@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
@@ -432,6 +432,12 @@ var dependencySchema = z.strictObject({
432
432
  }).refine(({ source, version }) => source !== void 0 || version !== void 0, {
433
433
  message: "dependency must define a version or a source"
434
434
  });
435
+ var bugsSchema = z.strictObject({
436
+ url: nonEmptyStringSchema.optional().describe("The issue tracker URL."),
437
+ email: nonEmptyStringSchema.optional().describe("The address for reporting issues.")
438
+ }).refine(({ url, email }) => url !== void 0 || email !== void 0, {
439
+ message: "bugs must define a url or an email"
440
+ });
435
441
  var projectUrlSchema = z.strictObject({
436
442
  label: nonEmptyStringSchema.describe("The label displayed for the project link."),
437
443
  url: nonEmptyStringSchema.describe("The project link URL.")
@@ -446,6 +452,7 @@ var packageConfigSchema = z.strictObject({
446
452
  description: z.string().optional().describe("The package description used in generated metadata."),
447
453
  repository: nonEmptyStringSchema.optional().describe("The source repository for the generated SDK."),
448
454
  homepage: nonEmptyStringSchema.optional().describe("The package homepage URL."),
455
+ bugs: bugsSchema.optional().describe("Where issues with the package are reported."),
449
456
  documentationUrl: nonEmptyStringSchema.optional().describe("The package documentation URL."),
450
457
  authors: z.array(authorSchema).optional().describe("Authors credited in package metadata."),
451
458
  developers: z.array(developerSchema).optional().describe("Developers credited in package metadata."),
@@ -1233,6 +1240,7 @@ function githubOutput(value, publishInfo, rawOutput, language, sourcePath, state
1233
1240
  const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
1234
1241
  if (type) consume(state, [...sourcePath, "type"]);
1235
1242
  if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
1243
+ if (value.workflows === true) consume(state, [...sourcePath, "workflows"]);
1236
1244
  if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
1237
1245
  if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
1238
1246
  consumeCredentialObject(value.credentials, [...sourcePath, "credentials"], state);
@@ -2428,7 +2436,7 @@ var packageScriptSchema = z.strictObject({
2428
2436
  command: nonEmptyStringSchema.describe("The command executed by the package script.")
2429
2437
  });
2430
2438
  var httpClientSchema = z.strictObject({
2431
- name: z.enum(["axios", "fetch"]).describe("The HTTP client used by generated TypeScript code.")
2439
+ name: z.enum(["axios", "fetch", "node-fetch"]).describe("The HTTP client used by generated TypeScript code.")
2432
2440
  });
2433
2441
  var typescriptGenerationConfigSchema = z.strictObject({
2434
2442
  typescriptVersion: nonEmptyStringSchema.optional().describe("The TypeScript version used by the generated project."),
@@ -2444,6 +2452,37 @@ var typescriptGenerationConfigSchema = z.strictObject({
2444
2452
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
2445
2453
  namespaceExportName: nonEmptyStringSchema.optional().describe("The top-level namespace export name."),
2446
2454
  consolidateTypeFiles: z.boolean().optional().describe("Whether generated types are consolidated into fewer source files."),
2455
+ formDataSupport: z.enum(["Node16", "Node18"]).optional().describe(
2456
+ "The multipart form-data implementation: Node16 uses the form-data packages, Node18 uses the platform FormData."
2457
+ ),
2458
+ allowExtraFields: z.boolean().optional().describe(
2459
+ "Whether response parsing keeps unrecognized object keys and accepts unrecognized union members and enum values."
2460
+ ),
2461
+ generateSubpackageExports: z.boolean().optional().describe(
2462
+ "Whether the package manifest exports each subpackage client as its own entry point."
2463
+ ),
2464
+ exportAllRequestsAtRoot: z.boolean().optional().describe("Whether every request type is also exported from the package root."),
2465
+ generateEndpointMetadata: z.boolean().optional().describe("Whether generated clients expose metadata for each endpoint."),
2466
+ outputEsm: z.boolean().optional().describe(
2467
+ "Whether the package is marked as an ES module while still shipping its CommonJS build."
2468
+ ),
2469
+ neverThrowErrors: z.boolean().optional().describe(
2470
+ "Whether client methods return a wrapped response instead of throwing on a non-2xx status."
2471
+ ),
2472
+ includeOtherInUnionTypes: z.boolean().optional().describe("Whether union types gain a member for variants the SDK does not recognize."),
2473
+ includeUtilsOnUnionMembers: z.boolean().optional().describe("Whether helper utilities are generated on each member of a union type."),
2474
+ omitFernHeaders: z.boolean().optional().describe("Whether requests omit the SDK identification headers and the User-Agent header."),
2475
+ linter: z.enum(["biome", "oxlint", "none"]).optional().describe("The linter configured in the generated project."),
2476
+ formatter: z.enum(["prettier", "biome", "oxfmt", "none"]).optional().describe("The formatter configured in the generated project."),
2477
+ exports: jsonObjectSchema.optional().describe(
2478
+ "package.json exports entries, keyed by subpath, applied over the generated exports. Each subpath replaces the generated one."
2479
+ ),
2480
+ files: z.array(nonEmptyStringSchema).optional().describe("package.json files entries, listed ahead of the generated ones."),
2481
+ engines: z.record(nonEmptyStringSchema, nonEmptyStringSchema).optional().describe("package.json engines version ranges, keyed by engine name such as node."),
2482
+ lintStaged: z.record(nonEmptyStringSchema, z.array(nonEmptyStringSchema).min(1)).optional().describe("lint-staged commands to run, keyed by file glob."),
2483
+ browser: z.record(nonEmptyStringSchema, z.union([z.boolean(), nonEmptyStringSchema])).optional().describe(
2484
+ "package.json browser field: a module or file is excluded (false) or replaced by another path."
2485
+ ),
2447
2486
  allowCustomFetcher: z.boolean().optional().describe("Whether callers can supply a custom fetch implementation."),
2448
2487
  useBrandedStringAliases: z.boolean().optional().describe("Whether string aliases are emitted as distinct branded types."),
2449
2488
  useLegacyExports: z.boolean().optional().describe("Whether the package emits the legacy export layout."),
@@ -2859,16 +2898,21 @@ function mapFernConfigToSdkConfigV1(input) {
2859
2898
  ...optional("client", clients.targetOverrides[index]),
2860
2899
  ...optional("docs", docs.targetOverrides[index])
2861
2900
  };
2862
- const targetPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2901
+ const mappedPackage = { ...invocation.package, ...outputPackage, ...generator.package };
2863
2902
  invocation.unsupportedFields.push(
2864
2903
  ...resolveTargetPackage(
2865
- targetPackage,
2904
+ mappedPackage,
2866
2905
  invocation.packageFallbacks,
2867
2906
  generator,
2868
2907
  output.delivery,
2869
2908
  index
2870
2909
  )
2871
2910
  );
2911
+ const targetPackage = withRustCratesPublishDefaults(mappedPackage, {
2912
+ language,
2913
+ output,
2914
+ generator
2915
+ });
2872
2916
  if (Object.keys(targetPackage).length > 0 || outputPackage || generator.package) {
2873
2917
  target.package = targetPackage;
2874
2918
  }
@@ -2937,6 +2981,21 @@ function mapFernConfigToSdkConfigV1(input) {
2937
2981
  ])
2938
2982
  };
2939
2983
  }
2984
+ function withRustCratesPublishDefaults(packageConfig, { language, output, generator }) {
2985
+ if (language !== "rust" || !("publish" in output) || output.publish?.registry !== "crates") {
2986
+ return packageConfig;
2987
+ }
2988
+ const { packageName } = packageConfig;
2989
+ return {
2990
+ ...packageName ? { description: `Rust SDK for ${packageName} generated by Fern` } : {},
2991
+ ...usesCustomLicenseFile(generator) ? {} : { license: { type: "MIT" } },
2992
+ ...packageConfig
2993
+ };
2994
+ }
2995
+ function usesCustomLicenseFile({ config, raw }) {
2996
+ const metadata = isObject(raw) && isObject(raw.metadata) ? raw.metadata : void 0;
2997
+ return isObject(config) && typeof config.packageLicenseFile === "string" || isObject(metadata?.license);
2998
+ }
2940
2999
  function resolveLanguage(generator, index) {
2941
3000
  const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
2942
3001
  if (!language || !isFernLanguage(language)) {
@@ -3075,6 +3134,13 @@ function mapInvocation(generator, language, activeLanguages, index) {
3075
3134
  }
3076
3135
  }
3077
3136
  const docs = mapReadme(generator.readme, language, activeLanguages, state, [...prefix, "readme"]);
3137
+ if (language === "typescript") {
3138
+ const includeApiReference = takeBoolean(config, ["includeApiReference"], state, [
3139
+ ...prefix,
3140
+ "config"
3141
+ ]);
3142
+ if (includeApiReference !== void 0) docs.includeApiReference = includeApiReference;
3143
+ }
3078
3144
  const unsupportedFields = [
3079
3145
  ...state.valueDiagnostics ?? [],
3080
3146
  ...collectUnsupported(config, [...prefix, "config"], state),
@@ -3255,7 +3321,13 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
3255
3321
  });
3256
3322
  if (Object.keys(naming).length) generation.naming = naming;
3257
3323
  const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
3258
- if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
3324
+ const wireTestsFallback = language === "typescript" ? takeBoolean(config, ["wireTestsFallbackToAutoGeneratedErrorExamples"], state, basePath) : void 0;
3325
+ if (wireTests !== void 0 || wireTestsFallback !== void 0) {
3326
+ generation.wireTests = { enabled: wireTests ?? true };
3327
+ if (wireTestsFallback !== void 0) {
3328
+ generation.wireTests.fallbackToGeneratedErrorExamples = wireTestsFallback;
3329
+ }
3330
+ }
3259
3331
  const webSockets = takeBoolean(
3260
3332
  config,
3261
3333
  ["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
@@ -3298,10 +3370,10 @@ function mapTypescriptStreams(config, state, basePath) {
3298
3370
  function mapLanguageConfig(language, config, state, packageConfig, basePath, targetIndex) {
3299
3371
  switch (language) {
3300
3372
  case "typescript":
3301
- return mapTypescript(config, state, packageConfig, basePath);
3373
+ return mapTypescript(config, state, packageConfig, basePath, true);
3302
3374
  case "mcp":
3303
3375
  return {
3304
- ...mapTypescript(config, state, packageConfig, basePath),
3376
+ ...mapTypescript(config, state, packageConfig, basePath, false),
3305
3377
  ...mapMcp(config, state, basePath)
3306
3378
  };
3307
3379
  case "python":
@@ -3327,7 +3399,7 @@ function mapLanguageConfig(language, config, state, packageConfig, basePath, tar
3327
3399
  return mapTerraform(config, state, packageConfig, basePath);
3328
3400
  }
3329
3401
  }
3330
- function mapTypescript(config, state, packageConfig, basePath) {
3402
+ function mapTypescript(config, state, packageConfig, basePath, sdkTarget) {
3331
3403
  const packageJsonManifest = mapPackageManifest(
3332
3404
  config,
3333
3405
  ["packageJson"],
@@ -3340,18 +3412,74 @@ function mapTypescript(config, state, packageConfig, basePath) {
3340
3412
  const packageManagerVersionPart = packageManagerAtIndex >= 0 ? packageJsonPackageManager?.slice(packageManagerAtIndex + 1).split("+")[0] : void 0;
3341
3413
  const packageManagerVersion = packageManagerVersionPart || void 0;
3342
3414
  if (packageJsonManifest) liftPackageJsonDependencies(packageJsonManifest, state, packageConfig);
3415
+ const manifestOptions = sdkTarget && packageJsonManifest ? mapPackageManifestOptions(packageJsonManifest, state, packageConfig) : {};
3343
3416
  const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
3344
3417
  const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
3345
- const fetchSupport = takeEnum(config, ["fetchSupport"], ["native"], state, basePath);
3418
+ const fetchSupport = takeEnum(
3419
+ config,
3420
+ ["fetchSupport"],
3421
+ sdkTarget ? ["native", "node-fetch"] : ["native"],
3422
+ state,
3423
+ basePath
3424
+ );
3346
3425
  const namingObject = takeObject(config, ["naming"], state, basePath);
3347
3426
  const nestedNamespace = namingObject ? takeString(namingObject.value, ["namespace"], state, namingObject.path) : void 0;
3427
+ const sdkOnlyOptions = sdkTarget ? {
3428
+ formDataSupport: takeEnum(
3429
+ config,
3430
+ ["formDataSupport"],
3431
+ ["Node16", "Node18"],
3432
+ state,
3433
+ basePath
3434
+ ),
3435
+ allowExtraFields: takeBoolean(config, ["allowExtraFields"], state, basePath),
3436
+ generateSubpackageExports: takeBoolean(
3437
+ config,
3438
+ ["generateSubpackageExports"],
3439
+ state,
3440
+ basePath
3441
+ ),
3442
+ exportAllRequestsAtRoot: takeBoolean(config, ["exportAllRequestsAtRoot"], state, basePath),
3443
+ generateEndpointMetadata: takeBoolean(
3444
+ config,
3445
+ ["generateEndpointMetadata"],
3446
+ state,
3447
+ basePath
3448
+ ),
3449
+ outputEsm: takeBoolean(config, ["outputEsm"], state, basePath),
3450
+ neverThrowErrors: takeBoolean(config, ["neverThrowErrors"], state, basePath),
3451
+ includeOtherInUnionTypes: takeBoolean(
3452
+ config,
3453
+ ["includeOtherInUnionTypes"],
3454
+ state,
3455
+ basePath
3456
+ ),
3457
+ includeUtilsOnUnionMembers: takeBoolean(
3458
+ config,
3459
+ ["includeUtilsOnUnionMembers"],
3460
+ state,
3461
+ basePath
3462
+ ),
3463
+ omitFernHeaders: takeBoolean(config, ["omitFernHeaders"], state, basePath),
3464
+ linter: takeEnum(config, ["linter"], ["biome", "oxlint", "none"], state, basePath),
3465
+ formatter: takeEnum(
3466
+ config,
3467
+ ["formatter"],
3468
+ ["prettier", "biome", "oxfmt", "none"],
3469
+ state,
3470
+ basePath
3471
+ )
3472
+ } : {};
3348
3473
  return compact({
3474
+ ...sdkOnlyOptions,
3475
+ // Only the manifest writes these keys; nothing in sdkOnlyOptions or below shares a name.
3476
+ ...manifestOptions,
3349
3477
  typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
3350
3478
  zodVersion: takeString(config, ["zodVersion"], state, basePath),
3351
3479
  packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
3352
3480
  packageManagerVersion,
3353
3481
  testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
3354
- httpClient: fetchSupport === "native" ? { name: "fetch" } : void 0,
3482
+ httpClient: fetchSupport === void 0 ? void 0 : { name: fetchSupport === "native" ? "fetch" : "node-fetch" },
3355
3483
  bundle: takeBoolean(config, ["bundle"], state, basePath),
3356
3484
  exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
3357
3485
  namespaceExportName: takeString(config, ["namespaceExportName", "namespaceExport"], state, basePath) ?? nestedNamespace,
@@ -3748,6 +3876,83 @@ function mapPackageManifest(config, aliases, state, packageConfig, basePath) {
3748
3876
  );
3749
3877
  return manifest;
3750
3878
  }
3879
+ function mapPackageManifestOptions(manifest, state, packageConfig) {
3880
+ const bugs = takeManifestBugs(manifest, state);
3881
+ if (bugs) packageConfig.bugs = bugs;
3882
+ const repository = takeManifestRepository(manifest, state);
3883
+ if (repository !== void 0 && packageConfig.repository === void 0) {
3884
+ packageConfig.repository = repository;
3885
+ }
3886
+ const exports = takeObject(manifest.value, ["exports"], state, manifest.path);
3887
+ if (exports) consume(state, exports.path);
3888
+ return compact({
3889
+ exports: exports?.value,
3890
+ scripts: takeManifestScripts(manifest, state),
3891
+ files: takeStringArray(manifest.value, ["files"], state, manifest.path),
3892
+ engines: takeManifestStringRecord(manifest, "engines", state),
3893
+ lintStaged: takeManifestLintStaged(manifest, state),
3894
+ browser: takeManifestBrowser(manifest, state)
3895
+ });
3896
+ }
3897
+ function takeManifestBugs(manifest, state) {
3898
+ const text = takeString(manifest.value, ["bugs"], state, manifest.path);
3899
+ if (text !== void 0) return { url: text };
3900
+ const located = takeObject(manifest.value, ["bugs"], state, manifest.path);
3901
+ if (!located) return void 0;
3902
+ const url = takeString(located.value, ["url"], state, located.path);
3903
+ const email = takeString(located.value, ["email"], state, located.path);
3904
+ return url === void 0 && email === void 0 ? void 0 : compact({ url, email });
3905
+ }
3906
+ function takeManifestRepository(manifest, state) {
3907
+ const text = takeString(manifest.value, ["repository"], state, manifest.path);
3908
+ if (text !== void 0) return text;
3909
+ const located = takeObject(manifest.value, ["repository"], state, manifest.path);
3910
+ if (!located) return void 0;
3911
+ const url = takeString(located.value, ["url"], state, located.path);
3912
+ if (url !== void 0) void takeEnum(located.value, ["type"], ["git"], state, located.path);
3913
+ return url;
3914
+ }
3915
+ function takeManifestScripts(manifest, state) {
3916
+ const located = takeObject(manifest.value, ["scripts"], state, manifest.path);
3917
+ if (!located) return void 0;
3918
+ const scripts = Object.entries(located.value).flatMap(([name, command]) => {
3919
+ if (typeof command !== "string" || !command) return [];
3920
+ consume(state, [...located.path, name]);
3921
+ return [{ name, command }];
3922
+ });
3923
+ return scripts.length ? scripts : void 0;
3924
+ }
3925
+ function takeManifestStringRecord(manifest, key, state) {
3926
+ const located = takeObject(manifest.value, [key], state, manifest.path);
3927
+ if (!located) return void 0;
3928
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3929
+ if (typeof value !== "string" || !value) return [];
3930
+ consume(state, [...located.path, name]);
3931
+ return [[name, value]];
3932
+ });
3933
+ return entries.length ? Object.fromEntries(entries) : void 0;
3934
+ }
3935
+ function takeManifestLintStaged(manifest, state) {
3936
+ const located = takeObject(manifest.value, ["lint-staged"], state, manifest.path);
3937
+ if (!located) return void 0;
3938
+ const entries = Object.entries(located.value).flatMap(([glob, commands]) => {
3939
+ const list = typeof commands === "string" ? [commands] : stringArrayValue(commands);
3940
+ if (!list?.length || list.some((command) => !command)) return [];
3941
+ consume(state, [...located.path, glob]);
3942
+ return [[glob, list]];
3943
+ });
3944
+ return entries.length ? Object.fromEntries(entries) : void 0;
3945
+ }
3946
+ function takeManifestBrowser(manifest, state) {
3947
+ const located = takeObject(manifest.value, ["browser"], state, manifest.path);
3948
+ if (!located) return void 0;
3949
+ const entries = Object.entries(located.value).flatMap(([name, value]) => {
3950
+ if (typeof value !== "boolean" && (typeof value !== "string" || !value)) return [];
3951
+ consume(state, [...located.path, name]);
3952
+ return [[name, value]];
3953
+ });
3954
+ return entries.length ? Object.fromEntries(entries) : void 0;
3955
+ }
3751
3956
  function takeManifestAuthors(manifest, state) {
3752
3957
  const located = locate(manifest.value, ["authors"], manifest.path);
3753
3958
  if (!located || !Array.isArray(located.value)) return [];