@techspokes/typescript-wsdl-client 0.25.0 → 0.26.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 (37) hide show
  1. package/README.md +3 -2
  2. package/dist/app/generateApp.js +1 -1
  3. package/dist/client/generateTypes.d.ts.map +1 -1
  4. package/dist/client/generateTypes.js +136 -65
  5. package/dist/compiler/schemaCompiler.d.ts +19 -0
  6. package/dist/compiler/schemaCompiler.d.ts.map +1 -1
  7. package/dist/compiler/schemaCompiler.js +152 -49
  8. package/dist/compiler/shapeResolver.js +15 -0
  9. package/dist/openapi/generateSchemas.d.ts.map +1 -1
  10. package/dist/openapi/generateSchemas.js +39 -3
  11. package/dist/test/generateTests.js +1 -1
  12. package/dist/test/generators.d.ts +2 -2
  13. package/dist/test/generators.d.ts.map +1 -1
  14. package/dist/test/generators.js +84 -3
  15. package/dist/test/mockData.d.ts +19 -0
  16. package/dist/test/mockData.d.ts.map +1 -1
  17. package/dist/test/mockData.js +9 -0
  18. package/docs/README.md +1 -0
  19. package/docs/api-reference.md +21 -0
  20. package/docs/cli-reference.md +37 -8
  21. package/docs/concepts.md +18 -4
  22. package/docs/generated-code.md +18 -0
  23. package/docs/migration-playbook.md +1 -1
  24. package/docs/migration.md +1 -1
  25. package/docs/output-anatomy.md +1 -1
  26. package/docs/production.md +3 -3
  27. package/docs/releases/v0.25.2.md +32 -0
  28. package/docs/releases/v0.26.0.md +32 -0
  29. package/docs/roadmap/README.md +89 -0
  30. package/docs/roadmap/v1.0-choice-union-mode.md +90 -0
  31. package/docs/roadmap/v1.0-contract-audit.md +74 -0
  32. package/docs/roadmap/v1.0-json-array-streaming.md +99 -0
  33. package/docs/roadmap/v1.0-openapi-fastify-compatibility.md +97 -0
  34. package/docs/roadmap/v1.0-release-candidate-gates.md +77 -0
  35. package/docs/roadmap/v1.0-wsdl-coverage-matrix.md +89 -0
  36. package/docs/supported-patterns.md +2 -1
  37. package/package.json +4 -4
package/README.md CHANGED
@@ -25,7 +25,7 @@ Most tools in this space stop at one layer: a SOAP runtime, type generation, or
25
25
 
26
26
  - Typed client, OpenAPI spec, REST gateway, and runnable app from one command
27
27
  - Deterministic output safe for CI regeneration and version control
28
- - Handles complex inheritance, `xs:attribute`, namespace collisions, nested XSD imports, and choice elements
28
+ - Handles complex inheritance, `xs:attribute`, namespace collisions, nested XSD imports, and configurable `xs:choice` modeling
29
29
  - Generated `operations.ts` interface enables testing without importing `soap` or calling a live service
30
30
  - OpenAPI is a first-class output, not an afterthought; types, schemas, and descriptions stay aligned
31
31
  - Opt-in NDJSON streaming for large SOAP responses: client emits `AsyncIterable<RecordType>`, gateway flushes records incrementally, OpenAPI advertises the record schema via `x-wsdl-tsc-stream`
@@ -152,7 +152,7 @@ Real-world WSDL/XSD files are rarely clean. This generator handles patterns that
152
152
  - `xs:attribute` on complex types, flattened into peer properties alongside elements
153
153
  - Namespace collisions across multiple XSD imports, resolved deterministically
154
154
  - Deep import chains across multiple schema files
155
- - Configurable strategies for `<xs:choice>` element modeling
155
+ - `<xs:choice>` groups modeled as default all-optional fields or opt-in exclusive unions with `--client-choice-mode union`
156
156
  - Correct optionality for nillable fields in both TypeScript and OpenAPI output
157
157
  - The `$value` pattern for simple content with attributes, preserving text content alongside attribute properties
