@domain-first/project-structure 8.7.0 → 8.8.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.
Files changed (33) hide show
  1. package/README.md +2 -0
  2. package/dist/287.js +1275 -1127
  3. package/dist/561.js +19 -3
  4. package/dist/780.js +9 -2
  5. package/dist/agent-cli.d.ts +35 -4
  6. package/dist/agent-requests.d.ts +22 -0
  7. package/dist/backend-module-move.d.ts +16 -0
  8. package/dist/config-file.d.ts +38 -18
  9. package/dist/graph.cjs +9 -2
  10. package/dist/implementation-options-schema.d.ts +19 -9
  11. package/dist/in-memory-db.d.ts +5 -6
  12. package/dist/index.cjs +1635 -1464
  13. package/dist/init.cjs +53 -59
  14. package/dist/integration-tests.d.ts +39 -0
  15. package/dist/integration-tests.spec.d.ts +1 -0
  16. package/dist/integration.cjs +1635 -1464
  17. package/dist/lint.cjs +9 -2
  18. package/dist/react.cjs +1635 -1464
  19. package/dist/upgrade-steps.d.ts +19 -4
  20. package/dist/upgrade.cjs +9 -2
  21. package/dist/use-cases/prompt-implementation-type.d.ts +2 -0
  22. package/package.json +1 -1
  23. package/skills/df-ps-implement/SKILL.md +2 -1
  24. package/skills/df-ps-scaffold/SKILL.md +2 -1
  25. package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
  26. package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
  27. package/skills/df-ps-scaffold/references/generators.md +31 -7
  28. package/skills/df-ps-scaffold/references/units/aggregate.md +3 -2
  29. package/skills/df-ps-scaffold/references/units/command-query.md +3 -2
  30. package/skills/df-ps-scaffold/references/units/helper.md +1 -1
  31. package/skills/df-ps-scaffold/references/units/implementation.md +1 -1
  32. package/skills/df-ps-scaffold/references/units/port.md +2 -1
  33. package/skills/df-ps-scaffold/references/units/services.md +4 -3
package/dist/init.cjs CHANGED
@@ -275,10 +275,17 @@ const implementation_options_schema_implementationKinds = [
275
275
  'ports'
276
276
  ];
277
277
  const implementation_options_schema_implementationLabelSchema = external_zod_default().string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
