@postman/sdk-config 0.0.4 → 0.1.1

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.
Files changed (36) hide show
  1. package/README.md +124 -101
  2. package/dist/index.cjs +2119 -282
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +3 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.js +2080 -283
  7. package/dist/index.js.map +1 -1
  8. package/dist/sdk-config/index.cjs +2238 -0
  9. package/dist/sdk-config/index.cjs.map +1 -0
  10. package/dist/sdk-config/index.d.cts +3 -0
  11. package/dist/sdk-config/index.d.ts +3 -0
  12. package/dist/sdk-config/index.js +2196 -0
  13. package/dist/sdk-config/index.js.map +1 -0
  14. package/dist/sdk-config/v1/index.cjs +2238 -0
  15. package/dist/sdk-config/v1/index.cjs.map +1 -0
  16. package/dist/sdk-config/v1/index.d.cts +8644 -0
  17. package/dist/sdk-config/v1/index.d.ts +8644 -0
  18. package/dist/sdk-config/v1/index.js +2196 -0
  19. package/dist/sdk-config/v1/index.js.map +1 -0
  20. package/dist/sdk-config-ir/index.cjs +160 -25
  21. package/dist/sdk-config-ir/index.cjs.map +1 -1
  22. package/dist/sdk-config-ir/index.d.cts +2 -1
  23. package/dist/sdk-config-ir/index.d.ts +2 -1
  24. package/dist/sdk-config-ir/index.js +158 -26
  25. package/dist/sdk-config-ir/index.js.map +1 -1
  26. package/dist/sdk-config-ir/v1/index.cjs +160 -25
  27. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  28. package/dist/sdk-config-ir/v1/index.d.cts +458 -428
  29. package/dist/sdk-config-ir/v1/index.d.ts +458 -428
  30. package/dist/sdk-config-ir/v1/index.js +158 -26
  31. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  32. package/dist/typescript-DK97815_.d.cts +427 -0
  33. package/dist/typescript-DK97815_.d.ts +427 -0
  34. package/package.json +16 -3
  35. package/src/sdk-config/v1/README.md +135 -0
  36. package/src/sdk-config-ir/v1/README.md +44 -26
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import semver from 'semver';
3
3
 
4
- // src/sdk-config-ir/v1/api.ts
4
+ // src/sdk-config-domain/v1/api.ts
5
5
  var nonEmptyStringSchema = z.string().min(1);
