@auto-engineer/server-generator-apollo-emmett 0.21.0 → 0.22.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 (57) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +20 -0
  3. package/dist/src/codegen/extract/data-sink.js +2 -2
  4. package/dist/src/codegen/extract/data-sink.js.map +1 -1
  5. package/dist/src/codegen/extract/projection.js +2 -2
  6. package/dist/src/codegen/extract/projection.js.map +1 -1
  7. package/dist/src/codegen/extract/states.d.ts.map +1 -1
  8. package/dist/src/codegen/extract/states.js +5 -4
  9. package/dist/src/codegen/extract/states.js.map +1 -1
  10. package/dist/src/codegen/scaffoldFromSchema.js +1 -1
  11. package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
  12. package/dist/src/codegen/templates/command/decide.specs.ts +33 -31
  13. package/dist/src/codegen/templates/command/decide.ts.ejs +1 -1
  14. package/dist/src/codegen/templates/command/handle.specs.ts +46 -42
  15. package/dist/src/codegen/templates/command/handle.ts.ejs +2 -2
  16. package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +12 -10
  17. package/dist/src/codegen/templates/command/register.specs.ts +13 -11
  18. package/dist/src/codegen/templates/query/projection.specs.specs.ts +64 -54
  19. package/dist/src/codegen/templates/query/projection.specs.ts +56 -48
  20. package/dist/src/codegen/templates/query/projection.specs.ts.ejs +1 -1
  21. package/dist/src/codegen/templates/query/projection.ts.ejs +10 -10
  22. package/dist/src/codegen/templates/query/query.resolver.specs.ts +92 -78
  23. package/dist/src/codegen/templates/query/query.resolver.ts.ejs +2 -2
  24. package/dist/src/codegen/templates/query/state.specs.ts +14 -12
  25. package/dist/src/codegen/templates/react/react.specs.specs.ts +8 -6
  26. package/dist/src/codegen/test-data/specVariant1.d.ts.map +1 -1
  27. package/dist/src/codegen/test-data/specVariant1.js +18 -16
  28. package/dist/src/codegen/test-data/specVariant1.js.map +1 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +4 -4
  31. package/src/codegen/extract/data-sink.ts +2 -2
  32. package/src/codegen/extract/projection.ts +2 -2
  33. package/src/codegen/extract/states.ts +6 -5
  34. package/src/codegen/scaffoldFromSchema.ts +1 -1
  35. package/src/codegen/templates/command/decide.specs.ts +33 -31
  36. package/src/codegen/templates/command/decide.ts.ejs +1 -1
  37. package/src/codegen/templates/command/handle.specs.ts +46 -42
  38. package/src/codegen/templates/command/handle.ts.ejs +2 -2
  39. package/src/codegen/templates/command/mutation.resolver.specs.ts +12 -10
  40. package/src/codegen/templates/command/register.specs.ts +13 -11
  41. package/src/codegen/templates/query/projection.specs.specs.ts +64 -54
  42. package/src/codegen/templates/query/projection.specs.ts +56 -48
  43. package/src/codegen/templates/query/projection.specs.ts.ejs +1 -1
  44. package/src/codegen/templates/query/projection.ts.ejs +10 -10
  45. package/src/codegen/templates/query/query.resolver.specs.ts +92 -78
  46. package/src/codegen/templates/query/query.resolver.ts.ejs +2 -2
  47. package/src/codegen/templates/query/state.specs.ts +14 -12
  48. package/src/codegen/templates/react/react.specs.specs.ts +8 -6
  49. package/src/codegen/test-data/specVariant1.ts +18 -16
  50. package/.turbo/turbo-format.log +0 -4
  51. package/.turbo/turbo-lint.log +0 -4
  52. package/.turbo/turbo-test.log +0 -14
  53. package/.turbo/turbo-type-check.log +0 -4
  54. package/dist/src/codegen/scaffoldFromSchema.integration.specs.d.ts +0 -2
  55. package/dist/src/codegen/scaffoldFromSchema.integration.specs.d.ts.map +0 -1
  56. package/dist/src/codegen/scaffoldFromSchema.integration.specs.js +0 -59
  57. package/dist/src/codegen/scaffoldFromSchema.integration.specs.js.map +0 -1
package/package.json CHANGED
@@ -31,8 +31,8 @@
31
31
  "graphql-type-json": "^0.3.2",
32
32
  "uuid": "^11.0.0",
33
33
  "web-streams-polyfill": "^4.1.0",
