taon 21.0.38 → 21.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/fesm2022/taon-browser.mjs +14 -15
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +3 -3
- package/browser-prod/fesm2022/taon-browser.mjs +167 -168
- 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 +3 -3
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/context-db-migrations.js +1 -1
- package/lib/context-db-migrations.js.map +1 -1
- package/lib/endpoint-context.js +11 -11
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/realtime/realtime-core.js +2 -2
- package/lib/realtime/realtime-core.js.map +1 -1
- package/lib/realtime/realtime-server.js +2 -2
- package/lib/realtime/realtime-server.js.map +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 +3 -3
- package/lib-prod/base-classes/base-class.js.map +1 -1
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.js +5 -5
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-migration.js +1 -1
- package/lib-prod/base-classes/base-migration.js.map +1 -1
- package/lib-prod/base-classes/base-repository.js +7 -7
- 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/context-db-migrations.js +1 -1
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.js +4 -4
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.js +1 -1
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/endpoint-context.js +75 -75
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.js +23 -23
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/formly/fromly.js +20 -20
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/formly/type-from-entity.js +5 -5
- package/lib-prod/formly/type-from-entity.js.map +1 -1
- package/lib-prod/helpers/class-helpers.js +16 -16
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/clone-obj.js +3 -3
- package/lib-prod/helpers/clone-obj.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.js +4 -4
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.js +5 -5
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/models.js +2 -2
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/orm/columns.js +6 -6
- package/lib-prod/orm/columns.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +6 -6
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-core.js +2 -2
- package/lib-prod/realtime/realtime-core.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +6 -6
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.js +2 -2
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/symbols.js +3 -3
- 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.js +7 -7
- package/lib-prod/validators.js.map +1 -1
- package/package.json +3 -28
- package/websql/fesm2022/taon-websql.mjs +20 -21
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +3 -3
- package/websql-prod/fesm2022/taon-websql.mjs +197 -198
- 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 +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import
|
|
3
|
-
import { _, Utils__NS__uniqArray, Helpers, UtilsOs__NS__isRunningInDocker, config, CoreModels__NS__SPECIAL_APP_READY_MESSAGE, UtilsOs__NS__isRunningInCliMode, crossPlatformPath, UtilsTerminal__NS__waitMilliseconds, CoreModels__NS__TaonHttpErrorCustomProp } from 'tnp-core/browser-prod';
|
|
2
|
+
import { ___NS__camelCase, ___NS__isUndefined, ___NS__isArray, ___NS__isFunction, ___NS__isNull, ___NS__isObject, ___NS__isRegExp, ___NS__isBuffer, ___NS__isArrayBuffer, ___NS__isDate, ___NS__isString, Utils__NS__uniqArray, ___NS__uniq, ___NS__times, ___NS__first, ___NS__cloneDeep, ___NS__merge, Helpers__NS__logInfo, UtilsOs__NS__isWebSQL, UtilsOs__NS__isElectron, Helpers__NS__error, UtilsOs__NS__isRunningInDocker, Helpers__NS__throwError, ___NS__isBoolean, ___NS__isNil, ___NS__set, Helpers__NS__info, ___NS__slice, ___NS__last, UtilsOs__NS__isNode, UtilsOs__NS__isBrowser, Helpers__NS__isBlob, config, CoreModels__NS__SPECIAL_APP_READY_MESSAGE, UtilsOs__NS__isRunningInCliMode, Helpers__NS__log, ___NS__isNumber, crossPlatformPath, UtilsTerminal__NS__waitMilliseconds, CoreModels__NS__TaonHttpErrorCustomProp, Helpers__NS__warn, ___NS__startCase } from 'tnp-core/browser-prod';
|
|
4
3
|
import axios from 'axios';
|
|
5
4
|
import { JSON10 } from 'json10/browser-prod';
|
|
6
5
|
import { walk } from 'lodash-walk-object/browser-prod';
|
|
@@ -611,7 +610,7 @@ class Realtime {
|
|
|
611
610
|
// className: string,
|
|
612
611
|
// propertyName: string,
|
|
613
612
|
// ) {
|
|
614
|
-
// return `${contextName}:room${
|
|
613
|
+
// return `${contextName}:room${___NS__camelCase(className)}${propertyName}`.toLowerCase();
|
|
615
614
|
// }
|
|
616
615
|
//#region custom events in rooms
|
|
617
616
|
ROOM_NAME_CUSTOM(contextName, customEvent) {
|
|
@@ -626,7 +625,7 @@ class Realtime {
|
|
|
626
625
|
//#endregion
|
|
627
626
|
//#region entity events
|
|
628
627
|
ROOM_NAME_UPDATE_ENTITY(contextName, className, entityId) {
|
|
629
|
-
return `${contextName}:room${
|
|
628
|
+
return `${contextName}:room${___NS__camelCase(className)}${entityId}`.toLowerCase();
|
|
630
629
|
}
|
|
631
630
|
ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(contextName) {
|
|
632
631
|
return `${contextName}:${this.KEYroomSubscribe}EntityEvents`;
|
|
@@ -637,7 +636,7 @@ class Realtime {
|
|
|
637
636
|
//#endregion
|
|
638
637
|
//#region entity property events
|
|
639
638
|
ROOM_NAME_UPDATE_ENTITY_PROPERTY(contextName, className, property, entityId) {
|
|
640
|
-
return `${contextName}:room${
|
|
639
|
+
return `${contextName}:room${___NS__camelCase(className)}${___NS__camelCase(property)}${entityId}`.toLowerCase();
|
|
641
640
|
}
|
|
642
641
|
ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(contextName) {
|
|
643
642
|
return `${contextName}:${this.KEYroomSubscribe}EntityPropertyEvents`;
|
|
@@ -695,7 +694,7 @@ const Symbols__NS__old = {
|
|
|
695
694
|
const Validators__NS__classNameVlidation = (className, target) => {
|
|
696
695
|
setTimeout(() => {
|
|
697
696
|
// console.log(`check after timeout ${className} , production mode: ${FrameworkContext.isProductionMode}`)
|
|
698
|
-
if (
|
|
697
|
+
if (___NS__isUndefined(className)) {
|
|
699
698
|
throw `[Taon]
|
|
700
699
|
Please provide "className" property for each Controller and Entity:
|
|
701
700
|
|
|
@@ -715,7 +714,7 @@ const Validators__NS__classNameVlidation = (className, target) => {
|
|
|
715
714
|
`;
|
|
716
715
|
}
|
|
717
716
|
});
|
|
718
|
-
return
|
|
717
|
+
return ___NS__isUndefined(className) ? target.name : className;
|
|
719
718
|
};
|
|
720
719
|
//#endregion
|
|
721
720
|
//#region validate method config
|
|
@@ -743,8 +742,8 @@ const Validators__NS__checkIfMethodsWithReponseTYpeAlowed = (methods, current) =
|
|
|
743
742
|
//#region validate class functions
|
|
744
743
|
// TODO
|
|
745
744
|
const Validators__NS__validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
746
|
-
if (
|
|
747
|
-
controllers.filter(f => !
|
|
745
|
+
if (___NS__isArray(controllers) &&
|
|
746
|
+
controllers.filter(f => !___NS__isFunction(f)).length > 0) {
|
|
748
747
|
console.error('controllers', controllers);
|
|
749
748
|
throw `
|
|
750
749
|
|
|
@@ -752,8 +751,8 @@ const Validators__NS__validateClassFunctions = (controllers, entities, proviers,
|
|
|
752
751
|
|
|
753
752
|
`;
|
|
754
753
|
}
|
|
755
|
-
if (
|
|
756
|
-
entities.filter(f => !
|
|
754
|
+
if (___NS__isArray(entities) &&
|
|
755
|
+
entities.filter(f => !___NS__isFunction(f)).length > 0) {
|
|
757
756
|
console.error('entites', entities);
|
|
758
757
|
throw `
|
|
759
758
|
|
|
@@ -764,7 +763,7 @@ const Validators__NS__validateClassFunctions = (controllers, entities, proviers,
|
|
|
764
763
|
};
|
|
765
764
|
//#endregion
|
|
766
765
|
const Validators__NS__preventUndefinedModel = (model, id) => {
|
|
767
|
-
if (
|
|
766
|
+
if (___NS__isUndefined(model)) {
|
|
768
767
|
throw `Bad update by id, config, id: ${id}`;
|
|
769
768
|
}
|
|
770
769
|
};
|
|
@@ -779,7 +778,7 @@ const Validators__NS__preventUndefinedModel = (model, id) => {
|
|
|
779
778
|
* TODO - repalce in every place when getting class fn from object
|
|
780
779
|
*/
|
|
781
780
|
const ClassHelpers__NS__getClassFnFromObject = (json) => {
|
|
782
|
-
if (
|
|
781
|
+
if (___NS__isUndefined(json) || ___NS__isNull(json)) {
|
|
783
782
|
return;
|
|
784
783
|
}
|
|
785
784
|
if (json.constructor) {
|
|
@@ -804,7 +803,7 @@ const ClassHelpers__NS__getName = (classFnOrObject) => {
|
|
|
804
803
|
return ((classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
805
804
|
? classFnOrObject[Symbols__NS__classNameStaticProperty]
|
|
806
805
|
: classFnOrObject?.constructor[Symbols__NS__classNameStaticProperty]) ||
|
|
807
|
-
(
|
|
806
|
+
(___NS__isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
808
807
|
};
|
|
809
808
|
//#endregion
|
|
810
809
|
const ClassHelpers__NS__getOrginalClass = (classFnOrObject) => {
|
|
@@ -828,7 +827,7 @@ const ClassHelpers__NS__getFullInternalName = (classFnOrObject) => {
|
|
|
828
827
|
//#endregion
|
|
829
828
|
//#region get unique key
|
|
830
829
|
const ClassHelpers__NS__getUniqueKey = (classFnOrObject) => {
|
|
831
|
-
const classFn =
|
|
830
|
+
const classFn = ___NS__isFunction(classFnOrObject)
|
|
832
831
|
? classFnOrObject
|
|
833
832
|
: classFnOrObject.constructor;
|
|
834
833
|
const config = Reflect.getMetadata(Symbols__NS__metadata.options.entity, classFn);
|
|
@@ -837,18 +836,18 @@ const ClassHelpers__NS__getUniqueKey = (classFnOrObject) => {
|
|
|
837
836
|
//#endregion
|
|
838
837
|
//#region is class object
|
|
839
838
|
const ClassHelpers__NS__isContextClassObject = (obj) => {
|
|
840
|
-
if (!
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
839
|
+
if (!___NS__isObject(obj) ||
|
|
840
|
+
___NS__isArray(obj) ||
|
|
841
|
+
___NS__isRegExp(obj) ||
|
|
842
|
+
___NS__isBuffer(obj) ||
|
|
843
|
+
___NS__isArrayBuffer(obj)) {
|
|
845
844
|
return false;
|
|
846
845
|
}
|
|
847
|
-
if (
|
|
846
|
+
if (___NS__isDate(obj)) {
|
|
848
847
|
return true;
|
|
849
848
|
}
|
|
850
849
|
const className = ClassHelpers__NS__getName(obj);
|
|
851
|
-
return
|
|
850
|
+
return ___NS__isString(className) && className !== 'Object';
|
|
852
851
|
};
|
|
853
852
|
//#endregion
|
|
854
853
|
//#region get name
|
|
@@ -865,9 +864,9 @@ const ClassHelpers__NS__hasParentClassWithName = (target, className, targets = [
|
|
|
865
864
|
}
|
|
866
865
|
targets.push(target);
|
|
867
866
|
let targetProto = Object.getPrototypeOf(target);
|
|
868
|
-
if (
|
|
867
|
+
if (___NS__isFunction(targetProto) &&
|
|
869
868
|
ClassHelpers__NS__getName(targetProto) === className) {
|
|
870
|
-
// console.log(`true "${
|
|
869
|
+
// console.log(`true "${___NS__first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
871
870
|
return true;
|
|
872
871
|
}
|
|
873
872
|
return ClassHelpers__NS__hasParentClassWithName(targetProto, className, targets);
|
|
@@ -907,7 +906,7 @@ const ClassHelpers__NS__getMethodsNames = (classOrClassInstance, allMethodsNames
|
|
|
907
906
|
if (!classOrClassInstance) {
|
|
908
907
|
return Utils__NS__uniqArray(allMethodsNames);
|
|
909
908
|
}
|
|
910
|
-
const isClassFunction =
|
|
909
|
+
const isClassFunction = ___NS__isFunction(classOrClassInstance);
|
|
911
910
|
const classFun = isClassFunction
|
|
912
911
|
? classOrClassInstance
|
|
913
912
|
: Object.getPrototypeOf(classOrClassInstance);
|
|
@@ -915,7 +914,7 @@ const ClassHelpers__NS__getMethodsNames = (classOrClassInstance, allMethodsNames
|
|
|
915
914
|
? classOrClassInstance?.prototype
|
|
916
915
|
: classOrClassInstance;
|
|
917
916
|
const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
|
|
918
|
-
const properties =
|
|
917
|
+
const properties = ___NS__uniq([
|
|
919
918
|
...Object.getOwnPropertyNames(objectToCheck || {}),
|
|
920
919
|
...Object.getOwnPropertyNames(prototypeObj || {}),
|
|
921
920
|
...Object.keys(objectToCheck || {}),
|
|
@@ -934,13 +933,13 @@ const ClassHelpers__NS__getMethodsNames = (classOrClassInstance, allMethodsNames
|
|
|
934
933
|
//#endregion
|
|
935
934
|
//#region get controller configs
|
|
936
935
|
const ClassHelpers__NS__getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
937
|
-
if (!
|
|
936
|
+
if (!___NS__isFunction(target)) {
|
|
938
937
|
throw `[typescript-class-helper][getControllerConfigs] Cannot get class config from: ${target}`;
|
|
939
938
|
}
|
|
940
939
|
let config;
|
|
941
940
|
const parentClass = Object.getPrototypeOf(target);
|
|
942
941
|
const parentName = parentClass ? ClassHelpers__NS__getName(parentClass) : void 0;
|
|
943
|
-
const isValidParent =
|
|
942
|
+
const isValidParent = ___NS__isFunction(parentClass) && parentName !== '';
|
|
944
943
|
config = controllerConfigFrom(ClassHelpers__NS__getClassConfig(target));
|
|
945
944
|
configs.push(config);
|
|
946
945
|
return isValidParent
|
|
@@ -997,7 +996,7 @@ const ClassHelpers__NS__getClassConfig = (constructor) => {
|
|
|
997
996
|
//namespace TaonHelpers
|
|
998
997
|
//#region fillUpTo string
|
|
999
998
|
const TaonHelpers__NS__fillUpTo = (s, nCharacters) => {
|
|
1000
|
-
return
|
|
999
|
+
return ___NS__times(nCharacters, n => {
|
|
1001
1000
|
if (s.charAt(n)) {
|
|
1002
1001
|
return s.charAt(n);
|
|
1003
1002
|
}
|
|
@@ -1012,7 +1011,7 @@ const TaonHelpers__NS__isGoodPath = (p) => {
|
|
|
1012
1011
|
//#endregion
|
|
1013
1012
|
const TaonHelpers__NS__firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
1014
1013
|
if (Array.isArray(stringOrArrayOfString)) {
|
|
1015
|
-
return
|
|
1014
|
+
return ___NS__first(stringOrArrayOfString);
|
|
1016
1015
|
}
|
|
1017
1016
|
return stringOrArrayOfString;
|
|
1018
1017
|
};
|
|
@@ -1062,7 +1061,7 @@ const TaonHelpers__NS__defaultType = value => {
|
|
|
1062
1061
|
//#region parse json with string jsons
|
|
1063
1062
|
const TaonHelpers__NS__parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1064
1063
|
// console.log('checking object', object)
|
|
1065
|
-
if (!
|
|
1064
|
+
if (!___NS__isObject(object)) {
|
|
1066
1065
|
if (waring) {
|
|
1067
1066
|
console.error(`
|
|
1068
1067
|
parseJSONwithStringJSONs(...)
|
|
@@ -1071,7 +1070,7 @@ const TaonHelpers__NS__parseJSONwithStringJSONs = (object, waring = false) => {
|
|
|
1071
1070
|
}
|
|
1072
1071
|
return object;
|
|
1073
1072
|
}
|
|
1074
|
-
let res =
|
|
1073
|
+
let res = ___NS__cloneDeep(object);
|
|
1075
1074
|
Object.keys(res).forEach(key => {
|
|
1076
1075
|
let isJson = false;
|
|
1077
1076
|
try {
|
|
@@ -1193,7 +1192,7 @@ class Models__NS__DatabaseConfigTypeOrm {
|
|
|
1193
1192
|
//#region models / database config
|
|
1194
1193
|
class Models__NS__DatabaseConfig extends Models__NS__DatabaseConfigTypeOrm {
|
|
1195
1194
|
static from(databasePartialConfig) {
|
|
1196
|
-
return
|
|
1195
|
+
return ___NS__merge(new Models__NS__DatabaseConfig(), databasePartialConfig);
|
|
1197
1196
|
}
|
|
1198
1197
|
get databaseConfigTypeORM() {
|
|
1199
1198
|
/* */
|
|
@@ -1245,7 +1244,7 @@ class RealtimeSubsManager {
|
|
|
1245
1244
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1246
1245
|
}
|
|
1247
1246
|
else {
|
|
1248
|
-
if (
|
|
1247
|
+
if (___NS__isString(this.options.property)) {
|
|
1249
1248
|
const subscribeEvent = Symbols__NS__REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1250
1249
|
// this means: send to current client entity property events updates
|
|
1251
1250
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
@@ -1282,7 +1281,7 @@ class RealtimeSubsManager {
|
|
|
1282
1281
|
realtime.emit(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.options.core.ctx.contextName), roomName);
|
|
1283
1282
|
}
|
|
1284
1283
|
else {
|
|
1285
|
-
if (
|
|
1284
|
+
if (___NS__isString(property)) {
|
|
1286
1285
|
realtime.emit(Symbols__NS__REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1287
1286
|
}
|
|
1288
1287
|
else {
|
|
@@ -1322,7 +1321,7 @@ class RealtimeClient {
|
|
|
1322
1321
|
this.core = core;
|
|
1323
1322
|
if (!core.ctx.disabledRealtime) {
|
|
1324
1323
|
// this.core.ctx.logRealtime &&
|
|
1325
|
-
//
|
|
1324
|
+
// Helpers__NS__info(`
|
|
1326
1325
|
// [ctx=${this.core.ctx.contextName}] init RealtimeClient (type: ${this.core.ctx.contextType})
|
|
1327
1326
|
// `);
|
|
1328
1327
|
this.init();
|
|
@@ -1340,14 +1339,14 @@ class RealtimeClient {
|
|
|
1340
1339
|
this.core.ctx.config.frontendHost !== '' &&
|
|
1341
1340
|
this.core.ctx.isRunningInsideDocker) {
|
|
1342
1341
|
this.core.ctx.logRealtime &&
|
|
1343
|
-
|
|
1342
|
+
Helpers__NS__logInfo(`[${this.core.ctx.contextName}] USING FRONTEND HOST` +
|
|
1344
1343
|
` ${this.core.ctx.config.frontendHost} FOR REALTIME`);
|
|
1345
1344
|
nspPath.global = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.global.pathname}`);
|
|
1346
1345
|
nspPath.realtime = new URL(`${this.core.ctx.frontendHostUri.origin}${nspPath.realtime.pathname}`);
|
|
1347
1346
|
}
|
|
1348
1347
|
else {
|
|
1349
1348
|
this.core.ctx.logRealtime &&
|
|
1350
|
-
|
|
1349
|
+
Helpers__NS__logInfo(`[${this.core.ctx.contextName}] Not using frontend host for realtime`);
|
|
1351
1350
|
}
|
|
1352
1351
|
this.core.ctx.logRealtime &&
|
|
1353
1352
|
console.info('[CLIENT] NAMESPACE GLOBAL ', nspPath.global.href + ` host: ${this.core.ctx.host}`);
|
|
@@ -1399,7 +1398,7 @@ class RealtimeClient {
|
|
|
1399
1398
|
*/
|
|
1400
1399
|
listenChangesEntity(entityClassFnOrObj, options) {
|
|
1401
1400
|
options = options || {};
|
|
1402
|
-
if (
|
|
1401
|
+
if (___NS__isObject(entityClassFnOrObj)) {
|
|
1403
1402
|
const orgObj = entityClassFnOrObj;
|
|
1404
1403
|
entityClassFnOrObj =
|
|
1405
1404
|
ClassHelpers__NS__getClassFnFromObject(entityClassFnOrObj);
|
|
@@ -1411,7 +1410,7 @@ class RealtimeClient {
|
|
|
1411
1410
|
//#region parameters validation
|
|
1412
1411
|
const { property, customEvent } = options;
|
|
1413
1412
|
const className = !customEvent && ClassHelpers__NS__getName(entityClassFnOrObj);
|
|
1414
|
-
if (
|
|
1413
|
+
if (___NS__isString(property)) {
|
|
1415
1414
|
if (property.trim() === '') {
|
|
1416
1415
|
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
1417
1416
|
}
|
|
@@ -1437,7 +1436,7 @@ to use socket realtime connection;
|
|
|
1437
1436
|
roomName = Symbols__NS__REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1438
1437
|
}
|
|
1439
1438
|
else {
|
|
1440
|
-
roomName =
|
|
1439
|
+
roomName = ___NS__isString(property)
|
|
1441
1440
|
? Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1442
1441
|
: Symbols__NS__REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1443
1442
|
}
|
|
@@ -1790,7 +1789,7 @@ class RealtimeServer {
|
|
|
1790
1789
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
1791
1790
|
return;
|
|
1792
1791
|
}
|
|
1793
|
-
if (
|
|
1792
|
+
if (___NS__isArray(property)) {
|
|
1794
1793
|
property.forEach(propertyFromArr => {
|
|
1795
1794
|
this.triggerChanges(entityObjOrClass, propertyFromArr, idToTrigger);
|
|
1796
1795
|
});
|
|
@@ -2467,7 +2466,7 @@ class RealtimeCore {
|
|
|
2467
2466
|
// console.log(`
|
|
2468
2467
|
// [ctx=${this.ctx.contextName}] realtime strategy: ${this.strategy}, context type: ${this.ctx.contextType}
|
|
2469
2468
|
// `);
|
|
2470
|
-
if (
|
|
2469
|
+
if (UtilsOs__NS__isWebSQL) {
|
|
2471
2470
|
this.server = new RealtimeServer(this);
|
|
2472
2471
|
// console.log('DONE INITING SERVER');
|
|
2473
2472
|
this.client = new RealtimeClient(this);
|
|
@@ -2505,7 +2504,7 @@ class RealtimeCore {
|
|
|
2505
2504
|
nsp = nsp === '/' ? '' : nsp;
|
|
2506
2505
|
const contextNameForCommunication = this.ctx.contextNameForCommunication;
|
|
2507
2506
|
let prefix = `${apiPrefix}/${contextNameForCommunication}/udp`;
|
|
2508
|
-
if (
|
|
2507
|
+
if (UtilsOs__NS__isElectron) {
|
|
2509
2508
|
prefix = ``;
|
|
2510
2509
|
}
|
|
2511
2510
|
const href = `${this.ctx.uriOrigin}${this.ctx.uriPathnameOrNothingIfRoot}` +
|
|
@@ -2540,37 +2539,37 @@ class EndpointContext {
|
|
|
2540
2539
|
//#endregion
|
|
2541
2540
|
//#region fields / logs
|
|
2542
2541
|
get logHttp() {
|
|
2543
|
-
if (
|
|
2542
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2544
2543
|
return !!this.config.logs.http;
|
|
2545
2544
|
}
|
|
2546
2545
|
return this.config?.logs === true;
|
|
2547
2546
|
}
|
|
2548
2547
|
get logRealtime() {
|
|
2549
|
-
if (
|
|
2548
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2550
2549
|
return !!this.config.logs.realtime;
|
|
2551
2550
|
}
|
|
2552
2551
|
return this.config?.logs === true;
|
|
2553
2552
|
}
|
|
2554
2553
|
get logFramework() {
|
|
2555
|
-
if (
|
|
2554
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2556
2555
|
return !!this.config.logs.framework;
|
|
2557
2556
|
}
|
|
2558
2557
|
return this.config?.logs === true;
|
|
2559
2558
|
}
|
|
2560
2559
|
get logRoutes() {
|
|
2561
|
-
if (
|
|
2560
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2562
2561
|
return !!this.config.logs.routes;
|
|
2563
2562
|
}
|
|
2564
2563
|
return this.config?.logs === true;
|
|
2565
2564
|
}
|
|
2566
2565
|
get logDb() {
|
|
2567
|
-
if (
|
|
2566
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2568
2567
|
return !!this.config.logs.db;
|
|
2569
2568
|
}
|
|
2570
2569
|
return this.config?.logs === true;
|
|
2571
2570
|
}
|
|
2572
2571
|
get logMigrations() {
|
|
2573
|
-
if (
|
|
2572
|
+
if (___NS__isObject(this.config?.logs)) {
|
|
2574
2573
|
return !!this.config.logs.migrations;
|
|
2575
2574
|
}
|
|
2576
2575
|
return this.config?.logs === true;
|
|
@@ -2705,10 +2704,10 @@ class EndpointContext {
|
|
|
2705
2704
|
//#region gather all instances for all contexts
|
|
2706
2705
|
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
2707
2706
|
// this thinng belowe is nice for debugging purpose
|
|
2708
|
-
// if (
|
|
2707
|
+
// if (___NS__isUndefined(cloneClassFunction[Symbols__NS__orignalClassClonesObj])) {
|
|
2709
2708
|
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = {};
|
|
2710
2709
|
// }
|
|
2711
|
-
// if (
|
|
2710
|
+
// if (___NS__isUndefined(TaonBaseClass[Symbols__NS__orignalClassClonesObj])) {
|
|
2712
2711
|
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = {};
|
|
2713
2712
|
// }
|
|
2714
2713
|
// const all = {
|
|
@@ -2730,7 +2729,7 @@ class EndpointContext {
|
|
|
2730
2729
|
for (const key of Object.keys(classesInput || {})) {
|
|
2731
2730
|
const TaonBaseClass = classesInput[key];
|
|
2732
2731
|
if (!TaonBaseClass) {
|
|
2733
|
-
|
|
2732
|
+
Helpers__NS__error(`Class ${key} is not defined in context ${ctx.contextName}
|
|
2734
2733
|
|
|
2735
2734
|
Please check if you have correct import in context file
|
|
2736
2735
|
|
|
@@ -2767,7 +2766,7 @@ class EndpointContext {
|
|
|
2767
2766
|
// @ts-ignore
|
|
2768
2767
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
2769
2768
|
this.config = this.configFn({});
|
|
2770
|
-
if (
|
|
2769
|
+
if (___NS__isObject(this.config.database)) {
|
|
2771
2770
|
this.config.database = Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
2772
2771
|
}
|
|
2773
2772
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
@@ -2782,15 +2781,15 @@ class EndpointContext {
|
|
|
2782
2781
|
if (this.config.host &&
|
|
2783
2782
|
!this.config.host.startsWith('http://') &&
|
|
2784
2783
|
!this.config.host.startsWith('https://')) {
|
|
2785
|
-
|
|
2784
|
+
Helpers__NS__throwError(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
2786
2785
|
}
|
|
2787
|
-
if (
|
|
2786
|
+
if (___NS__isUndefined(this.config.useIpcWhenElectron)) {
|
|
2788
2787
|
this.config.useIpcWhenElectron = true;
|
|
2789
2788
|
}
|
|
2790
2789
|
// console.log(`config for ${this.contextName}`, this.config);
|
|
2791
2790
|
//#region resolve if skipping writing server routes
|
|
2792
2791
|
//@ts-expect-error overriding readonly
|
|
2793
|
-
this.skipWritingServerRoutes =
|
|
2792
|
+
this.skipWritingServerRoutes = ___NS__isBoolean(this.config.skipWritingServerRoutes)
|
|
2794
2793
|
? this.config.skipWritingServerRoutes
|
|
2795
2794
|
: false;
|
|
2796
2795
|
//#endregion
|
|
@@ -2805,10 +2804,10 @@ class EndpointContext {
|
|
|
2805
2804
|
}
|
|
2806
2805
|
// console.log(`
|
|
2807
2806
|
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
2808
|
-
//
|
|
2807
|
+
// UtilsOs__NS__isElectron: ${UtilsOs__NS__isElectron}
|
|
2809
2808
|
// `)
|
|
2810
|
-
if (this.config.useIpcWhenElectron &&
|
|
2811
|
-
if (
|
|
2809
|
+
if (this.config.useIpcWhenElectron && UtilsOs__NS__isElectron) {
|
|
2810
|
+
if (UtilsOs__NS__isWebSQL) {
|
|
2812
2811
|
this.mode = 'backend-frontend(websql-electron)';
|
|
2813
2812
|
}
|
|
2814
2813
|
else {
|
|
@@ -2823,7 +2822,7 @@ class EndpointContext {
|
|
|
2823
2822
|
if (!this.mode && !this.config.abstract) {
|
|
2824
2823
|
const errMsg = `You need to provide host property or ` +
|
|
2825
2824
|
`useIpcWhenElectron or mark it as abstract`;
|
|
2826
|
-
|
|
2825
|
+
Helpers__NS__error(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
2827
2826
|
/* */
|
|
2828
2827
|
/* */
|
|
2829
2828
|
}
|
|
@@ -2838,7 +2837,7 @@ class EndpointContext {
|
|
|
2838
2837
|
`);
|
|
2839
2838
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
2840
2839
|
}
|
|
2841
|
-
else if (
|
|
2840
|
+
else if (___NS__isObject(this.config.database)) {
|
|
2842
2841
|
this.logFramework &&
|
|
2843
2842
|
console.log(`
|
|
2844
2843
|
|
|
@@ -2847,13 +2846,13 @@ class EndpointContext {
|
|
|
2847
2846
|
`);
|
|
2848
2847
|
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
2849
2848
|
walk.Object(this.config.database, (value, lodashPath) => {
|
|
2850
|
-
if (
|
|
2849
|
+
if (___NS__isNil(value) || ___NS__isFunction(value) || ___NS__isObject(value)) {
|
|
2851
2850
|
// skipping
|
|
2852
2851
|
}
|
|
2853
2852
|
else {
|
|
2854
2853
|
this.logFramework &&
|
|
2855
2854
|
console.info(`Overriding database config: ${lodashPath}=${value}`);
|
|
2856
|
-
|
|
2855
|
+
___NS__set(this.databaseConfig, lodashPath, value);
|
|
2857
2856
|
}
|
|
2858
2857
|
}, {
|
|
2859
2858
|
walkGetters: false,
|
|
@@ -2862,7 +2861,7 @@ class EndpointContext {
|
|
|
2862
2861
|
//#endregion
|
|
2863
2862
|
//#region resolve session
|
|
2864
2863
|
if (this.config.session) {
|
|
2865
|
-
this.session =
|
|
2864
|
+
this.session = ___NS__cloneDeep(this.config.session);
|
|
2866
2865
|
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
2867
2866
|
if (!this.session.cookieMaxAge) {
|
|
2868
2867
|
this.session.cookieMaxAge = oneHour;
|
|
@@ -3017,7 +3016,7 @@ class EndpointContext {
|
|
|
3017
3016
|
/* */
|
|
3018
3017
|
/* */
|
|
3019
3018
|
this.logRealtime &&
|
|
3020
|
-
|
|
3019
|
+
Helpers__NS__info(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
3021
3020
|
this.realtime = new RealtimeCore(this);
|
|
3022
3021
|
}
|
|
3023
3022
|
//#endregion
|
|
@@ -3026,16 +3025,16 @@ class EndpointContext {
|
|
|
3026
3025
|
// console.log({ ref })
|
|
3027
3026
|
if (this.config.abstract) {
|
|
3028
3027
|
this.logFramework &&
|
|
3029
|
-
|
|
3028
|
+
Helpers__NS__info(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
3030
3029
|
}
|
|
3031
3030
|
else {
|
|
3032
3031
|
if (this.isRemoteHost) {
|
|
3033
3032
|
this.logFramework &&
|
|
3034
|
-
|
|
3033
|
+
Helpers__NS__info(`[taon] Create context for remote host: ${this.config.host}`);
|
|
3035
3034
|
}
|
|
3036
3035
|
else {
|
|
3037
3036
|
this.logFramework &&
|
|
3038
|
-
|
|
3037
|
+
Helpers__NS__info(`[taon] Create context for host: ${this.config.host}`);
|
|
3039
3038
|
}
|
|
3040
3039
|
}
|
|
3041
3040
|
//#endregion
|
|
@@ -3321,7 +3320,7 @@ class EndpointContext {
|
|
|
3321
3320
|
let entityName = '';
|
|
3322
3321
|
// entity thing is only for repositories local repositories
|
|
3323
3322
|
// if (className === 'TaonBaseRepository') {
|
|
3324
|
-
const entityFn =
|
|
3323
|
+
const entityFn = ___NS__first(locaInstanceConstructorArgs);
|
|
3325
3324
|
const entity = entityFn && entityFn();
|
|
3326
3325
|
entityName = (entity && ClassHelpers__NS__getName(entity)) || '';
|
|
3327
3326
|
// console.log(`entityName `, entityName);
|
|
@@ -3384,7 +3383,7 @@ class EndpointContext {
|
|
|
3384
3383
|
//#endregion
|
|
3385
3384
|
//#region methods & getters / check if context initialized
|
|
3386
3385
|
checkIfContextInitialized() {
|
|
3387
|
-
if (
|
|
3386
|
+
if (___NS__isUndefined(this.config)) {
|
|
3388
3387
|
throw new Error(`Please check if your context has been initialized.
|
|
3389
3388
|
|
|
3390
3389
|
// ...
|
|
@@ -3485,7 +3484,7 @@ class EndpointContext {
|
|
|
3485
3484
|
]) {
|
|
3486
3485
|
//#region init class static _ property
|
|
3487
3486
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
3488
|
-
if (
|
|
3487
|
+
if (___NS__isFunction(classFun._)) {
|
|
3489
3488
|
await classFun._();
|
|
3490
3489
|
}
|
|
3491
3490
|
}
|
|
@@ -3499,15 +3498,15 @@ class EndpointContext {
|
|
|
3499
3498
|
Models__NS__ClassType.MIGRATION,
|
|
3500
3499
|
]) {
|
|
3501
3500
|
//#region init providers, repositories _ property
|
|
3502
|
-
//
|
|
3501
|
+
// Helpers__NS__taskStarted(
|
|
3503
3502
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
3504
3503
|
// );
|
|
3505
3504
|
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
3506
|
-
if (
|
|
3505
|
+
if (___NS__isFunction(ctrl._)) {
|
|
3507
3506
|
await ctrl._();
|
|
3508
3507
|
}
|
|
3509
3508
|
}
|
|
3510
|
-
//
|
|
3509
|
+
// Helpers__NS__taskStarted(
|
|
3511
3510
|
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} DONE`,
|
|
3512
3511
|
// );
|
|
3513
3512
|
//#endregion
|
|
@@ -3876,7 +3875,7 @@ class EndpointContext {
|
|
|
3876
3875
|
//#region methods & getters / initialize metadata
|
|
3877
3876
|
//#region methods & getters / update class calculate path
|
|
3878
3877
|
updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
|
|
3879
|
-
const parentsCalculatedPath =
|
|
3878
|
+
const parentsCalculatedPath = ___NS__slice(rawConfigs, 1)
|
|
3880
3879
|
.reverse()
|
|
3881
3880
|
.map(bc => {
|
|
3882
3881
|
if (TaonHelpers__NS__isGoodPath(bc.path)) {
|
|
@@ -3896,7 +3895,7 @@ class EndpointContext {
|
|
|
3896
3895
|
.replace(/\/\//g, '/')
|
|
3897
3896
|
.split('/')
|
|
3898
3897
|
.reduce((acc, bc) => {
|
|
3899
|
-
return
|
|
3898
|
+
return ___NS__last(acc) === bc ? acc : [...acc, bc];
|
|
3900
3899
|
}, [])
|
|
3901
3900
|
.join('/');
|
|
3902
3901
|
}
|
|
@@ -3906,8 +3905,8 @@ class EndpointContext {
|
|
|
3906
3905
|
//#region methods & getters / dedupe class configs
|
|
3907
3906
|
mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
|
|
3908
3907
|
const currentControllerMethodsConfig = classConfig.methods;
|
|
3909
|
-
|
|
3910
|
-
const parentControllerMethods =
|
|
3908
|
+
___NS__slice(rawConfigs, 1).forEach(bc => {
|
|
3909
|
+
const parentControllerMethods = ___NS__cloneDeep(bc.methods);
|
|
3911
3910
|
for (const methodsName in parentControllerMethods) {
|
|
3912
3911
|
if (parentControllerMethods.hasOwnProperty(methodsName)) {
|
|
3913
3912
|
if (!currentControllerMethodsConfig[methodsName]) {
|
|
@@ -3928,7 +3927,7 @@ class EndpointContext {
|
|
|
3928
3927
|
const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
3929
3928
|
for (const controllerClassFn of allControllers) {
|
|
3930
3929
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
3931
|
-
if (
|
|
3930
|
+
if (___NS__isFunction(instance.afterAllCtxInited)) {
|
|
3932
3931
|
await instance.afterAllCtxInited({ ctxStorage });
|
|
3933
3932
|
}
|
|
3934
3933
|
}
|
|
@@ -3958,7 +3957,7 @@ class EndpointContext {
|
|
|
3958
3957
|
//#region combine middlewares from controllers
|
|
3959
3958
|
classConfig.calculatedMiddlewaresControllerObj = {};
|
|
3960
3959
|
[...rawConfigs].reverse().forEach(rc => {
|
|
3961
|
-
if (
|
|
3960
|
+
if (___NS__isFunction(rc.middlewares)) {
|
|
3962
3961
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
3963
3962
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
3964
3963
|
className(middlewareClass) {
|
|
@@ -3985,7 +3984,7 @@ class EndpointContext {
|
|
|
3985
3984
|
[...rawConfigs].reverse().forEach(rc => {
|
|
3986
3985
|
if (rc.methods[methodName]) {
|
|
3987
3986
|
const parentMethodConfig = rc.methods[methodName];
|
|
3988
|
-
if (
|
|
3987
|
+
if (___NS__isFunction(parentMethodConfig.middlewares)) {
|
|
3989
3988
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
3990
3989
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
3991
3990
|
className(middlewareClass) {
|
|
@@ -4016,7 +4015,7 @@ class EndpointContext {
|
|
|
4016
4015
|
//#endregion
|
|
4017
4016
|
//#region init server
|
|
4018
4017
|
// console.log({ expressPath });
|
|
4019
|
-
if (
|
|
4018
|
+
if (UtilsOs__NS__isNode || UtilsOs__NS__isWebSQL) {
|
|
4020
4019
|
/* */
|
|
4021
4020
|
/* */
|
|
4022
4021
|
/* */
|
|
@@ -4034,7 +4033,7 @@ class EndpointContext {
|
|
|
4034
4033
|
}
|
|
4035
4034
|
//#endregion
|
|
4036
4035
|
//#region init client
|
|
4037
|
-
const shouldInitClient =
|
|
4036
|
+
const shouldInitClient = UtilsOs__NS__isBrowser || this.isRemoteHost || UtilsOs__NS__isWebSQL;
|
|
4038
4037
|
// console.log('shouldInitClient', shouldInitClient);
|
|
4039
4038
|
if (shouldInitClient) {
|
|
4040
4039
|
// console.log(
|
|
@@ -4115,7 +4114,7 @@ class EndpointContext {
|
|
|
4115
4114
|
async initCustomClientMiddlewares() {
|
|
4116
4115
|
const middlewares = this.getClassesInstancesArrBy(Models__NS__ClassType.MIDDLEWARE)
|
|
4117
4116
|
.map(f => f)
|
|
4118
|
-
.filter(f =>
|
|
4117
|
+
.filter(f => ___NS__isFunction(f.interceptClient));
|
|
4119
4118
|
middlewares.forEach(middlewareInstanceName => {
|
|
4120
4119
|
const contextName = this.contextName;
|
|
4121
4120
|
const interceptorName = `${contextName}-${ClassHelpers__NS__getName(middlewareInstanceName)}`;
|
|
@@ -4289,7 +4288,7 @@ class EndpointContext {
|
|
|
4289
4288
|
.map(middlewareClassFun => {
|
|
4290
4289
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
4291
4290
|
if (middlewareInstance &&
|
|
4292
|
-
|
|
4291
|
+
___NS__isFunction(middlewareInstance.interceptServerMethod)) {
|
|
4293
4292
|
const middlewareFn = ClassHelpers__NS__asyncHandler(async (req, res, next) => {
|
|
4294
4293
|
await middlewareInstance.interceptServerMethod({
|
|
4295
4294
|
req,
|
|
@@ -4323,7 +4322,7 @@ class EndpointContext {
|
|
|
4323
4322
|
//#endregion
|
|
4324
4323
|
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
4325
4324
|
//#endregion
|
|
4326
|
-
if (
|
|
4325
|
+
if (UtilsOs__NS__isElectron) {
|
|
4327
4326
|
/* */
|
|
4328
4327
|
/* */
|
|
4329
4328
|
/* */
|
|
@@ -4629,7 +4628,7 @@ class EndpointContext {
|
|
|
4629
4628
|
const middlewares = methodConfig.calculatedMiddlewares;
|
|
4630
4629
|
const middlewaresInstances = middlewares
|
|
4631
4630
|
.map(f => this.getInstanceBy(f))
|
|
4632
|
-
.filter(f =>
|
|
4631
|
+
.filter(f => ___NS__isFunction(f.interceptClientMethod));
|
|
4633
4632
|
middlewaresInstances.forEach(instance => {
|
|
4634
4633
|
const middlewareName = ClassHelpers__NS__getName(instance);
|
|
4635
4634
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
@@ -4658,7 +4657,7 @@ class EndpointContext {
|
|
|
4658
4657
|
//#endregion
|
|
4659
4658
|
const orgMethods = target.prototype[methodConfig.methodName];
|
|
4660
4659
|
//#region handle electron ipc request
|
|
4661
|
-
if (
|
|
4660
|
+
if (UtilsOs__NS__isElectron) {
|
|
4662
4661
|
const ipcRenderer = window.require('electron').ipcRenderer;
|
|
4663
4662
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
4664
4663
|
const received = new Promise(async (resolve, reject) => {
|
|
@@ -4676,7 +4675,7 @@ class EndpointContext {
|
|
|
4676
4675
|
method: methodConfig.type,
|
|
4677
4676
|
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4678
4677
|
}${methodConfig.path} `,
|
|
4679
|
-
},
|
|
4678
|
+
}, Helpers__NS__isBlob(body) || ___NS__isString(body)
|
|
4680
4679
|
? body
|
|
4681
4680
|
: JSON.stringify(body), RestHeaders.from(headers), void 0, () => body);
|
|
4682
4681
|
resolve(res);
|
|
@@ -4928,7 +4927,7 @@ class EndpointContext {
|
|
|
4928
4927
|
if (mapping) {
|
|
4929
4928
|
rest.headers.set(Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4930
4929
|
}
|
|
4931
|
-
queryParams =
|
|
4930
|
+
queryParams = ___NS__cloneDeep(param);
|
|
4932
4931
|
}
|
|
4933
4932
|
}
|
|
4934
4933
|
if (currentParam.paramType === 'Header') {
|
|
@@ -5192,7 +5191,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5192
5191
|
setTimeout(async () => {
|
|
5193
5192
|
if (UtilsOs__NS__isRunningInDocker()) {
|
|
5194
5193
|
const activeContext = config?.activeContext || null;
|
|
5195
|
-
if (
|
|
5194
|
+
if (___NS__isString(activeContext) &&
|
|
5196
5195
|
activeContext !== '' &&
|
|
5197
5196
|
activeContext !== config?.contextName) {
|
|
5198
5197
|
console.warn(`[taon] Context ${endpointContextRef.contextName} is not active context, skipping initialization.`);
|
|
@@ -5228,11 +5227,11 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5228
5227
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
5229
5228
|
if (keepWebsqlDbDataAfterReload) {
|
|
5230
5229
|
!UtilsOs__NS__isRunningInCliMode() &&
|
|
5231
|
-
|
|
5230
|
+
Helpers__NS__info(`[taon] Keeping websql data after reload ` +
|
|
5232
5231
|
`(context=${endpointContextRef.contextName}).`);
|
|
5233
5232
|
}
|
|
5234
5233
|
else {
|
|
5235
|
-
|
|
5234
|
+
Helpers__NS__info(`[taon] Dropping all tables and data ` +
|
|
5236
5235
|
`(context=${endpointContextRef.contextName}).`);
|
|
5237
5236
|
}
|
|
5238
5237
|
//#endregion
|
|
@@ -5253,17 +5252,17 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5253
5252
|
//#region run migrations tasks
|
|
5254
5253
|
if (endpointContextRef.onlyMigrationRun) {
|
|
5255
5254
|
endpointContextRef.logMigrations &&
|
|
5256
|
-
|
|
5255
|
+
Helpers__NS__log(`[taon] Running only migrations (context=${endpointContextRef.contextName}).`);
|
|
5257
5256
|
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5258
5257
|
}
|
|
5259
5258
|
else if (endpointContextRef.onlyMigrationRevertToTimestamp) {
|
|
5260
5259
|
endpointContextRef.logMigrations &&
|
|
5261
|
-
|
|
5260
|
+
Helpers__NS__log(`[taon] Reverting migrations to timestamp ${endpointContextRef.onlyMigrationRevertToTimestamp} (context=${endpointContextRef.contextName}).`);
|
|
5262
5261
|
await endpointContextRef.dbMigrations.revertMigrationToTimestamp(endpointContextRef.onlyMigrationRevertToTimestamp);
|
|
5263
5262
|
}
|
|
5264
5263
|
else {
|
|
5265
5264
|
endpointContextRef.logMigrations &&
|
|
5266
|
-
|
|
5265
|
+
Helpers__NS__log(`[taon] Running all not applied migrations (context=${endpointContextRef.contextName}).`);
|
|
5267
5266
|
await endpointContextRef.dbMigrations.runAllNotCompletedMigrations();
|
|
5268
5267
|
}
|
|
5269
5268
|
//#endregion
|
|
@@ -5406,11 +5405,11 @@ const getTransformFunction = (target) => {
|
|
|
5406
5405
|
// console.log(`CONFIGS TO CHECK`, configs)
|
|
5407
5406
|
const functions = configs
|
|
5408
5407
|
.map(c => {
|
|
5409
|
-
if (
|
|
5408
|
+
if (___NS__isFunction(c.browserTransformFn)) {
|
|
5410
5409
|
return c.browserTransformFn;
|
|
5411
5410
|
}
|
|
5412
5411
|
})
|
|
5413
|
-
.filter(f =>
|
|
5412
|
+
.filter(f => ___NS__isFunction(f));
|
|
5414
5413
|
return functions.length === 0
|
|
5415
5414
|
? void 0
|
|
5416
5415
|
: function (entity) {
|
|
@@ -5431,7 +5430,7 @@ const singleTransform = (json) => {
|
|
|
5431
5430
|
let pbrowserTransformFn = getTransformFunction(ptarget);
|
|
5432
5431
|
if (pbrowserTransformFn) {
|
|
5433
5432
|
const newValue = pbrowserTransformFn(json);
|
|
5434
|
-
if (!
|
|
5433
|
+
if (!___NS__isObject(newValue)) {
|
|
5435
5434
|
console.error(`Please return object in transform function for class: ` +
|
|
5436
5435
|
`${ClassHelpers__NS__getName(json)}`);
|
|
5437
5436
|
}
|
|
@@ -5467,7 +5466,7 @@ class EntityProcess {
|
|
|
5467
5466
|
//#endregion
|
|
5468
5467
|
//#region check advanced manipulation
|
|
5469
5468
|
checkAdvancedManiupulation() {
|
|
5470
|
-
if (
|
|
5469
|
+
if (___NS__isFunction(this.result)) {
|
|
5471
5470
|
this.advancedManipulation = true;
|
|
5472
5471
|
this.result = this.result();
|
|
5473
5472
|
}
|
|
@@ -5477,7 +5476,7 @@ class EntityProcess {
|
|
|
5477
5476
|
async run() {
|
|
5478
5477
|
this.checkAdvancedManiupulation();
|
|
5479
5478
|
this.data = this.result;
|
|
5480
|
-
if (
|
|
5479
|
+
if (___NS__isObject(this.result)) {
|
|
5481
5480
|
if (this.advancedManipulation) {
|
|
5482
5481
|
this.applayTransformFn();
|
|
5483
5482
|
}
|
|
@@ -5488,14 +5487,14 @@ class EntityProcess {
|
|
|
5488
5487
|
//#endregion
|
|
5489
5488
|
//#region apply transform function
|
|
5490
5489
|
applayTransformFn() {
|
|
5491
|
-
if (
|
|
5490
|
+
if (___NS__isObject(this.data) && !___NS__isArray(this.data)) {
|
|
5492
5491
|
this.data = singleTransform(this.data);
|
|
5493
5492
|
}
|
|
5494
5493
|
const { include } = { include: [] };
|
|
5495
5494
|
walk.Object(this.data, (value, lodashPath, changeValue, { skipObject, isCircural }) => {
|
|
5496
5495
|
// console.log(`${isCircural ? 'CIR' : 'NOT'} : ${lodashPath}`)
|
|
5497
5496
|
if (!isCircural) {
|
|
5498
|
-
if (!
|
|
5497
|
+
if (!___NS__isArray(value) && ___NS__isObject(value)) {
|
|
5499
5498
|
changeValue(singleTransform(value));
|
|
5500
5499
|
}
|
|
5501
5500
|
}
|
|
@@ -5512,7 +5511,7 @@ class EntityProcess {
|
|
|
5512
5511
|
setHeaders() {
|
|
5513
5512
|
const { include } = { include: [] };
|
|
5514
5513
|
const className = ClassHelpers__NS__getName(this.data);
|
|
5515
|
-
const doNothing =
|
|
5514
|
+
const doNothing = ___NS__isNil(this.data) ||
|
|
5516
5515
|
[
|
|
5517
5516
|
'Object',
|
|
5518
5517
|
'',
|
|
@@ -5536,32 +5535,32 @@ class EntityProcess {
|
|
|
5536
5535
|
send() {
|
|
5537
5536
|
if (this.advancedManipulation) {
|
|
5538
5537
|
const browserKey = config.folder.browser;
|
|
5539
|
-
let toSend =
|
|
5538
|
+
let toSend = ___NS__isArray(this.data) ? [] : {};
|
|
5540
5539
|
const { include = [], exclude = [] } = { include: [], exclude: [] };
|
|
5541
5540
|
walk.Object(this.data, (value, lodashPath, changeVAlue, { isCircural, skipObject }) => {
|
|
5542
5541
|
// console.log(`${isCircural ? 'CIR' : 'NOT'} ${lodashPath}`)
|
|
5543
5542
|
if (isCircural) {
|
|
5544
|
-
|
|
5543
|
+
___NS__set(toSend, lodashPath, null);
|
|
5545
5544
|
}
|
|
5546
5545
|
else {
|
|
5547
5546
|
const fun = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(value));
|
|
5548
|
-
if (
|
|
5549
|
-
|
|
5547
|
+
if (___NS__isFunction(fun)) {
|
|
5548
|
+
___NS__set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
|
|
5550
5549
|
const indexProp = ClassHelpers__NS__getUniqueKey(value);
|
|
5551
|
-
|
|
5550
|
+
___NS__set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
|
|
5552
5551
|
// skipObject()
|
|
5553
5552
|
}
|
|
5554
5553
|
else {
|
|
5555
|
-
|
|
5554
|
+
___NS__set(toSend, lodashPath, value);
|
|
5556
5555
|
}
|
|
5557
5556
|
}
|
|
5558
5557
|
}, { checkCircural: true, breadthWalk: true, include });
|
|
5559
|
-
if (!
|
|
5558
|
+
if (!___NS__isArray(this.data)) {
|
|
5560
5559
|
let funParent = getTransformFunction(ClassHelpers__NS__getClassFnFromObject(this.data));
|
|
5561
5560
|
// if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
|
|
5562
5561
|
// console.log(`funParent !!! have fun? ${!!funParent} `)
|
|
5563
5562
|
// }
|
|
5564
|
-
if (
|
|
5563
|
+
if (___NS__isFunction(funParent)) {
|
|
5565
5564
|
toSend = {
|
|
5566
5565
|
[browserKey]: toSend[browserKey],
|
|
5567
5566
|
};
|
|
@@ -5572,21 +5571,21 @@ class EntityProcess {
|
|
|
5572
5571
|
if (!((include.length > 0 && !include.includes(prop)) ||
|
|
5573
5572
|
(exclude.length > 0 && exclude.includes(prop)))) {
|
|
5574
5573
|
if (ClassHelpers__NS__isContextClassObject(v) &&
|
|
5575
|
-
|
|
5574
|
+
___NS__isFunction(getTransformFunction(ClassHelpers__NS__getClassFnFromObject(v)))) {
|
|
5576
5575
|
toSend[prop] = {
|
|
5577
5576
|
[browserKey]: v[browserKey],
|
|
5578
5577
|
};
|
|
5579
5578
|
const indexProp = ClassHelpers__NS__getUniqueKey(v);
|
|
5580
5579
|
toSend[prop][indexProp] = this.data[prop][indexProp];
|
|
5581
5580
|
for (const key in v) {
|
|
5582
|
-
if (
|
|
5581
|
+
if (___NS__isObject(v) &&
|
|
5583
5582
|
v.hasOwnProperty(key) &&
|
|
5584
5583
|
![indexProp, config.folder.browser].includes(key) &&
|
|
5585
|
-
(
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5584
|
+
(___NS__isString(v[key]) ||
|
|
5585
|
+
___NS__isNumber(v[key]) ||
|
|
5586
|
+
___NS__isDate(v[key]) ||
|
|
5587
|
+
___NS__isNull(v[key]) ||
|
|
5588
|
+
___NS__isBoolean(v[key]))) {
|
|
5590
5589
|
toSend[prop][key] = v[key];
|
|
5591
5590
|
}
|
|
5592
5591
|
}
|
|
@@ -5608,13 +5607,13 @@ class EntityProcess {
|
|
|
5608
5607
|
}
|
|
5609
5608
|
|
|
5610
5609
|
const cloneObj = (override, classFn) => {
|
|
5611
|
-
const result =
|
|
5610
|
+
const result = ___NS__merge(new classFn(), ___NS__cloneDeep(this));
|
|
5612
5611
|
walk.Object(override || {}, (value, lodashPath) => {
|
|
5613
|
-
if (
|
|
5612
|
+
if (___NS__isNil(value) || ___NS__isFunction(value) || ___NS__isObject(value)) {
|
|
5614
5613
|
// skipping
|
|
5615
5614
|
}
|
|
5616
5615
|
else {
|
|
5617
|
-
|
|
5616
|
+
___NS__set(result, lodashPath, value);
|
|
5618
5617
|
}
|
|
5619
5618
|
}, {
|
|
5620
5619
|
walkGetters: false,
|
|
@@ -5641,14 +5640,14 @@ class TaonBaseClass {
|
|
|
5641
5640
|
* @returns cloned instance of the class
|
|
5642
5641
|
*/
|
|
5643
5642
|
clone(overrideObjOrFn) {
|
|
5644
|
-
if (
|
|
5643
|
+
if (___NS__isString(overrideObjOrFn)) {
|
|
5645
5644
|
console.log(overrideObjOrFn);
|
|
5646
5645
|
throw new Error('String is not supported as .clone() method argument');
|
|
5647
5646
|
}
|
|
5648
5647
|
const classFn = ClassHelpers__NS__getClassFnFromObject(this);
|
|
5649
|
-
if (
|
|
5648
|
+
if (___NS__isFunction(overrideObjOrFn)) {
|
|
5650
5649
|
// console.log('clone with fn');
|
|
5651
|
-
const oldValues = (
|
|
5650
|
+
const oldValues = (___NS__cloneDeep(this) || {});
|
|
5652
5651
|
return cloneObj(overrideObjOrFn(oldValues), classFn);
|
|
5653
5652
|
}
|
|
5654
5653
|
// console.log('clone normal');
|
|
@@ -5765,7 +5764,7 @@ function TaonEntity(options) {
|
|
|
5765
5764
|
options = options || {};
|
|
5766
5765
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5767
5766
|
ClassHelpers__NS__setName(constructor, options?.className);
|
|
5768
|
-
Mapping__NS__DefaultModelWithMapping(options?.defaultModelValues || {},
|
|
5767
|
+
Mapping__NS__DefaultModelWithMapping(options?.defaultModelValues || {}, ___NS__merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
5769
5768
|
// TODO when entit metadata generator read use this
|
|
5770
5769
|
Mapping__NS__DefaultModelWithMapping(void 0, {})(constructor);
|
|
5771
5770
|
Reflect.defineMetadata(Symbols__NS__metadata.options.entity, options, constructor);
|
|
@@ -5827,7 +5826,7 @@ const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, p
|
|
|
5827
5826
|
if (methodConfig.parameters.hasOwnProperty(key)) {
|
|
5828
5827
|
const element = methodConfig.parameters[key];
|
|
5829
5828
|
if (element.paramType === 'Path' &&
|
|
5830
|
-
|
|
5829
|
+
___NS__isString(element.paramName) &&
|
|
5831
5830
|
element.paramName.trim().length > 0) {
|
|
5832
5831
|
paramsPathConcatedPath += `/${element.paramName}/:${element.paramName}`;
|
|
5833
5832
|
}
|
|
@@ -6383,8 +6382,8 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6383
6382
|
//#endregion
|
|
6384
6383
|
//#region init
|
|
6385
6384
|
async _() {
|
|
6386
|
-
if (!
|
|
6387
|
-
|
|
6385
|
+
if (!___NS__isFunction(this.entityClassResolveFn)) {
|
|
6386
|
+
Helpers__NS__warn(`Skipping initing CRUD controller ${ClassHelpers__NS__getName(this)} because entityClassResolveFn is not provided.`);
|
|
6388
6387
|
return;
|
|
6389
6388
|
}
|
|
6390
6389
|
let entityClassFn = this.entityClassResolveFn();
|
|
@@ -6392,11 +6391,11 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6392
6391
|
if (entityClassFn) {
|
|
6393
6392
|
const configEntity = Reflect.getMetadata(Symbols__NS__metadata.options.entity, ClassHelpers__NS__getClassFnFromObject(this));
|
|
6394
6393
|
if (configEntity?.createTable === false) {
|
|
6395
|
-
|
|
6394
|
+
Helpers__NS__warn(`Table for entity ${ClassHelpers__NS__getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
6396
6395
|
}
|
|
6397
6396
|
}
|
|
6398
6397
|
else {
|
|
6399
|
-
|
|
6398
|
+
Helpers__NS__error(`Entity class not provided for controller ${ClassHelpers__NS__getName(this)}.
|
|
6400
6399
|
|
|
6401
6400
|
Please provide entity as class property entityClassFn:
|
|
6402
6401
|
|
|
@@ -7674,7 +7673,7 @@ class TaonBaseMigration extends TaonBaseInjector {
|
|
|
7674
7673
|
return true;
|
|
7675
7674
|
}
|
|
7676
7675
|
getDescription() {
|
|
7677
|
-
return
|
|
7676
|
+
return ___NS__startCase(ClassHelpers__NS__getName(this));
|
|
7678
7677
|
}
|
|
7679
7678
|
async up(queryRunner) {
|
|
7680
7679
|
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers__NS__getName(this)}"`);
|
|
@@ -7829,15 +7828,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
7829
7828
|
}], ctorParameters: () => [{ type: i1.FormlyFormBuilder }] });
|
|
7830
7829
|
|
|
7831
7830
|
function findTypeForEntity(entity, isArray = false) {
|
|
7832
|
-
if (!
|
|
7831
|
+
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
7833
7832
|
RegisterComponentType.prototype.types = [];
|
|
7834
7833
|
}
|
|
7835
7834
|
return getRegisteredComponents().find(c => c.entity === entity && c.isArray === isArray);
|
|
7836
7835
|
}
|
|
7837
7836
|
function typeFromEntity(component, entity) {
|
|
7838
|
-
const isArray =
|
|
7837
|
+
const isArray = ___NS__isArray(entity);
|
|
7839
7838
|
if (isArray) {
|
|
7840
|
-
entity =
|
|
7839
|
+
entity = ___NS__first(entity);
|
|
7841
7840
|
}
|
|
7842
7841
|
let name = ClassHelpers__NS__getName(component);
|
|
7843
7842
|
let res = { name, component, entity, isArray };
|
|
@@ -7849,7 +7848,7 @@ function typeFromName(component, name) {
|
|
|
7849
7848
|
return res;
|
|
7850
7849
|
}
|
|
7851
7850
|
function RegisterComponentTypeForEntity(entity) {
|
|
7852
|
-
if (!
|
|
7851
|
+
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
7853
7852
|
RegisterComponentType.prototype.types = [];
|
|
7854
7853
|
}
|
|
7855
7854
|
return function (target, propertyKey, descriptor) {
|
|
@@ -7857,7 +7856,7 @@ function RegisterComponentTypeForEntity(entity) {
|
|
|
7857
7856
|
};
|
|
7858
7857
|
}
|
|
7859
7858
|
function RegisterComponentType(className, ...optionslNames) {
|
|
7860
|
-
if (!
|
|
7859
|
+
if (!___NS__isArray(RegisterComponentType.prototype.types)) {
|
|
7861
7860
|
RegisterComponentType.prototype.types = [];
|
|
7862
7861
|
}
|
|
7863
7862
|
return function (target, propertyKey, descriptor) {
|
|
@@ -7886,8 +7885,8 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7886
7885
|
const mapping = Mapping__NS__getModelsMapping(target);
|
|
7887
7886
|
// console.log('mapping', mapping)
|
|
7888
7887
|
const fieldNames = CLASS.describeProperites(target);
|
|
7889
|
-
const checkExclude =
|
|
7890
|
-
const checkInclude =
|
|
7888
|
+
const checkExclude = ___NS__isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
7889
|
+
const checkInclude = ___NS__isArray(keysPathesToInclude) && keysPathesToInclude.length > 0;
|
|
7891
7890
|
if (checkExclude && checkInclude) {
|
|
7892
7891
|
throw new Error(`In Taon function getFromlyConfigFor(...) please use keysPathesToInclude or keysPathesToExclude, `);
|
|
7893
7892
|
}
|
|
@@ -7920,7 +7919,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7920
7919
|
fieldArray: {
|
|
7921
7920
|
fieldGroupClassName: 'row',
|
|
7922
7921
|
templateOptions: {
|
|
7923
|
-
label: `Add new ${
|
|
7922
|
+
label: `Add new ${___NS__startCase(key)}`,
|
|
7924
7923
|
},
|
|
7925
7924
|
fieldGroup,
|
|
7926
7925
|
},
|
|
@@ -7941,7 +7940,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7941
7940
|
res = {
|
|
7942
7941
|
fieldGroupClassName: 'row',
|
|
7943
7942
|
templateOptions: {
|
|
7944
|
-
label: `${
|
|
7943
|
+
label: `${___NS__startCase(key)}`,
|
|
7945
7944
|
},
|
|
7946
7945
|
wrappers: ['groupwrap'],
|
|
7947
7946
|
fieldGroup,
|
|
@@ -7953,16 +7952,16 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7953
7952
|
key,
|
|
7954
7953
|
model,
|
|
7955
7954
|
type,
|
|
7956
|
-
defaultValue: !
|
|
7955
|
+
defaultValue: !___NS__isUndefined(target.prototype[key])
|
|
7957
7956
|
? target.prototype[key]
|
|
7958
7957
|
: undefined,
|
|
7959
7958
|
templateOptions: {
|
|
7960
|
-
label:
|
|
7959
|
+
label: ___NS__isString(model)
|
|
7961
7960
|
? `${model
|
|
7962
7961
|
.split('.')
|
|
7963
|
-
.map(l =>
|
|
7964
|
-
.join(' / ')} / ${
|
|
7965
|
-
:
|
|
7962
|
+
.map(l => ___NS__startCase(l))
|
|
7963
|
+
.join(' / ')} / ${___NS__startCase(key)}`
|
|
7964
|
+
: ___NS__startCase(key),
|
|
7966
7965
|
options: selectOptions,
|
|
7967
7966
|
},
|
|
7968
7967
|
};
|
|
@@ -8004,30 +8003,30 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
8004
8003
|
function resolveSimpleTypes() {
|
|
8005
8004
|
for (const key in target.prototype) {
|
|
8006
8005
|
if (target.prototype.hasOwnProperty(key) &&
|
|
8007
|
-
!
|
|
8006
|
+
!___NS__isFunction(target.prototype[key])) {
|
|
8008
8007
|
if (!isAlowedPath(key)) {
|
|
8009
8008
|
continue;
|
|
8010
8009
|
}
|
|
8011
|
-
if (!
|
|
8010
|
+
if (!___NS__isUndefined(mapping[key])) {
|
|
8012
8011
|
continue;
|
|
8013
8012
|
}
|
|
8014
8013
|
const element = target.prototype[key];
|
|
8015
8014
|
let type = 'input';
|
|
8016
|
-
if (
|
|
8015
|
+
if (___NS__isBoolean(element)) {
|
|
8017
8016
|
type = 'switch';
|
|
8018
8017
|
}
|
|
8019
|
-
else if (
|
|
8018
|
+
else if (___NS__isDate(element)) {
|
|
8020
8019
|
type = 'datepicker';
|
|
8021
8020
|
}
|
|
8022
|
-
else if (
|
|
8021
|
+
else if (___NS__isFunction(target['getOptionsFor'])) {
|
|
8023
8022
|
var selectOptions = target['getOptionsFor'](key);
|
|
8024
|
-
if (!
|
|
8023
|
+
if (!___NS__isUndefined(selectOptions)) {
|
|
8025
8024
|
type = 'select';
|
|
8026
8025
|
}
|
|
8027
8026
|
}
|
|
8028
|
-
else if (
|
|
8027
|
+
else if (___NS__isFunction(target.prototype?.getOptionsFor)) {
|
|
8029
8028
|
var selectOptions = target.prototype?.getOptionsFor(key);
|
|
8030
|
-
if (!
|
|
8029
|
+
if (!___NS__isUndefined(selectOptions)) {
|
|
8031
8030
|
type = 'select';
|
|
8032
8031
|
}
|
|
8033
8032
|
}
|
|
@@ -8042,10 +8041,10 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
8042
8041
|
fieldNames
|
|
8043
8042
|
.filter(key => !simpleResolved.includes(key))
|
|
8044
8043
|
.forEach(key => {
|
|
8045
|
-
if (isAlowedPath(key) && !
|
|
8044
|
+
if (isAlowedPath(key) && !___NS__isUndefined(mapping[key])) {
|
|
8046
8045
|
let className = mapping[key];
|
|
8047
|
-
const isArray =
|
|
8048
|
-
className = isArray ?
|
|
8046
|
+
const isArray = ___NS__isArray(className);
|
|
8047
|
+
className = isArray ? ___NS__first(className) : className;
|
|
8049
8048
|
if (className === 'Date') {
|
|
8050
8049
|
fields.push(inputToPush(key, 'datepicker', parentModel));
|
|
8051
8050
|
}
|
|
@@ -8086,7 +8085,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
8086
8085
|
const StringColumn = (defaultValue = null, length = 100) => Column({
|
|
8087
8086
|
type: 'varchar',
|
|
8088
8087
|
length,
|
|
8089
|
-
nullable:
|
|
8088
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8090
8089
|
default: defaultValue,
|
|
8091
8090
|
});
|
|
8092
8091
|
/**
|
|
@@ -8095,7 +8094,7 @@ const StringColumn = (defaultValue = null, length = 100) => Column({
|
|
|
8095
8094
|
const String100Column = (defaultValue = null) => Column({
|
|
8096
8095
|
type: 'varchar',
|
|
8097
8096
|
length: 100,
|
|
8098
|
-
nullable:
|
|
8097
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8099
8098
|
default: defaultValue,
|
|
8100
8099
|
});
|
|
8101
8100
|
/**
|
|
@@ -8104,7 +8103,7 @@ const String100Column = (defaultValue = null) => Column({
|
|
|
8104
8103
|
const String20Column = (defaultValue = null) => Column({
|
|
8105
8104
|
type: 'varchar',
|
|
8106
8105
|
length: 20,
|
|
8107
|
-
nullable:
|
|
8106
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8108
8107
|
default: defaultValue,
|
|
8109
8108
|
});
|
|
8110
8109
|
/**
|
|
@@ -8113,7 +8112,7 @@ const String20Column = (defaultValue = null) => Column({
|
|
|
8113
8112
|
const String45Column = (defaultValue = null) => Column({
|
|
8114
8113
|
type: 'varchar',
|
|
8115
8114
|
length: 45,
|
|
8116
|
-
nullable:
|
|
8115
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8117
8116
|
default: defaultValue,
|
|
8118
8117
|
});
|
|
8119
8118
|
/**
|
|
@@ -8122,7 +8121,7 @@ const String45Column = (defaultValue = null) => Column({
|
|
|
8122
8121
|
const String500Column = (defaultValue = null) => Column({
|
|
8123
8122
|
type: 'varchar',
|
|
8124
8123
|
length: 500,
|
|
8125
|
-
nullable:
|
|
8124
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8126
8125
|
default: defaultValue,
|
|
8127
8126
|
});
|
|
8128
8127
|
/**
|
|
@@ -8131,7 +8130,7 @@ const String500Column = (defaultValue = null) => Column({
|
|
|
8131
8130
|
const String200Column = (defaultValue = null) => Column({
|
|
8132
8131
|
type: 'varchar',
|
|
8133
8132
|
length: 200,
|
|
8134
|
-
nullable:
|
|
8133
|
+
nullable: ___NS__isNil(defaultValue),
|
|
8135
8134
|
default: defaultValue,
|
|
8136
8135
|
});
|
|
8137
8136
|
const NumberColumn = () => Column({ type: 'int', nullable: true });
|
|
@@ -8196,10 +8195,10 @@ const Taon__NS__getResponseValue = getResponseValue;
|
|
|
8196
8195
|
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8197
8196
|
//#endregion
|
|
8198
8197
|
//#region aliases to helpers
|
|
8199
|
-
const Taon__NS__isBrowser =
|
|
8200
|
-
const Taon__NS__isNode =
|
|
8201
|
-
const Taon__NS__isWebSQL =
|
|
8202
|
-
const Taon__NS__isElectron =
|
|
8198
|
+
const Taon__NS__isBrowser = UtilsOs__NS__isBrowser;
|
|
8199
|
+
const Taon__NS__isNode = UtilsOs__NS__isNode;
|
|
8200
|
+
const Taon__NS__isWebSQL = UtilsOs__NS__isWebSQL;
|
|
8201
|
+
const Taon__NS__isElectron = UtilsOs__NS__isElectron;
|
|
8203
8202
|
//#endregion
|
|
8204
8203
|
const Taon__NS__createContext = createContext;
|
|
8205
8204
|
const Taon__NS__createContextTemplate = createContextTemplate;
|