taon 21.0.52 → 21.0.54
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/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 +19 -0
- package/lib-prod/base-classes/base-angular-service.js +84 -0
- package/lib-prod/base-classes/base-class.js +35 -0
- package/lib-prod/base-classes/{base-context.ts → base-context.js} +13 -15
- package/lib-prod/base-classes/base-controller.js +154 -0
- package/lib-prod/base-classes/base-crud-controller.js +264 -0
- package/lib-prod/base-classes/base-custom-repository.js +9 -0
- package/lib-prod/base-classes/{base-electron-service.ts → base-electron-service.js} +1 -12
- package/lib-prod/base-classes/base-entity.js +22 -0
- package/lib-prod/base-classes/base-file-upload.middleware.js +75 -0
- package/lib-prod/base-classes/base-injector.js +184 -0
- package/lib-prod/base-classes/base-middleware.js +9 -0
- package/lib-prod/base-classes/base-migration.js +20 -0
- package/lib-prod/base-classes/{base-provider.ts → base-provider.js} +2 -2
- package/lib-prod/base-classes/base-repository.js +617 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.js +145 -0
- package/lib-prod/base-classes/{base.ts → base.js} +2 -15
- package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
- package/lib-prod/config/controller-config.js +28 -0
- package/lib-prod/config/controller-options.js +3 -0
- package/lib-prod/config/method-config.js +7 -0
- package/lib-prod/config/param-config.js +3 -0
- package/lib-prod/constants.js +33 -0
- package/lib-prod/context-db-migrations.js +342 -0
- package/lib-prod/create-context.js +217 -0
- package/lib-prod/decorators/classes/controller-decorator.js +17 -0
- package/lib-prod/decorators/classes/entity-decorator.js +28 -0
- package/lib-prod/decorators/classes/middleware-decorator.js +16 -0
- package/lib-prod/decorators/classes/migration-decorator.js +15 -0
- package/lib-prod/decorators/classes/provider-decorator.js +15 -0
- package/lib-prod/decorators/classes/repository-decorator.js +15 -0
- package/lib-prod/decorators/classes/subscriber-decorator.js +15 -0
- package/lib-prod/decorators/decorator-abstract-opt.js +2 -0
- package/lib-prod/decorators/http/http-decorators.js +20 -0
- package/lib-prod/decorators/http/http-methods-decorators.js +102 -0
- package/lib-prod/decorators/http/http-params-decorators.js +42 -0
- package/lib-prod/dependency-injection/di-container.js +30 -0
- package/lib-prod/endpoint-context-storage.js +31 -0
- package/lib-prod/endpoint-context.js +2397 -0
- package/lib-prod/entity-process.js +225 -0
- package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
- package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
- package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
- package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
- package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
- package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
- package/lib-prod/express-types.js +1 -0
- package/lib-prod/formly/formly.models.js +1 -0
- package/lib-prod/formly/fromly.js +205 -0
- package/lib-prod/formly/type-from-entity.js +51 -0
- package/lib-prod/get-response-value.js +22 -0
- package/lib-prod/global-state/taon-global-state/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-global-state/{taon-global-state.abstract.context.ts → taon-global-state.abstract.context.js} +9 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +7 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +42 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +35 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +44 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +46 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +11 -0
- package/lib-prod/global-state/taon-transaction-registry/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-transaction-registry/{taon-transaction-registry.abstract.context.ts → taon-transaction-registry.abstract.context.js} +10 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +5 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +31 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +5 -0
- package/lib-prod/helpers/class-helpers.js +228 -0
- package/lib-prod/helpers/clone-obj.js +17 -0
- package/lib-prod/helpers/taon-helpers.js +147 -0
- package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
- package/lib-prod/index.js +252 -0
- package/lib-prod/{inject.ts → inject.js} +35 -57
- package/lib-prod/migrations/index.js +2 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
- package/lib-prod/models.js +78 -0
- package/lib-prod/orm/columns.js +64 -0
- package/lib-prod/orm/index.js +56 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +198 -0
- package/lib-prod/realtime/realtime-core.js +81 -0
- package/lib-prod/realtime/realtime-server.js +237 -0
- package/lib-prod/realtime/realtime-strategy/{index.ts → index.js} +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +280 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +289 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +27 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +11 -0
- package/lib-prod/realtime/realtime-subs-manager.js +88 -0
- package/lib-prod/realtime/realtime.models.js +2 -0
- package/lib-prod/symbols.js +108 -0
- package/lib-prod/ui/index.js +1 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -0
- package/lib-prod/validators.js +80 -0
- package/lib-prod.split-namespaces.json +31 -91
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/base-classes/base-abstract-entity.ts +0 -34
- package/lib-prod/base-classes/base-angular-service.ts +0 -107
- package/lib-prod/base-classes/base-class.ts +0 -46
- package/lib-prod/base-classes/base-controller.ts +0 -240
- package/lib-prod/base-classes/base-crud-controller.ts +0 -298
- package/lib-prod/base-classes/base-custom-repository.ts +0 -10
- package/lib-prod/base-classes/base-entity.ts +0 -28
- package/lib-prod/base-classes/base-file-upload.middleware.ts +0 -92
- package/lib-prod/base-classes/base-injector.ts +0 -278
- package/lib-prod/base-classes/base-middleware.ts +0 -71
- package/lib-prod/base-classes/base-migration.ts +0 -26
- package/lib-prod/base-classes/base-repository.ts +0 -942
- package/lib-prod/base-classes/base-subscriber-for-entity.ts +0 -196
- package/lib-prod/config/controller-config.ts +0 -58
- package/lib-prod/config/controller-options.ts +0 -19
- package/lib-prod/config/method-config.ts +0 -55
- package/lib-prod/config/param-config.ts +0 -16
- package/lib-prod/constants.ts +0 -63
- package/lib-prod/context-db-migrations.ts +0 -488
- package/lib-prod/create-context.ts +0 -345
- package/lib-prod/decorators/classes/controller-decorator.ts +0 -25
- package/lib-prod/decorators/classes/entity-decorator.ts +0 -57
- package/lib-prod/decorators/classes/middleware-decorator.ts +0 -29
- package/lib-prod/decorators/classes/migration-decorator.ts +0 -27
- package/lib-prod/decorators/classes/provider-decorator.ts +0 -28
- package/lib-prod/decorators/classes/repository-decorator.ts +0 -26
- package/lib-prod/decorators/classes/subscriber-decorator.ts +0 -28
- package/lib-prod/decorators/decorator-abstract-opt.ts +0 -4
- package/lib-prod/decorators/http/http-decorators.ts +0 -26
- package/lib-prod/decorators/http/http-methods-decorators.ts +0 -275
- package/lib-prod/decorators/http/http-params-decorators.ts +0 -105
- package/lib-prod/dependency-injection/di-container.ts +0 -39
- package/lib-prod/endpoint-context-storage.ts +0 -47
- package/lib-prod/endpoint-context.ts +0 -3110
- package/lib-prod/entity-process.ts +0 -286
- package/lib-prod/express-types.ts +0 -4
- package/lib-prod/formly/formly.models.ts +0 -7
- package/lib-prod/formly/fromly.ts +0 -261
- package/lib-prod/formly/type-from-entity.ts +0 -80
- package/lib-prod/get-response-value.ts +0 -30
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +0 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +0 -44
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +0 -40
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +0 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +0 -48
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +0 -16
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +0 -47
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +0 -18
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +0 -21
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +0 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +0 -38
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +0 -54
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +0 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +0 -6
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +0 -16
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +0 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +0 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +0 -9
- package/lib-prod/helpers/class-helpers.ts +0 -315
- package/lib-prod/helpers/clone-obj.ts +0 -24
- package/lib-prod/helpers/taon-helpers.ts +0 -181
- package/lib-prod/index.ts +0 -323
- package/lib-prod/lib-info.md +0 -8
- package/lib-prod/migrations/index.ts +0 -2
- package/lib-prod/migrations/migrations-info.md +0 -6
- package/lib-prod/models.ts +0 -427
- package/lib-prod/orm/columns.ts +0 -121
- package/lib-prod/orm/index.ts +0 -62
- package/lib-prod/realtime/realtime-client.ts +0 -288
- package/lib-prod/realtime/realtime-core.ts +0 -134
- package/lib-prod/realtime/realtime-server.ts +0 -398
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +0 -344
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +0 -349
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +0 -30
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +0 -21
- package/lib-prod/realtime/realtime-subs-manager.ts +0 -127
- package/lib-prod/realtime/realtime.models.ts +0 -33
- package/lib-prod/symbols.ts +0 -136
- package/lib-prod/ui/index.ts +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.ts +0 -1
- package/lib-prod/validators.ts +0 -103
- /package/lib-prod/env/{index.ts → index.js} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TaonRepository } from '../decorators/classes/repository-decorator';
|
|
2
|
+
import { TaonBaseInjector } from './base-injector';
|
|
3
|
+
//#endregion
|
|
4
|
+
let TaonBaseCustomRepository = class TaonBaseCustomRepository extends TaonBaseInjector {
|
|
5
|
+
};
|
|
6
|
+
TaonBaseCustomRepository = __decorate([
|
|
7
|
+
TaonRepository({ className: 'TaonBaseCustomRepository' })
|
|
8
|
+
], TaonBaseCustomRepository);
|
|
9
|
+
export { TaonBaseCustomRepository };
|
|
@@ -2,35 +2,26 @@
|
|
|
2
2
|
// //#region imports
|
|
3
3
|
// import * as childProcess from 'child_process';
|
|
4
4
|
// import * as fs from 'fs';
|
|
5
|
-
|
|
6
5
|
// import { Injectable } from '@angular/core';
|
|
7
6
|
// import { ipcRenderer, webFrame } from 'electron';
|
|
8
7
|
// import { UtilsOs } from 'tnp-core/src';
|
|
9
8
|
// //#endregion
|
|
10
|
-
|
|
11
9
|
// // If you import a module but never use any of the imported values other than as TypeScript types,
|
|
12
10
|
// // the resulting javascript file will look as if you never imported the module at all.
|
|
13
|
-
|
|
14
11
|
// @Injectable({
|
|
15
12
|
// providedIn: 'root',
|
|
16
13
|
// })
|
|
17
14
|
// export class TaonBaseElectronService {
|
|
18
15
|
// ipcRenderer!: typeof ipcRenderer;
|
|
19
|
-
|
|
20
16
|
// webFrame!: typeof webFrame;
|
|
21
|
-
|
|
22
17
|
// childProcess!: typeof childProcess;
|
|
23
|
-
|
|
24
18
|
// fs!: typeof fs;
|
|
25
|
-
|
|
26
19
|
// constructor() {
|
|
27
20
|
// // Conditional imports
|
|
28
21
|
// if (UtilsOs.isElectron) {
|
|
29
22
|
// this.ipcRenderer = (window as any).require('electron').ipcRenderer;
|
|
30
23
|
// this.webFrame = (window as any).require('electron').webFrame;
|
|
31
|
-
|
|
32
24
|
// this.fs = (window as any).require('fs');
|
|
33
|
-
|
|
34
25
|
// this.childProcess = (window as any).require('child_process');
|
|
35
26
|
// this.childProcess.exec('node -v', (error, stdout, stderr) => {
|
|
36
27
|
// if (error) {
|
|
@@ -43,7 +34,6 @@
|
|
|
43
34
|
// }
|
|
44
35
|
// console.log(`stdout:\n${stdout}`);
|
|
45
36
|
// });
|
|
46
|
-
|
|
47
37
|
// // Notes :
|
|
48
38
|
// // * A NodeJS's dependency imported with 'window.require' MUST BE present in `dependencies` of both `app/package.json`
|
|
49
39
|
// // and `package.json (root folder)` in order to make it work here in Electron's Renderer process (src folder)
|
|
@@ -51,10 +41,9 @@
|
|
|
51
41
|
// // * A NodeJS's dependency imported with TS module import (ex: import { Dropbox } from 'dropbox') CAN only be present
|
|
52
42
|
// // in `dependencies` of `package.json (root folder)` because it is loaded during build phase and does not need to be
|
|
53
43
|
// // in the final bundle. Reminder : only if not used in Electron's Main process (app folder)
|
|
54
|
-
|
|
55
44
|
// // If you want to use a NodeJS 3rd party deps in Renderer process,
|
|
56
45
|
// // ipcRenderer.invoke can serve many common use cases.
|
|
57
46
|
// // https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args
|
|
58
47
|
// }
|
|
59
48
|
// }
|
|
60
|
-
// }
|
|
49
|
+
// }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Entity } from 'taon-typeorm/lib-prod'; // @websql
|
|
2
|
+
import { TaonBaseClass } from './base-class';
|
|
3
|
+
//#region @websql
|
|
4
|
+
let TaonBaseEntity = class TaonBaseEntity extends TaonBaseClass {
|
|
5
|
+
/**
|
|
6
|
+
* simple check if relation is ok
|
|
7
|
+
*/
|
|
8
|
+
relation(relationName) {
|
|
9
|
+
return relationName;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* simple check if relation is ok
|
|
13
|
+
*/
|
|
14
|
+
relations(relationNames) {
|
|
15
|
+
return relationNames;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
TaonBaseEntity = __decorate([
|
|
19
|
+
Entity()
|
|
20
|
+
//#endregion
|
|
21
|
+
], TaonBaseEntity);
|
|
22
|
+
export { TaonBaseEntity };
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
TaonBaseFileUploadMiddleware = __decorate([
|
|
71
|
+
TaonMiddleware({
|
|
72
|
+
className: 'TaonBaseFileUploadMiddleware',
|
|
73
|
+
})
|
|
74
|
+
], TaonBaseFileUploadMiddleware);
|
|
75
|
+
export { TaonBaseFileUploadMiddleware };
|
|
@@ -0,0 +1,184 @@
|
|
|
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 });
|
|
85
|
+
}
|
|
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)}".
|
|
140
|
+
|
|
141
|
+
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
142
|
+
|
|
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)}".
|
|
173
|
+
|
|
174
|
+
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
175
|
+
|
|
176
|
+
`);
|
|
177
|
+
}
|
|
178
|
+
instance[propName] = value;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TaonBaseInjector } from './base-injector';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* TODO
|
|
5
4
|
* - global provider available in all contexts
|
|
6
5
|
* - provider available in own context
|
|
7
6
|
*/
|
|
8
|
-
export class TaonBaseProvider extends TaonBaseInjector {
|
|
7
|
+
export class TaonBaseProvider extends TaonBaseInjector {
|
|
8
|
+
}
|