@postman/sdk-config 0.11.0 → 0.12.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 +214 -9
  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 +214 -9
  6. package/dist/index.js.map +1 -1
  7. package/dist/sdk-config/index.cjs +214 -9
  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 +214 -9
  12. package/dist/sdk-config/index.js.map +1 -1
  13. package/dist/sdk-config/v1/index.cjs +214 -9
  14. package/dist/sdk-config/v1/index.cjs.map +1 -1
  15. package/dist/sdk-config/v1/index.d.cts +234 -2
  16. package/dist/sdk-config/v1/index.d.ts +234 -2
  17. package/dist/sdk-config/v1/index.js +214 -9
  18. package/dist/sdk-config/v1/index.js.map +1 -1
  19. package/dist/sdk-config-ir/index.cjs +39 -1
  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 +39 -1
  24. package/dist/sdk-config-ir/index.js.map +1 -1
  25. package/dist/sdk-config-ir/v1/index.cjs +39 -1
  26. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  27. package/dist/sdk-config-ir/v1/index.d.cts +186 -2
  28. package/dist/sdk-config-ir/v1/index.d.ts +186 -2
  29. package/dist/sdk-config-ir/v1/index.js +39 -1
  30. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  31. package/dist/{typescript-CsAa1VSy.d.cts → typescript-Byhn4MqL.d.cts} +64 -0
  32. package/dist/{typescript-CsAa1VSy.d.ts → typescript-Byhn4MqL.d.ts} +64 -0
  33. package/package.json +1 -1
  34. package/src/sdk-config-ir/v1/README.md +79 -31
package/dist/index.cjs CHANGED
@@ -438,6 +438,12 @@ var dependencySchema = zod.z.strictObject({
438
438
  }).refine(({ source, version }) => source !== void 0 || version !== void 0, {
439
439
  message: "dependency must define a version or a source"
440
440
  });
