@mh-gg/schema 0.1.1-alpha.20260613T085325975Z

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.
Files changed (68) hide show
  1. package/package.json +39 -0
  2. package/schemas/app-composition.schema.json +684 -0
  3. package/schemas/example-app.schema.json +64 -0
  4. package/schemas/example-demo.schema.json +45 -0
  5. package/schemas/micro-plugin.schema.json +20 -0
  6. package/src/actions.cjs +31 -0
  7. package/src/app.d.ts +119 -0
  8. package/src/builder/app.cjs +157 -0
  9. package/src/builder/effects.cjs +116 -0
  10. package/src/builder/guards.cjs +35 -0
  11. package/src/builder/index.cjs +11 -0
  12. package/src/builder/matterhornApp/build.cjs +137 -0
  13. package/src/builder/matterhornApp/bundle.cjs +89 -0
  14. package/src/builder/matterhornApp/demo.cjs +161 -0
  15. package/src/builder/matterhornApp/demoAliases.cjs +50 -0
  16. package/src/builder/matterhornApp/descriptors.cjs +59 -0
  17. package/src/builder/matterhornApp/exports.cjs +95 -0
  18. package/src/builder/matterhornApp/frontend.cjs +80 -0
  19. package/src/builder/matterhornApp/plugins.cjs +95 -0
  20. package/src/builder/matterhornApp/shared.cjs +105 -0
  21. package/src/builder/matterhornApp.cjs +7 -0
  22. package/src/builder/model.cjs +172 -0
  23. package/src/builder/notifications.cjs +51 -0
  24. package/src/builder/refs.cjs +33 -0
  25. package/src/builder/schema.cjs +101 -0
  26. package/src/builder/streamKey.cjs +27 -0
  27. package/src/composition.cjs +157 -0
  28. package/src/configured.cjs +41 -0
  29. package/src/configured.d.ts +1 -0
  30. package/src/imports/loader.cjs +86 -0
  31. package/src/index.cjs +12 -0
  32. package/src/index.d.ts +168 -0
  33. package/src/json.cjs +70 -0
  34. package/src/jsonSchema/validator.cjs +131 -0
  35. package/src/microPlugin.cjs +112 -0
  36. package/src/model/collections.cjs +57 -0
  37. package/src/model/effects.cjs +149 -0
  38. package/src/model/expressions.cjs +85 -0
  39. package/src/model/guards.cjs +139 -0
  40. package/src/model/index.cjs +9 -0
  41. package/src/model/partitionOperands.cjs +89 -0
  42. package/src/model/partitionValidator.cjs +95 -0
  43. package/src/model/payload.cjs +93 -0
  44. package/src/model/plugin.cjs +146 -0
  45. package/src/notifications.cjs +41 -0
  46. package/src/notifications.d.ts +63 -0
  47. package/src/registry.cjs +63 -0
  48. package/src/runtime-exports.d.ts +65 -0
  49. package/src/streamKey.d.ts +15 -0
  50. package/src/types/actionTypes.cjs +164 -0
  51. package/src/types/coreActionPayloadSchemas.cjs +35 -0
  52. package/src/types/coreFeatures.cjs +29 -0
  53. package/src/types/entities.cjs +131 -0
  54. package/src/types/entityAliases.cjs +84 -0
  55. package/src/types/generator.cjs +145 -0
  56. package/src/types/index.cjs +5 -0
  57. package/src/types/interfaceBlock.cjs +41 -0
  58. package/src/types/pluginEntities.cjs +83 -0
  59. package/src/types/schema.cjs +148 -0
  60. package/src/types/standardPluginEntityTypes.cjs +135 -0
  61. package/test/content-lww-contract.test.cjs +104 -0
  62. package/test/partitionValidator.test.cjs +92 -0
  63. package/test/schema-array-effects.test.cjs +116 -0
  64. package/test/schema-builder-types.test.cjs +383 -0
  65. package/test/schema-composition.test.cjs +144 -0
  66. package/test/schema-configured-builders.test.cjs +286 -0
  67. package/test/schema-imports.test.cjs +66 -0
  68. package/test/schema-model-interpreter.test.cjs +273 -0
