The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add createdAt outside createLinkBodySchema parsing
Steven Teyca4d0a73ff26
diff --git a/apps/web/app/api/cron/import/csv/route.ts b/apps/web/app/api/cron/import/csv/route.tsindex aa4c597104..258d6f7798 100644--- a/apps/web/app/api/cron/import/csv/route.ts+++ b/apps/web/app/api/cron/import/csv/route.ts@@ -196,11 +196,14 @@ export async function POST(req: Request) {),...linksToCreate.map(({ createdAt, tags, ...link }) =>processLink({- payload: createLinkBodySchema.parse({- ...link,+ payload: {+ ...createLinkBodySchema.parse({+ ...link,+ tagNames: tags || undefined,+ }),+ // 'createdAt' is not a valid field in createLinkBodySchema – but is valid for CSV importscreatedAt: createdAt?.toISOString(),- tagNames: tags || undefined,- }),+ },workspace: workspace as WorkspaceProps,userId,bulk: true,diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex 15d0d97142..e9d0157bdc 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -64,7 +64,6 @@ export async function processLink<T extends Record<string, any>>({geo,doIndex,tagNames,- createdAt,} = payload;let expiresAt: string | Date | null | undefined = payload.expiresAt;@@ -98,11 +97,8 @@ export async function processLink<T extends Record<string, any>>({};}- // free plan restrictions (after Jan 19, 2024)- if (- (!workspace || workspace.plan === "free") &&- (!createdAt || new Date(createdAt) > new Date("2024-01-19"))- ) {+ // free plan restrictions+ if (!workspace || workspace.plan === "free") {if (key === "_root" && url) {return {link: payload,diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex 6658d567e1..b380c4cbf7 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -202,7 +202,8 @@ export const createLinkBodySchema = z.object({"The unique name of the tags assigned to the short link (case insensitive).",),comments: z.string().nullish().describe("The comments for the short link."),- expiresAt: parseDateSchema+ expiresAt: z+ .string().nullish().describe("The date and time when the short link will expire at."),expiredUrl: parseUrlSchema