@workos/oagen 0.23.0 → 0.24.1
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/dist/cli/index.mjs +198 -54
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-B7dMUCoJ.mjs → diff-8vcYeHKf.mjs} +134 -55
- package/dist/{diff-B7dMUCoJ.mjs.map → diff-8vcYeHKf.mjs.map} +1 -1
- package/dist/index.d.mts +32 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +66 -1
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +65 -0
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +65 -0
- package/dist/smoke.mjs.map +1 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -175,11 +175,26 @@ interface EmitterContext {
|
|
|
175
175
|
* Scoped-generation signal: the set of POST-MOUNT service names a `--services`
|
|
176
176
|
* run selected. When present and non-empty, emitters must emit ONLY these
|
|
177
177
|
* services' per-service resource/test files, while still emitting models,
|
|
178
|
-
* enums, the root client, and all aggregate/barrel files
|
|
179
|
-
* (so shared files stay byte-identical and a brand-new
|
|
180
|
-
* wired into the client automatically). Absent/empty ⇒
|
|
178
|
+
* enums, the root client, and all aggregate/barrel files for the surface the
|
|
179
|
+
* engine hands them (so shared files stay byte-identical and a brand-new
|
|
180
|
+
* selected service is wired into the client automatically). Absent/empty ⇒
|
|
181
|
+
* full generation.
|
|
182
|
+
*
|
|
183
|
+
* NOTE: the engine narrows the spec it passes to the aggregate generators to
|
|
184
|
+
* `selected ∪ already-on-disk` services (see `presentServiceKeys`), so the
|
|
185
|
+
* "full spec" an emitter sees in a scoped run excludes services the spec just
|
|
186
|
+
* added that this SDK has never generated — they would otherwise be wired into
|
|
187
|
+
* barrels/the client with no implementation behind them (orphaned imports).
|
|
181
188
|
*/
|
|
182
189
|
scopedServices?: Set<string>;
|
|
190
|
+
/**
|
|
191
|
+
* Canonical (casing/separator-insensitive) keys of services the prior manifest
|
|
192
|
+
* recorded as already generated on disk. Populated only in a scoped run, from
|
|
193
|
+
* the output/target `.oagen-manifest.json` operations map. The engine uses it
|
|
194
|
+
* to keep an already-present service in the aggregate surface (byte-identical
|
|
195
|
+
* regen) while dropping a spec-only, never-generated, out-of-scope service.
|
|
196
|
+
*/
|
|
197
|
+
presentServiceKeys?: Set<string>;
|
|
183
198
|
/**
|
|
184
199
|
* Scoped-generation model/enum allow-lists: names of models/enums reachable
|
|
185
200
|
* from the selected services. When `scopedServices` is active,
|
|
@@ -440,6 +455,7 @@ declare function buildEmitterContext(spec: ApiSpec, options: {
|
|
|
440
455
|
target?: string;
|
|
441
456
|
priorTargetManifestPaths?: Set<string>;
|
|
442
457
|
scopedServices?: Set<string>;
|
|
458
|
+
presentServiceKeys?: Set<string>;
|
|
443
459
|
}): EmitterContext;
|
|
444
460
|
/**
|
|
445
461
|
* Collect model and enum names transitively referenced by service operations.
|
|
@@ -455,12 +471,17 @@ declare function collectReferencedNames(services: Service[], models: Model[], op
|
|
|
455
471
|
/**
|
|
456
472
|
* Collect all generated files from an emitter (no headers, no path prefixes).
|
|
457
473
|
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* selected service is wired into the client automatically)
|
|
462
|
-
*
|
|
463
|
-
*
|
|
474
|
+
* A full run emits over the whole spec. A scoped (`--services`) run still emits
|
|
475
|
+
* model placement, dedup, the root client, and aggregate/barrel files
|
|
476
|
+
* byte-identically for every service ALREADY on disk (plus the brand-new
|
|
477
|
+
* selected service, which is wired into the client automatically) — but it
|
|
478
|
+
* narrows that surface to `selected ∪ already-on-disk` services
|
|
479
|
+
* (`aggregateSurfaceServices`). A service the spec just added that is neither
|
|
480
|
+
* selected nor already generated is dropped from the surface entirely, so its
|
|
481
|
+
* models/discriminators are not pulled into reachability and barrels/the client
|
|
482
|
+
* never import a resource this run does not emit. The emitters additionally
|
|
483
|
+
* consult `ctx.scopedServices` to emit only the selected services' per-service
|
|
484
|
+
* resource/test files.
|
|
464
485
|
*/
|
|
465
486
|
declare function generateAllFiles(spec: ApiSpec, emitter: Emitter, ctx: EmitterContext): GeneratedFile[];
|
|
466
487
|
/** Apply file header to generated files, respecting headerPlacement and JSON files. */
|
|
@@ -476,7 +497,8 @@ declare function generateFiles(spec: ApiSpec, emitter: Emitter, options: {
|
|
|
476
497
|
emitterOptions?: Record<string, unknown>;
|
|
477
498
|
target?: string;
|
|
478
499
|
priorTargetManifestPaths?: Set<string>; /** Scoped-generation signal (POST-MOUNT names); set on ctx for emitters to gate per-service emission. */
|
|
479
|
-
scopedServices?: Set<string>;
|
|
500
|
+
scopedServices?: Set<string>; /** Canonical keys of services already on disk (prior manifest); narrows the scoped aggregate surface. */
|
|
501
|
+
presentServiceKeys?: Set<string>;
|
|
480
502
|
}): {
|
|
481
503
|
files: GeneratedFile[];
|
|
482
504
|
ctx: EmitterContext;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ir/operation-hints.ts","../src/errors.ts","../src/engine/types.ts","../src/differ/types.ts","../src/parser/parse.ts","../src/engine/orchestrator.ts","../src/engine/generate-files.ts","../src/engine/writer.ts","../src/engine/integrate.ts","../src/engine/registry.ts","../src/differ/diff.ts","../src/utils/naming.ts","../src/engine/operation-plan.ts","../src/cli/config-loader.ts","../src/snippets/example-builder.ts","../src/snippets/types.ts","../src/snippets/runner.ts","../src/snippets/shared.ts"],"mappings":";;;;UAeiB,aAAA;EAAA;EAEf,IAAA;;EAEA,OAAA;EAFA;EAIA,KAAA,GAAQ,SAAA;EAAR;EAEA,QAAA,GAAW,MAAA;EAAX;EAEA,eAAA;EAAA;;;;AAUF;;EAHE,UAAA;AAAA;AAAA,UAGe,SAAA;EAIf;EAFA,IAAA;EAIW;EAFX,aAAA;EAMA;EAJA,QAAA,GAA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;cACrB,OAAA,UAAiB,IAAA;AAAA;;;UC5Ed,aAAA;EACf,IAAA;EACA,OAAA;EACA,YAAA;EACA,eAAA;EFWA;EETA,eAAA;EFWQ;EETR,iBAAA;AAAA;AAAA,UAGe,cAAA;EACf,SAAA;EACA,eAAA;EACA,IAAA,EAAM,OAAA;EACN,SAAA;EACA,UAAA,GAAa,UAAA;EACb,aAAA,GAAgB,aAAA;EFoBC;EElBjB,kBAAA,GAAqB,iBAAA;EFgBrB;;;;;EEVA,UAAA,GAAa,MAAA;EFsBC;EEpBd,cAAA,GAAiB,MAAA;EF2BF;EEzBf,SAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ir/operation-hints.ts","../src/errors.ts","../src/engine/types.ts","../src/differ/types.ts","../src/parser/parse.ts","../src/engine/orchestrator.ts","../src/engine/generate-files.ts","../src/engine/writer.ts","../src/engine/integrate.ts","../src/engine/registry.ts","../src/differ/diff.ts","../src/utils/naming.ts","../src/engine/operation-plan.ts","../src/cli/config-loader.ts","../src/snippets/example-builder.ts","../src/snippets/types.ts","../src/snippets/runner.ts","../src/snippets/shared.ts"],"mappings":";;;;UAeiB,aAAA;EAAA;EAEf,IAAA;;EAEA,OAAA;EAFA;EAIA,KAAA,GAAQ,SAAA;EAAR;EAEA,QAAA,GAAW,MAAA;EAAX;EAEA,eAAA;EAAA;;;;AAUF;;EAHE,UAAA;AAAA;AAAA,UAGe,SAAA;EAIf;EAFA,IAAA;EAIW;EAFX,aAAA;EAMA;EAJA,QAAA,GAAW,MAAA;EAUG;EARd,eAAA;EAee;EAbf,aAAA;;;;;;EAMA,cAAA;AAAA;AAAA,UAOe,iBAAA;EAEJ;EAAX,SAAA,EAAW,SAAA;EAEF;EAAT,OAAA,EAAS,OAAA;EAIT;EAFA,UAAA;EAIW;EAFX,OAAA;EAIU;EAFV,QAAA,GAAW,eAAA;EAMX;EAJA,QAAA,EAAU,MAAA;EAIA;EAFV,eAAA;EAK8B;EAH9B,UAAA;A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AA,EAAK,cAAA,EACL,QAAA,EAAU,cAAA,GACT,aAAA;;;;;;;iBAqEa,kBAAA,CACd,OAAA,EAAS,eAAA,EACT,GAAA,EAAK,cAAA,EACL,QAAA,EAAU,cAAA,GACT,UAAA;AAAA,iBAuBa,cAAA,CAAe,QAAA,EAAU,iBAAA,GAAoB,GAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as walkTypeRef, C as assertNever, D as collectModelRefs, E as collectFieldDependencies, O as collectRequestBodyModels, S as SpecParseError, T as collectEnumRefs, _ as ConfigVersionMismatchError, a as singularize, b as OagenError, c as stripListItemMarkers, d as toPascalCase, f as toSnakeCase, g as ConfigLoadError, h as ConfigError, k as mapTypeRef, l as toCamelCase, m as CommandError, n as ACRONYM_SET, o as splitWords, p as toUpperSnakeCase, r as cleanSchemaName, s as stripBackendPrefixes, u as toKebabCase, v as ExtractorError, w as assignModelsToServices, x as RegistryError, y as InternalError } from "./tree-sitter-DcUvm0KA.mjs";
|
|
2
|
-
import { c as treeShakeFiles, d as collectReferencedNames, f as generateAllFiles, h as resolveOperations, i as generate, l as applyFileHeaders, m as deriveMethodName, n as getEmitter, o as integrateGeneratedFiles, p as generateFiles, r as registerEmitter, s as mapFilesForTargetIntegration, t as diffSpecs, u as buildEmitterContext } from "./diff-
|
|
2
|
+
import { c as treeShakeFiles, d as collectReferencedNames, f as generateAllFiles, h as resolveOperations, i as generate, l as applyFileHeaders, m as deriveMethodName, n as getEmitter, o as integrateGeneratedFiles, p as generateFiles, r as registerEmitter, s as mapFilesForTargetIntegration, t as diffSpecs, u as buildEmitterContext } from "./diff-8vcYeHKf.mjs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -2105,6 +2105,10 @@ function extractRequestBody(body, op, inlineModels) {
|
|
|
2105
2105
|
return {};
|
|
2106
2106
|
}
|
|
2107
2107
|
const contextName = cleanSchemaName(op?.operationId ? toPascalCase(normalizeOperationIdForNaming(op.operationId)) + "Request" : "RequestBody");
|
|
2108
|
+
if (schema.oneOf && schema.discriminator) {
|
|
2109
|
+
const merged = flattenDiscriminatedUnionBody(schema);
|
|
2110
|
+
if (merged) schema = merged;
|
|
2111
|
+
}
|
|
2108
2112
|
if (schema.properties && (schema.type === "object" || !schema.type)) {
|
|
2109
2113
|
const requiredSet = new Set(schema.required ?? []);
|
|
2110
2114
|
const fields = [];
|
|
@@ -2170,6 +2174,67 @@ function extractRequestBody(body, op, inlineModels) {
|
|
|
2170
2174
|
encoding
|
|
2171
2175
|
};
|
|
2172
2176
|
}
|
|
2177
|
+
/**
|
|
2178
|
+
* Fold a discriminated-union request body into the equivalent single object so
|
|
2179
|
+
* its fields can be spread into method arguments instead of forcing callers to
|
|
2180
|
+
* construct an opaque union.
|
|
2181
|
+
*
|
|
2182
|
+
* The result is the union of every variant's properties: the discriminator is
|
|
2183
|
+
* collapsed to an enum of the pinned const values, and any field that isn't
|
|
2184
|
+
* present-and-required in *every* variant becomes optional (it varies by
|
|
2185
|
+
* branch, so it can't be unconditionally required). The discriminator itself is
|
|
2186
|
+
* always required. This mirrors what a spec author would write by hand to model
|
|
2187
|
+
* the same shape as a flat object.
|
|
2188
|
+
*
|
|
2189
|
+
* Returns null — leaving the union intact — unless the body is a clean
|
|
2190
|
+
* inline-object discriminated union: a variant that is a `$ref`, a non-object,
|
|
2191
|
+
* or that doesn't pin the discriminator to a string const can't be safely
|
|
2192
|
+
* merged. Gating on an *explicit* `discriminator` keeps undiscriminated `oneOf`
|
|
2193
|
+
* bodies untouched.
|
|
2194
|
+
*/
|
|
2195
|
+
function flattenDiscriminatedUnionBody(schema) {
|
|
2196
|
+
const discProp = schema.discriminator?.propertyName;
|
|
2197
|
+
if (!discProp || !Array.isArray(schema.oneOf) || schema.oneOf.length === 0) return null;
|
|
2198
|
+
const variants = schema.oneOf;
|
|
2199
|
+
const discValues = [];
|
|
2200
|
+
let discPropSchema;
|
|
2201
|
+
for (const variant of variants) {
|
|
2202
|
+
if (variant.$ref || !variant.properties || !(variant.type === "object" || variant.type === void 0)) return null;
|
|
2203
|
+
const dp = variant.properties[discProp];
|
|
2204
|
+
const constVal = typeof dp?.const === "string" ? dp.const : Array.isArray(dp?.enum) && dp.enum.length === 1 && typeof dp.enum[0] === "string" ? dp.enum[0] : void 0;
|
|
2205
|
+
if (constVal === void 0) return null;
|
|
2206
|
+
if (!discValues.includes(constVal)) discValues.push(constVal);
|
|
2207
|
+
if (!discPropSchema) discPropSchema = dp;
|
|
2208
|
+
}
|
|
2209
|
+
const variantCount = variants.length;
|
|
2210
|
+
const mergedProps = {};
|
|
2211
|
+
const requiredCounts = {};
|
|
2212
|
+
const order = [discProp];
|
|
2213
|
+
for (const variant of variants) {
|
|
2214
|
+
const required = new Set(variant.required ?? []);
|
|
2215
|
+
for (const [name, propSchema] of Object.entries(variant.properties)) {
|
|
2216
|
+
if (name === discProp || !propSchema) continue;
|
|
2217
|
+
if (!(name in mergedProps)) {
|
|
2218
|
+
mergedProps[name] = propSchema;
|
|
2219
|
+
order.push(name);
|
|
2220
|
+
}
|
|
2221
|
+
if (required.has(name)) requiredCounts[name] = (requiredCounts[name] ?? 0) + 1;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
mergedProps[discProp] = {
|
|
2225
|
+
type: "string",
|
|
2226
|
+
enum: discValues,
|
|
2227
|
+
...discPropSchema?.description ? { description: discPropSchema.description } : {}
|
|
2228
|
+
};
|
|
2229
|
+
const properties = {};
|
|
2230
|
+
for (const name of order) properties[name] = mergedProps[name];
|
|
2231
|
+
return {
|
|
2232
|
+
type: "object",
|
|
2233
|
+
properties,
|
|
2234
|
+
required: order.filter((name) => name === discProp || requiredCounts[name] === variantCount),
|
|
2235
|
+
...schema.description ? { description: schema.description } : {}
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2173
2238
|
/** Derive a unique variant name for a oneOf inline model. */
|
|
2174
2239
|
function deriveOneOfVariantName(variant, baseName, existingModels) {
|
|
2175
2240
|
if (variant.properties) {
|