@nowline/core 0.8.6 → 0.9.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,425 @@
|
|
|
1
|
+
// Property value, unknown key, raw style key and style enum checks
|
|
2
|
+
// (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 { AstNode, ValidationAcceptor } from 'langium';
|
|
6
|
+
import type { EntityProperty, RoadmapDeclaration, StyleProperty } from '../../generated/ast.js';
|
|
7
|
+
import {
|
|
8
|
+
isDefaultDeclaration,
|
|
9
|
+
isItemDeclaration,
|
|
10
|
+
isSwimlaneDeclaration,
|
|
11
|
+
} from '../../generated/ast.js';
|
|
12
|
+
import { isRealIsoDate, propKey } from '../../util/props.js';
|
|
13
|
+
import { describeNode, suggestKey } from '../validator-utils.js';
|
|
14
|
+
import { isWaveBannedProperty } from '../waves.js';
|
|
15
|
+
import { acceptTr, isIdentifier } from './support.js';
|
|
16
|
+
import {
|
|
17
|
+
CALENDAR_MODES,
|
|
18
|
+
COLOR_NAMES,
|
|
19
|
+
DURATION_RE,
|
|
20
|
+
ENTITY_KNOWN_PROPS,
|
|
21
|
+
HEX_COLOR_RE,
|
|
22
|
+
NON_WORKING_VALUES,
|
|
23
|
+
PERCENTAGE_RE,
|
|
24
|
+
POSITIVE_DECIMAL_FRACTION_RE,
|
|
25
|
+
POSITIVE_INTEGER_RE,
|
|
26
|
+
POSITIVE_NUMBER_RE,
|
|
27
|
+
POSITIVE_PERCENT_RE,
|
|
28
|
+
STYLE_PROP_ENUMS,
|
|
29
|
+
STYLE_PROP_KEYS,
|
|
30
|
+
suggestConcept,
|
|
31
|
+
UNIVERSAL_ENTITY_PROPS,
|
|
32
|
+
UTILIZATION_NONE,
|
|
33
|
+
} from './tables.js';
|
|
34
|
+
|
|
35
|
+
// --- Property value validation (general) ---
|
|
36
|
+
export function checkPropertyValues(prop: EntityProperty, accept: ValidationAcceptor): void {
|
|
37
|
+
// A key a wave may not take is NL.E1105 only (checkWaveDeclarations).
|
|
38
|
+
if (isWaveBannedProperty(prop)) return;
|
|
39
|
+
const key = propKey(prop);
|
|
40
|
+
const val = prop.value;
|
|
41
|
+
const vals = prop.values;
|
|
42
|
+
const allValues = val ? [val] : vals;
|
|
43
|
+
|
|
44
|
+
switch (key) {
|
|
45
|
+
case 'status':
|
|
46
|
+
// Forward/resolution validated at file scope (checkForwardReferences).
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case 'duration':
|
|
50
|
+
// `duration:` is literal-only — no alias lookup. Authors who
|
|
51
|
+
// want a named alias use `size:NAME` instead, which resolves
|
|
52
|
+
// to the size's `effort:` (and divides by `capacity:` at
|
|
53
|
+
// layout time, m5).
|
|
54
|
+
if (val && !DURATION_RE.test(val)) {
|
|
55
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0400', {
|
|
56
|
+
value: val,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case 'size':
|
|
62
|
+
if (val && !isIdentifier(val)) {
|
|
63
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0401', {
|
|
64
|
+
value: val,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
case 'effort':
|
|
70
|
+
if (val && !DURATION_RE.test(val)) {
|
|
71
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0402', {
|
|
72
|
+
value: val,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case 'remaining': {
|
|
78
|
+
// Accepts either a percent (`30%`, validated 0-100) or a
|
|
79
|
+
// single-engineer effort literal (`1w`, `0.5d`). The literal
|
|
80
|
+
// form is normalized to a percent at layout time using the
|
|
81
|
+
// item's resolved total effort (m5); overflow there emits a
|
|
82
|
+
// soft warning and clamps the rendered bar to 100%.
|
|
83
|
+
if (val) {
|
|
84
|
+
if (PERCENTAGE_RE.test(val)) {
|
|
85
|
+
const pct = parseFloat(val);
|
|
86
|
+
if (pct < 0 || pct > 100) {
|
|
87
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0404', {
|
|
88
|
+
value: val,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
} else if (!DURATION_RE.test(val)) {
|
|
92
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0403', {
|
|
93
|
+
value: val,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case 'date':
|
|
101
|
+
case 'start':
|
|
102
|
+
case 'end':
|
|
103
|
+
// A date must name a real calendar day: `Date` would roll `2026-02-30`
|
|
104
|
+
// over to March 2, and layout reads an impossible day as no date.
|
|
105
|
+
if (val && !isRealIsoDate(val)) {
|
|
106
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0405', {
|
|
107
|
+
key,
|
|
108
|
+
value: val,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case 'scale':
|
|
114
|
+
if (val && !DURATION_RE.test(val)) {
|
|
115
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0406', {
|
|
116
|
+
value: val,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 'calendar':
|
|
122
|
+
if (val && !CALENDAR_MODES.has(val)) {
|
|
123
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0407', {
|
|
124
|
+
value: val,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'on':
|
|
130
|
+
case 'after':
|
|
131
|
+
case 'before':
|
|
132
|
+
if (allValues.length === 0) {
|
|
133
|
+
acceptTr(accept, 'error', { node: prop }, 'NL.E0408', { key });
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
case 'capacity': {
|
|
138
|
+
if (!val) break;
|
|
139
|
+
const parent = prop.$container;
|
|
140
|
+
const parentKind = capacityParentKind(parent);
|
|
141
|
+
// Parallel/group ban is reported by checkNoComputedProperties; skip here.
|
|
142
|
+
if (parentKind === 'invalid') break;
|
|
143
|
+
if (parentKind === 'lane') {
|
|
144
|
+
if (!POSITIVE_NUMBER_RE.test(val) || parseFloat(val) <= 0) {
|
|
145
|
+
accept(
|
|
146
|
+
'error',
|
|
147
|
+
`Invalid swimlane capacity "${val}". Use a positive integer (e.g. capacity:5) or decimal (e.g. capacity:1.5). Percent literals are not allowed on swimlanes.`,
|
|
148
|
+
{ node: prop, property: 'value' },
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
153
|
+
const pct = parseFloat(val);
|
|
154
|
+
if (pct <= 0) {
|
|
155
|
+
accept('error', `Item capacity "${val}" must be positive.`, {
|
|
156
|
+
node: prop,
|
|
157
|
+
property: 'value',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
} else if (POSITIVE_NUMBER_RE.test(val)) {
|
|
161
|
+
if (parseFloat(val) <= 0) {
|
|
162
|
+
accept('error', `Item capacity "${val}" must be positive.`, {
|
|
163
|
+
node: prop,
|
|
164
|
+
property: 'value',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
accept(
|
|
169
|
+
'error',
|
|
170
|
+
`Invalid item capacity "${val}". Use a positive integer (capacity:2), decimal (capacity:0.5), or percent literal (capacity:50%).`,
|
|
171
|
+
{ node: prop, property: 'value' },
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
case 'overcapacity': {
|
|
179
|
+
// Removed in m9. Suppression is now expressed via
|
|
180
|
+
// `utilization-warn-at:none` / `utilization-over-at:none`
|
|
181
|
+
// (see specs/dsl.md § Capacity → Utilization thresholds).
|
|
182
|
+
accept(
|
|
183
|
+
'error',
|
|
184
|
+
`"overcapacity:" was removed. Use "utilization-over-at:none" (and/or "utilization-warn-at:none") to suppress the lane utilization underline.`,
|
|
185
|
+
{ node: prop },
|
|
186
|
+
);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
case 'utilization-warn-at':
|
|
191
|
+
case 'utilization-over-at': {
|
|
192
|
+
if (!val) break;
|
|
193
|
+
if (!isUtilizationAllowedHere(prop.$container)) {
|
|
194
|
+
accept('error', `"${key}:" is only valid on "swimlane" or "default swimlane".`, {
|
|
195
|
+
node: prop,
|
|
196
|
+
});
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (val === UTILIZATION_NONE) break;
|
|
200
|
+
if (POSITIVE_PERCENT_RE.test(val)) {
|
|
201
|
+
if (parseFloat(val) <= 0) {
|
|
202
|
+
accept('error', `${key} value "${val}" must be positive.`, {
|
|
203
|
+
node: prop,
|
|
204
|
+
property: 'value',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
// Decimals must include the dot to read as fractions; bare
|
|
210
|
+
// integers are ambiguous (`80` could mean 80% or 8000% as a
|
|
211
|
+
// fraction) so we reject them with a hint to disambiguate.
|
|
212
|
+
if (POSITIVE_DECIMAL_FRACTION_RE.test(val)) {
|
|
213
|
+
if (parseFloat(val) <= 0) {
|
|
214
|
+
accept('error', `${key} value "${val}" must be positive.`, {
|
|
215
|
+
node: prop,
|
|
216
|
+
property: 'value',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
if (POSITIVE_INTEGER_RE.test(val)) {
|
|
222
|
+
accept(
|
|
223
|
+
'error',
|
|
224
|
+
`Ambiguous ${key} value "${val}". Use the percent form ("${val}%") or the decimal-fraction form ("0.${val}") to make the intent explicit.`,
|
|
225
|
+
{ node: prop, property: 'value' },
|
|
226
|
+
);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
accept(
|
|
230
|
+
'error',
|
|
231
|
+
`Invalid ${key} value "${val}". Use a positive percent (e.g. 80%), a positive decimal fraction (e.g. 0.8), or "none" to opt out.`,
|
|
232
|
+
{ node: prop, property: 'value' },
|
|
233
|
+
);
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
case 'capacity-icon':
|
|
238
|
+
// Value-form rule (built-in / symbol id / string literal) and
|
|
239
|
+
// forward-reference rule are enforced together by
|
|
240
|
+
// checkSymbolReferences at file scope so style blocks and
|
|
241
|
+
// default-declaration property positions share one code path.
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case 'icon':
|
|
245
|
+
// Same handling as capacity-icon.
|
|
246
|
+
break;
|
|
247
|
+
|
|
248
|
+
case 'non-working':
|
|
249
|
+
// Raw on an entity line the key is Rule 20's error alone
|
|
250
|
+
// (checkNoRawStyleProperties); the value is checked where the
|
|
251
|
+
// key may be set, on a `default` line.
|
|
252
|
+
if (isDefaultDeclaration(prop.$container)) {
|
|
253
|
+
checkNonWorkingValue(val, prop, accept);
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
|
|
257
|
+
default:
|
|
258
|
+
if (STYLE_PROP_KEYS.has(key)) {
|
|
259
|
+
if (key === 'bg' || key === 'fg' || key === 'text') {
|
|
260
|
+
if (val && !isColorValue(val)) {
|
|
261
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0801', {
|
|
262
|
+
value: val,
|
|
263
|
+
key,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
} else if (key in STYLE_PROP_ENUMS) {
|
|
267
|
+
const allowed = STYLE_PROP_ENUMS[key];
|
|
268
|
+
if (val && !allowed.has(val)) {
|
|
269
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0802', {
|
|
270
|
+
value: val,
|
|
271
|
+
key,
|
|
272
|
+
allowed: [...allowed].join(', '),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// --- Rule 20: Raw style properties banned on roadmap-section entities ---
|
|
282
|
+
export function checkNoRawStyleProperties(
|
|
283
|
+
node: {
|
|
284
|
+
$type: string;
|
|
285
|
+
properties: EntityProperty[];
|
|
286
|
+
name?: string;
|
|
287
|
+
title?: string;
|
|
288
|
+
},
|
|
289
|
+
accept: ValidationAcceptor,
|
|
290
|
+
): void {
|
|
291
|
+
for (const prop of node.properties) {
|
|
292
|
+
const key = propKey(prop);
|
|
293
|
+
if (STYLE_PROP_KEYS.has(key)) {
|
|
294
|
+
acceptTr(accept, 'error', { node: prop }, 'NL.E0804', {
|
|
295
|
+
key,
|
|
296
|
+
entity: describeNode(node),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Warn on property keys the runtime never reads. Severity is `warning` so a
|
|
303
|
+
// file that happened to render with a bogus key (e.g. `roadmap r now:2026-01-25`)
|
|
304
|
+
// keeps parsing — promoting to error would break files that work today even
|
|
305
|
+
// though the bogus key was a no-op all along.
|
|
306
|
+
//
|
|
307
|
+
// Skips:
|
|
308
|
+
// - raw style keys (already an error from `checkNoRawStyleProperties`)
|
|
309
|
+
// - `footnote` (already an error from `checkNoFootnoteProperty`)
|
|
310
|
+
// - sizing keys on parallel/group (already an error from `checkNoComputedProperties`)
|
|
311
|
+
// - `wave` on every entity (the wave rules own it: NL.W0702 with no waves,
|
|
312
|
+
// NL.E1104 / NL.E1105 where it is not allowed)
|
|
313
|
+
// - the keys a wave may not take (already NL.E1105)
|
|
314
|
+
//
|
|
315
|
+
// Suggests the closest known key within 2 edits when one exists, so the
|
|
316
|
+
// existing `DID_YOU_MEAN_RE` in `packages/cli/src/diagnostics/adapt.ts` picks
|
|
317
|
+
// it up as a structured suggestion alongside the rendered message.
|
|
318
|
+
export function checkUnknownEntityProperties(
|
|
319
|
+
node: {
|
|
320
|
+
$type: string;
|
|
321
|
+
properties: EntityProperty[];
|
|
322
|
+
name?: string;
|
|
323
|
+
title?: string;
|
|
324
|
+
},
|
|
325
|
+
accept: ValidationAcceptor,
|
|
326
|
+
): void {
|
|
327
|
+
const known = ENTITY_KNOWN_PROPS[node.$type];
|
|
328
|
+
if (!known) return;
|
|
329
|
+
const computedBanned =
|
|
330
|
+
node.$type === 'ParallelBlock' || node.$type === 'GroupBlock'
|
|
331
|
+
? new Set(['size', 'duration', 'remaining', 'capacity'])
|
|
332
|
+
: null;
|
|
333
|
+
for (const prop of node.properties) {
|
|
334
|
+
const key = propKey(prop);
|
|
335
|
+
if (known.has(key)) continue;
|
|
336
|
+
if (UNIVERSAL_ENTITY_PROPS.has(key)) continue;
|
|
337
|
+
if (STYLE_PROP_KEYS.has(key)) continue;
|
|
338
|
+
if (key === 'footnote') continue;
|
|
339
|
+
if (computedBanned?.has(key)) continue;
|
|
340
|
+
if (key === 'wave' || isWaveBannedProperty(prop)) continue;
|
|
341
|
+
const candidates: string[] = [...known, ...UNIVERSAL_ENTITY_PROPS];
|
|
342
|
+
const suggested =
|
|
343
|
+
suggestConcept(key, known, node.$type) ?? suggestKey(key, candidates) ?? '';
|
|
344
|
+
acceptTr(accept, 'warning', { node: prop, property: 'key' }, 'NL.W0700', {
|
|
345
|
+
key,
|
|
346
|
+
entity: describeNode(node),
|
|
347
|
+
suggested,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// --- Rule 18: Style property enum values ---
|
|
353
|
+
// Value forms accepted by `icon:` and `capacity-icon:` (built-in identifier,
|
|
354
|
+
// symbol name, or inline string literal) plus forward-reference resolution are
|
|
355
|
+
// enforced by checkSymbolReferences at file scope so style blocks and
|
|
356
|
+
// `default <entity>` lines share a single code path.
|
|
357
|
+
export function checkStylePropertyEnum(prop: StyleProperty, accept: ValidationAcceptor): void {
|
|
358
|
+
const key = propKey(prop);
|
|
359
|
+
const val = prop.value;
|
|
360
|
+
|
|
361
|
+
if (key === 'bg' || key === 'fg' || key === 'text') {
|
|
362
|
+
if (!isColorValue(val)) {
|
|
363
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0801', {
|
|
364
|
+
value: val,
|
|
365
|
+
key,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
} else if (key === 'non-working') {
|
|
369
|
+
checkNonWorkingValue(val, prop, accept);
|
|
370
|
+
} else if (key in STYLE_PROP_ENUMS) {
|
|
371
|
+
const allowed = STYLE_PROP_ENUMS[key];
|
|
372
|
+
if (!allowed.has(val)) {
|
|
373
|
+
acceptTr(accept, 'error', { node: prop, property: 'value' }, 'NL.E0802', {
|
|
374
|
+
value: val,
|
|
375
|
+
key,
|
|
376
|
+
allowed: [...allowed].join(', '),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
} else if (!STYLE_PROP_KEYS.has(key)) {
|
|
380
|
+
acceptTr(accept, 'error', { node: prop, property: 'key' }, 'NL.E0803', { key });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// --- Roadmap declaration specific property checks ---
|
|
385
|
+
// Property-level validation of start:/date: lives in the generic EntityProperty check;
|
|
386
|
+
// this hook is kept for future roadmap-scoped rules (and to make registration symmetric).
|
|
387
|
+
export function checkRoadmapProperties(
|
|
388
|
+
_roadmap: RoadmapDeclaration,
|
|
389
|
+
_accept: ValidationAcceptor,
|
|
390
|
+
): void {
|
|
391
|
+
// intentionally empty
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function isColorValue(val: string): boolean {
|
|
395
|
+
return COLOR_NAMES.has(val) || HEX_COLOR_RE.test(val);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** NL.E0800 unless `value` is a `non-working:` value (`hide` or `show`). */
|
|
399
|
+
function checkNonWorkingValue(
|
|
400
|
+
value: string | undefined,
|
|
401
|
+
node: EntityProperty | StyleProperty,
|
|
402
|
+
accept: ValidationAcceptor,
|
|
403
|
+
): void {
|
|
404
|
+
if (value === undefined || NON_WORKING_VALUES.has(value)) return;
|
|
405
|
+
acceptTr(accept, 'error', { node, property: 'value' }, 'NL.E0800', { value });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
type CapacityParentKind = 'lane' | 'item' | 'invalid';
|
|
409
|
+
|
|
410
|
+
function capacityParentKind(parent: AstNode | undefined): CapacityParentKind {
|
|
411
|
+
if (!parent) return 'invalid';
|
|
412
|
+
if (isSwimlaneDeclaration(parent)) return 'lane';
|
|
413
|
+
if (isItemDeclaration(parent)) return 'item';
|
|
414
|
+
if (isDefaultDeclaration(parent)) {
|
|
415
|
+
return parent.entityType === 'swimlane' ? 'lane' : 'item';
|
|
416
|
+
}
|
|
417
|
+
return 'invalid';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function isUtilizationAllowedHere(parent: AstNode | undefined): boolean {
|
|
421
|
+
if (!parent) return false;
|
|
422
|
+
if (isSwimlaneDeclaration(parent)) return true;
|
|
423
|
+
if (isDefaultDeclaration(parent) && parent.entityType === 'swimlane') return true;
|
|
424
|
+
return false;
|
|
425
|
+
}
|