Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Remove COUNTRY_CODES from OpenAPI spec

Steven Tey306dd1758bda
diff --git a/apps/web/lib/ai/generate-filters.ts b/apps/web/lib/ai/generate-filters.ts
index a2518f1046..199b6c8302 100644
--- a/apps/web/lib/ai/generate-filters.ts
+++ b/apps/web/lib/ai/generate-filters.ts
@@ -3,18 +3,32 @@
import { VALID_ANALYTICS_FILTERS } from "@/lib/analytics/constants";
import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";
import { anthropic } from "@ai-sdk/anthropic";
+import { COUNTRY_CODES } from "@dub/utils";
import { streamObject } from "ai";
import { createStreamableValue } from "ai/rsc";
+import z from "../zod";
export async function generateFilters(prompt: string) {
const stream = createStreamableValue();
- const schema = analyticsQuerySchema.pick({
- ...(VALID_ANALYTICS_FILTERS.reduce((acc, filter) => {
- acc[filter] = true;
- return acc;
- }, {}) as any),
- });
+ const schema = analyticsQuerySchema
+ .pick({
+ ...(VALID_ANALYTICS_FILTERS.reduce((acc, filter) => {
+ acc[filter] = true;
+ return acc;
+ }, {}) as any),
+ })
+ .merge(
+ z.object({
+ // polyfilling this here cause we're removing it from the main Analytics schema (to save space for our OpenAPI spec)
+ country: z
+ .enum(COUNTRY_CODES)
+ .optional()
+ .describe(
+ "The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information.",
+ ),
+ }),
+ );
(async () => {
const { partialObjectStream } = await streamObject({
diff --git a/apps/web/lib/cron/verify-vercel.ts b/apps/web/lib/cron/verify-vercel.ts
index a57c2063e6..ecb1f93a31 100644
--- a/apps/web/lib/cron/verify-vercel.ts
+++ b/apps/web/lib/cron/verify-vercel.ts
@@ -2,9 +2,9 @@ import { DubApiError } from "../api/errors";
export const verifyVercelSignature = async (req: Request) => {
// skip verification in local development
- if (process.env.VERCEL !== "1") {
- return;
- }
+ // if (process.env.VERCEL !== "1") {
+ // return;
+ // }
const authHeader = req.headers.get("authorization");
if (
diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.ts
index 2521d82d39..f93a5fed16 100644
--- a/apps/web/lib/zod/schemas/analytics.ts
+++ b/apps/web/lib/zod/schemas/analytics.ts
@@ -10,7 +10,6 @@ import { prefixWorkspaceId } from "@/lib/api/workspace-id";
import z from "@/lib/zod";
import {
CONTINENT_CODES,
- COUNTRY_CODES,
PAGINATION_LIMIT,
THE_BEGINNING_OF_TIME,
capitalize,
@@ -146,10 +145,10 @@ export const analyticsQuerySchema = z
)
.openapi({ example: "America/New_York", default: "UTC" }),
country: z
- .enum(COUNTRY_CODES)
+ .string()
.optional()
.describe(
- "The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. Learn more: https://d.to/geo",
+ "The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information.",
)
.openapi({ ref: "countryCode" }),
city: z
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index 945c9e23aa..6a7fd6991e 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -1,7 +1,6 @@
import { ErrorCode } from "@/lib/api/errors";
import z from "@/lib/zod";
import {
- COUNTRY_CODES,
THE_BEGINNING_OF_TIME,
formatDate,
validDomainRegex,
@@ -377,10 +376,10 @@ export const createLinkBodySchema = z.object({
"The Android destination URL for the short link for Android device targeting.",
),
geo: z
- .record(z.enum(COUNTRY_CODES), parseUrlSchema)
+ .record(z.string(), parseUrlSchema)
.nullish()
.describe(
- "Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`.",
+ "Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. See https://d.to/geo for more information.",
)
.openapi({ ref: "linkGeoTargeting" }),
doIndex: z
@@ -620,10 +619,10 @@ export const LinkSchema = z
"The Android destination URL for the short link for Android device targeting.",
),
geo: z
- .record(z.enum(COUNTRY_CODES), z.string().url())
+ .record(z.string(), z.string().url())
.nullable()
.describe(
- "Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. Learn more: https://d.to/geo",
+ "Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. See https://d.to/geo for more information.",
),
publicStats: z
.boolean()
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index b78c8a5c2f..ac1a86e26f 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -385,10 +385,10 @@ export const createPartnerSchema = z.object({
"The partner's unique ID in your system. Useful for retrieving the partner's links and stats later on. If not provided, the partner will be created as a standalone partner.",
),
country: z
- .enum(COUNTRY_CODES)
+ .string()
.nullish()
.describe(
- "The partner's country of residence. Must be passed as a 2-letter ISO 3166-1 country code. Learn more: https://d.to/geo",
+ "The partner's country of residence. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information.",
),
description: z
.string()