@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.
@@ -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({
@@ -2411,6 +2432,14 @@ function mapInvocation(generator, language, activeLanguages, index) {
2411
2432
  ...prefix,
2412
2433
  "config"
2413
2434
  ]);
2435
+ const apiWideIdempotency = idempotencyKeyGenerationFrom(
2436
+ generator.idempotencyKeyGenerationConfig,
2437
+ [...prefix, "idempotencyKeyGenerationConfig"],
2438
+ state
2439
+ );
2440
+ if (apiWideIdempotency && client.idempotencyKeyGeneration === void 0) {
2441
+ client.idempotencyKeyGeneration = apiWideIdempotency;
2442
+ }
2414
2443
  const rawGenerator = isObject(generator.raw) ? generator.raw : void 0;
2415
2444
  const smartCasing = typeof rawGenerator?.["smart-casing"] === "boolean" ? rawGenerator["smart-casing"] : generator.smartCasing === false ? false : void 0;
2416
2445
  const smartCasingDigitWordBoundary = typeof rawGenerator?.["smart-casing-digit-word-boundary"] === "boolean" ? rawGenerator["smart-casing-digit-word-boundary"] : generator.smartCasingDigitWordBoundary === true ? true : void 0;
@@ -2444,16 +2473,19 @@ function mapInvocation(generator, language, activeLanguages, index) {
2444
2473
  ...collectUnsupported(config, [...prefix, "config"], state),
2445
2474
  ...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
2446
2475
  ...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
2447
- ...unsupportedResolvedFields(generator, index)
2476
+ ...unsupportedResolvedFields(generator, index, apiWideIdempotency !== void 0)
2448
2477
  ];
2449
2478
  return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
2450
2479
  }
