@auto-engineer/server-generator-apollo-emmett 0.13.0 → 0.13.1

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 (92) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +8 -0
  3. package/dist/src/codegen/extract/commands.d.ts +7 -14
  4. package/dist/src/codegen/extract/commands.d.ts.map +1 -1
  5. package/dist/src/codegen/extract/commands.js.map +1 -1
  6. package/dist/src/codegen/extract/data-sink.d.ts +1 -1
  7. package/dist/src/codegen/extract/data-sink.d.ts.map +1 -1
  8. package/dist/src/codegen/extract/data-sink.js +9 -31
  9. package/dist/src/codegen/extract/data-sink.js.map +1 -1
  10. package/dist/src/codegen/extract/events.d.ts +4 -8
  11. package/dist/src/codegen/extract/events.d.ts.map +1 -1
  12. package/dist/src/codegen/extract/events.js.map +1 -1
  13. package/dist/src/codegen/extract/gwt.d.ts +2 -2
  14. package/dist/src/codegen/extract/gwt.d.ts.map +1 -1
  15. package/dist/src/codegen/extract/gwt.js +6 -21
  16. package/dist/src/codegen/extract/gwt.js.map +1 -1
  17. package/dist/src/codegen/extract/messages.d.ts +4 -4
  18. package/dist/src/codegen/extract/messages.d.ts.map +1 -1
  19. package/dist/src/codegen/extract/messages.js +24 -47
  20. package/dist/src/codegen/extract/messages.js.map +1 -1
  21. package/dist/src/codegen/extract/query.d.ts +5 -7
  22. package/dist/src/codegen/extract/query.d.ts.map +1 -1
  23. package/dist/src/codegen/extract/query.js +10 -8
  24. package/dist/src/codegen/extract/query.js.map +1 -1
  25. package/dist/src/codegen/extract/slice-normalizer.d.ts +29 -0
  26. package/dist/src/codegen/extract/slice-normalizer.d.ts.map +1 -0
  27. package/dist/src/codegen/extract/slice-normalizer.js +48 -0
  28. package/dist/src/codegen/extract/slice-normalizer.js.map +1 -0
  29. package/dist/src/codegen/extract/step-converter.d.ts +17 -0
  30. package/dist/src/codegen/extract/step-converter.d.ts.map +1 -0
  31. package/dist/src/codegen/extract/step-converter.js +82 -0
  32. package/dist/src/codegen/extract/step-converter.js.map +1 -0
  33. package/dist/src/codegen/extract/step-types.d.ts +30 -0
  34. package/dist/src/codegen/extract/step-types.d.ts.map +1 -0
  35. package/dist/src/codegen/extract/step-types.js +16 -0
  36. package/dist/src/codegen/extract/step-types.js.map +1 -0
  37. package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
  38. package/dist/src/codegen/scaffoldFromSchema.js +7 -29
  39. package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
  40. package/dist/src/codegen/templates/command/commands.specs.ts +33 -28
  41. package/dist/src/codegen/templates/command/decide.specs.specs.ts +153 -138
  42. package/dist/src/codegen/templates/command/decide.specs.ts +169 -146
  43. package/dist/src/codegen/templates/command/events.specs.ts +43 -38
  44. package/dist/src/codegen/templates/command/evolve.specs.ts +38 -33
  45. package/dist/src/codegen/templates/command/handle.specs.ts +71 -61
  46. package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +122 -102
  47. package/dist/src/codegen/templates/command/register.specs.ts +39 -34
  48. package/dist/src/codegen/templates/command/state.specs.ts +39 -34
  49. package/dist/src/codegen/templates/query/projection.specs.specs.ts +399 -359
  50. package/dist/src/codegen/templates/query/projection.specs.ts +242 -216
  51. package/dist/src/codegen/templates/query/projection.specs.ts.ejs +38 -12
  52. package/dist/src/codegen/templates/query/query.resolver.specs.ts +59 -51
  53. package/dist/src/codegen/templates/query/state.specs.ts +1 -1
  54. package/dist/src/codegen/templates/react/react.specs.specs.ts +93 -85
  55. package/dist/src/codegen/templates/react/react.specs.ts +135 -122
  56. package/dist/src/codegen/templates/react/register.specs.ts +135 -122
  57. package/dist/src/codegen/test-data/specVariant1.d.ts.map +1 -1
  58. package/dist/src/codegen/test-data/specVariant1.js +101 -90
  59. package/dist/src/codegen/test-data/specVariant1.js.map +1 -1
  60. package/dist/src/codegen/types.d.ts +5 -7
  61. package/dist/src/codegen/types.d.ts.map +1 -1
  62. package/dist/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +4 -4
  64. package/src/codegen/extract/commands.ts +7 -8
  65. package/src/codegen/extract/data-sink.ts +16 -43
  66. package/src/codegen/extract/events.ts +4 -5
  67. package/src/codegen/extract/gwt.ts +12 -29
  68. package/src/codegen/extract/messages.ts +43 -70
  69. package/src/codegen/extract/query.ts +14 -12
  70. package/src/codegen/extract/slice-normalizer.ts +88 -0
  71. package/src/codegen/extract/step-converter.ts +124 -0
  72. package/src/codegen/extract/step-types.ts +52 -0
  73. package/src/codegen/scaffoldFromSchema.ts +8 -45
  74. package/src/codegen/templates/command/commands.specs.ts +33 -28
  75. package/src/codegen/templates/command/decide.specs.specs.ts +153 -138
  76. package/src/codegen/templates/command/decide.specs.ts +169 -146
  77. package/src/codegen/templates/command/events.specs.ts +43 -38
  78. package/src/codegen/templates/command/evolve.specs.ts +38 -33
  79. package/src/codegen/templates/command/handle.specs.ts +71 -61
  80. package/src/codegen/templates/command/mutation.resolver.specs.ts +122 -102
  81. package/src/codegen/templates/command/register.specs.ts +39 -34
  82. package/src/codegen/templates/command/state.specs.ts +39 -34
  83. package/src/codegen/templates/query/projection.specs.specs.ts +399 -359
  84. package/src/codegen/templates/query/projection.specs.ts +242 -216
  85. package/src/codegen/templates/query/projection.specs.ts.ejs +38 -12
  86. package/src/codegen/templates/query/query.resolver.specs.ts +59 -51
  87. package/src/codegen/templates/query/state.specs.ts +1 -1
  88. package/src/codegen/templates/react/react.specs.specs.ts +93 -85
  89. package/src/codegen/templates/react/react.specs.ts +135 -122
  90. package/src/codegen/templates/react/register.specs.ts +135 -122
  91. package/src/codegen/test-data/specVariant1.ts +101 -90
  92. package/src/codegen/types.ts +6 -4
