@auto-engineer/server-generator-apollo-emmett 1.144.0 → 1.146.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 +6 -6
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +55 -0
- package/dist/src/codegen/extract/imports.js +1 -1
- package/dist/src/codegen/extract/imports.js.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.d.ts +11 -1
- package/dist/src/codegen/scaffoldFromSchema.d.ts.map +1 -1
- package/dist/src/codegen/scaffoldFromSchema.js +52 -9
- package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
- package/dist/src/codegen/templates/command/handle.specs.ts +201 -0
- package/dist/src/codegen/templates/command/handle.ts.ejs +34 -0
- package/dist/src/codegen/templates/query/projection.specs.ts +3 -10
- package/dist/src/codegen/templates/query/query.resolver.specs.ts +6 -20
- package/dist/src/codegen/templates/query/query.resolver.ts.ejs +14 -5
- package/dist/src/codegen/templates/react/react.specs.ts.ejs +2 -2
- package/dist/src/codegen/templates/react/react.ts.ejs +1 -1
- package/dist/src/codegen/templates/react/register.ts.ejs +1 -1
- package/dist/src/codegen/types.d.ts +1 -0
- package/dist/src/codegen/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ketchup-plan.md +5 -6
- package/package.json +4 -4
- package/src/codegen/buildCrossSceneGivens.specs.ts +263 -0
- package/src/codegen/extract/imports.specs.ts +26 -0
- package/src/codegen/extract/imports.ts +1 -1
- package/src/codegen/scaffoldFromSchema.ts +73 -5
- package/src/codegen/templates/command/handle.specs.ts +201 -0
- package/src/codegen/templates/command/handle.ts.ejs +34 -0
- package/src/codegen/templates/query/projection.specs.ts +3 -10
- package/src/codegen/templates/query/query.resolver.specs.ts +6 -20
- package/src/codegen/templates/query/query.resolver.ts.ejs +14 -5
- package/src/codegen/templates/react/react.specs.ts.ejs +2 -2
- package/src/codegen/templates/react/react.ts.ejs +1 -1
- package/src/codegen/templates/react/register.ts.ejs +1 -1
- package/src/codegen/types.ts +1 -0
|
@@ -579,4 +579,205 @@ describe('generateScaffoldFilePlans', () => {
|
|
|
579
579
|
"
|
|
580
580
|
`);
|
|
581
581
|
});
|
|
582
|
+
it('should generate aggregateStream pre-loading for cross-scene Given events', async () => {
|
|
583
|
+
const spec: SpecsSchema = {
|
|
584
|
+
variant: 'specs',
|
|
585
|
+
scenes: [
|
|
586
|
+
{
|
|
587
|
+
name: 'Workouts management',
|
|
588
|
+
moments: [
|
|
589
|
+
{
|
|
590
|
+
type: 'command',
|
|
591
|
+
name: 'Create workout',
|
|
592
|
+
stream: 'workout-${workoutId}',
|
|
593
|
+
client: { specs: [] },
|
|
594
|
+
server: {
|
|
595
|
+
description: '',
|
|
596
|
+
specs: [
|
|
597
|
+
{
|
|
598
|
+
type: 'gherkin',
|
|
599
|
+
feature: 'Create workout',
|
|
600
|
+
rules: [
|
|
601
|
+
{
|
|
602
|
+
name: 'Should create',
|
|
603
|
+
examples: [
|
|
604
|
+
{
|
|
605
|
+
name: 'Workout created',
|
|
606
|
+
steps: [
|
|
607
|
+
{ keyword: 'When', text: 'CreateWorkout', docString: { workoutId: 'w1', name: 'Legs' } },
|
|
608
|
+
{
|
|
609
|
+
keyword: 'Then',
|
|
610
|
+
text: 'WorkoutCreated',
|
|
611
|
+
docString: { workoutId: 'w1', name: 'Legs' },
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
},
|
|
615
|
+
],
|
|
616
|
+
},
|
|
617
|
+
],
|
|
618
|
+
},
|
|
619
|
+
],
|
|
620
|
+
data: {
|
|
621
|
+
items: [
|
|
622
|
+
{
|
|
623
|
+
target: { type: 'Event', name: 'WorkoutCreated' },
|
|
624
|
+
destination: { type: 'stream', pattern: 'workout-${workoutId}' },
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
name: 'Profile and progress',
|
|
634
|
+
moments: [
|
|
635
|
+
{
|
|
636
|
+
type: 'command',
|
|
637
|
+
name: 'Record progress',
|
|
638
|
+
stream: 'progress-${progressId}',
|
|
639
|
+
client: { specs: [] },
|
|
640
|
+
server: {
|
|
641
|
+
description: '',
|
|
642
|
+
specs: [
|
|
643
|
+
{
|
|
644
|
+
type: 'gherkin',
|
|
645
|
+
feature: 'Record progress',
|
|
646
|
+
rules: [
|
|
647
|
+
{
|
|
648
|
+
name: 'Should record progress',
|
|
649
|
+
examples: [
|
|
650
|
+
{
|
|
651
|
+
name: 'Progress recorded after workout',
|
|
652
|
+
steps: [
|
|
653
|
+
{
|
|
654
|
+
keyword: 'Given',
|
|
655
|
+
text: 'WorkoutCreated',
|
|
656
|
+
docString: { workoutId: 'w1', name: 'Legs' },
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
keyword: 'When',
|
|
660
|
+
text: 'RecordProgress',
|
|
661
|
+
docString: { workoutId: 'w1', date: '2024-01-01' },
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
keyword: 'Then',
|
|
665
|
+
text: 'ProgressRecorded',
|
|
666
|
+
docString: { workoutId: 'w1', date: '2024-01-01' },
|
|
667
|
+
},
|
|
668
|
+
],
|
|
669
|
+
},
|
|
670
|
+
],
|
|
671
|
+
},
|
|
672
|
+
],
|
|
673
|
+
},
|
|
674
|
+
],
|
|
675
|
+
data: {
|
|
676
|
+
items: [
|
|
677
|
+
{
|
|
678
|
+
target: { type: 'Event', name: 'ProgressRecorded' },
|
|
679
|
+
destination: { type: 'stream', pattern: 'progress-${progressId}' },
|
|
680
|
+
},
|
|
681
|
+
],
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
],
|
|
686
|
+
},
|
|
687
|
+
],
|
|
688
|
+
messages: [
|
|
689
|
+
{
|
|
690
|
+
type: 'command',
|
|
691
|
+
name: 'CreateWorkout',
|
|
692
|
+
fields: [
|
|
693
|
+
{ name: 'workoutId', type: 'string', required: true },
|
|
694
|
+
{ name: 'name', type: 'string', required: true },
|
|
695
|
+
],
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
type: 'command',
|
|
699
|
+
name: 'RecordProgress',
|
|
700
|
+
fields: [
|
|
701
|
+
{ name: 'workoutId', type: 'string', required: true },
|
|
702
|
+
{ name: 'date', type: 'Date', required: true },
|
|
703
|
+
],
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
type: 'event',
|
|
707
|
+
name: 'WorkoutCreated',
|
|
708
|
+
source: 'internal',
|
|
709
|
+
fields: [
|
|
710
|
+
{ name: 'workoutId', type: 'string', required: true },
|
|
711
|
+
{ name: 'name', type: 'string', required: true },
|
|
712
|
+
],
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
type: 'event',
|
|
716
|
+
name: 'ProgressRecorded',
|
|
717
|
+
source: 'internal',
|
|
718
|
+
fields: [
|
|
719
|
+
{ name: 'workoutId', type: 'string', required: true },
|
|
720
|
+
{ name: 'date', type: 'Date', required: true },
|
|
721
|
+
],
|
|
722
|
+
},
|
|
723
|
+
],
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const { plans } = await generateScaffoldFilePlans(spec.scenes, spec.messages, undefined, 'src/domain/narratives');
|
|
727
|
+
|
|
728
|
+
const recordProgressHandle = plans.find(
|
|
729
|
+
(p) => p.outputPath.includes('record-progress') && p.outputPath.endsWith('handle.ts'),
|
|
730
|
+
);
|
|
731
|
+
expect(recordProgressHandle?.contents).toMatchInlineSnapshot(`
|
|
732
|
+
"import { randomUUID } from 'node:crypto';
|
|
733
|
+
|
|
734
|
+
import { CommandHandler, type EventStore, type MessageHandlerResult } from '@event-driven-io/emmett';
|
|
735
|
+
import { evolve } from './evolve';
|
|
736
|
+
import { initialState } from './state';
|
|
737
|
+
import { decide } from './decide';
|
|
738
|
+
import type { RecordProgress } from './commands';
|
|
739
|
+
|
|
740
|
+
export const handle = async (eventStore: EventStore, command: RecordProgress): Promise<MessageHandlerResult> => {
|
|
741
|
+
const streamId = \`progress-\${randomUUID()}\`;
|
|
742
|
+
|
|
743
|
+
const { state: preLoadedState } = await eventStore.aggregateStream(\`workout-\${command.data.workoutId}\`, {
|
|
744
|
+
evolve,
|
|
745
|
+
initialState: initialState,
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
const handler = CommandHandler({
|
|
749
|
+
evolve,
|
|
750
|
+
initialState: () => preLoadedState,
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
await handler(eventStore, streamId, (state) => decide(command, state));
|
|
754
|
+
return undefined;
|
|
755
|
+
};
|
|
756
|
+
"
|
|
757
|
+
`);
|
|
758
|
+
|
|
759
|
+
const createWorkoutHandle = plans.find(
|
|
760
|
+
(p) => p.outputPath.includes('create-workout') && p.outputPath.endsWith('handle.ts'),
|
|
761
|
+
);
|
|
762
|
+
expect(createWorkoutHandle?.contents).toMatchInlineSnapshot(`
|
|
763
|
+
"import { CommandHandler, type EventStore, type MessageHandlerResult } from '@event-driven-io/emmett';
|
|
764
|
+
import { evolve } from './evolve';
|
|
765
|
+
import { initialState } from './state';
|
|
766
|
+
import { decide } from './decide';
|
|
767
|
+
import type { CreateWorkout } from './commands';
|
|
768
|
+
|
|
769
|
+
const handler = CommandHandler({
|
|
770
|
+
evolve,
|
|
771
|
+
initialState,
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
export const handle = async (eventStore: EventStore, command: CreateWorkout): Promise<MessageHandlerResult> => {
|
|
775
|
+
const streamId = \`workout-\${command.data.workoutId}\`;
|
|
776
|
+
|
|
777
|
+
await handler(eventStore, streamId, (state) => decide(command, state));
|
|
778
|
+
return undefined;
|
|
779
|
+
};
|
|
780
|
+
"
|
|
781
|
+
`);
|
|
782
|
+
});
|
|
582
783
|
});
|
|
@@ -66,6 +66,10 @@ const needsStreamGuard = streamVars.length > 0 && !allCmdFieldSets.every(fs => s
|
|
|
66
66
|
const varInAnyCommand = (v) => allCmdFieldSets.some(fs => fs.has(v));
|
|
67
67
|
const guardVars = needsStreamGuard ? streamVars.filter(v => varInAnyCommand(v)) : [];
|
|
68
68
|
const uuidVars = needsStreamGuard ? streamVars.filter(v => !varInAnyCommand(v)) : [];
|
|
69
|
+
|
|
70
|
+
const csGivens = (crossSceneGivens || []);
|
|
71
|
+
const resolvedCsGivens = csGivens.filter(g => g.allVarsResolved);
|
|
72
|
+
const hasCrossScene = resolvedCsGivens.length > 0;
|
|
69
73
|
%>
|
|
70
74
|
|
|
71
75
|
<% if (uuidVars.length > 0) { -%>
|
|
@@ -92,11 +96,13 @@ import type { <%= commands.map(c => pascalCase(c.type)).join(', ') %> } from './
|
|
|
92
96
|
*/
|
|
93
97
|
<% } -%>
|
|
94
98
|
|
|
99
|
+
<% if (!hasCrossScene) { -%>
|
|
95
100
|
const handler = CommandHandler({
|
|
96
101
|
evolve,
|
|
97
102
|
initialState,
|
|
98
103
|
});
|
|
99
104
|
|
|
105
|
+
<% } -%>
|
|
100
106
|
export const handle = async (
|
|
101
107
|
eventStore: EventStore,
|
|
102
108
|
command: <%= commands.map(c => pascalCase(c.type)).join(' | ') %>
|
|
@@ -122,6 +128,34 @@ command: <%= commands.map(c => pascalCase(c.type)).join(' | ') %>
|
|
|
122
128
|
const streamId = '<%= stream?.pattern ?? 'unknown-stream' %>';
|
|
123
129
|
<% } -%>
|
|
124
130
|
|
|
131
|
+
<% if (hasCrossScene) { -%>
|
|
132
|
+
<% resolvedCsGivens.forEach((csg, i) => {
|
|
133
|
+
const stateVar = resolvedCsGivens.length === 1
|
|
134
|
+
? 'preLoadedState'
|
|
135
|
+
: `preLoadedState${i}`;
|
|
136
|
+
const prevInitial = i === 0
|
|
137
|
+
? 'initialState'
|
|
138
|
+
: resolvedCsGivens.length === 1
|
|
139
|
+
? '() => preLoadedState'
|
|
140
|
+
: `() => preLoadedState${i - 1}`;
|
|
141
|
+
const resolvedPattern = csg.sourceStreamPattern.replace(
|
|
142
|
+
/\$\{([^}]+)\}/g, (_, key) => {
|
|
143
|
+
const link = csg.linkingFields.find(l => l.streamVar === key);
|
|
144
|
+
return '${command.data.' + link.commandField + '}';
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
-%>
|
|
148
|
+
const { state: <%= stateVar %> } = await eventStore.aggregateStream(`<%= resolvedPattern %>`, { evolve, initialState: <%= prevInitial %> });
|
|
149
|
+
<% }) -%>
|
|
150
|
+
|
|
151
|
+
const handler = CommandHandler({
|
|
152
|
+
evolve,
|
|
153
|
+
initialState: () => <%= resolvedCsGivens.length === 1
|
|
154
|
+
? 'preLoadedState'
|
|
155
|
+
: `preLoadedState${resolvedCsGivens.length - 1}` %>,
|
|
156
|
+
});
|
|
157
|
+
<% } -%>
|
|
158
|
+
|
|
125
159
|
<% integrationCalls.forEach(({ call }) => { -%>
|
|
126
160
|
<%= call %>
|
|
127
161
|
|
|
@@ -400,21 +400,14 @@ describe('projection.ts.ejs', () => {
|
|
|
400
400
|
|
|
401
401
|
@Resolver()
|
|
402
402
|
export class ViewWishlistQueryResolver {
|
|
403
|
-
@Query(() =>
|
|
403
|
+
@Query(() => Wishlist, { nullable: true })
|
|
404
404
|
async wishlist(
|
|
405
405
|
@Ctx() ctx: GraphQLContext,
|
|
406
406
|
@Arg('sessionId', () => ID, { nullable: true }) sessionId?: string,
|
|
407
|
-
): Promise<Wishlist
|
|
407
|
+
): Promise<Wishlist | null> {
|
|
408
408
|
const model = new ReadModel<Wishlist>(ctx.database, 'WishlistProjection');
|
|
409
409
|
|
|
410
|
-
|
|
411
|
-
// - model.find(filterFn?) → T[] returns all matches (or all documents if no filter)
|
|
412
|
-
// - model.findOne(filterFn) → T | null returns the first match
|
|
413
|
-
//
|
|
414
|
-
// The scaffolded code below uses find() returning an array.
|
|
415
|
-
// If this query should return a single item, switch to findOne().
|
|
416
|
-
|
|
417
|
-
return model.find((item) => {
|
|
410
|
+
return model.findOne((item) => {
|
|
418
411
|
if (sessionId !== undefined && item.sessionId !== sessionId) return false;
|
|
419
412
|
|
|
420
413
|
return true;
|
|
@@ -224,21 +224,14 @@ describe('query.resolver.ts.ejs', () => {
|
|
|
224
224
|
|
|
225
225
|
@Resolver()
|
|
226
226
|
export class ViewsSuggestedItemsQueryResolver {
|
|
227
|
-
@Query(() =>
|
|
227
|
+
@Query(() => SuggestedItems, { nullable: true })
|
|
228
228
|
async suggestedItems(
|
|
229
229
|
@Ctx() ctx: GraphQLContext,
|
|
230
230
|
@Arg('sessionId', () => ID, { nullable: true }) sessionId?: string,
|
|
231
|
-
): Promise<SuggestedItems
|
|
231
|
+
): Promise<SuggestedItems | null> {
|
|
232
232
|
const model = new ReadModel<SuggestedItems>(ctx.database, 'SuggestedItemsProjection');
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
// - model.find(filterFn?) → T[] returns all matches (or all documents if no filter)
|
|
236
|
-
// - model.findOne(filterFn) → T | null returns the first match
|
|
237
|
-
//
|
|
238
|
-
// The scaffolded code below uses find() returning an array.
|
|
239
|
-
// If this query should return a single item, switch to findOne().
|
|
240
|
-
|
|
241
|
-
return model.find((item) => {
|
|
234
|
+
return model.findOne((item) => {
|
|
242
235
|
if (sessionId !== undefined && item.sessionId !== sessionId) return false;
|
|
243
236
|
|
|
244
237
|
return true;
|
|
@@ -1393,21 +1386,14 @@ describe('query.resolver.ts.ejs', () => {
|
|
|
1393
1386
|
|
|
1394
1387
|
@Resolver()
|
|
1395
1388
|
export class ViewWorkoutQueryResolver {
|
|
1396
|
-
@Query(() =>
|
|
1389
|
+
@Query(() => WorkoutView, { nullable: true })
|
|
1397
1390
|
async workout(
|
|
1398
1391
|
@Ctx() ctx: GraphQLContext,
|
|
1399
1392
|
@Arg('workoutId', () => ID, { nullable: true }) workoutId?: string,
|
|
1400
|
-
): Promise<WorkoutView
|
|
1393
|
+
): Promise<WorkoutView | null> {
|
|
1401
1394
|
const model = new ReadModel<WorkoutView>(ctx.database, 'WorkoutProjection');
|
|
1402
1395
|
|
|
1403
|
-
|
|
1404
|
-
// - model.find(filterFn?) → T[] returns all matches (or all documents if no filter)
|
|
1405
|
-
// - model.findOne(filterFn) → T | null returns the first match
|
|
1406
|
-
//
|
|
1407
|
-
// The scaffolded code below uses find() returning an array.
|
|
1408
|
-
// If this query should return a single item, switch to findOne().
|
|
1409
|
-
|
|
1410
|
-
return model.find((item) => {
|
|
1396
|
+
return model.findOne((item) => {
|
|
1411
1397
|
if (workoutId !== undefined && item.id !== workoutId) return false;
|
|
1412
1398
|
|
|
1413
1399
|
return true;
|
|
@@ -44,6 +44,15 @@ const usedArgNames = isSingleton
|
|
|
44
44
|
: new Set((parsedRequest?.args ?? []).filter(a => stateFieldNames.has(a.name) || argFieldMap[a.name]).map(a => a.name));
|
|
45
45
|
const hasMatchingArgs = usedArgNames.size > 0;
|
|
46
46
|
|
|
47
|
+
const isIdLookup = !isSingleton
|
|
48
|
+
&& typeof projectionIdField === 'string'
|
|
49
|
+
&& (parsedRequest?.args ?? []).some(a => {
|
|
50
|
+
const mapping = argFieldMap[a.name];
|
|
51
|
+
const mappedField = mapping ? mapping.field : (stateFieldNames.has(a.name) ? a.name : null);
|
|
52
|
+
const op = mapping ? mapping.operator : 'eq';
|
|
53
|
+
return mappedField === projectionIdField && op === 'eq';
|
|
54
|
+
});
|
|
55
|
+
|
|
47
56
|
const resolveArgTypes = (arg) => {
|
|
48
57
|
const isCustom = !KNOWN_GQL_SCALARS.has(arg.graphqlType);
|
|
49
58
|
return {
|
|
@@ -162,7 +171,7 @@ async <%= queryName %>(
|
|
|
162
171
|
return result;
|
|
163
172
|
}
|
|
164
173
|
<% } else { %>
|
|
165
|
-
@Query(() =>
|
|
174
|
+
@Query(() => <%= isIdLookup ? viewType + ', { nullable: true }' : '[' + viewType + ']' %>)
|
|
166
175
|
async <%= queryName %>(
|
|
167
176
|
@Ctx() ctx: GraphQLContext<% if (parsedRequest?.args?.length) { %>,
|
|
168
177
|
<% for (let i = 0; i < parsedRequest.args.length; i++) {
|
|
@@ -170,17 +179,17 @@ async <%= queryName %>(
|
|
|
170
179
|
const { gqlType, tsType } = resolveArgTypes(arg);
|
|
171
180
|
%> @Arg('<%= arg.name %>', () => <%= gqlType %>, { nullable: true }) <%= usedArgNames.has(arg.name) ? arg.name : '_' + arg.name %>?: <%= tsType %><%= i < parsedRequest.args.length - 1 ? ',' : '' %>
|
|
172
181
|
<% } } %>
|
|
173
|
-
): Promise<<%= viewType
|
|
182
|
+
): Promise<<%= isIdLookup ? viewType + ' | null' : viewType + '[]' %>> {
|
|
174
183
|
const model = new ReadModel<<%= viewType %>>(ctx.database, '<%= collectionName %>');
|
|
175
|
-
|
|
184
|
+
<% if (!isIdLookup) { %>
|
|
176
185
|
// ReadModel API:
|
|
177
186
|
// - model.find(filterFn?) → T[] returns all matches (or all documents if no filter)
|
|
178
187
|
// - model.findOne(filterFn) → T | null returns the first match
|
|
179
188
|
//
|
|
180
189
|
// The scaffolded code below uses find() returning an array.
|
|
181
190
|
// If this query should return a single item, switch to findOne().
|
|
182
|
-
|
|
183
|
-
return model
|
|
191
|
+
<% } %>
|
|
192
|
+
return model.<%= isIdLookup ? 'findOne' : 'find' %>((<%= hasMatchingArgs ? 'item' : '_item' %>) => {
|
|
184
193
|
<% if (parsedRequest?.args?.length) {
|
|
185
194
|
for (const arg of parsedRequest.args) {
|
|
186
195
|
const mapping = argFieldMap[arg.name];
|
|
@@ -39,7 +39,7 @@ for (const eventType of allUsedEvents) {
|
|
|
39
39
|
if (event) {
|
|
40
40
|
const isCrossScene = event.sourceSceneName && event.sourceSceneName !== sceneName;
|
|
41
41
|
const importPath = isCrossScene
|
|
42
|
-
? `../../${toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}/events`
|
|
42
|
+
? `../../${event.sourceSceneDirName || toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}/events`
|
|
43
43
|
: event.sourceMomentName ? `../${toKebabCase(event.sourceMomentName)}/events` : './events';
|
|
44
44
|
if (!eventImportGroups.has(importPath)) {
|
|
45
45
|
eventImportGroups.set(importPath, []);
|
|
@@ -53,7 +53,7 @@ for (const commandType of allUsedCommands) {
|
|
|
53
53
|
if (command) {
|
|
54
54
|
const isCrossScene = command.sourceSceneName && command.sourceSceneName !== sceneName;
|
|
55
55
|
const importPath = isCrossScene
|
|
56
|
-
? `../../${toKebabCase(command.sourceSceneName)}/${toKebabCase(command.sourceMomentName)}/commands`
|
|
56
|
+
? `../../${command.sourceSceneDirName || toKebabCase(command.sourceSceneName)}/${toKebabCase(command.sourceMomentName)}/commands`
|
|
57
57
|
: command.sourceMomentName ? `../${toKebabCase(command.sourceMomentName)}/commands` : './commands';
|
|
58
58
|
if (!commandImportGroups.has(importPath)) {
|
|
59
59
|
commandImportGroups.set(importPath, []);
|
|
@@ -8,7 +8,7 @@ for (const pair of eventCommandPairs) {
|
|
|
8
8
|
const event = events.find(e => e.type === pair.eventType);
|
|
9
9
|
const isCrossScene = event?.sourceSceneName && event.sourceSceneName !== sceneName;
|
|
10
10
|
const importBase = isCrossScene
|
|
11
|
-
? `../../${toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}`
|
|
11
|
+
? `../../${event.sourceSceneDirName || toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}`
|
|
12
12
|
: event?.sourceMomentName ? `../${toKebabCase(event.sourceMomentName)}` : '.';
|
|
13
13
|
if (!importGroups.has(importBase)) importGroups.set(importBase, []);
|
|
14
14
|
const typeName = pascalCase(pair.eventType);
|
|
@@ -8,7 +8,7 @@ for (const pair of eventCommandPairs) {
|
|
|
8
8
|
const event = events.find(e => e.type === pair.eventType);
|
|
9
9
|
const isCrossScene = event?.sourceSceneName && event.sourceSceneName !== sceneName;
|
|
10
10
|
const importBase = isCrossScene
|
|
11
|
-
? `../../${toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}`
|
|
11
|
+
? `../../${event.sourceSceneDirName || toKebabCase(event.sourceSceneName)}/${toKebabCase(event.sourceMomentName)}`
|
|
12
12
|
: event?.sourceMomentName ? `../${toKebabCase(event.sourceMomentName)}` : '.';
|
|
13
13
|
if (!importGroups.has(importBase)) importGroups.set(importBase, []);
|
|
14
14
|
const typeName = pascalCase(pair.eventType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErF,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAEzD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErF,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAEzD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,CAAC;IAC9B,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|