@auto-engineer/server-generator-apollo-emmett 1.138.0 → 1.140.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.
Files changed (170) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +4 -4
  3. package/.turbo/turbo-type-check.log +1 -1
  4. package/CHANGELOG.md +39 -0
  5. package/DEBUG.md +4 -4
  6. package/dist/src/codegen/extract/data-sink.d.ts +2 -2
  7. package/dist/src/codegen/extract/data-sink.d.ts.map +1 -1
  8. package/dist/src/codegen/extract/data-sink.js +2 -2
  9. package/dist/src/codegen/extract/data-sink.js.map +1 -1
  10. package/dist/src/codegen/extract/events.d.ts +3 -3
  11. package/dist/src/codegen/extract/events.d.ts.map +1 -1
  12. package/dist/src/codegen/extract/events.js +11 -11
  13. package/dist/src/codegen/extract/events.js.map +1 -1
  14. package/dist/src/codegen/extract/gwt.d.ts +2 -2
  15. package/dist/src/codegen/extract/gwt.d.ts.map +1 -1
  16. package/dist/src/codegen/extract/gwt.js +2 -2
  17. package/dist/src/codegen/extract/gwt.js.map +1 -1
  18. package/dist/src/codegen/extract/imports.d.ts +4 -4
  19. package/dist/src/codegen/extract/imports.d.ts.map +1 -1
  20. package/dist/src/codegen/extract/imports.js +8 -8
  21. package/dist/src/codegen/extract/imports.js.map +1 -1
  22. package/dist/src/codegen/extract/messages.d.ts +2 -2
  23. package/dist/src/codegen/extract/messages.d.ts.map +1 -1
  24. package/dist/src/codegen/extract/messages.js +9 -9
  25. package/dist/src/codegen/extract/messages.js.map +1 -1
  26. package/dist/src/codegen/extract/projection.d.ts +7 -7
  27. package/dist/src/codegen/extract/projection.d.ts.map +1 -1
  28. package/dist/src/codegen/extract/projection.js +3 -3
  29. package/dist/src/codegen/extract/projection.js.map +1 -1
  30. package/dist/src/codegen/extract/query.d.ts +2 -2
  31. package/dist/src/codegen/extract/query.d.ts.map +1 -1
  32. package/dist/src/codegen/extract/query.js.map +1 -1
  33. package/dist/src/codegen/extract/slice-normalizer.d.ts +4 -4
  34. package/dist/src/codegen/extract/slice-normalizer.d.ts.map +1 -1
  35. package/dist/src/codegen/extract/slice-normalizer.js +7 -7
  36. package/dist/src/codegen/extract/slice-normalizer.js.map +1 -1
  37. package/dist/src/codegen/extract/states.d.ts +3 -3
  38. package/dist/src/codegen/extract/states.d.ts.map +1 -1
  39. package/dist/src/codegen/extract/states.js.map +1 -1
  40. package/dist/src/codegen/extract/step-converter.d.ts +7 -7
  41. package/dist/src/codegen/extract/step-converter.d.ts.map +1 -1
  42. package/dist/src/codegen/extract/step-converter.js +12 -12
  43. package/dist/src/codegen/extract/step-converter.js.map +1 -1
  44. package/dist/src/codegen/extract/step-types.d.ts +4 -4
  45. package/dist/src/codegen/extract/step-types.d.ts.map +1 -1
  46. package/dist/src/codegen/extract/step-types.js +1 -1
  47. package/dist/src/codegen/extract/step-types.js.map +1 -1
  48. package/dist/src/codegen/scaffoldFromSchema.d.ts +12 -12
  49. package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
  50. package/dist/src/codegen/scaffoldFromSchema.js +113 -101
  51. package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
  52. package/dist/src/codegen/templates/command/commands.specs.ts +3 -3
  53. package/dist/src/codegen/templates/command/decide.specs.specs.ts +52 -52
  54. package/dist/src/codegen/templates/command/decide.specs.ts +12 -12
  55. package/dist/src/codegen/templates/command/decide.specs.ts.ejs +1 -1
  56. package/dist/src/codegen/templates/command/events.specs.ts +3 -3
  57. package/dist/src/codegen/templates/command/evolve.specs.ts +3 -3
  58. package/dist/src/codegen/templates/command/handle.specs.ts +13 -13
  59. package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +19 -19
  60. package/dist/src/codegen/templates/command/register.specs.ts +3 -3
  61. package/dist/src/codegen/templates/command/state.specs.ts +3 -3
  62. package/dist/src/codegen/templates/query/events.specs.ts +4 -4
  63. package/dist/src/codegen/templates/query/projection.specs.specs.ts +60 -60
  64. package/dist/src/codegen/templates/query/projection.specs.ts +54 -29
  65. package/dist/src/codegen/templates/query/projection.specs.ts.ejs +2 -2
  66. package/dist/src/codegen/templates/query/query.resolver.specs.ts +63 -63
  67. package/dist/src/codegen/templates/query/query.resolver.ts.ejs +1 -1
  68. package/dist/src/codegen/templates/query/state.specs.ts +9 -9
  69. package/dist/src/codegen/templates/react/react.specs.specs.ts +15 -15
  70. package/dist/src/codegen/templates/react/react.specs.ts +16 -16
  71. package/dist/src/codegen/templates/react/react.specs.ts.ejs +9 -9
  72. package/dist/src/codegen/templates/react/react.ts.ejs +5 -5
  73. package/dist/src/codegen/templates/react/react.ts.specs.ts +33 -33
  74. package/dist/src/codegen/templates/react/register.specs.ts +7 -7
  75. package/dist/src/codegen/templates/react/register.ts.ejs +4 -4
  76. package/dist/src/codegen/test-data/specVariant1.d.ts.map +1 -1
  77. package/dist/src/codegen/test-data/specVariant1.js +3 -2
  78. package/dist/src/codegen/test-data/specVariant1.js.map +1 -1
  79. package/dist/src/codegen/types.d.ts +2 -2
  80. package/dist/src/codegen/types.d.ts.map +1 -1
  81. package/dist/src/commands/generate-server.d.ts +21 -21
  82. package/dist/src/commands/generate-server.d.ts.map +1 -1
  83. package/dist/src/commands/generate-server.js +81 -63
  84. package/dist/src/commands/generate-server.js.map +1 -1
  85. package/dist/src/commands/initialize-server.d.ts.map +1 -1
  86. package/dist/src/commands/initialize-server.js +2 -2
  87. package/dist/src/commands/initialize-server.js.map +1 -1
  88. package/dist/src/domain/flows/shared/types.d.ts +14 -0
  89. package/dist/src/domain/flows/shared/types.d.ts.map +1 -0
  90. package/dist/src/domain/flows/shared/types.js +2 -0
  91. package/dist/src/domain/flows/shared/types.js.map +1 -0
  92. package/dist/src/domain/flows/shared/types.ts +15 -0
  93. package/dist/src/domain/narratives/shared/types.d.ts +14 -0
  94. package/dist/src/domain/narratives/shared/types.d.ts.map +1 -0
  95. package/dist/src/domain/narratives/shared/types.js +2 -0
  96. package/dist/src/domain/narratives/shared/types.js.map +1 -0
  97. package/dist/src/domain/narratives/shared/types.ts +15 -0
  98. package/dist/src/index.d.ts +1 -1
  99. package/dist/src/index.d.ts.map +1 -1
  100. package/dist/src/server.js +3 -3
  101. package/dist/src/server.js.map +1 -1
  102. package/dist/src/server.ts +3 -3
  103. package/dist/src/utils/loadRegisterFiles.d.ts +2 -2
  104. package/dist/src/utils/loadRegisterFiles.d.ts.map +1 -1
  105. package/dist/src/utils/loadRegisterFiles.js.map +1 -1
  106. package/dist/src/utils/loadRegisterFiles.ts +5 -5
  107. package/dist/src/utils/loadResolvers.js +1 -1
  108. package/dist/src/utils/loadResolvers.js.map +1 -1
  109. package/dist/src/utils/loadResolvers.ts +1 -1
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/package.json +4 -4
  112. package/src/codegen/extract/data-sink.ts +5 -5
  113. package/src/codegen/extract/events.ts +15 -15
  114. package/src/codegen/extract/gwt.ts +4 -4
  115. package/src/codegen/extract/imports.specs.ts +19 -19
  116. package/src/codegen/extract/imports.ts +13 -13
  117. package/src/codegen/extract/messages.specs.ts +30 -30
  118. package/src/codegen/extract/messages.ts +16 -16
  119. package/src/codegen/extract/projection.specs.ts +22 -22
  120. package/src/codegen/extract/projection.ts +9 -9
  121. package/src/codegen/extract/query.ts +2 -2
  122. package/src/codegen/extract/slice-normalizer.specs.ts +11 -11
  123. package/src/codegen/extract/slice-normalizer.ts +14 -14
  124. package/src/codegen/extract/states.ts +4 -4
  125. package/src/codegen/extract/step-converter.specs.ts +9 -9
  126. package/src/codegen/extract/step-converter.ts +15 -15
  127. package/src/codegen/extract/step-types.specs.ts +12 -12
  128. package/src/codegen/extract/step-types.ts +4 -4
  129. package/src/codegen/findEventSource.specs.ts +23 -23
  130. package/src/codegen/scaffoldErrors.specs.ts +4 -4
  131. package/src/codegen/scaffoldFromSchema.filter.specs.ts +32 -32
  132. package/src/codegen/scaffoldFromSchema.ts +146 -132
  133. package/src/codegen/templates/command/commands.specs.ts +3 -3
  134. package/src/codegen/templates/command/decide.specs.specs.ts +52 -52
  135. package/src/codegen/templates/command/decide.specs.ts +12 -12
  136. package/src/codegen/templates/command/decide.specs.ts.ejs +1 -1
  137. package/src/codegen/templates/command/events.specs.ts +3 -3
  138. package/src/codegen/templates/command/evolve.specs.ts +3 -3
  139. package/src/codegen/templates/command/handle.specs.ts +13 -13
  140. package/src/codegen/templates/command/mutation.resolver.specs.ts +19 -19
  141. package/src/codegen/templates/command/register.specs.ts +3 -3
  142. package/src/codegen/templates/command/state.specs.ts +3 -3
  143. package/src/codegen/templates/query/events.specs.ts +4 -4
  144. package/src/codegen/templates/query/projection.specs.specs.ts +60 -60
  145. package/src/codegen/templates/query/projection.specs.ts +54 -29
  146. package/src/codegen/templates/query/projection.specs.ts.ejs +2 -2
  147. package/src/codegen/templates/query/query.resolver.specs.ts +63 -63
  148. package/src/codegen/templates/query/query.resolver.ts.ejs +1 -1
  149. package/src/codegen/templates/query/state.specs.ts +9 -9
  150. package/src/codegen/templates/react/react.specs.specs.ts +15 -15
  151. package/src/codegen/templates/react/react.specs.ts +16 -16
  152. package/src/codegen/templates/react/react.specs.ts.ejs +9 -9
  153. package/src/codegen/templates/react/react.ts.ejs +5 -5
  154. package/src/codegen/templates/react/react.ts.specs.ts +33 -33
  155. package/src/codegen/templates/react/register.specs.ts +7 -7
  156. package/src/codegen/templates/react/register.ts.ejs +4 -4
  157. package/src/codegen/test-data/specVariant1.json +1 -1
  158. package/src/codegen/test-data/specVariant1.ts +3 -2
  159. package/src/codegen/test-data/specVariant2.json +1 -1
  160. package/src/codegen/types.ts +2 -2
  161. package/src/commands/generate-server.specs.ts +81 -79
  162. package/src/commands/generate-server.ts +110 -88
  163. package/src/commands/initialize-server.specs.ts +4 -4
  164. package/src/commands/initialize-server.ts +5 -2
  165. package/src/domain/flows/shared/types.ts +15 -0
  166. package/src/domain/narratives/shared/types.ts +15 -0
  167. package/src/index.ts +1 -1
  168. package/src/server.ts +3 -3
  169. package/src/utils/loadRegisterFiles.ts +5 -5
  170. package/src/utils/loadResolvers.ts +1 -1
