@auto-engineer/server-generator-apollo-emmett 1.147.0 → 1.149.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 (30) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +6 -6
  3. package/.turbo/turbo-type-check.log +1 -1
  4. package/CHANGELOG.md +53 -0
  5. package/README.md +174 -103
  6. package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
  7. package/dist/src/codegen/scaffoldFromSchema.js +4 -0
  8. package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
  9. package/dist/src/codegen/templateHelpers.d.ts +11 -0
  10. package/dist/src/codegen/templateHelpers.d.ts.map +1 -0
  11. package/dist/src/codegen/templateHelpers.js +47 -0
  12. package/dist/src/codegen/templateHelpers.js.map +1 -0
  13. package/dist/src/codegen/templates/command/decide.specs.specs.ts +473 -0
  14. package/dist/src/codegen/templates/command/decide.specs.ts +1 -10
  15. package/dist/src/codegen/templates/command/decide.specs.ts.ejs +0 -45
  16. package/dist/src/codegen/templates/command/decide.ts.ejs +31 -2
  17. package/dist/src/codegen/templates/command/state.specs.ts +89 -0
  18. package/dist/src/codegen/templates/command/state.ts.ejs +20 -0
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/ketchup-plan.md +5 -3
  21. package/package.json +4 -4
  22. package/src/codegen/scaffoldFromSchema.ts +4 -0
  23. package/src/codegen/templateHelpers.specs.ts +98 -0
  24. package/src/codegen/templateHelpers.ts +58 -0
  25. package/src/codegen/templates/command/decide.specs.specs.ts +473 -0
  26. package/src/codegen/templates/command/decide.specs.ts +1 -10
  27. package/src/codegen/templates/command/decide.specs.ts.ejs +0 -45
  28. package/src/codegen/templates/command/decide.ts.ejs +31 -2
  29. package/src/codegen/templates/command/state.specs.ts +89 -0
  30. package/src/codegen/templates/command/state.ts.ejs +20 -0
@@ -141,4 +141,93 @@ describe('state.ts.ejs', () => {
141
141
  "
142
142
  `);
143
143
  });
144
+
145
+ it('should include Given state ref hints when specs use state refs', async () => {
146
+ const spec: SpecsSchema = {
147
+ variant: 'specs',
148
+ scenes: [
149
+ {
150
+ name: 'Profile scene',
151
+ moments: [
152
+ {
153
+ type: 'command',
154
+ name: 'Update profile',
155
+ stream: 'profile',
156
+ client: { specs: [] },
157
+ server: {
158
+ description: '',
159
+ specs: [
160
+ {
161
+ type: 'gherkin',
162
+ feature: 'Update profile',
163
+ rules: [
164
+ {
165
+ name: 'Should update profile',
166
+ examples: [
167
+ {
168
+ name: 'Profile updated',
169
+ steps: [
170
+ {
171
+ keyword: 'Given',
172
+ text: 'CreatedProfile',
173
+ docString: { userId: 'u1', status: 'created' },
174
+ },
175
+ {
176
+ keyword: 'When',
177
+ text: 'UpdateProfile',
178
+ docString: { userId: 'u1', displayName: 'Alice' },
179
+ },
180
+ {
181
+ keyword: 'Then',
182
+ text: 'ProfileUpdated',
183
+ docString: { userId: 'u1', displayName: 'Alice' },
184
+ },
185
+ ],
186
+ },
187
+ ],
188
+ },
189
+ ],
190
+ },
191
+ ],
192
+ },
193
+ },
194
+ ],
195
+ },
196
+ ],
197
+ messages: [
198
+ {
199
+ type: 'state',
200
+ name: 'CreatedProfile',
201
+ fields: [
202
+ { name: 'userId', type: 'string', required: true },
203
+ { name: 'status', type: 'string', required: true },
204
+ ],
205
+ },
206
+ {
207
+ type: 'command',
208
+ name: 'UpdateProfile',
209
+ fields: [
210
+ { name: 'userId', type: 'string', required: true },
211
+ { name: 'displayName', type: 'string', required: true },
212
+ ],
213
+ },
214
+ {
215
+ type: 'event',
216
+ name: 'ProfileUpdated',
217
+ source: 'internal',
218
+ fields: [
219
+ { name: 'userId', type: 'string', required: true },
220
+ { name: 'displayName', type: 'string', required: true },
221
+ ],
222
+ },
223
+ ],
224
+ };
225
+
226
+ const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
227
+ const stateFile = plans.find((p) => p.outputPath.endsWith('state.ts'));
228
+ const contents = stateFile?.contents ?? '';
229
+
230
+ expect(contents).toContain('Given precondition states from specs');
231
+ expect(contents).toContain("status: 'created'");
232
+ });
144
233
  });
@@ -1,3 +1,16 @@
1
+ <%
2
+ const allGivenStateRefs = [];
3
+ for (const [cmd, scenarios] of Object.entries(gwtMapping)) {
4
+ for (const s of scenarios) {
5
+ for (const g of (s.given || [])) {
6
+ if (!events.some(e => e.type === g.eventRef)) {
7
+ allGivenStateRefs.push(g);
8
+ }
9
+ }
10
+ }
11
+ }
12
+ const uniqueStatusValues = [...new Set(allGivenStateRefs.map(g => g.exampleData?.status).filter(Boolean))];
13
+ -%>
1
14
  /**
2
15
  * ## IMPLEMENTATION INSTRUCTIONS ##
3
16
  *
@@ -40,6 +53,13 @@
40
53
  *
41
54
  * Note: Status string literals should match your schema's enum values (usually snake_case).
42
55
  * If an enum is defined in domain/shared/types.ts, reference the enum type instead of literals.
56
+ <% if (uniqueStatusValues.length > 0) { -%>
57
+ *
58
+ * Given precondition states from specs (your State MUST include a variant for each):
59
+ <% for (const status of uniqueStatusValues) { -%>
60
+ * - status: '<%= status %>'
61
+ <% } -%>
62
+ <% } -%>
43
63
  */
44
64
 
45
65
  // TODO: Replace with a discriminated union of domain states for the current slice