taon 21.0.34 → 21.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +3 -3
- package/browser-prod/fesm2022/taon-browser.mjs +315 -315
- package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-browser.d.ts +145 -145
- package/browser-prod.split-namespaces.json +162 -162
- package/icon-menu-taon.svg +15 -15
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/migrations/index.d.ts +1 -0
- package/lib/migrations/index.js +19 -0
- package/lib/migrations/index.js.map +1 -0
- package/lib/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib/migrations/migrations_index._auto-generated_.js +4 -0
- package/lib/migrations/migrations_index._auto-generated_.js.map +1 -0
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-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 -5
- 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 -8
- 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 -3
- 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 -14
- 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/get-response-value.js.map +1 -1
- 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.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 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +3 -3
- 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.utils.d.ts +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +2 -2
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -1
- package/lib-prod/helpers/class-helpers.d.ts +14 -14
- package/lib-prod/helpers/class-helpers.js +54 -54
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.d.ts +11 -11
- package/lib-prod/helpers/taon-helpers.js +26 -26
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.d.ts +17 -17
- package/lib-prod/index.js +16 -16
- 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/migrations/index.d.ts +1 -0
- package/lib-prod/migrations/index.js +19 -0
- package/lib-prod/migrations/index.js.map +1 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js +4 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js.map +1 -0
- package/lib-prod/models.d.ts +37 -37
- package/lib-prod/models.js +25 -25
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/package.json +1 -1
- 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 +3 -3
- package/lib-prod/symbols.d.ts +9 -9
- package/lib-prod/symbols.js +10 -10
- 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 -4
- package/lib-prod/validators.js +9 -9
- package/lib-prod/validators.js.map +1 -1
- package/lib-prod.split-namespaces.json +164 -164
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +3 -3
- package/websql-prod/fesm2022/taon-websql.mjs +389 -389
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-websql.d.ts +146 -146
- package/websql-prod.split-namespaces.json +164 -164
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/websql-prod';
|
|
3
|
-
import { _,
|
|
3
|
+
import { _, Utils__NS__uniqArray, UtilsMigrations__NS__isValidTimestamp, Helpers, UtilsMigrations__NS__getTimestampFromClassName, UtilsOs__NS__isRunningInDocker, UtilsOs__NS__isElectron, crossPlatformPath, config, CoreModels__NS__SPECIAL_APP_READY_MESSAGE, UtilsOs__NS__isRunningInCliMode, UtilsTerminal__NS__waitMilliseconds, CoreModels__NS__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, Resource,
|
|
7
|
+
import { RestResponseWrapper, Resource, Models__NS__HttpResponse, RestHeaders, Mapping__NS__decode, Mapping__NS__DefaultModelWithMapping, HttpResponseError, Mapping__NS__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';
|
|
@@ -75,36 +75,36 @@ const BaseTaonClassesNames = [
|
|
|
75
75
|
const TaonTempDatabasesFolder = 'databases';
|
|
76
76
|
const TaonTempRoutesFolder = 'routes';
|
|
77
77
|
//namespace Models
|
|
78
|
-
const
|
|
78
|
+
const Models__NS__DatabasesFolder = TaonTempDatabasesFolder;
|
|
79
79
|
//#region models / class types
|
|
80
|
-
var
|
|
81
|
-
(function (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})(
|
|
90
|
-
const
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
80
|
+
var Models__NS__ClassType;
|
|
81
|
+
(function (Models__NS__ClassType) {
|
|
82
|
+
Models__NS__ClassType["ENTITY"] = "ENTITY";
|
|
83
|
+
Models__NS__ClassType["CONTROLLER"] = "CONTROLLER";
|
|
84
|
+
Models__NS__ClassType["REPOSITORY"] = "REPOSITORY";
|
|
85
|
+
Models__NS__ClassType["PROVIDER"] = "PROVIDER";
|
|
86
|
+
Models__NS__ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
87
|
+
Models__NS__ClassType["MIGRATION"] = "MIGRATION";
|
|
88
|
+
Models__NS__ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
89
|
+
})(Models__NS__ClassType || (Models__NS__ClassType = {}));
|
|
90
|
+
const Models__NS__ClassTypeKey = {
|
|
91
|
+
[Models__NS__ClassType.ENTITY]: 'entities',
|
|
92
|
+
[Models__NS__ClassType.CONTROLLER]: 'controllers',
|
|
93
|
+
[Models__NS__ClassType.REPOSITORY]: 'repositories',
|
|
94
|
+
[Models__NS__ClassType.PROVIDER]: 'providers',
|
|
95
|
+
[Models__NS__ClassType.SUBSCRIBER]: 'subscribers',
|
|
96
|
+
[Models__NS__ClassType.MIGRATION]: 'migrations',
|
|
97
|
+
[Models__NS__ClassType.MIDDLEWARE]: 'middlewares',
|
|
98
98
|
};
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region models / database connection options
|
|
101
|
-
class
|
|
101
|
+
class Models__NS__DatabaseConfigTypeOrm {
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region models / database config
|
|
105
|
-
class
|
|
105
|
+
class Models__NS__DatabaseConfig extends Models__NS__DatabaseConfigTypeOrm {
|
|
106
106
|
static from(databasePartialConfig) {
|
|
107
|
-
return _.merge(new
|
|
107
|
+
return _.merge(new Models__NS__DatabaseConfig(), databasePartialConfig);
|
|
108
108
|
}
|
|
109
109
|
get databaseConfigTypeORM() {
|
|
110
110
|
//#region @websqlFunc
|
|
@@ -224,14 +224,14 @@ class Realtime {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
//namespace Symbols
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
const
|
|
227
|
+
const Symbols__NS__ctxInClassOrClassObj = Symbol();
|
|
228
|
+
const Symbols__NS__classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
229
|
+
const Symbols__NS__fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
230
|
+
const Symbols__NS__orignalClass = OrignalClassKey;
|
|
231
|
+
const Symbols__NS__orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
232
|
+
const Symbols__NS__classMethodsNames = `$$classMethodsNames$$`;
|
|
233
|
+
const Symbols__NS__REALTIME = new Realtime();
|
|
234
|
+
const Symbols__NS__metadata = {
|
|
235
235
|
className: `class:realname`,
|
|
236
236
|
options: {
|
|
237
237
|
controller: `controller:options`,
|
|
@@ -242,7 +242,7 @@ const Symbols_metadata = {
|
|
|
242
242
|
migration: `migration:options`,
|
|
243
243
|
},
|
|
244
244
|
};
|
|
245
|
-
const
|
|
245
|
+
const Symbols__NS__old = {
|
|
246
246
|
HAS_TABLE_IN_DB: Symbol(),
|
|
247
247
|
MDC_KEY: `modeldataconfig`,
|
|
248
248
|
WEBSQL_REST_PROGRESS_FUN: Symbol(),
|
|
@@ -269,7 +269,7 @@ const Symbols_old = {
|
|
|
269
269
|
|
|
270
270
|
//namespace Validators
|
|
271
271
|
//#region vlidate class name
|
|
272
|
-
const
|
|
272
|
+
const Validators__NS__classNameVlidation = (className, target) => {
|
|
273
273
|
setTimeout(() => {
|
|
274
274
|
// console.log(`check after timeout ${className} , production mode: ${FrameworkContext.isProductionMode}`)
|
|
275
275
|
if (_.isUndefined(className)) {
|
|
@@ -296,7 +296,7 @@ const Validators_classNameVlidation = (className, target) => {
|
|
|
296
296
|
};
|
|
297
297
|
//#endregion
|
|
298
298
|
//#region validate method config
|
|
299
|
-
const
|
|
299
|
+
const Validators__NS__checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
300
300
|
const defaultResponseType = 'text or JSON';
|
|
301
301
|
if (!current.responseType) {
|
|
302
302
|
return;
|
|
@@ -319,7 +319,7 @@ const Validators_checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region validate class functions
|
|
321
321
|
// TODO
|
|
322
|
-
const
|
|
322
|
+
const Validators__NS__validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
323
323
|
if (_.isArray(controllers) &&
|
|
324
324
|
controllers.filter(f => !_.isFunction(f)).length > 0) {
|
|
325
325
|
console.error('controllers', controllers);
|
|
@@ -340,7 +340,7 @@ const Validators_validateClassFunctions = (controllers, entities, proviers, repo
|
|
|
340
340
|
}
|
|
341
341
|
};
|
|
342
342
|
//#endregion
|
|
343
|
-
const
|
|
343
|
+
const Validators__NS__preventUndefinedModel = (model, id) => {
|
|
344
344
|
if (_.isUndefined(model)) {
|
|
345
345
|
throw `Bad update by id, config, id: ${id}`;
|
|
346
346
|
}
|
|
@@ -355,7 +355,7 @@ const Validators_preventUndefinedModel = (model, id) => {
|
|
|
355
355
|
/**
|
|
356
356
|
* TODO - repalce in every place when getting class fn from object
|
|
357
357
|
*/
|
|
358
|
-
const
|
|
358
|
+
const ClassHelpers__NS__getClassFnFromObject = (json) => {
|
|
359
359
|
if (_.isUndefined(json) || _.isNull(json)) {
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
@@ -369,7 +369,7 @@ const ClassHelpers_getClassFnFromObject = (json) => {
|
|
|
369
369
|
};
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region get name
|
|
372
|
-
const
|
|
372
|
+
const ClassHelpers__NS__getName = (classFnOrObject) => {
|
|
373
373
|
// exception for FormData
|
|
374
374
|
if (classFnOrObject instanceof FormData) {
|
|
375
375
|
return 'FormData';
|
|
@@ -378,42 +378,42 @@ const ClassHelpers_getName = (classFnOrObject) => {
|
|
|
378
378
|
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
379
379
|
throw new Error(`Cannot get name from this object or class.`);
|
|
380
380
|
}
|
|
381
|
-
return ((classFnOrObject[
|
|
382
|
-
? classFnOrObject[
|
|
383
|
-
: classFnOrObject?.constructor[
|
|
381
|
+
return ((classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
382
|
+
? classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
383
|
+
: classFnOrObject?.constructor[Symbols__NS__classNameStaticProperty]) ||
|
|
384
384
|
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
385
385
|
};
|
|
386
386
|
//#endregion
|
|
387
|
-
const
|
|
388
|
-
const org = classFnOrObject[
|
|
387
|
+
const ClassHelpers__NS__getOrginalClass = (classFnOrObject) => {
|
|
388
|
+
const org = classFnOrObject[Symbols__NS__orignalClass];
|
|
389
389
|
if (!org) {
|
|
390
390
|
return classFnOrObject;
|
|
391
391
|
}
|
|
392
|
-
return
|
|
392
|
+
return ClassHelpers__NS__getOrginalClass(org);
|
|
393
393
|
};
|
|
394
394
|
//#region get full internal name
|
|
395
|
-
const
|
|
395
|
+
const ClassHelpers__NS__getFullInternalName = (classFnOrObject) => {
|
|
396
396
|
// exception for FormData
|
|
397
397
|
if (!classFnOrObject) {
|
|
398
398
|
throw new Error(`Cannot get name from: ${classFnOrObject}`);
|
|
399
399
|
}
|
|
400
|
-
return ((classFnOrObject[
|
|
401
|
-
? classFnOrObject[
|
|
402
|
-
: classFnOrObject?.constructor[
|
|
400
|
+
return ((classFnOrObject[Symbols__NS__fullClassNameStaticProperty]
|
|
401
|
+
? classFnOrObject[Symbols__NS__fullClassNameStaticProperty]
|
|
402
|
+
: classFnOrObject?.constructor[Symbols__NS__fullClassNameStaticProperty]) ||
|
|
403
403
|
void 0);
|
|
404
404
|
};
|
|
405
405
|
//#endregion
|
|
406
406
|
//#region get unique key
|
|
407
|
-
const
|
|
407
|
+
const ClassHelpers__NS__getUniqueKey = (classFnOrObject) => {
|
|
408
408
|
const classFn = _.isFunction(classFnOrObject)
|
|
409
409
|
? classFnOrObject
|
|
410
410
|
: classFnOrObject.constructor;
|
|
411
|
-
const config = Reflect.getMetadata(
|
|
411
|
+
const config = Reflect.getMetadata(Symbols__NS__metadata.options.entity, classFn);
|
|
412
412
|
return config.uniqueKeyProp;
|
|
413
413
|
};
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region is class object
|
|
416
|
-
const
|
|
416
|
+
const ClassHelpers__NS__isContextClassObject = (obj) => {
|
|
417
417
|
if (!_.isObject(obj) ||
|
|
418
418
|
_.isArray(obj) ||
|
|
419
419
|
_.isRegExp(obj) ||
|
|
@@ -424,30 +424,30 @@ const ClassHelpers_isContextClassObject = (obj) => {
|
|
|
424
424
|
if (_.isDate(obj)) {
|
|
425
425
|
return true;
|
|
426
426
|
}
|
|
427
|
-
const className =
|
|
427
|
+
const className = ClassHelpers__NS__getName(obj);
|
|
428
428
|
return _.isString(className) && className !== 'Object';
|
|
429
429
|
};
|
|
430
430
|
//#endregion
|
|
431
431
|
//#region get name
|
|
432
|
-
const
|
|
432
|
+
const ClassHelpers__NS__setName = (target, className) => {
|
|
433
433
|
// console.log('setName', className, target.name)
|
|
434
|
-
|
|
435
|
-
target[
|
|
434
|
+
Validators__NS__classNameVlidation(className, target);
|
|
435
|
+
target[Symbols__NS__classNameStaticProperty] = className;
|
|
436
436
|
};
|
|
437
437
|
//#endregion
|
|
438
438
|
//#region has parent with class name
|
|
439
|
-
const
|
|
439
|
+
const ClassHelpers__NS__hasParentClassWithName = (target, className, targets = []) => {
|
|
440
440
|
if (!target) {
|
|
441
441
|
return false;
|
|
442
442
|
}
|
|
443
443
|
targets.push(target);
|
|
444
444
|
let targetProto = Object.getPrototypeOf(target);
|
|
445
445
|
if (_.isFunction(targetProto) &&
|
|
446
|
-
|
|
446
|
+
ClassHelpers__NS__getName(targetProto) === className) {
|
|
447
447
|
// console.log(`true "${_.first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
448
448
|
return true;
|
|
449
449
|
}
|
|
450
|
-
return
|
|
450
|
+
return ClassHelpers__NS__hasParentClassWithName(targetProto, className, targets);
|
|
451
451
|
};
|
|
452
452
|
//#endregion
|
|
453
453
|
//#region get methods name
|
|
@@ -477,12 +477,12 @@ const notAllowedAsMethodName = [
|
|
|
477
477
|
/**
|
|
478
478
|
* Express async handler for middleware functions.
|
|
479
479
|
*/
|
|
480
|
-
const
|
|
480
|
+
const ClassHelpers__NS__asyncHandler = fn => (req, res, next) => {
|
|
481
481
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
482
482
|
};
|
|
483
|
-
const
|
|
483
|
+
const ClassHelpers__NS__getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
484
484
|
if (!classOrClassInstance) {
|
|
485
|
-
return
|
|
485
|
+
return Utils__NS__uniqArray(allMethodsNames);
|
|
486
486
|
}
|
|
487
487
|
const isClassFunction = _.isFunction(classOrClassInstance);
|
|
488
488
|
const classFun = isClassFunction
|
|
@@ -504,37 +504,37 @@ const ClassHelpers_getMethodsNames = (classOrClassInstance, allMethodsNames = []
|
|
|
504
504
|
if (!classFun ||
|
|
505
505
|
!classFun.constructor ||
|
|
506
506
|
classFun?.constructor?.name === 'Object') {
|
|
507
|
-
return
|
|
507
|
+
return Utils__NS__uniqArray(allMethodsNames);
|
|
508
508
|
}
|
|
509
|
-
return
|
|
509
|
+
return ClassHelpers__NS__getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
|
|
510
510
|
};
|
|
511
511
|
//#endregion
|
|
512
512
|
//#region get controller configs
|
|
513
|
-
const
|
|
513
|
+
const ClassHelpers__NS__getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
514
514
|
if (!_.isFunction(target)) {
|
|
515
515
|
throw `[typescript-class-helper][getControllerConfigs] Cannot get class config from: ${target}`;
|
|
516
516
|
}
|
|
517
517
|
let config;
|
|
518
518
|
const parentClass = Object.getPrototypeOf(target);
|
|
519
|
-
const parentName = parentClass ?
|
|
519
|
+
const parentName = parentClass ? ClassHelpers__NS__getName(parentClass) : void 0;
|
|
520
520
|
const isValidParent = _.isFunction(parentClass) && parentName !== '';
|
|
521
|
-
config = controllerConfigFrom(
|
|
521
|
+
config = controllerConfigFrom(ClassHelpers__NS__getClassConfig(target));
|
|
522
522
|
configs.push(config);
|
|
523
523
|
return isValidParent
|
|
524
|
-
?
|
|
524
|
+
? ClassHelpers__NS__getControllerConfigs(parentClass, configs, target)
|
|
525
525
|
: configs;
|
|
526
526
|
};
|
|
527
527
|
//#endregion
|
|
528
528
|
//#region ensure configs
|
|
529
529
|
// Ensure ClassConfig on constructor, clone parent if needed
|
|
530
|
-
const
|
|
531
|
-
let cfg = Reflect.getOwnMetadata(
|
|
530
|
+
const ClassHelpers__NS__ensureClassConfig = (target) => {
|
|
531
|
+
let cfg = Reflect.getOwnMetadata(Symbols__NS__metadata.options.controller, // META_KEYS.class,
|
|
532
532
|
target);
|
|
533
533
|
if (!cfg) {
|
|
534
534
|
cfg = { methods: {} };
|
|
535
535
|
const parent = Object.getPrototypeOf(target);
|
|
536
536
|
if (parent && parent !== Function.prototype) {
|
|
537
|
-
const parentCfg = Reflect.getMetadata(
|
|
537
|
+
const parentCfg = Reflect.getMetadata(Symbols__NS__metadata.options.controller, // META_KEYS.class,
|
|
538
538
|
parent);
|
|
539
539
|
if (parentCfg) {
|
|
540
540
|
// Deep copy each method config so child gets its own objects
|
|
@@ -551,13 +551,13 @@ const ClassHelpers_ensureClassConfig = (target) => {
|
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
|
-
Reflect.defineMetadata(
|
|
554
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.controller, cfg, target);
|
|
555
555
|
}
|
|
556
556
|
return cfg;
|
|
557
557
|
};
|
|
558
558
|
// Ensure MethodConfig inside ClassConfig
|
|
559
|
-
const
|
|
560
|
-
const classCfg =
|
|
559
|
+
const ClassHelpers__NS__ensureMethodConfig = (target, propertyKey) => {
|
|
560
|
+
const classCfg = ClassHelpers__NS__ensureClassConfig(target.constructor);
|
|
561
561
|
let methodCfg = classCfg.methods[propertyKey?.toString()];
|
|
562
562
|
if (!methodCfg) {
|
|
563
563
|
methodCfg = { methodName: propertyKey?.toString(), parameters: {} };
|
|
@@ -565,8 +565,8 @@ const ClassHelpers_ensureMethodConfig = (target, propertyKey) => {
|
|
|
565
565
|
}
|
|
566
566
|
return methodCfg;
|
|
567
567
|
};
|
|
568
|
-
const
|
|
569
|
-
return Reflect.getMetadata(
|
|
568
|
+
const ClassHelpers__NS__getClassConfig = (constructor) => {
|
|
569
|
+
return Reflect.getMetadata(Symbols__NS__metadata.options.controller, constructor);
|
|
570
570
|
};
|
|
571
571
|
//#endregion
|
|
572
572
|
//end of namespace ClassHelpers
|
|
@@ -680,21 +680,21 @@ class ContextDbMigrations {
|
|
|
680
680
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
681
681
|
return;
|
|
682
682
|
}
|
|
683
|
-
if (!
|
|
683
|
+
if (!UtilsMigrations__NS__isValidTimestamp(timestamp)) {
|
|
684
684
|
Helpers.throw(`Invalid timestamp provided for migration revert: ${timestamp}`);
|
|
685
685
|
}
|
|
686
686
|
// Get all migration class functions and reverse the order
|
|
687
687
|
const migrationsClassFns = this.ctx
|
|
688
|
-
.getClassFunByArr(
|
|
688
|
+
.getClassFunByArr(Models__NS__ClassType.MIGRATION)
|
|
689
689
|
.reverse();
|
|
690
690
|
// Filter migrations that need to be reverted
|
|
691
691
|
const migrationClassesInstancesToRevert = migrationsClassFns
|
|
692
692
|
.map(classFn => {
|
|
693
|
-
const timestampFromClassName = Number(
|
|
693
|
+
const timestampFromClassName = Number(UtilsMigrations__NS__getTimestampFromClassName(ClassHelpers__NS__getName(classFn)));
|
|
694
694
|
if (timestampFromClassName <= timestamp) {
|
|
695
695
|
// this.ctx.logMigrations &&
|
|
696
696
|
// console.log(
|
|
697
|
-
// `Stopping migration filter at: ${
|
|
697
|
+
// `Stopping migration filter at: ${ClassHelpers__NS__getName(classFn)} ` +
|
|
698
698
|
// `with timestamp ${timestampFromClassName}`,
|
|
699
699
|
// );
|
|
700
700
|
return null;
|
|
@@ -714,7 +714,7 @@ class ContextDbMigrations {
|
|
|
714
714
|
const appliedMigrationsForContextNames = appliedMigrationsForContext.map(m => m.name);
|
|
715
715
|
// console.log({ appliedMigrationsForContextNames });
|
|
716
716
|
for (const migrationClassInstance of migrationClassesInstancesToRevert) {
|
|
717
|
-
const migrationName =
|
|
717
|
+
const migrationName = ClassHelpers__NS__getName(migrationClassInstance);
|
|
718
718
|
if (!appliedMigrationsForContextNames.includes(migrationName)) {
|
|
719
719
|
this.ctx.logMigrations &&
|
|
720
720
|
console.warn(`Skipping migration not marked as applied: ${migrationName}`);
|
|
@@ -772,7 +772,7 @@ class ContextDbMigrations {
|
|
|
772
772
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
773
773
|
return;
|
|
774
774
|
}
|
|
775
|
-
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
775
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(Models__NS__ClassType.MIGRATION);
|
|
776
776
|
const migrationClassesInstances = migrationsClassFns
|
|
777
777
|
.map(classFn => this.ctx.getInstanceBy(classFn))
|
|
778
778
|
.map(f => f)
|
|
@@ -785,7 +785,7 @@ class ContextDbMigrations {
|
|
|
785
785
|
const allMigrationsInDb = await queryRunner.query(`SELECT name FROM ${this.DEFAULT_MIGRATION_TABLE_NAME}`);
|
|
786
786
|
const allMigrationInDBNames = allMigrationsInDb.map(m => m.name);
|
|
787
787
|
for (const instance of migrationClassesInstances) {
|
|
788
|
-
const migrationName =
|
|
788
|
+
const migrationName = ClassHelpers__NS__getName(instance);
|
|
789
789
|
if (allMigrationInDBNames.includes(migrationName)) {
|
|
790
790
|
this.ctx.logMigrations &&
|
|
791
791
|
console.log(`Skipping already applied migration: ${migrationName}`);
|
|
@@ -826,9 +826,9 @@ class ContextDbMigrations {
|
|
|
826
826
|
if (this.ctx.isRemoteHost || !this.ctx.connection) {
|
|
827
827
|
return;
|
|
828
828
|
}
|
|
829
|
-
const migrationsClassFns = this.ctx.getClassFunByArr(
|
|
829
|
+
const migrationsClassFns = this.ctx.getClassFunByArr(Models__NS__ClassType.MIGRATION);
|
|
830
830
|
// console.log({
|
|
831
|
-
// migrationClassesALl: migrationsClassFns.map(f =>
|
|
831
|
+
// migrationClassesALl: migrationsClassFns.map(f => ClassHelpers__NS__getName(f)),
|
|
832
832
|
// });
|
|
833
833
|
const migrationClassesInstances = migrationsClassFns
|
|
834
834
|
.map(classFn => this.ctx.getInstanceBy(classFn))
|
|
@@ -836,7 +836,7 @@ class ContextDbMigrations {
|
|
|
836
836
|
.filter(migrationInstance => migrationInstance.isReadyToRun());
|
|
837
837
|
// console.log({
|
|
838
838
|
// migrationClassesInstances: migrationsClassFns.map(f =>
|
|
839
|
-
//
|
|
839
|
+
// ClassHelpers__NS__getName(f),
|
|
840
840
|
// ),
|
|
841
841
|
// });
|
|
842
842
|
const queryRunner = this.ctx.connection.createQueryRunner();
|
|
@@ -852,7 +852,7 @@ class ContextDbMigrations {
|
|
|
852
852
|
const pendingMigrationsForContext = appliedMigrationsForContext.filter(m => m.status === this.MIGRATION_STATUS_PENDING);
|
|
853
853
|
// Run pending migrations first
|
|
854
854
|
for (const pendingContextMigration of pendingMigrationsForContext) {
|
|
855
|
-
const migrationInstance = migrationClassesInstances.find(instance =>
|
|
855
|
+
const migrationInstance = migrationClassesInstances.find(instance => ClassHelpers__NS__getName(instance) === pendingContextMigration.name);
|
|
856
856
|
if (!migrationInstance) {
|
|
857
857
|
this.ctx.logMigrations &&
|
|
858
858
|
console.warn(`Pending migration ${pendingContextMigration.name} not found in loaded migrations.`);
|
|
@@ -869,7 +869,7 @@ class ContextDbMigrations {
|
|
|
869
869
|
//#endregion
|
|
870
870
|
//#region run new migrations
|
|
871
871
|
for (const instance of migrationClassesInstances) {
|
|
872
|
-
const migrationName =
|
|
872
|
+
const migrationName = ClassHelpers__NS__getName(instance);
|
|
873
873
|
if (appliedMigrationsForContext.some(m => m.name === migrationName)) {
|
|
874
874
|
this.ctx.logMigrations &&
|
|
875
875
|
console.log(`Skipping already applied migration: ${migrationName}`);
|
|
@@ -967,7 +967,7 @@ const getResponseValue = (response, options) => {
|
|
|
967
967
|
|
|
968
968
|
//namespace TaonHelpers
|
|
969
969
|
//#region fillUpTo string
|
|
970
|
-
const
|
|
970
|
+
const TaonHelpers__NS__fillUpTo = (s, nCharacters) => {
|
|
971
971
|
return _.times(nCharacters, n => {
|
|
972
972
|
if (s.charAt(n)) {
|
|
973
973
|
return s.charAt(n);
|
|
@@ -977,18 +977,18 @@ const TaonHelpers_fillUpTo = (s, nCharacters) => {
|
|
|
977
977
|
};
|
|
978
978
|
//#endregion
|
|
979
979
|
//#region is good path
|
|
980
|
-
const
|
|
980
|
+
const TaonHelpers__NS__isGoodPath = (p) => {
|
|
981
981
|
return p && typeof p === 'string' && p.trim() !== '';
|
|
982
982
|
};
|
|
983
983
|
//#endregion
|
|
984
|
-
const
|
|
984
|
+
const TaonHelpers__NS__firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
985
985
|
if (Array.isArray(stringOrArrayOfString)) {
|
|
986
986
|
return _.first(stringOrArrayOfString);
|
|
987
987
|
}
|
|
988
988
|
return stringOrArrayOfString;
|
|
989
989
|
};
|
|
990
990
|
//#region try transform params
|
|
991
|
-
const
|
|
991
|
+
const TaonHelpers__NS__tryTransformParam = param => {
|
|
992
992
|
if (typeof param === 'string') {
|
|
993
993
|
let n = Number(param);
|
|
994
994
|
if (!isNaN(n))
|
|
@@ -1012,14 +1012,14 @@ const TaonHelpers_tryTransformParam = param => {
|
|
|
1012
1012
|
};
|
|
1013
1013
|
//#endregion
|
|
1014
1014
|
//#region get expores path
|
|
1015
|
-
const
|
|
1015
|
+
const TaonHelpers__NS__getExpressPath = (c, pathOrClassConfig) => {
|
|
1016
1016
|
if (typeof pathOrClassConfig === 'string')
|
|
1017
1017
|
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1018
1018
|
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1019
1019
|
};
|
|
1020
1020
|
//#endregion
|
|
1021
1021
|
//#region get default value tyep
|
|
1022
|
-
const
|
|
1022
|
+
const TaonHelpers__NS__defaultType = value => {
|
|
1023
1023
|
if (typeof value === 'string')
|
|
1024
1024
|
return '';
|
|
1025
1025
|
if (typeof value === 'boolean')
|
|
@@ -1031,7 +1031,7 @@ const TaonHelpers_defaultType = value => {
|
|
|
1031
1031
|
};
|
|
1032
1032
|
//#endregion
|
|
1033
1033
|
//#region parse json with string jsons
|
|
1034
|
-
const
|
|
1034
|
+
const TaonHelpers__NS__parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1035
1035
|
// console.log('checking object', object)
|
|
1036
1036
|
if (!_.isObject(object)) {
|
|
1037
1037
|
if (waring) {
|
|
@@ -1055,22 +1055,22 @@ const TaonHelpers_parseJSONwithStringJSONs = (object, waring = false) => {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
// console.log(`key ${key} is json `, isJson)
|
|
1057
1057
|
if (isJson) {
|
|
1058
|
-
res[key] =
|
|
1058
|
+
res[key] = TaonHelpers__NS__parseJSONwithStringJSONs(res[key], false);
|
|
1059
1059
|
}
|
|
1060
1060
|
});
|
|
1061
1061
|
return res;
|
|
1062
1062
|
};
|
|
1063
1063
|
//#endregion
|
|
1064
1064
|
//#region is plain file or folder
|
|
1065
|
-
const
|
|
1065
|
+
const TaonHelpers__NS__isPlainFileOrFolder = filePath => {
|
|
1066
1066
|
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
1067
1067
|
};
|
|
1068
1068
|
//#endregion
|
|
1069
1069
|
//#region ips key name repsonse
|
|
1070
|
-
const
|
|
1070
|
+
const TaonHelpers__NS__ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
1071
1071
|
return [
|
|
1072
1072
|
'response',
|
|
1073
|
-
|
|
1073
|
+
ClassHelpers__NS__getName(target),
|
|
1074
1074
|
methodConfig.methodName,
|
|
1075
1075
|
methodConfig.type,
|
|
1076
1076
|
expressPath,
|
|
@@ -1078,10 +1078,10 @@ const TaonHelpers_ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
|
1078
1078
|
};
|
|
1079
1079
|
//#endregion
|
|
1080
1080
|
//#region ipc key name request
|
|
1081
|
-
const
|
|
1081
|
+
const TaonHelpers__NS__ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
1082
1082
|
return [
|
|
1083
1083
|
'request',
|
|
1084
|
-
|
|
1084
|
+
ClassHelpers__NS__getName(target),
|
|
1085
1085
|
methodConfig.methodName,
|
|
1086
1086
|
methodConfig.type,
|
|
1087
1087
|
expressPath,
|
|
@@ -1089,7 +1089,7 @@ const TaonHelpers_ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
|
1089
1089
|
};
|
|
1090
1090
|
//#endregion
|
|
1091
1091
|
//#region websql mocks
|
|
1092
|
-
const
|
|
1092
|
+
const TaonHelpers__NS__websqlMocks = headers => {
|
|
1093
1093
|
const response = {
|
|
1094
1094
|
status(status) {
|
|
1095
1095
|
// console.log({status})
|
|
@@ -1134,18 +1134,18 @@ class RealtimeSubsManager {
|
|
|
1134
1134
|
// console.info(`[BROWSER]][IPC] subscribe to "${this.options?.roomName}" by sending event: "${subscribeEvent}"`, this.options);
|
|
1135
1135
|
this.isListening = true;
|
|
1136
1136
|
if (this.options.customEvent) {
|
|
1137
|
-
const subscribeEvent =
|
|
1137
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.options.core.ctx.contextName);
|
|
1138
1138
|
// this means: send to current client custom event notification
|
|
1139
1139
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1140
1140
|
}
|
|
1141
1141
|
else {
|
|
1142
1142
|
if (_.isString(this.options.property)) {
|
|
1143
|
-
const subscribeEvent =
|
|
1143
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1144
1144
|
// this means: send to current client entity property events updates
|
|
1145
1145
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1146
1146
|
}
|
|
1147
1147
|
else {
|
|
1148
|
-
const subscribeEvent =
|
|
1148
|
+
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1149
1149
|
// this means: send to current client entity update events
|
|
1150
1150
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1151
1151
|
}
|
|
@@ -1173,14 +1173,14 @@ class RealtimeSubsManager {
|
|
|
1173
1173
|
const { core, customEvent, roomName, property } = this.options;
|
|
1174
1174
|
const realtime = core.socketFE;
|
|
1175
1175
|
if (customEvent) {
|
|
1176
|
-
realtime.emit(
|
|
1176
|
+
realtime.emit(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.options.core.ctx.contextName), roomName);
|
|
1177
1177
|
}
|
|
1178
1178
|
else {
|
|
1179
1179
|
if (_.isString(property)) {
|
|
1180
|
-
realtime.emit(
|
|
1180
|
+
realtime.emit(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1181
1181
|
}
|
|
1182
1182
|
else {
|
|
1183
|
-
realtime.emit(
|
|
1183
|
+
realtime.emit(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
@@ -1227,7 +1227,7 @@ class RealtimeClient {
|
|
|
1227
1227
|
//#region prepare naspaces pathes
|
|
1228
1228
|
const nspPath = {
|
|
1229
1229
|
global: this.core.pathFor(),
|
|
1230
|
-
realtime: this.core.pathFor(
|
|
1230
|
+
realtime: this.core.pathFor(Symbols__NS__REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1231
1231
|
};
|
|
1232
1232
|
// console.log('[browser] nspPath', nspPath);
|
|
1233
1233
|
if (this.core.ctx.config.frontendHost &&
|
|
@@ -1296,15 +1296,15 @@ class RealtimeClient {
|
|
|
1296
1296
|
if (_.isObject(entityClassFnOrObj)) {
|
|
1297
1297
|
const orgObj = entityClassFnOrObj;
|
|
1298
1298
|
entityClassFnOrObj =
|
|
1299
|
-
|
|
1300
|
-
const uniqueKey =
|
|
1299
|
+
ClassHelpers__NS__getClassFnFromObject(entityClassFnOrObj);
|
|
1300
|
+
const uniqueKey = ClassHelpers__NS__getUniqueKey(entityClassFnOrObj);
|
|
1301
1301
|
if (uniqueKey) {
|
|
1302
1302
|
options.idOrUniqValue = orgObj[uniqueKey];
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
//#region parameters validation
|
|
1306
1306
|
const { property, customEvent } = options;
|
|
1307
|
-
const className = !customEvent &&
|
|
1307
|
+
const className = !customEvent && ClassHelpers__NS__getName(entityClassFnOrObj);
|
|
1308
1308
|
if (_.isString(property)) {
|
|
1309
1309
|
if (property.trim() === '') {
|
|
1310
1310
|
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
@@ -1328,12 +1328,12 @@ to use socket realtime connection;
|
|
|
1328
1328
|
}
|
|
1329
1329
|
let roomName;
|
|
1330
1330
|
if (customEvent) {
|
|
1331
|
-
roomName =
|
|
1331
|
+
roomName = Symbols__NS__REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1332
1332
|
}
|
|
1333
1333
|
else {
|
|
1334
1334
|
roomName = _.isString(property)
|
|
1335
|
-
?
|
|
1336
|
-
:
|
|
1335
|
+
? Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1336
|
+
: Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1337
1337
|
}
|
|
1338
1338
|
const roomSubOptions = {
|
|
1339
1339
|
core: this.core,
|
|
@@ -1361,9 +1361,9 @@ to use socket realtime connection;
|
|
|
1361
1361
|
* Example: for pagination, lists update ...
|
|
1362
1362
|
*/
|
|
1363
1363
|
listenChangesEntityTable(entityClassFn) {
|
|
1364
|
-
const className =
|
|
1364
|
+
const className = ClassHelpers__NS__getName(entityClassFn);
|
|
1365
1365
|
return this.listenChangesEntity(entityClassFn, {
|
|
1366
|
-
customEvent:
|
|
1366
|
+
customEvent: Symbols__NS__REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
1367
1367
|
});
|
|
1368
1368
|
}
|
|
1369
1369
|
//#endregion
|
|
@@ -1435,7 +1435,7 @@ class RealtimeServer {
|
|
|
1435
1435
|
//#region @websql
|
|
1436
1436
|
//#region prepare namespaces pathes
|
|
1437
1437
|
const nspPathGlobal = this.core.pathFor();
|
|
1438
|
-
const nspPathRealtime = this.core.pathFor(
|
|
1438
|
+
const nspPathRealtime = this.core.pathFor(Symbols__NS__REALTIME.NAMESPACE(this.core.ctx.contextName));
|
|
1439
1439
|
//#endregion
|
|
1440
1440
|
// console.log('[backend] nspPath', nspPath);
|
|
1441
1441
|
const cors = {
|
|
@@ -1474,37 +1474,37 @@ class RealtimeServer {
|
|
|
1474
1474
|
this.core.ctx.logRealtime &&
|
|
1475
1475
|
console.info(`[backend] client connected to namespace "${nspPathRealtime.pathname}", ` +
|
|
1476
1476
|
` host: ${this.core.ctx.host}`);
|
|
1477
|
-
backendSocketForClient.on(
|
|
1477
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
|
|
1478
1478
|
this.core.ctx.logRealtime &&
|
|
1479
1479
|
console.info(`Joining room ${roomName} in namespace REALTIME` +
|
|
1480
1480
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1481
1481
|
backendSocketForClient.join(roomName);
|
|
1482
1482
|
});
|
|
1483
|
-
backendSocketForClient.on(
|
|
1483
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1484
1484
|
this.core.ctx.logRealtime &&
|
|
1485
1485
|
console.info(`[backend] Joining room ${roomName} in namespace REALTIME` +
|
|
1486
1486
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1487
1487
|
backendSocketForClient.join(roomName);
|
|
1488
1488
|
});
|
|
1489
|
-
backendSocketForClient.on(
|
|
1489
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1490
1490
|
this.core.ctx.logRealtime &&
|
|
1491
1491
|
console.info(`[backend] Joining room ${roomName} in namespace REALTIME ` +
|
|
1492
1492
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1493
1493
|
backendSocketForClient.join(roomName);
|
|
1494
1494
|
});
|
|
1495
|
-
backendSocketForClient.on(
|
|
1495
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.core.ctx.contextName), roomName => {
|
|
1496
1496
|
this.core.ctx.logRealtime &&
|
|
1497
1497
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME` +
|
|
1498
1498
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1499
1499
|
backendSocketForClient.leave(roomName);
|
|
1500
1500
|
});
|
|
1501
|
-
backendSocketForClient.on(
|
|
1501
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1502
1502
|
this.core.ctx.logRealtime &&
|
|
1503
1503
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME ` +
|
|
1504
1504
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
1505
1505
|
backendSocketForClient.leave(roomName);
|
|
1506
1506
|
});
|
|
1507
|
-
backendSocketForClient.on(
|
|
1507
|
+
backendSocketForClient.on(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.core.ctx.contextName), roomName => {
|
|
1508
1508
|
this.core.ctx.logRealtime &&
|
|
1509
1509
|
console.info(`[backend] Leaving room ${roomName} in namespace REALTIME ` +
|
|
1510
1510
|
` host: ${this.core.ctx.contextName}/${this.core.ctx.host}`);
|
|
@@ -1526,25 +1526,25 @@ class RealtimeServer {
|
|
|
1526
1526
|
return;
|
|
1527
1527
|
}
|
|
1528
1528
|
if (customEvent) {
|
|
1529
|
-
roomName =
|
|
1529
|
+
roomName = Symbols__NS__REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1530
1530
|
}
|
|
1531
1531
|
else {
|
|
1532
1532
|
let entityFn = entityObjOrClass;
|
|
1533
1533
|
const entityIsObject = !_.isFunction(entityObjOrClass) && _.isObject(entityObjOrClass);
|
|
1534
1534
|
if (entityIsObject) {
|
|
1535
|
-
entityFn =
|
|
1535
|
+
entityFn = ClassHelpers__NS__getClassFnFromObject(entityObjOrClass);
|
|
1536
1536
|
}
|
|
1537
|
-
const uniqueKey =
|
|
1537
|
+
const uniqueKey = ClassHelpers__NS__getUniqueKey(entityFn);
|
|
1538
1538
|
if (entityIsObject) {
|
|
1539
1539
|
valueOfUniqueProperty = entityObjOrClass[uniqueKey];
|
|
1540
1540
|
}
|
|
1541
1541
|
if (!valueOfUniqueProperty) {
|
|
1542
|
-
Helpers.error(`[Taon][Realtime] Entity without iD ! ${
|
|
1542
|
+
Helpers.error(`[Taon][Realtime] Entity without iD ! ${ClassHelpers__NS__getName(entityFn)} `, true, true);
|
|
1543
1543
|
return;
|
|
1544
1544
|
}
|
|
1545
1545
|
roomName = _.isString(property)
|
|
1546
|
-
?
|
|
1547
|
-
:
|
|
1546
|
+
? Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, ClassHelpers__NS__getName(entityFn), property, valueOfUniqueProperty)
|
|
1547
|
+
: Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, ClassHelpers__NS__getName(entityFn), valueOfUniqueProperty);
|
|
1548
1548
|
}
|
|
1549
1549
|
this.core.socketBE.in(roomName).emit(roomName, // roomName == eventName in room na
|
|
1550
1550
|
customEvent ? customEventData : '');
|
|
@@ -1560,7 +1560,7 @@ class RealtimeServer {
|
|
|
1560
1560
|
*/
|
|
1561
1561
|
idToTrigger) {
|
|
1562
1562
|
if (this.core.ctx.disabledRealtime) {
|
|
1563
|
-
const className =
|
|
1563
|
+
const className = ClassHelpers__NS__getName(entityObjOrClass);
|
|
1564
1564
|
console.warn(`[Taon][TriggerEntityChanges] Entity "${className}' is not realtime`);
|
|
1565
1565
|
return;
|
|
1566
1566
|
}
|
|
@@ -1580,7 +1580,7 @@ class RealtimeServer {
|
|
|
1580
1580
|
*/
|
|
1581
1581
|
idToTrigger) {
|
|
1582
1582
|
if (this.core.ctx.disabledRealtime) {
|
|
1583
|
-
const className =
|
|
1583
|
+
const className = ClassHelpers__NS__getName(entityObjOrClass);
|
|
1584
1584
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
1585
1585
|
return;
|
|
1586
1586
|
}
|
|
@@ -1596,12 +1596,12 @@ class RealtimeServer {
|
|
|
1596
1596
|
//#endregion
|
|
1597
1597
|
//#region methods & getters / trigger entity table changes
|
|
1598
1598
|
triggerEntityTableChanges(entityClassOrInstance) {
|
|
1599
|
-
const className =
|
|
1599
|
+
const className = ClassHelpers__NS__getName(entityClassOrInstance);
|
|
1600
1600
|
if (this.core.ctx.disabledRealtime) {
|
|
1601
1601
|
console.warn(`[Taon][TriggerEntityTableChanges] Entity "${className}' is not realtime`);
|
|
1602
1602
|
return;
|
|
1603
1603
|
}
|
|
1604
|
-
this.triggerChanges(entityClassOrInstance, void 0, void 0,
|
|
1604
|
+
this.triggerChanges(entityClassOrInstance, void 0, void 0, Symbols__NS__REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className));
|
|
1605
1605
|
}
|
|
1606
1606
|
//#endregion
|
|
1607
1607
|
//#endregion
|
|
@@ -2128,11 +2128,11 @@ class MockSocket {
|
|
|
2128
2128
|
//#region emit
|
|
2129
2129
|
emit(eventName, ...args) {
|
|
2130
2130
|
eventName = eventName || '';
|
|
2131
|
-
if (eventName.includes(`:${
|
|
2131
|
+
if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomSubscribe}`)) {
|
|
2132
2132
|
const room = args[0];
|
|
2133
2133
|
this.join(room);
|
|
2134
2134
|
}
|
|
2135
|
-
else if (eventName.includes(`:${
|
|
2135
|
+
else if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomUnsubscribe}`)) {
|
|
2136
2136
|
const room = args[0];
|
|
2137
2137
|
this.leave(room);
|
|
2138
2138
|
}
|
|
@@ -2467,18 +2467,18 @@ class EndpointContext {
|
|
|
2467
2467
|
//#endregion
|
|
2468
2468
|
//#region fields / types from contexts
|
|
2469
2469
|
this.injectableTypesfromContexts = [
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2470
|
+
Models__NS__ClassType.CONTROLLER,
|
|
2471
|
+
Models__NS__ClassType.PROVIDER,
|
|
2472
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
2473
|
+
Models__NS__ClassType.REPOSITORY,
|
|
2474
|
+
Models__NS__ClassType.SUBSCRIBER,
|
|
2475
|
+
Models__NS__ClassType.MIGRATION,
|
|
2476
2476
|
];
|
|
2477
2477
|
//#endregion
|
|
2478
2478
|
//#region fields / all types from contexts
|
|
2479
2479
|
this.allTypesfromContexts = [
|
|
2480
2480
|
...this.injectableTypesfromContexts,
|
|
2481
|
-
|
|
2481
|
+
Models__NS__ClassType.ENTITY,
|
|
2482
2482
|
];
|
|
2483
2483
|
//#endregion
|
|
2484
2484
|
//#region fields / express app
|
|
@@ -2503,7 +2503,7 @@ class EndpointContext {
|
|
|
2503
2503
|
// Return a new class that extends the base class
|
|
2504
2504
|
const cloneClass = () => {
|
|
2505
2505
|
var _a, _b, _c, _d, _e;
|
|
2506
|
-
if (TaonBaseClass[
|
|
2506
|
+
if (TaonBaseClass[Symbols__NS__fullClassNameStaticProperty] ===
|
|
2507
2507
|
`${ctx.contextName}.${className}`) {
|
|
2508
2508
|
return TaonBaseClass;
|
|
2509
2509
|
}
|
|
@@ -2515,7 +2515,7 @@ class EndpointContext {
|
|
|
2515
2515
|
// You can override prototype properties or methods here if needed
|
|
2516
2516
|
// static properties override allowed
|
|
2517
2517
|
}
|
|
2518
|
-
static { _a =
|
|
2518
|
+
static { _a = Symbols__NS__orignalClass, _b = Symbols__NS__fullClassNameStaticProperty, _c = Symbols__NS__classNameStaticProperty, _d = Symbols__NS__ctxInClassOrClassObj, _e = Symbols__NS__ctxInClassOrClassObj; }
|
|
2519
2519
|
// @ts-ignore
|
|
2520
2520
|
static { this[_a] = TaonBaseClass; }
|
|
2521
2521
|
// @ts-ignore
|
|
@@ -2525,13 +2525,13 @@ class EndpointContext {
|
|
|
2525
2525
|
static { this[_d] = ctx; }
|
|
2526
2526
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2527
2527
|
static __getFullPathForClass__(arr = []) {
|
|
2528
|
-
const name = this[
|
|
2528
|
+
const name = this[Symbols__NS__fullClassNameStaticProperty];
|
|
2529
2529
|
arr.push(name);
|
|
2530
2530
|
// @ts-ignore
|
|
2531
|
-
if (this[
|
|
2532
|
-
this[
|
|
2531
|
+
if (this[Symbols__NS__orignalClass] && // @ts-ignore
|
|
2532
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__) {
|
|
2533
2533
|
// @ts-ignore
|
|
2534
|
-
this[
|
|
2534
|
+
this[Symbols__NS__orignalClass].__getFullPathForClass__(arr);
|
|
2535
2535
|
}
|
|
2536
2536
|
return arr.join('/');
|
|
2537
2537
|
}
|
|
@@ -2544,19 +2544,19 @@ class EndpointContext {
|
|
|
2544
2544
|
//#region gather all instances for all contexts
|
|
2545
2545
|
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
2546
2546
|
// this thinng belowe is nice for debugging purpose
|
|
2547
|
-
// if (_.isUndefined(cloneClassFunction[
|
|
2548
|
-
// cloneClassFunction[
|
|
2547
|
+
// if (_.isUndefined(cloneClassFunction[Symbols__NS__orignalClassClonesObj])) {
|
|
2548
|
+
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = {};
|
|
2549
2549
|
// }
|
|
2550
|
-
// if (_.isUndefined(TaonBaseClass[
|
|
2551
|
-
// TaonBaseClass[
|
|
2550
|
+
// if (_.isUndefined(TaonBaseClass[Symbols__NS__orignalClassClonesObj])) {
|
|
2551
|
+
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = {};
|
|
2552
2552
|
// }
|
|
2553
2553
|
// const all = {
|
|
2554
|
-
// ...TaonBaseClass[
|
|
2555
|
-
// ...cloneClassFunction[
|
|
2554
|
+
// ...TaonBaseClass[Symbols__NS__orignalClassClonesObj],
|
|
2555
|
+
// ...cloneClassFunction[Symbols__NS__orignalClassClonesObj],
|
|
2556
2556
|
// };
|
|
2557
2557
|
// all[ctx.contextName] = cloneClassFunction;
|
|
2558
|
-
// cloneClassFunction[
|
|
2559
|
-
// TaonBaseClass[
|
|
2558
|
+
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = all;
|
|
2559
|
+
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = all;
|
|
2560
2560
|
//#endregion
|
|
2561
2561
|
return cloneClassFunction;
|
|
2562
2562
|
};
|
|
@@ -2575,13 +2575,13 @@ class EndpointContext {
|
|
|
2575
2575
|
|
|
2576
2576
|
`);
|
|
2577
2577
|
}
|
|
2578
|
-
var className = Reflect.getMetadata(
|
|
2578
|
+
var className = Reflect.getMetadata(Symbols__NS__metadata.className, TaonBaseClass);
|
|
2579
2579
|
// console.log('Metadata className', className, TaonBaseClass);
|
|
2580
2580
|
// if (!className) {
|
|
2581
2581
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
2582
2582
|
// }
|
|
2583
2583
|
className = className || key;
|
|
2584
|
-
TaonBaseClass[
|
|
2584
|
+
TaonBaseClass[Symbols__NS__classNameStaticProperty] = className;
|
|
2585
2585
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
2586
2586
|
TaonBaseClass,
|
|
2587
2587
|
className,
|
|
@@ -2594,7 +2594,7 @@ class EndpointContext {
|
|
|
2594
2594
|
return classes;
|
|
2595
2595
|
};
|
|
2596
2596
|
this.cloneOptions = this.cloneOptions || {};
|
|
2597
|
-
this.isRunningInsideDocker =
|
|
2597
|
+
this.isRunningInsideDocker = UtilsOs__NS__isRunningInDocker();
|
|
2598
2598
|
}
|
|
2599
2599
|
//#endregion
|
|
2600
2600
|
//#region methods & getters / init
|
|
@@ -2607,7 +2607,7 @@ class EndpointContext {
|
|
|
2607
2607
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
2608
2608
|
this.config = this.configFn({});
|
|
2609
2609
|
if (_.isObject(this.config.database)) {
|
|
2610
|
-
this.config.database =
|
|
2610
|
+
this.config.database = Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
2611
2611
|
}
|
|
2612
2612
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
2613
2613
|
if (this.cloneOptions.overrideHost &&
|
|
@@ -2720,31 +2720,31 @@ class EndpointContext {
|
|
|
2720
2720
|
this.config.subscribers = this.config.subscribers || {};
|
|
2721
2721
|
this.config.migrations = this.config.migrations || {};
|
|
2722
2722
|
this.config.entities = {
|
|
2723
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2723
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.ENTITY)),
|
|
2724
2724
|
...this.config.entities,
|
|
2725
2725
|
};
|
|
2726
2726
|
this.config.controllers = {
|
|
2727
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2727
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.CONTROLLER)),
|
|
2728
2728
|
...this.config.controllers,
|
|
2729
2729
|
};
|
|
2730
2730
|
this.config.providers = {
|
|
2731
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2731
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.PROVIDER)),
|
|
2732
2732
|
...this.config.providers,
|
|
2733
2733
|
};
|
|
2734
2734
|
this.config.middlewares = {
|
|
2735
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2735
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIDDLEWARE)),
|
|
2736
2736
|
...this.config.middlewares,
|
|
2737
2737
|
};
|
|
2738
2738
|
this.config.subscribers = {
|
|
2739
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2739
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.SUBSCRIBER)),
|
|
2740
2740
|
...this.config.subscribers,
|
|
2741
2741
|
};
|
|
2742
2742
|
this.config.repositories = {
|
|
2743
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2743
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.REPOSITORY)),
|
|
2744
2744
|
...this.config.repositories,
|
|
2745
2745
|
};
|
|
2746
2746
|
this.config.migrations = {
|
|
2747
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2747
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models__NS__ClassType.MIGRATION)),
|
|
2748
2748
|
...this.config.migrations,
|
|
2749
2749
|
};
|
|
2750
2750
|
// console.log(this.config);
|
|
@@ -2755,37 +2755,37 @@ class EndpointContext {
|
|
|
2755
2755
|
classesInput: this.config.controllers,
|
|
2756
2756
|
config: this.config,
|
|
2757
2757
|
ctx: this,
|
|
2758
|
-
classType:
|
|
2758
|
+
classType: Models__NS__ClassType.CONTROLLER,
|
|
2759
2759
|
});
|
|
2760
2760
|
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
2761
2761
|
classesInput: this.config.repositories,
|
|
2762
2762
|
config: this.config,
|
|
2763
2763
|
ctx: this,
|
|
2764
|
-
classType:
|
|
2764
|
+
classType: Models__NS__ClassType.REPOSITORY,
|
|
2765
2765
|
});
|
|
2766
2766
|
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
2767
2767
|
classesInput: this.config.providers,
|
|
2768
2768
|
config: this.config,
|
|
2769
2769
|
ctx: this,
|
|
2770
|
-
classType:
|
|
2770
|
+
classType: Models__NS__ClassType.PROVIDER,
|
|
2771
2771
|
});
|
|
2772
2772
|
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
2773
2773
|
classesInput: this.config.middlewares,
|
|
2774
2774
|
config: this.config,
|
|
2775
2775
|
ctx: this,
|
|
2776
|
-
classType:
|
|
2776
|
+
classType: Models__NS__ClassType.MIDDLEWARE,
|
|
2777
2777
|
});
|
|
2778
2778
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
2779
2779
|
classesInput: this.config.subscribers,
|
|
2780
2780
|
config: this.config,
|
|
2781
2781
|
ctx: this,
|
|
2782
|
-
classType:
|
|
2782
|
+
classType: Models__NS__ClassType.SUBSCRIBER,
|
|
2783
2783
|
});
|
|
2784
2784
|
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
2785
2785
|
classesInput: this.config.migrations,
|
|
2786
2786
|
config: this.config,
|
|
2787
2787
|
ctx: this,
|
|
2788
|
-
classType:
|
|
2788
|
+
classType: Models__NS__ClassType.MIGRATION,
|
|
2789
2789
|
});
|
|
2790
2790
|
//#endregion
|
|
2791
2791
|
//#region prepare instances
|
|
@@ -2794,7 +2794,7 @@ class EndpointContext {
|
|
|
2794
2794
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
2795
2795
|
}
|
|
2796
2796
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
2797
|
-
await this.createInstances(this.config[
|
|
2797
|
+
await this.createInstances(this.config[Models__NS__ClassTypeKey[classTypeName]], classTypeName);
|
|
2798
2798
|
}
|
|
2799
2799
|
//#endregion
|
|
2800
2800
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
@@ -2895,13 +2895,13 @@ class EndpointContext {
|
|
|
2895
2895
|
|
|
2896
2896
|
`);
|
|
2897
2897
|
//#region @websqlFunc
|
|
2898
|
-
let databaseConfig =
|
|
2899
|
-
const tcpUdpDatabaseSqliteRelativeFileLocation = `${
|
|
2898
|
+
let databaseConfig = Models__NS__DatabaseConfig.from({});
|
|
2899
|
+
const tcpUdpDatabaseSqliteRelativeFileLocation = `${Models__NS__DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
2900
2900
|
if (this.isRunningInsideDocker) {
|
|
2901
2901
|
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
2902
2902
|
// Helpers.info('Running in docker, using in mysql database');
|
|
2903
2903
|
// // TODO auto resolve database config in docker
|
|
2904
|
-
// databaseConfig =
|
|
2904
|
+
// databaseConfig = Models__NS__DatabaseConfig.from({
|
|
2905
2905
|
// database: `db-${this.contextName}.sqlite`,
|
|
2906
2906
|
// type: 'mysql',
|
|
2907
2907
|
// recreateMode: 'PRESERVE_DATA+MIGRATIONS',
|
|
@@ -2925,7 +2925,7 @@ class EndpointContext {
|
|
|
2925
2925
|
/* */
|
|
2926
2926
|
/* */
|
|
2927
2927
|
/* */
|
|
2928
|
-
databaseConfig = databaseConfig =
|
|
2928
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
2929
2929
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
2930
2930
|
type: 'sqljs',
|
|
2931
2931
|
useLocalForage: false,
|
|
@@ -2966,8 +2966,8 @@ class EndpointContext {
|
|
|
2966
2966
|
/* */
|
|
2967
2967
|
/* */
|
|
2968
2968
|
/* */
|
|
2969
|
-
databaseConfig =
|
|
2970
|
-
location:
|
|
2969
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
2970
|
+
location: UtilsOs__NS__isElectron
|
|
2971
2971
|
? dbLocationInOs
|
|
2972
2972
|
: `db-${this.contextName}.sqlite`,
|
|
2973
2973
|
type: 'sqljs',
|
|
@@ -2984,7 +2984,7 @@ class EndpointContext {
|
|
|
2984
2984
|
keepWebsqlDbDataAfterReload =
|
|
2985
2985
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload; // TODO @LAST
|
|
2986
2986
|
//#endregion
|
|
2987
|
-
databaseConfig = databaseConfig =
|
|
2987
|
+
databaseConfig = databaseConfig = Models__NS__DatabaseConfig.from({
|
|
2988
2988
|
location: `db-${this.contextName}.sqlite`,
|
|
2989
2989
|
type: 'sqljs',
|
|
2990
2990
|
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
@@ -2997,7 +2997,7 @@ class EndpointContext {
|
|
|
2997
2997
|
//#endregion
|
|
2998
2998
|
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
2999
2999
|
case 'backend-frontend(tcp+udp)':
|
|
3000
|
-
databaseConfig =
|
|
3000
|
+
databaseConfig = Models__NS__DatabaseConfig.from({
|
|
3001
3001
|
database: `context-db-${this.contextName}`,
|
|
3002
3002
|
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
3003
3003
|
type: 'sqljs',
|
|
@@ -3101,7 +3101,7 @@ class EndpointContext {
|
|
|
3101
3101
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
3102
3102
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
3103
3103
|
return arr.reduce((acc, c) => {
|
|
3104
|
-
acc[
|
|
3104
|
+
acc[ClassHelpers__NS__getName(c)] = c;
|
|
3105
3105
|
return acc;
|
|
3106
3106
|
}, {});
|
|
3107
3107
|
}
|
|
@@ -3141,9 +3141,9 @@ class EndpointContext {
|
|
|
3141
3141
|
//#endregion
|
|
3142
3142
|
//#region methods & getters / inject
|
|
3143
3143
|
inject(ctor, options) {
|
|
3144
|
-
const className =
|
|
3144
|
+
const className = ClassHelpers__NS__getName(ctor);
|
|
3145
3145
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
3146
|
-
if (this.isCLassType(
|
|
3146
|
+
if (this.isCLassType(Models__NS__ClassType.REPOSITORY, ctor)) {
|
|
3147
3147
|
options.localInstance = true;
|
|
3148
3148
|
}
|
|
3149
3149
|
if (options?.localInstance) {
|
|
@@ -3153,7 +3153,7 @@ class EndpointContext {
|
|
|
3153
3153
|
// if (className === 'TaonBaseRepository') {
|
|
3154
3154
|
const entityFn = _.first(locaInstanceConstructorArgs);
|
|
3155
3155
|
const entity = entityFn && entityFn();
|
|
3156
|
-
entityName = (entity &&
|
|
3156
|
+
entityName = (entity && ClassHelpers__NS__getName(entity)) || '';
|
|
3157
3157
|
// console.log(`entityName `, entityName);
|
|
3158
3158
|
// }
|
|
3159
3159
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
@@ -3163,12 +3163,12 @@ class EndpointContext {
|
|
|
3163
3163
|
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
3164
3164
|
if (existed) {
|
|
3165
3165
|
// console.log(
|
|
3166
|
-
// `EXISTED ${
|
|
3166
|
+
// `EXISTED ${ClassHelpers__NS__getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3167
3167
|
// );
|
|
3168
3168
|
return existed;
|
|
3169
3169
|
}
|
|
3170
3170
|
// console.log(
|
|
3171
|
-
// `NEW ${
|
|
3171
|
+
// `NEW ${ClassHelpers__NS__getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3172
3172
|
// );
|
|
3173
3173
|
if (!ctxClassFn) {
|
|
3174
3174
|
throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
|
|
@@ -3194,11 +3194,11 @@ class EndpointContext {
|
|
|
3194
3194
|
*/
|
|
3195
3195
|
getInstanceBy(ctor) {
|
|
3196
3196
|
// if (!!this.__contextForControllerInstanceAccess) {
|
|
3197
|
-
// const className =
|
|
3198
|
-
// const allControllers = this.getClassFunByArr(
|
|
3197
|
+
// const className = ClassHelpers__NS__getName(ctor);
|
|
3198
|
+
// const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
3199
3199
|
// // TODO QUICK_FIX cache controllers
|
|
3200
3200
|
// for (const ctrl of allControllers) {
|
|
3201
|
-
// if (
|
|
3201
|
+
// if (ClassHelpers__NS__getName(ctrl) === className) {
|
|
3202
3202
|
// // console.log('injecting from contextForControllerInstanceAcesss', className);
|
|
3203
3203
|
// return this.__contextForControllerInstanceAccess.inject(ctor, {
|
|
3204
3204
|
// localInstance: false,
|
|
@@ -3230,24 +3230,24 @@ class EndpointContext {
|
|
|
3230
3230
|
getClassFunBy(classType) {
|
|
3231
3231
|
this.checkIfContextInitialized();
|
|
3232
3232
|
switch (classType) {
|
|
3233
|
-
case
|
|
3233
|
+
case Models__NS__ClassType.CONTROLLER:
|
|
3234
3234
|
return this.config.controllers;
|
|
3235
|
-
case
|
|
3235
|
+
case Models__NS__ClassType.ENTITY:
|
|
3236
3236
|
return this.config.entities;
|
|
3237
|
-
case
|
|
3237
|
+
case Models__NS__ClassType.PROVIDER:
|
|
3238
3238
|
return this.config.providers;
|
|
3239
|
-
case
|
|
3239
|
+
case Models__NS__ClassType.MIDDLEWARE:
|
|
3240
3240
|
return this.config.middlewares;
|
|
3241
|
-
case
|
|
3241
|
+
case Models__NS__ClassType.REPOSITORY:
|
|
3242
3242
|
return this.config.repositories;
|
|
3243
|
-
case
|
|
3243
|
+
case Models__NS__ClassType.SUBSCRIBER:
|
|
3244
3244
|
return this.config.subscribers;
|
|
3245
|
-
case
|
|
3245
|
+
case Models__NS__ClassType.MIGRATION:
|
|
3246
3246
|
return this.config.migrations;
|
|
3247
3247
|
}
|
|
3248
3248
|
}
|
|
3249
3249
|
isCLassType(classType, classFn) {
|
|
3250
|
-
return !!this.getClassFunBy(classType)[
|
|
3250
|
+
return !!this.getClassFunBy(classType)[ClassHelpers__NS__getName(classFn)];
|
|
3251
3251
|
}
|
|
3252
3252
|
/**
|
|
3253
3253
|
* Only for injectable types
|
|
@@ -3255,14 +3255,14 @@ class EndpointContext {
|
|
|
3255
3255
|
*/
|
|
3256
3256
|
getClassFunByClassName(className) {
|
|
3257
3257
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
3258
|
-
const classesForInjectableType = this.config[
|
|
3258
|
+
const classesForInjectableType = this.config[Models__NS__ClassTypeKey[classTypeName]];
|
|
3259
3259
|
if (classesForInjectableType[className]) {
|
|
3260
3260
|
return classesForInjectableType[className];
|
|
3261
3261
|
}
|
|
3262
3262
|
}
|
|
3263
3263
|
}
|
|
3264
3264
|
getClassFunByClass(classFunction) {
|
|
3265
|
-
const className =
|
|
3265
|
+
const className = ClassHelpers__NS__getName(classFunction);
|
|
3266
3266
|
return this.getClassFunByClassName(className);
|
|
3267
3267
|
}
|
|
3268
3268
|
getClassFunByArr(classType) {
|
|
@@ -3281,11 +3281,11 @@ class EndpointContext {
|
|
|
3281
3281
|
]) {
|
|
3282
3282
|
const instance = DITaonContainer.resolve(classFn);
|
|
3283
3283
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
3284
|
-
const className =
|
|
3284
|
+
const className = ClassHelpers__NS__getName(classFn);
|
|
3285
3285
|
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
3286
3286
|
classInstancesByNameObj[className] = instance;
|
|
3287
3287
|
// update config
|
|
3288
|
-
this.config[
|
|
3288
|
+
this.config[Models__NS__ClassTypeKey[classType]][className] = classFn;
|
|
3289
3289
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
3290
3290
|
this.allClassesInstances[className] = instance;
|
|
3291
3291
|
}
|
|
@@ -3297,18 +3297,18 @@ class EndpointContext {
|
|
|
3297
3297
|
return;
|
|
3298
3298
|
}
|
|
3299
3299
|
//#region @websql
|
|
3300
|
-
for (const classFun of this.getClassFunByArr(
|
|
3301
|
-
const repo = (await this.connection.getRepository(
|
|
3302
|
-
this.repos.set(
|
|
3300
|
+
for (const classFun of this.getClassFunByArr(Models__NS__ClassType.ENTITY)) {
|
|
3301
|
+
const repo = (await this.connection.getRepository(ClassHelpers__NS__getOrginalClass(classFun)));
|
|
3302
|
+
this.repos.set(ClassHelpers__NS__getName(classFun), repo);
|
|
3303
3303
|
}
|
|
3304
3304
|
//#endregion
|
|
3305
3305
|
for (const classTypeName of [
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3306
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
3307
|
+
Models__NS__ClassType.PROVIDER,
|
|
3308
|
+
Models__NS__ClassType.REPOSITORY,
|
|
3309
|
+
Models__NS__ClassType.CONTROLLER,
|
|
3310
|
+
Models__NS__ClassType.ENTITY,
|
|
3311
|
+
Models__NS__ClassType.MIGRATION,
|
|
3312
3312
|
]) {
|
|
3313
3313
|
//#region init class static _ property
|
|
3314
3314
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
@@ -3319,11 +3319,11 @@ class EndpointContext {
|
|
|
3319
3319
|
//#endregion
|
|
3320
3320
|
}
|
|
3321
3321
|
for (const classTypeName of [
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3322
|
+
Models__NS__ClassType.MIDDLEWARE,
|
|
3323
|
+
Models__NS__ClassType.PROVIDER,
|
|
3324
|
+
Models__NS__ClassType.REPOSITORY,
|
|
3325
|
+
Models__NS__ClassType.CONTROLLER,
|
|
3326
|
+
Models__NS__ClassType.MIGRATION,
|
|
3327
3327
|
]) {
|
|
3328
3328
|
//#region init providers, repositories _ property
|
|
3329
3329
|
// Helpers.taskStarted(
|
|
@@ -3343,7 +3343,7 @@ class EndpointContext {
|
|
|
3343
3343
|
//#endregion
|
|
3344
3344
|
//#region methods & getters / is active on
|
|
3345
3345
|
isActiveOn(classInstance) {
|
|
3346
|
-
let contextRef = classInstance[
|
|
3346
|
+
let contextRef = classInstance[Symbols__NS__ctxInClassOrClassObj];
|
|
3347
3347
|
return this === contextRef;
|
|
3348
3348
|
}
|
|
3349
3349
|
//#endregion
|
|
@@ -3514,11 +3514,11 @@ class EndpointContext {
|
|
|
3514
3514
|
if (this.isRemoteHost) {
|
|
3515
3515
|
return;
|
|
3516
3516
|
}
|
|
3517
|
-
const subscriberClasses = this.getClassFunByArr(
|
|
3517
|
+
const subscriberClasses = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
3518
3518
|
for (const subscriberClassFn of subscriberClasses) {
|
|
3519
|
-
const options = Reflect.getMetadata(
|
|
3519
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.subscriber, subscriberClassFn);
|
|
3520
3520
|
// console.log('subscriber options', options);
|
|
3521
|
-
// const nameForSubscriber =
|
|
3521
|
+
// const nameForSubscriber = ClassHelpers__NS__getName(subscriber);
|
|
3522
3522
|
EventSubscriber()(subscriberClassFn);
|
|
3523
3523
|
}
|
|
3524
3524
|
//#endregion
|
|
@@ -3530,13 +3530,13 @@ class EndpointContext {
|
|
|
3530
3530
|
if (this.isRemoteHost) {
|
|
3531
3531
|
return;
|
|
3532
3532
|
}
|
|
3533
|
-
const entities = this.getClassFunByArr(
|
|
3533
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY);
|
|
3534
3534
|
for (const entity of entities) {
|
|
3535
|
-
const options = Reflect.getMetadata(
|
|
3535
|
+
const options = Reflect.getMetadata(Symbols__NS__metadata.options.entity, entity);
|
|
3536
3536
|
const createTable = _.isUndefined(options.createTable)
|
|
3537
3537
|
? true
|
|
3538
3538
|
: options.createTable;
|
|
3539
|
-
const nameForEntity =
|
|
3539
|
+
const nameForEntity = ClassHelpers__NS__getName(entity);
|
|
3540
3540
|
if (createTable) {
|
|
3541
3541
|
this.logDb &&
|
|
3542
3542
|
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
@@ -3576,10 +3576,10 @@ class EndpointContext {
|
|
|
3576
3576
|
if (this.isRemoteHost || !this.databaseConfig) {
|
|
3577
3577
|
return;
|
|
3578
3578
|
}
|
|
3579
|
-
const entities = this.getClassFunByArr(
|
|
3580
|
-
return
|
|
3579
|
+
const entities = this.getClassFunByArr(Models__NS__ClassType.ENTITY).map(entityFn => {
|
|
3580
|
+
return ClassHelpers__NS__getOrginalClass(entityFn);
|
|
3581
3581
|
});
|
|
3582
|
-
const subscribers = this.getClassFunByArr(
|
|
3582
|
+
const subscribers = this.getClassFunByArr(Models__NS__ClassType.SUBSCRIBER);
|
|
3583
3583
|
let autoSave = false;
|
|
3584
3584
|
if (!_.isNil(this.databaseConfig.autoSave)) {
|
|
3585
3585
|
autoSave = this.databaseConfig.autoSave;
|
|
@@ -3673,20 +3673,20 @@ class EndpointContext {
|
|
|
3673
3673
|
const parentsCalculatedPath = _.slice(rawConfigs, 1)
|
|
3674
3674
|
.reverse()
|
|
3675
3675
|
.map(bc => {
|
|
3676
|
-
if (
|
|
3676
|
+
if (TaonHelpers__NS__isGoodPath(bc.path)) {
|
|
3677
3677
|
return bc.path;
|
|
3678
3678
|
}
|
|
3679
3679
|
return bc.className;
|
|
3680
3680
|
})
|
|
3681
3681
|
.join('/');
|
|
3682
3682
|
const contextNameForCommunication = this.contextNameForCommunication;
|
|
3683
|
-
if (
|
|
3683
|
+
if (TaonHelpers__NS__isGoodPath(classConfig.path)) {
|
|
3684
3684
|
classConfig.calculatedPath = classConfig.path;
|
|
3685
3685
|
}
|
|
3686
3686
|
else {
|
|
3687
3687
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3688
3688
|
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
3689
|
-
`${
|
|
3689
|
+
`${ClassHelpers__NS__getName(controllerClassFn)}`)
|
|
3690
3690
|
.replace(/\/\//g, '/')
|
|
3691
3691
|
.split('/')
|
|
3692
3692
|
.reduce((acc, bc) => {
|
|
@@ -3719,7 +3719,7 @@ class EndpointContext {
|
|
|
3719
3719
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3720
3720
|
return;
|
|
3721
3721
|
}
|
|
3722
|
-
const allControllers = this.getClassFunByArr(
|
|
3722
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
3723
3723
|
for (const controllerClassFn of allControllers) {
|
|
3724
3724
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
3725
3725
|
if (_.isFunction(instance.afterAllCtxInited)) {
|
|
@@ -3731,21 +3731,21 @@ class EndpointContext {
|
|
|
3731
3731
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3732
3732
|
return;
|
|
3733
3733
|
}
|
|
3734
|
-
const allControllers = this.getClassFunByArr(
|
|
3734
|
+
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
3735
3735
|
// debugger
|
|
3736
3736
|
// console.log('allControllers', allControllers);
|
|
3737
3737
|
for (const controllerClassFn of allControllers) {
|
|
3738
|
-
// console.log(
|
|
3739
|
-
// const controllerName =
|
|
3738
|
+
// console.log(ClassHelpers__NS__getClassConfig(controllerClassFn));
|
|
3739
|
+
// const controllerName = ClassHelpers__NS__getName(controllerClassFn);
|
|
3740
3740
|
// console.log(
|
|
3741
3741
|
// `for ${controllerName}`,
|
|
3742
|
-
//
|
|
3742
|
+
// ClassHelpers__NS__getClassConfig(controllerClassFn),
|
|
3743
3743
|
// );
|
|
3744
|
-
controllerClassFn[
|
|
3745
|
-
|
|
3746
|
-
const rawConfigs =
|
|
3744
|
+
controllerClassFn[Symbols__NS__classMethodsNames] =
|
|
3745
|
+
ClassHelpers__NS__getMethodsNames(controllerClassFn);
|
|
3746
|
+
const rawConfigs = ClassHelpers__NS__getControllerConfigs(controllerClassFn);
|
|
3747
3747
|
// console.log(controllerName, { rawConfigs });
|
|
3748
|
-
// console.log(`Class config for ${
|
|
3748
|
+
// console.log(`Class config for ${ClassHelpers__NS__getName(controllerClassFn)}`, configs)
|
|
3749
3749
|
const classConfig = rawConfigs[0];
|
|
3750
3750
|
this.updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn);
|
|
3751
3751
|
this.mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn);
|
|
@@ -3756,7 +3756,7 @@ class EndpointContext {
|
|
|
3756
3756
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
3757
3757
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
3758
3758
|
className(middlewareClass) {
|
|
3759
|
-
return
|
|
3759
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
3760
3760
|
},
|
|
3761
3761
|
});
|
|
3762
3762
|
}
|
|
@@ -3783,7 +3783,7 @@ class EndpointContext {
|
|
|
3783
3783
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
3784
3784
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
3785
3785
|
className(middlewareClass) {
|
|
3786
|
-
return
|
|
3786
|
+
return ClassHelpers__NS__getName(controllerClassFn);
|
|
3787
3787
|
},
|
|
3788
3788
|
});
|
|
3789
3789
|
}
|
|
@@ -3806,7 +3806,7 @@ class EndpointContext {
|
|
|
3806
3806
|
: '';
|
|
3807
3807
|
const expressPath = methodConfig.global
|
|
3808
3808
|
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
3809
|
-
:
|
|
3809
|
+
: TaonHelpers__NS__getExpressPath(classConfig, methodConfig);
|
|
3810
3810
|
//#endregion
|
|
3811
3811
|
//#region init server
|
|
3812
3812
|
// console.log({ expressPath });
|
|
@@ -3826,7 +3826,7 @@ class EndpointContext {
|
|
|
3826
3826
|
if (shouldInitClient) {
|
|
3827
3827
|
// console.log(
|
|
3828
3828
|
// 'initClient',
|
|
3829
|
-
//
|
|
3829
|
+
// ClassHelpers__NS__getFullInternalName(controllerClassFn),
|
|
3830
3830
|
// type,
|
|
3831
3831
|
// methodConfig,
|
|
3832
3832
|
// expressPath,
|
|
@@ -3853,12 +3853,12 @@ class EndpointContext {
|
|
|
3853
3853
|
}
|
|
3854
3854
|
// const contexts: EndpointContext[] = [this];
|
|
3855
3855
|
//#region @websql
|
|
3856
|
-
const troutes =
|
|
3856
|
+
const troutes = Utils__NS__uniqArray(this.activeRoutes.map(f => {
|
|
3857
3857
|
return `${f.method} ${f.expressPath}`;
|
|
3858
3858
|
})).map(f => {
|
|
3859
3859
|
const [method, expressPath] = f.split(' ');
|
|
3860
3860
|
return (`\n### ${_.startCase(_.last(expressPath.split('/')))}\n` +
|
|
3861
|
-
|
|
3861
|
+
TaonHelpers__NS__fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
3862
3862
|
this.uriOrigin +
|
|
3863
3863
|
expressPath);
|
|
3864
3864
|
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
@@ -3891,12 +3891,12 @@ class EndpointContext {
|
|
|
3891
3891
|
//#endregion
|
|
3892
3892
|
//#region methods & getters / init middlewares
|
|
3893
3893
|
async initCustomClientMiddlewares() {
|
|
3894
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
3894
|
+
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE)
|
|
3895
3895
|
.map(f => f)
|
|
3896
3896
|
.filter(f => _.isFunction(f.interceptClient));
|
|
3897
3897
|
middlewares.forEach(middlewareInstanceName => {
|
|
3898
3898
|
const contextName = this.contextName;
|
|
3899
|
-
const interceptorName = `${contextName}-${
|
|
3899
|
+
const interceptorName = `${contextName}-${ClassHelpers__NS__getName(middlewareInstanceName)}`;
|
|
3900
3900
|
Resource.request.interceptors.set(interceptorName, {
|
|
3901
3901
|
intercept: ({ req, next }) => {
|
|
3902
3902
|
const url = new URL(req.url);
|
|
@@ -4068,7 +4068,7 @@ class EndpointContext {
|
|
|
4068
4068
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
4069
4069
|
if (middlewareInstance &&
|
|
4070
4070
|
_.isFunction(middlewareInstance.interceptServerMethod)) {
|
|
4071
|
-
const middlewareFn =
|
|
4071
|
+
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
4072
4072
|
await middlewareInstance.interceptServerMethod({
|
|
4073
4073
|
req,
|
|
4074
4074
|
res,
|
|
@@ -4410,7 +4410,7 @@ class EndpointContext {
|
|
|
4410
4410
|
.map(f => this.getInstanceBy(f))
|
|
4411
4411
|
.filter(f => _.isFunction(f.interceptClientMethod));
|
|
4412
4412
|
middlewaresInstances.forEach(instance => {
|
|
4413
|
-
const middlewareName =
|
|
4413
|
+
const middlewareName = ClassHelpers__NS__getName(instance);
|
|
4414
4414
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
4415
4415
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
4416
4416
|
Resource.request.methodsInterceptors.set(interceptorKey, {
|
|
@@ -4442,14 +4442,14 @@ class EndpointContext {
|
|
|
4442
4442
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
4443
4443
|
const received = new Promise(async (resolve, reject) => {
|
|
4444
4444
|
const headers = {};
|
|
4445
|
-
const { request, response } =
|
|
4445
|
+
const { request, response } = TaonHelpers__NS__websqlMocks(headers);
|
|
4446
4446
|
//#region @browser
|
|
4447
|
-
ipcRenderer.once(
|
|
4447
|
+
ipcRenderer.once(TaonHelpers__NS__ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
|
|
4448
4448
|
let res = responseData;
|
|
4449
4449
|
console.log({ responseData });
|
|
4450
4450
|
try {
|
|
4451
4451
|
const body = res;
|
|
4452
|
-
res = new
|
|
4452
|
+
res = new Models__NS__HttpResponse({
|
|
4453
4453
|
body: void 0,
|
|
4454
4454
|
isArray: void 0,
|
|
4455
4455
|
method: methodConfig.type,
|
|
@@ -4465,7 +4465,7 @@ class EndpointContext {
|
|
|
4465
4465
|
reject(error);
|
|
4466
4466
|
}
|
|
4467
4467
|
});
|
|
4468
|
-
ipcRenderer.send(
|
|
4468
|
+
ipcRenderer.send(TaonHelpers__NS__ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
4469
4469
|
//#endregion
|
|
4470
4470
|
});
|
|
4471
4471
|
received['observable'] = from(received);
|
|
@@ -4485,22 +4485,22 @@ class EndpointContext {
|
|
|
4485
4485
|
const MIN_TIMEOUT = 400;
|
|
4486
4486
|
const MIN_TIMEOUT_STEP = 200;
|
|
4487
4487
|
const globalThisVar = globalThis; // TODO not a good idea! probably should be in context
|
|
4488
|
-
const timeout = globalThisVar[
|
|
4489
|
-
let updateFun = globalThisVar[
|
|
4490
|
-
if (!globalThisVar[
|
|
4491
|
-
globalThisVar[
|
|
4492
|
-
}
|
|
4493
|
-
updateFun = globalThisVar[
|
|
4494
|
-
let startFun = globalThisVar[
|
|
4495
|
-
if (!globalThisVar[
|
|
4496
|
-
globalThisVar[
|
|
4497
|
-
}
|
|
4498
|
-
startFun = globalThisVar[
|
|
4499
|
-
let doneFun = globalThisVar[
|
|
4500
|
-
if (!globalThisVar[
|
|
4501
|
-
globalThisVar[
|
|
4502
|
-
}
|
|
4503
|
-
doneFun = globalThisVar[
|
|
4488
|
+
const timeout = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_TIMEOUT] || MIN_TIMEOUT;
|
|
4489
|
+
let updateFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN];
|
|
4490
|
+
if (!globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN]) {
|
|
4491
|
+
globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN] = new Subject();
|
|
4492
|
+
}
|
|
4493
|
+
updateFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN];
|
|
4494
|
+
let startFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_START];
|
|
4495
|
+
if (!globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_START]) {
|
|
4496
|
+
globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_START] = new Subject();
|
|
4497
|
+
}
|
|
4498
|
+
startFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_START];
|
|
4499
|
+
let doneFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_DONE];
|
|
4500
|
+
if (!globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_DONE]) {
|
|
4501
|
+
globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_DONE] = new Subject();
|
|
4502
|
+
}
|
|
4503
|
+
doneFun = globalThisVar[Symbols__NS__old.WEBSQL_REST_PROGRESS_FUN_DONE];
|
|
4504
4504
|
let periodsToUpdate = 0;
|
|
4505
4505
|
if (timeout >= MIN_TIMEOUT) {
|
|
4506
4506
|
periodsToUpdate = Math.floor(timeout / MIN_TIMEOUT_STEP);
|
|
@@ -4536,7 +4536,7 @@ class EndpointContext {
|
|
|
4536
4536
|
// }
|
|
4537
4537
|
const received = new Promise(async (resolve, reject) => {
|
|
4538
4538
|
const headers = {};
|
|
4539
|
-
const { request, response } =
|
|
4539
|
+
const { request, response } = TaonHelpers__NS__websqlMocks(headers);
|
|
4540
4540
|
let res;
|
|
4541
4541
|
try {
|
|
4542
4542
|
res = await Helpers.runSyncOrAsync({
|
|
@@ -4565,7 +4565,7 @@ class EndpointContext {
|
|
|
4565
4565
|
res = await res.received;
|
|
4566
4566
|
}
|
|
4567
4567
|
const body = res;
|
|
4568
|
-
res = new
|
|
4568
|
+
res = new Models__NS__HttpResponse({
|
|
4569
4569
|
body: void 0,
|
|
4570
4570
|
isArray: void 0,
|
|
4571
4571
|
method: methodConfig.type,
|
|
@@ -4612,34 +4612,34 @@ class EndpointContext {
|
|
|
4612
4612
|
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
4613
4613
|
// const productionMode = FrameworkContext.isProductionMode;
|
|
4614
4614
|
//#region resolve frontend parameters
|
|
4615
|
-
if (!storage[
|
|
4616
|
-
storage[
|
|
4617
|
-
if (!storage[
|
|
4618
|
-
storage[
|
|
4619
|
-
const endpoints = storage[
|
|
4615
|
+
if (!storage[Symbols__NS__old.ENDPOINT_META_CONFIG])
|
|
4616
|
+
storage[Symbols__NS__old.ENDPOINT_META_CONFIG] = {};
|
|
4617
|
+
if (!storage[Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4618
|
+
storage[Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4619
|
+
const endpoints = storage[Symbols__NS__old.ENDPOINT_META_CONFIG];
|
|
4620
4620
|
let rest;
|
|
4621
4621
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4622
4622
|
let headers = {};
|
|
4623
4623
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4624
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4624
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4625
4625
|
'Content-Type': methodConfig.contentType,
|
|
4626
4626
|
Accept: methodConfig.contentType,
|
|
4627
4627
|
}));
|
|
4628
4628
|
}
|
|
4629
4629
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4630
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4630
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4631
4631
|
'Content-Type': methodConfig.contentType,
|
|
4632
4632
|
Accept: methodConfig.contentType,
|
|
4633
4633
|
responsetypeaxios: methodConfig.responseType,
|
|
4634
4634
|
}));
|
|
4635
4635
|
}
|
|
4636
4636
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4637
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4637
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4638
4638
|
responsetypeaxios: methodConfig.responseType,
|
|
4639
4639
|
}));
|
|
4640
4640
|
}
|
|
4641
4641
|
else {
|
|
4642
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4642
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols__NS__old.MAPPING_CONFIG_HEADER, Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4643
4643
|
}
|
|
4644
4644
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4645
4645
|
}
|
|
@@ -4672,23 +4672,23 @@ class EndpointContext {
|
|
|
4672
4672
|
}
|
|
4673
4673
|
if (currentParam.paramType === 'Query') {
|
|
4674
4674
|
if (currentParam.paramName) {
|
|
4675
|
-
const mapping =
|
|
4675
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
4676
4676
|
if (mapping) {
|
|
4677
|
-
rest.headers.set(`${
|
|
4677
|
+
rest.headers.set(`${Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4678
4678
|
}
|
|
4679
4679
|
queryParams[currentParam.paramName] = param;
|
|
4680
4680
|
}
|
|
4681
4681
|
else {
|
|
4682
|
-
const mapping =
|
|
4682
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
4683
4683
|
if (mapping) {
|
|
4684
|
-
rest.headers.set(
|
|
4684
|
+
rest.headers.set(Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4685
4685
|
}
|
|
4686
4686
|
queryParams = _.cloneDeep(param);
|
|
4687
4687
|
}
|
|
4688
4688
|
}
|
|
4689
4689
|
if (currentParam.paramType === 'Header') {
|
|
4690
4690
|
if (currentParam.paramName) {
|
|
4691
|
-
if (currentParam.paramName ===
|
|
4691
|
+
if (currentParam.paramName === Symbols__NS__old.MDC_KEY) {
|
|
4692
4692
|
// parese MDC
|
|
4693
4693
|
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4694
4694
|
}
|
|
@@ -4707,7 +4707,7 @@ class EndpointContext {
|
|
|
4707
4707
|
}
|
|
4708
4708
|
if (currentParam.paramType === 'Body') {
|
|
4709
4709
|
if (currentParam.paramName) {
|
|
4710
|
-
if (
|
|
4710
|
+
if (ClassHelpers__NS__getName(bodyObject) === 'FormData') {
|
|
4711
4711
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
4712
4712
|
Use this:
|
|
4713
4713
|
// ...
|
|
@@ -4720,35 +4720,35 @@ instead
|
|
|
4720
4720
|
// ...
|
|
4721
4721
|
`);
|
|
4722
4722
|
}
|
|
4723
|
-
const mapping =
|
|
4723
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
4724
4724
|
if (mapping) {
|
|
4725
|
-
rest.headers.set(`${
|
|
4725
|
+
rest.headers.set(`${Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4726
4726
|
}
|
|
4727
4727
|
bodyObject[currentParam.paramName] = param;
|
|
4728
4728
|
}
|
|
4729
4729
|
else {
|
|
4730
|
-
const mapping =
|
|
4730
|
+
const mapping = Mapping__NS__decode(param, !ctx.isProductionMode);
|
|
4731
4731
|
if (mapping) {
|
|
4732
|
-
rest.headers.set(
|
|
4732
|
+
rest.headers.set(Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
4733
4733
|
}
|
|
4734
4734
|
bodyObject = param;
|
|
4735
4735
|
}
|
|
4736
4736
|
}
|
|
4737
4737
|
});
|
|
4738
4738
|
if (typeof bodyObject === 'object' &&
|
|
4739
|
-
|
|
4739
|
+
ClassHelpers__NS__getName(bodyObject) !== 'FormData') {
|
|
4740
4740
|
let circuralFromItem = [];
|
|
4741
4741
|
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
4742
4742
|
circuralFromItem = circs;
|
|
4743
4743
|
}));
|
|
4744
|
-
rest.headers.set(
|
|
4744
|
+
rest.headers.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
4745
4745
|
}
|
|
4746
4746
|
if (typeof queryParams === 'object') {
|
|
4747
4747
|
let circuralFromQueryParams = [];
|
|
4748
4748
|
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
4749
4749
|
circuralFromQueryParams = circs;
|
|
4750
4750
|
}));
|
|
4751
|
-
rest.headers.set(
|
|
4751
|
+
rest.headers.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
4752
4752
|
}
|
|
4753
4753
|
//#endregion
|
|
4754
4754
|
const httpResultObj = {
|
|
@@ -4768,7 +4768,7 @@ instead
|
|
|
4768
4768
|
|
|
4769
4769
|
class ContextsEndpointStorage {
|
|
4770
4770
|
constructor() {
|
|
4771
|
-
this.SPECIAL_APP_READY_MESSAGE =
|
|
4771
|
+
this.SPECIAL_APP_READY_MESSAGE = CoreModels__NS__SPECIAL_APP_READY_MESSAGE;
|
|
4772
4772
|
this.taonEndpointContexts = new Map();
|
|
4773
4773
|
// Private constructor to prevent direct instantiation
|
|
4774
4774
|
}
|
|
@@ -4877,9 +4877,9 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4877
4877
|
return classFun;
|
|
4878
4878
|
//#region old
|
|
4879
4879
|
// TODO hmmmm for now context for controller inside api service
|
|
4880
|
-
// const allContexts = Object.values(classFun[
|
|
4880
|
+
// const allContexts = Object.values(classFun[Symbols__NS__orignalClassClonesObj] || {}).map(classFn => {
|
|
4881
4881
|
// return {
|
|
4882
|
-
// ctx: classFn[
|
|
4882
|
+
// ctx: classFn[Symbols__NS__ctxInClassOrClassObj] as EndpointContext,
|
|
4883
4883
|
// classFn,
|
|
4884
4884
|
// }
|
|
4885
4885
|
// })
|
|
@@ -4899,7 +4899,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4899
4899
|
return await new Promise(async (resolve, reject) => {
|
|
4900
4900
|
//#region init in set timeout
|
|
4901
4901
|
setTimeout(async () => {
|
|
4902
|
-
if (
|
|
4902
|
+
if (UtilsOs__NS__isRunningInDocker()) {
|
|
4903
4903
|
const activeContext = config?.activeContext || null;
|
|
4904
4904
|
if (_.isString(activeContext) &&
|
|
4905
4905
|
activeContext !== '' &&
|
|
@@ -4937,7 +4937,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
4937
4937
|
keepWebsqlDbDataAfterReload =
|
|
4938
4938
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
4939
4939
|
if (keepWebsqlDbDataAfterReload) {
|
|
4940
|
-
!
|
|
4940
|
+
!UtilsOs__NS__isRunningInCliMode() &&
|
|
4941
4941
|
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
4942
4942
|
`(context=${endpointContextRef.contextName}).`);
|
|
4943
4943
|
}
|
|
@@ -5015,7 +5015,7 @@ const inject = (entity) => {
|
|
|
5015
5015
|
return () => false;
|
|
5016
5016
|
}
|
|
5017
5017
|
const ctor = entity();
|
|
5018
|
-
const contextFromClass = ctor[
|
|
5018
|
+
const contextFromClass = ctor[Symbols__NS__ctxInClassOrClassObj];
|
|
5019
5019
|
const resultContext = contextFromClass;
|
|
5020
5020
|
if (resultContext) {
|
|
5021
5021
|
let instance = resultContext.inject(ctor, {
|
|
@@ -5028,7 +5028,7 @@ const inject = (entity) => {
|
|
|
5028
5028
|
if (propName === 'getOriginalConstructor') {
|
|
5029
5029
|
return () => instance.constructor;
|
|
5030
5030
|
}
|
|
5031
|
-
const methods = ctor[
|
|
5031
|
+
const methods = ctor[Symbols__NS__classMethodsNames] || [];
|
|
5032
5032
|
const isMethods = methods.includes(propName);
|
|
5033
5033
|
const methodOrProperty = isMethods
|
|
5034
5034
|
? instance[propName].bind(instance)
|
|
@@ -5066,7 +5066,7 @@ const inject = (entity) => {
|
|
|
5066
5066
|
// const subscriberClassFN: typeof TaonBaseClass =
|
|
5067
5067
|
// subscriberClassResolveFn() as any;
|
|
5068
5068
|
// const ctx = subscriberClassFN[
|
|
5069
|
-
//
|
|
5069
|
+
// Symbols__NS__ctxInClassOrClassObj
|
|
5070
5070
|
// ] as EndpointContext;
|
|
5071
5071
|
// if (!ctx) {
|
|
5072
5072
|
// throw new Error(
|
|
@@ -5107,12 +5107,12 @@ const getTransformFunction = (target) => {
|
|
|
5107
5107
|
if (!target) {
|
|
5108
5108
|
return;
|
|
5109
5109
|
}
|
|
5110
|
-
// const className =
|
|
5110
|
+
// const className = ClassHelpers__NS__getName(target)
|
|
5111
5111
|
// target = ClassHelpers.getBy(className);
|
|
5112
5112
|
if (!target) {
|
|
5113
5113
|
return void 0;
|
|
5114
5114
|
}
|
|
5115
|
-
const configs =
|
|
5115
|
+
const configs = ClassHelpers__NS__getControllerConfigs(target);
|
|
5116
5116
|
// console.log(`CONFIGS TO CHECK`, configs)
|
|
5117
5117
|
const functions = configs
|
|
5118
5118
|
.map(c => {
|
|
@@ -5137,13 +5137,13 @@ const getTransformFunction = (target) => {
|
|
|
5137
5137
|
* @deprecated
|
|
5138
5138
|
*/
|
|
5139
5139
|
const singleTransform = (json) => {
|
|
5140
|
-
let ptarget =
|
|
5140
|
+
let ptarget = ClassHelpers__NS__getClassFnFromObject(json);
|
|
5141
5141
|
let pbrowserTransformFn = getTransformFunction(ptarget);
|
|
5142
5142
|
if (pbrowserTransformFn) {
|
|
5143
5143
|
const newValue = pbrowserTransformFn(json);
|
|
5144
5144
|
if (!_.isObject(newValue)) {
|
|
5145
5145
|
console.error(`Please return object in transform function for class: ` +
|
|
5146
|
-
`${
|
|
5146
|
+
`${ClassHelpers__NS__getName(json)}`);
|
|
5147
5147
|
}
|
|
5148
5148
|
else {
|
|
5149
5149
|
json = newValue;
|
|
@@ -5221,7 +5221,7 @@ class EntityProcess {
|
|
|
5221
5221
|
//#region set headers
|
|
5222
5222
|
setHeaders() {
|
|
5223
5223
|
const { include } = { include: [] };
|
|
5224
|
-
const className =
|
|
5224
|
+
const className = ClassHelpers__NS__getName(this.data);
|
|
5225
5225
|
const doNothing = _.isNil(this.data) ||
|
|
5226
5226
|
[
|
|
5227
5227
|
'Object',
|
|
@@ -5234,10 +5234,10 @@ class EntityProcess {
|
|
|
5234
5234
|
breadthWalk: true,
|
|
5235
5235
|
include,
|
|
5236
5236
|
});
|
|
5237
|
-
this.entityMapping =
|
|
5238
|
-
this.response.set(
|
|
5237
|
+
this.entityMapping = Mapping__NS__decode(cleaned, !this.advancedManipulation);
|
|
5238
|
+
this.response.set(Symbols__NS__old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
|
|
5239
5239
|
if (this.advancedManipulation) {
|
|
5240
|
-
this.response.set(
|
|
5240
|
+
this.response.set(Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
|
|
5241
5241
|
}
|
|
5242
5242
|
}
|
|
5243
5243
|
}
|
|
@@ -5254,10 +5254,10 @@ class EntityProcess {
|
|
|
5254
5254
|
_.set(toSend, lodashPath, null);
|
|
5255
5255
|
}
|
|
5256
5256
|
else {
|
|
5257
|
-
const fun = getTransformFunction(
|
|
5257
|
+
const fun = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(value));
|
|
5258
5258
|
if (_.isFunction(fun)) {
|
|
5259
5259
|
_.set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
|
|
5260
|
-
const indexProp =
|
|
5260
|
+
const indexProp = ClassHelpers__NS__getUniqueKey(value);
|
|
5261
5261
|
_.set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
|
|
5262
5262
|
// skipObject()
|
|
5263
5263
|
}
|
|
@@ -5267,7 +5267,7 @@ class EntityProcess {
|
|
|
5267
5267
|
}
|
|
5268
5268
|
}, { checkCircural: true, breadthWalk: true, include });
|
|
5269
5269
|
if (!_.isArray(this.data)) {
|
|
5270
|
-
let funParent = getTransformFunction(
|
|
5270
|
+
let funParent = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(this.data));
|
|
5271
5271
|
// if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
|
|
5272
5272
|
// console.log(`funParent !!! have fun? ${!!funParent} `)
|
|
5273
5273
|
// }
|
|
@@ -5281,12 +5281,12 @@ class EntityProcess {
|
|
|
5281
5281
|
const v = this.data[prop];
|
|
5282
5282
|
if (!((include.length > 0 && !include.includes(prop)) ||
|
|
5283
5283
|
(exclude.length > 0 && exclude.includes(prop)))) {
|
|
5284
|
-
if (
|
|
5285
|
-
_.isFunction(getTransformFunction(
|
|
5284
|
+
if (ClassHelpers__NS__isContextClassObject(v) &&
|
|
5285
|
+
_.isFunction(getTransformFunction(ClassHelpers__NS__getClassFnFromObject(v)))) {
|
|
5286
5286
|
toSend[prop] = {
|
|
5287
5287
|
[browserKey]: v[browserKey],
|
|
5288
5288
|
};
|
|
5289
|
-
const indexProp =
|
|
5289
|
+
const indexProp = ClassHelpers__NS__getUniqueKey(v);
|
|
5290
5290
|
toSend[prop][indexProp] = this.data[prop][indexProp];
|
|
5291
5291
|
for (const key in v) {
|
|
5292
5292
|
if (_.isObject(v) &&
|
|
@@ -5471,7 +5471,7 @@ class TaonBaseClass {
|
|
|
5471
5471
|
console.log(overrideObjOrFn);
|
|
5472
5472
|
throw new Error('String is not supported as .clone() method argument');
|
|
5473
5473
|
}
|
|
5474
|
-
const classFn =
|
|
5474
|
+
const classFn = ClassHelpers__NS__getClassFnFromObject(this);
|
|
5475
5475
|
if (_.isFunction(overrideObjOrFn)) {
|
|
5476
5476
|
// console.log('clone with fn');
|
|
5477
5477
|
const oldValues = (_.cloneDeep(this) || {});
|
|
@@ -5659,12 +5659,12 @@ function TaonEntity(options) {
|
|
|
5659
5659
|
return function (constructor) {
|
|
5660
5660
|
options = options || {};
|
|
5661
5661
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5662
|
-
|
|
5663
|
-
|
|
5662
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
5663
|
+
Mapping__NS__DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
5664
5664
|
// TODO when entit metadata generator read use this
|
|
5665
|
-
|
|
5666
|
-
Reflect.defineMetadata(
|
|
5667
|
-
Reflect.defineMetadata(
|
|
5665
|
+
Mapping__NS__DefaultModelWithMapping(void 0, {})(constructor);
|
|
5666
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.entity, options, constructor);
|
|
5667
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
5668
5668
|
//#region @websql
|
|
5669
5669
|
Entity(options?.className)(constructor);
|
|
5670
5670
|
//#endregion
|
|
@@ -5716,9 +5716,9 @@ TAON_GLOBAL_STATE = __decorate([
|
|
|
5716
5716
|
*/
|
|
5717
5717
|
function TaonController(options) {
|
|
5718
5718
|
return function (constructor) {
|
|
5719
|
-
|
|
5720
|
-
Reflect.defineMetadata(
|
|
5721
|
-
const cfg =
|
|
5719
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
5720
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
5721
|
+
const cfg = ClassHelpers__NS__ensureClassConfig(constructor);
|
|
5722
5722
|
options = options || {};
|
|
5723
5723
|
cfg.className = options.className || constructor.name;
|
|
5724
5724
|
cfg.path = options.path || '';
|
|
@@ -5728,7 +5728,7 @@ function TaonController(options) {
|
|
|
5728
5728
|
}
|
|
5729
5729
|
|
|
5730
5730
|
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
5731
|
-
const methodConfig =
|
|
5731
|
+
const methodConfig = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
|
|
5732
5732
|
let options;
|
|
5733
5733
|
if (typeof pathOrOptions === 'object') {
|
|
5734
5734
|
options = pathOrOptions;
|
|
@@ -5779,7 +5779,7 @@ function GET(pathOrOptions, pathIsGlobal = false) {
|
|
|
5779
5779
|
* ...
|
|
5780
5780
|
* // in your taon controller
|
|
5781
5781
|
* ..Taon.Http.HTML()
|
|
5782
|
-
* sendHtmlDummyWebsite():
|
|
5782
|
+
* sendHtmlDummyWebsite(): Taon__NS__ResponseHtml {
|
|
5783
5783
|
* return `
|
|
5784
5784
|
<html>
|
|
5785
5785
|
<head>
|
|
@@ -5829,7 +5829,7 @@ function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
|
5829
5829
|
}
|
|
5830
5830
|
|
|
5831
5831
|
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
5832
|
-
const methodCfg =
|
|
5832
|
+
const methodCfg = ClassHelpers__NS__ensureMethodConfig(target, propertyKey);
|
|
5833
5833
|
const nameKey = name ? name : param;
|
|
5834
5834
|
// const key = name || `${param}_${parameterIndex}`;
|
|
5835
5835
|
methodCfg.parameters[nameKey] = {
|
|
@@ -5875,9 +5875,9 @@ function Body(name) {
|
|
|
5875
5875
|
*/
|
|
5876
5876
|
function TaonMiddleware(options) {
|
|
5877
5877
|
return function (constructor) {
|
|
5878
|
-
Reflect.defineMetadata(
|
|
5879
|
-
Reflect.defineMetadata(
|
|
5880
|
-
|
|
5878
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
|
|
5879
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
5880
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
5881
5881
|
};
|
|
5882
5882
|
}
|
|
5883
5883
|
class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
@@ -5899,7 +5899,7 @@ class TaonBaseInjector {
|
|
|
5899
5899
|
* Current endpoint context
|
|
5900
5900
|
*/
|
|
5901
5901
|
get __endpoint_context__() {
|
|
5902
|
-
return this[
|
|
5902
|
+
return this[Symbols__NS__ctxInClassOrClassObj];
|
|
5903
5903
|
}
|
|
5904
5904
|
/**
|
|
5905
5905
|
* get current endpoint context
|
|
@@ -5928,7 +5928,7 @@ class TaonBaseInjector {
|
|
|
5928
5928
|
localInstance: true,
|
|
5929
5929
|
locaInstanceConstructorArgs: [
|
|
5930
5930
|
() => {
|
|
5931
|
-
const classToProcess = this.ctx.allClassesInstances[
|
|
5931
|
+
const classToProcess = this.ctx.allClassesInstances[ClassHelpers__NS__getName(cutomRepositoryClass)];
|
|
5932
5932
|
return classToProcess.entityClassResolveFn();
|
|
5933
5933
|
},
|
|
5934
5934
|
],
|
|
@@ -6003,7 +6003,7 @@ class TaonBaseInjector {
|
|
|
6003
6003
|
const contextClassInstance = this;
|
|
6004
6004
|
return new Proxy({}, {
|
|
6005
6005
|
get: (__, propName) => {
|
|
6006
|
-
const contextFromClass = ctor && ctor[
|
|
6006
|
+
const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
|
|
6007
6007
|
const resultContext = contextFromClass
|
|
6008
6008
|
? contextFromClass
|
|
6009
6009
|
: this.__endpoint_context__;
|
|
@@ -6018,17 +6018,17 @@ class TaonBaseInjector {
|
|
|
6018
6018
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6019
6019
|
});
|
|
6020
6020
|
if (!instance) {
|
|
6021
|
-
throw new Error(`Not able to inject "${
|
|
6022
|
-
`property "${propName?.toString()}" on class "${
|
|
6021
|
+
throw new Error(`Not able to inject "${ClassHelpers__NS__getName(ctor) || ctor.name}" inside ` +
|
|
6022
|
+
`property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(this)}".
|
|
6023
6023
|
|
|
6024
|
-
Please add "${
|
|
6024
|
+
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6025
6025
|
|
|
6026
6026
|
`);
|
|
6027
6027
|
}
|
|
6028
6028
|
const result = typeof instance[propName] === 'function'
|
|
6029
6029
|
? instance[propName].bind(instance)
|
|
6030
6030
|
: instance[propName];
|
|
6031
|
-
// console.log(`Accessing injected "${propName?.toString()}" from "${
|
|
6031
|
+
// console.log(`Accessing injected "${propName?.toString()}" from "${ClassHelpers__NS__getName(ctor) || ctor.name}"`,result)
|
|
6032
6032
|
return result;
|
|
6033
6033
|
}
|
|
6034
6034
|
//#region @browser
|
|
@@ -6036,7 +6036,7 @@ class TaonBaseInjector {
|
|
|
6036
6036
|
//#endregion
|
|
6037
6037
|
},
|
|
6038
6038
|
set: (__, propName, value) => {
|
|
6039
|
-
const contextFromClass = ctor && ctor[
|
|
6039
|
+
const contextFromClass = ctor && ctor[Symbols__NS__ctxInClassOrClassObj];
|
|
6040
6040
|
const resultContext = contextFromClass
|
|
6041
6041
|
? contextFromClass
|
|
6042
6042
|
: this.__endpoint_context__;
|
|
@@ -6051,11 +6051,11 @@ class TaonBaseInjector {
|
|
|
6051
6051
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6052
6052
|
});
|
|
6053
6053
|
if (!instance) {
|
|
6054
|
-
const classNameNotResolved =
|
|
6054
|
+
const classNameNotResolved = ClassHelpers__NS__getName(ctor) || ctor.name;
|
|
6055
6055
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
6056
|
-
`property "${propName?.toString()}" on class "${
|
|
6056
|
+
`property "${propName?.toString()}" on class "${ClassHelpers__NS__getName(this)}".
|
|
6057
6057
|
|
|
6058
|
-
Please add "${
|
|
6058
|
+
Please add "${ClassHelpers__NS__getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6059
6059
|
|
|
6060
6060
|
`);
|
|
6061
6061
|
}
|
|
@@ -6234,7 +6234,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6234
6234
|
let i = 0;
|
|
6235
6235
|
let httpErrorsCount = 0;
|
|
6236
6236
|
while (true) {
|
|
6237
|
-
await
|
|
6237
|
+
await UtilsTerminal__NS__waitMilliseconds(poolingInterval);
|
|
6238
6238
|
try {
|
|
6239
6239
|
const resp = await taonRequest({
|
|
6240
6240
|
reqIndexNum: i,
|
|
@@ -6248,7 +6248,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6248
6248
|
httpErrorsCount++;
|
|
6249
6249
|
if (options.loopRequestsOnBackendError) {
|
|
6250
6250
|
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6251
|
-
error.body.json[
|
|
6251
|
+
error.body.json[CoreModels__NS__TaonHttpErrorCustomProp];
|
|
6252
6252
|
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6253
6253
|
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6254
6254
|
const resBool = await options.loopRequestsOnBackendError({
|
|
@@ -6306,23 +6306,23 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6306
6306
|
//#region init
|
|
6307
6307
|
async _() {
|
|
6308
6308
|
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
6309
|
-
Helpers.warn(`Skipping initing CRUD controller ${
|
|
6309
|
+
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers__NS__getName(this)} because entityClassResolveFn is not provided.`);
|
|
6310
6310
|
return;
|
|
6311
6311
|
}
|
|
6312
6312
|
let entityClassFn = this.entityClassResolveFn();
|
|
6313
6313
|
this.db = this.injectRepo(entityClassFn);
|
|
6314
6314
|
if (entityClassFn) {
|
|
6315
|
-
const configEntity = Reflect.getMetadata(
|
|
6315
|
+
const configEntity = Reflect.getMetadata(Symbols__NS__metadata.options.entity, ClassHelpers__NS__getClassFnFromObject(this));
|
|
6316
6316
|
if (configEntity?.createTable === false) {
|
|
6317
|
-
Helpers.warn(`Table for entity ${
|
|
6317
|
+
Helpers.warn(`Table for entity ${ClassHelpers__NS__getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
6318
6318
|
}
|
|
6319
6319
|
}
|
|
6320
6320
|
else {
|
|
6321
|
-
Helpers.error(`Entity class not provided for controller ${
|
|
6321
|
+
Helpers.error(`Entity class not provided for controller ${ClassHelpers__NS__getName(this)}.
|
|
6322
6322
|
|
|
6323
6323
|
Please provide entity as class property entityClassFn:
|
|
6324
6324
|
|
|
6325
|
-
class ${
|
|
6325
|
+
class ${ClassHelpers__NS__getName(this)} extends TaonBaseCrudController<Entity> {
|
|
6326
6326
|
// ...
|
|
6327
6327
|
entityClassResolveFn = ()=> MyEntityClass;
|
|
6328
6328
|
// ...
|
|
@@ -6341,7 +6341,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6341
6341
|
if (model === void 0) {
|
|
6342
6342
|
return;
|
|
6343
6343
|
}
|
|
6344
|
-
|
|
6344
|
+
Validators__NS__preventUndefinedModel(model, id);
|
|
6345
6345
|
let value = model[property];
|
|
6346
6346
|
let result;
|
|
6347
6347
|
if (_.isString(value) || _.isArray(value)) {
|
|
@@ -6375,7 +6375,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6375
6375
|
take: take,
|
|
6376
6376
|
skip: skip,
|
|
6377
6377
|
});
|
|
6378
|
-
response?.setHeader(
|
|
6378
|
+
response?.setHeader(Symbols__NS__old.X_TOTAL_COUNT, total);
|
|
6379
6379
|
// const lastPage = Math.ceil(total / take);
|
|
6380
6380
|
// const nextPage = page + 1 > lastPage ? null : page + 1;
|
|
6381
6381
|
// const prevPage = page - 1 < 1 ? null : page - 1;
|
|
@@ -6396,7 +6396,7 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6396
6396
|
return async (request, response) => {
|
|
6397
6397
|
if (this.db.repositoryExists) {
|
|
6398
6398
|
const { models, totalCount } = await this.db.getAll();
|
|
6399
|
-
response?.setHeader(
|
|
6399
|
+
response?.setHeader(Symbols__NS__old.X_TOTAL_COUNT, totalCount);
|
|
6400
6400
|
return models;
|
|
6401
6401
|
}
|
|
6402
6402
|
return [];
|
|
@@ -6593,9 +6593,9 @@ TaonBaseCrudController = __decorate([
|
|
|
6593
6593
|
*/
|
|
6594
6594
|
function TaonRepository(options) {
|
|
6595
6595
|
return function (constructor) {
|
|
6596
|
-
Reflect.defineMetadata(
|
|
6597
|
-
Reflect.defineMetadata(
|
|
6598
|
-
|
|
6596
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.repository, options, constructor);
|
|
6597
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
6598
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
6599
6599
|
};
|
|
6600
6600
|
}
|
|
6601
6601
|
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
@@ -6625,7 +6625,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6625
6625
|
if (!this.__dbQuery) {
|
|
6626
6626
|
if (!this.ctx) {
|
|
6627
6627
|
return; // TODO
|
|
6628
|
-
throw new Error(`[TaonBaseRepository] Context not inited for class ${
|
|
6628
|
+
throw new Error(`[TaonBaseRepository] Context not inited for class ${ClassHelpers__NS__getName(this)}`);
|
|
6629
6629
|
}
|
|
6630
6630
|
const connection = this.ctx?.connection;
|
|
6631
6631
|
if (!connection) {
|
|
@@ -6651,7 +6651,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6651
6651
|
return this[this.REPOS_CACHE_KEY];
|
|
6652
6652
|
}
|
|
6653
6653
|
const resolvedRepoClass = this.entityClassResolveFn();
|
|
6654
|
-
const resolvedRepoName =
|
|
6654
|
+
const resolvedRepoName = ClassHelpers__NS__getName(resolvedRepoClass);
|
|
6655
6655
|
const repo = this.ctx.repos.get(resolvedRepoName);
|
|
6656
6656
|
// TODO better recognize what is class in context
|
|
6657
6657
|
if (!repo) {
|
|
@@ -6833,7 +6833,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
6833
6833
|
where: { id: idOrEntity },
|
|
6834
6834
|
});
|
|
6835
6835
|
if (!deletedEntity) {
|
|
6836
|
-
Helpers.warn(`[TaonBaseRepository] Entity "${
|
|
6836
|
+
Helpers.warn(`[TaonBaseRepository] Entity "${ClassHelpers__NS__getName(this.repo.target)}" ` + `with id ${idOrEntity} not found, cannot remove`);
|
|
6837
6837
|
return;
|
|
6838
6838
|
}
|
|
6839
6839
|
const idCopy = deletedEntity.id;
|
|
@@ -7193,7 +7193,7 @@ let TaonBaseRepository = class TaonBaseRepository extends TaonBaseCustomReposito
|
|
|
7193
7193
|
//#region @websqlFunc
|
|
7194
7194
|
// console.log('repo', this.__repository);
|
|
7195
7195
|
// console.log(
|
|
7196
|
-
// `repo taget name "${
|
|
7196
|
+
// `repo taget name "${ClassHelpers__NS__getName(this.__repository.target)}"`,
|
|
7197
7197
|
// );
|
|
7198
7198
|
// debugger;
|
|
7199
7199
|
const totalCount = await this.repo.count();
|
|
@@ -7223,7 +7223,7 @@ TaonBaseRepository = __decorate([
|
|
|
7223
7223
|
// export function isActive(state: string): state is TaonGlobalStateStatus {
|
|
7224
7224
|
// return state === 'active';
|
|
7225
7225
|
// }
|
|
7226
|
-
const
|
|
7226
|
+
const TaonGlobalStateUtils__NS__assertAllowedTransition = (from, to) => {
|
|
7227
7227
|
if (!allowedTaonGlobalStatusOrders[from]?.includes(to)) {
|
|
7228
7228
|
throw new Error(`Invalid state transition: ${from} → ${to}`);
|
|
7229
7229
|
}
|
|
@@ -7258,7 +7258,7 @@ let TaonGlobalStateRepository = class TaonGlobalStateRepository extends TaonBase
|
|
|
7258
7258
|
async transitionTo(next) {
|
|
7259
7259
|
//#region @websqlFunc
|
|
7260
7260
|
const current = await this.getLastStatus();
|
|
7261
|
-
|
|
7261
|
+
TaonGlobalStateUtils__NS__assertAllowedTransition(current.status, next);
|
|
7262
7262
|
const newState = this.create({ status: next });
|
|
7263
7263
|
await this.save(newState);
|
|
7264
7264
|
return newState;
|
|
@@ -7325,9 +7325,9 @@ class TaonBaseProvider extends TaonBaseInjector {
|
|
|
7325
7325
|
*/
|
|
7326
7326
|
function TaonProvider(options) {
|
|
7327
7327
|
return function (constructor) {
|
|
7328
|
-
Reflect.defineMetadata(
|
|
7329
|
-
Reflect.defineMetadata(
|
|
7330
|
-
|
|
7328
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.provider, options, constructor);
|
|
7329
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
7330
|
+
ClassHelpers__NS__setName(constructor, options?.className || constructor.name);
|
|
7331
7331
|
};
|
|
7332
7332
|
}
|
|
7333
7333
|
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
@@ -7358,9 +7358,9 @@ TaonGlobalStateMiddleware = __decorate([
|
|
|
7358
7358
|
*/
|
|
7359
7359
|
function TaonSubscriber(options) {
|
|
7360
7360
|
return function (constructor) {
|
|
7361
|
-
Reflect.defineMetadata(
|
|
7362
|
-
Reflect.defineMetadata(
|
|
7363
|
-
|
|
7361
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.subscriber, options, constructor);
|
|
7362
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
7363
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
7364
7364
|
};
|
|
7365
7365
|
}
|
|
7366
7366
|
class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
@@ -7568,13 +7568,13 @@ class TaonBaseMigration extends TaonBaseInjector {
|
|
|
7568
7568
|
return true;
|
|
7569
7569
|
}
|
|
7570
7570
|
getDescription() {
|
|
7571
|
-
return _.startCase(
|
|
7571
|
+
return _.startCase(ClassHelpers__NS__getName(this));
|
|
7572
7572
|
}
|
|
7573
7573
|
async up(queryRunner) {
|
|
7574
|
-
console.log(`[TaonBaseMigration] Running migration UP "${
|
|
7574
|
+
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers__NS__getName(this)}"`);
|
|
7575
7575
|
}
|
|
7576
7576
|
async down(queryRunner) {
|
|
7577
|
-
console.log(`[TaonBaseMigration] Running migration DOWN "${
|
|
7577
|
+
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers__NS__getName(this)}"`);
|
|
7578
7578
|
}
|
|
7579
7579
|
}
|
|
7580
7580
|
|
|
@@ -7733,7 +7733,7 @@ function typeFromEntity(component, entity) {
|
|
|
7733
7733
|
if (isArray) {
|
|
7734
7734
|
entity = _.first(entity);
|
|
7735
7735
|
}
|
|
7736
|
-
let name =
|
|
7736
|
+
let name = ClassHelpers__NS__getName(component);
|
|
7737
7737
|
let res = { name, component, entity, isArray };
|
|
7738
7738
|
// console.log(res);
|
|
7739
7739
|
return res;
|
|
@@ -7755,7 +7755,7 @@ function RegisterComponentType(className, ...optionslNames) {
|
|
|
7755
7755
|
RegisterComponentType.prototype.types = [];
|
|
7756
7756
|
}
|
|
7757
7757
|
return function (target, propertyKey, descriptor) {
|
|
7758
|
-
|
|
7758
|
+
ClassHelpers__NS__setName(target, className);
|
|
7759
7759
|
RegisterComponentType.prototype.types.push(typeFromEntity(target));
|
|
7760
7760
|
optionslNames.forEach(name => {
|
|
7761
7761
|
RegisterComponentType.prototype.types.push(typeFromName(target, name));
|
|
@@ -7777,7 +7777,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7777
7777
|
if (level === maxLevel) {
|
|
7778
7778
|
return [];
|
|
7779
7779
|
}
|
|
7780
|
-
const mapping =
|
|
7780
|
+
const mapping = Mapping__NS__getModelsMapping(target);
|
|
7781
7781
|
// console.log('mapping', mapping)
|
|
7782
7782
|
const fieldNames = CLASS.describeProperites(target);
|
|
7783
7783
|
const checkExclude = _.isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
@@ -7981,9 +7981,9 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7981
7981
|
*/
|
|
7982
7982
|
function TaonMigration(options) {
|
|
7983
7983
|
return function (constructor) {
|
|
7984
|
-
Reflect.defineMetadata(
|
|
7985
|
-
Reflect.defineMetadata(
|
|
7986
|
-
|
|
7984
|
+
Reflect.defineMetadata(Symbols__NS__metadata.options.migration, options, constructor);
|
|
7985
|
+
Reflect.defineMetadata(Symbols__NS__metadata.className, options?.className || constructor.name, constructor);
|
|
7986
|
+
ClassHelpers__NS__setName(constructor, options?.className);
|
|
7987
7987
|
};
|
|
7988
7988
|
}
|
|
7989
7989
|
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
@@ -7994,7 +7994,7 @@ class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
|
7994
7994
|
/**
|
|
7995
7995
|
* Remove global taon loader from env.ts [loading.preAngularBootstrap]
|
|
7996
7996
|
*/
|
|
7997
|
-
const
|
|
7997
|
+
const Taon__NS__removeLoader = (afterMS = 0) => {
|
|
7998
7998
|
return new Promise(resolve => {
|
|
7999
7999
|
setTimeout(() => {
|
|
8000
8000
|
globalThis?.window?.document
|
|
@@ -8008,7 +8008,7 @@ const Taon_removeLoader = (afterMS = 0) => {
|
|
|
8008
8008
|
}, afterMS);
|
|
8009
8009
|
});
|
|
8010
8010
|
};
|
|
8011
|
-
const
|
|
8011
|
+
const Taon__NS__error = (opt) => {
|
|
8012
8012
|
throw () => {
|
|
8013
8013
|
if (typeof opt === 'string') {
|
|
8014
8014
|
opt = {
|
|
@@ -8018,7 +8018,7 @@ const Taon_error = (opt) => {
|
|
|
8018
8018
|
return opt;
|
|
8019
8019
|
};
|
|
8020
8020
|
};
|
|
8021
|
-
const
|
|
8021
|
+
const Taon__NS__getResponseValue = getResponseValue;
|
|
8022
8022
|
//#region class decorators
|
|
8023
8023
|
// TODO new 5.8 typescript is not allowing this
|
|
8024
8024
|
// export import Controller = controllerDecorator.TaonController;
|
|
@@ -8030,22 +8030,22 @@ const Taon_getResponseValue = getResponseValue;
|
|
|
8030
8030
|
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8031
8031
|
//#endregion
|
|
8032
8032
|
//#region aliases to helpers
|
|
8033
|
-
const
|
|
8034
|
-
const
|
|
8035
|
-
const
|
|
8036
|
-
const
|
|
8033
|
+
const Taon__NS__isBrowser = coreHelpers.Helpers.isBrowser;
|
|
8034
|
+
const Taon__NS__isNode = coreHelpers.Helpers.isNode;
|
|
8035
|
+
const Taon__NS__isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
8036
|
+
const Taon__NS__isElectron = coreHelpers.Helpers.isElectron;
|
|
8037
8037
|
//#endregion
|
|
8038
|
-
const
|
|
8039
|
-
const
|
|
8040
|
-
const
|
|
8038
|
+
const Taon__NS__createContext = createContext;
|
|
8039
|
+
const Taon__NS__createContextTemplate = createContextTemplate;
|
|
8040
|
+
const Taon__NS__inject = inject;
|
|
8041
8041
|
/**
|
|
8042
8042
|
* @deprecated
|
|
8043
8043
|
* use createContext instead
|
|
8044
8044
|
*/
|
|
8045
|
-
const
|
|
8045
|
+
const Taon__NS__init = async (options) => {
|
|
8046
8046
|
const TaonBaseContext = (await Promise.resolve().then(function () { return baseContext; }))
|
|
8047
8047
|
.TaonBaseContext;
|
|
8048
|
-
const context =
|
|
8048
|
+
const context = Taon__NS__createContext(() => ({
|
|
8049
8049
|
appId: 'default-app-not-used-anymore',
|
|
8050
8050
|
contextName: 'default',
|
|
8051
8051
|
host: options.host,
|
|
@@ -8179,5 +8179,5 @@ const TAON_FLATTEN_MAPPING = {
|
|
|
8179
8179
|
* Generated bundle index. Do not edit.
|
|
8180
8180
|
*/
|
|
8181
8181
|
|
|
8182
|
-
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL,
|
|
8182
|
+
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers__NS__asyncHandler, ClassHelpers__NS__ensureClassConfig, ClassHelpers__NS__ensureMethodConfig, ClassHelpers__NS__getClassConfig, ClassHelpers__NS__getClassFnFromObject, ClassHelpers__NS__getControllerConfigs, ClassHelpers__NS__getFullInternalName, ClassHelpers__NS__getMethodsNames, ClassHelpers__NS__getName, ClassHelpers__NS__getOrginalClass, ClassHelpers__NS__getUniqueKey, ClassHelpers__NS__hasParentClassWithName, ClassHelpers__NS__isContextClassObject, ClassHelpers__NS__setName, ContextDbMigrations, ContextsEndpointStorage, ControllerConfig, Cookie, DELETE, DITaonContainer, DateTimeColumn, DecimalNumberColumn, DecoratorAbstractOpt, EndpointContext, EntityProcess, FormlyHorizontalWrapper, GET, HEAD, HTML, Header, MethodConfig, MockNamespaceIpc, MockServerIpc, MockSocketIpc, Models__NS__ClassType, Models__NS__ClassTypeKey, Models__NS__DatabaseConfig, Models__NS__DatabaseConfigTypeOrm, Models__NS__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__NS__REALTIME, Symbols__NS__classMethodsNames, Symbols__NS__classNameStaticProperty, Symbols__NS__ctxInClassOrClassObj, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__old, Symbols__NS__orignalClass, Symbols__NS__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__NS__defaultType, TaonHelpers__NS__fillUpTo, TaonHelpers__NS__firstStringOrElemFromArray, TaonHelpers__NS__getExpressPath, TaonHelpers__NS__ipcKeyNameRequest, TaonHelpers__NS__ipcKeyNameResponse, TaonHelpers__NS__isGoodPath, TaonHelpers__NS__isPlainFileOrFolder, TaonHelpers__NS__parseJSONwithStringJSONs, TaonHelpers__NS__tryTransformParam, TaonHelpers__NS__websqlMocks, TaonMiddleware, TaonMiddlewareOptions, TaonMigration, TaonMigrationOptions, TaonProvider, TaonProviderOptions, TaonRepository, TaonRepositoryOptions, TaonRestResponseWrapper, TaonSubscriber, TaonSubscriberOptions, TaonTempDatabasesFolder, TaonTempRoutesFolder, Taon__NS__createContext, Taon__NS__createContextTemplate, Taon__NS__error, Taon__NS__getResponseValue, Taon__NS__init, Taon__NS__inject, Taon__NS__isBrowser, Taon__NS__isElectron, Taon__NS__isNode, Taon__NS__isWebSQL, Taon__NS__removeLoader, Validators__NS__checkIfMethodsWithReponseTYpeAlowed, Validators__NS__classNameVlidation, Validators__NS__preventUndefinedModel, Validators__NS__validateClassFunctions, apiPrefix, cloneObj, controllerConfigFrom, createContext, createContextTemplate, findTypeForEntity, getFromlyConfigFor, getRegisteredComponents, getResponseValue, getTransformFunction, inject, singleTransform, typeFromEntity, typeFromName };
|
|
8183
8183
|
//# sourceMappingURL=taon-websql.mjs.map
|