@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
@@ -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);
@@ -2434,7 +2442,7 @@ var packageScriptSchema = zod.z.strictObject({
2434
2442
  command: nonEmptyStringSchema.describe("The command executed by the package script.")
2435
2443
  });
2436
2444
  var httpClientSchema = zod.z.strictObject({
2437
- name: zod.z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
2445
+ name: zod.z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
2438
2446
  });
2439
2447
  var typescriptGenerationConfigSchema = zod.z.strictObject({
2440
2448
  typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
@@ -2450,6 +2458,37 @@ var typescriptGenerationConfigSchema = zod.z.strictObject({
2450
2458
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
2451
2459
  namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
2452
2460
  consolidateTypeFiles: zod.z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
2461
+ formDataSupport: zod.z.enum(["Node16", "Node18"]).optional().describe(
2462
+ "The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
2463
+ ),
2464
+ allowExtraFields: zod.z.boolean().optional().describe(
2465
+ "Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
2466
+ ),
2467
+ generateSubpackageExports: zod.z.boolean().optional().describe(
2468
+ "Whether the package manifest exports each subpackage client as its own entry point."
2469
+ ),
2470
+ exportAllRequestsAtRoot: zod.z.boolean().optional().describe("Whether every request type is also exported from the package root."),
2471
+ generateEndpointMetadata: zod.z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
2472
+ outputEsm: zod.z.boolean().optional().describe(
2473
+ "Whether the package is marked as an ES module while still shipping its CommonJS build."
2474
+ ),
2475
+ neverThrowErrors: zod.z.boolean().optional().describe(
2476
+ "Whether client methods return a wrapped response instead of throwing on a non-2xx status."
2477
+ ),
2478
+ includeOtherInUnionTypes: zod.z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
2479
+ includeUtilsOnUnionMembers: zod.z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
2480
+ omitFernHeaders: zod.z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
2481
+ linter: zod.z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
2482
+ formatter: zod.z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
2483
+ exports: jsonObjectSchema.optional().describe(
2484
+ "package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
2485
+ ),
2486
+ files: zod.z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
2487
+ engines: zod.z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
2488
+ lintStaged: zod.z.record(nonEmptyStringSchema, zod.z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
2489
+ browser: zod.z.record(nonEmptyStringSchema, zod.z.union([zod.z.boolean(), nonEmptyStringSchema])).optional().describe(
2490
+ "package.json browser field: a module or file is excluded (false) or replaced by another path."
2491
+ ),
2453
2492
  allowCustomFetcher: zod.z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
2454
2493
  useBrandedStringAliases: zod.z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
2455
2494
  useLegacyExports: zod.z.boolean().optional().describe("Whether the package emits the legacy export layout."),
@@ -2865,16 +2904,21 @@ function mapFernConfigToSdkConfigV1(input) {
2865
2904
  ...optional("client", clients.targetOverrides[index]),
2866
2905
  ...optional("docs", docs.targetOverrides[index])
2867
2906
  };
2868
- const targetPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2907
+ const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2869
2908
  invocation.unsupportedFields.push(
2870
2909
  ...resolveTargetPackage(
2871
- targetPackage,
2910
+ mappedPackage,
2872
2911
  invocation.packageFallbacks,
2873
2912
  generator,
2874
2913
  output.delivery,
2875
2914
  index
2876
2915
  )
2877
2916
  );
2917
+ const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
2918
+ language,
2919
+ output,
2920
+ generator
2921
+ });
2878
2922
  if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
2879
2923
  target.package = targetPackage;
2880
2924
  }
@@ -2943,6 +2987,21 @@ function mapFernConfigToSdkConfigV1(input) {
2943
2987
  ])
2944
2988
  };
2945
2989
  }
2990
+ function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
2991
+ if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
2992
+ return packageConfig;
2993
+ }
2994
+ const { packageName } = packageConfig;
2995
+ return {
2996
+ ...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
2997
+ ...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
2998
+ ...packageConfig
2999
+ };
3000
+ }
3001
+ function usesCustomLicenseFile({ config, raw }) {
3002
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
3003
+ return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
3004
+ }
2946
3005
  function resolveLanguage(generator, index) {
2947
3006
  const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
2948
3007
  if (!language || !isFernLanguage(language)) {
@@ -3081,6 +3140,13 @@ function mapInvocation(generator, language, activeLanguages, index) {
3081
3140
  }
3082
3141
  }
3083
3142
  const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
3143
+ if (language === "typescript") {
3144
+ const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
3145
+ ...prefix,
3146
+ "config"
3147
+ ]);
3148
+ if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
3149
+ }
3084
3150
  const unsupportedFields = [
3085
3151
  ...state.valueDiagnostics ?? [],
3086
3152
  ...collectUnsupported(config, [...prefix, "config"], state),
@@ -3261,7 +3327,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
3261
3327
  });
