@auto-engineer/server-generator-apollo-emmett 1.87.0 → 1.88.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +25 -0
- package/dist/src/codegen/extract/messages.d.ts +1 -1
- package/dist/src/codegen/extract/messages.d.ts.map +1 -1
- package/dist/src/codegen/extract/projection.d.ts +1 -1
- package/dist/src/codegen/extract/projection.d.ts.map +1 -1
- package/dist/src/codegen/extract/projection.js +14 -1
- package/dist/src/codegen/extract/projection.js.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
- package/dist/src/codegen/templates/command/decide.specs.specs.ts +306 -0
- package/dist/src/codegen/templates/command/decide.specs.ts +4 -4
- package/dist/src/codegen/templates/command/decide.specs.ts.ejs +27 -1
- package/dist/src/codegen/templates/command/decide.ts.ejs +1 -1
- package/dist/src/codegen/templates/query/projection.specs.specs.ts +174 -1
- package/dist/src/codegen/templates/query/projection.specs.ts.ejs +38 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ketchup-plan.md +5 -1
- package/package.json +4 -4
- package/src/codegen/extract/messages.ts +1 -1
- package/src/codegen/extract/projection.ts +13 -3
- package/src/codegen/scaffoldFromSchema.ts +1 -1
- package/src/codegen/templates/command/decide.specs.specs.ts +306 -0
- package/src/codegen/templates/command/decide.specs.ts +4 -4
- package/src/codegen/templates/command/decide.specs.ts.ejs +27 -1
- package/src/codegen/templates/command/decide.ts.ejs +1 -1
- package/src/codegen/templates/query/projection.specs.specs.ts +174 -1
- package/src/codegen/templates/query/projection.specs.ts.ejs +38 -12
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
const targetName = slice?.server?.data?.items?.[0]?.target?.name || 'UnknownState';
|
|
3
3
|
const TargetType = pascalCase(targetName);
|
|
4
4
|
const projName = projectionName || "UnknownProjection";
|
|
5
|
-
const
|
|
5
|
+
const isCompositeKey = Array.isArray(projectionIdField);
|
|
6
|
+
const compositeKeyFields = isCompositeKey ? projectionIdField : [];
|
|
7
|
+
const idField = typeof projectionIdField === 'string' ? projectionIdField : 'id';
|
|
6
8
|
const uniqueEventTypes = allEventTypesArray;
|
|
7
9
|
|
|
8
10
|
// Extract query name from the slice's request field for query action detection
|
|
@@ -70,6 +72,29 @@ function formatSpecValue(value, tsType) {
|
|
|
70
72
|
return `'${value}'`;
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
function findIdFieldValue(fieldName, expectedState, allTestEvents, isQueryActionTest, testCase) {
|
|
76
|
+
let value = expectedState.exampleData?.[fieldName];
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
for (const evt of allTestEvents) {
|
|
79
|
+
if (evt.exampleData?.[fieldName] !== undefined) {
|
|
80
|
+
value = evt.exampleData[fieldName];
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (value === undefined && isQueryActionTest && testCase.when?.args) {
|
|
86
|
+
value = testCase.when.args[fieldName];
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function formatIdLookupValue(value) {
|
|
92
|
+
if (value === undefined || value === null) return null;
|
|
93
|
+
if (typeof value === 'object') return null;
|
|
94
|
+
const inferredType = typeof value === 'number' ? 'number' : typeof value === 'boolean' ? 'boolean' : 'string';
|
|
95
|
+
return formatSpecValue(value, inferredType);
|
|
96
|
+
}
|
|
97
|
+
|
|
73
98
|
const queryName = extractQueryName(slice?.request);
|
|
74
99
|
const ruleGroups = new Map();
|
|
75
100
|
|
|
@@ -228,20 +253,21 @@ _%>
|
|
|
228
253
|
.findOne(<% if (projectionSingleton) { %>);<%
|
|
229
254
|
} else {
|
|
230
255
|
%>(doc) => <%
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const value = expectedState.exampleData?.[part];
|
|
237
|
-
const valueStr = typeof value === 'string' ? `'${value}'` : value || "'test-value'";
|
|
238
|
-
return `doc.${part} === ${valueStr}`;
|
|
256
|
+
if (isCompositeKey) {
|
|
257
|
+
const conditions = compositeKeyFields.map(part => {
|
|
258
|
+
const value = findIdFieldValue(part, expectedState, allTestEvents, isQueryActionTest, testCase);
|
|
259
|
+
const formatted = formatIdLookupValue(value);
|
|
260
|
+
return `doc.${part} === ${formatted ?? "'test-id'"}`;
|
|
239
261
|
}).join(' && ');
|
|
240
262
|
%><%= conditions %><%
|
|
241
263
|
} else {
|
|
242
|
-
const value = expectedState
|
|
243
|
-
const
|
|
244
|
-
|
|
264
|
+
const value = findIdFieldValue(idField, expectedState, allTestEvents, isQueryActionTest, testCase);
|
|
265
|
+
const formatted = formatIdLookupValue(value);
|
|
266
|
+
if (formatted !== null) {
|
|
267
|
+
%>doc.<%= idField %> === <%= formatted %><%
|
|
268
|
+
} else {
|
|
269
|
+
%>doc.<%= idField %> === 'test-id'<%
|
|
270
|
+
}
|
|
245
271
|
}
|
|
246
272
|
%>);<%
|
|
247
273
|
}
|