@nest-forge/core 0.0.2 → 0.0.4
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/package.json +6 -17
- package/tsconfig.json +2 -1
- package/.prettierignore +0 -3
- package/.prettierrc +0 -7
- package/README.md +0 -0
- package/dist/architecture/component.d.ts +0 -7
- package/dist/architecture/component.js +0 -24
- package/dist/architecture/controller.d.ts +0 -3
- package/dist/architecture/controller.js +0 -7
- package/dist/architecture/index.d.ts +0 -4
- package/dist/architecture/index.js +0 -7
- package/dist/architecture/module.d.ts +0 -5
- package/dist/architecture/module.js +0 -8
- package/dist/architecture/service.d.ts +0 -3
- package/dist/architecture/service.js +0 -12
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -6
- package/dist/extensions/extension.d.ts +0 -56
- package/dist/extensions/extension.js +0 -55
- package/dist/extensions/index.d.ts +0 -1
- package/dist/extensions/index.js +0 -4
- package/dist/forge-options.interface.d.ts +0 -13
- package/dist/forge-options.interface.js +0 -2
- package/dist/forge.factory.d.ts +0 -37
- package/dist/forge.factory.js +0 -200
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -7
- package/eslint.config.mjs +0 -31
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-forge/core",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
7
7
|
"watch": "rimraf dist && tsc -w -p tsconfig.json",
|
|
8
|
-
"format": "prettier --write \"{src,apps,libs,test}/**/*.ts\""
|
|
9
|
-
"lint": "eslint --ignore-pattern .gitignore \"{src,apps,libs,test}/**/*.ts\""
|
|
8
|
+
"format": "prettier --write \"{src,apps,libs,test}/**/*.ts\""
|
|
10
9
|
},
|
|
11
10
|
"directories": {
|
|
12
11
|
"lib": "src"
|
|
@@ -15,13 +14,12 @@
|
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
16
15
|
"keywords": [],
|
|
17
16
|
"license": "UNLICENSED",
|
|
18
|
-
"homepage": "https://github.com/nest-forge",
|
|
19
17
|
"repository": {
|
|
20
18
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/nest-forge
|
|
19
|
+
"url": "https://github.com/baileyherbert/nest-forge"
|
|
22
20
|
},
|
|
23
21
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/nest-forge/
|
|
22
|
+
"url": "https://github.com/baileyherbert/nest-forge/issues"
|
|
25
23
|
},
|
|
26
24
|
"author": "Bailey Herbert <hello@bailey.sh>",
|
|
27
25
|
"contributors": [],
|
|
@@ -29,19 +27,10 @@
|
|
|
29
27
|
"tslib": "^2.8.1"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@eslint/js": "^9.39.2",
|
|
34
|
-
"@types/node": "~25.0.0",
|
|
35
|
-
"eslint": "^9.18.0",
|
|
36
|
-
"eslint-config-prettier": "^10.1.8",
|
|
37
|
-
"eslint-plugin-import": "^2.32.0",
|
|
38
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
39
|
-
"globals": "^16.0.0",
|
|
30
|
+
"@types/node": "~24.0.0",
|
|
40
31
|
"prettier": "3.7.4",
|
|
41
|
-
"reflect-metadata": "^0.2.2",
|
|
42
32
|
"rimraf": "^6.1.2",
|
|
43
|
-
"typescript": "^5.9.0"
|
|
44
|
-
"typescript-eslint": "^8.51.0"
|
|
33
|
+
"typescript": "^5.9.0"
|
|
45
34
|
},
|
|
46
35
|
"peerDependencies": {
|
|
47
36
|
"@nestjs/common": "^10.2.0 || ^11.0.0",
|
package/tsconfig.json
CHANGED
package/.prettierignore
DELETED
package/.prettierrc
DELETED
package/README.md
DELETED
|
File without changes
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare abstract class ForgeBaseComponent {
|
|
2
|
-
protected onModuleInit(): any;
|
|
3
|
-
protected onApplicationBootstrap(): any;
|
|
4
|
-
protected onModuleDestroy(signal: string): any;
|
|
5
|
-
protected beforeApplicationShutdown(signal: string): any;
|
|
6
|
-
protected onApplicationShutdown(signal: string): any;
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ForgeBaseComponent = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const core_1 = require("@nestjs/core");
|
|
9
|
-
class ForgeBaseComponent {
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
[_a = constants_1.FORGE_FIELD_MODULE_REF];
|
|
14
|
-
onModuleInit() { }
|
|
15
|
-
onApplicationBootstrap() { }
|
|
16
|
-
onModuleDestroy(signal) { }
|
|
17
|
-
beforeApplicationShutdown(signal) { }
|
|
18
|
-
onApplicationShutdown(signal) { }
|
|
19
|
-
}
|
|
20
|
-
exports.ForgeBaseComponent = ForgeBaseComponent;
|
|
21
|
-
tslib_1.__decorate([
|
|
22
|
-
(0, common_1.Inject)(core_1.ModuleRef),
|
|
23
|
-
tslib_1.__metadata("design:type", core_1.ModuleRef)
|
|
24
|
-
], ForgeBaseComponent.prototype, _a, void 0);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForgeController = void 0;
|
|
4
|
-
const component_1 = require("./component");
|
|
5
|
-
class ForgeController extends component_1.ForgeBaseComponent {
|
|
6
|
-
}
|
|
7
|
-
exports.ForgeController = ForgeController;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./component"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./module"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./controller"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./service"), exports);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForgeModule = void 0;
|
|
4
|
-
const component_1 = require("./component");
|
|
5
|
-
class ForgeModule extends component_1.ForgeBaseComponent {
|
|
6
|
-
configure(consumer) { }
|
|
7
|
-
}
|
|
8
|
-
exports.ForgeModule = ForgeModule;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForgeService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const component_1 = require("./component");
|
|
7
|
-
let ForgeService = class ForgeService extends component_1.ForgeBaseComponent {
|
|
8
|
-
};
|
|
9
|
-
exports.ForgeService = ForgeService;
|
|
10
|
-
exports.ForgeService = ForgeService = tslib_1.__decorate([
|
|
11
|
-
(0, common_1.Injectable)()
|
|
12
|
-
], ForgeService);
|
package/dist/constants.d.ts
DELETED
package/dist/constants.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FORGE_TOKEN_ROOT_MODULE = exports.FORGE_FIELD_MODULE_REF = exports.FORGE_ROOT_MODULE = void 0;
|
|
4
|
-
exports.FORGE_ROOT_MODULE = Symbol('FORGE_ROOT_MODULE');
|
|
5
|
-
exports.FORGE_FIELD_MODULE_REF = Symbol('FORGE_FIELD_MODULE_REF');
|
|
6
|
-
exports.FORGE_TOKEN_ROOT_MODULE = Symbol('FORGE_TOKEN_ROOT_MODULE');
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { INestApplication, INestApplicationContext, INestMicroservice, MiddlewareConsumer, ModuleMetadata } from '@nestjs/common';
|
|
2
|
-
import { ForgeController, ForgeModule, ForgeService } from '../architecture';
|
|
3
|
-
export declare abstract class ForgeExtension {
|
|
4
|
-
/**
|
|
5
|
-
* The metdata for this extension.
|
|
6
|
-
*/
|
|
7
|
-
private readonly _metadata;
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a new forge extension instance.
|
|
10
|
-
*/
|
|
11
|
-
constructor(options?: ForgeExtensionMetadata);
|
|
12
|
-
/**
|
|
13
|
-
* Configures a Nest application instance.
|
|
14
|
-
*/
|
|
15
|
-
configureHttpApplication(application: INestApplication): any;
|
|
16
|
-
/**
|
|
17
|
-
* Configures a Nest application context. This is for a standalone application that has no web server.
|
|
18
|
-
*/
|
|
19
|
-
configureStandaloneApplication(context: INestApplicationContext): any;
|
|
20
|
-
/**
|
|
21
|
-
* Configures a Nest microservice context.
|
|
22
|
-
*/
|
|
23
|
-
configureMicroserviceApplication(context: INestMicroservice): any;
|
|
24
|
-
/**
|
|
25
|
-
* Configures the root module of the application.
|
|
26
|
-
*/
|
|
27
|
-
configureRootModule(consumer: MiddlewareConsumer): any;
|
|
28
|
-
/**
|
|
29
|
-
* Instruments the application context. If a value is returned, the instance is replaced with that value, and no further extensions are
|
|
30
|
-
* queried.
|
|
31
|
-
*/
|
|
32
|
-
instrument(instance: unknown): any;
|
|
33
|
-
/**
|
|
34
|
-
* Augments a `ForgeModule` instance.
|
|
35
|
-
*/
|
|
36
|
-
augmentModule(instance: ForgeModule, moduleRef: any): any;
|
|
37
|
-
/**
|
|
38
|
-
* Augments a `ForgeController` instance.
|
|
39
|
-
*/
|
|
40
|
-
augmentController(instance: ForgeController, moduleRef: any): any;
|
|
41
|
-
/**
|
|
42
|
-
* Augments a `ForgeService` instance.
|
|
43
|
-
*/
|
|
44
|
-
augmentService(instance: ForgeService, moduleRef: any): any;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the metadata for this extension.
|
|
47
|
-
*/
|
|
48
|
-
getMetadata(): ForgeExtensionMetadata;
|
|
49
|
-
}
|
|
50
|
-
export interface ForgeExtensionMetadata extends ModuleMetadata {
|
|
51
|
-
/**
|
|
52
|
-
* An optional array of nested extensions to import.
|
|
53
|
-
*/
|
|
54
|
-
extensions?: ForgeExtensionResolvable[];
|
|
55
|
-
}
|
|
56
|
-
export type ForgeExtensionResolvable = ForgeExtension | (new () => ForgeExtension) | null | undefined | false;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ForgeExtension = void 0;
|
|
4
|
-
class ForgeExtension {
|
|
5
|
-
/**
|
|
6
|
-
* The metdata for this extension.
|
|
7
|
-
*/
|
|
8
|
-
_metadata;
|
|
9
|
-
/**
|
|
10
|
-
* Constructs a new forge extension instance.
|
|
11
|
-
*/
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this._metadata = options || {};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Configures a Nest application instance.
|
|
17
|
-
*/
|
|
18
|
-
configureHttpApplication(application) { }
|
|
19
|
-
/**
|
|
20
|
-
* Configures a Nest application context. This is for a standalone application that has no web server.
|
|
21
|
-
*/
|
|
22
|
-
configureStandaloneApplication(context) { }
|
|
23
|
-
/**
|
|
24
|
-
* Configures a Nest microservice context.
|
|
25
|
-
*/
|
|
26
|
-
configureMicroserviceApplication(context) { }
|
|
27
|
-
/**
|
|
28
|
-
* Configures the root module of the application.
|
|
29
|
-
*/
|
|
30
|
-
configureRootModule(consumer) { }
|
|
31
|
-
/**
|
|
32
|
-
* Instruments the application context. If a value is returned, the instance is replaced with that value, and no further extensions are
|
|
33
|
-
* queried.
|
|
34
|
-
*/
|
|
35
|
-
instrument(instance) { }
|
|
36
|
-
/**
|
|
37
|
-
* Augments a `ForgeModule` instance.
|
|
38
|
-
*/
|
|
39
|
-
augmentModule(instance, moduleRef) { }
|
|
40
|
-
/**
|
|
41
|
-
* Augments a `ForgeController` instance.
|
|
42
|
-
*/
|
|
43
|
-
augmentController(instance, moduleRef) { }
|
|
44
|
-
/**
|
|
45
|
-
* Augments a `ForgeService` instance.
|
|
46
|
-
*/
|
|
47
|
-
augmentService(instance, moduleRef) { }
|
|
48
|
-
/**
|
|
49
|
-
* Returns the metadata for this extension.
|
|
50
|
-
*/
|
|
51
|
-
getMetadata() {
|
|
52
|
-
return this._metadata;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.ForgeExtension = ForgeExtension;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './extension';
|
package/dist/extensions/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NestApplicationOptions } from '@nestjs/common';
|
|
2
|
-
import { ForgeExtensionResolvable } from './extensions';
|
|
3
|
-
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
4
|
-
import { NestMicroserviceOptions } from '@nestjs/common/interfaces/microservices/nest-microservice-options.interface';
|
|
5
|
-
export interface ForgeApplicationOptions extends NestApplicationOptions {
|
|
6
|
-
extensions?: ForgeExtensionResolvable | ForgeExtensionResolvable[];
|
|
7
|
-
}
|
|
8
|
-
export interface ForgeApplicationContextOptions extends NestApplicationContextOptions {
|
|
9
|
-
extensions?: ForgeExtensionResolvable | ForgeExtensionResolvable[];
|
|
10
|
-
}
|
|
11
|
-
export interface ForgeMicroserviceOptions extends NestMicroserviceOptions {
|
|
12
|
-
extensions?: ForgeExtensionResolvable | ForgeExtensionResolvable[];
|
|
13
|
-
}
|
package/dist/forge.factory.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, ForwardReference, MiddlewareConsumer, Type } from '@nestjs/common';
|
|
2
|
-
import { ForgeApplicationContextOptions, ForgeApplicationOptions, ForgeMicroserviceOptions } from './forge-options.interface';
|
|
3
|
-
import { ForgeExtension, ForgeExtensionResolvable } from './extensions';
|
|
4
|
-
import { ModuleRef } from '@nestjs/core';
|
|
5
|
-
import { FORGE_ROOT_MODULE } from './constants';
|
|
6
|
-
import { ForgeBaseComponent, ForgeController, ForgeModule, ForgeService } from './architecture';
|
|
7
|
-
declare class Forge {
|
|
8
|
-
private _augmented;
|
|
9
|
-
create(appModule: IEntryNestModule, options?: ForgeApplicationOptions): Promise<import("@nestjs/common").INestApplication<any>>;
|
|
10
|
-
createApplicationContext(appModule: IEntryNestModule, options: ForgeApplicationContextOptions): Promise<import("@nestjs/common").INestApplicationContext>;
|
|
11
|
-
createMicroservice<T extends object>(appModule: IEntryNestModule, options: ForgeMicroserviceOptions & T): Promise<import("@nestjs/common").INestMicroservice>;
|
|
12
|
-
protected discoverExtensions(resolvables: ForgeExtensionResolvable | ForgeExtensionResolvable[]): ForgeExtension[];
|
|
13
|
-
protected resolveExtension(resolvable: ForgeExtensionResolvable): ForgeExtension;
|
|
14
|
-
protected createRootModule(appModule: IEntryNestModule, extensions: ForgeExtension[]): {
|
|
15
|
-
new (moduleRef: ModuleRef): {
|
|
16
|
-
readonly moduleRef: ModuleRef;
|
|
17
|
-
configure(consumer: MiddlewareConsumer): void;
|
|
18
|
-
readonly [FORGE_ROOT_MODULE]: true;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
protected createInstrument(extensions: ForgeExtension[], originalInstrument?: Instrument): InstrumentResponse;
|
|
22
|
-
protected augmentComponents(instances: ForgeBaseComponent[], extensions: ForgeExtension[]): void;
|
|
23
|
-
protected augmentModule(instance: ForgeModule, extensions: ForgeExtension[]): void;
|
|
24
|
-
protected augmentController(instance: ForgeController, extensions: ForgeExtension[]): void;
|
|
25
|
-
protected augmentService(instance: ForgeService, extensions: ForgeExtension[]): void;
|
|
26
|
-
protected _isRootModule(instance: unknown): instance is IForgeRootModule;
|
|
27
|
-
}
|
|
28
|
-
type IEntryNestModule = Type<any> | DynamicModule | ForwardReference | Promise<IEntryNestModule>;
|
|
29
|
-
type Instrument = {
|
|
30
|
-
instanceDecorator: (instance: unknown) => unknown;
|
|
31
|
-
};
|
|
32
|
-
interface InstrumentResponse {
|
|
33
|
-
instances: ForgeBaseComponent[];
|
|
34
|
-
instanceDecorator: (instance: unknown) => any;
|
|
35
|
-
}
|
|
36
|
-
declare const forge: Forge;
|
|
37
|
-
export { forge as Forge };
|
package/dist/forge.factory.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Forge = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const core_1 = require("@nestjs/core");
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
|
-
const architecture_1 = require("./architecture");
|
|
9
|
-
class Forge {
|
|
10
|
-
_augmented = new Set();
|
|
11
|
-
async create(appModule, options) {
|
|
12
|
-
const extensions = this.discoverExtensions(options?.extensions ?? []);
|
|
13
|
-
const root = this.createRootModule(appModule, extensions);
|
|
14
|
-
const instrument = this.createInstrument(extensions, options.instrument);
|
|
15
|
-
const app = await core_1.NestFactory.create(root, {
|
|
16
|
-
...options,
|
|
17
|
-
instrument: {
|
|
18
|
-
instanceDecorator: instrument.instanceDecorator,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
this.augmentComponents(instrument.instances, extensions);
|
|
22
|
-
for (const extension of extensions) {
|
|
23
|
-
extension.configureHttpApplication(app);
|
|
24
|
-
}
|
|
25
|
-
return app;
|
|
26
|
-
}
|
|
27
|
-
async createApplicationContext(appModule, options) {
|
|
28
|
-
const extensions = this.discoverExtensions(options?.extensions ?? []);
|
|
29
|
-
const root = this.createRootModule(appModule, extensions);
|
|
30
|
-
const instrument = this.createInstrument(extensions, options.instrument);
|
|
31
|
-
const app = await core_1.NestFactory.createApplicationContext(root, {
|
|
32
|
-
...options,
|
|
33
|
-
instrument: {
|
|
34
|
-
instanceDecorator: instrument.instanceDecorator,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
this.augmentComponents(instrument.instances, extensions);
|
|
38
|
-
for (const extension of extensions) {
|
|
39
|
-
extension.configureStandaloneApplication(app);
|
|
40
|
-
}
|
|
41
|
-
return app;
|
|
42
|
-
}
|
|
43
|
-
async createMicroservice(appModule, options) {
|
|
44
|
-
const extensions = this.discoverExtensions(options?.extensions ?? []);
|
|
45
|
-
const root = this.createRootModule(appModule, extensions);
|
|
46
|
-
const instrument = this.createInstrument(extensions, options.instrument);
|
|
47
|
-
const app = await core_1.NestFactory.createMicroservice(root, {
|
|
48
|
-
...options,
|
|
49
|
-
instrument: {
|
|
50
|
-
instanceDecorator: instrument.instanceDecorator,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
this.augmentComponents(instrument.instances, extensions);
|
|
54
|
-
for (const extension of extensions) {
|
|
55
|
-
extension.configureMicroserviceApplication(app);
|
|
56
|
-
}
|
|
57
|
-
return app;
|
|
58
|
-
}
|
|
59
|
-
discoverExtensions(resolvables) {
|
|
60
|
-
const extensions = new Map();
|
|
61
|
-
if (!Array.isArray(resolvables)) {
|
|
62
|
-
resolvables = [resolvables];
|
|
63
|
-
}
|
|
64
|
-
for (const resolvable of resolvables) {
|
|
65
|
-
const extension = this.resolveExtension(resolvable);
|
|
66
|
-
if (extension !== null) {
|
|
67
|
-
const metadata = extension.getMetadata();
|
|
68
|
-
for (const nestedExtension of this.discoverExtensions(metadata.extensions)) {
|
|
69
|
-
extensions.delete(nestedExtension.constructor);
|
|
70
|
-
extensions.set(nestedExtension.constructor, nestedExtension);
|
|
71
|
-
}
|
|
72
|
-
extensions.delete(extension.constructor);
|
|
73
|
-
extensions.set(extension.constructor, extension);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return Array.from(extensions.values());
|
|
77
|
-
}
|
|
78
|
-
resolveExtension(resolvable) {
|
|
79
|
-
if (resolvable === false || resolvable === null || resolvable === undefined) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
if (typeof resolvable === 'object') {
|
|
83
|
-
return resolvable;
|
|
84
|
-
}
|
|
85
|
-
if (typeof resolvable === 'function') {
|
|
86
|
-
return new resolvable();
|
|
87
|
-
}
|
|
88
|
-
throw new Error(`Unsupported extension resolvable "${String(resolvable)}"`);
|
|
89
|
-
}
|
|
90
|
-
createRootModule(appModule, extensions) {
|
|
91
|
-
const meta = {
|
|
92
|
-
imports: [],
|
|
93
|
-
controllers: [],
|
|
94
|
-
providers: [],
|
|
95
|
-
exports: [],
|
|
96
|
-
};
|
|
97
|
-
for (const extension of extensions) {
|
|
98
|
-
const extensionMeta = extension.getMetadata();
|
|
99
|
-
meta.imports.push(...(extensionMeta.imports ?? []));
|
|
100
|
-
meta.controllers.push(...(extensionMeta.controllers ?? []));
|
|
101
|
-
meta.providers.push(...(extensionMeta.providers ?? []));
|
|
102
|
-
meta.exports.push(...(extensionMeta.exports ?? []));
|
|
103
|
-
}
|
|
104
|
-
meta.imports.push(appModule);
|
|
105
|
-
let ForgeRootModule = class ForgeRootModule {
|
|
106
|
-
moduleRef;
|
|
107
|
-
[constants_1.FORGE_ROOT_MODULE] = true;
|
|
108
|
-
constructor(moduleRef) {
|
|
109
|
-
this.moduleRef = moduleRef;
|
|
110
|
-
}
|
|
111
|
-
configure(consumer) {
|
|
112
|
-
for (const extension of extensions) {
|
|
113
|
-
extension.configureRootModule(consumer);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
ForgeRootModule = tslib_1.__decorate([
|
|
118
|
-
(0, common_1.Module)(meta),
|
|
119
|
-
(0, common_1.Global)(),
|
|
120
|
-
tslib_1.__metadata("design:paramtypes", [core_1.ModuleRef])
|
|
121
|
-
], ForgeRootModule);
|
|
122
|
-
let ForgeRootProviderModule = class ForgeRootProviderModule {
|
|
123
|
-
};
|
|
124
|
-
ForgeRootProviderModule = tslib_1.__decorate([
|
|
125
|
-
(0, common_1.Global)(),
|
|
126
|
-
(0, common_1.Module)({
|
|
127
|
-
providers: [
|
|
128
|
-
{
|
|
129
|
-
provide: constants_1.FORGE_TOKEN_ROOT_MODULE,
|
|
130
|
-
useClass: ForgeRootModule,
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
exports: [constants_1.FORGE_TOKEN_ROOT_MODULE],
|
|
134
|
-
})
|
|
135
|
-
], ForgeRootProviderModule);
|
|
136
|
-
meta.imports.unshift(ForgeRootProviderModule);
|
|
137
|
-
return ForgeRootModule;
|
|
138
|
-
}
|
|
139
|
-
createInstrument(extensions, originalInstrument) {
|
|
140
|
-
const hasOriginalInstrument = originalInstrument && originalInstrument.instanceDecorator;
|
|
141
|
-
const instances = new Array();
|
|
142
|
-
return {
|
|
143
|
-
instances,
|
|
144
|
-
instanceDecorator: (instance) => {
|
|
145
|
-
if (this._isRootModule(instance)) {
|
|
146
|
-
// TODO
|
|
147
|
-
}
|
|
148
|
-
if (instance instanceof architecture_1.ForgeBaseComponent) {
|
|
149
|
-
instances.push(instance);
|
|
150
|
-
}
|
|
151
|
-
for (const extension of extensions) {
|
|
152
|
-
const response = extension.instrument(instance);
|
|
153
|
-
if (response !== undefined) {
|
|
154
|
-
return response;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (hasOriginalInstrument) {
|
|
158
|
-
return originalInstrument.instanceDecorator(instance);
|
|
159
|
-
}
|
|
160
|
-
return instance;
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
augmentComponents(instances, extensions) {
|
|
165
|
-
for (const instance of instances) {
|
|
166
|
-
if (!this._augmented.has(instance)) {
|
|
167
|
-
if (instance instanceof architecture_1.ForgeModule) {
|
|
168
|
-
this.augmentModule(instance, extensions);
|
|
169
|
-
}
|
|
170
|
-
else if (instance instanceof architecture_1.ForgeController) {
|
|
171
|
-
this.augmentController(instance, extensions);
|
|
172
|
-
}
|
|
173
|
-
else if (instance instanceof architecture_1.ForgeService) {
|
|
174
|
-
this.augmentService(instance, extensions);
|
|
175
|
-
}
|
|
176
|
-
this._augmented.add(instance);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
augmentModule(instance, extensions) {
|
|
181
|
-
for (const extension of extensions) {
|
|
182
|
-
extension.augmentModule(instance, instance[constants_1.FORGE_FIELD_MODULE_REF]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
augmentController(instance, extensions) {
|
|
186
|
-
for (const extension of extensions) {
|
|
187
|
-
extension.augmentController(instance, instance[constants_1.FORGE_FIELD_MODULE_REF]);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
augmentService(instance, extensions) {
|
|
191
|
-
for (const extension of extensions) {
|
|
192
|
-
extension.augmentService(instance, instance[constants_1.FORGE_FIELD_MODULE_REF]);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
_isRootModule(instance) {
|
|
196
|
-
return typeof instance === 'object' && instance !== null && instance[constants_1.FORGE_ROOT_MODULE] === true;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
const forge = new Forge();
|
|
200
|
-
exports.Forge = forge;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./forge.factory"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./forge-options.interface"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./extensions"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./architecture"), exports);
|
package/eslint.config.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import { defineConfig } from 'eslint/config';
|
|
3
|
-
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
-
import tseslint from 'typescript-eslint';
|
|
5
|
-
import globals from 'globals';
|
|
6
|
-
|
|
7
|
-
export default defineConfig(
|
|
8
|
-
{
|
|
9
|
-
ignores: ['node_modules', '**/node_modules/**', '**/*.js', '**/*.d.ts']
|
|
10
|
-
},
|
|
11
|
-
eslint.configs.recommended,
|
|
12
|
-
...tseslint.configs.recommendedTypeChecked,
|
|
13
|
-
eslintPluginPrettierRecommended,
|
|
14
|
-
{
|
|
15
|
-
languageOptions: {
|
|
16
|
-
globals: {
|
|
17
|
-
...globals.node,
|
|
18
|
-
...globals.jest
|
|
19
|
-
},
|
|
20
|
-
ecmaVersion: 2024,
|
|
21
|
-
sourceType: 'module',
|
|
22
|
-
parserOptions: {
|
|
23
|
-
projectService: true,
|
|
24
|
-
tsconfigRootDir: import.meta.dirname
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
rules: {}
|
|
30
|
-
}
|
|
31
|
-
);
|