@postman/sdk-config 0.10.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +6 -0
  2. package/dist/index.cjs +909 -41
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +3 -3
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.js +895 -42
  7. package/dist/index.js.map +1 -1
  8. package/dist/sdk-config/index.cjs +861 -41
  9. package/dist/sdk-config/index.cjs.map +1 -1
  10. package/dist/sdk-config/index.d.cts +2 -2
  11. package/dist/sdk-config/index.d.ts +2 -2
  12. package/dist/sdk-config/index.js +854 -42
  13. package/dist/sdk-config/index.js.map +1 -1
  14. package/dist/sdk-config/v1/index.cjs +861 -41
  15. package/dist/sdk-config/v1/index.cjs.map +1 -1
  16. package/dist/sdk-config/v1/index.d.cts +3345 -2632
  17. package/dist/sdk-config/v1/index.d.ts +3345 -2632
  18. package/dist/sdk-config/v1/index.js +854 -42
  19. package/dist/sdk-config/v1/index.js.map +1 -1
  20. package/dist/sdk-config-ir/index.cjs +286 -5
  21. package/dist/sdk-config-ir/index.cjs.map +1 -1
  22. package/dist/sdk-config-ir/index.d.cts +2 -2
  23. package/dist/sdk-config-ir/index.d.ts +2 -2
  24. package/dist/sdk-config-ir/index.js +280 -6
  25. package/dist/sdk-config-ir/index.js.map +1 -1
  26. package/dist/sdk-config-ir/v1/index.cjs +286 -5
  27. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  28. package/dist/sdk-config-ir/v1/index.d.cts +3291 -2958
  29. package/dist/sdk-config-ir/v1/index.d.ts +3291 -2958
  30. package/dist/sdk-config-ir/v1/index.js +280 -6
  31. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  32. package/dist/{typescript-Chge0X4f.d.cts → typescript-Byhn4MqL.d.cts} +145 -1
  33. package/dist/{typescript-Chge0X4f.d.ts → typescript-Byhn4MqL.d.ts} +145 -1
  34. package/package.json +1 -1
  35. package/src/sdk-config/v1/README.md +183 -1
  36. package/src/sdk-config-ir/v1/README.md +107 -31
package/dist/index.js CHANGED
@@ -125,13 +125,21 @@ var oauthScopeSchema = z.strictObject({
125
125
  name: nonEmptyStringSchema.describe("The OAuth scope value requested from the provider."),
126
126
  description: z.string().optional().describe("A description of the OAuth scope included in generated SDK documentation.")
127
127
  });
