@nowline/core 0.8.6 → 0.10.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/README.md +9 -0
- package/dist/convert/printer.d.ts.map +1 -1
- package/dist/convert/printer.js +20 -9
- package/dist/convert/printer.js.map +1 -1
- package/dist/convert/schema.d.ts +7 -0
- package/dist/convert/schema.d.ts.map +1 -1
- package/dist/convert/schema.js +1 -1
- package/dist/convert/schema.js.map +1 -1
- package/dist/generated/ast.d.ts +134 -24
- package/dist/generated/ast.d.ts.map +1 -1
- package/dist/generated/ast.js +95 -3
- package/dist/generated/ast.js.map +1 -1
- package/dist/generated/grammar.d.ts.map +1 -1
- package/dist/generated/grammar.js +434 -148
- package/dist/generated/grammar.js.map +1 -1
- package/dist/i18n/codes.d.ts +1 -1
- package/dist/i18n/codes.d.ts.map +1 -1
- package/dist/i18n/codes.js +44 -1
- package/dist/i18n/codes.js.map +1 -1
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.en.d.ts +107 -0
- package/dist/i18n/messages.en.d.ts.map +1 -1
- package/dist/i18n/messages.en.js +220 -1
- package/dist/i18n/messages.en.js.map +1 -1
- package/dist/i18n/messages.fr.d.ts.map +1 -1
- package/dist/i18n/messages.fr.js +250 -1
- package/dist/i18n/messages.fr.js.map +1 -1
- package/dist/i18n/wave-message-types.d.ts +238 -0
- package/dist/i18n/wave-message-types.d.ts.map +1 -0
- package/dist/i18n/wave-message-types.js +11 -0
- package/dist/i18n/wave-message-types.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +9 -0
- package/dist/internal.js.map +1 -0
- package/dist/language/ast-walk.d.ts +31 -0
- package/dist/language/ast-walk.d.ts.map +1 -0
- package/dist/language/ast-walk.js +109 -0
- package/dist/language/ast-walk.js.map +1 -0
- package/dist/language/calendar-declarations.d.ts +31 -0
- package/dist/language/calendar-declarations.d.ts.map +1 -0
- package/dist/language/calendar-declarations.js +99 -0
- package/dist/language/calendar-declarations.js.map +1 -0
- package/dist/language/include-references.d.ts +11 -0
- package/dist/language/include-references.d.ts.map +1 -0
- package/dist/language/include-references.js +45 -0
- package/dist/language/include-references.js.map +1 -0
- package/dist/language/include-resolver.d.ts +78 -1
- package/dist/language/include-resolver.d.ts.map +1 -1
- package/dist/language/include-resolver.js +190 -12
- package/dist/language/include-resolver.js.map +1 -1
- package/dist/language/include-waves.d.ts +73 -0
- package/dist/language/include-waves.d.ts.map +1 -0
- package/dist/language/include-waves.js +319 -0
- package/dist/language/include-waves.js.map +1 -0
- package/dist/language/nowline-validator.d.ts +6 -1
- package/dist/language/nowline-validator.d.ts.map +1 -1
- package/dist/language/nowline-validator.js +95 -1589
- package/dist/language/nowline-validator.js.map +1 -1
- package/dist/language/references.d.ts +14 -0
- package/dist/language/references.d.ts.map +1 -0
- package/dist/language/references.js +36 -0
- package/dist/language/references.js.map +1 -0
- package/dist/language/style-chain.d.ts +37 -0
- package/dist/language/style-chain.d.ts.map +1 -0
- package/dist/language/style-chain.js +55 -0
- package/dist/language/style-chain.js.map +1 -0
- package/dist/language/validator/calendar.d.ts +9 -0
- package/dist/language/validator/calendar.d.ts.map +1 -0
- package/dist/language/validator/calendar.js +250 -0
- package/dist/language/validator/calendar.js.map +1 -0
- package/dist/language/validator/entities.d.ts +23 -0
- package/dist/language/validator/entities.d.ts.map +1 -0
- package/dist/language/validator/entities.js +261 -0
- package/dist/language/validator/entities.js.map +1 -0
- package/dist/language/validator/properties.d.ts +18 -0
- package/dist/language/validator/properties.d.ts.map +1 -0
- package/dist/language/validator/properties.js +356 -0
- package/dist/language/validator/properties.js.map +1 -0
- package/dist/language/validator/references.d.ts +7 -0
- package/dist/language/validator/references.d.ts.map +1 -0
- package/dist/language/validator/references.js +261 -0
- package/dist/language/validator/references.js.map +1 -0
- package/dist/language/validator/structure.d.ts +16 -0
- package/dist/language/validator/structure.d.ts.map +1 -0
- package/dist/language/validator/structure.js +166 -0
- package/dist/language/validator/structure.js.map +1 -0
- package/dist/language/validator/style.d.ts +5 -0
- package/dist/language/validator/style.d.ts.map +1 -0
- package/dist/language/validator/style.js +126 -0
- package/dist/language/validator/style.js.map +1 -0
- package/dist/language/validator/support.d.ts +35 -0
- package/dist/language/validator/support.d.ts.map +1 -0
- package/dist/language/validator/support.js +49 -0
- package/dist/language/validator/support.js.map +1 -0
- package/dist/language/validator/symbols.d.ts +6 -0
- package/dist/language/validator/symbols.d.ts.map +1 -0
- package/dist/language/validator/symbols.js +131 -0
- package/dist/language/validator/symbols.js.map +1 -0
- package/dist/language/validator/tables.d.ts +34 -0
- package/dist/language/validator/tables.d.ts.map +1 -0
- package/dist/language/validator/tables.js +120 -0
- package/dist/language/validator/tables.js.map +1 -0
- package/dist/language/validator-utils.d.ts +32 -0
- package/dist/language/validator-utils.d.ts.map +1 -0
- package/dist/language/validator-utils.js +118 -0
- package/dist/language/validator-utils.js.map +1 -0
- package/dist/language/value-tables.d.ts +107 -0
- package/dist/language/value-tables.d.ts.map +1 -0
- package/dist/language/value-tables.js +240 -0
- package/dist/language/value-tables.js.map +1 -0
- package/dist/language/waves-order.d.ts +51 -0
- package/dist/language/waves-order.d.ts.map +1 -0
- package/dist/language/waves-order.js +787 -0
- package/dist/language/waves-order.js.map +1 -0
- package/dist/language/waves-plan.d.ts +45 -0
- package/dist/language/waves-plan.d.ts.map +1 -0
- package/dist/language/waves-plan.js +64 -0
- package/dist/language/waves-plan.js.map +1 -0
- package/dist/language/waves.d.ts +96 -0
- package/dist/language/waves.d.ts.map +1 -0
- package/dist/language/waves.js +575 -0
- package/dist/language/waves.js.map +1 -0
- package/dist/util/props.d.ts +27 -0
- package/dist/util/props.d.ts.map +1 -0
- package/dist/util/props.js +49 -0
- package/dist/util/props.js.map +1 -0
- package/dist/util/single-line.d.ts +14 -0
- package/dist/util/single-line.d.ts.map +1 -0
- package/dist/util/single-line.js +16 -0
- package/dist/util/single-line.js.map +1 -0
- package/package.json +7 -3
- package/src/convert/printer.ts +20 -10
- package/src/convert/schema.ts +8 -1
- package/src/generated/ast.ts +159 -27
- package/src/generated/grammar.ts +434 -148
- package/src/i18n/codes.ts +95 -2
- package/src/i18n/index.ts +1 -0
- package/src/i18n/messages.en.ts +300 -1
- package/src/i18n/messages.fr.ts +335 -1
- package/src/i18n/wave-message-types.ts +206 -0
- package/src/index.ts +33 -0
- package/src/internal.ts +9 -0
- package/src/language/ast-walk.ts +158 -0
- package/src/language/calendar-declarations.ts +141 -0
- package/src/language/include-references.ts +49 -0
- package/src/language/include-resolver.ts +284 -10
- package/src/language/include-waves.ts +419 -0
- package/src/language/nowline-validator.ts +98 -1835
- package/src/language/nowline.langium +56 -22
- package/src/language/references.ts +40 -0
- package/src/language/style-chain.ts +95 -0
- package/src/language/validator/calendar.ts +319 -0
- package/src/language/validator/entities.ts +366 -0
- package/src/language/validator/properties.ts +425 -0
- package/src/language/validator/references.ts +295 -0
- package/src/language/validator/structure.ts +206 -0
- package/src/language/validator/style.ts +149 -0
- package/src/language/validator/support.ts +84 -0
- package/src/language/validator/symbols.ts +141 -0
- package/src/language/validator/tables.ts +171 -0
- package/src/language/validator-utils.ts +123 -0
- package/src/language/value-tables.ts +260 -0
- package/src/language/waves-order.ts +879 -0
- package/src/language/waves-plan.ts +101 -0
- package/src/language/waves.ts +731 -0
- package/src/util/props.ts +59 -0
- package/src/util/single-line.ts +15 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
// Anchor, milestone, footnote, item, parallel, group, size, status, utilization and person
|
|
2
|
+
// checks (specs/core-ast-utilities.md §3.6). Moved out of nowline-validator.ts as-is; the class
|
|
3
|
+
// forwards one method per check.
|
|
4
|
+
|
|
5
|
+
import type { ValidationAcceptor } from 'langium';
|
|
6
|
+
import type {
|
|
7
|
+
AnchorDeclaration,
|
|
8
|
+
DefaultDeclaration,
|
|
9
|
+
EntityProperty,
|
|
10
|
+
FootnoteDeclaration,
|
|
11
|
+
GroupBlock,
|
|
12
|
+
ItemDeclaration,
|
|
13
|
+
MilestoneDeclaration,
|
|
14
|
+
NowlineFile,
|
|
15
|
+
ParallelBlock,
|
|
16
|
+
PersonDeclaration,
|
|
17
|
+
SizeDeclaration,
|
|
18
|
+
StatusDeclaration,
|
|
19
|
+
SwimlaneDeclaration,
|
|
20
|
+
} from '../../generated/ast.js';
|
|
21
|
+
import {
|
|
22
|
+
isDefaultDeclaration,
|
|
23
|
+
isDescriptionDirective,
|
|
24
|
+
isPersonDeclaration,
|
|
25
|
+
isSizeDeclaration,
|
|
26
|
+
} from '../../generated/ast.js';
|
|
27
|
+
import { isRealIsoDate, propKey } from '../../util/props.js';
|
|
28
|
+
import { declarations } from '../ast-walk.js';
|
|
29
|
+
import { describeNode, displayName } from '../validator-utils.js';
|
|
30
|
+
import { BUILTIN_STATUSES } from '../value-tables.js';
|
|
31
|
+
import { acceptTr, locationOf, resolveLocalStart } from './support.js';
|
|
32
|
+
import {
|
|
33
|
+
BARE_DURATION_SUFFIX_RE,
|
|
34
|
+
BUILTIN_STATUS_SET,
|
|
35
|
+
DURATION_RE,
|
|
36
|
+
POSITIVE_DECIMAL_FRACTION_RE,
|
|
37
|
+
POSITIVE_PERCENT_RE,
|
|
38
|
+
UTILIZATION_NONE,
|
|
39
|
+
} from './tables.js';
|
|
40
|
+
|
|
41
|
+
// --- Rule 11: Anchor requires date: ---
|
|
42
|
+
export function checkAnchorRequiredDate(
|
|
43
|
+
anchor: AnchorDeclaration,
|
|
44
|
+
accept: ValidationAcceptor,
|
|
45
|
+
): void {
|
|
46
|
+
const dateProp = anchor.properties.find((p) => propKey(p) === 'date');
|
|
47
|
+
if (!dateProp) {
|
|
48
|
+
acceptTr(accept, 'error', { node: anchor }, 'NL.E0500', { name: displayName(anchor) });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// --- R2 + R3: anchor must not precede roadmap start; dated roadmap requires start: ---
|
|
53
|
+
export function checkAnchorAgainstStart(
|
|
54
|
+
anchor: AnchorDeclaration,
|
|
55
|
+
accept: ValidationAcceptor,
|
|
56
|
+
): void {
|
|
57
|
+
const dateProp = anchor.properties.find((p) => propKey(p) === 'date');
|
|
58
|
+
if (!dateProp?.value) return;
|
|
59
|
+
const raw = dateProp.value;
|
|
60
|
+
if (!isRealIsoDate(raw)) return;
|
|
61
|
+
const anchorDate = new Date(raw);
|
|
62
|
+
|
|
63
|
+
const start = resolveLocalStart(anchor.$container);
|
|
64
|
+
switch (start.kind) {
|
|
65
|
+
case 'invalid':
|
|
66
|
+
return;
|
|
67
|
+
case 'missing':
|
|
68
|
+
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0501', {
|
|
69
|
+
name: displayName(anchor),
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
case 'valid':
|
|
73
|
+
if (anchorDate < start.date) {
|
|
74
|
+
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0502', {
|
|
75
|
+
name: displayName(anchor),
|
|
76
|
+
date: raw,
|
|
77
|
+
start: start.iso,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// --- Rule 12: Milestone requires date: or after: ---
|
|
85
|
+
export function checkMilestoneRequirement(
|
|
86
|
+
milestone: MilestoneDeclaration,
|
|
87
|
+
accept: ValidationAcceptor,
|
|
88
|
+
): void {
|
|
89
|
+
const hasDate = milestone.properties.some((p) => propKey(p) === 'date');
|
|
90
|
+
const hasAfter = milestone.properties.some((p) => propKey(p) === 'after');
|
|
91
|
+
if (!hasDate && !hasAfter) {
|
|
92
|
+
acceptTr(accept, 'error', { node: milestone }, 'NL.E0503', {
|
|
93
|
+
name: displayName(milestone),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// --- R2 + R3: dated milestone must not precede roadmap start ---
|
|
99
|
+
export function checkMilestoneAgainstStart(
|
|
100
|
+
milestone: MilestoneDeclaration,
|
|
101
|
+
accept: ValidationAcceptor,
|
|
102
|
+
): void {
|
|
103
|
+
const dateProp = milestone.properties.find((p) => propKey(p) === 'date');
|
|
104
|
+
if (!dateProp?.value) return;
|
|
105
|
+
const raw = dateProp.value;
|
|
106
|
+
if (!isRealIsoDate(raw)) return;
|
|
107
|
+
const milestoneDate = new Date(raw);
|
|
108
|
+
|
|
109
|
+
const start = resolveLocalStart(milestone.$container);
|
|
110
|
+
switch (start.kind) {
|
|
111
|
+
case 'invalid':
|
|
112
|
+
return;
|
|
113
|
+
case 'missing':
|
|
114
|
+
accept(
|
|
115
|
+
'error',
|
|
116
|
+
`Milestone "${displayName(milestone)}" has a date but the roadmap is missing "start:". Add start:YYYY-MM-DD to the roadmap.`,
|
|
117
|
+
{
|
|
118
|
+
node: dateProp,
|
|
119
|
+
property: 'value',
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
return;
|
|
123
|
+
case 'valid':
|
|
124
|
+
if (milestoneDate < start.date) {
|
|
125
|
+
acceptTr(accept, 'error', { node: dateProp, property: 'value' }, 'NL.E0504', {
|
|
126
|
+
name: displayName(milestone),
|
|
127
|
+
date: raw,
|
|
128
|
+
start: start.iso,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// --- Rule 13: Footnote requires on ---
|
|
136
|
+
export function checkFootnoteOn(footnote: FootnoteDeclaration, accept: ValidationAcceptor): void {
|
|
137
|
+
const hasOn = footnote.properties.some((p) => propKey(p) === 'on');
|
|
138
|
+
if (!hasOn) {
|
|
139
|
+
acceptTr(accept, 'error', { node: footnote }, 'NL.E0505');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// --- Rule 13a: `footnote:` is not a valid property on host entities ---
|
|
144
|
+
// The spec attaches footnotes via the `on:` property on the footnote
|
|
145
|
+
// declaration only; there is no forward `footnote:` property on the
|
|
146
|
+
// referenced item / swimlane / etc. Surface a fix-it style error so
|
|
147
|
+
// authors who reach for the (legacy, undocumented) forward form get
|
|
148
|
+
// a clear nudge toward the spec-mandated direction.
|
|
149
|
+
export function checkNoFootnoteProperty(
|
|
150
|
+
node: {
|
|
151
|
+
$type: string;
|
|
152
|
+
properties: EntityProperty[];
|
|
153
|
+
name?: string;
|
|
154
|
+
title?: string;
|
|
155
|
+
},
|
|
156
|
+
accept: ValidationAcceptor,
|
|
157
|
+
): void {
|
|
158
|
+
for (const prop of node.properties) {
|
|
159
|
+
if (propKey(prop) === 'footnote') {
|
|
160
|
+
accept(
|
|
161
|
+
'error',
|
|
162
|
+
`Property "footnote:" is not valid on ${describeNode(node)}. ` +
|
|
163
|
+
'Footnotes attach via "on:" on the footnote declaration — ' +
|
|
164
|
+
'declare `footnote <id> on:<target-id>` instead.',
|
|
165
|
+
{ node: prop },
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// --- Rule 10: Item requires either size: or duration: ---
|
|
172
|
+
export function checkItemRequiredDuration(item: ItemDeclaration, accept: ValidationAcceptor): void {
|
|
173
|
+
const hasDuration = item.properties.some((p) => propKey(p) === 'duration');
|
|
174
|
+
const hasSize = item.properties.some((p) => propKey(p) === 'size');
|
|
175
|
+
if (!hasDuration && !hasSize) {
|
|
176
|
+
acceptTr(accept, 'error', { node: item }, 'NL.E0600', { name: displayName(item) });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// --- Parallel/group rule 3: size/duration/remaining/capacity not valid on parallel/group ---
|
|
181
|
+
export function checkNoComputedProperties(
|
|
182
|
+
node: ParallelBlock | GroupBlock,
|
|
183
|
+
accept: ValidationAcceptor,
|
|
184
|
+
): void {
|
|
185
|
+
for (const prop of node.properties) {
|
|
186
|
+
const key = propKey(prop);
|
|
187
|
+
if (key === 'size' || key === 'duration' || key === 'remaining' || key === 'capacity') {
|
|
188
|
+
accept(
|
|
189
|
+
'error',
|
|
190
|
+
`"${key}" is not valid on ${node.$type === 'ParallelBlock' ? 'parallel' : 'group'} (computed from children).`,
|
|
191
|
+
{
|
|
192
|
+
node: prop,
|
|
193
|
+
},
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// --- Parallel/group rule 1: Parallel requires >= 2 children ---
|
|
200
|
+
export function checkParallelMinChildren(node: ParallelBlock, accept: ValidationAcceptor): void {
|
|
201
|
+
const children = node.content.filter((c) => !isDescriptionDirective(c));
|
|
202
|
+
if (children.length === 0) {
|
|
203
|
+
accept('error', 'Parallel block must contain at least 2 children.', { node });
|
|
204
|
+
} else if (children.length === 1) {
|
|
205
|
+
accept(
|
|
206
|
+
'warning',
|
|
207
|
+
'Parallel block has only 1 child. Use at least 2 for parallel execution.',
|
|
208
|
+
{ node },
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// --- Parallel/group rule 2: Group requires >= 1 child ---
|
|
214
|
+
export function checkGroupMinChildren(node: GroupBlock, accept: ValidationAcceptor): void {
|
|
215
|
+
const children = node.content.filter((c) => !isDescriptionDirective(c));
|
|
216
|
+
if (children.length === 0) {
|
|
217
|
+
accept('error', 'Group must contain at least 1 child.', { node });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// --- Size declaration: rule 5 (effort: required), rule 4 (id format) ---
|
|
222
|
+
export function checkSizeDeclaration(decl: SizeDeclaration, accept: ValidationAcceptor): void {
|
|
223
|
+
const effortProp = decl.properties.find((p) => propKey(p) === 'effort');
|
|
224
|
+
if (!effortProp) {
|
|
225
|
+
accept('error', `Size "${displayName(decl)}" requires an "effort:" property.`, {
|
|
226
|
+
node: decl,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (decl.name) {
|
|
231
|
+
if (DURATION_RE.test(decl.name) || BARE_DURATION_SUFFIX_RE.test(decl.name)) {
|
|
232
|
+
accept(
|
|
233
|
+
'error',
|
|
234
|
+
`Size id "${decl.name}" collides with the raw duration pattern. Choose a different name (e.g. "xs", "small", "quarter").`,
|
|
235
|
+
{ node: decl, property: 'name' },
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// --- Status declaration: id collision with built-ins ---
|
|
242
|
+
export function checkStatusDeclaration(decl: StatusDeclaration, accept: ValidationAcceptor): void {
|
|
243
|
+
if (decl.name) {
|
|
244
|
+
if (BUILTIN_STATUS_SET.has(decl.name)) {
|
|
245
|
+
accept(
|
|
246
|
+
'error',
|
|
247
|
+
`Status id "${decl.name}" collides with the built-in status value. Built-ins: ${BUILTIN_STATUSES.join(', ')}.`,
|
|
248
|
+
{ node: decl, property: 'name' },
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// --- Rule 5: Duplicate size ids ---
|
|
255
|
+
export function checkDuplicateSizeIds(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
256
|
+
const seen = new Map<string, SizeDeclaration>();
|
|
257
|
+
for (const entry of file.roadmapEntries) {
|
|
258
|
+
if (isSizeDeclaration(entry) && entry.name) {
|
|
259
|
+
const existing = seen.get(entry.name);
|
|
260
|
+
if (existing) {
|
|
261
|
+
accept(
|
|
262
|
+
'error',
|
|
263
|
+
`Duplicate size id "${entry.name}". First declared at ${locationOf(existing)}.`,
|
|
264
|
+
{ node: entry, property: 'name' },
|
|
265
|
+
);
|
|
266
|
+
} else {
|
|
267
|
+
seen.set(entry.name, entry);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// --- Rule 17d (ordering half): utilization-warn-at <= utilization-over-at ---
|
|
274
|
+
// Runs on both `SwimlaneDeclaration` and `DefaultDeclaration` (when its
|
|
275
|
+
// entityType is `swimlane`). The value-form check in checkPropertyValues
|
|
276
|
+
// has already run by the time this fires; this method only re-reads the
|
|
277
|
+
// values and compares fractions when both are numeric. `none` on either
|
|
278
|
+
// side opts that side out and skips the comparison (the spec treats the
|
|
279
|
+
// two thresholds as independent — see specs/dsl.md rule 17d).
|
|
280
|
+
export function checkUtilizationOrdering(
|
|
281
|
+
decl: SwimlaneDeclaration | DefaultDeclaration,
|
|
282
|
+
accept: ValidationAcceptor,
|
|
283
|
+
): void {
|
|
284
|
+
if (isDefaultDeclaration(decl) && decl.entityType !== 'swimlane') return;
|
|
285
|
+
const warnProp = decl.properties.find((p) => propKey(p) === 'utilization-warn-at');
|
|
286
|
+
const overProp = decl.properties.find((p) => propKey(p) === 'utilization-over-at');
|
|
287
|
+
if (!warnProp || !overProp) return;
|
|
288
|
+
const warn = parseUtilizationFraction(warnProp.value);
|
|
289
|
+
const over = parseUtilizationFraction(overProp.value);
|
|
290
|
+
if (warn === null || over === null) return;
|
|
291
|
+
if (warn > over) {
|
|
292
|
+
accept(
|
|
293
|
+
'error',
|
|
294
|
+
`utilization-warn-at (${warnProp.value}) must be ≤ utilization-over-at (${overProp.value}). Warn fires below over; if both fire at the same point, the warn band collapses to zero.`,
|
|
295
|
+
{ node: warnProp, property: 'value' },
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// --- Rules 30-32: Person declare-once + bare top-level warning ---
|
|
301
|
+
export function checkPersonDeclarations(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
302
|
+
type DeclSite = { node: PersonDeclaration; isDeclaration: boolean };
|
|
303
|
+
const sitesByName = new Map<string, DeclSite[]>();
|
|
304
|
+
|
|
305
|
+
const isRealDeclaration = (p: PersonDeclaration): boolean => {
|
|
306
|
+
return Boolean(p.title) || p.properties.length > 0 || p.description !== undefined;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const visitPerson = (p: PersonDeclaration) => {
|
|
310
|
+
if (!p.name) return;
|
|
311
|
+
const isDecl = isRealDeclaration(p);
|
|
312
|
+
if (!sitesByName.has(p.name)) sitesByName.set(p.name, []);
|
|
313
|
+
sitesByName.get(p.name)!.push({ node: p, isDeclaration: isDecl });
|
|
314
|
+
if (!isDecl && p.$container.$type === 'NowlineFile') {
|
|
315
|
+
accept(
|
|
316
|
+
'warning',
|
|
317
|
+
`Bare "person ${p.name}" at roadmap top level has no declaration. Either add properties (title, link, etc.) or remove the line.`,
|
|
318
|
+
{ node: p },
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
for (const node of declarations(file)) {
|
|
324
|
+
if (isPersonDeclaration(node)) visitPerson(node);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
for (const [name, sites] of sitesByName) {
|
|
328
|
+
const decls = sites.filter((s) => s.isDeclaration);
|
|
329
|
+
if (decls.length > 1) {
|
|
330
|
+
for (let i = 1; i < decls.length; i++) {
|
|
331
|
+
accept(
|
|
332
|
+
'error',
|
|
333
|
+
`Person "${name}" is declared more than once. First declaration at ${locationOf(decls[0].node)}.`,
|
|
334
|
+
{ node: decls[i].node },
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Parse a numeric utilization-threshold value into a fraction. Mirrors the
|
|
343
|
+
* accepted value forms in checkPropertyValues (case `utilization-warn-at` /
|
|
344
|
+
* `utilization-over-at`):
|
|
345
|
+
*
|
|
346
|
+
* - `'none'` → null (opt-out; ordering check skips this side).
|
|
347
|
+
* - positive percent (`80%`) → 0.8.
|
|
348
|
+
* - positive decimal fraction (`0.8`) → 0.8 (or `1.25` → 1.25 for the
|
|
349
|
+
* intentionally-stretched-over case `utilization-over-at:125%`).
|
|
350
|
+
* - bare integer or anything else → null. Bare integers are rejected with
|
|
351
|
+
* a disambiguation hint by the value-form check before this helper runs;
|
|
352
|
+
* returning null here makes the ordering check skip that side instead of
|
|
353
|
+
* double-reporting.
|
|
354
|
+
*/
|
|
355
|
+
function parseUtilizationFraction(val: string | undefined): number | null {
|
|
356
|
+
if (!val || val === UTILIZATION_NONE) return null;
|
|
357
|
+
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
358
|
+
const n = parseFloat(val);
|
|
359
|
+
return Number.isFinite(n) && n > 0 ? n / 100 : null;
|
|
360
|
+
}
|
|
361
|
+
if (POSITIVE_DECIMAL_FRACTION_RE.test(val)) {
|
|
362
|
+
const n = parseFloat(val);
|
|
363
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
364
|
+
}
|
|
365
|
+
return null;
|
|
366
|
+
}
|