@vived/core 1.4.5 → 1.5.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.
- package/dist/cjs/DomainFactories/Entities/DomainFactory.js +43 -0
- package/dist/cjs/DomainFactories/Entities/DomainFactory.js.map +1 -0
- package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js +72 -0
- package/dist/cjs/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -0
- package/dist/cjs/DomainFactories/Entities/index.js +19 -0
- package/dist/cjs/DomainFactories/Entities/index.js.map +1 -0
- package/dist/cjs/DomainFactories/Mocks/MockDomainFactory.js +38 -0
- package/dist/cjs/DomainFactories/Mocks/MockDomainFactory.js.map +1 -0
- package/dist/cjs/DomainFactories/Mocks/index.js +18 -0
- package/dist/cjs/DomainFactories/Mocks/index.js.map +1 -0
- package/dist/cjs/DomainFactories/index.js +19 -0
- package/dist/cjs/DomainFactories/index.js.map +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/DomainFactories/Entities/DomainFactory.js +39 -0
- package/dist/esm/DomainFactories/Entities/DomainFactory.js.map +1 -0
- package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js +68 -0
- package/dist/esm/DomainFactories/Entities/DomainFactoryRepo.js.map +1 -0
- package/dist/esm/DomainFactories/Entities/index.js +3 -0
- package/dist/esm/DomainFactories/Entities/index.js.map +1 -0
- package/dist/esm/DomainFactories/Mocks/MockDomainFactory.js +34 -0
- package/dist/esm/DomainFactories/Mocks/MockDomainFactory.js.map +1 -0
- package/dist/esm/DomainFactories/Mocks/index.js +2 -0
- package/dist/esm/DomainFactories/Mocks/index.js.map +1 -0
- package/dist/esm/DomainFactories/index.js +3 -0
- package/dist/esm/DomainFactories/index.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/DomainFactories/Entities/DomainFactory.d.ts +54 -0
- package/dist/types/DomainFactories/Entities/DomainFactory.d.ts.map +1 -0
- package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts +44 -0
- package/dist/types/DomainFactories/Entities/DomainFactoryRepo.d.ts.map +1 -0
- package/dist/types/DomainFactories/Entities/index.d.ts +3 -0
- package/dist/types/DomainFactories/Entities/index.d.ts.map +1 -0
- package/dist/types/DomainFactories/Mocks/MockDomainFactory.d.ts +33 -0
- package/dist/types/DomainFactories/Mocks/MockDomainFactory.d.ts.map +1 -0
- package/dist/types/DomainFactories/Mocks/index.d.ts +2 -0
- package/dist/types/DomainFactories/Mocks/index.d.ts.map +1 -0
- package/dist/types/DomainFactories/index.d.ts +3 -0
- package/dist/types/DomainFactories/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainFactory = void 0;
|
|
4
|
+
const AppObject_1 = require("../../AppObject");
|
|
5
|
+
const DomainFactoryRepo_1 = require("./DomainFactoryRepo");
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for domain factories in the application architecture.
|
|
8
|
+
*
|
|
9
|
+
* DomainFactory is responsible for setting up and initializing the components
|
|
10
|
+
* of a specific domain in a structured, multi-phase approach. Each domain factory
|
|
11
|
+
* automatically registers itself with the DomainFactoryRepo during construction.
|
|
12
|
+
*
|
|
13
|
+
* The setup process follows a specific sequence to ensure dependencies are properly
|
|
14
|
+
* resolved:
|
|
15
|
+
* 1. First, entities are set up (data models)
|
|
16
|
+
* 2. Then, use cases are set up (business logic)
|
|
17
|
+
* 3. Next, presentation managers are set up (view models)
|
|
18
|
+
* 4. Finally, any remaining initialization is performed
|
|
19
|
+
*
|
|
20
|
+
* This ordered approach ensures that dependencies are available when needed, as
|
|
21
|
+
* UCs typically depend on entities, and PMs typically depend on UCs.
|
|
22
|
+
*/
|
|
23
|
+
class DomainFactory extends AppObject_1.AppObjectEntity {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new DomainFactory and registers it with the DomainFactoryRepo.
|
|
26
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
27
|
+
*/
|
|
28
|
+
constructor(appObject) {
|
|
29
|
+
super(appObject, DomainFactory.type);
|
|
30
|
+
/**
|
|
31
|
+
* The name of this domain factory
|
|
32
|
+
* This should be set by concrete implementations to allow domain factories
|
|
33
|
+
* to be located by name.
|
|
34
|
+
*/
|
|
35
|
+
this.factoryName = "";
|
|
36
|
+
// Auto-register with the repository
|
|
37
|
+
DomainFactoryRepo_1.DomainFactoryRepo.get(this.appObjects)?.add(this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.DomainFactory = DomainFactory;
|
|
41
|
+
/** Unique type identifier for this component */
|
|
42
|
+
DomainFactory.type = "DomainFactory";
|
|
43
|
+
//# sourceMappingURL=DomainFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactory.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactory.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAC7D,2DAAwD;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAsB,aAAc,SAAQ,2BAAe;IAmCzD;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QApCvC;;;;WAIG;QACM,gBAAW,GAAW,EAAE,CAAC;QAgChC,oCAAoC;QACpC,qCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;;AA3CH,sCA4CC;AA3CC,gDAAgD;AACzC,kBAAI,GAAG,eAAe,AAAlB,CAAmB","sourcesContent":["import { AppObject, AppObjectEntity } from \"../../AppObject\";\r\nimport { DomainFactoryRepo } from \"./DomainFactoryRepo\";\r\n\r\n/**\r\n * Abstract base class for domain factories in the application architecture.\r\n *\r\n * DomainFactory is responsible for setting up and initializing the components\r\n * of a specific domain in a structured, multi-phase approach. Each domain factory\r\n * automatically registers itself with the DomainFactoryRepo during construction.\r\n *\r\n * The setup process follows a specific sequence to ensure dependencies are properly\r\n * resolved:\r\n * 1. First, entities are set up (data models)\r\n * 2. Then, use cases are set up (business logic)\r\n * 3. Next, presentation managers are set up (view models)\r\n * 4. Finally, any remaining initialization is performed\r\n *\r\n * This ordered approach ensures that dependencies are available when needed, as\r\n * UCs typically depend on entities, and PMs typically depend on UCs.\r\n */\r\nexport abstract class DomainFactory extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactory\";\r\n\r\n /**\r\n * The name of this domain factory\r\n * This should be set by concrete implementations to allow domain factories\r\n * to be located by name.\r\n */\r\n readonly factoryName: string = \"\";\r\n\r\n /**\r\n * Set up entities for this domain.\r\n * This phase should create and configure all data models and repositories.\r\n */\r\n abstract setupEntities(): void;\r\n\r\n /**\r\n * Set up use cases for this domain.\r\n * This phase should create and configure business logic components that operate on entities.\r\n */\r\n abstract setupUCs(): void;\r\n\r\n /**\r\n * Set up presentation managers for this domain.\r\n * This phase should create and configure components that transform entity data into view models.\r\n */\r\n abstract setupPMs(): void;\r\n\r\n /**\r\n * Perform final setup operations for this domain.\r\n * This phase handles any remaining initialization that depends on all other components being ready.\r\n */\r\n abstract finalSetup(): void;\r\n\r\n /**\r\n * Creates a new DomainFactory and registers it with the DomainFactoryRepo.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactory.type);\r\n // Auto-register with the repository\r\n DomainFactoryRepo.get(this.appObjects)?.add(this);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainFactoryRepo = void 0;
|
|
4
|
+
const AppObject_1 = require("../../AppObject");
|
|
5
|
+
/**
|
|
6
|
+
* Repository for managing DomainFactory instances in the application.
|
|
7
|
+
*
|
|
8
|
+
* DomainFactoryRepo is implemented as a singleton that coordinates the setup
|
|
9
|
+
* and initialization of all domain factories. It ensures that the setup phases
|
|
10
|
+
* are executed in the correct order across all registered factories:
|
|
11
|
+
* 1. All factories set up their entities first
|
|
12
|
+
* 2. Then all factories set up their use cases
|
|
13
|
+
* 3. Next all factories set up their presentation managers
|
|
14
|
+
* 4. Finally, all factories perform their final setup operations
|
|
15
|
+
*
|
|
16
|
+
* This phased approach ensures that components in one domain can depend on
|
|
17
|
+
* components from another domain being properly initialized.
|
|
18
|
+
*/
|
|
19
|
+
class DomainFactoryRepo extends AppObject_1.AppObjectEntityRepo {
|
|
20
|
+
/**
|
|
21
|
+
* Global accessor for the singleton repository
|
|
22
|
+
* @param appObjects The AppObjectRepo to search in
|
|
23
|
+
* @returns The singleton DomainFactoryRepo or undefined if not created yet
|
|
24
|
+
*/
|
|
25
|
+
static get(appObjects) {
|
|
26
|
+
return (0, AppObject_1.getSingletonComponent)(DomainFactoryRepo.type, appObjects);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves a domain factory by its name.
|
|
30
|
+
* @param name The name of the domain factory to find
|
|
31
|
+
* @returns The matching domain factory or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
getByName(name) {
|
|
34
|
+
const allFactories = this.getAll();
|
|
35
|
+
return allFactories.find((factory) => factory.factoryName === name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new DomainFactoryRepo and registers it with the given AppObject.
|
|
39
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
40
|
+
*/
|
|
41
|
+
constructor(appObject) {
|
|
42
|
+
super(appObject, DomainFactoryRepo.type);
|
|
43
|
+
/**
|
|
44
|
+
* Orchestrates the setup of the entire domain layer in the correct sequence.
|
|
45
|
+
* Calls each setup phase on all factories before proceeding to the next phase.
|
|
46
|
+
* This ensures cross-domain dependencies are properly resolved.
|
|
47
|
+
*/
|
|
48
|
+
this.setupDomain = () => {
|
|
49
|
+
const allFactories = this.getAll();
|
|
50
|
+
// Phase 1: Set up all entities first
|
|
51
|
+
allFactories.forEach((domainFactory) => {
|
|
52
|
+
domainFactory.setupEntities();
|
|
53
|
+
});
|
|
54
|
+
// Phase 2: Set up all use cases next
|
|
55
|
+
allFactories.forEach((domainFactory) => {
|
|
56
|
+
domainFactory.setupUCs();
|
|
57
|
+
});
|
|
58
|
+
// Phase 3: Set up all presentation managers
|
|
59
|
+
allFactories.forEach((domainFactory) => {
|
|
60
|
+
domainFactory.setupPMs();
|
|
61
|
+
});
|
|
62
|
+
// Phase 4: Perform final setup operations
|
|
63
|
+
allFactories.forEach((domainFactory) => {
|
|
64
|
+
domainFactory.finalSetup();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.DomainFactoryRepo = DomainFactoryRepo;
|
|
70
|
+
/** Unique type identifier for this component */
|
|
71
|
+
DomainFactoryRepo.type = "DomainFactoryRepo";
|
|
72
|
+
//# sourceMappingURL=DomainFactoryRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactoryRepo.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":";;;AAAA,+CAKyB;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAa,iBAAkB,SAAQ,+BAAkC;IAIvE;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,iCAAqB,EAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;IA+BD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QA5C3C;;;;WAIG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAEnC,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;YAEH,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,4CAA4C;YAC5C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,0CAA0C;YAC1C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,UAAU,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAkBF,CAAC;;AA7DH,8CA8DC;AA7DC,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,AAAtB,CAAuB","sourcesContent":["import {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo,\r\n getSingletonComponent,\r\n} from \"../../AppObject\";\r\nimport { DomainFactory } from \"./DomainFactory\";\r\n\r\n/**\r\n * Repository for managing DomainFactory instances in the application.\r\n *\r\n * DomainFactoryRepo is implemented as a singleton that coordinates the setup\r\n * and initialization of all domain factories. It ensures that the setup phases\r\n * are executed in the correct order across all registered factories:\r\n * 1. All factories set up their entities first\r\n * 2. Then all factories set up their use cases\r\n * 3. Next all factories set up their presentation managers\r\n * 4. Finally, all factories perform their final setup operations\r\n *\r\n * This phased approach ensures that components in one domain can depend on\r\n * components from another domain being properly initialized.\r\n */\r\nexport class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory> {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactoryRepo\";\r\n\r\n /**\r\n * Global accessor for the singleton repository\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton DomainFactoryRepo or undefined if not created yet\r\n */\r\n static get(appObjects: AppObjectRepo) {\r\n return getSingletonComponent<DomainFactoryRepo>(\r\n DomainFactoryRepo.type,\r\n appObjects\r\n );\r\n }\r\n\r\n /**\r\n * Orchestrates the setup of the entire domain layer in the correct sequence.\r\n * Calls each setup phase on all factories before proceeding to the next phase.\r\n * This ensures cross-domain dependencies are properly resolved.\r\n */\r\n setupDomain = () => {\r\n const allFactories = this.getAll();\r\n\r\n // Phase 1: Set up all entities first\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupEntities();\r\n });\r\n\r\n // Phase 2: Set up all use cases next\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupUCs();\r\n });\r\n\r\n // Phase 3: Set up all presentation managers\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupPMs();\r\n });\r\n\r\n // Phase 4: Perform final setup operations\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.finalSetup();\r\n });\r\n };\r\n\r\n /**\r\n * Retrieves a domain factory by its name.\r\n * @param name The name of the domain factory to find\r\n * @returns The matching domain factory or undefined if not found\r\n */\r\n getByName(name: string): DomainFactory | undefined {\r\n const allFactories = this.getAll();\r\n return allFactories.find((factory) => factory.factoryName === name);\r\n }\r\n\r\n /**\r\n * Creates a new DomainFactoryRepo and registers it with the given AppObject.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactoryRepo.type);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DomainFactory"), exports);
|
|
18
|
+
__exportStar(require("./DomainFactoryRepo"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,sDAAoC","sourcesContent":["export * from \"./DomainFactory\";\r\nexport * from \"./DomainFactoryRepo\";"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockDomainFactory = void 0;
|
|
4
|
+
const DomainFactory_1 = require("../Entities/DomainFactory");
|
|
5
|
+
/**
|
|
6
|
+
* A mock implementation of the DomainFactory for use in tests.
|
|
7
|
+
*
|
|
8
|
+
* MockDomainFactory replaces the abstract methods from DomainFactory
|
|
9
|
+
* with Jest mock functions (jest.fn()), allowing tests to:
|
|
10
|
+
* 1. Verify that these methods are called
|
|
11
|
+
* 2. Count how many times they are called
|
|
12
|
+
* 3. Assert the order in which they are called
|
|
13
|
+
* 4. Provide custom implementations when needed
|
|
14
|
+
*
|
|
15
|
+
* This class is particularly useful for testing the DomainFactoryRepo's
|
|
16
|
+
* setupDomain method and ensuring the proper sequence of setup phases.
|
|
17
|
+
*/
|
|
18
|
+
class MockDomainFactory extends DomainFactory_1.DomainFactory {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new MockDomainFactory instance
|
|
21
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
22
|
+
*/
|
|
23
|
+
constructor(appObject) {
|
|
24
|
+
super(appObject);
|
|
25
|
+
/** The name of this factory */
|
|
26
|
+
this.factoryName = "MockDomainFactory";
|
|
27
|
+
/** Mock implementation of setting up entities */
|
|
28
|
+
this.setupEntities = jest.fn();
|
|
29
|
+
/** Mock implementation of setting up use cases */
|
|
30
|
+
this.setupUCs = jest.fn();
|
|
31
|
+
/** Mock implementation of setting up presentation managers */
|
|
32
|
+
this.setupPMs = jest.fn();
|
|
33
|
+
/** Mock implementation of the final setup phase */
|
|
34
|
+
this.finalSetup = jest.fn();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.MockDomainFactory = MockDomainFactory;
|
|
38
|
+
//# sourceMappingURL=MockDomainFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDomainFactory.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/MockDomainFactory.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAa,iBAAkB,SAAQ,6BAAa;IAgBlD;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QApBnB,+BAA+B;QACtB,gBAAW,GAAG,mBAAmB,CAAC;QAE3C,iDAAiD;QACjD,kBAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE1B,kDAAkD;QAClD,aAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAErB,8DAA8D;QAC9D,aAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAErB,mDAAmD;QACnD,eAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAQvB,CAAC;CACF;AAvBD,8CAuBC","sourcesContent":["import { AppObject } from \"../../AppObject\";\r\nimport { DomainFactory } from \"../Entities/DomainFactory\";\r\n\r\n/**\r\n * A mock implementation of the DomainFactory for use in tests.\r\n *\r\n * MockDomainFactory replaces the abstract methods from DomainFactory\r\n * with Jest mock functions (jest.fn()), allowing tests to:\r\n * 1. Verify that these methods are called\r\n * 2. Count how many times they are called\r\n * 3. Assert the order in which they are called\r\n * 4. Provide custom implementations when needed\r\n *\r\n * This class is particularly useful for testing the DomainFactoryRepo's\r\n * setupDomain method and ensuring the proper sequence of setup phases.\r\n */\r\nexport class MockDomainFactory extends DomainFactory {\r\n /** The name of this factory */\r\n readonly factoryName = \"MockDomainFactory\";\r\n\r\n /** Mock implementation of setting up entities */\r\n setupEntities = jest.fn();\r\n\r\n /** Mock implementation of setting up use cases */\r\n setupUCs = jest.fn();\r\n\r\n /** Mock implementation of setting up presentation managers */\r\n setupPMs = jest.fn();\r\n\r\n /** Mock implementation of the final setup phase */\r\n finalSetup = jest.fn();\r\n\r\n /**\r\n * Creates a new MockDomainFactory instance\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MockDomainFactory"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC","sourcesContent":["export * from \"./MockDomainFactory\";\r\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Entities"), exports);
|
|
18
|
+
__exportStar(require("./Mocks"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DomainFactories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB","sourcesContent":["export * from \"./Entities\";\r\nexport * from \"./Mocks\";"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AppObject"), exports);
|
|
18
|
+
__exportStar(require("./DomainFactories"), exports);
|
|
18
19
|
__exportStar(require("./Entities"), exports);
|
|
19
20
|
__exportStar(require("./ExampleFeature"), exports);
|
|
20
21
|
__exportStar(require("./Types"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,mDAAgC;AAChC,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,oDAAiC;AACjC,6CAA2B;AAC3B,mDAAgC;AAChC,0CAAwB;AACxB,8CAA4B;AAC5B,iDAA+B","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./DomainFactories\"\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AppObjectEntity } from "../../AppObject";
|
|
2
|
+
import { DomainFactoryRepo } from "./DomainFactoryRepo";
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for domain factories in the application architecture.
|
|
5
|
+
*
|
|
6
|
+
* DomainFactory is responsible for setting up and initializing the components
|
|
7
|
+
* of a specific domain in a structured, multi-phase approach. Each domain factory
|
|
8
|
+
* automatically registers itself with the DomainFactoryRepo during construction.
|
|
9
|
+
*
|
|
10
|
+
* The setup process follows a specific sequence to ensure dependencies are properly
|
|
11
|
+
* resolved:
|
|
12
|
+
* 1. First, entities are set up (data models)
|
|
13
|
+
* 2. Then, use cases are set up (business logic)
|
|
14
|
+
* 3. Next, presentation managers are set up (view models)
|
|
15
|
+
* 4. Finally, any remaining initialization is performed
|
|
16
|
+
*
|
|
17
|
+
* This ordered approach ensures that dependencies are available when needed, as
|
|
18
|
+
* UCs typically depend on entities, and PMs typically depend on UCs.
|
|
19
|
+
*/
|
|
20
|
+
export class DomainFactory extends AppObjectEntity {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new DomainFactory and registers it with the DomainFactoryRepo.
|
|
23
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
24
|
+
*/
|
|
25
|
+
constructor(appObject) {
|
|
26
|
+
super(appObject, DomainFactory.type);
|
|
27
|
+
/**
|
|
28
|
+
* The name of this domain factory
|
|
29
|
+
* This should be set by concrete implementations to allow domain factories
|
|
30
|
+
* to be located by name.
|
|
31
|
+
*/
|
|
32
|
+
this.factoryName = "";
|
|
33
|
+
// Auto-register with the repository
|
|
34
|
+
DomainFactoryRepo.get(this.appObjects)?.add(this);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Unique type identifier for this component */
|
|
38
|
+
DomainFactory.type = "DomainFactory";
|
|
39
|
+
//# sourceMappingURL=DomainFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactory.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,aAAc,SAAQ,eAAe;IAmCzD;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QApCvC;;;;WAIG;QACM,gBAAW,GAAW,EAAE,CAAC;QAgChC,oCAAoC;QACpC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;;AA1CD,gDAAgD;AACzC,kBAAI,GAAG,eAAe,AAAlB,CAAmB","sourcesContent":["import { AppObject, AppObjectEntity } from \"../../AppObject\";\r\nimport { DomainFactoryRepo } from \"./DomainFactoryRepo\";\r\n\r\n/**\r\n * Abstract base class for domain factories in the application architecture.\r\n *\r\n * DomainFactory is responsible for setting up and initializing the components\r\n * of a specific domain in a structured, multi-phase approach. Each domain factory\r\n * automatically registers itself with the DomainFactoryRepo during construction.\r\n *\r\n * The setup process follows a specific sequence to ensure dependencies are properly\r\n * resolved:\r\n * 1. First, entities are set up (data models)\r\n * 2. Then, use cases are set up (business logic)\r\n * 3. Next, presentation managers are set up (view models)\r\n * 4. Finally, any remaining initialization is performed\r\n *\r\n * This ordered approach ensures that dependencies are available when needed, as\r\n * UCs typically depend on entities, and PMs typically depend on UCs.\r\n */\r\nexport abstract class DomainFactory extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactory\";\r\n\r\n /**\r\n * The name of this domain factory\r\n * This should be set by concrete implementations to allow domain factories\r\n * to be located by name.\r\n */\r\n readonly factoryName: string = \"\";\r\n\r\n /**\r\n * Set up entities for this domain.\r\n * This phase should create and configure all data models and repositories.\r\n */\r\n abstract setupEntities(): void;\r\n\r\n /**\r\n * Set up use cases for this domain.\r\n * This phase should create and configure business logic components that operate on entities.\r\n */\r\n abstract setupUCs(): void;\r\n\r\n /**\r\n * Set up presentation managers for this domain.\r\n * This phase should create and configure components that transform entity data into view models.\r\n */\r\n abstract setupPMs(): void;\r\n\r\n /**\r\n * Perform final setup operations for this domain.\r\n * This phase handles any remaining initialization that depends on all other components being ready.\r\n */\r\n abstract finalSetup(): void;\r\n\r\n /**\r\n * Creates a new DomainFactory and registers it with the DomainFactoryRepo.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactory.type);\r\n // Auto-register with the repository\r\n DomainFactoryRepo.get(this.appObjects)?.add(this);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AppObjectEntityRepo, getSingletonComponent, } from "../../AppObject";
|
|
2
|
+
/**
|
|
3
|
+
* Repository for managing DomainFactory instances in the application.
|
|
4
|
+
*
|
|
5
|
+
* DomainFactoryRepo is implemented as a singleton that coordinates the setup
|
|
6
|
+
* and initialization of all domain factories. It ensures that the setup phases
|
|
7
|
+
* are executed in the correct order across all registered factories:
|
|
8
|
+
* 1. All factories set up their entities first
|
|
9
|
+
* 2. Then all factories set up their use cases
|
|
10
|
+
* 3. Next all factories set up their presentation managers
|
|
11
|
+
* 4. Finally, all factories perform their final setup operations
|
|
12
|
+
*
|
|
13
|
+
* This phased approach ensures that components in one domain can depend on
|
|
14
|
+
* components from another domain being properly initialized.
|
|
15
|
+
*/
|
|
16
|
+
export class DomainFactoryRepo extends AppObjectEntityRepo {
|
|
17
|
+
/**
|
|
18
|
+
* Global accessor for the singleton repository
|
|
19
|
+
* @param appObjects The AppObjectRepo to search in
|
|
20
|
+
* @returns The singleton DomainFactoryRepo or undefined if not created yet
|
|
21
|
+
*/
|
|
22
|
+
static get(appObjects) {
|
|
23
|
+
return getSingletonComponent(DomainFactoryRepo.type, appObjects);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a domain factory by its name.
|
|
27
|
+
* @param name The name of the domain factory to find
|
|
28
|
+
* @returns The matching domain factory or undefined if not found
|
|
29
|
+
*/
|
|
30
|
+
getByName(name) {
|
|
31
|
+
const allFactories = this.getAll();
|
|
32
|
+
return allFactories.find((factory) => factory.factoryName === name);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new DomainFactoryRepo and registers it with the given AppObject.
|
|
36
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
37
|
+
*/
|
|
38
|
+
constructor(appObject) {
|
|
39
|
+
super(appObject, DomainFactoryRepo.type);
|
|
40
|
+
/**
|
|
41
|
+
* Orchestrates the setup of the entire domain layer in the correct sequence.
|
|
42
|
+
* Calls each setup phase on all factories before proceeding to the next phase.
|
|
43
|
+
* This ensures cross-domain dependencies are properly resolved.
|
|
44
|
+
*/
|
|
45
|
+
this.setupDomain = () => {
|
|
46
|
+
const allFactories = this.getAll();
|
|
47
|
+
// Phase 1: Set up all entities first
|
|
48
|
+
allFactories.forEach((domainFactory) => {
|
|
49
|
+
domainFactory.setupEntities();
|
|
50
|
+
});
|
|
51
|
+
// Phase 2: Set up all use cases next
|
|
52
|
+
allFactories.forEach((domainFactory) => {
|
|
53
|
+
domainFactory.setupUCs();
|
|
54
|
+
});
|
|
55
|
+
// Phase 3: Set up all presentation managers
|
|
56
|
+
allFactories.forEach((domainFactory) => {
|
|
57
|
+
domainFactory.setupPMs();
|
|
58
|
+
});
|
|
59
|
+
// Phase 4: Perform final setup operations
|
|
60
|
+
allFactories.forEach((domainFactory) => {
|
|
61
|
+
domainFactory.finalSetup();
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Unique type identifier for this component */
|
|
67
|
+
DomainFactoryRepo.type = "DomainFactoryRepo";
|
|
68
|
+
//# sourceMappingURL=DomainFactoryRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactoryRepo.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAAkC;IAIvE;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,qBAAqB,CAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;IA+BD;;;;OAIG;IACH,SAAS,CAAC,IAAY;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QA5C3C;;;;WAIG;QACH,gBAAW,GAAG,GAAG,EAAE;YACjB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAEnC,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;YAEH,qCAAqC;YACrC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,4CAA4C;YAC5C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,0CAA0C;YAC1C,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACrC,aAAa,CAAC,UAAU,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAkBF,CAAC;;AA5DD,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,AAAtB,CAAuB","sourcesContent":["import {\r\n AppObject,\r\n AppObjectEntityRepo,\r\n AppObjectRepo,\r\n getSingletonComponent,\r\n} from \"../../AppObject\";\r\nimport { DomainFactory } from \"./DomainFactory\";\r\n\r\n/**\r\n * Repository for managing DomainFactory instances in the application.\r\n *\r\n * DomainFactoryRepo is implemented as a singleton that coordinates the setup\r\n * and initialization of all domain factories. It ensures that the setup phases\r\n * are executed in the correct order across all registered factories:\r\n * 1. All factories set up their entities first\r\n * 2. Then all factories set up their use cases\r\n * 3. Next all factories set up their presentation managers\r\n * 4. Finally, all factories perform their final setup operations\r\n *\r\n * This phased approach ensures that components in one domain can depend on\r\n * components from another domain being properly initialized.\r\n */\r\nexport class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory> {\r\n /** Unique type identifier for this component */\r\n static type = \"DomainFactoryRepo\";\r\n\r\n /**\r\n * Global accessor for the singleton repository\r\n * @param appObjects The AppObjectRepo to search in\r\n * @returns The singleton DomainFactoryRepo or undefined if not created yet\r\n */\r\n static get(appObjects: AppObjectRepo) {\r\n return getSingletonComponent<DomainFactoryRepo>(\r\n DomainFactoryRepo.type,\r\n appObjects\r\n );\r\n }\r\n\r\n /**\r\n * Orchestrates the setup of the entire domain layer in the correct sequence.\r\n * Calls each setup phase on all factories before proceeding to the next phase.\r\n * This ensures cross-domain dependencies are properly resolved.\r\n */\r\n setupDomain = () => {\r\n const allFactories = this.getAll();\r\n\r\n // Phase 1: Set up all entities first\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupEntities();\r\n });\r\n\r\n // Phase 2: Set up all use cases next\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupUCs();\r\n });\r\n\r\n // Phase 3: Set up all presentation managers\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.setupPMs();\r\n });\r\n\r\n // Phase 4: Perform final setup operations\r\n allFactories.forEach((domainFactory) => {\r\n domainFactory.finalSetup();\r\n });\r\n };\r\n\r\n /**\r\n * Retrieves a domain factory by its name.\r\n * @param name The name of the domain factory to find\r\n * @returns The matching domain factory or undefined if not found\r\n */\r\n getByName(name: string): DomainFactory | undefined {\r\n const allFactories = this.getAll();\r\n return allFactories.find((factory) => factory.factoryName === name);\r\n }\r\n\r\n /**\r\n * Creates a new DomainFactoryRepo and registers it with the given AppObject.\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, DomainFactoryRepo.type);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./DomainFactory\";\r\nexport * from \"./DomainFactoryRepo\";"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DomainFactory } from "../Entities/DomainFactory";
|
|
2
|
+
/**
|
|
3
|
+
* A mock implementation of the DomainFactory for use in tests.
|
|
4
|
+
*
|
|
5
|
+
* MockDomainFactory replaces the abstract methods from DomainFactory
|
|
6
|
+
* with Jest mock functions (jest.fn()), allowing tests to:
|
|
7
|
+
* 1. Verify that these methods are called
|
|
8
|
+
* 2. Count how many times they are called
|
|
9
|
+
* 3. Assert the order in which they are called
|
|
10
|
+
* 4. Provide custom implementations when needed
|
|
11
|
+
*
|
|
12
|
+
* This class is particularly useful for testing the DomainFactoryRepo's
|
|
13
|
+
* setupDomain method and ensuring the proper sequence of setup phases.
|
|
14
|
+
*/
|
|
15
|
+
export class MockDomainFactory extends DomainFactory {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new MockDomainFactory instance
|
|
18
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
19
|
+
*/
|
|
20
|
+
constructor(appObject) {
|
|
21
|
+
super(appObject);
|
|
22
|
+
/** The name of this factory */
|
|
23
|
+
this.factoryName = "MockDomainFactory";
|
|
24
|
+
/** Mock implementation of setting up entities */
|
|
25
|
+
this.setupEntities = jest.fn();
|
|
26
|
+
/** Mock implementation of setting up use cases */
|
|
27
|
+
this.setupUCs = jest.fn();
|
|
28
|
+
/** Mock implementation of setting up presentation managers */
|
|
29
|
+
this.setupPMs = jest.fn();
|
|
30
|
+
/** Mock implementation of the final setup phase */
|
|
31
|
+
this.finalSetup = jest.fn();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=MockDomainFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDomainFactory.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/MockDomainFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAgBlD;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QApBnB,+BAA+B;QACtB,gBAAW,GAAG,mBAAmB,CAAC;QAE3C,iDAAiD;QACjD,kBAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE1B,kDAAkD;QAClD,aAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAErB,8DAA8D;QAC9D,aAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAErB,mDAAmD;QACnD,eAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAQvB,CAAC;CACF","sourcesContent":["import { AppObject } from \"../../AppObject\";\r\nimport { DomainFactory } from \"../Entities/DomainFactory\";\r\n\r\n/**\r\n * A mock implementation of the DomainFactory for use in tests.\r\n *\r\n * MockDomainFactory replaces the abstract methods from DomainFactory\r\n * with Jest mock functions (jest.fn()), allowing tests to:\r\n * 1. Verify that these methods are called\r\n * 2. Count how many times they are called\r\n * 3. Assert the order in which they are called\r\n * 4. Provide custom implementations when needed\r\n *\r\n * This class is particularly useful for testing the DomainFactoryRepo's\r\n * setupDomain method and ensuring the proper sequence of setup phases.\r\n */\r\nexport class MockDomainFactory extends DomainFactory {\r\n /** The name of this factory */\r\n readonly factoryName = \"MockDomainFactory\";\r\n\r\n /** Mock implementation of setting up entities */\r\n setupEntities = jest.fn();\r\n\r\n /** Mock implementation of setting up use cases */\r\n setupUCs = jest.fn();\r\n\r\n /** Mock implementation of setting up presentation managers */\r\n setupPMs = jest.fn();\r\n\r\n /** Mock implementation of the final setup phase */\r\n finalSetup = jest.fn();\r\n\r\n /**\r\n * Creates a new MockDomainFactory instance\r\n * @param appObject The parent AppObject this component will be attached to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./MockDomainFactory\";\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DomainFactories/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC","sourcesContent":["export * from \"./Entities\";\r\nexport * from \"./Mocks\";"]}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./AppObject\";\r\nexport * from \"./DomainFactories\"\r\nexport * from \"./Entities\";\r\nexport * from \"./ExampleFeature\"\r\nexport * from \"./Types\";\r\nexport * from \"./Utilities\";\r\nexport * from \"./ValueObjects\";\r\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AppObject, AppObjectEntity } from "../../AppObject";
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for domain factories in the application architecture.
|
|
4
|
+
*
|
|
5
|
+
* DomainFactory is responsible for setting up and initializing the components
|
|
6
|
+
* of a specific domain in a structured, multi-phase approach. Each domain factory
|
|
7
|
+
* automatically registers itself with the DomainFactoryRepo during construction.
|
|
8
|
+
*
|
|
9
|
+
* The setup process follows a specific sequence to ensure dependencies are properly
|
|
10
|
+
* resolved:
|
|
11
|
+
* 1. First, entities are set up (data models)
|
|
12
|
+
* 2. Then, use cases are set up (business logic)
|
|
13
|
+
* 3. Next, presentation managers are set up (view models)
|
|
14
|
+
* 4. Finally, any remaining initialization is performed
|
|
15
|
+
*
|
|
16
|
+
* This ordered approach ensures that dependencies are available when needed, as
|
|
17
|
+
* UCs typically depend on entities, and PMs typically depend on UCs.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class DomainFactory extends AppObjectEntity {
|
|
20
|
+
/** Unique type identifier for this component */
|
|
21
|
+
static type: string;
|
|
22
|
+
/**
|
|
23
|
+
* The name of this domain factory
|
|
24
|
+
* This should be set by concrete implementations to allow domain factories
|
|
25
|
+
* to be located by name.
|
|
26
|
+
*/
|
|
27
|
+
readonly factoryName: string;
|
|
28
|
+
/**
|
|
29
|
+
* Set up entities for this domain.
|
|
30
|
+
* This phase should create and configure all data models and repositories.
|
|
31
|
+
*/
|
|
32
|
+
abstract setupEntities(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Set up use cases for this domain.
|
|
35
|
+
* This phase should create and configure business logic components that operate on entities.
|
|
36
|
+
*/
|
|
37
|
+
abstract setupUCs(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Set up presentation managers for this domain.
|
|
40
|
+
* This phase should create and configure components that transform entity data into view models.
|
|
41
|
+
*/
|
|
42
|
+
abstract setupPMs(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Perform final setup operations for this domain.
|
|
45
|
+
* This phase handles any remaining initialization that depends on all other components being ready.
|
|
46
|
+
*/
|
|
47
|
+
abstract finalSetup(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new DomainFactory and registers it with the DomainFactoryRepo.
|
|
50
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
51
|
+
*/
|
|
52
|
+
constructor(appObject: AppObject);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=DomainFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactory.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG7D;;;;;;;;;;;;;;;;GAgBG;AACH,8BAAsB,aAAc,SAAQ,eAAe;IACzD,gDAAgD;IAChD,MAAM,CAAC,IAAI,SAAmB;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAM;IAElC;;;OAGG;IACH,QAAQ,CAAC,aAAa,IAAI,IAAI;IAE9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAEzB;;;OAGG;IACH,QAAQ,CAAC,UAAU,IAAI,IAAI;IAE3B;;;OAGG;gBACS,SAAS,EAAE,SAAS;CAKjC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AppObject, AppObjectEntityRepo, AppObjectRepo } from "../../AppObject";
|
|
2
|
+
import { DomainFactory } from "./DomainFactory";
|
|
3
|
+
/**
|
|
4
|
+
* Repository for managing DomainFactory instances in the application.
|
|
5
|
+
*
|
|
6
|
+
* DomainFactoryRepo is implemented as a singleton that coordinates the setup
|
|
7
|
+
* and initialization of all domain factories. It ensures that the setup phases
|
|
8
|
+
* are executed in the correct order across all registered factories:
|
|
9
|
+
* 1. All factories set up their entities first
|
|
10
|
+
* 2. Then all factories set up their use cases
|
|
11
|
+
* 3. Next all factories set up their presentation managers
|
|
12
|
+
* 4. Finally, all factories perform their final setup operations
|
|
13
|
+
*
|
|
14
|
+
* This phased approach ensures that components in one domain can depend on
|
|
15
|
+
* components from another domain being properly initialized.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DomainFactoryRepo extends AppObjectEntityRepo<DomainFactory> {
|
|
18
|
+
/** Unique type identifier for this component */
|
|
19
|
+
static type: string;
|
|
20
|
+
/**
|
|
21
|
+
* Global accessor for the singleton repository
|
|
22
|
+
* @param appObjects The AppObjectRepo to search in
|
|
23
|
+
* @returns The singleton DomainFactoryRepo or undefined if not created yet
|
|
24
|
+
*/
|
|
25
|
+
static get(appObjects: AppObjectRepo): DomainFactoryRepo | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Orchestrates the setup of the entire domain layer in the correct sequence.
|
|
28
|
+
* Calls each setup phase on all factories before proceeding to the next phase.
|
|
29
|
+
* This ensures cross-domain dependencies are properly resolved.
|
|
30
|
+
*/
|
|
31
|
+
setupDomain: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves a domain factory by its name.
|
|
34
|
+
* @param name The name of the domain factory to find
|
|
35
|
+
* @returns The matching domain factory or undefined if not found
|
|
36
|
+
*/
|
|
37
|
+
getByName(name: string): DomainFactory | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new DomainFactoryRepo and registers it with the given AppObject.
|
|
40
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
41
|
+
*/
|
|
42
|
+
constructor(appObject: AppObject);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=DomainFactoryRepo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomainFactoryRepo.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/DomainFactoryRepo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,aAAa,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB,CAAC,aAAa,CAAC;IACvE,gDAAgD;IAChD,MAAM,CAAC,IAAI,SAAuB;IAElC;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa;IAOpC;;;;OAIG;IACH,WAAW,aAsBT;IAEF;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAKlD;;;OAGG;gBACS,SAAS,EAAE,SAAS;CAGjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AppObject } from "../../AppObject";
|
|
2
|
+
import { DomainFactory } from "../Entities/DomainFactory";
|
|
3
|
+
/**
|
|
4
|
+
* A mock implementation of the DomainFactory for use in tests.
|
|
5
|
+
*
|
|
6
|
+
* MockDomainFactory replaces the abstract methods from DomainFactory
|
|
7
|
+
* with Jest mock functions (jest.fn()), allowing tests to:
|
|
8
|
+
* 1. Verify that these methods are called
|
|
9
|
+
* 2. Count how many times they are called
|
|
10
|
+
* 3. Assert the order in which they are called
|
|
11
|
+
* 4. Provide custom implementations when needed
|
|
12
|
+
*
|
|
13
|
+
* This class is particularly useful for testing the DomainFactoryRepo's
|
|
14
|
+
* setupDomain method and ensuring the proper sequence of setup phases.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MockDomainFactory extends DomainFactory {
|
|
17
|
+
/** The name of this factory */
|
|
18
|
+
readonly factoryName = "MockDomainFactory";
|
|
19
|
+
/** Mock implementation of setting up entities */
|
|
20
|
+
setupEntities: jest.Mock<any, any, any>;
|
|
21
|
+
/** Mock implementation of setting up use cases */
|
|
22
|
+
setupUCs: jest.Mock<any, any, any>;
|
|
23
|
+
/** Mock implementation of setting up presentation managers */
|
|
24
|
+
setupPMs: jest.Mock<any, any, any>;
|
|
25
|
+
/** Mock implementation of the final setup phase */
|
|
26
|
+
finalSetup: jest.Mock<any, any, any>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new MockDomainFactory instance
|
|
29
|
+
* @param appObject The parent AppObject this component will be attached to
|
|
30
|
+
*/
|
|
31
|
+
constructor(appObject: AppObject);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=MockDomainFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDomainFactory.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/MockDomainFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,+BAA+B;IAC/B,QAAQ,CAAC,WAAW,uBAAuB;IAE3C,iDAAiD;IACjD,aAAa,2BAAa;IAE1B,kDAAkD;IAClD,QAAQ,2BAAa;IAErB,8DAA8D;IAC9D,QAAQ,2BAAa;IAErB,mDAAmD;IACnD,UAAU,2BAAa;IAEvB;;;OAGG;gBACS,SAAS,EAAE,SAAS;CAGjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/DomainFactories/Mocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DomainFactories/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|