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.
Files changed (76) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +111 -0
  3. package/dist/src/decorators/index.d.ts +4 -0
  4. package/dist/src/decorators/index.js +7 -0
  5. package/dist/src/decorators/index.js.map +1 -0
  6. package/dist/src/decorators/meta.d.ts +22 -0
  7. package/dist/src/decorators/meta.js +35 -0
  8. package/dist/src/decorators/meta.js.map +1 -0
  9. package/dist/src/decorators/shared.d.ts +49 -0
  10. package/dist/src/decorators/shared.js +149 -0
  11. package/dist/src/decorators/shared.js.map +1 -0
  12. package/dist/src/decorators/ui.d.ts +41 -0
  13. package/dist/src/decorators/ui.js +106 -0
  14. package/dist/src/decorators/ui.js.map +1 -0
  15. package/dist/src/decorators/validation.d.ts +25 -0
  16. package/dist/src/decorators/validation.js +91 -0
  17. package/dist/src/decorators/validation.js.map +1 -0
  18. package/dist/src/emitter.d.ts +15 -0
  19. package/dist/src/emitter.js +224 -0
  20. package/dist/src/emitter.js.map +1 -0
  21. package/dist/src/emitters/block-index.d.ts +4 -0
  22. package/dist/src/emitters/block-index.js +19 -0
  23. package/dist/src/emitters/block-index.js.map +1 -0
  24. package/dist/src/emitters/block-ui.d.ts +18 -0
  25. package/dist/src/emitters/block-ui.js +203 -0
  26. package/dist/src/emitters/block-ui.js.map +1 -0
  27. package/dist/src/emitters/field-occurrences.d.ts +18 -0
  28. package/dist/src/emitters/field-occurrences.js +237 -0
  29. package/dist/src/emitters/field-occurrences.js.map +1 -0
  30. package/dist/src/emitters/overlay.d.ts +16 -0
  31. package/dist/src/emitters/overlay.js +449 -0
  32. package/dist/src/emitters/overlay.js.map +1 -0
  33. package/dist/src/emitters/override-condition.d.ts +12 -0
  34. package/dist/src/emitters/override-condition.js +25 -0
  35. package/dist/src/emitters/override-condition.js.map +1 -0
  36. package/dist/src/index.d.ts +51 -0
  37. package/dist/src/index.js +55 -0
  38. package/dist/src/index.js.map +1 -0
  39. package/dist/src/lib.d.ts +361 -0
  40. package/dist/src/lib.js +194 -0
  41. package/dist/src/lib.js.map +1 -0
  42. package/dist/src/linter.d.ts +1 -0
  43. package/dist/src/linter.js +337 -0
  44. package/dist/src/linter.js.map +1 -0
  45. package/dist/src/model.d.ts +134 -0
  46. package/dist/src/model.js +203 -0
  47. package/dist/src/model.js.map +1 -0
  48. package/dist/src/public.d.ts +33 -0
  49. package/dist/src/public.js +40 -0
  50. package/dist/src/public.js.map +1 -0
  51. package/dist/src/validate.d.ts +15 -0
  52. package/dist/src/validate.js +737 -0
  53. package/dist/src/validate.js.map +1 -0
  54. package/lib/main.tsp +4 -0
  55. package/lib/meta.tsp +33 -0
  56. package/lib/types.tsp +134 -0
  57. package/lib/ui.tsp +78 -0
  58. package/lib/validation.tsp +134 -0
  59. package/package.json +54 -0
  60. package/src/decorators/index.ts +6 -0
  61. package/src/decorators/meta.ts +52 -0
  62. package/src/decorators/shared.ts +187 -0
  63. package/src/decorators/ui.ts +192 -0
  64. package/src/decorators/validation.ts +220 -0
  65. package/src/emitter.ts +272 -0
  66. package/src/emitters/block-index.ts +24 -0
  67. package/src/emitters/block-ui.ts +254 -0
  68. package/src/emitters/field-occurrences.ts +345 -0
  69. package/src/emitters/overlay.ts +596 -0
  70. package/src/emitters/override-condition.ts +37 -0
  71. package/src/index.ts +59 -0
  72. package/src/lib.ts +195 -0
  73. package/src/linter.ts +380 -0
  74. package/src/model.ts +400 -0
  75. package/src/public.ts +94 -0
  76. package/src/validate.ts +887 -0
