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.
Files changed (115) hide show
  1. package/bin/taon +5 -5
  2. package/bin/taon-debug +5 -5
  3. package/bin/taon-debug-brk +4 -4
  4. package/browser/package.json +1 -1
  5. package/browser-prod/package.json +1 -1
  6. package/icon-menu-taon.svg +15 -15
  7. package/lib/build-info._auto-generated_.d.ts +1 -1
  8. package/lib/build-info._auto-generated_.js +1 -1
  9. package/lib/package.json +1 -1
  10. package/lib/ui/index.js +2 -2
  11. package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
  12. package/lib-prod/base-classes/base-abstract-entity.js +17 -31
  13. package/lib-prod/base-classes/base-angular-service.js +83 -55
  14. package/lib-prod/base-classes/base-class.js +33 -35
  15. package/lib-prod/base-classes/base-context.js +17 -19
  16. package/lib-prod/base-classes/base-controller.js +146 -154
  17. package/lib-prod/base-classes/base-crud-controller.js +250 -221
  18. package/lib-prod/base-classes/base-custom-repository.js +7 -18
  19. package/lib-prod/base-classes/base-electron-service.js +49 -0
  20. package/lib-prod/base-classes/base-entity.js +20 -30
  21. package/lib-prod/base-classes/base-file-upload.middleware.js +72 -75
  22. package/lib-prod/base-classes/base-injector.js +176 -194
  23. package/lib-prod/base-classes/base-middleware.js +8 -5
  24. package/lib-prod/base-classes/base-migration.js +19 -22
  25. package/lib-prod/base-classes/base-provider.js +7 -5
  26. package/lib-prod/base-classes/base-repository.js +601 -573
  27. package/lib-prod/base-classes/base-subscriber-for-entity.js +143 -152
  28. package/lib-prod/base-classes/base.js +18 -0
  29. package/lib-prod/build-info._auto-generated_.js +26 -14
  30. package/lib-prod/config/controller-config.js +24 -24
  31. package/lib-prod/config/controller-options.js +2 -5
  32. package/lib-prod/config/method-config.js +6 -8
  33. package/lib-prod/config/param-config.js +2 -8
  34. package/lib-prod/constants.js +29 -25
  35. package/lib-prod/context-db-migrations.js +328 -324
  36. package/lib-prod/create-context.js +211 -146
  37. package/lib-prod/decorators/classes/controller-decorator.js +16 -20
  38. package/lib-prod/decorators/classes/entity-decorator.js +26 -47
  39. package/lib-prod/decorators/classes/middleware-decorator.js +14 -24
  40. package/lib-prod/decorators/classes/migration-decorator.js +13 -22
  41. package/lib-prod/decorators/classes/provider-decorator.js +13 -23
  42. package/lib-prod/decorators/classes/repository-decorator.js +13 -22
  43. package/lib-prod/decorators/classes/subscriber-decorator.js +13 -23
  44. package/lib-prod/decorators/decorator-abstract-opt.js +1 -4
  45. package/lib-prod/decorators/http/http-decorators.js +20 -5
  46. package/lib-prod/decorators/http/http-methods-decorators.js +91 -133
  47. package/lib-prod/decorators/http/http-params-decorators.js +36 -62
  48. package/lib-prod/dependency-injection/di-container.js +28 -29
  49. package/lib-prod/endpoint-context-storage.js +27 -32
  50. package/lib-prod/endpoint-context.js +2294 -1930
  51. package/lib-prod/entity-process.js +209 -198
  52. package/lib-prod/env/env.angular-node-app.js +66 -130
  53. package/lib-prod/env/env.docs-webapp.js +66 -130
  54. package/lib-prod/env/env.electron-app.js +66 -130
  55. package/lib-prod/env/env.mobile-app.js +66 -130
  56. package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
  57. package/lib-prod/env/env.vscode-plugin.js +66 -130
  58. package/lib-prod/env/index.js +6 -6
  59. package/lib-prod/express-types.js +1 -0
  60. package/lib-prod/formly/formly.models.js +1 -0
  61. package/lib-prod/formly/fromly.js +196 -175
  62. package/lib-prod/formly/type-from-entity.js +45 -52
  63. package/lib-prod/get-response-value.js +21 -18
  64. package/lib-prod/global-state/taon-global-state/index.js +6 -5
  65. package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +18 -19
  66. package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +6 -9
  67. package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +40 -46
  68. package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +33 -46
  69. package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +10 -20
  70. package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +43 -33
  71. package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +10 -20
  72. package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +43 -44
  73. package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +20 -27
  74. package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +10 -10
  75. package/lib-prod/global-state/taon-transaction-registry/index.js +11 -10
  76. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +20 -21
  77. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +4 -7
  78. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +34 -39
  79. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +34 -54
  80. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +10 -20
  81. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -10
  82. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +10 -20
  83. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +29 -34
  84. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +20 -27
  85. package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +4 -5
  86. package/lib-prod/helpers/class-helpers.js +210 -177
  87. package/lib-prod/helpers/clone-obj.js +16 -20
  88. package/lib-prod/helpers/taon-helpers.js +132 -114
  89. package/lib-prod/index._auto-generated_.js +5 -0
  90. package/lib-prod/index.js +248 -227
  91. package/lib-prod/inject.js +88 -33
  92. package/lib-prod/migrations/index.js +2 -1
  93. package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
  94. package/lib-prod/models.js +72 -103
  95. package/lib-prod/orm/columns.js +58 -118
  96. package/lib-prod/orm/index.js +56 -1
  97. package/lib-prod/package.json +1 -1
  98. package/lib-prod/realtime/realtime-client.js +188 -186
  99. package/lib-prod/realtime/realtime-core.js +77 -78
  100. package/lib-prod/realtime/realtime-server.js +225 -240
  101. package/lib-prod/realtime/realtime-strategy/index.js +4 -4
  102. package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +273 -219
  103. package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +267 -240
  104. package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +26 -20
  105. package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +10 -13
  106. package/lib-prod/realtime/realtime-subs-manager.js +82 -90
  107. package/lib-prod/realtime/realtime.models.js +2 -0
  108. package/lib-prod/symbols.js +104 -105
  109. package/lib-prod/ui/index.js +1 -5
  110. package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -5
  111. package/lib-prod/validators.js +43 -37
  112. package/lib-prod.split-namespaces.json +32 -86
  113. package/package.json +1 -1
  114. package/websql/package.json +1 -1
  115. package/websql-prod/package.json +1 -1
