@postman/sdk-config 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +237 -58
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +237 -59
  7. package/dist/index.js.map +1 -1
  8. package/dist/sdk-config/index.cjs +173 -11
  9. package/dist/sdk-config/index.cjs.map +1 -1
  10. package/dist/sdk-config/index.d.cts +1 -1
  11. package/dist/sdk-config/index.d.ts +1 -1
  12. package/dist/sdk-config/index.js +173 -11
  13. package/dist/sdk-config/index.js.map +1 -1
  14. package/dist/sdk-config/v1/index.cjs +173 -11
  15. package/dist/sdk-config/v1/index.cjs.map +1 -1
  16. package/dist/sdk-config/v1/index.d.cts +6032 -294
  17. package/dist/sdk-config/v1/index.d.ts +6032 -294
  18. package/dist/sdk-config/v1/index.js +173 -11
  19. package/dist/sdk-config/v1/index.js.map +1 -1
  20. package/dist/sdk-config-ir/index.cjs +209 -51
  21. package/dist/sdk-config-ir/index.cjs.map +1 -1
  22. package/dist/sdk-config-ir/index.d.cts +1 -1
  23. package/dist/sdk-config-ir/index.d.ts +1 -1
  24. package/dist/sdk-config-ir/index.js +209 -52
  25. package/dist/sdk-config-ir/index.js.map +1 -1
  26. package/dist/sdk-config-ir/v1/index.cjs +209 -51
  27. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  28. package/dist/sdk-config-ir/v1/index.d.cts +1203 -6
  29. package/dist/sdk-config-ir/v1/index.d.ts +1203 -6
  30. package/dist/sdk-config-ir/v1/index.js +209 -52
  31. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  32. package/dist/{typescript-D0YeGxxS.d.cts → typescript-VEqEGvnA.d.cts} +60 -1
  33. package/dist/{typescript-D0YeGxxS.d.ts → typescript-VEqEGvnA.d.ts} +60 -1
  34. package/package.json +2 -2
  35. package/src/sdk-config/v1/README.md +59 -4
@@ -134,6 +134,39 @@ var publicClientIdSchema = nonEmptyStringSchema.refine((value) => value.trim() =
134
134
  }).refine((value) => !value.includes("${"), {
135
135
  message: "must be a literal public client ID, not an environment expression"
136
136
  });
