@llm4ts/shell 2.13.0 → 2.14.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.
|
@@ -29,29 +29,59 @@ export class Facets extends Schema.Class("Facets")({
|
|
|
29
29
|
minInclusive: Schema.optionalKey(Schema.String),
|
|
30
30
|
maxInclusive: Schema.optionalKey(Schema.String),
|
|
31
31
|
minExclusive: Schema.optionalKey(Schema.String),
|
|
32
|
-
maxExclusive: Schema.optionalKey(Schema.String)
|
|
32
|
+
maxExclusive: Schema.optionalKey(Schema.String),
|
|
33
|
+
whiteSpace: Schema.optionalKey(Schema.Literals(["preserve", "replace", "collapse"]))
|
|
33
34
|
}) {
|
|
34
35
|
}
|
|
36
|
+
/** A model group (`xs:sequence`, `xs:choice`, `xs:all`) of a complex type's content. */
|
|
37
|
+
export class ModelGroup extends Schema.Class("ModelGroup")({
|
|
38
|
+
/** Index of the group within its type's `groups`. */
|
|
39
|
+
id: Schema.Int,
|
|
40
|
+
kind: Schema.Literals(["sequence", "choice", "all"]),
|
|
41
|
+
minOccurs: Schema.Int,
|
|
42
|
+
maxOccurs: Occurs,
|
|
43
|
+
/** The enclosing group; absent for a group at the top of the content. */
|
|
44
|
+
parent: Schema.optionalKey(Schema.Int),
|
|
45
|
+
/** Index into the type's `fields` of the first field at or after the group's start. */
|
|
46
|
+
start: Schema.Int
|
|
47
|
+
}) {
|
|
48
|
+
}
|
|
49
|
+
/** An element particle's own occurrence bounds, before its groups' bounds fold in. */
|
|
50
|
+
export const ParticleOccurs = Schema.Struct({ min: Schema.Int, max: Occurs });
|
|
35
51
|
/** A child element of a complex type's content model. */
|
|
36
52
|
export class ElementField extends Schema.Class("ElementField")({
|
|
37
53
|
name: Schema.String,
|
|
38
54
|
/** Namespace of the element as it appears on the wire (`""` when unqualified). */
|
|
39
55
|
namespace: Schema.String,
|
|
40
56
|
type: QName,
|
|
57
|
+
/**
|
|
58
|
+
* Effective bounds within one instance of the type: an optional group
|
|
59
|
+
* makes its elements optional, a repeating group makes them repeat.
|
|
60
|
+
*/
|
|
41
61
|
minOccurs: Schema.Int,
|
|
42
62
|
maxOccurs: Occurs,
|
|
43
63
|
nillable: Schema.Boolean,
|
|
44
|
-
/** Set when the field sits inside an `xs:choice`: the choice's index within the type. */
|
|
64
|
+
/** Set when the field sits inside an `xs:choice`: the innermost choice's index within the type. */
|
|
45
65
|
choice: Schema.optionalKey(Schema.Int),
|
|
46
66
|
/** Within a choice: the alternative this field belongs to (a sequence is one alternative). */
|
|
47
67
|
branch: Schema.optionalKey(Schema.Int),
|
|
68
|
+
/** The innermost model group (index into the type's `groups`); the exact content model. */
|
|
69
|
+
group: Schema.optionalKey(Schema.Int),
|
|
70
|
+
/** The element particle's own bounds within `group`. */
|
|
71
|
+
occurs: Schema.optionalKey(ParticleOccurs),
|
|
72
|
+
/** `fixed=`: the only value the element may hold. */
|
|
73
|
+
fixed: Schema.optionalKey(Schema.String),
|
|
48
74
|
documentation: Schema.optionalKey(Schema.String)
|
|
49
75
|
}) {
|
|
50
76
|
}
|
|
51
77
|
export class AttributeField extends Schema.Class("AttributeField")({
|
|
52
78
|
name: Schema.String,
|
|
79
|
+
/** Namespace of the attribute on the wire; absent when unqualified. */
|
|
80
|
+
namespace: Schema.optionalKey(Schema.String),
|
|
53
81
|
type: QName,
|
|
54
82
|
required: Schema.Boolean,
|
|
83
|
+
/** `fixed=`: the only value the attribute may hold. */
|
|
84
|
+
fixed: Schema.optionalKey(Schema.String),
|
|
55
85
|
documentation: Schema.optionalKey(Schema.String)
|
|
56
86
|
}) {
|
|
57
87
|
}
|
|
@@ -63,6 +93,8 @@ export class ComplexTypeDef extends Schema.Class("ComplexTypeDef")({
|
|
|
63
93
|
/** `xs:extension` base, already flattened into `fields`/`attributes`. */
|
|
64
94
|
base: Schema.optionalKey(QName),
|
|
65
95
|
fields: Schema.Array(ElementField),
|
|
96
|
+
/** The model groups the fields sit in (see `ElementField.group`). */
|
|
97
|
+
groups: Schema.optionalKey(Schema.Array(ModelGroup)),
|
|
66
98
|
attributes: Schema.Array(AttributeField),
|
|
67
99
|
/** Simple content (`xs:simpleContent`): the text value's type. */
|
|
68
100
|
textType: Schema.optionalKey(QName),
|
|
@@ -76,6 +108,10 @@ export class SimpleTypeDef extends Schema.Class("SimpleTypeDef")({
|
|
|
76
108
|
/** The restriction base (an `xs:` builtin or another simple type). */
|
|
77
109
|
base: QName,
|
|
78
110
|
facets: Facets,
|
|
111
|
+
/** `xs:list` and `xs:union` types; absent for a restriction. */
|
|
112
|
+
variety: Schema.optionalKey(Schema.Literals(["list", "union"])),
|
|
113
|
+
/** A list's item type. */
|
|
114
|
+
itemType: Schema.optionalKey(QName),
|
|
79
115
|
documentation: Schema.optionalKey(Schema.String)
|
|
80
116
|
}) {
|
|
81
117
|
}
|
|
@@ -84,6 +120,7 @@ export class ElementDecl extends Schema.Class("ElementDecl")({
|
|
|
84
120
|
name: QName,
|
|
85
121
|
type: QName,
|
|
86
122
|
nillable: Schema.Boolean,
|
|
123
|
+
fixed: Schema.optionalKey(Schema.String),
|
|
87
124
|
documentation: Schema.optionalKey(Schema.String)
|
|
88
125
|
}) {
|
|
89
126
|
}
|
|
@@ -126,6 +163,8 @@ export const OpenQuestionCode = Schema.Literals([
|
|
|
126
163
|
"list-or-union",
|
|
127
164
|
"unresolved-type",
|
|
128
165
|
"unresolved-element",
|
|
166
|
+
"unresolved-attribute",
|
|
167
|
+
"redefine",
|
|
129
168
|
"non-literal-part",
|
|
130
169
|
"unsupported-binding",
|
|
131
170
|
"multi-part-message",
|
|
@@ -155,3 +194,90 @@ export class WsdlCatalog extends Schema.Class("WsdlCatalog")({
|
|
|
155
194
|
export const typeByName = (catalog, name) => catalog.types.find((type) => type.name === name);
|
|
156
195
|
export const elementByName = (catalog, name) => catalog.elements.find((element) => element.name === name);
|
|
157
196
|
export const operationByName = (catalog, name) => catalog.operations.find((operation) => operation.name === name);
|
|
197
|
+
/**
|
|
198
|
+
* The content model of a complex type as a particle tree, rooted in a
|
|
199
|
+
* sequence that occurs once (an extension's base content, then its own).
|
|
200
|
+
* A catalog written before model groups were recorded is rebuilt from the
|
|
201
|
+
* fields' choice and branch ids.
|
|
202
|
+
*/
|
|
203
|
+
export const contentModel = (type) => {
|
|
204
|
+
const groups = type.groups ?? [];
|
|
205
|
+
const exact = type.fields.every((field) => field.group !== undefined);
|
|
206
|
+
const legacyElement = (field) => ({
|
|
207
|
+
kind: "element",
|
|
208
|
+
field,
|
|
209
|
+
min: field.minOccurs,
|
|
210
|
+
max: field.maxOccurs
|
|
211
|
+
});
|
|
212
|
+
if (!exact || groups.length === 0) {
|
|
213
|
+
// Top-level entries: a field, or the id of a choice at its first field.
|
|
214
|
+
const top = [];
|
|
215
|
+
const choices = new Map();
|
|
216
|
+
for (const field of type.fields) {
|
|
217
|
+
if (field.choice === undefined) {
|
|
218
|
+
top.push(field);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const branches = choices.get(field.choice) ?? new Map();
|
|
222
|
+
if (!choices.has(field.choice))
|
|
223
|
+
top.push(field.choice);
|
|
224
|
+
choices.set(field.choice, branches);
|
|
225
|
+
branches.set(field.branch, [...(branches.get(field.branch) ?? []), field]);
|
|
226
|
+
}
|
|
227
|
+
const children = top.map((entry) => {
|
|
228
|
+
if (typeof entry !== "number")
|
|
229
|
+
return legacyElement(entry);
|
|
230
|
+
const alternatives = [...(choices.get(entry)?.values() ?? [])].map((members) => members.length === 1 && members[0] !== undefined
|
|
231
|
+
? legacyElement(members[0])
|
|
232
|
+
: { kind: "sequence", min: 1, max: 1, children: members.map(legacyElement) });
|
|
233
|
+
return { kind: "choice", min: 1, max: 1, children: alternatives };
|
|
234
|
+
});
|
|
235
|
+
return { kind: "sequence", min: 1, max: 1, children };
|
|
236
|
+
}
|
|
237
|
+
// Children of each group in document order: a group sits before the
|
|
238
|
+
// field it starts at; groups starting together keep their id order.
|
|
239
|
+
const entries = [];
|
|
240
|
+
const childrenOf = (parent) => entries
|
|
241
|
+
.filter((entry) => entry.parent === parent)
|
|
242
|
+
.sort((left, right) => left.order[0] - right.order[0] ||
|
|
243
|
+
left.order[1] - right.order[1] ||
|
|
244
|
+
left.order[2] - right.order[2])
|
|
245
|
+
.map((entry) => entry.build());
|
|
246
|
+
groups.forEach((group) => {
|
|
247
|
+
entries.push({
|
|
248
|
+
parent: group.parent,
|
|
249
|
+
order: [group.start, 0, group.id],
|
|
250
|
+
build: () => ({
|
|
251
|
+
kind: group.kind,
|
|
252
|
+
min: group.minOccurs,
|
|
253
|
+
max: group.maxOccurs,
|
|
254
|
+
children: childrenOf(group.id)
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
type.fields.forEach((field, index) => {
|
|
259
|
+
entries.push({
|
|
260
|
+
parent: field.group,
|
|
261
|
+
order: [index, 1, 0],
|
|
262
|
+
build: () => ({
|
|
263
|
+
kind: "element",
|
|
264
|
+
field,
|
|
265
|
+
min: field.occurs?.min ?? field.minOccurs,
|
|
266
|
+
max: field.occurs?.max ?? field.maxOccurs
|
|
267
|
+
})
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return { kind: "sequence", min: 1, max: 1, children: childrenOf(undefined) };
|
|
271
|
+
};
|
|
272
|
+
/** Every element field under a particle, in order. */
|
|
273
|
+
export const particleFields = (particle) => particle.kind === "element" ? [particle.field] : particle.children.flatMap(particleFields);
|
|
274
|
+
/** Whether a particle can be satisfied by no elements at all. */
|
|
275
|
+
export const emptiable = (particle) => {
|
|
276
|
+
if (particle.min === 0)
|
|
277
|
+
return true;
|
|
278
|
+
if (particle.kind === "element")
|
|
279
|
+
return false;
|
|
280
|
+
return particle.kind === "choice"
|
|
281
|
+
? particle.children.some(emptiable)
|
|
282
|
+
: particle.children.every(emptiable);
|
|
283
|
+
};
|