@hailstails/hone 2.0.0-pre.4 → 2.0.0-pre.5
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/ADOPTING.md +4 -15
- package/CHANGELOG.md +34 -0
- package/MIGRATING.md +6 -6
- package/README.md +3 -4
- package/chunks/{chunk-FPIP7JEC.js → chunk-4AJQHZ7I.js} +1 -1
- package/chunks/{chunk-CXM5KBZX.js → chunk-6LTJRJOE.js} +1 -1
- package/chunks/{chunk-PVSC4SE3.js → chunk-BISP2JOL.js} +4 -6
- package/chunks/{chunk-YGMO5Z6U.js → chunk-EFUWHLZK.js} +187 -193
- package/chunks/{chunk-BRANVR7K.js → chunk-FRE5IA3C.js} +1 -1
- package/chunks/{chunk-E4D5WDRX.js → chunk-GMLT3MHO.js} +252 -254
- package/chunks/chunk-M4VSJ27S.js +139 -0
- package/chunks/chunk-ND3EOGDK.js +2350 -0
- package/chunks/chunk-ONDBACCR.js +14332 -0
- package/chunks/{chunk-LD766VWU.js → chunk-U6W65ZOF.js} +31 -2
- package/chunks/{chunk-BKQ3K766.js → chunk-WPEOCLTP.js} +39 -33
- package/chunks/{chunk-A3RL4O5V.js → chunk-XNIXPQQ5.js} +35 -2
- package/docs/extending.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/package.json +1 -1
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +1 -1
- package/rules/numbers.md +4 -4
- package/rules/principles/no-leak-across-a-boundary.md +1 -1
- package/rules/principles.md +1 -1
- package/rules/record-kinds/authorised-location.md +1 -1
- package/rules/records.md +11 -19
- package/rules/rules.md +5 -5
- package/rules/sources.md +6 -7
- package/rules/typescript/checks.md +55 -387
- package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
- package/rules/typescript/recipes/assert-to-narrow.md +114 -4
- package/rules/typescript/recipes/closure-factory.md +5 -5
- package/rules/typescript/recipes/companion-test-file.md +5 -3
- package/rules/typescript/recipes/composed-orchestrator.md +6 -4
- package/rules/typescript/recipes/composition-root.md +5 -3
- package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
- package/rules/typescript/recipes/copy-never-write-in.md +6 -4
- package/rules/typescript/recipes/declared-not-bundled.md +5 -3
- package/rules/typescript/recipes/dependency-record.md +5 -3
- package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
- package/rules/typescript/recipes/entity-module.md +8 -5
- package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
- package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
- package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
- package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
- package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
- package/rules/typescript/recipes/functional-iteration.md +8 -3
- package/rules/typescript/recipes/guard-clauses.md +5 -3
- package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
- package/rules/typescript/recipes/integration-test-suffix.md +5 -3
- package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
- package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
- package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
- package/rules/typescript/recipes/named-exported-type.md +5 -3
- package/rules/typescript/recipes/narrow-ports.md +5 -3
- package/rules/typescript/recipes/one-argument-object.md +8 -3
- package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
- package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
- package/rules/typescript/recipes/repo-scripts-only.md +5 -3
- package/rules/typescript/recipes/result-union.md +5 -5
- package/rules/typescript/recipes/screaming-folders.md +5 -5
- package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
- package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
- package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
- package/rules/typescript/recipes/whole-words.md +5 -3
- package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
- package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
- package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
- package/rules/typescript/recipes.md +567 -21
- package/rules/typescript/symptoms/ambient-randomness.md +1 -1
- package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
- package/rules/typescript/symptoms/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site.md +1 -1
- package/rules/typescript/symptoms/{assertion-outside-a-test.md → assertion-outside-a-test-body.md} +1 -1
- package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
- package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
- package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
- package/rules/typescript/symptoms/{code-or-prose-read-as-text.md → code-or-prose-read-as-text-in-a-test.md} +2 -2
- package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
- package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
- package/rules/typescript/symptoms/date-used-directly.md +1 -1
- package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -18
- package/rules/typescript/symptoms/double-with-a-body.md +1 -1
- package/rules/typescript/symptoms/{export-from-a-test-file.md → export-from-a-test.md} +1 -1
- package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
- package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
- package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
- package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
- package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
- package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
- package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
- package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
- package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
- package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
- package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
- package/rules/typescript/symptoms/rebinding.md +11 -1
- package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
- package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
- package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
- package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +1 -1
- package/rules/typescript/symptoms/unasserted-call.md +1 -1
- package/rules/typescript/symptoms.md +35 -35
- package/src/domain/language-layer/authored-item-types.d.ts +21 -5
- package/src/domain/runner/runner-result-types.d.ts +1 -2
- package/src/eslint-plugin.js +40 -38
- package/src/hone.js +15 -13638
- package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
- package/src/infrastructure/engines/eslint/runner/runner.js +55 -45
- package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.js +1 -1
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +39 -65
- package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.js +1 -1
- package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.js +1 -1
- package/src/infrastructure/engines/walker/runner/runner.js +10 -10
- package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +3 -3
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +15 -3
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +118 -4
- package/src/measure-engines.process.js +80 -0
- package/src/testing.js +81 -9
- package/chunks/chunk-7FVSZ2VL.js +0 -1304
- package/chunks/chunk-BIDD2YWP.js +0 -398
- package/rules/record-kinds/boundary-record.md +0 -9
- package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
- package/rules/typescript/recipes/stub-with-vifn.md +0 -20
- /package/rules/typescript/symptoms/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read.md +0 -0
- /package/rules/typescript/symptoms/{export-from-a-test-file → export-from-a-test}/test-file-export.md +0 -0
- /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.examples.json +0 -0
- /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/piece.json +0 -0
- /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/piece.json +0 -0
- /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.examples.json +0 -0
- /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/piece.json +0 -0
- /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.examples.json +0 -0
|
@@ -0,0 +1,2350 @@
|
|
|
1
|
+
import {
|
|
2
|
+
symptomUnheldText
|
|
3
|
+
} from "./chunk-XNIXPQQ5.js";
|
|
4
|
+
import {
|
|
5
|
+
SETTINGS_FILE_NAME,
|
|
6
|
+
VERSION_ONE_SETTINGS_FILE_NAME,
|
|
7
|
+
checkAddressOf,
|
|
8
|
+
checksOf,
|
|
9
|
+
everyOk,
|
|
10
|
+
projectionOutputsOf,
|
|
11
|
+
repoPathBeneath,
|
|
12
|
+
repoPathOf
|
|
13
|
+
} from "./chunk-U6W65ZOF.js";
|
|
14
|
+
import {
|
|
15
|
+
ownedNameText,
|
|
16
|
+
readNamedPiece,
|
|
17
|
+
sameOwnedName
|
|
18
|
+
} from "./chunk-4AJQHZ7I.js";
|
|
19
|
+
import {
|
|
20
|
+
clauseAddressSchema
|
|
21
|
+
} from "./chunk-FRE5IA3C.js";
|
|
22
|
+
import {
|
|
23
|
+
CATALOGUE_NAME,
|
|
24
|
+
CHECK_ADDRESS_SEPARATOR,
|
|
25
|
+
NOT_INSTALLED,
|
|
26
|
+
TOOL_IDENTITY,
|
|
27
|
+
TOOL_RULE_SET,
|
|
28
|
+
absolutePathSchema,
|
|
29
|
+
anchorKindSchema,
|
|
30
|
+
checkAddressOfNames,
|
|
31
|
+
checkAddressTextOf,
|
|
32
|
+
checkNamesOf,
|
|
33
|
+
clauseAddressText,
|
|
34
|
+
engineIdSchema,
|
|
35
|
+
isCatalogueName,
|
|
36
|
+
isRepoPath,
|
|
37
|
+
parsedJson,
|
|
38
|
+
readVersionOneJson,
|
|
39
|
+
sameClauseAddress
|
|
40
|
+
} from "./chunk-WPEOCLTP.js";
|
|
41
|
+
import {
|
|
42
|
+
gatheredOutcomes
|
|
43
|
+
} from "./chunk-YONPKP3C.js";
|
|
44
|
+
import {
|
|
45
|
+
isRuleSetName
|
|
46
|
+
} from "./chunk-OO5KV7KN.js";
|
|
47
|
+
|
|
48
|
+
// src/domain/records/hone-records/records-layout.ts
|
|
49
|
+
var RECORDS_VERSION = 2;
|
|
50
|
+
var RECORDS_FOLDER = "hone-records";
|
|
51
|
+
var RECORDS_FILE_EXTENSION = ".json";
|
|
52
|
+
var RECORDS_ROOT = repoPathOf(RECORDS_FOLDER);
|
|
53
|
+
var NAMED_FOLDER_KINDS = [
|
|
54
|
+
"authorised-locations",
|
|
55
|
+
"debt",
|
|
56
|
+
"deviations"
|
|
57
|
+
];
|
|
58
|
+
var SINGLE_FILE_KINDS = ["dependency-records"];
|
|
59
|
+
var NOT_A_RECORDS_FILE = { standing: "not-a-records-file" };
|
|
60
|
+
var namedKindOf = (request) => NAMED_FOLDER_KINDS.find((candidate) => candidate === request.folder);
|
|
61
|
+
var namedFileOf = (request) => {
|
|
62
|
+
const kind = namedKindOf(request);
|
|
63
|
+
return kind === void 0 || !request.name.endsWith(RECORDS_FILE_EXTENSION) || request.name.length === RECORDS_FILE_EXTENSION.length ? NOT_A_RECORDS_FILE : {
|
|
64
|
+
standing: "named",
|
|
65
|
+
ruleSet: request.ruleSet,
|
|
66
|
+
kind,
|
|
67
|
+
name: request.name.slice(0, -RECORDS_FILE_EXTENSION.length)
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
var ruleSetOfFolder = (request) => isRuleSetName(request.folder) && request.folder !== TOOL_RULE_SET && namedKindOf(request) === void 0 ? { name: request.folder } : void 0;
|
|
71
|
+
var ruleSetFileOf = (request) => {
|
|
72
|
+
const ruleSet = ruleSetOfFolder(request);
|
|
73
|
+
return ruleSet === void 0 ? NOT_A_RECORDS_FILE : namedFileOf({ ruleSet, folder: request.kindFolder, name: request.name });
|
|
74
|
+
};
|
|
75
|
+
var singleFileOf = (request) => {
|
|
76
|
+
const kind = SINGLE_FILE_KINDS.find(
|
|
77
|
+
(candidate) => `${candidate}${RECORDS_FILE_EXTENSION}` === request.name
|
|
78
|
+
);
|
|
79
|
+
return kind === void 0 ? NOT_A_RECORDS_FILE : { standing: "single", kind };
|
|
80
|
+
};
|
|
81
|
+
var recordsFileStandingOf = (request) => {
|
|
82
|
+
const [root, first, second, third, ...rest] = request.file.split("/");
|
|
83
|
+
if (root !== RECORDS_FOLDER || first === void 0 || rest.length > 0) {
|
|
84
|
+
return NOT_A_RECORDS_FILE;
|
|
85
|
+
}
|
|
86
|
+
if (second === void 0) {
|
|
87
|
+
return singleFileOf({ name: first });
|
|
88
|
+
}
|
|
89
|
+
return third === void 0 ? namedFileOf({ ruleSet: TOOL_RULE_SET, folder: first, name: second }) : ruleSetFileOf({ folder: first, kindFolder: second, name: third });
|
|
90
|
+
};
|
|
91
|
+
var ruleSetFolderOf = (request) => request.ruleSet === TOOL_RULE_SET ? RECORDS_ROOT : repoPathBeneath({ parent: RECORDS_ROOT, segment: request.ruleSet.name });
|
|
92
|
+
var namedRecordsFileOf = (request) => {
|
|
93
|
+
const folder = repoPathBeneath({
|
|
94
|
+
parent: ruleSetFolderOf(request),
|
|
95
|
+
segment: request.kind
|
|
96
|
+
});
|
|
97
|
+
const file = `${folder}/${request.name}${RECORDS_FILE_EXTENSION}`;
|
|
98
|
+
return isCatalogueName(request.name) && isRepoPath(file) ? { outcome: "ok", value: file } : {
|
|
99
|
+
outcome: "failed",
|
|
100
|
+
error: { kind: "not-a-records-name", folder, name: request.name }
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/infrastructure/printed-report/printed-text.ts
|
|
105
|
+
var onOneLine = (request) => request.text.replaceAll("\n", "\\n").replaceAll("\r", "\\r");
|
|
106
|
+
var quoted = (request) => onOneLine({ text: JSON.stringify(request.text) });
|
|
107
|
+
var counted = (request) => request.count === 1 ? `1 ${request.noun}` : `${request.count} ${request.noun}s`;
|
|
108
|
+
|
|
109
|
+
// src/domain/records/hone-records/record-listings.ts
|
|
110
|
+
var reachNotesOf = (request) => {
|
|
111
|
+
const { record } = request;
|
|
112
|
+
return record.reach.reaches === "unknown-check" ? [{ kind: "unknown-check", symptom: record.symptom, check: record.reach.check }] : [];
|
|
113
|
+
};
|
|
114
|
+
var owingNotesOf = (request) => {
|
|
115
|
+
const { holding } = request.record;
|
|
116
|
+
return holding.held === "stated" && holding.owing.matches === "not-the-catalogue" ? [holding.owing.note] : [];
|
|
117
|
+
};
|
|
118
|
+
var catalogueNotesOf = (request) => [...reachNotesOf(request), ...owingNotesOf(request)];
|
|
119
|
+
var carriedOf = (request) => {
|
|
120
|
+
const { record } = request;
|
|
121
|
+
switch (record.kind) {
|
|
122
|
+
case "debt":
|
|
123
|
+
case "authorised-location":
|
|
124
|
+
return record.holding.held === "carried" ? [{ lacks: record.holding.lacks, standing: record.holding.standing }] : [];
|
|
125
|
+
case "deviation":
|
|
126
|
+
case "dependency-record":
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var carriedListingOf = (request) => request.records.flatMap(
|
|
131
|
+
({ place, record }) => carriedOf({ record }).map((carried) => ({ place, ...carried }))
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// src/infrastructure/printed-report/records/record-lines.ts
|
|
135
|
+
var WHOLE_RECORD = "record";
|
|
136
|
+
var SPLITS_A_FIELD = /[\s"]/;
|
|
137
|
+
var recordsFileText = (request) => SPLITS_A_FIELD.test(request.file) ? quoted({ text: request.file }) : request.file;
|
|
138
|
+
var recordPlaceText = (request) => `${recordsFileText(request.place)} records[${request.place.index}]`;
|
|
139
|
+
var outsidePartyText = (request) => {
|
|
140
|
+
switch (request.party.kind) {
|
|
141
|
+
case "package":
|
|
142
|
+
return request.party.dependency;
|
|
143
|
+
case "scheme-module":
|
|
144
|
+
return request.party.specifier;
|
|
145
|
+
case "scheme":
|
|
146
|
+
return request.party.scheme;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var bindingText = (request) => {
|
|
150
|
+
switch (request.binding.binds) {
|
|
151
|
+
case "check-and-file":
|
|
152
|
+
return "";
|
|
153
|
+
case "check-file-and-outside-party":
|
|
154
|
+
return ` for ${outsidePartyText({ party: request.binding.outsideParty })}`;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var catalogueNoteWords = (request) => {
|
|
158
|
+
switch (request.note.kind) {
|
|
159
|
+
case "unknown-check":
|
|
160
|
+
return `the catalogue has no check ${quoted({ text: request.note.check })} of ${request.note.symptom.name}`;
|
|
161
|
+
case "unknown-case":
|
|
162
|
+
return `the catalogue has no case ${quoted({ text: request.note.case })}, owing ${quoted({ text: request.note.owes })}`;
|
|
163
|
+
case "owes-not-owed":
|
|
164
|
+
return `${request.note.case.name} does not owe ${quoted({ text: request.note.owes })}`;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var carriedText = (request) => request.holding.held === "carried" ? " carried" : "";
|
|
168
|
+
var heldText = (request) => {
|
|
169
|
+
const { record } = request;
|
|
170
|
+
switch (record.kind) {
|
|
171
|
+
case "debt":
|
|
172
|
+
return carriedText(record);
|
|
173
|
+
case "authorised-location":
|
|
174
|
+
return `${carriedText(record)}${catalogueNotesOf({ record }).map((note) => ` note: ${catalogueNoteWords({ note })}`).join("")}`;
|
|
175
|
+
case "deviation":
|
|
176
|
+
case "dependency-record":
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var reachedText = (request) => {
|
|
181
|
+
const { symptom, reach } = request;
|
|
182
|
+
switch (reach.reaches) {
|
|
183
|
+
case "whole-symptom":
|
|
184
|
+
return symptom.name;
|
|
185
|
+
case "one-check":
|
|
186
|
+
return checkAddressOf({ check: reach.check });
|
|
187
|
+
case "unknown-check":
|
|
188
|
+
return `${symptom.name}#${reach.check}`;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var subjectOf = (request) => {
|
|
192
|
+
const { record } = request;
|
|
193
|
+
switch (record.kind) {
|
|
194
|
+
case "debt":
|
|
195
|
+
return `${reachedText(record)} ${record.kind} ${record.file}`;
|
|
196
|
+
case "authorised-location":
|
|
197
|
+
return `${reachedText(record)} ${record.kind} ${record.file}${bindingText(record.holding)}`;
|
|
198
|
+
case "deviation":
|
|
199
|
+
return `${record.recipe.name} ${record.kind} ${record.file}`;
|
|
200
|
+
case "dependency-record":
|
|
201
|
+
return `${record.dependency} ${record.kind}`;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var referenceOf = (request) => {
|
|
205
|
+
const { record } = request;
|
|
206
|
+
switch (record.kind) {
|
|
207
|
+
case "debt":
|
|
208
|
+
return record.kind;
|
|
209
|
+
case "authorised-location":
|
|
210
|
+
return `${record.kind}${bindingText(record.holding)}`;
|
|
211
|
+
case "deviation":
|
|
212
|
+
return `${record.kind} ${record.recipe.name}`;
|
|
213
|
+
case "dependency-record":
|
|
214
|
+
return `${record.kind} ${record.dependency}`;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var recordSubjectText = (request) => `${subjectOf(request)}${heldText(request)}`;
|
|
218
|
+
var recordReferenceText = (request) => `${referenceOf(request)}${heldText(request)}`;
|
|
219
|
+
var referencesText = (request) => request.records.map((placed2) => ` ${request.lead} ${recordReferenceText({ record: placed2.record })}`).join("");
|
|
220
|
+
var recordNoteLine = (request) => `${recordPlaceText(request.recordNote)} ${request.recordNote.note.kind}: ${catalogueNoteWords(request.recordNote)}`;
|
|
221
|
+
var issueText = (request) => {
|
|
222
|
+
const path = request.issue.path.length === 0 ? WHOLE_RECORD : request.issue.path.join(".");
|
|
223
|
+
return `${path}: ${request.issue.message}`;
|
|
224
|
+
};
|
|
225
|
+
var refusalDetail = (request) => {
|
|
226
|
+
const { refusal } = request;
|
|
227
|
+
switch (refusal.kind) {
|
|
228
|
+
case "form-refused":
|
|
229
|
+
return ` ${onOneLine({ text: refusal.issues.map((issue) => issueText({ issue })).join("; ") })}`;
|
|
230
|
+
case "unknown-symptom":
|
|
231
|
+
return ` ${quoted({ text: refusal.symptom })}`;
|
|
232
|
+
case "unknown-check":
|
|
233
|
+
return ` ${quoted({ text: refusal.check })} of ${refusal.symptom}`;
|
|
234
|
+
case "unknown-recipe":
|
|
235
|
+
return ` ${quoted({ text: refusal.recipe })}`;
|
|
236
|
+
case "recipe-reason-not-the-catalogues":
|
|
237
|
+
return ` ${refusal.recipe.name}: the catalogue gives its reason as ${quoted({ text: refusal.recipe.reason.text })}`;
|
|
238
|
+
case "named-ban":
|
|
239
|
+
return ` ${refusal.dependency}`;
|
|
240
|
+
case "no-check-named":
|
|
241
|
+
case "no-authorised-correct-use":
|
|
242
|
+
case "outside-party-missing":
|
|
243
|
+
case "outside-party-not-bound":
|
|
244
|
+
return ` ${refusal.symptom}`;
|
|
245
|
+
case "scheme-party-stated":
|
|
246
|
+
return ` ${refusal.outsideParty}, a whole scheme, which only an upgraded record holds`;
|
|
247
|
+
case "misplaced":
|
|
248
|
+
return ` ${refusal.belongsIn}`;
|
|
249
|
+
case "not-a-records-name":
|
|
250
|
+
return ` ${refusal.folder} ${quoted({ text: refusal.name })}`;
|
|
251
|
+
case "carried-changed-since-base":
|
|
252
|
+
return "";
|
|
253
|
+
case "held-at-moved-path":
|
|
254
|
+
return ` ${refusal.movedTo}: git moved its file there; run record-debt to repoint it`;
|
|
255
|
+
case "duplicate":
|
|
256
|
+
return ` of ${recordPlaceText({ place: refusal.of })}`;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
var refusalText = (request) => `${request.refusal.kind}${refusalDetail(request)}`;
|
|
260
|
+
var refusedLines = (request) => request.refused.refusals.map(
|
|
261
|
+
(refusal) => `${recordPlaceText(request.refused)} ${refusal.kind}${refusalDetail({ refusal })}`
|
|
262
|
+
);
|
|
263
|
+
var carriedLine = (request) => {
|
|
264
|
+
const lacks = request.listing.lacks.length === 0 ? "" : ` lacks ${request.listing.lacks.join(", ")}`;
|
|
265
|
+
return `${recordPlaceText(request.listing)} ${request.listing.standing}${lacks}`;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// src/infrastructure/command-line/nested-configuration-issue.ts
|
|
269
|
+
var NESTED_CONFIGURATION_ISSUE = `${TOOL_IDENTITY.repository}/issues/72`;
|
|
270
|
+
|
|
271
|
+
// src/infrastructure/printed-report/run-state-lines.ts
|
|
272
|
+
var PASS_A_BASE = "pass --base-revision with the branch's base, such as origin/main";
|
|
273
|
+
var LEAVE_FORFEITURE_ELSEWHERE = `leave forfeiture to another run with "forfeiture": "elsewhere" in ${SETTINGS_FILE_NAME} or --forfeiture elsewhere`;
|
|
274
|
+
var GENERATED_CONFIGURATION = "or, where a tool such as sku generates the configuration, last in the configuration the tool takes";
|
|
275
|
+
var BASE_NEEDS = {
|
|
276
|
+
"forfeiture-unmeasured": {
|
|
277
|
+
unchecked: "debt cannot be checked for forfeiture",
|
|
278
|
+
nextStep: `${PASS_A_BASE}, or ${LEAVE_FORFEITURE_ELSEWHERE}`,
|
|
279
|
+
gitAttempt: "list the files changed since that revision",
|
|
280
|
+
needs: `Hone needs that revision and the history back to where this branch left it, or ${LEAVE_FORFEITURE_ELSEWHERE}`
|
|
281
|
+
},
|
|
282
|
+
"import-unmeasured": {
|
|
283
|
+
unchecked: "carried records cannot be checked against it",
|
|
284
|
+
nextStep: `${PASS_A_BASE}, or ${LEAVE_FORFEITURE_ELSEWHERE}`,
|
|
285
|
+
gitAttempt: `read ${RECORDS_FOLDER} at that revision`,
|
|
286
|
+
needs: `Hone needs ${RECORDS_FOLDER} as it was at that revision`
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
var recordsUnmeasuredLine = (request) => {
|
|
290
|
+
const { kind, base } = request.unmeasured;
|
|
291
|
+
const needs = BASE_NEEDS[kind];
|
|
292
|
+
switch (base.state) {
|
|
293
|
+
case "not-given":
|
|
294
|
+
return `${kind} no-base-revision: no --base-revision was given, so ${needs.unchecked}; ${needs.nextStep}`;
|
|
295
|
+
case "git-failed":
|
|
296
|
+
return `${kind} base-git-failed ${quoted({ text: base.revision })}: git could not ${needs.gitAttempt} and said ${quoted({ text: base.gitMessage })}; ${needs.needs}`;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var projectionFileOf = (request) => projectionOutputsOf({ engineName: request.engine.name }).configuration;
|
|
300
|
+
var refreshStep = (request) => `run ${request.projectCommand} and commit every file it writes`;
|
|
301
|
+
var sliceNote = (request) => request.problems.some(
|
|
302
|
+
(problem) => problem.scope === "slice" && problem.engine.name === request.engine.name
|
|
303
|
+
) ? `; the ${request.engine.name} lines under projection-problems name the package slices involved` : "";
|
|
304
|
+
var nestedNote = (request) => request.folders.length === 0 ? "" : `; ${request.folders.join(", ")} hold their own ${SETTINGS_FILE_NAME}, and nested Hone configurations are not supported yet (${NESTED_CONFIGURATION_ISSUE}): to govern such a folder from this repository, remove its ${SETTINGS_FILE_NAME} and keep its records here, then run ${request.projectCommand}, which writes its slice`;
|
|
305
|
+
var measuredNothingNextStep = (request) => request.problems.some((problem) => problem.engine.name === request.engine.name) ? `the ${request.engine.name} lines under projection-problems name what to fix` : `check that the ${request.engine.name} configuration lints the files under check`;
|
|
306
|
+
var projectionMissingLine = (request) => {
|
|
307
|
+
const { engine } = request.unmeasured;
|
|
308
|
+
return `${request.unmeasured.kind} ${engine.name} missing: ${projectionFileOf({ engine })} is not written; ${refreshStep(request)}`;
|
|
309
|
+
};
|
|
310
|
+
var engineNotRunLine = (request) => {
|
|
311
|
+
const { unmeasured } = request;
|
|
312
|
+
const { engine } = unmeasured;
|
|
313
|
+
const file = projectionFileOf({ engine });
|
|
314
|
+
switch (unmeasured.projection) {
|
|
315
|
+
case "missing":
|
|
316
|
+
return projectionMissingLine({ ...request, unmeasured });
|
|
317
|
+
case "measured-nothing":
|
|
318
|
+
return `${unmeasured.kind} ${engine.name} measured-nothing: the ${engine.name} engine measured no file in this run, so the records its checks answer were not judged, neither kept as answering nor removed as stale; ${measuredNothingNextStep({ ...request, engine })}`;
|
|
319
|
+
case "not-included":
|
|
320
|
+
return `${unmeasured.kind} ${engine.name} not-included: the ${engine.name} configuration leaves the projection out of effect for a file under check; spread the default export of ${file}, or of a package's own ${file} in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), ${GENERATED_CONFIGURATION}${sliceNote({ ...request, engine })}${nestedNote({ ...request, folders: unmeasured.nestedConfigurations })}`;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var unmeasuredLine = (request) => {
|
|
324
|
+
const { unmeasured } = request;
|
|
325
|
+
switch (unmeasured.kind) {
|
|
326
|
+
case "forfeiture-unmeasured":
|
|
327
|
+
case "import-unmeasured":
|
|
328
|
+
return recordsUnmeasuredLine({ unmeasured });
|
|
329
|
+
case "engine-not-run":
|
|
330
|
+
return engineNotRunLine({ ...request, unmeasured });
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
var folderOf = (request) => request.slice.split("/").slice(0, -1).join("/");
|
|
334
|
+
var sliceProblemReason = (request) => {
|
|
335
|
+
const { engine, slice } = request.problem;
|
|
336
|
+
const folder = folderOf({ slice });
|
|
337
|
+
switch (request.problem.state) {
|
|
338
|
+
case "out-of-date":
|
|
339
|
+
return `that slice differs from what hone project writes now; ${refreshStep(request)}`;
|
|
340
|
+
case "missing":
|
|
341
|
+
return `that slice is not written; ${refreshStep(request)}`;
|
|
342
|
+
case "unconfigured":
|
|
343
|
+
return `${folder} has no ${engine.name} configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check`;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
var projectionProblemLine = (request) => {
|
|
347
|
+
const { problem } = request;
|
|
348
|
+
switch (problem.scope) {
|
|
349
|
+
case "projection":
|
|
350
|
+
return `${problem.engine.name} ${problem.state}: ${projectionFileOf(problem)} differs from what hone project writes now; ${refreshStep(request)}`;
|
|
351
|
+
case "slice":
|
|
352
|
+
return `${problem.engine.name} ${problem.state} ${problem.slice}: ${sliceProblemReason({ ...request, problem })}`;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var assessmentLine = (request) => {
|
|
356
|
+
const { partial } = request;
|
|
357
|
+
switch (partial.concern) {
|
|
358
|
+
case "forfeiture":
|
|
359
|
+
return `forfeiture ${partial.assessedBy}: ${counted({ count: partial.debts, noun: "debt record" })} not checked for forfeiture in this run`;
|
|
360
|
+
case "carried-standing":
|
|
361
|
+
return `carried standing ${partial.assessedBy}: ${counted({ count: partial.carried, noun: "carried record" })} not checked against the base in this run`;
|
|
362
|
+
case "nested-projection":
|
|
363
|
+
return `${partial.engine.name} not-included: the parent projection is out of effect under ${partial.folders.join(", ")}, where this run found local ${SETTINGS_FILE_NAME} files`;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var NOTE_KEY_TEXTS = {
|
|
367
|
+
generated: "generated",
|
|
368
|
+
layers: "layers"
|
|
369
|
+
};
|
|
370
|
+
var settingsNoteText = (request) => `${NOTE_KEY_TEXTS[request.note.key]} is declared; no check reads it yet`;
|
|
371
|
+
var settingsNoteLine = (request) => settingsNoteText(request);
|
|
372
|
+
|
|
373
|
+
// src/infrastructure/printed-report/load-failures/load-failure-lines.ts
|
|
374
|
+
var LOAD_FAILURE_LEAD = "load failure:";
|
|
375
|
+
var WHOLE_DOCUMENT = "document";
|
|
376
|
+
var ONE_RULE_TODAY = "these checks are one rule today, so they";
|
|
377
|
+
var LISTED_TO_RUN = "checkSettings gives settings only to a check listed to run";
|
|
378
|
+
var SUPPORTED_VERSION_REPAIR = "add a supported version to the devDependencies of the repository root";
|
|
379
|
+
var EACH_SUPPORTED_VERSION_REPAIR = "add a supported version of each to the devDependencies of the repository root";
|
|
380
|
+
var RECORDS_FILES = `a records file is ${SINGLE_FILE_KINDS.map((kind) => `${kind}${RECORDS_FILE_EXTENSION}`).join(" or ")}, or a ${RECORDS_FILE_EXTENSION} file named for its symptom, or for its recipe in ${NAMED_FOLDER_KINDS.at(-1)}, inside the folder ${NAMED_FOLDER_KINDS.slice(0, -1).join(", ")} or ${NAMED_FOLDER_KINDS.at(-1)} of ${RECORDS_FOLDER}`;
|
|
381
|
+
var engineText = (request) => request.engine.named === "engine" ? request.engine.engine.name : request.engine.mechanism;
|
|
382
|
+
var unavailablePeerRepair = (request) => request.peer.peer === "required" && request.peer.found === NOT_INSTALLED ? `${request.peer.packageName} is a required peer of ${TOOL_IDENTITY.packageName}, so this install is incomplete; ${SUPPORTED_VERSION_REPAIR} and reinstall` : SUPPORTED_VERSION_REPAIR;
|
|
383
|
+
var unavailablePeersRepair = (request) => {
|
|
384
|
+
const [first, ...rest] = request.peers;
|
|
385
|
+
return rest.length === 0 ? unavailablePeerRepair({ peer: first }) : EACH_SUPPORTED_VERSION_REPAIR;
|
|
386
|
+
};
|
|
387
|
+
var unavailablePeerText = (request) => `${request.peer.packageName} found ${request.peer.found}, supported ${request.peer.supported}`;
|
|
388
|
+
var runnerFailureFields = (request) => {
|
|
389
|
+
const { failure } = request;
|
|
390
|
+
switch (failure.kind) {
|
|
391
|
+
case "piece-invalid":
|
|
392
|
+
return [failure.kind, failure.pieceRoot, failure.detail];
|
|
393
|
+
case "file-unreadable":
|
|
394
|
+
case "file-unparseable":
|
|
395
|
+
return [failure.kind, failure.file, failure.detail];
|
|
396
|
+
case "toolchain-unavailable":
|
|
397
|
+
return [
|
|
398
|
+
failure.kind,
|
|
399
|
+
`${failure.peers.map((peer) => unavailablePeerText({ peer })).join("; ")}: ${unavailablePeersRepair({ peers: failure.peers })}`
|
|
400
|
+
];
|
|
401
|
+
case "toolchain-shadowed":
|
|
402
|
+
return [
|
|
403
|
+
failure.kind,
|
|
404
|
+
failure.packageName,
|
|
405
|
+
`resolved from ${failure.location} inside the core install ${failure.installRoot}: delete ${failure.installRoot}/node_modules, then reinstall the package with the repository's package manager, so the repository's own copy is used`
|
|
406
|
+
];
|
|
407
|
+
case "tool-failed":
|
|
408
|
+
case "plugin-conflict":
|
|
409
|
+
case "team-config-unloadable":
|
|
410
|
+
case "runner-invalid-output":
|
|
411
|
+
return [failure.kind, failure.detail];
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var allowedText = (request) => request.allowed.stated === "by-catalogue" ? `it runs on ${request.allowed.engines.join(" or ")}; list it with one of those` : "the rule set does not run that check on that engine, though its catalogue says it does; list the check with an engine its rule set runs it on, or correct the rule set";
|
|
415
|
+
var settingsListingRepair = (request) => request.listing === "unlisted" ? "list it under checks or remove its settings" : "run it or remove its settings";
|
|
416
|
+
var issueText2 = (request) => {
|
|
417
|
+
const path = request.issue.path.length === 0 ? WHOLE_DOCUMENT : request.issue.path.join(".");
|
|
418
|
+
return `${path}: ${onOneLine({ text: request.issue.message })}`;
|
|
419
|
+
};
|
|
420
|
+
var documentRefusalText = (request) => {
|
|
421
|
+
const { refusal } = request;
|
|
422
|
+
const lead = `${recordsFileText(refusal)} ${refusal.kind}`;
|
|
423
|
+
switch (refusal.kind) {
|
|
424
|
+
case "not-a-records-file":
|
|
425
|
+
return lead;
|
|
426
|
+
case "unknown-rule-set":
|
|
427
|
+
return `${lead} ${refusal.ruleSet}: no check this run reads comes from that rule set; declare it in ${SETTINGS_FILE_NAME} and list its checks, or remove its records`;
|
|
428
|
+
case "document-refused":
|
|
429
|
+
return `${lead} ${refusal.issues.map((issue) => issueText2({ issue })).join(", ")}`;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
var catalogueFields = (request) => {
|
|
433
|
+
const { failure } = request;
|
|
434
|
+
switch (failure.reason.reason) {
|
|
435
|
+
case "absent":
|
|
436
|
+
return [
|
|
437
|
+
`${failure.path}:`,
|
|
438
|
+
`the symptom catalogue is missing from this install; reinstall ${TOOL_IDENTITY.packageName}`
|
|
439
|
+
];
|
|
440
|
+
case "unreadable":
|
|
441
|
+
return [failure.path, failure.reason.detail];
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
var notReadyFields = ({ what }) => [
|
|
445
|
+
`${what.command}:`,
|
|
446
|
+
`this release runs ${what.command} on version 1 files only, and this repository holds ${SETTINGS_FILE_NAME}`
|
|
447
|
+
];
|
|
448
|
+
var CONFIG_ROOT_REPAIR = `an eslintConfigRoots entry is a folder git tracks files under outside every excluded path, spelled exactly as git spells it; fix or remove it in ${SETTINGS_FILE_NAME}`;
|
|
449
|
+
var toolFields = (request) => {
|
|
450
|
+
const { failure } = request;
|
|
451
|
+
switch (failure.kind) {
|
|
452
|
+
case "arguments-invalid":
|
|
453
|
+
case "git-failed":
|
|
454
|
+
case "unexpected-error":
|
|
455
|
+
return [failure.detail];
|
|
456
|
+
case "install-root-unresolvable":
|
|
457
|
+
return [failure.url, failure.detail];
|
|
458
|
+
case "file-unreadable":
|
|
459
|
+
case "file-malformed":
|
|
460
|
+
case "file-unwritable":
|
|
461
|
+
case "rule-set-invalid":
|
|
462
|
+
return [failure.path, failure.detail];
|
|
463
|
+
case "unsupported-version":
|
|
464
|
+
return [failure.path, String(JSON.stringify(failure.found))];
|
|
465
|
+
case "reserved-rule-set-name":
|
|
466
|
+
case "unknown-rule-set":
|
|
467
|
+
return [failure.name];
|
|
468
|
+
case "rule-set-name-collision":
|
|
469
|
+
return [failure.name, failure.other];
|
|
470
|
+
case "rule-sets-share-a-check":
|
|
471
|
+
return [
|
|
472
|
+
`${failure.check}:`,
|
|
473
|
+
`rule sets ${failure.ruleSets.join(" and ")} both hold this check, so its findings and records would be credited to the wrong one; rename the check in one of them`
|
|
474
|
+
];
|
|
475
|
+
case "config-root-untracked":
|
|
476
|
+
return [`${failure.root}:`, CONFIG_ROOT_REPAIR];
|
|
477
|
+
case "config-absent":
|
|
478
|
+
return [
|
|
479
|
+
failure.repo,
|
|
480
|
+
`holds no ${SETTINGS_FILE_NAME}; give the folder that holds it, usually the repository root`
|
|
481
|
+
];
|
|
482
|
+
case "settings-in-both-versions":
|
|
483
|
+
return [
|
|
484
|
+
`${failure.repo}:`,
|
|
485
|
+
`it holds both ${VERSION_ONE_SETTINGS_FILE_NAME} and ${SETTINGS_FILE_NAME}; keep the one this repository runs on and remove the other`
|
|
486
|
+
];
|
|
487
|
+
case "not-ready-yet":
|
|
488
|
+
return notReadyFields({ what: failure.what });
|
|
489
|
+
case "projection-stale":
|
|
490
|
+
return [
|
|
491
|
+
"scope" in failure.problem ? projectionProblemLine({ ...failure, problem: failure.problem }) : projectionMissingLine({ ...failure, unmeasured: failure.problem })
|
|
492
|
+
];
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
var checkFields = (request) => {
|
|
496
|
+
const { failure } = request;
|
|
497
|
+
switch (failure.kind) {
|
|
498
|
+
case "unknown-check":
|
|
499
|
+
return [failure.check];
|
|
500
|
+
case "review-only-listed":
|
|
501
|
+
return [
|
|
502
|
+
`${failure.check}:`,
|
|
503
|
+
"a check enforced by review has no engine and is left out of checks; remove it"
|
|
504
|
+
];
|
|
505
|
+
case "duplicate-check":
|
|
506
|
+
return [failure.key, failure.check, failure.prefixedCheck];
|
|
507
|
+
case "engine-not-allowed":
|
|
508
|
+
return [failure.check, `${failure.engine}:`, allowedText(failure)];
|
|
509
|
+
case "engine-missing":
|
|
510
|
+
return [engineText(failure)];
|
|
511
|
+
case "engine-invalid":
|
|
512
|
+
return [engineText(failure), failure.detail];
|
|
513
|
+
case "engine-failed":
|
|
514
|
+
return [engineText(failure), ...runnerFailureFields({ failure: failure.failure })];
|
|
515
|
+
case "check-missing":
|
|
516
|
+
return [failure.check, engineText(failure)];
|
|
517
|
+
case "checks-run-together":
|
|
518
|
+
return [
|
|
519
|
+
failure.check,
|
|
520
|
+
`${failure.others.join(" ")}:`,
|
|
521
|
+
`${ONE_RULE_TODAY} run together; list each of them as ${failure.check} is listed`
|
|
522
|
+
];
|
|
523
|
+
case "check-settings-refused":
|
|
524
|
+
return [
|
|
525
|
+
failure.check,
|
|
526
|
+
`${failure.listing}:`,
|
|
527
|
+
`${LISTED_TO_RUN}; ${settingsListingRepair(failure)}`
|
|
528
|
+
];
|
|
529
|
+
case "check-settings-differ":
|
|
530
|
+
return [
|
|
531
|
+
failure.check,
|
|
532
|
+
`${failure.other}:`,
|
|
533
|
+
`${ONE_RULE_TODAY} take one set of settings; give them the same settings`
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
var upgradeCommandText = (request) => request.upgradeCommand ?? "hone upgrade";
|
|
538
|
+
var recordsFields = (request) => {
|
|
539
|
+
const { failure } = request;
|
|
540
|
+
switch (failure.kind) {
|
|
541
|
+
case "records-folder-unreadable":
|
|
542
|
+
return [recordsFileText({ file: failure.folder }), failure.detail];
|
|
543
|
+
case "records-file-unreadable":
|
|
544
|
+
case "records-file-not-json":
|
|
545
|
+
return [recordsFileText(failure), failure.detail];
|
|
546
|
+
case "not-a-records-file":
|
|
547
|
+
return [
|
|
548
|
+
`${recordsFileText(failure)}:`,
|
|
549
|
+
`${RECORDS_FILES}; move this file to where its kind belongs, or out of ${RECORDS_FOLDER} if it holds no records`
|
|
550
|
+
];
|
|
551
|
+
case "not-a-records-name":
|
|
552
|
+
return [
|
|
553
|
+
recordsFileText({ file: failure.folder }),
|
|
554
|
+
`${quoted({ text: failure.name })}:`,
|
|
555
|
+
"no repository path can hold that name; rename it"
|
|
556
|
+
];
|
|
557
|
+
case "records-refused":
|
|
558
|
+
return [failure.refusals.map((refusal) => documentRefusalText({ refusal })).join("; ")];
|
|
559
|
+
case "catalogue-not-read":
|
|
560
|
+
return catalogueFields({ failure });
|
|
561
|
+
case "upgrade-needed":
|
|
562
|
+
return [
|
|
563
|
+
`${failure.path}:`,
|
|
564
|
+
`this is a version 1 file; run ${upgradeCommandText(request)}, which rewrites every version 1 file as version 2, and commit what it writes`
|
|
565
|
+
];
|
|
566
|
+
case "rule-set-not-upgraded":
|
|
567
|
+
return [
|
|
568
|
+
`${failure.path}:`,
|
|
569
|
+
`this rule set is in the version 1 layout; run ${upgradeCommandText(request)}, which rewrites it as version 2, and commit what it writes`
|
|
570
|
+
];
|
|
571
|
+
case "rule-set-half-upgraded":
|
|
572
|
+
return [
|
|
573
|
+
`${failure.path}:`,
|
|
574
|
+
"this rule set holds both version 1 discipline files and version 2 items, so an upgrade stopped part way; remove these version 1 files, or restore the rule set from version control and run the upgrade again:",
|
|
575
|
+
...failure.files
|
|
576
|
+
];
|
|
577
|
+
case "symptom-unheld":
|
|
578
|
+
return [symptomUnheldText({ failure })];
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
var failureFields = (request) => {
|
|
582
|
+
const { failure } = request;
|
|
583
|
+
switch (failure.kind) {
|
|
584
|
+
case "arguments-invalid":
|
|
585
|
+
case "git-failed":
|
|
586
|
+
case "unexpected-error":
|
|
587
|
+
case "install-root-unresolvable":
|
|
588
|
+
case "file-unreadable":
|
|
589
|
+
case "file-malformed":
|
|
590
|
+
case "file-unwritable":
|
|
591
|
+
case "rule-set-invalid":
|
|
592
|
+
case "unsupported-version":
|
|
593
|
+
case "reserved-rule-set-name":
|
|
594
|
+
case "unknown-rule-set":
|
|
595
|
+
case "rule-set-name-collision":
|
|
596
|
+
case "rule-sets-share-a-check":
|
|
597
|
+
case "config-root-untracked":
|
|
598
|
+
case "config-absent":
|
|
599
|
+
case "settings-in-both-versions":
|
|
600
|
+
case "not-ready-yet":
|
|
601
|
+
case "projection-stale":
|
|
602
|
+
return toolFields({ failure });
|
|
603
|
+
case "unknown-check":
|
|
604
|
+
case "review-only-listed":
|
|
605
|
+
case "duplicate-check":
|
|
606
|
+
case "engine-not-allowed":
|
|
607
|
+
case "engine-missing":
|
|
608
|
+
case "engine-invalid":
|
|
609
|
+
case "engine-failed":
|
|
610
|
+
case "check-missing":
|
|
611
|
+
case "checks-run-together":
|
|
612
|
+
case "check-settings-refused":
|
|
613
|
+
case "check-settings-differ":
|
|
614
|
+
return checkFields({ failure });
|
|
615
|
+
case "records-folder-unreadable":
|
|
616
|
+
case "records-file-unreadable":
|
|
617
|
+
case "records-file-not-json":
|
|
618
|
+
case "not-a-records-file":
|
|
619
|
+
case "not-a-records-name":
|
|
620
|
+
case "records-refused":
|
|
621
|
+
case "catalogue-not-read":
|
|
622
|
+
case "upgrade-needed":
|
|
623
|
+
case "rule-set-not-upgraded":
|
|
624
|
+
case "rule-set-half-upgraded":
|
|
625
|
+
case "symptom-unheld":
|
|
626
|
+
return recordsFields({ failure, upgradeCommand: request.upgradeCommand });
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var runLoadFailureLine = (request) => [
|
|
630
|
+
LOAD_FAILURE_LEAD,
|
|
631
|
+
request.failure.kind,
|
|
632
|
+
...failureFields(request).map((text) => onOneLine({ text }))
|
|
633
|
+
].join(" ");
|
|
634
|
+
|
|
635
|
+
// src/domain/language-layer/catalogue-binding.ts
|
|
636
|
+
var boundCheckOf = (request) => ({
|
|
637
|
+
check: request.check,
|
|
638
|
+
engines: request.bindings.get(checkAddressTextOf(request)) ?? []
|
|
639
|
+
});
|
|
640
|
+
var checkOf = (bound) => ({ ...bound.check, engines: bound.engines });
|
|
641
|
+
var catalogueBoundTo = (request) => {
|
|
642
|
+
const bound = request.content.checks.map(
|
|
643
|
+
(check) => boundCheckOf({ check, bindings: request.bindings })
|
|
644
|
+
);
|
|
645
|
+
const unrun = bound.filter((each) => each.engines.length === 0).map((each) => checkAddressTextOf({ check: each.check }));
|
|
646
|
+
return unrun.length > 0 ? { outcome: "failed", error: `no piece runs the clause of ${unrun.join(", ")}` } : { outcome: "ok", value: { ...request.content, checks: bound.map(checkOf) } };
|
|
647
|
+
};
|
|
648
|
+
var holdingBoundTo = (request) => {
|
|
649
|
+
if (request.holding.held === "none") {
|
|
650
|
+
return { outcome: "ok", value: request.holding };
|
|
651
|
+
}
|
|
652
|
+
const catalogue = catalogueBoundTo({
|
|
653
|
+
content: request.holding.content,
|
|
654
|
+
bindings: request.bindings
|
|
655
|
+
});
|
|
656
|
+
return catalogue.outcome === "failed" ? catalogue : { outcome: "ok", value: { held: "catalogue", catalogue: catalogue.value } };
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// src/domain/language-layer/symptom-catalogue-location.ts
|
|
660
|
+
var SYMPTOM_CATALOGUE_SEGMENTS = ["rules"];
|
|
661
|
+
|
|
662
|
+
// src/infrastructure/engines/engine-registry.ts
|
|
663
|
+
var ENGINE_REGISTRY = [{ name: "walker" }, { name: "eslint" }];
|
|
664
|
+
|
|
665
|
+
// src/infrastructure/engines/piece-engines.ts
|
|
666
|
+
var allBound = (bounds) => {
|
|
667
|
+
const failure = bounds.find((bound) => bound.outcome === "failed");
|
|
668
|
+
return failure ?? {
|
|
669
|
+
outcome: "ok",
|
|
670
|
+
value: bounds.flatMap((bound) => bound.outcome === "ok" ? bound.value : [])
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
var bindingsByAddress = (bindings) => {
|
|
674
|
+
const byAddress = /* @__PURE__ */ new Map();
|
|
675
|
+
bindings.forEach(({ address, engine }) => {
|
|
676
|
+
const engines = byAddress.get(address) ?? [];
|
|
677
|
+
if (!engines.some(({ name }) => name === engine.name)) {
|
|
678
|
+
byAddress.set(address, [...engines, engine]);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
return byAddress;
|
|
682
|
+
};
|
|
683
|
+
var namedBindingOf = (request) => {
|
|
684
|
+
const address = checkAddressTextOf(request);
|
|
685
|
+
const names = checkNamesOf({ text: address });
|
|
686
|
+
if (names === void 0) {
|
|
687
|
+
return { outcome: "ok", value: [] };
|
|
688
|
+
}
|
|
689
|
+
const piece = readNamedPiece({ ...request.source, ...names, mechanism: request.engine.name });
|
|
690
|
+
if (piece.outcome === "ok") {
|
|
691
|
+
return { outcome: "ok", value: [{ address, engine: request.engine }] };
|
|
692
|
+
}
|
|
693
|
+
return piece.error.kind === "piece-missing" ? { outcome: "ok", value: [] } : piece;
|
|
694
|
+
};
|
|
695
|
+
var readEngineBindings = (source, checks) => {
|
|
696
|
+
const bound = allBound(
|
|
697
|
+
ENGINE_REGISTRY.flatMap(
|
|
698
|
+
(engine) => checks.map((check) => namedBindingOf({ source, engine, check }))
|
|
699
|
+
)
|
|
700
|
+
);
|
|
701
|
+
return bound.outcome === "failed" ? bound : { outcome: "ok", value: bindingsByAddress(bound.value) };
|
|
702
|
+
};
|
|
703
|
+
var createEngineBindingsRepository = (options) => ({
|
|
704
|
+
read: (request) => readEngineBindings(options, request.checks)
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
// src/infrastructure/disciplines-file/version-one-names.ts
|
|
708
|
+
import { z as z2 } from "zod";
|
|
709
|
+
|
|
710
|
+
// src/infrastructure/content-files/symptom-catalogues/symptom-catalogue-wire.ts
|
|
711
|
+
import { z } from "zod";
|
|
712
|
+
|
|
713
|
+
// src/domain/language-layer/symptom-catalogue.ts
|
|
714
|
+
var pointedNameOf = (request) => request.point.kind === "rule" ? request.point.rule.name : request.point.principle.name;
|
|
715
|
+
var indicatedNamesOf = (request) => [
|
|
716
|
+
...new Set(
|
|
717
|
+
request.symptom.mayIndicate.flatMap(
|
|
718
|
+
(indication) => indication.points.map((point) => pointedNameOf({ point }))
|
|
719
|
+
)
|
|
720
|
+
)
|
|
721
|
+
];
|
|
722
|
+
var NOT_IN_CATALOGUE = { reading: "not-in-catalogue" };
|
|
723
|
+
var formReadingOf = (request) => {
|
|
724
|
+
const form = request.forms.find((candidate) => candidate.form === request.remedy?.form);
|
|
725
|
+
return form === void 0 ? NOT_IN_CATALOGUE : { reading: "named", symptom: form.symptom };
|
|
726
|
+
};
|
|
727
|
+
var sightReadingOf = (request) => {
|
|
728
|
+
switch (request.sight.kind) {
|
|
729
|
+
case "one-symptom":
|
|
730
|
+
return { reading: "named", symptom: request.sight.symptom };
|
|
731
|
+
case "symptom-by-form":
|
|
732
|
+
return formReadingOf({ forms: request.sight.forms, remedy: request.remedy });
|
|
733
|
+
case "method":
|
|
734
|
+
case "outside-the-cases":
|
|
735
|
+
return { reading: "sees-no-symptom" };
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
var symptomReadingOf = (request) => {
|
|
739
|
+
const catalogued = request.catalogue.clauses.find(
|
|
740
|
+
(entry) => sameClauseAddress({ left: entry.clause, right: request.finding.clause }) === "same"
|
|
741
|
+
);
|
|
742
|
+
return catalogued === void 0 ? NOT_IN_CATALOGUE : sightReadingOf({ sight: catalogued.sight, remedy: request.finding.remedy });
|
|
743
|
+
};
|
|
744
|
+
var mapSpecificsToBinding = (request) => request.specifics.includes("outside-party") ? "check-file-and-outside-party" : "check-and-file";
|
|
745
|
+
var mapSymptomToAuthorisation = (request) => {
|
|
746
|
+
const [binding] = request.symptom.correctUses.flatMap(
|
|
747
|
+
(use) => "binding" in use ? [use.binding] : []
|
|
748
|
+
);
|
|
749
|
+
return binding ?? "no-correct-use";
|
|
750
|
+
};
|
|
751
|
+
var mapCheckToPartyNaming = (request) => request.check.findingSpecifics.includes("outside-party") ? "names-the-party" : "names-no-party";
|
|
752
|
+
|
|
753
|
+
// src/domain/language-layer/binding-invariants.ts
|
|
754
|
+
var listDivergentBindings = (request) => {
|
|
755
|
+
const bindings = new Set(
|
|
756
|
+
request.symptom.correctUses.flatMap((use) => "binding" in use ? [use.binding] : [])
|
|
757
|
+
);
|
|
758
|
+
return bindings.size > 1 ? [{ kind: "divergent-bindings", symptom: request.symptom.name }] : [];
|
|
759
|
+
};
|
|
760
|
+
var listUnreportedBindings = (request) => request.symptoms.filter((symptom) => mapSymptomToAuthorisation({ symptom }) === "check-file-and-outside-party").flatMap(
|
|
761
|
+
(symptom) => request.checks.filter(
|
|
762
|
+
(check) => check.symptom.name === symptom.name && mapCheckToPartyNaming({ check }) === "names-no-party"
|
|
763
|
+
).map((check) => ({
|
|
764
|
+
kind: "binding-not-reported",
|
|
765
|
+
symptom: symptom.name,
|
|
766
|
+
check: check.name
|
|
767
|
+
}))
|
|
768
|
+
);
|
|
769
|
+
|
|
770
|
+
// src/domain/language-layer/case-name.ts
|
|
771
|
+
var TITLE_PARENTHETICAL = /\s*\([^)]*\)/g;
|
|
772
|
+
var NOT_A_NAME_CHARACTER = /[^a-z0-9]+/g;
|
|
773
|
+
var EDGE_HYPHEN = /^-|-$/g;
|
|
774
|
+
var mapTitleToCaseName = (request) => request.title.replace(TITLE_PARENTHETICAL, "").toLowerCase().replace(NOT_A_NAME_CHARACTER, "-").replace(EDGE_HYPHEN, "");
|
|
775
|
+
var findCaseNameFaults = (request) => {
|
|
776
|
+
const titled = mapTitleToCaseName(request);
|
|
777
|
+
return request.name === titled ? [] : [`cases names ${request.name}, which its title ${request.title} names ${titled}`];
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// src/domain/language-layer/catalogue-address.ts
|
|
781
|
+
var mapSymptomToAddress = (request) => ({
|
|
782
|
+
ruleSet: request.symptom.ruleSet,
|
|
783
|
+
name: request.symptom.name
|
|
784
|
+
});
|
|
785
|
+
var mapCheckToAddress = (request) => ({
|
|
786
|
+
name: request.check.name,
|
|
787
|
+
symptom: request.check.symptom
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
// src/domain/language-layer/owed-points.ts
|
|
791
|
+
var compareOwedPoints = (request) => request.left.kind === request.right.kind && request.left.name === request.right.name ? "same" : "different";
|
|
792
|
+
var findOwedPoint = (request) => request.owes.find(
|
|
793
|
+
(owed) => compareOwedPoints({ left: request.mapOwedToPoint(owed), right: request.point }) === "same"
|
|
794
|
+
);
|
|
795
|
+
var mapPointsToUnowed = (request) => request.points.filter(
|
|
796
|
+
(point) => findOwedPoint({ owes: request.owes, point, mapOwedToPoint: (owed) => owed }) === void 0
|
|
797
|
+
);
|
|
798
|
+
var createUnowedPointFault = (request) => `${request.symptom} points ${request.owing} at ${request.point.name}, which ${request.owing} does not owe`;
|
|
799
|
+
var findUnowedPointFaults = (request) => mapPointsToUnowed({ owes: request.owing.owes, points: request.points }).map(
|
|
800
|
+
(point) => createUnowedPointFault({ symptom: request.symptom, owing: request.owing.name, point })
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
// src/domain/language-layer/recipe-reach.ts
|
|
804
|
+
var mapPointToReach = (request) => {
|
|
805
|
+
const { point, serves } = request;
|
|
806
|
+
if (point.kind === "rule") {
|
|
807
|
+
return serves.kind === "rule" && serves.rule.name === point.rule.name ? "reached" : "not-reached";
|
|
808
|
+
}
|
|
809
|
+
const principle = serves.kind === "rule" ? serves.rule.principle : serves.principle;
|
|
810
|
+
return principle.name === point.principle.name ? "reached" : "not-reached";
|
|
811
|
+
};
|
|
812
|
+
var mapSymptomToReach = (request) => {
|
|
813
|
+
const points = request.symptom.mayIndicate.flatMap((indication) => indication.points);
|
|
814
|
+
return request.serves.some(
|
|
815
|
+
(serves) => points.some((point) => mapPointToReach({ point, serves }) === "reached")
|
|
816
|
+
) ? "reached" : "not-reached";
|
|
817
|
+
};
|
|
818
|
+
var findRecipeFaults = (request) => request.recipes.filter(({ serves }) => mapSymptomToReach({ ...request, serves }) === "not-reached").map(({ name, serves }) => ({
|
|
819
|
+
kind: "recipe-not-indicated",
|
|
820
|
+
symptom: request.symptom.name,
|
|
821
|
+
recipe: name,
|
|
822
|
+
serves: serves.map((point) => pointedNameOf({ point }))
|
|
823
|
+
}));
|
|
824
|
+
|
|
825
|
+
// src/domain/language-layer/recipe-examples.ts
|
|
826
|
+
var compareCheckAddresses = (request) => request.left.name === request.right.name ? sameOwnedName({ left: request.left.symptom, right: request.right.symptom }) : "different";
|
|
827
|
+
var findCheckFaults = (request) => {
|
|
828
|
+
const { check, serves } = request;
|
|
829
|
+
const answering = {
|
|
830
|
+
recipe: request.recipe.name,
|
|
831
|
+
anchor: request.anchor,
|
|
832
|
+
check: checkAddressTextOf({ check })
|
|
833
|
+
};
|
|
834
|
+
const held = request.checks.find(
|
|
835
|
+
(candidate) => compareCheckAddresses({ left: candidate, right: check }) === "same"
|
|
836
|
+
);
|
|
837
|
+
const symptom = request.symptoms.find(
|
|
838
|
+
(candidate) => sameOwnedName({ left: candidate, right: check.symptom }) === "same"
|
|
839
|
+
);
|
|
840
|
+
if (held === void 0 || symptom === void 0) {
|
|
841
|
+
return [{ kind: "check-unheld", ...answering }];
|
|
842
|
+
}
|
|
843
|
+
return mapSymptomToReach({ symptom, serves }) === "reached" ? [] : [
|
|
844
|
+
{
|
|
845
|
+
kind: "recipe-not-indicated",
|
|
846
|
+
...answering,
|
|
847
|
+
symptom: symptom.name,
|
|
848
|
+
serves: serves.map((point) => pointedNameOf({ point }))
|
|
849
|
+
}
|
|
850
|
+
];
|
|
851
|
+
};
|
|
852
|
+
var findExampleFaults = (request) => (request.recipe.examples ?? []).flatMap(
|
|
853
|
+
({ anchor, answers }) => answers.flatMap(({ check }) => findCheckFaults({ ...request, anchor, check }))
|
|
854
|
+
);
|
|
855
|
+
var mapExampleToReach = (request) => request.example.answers.some(
|
|
856
|
+
(answer) => answer.form === request.form && compareCheckAddresses({ left: answer.check, right: request.check }) === "same"
|
|
857
|
+
) ? "reached" : "not-reached";
|
|
858
|
+
var listExamplesOfForm = (request) => request.recipes.flatMap(
|
|
859
|
+
(recipe) => (recipe.examples ?? []).filter((example) => mapExampleToReach({ ...request, example }) === "reached").map(({ anchor }) => ({ recipe, anchor }))
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
// src/infrastructure/content-files/symptom-catalogues/symptom-catalogue-wire.ts
|
|
863
|
+
var SUPPORTED_VERSION = 1;
|
|
864
|
+
var NOT_A_CATALOGUE_NAME = "is not a lower-case hyphenated name";
|
|
865
|
+
var catalogueNameSchema = z.string().regex(new RegExp(`^${CATALOGUE_NAME}$`), { error: NOT_A_CATALOGUE_NAME });
|
|
866
|
+
var textSchema = z.string().min(1);
|
|
867
|
+
var standingSchema = z.enum(["accepted", "proposed"]);
|
|
868
|
+
var recordKindNameSchema = z.enum([
|
|
869
|
+
"authorised-location",
|
|
870
|
+
"deviation",
|
|
871
|
+
"debt",
|
|
872
|
+
"dependency-record"
|
|
873
|
+
]);
|
|
874
|
+
var pointedWireSchema = z.union([
|
|
875
|
+
z.strictObject({ rule: catalogueNameSchema }),
|
|
876
|
+
z.strictObject({ principle: catalogueNameSchema })
|
|
877
|
+
]);
|
|
878
|
+
var caseWireSchema = z.strictObject({
|
|
879
|
+
name: catalogueNameSchema,
|
|
880
|
+
title: textSchema,
|
|
881
|
+
standing: standingSchema,
|
|
882
|
+
owes: z.array(pointedWireSchema).min(1)
|
|
883
|
+
});
|
|
884
|
+
var specificSchema = z.enum(["outside-party"]);
|
|
885
|
+
var specificsSchema = z.array(specificSchema).min(1);
|
|
886
|
+
var correctUseWireSchema = z.discriminatedUnion("kind", [
|
|
887
|
+
z.strictObject({
|
|
888
|
+
situation: textSchema,
|
|
889
|
+
kind: z.literal("authorised-location"),
|
|
890
|
+
at: textSchema.optional(),
|
|
891
|
+
binds: specificsSchema.optional()
|
|
892
|
+
}),
|
|
893
|
+
z.strictObject({
|
|
894
|
+
situation: textSchema,
|
|
895
|
+
kind: recordKindNameSchema.exclude(["authorised-location"]),
|
|
896
|
+
at: textSchema.optional()
|
|
897
|
+
})
|
|
898
|
+
]);
|
|
899
|
+
var seenBySchema = z.enum([
|
|
900
|
+
"syntax",
|
|
901
|
+
"types",
|
|
902
|
+
"graph",
|
|
903
|
+
"app",
|
|
904
|
+
"files",
|
|
905
|
+
"history",
|
|
906
|
+
"person"
|
|
907
|
+
]);
|
|
908
|
+
var reportsSchema = z.enum(["seen", "seen-to-breach"]);
|
|
909
|
+
var symptomWireSchema = z.strictObject({
|
|
910
|
+
name: catalogueNameSchema,
|
|
911
|
+
title: textSchema,
|
|
912
|
+
group: textSchema,
|
|
913
|
+
seen: textSchema,
|
|
914
|
+
mayIndicate: z.array(
|
|
915
|
+
z.strictObject({
|
|
916
|
+
case: catalogueNameSchema,
|
|
917
|
+
situation: textSchema.optional(),
|
|
918
|
+
quote: textSchema.optional(),
|
|
919
|
+
points: z.array(pointedWireSchema).min(1)
|
|
920
|
+
})
|
|
921
|
+
).min(1),
|
|
922
|
+
breachUsuallySits: textSchema,
|
|
923
|
+
seenBy: z.array(seenBySchema).min(1),
|
|
924
|
+
reports: reportsSchema.optional(),
|
|
925
|
+
recipes: z.array(catalogueNameSchema),
|
|
926
|
+
correctUses: z.array(correctUseWireSchema),
|
|
927
|
+
howItIsSeen: textSchema.optional(),
|
|
928
|
+
breachACheckCouldName: textSchema.optional(),
|
|
929
|
+
toNameTheBreach: textSchema.optional()
|
|
930
|
+
});
|
|
931
|
+
var sightWireSchema = z.discriminatedUnion("kind", [
|
|
932
|
+
z.strictObject({ kind: z.literal("one-symptom"), symptom: catalogueNameSchema }),
|
|
933
|
+
z.strictObject({
|
|
934
|
+
kind: z.literal("symptom-by-form"),
|
|
935
|
+
forms: z.array(z.strictObject({ form: textSchema, symptom: catalogueNameSchema })).min(1)
|
|
936
|
+
}),
|
|
937
|
+
z.strictObject({
|
|
938
|
+
kind: z.literal("method"),
|
|
939
|
+
recipe: catalogueNameSchema,
|
|
940
|
+
outcomeSeenBy: z.array(catalogueNameSchema).min(1)
|
|
941
|
+
}),
|
|
942
|
+
z.strictObject({ kind: z.literal("outside-the-cases") })
|
|
943
|
+
]);
|
|
944
|
+
var recordKindWireSchema = z.strictObject({
|
|
945
|
+
name: recordKindNameSchema,
|
|
946
|
+
title: textSchema,
|
|
947
|
+
phrase: textSchema,
|
|
948
|
+
todaysFormat: z.enum(["authorised-location", "file-carve-out", "none-yet"])
|
|
949
|
+
});
|
|
950
|
+
var checkWireSchema = z.strictObject({
|
|
951
|
+
symptom: catalogueNameSchema,
|
|
952
|
+
name: catalogueNameSchema,
|
|
953
|
+
clause: clauseAddressSchema.optional(),
|
|
954
|
+
findingSpecifics: specificsSchema.optional(),
|
|
955
|
+
flagsBeyondTheSymptom: textSchema.optional(),
|
|
956
|
+
misses: textSchema.optional(),
|
|
957
|
+
settingsTracedTo: textSchema.optional()
|
|
958
|
+
});
|
|
959
|
+
var checkNamesSchema = z.string().transform((text, context) => {
|
|
960
|
+
const names = checkNamesOf({ text });
|
|
961
|
+
if (names !== void 0) {
|
|
962
|
+
return names;
|
|
963
|
+
}
|
|
964
|
+
context.addIssue({ code: "custom", message: "is not a check address, <symptom>#<check>" });
|
|
965
|
+
return z.NEVER;
|
|
966
|
+
});
|
|
967
|
+
var recipeExampleWireSchema = z.strictObject({
|
|
968
|
+
anchor: catalogueNameSchema,
|
|
969
|
+
answers: z.array(z.strictObject({ check: checkNamesSchema, form: textSchema })).min(1)
|
|
970
|
+
});
|
|
971
|
+
var catalogueFileSchema = z.strictObject({
|
|
972
|
+
version: z.literal(SUPPORTED_VERSION),
|
|
973
|
+
principles: z.array(z.strictObject({ name: catalogueNameSchema, title: textSchema })),
|
|
974
|
+
rules: z.array(
|
|
975
|
+
z.strictObject({
|
|
976
|
+
name: catalogueNameSchema,
|
|
977
|
+
title: textSchema,
|
|
978
|
+
principle: catalogueNameSchema,
|
|
979
|
+
standing: standingSchema
|
|
980
|
+
})
|
|
981
|
+
),
|
|
982
|
+
cases: z.array(caseWireSchema),
|
|
983
|
+
recipes: z.array(
|
|
984
|
+
z.strictObject({
|
|
985
|
+
name: catalogueNameSchema,
|
|
986
|
+
title: textSchema,
|
|
987
|
+
serves: z.array(pointedWireSchema).min(1),
|
|
988
|
+
standing: standingSchema,
|
|
989
|
+
reason: z.strictObject({ text: textSchema, standing: standingSchema }),
|
|
990
|
+
examples: z.array(recipeExampleWireSchema).optional()
|
|
991
|
+
})
|
|
992
|
+
),
|
|
993
|
+
recordKinds: z.array(recordKindWireSchema),
|
|
994
|
+
engines: z.array(z.strictObject({ name: engineIdSchema })),
|
|
995
|
+
symptoms: z.array(symptomWireSchema),
|
|
996
|
+
clauses: z.array(z.strictObject({ clause: clauseAddressSchema, sight: sightWireSchema })),
|
|
997
|
+
checks: z.array(checkWireSchema),
|
|
998
|
+
namedBans: z.array(z.strictObject({ outsideDependency: textSchema }))
|
|
999
|
+
});
|
|
1000
|
+
var resolved = (found) => ({ outcome: "ok", value: found });
|
|
1001
|
+
var faultsOf = (resolution) => resolution.outcome === "failed" ? resolution.error : [];
|
|
1002
|
+
var allResolved = (resolutions) => {
|
|
1003
|
+
const faults = resolutions.flatMap(faultsOf);
|
|
1004
|
+
return faults.length > 0 ? { outcome: "failed", error: faults } : resolved(
|
|
1005
|
+
resolutions.flatMap(
|
|
1006
|
+
(resolution) => resolution.outcome === "ok" ? [resolution.value] : []
|
|
1007
|
+
)
|
|
1008
|
+
);
|
|
1009
|
+
};
|
|
1010
|
+
var mapped = (request) => request.resolution.outcome === "failed" ? request.resolution : resolved(request.to(request.resolution.value));
|
|
1011
|
+
var entryNamed = (request) => {
|
|
1012
|
+
const entry = request.entries.find((candidate) => candidate.name === request.name);
|
|
1013
|
+
return entry === void 0 ? { outcome: "failed", error: [request.refusal] } : resolved(entry);
|
|
1014
|
+
};
|
|
1015
|
+
var notHeldRefusal = (request) => `${request.listing} names ${request.name}, which the catalogue does not hold`;
|
|
1016
|
+
var heldEntryNamed = (request) => entryNamed({ ...request, refusal: notHeldRefusal(request) });
|
|
1017
|
+
var principleOf = (wire) => ({ name: wire.name, title: wire.title });
|
|
1018
|
+
var mapWireToRecipeExample = (request) => ({
|
|
1019
|
+
anchor: request.wire.anchor,
|
|
1020
|
+
answers: request.wire.answers.map(({ check, form }) => ({
|
|
1021
|
+
check: { name: check.check, symptom: { ruleSet: request.ruleSet, name: check.symptom } },
|
|
1022
|
+
form
|
|
1023
|
+
}))
|
|
1024
|
+
});
|
|
1025
|
+
var recipeOf = (request) => ({
|
|
1026
|
+
ruleSet: request.ruleSet,
|
|
1027
|
+
name: request.wire.name,
|
|
1028
|
+
title: request.wire.title,
|
|
1029
|
+
standing: request.wire.standing,
|
|
1030
|
+
reason: { text: request.wire.reason.text, standing: request.wire.reason.standing },
|
|
1031
|
+
...request.wire.examples === void 0 ? {} : {
|
|
1032
|
+
examples: request.wire.examples.map(
|
|
1033
|
+
(wire) => mapWireToRecipeExample({ wire, ruleSet: request.ruleSet })
|
|
1034
|
+
)
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
var recordKindOf = (wire) => ({
|
|
1038
|
+
name: wire.name,
|
|
1039
|
+
title: wire.title,
|
|
1040
|
+
phrase: wire.phrase,
|
|
1041
|
+
todaysFormat: wire.todaysFormat
|
|
1042
|
+
});
|
|
1043
|
+
var engineOf = (wire) => ({ name: wire.name });
|
|
1044
|
+
var namedBanOf = (wire) => ({
|
|
1045
|
+
outsideDependency: wire.outsideDependency
|
|
1046
|
+
});
|
|
1047
|
+
var ruleOf = (request) => mapped({
|
|
1048
|
+
resolution: heldEntryNamed({
|
|
1049
|
+
listing: "rules",
|
|
1050
|
+
entries: request.principles,
|
|
1051
|
+
name: request.wire.principle
|
|
1052
|
+
}),
|
|
1053
|
+
to: (principle) => ({
|
|
1054
|
+
name: request.wire.name,
|
|
1055
|
+
title: request.wire.title,
|
|
1056
|
+
principle,
|
|
1057
|
+
standing: request.wire.standing
|
|
1058
|
+
})
|
|
1059
|
+
});
|
|
1060
|
+
var pointedOf = (request) => "rule" in request.point ? mapped({
|
|
1061
|
+
resolution: heldEntryNamed({
|
|
1062
|
+
listing: request.listing,
|
|
1063
|
+
entries: request.pointable.rules,
|
|
1064
|
+
name: request.point.rule
|
|
1065
|
+
}),
|
|
1066
|
+
to: (rule) => ({ kind: "rule", rule })
|
|
1067
|
+
}) : mapped({
|
|
1068
|
+
resolution: heldEntryNamed({
|
|
1069
|
+
listing: request.listing,
|
|
1070
|
+
entries: request.pointable.principles,
|
|
1071
|
+
name: request.point.principle
|
|
1072
|
+
}),
|
|
1073
|
+
to: (principle) => ({ kind: "principle", principle })
|
|
1074
|
+
});
|
|
1075
|
+
var resolveServes = (request) => allResolved(
|
|
1076
|
+
request.wire.serves.map(
|
|
1077
|
+
(point) => pointedOf({ listing: "recipes", point, pointable: request.pointable })
|
|
1078
|
+
)
|
|
1079
|
+
);
|
|
1080
|
+
var caseOf = (request) => {
|
|
1081
|
+
const owes = allResolved(
|
|
1082
|
+
request.wire.owes.map(
|
|
1083
|
+
(point) => pointedOf({ listing: "cases", point, pointable: request.pointable })
|
|
1084
|
+
)
|
|
1085
|
+
);
|
|
1086
|
+
const nameFaults = findCaseNameFaults(request.wire);
|
|
1087
|
+
return owes.outcome === "failed" || nameFaults.length > 0 ? { outcome: "failed", error: [...nameFaults, ...faultsOf(owes)] } : resolved({
|
|
1088
|
+
name: request.wire.name,
|
|
1089
|
+
title: request.wire.title,
|
|
1090
|
+
standing: request.wire.standing,
|
|
1091
|
+
owes: owes.value
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
var requiredRecordKindFaultsOf = (recordKinds) => ["debt", "authorised-location"].flatMap(
|
|
1095
|
+
(name) => recordKinds.some((kind) => kind.name === name) ? [] : [`recordKinds holds no ${name}, which every symptom takes`]
|
|
1096
|
+
);
|
|
1097
|
+
var pointableOf = (request) => {
|
|
1098
|
+
const principles = request.file.principles.map(principleOf);
|
|
1099
|
+
return mapped({
|
|
1100
|
+
resolution: allResolved(request.file.rules.map((wire) => ruleOf({ wire, principles }))),
|
|
1101
|
+
to: (rules) => ({ principles, rules })
|
|
1102
|
+
});
|
|
1103
|
+
};
|
|
1104
|
+
var recordKindsOf = (request) => {
|
|
1105
|
+
const own = request.file.recordKinds.map(recordKindOf);
|
|
1106
|
+
return [
|
|
1107
|
+
...request.inheritedRecordKinds.filter(
|
|
1108
|
+
(inherited) => !own.some((kind) => kind.name === inherited.name)
|
|
1109
|
+
),
|
|
1110
|
+
...own
|
|
1111
|
+
];
|
|
1112
|
+
};
|
|
1113
|
+
var definitionsOf = (request) => {
|
|
1114
|
+
const pointable = pointableOf(request);
|
|
1115
|
+
if (pointable.outcome === "failed") {
|
|
1116
|
+
return pointable;
|
|
1117
|
+
}
|
|
1118
|
+
const recordKinds = recordKindsOf(request);
|
|
1119
|
+
const cases = allResolved(
|
|
1120
|
+
request.file.cases.map((wire) => caseOf({ wire, pointable: pointable.value }))
|
|
1121
|
+
);
|
|
1122
|
+
const recordKindFaults = requiredRecordKindFaultsOf(recordKinds);
|
|
1123
|
+
const served = allResolved(
|
|
1124
|
+
request.file.recipes.map((wire) => resolveServes({ wire, pointable: pointable.value }))
|
|
1125
|
+
);
|
|
1126
|
+
return cases.outcome === "failed" || recordKindFaults.length > 0 || served.outcome === "failed" ? {
|
|
1127
|
+
outcome: "failed",
|
|
1128
|
+
error: [...faultsOf(cases), ...recordKindFaults, ...faultsOf(served)]
|
|
1129
|
+
} : resolved({
|
|
1130
|
+
...pointable.value,
|
|
1131
|
+
cases: cases.value,
|
|
1132
|
+
recipes: request.file.recipes.map((wire) => recipeOf({ wire, ruleSet: request.ruleSet })),
|
|
1133
|
+
recordKinds,
|
|
1134
|
+
engines: request.file.engines.map(engineOf)
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
var mapWireToOwedPoint = (request) => "rule" in request.point ? { kind: "rule", name: request.point.rule } : { kind: "principle", name: request.point.principle };
|
|
1138
|
+
var mapPointedToOwedPoint = (point) => point.kind === "rule" ? { kind: "rule", name: point.rule.name } : { kind: "principle", name: point.principle.name };
|
|
1139
|
+
var resolveOwedPoint = (request) => {
|
|
1140
|
+
const wanted = mapWireToOwedPoint({ point: request.point });
|
|
1141
|
+
const owed = findOwedPoint({
|
|
1142
|
+
owes: request.owing.owes,
|
|
1143
|
+
point: wanted,
|
|
1144
|
+
mapOwedToPoint: mapPointedToOwedPoint
|
|
1145
|
+
});
|
|
1146
|
+
return owed === void 0 ? {
|
|
1147
|
+
outcome: "failed",
|
|
1148
|
+
error: [
|
|
1149
|
+
createUnowedPointFault({
|
|
1150
|
+
symptom: request.symptom,
|
|
1151
|
+
owing: request.owing.name,
|
|
1152
|
+
point: wanted
|
|
1153
|
+
})
|
|
1154
|
+
]
|
|
1155
|
+
} : resolved(owed);
|
|
1156
|
+
};
|
|
1157
|
+
var indicationOf = (request) => {
|
|
1158
|
+
const indicated = heldEntryNamed({
|
|
1159
|
+
listing: "symptoms",
|
|
1160
|
+
entries: request.definitions.cases,
|
|
1161
|
+
name: request.indication.case
|
|
1162
|
+
});
|
|
1163
|
+
if (indicated.outcome === "failed") {
|
|
1164
|
+
return indicated;
|
|
1165
|
+
}
|
|
1166
|
+
return mapped({
|
|
1167
|
+
resolution: allResolved(
|
|
1168
|
+
request.indication.points.map(
|
|
1169
|
+
(point) => resolveOwedPoint({ symptom: request.symptom, owing: indicated.value, point })
|
|
1170
|
+
)
|
|
1171
|
+
),
|
|
1172
|
+
to: (points) => request.indication.situation === void 0 ? { case: indicated.value, points } : { case: indicated.value, situation: request.indication.situation, points }
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1175
|
+
var mapWireToCorrectUse = (request) => {
|
|
1176
|
+
const { use, kind } = request;
|
|
1177
|
+
const at = use.at === void 0 ? {} : { at: use.at };
|
|
1178
|
+
const { name } = kind;
|
|
1179
|
+
if (name === "authorised-location") {
|
|
1180
|
+
return {
|
|
1181
|
+
situation: use.situation,
|
|
1182
|
+
kind: { ...kind, name },
|
|
1183
|
+
...at,
|
|
1184
|
+
binding: mapSpecificsToBinding({ specifics: "binds" in use ? use.binds ?? [] : [] })
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
return { situation: use.situation, kind: { ...kind, name }, ...at };
|
|
1188
|
+
};
|
|
1189
|
+
var resolveCorrectUse = (request) => mapped({
|
|
1190
|
+
resolution: heldEntryNamed({
|
|
1191
|
+
listing: "symptoms",
|
|
1192
|
+
entries: request.definitions.recordKinds,
|
|
1193
|
+
name: request.use.kind
|
|
1194
|
+
}),
|
|
1195
|
+
to: (kind) => mapWireToCorrectUse({ use: request.use, kind })
|
|
1196
|
+
});
|
|
1197
|
+
var mapBindingFaultToText = (request) => {
|
|
1198
|
+
const { fault } = request;
|
|
1199
|
+
switch (fault.kind) {
|
|
1200
|
+
case "divergent-bindings":
|
|
1201
|
+
return `${fault.symptom} has authorised-location correct uses that bind differently`;
|
|
1202
|
+
case "binding-not-reported":
|
|
1203
|
+
return `${fault.symptom} binds outside-party, which its check ${fault.check} does not report`;
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
var symptomOf = (request) => {
|
|
1207
|
+
const { wire, definitions } = request;
|
|
1208
|
+
const mayIndicate = allResolved(
|
|
1209
|
+
wire.mayIndicate.map(
|
|
1210
|
+
(indication) => indicationOf({ symptom: wire.name, indication, definitions })
|
|
1211
|
+
)
|
|
1212
|
+
);
|
|
1213
|
+
const recipes = allResolved(
|
|
1214
|
+
wire.recipes.map(
|
|
1215
|
+
(name) => heldEntryNamed({ listing: "symptoms", entries: definitions.recipes, name })
|
|
1216
|
+
)
|
|
1217
|
+
);
|
|
1218
|
+
const correctUses = allResolved(
|
|
1219
|
+
wire.correctUses.map((use) => resolveCorrectUse({ use, definitions }))
|
|
1220
|
+
);
|
|
1221
|
+
if (mayIndicate.outcome === "failed" || recipes.outcome === "failed" || correctUses.outcome === "failed") {
|
|
1222
|
+
return {
|
|
1223
|
+
outcome: "failed",
|
|
1224
|
+
error: [...faultsOf(mayIndicate), ...faultsOf(recipes), ...faultsOf(correctUses)]
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
const symptom = {
|
|
1228
|
+
ruleSet: request.ruleSet,
|
|
1229
|
+
name: wire.name,
|
|
1230
|
+
title: wire.title,
|
|
1231
|
+
seen: wire.seen,
|
|
1232
|
+
mayIndicate: mayIndicate.value,
|
|
1233
|
+
breachUsuallySits: wire.breachUsuallySits,
|
|
1234
|
+
recipes: recipes.value,
|
|
1235
|
+
correctUses: correctUses.value
|
|
1236
|
+
};
|
|
1237
|
+
const divergent = listDivergentBindings({ symptom });
|
|
1238
|
+
return divergent.length > 0 ? { outcome: "failed", error: divergent.map((fault) => mapBindingFaultToText({ fault })) } : resolved(symptom);
|
|
1239
|
+
};
|
|
1240
|
+
var sightedSymptomOf = (request) => mapped({
|
|
1241
|
+
resolution: heldEntryNamed({
|
|
1242
|
+
listing: "clauses",
|
|
1243
|
+
entries: request.symptoms,
|
|
1244
|
+
name: request.name
|
|
1245
|
+
}),
|
|
1246
|
+
to: (symptom) => mapSymptomToAddress({ symptom })
|
|
1247
|
+
});
|
|
1248
|
+
var methodSightOf = (request) => {
|
|
1249
|
+
const recipe = heldEntryNamed({
|
|
1250
|
+
listing: "clauses",
|
|
1251
|
+
entries: request.recipes,
|
|
1252
|
+
name: request.sight.recipe
|
|
1253
|
+
});
|
|
1254
|
+
const outcomeSeenBy = allResolved(
|
|
1255
|
+
request.sight.outcomeSeenBy.map((name) => sightedSymptomOf({ ...request, name }))
|
|
1256
|
+
);
|
|
1257
|
+
return recipe.outcome === "failed" || outcomeSeenBy.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(recipe), ...faultsOf(outcomeSeenBy)] } : resolved({ kind: "method", recipe: recipe.value, outcomeSeenBy: outcomeSeenBy.value });
|
|
1258
|
+
};
|
|
1259
|
+
var sightOf = (request) => {
|
|
1260
|
+
const { sight } = request;
|
|
1261
|
+
switch (sight.kind) {
|
|
1262
|
+
case "one-symptom":
|
|
1263
|
+
return mapped({
|
|
1264
|
+
resolution: sightedSymptomOf({ ...request, name: sight.symptom }),
|
|
1265
|
+
to: (symptom) => ({ kind: "one-symptom", symptom })
|
|
1266
|
+
});
|
|
1267
|
+
case "symptom-by-form":
|
|
1268
|
+
return mapped({
|
|
1269
|
+
resolution: allResolved(
|
|
1270
|
+
sight.forms.map(
|
|
1271
|
+
(form) => mapped({
|
|
1272
|
+
resolution: sightedSymptomOf({ ...request, name: form.symptom }),
|
|
1273
|
+
to: (symptom) => ({ form: form.form, symptom })
|
|
1274
|
+
})
|
|
1275
|
+
)
|
|
1276
|
+
),
|
|
1277
|
+
to: (forms) => ({ kind: "symptom-by-form", forms })
|
|
1278
|
+
});
|
|
1279
|
+
case "method":
|
|
1280
|
+
return methodSightOf({ ...request, sight });
|
|
1281
|
+
case "outside-the-cases":
|
|
1282
|
+
return resolved({ kind: "outside-the-cases" });
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
var clauseOf = (request) => mapped({
|
|
1286
|
+
resolution: sightOf({ ...request, sight: request.wire.sight }),
|
|
1287
|
+
to: (sight) => ({ clause: request.wire.clause, sight })
|
|
1288
|
+
});
|
|
1289
|
+
var sightedSymptomsOf = (request) => {
|
|
1290
|
+
switch (request.sight.kind) {
|
|
1291
|
+
case "one-symptom":
|
|
1292
|
+
return [request.sight.symptom];
|
|
1293
|
+
case "symptom-by-form":
|
|
1294
|
+
return request.sight.forms.map((form) => form.symptom);
|
|
1295
|
+
case "method":
|
|
1296
|
+
case "outside-the-cases":
|
|
1297
|
+
return [];
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
var sightedNamesOf = (request) => [
|
|
1301
|
+
...new Set(sightedSymptomsOf({ sight: request.clause.sight }).map((symptom) => symptom.name))
|
|
1302
|
+
];
|
|
1303
|
+
var formsOf = (request) => request.clause.sight.kind === "symptom-by-form" ? request.clause.sight.forms.filter((form) => form.symptom.name === request.symptom.name).map((form) => form.form) : [];
|
|
1304
|
+
var checkedClauseOf = (request) => {
|
|
1305
|
+
const clause = request.clauses.find(
|
|
1306
|
+
(candidate) => sameClauseAddress({ left: candidate.clause, right: request.address }) === "same"
|
|
1307
|
+
);
|
|
1308
|
+
return clause === void 0 ? {
|
|
1309
|
+
outcome: "failed",
|
|
1310
|
+
error: [
|
|
1311
|
+
notHeldRefusal({
|
|
1312
|
+
listing: "checks",
|
|
1313
|
+
name: clauseAddressText({ address: request.address })
|
|
1314
|
+
})
|
|
1315
|
+
]
|
|
1316
|
+
} : resolved(clause);
|
|
1317
|
+
};
|
|
1318
|
+
var CHECK_PAGE_EXTENSION = ".md";
|
|
1319
|
+
var createCheckPage = (request) => `${request.symptom.name}/${request.name}${CHECK_PAGE_EXTENSION}`;
|
|
1320
|
+
var sightedCheckOf = (request) => sightedNamesOf({ clause: request.clause }).includes(request.symptom.name) ? resolved({
|
|
1321
|
+
name: request.wire.name,
|
|
1322
|
+
symptom: request.symptom,
|
|
1323
|
+
page: createCheckPage({ symptom: request.symptom, name: request.wire.name }),
|
|
1324
|
+
clause: request.clause.clause,
|
|
1325
|
+
forms: formsOf({ clause: request.clause, symptom: request.symptom }),
|
|
1326
|
+
findingSpecifics: request.wire.findingSpecifics ?? []
|
|
1327
|
+
}) : {
|
|
1328
|
+
outcome: "failed",
|
|
1329
|
+
error: [
|
|
1330
|
+
`checks names ${request.symptom.name}#${request.wire.name} on ${clauseAddressText({ address: request.clause.clause })}, which does not see ${request.symptom.name}`
|
|
1331
|
+
]
|
|
1332
|
+
};
|
|
1333
|
+
var checkOf2 = (request) => {
|
|
1334
|
+
const { wire } = request;
|
|
1335
|
+
const symptom = mapped({
|
|
1336
|
+
resolution: heldEntryNamed({
|
|
1337
|
+
listing: "checks",
|
|
1338
|
+
entries: request.symptoms,
|
|
1339
|
+
name: wire.symptom
|
|
1340
|
+
}),
|
|
1341
|
+
to: (held) => mapSymptomToAddress({ symptom: held })
|
|
1342
|
+
});
|
|
1343
|
+
if (wire.clause === void 0) {
|
|
1344
|
+
return symptom.outcome === "failed" ? symptom : resolved({
|
|
1345
|
+
name: wire.name,
|
|
1346
|
+
symptom: symptom.value,
|
|
1347
|
+
page: createCheckPage({ symptom: symptom.value, name: wire.name }),
|
|
1348
|
+
forms: [],
|
|
1349
|
+
findingSpecifics: wire.findingSpecifics ?? []
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
const clause = checkedClauseOf({ ...request, address: wire.clause });
|
|
1353
|
+
return symptom.outcome === "failed" || clause.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(symptom), ...faultsOf(clause)] } : sightedCheckOf({ wire, symptom: symptom.value, clause: clause.value });
|
|
1354
|
+
};
|
|
1355
|
+
var uncheckedSightingsOf = (request) => {
|
|
1356
|
+
const checked = checksOf({ catalogue: request, clause: request.clause.clause });
|
|
1357
|
+
return checked.length === 0 ? [] : sightedNamesOf(request).filter((name) => !checked.some((check) => check.symptom.name === name)).map(
|
|
1358
|
+
(name) => `${clauseAddressText({ address: request.clause.clause })} sees ${name}, which no check names`
|
|
1359
|
+
);
|
|
1360
|
+
};
|
|
1361
|
+
var resolvedChecksOf = (request) => {
|
|
1362
|
+
const checks = allResolved(request.wires.map((wire) => checkOf2({ ...request, wire })));
|
|
1363
|
+
if (checks.outcome === "failed") {
|
|
1364
|
+
return checks;
|
|
1365
|
+
}
|
|
1366
|
+
const unchecked = request.clauses.flatMap(
|
|
1367
|
+
(clause) => uncheckedSightingsOf({ clause, checks: checks.value })
|
|
1368
|
+
);
|
|
1369
|
+
const unreported = listUnreportedBindings({
|
|
1370
|
+
symptoms: request.symptoms,
|
|
1371
|
+
checks: checks.value
|
|
1372
|
+
}).map((fault) => mapBindingFaultToText({ fault }));
|
|
1373
|
+
const faults = [...unchecked, ...unreported];
|
|
1374
|
+
return faults.length > 0 ? { outcome: "failed", error: faults } : checks;
|
|
1375
|
+
};
|
|
1376
|
+
var mapExampleFaultToText = (request) => {
|
|
1377
|
+
const { fault } = request;
|
|
1378
|
+
switch (fault.kind) {
|
|
1379
|
+
case "check-unheld":
|
|
1380
|
+
return `the example ${fault.anchor} of ${fault.recipe} answers ${fault.check}, which the catalogue does not hold`;
|
|
1381
|
+
case "recipe-not-indicated":
|
|
1382
|
+
return `the example ${fault.anchor} of ${fault.recipe} answers ${fault.check}, but ${fault.recipe} serves ${fault.serves.join(", ")}, none of which ${fault.symptom} indicates`;
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
var mapRecipeFaultToText = (request) => {
|
|
1386
|
+
const { symptom, recipe, serves } = request.fault;
|
|
1387
|
+
return `${symptom} lists the recipe ${recipe}, but ${recipe} serves ${serves.join(", ")}, none of which ${symptom} indicates`;
|
|
1388
|
+
};
|
|
1389
|
+
var listServingRecipes = (request) => request.file.recipes.flatMap((wire) => {
|
|
1390
|
+
const serves = resolveServes({ wire, pointable: request.pointable });
|
|
1391
|
+
return serves.outcome === "failed" ? [] : [{ name: wire.name, serves: serves.value }];
|
|
1392
|
+
});
|
|
1393
|
+
var listRecipeFaults = (request) => {
|
|
1394
|
+
const serving = listServingRecipes(request);
|
|
1395
|
+
return request.symptoms.flatMap((symptom) => {
|
|
1396
|
+
const listed = symptom.recipes.map(({ name }) => name);
|
|
1397
|
+
const recipes = serving.filter(({ name }) => listed.includes(name));
|
|
1398
|
+
return findRecipeFaults({ symptom, recipes }).map((fault) => mapRecipeFaultToText({ fault }));
|
|
1399
|
+
});
|
|
1400
|
+
};
|
|
1401
|
+
var listExampleFaults = (request) => {
|
|
1402
|
+
const { symptoms, checks, pointable, ruleSet } = request;
|
|
1403
|
+
return request.file.recipes.flatMap((wire) => {
|
|
1404
|
+
const serves = resolveServes({ wire, pointable });
|
|
1405
|
+
return serves.outcome === "failed" ? serves.error : findExampleFaults({
|
|
1406
|
+
recipe: recipeOf({ wire, ruleSet }),
|
|
1407
|
+
serves: serves.value,
|
|
1408
|
+
symptoms,
|
|
1409
|
+
checks
|
|
1410
|
+
}).map((fault) => mapExampleFaultToText({ fault }));
|
|
1411
|
+
});
|
|
1412
|
+
};
|
|
1413
|
+
var catalogueOf = (request) => {
|
|
1414
|
+
const definitions = definitionsOf(request);
|
|
1415
|
+
if (definitions.outcome === "failed") {
|
|
1416
|
+
return definitions;
|
|
1417
|
+
}
|
|
1418
|
+
const symptoms = allResolved(
|
|
1419
|
+
request.file.symptoms.map(
|
|
1420
|
+
(wire) => symptomOf({ wire, definitions: definitions.value, ruleSet: request.ruleSet })
|
|
1421
|
+
)
|
|
1422
|
+
);
|
|
1423
|
+
if (symptoms.outcome === "failed") {
|
|
1424
|
+
return symptoms;
|
|
1425
|
+
}
|
|
1426
|
+
const sighting = { symptoms: symptoms.value, recipes: definitions.value.recipes };
|
|
1427
|
+
const clauses = allResolved(request.file.clauses.map((wire) => clauseOf({ ...sighting, wire })));
|
|
1428
|
+
if (clauses.outcome === "failed") {
|
|
1429
|
+
return clauses;
|
|
1430
|
+
}
|
|
1431
|
+
const checks = resolvedChecksOf({
|
|
1432
|
+
symptoms: symptoms.value,
|
|
1433
|
+
clauses: clauses.value,
|
|
1434
|
+
wires: request.file.checks
|
|
1435
|
+
});
|
|
1436
|
+
if (checks.outcome === "failed") {
|
|
1437
|
+
return checks;
|
|
1438
|
+
}
|
|
1439
|
+
const chain = {
|
|
1440
|
+
...request,
|
|
1441
|
+
pointable: definitions.value,
|
|
1442
|
+
symptoms: symptoms.value,
|
|
1443
|
+
checks: checks.value
|
|
1444
|
+
};
|
|
1445
|
+
const chainFaults = [...listRecipeFaults(chain), ...listExampleFaults(chain)];
|
|
1446
|
+
return chainFaults.length > 0 ? { outcome: "failed", error: chainFaults } : resolved({
|
|
1447
|
+
...definitions.value,
|
|
1448
|
+
symptoms: symptoms.value,
|
|
1449
|
+
clauses: clauses.value,
|
|
1450
|
+
checks: checks.value,
|
|
1451
|
+
namedBans: request.file.namedBans.map(namedBanOf)
|
|
1452
|
+
});
|
|
1453
|
+
};
|
|
1454
|
+
var repeatsIn = (request) => request.names.filter((name, index) => request.names.indexOf(name) !== index).map((name) => `${request.listing} holds ${name} more than once`);
|
|
1455
|
+
var formSectionRepeatsOf = (request) => request.file.clauses.flatMap(
|
|
1456
|
+
({ clause, sight }) => sight.kind === "symptom-by-form" ? repeatsIn({
|
|
1457
|
+
listing: `the forms of ${clauseAddressText({ address: clause })}`,
|
|
1458
|
+
names: sight.forms.map((form) => form.form)
|
|
1459
|
+
}) : []
|
|
1460
|
+
);
|
|
1461
|
+
var listExampleRepeats = (request) => request.file.recipes.flatMap(
|
|
1462
|
+
({ name, examples }) => repeatsIn({
|
|
1463
|
+
listing: `the examples of ${name}`,
|
|
1464
|
+
names: (examples ?? []).map(({ anchor }) => anchor)
|
|
1465
|
+
})
|
|
1466
|
+
);
|
|
1467
|
+
var indicatedCaseRepeatsOf = (request) => request.file.symptoms.flatMap(
|
|
1468
|
+
(symptom) => repeatsIn({
|
|
1469
|
+
listing: `the cases of ${symptom.name}`,
|
|
1470
|
+
names: symptom.mayIndicate.map(
|
|
1471
|
+
(indication) => indication.situation === void 0 ? indication.case : `${indication.case}: ${indication.situation}`
|
|
1472
|
+
)
|
|
1473
|
+
})
|
|
1474
|
+
);
|
|
1475
|
+
var checkedClauseRepeatsOf = (request) => [...new Set(request.file.checks.map((check) => check.symptom))].flatMap(
|
|
1476
|
+
(symptom) => repeatsIn({
|
|
1477
|
+
listing: `the checks of ${symptom}`,
|
|
1478
|
+
names: request.file.checks.filter((check) => check.symptom === symptom).map(
|
|
1479
|
+
(check) => check.clause === void 0 ? `${check.symptom}#${check.name}` : clauseAddressText({ address: check.clause })
|
|
1480
|
+
)
|
|
1481
|
+
})
|
|
1482
|
+
);
|
|
1483
|
+
var repeatedNamesOf = (request) => [
|
|
1484
|
+
...repeatsIn({
|
|
1485
|
+
listing: "principles",
|
|
1486
|
+
names: request.file.principles.map((principle) => principle.name)
|
|
1487
|
+
}),
|
|
1488
|
+
...repeatsIn({ listing: "rules", names: request.file.rules.map((rule) => rule.name) }),
|
|
1489
|
+
...repeatsIn({ listing: "cases", names: request.file.cases.map((entry) => entry.name) }),
|
|
1490
|
+
...repeatsIn({ listing: "recipes", names: request.file.recipes.map((recipe) => recipe.name) }),
|
|
1491
|
+
...repeatsIn({
|
|
1492
|
+
listing: "recordKinds",
|
|
1493
|
+
names: request.file.recordKinds.map((kind) => kind.name)
|
|
1494
|
+
}),
|
|
1495
|
+
...repeatsIn({ listing: "engines", names: request.file.engines.map((engine) => engine.name) }),
|
|
1496
|
+
...repeatsIn({
|
|
1497
|
+
listing: "symptoms",
|
|
1498
|
+
names: request.file.symptoms.map((symptom) => symptom.name)
|
|
1499
|
+
}),
|
|
1500
|
+
...repeatsIn({
|
|
1501
|
+
listing: "clauses",
|
|
1502
|
+
names: request.file.clauses.map(({ clause }) => clauseAddressText({ address: clause }))
|
|
1503
|
+
}),
|
|
1504
|
+
...repeatsIn({
|
|
1505
|
+
listing: "checks",
|
|
1506
|
+
names: request.file.checks.map((check) => `${check.symptom}#${check.name}`)
|
|
1507
|
+
}),
|
|
1508
|
+
...checkedClauseRepeatsOf(request),
|
|
1509
|
+
...formSectionRepeatsOf(request),
|
|
1510
|
+
...listExampleRepeats(request),
|
|
1511
|
+
...indicatedCaseRepeatsOf(request)
|
|
1512
|
+
];
|
|
1513
|
+
var checkedCatalogueFileSchema = catalogueFileSchema.superRefine((file, context) => {
|
|
1514
|
+
repeatedNamesOf({ file }).forEach((message) => {
|
|
1515
|
+
context.addIssue({ code: "custom", message });
|
|
1516
|
+
});
|
|
1517
|
+
});
|
|
1518
|
+
var refusalText2 = (request) => request.faults.map((fault) => `\u2716 ${fault}`).join("\n");
|
|
1519
|
+
var catalogueContentFromFile = (request) => {
|
|
1520
|
+
const repeats = repeatedNamesOf({ file: request.file });
|
|
1521
|
+
if (repeats.length > 0) {
|
|
1522
|
+
return { outcome: "failed", error: refusalText2({ faults: repeats }) };
|
|
1523
|
+
}
|
|
1524
|
+
const catalogue = catalogueOf(request);
|
|
1525
|
+
return catalogue.outcome === "failed" ? { outcome: "failed", error: refusalText2({ faults: catalogue.error }) } : catalogue;
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
// src/infrastructure/disciplines-file/version-one-names.ts
|
|
1529
|
+
var VERSION_ONE_NAMES_SEGMENTS = [
|
|
1530
|
+
"src",
|
|
1531
|
+
"infrastructure",
|
|
1532
|
+
"disciplines-file",
|
|
1533
|
+
"version-one-names.json"
|
|
1534
|
+
];
|
|
1535
|
+
var formatOfTodaySchema = recordKindWireSchema.shape.todaysFormat.exclude(["none-yet"]);
|
|
1536
|
+
var checkAddressSchema = z2.string().regex(new RegExp(`^${CATALOGUE_NAME}#${CATALOGUE_NAME}$`), {
|
|
1537
|
+
error: "is not a check address of the form <symptom>#<check>"
|
|
1538
|
+
});
|
|
1539
|
+
var versionOneNamesSchema = z2.strictObject({
|
|
1540
|
+
version: z2.literal(1),
|
|
1541
|
+
clauses: z2.array(
|
|
1542
|
+
z2.strictObject({
|
|
1543
|
+
clause: clauseAddressSchema,
|
|
1544
|
+
sight: z2.union([sightWireSchema, z2.literal("piece-forms")]),
|
|
1545
|
+
checks: z2.array(checkAddressSchema),
|
|
1546
|
+
anchor: anchorKindSchema.optional(),
|
|
1547
|
+
review: z2.string().min(1).optional()
|
|
1548
|
+
})
|
|
1549
|
+
),
|
|
1550
|
+
recordKinds: z2.partialRecord(recordKindNameSchema, formatOfTodaySchema)
|
|
1551
|
+
}).superRefine((file, context) => {
|
|
1552
|
+
const checks = file.clauses.flatMap((entry) => entry.checks);
|
|
1553
|
+
[...new Set(checks.filter((check, index) => checks.indexOf(check) !== index))].forEach(
|
|
1554
|
+
(check) => {
|
|
1555
|
+
context.addIssue({ code: "custom", message: `${check} is named by more than one clause` });
|
|
1556
|
+
}
|
|
1557
|
+
);
|
|
1558
|
+
file.clauses.filter((entry) => entry.anchor === void 0 === entry.checks.length > 0).forEach((entry) => {
|
|
1559
|
+
context.addIssue({
|
|
1560
|
+
code: "custom",
|
|
1561
|
+
message: `${clauseAddressText({ address: entry.clause })} needs an anchor exactly when it names a check`
|
|
1562
|
+
});
|
|
1563
|
+
});
|
|
1564
|
+
});
|
|
1565
|
+
var NO_VERSION_ONE_NAMES = {
|
|
1566
|
+
clauses: [],
|
|
1567
|
+
claimsPieceForms: [],
|
|
1568
|
+
namedClauses: [],
|
|
1569
|
+
clauseOfCheck: /* @__PURE__ */ new Map(),
|
|
1570
|
+
formatsOfToday: {}
|
|
1571
|
+
};
|
|
1572
|
+
var addressedCheckOf = (address) => {
|
|
1573
|
+
const mark = address.indexOf(CHECK_ADDRESS_SEPARATOR);
|
|
1574
|
+
return { name: address.slice(mark + 1), symptom: { name: address.slice(0, mark) } };
|
|
1575
|
+
};
|
|
1576
|
+
var namedClauseOf = (entry) => entry.anchor === void 0 ? { clause: entry.clause, kind: "judgement" } : {
|
|
1577
|
+
clause: entry.clause,
|
|
1578
|
+
kind: "mechanical",
|
|
1579
|
+
anchor: entry.anchor,
|
|
1580
|
+
checks: entry.checks.map(addressedCheckOf)
|
|
1581
|
+
};
|
|
1582
|
+
var namesOf = (file) => ({
|
|
1583
|
+
clauses: file.clauses.flatMap(
|
|
1584
|
+
({ clause, sight }) => sight === "piece-forms" ? [] : [{ clause, sight }]
|
|
1585
|
+
),
|
|
1586
|
+
claimsPieceForms: file.clauses.flatMap(
|
|
1587
|
+
({ clause, sight }) => sight === "piece-forms" ? [clause] : []
|
|
1588
|
+
),
|
|
1589
|
+
namedClauses: file.clauses.map(namedClauseOf),
|
|
1590
|
+
clauseOfCheck: new Map(
|
|
1591
|
+
file.clauses.flatMap(
|
|
1592
|
+
({ clause, checks }) => checks.map((check) => [check, clause])
|
|
1593
|
+
)
|
|
1594
|
+
),
|
|
1595
|
+
formatsOfToday: file.recordKinds
|
|
1596
|
+
});
|
|
1597
|
+
var checksNamedFor = (request) => request.names.namedClauses.flatMap((named2) => {
|
|
1598
|
+
if (named2.kind !== "mechanical" || sameClauseAddress({ left: named2.clause, right: request.clause }) === "different") {
|
|
1599
|
+
return [];
|
|
1600
|
+
}
|
|
1601
|
+
return named2.checks.flatMap((check) => {
|
|
1602
|
+
const names = checkNamesOf({ text: checkAddressTextOf({ check }) });
|
|
1603
|
+
return names === void 0 ? [] : [names];
|
|
1604
|
+
});
|
|
1605
|
+
});
|
|
1606
|
+
var versionOneNamesOf = (request) => {
|
|
1607
|
+
const parsed = versionOneNamesSchema.safeParse(request.document);
|
|
1608
|
+
return parsed.success ? { outcome: "ok", value: namesOf(parsed.data) } : { outcome: "failed", error: z2.prettifyError(parsed.error) };
|
|
1609
|
+
};
|
|
1610
|
+
var readVersionOneNames = (request) => {
|
|
1611
|
+
const document = readVersionOneJson(request);
|
|
1612
|
+
if (document.outcome === "failed") {
|
|
1613
|
+
return document;
|
|
1614
|
+
}
|
|
1615
|
+
const names = versionOneNamesOf({ document: document.value });
|
|
1616
|
+
return names.outcome === "failed" ? {
|
|
1617
|
+
outcome: "failed",
|
|
1618
|
+
error: { kind: "file-malformed", path: request.path, detail: names.error }
|
|
1619
|
+
} : names;
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
// src/infrastructure/content-files/item-folders/item-document.ts
|
|
1623
|
+
var ofKind = (kind) => (placed2) => placed2.item.kind === kind;
|
|
1624
|
+
var allAssembled = (assembled) => {
|
|
1625
|
+
const failure = assembled.find((each) => each.outcome === "failed");
|
|
1626
|
+
return failure?.outcome === "failed" ? failure : {
|
|
1627
|
+
outcome: "ok",
|
|
1628
|
+
value: assembled.flatMap((each) => each.outcome === "ok" ? [each.value] : [])
|
|
1629
|
+
};
|
|
1630
|
+
};
|
|
1631
|
+
var recordKindOf2 = (request) => {
|
|
1632
|
+
const { placed: placed2 } = request;
|
|
1633
|
+
const name = recordKindNameSchema.safeParse(placed2.name);
|
|
1634
|
+
return name.success ? {
|
|
1635
|
+
outcome: "ok",
|
|
1636
|
+
value: {
|
|
1637
|
+
name: name.data,
|
|
1638
|
+
title: placed2.title,
|
|
1639
|
+
...placed2.item.facts,
|
|
1640
|
+
todaysFormat: request.formatsOfToday[name.data] ?? "none-yet"
|
|
1641
|
+
}
|
|
1642
|
+
} : { outcome: "failed", error: `${placed2.name} is not the name of a record kind` };
|
|
1643
|
+
};
|
|
1644
|
+
var ruleOf2 = (placed2) => ({
|
|
1645
|
+
name: placed2.name,
|
|
1646
|
+
title: placed2.title,
|
|
1647
|
+
principle: placed2.item.facts.principle,
|
|
1648
|
+
standing: placed2.item.facts.standing
|
|
1649
|
+
});
|
|
1650
|
+
var checkOf3 = (request) => {
|
|
1651
|
+
const symptom = request.placed.within ?? "";
|
|
1652
|
+
const name = request.placed.name;
|
|
1653
|
+
const clause = request.clauseOfCheck.get(`${symptom}#${name}`);
|
|
1654
|
+
return {
|
|
1655
|
+
symptom,
|
|
1656
|
+
name,
|
|
1657
|
+
...clause === void 0 ? {} : { clause },
|
|
1658
|
+
...request.placed.item.facts
|
|
1659
|
+
};
|
|
1660
|
+
};
|
|
1661
|
+
var unheldChecksOf = (request) => {
|
|
1662
|
+
const held = new Set(request.checks.map((check) => `${check.symptom}#${check.name}`));
|
|
1663
|
+
return [...request.clauseOfCheck.keys()].filter((address) => !held.has(address));
|
|
1664
|
+
};
|
|
1665
|
+
var catalogueFileOf = (request) => {
|
|
1666
|
+
const { items, beside } = request;
|
|
1667
|
+
const recordKinds = allAssembled(
|
|
1668
|
+
items.filter(ofKind("record-kind")).map((placed2) => recordKindOf2({ placed: placed2, formatsOfToday: beside.formatsOfToday }))
|
|
1669
|
+
);
|
|
1670
|
+
if (recordKinds.outcome === "failed") {
|
|
1671
|
+
return recordKinds;
|
|
1672
|
+
}
|
|
1673
|
+
const checks = items.filter(ofKind("check")).map((placed2) => checkOf3({ placed: placed2, clauseOfCheck: beside.clauseOfCheck }));
|
|
1674
|
+
const [unheld] = unheldChecksOf({ checks, clauseOfCheck: beside.clauseOfCheck });
|
|
1675
|
+
if (unheld !== void 0) {
|
|
1676
|
+
return { outcome: "failed", error: `the version 1 names give ${unheld}, which no item holds` };
|
|
1677
|
+
}
|
|
1678
|
+
const rules = items.filter(ofKind("rule"));
|
|
1679
|
+
return {
|
|
1680
|
+
outcome: "ok",
|
|
1681
|
+
value: {
|
|
1682
|
+
version: SUPPORTED_VERSION,
|
|
1683
|
+
principles: items.filter(ofKind("principle")).map((placed2) => ({ name: placed2.name, title: placed2.title })),
|
|
1684
|
+
rules: rules.map(ruleOf2),
|
|
1685
|
+
cases: items.filter(ofKind("case")).map((placed2) => ({ name: placed2.name, title: placed2.title, ...placed2.item.facts })),
|
|
1686
|
+
recipes: items.filter(ofKind("recipe")).map((placed2) => ({ name: placed2.name, title: placed2.title, ...placed2.item.facts })),
|
|
1687
|
+
recordKinds: recordKinds.value,
|
|
1688
|
+
engines: beside.engines,
|
|
1689
|
+
symptoms: items.filter(ofKind("symptom")).map((placed2) => ({ name: placed2.name, title: placed2.title, ...placed2.item.facts })),
|
|
1690
|
+
clauses: beside.clauses,
|
|
1691
|
+
checks,
|
|
1692
|
+
namedBans: rules.flatMap((placed2) => placed2.item.facts.namedBans ?? []).map((outsideDependency) => ({ outsideDependency }))
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1697
|
+
// src/infrastructure/content-files/item-folders/item-facts.ts
|
|
1698
|
+
import { z as z3 } from "zod";
|
|
1699
|
+
var OMITTED_NAME_AND_TITLE = { name: true, title: true };
|
|
1700
|
+
var reviewLensSchema = z3.enum([
|
|
1701
|
+
"clean-architecture",
|
|
1702
|
+
"decomposition",
|
|
1703
|
+
"di-discipline",
|
|
1704
|
+
"errors-as-data",
|
|
1705
|
+
"function-first",
|
|
1706
|
+
"naming",
|
|
1707
|
+
"test-discipline",
|
|
1708
|
+
"type-soundness",
|
|
1709
|
+
"zod-boundary"
|
|
1710
|
+
]);
|
|
1711
|
+
var reviewLensesSchema = z3.array(reviewLensSchema).min(1).optional();
|
|
1712
|
+
var principleFactsSchema = catalogueFileSchema.shape.principles.element.omit(OMITTED_NAME_AND_TITLE).extend({ lenses: reviewLensesSchema });
|
|
1713
|
+
var ruleFactsSchema = catalogueFileSchema.shape.rules.element.omit(OMITTED_NAME_AND_TITLE).extend({ namedBans: z3.array(z3.string().min(1)).min(1).optional(), lenses: reviewLensesSchema });
|
|
1714
|
+
var caseFactsSchema = caseWireSchema.omit(OMITTED_NAME_AND_TITLE);
|
|
1715
|
+
var recipeFactsSchema = catalogueFileSchema.shape.recipes.element.omit(OMITTED_NAME_AND_TITLE);
|
|
1716
|
+
var recordKindFactsSchema = recordKindWireSchema.omit({
|
|
1717
|
+
...OMITTED_NAME_AND_TITLE,
|
|
1718
|
+
todaysFormat: true
|
|
1719
|
+
});
|
|
1720
|
+
var symptomFactsSchema = symptomWireSchema.omit(OMITTED_NAME_AND_TITLE);
|
|
1721
|
+
var checkFactsSchema = checkWireSchema.omit({ symptom: true, name: true, clause: true });
|
|
1722
|
+
var itemOf = (request) => request.result.success ? { outcome: "ok", value: request.toItem(request.result.data) } : { outcome: "failed", error: z3.prettifyError(request.result.error) };
|
|
1723
|
+
var itemFactsOf = (request) => {
|
|
1724
|
+
const { facts } = request;
|
|
1725
|
+
switch (request.kind) {
|
|
1726
|
+
case "principle":
|
|
1727
|
+
return itemOf({
|
|
1728
|
+
result: principleFactsSchema.safeParse(facts),
|
|
1729
|
+
toItem: (parsed) => ({ kind: "principle", facts: parsed })
|
|
1730
|
+
});
|
|
1731
|
+
case "rule":
|
|
1732
|
+
return itemOf({
|
|
1733
|
+
result: ruleFactsSchema.safeParse(facts),
|
|
1734
|
+
toItem: (parsed) => ({ kind: "rule", facts: parsed })
|
|
1735
|
+
});
|
|
1736
|
+
case "case":
|
|
1737
|
+
return itemOf({
|
|
1738
|
+
result: caseFactsSchema.safeParse(facts),
|
|
1739
|
+
toItem: (parsed) => ({ kind: "case", facts: parsed })
|
|
1740
|
+
});
|
|
1741
|
+
case "recipe":
|
|
1742
|
+
return itemOf({
|
|
1743
|
+
result: recipeFactsSchema.safeParse(facts),
|
|
1744
|
+
toItem: (parsed) => ({ kind: "recipe", facts: parsed })
|
|
1745
|
+
});
|
|
1746
|
+
case "record-kind":
|
|
1747
|
+
return itemOf({
|
|
1748
|
+
result: recordKindFactsSchema.safeParse(facts),
|
|
1749
|
+
toItem: (parsed) => ({ kind: "record-kind", facts: parsed })
|
|
1750
|
+
});
|
|
1751
|
+
case "symptom":
|
|
1752
|
+
return itemOf({
|
|
1753
|
+
result: symptomFactsSchema.safeParse(facts),
|
|
1754
|
+
toItem: (parsed) => ({ kind: "symptom", facts: parsed })
|
|
1755
|
+
});
|
|
1756
|
+
case "check":
|
|
1757
|
+
return itemOf({
|
|
1758
|
+
result: checkFactsSchema.safeParse(facts),
|
|
1759
|
+
toItem: (parsed) => ({ kind: "check", facts: parsed })
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
|
|
1764
|
+
// src/infrastructure/content-files/item-folders/item-identity.ts
|
|
1765
|
+
var ITEM_EXTENSION = ".md";
|
|
1766
|
+
var LIST_PAGE_FILE = "README.md";
|
|
1767
|
+
var SEGMENT_SEPARATOR = "/";
|
|
1768
|
+
var ROOT_KIND_FOLDERS = /* @__PURE__ */ new Map([
|
|
1769
|
+
["principles", "principle"],
|
|
1770
|
+
["rules", "rule"],
|
|
1771
|
+
["cases", "case"],
|
|
1772
|
+
["record-kinds", "record-kind"]
|
|
1773
|
+
]);
|
|
1774
|
+
var LANGUAGE_KIND_FOLDERS = /* @__PURE__ */ new Map([
|
|
1775
|
+
["symptoms", "symptom"],
|
|
1776
|
+
["recipes", "recipe"]
|
|
1777
|
+
]);
|
|
1778
|
+
var CHECKS_UNDER = "symptoms";
|
|
1779
|
+
var NOT_A_NAME = "is not a lower-case hyphenated name";
|
|
1780
|
+
var placed = (identity) => ({ outcome: "ok", value: identity });
|
|
1781
|
+
var refused = (refusal) => ({ outcome: "failed", error: { refusal } });
|
|
1782
|
+
var nameRefusalOf = (request) => {
|
|
1783
|
+
switch (request.kind) {
|
|
1784
|
+
case "record-kind":
|
|
1785
|
+
return recordKindNameSchema.safeParse(request.name).success ? void 0 : `${request.name} is not the name of a record kind`;
|
|
1786
|
+
case "principle":
|
|
1787
|
+
case "rule":
|
|
1788
|
+
case "case":
|
|
1789
|
+
case "recipe":
|
|
1790
|
+
case "symptom":
|
|
1791
|
+
case "check":
|
|
1792
|
+
return isCatalogueName(request.name) ? void 0 : `${request.name} ${NOT_A_NAME}`;
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
var named = (request) => {
|
|
1796
|
+
const refusal = nameRefusalOf(request);
|
|
1797
|
+
return refusal === void 0 ? placed(request) : refused(refusal);
|
|
1798
|
+
};
|
|
1799
|
+
var checkOf4 = (request) => isCatalogueName(request.symptom) ? named({ kind: "check", name: request.stem, within: request.symptom }) : refused(`${request.symptom} ${NOT_A_NAME}, and a check sits in the folder of its symptom`);
|
|
1800
|
+
var placementOfFolders = (request) => {
|
|
1801
|
+
const [first, second, third] = request.folders;
|
|
1802
|
+
const rootKind = first === void 0 ? void 0 : ROOT_KIND_FOLDERS.get(first);
|
|
1803
|
+
const languageKind = second === void 0 ? void 0 : LANGUAGE_KIND_FOLDERS.get(second);
|
|
1804
|
+
if (request.folders.length === 1 && rootKind !== void 0) {
|
|
1805
|
+
return named({ kind: rootKind, name: request.stem, within: void 0 });
|
|
1806
|
+
}
|
|
1807
|
+
if (request.folders.length === 2 && languageKind !== void 0) {
|
|
1808
|
+
return named({ kind: languageKind, name: request.stem, within: void 0 });
|
|
1809
|
+
}
|
|
1810
|
+
if (request.folders.length === 3 && second === CHECKS_UNDER && third !== void 0) {
|
|
1811
|
+
return checkOf4({ stem: request.stem, symptom: third });
|
|
1812
|
+
}
|
|
1813
|
+
return refused("sits where no kind of item is kept");
|
|
1814
|
+
};
|
|
1815
|
+
var segmentsOf = (request) => request.path.split(SEGMENT_SEPARATOR);
|
|
1816
|
+
var fileOf = (request) => segmentsOf(request).at(-1) ?? "";
|
|
1817
|
+
var folderPlaceOf = (request) => {
|
|
1818
|
+
const [first, second] = request.folders;
|
|
1819
|
+
const underRootKind = first !== void 0 && ROOT_KIND_FOLDERS.has(first);
|
|
1820
|
+
const underLanguageKind = second !== void 0 && LANGUAGE_KIND_FOLDERS.has(second);
|
|
1821
|
+
return underRootKind || underLanguageKind ? "under-a-kind-folder" : "elsewhere";
|
|
1822
|
+
};
|
|
1823
|
+
var fileRoleOf = (request) => {
|
|
1824
|
+
const file = fileOf(request);
|
|
1825
|
+
return file !== LIST_PAGE_FILE && file.endsWith(ITEM_EXTENSION) && folderPlaceOf({ folders: segmentsOf(request).slice(0, -1) }) === "under-a-kind-folder" ? "item" : "other";
|
|
1826
|
+
};
|
|
1827
|
+
var identityOf = (request) => placementOfFolders({
|
|
1828
|
+
folders: segmentsOf(request).slice(0, -1),
|
|
1829
|
+
stem: fileOf(request).slice(0, -ITEM_EXTENSION.length)
|
|
1830
|
+
});
|
|
1831
|
+
|
|
1832
|
+
// src/infrastructure/content-files/item-folders/item-listing.ts
|
|
1833
|
+
var PATH_SEPARATOR = "/";
|
|
1834
|
+
var byCodePoint = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
1835
|
+
var folderAt = (request) => {
|
|
1836
|
+
const joined = request.path.join({ segments: [request.root, ...request.within] });
|
|
1837
|
+
const folder = absolutePathSchema.safeParse(joined);
|
|
1838
|
+
return folder.success ? { outcome: "ok", value: folder.data } : {
|
|
1839
|
+
outcome: "failed",
|
|
1840
|
+
error: {
|
|
1841
|
+
kind: "directory-unreadable",
|
|
1842
|
+
path: request.root,
|
|
1843
|
+
detail: `${joined} is not an absolute path`
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
};
|
|
1847
|
+
var joinedLists = (lists) => {
|
|
1848
|
+
const failure = lists.find((list) => list.outcome === "failed");
|
|
1849
|
+
return failure ?? {
|
|
1850
|
+
outcome: "ok",
|
|
1851
|
+
value: lists.flatMap((list) => list.outcome === "ok" ? list.value : [])
|
|
1852
|
+
};
|
|
1853
|
+
};
|
|
1854
|
+
var listedEntry = (request) => request.entry.kind === "directory" ? listedWithin({ ...request, within: [...request.within, request.entry.name] }) : { outcome: "ok", value: [[...request.within, request.entry.name].join(PATH_SEPARATOR)] };
|
|
1855
|
+
var listedWithin = (request) => {
|
|
1856
|
+
const folder = folderAt(request);
|
|
1857
|
+
if (folder.outcome === "failed") {
|
|
1858
|
+
return folder;
|
|
1859
|
+
}
|
|
1860
|
+
const entries = request.directory.list({ path: folder.value });
|
|
1861
|
+
return entries.outcome === "failed" ? entries : joinedLists(entries.value.map((entry) => listedEntry({ ...request, entry })));
|
|
1862
|
+
};
|
|
1863
|
+
var filesUnder = (request) => {
|
|
1864
|
+
const listed = listedWithin({ ...request, within: [] });
|
|
1865
|
+
return listed.outcome === "failed" ? listed : { outcome: "ok", value: [...listed.value].sort(byCodePoint) };
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
// src/infrastructure/content-files/item-folders/item-text.ts
|
|
1869
|
+
var TITLE_LINE = /^# (?<title>\S.*)$/;
|
|
1870
|
+
var FENCE_LINE = /^```(?<language>[A-Za-z0-9_-]*)\s*$/;
|
|
1871
|
+
var FACTS_LANGUAGE = "json";
|
|
1872
|
+
var LINE_BREAK = /\r?\n/;
|
|
1873
|
+
var scanned = (scan, numbered) => {
|
|
1874
|
+
const fence = FENCE_LINE.exec(numbered.line);
|
|
1875
|
+
if (scan.open === void 0) {
|
|
1876
|
+
return fence === null ? scan : { open: { language: fence.groups?.language ?? "", lines: [] }, closed: scan.closed };
|
|
1877
|
+
}
|
|
1878
|
+
return fence === null ? {
|
|
1879
|
+
open: { language: scan.open.language, lines: [...scan.open.lines, numbered.line] },
|
|
1880
|
+
closed: scan.closed
|
|
1881
|
+
} : { open: void 0, closed: [...scan.closed, { ...scan.open, closedAt: numbered.index }] };
|
|
1882
|
+
};
|
|
1883
|
+
var titleOf = (request) => {
|
|
1884
|
+
const first = request.lines.find((line) => line.trim().length > 0);
|
|
1885
|
+
const title = first === void 0 ? void 0 : TITLE_LINE.exec(first)?.groups?.title;
|
|
1886
|
+
return title === void 0 ? { outcome: "failed", error: "does not start with a title line, # <title>" } : { outcome: "ok", value: title.trim() };
|
|
1887
|
+
};
|
|
1888
|
+
var factsFenceOf = (request) => {
|
|
1889
|
+
const scan = request.lines.map((line, index) => ({ line, index })).reduce(scanned, { open: void 0, closed: [] });
|
|
1890
|
+
if (scan.open !== void 0) {
|
|
1891
|
+
return { outcome: "failed", error: "has a fenced block that is never closed" };
|
|
1892
|
+
}
|
|
1893
|
+
const [only, ...others] = scan.closed.filter((fence) => fence.language === FACTS_LANGUAGE);
|
|
1894
|
+
if (only === void 0) {
|
|
1895
|
+
return { outcome: "failed", error: "holds no fenced json block of facts" };
|
|
1896
|
+
}
|
|
1897
|
+
return others.length > 0 ? { outcome: "failed", error: "holds more than one fenced json block; the facts are one block" } : { outcome: "ok", value: only };
|
|
1898
|
+
};
|
|
1899
|
+
var itemTextOf = (request) => {
|
|
1900
|
+
const lines = request.text.split(LINE_BREAK);
|
|
1901
|
+
const title = titleOf({ lines });
|
|
1902
|
+
if (title.outcome === "failed") {
|
|
1903
|
+
return title;
|
|
1904
|
+
}
|
|
1905
|
+
const fence = factsFenceOf({ lines });
|
|
1906
|
+
if (fence.outcome === "failed") {
|
|
1907
|
+
return fence;
|
|
1908
|
+
}
|
|
1909
|
+
const facts = parsedJson({ text: fence.value.lines.join("\n") });
|
|
1910
|
+
const prose = lines.slice(fence.value.closedAt + 1).join("\n").trim();
|
|
1911
|
+
return facts.outcome === "failed" ? { outcome: "failed", error: `has facts that are not JSON: ${facts.error}` } : { outcome: "ok", value: { title: title.value, facts: facts.value, prose } };
|
|
1912
|
+
};
|
|
1913
|
+
var FACTS_INDENT = 2;
|
|
1914
|
+
var itemTextFrom = (request) => `# ${request.title}
|
|
1915
|
+
|
|
1916
|
+
\`\`\`${FACTS_LANGUAGE}
|
|
1917
|
+
${JSON.stringify(request.facts, null, FACTS_INDENT)}
|
|
1918
|
+
\`\`\`
|
|
1919
|
+
`;
|
|
1920
|
+
|
|
1921
|
+
// src/infrastructure/content-files/item-folders/read-item-folder-catalogue.ts
|
|
1922
|
+
var malformed = (request) => ({
|
|
1923
|
+
kind: "file-malformed",
|
|
1924
|
+
path: request.path,
|
|
1925
|
+
detail: request.detail
|
|
1926
|
+
});
|
|
1927
|
+
var placedItemAt = (request) => {
|
|
1928
|
+
const path = request.path.join({ segments: [request.root, request.file] });
|
|
1929
|
+
const identity = identityOf({ path: request.file });
|
|
1930
|
+
if (identity.outcome === "failed") {
|
|
1931
|
+
return { outcome: "failed", error: malformed({ path, detail: identity.error.refusal }) };
|
|
1932
|
+
}
|
|
1933
|
+
const text = request.fileText.read({ path });
|
|
1934
|
+
if (text.outcome === "failed") {
|
|
1935
|
+
return {
|
|
1936
|
+
outcome: "failed",
|
|
1937
|
+
error: { kind: "file-unreadable", path, detail: text.error.detail }
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
const read = itemTextOf({ text: text.value });
|
|
1941
|
+
if (read.outcome === "failed") {
|
|
1942
|
+
return { outcome: "failed", error: malformed({ path, detail: read.error }) };
|
|
1943
|
+
}
|
|
1944
|
+
const facts = itemFactsOf({ kind: identity.value.kind, facts: read.value.facts });
|
|
1945
|
+
return facts.outcome === "failed" ? { outcome: "failed", error: malformed({ path, detail: facts.error }) } : {
|
|
1946
|
+
outcome: "ok",
|
|
1947
|
+
value: {
|
|
1948
|
+
name: identity.value.name,
|
|
1949
|
+
...request.sourcePrefix === void 0 ? {} : { sourceFile: `${request.sourcePrefix}/${request.file}` },
|
|
1950
|
+
within: identity.value.within,
|
|
1951
|
+
title: read.value.title,
|
|
1952
|
+
item: facts.value
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
};
|
|
1956
|
+
var placedItemsOf = (request) => {
|
|
1957
|
+
const reads = request.files.filter((file) => fileRoleOf({ path: file }) === "item").map((file) => placedItemAt({ ...request, file }));
|
|
1958
|
+
const failure = reads.find((each) => each.outcome === "failed");
|
|
1959
|
+
return failure?.outcome === "failed" ? failure : {
|
|
1960
|
+
outcome: "ok",
|
|
1961
|
+
value: reads.flatMap((each) => each.outcome === "ok" ? [each.value] : [])
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1964
|
+
var createSourceKey = (placed2) => placed2.within === void 0 ? placed2.name : checkAddressTextOf({ check: { name: placed2.name, symptom: { name: placed2.within } } });
|
|
1965
|
+
var mapItemsToSourceFiles = (request) => new Map(
|
|
1966
|
+
request.items.filter((placed2) => placed2.item.kind === request.kind).flatMap(
|
|
1967
|
+
(placed2) => placed2.sourceFile === void 0 ? [] : [[createSourceKey(placed2), placed2.sourceFile]]
|
|
1968
|
+
)
|
|
1969
|
+
);
|
|
1970
|
+
var addSourceFiles = (request) => {
|
|
1971
|
+
const symptomFiles = mapItemsToSourceFiles({ items: request.items, kind: "symptom" });
|
|
1972
|
+
const checkFiles = mapItemsToSourceFiles({ items: request.items, kind: "check" });
|
|
1973
|
+
const symptoms = request.content.symptoms.map((symptom) => {
|
|
1974
|
+
const sourceFile = symptomFiles.get(symptom.name);
|
|
1975
|
+
return sourceFile === void 0 ? symptom : { ...symptom, sourceFile };
|
|
1976
|
+
});
|
|
1977
|
+
const recipeFiles = mapItemsToSourceFiles({ items: request.items, kind: "recipe" });
|
|
1978
|
+
const recipes = request.content.recipes.map((recipe) => {
|
|
1979
|
+
const sourceFile = recipeFiles.get(recipe.name);
|
|
1980
|
+
return sourceFile === void 0 ? recipe : { ...recipe, sourceFile };
|
|
1981
|
+
});
|
|
1982
|
+
const checks = request.content.checks.map((check) => ({
|
|
1983
|
+
...check,
|
|
1984
|
+
page: checkFiles.get(checkAddressTextOf({ check })) ?? check.page
|
|
1985
|
+
}));
|
|
1986
|
+
return { ...request.content, recipes, symptoms, checks };
|
|
1987
|
+
};
|
|
1988
|
+
var holdingOf = (request) => {
|
|
1989
|
+
const file = catalogueFileOf({ items: request.items, beside: request.beside });
|
|
1990
|
+
const content = file.outcome === "failed" ? file : catalogueContentFromFile({
|
|
1991
|
+
file: file.value,
|
|
1992
|
+
ruleSet: request.ruleSet,
|
|
1993
|
+
inheritedRecordKinds: request.inheritedRecordKinds
|
|
1994
|
+
});
|
|
1995
|
+
if (content.outcome === "failed") {
|
|
1996
|
+
return { outcome: "failed", error: malformed({ path: request.root, detail: content.error }) };
|
|
1997
|
+
}
|
|
1998
|
+
return {
|
|
1999
|
+
outcome: "ok",
|
|
2000
|
+
value: {
|
|
2001
|
+
held: "catalogue",
|
|
2002
|
+
content: addSourceFiles({ content: content.value, items: request.items })
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
};
|
|
2006
|
+
var readItemFolderCatalogue = (request) => {
|
|
2007
|
+
const files = filesUnder(request);
|
|
2008
|
+
if (files.outcome === "failed") {
|
|
2009
|
+
return {
|
|
2010
|
+
outcome: "failed",
|
|
2011
|
+
error: { kind: "file-unreadable", path: files.error.path, detail: files.error.detail }
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
const items = placedItemsOf({ ...request, files: files.value });
|
|
2015
|
+
if (items.outcome === "failed") {
|
|
2016
|
+
return items;
|
|
2017
|
+
}
|
|
2018
|
+
return items.value.length === 0 ? { outcome: "ok", value: { held: "none" } } : holdingOf({ ...request, items: items.value });
|
|
2019
|
+
};
|
|
2020
|
+
var createItemFolderCatalogueRepository = (options) => ({
|
|
2021
|
+
read: () => readItemFolderCatalogue(options)
|
|
2022
|
+
});
|
|
2023
|
+
|
|
2024
|
+
// src/infrastructure/content-files/rule-sets/installed-pieces.ts
|
|
2025
|
+
var installedNamesPathOf = (request) => request.path.join({ segments: [request.installRoot, ...VERSION_ONE_NAMES_SEGMENTS] });
|
|
2026
|
+
var readInstalledNames = (request) => readVersionOneNames({ fileText: request.fileText, path: installedNamesPathOf(request) });
|
|
2027
|
+
var installedPieceOf = (request) => {
|
|
2028
|
+
const location = { ...request, ruleSetRoot: request.installRoot };
|
|
2029
|
+
const piece = readNamedPiece(location);
|
|
2030
|
+
if (piece.outcome === "failed") {
|
|
2031
|
+
return piece.error.kind === "piece-missing" ? { outcome: "ok", value: void 0 } : piece;
|
|
2032
|
+
}
|
|
2033
|
+
return {
|
|
2034
|
+
outcome: "ok",
|
|
2035
|
+
value: {
|
|
2036
|
+
mechanism: request.mechanism,
|
|
2037
|
+
examplesPath: piece.value.examplesPath,
|
|
2038
|
+
piece: piece.value
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
};
|
|
2042
|
+
var firstPieceFrom = (request) => {
|
|
2043
|
+
const [check, ...remaining] = request.checks;
|
|
2044
|
+
if (check === void 0) {
|
|
2045
|
+
return { outcome: "ok", value: void 0 };
|
|
2046
|
+
}
|
|
2047
|
+
const held = installedPieceOf({ ...request, ...check });
|
|
2048
|
+
return held.outcome === "failed" || held.value !== void 0 ? held : firstPieceFrom({ ...request, checks: remaining });
|
|
2049
|
+
};
|
|
2050
|
+
var firstInstalledPieceFor = (request) => firstPieceFrom({ ...request, checks: checksNamedFor(request) });
|
|
2051
|
+
var installedPiecesFor = (request) => {
|
|
2052
|
+
const held = everyOk({
|
|
2053
|
+
entries: request.mechanisms,
|
|
2054
|
+
resolve: (mechanism) => firstInstalledPieceFor({ ...request, mechanism })
|
|
2055
|
+
});
|
|
2056
|
+
return held.outcome === "failed" ? held : { outcome: "ok", value: held.value.filter((piece) => piece !== void 0) };
|
|
2057
|
+
};
|
|
2058
|
+
var catalogueClausesOf = (request) => {
|
|
2059
|
+
const forms = everyOk({
|
|
2060
|
+
entries: request.names.claimsPieceForms,
|
|
2061
|
+
resolve: (clause) => {
|
|
2062
|
+
const first = firstInstalledPieceFor({ ...request, clause, mechanism: "walker" });
|
|
2063
|
+
if (first.outcome === "failed") {
|
|
2064
|
+
return first;
|
|
2065
|
+
}
|
|
2066
|
+
const forms2 = Object.entries(first.value?.piece.forms ?? {});
|
|
2067
|
+
if (first.value === void 0 || forms2.length === 0) {
|
|
2068
|
+
return {
|
|
2069
|
+
outcome: "failed",
|
|
2070
|
+
error: {
|
|
2071
|
+
kind: "rule-set-invalid",
|
|
2072
|
+
path: installedNamesPathOf(request),
|
|
2073
|
+
detail: `no piece declares the forms of ${clauseAddressText({ address: clause })}`
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
const names = new Set(
|
|
2078
|
+
checksNamedFor({ names: request.names, clause }).map(checkAddressOfNames)
|
|
2079
|
+
);
|
|
2080
|
+
const unknown = forms2.find(([, check]) => !names.has(checkAddressOfNames(check)));
|
|
2081
|
+
if (unknown !== void 0) {
|
|
2082
|
+
const [form, check] = unknown;
|
|
2083
|
+
return {
|
|
2084
|
+
outcome: "failed",
|
|
2085
|
+
error: {
|
|
2086
|
+
kind: "file-malformed",
|
|
2087
|
+
path: first.value.piece.declarationPath,
|
|
2088
|
+
detail: `form ${form} names unregistered check ${checkAddressOfNames(check)}`
|
|
2089
|
+
}
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
return {
|
|
2093
|
+
outcome: "ok",
|
|
2094
|
+
value: {
|
|
2095
|
+
clause,
|
|
2096
|
+
sight: {
|
|
2097
|
+
kind: "symptom-by-form",
|
|
2098
|
+
forms: forms2.map(([form, { symptom }]) => ({ form, symptom }))
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
return forms.outcome === "failed" ? forms : { outcome: "ok", value: [...request.names.clauses, ...forms.value] };
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2107
|
+
// src/infrastructure/content-files/symptom-catalogues/read-symptom-catalogue.ts
|
|
2108
|
+
var namesOfRuleSet = (request) => request.upgradeNames !== void 0 ? { outcome: "ok", value: request.upgradeNames } : request.ruleSetRoot === request.installRoot ? readVersionOneNames({
|
|
2109
|
+
fileText: request.fileText,
|
|
2110
|
+
path: request.path.join({
|
|
2111
|
+
segments: [request.installRoot, ...VERSION_ONE_NAMES_SEGMENTS]
|
|
2112
|
+
})
|
|
2113
|
+
}) : { outcome: "ok", value: NO_VERSION_ONE_NAMES };
|
|
2114
|
+
var VERSION_ONE_RULE_FILE = "discipline.json";
|
|
2115
|
+
var versionOneRuleFilesOf = (request) => {
|
|
2116
|
+
const entries = request.directory.list({ path: request.itemRoot });
|
|
2117
|
+
if (entries.outcome === "failed") {
|
|
2118
|
+
return {
|
|
2119
|
+
outcome: "failed",
|
|
2120
|
+
error: { kind: "file-unreadable", path: entries.error.path, detail: entries.error.detail }
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
return {
|
|
2124
|
+
outcome: "ok",
|
|
2125
|
+
value: entries.value.flatMap((entry) => {
|
|
2126
|
+
const path = request.path.join({
|
|
2127
|
+
segments: [request.itemRoot, entry.name, VERSION_ONE_RULE_FILE]
|
|
2128
|
+
});
|
|
2129
|
+
return entry.kind === "directory" && request.fileText.exists({ path }) === "present" ? [path] : [];
|
|
2130
|
+
})
|
|
2131
|
+
};
|
|
2132
|
+
};
|
|
2133
|
+
var refusedWhenVersionOne = (request) => {
|
|
2134
|
+
if (request.holding.held === "catalogue") {
|
|
2135
|
+
return { outcome: "ok", value: request.holding };
|
|
2136
|
+
}
|
|
2137
|
+
const files = versionOneRuleFilesOf(request);
|
|
2138
|
+
if (files.outcome === "failed") {
|
|
2139
|
+
return files;
|
|
2140
|
+
}
|
|
2141
|
+
return files.value.length > 0 ? { outcome: "failed", error: { kind: "rule-set-not-upgraded", path: request.ruleSetRoot } } : { outcome: "ok", value: request.holding };
|
|
2142
|
+
};
|
|
2143
|
+
var readSymptomCatalogue = (request) => {
|
|
2144
|
+
const itemRoot = request.path.join({
|
|
2145
|
+
segments: [request.ruleSetRoot, ...SYMPTOM_CATALOGUE_SEGMENTS]
|
|
2146
|
+
});
|
|
2147
|
+
const root = absolutePathSchema.safeParse(itemRoot);
|
|
2148
|
+
if (!root.success) {
|
|
2149
|
+
return {
|
|
2150
|
+
outcome: "failed",
|
|
2151
|
+
error: { kind: "file-unreadable", path: itemRoot, detail: "is not an absolute path" }
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2154
|
+
const names = namesOfRuleSet(request);
|
|
2155
|
+
if (names.outcome === "failed") {
|
|
2156
|
+
return names;
|
|
2157
|
+
}
|
|
2158
|
+
const clauses = catalogueClausesOf({
|
|
2159
|
+
...request,
|
|
2160
|
+
installRoot: request.ruleSetRoot,
|
|
2161
|
+
names: names.value
|
|
2162
|
+
});
|
|
2163
|
+
if (clauses.outcome === "failed") {
|
|
2164
|
+
return clauses;
|
|
2165
|
+
}
|
|
2166
|
+
if (request.fileText.exists({ path: root.data }) === "absent") {
|
|
2167
|
+
return { outcome: "ok", value: { held: "none" } };
|
|
2168
|
+
}
|
|
2169
|
+
const beside = {
|
|
2170
|
+
engines: ENGINE_REGISTRY,
|
|
2171
|
+
clauses: clauses.value,
|
|
2172
|
+
clauseOfCheck: names.value.clauseOfCheck,
|
|
2173
|
+
formatsOfToday: names.value.formatsOfToday
|
|
2174
|
+
};
|
|
2175
|
+
const holding = createItemFolderCatalogueRepository({
|
|
2176
|
+
fileText: request.fileText,
|
|
2177
|
+
directory: request.directory,
|
|
2178
|
+
path: request.path,
|
|
2179
|
+
root: root.data,
|
|
2180
|
+
ruleSet: request.ruleSet,
|
|
2181
|
+
beside,
|
|
2182
|
+
inheritedRecordKinds: request.inheritedRecordKinds,
|
|
2183
|
+
sourcePrefix: request.ruleSetRoot === request.installRoot ? void 0 : SYMPTOM_CATALOGUE_SEGMENTS.join("/")
|
|
2184
|
+
}).read({});
|
|
2185
|
+
return holding.outcome === "failed" ? holding : refusedWhenVersionOne({ ...request, itemRoot: root.data, holding: holding.value });
|
|
2186
|
+
};
|
|
2187
|
+
var createSymptomCatalogueRepository = (options) => ({
|
|
2188
|
+
read: () => readSymptomCatalogue(options)
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
// src/infrastructure/content-files/symptom-catalogues/bound-catalogue.ts
|
|
2192
|
+
var readBoundCatalogue = (source) => {
|
|
2193
|
+
const holding = createSymptomCatalogueRepository(source).read({});
|
|
2194
|
+
if (holding.outcome === "failed") {
|
|
2195
|
+
return holding;
|
|
2196
|
+
}
|
|
2197
|
+
const checks = holding.value.held === "catalogue" ? holding.value.content.checks : [];
|
|
2198
|
+
const bindings = createEngineBindingsRepository(source).read({ checks });
|
|
2199
|
+
if (bindings.outcome === "failed") {
|
|
2200
|
+
return bindings;
|
|
2201
|
+
}
|
|
2202
|
+
const bound = holdingBoundTo({ holding: holding.value, bindings: bindings.value });
|
|
2203
|
+
return bound.outcome === "failed" ? {
|
|
2204
|
+
outcome: "failed",
|
|
2205
|
+
error: {
|
|
2206
|
+
kind: "file-malformed",
|
|
2207
|
+
path: source.path.join({ segments: [source.ruleSetRoot, ...SYMPTOM_CATALOGUE_SEGMENTS] }),
|
|
2208
|
+
detail: bound.error
|
|
2209
|
+
}
|
|
2210
|
+
} : bound;
|
|
2211
|
+
};
|
|
2212
|
+
var createBoundCatalogueOf = (options) => {
|
|
2213
|
+
const boundCatalogueOf = (request) => readBoundCatalogue({ ...request, directory: options.directory });
|
|
2214
|
+
return boundCatalogueOf;
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
// src/domain/language-layer/rule-content.ts
|
|
2218
|
+
var createRuleContent = (request) => ({
|
|
2219
|
+
symptoms: new Map(
|
|
2220
|
+
request.catalogues.flatMap(
|
|
2221
|
+
(catalogue) => catalogue.symptoms.map((symptom) => [
|
|
2222
|
+
ownedNameText(symptom),
|
|
2223
|
+
symptom
|
|
2224
|
+
])
|
|
2225
|
+
)
|
|
2226
|
+
)
|
|
2227
|
+
});
|
|
2228
|
+
var mapAddressToSymptom = (request) => {
|
|
2229
|
+
const symptom = request.content.symptoms.get(ownedNameText(request.symptom));
|
|
2230
|
+
return symptom === void 0 ? { outcome: "failed", error: { kind: "symptom-unheld", symptom: request.symptom } } : { outcome: "ok", value: symptom };
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2233
|
+
// src/application/run/engines/engine-checks.ts
|
|
2234
|
+
var mapChecksToEngineChecks = (request) => gatheredOutcomes({
|
|
2235
|
+
outcomes: request.checks.map((check) => {
|
|
2236
|
+
const symptom = mapAddressToSymptom({ content: request.content, symptom: check.symptom });
|
|
2237
|
+
if (symptom.outcome === "failed") return symptom;
|
|
2238
|
+
return {
|
|
2239
|
+
outcome: "ok",
|
|
2240
|
+
value: [
|
|
2241
|
+
{
|
|
2242
|
+
name: check.name,
|
|
2243
|
+
symptom: {
|
|
2244
|
+
ruleSet: check.symptom.ruleSet,
|
|
2245
|
+
name: check.symptom.name,
|
|
2246
|
+
title: symptom.value.title
|
|
2247
|
+
},
|
|
2248
|
+
engines: check.engines
|
|
2249
|
+
}
|
|
2250
|
+
]
|
|
2251
|
+
};
|
|
2252
|
+
})
|
|
2253
|
+
});
|
|
2254
|
+
var mapCataloguesToEngineChecks = (request) => mapChecksToEngineChecks({
|
|
2255
|
+
checks: request.catalogues.flatMap((catalogue) => catalogue.checks),
|
|
2256
|
+
content: createRuleContent({ catalogues: request.catalogues })
|
|
2257
|
+
});
|
|
2258
|
+
|
|
2259
|
+
// src/application/run/tool-catalogue.ts
|
|
2260
|
+
var unreadDetailOf = (request) => {
|
|
2261
|
+
const { error } = request;
|
|
2262
|
+
return error.kind === "file-unreadable" || error.kind === "file-malformed" ? error.detail : error.kind;
|
|
2263
|
+
};
|
|
2264
|
+
var toolCatalogueOf = (request) => {
|
|
2265
|
+
const path = request.path.join({
|
|
2266
|
+
segments: [request.installRoot, ...SYMPTOM_CATALOGUE_SEGMENTS]
|
|
2267
|
+
});
|
|
2268
|
+
const held = request.boundCatalogueOf({
|
|
2269
|
+
fileText: request.fileText,
|
|
2270
|
+
path: request.path,
|
|
2271
|
+
ruleSetRoot: request.installRoot,
|
|
2272
|
+
ruleSet: TOOL_RULE_SET,
|
|
2273
|
+
installRoot: request.installRoot,
|
|
2274
|
+
inheritedRecordKinds: []
|
|
2275
|
+
});
|
|
2276
|
+
if (held.outcome === "failed") {
|
|
2277
|
+
return {
|
|
2278
|
+
outcome: "failed",
|
|
2279
|
+
error: {
|
|
2280
|
+
kind: "catalogue-not-read",
|
|
2281
|
+
path,
|
|
2282
|
+
reason: { reason: "unreadable", detail: unreadDetailOf({ error: held.error }) }
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
return held.value.held === "catalogue" ? { outcome: "ok", value: held.value.catalogue } : {
|
|
2287
|
+
outcome: "failed",
|
|
2288
|
+
error: { kind: "catalogue-not-read", path, reason: { reason: "absent" } }
|
|
2289
|
+
};
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2292
|
+
export {
|
|
2293
|
+
pointedNameOf,
|
|
2294
|
+
indicatedNamesOf,
|
|
2295
|
+
symptomReadingOf,
|
|
2296
|
+
mapSymptomToAuthorisation,
|
|
2297
|
+
mapCheckToPartyNaming,
|
|
2298
|
+
listExamplesOfForm,
|
|
2299
|
+
createRuleContent,
|
|
2300
|
+
mapAddressToSymptom,
|
|
2301
|
+
onOneLine,
|
|
2302
|
+
quoted,
|
|
2303
|
+
catalogueNotesOf,
|
|
2304
|
+
carriedListingOf,
|
|
2305
|
+
recordsFileText,
|
|
2306
|
+
recordPlaceText,
|
|
2307
|
+
recordSubjectText,
|
|
2308
|
+
referencesText,
|
|
2309
|
+
recordNoteLine,
|
|
2310
|
+
refusalText,
|
|
2311
|
+
refusedLines,
|
|
2312
|
+
carriedLine,
|
|
2313
|
+
RECORDS_VERSION,
|
|
2314
|
+
RECORDS_FOLDER,
|
|
2315
|
+
NAMED_FOLDER_KINDS,
|
|
2316
|
+
recordsFileStandingOf,
|
|
2317
|
+
namedRecordsFileOf,
|
|
2318
|
+
NESTED_CONFIGURATION_ISSUE,
|
|
2319
|
+
unmeasuredLine,
|
|
2320
|
+
projectionProblemLine,
|
|
2321
|
+
assessmentLine,
|
|
2322
|
+
settingsNoteLine,
|
|
2323
|
+
mapChecksToEngineChecks,
|
|
2324
|
+
mapCataloguesToEngineChecks,
|
|
2325
|
+
runLoadFailureLine,
|
|
2326
|
+
SYMPTOM_CATALOGUE_SEGMENTS,
|
|
2327
|
+
ENGINE_REGISTRY,
|
|
2328
|
+
findCaseNameFaults,
|
|
2329
|
+
mapSymptomToAddress,
|
|
2330
|
+
mapCheckToAddress,
|
|
2331
|
+
findUnowedPointFaults,
|
|
2332
|
+
catalogueNameSchema,
|
|
2333
|
+
caseWireSchema,
|
|
2334
|
+
symptomWireSchema,
|
|
2335
|
+
catalogueFileSchema,
|
|
2336
|
+
mapWireToOwedPoint,
|
|
2337
|
+
VERSION_ONE_NAMES_SEGMENTS,
|
|
2338
|
+
NO_VERSION_ONE_NAMES,
|
|
2339
|
+
versionOneNamesOf,
|
|
2340
|
+
readVersionOneNames,
|
|
2341
|
+
itemTextFrom,
|
|
2342
|
+
installedNamesPathOf,
|
|
2343
|
+
readInstalledNames,
|
|
2344
|
+
firstInstalledPieceFor,
|
|
2345
|
+
installedPiecesFor,
|
|
2346
|
+
versionOneRuleFilesOf,
|
|
2347
|
+
readBoundCatalogue,
|
|
2348
|
+
createBoundCatalogueOf,
|
|
2349
|
+
toolCatalogueOf
|
|
2350
|
+
};
|