@auto-engineer/server-generator-apollo-emmett 0.13.3 → 0.14.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/CHANGELOG.md +12 -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/events.d.ts +1 -1
- package/dist/src/codegen/extract/events.d.ts.map +1 -1
- package/dist/src/codegen/extract/fields.d.ts +1 -1
- package/dist/src/codegen/extract/fields.d.ts.map +1 -1
- package/dist/src/codegen/extract/graphql.js +1 -1
- package/dist/src/codegen/extract/graphql.js.map +1 -1
- package/dist/src/codegen/extract/gwt.d.ts.map +1 -1
- package/dist/src/codegen/extract/imports.d.ts +1 -1
- package/dist/src/codegen/extract/imports.d.ts.map +1 -1
- package/dist/src/codegen/extract/imports.js.map +1 -1
- package/dist/src/codegen/extract/index.d.ts +3 -3
- package/dist/src/codegen/extract/index.d.ts.map +1 -1
- package/dist/src/codegen/extract/index.js +3 -3
- package/dist/src/codegen/extract/index.js.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/messages.js +1 -1
- package/dist/src/codegen/extract/messages.js.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/slice-normalizer.d.ts +1 -1
- package/dist/src/codegen/extract/slice-normalizer.d.ts.map +1 -1
- package/dist/src/codegen/extract/slice-normalizer.js +1 -1
- package/dist/src/codegen/extract/slice-normalizer.js.map +1 -1
- package/dist/src/codegen/extract/states.d.ts +2 -2
- package/dist/src/codegen/extract/states.d.ts.map +1 -1
- package/dist/src/codegen/extract/step-converter.d.ts +2 -2
- package/dist/src/codegen/extract/step-converter.d.ts.map +1 -1
- package/dist/src/codegen/extract/step-converter.js +1 -1
- package/dist/src/codegen/extract/step-converter.js.map +1 -1
- package/dist/src/codegen/extract/step-types.d.ts +1 -2
- package/dist/src/codegen/extract/step-types.d.ts.map +1 -1
- package/dist/src/codegen/extract/step-types.js.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.d.ts +1 -1
- package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.integration.specs.js +5 -5
- package/dist/src/codegen/scaffoldFromSchema.integration.specs.js.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.js +18 -15
- package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
- package/dist/src/codegen/templates/command/commands.specs.ts +2 -2
- package/dist/src/codegen/templates/command/decide.specs.specs.ts +2 -2
- package/dist/src/codegen/templates/command/decide.specs.ts +2 -2
- package/dist/src/codegen/templates/command/events.specs.ts +2 -2
- package/dist/src/codegen/templates/command/evolve.specs.ts +2 -2
- package/dist/src/codegen/templates/command/handle.specs.ts +2 -2
- package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +2 -2
- package/dist/src/codegen/templates/command/register.specs.ts +2 -2
- package/dist/src/codegen/templates/command/state.specs.ts +2 -2
- package/dist/src/codegen/templates/query/projection.specs.specs.ts +2 -2
- package/dist/src/codegen/templates/query/projection.specs.ts +2 -2
- package/dist/src/codegen/templates/query/query.resolver.specs.ts +2 -2
- package/dist/src/codegen/templates/query/state.specs.ts +2 -2
- package/dist/src/codegen/templates/react/react.specs.specs.ts +2 -2
- package/dist/src/codegen/templates/react/react.specs.ts +2 -2
- package/dist/src/codegen/templates/react/register.specs.ts +2 -2
- 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/types.d.ts +1 -1
- package/dist/src/codegen/utils/path.js +3 -3
- package/dist/src/codegen/utils/path.js.map +1 -1
- package/dist/src/commands/generate-server.d.ts +1 -1
- package/dist/src/commands/generate-server.d.ts.map +1 -1
- package/dist/src/commands/generate-server.js +9 -10
- package/dist/src/commands/generate-server.js.map +1 -1
- package/dist/src/domain/shared/index.d.ts +1 -1
- package/dist/src/domain/shared/index.d.ts.map +1 -1
- package/dist/src/domain/shared/index.js +1 -1
- package/dist/src/domain/shared/index.js.map +1 -1
- package/dist/src/domain/shared/index.ts +1 -1
- package/dist/src/domain/shared/reactorSpecification.d.ts +5 -11
- package/dist/src/domain/shared/reactorSpecification.d.ts.map +1 -1
- package/dist/src/domain/shared/reactorSpecification.js +1 -1
- package/dist/src/domain/shared/reactorSpecification.js.map +1 -1
- package/dist/src/domain/shared/reactorSpecification.ts +7 -13
- package/dist/src/domain/shared/types.d.ts +1 -1
- package/dist/src/domain/shared/types.d.ts.map +1 -1
- package/dist/src/domain/shared/types.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/server.js.map +1 -1
- package/dist/src/server.ts +2 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +2 -2
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/index.ts +2 -2
- package/dist/src/utils/loadProjections.d.ts.map +1 -1
- package/dist/src/utils/loadProjections.js +1 -1
- package/dist/src/utils/loadProjections.js.map +1 -1
- package/dist/src/utils/loadProjections.ts +2 -2
- package/dist/src/utils/loadRegisterFiles.d.ts +1 -1
- package/dist/src/utils/loadRegisterFiles.d.ts.map +1 -1
- package/dist/src/utils/loadRegisterFiles.js +1 -1
- package/dist/src/utils/loadRegisterFiles.js.map +1 -1
- package/dist/src/utils/loadRegisterFiles.ts +3 -3
- package/dist/src/utils/loadResolvers.d.ts +1 -3
- package/dist/src/utils/loadResolvers.d.ts.map +1 -1
- package/dist/src/utils/loadResolvers.js.map +1 -1
- package/dist/src/utils/loadResolvers.ts +1 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -8
- package/src/codegen/extract/commands.ts +1 -1
- package/src/codegen/extract/events.ts +1 -1
- package/src/codegen/extract/fields.ts +1 -1
- package/src/codegen/extract/graphql.ts +2 -2
- package/src/codegen/extract/gwt.ts +1 -1
- package/src/codegen/extract/imports.ts +1 -1
- package/src/codegen/extract/index.ts +3 -3
- package/src/codegen/extract/messages.ts +3 -3
- package/src/codegen/extract/projection.ts +1 -1
- package/src/codegen/extract/slice-normalizer.ts +4 -4
- package/src/codegen/extract/states.ts +2 -2
- package/src/codegen/extract/step-converter.ts +6 -6
- package/src/codegen/extract/step-types.ts +1 -2
- package/src/codegen/scaffoldFromSchema.integration.specs.ts +5 -5
- package/src/codegen/scaffoldFromSchema.ts +29 -25
- package/src/codegen/templates/command/commands.specs.ts +2 -2
- package/src/codegen/templates/command/decide.specs.specs.ts +2 -2
- package/src/codegen/templates/command/decide.specs.ts +2 -2
- package/src/codegen/templates/command/events.specs.ts +2 -2
- package/src/codegen/templates/command/evolve.specs.ts +2 -2
- package/src/codegen/templates/command/handle.specs.ts +2 -2
- package/src/codegen/templates/command/mutation.resolver.specs.ts +2 -2
- package/src/codegen/templates/command/register.specs.ts +2 -2
- package/src/codegen/templates/command/state.specs.ts +2 -2
- package/src/codegen/templates/query/projection.specs.specs.ts +2 -2
- package/src/codegen/templates/query/projection.specs.ts +2 -2
- package/src/codegen/templates/query/query.resolver.specs.ts +2 -2
- package/src/codegen/templates/query/state.specs.ts +2 -2
- package/src/codegen/templates/react/react.specs.specs.ts +2 -2
- package/src/codegen/templates/react/react.specs.ts +2 -2
- package/src/codegen/templates/react/register.specs.ts +2 -2
- package/src/codegen/test-data/specVariant1.ts +1 -1
- package/src/codegen/types.ts +1 -1
- package/src/codegen/utils/path.ts +3 -3
- package/src/commands/generate-server.ts +10 -11
- package/src/domain/shared/index.ts +1 -1
- package/src/domain/shared/reactorSpecification.ts +7 -13
- package/src/domain/shared/types.ts +1 -1
- package/src/index.ts +6 -6
- package/src/server.ts +2 -2
- package/src/utils/index.ts +2 -2
- package/src/utils/loadProjections.ts +2 -2
- package/src/utils/loadRegisterFiles.ts +3 -3
- package/src/utils/loadResolvers.ts +1 -3
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/narrative": "0.
|
|
35
|
-
"@auto-engineer/message-bus": "0.
|
|
34
|
+
"@auto-engineer/narrative": "0.14.0",
|
|
35
|
+
"@auto-engineer/message-bus": "0.14.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -43,18 +43,14 @@
|
|
|
43
43
|
"typescript": "^5.8.3",
|
|
44
44
|
"vitest": "^3.2.4",
|
|
45
45
|
"tsx": "^4.19.2",
|
|
46
|
-
"@auto-engineer/cli": "0.
|
|
46
|
+
"@auto-engineer/cli": "0.14.0"
|
|
47
47
|
},
|
|
48
|
-
"version": "0.
|
|
48
|
+
"version": "0.14.0",
|
|
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",
|
|
52
52
|
"test": "vitest run --reporter=dot",
|
|
53
53
|
"type-check": "tsc --noEmit --project tsconfig.json",
|
|
54
|
-
"lint": "eslint 'src/**/*.ts' --ignore-pattern '**/*.specs.ts' --ignore-pattern '**/.tmp/**' --max-warnings 0 --config ../../eslint.config.ts",
|
|
55
|
-
"format": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
56
|
-
"lint:fix": "eslint 'src/**/*.ts' --ignore-pattern '**/*.specs.ts' --ignore-pattern '**/.tmp/**' --fix --config ../../eslint.config.ts",
|
|
57
|
-
"format:fix": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
58
54
|
"link:dev": "pnpm build && pnpm link --global",
|
|
59
55
|
"unlink:dev": "pnpm unlink --global"
|
|
60
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommandRef, ErrorRef, EventRef, Message, MessageDefinition } from '../types';
|
|
2
2
|
import { extractFieldsFromMessage } from './fields';
|
|
3
3
|
|
|
4
4
|
function createCommandMessage(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type OperationDefinitionNode, parse, print, type TypeNode } from 'graphql';
|
|
2
2
|
|
|
3
3
|
export interface ParsedArg {
|
|
4
4
|
name: string;
|
|
@@ -88,7 +88,7 @@ export function parseGraphQlRequest(request: string): ParsedGraphQlQuery {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const baseName = field.name.value;
|
|
91
|
-
const returnType = pascalCase(baseName)
|
|
91
|
+
const returnType = `${pascalCase(baseName)}View`;
|
|
92
92
|
|
|
93
93
|
return {
|
|
94
94
|
queryName: baseName,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Slice } from '@auto-engineer/narrative';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CommandRef, EventRef, GwtCondition } from '../types';
|
|
3
3
|
import { extractGwtSpecsFromSlice, type GwtConditionWithRule } from './step-converter';
|
|
4
4
|
|
|
5
5
|
export function buildCommandGwtMapping(slice: Slice): Record<string, (GwtCondition & { failingFields?: string[] })[]> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './commands';
|
|
2
2
|
export * from './events';
|
|
3
3
|
export * from './gwt';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './imports';
|
|
5
5
|
export * from './messages';
|
|
6
|
-
export * from './query';
|
|
7
6
|
export * from './projection';
|
|
8
|
-
export * from './
|
|
7
|
+
export * from './query';
|
|
8
|
+
export * from './states';
|
|
9
9
|
export * from './type-helpers';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { extractCommandsFromGwt, extractCommandsFromThen } from './commands';
|
|
2
1
|
import type { Slice } from '@auto-engineer/narrative';
|
|
3
|
-
import
|
|
2
|
+
import createDebug from 'debug';
|
|
3
|
+
import type { CommandRef, EventRef, Message, MessageDefinition } from '../types';
|
|
4
|
+
import { extractCommandsFromGwt, extractCommandsFromThen } from './commands';
|
|
4
5
|
import { extractEventsFromGiven, extractEventsFromThen, extractEventsFromWhen } from './events';
|
|
5
6
|
import { extractFieldsFromMessage } from './fields';
|
|
6
7
|
import { extractProjectionIdField, extractProjectionSingleton } from './projection';
|
|
7
8
|
import { extractStatesFromData, extractStatesFromTarget } from './states';
|
|
8
9
|
import { extractGwtFromSpecs } from './step-converter';
|
|
9
|
-
import createDebug from 'debug';
|
|
10
10
|
|
|
11
11
|
const debug = createDebug('auto:server-generator-apollo-emmett:extract:messages');
|
|
12
12
|
const debugCommand = createDebug('auto:server-generator-apollo-emmett:extract:messages:command');
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Slice, Spec } from '@auto-engineer/narrative';
|
|
2
2
|
import {
|
|
3
3
|
type CommandRef,
|
|
4
|
-
type EventRef,
|
|
5
|
-
type StateRef,
|
|
6
4
|
type ErrorRef,
|
|
7
|
-
type
|
|
8
|
-
getSliceType,
|
|
5
|
+
type EventRef,
|
|
9
6
|
extractGwtFromSpecs,
|
|
10
7
|
type GwtConditionWithRule,
|
|
8
|
+
getSliceType,
|
|
9
|
+
type SliceType,
|
|
10
|
+
type StateRef,
|
|
11
11
|
} from './step-converter';
|
|
12
12
|
|
|
13
13
|
interface NormalizedExample {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Slice } from '@auto-engineer/narrative';
|
|
2
|
-
import { Message, MessageDefinition } from '../types';
|
|
1
|
+
import type { Slice } from '@auto-engineer/narrative';
|
|
2
|
+
import type { Message, MessageDefinition } from '../types';
|
|
3
3
|
import { extractFieldsFromMessage } from './fields';
|
|
4
4
|
|
|
5
5
|
interface DataItem {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Example,
|
|
1
|
+
import type { Example, Slice, Spec } from '@auto-engineer/narrative';
|
|
2
2
|
import {
|
|
3
|
-
type SliceType,
|
|
4
|
-
type MajorKeyword,
|
|
5
3
|
type CommandRef,
|
|
6
|
-
type EventRef,
|
|
7
|
-
type StateRef,
|
|
8
4
|
type ErrorRef,
|
|
5
|
+
type EventRef,
|
|
6
|
+
getSliceType,
|
|
9
7
|
isStepWithDocString,
|
|
10
8
|
isStepWithError,
|
|
9
|
+
type MajorKeyword,
|
|
11
10
|
resolveMajorKeyword,
|
|
12
|
-
|
|
11
|
+
type SliceType,
|
|
12
|
+
type StateRef,
|
|
13
13
|
} from './step-types';
|
|
14
14
|
|
|
15
15
|
export type { CommandRef, EventRef, StateRef, ErrorRef, SliceType };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Step,
|
|
2
|
-
import type { StepWithDocStringSchema, StepWithErrorSchema } from '@auto-engineer/narrative';
|
|
1
|
+
import type { Slice, Step, StepWithDocStringSchema, StepWithErrorSchema } from '@auto-engineer/narrative';
|
|
3
2
|
import type { z } from 'zod';
|
|
4
3
|
|
|
5
4
|
export type StepWithDocString = z.infer<typeof StepWithDocStringSchema>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
2
4
|
import { execa } from 'execa';
|
|
3
|
-
import
|
|
4
|
-
import { mkdir, readdir, rm } from 'fs/promises';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
5
|
+
import { describe, it } from 'vitest';
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
|
|
@@ -53,7 +53,7 @@ describe.skip('generateServer integration test', { timeout: 20000 }, () => {
|
|
|
53
53
|
const testResult = await execa('npx', ['vitest', 'run', '--dir', serverDir], {
|
|
54
54
|
reject: false,
|
|
55
55
|
});
|
|
56
|
-
const output = testResult.stdout
|
|
56
|
+
const output = `${testResult.stdout}\n${testResult.stderr}`;
|
|
57
57
|
|
|
58
58
|
const notYetImplementedMatches = output.match(/Not yet implemented: \w+/g) ?? [];
|
|
59
59
|
const otherFailures = output.includes('FAIL') && !output.includes('Not yet implemented') ? output : '';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import {
|
|
5
|
-
import ejs from 'ejs';
|
|
6
|
-
import { ensureDirExists, ensureDirPath, toKebabCase } from './utils/path';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path, { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import type { Model, Narrative, Slice } from '@auto-engineer/narrative';
|
|
7
5
|
import { camelCase, pascalCase } from 'change-case';
|
|
8
|
-
import prettier from 'prettier';
|
|
9
|
-
import { Narrative, Slice, Model } from '@auto-engineer/narrative';
|
|
10
6
|
import createDebug from 'debug';
|
|
7
|
+
import ejs from 'ejs';
|
|
8
|
+
import prettier from 'prettier';
|
|
9
|
+
import { ensureDirExists, ensureDirPath, toKebabCase } from './utils/path';
|
|
11
10
|
|
|
12
11
|
const debug = createDebug('auto:server-generator-apollo-emmett:scaffold');
|
|
13
12
|
const debugTemplate = createDebug('auto:server-generator-apollo-emmett:scaffold:template');
|
|
@@ -16,29 +15,30 @@ const debugFlow = createDebug('auto:server-generator-apollo-emmett:scaffold:flow
|
|
|
16
15
|
const debugSlice = createDebug('auto:server-generator-apollo-emmett:scaffold:slice');
|
|
17
16
|
const debugPlan = createDebug('auto:server-generator-apollo-emmett:scaffold:plan');
|
|
18
17
|
const debugFormat = createDebug('auto:server-generator-apollo-emmett:scaffold:format');
|
|
18
|
+
|
|
19
19
|
import {
|
|
20
|
+
baseTs,
|
|
20
21
|
buildCommandGwtMapping,
|
|
21
22
|
buildQueryGwtMapping,
|
|
23
|
+
createCollectEnumNames,
|
|
24
|
+
createEventUnionType,
|
|
25
|
+
createFieldUsesDate,
|
|
26
|
+
createFieldUsesFloat,
|
|
27
|
+
createFieldUsesJSON,
|
|
28
|
+
createIsEnumType,
|
|
22
29
|
extractMessagesFromSpecs,
|
|
23
30
|
extractProjectionName,
|
|
24
|
-
groupEventImports,
|
|
25
31
|
getAllEventTypes,
|
|
26
32
|
getLocalEvents,
|
|
27
|
-
|
|
28
|
-
isInlineObject as isInlineObjectHelper,
|
|
33
|
+
groupEventImports,
|
|
29
34
|
isInlineObjectArray as isInlineObjectArrayHelper,
|
|
30
|
-
|
|
31
|
-
createIsEnumType,
|
|
32
|
-
createFieldUsesDate,
|
|
33
|
-
createFieldUsesJSON,
|
|
34
|
-
createFieldUsesFloat,
|
|
35
|
-
createCollectEnumNames,
|
|
35
|
+
isInlineObject as isInlineObjectHelper,
|
|
36
36
|
} from './extract';
|
|
37
|
-
import { extractGwtSpecsFromSlice, type GwtResult } from './extract/step-converter';
|
|
38
|
-
import { normalizeSliceForTemplate } from './extract/slice-normalizer';
|
|
39
|
-
import { Message, MessageDefinition, GwtCondition } from './types';
|
|
40
|
-
import { parseGraphQlRequest } from './extract/graphql';
|
|
41
37
|
import { getStreamFromSink } from './extract/data-sink';
|
|
38
|
+
import { parseGraphQlRequest } from './extract/graphql';
|
|
39
|
+
import { normalizeSliceForTemplate } from './extract/slice-normalizer';
|
|
40
|
+
import { extractGwtSpecsFromSlice, type GwtResult } from './extract/step-converter';
|
|
41
|
+
import type { GwtCondition, Message, MessageDefinition } from './types';
|
|
42
42
|
|
|
43
43
|
const defaultFilesByType: Record<string, string[]> = {
|
|
44
44
|
command: [
|
|
@@ -242,11 +242,13 @@ async function appendEnumsToSharedTypes(baseDir: string, enums: EnumDefinition[]
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
const prettierConfig = await prettier.resolveConfig(sharedTypesPath);
|
|
246
245
|
const formatted = await prettier.format(newContent, {
|
|
247
|
-
...prettierConfig,
|
|
248
246
|
parser: 'typescript',
|
|
249
247
|
filepath: sharedTypesPath,
|
|
248
|
+
singleQuote: true,
|
|
249
|
+
trailingComma: 'all',
|
|
250
|
+
printWidth: 120,
|
|
251
|
+
tabWidth: 2,
|
|
250
252
|
});
|
|
251
253
|
|
|
252
254
|
await fs.mkdir(path.dirname(sharedTypesPath), { recursive: true });
|
|
@@ -435,11 +437,13 @@ async function generateFileForTemplate(
|
|
|
435
437
|
debugFiles(' Rendered content size: %d bytes', contents.length);
|
|
436
438
|
|
|
437
439
|
debugFiles(' Formatting with Prettier...');
|
|
438
|
-
const prettierConfig = await prettier.resolveConfig(outputPath);
|
|
439
440
|
const formattedContents = await prettier.format(contents, {
|
|
440
|
-
...prettierConfig,
|
|
441
441
|
parser: 'typescript',
|
|
442
442
|
filepath: outputPath,
|
|
443
|
+
singleQuote: true,
|
|
444
|
+
trailingComma: 'all',
|
|
445
|
+
printWidth: 120,
|
|
446
|
+
tabWidth: 2,
|
|
443
447
|
});
|
|
444
448
|
debugFiles(' Formatted content size: %d bytes', formattedContents.length);
|
|
445
449
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('commands.ts.ejs', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('spec.ts.ejs', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('decide.ts.ejs', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('events.ts.ejs', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('evolve.ts.ejs', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
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 () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('query.resolver.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid query resolver from request field', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
3
|
-
import { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
4
4
|
|
|
5
5
|
describe('state.ts.ejs', () => {
|
|
6
6
|
it('should generate a valid state definition file for a query slice with a state message', async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('react.specs.ts.ejs (react slice)', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('handle.ts.ejs (react slice)', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Model as SpecsSchema } from '@auto-engineer/narrative';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema';
|
|
4
4
|
|
|
5
5
|
describe('register.ts.ejs (react slice)', () => {
|
package/src/codegen/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mkdir } from 'fs/promises';
|
|
3
|
-
import
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
4
|
|
|
5
5
|
export function toKebabCase(str: string): string {
|
|
6
6
|
return str
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { type Command, defineCommandHandler, type Event } from '@auto-engineer/message-bus';
|
|
7
|
+
import type { Model } from '@auto-engineer/narrative';
|
|
8
|
+
import createDebug from 'debug';
|
|
9
|
+
import { execa } from 'execa';
|
|
1
10
|
import fs from 'fs-extra';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { readFile, writeFile } from 'fs/promises';
|
|
4
|
-
import { resolve, join } from 'path';
|
|
5
|
-
import { existsSync } from 'fs';
|
|
6
11
|
import { generateScaffoldFilePlans, writeScaffoldFilePlans } from '../codegen/scaffoldFromSchema';
|
|
7
12
|
import { ensureDirExists, ensureDirPath, toKebabCase } from '../codegen/utils/path';
|
|
8
|
-
import { Model } from '@auto-engineer/narrative';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import { dirname } from 'path';
|
|
11
|
-
import { execa } from 'execa';
|
|
12
|
-
import createDebug from 'debug';
|
|
13
|
-
import { defineCommandHandler, Command, Event } from '@auto-engineer/message-bus';
|
|
14
13
|
|
|
15
14
|
const debug = createDebug('auto:server-generator-apollo-emmett');
|
|
16
15
|
const debugModel = createDebug('auto:server-generator-apollo-emmett:schema');
|
|
@@ -346,7 +345,7 @@ async function copyRootFilesFromSrc(from: string, to: string): Promise<void> {
|
|
|
346
345
|
|
|
347
346
|
// If "from" is a file, copy it directly to directory "to" maintaining filename
|
|
348
347
|
const fromStat = await fs.stat(from).catch(() => undefined);
|
|
349
|
-
if (fromStat
|
|
348
|
+
if (fromStat?.isFile()) {
|
|
350
349
|
debugFiles(' Source is a file, copying directly');
|
|
351
350
|
await fs.ensureDir(to);
|
|
352
351
|
const destFile = path.join(to, path.basename(from));
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CommandSender,
|
|
3
|
-
isErrorConstructor,
|
|
4
|
-
type ErrorConstructor,
|
|
5
2
|
AssertionError,
|
|
6
3
|
assertTrue,
|
|
4
|
+
type CommandSender,
|
|
5
|
+
type ErrorConstructor,
|
|
6
|
+
isErrorConstructor,
|
|
7
7
|
type MessageProcessor,
|
|
8
8
|
} from '@event-driven-io/emmett';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
(command: CommandType): boolean;
|
|
12
|
-
}
|
|
10
|
+
type CommandCheck<CommandType> = (command: CommandType) => boolean;
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
(error: ErrorType): boolean;
|
|
16
|
-
}
|
|
12
|
+
type ErrorCheck<ErrorType> = (error: ErrorType) => boolean;
|
|
17
13
|
|
|
18
14
|
export type ThenThrows<ErrorType extends Error> =
|
|
19
15
|
| (() => void)
|
|
@@ -32,13 +28,11 @@ interface ReactorSpecificationReturn<Event, Command, Context> {
|
|
|
32
28
|
};
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
export
|
|
31
|
+
export type ReactorSpecification<
|
|
36
32
|
Event,
|
|
37
33
|
Command,
|
|
38
34
|
Context extends { commandSender: CommandSender } = { commandSender: CommandSender },
|
|
39
|
-
>
|
|
40
|
-
(givenEvents: Event | Event[]): ReactorSpecificationReturn<Event, Command, Context>;
|
|
41
|
-
}
|
|
35
|
+
> = (givenEvents: Event | Event[]) => ReactorSpecificationReturn<Event, Command, Context>;
|
|
42
36
|
|
|
43
37
|
export const ReactorSpecification = {
|
|
44
38
|
for: reactorSpecificationFor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { registerEnumType } from 'type-graphql';
|
|
2
2
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
|
-
import { CommandSender, EventStore,
|
|
4
|
+
import type { CommandSender, EventStore, InMemoryDatabase } from '@event-driven-io/emmett';
|
|
5
5
|
|
|
6
6
|
export interface ReactorContext {
|
|
7
7
|
eventStore: EventStore;
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { commandHandler as generateServerHandler } from './commands/generate-server';
|
|
2
2
|
|
|
3
3
|
export const COMMANDS = [generateServerHandler];
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export type {
|
|
5
|
+
GenerateServerCommand,
|
|
6
|
+
GenerateServerEvents,
|
|
7
|
+
ServerGeneratedEvent,
|
|
8
|
+
ServerGenerationFailedEvent,
|
|
9
|
+
SliceGeneratedEvent,
|
|
10
10
|
} from './commands/generate-server';
|
package/src/server.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { getInMemoryDatabase, getInMemoryMessageBus, handleInMemoryProjections } from '@event-driven-io/emmett';
|
|
3
|
+
import { getSQLiteEventStore } from '@event-driven-io/emmett-sqlite';
|
|
2
4
|
import { ApolloServer } from 'apollo-server';
|
|
3
5
|
import { buildSchema } from 'type-graphql';
|
|
4
6
|
import { loadProjections, loadRegisterFiles, loadResolvers } from './utils';
|
|
5
|
-
import { getInMemoryMessageBus, getInMemoryDatabase, handleInMemoryProjections } from '@event-driven-io/emmett';
|
|
6
|
-
import { getSQLiteEventStore } from '@event-driven-io/emmett-sqlite';
|
|
7
7
|
|
|
8
8
|
async function start() {
|
|
9
9
|
const loadedProjections = await loadProjections('src/domain/flows/**/projection.{ts,js}');
|
package/src/utils/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
3
2
|
import type { ProjectionDefinition } from '@event-driven-io/emmett';
|
|
3
|
+
import fg from 'fast-glob';
|
|
4
4
|
|
|
5
5
|
export async function loadProjections(source: string): Promise<ProjectionDefinition[]> {
|
|
6
6
|
const files = await fg(source, { absolute: true });
|