@neondatabase/config 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,6 +133,32 @@ declare const functionDefSchema: z.ZodObject<{
133
133
  declare const bucketDefSchema: z.ZodObject<{
134
134
  access: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"private">, z.ZodLiteral<"public_read">]>>;
135
135
  }, z.core.$strict>;
136
+ /**
137
+ * Functions record with trigger-name uniqueness. Used as both top-level `functions`
138
+ * and `preview.functions` so {@link previewInputSchema} (`schemas.preview`) keeps the
139
+ * same validation when parsed on its own.
140
+ */
141
+ declare const functionsRecordSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
142
+ name: z.ZodString;
143
+ source: z.ZodString;
144
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
145
+ externalPackages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
146
+ name: z.ZodString;
147
+ includeFiles: z.ZodOptional<z.ZodBoolean>;
148
+ }, z.core.$strict>]>>>;
149
+ bundler: z.ZodOptional<z.ZodCustom<FunctionBundlerInput, FunctionBundlerInput>>;
150
+ dev: z.ZodOptional<z.ZodObject<{
151
+ port: z.ZodOptional<z.ZodNumber>;
152
+ }, z.core.$strict>>;
153
+ triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
154
+ type: z.ZodLiteral<"schedule">;
155
+ name: z.ZodString;
156
+ cron: z.ZodString;
157
+ functionPath: z.ZodOptional<z.ZodString>;
158
+ enabled: z.ZodOptional<z.ZodBoolean>;
159
+ }, z.core.$strict>>>;
160
+ customDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
161
+ }, z.core.$strict>>;
136
162
  /** Static, beta Preview feature set: AI Gateway toggle + functions/buckets records. */
137
163
  declare const previewInputSchema: z.ZodObject<{
138
164
  aiGateway: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
@@ -183,6 +209,10 @@ declare const branchTuningSchema: z.ZodObject<{
183
209
  suspendTimeout: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodString, z.ZodNumber]>>;
184
210
  }, z.core.$strict>>;
185
211
  }, z.core.$strict>>;
212
+ functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
213
+ runtime: z.ZodOptional<z.ZodLiteral<"nodejs24">>;
214
+ customDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
215
+ }, z.core.$strict>>>;
186
216
  preview: z.ZodOptional<z.ZodObject<{
187
217
  functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
188
218
  runtime: z.ZodOptional<z.ZodLiteral<"nodejs24">>;
@@ -218,6 +248,33 @@ declare const configInputSchema: z.ZodObject<{
218
248
  serverTimingEnabled: z.ZodOptional<z.ZodBoolean>;
219
249
  }, z.core.$strict>>;
220
250
  }, z.core.$strict>]>>;
