@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/README.md CHANGED
@@ -3,9 +3,10 @@
3
3
  Build and validate SDK Config documents for SDK Generation API requests.
4
4
 
5
5
  SDK Config describes what to generate: API source provenance, SDK identity, API behavior, client
6
- behavior, package metadata, documentation, output, shared generation options, and one or more
7
- language targets. The materialized API source bytes, authentication, idempotency, and transport
8
- metadata belong to the SDK Generation API request rather than the SDK Config document.
6
+ behavior, package metadata, documentation, output, shared generation options, optional publishing
7
+ credentials/signing material, and one or more language targets. The materialized API source bytes,
8
+ idempotency, and transport metadata belong to the SDK Generation API request rather than the SDK
9
+ Config document.
9
10
 
10
11
  ## Install
11
12
 
@@ -36,9 +37,7 @@ const input: SdkConfigV1Input = {
36
37
  source: {
37
38
  specs: [{ id: 'example', type: 'openapi', path: './openapi.yml' }],
38
39
  },
39
- api: {},
40
40
  client: { timeoutMs: 30_000 },
41
- package: {},
42
41
  output: { delivery: 'zip', fileName: 'example-typescript.zip' },
43
42
  docs: { includeApiReference: true },
44
43
  generation: { includeWatermark: true },
@@ -59,6 +58,9 @@ const sdkConfig: SdkConfigV1 = parseSdkConfigV1(document);
59
58
  Use `parseSdkConfigV1` when entering the runtime boundary and materializing the shared domain
60
59
  defaults. For validation without throwing, use the exported schema:
61
60
 
61
+ Empty top-level `api`, `client`, `package`, `docs`, and `generation` blocks may be omitted from the
62
+ customer document. Runtime parsing materializes those blocks and their versioned defaults.
63
+
62
64
  ```ts
63
65
  import { sdkConfigV1Schema } from '@postman/sdk-config/sdk-config/v1';
64
66
 
@@ -69,7 +71,10 @@ if (!result.success) {
69
71
  ```
70
72
 
71
73
  SDK Config objects are strict. Unknown fields, duplicate language targets, incompatible package
72
- publication settings, and non-exact generator versions are rejected.
74
+ publication settings, and non-exact generator versions are rejected. Publishing credentials and
75
+ signing material may be provided under `output.publish.credentials`, Maven
76
+ `output.publish.signature`, or `output.github.credentials`; these fields can contain raw secrets and
77
+ must be handled accordingly by clients and servers.
73
78
 
74
79
  `SdkConfigV1` accepts customer-facing local source paths and HTTP(S) source URLs, but not
75
80
  server-owned signed URLs or artifact metadata. See the
package/dist/index.cjs CHANGED
@@ -283,8 +283,8 @@ var clientConfigSchema = zod.z.strictObject({
283
283
  var sdkConfigV1ClientConfigSchema = clientConfigSchema;
284
284
  var sdkConfigV1ClientConfigOverrideSchema = clientConfigOverrideSchema;
285
285
  var goModulePathSchema = relativePathSchema.regex(
286
- /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)+$/,
287
- "Go module path must be a slash-delimited path using letters, numbers, dots, dashes, underscores, or tildes"
286
+ /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*$/,
287
+ "Go module path must use letters, numbers, dots, dashes, underscores or tildes, in slash-delimited segments"
288
288
  );
289
289
  var composerPackageNameSchema = nonEmptyStringSchema.regex(
290
290
  /^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$/,
@@ -549,6 +549,9 @@ function compact(value) {
549
549
  function optional(key, value) {
550
550
  return value === void 0 ? {} : { [key]: value };
551
551
  }
552
+ function optionalObject(key, value) {
553
+ return Object.keys(value).length === 0 ? {} : { [key]: value };
554
+ }
552
555
  function isObject(value) {
553
556
  return value !== null && typeof value === "object" && !Array.isArray(value);
554
557
  }
@@ -708,6 +711,7 @@ function githubOutput(value, publishInfo, language, sourcePath, state, index) {
708
711
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
709
712
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
710
713
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
714
+ const credentials = mapCredentials(value.credentials, [...sourcePath, "credentials"], state);
711
715
  return {
712
716
  output: {
713
717
  delivery: "github",
@@ -716,13 +720,58 @@ function githubOutput(value, publishInfo, language, sourcePath, state, index) {
716
720
  ...optional("host", stringValue(value.host)),
717
721
  ...optional("branch", stringValue(value.branch)),
718
722
  mode: value.makePr === true || type === "pullRequest" ? "pull-request" : type === "push" ? "push" : "release",
719
- ...optional("reviewers", reviewers)
723
+ ...optional("reviewers", reviewers),
724
+ ...optional("credentials", credentials)
720
725
  },
721
726
  ...publication ? { publish: publication.publish } : {}
722
727
  },
723
728
  ...optional("package", publication?.package)
724
729
  };
725
730
  }
731
+ function mapCredentials(value, sourcePath, state) {
732
+ if (!isObject(value)) return void 0;
733
+ return credentialsFromObject(value, sourcePath, state);
734
+ }
735
+ function mapInlineCredentials(value, sourcePath, state) {
736
+ const credentials = mapCredentials(value.credentials, [...sourcePath, "credentials"], state);
737
+ if (credentials) return credentials;
738
+ return credentialsFromObject(value, sourcePath, state);
739
+ }
740
+ function credentialsFromObject(value, sourcePath, state) {
741
+ const credentials = {};
742
+ const username = stringValue(value.username);
743
+ const password = stringValue(value.password);
744
+ const token = stringValue(value.token);
745
+ const apiKey = stringValue(value.apiKey);
746
+ if (username) {
747
+ credentials.username = username;
748
+ consume(state, [...sourcePath, "username"]);
749
+ }
750
+ if (password) {
751
+ credentials.password = password;
752
+ consume(state, [...sourcePath, "password"]);
753
+ }
754
+ if (token) {
755
+ credentials.token = token;
756
+ consume(state, [...sourcePath, "token"]);
757
+ }
758
+ if (apiKey) {
759
+ credentials.apiKey = apiKey;
760
+ consume(state, [...sourcePath, "apiKey"]);
761
+ }
762
+ return Object.keys(credentials).length === 0 ? void 0 : credentials;
763
+ }
764
+ function mapMavenSignature(value, sourcePath, state) {
765
+ if (!isObject(value)) return void 0;
766
+ const keyId = stringValue(value.keyId);
767
+ const password = stringValue(value.password);
768
+ const secretKey = stringValue(value.secretKey);
769
+ if (!keyId || !password || !secretKey) return void 0;
770
+ consume(state, [...sourcePath, "keyId"]);
771
+ consume(state, [...sourcePath, "password"]);
772
+ consume(state, [...sourcePath, "secretKey"]);
773
+ return { keyId, password, secretKey };
774
+ }
726
775
  function mapReviewers(value, sourcePath, state) {
727
776
  if (Array.isArray(value)) {
728
777
  const teams2 = reviewerNames(value, "team", sourcePath, state);
@@ -766,11 +815,13 @@ function mapPublication(value, language, sourcePath, state, index) {
766
815
  const registry = publicationRegistry(type, language, [...sourcePath, "type"], index);
767
816
  const registryUrl = stringValue(nested.registryUrl);
768
817
  if (registryUrl) consume(state, [...nestedPath, "registryUrl"]);
818
+ const credentials = mapInlineCredentials(nested, nestedPath, state);
769
819
  if (registry === "maven") {
770
820
  const coordinate = stringValue(nested.coordinate);
821
+ const signature = mapMavenSignature(nested.signature, [...nestedPath, "signature"], state);
771
822
  if (coordinate) consume(state, [...nestedPath, "coordinate"]);
772
823
  return {
773
- publish: compact({ registry, url: registryUrl }),
824
+ publish: compact({ registry, url: registryUrl, credentials, signature }),
774
825
  ...coordinate ? { package: mavenPackage(coordinate, [...nestedPath, "coordinate"], index) } : {}
775
826
  };
776
827
  }
@@ -779,7 +830,7 @@ function mapPublication(value, language, sourcePath, state, index) {
779
830
  if (packageName) consume(state, [...nestedPath, packageNameField]);
780
831
  const metadata = registry === "pypi" ? mapPypiMetadata(nested.pypiMetadata, nestedPath, state) : {};
781
832
  return {
782
- publish: compact({ registry, url: registryUrl }),
833
+ publish: compact({ registry, url: registryUrl, credentials }),
783
834
  ...packageName || Object.keys(metadata).length ? { package: { ...optional("packageName", packageName), ...metadata } } : {}
784
835
  };
785
836
  }
@@ -896,7 +947,11 @@ function finishOutputMapping(mapping, outputMode, sourcePath, state, index) {
896
947
  code: "FERN_OUTPUT_CREDENTIAL_UNSUPPORTED",
897
948
  severity: "warning",
898
949
  path: sourcePath,
899
- reason: "Fern output credentials and signatures are intentionally excluded from SDK Config v1",
950
+ // This diagnostic only captures credential/signature fields that remained
951
+ // unconsumed after mapping supported registry/GitHub credentials into
952
+ // SDK Config v1. Supported credential shapes are carried through; this
953
+ // warning is about the remaining legacy-only credential fields.
954
+ reason: "Some Fern output credentials and signatures are intentionally excluded from SDK Config v1 when they cannot be represented in the public schema",
900
955
  suggestedAction: "Provide publishing credentials through the build request or external secret resolution."
901
956
  }
902
957
  ] : [],
@@ -1116,15 +1171,33 @@ var sdkConfigV1PublishRegistrySchema = zod.z.enum([
1116
1171
  "go",
1117
1172
  "composer"
1118
1173
  ]);
1174
+ var registryCredentialsSchema = zod.z.strictObject({
1175
+ username: nonEmptyStringSchema.optional(),
1176
+ password: nonEmptyStringSchema.optional(),
1177
+ token: nonEmptyStringSchema.optional(),
1178
+ apiKey: nonEmptyStringSchema.optional()
1179
+ });
1180
+ var mavenSignatureSchema = zod.z.strictObject({
1181
+ keyId: nonEmptyStringSchema,
1182
+ password: nonEmptyStringSchema,
1183
+ secretKey: nonEmptyStringSchema
1184
+ });
1119
1185
  var commonPublishShape = {
1120
1186
  url: nonEmptyStringSchema.optional(),
1187
+ /** Raw registry credentials. These values can be sensitive and must be handled as secrets. */
1188
+ credentials: registryCredentialsSchema.optional(),
1121
1189
  releaseBranch: nonEmptyStringSchema.optional(),
1122
1190
  tolerateRepublish: zod.z.boolean().optional()
1123
1191
  };
1124
1192
  var sdkConfigV1PublishConfigSchema = zod.z.discriminatedUnion("registry", [
1125
1193
  zod.z.strictObject({ registry: zod.z.literal("npm"), ...commonPublishShape }),
1126
1194
  zod.z.strictObject({ registry: zod.z.literal("pypi"), ...commonPublishShape }),
1127
- zod.z.strictObject({ registry: zod.z.literal("maven"), ...commonPublishShape }),
1195
+ zod.z.strictObject({
1196
+ registry: zod.z.literal("maven"),
1197
+ /** Raw Maven signing material. These values can be sensitive and must be handled as secrets. */
1198
+ signature: mavenSignatureSchema.optional(),
1199
+ ...commonPublishShape
1200
+ }),
1128
1201
  zod.z.strictObject({ registry: zod.z.literal("nuget"), ...commonPublishShape }),
1129
1202
  zod.z.strictObject({ registry: zod.z.literal("rubygems"), ...commonPublishShape }),
1130
1203
  zod.z.strictObject({ registry: zod.z.literal("crates"), ...commonPublishShape }),
@@ -1135,12 +1208,15 @@ var reviewersSchema = zod.z.strictObject({
1135
1208
  teams: zod.z.array(nonEmptyStringSchema).optional(),
1136
1209
  users: zod.z.array(nonEmptyStringSchema).optional()
1137
1210
  });
1211
+ var githubCredentialsSchema = registryCredentialsSchema;
1138
1212
  var githubOutputSchema = zod.z.strictObject({
1139
1213
  repository: nonEmptyStringSchema,
1140
1214
  host: nonEmptyStringSchema.optional(),
1141
1215
  branch: nonEmptyStringSchema.optional(),
1142
- mode: zod.z.enum(["release", "pull-request", "push"]).optional(),
1216
+ mode: zod.z.enum(["release", "pull-request", "push", "commit", "commit-and-release"]).optional(),
1143
1217
  reviewers: reviewersSchema.optional(),
1218
+ /** Raw GitHub credentials. These values can be sensitive and must be handled as secrets. */
1219
+ credentials: githubCredentialsSchema.optional(),
1144
1220
  privateRepository: zod.z.boolean().optional()
1145
1221
  });
1146
1222
  var filesOutputSchema = zod.z.strictObject({
@@ -1558,12 +1634,12 @@ var sdkConfigV1Schema = zod.z.strictObject({
1558
1634
  sdkVersion: nonEmptyStringSchema.default("1.0.0"),
1559
1635
  apiVersion: nonEmptyStringSchema.optional(),
1560
1636
  source: sdkConfigV1SourceConfigSchema,
1561
- api: sdkConfigV1ApiConfigSchema,
1562
- client: sdkConfigV1ClientConfigSchema,
1563
- package: sdkConfigV1PackageConfigSchema,
1637
+ api: sdkConfigV1ApiConfigSchema.prefault({}),
1638
+ client: sdkConfigV1ClientConfigSchema.prefault({}),
1639
+ package: sdkConfigV1PackageConfigSchema.prefault({}),
1564
1640
  output: sdkConfigV1OutputConfigSchema.optional(),
1565
- docs: sdkConfigV1DocsConfigSchema,
1566
- generation: sdkConfigV1GenerationConfigSchema,
1641
+ docs: sdkConfigV1DocsConfigSchema.prefault({}),
1642
+ generation: sdkConfigV1GenerationConfigSchema.prefault({}),
1567
1643
  targets: zod.z.array(sdkConfigV1TargetSchema).min(1)
1568
1644
  }).superRefine(({ output, package: globalPackage, targets }, context) => {
1569
1645
  const configuredLanguages = /* @__PURE__ */ new Set();
@@ -1679,11 +1755,10 @@ function mapFernConfigToSdkConfigV1(input) {
1679
1755
  source: input.source,
1680
1756
  ...optional("sdkVersion", input.sdkVersion),
1681
1757
  ...optional("apiVersion", input.apiVersion),
1682
- api,
1683
- client: clients.shared,
1684
- package: {},
1685
- docs: docs.shared,
1686
- generation: generations.shared,
1758
+ ...optionalObject("api", api),
1759
+ ...optionalObject("client", clients.shared),
1760
+ ...optionalObject("docs", docs.shared),
1761
+ ...optionalObject("generation", generations.shared),
1687
1762
  targets
1688
1763
  };
1689
1764
  const parsed = sdkConfigV1Schema.safeParse(sdkConfig);
@@ -2537,13 +2612,18 @@ var credentialResolutionSchema = zod.z.enum([
2537
2612
  "resolved-by-orchestrator",
2538
2613
  "resolved-by-fiddle"
2539
2614
  ]);
2615
+ var registryCredentialsSchema2 = zod.z.strictObject({
2616
+ username: nonEmptyStringSchema.optional(),
2617
+ password: nonEmptyStringSchema.optional(),
2618
+ token: nonEmptyStringSchema.optional(),
2619
+ apiKey: nonEmptyStringSchema.optional()
2620
+ });
2540
2621
  var commonPublishShape2 = {
2541
2622
  url: nonEmptyStringSchema.optional(),
2542
- /**
2543
- * Reference to registry publishing credentials. Raw tokens/passwords are intentionally not part of
2544
- * SDK Config IR; the external publisher or orchestrator resolves this reference before use.
2545
- */
2623
+ /** Reference to registry publishing credentials. */
2546
2624
  credentialsRef: nonEmptyStringSchema.optional(),
2625
+ /** Raw registry credentials. These values can be sensitive and must be handled as secrets. */
2626
+ credentials: registryCredentialsSchema2.optional(),
2547
2627
  /**
2548
2628
  * Registry-specific package version override. If omitted, the external publisher/orchestrator may
2549
2629
  * fall back to target.sdkVersion.
@@ -2567,6 +2647,11 @@ var mavenSignatureEnvironmentSchema = zod.z.strictObject({
2567
2647
  passwordEnvironmentVariable: nonEmptyStringSchema.optional(),
2568
2648
  secretKeyEnvironmentVariable: nonEmptyStringSchema.optional()
2569
2649
  });
2650
+ var mavenSignatureSchema2 = zod.z.strictObject({
2651
+ keyId: nonEmptyStringSchema,
2652
+ password: nonEmptyStringSchema,
2653
+ secretKey: nonEmptyStringSchema
2654
+ });
2570
2655
  var publishConfigSchema = zod.z.discriminatedUnion("registry", [
2571
2656
  zod.z.strictObject({
2572
2657
  registry: zod.z.literal("npm"),
@@ -2612,11 +2697,10 @@ var publishConfigSchema = zod.z.discriminatedUnion("registry", [
2612
2697
  passwordEnvironmentVariable: nonEmptyStringSchema.optional(),
2613
2698
  mavenUrlEnvironmentVariable: nonEmptyStringSchema.optional(),
2614
2699
  signatureEnvironmentVariables: mavenSignatureEnvironmentSchema.optional(),
2615
- /**
2616
- * Reference to Maven signing credentials. Raw signing keys are intentionally not part of SDK
2617
- * Config IR; the external publisher or orchestrator resolves this reference before use.
2618
- */
2700
+ /** Reference to Maven signing credentials. */
2619
2701
  signingCredentialsRef: nonEmptyStringSchema.optional(),
2702
+ /** Raw Maven signing material. These values can be sensitive and must be handled as secrets. */
2703
+ signature: mavenSignatureSchema2.optional(),
2620
2704
  ...commonPublishShape2
2621
2705
  })
2622
2706
  ]);
@@ -2627,18 +2711,27 @@ var reviewersSchema2 = zod.z.strictObject({
2627
2711
  var replayControlSchema = zod.z.strictObject({
2628
2712
  enabled: zod.z.boolean()
2629
2713
  });
2714
+ var githubLicenseSchema = zod.z.strictObject({
2715
+ /** SPDX identifier or license key for the repository license (for example, "MIT"). */
2716
+ type: nonEmptyStringSchema.optional(),
2717
+ /** Path to a custom license file to be committed into the GitHub repository. */
2718
+ customPath: nonEmptyStringSchema.optional()
2719
+ }).refine((value) => value.type !== void 0 || value.customPath !== void 0, {
2720
+ message: "GitHub license must set type or customPath"
2721
+ });
2630
2722
  var githubOutputSchema2 = zod.z.strictObject({
2631
2723
  repository: nonEmptyStringSchema,
2632
2724
  host: nonEmptyStringSchema.optional(),
2633
2725
  branch: nonEmptyStringSchema.optional(),
2634
- mode: zod.z.enum(["release", "pull-request", "push"]).optional(),
2726
+ mode: zod.z.enum(["release", "pull-request", "push", "commit", "commit-and-release"]).optional(),
2635
2727
  reviewers: reviewersSchema2.optional(),
2636
- /**
2637
- * Reference to GitHub credentials. Raw tokens are intentionally not part of SDK Config IR; the
2638
- * external publisher or orchestrator resolves this reference before use.
2639
- */
2728
+ /** Reference to GitHub credentials. */
2640
2729
  credentialsRef: nonEmptyStringSchema.optional(),
2730
+ /** Raw GitHub credentials. These values can be sensitive and must be handled as secrets. */
2731
+ credentials: registryCredentialsSchema2.optional(),
2641
2732
  privateRepository: zod.z.boolean().optional(),
2733
+ /** GitHub license block scoped to repository delivery. */
2734
+ license: githubLicenseSchema.optional(),
2642
2735
  /** GitHub replay control. If omitted, the external publisher applies its default behavior. */
2643
2736
  replay: replayControlSchema.optional(),
2644
2737
  /** Run GitHub publishing verification. Defaults to false to match current Fiddle job behavior. */
@@ -2649,10 +2742,7 @@ var githubOutputSchema2 = zod.z.strictObject({
2649
2742
  autoMerge: zod.z.boolean().default(false)
2650
2743
  });
2651
2744
  var credentialResolutionShape = {
2652
- /**
2653
- * Where output credential references are resolved. SDK Config IR carries refs only; raw resolved
2654
- * credentials belong at the external publisher/orchestrator boundary, not in this config.
2655
- */
2745
+ /** Where output credential references are resolved. */
2656
2746
  credentialResolution: credentialResolutionSchema.default("refs-only")
2657
2747
  };
2658
2748
  var filesOutputSchema2 = zod.z.strictObject({