6
+ var relativePathSchema = nonEmptyStringSchema.refine(
7
+ (value) => !/^(?:[\\/]|[A-Za-z]:)/.test(value) && !value.split(/[\\/]/).some((segment) => segment === ".."),
8
+ { message: "must be a relative path without parent directory segments" }
9
+ );
6
10
  var exactSemverSchema = z.string().refine(
7
11
  (value) => {
8
12
  if (value.trim() !== value || !/^\d/.test(value)) {
@@ -25,7 +29,7 @@ var jsonValueSchema = z.lazy(
25
29
  );
26
30
  var jsonObjectSchema = z.record(z.string(), jsonValueSchema);
27
31
 
28
- // src/sdk-config-ir/v1/api.ts
32
+ // src/sdk-config-domain/v1/api.ts
29
33
  var authVariableSchema = z.strictObject({
30
34
  name: nonEmptyStringSchema.optional(),
31
35
  environmentVariable: nonEmptyStringSchema.optional(),
@@ -175,8 +179,20 @@ var apiConfigSchema = z.strictObject({
175
179
  environmentVariables: z.array(environmentVariableSchema).default([]),
176
180
  defaultEnvironment: nonEmptyStringSchema.optional(),
177
181
  auth: authConfigSchema.optional(),
178
- headers: z.array(headerSchema).optional()
182
+ headers: z.array(headerSchema).optional(),
183
+ /**
184
+ * Selects the named `x-fern-audiences`.
185
+ *
186
+ * Absent means all audiences. A present empty array selects no tagged audience: untagged nodes
187
+ * remain included, while every audience-tagged node is excluded.
188
+ */
189
+ audiences: z.array(nonEmptyStringSchema).optional()
179
190
  });
191
+
192
+ // src/sdk-config/v1/api.ts
193
+ var sdkConfigV1AuthSchemeSchema = authSchemeSchema;
194
+ var sdkConfigV1AuthConfigSchema = authConfigSchema;
195
+ var sdkConfigV1ApiConfigSchema = apiConfigSchema;
180
196
  var retryConfigSchema = z.strictObject({
181
197
  enabled: z.boolean().default(true),
182
198
  maxAttempts: z.number().int().min(1).default(3),
@@ -229,178 +245,13 @@ var clientConfigSchema = z.strictObject({
229
245
  pathParameterStyle: parameterStyleSchema.optional(),
230
246
  filePropertyStyle: parameterStyleSchema.optional(),
231
247
  useDefaultRequestParameterValues: z.boolean().optional(),
248
+ respectOptionalRequestBody: z.boolean().optional(),
232
249
  tokenRefresh: tokenRefreshConfigSchema.optional()
233
250
  });
234
- var unsupportedFieldSchema = z.strictObject({
235
- source: z.enum(["fern", "postman", "sdk-config-ir"]),
236
- path: z.array(z.union([nonEmptyStringSchema, z.number().int().nonnegative()])).min(1),
237
- code: nonEmptyStringSchema.optional(),
238
- reason: nonEmptyStringSchema,
239
- severity: z.enum(["error", "warning", "info"]),
240
- risk: z.enum(["high", "medium", "low"]),
241
- owner: nonEmptyStringSchema,
242
- suggestedAction: nonEmptyStringSchema
243
- });
244
- var postmanLegacyInputSchema = z.strictObject({
245
- kind: z.literal("postman-build-parameters"),
246
- value: jsonObjectSchema
247
- });
248
- var fernLegacyInputSchema = z.strictObject({
249
- kind: z.literal("fern-generator-invocation"),
250
- value: jsonObjectSchema
251
- });
252
- var legacyInputSchema = z.discriminatedUnion("kind", [
253
- postmanLegacyInputSchema,
254
- fernLegacyInputSchema
255
- ]);
256
- var compatibilityConfigSchema = z.strictObject({
257
- outputProfile: z.enum(["converged", "postman-legacy", "fern-legacy"]),
258
- legacyInput: legacyInputSchema.optional(),
259
- unsupportedFields: z.array(unsupportedFieldSchema).optional()
260
- });
261
- var httpMethodSchema = z.enum([
262
- "GET",
263
- "POST",
264
- "PUT",
265
- "PATCH",
266
- "DELETE",
267
- "HEAD",
268
- "OPTIONS",
269
- "TRACE",
270
- "CONNECT"
271
- ]);
272
- var readmeEndpointSchema = z.strictObject({
273
- method: httpMethodSchema,
274
- path: nonEmptyStringSchema,
275
- stream: z.boolean().optional()
276
- });
277
- var readmeConfigSchema = z.strictObject({
278
- apiName: nonEmptyStringSchema.optional(),
279
- introduction: z.string().optional(),
280
- apiReferenceLink: nonEmptyStringSchema.optional(),
281
- bannerLink: nonEmptyStringSchema.optional(),
282
- disabledSections: z.array(nonEmptyStringSchema).optional(),
283
- defaultEndpoint: readmeEndpointSchema.optional(),
284
- features: z.record(z.string(), z.array(readmeEndpointSchema)).optional()
285
- });
286
- var snippetsConfigSchema = z.strictObject({
287
- enabled: z.boolean(),
288
- format: z.enum(["md", "json"]).optional(),
289
- outputPath: nonEmptyStringSchema.optional()
290
- });
291
- var docsConfigSchema = z.strictObject({
292
- readme: readmeConfigSchema.optional(),
293
- snippets: snippetsConfigSchema.optional(),
294
- referenceBaseUrl: nonEmptyStringSchema.optional(),
295
- includeApiReference: z.boolean().optional()
296
- });
297
- var cliGenerationConfigSchema = z.strictObject({
298
- paginationParameters: z.array(nonEmptyStringSchema).optional(),
299
- skills: z.boolean().optional()
300
- });
301
- var csharpGenerationConfigSchema = z.strictObject({
302
- useOptionalWrapper: z.boolean().optional(),
303
- simplifyObjectDictionaries: z.boolean().optional(),
304
- explicitNamespaces: z.boolean().optional(),
305
- rootNamespaceForCoreClasses: z.boolean().optional(),
306
- includeExceptionHandler: z.boolean().optional()
307
- });
308
- var goGenerationConfigSchema = z.strictObject({
309
- legacyComplexModels: z.boolean().optional(),
310
- unionVersion: z.enum(["v0", "v1"]).optional(),
311
- includeLegacyClientOptions: z.boolean().optional()
312
- });
313
- var jvmGenerationConfigSchema = z.strictObject({
314
- packageLayout: z.enum(["flat", "nested"]).optional(),
315
- useLocalDateForDates: z.boolean().optional(),
316
- collapseOptionalNullable: z.boolean().optional(),
317
- gradleDistributionUrl: z.string().min(1).optional(),
318
- gradlePluginManagement: z.string().optional(),
319
- gradleCentralDependencyManagement: z.boolean().optional()
320
- });
321
-
322
- // src/sdk-config-ir/v1/language/java.ts
323
- var javaGenerationConfigSchema = jvmGenerationConfigSchema.extend({
324
- includeKotlinSnippets: z.boolean().optional()
325
- });
326
-
327
- // src/sdk-config-ir/v1/language/kotlin.ts
328
- var kotlinGenerationConfigSchema = jvmGenerationConfigSchema;
329
- var compilerOptionsSchema = z.strictObject({
330
- target: nonEmptyStringSchema.optional(),
331
- module: nonEmptyStringSchema.optional(),
332
- lib: z.array(nonEmptyStringSchema).optional()
333
- });
334
- var packageScriptSchema = z.strictObject({
335
- name: nonEmptyStringSchema,
336
- command: nonEmptyStringSchema
337
- });
338
- var httpClientSchema = z.strictObject({
339
- name: z.enum(["axios", "fetch"])
340
- });
341
- var typescriptGenerationConfigSchema = z.strictObject({
342
- typescriptVersion: nonEmptyStringSchema.optional(),
343
- zodVersion: nonEmptyStringSchema.optional(),
344
- compilerOptions: compilerOptionsSchema.optional(),
345
- httpClient: httpClientSchema.optional(),
346
- packageManager: z.enum(["pnpm", "yarn"]).optional(),
347
- testFramework: z.enum(["jest", "vitest"]).optional(),
348
- namingStrategy: z.enum(["base", "originalPropertyNames"]).optional(),
349
- bundle: z.boolean().optional(),
350
- exportClassDefault: z.boolean().optional(),
351
- allowCustomFetcher: z.boolean().optional(),
352
- useBrandedStringAliases: z.boolean().optional(),
353
- useLegacyExports: z.boolean().optional(),
354
- useBigInt: z.boolean().optional(),
355
- serdeLayer: z.boolean().optional(),
356
- scripts: z.array(packageScriptSchema).optional()
357
- });
358
251
 
359
- // src/sdk-config-ir/v1/language/mcp.ts
360
- var mcpGenerationConfigSchema = typescriptGenerationConfigSchema;
361
- var phpGenerationConfigSchema = z.strictObject({
362
- propertyAccess: z.enum(["public", "private"]).optional(),
363
- generateClientInterfaces: z.boolean().optional()
364
- });
365
- var pythonClientSchema = z.strictObject({
366
- fileName: nonEmptyStringSchema.optional(),
367
- exportedFileName: nonEmptyStringSchema.optional()
368
- });
369
- var pydanticConfigSchema = z.strictObject({
370
- versionCompatibility: z.enum(["v1", "v2", "both", "v1-on-v2"]).optional(),
371
- frozen: z.boolean().optional(),
372
- requireOptionalFields: z.boolean().optional(),
373
- unionNaming: z.enum(["v0", "v1"]).optional(),
374
- useFieldAliases: z.boolean().optional()
375
- });
376
- var pythonGenerationConfigSchema = z.strictObject({
377
- pythonVersion: nonEmptyStringSchema.optional(),
378
- pydanticVersion: nonEmptyStringSchema.optional(),
379
- pydantic: pydanticConfigSchema.optional(),
380
- client: pythonClientSchema.optional(),
381
- alwaysInitializeOptionals: z.boolean().optional(),
382
- useTypedDictRequests: z.boolean().optional()
383
- });
384
- var rubyGenerationConfigSchema = z.strictObject({
385
- requirePaths: z.array(nonEmptyStringSchema).optional()
386
- });
387
- var rustGenerationConfigSchema = z.strictObject({
388
- /**
389
- * Rust type for datetime primitives. `offset` maps to `DateTime<FixedOffset>` and preserves the
390
- * timezone the payload carried; `utc` maps to `DateTime<Utc>` and normalizes to UTC.
391
- */
392
- dateTimeType: z.enum(["offset", "utc"]).optional(),
393
- /** Uppercase common initialisms in generated names (`UserID` rather than `UserId`). */
394
- capitalizeInitialisms: z.boolean().optional(),
395
- /** Cargo features, mapping a feature name to the dependencies or features it enables. */
396
- features: z.record(z.string(), z.array(nonEmptyStringSchema)).optional(),
397
- /** Overrides which features make up Cargo's `default` feature set. */
398
- defaultFeatures: z.array(nonEmptyStringSchema).optional()
399
- });
400
- var swiftGenerationConfigSchema = z.strictObject({
401
- moduleName: nonEmptyStringSchema.optional()
402
- });
403
- var goModulePathSchema = nonEmptyStringSchema.regex(
252
+ // src/sdk-config/v1/client.ts
253
+ var sdkConfigV1ClientConfigSchema = clientConfigSchema;
254
+ var goModulePathSchema = relativePathSchema.regex(
404
255
  /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)+$/,
405
256
  "Go module path must be a slash-delimited path using letters, numbers, dots, dashes, underscores, or tildes"
406
257
  );
@@ -478,96 +329,1965 @@ var packageConfigSchema = z.strictObject({
478
329
  extraDevDependencies: z.array(dependencySchema).optional(),
479
330
  extraPeerDependencies: z.array(dependencySchema).optional()
480
331
  });
481
-
482
- // src/sdk-config-ir/v1/language/terraform.ts
483
- var planModifierSourceSchema = z.discriminatedUnion("enabled", [
484
- z.strictObject({ enabled: z.literal(true), sourceDir: nonEmptyStringSchema }),
485
- z.strictObject({ enabled: z.literal(false) })
332
+ var httpMethodSchema = z.enum([
333
+ "GET",
334
+ "POST",
335
+ "PUT",
336
+ "PATCH",
337
+ "DELETE",
338
+ "HEAD",
339
+ "OPTIONS",
340
+ "TRACE",
341
+ "CONNECT"
486
342
  ]);
487
- var planModifiersSchema = z.strictObject({
488
- resources: planModifierSourceSchema,
489
- attributes: planModifierSourceSchema
490
- });
491
- var providerSchemaSchema = z.strictObject({
492
- addressKey: nonEmptyStringSchema,
493
- authTokenKey: nonEmptyStringSchema
494
- });
495
- var terraformGenerationConfigSchema = z.strictObject({
496
- providerName: nonEmptyStringSchema.optional(),
497
- providerVersion: nonEmptyStringSchema.optional(),
498
- providerModulePath: goModulePathSchema.optional(),
499
- mockAcceptance: z.boolean().optional(),
500
- hideComputedDiff: z.boolean().optional(),
501
- providerSchema: providerSchemaSchema.optional(),
502
- planModifiers: planModifiersSchema.optional()
503
- });
504
-
505
- // src/sdk-config-ir/v1/generation.ts
506
- var generationAssetSchema = z.strictObject({
507
- type: z.enum(["path", "url", "artifact"]),
508
- location: nonEmptyStringSchema
343
+ var readmeEndpointSchema = z.strictObject({
344
+ method: httpMethodSchema,
345
+ path: nonEmptyStringSchema,
346
+ stream: z.boolean().optional()
509
347
  });
510
- var hookDependencySchema = z.strictObject({
511
- name: nonEmptyStringSchema,
512
- version: nonEmptyStringSchema,
513
- groupId: nonEmptyStringSchema.optional()
348
+ var readmeCustomSectionSchema = z.strictObject({
349
+ title: nonEmptyStringSchema,
350
+ content: z.string()
514
351
  });
515
- var hooksConfigSchema = z.strictObject({
516
- enabled: z.boolean(),
517
- source: generationAssetSchema.optional(),
518
- dependencies: z.array(hookDependencySchema).optional()
352
+ var readmeConfigSchema = z.strictObject({
353
+ apiName: nonEmptyStringSchema.optional(),
354
+ introduction: z.string().optional(),
355
+ apiReferenceLink: nonEmptyStringSchema.optional(),
356
+ bannerLink: nonEmptyStringSchema.optional(),
357
+ disabledSections: z.array(nonEmptyStringSchema).optional(),
358
+ customSections: z.array(readmeCustomSectionSchema).optional(),
359
+ defaultEndpoint: readmeEndpointSchema.optional(),
360
+ features: z.record(z.string(), z.array(readmeEndpointSchema)).optional()
519
361
  });
520
- var customCodeConfigSchema = z.strictObject({
362
+ var snippetsConfigSchema = z.strictObject({
521
363
  enabled: z.boolean(),
522
- source: generationAssetSchema.optional(),
523
- conflictStrategy: z.enum(["mark", "ours", "theirs"]).optional(),
524
- trackChanges: z.boolean().optional(),
525
- previousBuildId: z.number().int().positive().optional(),
526
- protectedFiles: z.array(nonEmptyStringSchema).optional()
364
+ format: z.enum(["md", "json"]).optional(),
365
+ outputPath: nonEmptyStringSchema.optional()
527
366
  });
528
- var workflowConfigSchema = z.strictObject({
529
- path: nonEmptyStringSchema,
530
- outputName: nonEmptyStringSchema.optional()
367
+ var docsConfigSchema = z.strictObject({
368
+ readme: readmeConfigSchema.optional(),
369
+ snippets: snippetsConfigSchema.optional(),
370
+ referenceBaseUrl: nonEmptyStringSchema.optional(),
371
+ includeApiReference: z.boolean().optional()
531
372
  });
532
- var analyticsHeaderSchema = z.union([
533
- z.strictObject({ name: nonEmptyStringSchema, value: z.string() }),
534
- z.strictObject({ name: nonEmptyStringSchema, valueRef: nonEmptyStringSchema })
535
- ]);
536
- var analyticsConfigSchema = z.strictObject({
537
- enabled: z.boolean(),
538
- endpoint: nonEmptyStringSchema.optional(),
539
- exporter: z.enum(["otlp-http", "console"]).optional(),
540
- headers: z.array(analyticsHeaderSchema).optional(),
541
- batchSize: z.number().int().positive().optional(),
542
- scheduledDelayMs: z.number().nonnegative().optional(),
543
- exportTimeoutMs: z.number().nonnegative().optional()
544
- }).superRefine(({ enabled, endpoint }, context) => {
545
- if (enabled && endpoint === void 0) {
546
- context.addIssue({
547
- code: "custom",
548
- message: "endpoint is required when analytics is enabled",
549
- path: ["endpoint"]
550
- });
373
+
374
+ // src/sdk-config/v1/docs.ts
375
+ var sdkConfigV1ReadmeEndpointSchema = readmeEndpointSchema;
376
+ var sdkConfigV1ReadmeCustomSectionSchema = readmeCustomSectionSchema;
377
+ var sdkConfigV1DocsConfigSchema = docsConfigSchema;
378
+
379
+ // src/sdk-config/v1/fern-config-mapper-types.ts
380
+ var FernConfigMappingError = class extends Error {
381
+ constructor(issues) {
382
+ super(issues.map(({ path, reason }) => `${path.join(".")}: ${reason}`).join("\n"));
383
+ this.issues = issues;
384
+ this.name = "FernConfigMappingError";
551
385
  }
552
- });
386
+ issues;
387
+ };
388
+
389
+ // src/sdk-config/v1/fern-config-mapper-helpers.ts
390
+ function fail(code, path, reason, suggestedAction, sdkConfigPath) {
391
+ throw new FernConfigMappingError([
392
+ {
393
+ code,
394
+ severity: "error",
395
+ path,
396
+ reason,
397
+ suggestedAction,
398
+ ...optional("sdkConfigPath", sdkConfigPath)
399
+ }
400
+ ]);
401
+ }
402
+ function takeTimeoutMs(value, state, basePath) {
403
+ const milliseconds = locate(value, ["defaultTimeout", "defaultTimeoutInMilliseconds"], basePath);
404
+ if (milliseconds && (milliseconds.value === "infinity" || isNonNegativeNumber(milliseconds.value))) {
405
+ consume(state, milliseconds.path);
406
+ return milliseconds.value;
407
+ }
408
+ const seconds = locate(
409
+ value,
410
+ ["defaultTimeoutInSeconds", "timeoutInSeconds", "timeout"],
411
+ basePath
412
+ );
413
+ if (seconds && (seconds.value === "infinity" || isNonNegativeNumber(seconds.value))) {
414
+ consume(state, seconds.path);
415
+ return seconds.value === "infinity" ? "infinity" : seconds.value * 1e3;
416
+ }
417
+ return void 0;
418
+ }
419
+ function locate(value, aliases, basePath) {
420
+ for (const [key, child] of Object.entries(value)) {
421
+ if (aliases.some((alias) => normalizeKey(alias) === normalizeKey(key))) {
422
+ return { value: child, path: [...basePath, key] };
423
+ }
424
+ }
425
+ return void 0;
426
+ }
427
+ function takeObject(value, aliases, _state, basePath) {
428
+ const located = locate(value, aliases, basePath);
429
+ return located && isObject(located.value) ? { value: located.value, path: located.path } : void 0;
430
+ }
431
+ function takeString(value, aliases, state, basePath) {
432
+ const located = locate(value, aliases, basePath);
433
+ if (!located || typeof located.value !== "string" || located.value.length === 0) return void 0;
434
+ consume(state, located.path);
435
+ return located.value;
436
+ }
437
+ function takeGoModulePath(value, aliases, state, basePath) {
438
+ const located = locate(value, aliases, basePath);
439
+ if (!located || !goModulePathSchema.safeParse(located.value).success) return void 0;
440
+ consume(state, located.path);
441
+ return located.value;
442
+ }
443
+ function takeBoolean(value, aliases, state, basePath) {
444
+ const located = locate(value, aliases, basePath);
445
+ if (!located || typeof located.value !== "boolean") return void 0;
446
+ consume(state, located.path);
447
+ return located.value;
448
+ }
449
+ function takeNumber(value, aliases, state, basePath) {
450
+ const located = locate(value, aliases, basePath);
451
+ if (!located || !isNonNegativeNumber(located.value) || !Number.isInteger(located.value))
452
+ return void 0;
453
+ consume(state, located.path);
454
+ return located.value;
455
+ }
456
+ function takeEnum(value, aliases, values, state, basePath) {
457
+ const located = locate(value, aliases, basePath);
458
+ if (!located || typeof located.value !== "string" || !values.includes(located.value))
459
+ return void 0;
460
+ consume(state, located.path);
461
+ return located.value;
462
+ }
463
+ function takeEnumArray(value, aliases, values, state, basePath) {
464
+ const located = locate(value, aliases, basePath);
465
+ if (!located || !Array.isArray(located.value) || located.value.some((item) => typeof item !== "string" || !values.includes(item)))
466
+ return void 0;
467
+ consume(state, located.path);
468
+ return located.value;
469
+ }
470
+ function takeStringArray(value, aliases, state, basePath) {
471
+ const located = locate(value, aliases, basePath);
472
+ const strings = located ? stringArrayValue(located.value) : void 0;
473
+ if (!located || !strings) return void 0;
474
+ consume(state, located.path);
475
+ return strings;
476
+ }
477
+ function takeStringArrayRecord(value, aliases, state, basePath) {
478
+ const located = locate(value, aliases, basePath);
479
+ if (!located || !isObject(located.value)) return void 0;
480
+ const entries = Object.entries(located.value);
481
+ if (entries.some(([, item]) => !stringArrayValue(item))) return void 0;
482
+ consume(state, located.path);
483
+ return Object.fromEntries(entries);
484
+ }
485
+ function collectUnsupported(value, basePath, state) {
486
+ return collectLeafPaths(value, basePath).filter((path) => {
487
+ const key = pathKey(path);
488
+ return ![...state.consumedPaths].some(
489
+ (consumed) => key === consumed || key.startsWith(`${consumed}.`)
490
+ );
491
+ }).map((path) => ({
492
+ code: "FERN_CONFIG_FIELD_UNSUPPORTED",
493
+ severity: "warning",
494
+ path,
495
+ reason: "Fern configuration field is not represented by SDK Config v1",
496
+ suggestedAction: "Review this value and set the closest SDK Config field manually, or preserve the setting outside SDK Config if no equivalent exists."
497
+ }));
498
+ }
499
+ function collectLeafPaths(value, path) {
500
+ if (Array.isArray(value))
501
+ return value.flatMap((item, index) => collectLeafPaths(item, [...path, index]));
502
+ if (isObject(value))
503
+ return Object.entries(value).flatMap(([key, child]) => collectLeafPaths(child, [...path, key]));
504
+ return value === void 0 ? [] : [path];
505
+ }
506
+ function consume(state, path) {
507
+ state.consumedPaths.add(pathKey(path));
508
+ }
509
+ function pathKey(path) {
510
+ return path.join(".");
511
+ }
512
+ function normalizeKey(value) {
513
+ return value.replace(/[-_]/g, "").toLowerCase();
514
+ }
515
+ function compact(value) {
516
+ return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
517
+ }
518
+ function optional(key, value) {
519
+ return value === void 0 ? {} : { [key]: value };
520
+ }
521
+ function isObject(value) {
522
+ return value !== null && typeof value === "object" && !Array.isArray(value);
523
+ }
524
+ function isNonNegativeNumber(value) {
525
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
526
+ }
527
+ function stringValue(value) {
528
+ return typeof value === "string" && value.length > 0 ? value : void 0;
529
+ }
530
+ function stringArrayValue(value) {
531
+ return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0) ? value : void 0;
532
+ }
533
+ function stableJson(value) {
534
+ return JSON.stringify(sortKeys(value));
535
+ }
536
+ function sortKeys(value) {
537
+ if (Array.isArray(value)) return value.map(sortKeys);
538
+ if (!isObject(value)) return value;
539
+ return Object.fromEntries(
540
+ Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortKeys(child)])
541
+ );
542
+ }
543
+
544
+ // src/sdk-config/v1/fern-config-mapper-output.ts
545
+ function mapOutput(generator, language, index) {
546
+ const raw = isObject(generator.raw) ? generator.raw : void 0;
547
+ const rawOutput = raw && isObject(raw.output) ? raw.output : void 0;
548
+ const outputPath = ["group", "generators", index, "outputMode"];
549
+ const state = { consumedPaths: /* @__PURE__ */ new Set() };
550
+ if (rawOutput?.location === "local-file-system") {
551
+ if (isObject(generator.outputMode)) consume(state, [...outputPath, "type"]);
552
+ return finishOutputMapping(
553
+ {
554
+ output: {
555
+ delivery: "files",
556
+ ...typeof rawOutput.path === "string" && rawOutput.path ? { path: rawOutput.path } : {}
557
+ }
558
+ },
559
+ generator.outputMode,
560
+ outputPath,
561
+ state,
562
+ index
563
+ );
564
+ }
565
+ if (!isObject(generator.outputMode) || typeof generator.outputMode.type !== "string") {
566
+ fail(
567
+ "FERN_OUTPUT_REQUIRED",
568
+ ["group", "generators", index, "outputMode"],
569
+ `Cannot map output for Fern generator ${generator.name}`,
570
+ "Set generator.output to a public SDK Config output, or provide the resolved Fern outputMode.",
571
+ ["targets", index, "output"]
572
+ );
573
+ }
574
+ const output = generator.outputMode;
575
+ consume(state, [...outputPath, "type"]);
576
+ switch (output.type) {
577
+ case "downloadFiles":
578
+ return finishOutputMapping({ output: { delivery: "zip" } }, output, outputPath, state, index);
579
+ case "github":
580
+ return finishOutputMapping(
581
+ githubOutput(output, output.publishInfo, language, outputPath, state, index),
582
+ output,
583
+ outputPath,
584
+ state,
585
+ index
586
+ );
587
+ case "githubV2": {
588
+ if (!isObject(output.githubV2))
589
+ fail(
590
+ "FERN_GITHUB_OUTPUT_INVALID",
591
+ ["group", "generators", index, "outputMode", "githubV2"],
592
+ "Fern githubV2 output is missing its configuration",
593
+ 'Set target.output manually with delivery "github" and the intended repository.',
594
+ ["targets", index, "output"]
595
+ );
596
+ const githubPath = [...outputPath, "githubV2"];
597
+ return finishOutputMapping(
598
+ githubOutput(
599
+ output.githubV2,
600
+ output.githubV2.publishInfo,
601
+ language,
602
+ githubPath,
603
+ state,
604
+ index
605
+ ),
606
+ output,
607
+ outputPath,
608
+ state,
609
+ index
610
+ );
611
+ }
612
+ case "publishV2": {
613
+ const publication = mapPublication(
614
+ output.publishV2,
615
+ language,
616
+ [...outputPath, "publishV2"],
617
+ state,
618
+ index
619
+ );
620
+ return finishOutputMapping(
621
+ {
622
+ output: { delivery: "zip", publish: publication.publish },
623
+ ...optional("package", publication.package)
624
+ },
625
+ output,
626
+ outputPath,
627
+ state,
628
+ index
629
+ );
630
+ }
631
+ case "publish": {
632
+ const publication = mapLegacyPublication(
633
+ output.registryOverrides,
634
+ language,
635
+ [...outputPath, "registryOverrides"],
636
+ state,
637
+ index
638
+ );
639
+ return finishOutputMapping(
640
+ {
641
+ output: { delivery: "zip", publish: publication.publish },
642
+ ...optional("package", publication.package)
643
+ },
644
+ output,
645
+ outputPath,
646
+ state,
647
+ index
648
+ );
649
+ }
650
+ default:
651
+ fail(
652
+ "FERN_OUTPUT_UNSUPPORTED",
653
+ ["group", "generators", index, "outputMode", "type"],
654
+ `Unsupported Fern output mode "${output.type}"`,
655
+ "Choose the equivalent files, zip, or github SDK Config output manually.",
656
+ ["targets", index, "output"]
657
+ );
658
+ }
659
+ }
660
+ function githubOutput(value, publishInfo, language, sourcePath, state, index) {
661
+ const owner = stringValue(value.owner);
662
+ const repo = stringValue(value.repo);
663
+ if (!owner || !repo)
664
+ fail(
665
+ "FERN_GITHUB_REPOSITORY_REQUIRED",
666
+ sourcePath,
667
+ "Fern GitHub output requires owner and repo",
668
+ 'Set target.output.github.repository manually as "owner/repository".',
669
+ ["targets", index, "output", "github", "repository"]
670
+ );
671
+ consume(state, [...sourcePath, "owner"]);
672
+ consume(state, [...sourcePath, "repo"]);
673
+ const publication = publishInfo ? mapPublication(publishInfo, language, [...sourcePath, "publishInfo"], state, index) : void 0;
674
+ const type = stringValue(value.type);
675
+ const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
676
+ if (type) consume(state, [...sourcePath, "type"]);
677
+ if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
678
+ if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
679
+ if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
680
+ return {
681
+ output: {
682
+ delivery: "github",
683
+ github: {
684
+ repository: `${owner}/${repo}`,
685
+ ...optional("host", stringValue(value.host)),
686
+ ...optional("branch", stringValue(value.branch)),
687
+ mode: value.makePr === true || type === "pullRequest" ? "pull-request" : type === "push" ? "push" : "release",
688
+ ...optional("reviewers", reviewers)
689
+ },
690
+ ...publication ? { publish: publication.publish } : {}
691
+ },
692
+ ...optional("package", publication?.package)
693
+ };
694
+ }
695
+ function mapReviewers(value, sourcePath, state) {
696
+ if (Array.isArray(value)) {
697
+ const teams2 = reviewerNames(value, "team", sourcePath, state);
698
+ const users2 = reviewerNames(value, "user", sourcePath, state);
699
+ return teams2 || users2 ? { ...optional("teams", teams2), ...optional("users", users2) } : void 0;
700
+ }
701
+ if (!isObject(value)) return void 0;
702
+ const teams = reviewerNames(value.teams, "team", [...sourcePath, "teams"], state);
703
+ const users = reviewerNames(value.users, "user", [...sourcePath, "users"], state);
704
+ return teams || users ? { ...optional("teams", teams), ...optional("users", users) } : void 0;
705
+ }
706
+ function reviewerNames(value, expectedType, sourcePath, state) {
707
+ if (!Array.isArray(value)) return void 0;
708
+ const names = value.flatMap((reviewer, index) => {
709
+ if (typeof reviewer === "string") {
710
+ consume(state, [...sourcePath, index]);
711
+ return [reviewer];
712
+ }
713
+ if (!isObject(reviewer) || reviewer.type !== expectedType || typeof reviewer.name !== "string") {
714
+ return [];
715
+ }
716
+ consume(state, [...sourcePath, index, "type"]);
717
+ consume(state, [...sourcePath, index, "name"]);
718
+ return [reviewer.name];
719
+ });
720
+ return names.length ? names : void 0;
721
+ }
722
+ function mapPublication(value, language, sourcePath, state, index) {
723
+ if (!isObject(value))
724
+ fail(
725
+ "FERN_PUBLICATION_INVALID",
726
+ sourcePath,
727
+ "Fern publication output is invalid",
728
+ "Set target.output.publish and target.package manually.",
729
+ ["targets", index, "output", "publish"]
730
+ );
731
+ const type = stringValue(value.type);
732
+ if (type) consume(state, [...sourcePath, "type"]);
733
+ const nested = type && isObject(value[type]) ? value[type] : value;
734
+ const nestedPath = nested === value ? sourcePath : [...sourcePath, type];
735
+ const registry = publicationRegistry(type, language, [...sourcePath, "type"], index);
736
+ const registryUrl = stringValue(nested.registryUrl);
737
+ if (registryUrl) consume(state, [...nestedPath, "registryUrl"]);
738
+ if (registry === "maven") {
739
+ const coordinate = stringValue(nested.coordinate);
740
+ if (coordinate) consume(state, [...nestedPath, "coordinate"]);
741
+ return {
742
+ publish: compact({ registry, url: registryUrl }),
743
+ ...coordinate ? { package: mavenPackage(coordinate, [...nestedPath, "coordinate"], index) } : {}
744
+ };
745
+ }
746
+ const packageNameField = stringValue(nested.packageName) ? "packageName" : "coordinate";
747
+ const packageName = stringValue(nested[packageNameField]);
748
+ if (packageName) consume(state, [...nestedPath, packageNameField]);
749
+ const metadata = registry === "pypi" ? mapPypiMetadata(nested.pypiMetadata, nestedPath, state) : {};
750
+ return {
751
+ publish: compact({ registry, url: registryUrl }),
752
+ ...packageName || Object.keys(metadata).length ? { package: { ...optional("packageName", packageName), ...metadata } } : {}
753
+ };
754
+ }
755
+ function mapLegacyPublication(value, language, sourcePath, state, index) {
756
+ const registry = defaultRegistry(language, sourcePath, index);
757
+ const overrides = isObject(value) ? value : {};
758
+ const override = isObject(overrides[registry]) ? overrides[registry] : {};
759
+ return mapPublication(override, language, [...sourcePath, registry], state, index);
760
+ }
761
+ function publicationRegistry(type, language, sourcePath, index) {
762
+ if (type === "postman") {
763
+ fail(
764
+ "FERN_POSTMAN_PUBLICATION_UNSUPPORTED",
765
+ sourcePath,
766
+ "Postman collection publication is not an SDK output",
767
+ "Remove this non-SDK target or convert it separately from the SDK Config document."
768
+ );
769
+ }
770
+ const normalized = type?.replace(/Override$/, "").toLowerCase();
771
+ if (normalized === "rubygems") return "rubygems";
772
+ if (normalized && ["npm", "pypi", "maven", "nuget", "crates"].includes(normalized)) {
773
+ return normalized;
774
+ }
775
+ if (normalized !== void 0) {
776
+ fail(
777
+ "FERN_PUBLICATION_UNSUPPORTED",
778
+ sourcePath,
779
+ `Unsupported Fern publication type "${type}"`,
780
+ "Set target.output.publish and target.package manually if SDK Config supports the registry.",
781
+ ["targets", index, "output", "publish"]
782
+ );
783
+ }
784
+ return defaultRegistry(language, sourcePath, index);
785
+ }
786
+ function defaultRegistry(language, sourcePath, index) {
787
+ const registries = {
788
+ typescript: "npm",
789
+ mcp: "npm",
790
+ python: "pypi",
791
+ java: "maven",
792
+ kotlin: "maven",
793
+ csharp: "nuget",
794
+ ruby: "rubygems",
795
+ rust: "crates",
796
+ go: "go",
797
+ php: "composer"
798
+ };
799
+ const registry = registries[language];
800
+ if (!registry)
801
+ fail(
802
+ "FERN_PUBLICATION_REGISTRY_REQUIRED",
803
+ sourcePath,
804
+ `No publication registry can be inferred for ${language}`,
805
+ "Set target.output.publish.registry manually.",
806
+ ["targets", index, "output", "publish", "registry"]
807
+ );
808
+ return registry;
809
+ }
810
+ function mavenPackage(coordinate, sourcePath, index) {
811
+ const parts = coordinate.split(":");
812
+ const [groupId, artifactId] = parts;
813
+ if (parts.length !== 2 || !groupId || !artifactId)
814
+ fail(
815
+ "FERN_MAVEN_COORDINATE_INVALID",
816
+ sourcePath,
817
+ `Invalid Maven coordinate ${coordinate}`,
818
+ "Set target.package.groupId and target.package.artifactId manually.",
819
+ ["targets", index, "package"]
820
+ );
821
+ return { groupId, artifactId };
822
+ }
823
+ function mapPypiMetadata(value, sourcePath, state) {
824
+ if (!isObject(value)) return {};
825
+ const metadataPath = [...sourcePath, "pypiMetadata"];
826
+ const description = stringValue(value.description);
827
+ const keywords = stringArrayValue(value.keywords);
828
+ const documentationUrl = stringValue(value.documentationLink);
829
+ const homepage = stringValue(value.homepageLink);
830
+ const authors = mapAuthors(value.authors, [...metadataPath, "authors"], state);
831
+ if (description) consume(state, [...metadataPath, "description"]);
832
+ if (keywords) consume(state, [...metadataPath, "keywords"]);
833
+ if (documentationUrl) consume(state, [...metadataPath, "documentationLink"]);
834
+ if (homepage) consume(state, [...metadataPath, "homepageLink"]);
835
+ return compact({ description, authors, keywords, documentationUrl, homepage });
836
+ }
837
+ function mapAuthors(value, sourcePath, state) {
838
+ if (!Array.isArray(value)) return void 0;
839
+ const authors = value.flatMap((author) => {
840
+ if (!isObject(author)) return [];
841
+ const name = stringValue(author.name);
842
+ const email = stringValue(author.email);
843
+ return name ? [{ name, ...optional("email", email) }] : [];
844
+ });
845
+ if (authors.length !== value.length) return void 0;
846
+ value.forEach((author, index) => {
847
+ consume(state, [...sourcePath, index, "name"]);
848
+ if (isObject(author) && stringValue(author.email)) {
849
+ consume(state, [...sourcePath, index, "email"]);
850
+ }
851
+ });
852
+ return authors;
853
+ }
854
+ function finishOutputMapping(mapping, outputMode, sourcePath, state, index) {
855
+ for (const path of collectLeafPaths(outputMode, sourcePath)) {
856
+ if (path[path.length - 1] === "_visit") consume(state, path);
857
+ }
858
+ return {
859
+ ...mapping,
860
+ unsupportedFields: collectUnsupported(outputMode, sourcePath, state).map(
861
+ (diagnostic) => outputDiagnostic(diagnostic.path, index)
862
+ )
863
+ };
864
+ }
865
+ function outputDiagnostic(path, index) {
866
+ const fields = path.filter((part) => typeof part === "string");
867
+ const field = fields[fields.length - 1];
868
+ const credential = fields.some((part) => part === "credentials" || part === "signature") || ["apiKey", "keyId", "password", "secretKey", "token", "username"].includes(field ?? "");
869
+ if (credential) {
870
+ return {
871
+ code: "FERN_OUTPUT_CREDENTIAL_UNSUPPORTED",
872
+ severity: "warning",
873
+ path,
874
+ reason: "Fern output credentials and signatures are not represented by SDK Config v1",
875
+ suggestedAction: "Configure publication credentials and signing secrets outside SDK Config."
876
+ };
877
+ }
878
+ const guidance = {
879
+ directory: {
880
+ suggestedAction: "Preserve the GitHub output subdirectory outside SDK Config; public v1 has no repository subdirectory field."
881
+ },
882
+ license: {
883
+ sdkConfigPath: ["targets", index, "package", "license"],
884
+ suggestedAction: "Set target.package.license manually using portable license metadata."
885
+ },
886
+ id: {
887
+ sdkConfigPath: ["targets", index, "package", "license"],
888
+ suggestedAction: "Set target.package.license manually using portable license metadata."
889
+ },
890
+ contents: {
891
+ sdkConfigPath: ["targets", index, "package", "license"],
892
+ suggestedAction: "Set target.package.license manually without embedding license contents."
893
+ },
894
+ downloadSnippets: {
895
+ sdkConfigPath: ["docs", "snippets", "enabled"],
896
+ suggestedAction: "Set docs.snippets.enabled manually and choose a portable output path if needed."
897
+ },
898
+ version: {
899
+ sdkConfigPath: ["targets", index, "sdkVersion"],
900
+ suggestedAction: "Set target.sdkVersion manually if this output version identifies the SDK artifact."
901
+ },
902
+ description: {
903
+ sdkConfigPath: ["targets", index, "package", "description"],
904
+ suggestedAction: "Set target.package.description manually to a valid value."
905
+ },
906
+ authors: {
907
+ sdkConfigPath: ["targets", index, "package", "authors"],
908
+ suggestedAction: "Set target.package.authors manually using valid author metadata."
909
+ },
910
+ keywords: {
911
+ sdkConfigPath: ["targets", index, "package", "keywords"],
912
+ suggestedAction: "Set target.package.keywords manually using non-empty strings."
913
+ },
914
+ documentationLink: {
915
+ sdkConfigPath: ["targets", index, "package", "documentationUrl"],
916
+ suggestedAction: "Set target.package.documentationUrl manually to a valid URL."
917
+ },
918
+ homepageLink: {
919
+ sdkConfigPath: ["targets", index, "package", "homepage"],
920
+ suggestedAction: "Set target.package.homepage manually to a valid URL."
921
+ }
922
+ };
923
+ const fieldGuidance = field ? guidance[field] : void 0;
924
+ const resolvedGuidance = fields.includes("license") ? guidance.license : fieldGuidance;
925
+ return {
926
+ code: "FERN_OUTPUT_FIELD_UNSUPPORTED",
927
+ severity: "warning",
928
+ path,
929
+ reason: "Fern output field is not represented by SDK Config v1",
930
+ ...optional("sdkConfigPath", resolvedGuidance?.sdkConfigPath),
931
+ suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
932
+ };
933
+ }
934
+ var customerGenerationAssetSchema = z.discriminatedUnion("type", [
935
+ z.strictObject({ type: z.literal("path"), location: relativePathSchema }),
936
+ z.strictObject({ type: z.literal("url"), location: nonEmptyStringSchema })
937
+ ]);
938
+ var hookDependencySchema = z.strictObject({
939
+ name: nonEmptyStringSchema,
940
+ version: nonEmptyStringSchema,
941
+ groupId: nonEmptyStringSchema.optional()
942
+ });
943
+ var hooksConfigSchema = z.strictObject({
944
+ enabled: z.boolean(),
945
+ source: customerGenerationAssetSchema.optional(),
946
+ dependencies: z.array(hookDependencySchema).optional()
947
+ });
948
+ var customCodeConfigSchema = z.strictObject({
949
+ enabled: z.boolean(),
950
+ source: customerGenerationAssetSchema.optional(),
951
+ conflictStrategy: z.enum(["mark", "ours", "theirs"]).optional(),
952
+ trackChanges: z.boolean().optional(),
953
+ protectedFiles: z.array(nonEmptyStringSchema).optional()
954
+ });
955
+ var workflowConfigSchema = z.strictObject({
956
+ path: relativePathSchema,
957
+ outputName: nonEmptyStringSchema.optional()
958
+ });
959
+ var analyticsHeaderSchema = z.union([
960
+ z.strictObject({ name: nonEmptyStringSchema, value: z.string() }),
961
+ z.strictObject({
962
+ name: nonEmptyStringSchema,
963
+ valueRef: nonEmptyStringSchema
964
+ })
965
+ ]);
966
+ var analyticsConfigSchema = z.strictObject({
967
+ enabled: z.boolean(),
968
+ endpoint: nonEmptyStringSchema.optional(),
969
+ exporter: z.enum(["otlp-http", "console"]).optional(),
970
+ headers: z.array(analyticsHeaderSchema).optional(),
971
+ batchSize: z.number().int().positive().optional(),
972
+ scheduledDelayMs: z.number().nonnegative().optional(),
973
+ exportTimeoutMs: z.number().nonnegative().optional()
974
+ }).superRefine(({ enabled, endpoint }, context) => {
975
+ if (enabled && endpoint === void 0) {
976
+ context.addIssue({
977
+ code: "custom",
978
+ message: "endpoint is required when analytics is enabled",
979
+ path: ["endpoint"]
980
+ });
981
+ }
982
+ });
553
983
  var wireTestsSchema = z.strictObject({
554
984
  enabled: z.boolean(),
555
985
  exclusions: z.array(nonEmptyStringSchema).optional(),
556
986
  fallbackToGeneratedErrorExamples: z.boolean().optional(),
557
987
  fixtureSource: z.enum(["synthetic", "recorded", "auto"]).optional()
558
988
  });
559
- var unitTestsSchema = z.strictObject({
989
+ var unitTestsSchema = z.strictObject({
990
+ enabled: z.boolean(),
991
+ mode: z.enum(["core-runtime", "schema-driven", "both"]).optional(),
992
+ exclusions: z.array(nonEmptyStringSchema).optional()
993
+ });
994
+ var streamsSchema = z.strictObject({
995
+ enabled: z.boolean(),
996
+ responseType: z.enum(["wrapper", "native", "web"]).optional(),
997
+ fileResponseType: z.enum(["stream", "binary-response"]).optional(),
998
+ defaultChunkSizeBytes: z.number().int().positive().optional()
999
+ });
1000
+ var namingConfigSchema = z.strictObject({
1001
+ clientName: nonEmptyStringSchema.optional(),
1002
+ exportedClientName: nonEmptyStringSchema.optional(),
1003
+ environmentTypeName: nonEmptyStringSchema.optional(),
1004
+ apiErrorName: nonEmptyStringSchema.optional(),
1005
+ baseErrorName: nonEmptyStringSchema.optional(),
1006
+ pagerName: nonEmptyStringSchema.optional()
1007
+ });
1008
+ var layoutConfigSchema = z.strictObject({
1009
+ outputDirectory: z.enum(["project-root", "source-root"]).optional(),
1010
+ packagePath: nonEmptyStringSchema.optional()
1011
+ });
1012
+ var serializationConfigSchema = z.strictObject({
1013
+ enumRepresentation: z.enum(["enum", "union", "literal", "forward-compatible-enum", "language-default"]).optional(),
1014
+ additionalProperties: z.enum(["allow", "forbid", "ignore", "language-default"]).optional(),
1015
+ inlineTypes: z.boolean().optional(),
1016
+ omitUndefined: z.boolean().optional()
1017
+ });
1018
+ var sdkConfigV1GenerationConfigSchema = z.strictObject({
1019
+ includeWatermark: z.boolean().default(false),
1020
+ ai: z.boolean().default(false),
1021
+ includeOptionalSnippetParameters: z.boolean().optional(),
1022
+ buildAllModels: z.boolean().default(false),
1023
+ inferServiceNames: z.boolean().default(false),
1024
+ includeDeprecatedOperations: z.boolean().default(true),
1025
+ multipleResponses: z.boolean().default(false),
1026
+ devContainer: z.boolean().default(false),
1027
+ allowMockClient: z.boolean().default(false),
1028
+ ignoreFiles: z.array(nonEmptyStringSchema).optional(),
1029
+ reservedKeywords: z.array(nonEmptyStringSchema).optional(),
1030
+ hooks: hooksConfigSchema.optional(),
1031
+ customCode: customCodeConfigSchema.optional(),
1032
+ workflows: z.array(workflowConfigSchema).optional(),
1033
+ customQueryPaths: z.array(relativePathSchema).optional(),
1034
+ analytics: analyticsConfigSchema.optional(),
1035
+ wireTests: wireTestsSchema.optional(),
1036
+ unitTests: unitTestsSchema.optional(),
1037
+ webSockets: z.boolean().optional(),
1038
+ streams: streamsSchema.optional(),
1039
+ naming: namingConfigSchema.optional(),
1040
+ layout: layoutConfigSchema.optional(),
1041
+ serialization: serializationConfigSchema.optional()
1042
+ });
1043
+ var sdkConfigV1PublishRegistrySchema = z.enum([
1044
+ "npm",
1045
+ "pypi",
1046
+ "maven",
1047
+ "nuget",
1048
+ "rubygems",
1049
+ "crates",
1050
+ "go",
1051
+ "composer"
1052
+ ]);
1053
+ var commonPublishShape = {
1054
+ url: nonEmptyStringSchema.optional(),
1055
+ releaseBranch: nonEmptyStringSchema.optional(),
1056
+ tolerateRepublish: z.boolean().optional()
1057
+ };
1058
+ var sdkConfigV1PublishConfigSchema = z.discriminatedUnion("registry", [
1059
+ z.strictObject({ registry: z.literal("npm"), ...commonPublishShape }),
1060
+ z.strictObject({ registry: z.literal("pypi"), ...commonPublishShape }),
1061
+ z.strictObject({ registry: z.literal("maven"), ...commonPublishShape }),
1062
+ z.strictObject({ registry: z.literal("nuget"), ...commonPublishShape }),
1063
+ z.strictObject({ registry: z.literal("rubygems"), ...commonPublishShape }),
1064
+ z.strictObject({ registry: z.literal("crates"), ...commonPublishShape }),
1065
+ z.strictObject({ registry: z.literal("go"), ...commonPublishShape }),
1066
+ z.strictObject({ registry: z.literal("composer"), ...commonPublishShape })
1067
+ ]);
1068
+ var reviewersSchema = z.strictObject({
1069
+ teams: z.array(nonEmptyStringSchema).optional(),
1070
+ users: z.array(nonEmptyStringSchema).optional()
1071
+ });
1072
+ var githubOutputSchema = z.strictObject({
1073
+ repository: nonEmptyStringSchema,
1074
+ host: nonEmptyStringSchema.optional(),
1075
+ branch: nonEmptyStringSchema.optional(),
1076
+ mode: z.enum(["release", "pull-request", "push"]).optional(),
1077
+ reviewers: reviewersSchema.optional(),
1078
+ privateRepository: z.boolean().optional()
1079
+ });
1080
+ var filesOutputSchema = z.strictObject({
1081
+ delivery: z.literal("files"),
1082
+ path: nonEmptyStringSchema.optional(),
1083
+ publish: sdkConfigV1PublishConfigSchema.optional()
1084
+ });
1085
+ var zipOutputSchema = z.strictObject({
1086
+ delivery: z.literal("zip"),
1087
+ fileName: nonEmptyStringSchema.optional(),
1088
+ publish: sdkConfigV1PublishConfigSchema.optional()
1089
+ });
1090
+ var githubDeliverySchema = z.strictObject({
1091
+ delivery: z.literal("github"),
1092
+ github: githubOutputSchema,
1093
+ publish: sdkConfigV1PublishConfigSchema.optional()
1094
+ });
1095
+ var sdkConfigV1OutputConfigSchema = z.discriminatedUnion(
1096
+ "delivery",
1097
+ [filesOutputSchema, zipOutputSchema, githubDeliverySchema],
1098
+ { error: 'output.delivery must be one of "files", "zip", or "github"' }
1099
+ );
1100
+
1101
+ // src/sdk-config/v1/package.ts
1102
+ var sdkConfigV1DependencySchema = dependencySchema;
1103
+ var sdkConfigV1PackageConfigSchema = packageConfigSchema;
1104
+ var cliGenerationConfigSchema = z.strictObject({
1105
+ paginationParameters: z.array(nonEmptyStringSchema).optional(),
1106
+ skills: z.boolean().optional()
1107
+ });
1108
+ var csharpGenerationConfigSchema = z.strictObject({
1109
+ useOptionalWrapper: z.boolean().optional(),
1110
+ simplifyObjectDictionaries: z.boolean().optional(),
1111
+ explicitNamespaces: z.boolean().optional(),
1112
+ rootNamespaceForCoreClasses: z.boolean().optional(),
1113
+ includeExceptionHandler: z.boolean().optional(),
1114
+ experimentalExplicitNullableOptional: z.boolean().optional()
1115
+ });
1116
+ var goGenerationConfigSchema = z.strictObject({
1117
+ legacyComplexModels: z.boolean().optional(),
1118
+ /** Uppercase common initialisms in generated names (`UserID` rather than `UserId`). */
1119
+ smartCasing: z.boolean().optional(),
1120
+ /** Overrides the fern root-client constructor independently from the client type name. */
1121
+ clientConstructorName: nonEmptyStringSchema.optional(),
1122
+ unionVersion: z.enum(["v0", "v1"]).optional(),
1123
+ includeLegacyClientOptions: z.boolean().optional()
1124
+ });
1125
+ var jvmGenerationConfigSchema = z.strictObject({
1126
+ packageLayout: z.enum(["flat", "nested"]).optional(),
1127
+ useLocalDateForDates: z.boolean().optional(),
1128
+ collapseOptionalNullable: z.boolean().optional(),
1129
+ gradleDistributionUrl: z.string().min(1).optional(),
1130
+ gradlePluginManagement: z.string().optional(),
1131
+ gradleCentralDependencyManagement: z.boolean().optional(),
1132
+ /** Selects co-located async methods or a separate async client surface. */
1133
+ asyncStyle: z.enum(["dedicated-client", "twin-methods"]).optional()
1134
+ });
1135
+
1136
+ // src/sdk-config-domain/v1/language/java.ts
1137
+ var javaGenerationConfigSchema = jvmGenerationConfigSchema.extend({
1138
+ includeKotlinSnippets: z.boolean().optional()
1139
+ });
1140
+
1141
+ // src/sdk-config-domain/v1/language/kotlin.ts
1142
+ var kotlinGenerationConfigSchema = jvmGenerationConfigSchema;
1143
+ var compilerOptionsSchema = z.strictObject({
1144
+ target: nonEmptyStringSchema.optional(),
1145
+ module: nonEmptyStringSchema.optional(),
1146
+ lib: z.array(nonEmptyStringSchema).optional()
1147
+ });
1148
+ var packageScriptSchema = z.strictObject({
1149
+ name: nonEmptyStringSchema,
1150
+ command: nonEmptyStringSchema
1151
+ });
1152
+ var httpClientSchema = z.strictObject({
1153
+ name: z.enum(["axios", "fetch"])
1154
+ });
1155
+ var typescriptGenerationConfigSchema = z.strictObject({
1156
+ typescriptVersion: nonEmptyStringSchema.optional(),
1157
+ zodVersion: nonEmptyStringSchema.optional(),
1158
+ compilerOptions: compilerOptionsSchema.optional(),
1159
+ httpClient: httpClientSchema.optional(),
1160
+ packageManager: z.enum(["pnpm", "yarn"]).optional(),
1161
+ testFramework: z.enum(["jest", "vitest"]).optional(),
1162
+ namingStrategy: z.enum(["base", "originalPropertyNames"]).optional(),
1163
+ bundle: z.boolean().optional(),
1164
+ exportClassDefault: z.boolean().optional(),
1165
+ allowCustomFetcher: z.boolean().optional(),
1166
+ useBrandedStringAliases: z.boolean().optional(),
1167
+ useLegacyExports: z.boolean().optional(),
1168
+ useBigInt: z.boolean().optional(),
1169
+ serdeLayer: z.boolean().optional(),
1170
+ scripts: z.array(packageScriptSchema).optional()
1171
+ });
1172
+
1173
+ // src/sdk-config-domain/v1/language/mcp.ts
1174
+ var mcpAvailabilityStatuses = [
1175
+ "IN_DEVELOPMENT",
1176
+ "PRE_RELEASE",
1177
+ "GENERAL_AVAILABILITY",
1178
+ "DEPRECATED",
1179
+ "ALPHA",
1180
+ "BETA",
1181
+ "PREVIEW",
1182
+ "LEGACY"
1183
+ ];
1184
+ var mcpToolFilterSchema = z.strictObject({
1185
+ include: z.array(nonEmptyStringSchema).optional(),
1186
+ exclude: z.array(nonEmptyStringSchema).optional()
1187
+ });
1188
+ var mcpToolsetNameSchema = nonEmptyStringSchema.refine(
1189
+ (name) => name !== "default" && /^[a-z0-9-]+$/.test(name),
1190
+ 'toolset names must match [a-z0-9-]+ and cannot be "default"'
1191
+ );
1192
+ var mcpGenerationConfigSchema = typescriptGenerationConfigSchema.extend({
1193
+ serverName: nonEmptyStringSchema.optional(),
1194
+ serverDescription: nonEmptyStringSchema.optional(),
1195
+ excludeAvailability: z.array(z.enum(mcpAvailabilityStatuses)).optional(),
1196
+ tools: mcpToolFilterSchema.optional(),
1197
+ toolsets: z.record(mcpToolsetNameSchema, mcpToolFilterSchema).optional()
1198
+ });
1199
+ var phpGenerationConfigSchema = z.strictObject({
1200
+ propertyAccess: z.enum(["public", "private"]).optional(),
1201
+ generateClientInterfaces: z.boolean().optional()
1202
+ });
1203
+ var pythonClientSchema = z.strictObject({
1204
+ fileName: nonEmptyStringSchema.optional(),
1205
+ exportedFileName: nonEmptyStringSchema.optional()
1206
+ });
1207
+ var pydanticConfigSchema = z.strictObject({
1208
+ versionCompatibility: z.enum(["v1", "v2", "both", "v1-on-v2"]).optional(),
1209
+ frozen: z.boolean().optional(),
1210
+ requireOptionalFields: z.boolean().optional(),
1211
+ unionNaming: z.enum(["v0", "v1"]).optional(),
1212
+ useFieldAliases: z.boolean().optional()
1213
+ });
1214
+ var pythonGenerationConfigSchema = z.strictObject({
1215
+ pythonVersion: nonEmptyStringSchema.optional(),
1216
+ pydanticVersion: nonEmptyStringSchema.optional(),
1217
+ pydantic: pydanticConfigSchema.optional(),
1218
+ client: pythonClientSchema.optional(),
1219
+ alwaysInitializeOptionals: z.boolean().optional(),
1220
+ useTypedDictRequests: z.boolean().optional()
1221
+ });
1222
+ var rubyGenerationConfigSchema = z.strictObject({
1223
+ requirePaths: z.array(nonEmptyStringSchema).optional()
1224
+ });
1225
+ var rustGenerationConfigSchema = z.strictObject({
1226
+ /**
1227
+ * Rust type for datetime primitives. `offset` maps to `DateTime<FixedOffset>` and preserves the
1228
+ * timezone the payload carried; `utc` maps to `DateTime<Utc>` and normalizes to UTC.
1229
+ */
1230
+ dateTimeType: z.enum(["offset", "utc"]).optional(),
1231
+ /** Uppercase common initialisms in generated names (`UserID` rather than `UserId`). */
1232
+ capitalizeInitialisms: z.boolean().optional(),
1233
+ /** Cargo features, mapping a feature name to the dependencies or features it enables. */
1234
+ features: z.record(z.string(), z.array(nonEmptyStringSchema)).optional(),
1235
+ /** Overrides which features make up Cargo's `default` feature set. */
1236
+ defaultFeatures: z.array(nonEmptyStringSchema).optional()
1237
+ });
1238
+ var swiftGenerationConfigSchema = z.strictObject({
1239
+ moduleName: nonEmptyStringSchema.optional(),
1240
+ nullableAsOptional: z.boolean().optional()
1241
+ });
1242
+ var planModifierSourceSchema = z.discriminatedUnion("enabled", [
1243
+ z.strictObject({ enabled: z.literal(true), sourceDir: nonEmptyStringSchema }),
1244
+ z.strictObject({ enabled: z.literal(false) })
1245
+ ]);
1246
+ var planModifiersSchema = z.strictObject({
1247
+ resources: planModifierSourceSchema,
1248
+ attributes: planModifierSourceSchema
1249
+ });
1250
+ var providerSchemaSchema = z.strictObject({
1251
+ addressKey: nonEmptyStringSchema,
1252
+ authTokenKey: nonEmptyStringSchema
1253
+ });
1254
+ var terraformGenerationConfigSchema = z.strictObject({
1255
+ providerName: nonEmptyStringSchema.optional(),
1256
+ providerVersion: nonEmptyStringSchema.optional(),
1257
+ providerModulePath: goModulePathSchema.optional(),
1258
+ mockAcceptance: z.boolean().optional(),
1259
+ hideComputedDiff: z.boolean().optional(),
1260
+ providerSchema: providerSchemaSchema.optional(),
1261
+ planModifiers: planModifiersSchema.optional()
1262
+ });
1263
+
1264
+ // src/sdk-config/v1/target.ts
1265
+ var targetOverrideShape = {
1266
+ generatorVersion: exactSemverSchema.optional(),
1267
+ sdkName: nonEmptyStringSchema.optional(),
1268
+ sdkVersion: nonEmptyStringSchema.optional(),
1269
+ package: sdkConfigV1PackageConfigSchema.optional(),
1270
+ output: sdkConfigV1OutputConfigSchema.optional()
1271
+ };
1272
+ var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
1273
+ z.strictObject({
1274
+ language: z.literal("typescript"),
1275
+ generation: typescriptGenerationConfigSchema.optional(),
1276
+ ...targetOverrideShape
1277
+ }),
1278
+ z.strictObject({
1279
+ language: z.literal("python"),
1280
+ generation: pythonGenerationConfigSchema.optional(),
1281
+ ...targetOverrideShape
1282
+ }),
1283
+ z.strictObject({
1284
+ language: z.literal("java"),
1285
+ generation: javaGenerationConfigSchema.optional(),
1286
+ ...targetOverrideShape
1287
+ }),
1288
+ z.strictObject({
1289
+ language: z.literal("kotlin"),
1290
+ generation: kotlinGenerationConfigSchema.optional(),
1291
+ ...targetOverrideShape
1292
+ }),
1293
+ z.strictObject({
1294
+ language: z.literal("go"),
1295
+ generation: goGenerationConfigSchema.optional(),
1296
+ ...targetOverrideShape
1297
+ }),
1298
+ z.strictObject({
1299
+ language: z.literal("csharp"),
1300
+ generation: csharpGenerationConfigSchema.optional(),
1301
+ ...targetOverrideShape
1302
+ }),
1303
+ z.strictObject({
1304
+ language: z.literal("php"),
1305
+ generation: phpGenerationConfigSchema.optional(),
1306
+ ...targetOverrideShape
1307
+ }),
1308
+ z.strictObject({
1309
+ language: z.literal("ruby"),
1310
+ generation: rubyGenerationConfigSchema.optional(),
1311
+ ...targetOverrideShape
1312
+ }),
1313
+ z.strictObject({
1314
+ language: z.literal("rust"),
1315
+ generation: rustGenerationConfigSchema.optional(),
1316
+ ...targetOverrideShape
1317
+ }),
1318
+ z.strictObject({
1319
+ language: z.literal("swift"),
1320
+ generation: swiftGenerationConfigSchema.optional(),
1321
+ ...targetOverrideShape
1322
+ }),
1323
+ z.strictObject({
1324
+ language: z.literal("cli"),
1325
+ generation: cliGenerationConfigSchema.optional(),
1326
+ ...targetOverrideShape
1327
+ }),
1328
+ z.strictObject({
1329
+ language: z.literal("mcp"),
1330
+ generation: mcpGenerationConfigSchema.optional(),
1331
+ ...targetOverrideShape
1332
+ }),
1333
+ z.strictObject({
1334
+ language: z.literal("terraform"),
1335
+ generation: terraformGenerationConfigSchema.optional(),
1336
+ ...targetOverrideShape
1337
+ })
1338
+ ]);
1339
+
1340
+ // src/sdk-config/v1/sdk-config-v1.ts
1341
+ var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
1342
+ var publishRegistryLanguages = {
1343
+ npm: ["typescript", "mcp"],
1344
+ pypi: ["python"],
1345
+ maven: ["java", "kotlin"],
1346
+ nuget: ["csharp"],
1347
+ rubygems: ["ruby"],
1348
+ crates: ["rust"],
1349
+ go: ["go"],
1350
+ composer: ["php"]
1351
+ };
1352
+ var packageNameRegistries = /* @__PURE__ */ new Set([
1353
+ "npm",
1354
+ "pypi",
1355
+ "nuget",
1356
+ "rubygems",
1357
+ "crates",
1358
+ "composer"
1359
+ ]);
1360
+ function validatePublishingIdentity(packageConfig, registry, targetIndex, context) {
1361
+ const pathPrefix = ["targets", targetIndex, "package"];
1362
+ if (packageNameRegistries.has(registry) && !packageConfig.packageName) {
1363
+ context.addIssue({
1364
+ code: "custom",
1365
+ message: `packageName is required when publishing to "${registry}"`,
1366
+ path: [...pathPrefix, "packageName"]
1367
+ });
1368
+ }
1369
+ if (registry === "composer" && packageConfig.packageName) {
1370
+ const result = composerPackageNameSchema.safeParse(packageConfig.packageName);
1371
+ if (!result.success) {
1372
+ context.addIssue({
1373
+ code: "custom",
1374
+ message: result.error.issues[0]?.message ?? "Invalid Composer package name",
1375
+ path: [...pathPrefix, "packageName"]
1376
+ });
1377
+ }
1378
+ }
1379
+ if (registry === "go" && !packageConfig.modulePath) {
1380
+ context.addIssue({
1381
+ code: "custom",
1382
+ message: "modulePath is required when publishing a Go module",
1383
+ path: [...pathPrefix, "modulePath"]
1384
+ });
1385
+ }
1386
+ if (registry === "maven") {
1387
+ ["groupId", "artifactId"].forEach((field) => {
1388
+ if (!packageConfig[field]) {
1389
+ context.addIssue({
1390
+ code: "custom",
1391
+ message: `${field} is required when publishing to Maven`,
1392
+ path: [...pathPrefix, field]
1393
+ });
1394
+ }
1395
+ });
1396
+ }
1397
+ }
1398
+ function validateTargetPublishing(target, targetIndex, globalPackage, globalOutput, context) {
1399
+ const output = target.output ?? globalOutput;
1400
+ if (!output.publish) {
1401
+ return;
1402
+ }
1403
+ const registry = output.publish.registry;
1404
+ if (!publishRegistryLanguages[registry].some((language) => language === target.language)) {
1405
+ context.addIssue({
1406
+ code: "custom",
1407
+ message: `registry "${registry}" is not supported for target language "${target.language}"`,
1408
+ path: ["targets", targetIndex, target.output ? "output" : "language"]
1409
+ });
1410
+ return;
1411
+ }
1412
+ validatePublishingIdentity(
1413
+ { ...globalPackage, ...target.package },
1414
+ registry,
1415
+ targetIndex,
1416
+ context
1417
+ );
1418
+ }
1419
+ var sdkConfigV1Schema = z.strictObject({
1420
+ schemaVersion: z.literal(SDK_CONFIG_V1_SCHEMA_VERSION),
1421
+ sdkName: nonEmptyStringSchema,
1422
+ sdkVersion: nonEmptyStringSchema.default("1.0.0"),
1423
+ apiVersion: nonEmptyStringSchema.optional(),
1424
+ api: sdkConfigV1ApiConfigSchema,
1425
+ client: sdkConfigV1ClientConfigSchema,
1426
+ package: sdkConfigV1PackageConfigSchema,
1427
+ output: sdkConfigV1OutputConfigSchema,
1428
+ docs: sdkConfigV1DocsConfigSchema,
1429
+ generation: sdkConfigV1GenerationConfigSchema,
1430
+ targets: z.array(sdkConfigV1TargetSchema).min(1)
1431
+ }).superRefine(({ output, package: globalPackage, targets }, context) => {
1432
+ const configuredLanguages = /* @__PURE__ */ new Set();
1433
+ targets.forEach((target, targetIndex) => {
1434
+ if (configuredLanguages.has(target.language)) {
1435
+ context.addIssue({
1436
+ code: "custom",
1437
+ message: `target language "${target.language}" must be unique`,
1438
+ path: ["targets", targetIndex, "language"]
1439
+ });
1440
+ }
1441
+ configuredLanguages.add(target.language);
1442
+ validateTargetPublishing(target, targetIndex, globalPackage, output, context);
1443
+ });
1444
+ });
1445
+ function parseSdkConfigV1(value) {
1446
+ return sdkConfigV1Schema.parse(value);
1447
+ }
1448
+
1449
+ // src/sdk-config/v1/fern-config-mapper.ts
1450
+ var generatorLanguages = {
1451
+ "fernapi/fern-typescript": "typescript",
1452
+ "fernapi/fern-typescript-sdk": "typescript",
1453
+ "fernapi/fern-typescript-node-sdk": "typescript",
1454
+ "fernapi/fern-typescript-browser-sdk": "typescript",
1455
+ "fernapi/fern-python-sdk": "python",
1456
+ "fernapi/fern-java-sdk": "java",
1457
+ "fernapi/fern-kotlin-sdk": "kotlin",
1458
+ "fernapi/fern-go-sdk": "go",
1459
+ "fernapi/fern-csharp-sdk": "csharp",
1460
+ "fernapi/fern-php-sdk": "php",
1461
+ "fernapi/fern-ruby-sdk": "ruby",
1462
+ "fernapi/fern-ruby-sdk-v2": "ruby",
1463
+ "fernapi/fern-rust-sdk": "rust",
1464
+ "fernapi/fern-swift-sdk": "swift",
1465
+ "fernapi/fern-cli": "cli",
1466
+ "fernapi/fern-cli-generator": "cli",
1467
+ "fernapi/fern-mcp-server": "mcp"
1468
+ };
1469
+ function mapFernConfigToSdkConfigV1(input) {
1470
+ if (input.group.generators.length === 0) {
1471
+ fail(
1472
+ "FERN_GENERATORS_REQUIRED",
1473
+ ["group", "generators"],
1474
+ "Fern generator group must contain at least one generator",
1475
+ "Select a Fern generator group containing at least one SDK generator."
1476
+ );
1477
+ }
1478
+ const mapped = input.group.generators.map((generator, index) => {
1479
+ const language = resolveLanguage(generator, index);
1480
+ const invocation = mapInvocation(generator, language, index);
1481
+ const outputMapping = generator.output ? { output: generator.output, unsupportedFields: [] } : mapOutput(generator, language, index);
1482
+ return {
1483
+ generator,
1484
+ language,
1485
+ invocation,
1486
+ ...outputMapping
1487
+ };
1488
+ });
1489
+ requireUniqueLanguages(mapped.map(({ language }) => language));
1490
+ const client = requireSharedBlock(
1491
+ mapped.map(({ invocation }) => invocation.client),
1492
+ "client",
1493
+ (value) => sdkConfigV1ClientConfigSchema.parse(value)
1494
+ );
1495
+ const docs = requireSharedBlock(
1496
+ mapped.map(({ invocation }) => invocation.docs),
1497
+ "docs",
1498
+ (value) => sdkConfigV1DocsConfigSchema.parse(value)
1499
+ );
1500
+ const generation = requireSharedBlock(
1501
+ mapped.map(({ invocation }) => invocation.generation),
1502
+ "generation",
1503
+ (value) => sdkConfigV1GenerationConfigSchema.parse(value)
1504
+ );
1505
+ const api = { ...input.api ?? {} };
1506
+ delete api.audiences;
1507
+ if (input.group.audiences.type === "select") {
1508
+ api.audiences = [...input.group.audiences.audiences];
1509
+ }
1510
+ const targets = mapped.map(
1511
+ ({ generator, invocation, language, output, package: outputPackage }, index) => {
1512
+ const target = {
1513
+ language,
1514
+ output,
1515
+ ...optional("sdkName", generator.sdkName),
1516
+ ...optional("sdkVersion", generator.sdkVersion)
1517
+ };
1518
+ if (Object.keys(invocation.package).length > 0 || outputPackage || generator.package) {
1519
+ target.package = { ...invocation.package, ...outputPackage, ...generator.package };
1520
+ }
1521
+ if (Object.keys(invocation.targetGeneration).length > 0) {
1522
+ target.generation = invocation.targetGeneration;
1523
+ }
1524
+ if (generator.version) {
1525
+ if (exactSemverSchema.safeParse(generator.version).success) {
1526
+ target.generatorVersion = generator.version;
1527
+ } else {
1528
+ invocation.unsupportedFields.push({
1529
+ code: "FERN_GENERATOR_VERSION_NOT_EXACT",
1530
+ severity: "warning",
1531
+ path: ["group", "generators", index, "version"],
1532
+ reason: "SDK Config requires an exact generator semantic version",
1533
+ sdkConfigPath: ["targets", index, "generatorVersion"],
1534
+ suggestedAction: "Resolve the Fern generator tag to an exact semantic version and set target.generatorVersion manually, or leave it omitted."
1535
+ });
1536
+ }
1537
+ }
1538
+ return target;
1539
+ }
1540
+ );
1541
+ const parsed = sdkConfigV1Schema.safeParse({
1542
+ schemaVersion: "sdk-config/v1",
1543
+ sdkName: input.apiName,
1544
+ ...optional("sdkVersion", input.sdkVersion),
1545
+ ...optional("apiVersion", input.apiVersion),
1546
+ api,
1547
+ client,
1548
+ package: {},
1549
+ output: mapped[0].output,
1550
+ docs,
1551
+ generation,
1552
+ targets
1553
+ });
1554
+ if (!parsed.success) {
1555
+ throw new FernConfigMappingError(
1556
+ parsed.error.issues.map((issue) => {
1557
+ const path = issue.path.map(
1558
+ (part) => typeof part === "symbol" ? part.description ?? part.toString() : part
1559
+ );
1560
+ return {
1561
+ code: "SDK_CONFIG_VALIDATION_FAILED",
1562
+ severity: "error",
1563
+ path: ["mappedSdkConfig", ...path],
1564
+ reason: issue.message,
1565
+ sdkConfigPath: path,
1566
+ suggestedAction: `Set ${path.join(".")} manually to a valid SDK Config v1 value.`
1567
+ };
1568
+ })
1569
+ );
1570
+ }
1571
+ return {
1572
+ sdkConfig: parsed.data,
1573
+ unsupportedFields: mapped.flatMap(({ invocation, unsupportedFields }) => [
1574
+ ...invocation.unsupportedFields,
1575
+ ...unsupportedFields
1576
+ ])
1577
+ };
1578
+ }
1579
+ function resolveLanguage(generator, index) {
1580
+ const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
1581
+ if (!language || !isFernLanguage(language)) {
1582
+ fail(
1583
+ "FERN_SDK_LANGUAGE_REQUIRED",
1584
+ ["group", "generators", index, "name"],
1585
+ `Cannot determine an SDK language for Fern generator ${generator.name}`,
1586
+ "Set sdkLanguage explicitly if this custom generator produces one of the SDK Config v1 target languages.",
1587
+ ["targets", index, "language"]
1588
+ );
1589
+ }
1590
+ return language;
1591
+ }
1592
+ function isFernLanguage(value) {
1593
+ return [
1594
+ "typescript",
1595
+ "python",
1596
+ "java",
1597
+ "kotlin",
1598
+ "go",
1599
+ "csharp",
1600
+ "php",
1601
+ "ruby",
1602
+ "rust",
1603
+ "swift",
1604
+ "cli",
1605
+ "mcp",
1606
+ "terraform"
1607
+ ].includes(value);
1608
+ }
1609
+ function requireUniqueLanguages(languages) {
1610
+ const seen = /* @__PURE__ */ new Set();
1611
+ for (const language of languages) {
1612
+ if (seen.has(language)) {
1613
+ fail(
1614
+ "FERN_DUPLICATE_TARGET_LANGUAGE",
1615
+ ["group", "generators"],
1616
+ `SDK Config v1 cannot represent multiple Fern generators for language "${language}"`,
1617
+ "Create a separate SDK Config document for each generator that targets the same language.",
1618
+ ["targets"]
1619
+ );
1620
+ }
1621
+ seen.add(language);
1622
+ }
1623
+ }
1624
+ function requireSharedBlock(values, name, normalize) {
1625
+ const first = normalize(values[0]);
1626
+ const serialized = stableJson(first);
1627
+ if (values.some((value) => stableJson(normalize(value)) !== serialized)) {
1628
+ fail(
1629
+ "FERN_TARGET_SPECIFIC_SHARED_CONFIG",
1630
+ ["group", "generators"],
1631
+ `SDK Config v1 cannot represent target-specific Fern ${name} configuration`,
1632
+ `Choose one shared ${name} configuration manually or create separate SDK Config documents for the differing targets.`,
1633
+ [name]
1634
+ );
1635
+ }
1636
+ return first;
1637
+ }
1638
+ function mapInvocation(generator, language, index) {
1639
+ const prefix = ["group", "generators", index];
1640
+ const state = { consumedPaths: /* @__PURE__ */ new Set() };
1641
+ const config = isObject(generator.config) ? generator.config : {};
1642
+ const client = {};
1643
+ const generation = {};
1644
+ const packageConfig = {};
1645
+ mapCommonConfig(config, state, client, generation, packageConfig, [...prefix, "config"]);
1646
+ const targetGeneration = mapLanguageConfig(language, config, state, packageConfig, [
1647
+ ...prefix,
1648
+ "config"
1649
+ ]);
1650
+ mapPublishMetadata(generator.publishMetadata, packageConfig);
1651
+ if (language === "go" && generator.smartCasing !== void 0) {
1652
+ targetGeneration.smartCasing = generator.smartCasing;
1653
+ }
1654
+ if (generator.keywords?.length) {
1655
+ generation.reservedKeywords = [...generator.keywords];
1656
+ }
1657
+ const settings = isObject(generator.settings) ? generator.settings : void 0;
1658
+ if (settings) {
1659
+ const inlinePathParameters = takeBoolean(settings, ["inlinePathParameters"], state, [
1660
+ ...prefix,
1661
+ "settings"
1662
+ ]);
1663
+ if (inlinePathParameters !== void 0 && client.pathParameterStyle === void 0) {
1664
+ client.pathParameterStyle = inlinePathParameters ? "inline" : "wrapped";
1665
+ }
1666
+ }
1667
+ const docs = mapReadme(generator.readme, state, [...prefix, "readme"]);
1668
+ const unsupportedFields = [
1669
+ ...collectUnsupported(config, [...prefix, "config"], state),
1670
+ ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
1671
+ ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
1672
+ ...unsupportedResolvedFields(generator, index, language)
1673
+ ];
1674
+ return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
1675
+ }
1676
+ function unsupportedResolvedFields(generator, index, language) {
1677
+ const values = [
1678
+ ["automation", isDefaultAutomation(generator.automation) ? void 0 : generator.automation],
1679
+ ["containerImage", generator.containerImage],
1680
+ ["irVersionOverride", generator.irVersionOverride],
1681
+ ["idempotencyKeyGenerationConfig", generator.idempotencyKeyGenerationConfig],
1682
+ ["absolutePathToLocalSnippets", generator.absolutePathToLocalSnippets],
1683
+ [
1684
+ "smartCasingDigitWordBoundary",
1685
+ generator.smartCasingDigitWordBoundary === false ? void 0 : generator.smartCasingDigitWordBoundary
1686
+ ],
1687
+ [
1688
+ "disableExamples",
1689
+ generator.disableExamples === false ? void 0 : generator.disableExamples
1690
+ ],
1691
+ ["apiOverride", generator.apiOverride],
1692
+ ...language === "go" || generator.smartCasing === true ? [] : [["smartCasing", generator.smartCasing]]
1693
+ ];
1694
+ return values.flatMap(([field, value]) => {
1695
+ if (value === void 0) return [];
1696
+ const guidance = resolvedFieldGuidance(field);
1697
+ return [
1698
+ {
1699
+ code: "FERN_RESOLVED_FIELD_UNSUPPORTED",
1700
+ severity: "warning",
1701
+ path: ["group", "generators", index, field],
1702
+ reason: "Resolved Fern field is not represented by SDK Config v1",
1703
+ ...optional("sdkConfigPath", guidance.sdkConfigPath),
1704
+ suggestedAction: guidance.suggestedAction
1705
+ }
1706
+ ];
1707
+ });
1708
+ }
1709
+ function resolvedFieldGuidance(field) {
1710
+ if (field === "absolutePathToLocalSnippets") {
1711
+ return {
1712
+ sdkConfigPath: ["docs", "snippets", "outputPath"],
1713
+ suggestedAction: "Choose a portable relative snippet path and set docs.snippets.outputPath manually."
1714
+ };
1715
+ }
1716
+ if (field === "idempotencyKeyGenerationConfig") {
1717
+ return {
1718
+ suggestedAction: "Preserve this orchestration setting outside SDK Config; public v1 has no idempotency-generation field."
1719
+ };
1720
+ }
1721
+ return {
1722
+ suggestedAction: "Review this Fern setting and preserve it outside SDK Config, or set an equivalent SDK Config field manually if one is introduced."
1723
+ };
1724
+ }
1725
+ function isDefaultAutomation(value) {
1726
+ return isObject(value) && value.generate === true && value.upgrade === true && value.preview === true && value.verify === true;
1727
+ }
1728
+ function mapCommonConfig(config, state, client, generation, packageConfig, basePath) {
1729
+ const inlinePath = takeBoolean(config, ["inlinePathParameters"], state, basePath);
1730
+ const inlineFile = takeBoolean(config, ["inlineFileProperties"], state, basePath);
1731
+ const inlineRequest = takeBoolean(config, ["inlineRequestParams"], state, basePath);
1732
+ if (inlinePath !== void 0) client.pathParameterStyle = inlinePath ? "inline" : "wrapped";
1733
+ if (inlineFile !== void 0) client.filePropertyStyle = inlineFile ? "inline" : "wrapped";
1734
+ if (inlineRequest !== void 0)
1735
+ client.requestParameterStyle = inlineRequest ? "inline" : "wrapped";
1736
+ const timeoutMs = takeTimeoutMs(config, state, basePath);
1737
+ if (timeoutMs !== void 0) client.timeoutMs = timeoutMs;
1738
+ const skipValidation = takeBoolean(
1739
+ config,
1740
+ ["skipResponseValidation", "skipValidation"],
1741
+ state,
1742
+ basePath
1743
+ );
1744
+ if (skipValidation !== void 0) client.responseValidation = !skipValidation;
1745
+ const useDefaults = takeBoolean(config, ["useDefaultRequestParameterValues"], state, basePath);
1746
+ if (useDefaults !== void 0) client.useDefaultRequestParameterValues = useDefaults;
1747
+ const respectOptionalBody = takeBoolean(config, ["respectOptionalRequestBody"], state, basePath);
1748
+ if (respectOptionalBody !== void 0) client.respectOptionalRequestBody = respectOptionalBody;
1749
+ const maxRetries = takeNumber(config, ["maxRetries"], state, basePath);
1750
+ const statusCodeProfile = takeEnum(
1751
+ config,
1752
+ ["retryStatusCodes"],
1753
+ ["legacy", "recommended"],
1754
+ state,
1755
+ basePath
1756
+ );
1757
+ if (maxRetries !== void 0 || statusCodeProfile !== void 0) {
1758
+ client.retry = {
1759
+ ...maxRetries === void 0 ? {} : { maxAttempts: maxRetries + 1 },
1760
+ ...optional("statusCodeProfile", statusCodeProfile)
1761
+ };
1762
+ }
1763
+ const naming = compact({
1764
+ pagerName: takeString(
1765
+ config,
1766
+ ["customPagerName", "customPagerClassname", "customPagerClassName"],
1767
+ state,
1768
+ basePath
1769
+ ),
1770
+ clientName: takeString(config, ["clientName", "clientClassName"], state, basePath),
1771
+ exportedClientName: takeString(
1772
+ config,
1773
+ ["exportedClientName", "exportedClientClassName"],
1774
+ state,
1775
+ basePath
1776
+ ),
1777
+ environmentTypeName: takeString(
1778
+ config,
1779
+ ["environmentClassName", "environmentEnumName"],
1780
+ state,
1781
+ basePath
1782
+ ),
1783
+ apiErrorName: takeString(config, ["baseApiExceptionClassName"], state, basePath),
1784
+ baseErrorName: takeString(config, ["baseExceptionClassName"], state, basePath)
1785
+ });
1786
+ if (Object.keys(naming).length) generation.naming = naming;
1787
+ const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
1788
+ if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
1789
+ const webSockets = takeBoolean(
1790
+ config,
1791
+ ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
1792
+ state,
1793
+ basePath
1794
+ );
1795
+ if (webSockets !== void 0) generation.webSockets = webSockets;
1796
+ const inlineTypes = takeBoolean(config, ["enableInlineTypes"], state, basePath);
1797
+ const omitUndefined = takeBoolean(config, ["omitUndefined"], state, basePath);
1798
+ const forwardEnums = takeBoolean(config, ["enableForwardCompatibleEnums"], state, basePath);
1799
+ const serialization = compact({
1800
+ inlineTypes,
1801
+ omitUndefined,
1802
+ enumRepresentation: forwardEnums === void 0 ? void 0 : forwardEnums ? "forward-compatible-enum" : "language-default"
1803
+ });
1804
+ if (Object.keys(serialization).length) generation.serialization = serialization;
1805
+ const namespace = takeString(config, ["namespace", "packagePrefix"], state, basePath);
1806
+ if (namespace !== void 0) packageConfig.namespace = namespace;
1807
+ const packagePath = takeString(config, ["packagePath"], state, basePath);
1808
+ if (packagePath !== void 0) generation.layout = { packagePath };
1809
+ mapDependencies(config, state, packageConfig, basePath);
1810
+ }
1811
+ function mapLanguageConfig(language, config, state, packageConfig, basePath) {
1812
+ switch (language) {
1813
+ case "typescript":
1814
+ return mapTypescript(config, state, packageConfig, basePath);
1815
+ case "mcp":
1816
+ return {
1817
+ ...mapTypescript(config, state, packageConfig, basePath),
1818
+ ...mapMcp(config, state, basePath)
1819
+ };
1820
+ case "python":
1821
+ return mapPython(config, state, packageConfig, basePath);
1822
+ case "java":
1823
+ case "kotlin":
1824
+ return mapJvm(language, config, state, packageConfig, basePath);
1825
+ case "go":
1826
+ return mapGo(config, state, packageConfig, basePath);
1827
+ case "csharp":
1828
+ return mapCsharp(config, state, packageConfig, basePath);
1829
+ case "php":
1830
+ return mapPhp(config, state, packageConfig, basePath);
1831
+ case "ruby":
1832
+ return mapRuby(config, state, packageConfig, basePath);
1833
+ case "rust":
1834
+ return mapRust(config, state, packageConfig, basePath);
1835
+ case "swift":
1836
+ return compact({ moduleName: takeString(config, ["moduleName"], state, basePath) });
1837
+ case "cli":
1838
+ return mapCli(config, state, packageConfig, basePath);
1839
+ case "terraform":
1840
+ return mapTerraform(config, state, packageConfig, basePath);
1841
+ }
1842
+ }
1843
+ function mapTypescript(config, state, packageConfig, basePath) {
1844
+ const packageJson = takeObject(config, ["packageJson"], state, basePath);
1845
+ const packageName = packageJson ? takeString(packageJson.value, ["name"], state, packageJson.path) : void 0;
1846
+ if (packageName !== void 0) packageConfig.packageName = packageName;
1847
+ const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
1848
+ const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
1849
+ return compact({
1850
+ typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
1851
+ zodVersion: takeString(config, ["zodVersion"], state, basePath),
1852
+ packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
1853
+ testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
1854
+ bundle: takeBoolean(config, ["bundle"], state, basePath),
1855
+ exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
1856
+ allowCustomFetcher: takeBoolean(config, ["allowCustomFetcher"], state, basePath),
1857
+ useBrandedStringAliases: takeBoolean(config, ["useBrandedStringAliases"], state, basePath),
1858
+ useLegacyExports: takeBoolean(config, ["useLegacyExports"], state, basePath),
1859
+ useBigInt: takeBoolean(config, ["useBigInt"], state, basePath),
1860
+ serdeLayer: serdeLayer ?? (noSerdeLayer === void 0 ? void 0 : !noSerdeLayer)
1861
+ });
1862
+ }
1863
+ function mapPython(config, state, packageConfig, basePath) {
1864
+ const moduleName = takeString(config, ["packageName"], state, basePath);
1865
+ const packageName = takeString(config, ["pypiPackageName"], state, basePath);
1866
+ if (moduleName !== void 0) packageConfig.moduleName = moduleName;
1867
+ if (packageName !== void 0) packageConfig.packageName = packageName;
1868
+ return compact({
1869
+ pythonVersion: takeString(config, ["pythonVersion", "pyprojectPythonVersion"], state, basePath),
1870
+ pydanticVersion: takeString(config, ["pydanticVersion"], state, basePath),
1871
+ alwaysInitializeOptionals: takeBoolean(config, ["alwaysInitializeOptionals"], state, basePath),
1872
+ useTypedDictRequests: takeBoolean(config, ["useTypedDictRequests"], state, basePath)
1873
+ });
1874
+ }
1875
+ function mapJvm(language, config, state, packageConfig, basePath) {
1876
+ const namespace = takeString(config, ["packageName", "packagePrefix"], state, basePath);
1877
+ const groupId = takeString(config, ["group", "groupId"], state, basePath);
1878
+ const artifactId = takeString(config, ["artifact", "artifactId"], state, basePath);
1879
+ if (namespace !== void 0) packageConfig.namespace = namespace;
1880
+ if (groupId !== void 0) packageConfig.groupId = groupId;
1881
+ if (artifactId !== void 0) packageConfig.artifactId = artifactId;
1882
+ return compact({
1883
+ packageLayout: takeEnum(config, ["packageLayout"], ["flat", "nested"], state, basePath),
1884
+ useLocalDateForDates: takeBoolean(config, ["useLocalDateForDates"], state, basePath),
1885
+ collapseOptionalNullable: takeBoolean(config, ["collapseOptionalNullable"], state, basePath),
1886
+ gradleDistributionUrl: takeString(config, ["gradleDistributionUrl"], state, basePath),
1887
+ gradlePluginManagement: takeString(config, ["gradlePluginManagement"], state, basePath),
1888
+ gradleCentralDependencyManagement: takeBoolean(
1889
+ config,
1890
+ ["gradleCentralDependencyManagement"],
1891
+ state,
1892
+ basePath
1893
+ ),
1894
+ asyncStyle: takeEnum(
1895
+ config,
1896
+ ["asyncStyle"],
1897
+ ["dedicated-client", "twin-methods"],
1898
+ state,
1899
+ basePath
1900
+ ),
1901
+ ...language === "java" ? {
1902
+ includeKotlinSnippets: takeBoolean(config, ["includeKotlinSnippets"], state, basePath)
1903
+ } : {}
1904
+ });
1905
+ }
1906
+ function mapGo(config, state, packageConfig, basePath) {
1907
+ const module = takeObject(config, ["module"], state, basePath);
1908
+ const modulePath = module ? takeGoModulePath(module.value, ["path"], state, module.path) : void 0;
1909
+ const packageName = takeString(config, ["packageName"], state, basePath);
1910
+ if (modulePath !== void 0) packageConfig.modulePath = modulePath;
1911
+ if (packageName !== void 0) packageConfig.packageName = packageName;
1912
+ return compact({
1913
+ legacyComplexModels: takeBoolean(config, ["legacyComplexModels"], state, basePath),
1914
+ unionVersion: takeEnum(config, ["union"], ["v0", "v1"], state, basePath),
1915
+ includeLegacyClientOptions: takeBoolean(
1916
+ config,
1917
+ ["includeLegacyClientOptions"],
1918
+ state,
1919
+ basePath
1920
+ ),
1921
+ clientConstructorName: takeString(config, ["clientConstructorName"], state, basePath)
1922
+ });
1923
+ }
1924
+ function mapCsharp(config, state, packageConfig, basePath) {
1925
+ const packageName = takeString(config, ["packageId"], state, basePath);
1926
+ if (packageName !== void 0) packageConfig.packageName = packageName;
1927
+ return compact({
1928
+ useOptionalWrapper: takeBoolean(config, ["useOptionalWrapper"], state, basePath),
1929
+ simplifyObjectDictionaries: takeBoolean(
1930
+ config,
1931
+ ["simplifyObjectDictionaries"],
1932
+ state,
1933
+ basePath
1934
+ ),
1935
+ explicitNamespaces: takeBoolean(config, ["explicitNamespaces"], state, basePath),
1936
+ rootNamespaceForCoreClasses: takeBoolean(
1937
+ config,
1938
+ ["rootNamespaceForCoreClasses"],
1939
+ state,
1940
+ basePath
1941
+ ),
1942
+ includeExceptionHandler: takeBoolean(config, ["includeExceptionHandler"], state, basePath),
1943
+ experimentalExplicitNullableOptional: takeBoolean(
1944
+ config,
1945
+ ["experimentalExplicitNullableOptional"],
1946
+ state,
1947
+ basePath
1948
+ )
1949
+ });
1950
+ }
1951
+ function mapPhp(config, state, packageConfig, basePath) {
1952
+ const packageName = takeString(config, ["packageName"], state, basePath);
1953
+ if (packageName !== void 0) packageConfig.packageName = packageName;
1954
+ return compact({
1955
+ propertyAccess: takeEnum(config, ["propertyAccess"], ["public", "private"], state, basePath),
1956
+ generateClientInterfaces: takeBoolean(config, ["generateClientInterfaces"], state, basePath)
1957
+ });
1958
+ }
1959
+ function mapRuby(config, state, packageConfig, basePath) {
1960
+ const moduleName = takeString(config, ["moduleName"], state, basePath);
1961
+ if (moduleName !== void 0) packageConfig.moduleName = moduleName;
1962
+ return compact({ requirePaths: takeStringArray(config, ["requirePaths"], state, basePath) });
1963
+ }
1964
+ function mapRust(config, state, packageConfig, basePath) {
1965
+ const packageName = takeString(config, ["crateName"], state, basePath);
1966
+ const repository = takeString(config, ["packageRepository"], state, basePath);
1967
+ const description = takeString(config, ["packageDescription"], state, basePath);
1968
+ const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
1969
+ Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
1970
+ return compact({
1971
+ dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
1972
+ capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
1973
+ features: takeStringArrayRecord(config, ["features"], state, basePath),
1974
+ defaultFeatures: takeStringArray(config, ["defaultFeatures"], state, basePath)
1975
+ });
1976
+ }
1977
+ function mapCli(config, state, packageConfig, basePath) {
1978
+ const identity = takeObject(config, ["packageIdentity"], state, basePath);
1979
+ if (identity) {
1980
+ Object.assign(
1981
+ packageConfig,
1982
+ compact({
1983
+ packageName: takeString(identity.value, ["name"], state, identity.path),
1984
+ repository: takeString(identity.value, ["repository"], state, identity.path),
1985
+ description: takeString(identity.value, ["description"], state, identity.path)
1986
+ })
1987
+ );
1988
+ }
1989
+ return compact({
1990
+ paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
1991
+ skills: takeBoolean(config, ["skills"], state, basePath)
1992
+ });
1993
+ }
1994
+ function mapTerraform(config, state, packageConfig, basePath) {
1995
+ const providerModulePath = takeString(
1996
+ config,
1997
+ ["providerModulePath", "providerGoModuleName"],
1998
+ state,
1999
+ basePath
2000
+ );
2001
+ if (providerModulePath !== void 0) packageConfig.modulePath = providerModulePath;
2002
+ return compact({
2003
+ providerName: takeString(config, ["providerName"], state, basePath),
2004
+ providerVersion: takeString(config, ["providerVersion"], state, basePath),
2005
+ providerModulePath,
2006
+ mockAcceptance: takeBoolean(config, ["mockAcceptance"], state, basePath),
2007
+ hideComputedDiff: takeBoolean(config, ["hideComputedDiff"], state, basePath)
2008
+ });
2009
+ }
2010
+ function mapMcp(config, state, basePath) {
2011
+ return compact({
2012
+ serverName: takeString(config, ["serverName"], state, basePath),
2013
+ serverDescription: takeString(config, ["serverDescription"], state, basePath),
2014
+ excludeAvailability: takeEnumArray(
2015
+ config,
2016
+ ["excludeAvailability"],
2017
+ [
2018
+ "IN_DEVELOPMENT",
2019
+ "PRE_RELEASE",
2020
+ "GENERAL_AVAILABILITY",
2021
+ "DEPRECATED",
2022
+ "ALPHA",
2023
+ "BETA",
2024
+ "PREVIEW",
2025
+ "LEGACY"
2026
+ ],
2027
+ state,
2028
+ basePath
2029
+ ),
2030
+ tools: takeToolFilter(config, ["tools"], state, basePath),
2031
+ toolsets: takeToolsets(config, ["toolsets"], state, basePath)
2032
+ });
2033
+ }
2034
+ function mapReadme(value, state, basePath) {
2035
+ if (!isObject(value)) return {};
2036
+ const readme = compact({
2037
+ apiName: takeString(value, ["apiName"], state, basePath),
2038
+ introduction: takeString(value, ["introduction"], state, basePath),
2039
+ apiReferenceLink: takeString(value, ["apiReferenceLink"], state, basePath),
2040
+ bannerLink: takeString(value, ["bannerLink"], state, basePath),
2041
+ disabledSections: takeStringArray(value, ["disabledSections"], state, basePath),
2042
+ customSections: takeCustomSections(value, state, basePath),
2043
+ defaultEndpoint: takeReadmeEndpoint(value, ["defaultEndpoint"], state, basePath),
2044
+ features: takeReadmeFeatures(value, state, basePath)
2045
+ });
2046
+ return Object.keys(readme).length ? { readme } : {};
2047
+ }
2048
+ function mapPublishMetadata(value, packageConfig) {
2049
+ if (!isObject(value)) return;
2050
+ const publisherName = stringValue(value.publisherName);
2051
+ const publisherEmail = stringValue(value.publisherEmail);
2052
+ Object.assign(
2053
+ packageConfig,
2054
+ compact({
2055
+ description: stringValue(value.packageDescription),
2056
+ documentationUrl: stringValue(value.referenceUrl),
2057
+ authors: publisherName ? [{ name: publisherName, ...optional("email", publisherEmail) }] : void 0
2058
+ })
2059
+ );
2060
+ }
2061
+ function mapDependencies(config, state, packageConfig, basePath) {
2062
+ for (const field of [
2063
+ "extraDependencies",
2064
+ "extraDevDependencies",
2065
+ "extraPeerDependencies"
2066
+ ]) {
2067
+ const located = takeObject(config, [field], state, basePath);
2068
+ if (!located) continue;
2069
+ const dependencies = Object.entries(located.value).flatMap(
2070
+ ([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
2071
+ );
2072
+ if (dependencies.length) packageConfig[field] = dependencies;
2073
+ }
2074
+ }
2075
+ function mapDependency(name, value, state, path) {
2076
+ if (typeof value === "string" && value) {
2077
+ consume(state, path);
2078
+ return [{ name, version: value }];
2079
+ }
2080
+ if (!isObject(value)) return [];
2081
+ const version = takeString(value, ["version"], state, path);
2082
+ const gitUrl = takeString(value, ["git"], state, path);
2083
+ const localPath = takeString(value, ["path"], state, path);
2084
+ const source = gitUrl ? {
2085
+ type: "git",
2086
+ url: gitUrl,
2087
+ ...optional("ref", takeString(value, ["ref"], state, path))
2088
+ } : localPath ? { type: "path", path: localPath } : void 0;
2089
+ if (!version && !source) return [];
2090
+ return [
2091
+ {
2092
+ name,
2093
+ ...optional("version", version),
2094
+ ...optional("source", source),
2095
+ ...optional("packageName", takeString(value, ["package"], state, path)),
2096
+ ...optional("features", takeStringArray(value, ["features"], state, path)),
2097
+ ...optional("extras", takeStringArray(value, ["extras"], state, path)),
2098
+ ...optional("optional", takeBoolean(value, ["optional"], state, path)),
2099
+ ...optional("defaultFeatures", takeBoolean(value, ["defaultFeatures"], state, path)),
2100
+ ...optional("environmentMarker", takeString(value, ["python"], state, path))
2101
+ }
2102
+ ];
2103
+ }
2104
+ function takeCustomSections(value, state, basePath) {
2105
+ const located = locate(value, ["customSections"], basePath);
2106
+ if (!located || !Array.isArray(located.value)) return void 0;
2107
+ const sections = located.value.flatMap(
2108
+ (section) => isObject(section) && section.language === void 0 && typeof section.title === "string" && typeof section.content === "string" ? [{ title: section.title, content: section.content }] : []
2109
+ );
2110
+ if (sections.length !== located.value.length) return void 0;
2111
+ consume(state, located.path);
2112
+ return sections;
2113
+ }
2114
+ function takeReadmeEndpoint(value, aliases, state, basePath) {
2115
+ const located = locate(value, aliases, basePath);
2116
+ if (!located) return void 0;
2117
+ const endpoint = parseReadmeEndpoint(located.value);
2118
+ if (endpoint) consume(state, located.path);
2119
+ return endpoint;
2120
+ }
2121
+ function takeReadmeFeatures(value, state, basePath) {
2122
+ const located = locate(value, ["features"], basePath);
2123
+ if (!located || !isObject(located.value)) return void 0;
2124
+ const features = {};
2125
+ for (const [name, endpoints] of Object.entries(located.value)) {
2126
+ if (!Array.isArray(endpoints)) return void 0;
2127
+ const parsed = endpoints.map(parseReadmeEndpoint);
2128
+ if (parsed.some((endpoint) => !endpoint)) return void 0;
2129
+ features[name] = parsed;
2130
+ }
2131
+ consume(state, located.path);
2132
+ return features;
2133
+ }
2134
+ function parseReadmeEndpoint(value) {
2135
+ if (typeof value === "string") {
2136
+ const match = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)\s+(\/\S*)$/.exec(
2137
+ value.trim()
2138
+ );
2139
+ return match ? { method: match[1], path: match[2] } : void 0;
2140
+ }
2141
+ if (!isObject(value) || typeof value.method !== "string" || typeof value.path !== "string") {
2142
+ return void 0;
2143
+ }
2144
+ const method = value.method.toUpperCase();
2145
+ if (!["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT"].includes(
2146
+ method
2147
+ )) {
2148
+ return void 0;
2149
+ }
2150
+ return {
2151
+ method,
2152
+ path: value.path,
2153
+ ...optional("stream", typeof value.stream === "boolean" ? value.stream : void 0)
2154
+ };
2155
+ }
2156
+ function takeToolFilter(value, aliases, state, basePath) {
2157
+ const located = takeObject(value, aliases, state, basePath);
2158
+ if (!located) return void 0;
2159
+ const filter = compact({
2160
+ include: stringArrayValue(located.value.include),
2161
+ exclude: stringArrayValue(located.value.exclude)
2162
+ });
2163
+ if (Object.keys(filter).length === 0 && Object.keys(located.value).length > 0) return void 0;
2164
+ consume(state, located.path);
2165
+ return filter;
2166
+ }
2167
+ function takeToolsets(value, aliases, state, basePath) {
2168
+ const located = takeObject(value, aliases, state, basePath);
2169
+ if (!located) return void 0;
2170
+ const entries = Object.entries(located.value).map(([name, filter]) => {
2171
+ if (name === "default" || !/^[a-z0-9-]+$/.test(name)) {
2172
+ fail(
2173
+ "FERN_MCP_TOOLSET_NAME_INVALID",
2174
+ [...located.path, name],
2175
+ `MCP toolset name "${name}" is not valid in SDK Config v1`,
2176
+ 'Rename the toolset to lowercase letters, numbers, or hyphens; "default" is reserved.',
2177
+ ["targets", basePath[2], "generation", "toolsets", name]
2178
+ );
2179
+ }
2180
+ if (!isObject(filter)) return void 0;
2181
+ return [
2182
+ name,
2183
+ compact({
2184
+ include: stringArrayValue(filter.include),
2185
+ exclude: stringArrayValue(filter.exclude)
2186
+ })
2187
+ ];
2188
+ });
2189
+ if (entries.some((entry) => !entry)) return void 0;
2190
+ consume(state, located.path);
2191
+ return Object.fromEntries(entries.filter((entry) => entry !== void 0));
2192
+ }
2193
+ var unsupportedFieldSchema = z.strictObject({
2194
+ source: z.enum(["fern", "postman", "sdk-config-ir"]),
2195
+ path: z.array(z.union([nonEmptyStringSchema, z.number().int().nonnegative()])).min(1),
2196
+ code: nonEmptyStringSchema.optional(),
2197
+ reason: nonEmptyStringSchema,
2198
+ severity: z.enum(["error", "warning", "info"]),
2199
+ risk: z.enum(["high", "medium", "low"]),
2200
+ owner: nonEmptyStringSchema,
2201
+ suggestedAction: nonEmptyStringSchema
2202
+ });
2203
+ var postmanLegacyInputSchema = z.strictObject({
2204
+ kind: z.literal("postman-build-parameters"),
2205
+ value: jsonObjectSchema
2206
+ });
2207
+ var fernLegacyInputSchema = z.strictObject({
2208
+ kind: z.literal("fern-generator-invocation"),
2209
+ value: jsonObjectSchema
2210
+ });
2211
+ var legacyInputSchema = z.discriminatedUnion("kind", [
2212
+ postmanLegacyInputSchema,
2213
+ fernLegacyInputSchema
2214
+ ]);
2215
+ var compatibilityConfigSchema = z.strictObject({
2216
+ outputProfile: z.enum(["converged", "postman-legacy", "fern-legacy"]),
2217
+ legacyInput: legacyInputSchema.optional(),
2218
+ unsupportedFields: z.array(unsupportedFieldSchema).optional()
2219
+ });
2220
+ var generationAssetSchema = z.discriminatedUnion("type", [
2221
+ z.strictObject({ type: z.literal("path"), location: relativePathSchema }),
2222
+ z.strictObject({ type: z.literal("url"), location: nonEmptyStringSchema }),
2223
+ z.strictObject({ type: z.literal("artifact"), location: nonEmptyStringSchema })
2224
+ ]);
2225
+ var hookDependencySchema2 = z.strictObject({
2226
+ name: nonEmptyStringSchema,
2227
+ version: nonEmptyStringSchema,
2228
+ groupId: nonEmptyStringSchema.optional()
2229
+ });
2230
+ var hooksConfigSchema2 = z.strictObject({
2231
+ enabled: z.boolean(),
2232
+ source: generationAssetSchema.optional(),
2233
+ dependencies: z.array(hookDependencySchema2).optional()
2234
+ });
2235
+ var customCodeConfigSchema2 = z.strictObject({
2236
+ enabled: z.boolean(),
2237
+ source: generationAssetSchema.optional(),
2238
+ conflictStrategy: z.enum(["mark", "ours", "theirs"]).optional(),
2239
+ trackChanges: z.boolean().optional(),
2240
+ previousBuildId: z.number().int().positive().optional(),
2241
+ protectedFiles: z.array(nonEmptyStringSchema).optional()
2242
+ });
2243
+ var workflowConfigSchema2 = z.strictObject({
2244
+ path: relativePathSchema,
2245
+ outputName: nonEmptyStringSchema.optional()
2246
+ });
2247
+ var analyticsHeaderSchema2 = z.union([
2248
+ z.strictObject({ name: nonEmptyStringSchema, value: z.string() }),
2249
+ z.strictObject({ name: nonEmptyStringSchema, valueRef: nonEmptyStringSchema })
2250
+ ]);
2251
+ var analyticsConfigSchema2 = z.strictObject({
2252
+ enabled: z.boolean(),
2253
+ endpoint: nonEmptyStringSchema.optional(),
2254
+ exporter: z.enum(["otlp-http", "console"]).optional(),
2255
+ headers: z.array(analyticsHeaderSchema2).optional(),
2256
+ batchSize: z.number().int().positive().optional(),
2257
+ scheduledDelayMs: z.number().nonnegative().optional(),
2258
+ exportTimeoutMs: z.number().nonnegative().optional()
2259
+ }).superRefine(({ enabled, endpoint }, context) => {
2260
+ if (enabled && endpoint === void 0) {
2261
+ context.addIssue({
2262
+ code: "custom",
2263
+ message: "endpoint is required when analytics is enabled",
2264
+ path: ["endpoint"]
2265
+ });
2266
+ }
2267
+ });
2268
+ var wireTestsSchema2 = z.strictObject({
2269
+ enabled: z.boolean(),
2270
+ exclusions: z.array(nonEmptyStringSchema).optional(),
2271
+ fallbackToGeneratedErrorExamples: z.boolean().optional(),
2272
+ fixtureSource: z.enum(["synthetic", "recorded", "auto"]).optional()
2273
+ });
2274
+ var unitTestsSchema2 = z.strictObject({
560
2275
  enabled: z.boolean(),
561
2276
  mode: z.enum(["core-runtime", "schema-driven", "both"]).optional(),
562
2277
  exclusions: z.array(nonEmptyStringSchema).optional()
563
2278
  });
564
- var streamsSchema = z.strictObject({
2279
+ var fernDefinitionMetadataSchema = z.strictObject({
2280
+ definitionS3DownloadUrl: nonEmptyStringSchema,
2281
+ outputPath: nonEmptyStringSchema.optional(),
2282
+ cliVersion: nonEmptyStringSchema.optional()
2283
+ });
2284
+ var streamsSchema2 = z.strictObject({
565
2285
  enabled: z.boolean(),
566
2286
  responseType: z.enum(["wrapper", "native", "web"]).optional(),
567
2287
  fileResponseType: z.enum(["stream", "binary-response"]).optional(),
568
2288
  defaultChunkSizeBytes: z.number().int().positive().optional()
569
2289
  });
570
- var namingConfigSchema = z.strictObject({
2290
+ var namingConfigSchema2 = z.strictObject({
571
2291
  clientName: nonEmptyStringSchema.optional(),
572
2292
  exportedClientName: nonEmptyStringSchema.optional(),
573
2293
  environmentTypeName: nonEmptyStringSchema.optional(),
@@ -575,11 +2295,11 @@ var namingConfigSchema = z.strictObject({
575
2295
  baseErrorName: nonEmptyStringSchema.optional(),
576
2296
  pagerName: nonEmptyStringSchema.optional()
577
2297
  });
578
- var layoutConfigSchema = z.strictObject({
2298
+ var layoutConfigSchema2 = z.strictObject({
579
2299
  outputDirectory: z.enum(["project-root", "source-root"]).optional(),
580
2300
  packagePath: nonEmptyStringSchema.optional()
581
2301
  });
582
- var serializationConfigSchema = z.strictObject({
2302
+ var serializationConfigSchema2 = z.strictObject({
583
2303
  enumRepresentation: z.enum(["enum", "union", "literal", "forward-compatible-enum", "language-default"]).optional(),
584
2304
  additionalProperties: z.enum(["allow", "forbid", "ignore", "language-default"]).optional(),
585
2305
  inlineTypes: z.boolean().optional(),
@@ -612,19 +2332,30 @@ var generationConfigSchema = z.strictObject({
612
2332
  devContainer: z.boolean().default(false),
613
2333
  allowMockClient: z.boolean().default(false),
614
2334
  ignoreFiles: z.array(nonEmptyStringSchema).optional(),
2335
+ /**
2336
+ * Raw .fernignore file contents supplied to external publishers that need Fern ignore semantics.
2337
+ * This is separate from generation.ignoreFiles because raw contents preserve comments, ordering,
2338
+ * blank lines, and negation rules.
2339
+ */
2340
+ fernignoreContents: z.string().optional(),
2341
+ /**
2342
+ * Optional Fern definition metadata for publisher paths that need to write definition or
2343
+ * mock-server support files. This is not required for core GitHub artifact publishing.
2344
+ */
2345
+ fernDefinitionMetadata: fernDefinitionMetadataSchema.optional(),
615
2346
  reservedKeywords: z.array(nonEmptyStringSchema).optional(),
616
- hooks: hooksConfigSchema.optional(),
617
- customCode: customCodeConfigSchema.optional(),
618
- workflows: z.array(workflowConfigSchema).optional(),
619
- customQueryPaths: z.array(nonEmptyStringSchema).optional(),
620
- analytics: analyticsConfigSchema.optional(),
621
- wireTests: wireTestsSchema.optional(),
622
- unitTests: unitTestsSchema.optional(),
2347
+ hooks: hooksConfigSchema2.optional(),
2348
+ customCode: customCodeConfigSchema2.optional(),
2349
+ workflows: z.array(workflowConfigSchema2).optional(),
2350
+ customQueryPaths: z.array(relativePathSchema).optional(),
2351
+ analytics: analyticsConfigSchema2.optional(),
2352
+ wireTests: wireTestsSchema2.optional(),
2353
+ unitTests: unitTestsSchema2.optional(),
623
2354
  webSockets: z.boolean().optional(),
624
- streams: streamsSchema.optional(),
625
- naming: namingConfigSchema.optional(),
626
- layout: layoutConfigSchema.optional(),
627
- serialization: serializationConfigSchema.optional(),
2355
+ streams: streamsSchema2.optional(),
2356
+ naming: namingConfigSchema2.optional(),
2357
+ layout: layoutConfigSchema2.optional(),
2358
+ serialization: serializationConfigSchema2.optional(),
628
2359
  language: languageGenerationConfigSchema.optional()
629
2360
  });
630
2361
  var publishRegistrySchema = z.enum([
@@ -637,57 +2368,95 @@ var publishRegistrySchema = z.enum([
637
2368
  "go",
638
2369
  "composer"
639
2370
  ]);
640
- var commonPublishShape = {
2371
+ var credentialResolutionSchema = z.enum([
2372
+ "refs-only",
2373
+ "resolved-by-orchestrator",
2374
+ "resolved-by-fiddle"
2375
+ ]);
2376
+ var commonPublishShape2 = {
641
2377
  url: nonEmptyStringSchema.optional(),
2378
+ /**
2379
+ * Reference to registry publishing credentials. Raw tokens/passwords are intentionally not part of
2380
+ * SDK Config IR; the external publisher or orchestrator resolves this reference before use.
2381
+ */
642
2382
  credentialsRef: nonEmptyStringSchema.optional(),
643
2383
  releaseBranch: nonEmptyStringSchema.optional(),
644
2384
  tolerateRepublish: z.boolean().optional()
645
2385
  };
646
2386
  var publishConfigSchema = z.discriminatedUnion("registry", [
647
- z.strictObject({ registry: z.literal("npm"), ...commonPublishShape }),
648
- z.strictObject({ registry: z.literal("pypi"), ...commonPublishShape }),
649
- z.strictObject({ registry: z.literal("nuget"), ...commonPublishShape }),
650
- z.strictObject({ registry: z.literal("rubygems"), ...commonPublishShape }),
651
- z.strictObject({ registry: z.literal("crates"), ...commonPublishShape }),
652
- z.strictObject({ registry: z.literal("go"), ...commonPublishShape }),
653
- z.strictObject({ registry: z.literal("composer"), ...commonPublishShape }),
2387
+ z.strictObject({ registry: z.literal("npm"), ...commonPublishShape2 }),
2388
+ z.strictObject({ registry: z.literal("pypi"), ...commonPublishShape2 }),
2389
+ z.strictObject({ registry: z.literal("nuget"), ...commonPublishShape2 }),
2390
+ z.strictObject({ registry: z.literal("rubygems"), ...commonPublishShape2 }),
2391
+ z.strictObject({ registry: z.literal("crates"), ...commonPublishShape2 }),
2392
+ z.strictObject({ registry: z.literal("go"), ...commonPublishShape2 }),
2393
+ z.strictObject({ registry: z.literal("composer"), ...commonPublishShape2 }),
654
2394
  z.strictObject({
655
2395
  registry: z.literal("maven"),
2396
+ /**
2397
+ * Reference to Maven signing credentials. Raw signing keys are intentionally not part of SDK
2398
+ * Config IR; the external publisher or orchestrator resolves this reference before use.
2399
+ */
656
2400
  signingCredentialsRef: nonEmptyStringSchema.optional(),
657
- ...commonPublishShape
2401
+ ...commonPublishShape2
658
2402
  })
659
2403
  ]);
660
- var reviewersSchema = z.strictObject({
2404
+ var reviewersSchema2 = z.strictObject({
661
2405
  teams: z.array(nonEmptyStringSchema).optional(),
662
2406
  users: z.array(nonEmptyStringSchema).optional()
663
2407
  });
664
- var githubOutputSchema = z.strictObject({
2408
+ var replayControlSchema = z.strictObject({
2409
+ enabled: z.boolean()
2410
+ });
2411
+ var githubOutputSchema2 = z.strictObject({
665
2412
  repository: nonEmptyStringSchema,
666
2413
  host: nonEmptyStringSchema.optional(),
667
2414
  branch: nonEmptyStringSchema.optional(),
668
2415
  mode: z.enum(["release", "pull-request", "push"]).optional(),
669
- reviewers: reviewersSchema.optional(),
2416
+ reviewers: reviewersSchema2.optional(),
2417
+ /**
2418
+ * Reference to GitHub credentials. Raw tokens are intentionally not part of SDK Config IR; the
2419
+ * external publisher or orchestrator resolves this reference before use.
2420
+ */
670
2421
  credentialsRef: nonEmptyStringSchema.optional(),
671
- privateRepository: z.boolean().optional()
672
- });
673
- var filesOutputSchema = z.strictObject({
2422
+ privateRepository: z.boolean().optional(),
2423
+ /** GitHub replay control. If omitted, the external publisher applies its default behavior. */
2424
+ replay: replayControlSchema.optional(),
2425
+ /** Run GitHub publishing verification. Defaults to false to match current Fiddle job behavior. */
2426
+ verify: z.boolean().default(false),
2427
+ /** Skip creating/updating a GitHub PR when no files changed. Defaults to false. */
2428
+ skipIfNoDiff: z.boolean().default(false),
2429
+ /** Automatically merge the GitHub publishing PR. Defaults to false. */
2430
+ autoMerge: z.boolean().default(false)
2431
+ });
2432
+ var credentialResolutionShape = {
2433
+ /**
2434
+ * Where output credential references are resolved. SDK Config IR carries refs only; raw resolved
2435
+ * credentials belong at the external publisher/orchestrator boundary, not in this config.
2436
+ */
2437
+ credentialResolution: credentialResolutionSchema.default("refs-only")
2438
+ };
2439
+ var filesOutputSchema2 = z.strictObject({
674
2440
  delivery: z.literal("files"),
675
2441
  path: nonEmptyStringSchema.optional(),
676
- publish: publishConfigSchema.optional()
2442
+ publish: publishConfigSchema.optional(),
2443
+ ...credentialResolutionShape
677
2444
  });
678
- var zipOutputSchema = z.strictObject({
2445
+ var zipOutputSchema2 = z.strictObject({
679
2446
  delivery: z.literal("zip"),
680
2447
  fileName: nonEmptyStringSchema.optional(),
681
- publish: publishConfigSchema.optional()
2448
+ publish: publishConfigSchema.optional(),
2449
+ ...credentialResolutionShape
682
2450
  });
683
- var githubDeliverySchema = z.strictObject({
2451
+ var githubDeliverySchema2 = z.strictObject({
684
2452
  delivery: z.literal("github"),
685
- github: githubOutputSchema,
686
- publish: publishConfigSchema.optional()
2453
+ github: githubOutputSchema2,
2454
+ publish: publishConfigSchema.optional(),
2455
+ ...credentialResolutionShape
687
2456
  });
688
2457
  var outputConfigSchema = z.discriminatedUnion(
689
2458
  "delivery",
690
- [filesOutputSchema, zipOutputSchema, githubDeliverySchema],
2459
+ [filesOutputSchema2, zipOutputSchema2, githubDeliverySchema2],
691
2460
  {
692
2461
  error: 'output.delivery must be one of "files", "zip", or "github"'
693
2462
  }
@@ -703,7 +2472,8 @@ var apiImportSettingsSchema = z.strictObject({
703
2472
  onlyIncludeReferencedSchemas: z.boolean().optional(),
704
2473
  objectQueryParameters: z.boolean().optional(),
705
2474
  typeDatesAsStrings: z.boolean().optional(),
706
- groupMultiApiEnvironments: z.boolean().optional()
2475
+ groupMultiApiEnvironments: z.boolean().optional(),
2476
+ defaultIntegerFormat: z.enum(["int32", "int64", "uint32", "uint64"]).optional()
707
2477
  });
708
2478
  var sourceSpecTypeSchema = z.enum([
709
2479
  "openapi",
@@ -760,15 +2530,27 @@ var targetConfigSchema = z.strictObject({
760
2530
  generatorVersion: exactSemverSchema.optional(),
761
2531
  sourceOrigin: z.enum(["postman", "fern"]),
762
2532
  sdkName: nonEmptyStringSchema,
2533
+ /**
2534
+ * Stable Fern/Fiddle API identity for external publishing.
2535
+ * Producers must set this explicitly for GitHub or registry publishing; it is not inferred from
2536
+ * target.sdkName because SDK display names and Fern API names are not equivalent.
2537
+ */
2538
+ apiName: nonEmptyStringSchema.optional(),
763
2539
  organization: nonEmptyStringSchema.optional(),
2540
+ /**
2541
+ * Stable Fern/Fiddle organization identity for external publishing.
2542
+ * Producers must set this explicitly for GitHub or registry publishing; it is not inferred from
2543
+ * target.organization because source organization metadata is optional and may not match Fern.
2544
+ */
2545
+ organizationName: nonEmptyStringSchema.optional(),
764
2546
  sdkVersion: nonEmptyStringSchema.default("1.0.0"),
765
2547
  apiVersion: nonEmptyStringSchema.optional()
766
2548
  });
767
2549
 
768
2550
  // src/sdk-config-ir/v1/sdk-config-ir-v1.ts
769
2551
  var SDK_CONFIG_IR_V1_SCHEMA_VERSION = "sdk-config-ir/v1";
770
- var publishRegistryLanguages = {
771
- npm: ["typescript"],
2552
+ var publishRegistryLanguages2 = {
2553
+ npm: ["typescript", "mcp"],
772
2554
  pypi: ["python"],
773
2555
  maven: ["java", "kotlin"],
774
2556
  nuget: ["csharp"],
@@ -777,7 +2559,7 @@ var publishRegistryLanguages = {
777
2559
  go: ["go"],
778
2560
  composer: ["php"]
779
2561
  };
780
- var packageNameRegistries = /* @__PURE__ */ new Set([
2562
+ var packageNameRegistries2 = /* @__PURE__ */ new Set([
781
2563
  "npm",
782
2564
  "pypi",
783
2565
  "nuget",
@@ -785,8 +2567,8 @@ var packageNameRegistries = /* @__PURE__ */ new Set([
785
2567
  "crates",
786
2568
  "composer"
787
2569
  ]);
788
- function validatePublishingIdentity(packageConfig, registry, context) {
789
- if (packageNameRegistries.has(registry) && !packageConfig.packageName) {
2570
+ function validatePublishingIdentity2(packageConfig, registry, context) {
2571
+ if (packageNameRegistries2.has(registry) && !packageConfig.packageName) {
790
2572
  context.addIssue({
791
2573
  code: "custom",
792
2574
  message: `package.packageName is required when publishing to "${registry}"`,
@@ -836,6 +2618,21 @@ var sdkConfigIrV1Schema = z.strictObject({
836
2618
  compatibility: compatibilityConfigSchema.optional()
837
2619
  }).superRefine(({ compatibility, generation, output, package: packageConfig, target }, context) => {
838
2620
  const configuredLanguages = Object.keys(generation.language ?? {});
2621
+ const requiresExternalPublishIdentity = output.delivery === "github" || output.publish !== void 0;
2622
+ if (requiresExternalPublishIdentity) {
2623
+ [
2624
+ ["apiName", "target.apiName is required for external publishing"],
2625
+ ["organizationName", "target.organizationName is required for external publishing"]
2626
+ ].forEach(([field, message]) => {
2627
+ if (!target[field]) {
2628
+ context.addIssue({
2629
+ code: "custom",
2630
+ message,
2631
+ path: ["target", field]
2632
+ });
2633
+ }
2634
+ });
2635
+ }
839
2636
  configuredLanguages.forEach((language) => {
840
2637
  if (language !== target.language) {
841
2638
  context.addIssue({
@@ -845,7 +2642,7 @@ var sdkConfigIrV1Schema = z.strictObject({
845
2642
  });
846
2643
  }
847
2644
  });
848
- if (output.publish && !publishRegistryLanguages[output.publish.registry].some(
2645
+ if (output.publish && !publishRegistryLanguages2[output.publish.registry].some(
849
2646
  (language) => language === target.language
850
2647
  )) {
851
2648
  context.addIssue({
@@ -855,7 +2652,7 @@ var sdkConfigIrV1Schema = z.strictObject({
855
2652
  });
856
2653
  }
857
2654
  if (output.publish) {
858
- validatePublishingIdentity(packageConfig, output.publish.registry, context);
2655
+ validatePublishingIdentity2(packageConfig, output.publish.registry, context);
859
2656
  }
860
2657
  if (compatibility?.legacyInput) {
861
2658
  const expectedKind = target.sourceOrigin === "postman" ? "postman-build-parameters" : "fern-generator-invocation";
@@ -872,6 +2669,6 @@ function parseSdkConfigIrV1(value) {
872
2669
  return sdkConfigIrV1Schema.parse(value);
873
2670
  }
874
2671
 
875
- export { SDK_CONFIG_IR_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliGenerationConfigSchema, clientConfigSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeEndpointSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrV1Schema, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema };
2672
+ export { FernConfigMappingError, SDK_CONFIG_IR_V1_SCHEMA_VERSION, SDK_CONFIG_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliGenerationConfigSchema, clientConfigSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mapFernConfigToSdkConfigV1, mcpAvailabilityStatuses, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, parseSdkConfigV1, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeCustomSectionSchema, readmeEndpointSchema, relativePathSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrV1Schema, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, relativePathSchema as sdkConfigV1RelativePathSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema };
876
2673
  //# sourceMappingURL=index.js.map
877
2674
  //# sourceMappingURL=index.js.map