158
158
  - `ArrayOf*` wrapper types, unwrapped automatically in OpenAPI with runtime bridging
@@ -233,6 +233,7 @@ See [CLI Reference](docs/cli-reference.md) for all flags and examples.
233
233
  | [Core Concepts](docs/concepts.md) | Flattening, $value, primitives, determinism |
234
234
  | [Architecture](docs/architecture.md) | Internal pipeline for contributors |
235
235
  | [Agent Skill Artifact](docs/agent-skill.md) | Release ZIP for consumer-project AI agents |
236
+ | [Version 1.0 Roadmap Plan](docs/roadmap/README.md) | Implementation slices and release gates for 1.0 |
236
237
  | [Streamable Responses (ADR-002)](docs/decisions/002-streamable-responses.md) | Opt-in streaming: client `AsyncIterable`, gateway NDJSON, `x-wsdl-tsc-stream` |
237
238
  | [Version Migration](docs/migration.md) | Upgrading between package versions |
238
239
 
@@ -516,7 +516,7 @@ function generatePackageJson(appDir, force) {
516
516
  },
517
517
  devDependencies: {
518
518
  "@types/node": "^25.9.1",
519
- tsx: "^4.22.3",
519
+ tsx: "^4.22.4",
520
520
  typescript: "^6.0.3",
521
521
  },
522
522
  };