278
- const implementationOptionsSchema = external_zod_default().partialRecord(external_zod_default()["enum"](implementation_options_schema_implementationKinds), external_zod_default().object({
278
+ const implementationGroupSchema = external_zod_default().object({
279
279
  primary: external_zod_default().array(implementation_options_schema_implementationLabelSchema).default([]),
280
280
  test: external_zod_default().array(implementation_options_schema_implementationLabelSchema).default([])
281
- }).strict());
281
+ }).strict();
282
+ const implementationOptionsSchema = external_zod_default().object({
283
+ ...Object.fromEntries(implementation_options_schema_implementationKinds.map((kind)=>[
284
+ kind,
285
+ implementationGroupSchema.optional()
286
+ ])),
287
+ integrationTests: external_zod_default().array(implementation_options_schema_implementationLabelSchema).optional()
288
+ }).strict();
282
289
  class project_root_ProjectRoot {
283
290
  path;
284
291
  constructor(){
@@ -631,6 +638,7 @@ const save_pending_changes_savePendingChanges = async ()=>{
631
638
  writePendingChanges();
632
639
  return true;
633
640
  };
641
+ const context_dependencies_crossContextImplementation = 'cross-context';
634
642
  new Map([
635
643
  [
636
644
  'prisma',
@@ -645,6 +653,7 @@ const wiring_relativeImport = (fromFile, toFile)=>{
645
653
  const relativePath = external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile).replace(/\.ts$/, '').split(external_node_path_default().sep).join('/');
646
654
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
647
655
  };
656
+ const inMemoryImplementationType = 'in-memory';
648
657
  const inMemoryDbService = `type Entry = {
649
658
  id: unknown;
650
659
  item: any;
@@ -760,32 +769,13 @@ export const wireInMemoryDbInfrastructureService = wireClass(
760
769
  []
761
770
  );
762
771
  `;
763
- const inMemoryDbSpec = (testingLibrary, withWiring)=>`
764
- import { describe, test, expect, beforeEach } from '${testingLibrary}'
765
- ${withWiring ? `import { type InMemoryDbInfrastructureService } from './in-memory-db-infrastructure-service'
766
- import { wireInMemoryDbInfrastructureService } from '../../wiring/infrastructure-services/wire-in-memory-db-infrastructure-service'` : "import { InMemoryDbInfrastructureService } from './in-memory-db-infrastructure-service'"}
767
-
768
- let inMemoryDbInfrastructureService: InMemoryDbInfrastructureService
769
-
770
- beforeEach(() => {
771
- inMemoryDbInfrastructureService = ${withWiring ? 'wireInMemoryDbInfrastructureService()' : 'new InMemoryDbInfrastructureService()'}
772
- })
773
-
774
- describe('in memory db', () => {
775
- test('can be ${withWiring ? 'wired' : 'created'}', () => {
776
- expect(inMemoryDbInfrastructureService).toBeDefined()
777
- })
778
- })
779
- `.trim();
780
772
  const in_memory_db_withWiring = ()=>config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire');
781
773
  const in_memory_db_scaffoldInMemoryDb = (shared)=>{
782
- const { testingLibrary } = config_file_ConfigFile.backend;
783
774
  const servicesFolder = shared.subitem([
784
775
  'infrastructure',
785
776
  'services'
786
777
  ]);
787
778
  servicesFolder.createFile('in-memory-db-infrastructure-service.ts', inMemoryDbService);
788
- if (testingLibrary) servicesFolder.createFile('in-memory-db-infrastructure-service.spec.ts', inMemoryDbSpec(testingLibrary, in_memory_db_withWiring()));
789
779
  if (in_memory_db_withWiring()) shared.subitem([
790
780
  'wiring',
791
781
  'infrastructure-services'
@@ -1168,44 +1158,6 @@ const storybook_addStorybook = async ()=>{
1168
1158
  })
1169
1159
  ];
1170
1160
  };
1171
- const defaultEnvBranches = {
1172
- names: [
1173
- 'test',
1174
- 'development',
1175
- 'production'
1176
- ],
1177
- test: 'test'
1178
- };
1179
- const wire_branches_envBranches = ()=>{
1180
- const configured = config_file_ConfigFile.exists ? config_file_ConfigFile.Instance.data.backend?.envBranches : void 0;
1181
- const { names, test } = configured ?? defaultEnvBranches;
1182
- return {
1183
- names,
1184
- test,
1185
- primary: names.filter((name)=>name !== test),
1186
- custom: Boolean(configured)
1187
- };
1188
- };
1189
- const envBranchedWireSource = ()=>{
1190
- const { names, custom } = wire_branches_envBranches();
1191
- if (!custom) return `import { branchedWire } from '@domain-first/wire'
1192
-
1193
- export const envBranchedWire = branchedWire(() => {
1194
- return process.env.NODE_ENV ?? 'development' as 'test' | 'development' | 'production'
1195
- });`;
1196
- return `import { branchedWire } from '@domain-first/wire'
1197
-
1198
- export type EnvBranch = ${names.map((name)=>`'${name}'`).join(' | ')}
1199
-
1200
- /**
1201
- * The branch this process runs in. Write how it is selected:
1202
- * until then, this function doesn't compile.
1203
- */
1204
- const currentBranch = (): EnvBranch => {
1205
- }
1206
-
1207
- export const envBranchedWire = branchedWire(currentBranch)`;
1208
- };
1209
1161
  new Set([
1210
1162
  'node_modules',
1211
1163
  '.git',
@@ -1261,6 +1213,48 @@ const domainModelLayout = (kind)=>{
1261
1213
  };
1262
1214
  };
1263
1215
  domainModelLayout('entity'), domainModelLayout('value-object'), serviceLayout('domain'), serviceLayout('application'), serviceLayout('infrastructure'), serviceLayout('presentation'), handlerLayout('command'), handlerLayout('query');
1216
+ new Set([
1217
+ inMemoryImplementationType,
1218
+ context_dependencies_crossContextImplementation
1219
+ ]);
1220
+ const defaultEnvBranches = {
1221
+ names: [
1222
+ 'test',
1223
+ 'development',
1224
+ 'production'
1225
+ ],
1226
+ test: 'test'
1227
+ };
1228
+ const wire_branches_envBranches = ()=>{
1229
+ const configured = config_file_ConfigFile.exists ? config_file_ConfigFile.Instance.data.backend?.envBranches : void 0;
1230
+ const { names, test } = configured ?? defaultEnvBranches;
1231
+ return {
1232
+ names,
1233
+ test,
1234
+ primary: names.filter((name)=>name !== test),
1235
+ custom: Boolean(configured)
1236
+ };
1237
+ };
1238
+ const envBranchedWireSource = ()=>{
1239
+ const { names, custom } = wire_branches_envBranches();
1240
+ if (!custom) return `import { branchedWire } from '@domain-first/wire'
1241
+
1242
+ export const envBranchedWire = branchedWire(() => {
1243
+ return process.env.NODE_ENV ?? 'development' as 'test' | 'development' | 'production'
1244
+ });`;
1245
+ return `import { branchedWire } from '@domain-first/wire'
1246
+
1247
+ export type EnvBranch = ${names.map((name)=>`'${name}'`).join(' | ')}
1248
+
1249
+ /**
1250
+ * The branch this process runs in. Write how it is selected:
1251
+ * until then, this function doesn't compile.
1252
+ */
1253
+ const currentBranch = (): EnvBranch => {
1254
+ }
1255
+
1256
+ export const envBranchedWire = branchedWire(currentBranch)`;
1257
+ };
1264
1258
  const configurationSections = [
1265
1259
  'project',
1266
1260
  'backend',
@@ -0,0 +1,39 @@
1
+ import { type BackendUnit } from './backend-module-move';
2
+ import { File } from './file-system';
3
+ /**
4
+ * Integration specs are generated with the Testcontainers integration and
5
+ * wiring: a spec builds its subject through its wire factory.
6
+ */
7
+ export declare const integrationSpecsAvailable: () => boolean;
8
+ /** Types that never get an integration spec unless listed by hand. */
9
+ export declare const systemImplementationTypes: Set<string>;
10
+ export declare const integrationTestTypes: () => string[];
11
+ /** Records the types whose implementations get integration specs. */
12
+ export declare const setIntegrationTestTypes: (types: string[]) => void;
13
+ /**
14
+ * Exports the factory of an implementation from the contract's wire
15
+ * (`const wirePrismaImplementation` → `export const ...`), so a spec can
16
+ * build it without the environment branches. False when the wire has no
17
+ * such factory.
18
+ */
19
+ export declare const exportImplementationWire: (wireFile: File, label: string) => boolean;
20
+ type SpecSubject = Pick<BackendUnit, 'kind' | 'name' | 'ownerPath'>;
21
+ /**
22
+ * Stages the integration spec of an implementation, or of an
23
+ * infrastructure service without `label`, unless it exists. An
24
+ * implementation's factory gets exported from the contract's wire.
25
+ * Returns the spec file, if staged.
26
+ */
27
+ export declare const scaffoldIntegrationSpec: (unit: SpecSubject, label?: string) => File | undefined;
28
+ /**
29
+ * Whether implementations of this primary type get an integration spec.
30
+ * A listed type does; a newly entered one asks (default yes), and a type
31
+ * saved for future use records the answer.
32
+ */
33
+ export declare const wantsIntegrationTests: (label: string, { entered, save }: {
34
+ entered: boolean;
35
+ save: boolean;
36
+ }) => Promise<boolean>;
37
+ /** Whether a new infrastructure service gets an integration spec. */
38
+ export declare const wantsServiceIntegrationSpec: () => Promise<boolean>;
39
+ export {};
@@ -0,0 +1 @@
1
+ export {};