@rayfold/conformance 0.1.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.
@@ -0,0 +1,1199 @@
1
+ {
2
+ "name": "Streams (spec 04 s1)",
3
+ "schema": "\nentity Author { id: ID name: String bio: String? @lazy }\nentity Book @cache(maxAge: 60s, scope: public) {\n id: ID\n title: String\n stock: Int\n author: Author\n secret: String? @allow(read: viewer.role == \"admin\")\n reviews(page: PageArgs = { first: 10 }): Page<Review>\n version: Int @version\n}\ninput BookPatch { title: String? stock: Int? @range(min: 0) secret: String? }\nentity Review { id: ID rating: Int bookId: ID }\nentity Order @allow(read: viewer.id == customerId) { id: ID customerId: ID bookId: ID qty: Int }\nobject Tick { n: Int }\nview Book.default = { id title stock }\nquery book(id: ID): Book?\nquery books(page: PageArgs = { first: 20 }): Page<Book> @cost(base: 5, perItem: 1)\nquery author(id: ID): Author?\nquery order(id: ID): Order? @allow(read: viewer != null)\ncommand buy(bookId: ID, qty: Int = 1 @range(min: 1, max: 10)): Order throws OutOfStock { bookId: ID, available: Int } emits Bought @allow(write: viewer != null) @simulate\ncommand restock(bookId: ID, qty: Int): Book\ncommand patchBook(id: ID, patch: BookPatch): Book\nevent Bought { orderId: ID }\nstream ticks(n: Int): Tick\n",
4
+ "ir": {
5
+ "rayfold": "0.1",
6
+ "types": {
7
+ "ID": {
8
+ "kind": "scalar",
9
+ "name": "ID",
10
+ "annotations": [],
11
+ "builtin": true
12
+ },
13
+ "String": {
14
+ "kind": "scalar",
15
+ "name": "String",
16
+ "annotations": [],
17
+ "builtin": true
18
+ },
19
+ "Int": {
20
+ "kind": "scalar",
21
+ "name": "Int",
22
+ "annotations": [],
23
+ "builtin": true
24
+ },
25
+ "Long": {
26
+ "kind": "scalar",
27
+ "name": "Long",
28
+ "annotations": [],
29
+ "builtin": true
30
+ },
31
+ "Float": {
32
+ "kind": "scalar",
33
+ "name": "Float",
34
+ "annotations": [],
35
+ "builtin": true
36
+ },
37
+ "Boolean": {
38
+ "kind": "scalar",
39
+ "name": "Boolean",
40
+ "annotations": [],
41
+ "builtin": true
42
+ },
43
+ "Decimal": {
44
+ "kind": "scalar",
45
+ "name": "Decimal",
46
+ "annotations": [],
47
+ "builtin": true
48
+ },
49
+ "Instant": {
50
+ "kind": "scalar",
51
+ "name": "Instant",
52
+ "annotations": [],
53
+ "builtin": true
54
+ },
55
+ "Date": {
56
+ "kind": "scalar",
57
+ "name": "Date",
58
+ "annotations": [],
59
+ "builtin": true
60
+ },
61
+ "Duration": {
62
+ "kind": "scalar",
63
+ "name": "Duration",
64
+ "annotations": [],
65
+ "builtin": true
66
+ },
67
+ "Bytes": {
68
+ "kind": "scalar",
69
+ "name": "Bytes",
70
+ "annotations": [],
71
+ "builtin": true
72
+ },
73
+ "JSON": {
74
+ "kind": "scalar",
75
+ "name": "JSON",
76
+ "annotations": [],
77
+ "builtin": true
78
+ },
79
+ "Page": {
80
+ "kind": "object",
81
+ "name": "Page",
82
+ "builtin": true,
83
+ "typeParams": [
84
+ "T"
85
+ ],
86
+ "annotations": [],
87
+ "fields": [
88
+ {
89
+ "name": "items",
90
+ "type": {
91
+ "kind": "list",
92
+ "of": {
93
+ "kind": "named",
94
+ "name": "T",
95
+ "nullable": false
96
+ },
97
+ "nullable": false
98
+ },
99
+ "args": [],
100
+ "annotations": [],
101
+ "ordinal": 1
102
+ },
103
+ {
104
+ "name": "cursor",
105
+ "type": {
106
+ "kind": "named",
107
+ "name": "String",
108
+ "nullable": true
109
+ },
110
+ "args": [],
111
+ "annotations": [],
112
+ "ordinal": 2
113
+ },
114
+ {
115
+ "name": "hasMore",
116
+ "type": {
117
+ "kind": "named",
118
+ "name": "Boolean",
119
+ "nullable": false
120
+ },
121
+ "args": [],
122
+ "annotations": [],
123
+ "ordinal": 3
124
+ },
125
+ {
126
+ "name": "total",
127
+ "type": {
128
+ "kind": "named",
129
+ "name": "Int",
130
+ "nullable": true
131
+ },
132
+ "args": [],
133
+ "annotations": [],
134
+ "ordinal": 4
135
+ }
136
+ ]
137
+ },
138
+ "PageArgs": {
139
+ "kind": "input",
140
+ "name": "PageArgs",
141
+ "builtin": true,
142
+ "annotations": [],
143
+ "fields": [
144
+ {
145
+ "name": "first",
146
+ "type": {
147
+ "kind": "named",
148
+ "name": "Int",
149
+ "nullable": false
150
+ },
151
+ "args": [],
152
+ "default": 20,
153
+ "annotations": [],
154
+ "ordinal": 1
155
+ },
156
+ {
157
+ "name": "after",
158
+ "type": {
159
+ "kind": "named",
160
+ "name": "String",
161
+ "nullable": true
162
+ },
163
+ "args": [],
164
+ "annotations": [],
165
+ "ordinal": 2
166
+ },
167
+ {
168
+ "name": "offset",
169
+ "type": {
170
+ "kind": "named",
171
+ "name": "Int",
172
+ "nullable": true
173
+ },
174
+ "args": [],
175
+ "annotations": [],
176
+ "ordinal": 3
177
+ }
178
+ ]
179
+ },
180
+ "Author": {
181
+ "kind": "entity",
182
+ "name": "Author",
183
+ "annotations": [],
184
+ "fields": [
185
+ {
186
+ "name": "id",
187
+ "type": {
188
+ "kind": "named",
189
+ "name": "ID",
190
+ "nullable": false
191
+ },
192
+ "args": [],
193
+ "annotations": [],
194
+ "ordinal": 1
195
+ },
196
+ {
197
+ "name": "name",
198
+ "type": {
199
+ "kind": "named",
200
+ "name": "String",
201
+ "nullable": false
202
+ },
203
+ "args": [],
204
+ "annotations": [],
205
+ "ordinal": 2
206
+ },
207
+ {
208
+ "name": "bio",
209
+ "type": {
210
+ "kind": "named",
211
+ "name": "String",
212
+ "nullable": true
213
+ },
214
+ "args": [],
215
+ "annotations": [
216
+ {
217
+ "name": "lazy",
218
+ "args": {}
219
+ }
220
+ ],
221
+ "ordinal": 3
222
+ }
223
+ ],
224
+ "implements": []
225
+ },
226
+ "Book": {
227
+ "kind": "entity",
228
+ "name": "Book",
229
+ "annotations": [
230
+ {
231
+ "name": "cache",
232
+ "args": {
233
+ "maxAge": {
234
+ "$duration": 60000
235
+ },
236
+ "scope": {
237
+ "$ident": "public"
238
+ }
239
+ }
240
+ }
241
+ ],
242
+ "fields": [
243
+ {
244
+ "name": "id",
245
+ "type": {
246
+ "kind": "named",
247
+ "name": "ID",
248
+ "nullable": false
249
+ },
250
+ "args": [],
251
+ "annotations": [],
252
+ "ordinal": 1
253
+ },
254
+ {
255
+ "name": "title",
256
+ "type": {
257
+ "kind": "named",
258
+ "name": "String",
259
+ "nullable": false
260
+ },
261
+ "args": [],
262
+ "annotations": [],
263
+ "ordinal": 2
264
+ },
265
+ {
266
+ "name": "stock",
267
+ "type": {
268
+ "kind": "named",
269
+ "name": "Int",
270
+ "nullable": false
271
+ },
272
+ "args": [],
273
+ "annotations": [],
274
+ "ordinal": 3
275
+ },
276
+ {
277
+ "name": "author",
278
+ "type": {
279
+ "kind": "named",
280
+ "name": "Author",
281
+ "nullable": false
282
+ },
283
+ "args": [],
284
+ "annotations": [],
285
+ "ordinal": 4
286
+ },
287
+ {
288
+ "name": "secret",
289
+ "type": {
290
+ "kind": "named",
291
+ "name": "String",
292
+ "nullable": true
293
+ },
294
+ "args": [],
295
+ "annotations": [
296
+ {
297
+ "name": "allow",
298
+ "args": {
299
+ "read": {
300
+ "$expr": {
301
+ "k": "bin",
302
+ "op": "==",
303
+ "l": {
304
+ "k": "path",
305
+ "root": "viewer",
306
+ "path": [
307
+ "role"
308
+ ]
309
+ },
310
+ "r": {
311
+ "k": "lit",
312
+ "v": "admin"
313
+ }
314
+ }
315
+ }
316
+ }
317
+ }
318
+ ],
319
+ "ordinal": 5
320
+ },
321
+ {
322
+ "name": "reviews",
323
+ "type": {
324
+ "kind": "named",
325
+ "name": "Page",
326
+ "nullable": false,
327
+ "args": [
328
+ {
329
+ "kind": "named",
330
+ "name": "Review",
331
+ "nullable": false
332
+ }
333
+ ]
334
+ },
335
+ "args": [
336
+ {
337
+ "name": "page",
338
+ "type": {
339
+ "kind": "named",
340
+ "name": "PageArgs",
341
+ "nullable": false
342
+ },
343
+ "annotations": [],
344
+ "default": {
345
+ "first": 10
346
+ }
347
+ }
348
+ ],
349
+ "annotations": [],
350
+ "ordinal": 6
351
+ },
352
+ {
353
+ "name": "version",
354
+ "type": {
355
+ "kind": "named",
356
+ "name": "Int",
357
+ "nullable": false
358
+ },
359
+ "args": [],
360
+ "annotations": [
361
+ {
362
+ "name": "version",
363
+ "args": {}
364
+ }
365
+ ],
366
+ "ordinal": 7
367
+ }
368
+ ],
369
+ "implements": []
370
+ },
371
+ "BookPatch": {
372
+ "kind": "input",
373
+ "name": "BookPatch",
374
+ "annotations": [],
375
+ "fields": [
376
+ {
377
+ "name": "title",
378
+ "type": {
379
+ "kind": "named",
380
+ "name": "String",
381
+ "nullable": true
382
+ },
383
+ "args": [],
384
+ "annotations": [],
385
+ "ordinal": 1
386
+ },
387
+ {
388
+ "name": "stock",
389
+ "type": {
390
+ "kind": "named",
391
+ "name": "Int",
392
+ "nullable": true
393
+ },
394
+ "args": [],
395
+ "annotations": [
396
+ {
397
+ "name": "range",
398
+ "args": {
399
+ "min": 0
400
+ }
401
+ }
402
+ ],
403
+ "ordinal": 2
404
+ },
405
+ {
406
+ "name": "secret",
407
+ "type": {
408
+ "kind": "named",
409
+ "name": "String",
410
+ "nullable": true
411
+ },
412
+ "args": [],
413
+ "annotations": [],
414
+ "ordinal": 3
415
+ }
416
+ ]
417
+ },
418
+ "Review": {
419
+ "kind": "entity",
420
+ "name": "Review",
421
+ "annotations": [],
422
+ "fields": [
423
+ {
424
+ "name": "id",
425
+ "type": {
426
+ "kind": "named",
427
+ "name": "ID",
428
+ "nullable": false
429
+ },
430
+ "args": [],
431
+ "annotations": [],
432
+ "ordinal": 1
433
+ },
434
+ {
435
+ "name": "rating",
436
+ "type": {
437
+ "kind": "named",
438
+ "name": "Int",
439
+ "nullable": false
440
+ },
441
+ "args": [],
442
+ "annotations": [],
443
+ "ordinal": 2
444
+ },
445
+ {
446
+ "name": "bookId",
447
+ "type": {
448
+ "kind": "named",
449
+ "name": "ID",
450
+ "nullable": false
451
+ },
452
+ "args": [],
453
+ "annotations": [],
454
+ "ordinal": 3
455
+ }
456
+ ],
457
+ "implements": []
458
+ },
459
+ "Order": {
460
+ "kind": "entity",
461
+ "name": "Order",
462
+ "annotations": [
463
+ {
464
+ "name": "allow",
465
+ "args": {
466
+ "read": {
467
+ "$expr": {
468
+ "k": "bin",
469
+ "op": "==",
470
+ "l": {
471
+ "k": "path",
472
+ "root": "viewer",
473
+ "path": [
474
+ "id"
475
+ ]
476
+ },
477
+ "r": {
478
+ "k": "path",
479
+ "root": "this",
480
+ "path": [
481
+ "customerId"
482
+ ]
483
+ }
484
+ }
485
+ }
486
+ }
487
+ }
488
+ ],
489
+ "fields": [
490
+ {
491
+ "name": "id",
492
+ "type": {
493
+ "kind": "named",
494
+ "name": "ID",
495
+ "nullable": false
496
+ },
497
+ "args": [],
498
+ "annotations": [],
499
+ "ordinal": 1
500
+ },
501
+ {
502
+ "name": "customerId",
503
+ "type": {
504
+ "kind": "named",
505
+ "name": "ID",
506
+ "nullable": false
507
+ },
508
+ "args": [],
509
+ "annotations": [],
510
+ "ordinal": 2
511
+ },
512
+ {
513
+ "name": "bookId",
514
+ "type": {
515
+ "kind": "named",
516
+ "name": "ID",
517
+ "nullable": false
518
+ },
519
+ "args": [],
520
+ "annotations": [],
521
+ "ordinal": 3
522
+ },
523
+ {
524
+ "name": "qty",
525
+ "type": {
526
+ "kind": "named",
527
+ "name": "Int",
528
+ "nullable": false
529
+ },
530
+ "args": [],
531
+ "annotations": [],
532
+ "ordinal": 4
533
+ }
534
+ ],
535
+ "implements": []
536
+ },
537
+ "Tick": {
538
+ "kind": "object",
539
+ "name": "Tick",
540
+ "annotations": [],
541
+ "fields": [
542
+ {
543
+ "name": "n",
544
+ "type": {
545
+ "kind": "named",
546
+ "name": "Int",
547
+ "nullable": false
548
+ },
549
+ "args": [],
550
+ "annotations": [],
551
+ "ordinal": 1
552
+ }
553
+ ]
554
+ },
555
+ "OutOfStock": {
556
+ "kind": "error",
557
+ "name": "OutOfStock",
558
+ "annotations": [],
559
+ "fields": [
560
+ {
561
+ "name": "bookId",
562
+ "type": {
563
+ "kind": "named",
564
+ "name": "ID",
565
+ "nullable": false
566
+ },
567
+ "args": [],
568
+ "annotations": [],
569
+ "ordinal": 1
570
+ },
571
+ {
572
+ "name": "available",
573
+ "type": {
574
+ "kind": "named",
575
+ "name": "Int",
576
+ "nullable": false
577
+ },
578
+ "args": [],
579
+ "annotations": [],
580
+ "ordinal": 2
581
+ }
582
+ ]
583
+ },
584
+ "Bought": {
585
+ "kind": "event",
586
+ "name": "Bought",
587
+ "annotations": [],
588
+ "fields": [
589
+ {
590
+ "name": "orderId",
591
+ "type": {
592
+ "kind": "named",
593
+ "name": "ID",
594
+ "nullable": false
595
+ },
596
+ "args": [],
597
+ "annotations": [],
598
+ "ordinal": 1
599
+ }
600
+ ]
601
+ }
602
+ },
603
+ "ops": {
604
+ "book": {
605
+ "kind": "query",
606
+ "name": "book",
607
+ "args": [
608
+ {
609
+ "name": "id",
610
+ "type": {
611
+ "kind": "named",
612
+ "name": "ID",
613
+ "nullable": false
614
+ },
615
+ "annotations": []
616
+ }
617
+ ],
618
+ "returns": {
619
+ "kind": "named",
620
+ "name": "Book",
621
+ "nullable": true
622
+ },
623
+ "throws": [],
624
+ "emits": [],
625
+ "annotations": []
626
+ },
627
+ "books": {
628
+ "kind": "query",
629
+ "name": "books",
630
+ "args": [
631
+ {
632
+ "name": "page",
633
+ "type": {
634
+ "kind": "named",
635
+ "name": "PageArgs",
636
+ "nullable": false
637
+ },
638
+ "annotations": [],
639
+ "default": {
640
+ "first": 20
641
+ }
642
+ }
643
+ ],
644
+ "returns": {
645
+ "kind": "named",
646
+ "name": "Page",
647
+ "nullable": false,
648
+ "args": [
649
+ {
650
+ "kind": "named",
651
+ "name": "Book",
652
+ "nullable": false
653
+ }
654
+ ]
655
+ },
656
+ "throws": [],
657
+ "emits": [],
658
+ "annotations": [
659
+ {
660
+ "name": "cost",
661
+ "args": {
662
+ "base": 5,
663
+ "perItem": 1
664
+ }
665
+ }
666
+ ]
667
+ },
668
+ "author": {
669
+ "kind": "query",
670
+ "name": "author",
671
+ "args": [
672
+ {
673
+ "name": "id",
674
+ "type": {
675
+ "kind": "named",
676
+ "name": "ID",
677
+ "nullable": false
678
+ },
679
+ "annotations": []
680
+ }
681
+ ],
682
+ "returns": {
683
+ "kind": "named",
684
+ "name": "Author",
685
+ "nullable": true
686
+ },
687
+ "throws": [],
688
+ "emits": [],
689
+ "annotations": []
690
+ },
691
+ "order": {
692
+ "kind": "query",
693
+ "name": "order",
694
+ "args": [
695
+ {
696
+ "name": "id",
697
+ "type": {
698
+ "kind": "named",
699
+ "name": "ID",
700
+ "nullable": false
701
+ },
702
+ "annotations": []
703
+ }
704
+ ],
705
+ "returns": {
706
+ "kind": "named",
707
+ "name": "Order",
708
+ "nullable": true
709
+ },
710
+ "throws": [],
711
+ "emits": [],
712
+ "annotations": [
713
+ {
714
+ "name": "allow",
715
+ "args": {
716
+ "read": {
717
+ "$expr": {
718
+ "k": "bin",
719
+ "op": "!=",
720
+ "l": {
721
+ "k": "path",
722
+ "root": "viewer",
723
+ "path": []
724
+ },
725
+ "r": {
726
+ "k": "lit",
727
+ "v": null
728
+ }
729
+ }
730
+ }
731
+ }
732
+ }
733
+ ]
734
+ },
735
+ "buy": {
736
+ "kind": "command",
737
+ "name": "buy",
738
+ "args": [
739
+ {
740
+ "name": "bookId",
741
+ "type": {
742
+ "kind": "named",
743
+ "name": "ID",
744
+ "nullable": false
745
+ },
746
+ "annotations": []
747
+ },
748
+ {
749
+ "name": "qty",
750
+ "type": {
751
+ "kind": "named",
752
+ "name": "Int",
753
+ "nullable": false
754
+ },
755
+ "annotations": [
756
+ {
757
+ "name": "range",
758
+ "args": {
759
+ "min": 1,
760
+ "max": 10
761
+ }
762
+ }
763
+ ],
764
+ "default": 1
765
+ }
766
+ ],
767
+ "returns": {
768
+ "kind": "named",
769
+ "name": "Order",
770
+ "nullable": false
771
+ },
772
+ "throws": [
773
+ "OutOfStock"
774
+ ],
775
+ "emits": [
776
+ "Bought"
777
+ ],
778
+ "annotations": [
779
+ {
780
+ "name": "allow",
781
+ "args": {
782
+ "write": {
783
+ "$expr": {
784
+ "k": "bin",
785
+ "op": "!=",
786
+ "l": {
787
+ "k": "path",
788
+ "root": "viewer",
789
+ "path": []
790
+ },
791
+ "r": {
792
+ "k": "lit",
793
+ "v": null
794
+ }
795
+ }
796
+ }
797
+ }
798
+ },
799
+ {
800
+ "name": "simulate",
801
+ "args": {}
802
+ }
803
+ ]
804
+ },
805
+ "restock": {
806
+ "kind": "command",
807
+ "name": "restock",
808
+ "args": [
809
+ {
810
+ "name": "bookId",
811
+ "type": {
812
+ "kind": "named",
813
+ "name": "ID",
814
+ "nullable": false
815
+ },
816
+ "annotations": []
817
+ },
818
+ {
819
+ "name": "qty",
820
+ "type": {
821
+ "kind": "named",
822
+ "name": "Int",
823
+ "nullable": false
824
+ },
825
+ "annotations": []
826
+ }
827
+ ],
828
+ "returns": {
829
+ "kind": "named",
830
+ "name": "Book",
831
+ "nullable": false
832
+ },
833
+ "throws": [],
834
+ "emits": [],
835
+ "annotations": []
836
+ },
837
+ "patchBook": {
838
+ "kind": "command",
839
+ "name": "patchBook",
840
+ "args": [
841
+ {
842
+ "name": "id",
843
+ "type": {
844
+ "kind": "named",
845
+ "name": "ID",
846
+ "nullable": false
847
+ },
848
+ "annotations": []
849
+ },
850
+ {
851
+ "name": "patch",
852
+ "type": {
853
+ "kind": "named",
854
+ "name": "BookPatch",
855
+ "nullable": false
856
+ },
857
+ "annotations": []
858
+ }
859
+ ],
860
+ "returns": {
861
+ "kind": "named",
862
+ "name": "Book",
863
+ "nullable": false
864
+ },
865
+ "throws": [],
866
+ "emits": [],
867
+ "annotations": []
868
+ },
869
+ "ticks": {
870
+ "kind": "stream",
871
+ "name": "ticks",
872
+ "args": [
873
+ {
874
+ "name": "n",
875
+ "type": {
876
+ "kind": "named",
877
+ "name": "Int",
878
+ "nullable": false
879
+ },
880
+ "annotations": []
881
+ }
882
+ ],
883
+ "returns": {
884
+ "kind": "named",
885
+ "name": "Tick",
886
+ "nullable": false
887
+ },
888
+ "throws": [],
889
+ "emits": [],
890
+ "annotations": []
891
+ }
892
+ },
893
+ "views": {
894
+ "Book.default": {
895
+ "type": "Book",
896
+ "name": "default",
897
+ "shape": {
898
+ "items": [
899
+ {
900
+ "kind": "field",
901
+ "name": "id"
902
+ },
903
+ {
904
+ "kind": "field",
905
+ "name": "title"
906
+ },
907
+ {
908
+ "kind": "field",
909
+ "name": "stock"
910
+ }
911
+ ]
912
+ }
913
+ }
914
+ }
915
+ },
916
+ "data": {
917
+ "Author": [
918
+ {
919
+ "id": "a1",
920
+ "name": "Ann",
921
+ "bio": "Writes."
922
+ },
923
+ {
924
+ "id": "a2",
925
+ "name": "Bob",
926
+ "bio": null
927
+ }
928
+ ],
929
+ "Book": [
930
+ {
931
+ "id": "b1",
932
+ "title": "T1",
933
+ "stock": 2,
934
+ "authorId": "a1",
935
+ "secret": "s1",
936
+ "version": 1
937
+ },
938
+ {
939
+ "id": "b2",
940
+ "title": "T2",
941
+ "stock": 0,
942
+ "authorId": "a2",
943
+ "secret": "s2",
944
+ "version": 1
945
+ }
946
+ ],
947
+ "Review": [
948
+ {
949
+ "id": "r1",
950
+ "rating": 5,
951
+ "bookId": "b1"
952
+ },
953
+ {
954
+ "id": "r2",
955
+ "rating": 3,
956
+ "bookId": "b1"
957
+ },
958
+ {
959
+ "id": "r3",
960
+ "rating": 4,
961
+ "bookId": "b2"
962
+ }
963
+ ],
964
+ "Order": [
965
+ {
966
+ "id": "o0",
967
+ "customerId": "u1",
968
+ "bookId": "b1",
969
+ "qty": 1
970
+ }
971
+ ]
972
+ },
973
+ "resolvers": {
974
+ "Query": {
975
+ "book": {
976
+ "from": "Book",
977
+ "where": {
978
+ "id": "$args.id"
979
+ },
980
+ "mode": "one"
981
+ },
982
+ "books": {
983
+ "from": "Book",
984
+ "mode": "page"
985
+ },
986
+ "author": {
987
+ "from": "Author",
988
+ "where": {
989
+ "id": "$args.id"
990
+ },
991
+ "mode": "one"
992
+ },
993
+ "order": {
994
+ "from": "Order",
995
+ "where": {
996
+ "id": "$args.id"
997
+ },
998
+ "mode": "one"
999
+ }
1000
+ },
1001
+ "fields": {
1002
+ "Book": {
1003
+ "author": {
1004
+ "from": "Author",
1005
+ "key": "authorId",
1006
+ "match": "id",
1007
+ "mode": "one"
1008
+ },
1009
+ "reviews": {
1010
+ "from": "Review",
1011
+ "key": "id",
1012
+ "match": "bookId",
1013
+ "mode": "page"
1014
+ }
1015
+ }
1016
+ },
1017
+ "Command": {
1018
+ "buy": {
1019
+ "fail": [
1020
+ {
1021
+ "when": {
1022
+ "from": "Book",
1023
+ "where": {
1024
+ "id": "$args.bookId"
1025
+ },
1026
+ "field": "stock",
1027
+ "op": "lt",
1028
+ "value": "$args.qty"
1029
+ },
1030
+ "type": "OutOfStock",
1031
+ "data": {
1032
+ "bookId": "$args.bookId",
1033
+ "available": "$row.stock"
1034
+ },
1035
+ "message": "Out of stock"
1036
+ }
1037
+ ],
1038
+ "update": {
1039
+ "table": "Book",
1040
+ "where": {
1041
+ "id": "$args.bookId"
1042
+ },
1043
+ "set": {
1044
+ "stock": {
1045
+ "$sub": "$args.qty"
1046
+ }
1047
+ }
1048
+ },
1049
+ "insert": {
1050
+ "into": "Order",
1051
+ "row": {
1052
+ "customerId": "$viewer.id",
1053
+ "bookId": "$args.bookId",
1054
+ "qty": "$args.qty"
1055
+ },
1056
+ "idPrefix": "o"
1057
+ },
1058
+ "returns": "inserted",
1059
+ "patch": [
1060
+ {
1061
+ "invOp": [
1062
+ "books"
1063
+ ]
1064
+ }
1065
+ ],
1066
+ "emit": [
1067
+ {
1068
+ "event": "Bought",
1069
+ "payload": {
1070
+ "orderId": "$row.id"
1071
+ }
1072
+ }
1073
+ ]
1074
+ },
1075
+ "restock": {
1076
+ "update": {
1077
+ "table": "Book",
1078
+ "where": {
1079
+ "id": "$args.bookId"
1080
+ },
1081
+ "set": {
1082
+ "stock": {
1083
+ "$add": "$args.qty"
1084
+ }
1085
+ }
1086
+ },
1087
+ "returns": "updated"
1088
+ },
1089
+ "patchBook": {
1090
+ "update": {
1091
+ "table": "Book",
1092
+ "where": {
1093
+ "id": "$args.id"
1094
+ },
1095
+ "merge": "$args.patch",
1096
+ "version": "version"
1097
+ },
1098
+ "returns": "updated"
1099
+ }
1100
+ },
1101
+ "Stream": {
1102
+ "ticks": {
1103
+ "items": [
1104
+ {
1105
+ "n": 1
1106
+ },
1107
+ {
1108
+ "n": 2
1109
+ }
1110
+ ]
1111
+ }
1112
+ }
1113
+ },
1114
+ "cases": [
1115
+ {
1116
+ "name": "items are projected through the shape and the stream ends with fin",
1117
+ "request": {
1118
+ "ops": [
1119
+ {
1120
+ "id": 1,
1121
+ "op": "ticks",
1122
+ "args": {
1123
+ "n": 2
1124
+ }
1125
+ }
1126
+ ]
1127
+ },
1128
+ "frames": [
1129
+ {
1130
+ "id": 1,
1131
+ "item": {
1132
+ "n": 1
1133
+ }
1134
+ },
1135
+ {
1136
+ "id": 1,
1137
+ "item": {
1138
+ "n": 2
1139
+ }
1140
+ },
1141
+ {
1142
+ "id": 1,
1143
+ "fin": true
1144
+ }
1145
+ ]
1146
+ },
1147
+ {
1148
+ "name": "a stream may run alongside a query in one batch",
1149
+ "request": {
1150
+ "ops": [
1151
+ {
1152
+ "id": 1,
1153
+ "op": "ticks",
1154
+ "args": {
1155
+ "n": 2
1156
+ }
1157
+ },
1158
+ {
1159
+ "id": 2,
1160
+ "op": "book",
1161
+ "args": {
1162
+ "id": "b1"
1163
+ },
1164
+ "shape": "{ id }"
1165
+ }
1166
+ ]
1167
+ },
1168
+ "frames": [
1169
+ {
1170
+ "id": 1,
1171
+ "item": {
1172
+ "n": 1
1173
+ }
1174
+ },
1175
+ {
1176
+ "id": 1,
1177
+ "item": {
1178
+ "n": 2
1179
+ }
1180
+ },
1181
+ {
1182
+ "id": 1,
1183
+ "fin": true
1184
+ },
1185
+ {
1186
+ "id": 2,
1187
+ "data": {
1188
+ "$type": "Book",
1189
+ "id": "b1"
1190
+ },
1191
+ "meta": {
1192
+ "cost": 1
1193
+ },
1194
+ "fin": true
1195
+ }
1196
+ ]
1197
+ }
1198
+ ]
1199
+ }