@postman/sdk-config 0.23.0 → 0.25.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 +85 -2
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +85 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/sdk-config/index.cjs +67 -1
  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 +67 -1
  12. package/dist/sdk-config/index.js.map +1 -1
  13. package/dist/sdk-config/v1/index.cjs +67 -1
  14. package/dist/sdk-config/v1/index.cjs.map +1 -1
  15. package/dist/sdk-config/v1/index.d.cts +16 -2
  16. package/dist/sdk-config/v1/index.d.ts +16 -2
  17. package/dist/sdk-config/v1/index.js +67 -1
  18. package/dist/sdk-config/v1/index.js.map +1 -1
  19. package/dist/sdk-config-ir/index.cjs +63 -1
  20. package/dist/sdk-config-ir/index.cjs.map +1 -1
  21. package/dist/sdk-config-ir/index.d.cts +2 -2
  22. package/dist/sdk-config-ir/index.d.ts +2 -2
  23. package/dist/sdk-config-ir/index.js +63 -2
  24. package/dist/sdk-config-ir/index.js.map +1 -1
  25. package/dist/sdk-config-ir/v1/index.cjs +63 -1
  26. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  27. package/dist/sdk-config-ir/v1/index.d.cts +39 -3
  28. package/dist/sdk-config-ir/v1/index.d.ts +39 -3
  29. package/dist/sdk-config-ir/v1/index.js +63 -2
  30. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  31. package/dist/{typescript-ZRqfOhMd.d.cts → typescript-BIq_eF34.d.cts} +10 -1
  32. package/dist/{typescript-ZRqfOhMd.d.ts → typescript-BIq_eF34.d.ts} +10 -1
  33. package/package.json +1 -1
  34. package/src/sdk-config/v1/README.md +31 -0