@@ -19,56 +19,63 @@ describe('projection.ts.ejs', () => {
19
19
  },
20
20
  server: {
21
21
  description: 'handles create/remove listing',
22
- specs: {
23
- name: 'Create/remove listing command',
24
- rules: [
25
- {
26
- description: 'Should handle listing operations',
27
- examples: [
28
- {
29
- description: 'User creates listing successfully',
30
- when: {
31
- commandRef: 'CreateListing',
32
- exampleData: {
33
- propertyId: 'listing_123',
34
- title: 'Sea View Flat',
35
- pricePerNight: 120,
36
- location: 'Brighton',
37
- maxGuests: 4,
38
- },
22
+ specs: [
23
+ {
24
+ type: 'gherkin',
25
+ feature: 'Create/remove listing command',
26
+ rules: [
27
+ {
28
+ name: 'Should handle listing operations',
29
+ examples: [
30
+ {
31
+ name: 'User creates listing successfully',
32
+ steps: [
33
+ {
34
+ keyword: 'When',
35
+ text: 'CreateListing',
36
+ docString: {
37
+ propertyId: 'listing_123',
38
+ title: 'Sea View Flat',
39
+ pricePerNight: 120,
40
+ location: 'Brighton',
41
+ maxGuests: 4,
42
+ },
43
+ },
44
+ {
45
+ keyword: 'Then',
46
+ text: 'ListingCreated',
47
+ docString: {
48
+ propertyId: 'listing_123',
49
+ title: 'Sea View Flat',
50
+ pricePerNight: 120,
51
+ location: 'Brighton',
52
+ maxGuests: 4,
53
+ },
54
+ },
55
+ ],
39
56
  },
40
- then: [
41
- {
42
- eventRef: 'ListingCreated',
43
- exampleData: {
44
- propertyId: 'listing_123',
45
- title: 'Sea View Flat',
46
- pricePerNight: 120,
47
- location: 'Brighton',
48
- maxGuests: 4,
57
+ {
58
+ name: 'User removes listing successfully',
59
+ steps: [
60
+ {
61
+ keyword: 'When',
62
+ text: 'RemoveListing',
63
+ docString: {
64
+ propertyId: 'listing_123',
65
+ },
49
66
  },
50
- },
51
- ],
52
- },
53
- {
54
- description: 'User removes listing successfully',
55
- when: {
56
- commandRef: 'RemoveListing',
57
- exampleData: {
58
- propertyId: 'listing_123',
59
- },
67
+ {
68
+ keyword: 'Then',
69
+ text: 'ListingRemoved',
70
+ docString: {},
71
+ },
72
+ ],
60
73
  },
61
- then: [
62
- {
63
- eventRef: 'ListingRemoved',
64
- exampleData: {},
65
- },
66
- ],
67
- },
68
- ],
69
- },
70
- ],
71
- },
74
+ ],
75
+ },
76
+ ],
77
+ },
78
+ ],
72
79
  },
73
80
  },
74
81
  {
@@ -93,60 +100,63 @@ describe('projection.ts.ejs', () => {
93
100
  },
94
101
  },
95
102
  ],
96
- specs: {
97
- name: 'Search listings query',
98
- rules: [
99
- {
100
- description: 'Should project listings correctly',
101
- examples: [
102
- {
103
- description: 'Listing created shows in search results',
104
- when: [
105
- {
106
- eventRef: 'ListingCreated',
107
- exampleData: {
108
- propertyId: 'listing_123',
109
- title: 'Sea View Flat',
110
- pricePerNight: 120,
111
- location: 'Brighton',
112
- maxGuests: 4,
103
+ specs: [
104
+ {
105
+ type: 'gherkin',
106
+ feature: 'Search listings query',
107
+ rules: [
108
+ {
109
+ name: 'Should project listings correctly',
110
+ examples: [
111
+ {
112
+ name: 'Listing created shows in search results',
113
+ steps: [
114
+ {
115
+ keyword: 'When',
116
+ text: 'ListingCreated',
117
+ docString: {
118
+ propertyId: 'listing_123',
119
+ title: 'Sea View Flat',
120
+ pricePerNight: 120,
121
+ location: 'Brighton',
122
+ maxGuests: 4,
123
+ },
113
124
  },
114
- },
115
- ],
116
- then: [
117
- {
118
- stateRef: 'AvailableListings',
119
- exampleData: {
120
- propertyId: 'listing_123',
121
- title: 'Sea View Flat',
122
- pricePerNight: 120,
123
- location: 'Brighton',
124
- maxGuests: 4,
125
+ {
126
+ keyword: 'Then',
127
+ text: 'AvailableListings',
128
+ docString: {
129
+ propertyId: 'listing_123',
130
+ title: 'Sea View Flat',
131
+ pricePerNight: 120,
132
+ location: 'Brighton',
133
+ maxGuests: 4,
134
+ },
125
135
  },
126
- },
127
- ],
128
- },
129
- {
130
- description: 'Listing removed disappears from search results',
131
- when: [
132
- {
133
- eventRef: 'ListingRemoved',
134
- exampleData: {
135
- propertyId: 'listing_123',
136
+ ],
137
+ },
138
+ {
139
+ name: 'Listing removed disappears from search results',
140
+ steps: [
141
+ {
142
+ keyword: 'When',
143
+ text: 'ListingRemoved',
144
+ docString: {
145
+ propertyId: 'listing_123',
146
+ },
136
147
  },
137
- },
138
- ],
139
- then: [
140
- {
141
- stateRef: 'AvailableListings',
142
- exampleData: {},
143
- },
144
- ],
145
- },
146
- ],
147
- },
148
- ],
149
- },
148
+ {
149
+ keyword: 'Then',
150
+ text: 'AvailableListings',
151
+ docString: {},
152
+ },
153
+ ],
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ },
159
+ ],
150
160
  },
151
161
  },
152
162
  ],
@@ -312,7 +322,7 @@ describe('projection.ts.ejs', () => {
312
322
  },
313
323
  },
314
324
  ],
315
- specs: { name: '', rules: [] },
325
+ specs: [],
316
326
  },
317
327
  },
318
328
  ],
@@ -395,35 +405,40 @@ describe('projection.ts.ejs', () => {
395
405
  },
396
406
  server: {
397
407
  description: 'handles todo operations',
398
- specs: {
399
- name: 'Manage todo command',
400
- rules: [
401
- {
402
- description: 'Should handle todo operations',
403
- examples: [
404
- {
405
- description: 'User adds todo',
406
- when: {
407
- commandRef: 'AddTodo',
408
- exampleData: {
409
- todoId: 'todo_123',
410
- title: 'Buy milk',
411
- },
412
- },
413
- then: [
414
- {
415
- eventRef: 'TodoAdded',
416
- exampleData: {
417
- todoId: 'todo_123',
418
- title: 'Buy milk',
408
+ specs: [
409
+ {
410
+ type: 'gherkin',
411
+ feature: 'Manage todo command',
412
+ rules: [
413
+ {
414
+ name: 'Should handle todo operations',
415
+ examples: [
416
+ {
417
+ name: 'User adds todo',
418
+ steps: [
419
+ {
420
+ keyword: 'When',
421
+ text: 'AddTodo',
422
+ docString: {
423
+ todoId: 'todo_123',
424
+ title: 'Buy milk',
425
+ },
419
426
  },
420
- },
421
- ],
422
- },
423
- ],
424
- },
425
- ],
426
- },
427
+ {
428
+ keyword: 'Then',
429
+ text: 'TodoAdded',
430
+ docString: {
431
+ todoId: 'todo_123',
432
+ title: 'Buy milk',
433
+ },
434
+ },
435
+ ],
436
+ },
437
+ ],
438
+ },
439
+ ],
440
+ },
441
+ ],
427
442
  },
428
443
  },
429
444
  {
@@ -448,36 +463,39 @@ describe('projection.ts.ejs', () => {
448
463
  },
449
464
  },
450
465
  ],
451
- specs: {
452
- name: 'View summary query',
453
- rules: [
454
- {
455
- description: 'Should aggregate todo counts',
456
- examples: [
457
- {
458
- description: 'Todo added updates count',
459
- when: [
460
- {
461
- eventRef: 'TodoAdded',
462
- exampleData: {
463
- todoId: 'todo_123',
464
- title: 'Buy milk',
466
+ specs: [
467
+ {
468
+ type: 'gherkin',
469
+ feature: 'View summary query',
470
+ rules: [
471
+ {
472
+ name: 'Should aggregate todo counts',
473
+ examples: [
474
+ {
475
+ name: 'Todo added updates count',
476
+ steps: [
477
+ {
478
+ keyword: 'When',
479
+ text: 'TodoAdded',
480
+ docString: {
481
+ todoId: 'todo_123',
482
+ title: 'Buy milk',
483
+ },
465
484
  },
466
- },
467
- ],
468
- then: [
469
- {
470
- stateRef: 'TodoSummary',
471
- exampleData: {
472
- totalCount: 1,
485
+ {
486
+ keyword: 'Then',
487
+ text: 'TodoSummary',
488
+ docString: {
489
+ totalCount: 1,
490
+ },
473
491
  },
474
- },
475
- ],
476
- },
477
- ],
478
- },
479
- ],
480
- },
492
+ ],
493
+ },
494
+ ],
495
+ },
496
+ ],
497
+ },
498
+ ],
481
499
  },
482
500
  },
483
501
  ],
@@ -600,37 +618,42 @@ describe('projection.ts.ejs', () => {
600
618
  },
601
619
  server: {
602
620
  description: 'handles user project operations',
603
- specs: {
604
- name: 'Manage user project command',
605
- rules: [
606
- {
607
- description: 'Should handle user project operations',
608
- examples: [
609
- {
610
- description: 'User joins project',
611
- when: {
612
- commandRef: 'JoinProject',
613
- exampleData: {
614
- userId: 'user_123',
615
- projectId: 'proj_456',
616
- role: 'developer',
617
- },
618
- },
619
- then: [
620
- {
621
- eventRef: 'UserJoinedProject',
622
- exampleData: {
623
- userId: 'user_123',
624
- projectId: 'proj_456',
625
- role: 'developer',
621
+ specs: [
622
+ {
623
+ type: 'gherkin',
624
+ feature: 'Manage user project command',
625
+ rules: [
626
+ {
627
+ name: 'Should handle user project operations',
628
+ examples: [
629
+ {
630
+ name: 'User joins project',
631
+ steps: [
632
+ {
633
+ keyword: 'When',
634
+ text: 'JoinProject',
635
+ docString: {
636
+ userId: 'user_123',
637
+ projectId: 'proj_456',
638
+ role: 'developer',
639
+ },
626
640
  },
627
- },
628
- ],
629
- },
630
- ],
631
- },
632
- ],
633
- },
641
+ {
642
+ keyword: 'Then',
643
+ text: 'UserJoinedProject',
644
+ docString: {
645
+ userId: 'user_123',
646
+ projectId: 'proj_456',
647
+ role: 'developer',
648
+ },
649
+ },
650
+ ],
651
+ },
652
+ ],
653
+ },
654
+ ],
655
+ },
656
+ ],
634
657
  },
635
658
  },
636
659
  {
@@ -655,39 +678,42 @@ describe('projection.ts.ejs', () => {
655
678
  },
656
679
  },
657
680
  ],
658
- specs: {
659
- name: 'View user projects query',
660
- rules: [
661
- {
662
- description: 'Should track user project memberships',
663
- examples: [
664
- {
665
- description: 'User joins project',
666
- when: [
667
- {
668
- eventRef: 'UserJoinedProject',
669
- exampleData: {
670
- userId: 'user_123',
671
- projectId: 'proj_456',
672
- role: 'developer',
681
+ specs: [
682
+ {
683
+ type: 'gherkin',
684
+ feature: 'View user projects query',
685
+ rules: [
686
+ {
687
+ name: 'Should track user project memberships',
688
+ examples: [
689
+ {
690
+ name: 'User joins project',
691
+ steps: [
692
+ {
693
+ keyword: 'When',
694
+ text: 'UserJoinedProject',
695
+ docString: {
696
+ userId: 'user_123',
697
+ projectId: 'proj_456',
698
+ role: 'developer',
699
+ },
673
700
  },
674
- },
675
- ],
676
- then: [
677
- {
678
- stateRef: 'UserProject',
679
- exampleData: {
680
- userId: 'user_123',
681
- projectId: 'proj_456',
682
- role: 'developer',
701
+ {
702
+ keyword: 'Then',
703
+ text: 'UserProject',
704
+ docString: {
705
+ userId: 'user_123',
706
+ projectId: 'proj_456',
707
+ role: 'developer',
708
+ },
683
709
  },
684
- },
685
- ],
686
- },
687
- ],
688
- },
689
- ],
690
- },
710
+ ],
711
+ },
712
+ ],
713
+ },
714
+ ],
715
+ },
716
+ ],
691
717
  },
692
718
  },
693
719
  ],
@@ -6,20 +6,46 @@ const idField = projectionIdField ?? 'id';
6
6
  const uniqueEventTypes = allEventTypesArray;
7
7
 
8
8
  const ruleGroups = new Map();
9
- const rules = slice?.server?.specs?.rules || [];
10
- for (const rule of rules) {
11
- const ruleDescription = rule.description || `${flowName} | ${sliceName}`;
12
- if (!ruleGroups.has(ruleDescription)) {
13
- ruleGroups.set(ruleDescription, []);
9
+
10
+ if (Array.isArray(slice?.server?.specs)) {
11
+ for (const spec of slice.server.specs) {
12
+ const rules = spec.rules || [];
13
+ for (const rule of rules) {
14
+ const ruleDescription = rule.name || `${flowName} | ${sliceName}`;
15
+ if (!ruleGroups.has(ruleDescription)) {
16
+ ruleGroups.set(ruleDescription, []);
17
+ }
18
+
19
+ for (const example of rule.examples || []) {
20
+ const givenSteps = example.steps?.filter(step => step.keyword === 'Given') || [];
21
+ const whenSteps = example.steps?.filter(step => step.keyword === 'When') || [];
22
+ const thenSteps = example.steps?.filter(step => step.keyword === 'Then') || [];
23
+
24
+ ruleGroups.get(ruleDescription).push({
25
+ description: example.name || 'should handle events correctly',
26
+ given: givenSteps.map(step => ({ eventRef: step.text, exampleData: step.docString || {} })),
27
+ when: whenSteps.map(step => ({ eventRef: step.text, exampleData: step.docString || {} })),
28
+ then: thenSteps.map(step => ({ stateRef: step.text, exampleData: step.docString || {} }))
29
+ });
30
+ }
31
+ }
14
32
  }
33
+ } else {
34
+ const rules = slice?.server?.specs?.rules || [];
35
+ for (const rule of rules) {
36
+ const ruleDescription = rule.description || `${flowName} | ${sliceName}`;
37
+ if (!ruleGroups.has(ruleDescription)) {
38
+ ruleGroups.set(ruleDescription, []);
39
+ }
15
40
 
16
- for (const example of rule.examples || []) {
17
- ruleGroups.get(ruleDescription).push({
18
- description: example.description || 'should handle events correctly',
19
- given: example.given || [],
20
- when: example.when || [],
21
- then: example.then || []
22
- });
41
+ for (const example of rule.examples || []) {
42
+ ruleGroups.get(ruleDescription).push({
43
+ description: example.description || 'should handle events correctly',
44
+ given: example.given || [],
45
+ when: example.when || [],
46
+ then: example.then || []
47
+ });
48
+ }
23
49
  }
24
50
  }
25
51
  _%>