@postman/sdk-config 0.3.0 → 0.3.2

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/dist/index.js CHANGED
@@ -277,8 +277,8 @@ var clientConfigSchema = z.strictObject({
277
277
  var sdkConfigV1ClientConfigSchema = clientConfigSchema;
278
278
  var sdkConfigV1ClientConfigOverrideSchema = clientConfigOverrideSchema;
279
279
  var goModulePathSchema = relativePathSchema.regex(
280
- /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)+$/,
281
- "Go module path must be a slash-delimited path using letters, numbers, dots, dashes, underscores, or tildes"
280
+ /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/,
281
+ "Go module path must use letters, numbers, dots, dashes, underscores or tildes, in slash-delimited segments"
282
282
  );
283
283
  var composerPackageNameSchema = nonEmptyStringSchema.regex(
284
284
  /^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$/,
@@ -543,6 +543,9 @@ function compact(value) {
543
543
  function optional(key, value) {
544
544
  return value === void 0 ? {} : { [key]: value };
545
545
  }
546
+ function optionalObject(key, value) {
547
+ return Object.keys(value).length === 0 ? {} : { [key]: value };
548
+ }
546
549
  function isObject(value) {
547
550
  return value !== null && typeof value === "object" && !Array.isArray(value);
548
551
  }
@@ -702,6 +705,7 @@ function githubOutput(value, publishInfo, language, sourcePath, state, index) {
702
705
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
703
706
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
704
707
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
708
+ const credentials = mapCredentials(value.credentials, [...sourcePath, "credentials"], state);
705
709
  return {
706
710
  output: {
707
711
  delivery: "github",
@@ -710,13 +714,58 @@ function githubOutput(value, publishInfo, language, sourcePath, state, index) {
710
714
  ...optional("host", stringValue(value.host)),
711
715
  ...optional("branch", stringValue(value.branch)),
712
716
  mode: value.makePr === true || type === "pullRequest" ? "pull-request" : type === "push" ? "push" : "release",
713
- ...optional("reviewers", reviewers)
717
+ ...optional("reviewers", reviewers),
718
+ ...optional("credentials", credentials)
714
719
  },
715
720
  ...publication ? { publish: publication.publish } : {}
716
721
  },
717
722
  ...optional("package", publication?.package)
718
723
  };
719
724
  }
725
+ function mapCredentials(value, sourcePath, state) {
726
+ if (!isObject(value)) return void 0;
727
+ return credentialsFromObject(value, sourcePath, state);
728
+ }
729
+ function mapInlineCredentials(value, sourcePath, state) {
730
+ const credentials = mapCredentials(value.credentials, [...sourcePath, "credentials"], state);
731
+ if (credentials) return credentials;
732
+ return credentialsFromObject(value, sourcePath, state);
733
+ }
734
+ function credentialsFromObject(value, sourcePath, state) {
735
+ const credentials = {};
736
+ const username = stringValue(value.username);
737
+ const password = stringValue(value.password);
738
+ const token = stringValue(value.token);
739
+ const apiKey = stringValue(value.apiKey);
740
+ if (username) {
741
+ credentials.username = username;
742
+ consume(state, [...sourcePath, "username"]);
743
+ }
744
+ if (password) {
745
+ credentials.password = password;
746
+ consume(state, [...sourcePath, "password"]);
747
+ }
748
+ if (token) {
749
+ credentials.token = token;
750
+ consume(state, [...sourcePath, "token"]);
751
+ }
752
+ if (apiKey) {
753
+ credentials.apiKey = apiKey;
754
+ consume(state, [...sourcePath, "apiKey"]);
755
+ }
756
+ return Object.keys(credentials).length === 0 ? void 0 : credentials;
757
+ }
758
+ function mapMavenSignature(value, sourcePath, state) {
759
+ if (!isObject(value)) return void 0;
760
+ const keyId = stringValue(value.keyId);
761
+ const password = stringValue(value.password);
762
+ const secretKey = stringValue(value.secretKey);
763
+ if (!keyId || !password || !secretKey) return void 0;
764
+ consume(state, [...sourcePath, "keyId"]);
765
+ consume(state, [...sourcePath, "password"]);
766
+ consume(state, [...sourcePath, "secretKey"]);
767
+ return { keyId, password, secretKey };
768
+ }
720
769
  function mapReviewers(value, sourcePath, state) {
721
770
  if (Array.isArray(value)) {
722
771
  const teams2 = reviewerNames(value, "team", sourcePath, state);
@@ -760,11 +809,13 @@ function mapPublication(value, language, sourcePath, state, index) {
760
809
  const registry = publicationRegistry(type, language, [...sourcePath, "type"], index);
761
810
  const registryUrl = stringValue(nested.registryUrl);
762
811
  if (registryUrl) consume(state, [...nestedPath, "registryUrl"]);
812
+ const credentials = mapInlineCredentials(nested, nestedPath, state);
763
813
  if (registry === "maven") {
764
814
  const coordinate = stringValue(nested.coordinate);
815
+ const signature = mapMavenSignature(nested.signature, [...nestedPath, "signature"], state);
765
816
  if (coordinate) consume(state, [...nestedPath, "coordinate"]);
766
817
  return {
767
- publish: compact({ registry, url: registryUrl }),
818
+ publish: compact({ registry, url: registryUrl, credentials, signature }),
768
819
  ...coordinate ? { package: mavenPackage(coordinate, [...nestedPath, "coordinate"], index) } : {}
769
820
  };
770
821
  }
@@ -773,7 +824,7 @@ function mapPublication(value, language, sourcePath, state, index) {
773
824
  if (packageName) consume(state, [...nestedPath, packageNameField]);
774
825
  const metadata = registry === "pypi" ? mapPypiMetadata(nested.pypiMetadata, nestedPath, state) : {};
775
826
  return {
776
- publish: compact({ registry, url: registryUrl }),
827
+ publish: compact({ registry, url: registryUrl, credentials }),
777
828
  ...packageName || Object.keys(metadata).length ? { package: { ...optional("packageName", packageName), ...metadata } } : {}
778
829
  };
779
830
  }
@@ -890,7 +941,11 @@ function finishOutputMapping(mapping, outputMode, sourcePath, state, index) {
890
941
  code: "FERN_OUTPUT_CREDENTIAL_UNSUPPORTED",
891
942
  severity: "warning",
892
943
  path: sourcePath,
893
- reason: "Fern output credentials and signatures are intentionally excluded from SDK Config v1",
944
+ // This diagnostic only captures credential/signature fields that remained
945
+ // unconsumed after mapping supported registry/GitHub credentials into
946
+ // SDK Config v1. Supported credential shapes are carried through; this
947
+ // warning is about the remaining legacy-only credential fields.
948
+ reason: "Some Fern output credentials and signatures are intentionally excluded from SDK Config v1 when they cannot be represented in the public schema",
894
949
  suggestedAction: "Provide publishing credentials through the build request or external secret resolution."
895
950
  }
896
951
  ] : [],
@@ -1110,15 +1165,33 @@ var sdkConfigV1PublishRegistrySchema = z.enum([
1110
1165
  "go",
1111
1166
  "composer"
1112
1167
  ]);
1168
+ var registryCredentialsSchema = z.strictObject({
1169
+ username: nonEmptyStringSchema.optional(),
1170
+ password: nonEmptyStringSchema.optional(),
1171
+ token: nonEmptyStringSchema.optional(),
1172
+ apiKey: nonEmptyStringSchema.optional()
1173
+ });
1174
+ var mavenSignatureSchema = z.strictObject({
1175
+ keyId: nonEmptyStringSchema,
1176
+ password: nonEmptyStringSchema,
1177
+ secretKey: nonEmptyStringSchema
1178
+ });
1113
1179
  var commonPublishShape = {
1114
1180
  url: nonEmptyStringSchema.optional(),
1181
+ /** Raw registry credentials. These values can be sensitive and must be handled as secrets. */
1182
+ credentials: registryCredentialsSchema.optional(),
1115
1183
  releaseBranch: nonEmptyStringSchema.optional(),
1116
1184
  tolerateRepublish: z.boolean().optional()
1117
1185
  };
1118
1186
  var sdkConfigV1PublishConfigSchema = z.discriminatedUnion("registry", [
1119
1187
  z.strictObject({ registry: z.literal("npm"), ...commonPublishShape }),
1120
1188
  z.strictObject({ registry: z.literal("pypi"), ...commonPublishShape }),
1121
- z.strictObject({ registry: z.literal("maven"), ...commonPublishShape }),
1189
+ z.strictObject({
1190
+ registry: z.literal("maven"),
1191
+ /** Raw Maven signing material. These values can be sensitive and must be handled as secrets. */
1192
+ signature: mavenSignatureSchema.optional(),
1193
+ ...commonPublishShape
1194
+ }),
1122
1195
  z.strictObject({ registry: z.literal("nuget"), ...commonPublishShape }),
1123
1196
  z.strictObject({ registry: z.literal("rubygems"), ...commonPublishShape }),
1124
1197
  z.strictObject({ registry: z.literal("crates"), ...commonPublishShape }),
@@ -1129,12 +1202,15 @@ var reviewersSchema = z.strictObject({
1129
1202
  teams: z.array(nonEmptyStringSchema).optional(),
1130
1203
  users: z.array(nonEmptyStringSchema).optional()
1131
1204
  });
1205
+ var githubCredentialsSchema = registryCredentialsSchema;
1132
1206
  var githubOutputSchema = z.strictObject({
1133
1207
  repository: nonEmptyStringSchema,
1134
1208
  host: nonEmptyStringSchema.optional(),
1135
1209
  branch: nonEmptyStringSchema.optional(),
1136
- mode: z.enum(["release", "pull-request", "push"]).optional(),
1210
+ mode: z.enum(["release", "pull-request", "push", "commit", "commit-and-release"]).optional(),
1137
1211
  reviewers: reviewersSchema.optional(),
1212
+ /** Raw GitHub credentials. These values can be sensitive and must be handled as secrets. */
1213
+ credentials: githubCredentialsSchema.optional(),
1138
1214
  privateRepository: z.boolean().optional()
1139
1215
  });
1140
1216
  var filesOutputSchema = z.strictObject({
@@ -1552,12 +1628,12 @@ var sdkConfigV1Schema = z.strictObject({
1552
1628
  sdkVersion: nonEmptyStringSchema.default("1.0.0"),
1553
1629
  apiVersion: nonEmptyStringSchema.optional(),
1554
1630
  source: sdkConfigV1SourceConfigSchema,
1555
- api: sdkConfigV1ApiConfigSchema,
1556
- client: sdkConfigV1ClientConfigSchema,
1557
- package: sdkConfigV1PackageConfigSchema,
1631
+ api: sdkConfigV1ApiConfigSchema.prefault({}),
1632
+ client: sdkConfigV1ClientConfigSchema.prefault({}),
1633
+ package: sdkConfigV1PackageConfigSchema.prefault({}),
1558
1634
  output: sdkConfigV1OutputConfigSchema.optional(),
1559
- docs: sdkConfigV1DocsConfigSchema,
1560
- generation: sdkConfigV1GenerationConfigSchema,
1635
+ docs: sdkConfigV1DocsConfigSchema.prefault({}),
1636
+ generation: sdkConfigV1GenerationConfigSchema.prefault({}),
1561
1637
  targets: z.array(sdkConfigV1TargetSchema).min(1)
1562
1638
  }).superRefine(({ output, package: globalPackage, targets }, context) => {
1563
1639
  const configuredLanguages = /* @__PURE__ */ new Set();
@@ -1673,11 +1749,10 @@ function mapFernConfigToSdkConfigV1(input) {
1673
1749
  source: input.source,
1674
1750
  ...optional("sdkVersion", input.sdkVersion),
1675
1751
  ...optional("apiVersion", input.apiVersion),
1676
- api,
1677
- client: clients.shared,
1678
- package: {},
1679
- docs: docs.shared,
1680
- generation: generations.shared,
1752
+ ...optionalObject("api", api),
1753
+ ...optionalObject("client", clients.shared),
1754
+ ...optionalObject("docs", docs.shared),
1755
+ ...optionalObject("generation", generations.shared),
1681
1756
  targets
1682
1757
  };
1683
1758
  const parsed = sdkConfigV1Schema.safeParse(sdkConfig);
@@ -2531,13 +2606,18 @@ var credentialResolutionSchema = z.enum([
2531
2606
  "resolved-by-orchestrator",
2532
2607
  "resolved-by-fiddle"
2533
2608
  ]);
2609
+ var registryCredentialsSchema2 = z.strictObject({
2610
+ username: nonEmptyStringSchema.optional(),
2611
+ password: nonEmptyStringSchema.optional(),
2612
+ token: nonEmptyStringSchema.optional(),
2613
+ apiKey: nonEmptyStringSchema.optional()
2614
+ });
2534
2615
  var commonPublishShape2 = {
2535
2616
  url: nonEmptyStringSchema.optional(),
2536
- /**
2537
- * Reference to registry publishing credentials. Raw tokens/passwords are intentionally not part of
2538
- * SDK Config IR; the external publisher or orchestrator resolves this reference before use.
2539
- */
2617
+ /** Reference to registry publishing credentials. */
2540
2618
  credentialsRef: nonEmptyStringSchema.optional(),
2619
+ /** Raw registry credentials. These values can be sensitive and must be handled as secrets. */
2620
+ credentials: registryCredentialsSchema2.optional(),
2541
2621
  /**
2542
2622
  * Registry-specific package version override. If omitted, the external publisher/orchestrator may
2543
2623
  * fall back to target.sdkVersion.
@@ -2561,6 +2641,11 @@ var mavenSignatureEnvironmentSchema = z.strictObject({
2561
2641
  passwordEnvironmentVariable: nonEmptyStringSchema.optional(),
2562
2642
  secretKeyEnvironmentVariable: nonEmptyStringSchema.optional()
2563
2643
  });
2644
+ var mavenSignatureSchema2 = z.strictObject({
2645
+ keyId: nonEmptyStringSchema,
2646
+ password: nonEmptyStringSchema,
2647
+ secretKey: nonEmptyStringSchema
2648
+ });
2564
2649
  var publishConfigSchema = z.discriminatedUnion("registry", [
2565
2650
  z.strictObject({
2566
2651
  registry: z.literal("npm"),
@@ -2606,11 +2691,10 @@ var publishConfigSchema = z.discriminatedUnion("registry", [
2606
2691
  passwordEnvironmentVariable: nonEmptyStringSchema.optional(),
2607
2692
  mavenUrlEnvironmentVariable: nonEmptyStringSchema.optional(),
2608
2693
  signatureEnvironmentVariables: mavenSignatureEnvironmentSchema.optional(),
2609
- /**
2610
- * Reference to Maven signing credentials. Raw signing keys are intentionally not part of SDK
2611
- * Config IR; the external publisher or orchestrator resolves this reference before use.
2612
- */
2694
+ /** Reference to Maven signing credentials. */
2613
2695
  signingCredentialsRef: nonEmptyStringSchema.optional(),
2696
+ /** Raw Maven signing material. These values can be sensitive and must be handled as secrets. */
2697
+ signature: mavenSignatureSchema2.optional(),
2614
2698
  ...commonPublishShape2
2615
2699
  })
2616
2700
  ]);
@@ -2621,18 +2705,27 @@ var reviewersSchema2 = z.strictObject({
2621
2705
  var replayControlSchema = z.strictObject({
2622
2706
  enabled: z.boolean()
2623
2707
  });
2708
+ var githubLicenseSchema = z.strictObject({
2709
+ /** SPDX identifier or license key for the repository license (for example, "MIT"). */
2710
+ type: nonEmptyStringSchema.optional(),
2711
+ /** Path to a custom license file to be committed into the GitHub repository. */
2712
+ customPath: nonEmptyStringSchema.optional()
2713
+ }).refine((value) => value.type !== void 0 || value.customPath !== void 0, {
2714
+ message: "GitHub license must set type or customPath"
2715
+ });
2624
2716
  var githubOutputSchema2 = z.strictObject({
2625
2717
  repository: nonEmptyStringSchema,
2626
2718
  host: nonEmptyStringSchema.optional(),
2627
2719
  branch: nonEmptyStringSchema.optional(),
2628
- mode: z.enum(["release", "pull-request", "push"]).optional(),
2720
+ mode: z.enum(["release", "pull-request", "push", "commit", "commit-and-release"]).optional(),
2629
2721
  reviewers: reviewersSchema2.optional(),
2630
- /**
2631
- * Reference to GitHub credentials. Raw tokens are intentionally not part of SDK Config IR; the
2632
- * external publisher or orchestrator resolves this reference before use.
2633
- */
2722
+ /** Reference to GitHub credentials. */
2634
2723
  credentialsRef: nonEmptyStringSchema.optional(),
2724
+ /** Raw GitHub credentials. These values can be sensitive and must be handled as secrets. */
2725
+ credentials: registryCredentialsSchema2.optional(),
2635
2726
  privateRepository: z.boolean().optional(),
2727
+ /** GitHub license block scoped to repository delivery. */
2728
+ license: githubLicenseSchema.optional(),
2636
2729
  /** GitHub replay control. If omitted, the external publisher applies its default behavior. */
2637
2730
  replay: replayControlSchema.optional(),
2638
2731
  /** Run GitHub publishing verification. Defaults to false to match current Fiddle job behavior. */
@@ -2643,10 +2736,7 @@ var githubOutputSchema2 = z.strictObject({
2643
2736
  autoMerge: z.boolean().default(false)
2644
2737
  });
2645
2738
  var credentialResolutionShape = {
2646
- /**
2647
- * Where output credential references are resolved. SDK Config IR carries refs only; raw resolved
2648
- * credentials belong at the external publisher/orchestrator boundary, not in this config.
2649
- */
2739
+ /** Where output credential references are resolved. */
2650
2740
  credentialResolution: credentialResolutionSchema.default("refs-only")
2651
2741
  };
2652
2742
  var filesOutputSchema2 = z.strictObject({