@auto-engineer/server-generator-apollo-emmett 0.1.4 → 0.8.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 (132) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +14 -171
  3. package/.turbo/turbo-type-check.log +4 -5
  4. package/CHANGELOG.md +19 -0
  5. package/dist/codegen/extract/commands.d.ts +11 -5
  6. package/dist/codegen/extract/commands.d.ts.map +1 -1
  7. package/dist/codegen/extract/commands.js +27 -12
  8. package/dist/codegen/extract/commands.js.map +1 -1
  9. package/dist/codegen/extract/data-sink.d.ts.map +1 -1
  10. package/dist/codegen/extract/data-sink.js +52 -28
  11. package/dist/codegen/extract/data-sink.js.map +1 -1
  12. package/dist/codegen/extract/gwt.d.ts.map +1 -1
  13. package/dist/codegen/extract/gwt.js +37 -6
  14. package/dist/codegen/extract/gwt.js.map +1 -1
  15. package/dist/codegen/extract/messages.d.ts.map +1 -1
  16. package/dist/codegen/extract/messages.js +38 -6
  17. package/dist/codegen/extract/messages.js.map +1 -1
  18. package/dist/codegen/extract/query.d.ts.map +1 -1
  19. package/dist/codegen/extract/query.js +9 -2
  20. package/dist/codegen/extract/query.js.map +1 -1
  21. package/dist/codegen/scaffoldFromSchema.d.ts.map +1 -1
  22. package/dist/codegen/scaffoldFromSchema.js +21 -6
  23. package/dist/codegen/scaffoldFromSchema.js.map +1 -1
  24. package/dist/codegen/templates/command/commands.specs.ts +28 -19
  25. package/dist/codegen/templates/command/decide.specs.specs.ts +75 -57
  26. package/dist/codegen/templates/command/decide.specs.ts +147 -110
  27. package/dist/codegen/templates/command/events.specs.ts +38 -29
  28. package/dist/codegen/templates/command/evolve.specs.ts +33 -24
  29. package/dist/codegen/templates/command/handle.specs.ts +61 -43
  30. package/dist/codegen/templates/command/mutation.resolver.specs.ts +28 -19
  31. package/dist/codegen/templates/command/register.specs.ts +34 -25
  32. package/dist/codegen/templates/command/state.specs.ts +34 -25
  33. package/dist/codegen/templates/query/projection.specs.specs..ts +100 -80
  34. package/dist/codegen/templates/query/projection.specs.ts +101 -81
  35. package/dist/codegen/templates/query/query.resolver.specs.ts +2 -2
  36. package/dist/codegen/templates/query/state.specs.ts +1 -1
  37. package/dist/codegen/templates/react/react.specs.specs.ts +86 -68
  38. package/dist/codegen/templates/react/react.specs.ts +123 -96
  39. package/dist/codegen/templates/react/react.specs.ts.ejs +9 -1
  40. package/dist/codegen/templates/react/react.ts.ejs +8 -1
  41. package/dist/codegen/templates/react/register.specs.ts +123 -96
  42. package/dist/codegen/templates/react/register.ts.ejs +8 -1
  43. package/dist/codegen/test-data/specVariant1.d.ts.map +1 -1
  44. package/dist/codegen/test-data/specVariant1.js +92 -65
  45. package/dist/codegen/test-data/specVariant1.js.map +1 -1
  46. package/dist/codegen/types.d.ts +4 -4
  47. package/dist/codegen/types.d.ts.map +1 -1
  48. package/dist/commands/generate-server.d.ts +11 -45
  49. package/dist/commands/generate-server.d.ts.map +1 -1
  50. package/dist/commands/generate-server.js +29 -24
  51. package/dist/commands/generate-server.js.map +1 -1
  52. package/dist/index.d.ts +11 -2
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +2 -2
  55. package/dist/index.js.map +1 -1
  56. package/package.json +9 -9
  57. package/src/codegen/extract/commands.ts +48 -19
  58. package/src/codegen/extract/data-sink.ts +68 -31
  59. package/src/codegen/extract/gwt.ts +45 -10
  60. package/src/codegen/extract/messages.ts +49 -7
  61. package/src/codegen/extract/query.ts +15 -2
  62. package/src/codegen/scaffoldFromSchema.ts +27 -6
  63. package/src/codegen/templates/command/commands.specs.ts +28 -19
  64. package/src/codegen/templates/command/decide.specs.specs.ts +75 -57
  65. package/src/codegen/templates/command/decide.specs.ts +147 -110
  66. package/src/codegen/templates/command/events.specs.ts +38 -29
  67. package/src/codegen/templates/command/evolve.specs.ts +33 -24
  68. package/src/codegen/templates/command/handle.specs.ts +61 -43
  69. package/src/codegen/templates/command/mutation.resolver.specs.ts +28 -19
  70. package/src/codegen/templates/command/register.specs.ts +34 -25
  71. package/src/codegen/templates/command/state.specs.ts +34 -25
  72. package/src/codegen/templates/query/projection.specs.specs..ts +100 -80
  73. package/src/codegen/templates/query/projection.specs.ts +101 -81
  74. package/src/codegen/templates/query/query.resolver.specs.ts +2 -2
  75. package/src/codegen/templates/query/state.specs.ts +1 -1
  76. package/src/codegen/templates/react/react.specs.specs.ts +86 -68
  77. package/src/codegen/templates/react/react.specs.ts +123 -96
  78. package/src/codegen/templates/react/react.specs.ts.ejs +9 -1
  79. package/src/codegen/templates/react/react.ts.ejs +8 -1
  80. package/src/codegen/templates/react/register.specs.ts +123 -96
  81. package/src/codegen/templates/react/register.ts.ejs +8 -1
  82. package/src/codegen/test-data/specVariant1.ts +92 -65
  83. package/src/codegen/types.ts +4 -4
  84. package/src/commands/generate-server.ts +29 -28
  85. package/src/index.ts +8 -2
  86. package/tsconfig.tsbuildinfo +1 -1
  87. package/.tmp/server-test-output/server/package.json +0 -26
  88. package/.tmp/server-test-output/server/scripts/generate-schema.ts +0 -31
  89. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/commands.ts +0 -8
  90. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/decide.specs.ts +0 -36
  91. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/decide.ts +0 -33
  92. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/events.ts +0 -10
  93. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/evolve.ts +0 -28
  94. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/handle.ts +0 -24
  95. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/mutation.resolver.ts +0 -25
  96. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/register.ts +0 -7
  97. package/.tmp/server-test-output/server/src/domain/flows/add-item/create-item/state.ts +0 -47
  98. package/.tmp/server-test-output/server/src/domain/flows/add-item/get-available-items/projection.specs.ts +0 -46
  99. package/.tmp/server-test-output/server/src/domain/flows/add-item/get-available-items/projection.ts +0 -38
  100. package/.tmp/server-test-output/server/src/domain/flows/add-item/get-available-items/query.resolver.ts +0 -39
  101. package/.tmp/server-test-output/server/src/domain/flows/add-item/get-available-items/state.ts +0 -5
  102. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/commands.ts +0 -8
  103. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/decide.specs.ts +0 -36
  104. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/decide.ts +0 -33
  105. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/events.ts +0 -3
  106. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/evolve.ts +0 -28
  107. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/handle.ts +0 -24
  108. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/mutation.resolver.ts +0 -25
  109. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/register.ts +0 -7
  110. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-new-item/state.ts +0 -47
  111. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-on-new-item/react.specs.ts +0 -49
  112. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-on-new-item/react.ts +0 -43
  113. package/.tmp/server-test-output/server/src/domain/flows/add-item/notify-on-new-item/register.ts +0 -24
  114. package/.tmp/server-test-output/server/src/domain/shared/ReadModel.ts +0 -26
  115. package/.tmp/server-test-output/server/src/domain/shared/index.ts +0 -4
  116. package/.tmp/server-test-output/server/src/domain/shared/reactorSpecification.ts +0 -257
  117. package/.tmp/server-test-output/server/src/domain/shared/sendCommand.ts +0 -21
  118. package/.tmp/server-test-output/server/src/domain/shared/types.ts +0 -31
  119. package/.tmp/server-test-output/server/src/server.ts +0 -43
  120. package/.tmp/server-test-output/server/src/utils/index.ts +0 -3
  121. package/.tmp/server-test-output/server/src/utils/loadProjections.ts +0 -30
  122. package/.tmp/server-test-output/server/src/utils/loadRegisterFiles.ts +0 -41
  123. package/.tmp/server-test-output/server/src/utils/loadResolvers.ts +0 -36
  124. package/.tmp/server-test-output/server/tsconfig.json +0 -19
  125. package/.tmp/server-test-output/server/vitest.config.ts +0 -7
  126. package/.turbo/turbo-format.log +0 -57
  127. package/.turbo/turbo-lint.log +0 -5
  128. package/dist/cli-manifest.d.ts +0 -3
  129. package/dist/cli-manifest.d.ts.map +0 -1
  130. package/dist/cli-manifest.js +0 -35
  131. package/dist/cli-manifest.js.map +0 -1
  132. package/src/cli-manifest.ts +0 -37
