@auto-engineer/server-generator-apollo-emmett 1.89.0 → 1.95.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 (29) 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 +155 -0
  5. package/dist/src/codegen/extract/type-helpers.d.ts +0 -6
  6. package/dist/src/codegen/extract/type-helpers.d.ts.map +1 -1
  7. package/dist/src/codegen/extract/type-helpers.js +1 -65
  8. package/dist/src/codegen/extract/type-helpers.js.map +1 -1
  9. package/dist/src/codegen/scaffoldFromSchema.d.ts +2 -0
  10. package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
  11. package/dist/src/codegen/scaffoldFromSchema.js +51 -11
  12. package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
  13. package/dist/src/codegen/templates/command/evolve.specs.ts +32 -28
  14. package/dist/src/codegen/templates/command/evolve.ts.ejs +4 -0
  15. package/dist/src/codegen/templates/query/projection.specs.specs.ts +1 -0
  16. package/dist/src/codegen/templates/query/projection.specs.ts +4 -0
  17. package/dist/src/codegen/templates/query/projection.ts.ejs +1 -0
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/ketchup-plan.md +5 -0
  20. package/package.json +4 -4
  21. package/src/codegen/extract/type-helpers.specs.ts +2 -7
  22. package/src/codegen/extract/type-helpers.ts +1 -59
  23. package/src/codegen/formatTsValue.specs.ts +141 -0
  24. package/src/codegen/scaffoldFromSchema.ts +60 -16
  25. package/src/codegen/templates/command/evolve.specs.ts +32 -28
  26. package/src/codegen/templates/command/evolve.ts.ejs +4 -0
  27. package/src/codegen/templates/query/projection.specs.specs.ts +1 -0
  28. package/src/codegen/templates/query/projection.specs.ts +4 -0
  29. package/src/codegen/templates/query/projection.ts.ejs +1 -0
