@auto-engineer/server-generator-apollo-emmett 0.11.10 → 0.11.11
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 +5 -0
- package/.turbo/turbo-format.log +4 -0
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +14 -0
- package/.turbo/turbo-type-check.log +4 -0
- package/CHANGELOG.md +10 -0
- package/dist/src/codegen/extract/commands.d.ts +1 -1
- package/dist/src/codegen/extract/commands.d.ts.map +1 -1
- package/dist/src/codegen/extract/data-sink.d.ts +1 -1
- package/dist/src/codegen/extract/data-sink.d.ts.map +1 -1
- package/dist/src/codegen/extract/events.d.ts +1 -1
- package/dist/src/codegen/extract/events.d.ts.map +1 -1
- package/dist/src/codegen/extract/gwt.d.ts +1 -1
- package/dist/src/codegen/extract/gwt.d.ts.map +1 -1
- 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/query.d.ts +1 -1
- package/dist/src/codegen/extract/query.d.ts.map +1 -1
- package/dist/src/codegen/extract/states.d.ts +1 -1
- package/dist/src/codegen/extract/states.d.ts.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.d.ts +3 -3
- package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
- package/dist/src/codegen/templates/command/commands.specs.ts +3 -3
- package/dist/src/codegen/templates/command/decide.specs.specs.ts +7 -7
- package/dist/src/codegen/templates/command/decide.specs.ts +9 -9
- package/dist/src/codegen/templates/command/events.specs.ts +3 -3
- package/dist/src/codegen/templates/command/evolve.specs.ts +3 -3
- package/dist/src/codegen/templates/command/handle.specs.ts +10 -5
- package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +7 -7
- package/dist/src/codegen/templates/command/register.specs.ts +3 -3
- package/dist/src/codegen/templates/command/state.specs.ts +3 -3
- package/dist/src/codegen/templates/query/projection.specs.specs.ts +7 -7
- package/dist/src/codegen/templates/query/projection.specs.ts +5 -5
- package/dist/src/codegen/templates/query/query.resolver.specs.ts +13 -13
- package/dist/src/codegen/templates/query/state.specs.ts +3 -3
- package/dist/src/codegen/templates/react/react.specs.specs.ts +3 -3
- package/dist/src/codegen/templates/react/react.specs.ts +3 -3
- package/dist/src/codegen/templates/react/register.specs.ts +3 -3
- package/dist/src/codegen/test-data/specVariant1.d.ts +1 -1
- package/dist/src/codegen/test-data/specVariant1.d.ts.map +1 -1
- package/dist/src/codegen/test-data/specVariant1.js +1 -1
- package/dist/src/codegen/test-data/specVariant1.js.map +1 -1
- package/dist/src/codegen/types.d.ts +1 -1
- package/dist/src/codegen/types.d.ts.map +1 -1
- package/dist/src/commands/generate-server.d.ts.map +1 -1
- package/dist/src/commands/generate-server.js +11 -8
- package/dist/src/commands/generate-server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/codegen/extract/commands.ts +1 -1
- package/src/codegen/extract/data-sink.ts +1 -1
- package/src/codegen/extract/events.ts +1 -1
- package/src/codegen/extract/gwt.ts +1 -1
- package/src/codegen/extract/messages.ts +1 -1
- package/src/codegen/extract/projection.ts +1 -1
- package/src/codegen/extract/query.ts +1 -1
- package/src/codegen/extract/states.ts +1 -1
- package/src/codegen/scaffoldFromSchema.ts +10 -10
- package/src/codegen/templates/command/commands.specs.ts +3 -3
- package/src/codegen/templates/command/decide.specs.specs.ts +7 -7
- package/src/codegen/templates/command/decide.specs.ts +9 -9
- package/src/codegen/templates/command/events.specs.ts +3 -3
- package/src/codegen/templates/command/evolve.specs.ts +3 -3
- package/src/codegen/templates/command/handle.specs.ts +10 -5
- package/src/codegen/templates/command/mutation.resolver.specs.ts +7 -7
- package/src/codegen/templates/command/register.specs.ts +3 -3
- package/src/codegen/templates/command/state.specs.ts +3 -3
- package/src/codegen/templates/query/projection.specs.specs.ts +7 -7
- package/src/codegen/templates/query/projection.specs.ts +5 -5
- package/src/codegen/templates/query/query.resolver.specs.ts +13 -13
- package/src/codegen/templates/query/state.specs.ts +3 -3
- package/src/codegen/templates/react/react.specs.specs.ts +3 -3
- package/src/codegen/templates/react/react.specs.ts +3 -3
- package/src/codegen/templates/react/register.specs.ts +3 -3
- package/src/codegen/test-data/specVariant1.ts +2 -2
- package/src/codegen/types.ts +1 -1
- package/src/commands/generate-server.ts +13 -9
package/package.json
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"graphql-type-json": "^0.3.2",
|
|
32
32
|
"uuid": "^11.0.0",
|
|
33
33
|
"web-streams-polyfill": "^4.1.0",
|
|
34
|
-
"@auto-engineer/
|
|
35
|
-
"@auto-engineer/message-bus": "0.11.
|
|
34
|
+
"@auto-engineer/narrative": "0.11.11",
|
|
35
|
+
"@auto-engineer/message-bus": "0.11.11"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"typescript": "^5.8.3",
|
|
44
44
|
"vitest": "^3.2.4",
|
|
45
45
|
"tsx": "^4.19.2",
|
|
46
|
-
"@auto-engineer/cli": "0.11.
|
|
46
|
+
"@auto-engineer/cli": "0.11.11"
|
|
47
47
|
},
|
|
48
|
-
"version": "0.11.
|
|
48
|
+
"version": "0.11.11",
|
|
49
49
|
"scripts": {
|
|
50
50
|
"generate:server": "tsx src/cli/index.ts",
|
|
51
51
|
"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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandExample, Slice, type Example } from '@auto-engineer/
|
|
1
|
+
import { CommandExample, Slice, type Example } from '@auto-engineer/narrative';
|
|
2
2
|
|
|
3
3
|
function resolveStreamId(stream: string, exampleData: Record<string, unknown>): string {
|
|
4
4
|
return stream.replace(/\$\{([^}]+)\}/g, (_, key: string) => String(exampleData?.[key] ?? 'unknown'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Slice, CommandExample, EventExample, StateExample, Example } from '@auto-engineer/
|
|
1
|
+
import { Slice, CommandExample, EventExample, StateExample, Example } from '@auto-engineer/narrative';
|
|
2
2
|
import { GwtCondition } from '../types';
|
|
3
3
|
|
|
4
4
|
export function buildCommandGwtMapping(slice: Slice): Record<string, (GwtCondition & { failingFields?: string[] })[]> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractCommandsFromGwt, extractCommandsFromThen } from './commands';
|
|
2
|
-
import { CommandExample, ErrorExample, EventExample, Slice, StateExample } from '@auto-engineer/
|
|
2
|
+
import { CommandExample, ErrorExample, EventExample, Slice, StateExample } from '@auto-engineer/narrative';
|
|
3
3
|
import { Message, MessageDefinition } from '../types';
|
|
4
4
|
import { extractEventsFromGiven, extractEventsFromThen, extractEventsFromWhen } from './events';
|
|
5
5
|
import { extractFieldsFromMessage } from './fields';
|
|
@@ -6,7 +6,7 @@ import ejs from 'ejs';
|
|
|
6
6
|
import { ensureDirExists, ensureDirPath, toKebabCase } from './utils/path';
|
|
7
7
|
import { camelCase, pascalCase } from 'change-case';
|
|
8
8
|
import prettier from 'prettier';
|
|
9
|
-
import {
|
|
9
|
+
import { Narrative, Slice, Model } from '@auto-engineer/narrative';
|
|
10
10
|
import createDebug from 'debug';
|
|
11
11
|
|
|
12
12
|
const debug = createDebug('auto:server-generator-apollo-emmett:scaffold');
|
|
@@ -484,7 +484,7 @@ function extractUsedErrors(gwtMapping: Record<string, (GwtCondition & { failingF
|
|
|
484
484
|
|
|
485
485
|
async function prepareTemplateData(
|
|
486
486
|
slice: Slice,
|
|
487
|
-
flow:
|
|
487
|
+
flow: Narrative,
|
|
488
488
|
commands: Message[],
|
|
489
489
|
events: Message[],
|
|
490
490
|
states: Message[],
|
|
@@ -556,7 +556,7 @@ async function prepareTemplateData(
|
|
|
556
556
|
|
|
557
557
|
function annotateEventSources(
|
|
558
558
|
events: Message[],
|
|
559
|
-
flows:
|
|
559
|
+
flows: Narrative[],
|
|
560
560
|
fallbackFlowName: string,
|
|
561
561
|
fallbackSliceName: string,
|
|
562
562
|
): void {
|
|
@@ -582,7 +582,7 @@ function canSliceProduceEvent(slice: Slice): boolean {
|
|
|
582
582
|
return ['command', 'react'].includes(slice.type) && 'server' in slice && Boolean(slice.server?.specs);
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
-
function findEventSource(flows:
|
|
585
|
+
function findEventSource(flows: Narrative[], eventType: string): { flowName: string; sliceName: string } | null {
|
|
586
586
|
debugSlice('Finding source for event: %s', eventType);
|
|
587
587
|
|
|
588
588
|
for (const flow of flows) {
|
|
@@ -603,7 +603,7 @@ function findEventSource(flows: Flow[], eventType: string): { flowName: string;
|
|
|
603
603
|
|
|
604
604
|
function annotateCommandSources(
|
|
605
605
|
commands: Message[],
|
|
606
|
-
flows:
|
|
606
|
+
flows: Narrative[],
|
|
607
607
|
fallbackFlowName: string,
|
|
608
608
|
fallbackSliceName: string,
|
|
609
609
|
): void {
|
|
@@ -616,7 +616,7 @@ function annotateCommandSources(
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
-
function findCommandSource(flows:
|
|
619
|
+
function findCommandSource(flows: Narrative[], commandType: string): { flowName: string; sliceName: string } | null {
|
|
620
620
|
debugSlice('Finding source for command: %s', commandType);
|
|
621
621
|
for (const flow of flows) {
|
|
622
622
|
for (const slice of flow.slices) {
|
|
@@ -646,10 +646,10 @@ function findCommandSource(flows: Flow[], commandType: string): { flowName: stri
|
|
|
646
646
|
|
|
647
647
|
async function generateFilesForSlice(
|
|
648
648
|
slice: Slice,
|
|
649
|
-
flow:
|
|
649
|
+
flow: Narrative,
|
|
650
650
|
sliceDir: string,
|
|
651
651
|
messages: MessageDefinition[],
|
|
652
|
-
flows:
|
|
652
|
+
flows: Narrative[],
|
|
653
653
|
unionToEnumName: Map<string, string>,
|
|
654
654
|
integrations?: Model['integrations'],
|
|
655
655
|
): Promise<FilePlan[]> {
|
|
@@ -698,7 +698,7 @@ async function generateFilesForSlice(
|
|
|
698
698
|
}
|
|
699
699
|
|
|
700
700
|
export async function generateScaffoldFilePlans(
|
|
701
|
-
flows:
|
|
701
|
+
flows: Narrative[],
|
|
702
702
|
messages: Model['messages'],
|
|
703
703
|
integrations?: Model['integrations'],
|
|
704
704
|
baseDir = 'src/domain/flows',
|
|
@@ -766,7 +766,7 @@ export async function writeScaffoldFilePlans(plans: FilePlan[]) {
|
|
|
766
766
|
}
|
|
767
767
|
|
|
768
768
|
export async function scaffoldFromSchema(
|
|
769
|
-
flows:
|
|
769
|
+
flows: Narrative[],
|
|
770
770
|
messages: Model['messages'],
|
|
771
771
|
baseDir = 'src/domain/flows',
|
|
772
772
|
): Promise<void> {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
2
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('commands.ts.ejs', () => {
|
|
6
6
|
it('should generate correct command file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -72,7 +72,7 @@ describe('commands.ts.ejs', () => {
|
|
|
72
72
|
],
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
75
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
76
76
|
const commandFile = plans.find((p) => p.outputPath.endsWith('commands.ts'));
|
|
77
77
|
|
|
78
78
|
expect(commandFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
2
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('spec.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid spec file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -91,7 +91,7 @@ describe('spec.ts.ejs', () => {
|
|
|
91
91
|
],
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
94
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
95
95
|
const specFile = plans.find((p) => p.outputPath.endsWith('specs.ts'));
|
|
96
96
|
|
|
97
97
|
expect(specFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -150,7 +150,7 @@ describe('spec.ts.ejs', () => {
|
|
|
150
150
|
it('should include given events in the spec file when provided', async () => {
|
|
151
151
|
const spec: SpecsSchema = {
|
|
152
152
|
variant: 'specs',
|
|
153
|
-
|
|
153
|
+
narratives: [
|
|
154
154
|
{
|
|
155
155
|
name: 'Guest removes a listing',
|
|
156
156
|
slices: [
|
|
@@ -233,7 +233,7 @@ describe('spec.ts.ejs', () => {
|
|
|
233
233
|
],
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
236
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
237
237
|
const specFile = plans.find((p) => p.outputPath.endsWith('specs.ts'));
|
|
238
238
|
|
|
239
239
|
expect(specFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -292,7 +292,7 @@ describe('spec.ts.ejs', () => {
|
|
|
292
292
|
it('should generate separate tests for multiple examples with different scenarios', async () => {
|
|
293
293
|
const spec: SpecsSchema = {
|
|
294
294
|
variant: 'specs',
|
|
295
|
-
|
|
295
|
+
narratives: [
|
|
296
296
|
{
|
|
297
297
|
name: 'Questionnaires',
|
|
298
298
|
slices: [
|
|
@@ -421,7 +421,7 @@ describe('spec.ts.ejs', () => {
|
|
|
421
421
|
],
|
|
422
422
|
};
|
|
423
423
|
|
|
424
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
424
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
425
425
|
const specFile = plans.find((p) => p.outputPath.endsWith('specs.ts'));
|
|
426
426
|
|
|
427
427
|
expect(specFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
2
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('decide.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid decide file when both command and event exist', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -72,7 +72,7 @@ describe('decide.ts.ejs', () => {
|
|
|
72
72
|
],
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
75
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
76
76
|
const decideFile = plans.find((p) => p.outputPath.endsWith('decide.ts'));
|
|
77
77
|
|
|
78
78
|
expect(decideFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -117,7 +117,7 @@ describe('decide.ts.ejs', () => {
|
|
|
117
117
|
it('should include implementation instructions when prior events are required', async () => {
|
|
118
118
|
const spec: SpecsSchema = {
|
|
119
119
|
variant: 'specs',
|
|
120
|
-
|
|
120
|
+
narratives: [
|
|
121
121
|
{
|
|
122
122
|
name: 'Host removes a listing',
|
|
123
123
|
slices: [
|
|
@@ -198,7 +198,7 @@ describe('decide.ts.ejs', () => {
|
|
|
198
198
|
],
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
201
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
202
202
|
const decideFile = plans.find((p) => p.outputPath.endsWith('decide.ts'));
|
|
203
203
|
|
|
204
204
|
expect(decideFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -243,7 +243,7 @@ describe('decide.ts.ejs', () => {
|
|
|
243
243
|
it('should generate a decide file that handles multiple GWTs including an error', async () => {
|
|
244
244
|
const spec: SpecsSchema = {
|
|
245
245
|
variant: 'specs',
|
|
246
|
-
|
|
246
|
+
narratives: [
|
|
247
247
|
{
|
|
248
248
|
name: 'Host creates a listing',
|
|
249
249
|
slices: [
|
|
@@ -339,7 +339,7 @@ describe('decide.ts.ejs', () => {
|
|
|
339
339
|
],
|
|
340
340
|
};
|
|
341
341
|
|
|
342
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
342
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
343
343
|
const decideFile = plans.find((p) => p.outputPath.endsWith('decide.ts'));
|
|
344
344
|
|
|
345
345
|
expect(decideFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -388,7 +388,7 @@ describe('decide.ts.ejs', () => {
|
|
|
388
388
|
it('should include integration return type and usage in decide function', async () => {
|
|
389
389
|
const spec: SpecsSchema = {
|
|
390
390
|
variant: 'specs',
|
|
391
|
-
|
|
391
|
+
narratives: [
|
|
392
392
|
{
|
|
393
393
|
name: 'Assistant suggests items',
|
|
394
394
|
slices: [
|
|
@@ -525,7 +525,7 @@ describe('decide.ts.ejs', () => {
|
|
|
525
525
|
],
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
528
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, spec.integrations);
|
|
529
529
|
const decideFile = plans.find((p) => p.outputPath.endsWith('decide.ts'));
|
|
530
530
|
|
|
531
531
|
expect(decideFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
2
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('events.ts.ejs', () => {
|
|
6
6
|
it('should generate an event file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -93,7 +93,7 @@ describe('events.ts.ejs', () => {
|
|
|
93
93
|
],
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
96
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
97
97
|
const eventFile = plans.find((p) => p.outputPath.endsWith('events.ts'));
|
|
98
98
|
|
|
99
99
|
expect(eventFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
2
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('evolve.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid evolve file from event structure', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -72,7 +72,7 @@ describe('evolve.ts.ejs', () => {
|
|
|
72
72
|
],
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
75
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
76
76
|
const evolveFile = plans.find((p) => p.outputPath.endsWith('evolve.ts'));
|
|
77
77
|
|
|
78
78
|
expect(evolveFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
3
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('generateScaffoldFilePlans', () => {
|
|
6
6
|
it('should generate a valid handle file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -97,7 +97,7 @@ describe('generateScaffoldFilePlans', () => {
|
|
|
97
97
|
],
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
100
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
101
101
|
const handleFile = plans.find((p) => p.outputPath.endsWith('handle.ts'));
|
|
102
102
|
|
|
103
103
|
expect(handleFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -131,7 +131,7 @@ describe('generateScaffoldFilePlans', () => {
|
|
|
131
131
|
it('should generate a valid handle file with integration', async () => {
|
|
132
132
|
const spec: SpecsSchema = {
|
|
133
133
|
variant: 'specs',
|
|
134
|
-
|
|
134
|
+
narratives: [
|
|
135
135
|
{
|
|
136
136
|
name: 'Assistant suggests items',
|
|
137
137
|
slices: [
|
|
@@ -268,7 +268,12 @@ describe('generateScaffoldFilePlans', () => {
|
|
|
268
268
|
],
|
|
269
269
|
};
|
|
270
270
|
|
|
271
|
-
const plans = await generateScaffoldFilePlans(
|
|
271
|
+
const plans = await generateScaffoldFilePlans(
|
|
272
|
+
spec.narratives,
|
|
273
|
+
spec.messages,
|
|
274
|
+
spec.integrations,
|
|
275
|
+
'src/domain/flows',
|
|
276
|
+
);
|
|
272
277
|
const handleFile = plans.find((p) => p.outputPath.endsWith('handle.ts'));
|
|
273
278
|
|
|
274
279
|
expect(handleFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
3
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('mutation.resolver.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid mutation resolver file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -72,7 +72,7 @@ describe('mutation.resolver.ts.ejs', () => {
|
|
|
72
72
|
],
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
75
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
76
76
|
const mutationFile = plans.find((p) => p.outputPath.endsWith('mutation.resolver.ts'));
|
|
77
77
|
|
|
78
78
|
expect(mutationFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -134,7 +134,7 @@ describe('mutation.resolver.ts.ejs', () => {
|
|
|
134
134
|
it('should generate the mutation resolver for AnswerQuestion', async () => {
|
|
135
135
|
const spec: SpecsSchema = {
|
|
136
136
|
variant: 'specs',
|
|
137
|
-
|
|
137
|
+
narratives: [
|
|
138
138
|
{
|
|
139
139
|
name: 'Questionnaires',
|
|
140
140
|
slices: [
|
|
@@ -220,7 +220,7 @@ describe('mutation.resolver.ts.ejs', () => {
|
|
|
220
220
|
integrations: [],
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
223
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
224
224
|
const mutationFile = plans.find(
|
|
225
225
|
(p) =>
|
|
226
226
|
p.outputPath.endsWith('mutation.resolver.ts') && p.contents.includes('export class AnswerQuestionResolver'),
|
|
@@ -267,7 +267,7 @@ describe('mutation.resolver.ts.ejs', () => {
|
|
|
267
267
|
it('generates nested input types for inline object arrays in a mutation', async () => {
|
|
268
268
|
const spec: SpecsSchema = {
|
|
269
269
|
variant: 'specs',
|
|
270
|
-
|
|
270
|
+
narratives: [
|
|
271
271
|
{
|
|
272
272
|
name: 'Cart',
|
|
273
273
|
slices: [
|
|
@@ -315,7 +315,7 @@ describe('mutation.resolver.ts.ejs', () => {
|
|
|
315
315
|
],
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
318
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
319
319
|
const mutationFile = plans.find(
|
|
320
320
|
(p) =>
|
|
321
321
|
p.outputPath.endsWith('mutation.resolver.ts') && p.contents.includes('export class AddItemsToCartResolver'),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
3
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('generateScaffoldFilePlans', () => {
|
|
6
6
|
it('should generate a valid register file', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -98,7 +98,7 @@ describe('generateScaffoldFilePlans', () => {
|
|
|
98
98
|
],
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
101
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
102
102
|
const registerFile = plans.find((p) => p.outputPath.endsWith('register.ts'));
|
|
103
103
|
|
|
104
104
|
expect(registerFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
3
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('state.ts.ejs', () => {
|
|
6
6
|
it('should generate an initial state', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'Host creates a listing',
|
|
12
12
|
slices: [
|
|
@@ -78,7 +78,7 @@ describe('state.ts.ejs', () => {
|
|
|
78
78
|
],
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
81
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
82
82
|
const stateFile = plans.find((p) => p.outputPath.endsWith('state.ts'));
|
|
83
83
|
|
|
84
84
|
expect(stateFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/
|
|
3
|
+
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('projection.specs.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid test spec for a query slice projection', async () => {
|
|
7
7
|
const spec: SpecsSchema = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'listing-flow',
|
|
12
12
|
slices: [
|
|
@@ -180,7 +180,7 @@ describe('projection.specs.ts.ejs', () => {
|
|
|
180
180
|
],
|
|
181
181
|
} as SpecsSchema;
|
|
182
182
|
|
|
183
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
183
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
184
184
|
const specFile = plans.find((p) => p.outputPath.endsWith('projection.specs.ts'));
|
|
185
185
|
|
|
186
186
|
expect(specFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -241,7 +241,7 @@ describe('projection.specs.ts.ejs', () => {
|
|
|
241
241
|
it('should generate a valid test spec for a model with given/when/then pattern', async () => {
|
|
242
242
|
const questionnaireSpec: SpecsSchema = {
|
|
243
243
|
variant: 'specs',
|
|
244
|
-
|
|
244
|
+
narratives: [
|
|
245
245
|
{
|
|
246
246
|
name: 'Questionnaires',
|
|
247
247
|
slices: [
|
|
@@ -363,7 +363,7 @@ describe('projection.specs.ts.ejs', () => {
|
|
|
363
363
|
} as SpecsSchema;
|
|
364
364
|
|
|
365
365
|
const plans = await generateScaffoldFilePlans(
|
|
366
|
-
questionnaireSpec.
|
|
366
|
+
questionnaireSpec.narratives,
|
|
367
367
|
questionnaireSpec.messages,
|
|
368
368
|
undefined,
|
|
369
369
|
'src/domain/flows',
|
|
@@ -380,7 +380,7 @@ describe('projection.specs.ts.ejs', () => {
|
|
|
380
380
|
it('should include all events from both given and when clauses in projection imports and types', async () => {
|
|
381
381
|
const spec: SpecsSchema = {
|
|
382
382
|
variant: 'specs',
|
|
383
|
-
|
|
383
|
+
narratives: [
|
|
384
384
|
{
|
|
385
385
|
name: 'questionnaires',
|
|
386
386
|
slices: [
|
|
@@ -569,7 +569,7 @@ describe('projection.specs.ts.ejs', () => {
|
|
|
569
569
|
} as SpecsSchema;
|
|
570
570
|
|
|
571
571
|
const plans = await generateScaffoldFilePlans(
|
|
572
|
-
spec.
|
|
572
|
+
spec.narratives,
|
|
573
573
|
[
|
|
574
574
|
{
|
|
575
575
|
type: 'command',
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model } from '@auto-engineer/
|
|
3
|
+
import { Model } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('projection.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid projection file with correct relative event import path from producing slice', async () => {
|
|
7
7
|
const flows: Model = {
|
|
8
8
|
variant: 'specs',
|
|
9
|
-
|
|
9
|
+
narratives: [
|
|
10
10
|
{
|
|
11
11
|
name: 'listing-flow',
|
|
12
12
|
slices: [
|
|
@@ -201,7 +201,7 @@ describe('projection.ts.ejs', () => {
|
|
|
201
201
|
],
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
const plans = await generateScaffoldFilePlans(flows.
|
|
204
|
+
const plans = await generateScaffoldFilePlans(flows.narratives, flows.messages, undefined, 'src/domain/flows');
|
|
205
205
|
const projectionFile = plans.find((p) => p.outputPath.endsWith('projection.ts'));
|
|
206
206
|
|
|
207
207
|
expect(projectionFile?.contents).toMatchInlineSnapshot(`
|
|
@@ -279,7 +279,7 @@ describe('projection.ts.ejs', () => {
|
|
|
279
279
|
it('should generate a valid query resolver using ID type', async () => {
|
|
280
280
|
const spec: Model = {
|
|
281
281
|
variant: 'specs',
|
|
282
|
-
|
|
282
|
+
narratives: [
|
|
283
283
|
{
|
|
284
284
|
name: 'wishlist-flow',
|
|
285
285
|
slices: [
|
|
@@ -330,7 +330,7 @@ describe('projection.ts.ejs', () => {
|
|
|
330
330
|
],
|
|
331
331
|
};
|
|
332
332
|
|
|
333
|
-
const plans = await generateScaffoldFilePlans(spec.
|
|
333
|
+
const plans = await generateScaffoldFilePlans(spec.narratives, spec.messages, undefined, 'src/domain/flows');
|
|
334
334
|
const resolverFile = plans.find((p) => p.outputPath.endsWith('query.resolver.ts'));
|
|
335
335
|
|
|
336
336
|
expect(resolverFile?.contents).toMatchInlineSnapshot(`
|