@conformetry/validation 0.0.4 → 0.0.6
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/CHANGELOG.md +23 -0
- package/README.md +58 -45
- package/dist/src/index.d.ts +42 -5
- package/dist/src/index.js +89 -14
- package/package.json +5 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## 0.0.6 (2026-10-08)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **conformetry,lexico:** ✨ add frontend conformetry templates and infer validation inputs ([#1301](https://github.com/organizzolini/codebase/pull/1301))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated conformetry-configuration to 0.0.6
|
|
10
|
+
- Updated conformetry-languages to 0.0.6
|
|
11
|
+
- Updated conformetry-core to 0.0.6
|
|
12
|
+
|
|
13
|
+
## 0.0.5 (2026-10-06)
|
|
14
|
+
|
|
15
|
+
### 💅 Refactors
|
|
16
|
+
|
|
17
|
+
- **ic-suite:** ♻️ rename @codebase/logger to @codebase/logging ([#1208](https://github.com/organizzolini/codebase/pull/1208))
|
|
18
|
+
|
|
19
|
+
### 🧱 Updated Dependencies
|
|
20
|
+
|
|
21
|
+
- Updated conformetry-configuration to 0.0.5
|
|
22
|
+
- Updated conformetry-languages to 0.0.5
|
|
23
|
+
- Updated conformetry-core to 0.0.5
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 👔 Conformetry Validation
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@conformetry/validation)
|
|
4
|
+
|
|
3
5
|
The validation orchestrator for [Conformetry](../conformetry-cli/README.md):
|
|
4
6
|
it matches instances to templates, checks the declared files exist, routes
|
|
5
7
|
each document to the validator that claims its extension, and deduplicates
|
|
@@ -101,13 +103,13 @@ Call stacks traced through `packages/ic-suite/conformetry/conformetry-validation
|
|
|
101
103
|
|
|
102
104
|
| Measure | Value |
|
|
103
105
|
| --- | --- |
|
|
104
|
-
| Callables |
|
|
106
|
+
| Callables | 58 |
|
|
105
107
|
| Files | 18 |
|
|
106
|
-
| Calls traced |
|
|
108
|
+
| Calls traced | 61 |
|
|
107
109
|
| Call stacks | 0 |
|
|
108
110
|
| Deepest stack | 0 |
|
|
109
111
|
| Stacks through recursion | 0 |
|
|
110
|
-
| Unfollowable calls |
|
|
112
|
+
| Unfollowable calls | 2 |
|
|
111
113
|
|
|
112
114
|
### Limits
|
|
113
115
|
|
|
@@ -126,32 +128,41 @@ None.
|
|
|
126
128
|
|
|
127
129
|
| Callable | Breadth | Calls directly | Location |
|
|
128
130
|
| --- | --- | --- | --- |
|
|
129
|
-
| `ValidationService.validate` | 10 | `ConfigurationService.matchInstances`, `ValidationService.selectValidators`, `LanguagesService.resolveValidators`, `ValidationService.readTemplateExtensions`, `ValidationService.map(…)`, `ValidationScoringService.scoreInstances`, `ValidationDeduplicationService.deduplicate`, `ValidationFindingsService.buildUnmatchedResults`, `ValidationService.map(…)`, `ValidationService.every(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:
|
|
130
|
-
| `ValidationService.
|
|
131
|
-
| `
|
|
131
|
+
| `ValidationService.validate` | 10 | `ConfigurationService.matchInstances`, `ValidationService.selectValidators`, `LanguagesService.resolveValidators`, `ValidationService.readTemplateExtensions`, `ValidationService.map(…)`, `ValidationScoringService.scoreInstances`, `ValidationDeduplicationService.deduplicate`, `ValidationFindingsService.buildUnmatchedResults`, `ValidationService.map(…)`, `ValidationService.every(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:194` |
|
|
132
|
+
| `ValidationService.compareInstance` | 6 | `ConfigurationService.prepareDocuments`, `ValidationService.readClaimedExtensions`, `FilesService.checkInstanceFiles`, `ValidationService.map(…)`, `ValidationService.flatMap(…)`, `ValidationService.reduce(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:57` |
|
|
133
|
+
| `ValidationScoringService.scoreInstance` | 5 | `ValidationScoringService.reduce(…)`, `ScoringService.calculateScore`, `ValidationScoringService.resolveThreshold`, `ValidationScoringService.resolveInstancePath`, `ValidationScoringService.some(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-scoring.service.ts:74` |
|
|
132
134
|
|
|
133
135
|
<details>
|
|
134
|
-
<summary>
|
|
136
|
+
<summary>26 more callables</summary>
|
|
135
137
|
|
|
136
138
|
| Callable | Breadth | Calls directly | Location |
|
|
137
139
|
| --- | --- | --- | --- |
|
|
138
|
-
| `
|
|
140
|
+
| `ValidationService.inferPlaceholders` | 5 | `ConfigurationService.prepareDocuments`, `ValidationService.readClaimedExtensions`, `RunnerService.captureDocuments`, `ValidationService.flatMap(…)`, `ValidationService.filter(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:102` |
|
|
141
|
+
| `RunnerService.runValidator` | 4 | `RunnerService.map(…)`, `RunnerService.filter(…)`, `RunnerService.filter(…)`, `RunnerService.reduce(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:108` |
|
|
142
|
+
| `ValidationFindingsService.reportMissingPlaceholders` | 3 | `ValidationFindingsService.filter(…)`, `ValidationFindingsService.map(…)`, `ValidationFindingsService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:109` |
|
|
143
|
+
| `ValidationService.map(…)` | 3 | `ValidationService.inferPlaceholders`, `ValidationFindingsService.reportMissingPlaceholders`, `ValidationService.compareInstance` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:205` |
|
|
139
144
|
| `ValidationDeduplicationService.deduplicate` | 2 | `ValidationDeduplicationService.selectOwners`, `ValidationDeduplicationService.flatMap(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-deduplication.service.ts:90` |
|
|
140
|
-
| `ValidationFindingsService.buildUnmatchedResults` | 2 | `ValidationFindingsService.resolveTemplatesRootPath`, `ValidationFindingsService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:
|
|
141
|
-
| `ValidationScoringService.scoreInstances` | 2 | `ValidationScoringService.scoreInstance`, `ValidationScoringService.resolveScoreKey` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-scoring.service.ts:
|
|
142
|
-
| `RunnerService.
|
|
143
|
-
| `RunnerService.
|
|
145
|
+
| `ValidationFindingsService.buildUnmatchedResults` | 2 | `ValidationFindingsService.resolveTemplatesRootPath`, `ValidationFindingsService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:69` |
|
|
146
|
+
| `ValidationScoringService.scoreInstances` | 2 | `ValidationScoringService.scoreInstance`, `ValidationScoringService.resolveScoreKey` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-scoring.service.ts:119` |
|
|
147
|
+
| `RunnerService.captureDocuments` | 1 | `RunnerService.reduce(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:75` |
|
|
148
|
+
| `RunnerService.reduce(…)` | 1 | `RunnerService.find(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:80` |
|
|
149
|
+
| `RunnerService.find(…)` | 1 | `RunnerService.claimsDocument` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:81` |
|
|
150
|
+
| `RunnerService.filter(…)` | 1 | `RunnerService.claimsDocument` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:112` |
|
|
151
|
+
| `RunnerService.map(…)` | 1 | `RunnerService.validateDocument` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/runner/runner.service.ts:115` |
|
|
144
152
|
| `ValidationDeduplicationService.selectOwners` | 1 | `ValidationDeduplicationService.compareInstances` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-deduplication.service.ts:57` |
|
|
145
153
|
| `ValidationDeduplicationService.flatMap(…)` | 1 | `ValidationDeduplicationService.filter(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-deduplication.service.ts:94` |
|
|
146
154
|
| `ValidationDeduplicationService.filter(…)` | 1 | `ValidationDeduplicationService.resolveFindingKey` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-deduplication.service.ts:95` |
|
|
147
|
-
| `ValidationFindingsService.resolveTemplatesRootPath` | 1 | `ValidationFindingsService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:
|
|
148
|
-
| `ValidationFindingsService.map(…)` | 1 | `ValidationFindingsService.describeReason` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:
|
|
155
|
+
| `ValidationFindingsService.resolveTemplatesRootPath` | 1 | `ValidationFindingsService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:58` |
|
|
156
|
+
| `ValidationFindingsService.map(…)` | 1 | `ValidationFindingsService.describeReason` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:75` |
|
|
157
|
+
| `ValidationFindingsService.map(…)` | 1 | `ValidationFindingsService.filter(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:121` |
|
|
158
|
+
| `ValidationFindingsService.filter(…)` | 1 | `ValidationFindingsService.some(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-findings.service.ts:124` |
|
|
149
159
|
| `ValidationScoringService.reduce(…)` | 1 | `ScoringService.sumWeights` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-scoring.service.ts:75` |
|
|
150
|
-
| `
|
|
151
|
-
| `ValidationService.
|
|
152
|
-
| `ValidationService.
|
|
153
|
-
| `ValidationService.
|
|
154
|
-
| `ValidationService.
|
|
160
|
+
| `ValidationScoringService.some(…)` | 1 | `ValidationScoringService.some(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation-scoring.service.ts:92` |
|
|
161
|
+
| `ValidationService.map(…)` | 1 | `RunnerService.runValidator` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:68` |
|
|
162
|
+
| `ValidationService.readClaimedExtensions` | 1 | `ValidationService.flatMap(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:142` |
|
|
163
|
+
| `ValidationService.readTemplateExtensions` | 1 | `ValidationService.flatMap(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:151` |
|
|
164
|
+
| `ValidationService.flatMap(…)` | 1 | `ValidationService.map(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:154` |
|
|
165
|
+
| `ValidationService.selectValidators` | 1 | `ValidationService.filter(…)` | `packages/ic-suite/conformetry/conformetry-validation/src/modules/validation/validation.service.ts:164` |
|
|
155
166
|
|
|
156
167
|
</details>
|
|
157
168
|
<!-- callidescope:end -->
|
|
@@ -279,6 +290,7 @@ graph LR
|
|
|
279
290
|
file_src_modules_validation_validation_deduplication_service_ts --> file_src_modules_validation_validation_types_ts
|
|
280
291
|
file_src_modules_validation_validation_deduplication_service_unit_test_ts --> file_src_modules_validation_validation_deduplication_service_ts
|
|
281
292
|
file_src_modules_validation_validation_deduplication_service_unit_test_ts --> file_src_modules_validation_validation_types_ts
|
|
293
|
+
file_src_modules_validation_validation_findings_service_ts --> file_src_modules_validation_validation_types_ts
|
|
282
294
|
file_src_modules_validation_validation_findings_service_unit_test_ts --> file_src_modules_validation_validation_findings_service_ts
|
|
283
295
|
file_src_modules_validation_validation_scoring_service_ts --> file_src_modules_validation_validation_constants_ts
|
|
284
296
|
file_src_modules_validation_validation_scoring_service_ts --> file_src_modules_validation_validation_types_ts
|
|
@@ -295,6 +307,7 @@ graph LR
|
|
|
295
307
|
file_src_modules_validation_validation_service_ts --> file_src_modules_validation_validation_types_ts
|
|
296
308
|
file_src_modules_validation_validation_service_unit_test_ts --> file_src_modules_validation_validation_module_ts
|
|
297
309
|
file_src_modules_validation_validation_service_unit_test_ts --> file_src_modules_validation_validation_service_ts
|
|
310
|
+
file_src_modules_validation_validation_service_unit_test_ts --> file_src_modules_validation_validation_types_ts
|
|
298
311
|
```
|
|
299
312
|
<!-- codependix:end name="codependix-file-imports" -->
|
|
300
313
|
|
|
@@ -304,23 +317,23 @@ graph LR
|
|
|
304
317
|
|
|
305
318
|
### Project
|
|
306
319
|
|
|
307
|
-

|
|
321
|
+

|
|
309
322
|

|
|
310
323
|

|
|
311
324
|
|
|
312
325
|
### Measured Targets
|
|
313
326
|
|
|
314
|
-

|
|
315
328
|
|
|
316
329
|
### TypeScript
|
|
317
330
|
|
|
318
331
|

|
|
319
|
-

|
|
320
333
|

|
|
321
334
|

|
|
322
335
|

|
|
323
|
-

|
|
324
337
|

|
|
325
338
|
|
|
326
339
|
### JavaScript
|
|
@@ -329,15 +342,15 @@ graph LR
|
|
|
329
342
|

|
|
330
343
|

|
|
331
344
|

|
|
332
|
-

|
|
346
|
+

|
|
347
|
+

|
|
348
|
+

|
|
349
|
+

|
|
350
|
+

|
|
351
|
+

|
|
352
|
+

|
|
353
|
+

|
|
341
354
|

|
|
342
355
|
|
|
343
356
|
### Python
|
|
@@ -358,16 +371,16 @@ graph LR
|
|
|
358
371
|
### JSON
|
|
359
372
|
|
|
360
373
|

|
|
361
|
-

|
|
362
375
|

|
|
363
376
|

|
|
364
377
|

|
|
365
|
-

|
|
366
379
|

|
|
367
380
|

|
|
368
381
|

|
|
369
|
-

|
|
383
|
+

|
|
371
384
|

|
|
372
385
|
|
|
373
386
|
### YAML
|
|
@@ -492,21 +505,21 @@ graph LR
|
|
|
492
505
|
|
|
493
506
|
### Markdown
|
|
494
507
|
|
|
495
|
-

|
|
509
|
+

|
|
497
510
|

|
|
498
|
-

|
|
512
|
+

|
|
500
513
|

|
|
501
514
|

|
|
502
515
|

|
|
503
|
-

|
|
517
|
+

|
|
518
|
+

|
|
506
519
|

|
|
507
520
|

|
|
508
521
|

|
|
509
|
-

|
|
510
523
|

|
|
511
524
|

|
|
512
525
|

|
package/dist/src/index.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ export declare class RunnerService {
|
|
|
57
57
|
private claimsDocument;
|
|
58
58
|
/** Compares one document and keeps its findings with its requirement size. */
|
|
59
59
|
private validateDocument;
|
|
60
|
+
/**
|
|
61
|
+
* Compares every document with the validator claiming it and collects what
|
|
62
|
+
* the placeholder values captured, keyed by value.
|
|
63
|
+
*
|
|
64
|
+
* Documents are visited in order and the first capture of a value is kept,
|
|
65
|
+
* so the value comes from the first file — and within it the first node —
|
|
66
|
+
* that revealed it.
|
|
67
|
+
*/
|
|
68
|
+
captureDocuments(args: {
|
|
69
|
+
documents: PreparedValidationDocument[];
|
|
70
|
+
validators: ConformetryLanguageValidator[];
|
|
71
|
+
}): Record<string, string>;
|
|
60
72
|
/**
|
|
61
73
|
* Selects the documents a validator claims and returns its aggregated
|
|
62
74
|
* result.
|
|
@@ -193,6 +205,17 @@ export declare class ValidationFindingsService {
|
|
|
193
205
|
templates: TemplateDefinition[];
|
|
194
206
|
unmatched: UnmatchedInstance[];
|
|
195
207
|
}): ValidationFileResult[];
|
|
208
|
+
/**
|
|
209
|
+
* Adds one finding per placeholder nothing in the instance revealed.
|
|
210
|
+
*
|
|
211
|
+
* `missing` maps each such placeholder to the random value it was still
|
|
212
|
+
* rendered with. Differences quoting that value are dropped: they restate
|
|
213
|
+
* the same gap in terms of a value nobody wrote, and the finding names it.
|
|
214
|
+
*/
|
|
215
|
+
reportMissingPlaceholders(args: {
|
|
216
|
+
group: InstanceFileResults;
|
|
217
|
+
missing: Record<string, string>;
|
|
218
|
+
}): InstanceFileResults;
|
|
196
219
|
}
|
|
197
220
|
|
|
198
221
|
/**
|
|
@@ -273,10 +296,6 @@ export declare class ValidationService {
|
|
|
273
296
|
private readonly validationFindingsService;
|
|
274
297
|
private readonly validationScoringService;
|
|
275
298
|
constructor(configurationService: ConfigurationService, filesService: FilesService, languagesService: LanguagesService, runnerService: RunnerService, validationDeduplicationService: ValidationDeduplicationService, validationFindingsService: ValidationFindingsService, validationScoringService: ValidationScoringService);
|
|
276
|
-
/** Every distinct file extension the matched templates declare. */
|
|
277
|
-
private readTemplateExtensions;
|
|
278
|
-
/** Narrows the resolved validators to the names the caller asked for. */
|
|
279
|
-
private selectValidators;
|
|
280
299
|
/**
|
|
281
300
|
* Checks one instance's files exist, then compares the documents whose
|
|
282
301
|
* extensions the selected validators claim.
|
|
@@ -284,7 +303,25 @@ export declare class ValidationService {
|
|
|
284
303
|
* File existence comes first because a missing file cannot be compared, and
|
|
285
304
|
* reporting it once is clearer than every language reporting it in turn.
|
|
286
305
|
*/
|
|
287
|
-
private
|
|
306
|
+
private compareInstance;
|
|
307
|
+
/**
|
|
308
|
+
* Fills in each placeholder nothing supplied from the instance itself.
|
|
309
|
+
*
|
|
310
|
+
* The template was rendered with a random value standing in for each one,
|
|
311
|
+
* and a first comparison captures the text of the instance node aligned with
|
|
312
|
+
* the first template node holding each value. The instance comes back with
|
|
313
|
+
* that text substituted, ready for the ordinary comparison — which is the
|
|
314
|
+
* consistency check, since a later occurrence holding different text is an
|
|
315
|
+
* ordinary difference. `missing` keeps the stand-in of every placeholder
|
|
316
|
+
* nothing revealed. The capture pass runs only when something is unresolved.
|
|
317
|
+
*/
|
|
318
|
+
private inferPlaceholders;
|
|
319
|
+
/** Every extension the selected validators claim. */
|
|
320
|
+
private readClaimedExtensions;
|
|
321
|
+
/** Every distinct file extension the matched templates declare. */
|
|
322
|
+
private readTemplateExtensions;
|
|
323
|
+
/** Narrows the resolved validators to the names the caller asked for. */
|
|
324
|
+
private selectValidators;
|
|
288
325
|
/**
|
|
289
326
|
* Validates every instance and returns the differences found.
|
|
290
327
|
*
|
package/dist/src/index.js
CHANGED
|
@@ -32,6 +32,15 @@ var p = class {
|
|
|
32
32
|
totalWeight: n
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
captureDocuments(e) {
|
|
36
|
+
return e.documents.reduce((t, n) => ({
|
|
37
|
+
...e.validators.find((e) => this.claimsDocument({
|
|
38
|
+
document: n,
|
|
39
|
+
validator: e
|
|
40
|
+
}))?.validateDocument(n).captures,
|
|
41
|
+
...t
|
|
42
|
+
}), {});
|
|
43
|
+
}
|
|
35
44
|
runValidator(e) {
|
|
36
45
|
let t = e.documents.filter((t) => this.claimsDocument({
|
|
37
46
|
document: t,
|
|
@@ -126,6 +135,33 @@ var g = class {
|
|
|
126
135
|
};
|
|
127
136
|
});
|
|
128
137
|
}
|
|
138
|
+
reportMissingPlaceholders(e) {
|
|
139
|
+
let t = Object.entries(e.missing);
|
|
140
|
+
if (t.length === 0) return e.group;
|
|
141
|
+
let { instance: r } = e.group.instance, i = e.group.fileResults.map((e) => ({
|
|
142
|
+
...e,
|
|
143
|
+
differences: e.differences.filter((e) => {
|
|
144
|
+
let n = JSON.stringify(e);
|
|
145
|
+
return !t.some(([, e]) => n.includes(e));
|
|
146
|
+
})
|
|
147
|
+
})).filter((e) => e.differences.length > 0);
|
|
148
|
+
return {
|
|
149
|
+
...e.group,
|
|
150
|
+
fileResults: [{
|
|
151
|
+
differences: t.map(([e]) => ({
|
|
152
|
+
differenceType: "placeholder",
|
|
153
|
+
fix: `Supply ${e} in the instance group's substitutions, or restore the template text that uses {{${e}}} in the instance.`,
|
|
154
|
+
message: `Could not infer {{${e}}}: no instance node aligned with the template text that uses it`,
|
|
155
|
+
weight: 1
|
|
156
|
+
})),
|
|
157
|
+
filename: r.nameStem,
|
|
158
|
+
instanceFilePath: n.join(r.path, r.nameStem),
|
|
159
|
+
templateFilePath: e.group.instance.template.directoryPath,
|
|
160
|
+
totalWeight: t.length
|
|
161
|
+
}, ...i],
|
|
162
|
+
totalWeight: e.group.totalWeight + t.length
|
|
163
|
+
};
|
|
164
|
+
}
|
|
129
165
|
};
|
|
130
166
|
g = f([e(), d("design:paramtypes", [])], g);
|
|
131
167
|
//#endregion
|
|
@@ -152,7 +188,7 @@ var _ = class {
|
|
|
152
188
|
return {
|
|
153
189
|
failedWeight: t,
|
|
154
190
|
instancePath: this.resolveInstancePath(e.instance),
|
|
155
|
-
ok: r >= i,
|
|
191
|
+
ok: r >= i && !e.fileResults.some((e) => e.differences.some((e) => e.differenceType === "placeholder")),
|
|
156
192
|
score: r,
|
|
157
193
|
templateName: e.instance.template.name,
|
|
158
194
|
threshold: i,
|
|
@@ -187,16 +223,9 @@ var v = class {
|
|
|
187
223
|
constructor(e, t, n, r, i, a, o) {
|
|
188
224
|
this.configurationService = e, this.filesService = t, this.languagesService = n, this.runnerService = r, this.validationDeduplicationService = i, this.validationFindingsService = a, this.validationScoringService = o;
|
|
189
225
|
}
|
|
190
|
-
|
|
191
|
-
return [...new Set(e.flatMap((e) => e.template.filePaths.map((e) => n.extname(e))))];
|
|
192
|
-
}
|
|
193
|
-
selectValidators(e) {
|
|
194
|
-
let { languageNames: t } = e;
|
|
195
|
-
return t === void 0 || t.length === 0 ? e.validators : e.validators.filter((e) => t.includes(e.descriptor.name));
|
|
196
|
-
}
|
|
197
|
-
validateInstance(e) {
|
|
226
|
+
compareInstance(e) {
|
|
198
227
|
let [t] = this.configurationService.prepareDocuments({
|
|
199
|
-
fileExtensions:
|
|
228
|
+
fileExtensions: this.readClaimedExtensions(e.validators),
|
|
200
229
|
instances: [e.instance]
|
|
201
230
|
}), n = this.filesService.checkInstanceFiles({ instances: [e.instance] }), r = e.validators.map((n) => this.runnerService.runValidator({
|
|
202
231
|
checkedPaths: [e.instance.instance.path],
|
|
@@ -209,6 +238,43 @@ var v = class {
|
|
|
209
238
|
totalWeight: r.reduce((e, t) => e + t.totalWeight, n.totalWeight)
|
|
210
239
|
};
|
|
211
240
|
}
|
|
241
|
+
inferPlaceholders(e) {
|
|
242
|
+
let t = Object.entries(e.instance.placeholderValues ?? {});
|
|
243
|
+
if (t.length === 0) return {
|
|
244
|
+
instance: e.instance,
|
|
245
|
+
missing: {}
|
|
246
|
+
};
|
|
247
|
+
let [n] = this.configurationService.prepareDocuments({
|
|
248
|
+
fileExtensions: this.readClaimedExtensions(e.validators),
|
|
249
|
+
instances: [e.instance]
|
|
250
|
+
}), r = this.runnerService.captureDocuments({
|
|
251
|
+
documents: n?.documents ?? [],
|
|
252
|
+
validators: e.validators
|
|
253
|
+
}), i = Object.fromEntries(t.flatMap(([e, t]) => {
|
|
254
|
+
let n = r[t];
|
|
255
|
+
return n === void 0 ? [] : [[e, n]];
|
|
256
|
+
}));
|
|
257
|
+
return {
|
|
258
|
+
instance: {
|
|
259
|
+
...e.instance,
|
|
260
|
+
substitutions: {
|
|
261
|
+
...e.instance.substitutions,
|
|
262
|
+
...i
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
missing: Object.fromEntries(t.filter(([e]) => !Object.hasOwn(i, e)))
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
readClaimedExtensions(e) {
|
|
269
|
+
return e.flatMap((e) => [...e.descriptor.fileExtensions]);
|
|
270
|
+
}
|
|
271
|
+
readTemplateExtensions(e) {
|
|
272
|
+
return [...new Set(e.flatMap((e) => e.template.filePaths.map((e) => n.extname(e))))];
|
|
273
|
+
}
|
|
274
|
+
selectValidators(e) {
|
|
275
|
+
let { languageNames: t } = e;
|
|
276
|
+
return t === void 0 || t.length === 0 ? e.validators : e.validators.filter((e) => t.includes(e.descriptor.name));
|
|
277
|
+
}
|
|
212
278
|
validate(e) {
|
|
213
279
|
let { matched: t, unmatched: n } = this.configurationService.matchInstances({
|
|
214
280
|
instances: e.instances,
|
|
@@ -216,10 +282,19 @@ var v = class {
|
|
|
216
282
|
}), r = this.selectValidators({
|
|
217
283
|
languageNames: e.languageNames,
|
|
218
284
|
validators: this.languagesService.resolveValidators({ extensions: this.readTemplateExtensions(t) })
|
|
219
|
-
}), i = t.map((e) =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
285
|
+
}), i = t.map((e) => {
|
|
286
|
+
let t = this.inferPlaceholders({
|
|
287
|
+
instance: e,
|
|
288
|
+
validators: r
|
|
289
|
+
});
|
|
290
|
+
return this.validationFindingsService.reportMissingPlaceholders({
|
|
291
|
+
group: this.compareInstance({
|
|
292
|
+
instance: t.instance,
|
|
293
|
+
validators: r
|
|
294
|
+
}),
|
|
295
|
+
missing: t.missing
|
|
296
|
+
});
|
|
297
|
+
}), a = this.validationScoringService.scoreInstances({
|
|
223
298
|
groups: i,
|
|
224
299
|
runThreshold: e.threshold
|
|
225
300
|
}), o = [...this.validationDeduplicationService.deduplicate(i), ...this.validationFindingsService.buildUnmatchedResults({
|
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"url": "https://github.com/organizzolini/codebase/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@conformetry/configuration": "0.0.
|
|
8
|
-
"@conformetry/core": "0.0.
|
|
9
|
-
"@conformetry/languages": "0.0.
|
|
7
|
+
"@conformetry/configuration": "0.0.6",
|
|
8
|
+
"@conformetry/core": "0.0.6",
|
|
9
|
+
"@conformetry/languages": "0.0.6",
|
|
10
10
|
"@nestjs/common": "^11.1.21 || ^12.0.1",
|
|
11
11
|
"reflect-metadata": "^0.2.2"
|
|
12
12
|
},
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
|
+
"CHANGELOG.md",
|
|
32
33
|
"dist",
|
|
33
34
|
"LICENSE",
|
|
34
35
|
"README.md"
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"strict": true
|
|
60
61
|
},
|
|
61
62
|
"types": "./dist/src/index.d.ts",
|
|
62
|
-
"version": "0.0.
|
|
63
|
+
"version": "0.0.6"
|
|
63
64
|
}
|