@@ -6,10 +6,10 @@ describe('generateScaffoldFilePlans', () => {
6
6
  it('should generate a valid register file', async () => {
7
7
  const spec: SpecsSchema = {
8
8
  variant: 'specs',
9
- narratives: [
9
+ scenes: [
10
10
  {
11
11
  name: 'Host creates a listing',
12
- slices: [
12
+ moments: [
13
13
  {
14
14
  type: 'command',
15
15
  name: 'Create listing',
@@ -105,7 +105,7 @@ describe('generateScaffoldFilePlans', () => {
105
105
  ],
106
106
  };
107
107
 
108
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
108
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
109
109
  const registerFile = plans.find((p) => p.outputPath.endsWith('register.ts'));
110
110
 
111
111
  expect(registerFile?.contents).toMatchInlineSnapshot(`
@@ -6,10 +6,10 @@ describe('state.ts.ejs', () => {
6
6
  it('should generate an initial state', async () => {
7
7
  const spec: SpecsSchema = {
8
8
  variant: 'specs',
9
- narratives: [
9
+ scenes: [
10
10
  {
11
11
  name: 'Host creates a listing',
12
- slices: [
12
+ moments: [
13
13
  {
14
14
  type: 'command',
15
15
  name: 'Create listing',
@@ -83,7 +83,7 @@ describe('state.ts.ejs', () => {
83
83
  ],
84
84
  };
85
85
 
86
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
86
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
87
87
  const stateFile = plans.find((p) => p.outputPath.endsWith('state.ts'));
88
88
 
89
89
  expect(stateFile?.contents).toMatchInlineSnapshot(`
@@ -6,10 +6,10 @@ describe('query events.ts.ejs', () => {
6
6
  it('generates events.ts for orphan events not produced by any command slice', async () => {
7
7
  const spec: Model = {
8
8
  variant: 'specs',
9
- narratives: [
9
+ scenes: [
10
10
  {
11
- name: 'appointment-flow',
12
- slices: [
11
+ name: 'appointment-scene',
12
+ moments: [
13
13
  {
14
14
  type: 'query',
15
15
  name: 'view-appointments',
@@ -89,7 +89,7 @@ describe('query events.ts.ejs', () => {
89
89
  ],
90
90
  };
91
91
 
92
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
92
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
93
93
 
94
94
  const eventFile = plans.find((p) => p.outputPath.endsWith('view-appointments/events.ts'));
95
95
  expect(eventFile).toBeDefined();
@@ -6,10 +6,10 @@ describe('projection.specs.ts.ejs', () => {
6
6
  it('should generate a valid test spec for a query slice projection', async () => {
7
7
  const spec: SpecsSchema = {
8
8
  variant: 'specs',
9
- narratives: [
9
+ scenes: [
10
10
  {
11
- name: 'listing-flow',
12
- slices: [
11
+ name: 'listing-scene',
12
+ moments: [
13
13
  {
14
14
  type: 'command',
15
15
  name: 'CreateListing',
@@ -192,7 +192,7 @@ describe('projection.specs.ts.ejs', () => {
192
192
  ],
193
193
  } as SpecsSchema;
194
194
 
195
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
195
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
196
196
  const specFile = plans.find((p) => p.outputPath.endsWith('projection.specs.ts'));
197
197
 
198
198
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -253,10 +253,10 @@ describe('projection.specs.ts.ejs', () => {
253
253
  it('should generate a valid test spec for a model with given/when/then pattern', async () => {
254
254
  const questionnaireSpec: SpecsSchema = {
255
255
  variant: 'specs',
256
- narratives: [
256
+ scenes: [
257
257
  {
258
258
  name: 'Questionnaires',
259
- slices: [
259
+ moments: [
260
260
  {
261
261
  name: 'views the questionnaire',
262
262
  type: 'query',
@@ -379,10 +379,10 @@ describe('projection.specs.ts.ejs', () => {
379
379
  } as SpecsSchema;
380
380
 
381
381
  const { plans } = await generateScaffoldFilePlans(
382
- questionnaireSpec.narratives,
382
+ questionnaireSpec.scenes,
383
383
  questionnaireSpec.messages,
384
384
  undefined,
385
- 'src/domain/flows',
385
+ 'src/domain/narratives',
386
386
  );
387
387
  const specFile = plans.find((p) => p.outputPath.endsWith('projection.specs.ts'));
388
388
 
@@ -396,10 +396,10 @@ describe('projection.specs.ts.ejs', () => {
396
396
  it('should include all events from both given and when clauses in projection imports and types', async () => {
397
397
  const spec: SpecsSchema = {
398
398
  variant: 'specs',
399
- narratives: [
399
+ scenes: [
400
400
  {
401
401
  name: 'questionnaires',
402
- slices: [
402
+ moments: [
403
403
  {
404
404
  type: 'command',
405
405
  name: 'sends-the-questionnaire-link',
@@ -599,7 +599,7 @@ describe('projection.specs.ts.ejs', () => {
599
599
  } as SpecsSchema;
600
600
 
601
601
  const { plans } = await generateScaffoldFilePlans(
602
- spec.narratives,
602
+ spec.scenes,
603
603
  [
604
604
  {
605
605
  type: 'command',
@@ -622,7 +622,7 @@ describe('projection.specs.ts.ejs', () => {
622
622
  ...spec.messages,
623
623
  ],
624
624
  undefined,
625
- 'src/domain/flows',
625
+ 'src/domain/narratives',
626
626
  );
627
627
 
628
628
  // Check projection.specs.ts file
@@ -654,10 +654,10 @@ describe('projection.specs.ts.ejs', () => {
654
654
  it('should generate a valid test spec for singleton projection', async () => {
655
655
  const spec: SpecsSchema = {
656
656
  variant: 'specs',
657
- narratives: [
657
+ scenes: [
658
658
  {
659
- name: 'todo-flow',
660
- slices: [
659
+ name: 'todo-scene',
660
+ moments: [
661
661
  {
662
662
  type: 'command',
663
663
  name: 'manage-todo',
@@ -787,7 +787,7 @@ describe('projection.specs.ts.ejs', () => {
787
787
  ],
788
788
  } as SpecsSchema;
789
789
 
790
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
790
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
791
791
  const specFile = plans.find((p) => p.outputPath.endsWith('view-summary/projection.specs.ts'));
792
792
 
793
793
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -839,10 +839,10 @@ describe('projection.specs.ts.ejs', () => {
839
839
  it('should generate a valid test spec for composite key projection', async () => {
840
840
  const spec: SpecsSchema = {
841
841
  variant: 'specs',
842
- narratives: [
842
+ scenes: [
843
843
  {
844
- name: 'user-project-flow',
845
- slices: [
844
+ name: 'user-project-scene',
845
+ moments: [
846
846
  {
847
847
  type: 'command',
848
848
  name: 'manage-user-project',
@@ -983,7 +983,7 @@ describe('projection.specs.ts.ejs', () => {
983
983
  ],
984
984
  } as SpecsSchema;
985
985
 
986
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
986
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
987
987
  const specFile = plans.find((p) => p.outputPath.endsWith('view-user-projects/projection.specs.ts'));
988
988
 
989
989
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -1040,10 +1040,10 @@ describe('projection.specs.ts.ejs', () => {
1040
1040
  it('should generate empty when array for query action in projection.specs.ts', async () => {
1041
1041
  const spec: SpecsSchema = {
1042
1042
  variant: 'specs',
1043
- narratives: [
1043
+ scenes: [
1044
1044
  {
1045
- name: 'workout-flow',
1046
- slices: [
1045
+ name: 'workout-scene',
1046
+ moments: [
1047
1047
  {
1048
1048
  type: 'command',
1049
1049
  name: 'log-workout',
@@ -1162,7 +1162,7 @@ describe('projection.specs.ts.ejs', () => {
1162
1162
  ],
1163
1163
  } as SpecsSchema;
1164
1164
 
1165
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
1165
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
1166
1166
  const specFile = plans.find((p) => p.outputPath.endsWith('view-workout-history/projection.specs.ts'));
1167
1167
 
1168
1168
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -1216,10 +1216,10 @@ describe('projection.specs.ts.ejs', () => {
1216
1216
  it('should exclude query arg fields that differ from projection-computed values', async () => {
1217
1217
  const spec: SpecsSchema = {
1218
1218
  variant: 'specs',
1219
- narratives: [
1219
+ scenes: [
1220
1220
  {
1221
- name: 'fart-flow',
1222
- slices: [
1221
+ name: 'fart-scene',
1222
+ moments: [
1223
1223
  {
1224
1224
  type: 'command',
1225
1225
  name: 'log-fart',
@@ -1363,7 +1363,7 @@ describe('projection.specs.ts.ejs', () => {
1363
1363
  ],
1364
1364
  } as SpecsSchema;
1365
1365
 
1366
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
1366
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
1367
1367
  const specFile = plans.find((p) => p.outputPath.endsWith('view-fart-history/projection.specs.ts'));
1368
1368
 
1369
1369
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -1434,10 +1434,10 @@ describe('projection.specs.ts.ejs', () => {
1434
1434
  it('should serialize inline objects and arrays with Date sub-fields correctly', async () => {
1435
1435
  const spec: SpecsSchema = {
1436
1436
  variant: 'specs',
1437
- narratives: [
1437
+ scenes: [
1438
1438
  {
1439
- name: 'fitness-flow',
1440
- slices: [
1439
+ name: 'fitness-scene',
1440
+ moments: [
1441
1441
  {
1442
1442
  type: 'command',
1443
1443
  name: 'record-session',
@@ -1572,7 +1572,7 @@ describe('projection.specs.ts.ejs', () => {
1572
1572
  ],
1573
1573
  } as SpecsSchema;
1574
1574
 
1575
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
1575
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
1576
1576
  const specFile = plans.find((p) => p.outputPath.endsWith('view-member-stats/projection.specs.ts'));
1577
1577
 
1578
1578
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -1630,10 +1630,10 @@ describe('projection.specs.ts.ejs', () => {
1630
1630
  it('should generate valid projection.ts when When clause is a query action (QueryActionRef)', async () => {
1631
1631
  const spec: SpecsSchema = {
1632
1632
  variant: 'specs',
1633
- narratives: [
1633
+ scenes: [
1634
1634
  {
1635
- name: 'workout-flow',
1636
- slices: [
1635
+ name: 'workout-scene',
1636
+ moments: [
1637
1637
  {
1638
1638
  type: 'command',
1639
1639
  name: 'log-workout',
@@ -1758,7 +1758,7 @@ describe('projection.specs.ts.ejs', () => {
1758
1758
  ],
1759
1759
  } as SpecsSchema;
1760
1760
 
1761
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
1761
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
1762
1762
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-workout-history/projection.ts'));
1763
1763
 
1764
1764
  expect(projectionFile?.contents).toMatchInlineSnapshot(`
@@ -1839,10 +1839,10 @@ describe('projection.specs.ts.ejs', () => {
1839
1839
  it('should include ...document spread in non-removal evolve cases', async () => {
1840
1840
  const spec: SpecsSchema = {
1841
1841
  variant: 'specs',
1842
- narratives: [
1842
+ scenes: [
1843
1843
  {
1844
- name: 'item-flow',
1845
- slices: [
1844
+ name: 'item-scene',
1845
+ moments: [
1846
1846
  {
1847
1847
  type: 'command',
1848
1848
  name: 'manage-item',
@@ -2003,7 +2003,7 @@ describe('projection.specs.ts.ejs', () => {
2003
2003
  ],
2004
2004
  } as SpecsSchema;
2005
2005
 
2006
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2006
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2007
2007
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-items/projection.ts'));
2008
2008
  expect(projectionFile?.contents).toBeDefined();
2009
2009
 
@@ -2020,10 +2020,10 @@ describe('projection.specs.ts.ejs', () => {
2020
2020
  it('should warn when events lack the idField used by getDocumentId', async () => {
2021
2021
  const spec: SpecsSchema = {
2022
2022
  variant: 'specs',
2023
- narratives: [
2023
+ scenes: [
2024
2024
  {
2025
- name: 'order-flow',
2026
- slices: [
2025
+ name: 'order-scene',
2026
+ moments: [
2027
2027
  {
2028
2028
  type: 'command',
2029
2029
  name: 'manage-order',
@@ -2191,7 +2191,7 @@ describe('projection.specs.ts.ejs', () => {
2191
2191
  ],
2192
2192
  } as SpecsSchema;
2193
2193
 
2194
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2194
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2195
2195
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-orders/projection.ts'));
2196
2196
  expect(projectionFile?.contents).toBeDefined();
2197
2197
 
@@ -2202,10 +2202,10 @@ describe('projection.specs.ts.ejs', () => {
2202
2202
  it('should parse stringified JSON arrays in docString values for array-typed fields', async () => {
2203
2203
  const spec: SpecsSchema = {
2204
2204
  variant: 'specs',
2205
- narratives: [
2205
+ scenes: [
2206
2206
  {
2207
- name: 'appointment-flow',
2208
- slices: [
2207
+ name: 'appointment-scene',
2208
+ moments: [
2209
2209
  {
2210
2210
  type: 'command',
2211
2211
  name: 'book-appointment',
@@ -2317,7 +2317,7 @@ describe('projection.specs.ts.ejs', () => {
2317
2317
  ],
2318
2318
  } as SpecsSchema;
2319
2319
 
2320
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2320
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2321
2321
  const specFile = plans.find((p) => p.outputPath.endsWith('view-appointments/projection.specs.ts'));
2322
2322
 
2323
2323
  expect(specFile?.contents).toContain("appointmentId: 'appt_789'");
@@ -2328,10 +2328,10 @@ describe('projection.specs.ts.ejs', () => {
2328
2328
  it('should serialize array values correctly when event field is missing from schema', async () => {
2329
2329
  const spec: SpecsSchema = {
2330
2330
  variant: 'specs',
2331
- narratives: [
2331
+ scenes: [
2332
2332
  {
2333
- name: 'fitness-flow',
2334
- slices: [
2333
+ name: 'fitness-scene',
2334
+ moments: [
2335
2335
  {
2336
2336
  type: 'command',
2337
2337
  name: 'update-leaderboard',
@@ -2437,7 +2437,7 @@ describe('projection.specs.ts.ejs', () => {
2437
2437
  ],
2438
2438
  };
2439
2439
 
2440
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2440
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2441
2441
  const specFile = plans.find((p) => p.outputPath.endsWith('view-leaderboard/projection.specs.ts'));
2442
2442
 
2443
2443
  expect(specFile?.contents).not.toContain('[object Object]');
@@ -2447,10 +2447,10 @@ describe('projection.specs.ts.ejs', () => {
2447
2447
  it('should resolve idField value from Given/When events when not in Then state data', async () => {
2448
2448
  const spec: SpecsSchema = {
2449
2449
  variant: 'specs',
2450
- narratives: [
2450
+ scenes: [
2451
2451
  {
2452
- name: 'fitness-flow',
2453
- slices: [
2452
+ name: 'fitness-scene',
2453
+ moments: [
2454
2454
  {
2455
2455
  type: 'command',
2456
2456
  name: 'log-workout',
@@ -2565,7 +2565,7 @@ describe('projection.specs.ts.ejs', () => {
2565
2565
  ],
2566
2566
  } as SpecsSchema;
2567
2567
 
2568
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2568
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2569
2569
  const specFile = plans.find((p) => p.outputPath.endsWith('view-workout-summary/projection.specs.ts'));
2570
2570
 
2571
2571
  expect(specFile?.contents).toMatchInlineSnapshot(`
@@ -2620,10 +2620,10 @@ describe('projection.specs.ts.ejs', () => {
2620
2620
  it('should escape apostrophes in rule names and test descriptions', async () => {
2621
2621
  const spec: SpecsSchema = {
2622
2622
  variant: 'specs',
2623
- narratives: [
2623
+ scenes: [
2624
2624
  {
2625
- name: 'workout-flow',
2626
- slices: [
2625
+ name: 'workout-scene',
2626
+ moments: [
2627
2627
  {
2628
2628
  type: 'command',
2629
2629
  name: 'log-workout',
@@ -2735,7 +2735,7 @@ describe('projection.specs.ts.ejs', () => {
2735
2735
  ],
2736
2736
  } as SpecsSchema;
2737
2737
 
2738
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
2738
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
2739
2739
  const specFile = plans.find((p) => p.outputPath.endsWith('view-user-workouts/projection.specs.ts'));
2740
2740
 
2741
2741
  expect(specFile?.contents).toContain('describe("List of user\'s workouts"');
@@ -4,12 +4,12 @@ import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
4
4
 
5
5
  describe('projection.ts.ejs', () => {
6
6
  it('should generate a valid projection file with correct relative event import path from producing slice', async () => {
7
- const flows: Model = {
7
+ const scenes: Model = {
8
8
  variant: 'specs',
9
- narratives: [
9
+ scenes: [
10
10
  {
11
- name: 'listing-flow',
12
- slices: [
11
+ name: 'listing-scene',
12
+ moments: [
13
13
  {
14
14
  type: 'command',
15
15
  name: 'create-listing',
@@ -213,7 +213,12 @@ describe('projection.ts.ejs', () => {
213
213
  ],
214
214
  };
215
215
 
216
- const { plans } = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
216
+ const { plans } = await generateScaffoldFilePlans(
217
+ scenes.scenes,
218
+ scenes.messages,
219
+ undefined,
220
+ 'src/domain/narratives',
221
+ );
217
222
  const projectionFile = plans.find((p) => p.outputPath.endsWith('projection.ts'));
218
223
 
219
224
  expect(projectionFile?.contents).toMatchInlineSnapshot(`
@@ -321,10 +326,10 @@ describe('projection.ts.ejs', () => {
321
326
  it('should generate a valid query resolver using ID type', async () => {
322
327
  const spec: Model = {
323
328
  variant: 'specs',
324
- narratives: [
329
+ scenes: [
325
330
  {
326
- name: 'wishlist-flow',
327
- slices: [
331
+ name: 'wishlist-scene',
332
+ moments: [
328
333
  {
329
334
  type: 'query',
330
335
  name: 'view-wishlist',
@@ -374,7 +379,7 @@ describe('projection.ts.ejs', () => {
374
379
  ],
375
380
  };
376
381
 
377
- const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
382
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
378
383
  const resolverFile = plans.find((p) => p.outputPath.endsWith('query.resolver.ts'));
379
384
 
380
385
  expect(resolverFile?.contents).toMatchInlineSnapshot(`
@@ -421,12 +426,12 @@ describe('projection.ts.ejs', () => {
421
426
  });
422
427
 
423
428
  it('should generate a valid singleton projection file', async () => {
424
- const flows: Model = {
429
+ const scenes: Model = {
425
430
  variant: 'specs',
426
- narratives: [
431
+ scenes: [
427
432
  {
428
- name: 'todo-flow',
429
- slices: [
433
+ name: 'todo-scene',
434
+ moments: [
430
435
  {
431
436
  type: 'command',
432
437
  name: 'manage-todo',
@@ -560,7 +565,12 @@ describe('projection.ts.ejs', () => {
560
565
  ],
561
566
  };
562
567
 
563
- const { plans } = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
568
+ const { plans } = await generateScaffoldFilePlans(
569
+ scenes.scenes,
570
+ scenes.messages,
571
+ undefined,
572
+ 'src/domain/narratives',
573
+ );
564
574
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-summary/projection.ts'));
565
575
 
566
576
  expect(projectionFile?.contents).toMatchInlineSnapshot(`
@@ -649,12 +659,12 @@ describe('projection.ts.ejs', () => {
649
659
  });
650
660
 
651
661
  it('should generate a valid composite key projection file', async () => {
652
- const flows: Model = {
662
+ const scenes: Model = {
653
663
  variant: 'specs',
654
- narratives: [
664
+ scenes: [
655
665
  {
656
- name: 'user-project-flow',
657
- slices: [
666
+ name: 'user-project-scene',
667
+ moments: [
658
668
  {
659
669
  type: 'command',
660
670
  name: 'manage-user-project',
@@ -799,7 +809,12 @@ describe('projection.ts.ejs', () => {
799
809
  ],
800
810
  };
801
811
 
802
- const { plans } = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
812
+ const { plans } = await generateScaffoldFilePlans(
813
+ scenes.scenes,
814
+ scenes.messages,
815
+ undefined,
816
+ 'src/domain/narratives',
817
+ );
803
818
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-user-projects/projection.ts'));
804
819
 
805
820
  expect(projectionFile?.contents).toMatchInlineSnapshot(`
@@ -878,12 +893,12 @@ describe('projection.ts.ejs', () => {
878
893
  });
879
894
 
880
895
  it('should not treat mixed union type with quotes as enum import', async () => {
881
- const flows: Model = {
896
+ const scenes: Model = {
882
897
  variant: 'specs',
883
- narratives: [
898
+ scenes: [
884
899
  {
885
- name: 'order-flow',
886
- slices: [
900
+ name: 'order-scene',
901
+ moments: [
887
902
  {
888
903
  type: 'command',
889
904
  name: 'place-order',
@@ -1002,7 +1017,12 @@ describe('projection.ts.ejs', () => {
1002
1017
  ],
1003
1018
  };
1004
1019
 
1005
- const { plans } = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
1020
+ const { plans } = await generateScaffoldFilePlans(
1021
+ scenes.scenes,
1022
+ scenes.messages,
1023
+ undefined,
1024
+ 'src/domain/narratives',
1025
+ );
1006
1026
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-order-status/projection.ts'));
1007
1027
 
1008
1028
  expect(projectionFile?.contents).not.toContain('number | "pending"');
@@ -1010,12 +1030,12 @@ describe('projection.ts.ejs', () => {
1010
1030
  });
1011
1031
 
1012
1032
  it('should generate switch-based getDocumentId when events come from slices with different id fields', async () => {
1013
- const flows: Model = {
1033
+ const scenes: Model = {
1014
1034
  variant: 'specs',
1015
- narratives: [
1035
+ scenes: [
1016
1036
  {
1017
- name: 'workout-flow',
1018
- slices: [
1037
+ name: 'workout-scene',
1038
+ moments: [
1019
1039
  {
1020
1040
  type: 'command',
1021
1041
  name: 'create-workout',
@@ -1196,7 +1216,12 @@ describe('projection.ts.ejs', () => {
1196
1216
  ],
1197
1217
  };
1198
1218
 
1199
- const { plans } = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
1219
+ const { plans } = await generateScaffoldFilePlans(
1220
+ scenes.scenes,
1221
+ scenes.messages,
1222
+ undefined,
1223
+ 'src/domain/narratives',
1224
+ );
1200
1225
  const projectionFile = plans.find((p) => p.outputPath.endsWith('view-workout/projection.ts'));
1201
1226
 
1202
1227
  expect(projectionFile?.contents).toMatchInlineSnapshot(`
@@ -109,7 +109,7 @@ if (Array.isArray(slice?.server?.specs)) {
109
109
  for (const spec of slice.server.specs) {
110
110
  const rules = spec.rules || [];
111
111
  for (const rule of rules) {
112
- const ruleDescription = rule.name || `${flowName} | ${sliceName}`;
112
+ const ruleDescription = rule.name || `${sceneName} | ${momentName}`;
113
113
  if (!ruleGroups.has(ruleDescription)) {
114
114
  ruleGroups.set(ruleDescription, []);
115
115
  }
@@ -139,7 +139,7 @@ if (Array.isArray(slice?.server?.specs)) {
139
139
  } else {
140
140
  const rules = slice?.server?.specs?.rules || [];
141
141
  for (const rule of rules) {
142
- const ruleDescription = rule.description || `${flowName} | ${sliceName}`;
142
+ const ruleDescription = rule.description || `${sceneName} | ${momentName}`;
143
143
  if (!ruleGroups.has(ruleDescription)) {
144
144
  ruleGroups.set(ruleDescription, []);
145
145
  }