taon 21.0.53 → 21.0.55
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/bin/taon +5 -5
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +4 -4
- package/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-abstract-entity.js +17 -31
- package/lib-prod/base-classes/base-angular-service.js +83 -55
- package/lib-prod/base-classes/base-class.js +33 -35
- package/lib-prod/base-classes/base-context.js +17 -19
- package/lib-prod/base-classes/base-controller.js +146 -154
- package/lib-prod/base-classes/base-crud-controller.js +250 -221
- package/lib-prod/base-classes/base-custom-repository.js +7 -18
- package/lib-prod/base-classes/base-electron-service.js +49 -0
- package/lib-prod/base-classes/base-entity.js +20 -30
- package/lib-prod/base-classes/base-file-upload.middleware.js +72 -75
- package/lib-prod/base-classes/base-injector.js +176 -194
- package/lib-prod/base-classes/base-middleware.js +8 -5
- package/lib-prod/base-classes/base-migration.js +19 -22
- package/lib-prod/base-classes/base-provider.js +7 -5
- package/lib-prod/base-classes/base-repository.js +601 -573
- package/lib-prod/base-classes/base-subscriber-for-entity.js +143 -152
- package/lib-prod/base-classes/base.js +18 -0
- package/lib-prod/build-info._auto-generated_.js +26 -14
- package/lib-prod/config/controller-config.js +24 -24
- package/lib-prod/config/controller-options.js +2 -5
- package/lib-prod/config/method-config.js +6 -8
- package/lib-prod/config/param-config.js +2 -8
- package/lib-prod/constants.js +29 -25
- package/lib-prod/context-db-migrations.js +328 -324
- package/lib-prod/create-context.js +211 -146
- package/lib-prod/decorators/classes/controller-decorator.js +16 -20
- package/lib-prod/decorators/classes/entity-decorator.js +26 -47
- package/lib-prod/decorators/classes/middleware-decorator.js +14 -24
- package/lib-prod/decorators/classes/migration-decorator.js +13 -22
- package/lib-prod/decorators/classes/provider-decorator.js +13 -23
- package/lib-prod/decorators/classes/repository-decorator.js +13 -22
- package/lib-prod/decorators/classes/subscriber-decorator.js +13 -23
- package/lib-prod/decorators/decorator-abstract-opt.js +1 -4
- package/lib-prod/decorators/http/http-decorators.js +20 -5
- package/lib-prod/decorators/http/http-methods-decorators.js +91 -133
- package/lib-prod/decorators/http/http-params-decorators.js +36 -62
- package/lib-prod/dependency-injection/di-container.js +28 -29
- package/lib-prod/endpoint-context-storage.js +27 -32
- package/lib-prod/endpoint-context.js +2294 -1930
- package/lib-prod/entity-process.js +209 -198
- package/lib-prod/env/env.angular-node-app.js +66 -130
- package/lib-prod/env/env.docs-webapp.js +66 -130
- package/lib-prod/env/env.electron-app.js +66 -130
- package/lib-prod/env/env.mobile-app.js +66 -130
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
- package/lib-prod/env/env.vscode-plugin.js +66 -130
- package/lib-prod/env/index.js +6 -6
- package/lib-prod/express-types.js +1 -0
- package/lib-prod/formly/formly.models.js +1 -0
- package/lib-prod/formly/fromly.js +196 -175
- package/lib-prod/formly/type-from-entity.js +45 -52
- package/lib-prod/get-response-value.js +21 -18
- package/lib-prod/global-state/taon-global-state/index.js +6 -5
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +18 -19
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +6 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +40 -46
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +33 -46
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +10 -20
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +43 -33
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +10 -20
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +43 -44
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +20 -27
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +10 -10
- package/lib-prod/global-state/taon-transaction-registry/index.js +11 -10
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +20 -21
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +4 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +34 -39
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +34 -54
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +10 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -10
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +10 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +29 -34
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +20 -27
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +4 -5
- package/lib-prod/helpers/class-helpers.js +210 -177
- package/lib-prod/helpers/clone-obj.js +16 -20
- package/lib-prod/helpers/taon-helpers.js +132 -114
- package/lib-prod/index._auto-generated_.js +5 -0
- package/lib-prod/index.js +248 -227
- package/lib-prod/inject.js +88 -33
- package/lib-prod/migrations/index.js +2 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
- package/lib-prod/models.js +72 -103
- package/lib-prod/orm/columns.js +58 -118
- package/lib-prod/orm/index.js +56 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +188 -186
- package/lib-prod/realtime/realtime-core.js +77 -78
- package/lib-prod/realtime/realtime-server.js +225 -240
- package/lib-prod/realtime/realtime-strategy/index.js +4 -4
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +273 -219
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +267 -240
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +26 -20
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +10 -13
- package/lib-prod/realtime/realtime-subs-manager.js +82 -90
- package/lib-prod/realtime/realtime.models.js +2 -0
- package/lib-prod/symbols.js +104 -105
- package/lib-prod/ui/index.js +1 -5
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -5
- package/lib-prod/validators.js +43 -37
- package/lib-prod.split-namespaces.json +32 -86
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,78 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
//#region imports
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
import * as multer from 'multer';
|
|
4
|
+
import { crossPlatformPath, fse, path } from 'tnp-core/lib-prod';
|
|
5
|
+
import { TaonMiddleware } from '../decorators/classes/middleware-decorator';
|
|
6
|
+
import { TaonBaseMiddleware, } from './base-middleware';
|
|
7
|
+
//#endregion
|
|
8
|
+
/**
|
|
9
|
+
* Configurable file upload middleware (multer based)
|
|
10
|
+
*/
|
|
11
|
+
let TaonBaseFileUploadMiddleware = class TaonBaseFileUploadMiddleware extends TaonBaseMiddleware {
|
|
12
|
+
async interceptServerMethod({ req, res, next }, { methodName, expressPath }) {
|
|
13
|
+
return this.middleware()(req, res, next);
|
|
14
|
+
}
|
|
15
|
+
//#region upload Dir
|
|
16
|
+
uploadDir() {
|
|
17
|
+
return crossPlatformPath([this.ctx.cwd, 'uploaded-files']);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region storage
|
|
21
|
+
storage() {
|
|
22
|
+
//#region @backendFunc
|
|
23
|
+
const uploadDir = this.uploadDir();
|
|
24
|
+
if (!fse.existsSync(uploadDir)) {
|
|
25
|
+
try {
|
|
26
|
+
fse.mkdirSync(uploadDir, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
catch (error) { }
|
|
29
|
+
}
|
|
30
|
+
return multer.diskStorage({
|
|
31
|
+
destination: (_req, _file, cb) => cb(null, uploadDir),
|
|
32
|
+
filename: (_req, file, cb) => {
|
|
33
|
+
const ext = path.extname(file.originalname).toLowerCase();
|
|
34
|
+
const base = path
|
|
35
|
+
.basename(file.originalname, ext)
|
|
36
|
+
.replace(/[^\w.-]/g, '_');
|
|
37
|
+
const uniq = `${Date.now()}-${crypto.randomBytes(6).toString('hex')}`;
|
|
38
|
+
const filenameToProcess = `${base}-${uniq}${ext}`;
|
|
39
|
+
cb(null, filenameToProcess);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region upload
|
|
46
|
+
upload() {
|
|
47
|
+
//#region @backendFunc
|
|
48
|
+
return multer({
|
|
49
|
+
storage: this.storage(),
|
|
50
|
+
limits: { fileSize: 1024 * 1024 * 1024 }, // 1 GiB cap; tweak as needed
|
|
51
|
+
// TODO implement file filter if needed
|
|
52
|
+
// fileFilter: (_req, file, cb) => {
|
|
53
|
+
// // accept only .zip by filename extension
|
|
54
|
+
// if (path.extname(file.originalname).toLowerCase() !== '.zip') {
|
|
55
|
+
// return cb(new Error('Only .zip files are allowed'));
|
|
56
|
+
// }
|
|
57
|
+
// cb(null, true);
|
|
58
|
+
// },
|
|
59
|
+
});
|
|
60
|
+
//#endregion
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region middleware
|
|
64
|
+
middleware() {
|
|
65
|
+
//#region @backendFunc
|
|
66
|
+
return this.upload().any();
|
|
67
|
+
//#endregion
|
|
35
68
|
}
|
|
36
|
-
return multer.diskStorage({
|
|
37
|
-
destination: (_req, _file, cb) => cb(null, uploadDir),
|
|
38
|
-
filename: (_req, file, cb) => {
|
|
39
|
-
const ext = path.extname(file.originalname).toLowerCase();
|
|
40
|
-
const base = path.basename(file.originalname, ext).replace(/[^\w.-]/g, "_");
|
|
41
|
-
const uniq = `${Date.now()}-${crypto.randomBytes(6).toString("hex")}`;
|
|
42
|
-
const filenameToProcess = `${base}-${uniq}${ext}`;
|
|
43
|
-
cb(null, filenameToProcess);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region upload
|
|
49
|
-
upload() {
|
|
50
|
-
return multer({
|
|
51
|
-
storage: this.storage(),
|
|
52
|
-
limits: { fileSize: 1024 * 1024 * 1024 }
|
|
53
|
-
// 1 GiB cap; tweak as needed
|
|
54
|
-
// TODO implement file filter if needed
|
|
55
|
-
// fileFilter: (_req, file, cb) => {
|
|
56
|
-
// // accept only .zip by filename extension
|
|
57
|
-
// if (path.extname(file.originalname).toLowerCase() !== '.zip') {
|
|
58
|
-
// return cb(new Error('Only .zip files are allowed'));
|
|
59
|
-
// }
|
|
60
|
-
// cb(null, true);
|
|
61
|
-
// },
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region middleware
|
|
66
|
-
middleware() {
|
|
67
|
-
return this.upload().any();
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
69
|
};
|
|
71
|
-
TaonBaseFileUploadMiddleware =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
TaonBaseFileUploadMiddleware = __decorate([
|
|
71
|
+
TaonMiddleware({
|
|
72
|
+
className: 'TaonBaseFileUploadMiddleware',
|
|
73
|
+
})
|
|
75
74
|
], TaonBaseFileUploadMiddleware);
|
|
76
|
-
export {
|
|
77
|
-
TaonBaseFileUploadMiddleware
|
|
78
|
-
};
|
|
75
|
+
export { TaonBaseFileUploadMiddleware };
|
|
@@ -1,202 +1,184 @@
|
|
|
1
|
-
import { ClassHelpers__NS__getName } from
|
|
2
|
-
import { Symbols__NS__ctxInClassOrClassObj } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//#region inject / ctrl
|
|
86
|
-
/**
|
|
87
|
-
* example usage:
|
|
88
|
-
* ...
|
|
89
|
-
* exampleSubscriber = this.injectSubscriber(ExampleSubscriber)
|
|
90
|
-
* ...
|
|
91
|
-
*/
|
|
92
|
-
injectSubscriber(ctor) {
|
|
93
|
-
return this.__inject(ctor, { localInstance: false });
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region inject / ctrl
|
|
97
|
-
/**
|
|
98
|
-
* aliast to .injectController()
|
|
99
|
-
*/
|
|
100
|
-
injectCtrl(ctor) {
|
|
101
|
-
return this.injectController(ctor);
|
|
102
|
-
}
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region inject / global provider
|
|
105
|
-
/**
|
|
106
|
-
* inject middleware for context
|
|
107
|
-
*/
|
|
108
|
-
injectMiddleware(ctor) {
|
|
109
|
-
return this.__inject(ctor, { localInstance: false });
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region inject / context provider
|
|
113
|
-
/**
|
|
114
|
-
* inject provider for context
|
|
115
|
-
*/
|
|
116
|
-
injectProvider(ctor) {
|
|
117
|
-
return this.__inject(ctor, { localInstance: false });
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region inject / __ inject
|
|
121
|
-
/**
|
|
122
|
-
* Inject: Controllers, Providers, Repositories, Services, etc.
|
|
123
|
-
* TODO addd nest js injecting
|
|
124
|
-
*/
|
|
125
|
-
__inject(ctor, options) {
|
|
126
|
-
if (!options) {
|
|
127
|
-
options = {};
|
|
1
|
+
import { ClassHelpers__NS__getName } from '../helpers/class-helpers';
|
|
2
|
+
import { Symbols__NS__ctxInClassOrClassObj } from '../symbols';
|
|
3
|
+
//#endregion
|
|
4
|
+
export class TaonBaseInjector {
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region class initialization hook
|
|
7
|
+
/**
|
|
8
|
+
* class initialization hook
|
|
9
|
+
* taon after class instace creation
|
|
10
|
+
*/
|
|
11
|
+
async _() { }
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region context
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use ctx instead
|
|
16
|
+
* Current endpoint context
|
|
17
|
+
*/
|
|
18
|
+
get __endpoint_context__() {
|
|
19
|
+
return this[Symbols__NS__ctxInClassOrClassObj];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* get current endpoint context
|
|
23
|
+
*/
|
|
24
|
+
get ctx() {
|
|
25
|
+
return this.__endpoint_context__;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region inject
|
|
29
|
+
//#region inject / repo for entity
|
|
30
|
+
/**
|
|
31
|
+
* inject crud repo for entity
|
|
32
|
+
*/
|
|
33
|
+
injectRepo(entityForCrud) {
|
|
34
|
+
const repoProxy = this.__inject(void 0, {
|
|
35
|
+
localInstance: true,
|
|
36
|
+
resolveClassFromContext: 'TaonBaseRepository',
|
|
37
|
+
locaInstanceConstructorArgs: [() => entityForCrud],
|
|
38
|
+
});
|
|
39
|
+
return repoProxy;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region inject / custom repository
|
|
43
|
+
injectCustomRepository(cutomRepositoryClass) {
|
|
44
|
+
const repoProxy = this.__inject(cutomRepositoryClass, {
|
|
45
|
+
localInstance: true,
|
|
46
|
+
locaInstanceConstructorArgs: [
|
|
47
|
+
() => {
|
|
48
|
+
const classToProcess = this.ctx.allClassesInstances[ClassHelpers__NS__getName(cutomRepositoryClass)];
|
|
49
|
+
return classToProcess.entityClassResolveFn();
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
return repoProxy;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region inject / custom repo
|
|
57
|
+
/**
|
|
58
|
+
* aliast to this.injectRepository()
|
|
59
|
+
*/
|
|
60
|
+
injectCustomRepo(cutomRepositoryClass) {
|
|
61
|
+
const repoProxy = this.injectCustomRepository(cutomRepositoryClass);
|
|
62
|
+
return repoProxy;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region inject / controller
|
|
66
|
+
/**
|
|
67
|
+
* example usage:
|
|
68
|
+
* ...
|
|
69
|
+
* exampleController = this.injectController(ExampleController);
|
|
70
|
+
* ...
|
|
71
|
+
*/
|
|
72
|
+
injectController(ctor) {
|
|
73
|
+
return this.__inject(ctor, { localInstance: false });
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region inject / ctrl
|
|
77
|
+
/**
|
|
78
|
+
* example usage:
|
|
79
|
+
* ...
|
|
80
|
+
* exampleSubscriber = this.injectSubscriber(ExampleSubscriber)
|
|
81
|
+
* ...
|
|
82
|
+
*/
|
|
83
|
+
injectSubscriber(ctor) {
|
|
84
|
+
return this.__inject(ctor, { localInstance: false });
|
|
128
85
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region inject / ctrl
|
|
88
|
+
/**
|
|
89
|
+
* aliast to .injectController()
|
|
90
|
+
*/
|
|
91
|
+
injectCtrl(ctor) {
|
|
92
|
+
return this.injectController(ctor);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region inject / global provider
|
|
96
|
+
/**
|
|
97
|
+
* inject middleware for context
|
|
98
|
+
*/
|
|
99
|
+
injectMiddleware(ctor) {
|
|
100
|
+
return this.__inject(ctor, { localInstance: false });
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region inject / context provider
|
|
104
|
+
/**
|
|
105
|
+
* inject provider for context
|
|
106
|
+
*/
|
|
107
|
+
injectProvider(ctor) {
|
|
108
|
+
return this.__inject(ctor, { localInstance: false });
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region inject / __ inject
|
|
112
|
+
/**
|
|
113
|
+
* Inject: Controllers, Providers, Repositories, Services, etc.
|
|
114
|
+
* TODO addd nest js injecting
|
|
115
|
+
*/
|
|
116
|
+
__inject(ctor, options) {
|
|
117
|
+
if (!options) {
|
|
118
|
+
options = {};
|
|
119
|
+
}
|
|
120
|
+
const contextClassInstance = this;
|
|
121
|
+
return new Proxy({}, {
|
|
122
|
+
get: (__, propName) => {
|
|
123
|
+
const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
|
|
124
|
+
const resultContext = contextFromClass
|
|
125
|
+
? contextFromClass
|
|
126
|
+
: this.__endpoint_context__;
|
|
127
|
+
if (options.resolveClassFromContext) {
|
|
128
|
+
const resolvedClass = resultContext.getClassFunByClassName(options.resolveClassFromContext);
|
|
129
|
+
ctor = resolvedClass;
|
|
130
|
+
}
|
|
131
|
+
if (resultContext) {
|
|
132
|
+
var instance = resultContext.inject(ctor, {
|
|
133
|
+
...options,
|
|
134
|
+
contextClassInstance,
|
|
135
|
+
parentInstanceThatWillGetInjectedStuff: this,
|
|
136
|
+
});
|
|
137
|
+
if (!instance) {
|
|
138
|
+
throw new Error(`Not able to inject "${ClassHelpers__NS__getName(ctor) || ctor.name}" inside ` +
|
|
139
|
+
`property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(this)}".
|
|
153
140
|
|
|
154
141
|
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
155
142
|
|
|
156
|
-
`
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
143
|
+
`);
|
|
144
|
+
}
|
|
145
|
+
const result = typeof instance[propName] === 'function'
|
|
146
|
+
? instance[propName].bind(instance)
|
|
147
|
+
: instance[propName];
|
|
148
|
+
// console.log(`Accessing injected "${propName?.toString()}" from "${ClassHelpers__NS__getName(ctor) || ctor.name}"`,result)
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/* */
|
|
152
|
+
/* */
|
|
153
|
+
},
|
|
154
|
+
set: (__, propName, value) => {
|
|
155
|
+
const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
|
|
156
|
+
const resultContext = contextFromClass
|
|
157
|
+
? contextFromClass
|
|
158
|
+
: this.__endpoint_context__;
|
|
159
|
+
if (options.resolveClassFromContext) {
|
|
160
|
+
const resolvedClass = resultContext.getClassFunByClassName(options.resolveClassFromContext);
|
|
161
|
+
ctor = resolvedClass;
|
|
162
|
+
}
|
|
163
|
+
if (resultContext) {
|
|
164
|
+
var instance = resultContext.inject(ctor, {
|
|
165
|
+
...options,
|
|
166
|
+
contextClassInstance,
|
|
167
|
+
parentInstanceThatWillGetInjectedStuff: this,
|
|
168
|
+
});
|
|
169
|
+
if (!instance) {
|
|
170
|
+
const classNameNotResolved = ClassHelpers__NS__getName(ctor) || ctor.name;
|
|
171
|
+
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
172
|
+
`property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(this)}".
|
|
184
173
|
|
|
185
174
|
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
186
175
|
|
|
187
|
-
`
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
|
-
//#endregion
|
|
176
|
+
`);
|
|
177
|
+
}
|
|
178
|
+
instance[propName] = value;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
199
184
|
}
|
|
200
|
-
export {
|
|
201
|
-
TaonBaseInjector
|
|
202
|
-
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { TaonBaseInjector } from
|
|
2
|
-
|
|
1
|
+
import { TaonBaseInjector } from './base-injector';
|
|
2
|
+
//#endregion
|
|
3
|
+
/**
|
|
4
|
+
* TODO
|
|
5
|
+
* - global provider available in all contexts
|
|
6
|
+
* - provider available in own context
|
|
7
|
+
*/
|
|
8
|
+
export class TaonBaseMiddleware extends TaonBaseInjector {
|
|
3
9
|
}
|
|
4
|
-
export {
|
|
5
|
-
TaonBaseMiddleware
|
|
6
|
-
};
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { ___NS__startCase } from
|
|
2
|
-
import { ClassHelpers__NS__getName } from
|
|
3
|
-
import { TaonBaseInjector } from
|
|
4
|
-
class TaonBaseMigration extends TaonBaseInjector {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { ___NS__startCase } from 'tnp-core/lib-prod';
|
|
2
|
+
import { ClassHelpers__NS__getName } from '../helpers/class-helpers';
|
|
3
|
+
import { TaonBaseInjector } from './base-injector';
|
|
4
|
+
export class TaonBaseMigration extends TaonBaseInjector {
|
|
5
|
+
/**
|
|
6
|
+
* by default is READY to run
|
|
7
|
+
*/
|
|
8
|
+
isReadyToRun() {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
getDescription() {
|
|
12
|
+
return ___NS__startCase(ClassHelpers__NS__getName(this));
|
|
13
|
+
}
|
|
14
|
+
async up(queryRunner) {
|
|
15
|
+
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers__NS__getName(this)}"`);
|
|
16
|
+
}
|
|
17
|
+
async down(queryRunner) {
|
|
18
|
+
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers__NS__getName(this)}"`);
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
|
-
export {
|
|
22
|
-
TaonBaseMigration
|
|
23
|
-
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { TaonBaseInjector } from
|
|
2
|
-
|
|
1
|
+
import { TaonBaseInjector } from './base-injector';
|
|
2
|
+
/**
|
|
3
|
+
* TODO
|
|
4
|
+
* - global provider available in all contexts
|
|
5
|
+
* - provider available in own context
|
|
6
|
+
*/
|
|
7
|
+
export class TaonBaseProvider extends TaonBaseInjector {
|
|
3
8
|
}
|
|
4
|
-
export {
|
|
5
|
-
TaonBaseProvider
|
|
6
|
-
};
|