chore: upgrade deps and Zod v4 migration (#7425)

Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
Matti Nannt
2026-03-06 14:41:28 +01:00
committed by GitHub
parent 4860a9a5cf
commit afa192e5b9
219 changed files with 5379 additions and 5079 deletions
@@ -1,22 +1,23 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
extendZodWithOpenApi(z);
export const ZOverallHealthStatus = z
.object({
main_database: z.boolean().openapi({
description: "Main database connection status - true if database is reachable and running",
example: true,
}),
cache_database: z.boolean().openapi({
description: "Cache database connection status - true if cache database is reachable and running",
example: true,
}),
main_database: z
.boolean()
.meta({
example: true,
})
.describe("Main database connection status - true if database is reachable and running"),
cache_database: z
.boolean()
.meta({
example: true,
})
.describe("Cache database connection status - true if cache database is reachable and running"),
})
.openapi({
.meta({
title: "Health Check Response",
description: "Health check status for critical application dependencies",
});
})
.describe("Health check status for critical application dependencies");
export type OverallHealthStatus = z.infer<typeof ZOverallHealthStatus>;
@@ -1,26 +1,22 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZContactAttributeKey } from "@formbricks/database/zod/contact-attribute-keys";
extendZodWithOpenApi(z);
export const ZContactAttributeKeyIdSchema = z
.string()
.cuid2()
.openapi({
ref: "contactAttributeKeyId",
description: "The ID of the contact attribute key",
.meta({
id: "contactAttributeKeyId",
param: {
name: "id",
in: "path",
},
});
})
.describe("The ID of the contact attribute key");
export const ZContactAttributeKeyUpdateSchema = ZContactAttributeKey.pick({
name: true,
description: true,
}).openapi({
ref: "contactAttributeKeyUpdate",
}).meta({
id: "contactAttributeKeyUpdate",
description: "A contact attribute key to update. Key cannot be changed.",
});
@@ -17,7 +17,7 @@ export const getContactAttributeKeysEndpoint: ZodOpenApiOperationObject = {
description: "Gets contact attribute keys from the database.",
tags: ["Management API - Contact Attribute Keys"],
requestParams: {
query: ZGetContactAttributeKeysFilter.sourceType(),
query: ZGetContactAttributeKeysFilter,
},
responses: {
"200": {
@@ -17,7 +17,7 @@ export const GET = async (request: NextRequest) =>
authenticatedApiClient({
request,
schemas: {
query: ZGetContactAttributeKeysFilter.sourceType(),
query: ZGetContactAttributeKeysFilter,
},
handler: async ({ authentication, parsedInput }) => {
const { query } = parsedInput;
@@ -49,7 +49,7 @@ export const POST = async (request: NextRequest) =>
authenticatedApiClient({
request,
schemas: {
body: ZContactAttributeKeyInput.sourceType(),
body: ZContactAttributeKeyInput,
},
handler: async ({ authentication, parsedInput, auditLog }) => {
const { body } = parsedInput;
@@ -1,13 +1,10 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZContactAttributeKey } from "@formbricks/database/zod/contact-attribute-keys";
import { isSafeIdentifier } from "@/lib/utils/safe-identifier";
import { ZGetFilter } from "@/modules/api/v2/types/api-filter";
extendZodWithOpenApi(z);
export const ZGetContactAttributeKeysFilter = ZGetFilter.extend({
environmentId: z.string().cuid2().optional().describe("The environment ID to filter by"),
environmentId: z.cuid2().optional().describe("The environment ID to filter by"),
})
.refine(
(data) => {
@@ -37,15 +34,15 @@ export const ZContactAttributeKeyInput = ZContactAttributeKey.pick({
// Enforce safe identifier format for key
if (!isSafeIdentifier(data.key)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
code: "custom",
message:
"Key must be a safe identifier: only lowercase letters, numbers, and underscores, and must start with a letter",
path: ["key"],
});
}
})
.openapi({
ref: "contactAttributeKeyInput",
.meta({
id: "contactAttributeKeyInput",
description: "Input data for creating or updating a contact attribute",
});
@@ -1,25 +1,21 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZResponse } from "@formbricks/database/zod/responses";
extendZodWithOpenApi(z);
export const ZResponseIdSchema = z
.string()
.cuid2()
.openapi({
ref: "responseId",
description: "The ID of the response",
.meta({
id: "responseId",
param: {
name: "id",
in: "path",
},
});
})
.describe("The ID of the response");
export const ZResponseUpdateSchema = ZResponse.omit({
id: true,
surveyId: true,
}).openapi({
ref: "responseUpdate",
}).meta({
id: "responseUpdate",
description: "A response to update.",
});
@@ -13,7 +13,7 @@ export const getResponsesEndpoint: ZodOpenApiOperationObject = {
summary: "Get responses",
description: "Gets responses from the database.",
requestParams: {
query: ZGetResponsesFilter.sourceType(),
query: ZGetResponsesFilter,
},
tags: ["Management API - Responses"],
responses: {
@@ -19,7 +19,7 @@ export const GET = async (request: NextRequest) =>
authenticatedApiClient({
request,
schemas: {
query: ZGetResponsesFilter.sourceType(),
query: ZGetResponsesFilter,
},
handler: async ({ authentication, parsedInput }) => {
const { query } = parsedInput;
@@ -3,7 +3,7 @@ import { ZResponse } from "@formbricks/database/zod/responses";
import { ZGetFilter } from "@/modules/api/v2/types/api-filter";
export const ZGetResponsesFilter = ZGetFilter.extend({
surveyId: z.string().cuid2().optional(),
surveyId: z.cuid2().optional(),
contactId: z.string().optional(),
}).refine(
(data) => {
@@ -23,7 +23,7 @@ export const getPersonalizedSurveyLink: ZodOpenApiOperationObject = {
schema: makePartialSchema(
z.object({
data: z.object({
surveyUrl: z.string().url(),
surveyUrl: z.url(),
expiresAt: z
.string()
.nullable()
@@ -1,23 +1,18 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
extendZodWithOpenApi(z);
export const ZContactLinkParams = z.object({
surveyId: z
.string()
.cuid2()
.openapi({
description: "The ID of the survey",
.meta({
param: { name: "surveyId", in: "path" },
}),
})
.describe("The ID of the survey"),
contactId: z
.string()
.cuid2()
.openapi({
description: "The ID of the contact",
.meta({
param: { name: "contactId", in: "path" },
}),
})
.describe("The ID of the contact"),
});
export const ZContactLinkQuery = z.object({
@@ -1,24 +1,19 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZGetFilter } from "@/modules/api/v2/types/api-filter";
extendZodWithOpenApi(z);
export const ZContactLinksBySegmentParams = z.object({
surveyId: z
.string()
.cuid2()
.openapi({
description: "The ID of the survey",
.meta({
param: { name: "surveyId", in: "path" },
}),
})
.describe("The ID of the survey"),
segmentId: z
.string()
.cuid2()
.openapi({
description: "The ID of the segment",
.meta({
param: { name: "segmentId", in: "path" },
}),
})
.describe("The ID of the segment"),
});
export const ZContactLinksBySegmentQuery = ZGetFilter.pick({
@@ -30,7 +25,7 @@ export const ZContactLinksBySegmentQuery = ZGetFilter.pick({
.min(1)
.max(365)
.nullish()
.default(null)
.prefault(null)
.describe("Number of days until the generated JWT expires. If not provided, there is no expiration."),
attributeKeys: z
.string()
@@ -52,7 +47,7 @@ export type TContactWithAttributes = {
export const ZContactLinkResponse = z.object({
contactId: z.string().describe("The ID of the contact"),
surveyUrl: z.string().url().describe("Personalized survey link"),
surveyUrl: z.url().describe("Personalized survey link"),
expiresAt: z.string().nullable().describe("The date and time the link expires, null if no expiration"),
attributes: z.record(z.string(), z.string()).describe("The attributes of the contact"),
});
@@ -1,16 +1,12 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
extendZodWithOpenApi(z);
export const surveyIdSchema = z
.string()
.cuid2()
.openapi({
ref: "surveyId",
description: "The ID of the survey",
.meta({
id: "surveyId",
param: {
name: "id",
in: "path",
},
});
})
.describe("The ID of the survey");
@@ -1,15 +1,12 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZSurveyWithoutQuestionType } from "@formbricks/database/zod/surveys";
extendZodWithOpenApi(z);
export const ZGetSurveysFilter = z
.object({
limit: z.coerce.number().positive().min(1).max(100).optional().default(10),
skip: z.coerce.number().nonnegative().optional().default(0),
sortBy: z.enum(["createdAt", "updatedAt"]).optional().default("createdAt"),
order: z.enum(["asc", "desc"]).optional().default("desc"),
limit: z.coerce.number().positive().min(1).max(100).optional().prefault(10),
skip: z.coerce.number().nonnegative().optional().prefault(0),
sortBy: z.enum(["createdAt", "updatedAt"]).optional().prefault("createdAt"),
order: z.enum(["asc", "desc"]).optional().prefault("desc"),
startDate: z.coerce.date().optional(),
endDate: z.coerce.date().optional(),
surveyType: z.enum(["link", "app"]).optional(),
@@ -23,7 +20,7 @@ export const ZGetSurveysFilter = z
return true;
},
{
message: "startDate must be before endDate",
error: "startDate must be before endDate",
}
);
@@ -69,8 +66,8 @@ export const ZSurveyInput = ZSurveyWithoutQuestionType.pick({
inlineTriggers: true,
displayPercentage: true,
})
.openapi({
ref: "surveyInput",
.meta({
id: "surveyInput",
description: "A survey input object for creating or updating surveys",
});
@@ -1,20 +1,16 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZWebhook } from "@formbricks/database/zod/webhooks";
extendZodWithOpenApi(z);
export const ZWebhookIdSchema = z
.string()
.cuid2()
.openapi({
ref: "webhookId",
description: "The ID of the webhook",
.meta({
id: "webhookId",
param: {
name: "id",
in: "path",
},
});
})
.describe("The ID of the webhook");
export const ZWebhookUpdateSchema = ZWebhook.omit({
id: true,
@@ -22,7 +18,7 @@ export const ZWebhookUpdateSchema = ZWebhook.omit({
updatedAt: true,
environmentId: true,
secret: true,
}).openapi({
ref: "webhookUpdate",
}).meta({
id: "webhookUpdate",
description: "A webhook to update.",
});
@@ -13,7 +13,7 @@ export const getWebhooksEndpoint: ZodOpenApiOperationObject = {
summary: "Get webhooks",
description: "Gets webhooks from the database.",
requestParams: {
query: ZGetWebhooksFilter.sourceType(),
query: ZGetWebhooksFilter,
},
tags: ["Management API - Webhooks"],
responses: {
@@ -11,7 +11,7 @@ export const GET = async (request: NextRequest) =>
authenticatedApiClient({
request,
schemas: {
query: ZGetWebhooksFilter.sourceType(),
query: ZGetWebhooksFilter,
},
handler: async ({ authentication, parsedInput }) => {
const { query } = parsedInput;
@@ -3,7 +3,7 @@ import { ZWebhook } from "@formbricks/database/zod/webhooks";
import { ZGetFilter } from "@/modules/api/v2/types/api-filter";
export const ZGetWebhooksFilter = ZGetFilter.extend({
surveyIds: z.array(z.string().cuid2()).optional(),
surveyIds: z.array(z.cuid2()).optional(),
}).refine(
(data) => {
if (data.startDate && data.endDate && data.startDate > data.endDate) {
+1 -4
View File
@@ -1,6 +1,5 @@
import * as yaml from "yaml";
import { z } from "zod";
import { createDocument, extendZodWithOpenApi } from "zod-openapi";
import { createDocument } from "zod-openapi";
import { ZApiKeyData } from "@formbricks/database/zod/api-keys";
import { ZContact } from "@formbricks/database/zod/contact";
import { ZContactAttributeKey } from "@formbricks/database/zod/contact-attribute-keys";
@@ -27,8 +26,6 @@ import { rolePaths } from "@/modules/api/v2/roles/lib/openapi";
import { bulkContactPaths } from "@/modules/ee/contacts/api/v2/management/contacts/bulk/lib/openapi";
import { contactPaths } from "@/modules/ee/contacts/api/v2/management/contacts/lib/openapi";
extendZodWithOpenApi(z);
const document = createDocument({
openapi: "3.1.0",
info: {
@@ -14,7 +14,7 @@ export const getProjectTeamsEndpoint: ZodOpenApiOperationObject = {
summary: "Get project teams",
description: "Gets projectTeams from the database.",
requestParams: {
query: ZGetProjectTeamsFilter.sourceType(),
query: ZGetProjectTeamsFilter,
path: z.object({
organizationId: ZOrganizationIdSchema,
}),
@@ -24,7 +24,7 @@ export async function GET(request: Request, props: { params: Promise<{ organizat
return authenticatedApiClient({
request,
schemas: {
query: ZGetProjectTeamsFilter.sourceType(),
query: ZGetProjectTeamsFilter,
params: z.object({ organizationId: ZOrganizationIdSchema }),
},
externalParams: props.params,
@@ -3,8 +3,8 @@ import { ZProjectTeam } from "@formbricks/database/zod/project-teams";
import { ZGetFilter } from "@/modules/api/v2/types/api-filter";
export const ZGetProjectTeamsFilter = ZGetFilter.extend({
teamId: z.string().cuid2().optional(),
projectId: z.string().cuid2().optional(),
teamId: z.cuid2().optional(),
projectId: z.cuid2().optional(),
}).refine(
(data) => {
if (data.startDate && data.endDate && data.startDate > data.endDate) {
@@ -28,8 +28,8 @@ export const ZProjectTeamInput = ZProjectTeam.pick({
export type TProjectTeamInput = z.infer<typeof ZProjectTeamInput>;
export const ZGetProjectTeamUpdateFilter = z.object({
teamId: z.string().cuid2(),
projectId: z.string().cuid2(),
teamId: z.cuid2(),
projectId: z.cuid2(),
});
export const ZProjectZTeamUpdateSchema = ZProjectTeam.pick({
@@ -1,20 +1,16 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
import { ZTeam } from "@formbricks/database/zod/teams";
extendZodWithOpenApi(z);
export const ZTeamIdSchema = z
.string()
.cuid2()
.openapi({
ref: "teamId",
description: "The ID of the team",
.meta({
id: "teamId",
param: {
name: "id",
in: "path",
},
});
})
.describe("The ID of the team");
export const ZTeamUpdateSchema = ZTeam.omit({
id: true,
@@ -21,7 +21,7 @@ export const getTeamsEndpoint: ZodOpenApiOperationObject = {
path: z.object({
organizationId: ZOrganizationIdSchema,
}),
query: ZGetTeamsFilter.sourceType(),
query: ZGetTeamsFilter,
},
tags: ["Organizations API - Teams"],
responses: {
@@ -16,7 +16,7 @@ export const GET = async (request: NextRequest, props: { params: Promise<{ organ
authenticatedApiClient({
request,
schemas: {
query: ZGetTeamsFilter.sourceType(),
query: ZGetTeamsFilter,
params: z.object({ organizationId: ZOrganizationIdSchema }),
},
externalParams: props.params,
@@ -1,16 +1,12 @@
import { z } from "zod";
import { extendZodWithOpenApi } from "zod-openapi";
extendZodWithOpenApi(z);
export const ZOrganizationIdSchema = z
.string()
.cuid2()
.openapi({
ref: "organizationId",
description: "The ID of the organization",
.meta({
id: "organizationId",
param: {
name: "organizationId",
in: "path",
},
});
})
.describe("The ID of the organization");
@@ -17,7 +17,7 @@ export const getUsersEndpoint: ZodOpenApiOperationObject = {
path: z.object({
organizationId: ZOrganizationIdSchema,
}),
query: ZGetUsersFilter.sourceType(),
query: ZGetUsersFilter,
},
tags: ["Organizations API - Users"],
responses: {
@@ -24,7 +24,7 @@ export const GET = async (request: NextRequest, props: { params: Promise<{ organ
authenticatedApiClient({
request,
schemas: {
query: ZGetUsersFilter.sourceType(),
query: ZGetUsersFilter,
params: z.object({ organizationId: ZOrganizationIdSchema }),
},
externalParams: props.params,
+4 -4
View File
@@ -1,10 +1,10 @@
import { z } from "zod";
export const ZGetFilter = z.object({
limit: z.coerce.number().min(1).max(250).optional().default(50).describe("Number of items to return"),
skip: z.coerce.number().min(0).optional().default(0).describe("Number of items to skip"),
sortBy: z.enum(["createdAt", "updatedAt"]).optional().default("createdAt").describe("Sort by field"),
order: z.enum(["asc", "desc"]).optional().default("desc").describe("Sort order"),
limit: z.coerce.number().min(1).max(250).optional().prefault(50).describe("Number of items to return"),
skip: z.coerce.number().min(0).optional().prefault(0).describe("Number of items to skip"),
sortBy: z.enum(["createdAt", "updatedAt"]).optional().prefault("createdAt").describe("Sort by field"),
order: z.enum(["asc", "desc"]).optional().prefault("desc").describe("Sort order"),
startDate: z.coerce.date().optional().describe("Start date"),
endDate: z.coerce.date().optional().describe("End date"),
filterDateField: z.enum(["createdAt", "updatedAt"]).optional().describe("Date field to filter by"),
@@ -1,6 +1,6 @@
import { z } from "zod";
export function responseWithMetaSchema<T extends z.ZodTypeAny>(contentSchema: T) {
export function responseWithMetaSchema<T extends z.ZodType>(contentSchema: T) {
return z.object({
data: z.array(contentSchema).optional(),
meta: z