@@ -1 +1 @@
1
- {"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/client/generateTypes.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAGjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAsMvE"}
1
+ {"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/client/generateTypes.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAA0D,MAAM,+BAA+B,CAAC;AAG5H;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAmRvE"}
@@ -64,6 +64,65 @@ export function generateTypes(outFile, compiled) {
64
64
  const aliasNames = new Set(compiled.aliases.map((a) => a.name));
65
65
  const isValidIdent = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
66
66
  const emitPropName = (name) => (isValidIdent(name) ? name : JSON.stringify(name));
67
+ const isChoiceUnionMode = compiled.options.choice === "union";
68
+ const elementType = (e) => {
69
+ const isArray = e.max === "unbounded" || (e.max > 1);
70
+ return `${e.tsType}${isArray ? "[]" : ""}`;
71
+ };
72
+ const elementOptionalMarker = (e) => (compiled.options.nillableAsOptional && e.nillable) || (e.min ?? 0) === 0 ? "?" : "";
73
+ const emitElementProperty = (indent, e, options = {}) => {
74
+ const annObj = {
75
+ kind: e.name === "$value" ? "scalar value" : "element",
76
+ type: e.declaredType,
77
+ occurs: { min: e.min, max: e.max, nillable: e.nillable ?? false },
78
+ };
79
+ lines.push("");
80
+ if (e.doc) {
81
+ emitDocBlock(indent, e.doc, JSON.stringify(annObj));
82
+ }
83
+ else {
84
+ lines.push(`${indent}/** @xsd ${JSON.stringify(annObj)} */`);
85
+ }
86
+ lines.push(`${indent}${emitPropName(e.name)}${options.optionalMarker ?? elementOptionalMarker(e)}: ${options.tsType ?? elementType(e)};`);
87
+ };
88
+ const sortElementsForEmit = (elements) => {
89
+ elements.sort((a, b) => {
90
+ if (a.name === "$value")
91
+ return 1;
92
+ if (b.name === "$value")
93
+ return -1;
94
+ if (a.min !== 0 && b.min === 0)
95
+ return -1;
96
+ if (a.min === 0 && b.min !== 0)
97
+ return 1;
98
+ return a.name.localeCompare(b.name);
99
+ });
100
+ };
101
+ const sortAttributesForEmit = (attrs) => {
102
+ attrs.sort((a, b) => {
103
+ if (a.use === "required" && b.use !== "required")
104
+ return -1;
105
+ if (a.use !== "required" && b.use === "required")
106
+ return 1;
107
+ return a.name.localeCompare(b.name);
108
+ });
109
+ };
110
+ const emitAttributeProperty = (indent, a) => {
111
+ const opt = a.use === "required" ? "" : "?";
112
+ const annObj = {
113
+ kind: "attribute",
114
+ type: a.declaredType,
115
+ use: a.use || "optional",
116
+ };
117
+ lines.push("");
118
+ if (a.doc) {
119
+ emitDocBlock(indent, a.doc, JSON.stringify(annObj));
120
+ }
121
+ else {
122
+ lines.push(`${indent}/** @xsd ${JSON.stringify(annObj)} */`);
123
+ }
124
+ lines.push(`${indent}${emitPropName(a.name)}${opt}: ${a.tsType};`);
125
+ };
67
126
  const isSyntheticAliasSelfWrapper = (t) => {
68
127
  const elems = t.elems || [];
69
128
  return aliasNames.has(t.name) &&
@@ -110,13 +169,6 @@ export function generateTypes(outFile, compiled) {
110
169
  if (t.doc) {
111
170
  emitDocBlock("", t.doc);
112
171
  }
113
- // Header: extend base type if applicable
114
- if (baseName) {
115
- lines.push(`export interface ${t.name} extends ${baseName} {`);
116
- }
117
- else {
118
- lines.push(`export interface ${t.name} {`);
119
- }
120
172
  // Prepare lists: for complexContent extension use only local additions
121
173
  const attrsToEmit = complexBase ? (t.localAttrs || []) : (t.attrs || []);
122
174
  // Elements list similar
@@ -127,6 +179,79 @@ export function generateTypes(outFile, compiled) {
127
179
  if (idx >= 0)
128
180
  elementsToEmit.splice(idx, 1);
129
181
  }
182
+ const choiceGroupsToEmit = isChoiceUnionMode
183
+ ? (complexBase ? (t.localChoiceGroups || []) : (t.choiceGroups || []))
184
+ : [];
185
+ if (choiceGroupsToEmit.length > 0) {
186
+ const choiceElementNames = new Set(choiceGroupsToEmit.flatMap((group) => group.branches.map((branch) => branch.name)));
187
+ const baseElements = elementsToEmit.filter((e) => !choiceElementNames.has(e.name));
188
+ const baseNameForChoice = `${t.name}ChoiceBase`;
189
+ const choiceNames = choiceGroupsToEmit.map((group) => group.name).join(" & ");
190
+ lines.push(`export type ${t.name} = ${baseNameForChoice} & ${choiceNames};`);
191
+ lines.push("");
192
+ if (baseName) {
193
+ lines.push(`export interface ${baseNameForChoice} extends ${baseName} {`);
194
+ }
195
+ else {
196
+ lines.push(`export interface ${baseNameForChoice} {`);
197
+ }
198
+ if (0 < attrsToEmit.length) {
199
+ lines.push("");
200
+ lines.push(" /**");
201
+ lines.push((1 === attrsToEmit.length) ? " * Attribute." : " * Attributes.");
202
+ lines.push(" */");
203
+ sortAttributesForEmit(attrsToEmit);
204
+ }
205
+ for (const a of attrsToEmit) {
206
+ emitAttributeProperty(" ", a);
207
+ }
208
+ if (0 < baseElements.length) {
209
+ lines.push("");
210
+ lines.push(" /**");
211
+ lines.push((1 === baseElements.length) ? " * Child element." : " * Children elements.");
212
+ lines.push(" */");
213
+ sortElementsForEmit(baseElements);
214
+ }
215
+ for (const e of baseElements) {
216
+ if ((e.name === "$value") && (1 < baseElements.length)) {
217
+ lines.push("");
218
+ }
219
+ emitElementProperty(" ", e);
220
+ }
221
+ lines.push("}");
222
+ lines.push("");
223
+ for (const group of choiceGroupsToEmit) {
224
+ const branchNames = group.branches.map((branch) => branch.name);
225
+ lines.push(`export type ${group.name} =`);
226
+ for (const branch of group.branches) {
227
+ lines.push(" | {");
228
+ emitElementProperty(" ", branch);
229
+ for (const peerName of branchNames.filter((name) => name !== branch.name)) {
230
+ lines.push("");
231
+ lines.push(` ${emitPropName(peerName)}?: never;`);
232
+ }
233
+ lines.push(" }");
234
+ }
235
+ if (group.min === 0) {
236
+ lines.push(" | {");
237
+ for (const peerName of branchNames) {
238
+ lines.push("");
239
+ lines.push(` ${emitPropName(peerName)}?: never;`);
240
+ }
241
+ lines.push(" }");
242
+ }
243
+ lines.push(";");
244
+ lines.push("");
245
+ }
246
+ continue;
247
+ }
248
+ // Header: extend base type if applicable
249
+ if (baseName) {
250
+ lines.push(`export interface ${t.name} extends ${baseName} {`);
251
+ }
252
+ else {
253
+ lines.push(`export interface ${t.name} {`);
254
+ }
130
255
  //
131
256
  // Attributes — with JSDoc on every attribute
132
257
  //
@@ -136,33 +261,10 @@ export function generateTypes(outFile, compiled) {
136
261
  lines.push(" /**");
137
262
  lines.push((1 === t.attrs.length) ? " * Attribute." : " * Attributes.");
138
263
  lines.push(" */");
139
- // Sort the elements with the following logic: required first (sorted a-z), then optional (sorted a-z)
140
- attrsToEmit.sort((a, b) => {
141
- // Required attributes come before optional attributes
142
- if (a.use === "required" && b.use !== "required")
143
- return -1; // `a` is required, b is optional
144
- if (a.use !== "required" && b.use === "required")
145
- return 1; // `a` is optional, b is required
146
- // Within the same group (required or optional), sort alphabetically
147
- return a.name.localeCompare(b.name);
148
- });
264
+ sortAttributesForEmit(attrsToEmit);
149
265
  }
150
266
  for (const a of attrsToEmit) {
151
- const opt = a.use === "required" ? "" : "?";
152
- const annObj = {
153
- kind: "attribute",
154
- type: a.declaredType,
155
- use: a.use || "optional",
156
- };
157
- lines.push("");
158
- if (a.doc) {
159
- emitDocBlock(" ", a.doc, JSON.stringify(annObj));
160
- }
161
- else {
162
- const ann = ` /** @xsd ${JSON.stringify(annObj)} */`;
163
- lines.push(ann);
164
- }
165
- lines.push(` ${emitPropName(a.name)}${opt}: ${a.tsType};`);
267
+ emitAttributeProperty(" ", a);
166
268
  }
167
269
  //
168
270
  // Elements — with JSDoc on every element
@@ -174,45 +276,14 @@ export function generateTypes(outFile, compiled) {
174
276
  lines.push(" /**");
175
277
  lines.push((1 === elementsToEmit.length) ? " * Child element." : " * Children elements.");
176
278
  lines.push(" */");
177
- // Sort the elements with the following logic: required first (sorted a-z), then optional (sorted a-z), and finally "$value" if present.
178
- elementsToEmit.sort((a, b) => {
179
- // Special case: $value is always last
180
- if (a.name === "$value")
181
- return 1;
182
- if (b.name === "$value")
183
- return -1;
184
- // Required elements come before optional elements
185
- if (a.min !== 0 && b.min === 0)
186
- return -1; // `a` is required, b is optional
187
- if (a.min === 0 && b.min !== 0)
188
- return 1; // `a` is optional, b is required
189
- // Within the same group (required or optional), sort alphabetically
190
- return a.name.localeCompare(b.name);
191
- });
279
+ sortElementsForEmit(elementsToEmit);
192
280
  }
193
281
  for (const e of elementsToEmit) {
194
- const isArray = e.max === "unbounded" || (e.max > 1);
195
- const arr = isArray ? "[]" : "";
196
- const opt = (compiled.options.nillableAsOptional && e.nillable) || (e.min ?? 0) === 0 ? "?" : "";
197
- const annObj = {
198
- // if a.name === "$value", the kind should be "scalar value"
199
- kind: e.name === "$value" ? "scalar value" : "element",
200
- type: e.declaredType,
201
- occurs: { min: e.min, max: e.max, nillable: e.nillable ?? false },
202
- };
203
282
  // if the a.name === "$value" and we have more child elements, add an empty line before the annotation
204
283
  if ((e.name === "$value") && (1 < elementsToEmit.length)) {
205
284
  lines.push("");
206
285
  }
207
- lines.push("");
208
- if (e.doc) {
209
- emitDocBlock(" ", e.doc, JSON.stringify(annObj));
210
- }
211
- else {
212
- const ann = ` /** @xsd ${JSON.stringify(annObj)} */`;
213
- lines.push(ann);
214
- }
215
- lines.push(` ${emitPropName(e.name)}${opt}: ${e.tsType}${arr};`);
286
+ emitElementProperty(" ", e);
216
287
  }
217
288
  lines.push("}");
218
289
  lines.push("");
@@ -38,6 +38,23 @@ export type CompiledWildcard = {
38
38
  namespace?: string;
39
39
  processContents?: "lax" | "strict" | "skip";
40
40
  };
41
+ export type CompiledChoiceBranch = {
42
+ name: string;
43
+ tsType: string;
44
+ min: number;
45
+ max: number | "unbounded";
46
+ nillable?: boolean;
47
+ declaredType: string;
48
+ doc?: string;
49
+ sourceOrder: number;
50
+ };
51
+ export type CompiledChoiceGroup = {
52
+ name: string;
53
+ min: number;
54
+ max: number | "unbounded";
55
+ sourceOrder: number;
56
+ branches: CompiledChoiceBranch[];
57
+ };
41
58
  /**
42
59
  * Represents a compiled complex type with attributes and elements
43
60
  *
@@ -91,6 +108,8 @@ export type CompiledType = {
91
108
  doc?: string;
92
109
  }>;
93
110
  wildcards?: CompiledWildcard[];
111
+ choiceGroups?: CompiledChoiceGroup[];
112
+ localChoiceGroups?: CompiledChoiceGroup[];
94
113
  };
95
114
  /**
96
115
  * Represents a compiled type alias (simple type or restricted type)
@@ -1 +1 @@
1
- {"version":3,"file":"schemaCompiler.d.ts","sourceRoot":"","sources":["../../src/compiler/schemaCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAIzD,OAAO,KAAK,EAAC,uBAAuB,EAAE,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EA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MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;KAC/C,CAAC;IACF,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAwJF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,eAAe,EACxB,YAAY,CAAC,EAAE,YAAY,GAC1B,eAAe,CAm9BjB"}
@@ -317,6 +317,24 @@ export function compileCatalog(cat, options, streamConfig) {
317
317
  }
318
318
  }
319
319
  };
320
+ const mergeChoiceGroups = (into, list) => {
321
+ if (list.length === 0)
322
+ return into;
323
+ const merged = into ? [...into] : [];
324
+ const idx = new Map();
325
+ merged.forEach((g, i) => idx.set(g.name, i));
326
+ for (const g of list) {
327
+ const pos = idx.get(g.name);
328
+ if (pos == null) {
329
+ idx.set(g.name, merged.length);
330
+ merged.push(g);
331
+ }
332
+ else {
333
+ merged[pos] = g;
334
+ }
335
+ }
336
+ return merged;
337
+ };
320
338
  const collectAttributes = (node) => {
321
339
  const out = [];
322
340
  const attrs = getChildrenWithLocalName(node, "attribute");
@@ -380,61 +398,86 @@ export function compileCatalog(cat, options, streamConfig) {
380
398
  recurse(node);
381
399
  return out;
382
400
  };
401
+ const readOccurrence = (node) => {
402
+ const min = node["@_minOccurs"] ? Number(node["@_minOccurs"]) : 1;
403
+ const maxAttr = node["@_maxOccurs"];
404
+ const max = maxAttr === "unbounded" ? "unbounded" : maxAttr ? Number(maxAttr) : 1;
405
+ return { min, max };
406
+ };
407
+ const localNameOf = (key) => {
408
+ const idx = key.indexOf(":");
409
+ return idx >= 0 ? key.slice(idx + 1) : key;
410
+ };
411
+ const compositorChildren = (node) => {
412
+ const out = [];
413
+ for (const [key, value] of Object.entries(node || {})) {
414
+ const kind = localNameOf(key);
415
+ if (kind !== "element" && kind !== "sequence" && kind !== "all" && kind !== "choice") {
416
+ continue;
417
+ }
418
+ const arr = Array.isArray(value) ? value : [value];
419
+ for (const child of arr.filter(Boolean)) {
420
+ out.push({ kind, node: child });
421
+ }
422
+ }
423
+ return out;
424
+ };
425
+ const compileElementParticle = (ownerTypeName, e) => {
426
+ const nameOrRef = e["@_name"] || e["@_ref"];
427
+ if (!nameOrRef)
428
+ return undefined;
429
+ const propName = e["@_name"];
430
+ const { min, max } = readOccurrence(e);
431
+ const nillable = e["@_nillable"] === "true";
432
+ const inlineComplex = getFirstWithLocalName(e, "complexType");
433
+ const inlineSimple = getFirstWithLocalName(e, "simpleType");
434
+ if (inlineComplex) {
435
+ const inlineName = makeInlineTypeName(ownerTypeName, propName || nameOrRef, max);
436
+ const rec = getOrCompileComplex(inlineName, inlineComplex, schemaNS, prefixes);
437
+ return {
438
+ name: propName || nameOrRef,
439
+ tsType: rec.name,
440
+ min,
441
+ max,
442
+ nillable,
443
+ declaredType: `{${schemaNS}}${rec.name}`,
444
+ doc: extractAnnotationDocumentation(e),
445
+ };
446
+ }
447
+ if (inlineSimple) {
448
+ const r = compileSimpleTypeNode(inlineSimple, schemaNS, prefixes);
449
+ return {
450
+ name: propName || nameOrRef,
451
+ tsType: r.tsType,
452
+ min,
453
+ max,
454
+ nillable,
455
+ declaredType: r.declared,
456
+ doc: extractAnnotationDocumentation(e),
457
+ };
458
+ }
459
+ const t = e["@_type"] || e["@_ref"];
460
+ const q = t ? resolveQName(t, schemaNS, prefixes) : { ns: XS, local: "string" };
461
+ const r = resolveTypeRef(q, schemaNS, prefixes);
462
+ return {
463
+ name: propName || nameOrRef,
464
+ tsType: r.tsType,
465
+ min,
466
+ max,
467
+ nillable,
468
+ declaredType: r.declared,
469
+ doc: extractAnnotationDocumentation(e),
470
+ };
471
+ };
383
472
  const collectParticles = (ownerTypeName, node) => {
384
473
  const out = [];
385
474
  // process a compositor or element container recursively
386
475
  const recurse = (groupNode) => {
387
476
  // handle direct element children
388
477
  for (const e of getChildrenWithLocalName(groupNode, "element")) {
389
- const nameOrRef = e["@_name"] || e["@_ref"];
390
- if (!nameOrRef)
391
- continue;
392
- const propName = e["@_name"];
393
- const min = e["@_minOccurs"] ? Number(e["@_minOccurs"]) : 1;
394
- const maxAttr = e["@_maxOccurs"];
395
- const max = maxAttr === "unbounded" ? "unbounded" : maxAttr ? Number(maxAttr) : 1;
396
- const nillable = e["@_nillable"] === "true";
397
- const inlineComplex = getFirstWithLocalName(e, "complexType");
398
- const inlineSimple = getFirstWithLocalName(e, "simpleType");
399
- if (inlineComplex) {
400
- const inlineName = makeInlineTypeName(ownerTypeName, propName || nameOrRef, max);
401
- const rec = getOrCompileComplex(inlineName, inlineComplex, schemaNS, prefixes);
402
- out.push({
403
- name: propName || nameOrRef,
404
- tsType: rec.name,
405
- min,
406
- max,
407
- nillable,
408
- declaredType: `{${schemaNS}}${rec.name}`,
409
- doc: extractAnnotationDocumentation(e),
410
- });
411
- }
412
- else if (inlineSimple) {
413
- const r = compileSimpleTypeNode(inlineSimple, schemaNS, prefixes);
414
- out.push({
415
- name: propName || nameOrRef,
416
- tsType: r.tsType,
417
- min,
418
- max,
419
- nillable,
420
- declaredType: r.declared,
421
- doc: extractAnnotationDocumentation(e),
422
- });
423
- }
424
- else {
425
- const t = e["@_type"] || e["@_ref"];
426
- const q = t ? resolveQName(t, schemaNS, prefixes) : { ns: XS, local: "string" };
427
- const r = resolveTypeRef(q, schemaNS, prefixes);
428
- out.push({
429
- name: propName || nameOrRef,
430
- tsType: r.tsType,
431
- min,
432
- max,
433
- nillable,
434
- declaredType: r.declared,
435
- doc: extractAnnotationDocumentation(e),
436
- });
437
- }
478
+ const particle = compileElementParticle(ownerTypeName, e);
479
+ if (particle)
480
+ out.push(particle);
438
481
  }
439
482
  // recurse into nested compositor groups
440
483
  for (const comp of ["sequence", "all", "choice"]) {
@@ -446,17 +489,69 @@ export function compileCatalog(cat, options, streamConfig) {
446
489
  recurse(node);
447
490
  return out;
448
491
  };
492
+ const collectChoiceGroups = (ownerTypeName, node) => {
493
+ const out = [];
494
+ let choiceIndex = 0;
495
+ const recurse = (groupNode) => {
496
+ let sourceOrder = 0;
497
+ for (const child of compositorChildren(groupNode)) {
498
+ if (child.kind === "choice") {
499
+ const { min, max } = readOccurrence(child.node);
500
+ const branches = [];
501
+ let branchSourceOrder = 0;
502
+ for (const e of getChildrenWithLocalName(child.node, "element")) {
503
+ const particle = compileElementParticle(ownerTypeName, e);
504
+ if (particle) {
505
+ branches.push({
506
+ name: particle.name,
507
+ tsType: particle.tsType,
508
+ min: particle.min,
509
+ max: particle.max,
510
+ ...(particle.nillable ? { nillable: true } : {}),
511
+ declaredType: particle.declaredType,
512
+ ...(particle.doc ? { doc: particle.doc } : {}),
513
+ sourceOrder: branchSourceOrder,
514
+ });
515
+ }
516
+ branchSourceOrder += 1;
517
+ }
518
+ if (branches.length > 0) {
519
+ choiceIndex += 1;
520
+ out.push({
521
+ name: `${ownerTypeName}Choice${choiceIndex}`,
522
+ min,
523
+ max,
524
+ sourceOrder,
525
+ branches,
526
+ });
527
+ }
528
+ recurse(child.node);
529
+ }
530
+ else if (child.kind === "sequence" || child.kind === "all") {
531
+ recurse(child.node);
532
+ }
533
+ sourceOrder += 1;
534
+ }
535
+ };
536
+ recurse(node);
537
+ return out;
538
+ };
449
539
  const present = compiledMap.get(key);
450
540
  if (present) {
451
541
  // On duplicate definitions, merge new attributes and elements
452
542
  const newAttrs = collectAttributes(cnode);
453
543
  const newElems = collectParticles(outName, cnode);
454
544
  const newWildcards = collectWildcards(cnode);
545
+ const newChoiceGroups = collectChoiceGroups(outName, cnode);
455
546
  mergeAttrs(present.attrs, newAttrs);
456
547
  mergeElems(present.elems, newElems);
457
548
  if (newWildcards.length > 0) {
458
549
  present.wildcards = [...(present.wildcards ?? []), ...newWildcards];
459
550
  }
551
+ const mergedChoiceGroups = mergeChoiceGroups(present.choiceGroups, newChoiceGroups);
552
+ if (mergedChoiceGroups && mergedChoiceGroups.length > 0) {
553
+ present.choiceGroups = mergedChoiceGroups;
554
+ }
460
555
  if (!present.doc && typeDoc) {
461
556
  present.doc = typeDoc;
462
557
  }
@@ -467,6 +562,7 @@ export function compileCatalog(cat, options, streamConfig) {
467
562
  // result accumulators
468
563
  const attrs = [];
469
564
  const elems = [];
565
+ const choiceGroups = [];
470
566
  // Inheritance: complexContent
471
567
  const complexContent = getFirstWithLocalName(cnode, "complexContent");
472
568
  if (complexContent) {
@@ -486,14 +582,17 @@ export function compileCatalog(cat, options, streamConfig) {
486
582
  // inherit base members
487
583
  attrs.push(...baseType.attrs);
488
584
  elems.push(...baseType.elems);
585
+ choiceGroups.push(...(baseType.choiceGroups ?? []));
489
586
  }
490
587
  }
491
588
  // collect local additions/overrides
492
589
  const locals = collectAttributes(node);
493
590
  const localElems = collectParticles(outName, node);
494
591
  const localWildcards = collectWildcards(node);
592
+ const localChoiceGroups = collectChoiceGroups(outName, node);
495
593
  attrs.push(...locals);
496
594
  elems.push(...localElems);
595
+ choiceGroups.push(...localChoiceGroups);
497
596
  const result = {
498
597
  name: outName,
499
598
  ns: schemaNS,
@@ -504,6 +603,8 @@ export function compileCatalog(cat, options, streamConfig) {
504
603
  localAttrs: locals,
505
604
  localElems,
506
605
  ...(localWildcards.length > 0 ? { wildcards: localWildcards } : {}),
606
+ ...(choiceGroups.length > 0 ? { choiceGroups } : {}),
607
+ ...(localChoiceGroups.length > 0 ? { localChoiceGroups } : {}),
507
608
  };
508
609
  compiledMap.set(key, result);
509
610
  inProgress.delete(key);
@@ -547,6 +648,7 @@ export function compileCatalog(cat, options, streamConfig) {
547
648
  mergeAttrs(attrs, collectAttributes(cnode));
548
649
  mergeElems(elems, collectParticles(outName, cnode));
549
650
  const wildcards = collectWildcards(cnode);
651
+ choiceGroups.push(...collectChoiceGroups(outName, cnode));
550
652
  const result = {
551
653
  name: outName,
552
654
  ns: schemaNS,
@@ -554,6 +656,7 @@ export function compileCatalog(cat, options, streamConfig) {
554
656
  elems,
555
657
  doc: typeDoc,
556
658
  ...(wildcards.length > 0 ? { wildcards } : {}),
659
+ ...(choiceGroups.length > 0 ? { choiceGroups } : {}),
557
660
  };
558
661
  compiledMap.set(key, result);
559
662
  inProgress.delete(rawKey);
@@ -251,6 +251,21 @@ function canonicalizeType(t) {
251
251
  namespace: w.namespace ?? null,
252
252
  processContents: w.processContents ?? null,
253
253
  })),
254
+ choiceGroups: (t.choiceGroups ?? []).map((g) => ({
255
+ name: g.name,
256
+ min: g.min,
257
+ max: g.max,
258
+ sourceOrder: g.sourceOrder,
259
+ branches: g.branches.map((b) => ({
260
+ name: b.name,
261
+ tsType: b.tsType,
262
+ min: b.min,
263
+ max: b.max,
264
+ nillable: !!b.nillable,
265
+ declaredType: b.declaredType,
266
+ sourceOrder: b.sourceOrder,
267
+ })),
268
+ })),
254
269
  });
255
270
  }
256
271
  function canonicalizeAlias(a) {
@@ -1 +1 @@
1
- {"version":3,"file":"generateSchemas.d.ts","sourceRoot":"","sources":["../../src/openapi/generateSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAwKpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,iBAAiB,CAoD1G"}
1
+ {"version":3,"file":"generateSchemas.d.ts","sourceRoot":"","sources":["../../src/openapi/generateSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAkNpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,iBAAiB,CA2D1G"}