251
+ aiGateway: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
252
+ enabled: z.ZodOptional<z.ZodBoolean>;
253
+ }, z.core.$strict>]>>;
254
+ functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
255
+ name: z.ZodString;
256
+ source: z.ZodString;
257
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
258
+ externalPackages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
259
+ name: z.ZodString;
260
+ includeFiles: z.ZodOptional<z.ZodBoolean>;
261
+ }, z.core.$strict>]>>>;
262
+ bundler: z.ZodOptional<z.ZodCustom<FunctionBundlerInput, FunctionBundlerInput>>;
263
+ dev: z.ZodOptional<z.ZodObject<{
264
+ port: z.ZodOptional<z.ZodNumber>;
265
+ }, z.core.$strict>>;
266
+ triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
267
+ type: z.ZodLiteral<"schedule">;
268
+ name: z.ZodString;
269
+ cron: z.ZodString;
270
+ functionPath: z.ZodOptional<z.ZodString>;
271
+ enabled: z.ZodOptional<z.ZodBoolean>;
272
+ }, z.core.$strict>>>;
273
+ customDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
274
+ }, z.core.$strict>>>;
275
+ buckets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
276
+ access: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"private">, z.ZodLiteral<"public_read">]>>;
277
+ }, z.core.$strict>>>;
221
278
  preview: z.ZodOptional<z.ZodObject<{
222
279
  aiGateway: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
223
280
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -260,5 +317,5 @@ declare const configInputSchema: z.ZodObject<{
260
317
  */
261
318
  declare function formatZodIssues(error: z.ZodError): string[];
262
319
  //#endregion
263
- export { branchTuningSchema, bucketDefSchema, computeSettingsSchema, configInputSchema, dataApiConfigSchema, dataApiInputSchema, dataApiSettingsSchema, formatZodIssues, functionDefSchema, functionTuningSchema, postgresConfigSchema, previewInputSchema, serviceToggleInputSchema, serviceToggleSchema };
320
+ export { branchTuningSchema, bucketDefSchema, computeSettingsSchema, configInputSchema, dataApiConfigSchema, dataApiInputSchema, dataApiSettingsSchema, formatZodIssues, functionDefSchema, functionTuningSchema, functionsRecordSchema, postgresConfigSchema, previewInputSchema, serviceToggleInputSchema, serviceToggleSchema };
264
321
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/lib/schema.ts"],"mappings":";;;;;;;AAkCA;AAsDG;;;;;;;;;;AAAA;AAtD+B,cAArB,qBAAqB,EAAA,CAAA,CAAA,SAAA,CAAA;EAAA,qBAAA,eAAA,aAAA,CAAA,CAAA,GAAA,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,GAAA,GAAA,CAAA,GAAA,CAAA,GAAA,CAAA,GAAA,CAAA,GAAA,C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GAiDD,CAAA,CAAA,IAAA,CAAA;;cAGW,sBAAoB,CAAA,CAAA;;;GAG/B,CAAA,CAAA,IAAA,CAAA;;;;;cAWW,oBAAkB,CAAA,CAAA;;;;;;;;;;EAlE5B,CAAA,gBAAA,CAAA,CAAA;EApF2B,SAAA,eAAA,YAAA,YAAA,aAAA,CAAA;IAAA,OAAA,eAAA,aAAA,CAAA,UAAA,CAAA,CAAA;IAuFjB,aAAA,eAIX,WAAA,YAAA,CAAA,CAAA;EAAA,CAAA,gBAAA,CAAA,CAAA,CAAA;;;;;IAAA,CAAA,gBAAA,CAAA,CAAA,CAAA;EAJ0B,CAAA,gBAAA,CAAA,CAAA;AAAA,CAAA,EA+FzB,CAAA,CAAA,IAAA,CAAA,OA/FyB,CAAA;AAW5B;AA4BG;AA5B+B;;;cA2FrB,mBAAiB,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA/D3B,IAAA,eAAA,YAAA,CAAA;IA5B+B,CAAA,gBAAA,CAAA,CAAA;IAAA,QAAA,eAAA,WAAA,YAAA,CAAA;MAAA,IAAA,cAAA,CAAA,UAAA,CAAA;MA+BrB,IAAA,aAIX;MAAA,IAAA,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiEmB,CAAA,CAAA,YAAA,CAAA,CAAA;GAyClB,CAAA,CAAA,IAAA,CAAA;;;;;;;;;;iBAuEa,eAAA,QAAuB,CAAA,CAAE"}
@@ -121,12 +121,12 @@ const postgresConfigSchema = z.strictObject({ computeSettings: computeSettingsSc
121
121
  /**
122
122
  * Branch-unique function slug. Mirrors the Neon Functions API path-segment rule
123
123
  * (`platform/internal/platform/functions/name.go`): 1–20 lowercase letters and digits.
124
- * Used as the **key schema** of the `preview.functions` record, so a bad slug fails
124
+ * Used as the **key schema** of the `functions` record, so a bad slug fails
125
125
  * validation with a path pointing at the offending key and duplicate slugs are impossible
126
126
  * by construction (object keys are unique).
127
127
  */
128
128
  const functionSlugSchema = z.string().regex(/^[a-z0-9]{1,20}$/, "function slug must be 1-20 lowercase letters and digits (no hyphens or other characters)");
129
- /** Bucket name: 1–255 chars. Used as the key schema of the `preview.buckets` record. */
129
+ /** Bucket name: 1–255 chars. Used as the key schema of the `buckets` record. */
130
130
  const bucketNameSchema = z.string().min(1).max(255);
131
131
  /**
132
132
  * A single function environment-variable value. Must be a defined string: a `process.env.X`
@@ -313,21 +313,20 @@ const functionDefSchema = z.strictObject({
313
313
  });
314
314
  /** Static definition of a bucket (existence). Name is the record key. */
315
315
  const bucketDefSchema = z.strictObject({ access: z.union([z.literal("private"), z.literal("public_read")]).optional() });
316
- /** Static, beta Preview feature set: AI Gateway toggle + functions/buckets records. */
317
- const previewInputSchema = z.strictObject({
318
- aiGateway: serviceToggleInputSchema.optional(),
319
- functions: z.record(functionSlugSchema, functionDefSchema).optional(),
320
- buckets: z.record(bucketNameSchema, bucketDefSchema).optional()
321
- }).superRefine((preview, ctx) => {
316
+ /**
317
+ * Functions record with trigger-name uniqueness. Used as both top-level `functions`
318
+ * and `preview.functions` so {@link previewInputSchema} (`schemas.preview`) keeps the
319
+ * same validation when parsed on its own.
320
+ */
321
+ const functionsRecordSchema = z.record(functionSlugSchema, functionDefSchema).superRefine((functions, ctx) => {
322
322
  const byName = /* @__PURE__ */ new Map();
323
- for (const [slug, fn] of Object.entries(preview.functions ?? {})) {
323
+ for (const [slug, fn] of Object.entries(functions)) {
324
324
  const seenOnFn = /* @__PURE__ */ new Set();
325
325
  for (const [index, trigger] of (fn.triggers ?? []).entries()) {
326
326
  if (seenOnFn.has(trigger.name)) {
327
327
  ctx.addIssue({
328
328
  code: "custom",
329
329
  path: [
330
- "functions",
331
330
  slug,
332
331
  "triggers",
333
332
  index,
@@ -343,7 +342,6 @@ const previewInputSchema = z.strictObject({
343
342
  ctx.addIssue({
344
343
  code: "custom",
345
344
  path: [
346
- "functions",
347
345
  slug,
348
346
  "triggers",
349
347
  index,
@@ -357,6 +355,12 @@ const previewInputSchema = z.strictObject({
357
355
  }
358
356
  }
359
357
  });
358
+ /** Static, beta Preview feature set: AI Gateway toggle + functions/buckets records. */
359
+ const previewInputSchema = z.strictObject({
360
+ aiGateway: serviceToggleInputSchema.optional(),
361
+ functions: functionsRecordSchema.optional(),
362
+ buckets: z.record(bucketNameSchema, bucketDefSchema).optional()
363
+ });
360
364
  /** Per-function deploy tuning returned by the `branch` closure. */
361
365
  const functionTuningSchema = z.strictObject({
362
366
  runtime: runtimeSchema.optional(),
@@ -380,6 +384,7 @@ const branchTuningSchema = z.strictObject({
380
384
  });
381
385
  }),
382
386
  postgres: postgresConfigSchema.optional(),
387
+ functions: z.record(functionSlugSchema, functionTuningSchema).optional(),
383
388
  preview: previewTuningSchema.optional()
384
389
  }).superRefine((cfg, ctx) => {
385
390
  validateParentReference({
@@ -387,6 +392,12 @@ const branchTuningSchema = z.strictObject({
387
392
  path: ["parent"],
388
393
  parent: cfg.parent
389
394
  });
395
+ rejectDuplicateHome(ctx, {
396
+ gaPresent: cfg.functions !== void 0,
397
+ previewPresent: cfg.preview?.functions !== void 0,
398
+ gaPath: "functions",
399
+ previewPath: "preview.functions"
400
+ });
390
401
  });
391
402
  /**
392
403
  * The top-level object accepted by `defineConfig`. The `branch` closure is validated
@@ -396,9 +407,30 @@ const branchTuningSchema = z.strictObject({
396
407
  const configInputSchema = z.strictObject({
397
408
  auth: serviceToggleInputSchema.optional(),
398
409
  dataApi: dataApiInputSchema.optional(),
410
+ aiGateway: serviceToggleInputSchema.optional(),
411
+ functions: functionsRecordSchema.optional(),
412
+ buckets: z.record(bucketNameSchema, bucketDefSchema).optional(),
399
413
  preview: previewInputSchema.optional(),
400
414
  branch: z.custom((value) => typeof value === "function", { message: "branch must be a function: `branch: (branch) => ({ … })`" }).optional()
401
415
  }).superRefine((cfg, ctx) => {
416
+ rejectDuplicateHome(ctx, {
417
+ gaPresent: cfg.aiGateway !== void 0,
418
+ previewPresent: cfg.preview?.aiGateway !== void 0,
419
+ gaPath: "aiGateway",
420
+ previewPath: "preview.aiGateway"
421
+ });
422
+ rejectDuplicateHome(ctx, {
423
+ gaPresent: cfg.functions !== void 0,
424
+ previewPresent: cfg.preview?.functions !== void 0,
425
+ gaPath: "functions",
426
+ previewPath: "preview.functions"
427
+ });
428
+ rejectDuplicateHome(ctx, {
429
+ gaPresent: cfg.buckets !== void 0,
430
+ previewPresent: cfg.preview?.buckets !== void 0,
431
+ gaPath: "buckets",
432
+ previewPath: "preview.buckets"
433
+ });
402
434
  if (!isToggleEnabledValue(cfg.dataApi)) return;
403
435
  if (dataApiAuthProviderValue(cfg.dataApi) !== "neon") return;
404
436
  if (!isToggleEnabledValue(cfg.auth)) ctx.addIssue({
@@ -407,6 +439,14 @@ const configInputSchema = z.strictObject({
407
439
  message: "dataApi with authProvider \"neon\" requires Neon Auth — set `auth: true` (or `auth: { enabled: true }`), or use `dataApi.authProvider: \"external\"` with your own `jwksUrl`."
408
440
  });
409
441
  });
442
+ function rejectDuplicateHome(ctx, args) {
443
+ if (!args.gaPresent || !args.previewPresent) return;
444
+ ctx.addIssue({
445
+ code: "custom",
446
+ path: args.gaPath.split("."),
447
+ message: `${args.gaPath} is also declared as ${args.previewPath}. Keep ${args.gaPath} and remove ${args.previewPath}.`
448
+ });
449
+ }
410
450
  /**
411
451
  * Whether a parsed `auth` / `dataApi` toggle value is enabled: a present object (or `true`)
412
452
  * is on unless `enabled` is explicitly `false`. Mirrors `isServiceEnabled` in
@@ -476,6 +516,6 @@ function normaliseIssueMessage(issue) {
476
516
  return issue.message;
477
517
  }
478
518
  //#endregion
479
- export { branchTuningSchema, bucketDefSchema, computeSettingsSchema, configInputSchema, dataApiConfigSchema, dataApiInputSchema, dataApiSettingsSchema, formatZodIssues, functionDefSchema, functionTuningSchema, postgresConfigSchema, previewInputSchema, serviceToggleInputSchema, serviceToggleSchema };
519
+ export { branchTuningSchema, bucketDefSchema, computeSettingsSchema, configInputSchema, dataApiConfigSchema, dataApiInputSchema, dataApiSettingsSchema, formatZodIssues, functionDefSchema, functionTuningSchema, functionsRecordSchema, postgresConfigSchema, previewInputSchema, serviceToggleInputSchema, serviceToggleSchema };
480
520
 
481
521
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/lib/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n\tcustomDomainValidationError,\n\tnormalizeCustomDomain,\n} from \"./custom-domain.js\";\nimport { parseBranchTtl, parseSuspendTimeout } from \"./duration.js\";\nimport { externalPackageRoot } from \"./external-packages.js\";\nimport { isWildcardPattern, validatePattern } from \"./patterns.js\";\nimport { COMPUTE_UNITS, type FunctionBundlerInput } from \"./types.js\";\n\n/** Autoscaling max from the compute size table; larger sizes are fixed-size only. */\nconst AUTOSCALING_MAX_CU = 16;\n/** Documented ceiling on `max - min` when both bounds are set and differ. */\nconst AUTOSCALING_MAX_RANGE_CU = 8;\n\nconst computeUnitSchema = z.literal(COMPUTE_UNITS, {\n\terror: (issue) =>\n\t\t`must be a compute size Neon offers: 0.25, 0.5, an integer 1-16, or an even integer 18-56 (got ${JSON.stringify(issue.input)})`,\n});\n\n/**\n * Zod schema for {@link import(\"./types.js\").ComputeSettings}.\n *\n * CU values come from {@link COMPUTE_UNITS} (the Console size table). Plan limits are\n * the API's job. Cross-field autoscaling rules apply only when both bounds are set:\n * `min <= max`; if they differ, each bound is ≤ 16 and `max - min` ≤ 8. A single bound\n * cannot be checked against those rules because the other end is the project's default.\n *\n * `suspendTimeout` can be:\n * - `false` (never suspend)\n * - duration string like \"5m\", \"1h\" (must be 60s-604800s when parsed)\n * - number in seconds (60-604800, or -1/0 for special values)\n * - `undefined` (use platform default)\n */\nexport const computeSettingsSchema = z\n\t.strictObject({\n\t\tautoscalingLimitMinCu: computeUnitSchema.optional(),\n\t\tautoscalingLimitMaxCu: computeUnitSchema.optional(),\n\t\tsuspendTimeout: z\n\t\t\t.union([z.literal(false), z.string(), z.number()])\n\t\t\t.optional()\n\t\t\t.superRefine((value, ctx) => {\n\t\t\t\tif (value === undefined) return; // undefined is valid (use platform default)\n\t\t\t\tconst result = parseSuspendTimeout(value);\n\t\t\t\tif (\"error\" in result) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: result.error,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}),\n\t})\n\t.superRefine((settings, ctx) => {\n\t\tconst { autoscalingLimitMinCu: min, autoscalingLimitMaxCu: max } =\n\t\t\tsettings;\n\t\tif (min === undefined || max === undefined) return;\n\t\tif (min > max) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMinCu\"],\n\t\t\t\tmessage: `autoscalingLimitMinCu (${min}) must be <= autoscalingLimitMaxCu (${max})`,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (min === max) return;\n\t\tconst overMaxMessage = (field: string, value: number) =>\n\t\t\t`${field} (${value}) exceeds the autoscaling maximum of ${AUTOSCALING_MAX_CU} CU — sizes above ${AUTOSCALING_MAX_CU} are fixed-size only (set autoscalingLimitMinCu = autoscalingLimitMaxCu)`;\n\t\tif (min > AUTOSCALING_MAX_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMinCu\"],\n\t\t\t\tmessage: overMaxMessage(\"autoscalingLimitMinCu\", min),\n\t\t\t});\n\t\t}\n\t\tif (max > AUTOSCALING_MAX_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMaxCu\"],\n\t\t\t\tmessage: overMaxMessage(\"autoscalingLimitMaxCu\", max),\n\t\t\t});\n\t\t}\n\t\tif (max - min > AUTOSCALING_MAX_RANGE_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMaxCu\"],\n\t\t\t\tmessage: `autoscaling range cannot exceed ${AUTOSCALING_MAX_RANGE_CU} CU: min ${min} to max ${max} is a range of ${max - min}`,\n\t\t\t});\n\t\t}\n\t});\n\n/** Object form of a service toggle (`{ enabled?: boolean }`). */\nexport const serviceToggleSchema = z.strictObject({\n\tenabled: z.boolean().optional(),\n});\n\n/** A service toggle as written in a policy: `boolean` or `{ enabled?: boolean }`. */\nexport const serviceToggleInputSchema = z.union([\n\tz.boolean(),\n\tserviceToggleSchema,\n]);\n\n/**\n * Reusable Data API runtime settings (camelCase mirror of the Neon API `DataAPISettings`).\n * `strictObject` so a typo / snake_case key fails loudly instead of being silently dropped.\n */\nexport const dataApiSettingsSchema = z.strictObject({\n\tdbAggregatesEnabled: z.boolean().optional(),\n\tdbAnonRole: z.string().optional(),\n\tdbExtraSearchPath: z.string().optional(),\n\tdbMaxRows: z.number().int().optional(),\n\tdbSchemas: z.array(z.string()).optional(),\n\tjwtRoleClaimKey: z.string().optional(),\n\tjwtCacheMaxLifetime: z.number().int().optional(),\n\topenapiMode: z\n\t\t.union([z.literal(\"ignore-privileges\"), z.literal(\"disabled\")])\n\t\t.optional(),\n\tserverCorsAllowedOrigins: z.string().optional(),\n\tserverTimingEnabled: z.boolean().optional(),\n});\n\n/** Names of the external-IdP-only fields, forbidden when `authProvider` is `\"neon\"`. */\nconst DATA_API_EXTERNAL_ONLY_KEYS = [\n\t\"jwksUrl\",\n\t\"providerName\",\n\t\"jwtAudience\",\n] as const;\n\n/**\n * Object form of the `dataApi` toggle. A single `strictObject` plus a `superRefine` (rather\n * than a discriminated union) so the `\"neon\"` default works without the discriminator being\n * present, and so the \"external-only field with authProvider neon\" error points at the exact\n * offending key — mirroring the `?: never` type-level guard at runtime.\n */\nexport const dataApiConfigSchema = z\n\t.strictObject({\n\t\tenabled: z.boolean().optional(),\n\t\tauthProvider: z\n\t\t\t.union([z.literal(\"neon\"), z.literal(\"external\")])\n\t\t\t.optional(),\n\t\tjwksUrl: z.string().optional(),\n\t\tproviderName: z.string().optional(),\n\t\tjwtAudience: z.string().optional(),\n\t\tsettings: dataApiSettingsSchema.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\tconst provider = cfg.authProvider ?? \"neon\";\n\t\tif (provider !== \"neon\") return;\n\t\tfor (const key of DATA_API_EXTERNAL_ONLY_KEYS) {\n\t\t\tif (cfg[key] !== undefined) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [key],\n\t\t\t\t\tmessage: `${key} is only allowed with authProvider: \"external\" — Neon supplies it for authProvider: \"neon\".`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n/** A `dataApi` toggle as written in a policy: `boolean` or {@link dataApiConfigSchema}. */\nexport const dataApiInputSchema = z.union([z.boolean(), dataApiConfigSchema]);\n\nexport const postgresConfigSchema = z.strictObject({\n\tcomputeSettings: computeSettingsSchema.optional(),\n});\n\n/**\n * Branch-unique function slug. Mirrors the Neon Functions API path-segment rule\n * (`platform/internal/platform/functions/name.go`): 1–20 lowercase letters and digits.\n * Used as the **key schema** of the `preview.functions` record, so a bad slug fails\n * validation with a path pointing at the offending key and duplicate slugs are impossible\n * by construction (object keys are unique).\n */\nconst functionSlugSchema = z\n\t.string()\n\t.regex(\n\t\t/^[a-z0-9]{1,20}$/,\n\t\t\"function slug must be 1-20 lowercase letters and digits (no hyphens or other characters)\",\n\t);\n\n/** Bucket name: 1–255 chars. Used as the key schema of the `preview.buckets` record. */\nconst bucketNameSchema = z.string().min(1).max(255);\n\n/**\n * A single function environment-variable value. Must be a defined string: a `process.env.X`\n * that is unset evaluates to `undefined`, and the bare `z.string()` message for that case\n * (`Invalid input: expected string, received undefined`) gives no hint that an env var is the\n * culprit. The custom `error` replaces *only* the `undefined` case with a message that names\n * the offending function + env key (read from the issue path) and how to fix it; any other\n * wrong type keeps zod's default (`expected string, received number`, …).\n */\nconst functionEnvValueSchema = z.string({\n\terror: (issue) => {\n\t\tif (issue.input !== undefined) return undefined;\n\t\tconst path = issue.path ?? [];\n\t\tconst key = path.length > 0 ? String(path[path.length - 1]) : undefined;\n\t\tconst functionsIndex = path.indexOf(\"functions\");\n\t\tconst slug =\n\t\t\tfunctionsIndex >= 0 && functionsIndex + 1 < path.length\n\t\t\t\t? String(path[functionsIndex + 1])\n\t\t\t\t: undefined;\n\t\tconst subject =\n\t\t\tslug !== undefined && key !== undefined\n\t\t\t\t? `Environment variable \"${key}\" for function \"${slug}\"`\n\t\t\t\t: key !== undefined\n\t\t\t\t\t? `Environment variable \"${key}\"`\n\t\t\t\t\t: \"An environment variable\";\n\t\treturn `${subject} is undefined — its value (typically a \\`process.env.*\\`) is unset. Set it (for example \\`neon deploy --env <file>\\`) or omit the key from neon.ts if you do not want to write it. Do not coerce a missing value to an empty string: that uploads and deletes the live key.`;\n\t},\n});\n\n/**\n * Per-function environment map. Every value must be a defined string (see\n * {@link functionEnvValueSchema}): a `process.env.X` that is unset surfaces as `undefined` and\n * is rejected here (rather than silently shipping `undefined` into the deployment).\n */\nconst functionEnvSchema = z.record(z.string(), functionEnvValueSchema);\n\n/**\n * TCP port for a function's local dev server. Excludes 0 (which means \"any port\" to the OS\n * — `neon dev` expresses \"pick one for me\" by omitting `port`, not by passing 0).\n */\nconst devPortSchema = z.number().int().min(1).max(65535);\n\n/**\n * Local-dev settings for a function (`neon dev` only; never affects deploy). `port` is bound\n * exactly when set (and `neon dev` fails if it is taken), or a free port is found when omitted.\n */\nconst functionDevConfigSchema = z.strictObject({\n\tport: devPortSchema.optional(),\n});\n\nconst functionScheduleTriggerSchema = z.strictObject({\n\ttype: z.literal(\"schedule\"),\n\tname: z.string().min(1).max(255),\n\tcron: z.string().min(1),\n\tfunctionPath: z.string().min(1).optional(),\n\tenabled: z.boolean().optional(),\n});\n\nconst customDomainSchema = z.string().superRefine((value, ctx) => {\n\tconst message = customDomainValidationError(value);\n\tif (message) {\n\t\tctx.addIssue({ code: \"custom\", message });\n\t}\n});\n\nconst customDomainsSchema = z\n\t.array(customDomainSchema)\n\t.superRefine((domains, ctx) => {\n\t\tconst seen = new Set<string>();\n\t\tfor (const [index, domain] of domains.entries()) {\n\t\t\tconst normalized = normalizeCustomDomain(domain);\n\t\t\tif (seen.has(normalized)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [index],\n\t\t\t\t\tmessage: `custom domain \"${normalized}\" is listed more than once`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseen.add(normalized);\n\t\t}\n\t});\n\n/**\n * The name of a package the bundler must leave alone. Accepts what esbuild's `external`\n * accepts for a package — a bare name, a scope, or a subpath — and rejects a relative or\n * absolute path, which names a local module rather than a dependency and is never the right\n * thing to externalize (the bundle would ship an import of a file that isn't deployed).\n */\nconst externalPackageNameSchema = z\n\t.string()\n\t.min(1)\n\t.refine((value) => !value.startsWith(\".\") && !value.startsWith(\"/\"), {\n\t\terror: 'must be a package name such as \"microsandbox\" or \"@scope/pkg\", not a relative or absolute path',\n\t});\n\n/**\n * An entry whose files are staged has to name one installable package, because the deploy\n * hands its root to `npm install`. esbuild's `external` additionally accepts a `*` wildcard\n * and a bare scope, which name a set rather than a package — legal only when nothing is\n * being installed for them.\n */\nconst stageablePackageName = (value: string): boolean => {\n\t// A protocol (`node:fs`, `npm:pkg`) is a specifier, not something to install.\n\tif (/^[a-z][a-z0-9+.-]*:/i.test(value)) return false;\n\t// An empty segment (`foo//bar`) or a traversal is not a subpath the deploy can act on.\n\tconst segments = value.split(\"/\");\n\tif (segments.some((segment) => segment === \"\" || segment === \"..\")) {\n\t\treturn false;\n\t}\n\treturn isNpmPackageName(externalPackageRoot(value));\n};\n\n/**\n * npm's own rules for a package name, which is what the deploy hands to `npm install`.\n * Deliberately strict: whatever slips through here becomes a subprocess argument.\n */\nconst NPM_NAME_SEGMENT = /^[a-z0-9~][a-z0-9._~-]*$/;\n\nconst isNpmPackageName = (root: string): boolean => {\n\tif (root.length === 0 || root.length > 214) return false;\n\tif (!root.startsWith(\"@\")) return NPM_NAME_SEGMENT.test(root);\n\tconst [scope, name, ...rest] = root.slice(1).split(\"/\");\n\t// A bare scope names every package in it, not one package.\n\tif (rest.length > 0 || name === undefined) return false;\n\treturn NPM_NAME_SEGMENT.test(scope) && NPM_NAME_SEGMENT.test(name);\n};\n\n/**\n * One entry of `externalPackages`. A bare string is the common case and ships the package's\n * files; the object form exists only to turn that off. See {@link FunctionDef.externalPackages}.\n */\nconst externalPackageEntrySchema = z.union([\n\texternalPackageNameSchema,\n\tz.strictObject({\n\t\tname: externalPackageNameSchema,\n\t\tincludeFiles: z.boolean().optional(),\n\t}),\n]);\n\n/**\n * Per-function list of packages esbuild leaves unresolved at deploy time. See\n * {@link FunctionDef.externalPackages}.\n */\nconst functionExternalPackagesSchema = z.array(externalPackageEntrySchema);\n\nconst runtimeSchema = z.literal(\"nodejs24\");\n\nconst bundlerSchema = z.custom<FunctionBundlerInput>(\n\t(value) =>\n\t\tvalue === \"esbuild\" || value === \"none\" || typeof value === \"function\",\n\t{\n\t\tmessage:\n\t\t\t'bundler must be \"esbuild\", \"none\", or a function (fn) => Promise<FunctionBundle>',\n\t},\n);\n\nconst isEsbuildBundler = (\n\tbundler: z.infer<typeof bundlerSchema> | undefined,\n): boolean => bundler === undefined || bundler === \"esbuild\";\n\n/** The declared name of an entry, whichever form it was written in. */\nconst entryName = (\n\tentry: z.infer<typeof externalPackageEntrySchema>,\n): string => (typeof entry === \"string\" ? entry : entry.name);\n\n/** Whether an entry ships its files. Absent means yes — see `FunctionDef.externalPackages`. */\nconst entryIncludesFiles = (\n\tentry: z.infer<typeof externalPackageEntrySchema>,\n): boolean => (typeof entry === \"string\" ? true : entry.includeFiles !== false);\n\n/**\n * Static definition of a function (existence). The slug is the record key (validated by\n * {@link functionSlugSchema}), so it is not a field here. Deploy tuning (`runtime`) lives\n * in the `branch` closure, not here.\n *\n * `externalPackages` entries are checked for contradictions: the same package named twice,\n * or named once bare and once through a subpath with a different `includeFiles`. Both state\n * two intents for one package, and files are staged per package rather than per subpath, so\n * neither can be honoured as written.\n */\nexport const functionDefSchema = z\n\t.strictObject({\n\t\tname: z.string().min(1).max(255),\n\t\tsource: z.string().min(1),\n\t\tenv: functionEnvSchema.optional(),\n\t\texternalPackages: functionExternalPackagesSchema.optional(),\n\t\tbundler: bundlerSchema.optional(),\n\t\tdev: functionDevConfigSchema.optional(),\n\t\ttriggers: z.array(functionScheduleTriggerSchema).optional(),\n\t\tcustomDomains: customDomainsSchema.optional(),\n\t})\n\t.check((ctx) => {\n\t\tconst entries = ctx.value.externalPackages ?? [];\n\n\t\t// Other bundlers own their output, so `externalPackages` would be ignored.\n\t\tif (\n\t\t\tctx.value.externalPackages !== undefined &&\n\t\t\t!isEsbuildBundler(ctx.value.bundler)\n\t\t) {\n\t\t\tctx.issues.push({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tinput: ctx.value.externalPackages,\n\t\t\t\tpath: [\"externalPackages\"],\n\t\t\t\tmessage: `externalPackages only applies to the \"esbuild\" bundler; the \"${\n\t\t\t\t\ttypeof ctx.value.bundler === \"function\"\n\t\t\t\t\t\t? \"custom\"\n\t\t\t\t\t\t: ctx.value.bundler\n\t\t\t\t}\" bundler controls its own output. Remove externalPackages or switch to the esbuild bundler`,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst seenNames = new Map<string, number>();\n\t\tconst rootIntent = new Map<\n\t\t\tstring,\n\t\t\t{ includeFiles: boolean; at: string }\n\t\t>();\n\n\t\tentries.forEach((entry, index) => {\n\t\t\tconst name = entryName(entry);\n\t\t\tconst includeFiles = entryIncludesFiles(entry);\n\n\t\t\tif (includeFiles && !stageablePackageName(name)) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`\"${name}\" does not name a single installable package, so its files cannot ` +\n\t\t\t\t\t\t`be staged. Name one package, or set includeFiles: false to leave the ` +\n\t\t\t\t\t\t`import unresolved without shipping anything for it`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst firstIndex = seenNames.get(name);\n\t\t\tif (firstIndex !== undefined) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage: `\"${name}\" is listed more than once (first at index ${firstIndex})`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tseenNames.set(name, index);\n\n\t\t\t// Files are installed and traced per package, so two specifiers that resolve to the\n\t\t\t// same package cannot disagree about whether that package's files ship.\n\t\t\tconst root = externalPackageRoot(name);\n\t\t\tconst prior = rootIntent.get(root);\n\t\t\tif (prior !== undefined && prior.includeFiles !== includeFiles) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`\"${name}\" and \"${prior.at}\" are both part of the \"${root}\" package but disagree ` +\n\t\t\t\t\t\t`about includeFiles; files ship per package, so the whole package either ships or does not`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trootIntent.set(root, { includeFiles, at: name });\n\t\t});\n\t});\n\n/** Static definition of a bucket (existence). Name is the record key. */\nexport const bucketDefSchema = z.strictObject({\n\taccess: z\n\t\t.union([z.literal(\"private\"), z.literal(\"public_read\")])\n\t\t.optional(),\n});\n\n/** Static, beta Preview feature set: AI Gateway toggle + functions/buckets records. */\nexport const previewInputSchema = z\n\t.strictObject({\n\t\taiGateway: serviceToggleInputSchema.optional(),\n\t\tfunctions: z.record(functionSlugSchema, functionDefSchema).optional(),\n\t\tbuckets: z.record(bucketNameSchema, bucketDefSchema).optional(),\n\t})\n\t.superRefine((preview, ctx) => {\n\t\tconst byName = new Map<string, string>();\n\t\tfor (const [slug, fn] of Object.entries(preview.functions ?? {})) {\n\t\t\tconst seenOnFn = new Set<string>();\n\t\t\tfor (const [index, trigger] of (fn.triggers ?? []).entries()) {\n\t\t\t\tif (seenOnFn.has(trigger.name)) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tpath: [\"functions\", slug, \"triggers\", index, \"name\"],\n\t\t\t\t\t\tmessage: `trigger name \"${trigger.name}\" is listed more than once on function \"${slug}\"`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseenOnFn.add(trigger.name);\n\t\t\t\tconst prior = byName.get(trigger.name);\n\t\t\t\tif (prior !== undefined) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tpath: [\"functions\", slug, \"triggers\", index, \"name\"],\n\t\t\t\t\t\tmessage: `trigger name \"${trigger.name}\" is already used by function \"${prior}\"`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tbyName.set(trigger.name, slug);\n\t\t\t}\n\t\t}\n\t});\n\n/** Per-function deploy tuning returned by the `branch` closure. */\nexport const functionTuningSchema = z.strictObject({\n\truntime: runtimeSchema.optional(),\n\tcustomDomains: customDomainsSchema.optional(),\n});\n\n/** Per-branch Preview tuning. Keys must be slugs declared in the static `preview`. */\nconst previewTuningSchema = z.strictObject({\n\tfunctions: z.record(functionSlugSchema, functionTuningSchema).optional(),\n});\n\n/**\n * The object returned by the `branch` closure. Validated on every `resolveConfig` call so\n * tuning errors point at the concrete branch target that triggered them.\n */\nexport const branchTuningSchema = z\n\t.strictObject({\n\t\tparent: z.string().optional(),\n\t\tprotected: z.boolean().optional(),\n\t\tttl: z\n\t\t\t.union([z.string(), z.number()])\n\t\t\t.optional()\n\t\t\t.superRefine((value, ctx) => {\n\t\t\t\tif (value === undefined) return;\n\t\t\t\tconst result = parseBranchTtl(value);\n\t\t\t\tif (\"error\" in result) {\n\t\t\t\t\tctx.addIssue({ code: \"custom\", message: result.error });\n\t\t\t\t}\n\t\t\t}),\n\t\tpostgres: postgresConfigSchema.optional(),\n\t\tpreview: previewTuningSchema.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\tvalidateParentReference({\n\t\t\tctx,\n\t\t\tpath: [\"parent\"],\n\t\t\tparent: cfg.parent,\n\t\t});\n\t});\n\n/**\n * The top-level object accepted by `defineConfig`. The `branch` closure is validated\n * structurally as a function here; its returned tuning is validated per-evaluation by\n * {@link branchTuningSchema} inside `resolveConfig`.\n */\nexport const configInputSchema = z\n\t.strictObject({\n\t\tauth: serviceToggleInputSchema.optional(),\n\t\tdataApi: dataApiInputSchema.optional(),\n\t\tpreview: previewInputSchema.optional(),\n\t\tbranch: z\n\t\t\t.custom<(...args: unknown[]) => unknown>(\n\t\t\t\t(value) => typeof value === \"function\",\n\t\t\t\t{\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"branch must be a function: `branch: (branch) => ({ … })`\",\n\t\t\t\t},\n\t\t\t)\n\t\t\t.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\t// A Data API verified by Neon Auth (`authProvider: \"neon\"`, the default) needs Neon\n\t\t// Auth enabled on the same branch so the tokens it verifies actually exist. Enforce\n\t\t// the same invariant the `defineConfig` type-level check expresses, at runtime.\n\t\tif (!isToggleEnabledValue(cfg.dataApi)) return;\n\t\tif (dataApiAuthProviderValue(cfg.dataApi) !== \"neon\") return;\n\t\tif (!isToggleEnabledValue(cfg.auth)) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"auth\"],\n\t\t\t\tmessage:\n\t\t\t\t\t'dataApi with authProvider \"neon\" requires Neon Auth — set `auth: true` (or `auth: { enabled: true }`), or use `dataApi.authProvider: \"external\"` with your own `jwksUrl`.',\n\t\t\t});\n\t\t}\n\t});\n\n/**\n * Whether a parsed `auth` / `dataApi` toggle value is enabled: a present object (or `true`)\n * is on unless `enabled` is explicitly `false`. Mirrors `isServiceEnabled` in\n * `define-config.ts`, operating on the already-validated runtime value.\n */\nfunction isToggleEnabledValue(value: unknown): boolean {\n\tif (value === undefined || value === null) return false;\n\tif (typeof value === \"boolean\") return value;\n\tif (typeof value === \"object\") {\n\t\treturn (value as { enabled?: unknown }).enabled !== false;\n\t}\n\treturn false;\n}\n\n/** Read the (defaulted) `authProvider` from a parsed `dataApi` value. */\nfunction dataApiAuthProviderValue(value: unknown): \"neon\" | \"external\" {\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst provider = (value as { authProvider?: unknown }).authProvider;\n\t\tif (provider === \"external\") return \"external\";\n\t}\n\treturn \"neon\";\n}\n\nfunction validateParentReference(args: {\n\tctx: z.RefinementCtx;\n\tpath: (string | number)[];\n\tparent: string | undefined;\n}): void {\n\tconst { ctx, path, parent } = args;\n\tif (parent === undefined) return;\n\n\tconst patternCheck = validatePattern(parent);\n\tif (\"error\" in patternCheck) {\n\t\tctx.addIssue({ code: \"custom\", path, message: patternCheck.error });\n\t} else if (isWildcardPattern(parent)) {\n\t\tctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath,\n\t\t\tmessage: `parent must be a concrete branch name (no wildcards), got \"${parent}\"`,\n\t\t});\n\t}\n}\n\n/**\n * Convert the structured {@link z.ZodError} produced by `configSchema.safeParse` into the\n * `string[]` shape used by {@link import(\"./errors.js\").ConfigValidationError}.\n *\n * Issue paths are rendered as dot-separated property accesses (`postgres.computeSettings`)\n * and unknown-key issues from `strictObject` are normalised so the message contains the\n * substring \"unknown key\" — keeping pre-zod assertions in test suites and downstream tools\n * stable.\n */\nexport function formatZodIssues(error: z.ZodError): string[] {\n\treturn error.issues.map((issue) => {\n\t\tconst path = renderPath(issue.path);\n\t\tconst message = normaliseIssueMessage(issue);\n\t\treturn path ? `${path}: ${message}` : message;\n\t});\n}\n\nfunction renderPath(path: ReadonlyArray<PropertyKey>): string {\n\tlet out = \"\";\n\tfor (const segment of path) {\n\t\tif (typeof segment === \"number\") out += `[${segment}]`;\n\t\telse if (out === \"\") out += String(segment);\n\t\telse out += `.${String(segment)}`;\n\t}\n\treturn out;\n}\n\nfunction normaliseIssueMessage(issue: z.core.$ZodIssue): string {\n\tif (issue.code === \"unrecognized_keys\") {\n\t\tconst keys = issue.keys ?? [];\n\t\tconst formatted = keys.map((k) => JSON.stringify(k)).join(\", \");\n\t\treturn `unknown key${keys.length === 1 ? \"\" : \"s\"}: ${formatted}`;\n\t}\n\tif (issue.code === \"invalid_key\") {\n\t\t// A record *key* that fails its key schema (e.g. a bad function slug) surfaces in\n\t\t// zod as a single `invalid_key` issue whose own `message` is the generic, useless\n\t\t// \"Invalid key in record\". The actual reason — the function-slug regex rule, say —\n\t\t// lives in the nested key-schema `issues`. Hoist those so the user sees *why* the\n\t\t// key was rejected (the offending key itself is already in the issue `path`).\n\t\tconst reasons = issue.issues\n\t\t\t.map((nested) => nested.message)\n\t\t\t.filter((message) => message.length > 0);\n\t\tif (reasons.length > 0) return reasons.join(\"; \");\n\t}\n\treturn issue.message;\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,qBAAqB;;AAE3B,MAAM,2BAA2B;AAEjC,MAAM,oBAAoB,EAAE,QAAQ,eAAe,EAClD,QAAQ,UACP,iGAAiG,KAAK,UAAU,MAAM,KAAK,EAAE,GAC/H,CAAC;;;;;;;;;;;;;;;AAgBD,MAAa,wBAAwB,EACnC,aAAa;CACb,uBAAuB,kBAAkB,SAAS;CAClD,uBAAuB,kBAAkB,SAAS;CAClD,gBAAgB,EACd,MAAM;EAAC,EAAE,QAAQ,KAAK;EAAG,EAAE,OAAO;EAAG,EAAE,OAAO;CAAC,CAAC,CAAC,CACjD,SAAS,CAAC,CACV,aAAa,OAAO,QAAQ;EAC5B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,oBAAoB,KAAK;EACxC,IAAI,WAAW,QACd,IAAI,SAAS;GACZ,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EAAE,MAAM;EAAU;EAAM,SAAS,aAAa;CAAM,CAAC;MAC5D,IAAI,kBAAkB,MAAM,GAClC,IAAI,SAAS;EACZ,MAAM;EACN;EACA,SAAS,8DAA8D,OAAO;CAC/E,CAAC;AAEH;;;;;;;;;;AAWA,SAAgB,gBAAgB,OAA6B;CAC5D,OAAO,MAAM,OAAO,KAAK,UAAU;EAClC,MAAM,OAAO,WAAW,MAAM,IAAI;EAClC,MAAM,UAAU,sBAAsB,KAAK;EAC3C,OAAO,OAAO,GAAG,KAAK,IAAI,YAAY;CACvC,CAAC;AACF;AAEA,SAAS,WAAW,MAA0C;CAC7D,IAAI,MAAM;CACV,KAAK,MAAM,WAAW,MACrB,IAAI,OAAO,YAAY,UAAU,OAAO,IAAI,QAAQ;MAC/C,IAAI,QAAQ,IAAI,OAAO,OAAO,OAAO;MACrC,OAAO,IAAI,OAAO,OAAO;CAE/B,OAAO;AACR;AAEA,SAAS,sBAAsB,OAAiC;CAC/D,IAAI,MAAM,SAAS,qBAAqB;EACvC,MAAM,OAAO,MAAM,QAAQ,CAAC;EAC5B,MAAM,YAAY,KAAK,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;EAC9D,OAAO,cAAc,KAAK,WAAW,IAAI,KAAK,IAAI,IAAI;CACvD;CACA,IAAI,MAAM,SAAS,eAAe;EAMjC,MAAM,UAAU,MAAM,OACpB,KAAK,WAAW,OAAO,OAAO,CAAC,CAC/B,QAAQ,YAAY,QAAQ,SAAS,CAAC;EACxC,IAAI,QAAQ,SAAS,GAAG,OAAO,QAAQ,KAAK,IAAI;CACjD;CACA,OAAO,MAAM;AACd"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/lib/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n\tcustomDomainValidationError,\n\tnormalizeCustomDomain,\n} from \"./custom-domain.js\";\nimport { parseBranchTtl, parseSuspendTimeout } from \"./duration.js\";\nimport { externalPackageRoot } from \"./external-packages.js\";\nimport { isWildcardPattern, validatePattern } from \"./patterns.js\";\nimport { COMPUTE_UNITS, type FunctionBundlerInput } from \"./types.js\";\n\n/** Autoscaling max from the compute size table; larger sizes are fixed-size only. */\nconst AUTOSCALING_MAX_CU = 16;\n/** Documented ceiling on `max - min` when both bounds are set and differ. */\nconst AUTOSCALING_MAX_RANGE_CU = 8;\n\nconst computeUnitSchema = z.literal(COMPUTE_UNITS, {\n\terror: (issue) =>\n\t\t`must be a compute size Neon offers: 0.25, 0.5, an integer 1-16, or an even integer 18-56 (got ${JSON.stringify(issue.input)})`,\n});\n\n/**\n * Zod schema for {@link import(\"./types.js\").ComputeSettings}.\n *\n * CU values come from {@link COMPUTE_UNITS} (the Console size table). Plan limits are\n * the API's job. Cross-field autoscaling rules apply only when both bounds are set:\n * `min <= max`; if they differ, each bound is ≤ 16 and `max - min` ≤ 8. A single bound\n * cannot be checked against those rules because the other end is the project's default.\n *\n * `suspendTimeout` can be:\n * - `false` (never suspend)\n * - duration string like \"5m\", \"1h\" (must be 60s-604800s when parsed)\n * - number in seconds (60-604800, or -1/0 for special values)\n * - `undefined` (use platform default)\n */\nexport const computeSettingsSchema = z\n\t.strictObject({\n\t\tautoscalingLimitMinCu: computeUnitSchema.optional(),\n\t\tautoscalingLimitMaxCu: computeUnitSchema.optional(),\n\t\tsuspendTimeout: z\n\t\t\t.union([z.literal(false), z.string(), z.number()])\n\t\t\t.optional()\n\t\t\t.superRefine((value, ctx) => {\n\t\t\t\tif (value === undefined) return; // undefined is valid (use platform default)\n\t\t\t\tconst result = parseSuspendTimeout(value);\n\t\t\t\tif (\"error\" in result) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tmessage: result.error,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}),\n\t})\n\t.superRefine((settings, ctx) => {\n\t\tconst { autoscalingLimitMinCu: min, autoscalingLimitMaxCu: max } =\n\t\t\tsettings;\n\t\tif (min === undefined || max === undefined) return;\n\t\tif (min > max) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMinCu\"],\n\t\t\t\tmessage: `autoscalingLimitMinCu (${min}) must be <= autoscalingLimitMaxCu (${max})`,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (min === max) return;\n\t\tconst overMaxMessage = (field: string, value: number) =>\n\t\t\t`${field} (${value}) exceeds the autoscaling maximum of ${AUTOSCALING_MAX_CU} CU — sizes above ${AUTOSCALING_MAX_CU} are fixed-size only (set autoscalingLimitMinCu = autoscalingLimitMaxCu)`;\n\t\tif (min > AUTOSCALING_MAX_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMinCu\"],\n\t\t\t\tmessage: overMaxMessage(\"autoscalingLimitMinCu\", min),\n\t\t\t});\n\t\t}\n\t\tif (max > AUTOSCALING_MAX_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMaxCu\"],\n\t\t\t\tmessage: overMaxMessage(\"autoscalingLimitMaxCu\", max),\n\t\t\t});\n\t\t}\n\t\tif (max - min > AUTOSCALING_MAX_RANGE_CU) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"autoscalingLimitMaxCu\"],\n\t\t\t\tmessage: `autoscaling range cannot exceed ${AUTOSCALING_MAX_RANGE_CU} CU: min ${min} to max ${max} is a range of ${max - min}`,\n\t\t\t});\n\t\t}\n\t});\n\n/** Object form of a service toggle (`{ enabled?: boolean }`). */\nexport const serviceToggleSchema = z.strictObject({\n\tenabled: z.boolean().optional(),\n});\n\n/** A service toggle as written in a policy: `boolean` or `{ enabled?: boolean }`. */\nexport const serviceToggleInputSchema = z.union([\n\tz.boolean(),\n\tserviceToggleSchema,\n]);\n\n/**\n * Reusable Data API runtime settings (camelCase mirror of the Neon API `DataAPISettings`).\n * `strictObject` so a typo / snake_case key fails loudly instead of being silently dropped.\n */\nexport const dataApiSettingsSchema = z.strictObject({\n\tdbAggregatesEnabled: z.boolean().optional(),\n\tdbAnonRole: z.string().optional(),\n\tdbExtraSearchPath: z.string().optional(),\n\tdbMaxRows: z.number().int().optional(),\n\tdbSchemas: z.array(z.string()).optional(),\n\tjwtRoleClaimKey: z.string().optional(),\n\tjwtCacheMaxLifetime: z.number().int().optional(),\n\topenapiMode: z\n\t\t.union([z.literal(\"ignore-privileges\"), z.literal(\"disabled\")])\n\t\t.optional(),\n\tserverCorsAllowedOrigins: z.string().optional(),\n\tserverTimingEnabled: z.boolean().optional(),\n});\n\n/** Names of the external-IdP-only fields, forbidden when `authProvider` is `\"neon\"`. */\nconst DATA_API_EXTERNAL_ONLY_KEYS = [\n\t\"jwksUrl\",\n\t\"providerName\",\n\t\"jwtAudience\",\n] as const;\n\n/**\n * Object form of the `dataApi` toggle. A single `strictObject` plus a `superRefine` (rather\n * than a discriminated union) so the `\"neon\"` default works without the discriminator being\n * present, and so the \"external-only field with authProvider neon\" error points at the exact\n * offending key — mirroring the `?: never` type-level guard at runtime.\n */\nexport const dataApiConfigSchema = z\n\t.strictObject({\n\t\tenabled: z.boolean().optional(),\n\t\tauthProvider: z\n\t\t\t.union([z.literal(\"neon\"), z.literal(\"external\")])\n\t\t\t.optional(),\n\t\tjwksUrl: z.string().optional(),\n\t\tproviderName: z.string().optional(),\n\t\tjwtAudience: z.string().optional(),\n\t\tsettings: dataApiSettingsSchema.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\tconst provider = cfg.authProvider ?? \"neon\";\n\t\tif (provider !== \"neon\") return;\n\t\tfor (const key of DATA_API_EXTERNAL_ONLY_KEYS) {\n\t\t\tif (cfg[key] !== undefined) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [key],\n\t\t\t\t\tmessage: `${key} is only allowed with authProvider: \"external\" — Neon supplies it for authProvider: \"neon\".`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n/** A `dataApi` toggle as written in a policy: `boolean` or {@link dataApiConfigSchema}. */\nexport const dataApiInputSchema = z.union([z.boolean(), dataApiConfigSchema]);\n\nexport const postgresConfigSchema = z.strictObject({\n\tcomputeSettings: computeSettingsSchema.optional(),\n});\n\n/**\n * Branch-unique function slug. Mirrors the Neon Functions API path-segment rule\n * (`platform/internal/platform/functions/name.go`): 1–20 lowercase letters and digits.\n * Used as the **key schema** of the `functions` record, so a bad slug fails\n * validation with a path pointing at the offending key and duplicate slugs are impossible\n * by construction (object keys are unique).\n */\nconst functionSlugSchema = z\n\t.string()\n\t.regex(\n\t\t/^[a-z0-9]{1,20}$/,\n\t\t\"function slug must be 1-20 lowercase letters and digits (no hyphens or other characters)\",\n\t);\n\n/** Bucket name: 1–255 chars. Used as the key schema of the `buckets` record. */\nconst bucketNameSchema = z.string().min(1).max(255);\n\n/**\n * A single function environment-variable value. Must be a defined string: a `process.env.X`\n * that is unset evaluates to `undefined`, and the bare `z.string()` message for that case\n * (`Invalid input: expected string, received undefined`) gives no hint that an env var is the\n * culprit. The custom `error` replaces *only* the `undefined` case with a message that names\n * the offending function + env key (read from the issue path) and how to fix it; any other\n * wrong type keeps zod's default (`expected string, received number`, …).\n */\nconst functionEnvValueSchema = z.string({\n\terror: (issue) => {\n\t\tif (issue.input !== undefined) return undefined;\n\t\tconst path = issue.path ?? [];\n\t\tconst key = path.length > 0 ? String(path[path.length - 1]) : undefined;\n\t\tconst functionsIndex = path.indexOf(\"functions\");\n\t\tconst slug =\n\t\t\tfunctionsIndex >= 0 && functionsIndex + 1 < path.length\n\t\t\t\t? String(path[functionsIndex + 1])\n\t\t\t\t: undefined;\n\t\tconst subject =\n\t\t\tslug !== undefined && key !== undefined\n\t\t\t\t? `Environment variable \"${key}\" for function \"${slug}\"`\n\t\t\t\t: key !== undefined\n\t\t\t\t\t? `Environment variable \"${key}\"`\n\t\t\t\t\t: \"An environment variable\";\n\t\treturn `${subject} is undefined — its value (typically a \\`process.env.*\\`) is unset. Set it (for example \\`neon deploy --env <file>\\`) or omit the key from neon.ts if you do not want to write it. Do not coerce a missing value to an empty string: that uploads and deletes the live key.`;\n\t},\n});\n\n/**\n * Per-function environment map. Every value must be a defined string (see\n * {@link functionEnvValueSchema}): a `process.env.X` that is unset surfaces as `undefined` and\n * is rejected here (rather than silently shipping `undefined` into the deployment).\n */\nconst functionEnvSchema = z.record(z.string(), functionEnvValueSchema);\n\n/**\n * TCP port for a function's local dev server. Excludes 0 (which means \"any port\" to the OS\n * — `neon dev` expresses \"pick one for me\" by omitting `port`, not by passing 0).\n */\nconst devPortSchema = z.number().int().min(1).max(65535);\n\n/**\n * Local-dev settings for a function (`neon dev` only; never affects deploy). `port` is bound\n * exactly when set (and `neon dev` fails if it is taken), or a free port is found when omitted.\n */\nconst functionDevConfigSchema = z.strictObject({\n\tport: devPortSchema.optional(),\n});\n\nconst functionScheduleTriggerSchema = z.strictObject({\n\ttype: z.literal(\"schedule\"),\n\tname: z.string().min(1).max(255),\n\tcron: z.string().min(1),\n\tfunctionPath: z.string().min(1).optional(),\n\tenabled: z.boolean().optional(),\n});\n\nconst customDomainSchema = z.string().superRefine((value, ctx) => {\n\tconst message = customDomainValidationError(value);\n\tif (message) {\n\t\tctx.addIssue({ code: \"custom\", message });\n\t}\n});\n\nconst customDomainsSchema = z\n\t.array(customDomainSchema)\n\t.superRefine((domains, ctx) => {\n\t\tconst seen = new Set<string>();\n\t\tfor (const [index, domain] of domains.entries()) {\n\t\t\tconst normalized = normalizeCustomDomain(domain);\n\t\t\tif (seen.has(normalized)) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [index],\n\t\t\t\t\tmessage: `custom domain \"${normalized}\" is listed more than once`,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tseen.add(normalized);\n\t\t}\n\t});\n\n/**\n * The name of a package the bundler must leave alone. Accepts what esbuild's `external`\n * accepts for a package — a bare name, a scope, or a subpath — and rejects a relative or\n * absolute path, which names a local module rather than a dependency and is never the right\n * thing to externalize (the bundle would ship an import of a file that isn't deployed).\n */\nconst externalPackageNameSchema = z\n\t.string()\n\t.min(1)\n\t.refine((value) => !value.startsWith(\".\") && !value.startsWith(\"/\"), {\n\t\terror: 'must be a package name such as \"microsandbox\" or \"@scope/pkg\", not a relative or absolute path',\n\t});\n\n/**\n * An entry whose files are staged has to name one installable package, because the deploy\n * hands its root to `npm install`. esbuild's `external` additionally accepts a `*` wildcard\n * and a bare scope, which name a set rather than a package — legal only when nothing is\n * being installed for them.\n */\nconst stageablePackageName = (value: string): boolean => {\n\t// A protocol (`node:fs`, `npm:pkg`) is a specifier, not something to install.\n\tif (/^[a-z][a-z0-9+.-]*:/i.test(value)) return false;\n\t// An empty segment (`foo//bar`) or a traversal is not a subpath the deploy can act on.\n\tconst segments = value.split(\"/\");\n\tif (segments.some((segment) => segment === \"\" || segment === \"..\")) {\n\t\treturn false;\n\t}\n\treturn isNpmPackageName(externalPackageRoot(value));\n};\n\n/**\n * npm's own rules for a package name, which is what the deploy hands to `npm install`.\n * Deliberately strict: whatever slips through here becomes a subprocess argument.\n */\nconst NPM_NAME_SEGMENT = /^[a-z0-9~][a-z0-9._~-]*$/;\n\nconst isNpmPackageName = (root: string): boolean => {\n\tif (root.length === 0 || root.length > 214) return false;\n\tif (!root.startsWith(\"@\")) return NPM_NAME_SEGMENT.test(root);\n\tconst [scope, name, ...rest] = root.slice(1).split(\"/\");\n\t// A bare scope names every package in it, not one package.\n\tif (rest.length > 0 || name === undefined) return false;\n\treturn NPM_NAME_SEGMENT.test(scope) && NPM_NAME_SEGMENT.test(name);\n};\n\n/**\n * One entry of `externalPackages`. A bare string is the common case and ships the package's\n * files; the object form exists only to turn that off. See {@link FunctionDef.externalPackages}.\n */\nconst externalPackageEntrySchema = z.union([\n\texternalPackageNameSchema,\n\tz.strictObject({\n\t\tname: externalPackageNameSchema,\n\t\tincludeFiles: z.boolean().optional(),\n\t}),\n]);\n\n/**\n * Per-function list of packages esbuild leaves unresolved at deploy time. See\n * {@link FunctionDef.externalPackages}.\n */\nconst functionExternalPackagesSchema = z.array(externalPackageEntrySchema);\n\nconst runtimeSchema = z.literal(\"nodejs24\");\n\nconst bundlerSchema = z.custom<FunctionBundlerInput>(\n\t(value) =>\n\t\tvalue === \"esbuild\" || value === \"none\" || typeof value === \"function\",\n\t{\n\t\tmessage:\n\t\t\t'bundler must be \"esbuild\", \"none\", or a function (fn) => Promise<FunctionBundle>',\n\t},\n);\n\nconst isEsbuildBundler = (\n\tbundler: z.infer<typeof bundlerSchema> | undefined,\n): boolean => bundler === undefined || bundler === \"esbuild\";\n\n/** The declared name of an entry, whichever form it was written in. */\nconst entryName = (\n\tentry: z.infer<typeof externalPackageEntrySchema>,\n): string => (typeof entry === \"string\" ? entry : entry.name);\n\n/** Whether an entry ships its files. Absent means yes — see `FunctionDef.externalPackages`. */\nconst entryIncludesFiles = (\n\tentry: z.infer<typeof externalPackageEntrySchema>,\n): boolean => (typeof entry === \"string\" ? true : entry.includeFiles !== false);\n\n/**\n * Static definition of a function (existence). The slug is the record key (validated by\n * {@link functionSlugSchema}), so it is not a field here. Deploy tuning (`runtime`) lives\n * in the `branch` closure, not here.\n *\n * `externalPackages` entries are checked for contradictions: the same package named twice,\n * or named once bare and once through a subpath with a different `includeFiles`. Both state\n * two intents for one package, and files are staged per package rather than per subpath, so\n * neither can be honoured as written.\n */\nexport const functionDefSchema = z\n\t.strictObject({\n\t\tname: z.string().min(1).max(255),\n\t\tsource: z.string().min(1),\n\t\tenv: functionEnvSchema.optional(),\n\t\texternalPackages: functionExternalPackagesSchema.optional(),\n\t\tbundler: bundlerSchema.optional(),\n\t\tdev: functionDevConfigSchema.optional(),\n\t\ttriggers: z.array(functionScheduleTriggerSchema).optional(),\n\t\tcustomDomains: customDomainsSchema.optional(),\n\t})\n\t.check((ctx) => {\n\t\tconst entries = ctx.value.externalPackages ?? [];\n\n\t\t// Other bundlers own their output, so `externalPackages` would be ignored.\n\t\tif (\n\t\t\tctx.value.externalPackages !== undefined &&\n\t\t\t!isEsbuildBundler(ctx.value.bundler)\n\t\t) {\n\t\t\tctx.issues.push({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tinput: ctx.value.externalPackages,\n\t\t\t\tpath: [\"externalPackages\"],\n\t\t\t\tmessage: `externalPackages only applies to the \"esbuild\" bundler; the \"${\n\t\t\t\t\ttypeof ctx.value.bundler === \"function\"\n\t\t\t\t\t\t? \"custom\"\n\t\t\t\t\t\t: ctx.value.bundler\n\t\t\t\t}\" bundler controls its own output. Remove externalPackages or switch to the esbuild bundler`,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst seenNames = new Map<string, number>();\n\t\tconst rootIntent = new Map<\n\t\t\tstring,\n\t\t\t{ includeFiles: boolean; at: string }\n\t\t>();\n\n\t\tentries.forEach((entry, index) => {\n\t\t\tconst name = entryName(entry);\n\t\t\tconst includeFiles = entryIncludesFiles(entry);\n\n\t\t\tif (includeFiles && !stageablePackageName(name)) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`\"${name}\" does not name a single installable package, so its files cannot ` +\n\t\t\t\t\t\t`be staged. Name one package, or set includeFiles: false to leave the ` +\n\t\t\t\t\t\t`import unresolved without shipping anything for it`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst firstIndex = seenNames.get(name);\n\t\t\tif (firstIndex !== undefined) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage: `\"${name}\" is listed more than once (first at index ${firstIndex})`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tseenNames.set(name, index);\n\n\t\t\t// Files are installed and traced per package, so two specifiers that resolve to the\n\t\t\t// same package cannot disagree about whether that package's files ship.\n\t\t\tconst root = externalPackageRoot(name);\n\t\t\tconst prior = rootIntent.get(root);\n\t\t\tif (prior !== undefined && prior.includeFiles !== includeFiles) {\n\t\t\t\tctx.issues.push({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tinput: entry,\n\t\t\t\t\tpath: [\"externalPackages\", index],\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t`\"${name}\" and \"${prior.at}\" are both part of the \"${root}\" package but disagree ` +\n\t\t\t\t\t\t`about includeFiles; files ship per package, so the whole package either ships or does not`,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trootIntent.set(root, { includeFiles, at: name });\n\t\t});\n\t});\n\n/** Static definition of a bucket (existence). Name is the record key. */\nexport const bucketDefSchema = z.strictObject({\n\taccess: z\n\t\t.union([z.literal(\"private\"), z.literal(\"public_read\")])\n\t\t.optional(),\n});\n\n/**\n * Functions record with trigger-name uniqueness. Used as both top-level `functions`\n * and `preview.functions` so {@link previewInputSchema} (`schemas.preview`) keeps the\n * same validation when parsed on its own.\n */\nexport const functionsRecordSchema = z\n\t.record(functionSlugSchema, functionDefSchema)\n\t.superRefine((functions, ctx) => {\n\t\tconst byName = new Map<string, string>();\n\t\tfor (const [slug, fn] of Object.entries(functions)) {\n\t\t\tconst seenOnFn = new Set<string>();\n\t\t\tfor (const [index, trigger] of (fn.triggers ?? []).entries()) {\n\t\t\t\tif (seenOnFn.has(trigger.name)) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tpath: [slug, \"triggers\", index, \"name\"],\n\t\t\t\t\t\tmessage: `trigger name \"${trigger.name}\" is listed more than once on function \"${slug}\"`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tseenOnFn.add(trigger.name);\n\t\t\t\tconst prior = byName.get(trigger.name);\n\t\t\t\tif (prior !== undefined) {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tpath: [slug, \"triggers\", index, \"name\"],\n\t\t\t\t\t\tmessage: `trigger name \"${trigger.name}\" is already used by function \"${prior}\"`,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tbyName.set(trigger.name, slug);\n\t\t\t}\n\t\t}\n\t});\n\n/** Static, beta Preview feature set: AI Gateway toggle + functions/buckets records. */\nexport const previewInputSchema = z.strictObject({\n\taiGateway: serviceToggleInputSchema.optional(),\n\tfunctions: functionsRecordSchema.optional(),\n\tbuckets: z.record(bucketNameSchema, bucketDefSchema).optional(),\n});\n\n/** Per-function deploy tuning returned by the `branch` closure. */\nexport const functionTuningSchema = z.strictObject({\n\truntime: runtimeSchema.optional(),\n\tcustomDomains: customDomainsSchema.optional(),\n});\n\n/** Per-branch Preview tuning. Keys must be slugs declared in the static `preview`. */\nconst previewTuningSchema = z.strictObject({\n\tfunctions: z.record(functionSlugSchema, functionTuningSchema).optional(),\n});\n\n/**\n * The object returned by the `branch` closure. Validated on every `resolveConfig` call so\n * tuning errors point at the concrete branch target that triggered them.\n */\nexport const branchTuningSchema = z\n\t.strictObject({\n\t\tparent: z.string().optional(),\n\t\tprotected: z.boolean().optional(),\n\t\tttl: z\n\t\t\t.union([z.string(), z.number()])\n\t\t\t.optional()\n\t\t\t.superRefine((value, ctx) => {\n\t\t\t\tif (value === undefined) return;\n\t\t\t\tconst result = parseBranchTtl(value);\n\t\t\t\tif (\"error\" in result) {\n\t\t\t\t\tctx.addIssue({ code: \"custom\", message: result.error });\n\t\t\t\t}\n\t\t\t}),\n\t\tpostgres: postgresConfigSchema.optional(),\n\t\tfunctions: z\n\t\t\t.record(functionSlugSchema, functionTuningSchema)\n\t\t\t.optional(),\n\t\tpreview: previewTuningSchema.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\tvalidateParentReference({\n\t\t\tctx,\n\t\t\tpath: [\"parent\"],\n\t\t\tparent: cfg.parent,\n\t\t});\n\t\trejectDuplicateHome(ctx, {\n\t\t\tgaPresent: cfg.functions !== undefined,\n\t\t\tpreviewPresent: cfg.preview?.functions !== undefined,\n\t\t\tgaPath: \"functions\",\n\t\t\tpreviewPath: \"preview.functions\",\n\t\t});\n\t});\n\n/**\n * The top-level object accepted by `defineConfig`. The `branch` closure is validated\n * structurally as a function here; its returned tuning is validated per-evaluation by\n * {@link branchTuningSchema} inside `resolveConfig`.\n */\nexport const configInputSchema = z\n\t.strictObject({\n\t\tauth: serviceToggleInputSchema.optional(),\n\t\tdataApi: dataApiInputSchema.optional(),\n\t\taiGateway: serviceToggleInputSchema.optional(),\n\t\tfunctions: functionsRecordSchema.optional(),\n\t\tbuckets: z.record(bucketNameSchema, bucketDefSchema).optional(),\n\t\tpreview: previewInputSchema.optional(),\n\t\tbranch: z\n\t\t\t.custom<(...args: unknown[]) => unknown>(\n\t\t\t\t(value) => typeof value === \"function\",\n\t\t\t\t{\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"branch must be a function: `branch: (branch) => ({ … })`\",\n\t\t\t\t},\n\t\t\t)\n\t\t\t.optional(),\n\t})\n\t.superRefine((cfg, ctx) => {\n\t\trejectDuplicateHome(ctx, {\n\t\t\tgaPresent: cfg.aiGateway !== undefined,\n\t\t\tpreviewPresent: cfg.preview?.aiGateway !== undefined,\n\t\t\tgaPath: \"aiGateway\",\n\t\t\tpreviewPath: \"preview.aiGateway\",\n\t\t});\n\t\trejectDuplicateHome(ctx, {\n\t\t\tgaPresent: cfg.functions !== undefined,\n\t\t\tpreviewPresent: cfg.preview?.functions !== undefined,\n\t\t\tgaPath: \"functions\",\n\t\t\tpreviewPath: \"preview.functions\",\n\t\t});\n\t\trejectDuplicateHome(ctx, {\n\t\t\tgaPresent: cfg.buckets !== undefined,\n\t\t\tpreviewPresent: cfg.preview?.buckets !== undefined,\n\t\t\tgaPath: \"buckets\",\n\t\t\tpreviewPath: \"preview.buckets\",\n\t\t});\n\t\t// A Data API verified by Neon Auth (`authProvider: \"neon\"`, the default) needs Neon\n\t\t// Auth enabled on the same branch so the tokens it verifies actually exist. Enforce\n\t\t// the same invariant the `defineConfig` type-level check expresses, at runtime.\n\t\tif (!isToggleEnabledValue(cfg.dataApi)) return;\n\t\tif (dataApiAuthProviderValue(cfg.dataApi) !== \"neon\") return;\n\t\tif (!isToggleEnabledValue(cfg.auth)) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"auth\"],\n\t\t\t\tmessage:\n\t\t\t\t\t'dataApi with authProvider \"neon\" requires Neon Auth — set `auth: true` (or `auth: { enabled: true }`), or use `dataApi.authProvider: \"external\"` with your own `jwksUrl`.',\n\t\t\t});\n\t\t}\n\t});\n\nfunction rejectDuplicateHome(\n\tctx: z.RefinementCtx,\n\targs: {\n\t\tgaPresent: boolean;\n\t\tpreviewPresent: boolean;\n\t\tgaPath: string;\n\t\tpreviewPath: string;\n\t},\n): void {\n\tif (!args.gaPresent || !args.previewPresent) return;\n\tctx.addIssue({\n\t\tcode: \"custom\",\n\t\tpath: args.gaPath.split(\".\"),\n\t\tmessage: `${args.gaPath} is also declared as ${args.previewPath}. Keep ${args.gaPath} and remove ${args.previewPath}.`,\n\t});\n}\n\n/**\n * Whether a parsed `auth` / `dataApi` toggle value is enabled: a present object (or `true`)\n * is on unless `enabled` is explicitly `false`. Mirrors `isServiceEnabled` in\n * `define-config.ts`, operating on the already-validated runtime value.\n */\nfunction isToggleEnabledValue(value: unknown): boolean {\n\tif (value === undefined || value === null) return false;\n\tif (typeof value === \"boolean\") return value;\n\tif (typeof value === \"object\") {\n\t\treturn (value as { enabled?: unknown }).enabled !== false;\n\t}\n\treturn false;\n}\n\n/** Read the (defaulted) `authProvider` from a parsed `dataApi` value. */\nfunction dataApiAuthProviderValue(value: unknown): \"neon\" | \"external\" {\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst provider = (value as { authProvider?: unknown }).authProvider;\n\t\tif (provider === \"external\") return \"external\";\n\t}\n\treturn \"neon\";\n}\n\nfunction validateParentReference(args: {\n\tctx: z.RefinementCtx;\n\tpath: (string | number)[];\n\tparent: string | undefined;\n}): void {\n\tconst { ctx, path, parent } = args;\n\tif (parent === undefined) return;\n\n\tconst patternCheck = validatePattern(parent);\n\tif (\"error\" in patternCheck) {\n\t\tctx.addIssue({ code: \"custom\", path, message: patternCheck.error });\n\t} else if (isWildcardPattern(parent)) {\n\t\tctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath,\n\t\t\tmessage: `parent must be a concrete branch name (no wildcards), got \"${parent}\"`,\n\t\t});\n\t}\n}\n\n/**\n * Convert the structured {@link z.ZodError} produced by `configSchema.safeParse` into the\n * `string[]` shape used by {@link import(\"./errors.js\").ConfigValidationError}.\n *\n * Issue paths are rendered as dot-separated property accesses (`postgres.computeSettings`)\n * and unknown-key issues from `strictObject` are normalised so the message contains the\n * substring \"unknown key\" — keeping pre-zod assertions in test suites and downstream tools\n * stable.\n */\nexport function formatZodIssues(error: z.ZodError): string[] {\n\treturn error.issues.map((issue) => {\n\t\tconst path = renderPath(issue.path);\n\t\tconst message = normaliseIssueMessage(issue);\n\t\treturn path ? `${path}: ${message}` : message;\n\t});\n}\n\nfunction renderPath(path: ReadonlyArray<PropertyKey>): string {\n\tlet out = \"\";\n\tfor (const segment of path) {\n\t\tif (typeof segment === \"number\") out += `[${segment}]`;\n\t\telse if (out === \"\") out += String(segment);\n\t\telse out += `.${String(segment)}`;\n\t}\n\treturn out;\n}\n\nfunction normaliseIssueMessage(issue: z.core.$ZodIssue): string {\n\tif (issue.code === \"unrecognized_keys\") {\n\t\tconst keys = issue.keys ?? [];\n\t\tconst formatted = keys.map((k) => JSON.stringify(k)).join(\", \");\n\t\treturn `unknown key${keys.length === 1 ? \"\" : \"s\"}: ${formatted}`;\n\t}\n\tif (issue.code === \"invalid_key\") {\n\t\t// A record *key* that fails its key schema (e.g. a bad function slug) surfaces in\n\t\t// zod as a single `invalid_key` issue whose own `message` is the generic, useless\n\t\t// \"Invalid key in record\". The actual reason — the function-slug regex rule, say —\n\t\t// lives in the nested key-schema `issues`. Hoist those so the user sees *why* the\n\t\t// key was rejected (the offending key itself is already in the issue `path`).\n\t\tconst reasons = issue.issues\n\t\t\t.map((nested) => nested.message)\n\t\t\t.filter((message) => message.length > 0);\n\t\tif (reasons.length > 0) return reasons.join(\"; \");\n\t}\n\treturn issue.message;\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,qBAAqB;;AAE3B,MAAM,2BAA2B;AAEjC,MAAM,oBAAoB,EAAE,QAAQ,eAAe,EAClD,QAAQ,UACP,iGAAiG,KAAK,UAAU,MAAM,KAAK,EAAE,GAC/H,CAAC;;;;;;;;;;;;;;;AAgBD,MAAa,wBAAwB,EACnC,aAAa;CACb,uBAAuB,kBAAkB,SAAS;CAClD,uBAAuB,kBAAkB,SAAS;CAClD,gBAAgB,EACd,MAAM;EAAC,EAAE,QAAQ,KAAK;EAAG,EAAE,OAAO;EAAG,EAAE,OAAO;CAAC,CAAC,CAAC,CACjD,SAAS,CAAC,CACV,aAAa,OAAO,QAAQ;EAC5B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,oBAAoB,KAAK;EACxC,IAAI,WAAW,QACd,IAAI,SAAS;GACZ,MAAM;GACN,SAAS,OAAO;EACjB,CAAC;CAEH,CAAC;AACH,CAAC,CAAC,CACD,aAAa,UAAU,QAAQ;CAC/B,MAAM,EAAE,uBAAuB,KAAK,uBAAuB,QAC1D;CACD,IAAI,QAAQ,KAAA,KAAa,QAAQ,KAAA,GAAW;CAC5C,IAAI,MAAM,KAAK;EACd,IAAI,SAAS;GACZ,MAAM;GACN,MAAM,CAAC,uBAAuB;GAC9B,SAAS,0BAA0B,IAAI,sCAAsC,IAAI;EAClF,CAAC;EACD;CACD;CACA,IAAI,QAAQ,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C;EAC5B,MAAM,YAAY,KAAK,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;EAC9D,OAAO,cAAc,KAAK,WAAW,IAAI,KAAK,IAAI,IAAI;CACvD;CACA,IAAI,MAAM,SAAS,eAAe;EAMjC,MAAM,UAAU,MAAM,OACpB,KAAK,WAAW,OAAO,OAAO,CAAC,CAC/B,QAAQ,YAAY,QAAQ,SAAS,CAAC;EACxC,IAAI,QAAQ,SAAS,GAAG,OAAO,QAAQ,KAAK,IAAI;CACjD;CACA,OAAO,MAAM;AACd"}
@@ -311,9 +311,9 @@ type FunctionBundler = (fn: ResolvedFunctionConfig) => Promise<FunctionBundle>;
311
311
  */
312
312
  type FunctionBundlerInput = "esbuild" | "none" | FunctionBundler;
313
313
  /**
314
- * Static definition of a Neon Function (Preview feature). Declares that the function
314
+ * Static definition of a Neon Function. Declares that the function
315
315
  * **exists** on every branch; its branch-unique slug is the **record key** in
316
- * {@link PreviewInput.functions} (not a field here), so slugs are statically enumerable,
316
+ * `functions` (or deprecated {@link PreviewInput.functions}), so slugs are statically enumerable,
317
317
  * cannot duplicate, and the `branch` closure can only tune slugs that are declared here.
318
318
  * Runtime tuning is **not** here — it varies per branch and lives in the `branch` closure
319
319
  * (see {@link FunctionTuning}). Memory is fixed by the platform policy for now and is not
@@ -470,8 +470,8 @@ type CredentialPrincipalType = "user" | "function";
470
470
  /** Anonymous-access level for a branchable object-storage bucket. */
471
471
  type BucketAccessLevel = "private" | "public_read";
472
472
  /**
473
- * Static definition of a branchable object-storage bucket (Preview feature). The bucket's
474
- * name is the **record key** in {@link PreviewInput.buckets}, so names are statically
473
+ * Static definition of a branchable object-storage bucket. The bucket's
474
+ * name is the **record key** in `buckets` (or deprecated {@link PreviewInput.buckets}), so names are statically
475
475
  * enumerable and cannot duplicate.
476
476
  */
477
477
  interface BucketDef {
@@ -482,17 +482,28 @@ interface BucketDef {
482
482
  access?: BucketAccessLevel;
483
483
  }
484
484
  /**
485
- * Static, branch-scoped **Preview** features. Grouped under `preview` to signal they are
486
- * backed by Neon `x-stability-level: beta` endpoints and may change before GA. Everything
487
- * here is existential (it determines what exists on the branch); per-branch tuning lives in
488
- * the `branch` closure.
485
+ * Deprecated home for AI Gateway, Functions, and Object Storage.
486
+ *
487
+ * Those services are GA as top-level `aiGateway`, `functions`, and `buckets`.
488
+ * A `preview` block still works; deploy/apply warns that the keys can be lifted.
489
+ *
490
+ * @deprecated Use top-level `aiGateway`, `functions`, and `buckets`.
489
491
  */
490
492
  interface PreviewInput {
491
- /** Enable/disable the AI Gateway on the branch (toggle, like auth / dataApi). */
493
+ /**
494
+ * Enable/disable the AI Gateway on the branch (toggle, like auth / dataApi).
495
+ * @deprecated Use top-level `aiGateway`.
496
+ */
492
497
  aiGateway?: ServiceToggleInput;
493
- /** Functions to deploy, keyed by branch-unique slug (`^[a-z0-9]{1,20}$`). */
498
+ /**
499
+ * Functions to deploy, keyed by branch-unique slug (`^[a-z0-9]{1,20}$`).
500
+ * @deprecated Use top-level `functions`.
501
+ */
494
502
  functions?: Record<string, FunctionDef>;
495
- /** Object-storage buckets to create, keyed by bucket name. */
503
+ /**
504
+ * Object-storage buckets to create, keyed by bucket name.
505
+ * @deprecated Use top-level `buckets`.
506
+ */
496
507
  buckets?: Record<string, BucketDef>;
497
508
  }
498
509
  /**
@@ -512,11 +523,16 @@ interface FunctionTuning {
512
523
  customDomains?: string[];
513
524
  }
514
525
  /**
515
- * Per-branch tuning of Preview features. Only existing function slugs (those declared in
516
- * the static {@link PreviewInput.functions}) may be tuned — `Slug` is constrained to the
526
+ * Per-branch tuning of functions under the deprecated `preview` key.
527
+ * Only existing function slugs may be tuned — `Slug` is constrained to the
517
528
  * declared keys by {@link BranchTuningFn}.
529
+ *
530
+ * @deprecated Use top-level `branch: (branch) => ({ functions: { … } })`.
518
531
  */
519
532
  interface PreviewTuning<Slug extends string = string> {
533
+ /**
534
+ * @deprecated Use top-level `functions` on the object returned by `branch`.
535
+ */
520
536
  functions?: Partial<Record<Slug, FunctionTuning>>;
521
537
  }
522
538
  /**
@@ -554,31 +570,39 @@ interface BranchTuning<Slug extends string = string> {
554
570
  /** Whether the selected branch should be protected. Undefined means "leave as-is". */
555
571
  protected?: boolean;
556
572
  postgres?: PostgresConfig;
573
+ /** Per-function deploy tuning, keyed by declared slug. */
574
+ functions?: Partial<Record<Slug, FunctionTuning>>;
575
+ /**
576
+ * @deprecated Use top-level `functions` on this object.
577
+ */
557
578
  preview?: PreviewTuning<Slug>;
558
579
  }
559
- /** Extract the declared function slugs from a {@link PreviewInput} for closure typing. */
560
- type FunctionSlugsOf<Preview extends PreviewInput | undefined> = Preview extends {
580
+ /** Extract declared function slugs from top-level `functions` and/or `preview.functions`. */
581
+ type PreviewFunctionSlugs<Preview> = Preview extends {
561
582
  functions: infer F;
562
- } ? Extract<keyof F, string> : string;
583
+ } ? Extract<keyof F, string> : never;
584
+ type GaFunctionSlugs<Functions> = [Functions] extends [undefined] ? never : string extends keyof NonNullable<Functions> ? never : Extract<keyof NonNullable<Functions>, string>;
585
+ type FunctionSlugsOf<Preview extends PreviewInput | undefined, Functions extends Record<string, FunctionDef> | undefined = undefined> = [PreviewFunctionSlugs<Preview> | GaFunctionSlugs<Functions>] extends [never] ? string : PreviewFunctionSlugs<Preview> | GaFunctionSlugs<Functions>;
563
586
  /**
564
- * Signature of the `branch` closure. Generic over the static {@link PreviewInput} so the
565
- * `preview.functions` keys it may tune are constrained to the slugs actually declared.
587
+ * Signature of the `branch` closure. Generic over the static function homes so the
588
+ * `functions` keys it may tune are constrained to the slugs actually declared.
566
589
  */
567
- type BranchTuningFn<Preview extends PreviewInput | undefined = PreviewInput | undefined> = (branch: BranchTarget) => BranchTuning<FunctionSlugsOf<Preview>>;
590
+ type BranchTuningFn<Preview extends PreviewInput | undefined = PreviewInput | undefined, Functions extends Record<string, FunctionDef> | undefined = undefined> = (branch: BranchTarget) => BranchTuning<FunctionSlugsOf<Preview, Functions>>;
568
591
  /**
569
592
  * A validated Neon branch policy — the value `defineConfig({ … })` returns and `neon.ts`
570
593
  * default-exports.
571
594
  *
572
- * Split into a **static** existential set (top-level `auth` / `dataApi` GA toggles plus the
573
- * beta `preview` block) and a **dynamic** per-branch `branch` closure for tuning. The
574
- * static half is what makes the secret set — and therefore `NeonEnv<typeof config>` and
575
- * `parseEnv` — exact; the closure can tune but never change what exists.
595
+ * Split into a **static** existential set (top-level service toggles and records) and a
596
+ * **dynamic** per-branch `branch` closure for tuning. The static half is what makes the
597
+ * secret set — and therefore `NeonEnv<typeof config>` and `parseEnv` — exact; the closure
598
+ * can tune but never change what exists.
576
599
  *
577
- * Generic over the three static fields so the type system can read the exact toggle/slug
600
+ * Generic over the static fields so the type system can read the exact toggle/slug
578
601
  * literals; the defaults make the bare `Config` a usable "any policy" type for runtime
579
- * function signatures.
602
+ * function signatures. The first three type parameters stay `Auth`, `DataApi`, `Preview`
603
+ * so existing positional `Config<Auth, DataApi, Preview>` consumers keep compiling.
580
604
  */
581
- interface Config<Auth extends ServiceToggleInput | undefined = ServiceToggleInput | undefined, DataApi extends DataApiInput | undefined = DataApiInput | undefined, Preview extends PreviewInput | undefined = PreviewInput | undefined> {
605
+ interface Config<Auth extends ServiceToggleInput | undefined = ServiceToggleInput | undefined, DataApi extends DataApiInput | undefined = DataApiInput | undefined, Preview extends PreviewInput | undefined = PreviewInput | undefined, Functions extends Record<string, FunctionDef> | undefined = Record<string, FunctionDef> | undefined, Buckets extends Record<string, BucketDef> | undefined = Record<string, BucketDef> | undefined, AiGateway extends ServiceToggleInput | undefined = ServiceToggleInput | undefined> {
582
606
  /** Neon Auth integration toggle (GA). Static — drives `NeonEnv.auth`. */
583
607
  auth?: Auth;
584
608
  /**
@@ -588,10 +612,24 @@ interface Config<Auth extends ServiceToggleInput | undefined = ServiceToggleInpu
588
612
  * top-level `auth`.
589
613
  */
590
614
  dataApi?: DataApi;
591
- /** Beta (Preview) feature set: AI Gateway, functions, buckets. Static. */
615
+ /**
616
+ * AI Gateway toggle (GA). Static — drives `NeonEnv.aiGateway`. Same shapes as `auth`.
617
+ */
618
+ aiGateway?: AiGateway;
619
+ /**
620
+ * Functions to deploy, keyed by branch-unique slug (`^[a-z0-9]{1,20}$`).
621
+ */
622
+ functions?: Functions;
623
+ /**
624
+ * Object-storage buckets to create, keyed by bucket name.
625
+ */
626
+ buckets?: Buckets;
627
+ /**
628
+ * @deprecated Use top-level `aiGateway`, `functions`, and `buckets`.
629
+ */
592
630
  preview?: Preview;
593
631
  /** Per-branch tuning closure. Cannot change the static existential set. */
594
- branch?: BranchTuningFn<Preview>;
632
+ branch?: BranchTuningFn<Preview, Functions>;
595
633
  }
596
634
  /**
597
635
  * A function with all deploy defaults applied. `resolveConfig` fills in `runtime` so
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/lib/types.ts"],"mappings":";;AAKA;AAKA;AAGA;AAeA;AAQK,cA/BQ,aA+BgB,EAAA,SAAA,CAAA,IAAA,EAAA,GAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAiBxB,KA3CO,WAAA,GA2CM,CAAA,OA3CgB,aA2ChB,CAAA,CAAA,MAAA,CAAA;AAAA;AAQA,KAhDN,YAAA,GAgDM,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA;AAAq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