@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
|
@@ -27,7 +27,7 @@ var jsonValueSchema = z.lazy(
|
|
|
27
27
|
z.record(z.string(), jsonValueSchema)
|
|
28
28
|
])
|
|
29
29
|
);
|
|
30
|
-
z.record(z.string(), jsonValueSchema);
|
|
30
|
+
var jsonObjectSchema = z.record(z.string(), jsonValueSchema);
|
|
31
31
|
var hashAlgorithmSchema = z.enum(["sha1", "sha256", "sha384", "sha512"]);
|
|
32
32
|
var encodingSchema = z.enum(["base64", "hex"]);
|
|
33
33
|
var payloadComponentSchema = z.enum(["body", "timestamp", "notification-url", "message-id"]);
|
|
@@ -125,13 +125,21 @@ var oauthScopeSchema = z.strictObject({
|
|
|
125
125
|
name: nonEmptyStringSchema.describe("The OAuth scope value requested from the provider."),
|
|
126
126
|
description: z.string().optional().describe("A description of the OAuth scope included in generated SDK documentation.")
|
|
127
127
|
});
|
|
128
|
+
var publicClientIdSchema = nonEmptyStringSchema.refine((value) => value.trim() === value, {
|
|
129
|
+
message: "must not have leading or trailing whitespace"
|
|
130
|
+
}).refine((value) => !value.includes("${"), {
|
|
131
|
+
message: "must be a literal public client ID, not an environment expression"
|
|
132
|
+
});
|
|
128
133
|
var oauthFlowSchema = z.discriminatedUnion("type", [
|
|
129
134
|
z.strictObject({
|
|
130
135
|
type: z.literal("authorization-code").describe("Uses the OAuth authorization code flow."),
|
|
131
136
|
authorizationUrl: nonEmptyStringSchema.describe("The URL used to authorize the client."),
|
|
132
137
|
tokenUrl: nonEmptyStringSchema.describe("The URL used to exchange a code for tokens."),
|
|
133
138
|
refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
|
|
134
|
-
scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow.")
|
|
139
|
+
scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow."),
|
|
140
|
+
clientId: publicClientIdSchema.optional().describe(
|
|
141
|
+
"The public, non-secret OAuth client ID that generated interactive login flows, such as CLI browser login with PKCE, send to the authorization and token endpoints. It is embedded verbatim in generated code, so it must never be a client secret."
|
|
142
|
+
)
|
|
135
143
|
}),
|
|
136
144
|
z.strictObject({
|
|
137
145
|
type: z.literal("client-credentials").describe("Uses the OAuth client credentials flow."),
|
|
@@ -424,6 +432,12 @@ var dependencySchema = z.strictObject({
|
|
|
424
432
|
}).refine(({ source, version }) => source !== void 0 || version !== void 0, {
|
|
425
433
|
message: "dependency must define a version or a source"
|
|
426
434
|
});
|
|
435
|
+
var bugsSchema = z.strictObject({
|
|
436
|
+
url: nonEmptyStringSchema.optional().describe("The issue tracker URL."),
|
|
437
|
+
email: nonEmptyStringSchema.optional().describe("The address for reporting issues.")
|
|
438
|
+
}).refine(({ url, email }) => url !== void 0 || email !== void 0, {
|
|
439
|
+
message: "bugs must define a url or an email"
|
|
440
|
+
});
|
|
427
441
|
var projectUrlSchema = z.strictObject({
|
|
428
442
|
label: nonEmptyStringSchema.describe("The label displayed for the project link."),
|
|
429
443
|
url: nonEmptyStringSchema.describe("The project link URL.")
|
|
@@ -438,6 +452,7 @@ var packageConfigSchema = z.strictObject({
|
|
|
438
452
|
description: z.string().optional().describe("The package description used in generated metadata."),
|
|
439
453
|
repository: nonEmptyStringSchema.optional().describe("The source repository for the generated SDK."),
|
|
440
454
|
homepage: nonEmptyStringSchema.optional().describe("The package homepage URL."),
|
|
455
|
+
bugs: bugsSchema.optional().describe("Where issues with the package are reported."),
|
|
441
456
|
documentationUrl: nonEmptyStringSchema.optional().describe("The package documentation URL."),
|
|
442
457
|
authors: z.array(authorSchema).optional().describe("Authors credited in package metadata."),
|
|
443
458
|
developers: z.array(developerSchema).optional().describe("Developers credited in package metadata."),
|
|
@@ -447,8 +462,102 @@ var packageConfigSchema = z.strictObject({
|
|
|
447
462
|
projectUrls: z.array(projectUrlSchema).optional().describe("Labeled project links for package metadata."),
|
|
448
463
|
extraDependencies: z.array(dependencySchema).optional().describe("Additional runtime dependencies added to the generated package."),
|
|
449
464
|
extraDevDependencies: z.array(dependencySchema).optional().describe("Additional development dependencies added to the generated package."),
|
|
450
|
-
extraPeerDependencies: z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package.")
|
|
465
|
+
extraPeerDependencies: z.array(dependencySchema).optional().describe("Additional peer dependencies added to the generated package."),
|
|
466
|
+
extraPeerDependenciesMeta: z.record(nonEmptyStringSchema, jsonObjectSchema).optional().describe(
|
|
467
|
+
"npm peerDependenciesMeta entries keyed by peer dependency name, such as { optional: true }."
|
|
468
|
+
)
|
|
451
469
|
});
|
|
470
|
+
var GITHUB_ACTIONS_SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/;
|
|
471
|
+
var GITHUB_REPOSITORY_SLUG_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
|
472
|
+
var HOMEBREW_FORMULA_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
473
|
+
var githubActionsSecretNameSchema = z.string({ error: "must be the name of a GitHub Actions secret" }).regex(GITHUB_ACTIONS_SECRET_NAME_PATTERN, {
|
|
474
|
+
error: "must be the name of a GitHub Actions secret: start with an uppercase letter and contain only A-Z, 0-9, or _. Secret values and ${...} expressions are not accepted."
|
|
475
|
+
}).refine((value) => value !== "GITHUB_TOKEN", {
|
|
476
|
+
error: "GITHUB_TOKEN cannot be used: it is the workflow's built-in token, scoped to the generated repository. Store the credential under a different secret name."
|
|
477
|
+
});
|
|
478
|
+
var githubRepositorySlugSchema = z.string({ error: 'must be a GitHub repository in "<owner>/<repo>" form' }).regex(GITHUB_REPOSITORY_SLUG_PATTERN, {
|
|
479
|
+
error: 'must be a GitHub repository in "<owner>/<repo>" form, for example "acme/homebrew-tap"'
|
|
480
|
+
});
|
|
481
|
+
var homebrewFormulaNameSchema = z.string({ error: "must be a Homebrew formula name" }).regex(HOMEBREW_FORMULA_NAME_PATTERN, {
|
|
482
|
+
error: "must be a Homebrew formula name: start with a lowercase letter and contain only a-z, 0-9, or -"
|
|
483
|
+
});
|
|
484
|
+
var cliDistributionGithubAppSchema = z.strictObject({
|
|
485
|
+
appIdSecretName: githubActionsSecretNameSchema.describe(
|
|
486
|
+
"The name of the GitHub Actions secret holding the GitHub App ID or client ID."
|
|
487
|
+
),
|
|
488
|
+
privateKeySecretName: githubActionsSecretNameSchema.describe(
|
|
489
|
+
"The name of the GitHub Actions secret holding the GitHub App private key in PEM form."
|
|
490
|
+
)
|
|
491
|
+
});
|
|
492
|
+
var channelTokenSecretNameDescription = "The name of the GitHub Actions secret holding a token with write access to the channel repository. Takes precedence over githubApp for this channel.";
|
|
493
|
+
var cliDistributionHomebrewSchema = z.strictObject({
|
|
494
|
+
tap: githubRepositorySlugSchema.describe(
|
|
495
|
+
'The Homebrew tap repository in "<owner>/<repo>" form that receives the formula.'
|
|
496
|
+
),
|
|
497
|
+
formula: homebrewFormulaNameSchema.optional().describe("The Homebrew formula name; the generator defaults it to the CLI binary name."),
|
|
498
|
+
tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
|
|
499
|
+
});
|
|
500
|
+
var cliDistributionScoopSchema = z.strictObject({
|
|
501
|
+
bucket: githubRepositorySlugSchema.describe(
|
|
502
|
+
'The Scoop bucket repository in "<owner>/<repo>" form that receives the manifest.'
|
|
503
|
+
),
|
|
504
|
+
tokenSecretName: githubActionsSecretNameSchema.optional().describe(channelTokenSecretNameDescription)
|
|
505
|
+
});
|
|
506
|
+
var cliDistributionConfigSchema = z.strictObject({
|
|
507
|
+
githubApp: cliDistributionGithubAppSchema.optional().describe(
|
|
508
|
+
"A GitHub App used to mint short-lived tokens for every channel without its own tokenSecretName."
|
|
509
|
+
),
|
|
510
|
+
homebrew: cliDistributionHomebrewSchema.optional().describe("Publishes a Homebrew formula to a tap repository on each tagged release."),
|
|
511
|
+
scoop: cliDistributionScoopSchema.optional().describe("Publishes a Scoop manifest to a bucket repository on each tagged release.")
|
|
512
|
+
}).superRefine((distribution, context) => {
|
|
513
|
+
if (distribution.homebrew !== void 0 || distribution.scoop !== void 0) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (distribution.githubApp !== void 0) {
|
|
517
|
+
context.addIssue({
|
|
518
|
+
code: "custom",
|
|
519
|
+
message: "githubApp requires at least one distribution channel: homebrew or scoop",
|
|
520
|
+
path: ["githubApp"]
|
|
521
|
+
});
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
context.addIssue({
|
|
525
|
+
code: "custom",
|
|
526
|
+
message: "distribution must configure at least one channel: homebrew or scoop"
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
var CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE = 'distribution requires output.delivery "github": Homebrew and Scoop publish from a tagged GitHub Release produced by the generated release workflow. Set delivery to "github" or remove distribution.';
|
|
530
|
+
var CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE = 'package publication for target language "cli" requires output.delivery "github": the CLI generator publishes npm packages only from its generated GitHub workflow.';
|
|
531
|
+
var CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = "CLI_DISTRIBUTION_NON_RELEASE_MODE";
|
|
532
|
+
var nonReleaseGithubModes = /* @__PURE__ */ new Set(["pull-request", "push", "commit"]);
|
|
533
|
+
function cliDistributionModeDiagnostic(output, outputPath) {
|
|
534
|
+
const mode = output?.github?.mode;
|
|
535
|
+
if (output?.distribution === void 0 || mode === void 0 || !nonReleaseGithubModes.has(mode)) {
|
|
536
|
+
return void 0;
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
code: CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE,
|
|
540
|
+
severity: "warning",
|
|
541
|
+
path: [...outputPath, "github", "mode"],
|
|
542
|
+
reason: `GitHub mode "${mode}" does not create a release tag, so Homebrew and Scoop publish only after a semantic-version tag is pushed to the repository.`,
|
|
543
|
+
suggestedAction: 'Use mode "release" or "commit-and-release", or push a version tag after merging generated changes.'
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/sdk-config/v1/diagnostics.ts
|
|
548
|
+
function getSdkConfigV1Diagnostics(config) {
|
|
549
|
+
return config.targets.flatMap((target, targetIndex) => {
|
|
550
|
+
if (target.language !== "cli") {
|
|
551
|
+
return [];
|
|
552
|
+
}
|
|
553
|
+
const diagnostic = cliDistributionModeDiagnostic(target.output, [
|
|
554
|
+
"targets",
|
|
555
|
+
targetIndex,
|
|
556
|
+
"output"
|
|
557
|
+
]);
|
|
558
|
+
return diagnostic ? [diagnostic] : [];
|
|
559
|
+
});
|
|
560
|
+
}
|
|
452
561
|
var httpMethodSchema = z.enum([
|
|
453
562
|
"GET",
|
|
454
563
|
"POST",
|
|
@@ -653,6 +762,17 @@ function stringValue(value) {
|
|
|
653
762
|
function stringArrayValue(value) {
|
|
654
763
|
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0) ? value : void 0;
|
|
655
764
|
}
|
|
765
|
+
var canonicalLicenseTypes = {
|
|
766
|
+
mit: "MIT",
|
|
767
|
+
apache: "APACHE",
|
|
768
|
+
"apache-2.0": "APACHE",
|
|
769
|
+
"gpl-3.0": "GPL3",
|
|
770
|
+
"gpl-3.0-only": "GPL3",
|
|
771
|
+
unlicensed: "UNLICENSED"
|
|
772
|
+
};
|
|
773
|
+
function canonicalLicenseType(value) {
|
|
774
|
+
return canonicalLicenseTypes[value.trim().toLowerCase()];
|
|
775
|
+
}
|
|
656
776
|
function stableJson(value) {
|
|
657
777
|
return JSON.stringify(sortKeys(value));
|
|
658
778
|
}
|
|
@@ -663,6 +783,280 @@ function sortKeys(value) {
|
|
|
663
783
|
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortKeys(child)])
|
|
664
784
|
);
|
|
665
785
|
}
|
|
786
|
+
var ALPHANUMERIC_PATTERN = /[A-Za-z0-9]/;
|
|
787
|
+
var ROOT_GROUP_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
788
|
+
var KEBAB_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
789
|
+
var DOTTED_COMMAND_PATH_PATTERN = /^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/;
|
|
790
|
+
var FIELD_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
791
|
+
var RESERVED_USER_AGENT_SUFFIX_FLAGS = /* @__PURE__ */ new Set([
|
|
792
|
+
"params",
|
|
793
|
+
"output",
|
|
794
|
+
"json",
|
|
795
|
+
"format",
|
|
796
|
+
"dry-run",
|
|
797
|
+
"base-url",
|
|
798
|
+
"page-all",
|
|
799
|
+
"page-limit",
|
|
800
|
+
"page-delay",
|
|
801
|
+
"no-pager",
|
|
802
|
+
"no-extract",
|
|
803
|
+
"no-retry",
|
|
804
|
+
"no-stream",
|
|
805
|
+
"quiet",
|
|
806
|
+
"query",
|
|
807
|
+
"help",
|
|
808
|
+
"debug",
|
|
809
|
+
"schema"
|
|
810
|
+
]);
|
|
811
|
+
var RESERVED_PROFILES_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
812
|
+
"auth",
|
|
813
|
+
"completion",
|
|
814
|
+
"man",
|
|
815
|
+
"errors",
|
|
816
|
+
"generate-skills",
|
|
817
|
+
"help"
|
|
818
|
+
]);
|
|
819
|
+
var binaryNameSchema = nonEmptyStringSchema.regex(ALPHANUMERIC_PATTERN, {
|
|
820
|
+
message: "binaryName must contain at least one ASCII letter or digit"
|
|
821
|
+
});
|
|
822
|
+
var rootGroupSchema = z.string().regex(ROOT_GROUP_PATTERN, {
|
|
823
|
+
message: "rootGroup must start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores"
|
|
824
|
+
});
|
|
825
|
+
var userAgentSuffixFlagSchema = z.string().superRefine((value, context) => {
|
|
826
|
+
if (value.startsWith("-")) {
|
|
827
|
+
context.addIssue({
|
|
828
|
+
code: "custom",
|
|
829
|
+
message: 'userAgentSuffixFlag must be the long flag name without the leading "--"'
|
|
830
|
+
});
|
|
831
|
+
} else if (!KEBAB_NAME_PATTERN.test(value)) {
|
|
832
|
+
context.addIssue({
|
|
833
|
+
code: "custom",
|
|
834
|
+
message: "userAgentSuffixFlag must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
|
|
835
|
+
});
|
|
836
|
+
} else if (RESERVED_USER_AGENT_SUFFIX_FLAGS.has(value)) {
|
|
837
|
+
context.addIssue({
|
|
838
|
+
code: "custom",
|
|
839
|
+
message: `userAgentSuffixFlag "${value}" collides with a built-in global flag`
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
var profilesCommandNameSchema = z.string().superRefine((value, context) => {
|
|
844
|
+
if (!KEBAB_NAME_PATTERN.test(value)) {
|
|
845
|
+
context.addIssue({
|
|
846
|
+
code: "custom",
|
|
847
|
+
message: "profiles.commandName must start with a lowercase letter and contain only lowercase letters, digits, and hyphens"
|
|
848
|
+
});
|
|
849
|
+
} else if (RESERVED_PROFILES_COMMAND_NAMES.has(value)) {
|
|
850
|
+
context.addIssue({
|
|
851
|
+
code: "custom",
|
|
852
|
+
message: `profiles.commandName "${value}" collides with a built-in command group`
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
function dottedCommandPathSchema(field) {
|
|
857
|
+
return z.string().regex(DOTTED_COMMAND_PATH_PATTERN, {
|
|
858
|
+
message: `${field} must be a dotted command path such as "iam.keys.create"`
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
function fieldNameMapSchema(field) {
|
|
862
|
+
const message = `${field} keys and values must be field names containing only [A-Za-z0-9_.-]`;
|
|
863
|
+
return z.record(z.string(), z.string().regex(FIELD_NAME_PATTERN, { message })).superRefine((value, context) => {
|
|
864
|
+
for (const key of Object.keys(value)) {
|
|
865
|
+
if (!FIELD_NAME_PATTERN.test(key)) {
|
|
866
|
+
context.addIssue({ code: "custom", message, path: [key] });
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
var profilesProvisionOperationSchema = z.strictObject({
|
|
872
|
+
operation: dottedCommandPathSchema("profiles.provisionOperation.operation").describe(
|
|
873
|
+
"The dotted command path of the operation that mints a profile credential."
|
|
874
|
+
),
|
|
875
|
+
credential: fieldNameMapSchema("profiles.provisionOperation.credential").refine((value) => Object.keys(value).length > 0, {
|
|
876
|
+
message: "profiles.provisionOperation.credential must map at least one credential field"
|
|
877
|
+
}).describe("Maps each stored credential field to the response field that supplies it."),
|
|
878
|
+
revokeParameters: fieldNameMapSchema("profiles.provisionOperation.revokeParameters").optional().describe("Maps each revoke-operation parameter to the response field that supplies it.")
|
|
879
|
+
});
|
|
880
|
+
var profilesConfigSchema = z.strictObject({
|
|
881
|
+
enabled: z.boolean().describe("Whether the CLI emits profile commands and the global --profile flag."),
|
|
882
|
+
commandName: profilesCommandNameSchema.optional().describe('The profile command group name. The generator defaults to "profiles".'),
|
|
883
|
+
revokeOperation: dottedCommandPathSchema("profiles.revokeOperation").optional().describe('The dotted command path called by "profiles remove --revoke".'),
|
|
884
|
+
provisionOperation: profilesProvisionOperationSchema.optional().describe('The operation called by "profiles create --provision" and its response mapping.')
|
|
885
|
+
});
|
|
886
|
+
var cliGenerationConfigSchema = z.strictObject({
|
|
887
|
+
paginationParameters: z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
|
|
888
|
+
skills: z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands."),
|
|
889
|
+
binaryName: binaryNameSchema.optional().describe(
|
|
890
|
+
"The CLI executable name. The generator kebab-cases it and also uses it for the source directory and env-var prefix."
|
|
891
|
+
),
|
|
892
|
+
customCommands: z.boolean().optional().describe("Whether hand-written command support is generated. The generator defaults to true."),
|
|
893
|
+
rootGroup: rootGroupSchema.optional().describe("A command group that every spec-derived command is nested under."),
|
|
894
|
+
profiles: profilesConfigSchema.optional().describe("Named profile command configuration."),
|
|
895
|
+
splitTypeCrates: z.boolean().optional().describe("Whether generated types are split into one crate per API behind a facade crate."),
|
|
896
|
+
userAgentSuffixFlag: userAgentSuffixFlagSchema.optional().describe('The long flag name, without "--", that appends a product token to the User-Agent.')
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
// src/sdk-config/v1/fern-config-mapper-cli.ts
|
|
900
|
+
var CLI_GENERATION_FIELDS = [
|
|
901
|
+
"binaryName",
|
|
902
|
+
"customCommands",
|
|
903
|
+
"rootGroup",
|
|
904
|
+
"profiles",
|
|
905
|
+
"splitTypeCrates",
|
|
906
|
+
"userAgentSuffixFlag"
|
|
907
|
+
];
|
|
908
|
+
var PROFILES_FIELDS = ["enabled", "commandName", "revokeOperation"];
|
|
909
|
+
var PROVISION_OPERATION_FIELDS = ["operation", "credential", "revokeParameters"];
|
|
910
|
+
function mapCliGeneration(config, state, basePath, targetIndex) {
|
|
911
|
+
const generation = {};
|
|
912
|
+
for (const field of CLI_GENERATION_FIELDS) {
|
|
913
|
+
const raw = ownValue(config, field);
|
|
914
|
+
if (raw === void 0) continue;
|
|
915
|
+
const fieldPath = [...basePath, field];
|
|
916
|
+
const { value, consumedPaths } = field === "profiles" && isObject(raw) ? pickProfiles(raw, fieldPath) : { value: raw, consumedPaths: [fieldPath] };
|
|
917
|
+
const parsed = cliGenerationConfigSchema.shape[field].safeParse(value);
|
|
918
|
+
consumedPaths.forEach((path) => consume(state, path));
|
|
919
|
+
if (parsed.success) {
|
|
920
|
+
generation[field] = structuredClone(value);
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
const diagnostics = parsed.error.issues.map(
|
|
924
|
+
(issue) => invalidValueDiagnostic(field, fieldPath, issue.path, issue.message, targetIndex)
|
|
925
|
+
);
|
|
926
|
+
(state.valueDiagnostics ??= []).push(...diagnostics);
|
|
927
|
+
}
|
|
928
|
+
return generation;
|
|
929
|
+
}
|
|
930
|
+
function pickProfiles(profiles, path) {
|
|
931
|
+
const picked = pickKnown(profiles, PROFILES_FIELDS, path);
|
|
932
|
+
const provisionOperation = ownValue(profiles, "provisionOperation");
|
|
933
|
+
const provisionPath = [...path, "provisionOperation"];
|
|
934
|
+
if (isObject(provisionOperation)) {
|
|
935
|
+
const provision = pickKnown(provisionOperation, PROVISION_OPERATION_FIELDS, provisionPath);
|
|
936
|
+
picked.value.provisionOperation = provision.value;
|
|
937
|
+
picked.consumedPaths.push(...provision.consumedPaths);
|
|
938
|
+
} else if (provisionOperation !== void 0) {
|
|
939
|
+
picked.value.provisionOperation = provisionOperation;
|
|
940
|
+
picked.consumedPaths.push(provisionPath);
|
|
941
|
+
}
|
|
942
|
+
return { value: { enabled: false, ...picked.value }, consumedPaths: picked.consumedPaths };
|
|
943
|
+
}
|
|
944
|
+
function pickKnown(value, fields, path) {
|
|
945
|
+
const picked = {};
|
|
946
|
+
const consumedPaths = [];
|
|
947
|
+
for (const field of fields) {
|
|
948
|
+
const child = ownValue(value, field);
|
|
949
|
+
if (child === void 0) continue;
|
|
950
|
+
picked[field] = child;
|
|
951
|
+
consumedPaths.push([...path, field]);
|
|
952
|
+
}
|
|
953
|
+
return { value: picked, consumedPaths };
|
|
954
|
+
}
|
|
955
|
+
function ownValue(value, key) {
|
|
956
|
+
return Object.hasOwn(value, key) ? value[key] : void 0;
|
|
957
|
+
}
|
|
958
|
+
function invalidValueDiagnostic(field, fieldPath, issuePath, message, targetIndex) {
|
|
959
|
+
const relative = issuePath.map((part) => typeof part === "symbol" ? String(part) : part);
|
|
960
|
+
const sdkConfigField = ["targets", targetIndex, "generation", field];
|
|
961
|
+
return {
|
|
962
|
+
code: "FERN_CONFIG_VALUE_INVALID",
|
|
963
|
+
severity: "warning",
|
|
964
|
+
path: [...fieldPath, ...relative],
|
|
965
|
+
reason: `CLI setting ${field} was not migrated because SDK Config rejects it: ${message}`,
|
|
966
|
+
sdkConfigPath: [...sdkConfigField, ...relative],
|
|
967
|
+
suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/sdk-config/v1/fern-config-mapper-cli-distribution.ts
|
|
972
|
+
var DISTRIBUTION_KEYS = {
|
|
973
|
+
githubApp: { appIdSecret: "appIdSecretName", privateKeySecret: "privateKeySecretName" },
|
|
974
|
+
homebrew: { tap: "tap", formula: "formula", tokenEnvironmentVariable: "tokenSecretName" },
|
|
975
|
+
scoop: { bucket: "bucket", tokenEnvironmentVariable: "tokenSecretName" }
|
|
976
|
+
};
|
|
977
|
+
function mapCliDistribution(config, state, basePath, targetIndex) {
|
|
978
|
+
if (!Object.hasOwn(config, "distribution")) return;
|
|
979
|
+
const raw = config.distribution;
|
|
980
|
+
const path = [...basePath, "distribution"];
|
|
981
|
+
const translated = isObject(raw) ? translateDistribution(raw, path) : { value: raw, consumedPaths: [path], legacyKeys: /* @__PURE__ */ new Map() };
|
|
982
|
+
const parsed = cliDistributionConfigSchema.safeParse(translated.value);
|
|
983
|
+
translated.consumedPaths.forEach((consumedPath) => consume(state, consumedPath));
|
|
984
|
+
if (parsed.success) {
|
|
985
|
+
state.cliDistribution = { value: parsed.data, path };
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const diagnostics = parsed.error.issues.map(
|
|
989
|
+
(issue) => invalidDistributionDiagnostic(issue, path, translated.legacyKeys, targetIndex)
|
|
990
|
+
);
|
|
991
|
+
const reportedPaths = /* @__PURE__ */ new Set();
|
|
992
|
+
(state.valueDiagnostics ??= []).push(
|
|
993
|
+
...diagnostics.filter(({ path: diagnosticPath }) => {
|
|
994
|
+
const key = diagnosticPath.join(".");
|
|
995
|
+
if (reportedPaths.has(key)) return false;
|
|
996
|
+
reportedPaths.add(key);
|
|
997
|
+
return true;
|
|
998
|
+
})
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
function translateDistribution(distribution, path) {
|
|
1002
|
+
const value = {};
|
|
1003
|
+
const consumedPaths = [];
|
|
1004
|
+
const legacyKeys = /* @__PURE__ */ new Map();
|
|
1005
|
+
for (const [block, keys] of Object.entries(DISTRIBUTION_KEYS)) {
|
|
1006
|
+
if (!Object.hasOwn(distribution, block)) continue;
|
|
1007
|
+
const blockValue = distribution[block];
|
|
1008
|
+
const blockPath = [...path, block];
|
|
1009
|
+
if (!isObject(blockValue)) {
|
|
1010
|
+
value[block] = blockValue;
|
|
1011
|
+
consumedPaths.push(blockPath);
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
const translatedBlock = {};
|
|
1015
|
+
for (const [legacyKey, sdkConfigKey] of Object.entries(keys)) {
|
|
1016
|
+
if (!Object.hasOwn(blockValue, legacyKey)) continue;
|
|
1017
|
+
translatedBlock[sdkConfigKey] = blockValue[legacyKey];
|
|
1018
|
+
consumedPaths.push([...blockPath, legacyKey]);
|
|
1019
|
+
legacyKeys.set(`${block}.${sdkConfigKey}`, legacyKey);
|
|
1020
|
+
}
|
|
1021
|
+
value[block] = translatedBlock;
|
|
1022
|
+
}
|
|
1023
|
+
return { value, consumedPaths, legacyKeys };
|
|
1024
|
+
}
|
|
1025
|
+
function invalidDistributionDiagnostic(issue, path, legacyKeys, targetIndex) {
|
|
1026
|
+
const relative = issue.path.map((part) => typeof part === "symbol" ? String(part) : part);
|
|
1027
|
+
const [block, field] = relative;
|
|
1028
|
+
const legacyField = typeof block === "string" && typeof field === "string" ? legacyKeys.get(`${block}.${field}`) : void 0;
|
|
1029
|
+
const legacyRelative = typeof block === "string" && legacyField !== void 0 ? [block, legacyField] : relative;
|
|
1030
|
+
const sdkConfigField = ["targets", targetIndex, "output", "distribution"];
|
|
1031
|
+
return {
|
|
1032
|
+
code: "FERN_CONFIG_VALUE_INVALID",
|
|
1033
|
+
severity: "warning",
|
|
1034
|
+
path: [...path, ...legacyRelative],
|
|
1035
|
+
reason: `CLI distribution was not migrated because SDK Config rejects it: ${issue.message}`,
|
|
1036
|
+
sdkConfigPath: [...sdkConfigField, ...relative],
|
|
1037
|
+
suggestedAction: `Correct the value, then set ${sdkConfigField.join(".")} manually.`
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
function applyCliDistribution(output, pending, targetIndex) {
|
|
1041
|
+
if (pending === void 0) return { output, diagnostics: [] };
|
|
1042
|
+
if (output.delivery === "github") {
|
|
1043
|
+
return { output: { ...output, distribution: pending.value }, diagnostics: [] };
|
|
1044
|
+
}
|
|
1045
|
+
const outputPath = ["targets", targetIndex, "output"];
|
|
1046
|
+
return {
|
|
1047
|
+
output,
|
|
1048
|
+
diagnostics: [
|
|
1049
|
+
{
|
|
1050
|
+
code: "FERN_CLI_DISTRIBUTION_REQUIRES_GITHUB_OUTPUT",
|
|
1051
|
+
severity: "warning",
|
|
1052
|
+
path: pending.path,
|
|
1053
|
+
reason: `The CLI generator ignores distribution for "${output.delivery}" output, and SDK Config accepts distribution only with output.delivery "github", so it was not migrated`,
|
|
1054
|
+
sdkConfigPath: [...outputPath, "distribution"],
|
|
1055
|
+
suggestedAction: `Set ${outputPath.join(".")}.delivery to "github" for the CLI repository and add ${outputPath.join(".")}.distribution manually, or remove distribution.`
|
|
1056
|
+
}
|
|
1057
|
+
]
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
666
1060
|
|
|
667
1061
|
// src/sdk-config/v1/fern-config-mapper-output.ts
|
|
668
1062
|
function mapOutput(generator, language, index) {
|
|
@@ -846,6 +1240,7 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
|
|
|
846
1240
|
const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
|
|
847
1241
|
if (type) consume(state, [...sourcePath, "type"]);
|
|
848
1242
|
if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
|
|
1243
|
+
if (value.workflows === true) consume(state, [...sourcePath, "workflows"]);
|
|
849
1244
|
if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
|
|
850
1245
|
if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
|
|
851
1246
|
consumeCredentialObject(value.credentials, [...sourcePath, "credentials"], state);
|
|
@@ -873,11 +1268,10 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
|
|
|
873
1268
|
...optionalObject("package", { ...publication?.package, ...licensePackage })
|
|
874
1269
|
};
|
|
875
1270
|
}
|
|
876
|
-
var basicLicenseTypes = { mit: "MIT", apache: "APACHE" };
|
|
877
1271
|
function mapGithubLicense(value, sourcePath, state) {
|
|
878
1272
|
if (!isObject(value) || stringValue(value.type) !== "basic") return {};
|
|
879
1273
|
const id = stringValue(value.id);
|
|
880
|
-
const type = id ?
|
|
1274
|
+
const type = id ? canonicalLicenseType(id) : void 0;
|
|
881
1275
|
if (!type) return {};
|
|
882
1276
|
consume(state, [...sourcePath, "type"]);
|
|
883
1277
|
consume(state, [...sourcePath, "id"]);
|
|
@@ -1444,6 +1838,114 @@ function outputDiagnostic(path, index) {
|
|
|
1444
1838
|
suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
|
|
1445
1839
|
};
|
|
1446
1840
|
}
|
|
1841
|
+
|
|
1842
|
+
// src/sdk-config/v1/package.ts
|
|
1843
|
+
var sdkConfigV1DependencySchema = dependencySchema;
|
|
1844
|
+
var sdkConfigV1PackageConfigSchema = packageConfigSchema;
|
|
1845
|
+
|
|
1846
|
+
// src/sdk-config/v1/fern-config-mapper-package.ts
|
|
1847
|
+
var emailSchema = z.email();
|
|
1848
|
+
function mapCliPackageIdentity(identity, state, targetIndex) {
|
|
1849
|
+
mapIdentityField(identity, "homepage", stringValue, state);
|
|
1850
|
+
mapIdentityField(identity, "keywords", (value) => stringArrayValue(value)?.slice(), state);
|
|
1851
|
+
mapCargoAuthors(identity, state, targetIndex);
|
|
1852
|
+
mapIdentityField(identity, "license", licenseValue, state);
|
|
1853
|
+
}
|
|
1854
|
+
function mapIdentityField(identity, field, read, state) {
|
|
1855
|
+
const located = locate(identity.value, [field], identity.path);
|
|
1856
|
+
const value = located && read(located.value);
|
|
1857
|
+
if (located && value !== void 0) addPackageFallback(state, field, value, located.path);
|
|
1858
|
+
}
|
|
1859
|
+
function mapLicenseFallback(config, aliases, state, basePath) {
|
|
1860
|
+
const located = locate(config, aliases, basePath);
|
|
1861
|
+
const license = located && licenseValue(located.value);
|
|
1862
|
+
if (located && license) addPackageFallback(state, "license", license, located.path);
|
|
1863
|
+
}
|
|
1864
|
+
function resolveTargetPackage(targetPackage, fallbacks, generator, delivery, index) {
|
|
1865
|
+
const diagnostics = [];
|
|
1866
|
+
for (const fallback of fallbacks) {
|
|
1867
|
+
applyFallback(targetPackage, fallback, index, diagnostics);
|
|
1868
|
+
}
|
|
1869
|
+
if (delivery !== "github") {
|
|
1870
|
+
applyMetadataLicense(targetPackage, generator.raw, index, diagnostics);
|
|
1871
|
+
}
|
|
1872
|
+
return diagnostics;
|
|
1873
|
+
}
|
|
1874
|
+
function applyFallback(targetPackage, { field, value, path }, index, diagnostics) {
|
|
1875
|
+
const existing = targetPackage[field];
|
|
1876
|
+
if (existing === void 0) {
|
|
1877
|
+
targetPackage[field] = value;
|
|
1878
|
+
} else if (stableJson(existing) !== stableJson(value)) {
|
|
1879
|
+
diagnostics.push({
|
|
1880
|
+
code: "FERN_PACKAGE_VALUE_CONFLICT",
|
|
1881
|
+
severity: "warning",
|
|
1882
|
+
path,
|
|
1883
|
+
reason: `Fern value conflicts with the package.${field} already migrated for this target, which is kept`,
|
|
1884
|
+
sdkConfigPath: ["targets", index, "package", field],
|
|
1885
|
+
suggestedAction: `Choose the intended value and set targets.${index}.package.${field} manually.`
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
function applyMetadataLicense(targetPackage, raw, index, diagnostics) {
|
|
1890
|
+
const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
|
|
1891
|
+
if (metadata?.license === void 0 || metadata.license === null) return;
|
|
1892
|
+
const path = ["group", "generators", index, "metadata", "license"];
|
|
1893
|
+
const license = licenseValue(metadata.license);
|
|
1894
|
+
if (license) {
|
|
1895
|
+
applyFallback(targetPackage, { field: "license", value: license, path }, index, diagnostics);
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
diagnostics.push({
|
|
1899
|
+
code: "FERN_CONFIG_FIELD_UNSUPPORTED",
|
|
1900
|
+
severity: "warning",
|
|
1901
|
+
path,
|
|
1902
|
+
reason: isObject(metadata.license) ? "A custom license file cannot be migrated automatically" : "metadata.license is not a license identifier",
|
|
1903
|
+
sdkConfigPath: ["targets", index, "package", "license"],
|
|
1904
|
+
suggestedAction: `Set targets.${index}.package.license manually.`
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
function mapCargoAuthors(identity, state, targetIndex) {
|
|
1908
|
+
const located = locate(identity.value, ["authors"], identity.path);
|
|
1909
|
+
const entries = located && stringArrayValue(located.value);
|
|
1910
|
+
if (!located || !entries) return;
|
|
1911
|
+
consume(state, located.path);
|
|
1912
|
+
const authors = entries.map(parseCargoAuthor);
|
|
1913
|
+
const parsed = sdkConfigV1PackageConfigSchema.shape.authors.safeParse(authors);
|
|
1914
|
+
const invalid = parsed.success ? [] : [...new Set(parsed.error.issues.map((issue) => issue.path[0]))].filter(
|
|
1915
|
+
(index) => typeof index === "number"
|
|
1916
|
+
);
|
|
1917
|
+
if (invalid.length === 0) {
|
|
1918
|
+
addPackageFallback(state, "authors", authors, located.path);
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
const authorsPath = ["targets", targetIndex, "package", "authors"];
|
|
1922
|
+
(state.valueDiagnostics ??= []).push(
|
|
1923
|
+
...invalid.map((entry) => ({
|
|
1924
|
+
code: "FERN_CONFIG_VALUE_INVALID",
|
|
1925
|
+
severity: "warning",
|
|
1926
|
+
path: [...located.path, entry],
|
|
1927
|
+
reason: 'CLI packageIdentity.authors was not migrated because this entry is not "Name" or "Name <email>" with a valid email',
|
|
1928
|
+
sdkConfigPath: authorsPath,
|
|
1929
|
+
suggestedAction: `Correct the entry, then set ${authorsPath.join(".")} manually.`
|
|
1930
|
+
}))
|
|
1931
|
+
);
|
|
1932
|
+
}
|
|
1933
|
+
function parseCargoAuthor(entry) {
|
|
1934
|
+
const trimmed = entry.trim();
|
|
1935
|
+
const match = /^(.*?)\s*<([^<>]*)>$/.exec(trimmed);
|
|
1936
|
+
if (!match) return { name: trimmed };
|
|
1937
|
+
const [, name = "", email = ""] = match;
|
|
1938
|
+
if (name !== "" && !emailSchema.safeParse(email).success) return { name: trimmed };
|
|
1939
|
+
return { name, email };
|
|
1940
|
+
}
|
|
1941
|
+
function licenseValue(value) {
|
|
1942
|
+
const license = stringValue(value)?.trim();
|
|
1943
|
+
return license ? { type: canonicalLicenseType(license) ?? license } : void 0;
|
|
1944
|
+
}
|
|
1945
|
+
function addPackageFallback(state, field, value, path) {
|
|
1946
|
+
consume(state, path);
|
|
1947
|
+
(state.packageFallbacks ??= []).push({ field, value, path });
|
|
1948
|
+
}
|
|
1447
1949
|
var OMIT = /* @__PURE__ */ Symbol("omit");
|
|
1448
1950
|
function inputJsonSchema(schema) {
|
|
1449
1951
|
return z.toJSONSchema(schema, {
|
|
@@ -1701,7 +2203,16 @@ var sdkConfigV1PublishConfigSchema = z.discriminatedUnion("registry", [
|
|
|
1701
2203
|
z.strictObject({
|
|
1702
2204
|
registry: z.literal("npm").describe("Publishes the package to an npm-compatible registry."),
|
|
1703
2205
|
token: nonEmptyStringSchema.optional().describe("The npm registry token, or an environment expression that resolves to it."),
|
|
2206
|
+
trustedPublishing: z.boolean().optional().describe("Whether npm publication uses trusted publishing (OIDC) instead of a token."),
|
|
1704
2207
|
...commonPublishShape
|
|
2208
|
+
}).superRefine((publish, context) => {
|
|
2209
|
+
if (publish.trustedPublishing === true && publish.token !== void 0) {
|
|
2210
|
+
context.addIssue({
|
|
2211
|
+
code: "custom",
|
|
2212
|
+
message: "token must be omitted when trustedPublishing is true",
|
|
2213
|
+
path: ["token"]
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
1705
2216
|
}),
|
|
1706
2217
|
z.strictObject({
|
|
1707
2218
|
registry: z.literal("pypi").describe("Publishes the package to a PyPI-compatible registry."),
|
|
@@ -1779,10 +2290,29 @@ var sdkConfigV1OutputConfigSchema = z.discriminatedUnion(
|
|
|
1779
2290
|
[filesOutputSchema, zipOutputSchema, githubDeliverySchema],
|
|
1780
2291
|
{ error: 'output.delivery must be one of "files", "zip", or "github"' }
|
|
1781
2292
|
);
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
2293
|
+
var cliDistributionShape = {
|
|
2294
|
+
distribution: cliDistributionConfigSchema.optional().describe(
|
|
2295
|
+
"CLI release channels published by the generated release workflow; credentials are GitHub Actions secret names."
|
|
2296
|
+
)
|
|
2297
|
+
};
|
|
2298
|
+
function rejectDistributionWithoutGithub(output, context) {
|
|
2299
|
+
if (output.distribution !== void 0) {
|
|
2300
|
+
context.addIssue({
|
|
2301
|
+
code: "custom",
|
|
2302
|
+
message: CLI_DISTRIBUTION_REQUIRES_GITHUB_DELIVERY_MESSAGE,
|
|
2303
|
+
path: ["distribution"]
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
var sdkConfigV1CliOutputConfigSchema = z.discriminatedUnion(
|
|
2308
|
+
"delivery",
|
|
2309
|
+
[
|
|
2310
|
+
filesOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
|
|
2311
|
+
zipOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
|
|
2312
|
+
githubDeliverySchema.extend(cliDistributionShape)
|
|
2313
|
+
],
|
|
2314
|
+
{ error: 'output.delivery must be one of "files", "zip", or "github"' }
|
|
2315
|
+
);
|
|
1786
2316
|
var sdkConfigV1ReplayConfigSchema = z.strictObject({
|
|
1787
2317
|
enabled: z.boolean().describe("Whether regeneration reapplies customer-authored repository changes.")
|
|
1788
2318
|
});
|
|
@@ -1859,10 +2389,6 @@ var sdkConfigV1SourceConfigSchema = z.strictObject({
|
|
|
1859
2389
|
seenIds.add(id);
|
|
1860
2390
|
});
|
|
1861
2391
|
});
|
|
1862
|
-
var cliGenerationConfigSchema = z.strictObject({
|
|
1863
|
-
paginationParameters: z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
|
|
1864
|
-
skills: z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands.")
|
|
1865
|
-
});
|
|
1866
2392
|
var csharpGenerationConfigSchema = z.strictObject({
|
|
1867
2393
|
useOptionalWrapper: z.boolean().optional().describe("Whether optional values use an explicit Optional wrapper."),
|
|
1868
2394
|
simplifyObjectDictionaries: z.boolean().optional().describe("Whether object schemas with arbitrary values use simplified dictionary types."),
|
|
@@ -1910,7 +2436,7 @@ var packageScriptSchema = z.strictObject({
|
|
|
1910
2436
|
command: nonEmptyStringSchema.describe("The command executed by the package script.")
|
|
1911
2437
|
});
|
|
1912
2438
|
var httpClientSchema = z.strictObject({
|
|
1913
|
-
name: z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
|
|
2439
|
+
name: z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
|
|
1914
2440
|
});
|
|
1915
2441
|
var typescriptGenerationConfigSchema = z.strictObject({
|
|
1916
2442
|
typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
|
|
@@ -1926,6 +2452,37 @@ var typescriptGenerationConfigSchema = z.strictObject({
|
|
|
1926
2452
|
/** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
|
|
1927
2453
|
namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
|
|
1928
2454
|
consolidateTypeFiles: z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
|
|
2455
|
+
formDataSupport: z.enum(["Node16", "Node18"]).optional().describe(
|
|
2456
|
+
"The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
|
|
2457
|
+
),
|
|
2458
|
+
allowExtraFields: z.boolean().optional().describe(
|
|
2459
|
+
"Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
|
|
2460
|
+
),
|
|
2461
|
+
generateSubpackageExports: z.boolean().optional().describe(
|
|
2462
|
+
"Whether the package manifest exports each subpackage client as its own entry point."
|
|
2463
|
+
),
|
|
2464
|
+
exportAllRequestsAtRoot: z.boolean().optional().describe("Whether every request type is also exported from the package root."),
|
|
2465
|
+
generateEndpointMetadata: z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
|
|
2466
|
+
outputEsm: z.boolean().optional().describe(
|
|
2467
|
+
"Whether the package is marked as an ES module while still shipping its CommonJS build."
|
|
2468
|
+
),
|
|
2469
|
+
neverThrowErrors: z.boolean().optional().describe(
|
|
2470
|
+
"Whether client methods return a wrapped response instead of throwing on a non-2xx status."
|
|
2471
|
+
),
|
|
2472
|
+
includeOtherInUnionTypes: z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
|
|
2473
|
+
includeUtilsOnUnionMembers: z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
|
|
2474
|
+
omitFernHeaders: z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
|
|
2475
|
+
linter: z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
|
|
2476
|
+
formatter: z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
|
|
2477
|
+
exports: jsonObjectSchema.optional().describe(
|
|
2478
|
+
"package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
|
|
2479
|
+
),
|
|
2480
|
+
files: z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
|
|
2481
|
+
engines: z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
|
|
2482
|
+
lintStaged: z.record(nonEmptyStringSchema, z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
|
|
2483
|
+
browser: z.record(nonEmptyStringSchema, z.union([z.boolean(), nonEmptyStringSchema])).optional().describe(
|
|
2484
|
+
"package.json browser field: a module or file is excluded (false) or replaced by another path."
|
|
2485
|
+
),
|
|
1929
2486
|
allowCustomFetcher: z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
|
|
1930
2487
|
useBrandedStringAliases: z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
|
|
1931
2488
|
useLegacyExports: z.boolean().optional().describe("Whether the package emits the legacy export layout."),
|
|
@@ -2115,7 +2672,10 @@ var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
|
|
|
2115
2672
|
z.strictObject({
|
|
2116
2673
|
language: z.literal("cli").describe("Generates a command-line interface."),
|
|
2117
2674
|
generation: sdkConfigV1GenerationConfigOverrideSchema.extend(cliGenerationConfigSchema.shape).optional().describe("Common and CLI-specific generation settings for this target."),
|
|
2118
|
-
...targetOverrideShape
|
|
2675
|
+
...targetOverrideShape,
|
|
2676
|
+
output: sdkConfigV1CliOutputConfigSchema.optional().describe(
|
|
2677
|
+
"Output configuration, including optional CLI distribution channels, that replaces the root output for this target."
|
|
2678
|
+
)
|
|
2119
2679
|
}),
|
|
2120
2680
|
z.strictObject({
|
|
2121
2681
|
language: z.literal("mcp").describe("Generates an MCP server."),
|
|
@@ -2132,7 +2692,7 @@ var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
|
|
|
2132
2692
|
// src/sdk-config/v1/sdk-config-v1.ts
|
|
2133
2693
|
var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
|
|
2134
2694
|
var publishRegistryLanguages = {
|
|
2135
|
-
npm: ["typescript", "mcp"],
|
|
2695
|
+
npm: ["typescript", "mcp", "cli"],
|
|
2136
2696
|
pypi: ["python"],
|
|
2137
2697
|
maven: ["java", "kotlin"],
|
|
2138
2698
|
nuget: ["csharp"],
|
|
@@ -2209,6 +2769,13 @@ function validateTargetPublishing(target, targetIndex, globalPackage, globalOutp
|
|
|
2209
2769
|
});
|
|
2210
2770
|
return;
|
|
2211
2771
|
}
|
|
2772
|
+
if (target.language === "cli" && output.delivery !== "github") {
|
|
2773
|
+
context.addIssue({
|
|
2774
|
+
code: "custom",
|
|
2775
|
+
message: CLI_PUBLISH_REQUIRES_GITHUB_DELIVERY_MESSAGE,
|
|
2776
|
+
path: target.output ? ["targets", targetIndex, "output", "delivery"] : ["output", "delivery"]
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2212
2779
|
validatePublishingIdentity(
|
|
2213
2780
|
{ ...globalPackage, ...target.package },
|
|
2214
2781
|
registry,
|
|
@@ -2321,16 +2888,33 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2321
2888
|
package: outputPackage,
|
|
2322
2889
|
generation: outputGeneration
|
|
2323
2890
|
}, index) => {
|
|
2891
|
+
const distribution = applyCliDistribution(output, invocation.cliDistribution, index);
|
|
2892
|
+
invocation.unsupportedFields.push(...distribution.diagnostics);
|
|
2324
2893
|
const target = {
|
|
2325
2894
|
language,
|
|
2326
|
-
output,
|
|
2895
|
+
output: distribution.output,
|
|
2327
2896
|
...optional("sdkName", generator.sdkName),
|
|
2328
2897
|
...optional("sdkVersion", generator.sdkVersion),
|
|
2329
2898
|
...optional("client", clients.targetOverrides[index]),
|
|
2330
2899
|
...optional("docs", docs.targetOverrides[index])
|
|
2331
2900
|
};
|
|
2332
|
-
|
|
2333
|
-
|
|
2901
|
+
const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
|
|
2902
|
+
invocation.unsupportedFields.push(
|
|
2903
|
+
...resolveTargetPackage(
|
|
2904
|
+
mappedPackage,
|
|
2905
|
+
invocation.packageFallbacks,
|
|
2906
|
+
generator,
|
|
2907
|
+
output.delivery,
|
|
2908
|
+
index
|
|
2909
|
+
)
|
|
2910
|
+
);
|
|
2911
|
+
const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
|
|
2912
|
+
language,
|
|
2913
|
+
output,
|
|
2914
|
+
generator
|
|
2915
|
+
});
|
|
2916
|
+
if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
|
|
2917
|
+
target.package = targetPackage;
|
|
2334
2918
|
}
|
|
2335
2919
|
const targetGeneration = {
|
|
2336
2920
|
...generations.targetOverrides[index],
|
|
@@ -2397,6 +2981,21 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2397
2981
|
])
|
|
2398
2982
|
};
|
|
2399
2983
|
}
|
|
2984
|
+
function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
|
|
2985
|
+
if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
|
|
2986
|
+
return packageConfig;
|
|
2987
|
+
}
|
|
2988
|
+
const { packageName } = packageConfig;
|
|
2989
|
+
return {
|
|
2990
|
+
...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
|
|
2991
|
+
...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
|
|
2992
|
+
...packageConfig
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
function usesCustomLicenseFile({ config, raw }) {
|
|
2996
|
+
const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
|
|
2997
|
+
return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
|
|
2998
|
+
}
|
|
2400
2999
|
function resolveLanguage(generator, index) {
|
|
2401
3000
|
const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
|
|
2402
3001
|
if (!language || !isFernLanguage(language)) {
|
|
@@ -2512,10 +3111,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
|
|
|
2512
3111
|
...optional("smartCasingDigitWordBoundary", smartCasingDigitWordBoundary)
|
|
2513
3112
|
};
|
|
2514
3113
|
}
|
|
2515
|
-
const targetGeneration = mapLanguageConfig(
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
3114
|
+
const targetGeneration = mapLanguageConfig(
|
|
3115
|
+
language,
|
|
3116
|
+
config,
|
|
3117
|
+
state,
|
|
3118
|
+
packageConfig,
|
|
3119
|
+
[...prefix, "config"],
|
|
3120
|
+
index
|
|
3121
|
+
);
|
|
2519
3122
|
mapPublishMetadata(generator.publishMetadata, packageConfig);
|
|
2520
3123
|
if (generator.keywords?.length) {
|
|
2521
3124
|
generation.reservedKeywords = [...generator.keywords];
|
|
@@ -2531,13 +3134,30 @@ function mapInvocation(generator, language, activeLanguages, index) {
|
|
|
2531
3134
|
}
|
|
2532
3135
|
}
|
|
2533
3136
|
const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
|
|
3137
|
+
if (language === "typescript") {
|
|
3138
|
+
const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
|
|
3139
|
+
...prefix,
|
|
3140
|
+
"config"
|
|
3141
|
+
]);
|
|
3142
|
+
if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
|
|
3143
|
+
}
|
|
2534
3144
|
const unsupportedFields = [
|
|
3145
|
+
...state.valueDiagnostics ?? [],
|
|
2535
3146
|
...collectUnsupported(config, [...prefix, "config"], state),
|
|
2536
3147
|
...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
|
|
2537
3148
|
...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
|
|
2538
3149
|
...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
|
|
2539
3150
|
];
|
|
2540
|
-
return {
|
|
3151
|
+
return {
|
|
3152
|
+
client,
|
|
3153
|
+
docs,
|
|
3154
|
+
generation,
|
|
3155
|
+
package: packageConfig,
|
|
3156
|
+
packageFallbacks: state.packageFallbacks ?? [],
|
|
3157
|
+
...optional("cliDistribution", state.cliDistribution),
|
|
3158
|
+
targetGeneration,
|
|
3159
|
+
unsupportedFields
|
|
3160
|
+
};
|
|
2541
3161
|
}
|
|
2542
3162
|
function unsupportedResolvedFields(generator, index, idempotencyMapped) {
|
|
2543
3163
|
const values = [
|
|
@@ -2701,7 +3321,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
|
|
|
2701
3321
|
});
|
|
2702
3322
|
if (Object.keys(naming).length) generation.naming = naming;
|
|
2703
3323
|
const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
|
|
2704
|
-
|
|
3324
|
+
const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
|
|
3325
|
+
if (wireTests !== void 0 || wireTestsFallback !== void 0) {
|
|
3326
|
+
generation.wireTests = { enabled: wireTests ?? true };
|
|
3327
|
+
if (wireTestsFallback !== void 0) {
|
|
3328
|
+
generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
2705
3331
|
const webSockets = takeBoolean(
|
|
2706
3332
|
config,
|
|
2707
3333
|
["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
|
|
@@ -2727,6 +3353,7 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
|
|
|
2727
3353
|
const packagePath = takeString(config, ["packagePath"], state, basePath);
|
|
2728
3354
|
if (packagePath !== void 0) generation.layout = { packagePath };
|
|
2729
3355
|
mapDependencies(config, state, packageConfig, basePath);
|
|
3356
|
+
mapPeerDependenciesMeta(config, state, packageConfig, basePath);
|
|
2730
3357
|
}
|
|
2731
3358
|
function mapTypescriptStreams(config, state, basePath) {
|
|
2732
3359
|
const responseType = takeEnum(config, ["streamType"], ["wrapper", "web"], state, basePath);
|
|
@@ -2740,13 +3367,13 @@ function mapTypescriptStreams(config, state, basePath) {
|
|
|
2740
3367
|
if (responseType === void 0 && fileResponseType === void 0) return void 0;
|
|
2741
3368
|
return { enabled: true, ...compact({ responseType, fileResponseType }) };
|
|
2742
3369
|
}
|
|
2743
|
-
function mapLanguageConfig(language, config, state, packageConfig, basePath) {
|
|
3370
|
+
function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
|
|
2744
3371
|
switch (language) {
|
|
2745
3372
|
case "typescript":
|
|
2746
|
-
return mapTypescript(config, state, packageConfig, basePath);
|
|
3373
|
+
return mapTypescript(config, state, packageConfig, basePath, true);
|
|
2747
3374
|
case "mcp":
|
|
2748
3375
|
return {
|
|
2749
|
-
...mapTypescript(config, state, packageConfig, basePath),
|
|
3376
|
+
...mapTypescript(config, state, packageConfig, basePath, false),
|
|
2750
3377
|
...mapMcp(config, state, basePath)
|
|
2751
3378
|
};
|
|
2752
3379
|
case "python":
|
|
@@ -2767,12 +3394,12 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath) {
|
|
|
2767
3394
|
case "swift":
|
|
2768
3395
|
return mapSwift(config, state, basePath);
|
|
2769
3396
|
case "cli":
|
|
2770
|
-
return mapCli(config, state, packageConfig, basePath);
|
|
3397
|
+
return mapCli(config, state, packageConfig, basePath, targetIndex);
|
|
2771
3398
|
case "terraform":
|
|
2772
3399
|
return mapTerraform(config, state, packageConfig, basePath);
|
|
2773
3400
|
}
|
|
2774
3401
|
}
|
|
2775
|
-
function mapTypescript(config, state, packageConfig, basePath) {
|
|
3402
|
+
function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
|
|
2776
3403
|
const packageJsonManifest = mapPackageManifest(
|
|
2777
3404
|
config,
|
|
2778
3405
|
["packageJson"],
|
|
@@ -2784,18 +3411,75 @@ function mapTypescript(config, state, packageConfig, basePath) {
|
|
|
2784
3411
|
const packageManagerAtIndex = packageJsonPackageManager ? packageJsonPackageManager.indexOf("@", packageJsonPackageManager.startsWith("@") ? 1 : 0) : -1;
|
|
2785
3412
|
const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
|
|
2786
3413
|
const packageManagerVersion = packageManagerVersionPart || void 0;
|
|
3414
|
+
if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
|
|
3415
|
+
const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
|
|
2787
3416
|
const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
|
|
2788
3417
|
const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
|
|
2789
|
-
const fetchSupport = takeEnum(
|
|
3418
|
+
const fetchSupport = takeEnum(
|
|
3419
|
+
config,
|
|
3420
|
+
["fetchSupport"],
|
|
3421
|
+
sdkTarget ? ["native", "node-fetch"] : ["native"],
|
|
3422
|
+
state,
|
|
3423
|
+
basePath
|
|
3424
|
+
);
|
|
2790
3425
|
const namingObject = takeObject(config, ["naming"], state, basePath);
|
|
2791
3426
|
const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
|
|
3427
|
+
const sdkOnlyOptions = sdkTarget ? {
|
|
3428
|
+
formDataSupport: takeEnum(
|
|
3429
|
+
config,
|
|
3430
|
+
["formDataSupport"],
|
|
3431
|
+
["Node16", "Node18"],
|
|
3432
|
+
state,
|
|
3433
|
+
basePath
|
|
3434
|
+
),
|
|
3435
|
+
allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
|
|
3436
|
+
generateSubpackageExports: takeBoolean(
|
|
3437
|
+
config,
|
|
3438
|
+
["generateSubpackageExports"],
|
|
3439
|
+
state,
|
|
3440
|
+
basePath
|
|
3441
|
+
),
|
|
3442
|
+
exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
|
|
3443
|
+
generateEndpointMetadata: takeBoolean(
|
|
3444
|
+
config,
|
|
3445
|
+
["generateEndpointMetadata"],
|
|
3446
|
+
state,
|
|
3447
|
+
basePath
|
|
3448
|
+
),
|
|
3449
|
+
outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
|
|
3450
|
+
neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
|
|
3451
|
+
includeOtherInUnionTypes: takeBoolean(
|
|
3452
|
+
config,
|
|
3453
|
+
["includeOtherInUnionTypes"],
|
|
3454
|
+
state,
|
|
3455
|
+
basePath
|
|
3456
|
+
),
|
|
3457
|
+
includeUtilsOnUnionMembers: takeBoolean(
|
|
3458
|
+
config,
|
|
3459
|
+
["includeUtilsOnUnionMembers"],
|
|
3460
|
+
state,
|
|
3461
|
+
basePath
|
|
3462
|
+
),
|
|
3463
|
+
omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
|
|
3464
|
+
linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
|
|
3465
|
+
formatter: takeEnum(
|
|
3466
|
+
config,
|
|
3467
|
+
["formatter"],
|
|
3468
|
+
["prettier", "biome", "oxfmt", "none"],
|
|
3469
|
+
state,
|
|
3470
|
+
basePath
|
|
3471
|
+
)
|
|
3472
|
+
} : {};
|
|
2792
3473
|
return compact({
|
|
3474
|
+
...sdkOnlyOptions,
|
|
3475
|
+
// Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
|
|
3476
|
+
...manifestOptions,
|
|
2793
3477
|
typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
|
|
2794
3478
|
zodVersion: takeString(config, ["zodVersion"], state, basePath),
|
|
2795
3479
|
packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
|
|
2796
3480
|
packageManagerVersion,
|
|
2797
3481
|
testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
|
|
2798
|
-
httpClient: fetchSupport ===
|
|
3482
|
+
httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
|
|
2799
3483
|
bundle: takeBoolean(config, ["bundle"], state, basePath),
|
|
2800
3484
|
exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
|
|
2801
3485
|
namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
|
|
@@ -2953,6 +3637,7 @@ function mapRust(config, state, packageConfig, basePath) {
|
|
|
2953
3637
|
const description = takeString(config, ["packageDescription"], state, basePath);
|
|
2954
3638
|
const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
|
|
2955
3639
|
Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
|
|
3640
|
+
mapLicenseFallback(config, ["packageLicense"], state, basePath);
|
|
2956
3641
|
return compact({
|
|
2957
3642
|
dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
|
|
2958
3643
|
capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
|
|
@@ -2966,7 +3651,7 @@ function mapSwift(config, state, basePath) {
|
|
|
2966
3651
|
nullableAsOptional: takeBoolean(config, ["nullableAsOptional"], state, basePath)
|
|
2967
3652
|
});
|
|
2968
3653
|
}
|
|
2969
|
-
function mapCli(config, state, packageConfig, basePath) {
|
|
3654
|
+
function mapCli(config, state, packageConfig, basePath, targetIndex) {
|
|
2970
3655
|
const identity = takeObject(config, ["packageIdentity"], state, basePath);
|
|
2971
3656
|
if (identity) {
|
|
2972
3657
|
Object.assign(
|
|
@@ -2977,10 +3662,13 @@ function mapCli(config, state, packageConfig, basePath) {
|
|
|
2977
3662
|
description: takeString(identity.value, ["description"], state, identity.path)
|
|
2978
3663
|
})
|
|
2979
3664
|
);
|
|
3665
|
+
mapCliPackageIdentity(identity, state, targetIndex);
|
|
2980
3666
|
}
|
|
3667
|
+
mapCliDistribution(config, state, basePath, targetIndex);
|
|
2981
3668
|
return compact({
|
|
2982
3669
|
paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
|
|
2983
|
-
skills: takeBoolean(config, ["skills"], state, basePath)
|
|
3670
|
+
skills: takeBoolean(config, ["skills"], state, basePath),
|
|
3671
|
+
...mapCliGeneration(config, state, basePath, targetIndex)
|
|
2984
3672
|
});
|
|
2985
3673
|
}
|
|
2986
3674
|
function mapTerraform(config, state, packageConfig, basePath) {
|
|
@@ -3064,6 +3752,48 @@ function mapDependencies(config, state, packageConfig, basePath) {
|
|
|
3064
3752
|
if (dependencies.length) packageConfig[field] = dependencies;
|
|
3065
3753
|
}
|
|
3066
3754
|
}
|
|
3755
|
+
function liftPackageJsonDependencies(manifest, state, packageConfig) {
|
|
3756
|
+
for (const [field, target] of [
|
|
3757
|
+
["dependencies", "extraDependencies"],
|
|
3758
|
+
["devDependencies", "extraDevDependencies"],
|
|
3759
|
+
["peerDependencies", "extraPeerDependencies"]
|
|
3760
|
+
]) {
|
|
3761
|
+
const located = takeObject(manifest.value, [field], state, manifest.path);
|
|
3762
|
+
if (!located) continue;
|
|
3763
|
+
const lifted = Object.entries(located.value).flatMap(
|
|
3764
|
+
([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
|
|
3765
|
+
);
|
|
3766
|
+
if (lifted.length) packageConfig[target] = overrideByName(packageConfig[target] ?? [], lifted);
|
|
3767
|
+
}
|
|
3768
|
+
const meta = takeObject(manifest.value, ["peerDependenciesMeta"], state, manifest.path);
|
|
3769
|
+
if (!meta) return;
|
|
3770
|
+
const entries = peerDependenciesMetaEntries(meta, state);
|
|
3771
|
+
if (entries.length) {
|
|
3772
|
+
packageConfig.extraPeerDependenciesMeta = {
|
|
3773
|
+
...packageConfig.extraPeerDependenciesMeta,
|
|
3774
|
+
...Object.fromEntries(entries)
|
|
3775
|
+
};
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
function overrideByName(existing, overrides) {
|
|
3779
|
+
const byName = new Map(existing.map((dependency) => [dependency.name, dependency]));
|
|
3780
|
+
overrides.forEach((dependency) => byName.set(dependency.name, dependency));
|
|
3781
|
+
return [...byName.values()];
|
|
3782
|
+
}
|
|
3783
|
+
function mapPeerDependenciesMeta(config, state, packageConfig, basePath) {
|
|
3784
|
+
const located = takeObject(config, ["extraPeerDependenciesMeta"], state, basePath);
|
|
3785
|
+
if (!located) return;
|
|
3786
|
+
const entries = peerDependenciesMetaEntries(located, state);
|
|
3787
|
+
if (entries.length) packageConfig.extraPeerDependenciesMeta = Object.fromEntries(entries);
|
|
3788
|
+
}
|
|
3789
|
+
function peerDependenciesMetaEntries(located, state) {
|
|
3790
|
+
return Object.entries(located.value).flatMap(([name, value]) => {
|
|
3791
|
+
const parsed = jsonObjectSchema.safeParse(value);
|
|
3792
|
+
if (!parsed.success) return [];
|
|
3793
|
+
consume(state, [...located.path, name]);
|
|
3794
|
+
return [[name, parsed.data]];
|
|
3795
|
+
});
|
|
3796
|
+
}
|
|
3067
3797
|
function mapDependency(name, value, state, path) {
|
|
3068
3798
|
if (typeof value === "string" && value) {
|
|
3069
3799
|
consume(state, path);
|
|
@@ -3071,13 +3801,7 @@ function mapDependency(name, value, state, path) {
|
|
|
3071
3801
|
}
|
|
3072
3802
|
if (!isObject(value)) return [];
|
|
3073
3803
|
const version = takeString(value, ["version"], state, path);
|
|
3074
|
-
const
|
|
3075
|
-
const localPath = takeString(value, ["path"], state, path);
|
|
3076
|
-
const source = gitUrl ? {
|
|
3077
|
-
type: "git",
|
|
3078
|
-
url: gitUrl,
|
|
3079
|
-
...optional("ref", takeString(value, ["ref"], state, path))
|
|
3080
|
-
} : localPath ? { type: "path", path: localPath } : void 0;
|
|
3804
|
+
const source = takeDependencySource(value, state, path);
|
|
3081
3805
|
if (!version && !source) return [];
|
|
3082
3806
|
return [
|
|
3083
3807
|
{
|
|
@@ -3093,6 +3817,17 @@ function mapDependency(name, value, state, path) {
|
|
|
3093
3817
|
}
|
|
3094
3818
|
];
|
|
3095
3819
|
}
|
|
3820
|
+
function takeDependencySource(value, state, path) {
|
|
3821
|
+
const gitUrl = takeString(value, ["git"], state, path);
|
|
3822
|
+
if (gitUrl) {
|
|
3823
|
+
const ref = takeString(value, ["ref", "rev", "branch"], state, path);
|
|
3824
|
+
return { type: "git", url: gitUrl, ...optional("ref", ref) };
|
|
3825
|
+
}
|
|
3826
|
+
const localPath = takeString(value, ["path"], state, path);
|
|
3827
|
+
if (localPath) return { type: "path", path: localPath };
|
|
3828
|
+
const registry = takeString(value, ["registry"], state, path);
|
|
3829
|
+
return registry ? { type: "registry", registry } : void 0;
|
|
3830
|
+
}
|
|
3096
3831
|
function takeCustomSections(value, language, activeLanguages, state, basePath) {
|
|
3097
3832
|
const located = locate(value, ["customSections"], basePath);
|
|
3098
3833
|
if (!located || !Array.isArray(located.value)) return void 0;
|
|
@@ -3141,6 +3876,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
|
|
|
3141
3876
|
);
|
|
3142
3877
|
return manifest;
|
|
3143
3878
|
}
|
|
3879
|
+
function mapPackageManifestOptions(manifest, state, packageConfig) {
|
|
3880
|
+
const bugs = takeManifestBugs(manifest, state);
|
|
3881
|
+
if (bugs) packageConfig.bugs = bugs;
|
|
3882
|
+
const repository = takeManifestRepository(manifest, state);
|
|
3883
|
+
if (repository !== void 0 && packageConfig.repository === void 0) {
|
|
3884
|
+
packageConfig.repository = repository;
|
|
3885
|
+
}
|
|
3886
|
+
const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
|
|
3887
|
+
if (exports) consume(state, exports.path);
|
|
3888
|
+
return compact({
|
|
3889
|
+
exports: exports?.value,
|
|
3890
|
+
scripts: takeManifestScripts(manifest, state),
|
|
3891
|
+
files: takeStringArray(manifest.value, ["files"], state, manifest.path),
|
|
3892
|
+
engines: takeManifestStringRecord(manifest, "engines", state),
|
|
3893
|
+
lintStaged: takeManifestLintStaged(manifest, state),
|
|
3894
|
+
browser: takeManifestBrowser(manifest, state)
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3897
|
+
function takeManifestBugs(manifest, state) {
|
|
3898
|
+
const text = takeString(manifest.value, ["bugs"], state, manifest.path);
|
|
3899
|
+
if (text !== void 0) return { url: text };
|
|
3900
|
+
const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
|
|
3901
|
+
if (!located) return void 0;
|
|
3902
|
+
const url = takeString(located.value, ["url"], state, located.path);
|
|
3903
|
+
const email = takeString(located.value, ["email"], state, located.path);
|
|
3904
|
+
return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
|
|
3905
|
+
}
|
|
3906
|
+
function takeManifestRepository(manifest, state) {
|
|
3907
|
+
const text = takeString(manifest.value, ["repository"], state, manifest.path);
|
|
3908
|
+
if (text !== void 0) return text;
|
|
3909
|
+
const located = takeObject(manifest.value, ["repository"], state, manifest.path);
|
|
3910
|
+
if (!located) return void 0;
|
|
3911
|
+
const url = takeString(located.value, ["url"], state, located.path);
|
|
3912
|
+
if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
|
|
3913
|
+
return url;
|
|
3914
|
+
}
|
|
3915
|
+
function takeManifestScripts(manifest, state) {
|
|
3916
|
+
const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
|
|
3917
|
+
if (!located) return void 0;
|
|
3918
|
+
const scripts = Object.entries(located.value).flatMap(([name, command]) => {
|
|
3919
|
+
if (typeof command !== "string" || !command) return [];
|
|
3920
|
+
consume(state, [...located.path, name]);
|
|
3921
|
+
return [{ name, command }];
|
|
3922
|
+
});
|
|
3923
|
+
return scripts.length ? scripts : void 0;
|
|
3924
|
+
}
|
|
3925
|
+
function takeManifestStringRecord(manifest, key, state) {
|
|
3926
|
+
const located = takeObject(manifest.value, [key], state, manifest.path);
|
|
3927
|
+
if (!located) return void 0;
|
|
3928
|
+
const entries = Object.entries(located.value).flatMap(([name, value]) => {
|
|
3929
|
+
if (typeof value !== "string" || !value) return [];
|
|
3930
|
+
consume(state, [...located.path, name]);
|
|
3931
|
+
return [[name, value]];
|
|
3932
|
+
});
|
|
3933
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3934
|
+
}
|
|
3935
|
+
function takeManifestLintStaged(manifest, state) {
|
|
3936
|
+
const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
|
|
3937
|
+
if (!located) return void 0;
|
|
3938
|
+
const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
|
|
3939
|
+
const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
|
|
3940
|
+
if (!list?.length || list.some((command) => !command)) return [];
|
|
3941
|
+
consume(state, [...located.path, glob]);
|
|
3942
|
+
return [[glob, list]];
|
|
3943
|
+
});
|
|
3944
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3945
|
+
}
|
|
3946
|
+
function takeManifestBrowser(manifest, state) {
|
|
3947
|
+
const located = takeObject(manifest.value, ["browser"], state, manifest.path);
|
|
3948
|
+
if (!located) return void 0;
|
|
3949
|
+
const entries = Object.entries(located.value).flatMap(([name, value]) => {
|
|
3950
|
+
if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
|
|
3951
|
+
consume(state, [...located.path, name]);
|
|
3952
|
+
return [[name, value]];
|
|
3953
|
+
});
|
|
3954
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3955
|
+
}
|
|
3144
3956
|
function takeManifestAuthors(manifest, state) {
|
|
3145
3957
|
const located = locate(manifest.value, ["authors"], manifest.path);
|
|
3146
3958
|
if (!located || !Array.isArray(located.value)) return [];
|
|
@@ -3251,6 +4063,6 @@ function takeToolsets(value, aliases, state, basePath) {
|
|
|
3251
4063
|
return Object.fromEntries(entries.filter((entry) => entry !== void 0));
|
|
3252
4064
|
}
|
|
3253
4065
|
|
|
3254
|
-
export { FernConfigMappingError, SDK_CONFIG_V1_SCHEMA_VERSION, mapFernConfigToSdkConfigV1, parseSdkConfigV1, parseSdkConfigV1ForConsumption, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, sdkConfigV1GenerationConfigSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, relativePathSchema as sdkConfigV1RelativePathSchema, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, splitSdkConfigV1TargetGeneration, validateSdkConfigV1 };
|
|
4066
|
+
export { FernConfigMappingError, CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE as SDK_CONFIG_V1_CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE, SDK_CONFIG_V1_SCHEMA_VERSION, getSdkConfigV1Diagnostics, mapFernConfigToSdkConfigV1, parseSdkConfigV1, parseSdkConfigV1ForConsumption, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliDistributionConfigSchema as sdkConfigV1CliDistributionConfigSchema, cliDistributionGithubAppSchema as sdkConfigV1CliDistributionGithubAppSchema, cliDistributionHomebrewSchema as sdkConfigV1CliDistributionHomebrewSchema, cliDistributionScoopSchema as sdkConfigV1CliDistributionScoopSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1CliOutputConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, sdkConfigV1GenerationConfigSchema, githubActionsSecretNameSchema as sdkConfigV1GithubActionsSecretNameSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, relativePathSchema as sdkConfigV1RelativePathSchema, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, splitSdkConfigV1TargetGeneration, validateSdkConfigV1 };
|
|
3255
4067
|
//# sourceMappingURL=index.js.map
|
|
3256
4068
|
//# sourceMappingURL=index.js.map
|