128
+ var publicClientIdSchema = nonEmptyStringSchema.refine((value) => value.trim() === value, {
129
+ message: "must not have leading or trailing whitespace"
130
+ }).refine((value) => !value.includes("${"), {
131
+ message: "must be a literal public client ID, not an environment expression"
132
+ });
128
133
  var oauthFlowSchema = z.discriminatedUnion("type", [
129
134
  z.strictObject({
130
135
  type: z.literal("authorization-code").describe("Uses the OAuth authorization code flow."),
131
136
  authorizationUrl: nonEmptyStringSchema.describe("The URL used to authorize the client."),
132
137
  tokenUrl: nonEmptyStringSchema.describe("The URL used to exchange a code for tokens."),
133
138
  refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
134
- scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow.")
139
+ scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow."),
140
+ clientId: publicClientIdSchema.optional().describe(
141
+ "The public, non-secret OAuth client ID that generated interactive login flows, such as CLI browser login with PKCE, send to the authorization and token endpoints. It is embedded verbatim in generated code, so it must never be a client secret."
142
+ )
135
143
  }),
136
144
  z.strictObject({
137
145
  type: z.literal("client-credentials").describe("Uses the OAuth client credentials flow."),
@@ -424,6 +432,12 @@ var dependencySchema = z.strictObject({
424
432
  }).refine(({ source, version }) => source !== void 0 || version !== void 0, {
425
433
  message: "dependency must define a version or a source"
426
434
  });
435
+ var bugsSchema = z.strictObject({
436
+ url: nonEmptyStringSchema.optional().describe("The issue tracker URL."),
437
+ email: nonEmptyStringSchema.optional().describe("The address for reporting issues.")
438
+ }).refine(({ url, email }) => url !== void 0 || email !== void 0, {
439
+ message: "bugs must define a url or an email"
440
+ });
427
441
  var projectUrlSchema = z.strictObject({
428
442
  label: nonEmptyStringSchema.describe("The label displayed for the project link."),
429
443
  url: nonEmptyStringSchema.describe("The project link URL.")
@@ -438,6 +452,7 @@ var packageConfigSchema = z.strictObject({
438
452
  description: z.string().optional().describe("The package description used in generated metadata."),
439
453
  repository: nonEmptyStringSchema.optional().describe("The source repository for the generated SDK."),
440
454
  homepage: nonEmptyStringSchema.optional().describe("The package homepage URL."),
455
+ bugs: bugsSchema.optional().describe("Where issues with the package are reported."),
441
456
  documentationUrl: nonEmptyStringSchema.optional().describe("The package documentation URL."),
442
457
  authors: z.array(authorSchema).optional().describe("Authors credited in package metadata."),
443
458
  developers: z.array(developerSchema).optional().describe("Developers credited in package metadata."),
@@ -447,8 +462,102 @@ var packageConfigSchema = z.strictObject({
447
462
  projectUrls: z.array(projectUrlSchema).optional().describe("Labeled project links for package metadata."),
448
463
  extraDependencies: z.array(dependencySchema).optional().describe("Additional runtime dependencies added to the generated package."),
449
464
  extraDevDependencies: z.array(dependencySchema).optional().describe("Additional development dependencies added to the generated package."),
450
- extraPeerDependencies: z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package.")
465
+ extraPeerDependencies: z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package."),
466
+ extraPeerDependenciesMeta: z.record(nonEmptyStringSchema, jsonObjectSchema).optional().describe(
467
+ "npm peerDependenciesMeta entries keyed by peer dependency name, such as { optional: true }."
468
+ )
451
469
  });
470
+ var GITHUB_ACTIONS_SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/;
471
+ var GITHUB_REPOSITORY_SLUG_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
472
+ var HOMEBREW_FORMULA_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
473
+ var githubActionsSecretNameSchema = z.string({ error: "must be the name of a GitHub Actions secret" }).regex(GITHUB_ACTIONS_SECRET_NAME_PATTERN, {
474
+ error: "must be the name of a GitHub Actions secret: start with an uppercase letter and contain only A-Z, 0-9, or _. Secret values and ${...} expressions are not accepted."
475
+ }).refine((value) => value !== "GITHUB_TOKEN", {
476
+ error: "GITHUB_TOKEN cannot be used: it is the workflow's built-in token, scoped to the generated repository. Store the credential under a different secret name."
477
+ });
478
+ var githubRepositorySlugSchema = z.string({ error: 'must be a GitHub repository in "<owner>/<repo>" form' }).regex(GITHUB_REPOSITORY_SLUG_PATTERN, {
479
+ error: 'must be a GitHub repository in "<owner>/<repo>" form, for example "acme/homebrew-tap"'
480
+ });
481
+ var homebrewFormulaNameSchema = z.string({ error: "must be a Homebrew formula name" }).regex(HOMEBREW_FORMULA_NAME_PATTERN, {
482
+ error: "must be a Homebrew formula name: start with a lowercase letter and contain only a-z, 0-9, or -"
483
+ });
484
+ var cliDistributionGithubAppSchema = z.strictObject({
485
+ appIdSecretName: githubActionsSecretNameSchema.describe(
486
+ "The name of the GitHub Actions secret holding the GitHub App ID or client ID."
487
+ ),
488
+ privateKeySecretName: githubActionsSecretNameSchema.describe(
489
+ "The name of the GitHub Actions secret holding the GitHub App private key in PEM form."
490
+ )
491
+ });
492
+ var channelTokenSecretNameDescription = "The name of the GitHub Actions secret holding a token with write access to the channel repository. Takes precedence over githubApp for this channel.";
493
+ var cliDistributionHomebrewSchema = z.strictObject({
494
+ tap: githubRepositorySlugSchema.describe(
495
+ 'The Homebrew tap repository in "<owner>/<repo>" form that receives the formula.'
496
+ ),
497
+ formula: homebrewFormulaNameSchema.optional().describe("The Homebrew formula name; the generator defaults it to the CLI binary name."),
498
+ tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
499
+ });
500
+ var cliDistributionScoopSchema = z.strictObject({
501
+ bucket: githubRepositorySlugSchema.describe(
502
+ 'The Scoop bucket repository in "<owner>/<repo>" form that receives the manifest.'
503
+ ),
504
+ tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
505
+ });
506
+ var cliDistributionConfigSchema = z.strictObject({
507
+ githubApp: cliDistributionGithubAppSchema.optional().describe(
508
+ "A GitHub App used to mint short-lived tokens for every channel without its own tokenSecretName."
509
+ ),
510
+ homebrew: cliDistributionHomebrewSchema.optional().describe("Publishes a Homebrew formula to a tap repository on each tagged release."),
511
+ scoop: cliDistributionScoopSchema.optional().describe("Publishes a Scoop manifest to a bucket repository on each tagged release.")
512
+ }).superRefine((distribution, context) => {
513
+ if (distribution.homebrew !== void 0 || distribution.scoop !== void 0) {
514
+ return;
515
+ }
516
+ if (distribution.githubApp !== void 0) {
517
+ context.addIssue({
518
+ code: "custom",
519
+ message: "githubApp requires at least one distribution channel: homebrew or scoop",
520
+ path: ["githubApp"]
521
+ });
522
+ return;
523
+ }
524
+ context.addIssue({
525
+ code: "custom",
526
+ message: "distribution must configure at least one channel: homebrew or scoop"
527
+ });
528
+ });
529
+ var CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE = 'distribution requires output.delivery "github": Homebrew and Scoop publish from a tagged GitHub Release produced by the generated release workflow. Set delivery to "github" or remove distribution.';
530
+ var CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE = 'package publication for target language "cli" requires output.delivery "github": the CLI generator publishes npm packages only from its generated GitHub workflow.';
531
+ var CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = "CLI_DISTRIBUTION_NON_RELEASE_MODE";
532
+ var nonReleaseGithubModes = /* @__PURE__ */ new Set(["pull-request", "push", "commit"]);
533
+ function cliDistributionModeDiagnostic(output, outputPath) {
534
+ const mode = output?.github?.mode;
535
+ if (output?.distribution === void 0 || mode === void 0 || !nonReleaseGithubModes.has(mode)) {
536
+ return void 0;
537
+ }
538
+ return {
539
+ code: CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE,
540
+ severity: "warning",
541
+ path: [...outputPath, "github", "mode"],
542
+ reason: `GitHub mode "${mode}" does not create a release tag, so Homebrew and Scoop publish only after a semantic-version tag is pushed to the repository.`,
543
+ suggestedAction: 'Use mode "release" or "commit-and-release", or push a version tag after merging generated changes.'
544
+ };
545
+ }
546
+
547
+ // src/sdk-config/v1/diagnostics.ts
548
+ function getSdkConfigV1Diagnostics(config) {
549
+ return config.targets.flatMap((target, targetIndex) => {
550
+ if (target.language !== "cli") {
551
+ return [];
552
+ }
553
+ const diagnostic = cliDistributionModeDiagnostic(target.output, [
554
+ "targets",
555
+ targetIndex,
556
+ "output"
557
+ ]);
558
+ return diagnostic ? [diagnostic] : [];
559
+ });
560
+ }
452
561
  var httpMethodSchema = z.enum([
453
562
  "GET",
454
563
  "POST",
@@ -653,6 +762,17 @@ function stringValue(value) {
653
762
  function stringArrayValue(value) {
654
763
  return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0) ? value : void 0;
655
764
  }
765
+ var canonicalLicenseTypes = {
766
+ mit: "MIT",
767
+ apache: "APACHE",
768
+ "apache-2.0": "APACHE",
769
+ "gpl-3.0": "GPL3",
770
+ "gpl-3.0-only": "GPL3",
771
+ unlicensed: "UNLICENSED"
772
+ };
773
+ function canonicalLicenseType(value) {
774
+ return canonicalLicenseTypes[value.trim().toLowerCase()];
775
+ }
656
776
  function stableJson(value) {
657
777
  return JSON.stringify(sortKeys(value));
658
778
  }
@@ -663,6 +783,280 @@ function sortKeys(value) {
663
783
  Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortKeys(child)])
664
784
  );
665
785
  }
786
+ var ALPHANUMERIC_PATTERN = /[A-Za-z0-9]/;
787
+ var ROOT_GROUP_PATTERN = /^[a-z][a-z0-9_-]*$/;
788
+ var KEBAB_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
789
+ var DOTTED_COMMAND_PATH_PATTERN = /^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/;
790
+ var FIELD_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
791
+ var RESERVED_USER_AGENT_SUFFIX_FLAGS = /* @__PURE__ */ new Set([
792
+ "params",
793
+ "output",
794
+ "json",
795
+ "format",
796
+ "dry-run",
797
+ "base-url",
798
+ "page-all",
799
+ "page-limit",
800
+ "page-delay",
801
+ "no-pager",
802
+ "no-extract",
803
+ "no-retry",
804
+ "no-stream",
805
+ "quiet",
806
+ "query",
807
+ "help",
808
+ "debug",
809
+ "schema"
810
+ ]);
811
+ var RESERVED_PROFILES_COMMAND_NAMES = /* @__PURE__ */ new Set([
812
+ "auth",
813
+ "completion",
814
+ "man",
815
+ "errors",
816
+ "generate-skills",
817
+ "help"
818
+ ]);
819
+ var binaryNameSchema = nonEmptyStringSchema.regex(ALPHANUMERIC_PATTERN, {
820
+ message: "binaryName must contain at least one ASCII letter or digit"
821
+ });
822
+ var rootGroupSchema = z.string().regex(ROOT_GROUP_PATTERN, {
823
+ message: "rootGroup must start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores"
824
+ });
825
+ var userAgentSuffixFlagSchema = z.string().superRefine((value, context) => {
826
+ if (value.startsWith("-")) {
827
+ context.addIssue({
828
+ code: "custom",
829
+ message: 'userAgentSuffixFlag must be the long flag name without the leading "--"'
830
+ });
831
+ } else if (!KEBAB_NAME_PATTERN.test(value)) {
832
+ context.addIssue({
833
+ code: "custom",
834
+ message: "userAgentSuffixFlag must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
835
+ });
836
+ } else if (RESERVED_USER_AGENT_SUFFIX_FLAGS.has(value)) {
837
+ context.addIssue({
838
+ code: "custom",
839
+ message: `userAgentSuffixFlag "${value}" collides with a built-in global flag`
840
+ });
841
+ }
842
+ });
843
+ var profilesCommandNameSchema = z.string().superRefine((value, context) => {
844
+ if (!KEBAB_NAME_PATTERN.test(value)) {
845
+ context.addIssue({
846
+ code: "custom",
847
+ message: "profiles.commandName must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
848
+ });
849
+ } else if (RESERVED_PROFILES_COMMAND_NAMES.has(value)) {
850
+ context.addIssue({
851
+ code: "custom",
852
+ message: `profiles.commandName "${value}" collides with a built-in command group`
853
+ });
854
+ }
855
+ });
856
+ function dottedCommandPathSchema(field) {
857
+ return z.string().regex(DOTTED_COMMAND_PATH_PATTERN, {
858
+ message: `${field} must be a dotted command path such as "iam.keys.create"`
859
+ });
860
+ }
861
+ function fieldNameMapSchema(field) {
862
+ const message = `${field} keys and values must be field names containing only [A-Za-z0-9_.-]`;
863
+ return z.record(z.string(), z.string().regex(FIELD_NAME_PATTERN, { message })).superRefine((value, context) => {
864
+ for (const key of Object.keys(value)) {
865
+ if (!FIELD_NAME_PATTERN.test(key)) {
866
+ context.addIssue({ code: "custom", message, path: [key] });
867
+ }
868
+ }
869
+ });
870
+ }
871
+ var profilesProvisionOperationSchema = z.strictObject({
872
+ operation: dottedCommandPathSchema("profiles.provisionOperation.operation").describe(
873
+ "The dotted command path of the operation that mints a profile credential."
874
+ ),
875
+ credential: fieldNameMapSchema("profiles.provisionOperation.credential").refine((value) => Object.keys(value).length > 0, {
876
+ message: "profiles.provisionOperation.credential must map at least one credential field"
877
+ }).describe("Maps each stored credential field to the response field that supplies it."),
878
+ revokeParameters: fieldNameMapSchema("profiles.provisionOperation.revokeParameters").optional().describe("Maps each revoke-operation parameter to the response field that supplies it.")
879
+ });
880
+ var profilesConfigSchema = z.strictObject({
881
+ enabled: z.boolean().describe("Whether the CLI emits profile commands and the global --profile flag."),
882
+ commandName: profilesCommandNameSchema.optional().describe('The profile command group name. The generator defaults to "profiles".'),
883
+ revokeOperation: dottedCommandPathSchema("profiles.revokeOperation").optional().describe('The dotted command path called by "profiles remove --revoke".'),
884
+ provisionOperation: profilesProvisionOperationSchema.optional().describe('The operation called by "profiles create --provision" and its response mapping.')
885
+ });
886
+ var cliGenerationConfigSchema = z.strictObject({
887
+ paginationParameters: z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
888
+ skills: z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands."),
889
+ binaryName: binaryNameSchema.optional().describe(
890
+ "The CLI executable name. The generator kebab-cases it and also uses it for the source directory and env-var prefix."
891
+ ),
892
+ customCommands: z.boolean().optional().describe("Whether hand-written command support is generated. The generator defaults to true."),
893
+ rootGroup: rootGroupSchema.optional().describe("A command group that every spec-derived command is nested under."),
894
+ profiles: profilesConfigSchema.optional().describe("Named profile command configuration."),
895
+ splitTypeCrates: z.boolean().optional().describe("Whether generated types are split into one crate per API behind a facade crate."),
896
+ userAgentSuffixFlag: userAgentSuffixFlagSchema.optional().describe('The long flag name, without "--", that appends a product token to the User-Agent.')
897
+ });
898
+
899
+ // src/sdk-config/v1/fern-config-mapper-cli.ts
900
+ var CLI_GENERATION_FIELDS = [
901
+ "binaryName",
902
+ "customCommands",
903
+ "rootGroup",
904
+ "profiles",
905
+ "splitTypeCrates",
906
+ "userAgentSuffixFlag"
907
+ ];
908
+ var PROFILES_FIELDS = ["enabled", "commandName", "revokeOperation"];
909
+ var PROVISION_OPERATION_FIELDS = ["operation", "credential", "revokeParameters"];
910
+ function mapCliGeneration(config, state, basePath, targetIndex) {
911
+ const generation = {};
912
+ for (const field of CLI_GENERATION_FIELDS) {
913
+ const raw = ownValue(config, field);
914
+ if (raw === void 0) continue;
915
+ const fieldPath = [...basePath, field];
916
+ const { value, consumedPaths } = field === "profiles" && isObject(raw) ? pickProfiles(raw, fieldPath) : { value: raw, consumedPaths: [fieldPath] };
917
+ const parsed = cliGenerationConfigSchema.shape[field].safeParse(value);
918
+ consumedPaths.forEach((path) => consume(state, path));
919
+ if (parsed.success) {
920
+ generation[field] = structuredClone(value);
921
+ continue;
922
+ }
923
+ const diagnostics = parsed.error.issues.map(
924
+ (issue) => invalidValueDiagnostic(field, fieldPath, issue.path, issue.message, targetIndex)
925
+ );
926
+ (state.valueDiagnostics ??= []).push(...diagnostics);
927
+ }
928
+ return generation;
929
+ }
930
+ function pickProfiles(profiles, path) {
931
+ const picked = pickKnown(profiles, PROFILES_FIELDS, path);
932
+ const provisionOperation = ownValue(profiles, "provisionOperation");
933
+ const provisionPath = [...path, "provisionOperation"];
934
+ if (isObject(provisionOperation)) {
935
+ const provision = pickKnown(provisionOperation, PROVISION_OPERATION_FIELDS, provisionPath);
936
+ picked.value.provisionOperation = provision.value;
937
+ picked.consumedPaths.push(...provision.consumedPaths);
938
+ } else if (provisionOperation !== void 0) {
939
+ picked.value.provisionOperation = provisionOperation;
940
+ picked.consumedPaths.push(provisionPath);
941
+ }
942
+ return { value: { enabled: false, ...picked.value }, consumedPaths: picked.consumedPaths };
943
+ }
944
+ function pickKnown(value, fields, path) {
945
+ const picked = {};
946
+ const consumedPaths = [];
947
+ for (const field of fields) {
948
+ const child = ownValue(value, field);
949
+ if (child === void 0) continue;
950
+ picked[field] = child;
951
+ consumedPaths.push([...path, field]);
952
+ }
953
+ return { value: picked, consumedPaths };
954
+ }
955
+ function ownValue(value, key) {
956
+ return Object.hasOwn(value, key) ? value[key] : void 0;
957
+ }
958
+ function invalidValueDiagnostic(field, fieldPath, issuePath, message, targetIndex) {
959
+ const relative = issuePath.map((part) => typeof part === "symbol" ? String(part) : part);
960
+ const sdkConfigField = ["targets", targetIndex, "generation", field];
961
+ return {
962
+ code: "FERN_CONFIG_VALUE_INVALID",
963
+ severity: "warning",
964
+ path: [...fieldPath, ...relative],
965
+ reason: `CLI setting ${field} was not migrated because SDK Config rejects it: ${message}`,
966
+ sdkConfigPath: [...sdkConfigField, ...relative],
967
+ suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
968
+ };
969
+ }
970
+
971
+ // src/sdk-config/v1/fern-config-mapper-cli-distribution.ts
972
+ var DISTRIBUTION_KEYS = {
973
+ githubApp: { appIdSecret: "appIdSecretName", privateKeySecret: "privateKeySecretName" },
974
+ homebrew: { tap: "tap", formula: "formula", tokenEnvironmentVariable: "tokenSecretName" },
975
+ scoop: { bucket: "bucket", tokenEnvironmentVariable: "tokenSecretName" }
976
+ };
977
+ function mapCliDistribution(config, state, basePath, targetIndex) {
978
+ if (!Object.hasOwn(config, "distribution")) return;
979
+ const raw = config.distribution;
980
+ const path = [...basePath, "distribution"];
981
+ const translated = isObject(raw) ? translateDistribution(raw, path) : { value: raw, consumedPaths: [path], legacyKeys: /* @__PURE__ */ new Map() };
982
+ const parsed = cliDistributionConfigSchema.safeParse(translated.value);
983
+ translated.consumedPaths.forEach((consumedPath) => consume(state, consumedPath));
984
+ if (parsed.success) {
985
+ state.cliDistribution = { value: parsed.data, path };
986
+ return;
987
+ }
988
+ const diagnostics = parsed.error.issues.map(
989
+ (issue) => invalidDistributionDiagnostic(issue, path, translated.legacyKeys, targetIndex)
990
+ );
991
+ const reportedPaths = /* @__PURE__ */ new Set();
992
+ (state.valueDiagnostics ??= []).push(
993
+ ...diagnostics.filter(({ path: diagnosticPath }) => {
994
+ const key = diagnosticPath.join(".");
995
+ if (reportedPaths.has(key)) return false;
996
+ reportedPaths.add(key);
997
+ return true;
998
+ })
999
+ );
1000
+ }
1001
+ function translateDistribution(distribution, path) {
1002
+ const value = {};
1003
+ const consumedPaths = [];
1004
+ const legacyKeys = /* @__PURE__ */ new Map();
1005
+ for (const [block, keys] of Object.entries(DISTRIBUTION_KEYS)) {
1006
+ if (!Object.hasOwn(distribution, block)) continue;
1007
+ const blockValue = distribution[block];
1008
+ const blockPath = [...path, block];
1009
+ if (!isObject(blockValue)) {
1010
+ value[block] = blockValue;
1011
+ consumedPaths.push(blockPath);
1012
+ continue;
1013
+ }
1014
+ const translatedBlock = {};
1015
+ for (const [legacyKey, sdkConfigKey] of Object.entries(keys)) {
1016
+ if (!Object.hasOwn(blockValue, legacyKey)) continue;
1017
+ translatedBlock[sdkConfigKey] = blockValue[legacyKey];
1018
+ consumedPaths.push([...blockPath, legacyKey]);
1019
+ legacyKeys.set(`${block}.${sdkConfigKey}`, legacyKey);
1020
+ }
1021
+ value[block] = translatedBlock;
1022
+ }
1023
+ return { value, consumedPaths, legacyKeys };
1024
+ }
1025
+ function invalidDistributionDiagnostic(issue, path, legacyKeys, targetIndex) {
1026
+ const relative = issue.path.map((part) => typeof part === "symbol" ? String(part) : part);
1027
+ const [block, field] = relative;
1028
+ const legacyField = typeof block === "string" && typeof field === "string" ? legacyKeys.get(`${block}.${field}`) : void 0;
1029
+ const legacyRelative = typeof block === "string" && legacyField !== void 0 ? [block, legacyField] : relative;
1030
+ const sdkConfigField = ["targets", targetIndex, "output", "distribution"];
1031
+ return {
1032
+ code: "FERN_CONFIG_VALUE_INVALID",
1033
+ severity: "warning",
1034
+ path: [...path, ...legacyRelative],
1035
+ reason: `CLI distribution was not migrated because SDK Config rejects it: ${issue.message}`,
1036
+ sdkConfigPath: [...sdkConfigField, ...relative],
1037
+ suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
1038
+ };
1039
+ }
1040
+ function applyCliDistribution(output, pending, targetIndex) {
1041
+ if (pending === void 0) return { output, diagnostics: [] };
1042
+ if (output.delivery === "github") {
1043
+ return { output: { ...output, distribution: pending.value }, diagnostics: [] };
1044
+ }
1045
+ const outputPath = ["targets", targetIndex, "output"];
1046
+ return {
1047
+ output,
1048
+ diagnostics: [
1049
+ {
1050
+ code: "FERN_CLI_DISTRIBUTION_REQUIRES_GITHUB_OUTPUT",
1051
+ severity: "warning",
1052
+ path: pending.path,
1053
+ reason: `The CLI generator ignores distribution for "${output.delivery}" output, and SDK Config accepts distribution only with output.delivery "github", so it was not migrated`,
1054
+ sdkConfigPath: [...outputPath, "distribution"],
1055
+ suggestedAction: `Set ${outputPath.join(".")}.delivery to "github" for the CLI repository and add ${outputPath.join(".")}.distribution manually, or remove distribution.`
1056
+ }
1057
+ ]
1058
+ };
1059
+ }
666
1060
 
667
1061
  // src/sdk-config/v1/fern-config-mapper-output.ts
668
1062
  function mapOutput(generator, language, index) {
@@ -846,6 +1240,7 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
846
1240
  const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
847
1241
  if (type) consume(state, [...sourcePath, "type"]);
848
1242
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
1243
+ if (value.workflows === true) consume(state, [...sourcePath, "workflows"]);
849
1244
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
850
1245
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
851
1246
  consumeCredentialObject(value.credentials, [...sourcePath, "credentials"], state);
@@ -873,11 +1268,10 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
873
1268
  ...optionalObject("package", { ...publication?.package, ...licensePackage })
874
1269
  };
875
1270
  }
876
- var basicLicenseTypes = { mit: "MIT", apache: "APACHE" };
877
1271
  function mapGithubLicense(value, sourcePath, state) {
878
1272
  if (!isObject(value) || stringValue(value.type) !== "basic") return {};
879
1273
  const id = stringValue(value.id);
880
- const type = id ? basicLicenseTypes[id.toLowerCase()] : void 0;
1274
+ const type = id ? canonicalLicenseType(id) : void 0;
881
1275
  if (!type) return {};
882
1276
  consume(state, [...sourcePath, "type"]);
883
1277
  consume(state, [...sourcePath, "id"]);
@@ -1444,6 +1838,114 @@ function outputDiagnostic(path, index) {
1444
1838
  suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
1445
1839
  };
1446
1840
  }
1841
+
1842
+ // src/sdk-config/v1/package.ts
1843
+ var sdkConfigV1DependencySchema = dependencySchema;
1844
+ var sdkConfigV1PackageConfigSchema = packageConfigSchema;
1845
+
1846
+ // src/sdk-config/v1/fern-config-mapper-package.ts
1847
+ var emailSchema = z.email();
1848
+ function mapCliPackageIdentity(identity, state, targetIndex) {
1849
+ mapIdentityField(identity, "homepage", stringValue, state);
1850
+ mapIdentityField(identity, "keywords", (value) => stringArrayValue(value)?.slice(), state);
1851
+ mapCargoAuthors(identity, state, targetIndex);
1852
+ mapIdentityField(identity, "license", licenseValue, state);
1853
+ }
1854
+ function mapIdentityField(identity, field, read, state) {
1855
+ const located = locate(identity.value, [field], identity.path);
1856
+ const value = located && read(located.value);
1857
+ if (located && value !== void 0) addPackageFallback(state, field, value, located.path);
1858
+ }
1859
+ function mapLicenseFallback(config, aliases, state, basePath) {
1860
+ const located = locate(config, aliases, basePath);
1861
+ const license = located && licenseValue(located.value);
1862
+ if (located && license) addPackageFallback(state, "license", license, located.path);
1863
+ }
1864
+ function resolveTargetPackage(targetPackage, fallbacks, generator, delivery, index) {
1865
+ const diagnostics = [];
1866
+ for (const fallback of fallbacks) {
1867
+ applyFallback(targetPackage, fallback, index, diagnostics);
1868
+ }
1869
+ if (delivery !== "github") {
1870
+ applyMetadataLicense(targetPackage, generator.raw, index, diagnostics);
1871
+ }
1872
+ return diagnostics;
1873
+ }
1874
+ function applyFallback(targetPackage, { field, value, path }, index, diagnostics) {
1875
+ const existing = targetPackage[field];
1876
+ if (existing === void 0) {
1877
+ targetPackage[field] = value;
1878
+ } else if (stableJson(existing) !== stableJson(value)) {
1879
+ diagnostics.push({
1880
+ code: "FERN_PACKAGE_VALUE_CONFLICT",
1881
+ severity: "warning",
1882
+ path,
1883
+ reason: `Fern value conflicts with the package.${field} already migrated for this target, which is kept`,
1884
+ sdkConfigPath: ["targets", index, "package", field],
1885
+ suggestedAction: `Choose the intended value and set targets.${index}.package.${field} manually.`
1886
+ });
1887
+ }
1888
+ }
1889
+ function applyMetadataLicense(targetPackage, raw, index, diagnostics) {
1890
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
1891
+ if (metadata?.license === void 0 || metadata.license === null) return;
1892
+ const path = ["group", "generators", index, "metadata", "license"];
1893
+ const license = licenseValue(metadata.license);
1894
+ if (license) {
1895
+ applyFallback(targetPackage, { field: "license", value: license, path }, index, diagnostics);
1896
+ return;
1897
+ }
1898
+ diagnostics.push({
1899
+ code: "FERN_CONFIG_FIELD_UNSUPPORTED",
1900
+ severity: "warning",
1901
+ path,
1902
+ reason: isObject(metadata.license) ? "A custom license file cannot be migrated automatically" : "metadata.license is not a license identifier",
1903
+ sdkConfigPath: ["targets", index, "package", "license"],
1904
+ suggestedAction: `Set targets.${index}.package.license manually.`
1905
+ });
1906
+ }
1907
+ function mapCargoAuthors(identity, state, targetIndex) {
1908
+ const located = locate(identity.value, ["authors"], identity.path);
1909
+ const entries = located && stringArrayValue(located.value);
1910
+ if (!located || !entries) return;
1911
+ consume(state, located.path);
1912
+ const authors = entries.map(parseCargoAuthor);
1913
+ const parsed = sdkConfigV1PackageConfigSchema.shape.authors.safeParse(authors);
1914
+ const invalid = parsed.success ? [] : [...new Set(parsed.error.issues.map((issue) => issue.path[0]))].filter(
1915
+ (index) => typeof index === "number"
1916
+ );
1917
+ if (invalid.length === 0) {
1918
+ addPackageFallback(state, "authors", authors, located.path);
1919
+ return;
1920
+ }
1921
+ const authorsPath = ["targets", targetIndex, "package", "authors"];
1922
+ (state.valueDiagnostics ??= []).push(
1923
+ ...invalid.map((entry) => ({
1924
+ code: "FERN_CONFIG_VALUE_INVALID",
1925
+ severity: "warning",
1926
+ path: [...located.path, entry],
1927
+ reason: 'CLI packageIdentity.authors was not migrated because this entry is not "Name" or "Name <email>" with a valid email',
1928
+ sdkConfigPath: authorsPath,
1929
+ suggestedAction: `Correct the entry, then set ${authorsPath.join(".")} manually.`
1930
+ }))
1931
+ );
1932
+ }
1933
+ function parseCargoAuthor(entry) {
1934
+ const trimmed = entry.trim();
1935
+ const match = /^(.*?)\s*<([^<>]*)>$/.exec(trimmed);
1936
+ if (!match) return { name: trimmed };
1937
+ const [, name = "", email = ""] = match;
1938
+ if (name !== "" && !emailSchema.safeParse(email).success) return { name: trimmed };
1939
+ return { name, email };
1940
+ }
1941
+ function licenseValue(value) {
1942
+ const license = stringValue(value)?.trim();
1943
+ return license ? { type: canonicalLicenseType(license) ?? license } : void 0;
1944
+ }
1945
+ function addPackageFallback(state, field, value, path) {
1946
+ consume(state, path);
1947
+ (state.packageFallbacks ??= []).push({ field, value, path });
1948
+ }
1447
1949
  var OMIT = /* @__PURE__ */ Symbol("omit");
1448
1950
  function inputJsonSchema(schema) {
1449
1951
  return z.toJSONSchema(schema, {
@@ -1713,7 +2215,16 @@ var sdkConfigV1PublishConfigSchema = z.discriminatedUnion("registry", [
1713
2215
  z.strictObject({
1714
2216
  registry: z.literal("npm").describe("Publishes the package to an npm-compatible registry."),
1715
2217
  token: nonEmptyStringSchema.optional().describe("The npm registry token, or an environment expression that resolves to it."),
2218
+ trustedPublishing: z.boolean().optional().describe("Whether npm publication uses trusted publishing (OIDC) instead of a token."),
1716
2219
  ...commonPublishShape
2220
+ }).superRefine((publish, context) => {
2221
+ if (publish.trustedPublishing === true && publish.token !== void 0) {
2222
+ context.addIssue({
2223
+ code: "custom",
2224
+ message: "token must be omitted when trustedPublishing is true",
2225
+ path: ["token"]
2226
+ });
2227
+ }
1717
2228
  }),
1718
2229
  z.strictObject({
1719
2230
  registry: z.literal("pypi").describe("Publishes the package to a PyPI-compatible registry."),
@@ -1791,10 +2302,29 @@ var sdkConfigV1OutputConfigSchema = z.discriminatedUnion(
1791
2302
  [filesOutputSchema, zipOutputSchema, githubDeliverySchema],
1792
2303
  { error: 'output.delivery must be one of "files", "zip", or "github"' }
1793
2304
  );
1794
-
1795
- // src/sdk-config/v1/package.ts
1796
- var sdkConfigV1DependencySchema = dependencySchema;
1797
- var sdkConfigV1PackageConfigSchema = packageConfigSchema;
2305
+ var cliDistributionShape = {
2306
+ distribution: cliDistributionConfigSchema.optional().describe(
2307
+ "CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
2308
+ )
2309
+ };
2310
+ function rejectDistributionWithoutGithub(output, context) {
2311
+ if (output.distribution !== void 0) {
2312
+ context.addIssue({
2313
+ code: "custom",
2314
+ message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
2315
+ path: ["distribution"]
2316
+ });
2317
+ }
2318
+ }
2319
+ var sdkConfigV1CliOutputConfigSchema = z.discriminatedUnion(
2320
+ "delivery",
2321
+ [
2322
+ filesOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2323
+ zipOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2324
+ githubDeliverySchema.extend(cliDistributionShape)
2325
+ ],
2326
+ { error: 'output.delivery must be one of "files", "zip", or "github"' }
2327
+ );
1798
2328
  var sdkConfigV1ReplayConfigSchema = z.strictObject({
1799
2329
  enabled: z.boolean().describe("Whether regeneration reapplies customer-authored repository changes.")
1800
2330
  });
@@ -1871,10 +2401,6 @@ var sdkConfigV1SourceConfigSchema = z.strictObject({
1871
2401
  seenIds.add(id);
1872
2402
  });
1873
2403
  });
1874
- var cliGenerationConfigSchema = z.strictObject({
1875
- paginationParameters: z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
1876
- skills: z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands.")
1877
- });
1878
2404
  var csharpGenerationConfigSchema = z.strictObject({
1879
2405
  useOptionalWrapper: z.boolean().optional().describe("Whether optional values use an explicit Optional wrapper."),
1880
2406
  simplifyObjectDictionaries: z.boolean().optional().describe("Whether object schemas with arbitrary values use simplified dictionary types."),
@@ -1922,7 +2448,7 @@ var packageScriptSchema = z.strictObject({
1922
2448
  command: nonEmptyStringSchema.describe("The command executed by the package script.")
1923
2449
  });
1924
2450
  var httpClientSchema = z.strictObject({
1925
- name: z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
2451
+ name: z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
1926
2452
  });
1927
2453
  var typescriptGenerationConfigSchema = z.strictObject({
1928
2454
  typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
@@ -1938,6 +2464,37 @@ var typescriptGenerationConfigSchema = z.strictObject({
1938
2464
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
1939
2465
  namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
1940
2466
  consolidateTypeFiles: z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
2467
+ formDataSupport: z.enum(["Node16", "Node18"]).optional().describe(
2468
+ "The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
2469
+ ),
2470
+ allowExtraFields: z.boolean().optional().describe(
2471
+ "Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
2472
+ ),
2473
+ generateSubpackageExports: z.boolean().optional().describe(
2474
+ "Whether the package manifest exports each subpackage client as its own entry point."
2475
+ ),
2476
+ exportAllRequestsAtRoot: z.boolean().optional().describe("Whether every request type is also exported from the package root."),
2477
+ generateEndpointMetadata: z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
2478
+ outputEsm: z.boolean().optional().describe(
2479
+ "Whether the package is marked as an ES module while still shipping its CommonJS build."
2480
+ ),
2481
+ neverThrowErrors: z.boolean().optional().describe(
2482
+ "Whether client methods return a wrapped response instead of throwing on a non-2xx status."
2483
+ ),
2484
+ includeOtherInUnionTypes: z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
2485
+ includeUtilsOnUnionMembers: z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
2486
+ omitFernHeaders: z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
2487
+ linter: z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
2488
+ formatter: z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
2489
+ exports: jsonObjectSchema.optional().describe(
2490
+ "package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
2491
+ ),
2492
+ files: z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
2493
+ engines: z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
2494
+ lintStaged: z.record(nonEmptyStringSchema, z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
2495
+ browser: z.record(nonEmptyStringSchema, z.union([z.boolean(), nonEmptyStringSchema])).optional().describe(
2496
+ "package.json browser field: a module or file is excluded (false) or replaced by another path."
2497
+ ),
1941
2498
  allowCustomFetcher: z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
1942
2499
  useBrandedStringAliases: z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
1943
2500
  useLegacyExports: z.boolean().optional().describe("Whether the package emits the legacy export layout."),
@@ -2127,7 +2684,10 @@ var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
2127
2684
  z.strictObject({
2128
2685
  language: z.literal("cli").describe("Generates a command-line interface."),
2129
2686
  generation: sdkConfigV1GenerationConfigOverrideSchema.extend(cliGenerationConfigSchema.shape).optional().describe("Common and CLI-specific generation settings for this target."),
2130
- ...targetOverrideShape
2687
+ ...targetOverrideShape,
2688
+ output: sdkConfigV1CliOutputConfigSchema.optional().describe(
2689
+ "Output configuration, including optional CLI distribution channels, that replaces the root output for this target."
2690
+ )
2131
2691
  }),
2132
2692
  z.strictObject({
2133
2693
  language: z.literal("mcp").describe("Generates an MCP server."),
@@ -2144,7 +2704,7 @@ var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
2144
2704
  // src/sdk-config/v1/sdk-config-v1.ts
2145
2705
  var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
2146
2706
  var publishRegistryLanguages = {
2147
- npm: ["typescript", "mcp"],
2707
+ npm: ["typescript", "mcp", "cli"],
2148
2708
  pypi: ["python"],
2149
2709
  maven: ["java", "kotlin"],
2150
2710
  nuget: ["csharp"],
@@ -2221,6 +2781,13 @@ function validateTargetPublishing(target, targetIndex, globalPackage, globalOutp
2221
2781
  });
2222
2782
  return;
2223
2783
  }
2784
+ if (target.language === "cli" && output.delivery !== "github") {
2785
+ context.addIssue({
2786
+ code: "custom",
2787
+ message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
2788
+ path: target.output ? ["targets", targetIndex, "output", "delivery"] : ["output", "delivery"]
2789
+ });
2790
+ }
2224
2791
  validatePublishingIdentity(
2225
2792
  { ...globalPackage, ...target.package },
2226
2793
  registry,
@@ -2333,16 +2900,33 @@ function mapFernConfigToSdkConfigV1(input) {
2333
2900
  package: outputPackage,
2334
2901
  generation: outputGeneration
2335
2902
  }, index) => {
2903
+ const distribution = applyCliDistribution(output, invocation.cliDistribution, index);
2904
+ invocation.unsupportedFields.push(...distribution.diagnostics);
2336
2905
  const target = {
2337
2906
  language,
2338
- output,
2907
+ output: distribution.output,
2339
2908
  ...optional("sdkName", generator.sdkName),
2340
2909
  ...optional("sdkVersion", generator.sdkVersion),
2341
2910
  ...optional("client", clients.targetOverrides[index]),
2342
2911
  ...optional("docs", docs.targetOverrides[index])
2343
2912
  };
2344
- if (Object.keys(invocation.package).length > 0 || outputPackage || generator.package) {
2345
- target.package = { ...invocation.package, ...outputPackage, ...generator.package };
2913
+ const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2914
+ invocation.unsupportedFields.push(
2915
+ ...resolveTargetPackage(
2916
+ mappedPackage,
2917
+ invocation.packageFallbacks,
2918
+ generator,
2919
+ output.delivery,
2920
+ index
2921
+ )
2922
+ );
2923
+ const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
2924
+ language,
2925
+ output,
2926
+ generator
2927
+ });
2928
+ if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
2929
+ target.package = targetPackage;
2346
2930
  }
2347
2931
  const targetGeneration = {
2348
2932
  ...generations.targetOverrides[index],
@@ -2409,6 +2993,21 @@ function mapFernConfigToSdkConfigV1(input) {
2409
2993
  ])
2410
2994
  };
2411
2995
  }
2996
+ function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
2997
+ if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
2998
+ return packageConfig;
2999
+ }
3000
+ const { packageName } = packageConfig;
3001
+ return {
3002
+ ...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
3003
+ ...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
3004
+ ...packageConfig
3005
+ };
3006
+ }
3007
+ function usesCustomLicenseFile({ config, raw }) {
3008
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
3009
+ return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
3010
+ }
2412
3011
  function resolveLanguage(generator, index) {
2413
3012
  const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
2414
3013
  if (!language || !isFernLanguage(language)) {
@@ -2524,10 +3123,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
2524
3123
  ...optional("smartCasingDigitWordBoundary", smartCasingDigitWordBoundary)
2525
3124
  };
2526
3125
  }
2527
- const targetGeneration = mapLanguageConfig(language, config, state, packageConfig, [
2528
- ...prefix,
2529
- "config"
2530
- ]);
3126
+ const targetGeneration = mapLanguageConfig(
3127
+ language,
3128
+ config,
3129
+ state,
3130
+ packageConfig,
3131
+ [...prefix, "config"],
3132
+ index
3133
+ );
2531
3134
  mapPublishMetadata(generator.publishMetadata, packageConfig);
2532
3135
  if (generator.keywords?.length) {
2533
3136
  generation.reservedKeywords = [...generator.keywords];
@@ -2543,13 +3146,30 @@ function mapInvocation(generator, language, activeLanguages, index) {
2543
3146
  }
2544
3147
  }
2545
3148
  const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
3149
+ if (language === "typescript") {
3150
+ const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
3151
+ ...prefix,
3152
+ "config"
3153
+ ]);
3154
+ if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
3155
+ }
2546
3156
  const unsupportedFields = [
3157
+ ...state.valueDiagnostics ?? [],
2547
3158
  ...collectUnsupported(config, [...prefix, "config"], state),
2548
3159
  ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
2549
3160
  ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
2550
3161
  ...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
2551
3162
  ];
2552
- return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
3163
+ return {
3164
+ client,
3165
+ docs,
3166
+ generation,
3167
+ package: packageConfig,
3168
+ packageFallbacks: state.packageFallbacks ?? [],
3169
+ ...optional("cliDistribution", state.cliDistribution),
3170
+ targetGeneration,
3171
+ unsupportedFields
3172
+ };
2553
3173
  }
2554
3174
  function unsupportedResolvedFields(generator, index, idempotencyMapped) {
2555
3175
  const values = [
@@ -2713,7 +3333,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2713
3333
  });
2714
3334
  if (Object.keys(naming).length) generation.naming = naming;
2715
3335
  const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
2716
- if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
3336
+ const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
3337
+ if (wireTests !== void 0 || wireTestsFallback !== void 0) {
3338
+ generation.wireTests = { enabled: wireTests ?? true };
3339
+ if (wireTestsFallback !== void 0) {
3340
+ generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
3341
+ }
3342
+ }
2717
3343
  const webSockets = takeBoolean(
2718
3344
  config,
2719
3345
  ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
@@ -2739,6 +3365,7 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2739
3365
  const packagePath = takeString(config, ["packagePath"], state, basePath);
2740
3366
  if (packagePath !== void 0) generation.layout = { packagePath };
2741
3367
  mapDependencies(config, state, packageConfig, basePath);
3368
+ mapPeerDependenciesMeta(config, state, packageConfig, basePath);
2742
3369
  }
2743
3370
  function mapTypescriptStreams(config, state, basePath) {
2744
3371
  const responseType = takeEnum(config, ["streamType"], ["wrapper", "web"], state, basePath);
@@ -2752,13 +3379,13 @@ function mapTypescriptStreams(config, state, basePath) {
2752
3379
  if (responseType === void 0 && fileResponseType === void 0) return void 0;
2753
3380
  return { enabled: true, ...compact({ responseType, fileResponseType }) };
2754
3381
  }
2755
- function mapLanguageConfig(language, config, state, packageConfig, basePath) {
3382
+ function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
2756
3383
  switch (language) {
2757
3384
  case "typescript":
2758
- return mapTypescript(config, state, packageConfig, basePath);
3385
+ return mapTypescript(config, state, packageConfig, basePath, true);
2759
3386
  case "mcp":
2760
3387
  return {
2761
- ...mapTypescript(config, state, packageConfig, basePath),
3388
+ ...mapTypescript(config, state, packageConfig, basePath, false),
2762
3389
  ...mapMcp(config, state, basePath)
2763
3390
  };
2764
3391
  case "python":
@@ -2779,12 +3406,12 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath) {
2779
3406
  case "swift":
2780
3407
  return mapSwift(config, state, basePath);
2781
3408
  case "cli":
2782
- return mapCli(config, state, packageConfig, basePath);
3409
+ return mapCli(config, state, packageConfig, basePath, targetIndex);
2783
3410
  case "terraform":
2784
3411
  return mapTerraform(config, state, packageConfig, basePath);
2785
3412
  }
2786
3413
  }
2787
- function mapTypescript(config, state, packageConfig, basePath) {
3414
+ function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
2788
3415
  const packageJsonManifest = mapPackageManifest(
2789
3416
  config,
2790
3417
  ["packageJson"],
@@ -2796,18 +3423,75 @@ function mapTypescript(config, state, packageConfig, basePath) {
2796
3423
  const packageManagerAtIndex = packageJsonPackageManager ? packageJsonPackageManager.indexOf("@", packageJsonPackageManager.startsWith("@") ? 1 : 0) : -1;
2797
3424
  const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
2798
3425
  const packageManagerVersion = packageManagerVersionPart || void 0;
3426
+ if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
3427
+ const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
2799
3428
  const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
2800
3429
  const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
2801
- const fetchSupport = takeEnum(config, ["fetchSupport"], ["native"], state, basePath);
3430
+ const fetchSupport = takeEnum(
3431
+ config,
3432
+ ["fetchSupport"],
3433
+ sdkTarget ? ["native", "node-fetch"] : ["native"],
3434
+ state,
3435
+ basePath
3436
+ );
2802
3437
  const namingObject = takeObject(config, ["naming"], state, basePath);
2803
3438
  const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
3439
+ const sdkOnlyOptions = sdkTarget ? {
3440
+ formDataSupport: takeEnum(
3441
+ config,
3442
+ ["formDataSupport"],
3443
+ ["Node16", "Node18"],
3444
+ state,
3445
+ basePath
3446
+ ),
3447
+ allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
3448
+ generateSubpackageExports: takeBoolean(
3449
+ config,
3450
+ ["generateSubpackageExports"],
3451
+ state,
3452
+ basePath
3453
+ ),
3454
+ exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
3455
+ generateEndpointMetadata: takeBoolean(
3456
+ config,
3457
+ ["generateEndpointMetadata"],
3458
+ state,
3459
+ basePath
3460
+ ),
3461
+ outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
3462
+ neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
3463
+ includeOtherInUnionTypes: takeBoolean(
3464
+ config,
3465
+ ["includeOtherInUnionTypes"],
3466
+ state,
3467
+ basePath
3468
+ ),
3469
+ includeUtilsOnUnionMembers: takeBoolean(
3470
+ config,
3471
+ ["includeUtilsOnUnionMembers"],
3472
+ state,
3473
+ basePath
3474
+ ),
3475
+ omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
3476
+ linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
3477
+ formatter: takeEnum(
3478
+ config,
3479
+ ["formatter"],
3480
+ ["prettier", "biome", "oxfmt", "none"],
3481
+ state,
3482
+ basePath
3483
+ )
3484
+ } : {};
2804
3485
  return compact({
3486
+ ...sdkOnlyOptions,
3487
+ // Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
3488
+ ...manifestOptions,
2805
3489
  typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
2806
3490
  zodVersion: takeString(config, ["zodVersion"], state, basePath),
2807
3491
  packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
2808
3492
  packageManagerVersion,
2809
3493
  testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
2810
- httpClient: fetchSupport === "native" ? { name: "fetch" } : void 0,
3494
+ httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
2811
3495
  bundle: takeBoolean(config, ["bundle"], state, basePath),
2812
3496
  exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
2813
3497
  namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
@@ -2965,6 +3649,7 @@ function mapRust(config, state, packageConfig, basePath) {
2965
3649
  const description = takeString(config, ["packageDescription"], state, basePath);
2966
3650
  const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
2967
3651
  Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
3652
+ mapLicenseFallback(config, ["packageLicense"], state, basePath);
2968
3653
  return compact({
2969
3654
  dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
2970
3655
  capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
@@ -2978,7 +3663,7 @@ function mapSwift(config, state, basePath) {
2978
3663
  nullableAsOptional: takeBoolean(config, ["nullableAsOptional"], state, basePath)
2979
3664
  });
2980
3665
  }
2981
- function mapCli(config, state, packageConfig, basePath) {
3666
+ function mapCli(config, state, packageConfig, basePath, targetIndex) {
2982
3667
  const identity = takeObject(config, ["packageIdentity"], state, basePath);
2983
3668
  if (identity) {
2984
3669
  Object.assign(
@@ -2989,10 +3674,13 @@ function mapCli(config, state, packageConfig, basePath) {
2989
3674
  description: takeString(identity.value, ["description"], state, identity.path)
2990
3675
  })
2991
3676
  );
3677
+ mapCliPackageIdentity(identity, state, targetIndex);
2992
3678
  }
3679
+ mapCliDistribution(config, state, basePath, targetIndex);
2993
3680
  return compact({
2994
3681
  paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
2995
- skills: takeBoolean(config, ["skills"], state, basePath)
3682
+ skills: takeBoolean(config, ["skills"], state, basePath),
3683
+ ...mapCliGeneration(config, state, basePath, targetIndex)
2996
3684
  });
2997
3685
  }
2998
3686
  function mapTerraform(config, state, packageConfig, basePath) {
@@ -3076,6 +3764,48 @@ function mapDependencies(config, state, packageConfig, basePath) {
3076
3764
  if (dependencies.length) packageConfig[field] = dependencies;
3077
3765
  }
3078
3766
  }
3767
+ function liftPackageJsonDependencies(manifest, state, packageConfig) {
3768
+ for (const [field, target] of [
3769
+ ["dependencies", "extraDependencies"],
3770
+ ["devDependencies", "extraDevDependencies"],
3771
+ ["peerDependencies", "extraPeerDependencies"]
3772
+ ]) {
3773
+ const located = takeObject(manifest.value, [field], state, manifest.path);
3774
+ if (!located) continue;
3775
+ const lifted = Object.entries(located.value).flatMap(
3776
+ ([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
3777
+ );
3778
+ if (lifted.length) packageConfig[target] = overrideByName(packageConfig[target] ?? [], lifted);
3779
+ }
3780
+ const meta = takeObject(manifest.value, ["peerDependenciesMeta"], state, manifest.path);
3781
+ if (!meta) return;
3782
+ const entries = peerDependenciesMetaEntries(meta, state);
3783
+ if (entries.length) {
3784
+ packageConfig.extraPeerDependenciesMeta = {
3785
+ ...packageConfig.extraPeerDependenciesMeta,
3786
+ ...Object.fromEntries(entries)
3787
+ };
3788
+ }
3789
+ }
3790
+ function overrideByName(existing, overrides) {
3791
+ const byName = new Map(existing.map((dependency) => [dependency.name, dependency]));
3792
+ overrides.forEach((dependency) => byName.set(dependency.name, dependency));
3793
+ return [...byName.values()];
3794
+ }
3795
+ function mapPeerDependenciesMeta(config, state, packageConfig, basePath) {
3796
+ const located = takeObject(config, ["extraPeerDependenciesMeta"], state, basePath);
3797
+ if (!located) return;
3798
+ const entries = peerDependenciesMetaEntries(located, state);
3799
+ if (entries.length) packageConfig.extraPeerDependenciesMeta = Object.fromEntries(entries);
3800
+ }
3801
+ function peerDependenciesMetaEntries(located, state) {
3802
+ return Object.entries(located.value).flatMap(([name, value]) => {
3803
+ const parsed = jsonObjectSchema.safeParse(value);
3804
+ if (!parsed.success) return [];
3805
+ consume(state, [...located.path, name]);
3806
+ return [[name, parsed.data]];
3807
+ });
3808
+ }
3079
3809
  function mapDependency(name, value, state, path) {
3080
3810
  if (typeof value === "string" && value) {
3081
3811
  consume(state, path);
@@ -3083,13 +3813,7 @@ function mapDependency(name, value, state, path) {
3083
3813
  }
3084
3814
  if (!isObject(value)) return [];
3085
3815
  const version = takeString(value, ["version"], state, path);
3086
- const gitUrl = takeString(value, ["git"], state, path);
3087
- const localPath = takeString(value, ["path"], state, path);
3088
- const source = gitUrl ? {
3089
- type: "git",
3090
- url: gitUrl,
3091
- ...optional("ref", takeString(value, ["ref"], state, path))
3092
- } : localPath ? { type: "path", path: localPath } : void 0;
3816
+ const source = takeDependencySource(value, state, path);
3093
3817
  if (!version && !source) return [];
3094
3818
  return [
3095
3819
  {
@@ -3105,6 +3829,17 @@ function mapDependency(name, value, state, path) {
3105
3829
  }
3106
3830
  ];
3107
3831
  }
3832
+ function takeDependencySource(value, state, path) {
3833
+ const gitUrl = takeString(value, ["git"], state, path);
3834
+ if (gitUrl) {
3835
+ const ref = takeString(value, ["ref", "rev", "branch"], state, path);
3836
+ return { type: "git", url: gitUrl, ...optional("ref", ref) };
3837
+ }
3838
+ const localPath = takeString(value, ["path"], state, path);
3839
+ if (localPath) return { type: "path", path: localPath };
3840
+ const registry = takeString(value, ["registry"], state, path);
3841
+ return registry ? { type: "registry", registry } : void 0;
3842
+ }
3108
3843
  function takeCustomSections(value, language, activeLanguages, state, basePath) {
3109
3844
  const located = locate(value, ["customSections"], basePath);
3110
3845
  if (!located || !Array.isArray(located.value)) return void 0;
@@ -3153,6 +3888,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
3153
3888
  );
3154
3889
  return manifest;
3155
3890
  }
3891
+ function mapPackageManifestOptions(manifest, state, packageConfig) {
3892
+ const bugs = takeManifestBugs(manifest, state);
3893
+ if (bugs) packageConfig.bugs = bugs;
3894
+ const repository = takeManifestRepository(manifest, state);
3895
+ if (repository !== void 0 && packageConfig.repository === void 0) {
3896
+ packageConfig.repository = repository;
3897
+ }
3898
+ const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
3899
+ if (exports) consume(state, exports.path);
3900
+ return compact({
3901
+ exports: exports?.value,
3902
+ scripts: takeManifestScripts(manifest, state),
3903
+ files: takeStringArray(manifest.value, ["files"], state, manifest.path),
3904
+ engines: takeManifestStringRecord(manifest, "engines", state),
3905
+ lintStaged: takeManifestLintStaged(manifest, state),
3906
+ browser: takeManifestBrowser(manifest, state)
3907
+ });
3908
+ }
3909
+ function takeManifestBugs(manifest, state) {
3910
+ const text = takeString(manifest.value, ["bugs"], state, manifest.path);
3911
+ if (text !== void 0) return { url: text };
3912
+ const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
3913
+ if (!located) return void 0;
3914
+ const url = takeString(located.value, ["url"], state, located.path);
3915
+ const email = takeString(located.value, ["email"], state, located.path);
3916
+ return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
3917
+ }
3918
+ function takeManifestRepository(manifest, state) {
3919
+ const text = takeString(manifest.value, ["repository"], state, manifest.path);
3920
+ if (text !== void 0) return text;
3921
+ const located = takeObject(manifest.value, ["repository"], state, manifest.path);
3922
+ if (!located) return void 0;
3923
+ const url = takeString(located.value, ["url"], state, located.path);
3924
+ if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
3925
+ return url;
3926
+ }
3927
+ function takeManifestScripts(manifest, state) {
3928
+ const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
3929
+ if (!located) return void 0;
3930
+ const scripts = Object.entries(located.value).flatMap(([name, command]) => {
3931
+ if (typeof command !== "string" || !command) return [];
3932
+ consume(state, [...located.path, name]);
3933
+ return [{ name, command }];
3934
+ });
3935
+ return scripts.length ? scripts : void 0;
3936
+ }
3937
+ function takeManifestStringRecord(manifest, key, state) {
3938
+ const located = takeObject(manifest.value, [key], state, manifest.path);
3939
+ if (!located) return void 0;
3940
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3941
+ if (typeof value !== "string" || !value) return [];
3942
+ consume(state, [...located.path, name]);
3943
+ return [[name, value]];
3944
+ });
3945
+ return entries.length ? Object.fromEntries(entries) : void 0;
3946
+ }
3947
+ function takeManifestLintStaged(manifest, state) {
3948
+ const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
3949
+ if (!located) return void 0;
3950
+ const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
3951
+ const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
3952
+ if (!list?.length || list.some((command) => !command)) return [];
3953
+ consume(state, [...located.path, glob]);
3954
+ return [[glob, list]];
3955
+ });
3956
+ return entries.length ? Object.fromEntries(entries) : void 0;
3957
+ }
3958
+ function takeManifestBrowser(manifest, state) {
3959
+ const located = takeObject(manifest.value, ["browser"], state, manifest.path);
3960
+ if (!located) return void 0;
3961
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3962
+ if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
3963
+ consume(state, [...located.path, name]);
3964
+ return [[name, value]];
3965
+ });
3966
+ return entries.length ? Object.fromEntries(entries) : void 0;
3967
+ }
3156
3968
  function takeManifestAuthors(manifest, state) {
3157
3969
  const located = locate(manifest.value, ["authors"], manifest.path);
3158
3970
  if (!located || !Array.isArray(located.value)) return [];
@@ -3293,6 +4105,15 @@ var compatibilityConfigSchema = z.strictObject({
3293
4105
  legacyInput: legacyInputSchema.optional().describe("Original producer input retained only for migration debugging."),
3294
4106
  unsupportedFields: z.array(unsupportedFieldSchema).optional().describe("Legacy fields that could not be represented in normalized configuration.")
3295
4107
  });
4108
+
4109
+ // src/sdk-config-ir/v1/diagnostics.ts
4110
+ function getSdkConfigIrV1Diagnostics(config) {
4111
+ if (config.target.language !== "cli") {
4112
+ return [];
4113
+ }
4114
+ const diagnostic = cliDistributionModeDiagnostic(config.output, ["output"]);
4115
+ return diagnostic ? [diagnostic] : [];
4116
+ }
3296
4117
  var generationAssetSchema = z.discriminatedUnion("type", [
3297
4118
  z.strictObject({
3298
4119
  type: z.literal("path").describe("Loads the generation asset from a relative path."),
@@ -3595,6 +4416,12 @@ var githubOutputSchema2 = z.strictObject({
3595
4416
  /** Automatically merge the GitHub publishing PR. Defaults to false. */
3596
4417
  autoMerge: z.boolean().default(false).describe("Whether the GitHub publisher automatically merges its pull request.")
3597
4418
  });
4419
+ var distributionShape = {
4420
+ /** Valid only for `cli` targets with GitHub delivery; secret names only, never values. */
4421
+ distribution: cliDistributionConfigSchema.optional().describe(
4422
+ "CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
4423
+ )
4424
+ };
3598
4425
  var credentialResolutionShape = {
3599
4426
  /** Where output credential references are resolved. */
3600
4427
  credentialResolution: credentialResolutionSchema.default("refs-only").describe("Where output credential references are resolved.")
@@ -3603,18 +4430,21 @@ var filesOutputSchema2 = z.strictObject({
3603
4430
  delivery: z.literal("files").describe("Writes the generated SDK to a directory."),
3604
4431
  path: nonEmptyStringSchema.optional().describe("The destination directory for generated files."),
3605
4432
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4433
+ ...distributionShape,
3606
4434
  ...credentialResolutionShape
3607
4435
  });
3608
4436
  var zipOutputSchema2 = z.strictObject({
3609
4437
  delivery: z.literal("zip").describe("Packages the generated SDK as a ZIP archive."),
3610
4438
  fileName: nonEmptyStringSchema.optional().describe("The generated ZIP archive file name."),
3611
4439
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4440
+ ...distributionShape,
3612
4441
  ...credentialResolutionShape
3613
4442
  });
3614
4443
  var githubDeliverySchema2 = z.strictObject({
3615
4444
  delivery: z.literal("github").describe("Delivers the generated SDK to GitHub."),
3616
4445
  github: githubOutputSchema2.describe("GitHub repository delivery settings."),
3617
4446
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4447
+ ...distributionShape,
3618
4448
  ...credentialResolutionShape
3619
4449
  });
3620
4450
  var outputConfigSchema = z.discriminatedUnion(
@@ -3699,7 +4529,7 @@ var targetConfigSchema = z.strictObject({
3699
4529
  // src/sdk-config-ir/v1/sdk-config-ir-v1.ts
3700
4530
  var SDK_CONFIG_IR_V1_SCHEMA_VERSION = "sdk-config-ir/v1";
3701
4531
  var publishRegistryLanguages2 = {
3702
- npm: ["typescript", "mcp"],
4532
+ npm: ["typescript", "mcp", "cli"],
3703
4533
  pypi: ["python"],
3704
4534
  maven: ["java", "kotlin"],
3705
4535
  nuget: ["csharp"],
@@ -3754,6 +4584,28 @@ function validatePublishingIdentity2(packageConfig, registry, context) {
3754
4584
  });
3755
4585
  }
3756
4586
  }
4587
+ function validateCliOutput(output, language, context) {
4588
+ if (output.distribution !== void 0 && language !== "cli") {
4589
+ context.addIssue({
4590
+ code: "custom",
4591
+ message: `output.distribution is supported only for target language "cli", not "${language}"`,
4592
+ path: ["output", "distribution"]
4593
+ });
4594
+ } else if (output.distribution !== void 0 && output.delivery !== "github") {
4595
+ context.addIssue({
4596
+ code: "custom",
4597
+ message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
4598
+ path: ["output", "distribution"]
4599
+ });
4600
+ }
4601
+ if (language === "cli" && output.publish && output.delivery !== "github") {
4602
+ context.addIssue({
4603
+ code: "custom",
4604
+ message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
4605
+ path: ["output", "publish"]
4606
+ });
4607
+ }
4608
+ }
3757
4609
  var sdkConfigIrV1Schema = z.strictObject({
3758
4610
  schemaVersion: z.literal(SDK_CONFIG_IR_V1_SCHEMA_VERSION).describe("The version of the normalized SDK Config IR schema."),
3759
4611
  source: sourceConfigSchema.describe("Materialized API descriptions consumed by generation."),
@@ -3815,6 +4667,7 @@ var sdkConfigIrV1Schema = z.strictObject({
3815
4667
  });
3816
4668
  }
3817
4669
  }
4670
+ validateCliOutput(output, target.language, context);
3818
4671
  if (compatibility?.legacyInput) {
3819
4672
  const expectedKind = target.sourceOrigin === "postman" ? "postman-build-parameters" : "fern-generator-invocation";
3820
4673
  if (compatibility.legacyInput.kind !== expectedKind) {
@@ -3854,6 +4707,6 @@ function parseSdkConfigIrV1ForConsumption(value) {
3854
4707
  return parseSdkConfigIrV1(stripUnknownProperties(value, sdkConfigIrV1InputJsonSchema));
3855
4708
  }
3856
4709
 
3857
- export { FernConfigMappingError, SDK_CONFIG_IR_V1_SCHEMA_VERSION, SDK_CONFIG_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliGenerationConfigSchema, clientConfigOverrideSchema, clientConfigSchema, clientRetryOverrideSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mapFernConfigToSdkConfigV1, mcpAvailabilityStatuses, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, parseSdkConfigIrV1ForConsumption, parseSdkConfigV1, parseSdkConfigV1ForConsumption, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeCustomSectionSchema, readmeEndpointSchema, relativePathSchema, replayConfigSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrCapabilitySchema, sdkConfigIrV1Schema, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, 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, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, serializeSdkConfigIrV1, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, splitSdkConfigV1TargetGeneration, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema, validateSdkConfigV1, webhookSignatureSchema };
4710
+ export { CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE, FernConfigMappingError, SDK_CONFIG_IR_V1_SCHEMA_VERSION, CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE as SDK_CONFIG_V1_CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE, SDK_CONFIG_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliDistributionConfigSchema, cliDistributionGithubAppSchema, cliDistributionHomebrewSchema, cliDistributionScoopSchema, cliGenerationConfigSchema, clientConfigOverrideSchema, clientConfigSchema, clientRetryOverrideSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, getSdkConfigIrV1Diagnostics, getSdkConfigV1Diagnostics, githubActionsSecretNameSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mapFernConfigToSdkConfigV1, mcpAvailabilityStatuses, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, parseSdkConfigIrV1ForConsumption, parseSdkConfigV1, parseSdkConfigV1ForConsumption, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeCustomSectionSchema, readmeEndpointSchema, relativePathSchema, replayConfigSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrCapabilitySchema, sdkConfigIrV1Schema, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliDistributionConfigSchema as sdkConfigV1CliDistributionConfigSchema, cliDistributionGithubAppSchema as sdkConfigV1CliDistributionGithubAppSchema, cliDistributionHomebrewSchema as sdkConfigV1CliDistributionHomebrewSchema, cliDistributionScoopSchema as sdkConfigV1CliDistributionScoopSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1CliOutputConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, sdkConfigV1GenerationConfigSchema, githubActionsSecretNameSchema as sdkConfigV1GithubActionsSecretNameSchema, 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, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, serializeSdkConfigIrV1, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, splitSdkConfigV1TargetGeneration, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema, validateSdkConfigV1, webhookSignatureSchema };
3858
4711
  //# sourceMappingURL=index.js.map
3859
4712
  //# sourceMappingURL=index.js.map