Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v19 is for Dime #1692

Merged
merged 65 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b6cd78e
Adjusting workflow triggers.
RobinTail Apr 22, 2024
4308342
Next: Drop support `zod` 3.22 (#1693)
RobinTail Apr 22, 2024
addfdae
Dedication: for Dime.
Apr 22, 2024
e02ea03
Merge branch 'master' into make-v19
RobinTail Apr 24, 2024
3aca212
Merge branch 'master' into make-v19
RobinTail Apr 25, 2024
c08f7b6
Drop Node below 18.18 (#1705)
RobinTail Apr 25, 2024
839668a
Changelog: 19.0.0 draft.
RobinTail Apr 25, 2024
f5178d6
Removing condition on compat test for jest in v19 (#1707)
RobinTail Apr 27, 2024
9d2e3dc
Drop Node 20 below 20.9.0 (#1708)
RobinTail Apr 27, 2024
7044d27
Merge branch 'master' into make-v19
RobinTail Apr 29, 2024
83c6912
Merge branch 'master' into make-v19
RobinTail Apr 30, 2024
90ec641
Rev: fixed swc code in compat test
RobinTail Apr 30, 2024
7315c83
Cancel rev: fixed swc core in compat test
RobinTail Apr 30, 2024
926a4f8
Merge branch 'master' into make-v19
RobinTail May 1, 2024
7d13dc7
Merge branch 'master' into make-v19
RobinTail May 3, 2024
4f7f31e
Merge branch 'master' into make-v19
RobinTail May 4, 2024
f66de3f
Removing the deprecated withMeta() (#1726)
RobinTail May 4, 2024
53ab7d3
Merge branch 'master' into make-v19
RobinTail May 4, 2024
3a29e71
Security: planning for June, deprecating v15
RobinTail May 4, 2024
81cb922
Merge branch 'master' into make-v19
RobinTail May 5, 2024
572ba79
Merge branch 'master' into make-v19
RobinTail May 6, 2024
ce3b2c1
Merge branch 'master' into make-v19
RobinTail May 7, 2024
2e0c2e1
Fix: freezing arrays returned by public methods (#1736)
RobinTail May 7, 2024
a780096
Merge branch 'master' into make-v19
RobinTail May 7, 2024
a2d5092
Merge branch 'master' into make-v19
RobinTail May 7, 2024
cc1fc6c
Merge branch 'master' into make-v19
RobinTail May 7, 2024
9cc3ec7
Feat: Selective parsers with child logger (#1741)
RobinTail May 8, 2024
5fbc249
Changelog: structuring the notes for 19.0.0.
RobinTail May 8, 2024
1a146fa
Readme: adjusting the beforeUpload example.
RobinTail May 8, 2024
e1e3d92
Merge branch 'master' into make-v19
RobinTail May 8, 2024
234fec6
Merge branch 'master' into make-v19
RobinTail May 9, 2024
4ef6ba6
Complete `zod` plugin with proprietary brands (#1730)
RobinTail May 9, 2024
93aa7b6
Automatic default raw parser (#1745)
RobinTail May 9, 2024
944eca1
19.0.0-beta.1
RobinTail May 9, 2024
976347f
Fix TS2527 for unique symbol (v19) (#1747)
RobinTail May 9, 2024
4cbbaa5
Reverting stict version for SWC core in compat test.
RobinTail May 9, 2024
fc97438
19.0.0-beta.2
RobinTail May 9, 2024
3ca5502
Logger adjustments for v19 (#1748)
RobinTail May 9, 2024
909d414
Ref: removing type argument from Metadata.
RobinTail May 9, 2024
d172bc7
Ref: unexposing Metadata (no longer needed after removing withMeta).
RobinTail May 9, 2024
ef64bab
Merge branch 'master' into make-v19
RobinTail May 10, 2024
51a55ba
Merge branch 'master' into make-v19
RobinTail May 10, 2024
ce7971f
19.0.0-beta.3
RobinTail May 10, 2024
f5d0f51
Readme: Notice on Zod Plugin.
RobinTail May 11, 2024
438e8f1
Readme: add plugin article to index.
RobinTail May 11, 2024
0c276c4
Merge branch 'master' into make-v19
RobinTail May 11, 2024
f6c5982
Merge branch 'master' into make-v19
RobinTail May 11, 2024
b6fccb4
Drop static options (#1755)
RobinTail May 11, 2024
2c33a66
Changelog: shortening.
RobinTail May 11, 2024
cb5fb58
19.0.0-beta.4
RobinTail May 11, 2024
6331783
Merge branch 'master' into make-v19
RobinTail May 11, 2024
8d32a37
Fix: child logger should be available when using `attachRouting()` (#…
RobinTail May 11, 2024
1345882
Merge branch 'master' into make-v19
RobinTail May 12, 2024
8162694
Merge branch 'master' into make-v19
RobinTail May 12, 2024
9a5f45e
Increasing minimal versions of express and upload peers (#1760)
RobinTail May 12, 2024
1548d84
Merge branch 'master' into make-v19
RobinTail May 12, 2024
28ed00e
Cleanup: Removing the requirement on configuring rawParser (#1762)
RobinTail May 12, 2024
7d39981
Fix test name.
RobinTail May 13, 2024
e1ca69e
Security: releasing earlier
RobinTail May 13, 2024
ba1e559
Changelog: reviewed
RobinTail May 13, 2024
3483635
Merge branch 'master' into make-v19
RobinTail May 13, 2024
9941017
19.0.0-beta.5
RobinTail May 13, 2024
6d84c5a
Notice: `beforeRouting` now called before parsing as well (#1766)
RobinTail May 13, 2024
2ad5b19
19.0.0-beta.6
RobinTail May 13, 2024
02a10ef
CI: no more PRs to v19
RobinTail May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
schedule:
- cron: '26 8 * * 1'

Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ name: Node.js CI

on:
push:
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.0.0, 18.x, 20.0.0, 20.x, 22.0.0, 22.x]
node-version: [18.18.0, 18.x, 20.9.0, 20.x, 22.0.0, 22.x]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Get yarn cache dir
Expand All @@ -41,13 +41,7 @@ jobs:
timeout_seconds: 15
max_attempts: 3
on_retry_command: yarn config set registry https://registry.npmjs.org
# todo use regular "yarn install" when min Node version increased to 18.18
# @typescript/eslint group compatibility issue fixed by ignoring engines for dev dependencies only:
command: |
npm pkg delete devDependencies
yarn install
git checkout -- .
yarn install --ignore-engines
command: yarn install
- name: Lint
run: yarn lint
- name: Test
Expand Down Expand Up @@ -75,15 +69,7 @@ jobs:
max_attempts: 3
on_retry_command: yarn config set registry https://registry.npmjs.org
command: yarn test:esm
- name: Check Jest 30 compatibility
uses: madhead/semver-utils@v4
id: jest30compat
with:
version: ${{ steps.setup-node.outputs.node-version }}
satisfies: '>=18.12.0'
lenient: false # require to parse or fail
- name: Compatibility test
if: steps.jest30compat.outputs.satisfies == 'true'
uses: nick-fields/retry@v3
with:
timeout_seconds: 15
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/swagger.yml
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: OpenAPI Validation

on:
push:
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [ master, v15, v16, v17 ]
branches: [ master, v16, v17, v18, make-v19 ]
RobinTail marked this conversation as resolved.
Show resolved Hide resolved


jobs:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Version 19

### v19.0.0

- Minimum supported versions:
- Node: 18.18.0 or 20.9.0,
- `zod`: 3.23.0.

## Version 18

### v18.3.0
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"*.md"
],
"engines": {
"node": "^18.0.0 || ^20.0.0 || ^22.0.0"
"node": "^18.18.0 || ^20.9.0 || ^22.0.0"
},
"dependencies": {
"ansis": "^3.1.0",
Expand All @@ -84,7 +84,7 @@
"prettier": "^3.1.0",
"typescript": "^5.1.3",
"vitest": "^1.0.4",
"zod": "^3.22.3"
"zod": "^3.23.0"
},
"peerDependenciesMeta": {
"@types/compression": {
Expand Down
12 changes: 6 additions & 6 deletions src/date-in-schema.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { z } from "zod";
import { proprietary } from "./metadata";
import { isValidDate, isoDateRegex } from "./schema-helpers";
import { isValidDate } from "./schema-helpers";

export const ezDateInKind = "DateIn";

export const dateIn = () => {
const base = z.string();
const hasDateMethod = base.date?.() instanceof z.ZodString;
const schema = hasDateMethod
? z.union([base.date(), base.datetime(), base.datetime({ local: true })])
: base.regex(isoDateRegex); // @todo remove after min zod v3.23 (v19)
const schema = z.union([
z.string().date(),
z.string().datetime(),
z.string().datetime({ local: true }),
]);

return proprietary(
ezDateInKind,
Expand Down
8 changes: 2 additions & 6 deletions src/documentation-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import {
} from "./logical-container";
import { Method } from "./method";
import { RawSchema, ezRawKind } from "./raw-schema";
import { isoDateRegex } from "./schema-helpers";
import {
HandlingRules,
HandlingVariant,
Expand Down Expand Up @@ -163,10 +162,7 @@ export const depictFile: Depicter<z.ZodType> = ({ schema }) => ({
type: "string",
format:
schema instanceof z.ZodString
? schema._def.checks.find(
/** @todo remove regex check when min zod v3.23 (v19) */
(check) => check.kind === "regex" || check.kind === "base64",
)
? schema._def.checks.find((check) => check.kind === "base64")
? "byte"
: "file"
: "binary",
Expand Down Expand Up @@ -331,7 +327,7 @@ export const depictDateIn: Depicter<z.ZodType> = (ctx) => {
description: "YYYY-MM-DDTHH:mm:ss.sssZ",
type: "string",
format: "date-time",
pattern: isoDateRegex.source,
pattern: /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?)?Z?$/.source,
externalDocs: {
url: isoDateDocumentationUrl,
},
Expand Down
15 changes: 1 addition & 14 deletions src/file-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,11 @@ const bufferSchema = z.custom<Buffer>((subject) => Buffer.isBuffer(subject), {
message: "Expected Buffer",
});

/** @todo remove after min zod v3.23 (v19) */
const base64Regex =
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;

const variants = {
buffer: () => proprietary(ezFileKind, bufferSchema),
string: () => proprietary(ezFileKind, z.string()),
binary: () => proprietary(ezFileKind, bufferSchema.or(z.string())),
base64: () => {
const base = z.string();
const hasBase64Method = base.base64?.() instanceof z.ZodString;
return proprietary(
ezFileKind,
hasBase64Method
? base.base64()
: base.regex(base64Regex, "Does not match base64 encoding"), // @todo remove after min zod v3.23 (v19)
);
},
base64: () => proprietary(ezFileKind, z.string().base64()),
};

type Variants = typeof variants;
Expand Down
11 changes: 0 additions & 11 deletions src/schema-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
export const isValidDate = (date: Date): boolean => !isNaN(date.getTime());

/**
* @example 2021-01-01T00:00:00.000Z
* @example 2021-01-01T00:00:00.0Z
* @example 2021-01-01T00:00:00Z
* @example 2021-01-01T00:00:00
* @example 2021-01-01
* @todo remove after min zod v3.23 (v19)
*/
export const isoDateRegex =
/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?)?Z?$/;
2 changes: 1 addition & 1 deletion src/startup-logo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getStartupLogo = () => {
const thanks = italic(
"Thank you for choosing Express Zod API for your project.".padStart(132),
);
const dedicationMessage = italic("for Victoria".padEnd(20));
const dedicationMessage = italic("for Dime".padEnd(20));

const pink = hex("#F5A9B8");
const blue = hex("#5BCEFA");
Expand Down
2 changes: 1 addition & 1 deletion tests/compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"jest": "^30.0.0-alpha.3",
"@types/jest": "^29.5.12",
"@swc/core": "^1.3.100",
"@swc/core": "^1.5.0",
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
"@swc/jest": "^0.2.29"
}
}
7 changes: 2 additions & 5 deletions tests/system/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("Example", async () => {
const data = new FormData();
data.append(
"avatar",
new Blob([logo], { type: "image/svg+xml" }), // FormData mime is buggy in Node 18.0.0
new Blob([logo], { type: "image/svg+xml" }),
filename,
);
data.append("str", "test string value");
Expand All @@ -212,10 +212,7 @@ describe("Example", async () => {
expect(json).toEqual({
data: {
hash: "f39beeff92379dc935586d726211c2620be6f879",
mime:
process.versions.node === "18.0.0"
? "application/octet-stream" // Node 18.0.0 FormData bug // @todo remove it when dropped
: "image/svg+xml",
mime: "image/svg+xml",
name: "logo.svg",
otherInputs: {
arr: ["456", "789"],
Expand Down
39 changes: 3 additions & 36 deletions tests/unit/__snapshots__/date-in-schema.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ez.dateIn() current mode > parsing > should handle invalid date 1`] = `
exports[`ez.dateIn() > parsing > should handle invalid date 1`] = `
[
{
"code": "invalid_string",
Expand All @@ -11,7 +11,7 @@ exports[`ez.dateIn() current mode > parsing > should handle invalid date 1`] = `
]
`;

exports[`ez.dateIn() current mode > parsing > should handle invalid format 1`] = `
exports[`ez.dateIn() > parsing > should handle invalid format 1`] = `
[
{
"code": "invalid_string",
Expand All @@ -22,7 +22,7 @@ exports[`ez.dateIn() current mode > parsing > should handle invalid format 1`] =
]
`;

exports[`ez.dateIn() current mode > parsing > should handle wrong parsed type 1`] = `
exports[`ez.dateIn() > parsing > should handle wrong parsed type 1`] = `
[
{
"code": "invalid_union",
Expand Down Expand Up @@ -60,36 +60,3 @@ exports[`ez.dateIn() current mode > parsing > should handle wrong parsed type 1`
},
]
`;

exports[`ez.dateIn() legacy mode > parsing > should handle invalid date 1`] = `
[
{
"code": "invalid_date",
"message": "Invalid date",
"path": [],
},
]
`;

exports[`ez.dateIn() legacy mode > parsing > should handle invalid format 1`] = `
[
{
"code": "invalid_string",
"message": "Invalid",
"path": [],
"validation": "regex",
},
]
`;

exports[`ez.dateIn() legacy mode > parsing > should handle wrong parsed type 1`] = `
[
{
"code": "invalid_type",
"expected": "string",
"message": "Expected string, received number",
"path": [],
"received": "number",
},
]
`;
13 changes: 1 addition & 12 deletions tests/unit/__snapshots__/file-schema.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ez.file() current mode > parsing > should perform additional check for base64 file 1`] = `
exports[`ez.file() > parsing > should perform additional check for base64 file 1`] = `
[
{
"code": "invalid_string",
Expand All @@ -10,14 +10,3 @@ exports[`ez.file() current mode > parsing > should perform additional check for
},
]
`;

exports[`ez.file() legacy mode > parsing > should perform additional check for base64 file 1`] = `
[
{
"code": "invalid_string",
"message": "Does not match base64 encoding",
"path": [],
"validation": "regex",
},
]
`;
13 changes: 2 additions & 11 deletions tests/unit/date-in-schema.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { z } from "zod";
import { getMeta } from "../../src/metadata";
import { ez } from "../../src";
import { beforeAll, describe, expect, test, vi } from "vitest";

describe.each(["current", "legacy"])("ez.dateIn() %s mode", (mode) => {
// @todo remove after min zod v3.23 (v19)
beforeAll(() => {
if (mode === "legacy") {
vi.spyOn(z.ZodString.prototype, "date").mockImplementation(
() => null as unknown as z.ZodString,
);
}
});
import { describe, expect, test } from "vitest";

describe("ez.dateIn()", () => {
describe("creation", () => {
test("should create an instance", () => {
const schema = ez.dateIn();
Expand Down
13 changes: 2 additions & 11 deletions tests/unit/file-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@ import { z } from "zod";
import { getMeta } from "../../src/metadata";
import { ez } from "../../src";
import { readFile } from "node:fs/promises";
import { beforeAll, describe, expect, test, vi } from "vitest";

describe.each(["current", "legacy"])("ez.file() %s mode", (mode) => {
// @todo remove after min zod v3.23 (v19)
beforeAll(() => {
if (mode === "legacy") {
vi.spyOn(z.ZodString.prototype, "base64").mockImplementation(
() => null as unknown as z.ZodString,
);
}
});
import { describe, expect, test } from "vitest";

describe("ez.file()", () => {
describe("creation", () => {
test("should create an instance being string by default", () => {
const schema = ez.file();
Expand Down
Loading