@hailstails/hone 0.1.0-pre.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +33 -7
- package/CHANGELOG.md +19 -0
- package/MIGRATING.md +31 -6
- package/README.md +73 -24
- package/api/audit.d.ts +6 -0
- package/api/audit.js +9 -1
- package/api/testing.js +36 -8
- package/chunks/{chunk-XE6RNNZB.js → chunk-63SJV5ZY.js} +1395 -1339
- package/chunks/{chunk-RNXPEK2U.js → chunk-BLGGM7AV.js} +2 -2
- package/chunks/{chunk-OKQHVZLO.js → chunk-CBWWAKQY.js} +1 -1
- package/chunks/{chunk-5X2BR42Y.js → chunk-FR4FASVM.js} +15 -24
- package/chunks/chunk-MXSIQPCV.js +13 -0
- package/chunks/{chunk-LHVFZMXD.js → chunk-MZTLH4EU.js} +60 -20
- package/chunks/chunk-NA5L6PUE.js +15 -0
- package/chunks/{chunk-OVEQ37JQ.js → chunk-PVCA3ISA.js} +42 -17
- package/chunks/chunk-RWQ4UNKY.js +24 -0
- package/chunks/{chunk-YL6WR3QW.js → chunk-Y4SMWOD2.js} +1 -1
- package/chunks/chunk-YLZ73C7O.js +0 -0
- package/chunks/{chunk-NILRE23T.js → chunk-Z4UBS7WI.js} +1 -1
- package/core/check/tool-command.js +702 -22
- package/core/conformance/conformance-testing-types.d.ts +2 -0
- package/core/mechanism-port/runner-module-types.d.ts +2 -0
- package/core/rule-set-reader/authored-rule-set-types.d.ts +2 -0
- package/core/values/edition-types.d.ts +16 -0
- package/docs/extending.md +31 -9
- package/docs/output-contract.md +101 -15
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -2
- package/mechanisms/audit/CD-27/piece.json +5 -1
- package/mechanisms/audit/CD-27/test-body-logic.js +55 -4
- package/mechanisms/audit/CD-5/comments-directives.js +4 -3
- package/mechanisms/audit/runner/runner.js +6 -5
- package/mechanisms/eslint/runner/runner.js +8 -4
- package/package.json +1 -1
- package/rules/CD-27/CHECKS.md +31 -1
- package/rules/CD-27/discipline.json +74 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
repoPathSchema,
|
|
3
3
|
snippetSchema
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MZTLH4EU.js";
|
|
5
5
|
import {
|
|
6
6
|
clauseAddressObjectSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FR4FASVM.js";
|
|
8
8
|
|
|
9
9
|
// core/mechanism-port/runner-result-schema.ts
|
|
10
10
|
import { z as z3 } from "zod";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDefaultPathPort,
|
|
3
3
|
installRootAboveEntry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MZTLH4EU.js";
|
|
5
5
|
|
|
6
6
|
// core/mechanism-port/toolchain-bound-runner.ts
|
|
7
7
|
var builtOnce = (request) => request.toolchain.then((loaded) => loaded.outcome === "failed" ? loaded : { outcome: "ok", value: request.runnerOf(loaded.value) });
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// core/values/branded-schema.ts
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
var brandedTextSchema = (request) => request.text.transform((text, context) => {
|
|
7
|
-
if (request.isBranded(text)) {
|
|
8
|
-
return text;
|
|
9
|
-
}
|
|
10
|
-
context.addIssue({ code: "custom", message: request.refusal });
|
|
11
|
-
return z.NEVER;
|
|
12
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
brandedTextSchema
|
|
3
|
+
} from "./chunk-MXSIQPCV.js";
|
|
13
4
|
|
|
14
5
|
// core/values/identifiers.ts
|
|
6
|
+
import { z } from "zod";
|
|
15
7
|
var RULE_SET_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
16
8
|
var DISCIPLINE_ID_PATTERN = /^[A-Z]{2,4}-[0-9]+[a-z]?$/;
|
|
17
9
|
var CLAUSE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
@@ -28,22 +20,22 @@ var isDisciplineId = (text) => DISCIPLINE_ID_PATTERN.test(text);
|
|
|
28
20
|
var isClauseId = (text) => CLAUSE_ID_PATTERN.test(text);
|
|
29
21
|
var isMechanismId = (text) => MECHANISM_ID_PATTERN.test(text) && !RESERVED_CLAUSE_STATES.has(text);
|
|
30
22
|
var ruleSetNameSchema = brandedTextSchema({
|
|
31
|
-
text:
|
|
23
|
+
text: z.string().regex(RULE_SET_NAME_PATTERN),
|
|
32
24
|
isBranded: isRuleSetName,
|
|
33
25
|
refusal: NOT_AN_IDENTIFIER
|
|
34
26
|
});
|
|
35
27
|
var disciplineIdSchema = brandedTextSchema({
|
|
36
|
-
text:
|
|
28
|
+
text: z.string().regex(DISCIPLINE_ID_PATTERN),
|
|
37
29
|
isBranded: isDisciplineId,
|
|
38
30
|
refusal: NOT_AN_IDENTIFIER
|
|
39
31
|
});
|
|
40
32
|
var clauseIdSchema = brandedTextSchema({
|
|
41
|
-
text:
|
|
33
|
+
text: z.string().regex(CLAUSE_ID_PATTERN),
|
|
42
34
|
isBranded: isClauseId,
|
|
43
35
|
refusal: NOT_AN_IDENTIFIER
|
|
44
36
|
});
|
|
45
37
|
var mechanismIdSchema = brandedTextSchema({
|
|
46
|
-
text:
|
|
38
|
+
text: z.string().regex(MECHANISM_ID_PATTERN).superRefine((text, context) => {
|
|
47
39
|
const reservedFor = RESERVED_CLAUSE_STATES.get(text);
|
|
48
40
|
if (reservedFor !== void 0) {
|
|
49
41
|
context.addIssue({ code: "custom", message: `"${text}" is reserved for ${reservedFor}, so it cannot name a mechanism` });
|
|
@@ -54,7 +46,7 @@ var mechanismIdSchema = brandedTextSchema({
|
|
|
54
46
|
});
|
|
55
47
|
|
|
56
48
|
// core/values/clause-address.ts
|
|
57
|
-
import { z as
|
|
49
|
+
import { z as z2 } from "zod";
|
|
58
50
|
|
|
59
51
|
// core/values/tool-identity.ts
|
|
60
52
|
var identified = (identity) => identity;
|
|
@@ -72,24 +64,24 @@ var TOOL_IDENTITY = identified({
|
|
|
72
64
|
// core/values/clause-address.ts
|
|
73
65
|
var TOOL_RULE_SET = TOOL_IDENTITY.ownRuleSet;
|
|
74
66
|
var CLAUSE_ADDRESS_TEXT = /^(?:(?<ruleSet>[^/#]+)\/)?(?<discipline>[^/#]+)#(?<clause>[^/#]+)$/;
|
|
75
|
-
var clauseAddressObjectSchema =
|
|
76
|
-
ruleSet:
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
var clauseAddressObjectSchema = z2.object({
|
|
68
|
+
ruleSet: z2.union([
|
|
69
|
+
z2.literal(TOOL_RULE_SET),
|
|
70
|
+
z2.object({
|
|
79
71
|
name: ruleSetNameSchema.refine((name) => name !== TOOL_RULE_SET)
|
|
80
72
|
})
|
|
81
73
|
]),
|
|
82
74
|
discipline: disciplineIdSchema,
|
|
83
75
|
clause: clauseIdSchema
|
|
84
76
|
});
|
|
85
|
-
var clauseAddressSchema =
|
|
77
|
+
var clauseAddressSchema = z2.string().transform((text, context) => {
|
|
86
78
|
const parts = CLAUSE_ADDRESS_TEXT.exec(text)?.groups;
|
|
87
79
|
if (parts === void 0) {
|
|
88
80
|
context.addIssue({
|
|
89
81
|
code: "custom",
|
|
90
82
|
message: "is not a clause address of the form [<ruleSet>/]<discipline>#<clause>"
|
|
91
83
|
});
|
|
92
|
-
return
|
|
84
|
+
return z2.NEVER;
|
|
93
85
|
}
|
|
94
86
|
return {
|
|
95
87
|
ruleSet: parts.ruleSet === void 0 || parts.ruleSet === TOOL_RULE_SET ? TOOL_RULE_SET : { name: parts.ruleSet },
|
|
@@ -101,7 +93,6 @@ var clauseAddressText = (request) => request.address.ruleSet === TOOL_RULE_SET ?
|
|
|
101
93
|
var sameClauseAddress = (request) => clauseAddressText({ address: request.left }) === clauseAddressText({ address: request.right }) ? "same" : "different";
|
|
102
94
|
|
|
103
95
|
export {
|
|
104
|
-
brandedTextSchema,
|
|
105
96
|
NOT_RUN,
|
|
106
97
|
NOT_ADOPTED,
|
|
107
98
|
ruleSetNameSchema,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// core/values/branded-schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var brandedTextSchema = (request) => request.text.transform((text, context) => {
|
|
4
|
+
if (request.isBranded(text)) {
|
|
5
|
+
return text;
|
|
6
|
+
}
|
|
7
|
+
context.addIssue({ code: "custom", message: request.refusal });
|
|
8
|
+
return z.NEVER;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
brandedTextSchema
|
|
13
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
brandedTextSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MXSIQPCV.js";
|
|
4
4
|
|
|
5
5
|
// core/platform-ports/file-system-port.ts
|
|
6
|
-
import { accessSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { accessSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
7
7
|
var NO_SUCH_FILE_CODE = "ENOENT";
|
|
8
8
|
var presenceAfterAccessFailure = (request) => request.thrown instanceof Error && "code" in request.thrown && request.thrown.code === NO_SUCH_FILE_CODE ? "absent" : "present";
|
|
9
9
|
var failureDetail = (request) => request.thrown instanceof Error ? request.thrown.message : String(request.thrown);
|
|
@@ -75,24 +75,45 @@ var defaultFileRemovalSurface = {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
var createDefaultFileRemovalPort = (_options) => createFileRemovalPort({ fileSystem: defaultFileRemovalSurface });
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
78
|
+
var createDirectoryPort = (options) => ({
|
|
79
|
+
list: (request) => {
|
|
80
|
+
try {
|
|
81
|
+
const entries = options.directory.list({ path: request.path });
|
|
82
|
+
return {
|
|
83
|
+
outcome: "ok",
|
|
84
|
+
value: [...entries].sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
|
|
85
|
+
};
|
|
86
|
+
} catch (thrown) {
|
|
87
|
+
return {
|
|
88
|
+
outcome: "failed",
|
|
89
|
+
error: { kind: "directory-unreadable", path: request.path, detail: failureDetail({ thrown }) }
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
create: (request) => {
|
|
94
|
+
try {
|
|
95
|
+
options.directory.create({ path: request.path });
|
|
96
|
+
return { outcome: "ok", value: void 0 };
|
|
97
|
+
} catch (thrown) {
|
|
98
|
+
return {
|
|
99
|
+
outcome: "failed",
|
|
100
|
+
error: { kind: "directory-uncreatable", path: request.path, detail: failureDetail({ thrown }) }
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
var defaultDirectorySurface = {
|
|
106
|
+
list: (request) => readdirSync(request.path, { withFileTypes: true }).map((entry) => ({
|
|
107
|
+
name: entry.name,
|
|
108
|
+
kind: entry.isDirectory() ? "directory" : "file"
|
|
109
|
+
})),
|
|
110
|
+
create: (request) => {
|
|
111
|
+
mkdirSync(request.path, { recursive: true });
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var createDefaultDirectoryPort = (_options) => createDirectoryPort({
|
|
115
|
+
directory: defaultDirectorySurface
|
|
93
116
|
});
|
|
94
|
-
var defaultImportModule = (request) => import(pathToFileURL(request.path).href);
|
|
95
|
-
var createDefaultModuleLoaderPort = (_options) => createModuleLoaderPort({ importModule: defaultImportModule });
|
|
96
117
|
|
|
97
118
|
// core/platform-ports/path-port.ts
|
|
98
119
|
import platformPath, { posix, win32 } from "node:path";
|
|
@@ -251,6 +272,24 @@ var createPathPort = (options) => portOver({ surface: surfaceOf({ flavour: optio
|
|
|
251
272
|
var defaultWorkingDirectory = () => process.cwd();
|
|
252
273
|
var createDefaultPathPort = (_options) => createPathPort({ flavour: "platform", workingDirectory: defaultWorkingDirectory });
|
|
253
274
|
|
|
275
|
+
// core/platform-ports/module-loader-port.ts
|
|
276
|
+
import { pathToFileURL } from "node:url";
|
|
277
|
+
var createModuleLoaderPort = (options) => ({
|
|
278
|
+
load: (request) => Promise.resolve().then(() => options.importModule({ path: request.path })).then(
|
|
279
|
+
(namespace) => ({ outcome: "ok", value: namespace }),
|
|
280
|
+
(thrown) => ({
|
|
281
|
+
outcome: "failed",
|
|
282
|
+
error: {
|
|
283
|
+
kind: "module-unloadable",
|
|
284
|
+
path: request.path,
|
|
285
|
+
detail: thrown instanceof Error ? thrown.message : String(thrown)
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
)
|
|
289
|
+
});
|
|
290
|
+
var defaultImportModule = (request) => import(pathToFileURL(request.path).href);
|
|
291
|
+
var createDefaultModuleLoaderPort = (_options) => createModuleLoaderPort({ importModule: defaultImportModule });
|
|
292
|
+
|
|
254
293
|
// core/values/install-layout.ts
|
|
255
294
|
var FOLDERS_BETWEEN_INSTALL_ROOT_AND_ENTRY = {
|
|
256
295
|
api: 1,
|
|
@@ -402,13 +441,14 @@ var snippetSchema = z4.string().transform((text) => {
|
|
|
402
441
|
export {
|
|
403
442
|
createDefaultFileTextPort,
|
|
404
443
|
createDefaultFileRemovalPort,
|
|
444
|
+
createDefaultDirectoryPort,
|
|
405
445
|
isRepoPathText,
|
|
406
446
|
repoPathTextSchema,
|
|
407
447
|
brandedRepoPathSchema,
|
|
408
448
|
repoPathSchema,
|
|
409
|
-
createDefaultModuleLoaderPort,
|
|
410
449
|
absolutePathSchema,
|
|
411
450
|
createDefaultPathPort,
|
|
451
|
+
createDefaultModuleLoaderPort,
|
|
412
452
|
NOT_INSTALLED,
|
|
413
453
|
versionSupport,
|
|
414
454
|
gatheredPeerFailure,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// core/values/edition-reach.ts
|
|
2
|
+
var EDITION_PATTERN = /^[1-9][0-9]*$/;
|
|
3
|
+
var isEdition = (text) => EDITION_PATTERN.test(text);
|
|
4
|
+
var ordinalOf = (request) => Number(request.edition);
|
|
5
|
+
var editionReaches = (request) => ordinalOf({ edition: request.edition }) >= ordinalOf({ edition: request.introducedIn }) ? "reached" : "not-reached";
|
|
6
|
+
var editionOrder = (request) => request.editions.every(
|
|
7
|
+
(edition, index) => request.editions.slice(0, index).every((earlier) => ordinalOf({ edition: earlier }) < ordinalOf({ edition }))
|
|
8
|
+
) ? "ascending" : "unordered";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
EDITION_PATTERN,
|
|
12
|
+
isEdition,
|
|
13
|
+
editionReaches,
|
|
14
|
+
editionOrder
|
|
15
|
+
};
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clauseEditionsSchema,
|
|
3
|
+
editionSchema
|
|
4
|
+
} from "./chunk-RWQ4UNKY.js";
|
|
1
5
|
import {
|
|
2
6
|
repoPathSchema
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MZTLH4EU.js";
|
|
4
8
|
import {
|
|
5
9
|
clauseIdSchema,
|
|
6
10
|
disciplineIdSchema,
|
|
7
11
|
mechanismIdSchema
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
|
|
10
|
-
// core/values/parsed-json.ts
|
|
11
|
-
var parsedJson = (request) => {
|
|
12
|
-
try {
|
|
13
|
-
const parsed = JSON.parse(request.text);
|
|
14
|
-
return { outcome: "ok", value: parsed };
|
|
15
|
-
} catch (thrown) {
|
|
16
|
-
return {
|
|
17
|
-
outcome: "failed",
|
|
18
|
-
error: thrown instanceof Error ? thrown.message : String(thrown)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
12
|
+
} from "./chunk-FR4FASVM.js";
|
|
22
13
|
|
|
23
14
|
// core/rule-set-reader/rule-set-reader.ts
|
|
24
15
|
import { z } from "zod";
|
|
@@ -52,6 +43,19 @@ var sameJsonValue = (request) => {
|
|
|
52
43
|
return left === right ? "same" : "different";
|
|
53
44
|
};
|
|
54
45
|
|
|
46
|
+
// core/values/parsed-json.ts
|
|
47
|
+
var parsedJson = (request) => {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(request.text);
|
|
50
|
+
return { outcome: "ok", value: parsed };
|
|
51
|
+
} catch (thrown) {
|
|
52
|
+
return {
|
|
53
|
+
outcome: "failed",
|
|
54
|
+
error: thrown instanceof Error ? thrown.message : String(thrown)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
55
59
|
// core/rule-set-reader/rule-set-reader.ts
|
|
56
60
|
var SUPPORTED_VERSION = 1;
|
|
57
61
|
var readVersionOneJson = (request) => {
|
|
@@ -84,7 +88,8 @@ var sourceCaseSchema = z.object({
|
|
|
84
88
|
name: z.string(),
|
|
85
89
|
fileName: repoPathSchema,
|
|
86
90
|
source: z.string(),
|
|
87
|
-
expectedLines: z.array(z.number())
|
|
91
|
+
expectedLines: z.array(z.number()),
|
|
92
|
+
edition: editionSchema.optional()
|
|
88
93
|
});
|
|
89
94
|
var flagCaseSchema = sourceCaseSchema.refine(
|
|
90
95
|
(sourceCase) => entryCount(sourceCase.expectedLines) === "some",
|
|
@@ -138,6 +143,7 @@ var clauseSettingDeclarationSchema = z.strictObject({
|
|
|
138
143
|
context.addIssue({ code: "custom", path: ["default"], message: "the default must be one of the choices" });
|
|
139
144
|
}
|
|
140
145
|
});
|
|
146
|
+
var RESERVED_EDITION_SETTING = "edition";
|
|
141
147
|
var pieceFileSchema = z.object({
|
|
142
148
|
version: z.literal(SUPPORTED_VERSION),
|
|
143
149
|
discipline: disciplineIdSchema,
|
|
@@ -146,7 +152,10 @@ var pieceFileSchema = z.object({
|
|
|
146
152
|
z.object({
|
|
147
153
|
clause: clauseIdSchema,
|
|
148
154
|
settings: z.unknown(),
|
|
149
|
-
clauseSettings: z.record(z.string().min(1), clauseSettingDeclarationSchema).default({})
|
|
155
|
+
clauseSettings: z.record(z.string().min(1), clauseSettingDeclarationSchema).default({}).refine((declarations) => !Object.hasOwn(declarations, RESERVED_EDITION_SETTING), {
|
|
156
|
+
error: `${RESERVED_EDITION_SETTING} is reserved for the clause's editions; declare them under editions`
|
|
157
|
+
}),
|
|
158
|
+
editions: clauseEditionsSchema
|
|
150
159
|
})
|
|
151
160
|
).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
|
|
152
161
|
error: "two entries name the same clause"
|
|
@@ -191,6 +200,17 @@ var readDisciplineFile = (request) => {
|
|
|
191
200
|
}
|
|
192
201
|
return { outcome: "ok", value: parsed.data };
|
|
193
202
|
};
|
|
203
|
+
var undeclaredCaseEditionOf = (request) => request.piece.clauses.flatMap((entry) => {
|
|
204
|
+
const definition = request.discipline.clauses.find(
|
|
205
|
+
(clause) => clause.id === entry.clause && clause.kind === "mechanical"
|
|
206
|
+
);
|
|
207
|
+
const cases = definition === void 0 ? [] : [...definition.cases.flag, ...definition.cases.allow];
|
|
208
|
+
return cases.flatMap(
|
|
209
|
+
(sourceCase) => sourceCase.edition === void 0 || entry.editions.declared.includes(sourceCase.edition) ? [] : [
|
|
210
|
+
`case ${sourceCase.name} of clause ${entry.clause} runs under edition ${sourceCase.edition}, which this piece does not declare; it declares ${entry.editions.declared.join(", ")}`
|
|
211
|
+
]
|
|
212
|
+
);
|
|
213
|
+
}).at(0);
|
|
194
214
|
var readPieceFile = (request) => {
|
|
195
215
|
const path = pieceFilePath({
|
|
196
216
|
path: request.path,
|
|
@@ -227,6 +247,10 @@ var readPieceFile = (request) => {
|
|
|
227
247
|
detail: `clause ${undeclared.clause} is not declared by discipline ${request.discipline.id}`
|
|
228
248
|
});
|
|
229
249
|
}
|
|
250
|
+
const unsupported = undeclaredCaseEditionOf({ piece, discipline: request.discipline });
|
|
251
|
+
if (unsupported !== void 0) {
|
|
252
|
+
return ruleSetInvalid({ path, detail: unsupported });
|
|
253
|
+
}
|
|
230
254
|
return { outcome: "ok", value: piece };
|
|
231
255
|
};
|
|
232
256
|
|
|
@@ -240,6 +264,7 @@ export {
|
|
|
240
264
|
sameJsonValue,
|
|
241
265
|
parsedJson,
|
|
242
266
|
readVersionOneJson,
|
|
267
|
+
RESERVED_EDITION_SETTING,
|
|
243
268
|
disciplineFilePath,
|
|
244
269
|
pieceFilePath,
|
|
245
270
|
readDisciplineFile,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EDITION_PATTERN,
|
|
3
|
+
editionOrder,
|
|
4
|
+
isEdition
|
|
5
|
+
} from "./chunk-NA5L6PUE.js";
|
|
6
|
+
import {
|
|
7
|
+
brandedTextSchema
|
|
8
|
+
} from "./chunk-MXSIQPCV.js";
|
|
9
|
+
|
|
10
|
+
// core/values/edition.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var editionSchema = brandedTextSchema({
|
|
13
|
+
text: z.string().regex(EDITION_PATTERN),
|
|
14
|
+
isBranded: isEdition,
|
|
15
|
+
refusal: "not an edition: a whole number from 1, written as text"
|
|
16
|
+
});
|
|
17
|
+
var FIRST_EDITION = editionSchema.parse("1");
|
|
18
|
+
var clauseEditionsSchema = z.tuple([editionSchema], editionSchema).default([FIRST_EDITION]).refine((editions) => editionOrder({ editions }) === "ascending", { error: "editions must be listed in ascending order, each once" }).transform(([first, ...later]) => ({ declared: [first, ...later], default: first, latest: later.at(-1) ?? first }));
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
editionSchema,
|
|
22
|
+
FIRST_EDITION,
|
|
23
|
+
clauseEditionsSchema
|
|
24
|
+
};
|
|
File without changes
|