@domain-first/project-structure 4.2.2 → 5.0.1
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/README.md +3 -3
- package/dist/201.js +20 -35
- package/dist/config-file.d.ts +8 -16
- package/dist/dependency-rules.d.ts +14 -23
- package/dist/index.cjs +95 -259
- package/dist/index.js +85 -235
- package/dist/lint.cjs +22 -37
- package/dist/lint.js +2 -2
- package/dist/wiring.d.ts +1 -1
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +24 -13
- package/skills/df-ps-plan-feature/SKILL.md +3 -3
- package/skills/df-ps-project-scripts/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/choosing-components.md +18 -20
- package/skills/df-ps-scaffold/references/generators.md +6 -11
package/dist/index.js
CHANGED
|
@@ -2124,40 +2124,31 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
2124
2124
|
});
|
|
2125
2125
|
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
2126
2126
|
const naming = new UnknownFormatNaming(commandName);
|
|
2127
|
-
const commandType = await prompts_select({
|
|
2128
|
-
choices: [
|
|
2129
|
-
'Execution (with infrastructure implementation)',
|
|
2130
|
-
'Orchestrator (no infrastructure implementation)'
|
|
2131
|
-
],
|
|
2132
|
-
message: 'Command type'
|
|
2133
|
-
});
|
|
2134
|
-
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
|
|
2135
2127
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
2128
|
+
const implementationType = await input({
|
|
2129
|
+
message: 'Command infrastructure implementation type:',
|
|
2130
|
+
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
2131
|
+
});
|
|
2132
|
+
let addTestImplementation = false;
|
|
2133
|
+
let testImplementationType = '';
|
|
2134
|
+
addTestImplementation = await prompts_confirm({
|
|
2135
|
+
message: 'Add a test implementation for Command'
|
|
2136
|
+
});
|
|
2137
|
+
if (addTestImplementation) testImplementationType = await input({
|
|
2138
|
+
message: 'Test Command infrastructure implementation type:',
|
|
2139
|
+
default: 'in-memory'
|
|
2140
|
+
});
|
|
2141
|
+
const implementationTypes = [
|
|
2142
|
+
implementationType,
|
|
2143
|
+
testImplementationType
|
|
2144
|
+
].filter((x)=>!!x);
|
|
2145
|
+
for (const implementation of implementationTypes){
|
|
2146
|
+
const formatNaming = new UnknownFormatNaming(implementation);
|
|
2147
|
+
const implementationFile = infrastructureFolder.subitem([
|
|
2148
|
+
formatNaming.fileName
|
|
2149
|
+
]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
2159
2150
|
import { defineHandler } from '@domain-first/handlers'
|
|
2160
|
-
import { ${naming.ClassName}Command } from '../../../application/commands
|
|
2151
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
|
|
2161
2152
|
|
|
2162
2153
|
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
2163
2154
|
constructor() {
|
|
@@ -2173,7 +2164,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
|
|
|
2173
2164
|
})
|
|
2174
2165
|
}
|
|
2175
2166
|
`.trim() : `
|
|
2176
|
-
import { ${naming.ClassName}Command } from '../../../application/commands
|
|
2167
|
+
import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
|
|
2177
2168
|
|
|
2178
2169
|
export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${naming.ClassName}Command {
|
|
2179
2170
|
constructor() {
|
|
@@ -2181,11 +2172,9 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
|
|
|
2181
2172
|
}
|
|
2182
2173
|
}
|
|
2183
2174
|
`.trim());
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
'execution'
|
|
2188
|
-
]).createFile(`${naming.fileName}-command.ts`, `
|
|
2175
|
+
if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
|
|
2176
|
+
}
|
|
2177
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
2189
2178
|
import type { Handler } from '@domain-first/handlers'
|
|
2190
2179
|
|
|
2191
2180
|
export abstract class ${naming.ClassName}Command {
|
|
@@ -2195,20 +2184,16 @@ export abstract class ${naming.ClassName}Command {
|
|
|
2195
2184
|
abstract handle: Handler<typeof ${naming.ClassName}Command.inputSchema, typeof ${naming.ClassName}Command.outputSchema>
|
|
2196
2185
|
}
|
|
2197
2186
|
`.trim());
|
|
2198
|
-
|
|
2199
|
-
'execution'
|
|
2200
|
-
]).createFile(`${naming.fileName}-command.ts`, `
|
|
2187
|
+
else commandsFolder.createFile(`${naming.fileName}-command.ts`, `
|
|
2201
2188
|
export abstract class ${naming.ClassName}Command {
|
|
2202
2189
|
|
|
2203
2190
|
}`.trim());
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
'execution'
|
|
2208
|
-
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
2191
|
+
if (scaffoldUnitTests) {
|
|
2192
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
2193
|
+
const specFile = commandsFolder.createFile(`${naming.fileName}-command.spec.ts`, `
|
|
2209
2194
|
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
2210
2195
|
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
2211
|
-
import { wire${naming.ClassName}Command } from '
|
|
2196
|
+
import { wire${naming.ClassName}Command } from '../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
|
|
2212
2197
|
|
|
2213
2198
|
type ${naming.ClassName}Command = ${implementationNaming.ClassName}${naming.ClassName}Command`}
|
|
2214
2199
|
|
|
@@ -2224,15 +2209,15 @@ describe('${naming.withSpaces} command', () => {
|
|
|
2224
2209
|
})
|
|
2225
2210
|
})
|
|
2226
2211
|
`.trim());
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2212
|
+
if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Command`);
|
|
2213
|
+
}
|
|
2214
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
2215
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
2216
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
2217
|
+
const wireFile = boundedContextFolder.subitem([
|
|
2218
|
+
'wiring',
|
|
2219
|
+
'commands'
|
|
2220
|
+
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
2236
2221
|
import { wireClass } from '@domain-first/wire'
|
|
2237
2222
|
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
2238
2223
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
|
|
@@ -2245,68 +2230,8 @@ export const wire${naming.ClassName}Command = envBranchedWire({
|
|
|
2245
2230
|
production: wire${implementationNaming.ClassName}Implementation
|
|
2246
2231
|
})
|
|
2247
2232
|
`.trim());
|
|
2248
|
-
|
|
2249
|
-
}
|
|
2250
|
-
return;
|
|
2233
|
+
await wireNewModuleDependencies(boundedContextFolder, wireFile);
|
|
2251
2234
|
}
|
|
2252
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.subitem([
|
|
2253
|
-
'orchestration'
|
|
2254
|
-
]).createFile(`${naming.fileName}-command.ts`, `
|
|
2255
|
-
import { defineHandler } from '@domain-first/handlers'
|
|
2256
|
-
|
|
2257
|
-
export class ${naming.ClassName}Command {
|
|
2258
|
-
constructor() {}
|
|
2259
|
-
|
|
2260
|
-
static inputSchema = {}
|
|
2261
|
-
static outputSchema = {}
|
|
2262
|
-
|
|
2263
|
-
handle = defineHandler({
|
|
2264
|
-
inputSchema: ${naming.ClassName}Command.inputSchema,
|
|
2265
|
-
outputSchema: ${naming.ClassName}Command.outputSchema,
|
|
2266
|
-
handler: async (payload) => {
|
|
2267
|
-
return {}
|
|
2268
|
-
}
|
|
2269
|
-
})
|
|
2270
|
-
}
|
|
2271
|
-
`.trim());
|
|
2272
|
-
else commandsFolder.subitem([
|
|
2273
|
-
'orchestration'
|
|
2274
|
-
]).createFile(`${naming.fileName}-command.ts`, `
|
|
2275
|
-
export class ${naming.ClassName}Command {
|
|
2276
|
-
constructor() {}
|
|
2277
|
-
}`.trim());
|
|
2278
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
|
|
2279
|
-
'wiring',
|
|
2280
|
-
'commands'
|
|
2281
|
-
]).createFile(`wire-${naming.fileName}-command.ts`, `
|
|
2282
|
-
import { wireClass } from '@domain-first/wire'
|
|
2283
|
-
import { ${naming.ClassName}Command } from '../../application/commands/orchestration/${naming.fileName}-command'
|
|
2284
|
-
|
|
2285
|
-
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
2286
|
-
`.trim());
|
|
2287
|
-
if (scaffoldUnitTests) commandsFolder.subitem([
|
|
2288
|
-
'orchestration'
|
|
2289
|
-
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
2290
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
2291
|
-
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
2292
|
-
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${naming.ClassName}Command } from './${naming.fileName}-command'`}
|
|
2293
|
-
|
|
2294
|
-
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
2295
|
-
|
|
2296
|
-
beforeEach(() => {
|
|
2297
|
-
${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${naming.ClassName}Command()`}
|
|
2298
|
-
})
|
|
2299
|
-
|
|
2300
|
-
describe('${naming.withSpaces} command', () => {
|
|
2301
|
-
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
2302
|
-
expect(${naming.variableName}Command).toBeDefined()
|
|
2303
|
-
})
|
|
2304
|
-
})
|
|
2305
|
-
`.trim());
|
|
2306
|
-
if (withWiring) await wireNewModuleDependencies(boundedContextFolder, boundedContextFolder.subitem([
|
|
2307
|
-
'wiring',
|
|
2308
|
-
'commands'
|
|
2309
|
-
]).file(`wire-${naming.fileName}-command.ts`));
|
|
2310
2235
|
};
|
|
2311
2236
|
const noAggregate = 'No aggregate';
|
|
2312
2237
|
const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
|
|
@@ -2651,42 +2576,33 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
2651
2576
|
const queryName = await input({
|
|
2652
2577
|
message: 'Name: '
|
|
2653
2578
|
});
|
|
2654
|
-
const naming = new UnknownFormatNaming(queryName);
|
|
2655
2579
|
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
2656
|
-
const
|
|
2657
|
-
choices: [
|
|
2658
|
-
'Execution (with infrastructure implementation)',
|
|
2659
|
-
'Orchestrator (no infrastructure implementation)'
|
|
2660
|
-
],
|
|
2661
|
-
message: 'Query type'
|
|
2662
|
-
});
|
|
2663
|
-
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
|
|
2580
|
+
const naming = new UnknownFormatNaming(queryName);
|
|
2664
2581
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
2582
|
+
const implementationType = await input({
|
|
2583
|
+
message: 'Query infrastructure implementation type:',
|
|
2584
|
+
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
2585
|
+
});
|
|
2586
|
+
let addTestImplementation = false;
|
|
2587
|
+
let testImplementationType = '';
|
|
2588
|
+
addTestImplementation = await prompts_confirm({
|
|
2589
|
+
message: 'Add a test implementation for Query'
|
|
2590
|
+
});
|
|
2591
|
+
if (addTestImplementation) testImplementationType = await input({
|
|
2592
|
+
message: 'Test Query infrastructure implementation type:',
|
|
2593
|
+
default: 'in-memory'
|
|
2594
|
+
});
|
|
2595
|
+
const implementationTypes = [
|
|
2596
|
+
implementationType,
|
|
2597
|
+
testImplementationType
|
|
2598
|
+
].filter((x)=>!!x);
|
|
2599
|
+
for (const implementation of implementationTypes){
|
|
2600
|
+
const formatNaming = new UnknownFormatNaming(implementation);
|
|
2601
|
+
const implementationFile = infrastructureFolder.subitem([
|
|
2602
|
+
formatNaming.fileName
|
|
2603
|
+
]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
2688
2604
|
import { defineHandler } from '@domain-first/handlers'
|
|
2689
|
-
import { ${naming.ClassName}Query } from '../../../application/queries
|
|
2605
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
|
|
2690
2606
|
|
|
2691
2607
|
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
2692
2608
|
constructor() {
|
|
@@ -2702,7 +2618,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
|
|
|
2702
2618
|
})
|
|
2703
2619
|
}
|
|
2704
2620
|
`.trim() : `
|
|
2705
|
-
import { ${naming.ClassName}Query } from '../../../application/queries
|
|
2621
|
+
import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
|
|
2706
2622
|
|
|
2707
2623
|
export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.ClassName}Query {
|
|
2708
2624
|
constructor() {
|
|
@@ -2710,11 +2626,9 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
|
|
|
2710
2626
|
}
|
|
2711
2627
|
}
|
|
2712
2628
|
`.trim());
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
'execution'
|
|
2717
|
-
]).createFile(`${naming.fileName}-query.ts`, `
|
|
2629
|
+
if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
|
|
2630
|
+
}
|
|
2631
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
2718
2632
|
import type { Handler } from '@domain-first/handlers'
|
|
2719
2633
|
|
|
2720
2634
|
export abstract class ${naming.ClassName}Query {
|
|
@@ -2724,20 +2638,16 @@ export abstract class ${naming.ClassName}Query {
|
|
|
2724
2638
|
abstract handle: Handler<typeof ${naming.ClassName}Query.inputSchema, typeof ${naming.ClassName}Query.outputSchema>
|
|
2725
2639
|
}
|
|
2726
2640
|
`.trim());
|
|
2727
|
-
|
|
2728
|
-
'execution'
|
|
2729
|
-
]).createFile(`${naming.fileName}-query.ts`, `
|
|
2641
|
+
else queriesFolder.createFile(`${naming.fileName}-query.ts`, `
|
|
2730
2642
|
export abstract class ${naming.ClassName}Query {
|
|
2731
2643
|
|
|
2732
2644
|
}`.trim());
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
'execution'
|
|
2737
|
-
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
2645
|
+
if (scaffoldUnitTests) {
|
|
2646
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
2647
|
+
const specFile = queriesFolder.createFile(`${naming.fileName}-query.spec.ts`, `
|
|
2738
2648
|
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
2739
2649
|
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
2740
|
-
import { wire${naming.ClassName}Query } from '
|
|
2650
|
+
import { wire${naming.ClassName}Query } from '../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
|
|
2741
2651
|
|
|
2742
2652
|
type ${naming.ClassName}Query = ${implementationNaming.ClassName}${naming.ClassName}Query`}
|
|
2743
2653
|
|
|
@@ -2753,15 +2663,15 @@ describe('${naming.withSpaces} query', () => {
|
|
|
2753
2663
|
})
|
|
2754
2664
|
})
|
|
2755
2665
|
`.trim());
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2666
|
+
if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Query`);
|
|
2667
|
+
}
|
|
2668
|
+
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
2669
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
2670
|
+
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
2671
|
+
const wireFile = boundedContextFolder.subitem([
|
|
2672
|
+
'wiring',
|
|
2673
|
+
'queries'
|
|
2674
|
+
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
2765
2675
|
import { wireClass } from '@domain-first/wire'
|
|
2766
2676
|
import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
|
|
2767
2677
|
${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
|
|
@@ -2774,68 +2684,8 @@ export const wire${naming.ClassName}Query = envBranchedWire({
|
|
|
2774
2684
|
production: wire${implementationNaming.ClassName}Implementation
|
|
2775
2685
|
})
|
|
2776
2686
|
`.trim());
|
|
2777
|
-
|
|
2778
|
-
}
|
|
2779
|
-
return;
|
|
2687
|
+
await wireNewModuleDependencies(boundedContextFolder, wireFile);
|
|
2780
2688
|
}
|
|
2781
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.subitem([
|
|
2782
|
-
'orchestration'
|
|
2783
|
-
]).createFile(`${naming.fileName}-query.ts`, `
|
|
2784
|
-
import { defineHandler } from '@domain-first/handlers'
|
|
2785
|
-
|
|
2786
|
-
export class ${naming.ClassName}Query {
|
|
2787
|
-
constructor() {}
|
|
2788
|
-
|
|
2789
|
-
static inputSchema = {}
|
|
2790
|
-
static outputSchema = {}
|
|
2791
|
-
|
|
2792
|
-
handle = defineHandler({
|
|
2793
|
-
inputSchema: ${naming.ClassName}Query.inputSchema,
|
|
2794
|
-
outputSchema: ${naming.ClassName}Query.outputSchema,
|
|
2795
|
-
handler: async (payload) => {
|
|
2796
|
-
return {}
|
|
2797
|
-
}
|
|
2798
|
-
})
|
|
2799
|
-
}
|
|
2800
|
-
`.trim());
|
|
2801
|
-
else queriesFolder.subitem([
|
|
2802
|
-
'orchestration'
|
|
2803
|
-
]).createFile(`${naming.fileName}-query.ts`, `
|
|
2804
|
-
export class ${naming.ClassName}Query {
|
|
2805
|
-
constructor() {}
|
|
2806
|
-
}`.trim());
|
|
2807
|
-
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
|
|
2808
|
-
'wiring',
|
|
2809
|
-
'queries'
|
|
2810
|
-
]).createFile(`wire-${naming.fileName}-query.ts`, `
|
|
2811
|
-
import { wireClass } from '@domain-first/wire'
|
|
2812
|
-
import { ${naming.ClassName}Query } from '../../application/queries/orchestration/${naming.fileName}-query'
|
|
2813
|
-
|
|
2814
|
-
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
2815
|
-
`.trim());
|
|
2816
|
-
if (scaffoldUnitTests) queriesFolder.subitem([
|
|
2817
|
-
'orchestration'
|
|
2818
|
-
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
2819
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
2820
|
-
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
2821
|
-
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${naming.ClassName}Query } from './${naming.fileName}-query'`}
|
|
2822
|
-
|
|
2823
|
-
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
2824
|
-
|
|
2825
|
-
beforeEach(() => {
|
|
2826
|
-
${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${naming.ClassName}Query()`}
|
|
2827
|
-
})
|
|
2828
|
-
|
|
2829
|
-
describe('${naming.withSpaces} query', () => {
|
|
2830
|
-
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
2831
|
-
expect(${naming.variableName}Query).toBeDefined()
|
|
2832
|
-
})
|
|
2833
|
-
})
|
|
2834
|
-
`.trim());
|
|
2835
|
-
if (withWiring) await wireNewModuleDependencies(boundedContextFolder, boundedContextFolder.subitem([
|
|
2836
|
-
'wiring',
|
|
2837
|
-
'queries'
|
|
2838
|
-
]).file(`wire-${naming.fileName}-query.ts`));
|
|
2839
2689
|
};
|
|
2840
2690
|
const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
2841
2691
|
const useCasesFolder = boundedContextFolder.subitem([
|
package/dist/lint.cjs
CHANGED
|
@@ -37,10 +37,8 @@ const moduleKinds = [
|
|
|
37
37
|
'application-ports',
|
|
38
38
|
'application-services',
|
|
39
39
|
'use-cases',
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'orchestration-commands',
|
|
43
|
-
'orchestration-queries',
|
|
40
|
+
'commands',
|
|
41
|
+
'queries',
|
|
44
42
|
'infrastructure-services',
|
|
45
43
|
'presentation-services'
|
|
46
44
|
];
|
|
@@ -49,10 +47,8 @@ const domain = [
|
|
|
49
47
|
'domain-services'
|
|
50
48
|
];
|
|
51
49
|
const commandsAndQueries = [
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'orchestration-commands',
|
|
55
|
-
'orchestration-queries'
|
|
50
|
+
'commands',
|
|
51
|
+
'queries'
|
|
56
52
|
];
|
|
57
53
|
const infrastructure = [
|
|
58
54
|
...domain,
|
|
@@ -80,16 +76,11 @@ const defaultDependencies = {
|
|
|
80
76
|
'application-services',
|
|
81
77
|
...commandsAndQueries
|
|
82
78
|
],
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'orchestration-commands': [
|
|
86
|
-
...domain,
|
|
87
|
-
'execution-commands',
|
|
88
|
-
'execution-queries'
|
|
79
|
+
commands: [
|
|
80
|
+
'infrastructure-services'
|
|
89
81
|
],
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
'execution-queries'
|
|
82
|
+
queries: [
|
|
83
|
+
'infrastructure-services'
|
|
93
84
|
],
|
|
94
85
|
'infrastructure-services': infrastructure,
|
|
95
86
|
'presentation-services': [
|
|
@@ -129,30 +120,26 @@ const resolveDependencyRules = (config = {})=>{
|
|
|
129
120
|
};
|
|
130
121
|
const defaultDependencyRules = resolveDependencyRules();
|
|
131
122
|
const isModuleKind = (value)=>moduleKinds.includes(value);
|
|
132
|
-
const wiredModuleKind = (wiringKind
|
|
133
|
-
const kind = 'commands' === wiringKind || 'queries' === wiringKind ? `${'execution' === external_node_path_default().basename(external_node_path_default().dirname(typeFile)) ? 'execution' : 'orchestration'}-${wiringKind}` : wiringKind;
|
|
134
|
-
return isModuleKind(kind) ? kind : void 0;
|
|
135
|
-
};
|
|
123
|
+
const wiredModuleKind = (wiringKind)=>isModuleKind(wiringKind) ? wiringKind : void 0;
|
|
136
124
|
const fileModuleKind = (segments)=>{
|
|
137
|
-
const [layer, folder
|
|
125
|
+
const [layer, folder] = segments;
|
|
138
126
|
const file = segments.at(-1) ?? '';
|
|
139
127
|
if (/^index(\.tsx?)?$/.test(file)) return;
|
|
140
128
|
if ('domain' === layer) {
|
|
141
129
|
if ('services' === folder) return 'domain-services';
|
|
142
130
|
return 'aggregates' === folder && /-repository(\.tsx?)?$/.test(file) ? 'repositories' : void 0;
|
|
143
131
|
}
|
|
144
|
-
if ('application' === layer) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
132
|
+
if ('application' === layer) return ({
|
|
133
|
+
commands: 'commands',
|
|
134
|
+
queries: 'queries',
|
|
135
|
+
ports: 'application-ports',
|
|
136
|
+
services: 'application-services',
|
|
137
|
+
'use-cases': 'use-cases'
|
|
138
|
+
})[folder];
|
|
152
139
|
if ('infrastructure' === layer) return ({
|
|
153
140
|
repositories: 'repositories',
|
|
154
|
-
commands: '
|
|
155
|
-
queries: '
|
|
141
|
+
commands: 'commands',
|
|
142
|
+
queries: 'queries',
|
|
156
143
|
'application-adapters': 'application-ports',
|
|
157
144
|
services: 'infrastructure-services'
|
|
158
145
|
})[folder];
|
|
@@ -381,13 +368,11 @@ const branchedTypeFiles = {
|
|
|
381
368
|
commands: (fileBase)=>[
|
|
382
369
|
'application',
|
|
383
370
|
'commands',
|
|
384
|
-
'execution',
|
|
385
371
|
`${fileBase}.ts`
|
|
386
372
|
],
|
|
387
373
|
queries: (fileBase)=>[
|
|
388
374
|
'application',
|
|
389
375
|
'queries',
|
|
390
|
-
'execution',
|
|
391
376
|
`${fileBase}.ts`
|
|
392
377
|
],
|
|
393
378
|
'application-ports': (fileBase)=>[
|
|
@@ -482,7 +467,7 @@ const findWiredModules = (contextPath)=>{
|
|
|
482
467
|
walk(external_node_path_default().join(contextPath, 'wiring'));
|
|
483
468
|
return result.sort((a, b)=>a.typeName.localeCompare(b.typeName));
|
|
484
469
|
};
|
|
485
|
-
const moduleKindOf = (module)=>wiredModuleKind(module.kind
|
|
470
|
+
const moduleKindOf = (module)=>wiredModuleKind(module.kind);
|
|
486
471
|
const wiring_layerRule = (consumer, candidate)=>visibleLayers[consumer.implementationsLayer].includes(candidate.layer) && ('infrastructure' !== consumer.implementationsLayer || 'application' !== candidate.layer || 'application-ports' === candidate.kind);
|
|
487
472
|
const canDependOn = (consumer, candidate, rules = defaultDependencyRules)=>{
|
|
488
473
|
const consumerKind = moduleKindOf(consumer);
|
|
@@ -626,8 +611,8 @@ const layerImportRules = {
|
|
|
626
611
|
rule: 'application imports outside domain and application:'
|
|
627
612
|
},
|
|
628
613
|
infrastructure: {
|
|
629
|
-
allows: ([layer, part
|
|
630
|
-
rule: 'infrastructure imports outside domain, infrastructure, application ports and
|
|
614
|
+
allows: ([layer, part])=>'domain' === layer || 'infrastructure' === layer || 'application' === layer && ('ports' === part || 'commands' === part || 'queries' === part),
|
|
615
|
+
rule: 'infrastructure imports outside domain, infrastructure, application ports and command and query contracts:'
|
|
631
616
|
},
|
|
632
617
|
presentation: {
|
|
633
618
|
allows: ([layer])=>'infrastructure' !== layer,
|
package/dist/lint.js
CHANGED
|
@@ -59,8 +59,8 @@ const layerImportRules = {
|
|
|
59
59
|
rule: 'application imports outside domain and application:'
|
|
60
60
|
},
|
|
61
61
|
infrastructure: {
|
|
62
|
-
allows: ([layer, part
|
|
63
|
-
rule: 'infrastructure imports outside domain, infrastructure, application ports and
|
|
62
|
+
allows: ([layer, part])=>'domain' === layer || 'infrastructure' === layer || 'application' === layer && ('ports' === part || 'commands' === part || 'queries' === part),
|
|
63
|
+
rule: 'infrastructure imports outside domain, infrastructure, application ports and command and query contracts:'
|
|
64
64
|
},
|
|
65
65
|
presentation: {
|
|
66
66
|
allows: ([layer])=>'infrastructure' !== layer,
|
package/dist/wiring.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare const findWiredModules: (contextPath: string) => WiredModule[];
|
|
|
47
47
|
/**
|
|
48
48
|
* The kind a module has in the dependency rules.
|
|
49
49
|
*/
|
|
50
|
-
export declare const moduleKindOf: (module: WiredModule) => "repositories" | "domain-services" | "application-ports" | "application-services" | "use-cases" | "
|
|
50
|
+
export declare const moduleKindOf: (module: WiredModule) => "repositories" | "domain-services" | "application-ports" | "application-services" | "use-cases" | "commands" | "queries" | "infrastructure-services" | "presentation-services" | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* The implementation label of a branched wire's class, taken from its
|
|
53
53
|
* folder: `infrastructure/repositories/prisma/…` → `prisma`.
|