137
+ var oauthExtraParametersSchema = z.record(z.string().min(1), z.string());
138
+ function parseUrl(value) {
139
+ try {
140
+ return new URL(value);
141
+ } catch {
142
+ return void 0;
143
+ }
144
+ }
145
+ var loopbackRedirectUriSchema = nonEmptyStringSchema.refine(
146
+ (value) => {
147
+ const url = parseUrl(value);
148
+ return url !== void 0 && url.protocol === "http:" && (url.hostname === "127.0.0.1" || url.hostname === "localhost") && url.port !== "";
149
+ },
150
+ {
151
+ message: "must be an http URL on 127.0.0.1 or localhost that pins a port, such as http://127.0.0.1:8484/callback"
152
+ }
153
+ );
154
+ function containsControlCharacter(value) {
155
+ return [...value].some((character) => {
156
+ const code = character.charCodeAt(0);
157
+ return code <= 31 || code === 127;
158
+ });
159
+ }
160
+ var hostedPageUrlSchema = nonEmptyStringSchema.refine(
161
+ (value) => {
162
+ const url = parseUrl(value);
163
+ return url !== void 0 && (url.protocol === "http:" || url.protocol === "https:");
164
+ },
165
+ { message: "must be an absolute http or https URL" }
166
+ ).refine((value) => !containsControlCharacter(value), {
167
+ message: "must not contain control characters"
168
+ });
169
+ var redirectPortSchema = z.number().int().min(1).max(65535);
137
170
  var oauthFlowSchema = z.discriminatedUnion("type", [
138
171
  z.strictObject({
139
172
  type: z.literal("authorization-code").describe("Uses the OAuth authorization code flow."),
@@ -143,7 +176,25 @@ var oauthFlowSchema = z.discriminatedUnion("type", [
143
176
  scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow."),
144
177
  clientId: publicClientIdSchema.optional().describe(
145
178
  "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."
146
- )
179
+ ),
180
+ redirectUri: loopbackRedirectUriSchema.optional().describe(
181
+ "The loopback callback of the interactive login, such as http://127.0.0.1:8484/callback. The login binds this exact host, port and path and sends it to the authorization server, so it must match the redirect registered there. Without it the login uses a free port chosen by the operating system."
182
+ ),
183
+ redirectUriBackupPorts: z.array(redirectPortSchema).min(1).optional().describe(
184
+ "Ports tried in order when the port of redirectUri is busy. Each reuses the host and path of redirectUri, and every resulting URI must be registered with the authorization server. Requires redirectUri."
185
+ ),
186
+ successRedirectUrl: hostedPageUrlSchema.optional().describe(
187
+ "A page the browser is sent to once the login captured the authorization code. Without it the login shows its own page."
188
+ ),
189
+ errorRedirectUrl: hostedPageUrlSchema.optional().describe(
190
+ "A page the browser is sent to when the login fails; the error and error_description query parameters are added. Without it the login shows its own page."
191
+ ),
192
+ authorizationParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the authorization request, such as audience."),
193
+ tokenParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the authorization code exchange request."),
194
+ refreshParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the token refresh request.")
195
+ }).refine((flow) => flow.redirectUriBackupPorts === void 0 || flow.redirectUri !== void 0, {
196
+ message: "redirectUriBackupPorts requires redirectUri",
197
+ path: ["redirectUriBackupPorts"]
147
198
  }),
148
199
  z.strictObject({
149
200
  type: z.literal("client-credentials").describe("Uses the OAuth client credentials flow."),
@@ -162,21 +213,47 @@ var oauthFlowSchema = z.discriminatedUnion("type", [
162
213
  tokenUrl: nonEmptyStringSchema.describe("The URL used to obtain access tokens."),
163
214
  refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
164
215
  scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow.")
216
+ }),
217
+ z.strictObject({
218
+ type: z.literal("device-code").describe(
219
+ "Uses the OAuth device authorization flow (RFC 8628) for logins without a browser."
220
+ ),
221
+ clientId: publicClientIdSchema.describe(
222
+ "The public, non-secret OAuth client ID sent to the device authorization and token endpoints. It is embedded verbatim in generated code, so it must never be a client secret."
223
+ ),
224
+ deviceAuthorizationUrl: nonEmptyStringSchema.describe(
225
+ "The URL that issues the device code, the user code and the verification URL."
226
+ ),
227
+ tokenUrl: nonEmptyStringSchema.describe(
228
+ "The URL polled to exchange the device code for tokens once the user approved."
229
+ ),
230
+ refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
231
+ scopes: z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow."),
232
+ deviceAuthorizationParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the device authorization request, such as audience."),
233
+ tokenParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the token polling request."),
234
+ refreshParameters: oauthExtraParametersSchema.optional().describe("Extra parameters added to the token refresh request.")
165
235
  })
166
236
  ]);
167
- var oauth2AuthSchema = z.strictObject({
237
+ var oauth2AuthObjectSchema = z.strictObject({
168
238
  id: nonEmptyStringSchema.describe("A unique identifier for this authentication scheme."),
169
239
  type: z.literal("oauth2").describe("Identifies an OAuth 2.0 authentication scheme."),
170
240
  flows: z.array(oauthFlowSchema).min(1).describe("The OAuth flows supported by the API."),
171
241
  clientId: authVariableSchema.optional().describe("The OAuth client ID parameter exposed by the SDK."),
172
242
  clientSecret: authVariableSchema.optional().describe("The OAuth client secret parameter exposed by the SDK."),
173
243
  tokenHeader: nonEmptyStringSchema.optional().describe("The request header that carries the OAuth access token."),
174
- tokenPrefix: nonEmptyStringSchema.optional().describe("The prefix added before the OAuth access token."),
244
+ tokenPrefix: nonEmptyStringSchema.optional().describe('The prefix added before the OAuth access token. Defaults to "Bearer" when omitted.'),
245
+ omitTokenPrefix: z.boolean().optional().describe(
246
+ 'Whether the OAuth access token is sent as-is, with no prefix. Without it, a missing tokenPrefix means "Bearer". Cannot be combined with tokenPrefix.'
247
+ ),
175
248
  refreshBufferSeconds: z.number().nonnegative().optional().describe("How early, in seconds, the client refreshes a token before it expires."),
176
249
  description: z.string().optional().describe(
177
250
  "A description of the authentication scheme included in generated SDK documentation."
178
251
  )
179
252
  });
253
+ var oauth2AuthSchema = oauth2AuthObjectSchema.refine(
254
+ (scheme) => !(scheme.omitTokenPrefix === true && scheme.tokenPrefix !== void 0),
255
+ { message: "omitTokenPrefix cannot be combined with tokenPrefix", path: ["omitTokenPrefix"] }
256
+ );
180
257
  var customAuthParameterSchema = z.strictObject({
181
258
  location: z.enum(["header", "query", "cookie"]).describe("Where the custom authentication value is sent."),
182
259
  name: nonEmptyStringSchema.describe("The header, query parameter, or cookie name."),
@@ -832,6 +909,9 @@ var RESERVED_PROFILES_COMMAND_NAMES = /* @__PURE__ */ new Set([
832
909
  var binaryNameSchema = nonEmptyStringSchema.regex(ALPHANUMERIC_PATTERN, {
833
910
  message: "binaryName must contain at least one ASCII letter or digit"
834
911
  });
912
+ var crateNameSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, {
913
+ message: "crateName must start with a letter, contain only letters, digits, hyphens, and underscores, and be at most 64 characters"
914
+ });
835
915
  var rootGroupSchema = z.string().regex(ROOT_GROUP_PATTERN, {
836
916
  message: "rootGroup must start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores"
837
917
  });
@@ -896,17 +976,78 @@ var profilesConfigSchema = z.strictObject({
896
976
  revokeOperation: dottedCommandPathSchema("profiles.revokeOperation").optional().describe('The dotted command path called by "profiles remove --revoke".'),
897
977
  provisionOperation: profilesProvisionOperationSchema.optional().describe('The operation called by "profiles create --provision" and its response mapping.')
898
978
  });
979
+ var oauthPropertyPathSchema = z.string().regex(FIELD_NAME_PATTERN, {
980
+ message: 'must be a property name, or a dotted path to a nested property, such as "data.token"'
981
+ }).regex(/^[^.]+(\.[^.]+)*$/, { message: "must not have an empty path segment" });
982
+ var oauthTokenRequestPropertiesSchema = z.strictObject({
983
+ clientId: oauthPropertyPathSchema.optional().describe('The request property that carries the client ID. Defaults to "client_id".'),
984
+ clientSecret: oauthPropertyPathSchema.optional().describe('The request property that carries the client secret. Defaults to "client_secret".'),
985
+ scopes: oauthPropertyPathSchema.optional().describe('The request property that carries the scopes. Defaults to "scope".')
986
+ });
987
+ var oauthTokenResponsePropertiesSchema = z.strictObject({
988
+ accessToken: oauthPropertyPathSchema.optional().describe('The response property that holds the access token. Defaults to "access_token".'),
989
+ expiresIn: oauthPropertyPathSchema.optional().describe(
990
+ 'The response property that holds the lifetime in seconds. Defaults to "expires_in".'
991
+ ),
992
+ refreshToken: oauthPropertyPathSchema.optional().describe('The response property that holds the refresh token. Defaults to "refresh_token".')
993
+ });
994
+ var oauthTokenEndpointsSchema = z.strictObject({
995
+ token: z.strictObject({
996
+ requestProperties: oauthTokenRequestPropertiesSchema.optional().describe("The names of the properties of the token request."),
997
+ responseProperties: oauthTokenResponsePropertiesSchema.optional().describe("The names of the properties of the token response.")
998
+ }).optional().describe("The token endpoint of the client credentials flow (its tokenUrl)."),
999
+ refresh: z.strictObject({
1000
+ requestProperties: z.strictObject({
1001
+ refreshToken: oauthPropertyPathSchema.optional().describe(
1002
+ 'The request property that carries the refresh token. Defaults to "refresh_token".'
1003
+ )
1004
+ }).optional().describe("The names of the properties of the refresh request."),
1005
+ responseProperties: oauthTokenResponsePropertiesSchema.optional().describe("The names of the properties of the refresh response.")
1006
+ }).optional().describe("The refresh endpoint of the client credentials flow (its refreshUrl).")
1007
+ });
1008
+ function oauthTokenEndpointsIssues(oauthTokenEndpoints, schemes, basePath) {
1009
+ const flowsById = /* @__PURE__ */ new Map();
1010
+ for (const scheme of schemes ?? []) {
1011
+ const flow = scheme.type === "oauth2" ? scheme.flows?.find((f) => f.type === "client-credentials") : void 0;
1012
+ if (flow !== void 0) {
1013
+ flowsById.set(scheme.id, flow);
1014
+ }
1015
+ }
1016
+ return Object.entries(oauthTokenEndpoints ?? {}).flatMap(([id, endpoints]) => {
1017
+ const flow = flowsById.get(id);
1018
+ if (flow === void 0) {
1019
+ return [
1020
+ {
1021
+ message: `oauthTokenEndpoints "${id}" must name an OAuth scheme with a client-credentials flow`,
1022
+ path: [...basePath, id]
1023
+ }
1024
+ ];
1025
+ }
1026
+ return endpoints.refresh !== void 0 && flow.refreshUrl === void 0 ? [
1027
+ {
1028
+ message: `oauthTokenEndpoints "${id}" has refresh settings, but its flow has no refreshUrl`,
1029
+ path: [...basePath, id, "refresh"]
1030
+ }
1031
+ ] : [];
1032
+ });
1033
+ }
899
1034
  var cliGenerationConfigSchema = z.strictObject({
900
1035
  paginationParameters: z.array(nonEmptyStringSchema).optional().describe("Request parameter names treated as pagination controls by the CLI."),
901
1036
  skills: z.boolean().optional().describe("Whether the generated CLI includes skills that teach AI agents to invoke commands."),
902
1037
  binaryName: binaryNameSchema.optional().describe(
903
1038
  "The CLI executable name. The generator kebab-cases it and also uses it for the source directory and env-var prefix."
904
1039
  ),
1040
+ crateName: crateNameSchema.optional().describe(
1041
+ "The name of the generated Cargo package, which release archives and installers are named after. The generator defaults it to the binary name when the output is delivered to GitHub."
1042
+ ),
905
1043
  customCommands: z.boolean().optional().describe("Whether hand-written command support is generated. The generator defaults to true."),
906
1044
  rootGroup: rootGroupSchema.optional().describe("A command group that every spec-derived command is nested under."),
907
1045
  profiles: profilesConfigSchema.optional().describe("Named profile command configuration."),
908
1046
  splitTypeCrates: z.boolean().optional().describe("Whether generated types are split into one crate per API behind a facade crate."),
909
- userAgentSuffixFlag: userAgentSuffixFlagSchema.optional().describe('The long flag name, without "--", that appends a product token to the User-Agent.')
1047
+ userAgentSuffixFlag: userAgentSuffixFlagSchema.optional().describe('The long flag name, without "--", that appends a product token to the User-Agent.'),
1048
+ oauthTokenEndpoints: z.record(nonEmptyStringSchema, oauthTokenEndpointsSchema).optional().describe(
1049
+ "Per OAuth scheme id (api.auth.schemes[].id), the names of the properties of the token and refresh requests and responses, for the client credentials flow of an API whose token endpoint does not use the RFC 6749 names."
1050
+ )
910
1051
  });
911
1052
 
912
1053
  // src/sdk-config/v1/fern-config-mapper-cli.ts
@@ -2444,6 +2585,12 @@ var zipOutputSchema = z.strictObject({
2444
2585
  fileName: nonEmptyStringSchema.optional().describe("The generated ZIP archive file name."),
2445
2586
  publish: sdkConfigV1PublishConfigSchema.optional().describe("Optional package registry publication.")
2446
2587
  });
2588
+ var localAliasOutputSchema = zipOutputSchema.extend({
2589
+ delivery: z.literal("local").describe('Alias of "zip": the package on the local machine.')
2590
+ }).transform(normalizeLocalDelivery);
2591
+ function normalizeLocalDelivery(output) {
2592
+ return { ...output, delivery: "zip" };
2593
+ }
2447
2594
  var githubDeliverySchema = z.strictObject({
2448
2595
  delivery: z.literal("github").describe("Delivers the generated SDK to GitHub."),
2449
2596
  github: githubOutputSchema.describe("GitHub repository delivery settings."),
@@ -2451,8 +2598,8 @@ var githubDeliverySchema = z.strictObject({
2451
2598
  });
2452
2599
  var sdkConfigV1OutputConfigSchema = z.discriminatedUnion(
2453
2600
  "delivery",
2454
- [filesOutputSchema, zipOutputSchema, githubDeliverySchema],
2455
- { error: 'output.delivery must be one of "files", "zip", or "github"' }
2601
+ [filesOutputSchema, zipOutputSchema, githubDeliverySchema, localAliasOutputSchema],
2602
+ { error: 'output.delivery must be one of "files", "zip", "local", or "github"' }
2456
2603
  );
2457
2604
  var hostedOutputSchema = z.strictObject({
2458
2605
  delivery: z.literal("hosted").describe("Deploys the generated MCP server to Fern-hosted infrastructure."),
@@ -2462,8 +2609,14 @@ var hostedOutputSchema = z.strictObject({
2462
2609
  });
2463
2610
  var sdkConfigV1McpOutputConfigSchema = z.discriminatedUnion(
2464
2611
  "delivery",
2465
- [filesOutputSchema, zipOutputSchema, githubDeliverySchema, hostedOutputSchema],
2466
- { error: 'output.delivery must be one of "files", "zip", "github", or "hosted"' }
2612
+ [
2613
+ filesOutputSchema,
2614
+ zipOutputSchema,
2615
+ githubDeliverySchema,
2616
+ hostedOutputSchema,
2617
+ localAliasOutputSchema
2618
+ ],
2619
+ { error: 'output.delivery must be one of "files", "zip", "local", "github", or "hosted"' }
2467
2620
  );
2468
2621
  var cliDistributionShape = {
2469
2622
  distribution: cliDistributionConfigSchema.optional().describe(
@@ -2484,9 +2637,10 @@ var sdkConfigV1CliOutputConfigSchema = z.discriminatedUnion(
2484
2637
  [
2485
2638
  filesOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2486
2639
  zipOutputSchema.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub),
2487
- githubDeliverySchema.extend(cliDistributionShape)
2640
+ githubDeliverySchema.extend(cliDistributionShape),
2641
+ localAliasOutputSchema.in.extend(cliDistributionShape).superRefine(rejectDistributionWithoutGithub).transform(normalizeLocalDelivery)
2488
2642
  ],
2489
- { error: 'output.delivery must be one of "files", "zip", or "github"' }
2643
+ { error: 'output.delivery must be one of "files", "zip", "local", or "github"' }
2490
2644
  );
2491
2645
  var sdkConfigV1ReplayConfigSchema = z.strictObject({
2492
2646
  enabled: z.boolean().describe("Whether regeneration reapplies customer-authored repository changes.")
@@ -3024,7 +3178,7 @@ var sdkConfigV1Schema = z.strictObject({
3024
3178
  docs: sdkConfigV1DocsConfigSchema.prefault({}).describe("Documentation settings inherited by every target."),
3025
3179
  generation: sdkConfigV1GenerationConfigSchema.prefault({}).describe("Generation settings inherited by every target."),
3026
3180
  targets: z.array(sdkConfigV1TargetSchema).min(1).describe("Language targets to generate; each language may appear once.")
3027
- }).superRefine(({ output, package: globalPackage, targets }, context) => {
3181
+ }).superRefine(({ api, output, package: globalPackage, targets }, context) => {
3028
3182
  const configuredLanguages = /* @__PURE__ */ new Set();
3029
3183
  targets.forEach((target, targetIndex) => {
3030
3184
  if (configuredLanguages.has(target.language)) {
@@ -3036,6 +3190,14 @@ var sdkConfigV1Schema = z.strictObject({
3036
3190
  }
3037
3191
  configuredLanguages.add(target.language);
3038
3192
  validateTargetPublishing(target, targetIndex, globalPackage, output, context);
3193
+ if (target.language === "cli") {
3194
+ oauthTokenEndpointsIssues(target.generation?.oauthTokenEndpoints, api.auth?.schemes, [
3195
+ "targets",
3196
+ targetIndex,
3197
+ "generation",
3198
+ "oauthTokenEndpoints"
3199
+ ]).forEach((issue) => context.addIssue({ code: "custom", ...issue }));
3200
+ }
3039
3201
  });
3040
3202
  });
3041
3203
  function validateSdkConfigV1(value) {