Skip to content

Commit

Permalink
fix: cuid validation 🚨 (formbricks#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-hoebenreich authored Sep 12, 2024
1 parent c53b58c commit 688dc25
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions packages/types/displays.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { z } from "zod";

export const ZDisplay = z.object({
id: z.string().cuid(),
id: z.string().cuid2(),
createdAt: z.date(),
updatedAt: z.date(),
personId: z.string().cuid().nullable(),
surveyId: z.string().cuid(),
responseId: z.string().cuid().nullable(),
personId: z.string().cuid2().nullable(),
surveyId: z.string().cuid2(),
responseId: z.string().cuid2().nullable(),
status: z.enum(["seen", "responded"]).nullable(),
});

export type TDisplay = z.infer<typeof ZDisplay>;

export const ZDisplayCreateInput = z.object({
environmentId: z.string().cuid(),
surveyId: z.string().cuid(),
environmentId: z.string().cuid2(),
surveyId: z.string().cuid2(),
userId: z.string().optional(),
responseId: z.string().cuid().optional(),
responseId: z.string().cuid2().optional(),
});

export type TDisplayCreateInput = z.infer<typeof ZDisplayCreateInput>;

export const ZDisplayUpdateInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
userId: z.string().optional(),
responseId: z.string().cuid().optional(),
responseId: z.string().cuid2().optional(),
});

export type TDisplayUpdateInput = z.infer<typeof ZDisplayUpdateInput>;
Expand All @@ -42,7 +42,7 @@ export const ZDisplayFilters = z.object({
max: z.date().optional(),
})
.optional(),
responseIds: z.array(z.string().cuid()).optional(),
responseIds: z.array(z.string().cuid2()).optional(),
});

export type TDisplayFilters = z.infer<typeof ZDisplayFilters>;
22 changes: 11 additions & 11 deletions packages/types/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type TSurveyWithTriggers = z.infer<typeof ZSurveyWithTriggers>;

export const ZJSWebsiteStateDisplay = z.object({
createdAt: z.date(),
surveyId: z.string().cuid(),
surveyId: z.string().cuid2(),
responded: z.boolean(),
});

Expand Down Expand Up @@ -65,14 +65,14 @@ export const ZJsWebsiteState = z.object({
export type TJsWebsiteState = z.infer<typeof ZJsWebsiteState>;

export const ZJsWebsiteSyncInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
version: z.string().optional(),
});

export type TJsWebsiteSyncInput = z.infer<typeof ZJsWebsiteSyncInput>;

export const ZJsWebsiteConfig = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
state: ZJsWebsiteState,
expiresAt: z.date(),
Expand All @@ -82,7 +82,7 @@ export const ZJsWebsiteConfig = z.object({
export type TJsWebsiteConfig = z.infer<typeof ZJsWebsiteConfig>;

export const ZJSAppConfig = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
userId: z.string(),
state: ZJsAppState,
Expand All @@ -93,7 +93,7 @@ export const ZJSAppConfig = z.object({
export type TJSAppConfig = z.infer<typeof ZJSAppConfig>;

export const ZJsWebsiteConfigUpdateInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
state: ZJsWebsiteState,
expiresAt: z.date(),
Expand All @@ -103,7 +103,7 @@ export const ZJsWebsiteConfigUpdateInput = z.object({
export type TJsWebsiteConfigUpdateInput = z.infer<typeof ZJsWebsiteConfigUpdateInput>;

export const ZJsAppConfigUpdateInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
userId: z.string(),
state: ZJsAppState,
Expand All @@ -114,7 +114,7 @@ export const ZJsAppConfigUpdateInput = z.object({
export type TJsAppConfigUpdateInput = z.infer<typeof ZJsAppConfigUpdateInput>;

export const ZJsWebsiteConfigInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
errorHandler: z.function().args(z.any()).returns(z.void()).optional(),
attributes: z.record(z.string()).optional(),
Expand All @@ -123,7 +123,7 @@ export const ZJsWebsiteConfigInput = z.object({
export type TJsWebsiteConfigInput = z.infer<typeof ZJsWebsiteConfigInput>;

export const ZJsAppConfigInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
errorHandler: z.function().args(z.any()).returns(z.void()).optional(),
userId: z.string(),
Expand All @@ -133,7 +133,7 @@ export const ZJsAppConfigInput = z.object({
export type TJsAppConfigInput = z.infer<typeof ZJsAppConfigInput>;

export const ZJsPeopleUserIdInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
userId: z.string().min(1).max(255),
version: z.string().optional(),
});
Expand All @@ -154,7 +154,7 @@ export const ZJsPeopleAttributeInput = z.object({
export type TJsPeopleAttributeInput = z.infer<typeof ZJsPeopleAttributeInput>;

export const ZJsActionInput = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
userId: z.string().optional(),
name: z.string(),
});
Expand All @@ -166,7 +166,7 @@ export const ZJsWesbiteActionInput = ZJsActionInput.omit({ userId: true });
export type TJsWesbiteActionInput = z.infer<typeof ZJsWesbiteActionInput>;

export const ZJsAppSyncParams = z.object({
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
apiHost: z.string(),
userId: z.string(),
attributes: ZAttributes.optional(),
Expand Down
2 changes: 1 addition & 1 deletion packages/types/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type TAccessType = z.infer<typeof ZAccessType>;

export const ZStorageRetrievalParams = z.object({
fileName: z.string(),
environmentId: z.string().cuid(),
environmentId: z.string().cuid2(),
accessType: ZAccessType,
});

Expand Down

0 comments on commit 688dc25

Please sign in to comment.