@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.cjs CHANGED
@@ -131,13 +131,21 @@ var oauthScopeSchema = zod.z.strictObject({
131
131
  name: nonEmptyStringSchema.describe("The OAuth scope value requested from the provider."),
132
132
  description: zod.z.string().optional().describe("A description of the OAuth scope included in generated SDK documentation.")
133
133
  });
134
+ var publicClientIdSchema = nonEmptyStringSchema.refine((value) => value.trim() === value, {
135
+ message: "must not have leading or trailing whitespace"
136
+ }).refine((value) => !value.includes("${"), {
137
+ message: "must be a literal public client ID, not an environment expression"
138
+ });
134
139
  var oauthFlowSchema = zod.z.discriminatedUnion("type", [
135
140
  zod.z.strictObject({
136
141
  type: zod.z.literal("authorization-code").describe("Uses the OAuth authorization code flow."),
137
142
  authorizationUrl: nonEmptyStringSchema.describe("The URL used to authorize the client."),
138
143
  tokenUrl: nonEmptyStringSchema.describe("The URL used to exchange a code for tokens."),
139
144
  refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
140
- scopes: zod.z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow.")
145
+ scopes: zod.z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow."),
146
+ clientId: publicClientIdSchema.optional().describe(
147
+ "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."
148
+ )
141
149
  }),
142
150
  zod.z.strictObject({
143
151
  type: zod.z.literal("client-credentials").describe("Uses the OAuth client credentials flow."),
@@ -430,6 +438,12 @@ var dependencySchema = zod.z.strictObject({
430
438
  }).refine(({ source, version }) => source !== void 0 || version !== void 0, {
431
439
  message: "dependency must define a version or a source"
432
440
  });
441
+ var bugsSchema = zod.z.strictObject({
442
+ url: nonEmptyStringSchema.optional().describe("The issue tracker URL."),
443
+ email: nonEmptyStringSchema.optional().describe("The address for reporting issues.")
444
+ }).refine(({ url, email }) => url !== void 0 || email !== void 0, {
445
+ message: "bugs must define a url or an email"
446
+ });
433
447
  var projectUrlSchema = zod.z.strictObject({
434
448
  label: nonEmptyStringSchema.describe("The label displayed for the project link."),
435
449
  url: nonEmptyStringSchema.describe("The project link URL.")
@@ -444,6 +458,7 @@ var packageConfigSchema = zod.z.strictObject({
444
458
  description: zod.z.string().optional().describe("The package description used in generated metadata."),
445
459
  repository: nonEmptyStringSchema.optional().describe("The source repository for the generated SDK."),
446
460
  homepage: nonEmptyStringSchema.optional().describe("The package homepage URL."),
461
+ bugs: bugsSchema.optional().describe("Where issues with the package are reported."),
447
462
  documentationUrl: nonEmptyStringSchema.optional().describe("The package documentation URL."),
448
463
  authors: zod.z.array(authorSchema).optional().describe("Authors credited in package metadata."),
449
464
  developers: zod.z.array(developerSchema).optional().describe("Developers credited in package metadata."),
@@ -453,8 +468,102 @@ var packageConfigSchema = zod.z.strictObject({
453
468
  projectUrls: zod.z.array(projectUrlSchema).optional().describe("Labeled project links for package metadata."),
454
469
  extraDependencies: zod.z.array(dependencySchema).optional().describe("Additional runtime dependencies added to the generated package."),
455
470
  extraDevDependencies: zod.z.array(dependencySchema).optional().describe("Additional development dependencies added to the generated package."),
456
- extraPeerDependencies: zod.z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package.")
471
+ extraPeerDependencies: zod.z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package."),
472
+ extraPeerDependenciesMeta: zod.z.record(nonEmptyStringSchema, jsonObjectSchema).optional().describe(
473
+ "npm peerDependenciesMeta entries keyed by peer dependency name, such as { optional: true }."
474
+ )
457
475
  });
476
+ var GITHUB_ACTIONS_SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/;
477
+ var GITHUB_REPOSITORY_SLUG_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
478
+ var HOMEBREW_FORMULA_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
479
+ var githubActionsSecretNameSchema = zod.z.string({ error: "must be the name of a GitHub Actions secret" }).regex(GITHUB_ACTIONS_SECRET_NAME_PATTERN, {
480
+ 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."
481
+ }).refine((value) => value !== "GITHUB_TOKEN", {
482
+ 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."
483
+ });
484
+ var githubRepositorySlugSchema = zod.z.string({ error: 'must be a GitHub repository in "<owner>/<repo>" form' }).regex(GITHUB_REPOSITORY_SLUG_PATTERN, {
485
+ error: 'must be a GitHub repository in "<owner>/<repo>" form, for example "acme/homebrew-tap"'
486
+ });
487
+ var homebrewFormulaNameSchema = zod.z.string({ error: "must be a Homebrew formula name" }).regex(HOMEBREW_FORMULA_NAME_PATTERN, {
488
+ error: "must be a Homebrew formula name: start with a lowercase letter and contain only a-z, 0-9, or -"
489
+ });
490
+ var cliDistributionGithubAppSchema = zod.z.strictObject({
491
+ appIdSecretName: githubActionsSecretNameSchema.describe(
492
+ "The name of the GitHub Actions secret holding the GitHub App ID or client ID."
493
+ ),
494
+ privateKeySecretName: githubActionsSecretNameSchema.describe(
495
+ "The name of the GitHub Actions secret holding the GitHub App private key in PEM form."
496
+ )
497
+ });
498
+ 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.";
499
+ var cliDistributionHomebrewSchema = zod.z.strictObject({
500
+ tap: githubRepositorySlugSchema.describe(
501
+ 'The Homebrew tap repository in "<owner>/<repo>" form that receives the formula.'
502
+ ),
503
+ formula: homebrewFormulaNameSchema.optional().describe("The Homebrew formula name; the generator defaults it to the CLI binary name."),
504
+ tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
505
+ });
506
+ var cliDistributionScoopSchema = zod.z.strictObject({
507
+ bucket: githubRepositorySlugSchema.describe(
508
+ 'The Scoop bucket repository in "<owner>/<repo>" form that receives the manifest.'
509
+ ),
510
+ tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
511
+ });
512
+ var cliDistributionConfigSchema = zod.z.strictObject({
513
+ githubApp: cliDistributionGithubAppSchema.optional().describe(
514
+ "A GitHub App used to mint short-lived tokens for every channel without its own tokenSecretName."
515
+ ),
516
+ homebrew: cliDistributionHomebrewSchema.optional().describe("Publishes a Homebrew formula to a tap repository on each tagged release."),
517
+ scoop: cliDistributionScoopSchema.optional().describe("Publishes a Scoop manifest to a bucket repository on each tagged release.")
518
+ }).superRefine((distribution, context) => {
519
+ if (distribution.homebrew !== void 0 || distribution.scoop !== void 0) {
520
+ return;
521
+ }
522
+ if (distribution.githubApp !== void 0) {
523
+ context.addIssue({
524
+ code: "custom",
525
+ message: "githubApp requires at least one distribution channel: homebrew or scoop",
526
+ path: ["githubApp"]
527
+ });
528
+ return;
529
+ }
530
+ context.addIssue({
531
+ code: "custom",
532
+ message: "distribution must configure at least one channel: homebrew or scoop"
533
+ });
534
+ });
535
+ 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.';
536
+ 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.';
537
+ var CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = "CLI_DISTRIBUTION_NON_RELEASE_MODE";
538
+ var nonReleaseGithubModes = /* @__PURE__ */ new Set(["pull-request", "push", "commit"]);
539
+ function cliDistributionModeDiagnostic(output, outputPath) {
540
+ const mode = output?.github?.mode;
541
+ if (output?.distribution === void 0 || mode === void 0 || !nonReleaseGithubModes.has(mode)) {
542
+ return void 0;
543
+ }
544
+ return {
545
+ code: CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE,
546
+ severity: "warning",
547
+ path: [...outputPath, "github", "mode"],
548
+ 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.`,
549
+ suggestedAction: 'Use mode "release" or "commit-and-release", or push a version tag after merging generated changes.'
550
+ };
551
+ }
552
+
553
+ // src/sdk-config/v1/diagnostics.ts
554
+ function getSdkConfigV1Diagnostics(config) {
555
+ return config.targets.flatMap((target, targetIndex) => {
556
+ if (target.language !== "cli") {
557
+ return [];
558
+ }
559
+ const diagnostic = cliDistributionModeDiagnostic(target.output, [
560
+ "targets",
561
+ targetIndex,
562
+ "output"
563
+ ]);
564
+ return diagnostic ? [diagnostic] : [];
565
+ });
566
+ }
458
567
  var httpMethodSchema = zod.z.enum([
459
568
  "GET",
460
569
  "POST",
@@ -659,6 +768,17 @@ function stringValue(value) {
659
768
  function stringArrayValue(value) {
660
769
  return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0) ? value : void 0;
661
770
  }
771
+ var canonicalLicenseTypes = {
772
+ mit: "MIT",
773
+ apache: "APACHE",
774
+ "apache-2.0": "APACHE",
775
+ "gpl-3.0": "GPL3",
776
+ "gpl-3.0-only": "GPL3",
777
+ unlicensed: "UNLICENSED"
778
+ };
779
+ function canonicalLicenseType(value) {
780
+ return canonicalLicenseTypes[value.trim().toLowerCase()];
781
+ }
662
782
  function stableJson(value) {
663
783
  return JSON.stringify(sortKeys(value));
664
784
  }
@@ -669,6 +789,280 @@ function sortKeys(value) {
669
789
  Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortKeys(child)])
670
790
  );
671
791
  }
792
+ var ALPHANUMERIC_PATTERN = /[A-Za-z0-9]/;
793
+ var ROOT_GROUP_PATTERN = /^[a-z][a-z0-9_-]*$/;
794
+ var KEBAB_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
795
+ var DOTTED_COMMAND_PATH_PATTERN = /^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/;
796
+ var FIELD_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
797
+ var RESERVED_USER_AGENT_SUFFIX_FLAGS = /* @__PURE__ */ new Set([
798
+ "params",
799
+ "output",
800
+ "json",
801
+ "format",
802
+ "dry-run",
803
+ "base-url",
804
+ "page-all",
805
+ "page-limit",
806
+ "page-delay",
807
+ "no-pager",
808
+ "no-extract",
809
+ "no-retry",
810
+ "no-stream",
811
+ "quiet",
812
+ "query",
813
+ "help",
814
+ "debug",
815
+ "schema"
816
+ ]);
817
+ var RESERVED_PROFILES_COMMAND_NAMES = /* @__PURE__ */ new Set([
818
+ "auth",
819
+ "completion",
820
+ "man",
821
+ "errors",
822
+ "generate-skills",
823
+ "help"
824
+ ]);
825
+ var binaryNameSchema = nonEmptyStringSchema.regex(ALPHANUMERIC_PATTERN, {
826
+ message: "binaryName must contain at least one ASCII letter or digit"
827
+ });
828
+ var rootGroupSchema = zod.z.string().regex(ROOT_GROUP_PATTERN, {
829
+ message: "rootGroup must start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores"
830
+ });
831
+ var userAgentSuffixFlagSchema = zod.z.string().superRefine((value, context) => {
832
+ if (value.startsWith("-")) {
833
+ context.addIssue({
834
+ code: "custom",
835
+ message: 'userAgentSuffixFlag must be the long flag name without the leading "--"'
836
+ });
837
+ } else if (!KEBAB_NAME_PATTERN.test(value)) {
838
+ context.addIssue({
839
+ code: "custom",
840
+ message: "userAgentSuffixFlag must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
841
+ });
842
+ } else if (RESERVED_USER_AGENT_SUFFIX_FLAGS.has(value)) {
843
+ context.addIssue({
844
+ code: "custom",
845
+ message: `userAgentSuffixFlag "${value}" collides with a built-in global flag`
846
+ });
847
+ }
848
+ });
849
+ var profilesCommandNameSchema = zod.z.string().superRefine((value, context) => {
850
+ if (!KEBAB_NAME_PATTERN.test(value)) {
851
+ context.addIssue({
852
+ code: "custom",
853
+ message: "profiles.commandName must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
854
+ });
855
+ } else if (RESERVED_PROFILES_COMMAND_NAMES.has(value)) {
856
+ context.addIssue({
857
+ code: "custom",
858
+ message: `profiles.commandName "${value}" collides with a built-in command group`
859
+ });
860
+ }
861
+ });
862
+ function dottedCommandPathSchema(field) {
863
+ return zod.z.string().regex(DOTTED_COMMAND_PATH_PATTERN, {
864
+ message: `${field} must be a dotted command path such as "iam.keys.create"`
865
+ });
866
+ }
867
+ function fieldNameMapSchema(field) {
868
+ const message = `${field} keys and values must be field names containing only [A-Za-z0-9_.-]`;
869
+ return zod.z.record(zod.z.string(), zod.z.string().regex(FIELD_NAME_PATTERN, { message })).superRefine((value, context) => {
870
+ for (const key of Object.keys(value)) {
871
+ if (!FIELD_NAME_PATTERN.test(key)) {
872
+ context.addIssue({ code: "custom", message, path: [key] });
873
+ }
874
+ }
875
+ });
876
+ }
877
+ var profilesProvisionOperationSchema = zod.z.strictObject({
878
+ operation: dottedCommandPathSchema("profiles.provisionOperation.operation").describe(
879
+ "The dotted command path of the operation that mints a profile credential."
880
+ ),
881
+ credential: fieldNameMapSchema("profiles.provisionOperation.credential").refine((value) => Object.keys(value).length > 0, {
882
+ message: "profiles.provisionOperation.credential must map at least one credential field"
883
+ }).describe("Maps each stored credential field to the response field that supplies it."),
884
+ revokeParameters: fieldNameMapSchema("profiles.provisionOperation.revokeParameters").optional().describe("Maps each revoke-operation parameter to the response field that supplies it.")
885
+ });
886
+ var profilesConfigSchema = zod.z.strictObject({
887
+ enabled: zod.z.boolean().describe("Whether the CLI emits profile commands and the global --profile flag."),
888
+ commandName: profilesCommandNameSchema.optional().describe('The profile command group name. The generator defaults to "profiles".'),
889
+ revokeOperation: dottedCommandPathSchema("profiles.revokeOperation").optional().describe('The dotted command path called by "profiles remove --revoke".'),
890
+ provisionOperation: profilesProvisionOperationSchema.optional().describe('The operation called by "profiles create --provision" and its response mapping.')
891
+ });
892
+ var cliGenerationConfigSchema = zod.z.strictObject({
893
+ paginationParameters: zod.z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
894
+ skills: zod.z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands."),
895
+ binaryName: binaryNameSchema.optional().describe(
896
+ "The CLI executable name. The generator kebab-cases it and also uses it for the source directory and env-var prefix."
897
+ ),
898
+ customCommands: zod.z.boolean().optional().describe("Whether hand-written command support is generated. The generator defaults to true."),
899
+ rootGroup: rootGroupSchema.optional().describe("A command group that every spec-derived command is nested under."),
900
+ profiles: profilesConfigSchema.optional().describe("Named profile command configuration."),
901
+ splitTypeCrates: zod.z.boolean().optional().describe("Whether generated types are split into one crate per API behind a facade crate."),
902
+ userAgentSuffixFlag: userAgentSuffixFlagSchema.optional().describe('The long flag name, without "--", that appends a product token to the User-Agent.')
903
+ });
904
+
905
+ // src/sdk-config/v1/fern-config-mapper-cli.ts
906
+ var CLI_GENERATION_FIELDS = [
907
+ "binaryName",
908
+ "customCommands",
909
+ "rootGroup",
910
+ "profiles",
911
+ "splitTypeCrates",
912
+ "userAgentSuffixFlag"
913
+ ];
914
+ var PROFILES_FIELDS = ["enabled", "commandName", "revokeOperation"];
915
+ var PROVISION_OPERATION_FIELDS = ["operation", "credential", "revokeParameters"];
916
+ function mapCliGeneration(config, state, basePath, targetIndex) {
917
+ const generation = {};
918
+ for (const field of CLI_GENERATION_FIELDS) {
919
+ const raw = ownValue(config, field);
920
+ if (raw === void 0) continue;
921
+ const fieldPath = [...basePath, field];
922
+ const { value, consumedPaths } = field === "profiles" && isObject(raw) ? pickProfiles(raw, fieldPath) : { value: raw, consumedPaths: [fieldPath] };
923
+ const parsed = cliGenerationConfigSchema.shape[field].safeParse(value);
924
+ consumedPaths.forEach((path) => consume(state, path));
925
+ if (parsed.success) {
926
+ generation[field] = structuredClone(value);
927
+ continue;
928
+ }
929
+ const diagnostics = parsed.error.issues.map(
930
+ (issue) => invalidValueDiagnostic(field, fieldPath, issue.path, issue.message, targetIndex)
931
+ );
932
+ (state.valueDiagnostics ??= []).push(...diagnostics);
933
+ }
934
+ return generation;
935
+ }
936
+ function pickProfiles(profiles, path) {
937
+ const picked = pickKnown(profiles, PROFILES_FIELDS, path);
938
+ const provisionOperation = ownValue(profiles, "provisionOperation");
939
+ const provisionPath = [...path, "provisionOperation"];
940
+ if (isObject(provisionOperation)) {
941
+ const provision = pickKnown(provisionOperation, PROVISION_OPERATION_FIELDS, provisionPath);
942
+ picked.value.provisionOperation = provision.value;
943
+ picked.consumedPaths.push(...provision.consumedPaths);
944
+ } else if (provisionOperation !== void 0) {
945
+ picked.value.provisionOperation = provisionOperation;
946
+ picked.consumedPaths.push(provisionPath);
947
+ }
948
+ return { value: { enabled: false, ...picked.value }, consumedPaths: picked.consumedPaths };
949
+ }
950
+ function pickKnown(value, fields, path) {
951
+ const picked = {};
952
+ const consumedPaths = [];
953
+ for (const field of fields) {
954
+ const child = ownValue(value, field);
955
+ if (child === void 0) continue;
956
+ picked[field] = child;
957
+ consumedPaths.push([...path, field]);
958
+ }
959
+ return { value: picked, consumedPaths };
960
+ }
961
+ function ownValue(value, key) {
962
+ return Object.hasOwn(value, key) ? value[key] : void 0;
963
+ }
964
+ function invalidValueDiagnostic(field, fieldPath, issuePath, message, targetIndex) {
965
+ const relative = issuePath.map((part) => typeof part === "symbol" ? String(part) : part);
966
+ const sdkConfigField = ["targets", targetIndex, "generation", field];
967
+ return {
968
+ code: "FERN_CONFIG_VALUE_INVALID",
969
+ severity: "warning",
970
+ path: [...fieldPath, ...relative],
971
+ reason: `CLI setting ${field} was not migrated because SDK Config rejects it: ${message}`,
972
+ sdkConfigPath: [...sdkConfigField, ...relative],
973
+ suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
974
+ };
975
+ }
976
+
977
+ // src/sdk-config/v1/fern-config-mapper-cli-distribution.ts
978
+ var DISTRIBUTION_KEYS = {
979
+ githubApp: { appIdSecret: "appIdSecretName", privateKeySecret: "privateKeySecretName" },
980
+ homebrew: { tap: "tap", formula: "formula", tokenEnvironmentVariable: "tokenSecretName" },
981
+ scoop: { bucket: "bucket", tokenEnvironmentVariable: "tokenSecretName" }
982
+ };
983
+ function mapCliDistribution(config, state, basePath, targetIndex) {
984
+ if (!Object.hasOwn(config, "distribution")) return;
985
+ const raw = config.distribution;
986
+ const path = [...basePath, "distribution"];
987
+ const translated = isObject(raw) ? translateDistribution(raw, path) : { value: raw, consumedPaths: [path], legacyKeys: /* @__PURE__ */ new Map() };
988
+ const parsed = cliDistributionConfigSchema.safeParse(translated.value);
989
+ translated.consumedPaths.forEach((consumedPath) => consume(state, consumedPath));
990
+ if (parsed.success) {
991
+ state.cliDistribution = { value: parsed.data, path };
992
+ return;
993
+ }
994
+ const diagnostics = parsed.error.issues.map(
995
+ (issue) => invalidDistributionDiagnostic(issue, path, translated.legacyKeys, targetIndex)
996
+ );
997
+ const reportedPaths = /* @__PURE__ */ new Set();
998
+ (state.valueDiagnostics ??= []).push(
999
+ ...diagnostics.filter(({ path: diagnosticPath }) => {
1000
+ const key = diagnosticPath.join(".");
1001
+ if (reportedPaths.has(key)) return false;
1002
+ reportedPaths.add(key);
1003
+ return true;
1004
+ })
1005
+ );
1006
+ }
1007
+ function translateDistribution(distribution, path) {
1008
+ const value = {};
1009
+ const consumedPaths = [];
1010
+ const legacyKeys = /* @__PURE__ */ new Map();
1011
+ for (const [block, keys] of Object.entries(DISTRIBUTION_KEYS)) {
1012
+ if (!Object.hasOwn(distribution, block)) continue;
1013
+ const blockValue = distribution[block];
1014
+ const blockPath = [...path, block];
1015
+ if (!isObject(blockValue)) {
1016
+ value[block] = blockValue;
1017
+ consumedPaths.push(blockPath);
1018
+ continue;
1019
+ }
1020
+ const translatedBlock = {};
1021
+ for (const [legacyKey, sdkConfigKey] of Object.entries(keys)) {
1022
+ if (!Object.hasOwn(blockValue, legacyKey)) continue;
1023
+ translatedBlock[sdkConfigKey] = blockValue[legacyKey];
1024
+ consumedPaths.push([...blockPath, legacyKey]);
1025
+ legacyKeys.set(`${block}.${sdkConfigKey}`, legacyKey);
1026
+ }
1027
+ value[block] = translatedBlock;
1028
+ }
1029
+ return { value, consumedPaths, legacyKeys };
1030
+ }
1031
+ function invalidDistributionDiagnostic(issue, path, legacyKeys, targetIndex) {
1032
+ const relative = issue.path.map((part) => typeof part === "symbol" ? String(part) : part);
1033
+ const [block, field] = relative;
1034
+ const legacyField = typeof block === "string" && typeof field === "string" ? legacyKeys.get(`${block}.${field}`) : void 0;
1035
+ const legacyRelative = typeof block === "string" && legacyField !== void 0 ? [block, legacyField] : relative;
1036
+ const sdkConfigField = ["targets", targetIndex, "output", "distribution"];
1037
+ return {
1038
+ code: "FERN_CONFIG_VALUE_INVALID",
1039
+ severity: "warning",
1040
+ path: [...path, ...legacyRelative],
1041
+ reason: `CLI distribution was not migrated because SDK Config rejects it: ${issue.message}`,
1042
+ sdkConfigPath: [...sdkConfigField, ...relative],
1043
+ suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
1044
+ };
1045
+ }
1046
+ function applyCliDistribution(output, pending, targetIndex) {
1047
+ if (pending === void 0) return { output, diagnostics: [] };
1048
+ if (output.delivery === "github") {
1049
+ return { output: { ...output, distribution: pending.value }, diagnostics: [] };
1050
+ }
1051
+ const outputPath = ["targets", targetIndex, "output"];
1052
+ return {
1053
+ output,
1054
+ diagnostics: [
1055
+ {
1056
+ code: "FERN_CLI_DISTRIBUTION_REQUIRES_GITHUB_OUTPUT",
1057
+ severity: "warning",
1058
+ path: pending.path,
1059
+ 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`,
1060
+ sdkConfigPath: [...outputPath, "distribution"],
1061
+ suggestedAction: `Set ${outputPath.join(".")}.delivery to "github" for the CLI repository and add ${outputPath.join(".")}.distribution manually, or remove distribution.`
1062
+ }
1063
+ ]
1064
+ };
1065
+ }
672
1066
 
673
1067
  // src/sdk-config/v1/fern-config-mapper-output.ts
674
1068
  function mapOutput(generator, language, index) {
@@ -852,6 +1246,7 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
852
1246
  const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
853
1247
  if (type) consume(state, [...sourcePath, "type"]);
854
1248
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
1249
+ if (value.workflows === true) consume(state, [...sourcePath, "workflows"]);
855
1250
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
856
1251
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
857
1252
  consumeCredentialObject(value.credentials, [...sourcePath, "credentials"], state);
@@ -879,11 +1274,10 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
879
1274
  ...optionalObject("package", { ...publication?.package, ...licensePackage })
880
1275
  };
881
1276
  }
882
- var basicLicenseTypes = { mit: "MIT", apache: "APACHE" };
883
1277
  function mapGithubLicense(value, sourcePath, state) {
884
1278
  if (!isObject(value) || stringValue(value.type) !== "basic") return {};
885
1279
  const id = stringValue(value.id);
886
- const type = id ? basicLicenseTypes[id.toLowerCase()] : void 0;
1280
+ const type = id ? canonicalLicenseType(id) : void 0;
887
1281
  if (!type) return {};
888
1282
  consume(state, [...sourcePath, "type"]);
889
1283
  consume(state, [...sourcePath, "id"]);
@@ -1450,6 +1844,114 @@ function outputDiagnostic(path, index) {
1450
1844
  suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
1451
1845
  };
1452
1846
  }
1847
+
1848
+ // src/sdk-config/v1/package.ts
1849
+ var sdkConfigV1DependencySchema = dependencySchema;
1850
+ var sdkConfigV1PackageConfigSchema = packageConfigSchema;
1851
+
1852
+ // src/sdk-config/v1/fern-config-mapper-package.ts
1853
+ var emailSchema = zod.z.email();
1854
+ function mapCliPackageIdentity(identity, state, targetIndex) {
1855
+ mapIdentityField(identity, "homepage", stringValue, state);
1856
+ mapIdentityField(identity, "keywords", (value) => stringArrayValue(value)?.slice(), state);
1857
+ mapCargoAuthors(identity, state, targetIndex);
1858
+ mapIdentityField(identity, "license", licenseValue, state);
1859
+ }
1860
+ function mapIdentityField(identity, field, read, state) {
1861
+ const located = locate(identity.value, [field], identity.path);
1862
+ const value = located && read(located.value);
1863
+ if (located && value !== void 0) addPackageFallback(state, field, value, located.path);
1864
+ }
1865
+ function mapLicenseFallback(config, aliases, state, basePath) {
1866
+ const located = locate(config, aliases, basePath);
1867
+ const license = located && licenseValue(located.value);
1868
+ if (located && license) addPackageFallback(state, "license", license, located.path);
1869
+ }
1870
+ function resolveTargetPackage(targetPackage, fallbacks, generator, delivery, index) {
1871
+ const diagnostics = [];
1872
+ for (const fallback of fallbacks) {
1873
+ applyFallback(targetPackage, fallback, index, diagnostics);
1874
+ }
1875
+ if (delivery !== "github") {
1876
+ applyMetadataLicense(targetPackage, generator.raw, index, diagnostics);
1877
+ }
1878
+ return diagnostics;
1879
+ }
1880
+ function applyFallback(targetPackage, { field, value, path }, index, diagnostics) {
1881
+ const existing = targetPackage[field];
1882
+ if (existing === void 0) {
1883
+ targetPackage[field] = value;
1884
+ } else if (stableJson(existing) !== stableJson(value)) {
1885
+ diagnostics.push({
1886
+ code: "FERN_PACKAGE_VALUE_CONFLICT",
1887
+ severity: "warning",
1888
+ path,
1889
+ reason: `Fern value conflicts with the package.${field} already migrated for this target, which is kept`,
1890
+ sdkConfigPath: ["targets", index, "package", field],
1891
+ suggestedAction: `Choose the intended value and set targets.${index}.package.${field} manually.`
1892
+ });
1893
+ }
1894
+ }
1895
+ function applyMetadataLicense(targetPackage, raw, index, diagnostics) {
1896
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
1897
+ if (metadata?.license === void 0 || metadata.license === null) return;
1898
+ const path = ["group", "generators", index, "metadata", "license"];
1899
+ const license = licenseValue(metadata.license);
1900
+ if (license) {
1901
+ applyFallback(targetPackage, { field: "license", value: license, path }, index, diagnostics);
1902
+ return;
1903
+ }
1904
+ diagnostics.push({
1905
+ code: "FERN_CONFIG_FIELD_UNSUPPORTED",
1906
+ severity: "warning",
1907
+ path,
1908
+ reason: isObject(metadata.license) ? "A custom license file cannot be migrated automatically" : "metadata.license is not a license identifier",
1909
+ sdkConfigPath: ["targets", index, "package", "license"],
1910
+ suggestedAction: `Set targets.${index}.package.license manually.`
1911
+ });
1912
+ }
1913
+ function mapCargoAuthors(identity, state, targetIndex) {
1914
+ const located = locate(identity.value, ["authors"], identity.path);
1915
+ const entries = located && stringArrayValue(located.value);
1916
+ if (!located || !entries) return;
1917
+ consume(state, located.path);
1918
+ const authors = entries.map(parseCargoAuthor);
1919
+ const parsed = sdkConfigV1PackageConfigSchema.shape.authors.safeParse(authors);
1920
+ const invalid = parsed.success ? [] : [...new Set(parsed.error.issues.map((issue) => issue.path[0]))].filter(
1921
+ (index) => typeof index === "number"
1922
+ );
1923
+ if (invalid.length === 0) {
1924
+ addPackageFallback(state, "authors", authors, located.path);
1925
+ return;
1926
+ }
1927
+ const authorsPath = ["targets", targetIndex, "package", "authors"];
1928
+ (state.valueDiagnostics ??= []).push(
1929
+ ...invalid.map((entry) => ({
1930
+ code: "FERN_CONFIG_VALUE_INVALID",
1931
+ severity: "warning",
1932
+ path: [...located.path, entry],
1933
+ reason: 'CLI packageIdentity.authors was not migrated because this entry is not "Name" or "Name <email>" with a valid email',
1934
+ sdkConfigPath: authorsPath,
1935
+ suggestedAction: `Correct the entry, then set ${authorsPath.join(".")} manually.`
1936
+ }))
1937
+ );
1938
+ }
1939
+ function parseCargoAuthor(entry) {
1940
+ const trimmed = entry.trim();
1941
+ const match = /^(.*?)\s*<([^<>]*)>$/.exec(trimmed);
1942
+ if (!match) return { name: trimmed };
1943
+ const [, name = "", email = ""] = match;
1944
+ if (name !== "" && !emailSchema.safeParse(email).success) return { name: trimmed };
1945
+ return { name, email };
1946
+ }
1947
+ function licenseValue(value) {
1948
+ const license = stringValue(value)?.trim();
1949
+ return license ? { type: canonicalLicenseType(license) ?? license } : void 0;
1950
+ }
1951
+ function addPackageFallback(state, field, value, path) {
1952
+ consume(state, path);
1953
+ (state.packageFallbacks ??= []).push({ field, value, path });
1954
+ }
1453
1955
  var OMIT = /* @__PURE__ */ Symbol("omit");
1454
1956
  function inputJsonSchema(schema) {
1455
1957
  return zod.z.toJSONSchema(schema, {
@@ -1719,7 +2221,16 @@ var sdkConfigV1PublishConfigSchema = zod.z.discriminatedUnion("registry", [
1719
2221
  zod.z.strictObject({
1720
2222
  registry: zod.z.literal("npm").describe("Publishes the package to an npm-compatible registry."),
1721
2223
  token: nonEmptyStringSchema.optional().describe("The npm registry token, or an environment expression that resolves to it."),
2224
+ trustedPublishing: zod.z.boolean().optional().describe("Whether npm publication uses trusted publishing (OIDC) instead of a token."),
1722
2225
  ...commonPublishShape
2226
+ }).superRefine((publish, context) => {
2227
+ if (publish.trustedPublishing === true && publish.token !== void 0) {
2228
+ context.addIssue({
2229
+ code: "custom",
2230
+ message: "token must be omitted when trustedPublishing is true",
2231
+ path: ["token"]
2232
+ });
2233
+ }
1723
2234
  }),
1724
2235
  zod.z.strictObject({
1725
2236
  registry: zod.z.literal("pypi").describe("Publishes the package to a PyPI-compatible registry."),
@@ -1797,10 +2308,29 @@ var sdkConfigV1OutputConfigSchema = zod.z.discriminatedUnion(
1797
2308
  [filesOutputSchema, zipOutputSchema, githubDeliverySchema],
1798
2309
  { error: 'output.delivery must be one of "files", "zip", or "github"' }
1799
2310
  );
1800
-
1801
- // src/sdk-config/v1/package.ts
1802
- var sdkConfigV1DependencySchema = dependencySchema;
1803
- var sdkConfigV1PackageConfigSchema = packageConfigSchema;
2311
+ var cliDistributionShape = {
2312
+ distribution: cliDistributionConfigSchema.optional().describe(
2313
+ "CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
2314
+ )
2315
+ };
2316
+ function rejectDistributionWithoutGithub(output, context) {
2317
+ if (output.distribution !== void 0) {
2318
+ context.addIssue({
2319
+ code: "custom",
2320
+ message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
2321
+ path: ["distribution"]
2322
+ });
2323
+ }
2324
+ }
2325
+ var sdkConfigV1CliOutputConfigSchema = zod.z.discriminatedUnion(
2326
+ "delivery",
2327
+ [
2328
+ filesOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2329
+ zipOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2330
+ githubDeliverySchema.extend(cliDistributionShape)
2331
+ ],
2332
+ { error: 'output.delivery must be one of "files", "zip", or "github"' }
2333
+ );
1804
2334
  var sdkConfigV1ReplayConfigSchema = zod.z.strictObject({
1805
2335
  enabled: zod.z.boolean().describe("Whether regeneration reapplies customer-authored repository changes.")
1806
2336
  });
@@ -1877,10 +2407,6 @@ var sdkConfigV1SourceConfigSchema = zod.z.strictObject({
1877
2407
  seenIds.add(id);
1878
2408
  });
1879
2409
  });
1880
- var cliGenerationConfigSchema = zod.z.strictObject({
1881
- paginationParameters: zod.z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
1882
- skills: zod.z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands.")
1883
- });
1884
2410
  var csharpGenerationConfigSchema = zod.z.strictObject({
1885
2411
  useOptionalWrapper: zod.z.boolean().optional().describe("Whether optional values use an explicit Optional wrapper."),
1886
2412
  simplifyObjectDictionaries: zod.z.boolean().optional().describe("Whether object schemas with arbitrary values use simplified dictionary types."),
@@ -1928,7 +2454,7 @@ var packageScriptSchema = zod.z.strictObject({
1928
2454
  command: nonEmptyStringSchema.describe("The command executed by the package script.")
1929
2455
  });
1930
2456
  var httpClientSchema = zod.z.strictObject({
1931
- name: zod.z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
2457
+ name: zod.z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
1932
2458
  });
1933
2459
  var typescriptGenerationConfigSchema = zod.z.strictObject({
1934
2460
  typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
@@ -1944,6 +2470,37 @@ var typescriptGenerationConfigSchema = zod.z.strictObject({
1944
2470
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
1945
2471
  namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
1946
2472
  consolidateTypeFiles: zod.z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
2473
+ formDataSupport: zod.z.enum(["Node16", "Node18"]).optional().describe(
2474
+ "The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
2475
+ ),
2476
+ allowExtraFields: zod.z.boolean().optional().describe(
2477
+ "Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
2478
+ ),
2479
+ generateSubpackageExports: zod.z.boolean().optional().describe(
2480
+ "Whether the package manifest exports each subpackage client as its own entry point."
2481
+ ),
2482
+ exportAllRequestsAtRoot: zod.z.boolean().optional().describe("Whether every request type is also exported from the package root."),
2483
+ generateEndpointMetadata: zod.z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
2484
+ outputEsm: zod.z.boolean().optional().describe(
2485
+ "Whether the package is marked as an ES module while still shipping its CommonJS build."
2486
+ ),
2487
+ neverThrowErrors: zod.z.boolean().optional().describe(
2488
+ "Whether client methods return a wrapped response instead of throwing on a non-2xx status."
2489
+ ),
2490
+ includeOtherInUnionTypes: zod.z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
2491
+ includeUtilsOnUnionMembers: zod.z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
2492
+ omitFernHeaders: zod.z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
2493
+ linter: zod.z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
2494
+ formatter: zod.z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
2495
+ exports: jsonObjectSchema.optional().describe(
2496
+ "package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
2497
+ ),
2498
+ files: zod.z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
2499
+ engines: zod.z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
2500
+ lintStaged: zod.z.record(nonEmptyStringSchema, zod.z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
2501
+ browser: zod.z.record(nonEmptyStringSchema, zod.z.union([zod.z.boolean(), nonEmptyStringSchema])).optional().describe(
2502
+ "package.json browser field: a module or file is excluded (false) or replaced by another path."
2503
+ ),
1947
2504
  allowCustomFetcher: zod.z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
1948
2505
  useBrandedStringAliases: zod.z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
1949
2506
  useLegacyExports: zod.z.boolean().optional().describe("Whether the package emits the legacy export layout."),
@@ -2133,7 +2690,10 @@ var sdkConfigV1TargetSchema = zod.z.discriminatedUnion("language", [
2133
2690
  zod.z.strictObject({
2134
2691
  language: zod.z.literal("cli").describe("Generates a command-line interface."),
2135
2692
  generation: sdkConfigV1GenerationConfigOverrideSchema.extend(cliGenerationConfigSchema.shape).optional().describe("Common and CLI-specific generation settings for this target."),
2136
- ...targetOverrideShape
2693
+ ...targetOverrideShape,
2694
+ output: sdkConfigV1CliOutputConfigSchema.optional().describe(
2695
+ "Output configuration, including optional CLI distribution channels, that replaces the root output for this target."
2696
+ )
2137
2697
  }),
2138
2698
  zod.z.strictObject({
2139
2699
  language: zod.z.literal("mcp").describe("Generates an MCP server."),
@@ -2150,7 +2710,7 @@ var sdkConfigV1TargetSchema = zod.z.discriminatedUnion("language", [
2150
2710
  // src/sdk-config/v1/sdk-config-v1.ts
2151
2711
  var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
2152
2712
  var publishRegistryLanguages = {
2153
- npm: ["typescript", "mcp"],
2713
+ npm: ["typescript", "mcp", "cli"],
2154
2714
  pypi: ["python"],
2155
2715
  maven: ["java", "kotlin"],
2156
2716
  nuget: ["csharp"],
@@ -2227,6 +2787,13 @@ function validateTargetPublishing(target, targetIndex, globalPackage, globalOutp
2227
2787
  });
2228
2788
  return;
2229
2789
  }
2790
+ if (target.language === "cli" && output.delivery !== "github") {
2791
+ context.addIssue({
2792
+ code: "custom",
2793
+ message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
2794
+ path: target.output ? ["targets", targetIndex, "output", "delivery"] : ["output", "delivery"]
2795
+ });
2796
+ }
2230
2797
  validatePublishingIdentity(
2231
2798
  { ...globalPackage, ...target.package },
2232
2799
  registry,
@@ -2339,16 +2906,33 @@ function mapFernConfigToSdkConfigV1(input) {
2339
2906
  package: outputPackage,
2340
2907
  generation: outputGeneration
2341
2908
  }, index) => {
2909
+ const distribution = applyCliDistribution(output, invocation.cliDistribution, index);
2910
+ invocation.unsupportedFields.push(...distribution.diagnostics);
2342
2911
  const target = {
2343
2912
  language,
2344
- output,
2913
+ output: distribution.output,
2345
2914
  ...optional("sdkName", generator.sdkName),
2346
2915
  ...optional("sdkVersion", generator.sdkVersion),
2347
2916
  ...optional("client", clients.targetOverrides[index]),
2348
2917
  ...optional("docs", docs.targetOverrides[index])
2349
2918
  };
2350
- if (Object.keys(invocation.package).length > 0 || outputPackage || generator.package) {
2351
- target.package = { ...invocation.package, ...outputPackage, ...generator.package };
2919
+ const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2920
+ invocation.unsupportedFields.push(
2921
+ ...resolveTargetPackage(
2922
+ mappedPackage,
2923
+ invocation.packageFallbacks,
2924
+ generator,
2925
+ output.delivery,
2926
+ index
2927
+ )
2928
+ );
2929
+ const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
2930
+ language,
2931
+ output,
2932
+ generator
2933
+ });
2934
+ if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
2935
+ target.package = targetPackage;
2352
2936
  }
2353
2937
  const targetGeneration = {
2354
2938
  ...generations.targetOverrides[index],
@@ -2415,6 +2999,21 @@ function mapFernConfigToSdkConfigV1(input) {
2415
2999
  ])
2416
3000
  };
2417
3001
  }
3002
+ function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
3003
+ if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
3004
+ return packageConfig;
3005
+ }
3006
+ const { packageName } = packageConfig;
3007
+ return {
3008
+ ...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
3009
+ ...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
3010
+ ...packageConfig
3011
+ };
3012
+ }
3013
+ function usesCustomLicenseFile({ config, raw }) {
3014
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
3015
+ return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
3016
+ }
2418
3017
  function resolveLanguage(generator, index) {
2419
3018
  const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
2420
3019
  if (!language || !isFernLanguage(language)) {
@@ -2530,10 +3129,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
2530
3129
  ...optional("smartCasingDigitWordBoundary", smartCasingDigitWordBoundary)
2531
3130
  };
2532
3131
  }
2533
- const targetGeneration = mapLanguageConfig(language, config, state, packageConfig, [
2534
- ...prefix,
2535
- "config"
2536
- ]);
3132
+ const targetGeneration = mapLanguageConfig(
3133
+ language,
3134
+ config,
3135
+ state,
3136
+ packageConfig,
3137
+ [...prefix, "config"],
3138
+ index
3139
+ );
2537
3140
  mapPublishMetadata(generator.publishMetadata, packageConfig);
2538
3141
  if (generator.keywords?.length) {
2539
3142
  generation.reservedKeywords = [...generator.keywords];
@@ -2549,13 +3152,30 @@ function mapInvocation(generator, language, activeLanguages, index) {
2549
3152
  }
2550
3153
  }
2551
3154
  const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
3155
+ if (language === "typescript") {
3156
+ const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
3157
+ ...prefix,
3158
+ "config"
3159
+ ]);
3160
+ if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
3161
+ }
2552
3162
  const unsupportedFields = [
3163
+ ...state.valueDiagnostics ?? [],
2553
3164
  ...collectUnsupported(config, [...prefix, "config"], state),
2554
3165
  ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
2555
3166
  ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
2556
3167
  ...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
2557
3168
  ];
2558
- return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
3169
+ return {
3170
+ client,
3171
+ docs,
3172
+ generation,
3173
+ package: packageConfig,
3174
+ packageFallbacks: state.packageFallbacks ?? [],
3175
+ ...optional("cliDistribution", state.cliDistribution),
3176
+ targetGeneration,
3177
+ unsupportedFields
3178
+ };
2559
3179
  }
2560
3180
  function unsupportedResolvedFields(generator, index, idempotencyMapped) {
2561
3181
  const values = [
@@ -2719,7 +3339,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2719
3339
  });
2720
3340
  if (Object.keys(naming).length) generation.naming = naming;
2721
3341
  const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
2722
- if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
3342
+ const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
3343
+ if (wireTests !== void 0 || wireTestsFallback !== void 0) {
3344
+ generation.wireTests = { enabled: wireTests ?? true };
3345
+ if (wireTestsFallback !== void 0) {
3346
+ generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
3347
+ }
3348
+ }
2723
3349
  const webSockets = takeBoolean(
2724
3350
  config,
2725
3351
  ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
@@ -2745,6 +3371,7 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2745
3371
  const packagePath = takeString(config, ["packagePath"], state, basePath);
2746
3372
  if (packagePath !== void 0) generation.layout = { packagePath };
2747
3373
  mapDependencies(config, state, packageConfig, basePath);
3374
+ mapPeerDependenciesMeta(config, state, packageConfig, basePath);
2748
3375
  }
2749
3376
  function mapTypescriptStreams(config, state, basePath) {
2750
3377
  const responseType = takeEnum(config, ["streamType"], ["wrapper", "web"], state, basePath);
@@ -2758,13 +3385,13 @@ function mapTypescriptStreams(config, state, basePath) {
2758
3385
  if (responseType === void 0 && fileResponseType === void 0) return void 0;
2759
3386
  return { enabled: true, ...compact({ responseType, fileResponseType }) };
2760
3387
  }
2761
- function mapLanguageConfig(language, config, state, packageConfig, basePath) {
3388
+ function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
2762
3389
  switch (language) {
2763
3390
  case "typescript":
2764
- return mapTypescript(config, state, packageConfig, basePath);
3391
+ return mapTypescript(config, state, packageConfig, basePath, true);
2765
3392
  case "mcp":
2766
3393
  return {
2767
- ...mapTypescript(config, state, packageConfig, basePath),
3394
+ ...mapTypescript(config, state, packageConfig, basePath, false),
2768
3395
  ...mapMcp(config, state, basePath)
2769
3396
  };
2770
3397
  case "python":
@@ -2785,12 +3412,12 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath) {
2785
3412
  case "swift":
2786
3413
  return mapSwift(config, state, basePath);
2787
3414
  case "cli":
2788
- return mapCli(config, state, packageConfig, basePath);
3415
+ return mapCli(config, state, packageConfig, basePath, targetIndex);
2789
3416
  case "terraform":
2790
3417
  return mapTerraform(config, state, packageConfig, basePath);
2791
3418
  }
2792
3419
  }
2793
- function mapTypescript(config, state, packageConfig, basePath) {
3420
+ function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
2794
3421
  const packageJsonManifest = mapPackageManifest(
2795
3422
  config,
2796
3423
  ["packageJson"],
@@ -2802,18 +3429,75 @@ function mapTypescript(config, state, packageConfig, basePath) {
2802
3429
  const packageManagerAtIndex = packageJsonPackageManager ? packageJsonPackageManager.indexOf("@", packageJsonPackageManager.startsWith("@") ? 1 : 0) : -1;
2803
3430
  const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
2804
3431
  const packageManagerVersion = packageManagerVersionPart || void 0;
3432
+ if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
3433
+ const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
2805
3434
  const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
2806
3435
  const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
2807
- const fetchSupport = takeEnum(config, ["fetchSupport"], ["native"], state, basePath);
3436
+ const fetchSupport = takeEnum(
3437
+ config,
3438
+ ["fetchSupport"],
3439
+ sdkTarget ? ["native", "node-fetch"] : ["native"],
3440
+ state,
3441
+ basePath
3442
+ );
2808
3443
  const namingObject = takeObject(config, ["naming"], state, basePath);
2809
3444
  const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
3445
+ const sdkOnlyOptions = sdkTarget ? {
3446
+ formDataSupport: takeEnum(
3447
+ config,
3448
+ ["formDataSupport"],
3449
+ ["Node16", "Node18"],
3450
+ state,
3451
+ basePath
3452
+ ),
3453
+ allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
3454
+ generateSubpackageExports: takeBoolean(
3455
+ config,
3456
+ ["generateSubpackageExports"],
3457
+ state,
3458
+ basePath
3459
+ ),
3460
+ exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
3461
+ generateEndpointMetadata: takeBoolean(
3462
+ config,
3463
+ ["generateEndpointMetadata"],
3464
+ state,
3465
+ basePath
3466
+ ),
3467
+ outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
3468
+ neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
3469
+ includeOtherInUnionTypes: takeBoolean(
3470
+ config,
3471
+ ["includeOtherInUnionTypes"],
3472
+ state,
3473
+ basePath
3474
+ ),
3475
+ includeUtilsOnUnionMembers: takeBoolean(
3476
+ config,
3477
+ ["includeUtilsOnUnionMembers"],
3478
+ state,
3479
+ basePath
3480
+ ),
3481
+ omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
3482
+ linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
3483
+ formatter: takeEnum(
3484
+ config,
3485
+ ["formatter"],
3486
+ ["prettier", "biome", "oxfmt", "none"],
3487
+ state,
3488
+ basePath
3489
+ )
3490
+ } : {};
2810
3491
  return compact({
3492
+ ...sdkOnlyOptions,
3493
+ // Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
3494
+ ...manifestOptions,
2811
3495
  typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
2812
3496
  zodVersion: takeString(config, ["zodVersion"], state, basePath),
2813
3497
  packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
2814
3498
  packageManagerVersion,
2815
3499
  testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
2816
- httpClient: fetchSupport === "native" ? { name: "fetch" } : void 0,
3500
+ httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
2817
3501
  bundle: takeBoolean(config, ["bundle"], state, basePath),
2818
3502
  exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
2819
3503
  namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
@@ -2971,6 +3655,7 @@ function mapRust(config, state, packageConfig, basePath) {
2971
3655
  const description = takeString(config, ["packageDescription"], state, basePath);
2972
3656
  const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
2973
3657
  Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
3658
+ mapLicenseFallback(config, ["packageLicense"], state, basePath);
2974
3659
  return compact({
2975
3660
  dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
2976
3661
  capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
@@ -2984,7 +3669,7 @@ function mapSwift(config, state, basePath) {
2984
3669
  nullableAsOptional: takeBoolean(config, ["nullableAsOptional"], state, basePath)
2985
3670
  });
2986
3671
  }
2987
- function mapCli(config, state, packageConfig, basePath) {
3672
+ function mapCli(config, state, packageConfig, basePath, targetIndex) {
2988
3673
  const identity = takeObject(config, ["packageIdentity"], state, basePath);
2989
3674
  if (identity) {
2990
3675
  Object.assign(
@@ -2995,10 +3680,13 @@ function mapCli(config, state, packageConfig, basePath) {
2995
3680
  description: takeString(identity.value, ["description"], state, identity.path)
2996
3681
  })
2997
3682
  );
3683
+ mapCliPackageIdentity(identity, state, targetIndex);
2998
3684
  }
3685
+ mapCliDistribution(config, state, basePath, targetIndex);
2999
3686
  return compact({
3000
3687
  paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
3001
- skills: takeBoolean(config, ["skills"], state, basePath)
3688
+ skills: takeBoolean(config, ["skills"], state, basePath),
3689
+ ...mapCliGeneration(config, state, basePath, targetIndex)
3002
3690
  });
3003
3691
  }
3004
3692
  function mapTerraform(config, state, packageConfig, basePath) {
@@ -3082,6 +3770,48 @@ function mapDependencies(config, state, packageConfig, basePath) {
3082
3770
  if (dependencies.length) packageConfig[field] = dependencies;
3083
3771
  }
3084
3772
  }
3773
+ function liftPackageJsonDependencies(manifest, state, packageConfig) {
3774
+ for (const [field, target] of [
3775
+ ["dependencies", "extraDependencies"],
3776
+ ["devDependencies", "extraDevDependencies"],
3777
+ ["peerDependencies", "extraPeerDependencies"]
3778
+ ]) {
3779
+ const located = takeObject(manifest.value, [field], state, manifest.path);
3780
+ if (!located) continue;
3781
+ const lifted = Object.entries(located.value).flatMap(
3782
+ ([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
3783
+ );
3784
+ if (lifted.length) packageConfig[target] = overrideByName(packageConfig[target] ?? [], lifted);
3785
+ }
3786
+ const meta = takeObject(manifest.value, ["peerDependenciesMeta"], state, manifest.path);
3787
+ if (!meta) return;
3788
+ const entries = peerDependenciesMetaEntries(meta, state);
3789
+ if (entries.length) {
3790
+ packageConfig.extraPeerDependenciesMeta = {
3791
+ ...packageConfig.extraPeerDependenciesMeta,
3792
+ ...Object.fromEntries(entries)
3793
+ };
3794
+ }
3795
+ }
3796
+ function overrideByName(existing, overrides) {
3797
+ const byName = new Map(existing.map((dependency) => [dependency.name, dependency]));
3798
+ overrides.forEach((dependency) => byName.set(dependency.name, dependency));
3799
+ return [...byName.values()];
3800
+ }
3801
+ function mapPeerDependenciesMeta(config, state, packageConfig, basePath) {
3802
+ const located = takeObject(config, ["extraPeerDependenciesMeta"], state, basePath);
3803
+ if (!located) return;
3804
+ const entries = peerDependenciesMetaEntries(located, state);
3805
+ if (entries.length) packageConfig.extraPeerDependenciesMeta = Object.fromEntries(entries);
3806
+ }
3807
+ function peerDependenciesMetaEntries(located, state) {
3808
+ return Object.entries(located.value).flatMap(([name, value]) => {
3809
+ const parsed = jsonObjectSchema.safeParse(value);
3810
+ if (!parsed.success) return [];
3811
+ consume(state, [...located.path, name]);
3812
+ return [[name, parsed.data]];
3813
+ });
3814
+ }
3085
3815
  function mapDependency(name, value, state, path) {
3086
3816
  if (typeof value === "string" && value) {
3087
3817
  consume(state, path);
@@ -3089,13 +3819,7 @@ function mapDependency(name, value, state, path) {
3089
3819
  }
3090
3820
  if (!isObject(value)) return [];
3091
3821
  const version = takeString(value, ["version"], state, path);
3092
- const gitUrl = takeString(value, ["git"], state, path);
3093
- const localPath = takeString(value, ["path"], state, path);
3094
- const source = gitUrl ? {
3095
- type: "git",
3096
- url: gitUrl,
3097
- ...optional("ref", takeString(value, ["ref"], state, path))
3098
- } : localPath ? { type: "path", path: localPath } : void 0;
3822
+ const source = takeDependencySource(value, state, path);
3099
3823
  if (!version && !source) return [];
3100
3824
  return [
3101
3825
  {
@@ -3111,6 +3835,17 @@ function mapDependency(name, value, state, path) {
3111
3835
  }
3112
3836
  ];
3113
3837
  }
3838
+ function takeDependencySource(value, state, path) {
3839
+ const gitUrl = takeString(value, ["git"], state, path);
3840
+ if (gitUrl) {
3841
+ const ref = takeString(value, ["ref", "rev", "branch"], state, path);
3842
+ return { type: "git", url: gitUrl, ...optional("ref", ref) };
3843
+ }
3844
+ const localPath = takeString(value, ["path"], state, path);
3845
+ if (localPath) return { type: "path", path: localPath };
3846
+ const registry = takeString(value, ["registry"], state, path);
3847
+ return registry ? { type: "registry", registry } : void 0;
3848
+ }
3114
3849
  function takeCustomSections(value, language, activeLanguages, state, basePath) {
3115
3850
  const located = locate(value, ["customSections"], basePath);
3116
3851
  if (!located || !Array.isArray(located.value)) return void 0;
@@ -3159,6 +3894,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
3159
3894
  );
3160
3895
  return manifest;
3161
3896
  }
3897
+ function mapPackageManifestOptions(manifest, state, packageConfig) {
3898
+ const bugs = takeManifestBugs(manifest, state);
3899
+ if (bugs) packageConfig.bugs = bugs;
3900
+ const repository = takeManifestRepository(manifest, state);
3901
+ if (repository !== void 0 && packageConfig.repository === void 0) {
3902
+ packageConfig.repository = repository;
3903
+ }
3904
+ const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
3905
+ if (exports) consume(state, exports.path);
3906
+ return compact({
3907
+ exports: exports?.value,
3908
+ scripts: takeManifestScripts(manifest, state),
3909
+ files: takeStringArray(manifest.value, ["files"], state, manifest.path),
3910
+ engines: takeManifestStringRecord(manifest, "engines", state),
3911
+ lintStaged: takeManifestLintStaged(manifest, state),
3912
+ browser: takeManifestBrowser(manifest, state)
3913
+ });
3914
+ }
3915
+ function takeManifestBugs(manifest, state) {
3916
+ const text = takeString(manifest.value, ["bugs"], state, manifest.path);
3917
+ if (text !== void 0) return { url: text };
3918
+ const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
3919
+ if (!located) return void 0;
3920
+ const url = takeString(located.value, ["url"], state, located.path);
3921
+ const email = takeString(located.value, ["email"], state, located.path);
3922
+ return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
3923
+ }
3924
+ function takeManifestRepository(manifest, state) {
3925
+ const text = takeString(manifest.value, ["repository"], state, manifest.path);
3926
+ if (text !== void 0) return text;
3927
+ const located = takeObject(manifest.value, ["repository"], state, manifest.path);
3928
+ if (!located) return void 0;
3929
+ const url = takeString(located.value, ["url"], state, located.path);
3930
+ if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
3931
+ return url;
3932
+ }
3933
+ function takeManifestScripts(manifest, state) {
3934
+ const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
3935
+ if (!located) return void 0;
3936
+ const scripts = Object.entries(located.value).flatMap(([name, command]) => {
3937
+ if (typeof command !== "string" || !command) return [];
3938
+ consume(state, [...located.path, name]);
3939
+ return [{ name, command }];
3940
+ });
3941
+ return scripts.length ? scripts : void 0;
3942
+ }
3943
+ function takeManifestStringRecord(manifest, key, state) {
3944
+ const located = takeObject(manifest.value, [key], state, manifest.path);
3945
+ if (!located) return void 0;
3946
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3947
+ if (typeof value !== "string" || !value) return [];
3948
+ consume(state, [...located.path, name]);
3949
+ return [[name, value]];
3950
+ });
3951
+ return entries.length ? Object.fromEntries(entries) : void 0;
3952
+ }
3953
+ function takeManifestLintStaged(manifest, state) {
3954
+ const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
3955
+ if (!located) return void 0;
3956
+ const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
3957
+ const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
3958
+ if (!list?.length || list.some((command) => !command)) return [];
3959
+ consume(state, [...located.path, glob]);
3960
+ return [[glob, list]];
3961
+ });
3962
+ return entries.length ? Object.fromEntries(entries) : void 0;
3963
+ }
3964
+ function takeManifestBrowser(manifest, state) {
3965
+ const located = takeObject(manifest.value, ["browser"], state, manifest.path);
3966
+ if (!located) return void 0;
3967
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3968
+ if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
3969
+ consume(state, [...located.path, name]);
3970
+ return [[name, value]];
3971
+ });
3972
+ return entries.length ? Object.fromEntries(entries) : void 0;
3973
+ }
3162
3974
  function takeManifestAuthors(manifest, state) {
3163
3975
  const located = locate(manifest.value, ["authors"], manifest.path);
3164
3976
  if (!located || !Array.isArray(located.value)) return [];
@@ -3299,6 +4111,15 @@ var compatibilityConfigSchema = zod.z.strictObject({
3299
4111
  legacyInput: legacyInputSchema.optional().describe("Original producer input retained only for migration debugging."),
3300
4112
  unsupportedFields: zod.z.array(unsupportedFieldSchema).optional().describe("Legacy fields that could not be represented in normalized configuration.")
3301
4113
  });
4114
+
4115
+ // src/sdk-config-ir/v1/diagnostics.ts
4116
+ function getSdkConfigIrV1Diagnostics(config) {
4117
+ if (config.target.language !== "cli") {
4118
+ return [];
4119
+ }
4120
+ const diagnostic = cliDistributionModeDiagnostic(config.output, ["output"]);
4121
+ return diagnostic ? [diagnostic] : [];
4122
+ }
3302
4123
  var generationAssetSchema = zod.z.discriminatedUnion("type", [
3303
4124
  zod.z.strictObject({
3304
4125
  type: zod.z.literal("path").describe("Loads the generation asset from a relative path."),
@@ -3601,6 +4422,12 @@ var githubOutputSchema2 = zod.z.strictObject({
3601
4422
  /** Automatically merge the GitHub publishing PR. Defaults to false. */
3602
4423
  autoMerge: zod.z.boolean().default(false).describe("Whether the GitHub publisher automatically merges its pull request.")
3603
4424
  });
4425
+ var distributionShape = {
4426
+ /** Valid only for `cli` targets with GitHub delivery; secret names only, never values. */
4427
+ distribution: cliDistributionConfigSchema.optional().describe(
4428
+ "CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
4429
+ )
4430
+ };
3604
4431
  var credentialResolutionShape = {
3605
4432
  /** Where output credential references are resolved. */
3606
4433
  credentialResolution: credentialResolutionSchema.default("refs-only").describe("Where output credential references are resolved.")
@@ -3609,18 +4436,21 @@ var filesOutputSchema2 = zod.z.strictObject({
3609
4436
  delivery: zod.z.literal("files").describe("Writes the generated SDK to a directory."),
3610
4437
  path: nonEmptyStringSchema.optional().describe("The destination directory for generated files."),
3611
4438
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4439
+ ...distributionShape,
3612
4440
  ...credentialResolutionShape
3613
4441
  });
3614
4442
  var zipOutputSchema2 = zod.z.strictObject({
3615
4443
  delivery: zod.z.literal("zip").describe("Packages the generated SDK as a ZIP archive."),
3616
4444
  fileName: nonEmptyStringSchema.optional().describe("The generated ZIP archive file name."),
3617
4445
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4446
+ ...distributionShape,
3618
4447
  ...credentialResolutionShape
3619
4448
  });
3620
4449
  var githubDeliverySchema2 = zod.z.strictObject({
3621
4450
  delivery: zod.z.literal("github").describe("Delivers the generated SDK to GitHub."),
3622
4451
  github: githubOutputSchema2.describe("GitHub repository delivery settings."),
3623
4452
  publish: publishConfigSchema.optional().describe("Optional package registry publication."),
4453
+ ...distributionShape,
3624
4454
  ...credentialResolutionShape
3625
4455
  });
3626
4456
  var outputConfigSchema = zod.z.discriminatedUnion(
@@ -3705,7 +4535,7 @@ var targetConfigSchema = zod.z.strictObject({
3705
4535
  // src/sdk-config-ir/v1/sdk-config-ir-v1.ts
3706
4536
  var SDK_CONFIG_IR_V1_SCHEMA_VERSION = "sdk-config-ir/v1";
3707
4537
  var publishRegistryLanguages2 = {
3708
- npm: ["typescript", "mcp"],
4538
+ npm: ["typescript", "mcp", "cli"],
3709
4539
  pypi: ["python"],
3710
4540
  maven: ["java", "kotlin"],
3711
4541
  nuget: ["csharp"],
@@ -3760,6 +4590,28 @@ function validatePublishingIdentity2(packageConfig, registry, context) {
3760
4590
  });
3761
4591
  }
3762
4592
  }
4593
+ function validateCliOutput(output, language, context) {
4594
+ if (output.distribution !== void 0 && language !== "cli") {
4595
+ context.addIssue({
4596
+ code: "custom",
4597
+ message: `output.distribution is supported only for target language "cli", not "${language}"`,
4598
+ path: ["output", "distribution"]
4599
+ });
4600
+ } else if (output.distribution !== void 0 && output.delivery !== "github") {
4601
+ context.addIssue({
4602
+ code: "custom",
4603
+ message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
4604
+ path: ["output", "distribution"]
4605
+ });
4606
+ }
4607
+ if (language === "cli" && output.publish && output.delivery !== "github") {
4608
+ context.addIssue({
4609
+ code: "custom",
4610
+ message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
4611
+ path: ["output", "publish"]
4612
+ });
4613
+ }
4614
+ }
3763
4615
  var sdkConfigIrV1Schema = zod.z.strictObject({
3764
4616
  schemaVersion: zod.z.literal(SDK_CONFIG_IR_V1_SCHEMA_VERSION).describe("The version of the normalized SDK Config IR schema."),
3765
4617
  source: sourceConfigSchema.describe("Materialized API descriptions consumed by generation."),
@@ -3821,6 +4673,7 @@ var sdkConfigIrV1Schema = zod.z.strictObject({
3821
4673
  });
3822
4674
  }
3823
4675
  }
4676
+ validateCliOutput(output, target.language, context);
3824
4677
  if (compatibility?.legacyInput) {
3825
4678
  const expectedKind = target.sourceOrigin === "postman" ? "postman-build-parameters" : "fern-generator-invocation";
3826
4679
  if (compatibility.legacyInput.kind !== expectedKind) {
@@ -3860,13 +4713,19 @@ function parseSdkConfigIrV1ForConsumption(value) {
3860
4713
  return parseSdkConfigIrV1(stripUnknownProperties(value, sdkConfigIrV1InputJsonSchema));
3861
4714
  }
3862
4715
 
4716
+ exports.CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE;
3863
4717
  exports.FernConfigMappingError = FernConfigMappingError;
3864
4718
  exports.SDK_CONFIG_IR_V1_SCHEMA_VERSION = SDK_CONFIG_IR_V1_SCHEMA_VERSION;
4719
+ exports.SDK_CONFIG_V1_CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE;
3865
4720
  exports.SDK_CONFIG_V1_SCHEMA_VERSION = SDK_CONFIG_V1_SCHEMA_VERSION;
3866
4721
  exports.apiConfigSchema = apiConfigSchema;
3867
4722
  exports.apiImportSettingsSchema = apiImportSettingsSchema;
3868
4723
  exports.authConfigSchema = authConfigSchema;
3869
4724
  exports.authSchemeSchema = authSchemeSchema;
4725
+ exports.cliDistributionConfigSchema = cliDistributionConfigSchema;
4726
+ exports.cliDistributionGithubAppSchema = cliDistributionGithubAppSchema;
4727
+ exports.cliDistributionHomebrewSchema = cliDistributionHomebrewSchema;
4728
+ exports.cliDistributionScoopSchema = cliDistributionScoopSchema;
3870
4729
  exports.cliGenerationConfigSchema = cliGenerationConfigSchema;
3871
4730
  exports.clientConfigOverrideSchema = clientConfigOverrideSchema;
3872
4731
  exports.clientConfigSchema = clientConfigSchema;
@@ -3878,6 +4737,9 @@ exports.dependencySchema = dependencySchema;
3878
4737
  exports.docsConfigSchema = docsConfigSchema;
3879
4738
  exports.exactSemverSchema = exactSemverSchema;
3880
4739
  exports.generationConfigSchema = generationConfigSchema;
4740
+ exports.getSdkConfigIrV1Diagnostics = getSdkConfigIrV1Diagnostics;
4741
+ exports.getSdkConfigV1Diagnostics = getSdkConfigV1Diagnostics;
4742
+ exports.githubActionsSecretNameSchema = githubActionsSecretNameSchema;
3881
4743
  exports.goGenerationConfigSchema = goGenerationConfigSchema;
3882
4744
  exports.goModulePathSchema = goModulePathSchema;
3883
4745
  exports.javaGenerationConfigSchema = javaGenerationConfigSchema;
@@ -3911,7 +4773,12 @@ exports.sdkConfigIrV1Schema = sdkConfigIrV1Schema;
3911
4773
  exports.sdkConfigV1ApiConfigSchema = sdkConfigV1ApiConfigSchema;
3912
4774
  exports.sdkConfigV1AuthConfigSchema = sdkConfigV1AuthConfigSchema;
3913
4775
  exports.sdkConfigV1AuthSchemeSchema = sdkConfigV1AuthSchemeSchema;
4776
+ exports.sdkConfigV1CliDistributionConfigSchema = cliDistributionConfigSchema;
4777
+ exports.sdkConfigV1CliDistributionGithubAppSchema = cliDistributionGithubAppSchema;
4778
+ exports.sdkConfigV1CliDistributionHomebrewSchema = cliDistributionHomebrewSchema;
4779
+ exports.sdkConfigV1CliDistributionScoopSchema = cliDistributionScoopSchema;
3914
4780
  exports.sdkConfigV1CliGenerationConfigSchema = cliGenerationConfigSchema;
4781
+ exports.sdkConfigV1CliOutputConfigSchema = sdkConfigV1CliOutputConfigSchema;
3915
4782
  exports.sdkConfigV1ClientConfigOverrideSchema = sdkConfigV1ClientConfigOverrideSchema;
3916
4783
  exports.sdkConfigV1ClientConfigSchema = sdkConfigV1ClientConfigSchema;
3917
4784
  exports.sdkConfigV1ComposerPackageNameSchema = composerPackageNameSchema;
@@ -3921,6 +4788,7 @@ exports.sdkConfigV1DocsConfigSchema = sdkConfigV1DocsConfigSchema;
3921
4788
  exports.sdkConfigV1ExactSemverSchema = exactSemverSchema;
3922
4789
  exports.sdkConfigV1GenerationConfigOverrideSchema = sdkConfigV1GenerationConfigOverrideSchema;
3923
4790
  exports.sdkConfigV1GenerationConfigSchema = sdkConfigV1GenerationConfigSchema;
4791
+ exports.sdkConfigV1GithubActionsSecretNameSchema = githubActionsSecretNameSchema;
3924
4792
  exports.sdkConfigV1GoGenerationConfigSchema = goGenerationConfigSchema;
3925
4793
  exports.sdkConfigV1GoModulePathSchema = goModulePathSchema;
3926
4794
  exports.sdkConfigV1JavaGenerationConfigSchema = javaGenerationConfigSchema;