@@ -81,35 +81,39 @@ describe('evolve.ts.ejs', () => {
81
81
  const evolveFile = plans.find((p) => p.outputPath.endsWith('evolve.ts'));
82
82
 
83
83
  expect(evolveFile?.contents).toMatchInlineSnapshot(`
84
- "import type { State } from './state';
85
- import type { ListingCreated } from './events';
84
+ "import type { State } from './state';
85
+ import type { ListingCreated } from './events';
86
86
 
87
- /**
88
- * ## IMPLEMENTATION INSTRUCTIONS ##
89
- *
90
- * This function defines how the domain state evolves in response to events.
91
- *
92
- * Guidelines:
93
- * - Apply only the **minimal** necessary changes for future decisions in \`decide.ts\`.
94
- * - Ignore any event fields not required for decision-making logic.
95
- * - If the event doesn’t change decision-relevant state, return the existing \`state\`.
96
- * - Prefer immutability: always return a **new state object**.
97
- * - Avoid spreading all of \`event.data\` unless all fields are relevant.
98
- */
87
+ /**
88
+ * ## IMPLEMENTATION INSTRUCTIONS ##
89
+ *
90
+ * This function defines how the domain state evolves in response to events.
91
+ *
92
+ * Guidelines:
93
+ * - Apply only the **minimal** necessary changes for future decisions in \`decide.ts\`.
94
+ * - Ignore any event fields not required for decision-making logic.
95
+ * - If the event doesn’t change decision-relevant state, return the existing \`state\`.
96
+ * - Prefer immutability: always return a **new state object**.
97
+ * - Avoid spreading all of \`event.data\` unless all fields are relevant.
98
+ * - If State is a discriminated union (e.g., NotInitialized | Initialized),
99
+ * always include the discriminant field (e.g., \`status\`) in return values.
100
+ * Do NOT spread \`...state\` and add variant-specific fields — construct a complete object:
101
+ * \`return { status: 'initialized', field: event.data.field };\`
102
+ */
99
103
 
100
- export const evolve = (state: State, event: ListingCreated): State => {
101
- switch (event.type) {
102
- case 'ListingCreated': {
103
- // TODO: Update state based on ListingCreated
104
- return {
105
- ...state,
106
- };
107
- }
108
- default:
109
- return state;
110
- }
111
- };
112
- "
113
- `);
104
+ export const evolve = (state: State, event: ListingCreated): State => {
105
+ switch (event.type) {
106
+ case 'ListingCreated': {
107
+ // TODO: Update state based on ListingCreated
108
+ return {
109
+ ...state,
110
+ };
111
+ }
112
+ default:
113
+ return state;
114
+ }
115
+ };
116
+ "
117
+ `);
114
118
  });
115
119
  });
@@ -15,6 +15,10 @@
15
15
  * - If the event doesn’t change decision-relevant state, return the existing `state`.
16
16
  * - Prefer immutability: always return a **new state object**.
17
17
  * - Avoid spreading all of `event.data` unless all fields are relevant.
18
+ * - If State is a discriminated union (e.g., NotInitialized | Initialized),
19
+ * always include the discriminant field (e.g., `status`) in return values.
20
+ * Do NOT spread `...state` and add variant-specific fields — construct a complete object:
21
+ * `return { status: 'initialized', field: event.data.field };`
18
22
  */
19
23
 
20
24
  export const evolve = (
@@ -1571,6 +1571,7 @@ describe('projection.specs.ts.ejs', () => {
1571
1571
  * Derive ALL field values from event.data or existing document state.
1572
1572
  * NEVER hardcode constant values — every output field must trace to an input.
1573
1573
  * Preserve all import paths above — they are generated from the model.
1574
+ * ⚠️ \`document\` may be null (first event for this entity). Guard before accessing properties.
1574
1575
  *
1575
1576
  * Implement how this event updates the projection.
1576
1577
  *
@@ -243,6 +243,7 @@ describe('projection.ts.ejs', () => {
243
243
  * Derive ALL field values from event.data or existing document state.
244
244
  * NEVER hardcode constant values — every output field must trace to an input.
245
245
  * Preserve all import paths above — they are generated from the model.
246
+ * ⚠️ \`document\` may be null (first event for this entity). Guard before accessing properties.
246
247
  *
247
248
  * Implement how this event updates the projection.
248
249
  *
@@ -282,6 +283,7 @@ describe('projection.ts.ejs', () => {
282
283
  * Derive ALL field values from event.data or existing document state.
283
284
  * NEVER hardcode constant values — every output field must trace to an input.
284
285
  * Preserve all import paths above — they are generated from the model.
286
+ * ⚠️ \`document\` may be null (first event for this entity). Guard before accessing properties.
285
287
  *
286
288
  * This event might indicate removal of a AvailableListings.
287
289
  *
@@ -582,6 +584,7 @@ describe('projection.ts.ejs', () => {
582
584
  * Derive ALL field values from event.data or existing document state.
583
585
  * NEVER hardcode constant values — every output field must trace to an input.
584
586
  * Preserve all import paths above — they are generated from the model.
587
+ * ⚠️ \`document\` may be null (first event for this entity). Guard before accessing properties.
585
588
  *
586
589
  * **SINGLETON AGGREGATION PATTERN**
587
590
  *
@@ -803,6 +806,7 @@ describe('projection.ts.ejs', () => {
803
806
  * Derive ALL field values from event.data or existing document state.
804
807
  * NEVER hardcode constant values — every output field must trace to an input.
805
808
  * Preserve all import paths above — they are generated from the model.
809
+ * ⚠️ \`document\` may be null (first event for this entity). Guard before accessing properties.
806
810
  *
807
811
  * **COMPOSITE KEY PROJECTION**
808
812
  *
@@ -124,6 +124,7 @@ case '<%= event.type %>': {
124
124
  * Derive ALL field values from event.data or existing document state.
125
125
  * NEVER hardcode constant values — every output field must trace to an input.
126
126
  * Preserve all import paths above — they are generated from the model.
127
+ * ⚠️ `document` may be null (first event for this entity). Guard before accessing properties.
127
128
  *
128
129
  <% if (isSingleton) { -%>
129
130
  * **SINGLETON AGGREGATION PATTERN**