@auto-engineer/server-generator-apollo-emmett 1.125.0 → 1.127.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.
package/package.json CHANGED
@@ -32,8 +32,8 @@
32
32
  "uuid": "^13.0.0",
33
33
  "web-streams-polyfill": "^4.1.0",
34
34
  "zod": "^3.22.4",
35
- "@auto-engineer/narrative": "1.125.0",
36
- "@auto-engineer/message-bus": "1.125.0"
35
+ "@auto-engineer/narrative": "1.127.0",
36
+ "@auto-engineer/message-bus": "1.127.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
@@ -44,9 +44,9 @@
44
44
  "typescript": "^5.8.3",
45
45
  "vitest": "^3.2.4",
46
46
  "tsx": "^4.19.2",
47
- "@auto-engineer/cli": "1.125.0"
47
+ "@auto-engineer/cli": "1.127.0"
48
48
  },
49
- "version": "1.125.0",
49
+ "version": "1.127.0",
50
50
  "scripts": {
51
51
  "generate:server": "tsx src/cli/index.ts",
52
52
  "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",
@@ -70,6 +70,69 @@ describe('state.ts.ejs', () => {
70
70
  `);
71
71
  });
72
72
 
73
+ it('should render projection state fields as required even when spec says required: false', async () => {
74
+ const spec: SpecsSchema = {
75
+ variant: 'specs',
76
+ narratives: [
77
+ {
78
+ name: 'Workout tracking',
79
+ slices: [
80
+ {
81
+ type: 'query',
82
+ name: 'Get workout history',
83
+ client: { specs: [] },
84
+ server: {
85
+ description: 'Projects workout history',
86
+ data: {
87
+ items: [
88
+ {
89
+ origin: {
90
+ type: 'projection',
91
+ name: 'WorkoutCompleted',
92
+ idField: 'id',
93
+ },
94
+ target: {
95
+ type: 'State',
96
+ name: 'WorkoutHistory',
97
+ },
98
+ },
99
+ ],
100
+ },
101
+ specs: [],
102
+ },
103
+ },
104
+ ],
105
+ },
106
+ ],
107
+ modules: [],
108
+ messages: [
109
+ {
110
+ type: 'state',
111
+ name: 'WorkoutHistory',
112
+ fields: [
113
+ { name: 'id', type: 'string', required: true },
114
+ { name: 'name', type: 'string', required: true },
115
+ { name: 'notes', type: 'string', required: false },
116
+ { name: 'calories', type: 'number', required: false },
117
+ ],
118
+ },
119
+ ],
120
+ };
121
+
122
+ const { plans } = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
123
+ const stateFile = plans.find((p) => p.outputPath.endsWith('state.ts'));
124
+
125
+ expect(stateFile?.contents).toMatchInlineSnapshot(`
126
+ "export type WorkoutHistory = {
127
+ id: string;
128
+ name: string;
129
+ notes: string;
130
+ calories: number;
131
+ };
132
+ "
133
+ `);
134
+ });
135
+
73
136
  it('should export fallback UnknownState when query slice has no data config', async () => {
74
137
  const spec: SpecsSchema = {
75
138
  variant: 'specs',
@@ -7,7 +7,7 @@ export type UnknownState = {
7
7
  <% for (const state of states) { -%>
8
8
  export type <%= pascalCase(state.type) %> = {
9
9
  <% for (const field of state.fields) { -%>
10
- <%- field.name %><%= field.required ? '' : '?' %>: <%- field.tsType %>;
10
+ <%- field.name %>: <%- field.tsType %>;
11
11
  <% } -%>
12
12
  };
13
13
  <% } -%>