simpler-forms 0.1.0-alpha.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/LICENSE.md +21 -0
- package/README.md +111 -0
- package/dist/src/decorators/index.d.ts +4 -0
- package/dist/src/decorators/index.js +7 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/decorators/meta.d.ts +22 -0
- package/dist/src/decorators/meta.js +35 -0
- package/dist/src/decorators/meta.js.map +1 -0
- package/dist/src/decorators/shared.d.ts +49 -0
- package/dist/src/decorators/shared.js +149 -0
- package/dist/src/decorators/shared.js.map +1 -0
- package/dist/src/decorators/ui.d.ts +41 -0
- package/dist/src/decorators/ui.js +106 -0
- package/dist/src/decorators/ui.js.map +1 -0
- package/dist/src/decorators/validation.d.ts +25 -0
- package/dist/src/decorators/validation.js +91 -0
- package/dist/src/decorators/validation.js.map +1 -0
- package/dist/src/emitter.d.ts +15 -0
- package/dist/src/emitter.js +224 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/emitters/block-index.d.ts +4 -0
- package/dist/src/emitters/block-index.js +19 -0
- package/dist/src/emitters/block-index.js.map +1 -0
- package/dist/src/emitters/block-ui.d.ts +18 -0
- package/dist/src/emitters/block-ui.js +203 -0
- package/dist/src/emitters/block-ui.js.map +1 -0
- package/dist/src/emitters/field-occurrences.d.ts +18 -0
- package/dist/src/emitters/field-occurrences.js +237 -0
- package/dist/src/emitters/field-occurrences.js.map +1 -0
- package/dist/src/emitters/overlay.d.ts +16 -0
- package/dist/src/emitters/overlay.js +449 -0
- package/dist/src/emitters/overlay.js.map +1 -0
- package/dist/src/emitters/override-condition.d.ts +12 -0
- package/dist/src/emitters/override-condition.js +25 -0
- package/dist/src/emitters/override-condition.js.map +1 -0
- package/dist/src/index.d.ts +51 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +361 -0
- package/dist/src/lib.js +194 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/linter.d.ts +1 -0
- package/dist/src/linter.js +337 -0
- package/dist/src/linter.js.map +1 -0
- package/dist/src/model.d.ts +134 -0
- package/dist/src/model.js +203 -0
- package/dist/src/model.js.map +1 -0
- package/dist/src/public.d.ts +33 -0
- package/dist/src/public.js +40 -0
- package/dist/src/public.js.map +1 -0
- package/dist/src/validate.d.ts +15 -0
- package/dist/src/validate.js +737 -0
- package/dist/src/validate.js.map +1 -0
- package/lib/main.tsp +4 -0
- package/lib/meta.tsp +33 -0
- package/lib/types.tsp +134 -0
- package/lib/ui.tsp +78 -0
- package/lib/validation.tsp +134 -0
- package/package.json +54 -0
- package/src/decorators/index.ts +6 -0
- package/src/decorators/meta.ts +52 -0
- package/src/decorators/shared.ts +187 -0
- package/src/decorators/ui.ts +192 -0
- package/src/decorators/validation.ts +220 -0
- package/src/emitter.ts +272 -0
- package/src/emitters/block-index.ts +24 -0
- package/src/emitters/block-ui.ts +254 -0
- package/src/emitters/field-occurrences.ts +345 -0
- package/src/emitters/overlay.ts +596 -0
- package/src/emitters/override-condition.ts +37 -0
- package/src/index.ts +59 -0
- package/src/lib.ts +195 -0
- package/src/linter.ts +380 -0
- package/src/model.ts +400 -0
- package/src/public.ts +94 -0
- package/src/validate.ts +887 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { createRule, defineCodeFix, defineLinter, getDoc, getMaxItems, getMaxLength, getMinItems, getMinLength, getSourceLocation, paramMessage, serializeValueAsJson, } from "@typespec/compiler";
|
|
2
|
+
import { allBlocks, modelOrder, orderedProps, propEnabledWhen, propOmit, propReadOnlyWhen, propRequiredWhen, propSection, propValidationConstraintsWhen, propVisibleWhen, } from "./model.js";
|
|
3
|
+
/**
|
|
4
|
+
* Hygiene checks. A TypeSpec linter rule may only be a warning, so everything whose failure
|
|
5
|
+
* makes an artifact *wrong* lives in `$onValidate` instead; what is left here is a
|
|
6
|
+
* specification worth tidying rather than a broken one.
|
|
7
|
+
*/
|
|
8
|
+
const orphanQuestion = createRule({
|
|
9
|
+
name: "no-orphan-question",
|
|
10
|
+
severity: "warning",
|
|
11
|
+
description: "A bank question that no form and no other question composes.",
|
|
12
|
+
messages: {
|
|
13
|
+
default: paramMessage `Question "${"id"}" is composed by nothing. Either a form should ask it or it should be deleted; an unasked question is still maintained.`,
|
|
14
|
+
},
|
|
15
|
+
create(context) {
|
|
16
|
+
return {
|
|
17
|
+
root: (program) => {
|
|
18
|
+
const blocks = allBlocks(program);
|
|
19
|
+
const byType = new Map(blocks.map((block) => [block.model, block]));
|
|
20
|
+
const referenced = new Set();
|
|
21
|
+
// Reachability, not property references. A question is composed by holding it in a
|
|
22
|
+
// property, by extending it, or by being reached through a model that is not itself
|
|
23
|
+
// a question -- and all three have to count, or the rule reports a question that a
|
|
24
|
+
// form does ask.
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const reach = (type, viaComposition) => {
|
|
27
|
+
const block = byType.get(type);
|
|
28
|
+
if (block && viaComposition)
|
|
29
|
+
referenced.add(block.id);
|
|
30
|
+
if (seen.has(type))
|
|
31
|
+
return;
|
|
32
|
+
seen.add(type);
|
|
33
|
+
// Extending a question composes it, for a scalar as much as for a model: naming a
|
|
34
|
+
// shape does not make the shape unasked.
|
|
35
|
+
const base = type.kind === "Model" ? type.baseModel : type.baseScalar;
|
|
36
|
+
if (base)
|
|
37
|
+
reach(base, true);
|
|
38
|
+
if (type.kind !== "Model")
|
|
39
|
+
return;
|
|
40
|
+
for (const prop of type.properties.values()) {
|
|
41
|
+
for (const target of held(prop))
|
|
42
|
+
reach(target, true);
|
|
43
|
+
for (let source = prop.sourceProperty; source; source = source.sourceProperty) {
|
|
44
|
+
if (source.model)
|
|
45
|
+
reach(source.model, true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
for (const block of blocks)
|
|
50
|
+
reach(block.model, false);
|
|
51
|
+
for (const block of blocks) {
|
|
52
|
+
if (block.kind !== "question")
|
|
53
|
+
continue;
|
|
54
|
+
if (referenced.has(block.id))
|
|
55
|
+
continue;
|
|
56
|
+
context.reportDiagnostic({
|
|
57
|
+
target: block.model,
|
|
58
|
+
format: { id: block.id },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* The declarations a property holds: its own type, and the entries of a list.
|
|
67
|
+
*
|
|
68
|
+
* Both, because a list can itself be a question -- `primary-org/applicant-type` is one to
|
|
69
|
+
* three codes, so the *list* is what the form asks -- and the entries can be a question too.
|
|
70
|
+
* Returning only the entries reports the list as composed by nothing.
|
|
71
|
+
*/
|
|
72
|
+
function held(prop) {
|
|
73
|
+
const type = prop.type;
|
|
74
|
+
if (type.kind === "Scalar")
|
|
75
|
+
return [type];
|
|
76
|
+
if (type.kind !== "Model")
|
|
77
|
+
return [];
|
|
78
|
+
const out = [type];
|
|
79
|
+
const item = type.indexer?.value;
|
|
80
|
+
if (item && (item.kind === "Model" || item.kind === "Scalar"))
|
|
81
|
+
out.push(item);
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
const questionDocs = createRule({
|
|
85
|
+
name: "require-question-docs",
|
|
86
|
+
severity: "warning",
|
|
87
|
+
description: "Every bank question needs a doc comment; it becomes its description.",
|
|
88
|
+
messages: {
|
|
89
|
+
default: paramMessage `Question "${"id"}" has no doc comment, so it has no description. Applicants read it, and so does anyone browsing the bank.`,
|
|
90
|
+
},
|
|
91
|
+
create(context) {
|
|
92
|
+
return {
|
|
93
|
+
root: (program) => {
|
|
94
|
+
for (const block of allBlocks(program)) {
|
|
95
|
+
if (block.kind !== "question")
|
|
96
|
+
continue;
|
|
97
|
+
if (getDoc(program, block.model))
|
|
98
|
+
continue;
|
|
99
|
+
context.reportDiagnostic({
|
|
100
|
+
target: block.model,
|
|
101
|
+
format: { id: block.id },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const sectionUnused = createRule({
|
|
109
|
+
name: "section-unused",
|
|
110
|
+
severity: "warning",
|
|
111
|
+
description: "A declared section that no field is placed in.",
|
|
112
|
+
messages: {
|
|
113
|
+
default: paramMessage `Section "${"section"}" on ${"form"} holds no fields, so it will not render. Usually this means a field was dropped.`,
|
|
114
|
+
},
|
|
115
|
+
create(context) {
|
|
116
|
+
return {
|
|
117
|
+
root: (program) => {
|
|
118
|
+
for (const block of allBlocks(program)) {
|
|
119
|
+
if (block.kind !== "form" ||
|
|
120
|
+
!block.sections ||
|
|
121
|
+
block.model.kind !== "Model")
|
|
122
|
+
continue;
|
|
123
|
+
const used = new Set();
|
|
124
|
+
for (const prop of orderedProps(program, block)) {
|
|
125
|
+
const section = propSection(program, prop);
|
|
126
|
+
if (section)
|
|
127
|
+
used.add(section.name);
|
|
128
|
+
}
|
|
129
|
+
for (const member of block.sections.members.values()) {
|
|
130
|
+
if (used.has(member.name))
|
|
131
|
+
continue;
|
|
132
|
+
// A documented empty section is deliberate static presentation content.
|
|
133
|
+
if (getDoc(program, member))
|
|
134
|
+
continue;
|
|
135
|
+
context.reportDiagnostic({
|
|
136
|
+
target: member,
|
|
137
|
+
format: { section: member.name, form: block.id },
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const orderIncomplete = createRule({
|
|
146
|
+
name: "order-incomplete",
|
|
147
|
+
severity: "warning",
|
|
148
|
+
description: "@UI.order that omits a property, which then falls to the end.",
|
|
149
|
+
messages: {
|
|
150
|
+
default: paramMessage `@UI.order on ${"model"} omits ${"missing"}. Omitted properties are appended in declaration order, which is rarely what was meant.`,
|
|
151
|
+
},
|
|
152
|
+
create(context) {
|
|
153
|
+
return {
|
|
154
|
+
model: (model) => {
|
|
155
|
+
const order = modelOrder(context.program, model);
|
|
156
|
+
if (!order)
|
|
157
|
+
return;
|
|
158
|
+
const missing = [...properties(model)]
|
|
159
|
+
.filter((prop) => !propOmit(context.program, prop) && !order.includes(prop.name))
|
|
160
|
+
.map((prop) => prop.name);
|
|
161
|
+
if (!missing.length)
|
|
162
|
+
return;
|
|
163
|
+
context.reportDiagnostic({
|
|
164
|
+
target: model,
|
|
165
|
+
format: {
|
|
166
|
+
model: model.name || "an anonymous model",
|
|
167
|
+
missing: missing.join(", "),
|
|
168
|
+
},
|
|
169
|
+
codefixes: [appendToOrder(model, missing)],
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
/**
|
|
176
|
+
* The fix is mechanical -- append the missing names in declaration order -- so it is
|
|
177
|
+
* offered rather than described.
|
|
178
|
+
*/
|
|
179
|
+
function appendToOrder(model, missing) {
|
|
180
|
+
return defineCodeFix({
|
|
181
|
+
id: "append-to-ui-order",
|
|
182
|
+
label: `Append ${missing.join(", ")} to @UI.order`,
|
|
183
|
+
fix: (context) => {
|
|
184
|
+
const decorator = model.decorators.find((d) => d.definition?.name === "@order");
|
|
185
|
+
const location = getSourceLocation(decorator?.node ?? model.node);
|
|
186
|
+
if (!location)
|
|
187
|
+
return;
|
|
188
|
+
const text = location.file.text.slice(location.pos, location.end);
|
|
189
|
+
const close = text.lastIndexOf(")");
|
|
190
|
+
if (close < 0)
|
|
191
|
+
return;
|
|
192
|
+
const addition = missing.map((n) => `, ${model.name}.${n}`).join("");
|
|
193
|
+
return context.prependText({
|
|
194
|
+
file: location.file,
|
|
195
|
+
pos: location.pos + close,
|
|
196
|
+
end: location.pos + close,
|
|
197
|
+
}, addition);
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const redeclaredProperty = createRule({
|
|
202
|
+
name: "no-redeclared-property",
|
|
203
|
+
severity: "warning",
|
|
204
|
+
description: "A derived block re-declaring a property it already inherits.",
|
|
205
|
+
messages: {
|
|
206
|
+
default: paramMessage `${"model"} re-declares ${"names"} identically to ${"base"}. A redeclaration that narrows -- making an optional member required for this form -- says something; one that repeats says nothing, and leaves two copies to keep in step by hand. For presentation only, use @UI.overrides.`,
|
|
207
|
+
},
|
|
208
|
+
create(context) {
|
|
209
|
+
return {
|
|
210
|
+
model: (model) => {
|
|
211
|
+
if (!model.baseModel)
|
|
212
|
+
return;
|
|
213
|
+
const inherited = new Map();
|
|
214
|
+
for (let m = model.baseModel; m; m = m.baseModel) {
|
|
215
|
+
for (const [name, prop] of m.properties)
|
|
216
|
+
if (!inherited.has(name))
|
|
217
|
+
inherited.set(name, prop);
|
|
218
|
+
}
|
|
219
|
+
const clashes = [...model.properties.values()]
|
|
220
|
+
.filter((prop) => {
|
|
221
|
+
const base = inherited.get(prop.name);
|
|
222
|
+
if (base &&
|
|
223
|
+
[
|
|
224
|
+
[
|
|
225
|
+
propEnabledWhen(context.program, base),
|
|
226
|
+
propEnabledWhen(context.program, prop),
|
|
227
|
+
],
|
|
228
|
+
[
|
|
229
|
+
propReadOnlyWhen(context.program, base),
|
|
230
|
+
propReadOnlyWhen(context.program, prop),
|
|
231
|
+
],
|
|
232
|
+
[
|
|
233
|
+
propRequiredWhen(context.program, base),
|
|
234
|
+
propRequiredWhen(context.program, prop),
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
propValidationConstraintsWhen(context.program, base),
|
|
238
|
+
propValidationConstraintsWhen(context.program, prop),
|
|
239
|
+
],
|
|
240
|
+
[
|
|
241
|
+
propVisibleWhen(context.program, base),
|
|
242
|
+
propVisibleWhen(context.program, prop),
|
|
243
|
+
],
|
|
244
|
+
].some(([left, right]) => JSON.stringify(left) !== JSON.stringify(right))) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
// Narrowing is the point of redeclaring: a form may require a member the
|
|
248
|
+
// question leaves optional. Only an identical repeat is worth a warning.
|
|
249
|
+
return (base &&
|
|
250
|
+
base.optional === prop.optional &&
|
|
251
|
+
base.type === prop.type &&
|
|
252
|
+
getMinItems(context.program, base) ===
|
|
253
|
+
getMinItems(context.program, prop) &&
|
|
254
|
+
getMaxItems(context.program, base) ===
|
|
255
|
+
getMaxItems(context.program, prop) &&
|
|
256
|
+
getMinLength(context.program, base) ===
|
|
257
|
+
getMinLength(context.program, prop) &&
|
|
258
|
+
getMaxLength(context.program, base) ===
|
|
259
|
+
getMaxLength(context.program, prop) &&
|
|
260
|
+
JSON.stringify(base.defaultValue
|
|
261
|
+
? serializeValueAsJson(context.program, base.defaultValue, base.defaultValue.type)
|
|
262
|
+
: undefined) ===
|
|
263
|
+
JSON.stringify(prop.defaultValue
|
|
264
|
+
? serializeValueAsJson(context.program, prop.defaultValue, prop.defaultValue.type)
|
|
265
|
+
: undefined));
|
|
266
|
+
})
|
|
267
|
+
.map((prop) => prop.name);
|
|
268
|
+
if (!clashes.length)
|
|
269
|
+
return;
|
|
270
|
+
context.reportDiagnostic({
|
|
271
|
+
target: model,
|
|
272
|
+
format: {
|
|
273
|
+
model: model.name || "an anonymous model",
|
|
274
|
+
names: clashes.join(", "),
|
|
275
|
+
base: model.baseModel.name || "its base",
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
const untaggedQuestion = createRule({
|
|
283
|
+
name: "require-question-tags",
|
|
284
|
+
severity: "warning",
|
|
285
|
+
description: "A bank question with no tags cannot be found by browsing.",
|
|
286
|
+
messages: {
|
|
287
|
+
default: paramMessage `Question "${"id"}" has no @Meta.tag, so it appears under no heading in the question browser.`,
|
|
288
|
+
},
|
|
289
|
+
create(context) {
|
|
290
|
+
return {
|
|
291
|
+
root: (program) => {
|
|
292
|
+
for (const block of allBlocks(program)) {
|
|
293
|
+
if (block.kind !== "question" || block.tags.length)
|
|
294
|
+
continue;
|
|
295
|
+
context.reportDiagnostic({
|
|
296
|
+
target: block.model,
|
|
297
|
+
format: { id: block.id },
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
/** Own and inherited properties, the derived declaration winning. */
|
|
305
|
+
function properties(model) {
|
|
306
|
+
const out = new Map();
|
|
307
|
+
const chain = [];
|
|
308
|
+
for (let m = model; m; m = m.baseModel)
|
|
309
|
+
chain.unshift(m);
|
|
310
|
+
for (const m of chain)
|
|
311
|
+
for (const prop of m.properties.values())
|
|
312
|
+
out.set(prop.name, prop);
|
|
313
|
+
return [...out.values()];
|
|
314
|
+
}
|
|
315
|
+
export const $linter = defineLinter({
|
|
316
|
+
rules: [
|
|
317
|
+
orphanQuestion,
|
|
318
|
+
questionDocs,
|
|
319
|
+
sectionUnused,
|
|
320
|
+
orderIncomplete,
|
|
321
|
+
redeclaredProperty,
|
|
322
|
+
untaggedQuestion,
|
|
323
|
+
],
|
|
324
|
+
ruleSets: {
|
|
325
|
+
recommended: {
|
|
326
|
+
enable: {
|
|
327
|
+
"simpler-forms/no-orphan-question": true,
|
|
328
|
+
"simpler-forms/require-question-docs": true,
|
|
329
|
+
"simpler-forms/section-unused": true,
|
|
330
|
+
"simpler-forms/order-incomplete": true,
|
|
331
|
+
"simpler-forms/no-redeclared-property": true,
|
|
332
|
+
"simpler-forms/require-question-tags": true,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
//# sourceMappingURL=linter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,EACZ,MAAM,EACN,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB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AAC,GAAG,CAAC,CAAC,SAAS;QAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5E,KAAK,MAAM,CAAC,IAAI,KAAK;QACnB,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE;YAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;IAClC,KAAK,EAAE;QACL,cAAc;QACd,YAAY;QACZ,aAAa;QACb,eAAe;QACf,kBAAkB;QAClB,gBAAgB;KACjB;IACD,QAAQ,EAAE;QACR,WAAW,EAAE;YACX,MAAM,EAAE;gBACN,kCAAkC,EAAE,IAAI;gBACxC,qCAAqC,EAAE,IAAI;gBAC3C,8BAA8B,EAAE,IAAI;gBACpC,gCAAgC,EAAE,IAAI;gBACtC,sCAAsC,EAAE,IAAI;gBAC5C,qCAAqC,EAAE,IAAI;aAC5C;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Enum, Model, ModelProperty, Program, Scalar } from "@typespec/compiler";
|
|
2
|
+
interface ConditionBase {
|
|
3
|
+
sourcePath: string[];
|
|
4
|
+
sourceIsArray: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface EqualsCondition extends ConditionBase {
|
|
7
|
+
operator: "equals";
|
|
8
|
+
value: string | number | boolean | null;
|
|
9
|
+
}
|
|
10
|
+
export interface InCondition extends ConditionBase {
|
|
11
|
+
operator: "in";
|
|
12
|
+
values: (string | number | boolean | null)[];
|
|
13
|
+
}
|
|
14
|
+
export interface CountAtLeastCondition extends ConditionBase {
|
|
15
|
+
operator: "countAtLeast";
|
|
16
|
+
minimum: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PresentCondition extends ConditionBase {
|
|
19
|
+
operator: "present";
|
|
20
|
+
}
|
|
21
|
+
export type AtomicCondition = EqualsCondition | InCondition | CountAtLeastCondition | PresentCondition;
|
|
22
|
+
/** Retain compiler identity out-of-band so declarative conditions remain JSON-serializable. */
|
|
23
|
+
export declare function rememberConditionSourceModel(condition: AtomicCondition, model: Model | undefined): void;
|
|
24
|
+
export declare const conditionSourceModel: (condition: AtomicCondition) => Model | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The only compound predicate currently authored by the library. Keeping this to a flat
|
|
27
|
+
* disjunction avoids introducing a general expression language for one source-backed use case.
|
|
28
|
+
*/
|
|
29
|
+
export interface AnyCondition {
|
|
30
|
+
operator: "any";
|
|
31
|
+
predicates: AtomicCondition[];
|
|
32
|
+
}
|
|
33
|
+
export type Condition = AtomicCondition | AnyCondition;
|
|
34
|
+
/** Everything the emitters need about one block, read out of decorator state. */
|
|
35
|
+
export interface Block {
|
|
36
|
+
/** A Model for object-valued blocks, a Scalar for single-value questions. */
|
|
37
|
+
model: Model | Scalar;
|
|
38
|
+
kind: "question" | "form";
|
|
39
|
+
/** True when the block is a single value rather than an object. */
|
|
40
|
+
scalar: boolean;
|
|
41
|
+
id: string;
|
|
42
|
+
meta: Record<string, unknown>;
|
|
43
|
+
classification: "semanticQuestion" | "captureMechanism";
|
|
44
|
+
tags: string[];
|
|
45
|
+
entity?: string;
|
|
46
|
+
responseRole?: ResponseRole;
|
|
47
|
+
label?: string;
|
|
48
|
+
doc?: string;
|
|
49
|
+
sections?: Enum;
|
|
50
|
+
order?: string[];
|
|
51
|
+
overrides: Record<string, Record<string, unknown>>;
|
|
52
|
+
}
|
|
53
|
+
export type ResponseRole = "applicantInput" | "calculatedOutput" | "systemValue" | "technicalField" | "attestation" | "staticContent";
|
|
54
|
+
export declare function readBlock(program: Program, model: Model | Scalar): Block | undefined;
|
|
55
|
+
/** All blocks in the program, in declaration order. */
|
|
56
|
+
export declare function allBlocks(program: Program): Block[];
|
|
57
|
+
export declare const propLabel: (p: Program, prop: ModelProperty) => string | undefined;
|
|
58
|
+
export declare const propHelpText: (p: Program, prop: ModelProperty) => string | undefined;
|
|
59
|
+
export declare const propWidget: (p: Program, prop: ModelProperty) => string | undefined;
|
|
60
|
+
export declare const propEncodedCheckboxGroup: (p: Program, prop: ModelProperty) => Record<string, unknown> | undefined;
|
|
61
|
+
export declare const propSection: (p: Program, prop: ModelProperty) => {
|
|
62
|
+
name: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
export declare const propReadOnly: (p: Program, prop: ModelProperty) => boolean;
|
|
66
|
+
export declare const propResponseRole: (p: Program, prop: ModelProperty) => ResponseRole | undefined;
|
|
67
|
+
export declare const typeResponseRole: (p: Program, type: Model | Scalar) => ResponseRole | undefined;
|
|
68
|
+
export declare const typeTags: (p: Program, type: Model | Scalar) => string[];
|
|
69
|
+
export declare const propReadOnlyWhen: (p: Program, prop: ModelProperty) => Condition[];
|
|
70
|
+
export declare const propOmit: (p: Program, prop: ModelProperty) => boolean;
|
|
71
|
+
export declare const propVisibleWhen: (p: Program, prop: ModelProperty) => Condition[];
|
|
72
|
+
export declare const propEnabledWhen: (p: Program, prop: ModelProperty) => Condition[];
|
|
73
|
+
export declare const propRequiredWhen: (p: Program, prop: ModelProperty) => Condition[];
|
|
74
|
+
export declare const propNotBefore: (p: Program, prop: ModelProperty) => ModelProperty | undefined;
|
|
75
|
+
export declare const propValidationConstraints: (p: Program, prop: ModelProperty) => Record<string, unknown>;
|
|
76
|
+
export declare const propExclusiveValues: (p: Program, prop: ModelProperty) => (string | number | boolean | null)[];
|
|
77
|
+
export declare const propValidationConstraintsWhen: (p: Program, prop: ModelProperty) => {
|
|
78
|
+
condition: Condition;
|
|
79
|
+
patch: Record<string, unknown>;
|
|
80
|
+
}[];
|
|
81
|
+
export declare const cardinalityRequiredPaths: (p: Program, target: Model | ModelProperty) => string[];
|
|
82
|
+
export declare const cardinalityRequiredWhen: (p: Program, target: Model | ModelProperty) => {
|
|
83
|
+
targetPath: string;
|
|
84
|
+
sourcePath: string;
|
|
85
|
+
value: string | number | boolean | null;
|
|
86
|
+
}[];
|
|
87
|
+
export declare const cardinalityAtLeastOnePathWhenPresent: (p: Program, target: Model | ModelProperty) => {
|
|
88
|
+
sourcePath: string;
|
|
89
|
+
targetPaths: string[];
|
|
90
|
+
}[];
|
|
91
|
+
export declare const cardinalityRequiredPathWhenPositiveDecimalString: (p: Program, target: Model | ModelProperty) => {
|
|
92
|
+
targetPath: string;
|
|
93
|
+
sourcePath: string;
|
|
94
|
+
}[];
|
|
95
|
+
export declare const cardinalityPositiveDecimalStringWhenPathPresent: (p: Program, target: Model | ModelProperty) => {
|
|
96
|
+
targetPath: string;
|
|
97
|
+
sourcePath: string;
|
|
98
|
+
}[];
|
|
99
|
+
export declare const modelAtLeastOneOf: (p: Program, model: Model) => string[][];
|
|
100
|
+
export declare const propComputed: (p: Program, prop: ModelProperty) => {
|
|
101
|
+
operator: string;
|
|
102
|
+
refs: string[];
|
|
103
|
+
} | undefined;
|
|
104
|
+
export declare const propComputedFrom: (p: Program, prop: ModelProperty) => {
|
|
105
|
+
operator: string;
|
|
106
|
+
paths: string[];
|
|
107
|
+
} | undefined;
|
|
108
|
+
export declare const propCalculationMaterialization: (p: Program, prop: ModelProperty) => "when_any_source_present" | undefined;
|
|
109
|
+
export declare const propEvaluationOrder: (p: Program, prop: ModelProperty) => number | undefined;
|
|
110
|
+
export declare const propTotals: (p: Program, prop: ModelProperty) => ModelProperty[] | undefined;
|
|
111
|
+
/** `@UI.label` for any model, block or not. */
|
|
112
|
+
export declare const modelLabel: (p: Program, model: Model) => string | undefined;
|
|
113
|
+
/** `@UI.order` for any model, block or not. */
|
|
114
|
+
export declare const modelOrder: (p: Program, model: Model) => string[] | undefined;
|
|
115
|
+
export declare const propOverrides: (p: Program, prop: ModelProperty) => Record<string, Record<string, unknown>>;
|
|
116
|
+
/** Own and inherited properties in declaration order, with the derived declaration winning. */
|
|
117
|
+
export declare function modelProperties(model: Model): ModelProperty[];
|
|
118
|
+
/** Properties in @UI.order if given, else declaration order; omitted ones dropped. */
|
|
119
|
+
export declare function orderedProps(program: Program, block: Block): ModelProperty[];
|
|
120
|
+
/**
|
|
121
|
+
* A block's own id and those of the questions it extends, nearest first.
|
|
122
|
+
*
|
|
123
|
+
* An entity question is a shape given a meaning -- `aor/signature` extends
|
|
124
|
+
* `generics/signature` -- so anything inferred from a shape has to look past the name at the
|
|
125
|
+
* front. Without this, naming a question stops the inference that its shape implied, which is
|
|
126
|
+
* exactly backwards.
|
|
127
|
+
*/
|
|
128
|
+
export declare function blockAncestry(program: Program, model: Model | Scalar): string[];
|
|
129
|
+
/** The child block a property composes, if any. */
|
|
130
|
+
export declare function childBlock(program: Program, prop: ModelProperty): Block | undefined;
|
|
131
|
+
export declare function scalarConstraints(program: Program, prop: ModelProperty): Record<string, unknown>;
|
|
132
|
+
export declare function enumValues(e: Enum): (string | number)[];
|
|
133
|
+
export declare function scalarType(s: Scalar): string;
|
|
134
|
+
export {};
|