@postman/sdk-config 0.19.1 → 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 (34) hide show
  1. package/dist/index.cjs +208 -50
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +208 -51
  6. package/dist/index.js.map +1 -1
  7. package/dist/sdk-config/index.cjs +154 -5
  8. package/dist/sdk-config/index.cjs.map +1 -1
  9. package/dist/sdk-config/index.d.cts +1 -1
  10. package/dist/sdk-config/index.d.ts +1 -1
  11. package/dist/sdk-config/index.js +154 -5
  12. package/dist/sdk-config/index.js.map +1 -1
  13. package/dist/sdk-config/v1/index.cjs +154 -5
  14. package/dist/sdk-config/v1/index.cjs.map +1 -1
  15. package/dist/sdk-config/v1/index.d.cts +164 -30
  16. package/dist/sdk-config/v1/index.d.ts +164 -30
  17. package/dist/sdk-config/v1/index.js +154 -5
  18. package/dist/sdk-config/v1/index.js.map +1 -1
  19. package/dist/sdk-config-ir/index.cjs +199 -49
  20. package/dist/sdk-config-ir/index.cjs.map +1 -1
  21. package/dist/sdk-config-ir/index.d.cts +1 -1
  22. package/dist/sdk-config-ir/index.d.ts +1 -1
  23. package/dist/sdk-config-ir/index.js +199 -50
  24. package/dist/sdk-config-ir/index.js.map +1 -1
  25. package/dist/sdk-config-ir/v1/index.cjs +199 -49
  26. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  27. package/dist/sdk-config-ir/v1/index.d.cts +163 -4
  28. package/dist/sdk-config-ir/v1/index.d.ts +163 -4
  29. package/dist/sdk-config-ir/v1/index.js +199 -50
  30. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  31. package/dist/{typescript-D0YeGxxS.d.cts → typescript-VEqEGvnA.d.cts} +60 -1
  32. package/dist/{typescript-D0YeGxxS.d.ts → typescript-VEqEGvnA.d.ts} +60 -1
  33. package/package.json +2 -2
  34. 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
@@ -3037,7 +3178,7 @@ var sdkConfigV1Schema = z.strictObject({
3037
3178
  docs: sdkConfigV1DocsConfigSchema.prefault({}).describe("Documentation settings inherited by every target."),
3038
3179
  generation: sdkConfigV1GenerationConfigSchema.prefault({}).describe("Generation settings inherited by every target."),
3039
3180
  targets: z.array(sdkConfigV1TargetSchema).min(1).describe("Language targets to generate; each language may appear once.")
3040
- }).superRefine(({ output, package: globalPackage, targets }, context) => {
3181
+ }).superRefine(({ api, output, package: globalPackage, targets }, context) => {
3041
3182
  const configuredLanguages = /* @__PURE__ */ new Set();
3042
3183
  targets.forEach((target, targetIndex) => {
3043
3184
  if (configuredLanguages.has(target.language)) {
@@ -3049,6 +3190,14 @@ var sdkConfigV1Schema = z.strictObject({
3049
3190
  }
3050
3191
  configuredLanguages.add(target.language);
3051
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
+ }
3052
3201
  });
3053
3202
  });
3054
3203
  function validateSdkConfigV1(value) {