@auto-engineer/server-generator-apollo-emmett 0.8.5 → 0.8.7
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 +2 -2
- package/CHANGELOG.md +16 -0
- 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 +54 -18
- package/dist/src/codegen/scaffoldFromSchema.js.map +1 -1
- package/dist/{codegen → src/codegen}/templates/command/commands.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/command/decide.specs.specs.ts +3 -3
- package/dist/{codegen → src/codegen}/templates/command/decide.specs.ts +1 -5
- package/dist/{codegen → src/codegen}/templates/command/events.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/command/evolve.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/command/handle.specs.ts +1 -3
- package/dist/src/codegen/templates/command/mutation.resolver.specs.ts +363 -0
- package/dist/src/codegen/templates/command/mutation.resolver.ts.ejs +99 -0
- package/dist/{codegen → src/codegen}/templates/command/register.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/command/state.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/query/projection.specs.specs..ts +3 -3
- package/dist/{codegen → src/codegen}/templates/query/projection.specs.ts +5 -9
- package/dist/{codegen → src/codegen}/templates/query/query.resolver.specs.ts +194 -23
- package/dist/src/codegen/templates/query/query.resolver.ts.ejs +137 -0
- package/dist/{codegen → src/codegen}/templates/query/state.specs.ts +1 -2
- package/dist/{codegen → src/codegen}/templates/react/react.specs.specs.ts +2 -2
- package/dist/{codegen → src/codegen}/templates/react/react.specs.ts +3 -3
- package/dist/{codegen → 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 +4 -2
- package/dist/src/codegen/test-data/specVariant1.js.map +1 -1
- package/dist/src/commands/generate-server.d.ts.map +1 -1
- package/dist/src/commands/generate-server.js +34 -24
- package/dist/src/commands/generate-server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/codegen/scaffoldFromSchema.ts +52 -20
- package/src/codegen/templates/command/commands.specs.ts +1 -2
- package/src/codegen/templates/command/decide.specs.specs.ts +3 -3
- package/src/codegen/templates/command/decide.specs.ts +1 -5
- package/src/codegen/templates/command/events.specs.ts +1 -2
- package/src/codegen/templates/command/evolve.specs.ts +1 -2
- package/src/codegen/templates/command/handle.specs.ts +1 -3
- package/src/codegen/templates/command/mutation.resolver.specs.ts +247 -8
- package/src/codegen/templates/command/mutation.resolver.ts.ejs +86 -12
- package/src/codegen/templates/command/register.specs.ts +1 -2
- package/src/codegen/templates/command/state.specs.ts +1 -2
- package/src/codegen/templates/query/projection.specs.specs..ts +3 -3
- package/src/codegen/templates/query/projection.specs.ts +5 -9
- package/src/codegen/templates/query/query.resolver.specs.ts +194 -23
- package/src/codegen/templates/query/query.resolver.ts.ejs +84 -45
- package/src/codegen/templates/query/state.specs.ts +1 -2
- package/src/codegen/templates/react/react.specs.specs.ts +2 -2
- 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 +5 -3
- package/src/commands/generate-server.ts +38 -30
- package/tsconfig.test.json +9 -0
- package/.turbo/turbo-test.log +0 -14
- package/.turbo/turbo-type-check.log +0 -4
- package/dist/codegen/templates/command/mutation.resolver.specs.ts +0 -124
- package/dist/codegen/templates/command/mutation.resolver.ts.ejs +0 -25
- package/dist/codegen/templates/query/query.resolver.ts.ejs +0 -98
- package/dist/src/codegen/templates/command/commands.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/commands.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/commands.specs.js +0 -96
- package/dist/src/codegen/templates/command/commands.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/decide.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/decide.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/decide.specs.js +0 -567
- package/dist/src/codegen/templates/command/decide.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/decide.specs.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/decide.specs.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/decide.specs.specs.js +0 -278
- package/dist/src/codegen/templates/command/decide.specs.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/events.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/events.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/events.specs.js +0 -112
- package/dist/src/codegen/templates/command/events.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/evolve.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/evolve.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/evolve.specs.js +0 -108
- package/dist/src/codegen/templates/command/evolve.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/handle.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/handle.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/handle.specs.js +0 -326
- package/dist/src/codegen/templates/command/handle.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/mutation.resolver.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/mutation.resolver.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/mutation.resolver.specs.js +0 -121
- package/dist/src/codegen/templates/command/mutation.resolver.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/register.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/register.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/register.specs.js +0 -113
- package/dist/src/codegen/templates/command/register.specs.js.map +0 -1
- package/dist/src/codegen/templates/command/state.specs.d.ts +0 -2
- package/dist/src/codegen/templates/command/state.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/command/state.specs.js +0 -133
- package/dist/src/codegen/templates/command/state.specs.js.map +0 -1
- package/dist/src/codegen/templates/query/projection.specs.d.ts +0 -2
- package/dist/src/codegen/templates/query/projection.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/query/projection.specs.js +0 -363
- package/dist/src/codegen/templates/query/projection.specs.js.map +0 -1
- package/dist/src/codegen/templates/query/projection.specs.specs..d.ts +0 -2
- package/dist/src/codegen/templates/query/projection.specs.specs..d.ts.map +0 -1
- package/dist/src/codegen/templates/query/projection.specs.specs..js +0 -293
- package/dist/src/codegen/templates/query/projection.specs.specs..js.map +0 -1
- package/dist/src/codegen/templates/query/query.resolver.specs.d.ts +0 -2
- package/dist/src/codegen/templates/query/query.resolver.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/query/query.resolver.specs.js +0 -249
- package/dist/src/codegen/templates/query/query.resolver.specs.js.map +0 -1
- package/dist/src/codegen/templates/query/state.specs.d.ts +0 -2
- package/dist/src/codegen/templates/query/state.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/query/state.specs.js +0 -67
- package/dist/src/codegen/templates/query/state.specs.js.map +0 -1
- package/dist/src/codegen/templates/react/react.specs.d.ts +0 -2
- package/dist/src/codegen/templates/react/react.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/react/react.specs.js +0 -265
- package/dist/src/codegen/templates/react/react.specs.js.map +0 -1
- package/dist/src/codegen/templates/react/react.specs.specs.d.ts +0 -2
- package/dist/src/codegen/templates/react/react.specs.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/react/react.specs.specs.js +0 -229
- package/dist/src/codegen/templates/react/react.specs.specs.js.map +0 -1
- package/dist/src/codegen/templates/react/register.specs.d.ts +0 -2
- package/dist/src/codegen/templates/react/register.specs.d.ts.map +0 -1
- package/dist/src/codegen/templates/react/register.specs.js +0 -246
- package/dist/src/codegen/templates/react/register.specs.js.map +0 -1
- /package/dist/{codegen → src/codegen}/templates/command/commands.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/decide.specs.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/decide.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/events.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/evolve.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/handle.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/register.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/command/state.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/query/projection.specs.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/query/projection.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/query/state.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/react/react.specs.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/react/react.ts.ejs +0 -0
- /package/dist/{codegen → src/codegen}/templates/react/register.ts.ejs +0 -0
- /package/dist/{domain → src/domain}/shared/ReadModel.ts +0 -0
- /package/dist/{domain → src/domain}/shared/index.ts +0 -0
- /package/dist/{domain → src/domain}/shared/reactorSpecification.ts +0 -0
- /package/dist/{domain → src/domain}/shared/sendCommand.ts +0 -0
- /package/dist/{domain → src/domain}/shared/types.ts +0 -0
- /package/dist/{server.ts → src/server.ts} +0 -0
- /package/dist/{utils → src/utils}/index.ts +0 -0
- /package/dist/{utils → src/utils}/loadProjections.ts +0 -0
- /package/dist/{utils → src/utils}/loadRegisterFiles.ts +0 -0
- /package/dist/{utils → src/utils}/loadResolvers.ts +0 -0
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema.js';
|
|
3
|
-
describe('projection.specs.ts.ejs', () => {
|
|
4
|
-
it('should generate a valid test spec for a query slice projection', async () => {
|
|
5
|
-
const spec = {
|
|
6
|
-
variant: 'specs',
|
|
7
|
-
flows: [
|
|
8
|
-
{
|
|
9
|
-
name: 'listing-flow',
|
|
10
|
-
slices: [
|
|
11
|
-
{
|
|
12
|
-
type: 'command',
|
|
13
|
-
name: 'CreateListing',
|
|
14
|
-
stream: 'listing-${propertyId}',
|
|
15
|
-
client: { description: '', specs: [] },
|
|
16
|
-
server: {
|
|
17
|
-
description: '',
|
|
18
|
-
specs: {
|
|
19
|
-
name: 'CreateListing command',
|
|
20
|
-
rules: [
|
|
21
|
-
{
|
|
22
|
-
description: 'Should handle listing operations',
|
|
23
|
-
examples: [
|
|
24
|
-
{
|
|
25
|
-
description: 'User creates listing successfully',
|
|
26
|
-
when: {
|
|
27
|
-
commandRef: 'CreateListing',
|
|
28
|
-
exampleData: {
|
|
29
|
-
propertyId: 'listing_123',
|
|
30
|
-
title: 'Sea View Flat',
|
|
31
|
-
pricePerNight: 120,
|
|
32
|
-
location: 'Brighton',
|
|
33
|
-
maxGuests: 4,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
then: [
|
|
37
|
-
{
|
|
38
|
-
eventRef: 'ListingCreated',
|
|
39
|
-
exampleData: {
|
|
40
|
-
propertyId: 'listing_123',
|
|
41
|
-
title: 'Sea View Flat',
|
|
42
|
-
pricePerNight: 120,
|
|
43
|
-
location: 'Brighton',
|
|
44
|
-
maxGuests: 4,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
description: 'User removes listing successfully',
|
|
51
|
-
when: {
|
|
52
|
-
commandRef: 'RemoveListing',
|
|
53
|
-
exampleData: {
|
|
54
|
-
propertyId: 'listing_123',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
then: [
|
|
58
|
-
{
|
|
59
|
-
eventRef: 'ListingRemoved',
|
|
60
|
-
exampleData: {},
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: 'query',
|
|
72
|
-
name: 'search-listings',
|
|
73
|
-
stream: 'listings',
|
|
74
|
-
client: { description: '', specs: [] },
|
|
75
|
-
server: {
|
|
76
|
-
description: '',
|
|
77
|
-
data: [
|
|
78
|
-
{
|
|
79
|
-
origin: {
|
|
80
|
-
type: 'projection',
|
|
81
|
-
idField: 'propertyId',
|
|
82
|
-
name: 'AvailablePropertiesProjection',
|
|
83
|
-
},
|
|
84
|
-
target: {
|
|
85
|
-
type: 'State',
|
|
86
|
-
name: 'AvailableListings',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
specs: {
|
|
91
|
-
name: 'Search listings query',
|
|
92
|
-
rules: [
|
|
93
|
-
{
|
|
94
|
-
description: 'Should project listings correctly',
|
|
95
|
-
examples: [
|
|
96
|
-
{
|
|
97
|
-
description: 'Listing created shows in search results',
|
|
98
|
-
when: [
|
|
99
|
-
{
|
|
100
|
-
eventRef: 'ListingCreated',
|
|
101
|
-
exampleData: {
|
|
102
|
-
propertyId: 'listing_123',
|
|
103
|
-
title: 'Sea View Flat',
|
|
104
|
-
pricePerNight: 120,
|
|
105
|
-
location: 'Brighton',
|
|
106
|
-
maxGuests: 4,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
then: [
|
|
111
|
-
{
|
|
112
|
-
stateRef: 'AvailableListings',
|
|
113
|
-
exampleData: {
|
|
114
|
-
propertyId: 'listing_123',
|
|
115
|
-
title: 'Sea View Flat',
|
|
116
|
-
pricePerNight: 120,
|
|
117
|
-
location: 'Brighton',
|
|
118
|
-
maxGuests: 4,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
description: 'Listing removed disappears from search results',
|
|
125
|
-
when: [
|
|
126
|
-
{
|
|
127
|
-
eventRef: 'ListingRemoved',
|
|
128
|
-
exampleData: {
|
|
129
|
-
propertyId: 'listing_123',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
then: [
|
|
134
|
-
{
|
|
135
|
-
stateRef: 'AvailableListings',
|
|
136
|
-
exampleData: {},
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
messages: [
|
|
150
|
-
{
|
|
151
|
-
type: 'command',
|
|
152
|
-
name: 'CreateListing',
|
|
153
|
-
fields: [
|
|
154
|
-
{ name: 'propertyId', type: 'string', required: true },
|
|
155
|
-
{ name: 'title', type: 'string', required: true },
|
|
156
|
-
{ name: 'pricePerNight', type: 'number', required: true },
|
|
157
|
-
{ name: 'location', type: 'string', required: true },
|
|
158
|
-
{ name: 'maxGuests', type: 'number', required: true },
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
type: 'command',
|
|
163
|
-
name: 'RemoveListing',
|
|
164
|
-
fields: [{ name: 'propertyId', type: 'string', required: true }],
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
type: 'event',
|
|
168
|
-
name: 'ListingCreated',
|
|
169
|
-
source: 'internal',
|
|
170
|
-
fields: [
|
|
171
|
-
{ name: 'propertyId', type: 'string', required: true },
|
|
172
|
-
{ name: 'title', type: 'string', required: true },
|
|
173
|
-
{ name: 'pricePerNight', type: 'number', required: true },
|
|
174
|
-
{ name: 'location', type: 'string', required: true },
|
|
175
|
-
{ name: 'maxGuests', type: 'number', required: true },
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
type: 'event',
|
|
180
|
-
name: 'ListingRemoved',
|
|
181
|
-
source: 'internal',
|
|
182
|
-
fields: [{ name: 'propertyId', type: 'string', required: true }],
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
type: 'state',
|
|
186
|
-
name: 'AvailableListings',
|
|
187
|
-
fields: [
|
|
188
|
-
{ name: 'propertyId', type: 'string', required: true },
|
|
189
|
-
{ name: 'title', type: 'string', required: true },
|
|
190
|
-
{ name: 'pricePerNight', type: 'number', required: true },
|
|
191
|
-
{ name: 'location', type: 'string', required: true },
|
|
192
|
-
{ name: 'maxGuests', type: 'number', required: true },
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
|
-
const plans = await generateScaffoldFilePlans(spec.flows, spec.messages, undefined, 'src/domain/flows');
|
|
198
|
-
const specFile = plans.find((p) => p.outputPath.endsWith('projection.spec.ts'));
|
|
199
|
-
expect(specFile?.contents).toMatchInlineSnapshot(`
|
|
200
|
-
"import { describe, it, beforeEach, expect } from 'vitest';
|
|
201
|
-
import { v4 as uuid } from 'uuid';
|
|
202
|
-
import {
|
|
203
|
-
InMemoryProjectionSpec,
|
|
204
|
-
eventsInStream,
|
|
205
|
-
newEventsInStream
|
|
206
|
-
} from '@event-driven-io/emmett';
|
|
207
|
-
import { projection } from './projection.js';
|
|
208
|
-
|
|
209
|
-
import type { ListingCreated, ListingRemoved } from '../create-listing/events.js';
|
|
210
|
-
import type { AvailableListings } from './state.js';
|
|
211
|
-
|
|
212
|
-
type AllEvents = ListingCreated | ListingRemoved;
|
|
213
|
-
|
|
214
|
-
describe('AvailableListings projection', () => {
|
|
215
|
-
let given: InMemoryProjectionSpec<AllEvents>;
|
|
216
|
-
let propertyId: string;
|
|
217
|
-
|
|
218
|
-
beforeEach(() => {
|
|
219
|
-
propertyId = \`listing-\${uuid()}\`;
|
|
220
|
-
given = InMemoryProjectionSpec.for({ projection });
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('handles ListingCreated', () =>
|
|
224
|
-
given([])
|
|
225
|
-
.when([
|
|
226
|
-
{
|
|
227
|
-
type: 'ListingCreated',
|
|
228
|
-
data: {
|
|
229
|
-
propertyId,
|
|
230
|
-
title: 'Sea View Flat',
|
|
231
|
-
pricePerNight: 120,
|
|
232
|
-
location: 'Brighton',
|
|
233
|
-
maxGuests: 4
|
|
234
|
-
},
|
|
235
|
-
metadata: {
|
|
236
|
-
streamName: propertyId,
|
|
237
|
-
streamPosition: 1n,
|
|
238
|
-
globalPosition: 1n
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
])
|
|
242
|
-
.then(async (state) => {
|
|
243
|
-
const document = await state.database
|
|
244
|
-
.collection<AvailableListings>('available-properties-projection')
|
|
245
|
-
.findOne((doc) => doc.propertyId === propertyId);
|
|
246
|
-
|
|
247
|
-
const expected: AvailableListings = {
|
|
248
|
-
propertyId,
|
|
249
|
-
title: 'Sea View Flat',
|
|
250
|
-
pricePerNight: 120,
|
|
251
|
-
location: 'Brighton',
|
|
252
|
-
maxGuests: 4
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
expect(document).toMatchObject(expected);
|
|
256
|
-
}));
|
|
257
|
-
|
|
258
|
-
it('handles ListingRemoved', () =>
|
|
259
|
-
given(
|
|
260
|
-
eventsInStream(propertyId, [
|
|
261
|
-
{
|
|
262
|
-
type: 'ListingCreated',
|
|
263
|
-
data: {
|
|
264
|
-
propertyId,
|
|
265
|
-
title: 'Sea View Flat',
|
|
266
|
-
pricePerNight: 120,
|
|
267
|
-
location: 'Brighton',
|
|
268
|
-
maxGuests: 4
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
])
|
|
272
|
-
)
|
|
273
|
-
.when(
|
|
274
|
-
newEventsInStream(propertyId, [
|
|
275
|
-
{
|
|
276
|
-
type: 'ListingRemoved',
|
|
277
|
-
data: {
|
|
278
|
-
propertyId
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
])
|
|
282
|
-
)
|
|
283
|
-
.then(async (state) => {
|
|
284
|
-
const document = await state.database
|
|
285
|
-
.collection<AvailableListings>('available-properties-projection')
|
|
286
|
-
.findOne((doc) => doc.propertyId === propertyId);
|
|
287
|
-
expect(document).toBeNull();
|
|
288
|
-
}));
|
|
289
|
-
});
|
|
290
|
-
`);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
//# sourceMappingURL=projection.specs.specs..js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projection.specs.specs..js","sourceRoot":"","sources":["../../../../../src/codegen/templates/query/projection.specs.specs..ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,IAAI,GAAgB;YACxB,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,eAAe;4BACrB,MAAM,EAAE,uBAAuB;4BAC/B,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;4BACtC,MAAM,EAAE;gCACN,WAAW,EAAE,EAAE;gCACf,KAAK,EAAE;oCACL,IAAI,EAAE,uBAAuB;oCAC7B,KAAK,EAAE;wCACL;4CACE,WAAW,EAAE,kCAAkC;4CAC/C,QAAQ,EAAE;gDACR;oDACE,WAAW,EAAE,mCAAmC;oDAChD,IAAI,EAAE;wDACJ,UAAU,EAAE,eAAe;wDAC3B,WAAW,EAAE;4DACX,UAAU,EAAE,aAAa;4DACzB,KAAK,EAAE,eAAe;4DACtB,aAAa,EAAE,GAAG;4DAClB,QAAQ,EAAE,UAAU;4DACpB,SAAS,EAAE,CAAC;yDACb;qDACF;oDACD,IAAI,EAAE;wDACJ;4DACE,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WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;qBACtD;iBACF;aACF;SACF,CAAC;QAEF,MAAM,KAAK,GAAG,MAAM,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACxG,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAEhF,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2FpD,CAAC,CAAC;IACD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.resolver.specs.d.ts","sourceRoot":"","sources":["../../../../../src/codegen/templates/query/query.resolver.specs.ts"],"names":[],"mappings":""}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema.js';
|
|
3
|
-
describe('query.resolver.ts.ejs', () => {
|
|
4
|
-
it('should generate a valid query resolver from request field', async () => {
|
|
5
|
-
const spec = {
|
|
6
|
-
variant: 'specs',
|
|
7
|
-
flows: [
|
|
8
|
-
{
|
|
9
|
-
name: 'listing-flow',
|
|
10
|
-
slices: [
|
|
11
|
-
{
|
|
12
|
-
type: 'query',
|
|
13
|
-
name: 'search-listings',
|
|
14
|
-
request: `
|
|
15
|
-
query SearchProperties($location: String, $maxPrice: Float, $minGuests: Int) {
|
|
16
|
-
searchProperties(location: $location, maxPrice: $maxPrice, minGuests: $minGuests) {
|
|
17
|
-
propertyId
|
|
18
|
-
title
|
|
19
|
-
pricePerNight
|
|
20
|
-
location
|
|
21
|
-
maxGuests
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`,
|
|
25
|
-
client: {
|
|
26
|
-
description: '',
|
|
27
|
-
specs: [],
|
|
28
|
-
},
|
|
29
|
-
server: {
|
|
30
|
-
description: '',
|
|
31
|
-
data: [
|
|
32
|
-
{
|
|
33
|
-
origin: {
|
|
34
|
-
type: 'projection',
|
|
35
|
-
idField: 'propertyId',
|
|
36
|
-
name: 'AvailablePropertiesProjection',
|
|
37
|
-
},
|
|
38
|
-
target: {
|
|
39
|
-
type: 'State',
|
|
40
|
-
name: 'AvailableListings',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
specs: { name: '', rules: [] },
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
messages: [
|
|
51
|
-
{
|
|
52
|
-
type: 'state',
|
|
53
|
-
name: 'AvailableListings',
|
|
54
|
-
fields: [
|
|
55
|
-
{ name: 'propertyId', type: 'string', required: true },
|
|
56
|
-
{ name: 'title', type: 'string', required: true },
|
|
57
|
-
{ name: 'pricePerNight', type: 'number', required: true },
|
|
58
|
-
{ name: 'location', type: 'string', required: true },
|
|
59
|
-
{ name: 'maxGuests', type: 'number', required: true },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
const plans = await generateScaffoldFilePlans(spec.flows, spec.messages, undefined, 'src/domain/flows');
|
|
65
|
-
const resolverFile = plans.find((p) => p.outputPath.endsWith('query.resolver.ts'));
|
|
66
|
-
expect(resolverFile?.contents).toMatchInlineSnapshot(`
|
|
67
|
-
"import { Query, Resolver, Arg, Ctx, ObjectType, Field } from 'type-graphql';
|
|
68
|
-
import { type GraphQLContext, ReadModel } from '../../../shared.js';
|
|
69
|
-
|
|
70
|
-
@ObjectType()
|
|
71
|
-
export class AvailableListings {
|
|
72
|
-
@Field(() => String)
|
|
73
|
-
propertyId!: string;
|
|
74
|
-
|
|
75
|
-
@Field(() => String)
|
|
76
|
-
title!: string;
|
|
77
|
-
|
|
78
|
-
@Field(() => Number)
|
|
79
|
-
pricePerNight!: number;
|
|
80
|
-
|
|
81
|
-
@Field(() => String)
|
|
82
|
-
location!: string;
|
|
83
|
-
|
|
84
|
-
@Field(() => Number)
|
|
85
|
-
maxGuests!: number;
|
|
86
|
-
|
|
87
|
-
[key: string]: unknown;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@Resolver()
|
|
91
|
-
export class SearchListingsQueryResolver {
|
|
92
|
-
@Query(() => [AvailableListings])
|
|
93
|
-
async searchProperties(
|
|
94
|
-
@Ctx() ctx: GraphQLContext,
|
|
95
|
-
@Arg('location', () => String, { nullable: true }) location?: string,
|
|
96
|
-
@Arg('maxPrice', () => Number, { nullable: true }) maxPrice?: number,
|
|
97
|
-
@Arg('minGuests', () => Number, { nullable: true }) minGuests?: number,
|
|
98
|
-
): Promise<AvailableListings[]> {
|
|
99
|
-
const model = new ReadModel<AvailableListings>(ctx.eventStore, 'AvailablePropertiesProjection');
|
|
100
|
-
|
|
101
|
-
// ## IMPLEMENTATION INSTRUCTIONS ##
|
|
102
|
-
// You can query the projection using the ReadModel API:
|
|
103
|
-
//
|
|
104
|
-
// - model.getAll() — fetch all documents
|
|
105
|
-
// - model.getById(id) — fetch a single document by ID (default key: 'id')
|
|
106
|
-
// - model.find(filterFn) — filter documents using a predicate
|
|
107
|
-
// - model.first(filterFn) — fetch the first document matching a predicate
|
|
108
|
-
//
|
|
109
|
-
// Example below uses \`.find()\` to filter
|
|
110
|
-
// change the logic for the query as needed to meet the requirements for the current slice.
|
|
111
|
-
|
|
112
|
-
return model.find((item) => {
|
|
113
|
-
if (location !== undefined && item.location !== location) return false;
|
|
114
|
-
|
|
115
|
-
if (maxPrice !== undefined && item.maxPrice !== maxPrice) return false;
|
|
116
|
-
|
|
117
|
-
if (minGuests !== undefined && item.minGuests !== minGuests) return false;
|
|
118
|
-
|
|
119
|
-
return true;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
"
|
|
124
|
-
`);
|
|
125
|
-
});
|
|
126
|
-
it('should generate a valid query resolver with array of inline object field', async () => {
|
|
127
|
-
const spec = {
|
|
128
|
-
variant: 'specs',
|
|
129
|
-
flows: [
|
|
130
|
-
{
|
|
131
|
-
name: 'assistant-flow',
|
|
132
|
-
slices: [
|
|
133
|
-
{
|
|
134
|
-
type: 'query',
|
|
135
|
-
name: 'views-suggested-items',
|
|
136
|
-
request: `
|
|
137
|
-
query GetSuggestedItems($sessionId: ID!) {
|
|
138
|
-
suggestedItems(sessionId: $sessionId) {
|
|
139
|
-
sessionId
|
|
140
|
-
items {
|
|
141
|
-
productId
|
|
142
|
-
name
|
|
143
|
-
quantity
|
|
144
|
-
reason
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
`,
|
|
149
|
-
client: { description: '', specs: [] },
|
|
150
|
-
server: {
|
|
151
|
-
description: '',
|
|
152
|
-
data: [
|
|
153
|
-
{
|
|
154
|
-
origin: {
|
|
155
|
-
type: 'projection',
|
|
156
|
-
idField: 'sessionId',
|
|
157
|
-
name: 'SuggestedItemsProjection',
|
|
158
|
-
},
|
|
159
|
-
target: {
|
|
160
|
-
type: 'State',
|
|
161
|
-
name: 'SuggestedItems',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
specs: { name: '', rules: [] },
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
messages: [
|
|
172
|
-
{
|
|
173
|
-
type: 'state',
|
|
174
|
-
name: 'SuggestedItems',
|
|
175
|
-
fields: [
|
|
176
|
-
{ name: 'sessionId', type: 'string', required: true },
|
|
177
|
-
{
|
|
178
|
-
name: 'items',
|
|
179
|
-
type: 'Array<{ productId: string; name: string; quantity: number; reason: string }>',
|
|
180
|
-
required: true,
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
const plans = await generateScaffoldFilePlans(spec.flows, spec.messages, undefined, 'src/domain/flows');
|
|
187
|
-
const resolverFile = plans.find((p) => p.outputPath.endsWith('query.resolver.ts'));
|
|
188
|
-
expect(resolverFile?.contents).toMatchInlineSnapshot(`
|
|
189
|
-
"import { Query, Resolver, Arg, Ctx, ObjectType, Field, ID } from 'type-graphql';
|
|
190
|
-
import { type GraphQLContext, ReadModel } from '../../../shared.js';
|
|
191
|
-
|
|
192
|
-
@ObjectType()
|
|
193
|
-
export class SuggestedItems {
|
|
194
|
-
@Field(() => String)
|
|
195
|
-
sessionId!: string;
|
|
196
|
-
|
|
197
|
-
@Field(() => [SuggestedItemsItems])
|
|
198
|
-
items!: SuggestedItemsItems[];
|
|
199
|
-
|
|
200
|
-
[key: string]: unknown;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@ObjectType()
|
|
204
|
-
export class SuggestedItemsItems {
|
|
205
|
-
@Field(() => String)
|
|
206
|
-
productId!: string;
|
|
207
|
-
|
|
208
|
-
@Field(() => String)
|
|
209
|
-
name!: string;
|
|
210
|
-
|
|
211
|
-
@Field(() => Number)
|
|
212
|
-
quantity!: number;
|
|
213
|
-
|
|
214
|
-
@Field(() => String)
|
|
215
|
-
reason!: string;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
@Resolver()
|
|
219
|
-
export class ViewsSuggestedItemsQueryResolver {
|
|
220
|
-
@Query(() => [SuggestedItems])
|
|
221
|
-
async suggestedItems(
|
|
222
|
-
@Ctx() ctx: GraphQLContext,
|
|
223
|
-
@Arg('sessionId', () => ID, { nullable: true }) sessionId?: string,
|
|
224
|
-
): Promise<SuggestedItems[]> {
|
|
225
|
-
const model = new ReadModel<SuggestedItems>(ctx.eventStore, 'SuggestedItemsProjection');
|
|
226
|
-
|
|
227
|
-
// ## IMPLEMENTATION INSTRUCTIONS ##
|
|
228
|
-
// You can query the projection using the ReadModel API:
|
|
229
|
-
//
|
|
230
|
-
// - model.getAll() — fetch all documents
|
|
231
|
-
// - model.getById(id) — fetch a single document by ID (default key: 'id')
|
|
232
|
-
// - model.find(filterFn) — filter documents using a predicate
|
|
233
|
-
// - model.first(filterFn) — fetch the first document matching a predicate
|
|
234
|
-
//
|
|
235
|
-
// Example below uses \`.find()\` to filter
|
|
236
|
-
// change the logic for the query as needed to meet the requirements for the current slice.
|
|
237
|
-
|
|
238
|
-
return model.find((item) => {
|
|
239
|
-
if (sessionId !== undefined && item.sessionId !== sessionId) return false;
|
|
240
|
-
|
|
241
|
-
return true;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
"
|
|
246
|
-
`);
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
//# sourceMappingURL=query.resolver.specs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.resolver.specs.js","sourceRoot":"","sources":["../../../../../src/codegen/templates/query/query.resolver.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,IAAI,GAAgB;YACxB,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,iBAAiB;4BACvB,OAAO,EAAE;;;;;;;;;;eAUR;4BACD,MAAM,EAAE;gCACN,WAAW,EAAE,EAAE;gCACf,KAAK,E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AAQ,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACxG,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAEnF,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0DpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.specs.d.ts","sourceRoot":"","sources":["../../../../../src/codegen/templates/query/state.specs.ts"],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { generateScaffoldFilePlans } from '../../scaffoldFromSchema.js';
|
|
3
|
-
describe('state.ts.ejs', () => {
|
|
4
|
-
it('should generate a valid state definition file for a query slice with a state message', async () => {
|
|
5
|
-
const spec = {
|
|
6
|
-
variant: 'specs',
|
|
7
|
-
flows: [
|
|
8
|
-
{
|
|
9
|
-
name: 'Inventory management',
|
|
10
|
-
slices: [
|
|
11
|
-
{
|
|
12
|
-
type: 'query',
|
|
13
|
-
name: 'Get available items',
|
|
14
|
-
client: {
|
|
15
|
-
description: 'Client view of available items',
|
|
16
|
-
specs: [],
|
|
17
|
-
},
|
|
18
|
-
server: {
|
|
19
|
-
description: 'Projects available items',
|
|
20
|
-
data: [
|
|
21
|
-
{
|
|
22
|
-
origin: {
|
|
23
|
-
type: 'projection',
|
|
24
|
-
name: 'ItemCreated',
|
|
25
|
-
idField: 'id',
|
|
26
|
-
},
|
|
27
|
-
target: {
|
|
28
|
-
type: 'State',
|
|
29
|
-
name: 'AvailableItems',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
specs: { name: '', rules: [] },
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
messages: [
|
|
40
|
-
{
|
|
41
|
-
type: 'state',
|
|
42
|
-
name: 'AvailableItems',
|
|
43
|
-
fields: [
|
|
44
|
-
{ name: 'id', type: 'string', required: true },
|
|
45
|
-
{ name: 'name', type: 'string', required: true },
|
|
46
|
-
{ name: 'price', type: 'number', required: true },
|
|
47
|
-
{ name: 'inStock', type: 'boolean', required: true },
|
|
48
|
-
{ name: 'addedAt', type: 'Date', required: true },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
};
|
|
53
|
-
const plans = await generateScaffoldFilePlans(spec.flows, spec.messages, undefined, 'src/domain/flows');
|
|
54
|
-
const stateFile = plans.find((p) => p.outputPath.endsWith('state.ts'));
|
|
55
|
-
expect(stateFile?.contents).toMatchInlineSnapshot(`
|
|
56
|
-
"export type AvailableItems = {
|
|
57
|
-
id: string;
|
|
58
|
-
name: string;
|
|
59
|
-
price: number;
|
|
60
|
-
inStock: boolean;
|
|
61
|
-
addedAt: Date;
|
|
62
|
-
};
|
|
63
|
-
"
|
|
64
|
-
`);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=state.specs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.specs.js","sourceRoot":"","sources":["../../../../../src/codegen/templates/query/state.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,sFAAsF,EAAE,KAAK,IAAI,EAAE;QACpG,MAAM,IAAI,GAAgB;YACxB,OAAO,EAAE,OAAO;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