@postman/sdk-config 0.5.0 → 0.6.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.
- package/README.md +15 -0
- package/dist/index.cjs +176 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +173 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk-config/index.cjs +135 -1
- package/dist/sdk-config/index.cjs.map +1 -1
- package/dist/sdk-config/index.d.cts +1 -1
- package/dist/sdk-config/index.d.ts +1 -1
- package/dist/sdk-config/index.js +135 -2
- package/dist/sdk-config/index.js.map +1 -1
- package/dist/sdk-config/v1/index.cjs +135 -1
- package/dist/sdk-config/v1/index.cjs.map +1 -1
- package/dist/sdk-config/v1/index.d.cts +3367 -3329
- package/dist/sdk-config/v1/index.d.ts +3367 -3329
- package/dist/sdk-config/v1/index.js +135 -2
- package/dist/sdk-config/v1/index.js.map +1 -1
- package/dist/sdk-config-ir/index.cjs +150 -0
- package/dist/sdk-config-ir/index.cjs.map +1 -1
- package/dist/sdk-config-ir/index.d.cts +1 -1
- package/dist/sdk-config-ir/index.d.ts +1 -1
- package/dist/sdk-config-ir/index.js +148 -1
- package/dist/sdk-config-ir/index.js.map +1 -1
- package/dist/sdk-config-ir/v1/index.cjs +150 -0
- package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
- package/dist/sdk-config-ir/v1/index.d.cts +26 -1
- package/dist/sdk-config-ir/v1/index.d.ts +26 -1
- package/dist/sdk-config-ir/v1/index.js +148 -1
- package/dist/sdk-config-ir/v1/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk-config/v1/README.md +5 -3
- package/src/sdk-config-ir/v1/README.md +6 -0
|
@@ -1240,10 +1240,16 @@ function finishOutputMapping(mapping, outputMode, sourcePath, state, index) {
|
|
|
1240
1240
|
for (const path of collectLeafPaths(outputMode, sourcePath)) {
|
|
1241
1241
|
if (path[path.length - 1] === "_visit") consume(state, path);
|
|
1242
1242
|
}
|
|
1243
|
+
const legacyGenerateFullProject = isObject(outputMode) ? outputMode.generateFullProject : void 0;
|
|
1244
|
+
const generationShape = typeof legacyGenerateFullProject === "boolean" ? { generation: { ...mapping.generation, generateFullProject: legacyGenerateFullProject } } : {};
|
|
1245
|
+
if (typeof legacyGenerateFullProject === "boolean") {
|
|
1246
|
+
consume(state, [...sourcePath, "generateFullProject"]);
|
|
1247
|
+
}
|
|
1243
1248
|
const unsupported = collectUnsupported(outputMode, sourcePath, state);
|
|
1244
1249
|
const hasCredentials = unsupported.some((diagnostic) => isCredentialPath(diagnostic.path));
|
|
1245
1250
|
return {
|
|
1246
1251
|
...mapping,
|
|
1252
|
+
...generationShape,
|
|
1247
1253
|
unsupportedFields: [
|
|
1248
1254
|
...state.credentialDiagnostics ?? [],
|
|
1249
1255
|
...hasCredentials ? [
|
|
@@ -1327,6 +1333,113 @@ function outputDiagnostic(path, index) {
|
|
|
1327
1333
|
suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
|
|
1328
1334
|
};
|
|
1329
1335
|
}
|
|
1336
|
+
var OMIT = /* @__PURE__ */ Symbol("omit");
|
|
1337
|
+
function inputJsonSchema(schema) {
|
|
1338
|
+
return z.toJSONSchema(schema, {
|
|
1339
|
+
io: "input",
|
|
1340
|
+
unrepresentable: "any"
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
function stripUnknownProperties(value, schema) {
|
|
1344
|
+
return project(value, schema, schema);
|
|
1345
|
+
}
|
|
1346
|
+
function project(value, candidateSchema, rootSchema, omitDefaults) {
|
|
1347
|
+
const resolvedCandidate = resolveSchema(candidateSchema, rootSchema);
|
|
1348
|
+
const schema = selectSchema(value, resolvedCandidate, rootSchema);
|
|
1349
|
+
if (Array.isArray(value)) {
|
|
1350
|
+
if (!schema.items) return value;
|
|
1351
|
+
return value.map((item) => {
|
|
1352
|
+
const projected = project(item, schema.items, rootSchema);
|
|
1353
|
+
return projected === OMIT ? item : projected;
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
if (!isRecord(value) || schema.type !== "object") return value;
|
|
1357
|
+
const entries = [];
|
|
1358
|
+
const properties = schema.properties ?? {};
|
|
1359
|
+
const unionProperties = collectAlternativeProperties(resolvedCandidate, rootSchema);
|
|
1360
|
+
for (const [key, propertySchema] of Object.entries(properties)) {
|
|
1361
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
1362
|
+
const projected = project(value[key], propertySchema, rootSchema);
|
|
1363
|
+
if (projected !== OMIT) entries.push([key, projected]);
|
|
1364
|
+
}
|
|
1365
|
+
for (const [key, fieldValue] of Object.entries(value)) {
|
|
1366
|
+
if (Object.hasOwn(properties, key)) continue;
|
|
1367
|
+
if (Object.hasOwn(unionProperties, key)) {
|
|
1368
|
+
entries.push([key, fieldValue]);
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1371
|
+
if (schema.additionalProperties !== false) {
|
|
1372
|
+
const projected = typeof schema.additionalProperties === "object" ? project(fieldValue, schema.additionalProperties, rootSchema) : fieldValue;
|
|
1373
|
+
if (projected !== OMIT) entries.push([key, projected]);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return Object.fromEntries(entries);
|
|
1377
|
+
}
|
|
1378
|
+
function collectAlternativeProperties(schema, rootSchema) {
|
|
1379
|
+
const alternatives = schema.oneOf ?? schema.anyOf;
|
|
1380
|
+
if (!alternatives) return schema.properties ?? {};
|
|
1381
|
+
return Object.assign(
|
|
1382
|
+
{},
|
|
1383
|
+
...alternatives.map((alternative) => resolveSchema(alternative, rootSchema).properties ?? {})
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
function selectSchema(value, schema, rootSchema) {
|
|
1387
|
+
const alternatives = schema.oneOf ?? schema.anyOf;
|
|
1388
|
+
if (!alternatives || alternatives.length === 0) return schema;
|
|
1389
|
+
const best = alternatives.map((alternative, index) => {
|
|
1390
|
+
const resolved = resolveSchema(alternative, rootSchema);
|
|
1391
|
+
return { index, schema: resolved, score: schemaMatchScore(value, resolved) };
|
|
1392
|
+
}).sort((left, right) => right.score - left.score || left.index - right.index)[0];
|
|
1393
|
+
return best.score === Number.NEGATIVE_INFINITY ? schema : best.schema;
|
|
1394
|
+
}
|
|
1395
|
+
function schemaMatchScore(value, schema) {
|
|
1396
|
+
if (Object.hasOwn(schema, "const") && !deepEqual(value, schema.const)) {
|
|
1397
|
+
return Number.NEGATIVE_INFINITY;
|
|
1398
|
+
}
|
|
1399
|
+
if (schema.enum && !schema.enum.some((candidate) => deepEqual(value, candidate))) {
|
|
1400
|
+
return Number.NEGATIVE_INFINITY;
|
|
1401
|
+
}
|
|
1402
|
+
if (schema.type === "object") {
|
|
1403
|
+
if (!isRecord(value)) return Number.NEGATIVE_INFINITY;
|
|
1404
|
+
const properties = schema.properties ?? {};
|
|
1405
|
+
for (const [key, propertySchema] of Object.entries(properties)) {
|
|
1406
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
1407
|
+
if (Object.hasOwn(propertySchema, "const") && !deepEqual(value[key], propertySchema.const)) {
|
|
1408
|
+
return Number.NEGATIVE_INFINITY;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
return Object.keys(value).filter((key) => Object.hasOwn(properties, key)).length;
|
|
1412
|
+
}
|
|
1413
|
+
if (schema.type === "array") return Array.isArray(value) ? 1 : Number.NEGATIVE_INFINITY;
|
|
1414
|
+
if (schema.type === "string") return typeof value === "string" ? 1 : Number.NEGATIVE_INFINITY;
|
|
1415
|
+
if (schema.type === "number" || schema.type === "integer") {
|
|
1416
|
+
return typeof value === "number" ? 1 : Number.NEGATIVE_INFINITY;
|
|
1417
|
+
}
|
|
1418
|
+
if (schema.type === "boolean") return typeof value === "boolean" ? 1 : Number.NEGATIVE_INFINITY;
|
|
1419
|
+
if (schema.type === "null") return value === null ? 1 : Number.NEGATIVE_INFINITY;
|
|
1420
|
+
return 0;
|
|
1421
|
+
}
|
|
1422
|
+
function resolveSchema(schema, rootSchema) {
|
|
1423
|
+
if (!schema.$ref) return schema;
|
|
1424
|
+
if (!schema.$ref.startsWith("#/$defs/")) return schema;
|
|
1425
|
+
const name = schema.$ref.slice("#/$defs/".length).replaceAll("~1", "/").replaceAll("~0", "~");
|
|
1426
|
+
return rootSchema.$defs?.[name] ?? schema;
|
|
1427
|
+
}
|
|
1428
|
+
function isRecord(value) {
|
|
1429
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1430
|
+
}
|
|
1431
|
+
function deepEqual(left, right) {
|
|
1432
|
+
if (Object.is(left, right)) return true;
|
|
1433
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
1434
|
+
return left.length === right.length && left.every((value, index) => deepEqual(value, right[index]));
|
|
1435
|
+
}
|
|
1436
|
+
if (isRecord(left) && isRecord(right)) {
|
|
1437
|
+
const leftKeys = Object.keys(left);
|
|
1438
|
+
const rightKeys = Object.keys(right);
|
|
1439
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && deepEqual(left[key], right[key]));
|
|
1440
|
+
}
|
|
1441
|
+
return false;
|
|
1442
|
+
}
|
|
1330
1443
|
var namingConfigSchema = z.strictObject({
|
|
1331
1444
|
clientName: nonEmptyStringSchema.optional(),
|
|
1332
1445
|
exportedClientName: nonEmptyStringSchema.optional(),
|
|
@@ -1425,6 +1538,8 @@ var generationConfigOverrideShape = {
|
|
|
1425
1538
|
inferServiceNames: z.boolean().optional(),
|
|
1426
1539
|
includeDeprecatedOperations: z.boolean().optional(),
|
|
1427
1540
|
multipleResponses: z.boolean().optional(),
|
|
1541
|
+
/** Generate the entire SDK project, including package manifests and publishable artifacts. */
|
|
1542
|
+
generateFullProject: z.boolean().optional(),
|
|
1428
1543
|
devContainer: z.boolean().optional(),
|
|
1429
1544
|
allowMockClient: z.boolean().optional(),
|
|
1430
1545
|
ignoreFiles: z.array(nonEmptyStringSchema).optional(),
|
|
@@ -1453,6 +1568,7 @@ var sdkConfigV1GenerationConfigSchema = z.strictObject({
|
|
|
1453
1568
|
inferServiceNames: z.boolean().default(false),
|
|
1454
1569
|
includeDeprecatedOperations: z.boolean().default(true),
|
|
1455
1570
|
multipleResponses: z.boolean().default(false),
|
|
1571
|
+
generateFullProject: z.boolean().default(false),
|
|
1456
1572
|
devContainer: z.boolean().default(false),
|
|
1457
1573
|
allowMockClient: z.boolean().default(false)
|
|
1458
1574
|
});
|
|
@@ -2002,6 +2118,10 @@ function validateSdkConfigV1(value) {
|
|
|
2002
2118
|
function parseSdkConfigV1(value) {
|
|
2003
2119
|
return sdkConfigV1Schema.parse(value);
|
|
2004
2120
|
}
|
|
2121
|
+
var sdkConfigV1InputJsonSchema = inputJsonSchema(sdkConfigV1Schema);
|
|
2122
|
+
function parseSdkConfigV1ForConsumption(value) {
|
|
2123
|
+
return parseSdkConfigV1(stripUnknownProperties(value, sdkConfigV1InputJsonSchema));
|
|
2124
|
+
}
|
|
2005
2125
|
|
|
2006
2126
|
// src/sdk-config/v1/fern-config-mapper.ts
|
|
2007
2127
|
var generatorLanguages = {
|
|
@@ -2057,7 +2177,14 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2057
2177
|
api.audiences = [...input.group.audiences.audiences];
|
|
2058
2178
|
}
|
|
2059
2179
|
const targets = mapped.map(
|
|
2060
|
-
({
|
|
2180
|
+
({
|
|
2181
|
+
generator,
|
|
2182
|
+
invocation,
|
|
2183
|
+
language,
|
|
2184
|
+
output,
|
|
2185
|
+
package: outputPackage,
|
|
2186
|
+
generation: outputGeneration
|
|
2187
|
+
}, index) => {
|
|
2061
2188
|
const target = {
|
|
2062
2189
|
language,
|
|
2063
2190
|
output,
|
|
@@ -2071,6 +2198,7 @@ function mapFernConfigToSdkConfigV1(input) {
|
|
|
2071
2198
|
}
|
|
2072
2199
|
const targetGeneration = {
|
|
2073
2200
|
...generations.targetOverrides[index],
|
|
2201
|
+
...outputGeneration,
|
|
2074
2202
|
...invocation.targetGeneration
|
|
2075
2203
|
};
|
|
2076
2204
|
if (Object.keys(targetGeneration).length > 0) {
|
|
@@ -2248,6 +2376,9 @@ function mapInvocation(generator, language, activeLanguages, index) {
|
|
|
2248
2376
|
if (generator.keywords?.length) {
|
|
2249
2377
|
generation.reservedKeywords = [...generator.keywords];
|
|
2250
2378
|
}
|
|
2379
|
+
if (generator.generateFullProject !== void 0) {
|
|
2380
|
+
generation.generateFullProject = generator.generateFullProject;
|
|
2381
|
+
}
|
|
2251
2382
|
const settings = isObject(generator.settings) ? generator.settings : void 0;
|
|
2252
2383
|
if (settings) {
|
|
2253
2384
|
const inlinePathParameters = takeBoolean(settings, ["inlinePathParameters"], state, [
|
|
@@ -2390,6 +2521,8 @@ function mapCommonConfig(language, config, state, client, generation, packageCon
|
|
|
2390
2521
|
basePath
|
|
2391
2522
|
);
|
|
2392
2523
|
if (webSockets !== void 0) generation.webSockets = webSockets;
|
|
2524
|
+
const generateFullProject = takeBoolean(config, ["generateFullProject"], state, basePath);
|
|
2525
|
+
if (generateFullProject !== void 0) generation.generateFullProject = generateFullProject;
|
|
2393
2526
|
const inlineTypes = takeBoolean(config, ["enableInlineTypes"], state, basePath);
|
|
2394
2527
|
const omitUndefined = takeBoolean(config, ["omitUndefined"], state, basePath);
|
|
2395
2528
|
const forwardEnums = takeBoolean(config, ["enableForwardCompatibleEnums"], state, basePath);
|
|
@@ -2864,6 +2997,6 @@ function takeToolsets(value, aliases, state, basePath) {
|
|
|
2864
2997
|
return Object.fromEntries(entries.filter((entry) => entry !== void 0));
|
|
2865
2998
|
}
|
|
2866
2999
|
|
|
2867
|
-
export { FernConfigMappingError, SDK_CONFIG_V1_SCHEMA_VERSION, mapFernConfigToSdkConfigV1, parseSdkConfigV1, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, sdkConfigV1GenerationConfigSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, relativePathSchema as sdkConfigV1RelativePathSchema, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, splitSdkConfigV1TargetGeneration, validateSdkConfigV1 };
|
|
3000
|
+
export { FernConfigMappingError, SDK_CONFIG_V1_SCHEMA_VERSION, mapFernConfigToSdkConfigV1, parseSdkConfigV1, parseSdkConfigV1ForConsumption, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigOverrideSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigOverrideSchema, sdkConfigV1GenerationConfigSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, relativePathSchema as sdkConfigV1RelativePathSchema, sdkConfigV1ReplayConfigSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, sdkConfigV1SourceConfigSchema, sdkConfigV1SourceSpecSchema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema, sdkConfigV1WebhookSignatureSchema, splitSdkConfigV1TargetGeneration, validateSdkConfigV1 };
|
|
2868
3001
|
//# sourceMappingURL=index.js.map
|
|
2869
3002
|
//# sourceMappingURL=index.js.map
|