Skip to content

Commit d382ab3

Browse files
committed
Migrate zod and associated dependencies to v4
1 parent 63eb78a commit d382ab3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3032
-4015
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@typescript-eslint/eslint-plugin": "^8.0.1",
4949
"@typescript-eslint/parser": "^8.0.1",
5050
"@vitejs/plugin-react": "^4.3.1",
51-
"@vitest/coverage-istanbul": "3.1.2",
51+
"@vitest/coverage-istanbul": "^3.1.2",
5252
"@vitest/ui": "^3.1.2",
5353
"aws-sdk-client-mock": "^4.1.0",
5454
"concurrently": "^9.1.2",
@@ -86,10 +86,10 @@
8686
"typescript": "^5.8.3",
8787
"typescript-eslint": "^8.31.0",
8888
"vite-tsconfig-paths": "^5.0.1",
89-
"vitest": "^3.1.2",
89+
"vitest": "^3.2.4",
9090
"yarn-upgrade-all": "^0.7.5"
9191
},
9292
"resolutions": {
9393
"pdfjs-dist": "^4.8.69"
9494
}
95-
}
95+
}

src/api/build.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const commonParams = {
4141
const require = topLevelCreateRequire(import.meta.url);
4242
const __filename = fileURLToPath(import.meta.url);
4343
const __dirname = path.dirname(__filename);
44-
import "zod-openapi/extend";
4544
`.trim(),
4645
}, // Banner for compatibility with CommonJS
4746
plugins: [
@@ -60,7 +59,6 @@ const commonParams = {
6059
},
6160
}),
6261
],
63-
inject: [resolve(process.cwd(), "./zod-openapi-patch.js")],
6462
};
6563
esbuild
6664
.build({

src/api/components/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { AppRoles } from "common/roles.js";
22
import { FastifyZodOpenApiSchema } from "fastify-zod-openapi";
3-
import { z } from "zod";
3+
import * as z from "zod/v4";
44

55
export const ts = z.coerce
66
.number()
77
.min(0)
88
.optional()
9-
.openapi({ description: "Staleness bound", example: 0 });
10-
export const groupId = z.string().min(1).openapi({
9+
.meta({ description: "Staleness bound", example: 0 });
10+
export const groupId = z.string().min(1).meta({
1111
description: "Entra ID Group ID",
1212
example: "d8cbb7c9-2f6d-4b7e-8ba6-b54f8892003b",
1313
});

src/api/esbuild.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const buildOptions = {
3535
const require = topLevelCreateRequire(import.meta.url);
3636
const __filename = fileURLToPath(import.meta.url);
3737
const __dirname = path.dirname(__filename);
38-
import "zod-openapi/extend";
3938
`.trim(),
4039
}, // Banner for compatibility with CommonJS
4140
plugins: [

src/api/functions/auditLog.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ function buildMarshalledAuditLogItem(entry: AuditLogEntry) {
2020
const expireAt =
2121
timestamp + Math.floor((RETENTION_DAYS * 24 * 60 * 60 * 1000) / 1000);
2222

23-
return marshall({
24-
...entry,
25-
createdAt: timestamp,
26-
expireAt,
27-
});
23+
return marshall(
24+
{
25+
...entry,
26+
createdAt: timestamp,
27+
expireAt,
28+
},
29+
{ removeUndefinedValues: true },
30+
);
2831
}
2932

3033
export async function createAuditLogEntry({

src/api/functions/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from "zod";
1+
import * as z from "zod/v4";
22

33
export function validateEmail(email: string): boolean {
44
const emailSchema = z.string().email();

src/api/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint import/no-nodejs-modules: ["error", {"allow": ["crypto"]}] */
2-
import "zod-openapi/extend";
2+
33
import { randomUUID } from "crypto";
44
import fastify, { FastifyInstance } from "fastify";
55
import FastifyAuthProvider from "@fastify/auth";
@@ -126,6 +126,7 @@ async function init(prettyPrint: boolean = false) {
126126
description: "QA API server",
127127
},
128128
],
129+
129130
tags: [
130131
{
131132
name: "Events",
@@ -177,6 +178,7 @@ async function init(prettyPrint: boolean = false) {
177178
description: "Manage the lifecycle of API keys.",
178179
},
179180
],
181+
180182
openapi: "3.1.0" satisfies ZodOpenApiVersion, // If this is not specified, it will default to 3.1.0
181183
components: {
182184
securitySchemes: {

src/api/lambda.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "zod-openapi/extend";
21
import awsLambdaFastify, { LambdaResponse } from "@fastify/aws-lambda";
32
import init from "./index.js";
43
import warmer from "lambda-warmer";

src/api/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"fastify": "^5.3.2",
4545
"fastify-plugin": "^5.0.1",
4646
"fastify-raw-body": "^5.0.0",
47-
"fastify-zod-openapi": "^4.1.1",
47+
"fastify-zod-openapi": "^5.0.1",
4848
"handlebars": "^4.7.8",
4949
"ical-generator": "^8.1.1",
5050
"ioredis": "^5.6.1",
@@ -60,8 +60,7 @@
6060
"qrcode": "^1.5.4",
6161
"stripe": "^18.0.0",
6262
"uuid": "^11.1.0",
63-
"zod": "^3.24.3",
64-
"zod-openapi": "^4.2.4",
63+
"zod": "^3.25.73",
6564
"zod-validation-error": "^3.3.1"
6665
},
6766
"devDependencies": {

src/api/routes/apiKey.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
DatabaseInsertError,
2222
ValidationError,
2323
} from "common/errors/index.js";
24-
import { z } from "zod";
24+
import * as z from "zod/v4";
2525
import { AvailableSQSFunctions, SQSPayload } from "common/types/sqsMessage.js";
2626
import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
2727

@@ -71,7 +71,7 @@ const apiKeyRoute: FastifyPluginAsync = async (fastify, _options) => {
7171
{
7272
Put: {
7373
TableName: genericConfig.ApiKeyTable,
74-
Item: marshall(apiKeyPayload),
74+
Item: marshall(apiKeyPayload, { removeUndefinedValues: true }),
7575
ConditionExpression: "attribute_not_exists(keyId)",
7676
},
7777
},
@@ -145,7 +145,7 @@ If you did not create this API key, please secure your account and notify the AC
145145
withTags(["API Keys"], {
146146
summary: "Delete an organization API key.",
147147
params: z.object({
148-
keyId: z.string().min(1).openapi({
148+
keyId: z.string().min(1).meta({
149149
description:
150150
"Key ID to delete. The key ID is the second segment of the API key.",
151151
}),

0 commit comments

Comments
 (0)