441
+ var bugsSchema = zod.z.strictObject({
442
+ url: nonEmptyStringSchema.optional().describe("The issue tracker URL."),
443
+ email: nonEmptyStringSchema.optional().describe("The address for reporting issues.")
444
+ }).refine(({ url, email }) => url !== void 0 || email !== void 0, {
445
+ message: "bugs must define a url or an email"
446
+ });
441
447
  var projectUrlSchema = zod.z.strictObject({
442
448
  label: nonEmptyStringSchema.describe("The label displayed for the project link."),
443
449
  url: nonEmptyStringSchema.describe("The project link URL.")
@@ -452,6 +458,7 @@ var packageConfigSchema = zod.z.strictObject({
452
458
  description: zod.z.string().optional().describe("The package description used in generated metadata."),
453
459
  repository: nonEmptyStringSchema.optional().describe("The source repository for the generated SDK."),
454
460
  homepage: nonEmptyStringSchema.optional().describe("The package homepage URL."),
461
+ bugs: bugsSchema.optional().describe("Where issues with the package are reported."),
455
462
  documentationUrl: nonEmptyStringSchema.optional().describe("The package documentation URL."),
456
463
  authors: zod.z.array(authorSchema).optional().describe("Authors credited in package metadata."),
457
464
  developers: zod.z.array(developerSchema).optional().describe("Developers credited in package metadata."),
@@ -1239,6 +1246,7 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
1239
1246
  const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
1240
1247
  if (type) consume(state, [...sourcePath, "type"]);
1241
1248
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
1249
+ if (value.workflows === true) consume(state, [...sourcePath, "workflows"]);
1242
1250
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
1243
1251
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
1244
1252
  consumeCredentialObject(value.credentials, [...sourcePath, "credentials"], state);
@@ -2446,7 +2454,7 @@ var packageScriptSchema = zod.z.strictObject({
2446
2454
  command: nonEmptyStringSchema.describe("The command executed by the package script.")
2447
2455
  });
2448
2456
  var httpClientSchema = zod.z.strictObject({
2449
- name: zod.z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
2457
+ name: zod.z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
2450
2458
  });
2451
2459
  var typescriptGenerationConfigSchema = zod.z.strictObject({
2452
2460
  typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
@@ -2462,6 +2470,37 @@ var typescriptGenerationConfigSchema = zod.z.strictObject({
2462
2470
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
2463
2471
  namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
2464
2472
  consolidateTypeFiles: zod.z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
2473
+ formDataSupport: zod.z.enum(["Node16", "Node18"]).optional().describe(
2474
+ "The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
2475
+ ),
2476
+ allowExtraFields: zod.z.boolean().optional().describe(
2477
+ "Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
2478
+ ),
2479
+ generateSubpackageExports: zod.z.boolean().optional().describe(
2480
+ "Whether the package manifest exports each subpackage client as its own entry point."
2481
+ ),
2482
+ exportAllRequestsAtRoot: zod.z.boolean().optional().describe("Whether every request type is also exported from the package root."),
2483
+ generateEndpointMetadata: zod.z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
2484
+ outputEsm: zod.z.boolean().optional().describe(
2485
+ "Whether the package is marked as an ES module while still shipping its CommonJS build."
2486
+ ),
2487
+ neverThrowErrors: zod.z.boolean().optional().describe(
2488
+ "Whether client methods return a wrapped response instead of throwing on a non-2xx status."
2489
+ ),
2490
+ includeOtherInUnionTypes: zod.z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
2491
+ includeUtilsOnUnionMembers: zod.z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
2492
+ omitFernHeaders: zod.z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
2493
+ linter: zod.z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
2494
+ formatter: zod.z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
2495
+ exports: jsonObjectSchema.optional().describe(
2496
+ "package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
2497
+ ),
2498
+ files: zod.z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
2499
+ engines: zod.z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
2500
+ lintStaged: zod.z.record(nonEmptyStringSchema, zod.z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
2501
+ browser: zod.z.record(nonEmptyStringSchema, zod.z.union([zod.z.boolean(), nonEmptyStringSchema])).optional().describe(
2502
+ "package.json browser field: a module or file is excluded (false) or replaced by another path."
2503
+ ),
2465
2504
  allowCustomFetcher: zod.z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
2466
2505
  useBrandedStringAliases: zod.z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
2467
2506
  useLegacyExports: zod.z.boolean().optional().describe("Whether the package emits the legacy export layout."),
@@ -2877,16 +2916,21 @@ function mapFernConfigToSdkConfigV1(input) {
2877
2916
  ...optional("client", clients.targetOverrides[index]),
2878
2917
  ...optional("docs", docs.targetOverrides[index])
2879
2918
  };
2880
- const targetPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2919
+ const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2881
2920
  invocation.unsupportedFields.push(
2882
2921
  ...resolveTargetPackage(
2883
- targetPackage,
2922
+ mappedPackage,
2884
2923
  invocation.packageFallbacks,
2885
2924
  generator,
2886
2925
  output.delivery,
2887
2926
  index
2888
2927
  )
2889
2928
  );
2929
+ const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
2930
+ language,
2931
+ output,
2932
+ generator
2933
+ });
2890
2934
  if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
2891
2935
  target.package = targetPackage;
2892
2936
  }
@@ -2955,6 +2999,21 @@ function mapFernConfigToSdkConfigV1(input) {
2955
2999
  ])
2956
3000
  };
2957
3001
  }
3002
+ function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
3003
+ if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
3004
+ return packageConfig;
3005
+ }
3006
+ const { packageName } = packageConfig;
3007
+ return {
3008
+ ...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
3009
+ ...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
3010
+ ...packageConfig
3011
+ };
3012
+ }
3013
+ function usesCustomLicenseFile({ config, raw }) {
3014
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
3015
+ return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
3016
+ }
2958
3017
  function resolveLanguage(generator, index) {
2959
3018
  const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
2960
3019
  if (!language || !isFernLanguage(language)) {
@@ -3093,6 +3152,13 @@ function mapInvocation(generator, language, activeLanguages, index) {
3093
3152
  }
3094
3153
  }
3095
3154
  const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
3155
+ if (language === "typescript") {
3156
+ const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
3157
+ ...prefix,
3158
+ "config"
3159
+ ]);
3160
+ if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
3161
+ }
3096
3162
  const unsupportedFields = [
3097
3163
  ...state.valueDiagnostics ?? [],
3098
3164
  ...collectUnsupported(config, [...prefix, "config"], state),
@@ -3273,7 +3339,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
3273
3339
  });
