@postman/sdk-config 0.5.1 → 0.7.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 (35) hide show
  1. package/README.md +15 -0
  2. package/dist/index.cjs +263 -27
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +3 -3
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.js +260 -28
  7. package/dist/index.js.map +1 -1
  8. package/dist/sdk-config/index.cjs +224 -27
  9. package/dist/sdk-config/index.cjs.map +1 -1
  10. package/dist/sdk-config/index.d.cts +2 -2
  11. package/dist/sdk-config/index.d.ts +2 -2
  12. package/dist/sdk-config/index.js +224 -28
  13. package/dist/sdk-config/index.js.map +1 -1
  14. package/dist/sdk-config/v1/index.cjs +224 -27
  15. package/dist/sdk-config/v1/index.cjs.map +1 -1
  16. package/dist/sdk-config/v1/index.d.cts +20 -2
  17. package/dist/sdk-config/v1/index.d.ts +20 -2
  18. package/dist/sdk-config/v1/index.js +224 -28
  19. package/dist/sdk-config/v1/index.js.map +1 -1
  20. package/dist/sdk-config-ir/index.cjs +153 -0
  21. package/dist/sdk-config-ir/index.cjs.map +1 -1
  22. package/dist/sdk-config-ir/index.d.cts +2 -2
  23. package/dist/sdk-config-ir/index.d.ts +2 -2
  24. package/dist/sdk-config-ir/index.js +151 -1
  25. package/dist/sdk-config-ir/index.js.map +1 -1
  26. package/dist/sdk-config-ir/v1/index.cjs +153 -0
  27. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  28. package/dist/sdk-config-ir/v1/index.d.cts +43 -3
  29. package/dist/sdk-config-ir/v1/index.d.ts +43 -3
  30. package/dist/sdk-config-ir/v1/index.js +151 -1
  31. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  32. package/dist/{typescript-BruxA5zG.d.cts → typescript-BdDv_kwT.d.cts} +8 -0
  33. package/dist/{typescript-BruxA5zG.d.ts → typescript-BdDv_kwT.d.ts} +8 -0
  34. package/package.json +1 -1
  35. package/src/sdk-config-ir/v1/README.md +10 -2
@@ -462,17 +462,22 @@ var typescriptGenerationConfigSchema = z.strictObject({
462
462
  compilerOptions: compilerOptionsSchema.optional(),
463
463
  httpClient: httpClientSchema.optional(),
464
464
  packageManager: z.enum(["pnpm", "yarn"]).optional(),
465
+ /** e.g. `1.22.22` — from the customer's own `config.packageJson.packageManager` (`yarn@1.22.22`). */
466
+ packageManagerVersion: nonEmptyStringSchema.optional(),
465
467
  testFramework: z.enum(["jest", "vitest"]).optional(),
466
468
  namingStrategy: z.enum(["base", "originalPropertyNames"]).optional(),
467
469
  bundle: z.boolean().optional(),
468
470
  exportClassDefault: z.boolean().optional(),
469
471
  /** Name of the top-level namespace export emitted by Fern-compatible TypeScript SDKs. */
470
472
  namespaceExportName: nonEmptyStringSchema.optional(),
473
+ consolidateTypeFiles: z.boolean().optional(),
471
474
  allowCustomFetcher: z.boolean().optional(),
472
475
  useBrandedStringAliases: z.boolean().optional(),
473
476
  useLegacyExports: z.boolean().optional(),
474
477
  useBigInt: z.boolean().optional(),
475
478
  serdeLayer: z.boolean().optional(),
479
+ /** Ship only the ESM build (drops CJS) to avoid the Node dual-package hazard. */
480
+ esmOnly: z.boolean().optional(),
476
481
  scripts: z.array(packageScriptSchema).optional()
477
482
  });
478
483
 
