@maias/core 0.2.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +46 -0
- package/dist/diagnostics.d.ts +42 -0
- package/dist/diagnostics.js +29 -0
- package/dist/edit.d.ts +84 -0
- package/dist/edit.js +321 -0
- package/dist/fmt.d.ts +27 -0
- package/dist/fmt.js +257 -0
- package/dist/graph.d.ts +29 -0
- package/dist/graph.js +93 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/lint.d.ts +8 -0
- package/dist/lint.js +176 -0
- package/dist/maias-schema.gen.d.ts +1 -0
- package/dist/maias-schema.gen.js +497 -0
- package/dist/model.d.ts +104 -0
- package/dist/model.js +58 -0
- package/dist/parse.d.ts +36 -0
- package/dist/parse.js +65 -0
- package/dist/schema-validate.d.ts +3 -0
- package/dist/schema-validate.js +97 -0
- package/dist/validate.d.ts +11 -0
- package/dist/validate.js +19 -0
- package/package.json +48 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
// GENERATED from schema/maias.schema.json — do not edit; run `npm run sync-schema`.
|
|
2
|
+
export const MAIAS_SCHEMA = {
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$id": "urn:maias:schema:1.1",
|
|
5
|
+
"title": "MAIAS — Mobile App Information Architecture Schema",
|
|
6
|
+
"description": "Formal definition of MAIAS documents, spec v1.1. YAML is the primary serialisation; an equivalent JSON document validates identically. Semantic rules that cannot be expressed here (unique IDs/paths, dangling targets, registry membership, reachability) are enforced by `maias validate` lint — see docs/spec/README.md.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"maias": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^1\\.[0-9]+$",
|
|
12
|
+
"description": "Spec version header, e.g. \"1.0\". Always a quoted string."
|
|
13
|
+
},
|
|
14
|
+
"app": {
|
|
15
|
+
"$ref": "#/$defs/app"
|
|
16
|
+
},
|
|
17
|
+
"screens": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"minItems": 1,
|
|
20
|
+
"items": {
|
|
21
|
+
"$ref": "#/$defs/screen"
|
|
22
|
+
},
|
|
23
|
+
"description": "All screen definitions."
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": [
|
|
27
|
+
"maias",
|
|
28
|
+
"app",
|
|
29
|
+
"screens"
|
|
30
|
+
],
|
|
31
|
+
"patternProperties": {
|
|
32
|
+
"^x_": {}
|
|
33
|
+
},
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"$defs": {
|
|
36
|
+
"screenId": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"pattern": "^[a-z][a-z0-9_]*$",
|
|
39
|
+
"description": "snake_case screen identifier."
|
|
40
|
+
},
|
|
41
|
+
"flowName": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"pattern": "^[a-z][a-z0-9_]*$",
|
|
44
|
+
"description": "snake_case flow name."
|
|
45
|
+
},
|
|
46
|
+
"path": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"pattern": "^/[a-z0-9-]+(/([a-z0-9-]+|:[a-z][a-z0-9_]*))*$",
|
|
49
|
+
"description": "Kebab-case URL path with optional :param segments, e.g. /map/location/:id."
|
|
50
|
+
},
|
|
51
|
+
"presentation": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": [
|
|
54
|
+
"push",
|
|
55
|
+
"replace",
|
|
56
|
+
"modal",
|
|
57
|
+
"sheet"
|
|
58
|
+
],
|
|
59
|
+
"description": "How the target screen is presented. Default: push."
|
|
60
|
+
},
|
|
61
|
+
"screenType": {
|
|
62
|
+
"description": "Core screen type, or an x_-prefixed custom type.",
|
|
63
|
+
"anyOf": [
|
|
64
|
+
{
|
|
65
|
+
"type": "string",
|
|
66
|
+
"enum": [
|
|
67
|
+
"action",
|
|
68
|
+
"action_sheet",
|
|
69
|
+
"container",
|
|
70
|
+
"detail",
|
|
71
|
+
"form",
|
|
72
|
+
"informational",
|
|
73
|
+
"list",
|
|
74
|
+
"map",
|
|
75
|
+
"marketing",
|
|
76
|
+
"menu",
|
|
77
|
+
"search",
|
|
78
|
+
"status"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "string",
|
|
83
|
+
"pattern": "^x_[a-z][a-z0-9_]*$"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"app": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"properties": {
|
|
90
|
+
"name": {
|
|
91
|
+
"type": "string",
|
|
92
|
+
"minLength": 1
|
|
93
|
+
},
|
|
94
|
+
"description": {
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"links": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"properties": {
|
|
100
|
+
"scheme": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"pattern": "^[a-z][a-z0-9-]*$",
|
|
103
|
+
"description": "App URL scheme for deep links, e.g. shopfront → shopfront://…"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": [
|
|
107
|
+
"scheme"
|
|
108
|
+
],
|
|
109
|
+
"patternProperties": {
|
|
110
|
+
"^x_": {}
|
|
111
|
+
},
|
|
112
|
+
"additionalProperties": false
|
|
113
|
+
},
|
|
114
|
+
"navigation": {
|
|
115
|
+
"$ref": "#/$defs/navigationRegistry"
|
|
116
|
+
},
|
|
117
|
+
"flows": {
|
|
118
|
+
"type": "array",
|
|
119
|
+
"minItems": 1,
|
|
120
|
+
"items": {
|
|
121
|
+
"$ref": "#/$defs/flow"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"required": [
|
|
126
|
+
"name",
|
|
127
|
+
"navigation",
|
|
128
|
+
"flows"
|
|
129
|
+
],
|
|
130
|
+
"patternProperties": {
|
|
131
|
+
"^x_": {}
|
|
132
|
+
},
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
},
|
|
135
|
+
"navigationRegistry": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"description": "Every screen must appear in exactly one of primary.screens / secondary.screens (lint-enforced).",
|
|
138
|
+
"properties": {
|
|
139
|
+
"primary": {
|
|
140
|
+
"$ref": "#/$defs/navigationGroup"
|
|
141
|
+
},
|
|
142
|
+
"secondary": {
|
|
143
|
+
"$ref": "#/$defs/navigationGroup"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"required": [
|
|
147
|
+
"primary",
|
|
148
|
+
"secondary"
|
|
149
|
+
],
|
|
150
|
+
"patternProperties": {
|
|
151
|
+
"^x_": {}
|
|
152
|
+
},
|
|
153
|
+
"additionalProperties": false
|
|
154
|
+
},
|
|
155
|
+
"navigationGroup": {
|
|
156
|
+
"type": "object",
|
|
157
|
+
"properties": {
|
|
158
|
+
"label": {
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
"screens": {
|
|
162
|
+
"type": "array",
|
|
163
|
+
"uniqueItems": true,
|
|
164
|
+
"items": {
|
|
165
|
+
"$ref": "#/$defs/screenId"
|
|
166
|
+
},
|
|
167
|
+
"description": "Screen IDs; primary = tab order."
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"required": [
|
|
171
|
+
"screens"
|
|
172
|
+
],
|
|
173
|
+
"patternProperties": {
|
|
174
|
+
"^x_": {}
|
|
175
|
+
},
|
|
176
|
+
"additionalProperties": false
|
|
177
|
+
},
|
|
178
|
+
"flow": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"properties": {
|
|
181
|
+
"name": {
|
|
182
|
+
"$ref": "#/$defs/flowName"
|
|
183
|
+
},
|
|
184
|
+
"description": {
|
|
185
|
+
"type": "string"
|
|
186
|
+
},
|
|
187
|
+
"entry_screen": {
|
|
188
|
+
"$ref": "#/$defs/screenId"
|
|
189
|
+
},
|
|
190
|
+
"screens": {
|
|
191
|
+
"type": "array",
|
|
192
|
+
"minItems": 1,
|
|
193
|
+
"uniqueItems": true,
|
|
194
|
+
"items": {
|
|
195
|
+
"$ref": "#/$defs/screenId"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"required": [
|
|
200
|
+
"name",
|
|
201
|
+
"entry_screen",
|
|
202
|
+
"screens"
|
|
203
|
+
],
|
|
204
|
+
"patternProperties": {
|
|
205
|
+
"^x_": {}
|
|
206
|
+
},
|
|
207
|
+
"additionalProperties": false
|
|
208
|
+
},
|
|
209
|
+
"screen": {
|
|
210
|
+
"type": "object",
|
|
211
|
+
"properties": {
|
|
212
|
+
"id": {
|
|
213
|
+
"$ref": "#/$defs/screenId"
|
|
214
|
+
},
|
|
215
|
+
"title": {
|
|
216
|
+
"type": "string",
|
|
217
|
+
"minLength": 1
|
|
218
|
+
},
|
|
219
|
+
"type": {
|
|
220
|
+
"$ref": "#/$defs/screenType"
|
|
221
|
+
},
|
|
222
|
+
"path": {
|
|
223
|
+
"$ref": "#/$defs/path"
|
|
224
|
+
},
|
|
225
|
+
"description": {
|
|
226
|
+
"type": "string",
|
|
227
|
+
"description": "What the screen does and why it exists. Lint warns when absent."
|
|
228
|
+
},
|
|
229
|
+
"presentation": {
|
|
230
|
+
"$ref": "#/$defs/presentation"
|
|
231
|
+
},
|
|
232
|
+
"auth": {
|
|
233
|
+
"type": "string",
|
|
234
|
+
"enum": [
|
|
235
|
+
"none",
|
|
236
|
+
"required"
|
|
237
|
+
],
|
|
238
|
+
"description": "Access gate. Default: none."
|
|
239
|
+
},
|
|
240
|
+
"deep_link": {
|
|
241
|
+
"type": "boolean",
|
|
242
|
+
"description": "Externally addressable at <scheme>://<path>. Default: false."
|
|
243
|
+
},
|
|
244
|
+
"back": {
|
|
245
|
+
"$ref": "#/$defs/backLink"
|
|
246
|
+
},
|
|
247
|
+
"features": {
|
|
248
|
+
"type": "array",
|
|
249
|
+
"items": {
|
|
250
|
+
"type": "string"
|
|
251
|
+
},
|
|
252
|
+
"description": "Named content/capability blocks (documentation-level)."
|
|
253
|
+
},
|
|
254
|
+
"actions": {
|
|
255
|
+
"type": "array",
|
|
256
|
+
"items": {
|
|
257
|
+
"$ref": "#/$defs/actionEntry"
|
|
258
|
+
},
|
|
259
|
+
"description": "Interactive elements that don't navigate."
|
|
260
|
+
},
|
|
261
|
+
"elements": {
|
|
262
|
+
"type": "array",
|
|
263
|
+
"items": {
|
|
264
|
+
"$ref": "#/$defs/element"
|
|
265
|
+
},
|
|
266
|
+
"description": "UI element declarations, in render order."
|
|
267
|
+
},
|
|
268
|
+
"states": {
|
|
269
|
+
"$ref": "#/$defs/states"
|
|
270
|
+
},
|
|
271
|
+
"navigation": {
|
|
272
|
+
"$ref": "#/$defs/screenNavigation"
|
|
273
|
+
},
|
|
274
|
+
"data": {
|
|
275
|
+
"$ref": "#/$defs/data"
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"required": [
|
|
279
|
+
"id",
|
|
280
|
+
"title",
|
|
281
|
+
"type",
|
|
282
|
+
"path"
|
|
283
|
+
],
|
|
284
|
+
"patternProperties": {
|
|
285
|
+
"^x_": {}
|
|
286
|
+
},
|
|
287
|
+
"additionalProperties": false
|
|
288
|
+
},
|
|
289
|
+
"backLink": {
|
|
290
|
+
"type": "object",
|
|
291
|
+
"description": "Declared back affordance (since spec 1.1): where the header back button leads. When label is omitted, renderers use the target screen's title.",
|
|
292
|
+
"properties": {
|
|
293
|
+
"label": {
|
|
294
|
+
"type": "string",
|
|
295
|
+
"minLength": 1
|
|
296
|
+
},
|
|
297
|
+
"target": {
|
|
298
|
+
"$ref": "#/$defs/screenId"
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"required": [
|
|
302
|
+
"target"
|
|
303
|
+
],
|
|
304
|
+
"patternProperties": {
|
|
305
|
+
"^x_": {}
|
|
306
|
+
},
|
|
307
|
+
"additionalProperties": false
|
|
308
|
+
},
|
|
309
|
+
"actionEntry": {
|
|
310
|
+
"description": "Plain string, or {label, external?} for actions that leave the app.",
|
|
311
|
+
"oneOf": [
|
|
312
|
+
{
|
|
313
|
+
"type": "string"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"type": "object",
|
|
317
|
+
"properties": {
|
|
318
|
+
"label": {
|
|
319
|
+
"type": "string"
|
|
320
|
+
},
|
|
321
|
+
"external": {
|
|
322
|
+
"type": "boolean"
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"required": [
|
|
326
|
+
"label"
|
|
327
|
+
],
|
|
328
|
+
"patternProperties": {
|
|
329
|
+
"^x_": {}
|
|
330
|
+
},
|
|
331
|
+
"additionalProperties": false
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
},
|
|
335
|
+
"element": {
|
|
336
|
+
"type": "object",
|
|
337
|
+
"description": "A design-system-neutral UI element. `type` beyond the core taxonomy is allowed by design (fallback guarantee); lint warns when an unknown type lacks the x_ prefix.",
|
|
338
|
+
"properties": {
|
|
339
|
+
"label": {
|
|
340
|
+
"type": "string"
|
|
341
|
+
},
|
|
342
|
+
"type": {
|
|
343
|
+
"type": "string",
|
|
344
|
+
"pattern": "^[a-z][a-z0-9_]*$",
|
|
345
|
+
"description": "Core taxonomy type (see docs/spec/05-elements.md) or x_-prefixed custom type."
|
|
346
|
+
},
|
|
347
|
+
"target": {
|
|
348
|
+
"$ref": "#/$defs/screenId"
|
|
349
|
+
},
|
|
350
|
+
"presentation": {
|
|
351
|
+
"$ref": "#/$defs/presentation"
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"required": [
|
|
355
|
+
"type"
|
|
356
|
+
],
|
|
357
|
+
"patternProperties": {
|
|
358
|
+
"^x_": {}
|
|
359
|
+
},
|
|
360
|
+
"additionalProperties": false
|
|
361
|
+
},
|
|
362
|
+
"states": {
|
|
363
|
+
"type": "object",
|
|
364
|
+
"description": "Non-default screen states. The default state is the screen's own `elements`.",
|
|
365
|
+
"properties": {
|
|
366
|
+
"empty": {
|
|
367
|
+
"$ref": "#/$defs/stateVariant"
|
|
368
|
+
},
|
|
369
|
+
"loading": {
|
|
370
|
+
"$ref": "#/$defs/stateVariant"
|
|
371
|
+
},
|
|
372
|
+
"error": {
|
|
373
|
+
"$ref": "#/$defs/stateVariant"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
"patternProperties": {
|
|
377
|
+
"^x_": {}
|
|
378
|
+
},
|
|
379
|
+
"additionalProperties": false
|
|
380
|
+
},
|
|
381
|
+
"stateVariant": {
|
|
382
|
+
"type": "object",
|
|
383
|
+
"properties": {
|
|
384
|
+
"description": {
|
|
385
|
+
"type": "string"
|
|
386
|
+
},
|
|
387
|
+
"elements": {
|
|
388
|
+
"type": "array",
|
|
389
|
+
"items": {
|
|
390
|
+
"$ref": "#/$defs/element"
|
|
391
|
+
},
|
|
392
|
+
"description": "Full replacement element list for this state."
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"patternProperties": {
|
|
396
|
+
"^x_": {}
|
|
397
|
+
},
|
|
398
|
+
"additionalProperties": false
|
|
399
|
+
},
|
|
400
|
+
"screenNavigation": {
|
|
401
|
+
"type": "object",
|
|
402
|
+
"properties": {
|
|
403
|
+
"primary": {
|
|
404
|
+
"type": "array",
|
|
405
|
+
"items": {
|
|
406
|
+
"$ref": "#/$defs/navigationItem"
|
|
407
|
+
},
|
|
408
|
+
"description": "Tab-bar items; only meaningful on primary screens."
|
|
409
|
+
},
|
|
410
|
+
"secondary": {
|
|
411
|
+
"type": "array",
|
|
412
|
+
"items": {
|
|
413
|
+
"$ref": "#/$defs/navigationItem"
|
|
414
|
+
},
|
|
415
|
+
"description": "Contextual links to other screens."
|
|
416
|
+
},
|
|
417
|
+
"actions": {
|
|
418
|
+
"type": "array",
|
|
419
|
+
"items": {
|
|
420
|
+
"$ref": "#/$defs/navigationAction"
|
|
421
|
+
},
|
|
422
|
+
"description": "Non-navigating interactions."
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
"patternProperties": {
|
|
426
|
+
"^x_": {}
|
|
427
|
+
},
|
|
428
|
+
"additionalProperties": false
|
|
429
|
+
},
|
|
430
|
+
"navigationItem": {
|
|
431
|
+
"type": "object",
|
|
432
|
+
"properties": {
|
|
433
|
+
"label": {
|
|
434
|
+
"type": "string",
|
|
435
|
+
"minLength": 1
|
|
436
|
+
},
|
|
437
|
+
"target": {
|
|
438
|
+
"$ref": "#/$defs/screenId"
|
|
439
|
+
},
|
|
440
|
+
"presentation": {
|
|
441
|
+
"$ref": "#/$defs/presentation"
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
"required": [
|
|
445
|
+
"label",
|
|
446
|
+
"target"
|
|
447
|
+
],
|
|
448
|
+
"patternProperties": {
|
|
449
|
+
"^x_": {}
|
|
450
|
+
},
|
|
451
|
+
"additionalProperties": false
|
|
452
|
+
},
|
|
453
|
+
"navigationAction": {
|
|
454
|
+
"type": "object",
|
|
455
|
+
"properties": {
|
|
456
|
+
"label": {
|
|
457
|
+
"type": "string",
|
|
458
|
+
"minLength": 1
|
|
459
|
+
},
|
|
460
|
+
"external": {
|
|
461
|
+
"type": "boolean",
|
|
462
|
+
"description": "True when the action leaves the app (web link, share sheet, …)."
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
"required": [
|
|
466
|
+
"label"
|
|
467
|
+
],
|
|
468
|
+
"patternProperties": {
|
|
469
|
+
"^x_": {}
|
|
470
|
+
},
|
|
471
|
+
"additionalProperties": false
|
|
472
|
+
},
|
|
473
|
+
"data": {
|
|
474
|
+
"type": "object",
|
|
475
|
+
"properties": {
|
|
476
|
+
"reads": {
|
|
477
|
+
"type": "array",
|
|
478
|
+
"items": {
|
|
479
|
+
"type": "string"
|
|
480
|
+
},
|
|
481
|
+
"description": "Data keys the screen consumes."
|
|
482
|
+
},
|
|
483
|
+
"writes": {
|
|
484
|
+
"type": "array",
|
|
485
|
+
"items": {
|
|
486
|
+
"type": "string"
|
|
487
|
+
},
|
|
488
|
+
"description": "Data keys the screen creates or mutates."
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
"patternProperties": {
|
|
492
|
+
"^x_": {}
|
|
493
|
+
},
|
|
494
|
+
"additionalProperties": false
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed object model for MAIAS documents, mirroring spec v1.0 (docs/spec/) 1:1.
|
|
3
|
+
* `x_`-prefixed extension fields may appear on any object; they are typed as
|
|
4
|
+
* an index signature so they survive typed access without casts.
|
|
5
|
+
*/
|
|
6
|
+
export type Presentation = 'push' | 'replace' | 'modal' | 'sheet';
|
|
7
|
+
export type AuthGate = 'none' | 'required';
|
|
8
|
+
export type CoreScreenType = 'action' | 'action_sheet' | 'container' | 'detail' | 'form' | 'informational' | 'list' | 'map' | 'marketing' | 'menu' | 'search' | 'status';
|
|
9
|
+
/** Core screen types plus `x_`-prefixed custom types. */
|
|
10
|
+
export type ScreenType = CoreScreenType | `x_${string}`;
|
|
11
|
+
export declare const CORE_SCREEN_TYPES: readonly CoreScreenType[];
|
|
12
|
+
/** The 29 core element types (spec chapter 5). Custom types are `x_`-prefixed. */
|
|
13
|
+
export declare const CORE_ELEMENT_TYPES: readonly string[];
|
|
14
|
+
export interface Extensible {
|
|
15
|
+
[key: `x_${string}`]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface Element extends Extensible {
|
|
18
|
+
type: string;
|
|
19
|
+
label?: string;
|
|
20
|
+
target?: string;
|
|
21
|
+
presentation?: Presentation;
|
|
22
|
+
}
|
|
23
|
+
export interface NavigationItem extends Extensible {
|
|
24
|
+
label: string;
|
|
25
|
+
target: string;
|
|
26
|
+
presentation?: Presentation;
|
|
27
|
+
}
|
|
28
|
+
export interface NavigationAction extends Extensible {
|
|
29
|
+
label: string;
|
|
30
|
+
external?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Screen `actions` entries: plain string or labelled object. */
|
|
33
|
+
export type ActionEntry = string | NavigationAction;
|
|
34
|
+
export interface ScreenNavigation extends Extensible {
|
|
35
|
+
primary?: NavigationItem[];
|
|
36
|
+
secondary?: NavigationItem[];
|
|
37
|
+
actions?: NavigationAction[];
|
|
38
|
+
}
|
|
39
|
+
/** Declared back affordance (spec §4.3, since 1.1). Label defaults to the target screen's title. */
|
|
40
|
+
export interface BackLink extends Extensible {
|
|
41
|
+
target: string;
|
|
42
|
+
label?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface StateVariant extends Extensible {
|
|
45
|
+
description?: string;
|
|
46
|
+
elements?: Element[];
|
|
47
|
+
}
|
|
48
|
+
export interface ScreenStates extends Extensible {
|
|
49
|
+
empty?: StateVariant;
|
|
50
|
+
loading?: StateVariant;
|
|
51
|
+
error?: StateVariant;
|
|
52
|
+
}
|
|
53
|
+
export interface ScreenData extends Extensible {
|
|
54
|
+
reads?: string[];
|
|
55
|
+
writes?: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface Screen extends Extensible {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
type: ScreenType | string;
|
|
61
|
+
path: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
presentation?: Presentation;
|
|
64
|
+
auth?: AuthGate;
|
|
65
|
+
deep_link?: boolean;
|
|
66
|
+
back?: BackLink;
|
|
67
|
+
features?: string[];
|
|
68
|
+
actions?: ActionEntry[];
|
|
69
|
+
elements?: Element[];
|
|
70
|
+
states?: ScreenStates;
|
|
71
|
+
navigation?: ScreenNavigation;
|
|
72
|
+
data?: ScreenData;
|
|
73
|
+
}
|
|
74
|
+
export interface Flow extends Extensible {
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
entry_screen: string;
|
|
78
|
+
screens: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface NavigationGroup extends Extensible {
|
|
81
|
+
label?: string;
|
|
82
|
+
screens: string[];
|
|
83
|
+
}
|
|
84
|
+
export interface NavigationRegistry extends Extensible {
|
|
85
|
+
primary: NavigationGroup;
|
|
86
|
+
secondary: NavigationGroup;
|
|
87
|
+
}
|
|
88
|
+
export interface AppLinks extends Extensible {
|
|
89
|
+
scheme: string;
|
|
90
|
+
}
|
|
91
|
+
export interface App extends Extensible {
|
|
92
|
+
name: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
links?: AppLinks;
|
|
95
|
+
navigation: NavigationRegistry;
|
|
96
|
+
flows: Flow[];
|
|
97
|
+
}
|
|
98
|
+
export interface MaiasDocument extends Extensible {
|
|
99
|
+
maias: string;
|
|
100
|
+
app: App;
|
|
101
|
+
screens: Screen[];
|
|
102
|
+
}
|
|
103
|
+
/** JSON path into the document: object keys and array indices. */
|
|
104
|
+
export type DocPath = (string | number)[];
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed object model for MAIAS documents, mirroring spec v1.0 (docs/spec/) 1:1.
|
|
3
|
+
* `x_`-prefixed extension fields may appear on any object; they are typed as
|
|
4
|
+
* an index signature so they survive typed access without casts.
|
|
5
|
+
*/
|
|
6
|
+
export const CORE_SCREEN_TYPES = [
|
|
7
|
+
'action',
|
|
8
|
+
'action_sheet',
|
|
9
|
+
'container',
|
|
10
|
+
'detail',
|
|
11
|
+
'form',
|
|
12
|
+
'informational',
|
|
13
|
+
'list',
|
|
14
|
+
'map',
|
|
15
|
+
'marketing',
|
|
16
|
+
'menu',
|
|
17
|
+
'search',
|
|
18
|
+
'status',
|
|
19
|
+
];
|
|
20
|
+
/** The 29 core element types (spec chapter 5). Custom types are `x_`-prefixed. */
|
|
21
|
+
export const CORE_ELEMENT_TYPES = [
|
|
22
|
+
// Text
|
|
23
|
+
'title',
|
|
24
|
+
'heading',
|
|
25
|
+
'paragraph',
|
|
26
|
+
'caption',
|
|
27
|
+
'bullets',
|
|
28
|
+
'label_value',
|
|
29
|
+
// Layout
|
|
30
|
+
'divider',
|
|
31
|
+
'spacer',
|
|
32
|
+
'card',
|
|
33
|
+
// Actions
|
|
34
|
+
'button',
|
|
35
|
+
'icon_button',
|
|
36
|
+
'link',
|
|
37
|
+
'chips',
|
|
38
|
+
// Inputs
|
|
39
|
+
'text_field',
|
|
40
|
+
'search_bar',
|
|
41
|
+
'toggle',
|
|
42
|
+
'checkbox',
|
|
43
|
+
'radio_group',
|
|
44
|
+
'dropdown',
|
|
45
|
+
'slider',
|
|
46
|
+
// Media
|
|
47
|
+
'image',
|
|
48
|
+
'avatar',
|
|
49
|
+
'map',
|
|
50
|
+
'video',
|
|
51
|
+
// Lists & collections
|
|
52
|
+
'list_item',
|
|
53
|
+
'empty_state',
|
|
54
|
+
// Feedback & status
|
|
55
|
+
'banner',
|
|
56
|
+
'progress',
|
|
57
|
+
'segmented_control',
|
|
58
|
+
];
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Document, LineCounter } from 'yaml';
|
|
2
|
+
import type { MaiasDocument, DocPath } from './model.js';
|
|
3
|
+
import { type Diagnostic } from './diagnostics.js';
|
|
4
|
+
export type SourceFormat = 'yaml' | 'json';
|
|
5
|
+
/**
|
|
6
|
+
* A parsed MAIAS document. Wraps the `yaml` Document (which preserves comments
|
|
7
|
+
* and source ranges for round-trip edits and line-referenced diagnostics)
|
|
8
|
+
* together with the plain-data view used by validation and graph utilities.
|
|
9
|
+
*
|
|
10
|
+
* JSON input is parsed through the same YAML parser (JSON is a YAML subset),
|
|
11
|
+
* so positions and edits work identically; `format` records the original
|
|
12
|
+
* serialisation so `toString()` can emit it back.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ParsedDocument {
|
|
15
|
+
readonly ydoc: Document;
|
|
16
|
+
private readonly lineCounter;
|
|
17
|
+
readonly format: SourceFormat;
|
|
18
|
+
constructor(ydoc: Document, lineCounter: LineCounter, format: SourceFormat);
|
|
19
|
+
/** Plain-data view. Recomputed on each call — cheap, and edits stay visible. */
|
|
20
|
+
get data(): MaiasDocument;
|
|
21
|
+
/** 1-based line/col for a JSON path, when resolvable. */
|
|
22
|
+
position(path: DocPath): {
|
|
23
|
+
line: number;
|
|
24
|
+
col: number;
|
|
25
|
+
} | undefined;
|
|
26
|
+
/** Serialise. YAML keeps comments and (for unedited nodes) original layout. */
|
|
27
|
+
toString(): string;
|
|
28
|
+
}
|
|
29
|
+
export interface ParseResult {
|
|
30
|
+
parsed?: ParsedDocument;
|
|
31
|
+
diagnostics: Diagnostic[];
|
|
32
|
+
}
|
|
33
|
+
/** Parse MAIAS source text (YAML or JSON). Syntax errors come back as diagnostics, never throws. */
|
|
34
|
+
export declare function parse(text: string, opts?: {
|
|
35
|
+
format?: SourceFormat;
|
|
36
|
+
}): ParseResult;
|