@@ -0,0 +1,684 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://matterhorn.gg/schemas/app-composition.schema.json",
4
+ "title": "Matterhorn app composition schema",
5
+ "type": "object",
6
+ "required": [
7
+ "kind",
8
+ "schemaVersion",
9
+ "app",
10
+ "primaryPlugin",
11
+ "plugins",
12
+ "views",
13
+ "actions",
14
+ "routes"
15
+ ],
16
+ "properties": {
17
+ "$schema": {
18
+ "type": "string"
19
+ },
20
+ "$imports": {
21
+ "$ref": "#/$defs/imports"
22
+ },
23
+ "kind": {
24
+ "const": "matterhorn.app-composition.schema"
25
+ },
26
+ "schemaVersion": {
27
+ "const": 1
28
+ },
29
+ "schemaHash": {
30
+ "type": "string"
31
+ },
32
+ "app": {
33
+ "type": "object",
34
+ "required": [
35
+ "id",
36
+ "version",
37
+ "name"
38
+ ],
39
+ "properties": {
40
+ "id": {
41
+ "type": "string",
42
+ "minLength": 1
43
+ },
44
+ "version": {
45
+ "type": "string",
46
+ "minLength": 1
47
+ },
48
+ "name": {
49
+ "type": "string",
50
+ "minLength": 1
51
+ }
52
+ },
53
+ "additionalProperties": false
54
+ },
55
+ "primaryPlugin": {
56
+ "type": "object",
57
+ "required": [
58
+ "id",
59
+ "version"
60
+ ],
61
+ "properties": {
62
+ "id": {
63
+ "type": "string",
64
+ "minLength": 1
65
+ },
66
+ "version": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "model": {
71
+ "$ref": "#/$defs/primaryModel"
72
+ }
73
+ },
74
+ "additionalProperties": false
75
+ },
76
+ "plugins": {
77
+ "type": "array",
78
+ "items": {
79
+ "oneOf": [
80
+ {
81
+ "type": "string",
82
+ "minLength": 1
83
+ },
84
+ {
85
+ "type": "object",
86
+ "required": [
87
+ "key",
88
+ "id",
89
+ "version"
90
+ ],
91
+ "properties": {
92
+ "key": {
93
+ "type": "string",
94
+ "minLength": 1
95
+ },
96
+ "id": {
97
+ "type": "string",
98
+ "minLength": 1
99
+ },
100
+ "version": {
101
+ "type": "string",
102
+ "minLength": 1
103
+ },
104
+ "required": {
105
+ "type": "boolean"
106
+ },
107
+ "config": {
108
+ "type": "object"
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ }
113
+ ]
114
+ }
115
+ },
116
+ "sharedScopes": {
117
+ "$ref": "#/$defs/sharedScopes"
118
+ },
119
+ "views": {
120
+ "type": "array",
121
+ "items": {
122
+ "type": "object"
123
+ }
124
+ },
125
+ "actions": {
126
+ "oneOf": [
127
+ {
128
+ "type": "object",
129
+ "additionalProperties": {
130
+ "$ref": "#/$defs/action"
131
+ }
132
+ },
133
+ {
134
+ "type": "array",
135
+ "items": {
136
+ "$ref": "#/$defs/action"
137
+ }
138
+ }
139
+ ]
140
+ },
141
+ "routes": {
142
+ "type": "array",
143
+ "items": {
144
+ "type": "object"
145
+ }
146
+ },
147
+ "notifications": {
148
+ "$ref": "#/$defs/notifications"
149
+ }
150
+ },
151
+ "additionalProperties": false,
152
+ "$defs": {
153
+ "imports": {
154
+ "oneOf": [
155
+ {
156
+ "type": "array",
157
+ "items": {
158
+ "$ref": "#/$defs/import"
159
+ }
160
+ },
161
+ {
162
+ "type": "object",
163
+ "additionalProperties": {
164
+ "oneOf": [
165
+ {
166
+ "type": "string"
167
+ },
168
+ {
169
+ "$ref": "#/$defs/import"
170
+ },
171
+ {
172
+ "type": "array",
173
+ "items": {
174
+ "oneOf": [
175
+ {
176
+ "type": "string"
177
+ },
178
+ {
179
+ "$ref": "#/$defs/import"
180
+ }
181
+ ]
182
+ }
183
+ }
184
+ ]
185
+ }
186
+ }
187
+ ]
188
+ },
189
+ "import": {
190
+ "type": "object",
191
+ "required": [
192
+ "path"
193
+ ],
194
+ "properties": {
195
+ "path": {
196
+ "type": "string",
197
+ "minLength": 1
198
+ },
199
+ "into": {
200
+ "type": "string",
201
+ "minLength": 1
202
+ },
203
+ "select": {
204
+ "type": "string",
205
+ "minLength": 1
206
+ },
207
+ "merge": {
208
+ "enum": [
209
+ "replace",
210
+ "merge",
211
+ "append"
212
+ ]
213
+ }
214
+ },
215
+ "additionalProperties": false
216
+ },
217
+ "sharedScopes": {
218
+ "type": "object",
219
+ "additionalProperties": {
220
+ "type": "object",
221
+ "required": [
222
+ "scopeType",
223
+ "scopeId",
224
+ "collections"
225
+ ],
226
+ "properties": {
227
+ "scopeType": {
228
+ "type": "string",
229
+ "minLength": 1
230
+ },
231
+ "scopeId": {
232
+ "type": "string",
233
+ "minLength": 1
234
+ },
235
+ "identity": {
236
+ "type": "string",
237
+ "minLength": 1
238
+ },
239
+ "participants": {
240
+ "type": "string",
241
+ "minLength": 1
242
+ },
243
+ "collections": {
244
+ "type": "array",
245
+ "minItems": 1,
246
+ "items": {
247
+ "type": "string",
248
+ "minLength": 1
249
+ }
250
+ },
251
+ "description": {
252
+ "type": "string"
253
+ },
254
+ "readClass": {
255
+ "enum": ["window", "head", "full-fold"]
256
+ },
257
+ "integrityClass": {
258
+ "enum": ["signature", "seq", "checkpoint"]
259
+ }
260
+ },
261
+ "additionalProperties": false
262
+ }
263
+ },
264
+ "action": {
265
+ "type": "object",
266
+ "required": [
267
+ "type"
268
+ ],
269
+ "properties": {
270
+ "name": {
271
+ "type": "string",
272
+ "minLength": 1
273
+ },
274
+ "plugin": {
275
+ "type": "string",
276
+ "minLength": 1
277
+ },
278
+ "pluginKey": {
279
+ "type": "string",
280
+ "minLength": 1
281
+ },
282
+ "pluginId": {
283
+ "type": "string",
284
+ "minLength": 1
285
+ },
286
+ "type": {
287
+ "type": "string",
288
+ "minLength": 1
289
+ },
290
+ "operation": {
291
+ "type": "string",
292
+ "minLength": 1
293
+ },
294
+ "label": {
295
+ "type": "string"
296
+ },
297
+ "payloadDefaults": {
298
+ "type": "object"
299
+ },
300
+ "payloadSchema": {
301
+ "type": "object"
302
+ },
303
+ "requiredRole": {
304
+ "type": "string"
305
+ }
306
+ },
307
+ "additionalProperties": false
308
+ },
309
+ "primaryModel": {
310
+ "type": "object",
311
+ "required": [
312
+ "kind",
313
+ "schemaVersion",
314
+ "state",
315
+ "operations"
316
+ ],
317
+ "properties": {
318
+ "kind": {
319
+ "const": "matterhorn.primary-model.schema"
320
+ },
321
+ "schemaVersion": {
322
+ "const": 1
323
+ },
324
+ "state": {
325
+ "type": "object"
326
+ },
327
+ "operations": {
328
+ "type": "object",
329
+ "additionalProperties": {
330
+ "type": "object",
331
+ "required": [
332
+ "payload",
333
+ "effects"
334
+ ],
335
+ "properties": {
336
+ "payload": {
337
+ "type": "object"
338
+ },
339
+ "authorize": {
340
+ "type": "object"
341
+ },
342
+ "guards": {
343
+ "type": "array",
344
+ "items": {
345
+ "$ref": "#/$defs/guard"
346
+ }
347
+ },
348
+ "effects": {
349
+ "type": "array",
350
+ "items": {
351
+ "$ref": "#/$defs/effect"
352
+ }
353
+ }
354
+ },
355
+ "additionalProperties": false
356
+ }
357
+ },
358
+ "views": {
359
+ "type": "object",
360
+ "additionalProperties": {
361
+ "type": "object"
362
+ }
363
+ },
364
+ "publicView": {
365
+ "type": "object"
366
+ },
367
+ "capabilities": {
368
+ "type": "object"
369
+ },
370
+ "shapes": {
371
+ "type": "object",
372
+ "additionalProperties": {
373
+ "type": "object",
374
+ "properties": {
375
+ "readClass": {
376
+ "enum": ["window", "head", "full-fold"]
377
+ },
378
+ "integrityClass": {
379
+ "enum": ["signature", "seq", "checkpoint"]
380
+ },
381
+ "storage": {
382
+ "enum": ["array", "map"]
383
+ },
384
+ "partition": {
385
+ "type": "string"
386
+ }
387
+ },
388
+ "additionalProperties": false
389
+ }
390
+ }
391
+ },
392
+ "additionalProperties": false
393
+ },
394
+ "effect": {
395
+ "type": "object",
396
+ "required": [
397
+ "kind"
398
+ ],
399
+ "properties": {
400
+ "kind": {
401
+ "enum": [
402
+ "noop",
403
+ "createRecord",
404
+ "upsertActorRecord",
405
+ "updateRecord",
406
+ "markRecord",
407
+ "mergePath",
408
+ "appendToArray",
409
+ "toggleReaction",
410
+ "insertIdIntoRecordArray",
411
+ "removeIdFromRecordArray"
412
+ ]
413
+ }
414
+ },
415
+ "additionalProperties": true
416
+ },
417
+ "guard": {
418
+ "type": "object",
419
+ "required": [
420
+ "kind"
421
+ ],
422
+ "properties": {
423
+ "kind": {
424
+ "enum": [
425
+ "noop",
426
+ "recordOwnerOrRole",
427
+ "recordFlagClear",
428
+ "eq",
429
+ "ne",
430
+ "lt",
431
+ "lte",
432
+ "gt",
433
+ "gte",
434
+ "exists",
435
+ "and",
436
+ "or",
437
+ "not"
438
+ ]
439
+ }
440
+ },
441
+ "additionalProperties": true
442
+ },
443
+ "notifications": {
444
+ "type": "object",
445
+ "required": [
446
+ "definitions"
447
+ ],
448
+ "properties": {
449
+ "schemaVersion": {
450
+ "type": "integer",
451
+ "minimum": 1
452
+ },
453
+ "definitions": {
454
+ "type": "object",
455
+ "additionalProperties": {
456
+ "$ref": "#/$defs/notification"
457
+ }
458
+ }
459
+ },
460
+ "additionalProperties": false
461
+ },
462
+ "notification": {
463
+ "type": "object",
464
+ "required": [
465
+ "on",
466
+ "kind",
467
+ "audience",
468
+ "scope",
469
+ "presentation",
470
+ "read"
471
+ ],
472
+ "properties": {
473
+ "on": {
474
+ "type": "object",
475
+ "required": [
476
+ "action"
477
+ ],
478
+ "properties": {
479
+ "action": {
480
+ "type": "string",
481
+ "minLength": 1
482
+ },
483
+ "plugin": {
484
+ "type": "string",
485
+ "minLength": 1
486
+ },
487
+ "type": {
488
+ "type": "string",
489
+ "minLength": 1
490
+ }
491
+ },
492
+ "additionalProperties": false
493
+ },
494
+ "kind": {
495
+ "type": "string",
496
+ "minLength": 1
497
+ },
498
+ "privacy": {
499
+ "enum": [
500
+ "encrypted",
501
+ "cleartext"
502
+ ]
503
+ },
504
+ "audience": {
505
+ "type": "object",
506
+ "required": [
507
+ "userIds"
508
+ ],
509
+ "properties": {
510
+ "userIds": {
511
+ "oneOf": [
512
+ {
513
+ "type": "string",
514
+ "minLength": 1
515
+ },
516
+ {
517
+ "type": "array",
518
+ "items": {
519
+ "type": "string",
520
+ "minLength": 1
521
+ }
522
+ }
523
+ ]
524
+ },
525
+ "excludeActor": {
526
+ "type": "boolean"
527
+ }
528
+ },
529
+ "additionalProperties": false
530
+ },
531
+ "scope": {
532
+ "type": "object",
533
+ "required": [
534
+ "type",
535
+ "id"
536
+ ],
537
+ "properties": {
538
+ "type": {
539
+ "type": "string",
540
+ "minLength": 1
541
+ },
542
+ "id": {
543
+ "type": "string",
544
+ "minLength": 1
545
+ }
546
+ },
547
+ "additionalProperties": false
548
+ },
549
+ "entity": {
550
+ "type": "object",
551
+ "required": [
552
+ "type",
553
+ "id"
554
+ ],
555
+ "properties": {
556
+ "type": {
557
+ "type": "string",
558
+ "minLength": 1
559
+ },
560
+ "id": {
561
+ "type": "string",
562
+ "minLength": 1
563
+ }
564
+ },
565
+ "additionalProperties": false
566
+ },
567
+ "presentation": {
568
+ "type": "object",
569
+ "properties": {
570
+ "title": {
571
+ "oneOf": [
572
+ {
573
+ "type": "string"
574
+ },
575
+ {
576
+ "type": "object",
577
+ "required": [
578
+ "$expr"
579
+ ],
580
+ "properties": {
581
+ "$expr": {
582
+ "type": "string",
583
+ "minLength": 1
584
+ },
585
+ "fallback": {
586
+ "type": "string"
587
+ }
588
+ },
589
+ "additionalProperties": false
590
+ }
591
+ ]
592
+ },
593
+ "body": {
594
+ "type": "string"
595
+ }
596
+ },
597
+ "additionalProperties": false
598
+ },
599
+ "link": {
600
+ "type": "object",
601
+ "required": [
602
+ "route"
603
+ ],
604
+ "properties": {
605
+ "route": {
606
+ "type": "string",
607
+ "minLength": 1
608
+ },
609
+ "params": {
610
+ "type": "object",
611
+ "additionalProperties": {
612
+ "type": "string"
613
+ }
614
+ }
615
+ },
616
+ "additionalProperties": false
617
+ },
618
+ "read": {
619
+ "type": "object",
620
+ "required": [
621
+ "scopeKey",
622
+ "cursor",
623
+ "defaultPolicy"
624
+ ],
625
+ "properties": {
626
+ "scopeKey": {
627
+ "type": "string",
628
+ "minLength": 1
629
+ },
630
+ "cursor": {
631
+ "type": "object",
632
+ "required": [
633
+ "createdAt",
634
+ "operationId"
635
+ ],
636
+ "properties": {
637
+ "createdAt": {
638
+ "type": "string",
639
+ "minLength": 1
640
+ },
641
+ "operationId": {
642
+ "type": "string",
643
+ "minLength": 1
644
+ }
645
+ },
646
+ "additionalProperties": false
647
+ },
648
+ "defaultPolicy": {
649
+ "enum": [
650
+ "player",
651
+ "click",
652
+ "route-visible",
653
+ "manual"
654
+ ]
655
+ }
656
+ },
657
+ "additionalProperties": false
658
+ },
659
+ "delivery": {
660
+ "type": "object",
661
+ "properties": {
662
+ "collapse": {
663
+ "enum": [
664
+ "scope",
665
+ "entity",
666
+ "none"
667
+ ]
668
+ },
669
+ "ttlSeconds": {
670
+ "type": "integer",
671
+ "minimum": 1
672
+ }
673
+ },
674
+ "additionalProperties": false
675
+ }
676
+ },
677
+ "additionalProperties": false
678
+ },
679
+ "notificationExpression": {
680
+ "type": "string",
681
+ "pattern": "^\\$[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$"
682
+ }
683
+ }
684
+ }