@nowline/core 0.8.5 → 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 +251 -141
- package/dist/generated/ast.d.ts.map +1 -1
- package/dist/generated/ast.js +96 -4
- package/dist/generated/ast.js.map +1 -1
- package/dist/generated/grammar.d.ts +1 -1
- package/dist/generated/grammar.d.ts.map +1 -1
- package/dist/generated/grammar.js +435 -149
- package/dist/generated/grammar.js.map +1 -1
- package/dist/generated/module.d.ts +3 -3
- package/dist/generated/module.d.ts.map +1 -1
- package/dist/generated/module.js +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-module.js.map +1 -1
- 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 +10 -6
- package/src/convert/printer.ts +20 -10
- package/src/convert/schema.ts +8 -1
- package/src/generated/ast.ts +160 -28
- package/src/generated/grammar.ts +435 -149
- package/src/generated/module.ts +1 -1
- 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
|
@@ -22,7 +22,8 @@ IncludeOption:
|
|
|
22
22
|
// --- Config Entries ---
|
|
23
23
|
|
|
24
24
|
ConfigEntry:
|
|
25
|
-
ScaleBlock | CalendarBlock | StyleDeclaration | SymbolDeclaration | DefaultDeclaration
|
|
25
|
+
ScaleBlock | CalendarBlock | StyleDeclaration | SymbolDeclaration | DefaultDeclaration |
|
|
26
|
+
NonWorkingDeclaration | WorkingDeclaration;
|
|
26
27
|
|
|
27
28
|
ScaleBlock:
|
|
28
29
|
'scale'
|
|
@@ -32,15 +33,18 @@ CalendarBlock:
|
|
|
32
33
|
'calendar'
|
|
33
34
|
(INDENT properties+=BlockProperty+ DEDENT)?;
|
|
34
35
|
|
|
36
|
+
// 'wave' appears here because it is a declaration keyword (WaveDeclaration) that the
|
|
37
|
+
// lexer prefers over ID; a v1 file could already write e.g. `name: wave` in a block.
|
|
38
|
+
// 'non-working' and 'working' are listed for the same reason (calendar declaration keywords).
|
|
35
39
|
BlockPropertyValue returns string:
|
|
36
|
-
ID | INTEGER | STRING | DURATION_LITERAL;
|
|
40
|
+
ID | INTEGER | STRING | DURATION_LITERAL | 'wave' | 'non-working' | 'working';
|
|
37
41
|
|
|
38
42
|
StyleDeclaration:
|
|
39
|
-
'style' (name=
|
|
43
|
+
'style' (name=EntityName)? (title=STRING)?
|
|
40
44
|
(INDENT properties+=StyleProperty+ DEDENT)?;
|
|
41
45
|
|
|
42
46
|
SymbolDeclaration:
|
|
43
|
-
'symbol' (name=
|
|
47
|
+
'symbol' (name=EntityName)? (title=STRING)?
|
|
44
48
|
(properties+=EntityProperty)*
|
|
45
49
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
46
50
|
|
|
@@ -49,9 +53,22 @@ SymbolDeclaration:
|
|
|
49
53
|
// the keyword in preference to ID. Without the alternation, `capacity-icon:person`
|
|
50
54
|
// (a built-in capacity-icon name) would fail to parse. Other built-in icon names
|
|
51
55
|
// (`none`, `multiplier`, `people`, `points`, `time`, `shield`, `warning`, `lock`)
|
|
52
|
-
// are not grammar keywords and therefore lex as ID without help.
|
|
56
|
+
// are not grammar keywords and therefore lex as ID without help. 'wave' is listed for
|
|
57
|
+
// the same reason (WaveDeclaration keyword), so v1 values such as `icon:wave` keep parsing.
|
|
58
|
+
// 'non-working' and 'working' (NonWorkingDeclaration / WorkingDeclaration keywords) follow
|
|
59
|
+
// the 'wave' precedent. Longer words such as `non-working-team` still lex as ID.
|
|
53
60
|
StylePropertyValue returns string:
|
|
54
|
-
ID | COLOR_HEX | STRING | 'person';
|
|
61
|
+
ID | COLOR_HEX | STRING | 'person' | 'wave' | 'non-working' | 'working';
|
|
62
|
+
|
|
63
|
+
// Calendar declarations (specs/working-calendar.md). Id and title are optional; the
|
|
64
|
+
// property shapes (date, start, end, every) are enforced by the validator, not the grammar.
|
|
65
|
+
NonWorkingDeclaration:
|
|
66
|
+
'non-working' (name=EntityName)? (title=STRING)?
|
|
67
|
+
(properties+=EntityProperty)*;
|
|
68
|
+
|
|
69
|
+
WorkingDeclaration:
|
|
70
|
+
'working' (name=EntityName)? (title=STRING)?
|
|
71
|
+
(properties+=EntityProperty)*;
|
|
55
72
|
|
|
56
73
|
DefaultDeclaration:
|
|
57
74
|
'default' entityType=DefaultEntityType
|
|
@@ -64,21 +81,28 @@ DefaultEntityType returns string:
|
|
|
64
81
|
// --- Roadmap ---
|
|
65
82
|
|
|
66
83
|
RoadmapDeclaration:
|
|
67
|
-
'roadmap' (name=
|
|
84
|
+
'roadmap' (name=EntityName)? (title=STRING)?
|
|
68
85
|
(properties+=EntityProperty)*;
|
|
69
86
|
|
|
70
87
|
RoadmapEntry:
|
|
71
88
|
PersonDeclaration | TeamDeclaration | AnchorDeclaration |
|
|
72
89
|
LabelDeclaration | SizeDeclaration | StatusDeclaration |
|
|
90
|
+
WaveDeclaration |
|
|
73
91
|
SwimlaneDeclaration | MilestoneDeclaration | FootnoteDeclaration;
|
|
74
92
|
|
|
93
|
+
// v1 compatibility: `wave` now lexes as a keyword. EntityName re-admits the bare
|
|
94
|
+
// word everywhere a v1 file could already write an identifier. 'non-working' and
|
|
95
|
+
// 'working' are admitted for the same reason.
|
|
96
|
+
EntityName returns string:
|
|
97
|
+
ID | 'wave' | 'non-working' | 'working';
|
|
98
|
+
|
|
75
99
|
PersonDeclaration:
|
|
76
|
-
'person' (name=
|
|
100
|
+
'person' (name=EntityName)? (title=STRING)?
|
|
77
101
|
(properties+=EntityProperty)*
|
|
78
102
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
79
103
|
|
|
80
104
|
TeamDeclaration:
|
|
81
|
-
'team' (name=
|
|
105
|
+
'team' (name=EntityName)? (title=STRING)?
|
|
82
106
|
(properties+=EntityProperty)*
|
|
83
107
|
(INDENT content+=TeamContent+ DEDENT)?;
|
|
84
108
|
|
|
@@ -86,30 +110,37 @@ TeamContent:
|
|
|
86
110
|
DescriptionDirective | PersonMemberRef | TeamDeclaration;
|
|
87
111
|
|
|
88
112
|
PersonMemberRef:
|
|
89
|
-
'person' ref=
|
|
113
|
+
'person' ref=EntityName;
|
|
90
114
|
|
|
91
115
|
AnchorDeclaration:
|
|
92
|
-
'anchor' (name=
|
|
116
|
+
'anchor' (name=EntityName)? (title=STRING)?
|
|
93
117
|
(properties+=EntityProperty)*
|
|
94
118
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
95
119
|
|
|
96
120
|
LabelDeclaration:
|
|
97
|
-
'label' (name=
|
|
121
|
+
'label' (name=EntityName)? (title=STRING)?
|
|
98
122
|
(properties+=EntityProperty)*
|
|
99
123
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
100
124
|
|
|
101
125
|
SizeDeclaration:
|
|
102
|
-
'size' (name=
|
|
126
|
+
'size' (name=EntityName)? (title=STRING)?
|
|
103
127
|
(properties+=EntityProperty)*
|
|
104
128
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
105
129
|
|
|
106
130
|
StatusDeclaration:
|
|
107
|
-
'status' (name=
|
|
131
|
+
'status' (name=EntityName)? (title=STRING)?
|
|
132
|
+
(properties+=EntityProperty)*
|
|
133
|
+
(INDENT description=DescriptionDirective DEDENT)?;
|
|
134
|
+
|
|
135
|
+
// Barrier that spans swimlanes (specs/waves.md). `name` stays optional in the
|
|
136
|
+
// grammar so the validator reports a missing id as NL.E1100 instead of a parse error.
|
|
137
|
+
WaveDeclaration:
|
|
138
|
+
'wave' (name=EntityName)? (title=STRING)?
|
|
108
139
|
(properties+=EntityProperty)*
|
|
109
140
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
110
141
|
|
|
111
142
|
SwimlaneDeclaration:
|
|
112
|
-
'swimlane' (name=
|
|
143
|
+
'swimlane' (name=EntityName)? (title=STRING)?
|
|
113
144
|
(properties+=EntityProperty)*
|
|
114
145
|
(INDENT content+=SwimlaneContent+ DEDENT)?;
|
|
115
146
|
|
|
@@ -117,12 +148,12 @@ SwimlaneContent:
|
|
|
117
148
|
DescriptionDirective | ItemDeclaration | ParallelBlock | GroupBlock;
|
|
118
149
|
|
|
119
150
|
ItemDeclaration:
|
|
120
|
-
'item' (name=
|
|
151
|
+
'item' (name=EntityName)? (title=STRING)?
|
|
121
152
|
(properties+=EntityProperty)*
|
|
122
153
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
123
154
|
|
|
124
155
|
ParallelBlock:
|
|
125
|
-
'parallel' (name=
|
|
156
|
+
'parallel' (name=EntityName)? (title=STRING)?
|
|
126
157
|
(properties+=EntityProperty)*
|
|
127
158
|
INDENT content+=ParallelContent+ DEDENT;
|
|
128
159
|
|
|
@@ -130,7 +161,7 @@ ParallelContent:
|
|
|
130
161
|
DescriptionDirective | ItemDeclaration | GroupBlock;
|
|
131
162
|
|
|
132
163
|
GroupBlock:
|
|
133
|
-
'group' (name=
|
|
164
|
+
'group' (name=EntityName)? (title=STRING)?
|
|
134
165
|
(properties+=EntityProperty)*
|
|
135
166
|
INDENT content+=GroupContent+ DEDENT;
|
|
136
167
|
|
|
@@ -138,12 +169,12 @@ GroupContent:
|
|
|
138
169
|
DescriptionDirective | ItemDeclaration | ParallelBlock | GroupBlock;
|
|
139
170
|
|
|
140
171
|
MilestoneDeclaration:
|
|
141
|
-
'milestone' (name=
|
|
172
|
+
'milestone' (name=EntityName)? (title=STRING)?
|
|
142
173
|
(properties+=EntityProperty)*
|
|
143
174
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
144
175
|
|
|
145
176
|
FootnoteDeclaration:
|
|
146
|
-
'footnote' (name=
|
|
177
|
+
'footnote' (name=EntityName)? (title=STRING)?
|
|
147
178
|
(properties+=EntityProperty)*
|
|
148
179
|
(INDENT description=DescriptionDirective DEDENT)?;
|
|
149
180
|
|
|
@@ -169,9 +200,12 @@ StyleProperty:
|
|
|
169
200
|
|
|
170
201
|
// 'person' appears here for the same reason as in StylePropertyValue — it is a
|
|
171
202
|
// declaration keyword that the lexer prefers over ID, but it must also be accepted
|
|
172
|
-
// as a property-atom value (e.g. `default swimlane capacity-icon:person`).
|
|
203
|
+
// as a property-atom value (e.g. `default swimlane capacity-icon:person`). 'wave' is
|
|
204
|
+
// listed for the same reason, so v1 values such as `after:wave` and `owner:wave` keep parsing.
|
|
205
|
+
// 'non-working' and 'working' are listed for the same reason, so a bare value such as
|
|
206
|
+
// `owner:working` keeps parsing.
|
|
173
207
|
PropertyAtom returns string:
|
|
174
|
-
ID | STRING | DURATION_LITERAL | PERCENTAGE | URL | DATE_LITERAL | COLOR_HEX | DECIMAL | INTEGER | 'person';
|
|
208
|
+
ID | STRING | DURATION_LITERAL | PERCENTAGE | URL | DATE_LITERAL | COLOR_HEX | DECIMAL | INTEGER | 'person' | 'wave' | 'non-working' | 'working';
|
|
175
209
|
|
|
176
210
|
// --- Terminals ---
|
|
177
211
|
// INDENT/DEDENT must be declared before ID to avoid Chevrotain unreachable-token errors.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Unresolved `after:`, `before:` and `on:` references (specs/dsl.md, Reference
|
|
2
|
+
// rule 1, NL.E0302). Shared by the validator, for the file it validates, and
|
|
3
|
+
// the include resolver, for each included file (which is never validated).
|
|
4
|
+
|
|
5
|
+
import type { EntityProperty, NowlineFile } from '../generated/ast.js';
|
|
6
|
+
import { ISO_DATE_RE, propKey } from '../util/props.js';
|
|
7
|
+
import { referenceableIds, visitProperties } from './ast-walk.js';
|
|
8
|
+
import { isWaveBannedProperty } from './waves.js';
|
|
9
|
+
|
|
10
|
+
/** One `after:`, `before:` or `on:` element that names no id declared in its file. */
|
|
11
|
+
export interface UnresolvedReference {
|
|
12
|
+
prop: EntityProperty;
|
|
13
|
+
key: 'after' | 'before' | 'on';
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Every `after:`, `before:` and `on:` element in `file` that names no id
|
|
19
|
+
* declared in that same file (NL.E0302). References never cross a file
|
|
20
|
+
* boundary, so the include resolver runs this on each included file too.
|
|
21
|
+
*/
|
|
22
|
+
export function unresolvedReferences(file: NowlineFile): UnresolvedReference[] {
|
|
23
|
+
const declaredIds = referenceableIds(file);
|
|
24
|
+
const out: UnresolvedReference[] = [];
|
|
25
|
+
for (const entry of file.roadmapEntries) {
|
|
26
|
+
visitProperties(entry, (prop) => {
|
|
27
|
+
const key = propKey(prop);
|
|
28
|
+
if (key !== 'after' && key !== 'before' && key !== 'on') return;
|
|
29
|
+
// A wave's before: is NL.E1105 only.
|
|
30
|
+
if (isWaveBannedProperty(prop)) return;
|
|
31
|
+
const vals = prop.value ? [prop.value] : prop.values;
|
|
32
|
+
for (const v of vals) {
|
|
33
|
+
if (!v) continue;
|
|
34
|
+
if ((key === 'after' || key === 'before') && ISO_DATE_RE.test(v)) continue;
|
|
35
|
+
if (!declaredIds.has(v)) out.push({ prop, key, value: v });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// The style precedence chain of specs/rendering.md § Style Precedence, levels
|
|
2
|
+
// 2-5, in one place (specs/core-ast-utilities.md §3.3). Core owns the order;
|
|
3
|
+
// layout owns what a key means (colours, size buckets, theme fallbacks), and
|
|
4
|
+
// NL.W0704 reads the same order to predict the roadmap's resolved style.
|
|
5
|
+
// Exported only through `@nowline/core/internal`. A leaf module: it imports
|
|
6
|
+
// nothing but the generated AST types and `util/props.ts`.
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
DefaultDeclaration,
|
|
10
|
+
EntityProperty,
|
|
11
|
+
LabelDeclaration,
|
|
12
|
+
StyleDeclaration,
|
|
13
|
+
} from '../generated/ast.js';
|
|
14
|
+
import { findProp } from '../util/props.js';
|
|
15
|
+
|
|
16
|
+
/** Where `styleLayers` looks up `style:`, `default <entity>` and label ids. */
|
|
17
|
+
export interface StyleSources {
|
|
18
|
+
/** Style id to its declaration. */
|
|
19
|
+
styles: ReadonlyMap<string, StyleDeclaration>;
|
|
20
|
+
/** Entity type (`roadmap`, `item`, ...) to its `default` line. */
|
|
21
|
+
defaults: ReadonlyMap<string, DefaultDeclaration>;
|
|
22
|
+
/** Label id to its declaration. */
|
|
23
|
+
labels: ReadonlyMap<string, LabelDeclaration>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* One layer of rendering.md § Style Precedence levels 2-5, in application
|
|
28
|
+
* order. A style layer whose `decl` is undefined names a style that the
|
|
29
|
+
* sources do not hold; a `label` layer names a label they do not hold.
|
|
30
|
+
*/
|
|
31
|
+
export type StyleLayer =
|
|
32
|
+
| {
|
|
33
|
+
level: 'default-style' | 'label-style' | 'entity-style';
|
|
34
|
+
id: string;
|
|
35
|
+
decl: StyleDeclaration | undefined;
|
|
36
|
+
}
|
|
37
|
+
| { level: 'label'; id: string; label: undefined }
|
|
38
|
+
| { level: 'default' | 'inline'; props: readonly EntityProperty[] };
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Levels 2-5 for an entity of `entityType` with `props`: the `default` line's
|
|
42
|
+
* `style:` then its own keys, each label's `style:` from last label to first
|
|
43
|
+
* (so the first label wins), the entity's `style:`, its own keys. A later
|
|
44
|
+
* layer wins a key. A `style:` or label that `sources` does not hold is a
|
|
45
|
+
* layer with `decl` (or `label`) undefined, so a caller can tell "unset" from
|
|
46
|
+
* "set somewhere it cannot see". A label without a `style:` adds no layer.
|
|
47
|
+
*/
|
|
48
|
+
export function styleLayers(
|
|
49
|
+
entityType: string,
|
|
50
|
+
props: readonly EntityProperty[],
|
|
51
|
+
sources: StyleSources,
|
|
52
|
+
): StyleLayer[] {
|
|
53
|
+
const layers: StyleLayer[] = [];
|
|
54
|
+
|
|
55
|
+
// Level 2: the `default <entity>` line, its `style:` first and its own
|
|
56
|
+
// keys on top (the same order levels 4 and 5 use on the entity).
|
|
57
|
+
const defaultDecl = sources.defaults.get(entityType);
|
|
58
|
+
if (defaultDecl) {
|
|
59
|
+
const defaultStyle = styleLayer('default-style', defaultDecl.properties, sources);
|
|
60
|
+
if (defaultStyle) layers.push(defaultStyle);
|
|
61
|
+
layers.push({ level: 'default', props: defaultDecl.properties });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Level 3: label styles, last label first so the first label wins.
|
|
65
|
+
const labelsProp = findProp(props, 'labels');
|
|
66
|
+
const labelIds = labelsProp ? (labelsProp.value ? [labelsProp.value] : labelsProp.values) : [];
|
|
67
|
+
for (const id of [...labelIds].reverse()) {
|
|
68
|
+
const label = sources.labels.get(id);
|
|
69
|
+
if (!label) {
|
|
70
|
+
layers.push({ level: 'label', id, label: undefined });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const labelStyle = styleLayer('label-style', label.properties, sources);
|
|
74
|
+
if (labelStyle) layers.push(labelStyle);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Level 4: the entity's own `style:`.
|
|
78
|
+
const entityStyle = styleLayer('entity-style', props, sources);
|
|
79
|
+
if (entityStyle) layers.push(entityStyle);
|
|
80
|
+
|
|
81
|
+
// Level 5: the entity's own keys.
|
|
82
|
+
layers.push({ level: 'inline', props });
|
|
83
|
+
return layers;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The layer of the `style:` in `props`, or undefined when it has none. */
|
|
87
|
+
function styleLayer(
|
|
88
|
+
level: 'default-style' | 'label-style' | 'entity-style',
|
|
89
|
+
props: readonly EntityProperty[],
|
|
90
|
+
sources: StyleSources,
|
|
91
|
+
): StyleLayer | undefined {
|
|
92
|
+
const id = findProp(props, 'style')?.value;
|
|
93
|
+
if (!id) return undefined;
|
|
94
|
+
return { level, id, decl: sources.styles.get(id) };
|
|
95
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// Calendar and scale block, calendar declaration, week and duplicate calendar id 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 { ValidationAcceptor } from 'langium';
|
|
6
|
+
import type {
|
|
7
|
+
CalendarBlock,
|
|
8
|
+
NonWorkingDeclaration,
|
|
9
|
+
NowlineFile,
|
|
10
|
+
ScaleBlock,
|
|
11
|
+
WorkingDeclaration,
|
|
12
|
+
} from '../../generated/ast.js';
|
|
13
|
+
import {
|
|
14
|
+
isCalendarBlock,
|
|
15
|
+
isNonWorkingDeclaration,
|
|
16
|
+
isWorkingDeclaration,
|
|
17
|
+
} from '../../generated/ast.js';
|
|
18
|
+
import { isRealIsoDate, propKey } from '../../util/props.js';
|
|
19
|
+
import type { CalendarDeclarationFacts } from '../calendar-declarations.js';
|
|
20
|
+
import {
|
|
21
|
+
CALENDAR_DECLARATION_KEYS,
|
|
22
|
+
classifyCalendarDeclaration,
|
|
23
|
+
isWeekday,
|
|
24
|
+
replacesPresetWeekend,
|
|
25
|
+
} from '../calendar-declarations.js';
|
|
26
|
+
import { entityTypeLabel } from '../validator-utils.js';
|
|
27
|
+
import type { DiagnosticInfo } from './support.js';
|
|
28
|
+
import { acceptTr } from './support.js';
|
|
29
|
+
import { CALENDAR_FIELDS, INTEGER_RE, SCALE_FIELDS } from './tables.js';
|
|
30
|
+
|
|
31
|
+
// --- Rule 7 (calendar): calendar block only valid when roadmap calendar:custom ---
|
|
32
|
+
// Rule 8: custom calendar requires all four fields.
|
|
33
|
+
export function checkCalendarBlockConsistency(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
34
|
+
const calendarBlocks = file.configEntries.filter(isCalendarBlock);
|
|
35
|
+
const calendarProp = file.roadmapDecl?.properties.find((p) => propKey(p) === 'calendar');
|
|
36
|
+
const calendarMode = calendarProp?.value;
|
|
37
|
+
|
|
38
|
+
if (calendarBlocks.length > 0 && calendarMode !== 'custom') {
|
|
39
|
+
for (const block of calendarBlocks) {
|
|
40
|
+
accept(
|
|
41
|
+
'error',
|
|
42
|
+
`A "calendar" config block is only valid when the roadmap declares calendar:custom.`,
|
|
43
|
+
{ node: block },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (calendarMode === 'custom' && calendarBlocks.length === 0) {
|
|
49
|
+
accept(
|
|
50
|
+
'error',
|
|
51
|
+
`calendar:custom requires a "calendar" config block with days-per-week, days-per-month, days-per-quarter, and days-per-year.`,
|
|
52
|
+
{ node: file.roadmapDecl!, property: 'properties' },
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (calendarMode === 'custom' && calendarBlocks.length > 0) {
|
|
57
|
+
for (const block of calendarBlocks) {
|
|
58
|
+
const presentKeys = new Set(block.properties.map((p) => propKey(p)));
|
|
59
|
+
for (const field of CALENDAR_FIELDS) {
|
|
60
|
+
if (!presentKeys.has(field)) {
|
|
61
|
+
accept(
|
|
62
|
+
'error',
|
|
63
|
+
`calendar:custom requires "${field}" in the calendar config block.`,
|
|
64
|
+
{ node: block },
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// --- Rule 9: calendar block property values must be positive integers ---
|
|
73
|
+
export function checkCalendarBlock(block: CalendarBlock, accept: ValidationAcceptor): void {
|
|
74
|
+
const seen = new Set<string>();
|
|
75
|
+
for (const prop of block.properties) {
|
|
76
|
+
const key = propKey(prop);
|
|
77
|
+
if (!CALENDAR_FIELDS.has(key)) {
|
|
78
|
+
accept(
|
|
79
|
+
'error',
|
|
80
|
+
`Unknown calendar property "${key}". Allowed: ${[...CALENDAR_FIELDS].join(', ')}.`,
|
|
81
|
+
{ node: prop, property: 'key' },
|
|
82
|
+
);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (seen.has(key)) {
|
|
86
|
+
accept('error', `Duplicate calendar property "${key}".`, {
|
|
87
|
+
node: prop,
|
|
88
|
+
property: 'key',
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
seen.add(key);
|
|
92
|
+
|
|
93
|
+
if (!INTEGER_RE.test(prop.value) || parseInt(prop.value, 10) <= 0) {
|
|
94
|
+
accept('error', `"${key}" must be a positive integer, got "${prop.value}".`, {
|
|
95
|
+
node: prop,
|
|
96
|
+
property: 'value',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// --- Scale block property validation ---
|
|
103
|
+
export function checkScaleBlock(block: ScaleBlock, accept: ValidationAcceptor): void {
|
|
104
|
+
const seen = new Set<string>();
|
|
105
|
+
for (const prop of block.properties) {
|
|
106
|
+
const key = propKey(prop);
|
|
107
|
+
if (!SCALE_FIELDS.has(key)) {
|
|
108
|
+
accept(
|
|
109
|
+
'error',
|
|
110
|
+
`Unknown scale property "${key}". Allowed: ${[...SCALE_FIELDS].join(', ')}.`,
|
|
111
|
+
{ node: prop, property: 'key' },
|
|
112
|
+
);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (seen.has(key)) {
|
|
116
|
+
accept('error', `Duplicate scale property "${key}".`, {
|
|
117
|
+
node: prop,
|
|
118
|
+
property: 'key',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
seen.add(key);
|
|
122
|
+
|
|
123
|
+
if (key === 'label-every') {
|
|
124
|
+
if (!INTEGER_RE.test(prop.value) || parseInt(prop.value, 10) <= 0) {
|
|
125
|
+
accept('error', `"label-every" must be a positive integer, got "${prop.value}".`, {
|
|
126
|
+
node: prop,
|
|
127
|
+
property: 'value',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// --- NW1-NW3: one `non-working` / `working` declaration (specs/working-calendar.md §6) ---
|
|
135
|
+
// Shared by both keywords. The shape is judged over the four own keys only; any other
|
|
136
|
+
// key is NL.E0901 on its own, so `date:2026-01-01 style:x` reports just that key.
|
|
137
|
+
export function checkCalendarDeclaration(
|
|
138
|
+
decl: NonWorkingDeclaration | WorkingDeclaration,
|
|
139
|
+
accept: ValidationAcceptor,
|
|
140
|
+
): void {
|
|
141
|
+
const kind = entityTypeLabel(decl);
|
|
142
|
+
const facts = classifyCalendarDeclaration(decl);
|
|
143
|
+
const { own } = facts;
|
|
144
|
+
|
|
145
|
+
for (const prop of decl.properties) {
|
|
146
|
+
if (!CALENDAR_DECLARATION_KEYS.has(propKey(prop))) {
|
|
147
|
+
acceptTr(accept, 'error', { node: prop, property: 'key' }, 'NL.E0901', {
|
|
148
|
+
kind,
|
|
149
|
+
key: propKey(prop),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (facts.shape === 'malformed') {
|
|
155
|
+
acceptTr(accept, 'error', { node: decl }, 'NL.E0900', { kind });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// `date:` elements. A single value is checked by checkPropertyValues.
|
|
159
|
+
const dateProp = own.get('date');
|
|
160
|
+
if (dateProp && dateProp.values.length > 0) {
|
|
161
|
+
dateProp.values.forEach((value, index) => {
|
|
162
|
+
if (!isRealIsoDate(value)) {
|
|
163
|
+
acceptTr(
|
|
164
|
+
accept,
|
|
165
|
+
'error',
|
|
166
|
+
{ node: dateProp, property: 'values', index },
|
|
167
|
+
'NL.E0405',
|
|
168
|
+
{
|
|
169
|
+
key: 'date',
|
|
170
|
+
value,
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
for (const key of ['start', 'end'] as const) {
|
|
178
|
+
const prop = own.get(key);
|
|
179
|
+
// A one-element bracket is the single date; two or more is a list.
|
|
180
|
+
if (prop && prop.values.length > 1) {
|
|
181
|
+
acceptTr(accept, 'error', { node: prop }, 'NL.E0902', { kind, key });
|
|
182
|
+
} else if (prop && prop.values.length === 1 && !isRealIsoDate(prop.values[0])) {
|
|
183
|
+
// checkPropertyValues reads `value` only, so the element is checked here.
|
|
184
|
+
acceptTr(accept, 'error', { node: prop, property: 'values', index: 0 }, 'NL.E0405', {
|
|
185
|
+
key,
|
|
186
|
+
value: prop.values[0],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const { start, end } = facts;
|
|
192
|
+
if (start && end && end < start) {
|
|
193
|
+
acceptTr(accept, 'error', { node: own.get('end')!, property: 'value' }, 'NL.E0903', {
|
|
194
|
+
start,
|
|
195
|
+
end,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const everyProp = own.get('every');
|
|
200
|
+
if (everyProp) {
|
|
201
|
+
const seen = new Set<string>();
|
|
202
|
+
const names = everyProp.value !== undefined ? [everyProp.value] : everyProp.values;
|
|
203
|
+
names.forEach((value, index) => {
|
|
204
|
+
const info: DiagnosticInfo =
|
|
205
|
+
everyProp.values.length > 0
|
|
206
|
+
? { node: everyProp, property: 'values', index }
|
|
207
|
+
: { node: everyProp, property: 'value' };
|
|
208
|
+
if (!isWeekday(value)) {
|
|
209
|
+
acceptTr(accept, 'error', info, 'NL.E0904', { value });
|
|
210
|
+
} else if (seen.has(value)) {
|
|
211
|
+
acceptTr(accept, 'error', info, 'NL.E0905', { value });
|
|
212
|
+
}
|
|
213
|
+
seen.add(value);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// --- NW3 / NW4: the open-ended week of the root file ---
|
|
219
|
+
// Mirrors `resolveWorkingCalendar` in @nowline/layout for the file alone: an include's
|
|
220
|
+
// declarations are not visible here, so they never feed the week (documented limit).
|
|
221
|
+
export function checkCalendarWeek(file: NowlineFile, accept: ValidationAcceptor): void {
|
|
222
|
+
const roadmap = file.roadmapDecl;
|
|
223
|
+
// A file with no roadmap is an include; the roadmap that pulls it in owns the calendar.
|
|
224
|
+
if (!roadmap) return;
|
|
225
|
+
|
|
226
|
+
const declarations = file.configEntries.filter(isCalendarDeclaration);
|
|
227
|
+
const usable = declarations
|
|
228
|
+
.map((decl) => ({ decl, facts: classifyCalendarDeclaration(decl) }))
|
|
229
|
+
.filter(({ facts }) => facts.wellFormed);
|
|
230
|
+
const weekdaysOf = (facts: CalendarDeclarationFacts): number[] => facts.weekdays ?? [];
|
|
231
|
+
const openEnded = usable.filter(({ facts }) => facts.shape === 'open-recurrence');
|
|
232
|
+
|
|
233
|
+
const calendarProp = roadmap.properties.find((p) => propKey(p) === 'calendar');
|
|
234
|
+
const block = file.configEntries.find(isCalendarBlock);
|
|
235
|
+
const isCustom = calendarProp?.value === 'custom' && block !== undefined;
|
|
236
|
+
const isFull = calendarProp?.value === 'full';
|
|
237
|
+
const daysPerWeekProp = isCustom
|
|
238
|
+
? block.properties.find((p) => propKey(p) === 'days-per-week')
|
|
239
|
+
: undefined;
|
|
240
|
+
const declaredDays = parseInt(daysPerWeekProp?.value ?? '', 10);
|
|
241
|
+
const daysPerWeek = isCustom
|
|
242
|
+
? Number.isFinite(declaredDays) && declaredDays > 0
|
|
243
|
+
? declaredDays
|
|
244
|
+
: BUSINESS_DAYS_PER_WEEK
|
|
245
|
+
: isFull
|
|
246
|
+
? 7
|
|
247
|
+
: BUSINESS_DAYS_PER_WEEK;
|
|
248
|
+
|
|
249
|
+
// The preset weekend, unless a non-working declaration is named `weekend`.
|
|
250
|
+
const replacesWeekend = replacesPresetWeekend(declarations);
|
|
251
|
+
const open = new Set<number>(!isCustom && !isFull && !replacesWeekend ? [0, 6] : []);
|
|
252
|
+
for (const { decl, facts } of openEnded) {
|
|
253
|
+
if (isNonWorkingDeclaration(decl)) {
|
|
254
|
+
for (const day of weekdaysOf(facts)) open.add(day);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
for (const { decl, facts } of openEnded) {
|
|
258
|
+
if (isWorkingDeclaration(decl)) {
|
|
259
|
+
for (const day of weekdaysOf(facts)) open.delete(day);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (open.size === 7) {
|
|
264
|
+
for (const { decl } of openEnded) {
|
|
265
|
+
if (isNonWorkingDeclaration(decl)) {
|
|
266
|
+
acceptTr(accept, 'error', { node: decl }, 'NL.E0906');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
for (const { decl, facts } of usable) {
|
|
271
|
+
if (!isNonWorkingDeclaration(decl) || facts.shape !== 'half-bounded-recurrence') {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const days = new Set([...open, ...weekdaysOf(facts)]);
|
|
275
|
+
if (days.size === 7) acceptTr(accept, 'error', { node: decl }, 'NL.E0906');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const working = 7 - open.size;
|
|
279
|
+
// With no working day left the error above is the finding.
|
|
280
|
+
if (working === 0 || working === daysPerWeek) return;
|
|
281
|
+
const info: DiagnosticInfo = isCustom
|
|
282
|
+
? daysPerWeekProp
|
|
283
|
+
? { node: daysPerWeekProp, property: 'value' }
|
|
284
|
+
: { node: block }
|
|
285
|
+
: calendarProp
|
|
286
|
+
? { node: calendarProp }
|
|
287
|
+
: openEnded.length > 0
|
|
288
|
+
? { node: openEnded[0].decl }
|
|
289
|
+
: { node: roadmap };
|
|
290
|
+
acceptTr(accept, 'warning', info, 'NL.W0705', { daysPerWeek, working });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// --- NW5: duplicate declaration ids in one file, per keyword ---
|
|
294
|
+
export function checkDuplicateCalendarDeclarationIds(
|
|
295
|
+
file: NowlineFile,
|
|
296
|
+
accept: ValidationAcceptor,
|
|
297
|
+
): void {
|
|
298
|
+
const seen = new Map<string, NonWorkingDeclaration | WorkingDeclaration>();
|
|
299
|
+
for (const entry of file.configEntries) {
|
|
300
|
+
if (!isCalendarDeclaration(entry) || !entry.name) continue;
|
|
301
|
+
const key = `${entry.$type}:${entry.name}`;
|
|
302
|
+
if (seen.has(key)) {
|
|
303
|
+
acceptTr(accept, 'error', { node: entry, property: 'name' }, 'NL.E0907', {
|
|
304
|
+
kind: entityTypeLabel(entry),
|
|
305
|
+
name: entry.name,
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
seen.set(key, entry);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const BUSINESS_DAYS_PER_WEEK = 5;
|
|
314
|
+
|
|
315
|
+
type CalendarDeclaration = NonWorkingDeclaration | WorkingDeclaration;
|
|
316
|
+
|
|
317
|
+
function isCalendarDeclaration(node: unknown): node is CalendarDeclaration {
|
|
318
|
+
return isNonWorkingDeclaration(node) || isWorkingDeclaration(node);
|
|
319
|
+
}
|