@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.
- package/README.md +6 -0
- package/dist/index.cjs +909 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +895 -42
- package/dist/index.js.map +1 -1
- package/dist/sdk-config/index.cjs +861 -41
- package/dist/sdk-config/index.cjs.map +1 -1
- package/dist/sdk-config/index.d.cts +2 -2
- package/dist/sdk-config/index.d.ts +2 -2
- package/dist/sdk-config/index.js +854 -42
- package/dist/sdk-config/index.js.map +1 -1
- package/dist/sdk-config/v1/index.cjs +861 -41
- package/dist/sdk-config/v1/index.cjs.map +1 -1
- package/dist/sdk-config/v1/index.d.cts +3345 -2632
- package/dist/sdk-config/v1/index.d.ts +3345 -2632
- package/dist/sdk-config/v1/index.js +854 -42
- package/dist/sdk-config/v1/index.js.map +1 -1
- package/dist/sdk-config-ir/index.cjs +286 -5
- package/dist/sdk-config-ir/index.cjs.map +1 -1
- package/dist/sdk-config-ir/index.d.cts +2 -2
- package/dist/sdk-config-ir/index.d.ts +2 -2
- package/dist/sdk-config-ir/index.js +280 -6
- package/dist/sdk-config-ir/index.js.map +1 -1
- package/dist/sdk-config-ir/v1/index.cjs +286 -5
- package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
- package/dist/sdk-config-ir/v1/index.d.cts +3291 -2958
- package/dist/sdk-config-ir/v1/index.d.ts +3291 -2958
- package/dist/sdk-config-ir/v1/index.js +280 -6
- package/dist/sdk-config-ir/v1/index.js.map +1 -1
- package/dist/{typescript-Chge0X4f.d.cts → typescript-Byhn4MqL.d.cts} +145 -1
- package/dist/{typescript-Chge0X4f.d.ts → typescript-Byhn4MqL.d.ts} +145 -1
- package/package.json +1 -1
- package/src/sdk-config/v1/README.md +183 -1
- package/src/sdk-config-ir/v1/README.md +107 -31
|
@@ -33,7 +33,7 @@ var jsonValueSchema = zod.z.lazy(
|
|
|
33
33
|
zod.z.record(zod.z.string(), jsonValueSchema)
|
|
34
34
|
])
|
|
35
35
|
);
|
|
36
|
-
zod.z.record(zod.z.string(), jsonValueSchema);
|
|
36
|
+
var jsonObjectSchema = zod.z.record(zod.z.string(), jsonValueSchema);
|
|
37
37
|
var hashAlgorithmSchema = zod.z.enum(["sha1", "sha256", "sha384", "sha512"]);
|
|
38
38
|
var encodingSchema = zod.z.enum(["base64", "hex"]);
|
|
39
39
|
var payloadComponentSchema = zod.z.enum(["body", "timestamp", "notification-url", "message-id"]);
|
|
@@ -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
|
+
)
|
|
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
|
+
)
|
|
457
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 ?
|
|
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, {
|
|
@@ -1707,7 +2209,16 @@ var sdkConfigV1PublishConfigSchema = zod.z.discriminatedUnion("registry", [
|
|
|
1707
2209
|
zod.z.strictObject({
|
|
1708
2210
|
registry: zod.z.literal("npm").describe("Publishes the package to an npm-compatible registry."),
|
|
1709
2211
|
token: nonEmptyStringSchema.optional().describe("The npm registry token, or an environment expression that resolves to it."),
|
|
2212
|
+
trustedPublishing: zod.z.boolean().optional().describe("Whether npm publication uses trusted publishing (OIDC) instead of a token."),
|
|
1710
2213
|
...commonPublishShape
|
|
2214
|
+
}).superRefine((publish, context) => {
|
|
2215
|
+
if (publish.trustedPublishing === true && publish.token !== void 0) {
|
|
2216
|
+
context.addIssue({
|
|
2217
|
+
code: "custom",
|
|
2218
|
+
message: "token must be omitted when trustedPublishing is true",
|
|
2219
|
+
path: ["token"]
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
1711
2222
|
}),
|
|
1712
2223
|
zod.z.strictObject({
|
|
1713
2224
|
registry: zod.z.literal("pypi").describe("Publishes the package to a PyPI-compatible registry."),
|
|
@@ -1785,10 +2296,29 @@ var sdkConfigV1OutputConfigSchema = zod.z.discriminatedUnion(
|
|
|
1785
2296
|
[filesOutputSchema, zipOutputSchema, githubDeliverySchema],
|
|
1786
2297
|
{ error: 'output.delivery must be one of "files", "zip", or "github"' }
|
|
1787
2298
|
);
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2299
|
+
var cliDistributionShape = {
|
|
2300
|
+
distribution: cliDistributionConfigSchema.optional().describe(
|
|
2301
|
+
"CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
|
|
2302
|
+
)
|
|
2303
|
+
};
|
|
2304
|
+
function rejectDistributionWithoutGithub(output, context) {
|
|
2305
|
+
if (output.distribution !== void 0) {
|
|
2306
|
+
context.addIssue({
|
|
2307
|
+
code: "custom",
|
|
2308
|
+
message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
|
|
2309
|
+
path: ["distribution"]
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
var sdkConfigV1CliOutputConfigSchema = zod.z.discriminatedUnion(
|
|
2314
|
+
"delivery",
|
|
2315
|
+
[
|
|
2316
|
+
filesOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
|
|
2317
|
+
zipOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
|
|
2318
|
+
githubDeliverySchema.extend(cliDistributionShape)
|
|
2319
|
+
],
|
|
2320
|
+
{ error: 'output.delivery must be one of "files", "zip", or "github"' }
|
|
2321
|
+
);
|
|
1792
2322
|
var sdkConfigV1ReplayConfigSchema = zod.z.strictObject({
|
|
1793
2323
|
enabled: zod.z.boolean().describe("Whether regeneration reapplies customer-authored repository changes.")
|
|
1794
2324
|
});
|
|
@@ -1865,10 +2395,6 @@ var sdkConfigV1SourceConfigSchema = zod.z.strictObject({
|
|
|
1865
2395
|
seenIds.add(id);
|
|
1866
2396
|
});
|
|
1867
2397
|
});
|
|
1868
|
-
var cliGenerationConfigSchema = zod.z.strictObject({
|
|
1869
|
-
paginationParameters: zod.z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
|
|
1870
|
-
skills: zod.z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands.")
|
|
1871
|
-
});
|
|
1872
2398
|
var csharpGenerationConfigSchema = zod.z.strictObject({
|
|
1873
2399
|
useOptionalWrapper: zod.z.boolean().optional().describe("Whether optional values use an explicit Optional wrapper."),
|
|
1874
2400
|
simplifyObjectDictionaries: zod.z.boolean().optional().describe("Whether object schemas with arbitrary values use simplified dictionary types."),
|
|
@@ -1916,7 +2442,7 @@ var packageScriptSchema = zod.z.strictObject({
|
|
|
1916
2442
|
command: nonEmptyStringSchema.describe("The command executed by the package script.")
|
|
1917
2443
|
});
|
|
1918
2444
|
var httpClientSchema = zod.z.strictObject({
|
|
1919
|
-
name: zod.z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
|
|
2445
|
+
name: zod.z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
|
|
1920
2446
|
});
|
|
1921
2447
|
var typescriptGenerationConfigSchema = zod.z.strictObject({
|
|
1922
2448
|
typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
|
|
@@ -1932,6 +2458,37 @@ var typescriptGenerationConfigSchema = zod.z.strictObject({
|
|
|
1932
2458
|
/** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
|
|
1933
2459
|
namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
|
|
1934
2460
|
consolidateTypeFiles: zod.z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
|
|
2461
|
+
formDataSupport: zod.z.enum(["Node16", "Node18"]).optional().describe(
|
|
2462
|
+
"The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
|
|
2463
|
+
),
|
|
2464
|
+
allowExtraFields: zod.z.boolean().optional().describe(
|
|
2465
|
+
"Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
|
|
2466
|
+
),
|
|
2467
|
+
generateSubpackageExports: zod.z.boolean().optional().describe(
|
|
2468
|
+
"Whether the package manifest exports each subpackage client as its own entry point."
|
|
2469
|
+
),
|
|
2470
|
+
exportAllRequestsAtRoot: zod.z.boolean().optional().describe("Whether every request type is also exported from the package root."),
|
|
2471
|
+
generateEndpointMetadata: zod.z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
|
|
2472
|
+
outputEsm: zod.z.boolean().optional().describe(
|
|
2473
|
+
"Whether the package is marked as an ES module while still shipping its CommonJS build."
|
|
2474
|
+
),
|
|
2475
|
+
neverThrowErrors: zod.z.boolean().optional().describe(
|
|
2476
|
+
"Whether client methods return a wrapped response instead of throwing on a non-2xx status."
|
|
2477
|
+
),
|
|
2478
|
+
includeOtherInUnionTypes: zod.z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
|
|
2479
|
+
includeUtilsOnUnionMembers: zod.z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
|
|
2480
|
+
omitFernHeaders: zod.z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
|
|
2481
|
+
linter: zod.z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
|
|
2482
|
+
formatter: zod.z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
|
|
2483
|
+
exports: jsonObjectSchema.optional().describe(
|
|
2484
|
+
"package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
|
|
2485
|
+
),
|
|
2486
|
+
files: zod.z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
|
|
2487
|
+
engines: zod.z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
|
|
2488
|
+
lintStaged: zod.z.record(nonEmptyStringSchema, zod.z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
|
|
2489
|
+
browser: zod.z.record(nonEmptyStringSchema, zod.z.union([zod.z.boolean(), nonEmptyStringSchema])).optional().describe(
|
|
2490
|
+
"package.json browser field: a module or file is excluded (false) or replaced by another path."
|
|
2491
|
+
),
|
|
1935
2492
|
allowCustomFetcher: zod.z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
|
|
1936
2493
|
useBrandedStringAliases: zod.z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
|
|
1937
2494
|
useLegacyExports: zod.z.boolean().optional().describe("Whether the package emits the legacy export layout."),
|
|
@@ -2121,7 +2678,10 @@ var sdkConfigV1TargetSchema = zod.z.discriminatedUnion("language", [
|
|
|
2121
2678
|
zod.z.strictObject({
|
|
2122
2679
|
language: zod.z.literal("cli").describe("Generates a command-line interface."),
|
|
2123
2680
|
generation: sdkConfigV1GenerationConfigOverrideSchema.extend(cliGenerationConfigSchema.shape).optional().describe("Common and CLI-specific generation settings for this target."),
|
|
2124
|
-
...targetOverrideShape
|
|
2681
|
+
...targetOverrideShape,
|
|
2682
|
+
output: sdkConfigV1CliOutputConfigSchema.optional().describe(
|
|
2683
|
+
"Output configuration, including optional CLI distribution channels, that replaces the root output for this target."
|
|
2684
|
+
)
|
|
2125
2685
|
}),
|
|
2126
2686
|
zod.z.strictObject({
|
|
2127
2687
|
language: zod.z.literal("mcp").describe("Generates an MCP server."),
|
|
@@ -2138,7 +2698,7 @@ var sdkConfigV1TargetSchema = zod.z.discriminatedUnion("language", [
|
|
|
2138
2698
|
// src/sdk-config/v1/sdk-config-v1.ts
|
|
2139
2699
|
var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
|
|
2140
2700
|
var publishRegistryLanguages = {
|
|
2141
|
-
npm: ["typescript", "mcp"],
|
|
2701
|
+
npm: ["typescript", "mcp", "cli"],
|
|
2142
2702
|
pypi: ["python"],
|
|
2143
2703
|
maven: ["java", "kotlin"],
|
|
2144
2704
|
nuget: ["csharp"],
|
|
@@ -2215,6 +2775,13 @@ function validateTargetPublishing(target, targetIndex, globalPackage, globalOutp
|
|
|
2215
2775
|
});
|
|
2216
2776
|
return;
|
|
2217
2777
|
}
|
|
2778
|
+
if (target.language === "cli" && output.delivery !== "github") {
|
|
2779
|
+
context.addIssue({
|
|
2780
|
+
code: "custom",
|
|
2781
|
+
message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
|
|
2782
|
+
path: target.output ? ["targets", targetIndex, "output", "delivery"] : ["output", "delivery"]
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2218
2785
|
validatePublishingIdentity(
|
|
2219
2786
|
{ ...globalPackage, ...target.package },
|
|
2220
2787
|
registry,
|
|
@@ -2327,16 +2894,33 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2327
2894
|
package: outputPackage,
|
|
2328
2895
|
generation: outputGeneration
|
|
2329
2896
|
}, index) => {
|
|
2897
|
+
const distribution = applyCliDistribution(output, invocation.cliDistribution, index);
|
|
2898
|
+
invocation.unsupportedFields.push(...distribution.diagnostics);
|
|
2330
2899
|
const target = {
|
|
2331
2900
|
language,
|
|
2332
|
-
output,
|
|
2901
|
+
output: distribution.output,
|
|
2333
2902
|
...optional("sdkName", generator.sdkName),
|
|
2334
2903
|
...optional("sdkVersion", generator.sdkVersion),
|
|
2335
2904
|
...optional("client", clients.targetOverrides[index]),
|
|
2336
2905
|
...optional("docs", docs.targetOverrides[index])
|
|
2337
2906
|
};
|
|
2338
|
-
|
|
2339
|
-
|
|
2907
|
+
const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
|
|
2908
|
+
invocation.unsupportedFields.push(
|
|
2909
|
+
...resolveTargetPackage(
|
|
2910
|
+
mappedPackage,
|
|
2911
|
+
invocation.packageFallbacks,
|
|
2912
|
+
generator,
|
|
2913
|
+
output.delivery,
|
|
2914
|
+
index
|
|
2915
|
+
)
|
|
2916
|
+
);
|
|
2917
|
+
const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
|
|
2918
|
+
language,
|
|
2919
|
+
output,
|
|
2920
|
+
generator
|
|
2921
|
+
});
|
|
2922
|
+
if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
|
|
2923
|
+
target.package = targetPackage;
|
|
2340
2924
|
}
|
|
2341
2925
|
const targetGeneration = {
|
|
2342
2926
|
...generations.targetOverrides[index],
|
|
@@ -2403,6 +2987,21 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2403
2987
|
])
|
|
2404
2988
|
};
|
|
2405
2989
|
}
|
|
2990
|
+
function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
|
|
2991
|
+
if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
|
|
2992
|
+
return packageConfig;
|
|
2993
|
+
}
|
|
2994
|
+
const { packageName } = packageConfig;
|
|
2995
|
+
return {
|
|
2996
|
+
...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
|
|
2997
|
+
...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
|
|
2998
|
+
...packageConfig
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
function usesCustomLicenseFile({ config, raw }) {
|
|
3002
|
+
const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
|
|
3003
|
+
return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
|
|
3004
|
+
}
|
|
2406
3005
|
function resolveLanguage(generator, index) {
|
|
2407
3006
|
const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
|
|
2408
3007
|
if (!language || !isFernLanguage(language)) {
|
|
@@ -2518,10 +3117,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
|
|
|
2518
3117
|
...optional("smartCasingDigitWordBoundary", smartCasingDigitWordBoundary)
|
|
2519
3118
|
};
|
|
2520
3119
|
}
|
|
2521
|
-
const targetGeneration = mapLanguageConfig(
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
3120
|
+
const targetGeneration = mapLanguageConfig(
|
|
3121
|
+
language,
|
|
3122
|
+
config,
|
|
3123
|
+
state,
|
|
3124
|
+
packageConfig,
|
|
3125
|
+
[...prefix, "config"],
|
|
3126
|
+
index
|
|
3127
|
+
);
|
|
2525
3128
|
mapPublishMetadata(generator.publishMetadata, packageConfig);
|
|
2526
3129
|
if (generator.keywords?.length) {
|
|
2527
3130
|
generation.reservedKeywords = [...generator.keywords];
|
|
@@ -2537,13 +3140,30 @@ function mapInvocation(generator, language, activeLanguages, index) {
|
|
|
2537
3140
|
}
|
|
2538
3141
|
}
|
|
2539
3142
|
const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
|
|
3143
|
+
if (language === "typescript") {
|
|
3144
|
+
const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
|
|
3145
|
+
...prefix,
|
|
3146
|
+
"config"
|
|
3147
|
+
]);
|
|
3148
|
+
if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
|
|
3149
|
+
}
|
|
2540
3150
|
const unsupportedFields = [
|
|
3151
|
+
...state.valueDiagnostics ?? [],
|
|
2541
3152
|
...collectUnsupported(config, [...prefix, "config"], state),
|
|
2542
3153
|
...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
|
|
2543
3154
|
...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
|
|
2544
3155
|
...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
|
|
2545
3156
|
];
|
|
2546
|
-
return {
|
|
3157
|
+
return {
|
|
3158
|
+
client,
|
|
3159
|
+
docs,
|
|
3160
|
+
generation,
|
|
3161
|
+
package: packageConfig,
|
|
3162
|
+
packageFallbacks: state.packageFallbacks ?? [],
|
|
3163
|
+
...optional("cliDistribution", state.cliDistribution),
|
|
3164
|
+
targetGeneration,
|
|
3165
|
+
unsupportedFields
|
|
3166
|
+
};
|
|
2547
3167
|
}
|
|
2548
3168
|
function unsupportedResolvedFields(generator, index, idempotencyMapped) {
|
|
2549
3169
|
const values = [
|
|
@@ -2707,7 +3327,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
|
|
|
2707
3327
|
});
|
|
2708
3328
|
if (Object.keys(naming).length) generation.naming = naming;
|
|
2709
3329
|
const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
|
|
2710
|
-
|
|
3330
|
+
const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
|
|
3331
|
+
if (wireTests !== void 0 || wireTestsFallback !== void 0) {
|
|
3332
|
+
generation.wireTests = { enabled: wireTests ?? true };
|
|
3333
|
+
if (wireTestsFallback !== void 0) {
|
|
3334
|
+
generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
2711
3337
|
const webSockets = takeBoolean(
|
|
2712
3338
|
config,
|
|
2713
3339
|
["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
|
|
@@ -2733,6 +3359,7 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
|
|
|
2733
3359
|
const packagePath = takeString(config, ["packagePath"], state, basePath);
|
|
2734
3360
|
if (packagePath !== void 0) generation.layout = { packagePath };
|
|
2735
3361
|
mapDependencies(config, state, packageConfig, basePath);
|
|
3362
|
+
mapPeerDependenciesMeta(config, state, packageConfig, basePath);
|
|
2736
3363
|
}
|
|
2737
3364
|
function mapTypescriptStreams(config, state, basePath) {
|
|
2738
3365
|
const responseType = takeEnum(config, ["streamType"], ["wrapper", "web"], state, basePath);
|
|
@@ -2746,13 +3373,13 @@ function mapTypescriptStreams(config, state, basePath) {
|
|
|
2746
3373
|
if (responseType === void 0 && fileResponseType === void 0) return void 0;
|
|
2747
3374
|
return { enabled: true, ...compact({ responseType, fileResponseType }) };
|
|
2748
3375
|
}
|
|
2749
|
-
function mapLanguageConfig(language, config, state, packageConfig, basePath) {
|
|
3376
|
+
function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
|
|
2750
3377
|
switch (language) {
|
|
2751
3378
|
case "typescript":
|
|
2752
|
-
return mapTypescript(config, state, packageConfig, basePath);
|
|
3379
|
+
return mapTypescript(config, state, packageConfig, basePath, true);
|
|
2753
3380
|
case "mcp":
|
|
2754
3381
|
return {
|
|
2755
|
-
...mapTypescript(config, state, packageConfig, basePath),
|
|
3382
|
+
...mapTypescript(config, state, packageConfig, basePath, false),
|
|
2756
3383
|
...mapMcp(config, state, basePath)
|
|
2757
3384
|
};
|
|
2758
3385
|
case "python":
|
|
@@ -2773,12 +3400,12 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath) {
|
|
|
2773
3400
|
case "swift":
|
|
2774
3401
|
return mapSwift(config, state, basePath);
|
|
2775
3402
|
case "cli":
|
|
2776
|
-
return mapCli(config, state, packageConfig, basePath);
|
|
3403
|
+
return mapCli(config, state, packageConfig, basePath, targetIndex);
|
|
2777
3404
|
case "terraform":
|
|
2778
3405
|
return mapTerraform(config, state, packageConfig, basePath);
|
|
2779
3406
|
}
|
|
2780
3407
|
}
|
|
2781
|
-
function mapTypescript(config, state, packageConfig, basePath) {
|
|
3408
|
+
function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
|
|
2782
3409
|
const packageJsonManifest = mapPackageManifest(
|
|
2783
3410
|
config,
|
|
2784
3411
|
["packageJson"],
|
|
@@ -2790,18 +3417,75 @@ function mapTypescript(config, state, packageConfig, basePath) {
|
|
|
2790
3417
|
const packageManagerAtIndex = packageJsonPackageManager ? packageJsonPackageManager.indexOf("@", packageJsonPackageManager.startsWith("@") ? 1 : 0) : -1;
|
|
2791
3418
|
const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
|
|
2792
3419
|
const packageManagerVersion = packageManagerVersionPart || void 0;
|
|
3420
|
+
if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
|
|
3421
|
+
const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
|
|
2793
3422
|
const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
|
|
2794
3423
|
const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
|
|
2795
|
-
const fetchSupport = takeEnum(
|
|
3424
|
+
const fetchSupport = takeEnum(
|
|
3425
|
+
config,
|
|
3426
|
+
["fetchSupport"],
|
|
3427
|
+
sdkTarget ? ["native", "node-fetch"] : ["native"],
|
|
3428
|
+
state,
|
|
3429
|
+
basePath
|
|
3430
|
+
);
|
|
2796
3431
|
const namingObject = takeObject(config, ["naming"], state, basePath);
|
|
2797
3432
|
const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
|
|
3433
|
+
const sdkOnlyOptions = sdkTarget ? {
|
|
3434
|
+
formDataSupport: takeEnum(
|
|
3435
|
+
config,
|
|
3436
|
+
["formDataSupport"],
|
|
3437
|
+
["Node16", "Node18"],
|
|
3438
|
+
state,
|
|
3439
|
+
basePath
|
|
3440
|
+
),
|
|
3441
|
+
allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
|
|
3442
|
+
generateSubpackageExports: takeBoolean(
|
|
3443
|
+
config,
|
|
3444
|
+
["generateSubpackageExports"],
|
|
3445
|
+
state,
|
|
3446
|
+
basePath
|
|
3447
|
+
),
|
|
3448
|
+
exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
|
|
3449
|
+
generateEndpointMetadata: takeBoolean(
|
|
3450
|
+
config,
|
|
3451
|
+
["generateEndpointMetadata"],
|
|
3452
|
+
state,
|
|
3453
|
+
basePath
|
|
3454
|
+
),
|
|
3455
|
+
outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
|
|
3456
|
+
neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
|
|
3457
|
+
includeOtherInUnionTypes: takeBoolean(
|
|
3458
|
+
config,
|
|
3459
|
+
["includeOtherInUnionTypes"],
|
|
3460
|
+
state,
|
|
3461
|
+
basePath
|
|
3462
|
+
),
|
|
3463
|
+
includeUtilsOnUnionMembers: takeBoolean(
|
|
3464
|
+
config,
|
|
3465
|
+
["includeUtilsOnUnionMembers"],
|
|
3466
|
+
state,
|
|
3467
|
+
basePath
|
|
3468
|
+
),
|
|
3469
|
+
omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
|
|
3470
|
+
linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
|
|
3471
|
+
formatter: takeEnum(
|
|
3472
|
+
config,
|
|
3473
|
+
["formatter"],
|
|
3474
|
+
["prettier", "biome", "oxfmt", "none"],
|
|
3475
|
+
state,
|
|
3476
|
+
basePath
|
|
3477
|
+
)
|
|
3478
|
+
} : {};
|
|
2798
3479
|
return compact({
|
|
3480
|
+
...sdkOnlyOptions,
|
|
3481
|
+
// Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
|
|
3482
|
+
...manifestOptions,
|
|
2799
3483
|
typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
|
|
2800
3484
|
zodVersion: takeString(config, ["zodVersion"], state, basePath),
|
|
2801
3485
|
packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
|
|
2802
3486
|
packageManagerVersion,
|
|
2803
3487
|
testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
|
|
2804
|
-
httpClient: fetchSupport ===
|
|
3488
|
+
httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
|
|
2805
3489
|
bundle: takeBoolean(config, ["bundle"], state, basePath),
|
|
2806
3490
|
exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
|
|
2807
3491
|
namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
|
|
@@ -2959,6 +3643,7 @@ function mapRust(config, state, packageConfig, basePath) {
|
|
|
2959
3643
|
const description = takeString(config, ["packageDescription"], state, basePath);
|
|
2960
3644
|
const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
|
|
2961
3645
|
Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
|
|
3646
|
+
mapLicenseFallback(config, ["packageLicense"], state, basePath);
|
|
2962
3647
|
return compact({
|
|
2963
3648
|
dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
|
|
2964
3649
|
capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
|
|
@@ -2972,7 +3657,7 @@ function mapSwift(config, state, basePath) {
|
|
|
2972
3657
|
nullableAsOptional: takeBoolean(config, ["nullableAsOptional"], state, basePath)
|
|
2973
3658
|
});
|
|
2974
3659
|
}
|
|
2975
|
-
function mapCli(config, state, packageConfig, basePath) {
|
|
3660
|
+
function mapCli(config, state, packageConfig, basePath, targetIndex) {
|
|
2976
3661
|
const identity = takeObject(config, ["packageIdentity"], state, basePath);
|
|
2977
3662
|
if (identity) {
|
|
2978
3663
|
Object.assign(
|
|
@@ -2983,10 +3668,13 @@ function mapCli(config, state, packageConfig, basePath) {
|
|
|
2983
3668
|
description: takeString(identity.value, ["description"], state, identity.path)
|
|
2984
3669
|
})
|
|
2985
3670
|
);
|
|
3671
|
+
mapCliPackageIdentity(identity, state, targetIndex);
|
|
2986
3672
|
}
|
|
3673
|
+
mapCliDistribution(config, state, basePath, targetIndex);
|
|
2987
3674
|
return compact({
|
|
2988
3675
|
paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
|
|
2989
|
-
skills: takeBoolean(config, ["skills"], state, basePath)
|
|
3676
|
+
skills: takeBoolean(config, ["skills"], state, basePath),
|
|
3677
|
+
...mapCliGeneration(config, state, basePath, targetIndex)
|
|
2990
3678
|
});
|
|
2991
3679
|
}
|
|
2992
3680
|
function mapTerraform(config, state, packageConfig, basePath) {
|
|
@@ -3070,6 +3758,48 @@ function mapDependencies(config, state, packageConfig, basePath) {
|
|
|
3070
3758
|
if (dependencies.length) packageConfig[field] = dependencies;
|
|
3071
3759
|
}
|
|
3072
3760
|
}
|
|
3761
|
+
function liftPackageJsonDependencies(manifest, state, packageConfig) {
|
|
3762
|
+
for (const [field, target] of [
|
|
3763
|
+
["dependencies", "extraDependencies"],
|
|
3764
|
+
["devDependencies", "extraDevDependencies"],
|
|
3765
|
+
["peerDependencies", "extraPeerDependencies"]
|
|
3766
|
+
]) {
|
|
3767
|
+
const located = takeObject(manifest.value, [field], state, manifest.path);
|
|
3768
|
+
if (!located) continue;
|
|
3769
|
+
const lifted = Object.entries(located.value).flatMap(
|
|
3770
|
+
([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
|
|
3771
|
+
);
|
|
3772
|
+
if (lifted.length) packageConfig[target] = overrideByName(packageConfig[target] ?? [], lifted);
|
|
3773
|
+
}
|
|
3774
|
+
const meta = takeObject(manifest.value, ["peerDependenciesMeta"], state, manifest.path);
|
|
3775
|
+
if (!meta) return;
|
|
3776
|
+
const entries = peerDependenciesMetaEntries(meta, state);
|
|
3777
|
+
if (entries.length) {
|
|
3778
|
+
packageConfig.extraPeerDependenciesMeta = {
|
|
3779
|
+
...packageConfig.extraPeerDependenciesMeta,
|
|
3780
|
+
...Object.fromEntries(entries)
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
function overrideByName(existing, overrides) {
|
|
3785
|
+
const byName = new Map(existing.map((dependency) => [dependency.name, dependency]));
|
|
3786
|
+
overrides.forEach((dependency) => byName.set(dependency.name, dependency));
|
|
3787
|
+
return [...byName.values()];
|
|
3788
|
+
}
|
|
3789
|
+
function mapPeerDependenciesMeta(config, state, packageConfig, basePath) {
|
|
3790
|
+
const located = takeObject(config, ["extraPeerDependenciesMeta"], state, basePath);
|
|
3791
|
+
if (!located) return;
|
|
3792
|
+
const entries = peerDependenciesMetaEntries(located, state);
|
|
3793
|
+
if (entries.length) packageConfig.extraPeerDependenciesMeta = Object.fromEntries(entries);
|
|
3794
|
+
}
|
|
3795
|
+
function peerDependenciesMetaEntries(located, state) {
|
|
3796
|
+
return Object.entries(located.value).flatMap(([name, value]) => {
|
|
3797
|
+
const parsed = jsonObjectSchema.safeParse(value);
|
|
3798
|
+
if (!parsed.success) return [];
|
|
3799
|
+
consume(state, [...located.path, name]);
|
|
3800
|
+
return [[name, parsed.data]];
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3073
3803
|
function mapDependency(name, value, state, path) {
|
|
3074
3804
|
if (typeof value === "string" && value) {
|
|
3075
3805
|
consume(state, path);
|
|
@@ -3077,13 +3807,7 @@ function mapDependency(name, value, state, path) {
|
|
|
3077
3807
|
}
|
|
3078
3808
|
if (!isObject(value)) return [];
|
|
3079
3809
|
const version = takeString(value, ["version"], state, path);
|
|
3080
|
-
const
|
|
3081
|
-
const localPath = takeString(value, ["path"], state, path);
|
|
3082
|
-
const source = gitUrl ? {
|
|
3083
|
-
type: "git",
|
|
3084
|
-
url: gitUrl,
|
|
3085
|
-
...optional("ref", takeString(value, ["ref"], state, path))
|
|
3086
|
-
} : localPath ? { type: "path", path: localPath } : void 0;
|
|
3810
|
+
const source = takeDependencySource(value, state, path);
|
|
3087
3811
|
if (!version && !source) return [];
|
|
3088
3812
|
return [
|
|
3089
3813
|
{
|
|
@@ -3099,6 +3823,17 @@ function mapDependency(name, value, state, path) {
|
|
|
3099
3823
|
}
|
|
3100
3824
|
];
|
|
3101
3825
|
}
|
|
3826
|
+
function takeDependencySource(value, state, path) {
|
|
3827
|
+
const gitUrl = takeString(value, ["git"], state, path);
|
|
3828
|
+
if (gitUrl) {
|
|
3829
|
+
const ref = takeString(value, ["ref", "rev", "branch"], state, path);
|
|
3830
|
+
return { type: "git", url: gitUrl, ...optional("ref", ref) };
|
|
3831
|
+
}
|
|
3832
|
+
const localPath = takeString(value, ["path"], state, path);
|
|
3833
|
+
if (localPath) return { type: "path", path: localPath };
|
|
3834
|
+
const registry = takeString(value, ["registry"], state, path);
|
|
3835
|
+
return registry ? { type: "registry", registry } : void 0;
|
|
3836
|
+
}
|
|
3102
3837
|
function takeCustomSections(value, language, activeLanguages, state, basePath) {
|
|
3103
3838
|
const located = locate(value, ["customSections"], basePath);
|
|
3104
3839
|
if (!located || !Array.isArray(located.value)) return void 0;
|
|
@@ -3147,6 +3882,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
|
|
|
3147
3882
|
);
|
|
3148
3883
|
return manifest;
|
|
3149
3884
|
}
|
|
3885
|
+
function mapPackageManifestOptions(manifest, state, packageConfig) {
|
|
3886
|
+
const bugs = takeManifestBugs(manifest, state);
|
|
3887
|
+
if (bugs) packageConfig.bugs = bugs;
|
|
3888
|
+
const repository = takeManifestRepository(manifest, state);
|
|
3889
|
+
if (repository !== void 0 && packageConfig.repository === void 0) {
|
|
3890
|
+
packageConfig.repository = repository;
|
|
3891
|
+
}
|
|
3892
|
+
const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
|
|
3893
|
+
if (exports) consume(state, exports.path);
|
|
3894
|
+
return compact({
|
|
3895
|
+
exports: exports?.value,
|
|
3896
|
+
scripts: takeManifestScripts(manifest, state),
|
|
3897
|
+
files: takeStringArray(manifest.value, ["files"], state, manifest.path),
|
|
3898
|
+
engines: takeManifestStringRecord(manifest, "engines", state),
|
|
3899
|
+
lintStaged: takeManifestLintStaged(manifest, state),
|
|
3900
|
+
browser: takeManifestBrowser(manifest, state)
|
|
3901
|
+
});
|
|
3902
|
+
}
|
|
3903
|
+
function takeManifestBugs(manifest, state) {
|
|
3904
|
+
const text = takeString(manifest.value, ["bugs"], state, manifest.path);
|
|
3905
|
+
if (text !== void 0) return { url: text };
|
|
3906
|
+
const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
|
|
3907
|
+
if (!located) return void 0;
|
|
3908
|
+
const url = takeString(located.value, ["url"], state, located.path);
|
|
3909
|
+
const email = takeString(located.value, ["email"], state, located.path);
|
|
3910
|
+
return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
|
|
3911
|
+
}
|
|
3912
|
+
function takeManifestRepository(manifest, state) {
|
|
3913
|
+
const text = takeString(manifest.value, ["repository"], state, manifest.path);
|
|
3914
|
+
if (text !== void 0) return text;
|
|
3915
|
+
const located = takeObject(manifest.value, ["repository"], state, manifest.path);
|
|
3916
|
+
if (!located) return void 0;
|
|
3917
|
+
const url = takeString(located.value, ["url"], state, located.path);
|
|
3918
|
+
if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
|
|
3919
|
+
return url;
|
|
3920
|
+
}
|
|
3921
|
+
function takeManifestScripts(manifest, state) {
|
|
3922
|
+
const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
|
|
3923
|
+
if (!located) return void 0;
|
|
3924
|
+
const scripts = Object.entries(located.value).flatMap(([name, command]) => {
|
|
3925
|
+
if (typeof command !== "string" || !command) return [];
|
|
3926
|
+
consume(state, [...located.path, name]);
|
|
3927
|
+
return [{ name, command }];
|
|
3928
|
+
});
|
|
3929
|
+
return scripts.length ? scripts : void 0;
|
|
3930
|
+
}
|
|
3931
|
+
function takeManifestStringRecord(manifest, key, state) {
|
|
3932
|
+
const located = takeObject(manifest.value, [key], state, manifest.path);
|
|
3933
|
+
if (!located) return void 0;
|
|
3934
|
+
const entries = Object.entries(located.value).flatMap(([name, value]) => {
|
|
3935
|
+
if (typeof value !== "string" || !value) return [];
|
|
3936
|
+
consume(state, [...located.path, name]);
|
|
3937
|
+
return [[name, value]];
|
|
3938
|
+
});
|
|
3939
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3940
|
+
}
|
|
3941
|
+
function takeManifestLintStaged(manifest, state) {
|
|
3942
|
+
const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
|
|
3943
|
+
if (!located) return void 0;
|
|
3944
|
+
const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
|
|
3945
|
+
const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
|
|
3946
|
+
if (!list?.length || list.some((command) => !command)) return [];
|
|
3947
|
+
consume(state, [...located.path, glob]);
|
|
3948
|
+
return [[glob, list]];
|
|
3949
|
+
});
|
|
3950
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3951
|
+
}
|
|
3952
|
+
function takeManifestBrowser(manifest, state) {
|
|
3953
|
+
const located = takeObject(manifest.value, ["browser"], state, manifest.path);
|
|
3954
|
+
if (!located) return void 0;
|
|
3955
|
+
const entries = Object.entries(located.value).flatMap(([name, value]) => {
|
|
3956
|
+
if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
|
|
3957
|
+
consume(state, [...located.path, name]);
|
|
3958
|
+
return [[name, value]];
|
|
3959
|
+
});
|
|
3960
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3961
|
+
}
|
|
3150
3962
|
function takeManifestAuthors(manifest, state) {
|
|
3151
3963
|
const located = locate(manifest.value, ["authors"], manifest.path);
|
|
3152
3964
|
if (!located || !Array.isArray(located.value)) return [];
|
|
@@ -3258,14 +4070,21 @@ function takeToolsets(value, aliases, state, basePath) {
|
|
|
3258
4070
|
}
|
|
3259
4071
|
|
|
3260
4072
|
exports.FernConfigMappingError = FernConfigMappingError;
|
|
4073
|
+
exports.SDK_CONFIG_V1_CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE;
|
|
3261
4074
|
exports.SDK_CONFIG_V1_SCHEMA_VERSION = SDK_CONFIG_V1_SCHEMA_VERSION;
|
|
4075
|
+
exports.getSdkConfigV1Diagnostics = getSdkConfigV1Diagnostics;
|
|
3262
4076
|
exports.mapFernConfigToSdkConfigV1 = mapFernConfigToSdkConfigV1;
|
|
3263
4077
|
exports.parseSdkConfigV1 = parseSdkConfigV1;
|
|
3264
4078
|
exports.parseSdkConfigV1ForConsumption = parseSdkConfigV1ForConsumption;
|
|
3265
4079
|
exports.sdkConfigV1ApiConfigSchema = sdkConfigV1ApiConfigSchema;
|
|
3266
4080
|
exports.sdkConfigV1AuthConfigSchema = sdkConfigV1AuthConfigSchema;
|
|
3267
4081
|
exports.sdkConfigV1AuthSchemeSchema = sdkConfigV1AuthSchemeSchema;
|
|
4082
|
+
exports.sdkConfigV1CliDistributionConfigSchema = cliDistributionConfigSchema;
|
|
4083
|
+
exports.sdkConfigV1CliDistributionGithubAppSchema = cliDistributionGithubAppSchema;
|
|
4084
|
+
exports.sdkConfigV1CliDistributionHomebrewSchema = cliDistributionHomebrewSchema;
|
|
4085
|
+
exports.sdkConfigV1CliDistributionScoopSchema = cliDistributionScoopSchema;
|
|
3268
4086
|
exports.sdkConfigV1CliGenerationConfigSchema = cliGenerationConfigSchema;
|
|
4087
|
+
exports.sdkConfigV1CliOutputConfigSchema = sdkConfigV1CliOutputConfigSchema;
|
|
3269
4088
|
exports.sdkConfigV1ClientConfigOverrideSchema = sdkConfigV1ClientConfigOverrideSchema;
|
|
3270
4089
|
exports.sdkConfigV1ClientConfigSchema = sdkConfigV1ClientConfigSchema;
|
|
3271
4090
|
exports.sdkConfigV1ComposerPackageNameSchema = composerPackageNameSchema;
|
|
@@ -3275,6 +4094,7 @@ exports.sdkConfigV1DocsConfigSchema = sdkConfigV1DocsConfigSchema;
|
|
|
3275
4094
|
exports.sdkConfigV1ExactSemverSchema = exactSemverSchema;
|
|
3276
4095
|
exports.sdkConfigV1GenerationConfigOverrideSchema = sdkConfigV1GenerationConfigOverrideSchema;
|
|
3277
4096
|
exports.sdkConfigV1GenerationConfigSchema = sdkConfigV1GenerationConfigSchema;
|
|
4097
|
+
exports.sdkConfigV1GithubActionsSecretNameSchema = githubActionsSecretNameSchema;
|
|
3278
4098
|
exports.sdkConfigV1GoGenerationConfigSchema = goGenerationConfigSchema;
|
|
3279
4099
|
exports.sdkConfigV1GoModulePathSchema = goModulePathSchema;
|
|
3280
4100
|
exports.sdkConfigV1JavaGenerationConfigSchema = javaGenerationConfigSchema;
|