@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.cjs CHANGED
@@ -303,7 +303,7 @@ var retryConfigSchema = zod.z.strictObject({
303
303
  maxDelayMs: zod.z.number().nonnegative().default(5e3).describe("The maximum backoff delay between attempts, in milliseconds."),
304
304
  jitterMs: zod.z.number().nonnegative().default(50).describe("The maximum random jitter added to retry delays, in milliseconds."),
305
305
  backoffFactor: zod.z.number().positive().default(2).describe("The multiplier applied to the delay after each failed attempt."),
306
- methods: zod.z.array(nonEmptyStringSchema).default(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).describe("HTTP methods that are eligible for retries."),
306
+ methods: zod.z.array(nonEmptyStringSchema).default(["GET", "PUT", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP methods that are eligible for retries."),
307
307
  maxRetryAfterDelayMs: zod.z.number().nonnegative().default(6e4).describe("The longest Retry-After delay the client will honor, in milliseconds.")
308
308
  }).superRefine(validateRetryDelays);
309
309
  var constructorParameterSchema = zod.z.strictObject({
@@ -329,6 +329,22 @@ var tokenRefreshConfigSchema = zod.z.strictObject({
329
329
  });
330
330
  }
331
331
  });
332
+ var idempotencyKeyGenerationSchema = zod.z.strictObject({
333
+ enabled: zod.z.boolean().describe("Whether the client generates an idempotency key when the caller supplies none."),
334
+ headerName: nonEmptyStringSchema.optional().describe("The header that carries the generated key. Generators default to Idempotency-Key."),
335
+ methods: zod.z.array(nonEmptyStringSchema).optional().describe("HTTP methods that receive a generated key. Generators default to POST and PUT.")
336
+ });
337
+ var userAgentConfigSchema = zod.z.strictObject({
338
+ template: nonEmptyStringSchema.optional().describe(
339
+ "The User-Agent product token, resolved at generation time. Supports the {packageName}, {version}, {language}, {generatorVersion}, {organization}, and {apiName} placeholders."
340
+ ),
341
+ includePlatformInfo: zod.z.boolean().optional().describe(
342
+ "Whether the User-Agent carries operating system, architecture, and runtime details, as `{product} ({os}; {arch}) {runtime}/{runtimeVersion}`."
343
+ ),
344
+ allowAppInfo: zod.z.boolean().optional().describe(
345
+ "Whether callers can pass application info that is appended to the User-Agent as a `{name}/{version} ({comment})` product token."
346
+ )
347
+ });
332
348
  var clientOverrideShape = {
333
349
  retry: clientRetryOverrideSchema.optional().describe("Retry behavior for generated API requests."),
334
350
  responseHeaders: zod.z.boolean().optional().describe("Whether generated operations expose HTTP response headers."),
@@ -341,7 +357,12 @@ var clientOverrideShape = {
341
357
  filePropertyStyle: parameterStyleSchema.optional().describe("Whether generated file properties are wrapped or passed inline."),
342
358
  useDefaultRequestParameterValues: zod.z.boolean().optional().describe("Whether schema defaults are applied to omitted request parameters."),
343
359
  respectOptionalRequestBody: zod.z.boolean().optional().describe("Whether an optional request body remains optional in generated methods."),
344
- tokenRefresh: tokenRefreshConfigSchema.optional().describe("Refresh-token behavior for the generated client.")
360
+ tokenRefresh: tokenRefreshConfigSchema.optional().describe("Refresh-token behavior for the generated client."),
361
+ idempotencyKeyGeneration: idempotencyKeyGenerationSchema.optional().describe("Automatic idempotency keys on eligible requests."),
362
+ userAgent: userAgentConfigSchema.optional().describe("The User-Agent header the generated client sends."),
363
+ offsetSemantics: zod.z.enum(["item-index", "page-index"]).optional().describe(
364
+ "How an offset-paginated endpoint advances: by the number of items returned, or by one page."
365
+ )
345
366
  };
346
367
  var clientConfigOverrideSchema = zod.z.strictObject(clientOverrideShape);
347
368
  var clientConfigSchema = zod.z.strictObject({
@@ -2423,6 +2444,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
2423
2444
  ...prefix,
2424
2445
  "config"
2425
2446
  ]);
2447
+ const apiWideIdempotency = idempotencyKeyGenerationFrom(
2448
+ generator.idempotencyKeyGenerationConfig,
2449
+ [...prefix, "idempotencyKeyGenerationConfig"],
2450
+ state
2451
+ );
2452
+ if (apiWideIdempotency && client.idempotencyKeyGeneration === void 0) {
2453
+ client.idempotencyKeyGeneration = apiWideIdempotency;
2454
+ }
2426
2455
  const rawGenerator = isObject(generator.raw) ? generator.raw : void 0;
2427
2456
  const smartCasing = typeof rawGenerator?.["smart-casing"] === "boolean" ? rawGenerator["smart-casing"] : generator.smartCasing === false ? false : void 0;
2428
2457
  const smartCasingDigitWordBoundary = typeof rawGenerator?.["smart-casing-digit-word-boundary"] === "boolean" ? rawGenerator["smart-casing-digit-word-boundary"] : generator.smartCasingDigitWordBoundary === true ? true : void 0;
@@ -2456,16 +2485,19 @@ function mapInvocation(generator, language, activeLanguages, index) {
2456
2485
  ...collectUnsupported(config, [...prefix, "config"], state),
2457
2486
  ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
2458
2487
  ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
2459
- ...unsupportedResolvedFields(generator, index)
2488
+ ...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
2460
2489
  ];
2461
2490
  return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
2462
2491
  }
2463
- function unsupportedResolvedFields(generator, index) {
2492
+ function unsupportedResolvedFields(generator, index, idempotencyMapped) {
2464
2493
  const values = [
2465
2494
  ["automation", isDefaultAutomation(generator.automation) ? void 0 : generator.automation],
2466
2495
  ["containerImage", generator.containerImage],
2467
2496
  ["irVersionOverride", generator.irVersionOverride],
2468
- ["idempotencyKeyGenerationConfig", generator.idempotencyKeyGenerationConfig],
2497
+ [
2498
+ "idempotencyKeyGenerationConfig",
2499
+ idempotencyMapped ? void 0 : generator.idempotencyKeyGenerationConfig
2500
+ ],
2469
2501
  ["absolutePathToLocalSnippets", generator.absolutePathToLocalSnippets],
2470
2502
  [
2471
2503
  "disableExamples",
@@ -2498,7 +2530,8 @@ function resolvedFieldGuidance(field) {
2498
2530
  }
2499
2531
  if (field === "idempotencyKeyGenerationConfig") {
2500
2532
  return {
2501
- suggestedAction: "Preserve this orchestration setting outside SDK Config; public v1 has no idempotency-generation field."
2533
+ sdkConfigPath: ["client", "idempotencyKeyGeneration"],
2534
+ suggestedAction: "Use true, false, or an object with header-name and methods, or set client.idempotencyKeyGeneration manually."
2502
2535
  };
2503
2536
  }
2504
2537
  if (field === "generateFullProject") {
@@ -2513,6 +2546,20 @@ function resolvedFieldGuidance(field) {
2513
2546
  function isDefaultAutomation(value) {
2514
2547
  return isObject(value) && value.generate === true && value.upgrade === true && value.preview === true && value.verify === true;
2515
2548
  }
2549
+ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
2550
+ function idempotencyKeyGenerationFrom(value, path, state) {
2551
+ if (typeof value === "boolean") {
2552
+ consume(state, path);
2553
+ return { enabled: value };
2554
+ }
2555
+ if (!isObject(value)) return void 0;
2556
+ const probe = { consumedPaths: /* @__PURE__ */ new Set() };
2557
+ const headerName = takeString(value, ["headerName"], probe, path);
2558
+ const methods = takeEnumArray(value, ["methods"], HTTP_METHODS, probe, path);
2559
+ if (probe.consumedPaths.size !== Object.keys(value).length) return void 0;
2560
+ consume(state, path);
2561
+ return { enabled: true, ...optional("headerName", headerName), ...optional("methods", methods) };
2562
+ }
2516
2563
  function mapCommonConfig(language, config, state, client, generation, packageConfig, basePath) {
2517
2564
  const inlinePath = takeBoolean(config, ["inlinePathParameters"], state, basePath);
2518
2565
  const inlineFile = takeBoolean(config, ["inlineFileProperties"], state, basePath);
@@ -2537,6 +2584,23 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2537
2584
  if (useDefaults !== void 0) client.useDefaultRequestParameterValues = useDefaults;
2538
2585
  const respectOptionalBody = takeBoolean(config, ["respectOptionalRequestBody"], state, basePath);
2539
2586
  if (respectOptionalBody !== void 0) client.respectOptionalRequestBody = respectOptionalBody;
2587
+ const idempotency = locate(config, ["autoGenerateIdempotencyKey"], basePath);
2588
+ const idempotencyKeyGeneration = idempotency && idempotencyKeyGenerationFrom(idempotency.value, idempotency.path, state);
2589
+ if (idempotencyKeyGeneration) client.idempotencyKeyGeneration = idempotencyKeyGeneration;
2590
+ const userAgent = compact({
2591
+ template: takeString(config, ["userAgent"], state, basePath),
2592
+ includePlatformInfo: takeBoolean(config, ["includePlatformHeaders"], state, basePath),
2593
+ allowAppInfo: takeBoolean(config, ["allowUserAgentAppInfo"], state, basePath)
2594
+ });
2595
+ if (Object.keys(userAgent).length) client.userAgent = userAgent;
2596
+ const offsetSemantics = takeEnum(
2597
+ config,
2598
+ ["offsetSemantics"],
2599
+ ["item-index", "page-index"],
2600
+ state,
2601
+ basePath
2602
+ );
2603
+ if (offsetSemantics !== void 0) client.offsetSemantics = offsetSemantics;
2540
2604
  const maxRetries = takeNumber(config, ["maxRetries"], state, basePath);
2541
2605
  const statusCodeProfile = takeEnum(
2542
2606
  config,
@@ -2554,7 +2618,10 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2554
2618
  const pythonClient = language === "python" ? takeObject(config, ["client"], state, basePath) : void 0;
2555
2619
  const typescriptNaming = language === "typescript" || language === "mcp" ? takeObject(config, ["naming"], state, basePath) : void 0;
2556
2620
  const directClientName = takeString(config, ["clientName", "clientClassName"], state, basePath);
2557
- const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : void 0;
2621
+ const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : language === "ruby" ? (
2622
+ // Fern's Ruby generator renames the root client class (`Auth0::Management`) with it.
2623
+ takeString(config, ["clientModuleName"], state, basePath)
2624
+ ) : void 0;
2558
2625
  const directExportedClientName = takeString(
2559
2626
  config,
2560
2627
  ["exportedClientName", "exportedClientClassName"],
@@ -2825,6 +2892,8 @@ function mapComposerRequirements(manifest, state, packageConfig) {
2825
2892
  function mapRuby(config, state, packageConfig, basePath) {
2826
2893
  const moduleName = takeString(config, ["moduleName"], state, basePath);
2827
2894
  if (moduleName !== void 0) packageConfig.moduleName = moduleName;
2895
+ const packageName = takeString(config, ["package-name"], state, basePath);
2896
+ if (packageName !== void 0) packageConfig.packageName = packageName;
2828
2897
  return compact({ requirePaths: takeStringArray(config, ["requirePaths"], state, basePath) });
2829
2898
  }
2830
2899
  function mapRust(config, state, packageConfig, basePath) {