2451
- function unsupportedResolvedFields(generator, index) {
2480
+ function unsupportedResolvedFields(generator, index, idempotencyMapped) {
2452
2481
  const values = [
2453
2482
  ["automation", isDefaultAutomation(generator.automation) ? void 0 : generator.automation],
2454
2483
  ["containerImage", generator.containerImage],
2455
2484
  ["irVersionOverride", generator.irVersionOverride],
2456
- ["idempotencyKeyGenerationConfig", generator.idempotencyKeyGenerationConfig],
2485
+ [
2486
+ "idempotencyKeyGenerationConfig",
2487
+ idempotencyMapped ? void 0 : generator.idempotencyKeyGenerationConfig
2488
+ ],
2457
2489
  ["absolutePathToLocalSnippets", generator.absolutePathToLocalSnippets],
2458
2490
  [
2459
2491
  "disableExamples",
@@ -2486,7 +2518,8 @@ function resolvedFieldGuidance(field) {
2486
2518
  }
2487
2519
  if (field === "idempotencyKeyGenerationConfig") {
2488
2520
  return {
2489
- suggestedAction: "Preserve this orchestration setting outside SDK Config; public v1 has no idempotency-generation field."
2521
+ sdkConfigPath: ["client", "idempotencyKeyGeneration"],
2522
+ suggestedAction: "Use true, false, or an object with header-name and methods, or set client.idempotencyKeyGeneration manually."
2490
2523
  };
2491
2524
  }
2492
2525
  if (field === "generateFullProject") {
@@ -2501,6 +2534,20 @@ function resolvedFieldGuidance(field) {
2501
2534
  function isDefaultAutomation(value) {
2502
2535
  return isObject(value) && value.generate === true && value.upgrade === true && value.preview === true && value.verify === true;
2503
2536
  }
2537
+ var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
2538
+ function idempotencyKeyGenerationFrom(value, path, state) {
2539
+ if (typeof value === "boolean") {
2540
+ consume(state, path);
2541
+ return { enabled: value };
2542
+ }
2543
+ if (!isObject(value)) return void 0;
2544
+ const probe = { consumedPaths: /* @__PURE__ */ new Set() };
2545
+ const headerName = takeString(value, ["headerName"], probe, path);
2546
+ const methods = takeEnumArray(value, ["methods"], HTTP_METHODS, probe, path);
2547
+ if (probe.consumedPaths.size !== Object.keys(value).length) return void 0;
2548
+ consume(state, path);
2549
+ return { enabled: true, ...optional("headerName", headerName), ...optional("methods", methods) };
2550
+ }
2504
2551
  function mapCommonConfig(language, config, state, client, generation, packageConfig, basePath) {
2505
2552
  const inlinePath = takeBoolean(config, ["inlinePathParameters"], state, basePath);
2506
2553
  const inlineFile = takeBoolean(config, ["inlineFileProperties"], state, basePath);
@@ -2525,6 +2572,23 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2525
2572
  if (useDefaults !== void 0) client.useDefaultRequestParameterValues = useDefaults;
2526
2573
  const respectOptionalBody = takeBoolean(config, ["respectOptionalRequestBody"], state, basePath);
2527
2574
  if (respectOptionalBody !== void 0) client.respectOptionalRequestBody = respectOptionalBody;
2575
+ const idempotency = locate(config, ["autoGenerateIdempotencyKey"], basePath);
2576
+ const idempotencyKeyGeneration = idempotency && idempotencyKeyGenerationFrom(idempotency.value, idempotency.path, state);
2577
+ if (idempotencyKeyGeneration) client.idempotencyKeyGeneration = idempotencyKeyGeneration;
2578
+ const userAgent = compact({
2579
+ template: takeString(config, ["userAgent"], state, basePath),
2580
+ includePlatformInfo: takeBoolean(config, ["includePlatformHeaders"], state, basePath),
2581
+ allowAppInfo: takeBoolean(config, ["allowUserAgentAppInfo"], state, basePath)
2582
+ });
2583
+ if (Object.keys(userAgent).length) client.userAgent = userAgent;
2584
+ const offsetSemantics = takeEnum(
2585
+ config,
2586
+ ["offsetSemantics"],
2587
+ ["item-index", "page-index"],
2588
+ state,
2589
+ basePath
2590
+ );
2591
+ if (offsetSemantics !== void 0) client.offsetSemantics = offsetSemantics;
2528
2592
  const maxRetries = takeNumber(config, ["maxRetries"], state, basePath);
2529
2593
  const statusCodeProfile = takeEnum(
2530
2594
  config,
@@ -2542,7 +2606,10 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
2542
2606
  const pythonClient = language === "python" ? takeObject(config, ["client"], state, basePath) : void 0;
2543
2607
  const typescriptNaming = language === "typescript" || language === "mcp" ? takeObject(config, ["naming"], state, basePath) : void 0;
2544
2608
  const directClientName = takeString(config, ["clientName", "clientClassName"], state, basePath);
2545
- const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : void 0;
2609
+ const nestedClientName = pythonClient ? takeString(pythonClient.value, ["className"], state, pythonClient.path) : typescriptNaming ? takeString(typescriptNaming.value, ["client"], state, typescriptNaming.path) : language === "ruby" ? (
2610
+ // Fern's Ruby generator renames the root client class (`Auth0::Management`) with it.
2611
+ takeString(config, ["clientModuleName"], state, basePath)
2612
+ ) : void 0;
2546
2613
  const directExportedClientName = takeString(
2547
2614
  config,
2548
2615
  ["exportedClientName", "exportedClientClassName"],
@@ -2813,6 +2880,8 @@ function mapComposerRequirements(manifest, state, packageConfig) {
2813
2880
  function mapRuby(config, state, packageConfig, basePath) {
2814
2881
  const moduleName = takeString(config, ["moduleName"], state, basePath);
2815
2882
  if (moduleName !== void 0) packageConfig.moduleName = moduleName;
2883
+ const packageName = takeString(config, ["package-name"], state, basePath);
2884
+ if (packageName !== void 0) packageConfig.packageName = packageName;
2816
2885
  return compact({ requirePaths: takeStringArray(config, ["requirePaths"], state, basePath) });
2817
2886
  }
2818
2887
  function mapRust(config, state, packageConfig, basePath) {