package/dist/index.cjs CHANGED
@@ -205,6 +205,9 @@ var oauthFlowSchema = zod.z.discriminatedUnion("type", [
205
205
  zod.z.strictObject({
206
206
  type: zod.z.literal("client-credentials").describe("Uses the OAuth client credentials flow."),
207
207
  tokenUrl: nonEmptyStringSchema.describe("The URL used to obtain access tokens."),
208
+ environmentTokenUrls: zod.z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe(
209
+ "Token URLs by environment name, for an API whose token endpoint differs per environment. When the selected environment has an entry, its URL replaces tokenUrl, so staging and development do not call the production token endpoint. Each key must name an entry of api.environments; environments without an entry use tokenUrl."
210
+ ),
208
211
  refreshUrl: nonEmptyStringSchema.optional().describe("The URL used to refresh access tokens."),
209
212
  scopes: zod.z.array(oauthScopeSchema).optional().describe("The scopes supported by this flow.")
210
213
  }),
@@ -353,6 +356,34 @@ var apiConfigSchema = zod.z.strictObject({
353
356
  */
354
357
  webhookSignature: webhookSignatureSchema.optional().describe("How generated helpers verify webhook signatures from the API.")
355
358
  });
359
+ function oauthEnvironmentTokenUrlsIssues(api, basePath) {
360
+ const environmentNames = new Set((api.environments ?? []).map(({ name }) => name));
361
+ const issues = [];
362
+ (api.auth?.schemes ?? []).forEach((scheme, schemeIndex) => {
363
+ if (scheme.type !== "oauth2") return;
364
+ scheme.flows.forEach((flow, flowIndex) => {
365
+ if (flow.type !== "client-credentials") return;
366
+ Object.keys(flow.environmentTokenUrls ?? {}).forEach((environment) => {
367
+ if (!environmentNames.has(environment)) {
368
+ issues.push({
369
+ message: `environmentTokenUrls "${environment}" must name an entry of api.environments`,
370
+ path: [
371
+ ...basePath,
372
+ "auth",
373
+ "schemes",
374
+ schemeIndex,
375
+ "flows",
376
+ flowIndex,
377
+ "environmentTokenUrls",
378
+ environment
379
+ ]
380
+ });
381
+ }
382
+ });
383
+ });
384
+ });
385
+ return issues;
386
+ }
356
387
 
357
388
  // src/sdk-config/v1/api.ts
358
389
  var sdkConfigV1AuthSchemeSchema = authSchemeSchema;
@@ -802,9 +833,20 @@ var mcpCustomToolSchema = zod.z.strictObject({
802
833
  "Path to a TypeScript module that exports the tool `definition` and `handler`."
803
834
  )
804
835
  });
836
+ var mcpHooksSchema = zod.z.strictObject({
837
+ path: relativePathSchema.describe(
838
+ "Path to a TypeScript module exporting the MCP request/response hooks (`beforeRequest`, `afterResponse`, `onError`, `transformResult`)."
839
+ )
840
+ });
805
841
  var mcpGenerationConfigSchema = typescriptGenerationConfigSchema.extend({
806
842
  serverName: nonEmptyStringSchema.optional().describe("The name advertised by the generated MCP server."),
807
843
  serverDescription: nonEmptyStringSchema.optional().describe("The description advertised by the generated MCP server."),
844
+ instructions: nonEmptyStringSchema.optional().describe(
845
+ "Replaces the auto-generated server instructions returned on initialize. WARNING: the generated instructions encode protocol wiring (the openapi:// resource and schema URI templates and the _meta keys the agent needs to browse docs and fetch full input schemas); replacing them drops that wiring and can break schema/doc browsing, so prefer appendInstructions unless you intend to restate it. Emitted verbatim and sent to the MCP client on every conversation, so keep it concise."
846
+ ),
847
+ appendInstructions: nonEmptyStringSchema.optional().describe(
848
+ "Appended after the auto-generated server instructions returned on initialize, preserving the generated protocol wiring. When both instructions and appendInstructions are set, this is appended after the replacement text. Emitted verbatim and sent to the MCP client on every conversation, so keep it concise."
849
+ ),
808
850
  excludeAvailability: zod.z.array(zod.z.enum(mcpAvailabilityStatuses)).optional().describe("Operation availability statuses excluded from MCP tool generation."),
809
851
  tools: mcpToolFilterSchema.optional().describe("Global operation filters for generated MCP tools."),
810
852
  toolsets: zod.z.record(mcpToolsetNameSchema, mcpToolFilterSchema).optional().describe("Named MCP toolsets and the operation filters for each toolset."),
@@ -813,6 +855,9 @@ var mcpGenerationConfigSchema = typescriptGenerationConfigSchema.extend({
813
855
  ),
814
856
  customTools: zod.z.record(mcpToolNameSchema, mcpCustomToolSchema).optional().describe(
815
857
  "Hand-written tools, keyed by tool name, each pointing at a TypeScript module that exports its `definition` and `handler`. Emitted alongside the operation-derived tools."
858
+ ),
859
+ hooks: mcpHooksSchema.optional().describe(
860
+ "Customer-authored request/response hooks, emitted into the generated server as `src/hooks.ts` (replacing the no-op stub)."
816
861
  )
817
862
  });
818
863
 
@@ -3220,6 +3265,9 @@ var sdkConfigV1Schema = zod.z.strictObject({
3220
3265
  targets: zod.z.array(sdkConfigV1TargetSchema).min(1).describe("Language targets to generate; each language may appear once.")
3221
3266
  }).superRefine(({ api, output, package: globalPackage, targets }, context) => {
3222
3267
  const configuredLanguages = /* @__PURE__ */ new Set();
3268
+ oauthEnvironmentTokenUrlsIssues(api, ["api"]).forEach(
3269
+ (issue) => context.addIssue({ code: "custom", ...issue })
3270
+ );
3223
3271
  targets.forEach((target, targetIndex) => {
3224
3272
  if (configuredLanguages.has(target.language)) {
3225
3273
  context.addIssue({
@@ -4148,6 +4196,8 @@ function mapMcp(config, state, basePath) {
4148
4196
  return compact({
4149
4197
  serverName: takeString(config, ["serverName"], state, basePath),
4150
4198
  serverDescription: takeString(config, ["serverDescription"], state, basePath),
4199
+ instructions: takeString(config, ["instructions"], state, basePath),
4200
+ appendInstructions: takeString(config, ["appendInstructions"], state, basePath),
4151
4201
  excludeAvailability: takeEnumArray(
4152
4202
  config,
4153
4203
  ["excludeAvailability"],
@@ -4167,7 +4217,8 @@ function mapMcp(config, state, basePath) {
4167
4217
  tools: takeToolFilter(config, ["tools"], state, basePath),
4168
4218
  toolsets: takeToolsets(config, ["toolsets"], state, basePath),
4169
4219
  mergedTools: takeMergedTools(config, ["mergedTools"], state, basePath),
4170
- customTools: takeCustomTools(config, ["customTools"], state, basePath)
4220
+ customTools: takeCustomTools(config, ["customTools"], state, basePath),
4221
+ hooks: takeHooks(config, ["hooks"], state, basePath)
4171
4222
  });
4172
4223
  }
4173
4224
  function mapReadme(value, language, activeLanguages, state, basePath) {
@@ -4549,6 +4600,21 @@ function takeCustomTools(value, aliases, state, basePath) {
4549
4600
  consume(state, located.path);
4550
4601
  return Object.fromEntries(entries.filter((entry) => entry !== void 0));
4551
4602
  }
4603
+ function takeHooks(value, aliases, state, basePath) {
4604
+ const located = takeObject(value, aliases, state, basePath);
4605
+ if (!located) return void 0;
4606
+ if (typeof located.value.path !== "string") {
4607
+ fail(
4608
+ "FERN_MCP_HOOKS_SPEC_INVALID",
4609
+ located.path,
4610
+ 'MCP hooks must be an object with a string "path"',
4611
+ 'Give "hooks" a "path" pointing at the TypeScript module exporting the request/response hooks.',
4612
+ ["targets", basePath[2], "generation", "hooks"]
4613
+ );
4614
+ }
4615
+ consume(state, located.path);
4616
+ return { path: located.value.path };
4617
+ }
4552
4618
  function takeMergedTools(value, aliases, state, basePath) {
4553
4619
  const located = takeObject(value, aliases, state, basePath);
4554
4620
  if (!located) return void 0;
@@ -5183,6 +5249,9 @@ var sdkConfigIrV1Schema = zod.z.strictObject({
5183
5249
  }
5184
5250
  });
5185
5251
  }
5252
+ oauthEnvironmentTokenUrlsIssues(api, ["api"]).forEach(
5253
+ (issue) => context.addIssue({ code: "custom", ...issue })
5254
+ );
5186
5255
  oauthTokenEndpointsIssues(generation.language?.cli?.oauthTokenEndpoints, api.auth?.schemes, [
5187
5256
  "generation",
5188
5257
  "language",
@@ -5233,7 +5302,10 @@ var sdkConfigIrV1Schema = zod.z.strictObject({
5233
5302
  function parseSdkConfigIrV1(value) {
5234
5303
  return sdkConfigIrV1Schema.parse(value);
5235
5304
  }
5236
- var sdkConfigIrCapabilitySchema = zod.z.enum(["generation.generateFullProject"]);
5305
+ var sdkConfigIrCapabilitySchema = zod.z.enum([
5306
+ "generation.generateFullProject",
5307
+ "api.auth.oauth.environmentTokenUrls"
5308
+ ]);
5237
5309
  var sdkConfigIrV1InputJsonSchema = inputJsonSchema(sdkConfigIrV1Schema);
5238
5310
  function serializeSdkConfigIrV1(value) {
5239
5311
  const parsed = parseSdkConfigIrV1(value);
@@ -5245,6 +5317,9 @@ function serializeSdkConfigIrV1(value) {
5245
5317
  if (parsed.generation.generateFullProject) {
5246
5318
  requiredCapabilities.push("generation.generateFullProject");
5247
5319
  }
5320
+ if (usesEnvironmentTokenUrls(parsed)) {
5321
+ requiredCapabilities.push("api.auth.oauth.environmentTokenUrls");
5322
+ }
5248
5323
  const json = JSON.stringify(wireValue);
5249
5324
  if (json === void 0) {
5250
5325
  throw new Error("SDK Config IR v1 could not be serialized as JSON");
@@ -5257,6 +5332,13 @@ function serializeSdkConfigIrV1(value) {
5257
5332
  function parseSdkConfigIrV1ForConsumption(value) {
5258
5333
  return parseSdkConfigIrV1(stripUnknownProperties(value, sdkConfigIrV1InputJsonSchema));
5259
5334
  }
5335
+ function usesEnvironmentTokenUrls(value) {
5336
+ return (value.api.auth?.schemes ?? []).some(
5337
+ (scheme) => scheme.type === "oauth2" && scheme.flows.some(
5338
+ (flow) => flow.type === "client-credentials" && flow.environmentTokenUrls !== void 0 && Object.keys(flow.environmentTokenUrls).length > 0
5339
+ )
5340
+ );
5341
+ }
5260
5342
 
5261
5343
  exports.CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE = CLI_DISTRIBUTION_NON_RELEASE_MODE_CODE;
5262
5344
  exports.FernConfigMappingError = FernConfigMappingError;
@@ -5298,6 +5380,7 @@ exports.mapFernConfigToSdkConfigV1 = mapFernConfigToSdkConfigV1;
5298
5380
  exports.mcpAvailabilityStatuses = mcpAvailabilityStatuses;
5299
5381
  exports.mcpGenerationConfigSchema = mcpGenerationConfigSchema;
5300
5382
  exports.nonEmptyStringSchema = nonEmptyStringSchema;
5383
+ exports.oauthEnvironmentTokenUrlsIssues = oauthEnvironmentTokenUrlsIssues;
5301
5384
  exports.oauthTokenEndpointsIssues = oauthTokenEndpointsIssues;
5302
5385
  exports.outputConfigSchema = outputConfigSchema;
5303
5386
  exports.packageConfigSchema = packageConfigSchema;