@domain-first/project-structure 8.7.1 → 8.9.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 (39) hide show
  1. package/README.md +4 -2
  2. package/dist/287.js +2446 -2005
  3. package/dist/561.js +19 -3
  4. package/dist/780.js +9 -2
  5. package/dist/947.js +4 -0
  6. package/dist/agent-cli.d.ts +37 -5
  7. package/dist/agent-requests.d.ts +24 -0
  8. package/dist/backend-module-move.d.ts +16 -0
  9. package/dist/config-file.d.ts +38 -18
  10. package/dist/graph.cjs +13 -2
  11. package/dist/implementation-options-schema.d.ts +19 -9
  12. package/dist/in-memory-db.d.ts +4 -0
  13. package/dist/index.cjs +3465 -2997
  14. package/dist/init.cjs +94 -77
  15. package/dist/integration-tests.d.ts +39 -0
  16. package/dist/integration-tests.spec.d.ts +1 -0
  17. package/dist/integration.cjs +3489 -3021
  18. package/dist/integrations/drizzle.d.ts +8 -0
  19. package/dist/integrations/drizzle.spec.d.ts +1 -0
  20. package/dist/integrations/index.d.ts +1 -0
  21. package/dist/integrations/testcontainers.d.ts +1 -1
  22. package/dist/lint.cjs +13 -2
  23. package/dist/react.cjs +3465 -2997
  24. package/dist/upgrade-steps.d.ts +19 -4
  25. package/dist/upgrade.cjs +9 -2
  26. package/dist/use-cases/add-integration.d.ts +3 -3
  27. package/dist/use-cases/prompt-implementation-type.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/skills/df-ps-implement/SKILL.md +2 -1
  30. package/skills/df-ps-project-scripts/SKILL.md +22 -5
  31. package/skills/df-ps-scaffold/SKILL.md +1 -0
  32. package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
  33. package/skills/df-ps-scaffold/references/agent-operations.md +3 -2
  34. package/skills/df-ps-scaffold/references/generators.md +27 -2
  35. package/skills/df-ps-scaffold/references/units/aggregate.md +2 -1
  36. package/skills/df-ps-scaffold/references/units/command-query.md +2 -1
  37. package/skills/df-ps-scaffold/references/units/implementation.md +1 -1
  38. package/skills/df-ps-scaffold/references/units/port.md +1 -0
  39. package/skills/df-ps-scaffold/references/units/services.md +3 -2
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,11 +638,53 @@ const save_pending_changes_savePendingChanges = async ()=>{
631
638
  writePendingChanges();
632
639
  return true;
633
640
  };