@@ -1198,7 +1203,152 @@ var sdkConfigIrV1Schema = z.strictObject({
1198
1203
  function parseSdkConfigIrV1(value) {
1199
1204
  return sdkConfigIrV1Schema.parse(value);
1200
1205
  }
1206
+ var OMIT = /* @__PURE__ */ Symbol("omit");
1207
+ function inputJsonSchema(schema) {
1208
+ return z.toJSONSchema(schema, {
1209
+ io: "input",
1210
+ unrepresentable: "any"
1211
+ });
1212
+ }
1213
+ function stripUnknownProperties(value, schema) {
1214
+ return project(value, schema, schema, false);
1215
+ }
1216
+ function omitSchemaDefaults(value, schema) {
1217
+ const projected = project(value, schema, schema, true);
1218
+ return projected === OMIT ? void 0 : projected;
1219
+ }
1220
+ function project(value, candidateSchema, rootSchema, omitDefaults) {
1221
+ const resolvedCandidate = resolveSchema(candidateSchema, rootSchema);
1222
+ if (omitDefaults && Object.hasOwn(resolvedCandidate, "default") && deepEqual(value, resolvedCandidate.default)) {
1223
+ return OMIT;
1224
+ }
1225
+ const schema = selectSchema(value, resolvedCandidate, rootSchema);
1226
+ if (omitDefaults && schema !== resolvedCandidate && Object.hasOwn(schema, "default") && deepEqual(value, schema.default)) {
1227
+ return OMIT;
1228
+ }
1229
+ if (Array.isArray(value)) {
1230
+ if (!schema.items) return value;
1231
+ return value.map((item) => {
1232
+ const projected = project(item, schema.items, rootSchema, omitDefaults);
1233
+ return projected === OMIT ? item : projected;
1234
+ });
1235
+ }
1236
+ if (!isRecord(value) || schema.type !== "object") return value;
1237
+ const entries = [];
1238
+ const properties = schema.properties ?? {};
1239
+ const unionProperties = omitDefaults ? properties : collectAlternativeProperties(resolvedCandidate, rootSchema);
1240
+ for (const [key, propertySchema] of Object.entries(properties)) {
1241
+ if (!Object.hasOwn(value, key)) continue;
1242
+ const projected = project(value[key], propertySchema, rootSchema, omitDefaults);
1243
+ if (projected !== OMIT) entries.push([key, projected]);
1244
+ }
1245
+ for (const [key, fieldValue] of Object.entries(value)) {
1246
+ if (Object.hasOwn(properties, key)) continue;
1247
+ if (Object.hasOwn(unionProperties, key)) {
1248
+ entries.push([key, fieldValue]);
1249
+ continue;
1250
+ }
1251
+ if (schema.additionalProperties !== false) {
1252
+ const projected = typeof schema.additionalProperties === "object" ? project(fieldValue, schema.additionalProperties, rootSchema, omitDefaults) : fieldValue;
1253
+ if (projected !== OMIT) entries.push([key, projected]);
1254
+ } else if (omitDefaults) {
1255
+ throw new Error(`Cannot serialize property unknown to the wire schema: ${key}`);
1256
+ }
1257
+ }
1258
+ return Object.fromEntries(entries);
1259
+ }
1260
+ function collectAlternativeProperties(schema, rootSchema) {
1261
+ const alternatives = schema.oneOf ?? schema.anyOf;
1262
+ if (!alternatives) return schema.properties ?? {};
1263
+ return Object.assign(
1264
+ {},
1265
+ ...alternatives.map((alternative) => resolveSchema(alternative, rootSchema).properties ?? {})
1266
+ );
1267
+ }
1268
+ function selectSchema(value, schema, rootSchema) {
1269
+ const alternatives = schema.oneOf ?? schema.anyOf;
1270
+ if (!alternatives || alternatives.length === 0) return schema;
1271
+ const best = alternatives.map((alternative, index) => {
1272
+ const resolved = resolveSchema(alternative, rootSchema);
1273
+ return { index, schema: resolved, score: schemaMatchScore(value, resolved) };
1274
+ }).sort((left, right) => right.score - left.score || left.index - right.index)[0];
1275
+ return best.score === Number.NEGATIVE_INFINITY ? schema : best.schema;
1276
+ }
1277
+ function schemaMatchScore(value, schema) {
1278
+ if (Object.hasOwn(schema, "const") && !deepEqual(value, schema.const)) {
1279
+ return Number.NEGATIVE_INFINITY;
1280
+ }
1281
+ if (schema.enum && !schema.enum.some((candidate) => deepEqual(value, candidate))) {
1282
+ return Number.NEGATIVE_INFINITY;
1283
+ }
1284
+ if (schema.type === "object") {
1285
+ if (!isRecord(value)) return Number.NEGATIVE_INFINITY;
1286
+ const properties = schema.properties ?? {};
1287
+ for (const [key, propertySchema] of Object.entries(properties)) {
1288
+ if (!Object.hasOwn(value, key)) continue;
1289
+ if (Object.hasOwn(propertySchema, "const") && !deepEqual(value[key], propertySchema.const)) {
1290
+ return Number.NEGATIVE_INFINITY;
1291
+ }
1292
+ }
1293
+ return Object.keys(value).filter((key) => Object.hasOwn(properties, key)).length;
1294
+ }
1295
+ if (schema.type === "array") return Array.isArray(value) ? 1 : Number.NEGATIVE_INFINITY;
1296
+ if (schema.type === "string") return typeof value === "string" ? 1 : Number.NEGATIVE_INFINITY;
1297
+ if (schema.type === "number" || schema.type === "integer") {
1298
+ return typeof value === "number" ? 1 : Number.NEGATIVE_INFINITY;
1299
+ }
1300
+ if (schema.type === "boolean") return typeof value === "boolean" ? 1 : Number.NEGATIVE_INFINITY;
1301
+ if (schema.type === "null") return value === null ? 1 : Number.NEGATIVE_INFINITY;
1302
+ return 0;
1303
+ }
1304
+ function resolveSchema(schema, rootSchema) {
1305
+ if (!schema.$ref) return schema;
1306
+ if (!schema.$ref.startsWith("#/$defs/")) return schema;
1307
+ const name = schema.$ref.slice("#/$defs/".length).replaceAll("~1", "/").replaceAll("~0", "~");
1308
+ return rootSchema.$defs?.[name] ?? schema;
1309
+ }
1310
+ function isRecord(value) {
1311
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1312
+ }
1313
+ function deepEqual(left, right) {
1314
+ if (Object.is(left, right)) return true;
1315
+ if (Array.isArray(left) && Array.isArray(right)) {
1316
+ return left.length === right.length && left.every((value, index) => deepEqual(value, right[index]));
1317
+ }
1318
+ if (isRecord(left) && isRecord(right)) {
1319
+ const leftKeys = Object.keys(left);
1320
+ const rightKeys = Object.keys(right);
1321
+ return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && deepEqual(left[key], right[key]));
1322
+ }
1323
+ return false;
1324
+ }
1325
+
1326
+ // src/sdk-config-ir/v1/wire.ts
1327
+ var sdkConfigIrCapabilitySchema = z.enum(["generation.generateFullProject"]);
1328
+ var sdkConfigIrV1InputJsonSchema = inputJsonSchema(sdkConfigIrV1Schema);
1329
+ function serializeSdkConfigIrV1(value) {
1330
+ const parsed = parseSdkConfigIrV1(value);
1331
+ const wireValue = omitSchemaDefaults(parsed, sdkConfigIrV1InputJsonSchema);
1332
+ const requiredCapabilities = [];
1333
+ if (wireValue === void 0) {
1334
+ throw new Error("SDK Config IR v1 root cannot be omitted from its wire payload");
1335
+ }
1336
+ if (parsed.generation.generateFullProject) {
1337
+ requiredCapabilities.push("generation.generateFullProject");
1338
+ }
1339
+ const json = JSON.stringify(wireValue);
1340
+ if (json === void 0) {
1341
+ throw new Error("SDK Config IR v1 could not be serialized as JSON");
1342
+ }
1343
+ return {
1344
+ body: new TextEncoder().encode(json),
1345
+ requiredCapabilities
1346
+ };
1347
+ }
1348
+ function parseSdkConfigIrV1ForConsumption(value) {
1349
+ return parseSdkConfigIrV1(stripUnknownProperties(value, sdkConfigIrV1InputJsonSchema));
1350
+ }
1201
1351
 
1202
- export { SDK_CONFIG_IR_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliGenerationConfigSchema, clientConfigOverrideSchema, clientConfigSchema, clientRetryOverrideSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mcpAvailabilityStatuses, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeCustomSectionSchema, readmeEndpointSchema, relativePathSchema, replayConfigSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrV1Schema, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema, webhookSignatureSchema };
1352
+ export { SDK_CONFIG_IR_V1_SCHEMA_VERSION, apiConfigSchema, apiImportSettingsSchema, authConfigSchema, authSchemeSchema, cliGenerationConfigSchema, clientConfigOverrideSchema, clientConfigSchema, clientRetryOverrideSchema, compatibilityConfigSchema, composerPackageNameSchema, csharpGenerationConfigSchema, dependencySchema, docsConfigSchema, exactSemverSchema, generationConfigSchema, goGenerationConfigSchema, goModulePathSchema, javaGenerationConfigSchema, jsonObjectSchema, jsonValueSchema, kotlinGenerationConfigSchema, languageGenerationConfigSchema, legacyInputSchema, mcpAvailabilityStatuses, mcpGenerationConfigSchema, nonEmptyStringSchema, outputConfigSchema, packageConfigSchema, parseSdkConfigIrV1, parseSdkConfigIrV1ForConsumption, phpGenerationConfigSchema, publishConfigSchema, publishRegistrySchema, pythonGenerationConfigSchema, readmeCustomSectionSchema, readmeEndpointSchema, relativePathSchema, replayConfigSchema, rubyGenerationConfigSchema, rustGenerationConfigSchema, sdkConfigIrCapabilitySchema, sdkConfigIrV1Schema, serializeSdkConfigIrV1, sourceConfigSchema, sourceSpecConfigSchema, sourceSpecTypeSchema, swiftGenerationConfigSchema, targetConfigSchema, targetLanguageSchema, terraformGenerationConfigSchema, typescriptGenerationConfigSchema, unsupportedFieldSchema, webhookSignatureSchema };
1203
1353
  //# sourceMappingURL=index.js.map
1204
1354
  //# sourceMappingURL=index.js.map