@domain-first/project-structure 8.9.0 → 8.9.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/dist/{526.js → 115.js} +210 -2
- package/dist/{947.js → 201.js} +479 -2
- package/dist/287.js +2 -204
- package/dist/38.js +1 -2
- package/dist/561.js +2 -3
- package/dist/graph.js +1 -2
- package/dist/in-memory-db.d.ts +9 -0
- package/dist/index.cjs +6 -8
- package/dist/index.js +1 -1
- package/dist/init.cjs +6 -8
- package/dist/init.js +1 -1
- package/dist/integration.cjs +6 -8
- package/dist/integration.js +1 -1
- package/dist/lint.js +1 -1
- package/dist/react.cjs +6 -8
- package/dist/react.js +1 -1
- package/dist/upgrade-in-memory-db.d.ts +7 -0
- package/dist/upgrade-in-memory-db.spec.d.ts +1 -0
- package/dist/upgrade.cjs +93 -27
- package/dist/upgrade.js +25 -3
- package/package.json +1 -1
- package/dist/780.js +0 -481
package/dist/287.js
CHANGED
|
@@ -3,9 +3,8 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
3
3
|
import { Separator, checkbox as prompts_checkbox, confirm as prompts_confirm, input, search, select as prompts_select } from "@inquirer/prompts";
|
|
4
4
|
import node_fs from "node:fs";
|
|
5
5
|
import { styleText } from "node:util";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { missingDomainFirstPackages, walk, projectImports, escapeRegExp, pathParameterAsName, hasLegacyRootEndpoints, stageModuleMove, toPosix, rootStaticSegments, openapiExtractorPath, restControllers, hasDependency, openapiExtractor, missingPackages, codeExtension, isPathParameterName } from "./526.js";
|
|
6
|
+
import { availableDependencies, isSuggestedFor, domainFirstPackages as config_file_domainFirstPackages, scaffoldBackendRules, discardPendingChanges, UnknownFormatNaming, findWiredModules, Folder, compilerOption, implementationKinds, writePendingChanges, readWiredModule, addBranchedImplementation, hasNeighboringBoundedContext, implementationLabelSchema, withoutOverwrites, boundedContextLocation, branchNameSchema, filesToOverwrite, ConfigFile, relativeImport, wireBranches, wireDependencies, File, ProjectRoot, crossContextImportAllowed, crossContextImplementation, implementationType as wiring_implementationType } from "./201.js";
|
|
7
|
+
import { codeExtension, restControllers, missingDomainFirstPackages, isPathParameterName, keepInMemoryDbSection, walk, escapeRegExp, wireInMemoryDb, projectImports, pathParameterAsName, stageModuleMove, hasLegacyRootEndpoints, inMemoryImplementationType, toPosix, rootStaticSegments, inMemoryDbScaffolded, scaffoldInMemoryDb, injectInMemoryDb, isInMemoryDb, openapiExtractorPath, inMemoryDbTypeImport, addInMemoryDbSection, openapiExtractor, plural, missingPackages, inMemoryDbSectionMembers, usesInMemoryDb, hasDependency } from "./115.js";
|
|
9
8
|
const moduleId = (module)=>`${boundedContextLocation(module.typeFile)?.name ?? 'shared-kernel'}:${module.typeName}`;
|
|
10
9
|
const unitId = (unit)=>`${unit.kind}:${unit.aggregate ? `${unit.aggregate}/` : ''}${unit.name}`;
|
|
11
10
|
const savedImplementations = (kind, purpose)=>[
|
|
@@ -371,207 +370,6 @@ const addDrizzle = async ()=>{
|
|
|
371
370
|
})
|
|
372
371
|
];
|
|
373
372
|
};
|
|
374
|
-
const inMemoryImplementationType = 'in-memory';
|
|
375
|
-
const in_memory_db_className = 'InMemoryDbInfrastructureService';
|
|
376
|
-
const in_memory_db_wireName = 'wireInMemoryDbInfrastructureService';
|
|
377
|
-
const parameterName = 'inMemoryDbInfrastructureService';
|
|
378
|
-
const inMemoryDbService = `type Entry = {
|
|
379
|
-
id: unknown;
|
|
380
|
-
item: any;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
declare global {
|
|
384
|
-
var ___SHARED_IN_MEMORY_DB___: Record<string, Array<Entry>> | undefined;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
type Section<T, TId> = {
|
|
388
|
-
all: (predicate?: (x: T) => boolean) => T[];
|
|
389
|
-
first: (predicate: (x: T) => boolean) => T | null;
|
|
390
|
-
withId: (id: TId) => T | null;
|
|
391
|
-
lastAddedItem: () => T | null;
|
|
392
|
-
save: (payload: T extends { id: TId } ? T : [TId, T]) => void;
|
|
393
|
-
deleteById: (id: TId) => void;
|
|
394
|
-
delete: (predicate: (x: T) => boolean) => void;
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
type IdsAreEqual<TId> = (a: TId, b: TId) => boolean;
|
|
398
|
-
|
|
399
|
-
const comparisonMethodNames = ['equals', 'same', 'isSame', 'isEqual'] as const;
|
|
400
|
-
|
|
401
|
-
const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
|
|
402
|
-
if (typeof a !== 'object' || a === null) {
|
|
403
|
-
return Object.is(a, b);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
for (const methodName of comparisonMethodNames) {
|
|
407
|
-
const method: unknown = (a as Record<string, unknown>)[methodName];
|
|
408
|
-
if (typeof method === 'function') {
|
|
409
|
-
return Boolean(method.call(a, b));
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return Object.is(a, b);
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
const hasId = (x: unknown): x is { id: unknown } =>
|
|
417
|
-
typeof x === 'object' && x !== null && 'id' in x;
|
|
418
|
-
|
|
419
|
-
export class InMemoryDbInfrastructureService {
|
|
420
|
-
protected section<T extends { id: unknown }>(
|
|
421
|
-
key: string,
|
|
422
|
-
idsAreEqual?: IdsAreEqual<T['id']>
|
|
423
|
-
): Section<T, T['id']>;
|
|
424
|
-
protected section<T, TId>(
|
|
425
|
-
key: string,
|
|
426
|
-
idsAreEqual?: IdsAreEqual<TId>
|
|
427
|
-
): Section<T, TId>;
|
|
428
|
-
protected section<T, TId>(
|
|
429
|
-
key: string,
|
|
430
|
-
idsAreEqual: IdsAreEqual<TId> = defaultIdsAreEqual
|
|
431
|
-
): Section<T, TId> {
|
|
432
|
-
if (!globalThis.___SHARED_IN_MEMORY_DB___) {
|
|
433
|
-
globalThis.___SHARED_IN_MEMORY_DB___ = {};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (!globalThis.___SHARED_IN_MEMORY_DB___[key]) {
|
|
437
|
-
globalThis.___SHARED_IN_MEMORY_DB___[key] = [];
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const items = (): T[] =>
|
|
441
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key].map(
|
|
442
|
-
(entry) => entry.item
|
|
443
|
-
);
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
all: (predicate: (x: T) => boolean = () => true): T[] =>
|
|
447
|
-
items().filter(predicate),
|
|
448
|
-
first: (predicate: (x: T) => boolean): T | null =>
|
|
449
|
-
items().find(predicate) ?? null,
|
|
450
|
-
withId: (id: TId): T | null =>
|
|
451
|
-
items().find(
|
|
452
|
-
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
453
|
-
) ?? null,
|
|
454
|
-
lastAddedItem: (): T | null =>
|
|
455
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
|
|
456
|
-
save: (payload: T extends { id: TId } ? T : [TId, T]) => {
|
|
457
|
-
const id = Array.isArray(payload) ? payload[0] : payload.id;
|
|
458
|
-
const item = Array.isArray(payload) ? payload[1] : payload;
|
|
459
|
-
const entries = globalThis.___SHARED_IN_MEMORY_DB___![key];
|
|
460
|
-
const existing = entries.find((entry) =>
|
|
461
|
-
idsAreEqual(entry.id as TId, id)
|
|
462
|
-
);
|
|
463
|
-
if (existing) {
|
|
464
|
-
existing.item = item;
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
entries.push({ id, item });
|
|
468
|
-
},
|
|
469
|
-
deleteById: (id: TId) => {
|
|
470
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key] =
|
|
471
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key].filter(
|
|
472
|
-
(entry) => !idsAreEqual(entry.id as TId, id)
|
|
473
|
-
);
|
|
474
|
-
},
|
|
475
|
-
delete: (predicate: (x: T) => boolean) => {
|
|
476
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key] =
|
|
477
|
-
globalThis.___SHARED_IN_MEMORY_DB___![key].filter(
|
|
478
|
-
(entry) => !predicate(entry.item)
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
`;
|
|
485
|
-
const inMemoryDbWiring = `import { wireClass } from '@domain-first/wire';
|
|
486
|
-
import { InMemoryDbInfrastructureService } from '../../infrastructure/services/in-memory-db-infrastructure-service';
|
|
487
|
-
|
|
488
|
-
export const wireInMemoryDbInfrastructureService = wireClass(
|
|
489
|
-
InMemoryDbInfrastructureService,
|
|
490
|
-
[]
|
|
491
|
-
);
|
|
492
|
-
`;
|
|
493
|
-
const in_memory_db_withWiring = ()=>ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire');
|
|
494
|
-
const in_memory_db_sharedFolder = ()=>new Folder(new ProjectRoot().path).subitem([
|
|
495
|
-
ConfigFile.Instance.data.project.rootFolder,
|
|
496
|
-
'shared-kernel'
|
|
497
|
-
]);
|
|
498
|
-
const serviceFile = ()=>new File(in_memory_db_sharedFolder().path).subitem([
|
|
499
|
-
'infrastructure',
|
|
500
|
-
'services',
|
|
501
|
-
'in-memory-db-infrastructure-service.ts'
|
|
502
|
-
]);
|
|
503
|
-
const in_memory_db_wireFile = ()=>new File(in_memory_db_sharedFolder().path).subitem([
|
|
504
|
-
'wiring',
|
|
505
|
-
'infrastructure-services',
|
|
506
|
-
'wire-in-memory-db-infrastructure-service.ts'
|
|
507
|
-
]);
|
|
508
|
-
const scaffoldInMemoryDb = (shared)=>{
|
|
509
|
-
const servicesFolder = shared.subitem([
|
|
510
|
-
'infrastructure',
|
|
511
|
-
'services'
|
|
512
|
-
]);
|
|
513
|
-
servicesFolder.createFile('in-memory-db-infrastructure-service.ts', inMemoryDbService);
|
|
514
|
-
if (in_memory_db_withWiring()) shared.subitem([
|
|
515
|
-
'wiring',
|
|
516
|
-
'infrastructure-services'
|
|
517
|
-
]).createFile('wire-in-memory-db-infrastructure-service.ts', inMemoryDbWiring);
|
|
518
|
-
};
|
|
519
|
-
const inMemoryDbScaffolded = ()=>serviceFile().exists && (!in_memory_db_withWiring() || in_memory_db_wireFile().exists);
|
|
520
|
-
const usesInMemoryDb = (implementationType)=>Boolean(ConfigFile.Instance.data.backend?.withInMemoryDb) && new UnknownFormatNaming(implementationType).fileName === inMemoryImplementationType && inMemoryDbScaffolded();
|
|
521
|
-
const uncountableEndings = [
|
|
522
|
-
'data',
|
|
523
|
-
'info',
|
|
524
|
-
'usage',
|
|
525
|
-
'feedback',
|
|
526
|
-
'media',
|
|
527
|
-
'ware',
|
|
528
|
-
'equipment',
|
|
529
|
-
'information',
|
|
530
|
-
'knowledge',
|
|
531
|
-
'traffic',
|
|
532
|
-
'telemetry',
|
|
533
|
-
'analytics',
|
|
534
|
-
'series'
|
|
535
|
-
];
|
|
536
|
-
const uncountable = new RegExp(`(${uncountableEndings.join('|')})$`, 'i');
|
|
537
|
-
const plural = (word)=>{
|
|
538
|
-
if (uncountable.test(word)) return word;
|
|
539
|
-
if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;
|
|
540
|
-
if (/(^|[^aeiou]|qu)[aeiou]z$/i.test(word)) return `${word}zes`;
|
|
541
|
-
if (/(s|x|z|ch|sh)$/i.test(word)) return `${word}es`;
|
|
542
|
-
return `${word}s`;
|
|
543
|
-
};
|
|
544
|
-
const addInMemoryDbSection = (typeNaming, typeImportTarget)=>{
|
|
545
|
-
const file = serviceFile();
|
|
546
|
-
const sectionNaming = new UnknownFormatNaming(plural(typeNaming.fileName));
|
|
547
|
-
const field = sectionNaming.variableName;
|
|
548
|
-
if (new RegExp(`\\b${field}\\s*=\\s*this\\.section\\b`).test(file.data)) return field;
|
|
549
|
-
const withImport = addImport(file.data, `import type { ${typeNaming.ClassName} } from '${relativeImport(file.path, typeImportTarget)}';`);
|
|
550
|
-
file.update(addClassMember(withImport, in_memory_db_className, `${field} = this.section<${typeNaming.ClassName}>('${sectionNaming.fileName.toUpperCase()}');`));
|
|
551
|
-
return field;
|
|
552
|
-
};
|
|
553
|
-
const inMemoryDbTypeImport = (fromFile)=>`import type { ${in_memory_db_className} } from '${relativeImport(fromFile, serviceFile().path)}'`;
|
|
554
|
-
const inMemoryDbSectionMembers = (field, derived)=>`
|
|
555
|
-
private readonly data: ${in_memory_db_className}['${field}']
|
|
556
|
-
|
|
557
|
-
constructor(${parameterName}: ${in_memory_db_className}) {
|
|
558
|
-
${derived ? 'super()\n ' : ''}this.data = ${parameterName}.${field}
|
|
559
|
-
}
|
|
560
|
-
`.trim();
|
|
561
|
-
const keepInMemoryDbSection = (classFile, field)=>{
|
|
562
|
-
classFile.update(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)).replace('constructor() {}', inMemoryDbSectionMembers(field, false)));
|
|
563
|
-
};
|
|
564
|
-
const isInMemoryDb = (module)=>module.wireName === in_memory_db_wireName;
|
|
565
|
-
const injectInMemoryDb = (classFile, implementationName)=>{
|
|
566
|
-
classFile.update(addConstructorParameters(addImport(classFile.data, inMemoryDbTypeImport(classFile.path)), implementationName, [
|
|
567
|
-
`private readonly ${parameterName}: ${in_memory_db_className}`
|
|
568
|
-
]));
|
|
569
|
-
};
|
|
570
|
-
const wireInMemoryDb = (consumerWireFile, implementationName)=>{
|
|
571
|
-
consumerWireFile.update(addWireDependencies(addImport(consumerWireFile.data, `import { ${in_memory_db_wireName} } from '${relativeImport(consumerWireFile.path, in_memory_db_wireFile().path)}'`), implementationName, [
|
|
572
|
-
in_memory_db_wireName
|
|
573
|
-
]));
|
|
574
|
-
};
|
|
575
373
|
const addInMemoryDb = ()=>{
|
|
576
374
|
const config = ConfigFile.Instance.data;
|
|
577
375
|
if (!ConfigFile.backend.withInMemoryDb) ConfigFile.update({
|
package/dist/38.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
2
|
import node_path from "node:path";
|
|
3
|
-
import { namedImportFiles, canDependOn, isCrossContextImplementation, findWiredModules, moduleKindOf, readWiredModule, crossContextImportAllowed, wiredDependencyNames } from "./
|
|
4
|
-
import { defaultDependencyRules, fileModuleKind, compilerOption } from "./780.js";
|
|
3
|
+
import { defaultDependencyRules, fileModuleKind, namedImportFiles, canDependOn, isCrossContextImplementation, findWiredModules, moduleKindOf, readWiredModule, crossContextImportAllowed, compilerOption, wiredDependencyNames } from "./201.js";
|
|
5
4
|
const readAliases = (projectRoot)=>{
|
|
6
5
|
const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
|
|
7
6
|
const paths = compilerOption(tsconfig, 'paths');
|
package/dist/561.js
CHANGED
|
@@ -2,10 +2,9 @@ import node_fs from "node:fs";
|
|
|
2
2
|
import node_path from "node:path";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import zod from "zod";
|
|
5
|
-
import { implementationLabelSchema, discardPendingChanges, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges } from "./
|
|
5
|
+
import { implementationLabelSchema, availableDependencies, discardPendingChanges, findWiredModules, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges, hasNeighboringBoundedContext } from "./201.js";
|
|
6
6
|
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, helperImplementationTypes, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, runWithAnswers, scaffoldNewCommand, scaffoldNewQuery, findReactModules, moveBackendUnitUseCase, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewApplicationService, scaffoldNewImplementation, savedImplementations, RequestError, deleteReactModuleUseCase, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, integrationSpecsAvailable, integrationSpecFile, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
|
|
7
|
-
import {
|
|
8
|
-
import { restControllers } from "./526.js";
|
|
7
|
+
import { restControllers } from "./115.js";
|
|
9
8
|
const agent_requests_name = implementationLabelSchema;
|
|
10
9
|
const nestedName = zod.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*$/);
|
|
11
10
|
const id = zod.string().min(1);
|
package/dist/graph.js
CHANGED
|
@@ -4,9 +4,8 @@ import node_fs from "node:fs";
|
|
|
4
4
|
import node_os from "node:os";
|
|
5
5
|
import node_path from "node:path";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
|
-
import {
|
|
7
|
+
import { namedImportFiles, wiring_layers, findWiredModules, outdatedConfigMessage, ConfigFile, File, ProjectRoot, wiredDependencyNames } from "./201.js";
|
|
8
8
|
import { readAliases, resolveSpecifier } from "./38.js";
|
|
9
|
-
import { namedImportFiles, wiring_layers, findWiredModules, wiredDependencyNames } from "./947.js";
|
|
10
9
|
const sharedKernel = 'shared-kernel';
|
|
11
10
|
const contextsOf = (contextsFolder)=>node_fs.existsSync(contextsFolder) ? node_fs.readdirSync(contextsFolder, {
|
|
12
11
|
withFileTypes: true
|
package/dist/in-memory-db.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ import { type WiredModule } from './wiring';
|
|
|
5
5
|
* Implementations of this type get the in-memory DB.
|
|
6
6
|
*/
|
|
7
7
|
export declare const inMemoryImplementationType = "in-memory";
|
|
8
|
+
/**
|
|
9
|
+
* `withId` of 8.9.0 and earlier: it compared the stored items' `id`,
|
|
10
|
+
* so items saved as an `[id, item]` tuple were never found.
|
|
11
|
+
*/
|
|
12
|
+
export declare const legacyWithIdLookup = " withId: (id: TId): T | null =>\n items().find(\n (x: T) => hasId(x) && idsAreEqual(x.id as TId, id)\n ) ?? null,\n";
|
|
13
|
+
export declare const legacyHasId = "const hasId = (x: unknown): x is { id: unknown } =>\n typeof x === 'object' && x !== null && 'id' in x;\n\n";
|
|
14
|
+
/** Looks up the id saved with the item, as `save` and `deleteById` do. */
|
|
15
|
+
export declare const withIdLookup = " withId: (id: TId): T | null =>\n globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>\n idsAreEqual(entry.id as TId, id)\n )?.item ?? null,\n";
|
|
16
|
+
export declare const inMemoryDbService = "type Entry = {\n id: unknown;\n item: any;\n};\n\ndeclare global {\n var ___SHARED_IN_MEMORY_DB___: Record<string, Array<Entry>> | undefined;\n}\n\ntype Section<T, TId> = {\n all: (predicate?: (x: T) => boolean) => T[];\n first: (predicate: (x: T) => boolean) => T | null;\n withId: (id: TId) => T | null;\n lastAddedItem: () => T | null;\n save: (payload: T extends { id: TId } ? T : [TId, T]) => void;\n deleteById: (id: TId) => void;\n delete: (predicate: (x: T) => boolean) => void;\n};\n\ntype IdsAreEqual<TId> = (a: TId, b: TId) => boolean;\n\nconst comparisonMethodNames = ['equals', 'same', 'isSame', 'isEqual'] as const;\n\nconst defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {\n if (typeof a !== 'object' || a === null) {\n return Object.is(a, b);\n }\n\n for (const methodName of comparisonMethodNames) {\n const method: unknown = (a as Record<string, unknown>)[methodName];\n if (typeof method === 'function') {\n return Boolean(method.call(a, b));\n }\n }\n\n return Object.is(a, b);\n};\n\nexport class InMemoryDbInfrastructureService {\n protected section<T extends { id: unknown }>(\n key: string,\n idsAreEqual?: IdsAreEqual<T['id']>\n ): Section<T, T['id']>;\n protected section<T, TId>(\n key: string,\n idsAreEqual?: IdsAreEqual<TId>\n ): Section<T, TId>;\n protected section<T, TId>(\n key: string,\n idsAreEqual: IdsAreEqual<TId> = defaultIdsAreEqual\n ): Section<T, TId> {\n if (!globalThis.___SHARED_IN_MEMORY_DB___) {\n globalThis.___SHARED_IN_MEMORY_DB___ = {};\n }\n\n if (!globalThis.___SHARED_IN_MEMORY_DB___[key]) {\n globalThis.___SHARED_IN_MEMORY_DB___[key] = [];\n }\n\n const items = (): T[] =>\n globalThis.___SHARED_IN_MEMORY_DB___![key].map(\n (entry) => entry.item\n );\n\n return {\n all: (predicate: (x: T) => boolean = () => true): T[] =>\n items().filter(predicate),\n first: (predicate: (x: T) => boolean): T | null =>\n items().find(predicate) ?? null,\n withId: (id: TId): T | null =>\n globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>\n idsAreEqual(entry.id as TId, id)\n )?.item ?? null,\n lastAddedItem: (): T | null =>\n globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,\n save: (payload: T extends { id: TId } ? T : [TId, T]) => {\n const id = Array.isArray(payload) ? payload[0] : payload.id;\n const item = Array.isArray(payload) ? payload[1] : payload;\n const entries = globalThis.___SHARED_IN_MEMORY_DB___![key];\n const existing = entries.find((entry) =>\n idsAreEqual(entry.id as TId, id)\n );\n if (existing) {\n existing.item = item;\n return;\n }\n entries.push({ id, item });\n },\n deleteById: (id: TId) => {\n globalThis.___SHARED_IN_MEMORY_DB___![key] =\n globalThis.___SHARED_IN_MEMORY_DB___![key].filter(\n (entry) => !idsAreEqual(entry.id as TId, id)\n );\n },\n delete: (predicate: (x: T) => boolean) => {\n globalThis.___SHARED_IN_MEMORY_DB___![key] =\n globalThis.___SHARED_IN_MEMORY_DB___![key].filter(\n (entry) => !predicate(entry.item)\n );\n }\n };\n }\n}\n";
|
|
8
17
|
/**
|
|
9
18
|
* The shared in-memory DB with its wire, as the config says.
|
|
10
19
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -1283,6 +1283,11 @@ const inMemoryImplementationType = 'in-memory';
|
|
|
1283
1283
|
const in_memory_db_className = 'InMemoryDbInfrastructureService';
|
|
1284
1284
|
const in_memory_db_wireName = 'wireInMemoryDbInfrastructureService';
|
|
1285
1285
|
const in_memory_db_parameterName = 'inMemoryDbInfrastructureService';
|
|
1286
|
+
const withIdLookup = ` withId: (id: TId): T | null =>
|
|
1287
|
+
globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
|
|
1288
|
+
idsAreEqual(entry.id as TId, id)
|
|
1289
|
+
)?.item ?? null,
|
|
1290
|
+
`;
|
|
1286
1291
|
const inMemoryDbService = `type Entry = {
|
|
1287
1292
|
id: unknown;
|
|
1288
1293
|
item: any;
|
|
@@ -1321,9 +1326,6 @@ const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
|
|
|
1321
1326
|
return Object.is(a, b);
|
|
1322
1327
|
};
|
|
1323
1328
|
|
|
1324
|
-
const hasId = (x: unknown): x is { id: unknown } =>
|
|
1325
|
-
typeof x === 'object' && x !== null && 'id' in x;
|
|
1326
|
-
|
|
1327
1329
|
export class InMemoryDbInfrastructureService {
|
|
1328
1330
|
protected section<T extends { id: unknown }>(
|
|
1329
1331
|
key: string,
|
|
@@ -1355,11 +1357,7 @@ export class InMemoryDbInfrastructureService {
|
|
|
1355
1357
|
items().filter(predicate),
|
|
1356
1358
|
first: (predicate: (x: T) => boolean): T | null =>
|
|
1357
1359
|
items().find(predicate) ?? null,
|
|
1358
|
-
|
|
1359
|
-
items().find(
|
|
1360
|
-
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
1361
|
-
) ?? null,
|
|
1362
|
-
lastAddedItem: (): T | null =>
|
|
1360
|
+
${withIdLookup} lastAddedItem: (): T | null =>
|
|
1363
1361
|
globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
|
|
1364
1362
|
save: (payload: T extends { id: TId } ? T : [TId, T]) => {
|
|
1365
1363
|
const id = Array.isArray(payload) ? payload[0] : payload.id;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { select as prompts_select } from "@inquirer/prompts";
|
|
3
3
|
import { runCLI } from "./561.js";
|
|
4
|
-
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./
|
|
4
|
+
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./201.js";
|
|
5
5
|
import { scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewAggregateUseCase, scaffoldNewQuery, scaffoldNewInfrastructureService, scaffoldNewHandlersRestEndpoint, savePendingChanges, moveBackendUnitUseCase, scaffoldNewCommand, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, deleteBackendUnitUseCase, scaffoldNewApplicationService, scaffoldNewUseCase, scaffoldNewImplementation, wireDependency, scaffoldNewBoundedContextUseCase, scaffoldNewDomainObject, scaffoldNewApplicationPort } from "./287.js";
|
|
6
6
|
const main = async ()=>{
|
|
7
7
|
if (!ConfigFile.exists) {
|
package/dist/init.cjs
CHANGED
|
@@ -695,6 +695,11 @@ const wiring_relativeImport = (fromFile, toFile)=>{
|
|
|
695
695
|
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
|
|
696
696
|
};
|
|
697
697
|
const inMemoryImplementationType = 'in-memory';
|
|
698
|
+
const withIdLookup = ` withId: (id: TId): T | null =>
|
|
699
|
+
globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
|
|
700
|
+
idsAreEqual(entry.id as TId, id)
|
|
701
|
+
)?.item ?? null,
|
|
702
|
+
`;
|
|
698
703
|
const inMemoryDbService = `type Entry = {
|
|
699
704
|
id: unknown;
|
|
700
705
|
item: any;
|
|
@@ -733,9 +738,6 @@ const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
|
|
|
733
738
|
return Object.is(a, b);
|
|
734
739
|
};
|
|
735
740
|
|
|
736
|
-
const hasId = (x: unknown): x is { id: unknown } =>
|
|
737
|
-
typeof x === 'object' && x !== null && 'id' in x;
|
|
738
|
-
|
|
739
741
|
export class InMemoryDbInfrastructureService {
|
|
740
742
|
protected section<T extends { id: unknown }>(
|
|
741
743
|
key: string,
|
|
@@ -767,11 +769,7 @@ export class InMemoryDbInfrastructureService {
|
|
|
767
769
|
items().filter(predicate),
|
|
768
770
|
first: (predicate: (x: T) => boolean): T | null =>
|
|
769
771
|
items().find(predicate) ?? null,
|
|
770
|
-
|
|
771
|
-
items().find(
|
|
772
|
-
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
773
|
-
) ?? null,
|
|
774
|
-
lastAddedItem: (): T | null =>
|
|
772
|
+
${withIdLookup} lastAddedItem: (): T | null =>
|
|
775
773
|
globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
|
|
776
774
|
save: (payload: T extends { id: TId } ? T : [TId, T]) => {
|
|
777
775
|
const id = Array.isArray(payload) ? payload[0] : payload.id;
|
package/dist/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { ConfigFile, outdatedConfigMessage } from "./
|
|
3
|
+
import { ConfigFile, outdatedConfigMessage } from "./201.js";
|
|
4
4
|
import { printNextSteps, configurationSections, initializeUseCase, savePendingChanges } from "./287.js";
|
|
5
5
|
const help = `Usage: df-init [--section project|backend|frontend]
|
|
6
6
|
|
package/dist/integration.cjs
CHANGED
|
@@ -1283,6 +1283,11 @@ const inMemoryImplementationType = 'in-memory';
|
|
|
1283
1283
|
const in_memory_db_className = 'InMemoryDbInfrastructureService';
|
|
1284
1284
|
const in_memory_db_wireName = 'wireInMemoryDbInfrastructureService';
|
|
1285
1285
|
const in_memory_db_parameterName = 'inMemoryDbInfrastructureService';
|
|
1286
|
+
const withIdLookup = ` withId: (id: TId): T | null =>
|
|
1287
|
+
globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
|
|
1288
|
+
idsAreEqual(entry.id as TId, id)
|
|
1289
|
+
)?.item ?? null,
|
|
1290
|
+
`;
|
|
1286
1291
|
const inMemoryDbService = `type Entry = {
|
|
1287
1292
|
id: unknown;
|
|
1288
1293
|
item: any;
|
|
@@ -1321,9 +1326,6 @@ const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
|
|
|
1321
1326
|
return Object.is(a, b);
|
|
1322
1327
|
};
|
|
1323
1328
|
|
|
1324
|
-
const hasId = (x: unknown): x is { id: unknown } =>
|
|
1325
|
-
typeof x === 'object' && x !== null && 'id' in x;
|
|
1326
|
-
|
|
1327
1329
|
export class InMemoryDbInfrastructureService {
|
|
1328
1330
|
protected section<T extends { id: unknown }>(
|
|
1329
1331
|
key: string,
|
|
@@ -1355,11 +1357,7 @@ export class InMemoryDbInfrastructureService {
|
|
|
1355
1357
|
items().filter(predicate),
|
|
1356
1358
|
first: (predicate: (x: T) => boolean): T | null =>
|
|
1357
1359
|
items().find(predicate) ?? null,
|
|
1358
|
-
|
|
1359
|
-
items().find(
|
|
1360
|
-
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
1361
|
-
) ?? null,
|
|
1362
|
-
lastAddedItem: (): T | null =>
|
|
1360
|
+
${withIdLookup} lastAddedItem: (): T | null =>
|
|
1363
1361
|
globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
|
|
1364
1362
|
save: (payload: T extends { id: TId } ? T : [TId, T]) => {
|
|
1365
1363
|
const id = Array.isArray(payload) ? payload[0] : payload.id;
|
package/dist/integration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { runCLI } from "./561.js";
|
|
4
|
-
import { ConfigFile, outdatedConfigMessage } from "./
|
|
4
|
+
import { ConfigFile, outdatedConfigMessage } from "./201.js";
|
|
5
5
|
import { addIntegration } from "./287.js";
|
|
6
6
|
runCLI('df-integration', async ()=>{
|
|
7
7
|
const help = `Usage: df-integration
|
package/dist/lint.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { configuredDependencyRules, ProjectRoot, outdatedConfigMessage, ConfigFile } from "./
|
|
3
|
+
import { configuredDependencyRules, ProjectRoot, outdatedConfigMessage, ConfigFile } from "./201.js";
|
|
4
4
|
import { lintProject, formatViolations } from "./38.js";
|
|
5
5
|
const help = `Usage: df-lint [rootFolder]
|
|
6
6
|
|
package/dist/react.cjs
CHANGED
|
@@ -1283,6 +1283,11 @@ const inMemoryImplementationType = 'in-memory';
|
|
|
1283
1283
|
const in_memory_db_className = 'InMemoryDbInfrastructureService';
|
|
1284
1284
|
const in_memory_db_wireName = 'wireInMemoryDbInfrastructureService';
|
|
1285
1285
|
const in_memory_db_parameterName = 'inMemoryDbInfrastructureService';
|
|
1286
|
+
const withIdLookup = ` withId: (id: TId): T | null =>
|
|
1287
|
+
globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
|
|
1288
|
+
idsAreEqual(entry.id as TId, id)
|
|
1289
|
+
)?.item ?? null,
|
|
1290
|
+
`;
|
|
1286
1291
|
const inMemoryDbService = `type Entry = {
|
|
1287
1292
|
id: unknown;
|
|
1288
1293
|
item: any;
|
|
@@ -1321,9 +1326,6 @@ const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
|
|
|
1321
1326
|
return Object.is(a, b);
|
|
1322
1327
|
};
|
|
1323
1328
|
|
|
1324
|
-
const hasId = (x: unknown): x is { id: unknown } =>
|
|
1325
|
-
typeof x === 'object' && x !== null && 'id' in x;
|
|
1326
|
-
|
|
1327
1329
|
export class InMemoryDbInfrastructureService {
|
|
1328
1330
|
protected section<T extends { id: unknown }>(
|
|
1329
1331
|
key: string,
|
|
@@ -1355,11 +1357,7 @@ export class InMemoryDbInfrastructureService {
|
|
|
1355
1357
|
items().filter(predicate),
|
|
1356
1358
|
first: (predicate: (x: T) => boolean): T | null =>
|
|
1357
1359
|
items().find(predicate) ?? null,
|
|
1358
|
-
|
|
1359
|
-
items().find(
|
|
1360
|
-
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
1361
|
-
) ?? null,
|
|
1362
|
-
lastAddedItem: (): T | null =>
|
|
1360
|
+
${withIdLookup} lastAddedItem: (): T | null =>
|
|
1363
1361
|
globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
|
|
1364
1362
|
save: (payload: T extends { id: TId } ? T : [TId, T]) => {
|
|
1365
1363
|
const id = Array.isArray(payload) ? payload[0] : payload.id;
|
package/dist/react.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { select as prompts_select } from "@inquirer/prompts";
|
|
4
4
|
import { runCLI } from "./561.js";
|
|
5
|
-
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./
|
|
5
|
+
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./201.js";
|
|
6
6
|
import { scaffoldReactWidget, moveReactModuleUseCase, deleteReactModuleUseCase, scaffoldReactPage, scaffoldReactUIKitComponent, scaffoldReactSharedHook, savePendingChanges } from "./287.js";
|
|
7
7
|
runCLI('df-react', async ()=>{
|
|
8
8
|
const help = `Usage: df-react
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UpgradeStep } from './upgrade-steps';
|
|
2
|
+
/**
|
|
3
|
+
* Fixes `withId` of the generated in-memory DB: items saved as an
|
|
4
|
+
* `[id, item]` tuple have no `id` of their own and were never found.
|
|
5
|
+
* Only the untouched generated lookup is replaced.
|
|
6
|
+
*/
|
|
7
|
+
export declare const inMemoryDbWithIdStep: UpgradeStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|