@@ -0,0 +1,203 @@
1
+ import { getDoc, getMaxLength, getMinLength, getMaxItems, getMinItems, } from "@typespec/compiler";
2
+ import { stateKeys } from "./lib.js";
3
+ const conditionSourceModels = new WeakMap();
4
+ /** Retain compiler identity out-of-band so declarative conditions remain JSON-serializable. */
5
+ export function rememberConditionSourceModel(condition, model) {
6
+ if (model)
7
+ conditionSourceModels.set(condition, model);
8
+ }
9
+ export const conditionSourceModel = (condition) => conditionSourceModels.get(condition);
10
+ const g = (p, k, t) => p.stateMap(k).get(t);
11
+ function enumName(value) {
12
+ if (typeof value === "string")
13
+ return value;
14
+ if (value && typeof value === "object" && "name" in value) {
15
+ return String(value.name);
16
+ }
17
+ if (value && typeof value === "object" && "value" in value) {
18
+ return enumName(value.value);
19
+ }
20
+ return undefined;
21
+ }
22
+ export function readBlock(program, model) {
23
+ const q = g(program, stateKeys.questionMeta, model);
24
+ const f = g(program, stateKeys.formMeta, model);
25
+ if (!q && !f)
26
+ return undefined;
27
+ const meta = (q ?? f);
28
+ return {
29
+ model,
30
+ kind: q ? "question" : "form",
31
+ scalar: model.kind === "Scalar",
32
+ id: String(meta.id),
33
+ meta,
34
+ classification: (enumName(meta.classification) ??
35
+ "semanticQuestion"),
36
+ tags: g(program, stateKeys.tags, model) ?? [],
37
+ entity: g(program, stateKeys.entity, model),
38
+ responseRole: g(program, stateKeys.responseRole, model),
39
+ label: g(program, stateKeys.label, model),
40
+ doc: getDoc(program, model),
41
+ sections: g(program, stateKeys.sections, model),
42
+ order: g(program, stateKeys.order, model),
43
+ overrides: g(program, stateKeys.overrides, model) ?? {},
44
+ };
45
+ }
46
+ /** All blocks in the program, in declaration order. */
47
+ export function allBlocks(program) {
48
+ const out = [];
49
+ const seen = new Set();
50
+ const walk = (ns) => {
51
+ for (const m of [...ns.models.values(), ...ns.scalars.values()]) {
52
+ if (seen.has(m))
53
+ continue;
54
+ seen.add(m);
55
+ const b = readBlock(program, m);
56
+ if (b)
57
+ out.push(b);
58
+ }
59
+ for (const child of ns.namespaces.values())
60
+ walk(child);
61
+ };
62
+ walk(program.getGlobalNamespaceType());
63
+ return out;
64
+ }
65
+ export const propLabel = (p, prop) => g(p, stateKeys.label, prop);
66
+ export const propHelpText = (p, prop) => g(p, stateKeys.helpText, prop);
67
+ export const propWidget = (p, prop) => g(p, stateKeys.widget, prop);
68
+ export const propEncodedCheckboxGroup = (p, prop) => g(p, stateKeys.encodedCheckboxGroup, prop);
69
+ export const propSection = (p, prop) => g(p, stateKeys.section, prop);
70
+ export const propReadOnly = (p, prop) => g(p, stateKeys.readOnly, prop) === true;
71
+ export const propResponseRole = (p, prop) => g(p, stateKeys.responseRole, prop);
72
+ export const typeResponseRole = (p, type) => g(p, stateKeys.responseRole, type);
73
+ export const typeTags = (p, type) => g(p, stateKeys.tags, type) ?? [];
74
+ export const propReadOnlyWhen = (p, prop) => g(p, stateKeys.readOnlyWhen, prop) ?? [];
75
+ export const propOmit = (p, prop) => g(p, stateKeys.omit, prop) === true;
76
+ export const propVisibleWhen = (p, prop) => g(p, stateKeys.visibleWhen, prop) ?? [];
77
+ export const propEnabledWhen = (p, prop) => g(p, stateKeys.enabledWhen, prop) ?? [];
78
+ export const propRequiredWhen = (p, prop) => g(p, stateKeys.requiredWhen, prop) ?? [];
79
+ export const propNotBefore = (p, prop) => g(p, stateKeys.notBefore, prop);
80
+ export const propValidationConstraints = (p, prop) => g(p, stateKeys.validationConstraints, prop) ?? {};
81
+ export const propExclusiveValues = (p, prop) => g(p, stateKeys.exclusiveValues, prop) ?? [];
82
+ export const propValidationConstraintsWhen = (p, prop) => g(p, stateKeys.validationConstraintsWhen, prop) ?? [];
83
+ export const cardinalityRequiredPaths = (p, target) => g(p, stateKeys.requiredPaths, target) ?? [];
84
+ export const cardinalityRequiredWhen = (p, target) => g(p, stateKeys.requiredPathWhen, target) ?? [];
85
+ export const cardinalityAtLeastOnePathWhenPresent = (p, target) => g(p, stateKeys.atLeastOnePathWhenPresent, target) ?? [];
86
+ export const cardinalityRequiredPathWhenPositiveDecimalString = (p, target) => g(p, stateKeys.requiredPathWhenPositiveDecimalString, target) ?? [];
87
+ export const cardinalityPositiveDecimalStringWhenPathPresent = (p, target) => g(p, stateKeys.positiveDecimalStringWhenPathPresent, target) ?? [];
88
+ export const modelAtLeastOneOf = (p, model) => g(p, stateKeys.atLeastOneOf, model) ?? [];
89
+ export const propComputed = (p, prop) => g(p, stateKeys.computed, prop);
90
+ export const propComputedFrom = (p, prop) => g(p, stateKeys.computedFrom, prop);
91
+ export const propCalculationMaterialization = (p, prop) => g(p, stateKeys.calculationMaterialization, prop);
92
+ export const propEvaluationOrder = (p, prop) => g(p, stateKeys.evaluationOrder, prop);
93
+ export const propTotals = (p, prop) => g(p, stateKeys.totals, prop);
94
+ /** `@UI.label` for any model, block or not. */
95
+ export const modelLabel = (p, model) => g(p, stateKeys.label, model);
96
+ /** `@UI.order` for any model, block or not. */
97
+ export const modelOrder = (p, model) => g(p, stateKeys.order, model);
98
+ export const propOverrides = (p, prop) => g(p, stateKeys.overrides, prop) ?? {};
99
+ /** Own and inherited properties in declaration order, with the derived declaration winning. */
100
+ export function modelProperties(model) {
101
+ const chain = [];
102
+ for (let current = model; current; current = current.baseModel) {
103
+ chain.unshift(current);
104
+ }
105
+ const byName = new Map();
106
+ for (const current of chain) {
107
+ for (const property of current.properties.values())
108
+ byName.set(property.name, property);
109
+ }
110
+ return [...byName.values()];
111
+ }
112
+ /** Properties in @UI.order if given, else declaration order; omitted ones dropped. */
113
+ export function orderedProps(program, block) {
114
+ if (block.model.kind !== "Model")
115
+ return [];
116
+ // A form may extend a question to preserve flat response fields with explicit semantic
117
+ // lineage. Its inherited fields remain form members for sectioning and presentation.
118
+ // Question artifacts themselves keep their local surface and compose their base through
119
+ // JSON Schema `allOf`, so walking inherited properties there would duplicate that surface.
120
+ const candidates = block.kind === "form"
121
+ ? modelProperties(block.model)
122
+ : [...block.model.properties.values()];
123
+ const props = candidates.filter((p) => !propOmit(program, p));
124
+ if (!block.order)
125
+ return props;
126
+ const byName = new Map(props.map((p) => [p.name, p]));
127
+ const out = block.order
128
+ .map((n) => byName.get(n))
129
+ .filter(Boolean);
130
+ for (const p of props)
131
+ if (!out.includes(p))
132
+ out.push(p);
133
+ return out;
134
+ }
135
+ /**
136
+ * A block's own id and those of the questions it extends, nearest first.
137
+ *
138
+ * An entity question is a shape given a meaning -- `aor/signature` extends
139
+ * `generics/signature` -- so anything inferred from a shape has to look past the name at the
140
+ * front. Without this, naming a question stops the inference that its shape implied, which is
141
+ * exactly backwards.
142
+ */
143
+ export function blockAncestry(program, model) {
144
+ const out = [];
145
+ let current = model;
146
+ while (current) {
147
+ const block = readBlock(program, current);
148
+ if (block)
149
+ out.push(block.id);
150
+ current =
151
+ current.kind === "Model"
152
+ ? current.baseModel
153
+ : current.baseScalar;
154
+ }
155
+ return out;
156
+ }
157
+ /** The child block a property composes, if any. */
158
+ export function childBlock(program, prop) {
159
+ const t = prop.type;
160
+ if (t.kind === "Model" || t.kind === "Scalar")
161
+ return readBlock(program, t);
162
+ return undefined;
163
+ }
164
+ export function scalarConstraints(program, prop) {
165
+ const out = {};
166
+ const min = getMinLength(program, prop), max = getMaxLength(program, prop);
167
+ if (min !== undefined)
168
+ out.minLength = min;
169
+ if (max !== undefined)
170
+ out.maxLength = max;
171
+ const mnI = getMinItems(program, prop), mxI = getMaxItems(program, prop);
172
+ if (mnI !== undefined)
173
+ out.minItems = mnI;
174
+ if (mxI !== undefined)
175
+ out.maxItems = mxI;
176
+ return out;
177
+ }
178
+ export function enumValues(e) {
179
+ return [...e.members.values()].map((m) => (m.value ?? m.name));
180
+ }
181
+ export function scalarType(s) {
182
+ let cur = s;
183
+ while (cur) {
184
+ if (["string", "url", "uuid"].includes(cur.name))
185
+ return "string";
186
+ if (["boolean"].includes(cur.name))
187
+ return "boolean";
188
+ if (["int8", "int16", "int32", "int64", "integer", "safeint"].includes(cur.name))
189
+ return "integer";
190
+ if ([
191
+ "float",
192
+ "float32",
193
+ "float64",
194
+ "decimal",
195
+ "decimal128",
196
+ "numeric",
197
+ ].includes(cur.name))
198
+ return "number";
199
+ cur = cur.baseScalar;
200
+ }
201
+ return "string";
202
+ }
203
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AASA,OAAO,EACL,MAAM,EACN,YAAY,EACZ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G,KAAK,SAAS;QAAE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC1C,IAAI,GAAG,KAAK,SAAS;QAAE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAO;IAChC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAoB,CAC9C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,GAAG,GAAuB,CAAC,CAAC;IAChC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,QAAQ,CAAC;QAClE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,SAAS,CAAC;QACrD,IACE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAChE,GAAG,CAAC,IAAI,CACT;YAED,OAAO,SAAS,CAAC;QACnB,IACE;YACE,OAAO;YACP,SAAS;YACT,SAAS;YACT,SAAS;YACT,YAAY;YACZ,SAAS;SACV,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAEpB,OAAO,QAAQ,CAAC;QAClB,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC;IACvB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The API a target emitter reads.
3
+ *
4
+ * A consuming application contributes its own decorators, state, validation and emitted
5
+ * files through its own TypeSpec library, listed alongside this one in `tspconfig.yaml`.
6
+ * To do that it has to read the block graph this library builds, which is what the
7
+ * exports below are for.
8
+ *
9
+ * Everything here is public API and semver-governed. Nothing else in `src/` is: the
10
+ * decorator implementations, the emitters and the validators are internal, and a target
11
+ * that reaches past this module is depending on something that can change in a patch.
12
+ */
13
+ export {
14
+ /** Every question and form in the program, in declaration order. */
15
+ allBlocks,
16
+ /** Read one model as a block, or undefined if it is neither a question nor a form. */
17
+ readBlock,
18
+ /** The block a property's type resolves to, if that type is itself a block. */
19
+ childBlock,
20
+ /** A block's chain of enclosing blocks, nearest first. */
21
+ blockAncestry, type Block, } from "./model.js";
22
+ export {
23
+ /** The model a `countAtLeast` condition's source property belongs to. */
24
+ conditionSourceModel, type Condition, type AnyCondition, type AtomicCondition, type EqualsCondition, type InCondition, type CountAtLeastCondition, type PresentCondition, } from "./model.js";
25
+ /** An `enabledWhen` from `@UI.overrides`, normalized to the same shape as the decorator. */
26
+ export { normalizedOverrideEnabledWhen } from "./emitters/override-condition.js";
27
+ export { modelLabel, modelOrder, modelAtLeastOneOf,
28
+ /** Own and inherited properties in declaration order, derived declaration winning. */
29
+ modelProperties,
30
+ /** `modelProperties` with `@UI.order` applied. */
31
+ orderedProps, typeTags, typeResponseRole, enumValues, scalarType, scalarConstraints, } from "./model.js";
32
+ export { propLabel, propHelpText, propWidget, propEncodedCheckboxGroup, propSection, propOmit, propReadOnly, propOverrides, propResponseRole, propVisibleWhen, propEnabledWhen, propReadOnlyWhen, propRequiredWhen, propValidationConstraints, propValidationConstraintsWhen, propExclusiveValues, propComputed, propComputedFrom, propCalculationMaterialization, propEvaluationOrder, propNotBefore, propTotals, type ResponseRole, } from "./model.js";
33
+ export { cardinalityRequiredWhen, cardinalityRequiredPaths, cardinalityAtLeastOnePathWhenPresent, cardinalityRequiredPathWhenPositiveDecimalString, cardinalityPositiveDecimalStringWhenPathPresent, } from "./model.js";
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The API a target emitter reads.
3
+ *
4
+ * A consuming application contributes its own decorators, state, validation and emitted
5
+ * files through its own TypeSpec library, listed alongside this one in `tspconfig.yaml`.
6
+ * To do that it has to read the block graph this library builds, which is what the
7
+ * exports below are for.
8
+ *
9
+ * Everything here is public API and semver-governed. Nothing else in `src/` is: the
10
+ * decorator implementations, the emitters and the validators are internal, and a target
11
+ * that reaches past this module is depending on something that can change in a patch.
12
+ */
13
+ // --- the block graph ------------------------------------------------------
14
+ export {
15
+ /** Every question and form in the program, in declaration order. */
16
+ allBlocks,
17
+ /** Read one model as a block, or undefined if it is neither a question nor a form. */
18
+ readBlock,
19
+ /** The block a property's type resolves to, if that type is itself a block. */
20
+ childBlock,
21
+ /** A block's chain of enclosing blocks, nearest first. */
22
+ blockAncestry, } from "./model.js";
23
+ // --- conditions -----------------------------------------------------------
24
+ export {
25
+ /** The model a `countAtLeast` condition's source property belongs to. */
26
+ conditionSourceModel, } from "./model.js";
27
+ /** An `enabledWhen` from `@UI.overrides`, normalized to the same shape as the decorator. */
28
+ export { normalizedOverrideEnabledWhen } from "./emitters/override-condition.js";
29
+ // --- model-level state ----------------------------------------------------
30
+ export { modelLabel, modelOrder, modelAtLeastOneOf,
31
+ /** Own and inherited properties in declaration order, derived declaration winning. */
32
+ modelProperties,
33
+ /** `modelProperties` with `@UI.order` applied. */
34
+ orderedProps, typeTags, typeResponseRole, enumValues, scalarType, scalarConstraints, } from "./model.js";
35
+ // --- property-level state -------------------------------------------------
36
+ export { propLabel, propHelpText, propWidget, propEncodedCheckboxGroup, propSection, propOmit, propReadOnly, propOverrides, propResponseRole, propVisibleWhen, propEnabledWhen, propReadOnlyWhen, propRequiredWhen, propValidationConstraints, propValidationConstraintsWhen, propExclusiveValues, propComputed, propComputedFrom, propCalculationMaterialization, propEvaluationOrder, propNotBefore, propTotals, } from "./model.js";
37
+ // --- cardinality ----------------------------------------------------------
38
+ // Conditional-requiredness declarations, resolved against the type graph.
39
+ export { cardinalityRequiredWhen, cardinalityRequiredPaths, cardinalityAtLeastOnePathWhenPresent, cardinalityRequiredPathWhenPositiveDecimalString, cardinalityPositiveDecimalStringWhenPathPresent, } from "./model.js";
40
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,OAAO;AACL,oEAAoE;AACpE,SAAS;AACT,sFAAsF;AACtF,SAAS;AACT,+EAA+E;AAC/E,UAAU;AACV,0DAA0D;AAC1D,aAAa,GAEd,MAAM,YAAY,CAAC;AAEpB,6EAA6E;AAC7E,OAAO;AACL,yEAAyE;AACzE,oBAAoB,GAQrB,MAAM,YAAY,CAAC;AAEpB,4FAA4F;AAC5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEjF,6EAA6E;AAC7E,OAAO,EACL,UAAU,EACV,UAAU,EACV,iBAAiB;AACjB,sFAAsF;AACtF,eAAe;AACf,kDAAkD;AAClD,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,6EAA6E;AAC7E,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,wBAAwB,EACxB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,8BAA8B,EAC9B,mBAAmB,EACnB,aAAa,EACb,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,6EAA6E;AAC7E,0EAA0E;AAC1E,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,oCAAoC,EACpC,gDAAgD,EAChD,+CAA+C,GAChD,MAAM,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Model, ModelProperty, Program } from "@typespec/compiler";
2
+ /**
3
+ * Whole-program checks whose failure means the emitted artifacts would be wrong.
4
+ *
5
+ * These are errors, so they run here rather than in the linter, which may only warn. Each
6
+ * one exists because the defect it catches is currently invisible: a question named after a
7
+ * form, two blocks colliding on one output path, a condition comparing against a value the
8
+ * source enum does not have, a calculation that depends on itself, a field that is required
9
+ * but can be hidden, and a field in no section.
10
+ */
11
+ export declare function $onValidate(program: Program): void;
12
+ /** Own and inherited properties, the derived declaration winning. */
13
+ declare function allProperties(model: Model): Map<string, ModelProperty>;
14
+ /** The emitter needs the same notion of "all properties", derived declaration winning. */
15
+ export { allProperties as inheritedProperties };