641
+ const package_scripts_addPackageScripts = async (file, additions)=>{
642
+ const original = file.data;
643
+ const manifest = JSON.parse(original);
644
+ const scripts = {
645
+ ...manifest.scripts
646
+ };
647
+ const selected = {};
648
+ for (const [name, command] of Object.entries(additions)){
649
+ let target = name;
650
+ if (Object.hasOwn(scripts, name) && scripts[name] !== command) {
651
+ const action = await interaction_select({
652
+ key: `scriptConflicts.${name}`,
653
+ message: `Script "${name}" already exists: ${scripts[name]}`,
654
+ choices: [
655
+ 'Keep existing',
656
+ 'Replace',
657
+ 'Use another name'
658
+ ]
659
+ });
660
+ if ('Keep existing' === action) continue;
661
+ if ('Use another name' === action) target = await interaction_input({
662
+ key: `scriptNames.${name}`,
663
+ message: "New script name:",
664
+ validate: (value)=>!/^[a-zA-Z0-9:_-]+$/.test(value) || Object.hasOwn(scripts, value) || Object.hasOwn(additions, value) ? "Enter an unused script name (letters, numbers, :, _, -)." : true
665
+ });
666
+ }
667
+ scripts[target] = command;
668
+ selected[name] = target;
669
+ }
670
+ if (JSON.stringify(manifest.scripts) !== JSON.stringify(scripts)) {
671
+ manifest.scripts = scripts;
672
+ const indent = original.match(/\n([\t ]+)"/)?.[1] ?? ' ';
673
+ file.update(`${JSON.stringify(manifest, null, indent)}\n`);
674
+ }
675
+ return selected;
676
+ };
677
+ const package_scripts_describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
678
+ const context_dependencies_crossContextImplementation = 'cross-context';
634
679
  new Map([
635
680
  [
636
681
  'prisma',
637
682
  'prisma-infrastructure-service'
638
683
  ],
684
+ [
685
+ 'drizzle',
686
+ 'drizzle-infrastructure-service'
687
+ ],
639
688
  [
640
689
  'in-memory',
641
690
  'in-memory-db-infrastructure-service'
@@ -645,6 +694,7 @@ const wiring_relativeImport = (fromFile, toFile)=>{
645
694
  const relativePath = external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile).replace(/\.ts$/, '').split(external_node_path_default().sep).join('/');
646
695
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
647
696
  };
697
+ const inMemoryImplementationType = 'in-memory';
648
698
  const inMemoryDbService = `type Entry = {
649
699
  id: unknown;
650
700
  item: any;
@@ -813,43 +863,6 @@ const next_app_nextAppFolder = (root)=>[
813
863
  'src/app'
814
864
  ].find((folder)=>new file_system_Folder(external_node_path_default().join(root, folder)).exists) ?? 'app';
815
865
  require("node:module");
816
- const package_scripts_addPackageScripts = async (file, additions)=>{
817
- const original = file.data;
818
- const manifest = JSON.parse(original);
819
- const scripts = {
820
- ...manifest.scripts
821
- };
822
- const selected = {};
823
- for (const [name, command] of Object.entries(additions)){
824
- let target = name;
825
- if (Object.hasOwn(scripts, name) && scripts[name] !== command) {
826
- const action = await interaction_select({
827
- key: `scriptConflicts.${name}`,
828
- message: `Script "${name}" already exists: ${scripts[name]}`,
829
- choices: [
830
- 'Keep existing',
831
- 'Replace',
832
- 'Use another name'
833
- ]
834
- });
835
- if ('Keep existing' === action) continue;
836
- if ('Use another name' === action) target = await interaction_input({
837
- key: `scriptNames.${name}`,
838
- message: "New script name:",
839
- validate: (value)=>!/^[a-zA-Z0-9:_-]+$/.test(value) || Object.hasOwn(scripts, value) || Object.hasOwn(additions, value) ? "Enter an unused script name (letters, numbers, :, _, -)." : true
840
- });
841
- }
842
- scripts[target] = command;
843
- selected[name] = target;
844
- }
845
- if (JSON.stringify(manifest.scripts) !== JSON.stringify(scripts)) {
846
- manifest.scripts = scripts;
847
- const indent = original.match(/\n([\t ]+)"/)?.[1] ?? ' ';
848
- file.update(`${JSON.stringify(manifest, null, indent)}\n`);
849
- }
850
- return selected;
851
- };
852
- const package_scripts_describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
853
866
  const gitignore_addGitignoreEntry = (root, entry)=>{
854
867
  const gitignore = new file_system_File(external_node_path_default().join(root, '.gitignore'));
855
868
  const ignored = gitignore.exists ? gitignore.data : '';
@@ -1149,44 +1162,6 @@ const storybook_addStorybook = async ()=>{
1149
1162
  })
1150
1163
  ];
1151
1164
  };
1152
- const defaultEnvBranches = {
1153
- names: [
1154
- 'test',
1155
- 'development',
1156
- 'production'
1157
- ],
1158
- test: 'test'
1159
- };
1160
- const wire_branches_envBranches = ()=>{
1161
- const configured = config_file_ConfigFile.exists ? config_file_ConfigFile.Instance.data.backend?.envBranches : void 0;
1162
- const { names, test } = configured ?? defaultEnvBranches;
1163
- return {
1164
- names,
1165
- test,
1166
- primary: names.filter((name)=>name !== test),
1167
- custom: Boolean(configured)
1168
- };
1169
- };
1170
- const envBranchedWireSource = ()=>{
1171
- const { names, custom } = wire_branches_envBranches();
1172
- if (!custom) return `import { branchedWire } from '@domain-first/wire'
1173
-
1174
- export const envBranchedWire = branchedWire(() => {
1175
- return process.env.NODE_ENV ?? 'development' as 'test' | 'development' | 'production'
1176
- });`;
1177
- return `import { branchedWire } from '@domain-first/wire'
1178
-
1179
- export type EnvBranch = ${names.map((name)=>`'${name}'`).join(' | ')}
1180
-
1181
- /**
1182
- * The branch this process runs in. Write how it is selected:
1183
- * until then, this function doesn't compile.
1184
- */
1185
- const currentBranch = (): EnvBranch => {
1186
- }
1187
-
1188
- export const envBranchedWire = branchedWire(currentBranch)`;
1189
- };
1190
1165
  new Set([
1191
1166
  'node_modules',
1192
1167
  '.git',
@@ -1242,6 +1217,48 @@ const domainModelLayout = (kind)=>{
1242
1217
  };
1243
1218
  };
1244
1219
  domainModelLayout('entity'), domainModelLayout('value-object'), serviceLayout('domain'), serviceLayout('application'), serviceLayout('infrastructure'), serviceLayout('presentation'), handlerLayout('command'), handlerLayout('query');
1220
+ new Set([
1221
+ inMemoryImplementationType,
1222
+ context_dependencies_crossContextImplementation
1223
+ ]);
1224
+ const defaultEnvBranches = {
1225
+ names: [
1226
+ 'test',
1227
+ 'development',
1228
+ 'production'
1229
+ ],
1230
+ test: 'test'
1231
+ };
1232
+ const wire_branches_envBranches = ()=>{
1233
+ const configured = config_file_ConfigFile.exists ? config_file_ConfigFile.Instance.data.backend?.envBranches : void 0;
1234
+ const { names, test } = configured ?? defaultEnvBranches;
1235
+ return {
1236
+ names,
1237
+ test,
1238
+ primary: names.filter((name)=>name !== test),
1239
+ custom: Boolean(configured)
1240
+ };
1241
+ };
1242
+ const envBranchedWireSource = ()=>{
1243
+ const { names, custom } = wire_branches_envBranches();
1244
+ if (!custom) return `import { branchedWire } from '@domain-first/wire'
1245
+
1246
+ export const envBranchedWire = branchedWire(() => {
1247
+ return process.env.NODE_ENV ?? 'development' as 'test' | 'development' | 'production'
1248
+ });`;
1249
+ return `import { branchedWire } from '@domain-first/wire'
1250
+
1251
+ export type EnvBranch = ${names.map((name)=>`'${name}'`).join(' | ')}
1252
+
1253
+ /**
1254
+ * The branch this process runs in. Write how it is selected:
1255
+ * until then, this function doesn't compile.
1256
+ */
1257
+ const currentBranch = (): EnvBranch => {
1258
+ }
1259
+
1260
+ export const envBranchedWire = branchedWire(currentBranch)`;
1261
+ };
1245
1262
  const configurationSections = [
1246
1263
  'project',
1247
1264
  '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 {};