3262
3328
  if (Object.keys(naming).length) generation.naming = naming;
3263
3329
  const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
3264
- if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
3330
+ const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
3331
+ if (wireTests !== void 0 || wireTestsFallback !== void 0) {
3332
+ generation.wireTests = { enabled: wireTests ?? true };
3333
+ if (wireTestsFallback !== void 0) {
3334
+ generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
3335
+ }
3336
+ }
3265
3337
  const webSockets = takeBoolean(
3266
3338
  config,
3267
3339
  ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
@@ -3304,10 +3376,10 @@ function mapTypescriptStreams(config, state, basePath) {
3304
3376
  function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
3305
3377
  switch (language) {
3306
3378
  case "typescript":
3307
- return mapTypescript(config, state, packageConfig, basePath);
3379
+ return mapTypescript(config, state, packageConfig, basePath, true);
3308
3380
  case "mcp":
3309
3381
  return {
3310
- ...mapTypescript(config, state, packageConfig, basePath),
3382
+ ...mapTypescript(config, state, packageConfig, basePath, false),
3311
3383
  ...mapMcp(config, state, basePath)
3312
3384
  };
3313
3385
  case "python":
@@ -3333,7 +3405,7 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath, tar
3333
3405
  return mapTerraform(config, state, packageConfig, basePath);
3334
3406
  }
3335
3407
  }
3336
- function mapTypescript(config, state, packageConfig, basePath) {
3408
+ function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
3337
3409
  const packageJsonManifest = mapPackageManifest(
3338
3410
  config,
3339
3411
  ["packageJson"],
@@ -3346,18 +3418,74 @@ function mapTypescript(config, state, packageConfig, basePath) {
3346
3418
  const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
3347
3419
  const packageManagerVersion = packageManagerVersionPart || void 0;
3348
3420
  if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
3421
+ const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
3349
3422
  const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
3350
3423
  const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
3351
- const fetchSupport = takeEnum(config, ["fetchSupport"], ["native"], state, basePath);
3424
+ const fetchSupport = takeEnum(
3425
+ config,
3426
+ ["fetchSupport"],
3427
+ sdkTarget ? ["native", "node-fetch"] : ["native"],
3428
+ state,
3429
+ basePath
3430
+ );
3352
3431
  const namingObject = takeObject(config, ["naming"], state, basePath);
3353
3432
  const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
3433
+ const sdkOnlyOptions = sdkTarget ? {
3434
+ formDataSupport: takeEnum(
3435
+ config,
3436
+ ["formDataSupport"],
3437
+ ["Node16", "Node18"],
3438
+ state,
3439
+ basePath
3440
+ ),
3441
+ allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
3442
+ generateSubpackageExports: takeBoolean(
3443
+ config,
3444
+ ["generateSubpackageExports"],
3445
+ state,
3446
+ basePath
3447
+ ),
3448
+ exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
3449
+ generateEndpointMetadata: takeBoolean(
3450
+ config,
3451
+ ["generateEndpointMetadata"],
3452
+ state,
3453
+ basePath
3454
+ ),
3455
+ outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
3456
+ neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
3457
+ includeOtherInUnionTypes: takeBoolean(
3458
+ config,
3459
+ ["includeOtherInUnionTypes"],
3460
+ state,
3461
+ basePath
3462
+ ),
3463
+ includeUtilsOnUnionMembers: takeBoolean(
3464
+ config,
3465
+ ["includeUtilsOnUnionMembers"],
3466
+ state,
3467
+ basePath
3468
+ ),
3469
+ omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
3470
+ linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
3471
+ formatter: takeEnum(
3472
+ config,
3473
+ ["formatter"],
3474
+ ["prettier", "biome", "oxfmt", "none"],
3475
+ state,
3476
+ basePath
3477
+ )
3478
+ } : {};
3354
3479
  return compact({
3480
+ ...sdkOnlyOptions,
3481
+ // Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
3482
+ ...manifestOptions,
3355
3483
  typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
3356
3484
  zodVersion: takeString(config, ["zodVersion"], state, basePath),
3357
3485
  packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
3358
3486
  packageManagerVersion,
3359
3487
  testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
3360
- httpClient: fetchSupport === "native" ? { name: "fetch" } : void 0,
3488
+ httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
3361
3489
  bundle: takeBoolean(config, ["bundle"], state, basePath),
3362
3490
  exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
3363
3491
  namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
@@ -3754,6 +3882,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
3754
3882
  );
3755
3883
  return manifest;
3756
3884
  }
3885
+ function mapPackageManifestOptions(manifest, state, packageConfig) {
3886
+ const bugs = takeManifestBugs(manifest, state);
3887
+ if (bugs) packageConfig.bugs = bugs;
3888
+ const repository = takeManifestRepository(manifest, state);
3889
+ if (repository !== void 0 && packageConfig.repository === void 0) {
3890
+ packageConfig.repository = repository;
3891
+ }
3892
+ const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
3893
+ if (exports) consume(state, exports.path);
3894
+ return compact({
3895
+ exports: exports?.value,
3896
+ scripts: takeManifestScripts(manifest, state),
3897
+ files: takeStringArray(manifest.value, ["files"], state, manifest.path),
3898
+ engines: takeManifestStringRecord(manifest, "engines", state),
3899
+ lintStaged: takeManifestLintStaged(manifest, state),
3900
+ browser: takeManifestBrowser(manifest, state)
3901
+ });
3902
+ }
3903
+ function takeManifestBugs(manifest, state) {
3904
+ const text = takeString(manifest.value, ["bugs"], state, manifest.path);
3905
+ if (text !== void 0) return { url: text };
3906
+ const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
3907
+ if (!located) return void 0;
3908
+ const url = takeString(located.value, ["url"], state, located.path);
3909
+ const email = takeString(located.value, ["email"], state, located.path);
3910
+ return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
3911
+ }
3912
+ function takeManifestRepository(manifest, state) {
3913
+ const text = takeString(manifest.value, ["repository"], state, manifest.path);
3914
+ if (text !== void 0) return text;
3915
+ const located = takeObject(manifest.value, ["repository"], state, manifest.path);
3916
+ if (!located) return void 0;
3917
+ const url = takeString(located.value, ["url"], state, located.path);
3918
+ if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
3919
+ return url;
3920
+ }
3921
+ function takeManifestScripts(manifest, state) {
3922
+ const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
3923
+ if (!located) return void 0;
3924
+ const scripts = Object.entries(located.value).flatMap(([name, command]) => {
3925
+ if (typeof command !== "string" || !command) return [];
3926
+ consume(state, [...located.path, name]);
3927
+ return [{ name, command }];
3928
+ });
3929
+ return scripts.length ? scripts : void 0;
3930
+ }
3931
+ function takeManifestStringRecord(manifest, key, state) {
3932
+ const located = takeObject(manifest.value, [key], state, manifest.path);
3933
+ if (!located) return void 0;
3934
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3935
+ if (typeof value !== "string" || !value) return [];
3936
+ consume(state, [...located.path, name]);
3937
+ return [[name, value]];
3938
+ });
3939
+ return entries.length ? Object.fromEntries(entries) : void 0;
3940
+ }
3941
+ function takeManifestLintStaged(manifest, state) {
3942
+ const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
3943
+ if (!located) return void 0;
3944
+ const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
3945
+ const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
3946
+ if (!list?.length || list.some((command) => !command)) return [];
3947
+ consume(state, [...located.path, glob]);
3948
+ return [[glob, list]];
3949
+ });
3950
+ return entries.length ? Object.fromEntries(entries) : void 0;
3951
+ }
3952
+ function takeManifestBrowser(manifest, state) {
3953
+ const located = takeObject(manifest.value, ["browser"], state, manifest.path);
3954
+ if (!located) return void 0;
3955
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3956
+ if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
3957
+ consume(state, [...located.path, name]);
3958
+ return [[name, value]];
3959
+ });
3960
+ return entries.length ? Object.fromEntries(entries) : void 0;
3961
+ }
3757
3962
  function takeManifestAuthors(manifest, state) {
3758
3963
  const located = locate(manifest.value, ["authors"], manifest.path);
3759
3964
  if (!located || !Array.isArray(located.value)) return [];