taon 21.0.28 → 21.0.32
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/fesm2022/taon-browser.mjs +2 -14
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +73 -75
- package/browser-prod/fesm2022/taon-browser.mjs +770 -788
- package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
- package/browser-prod/package.json +23 -0
- package/browser-prod/types/taon-browser.d.ts +493 -513
- package/browser-prod.split-namespaces.json +186 -0
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-controller.d.ts +2 -1
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/decorators/http/http-decorators.d.ts +2 -1
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/decorators/http/http-params-decorators.js.map +1 -1
- package/lib/endpoint-context.d.ts +2 -1
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +2 -3
- package/lib/models.js +0 -7
- package/lib/models.js.map +1 -1
- package/lib/package.json +4 -0
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-class.js +1 -1
- package/lib-prod/base-classes/base-class.js.map +1 -1
- package/lib-prod/base-classes/base-context.d.ts +1 -1
- package/lib-prod/base-classes/base-controller.d.ts +5 -4
- package/lib-prod/base-classes/base-controller.js +2 -2
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.d.ts +13 -13
- package/lib-prod/base-classes/base-crud-controller.js +8 -9
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-injector.js +11 -11
- package/lib-prod/base-classes/base-injector.js.map +1 -1
- package/lib-prod/base-classes/base-middleware.d.ts +2 -2
- package/lib-prod/base-classes/base-migration.js +3 -3
- package/lib-prod/base-classes/base-migration.js.map +1 -1
- package/lib-prod/base-classes/base-repository.js +4 -4
- package/lib-prod/base-classes/base-repository.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/config/method-config.d.ts +2 -2
- package/lib-prod/config/param-config.d.ts +2 -2
- package/lib-prod/context-db-migrations.js +12 -12
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.d.ts +5 -5
- package/lib-prod/create-context.js +3 -3
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/controller-decorator.js +3 -3
- package/lib-prod/decorators/classes/controller-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.d.ts +3 -3
- package/lib-prod/decorators/classes/entity-decorator.js +5 -5
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/middleware-decorator.js +3 -3
- package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/migration-decorator.js +3 -3
- package/lib-prod/decorators/classes/migration-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/provider-decorator.js +3 -3
- package/lib-prod/decorators/classes/provider-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/repository-decorator.js +3 -3
- package/lib-prod/decorators/classes/repository-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/subscriber-decorator.js +3 -3
- package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib-prod/decorators/http/http-decorators.d.ts +3 -2
- package/lib-prod/decorators/http/http-decorators.js +2 -2
- package/lib-prod/decorators/http/http-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.d.ts +5 -5
- package/lib-prod/decorators/http/http-methods-decorators.js +2 -2
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-params-decorators.js +1 -1
- package/lib-prod/decorators/http/http-params-decorators.js.map +1 -1
- package/lib-prod/endpoint-context-storage.js +1 -1
- package/lib-prod/endpoint-context-storage.js.map +1 -1
- package/lib-prod/endpoint-context.d.ts +14 -13
- package/lib-prod/endpoint-context.js +171 -171
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.js +14 -14
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/formly/fromly.d.ts +2 -2
- package/lib-prod/formly/fromly.js +1 -1
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/formly/type-from-entity.js +2 -2
- package/lib-prod/formly/type-from-entity.js.map +1 -1
- package/lib-prod/get-response-value.d.ts +2 -2
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.d.ts +3 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.d.ts +1 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +12 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +2 -2
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +1 -3
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +6 -8
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -1
- package/lib-prod/helpers/class-helpers.d.ts +20 -22
- package/lib-prod/helpers/class-helpers.js +231 -218
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.d.ts +14 -16
- package/lib-prod/helpers/taon-helpers.js +148 -138
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.d.ts +80 -84
- package/lib-prod/index.js +71 -70
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/inject.js +3 -3
- package/lib-prod/inject.js.map +1 -1
- package/lib-prod/models.d.ts +242 -247
- package/lib-prod/models.js +83 -91
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/package.json +4 -0
- package/lib-prod/realtime/realtime-client.d.ts +2 -2
- package/lib-prod/realtime/realtime-client.js +9 -9
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +17 -17
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +3 -3
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +2 -2
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +2 -2
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.d.ts +2 -2
- package/lib-prod/realtime/realtime-subs-manager.js +6 -6
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/realtime/realtime.models.d.ts +23 -25
- package/lib-prod/realtime/realtime.models.js +1 -0
- package/lib-prod/realtime/realtime.models.js.map +1 -1
- package/lib-prod/symbols.d.ts +39 -41
- package/lib-prod/symbols.js +44 -45
- package/lib-prod/symbols.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +2 -2
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/validators.d.ts +4 -6
- package/lib-prod/validators.js +50 -47
- package/lib-prod/validators.js.map +1 -1
- package/lib-prod.split-namespaces.json +188 -0
- package/package.json +18 -12
- package/websql/fesm2022/taon-websql.mjs +2 -10
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +73 -75
- package/websql-prod/fesm2022/taon-websql.mjs +855 -870
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +23 -0
- package/websql-prod/types/taon-websql.d.ts +496 -516
- package/websql-prod.split-namespaces.json +188 -0
- package/migrations/index.d.ts +0 -1
- package/migrations/index.js +0 -19
- package/migrations/index.js.map +0 -1
- package/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/migrations/migrations_index._auto-generated_.js +0 -4
- package/migrations/migrations_index._auto-generated_.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/websql-prod';
|
|
3
|
-
import { _,
|
|
3
|
+
import { _, Utils_uniqArray, UtilsMigrations_isValidTimestamp, Helpers, UtilsMigrations_getTimestampFromClassName, UtilsOs_isRunningInDocker, UtilsOs_isElectron, crossPlatformPath, config, CoreModels_SPECIAL_APP_READY_MESSAGE, UtilsOs_isRunningInCliMode, UtilsTerminal_waitMilliseconds, CoreModels_TaonHttpErrorCustomProp } from 'tnp-core/websql-prod';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { JSON10 } from 'json10/websql-prod';
|
|
6
6
|
import { walk } from 'lodash-walk-object/websql-prod';
|
|
7
|
-
import { RestResponseWrapper,
|
|
7
|
+
import { RestResponseWrapper, Resource, Models_HttpResponse, RestHeaders, Mapping_decode, Mapping_DefaultModelWithMapping, HttpResponseError, Mapping_getModelsMapping } from 'ng2-rest/websql-prod';
|
|
8
8
|
import { Observable, Subject, from } from 'rxjs';
|
|
9
9
|
import { OrignalClassKey, Table, TableIndex, EventSubscriber, Entity, DataSource, Column, PrimaryGeneratedColumn, VersionColumn, CreateDateColumn } from 'taon-typeorm/websql-prod';
|
|
10
10
|
export { AfterInsert, AfterLoad, AfterRecover, AfterRemove, AfterSoftRemove, AfterUpdate, BeforeInsert, BeforeRecover, BeforeRemove, BeforeSoftRemove, BeforeUpdate, Column, Connection, CreateDateColumn, Column as CustomColumn, DeleteDateColumn, Generated, Generated as GeneratedColumn, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Repository, TreeChildren, TreeParent, UpdateDateColumn, VersionColumn, VirtualColumn } from 'taon-typeorm/websql-prod';
|
|
@@ -74,68 +74,58 @@ const BaseTaonClassesNames = [
|
|
|
74
74
|
];
|
|
75
75
|
const TaonTempDatabasesFolder = 'databases';
|
|
76
76
|
const TaonTempRoutesFolder = 'routes';
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
77
|
+
//namespace Models
|
|
78
|
+
const Models_DatabasesFolder = TaonTempDatabasesFolder;
|
|
79
|
+
//#region models / class types
|
|
80
|
+
var Models_ClassType;
|
|
81
|
+
(function (Models_ClassType) {
|
|
82
|
+
Models_ClassType["ENTITY"] = "ENTITY";
|
|
83
|
+
Models_ClassType["CONTROLLER"] = "CONTROLLER";
|
|
84
|
+
Models_ClassType["REPOSITORY"] = "REPOSITORY";
|
|
85
|
+
Models_ClassType["PROVIDER"] = "PROVIDER";
|
|
86
|
+
Models_ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
87
|
+
Models_ClassType["MIGRATION"] = "MIGRATION";
|
|
88
|
+
Models_ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
89
|
+
})(Models_ClassType || (Models_ClassType = {}));
|
|
90
|
+
const Models_ClassTypeKey = {
|
|
91
|
+
[Models_ClassType.ENTITY]: 'entities',
|
|
92
|
+
[Models_ClassType.CONTROLLER]: 'controllers',
|
|
93
|
+
[Models_ClassType.REPOSITORY]: 'repositories',
|
|
94
|
+
[Models_ClassType.PROVIDER]: 'providers',
|
|
95
|
+
[Models_ClassType.SUBSCRIBER]: 'subscribers',
|
|
96
|
+
[Models_ClassType.MIGRATION]: 'migrations',
|
|
97
|
+
[Models_ClassType.MIDDLEWARE]: 'middlewares',
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region models / database connection options
|
|
101
|
+
class Models_DatabaseConfigTypeOrm {
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region models / database config
|
|
105
|
+
class Models_DatabaseConfig extends Models_DatabaseConfigTypeOrm {
|
|
106
|
+
static from(databasePartialConfig) {
|
|
107
|
+
return _.merge(new Models_DatabaseConfig(), databasePartialConfig);
|
|
103
108
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (result.recreateMode === 'DROP_DB+MIGRATIONS') {
|
|
116
|
-
result.synchronize = true;
|
|
117
|
-
result.dropSchema = true;
|
|
118
|
-
}
|
|
119
|
-
else if (result.recreateMode === 'PRESERVE_DATA+MIGRATIONS') {
|
|
120
|
-
result.synchronize = false;
|
|
121
|
-
result.dropSchema = false;
|
|
122
|
-
}
|
|
109
|
+
get databaseConfigTypeORM() {
|
|
110
|
+
//#region @websqlFunc
|
|
111
|
+
const result = _.cloneDeep(this);
|
|
112
|
+
if (result.recreateMode) {
|
|
113
|
+
if (result.recreateMode === 'DROP_DB+MIGRATIONS') {
|
|
114
|
+
result.synchronize = true;
|
|
115
|
+
result.dropSchema = true;
|
|
116
|
+
}
|
|
117
|
+
else if (result.recreateMode === 'PRESERVE_DATA+MIGRATIONS') {
|
|
118
|
+
result.synchronize = false;
|
|
119
|
+
result.dropSchema = false;
|
|
123
120
|
}
|
|
124
|
-
delete result.recreateMode;
|
|
125
|
-
return result;
|
|
126
|
-
//#endregion
|
|
127
121
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region models / http
|
|
132
|
-
let Http;
|
|
133
|
-
(function (Http) {
|
|
134
|
-
Http.Rest = Models$1;
|
|
122
|
+
delete result.recreateMode;
|
|
123
|
+
return result;
|
|
135
124
|
//#endregion
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//end of namespace Models
|
|
139
129
|
|
|
140
130
|
class DecoratorAbstractOpt {
|
|
141
131
|
}
|
|
@@ -233,59 +223,57 @@ class Realtime {
|
|
|
233
223
|
return `${contextName}:${this.KEYroomUnsubscribe}EntityPropertyEvents`;
|
|
234
224
|
}
|
|
235
225
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
})(Symbols || (Symbols = {}));
|
|
226
|
+
//namespace Symbols
|
|
227
|
+
const Symbols_ctxInClassOrClassObj = Symbol();
|
|
228
|
+
const Symbols_classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
229
|
+
const Symbols_fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
230
|
+
const Symbols_orignalClass = OrignalClassKey;
|
|
231
|
+
const Symbols_orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
232
|
+
const Symbols_classMethodsNames = `$$classMethodsNames$$`;
|
|
233
|
+
const Symbols_REALTIME = new Realtime();
|
|
234
|
+
const Symbols_metadata = {
|
|
235
|
+
className: `class:realname`,
|
|
236
|
+
options: {
|
|
237
|
+
controller: `controller:options`,
|
|
238
|
+
entity: `entity:options`,
|
|
239
|
+
repository: `repository:options`,
|
|
240
|
+
provider: `provider:options`,
|
|
241
|
+
subscriber: `subscriber:options`,
|
|
242
|
+
migration: `migration:options`,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
const Symbols_old = {
|
|
246
|
+
HAS_TABLE_IN_DB: Symbol(),
|
|
247
|
+
MDC_KEY: `modeldataconfig`,
|
|
248
|
+
WEBSQL_REST_PROGRESS_FUN: Symbol(),
|
|
249
|
+
WEBSQL_REST_PROGRESS_FUN_START: Symbol(),
|
|
250
|
+
WEBSQL_REST_PROGRESS_FUN_DONE: Symbol(),
|
|
251
|
+
WEBSQL_REST_PROGRESS_TIMEOUT: Symbol(),
|
|
252
|
+
X_TOTAL_COUNT: `x-total-count`,
|
|
253
|
+
CIRCURAL_OBJECTS_MAP_BODY: `circuralmapbody`,
|
|
254
|
+
CIRCURAL_OBJECTS_MAP_QUERY_PARAM: `circuralmapbody`,
|
|
255
|
+
MAPPING_CONFIG_HEADER: `mappingheader`,
|
|
256
|
+
MAPPING_CONFIG_HEADER_BODY_PARAMS: `mhbodyparams`,
|
|
257
|
+
MAPPING_CONFIG_HEADER_QUERY_PARAMS: `mhqueryparams`,
|
|
258
|
+
ENDPOINT_META_CONFIG: `ng2_rest_endpoint_config`,
|
|
259
|
+
CLASS_DECORATOR_CONTEXT: `$$ng2_rest_class_context`,
|
|
260
|
+
SOCKET_MSG: `socketmessageng2rest`,
|
|
261
|
+
ANGULAR: {
|
|
262
|
+
INPUT_NAMES: Symbol(),
|
|
263
|
+
},
|
|
264
|
+
ERROR_MESSAGES: {
|
|
265
|
+
CLASS_NAME_MATCH: `Please check if your "class name" matches @Controller( className ) or @Entity( className )`,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
//end of namespace Symbols
|
|
280
269
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
throw `[Taon]
|
|
270
|
+
//namespace Validators
|
|
271
|
+
//#region vlidate class name
|
|
272
|
+
const Validators_classNameVlidation = (className, target) => {
|
|
273
|
+
setTimeout(() => {
|
|
274
|
+
// console.log(`check after timeout ${className} , production mode: ${FrameworkContext.isProductionMode}`)
|
|
275
|
+
if (_.isUndefined(className)) {
|
|
276
|
+
throw `[Taon]
|
|
289
277
|
Please provide "className" property for each Controller and Entity:
|
|
290
278
|
|
|
291
279
|
@Taon.Controller({ className: 'MyExampleCtrl' })
|
|
@@ -302,21 +290,21 @@ var Validators;
|
|
|
302
290
|
Functions/Classes names -this is only solution to preserve classes names.
|
|
303
291
|
|
|
304
292
|
`;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
return _.isUndefined(className) ? target.name : className;
|
|
308
|
-
};
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region validate method config
|
|
311
|
-
Validators.checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
312
|
-
const defaultResponseType = 'text or JSON';
|
|
313
|
-
if (!current.responseType) {
|
|
314
|
-
return;
|
|
315
293
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
294
|
+
});
|
|
295
|
+
return _.isUndefined(className) ? target.name : className;
|
|
296
|
+
};
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region validate method config
|
|
299
|
+
const Validators_checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
300
|
+
const defaultResponseType = 'text or JSON';
|
|
301
|
+
if (!current.responseType) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
for (let index = 0; index < methods.length; index++) {
|
|
305
|
+
const m = methods[index];
|
|
306
|
+
if (m.path === current.path && m.responseType !== current.responseType) {
|
|
307
|
+
throw new Error(`
|
|
320
308
|
[taon] you can have 2 methods with same path but differetn reponseType-s
|
|
321
309
|
|
|
322
310
|
${m.methodName}( ... path: ${m.path} ) -> responseType: ${m.responseType || defaultResponseType}
|
|
@@ -325,264 +313,263 @@ var Validators;
|
|
|
325
313
|
Please change path name on of the methods.
|
|
326
314
|
|
|
327
315
|
`);
|
|
328
|
-
}
|
|
329
316
|
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region validate class functions
|
|
321
|
+
// TODO
|
|
322
|
+
const Validators_validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
323
|
+
if (_.isArray(controllers) &&
|
|
324
|
+
controllers.filter(f => !_.isFunction(f)).length > 0) {
|
|
325
|
+
console.error('controllers', controllers);
|
|
326
|
+
throw `
|
|
339
327
|
|
|
340
328
|
Incorect value for property "controllers" inside Taon.Init(...)
|
|
341
329
|
|
|
342
330
|
`;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
331
|
+
}
|
|
332
|
+
if (_.isArray(entities) &&
|
|
333
|
+
entities.filter(f => !_.isFunction(f)).length > 0) {
|
|
334
|
+
console.error('entites', entities);
|
|
335
|
+
throw `
|
|
348
336
|
|
|
349
337
|
Incorect value for property "entities" inside Taon.Init(...)
|
|
350
338
|
|
|
351
339
|
`;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
343
|
+
const Validators_preventUndefinedModel = (model, id) => {
|
|
344
|
+
if (_.isUndefined(model)) {
|
|
345
|
+
throw `Bad update by id, config, id: ${id}`;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
//end of namespace Validators
|
|
361
349
|
|
|
362
350
|
//#region imports
|
|
363
351
|
/* */
|
|
364
352
|
//#endregion
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
parameters: { ...v.parameters }, // shallow clone parameters too
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
cfg = {
|
|
562
|
-
...parentCfg,
|
|
563
|
-
methods: clonedMethods,
|
|
353
|
+
//namespace ClassHelpers
|
|
354
|
+
//#region get class from name
|
|
355
|
+
/**
|
|
356
|
+
* TODO - repalce in every place when getting class fn from object
|
|
357
|
+
*/
|
|
358
|
+
const ClassHelpers_getClassFnFromObject = (json) => {
|
|
359
|
+
if (_.isUndefined(json) || _.isNull(json)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (json.constructor) {
|
|
363
|
+
return json.constructor;
|
|
364
|
+
}
|
|
365
|
+
const p = Object.getPrototypeOf(json);
|
|
366
|
+
return p && p.constructor && p.constructor.name !== 'Object'
|
|
367
|
+
? p.constructor
|
|
368
|
+
: void 0;
|
|
369
|
+
};
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region get name
|
|
372
|
+
const ClassHelpers_getName = (classFnOrObject) => {
|
|
373
|
+
// exception for FormData
|
|
374
|
+
if (classFnOrObject instanceof FormData) {
|
|
375
|
+
return 'FormData';
|
|
376
|
+
}
|
|
377
|
+
if (!classFnOrObject) {
|
|
378
|
+
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
379
|
+
throw new Error(`Cannot get name from this object or class.`);
|
|
380
|
+
}
|
|
381
|
+
return ((classFnOrObject[Symbols_classNameStaticProperty]
|
|
382
|
+
? classFnOrObject[Symbols_classNameStaticProperty]
|
|
383
|
+
: classFnOrObject?.constructor[Symbols_classNameStaticProperty]) ||
|
|
384
|
+
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
385
|
+
};
|
|
386
|
+
//#endregion
|
|
387
|
+
const ClassHelpers_getOrginalClass = (classFnOrObject) => {
|
|
388
|
+
const org = classFnOrObject[Symbols_orignalClass];
|
|
389
|
+
if (!org) {
|
|
390
|
+
return classFnOrObject;
|
|
391
|
+
}
|
|
392
|
+
return ClassHelpers_getOrginalClass(org);
|
|
393
|
+
};
|
|
394
|
+
//#region get full internal name
|
|
395
|
+
const ClassHelpers_getFullInternalName = (classFnOrObject) => {
|
|
396
|
+
// exception for FormData
|
|
397
|
+
if (!classFnOrObject) {
|
|
398
|
+
throw new Error(`Cannot get name from: ${classFnOrObject}`);
|
|
399
|
+
}
|
|
400
|
+
return ((classFnOrObject[Symbols_fullClassNameStaticProperty]
|
|
401
|
+
? classFnOrObject[Symbols_fullClassNameStaticProperty]
|
|
402
|
+
: classFnOrObject?.constructor[Symbols_fullClassNameStaticProperty]) ||
|
|
403
|
+
void 0);
|
|
404
|
+
};
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region get unique key
|
|
407
|
+
const ClassHelpers_getUniqueKey = (classFnOrObject) => {
|
|
408
|
+
const classFn = _.isFunction(classFnOrObject)
|
|
409
|
+
? classFnOrObject
|
|
410
|
+
: classFnOrObject.constructor;
|
|
411
|
+
const config = Reflect.getMetadata(Symbols_metadata.options.entity, classFn);
|
|
412
|
+
return config.uniqueKeyProp;
|
|
413
|
+
};
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region is class object
|
|
416
|
+
const ClassHelpers_isContextClassObject = (obj) => {
|
|
417
|
+
if (!_.isObject(obj) ||
|
|
418
|
+
_.isArray(obj) ||
|
|
419
|
+
_.isRegExp(obj) ||
|
|
420
|
+
_.isBuffer(obj) ||
|
|
421
|
+
_.isArrayBuffer(obj)) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
if (_.isDate(obj)) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
const className = ClassHelpers_getName(obj);
|
|
428
|
+
return _.isString(className) && className !== 'Object';
|
|
429
|
+
};
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region get name
|
|
432
|
+
const ClassHelpers_setName = (target, className) => {
|
|
433
|
+
// console.log('setName', className, target.name)
|
|
434
|
+
Validators_classNameVlidation(className, target);
|
|
435
|
+
target[Symbols_classNameStaticProperty] = className;
|
|
436
|
+
};
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region has parent with class name
|
|
439
|
+
const ClassHelpers_hasParentClassWithName = (target, className, targets = []) => {
|
|
440
|
+
if (!target) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
targets.push(target);
|
|
444
|
+
let targetProto = Object.getPrototypeOf(target);
|
|
445
|
+
if (_.isFunction(targetProto) &&
|
|
446
|
+
ClassHelpers_getName(targetProto) === className) {
|
|
447
|
+
// console.log(`true "${_.first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
return ClassHelpers_hasParentClassWithName(targetProto, className, targets);
|
|
451
|
+
};
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region get methods name
|
|
454
|
+
//#region not allowed as method name
|
|
455
|
+
const notAllowedAsMethodName = [
|
|
456
|
+
'length',
|
|
457
|
+
'name',
|
|
458
|
+
'arguments',
|
|
459
|
+
'caller',
|
|
460
|
+
'constructor',
|
|
461
|
+
'apply',
|
|
462
|
+
'bind',
|
|
463
|
+
'call',
|
|
464
|
+
'toString',
|
|
465
|
+
'__defineGetter__',
|
|
466
|
+
'__defineSetter__',
|
|
467
|
+
'hasOwnProperty',
|
|
468
|
+
'__lookupGetter__',
|
|
469
|
+
'__lookupSetter__',
|
|
470
|
+
'isPrototypeOf',
|
|
471
|
+
'propertyIsEnumerable',
|
|
472
|
+
'valueOf',
|
|
473
|
+
'__proto__',
|
|
474
|
+
'toLocaleString',
|
|
475
|
+
];
|
|
476
|
+
//#endregion
|
|
477
|
+
/**
|
|
478
|
+
* Express async handler for middleware functions.
|
|
479
|
+
*/
|
|
480
|
+
const ClassHelpers_asyncHandler = fn => (req, res, next) => {
|
|
481
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
482
|
+
};
|
|
483
|
+
const ClassHelpers_getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
484
|
+
if (!classOrClassInstance) {
|
|
485
|
+
return Utils_uniqArray(allMethodsNames);
|
|
486
|
+
}
|
|
487
|
+
const isClassFunction = _.isFunction(classOrClassInstance);
|
|
488
|
+
const classFun = isClassFunction
|
|
489
|
+
? classOrClassInstance
|
|
490
|
+
: Object.getPrototypeOf(classOrClassInstance);
|
|
491
|
+
const objectToCheck = isClassFunction
|
|
492
|
+
? classOrClassInstance?.prototype
|
|
493
|
+
: classOrClassInstance;
|
|
494
|
+
const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
|
|
495
|
+
const properties = _.uniq([
|
|
496
|
+
...Object.getOwnPropertyNames(objectToCheck || {}),
|
|
497
|
+
...Object.getOwnPropertyNames(prototypeObj || {}),
|
|
498
|
+
...Object.keys(objectToCheck || {}),
|
|
499
|
+
...Object.keys(prototypeObj || {}),
|
|
500
|
+
]).filter(f => !!f && !notAllowedAsMethodName.includes(f));
|
|
501
|
+
properties
|
|
502
|
+
.filter(methodName => typeof objectToCheck[methodName] === 'function')
|
|
503
|
+
.forEach(p => allMethodsNames.push(p));
|
|
504
|
+
if (!classFun ||
|
|
505
|
+
!classFun.constructor ||
|
|
506
|
+
classFun?.constructor?.name === 'Object') {
|
|
507
|
+
return Utils_uniqArray(allMethodsNames);
|
|
508
|
+
}
|
|
509
|
+
return ClassHelpers_getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
|
|
510
|
+
};
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region get controller configs
|
|
513
|
+
const ClassHelpers_getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
514
|
+
if (!_.isFunction(target)) {
|
|
515
|
+
throw `[typescript-class-helper][getControllerConfigs] Cannot get class config from: ${target}`;
|
|
516
|
+
}
|
|
517
|
+
let config;
|
|
518
|
+
const parentClass = Object.getPrototypeOf(target);
|
|
519
|
+
const parentName = parentClass ? ClassHelpers_getName(parentClass) : void 0;
|
|
520
|
+
const isValidParent = _.isFunction(parentClass) && parentName !== '';
|
|
521
|
+
config = controllerConfigFrom(ClassHelpers_getClassConfig(target));
|
|
522
|
+
configs.push(config);
|
|
523
|
+
return isValidParent
|
|
524
|
+
? ClassHelpers_getControllerConfigs(parentClass, configs, target)
|
|
525
|
+
: configs;
|
|
526
|
+
};
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region ensure configs
|
|
529
|
+
// Ensure ClassConfig on constructor, clone parent if needed
|
|
530
|
+
const ClassHelpers_ensureClassConfig = (target) => {
|
|
531
|
+
let cfg = Reflect.getOwnMetadata(Symbols_metadata.options.controller, // META_KEYS.class,
|
|
532
|
+
target);
|
|
533
|
+
if (!cfg) {
|
|
534
|
+
cfg = { methods: {} };
|
|
535
|
+
const parent = Object.getPrototypeOf(target);
|
|
536
|
+
if (parent && parent !== Function.prototype) {
|
|
537
|
+
const parentCfg = Reflect.getMetadata(Symbols_metadata.options.controller, // META_KEYS.class,
|
|
538
|
+
parent);
|
|
539
|
+
if (parentCfg) {
|
|
540
|
+
// Deep copy each method config so child gets its own objects
|
|
541
|
+
const clonedMethods = {};
|
|
542
|
+
for (const [k, v] of Object.entries(parentCfg.methods)) {
|
|
543
|
+
clonedMethods[k] = {
|
|
544
|
+
...v,
|
|
545
|
+
parameters: { ...v.parameters }, // shallow clone parameters too
|
|
564
546
|
};
|
|
565
547
|
}
|
|
548
|
+
cfg = {
|
|
549
|
+
...parentCfg,
|
|
550
|
+
methods: clonedMethods,
|
|
551
|
+
};
|
|
566
552
|
}
|
|
567
|
-
Reflect.defineMetadata(Symbols.metadata.options.controller, cfg, target);
|
|
568
553
|
}
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
554
|
+
Reflect.defineMetadata(Symbols_metadata.options.controller, cfg, target);
|
|
555
|
+
}
|
|
556
|
+
return cfg;
|
|
557
|
+
};
|
|
558
|
+
// Ensure MethodConfig inside ClassConfig
|
|
559
|
+
const ClassHelpers_ensureMethodConfig = (target, propertyKey) => {
|
|
560
|
+
const classCfg = ClassHelpers_ensureClassConfig(target.constructor);
|
|
561
|
+
let methodCfg = classCfg.methods[propertyKey?.toString()];
|
|
562
|
+
if (!methodCfg) {
|
|
563
|
+
methodCfg = { methodName: propertyKey?.toString(), parameters: {} };
|
|
564
|
+
classCfg.methods[propertyKey?.toString()] = methodCfg;
|
|
565
|
+
}
|
|
566
|
+
return methodCfg;
|
|
567
|
+
};
|
|
568
|
+
const ClassHelpers_getClassConfig = (constructor) => {
|
|
569
|
+
return Reflect.getMetadata(Symbols_metadata.options.controller, constructor);
|
|
570
|
+
};
|
|
571
|
+
//#endregion
|
|
572
|
+
//end of namespace ClassHelpers
|
|
586
573
|
|
|
587
574
|
//#region imports
|
|
588
575
|
class ContextDbMigrations {
|
|
@@ -693,21 +680,21 @@ class ContextDbMigrations {
|
|
|
693
680
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
694
681
|
return;
|
|
695
682
|
}
|
|
696
|
-
if (!
|
|
683
|
+
if (!UtilsMigrations_isValidTimestamp(timestamp)) {
|
|
697
684
|
Helpers.throw(`Invalid timestamp provided for migration revert: ${timestamp}`);
|
|
698
685
|
}
|
|
699
686
|
// Get all migration class functions and reverse the order
|
|
700
687
|
const migrationsClassFns = this.ctx
|
|
701
|
-
.getClassFunByArr(
|
|
688
|
+
.getClassFunByArr(Models_ClassType.MIGRATION)
|
|
702
689
|
.reverse();
|
|
703
690
|
// Filter migrations that need to be reverted
|
|
704
691
|
const migrationClassesInstancesToRevert = migrationsClassFns
|
|
705
692
|
.map(classFn => {
|
|
706
|
-
const timestampFromClassName = Number(
|
|
693
|
+
const timestampFromClassName = Number(UtilsMigrations_getTimestampFromClassName(ClassHelpers_getName(classFn)));
|
|
707
694
|
if (timestampFromClassName <= timestamp) {
|
|
708
695
|
// this.ctx.logMigrations &&
|
|
709
696
|
// console.log(
|
|
710
|
-
// `Stopping migration filter at: ${
|
|
697
|
+
// `Stopping migration filter at: ${ClassHelpers_getName(classFn)} ` +
|
|
711
698
|
// `with timestamp ${timestampFromClassName}`,
|
|
712
699
|
// );
|
|
713
700
|
return null;
|
|
@@ -727,7 +714,7 @@ class ContextDbMigrations {
|
|
|
727
714
|
const appliedMigrationsForContextNames = appliedMigrationsForContext.map(m => m.name);
|
|
728
715
|
// console.log({ appliedMigrationsForContextNames });
|
|
729
716
|
for (const migrationClassInstance of migrationClassesInstancesToRevert) {
|
|
730
|
-
const migrationName =
|
|
717
|
+
const migrationName = ClassHelpers_getName(migrationClassInstance);
|
|
731
718
|
if (!appliedMigrationsForContextNames.includes(migrationName)) {
|
|
732
719
|
this.ctx.logMigrations &&
|
|
733
720
|
console.warn(`Skipping migration not marked as applied: ${migrationName}`);
|
|
@@ -785,7 +772,7 @@ class ContextDbMigrations {
|
|
|
785
772
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
786
773
|
return;
|
|
787
774
|
}
|
|
788
|
-
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
775
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(Models_ClassType.MIGRATION);
|
|
789
776
|
const migrationClassesInstances = migrationsClassFns
|
|
790
777
|
.map(classFn => this.ctx.getInstanceBy(classFn))
|
|
791
778
|
.map(f => f)
|
|
@@ -798,7 +785,7 @@ class ContextDbMigrations {
|
|
|
798
785
|
const allMigrationsInDb = await queryRunner.query(`SELECT name FROM ${this.DEFAULT_MIGRATION_TABLE_NAME}`);
|
|
799
786
|
const allMigrationInDBNames = allMigrationsInDb.map(m => m.name);
|
|
800
787
|
for (const instance of migrationClassesInstances) {
|
|
801
|
-
const migrationName =
|
|
788
|
+
const migrationName = ClassHelpers_getName(instance);
|
|
802
789
|
if (allMigrationInDBNames.includes(migrationName)) {
|
|
803
790
|
this.ctx.logMigrations &&
|
|
804
791
|
console.log(`Skipping already applied migration: ${migrationName}`);
|
|
@@ -839,9 +826,9 @@ class ContextDbMigrations {
|
|
|
839
826
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
840
827
|
return;
|
|
841
828
|
}
|
|
842
|
-
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
829
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(Models_ClassType.MIGRATION);
|
|
843
830
|
// console.log({
|
|
844
|
-
// migrationClassesALl: migrationsClassFns.map(f =>
|
|
831
|
+
// migrationClassesALl: migrationsClassFns.map(f => ClassHelpers_getName(f)),
|
|
845
832
|
// });
|
|
846
833
|
const migrationClassesInstances = migrationsClassFns
|
|
847
834
|
.map(classFn => this.ctx.getInstanceBy(classFn))
|
|
@@ -849,7 +836,7 @@ class ContextDbMigrations {
|
|
|
849
836
|
.filter(migrationInstance => migrationInstance.isReadyToRun());
|
|
850
837
|
// console.log({
|
|
851
838
|
// migrationClassesInstances: migrationsClassFns.map(f =>
|
|
852
|
-
//
|
|
839
|
+
// ClassHelpers_getName(f),
|
|
853
840
|
// ),
|
|
854
841
|
// });
|
|
855
842
|
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
@@ -865,7 +852,7 @@ class ContextDbMigrations {
|
|
|
865
852
|
const pendingMigrationsForContext = appliedMigrationsForContext.filter(m => m.status === this.MIGRATION_STATUS_PENDING);
|
|
866
853
|
// Run pending migrations first
|
|
867
854
|
for (const pendingContextMigration of pendingMigrationsForContext) {
|
|
868
|
-
const migrationInstance = migrationClassesInstances.find(instance =>
|
|
855
|
+
const migrationInstance = migrationClassesInstances.find(instance => ClassHelpers_getName(instance) === pendingContextMigration.name);
|
|
869
856
|
if (!migrationInstance) {
|
|
870
857
|
this.ctx.logMigrations &&
|
|
871
858
|
console.warn(`Pending migration ${pendingContextMigration.name} not found in loaded migrations.`);
|
|
@@ -882,7 +869,7 @@ class ContextDbMigrations {
|
|
|
882
869
|
//#endregion
|
|
883
870
|
//#region run new migrations
|
|
884
871
|
for (const instance of migrationClassesInstances) {
|
|
885
|
-
const migrationName =
|
|
872
|
+
const migrationName = ClassHelpers_getName(instance);
|
|
886
873
|
if (appliedMigrationsForContext.some(m => m.name === migrationName)) {
|
|
887
874
|
this.ctx.logMigrations &&
|
|
888
875
|
console.log(`Skipping already applied migration: ${migrationName}`);
|
|
@@ -978,151 +965,150 @@ const getResponseValue = (response, options) => {
|
|
|
978
965
|
//#endregion
|
|
979
966
|
};
|
|
980
967
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
return true;
|
|
1013
|
-
}
|
|
1014
|
-
if (bool === 'false') {
|
|
1015
|
-
return false;
|
|
1016
|
-
}
|
|
1017
|
-
try {
|
|
1018
|
-
const t = JSON5.parse(param);
|
|
1019
|
-
return t;
|
|
1020
|
-
}
|
|
1021
|
-
catch (e) {
|
|
1022
|
-
return param;
|
|
1023
|
-
}
|
|
968
|
+
//namespace TaonHelpers
|
|
969
|
+
//#region fillUpTo string
|
|
970
|
+
const TaonHelpers_fillUpTo = (s, nCharacters) => {
|
|
971
|
+
return _.times(nCharacters, n => {
|
|
972
|
+
if (s.charAt(n)) {
|
|
973
|
+
return s.charAt(n);
|
|
974
|
+
}
|
|
975
|
+
return ' ';
|
|
976
|
+
}).join('');
|
|
977
|
+
};
|
|
978
|
+
//#endregion
|
|
979
|
+
//#region is good path
|
|
980
|
+
const TaonHelpers_isGoodPath = (p) => {
|
|
981
|
+
return p && typeof p === 'string' && p.trim() !== '';
|
|
982
|
+
};
|
|
983
|
+
//#endregion
|
|
984
|
+
const TaonHelpers_firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
985
|
+
if (Array.isArray(stringOrArrayOfString)) {
|
|
986
|
+
return _.first(stringOrArrayOfString);
|
|
987
|
+
}
|
|
988
|
+
return stringOrArrayOfString;
|
|
989
|
+
};
|
|
990
|
+
//#region try transform params
|
|
991
|
+
const TaonHelpers_tryTransformParam = param => {
|
|
992
|
+
if (typeof param === 'string') {
|
|
993
|
+
let n = Number(param);
|
|
994
|
+
if (!isNaN(n))
|
|
995
|
+
return n;
|
|
996
|
+
const bool = param.trim().toLowerCase();
|
|
997
|
+
if (bool === 'true') {
|
|
998
|
+
return true;
|
|
1024
999
|
}
|
|
1025
|
-
|
|
1026
|
-
};
|
|
1027
|
-
//#endregion
|
|
1028
|
-
//#region get expores path
|
|
1029
|
-
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
1030
|
-
if (typeof pathOrClassConfig === 'string')
|
|
1031
|
-
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1032
|
-
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1033
|
-
};
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region get default value tyep
|
|
1036
|
-
TaonHelpers.defaultType = value => {
|
|
1037
|
-
if (typeof value === 'string')
|
|
1038
|
-
return '';
|
|
1039
|
-
if (typeof value === 'boolean')
|
|
1000
|
+
if (bool === 'false') {
|
|
1040
1001
|
return false;
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
return
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1002
|
+
}
|
|
1003
|
+
try {
|
|
1004
|
+
const t = JSON5.parse(param);
|
|
1005
|
+
return t;
|
|
1006
|
+
}
|
|
1007
|
+
catch (e) {
|
|
1008
|
+
return param;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return param;
|
|
1012
|
+
};
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region get expores path
|
|
1015
|
+
const TaonHelpers_getExpressPath = (c, pathOrClassConfig) => {
|
|
1016
|
+
if (typeof pathOrClassConfig === 'string')
|
|
1017
|
+
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1018
|
+
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1019
|
+
};
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region get default value tyep
|
|
1022
|
+
const TaonHelpers_defaultType = value => {
|
|
1023
|
+
if (typeof value === 'string')
|
|
1024
|
+
return '';
|
|
1025
|
+
if (typeof value === 'boolean')
|
|
1026
|
+
return false;
|
|
1027
|
+
if (Array.isArray(value))
|
|
1028
|
+
return {};
|
|
1029
|
+
if (typeof value === 'object')
|
|
1030
|
+
return {};
|
|
1031
|
+
};
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region parse json with string jsons
|
|
1034
|
+
const TaonHelpers_parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1035
|
+
// console.log('checking object', object)
|
|
1036
|
+
if (!_.isObject(object)) {
|
|
1037
|
+
if (waring) {
|
|
1038
|
+
console.error(`
|
|
1053
1039
|
parseJSONwithStringJSONs(...)
|
|
1054
1040
|
Parameter should be a object, but is ${typeof object}
|
|
1055
1041
|
`, object);
|
|
1056
|
-
}
|
|
1057
|
-
return object;
|
|
1058
1042
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
};
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
return { request, response };
|
|
1043
|
+
return object;
|
|
1044
|
+
}
|
|
1045
|
+
let res = _.cloneDeep(object);
|
|
1046
|
+
Object.keys(res).forEach(key => {
|
|
1047
|
+
let isJson = false;
|
|
1048
|
+
try {
|
|
1049
|
+
const possibleJSON = JSON.parse(res[key]);
|
|
1050
|
+
res[key] = possibleJSON;
|
|
1051
|
+
isJson = true;
|
|
1052
|
+
}
|
|
1053
|
+
catch (e) {
|
|
1054
|
+
isJson = false;
|
|
1055
|
+
}
|
|
1056
|
+
// console.log(`key ${key} is json `, isJson)
|
|
1057
|
+
if (isJson) {
|
|
1058
|
+
res[key] = TaonHelpers_parseJSONwithStringJSONs(res[key], false);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
return res;
|
|
1062
|
+
};
|
|
1063
|
+
//#endregion
|
|
1064
|
+
//#region is plain file or folder
|
|
1065
|
+
const TaonHelpers_isPlainFileOrFolder = filePath => {
|
|
1066
|
+
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
1067
|
+
};
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region ips key name repsonse
|
|
1070
|
+
const TaonHelpers_ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
1071
|
+
return [
|
|
1072
|
+
'response',
|
|
1073
|
+
ClassHelpers_getName(target),
|
|
1074
|
+
methodConfig.methodName,
|
|
1075
|
+
methodConfig.type,
|
|
1076
|
+
expressPath,
|
|
1077
|
+
].join('--');
|
|
1078
|
+
};
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region ipc key name request
|
|
1081
|
+
const TaonHelpers_ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
1082
|
+
return [
|
|
1083
|
+
'request',
|
|
1084
|
+
ClassHelpers_getName(target),
|
|
1085
|
+
methodConfig.methodName,
|
|
1086
|
+
methodConfig.type,
|
|
1087
|
+
expressPath,
|
|
1088
|
+
].join('--');
|
|
1089
|
+
};
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region websql mocks
|
|
1092
|
+
const TaonHelpers_websqlMocks = headers => {
|
|
1093
|
+
const response = {
|
|
1094
|
+
status(status) {
|
|
1095
|
+
// console.log({status})
|
|
1096
|
+
return {
|
|
1097
|
+
send(send) {
|
|
1098
|
+
// console.log({status})
|
|
1099
|
+
},
|
|
1100
|
+
};
|
|
1101
|
+
},
|
|
1102
|
+
setHeader(key, value) {
|
|
1103
|
+
// console.log('Dummy set header', arguments)
|
|
1104
|
+
headers[key] = value;
|
|
1105
|
+
},
|
|
1123
1106
|
};
|
|
1124
|
-
|
|
1125
|
-
|
|
1107
|
+
const request = {};
|
|
1108
|
+
return { request, response };
|
|
1109
|
+
};
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//end of namespace TaonHelpers
|
|
1126
1112
|
|
|
1127
1113
|
//#region imports
|
|
1128
1114
|
/* */
|
|
@@ -1148,18 +1134,18 @@ class RealtimeSubsManager {
|
|
|
1148
1134
|
// console.info(`[BROWSER]][IPC] subscribe to "${this.options?.roomName}" by sending event: "${subscribeEvent}"`, this.options);
|
|
1149
1135
|
this.isListening = true;
|
|
1150
1136
|
if (this.options.customEvent) {
|
|
1151
|
-
const subscribeEvent =
|
|
1137
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.options.core.ctx.contextName);
|
|
1152
1138
|
// this means: send to current client custom event notification
|
|
1153
1139
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1154
1140
|
}
|
|
1155
1141
|
else {
|
|
1156
1142
|
if (_.isString(this.options.property)) {
|
|
1157
|
-
const subscribeEvent =
|
|
1143
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1158
1144
|
// this means: send to current client entity property events updates
|
|
1159
1145
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1160
1146
|
}
|
|
1161
1147
|
else {
|
|
1162
|
-
const subscribeEvent =
|
|
1148
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1163
1149
|
// this means: send to current client entity update events
|
|
1164
1150
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1165
1151
|
}
|
|
@@ -1187,14 +1173,14 @@ class RealtimeSubsManager {
|
|
|
1187
1173
|
const { core, customEvent, roomName, property } = this.options;
|
|
1188
1174
|
const realtime = core.socketFE;
|
|
1189
1175
|
if (customEvent) {
|
|
1190
|
-
realtime.emit(
|
|
1176
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.options.core.ctx.contextName), roomName);
|
|
1191
1177
|
}
|
|
1192
1178
|
else {
|
|
1193
1179
|
if (_.isString(property)) {
|
|
1194
|
-
realtime.emit(
|
|
1180
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1195
1181
|
}
|
|
1196
1182
|
else {
|
|
1197
|
-
realtime.emit(
|
|
1183
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1198
1184
|
}
|
|
1199
1185
|
}
|
|
1200
1186
|
}
|
|
@@ -1241,7 +1227,7 @@ class RealtimeClient {
|
|
|
1241
1227
|
//#region prepare naspaces pathes
|
|
1242
1228
|
const nspPath = {
|
|
1243
1229
|
global: this.core.pathFor(),
|
|
1244
|
-
realtime: this.core.pathFor(
|
|
1230
|
+
realtime: this.core.pathFor(Symbols_REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1245
1231
|
};
|
|
1246
1232
|
// console.log('[browser] nspPath', nspPath);
|
|
1247
1233
|
if (this.core.ctx.config.frontendHost &&
|
|
@@ -1310,15 +1296,15 @@ class RealtimeClient {
|
|
|
1310
1296
|
if (_.isObject(entityClassFnOrObj)) {
|
|
1311
1297
|
const orgObj = entityClassFnOrObj;
|
|
1312
1298
|
entityClassFnOrObj =
|
|
1313
|
-
|
|
1314
|
-
const uniqueKey =
|
|
1299
|
+
ClassHelpers_getClassFnFromObject(entityClassFnOrObj);
|
|
1300
|
+
const uniqueKey = ClassHelpers_getUniqueKey(entityClassFnOrObj);
|
|
1315
1301
|
if (uniqueKey) {
|
|
1316
1302
|
options.idOrUniqValue = orgObj[uniqueKey];
|
|
1317
1303
|
}
|
|
1318
1304
|
}
|
|
1319
1305
|
//#region parameters validation
|
|
1320
1306
|
const { property, customEvent } = options;
|
|
1321
|
-
const className = !customEvent &&
|
|
1307
|
+
const className = !customEvent && ClassHelpers_getName(entityClassFnOrObj);
|
|
1322
1308
|
if (_.isString(property)) {
|
|
1323
1309
|
if (property.trim() === '') {
|
|
1324
1310
|
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
@@ -1342,12 +1328,12 @@ to use socket realtime connection;
|
|
|
1342
1328
|
}
|
|
1343
1329
|
let roomName;
|
|
1344
1330
|
if (customEvent) {
|
|
1345
|
-
roomName =
|
|
1331
|
+
roomName = Symbols_REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1346
1332
|
}
|
|
1347
1333
|
else {
|
|
1348
1334
|
roomName = _.isString(property)
|
|
1349
|
-
?
|
|
1350
|
-
:
|
|
1335
|
+
? Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1336
|
+
: Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1351
1337
|
}
|
|
1352
1338
|
const roomSubOptions = {
|
|
1353
1339
|
core: this.core,
|
|
@@ -1375,9 +1361,9 @@ to use socket realtime connection;
|
|
|
1375
1361
|
* Example: for pagination, lists update ...
|
|
1376
1362
|
*/
|
|
1377
1363
|
listenChangesEntityTable(entityClassFn) {
|
|
1378
|
-
const className =
|
|
1364
|
+
const className = ClassHelpers_getName(entityClassFn);
|
|
1379
1365
|
return this.listenChangesEntity(entityClassFn, {
|
|
1380
|
-
customEvent:
|
|
1366
|
+
customEvent: Symbols_REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
1381
1367
|
});
|
|
1382
1368
|
}
|
|
1383
1369
|
//#endregion
|
|
@@ -1449,7 +1435,7 @@ class RealtimeServer {
|
|
|
1449
1435
|
//#region @websql
|
|
1450
1436
|
//#region prepare namespaces pathes
|
|
1451
1437
|
const nspPathGlobal = this.core.pathFor();
|
|
1452
|
-
const nspPathRealtime = this.core.pathFor(
|
|
1438
|
+
const nspPathRealtime = this.core.pathFor(Symbols_REALTIME.NAMESPACE(this.core.ctx.contextName));
|
|
1453
1439
|
//#endregion
|
|
1454
1440
|
// console.log('[backend] nspPath', nspPath);
|
|
1455
1441
|
const cors = {
|
|
@@ -1488,37 +1474,37 @@ class RealtimeServer {
|
|
|
1488
1474
|
this.core.ctx.logRealtime &&
|
|
1489
1475
|
console.info(`[backend] client connected to namespace "${nspPathRealtime.pathname}", ` +
|
|
1490
1476
|
` host: ${this.core.ctx.host}`);
|
|
1491
|
-
backendSocketForClient.on(
|
|
1477
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
|
|
1492
1478
|
this.core.ctx.logRealtime &&
|
|
1493
1479
|
console.info(`Joining room ${roomName} in namespace REALTIME` +
|
|
1494
1480
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1495
1481
|
backendSocketForClient.join(roomName);
|
|
1496
1482
|
});
|
|
1497
|
-
backendSocketForClient.on(
|
|
1483
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1498
1484
|
this.core.ctx.logRealtime &&
|
|
1499
1485
|
console.info(`[backend] Joining room ${roomName} in namespace REALTIME` +
|
|
1500
1486
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1501
1487
|
backendSocketForClient.join(roomName);
|
|
1502
1488
|
});
|
|
1503
|
-
backendSocketForClient.on(
|
|
1489
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1504
1490
|
this.core.ctx.logRealtime &&
|
|
1505
1491
|
console.info(`[backend] Joining room ${roomName} in namespace REALTIME ` +
|
|
1506
1492
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1507
1493
|
backendSocketForClient.join(roomName);
|
|
1508
1494
|
});
|
|
1509
|
-
backendSocketForClient.on(
|
|
1495
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
|
|
1510
1496
|
this.core.ctx.logRealtime &&
|
|
1511
1497
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME` +
|
|
1512
1498
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1513
1499
|
backendSocketForClient.leave(roomName);
|
|
1514
1500
|
});
|
|
1515
|
-
backendSocketForClient.on(
|
|
1501
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1516
1502
|
this.core.ctx.logRealtime &&
|
|
1517
1503
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME ` +
|
|
1518
1504
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1519
1505
|
backendSocketForClient.leave(roomName);
|
|
1520
1506
|
});
|
|
1521
|
-
backendSocketForClient.on(
|
|
1507
|
+
backendSocketForClient.on(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1522
1508
|
this.core.ctx.logRealtime &&
|
|
1523
1509
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME ` +
|
|
1524
1510
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
@@ -1540,25 +1526,25 @@ class RealtimeServer {
|
|
|
1540
1526
|
return;
|
|
1541
1527
|
}
|
|
1542
1528
|
if (customEvent) {
|
|
1543
|
-
roomName =
|
|
1529
|
+
roomName = Symbols_REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1544
1530
|
}
|
|
1545
1531
|
else {
|
|
1546
1532
|
let entityFn = entityObjOrClass;
|
|
1547
1533
|
const entityIsObject = !_.isFunction(entityObjOrClass) && _.isObject(entityObjOrClass);
|
|
1548
1534
|
if (entityIsObject) {
|
|
1549
|
-
entityFn =
|
|
1535
|
+
entityFn = ClassHelpers_getClassFnFromObject(entityObjOrClass);
|
|
1550
1536
|
}
|
|
1551
|
-
const uniqueKey =
|
|
1537
|
+
const uniqueKey = ClassHelpers_getUniqueKey(entityFn);
|
|
1552
1538
|
if (entityIsObject) {
|
|
1553
1539
|
valueOfUniqueProperty = entityObjOrClass[uniqueKey];
|
|
1554
1540
|
}
|
|
1555
1541
|
if (!valueOfUniqueProperty) {
|
|
1556
|
-
Helpers.error(`[Taon][Realtime] Entity without iD ! ${
|
|
1542
|
+
Helpers.error(`[Taon][Realtime] Entity without iD ! ${ClassHelpers_getName(entityFn)} `, true, true);
|
|
1557
1543
|
return;
|
|
1558
1544
|
}
|
|
1559
1545
|
roomName = _.isString(property)
|
|
1560
|
-
?
|
|
1561
|
-
:
|
|
1546
|
+
? Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, ClassHelpers_getName(entityFn), property, valueOfUniqueProperty)
|
|
1547
|
+
: Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, ClassHelpers_getName(entityFn), valueOfUniqueProperty);
|
|
1562
1548
|
}
|
|
1563
1549
|
this.core.socketBE.in(roomName).emit(roomName, // roomName == eventName in room na
|
|
1564
1550
|
customEvent ? customEventData : '');
|
|
@@ -1574,7 +1560,7 @@ class RealtimeServer {
|
|
|
1574
1560
|
*/
|
|
1575
1561
|
idToTrigger) {
|
|
1576
1562
|
if (this.core.ctx.disabledRealtime) {
|
|
1577
|
-
const className =
|
|
1563
|
+
const className = ClassHelpers_getName(entityObjOrClass);
|
|
1578
1564
|
console.warn(`[Taon][TriggerEntityChanges] Entity "${className}' is not realtime`);
|
|
1579
1565
|
return;
|
|
1580
1566
|
}
|
|
@@ -1594,7 +1580,7 @@ class RealtimeServer {
|
|
|
1594
1580
|
*/
|
|
1595
1581
|
idToTrigger) {
|
|
1596
1582
|
if (this.core.ctx.disabledRealtime) {
|
|
1597
|
-
const className =
|
|
1583
|
+
const className = ClassHelpers_getName(entityObjOrClass);
|
|
1598
1584
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
1599
1585
|
return;
|
|
1600
1586
|
}
|
|
@@ -1610,12 +1596,12 @@ class RealtimeServer {
|
|
|
1610
1596
|
//#endregion
|
|
1611
1597
|
//#region methods & getters / trigger entity table changes
|
|
1612
1598
|
triggerEntityTableChanges(entityClassOrInstance) {
|
|
1613
|
-
const className =
|
|
1599
|
+
const className = ClassHelpers_getName(entityClassOrInstance);
|
|
1614
1600
|
if (this.core.ctx.disabledRealtime) {
|
|
1615
1601
|
console.warn(`[Taon][TriggerEntityTableChanges] Entity "${className}' is not realtime`);
|
|
1616
1602
|
return;
|
|
1617
1603
|
}
|
|
1618
|
-
this.triggerChanges(entityClassOrInstance, void 0, void 0,
|
|
1604
|
+
this.triggerChanges(entityClassOrInstance, void 0, void 0, Symbols_REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className));
|
|
1619
1605
|
}
|
|
1620
1606
|
//#endregion
|
|
1621
1607
|
//#endregion
|
|
@@ -2142,11 +2128,11 @@ class MockSocket {
|
|
|
2142
2128
|
//#region emit
|
|
2143
2129
|
emit(eventName, ...args) {
|
|
2144
2130
|
eventName = eventName || '';
|
|
2145
|
-
if (eventName.includes(`:${
|
|
2131
|
+
if (eventName.includes(`:${Symbols_REALTIME.KEYroomSubscribe}`)) {
|
|
2146
2132
|
const room = args[0];
|
|
2147
2133
|
this.join(room);
|
|
2148
2134
|
}
|
|
2149
|
-
else if (eventName.includes(`:${
|
|
2135
|
+
else if (eventName.includes(`:${Symbols_REALTIME.KEYroomUnsubscribe}`)) {
|
|
2150
2136
|
const room = args[0];
|
|
2151
2137
|
this.leave(room);
|
|
2152
2138
|
}
|
|
@@ -2481,18 +2467,18 @@ class EndpointContext {
|
|
|
2481
2467
|
//#endregion
|
|
2482
2468
|
//#region fields / types from contexts
|
|
2483
2469
|
this.injectableTypesfromContexts = [
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2470
|
+
Models_ClassType.CONTROLLER,
|
|
2471
|
+
Models_ClassType.PROVIDER,
|
|
2472
|
+
Models_ClassType.MIDDLEWARE,
|
|
2473
|
+
Models_ClassType.REPOSITORY,
|
|
2474
|
+
Models_ClassType.SUBSCRIBER,
|
|
2475
|
+
Models_ClassType.MIGRATION,
|
|
2490
2476
|
];
|
|
2491
2477
|
//#endregion
|
|
2492
2478
|
//#region fields / all types from contexts
|
|
2493
2479
|
this.allTypesfromContexts = [
|
|
2494
2480
|
...this.injectableTypesfromContexts,
|
|
2495
|
-
|
|
2481
|
+
Models_ClassType.ENTITY,
|
|
2496
2482
|
];
|
|
2497
2483
|
//#endregion
|
|
2498
2484
|
//#region fields / express app
|
|
@@ -2517,7 +2503,7 @@ class EndpointContext {
|
|
|
2517
2503
|
// Return a new class that extends the base class
|
|
2518
2504
|
const cloneClass = () => {
|
|
2519
2505
|
var _a, _b, _c, _d, _e;
|
|
2520
|
-
if (TaonBaseClass[
|
|
2506
|
+
if (TaonBaseClass[Symbols_fullClassNameStaticProperty] ===
|
|
2521
2507
|
`${ctx.contextName}.${className}`) {
|
|
2522
2508
|
return TaonBaseClass;
|
|
2523
2509
|
}
|
|
@@ -2529,7 +2515,7 @@ class EndpointContext {
|
|
|
2529
2515
|
// You can override prototype properties or methods here if needed
|
|
2530
2516
|
// static properties override allowed
|
|
2531
2517
|
}
|
|
2532
|
-
static { _a =
|
|
2518
|
+
static { _a = Symbols_orignalClass, _b = Symbols_fullClassNameStaticProperty, _c = Symbols_classNameStaticProperty, _d = Symbols_ctxInClassOrClassObj, _e = Symbols_ctxInClassOrClassObj; }
|
|
2533
2519
|
// @ts-ignore
|
|
2534
2520
|
static { this[_a] = TaonBaseClass; }
|
|
2535
2521
|
// @ts-ignore
|
|
@@ -2539,13 +2525,13 @@ class EndpointContext {
|
|
|
2539
2525
|
static { this[_d] = ctx; }
|
|
2540
2526
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2541
2527
|
static __getFullPathForClass__(arr = []) {
|
|
2542
|
-
const name = this[
|
|
2528
|
+
const name = this[Symbols_fullClassNameStaticProperty];
|
|
2543
2529
|
arr.push(name);
|
|
2544
2530
|
// @ts-ignore
|
|
2545
|
-
if (this[
|
|
2546
|
-
this[
|
|
2531
|
+
if (this[Symbols_orignalClass] && // @ts-ignore
|
|
2532
|
+
this[Symbols_orignalClass].__getFullPathForClass__) {
|
|
2547
2533
|
// @ts-ignore
|
|
2548
|
-
this[
|
|
2534
|
+
this[Symbols_orignalClass].__getFullPathForClass__(arr);
|
|
2549
2535
|
}
|
|
2550
2536
|
return arr.join('/');
|
|
2551
2537
|
}
|
|
@@ -2558,19 +2544,19 @@ class EndpointContext {
|
|
|
2558
2544
|
//#region gather all instances for all contexts
|
|
2559
2545
|
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
2560
2546
|
// this thinng belowe is nice for debugging purpose
|
|
2561
|
-
// if (_.isUndefined(cloneClassFunction[
|
|
2562
|
-
// cloneClassFunction[
|
|
2547
|
+
// if (_.isUndefined(cloneClassFunction[Symbols_orignalClassClonesObj])) {
|
|
2548
|
+
// cloneClassFunction[Symbols_orignalClassClonesObj] = {};
|
|
2563
2549
|
// }
|
|
2564
|
-
// if (_.isUndefined(TaonBaseClass[
|
|
2565
|
-
// TaonBaseClass[
|
|
2550
|
+
// if (_.isUndefined(TaonBaseClass[Symbols_orignalClassClonesObj])) {
|
|
2551
|
+
// TaonBaseClass[Symbols_orignalClassClonesObj] = {};
|
|
2566
2552
|
// }
|
|
2567
2553
|
// const all = {
|
|
2568
|
-
// ...TaonBaseClass[
|
|
2569
|
-
// ...cloneClassFunction[
|
|
2554
|
+
// ...TaonBaseClass[Symbols_orignalClassClonesObj],
|
|
2555
|
+
// ...cloneClassFunction[Symbols_orignalClassClonesObj],
|
|
2570
2556
|
// };
|
|
2571
2557
|
// all[ctx.contextName] = cloneClassFunction;
|
|
2572
|
-
// cloneClassFunction[
|
|
2573
|
-
// TaonBaseClass[
|
|
2558
|
+
// cloneClassFunction[Symbols_orignalClassClonesObj] = all;
|
|
2559
|
+
// TaonBaseClass[Symbols_orignalClassClonesObj] = all;
|
|
2574
2560
|
//#endregion
|
|
2575
2561
|
return cloneClassFunction;
|
|
2576
2562
|
};
|
|
@@ -2589,13 +2575,13 @@ class EndpointContext {
|
|
|
2589
2575
|
|
|
2590
2576
|
`);
|
|
2591
2577
|
}
|
|
2592
|
-
var className = Reflect.getMetadata(
|
|
2578
|
+
var className = Reflect.getMetadata(Symbols_metadata.className, TaonBaseClass);
|
|
2593
2579
|
// console.log('Metadata className', className, TaonBaseClass);
|
|
2594
2580
|
// if (!className) {
|
|
2595
2581
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
2596
2582
|
// }
|
|
2597
2583
|
className = className || key;
|
|
2598
|
-
TaonBaseClass[
|
|
2584
|
+
TaonBaseClass[Symbols_classNameStaticProperty] = className;
|
|
2599
2585
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
2600
2586
|
TaonBaseClass,
|
|
2601
2587
|
className,
|
|
@@ -2608,7 +2594,7 @@ class EndpointContext {
|
|
|
2608
2594
|
return classes;
|
|
2609
2595
|
};
|
|
2610
2596
|
this.cloneOptions = this.cloneOptions || {};
|
|
2611
|
-
this.isRunningInsideDocker =
|
|
2597
|
+
this.isRunningInsideDocker = UtilsOs_isRunningInDocker();
|
|
2612
2598
|
}
|
|
2613
2599
|
//#endregion
|
|
2614
2600
|
//#region methods & getters / init
|
|
@@ -2621,7 +2607,7 @@ class EndpointContext {
|
|
|
2621
2607
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
2622
2608
|
this.config = this.configFn({});
|
|
2623
2609
|
if (_.isObject(this.config.database)) {
|
|
2624
|
-
this.config.database =
|
|
2610
|
+
this.config.database = Models_DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
2625
2611
|
}
|
|
2626
2612
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
2627
2613
|
if (this.cloneOptions.overrideHost &&
|
|
@@ -2734,31 +2720,31 @@ class EndpointContext {
|
|
|
2734
2720
|
this.config.subscribers = this.config.subscribers || {};
|
|
2735
2721
|
this.config.migrations = this.config.migrations || {};
|
|
2736
2722
|
this.config.entities = {
|
|
2737
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2723
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.ENTITY)),
|
|
2738
2724
|
...this.config.entities,
|
|
2739
2725
|
};
|
|
2740
2726
|
this.config.controllers = {
|
|
2741
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2727
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.CONTROLLER)),
|
|
2742
2728
|
...this.config.controllers,
|
|
2743
2729
|
};
|
|
2744
2730
|
this.config.providers = {
|
|
2745
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2731
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.PROVIDER)),
|
|
2746
2732
|
...this.config.providers,
|
|
2747
2733
|
};
|
|
2748
2734
|
this.config.middlewares = {
|
|
2749
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2735
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.MIDDLEWARE)),
|
|
2750
2736
|
...this.config.middlewares,
|
|
2751
2737
|
};
|
|
2752
2738
|
this.config.subscribers = {
|
|
2753
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2739
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.SUBSCRIBER)),
|
|
2754
2740
|
...this.config.subscribers,
|
|
2755
2741
|
};
|
|
2756
2742
|
this.config.repositories = {
|
|
2757
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2743
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.REPOSITORY)),
|
|
2758
2744
|
...this.config.repositories,
|
|
2759
2745
|
};
|
|
2760
2746
|
this.config.migrations = {
|
|
2761
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2747
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.MIGRATION)),
|
|
2762
2748
|
...this.config.migrations,
|
|
2763
2749
|
};
|
|
2764
2750
|
// console.log(this.config);
|
|
@@ -2769,37 +2755,37 @@ class EndpointContext {
|
|
|
2769
2755
|
classesInput: this.config.controllers,
|
|
2770
2756
|
config: this.config,
|
|
2771
2757
|
ctx: this,
|
|
2772
|
-
classType:
|
|
2758
|
+
classType: Models_ClassType.CONTROLLER,
|
|
2773
2759
|
});
|
|
2774
2760
|
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
2775
2761
|
classesInput: this.config.repositories,
|
|
2776
2762
|
config: this.config,
|
|
2777
2763
|
ctx: this,
|
|
2778
|
-
classType:
|
|
2764
|
+
classType: Models_ClassType.REPOSITORY,
|
|
2779
2765
|
});
|
|
2780
2766
|
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
2781
2767
|
classesInput: this.config.providers,
|
|
2782
2768
|
config: this.config,
|
|
2783
2769
|
ctx: this,
|
|
2784
|
-
classType:
|
|
2770
|
+
classType: Models_ClassType.PROVIDER,
|
|
2785
2771
|
});
|
|
2786
2772
|
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
2787
2773
|
classesInput: this.config.middlewares,
|
|
2788
2774
|
config: this.config,
|
|
2789
2775
|
ctx: this,
|
|
2790
|
-
classType:
|
|
2776
|
+
classType: Models_ClassType.MIDDLEWARE,
|
|
2791
2777
|
});
|
|
2792
2778
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
2793
2779
|
classesInput: this.config.subscribers,
|
|
2794
2780
|
config: this.config,
|
|
2795
2781
|
ctx: this,
|
|
2796
|
-
classType:
|
|
2782
|
+
classType: Models_ClassType.SUBSCRIBER,
|
|
2797
2783
|
});
|
|
2798
2784
|
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
2799
2785
|
classesInput: this.config.migrations,
|
|
2800
2786
|
config: this.config,
|
|
2801
2787
|
ctx: this,
|
|
2802
|
-
classType:
|
|
2788
|
+
classType: Models_ClassType.MIGRATION,
|
|
2803
2789
|
});
|
|
2804
2790
|
//#endregion
|
|
2805
2791
|
//#region prepare instances
|
|
@@ -2808,7 +2794,7 @@ class EndpointContext {
|
|
|
2808
2794
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
2809
2795
|
}
|
|
2810
2796
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
2811
|
-
await this.createInstances(this.config[
|
|
2797
|
+
await this.createInstances(this.config[Models_ClassTypeKey[classTypeName]], classTypeName);
|
|
2812
2798
|
}
|
|
2813
2799
|
//#endregion
|
|
2814
2800
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
@@ -2909,13 +2895,13 @@ class EndpointContext {
|
|
|
2909
2895
|
|
|
2910
2896
|
`);
|
|
2911
2897
|
//#region @websqlFunc
|
|
2912
|
-
let databaseConfig =
|
|
2913
|
-
const tcpUdpDatabaseSqliteRelativeFileLocation = `${
|
|
2898
|
+
let databaseConfig = Models_DatabaseConfig.from({});
|
|
2899
|
+
const tcpUdpDatabaseSqliteRelativeFileLocation = `${Models_DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
2914
2900
|
if (this.isRunningInsideDocker) {
|
|
2915
2901
|
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
2916
2902
|
// Helpers.info('Running in docker, using in mysql database');
|
|
2917
2903
|
// // TODO auto resolve database config in docker
|
|
2918
|
-
// databaseConfig =
|
|
2904
|
+
// databaseConfig = Models_DatabaseConfig.from({
|
|
2919
2905
|
// database: `db-${this.contextName}.sqlite`,
|
|
2920
2906
|
// type: 'mysql',
|
|
2921
2907
|
// recreateMode: 'PRESERVE_DATA+MIGRATIONS',
|
|
@@ -2939,7 +2925,7 @@ class EndpointContext {
|
|
|
2939
2925
|
/* */
|
|
2940
2926
|
/* */
|
|
2941
2927
|
/* */
|
|
2942
|
-
databaseConfig = databaseConfig =
|
|
2928
|
+
databaseConfig = databaseConfig = Models_DatabaseConfig.from({
|
|
2943
2929
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
2944
2930
|
type: 'sqljs',
|
|
2945
2931
|
useLocalForage: false,
|
|
@@ -2980,8 +2966,8 @@ class EndpointContext {
|
|
|
2980
2966
|
/* */
|
|
2981
2967
|
/* */
|
|
2982
2968
|
/* */
|
|
2983
|
-
databaseConfig =
|
|
2984
|
-
location:
|
|
2969
|
+
databaseConfig = Models_DatabaseConfig.from({
|
|
2970
|
+
location: UtilsOs_isElectron
|
|
2985
2971
|
? dbLocationInOs
|
|
2986
2972
|
: `db-${this.contextName}.sqlite`,
|
|
2987
2973
|
type: 'sqljs',
|
|
@@ -2998,7 +2984,7 @@ class EndpointContext {
|
|
|
2998
2984
|
keepWebsqlDbDataAfterReload =
|
|
2999
2985
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload; // TODO @LAST
|
|
3000
2986
|
//#endregion
|
|
3001
|
-
databaseConfig = databaseConfig =
|
|
2987
|
+
databaseConfig = databaseConfig = Models_DatabaseConfig.from({
|
|
3002
2988
|
location: `db-${this.contextName}.sqlite`,
|
|
3003
2989
|
type: 'sqljs',
|
|
3004
2990
|
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
@@ -3011,7 +2997,7 @@ class EndpointContext {
|
|
|
3011
2997
|
//#endregion
|
|
3012
2998
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
3013
2999
|
case 'backend-frontend(tcp+udp)':
|
|
3014
|
-
databaseConfig =
|
|
3000
|
+
databaseConfig = Models_DatabaseConfig.from({
|
|
3015
3001
|
database: `context-db-${this.contextName}`,
|
|
3016
3002
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
3017
3003
|
type: 'sqljs',
|
|
@@ -3115,7 +3101,7 @@ class EndpointContext {
|
|
|
3115
3101
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
3116
3102
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
3117
3103
|
return arr.reduce((acc, c) => {
|
|
3118
|
-
acc[
|
|
3104
|
+
acc[ClassHelpers_getName(c)] = c;
|
|
3119
3105
|
return acc;
|
|
3120
3106
|
}, {});
|
|
3121
3107
|
}
|
|
@@ -3155,9 +3141,9 @@ class EndpointContext {
|
|
|
3155
3141
|
//#endregion
|
|
3156
3142
|
//#region methods & getters / inject
|
|
3157
3143
|
inject(ctor, options) {
|
|
3158
|
-
const className =
|
|
3144
|
+
const className = ClassHelpers_getName(ctor);
|
|
3159
3145
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
3160
|
-
if (this.isCLassType(
|
|
3146
|
+
if (this.isCLassType(Models_ClassType.REPOSITORY, ctor)) {
|
|
3161
3147
|
options.localInstance = true;
|
|
3162
3148
|
}
|
|
3163
3149
|
if (options?.localInstance) {
|
|
@@ -3167,7 +3153,7 @@ class EndpointContext {
|
|
|
3167
3153
|
// if (className === 'TaonBaseRepository') {
|
|
3168
3154
|
const entityFn = _.first(locaInstanceConstructorArgs);
|
|
3169
3155
|
const entity = entityFn && entityFn();
|
|
3170
|
-
entityName = (entity &&
|
|
3156
|
+
entityName = (entity && ClassHelpers_getName(entity)) || '';
|
|
3171
3157
|
// console.log(`entityName `, entityName);
|
|
3172
3158
|
// }
|
|
3173
3159
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
@@ -3177,12 +3163,12 @@ class EndpointContext {
|
|
|
3177
3163
|
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
3178
3164
|
if (existed) {
|
|
3179
3165
|
// console.log(
|
|
3180
|
-
// `EXISTED ${
|
|
3166
|
+
// `EXISTED ${ClassHelpers_getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3181
3167
|
// );
|
|
3182
3168
|
return existed;
|
|
3183
3169
|
}
|
|
3184
3170
|
// console.log(
|
|
3185
|
-
// `NEW ${
|
|
3171
|
+
// `NEW ${ClassHelpers_getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3186
3172
|
// );
|
|
3187
3173
|
if (!ctxClassFn) {
|
|
3188
3174
|
throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
|
|
@@ -3208,11 +3194,11 @@ class EndpointContext {
|
|
|
3208
3194
|
*/
|
|
3209
3195
|
getInstanceBy(ctor) {
|
|
3210
3196
|
// if (!!this.__contextForControllerInstanceAccess) {
|
|
3211
|
-
// const className =
|
|
3212
|
-
// const allControllers = this.getClassFunByArr(
|
|
3197
|
+
// const className = ClassHelpers_getName(ctor);
|
|
3198
|
+
// const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3213
3199
|
// // TODO QUICK_FIX cache controllers
|
|
3214
3200
|
// for (const ctrl of allControllers) {
|
|
3215
|
-
// if (
|
|
3201
|
+
// if (ClassHelpers_getName(ctrl) === className) {
|
|
3216
3202
|
// // console.log('injecting from contextForControllerInstanceAcesss', className);
|
|
3217
3203
|
// return this.__contextForControllerInstanceAccess.inject(ctor, {
|
|
3218
3204
|
// localInstance: false,
|
|
@@ -3244,24 +3230,24 @@ class EndpointContext {
|
|
|
3244
3230
|
getClassFunBy(classType) {
|
|
3245
3231
|
this.checkIfContextInitialized();
|
|
3246
3232
|
switch (classType) {
|
|
3247
|
-
case
|
|
3233
|
+
case Models_ClassType.CONTROLLER:
|
|
3248
3234
|
return this.config.controllers;
|
|
3249
|
-
case
|
|
3235
|
+
case Models_ClassType.ENTITY:
|
|
3250
3236
|
return this.config.entities;
|
|
3251
|
-
case
|
|
3237
|
+
case Models_ClassType.PROVIDER:
|
|
3252
3238
|
return this.config.providers;
|
|
3253
|
-
case
|
|
3239
|
+
case Models_ClassType.MIDDLEWARE:
|
|
3254
3240
|
return this.config.middlewares;
|
|
3255
|
-
case
|
|
3241
|
+
case Models_ClassType.REPOSITORY:
|
|
3256
3242
|
return this.config.repositories;
|
|
3257
|
-
case
|
|
3243
|
+
case Models_ClassType.SUBSCRIBER:
|
|
3258
3244
|
return this.config.subscribers;
|
|
3259
|
-
case
|
|
3245
|
+
case Models_ClassType.MIGRATION:
|
|
3260
3246
|
return this.config.migrations;
|
|
3261
3247
|
}
|
|
3262
3248
|
}
|
|
3263
3249
|
isCLassType(classType, classFn) {
|
|
3264
|
-
return !!this.getClassFunBy(classType)[
|
|
3250
|
+
return !!this.getClassFunBy(classType)[ClassHelpers_getName(classFn)];
|
|
3265
3251
|
}
|
|
3266
3252
|
/**
|
|
3267
3253
|
* Only for injectable types
|
|
@@ -3269,14 +3255,14 @@ class EndpointContext {
|
|
|
3269
3255
|
*/
|
|
3270
3256
|
getClassFunByClassName(className) {
|
|
3271
3257
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
3272
|
-
const classesForInjectableType = this.config[
|
|
3258
|
+
const classesForInjectableType = this.config[Models_ClassTypeKey[classTypeName]];
|
|
3273
3259
|
if (classesForInjectableType[className]) {
|
|
3274
3260
|
return classesForInjectableType[className];
|
|
3275
3261
|
}
|
|
3276
3262
|
}
|
|
3277
3263
|
}
|
|
3278
3264
|
getClassFunByClass(classFunction) {
|
|
3279
|
-
const className =
|
|
3265
|
+
const className = ClassHelpers_getName(classFunction);
|
|
3280
3266
|
return this.getClassFunByClassName(className);
|
|
3281
3267
|
}
|
|
3282
3268
|
getClassFunByArr(classType) {
|
|
@@ -3295,11 +3281,11 @@ class EndpointContext {
|
|
|
3295
3281
|
]) {
|
|
3296
3282
|
const instance = DITaonContainer.resolve(classFn);
|
|
3297
3283
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
3298
|
-
const className =
|
|
3284
|
+
const className = ClassHelpers_getName(classFn);
|
|
3299
3285
|
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
3300
3286
|
classInstancesByNameObj[className] = instance;
|
|
3301
3287
|
// update config
|
|
3302
|
-
this.config[
|
|
3288
|
+
this.config[Models_ClassTypeKey[classType]][className] = classFn;
|
|
3303
3289
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
3304
3290
|
this.allClassesInstances[className] = instance;
|
|
3305
3291
|
}
|
|
@@ -3311,18 +3297,18 @@ class EndpointContext {
|
|
|
3311
3297
|
return;
|
|
3312
3298
|
}
|
|
3313
3299
|
//#region @websql
|
|
3314
|
-
for (const classFun of this.getClassFunByArr(
|
|
3315
|
-
const repo = (await this.connection.getRepository(
|
|
3316
|
-
this.repos.set(
|
|
3300
|
+
for (const classFun of this.getClassFunByArr(Models_ClassType.ENTITY)) {
|
|
3301
|
+
const repo = (await this.connection.getRepository(ClassHelpers_getOrginalClass(classFun)));
|
|
3302
|
+
this.repos.set(ClassHelpers_getName(classFun), repo);
|
|
3317
3303
|
}
|
|
3318
3304
|
//#endregion
|
|
3319
3305
|
for (const classTypeName of [
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3306
|
+
Models_ClassType.MIDDLEWARE,
|
|
3307
|
+
Models_ClassType.PROVIDER,
|
|
3308
|
+
Models_ClassType.REPOSITORY,
|
|
3309
|
+
Models_ClassType.CONTROLLER,
|
|
3310
|
+
Models_ClassType.ENTITY,
|
|
3311
|
+
Models_ClassType.MIGRATION,
|
|
3326
3312
|
]) {
|
|
3327
3313
|
//#region init class static _ property
|
|
3328
3314
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
@@ -3333,11 +3319,11 @@ class EndpointContext {
|
|
|
3333
3319
|
//#endregion
|
|
3334
3320
|
}
|
|
3335
3321
|
for (const classTypeName of [
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3322
|
+
Models_ClassType.MIDDLEWARE,
|
|
3323
|
+
Models_ClassType.PROVIDER,
|
|
3324
|
+
Models_ClassType.REPOSITORY,
|
|
3325
|
+
Models_ClassType.CONTROLLER,
|
|
3326
|
+
Models_ClassType.MIGRATION,
|
|
3341
3327
|
]) {
|
|
3342
3328
|
//#region init providers, repositories _ property
|
|
3343
3329
|
// Helpers.taskStarted(
|
|
@@ -3357,7 +3343,7 @@ class EndpointContext {
|
|
|
3357
3343
|
//#endregion
|
|
3358
3344
|
//#region methods & getters / is active on
|
|
3359
3345
|
isActiveOn(classInstance) {
|
|
3360
|
-
let contextRef = classInstance[
|
|
3346
|
+
let contextRef = classInstance[Symbols_ctxInClassOrClassObj];
|
|
3361
3347
|
return this === contextRef;
|
|
3362
3348
|
}
|
|
3363
3349
|
//#endregion
|
|
@@ -3528,11 +3514,11 @@ class EndpointContext {
|
|
|
3528
3514
|
if (this.isRemoteHost) {
|
|
3529
3515
|
return;
|
|
3530
3516
|
}
|
|
3531
|
-
const subscriberClasses = this.getClassFunByArr(
|
|
3517
|
+
const subscriberClasses = this.getClassFunByArr(Models_ClassType.SUBSCRIBER);
|
|
3532
3518
|
for (const subscriberClassFn of subscriberClasses) {
|
|
3533
|
-
const options = Reflect.getMetadata(
|
|
3519
|
+
const options = Reflect.getMetadata(Symbols_metadata.options.subscriber, subscriberClassFn);
|
|
3534
3520
|
// console.log('subscriber options', options);
|
|
3535
|
-
// const nameForSubscriber =
|
|
3521
|
+
// const nameForSubscriber = ClassHelpers_getName(subscriber);
|
|
3536
3522
|
EventSubscriber()(subscriberClassFn);
|
|
3537
3523
|
}
|
|
3538
3524
|
//#endregion
|
|
@@ -3544,13 +3530,13 @@ class EndpointContext {
|
|
|
3544
3530
|
if (this.isRemoteHost) {
|
|
3545
3531
|
return;
|
|
3546
3532
|
}
|
|
3547
|
-
const entities = this.getClassFunByArr(
|
|
3533
|
+
const entities = this.getClassFunByArr(Models_ClassType.ENTITY);
|
|
3548
3534
|
for (const entity of entities) {
|
|
3549
|
-
const options = Reflect.getMetadata(
|
|
3535
|
+
const options = Reflect.getMetadata(Symbols_metadata.options.entity, entity);
|
|
3550
3536
|
const createTable = _.isUndefined(options.createTable)
|
|
3551
3537
|
? true
|
|
3552
3538
|
: options.createTable;
|
|
3553
|
-
const nameForEntity =
|
|
3539
|
+
const nameForEntity = ClassHelpers_getName(entity);
|
|
3554
3540
|
if (createTable) {
|
|
3555
3541
|
this.logDb &&
|
|
3556
3542
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
@@ -3590,10 +3576,10 @@ class EndpointContext {
|
|
|
3590
3576
|
if (this.isRemoteHost || !this.databaseConfig) {
|
|
3591
3577
|
return;
|
|
3592
3578
|
}
|
|
3593
|
-
const entities = this.getClassFunByArr(
|
|
3594
|
-
return
|
|
3579
|
+
const entities = this.getClassFunByArr(Models_ClassType.ENTITY).map(entityFn => {
|
|
3580
|
+
return ClassHelpers_getOrginalClass(entityFn);
|
|
3595
3581
|
});
|
|
3596
|
-
const subscribers = this.getClassFunByArr(
|
|
3582
|
+
const subscribers = this.getClassFunByArr(Models_ClassType.SUBSCRIBER);
|
|
3597
3583
|
let autoSave = false;
|
|
3598
3584
|
if (!_.isNil(this.databaseConfig.autoSave)) {
|
|
3599
3585
|
autoSave = this.databaseConfig.autoSave;
|
|
@@ -3687,20 +3673,20 @@ class EndpointContext {
|
|
|
3687
3673
|
const parentsCalculatedPath = _.slice(rawConfigs, 1)
|
|
3688
3674
|
.reverse()
|
|
3689
3675
|
.map(bc => {
|
|
3690
|
-
if (
|
|
3676
|
+
if (TaonHelpers_isGoodPath(bc.path)) {
|
|
3691
3677
|
return bc.path;
|
|
3692
3678
|
}
|
|
3693
3679
|
return bc.className;
|
|
3694
3680
|
})
|
|
3695
3681
|
.join('/');
|
|
3696
3682
|
const contextNameForCommunication = this.contextNameForCommunication;
|
|
3697
|
-
if (
|
|
3683
|
+
if (TaonHelpers_isGoodPath(classConfig.path)) {
|
|
3698
3684
|
classConfig.calculatedPath = classConfig.path;
|
|
3699
3685
|
}
|
|
3700
3686
|
else {
|
|
3701
3687
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3702
3688
|
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
3703
|
-
`${
|
|
3689
|
+
`${ClassHelpers_getName(controllerClassFn)}`)
|
|
3704
3690
|
.replace(/\/\//g, '/')
|
|
3705
3691
|
.split('/')
|
|
3706
3692
|
.reduce((acc, bc) => {
|
|
@@ -3733,7 +3719,7 @@ class EndpointContext {
|
|
|
3733
3719
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3734
3720
|
return;
|
|
3735
3721
|
}
|
|
3736
|
-
const allControllers = this.getClassFunByArr(
|
|
3722
|
+
const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3737
3723
|
for (const controllerClassFn of allControllers) {
|
|
3738
3724
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
3739
3725
|
if (_.isFunction(instance.afterAllCtxInited)) {
|
|
@@ -3745,21 +3731,21 @@ class EndpointContext {
|
|
|
3745
3731
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3746
3732
|
return;
|
|
3747
3733
|
}
|
|
3748
|
-
const allControllers = this.getClassFunByArr(
|
|
3734
|
+
const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3749
3735
|
// debugger
|
|
3750
3736
|
// console.log('allControllers', allControllers);
|
|
3751
3737
|
for (const controllerClassFn of allControllers) {
|
|
3752
|
-
// console.log(
|
|
3753
|
-
// const controllerName =
|
|
3738
|
+
// console.log(ClassHelpers_getClassConfig(controllerClassFn));
|
|
3739
|
+
// const controllerName = ClassHelpers_getName(controllerClassFn);
|
|
3754
3740
|
// console.log(
|
|
3755
3741
|
// `for ${controllerName}`,
|
|
3756
|
-
//
|
|
3742
|
+
// ClassHelpers_getClassConfig(controllerClassFn),
|
|
3757
3743
|
// );
|
|
3758
|
-
controllerClassFn[
|
|
3759
|
-
|
|
3760
|
-
const rawConfigs =
|
|
3744
|
+
controllerClassFn[Symbols_classMethodsNames] =
|
|
3745
|
+
ClassHelpers_getMethodsNames(controllerClassFn);
|
|
3746
|
+
const rawConfigs = ClassHelpers_getControllerConfigs(controllerClassFn);
|
|
3761
3747
|
// console.log(controllerName, { rawConfigs });
|
|
3762
|
-
// console.log(`Class config for ${
|
|
3748
|
+
// console.log(`Class config for ${ClassHelpers_getName(controllerClassFn)}`, configs)
|
|
3763
3749
|
const classConfig = rawConfigs[0];
|
|
3764
3750
|
this.updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn);
|
|
3765
3751
|
this.mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn);
|
|
@@ -3770,7 +3756,7 @@ class EndpointContext {
|
|
|
3770
3756
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
3771
3757
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
3772
3758
|
className(middlewareClass) {
|
|
3773
|
-
return
|
|
3759
|
+
return ClassHelpers_getName(controllerClassFn);
|
|
3774
3760
|
},
|
|
3775
3761
|
});
|
|
3776
3762
|
}
|
|
@@ -3797,7 +3783,7 @@ class EndpointContext {
|
|
|
3797
3783
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
3798
3784
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
3799
3785
|
className(middlewareClass) {
|
|
3800
|
-
return
|
|
3786
|
+
return ClassHelpers_getName(controllerClassFn);
|
|
3801
3787
|
},
|
|
3802
3788
|
});
|
|
3803
3789
|
}
|
|
@@ -3820,7 +3806,7 @@ class EndpointContext {
|
|
|
3820
3806
|
: '';
|
|
3821
3807
|
const expressPath = methodConfig.global
|
|
3822
3808
|
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
3823
|
-
:
|
|
3809
|
+
: TaonHelpers_getExpressPath(classConfig, methodConfig);
|
|
3824
3810
|
//#endregion
|
|
3825
3811
|
//#region init server
|
|
3826
3812
|
// console.log({ expressPath });
|
|
@@ -3840,7 +3826,7 @@ class EndpointContext {
|
|
|
3840
3826
|
if (shouldInitClient) {
|
|
3841
3827
|
// console.log(
|
|
3842
3828
|
// 'initClient',
|
|
3843
|
-
//
|
|
3829
|
+
// ClassHelpers_getFullInternalName(controllerClassFn),
|
|
3844
3830
|
// type,
|
|
3845
3831
|
// methodConfig,
|
|
3846
3832
|
// expressPath,
|
|
@@ -3867,12 +3853,12 @@ class EndpointContext {
|
|
|
3867
3853
|
}
|
|
3868
3854
|
// const contexts: EndpointContext[] = [this];
|
|
3869
3855
|
//#region @websql
|
|
3870
|
-
const troutes =
|
|
3856
|
+
const troutes = Utils_uniqArray(this.activeRoutes.map(f => {
|
|
3871
3857
|
return `${f.method} ${f.expressPath}`;
|
|
3872
3858
|
})).map(f => {
|
|
3873
3859
|
const [method, expressPath] = f.split(' ');
|
|
3874
3860
|
return (`\n### ${_.startCase(_.last(expressPath.split('/')))}\n` +
|
|
3875
|
-
|
|
3861
|
+
TaonHelpers_fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
3876
3862
|
this.uriOrigin +
|
|
3877
3863
|
expressPath);
|
|
3878
3864
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
@@ -3905,12 +3891,12 @@ class EndpointContext {
|
|
|
3905
3891
|
//#endregion
|
|
3906
3892
|
//#region methods & getters / init middlewares
|
|
3907
3893
|
async initCustomClientMiddlewares() {
|
|
3908
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
3894
|
+
const middlewares = this.getClassesInstancesArrBy(Models_ClassType.MIDDLEWARE)
|
|
3909
3895
|
.map(f => f)
|
|
3910
3896
|
.filter(f => _.isFunction(f.interceptClient));
|
|
3911
3897
|
middlewares.forEach(middlewareInstanceName => {
|
|
3912
3898
|
const contextName = this.contextName;
|
|
3913
|
-
const interceptorName = `${contextName}-${
|
|
3899
|
+
const interceptorName = `${contextName}-${ClassHelpers_getName(middlewareInstanceName)}`;
|
|
3914
3900
|
Resource.request.interceptors.set(interceptorName, {
|
|
3915
3901
|
intercept: ({ req, next }) => {
|
|
3916
3902
|
const url = new URL(req.url);
|
|
@@ -4082,7 +4068,7 @@ class EndpointContext {
|
|
|
4082
4068
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
4083
4069
|
if (middlewareInstance &&
|
|
4084
4070
|
_.isFunction(middlewareInstance.interceptServerMethod)) {
|
|
4085
|
-
const middlewareFn =
|
|
4071
|
+
const middlewareFn = ClassHelpers_asyncHandler(async (req, res, next) => {
|
|
4086
4072
|
await middlewareInstance.interceptServerMethod({
|
|
4087
4073
|
req,
|
|
4088
4074
|
res,
|
|
@@ -4424,7 +4410,7 @@ class EndpointContext {
|
|
|
4424
4410
|
.map(f => this.getInstanceBy(f))
|
|
4425
4411
|
.filter(f => _.isFunction(f.interceptClientMethod));
|
|
4426
4412
|
middlewaresInstances.forEach(instance => {
|
|
4427
|
-
const middlewareName =
|
|
4413
|
+
const middlewareName = ClassHelpers_getName(instance);
|
|
4428
4414
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
4429
4415
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
4430
4416
|
Resource.request.methodsInterceptors.set(interceptorKey, {
|
|
@@ -4456,14 +4442,14 @@ class EndpointContext {
|
|
|
4456
4442
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
4457
4443
|
const received = new Promise(async (resolve, reject) => {
|
|
4458
4444
|
const headers = {};
|
|
4459
|
-
const { request, response } =
|
|
4445
|
+
const { request, response } = TaonHelpers_websqlMocks(headers);
|
|
4460
4446
|
//#region @browser
|
|
4461
|
-
ipcRenderer.once(
|
|
4447
|
+
ipcRenderer.once(TaonHelpers_ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
|
|
4462
4448
|
let res = responseData;
|
|
4463
4449
|
console.log({ responseData });
|
|
4464
4450
|
try {
|
|
4465
4451
|
const body = res;
|
|
4466
|
-
res = new
|
|
4452
|
+
res = new Models_HttpResponse({
|
|
4467
4453
|
body: void 0,
|
|
4468
4454
|
isArray: void 0,
|
|
4469
4455
|
method: methodConfig.type,
|
|
@@ -4479,7 +4465,7 @@ class EndpointContext {
|
|
|
4479
4465
|
reject(error);
|
|
4480
4466
|
}
|
|
4481
4467
|
});
|
|
4482
|
-
ipcRenderer.send(
|
|
4468
|
+
ipcRenderer.send(TaonHelpers_ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
4483
4469
|
//#endregion
|
|
4484
4470
|
});
|
|
4485
4471
|
received['observable'] = from(received);
|
|
@@ -4499,22 +4485,22 @@ class EndpointContext {
|
|
|
4499
4485
|
const MIN_TIMEOUT = 400;
|
|
4500
4486
|
const MIN_TIMEOUT_STEP = 200;
|
|
4501
4487
|
const globalThisVar = globalThis; // TODO not a good idea! probably should be in context
|
|
4502
|
-
const timeout = globalThisVar[
|
|
4503
|
-
let updateFun = globalThisVar[
|
|
4504
|
-
if (!globalThisVar[
|
|
4505
|
-
globalThisVar[
|
|
4506
|
-
}
|
|
4507
|
-
updateFun = globalThisVar[
|
|
4508
|
-
let startFun = globalThisVar[
|
|
4509
|
-
if (!globalThisVar[
|
|
4510
|
-
globalThisVar[
|
|
4511
|
-
}
|
|
4512
|
-
startFun = globalThisVar[
|
|
4513
|
-
let doneFun = globalThisVar[
|
|
4514
|
-
if (!globalThisVar[
|
|
4515
|
-
globalThisVar[
|
|
4516
|
-
}
|
|
4517
|
-
doneFun = globalThisVar[
|
|
4488
|
+
const timeout = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_TIMEOUT] || MIN_TIMEOUT;
|
|
4489
|
+
let updateFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN];
|
|
4490
|
+
if (!globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN]) {
|
|
4491
|
+
globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN] = new Subject();
|
|
4492
|
+
}
|
|
4493
|
+
updateFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN];
|
|
4494
|
+
let startFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_START];
|
|
4495
|
+
if (!globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_START]) {
|
|
4496
|
+
globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_START] = new Subject();
|
|
4497
|
+
}
|
|
4498
|
+
startFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_START];
|
|
4499
|
+
let doneFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_DONE];
|
|
4500
|
+
if (!globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_DONE]) {
|
|
4501
|
+
globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_DONE] = new Subject();
|
|
4502
|
+
}
|
|
4503
|
+
doneFun = globalThisVar[Symbols_old.WEBSQL_REST_PROGRESS_FUN_DONE];
|
|
4518
4504
|
let periodsToUpdate = 0;
|
|
4519
4505
|
if (timeout >= MIN_TIMEOUT) {
|
|
4520
4506
|
periodsToUpdate = Math.floor(timeout / MIN_TIMEOUT_STEP);
|
|
@@ -4550,7 +4536,7 @@ class EndpointContext {
|
|
|
4550
4536
|
// }
|
|
4551
4537
|
const received = new Promise(async (resolve, reject) => {
|
|
4552
4538
|
const headers = {};
|
|
4553
|
-
const { request, response } =
|
|
4539
|
+
const { request, response } = TaonHelpers_websqlMocks(headers);
|
|
4554
4540
|
let res;
|
|
4555
4541
|
try {
|
|
4556
4542
|
res = await Helpers.runSyncOrAsync({
|
|
@@ -4579,7 +4565,7 @@ class EndpointContext {
|
|
|
4579
4565
|
res = await res.received;
|
|
4580
4566
|
}
|
|
4581
4567
|
const body = res;
|
|
4582
|
-
res = new
|
|
4568
|
+
res = new Models_HttpResponse({
|
|
4583
4569
|
body: void 0,
|
|
4584
4570
|
isArray: void 0,
|
|
4585
4571
|
method: methodConfig.type,
|
|
@@ -4626,34 +4612,34 @@ class EndpointContext {
|
|
|
4626
4612
|
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
4627
4613
|
// const productionMode = FrameworkContext.isProductionMode;
|
|
4628
4614
|
//#region resolve frontend parameters
|
|
4629
|
-
if (!storage[
|
|
4630
|
-
storage[
|
|
4631
|
-
if (!storage[
|
|
4632
|
-
storage[
|
|
4633
|
-
const endpoints = storage[
|
|
4615
|
+
if (!storage[Symbols_old.ENDPOINT_META_CONFIG])
|
|
4616
|
+
storage[Symbols_old.ENDPOINT_META_CONFIG] = {};
|
|
4617
|
+
if (!storage[Symbols_old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4618
|
+
storage[Symbols_old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4619
|
+
const endpoints = storage[Symbols_old.ENDPOINT_META_CONFIG];
|
|
4634
4620
|
let rest;
|
|
4635
4621
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4636
4622
|
let headers = {};
|
|
4637
4623
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4638
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4624
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4639
4625
|
'Content-Type': methodConfig.contentType,
|
|
4640
4626
|
Accept: methodConfig.contentType,
|
|
4641
4627
|
}));
|
|
4642
4628
|
}
|
|
4643
4629
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4644
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4630
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4645
4631
|
'Content-Type': methodConfig.contentType,
|
|
4646
4632
|
Accept: methodConfig.contentType,
|
|
4647
4633
|
responsetypeaxios: methodConfig.responseType,
|
|
4648
4634
|
}));
|
|
4649
4635
|
}
|
|
4650
4636
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4651
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4637
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4652
4638
|
responsetypeaxios: methodConfig.responseType,
|
|
4653
4639
|
}));
|
|
4654
4640
|
}
|
|
4655
4641
|
else {
|
|
4656
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4642
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4657
4643
|
}
|
|
4658
4644
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4659
4645
|
}
|
|
@@ -4686,23 +4672,23 @@ class EndpointContext {
|
|
|
4686
4672
|
}
|
|
4687
4673
|
if (currentParam.paramType === 'Query') {
|
|
4688
4674
|
if (currentParam.paramName) {
|
|
4689
|
-
const mapping =
|
|
4675
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4690
4676
|
if (mapping) {
|
|
4691
|
-
rest.headers.set(`${
|
|
4677
|
+
rest.headers.set(`${Symbols_old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4692
4678
|
}
|
|
4693
4679
|
queryParams[currentParam.paramName] = param;
|
|
4694
4680
|
}
|
|
4695
4681
|
else {
|
|
4696
|
-
const mapping =
|
|
4682
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4697
4683
|
if (mapping) {
|
|
4698
|
-
rest.headers.set(
|
|
4684
|
+
rest.headers.set(Symbols_old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4699
4685
|
}
|
|
4700
4686
|
queryParams = _.cloneDeep(param);
|
|
4701
4687
|
}
|
|
4702
4688
|
}
|
|
4703
4689
|
if (currentParam.paramType === 'Header') {
|
|
4704
4690
|
if (currentParam.paramName) {
|
|
4705
|
-
if (currentParam.paramName ===
|
|
4691
|
+
if (currentParam.paramName === Symbols_old.MDC_KEY) {
|
|
4706
4692
|
// parese MDC
|
|
4707
4693
|
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4708
4694
|
}
|
|
@@ -4721,7 +4707,7 @@ class EndpointContext {
|
|
|
4721
4707
|
}
|
|
4722
4708
|
if (currentParam.paramType === 'Body') {
|
|
4723
4709
|
if (currentParam.paramName) {
|
|
4724
|
-
if (
|
|
4710
|
+
if (ClassHelpers_getName(bodyObject) === 'FormData') {
|
|
4725
4711
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
4726
4712
|
Use this:
|
|
4727
4713
|
// ...
|
|
@@ -4734,35 +4720,35 @@ instead
|
|
|
4734
4720
|
// ...
|
|
4735
4721
|
`);
|
|
4736
4722
|
}
|
|
4737
|
-
const mapping =
|
|
4723
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4738
4724
|
if (mapping) {
|
|
4739
|
-
rest.headers.set(`${
|
|
4725
|
+
rest.headers.set(`${Symbols_old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4740
4726
|
}
|
|
4741
4727
|
bodyObject[currentParam.paramName] = param;
|
|
4742
4728
|
}
|
|
4743
4729
|
else {
|
|
4744
|
-
const mapping =
|
|
4730
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4745
4731
|
if (mapping) {
|
|
4746
|
-
rest.headers.set(
|
|
4732
|
+
rest.headers.set(Symbols_old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
4747
4733
|
}
|
|
4748
4734
|
bodyObject = param;
|
|
4749
4735
|
}
|
|
4750
4736
|
}
|
|
4751
4737
|
});
|
|
4752
4738
|
if (typeof bodyObject === 'object' &&
|
|
4753
|
-
|
|
4739
|
+
ClassHelpers_getName(bodyObject) !== 'FormData') {
|
|
4754
4740
|
let circuralFromItem = [];
|
|
4755
4741
|
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
4756
4742
|
circuralFromItem = circs;
|
|
4757
4743
|
}));
|
|
4758
|
-
rest.headers.set(
|
|
4744
|
+
rest.headers.set(Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
4759
4745
|
}
|
|
4760
4746
|
if (typeof queryParams === 'object') {
|
|
4761
4747
|
let circuralFromQueryParams = [];
|
|
4762
4748
|
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
4763
4749
|
circuralFromQueryParams = circs;
|
|
4764
4750
|
}));
|
|
4765
|
-
rest.headers.set(
|
|
4751
|
+
rest.headers.set(Symbols_old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
4766
4752
|
}
|
|
4767
4753
|
//#endregion
|
|
4768
4754
|
const httpResultObj = {
|
|
@@ -4782,7 +4768,7 @@ instead
|
|
|
4782
4768
|
|
|
4783
4769
|
class ContextsEndpointStorage {
|
|
4784
4770
|
constructor() {
|
|
4785
|
-
this.SPECIAL_APP_READY_MESSAGE =
|
|
4771
|
+
this.SPECIAL_APP_READY_MESSAGE = CoreModels_SPECIAL_APP_READY_MESSAGE;
|
|
4786
4772
|
this.taonEndpointContexts = new Map();
|
|
4787
4773
|
// Private constructor to prevent direct instantiation
|
|
4788
4774
|
}
|
|
@@ -4891,9 +4877,9 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4891
4877
|
return classFun;
|
|
4892
4878
|
//#region old
|
|
4893
4879
|
// TODO hmmmm for now context for controller inside api service
|
|
4894
|
-
// const allContexts = Object.values(classFun[
|
|
4880
|
+
// const allContexts = Object.values(classFun[Symbols_orignalClassClonesObj] || {}).map(classFn => {
|
|
4895
4881
|
// return {
|
|
4896
|
-
// ctx: classFn[
|
|
4882
|
+
// ctx: classFn[Symbols_ctxInClassOrClassObj] as EndpointContext,
|
|
4897
4883
|
// classFn,
|
|
4898
4884
|
// }
|
|
4899
4885
|
// })
|
|
@@ -4913,7 +4899,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4913
4899
|
return await new Promise(async (resolve, reject) => {
|
|
4914
4900
|
//#region init in set timeout
|
|
4915
4901
|
setTimeout(async () => {
|
|
4916
|
-
if (
|
|
4902
|
+
if (UtilsOs_isRunningInDocker()) {
|
|
4917
4903
|
const activeContext = config?.activeContext || null;
|
|
4918
4904
|
if (_.isString(activeContext) &&
|
|
4919
4905
|
activeContext !== '' &&
|
|
@@ -4951,7 +4937,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4951
4937
|
keepWebsqlDbDataAfterReload =
|
|
4952
4938
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
4953
4939
|
if (keepWebsqlDbDataAfterReload) {
|
|
4954
|
-
!
|
|
4940
|
+
!UtilsOs_isRunningInCliMode() &&
|
|
4955
4941
|
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
4956
4942
|
`(context=${endpointContextRef.contextName}).`);
|
|
4957
4943
|
}
|
|
@@ -5029,7 +5015,7 @@ const inject = (entity) => {
|
|
|
5029
5015
|
return () => false;
|
|
5030
5016
|
}
|
|
5031
5017
|
const ctor = entity();
|
|
5032
|
-
const contextFromClass = ctor[
|
|
5018
|
+
const contextFromClass = ctor[Symbols_ctxInClassOrClassObj];
|
|
5033
5019
|
const resultContext = contextFromClass;
|
|
5034
5020
|
if (resultContext) {
|
|
5035
5021
|
let instance = resultContext.inject(ctor, {
|
|
@@ -5042,7 +5028,7 @@ const inject = (entity) => {
|
|
|
5042
5028
|
if (propName === 'getOriginalConstructor') {
|
|
5043
5029
|
return () => instance.constructor;
|
|
5044
5030
|
}
|
|
5045
|
-
const methods = ctor[
|
|
5031
|
+
const methods = ctor[Symbols_classMethodsNames] || [];
|
|
5046
5032
|
const isMethods = methods.includes(propName);
|
|
5047
5033
|
const methodOrProperty = isMethods
|
|
5048
5034
|
? instance[propName].bind(instance)
|
|
@@ -5080,7 +5066,7 @@ const inject = (entity) => {
|
|
|
5080
5066
|
// const subscriberClassFN: typeof TaonBaseClass =
|
|
5081
5067
|
// subscriberClassResolveFn() as any;
|
|
5082
5068
|
// const ctx = subscriberClassFN[
|
|
5083
|
-
//
|
|
5069
|
+
// Symbols_ctxInClassOrClassObj
|
|
5084
5070
|
// ] as EndpointContext;
|
|
5085
5071
|
// if (!ctx) {
|
|
5086
5072
|
// throw new Error(
|
|
@@ -5121,12 +5107,12 @@ const getTransformFunction = (target) => {
|
|
|
5121
5107
|
if (!target) {
|
|
5122
5108
|
return;
|
|
5123
5109
|
}
|
|
5124
|
-
// const className =
|
|
5110
|
+
// const className = ClassHelpers_getName(target)
|
|
5125
5111
|
// target = ClassHelpers.getBy(className);
|
|
5126
5112
|
if (!target) {
|
|
5127
5113
|
return void 0;
|
|
5128
5114
|
}
|
|
5129
|
-
const configs =
|
|
5115
|
+
const configs = ClassHelpers_getControllerConfigs(target);
|
|
5130
5116
|
// console.log(`CONFIGS TO CHECK`, configs)
|
|
5131
5117
|
const functions = configs
|
|
5132
5118
|
.map(c => {
|
|
@@ -5151,13 +5137,13 @@ const getTransformFunction = (target) => {
|
|
|
5151
5137
|
* @deprecated
|
|
5152
5138
|
*/
|
|
5153
5139
|
const singleTransform = (json) => {
|
|
5154
|
-
let ptarget =
|
|
5140
|
+
let ptarget = ClassHelpers_getClassFnFromObject(json);
|
|
5155
5141
|
let pbrowserTransformFn = getTransformFunction(ptarget);
|
|
5156
5142
|
if (pbrowserTransformFn) {
|
|
5157
5143
|
const newValue = pbrowserTransformFn(json);
|
|
5158
5144
|
if (!_.isObject(newValue)) {
|
|
5159
5145
|
console.error(`Please return object in transform function for class: ` +
|
|
5160
|
-
`${
|
|
5146
|
+
`${ClassHelpers_getName(json)}`);
|
|
5161
5147
|
}
|
|
5162
5148
|
else {
|
|
5163
5149
|
json = newValue;
|
|
@@ -5235,7 +5221,7 @@ class EntityProcess {
|
|
|
5235
5221
|
//#region set headers
|
|
5236
5222
|
setHeaders() {
|
|
5237
5223
|
const { include } = { include: [] };
|
|
5238
|
-
const className =
|
|
5224
|
+
const className = ClassHelpers_getName(this.data);
|
|
5239
5225
|
const doNothing = _.isNil(this.data) ||
|
|
5240
5226
|
[
|
|
5241
5227
|
'Object',
|
|
@@ -5248,10 +5234,10 @@ class EntityProcess {
|
|
|
5248
5234
|
breadthWalk: true,
|
|
5249
5235
|
include,
|
|
5250
5236
|
});
|
|
5251
|
-
this.entityMapping =
|
|
5252
|
-
this.response.set(
|
|
5237
|
+
this.entityMapping = Mapping_decode(cleaned, !this.advancedManipulation);
|
|
5238
|
+
this.response.set(Symbols_old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
|
|
5253
5239
|
if (this.advancedManipulation) {
|
|
5254
|
-
this.response.set(
|
|
5240
|
+
this.response.set(Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
|
|
5255
5241
|
}
|
|
5256
5242
|
}
|
|
5257
5243
|
}
|
|
@@ -5268,10 +5254,10 @@ class EntityProcess {
|
|
|
5268
5254
|
_.set(toSend, lodashPath, null);
|
|
5269
5255
|
}
|
|
5270
5256
|
else {
|
|
5271
|
-
const fun = getTransformFunction(
|
|
5257
|
+
const fun = getTransformFunction(ClassHelpers_getClassFnFromObject(value));
|
|
5272
5258
|
if (_.isFunction(fun)) {
|
|
5273
5259
|
_.set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
|
|
5274
|
-
const indexProp =
|
|
5260
|
+
const indexProp = ClassHelpers_getUniqueKey(value);
|
|
5275
5261
|
_.set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
|
|
5276
5262
|
// skipObject()
|
|
5277
5263
|
}
|
|
@@ -5281,7 +5267,7 @@ class EntityProcess {
|
|
|
5281
5267
|
}
|
|
5282
5268
|
}, { checkCircural: true, breadthWalk: true, include });
|
|
5283
5269
|
if (!_.isArray(this.data)) {
|
|
5284
|
-
let funParent = getTransformFunction(
|
|
5270
|
+
let funParent = getTransformFunction(ClassHelpers_getClassFnFromObject(this.data));
|
|
5285
5271
|
// if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
|
|
5286
5272
|
// console.log(`funParent !!! have fun? ${!!funParent} `)
|
|
5287
5273
|
// }
|
|
@@ -5295,12 +5281,12 @@ class EntityProcess {
|
|
|
5295
5281
|
const v = this.data[prop];
|
|
5296
5282
|
if (!((include.length > 0 && !include.includes(prop)) ||
|
|
5297
5283
|
(exclude.length > 0 && exclude.includes(prop)))) {
|
|
5298
|
-
if (
|
|
5299
|
-
_.isFunction(getTransformFunction(
|
|
5284
|
+
if (ClassHelpers_isContextClassObject(v) &&
|
|
5285
|
+
_.isFunction(getTransformFunction(ClassHelpers_getClassFnFromObject(v)))) {
|
|
5300
5286
|
toSend[prop] = {
|
|
5301
5287
|
[browserKey]: v[browserKey],
|
|
5302
5288
|
};
|
|
5303
|
-
const indexProp =
|
|
5289
|
+
const indexProp = ClassHelpers_getUniqueKey(v);
|
|
5304
5290
|
toSend[prop][indexProp] = this.data[prop][indexProp];
|
|
5305
5291
|
for (const key in v) {
|
|
5306
5292
|
if (_.isObject(v) &&
|
|
@@ -5485,7 +5471,7 @@ class TaonBaseClass {
|
|
|
5485
5471
|
console.log(overrideObjOrFn);
|
|
5486
5472
|
throw new Error('String is not supported as .clone() method argument');
|
|
5487
5473
|
}
|
|
5488
|
-
const classFn =
|
|
5474
|
+
const classFn = ClassHelpers_getClassFnFromObject(this);
|
|
5489
5475
|
if (_.isFunction(overrideObjOrFn)) {
|
|
5490
5476
|
// console.log('clone with fn');
|
|
5491
5477
|
const oldValues = (_.cloneDeep(this) || {});
|
|
@@ -5673,12 +5659,12 @@ function TaonEntity(options) {
|
|
|
5673
5659
|
return function (constructor) {
|
|
5674
5660
|
options = options || {};
|
|
5675
5661
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5676
|
-
|
|
5677
|
-
|
|
5662
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
5663
|
+
Mapping_DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
5678
5664
|
// TODO when entit metadata generator read use this
|
|
5679
|
-
|
|
5680
|
-
Reflect.defineMetadata(
|
|
5681
|
-
Reflect.defineMetadata(
|
|
5665
|
+
Mapping_DefaultModelWithMapping(void 0, {})(constructor);
|
|
5666
|
+
Reflect.defineMetadata(Symbols_metadata.options.entity, options, constructor);
|
|
5667
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5682
5668
|
//#region @websql
|
|
5683
5669
|
Entity(options?.className)(constructor);
|
|
5684
5670
|
//#endregion
|
|
@@ -5730,9 +5716,9 @@ TAON_GLOBAL_STATE = __decorate([
|
|
|
5730
5716
|
*/
|
|
5731
5717
|
function TaonController(options) {
|
|
5732
5718
|
return function (constructor) {
|
|
5733
|
-
|
|
5734
|
-
Reflect.defineMetadata(
|
|
5735
|
-
const cfg =
|
|
5719
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
5720
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5721
|
+
const cfg = ClassHelpers_ensureClassConfig(constructor);
|
|
5736
5722
|
options = options || {};
|
|
5737
5723
|
cfg.className = options.className || constructor.name;
|
|
5738
5724
|
cfg.path = options.path || '';
|
|
@@ -5742,7 +5728,7 @@ function TaonController(options) {
|
|
|
5742
5728
|
}
|
|
5743
5729
|
|
|
5744
5730
|
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
5745
|
-
const methodConfig =
|
|
5731
|
+
const methodConfig = ClassHelpers_ensureMethodConfig(target, propertyKey);
|
|
5746
5732
|
let options;
|
|
5747
5733
|
if (typeof pathOrOptions === 'object') {
|
|
5748
5734
|
options = pathOrOptions;
|
|
@@ -5793,7 +5779,7 @@ function GET(pathOrOptions, pathIsGlobal = false) {
|
|
|
5793
5779
|
* ...
|
|
5794
5780
|
* // in your taon controller
|
|
5795
5781
|
* ..Taon.Http.HTML()
|
|
5796
|
-
* sendHtmlDummyWebsite():
|
|
5782
|
+
* sendHtmlDummyWebsite(): Taon_ResponseHtml {
|
|
5797
5783
|
* return `
|
|
5798
5784
|
<html>
|
|
5799
5785
|
<head>
|
|
@@ -5843,7 +5829,7 @@ function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
|
5843
5829
|
}
|
|
5844
5830
|
|
|
5845
5831
|
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
5846
|
-
const methodCfg =
|
|
5832
|
+
const methodCfg = ClassHelpers_ensureMethodConfig(target, propertyKey);
|
|
5847
5833
|
const nameKey = name ? name : param;
|
|
5848
5834
|
// const key = name || `${param}_${parameterIndex}`;
|
|
5849
5835
|
methodCfg.parameters[nameKey] = {
|
|
@@ -5889,9 +5875,9 @@ function Body(name) {
|
|
|
5889
5875
|
*/
|
|
5890
5876
|
function TaonMiddleware(options) {
|
|
5891
5877
|
return function (constructor) {
|
|
5892
|
-
Reflect.defineMetadata(
|
|
5893
|
-
Reflect.defineMetadata(
|
|
5894
|
-
|
|
5878
|
+
Reflect.defineMetadata(Symbols_metadata.options.provider, options, constructor);
|
|
5879
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5880
|
+
ClassHelpers_setName(constructor, options?.className || constructor.name);
|
|
5895
5881
|
};
|
|
5896
5882
|
}
|
|
5897
5883
|
class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
@@ -5913,7 +5899,7 @@ class TaonBaseInjector {
|
|
|
5913
5899
|
* Current endpoint context
|
|
5914
5900
|
*/
|
|
5915
5901
|
get __endpoint_context__() {
|
|
5916
|
-
return this[
|
|
5902
|
+
return this[Symbols_ctxInClassOrClassObj];
|
|
5917
5903
|
}
|
|
5918
5904
|
/**
|
|
5919
5905
|
* get current endpoint context
|
|
@@ -5942,7 +5928,7 @@ class TaonBaseInjector {
|
|
|
5942
5928
|
localInstance: true,
|
|
5943
5929
|
locaInstanceConstructorArgs: [
|
|
5944
5930
|
() => {
|
|
5945
|
-
const classToProcess = this.ctx.allClassesInstances[
|
|
5931
|
+
const classToProcess = this.ctx.allClassesInstances[ClassHelpers_getName(cutomRepositoryClass)];
|
|
5946
5932
|
return classToProcess.entityClassResolveFn();
|
|
5947
5933
|
},
|
|
5948
5934
|
],
|
|
@@ -6017,7 +6003,7 @@ class TaonBaseInjector {
|
|
|
6017
6003
|
const contextClassInstance = this;
|
|
6018
6004
|
return new Proxy({}, {
|
|
6019
6005
|
get: (__, propName) => {
|
|
6020
|
-
const contextFromClass = ctor && ctor[
|
|
6006
|
+
const contextFromClass = ctor && ctor[Symbols_ctxInClassOrClassObj];
|
|
6021
6007
|
const resultContext = contextFromClass
|
|
6022
6008
|
? contextFromClass
|
|
6023
6009
|
: this.__endpoint_context__;
|
|
@@ -6032,17 +6018,17 @@ class TaonBaseInjector {
|
|
|
6032
6018
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6033
6019
|
});
|
|
6034
6020
|
if (!instance) {
|
|
6035
|
-
throw new Error(`Not able to inject "${
|
|
6036
|
-
`property "${propName?.toString()}" on class "${
|
|
6021
|
+
throw new Error(`Not able to inject "${ClassHelpers_getName(ctor) || ctor.name}" inside ` +
|
|
6022
|
+
`property "${propName?.toString()}" on class "${ClassHelpers_getName(this)}".
|
|
6037
6023
|
|
|
6038
|
-
Please add "${
|
|
6024
|
+
Please add "${ClassHelpers_getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6039
6025
|
|
|
6040
6026
|
`);
|
|
6041
6027
|
}
|
|
6042
6028
|
const result = typeof instance[propName] === 'function'
|
|
6043
6029
|
? instance[propName].bind(instance)
|
|
6044
6030
|
: instance[propName];
|
|
6045
|
-
// console.log(`Accessing injected "${propName?.toString()}" from "${
|
|
6031
|
+
// console.log(`Accessing injected "${propName?.toString()}" from "${ClassHelpers_getName(ctor) || ctor.name}"`,result)
|
|
6046
6032
|
return result;
|
|
6047
6033
|
}
|
|
6048
6034
|
//#region @browser
|
|
@@ -6050,7 +6036,7 @@ class TaonBaseInjector {
|
|
|
6050
6036
|
//#endregion
|
|
6051
6037
|
},
|
|
6052
6038
|
set: (__, propName, value) => {
|
|
6053
|
-
const contextFromClass = ctor && ctor[
|
|
6039
|
+
const contextFromClass = ctor && ctor[Symbols_ctxInClassOrClassObj];
|
|
6054
6040
|
const resultContext = contextFromClass
|
|
6055
6041
|
? contextFromClass
|
|
6056
6042
|
: this.__endpoint_context__;
|
|
@@ -6065,11 +6051,11 @@ class TaonBaseInjector {
|
|
|
6065
6051
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6066
6052
|
});
|
|
6067
6053
|
if (!instance) {
|
|
6068
|
-
const classNameNotResolved =
|
|
6054
|
+
const classNameNotResolved = ClassHelpers_getName(ctor) || ctor.name;
|
|
6069
6055
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
6070
|
-
`property "${propName?.toString()}" on class "${
|
|
6056
|
+
`property "${propName?.toString()}" on class "${ClassHelpers_getName(this)}".
|
|
6071
6057
|
|
|
6072
|
-
Please add "${
|
|
6058
|
+
Please add "${ClassHelpers_getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6073
6059
|
|
|
6074
6060
|
`);
|
|
6075
6061
|
}
|
|
@@ -6248,7 +6234,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6248
6234
|
let i = 0;
|
|
6249
6235
|
let httpErrorsCount = 0;
|
|
6250
6236
|
while (true) {
|
|
6251
|
-
await
|
|
6237
|
+
await UtilsTerminal_waitMilliseconds(poolingInterval);
|
|
6252
6238
|
try {
|
|
6253
6239
|
const resp = await taonRequest({
|
|
6254
6240
|
reqIndexNum: i,
|
|
@@ -6262,7 +6248,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6262
6248
|
httpErrorsCount++;
|
|
6263
6249
|
if (options.loopRequestsOnBackendError) {
|
|
6264
6250
|
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6265
|
-
error.body.json[
|
|
6251
|
+
error.body.json[CoreModels_TaonHttpErrorCustomProp];
|
|
6266
6252
|
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6267
6253
|
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6268
6254
|
const resBool = await options.loopRequestsOnBackendError({
|
|
@@ -6320,23 +6306,23 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6320
6306
|
//#region init
|
|
6321
6307
|
async _() {
|
|
6322
6308
|
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
6323
|
-
Helpers.warn(`Skipping initing CRUD controller ${
|
|
6309
|
+
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers_getName(this)} because entityClassResolveFn is not provided.`);
|
|
6324
6310
|
return;
|
|
6325
6311
|
}
|
|
6326
6312
|
let entityClassFn = this.entityClassResolveFn();
|
|
6327
6313
|
this.db = this.injectRepo(entityClassFn);
|
|
6328
6314
|
if (entityClassFn) {
|
|
6329
|
-
const configEntity = Reflect.getMetadata(
|
|
6315
|
+
const configEntity = Reflect.getMetadata(Symbols_metadata.options.entity, ClassHelpers_getClassFnFromObject(this));
|
|
6330
6316
|
if (configEntity?.createTable === false) {
|
|
6331
|
-
Helpers.warn(`Table for entity ${
|
|
6317
|
+
Helpers.warn(`Table for entity ${ClassHelpers_getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
6332
6318
|
}
|
|
6333
6319
|
}
|
|
6334
6320
|
else {
|
|
6335
|
-
Helpers.error(`Entity class not provided for controller ${
|
|
6321
|
+
Helpers.error(`Entity class not provided for controller ${ClassHelpers_getName(this)}.
|
|
6336
6322
|
|
|
6337
6323
|
Please provide entity as class property entityClassFn:
|
|
6338
6324
|
|
|
6339
|
-
class ${
|
|
6325
|
+
class ${ClassHelpers_getName(this)} extends TaonBaseCrudController<Entity> {
|
|
6340
6326
|
// ...
|
|
6341
6327
|
entityClassResolveFn = ()=> MyEntityClass;
|
|
6342
6328
|
// ...
|
|
@@ -6355,7 +6341,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6355
6341
|
if (model === void 0) {
|
|
6356
6342
|
return;
|
|
6357
6343
|
}
|
|
6358
|
-
|
|
6344
|
+
Validators_preventUndefinedModel(model, id);
|
|
6359
6345
|
let value = model[property];
|
|
6360
6346
|
let result;
|
|
6361
6347
|
if (_.isString(value) || _.isArray(value)) {
|
|
@@ -6389,7 +6375,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6389
6375
|
take: take,
|
|
6390
6376
|
skip: skip,
|
|
6391
6377
|
});
|
|
6392
|
-
response?.setHeader(
|
|
6378
|
+
response?.setHeader(Symbols_old.X_TOTAL_COUNT, total);
|
|
6393
6379
|
// const lastPage = Math.ceil(total / take);
|
|
6394
6380
|
// const nextPage = page + 1 > lastPage ? null : page + 1;
|
|
6395
6381
|
// const prevPage = page - 1 < 1 ? null : page - 1;
|
|
@@ -6410,7 +6396,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6410
6396
|
return async (request, response) => {
|
|
6411
6397
|
if (this.db.repositoryExists) {
|
|
6412
6398
|
const { models, totalCount } = await this.db.getAll();
|
|
6413
|
-
response?.setHeader(
|
|
6399
|
+
response?.setHeader(Symbols_old.X_TOTAL_COUNT, totalCount);
|
|
6414
6400
|
return models;
|
|
6415
6401
|
}
|
|
6416
6402
|
return [];
|
|
@@ -6607,9 +6593,9 @@ TaonBaseCrudController = __decorate([
|
|
|
6607
6593
|
*/
|
|
6608
6594
|
function TaonRepository(options) {
|
|
6609
6595
|
return function (constructor) {
|
|
6610
|
-
Reflect.defineMetadata(
|
|
6611
|
-
Reflect.defineMetadata(
|
|
6612
|
-
|
|
6596
|
+
Reflect.defineMetadata(Symbols_metadata.options.repository, options, constructor);
|
|
6597
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
6598
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
6613
6599
|
};
|
|
6614
6600
|
}
|
|
6615
6601
|
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
@@ -6639,7 +6625,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6639
6625
|
if (!this.__dbQuery) {
|
|
6640
6626
|
if (!this.ctx) {
|
|
6641
6627
|
return; // TODO
|
|
6642
|
-
throw new Error(`[TaonBaseRepository] Context not inited for class ${
|
|
6628
|
+
throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers_getName(this)}`);
|
|
6643
6629
|
}
|
|
6644
6630
|
const connection = this.ctx?.connection;
|
|
6645
6631
|
if (!connection) {
|
|
@@ -6665,7 +6651,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6665
6651
|
return this[this.REPOS_CACHE_KEY];
|
|
6666
6652
|
}
|
|
6667
6653
|
const resolvedRepoClass = this.entityClassResolveFn();
|
|
6668
|
-
const resolvedRepoName =
|
|
6654
|
+
const resolvedRepoName = ClassHelpers_getName(resolvedRepoClass);
|
|
6669
6655
|
const repo = this.ctx.repos.get(resolvedRepoName);
|
|
6670
6656
|
// TODO better recognize what is class in context
|
|
6671
6657
|
if (!repo) {
|
|
@@ -6847,7 +6833,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6847
6833
|
where: { id: idOrEntity },
|
|
6848
6834
|
});
|
|
6849
6835
|
if (!deletedEntity) {
|
|
6850
|
-
Helpers.warn(`[TaonBaseRepository] Entity "${
|
|
6836
|
+
Helpers.warn(`[TaonBaseRepository] Entity "${ClassHelpers_getName(this.repo.target)}" ` + `with id ${idOrEntity} not found, cannot remove`);
|
|
6851
6837
|
return;
|
|
6852
6838
|
}
|
|
6853
6839
|
const idCopy = deletedEntity.id;
|
|
@@ -7207,7 +7193,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7207
7193
|
//#region @websqlFunc
|
|
7208
7194
|
// console.log('repo', this.__repository);
|
|
7209
7195
|
// console.log(
|
|
7210
|
-
// `repo taget name "${
|
|
7196
|
+
// `repo taget name "${ClassHelpers_getName(this.__repository.target)}"`,
|
|
7211
7197
|
// );
|
|
7212
7198
|
// debugger;
|
|
7213
7199
|
const totalCount = await this.repo.count();
|
|
@@ -7233,17 +7219,16 @@ TaonBaseRepository = __decorate([
|
|
|
7233
7219
|
__metadata("design:paramtypes", [Function])
|
|
7234
7220
|
], TaonBaseRepository);
|
|
7235
7221
|
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
})(TaonGlobalStateUtils || (TaonGlobalStateUtils = {}));
|
|
7222
|
+
//namespace TaonGlobalStateUtils
|
|
7223
|
+
// export function isActive(state: string): state is TaonGlobalStateStatus {
|
|
7224
|
+
// return state === 'active';
|
|
7225
|
+
// }
|
|
7226
|
+
const TaonGlobalStateUtils_assertAllowedTransition = (from, to) => {
|
|
7227
|
+
if (!allowedTaonGlobalStatusOrders[from]?.includes(to)) {
|
|
7228
|
+
throw new Error(`Invalid state transition: ${from} → ${to}`);
|
|
7229
|
+
}
|
|
7230
|
+
};
|
|
7231
|
+
//end of namespace TaonGlobalStateUtils
|
|
7247
7232
|
|
|
7248
7233
|
//#region imports
|
|
7249
7234
|
//#endregion
|
|
@@ -7273,7 +7258,7 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
|
|
|
7273
7258
|
async transitionTo(next) {
|
|
7274
7259
|
//#region @websqlFunc
|
|
7275
7260
|
const current = await this.getLastStatus();
|
|
7276
|
-
|
|
7261
|
+
TaonGlobalStateUtils_assertAllowedTransition(current.status, next);
|
|
7277
7262
|
const newState = this.create({ status: next });
|
|
7278
7263
|
await this.save(newState);
|
|
7279
7264
|
return newState;
|
|
@@ -7340,9 +7325,9 @@ class TaonBaseProvider extends TaonBaseInjector {
|
|
|
7340
7325
|
*/
|
|
7341
7326
|
function TaonProvider(options) {
|
|
7342
7327
|
return function (constructor) {
|
|
7343
|
-
Reflect.defineMetadata(
|
|
7344
|
-
Reflect.defineMetadata(
|
|
7345
|
-
|
|
7328
|
+
Reflect.defineMetadata(Symbols_metadata.options.provider, options, constructor);
|
|
7329
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
7330
|
+
ClassHelpers_setName(constructor, options?.className || constructor.name);
|
|
7346
7331
|
};
|
|
7347
7332
|
}
|
|
7348
7333
|
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
@@ -7373,9 +7358,9 @@ TaonGlobalStateMiddleware = __decorate([
|
|
|
7373
7358
|
*/
|
|
7374
7359
|
function TaonSubscriber(options) {
|
|
7375
7360
|
return function (constructor) {
|
|
7376
|
-
Reflect.defineMetadata(
|
|
7377
|
-
Reflect.defineMetadata(
|
|
7378
|
-
|
|
7361
|
+
Reflect.defineMetadata(Symbols_metadata.options.subscriber, options, constructor);
|
|
7362
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
7363
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
7379
7364
|
};
|
|
7380
7365
|
}
|
|
7381
7366
|
class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
@@ -7583,13 +7568,13 @@ class TaonBaseMigration extends TaonBaseInjector {
|
|
|
7583
7568
|
return true;
|
|
7584
7569
|
}
|
|
7585
7570
|
getDescription() {
|
|
7586
|
-
return _.startCase(
|
|
7571
|
+
return _.startCase(ClassHelpers_getName(this));
|
|
7587
7572
|
}
|
|
7588
7573
|
async up(queryRunner) {
|
|
7589
|
-
console.log(`[TaonBaseMigration] Running migration UP "${
|
|
7574
|
+
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers_getName(this)}"`);
|
|
7590
7575
|
}
|
|
7591
7576
|
async down(queryRunner) {
|
|
7592
|
-
console.log(`[TaonBaseMigration] Running migration DOWN "${
|
|
7577
|
+
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers_getName(this)}"`);
|
|
7593
7578
|
}
|
|
7594
7579
|
}
|
|
7595
7580
|
|
|
@@ -7748,7 +7733,7 @@ function typeFromEntity(component, entity) {
|
|
|
7748
7733
|
if (isArray) {
|
|
7749
7734
|
entity = _.first(entity);
|
|
7750
7735
|
}
|
|
7751
|
-
let name =
|
|
7736
|
+
let name = ClassHelpers_getName(component);
|
|
7752
7737
|
let res = { name, component, entity, isArray };
|
|
7753
7738
|
// console.log(res);
|
|
7754
7739
|
return res;
|
|
@@ -7770,7 +7755,7 @@ function RegisterComponentType(className, ...optionslNames) {
|
|
|
7770
7755
|
RegisterComponentType.prototype.types = [];
|
|
7771
7756
|
}
|
|
7772
7757
|
return function (target, propertyKey, descriptor) {
|
|
7773
|
-
|
|
7758
|
+
ClassHelpers_setName(target, className);
|
|
7774
7759
|
RegisterComponentType.prototype.types.push(typeFromEntity(target));
|
|
7775
7760
|
optionslNames.forEach(name => {
|
|
7776
7761
|
RegisterComponentType.prototype.types.push(typeFromName(target, name));
|
|
@@ -7792,7 +7777,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7792
7777
|
if (level === maxLevel) {
|
|
7793
7778
|
return [];
|
|
7794
7779
|
}
|
|
7795
|
-
const mapping =
|
|
7780
|
+
const mapping = Mapping_getModelsMapping(target);
|
|
7796
7781
|
// console.log('mapping', mapping)
|
|
7797
7782
|
const fieldNames = CLASS.describeProperites(target);
|
|
7798
7783
|
const checkExclude = _.isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
@@ -7989,90 +7974,90 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7989
7974
|
return fields.filter(f => !!f);
|
|
7990
7975
|
}
|
|
7991
7976
|
|
|
7977
|
+
//end of namespace RealtimeModels
|
|
7978
|
+
|
|
7992
7979
|
/**
|
|
7993
7980
|
* Migration decorator
|
|
7994
7981
|
*/
|
|
7995
7982
|
function TaonMigration(options) {
|
|
7996
7983
|
return function (constructor) {
|
|
7997
|
-
Reflect.defineMetadata(
|
|
7998
|
-
Reflect.defineMetadata(
|
|
7999
|
-
|
|
7984
|
+
Reflect.defineMetadata(Symbols_metadata.options.migration, options, constructor);
|
|
7985
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
7986
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
8000
7987
|
};
|
|
8001
7988
|
}
|
|
8002
7989
|
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
8003
7990
|
}
|
|
8004
7991
|
|
|
8005
7992
|
// TODO export all things
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
body.style.backgroundColor = '';
|
|
8020
|
-
}
|
|
8021
|
-
resolve();
|
|
8022
|
-
}, afterMS);
|
|
8023
|
-
});
|
|
8024
|
-
};
|
|
8025
|
-
Taon.error = (opt) => {
|
|
8026
|
-
throw () => {
|
|
8027
|
-
if (typeof opt === 'string') {
|
|
8028
|
-
opt = {
|
|
8029
|
-
message: opt,
|
|
8030
|
-
};
|
|
7993
|
+
//namespace Taon
|
|
7994
|
+
/**
|
|
7995
|
+
* Remove global taon loader from env.ts [loading.preAngularBootstrap]
|
|
7996
|
+
*/
|
|
7997
|
+
const Taon_removeLoader = (afterMS = 0) => {
|
|
7998
|
+
return new Promise(resolve => {
|
|
7999
|
+
setTimeout(() => {
|
|
8000
|
+
globalThis?.window?.document
|
|
8001
|
+
?.getElementById('taonpreloadertoremove')
|
|
8002
|
+
?.remove();
|
|
8003
|
+
const body = globalThis?.window?.document?.body;
|
|
8004
|
+
if (body && body.style) {
|
|
8005
|
+
body.style.backgroundColor = '';
|
|
8031
8006
|
}
|
|
8032
|
-
|
|
8033
|
-
};
|
|
8034
|
-
};
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8045
|
-
//#endregion
|
|
8046
|
-
//#region aliases to helpers
|
|
8047
|
-
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|
|
8048
|
-
Taon.isNode = coreHelpers.Helpers.isNode;
|
|
8049
|
-
Taon.isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
8050
|
-
Taon.isElectron = coreHelpers.Helpers.isElectron;
|
|
8051
|
-
//#endregion
|
|
8052
|
-
Taon.createContext = createContext;
|
|
8053
|
-
Taon.createContextTemplate = createContextTemplate;
|
|
8054
|
-
Taon.inject = inject;
|
|
8055
|
-
Taon.symbols = Symbols;
|
|
8056
|
-
/**
|
|
8057
|
-
* @deprecated
|
|
8058
|
-
* use createContext instead
|
|
8059
|
-
*/
|
|
8060
|
-
Taon.init = async (options) => {
|
|
8061
|
-
const TaonBaseContext = (await Promise.resolve().then(function () { return baseContext; }))
|
|
8062
|
-
.TaonBaseContext;
|
|
8063
|
-
const context = Taon.createContext(() => ({
|
|
8064
|
-
appId: 'default-app-not-used-anymore',
|
|
8065
|
-
contextName: 'default',
|
|
8066
|
-
host: options.host,
|
|
8067
|
-
contexts: { TaonBaseContext },
|
|
8068
|
-
database: true,
|
|
8069
|
-
entities: Array.from(options.entities),
|
|
8070
|
-
controllers: Array.from(options.controllers),
|
|
8071
|
-
}));
|
|
8072
|
-
await context.initialize();
|
|
8073
|
-
return context;
|
|
8007
|
+
resolve();
|
|
8008
|
+
}, afterMS);
|
|
8009
|
+
});
|
|
8010
|
+
};
|
|
8011
|
+
const Taon_error = (opt) => {
|
|
8012
|
+
throw () => {
|
|
8013
|
+
if (typeof opt === 'string') {
|
|
8014
|
+
opt = {
|
|
8015
|
+
message: opt,
|
|
8016
|
+
};
|
|
8017
|
+
}
|
|
8018
|
+
return opt;
|
|
8074
8019
|
};
|
|
8075
|
-
}
|
|
8020
|
+
};
|
|
8021
|
+
const Taon_getResponseValue = getResponseValue;
|
|
8022
|
+
//#region class decorators
|
|
8023
|
+
// TODO new 5.8 typescript is not allowing this
|
|
8024
|
+
// export import Controller = controllerDecorator.TaonController;
|
|
8025
|
+
// export import Entity = entityDecorator.TaonEntity;
|
|
8026
|
+
// export import Provider = providerDecorator.TaonProvider;
|
|
8027
|
+
// export import Repository = repositoryDecorator.TaonRepository;
|
|
8028
|
+
// export import Subscriber = subscriberDecorator.TaonSubscriber;
|
|
8029
|
+
// export import Migration = migrationDecorator.TaonMigration;
|
|
8030
|
+
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8031
|
+
//#endregion
|
|
8032
|
+
//#region aliases to helpers
|
|
8033
|
+
const Taon_isBrowser = coreHelpers.Helpers.isBrowser;
|
|
8034
|
+
const Taon_isNode = coreHelpers.Helpers.isNode;
|
|
8035
|
+
const Taon_isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
8036
|
+
const Taon_isElectron = coreHelpers.Helpers.isElectron;
|
|
8037
|
+
//#endregion
|
|
8038
|
+
const Taon_createContext = createContext;
|
|
8039
|
+
const Taon_createContextTemplate = createContextTemplate;
|
|
8040
|
+
const Taon_inject = inject;
|
|
8041
|
+
/**
|
|
8042
|
+
* @deprecated
|
|
8043
|
+
* use createContext instead
|
|
8044
|
+
*/
|
|
8045
|
+
const Taon_init = async (options) => {
|
|
8046
|
+
const TaonBaseContext = (await Promise.resolve().then(function () { return baseContext; }))
|
|
8047
|
+
.TaonBaseContext;
|
|
8048
|
+
const context = Taon_createContext(() => ({
|
|
8049
|
+
appId: 'default-app-not-used-anymore',
|
|
8050
|
+
contextName: 'default',
|
|
8051
|
+
host: options.host,
|
|
8052
|
+
contexts: { TaonBaseContext },
|
|
8053
|
+
database: true,
|
|
8054
|
+
entities: Array.from(options.entities),
|
|
8055
|
+
controllers: Array.from(options.controllers),
|
|
8056
|
+
}));
|
|
8057
|
+
await context.initialize();
|
|
8058
|
+
return context;
|
|
8059
|
+
};
|
|
8060
|
+
//end of namespace Taon
|
|
8076
8061
|
//#region taon flattening map
|
|
8077
8062
|
const TAON_FLATTEN_MAPPING = {
|
|
8078
8063
|
'taon/src': {
|
|
@@ -8194,5 +8179,5 @@ const TAON_FLATTEN_MAPPING = {
|
|
|
8194
8179
|
* Generated bundle index. Do not edit.
|
|
8195
8180
|
*/
|
|
8196
8181
|
|
|
8197
|
-
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL,
|
|
8182
|
+
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers_asyncHandler, ClassHelpers_ensureClassConfig, ClassHelpers_ensureMethodConfig, ClassHelpers_getClassConfig, ClassHelpers_getClassFnFromObject, ClassHelpers_getControllerConfigs, ClassHelpers_getFullInternalName, ClassHelpers_getMethodsNames, ClassHelpers_getName, ClassHelpers_getOrginalClass, ClassHelpers_getUniqueKey, ClassHelpers_hasParentClassWithName, ClassHelpers_isContextClassObject, ClassHelpers_setName, ContextDbMigrations, ContextsEndpointStorage, ControllerConfig, Cookie, DELETE, DITaonContainer, DateTimeColumn, DecimalNumberColumn, DecoratorAbstractOpt, EndpointContext, EntityProcess, FormlyHorizontalWrapper, GET, HEAD, HTML, Header, MethodConfig, MockNamespaceIpc, MockServerIpc, MockSocketIpc, Models_ClassType, Models_ClassTypeKey, Models_DatabaseConfig, Models_DatabaseConfigTypeOrm, Models_DatabasesFolder, NumberColumn, PATCH, POST, PUT, ParamConfig, Path, Query, RealtimeClient, RealtimeCore, RealtimeServer, RealtimeStrategy, RealtimeStrategyIpc, RealtimeStrategyMock, RealtimeStrategySocketIO, RealtimeSubsManager, RegisterComponentType, RegisterComponentTypeForEntity, RepeatTypeComponent, SimpleJsonColumn, String100Column, String200Column, String20Column, String45Column, String500Column, StringColumn, Symbols_REALTIME, Symbols_classMethodsNames, Symbols_classNameStaticProperty, Symbols_ctxInClassOrClassObj, Symbols_fullClassNameStaticProperty, Symbols_metadata, Symbols_old, Symbols_orignalClass, Symbols_orignalClassClonesObj, TAON_CONTEXT, TAON_FLATTEN_MAPPING, TaonAdminService, TaonBaseAbstractEntity, TaonBaseAngularService, TaonBaseClass, TaonBaseContext, TaonBaseController, TaonBaseCrudController, TaonBaseCustomRepository, TaonBaseEntity, TaonBaseFileUploadMiddleware, TaonBaseInjector, TaonBaseMiddleware, TaonBaseMigration, TaonBaseProvider, TaonBaseRepository, TaonBaseSubscriberForEntity, TaonController, TaonControllerOptions, TaonEntity, TaonEntityKeysToOmitArr, TaonEntityOptions, TaonHelpers_defaultType, TaonHelpers_fillUpTo, TaonHelpers_firstStringOrElemFromArray, TaonHelpers_getExpressPath, TaonHelpers_ipcKeyNameRequest, TaonHelpers_ipcKeyNameResponse, TaonHelpers_isGoodPath, TaonHelpers_isPlainFileOrFolder, TaonHelpers_parseJSONwithStringJSONs, TaonHelpers_tryTransformParam, TaonHelpers_websqlMocks, TaonMiddleware, TaonMiddlewareOptions, TaonMigration, TaonMigrationOptions, TaonProvider, TaonProviderOptions, TaonRepository, TaonRepositoryOptions, TaonRestResponseWrapper, TaonSubscriber, TaonSubscriberOptions, TaonTempDatabasesFolder, TaonTempRoutesFolder, Taon_createContext, Taon_createContextTemplate, Taon_error, Taon_getResponseValue, Taon_init, Taon_inject, Taon_isBrowser, Taon_isElectron, Taon_isNode, Taon_isWebSQL, Taon_removeLoader, Validators_checkIfMethodsWithReponseTYpeAlowed, Validators_classNameVlidation, Validators_preventUndefinedModel, Validators_validateClassFunctions, apiPrefix, cloneObj, controllerConfigFrom, createContext, createContextTemplate, findTypeForEntity, getFromlyConfigFor, getRegisteredComponents, getResponseValue, getTransformFunction, inject, singleTransform, typeFromEntity, typeFromName };
|
|
8198
8183
|
//# sourceMappingURL=taon-websql.mjs.map
|