34
- "@auto-engineer/narrative": "0.21.0",
35
- "@auto-engineer/message-bus": "0.21.0"
34
+ "@auto-engineer/narrative": "0.22.0",
35
+ "@auto-engineer/message-bus": "0.22.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
@@ -43,9 +43,9 @@
43
43
  "typescript": "^5.8.3",
44
44
  "vitest": "^3.2.4",
45
45
  "tsx": "^4.19.2",
46
- "@auto-engineer/cli": "0.21.0"
46
+ "@auto-engineer/cli": "0.22.0"
47
47
  },
48
- "version": "0.21.0",
48
+ "version": "0.22.0",
49
49
  "scripts": {
50
50
  "generate:server": "tsx src/cli/index.ts",
51
51
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts && rm -rf dist/src/codegen/templates && mkdir -p dist/src/codegen && cp -r src/codegen/templates dist/src/codegen/templates && cp src/server.ts dist/src && cp -r src/utils dist/src && cp -r src/domain dist/src",
@@ -64,12 +64,12 @@ function processStreamSink(item: unknown, exampleData: Record<string, unknown>)
64
64
 
65
65
  export function getStreamFromSink(slice: Slice): { streamPattern?: string; streamId?: string } {
66
66
  if (!('server' in slice)) return {};
67
- if (slice.server == null || !('data' in slice.server) || !Array.isArray(slice.server.data)) {
67
+ if (slice.server?.data?.items == null || !Array.isArray(slice.server.data.items)) {
68
68
  return {};
69
69
  }
70
70
  const gwtSpecs = extractGwtSpecsFromSlice(slice);
71
71
  const exampleData = extractExampleDataFromSpecs(slice, gwtSpecs);
72
- const serverData = slice.server.data;
72
+ const serverData = slice.server.data.items;
73
73
 
74
74
  for (const item of serverData) {
75
75
  const result = processStreamSink(item, exampleData);
@@ -26,7 +26,7 @@ function isProjectionOrigin(origin: unknown): origin is ProjectionOrigin {
26
26
 
27
27
  function extractProjectionField<K extends keyof ProjectionOrigin>(slice: Slice, fieldName: K): string | undefined {
28
28
  if (!('server' in slice)) return undefined;
29
- const dataSource = slice.server?.data?.[0];
29
+ const dataSource = slice.server?.data?.items?.[0];
30
30
  if (!hasOrigin(dataSource)) return undefined;
31
31
 
32
32
  const origin = dataSource.origin;
@@ -50,7 +50,7 @@ export function extractProjectionName(slice: Slice): string | undefined {
50
50
 
51
51
  export function extractProjectionSingleton(slice: Slice): boolean {
52
52
  if (!('server' in slice)) return false;
53
- const dataSource = slice.server?.data?.[0];
53
+ const dataSource = slice.server?.data?.items?.[0];
54
54
  if (!hasOrigin(dataSource)) return false;
55
55
 
56
56
  const origin = dataSource.origin;
@@ -16,13 +16,14 @@ function createStateMessage(stateName: string, allMessages: MessageDefinition[])
16
16
  };
17
17
  }
18
18
 
19
- function hasServerData(slice: Slice): slice is Slice & { server: { data: unknown[] } } {
19
+ function hasServerData(slice: Slice): slice is Slice & { server: { data: { items: unknown[] } } } {
20
20
  return (
21
21
  'server' in slice &&
22
22
  Boolean(slice.server) &&
23
23
  'data' in slice.server &&
24
- Array.isArray(slice.server.data) &&
25
- slice.server.data.length > 0
24
+ slice.server.data?.items != null &&
25
+ Array.isArray(slice.server.data.items) &&
26
+ slice.server.data.items.length > 0
26
27
  );
27
28
  }
28
29
 
@@ -31,7 +32,7 @@ export function extractStatesFromTarget(slice: Slice, allMessages: MessageDefini
31
32
  return [];
32
33
  }
33
34
 
34
- const targets = slice.server.data
35
+ const targets = slice.server.data.items
35
36
  .map((d) => (d as DataItem).target?.name)
36
37
  .filter((name): name is string => typeof name === 'string');
37
38
  const uniqueTargets = Array.from(new Set(targets));
@@ -47,7 +48,7 @@ export function extractStatesFromData(slice: Slice, allMessages: MessageDefiniti
47
48
  const states: Message[] = [];
48
49
  const seenStates = new Set<string>();
49
50
 
50
- for (const dataItem of slice.server.data) {
51
+ for (const dataItem of slice.server.data.items) {
51
52
  const item = dataItem as DataItem;
52
53
  if (!('origin' in item) || typeof item.target?.name !== 'string') {
53
54
  continue;
@@ -537,7 +537,7 @@ async function prepareTemplateData(
537
537
  messages: allMessages,
538
538
  message:
539
539
  slice.type === 'query' && allMessages
540
- ? allMessages.find((m) => m.name === slice.server?.data?.[0]?.target?.name)
540
+ ? allMessages.find((m) => m.name === slice.server?.data?.items?.[0]?.target?.name)
541
541
  : undefined,
542
542
  integrations,
543
543
  eventImportGroups,
@@ -419,43 +419,45 @@ describe('decide.ts.ejs', () => {
419
419
  },
420
420
  server: {
421
421
  description: '',
422
- data: [
423
- {
424
- target: {
425
- type: 'Command',
426
- name: 'SuggestItems',
427
- },
428
- destination: {
429
- type: 'integration',
430
- systems: ['AI'],
431
- message: {
432
- name: 'DoChat',
433
- type: 'command',
434
- },
435
- },
436
- _additionalInstructions: 'Ensure systemPrompt includes product catalogue guidance',
437
- _withState: {
422
+ data: {
423
+ items: [
424
+ {
438
425
  target: {
439
- type: 'State',
440
- name: 'Products',
426
+ type: 'Command',
427
+ name: 'SuggestItems',
441
428
  },
442
- origin: {
429
+ destination: {
443
430
  type: 'integration',
444
- systems: ['product-catalog'],
431
+ systems: ['AI'],
432
+ message: {
433
+ name: 'DoChat',
434
+ type: 'command',
435
+ },
436
+ },
437
+ _additionalInstructions: 'Ensure systemPrompt includes product catalogue guidance',
438
+ _withState: {
439
+ target: {
440
+ type: 'State',
441
+ name: 'Products',
442
+ },
443
+ origin: {
444
+ type: 'integration',
445
+ systems: ['product-catalog'],
446
+ },
445
447
  },
446
448
  },
447
- },
448
- {
449
- target: {
450
- type: 'Event',
451
- name: 'ItemsSuggested',
452
- },
453
- destination: {
454
- type: 'stream',
455
- pattern: 'session-${sessionId}',
449
+ {
450
+ target: {
451
+ type: 'Event',
452
+ name: 'ItemsSuggested',
453
+ },
454
+ destination: {
455
+ type: 'stream',
456
+ pattern: 'session-${sessionId}',
457
+ },
456
458
  },
457
- },
458
- ],
459
+ ],
460
+ },
459
461
  specs: [
460
462
  {
461
463
  type: 'gherkin',
@@ -9,7 +9,7 @@ const fallbackEvents = Object.values(gwtMapping).flatMap(scenarios =>
9
9
  );
10
10
  const uniqueEventTypes = [...new Set(fallbackEvents.map(e => pascalCase(e.eventRef)))];
11
11
 
12
- const integrationData = (slice.server?.data ?? []).filter(d => d.destination?.type === 'integration');
12
+ const integrationData = (slice.server?.data?.items ?? []).filter(d => d.destination?.type === 'integration');
13
13
  const integration = integrationData[0];
14
14
  const integrationReturnType = integration?._withState?.target?.name;
15
15
  const integrationReturnSystem = integration?._withState?.origin?.systems?.[0];
@@ -58,18 +58,20 @@ describe('generateScaffoldFilePlans', () => {
58
58
  ],
59
59
  },
60
60
  ],
61
- data: [
62
- {
63
- target: {
64
- type: 'Event',
65
- name: 'ListingCreated',
66
- },
67
- destination: {
68
- type: 'stream',
69
- pattern: 'listings-${propertyId}',
61
+ data: {
62
+ items: [
63
+ {
64
+ target: {
65
+ type: 'Event',
66
+ name: 'ListingCreated',
67
+ },
68
+ destination: {
69
+ type: 'stream',
70
+ pattern: 'listings-${propertyId}',
71
+ },
70
72
  },
71
- },
72
- ],
73
+ ],
74
+ },
73
75
  },
74
76
  },
75
77
  ],
@@ -149,43 +151,45 @@ describe('generateScaffoldFilePlans', () => {
149
151
  },
150
152
  server: {
151
153
  description: '',
152
- data: [
153
- {
154
- target: {
155
- type: 'Command',
156
- name: 'SuggestItems',
157
- },
158
- destination: {
159
- type: 'integration',
160
- systems: ['AI'],
161
- message: {
162
- name: 'DoChat',
163
- type: 'command',
164
- },
165
- },
166
- _additionalInstructions: 'Ensure systemPrompt includes product catalogue guidance',
167
- _withState: {
154
+ data: {
155
+ items: [
156
+ {
168
157
  target: {
169
- type: 'State',
170
- name: 'Products',
158
+ type: 'Command',
159
+ name: 'SuggestItems',
171
160
  },
172
- origin: {
161
+ destination: {
173
162
  type: 'integration',
174
- systems: ['product-catalog'],
163
+ systems: ['AI'],
164
+ message: {
165
+ name: 'DoChat',
166
+ type: 'command',
167
+ },
168
+ },
169
+ _additionalInstructions: 'Ensure systemPrompt includes product catalogue guidance',
170
+ _withState: {
171
+ target: {
172
+ type: 'State',
173
+ name: 'Products',
174
+ },
175
+ origin: {
176
+ type: 'integration',
177
+ systems: ['product-catalog'],
178
+ },
175
179
  },
176
180
  },
177
- },
178
- {
179
- target: {
180
- type: 'Event',
181
- name: 'ItemsSuggested',
182
- },
183
- destination: {
184
- type: 'stream',
185
- pattern: 'session-${sessionId}',
181
+ {
182
+ target: {
183
+ type: 'Event',
184
+ name: 'ItemsSuggested',
185
+ },
186
+ destination: {
187
+ type: 'stream',
188
+ pattern: 'session-${sessionId}',
189
+ },
186
190
  },
187
- },
188
- ],
191
+ ],
192
+ },
189
193
  specs: [
190
194
  {
191
195
  type: 'gherkin',
@@ -1,5 +1,5 @@
1
1
  <%
2
- const integrationData = (slice.server?.data ?? []).filter(d => d.destination?.type === 'integration');
2
+ const integrationData = (slice.server?.data?.items ?? []).filter(d => d.destination?.type === 'integration');
3
3
 
4
4
  const integrationImports = new Map();
5
5
  const integrationSideEffectImports = new Set();
@@ -23,7 +23,7 @@ for (const d of integrationData) {
23
23
  }
24
24
  }
25
25
 
26
- const additionalInstructions = (slice.server?.data ?? [])
26
+ const additionalInstructions = (slice.server?.data?.items ?? [])
27
27
  .map(d => d._additionalInstructions)
28
28
  .filter(Boolean);
29
29
 
@@ -153,16 +153,18 @@ describe('mutation.resolver.ts.ejs', () => {
153
153
  'mutation AnswerQuestion($input: AnswerQuestionInput!) {\\n answerQuestion(input: $input) {\\n success\\n }\\n}',
154
154
  server: {
155
155
  description: '',
156
- data: [
157
- {
158
- target: { type: 'Event', name: 'QuestionAnswered' },
159
- destination: { type: 'stream', pattern: 'questionnaire-participantId' },
160
- },
161
- {
162
- target: { type: 'Event', name: 'QuestionnaireEditRejected' },
163
- destination: { type: 'stream', pattern: 'questionnaire-participantId' },
164
- },
165
- ],
156
+ data: {
157
+ items: [
158
+ {
159
+ target: { type: 'Event', name: 'QuestionAnswered' },
160
+ destination: { type: 'stream', pattern: 'questionnaire-participantId' },
161
+ },
162
+ {
163
+ target: { type: 'Event', name: 'QuestionnaireEditRejected' },
164
+ destination: { type: 'stream', pattern: 'questionnaire-participantId' },
165
+ },
166
+ ],
167
+ },
166
168
  specs: [
167
169
  {
168
170
  type: 'gherkin',
@@ -59,18 +59,20 @@ describe('generateScaffoldFilePlans', () => {
59
59
  ],
60
60
  },
61
61
  ],
62
- data: [
63
- {
64
- target: {
65
- type: 'Event',
66
- name: 'ListingCreated',
67
- },
68
- destination: {
69
- type: 'stream',
70
- pattern: 'listings-${propertyId}',
62
+ data: {
63
+ items: [
64
+ {
65
+ target: {
66
+ type: 'Event',
67
+ name: 'ListingCreated',
68
+ },
69
+ destination: {
70
+ type: 'stream',
71
+ pattern: 'listings-${propertyId}',
72
+ },
71
73
  },
72
- },
73
- ],
74
+ ],
75
+ },
74
76
  },
75
77
  },
76
78
  ],
@@ -83,19 +83,21 @@ describe('projection.specs.ts.ejs', () => {
83
83
  client: { specs: [] },
84
84
  server: {
85
85
  description: '',
86
- data: [
87
- {
88
- origin: {
89
- type: 'projection',
90
- idField: 'propertyId',
91
- name: 'AvailablePropertiesProjection',
92
- },
93
- target: {
94
- type: 'State',
95
- name: 'AvailableListings',
86
+ data: {
87
+ items: [
88
+ {
89
+ origin: {
90
+ type: 'projection',
91
+ idField: 'propertyId',
92
+ name: 'AvailablePropertiesProjection',
93
+ },
94
+ target: {
95
+ type: 'State',
96
+ name: 'AvailableListings',
97
+ },
96
98
  },
97
- },
98
- ],
99
+ ],
100
+ },
99
101
  specs: [
100
102
  {
101
103
  type: 'gherkin',
@@ -261,19 +263,21 @@ describe('projection.specs.ts.ejs', () => {
261
263
  client: { specs: [] },
262
264
  server: {
263
265
  description: '',
264
- data: [
265
- {
266
- target: {
267
- type: 'State',
268
- name: 'QuestionnaireProgress',
269
- },
270
- origin: {
271
- type: 'projection',
272
- name: 'Questionnaires',
273
- idField: 'questionnaire-participantId',
266
+ data: {
267
+ items: [
268
+ {
269
+ target: {
270
+ type: 'State',
271
+ name: 'QuestionnaireProgress',
272
+ },
273
+ origin: {
274
+ type: 'projection',
275
+ name: 'Questionnaires',
276
+ idField: 'questionnaire-participantId',
277
+ },
274
278
  },
275
- },
276
- ],
279
+ ],
280
+ },
277
281
  specs: [
278
282
  {
279
283
  type: 'gherkin',
@@ -544,12 +548,14 @@ describe('projection.specs.ts.ejs', () => {
544
548
  ],
545
549
  },
546
550
  ],
547
- data: [
548
- {
549
- origin: { name: 'Questionnaires', idField: 'questionnaireId-participantId' },
550
- target: { name: 'QuestionnaireProgress' },
551
- },
552
- ],
551
+ data: {
552
+ items: [
553
+ {
554
+ origin: { name: 'Questionnaires', idField: 'questionnaireId-participantId' },
555
+ target: { name: 'QuestionnaireProgress' },
556
+ },
557
+ ],
558
+ },
553
559
  },
554
560
  },
555
561
  ],
@@ -702,19 +708,21 @@ describe('projection.specs.ts.ejs', () => {
702
708
  client: { specs: [] },
703
709
  server: {
704
710
  description: '',
705
- data: [
706
- {
707
- target: {
708
- type: 'State',
709
- name: 'TodoSummary',
710
- },
711
- origin: {
712
- type: 'projection',
713
- name: 'TodoSummaryProjection',
714
- singleton: true,
711
+ data: {
712
+ items: [
713
+ {
714
+ target: {
715
+ type: 'State',
716
+ name: 'TodoSummary',
717
+ },
718
+ origin: {
719
+ type: 'projection',
720
+ name: 'TodoSummaryProjection',
721
+ singleton: true,
722
+ },
715
723
  },
716
- },
717
- ],
724
+ ],
725
+ },
718
726
  specs: [
719
727
  {
720
728
  type: 'gherkin',
@@ -887,19 +895,21 @@ describe('projection.specs.ts.ejs', () => {
887
895
  client: { specs: [] },
888
896
  server: {
889
897
  description: '',
890
- data: [
891
- {
892
- target: {
893
- type: 'State',
894
- name: 'UserProject',
895
- },
896
- origin: {
897
- type: 'projection',
898
- name: 'UserProjectsProjection',
899
- idField: ['userId', 'projectId'],
898
+ data: {
899
+ items: [
900
+ {
901
+ target: {
902
+ type: 'State',
903
+ name: 'UserProject',
904
+ },
905
+ origin: {
906
+ type: 'projection',
907
+ name: 'UserProjectsProjection',
908
+ idField: ['userId', 'projectId'],
909
+ },
900
910
  },
901
- },
902
- ],
911
+ ],
912
+ },
903
913
  specs: [
904
914
  {
905
915
  type: 'gherkin',