@0disoft/mensor-compiler 0.1.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 +201 -0
- package/dist/src/check-project.d.ts +9 -0
- package/dist/src/check-project.d.ts.map +1 -0
- package/dist/src/check-project.js +334 -0
- package/dist/src/check-project.js.map +1 -0
- package/dist/src/compiler-timing.d.ts +25 -0
- package/dist/src/compiler-timing.d.ts.map +1 -0
- package/dist/src/compiler-timing.js +72 -0
- package/dist/src/compiler-timing.js.map +1 -0
- package/dist/src/feature-roots.d.ts +6 -0
- package/dist/src/feature-roots.d.ts.map +1 -0
- package/dist/src/feature-roots.js +8 -0
- package/dist/src/feature-roots.js.map +1 -0
- package/dist/src/filesystem.d.ts +4 -0
- package/dist/src/filesystem.d.ts.map +1 -0
- package/dist/src/filesystem.js +127 -0
- package/dist/src/filesystem.js.map +1 -0
- package/dist/src/form-facts.d.ts +37 -0
- package/dist/src/form-facts.d.ts.map +1 -0
- package/dist/src/form-facts.js +2 -0
- package/dist/src/form-facts.js.map +1 -0
- package/dist/src/form-index-semantics.d.ts +4 -0
- package/dist/src/form-index-semantics.d.ts.map +1 -0
- package/dist/src/form-index-semantics.js +149 -0
- package/dist/src/form-index-semantics.js.map +1 -0
- package/dist/src/form-index-types.d.ts +69 -0
- package/dist/src/form-index-types.d.ts.map +1 -0
- package/dist/src/form-index-types.js +11 -0
- package/dist/src/form-index-types.js.map +1 -0
- package/dist/src/form-index-validation.d.ts +3 -0
- package/dist/src/form-index-validation.d.ts.map +1 -0
- package/dist/src/form-index-validation.js +360 -0
- package/dist/src/form-index-validation.js.map +1 -0
- package/dist/src/form-index.d.ts +8 -0
- package/dist/src/form-index.d.ts.map +1 -0
- package/dist/src/form-index.js +94 -0
- package/dist/src/form-index.js.map +1 -0
- package/dist/src/form-rule.d.ts +9 -0
- package/dist/src/form-rule.d.ts.map +1 -0
- package/dist/src/form-rule.js +399 -0
- package/dist/src/form-rule.js.map +1 -0
- package/dist/src/handler-rule.d.ts +10 -0
- package/dist/src/handler-rule.d.ts.map +1 -0
- package/dist/src/handler-rule.js +75 -0
- package/dist/src/handler-rule.js.map +1 -0
- package/dist/src/html-forms.d.ts +12 -0
- package/dist/src/html-forms.d.ts.map +1 -0
- package/dist/src/html-forms.js +275 -0
- package/dist/src/html-forms.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/locations.d.ts +12 -0
- package/dist/src/locations.d.ts.map +1 -0
- package/dist/src/locations.js +148 -0
- package/dist/src/locations.js.map +1 -0
- package/dist/src/module-boundary-rule.d.ts +12 -0
- package/dist/src/module-boundary-rule.d.ts.map +1 -0
- package/dist/src/module-boundary-rule.js +256 -0
- package/dist/src/module-boundary-rule.js.map +1 -0
- package/dist/src/ownership-rule.d.ts +13 -0
- package/dist/src/ownership-rule.d.ts.map +1 -0
- package/dist/src/ownership-rule.js +98 -0
- package/dist/src/ownership-rule.js.map +1 -0
- package/dist/src/paths.d.ts +11 -0
- package/dist/src/paths.d.ts.map +1 -0
- package/dist/src/paths.js +35 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/route-index.d.ts +9 -0
- package/dist/src/route-index.d.ts.map +1 -0
- package/dist/src/route-index.js +31 -0
- package/dist/src/route-index.js.map +1 -0
- package/dist/src/route-rule.d.ts +11 -0
- package/dist/src/route-rule.d.ts.map +1 -0
- package/dist/src/route-rule.js +54 -0
- package/dist/src/route-rule.js.map +1 -0
- package/dist/src/source-fact-index.d.ts +8 -0
- package/dist/src/source-fact-index.d.ts.map +1 -0
- package/dist/src/source-fact-index.js +38 -0
- package/dist/src/source-fact-index.js.map +1 -0
- package/dist/src/types.d.ts +29 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/typescript-source.d.ts +22 -0
- package/dist/src/typescript-source.d.ts.map +1 -0
- package/dist/src/typescript-source.js +352 -0
- package/dist/src/typescript-source.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { formFactsForLinkedForm } from "./form-index-semantics.js";
|
|
3
|
+
import { actionFormPropertyRange, actionFormCodecPropertyRange, actionBindingDecoderKindRange, actionRoutePropertyRange, actionSchemaPropertyRange, } from "./locations.js";
|
|
4
|
+
import { assertRelativePosixPath, compareText, InputFailure, joinProjectPath, } from "./paths.js";
|
|
5
|
+
export function checkFeatureForms(options) {
|
|
6
|
+
const featureRoot = path.posix.dirname(options.featureContractPath);
|
|
7
|
+
const diagnostics = [];
|
|
8
|
+
for (let actionIndex = 0; actionIndex < options.feature.actions.length; actionIndex += 1) {
|
|
9
|
+
const action = options.feature.actions[actionIndex];
|
|
10
|
+
if (action === undefined) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const templateFile = assertRelativePosixPath(action.form.template, "form template");
|
|
14
|
+
const projectTemplate = joinProjectPath(featureRoot, templateFile);
|
|
15
|
+
const matchingForms = formFactsForLinkedForm(options.formIndex, projectTemplate, action.form.id);
|
|
16
|
+
if (matchingForms.length !== 1) {
|
|
17
|
+
throw new InputFailure("configuration", matchingForms.length === 0 ? "form.not_found" : "form.id_duplicate", matchingForms.length === 0
|
|
18
|
+
? `Form ${JSON.stringify(action.form.id)} was not found in ${JSON.stringify(projectTemplate)}.`
|
|
19
|
+
: `Form id ${JSON.stringify(action.form.id)} appears more than once in ${JSON.stringify(projectTemplate)}.`, projectTemplate);
|
|
20
|
+
}
|
|
21
|
+
const form = matchingForms[0];
|
|
22
|
+
if (form === undefined) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (form.method !== action.route.method) {
|
|
26
|
+
diagnostics.push(methodMismatchDiagnostic({
|
|
27
|
+
actionId: action.id,
|
|
28
|
+
actionIndex,
|
|
29
|
+
actualMethod: form.method,
|
|
30
|
+
expectedMethod: action.route.method,
|
|
31
|
+
form,
|
|
32
|
+
templateFile: projectTemplate,
|
|
33
|
+
featureContractPath: options.featureContractPath,
|
|
34
|
+
featureText: options.featureText,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
const resolvedAction = resolveFormAction({
|
|
38
|
+
actionId: action.id,
|
|
39
|
+
documentPath: action.form.documentPath,
|
|
40
|
+
featureContractPath: options.featureContractPath,
|
|
41
|
+
form,
|
|
42
|
+
});
|
|
43
|
+
if (resolvedAction.path !== action.route.path) {
|
|
44
|
+
diagnostics.push(actionMismatchDiagnostic({
|
|
45
|
+
actionId: action.id,
|
|
46
|
+
actionIndex,
|
|
47
|
+
actualAction: resolvedAction.path,
|
|
48
|
+
actualActionSource: resolvedAction.source,
|
|
49
|
+
expectedAction: action.route.path,
|
|
50
|
+
form,
|
|
51
|
+
templateFile: projectTemplate,
|
|
52
|
+
featureContractPath: options.featureContractPath,
|
|
53
|
+
featureText: options.featureText,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
for (const control of form.unsupportedControls) {
|
|
57
|
+
diagnostics.push(unsupportedControlDiagnostic({
|
|
58
|
+
actionId: action.id,
|
|
59
|
+
form,
|
|
60
|
+
control,
|
|
61
|
+
templateFile: projectTemplate,
|
|
62
|
+
featureContractPath: options.featureContractPath,
|
|
63
|
+
featureText: options.featureText,
|
|
64
|
+
actionIndex,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
for (const fieldName of [...action.input.schema.required].sort(compareText)) {
|
|
68
|
+
if (!Object.hasOwn(action.input.schema.properties, fieldName)) {
|
|
69
|
+
throw new InputFailure("configuration", "schema.required_property_missing", `Required action field ${JSON.stringify(fieldName)} has no schema property.`, options.featureContractPath);
|
|
70
|
+
}
|
|
71
|
+
const binding = action.input.formCodec.bindings.find((candidate) => candidate.path.length === 1 && candidate.path[0] === fieldName);
|
|
72
|
+
if (binding === undefined) {
|
|
73
|
+
throw new InputFailure("configuration", "form.binding_missing", `Required action field ${JSON.stringify(fieldName)} has no form codec binding.`, options.featureContractPath);
|
|
74
|
+
}
|
|
75
|
+
if (form.fields.some((field) => field.name === binding.name)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
diagnostics.push(missingFieldDiagnostic({
|
|
79
|
+
actionId: action.id,
|
|
80
|
+
actionIndex,
|
|
81
|
+
fieldName,
|
|
82
|
+
form,
|
|
83
|
+
templateFile: projectTemplate,
|
|
84
|
+
featureContractPath: options.featureContractPath,
|
|
85
|
+
featureText: options.featureText,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
const acceptedFieldNames = new Set([
|
|
89
|
+
...action.input.formCodec.bindings.map((binding) => binding.name),
|
|
90
|
+
...(action.input.formCodec.ignoredFields ?? []).map((field) => field.name),
|
|
91
|
+
]);
|
|
92
|
+
for (const field of form.fields) {
|
|
93
|
+
if (acceptedFieldNames.has(field.name)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
diagnostics.push(unexpectedFieldDiagnostic({
|
|
97
|
+
actionId: action.id,
|
|
98
|
+
actionIndex,
|
|
99
|
+
fieldName: field.name,
|
|
100
|
+
fieldRange: field.range,
|
|
101
|
+
form,
|
|
102
|
+
templateFile: projectTemplate,
|
|
103
|
+
featureContractPath: options.featureContractPath,
|
|
104
|
+
featureText: options.featureText,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
action.input.formCodec.bindings.forEach((binding, bindingIndex) => {
|
|
108
|
+
const field = form.fields.find((candidate) => candidate.name === binding.name);
|
|
109
|
+
if (field === undefined) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const repeatedControlsAreOneRadioGroup = field.controls.length > 1 &&
|
|
113
|
+
field.controls.every((control) => control.kind === "input" && control.inputType === "radio");
|
|
114
|
+
const incompatibleControl = field.controls.length > 1 && !repeatedControlsAreOneRadioGroup
|
|
115
|
+
? field.controls[1]
|
|
116
|
+
: field.controls.find((control) => (control.kind === "input" && control.inputType === "checkbox") ||
|
|
117
|
+
(control.kind === "select" && control.multiple));
|
|
118
|
+
if (incompatibleControl === undefined) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
diagnostics.push(controlCodecMismatchDiagnostic({
|
|
122
|
+
actionId: action.id,
|
|
123
|
+
actionIndex,
|
|
124
|
+
bindingIndex,
|
|
125
|
+
controlCount: field.controls.length,
|
|
126
|
+
fieldName: binding.name,
|
|
127
|
+
form,
|
|
128
|
+
control: incompatibleControl,
|
|
129
|
+
templateFile: projectTemplate,
|
|
130
|
+
featureContractPath: options.featureContractPath,
|
|
131
|
+
featureText: options.featureText,
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return diagnostics;
|
|
136
|
+
}
|
|
137
|
+
function unsupportedControlDiagnostic(options) {
|
|
138
|
+
const description = options.control.reason === "file-input"
|
|
139
|
+
? "file input"
|
|
140
|
+
: options.control.reason === "named-submitter"
|
|
141
|
+
? "named submitter"
|
|
142
|
+
: "submitter route override";
|
|
143
|
+
return {
|
|
144
|
+
code: "form.control_unsupported",
|
|
145
|
+
severity: "error",
|
|
146
|
+
category: "form-contract",
|
|
147
|
+
message: `Form ${JSON.stringify(options.form.id)} contains unsupported ${description}.`,
|
|
148
|
+
file: options.templateFile,
|
|
149
|
+
range: options.control.range,
|
|
150
|
+
facts: {
|
|
151
|
+
actionId: options.actionId,
|
|
152
|
+
controlKind: options.control.kind,
|
|
153
|
+
controlType: options.control.inputType,
|
|
154
|
+
fieldName: options.control.name,
|
|
155
|
+
formId: options.form.id,
|
|
156
|
+
reason: options.control.reason,
|
|
157
|
+
template: options.templateFile,
|
|
158
|
+
},
|
|
159
|
+
related: [
|
|
160
|
+
{
|
|
161
|
+
role: "linked-action-route",
|
|
162
|
+
message: "This form is linked to a static action route contract.",
|
|
163
|
+
file: options.featureContractPath,
|
|
164
|
+
range: actionRoutePropertyRange(options.featureText, options.actionIndex, "path"),
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
repair: {
|
|
168
|
+
strategy: "remove-or-model-unsupported-control",
|
|
169
|
+
hint: `Remove the ${description}, or add an explicit serializable contract before relying on it.`,
|
|
170
|
+
mustPreserve: [
|
|
171
|
+
`action ${options.actionId}`,
|
|
172
|
+
"static form-to-action linkage",
|
|
173
|
+
],
|
|
174
|
+
mustNot: [
|
|
175
|
+
"silently ignore the unsupported control",
|
|
176
|
+
"weaken the action contract",
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function controlCodecMismatchDiagnostic(options) {
|
|
182
|
+
const controlShape = options.controlCount > 1
|
|
183
|
+
? `${options.controlCount} successful controls with the same wire name`
|
|
184
|
+
: options.control.kind === "input"
|
|
185
|
+
? `input[type=${options.control.inputType}]`
|
|
186
|
+
: "select[multiple]";
|
|
187
|
+
return {
|
|
188
|
+
code: "form.control_codec_mismatch",
|
|
189
|
+
severity: "error",
|
|
190
|
+
category: "form-contract",
|
|
191
|
+
message: `Form field ${JSON.stringify(options.fieldName)} uses ${controlShape}, which is incompatible with the text decoder.`,
|
|
192
|
+
file: options.templateFile,
|
|
193
|
+
range: options.control.range,
|
|
194
|
+
facts: {
|
|
195
|
+
actionId: options.actionId,
|
|
196
|
+
controlKind: options.control.kind === "select" ? "select" : "input",
|
|
197
|
+
...(options.controlCount > 1 ? { controlCount: options.controlCount } : {}),
|
|
198
|
+
controlType: options.control.inputType,
|
|
199
|
+
decoderKind: "text",
|
|
200
|
+
fieldName: options.fieldName,
|
|
201
|
+
formId: options.form.id,
|
|
202
|
+
multiple: options.control.multiple,
|
|
203
|
+
template: options.templateFile,
|
|
204
|
+
},
|
|
205
|
+
related: [
|
|
206
|
+
{
|
|
207
|
+
role: "form-decoder-kind",
|
|
208
|
+
message: "The form codec declares a scalar text decoder for this field.",
|
|
209
|
+
file: options.featureContractPath,
|
|
210
|
+
range: actionBindingDecoderKindRange(options.featureText, options.actionIndex, options.bindingIndex),
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
repair: {
|
|
214
|
+
strategy: "align-control-and-decoder",
|
|
215
|
+
hint: `Use a scalar text control for ${options.fieldName}, or introduce a codec that explicitly models ${controlShape}.`,
|
|
216
|
+
mustPreserve: [
|
|
217
|
+
`action ${options.actionId}`,
|
|
218
|
+
`field binding ${options.fieldName}`,
|
|
219
|
+
"form-to-action linkage",
|
|
220
|
+
],
|
|
221
|
+
mustNot: [
|
|
222
|
+
"coerce repeated or missing form values through the text decoder",
|
|
223
|
+
"remove the field binding to hide the mismatch",
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function methodMismatchDiagnostic(options) {
|
|
229
|
+
return {
|
|
230
|
+
code: "form.method_mismatch",
|
|
231
|
+
severity: "error",
|
|
232
|
+
category: "form-contract",
|
|
233
|
+
message: `Form ${JSON.stringify(options.form.id)} uses method ${JSON.stringify(options.actualMethod)}, but action ${JSON.stringify(options.actionId)} requires ${JSON.stringify(options.expectedMethod)}.`,
|
|
234
|
+
file: options.templateFile,
|
|
235
|
+
range: options.form.methodRange,
|
|
236
|
+
facts: {
|
|
237
|
+
actionId: options.actionId,
|
|
238
|
+
actualMethod: options.actualMethod,
|
|
239
|
+
expectedMethod: options.expectedMethod,
|
|
240
|
+
formId: options.form.id,
|
|
241
|
+
template: options.templateFile,
|
|
242
|
+
},
|
|
243
|
+
related: [
|
|
244
|
+
{
|
|
245
|
+
role: "action-route-method",
|
|
246
|
+
message: "The action contract declares the required HTTP method.",
|
|
247
|
+
file: options.featureContractPath,
|
|
248
|
+
range: actionRoutePropertyRange(options.featureText, options.actionIndex, "method"),
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
repair: {
|
|
252
|
+
strategy: "align-form-method",
|
|
253
|
+
hint: `Set form ${options.form.id} method to ${options.expectedMethod}.`,
|
|
254
|
+
mustPreserve: [
|
|
255
|
+
`action ${options.actionId}`,
|
|
256
|
+
`route method ${options.expectedMethod}`,
|
|
257
|
+
"form-to-action linkage",
|
|
258
|
+
],
|
|
259
|
+
mustNot: [
|
|
260
|
+
"change the action route to match an accidental form method",
|
|
261
|
+
"remove the form-to-action linkage",
|
|
262
|
+
],
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function actionMismatchDiagnostic(options) {
|
|
267
|
+
return {
|
|
268
|
+
code: "form.action_mismatch",
|
|
269
|
+
severity: "error",
|
|
270
|
+
category: "form-contract",
|
|
271
|
+
message: `Form ${JSON.stringify(options.form.id)} submits to ${JSON.stringify(options.actualAction)}, but action ${JSON.stringify(options.actionId)} requires ${JSON.stringify(options.expectedAction)}.`,
|
|
272
|
+
file: options.templateFile,
|
|
273
|
+
range: options.form.action.range,
|
|
274
|
+
facts: {
|
|
275
|
+
actionId: options.actionId,
|
|
276
|
+
actualAction: options.actualAction,
|
|
277
|
+
actualActionSource: options.actualActionSource,
|
|
278
|
+
expectedAction: options.expectedAction,
|
|
279
|
+
formId: options.form.id,
|
|
280
|
+
template: options.templateFile,
|
|
281
|
+
},
|
|
282
|
+
related: [
|
|
283
|
+
...(options.actualActionSource === "current-document"
|
|
284
|
+
? [{
|
|
285
|
+
role: "form-document-path",
|
|
286
|
+
message: "The form contract declares the current document path.",
|
|
287
|
+
file: options.featureContractPath,
|
|
288
|
+
range: actionFormPropertyRange(options.featureText, options.actionIndex, "documentPath"),
|
|
289
|
+
}]
|
|
290
|
+
: []),
|
|
291
|
+
{
|
|
292
|
+
role: "action-route-path",
|
|
293
|
+
message: "The action contract declares the required submission path.",
|
|
294
|
+
file: options.featureContractPath,
|
|
295
|
+
range: actionRoutePropertyRange(options.featureText, options.actionIndex, "path"),
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
repair: {
|
|
299
|
+
strategy: "align-form-action",
|
|
300
|
+
hint: options.actualActionSource === "current-document"
|
|
301
|
+
? `Set form ${options.form.id} action to ${options.expectedAction}, or align its documentPath with the real page route.`
|
|
302
|
+
: `Set form ${options.form.id} action to ${options.expectedAction}.`,
|
|
303
|
+
mustPreserve: [
|
|
304
|
+
`action ${options.actionId}`,
|
|
305
|
+
`route path ${options.expectedAction}`,
|
|
306
|
+
"form-to-action linkage",
|
|
307
|
+
],
|
|
308
|
+
mustNot: [
|
|
309
|
+
"change the action route to match an accidental form target",
|
|
310
|
+
"remove the form-to-action linkage",
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function resolveFormAction(options) {
|
|
316
|
+
if (options.form.action.kind === "literal") {
|
|
317
|
+
return { path: options.form.action.value, source: "literal" };
|
|
318
|
+
}
|
|
319
|
+
if (options.documentPath === undefined) {
|
|
320
|
+
throw new InputFailure("configuration", "form.document_path_missing", `Action ${JSON.stringify(options.actionId)} links a current-document form but does not declare form.documentPath.`, options.featureContractPath);
|
|
321
|
+
}
|
|
322
|
+
return { path: options.documentPath, source: "current-document" };
|
|
323
|
+
}
|
|
324
|
+
function unexpectedFieldDiagnostic(options) {
|
|
325
|
+
return {
|
|
326
|
+
code: "form.field_unexpected",
|
|
327
|
+
severity: "error",
|
|
328
|
+
category: "form-contract",
|
|
329
|
+
message: `Form ${JSON.stringify(options.form.id)} contains unexpected field ${JSON.stringify(options.fieldName)}.`,
|
|
330
|
+
file: options.templateFile,
|
|
331
|
+
range: options.fieldRange,
|
|
332
|
+
facts: {
|
|
333
|
+
actionId: options.actionId,
|
|
334
|
+
fieldName: options.fieldName,
|
|
335
|
+
formId: options.form.id,
|
|
336
|
+
template: options.templateFile,
|
|
337
|
+
unknownFieldsPolicy: "reject",
|
|
338
|
+
},
|
|
339
|
+
related: [
|
|
340
|
+
{
|
|
341
|
+
role: "unknown-fields-policy",
|
|
342
|
+
message: "The form codec rejects fields that are neither bound nor explicitly ignored.",
|
|
343
|
+
file: options.featureContractPath,
|
|
344
|
+
range: actionFormCodecPropertyRange(options.featureText, options.actionIndex, "unknownFields"),
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
repair: {
|
|
348
|
+
strategy: "declare-or-remove-unexpected-form-field",
|
|
349
|
+
hint: `Bind field ${options.fieldName}, declare it as ignored with its consumer, or remove the control.`,
|
|
350
|
+
mustPreserve: [
|
|
351
|
+
"unknown field rejection",
|
|
352
|
+
`action ${options.actionId}`,
|
|
353
|
+
"form-to-action linkage",
|
|
354
|
+
],
|
|
355
|
+
mustNot: [
|
|
356
|
+
"weaken the unknown field policy",
|
|
357
|
+
`silently discard ${options.fieldName} at runtime`,
|
|
358
|
+
],
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function missingFieldDiagnostic(options) {
|
|
363
|
+
return {
|
|
364
|
+
code: "form.field_missing",
|
|
365
|
+
severity: "error",
|
|
366
|
+
category: "form-contract",
|
|
367
|
+
message: `Form ${JSON.stringify(options.form.id)} is missing required field ${JSON.stringify(options.fieldName)}.`,
|
|
368
|
+
file: options.templateFile,
|
|
369
|
+
range: options.form.range,
|
|
370
|
+
facts: {
|
|
371
|
+
actionId: options.actionId,
|
|
372
|
+
fieldName: options.fieldName,
|
|
373
|
+
formId: options.form.id,
|
|
374
|
+
schemaPath: [options.fieldName],
|
|
375
|
+
template: options.templateFile,
|
|
376
|
+
},
|
|
377
|
+
related: [
|
|
378
|
+
{
|
|
379
|
+
role: "action-input-field",
|
|
380
|
+
message: "The action input requires this field.",
|
|
381
|
+
file: options.featureContractPath,
|
|
382
|
+
range: actionSchemaPropertyRange(options.featureText, options.actionIndex, options.fieldName),
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
repair: {
|
|
386
|
+
strategy: "add-missing-form-control",
|
|
387
|
+
hint: `Add a named control bound to ${options.fieldName} in form ${options.form.id}.`,
|
|
388
|
+
mustPreserve: [
|
|
389
|
+
`action input requirement for ${options.fieldName}`,
|
|
390
|
+
"form-to-action linkage",
|
|
391
|
+
],
|
|
392
|
+
mustNot: [
|
|
393
|
+
`make ${options.fieldName} optional`,
|
|
394
|
+
`remove ${options.fieldName} from the action input contract`,
|
|
395
|
+
],
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=form-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-rule.js","sourceRoot":"","sources":["../../src/form-rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAclC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,iBAAiB,CAAC,OAKjC;IACC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpE,MAAM,WAAW,GAAiB,EAAE,CAAC;IAErC,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,IAAI,CAAC,EAAE,CAAC;QACzF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QACD,MAAM,YAAY,GAAG,uBAAuB,CAC1C,MAAM,CAAC,IAAI,CAAC,QAAQ,EACpB,eAAe,CAChB,CAAC;QACF,MAAM,eAAe,GAAG,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QACnE,MAAM,aAAa,GAAG,sBAAsB,CAC1C,OAAO,CAAC,SAAS,EACjB,eAAe,EACf,MAAM,CAAC,IAAI,C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AC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,UAAU,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;YAC/B,QAAQ,EAAE,OAAO,CAAC,YAAY;SAC/B;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,uCAAuC;gBAChD,IAAI,EAAE,OAAO,CAAC,mBAAmB;gBACjC,KAAK,EAAE,yBAAyB,CAC9B,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,SAAS,CAClB;aACF;SACF;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,0BAA0B;YACpC,IAAI,EAAE,gCAAgC,OAAO,CAAC,SAAS,YAAY,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG;YACrF,YAAY,EAAE;gBACZ,gCAAgC,OAAO,CAAC,SAAS,EAAE;gBACnD,wBAAwB;aACzB;YACD,OAAO,EAAE;gBACP,QAAQ,OAAO,CAAC,SAAS,WAAW;gBACpC,UAAU,OAAO,CAAC,SAAS,iCAAiC;aAC7D;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Diagnostic, FeatureContract } from "@0disoft/mensor-contract";
|
|
2
|
+
import type { SourceFactIndex } from "./source-fact-index.js";
|
|
3
|
+
export declare function checkFeatureHandlers(options: {
|
|
4
|
+
readonly featureContractPath: string;
|
|
5
|
+
readonly featureText: string;
|
|
6
|
+
readonly feature: FeatureContract;
|
|
7
|
+
readonly discovered: ReadonlySet<string>;
|
|
8
|
+
readonly sourceFacts: SourceFactIndex;
|
|
9
|
+
}): Promise<readonly Diagnostic[]>;
|
|
10
|
+
//# sourceMappingURL=handler-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-rule.d.ts","sourceRoot":"","sources":["../../src/handler-rule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;CACvC,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAyCjC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { handlerExportRange } from "./locations.js";
|
|
3
|
+
import { assertRelativePosixPath, InputFailure, joinProjectPath, } from "./paths.js";
|
|
4
|
+
export async function checkFeatureHandlers(options) {
|
|
5
|
+
const featureRoot = path.posix.dirname(options.featureContractPath);
|
|
6
|
+
const diagnostics = [];
|
|
7
|
+
for (let actionIndex = 0; actionIndex < options.feature.actions.length; actionIndex += 1) {
|
|
8
|
+
const action = options.feature.actions[actionIndex];
|
|
9
|
+
if (action === undefined) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const handlerFile = assertRelativePosixPath(action.handler.file, "handler file");
|
|
13
|
+
const projectFile = joinProjectPath(featureRoot, handlerFile);
|
|
14
|
+
if (!options.discovered.has(projectFile)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const module = await options.sourceFacts.get(projectFile);
|
|
18
|
+
if (module.exports.some((entry) => entry.kind === "value" && entry.name === action.handler.export)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (module.hasExportStar) {
|
|
22
|
+
throw new InputFailure("configuration", "typescript.export_star_unsupported", `Handler source ${JSON.stringify(projectFile)} must explicitly re-export ${JSON.stringify(action.handler.export)} instead of relying on export *.`, projectFile);
|
|
23
|
+
}
|
|
24
|
+
diagnostics.push(missingExportDiagnostic({
|
|
25
|
+
actionId: action.id,
|
|
26
|
+
actionIndex,
|
|
27
|
+
exportName: action.handler.export,
|
|
28
|
+
handlerFile,
|
|
29
|
+
projectFile,
|
|
30
|
+
featureContractPath: options.featureContractPath,
|
|
31
|
+
featureText: options.featureText,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
return diagnostics;
|
|
35
|
+
}
|
|
36
|
+
function missingExportDiagnostic(options) {
|
|
37
|
+
return {
|
|
38
|
+
code: "handler.export_missing",
|
|
39
|
+
severity: "error",
|
|
40
|
+
category: "project-structure",
|
|
41
|
+
message: `Handler file ${JSON.stringify(options.handlerFile)} does not export ${JSON.stringify(options.exportName)}.`,
|
|
42
|
+
file: options.projectFile,
|
|
43
|
+
range: {
|
|
44
|
+
start: { line: 0, character: 0 },
|
|
45
|
+
end: { line: 0, character: 0 },
|
|
46
|
+
},
|
|
47
|
+
facts: {
|
|
48
|
+
actionId: options.actionId,
|
|
49
|
+
exportName: options.exportName,
|
|
50
|
+
handlerFile: options.handlerFile,
|
|
51
|
+
},
|
|
52
|
+
related: [
|
|
53
|
+
{
|
|
54
|
+
role: "handler-export-declaration",
|
|
55
|
+
message: "The action contract requires this named export.",
|
|
56
|
+
file: options.featureContractPath,
|
|
57
|
+
range: handlerExportRange(options.featureText, options.actionIndex),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
repair: {
|
|
61
|
+
strategy: "export-declared-handler",
|
|
62
|
+
hint: `Export ${options.exportName} from ${options.handlerFile}.`,
|
|
63
|
+
mustPreserve: [
|
|
64
|
+
`action ${options.actionId}`,
|
|
65
|
+
`handler file ${options.handlerFile}`,
|
|
66
|
+
`handler export ${options.exportName}`,
|
|
67
|
+
],
|
|
68
|
+
mustNot: [
|
|
69
|
+
"change the contract to an unrelated export",
|
|
70
|
+
"execute the handler during checking",
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=handler-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-rule.js","sourceRoot":"","sources":["../../src/handler-rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAM1C;IACC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpE,MAAM,WAAW,GAAqC,EAAE,CAAC;IAEzD,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,IAAI,CAAC,EAAE,CAAC;QACzF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QACD,MAAM,WAAW,GAAG,uBAAuB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACjF,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACzC,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,O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,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,4BAA4B;gBAClC,OAAO,EAAE,iDAAiD;gBAC1D,IAAI,EAAE,OAAO,CAAC,mBAAmB;gBACjC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;aACpE;SACF;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,yBAAyB;YACnC,IAAI,EAAE,UAAU,OAAO,CAAC,UAAU,SAAS,OAAO,CAAC,WAAW,GAAG;YACjE,YAAY,EAAE;gBACZ,UAAU,OAAO,CAAC,QAAQ,EAAE;gBAC5B,gBAAgB,OAAO,CAAC,WAAW,EAAE;gBACrC,kBAAkB,OAAO,CAAC,UAAU,EAAE;aACvC;YACD,OAAO,EAAE;gBACP,4CAA4C;gBAC5C,qCAAqC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompilerTiming } from "./compiler-timing.js";
|
|
2
|
+
import { type FormDocumentFact, type FormIndex } from "./form-index.js";
|
|
3
|
+
export interface StaticHtmlFormIndexProvider {
|
|
4
|
+
readonly getIndex: (documentPaths: readonly string[]) => Promise<FormIndex>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createStaticHtmlFormIndexProvider(options: {
|
|
7
|
+
readonly producerVersion: string;
|
|
8
|
+
readonly readSource: (documentPath: string) => Promise<string>;
|
|
9
|
+
readonly timing?: CompilerTiming;
|
|
10
|
+
}): StaticHtmlFormIndexProvider;
|
|
11
|
+
export declare function extractStaticHtmlFormDocument(documentPath: string, html: string): FormDocumentFact;
|
|
12
|
+
//# sourceMappingURL=html-forms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-forms.d.ts","sourceRoot":"","sources":["../../src/html-forms.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAKf,MAAM,iBAAiB,CAAC;AAUzB,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,CACjB,aAAa,EAAE,SAAS,MAAM,EAAE,KAC7B,OAAO,CAAC,SAAS,CAAC,CAAC;CACzB;AAED,wBAAgB,iCAAiC,CAAC,OAAO,EAAE;IACzD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;CAClC,GAAG,2BAA2B,CAuD9B;AAED,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GACX,gBAAgB,CAclB"}
|