@@ -1,78 +1,75 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
11
- import * as crypto from "crypto";
12
- import * as multer from "multer";
13
- import { crossPlatformPath, fse, path } from "tnp-core/lib-prod";
14
- import { TaonMiddleware } from "../decorators/classes/middleware-decorator";
15
- import {
16
- TaonBaseMiddleware
17
- } from "./base-middleware";
18
- let TaonBaseFileUploadMiddleware = class extends TaonBaseMiddleware {
19
- async interceptServerMethod({ req, res, next }, { methodName, expressPath }) {
20
- return this.middleware()(req, res, next);
21
- }
22
- //#region upload Dir
23
- uploadDir() {
24
- return crossPlatformPath([this.ctx.cwd, "uploaded-files"]);
25
- }
26
- //#endregion
27
- //#region storage
28
- storage() {
29
- const uploadDir = this.uploadDir();
30
- if (!fse.existsSync(uploadDir)) {
31
- try {
32
- fse.mkdirSync(uploadDir, { recursive: true });
33
- } catch (error) {
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 = __decorateClass([
72
- TaonMiddleware({
73
- className: "TaonBaseFileUploadMiddleware"
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 "../helpers/class-helpers";
2
- import { Symbols__NS__ctxInClassOrClassObj } from "../symbols";
3
- class TaonBaseInjector {
4
- //#region proxy dummy function
5
- /**
6
- * for proxy purposes
7
- */
8
- getOriginalPrototype;
9
- /**
10
- * for proxy purposes
11
- */
12
- getOriginalConstructor;
13
- //#endregion
14
- //#region class initialization hook
15
- /**
16
- * class initialization hook
17
- * taon after class instace creation
18
- */
19
- async _() {
20
- }
21
- //#endregion
22
- //#region context
23
- /**
24
- * @deprecated use ctx instead
25
- * Current endpoint context
26
- */
27
- get __endpoint_context__() {
28
- return this[Symbols__NS__ctxInClassOrClassObj];
29
- }
30
- /**
31
- * get current endpoint context
32
- */
33
- get ctx() {
34
- return this.__endpoint_context__;
35
- }
36
- //#endregion
37
- //#region inject
38
- //#region inject / repo for entity
39
- /**
40
- * inject crud repo for entity
41
- */
42
- injectRepo(entityForCrud) {
43
- const repoProxy = this.__inject(void 0, {
44
- localInstance: true,
45
- resolveClassFromContext: "TaonBaseRepository",
46
- locaInstanceConstructorArgs: [() => entityForCrud]
47
- });
48
- return repoProxy;
49
- }
50
- //#endregion
51
- //#region inject / custom repository
52
- injectCustomRepository(cutomRepositoryClass) {
53
- const repoProxy = this.__inject(cutomRepositoryClass, {
54
- localInstance: true,
55
- locaInstanceConstructorArgs: [
56
- () => {
57
- const classToProcess = this.ctx.allClassesInstances[ClassHelpers__NS__getName(cutomRepositoryClass)];
58
- return classToProcess.entityClassResolveFn();
59
- }
60
- ]
61
- });
62
- return repoProxy;
63
- }
64
- //#endregion
65
- //#region inject / custom repo
66
- /**
67
- * aliast to this.injectRepository()
68
- */
69
- injectCustomRepo(cutomRepositoryClass) {
70
- const repoProxy = this.injectCustomRepository(cutomRepositoryClass);
71
- return repoProxy;
72
- }
73
- //#endregion
74
- //#region inject / controller
75
- /**
76
- * example usage:
77
- * ...
78
- * exampleController = this.injectController(ExampleController);
79
- * ...
80
- */
81
- injectController(ctor) {
82
- return this.__inject(ctor, { localInstance: false });
83
- }
84
- //#endregion
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
- const contextClassInstance = this;
130
- return new Proxy(
131
- {},
132
- {
133
- get: (__, propName) => {
134
- const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
135
- const resultContext = contextFromClass ? contextFromClass : this.__endpoint_context__;
136
- if (options.resolveClassFromContext) {
137
- const resolvedClass = resultContext.getClassFunByClassName(
138
- options.resolveClassFromContext
139
- );
140
- ctor = resolvedClass;
141
- }
142
- if (resultContext) {
143
- var instance = resultContext.inject(ctor, {
144
- ...options,
145
- contextClassInstance,
146
- parentInstanceThatWillGetInjectedStuff: this
147
- });
148
- if (!instance) {
149
- throw new Error(
150
- `Not able to inject "${ClassHelpers__NS__getName(ctor) || ctor.name}" inside property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(
151
- this
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
- const result = typeof instance[propName] === "function" ? instance[propName].bind(instance) : instance[propName];
160
- return result;
161
- }
162
- },
163
- set: (__, propName, value) => {
164
- const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
165
- const resultContext = contextFromClass ? contextFromClass : this.__endpoint_context__;
166
- if (options.resolveClassFromContext) {
167
- const resolvedClass = resultContext.getClassFunByClassName(
168
- options.resolveClassFromContext
169
- );
170
- ctor = resolvedClass;
171
- }
172
- if (resultContext) {
173
- var instance = resultContext.inject(ctor, {
174
- ...options,
175
- contextClassInstance,
176
- parentInstanceThatWillGetInjectedStuff: this
177
- });
178
- if (!instance) {
179
- const classNameNotResolved = ClassHelpers__NS__getName(ctor) || ctor.name;
180
- throw new Error(
181
- `Not able to inject "${classNameNotResolved}" inside property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(
182
- this
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
- instance[propName] = value;
191
- }
192
- return true;
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 "./base-injector";
2
- class TaonBaseMiddleware extends TaonBaseInjector {
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 "tnp-core/lib-prod";
2
- import { ClassHelpers__NS__getName } from "../helpers/class-helpers";
3
- import { TaonBaseInjector } from "./base-injector";
4
- 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
- }
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 "./base-injector";
2
- class TaonBaseProvider extends TaonBaseInjector {
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
- };