3274
3340
  if (Object.keys(naming).length) generation.naming = naming;
3275
3341
  const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
3276
- if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
3342
+ const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
3343
+ if (wireTests !== void 0 || wireTestsFallback !== void 0) {
3344
+ generation.wireTests = { enabled: wireTests ?? true };
3345
+ if (wireTestsFallback !== void 0) {
3346
+ generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
3347
+ }
3348
+ }
3277
3349
  const webSockets = takeBoolean(
3278
3350
  config,
3279
3351
  ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
@@ -3316,10 +3388,10 @@ function mapTypescriptStreams(config, state, basePath) {
3316
3388
  function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
3317
3389
  switch (language) {
3318
3390
  case "typescript":
3319
- return mapTypescript(config, state, packageConfig, basePath);
3391
+ return mapTypescript(config, state, packageConfig, basePath, true);
3320
3392
  case "mcp":
3321
3393
  return {
3322
- ...mapTypescript(config, state, packageConfig, basePath),
3394
+ ...mapTypescript(config, state, packageConfig, basePath, false),
3323
3395
  ...mapMcp(config, state, basePath)
3324
3396
  };
3325
3397
  case "python":
@@ -3345,7 +3417,7 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath, tar
3345
3417
  return mapTerraform(config, state, packageConfig, basePath);
3346
3418
  }
3347
3419
  }
3348
- function mapTypescript(config, state, packageConfig, basePath) {
3420
+ function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
3349
3421
  const packageJsonManifest = mapPackageManifest(
3350
3422
  config,
3351
3423
  ["packageJson"],
@@ -3358,18 +3430,74 @@ function mapTypescript(config, state, packageConfig, basePath) {
3358
3430
  const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
3359
3431
  const packageManagerVersion = packageManagerVersionPart || void 0;
3360
3432
  if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
3433
+ const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
3361
3434
  const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
3362
3435
  const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
3363
- const fetchSupport = takeEnum(config, ["fetchSupport"], ["native"], state, basePath);
3436
+ const fetchSupport = takeEnum(
3437
+ config,
3438
+ ["fetchSupport"],
3439
+ sdkTarget ? ["native", "node-fetch"] : ["native"],
3440
+ state,
3441
+ basePath
3442
+ );
3364
3443
  const namingObject = takeObject(config, ["naming"], state, basePath);
3365
3444
  const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
3445
+ const sdkOnlyOptions = sdkTarget ? {
3446
+ formDataSupport: takeEnum(
3447
+ config,
3448
+ ["formDataSupport"],
3449
+ ["Node16", "Node18"],
3450
+ state,
3451
+ basePath
3452
+ ),
3453
+ allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
3454
+ generateSubpackageExports: takeBoolean(
3455
+ config,
3456
+ ["generateSubpackageExports"],
3457
+ state,
3458
+ basePath
3459
+ ),
3460
+ exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
3461
+ generateEndpointMetadata: takeBoolean(
3462
+ config,
3463
+ ["generateEndpointMetadata"],
3464
+ state,
3465
+ basePath
3466
+ ),
3467
+ outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
3468
+ neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
3469
+ includeOtherInUnionTypes: takeBoolean(
3470
+ config,
3471
+ ["includeOtherInUnionTypes"],
3472
+ state,
3473
+ basePath
3474
+ ),
3475
+ includeUtilsOnUnionMembers: takeBoolean(
3476
+ config,
3477
+ ["includeUtilsOnUnionMembers"],
3478
+ state,
3479
+ basePath
3480
+ ),
3481
+ omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
3482
+ linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
3483
+ formatter: takeEnum(
3484
+ config,
3485
+ ["formatter"],
3486
+ ["prettier", "biome", "oxfmt", "none"],
3487
+ state,
3488
+ basePath
3489
+ )
3490
+ } : {};
3366
3491
  return compact({
3492
+ ...sdkOnlyOptions,
3493
+ // Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
3494
+ ...manifestOptions,
3367
3495
  typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
3368
3496
  zodVersion: takeString(config, ["zodVersion"], state, basePath),
3369
3497
  packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
3370
3498
  packageManagerVersion,
3371
3499
  testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
3372
- httpClient: fetchSupport === "native" ? { name: "fetch" } : void 0,
3500
+ httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
3373
3501
  bundle: takeBoolean(config, ["bundle"], state, basePath),
3374
3502
  exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
3375
3503
  namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
@@ -3766,6 +3894,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
3766
3894
  );
3767
3895
  return manifest;
3768
3896
  }
3897
+ function mapPackageManifestOptions(manifest, state, packageConfig) {
3898
+ const bugs = takeManifestBugs(manifest, state);
3899
+ if (bugs) packageConfig.bugs = bugs;
3900
+ const repository = takeManifestRepository(manifest, state);
3901
+ if (repository !== void 0 && packageConfig.repository === void 0) {
3902
+ packageConfig.repository = repository;
3903
+ }
3904
+ const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
3905
+ if (exports) consume(state, exports.path);
3906
+ return compact({
3907
+ exports: exports?.value,
3908
+ scripts: takeManifestScripts(manifest, state),
3909
+ files: takeStringArray(manifest.value, ["files"], state, manifest.path),
3910
+ engines: takeManifestStringRecord(manifest, "engines", state),
3911
+ lintStaged: takeManifestLintStaged(manifest, state),
3912
+ browser: takeManifestBrowser(manifest, state)
3913
+ });
3914
+ }
3915
+ function takeManifestBugs(manifest, state) {
3916
+ const text = takeString(manifest.value, ["bugs"], state, manifest.path);
3917
+ if (text !== void 0) return { url: text };
3918
+ const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
3919
+ if (!located) return void 0;
3920
+ const url = takeString(located.value, ["url"], state, located.path);
3921
+ const email = takeString(located.value, ["email"], state, located.path);
3922
+ return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
3923
+ }
3924
+ function takeManifestRepository(manifest, state) {
3925
+ const text = takeString(manifest.value, ["repository"], state, manifest.path);
3926
+ if (text !== void 0) return text;
3927
+ const located = takeObject(manifest.value, ["repository"], state, manifest.path);
3928
+ if (!located) return void 0;
3929
+ const url = takeString(located.value, ["url"], state, located.path);
3930
+ if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
3931
+ return url;
3932
+ }
3933
+ function takeManifestScripts(manifest, state) {
3934
+ const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
3935
+ if (!located) return void 0;
3936
+ const scripts = Object.entries(located.value).flatMap(([name, command]) => {
3937
+ if (typeof command !== "string" || !command) return [];
3938
+ consume(state, [...located.path, name]);
3939
+ return [{ name, command }];
3940
+ });
3941
+ return scripts.length ? scripts : void 0;
3942
+ }
3943
+ function takeManifestStringRecord(manifest, key, state) {
3944
+ const located = takeObject(manifest.value, [key], state, manifest.path);
3945
+ if (!located) return void 0;
3946
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3947
+ if (typeof value !== "string" || !value) return [];
3948
+ consume(state, [...located.path, name]);
3949
+ return [[name, value]];
3950
+ });
3951
+ return entries.length ? Object.fromEntries(entries) : void 0;
3952
+ }
3953
+ function takeManifestLintStaged(manifest, state) {
3954
+ const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
3955
+ if (!located) return void 0;
3956
+ const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
3957
+ const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
3958
+ if (!list?.length || list.some((command) => !command)) return [];
3959
+ consume(state, [...located.path, glob]);
3960
+ return [[glob, list]];
3961
+ });
3962
+ return entries.length ? Object.fromEntries(entries) : void 0;
3963
+ }
3964
+ function takeManifestBrowser(manifest, state) {
3965
+ const located = takeObject(manifest.value, ["browser"], state, manifest.path);
3966
+ if (!located) return void 0;
3967
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3968
+ if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
3969
+ consume(state, [...located.path, name]);
3970
+ return [[name, value]];
3971
+ });
3972
+ return entries.length ? Object.fromEntries(entries) : void 0;
3973
+ }
3769
3974
  function takeManifestAuthors(manifest, state) {
3770
3975
  const located = locate(manifest.value, ["authors"], manifest.path);
3771
3976
  if (!located || !Array.isArray(located.value)) return [];