@workos/oagen 0.3.0 → 0.4.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 +72 -0
- package/dist/cli/index.mjs +844 -56
- package/dist/cli/index.mjs.map +1 -1
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.mjs +9 -4
- package/dist/compat/index.mjs.map +1 -1
- package/dist/{diff-Cn6S74vV.mjs → diff-DcY93sii.mjs} +433 -14
- package/dist/diff-DcY93sii.mjs.map +1 -0
- package/dist/{differ-B6472Yef.mjs → differ-CG5ZErKl.mjs} +2 -2
- package/dist/{differ-B6472Yef.mjs.map → differ-CG5ZErKl.mjs.map} +1 -1
- package/dist/index.d.mts +107 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +337 -29
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +314 -32
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.d.mts +138 -0
- package/dist/smoke.d.mts.map +1 -1
- package/dist/smoke.mjs +314 -32
- package/dist/smoke.mjs.map +1 -1
- package/dist/{tree-sitter-DFRXfWg9.mjs → tree-sitter-C53w_0WE.mjs} +5 -7
- package/dist/tree-sitter-C53w_0WE.mjs.map +1 -0
- package/dist/{types-O25qZxMl.d.mts → types-D1tMqLVB.d.mts} +165 -2
- package/dist/types-D1tMqLVB.d.mts.map +1 -0
- package/dist/verify/index.d.mts +1 -1
- package/dist/verify/index.mjs +4 -4
- package/dist/verify/index.mjs.map +1 -1
- package/docs/architecture/ir-types.md +73 -1
- package/docs/cli.md +29 -8
- package/package.json +4 -4
- package/skills/review-operations/SKILL.md +83 -0
- package/dist/diff-Cn6S74vV.mjs.map +0 -1
- package/dist/tree-sitter-DFRXfWg9.mjs.map +0 -1
- package/dist/types-O25qZxMl.d.mts.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../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"],"mappings":";;;;;;
|
|
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"],"mappings":";;;;UAeiB,aAAA;EAAA;EAEf,IAAA;;EAEA,OAAA;EAFA;EAIA,KAAA,GAAQ,SAAA;EAAR;EAEA,QAAA,GAAW,MAAA;EAAX;EAEA,eAAA;AAAA;AAAA,UAGe,SAAA;EAHA;EAKf,IAAA;EAFwB;EAIxB,aAAA;EAEiB;EAAjB,QAAA,GAAW,MAAA;EAFX;EAIA,eAAA;EAFW;EAIX,aAAA;AAAA;AAAA,UAOe,iBAAA;EAPF;EASb,SAAA,EAAW,SAAA;EAFqB;EAIhC,OAAA,EAAS,OAAA;EAFE;EAIX,UAAA;EAIW;EAFX,OAAA;EAE0B;EAA1B,QAAA,GAAW,eAAA;AAAA;AAAA,UAGI,eAAA;EATN;EAWT,IAAA;EAPA;EASA,aAAA;EAPW;EASX,QAAA,EAAU,MAAA;EATgB;EAW1B,eAAA;EAR8B;EAU9B,aAAA;EAJgB;EAMhB,cAAA;EARA;EAUA,iBAAA;AAAA;;;;;;;AA4EF;;;;;iBAAgB,gBAAA,CAAiB,EAAA,EAAI,SAAA,EAAW,QAAA,EAAU,OAAA;;;;;AA6E1D;;;;iBAAgB,iBAAA,CACd,IAAA,EAAM,OAAA,EACN,KAAA,GAAQ,M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AMZ,WAAA,CAAY,CAAA;AAAA,iBAMZ,gBAAA,CAAiB,CAAA;AAAA,iBAiBjB,oBAAA,CAAqB,IAAA;AAAA,iBAqErB,eAAA,CAAgB,IAAA;;;UCzLf,aAAA;EACf,SAAA,EAAW,SAAA;EACX,QAAA;EACA,OAAA;EACA,gBAAA;EACA,mBAAA;EACA,WAAA;EACA,iBAAA;EZWA;;EYRA,sBAAA;EACA,eAAA;EACA,cAAA;EACA,OAAA;AAAA;AAAA,iBAGc,aAAA,CAAc,EAAA,EAAI,SAAA,GAAY,aAAA;;;UCX7B,WAAA;EACf,QAAA,GAAW,OAAA;EACX,UAAA,GAAa,SAAA;EbaI;EaXjB,cAAA;EbOA;EaLA,YAAA,GAAe,MAAA;EbOP;;;;;;EaAR,oBAAA,IAAwB,EAAA;EbOA;;;;;;EaAxB,mBAAA,IAAuB,IAAA;EbQvB;;EaLA,MAAA;EbOa;AAOf;;;;EaRE,cAAA,GAAiB,MAAA,SAAe,aAAA;EbkBrB;;;;;;EaXX,UAAA,GAAa,MAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,155 @@
|
|
|
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, 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-
|
|
2
|
-
import { a as integrateGeneratedFiles, c as applyFileHeaders, d as generateAllFiles, f as generateFiles, i as generate, l as buildEmitterContext, n as getEmitter, o as mapFilesForTargetIntegration, r as registerEmitter, s as treeShakeFiles, t as diffSpecs, u as collectReferencedNames } from "./diff-
|
|
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, 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-C53w_0WE.mjs";
|
|
2
|
+
import { a as integrateGeneratedFiles, c as applyFileHeaders, d as generateAllFiles, f as generateFiles, i as generate, l as buildEmitterContext, m as resolveOperations, n as getEmitter, o as mapFilesForTargetIntegration, p as deriveMethodName, r as registerEmitter, s as treeShakeFiles, t as diffSpecs, u as collectReferencedNames } from "./diff-DcY93sii.mjs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { BaseResolver, bundleDocument, createConfig, makeDocumentFromString } from "@redocly/openapi-core";
|
|
6
|
+
import { BaseResolver, Oas3_1Types, bundleDocument, createConfig, makeDocumentFromString } from "@redocly/openapi-core";
|
|
7
|
+
//#region src/ir/sdk-behavior.ts
|
|
8
|
+
/**
|
|
9
|
+
* Canonical SDK behavior defaults. These match the PHP emitter's current
|
|
10
|
+
* implementation (the most complete). Per-language overrides can be applied
|
|
11
|
+
* via `mergeSdkBehavior()` in each SDK's `oagen.config.ts`.
|
|
12
|
+
*
|
|
13
|
+
* - Retry: exponential backoff with jitter, retries on 429/5xx
|
|
14
|
+
* - Errors: standard HTTP status → exception kind mapping
|
|
15
|
+
* - Telemetry: enabled by default, tracks request ID + latency
|
|
16
|
+
* - Pagination: no inter-page delay (Node overrides to 350ms)
|
|
17
|
+
* - Idempotency: auto-generate UUID v4 for retryable POSTs
|
|
18
|
+
* - Logging: all lifecycle events enabled
|
|
19
|
+
* - User-Agent: SDK identifier + runtime version + app info + AI agent detection
|
|
20
|
+
* - Request guards: detect misplaced RequestOptions keys in params
|
|
21
|
+
* - Timeout: 60s default (Python overrides to 30s)
|
|
22
|
+
*/
|
|
23
|
+
function defaultSdkBehavior() {
|
|
24
|
+
return {
|
|
25
|
+
retry: {
|
|
26
|
+
retryableStatusCodes: [
|
|
27
|
+
429,
|
|
28
|
+
500,
|
|
29
|
+
502,
|
|
30
|
+
503,
|
|
31
|
+
504
|
|
32
|
+
],
|
|
33
|
+
maxRetries: 3,
|
|
34
|
+
retryOnConnectionError: true,
|
|
35
|
+
retryOnTimeout: true,
|
|
36
|
+
backoff: {
|
|
37
|
+
initialDelay: 1,
|
|
38
|
+
multiplier: 2,
|
|
39
|
+
maxDelay: 30,
|
|
40
|
+
jitterFactor: .5
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
errors: {
|
|
44
|
+
statusCodeMap: {
|
|
45
|
+
400: "BadRequest",
|
|
46
|
+
401: "Authentication",
|
|
47
|
+
403: "Authorization",
|
|
48
|
+
404: "NotFound",
|
|
49
|
+
409: "Conflict",
|
|
50
|
+
422: "UnprocessableEntity",
|
|
51
|
+
429: "RateLimitExceeded"
|
|
52
|
+
},
|
|
53
|
+
serverErrorKind: "Server",
|
|
54
|
+
clientErrorKind: "Api",
|
|
55
|
+
errorDocUrlTemplate: "https://workos.com/docs/errors/{code}"
|
|
56
|
+
},
|
|
57
|
+
telemetry: {
|
|
58
|
+
enabledByDefault: true,
|
|
59
|
+
headerName: "X-WorkOS-Client-Telemetry",
|
|
60
|
+
requestIdHeader: "X-Request-ID"
|
|
61
|
+
},
|
|
62
|
+
pagination: { autoPageDelayMs: 0 },
|
|
63
|
+
idempotency: {
|
|
64
|
+
headerName: "Idempotency-Key",
|
|
65
|
+
autoGenerateForPost: true
|
|
66
|
+
},
|
|
67
|
+
logging: {
|
|
68
|
+
enabled: true,
|
|
69
|
+
events: [
|
|
70
|
+
"request.start",
|
|
71
|
+
"request.success",
|
|
72
|
+
"request.retry",
|
|
73
|
+
"request.rate_limited",
|
|
74
|
+
"request.error",
|
|
75
|
+
"request.connection_error"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
userAgent: {
|
|
79
|
+
sdkIdentifierTemplate: "{name} {lang}/{version}",
|
|
80
|
+
includeRuntimeVersion: true,
|
|
81
|
+
allowAppInfo: true,
|
|
82
|
+
aiAgentEnvVars: [
|
|
83
|
+
{
|
|
84
|
+
envVar: "CLAUDE_CODE",
|
|
85
|
+
agentName: "ClaudeCode"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
envVar: "CURSOR_AGENT",
|
|
89
|
+
agentName: "Cursor"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
envVar: "CLINE_ACTIVE",
|
|
93
|
+
agentName: "Cline"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
envVar: "WINDSURF_ACTIVE",
|
|
97
|
+
agentName: "Windsurf"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
envVar: "COPILOT_AGENT",
|
|
101
|
+
agentName: "Copilot"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
requestGuard: { optionKeys: [
|
|
106
|
+
"api_key",
|
|
107
|
+
"apiKey",
|
|
108
|
+
"idempotency_key",
|
|
109
|
+
"idempotencyKey",
|
|
110
|
+
"extra_headers",
|
|
111
|
+
"extraHeaders",
|
|
112
|
+
"max_retries",
|
|
113
|
+
"maxRetries",
|
|
114
|
+
"base_url",
|
|
115
|
+
"baseUrl"
|
|
116
|
+
] },
|
|
117
|
+
timeout: { defaultTimeoutSeconds: 60 }
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Deep-merge partial overrides into the canonical defaults.
|
|
122
|
+
* Arrays replace entirely (so `retryableStatusCodes: [429]` replaces the full list,
|
|
123
|
+
* rather than appending). Object properties are merged recursively.
|
|
124
|
+
*/
|
|
125
|
+
function mergeSdkBehavior(overrides) {
|
|
126
|
+
return deepMerge(defaultSdkBehavior(), overrides);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Self-contained deep merge (no external imports — ir/ is layer 0).
|
|
130
|
+
* Arrays and primitives from `source` replace those in `target`.
|
|
131
|
+
* Objects are merged recursively.
|
|
132
|
+
*/
|
|
133
|
+
function deepMerge(target, source) {
|
|
134
|
+
const result = { ...target };
|
|
135
|
+
for (const key of Object.keys(source)) {
|
|
136
|
+
const sourceVal = source[key];
|
|
137
|
+
const targetVal = target[key];
|
|
138
|
+
if (sourceVal === void 0) continue;
|
|
139
|
+
if (sourceVal !== null && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal !== null && typeof targetVal === "object" && !Array.isArray(targetVal)) result[key] = deepMerge(targetVal, sourceVal);
|
|
140
|
+
else result[key] = sourceVal;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
7
145
|
//#region src/parser/refs.ts
|
|
8
146
|
async function loadAndBundleSpec(specPath) {
|
|
9
147
|
const absolutePath = resolve(specPath);
|
|
10
|
-
const document = makeDocumentFromString(await readFile(absolutePath, "utf-8"), pathToFileURL(absolutePath).href);
|
|
11
|
-
const config = await createConfig({});
|
|
12
|
-
const resolver = new BaseResolver();
|
|
13
148
|
const result = await bundleDocument({
|
|
14
|
-
document,
|
|
15
|
-
config:
|
|
16
|
-
|
|
149
|
+
document: makeDocumentFromString(await readFile(absolutePath, "utf-8"), pathToFileURL(absolutePath).href),
|
|
150
|
+
config: await createConfig({}),
|
|
151
|
+
types: Oas3_1Types,
|
|
152
|
+
externalRefResolver: new BaseResolver(),
|
|
17
153
|
dereference: false
|
|
18
154
|
});
|
|
19
155
|
if (result.problems.some((p) => p.severity === "error")) throw new SpecParseError(`Failed to parse spec: ${result.problems.filter((p) => p.severity === "error").map((p) => p.message).join("\n")}`, `Check the OpenAPI spec at "${absolutePath}" for syntax errors. Run a linter such as \`npx @redocly/cli lint ${specPath}\` to identify issues.`);
|
|
@@ -98,15 +234,39 @@ function buildInlineModel(name, schema) {
|
|
|
98
234
|
}
|
|
99
235
|
//#endregion
|
|
100
236
|
//#region src/parser/schemas.ts
|
|
101
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Module-level transform set during extractSchemas(). Used by schemaToTypeRef()
|
|
239
|
+
* to apply the same name transform to $ref model/enum references.
|
|
240
|
+
*/
|
|
241
|
+
let activeSchemaNameTransform = null;
|
|
242
|
+
/** Apply cleanSchemaName + the active transform (if any) to a raw schema name. */
|
|
243
|
+
function resolveSchemaName(rawName) {
|
|
244
|
+
let name = cleanSchemaName(toPascalCase(rawName));
|
|
245
|
+
if (activeSchemaNameTransform) name = activeSchemaNameTransform(name);
|
|
246
|
+
return name;
|
|
247
|
+
}
|
|
248
|
+
function extractSchemas(schemas, options) {
|
|
102
249
|
const enums = [];
|
|
103
250
|
if (!schemas) return {
|
|
104
251
|
models: [],
|
|
105
252
|
enums
|
|
106
253
|
};
|
|
254
|
+
if (options?.schemaNameTransform) {
|
|
255
|
+
const transform = options.schemaNameTransform;
|
|
256
|
+
const cleanedNames = Object.keys(schemas).map((n) => cleanSchemaName(toPascalCase(n)));
|
|
257
|
+
const transformedToOriginals = /* @__PURE__ */ new Map();
|
|
258
|
+
for (const cleaned of cleanedNames) {
|
|
259
|
+
const transformed = transform(cleaned);
|
|
260
|
+
if (!transformedToOriginals.has(transformed)) transformedToOriginals.set(transformed, []);
|
|
261
|
+
transformedToOriginals.get(transformed).push(cleaned);
|
|
262
|
+
}
|
|
263
|
+
const unsafeToTransform = /* @__PURE__ */ new Set();
|
|
264
|
+
for (const [, originals] of transformedToOriginals) if (originals.length > 1) for (const n of originals) unsafeToTransform.add(n);
|
|
265
|
+
activeSchemaNameTransform = (name) => unsafeToTransform.has(name) ? name : transform(name);
|
|
266
|
+
} else activeSchemaNameTransform = null;
|
|
107
267
|
const modelsByCleanName = /* @__PURE__ */ new Map();
|
|
108
268
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
109
|
-
const pascalName =
|
|
269
|
+
const pascalName = resolveSchemaName(name);
|
|
110
270
|
if (schema.enum) enums.push(extractEnum(pascalName, schema));
|
|
111
271
|
else {
|
|
112
272
|
const model = extractModel(pascalName, schema, schemas);
|
|
@@ -114,6 +274,12 @@ function extractSchemas(schemas) {
|
|
|
114
274
|
if (existing) {
|
|
115
275
|
if (model.fields.length > existing.fields.length) modelsByCleanName.set(pascalName, model);
|
|
116
276
|
} else modelsByCleanName.set(pascalName, model);
|
|
277
|
+
for (const inlineModel of extractDiscriminatedAllOfVariantModels(schema, pascalName)) {
|
|
278
|
+
const existingInline = modelsByCleanName.get(inlineModel.name);
|
|
279
|
+
if (existingInline) {
|
|
280
|
+
if (inlineModel.fields.length > existingInline.fields.length) modelsByCleanName.set(inlineModel.name, inlineModel);
|
|
281
|
+
} else modelsByCleanName.set(inlineModel.name, inlineModel);
|
|
282
|
+
}
|
|
117
283
|
}
|
|
118
284
|
}
|
|
119
285
|
const models = [...modelsByCleanName.values()];
|
|
@@ -129,6 +295,10 @@ function extractSchemas(schemas) {
|
|
|
129
295
|
enums
|
|
130
296
|
};
|
|
131
297
|
}
|
|
298
|
+
/** Clear the module-level schemaNameTransform. Called by parseSpec() after all extraction phases. */
|
|
299
|
+
function clearSchemaNameTransform() {
|
|
300
|
+
activeSchemaNameTransform = null;
|
|
301
|
+
}
|
|
132
302
|
/**
|
|
133
303
|
* Walk a single TypeRef and extract inline enum refs as top-level enum definitions.
|
|
134
304
|
* Shared by both schemas.ts (field-level) and parse.ts (model-level) collection passes.
|
|
@@ -165,7 +335,7 @@ function collectInlineEnums(fields, enums) {
|
|
|
165
335
|
function collectNestedInlineModels(ref, fieldName, parentModelName, schemas, models, modelNames, queue) {
|
|
166
336
|
walkTypeRef(ref, { model: (modelRef) => {
|
|
167
337
|
if (modelNames.has(modelRef.name)) return;
|
|
168
|
-
if (Object.keys(schemas).some((k) =>
|
|
338
|
+
if (Object.keys(schemas).some((k) => resolveSchemaName(k) === modelRef.name)) return;
|
|
169
339
|
const parentSchema = findSchemaByName(parentModelName, schemas);
|
|
170
340
|
if (!parentSchema) return;
|
|
171
341
|
const fieldSchema = findNestedFieldSchema(fieldName, parentSchema, schemas);
|
|
@@ -180,7 +350,7 @@ function collectNestedInlineModels(ref, fieldName, parentModelName, schemas, mod
|
|
|
180
350
|
}
|
|
181
351
|
/** Find a component schema by PascalCase name. */
|
|
182
352
|
function findSchemaByName(pascalName, schemas) {
|
|
183
|
-
for (const [k, v] of Object.entries(schemas)) if (
|
|
353
|
+
for (const [k, v] of Object.entries(schemas)) if (resolveSchemaName(k) === pascalName) return v;
|
|
184
354
|
return null;
|
|
185
355
|
}
|
|
186
356
|
/** Walk into a schema to find a field's sub-schema, resolving allOf. */
|
|
@@ -338,13 +508,88 @@ function extractAllOfModel(name, schema, schemas) {
|
|
|
338
508
|
fields
|
|
339
509
|
};
|
|
340
510
|
}
|
|
511
|
+
function extractDiscriminatedAllOfVariantModels(schema, fallbackName) {
|
|
512
|
+
const models = [];
|
|
513
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
514
|
+
for (const subSchema of schema.allOf ?? []) for (const variant of subSchema.oneOf ?? []) {
|
|
515
|
+
if (!variant.properties || variant.type !== void 0 && variant.type !== "object") continue;
|
|
516
|
+
const variantName = deriveDiscriminatedVariantName(variant, fallbackName);
|
|
517
|
+
for (const model of extractInlineModelDeep(variantName, variant)) {
|
|
518
|
+
if (seenNames.has(model.name)) continue;
|
|
519
|
+
seenNames.add(model.name);
|
|
520
|
+
models.push(model);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return models;
|
|
524
|
+
}
|
|
525
|
+
function deriveDiscriminatedVariantName(schema, fallbackName) {
|
|
526
|
+
if (!schema.properties) return fallbackName;
|
|
527
|
+
for (const name of [
|
|
528
|
+
"event",
|
|
529
|
+
"type",
|
|
530
|
+
"object"
|
|
531
|
+
]) {
|
|
532
|
+
const field = schema.properties[name];
|
|
533
|
+
if (!field) continue;
|
|
534
|
+
if (typeof field.const === "string") return toPascalCase(field.const);
|
|
535
|
+
if (field.enum && field.enum.length === 1 && typeof field.enum[0] === "string") return toPascalCase(field.enum[0]);
|
|
536
|
+
}
|
|
537
|
+
for (const field of Object.values(schema.properties)) {
|
|
538
|
+
if (!field) continue;
|
|
539
|
+
if (typeof field.const === "string") return toPascalCase(field.const);
|
|
540
|
+
if (field.enum && field.enum.length === 1 && typeof field.enum[0] === "string") return toPascalCase(field.enum[0]);
|
|
541
|
+
}
|
|
542
|
+
return fallbackName;
|
|
543
|
+
}
|
|
544
|
+
function extractInlineModelDeep(name, schema) {
|
|
545
|
+
const requiredSet = new Set(schema.required ?? []);
|
|
546
|
+
const fields = [];
|
|
547
|
+
const properties = schema.properties ?? {};
|
|
548
|
+
const nestedModels = [];
|
|
549
|
+
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
550
|
+
if (!fieldSchema) continue;
|
|
551
|
+
fields.push(buildFieldFromSchema(fieldName, fieldSchema, name, requiredSet));
|
|
552
|
+
if (fieldSchema.type === "object" && fieldSchema.properties) nestedModels.push(...extractInlineModelDeep(qualifyNestedInlineName(name, fieldName), fieldSchema));
|
|
553
|
+
if (fieldSchema.type === "array" && fieldSchema.items?.properties) nestedModels.push(...extractInlineModelDeep(qualifyNestedInlineName(name, fieldName), fieldSchema.items));
|
|
554
|
+
if (fieldSchema.allOf) {
|
|
555
|
+
const mergedProperties = {};
|
|
556
|
+
const mergedRequired = [];
|
|
557
|
+
for (const sub of fieldSchema.allOf) {
|
|
558
|
+
if (sub.properties) Object.assign(mergedProperties, sub.properties);
|
|
559
|
+
if (sub.required) mergedRequired.push(...sub.required);
|
|
560
|
+
}
|
|
561
|
+
if (Object.keys(mergedProperties).length > 0) nestedModels.push(...extractInlineModelDeep(qualifyNestedInlineName(name, fieldName), {
|
|
562
|
+
type: "object",
|
|
563
|
+
properties: mergedProperties,
|
|
564
|
+
required: mergedRequired
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
if (fieldSchema.oneOf) {
|
|
568
|
+
const objectVariant = fieldSchema.oneOf.find((v) => v.properties && (v.type === "object" || !v.type));
|
|
569
|
+
if (objectVariant) nestedModels.push(...extractInlineModelDeep(qualifyNestedInlineName(name, fieldName), objectVariant));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return [{
|
|
573
|
+
name,
|
|
574
|
+
description: schema.description,
|
|
575
|
+
fields
|
|
576
|
+
}, ...nestedModels];
|
|
577
|
+
}
|
|
578
|
+
function qualifyNestedInlineName(parentName, fieldName) {
|
|
579
|
+
const pascalField = toPascalCase(fieldName);
|
|
580
|
+
if (pascalField.startsWith(parentName)) return pascalField;
|
|
581
|
+
const qualified = `${stripListItemMarkers(parentName)}${pascalField}`;
|
|
582
|
+
const match = qualified.match(/^(.+?)([A-Z][a-z]+s?)$/);
|
|
583
|
+
if (match && match[2]) return match[1] + singularize(match[2]);
|
|
584
|
+
return qualified;
|
|
585
|
+
}
|
|
341
586
|
function schemaToTypeRef(schema, contextName, parentModelName) {
|
|
342
587
|
if (schema.$ref) {
|
|
343
588
|
const segments = schema.$ref.split("/");
|
|
344
589
|
const rawName = segments[segments.length - 1];
|
|
345
590
|
return {
|
|
346
591
|
kind: "model",
|
|
347
|
-
name:
|
|
592
|
+
name: resolveSchemaName(rawName)
|
|
348
593
|
};
|
|
349
594
|
}
|
|
350
595
|
if (Array.isArray(schema.type)) {
|
|
@@ -608,6 +853,7 @@ const KNOWN_DATA_PATHS = new Set([
|
|
|
608
853
|
"edges"
|
|
609
854
|
]);
|
|
610
855
|
const PAGINATION_METADATA_PATTERNS = [
|
|
856
|
+
"meta",
|
|
611
857
|
"metadata",
|
|
612
858
|
"pagination",
|
|
613
859
|
"cursor",
|
|
@@ -639,11 +885,12 @@ function detectListEnvelope(schema) {
|
|
|
639
885
|
}
|
|
640
886
|
if (arrayProps.length === 1 && nonArrayKeys.length >= 1) {
|
|
641
887
|
const arrayPropName = arrayProps[0];
|
|
642
|
-
|
|
888
|
+
const hasPaginationCompanion = nonArrayKeys.some((key) => PAGINATION_METADATA_PATTERNS.some((pattern) => key.toLowerCase().includes(pattern)));
|
|
889
|
+
if (KNOWN_DATA_PATHS.has(arrayPropName) && hasPaginationCompanion) return {
|
|
643
890
|
isEnvelope: true,
|
|
644
891
|
dataPath: arrayPropName
|
|
645
892
|
};
|
|
646
|
-
if (
|
|
893
|
+
if (hasPaginationCompanion) return {
|
|
647
894
|
isEnvelope: true,
|
|
648
895
|
dataPath: arrayPropName
|
|
649
896
|
};
|
|
@@ -947,13 +1194,33 @@ function extractOperations(paths, operationIdTransform) {
|
|
|
947
1194
|
const op = pathItem[method];
|
|
948
1195
|
if (!op) continue;
|
|
949
1196
|
const serviceName = inferServiceName(path, op.tags?.[0]);
|
|
950
|
-
const { operation, inlineModels: opModels } = buildOperation(method, path, op, pathLevelParams, operationIdTransform);
|
|
1197
|
+
const { operation, inlineModels: opModels } = buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName);
|
|
951
1198
|
inlineModels.push(...opModels);
|
|
952
1199
|
const ops = serviceMap.get(serviceName) ?? [];
|
|
953
1200
|
ops.push(operation);
|
|
954
1201
|
serviceMap.set(serviceName, ops);
|
|
955
1202
|
}
|
|
956
1203
|
}
|
|
1204
|
+
for (const [serviceName, operations] of serviceMap) {
|
|
1205
|
+
const pathGroups = /* @__PURE__ */ new Map();
|
|
1206
|
+
for (const op of operations) {
|
|
1207
|
+
const firstSeg = op.path.split("/").filter(Boolean)[0] ?? "";
|
|
1208
|
+
const groupKey = firstSeg.startsWith("{") ? serviceName : toPascalCase(firstSeg);
|
|
1209
|
+
const group = pathGroups.get(groupKey) ?? [];
|
|
1210
|
+
group.push(op);
|
|
1211
|
+
pathGroups.set(groupKey, group);
|
|
1212
|
+
}
|
|
1213
|
+
if (pathGroups.size > 1) {
|
|
1214
|
+
if ([...pathGroups.keys()].some((k) => k !== serviceName)) {
|
|
1215
|
+
serviceMap.delete(serviceName);
|
|
1216
|
+
for (const [groupName, groupOps] of pathGroups) {
|
|
1217
|
+
const existing = serviceMap.get(groupName) ?? [];
|
|
1218
|
+
existing.push(...groupOps);
|
|
1219
|
+
serviceMap.set(groupName, existing);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
957
1224
|
for (const [, operations] of serviceMap) disambiguateOperationNames(operations);
|
|
958
1225
|
return {
|
|
959
1226
|
services: Array.from(serviceMap.entries()).map(([name, operations]) => ({
|
|
@@ -1069,13 +1336,14 @@ function inferDeeperContext(path) {
|
|
|
1069
1336
|
if (nonParams.length >= 3) return toPascalCase(nonParams.slice(1, -1).join("_"));
|
|
1070
1337
|
return null;
|
|
1071
1338
|
}
|
|
1072
|
-
function buildOperation(method, path, op, pathLevelParams, operationIdTransform) {
|
|
1339
|
+
function buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName) {
|
|
1073
1340
|
const allParams = [...pathLevelParams, ...op.parameters ?? []];
|
|
1074
1341
|
const hasIdempotencyHeader = allParams.some((p) => p.in === "header" && p.name.toLowerCase() === "idempotency-key");
|
|
1075
|
-
const
|
|
1076
|
-
const
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1342
|
+
const opContext = serviceName;
|
|
1343
|
+
const pathParams = extractParams(allParams, "path", opContext);
|
|
1344
|
+
const queryParams = extractParams(allParams, "query", opContext);
|
|
1345
|
+
const headerParams = extractParams(allParams, "header", opContext).filter((p) => p.name.toLowerCase() !== "idempotency-key");
|
|
1346
|
+
const cookieParams = extractParams(allParams, "cookie", opContext);
|
|
1079
1347
|
const reqBodyModels = [];
|
|
1080
1348
|
const { body: requestBody, encoding: requestBodyEncoding } = extractRequestBody(op.requestBody, op, reqBodyModels);
|
|
1081
1349
|
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method);
|
|
@@ -1092,6 +1360,7 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform)
|
|
|
1092
1360
|
itemType
|
|
1093
1361
|
};
|
|
1094
1362
|
} else if (paginationFromParams) pagination = paginationFromParams;
|
|
1363
|
+
const security = extractOperationSecurity(op.security);
|
|
1095
1364
|
return {
|
|
1096
1365
|
operation: {
|
|
1097
1366
|
name: inferOperationName(method, path, op.operationId, operationIdTransform),
|
|
@@ -1110,19 +1379,35 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform)
|
|
|
1110
1379
|
pagination,
|
|
1111
1380
|
injectIdempotencyKey: hasIdempotencyHeader,
|
|
1112
1381
|
deprecated: op.deprecated || void 0,
|
|
1113
|
-
async: op["x-oagen-async"]
|
|
1382
|
+
async: op["x-oagen-async"],
|
|
1383
|
+
security
|
|
1114
1384
|
},
|
|
1115
1385
|
inlineModels
|
|
1116
1386
|
};
|
|
1117
1387
|
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Extract per-operation security requirements from an OpenAPI security directive.
|
|
1390
|
+
* Returns undefined when the operation uses the spec-level default security.
|
|
1391
|
+
*
|
|
1392
|
+
* OpenAPI security format: `security: [{ schemeName: [scope1, scope2] }]`
|
|
1393
|
+
*/
|
|
1394
|
+
function extractOperationSecurity(security) {
|
|
1395
|
+
if (!security || security.length === 0) return void 0;
|
|
1396
|
+
const requirements = [];
|
|
1397
|
+
for (const entry of security) for (const [schemeName, scopes] of Object.entries(entry)) requirements.push({
|
|
1398
|
+
schemeName,
|
|
1399
|
+
scopes: scopes ?? []
|
|
1400
|
+
});
|
|
1401
|
+
return requirements.length > 0 ? requirements : void 0;
|
|
1402
|
+
}
|
|
1118
1403
|
function buildDescription(summary, description) {
|
|
1119
1404
|
if (summary && description && summary !== description) return `${summary}\n\n${description}`;
|
|
1120
1405
|
return description ?? summary;
|
|
1121
1406
|
}
|
|
1122
|
-
function extractParams(params, location) {
|
|
1407
|
+
function extractParams(params, location, operationContext) {
|
|
1123
1408
|
return params.filter((p) => p.in === location).map((p) => ({
|
|
1124
1409
|
name: p.name,
|
|
1125
|
-
type: p.schema ? schemaToTypeRef(p.schema, p.name) : {
|
|
1410
|
+
type: p.schema ? schemaToTypeRef(p.schema, p.name, operationContext ? toPascalCase(operationContext) : void 0) : {
|
|
1126
1411
|
kind: "primitive",
|
|
1127
1412
|
type: "string"
|
|
1128
1413
|
},
|
|
@@ -1308,7 +1593,14 @@ function extractResponses(responses, op, path, method) {
|
|
|
1308
1593
|
statusCode: code,
|
|
1309
1594
|
type: extractedType
|
|
1310
1595
|
});
|
|
1311
|
-
} else if (code >= 400) {
|
|
1596
|
+
} else if (code >= 300 && code < 400) allSuccessResponses.push({
|
|
1597
|
+
statusCode: code,
|
|
1598
|
+
type: {
|
|
1599
|
+
kind: "primitive",
|
|
1600
|
+
type: "unknown"
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
else if (code >= 400) {
|
|
1312
1604
|
const jsonContent = resp.content?.["application/json"];
|
|
1313
1605
|
const type = jsonContent?.schema ? schemaToTypeRef(jsonContent.schema, `Error${code}`) : void 0;
|
|
1314
1606
|
errors.push({
|
|
@@ -1435,6 +1727,19 @@ function collectInlineEnumsFromModels(models, enums) {
|
|
|
1435
1727
|
const enumNames = new Set(enums.map((e) => e.name));
|
|
1436
1728
|
for (const model of models) for (const field of model.fields) collectInlineEnumFromRef(field.type, enums, enumNames);
|
|
1437
1729
|
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Collect inline enum definitions from operation parameters (query, path, header)
|
|
1732
|
+
* and promote them to top-level enums so emitters can generate typed enum files.
|
|
1733
|
+
*/
|
|
1734
|
+
function collectInlineEnumsFromOperations(services, enums) {
|
|
1735
|
+
const enumNames = new Set(enums.map((e) => e.name));
|
|
1736
|
+
for (const service of services) for (const op of service.operations) for (const param of [
|
|
1737
|
+
...op.pathParams,
|
|
1738
|
+
...op.queryParams,
|
|
1739
|
+
...op.headerParams,
|
|
1740
|
+
...op.cookieParams ?? []
|
|
1741
|
+
]) collectInlineEnumFromRef(param.type, enums, enumNames);
|
|
1742
|
+
}
|
|
1438
1743
|
//#endregion
|
|
1439
1744
|
//#region src/parser/normalize-model-refs.ts
|
|
1440
1745
|
function validateModelRefs(spec) {
|
|
@@ -1464,10 +1769,12 @@ async function parseSpec(specPath, options) {
|
|
|
1464
1769
|
const spec = parsed;
|
|
1465
1770
|
const version = spec.openapi ?? "";
|
|
1466
1771
|
if (!version.startsWith("3.")) throw new SpecParseError(`Unsupported OpenAPI version: ${version}. oagen requires OpenAPI 3.x`, `Update the spec to OpenAPI 3.0 or 3.1. If you are using Swagger 2.x, convert it first with \`npx swagger2openapi ${specPath}\`.`);
|
|
1467
|
-
const { models, enums } = extractSchemas(spec.components?.schemas);
|
|
1772
|
+
const { models, enums } = extractSchemas(spec.components?.schemas, { schemaNameTransform: options?.schemaNameTransform });
|
|
1468
1773
|
const { services, inlineModels } = extractOperations(spec.paths, options?.operationIdTransform);
|
|
1774
|
+
clearSchemaNameTransform();
|
|
1469
1775
|
const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(mergeInlineResponseModels(models, inlineModels), extractInlineModelsFromSchemas(spec.components?.schemas)), services);
|
|
1470
1776
|
collectInlineEnumsFromModels(finalModels, enums);
|
|
1777
|
+
collectInlineEnumsFromOperations(services, enums);
|
|
1471
1778
|
const auth = extractAuthSchemes(spec.components?.securitySchemes);
|
|
1472
1779
|
const serverEntries = (spec.servers ?? []).map((s) => ({
|
|
1473
1780
|
url: s.url ?? "",
|
|
@@ -1482,7 +1789,8 @@ async function parseSpec(specPath, options) {
|
|
|
1482
1789
|
services,
|
|
1483
1790
|
models: finalModels,
|
|
1484
1791
|
enums,
|
|
1485
|
-
auth
|
|
1792
|
+
auth,
|
|
1793
|
+
sdk: defaultSdkBehavior()
|
|
1486
1794
|
};
|
|
1487
1795
|
validateModelRefs(result);
|
|
1488
1796
|
return result;
|
|
@@ -1548,6 +1856,6 @@ function extractModelName(ref) {
|
|
|
1548
1856
|
}
|
|
1549
1857
|
}
|
|
1550
1858
|
//#endregion
|
|
1551
|
-
export { ACRONYM_SET, CommandError, ConfigError, ConfigLoadError, ConfigVersionMismatchError, ExtractorError, InternalError, OagenError, RegistryError, SpecParseError, applyFileHeaders, assertNever, assignModelsToServices, buildEmitterContext, cleanSchemaName, collectEnumRefs, collectFieldDependencies, collectModelRefs, collectReferencedNames, collectRequestBodyModels, diffSpecs, generate, generateAllFiles, generateFiles, getEmitter, integrateGeneratedFiles, mapFilesForTargetIntegration, mapTypeRef, parseSpec, planOperation, registerEmitter, stripBackendPrefixes, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, toUpperSnakeCase, treeShakeFiles, walkTypeRef };
|
|
1859
|
+
export { ACRONYM_SET, CommandError, ConfigError, ConfigLoadError, ConfigVersionMismatchError, ExtractorError, InternalError, OagenError, RegistryError, SpecParseError, applyFileHeaders, assertNever, assignModelsToServices, buildEmitterContext, cleanSchemaName, collectEnumRefs, collectFieldDependencies, collectModelRefs, collectReferencedNames, collectRequestBodyModels, defaultSdkBehavior, deriveMethodName, diffSpecs, generate, generateAllFiles, generateFiles, getEmitter, integrateGeneratedFiles, mapFilesForTargetIntegration, mapTypeRef, mergeSdkBehavior, parseSpec, planOperation, registerEmitter, resolveOperations, stripBackendPrefixes, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, toUpperSnakeCase, treeShakeFiles, walkTypeRef };
|
|
1552
1860
|
|
|
1553
1861
|
//# sourceMappingURL=index.mjs.map
|