@@ -272,8 +272,19 @@ function findEventSource(flows: Flow[], eventType: string): { flowName: string;
272
272
  for (const slice of flow.slices) {
273
273
  if (!['command', 'react'].includes(slice.type)) continue;
274
274
 
275
- const gwt = slice.server?.gwt ?? [];
276
- if (gwt.some((g) => g.then.some((t) => 'eventRef' in t && t.eventRef === eventType))) {
275
+ const specs = slice.server?.specs;
276
+ const rules = specs?.rules;
277
+ const gwtSpecs =
278
+ Array.isArray(rules) && rules.length > 0
279
+ ? rules.flatMap((rule) =>
280
+ rule.examples.map((example) => ({
281
+ given: example.given,
282
+ when: example.when,
283
+ then: example.then,
284
+ })),
285
+ )
286
+ : [];
287
+ if (gwtSpecs.some((g) => g.then.some((t) => 'eventRef' in t && t.eventRef === eventType))) {
277
288
  debugSlice(' Found event source in flow: %s, slice: %s', flow.name, slice.name);
278
289
  return { flowName: flow.name, sliceName: slice.name };
279
290
  }
@@ -304,8 +315,19 @@ function findCommandSource(flows: Flow[], commandType: string): { flowName: stri
304
315
  for (const slice of flow.slices) {
305
316
  if (slice.type !== 'command') continue;
306
317
 
307
- const gwt = slice.server?.gwt ?? [];
308
- if (gwt.some((g) => 'commandRef' in g.when && g.when.commandRef === commandType)) {
318
+ const specs = slice.server?.specs;
319
+ const rules = specs?.rules;
320
+ const gwtSpecs =
321
+ Array.isArray(rules) && rules.length > 0
322
+ ? rules.flatMap((rule) =>
323
+ rule.examples.map((example) => ({
324
+ given: example.given,
325
+ when: example.when,
326
+ then: example.then,
327
+ })),
328
+ )
329
+ : [];
330
+ if (gwtSpecs.some((g) => !Array.isArray(g.when) && 'commandRef' in g.when && g.when.commandRef === commandType)) {
309
331
  debugSlice(' Found command source in flow: %s, slice: %s', flow.name, slice.name);
310
332
  return { flowName: flow.name, sliceName: slice.name };
311
333
  }
@@ -339,7 +361,7 @@ async function generateFilesForSlice(
339
361
  debugSlice(' Commands: %d', extracted.commands.length);
340
362
  debugSlice(' Events: %d', extracted.events.length);
341
363
  debugSlice(' States: %d', extracted.states.length);
342
- console.log(
364
+ debugSlice(
343
365
  '💡 Events for slice',
344
366
  slice.name,
345
367
  extracted.events.map((e) => e.type),
@@ -416,7 +438,6 @@ export async function writeScaffoldFilePlans(plans: FilePlan[]) {
416
438
  await fs.writeFile(outputPath, contents, 'utf8');
417
439
  writtenCount++;
418
440
  debugPlan(' File written successfully (%d/%d)', writtenCount, plans.length);
419
- console.log(`✅ Created: ${outputPath}`);
420
441
  }
421
442
 
422
443
  debugPlan('All %d files written successfully', writtenCount);
@@ -19,26 +19,35 @@ describe('commands.ts.ejs', () => {
19
19
  },
20
20
  server: {
21
21
  description: 'test',
22
- gwt: [
23
- {
24
- when: {
25
- commandRef: 'CreateListing',
26
- exampleData: {
27
- propertyId: 'listing_123',
28
- title: 'nice apartment',
29
- pricePerNight: 250,
30
- maxGuests: 4,
31
- amenities: ['wifi', 'kitchen', 'parking'],
32
- available: true,
33
- tags: ['sea view', 'balcony'],
34
- rating: 4.8,
35
- metadata: { petsAllowed: true },
36
- listedAt: '2024-01-15T10:00:00Z',
37
- },
22
+ specs: {
23
+ name: 'Create listing command',
24
+ rules: [
25
+ {
26
+ description: 'Should accept valid listing data',
27
+ examples: [
28
+ {
29
+ description: 'User creates listing with valid data',
30
+ when: {
31
+ commandRef: 'CreateListing',
32
+ exampleData: {
33
+ propertyId: 'listing_123',
34
+ title: 'nice apartment',
35
+ pricePerNight: 250,
36
+ maxGuests: 4,
37
+ amenities: ['wifi', 'kitchen', 'parking'],
38
+ available: true,
39
+ tags: ['sea view', 'balcony'],
40
+ rating: 4.8,
41
+ metadata: { petsAllowed: true },
42
+ listedAt: '2024-01-15T10:00:00Z',
43
+ },
44
+ },
45
+ then: [],
46
+ },
47
+ ],
38
48
  },
39
- then: [],
40
- },
41
- ],
49
+ ],
50
+ },
42
51
  },
43
52
  },
44
53
  ],
@@ -16,36 +16,45 @@ describe('spec.ts.ejs', () => {
16
16
  client: { description: '', specs: [] },
17
17
  server: {
18
18
  description: '',
19
- gwt: [
20
- {
21
- when: {
22
- commandRef: 'CreateListing',
23
- exampleData: {
24
- propertyId: 'listing_123',
25
- title: 'blah',
26
- pricePerNight: 250,
27
- maxGuests: 4,
28
- amenities: ['wifi', 'kitchen'],
29
- available: true,
30
- tags: ['some tag'],
31
- rating: 4.8,
32
- metadata: { foo: 'bar' },
33
- listedAt: '2024-01-15T10:00:00Z',
34
- },
35
- },
36
- then: [
37
- {
38
- eventRef: 'ListingCreated',
39
- exampleData: {
40
- propertyId: 'listing_123',
41
- listedAt: '2024-01-15T10:00:00Z',
42
- rating: 4.8,
43
- metadata: { foo: 'bar' },
19
+ specs: {
20
+ name: 'Create listing spec',
21
+ rules: [
22
+ {
23
+ description: 'Should create listing successfully',
24
+ examples: [
25
+ {
26
+ description: 'User creates listing with valid data',
27
+ when: {
28
+ commandRef: 'CreateListing',
29
+ exampleData: {
30
+ propertyId: 'listing_123',
31
+ title: 'blah',
32
+ pricePerNight: 250,
33
+ maxGuests: 4,
34
+ amenities: ['wifi', 'kitchen'],
35
+ available: true,
36
+ tags: ['some tag'],
37
+ rating: 4.8,
38
+ metadata: { foo: 'bar' },
39
+ listedAt: '2024-01-15T10:00:00Z',
40
+ },
41
+ },
42
+ then: [
43
+ {
44
+ eventRef: 'ListingCreated',
45
+ exampleData: {
46
+ propertyId: 'listing_123',
47
+ listedAt: '2024-01-15T10:00:00Z',
48
+ rating: 4.8,
49
+ metadata: { foo: 'bar' },
50
+ },
51
+ },
52
+ ],
44
53
  },
45
- },
46
- ],
47
- },
48
- ],
54
+ ],
55
+ },
56
+ ],
57
+ },
49
58
  },
50
59
  },
51
60
  ],
@@ -147,36 +156,45 @@ describe('spec.ts.ejs', () => {
147
156
  client: { description: '', specs: [] },
148
157
  server: {
149
158
  description: '',
150
- gwt: [
151
- {
152
- given: [
153
- {
154
- eventRef: 'ListingCreated',
155
- exampleData: {
156
- propertyId: 'listing_123',
157
- listedAt: '2024-01-15T10:00:00Z',
158
- rating: 4.8,
159
- metadata: { foo: 'bar' },
159
+ specs: {
160
+ name: 'Remove listing spec',
161
+ rules: [
162
+ {
163
+ description: 'Should remove existing listing',
164
+ examples: [
165
+ {
166
+ description: 'Existing listing can be removed',
167
+ given: [
168
+ {
169
+ eventRef: 'ListingCreated',
170
+ exampleData: {
171
+ propertyId: 'listing_123',
172
+ listedAt: '2024-01-15T10:00:00Z',
173
+ rating: 4.8,
174
+ metadata: { foo: 'bar' },
175
+ },
176
+ },
177
+ ],
178
+ when: {
179
+ commandRef: 'RemoveListing',
180
+ exampleData: {
181
+ propertyId: 'listing_123',
182
+ },
183
+ },
184
+ then: [
185
+ {
186
+ eventRef: 'ListingRemoved',
187
+ exampleData: {
188
+ propertyId: 'listing_123',
189
+ removedAt: '2024-01-16T10:00:00Z',
190
+ },
191
+ },
192
+ ],
160
193
  },
161
- },
162
- ],
163
- when: {
164
- commandRef: 'RemoveListing',
165
- exampleData: {
166
- propertyId: 'listing_123',
167
- },
194
+ ],
168
195
  },
169
- then: [
170
- {
171
- eventRef: 'ListingRemoved',
172
- exampleData: {
173
- propertyId: 'listing_123',
174
- removedAt: '2024-01-16T10:00:00Z',
175
- },
176
- },
177
- ],
178
- },
179
- ],
196
+ ],
197
+ },
180
198
  },
181
199
  },
182
200
  ],
@@ -19,31 +19,40 @@ describe('decide.ts.ejs', () => {
19
19
  },
20
20
  server: {
21
21
  description: 'test',
22
- gwt: [
23
- {
24
- when: {
25
- commandRef: 'CreateListing',
26
- exampleData: {
27
- propertyId: 'listing_123',
28
- title: 'Some apartment',
29
- listedAt: '2024-01-15T10:00:00Z',
30
- rating: 4.8,
31
- metadata: { foo: 'bar' },
32
- },
33
- },
34
- then: [
35
- {
36
- eventRef: 'ListingCreated',
37
- exampleData: {
38
- propertyId: 'listing_123',
39
- listedAt: '2024-01-15T10:00:00Z',
40
- rating: 4.8,
41
- metadata: { foo: 'bar' },
22
+ specs: {
23
+ name: 'Create listing command',
24
+ rules: [
25
+ {
26
+ description: 'Should create listing with valid data',
27
+ examples: [
28
+ {
29
+ description: 'User creates listing successfully',
30
+ when: {
31
+ commandRef: 'CreateListing',
32
+ exampleData: {
33
+ propertyId: 'listing_123',
34
+ title: 'Some apartment',
35
+ listedAt: '2024-01-15T10:00:00Z',
36
+ rating: 4.8,
37
+ metadata: { foo: 'bar' },
38
+ },
39
+ },
40
+ then: [
41
+ {
42
+ eventRef: 'ListingCreated',
43
+ exampleData: {
44
+ propertyId: 'listing_123',
45
+ listedAt: '2024-01-15T10:00:00Z',
46
+ rating: 4.8,
47
+ metadata: { foo: 'bar' },
48
+ },
49
+ },
50
+ ],
42
51
  },
43
- },
44
- ],
45
- },
46
- ],
52
+ ],
53
+ },
54
+ ],
55
+ },
47
56
  },
48
57
  },
49
58
  ],
@@ -121,34 +130,43 @@ describe('decide.ts.ejs', () => {
121
130
  },
122
131
  server: {
123
132
  description: 'test',
124
- gwt: [
125
- {
126
- given: [
127
- {
128
- eventRef: 'ListingCreated',
129
- exampleData: {
130
- propertyId: 'listing_123',
131
- listedAt: '2024-01-15T10:00:00Z',
133
+ specs: {
134
+ name: 'Remove listing command',
135
+ rules: [
136
+ {
137
+ description: 'Should remove existing listing',
138
+ examples: [
139
+ {
140
+ description: 'Existing listing can be removed',
141
+ given: [
142
+ {
143
+ eventRef: 'ListingCreated',
144
+ exampleData: {
145
+ propertyId: 'listing_123',
146
+ listedAt: '2024-01-15T10:00:00Z',
147
+ },
148
+ },
149
+ ],
150
+ when: {
151
+ commandRef: 'RemoveListing',
152
+ exampleData: {
153
+ propertyId: 'listing_123',
154
+ },
155
+ },
156
+ then: [
157
+ {
158
+ eventRef: 'ListingRemoved',
159
+ exampleData: {
160
+ propertyId: 'listing_123',
161
+ removedAt: '2024-01-16T12:00:00Z',
162
+ },
163
+ },
164
+ ],
132
165
  },
133
- },
134
- ],
135
- when: {
136
- commandRef: 'RemoveListing',
137
- exampleData: {
138
- propertyId: 'listing_123',
139
- },
166
+ ],
140
167
  },
141
- then: [
142
- {
143
- eventRef: 'ListingRemoved',
144
- exampleData: {
145
- propertyId: 'listing_123',
146
- removedAt: '2024-01-16T12:00:00Z',
147
- },
148
- },
149
- ],
150
- },
151
- ],
168
+ ],
169
+ },
152
170
  },
153
171
  },
154
172
  ],
@@ -238,49 +256,59 @@ describe('decide.ts.ejs', () => {
238
256
  },
239
257
  server: {
240
258
  description: 'test',
241
- gwt: [
242
- {
243
- when: {
244
- commandRef: 'CreateListing',
245
- exampleData: {
246
- propertyId: 'listing_123',
247
- title: 'Some Apartment',
248
- listedAt: '2024-01-15T10:00:00Z',
249
- rating: 4.8,
250
- metadata: { foo: 'bar' },
251
- },
252
- },
253
- then: [
254
- {
255
- eventRef: 'ListingCreated',
256
- exampleData: {
257
- propertyId: 'listing_123',
258
- listedAt: '2024-01-15T10:00:00Z',
259
- rating: 4.8,
260
- metadata: { foo: 'bar' },
259
+ specs: {
260
+ name: 'Create listing command',
261
+ rules: [
262
+ {
263
+ description: 'Should handle multiple scenarios including errors',
264
+ examples: [
265
+ {
266
+ description: 'User creates listing successfully',
267
+ when: {
268
+ commandRef: 'CreateListing',
269
+ exampleData: {
270
+ propertyId: 'listing_123',
271
+ title: 'Some Apartment',
272
+ listedAt: '2024-01-15T10:00:00Z',
273
+ rating: 4.8,
274
+ metadata: { foo: 'bar' },
275
+ },
276
+ },
277
+ then: [
278
+ {
279
+ eventRef: 'ListingCreated',
280
+ exampleData: {
281
+ propertyId: 'listing_123',
282
+ listedAt: '2024-01-15T10:00:00Z',
283
+ rating: 4.8,
284
+ metadata: { foo: 'bar' },
285
+ },
286
+ },
287
+ ],
261
288
  },
262
- },
263
- ],
264
- },
265
- {
266
- when: {
267
- commandRef: 'CreateListing',
268
- exampleData: {
269
- propertyId: 'listing_123',
270
- title: '',
271
- listedAt: '2024-01-15T10:00:00Z',
272
- rating: 4.8,
273
- metadata: {},
274
- },
289
+ {
290
+ description: 'User creates listing with empty title should fail',
291
+ when: {
292
+ commandRef: 'CreateListing',
293
+ exampleData: {
294
+ propertyId: 'listing_123',
295
+ title: '',
296
+ listedAt: '2024-01-15T10:00:00Z',
297
+ rating: 4.8,
298
+ metadata: {},
299
+ },
300
+ },
301
+ then: [
302
+ {
303
+ errorType: 'ValidationError',
304
+ message: 'Title must not be empty',
305
+ },
306
+ ],
307
+ },
308
+ ],
275
309
  },
276
- then: [
277
- {
278
- errorType: 'ValidationError',
279
- message: 'Title must not be empty',
280
- },
281
- ],
282
- },
283
- ],
310
+ ],
311
+ },
284
312
  },
285
313
  },
286
314
  ],
@@ -411,26 +439,35 @@ describe('decide.ts.ejs', () => {
411
439
  },
412
440
  },
413
441
  ],
414
- gwt: [
415
- {
416
- when: {
417
- commandRef: 'SuggestItems',
418
- exampleData: {
419
- sessionId: 'session-123',
420
- prompt: 'What should I buy?',
421
- },
422
- },
423
- then: [
424
- {
425
- eventRef: 'ItemsSuggested',
426
- exampleData: {
427
- sessionId: 'session-123',
428
- items: [],
442
+ specs: {
443
+ name: 'Suggest items command',
444
+ rules: [
445
+ {
446
+ description: 'Should suggest items successfully',
447
+ examples: [
448
+ {
449
+ description: 'User requests item suggestions',
450
+ when: {
451
+ commandRef: 'SuggestItems',
452
+ exampleData: {
453
+ sessionId: 'session-123',
454
+ prompt: 'What should I buy?',
455
+ },
456
+ },
457
+ then: [
458
+ {
459
+ eventRef: 'ItemsSuggested',
460
+ exampleData: {
461
+ sessionId: 'session-123',
462
+ items: [],
463
+ },
464
+ },
465
+ ],
429
466
  },
430
- },
431
- ],
432
- },
433
- ],
467
+ ],
468
+ },
469
+ ],
470
+ },
434
471
  },
435
472
  },
436
473
  ],
@@ -19,36 +19,45 @@ describe('events.ts.ejs', () => {
19
19
  },
20
20
  server: {
21
21
  description: 'test',
22
- gwt: [
23
- {
24
- when: {
25
- commandRef: 'CreateListing',
26
- exampleData: {
27
- propertyId: 'listing_123',
28
- title: 'blah',
29
- pricePerNight: 250,
30
- maxGuests: 4,
31
- amenities: ['wifi', 'kitchen'],
32
- available: true,
33
- tags: ['some tag'],
34
- rating: 4.8,
35
- metadata: { foo: 'bar' },
36
- listedAt: '2024-01-15T10:00:00Z',
37
- },
38
- },
39
- then: [
40
- {
41
- eventRef: 'ListingCreated',
42
- exampleData: {
43
- propertyId: 'listing_123',
44
- listedAt: '2024-01-15T10:00:00Z',
45
- rating: 4.8,
46
- metadata: { foo: 'bar' },
22
+ specs: {
23
+ name: 'Create listing command',
24
+ rules: [
25
+ {
26
+ description: 'Should create listing successfully',
27
+ examples: [
28
+ {
29
+ description: 'User creates listing with valid data',
30
+ when: {
31
+ commandRef: 'CreateListing',
32
+ exampleData: {
33
+ propertyId: 'listing_123',
34
+ title: 'blah',
35
+ pricePerNight: 250,
36
+ maxGuests: 4,
37
+ amenities: ['wifi', 'kitchen'],
38
+ available: true,
39
+ tags: ['some tag'],
40
+ rating: 4.8,
41
+ metadata: { foo: 'bar' },
42
+ listedAt: '2024-01-15T10:00:00Z',
43
+ },
44
+ },
45
+ then: [
46
+ {
47
+ eventRef: 'ListingCreated',
48
+ exampleData: {
49
+ propertyId: 'listing_123',
50
+ listedAt: '2024-01-15T10:00:00Z',
51
+ rating: 4.8,
52
+ metadata: { foo: 'bar' },
53
+ },
54
+ },
55
+ ],
47
56
  },
48
- },
49
- ],
50
- },
51
- ],
57
+ ],
58
+ },
59
+ ],
60
+ },
52
61
  },
53
62
  },
54
63
  ],