@postman/sdk-config 0.8.0 → 0.9.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.
package/dist/index.js CHANGED
@@ -297,7 +297,7 @@ var retryConfigSchema = z.strictObject({
297
297
  maxDelayMs: z.number().nonnegative().default(5e3).describe("The maximum backoff delay between attempts, in milliseconds."),
298
298
  jitterMs: z.number().nonnegative().default(50).describe("The maximum random jitter added to retry delays, in milliseconds."),
299
299
  backoffFactor: z.number().positive().default(2).describe("The multiplier applied to the delay after each failed attempt."),
300
- methods: z.array(nonEmptyStringSchema).default(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).describe("HTTP methods that are eligible for retries."),
300
+ methods: z.array(nonEmptyStringSchema).default(["GET", "PUT", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP methods that are eligible for retries."),
301
301
  maxRetryAfterDelayMs: z.number().nonnegative().default(6e4).describe("The longest Retry-After delay the client will honor, in milliseconds.")
302
302
  }).superRefine(validateRetryDelays);
303
303
  var constructorParameterSchema = z.strictObject({
@@ -323,6 +323,22 @@ var tokenRefreshConfigSchema = z.strictObject({
323
323
  });
324
324
  }
325
325
  });
326
+ var idempotencyKeyGenerationSchema = z.strictObject({
327
+ enabled: z.boolean().describe("Whether the client generates an idempotency key when the caller supplies none."),
328
+ headerName: nonEmptyStringSchema.optional().describe("The header that carries the generated key. Generators default to Idempotency-Key."),
329
+ methods: z.array(nonEmptyStringSchema).optional().describe("HTTP methods that receive a generated key. Generators default to POST and PUT.")
330
+ });
331
+ var userAgentConfigSchema = z.strictObject({
332
+ template: nonEmptyStringSchema.optional().describe(
333
+ "The User-Agent product token, resolved at generation time. Supports the {packageName}, {version}, {language}, {generatorVersion}, {organization}, and {apiName} placeholders."
334
+ ),
335
+ includePlatformInfo: z.boolean().optional().describe(
336
+ "Whether the User-Agent carries operating system, architecture, and runtime details, as `{product} ({os}; {arch}) {runtime}/{runtimeVersion}`."
337
+ ),
338
+ allowAppInfo: z.boolean().optional().describe(
339
+ "Whether callers can pass application info that is appended to the User-Agent as a `{name}/{version} ({comment})` product token."
340
+ )
341
+ });
326
342
  var clientOverrideShape = {
327
343
  retry: clientRetryOverrideSchema.optional().describe("Retry behavior for generated API requests."),
328
344
  responseHeaders: z.boolean().optional().describe("Whether generated operations expose HTTP response headers."),
@@ -335,7 +351,12 @@ var clientOverrideShape = {
335
351
  filePropertyStyle: parameterStyleSchema.optional().describe("Whether generated file properties are wrapped or passed inline."),
336
352
  useDefaultRequestParameterValues: z.boolean().optional().describe("Whether schema defaults are applied to omitted request parameters."),
337
353
  respectOptionalRequestBody: z.boolean().optional().describe("Whether an optional request body remains optional in generated methods."),
338
- tokenRefresh: tokenRefreshConfigSchema.optional().describe("Refresh-token behavior for the generated client.")
354
+ tokenRefresh: tokenRefreshConfigSchema.optional().describe("Refresh-token behavior for the generated client."),
355
+ idempotencyKeyGeneration: idempotencyKeyGenerationSchema.optional().describe("Automatic idempotency keys on eligible requests."),
356
+ userAgent: userAgentConfigSchema.optional().describe("The User-Agent header the generated client sends."),
357
+ offsetSemantics: z.enum(["item-index", "page-index"]).optional().describe(
358
+ "How an offset-paginated endpoint advances: by the number of items returned, or by one page."
359
+ )
339
360
  };
340
361
  var clientConfigOverrideSchema = z.strictObject(clientOverrideShape);
341
362
  var clientConfigSchema = z.strictObject({
@@ -2417,6 +2438,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
2417
2438
  ...prefix,
2418
2439
  "config"
2419
2440
  ]);
2441
+ const apiWideIdempotency = idempotencyKeyGenerationFrom(
2442
+ generator.idempotencyKeyGenerationConfig,
2443
+ [...prefix, "idempotencyKeyGenerationConfig"],
2444
+ state
2445
+ );
2446
+ if (apiWideIdempotency && client.idempotencyKeyGeneration === void 0) {
2447
+ client.idempotencyKeyGeneration = apiWideIdempotency;
2448
+ }
2420
2449
  const rawGenerator = isObject(generator.raw) ? generator.raw : void 0;
2421
2450
  const smartCasing = typeof rawGenerator?.["smart-casing"] === "boolean" ? rawGenerator["smart-casing"] : generator.smartCasing === false ? false : void 0;
2422
2451
  const smartCasingDigitWordBoundary = typeof rawGenerator?.["smart-casing-digit-word-boundary"] === "boolean" ? rawGenerator["smart-casing-digit-word-boundary"] : generator.smartCasingDigitWordBoundary === true ? true : void 0;
@@ -2450,16 +2479,19 @@ function mapInvocation(generator, language, activeLanguages, index) {
2450
2479
  ...collectUnsupported(config, [...prefix, "config"], state),
2451
2480
  ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
2452
2481
  ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
2453
- ...unsupportedResolvedFields(generator, index)
2482
+ ...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
2454
2483
  ];
2455
2484
  return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
2456
2485
  }
2457
- function unsupportedResolvedFields(generator, index) {
2486
+ function unsupportedResolvedFields(generator, index, idempotencyMapped) {
2458
2487
  const values = [
2459
2488
  ["automation", isDefaultAutomation(generator.automation) ? void 0 : generator.automation],
2460
2489
  ["containerImage", generator.containerImage],
2461
2490
  ["irVersionOverride", generator.irVersionOverride],
2462
- ["idempotencyKeyGenerationConfig", generator.idempotencyKeyGenerationConfig],
2491
+ [
2492
+ "idempotencyKeyGenerationConfig",
2493
+ idempotencyMapped ? void 0 : generator.idempotencyKeyGenerationConfig
2494
+ ],
2463
2495
  ["absolutePathToLocalSnippets", generator.absolutePathToLocalSnippets],
2464
2496
  [
2465
2497
  "disableExamples",
@@ -2492,7 +2524,8 @@ function resolvedFieldGuidance(field) {
2492
2524
  }
2493
2525
  if (field === "idempotencyKeyGenerationConfig") {
2494
2526
  return {
2495
- suggestedAction: "Preserve this orchestration setting outside SDK Config; public v1 has no idempotency-generation field."
2527
+ sdkConfigPath: ["client", "idempotencyKeyGeneration"],
2528
+ suggestedAction: "Use true, false, or an object with header-name and methods, or set client.idempotencyKeyGeneration manually."
2496
2529
  };
2497
2530
  }
2498
2531
  if (field === "generateFullProject") {
@@ -2507,6 +2540,20 @@ function resolvedFieldGuidance(field) {
2507
2540
  function isDefaultAutomation(value) {
2508
2541
  return isObject(value) && value.generate === true && value.upgrade === true && value.preview === true && value.verify === true;
2509
2542
  }
2543
+ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
2544
+ function idempotencyKeyGenerationFrom(value, path, state) {
2545
+ if (typeof value === "boolean") {
2546
+ consume(state, path);
2547
+ return { enabled: value };
2548
+ }
2549
+ if (!isObject(value)) return void 0;
2550
+ const probe = { consumedPaths: /* @__PURE__ */ new Set() };
2551
+ const headerName = takeString(value, ["headerName"], probe, path);
2552
+ const methods = takeEnumArray(value, ["methods"], HTTP_METHODS, probe, path);
2553
+ if (probe.consumedPaths.size !== Object.keys(value).length) return void 0;
2554
+ consume(state, path);
2555
+ return { enabled: true, ...optional("headerName", headerName), ...optional("methods", methods) };
2556
+ }
2510
2557
  function mapCommonConfig(language, config, state, client, generation, packageConfig, basePath) {
2511
2558
  const inlinePath = takeBoolean(config, ["inlinePathParameters"], state, basePath);
2512
2559
  const inlineFile = takeBoolean(config, ["inlineFileProperties"], state, basePath);
@@ -2531,6 +2578,23 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2531
2578
  if (useDefaults !== void 0) client.useDefaultRequestParameterValues = useDefaults;
2532
2579
  const respectOptionalBody = takeBoolean(config, ["respectOptionalRequestBody"], state, basePath);
2533
2580
  if (respectOptionalBody !== void 0) client.respectOptionalRequestBody = respectOptionalBody;
2581
+ const idempotency = locate(config, ["autoGenerateIdempotencyKey"], basePath);
2582
+ const idempotencyKeyGeneration = idempotency && idempotencyKeyGenerationFrom(idempotency.value, idempotency.path, state);
2583
+ if (idempotencyKeyGeneration) client.idempotencyKeyGeneration = idempotencyKeyGeneration;
2584
+ const userAgent = compact({
2585
+ template: takeString(config, ["userAgent"], state, basePath),
2586
+ includePlatformInfo: takeBoolean(config, ["includePlatformHeaders"], state, basePath),
2587
+ allowAppInfo: takeBoolean(config, ["allowUserAgentAppInfo"], state, basePath)
2588
+ });
2589
+ if (Object.keys(userAgent).length) client.userAgent = userAgent;
2590
+ const offsetSemantics = takeEnum(
2591
+ config,
2592
+ ["offsetSemantics"],
2593
+ ["item-index", "page-index"],
2594
+ state,
2595
+ basePath
2596
+ );
2597
+ if (offsetSemantics !== void 0) client.offsetSemantics = offsetSemantics;
2534
2598
  const maxRetries = takeNumber(config, ["maxRetries"], state, basePath);
2535
2599
  const statusCodeProfile = takeEnum(
2536
2600
  config,
@@ -2548,7 +2612,10 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2548
2612
  const pythonClient = language === "python" ? takeObject(config, ["client"], state, basePath) : void 0;
2549
2613
  const typescriptNaming = language === "typescript" || language === "mcp" ? takeObject(config, ["naming"], state, basePath) : void 0;
2550
2614
  const directClientName = takeString(config, ["clientName", "clientClassName"], state, basePath);
2551
- const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : void 0;
2615
+ const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : language === "ruby" ? (
2616
+ // Fern's Ruby generator renames the root client class (`Auth0::Management`) with it.
2617
+ takeString(config, ["clientModuleName"], state, basePath)
2618
+ ) : void 0;
2552
2619
  const directExportedClientName = takeString(
2553
2620
  config,
2554
2621
  ["exportedClientName", "exportedClientClassName"],
@@ -2819,6 +2886,8 @@ function mapComposerRequirements(manifest, state, packageConfig) {
2819
2886
  function mapRuby(config, state, packageConfig, basePath) {
2820
2887
  const moduleName = takeString(config, ["moduleName"], state, basePath);
2821
2888
  if (moduleName !== void 0) packageConfig.moduleName = moduleName;
2889
+ const packageName = takeString(config, ["package-name"], state, basePath);
2890
+ if (packageName !== void 0) packageConfig.packageName = packageName;
2822
2891
  return compact({ requirePaths: takeStringArray(config, ["requirePaths"], state, basePath) });
2823
2892
  }
2824
2893
  function mapRust(config, state, packageConfig, basePath) {