taon 21.0.29 → 21.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/fesm2022/taon-browser.mjs +2 -14
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +76 -78
- package/browser-prod/fesm2022/taon-browser.mjs +770 -788
- package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
- package/browser-prod/package.json +23 -0
- package/browser-prod/types/taon-browser.d.ts +495 -513
- package/browser-prod.split-namespaces.json +186 -0
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-controller.d.ts +2 -1
- package/lib/base-classes/base-controller.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/decorators/http/http-decorators.d.ts +2 -1
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib/decorators/http/http-params-decorators.js.map +1 -1
- package/lib/endpoint-context.d.ts +2 -1
- package/lib/endpoint-context.js.map +1 -1
- package/lib/index.d.ts +3 -5
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/lib/models.d.ts +2 -3
- package/lib/models.js +0 -7
- package/lib/models.js.map +1 -1
- package/lib/package.json +4 -0
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-class.js +1 -1
- package/lib-prod/base-classes/base-class.js.map +1 -1
- package/lib-prod/base-classes/base-context.d.ts +1 -1
- package/lib-prod/base-classes/base-controller.d.ts +5 -4
- package/lib-prod/base-classes/base-controller.js +2 -2
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.d.ts +13 -13
- package/lib-prod/base-classes/base-crud-controller.js +8 -9
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-injector.js +11 -11
- package/lib-prod/base-classes/base-injector.js.map +1 -1
- package/lib-prod/base-classes/base-middleware.d.ts +2 -2
- package/lib-prod/base-classes/base-migration.js +3 -3
- package/lib-prod/base-classes/base-migration.js.map +1 -1
- package/lib-prod/base-classes/base-repository.js +4 -4
- package/lib-prod/base-classes/base-repository.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/config/method-config.d.ts +2 -2
- package/lib-prod/config/param-config.d.ts +2 -2
- package/lib-prod/context-db-migrations.js +12 -12
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.d.ts +5 -5
- package/lib-prod/create-context.js +3 -3
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/controller-decorator.js +3 -3
- package/lib-prod/decorators/classes/controller-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.d.ts +3 -3
- package/lib-prod/decorators/classes/entity-decorator.js +5 -5
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/middleware-decorator.js +3 -3
- package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/migration-decorator.js +3 -3
- package/lib-prod/decorators/classes/migration-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/provider-decorator.js +3 -3
- package/lib-prod/decorators/classes/provider-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/repository-decorator.js +3 -3
- package/lib-prod/decorators/classes/repository-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/subscriber-decorator.js +3 -3
- package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib-prod/decorators/http/http-decorators.d.ts +3 -2
- package/lib-prod/decorators/http/http-decorators.js +2 -2
- package/lib-prod/decorators/http/http-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.d.ts +5 -5
- package/lib-prod/decorators/http/http-methods-decorators.js +2 -2
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-params-decorators.js +1 -1
- package/lib-prod/decorators/http/http-params-decorators.js.map +1 -1
- package/lib-prod/endpoint-context-storage.js +1 -1
- package/lib-prod/endpoint-context-storage.js.map +1 -1
- package/lib-prod/endpoint-context.d.ts +14 -13
- package/lib-prod/endpoint-context.js +171 -171
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.js +14 -14
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/formly/fromly.d.ts +2 -2
- package/lib-prod/formly/fromly.js +1 -1
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/formly/type-from-entity.js +2 -2
- package/lib-prod/formly/type-from-entity.js.map +1 -1
- package/lib-prod/get-response-value.d.ts +2 -2
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.d.ts +3 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +1 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.d.ts +1 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +12 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +2 -2
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +1 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +1 -3
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +6 -8
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +1 -1
- package/lib-prod/helpers/class-helpers.d.ts +20 -22
- package/lib-prod/helpers/class-helpers.js +231 -218
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/helpers/taon-helpers.d.ts +14 -16
- package/lib-prod/helpers/taon-helpers.js +148 -138
- package/lib-prod/helpers/taon-helpers.js.map +1 -1
- package/lib-prod/index.d.ts +80 -84
- package/lib-prod/index.js +71 -70
- package/lib-prod/index.js.map +1 -1
- package/lib-prod/inject.js +3 -3
- package/lib-prod/inject.js.map +1 -1
- package/lib-prod/models.d.ts +242 -247
- package/lib-prod/models.js +83 -91
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/package.json +4 -0
- package/lib-prod/realtime/realtime-client.d.ts +2 -2
- package/lib-prod/realtime/realtime-client.js +9 -9
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js +17 -17
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +3 -3
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +2 -2
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +2 -2
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.d.ts +2 -2
- package/lib-prod/realtime/realtime-subs-manager.js +6 -6
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/realtime/realtime.models.d.ts +23 -25
- package/lib-prod/realtime/realtime.models.js +1 -0
- package/lib-prod/realtime/realtime.models.js.map +1 -1
- package/lib-prod/symbols.d.ts +39 -41
- package/lib-prod/symbols.js +44 -45
- package/lib-prod/symbols.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +2 -2
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/validators.d.ts +4 -6
- package/lib-prod/validators.js +50 -47
- package/lib-prod/validators.js.map +1 -1
- package/lib-prod.split-namespaces.json +188 -0
- package/package.json +28 -6
- package/websql/fesm2022/taon-websql.mjs +2 -10
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +76 -78
- package/websql-prod/fesm2022/taon-websql.mjs +855 -870
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +23 -0
- package/websql-prod/types/taon-websql.d.ts +498 -516
- package/websql-prod.split-namespaces.json +188 -0
- package/migrations/index.d.ts +0 -1
- package/migrations/index.js +0 -19
- package/migrations/index.js.map +0 -1
- package/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/migrations/migrations_index._auto-generated_.js +0 -4
- package/migrations/migrations_index._auto-generated_.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as coreHelpers from 'tnp-core/browser-prod';
|
|
3
|
-
import { _,
|
|
3
|
+
import { _, Utils_uniqArray, Helpers, UtilsOs_isRunningInDocker, config, CoreModels_SPECIAL_APP_READY_MESSAGE, UtilsOs_isRunningInCliMode, crossPlatformPath, UtilsTerminal_waitMilliseconds, CoreModels_TaonHttpErrorCustomProp } from 'tnp-core/browser-prod';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { JSON10 } from 'json10/browser-prod';
|
|
6
6
|
import { walk } from 'lodash-walk-object/browser-prod';
|
|
7
|
-
import { RestResponseWrapper,
|
|
7
|
+
import { RestResponseWrapper, Resource, Models_HttpResponse, RestHeaders, Mapping_decode, Mapping_DefaultModelWithMapping, HttpResponseError, Mapping_getModelsMapping } from 'ng2-rest/browser-prod';
|
|
8
8
|
import { Observable, from, Subject } from 'rxjs';
|
|
9
9
|
import * as i0 from '@angular/core';
|
|
10
10
|
import { InjectionToken, inject as inject$1, PLATFORM_ID, Injectable, ViewContainerRef, ViewChild, Component } from '@angular/core';
|
|
@@ -646,59 +646,57 @@ class Realtime {
|
|
|
646
646
|
return `${contextName}:${this.KEYroomUnsubscribe}EntityPropertyEvents`;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
})(Symbols || (Symbols = {}));
|
|
649
|
+
//namespace Symbols
|
|
650
|
+
const Symbols_ctxInClassOrClassObj = Symbol();
|
|
651
|
+
const Symbols_classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
652
|
+
const Symbols_fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
653
|
+
const Symbols_orignalClass = OrignalClassKey;
|
|
654
|
+
const Symbols_orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
655
|
+
const Symbols_classMethodsNames = `$$classMethodsNames$$`;
|
|
656
|
+
const Symbols_REALTIME = new Realtime();
|
|
657
|
+
const Symbols_metadata = {
|
|
658
|
+
className: `class:realname`,
|
|
659
|
+
options: {
|
|
660
|
+
controller: `controller:options`,
|
|
661
|
+
entity: `entity:options`,
|
|
662
|
+
repository: `repository:options`,
|
|
663
|
+
provider: `provider:options`,
|
|
664
|
+
subscriber: `subscriber:options`,
|
|
665
|
+
migration: `migration:options`,
|
|
666
|
+
},
|
|
667
|
+
};
|
|
668
|
+
const Symbols_old = {
|
|
669
|
+
HAS_TABLE_IN_DB: Symbol(),
|
|
670
|
+
MDC_KEY: `modeldataconfig`,
|
|
671
|
+
WEBSQL_REST_PROGRESS_FUN: Symbol(),
|
|
672
|
+
WEBSQL_REST_PROGRESS_FUN_START: Symbol(),
|
|
673
|
+
WEBSQL_REST_PROGRESS_FUN_DONE: Symbol(),
|
|
674
|
+
WEBSQL_REST_PROGRESS_TIMEOUT: Symbol(),
|
|
675
|
+
X_TOTAL_COUNT: `x-total-count`,
|
|
676
|
+
CIRCURAL_OBJECTS_MAP_BODY: `circuralmapbody`,
|
|
677
|
+
CIRCURAL_OBJECTS_MAP_QUERY_PARAM: `circuralmapbody`,
|
|
678
|
+
MAPPING_CONFIG_HEADER: `mappingheader`,
|
|
679
|
+
MAPPING_CONFIG_HEADER_BODY_PARAMS: `mhbodyparams`,
|
|
680
|
+
MAPPING_CONFIG_HEADER_QUERY_PARAMS: `mhqueryparams`,
|
|
681
|
+
ENDPOINT_META_CONFIG: `ng2_rest_endpoint_config`,
|
|
682
|
+
CLASS_DECORATOR_CONTEXT: `$$ng2_rest_class_context`,
|
|
683
|
+
SOCKET_MSG: `socketmessageng2rest`,
|
|
684
|
+
ANGULAR: {
|
|
685
|
+
INPUT_NAMES: Symbol(),
|
|
686
|
+
},
|
|
687
|
+
ERROR_MESSAGES: {
|
|
688
|
+
CLASS_NAME_MATCH: `Please check if your "class name" matches @Controller( className ) or @Entity( className )`,
|
|
689
|
+
},
|
|
690
|
+
};
|
|
691
|
+
//end of namespace Symbols
|
|
693
692
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
throw `[Taon]
|
|
693
|
+
//namespace Validators
|
|
694
|
+
//#region vlidate class name
|
|
695
|
+
const Validators_classNameVlidation = (className, target) => {
|
|
696
|
+
setTimeout(() => {
|
|
697
|
+
// console.log(`check after timeout ${className} , production mode: ${FrameworkContext.isProductionMode}`)
|
|
698
|
+
if (_.isUndefined(className)) {
|
|
699
|
+
throw `[Taon]
|
|
702
700
|
Please provide "className" property for each Controller and Entity:
|
|
703
701
|
|
|
704
702
|
@Taon.Controller({ className: 'MyExampleCtrl' })
|
|
@@ -715,21 +713,21 @@ var Validators;
|
|
|
715
713
|
Functions/Classes names -this is only solution to preserve classes names.
|
|
716
714
|
|
|
717
715
|
`;
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
return _.isUndefined(className) ? target.name : className;
|
|
721
|
-
};
|
|
722
|
-
//#endregion
|
|
723
|
-
//#region validate method config
|
|
724
|
-
Validators.checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
725
|
-
const defaultResponseType = 'text or JSON';
|
|
726
|
-
if (!current.responseType) {
|
|
727
|
-
return;
|
|
728
716
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
717
|
+
});
|
|
718
|
+
return _.isUndefined(className) ? target.name : className;
|
|
719
|
+
};
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region validate method config
|
|
722
|
+
const Validators_checkIfMethodsWithReponseTYpeAlowed = (methods, current) => {
|
|
723
|
+
const defaultResponseType = 'text or JSON';
|
|
724
|
+
if (!current.responseType) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
for (let index = 0; index < methods.length; index++) {
|
|
728
|
+
const m = methods[index];
|
|
729
|
+
if (m.path === current.path && m.responseType !== current.responseType) {
|
|
730
|
+
throw new Error(`
|
|
733
731
|
[taon] you can have 2 methods with same path but differetn reponseType-s
|
|
734
732
|
|
|
735
733
|
${m.methodName}( ... path: ${m.path} ) -> responseType: ${m.responseType || defaultResponseType}
|
|
@@ -738,410 +736,408 @@ var Validators;
|
|
|
738
736
|
Please change path name on of the methods.
|
|
739
737
|
|
|
740
738
|
`);
|
|
741
|
-
}
|
|
742
739
|
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region validate class functions
|
|
744
|
+
// TODO
|
|
745
|
+
const Validators_validateClassFunctions = (controllers, entities, proviers, repositories) => {
|
|
746
|
+
if (_.isArray(controllers) &&
|
|
747
|
+
controllers.filter(f => !_.isFunction(f)).length > 0) {
|
|
748
|
+
console.error('controllers', controllers);
|
|
749
|
+
throw `
|
|
752
750
|
|
|
753
751
|
Incorect value for property "controllers" inside Taon.Init(...)
|
|
754
752
|
|
|
755
753
|
`;
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
754
|
+
}
|
|
755
|
+
if (_.isArray(entities) &&
|
|
756
|
+
entities.filter(f => !_.isFunction(f)).length > 0) {
|
|
757
|
+
console.error('entites', entities);
|
|
758
|
+
throw `
|
|
761
759
|
|
|
762
760
|
Incorect value for property "entities" inside Taon.Init(...)
|
|
763
761
|
|
|
764
762
|
`;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
//#endregion
|
|
766
|
+
const Validators_preventUndefinedModel = (model, id) => {
|
|
767
|
+
if (_.isUndefined(model)) {
|
|
768
|
+
throw `Bad update by id, config, id: ${id}`;
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
//end of namespace Validators
|
|
774
772
|
|
|
775
773
|
//#region imports
|
|
776
774
|
/* */
|
|
777
775
|
//#endregion
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
parameters: { ...v.parameters }, // shallow clone parameters too
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
cfg = {
|
|
975
|
-
...parentCfg,
|
|
976
|
-
methods: clonedMethods,
|
|
776
|
+
//namespace ClassHelpers
|
|
777
|
+
//#region get class from name
|
|
778
|
+
/**
|
|
779
|
+
* TODO - repalce in every place when getting class fn from object
|
|
780
|
+
*/
|
|
781
|
+
const ClassHelpers_getClassFnFromObject = (json) => {
|
|
782
|
+
if (_.isUndefined(json) || _.isNull(json)) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
if (json.constructor) {
|
|
786
|
+
return json.constructor;
|
|
787
|
+
}
|
|
788
|
+
const p = Object.getPrototypeOf(json);
|
|
789
|
+
return p && p.constructor && p.constructor.name !== 'Object'
|
|
790
|
+
? p.constructor
|
|
791
|
+
: void 0;
|
|
792
|
+
};
|
|
793
|
+
//#endregion
|
|
794
|
+
//#region get name
|
|
795
|
+
const ClassHelpers_getName = (classFnOrObject) => {
|
|
796
|
+
// exception for FormData
|
|
797
|
+
if (classFnOrObject instanceof FormData) {
|
|
798
|
+
return 'FormData';
|
|
799
|
+
}
|
|
800
|
+
if (!classFnOrObject) {
|
|
801
|
+
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
802
|
+
throw new Error(`Cannot get name from this object or class.`);
|
|
803
|
+
}
|
|
804
|
+
return ((classFnOrObject[Symbols_classNameStaticProperty]
|
|
805
|
+
? classFnOrObject[Symbols_classNameStaticProperty]
|
|
806
|
+
: classFnOrObject?.constructor[Symbols_classNameStaticProperty]) ||
|
|
807
|
+
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
808
|
+
};
|
|
809
|
+
//#endregion
|
|
810
|
+
const ClassHelpers_getOrginalClass = (classFnOrObject) => {
|
|
811
|
+
const org = classFnOrObject[Symbols_orignalClass];
|
|
812
|
+
if (!org) {
|
|
813
|
+
return classFnOrObject;
|
|
814
|
+
}
|
|
815
|
+
return ClassHelpers_getOrginalClass(org);
|
|
816
|
+
};
|
|
817
|
+
//#region get full internal name
|
|
818
|
+
const ClassHelpers_getFullInternalName = (classFnOrObject) => {
|
|
819
|
+
// exception for FormData
|
|
820
|
+
if (!classFnOrObject) {
|
|
821
|
+
throw new Error(`Cannot get name from: ${classFnOrObject}`);
|
|
822
|
+
}
|
|
823
|
+
return ((classFnOrObject[Symbols_fullClassNameStaticProperty]
|
|
824
|
+
? classFnOrObject[Symbols_fullClassNameStaticProperty]
|
|
825
|
+
: classFnOrObject?.constructor[Symbols_fullClassNameStaticProperty]) ||
|
|
826
|
+
void 0);
|
|
827
|
+
};
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region get unique key
|
|
830
|
+
const ClassHelpers_getUniqueKey = (classFnOrObject) => {
|
|
831
|
+
const classFn = _.isFunction(classFnOrObject)
|
|
832
|
+
? classFnOrObject
|
|
833
|
+
: classFnOrObject.constructor;
|
|
834
|
+
const config = Reflect.getMetadata(Symbols_metadata.options.entity, classFn);
|
|
835
|
+
return config.uniqueKeyProp;
|
|
836
|
+
};
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region is class object
|
|
839
|
+
const ClassHelpers_isContextClassObject = (obj) => {
|
|
840
|
+
if (!_.isObject(obj) ||
|
|
841
|
+
_.isArray(obj) ||
|
|
842
|
+
_.isRegExp(obj) ||
|
|
843
|
+
_.isBuffer(obj) ||
|
|
844
|
+
_.isArrayBuffer(obj)) {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
if (_.isDate(obj)) {
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
const className = ClassHelpers_getName(obj);
|
|
851
|
+
return _.isString(className) && className !== 'Object';
|
|
852
|
+
};
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region get name
|
|
855
|
+
const ClassHelpers_setName = (target, className) => {
|
|
856
|
+
// console.log('setName', className, target.name)
|
|
857
|
+
Validators_classNameVlidation(className, target);
|
|
858
|
+
target[Symbols_classNameStaticProperty] = className;
|
|
859
|
+
};
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region has parent with class name
|
|
862
|
+
const ClassHelpers_hasParentClassWithName = (target, className, targets = []) => {
|
|
863
|
+
if (!target) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
targets.push(target);
|
|
867
|
+
let targetProto = Object.getPrototypeOf(target);
|
|
868
|
+
if (_.isFunction(targetProto) &&
|
|
869
|
+
ClassHelpers_getName(targetProto) === className) {
|
|
870
|
+
// console.log(`true "${_.first(targets).name}" for ${targets.map(d => d.name).join(',')}`)
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
return ClassHelpers_hasParentClassWithName(targetProto, className, targets);
|
|
874
|
+
};
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region get methods name
|
|
877
|
+
//#region not allowed as method name
|
|
878
|
+
const notAllowedAsMethodName = [
|
|
879
|
+
'length',
|
|
880
|
+
'name',
|
|
881
|
+
'arguments',
|
|
882
|
+
'caller',
|
|
883
|
+
'constructor',
|
|
884
|
+
'apply',
|
|
885
|
+
'bind',
|
|
886
|
+
'call',
|
|
887
|
+
'toString',
|
|
888
|
+
'__defineGetter__',
|
|
889
|
+
'__defineSetter__',
|
|
890
|
+
'hasOwnProperty',
|
|
891
|
+
'__lookupGetter__',
|
|
892
|
+
'__lookupSetter__',
|
|
893
|
+
'isPrototypeOf',
|
|
894
|
+
'propertyIsEnumerable',
|
|
895
|
+
'valueOf',
|
|
896
|
+
'__proto__',
|
|
897
|
+
'toLocaleString',
|
|
898
|
+
];
|
|
899
|
+
//#endregion
|
|
900
|
+
/**
|
|
901
|
+
* Express async handler for middleware functions.
|
|
902
|
+
*/
|
|
903
|
+
const ClassHelpers_asyncHandler = fn => (req, res, next) => {
|
|
904
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
905
|
+
};
|
|
906
|
+
const ClassHelpers_getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
|
|
907
|
+
if (!classOrClassInstance) {
|
|
908
|
+
return Utils_uniqArray(allMethodsNames);
|
|
909
|
+
}
|
|
910
|
+
const isClassFunction = _.isFunction(classOrClassInstance);
|
|
911
|
+
const classFun = isClassFunction
|
|
912
|
+
? classOrClassInstance
|
|
913
|
+
: Object.getPrototypeOf(classOrClassInstance);
|
|
914
|
+
const objectToCheck = isClassFunction
|
|
915
|
+
? classOrClassInstance?.prototype
|
|
916
|
+
: classOrClassInstance;
|
|
917
|
+
const prototypeObj = Object.getPrototypeOf(objectToCheck || {});
|
|
918
|
+
const properties = _.uniq([
|
|
919
|
+
...Object.getOwnPropertyNames(objectToCheck || {}),
|
|
920
|
+
...Object.getOwnPropertyNames(prototypeObj || {}),
|
|
921
|
+
...Object.keys(objectToCheck || {}),
|
|
922
|
+
...Object.keys(prototypeObj || {}),
|
|
923
|
+
]).filter(f => !!f && !notAllowedAsMethodName.includes(f));
|
|
924
|
+
properties
|
|
925
|
+
.filter(methodName => typeof objectToCheck[methodName] === 'function')
|
|
926
|
+
.forEach(p => allMethodsNames.push(p));
|
|
927
|
+
if (!classFun ||
|
|
928
|
+
!classFun.constructor ||
|
|
929
|
+
classFun?.constructor?.name === 'Object') {
|
|
930
|
+
return Utils_uniqArray(allMethodsNames);
|
|
931
|
+
}
|
|
932
|
+
return ClassHelpers_getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
|
|
933
|
+
};
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region get controller configs
|
|
936
|
+
const ClassHelpers_getControllerConfigs = (target, configs = [], callerTarget) => {
|
|
937
|
+
if (!_.isFunction(target)) {
|
|
938
|
+
throw `[typescript-class-helper][getControllerConfigs] Cannot get class config from: ${target}`;
|
|
939
|
+
}
|
|
940
|
+
let config;
|
|
941
|
+
const parentClass = Object.getPrototypeOf(target);
|
|
942
|
+
const parentName = parentClass ? ClassHelpers_getName(parentClass) : void 0;
|
|
943
|
+
const isValidParent = _.isFunction(parentClass) && parentName !== '';
|
|
944
|
+
config = controllerConfigFrom(ClassHelpers_getClassConfig(target));
|
|
945
|
+
configs.push(config);
|
|
946
|
+
return isValidParent
|
|
947
|
+
? ClassHelpers_getControllerConfigs(parentClass, configs, target)
|
|
948
|
+
: configs;
|
|
949
|
+
};
|
|
950
|
+
//#endregion
|
|
951
|
+
//#region ensure configs
|
|
952
|
+
// Ensure ClassConfig on constructor, clone parent if needed
|
|
953
|
+
const ClassHelpers_ensureClassConfig = (target) => {
|
|
954
|
+
let cfg = Reflect.getOwnMetadata(Symbols_metadata.options.controller, // META_KEYS.class,
|
|
955
|
+
target);
|
|
956
|
+
if (!cfg) {
|
|
957
|
+
cfg = { methods: {} };
|
|
958
|
+
const parent = Object.getPrototypeOf(target);
|
|
959
|
+
if (parent && parent !== Function.prototype) {
|
|
960
|
+
const parentCfg = Reflect.getMetadata(Symbols_metadata.options.controller, // META_KEYS.class,
|
|
961
|
+
parent);
|
|
962
|
+
if (parentCfg) {
|
|
963
|
+
// Deep copy each method config so child gets its own objects
|
|
964
|
+
const clonedMethods = {};
|
|
965
|
+
for (const [k, v] of Object.entries(parentCfg.methods)) {
|
|
966
|
+
clonedMethods[k] = {
|
|
967
|
+
...v,
|
|
968
|
+
parameters: { ...v.parameters }, // shallow clone parameters too
|
|
977
969
|
};
|
|
978
970
|
}
|
|
971
|
+
cfg = {
|
|
972
|
+
...parentCfg,
|
|
973
|
+
methods: clonedMethods,
|
|
974
|
+
};
|
|
979
975
|
}
|
|
980
|
-
Reflect.defineMetadata(Symbols.metadata.options.controller, cfg, target);
|
|
981
976
|
}
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}
|
|
977
|
+
Reflect.defineMetadata(Symbols_metadata.options.controller, cfg, target);
|
|
978
|
+
}
|
|
979
|
+
return cfg;
|
|
980
|
+
};
|
|
981
|
+
// Ensure MethodConfig inside ClassConfig
|
|
982
|
+
const ClassHelpers_ensureMethodConfig = (target, propertyKey) => {
|
|
983
|
+
const classCfg = ClassHelpers_ensureClassConfig(target.constructor);
|
|
984
|
+
let methodCfg = classCfg.methods[propertyKey?.toString()];
|
|
985
|
+
if (!methodCfg) {
|
|
986
|
+
methodCfg = { methodName: propertyKey?.toString(), parameters: {} };
|
|
987
|
+
classCfg.methods[propertyKey?.toString()] = methodCfg;
|
|
988
|
+
}
|
|
989
|
+
return methodCfg;
|
|
990
|
+
};
|
|
991
|
+
const ClassHelpers_getClassConfig = (constructor) => {
|
|
992
|
+
return Reflect.getMetadata(Symbols_metadata.options.controller, constructor);
|
|
993
|
+
};
|
|
994
|
+
//#endregion
|
|
995
|
+
//end of namespace ClassHelpers
|
|
999
996
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
return true;
|
|
1032
|
-
}
|
|
1033
|
-
if (bool === 'false') {
|
|
1034
|
-
return false;
|
|
1035
|
-
}
|
|
1036
|
-
try {
|
|
1037
|
-
const t = JSON5.parse(param);
|
|
1038
|
-
return t;
|
|
1039
|
-
}
|
|
1040
|
-
catch (e) {
|
|
1041
|
-
return param;
|
|
1042
|
-
}
|
|
997
|
+
//namespace TaonHelpers
|
|
998
|
+
//#region fillUpTo string
|
|
999
|
+
const TaonHelpers_fillUpTo = (s, nCharacters) => {
|
|
1000
|
+
return _.times(nCharacters, n => {
|
|
1001
|
+
if (s.charAt(n)) {
|
|
1002
|
+
return s.charAt(n);
|
|
1003
|
+
}
|
|
1004
|
+
return ' ';
|
|
1005
|
+
}).join('');
|
|
1006
|
+
};
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region is good path
|
|
1009
|
+
const TaonHelpers_isGoodPath = (p) => {
|
|
1010
|
+
return p && typeof p === 'string' && p.trim() !== '';
|
|
1011
|
+
};
|
|
1012
|
+
//#endregion
|
|
1013
|
+
const TaonHelpers_firstStringOrElemFromArray = (stringOrArrayOfString) => {
|
|
1014
|
+
if (Array.isArray(stringOrArrayOfString)) {
|
|
1015
|
+
return _.first(stringOrArrayOfString);
|
|
1016
|
+
}
|
|
1017
|
+
return stringOrArrayOfString;
|
|
1018
|
+
};
|
|
1019
|
+
//#region try transform params
|
|
1020
|
+
const TaonHelpers_tryTransformParam = param => {
|
|
1021
|
+
if (typeof param === 'string') {
|
|
1022
|
+
let n = Number(param);
|
|
1023
|
+
if (!isNaN(n))
|
|
1024
|
+
return n;
|
|
1025
|
+
const bool = param.trim().toLowerCase();
|
|
1026
|
+
if (bool === 'true') {
|
|
1027
|
+
return true;
|
|
1043
1028
|
}
|
|
1044
|
-
|
|
1045
|
-
};
|
|
1046
|
-
//#endregion
|
|
1047
|
-
//#region get expores path
|
|
1048
|
-
TaonHelpers.getExpressPath = (c, pathOrClassConfig) => {
|
|
1049
|
-
if (typeof pathOrClassConfig === 'string')
|
|
1050
|
-
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1051
|
-
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1052
|
-
};
|
|
1053
|
-
//#endregion
|
|
1054
|
-
//#region get default value tyep
|
|
1055
|
-
TaonHelpers.defaultType = value => {
|
|
1056
|
-
if (typeof value === 'string')
|
|
1057
|
-
return '';
|
|
1058
|
-
if (typeof value === 'boolean')
|
|
1029
|
+
if (bool === 'false') {
|
|
1059
1030
|
return false;
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
return
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1031
|
+
}
|
|
1032
|
+
try {
|
|
1033
|
+
const t = JSON5.parse(param);
|
|
1034
|
+
return t;
|
|
1035
|
+
}
|
|
1036
|
+
catch (e) {
|
|
1037
|
+
return param;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return param;
|
|
1041
|
+
};
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region get expores path
|
|
1044
|
+
const TaonHelpers_getExpressPath = (c, pathOrClassConfig) => {
|
|
1045
|
+
if (typeof pathOrClassConfig === 'string')
|
|
1046
|
+
return `${c.calculatedPath}${pathOrClassConfig}`.replace(/\/$/, '');
|
|
1047
|
+
return `${c.calculatedPath}${pathOrClassConfig.path}`.replace(/\/$/, '');
|
|
1048
|
+
};
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region get default value tyep
|
|
1051
|
+
const TaonHelpers_defaultType = value => {
|
|
1052
|
+
if (typeof value === 'string')
|
|
1053
|
+
return '';
|
|
1054
|
+
if (typeof value === 'boolean')
|
|
1055
|
+
return false;
|
|
1056
|
+
if (Array.isArray(value))
|
|
1057
|
+
return {};
|
|
1058
|
+
if (typeof value === 'object')
|
|
1059
|
+
return {};
|
|
1060
|
+
};
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region parse json with string jsons
|
|
1063
|
+
const TaonHelpers_parseJSONwithStringJSONs = (object, waring = false) => {
|
|
1064
|
+
// console.log('checking object', object)
|
|
1065
|
+
if (!_.isObject(object)) {
|
|
1066
|
+
if (waring) {
|
|
1067
|
+
console.error(`
|
|
1072
1068
|
parseJSONwithStringJSONs(...)
|
|
1073
1069
|
Parameter should be a object, but is ${typeof object}
|
|
1074
1070
|
`, object);
|
|
1075
|
-
}
|
|
1076
|
-
return object;
|
|
1077
1071
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
};
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
return { request, response };
|
|
1072
|
+
return object;
|
|
1073
|
+
}
|
|
1074
|
+
let res = _.cloneDeep(object);
|
|
1075
|
+
Object.keys(res).forEach(key => {
|
|
1076
|
+
let isJson = false;
|
|
1077
|
+
try {
|
|
1078
|
+
const possibleJSON = JSON.parse(res[key]);
|
|
1079
|
+
res[key] = possibleJSON;
|
|
1080
|
+
isJson = true;
|
|
1081
|
+
}
|
|
1082
|
+
catch (e) {
|
|
1083
|
+
isJson = false;
|
|
1084
|
+
}
|
|
1085
|
+
// console.log(`key ${key} is json `, isJson)
|
|
1086
|
+
if (isJson) {
|
|
1087
|
+
res[key] = TaonHelpers_parseJSONwithStringJSONs(res[key], false);
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
return res;
|
|
1091
|
+
};
|
|
1092
|
+
//#endregion
|
|
1093
|
+
//#region is plain file or folder
|
|
1094
|
+
const TaonHelpers_isPlainFileOrFolder = filePath => {
|
|
1095
|
+
return /^([a-zA-Z]|\-|\_|\@|\#|\$|\!|\^|\&|\*|\(|\))+$/.test(filePath);
|
|
1096
|
+
};
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region ips key name repsonse
|
|
1099
|
+
const TaonHelpers_ipcKeyNameResponse = (target, methodConfig, expressPath) => {
|
|
1100
|
+
return [
|
|
1101
|
+
'response',
|
|
1102
|
+
ClassHelpers_getName(target),
|
|
1103
|
+
methodConfig.methodName,
|
|
1104
|
+
methodConfig.type,
|
|
1105
|
+
expressPath,
|
|
1106
|
+
].join('--');
|
|
1107
|
+
};
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region ipc key name request
|
|
1110
|
+
const TaonHelpers_ipcKeyNameRequest = (target, methodConfig, expressPath) => {
|
|
1111
|
+
return [
|
|
1112
|
+
'request',
|
|
1113
|
+
ClassHelpers_getName(target),
|
|
1114
|
+
methodConfig.methodName,
|
|
1115
|
+
methodConfig.type,
|
|
1116
|
+
expressPath,
|
|
1117
|
+
].join('--');
|
|
1118
|
+
};
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region websql mocks
|
|
1121
|
+
const TaonHelpers_websqlMocks = headers => {
|
|
1122
|
+
const response = {
|
|
1123
|
+
status(status) {
|
|
1124
|
+
// console.log({status})
|
|
1125
|
+
return {
|
|
1126
|
+
send(send) {
|
|
1127
|
+
// console.log({status})
|
|
1128
|
+
},
|
|
1129
|
+
};
|
|
1130
|
+
},
|
|
1131
|
+
setHeader(key, value) {
|
|
1132
|
+
// console.log('Dummy set header', arguments)
|
|
1133
|
+
headers[key] = value;
|
|
1134
|
+
},
|
|
1142
1135
|
};
|
|
1143
|
-
|
|
1144
|
-
|
|
1136
|
+
const request = {};
|
|
1137
|
+
return { request, response };
|
|
1138
|
+
};
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//end of namespace TaonHelpers
|
|
1145
1141
|
|
|
1146
1142
|
// ! TODO make it as a nice way to wrap normal request
|
|
1147
1143
|
class TaonRestResponseWrapper extends RestResponseWrapper {
|
|
@@ -1167,72 +1163,58 @@ const BaseTaonClassesNames = [
|
|
|
1167
1163
|
];
|
|
1168
1164
|
const TaonTempDatabasesFolder = 'databases';
|
|
1169
1165
|
const TaonTempRoutesFolder = 'routes';
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
static from(databasePartialConfig) {
|
|
1202
|
-
return _.merge(new DatabaseConfig(), databasePartialConfig);
|
|
1203
|
-
}
|
|
1204
|
-
get databaseConfigTypeORM() {
|
|
1205
|
-
/* */
|
|
1206
|
-
/* */
|
|
1207
|
-
/* */
|
|
1208
|
-
/* */
|
|
1209
|
-
/* */
|
|
1210
|
-
/* */
|
|
1211
|
-
/* */
|
|
1212
|
-
/* */
|
|
1213
|
-
/* */
|
|
1214
|
-
/* */
|
|
1215
|
-
/* */
|
|
1216
|
-
/* */
|
|
1217
|
-
/* */
|
|
1218
|
-
/* */
|
|
1219
|
-
return (void 0);
|
|
1220
|
-
}
|
|
1166
|
+
//namespace Models
|
|
1167
|
+
const Models_DatabasesFolder = TaonTempDatabasesFolder;
|
|
1168
|
+
//#region models / class types
|
|
1169
|
+
var Models_ClassType;
|
|
1170
|
+
(function (Models_ClassType) {
|
|
1171
|
+
Models_ClassType["ENTITY"] = "ENTITY";
|
|
1172
|
+
Models_ClassType["CONTROLLER"] = "CONTROLLER";
|
|
1173
|
+
Models_ClassType["REPOSITORY"] = "REPOSITORY";
|
|
1174
|
+
Models_ClassType["PROVIDER"] = "PROVIDER";
|
|
1175
|
+
Models_ClassType["SUBSCRIBER"] = "SUBSCRIBER";
|
|
1176
|
+
Models_ClassType["MIGRATION"] = "MIGRATION";
|
|
1177
|
+
Models_ClassType["MIDDLEWARE"] = "MIDDLEWARE";
|
|
1178
|
+
})(Models_ClassType || (Models_ClassType = {}));
|
|
1179
|
+
const Models_ClassTypeKey = {
|
|
1180
|
+
[Models_ClassType.ENTITY]: 'entities',
|
|
1181
|
+
[Models_ClassType.CONTROLLER]: 'controllers',
|
|
1182
|
+
[Models_ClassType.REPOSITORY]: 'repositories',
|
|
1183
|
+
[Models_ClassType.PROVIDER]: 'providers',
|
|
1184
|
+
[Models_ClassType.SUBSCRIBER]: 'subscribers',
|
|
1185
|
+
[Models_ClassType.MIGRATION]: 'migrations',
|
|
1186
|
+
[Models_ClassType.MIDDLEWARE]: 'middlewares',
|
|
1187
|
+
};
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region models / database connection options
|
|
1190
|
+
class Models_DatabaseConfigTypeOrm {
|
|
1191
|
+
}
|
|
1192
|
+
//#endregion
|
|
1193
|
+
//#region models / database config
|
|
1194
|
+
class Models_DatabaseConfig extends Models_DatabaseConfigTypeOrm {
|
|
1195
|
+
static from(databasePartialConfig) {
|
|
1196
|
+
return _.merge(new Models_DatabaseConfig(), databasePartialConfig);
|
|
1221
1197
|
}
|
|
1222
|
-
|
|
1223
|
-
//#endregion
|
|
1224
|
-
//#region models / http
|
|
1225
|
-
let Http;
|
|
1226
|
-
(function (Http) {
|
|
1227
|
-
Http.Rest = Models$1;
|
|
1198
|
+
get databaseConfigTypeORM() {
|
|
1228
1199
|
/* */
|
|
1229
1200
|
/* */
|
|
1230
1201
|
/* */
|
|
1231
1202
|
/* */
|
|
1232
1203
|
/* */
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1204
|
+
/* */
|
|
1205
|
+
/* */
|
|
1206
|
+
/* */
|
|
1207
|
+
/* */
|
|
1208
|
+
/* */
|
|
1209
|
+
/* */
|
|
1210
|
+
/* */
|
|
1211
|
+
/* */
|
|
1212
|
+
/* */
|
|
1213
|
+
return (void 0);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
//#endregion
|
|
1217
|
+
//end of namespace Models
|
|
1236
1218
|
|
|
1237
1219
|
//#region imports
|
|
1238
1220
|
/* */
|
|
@@ -1258,18 +1240,18 @@ class RealtimeSubsManager {
|
|
|
1258
1240
|
// console.info(`[BROWSER]][IPC] subscribe to "${this.options?.roomName}" by sending event: "${subscribeEvent}"`, this.options);
|
|
1259
1241
|
this.isListening = true;
|
|
1260
1242
|
if (this.options.customEvent) {
|
|
1261
|
-
const subscribeEvent =
|
|
1243
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_CUSTOM(this.options.core.ctx.contextName);
|
|
1262
1244
|
// this means: send to current client custom event notification
|
|
1263
1245
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1264
1246
|
}
|
|
1265
1247
|
else {
|
|
1266
1248
|
if (_.isString(this.options.property)) {
|
|
1267
|
-
const subscribeEvent =
|
|
1249
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1268
1250
|
// this means: send to current client entity property events updates
|
|
1269
1251
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1270
1252
|
}
|
|
1271
1253
|
else {
|
|
1272
|
-
const subscribeEvent =
|
|
1254
|
+
const subscribeEvent = Symbols_REALTIME.ROOM_SUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName);
|
|
1273
1255
|
// this means: send to current client entity update events
|
|
1274
1256
|
realtime.emit(subscribeEvent, this.options.roomName);
|
|
1275
1257
|
}
|
|
@@ -1297,14 +1279,14 @@ class RealtimeSubsManager {
|
|
|
1297
1279
|
const { core, customEvent, roomName, property } = this.options;
|
|
1298
1280
|
const realtime = core.socketFE;
|
|
1299
1281
|
if (customEvent) {
|
|
1300
|
-
realtime.emit(
|
|
1282
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_CUSTOM(this.options.core.ctx.contextName), roomName);
|
|
1301
1283
|
}
|
|
1302
1284
|
else {
|
|
1303
1285
|
if (_.isString(property)) {
|
|
1304
|
-
realtime.emit(
|
|
1286
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_PROPERTY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1305
1287
|
}
|
|
1306
1288
|
else {
|
|
1307
|
-
realtime.emit(
|
|
1289
|
+
realtime.emit(Symbols_REALTIME.ROOM_UNSUBSCRIBE_ENTITY_UPDATE_EVENTS(this.options.core.ctx.contextName), roomName);
|
|
1308
1290
|
}
|
|
1309
1291
|
}
|
|
1310
1292
|
}
|
|
@@ -1351,7 +1333,7 @@ class RealtimeClient {
|
|
|
1351
1333
|
//#region prepare naspaces pathes
|
|
1352
1334
|
const nspPath = {
|
|
1353
1335
|
global: this.core.pathFor(),
|
|
1354
|
-
realtime: this.core.pathFor(
|
|
1336
|
+
realtime: this.core.pathFor(Symbols_REALTIME.NAMESPACE(this.core.ctx.contextName)),
|
|
1355
1337
|
};
|
|
1356
1338
|
// console.log('[browser] nspPath', nspPath);
|
|
1357
1339
|
if (this.core.ctx.config.frontendHost &&
|
|
@@ -1420,15 +1402,15 @@ class RealtimeClient {
|
|
|
1420
1402
|
if (_.isObject(entityClassFnOrObj)) {
|
|
1421
1403
|
const orgObj = entityClassFnOrObj;
|
|
1422
1404
|
entityClassFnOrObj =
|
|
1423
|
-
|
|
1424
|
-
const uniqueKey =
|
|
1405
|
+
ClassHelpers_getClassFnFromObject(entityClassFnOrObj);
|
|
1406
|
+
const uniqueKey = ClassHelpers_getUniqueKey(entityClassFnOrObj);
|
|
1425
1407
|
if (uniqueKey) {
|
|
1426
1408
|
options.idOrUniqValue = orgObj[uniqueKey];
|
|
1427
1409
|
}
|
|
1428
1410
|
}
|
|
1429
1411
|
//#region parameters validation
|
|
1430
1412
|
const { property, customEvent } = options;
|
|
1431
|
-
const className = !customEvent &&
|
|
1413
|
+
const className = !customEvent && ClassHelpers_getName(entityClassFnOrObj);
|
|
1432
1414
|
if (_.isString(property)) {
|
|
1433
1415
|
if (property.trim() === '') {
|
|
1434
1416
|
throw new Error(`[Taon][listenChangesEntity.. incorrect property '' for ${className}`);
|
|
@@ -1452,12 +1434,12 @@ to use socket realtime connection;
|
|
|
1452
1434
|
}
|
|
1453
1435
|
let roomName;
|
|
1454
1436
|
if (customEvent) {
|
|
1455
|
-
roomName =
|
|
1437
|
+
roomName = Symbols_REALTIME.ROOM_NAME_CUSTOM(this.core.ctx.contextName, customEvent);
|
|
1456
1438
|
}
|
|
1457
1439
|
else {
|
|
1458
1440
|
roomName = _.isString(property)
|
|
1459
|
-
?
|
|
1460
|
-
:
|
|
1441
|
+
? Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY_PROPERTY(this.core.ctx.contextName, className, property, options.idOrUniqValue)
|
|
1442
|
+
: Symbols_REALTIME.ROOM_NAME_UPDATE_ENTITY(this.core.ctx.contextName, className, options.idOrUniqValue);
|
|
1461
1443
|
}
|
|
1462
1444
|
const roomSubOptions = {
|
|
1463
1445
|
core: this.core,
|
|
@@ -1485,9 +1467,9 @@ to use socket realtime connection;
|
|
|
1485
1467
|
* Example: for pagination, lists update ...
|
|
1486
1468
|
*/
|
|
1487
1469
|
listenChangesEntityTable(entityClassFn) {
|
|
1488
|
-
const className =
|
|
1470
|
+
const className = ClassHelpers_getName(entityClassFn);
|
|
1489
1471
|
return this.listenChangesEntity(entityClassFn, {
|
|
1490
|
-
customEvent:
|
|
1472
|
+
customEvent: Symbols_REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className),
|
|
1491
1473
|
});
|
|
1492
1474
|
}
|
|
1493
1475
|
//#endregion
|
|
@@ -1784,7 +1766,7 @@ class RealtimeServer {
|
|
|
1784
1766
|
*/
|
|
1785
1767
|
idToTrigger) {
|
|
1786
1768
|
if (this.core.ctx.disabledRealtime) {
|
|
1787
|
-
const className =
|
|
1769
|
+
const className = ClassHelpers_getName(entityObjOrClass);
|
|
1788
1770
|
console.warn(`[Taon][TriggerEntityChanges] Entity "${className}' is not realtime`);
|
|
1789
1771
|
return;
|
|
1790
1772
|
}
|
|
@@ -1804,7 +1786,7 @@ class RealtimeServer {
|
|
|
1804
1786
|
*/
|
|
1805
1787
|
idToTrigger) {
|
|
1806
1788
|
if (this.core.ctx.disabledRealtime) {
|
|
1807
|
-
const className =
|
|
1789
|
+
const className = ClassHelpers_getName(entityObjOrClass);
|
|
1808
1790
|
console.warn(`[Taon][TriggerEntityPropertyChanges][property=${property}] Entity "${className}' is not realtime`);
|
|
1809
1791
|
return;
|
|
1810
1792
|
}
|
|
@@ -1820,12 +1802,12 @@ class RealtimeServer {
|
|
|
1820
1802
|
//#endregion
|
|
1821
1803
|
//#region methods & getters / trigger entity table changes
|
|
1822
1804
|
triggerEntityTableChanges(entityClassOrInstance) {
|
|
1823
|
-
const className =
|
|
1805
|
+
const className = ClassHelpers_getName(entityClassOrInstance);
|
|
1824
1806
|
if (this.core.ctx.disabledRealtime) {
|
|
1825
1807
|
console.warn(`[Taon][TriggerEntityTableChanges] Entity "${className}' is not realtime`);
|
|
1826
1808
|
return;
|
|
1827
1809
|
}
|
|
1828
|
-
this.triggerChanges(entityClassOrInstance, void 0, void 0,
|
|
1810
|
+
this.triggerChanges(entityClassOrInstance, void 0, void 0, Symbols_REALTIME.TABLE_CHANGE(this.core.ctx.contextName, className));
|
|
1829
1811
|
}
|
|
1830
1812
|
//#endregion
|
|
1831
1813
|
//#endregion
|
|
@@ -2354,11 +2336,11 @@ class MockSocket {
|
|
|
2354
2336
|
//#region emit
|
|
2355
2337
|
emit(eventName, ...args) {
|
|
2356
2338
|
eventName = eventName || '';
|
|
2357
|
-
if (eventName.includes(`:${
|
|
2339
|
+
if (eventName.includes(`:${Symbols_REALTIME.KEYroomSubscribe}`)) {
|
|
2358
2340
|
const room = args[0];
|
|
2359
2341
|
this.join(room);
|
|
2360
2342
|
}
|
|
2361
|
-
else if (eventName.includes(`:${
|
|
2343
|
+
else if (eventName.includes(`:${Symbols_REALTIME.KEYroomUnsubscribe}`)) {
|
|
2362
2344
|
const room = args[0];
|
|
2363
2345
|
this.leave(room);
|
|
2364
2346
|
}
|
|
@@ -2646,18 +2628,18 @@ class EndpointContext {
|
|
|
2646
2628
|
//#endregion
|
|
2647
2629
|
//#region fields / types from contexts
|
|
2648
2630
|
this.injectableTypesfromContexts = [
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2631
|
+
Models_ClassType.CONTROLLER,
|
|
2632
|
+
Models_ClassType.PROVIDER,
|
|
2633
|
+
Models_ClassType.MIDDLEWARE,
|
|
2634
|
+
Models_ClassType.REPOSITORY,
|
|
2635
|
+
Models_ClassType.SUBSCRIBER,
|
|
2636
|
+
Models_ClassType.MIGRATION,
|
|
2655
2637
|
];
|
|
2656
2638
|
//#endregion
|
|
2657
2639
|
//#region fields / all types from contexts
|
|
2658
2640
|
this.allTypesfromContexts = [
|
|
2659
2641
|
...this.injectableTypesfromContexts,
|
|
2660
|
-
|
|
2642
|
+
Models_ClassType.ENTITY,
|
|
2661
2643
|
];
|
|
2662
2644
|
//#endregion
|
|
2663
2645
|
//#region fields / express app
|
|
@@ -2682,7 +2664,7 @@ class EndpointContext {
|
|
|
2682
2664
|
// Return a new class that extends the base class
|
|
2683
2665
|
const cloneClass = () => {
|
|
2684
2666
|
var _a, _b, _c, _d, _e;
|
|
2685
|
-
if (TaonBaseClass[
|
|
2667
|
+
if (TaonBaseClass[Symbols_fullClassNameStaticProperty] ===
|
|
2686
2668
|
`${ctx.contextName}.${className}`) {
|
|
2687
2669
|
return TaonBaseClass;
|
|
2688
2670
|
}
|
|
@@ -2694,7 +2676,7 @@ class EndpointContext {
|
|
|
2694
2676
|
// You can override prototype properties or methods here if needed
|
|
2695
2677
|
// static properties override allowed
|
|
2696
2678
|
}
|
|
2697
|
-
static { _a =
|
|
2679
|
+
static { _a = Symbols_orignalClass, _b = Symbols_fullClassNameStaticProperty, _c = Symbols_classNameStaticProperty, _d = Symbols_ctxInClassOrClassObj, _e = Symbols_ctxInClassOrClassObj; }
|
|
2698
2680
|
// @ts-ignore
|
|
2699
2681
|
static { this[_a] = TaonBaseClass; }
|
|
2700
2682
|
// @ts-ignore
|
|
@@ -2704,13 +2686,13 @@ class EndpointContext {
|
|
|
2704
2686
|
static { this[_d] = ctx; }
|
|
2705
2687
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2706
2688
|
static __getFullPathForClass__(arr = []) {
|
|
2707
|
-
const name = this[
|
|
2689
|
+
const name = this[Symbols_fullClassNameStaticProperty];
|
|
2708
2690
|
arr.push(name);
|
|
2709
2691
|
// @ts-ignore
|
|
2710
|
-
if (this[
|
|
2711
|
-
this[
|
|
2692
|
+
if (this[Symbols_orignalClass] && // @ts-ignore
|
|
2693
|
+
this[Symbols_orignalClass].__getFullPathForClass__) {
|
|
2712
2694
|
// @ts-ignore
|
|
2713
|
-
this[
|
|
2695
|
+
this[Symbols_orignalClass].__getFullPathForClass__(arr);
|
|
2714
2696
|
}
|
|
2715
2697
|
return arr.join('/');
|
|
2716
2698
|
}
|
|
@@ -2723,19 +2705,19 @@ class EndpointContext {
|
|
|
2723
2705
|
//#region gather all instances for all contexts
|
|
2724
2706
|
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
2725
2707
|
// this thinng belowe is nice for debugging purpose
|
|
2726
|
-
// if (_.isUndefined(cloneClassFunction[
|
|
2727
|
-
// cloneClassFunction[
|
|
2708
|
+
// if (_.isUndefined(cloneClassFunction[Symbols_orignalClassClonesObj])) {
|
|
2709
|
+
// cloneClassFunction[Symbols_orignalClassClonesObj] = {};
|
|
2728
2710
|
// }
|
|
2729
|
-
// if (_.isUndefined(TaonBaseClass[
|
|
2730
|
-
// TaonBaseClass[
|
|
2711
|
+
// if (_.isUndefined(TaonBaseClass[Symbols_orignalClassClonesObj])) {
|
|
2712
|
+
// TaonBaseClass[Symbols_orignalClassClonesObj] = {};
|
|
2731
2713
|
// }
|
|
2732
2714
|
// const all = {
|
|
2733
|
-
// ...TaonBaseClass[
|
|
2734
|
-
// ...cloneClassFunction[
|
|
2715
|
+
// ...TaonBaseClass[Symbols_orignalClassClonesObj],
|
|
2716
|
+
// ...cloneClassFunction[Symbols_orignalClassClonesObj],
|
|
2735
2717
|
// };
|
|
2736
2718
|
// all[ctx.contextName] = cloneClassFunction;
|
|
2737
|
-
// cloneClassFunction[
|
|
2738
|
-
// TaonBaseClass[
|
|
2719
|
+
// cloneClassFunction[Symbols_orignalClassClonesObj] = all;
|
|
2720
|
+
// TaonBaseClass[Symbols_orignalClassClonesObj] = all;
|
|
2739
2721
|
//#endregion
|
|
2740
2722
|
return cloneClassFunction;
|
|
2741
2723
|
};
|
|
@@ -2754,13 +2736,13 @@ class EndpointContext {
|
|
|
2754
2736
|
|
|
2755
2737
|
`);
|
|
2756
2738
|
}
|
|
2757
|
-
var className = Reflect.getMetadata(
|
|
2739
|
+
var className = Reflect.getMetadata(Symbols_metadata.className, TaonBaseClass);
|
|
2758
2740
|
// console.log('Metadata className', className, TaonBaseClass);
|
|
2759
2741
|
// if (!className) {
|
|
2760
2742
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
2761
2743
|
// }
|
|
2762
2744
|
className = className || key;
|
|
2763
|
-
TaonBaseClass[
|
|
2745
|
+
TaonBaseClass[Symbols_classNameStaticProperty] = className;
|
|
2764
2746
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
2765
2747
|
TaonBaseClass,
|
|
2766
2748
|
className,
|
|
@@ -2773,7 +2755,7 @@ class EndpointContext {
|
|
|
2773
2755
|
return classes;
|
|
2774
2756
|
};
|
|
2775
2757
|
this.cloneOptions = this.cloneOptions || {};
|
|
2776
|
-
this.isRunningInsideDocker =
|
|
2758
|
+
this.isRunningInsideDocker = UtilsOs_isRunningInDocker();
|
|
2777
2759
|
}
|
|
2778
2760
|
//#endregion
|
|
2779
2761
|
//#region methods & getters / init
|
|
@@ -2786,7 +2768,7 @@ class EndpointContext {
|
|
|
2786
2768
|
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
2787
2769
|
this.config = this.configFn({});
|
|
2788
2770
|
if (_.isObject(this.config.database)) {
|
|
2789
|
-
this.config.database =
|
|
2771
|
+
this.config.database = Models_DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
2790
2772
|
}
|
|
2791
2773
|
this.config.host = this.host === null ? void 0 : this.host;
|
|
2792
2774
|
if (this.cloneOptions.overrideHost &&
|
|
@@ -2898,31 +2880,31 @@ class EndpointContext {
|
|
|
2898
2880
|
this.config.subscribers = this.config.subscribers || {};
|
|
2899
2881
|
this.config.migrations = this.config.migrations || {};
|
|
2900
2882
|
this.config.entities = {
|
|
2901
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2883
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.ENTITY)),
|
|
2902
2884
|
...this.config.entities,
|
|
2903
2885
|
};
|
|
2904
2886
|
this.config.controllers = {
|
|
2905
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2887
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.CONTROLLER)),
|
|
2906
2888
|
...this.config.controllers,
|
|
2907
2889
|
};
|
|
2908
2890
|
this.config.providers = {
|
|
2909
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2891
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.PROVIDER)),
|
|
2910
2892
|
...this.config.providers,
|
|
2911
2893
|
};
|
|
2912
2894
|
this.config.middlewares = {
|
|
2913
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2895
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.MIDDLEWARE)),
|
|
2914
2896
|
...this.config.middlewares,
|
|
2915
2897
|
};
|
|
2916
2898
|
this.config.subscribers = {
|
|
2917
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2899
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.SUBSCRIBER)),
|
|
2918
2900
|
...this.config.subscribers,
|
|
2919
2901
|
};
|
|
2920
2902
|
this.config.repositories = {
|
|
2921
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2903
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.REPOSITORY)),
|
|
2922
2904
|
...this.config.repositories,
|
|
2923
2905
|
};
|
|
2924
2906
|
this.config.migrations = {
|
|
2925
|
-
...(await this.getRecrusiveClassesfromContextsObj(
|
|
2907
|
+
...(await this.getRecrusiveClassesfromContextsObj(Models_ClassType.MIGRATION)),
|
|
2926
2908
|
...this.config.migrations,
|
|
2927
2909
|
};
|
|
2928
2910
|
// console.log(this.config);
|
|
@@ -2933,37 +2915,37 @@ class EndpointContext {
|
|
|
2933
2915
|
classesInput: this.config.controllers,
|
|
2934
2916
|
config: this.config,
|
|
2935
2917
|
ctx: this,
|
|
2936
|
-
classType:
|
|
2918
|
+
classType: Models_ClassType.CONTROLLER,
|
|
2937
2919
|
});
|
|
2938
2920
|
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
2939
2921
|
classesInput: this.config.repositories,
|
|
2940
2922
|
config: this.config,
|
|
2941
2923
|
ctx: this,
|
|
2942
|
-
classType:
|
|
2924
|
+
classType: Models_ClassType.REPOSITORY,
|
|
2943
2925
|
});
|
|
2944
2926
|
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
2945
2927
|
classesInput: this.config.providers,
|
|
2946
2928
|
config: this.config,
|
|
2947
2929
|
ctx: this,
|
|
2948
|
-
classType:
|
|
2930
|
+
classType: Models_ClassType.PROVIDER,
|
|
2949
2931
|
});
|
|
2950
2932
|
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
2951
2933
|
classesInput: this.config.middlewares,
|
|
2952
2934
|
config: this.config,
|
|
2953
2935
|
ctx: this,
|
|
2954
|
-
classType:
|
|
2936
|
+
classType: Models_ClassType.MIDDLEWARE,
|
|
2955
2937
|
});
|
|
2956
2938
|
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
2957
2939
|
classesInput: this.config.subscribers,
|
|
2958
2940
|
config: this.config,
|
|
2959
2941
|
ctx: this,
|
|
2960
|
-
classType:
|
|
2942
|
+
classType: Models_ClassType.SUBSCRIBER,
|
|
2961
2943
|
});
|
|
2962
2944
|
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
2963
2945
|
classesInput: this.config.migrations,
|
|
2964
2946
|
config: this.config,
|
|
2965
2947
|
ctx: this,
|
|
2966
|
-
classType:
|
|
2948
|
+
classType: Models_ClassType.MIGRATION,
|
|
2967
2949
|
});
|
|
2968
2950
|
//#endregion
|
|
2969
2951
|
//#region prepare instances
|
|
@@ -2972,7 +2954,7 @@ class EndpointContext {
|
|
|
2972
2954
|
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
2973
2955
|
}
|
|
2974
2956
|
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
2975
|
-
await this.createInstances(this.config[
|
|
2957
|
+
await this.createInstances(this.config[Models_ClassTypeKey[classTypeName]], classTypeName);
|
|
2976
2958
|
}
|
|
2977
2959
|
//#endregion
|
|
2978
2960
|
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
@@ -3289,7 +3271,7 @@ class EndpointContext {
|
|
|
3289
3271
|
async getRecrusiveClassesfromContextsObj(classType) {
|
|
3290
3272
|
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
3291
3273
|
return arr.reduce((acc, c) => {
|
|
3292
|
-
acc[
|
|
3274
|
+
acc[ClassHelpers_getName(c)] = c;
|
|
3293
3275
|
return acc;
|
|
3294
3276
|
}, {});
|
|
3295
3277
|
}
|
|
@@ -3329,9 +3311,9 @@ class EndpointContext {
|
|
|
3329
3311
|
//#endregion
|
|
3330
3312
|
//#region methods & getters / inject
|
|
3331
3313
|
inject(ctor, options) {
|
|
3332
|
-
const className =
|
|
3314
|
+
const className = ClassHelpers_getName(ctor);
|
|
3333
3315
|
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
3334
|
-
if (this.isCLassType(
|
|
3316
|
+
if (this.isCLassType(Models_ClassType.REPOSITORY, ctor)) {
|
|
3335
3317
|
options.localInstance = true;
|
|
3336
3318
|
}
|
|
3337
3319
|
if (options?.localInstance) {
|
|
@@ -3341,7 +3323,7 @@ class EndpointContext {
|
|
|
3341
3323
|
// if (className === 'TaonBaseRepository') {
|
|
3342
3324
|
const entityFn = _.first(locaInstanceConstructorArgs);
|
|
3343
3325
|
const entity = entityFn && entityFn();
|
|
3344
|
-
entityName = (entity &&
|
|
3326
|
+
entityName = (entity && ClassHelpers_getName(entity)) || '';
|
|
3345
3327
|
// console.log(`entityName `, entityName);
|
|
3346
3328
|
// }
|
|
3347
3329
|
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
@@ -3351,12 +3333,12 @@ class EndpointContext {
|
|
|
3351
3333
|
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
3352
3334
|
if (existed) {
|
|
3353
3335
|
// console.log(
|
|
3354
|
-
// `EXISTED ${
|
|
3336
|
+
// `EXISTED ${ClassHelpers_getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3355
3337
|
// );
|
|
3356
3338
|
return existed;
|
|
3357
3339
|
}
|
|
3358
3340
|
// console.log(
|
|
3359
|
-
// `NEW ${
|
|
3341
|
+
// `NEW ${ClassHelpers_getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
3360
3342
|
// );
|
|
3361
3343
|
if (!ctxClassFn) {
|
|
3362
3344
|
throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
|
|
@@ -3382,11 +3364,11 @@ class EndpointContext {
|
|
|
3382
3364
|
*/
|
|
3383
3365
|
getInstanceBy(ctor) {
|
|
3384
3366
|
// if (!!this.__contextForControllerInstanceAccess) {
|
|
3385
|
-
// const className =
|
|
3386
|
-
// const allControllers = this.getClassFunByArr(
|
|
3367
|
+
// const className = ClassHelpers_getName(ctor);
|
|
3368
|
+
// const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3387
3369
|
// // TODO QUICK_FIX cache controllers
|
|
3388
3370
|
// for (const ctrl of allControllers) {
|
|
3389
|
-
// if (
|
|
3371
|
+
// if (ClassHelpers_getName(ctrl) === className) {
|
|
3390
3372
|
// // console.log('injecting from contextForControllerInstanceAcesss', className);
|
|
3391
3373
|
// return this.__contextForControllerInstanceAccess.inject(ctor, {
|
|
3392
3374
|
// localInstance: false,
|
|
@@ -3418,24 +3400,24 @@ class EndpointContext {
|
|
|
3418
3400
|
getClassFunBy(classType) {
|
|
3419
3401
|
this.checkIfContextInitialized();
|
|
3420
3402
|
switch (classType) {
|
|
3421
|
-
case
|
|
3403
|
+
case Models_ClassType.CONTROLLER:
|
|
3422
3404
|
return this.config.controllers;
|
|
3423
|
-
case
|
|
3405
|
+
case Models_ClassType.ENTITY:
|
|
3424
3406
|
return this.config.entities;
|
|
3425
|
-
case
|
|
3407
|
+
case Models_ClassType.PROVIDER:
|
|
3426
3408
|
return this.config.providers;
|
|
3427
|
-
case
|
|
3409
|
+
case Models_ClassType.MIDDLEWARE:
|
|
3428
3410
|
return this.config.middlewares;
|
|
3429
|
-
case
|
|
3411
|
+
case Models_ClassType.REPOSITORY:
|
|
3430
3412
|
return this.config.repositories;
|
|
3431
|
-
case
|
|
3413
|
+
case Models_ClassType.SUBSCRIBER:
|
|
3432
3414
|
return this.config.subscribers;
|
|
3433
|
-
case
|
|
3415
|
+
case Models_ClassType.MIGRATION:
|
|
3434
3416
|
return this.config.migrations;
|
|
3435
3417
|
}
|
|
3436
3418
|
}
|
|
3437
3419
|
isCLassType(classType, classFn) {
|
|
3438
|
-
return !!this.getClassFunBy(classType)[
|
|
3420
|
+
return !!this.getClassFunBy(classType)[ClassHelpers_getName(classFn)];
|
|
3439
3421
|
}
|
|
3440
3422
|
/**
|
|
3441
3423
|
* Only for injectable types
|
|
@@ -3443,14 +3425,14 @@ class EndpointContext {
|
|
|
3443
3425
|
*/
|
|
3444
3426
|
getClassFunByClassName(className) {
|
|
3445
3427
|
for (const classTypeName of this.allTypesfromContexts) {
|
|
3446
|
-
const classesForInjectableType = this.config[
|
|
3428
|
+
const classesForInjectableType = this.config[Models_ClassTypeKey[classTypeName]];
|
|
3447
3429
|
if (classesForInjectableType[className]) {
|
|
3448
3430
|
return classesForInjectableType[className];
|
|
3449
3431
|
}
|
|
3450
3432
|
}
|
|
3451
3433
|
}
|
|
3452
3434
|
getClassFunByClass(classFunction) {
|
|
3453
|
-
const className =
|
|
3435
|
+
const className = ClassHelpers_getName(classFunction);
|
|
3454
3436
|
return this.getClassFunByClassName(className);
|
|
3455
3437
|
}
|
|
3456
3438
|
getClassFunByArr(classType) {
|
|
@@ -3469,11 +3451,11 @@ class EndpointContext {
|
|
|
3469
3451
|
]) {
|
|
3470
3452
|
const instance = DITaonContainer.resolve(classFn);
|
|
3471
3453
|
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
3472
|
-
const className =
|
|
3454
|
+
const className = ClassHelpers_getName(classFn);
|
|
3473
3455
|
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
3474
3456
|
classInstancesByNameObj[className] = instance;
|
|
3475
3457
|
// update config
|
|
3476
|
-
this.config[
|
|
3458
|
+
this.config[Models_ClassTypeKey[classType]][className] = classFn;
|
|
3477
3459
|
this.objWithClassesInstancesArr[classType].push(instance);
|
|
3478
3460
|
this.allClassesInstances[className] = instance;
|
|
3479
3461
|
}
|
|
@@ -3494,12 +3476,12 @@ class EndpointContext {
|
|
|
3494
3476
|
/* */
|
|
3495
3477
|
/* */
|
|
3496
3478
|
for (const classTypeName of [
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3479
|
+
Models_ClassType.MIDDLEWARE,
|
|
3480
|
+
Models_ClassType.PROVIDER,
|
|
3481
|
+
Models_ClassType.REPOSITORY,
|
|
3482
|
+
Models_ClassType.CONTROLLER,
|
|
3483
|
+
Models_ClassType.ENTITY,
|
|
3484
|
+
Models_ClassType.MIGRATION,
|
|
3503
3485
|
]) {
|
|
3504
3486
|
//#region init class static _ property
|
|
3505
3487
|
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
@@ -3510,11 +3492,11 @@ class EndpointContext {
|
|
|
3510
3492
|
//#endregion
|
|
3511
3493
|
}
|
|
3512
3494
|
for (const classTypeName of [
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3495
|
+
Models_ClassType.MIDDLEWARE,
|
|
3496
|
+
Models_ClassType.PROVIDER,
|
|
3497
|
+
Models_ClassType.REPOSITORY,
|
|
3498
|
+
Models_ClassType.CONTROLLER,
|
|
3499
|
+
Models_ClassType.MIGRATION,
|
|
3518
3500
|
]) {
|
|
3519
3501
|
//#region init providers, repositories _ property
|
|
3520
3502
|
// Helpers.taskStarted(
|
|
@@ -3534,7 +3516,7 @@ class EndpointContext {
|
|
|
3534
3516
|
//#endregion
|
|
3535
3517
|
//#region methods & getters / is active on
|
|
3536
3518
|
isActiveOn(classInstance) {
|
|
3537
|
-
let contextRef = classInstance[
|
|
3519
|
+
let contextRef = classInstance[Symbols_ctxInClassOrClassObj];
|
|
3538
3520
|
return this === contextRef;
|
|
3539
3521
|
}
|
|
3540
3522
|
//#endregion
|
|
@@ -3897,20 +3879,20 @@ class EndpointContext {
|
|
|
3897
3879
|
const parentsCalculatedPath = _.slice(rawConfigs, 1)
|
|
3898
3880
|
.reverse()
|
|
3899
3881
|
.map(bc => {
|
|
3900
|
-
if (
|
|
3882
|
+
if (TaonHelpers_isGoodPath(bc.path)) {
|
|
3901
3883
|
return bc.path;
|
|
3902
3884
|
}
|
|
3903
3885
|
return bc.className;
|
|
3904
3886
|
})
|
|
3905
3887
|
.join('/');
|
|
3906
3888
|
const contextNameForCommunication = this.contextNameForCommunication;
|
|
3907
|
-
if (
|
|
3889
|
+
if (TaonHelpers_isGoodPath(classConfig.path)) {
|
|
3908
3890
|
classConfig.calculatedPath = classConfig.path;
|
|
3909
3891
|
}
|
|
3910
3892
|
else {
|
|
3911
3893
|
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
3912
3894
|
`/${apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
3913
|
-
`${
|
|
3895
|
+
`${ClassHelpers_getName(controllerClassFn)}`)
|
|
3914
3896
|
.replace(/\/\//g, '/')
|
|
3915
3897
|
.split('/')
|
|
3916
3898
|
.reduce((acc, bc) => {
|
|
@@ -3943,7 +3925,7 @@ class EndpointContext {
|
|
|
3943
3925
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3944
3926
|
return;
|
|
3945
3927
|
}
|
|
3946
|
-
const allControllers = this.getClassFunByArr(
|
|
3928
|
+
const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3947
3929
|
for (const controllerClassFn of allControllers) {
|
|
3948
3930
|
const instance = this.getInstanceBy(controllerClassFn);
|
|
3949
3931
|
if (_.isFunction(instance.afterAllCtxInited)) {
|
|
@@ -3955,21 +3937,21 @@ class EndpointContext {
|
|
|
3955
3937
|
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
3956
3938
|
return;
|
|
3957
3939
|
}
|
|
3958
|
-
const allControllers = this.getClassFunByArr(
|
|
3940
|
+
const allControllers = this.getClassFunByArr(Models_ClassType.CONTROLLER);
|
|
3959
3941
|
// debugger
|
|
3960
3942
|
// console.log('allControllers', allControllers);
|
|
3961
3943
|
for (const controllerClassFn of allControllers) {
|
|
3962
|
-
// console.log(
|
|
3963
|
-
// const controllerName =
|
|
3944
|
+
// console.log(ClassHelpers_getClassConfig(controllerClassFn));
|
|
3945
|
+
// const controllerName = ClassHelpers_getName(controllerClassFn);
|
|
3964
3946
|
// console.log(
|
|
3965
3947
|
// `for ${controllerName}`,
|
|
3966
|
-
//
|
|
3948
|
+
// ClassHelpers_getClassConfig(controllerClassFn),
|
|
3967
3949
|
// );
|
|
3968
|
-
controllerClassFn[
|
|
3969
|
-
|
|
3970
|
-
const rawConfigs =
|
|
3950
|
+
controllerClassFn[Symbols_classMethodsNames] =
|
|
3951
|
+
ClassHelpers_getMethodsNames(controllerClassFn);
|
|
3952
|
+
const rawConfigs = ClassHelpers_getControllerConfigs(controllerClassFn);
|
|
3971
3953
|
// console.log(controllerName, { rawConfigs });
|
|
3972
|
-
// console.log(`Class config for ${
|
|
3954
|
+
// console.log(`Class config for ${ClassHelpers_getName(controllerClassFn)}`, configs)
|
|
3973
3955
|
const classConfig = rawConfigs[0];
|
|
3974
3956
|
this.updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn);
|
|
3975
3957
|
this.mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn);
|
|
@@ -3980,7 +3962,7 @@ class EndpointContext {
|
|
|
3980
3962
|
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
3981
3963
|
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
3982
3964
|
className(middlewareClass) {
|
|
3983
|
-
return
|
|
3965
|
+
return ClassHelpers_getName(controllerClassFn);
|
|
3984
3966
|
},
|
|
3985
3967
|
});
|
|
3986
3968
|
}
|
|
@@ -4007,7 +3989,7 @@ class EndpointContext {
|
|
|
4007
3989
|
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
4008
3990
|
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
4009
3991
|
className(middlewareClass) {
|
|
4010
|
-
return
|
|
3992
|
+
return ClassHelpers_getName(controllerClassFn);
|
|
4011
3993
|
},
|
|
4012
3994
|
});
|
|
4013
3995
|
}
|
|
@@ -4030,7 +4012,7 @@ class EndpointContext {
|
|
|
4030
4012
|
: '';
|
|
4031
4013
|
const expressPath = methodConfig.global
|
|
4032
4014
|
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
4033
|
-
:
|
|
4015
|
+
: TaonHelpers_getExpressPath(classConfig, methodConfig);
|
|
4034
4016
|
//#endregion
|
|
4035
4017
|
//#region init server
|
|
4036
4018
|
// console.log({ expressPath });
|
|
@@ -4057,7 +4039,7 @@ class EndpointContext {
|
|
|
4057
4039
|
if (shouldInitClient) {
|
|
4058
4040
|
// console.log(
|
|
4059
4041
|
// 'initClient',
|
|
4060
|
-
//
|
|
4042
|
+
// ClassHelpers_getFullInternalName(controllerClassFn),
|
|
4061
4043
|
// type,
|
|
4062
4044
|
// methodConfig,
|
|
4063
4045
|
// expressPath,
|
|
@@ -4131,12 +4113,12 @@ class EndpointContext {
|
|
|
4131
4113
|
//#endregion
|
|
4132
4114
|
//#region methods & getters / init middlewares
|
|
4133
4115
|
async initCustomClientMiddlewares() {
|
|
4134
|
-
const middlewares = this.getClassesInstancesArrBy(
|
|
4116
|
+
const middlewares = this.getClassesInstancesArrBy(Models_ClassType.MIDDLEWARE)
|
|
4135
4117
|
.map(f => f)
|
|
4136
4118
|
.filter(f => _.isFunction(f.interceptClient));
|
|
4137
4119
|
middlewares.forEach(middlewareInstanceName => {
|
|
4138
4120
|
const contextName = this.contextName;
|
|
4139
|
-
const interceptorName = `${contextName}-${
|
|
4121
|
+
const interceptorName = `${contextName}-${ClassHelpers_getName(middlewareInstanceName)}`;
|
|
4140
4122
|
Resource.request.interceptors.set(interceptorName, {
|
|
4141
4123
|
intercept: ({ req, next }) => {
|
|
4142
4124
|
const url = new URL(req.url);
|
|
@@ -4308,7 +4290,7 @@ class EndpointContext {
|
|
|
4308
4290
|
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
4309
4291
|
if (middlewareInstance &&
|
|
4310
4292
|
_.isFunction(middlewareInstance.interceptServerMethod)) {
|
|
4311
|
-
const middlewareFn =
|
|
4293
|
+
const middlewareFn = ClassHelpers_asyncHandler(async (req, res, next) => {
|
|
4312
4294
|
await middlewareInstance.interceptServerMethod({
|
|
4313
4295
|
req,
|
|
4314
4296
|
res,
|
|
@@ -4649,7 +4631,7 @@ class EndpointContext {
|
|
|
4649
4631
|
.map(f => this.getInstanceBy(f))
|
|
4650
4632
|
.filter(f => _.isFunction(f.interceptClientMethod));
|
|
4651
4633
|
middlewaresInstances.forEach(instance => {
|
|
4652
|
-
const middlewareName =
|
|
4634
|
+
const middlewareName = ClassHelpers_getName(instance);
|
|
4653
4635
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
4654
4636
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
4655
4637
|
Resource.request.methodsInterceptors.set(interceptorKey, {
|
|
@@ -4681,14 +4663,14 @@ class EndpointContext {
|
|
|
4681
4663
|
target.prototype[methodConfig.methodName] = function (...args) {
|
|
4682
4664
|
const received = new Promise(async (resolve, reject) => {
|
|
4683
4665
|
const headers = {};
|
|
4684
|
-
const { request, response } =
|
|
4666
|
+
const { request, response } = TaonHelpers_websqlMocks(headers);
|
|
4685
4667
|
//#region @browser
|
|
4686
|
-
ipcRenderer.once(
|
|
4668
|
+
ipcRenderer.once(TaonHelpers_ipcKeyNameResponse(target, methodConfig, expressPath), (event, responseData) => {
|
|
4687
4669
|
let res = responseData;
|
|
4688
4670
|
console.log({ responseData });
|
|
4689
4671
|
try {
|
|
4690
4672
|
const body = res;
|
|
4691
|
-
res = new
|
|
4673
|
+
res = new Models_HttpResponse({
|
|
4692
4674
|
body: void 0,
|
|
4693
4675
|
isArray: void 0,
|
|
4694
4676
|
method: methodConfig.type,
|
|
@@ -4704,7 +4686,7 @@ class EndpointContext {
|
|
|
4704
4686
|
reject(error);
|
|
4705
4687
|
}
|
|
4706
4688
|
});
|
|
4707
|
-
ipcRenderer.send(
|
|
4689
|
+
ipcRenderer.send(TaonHelpers_ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
4708
4690
|
//#endregion
|
|
4709
4691
|
});
|
|
4710
4692
|
received['observable'] = from(received);
|
|
@@ -4875,34 +4857,34 @@ class EndpointContext {
|
|
|
4875
4857
|
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
4876
4858
|
// const productionMode = FrameworkContext.isProductionMode;
|
|
4877
4859
|
//#region resolve frontend parameters
|
|
4878
|
-
if (!storage[
|
|
4879
|
-
storage[
|
|
4880
|
-
if (!storage[
|
|
4881
|
-
storage[
|
|
4882
|
-
const endpoints = storage[
|
|
4860
|
+
if (!storage[Symbols_old.ENDPOINT_META_CONFIG])
|
|
4861
|
+
storage[Symbols_old.ENDPOINT_META_CONFIG] = {};
|
|
4862
|
+
if (!storage[Symbols_old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
4863
|
+
storage[Symbols_old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4864
|
+
const endpoints = storage[Symbols_old.ENDPOINT_META_CONFIG];
|
|
4883
4865
|
let rest;
|
|
4884
4866
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4885
4867
|
let headers = {};
|
|
4886
4868
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4887
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4869
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4888
4870
|
'Content-Type': methodConfig.contentType,
|
|
4889
4871
|
Accept: methodConfig.contentType,
|
|
4890
4872
|
}));
|
|
4891
4873
|
}
|
|
4892
4874
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4893
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4875
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4894
4876
|
'Content-Type': methodConfig.contentType,
|
|
4895
4877
|
Accept: methodConfig.contentType,
|
|
4896
4878
|
responsetypeaxios: methodConfig.responseType,
|
|
4897
4879
|
}));
|
|
4898
4880
|
}
|
|
4899
4881
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4900
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4882
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, RestHeaders.from({
|
|
4901
4883
|
responsetypeaxios: methodConfig.responseType,
|
|
4902
4884
|
}));
|
|
4903
4885
|
}
|
|
4904
4886
|
else {
|
|
4905
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4887
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, Symbols_old.MAPPING_CONFIG_HEADER, Symbols_old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
4906
4888
|
}
|
|
4907
4889
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4908
4890
|
}
|
|
@@ -4935,23 +4917,23 @@ class EndpointContext {
|
|
|
4935
4917
|
}
|
|
4936
4918
|
if (currentParam.paramType === 'Query') {
|
|
4937
4919
|
if (currentParam.paramName) {
|
|
4938
|
-
const mapping =
|
|
4920
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4939
4921
|
if (mapping) {
|
|
4940
|
-
rest.headers.set(`${
|
|
4922
|
+
rest.headers.set(`${Symbols_old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4941
4923
|
}
|
|
4942
4924
|
queryParams[currentParam.paramName] = param;
|
|
4943
4925
|
}
|
|
4944
4926
|
else {
|
|
4945
|
-
const mapping =
|
|
4927
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4946
4928
|
if (mapping) {
|
|
4947
|
-
rest.headers.set(
|
|
4929
|
+
rest.headers.set(Symbols_old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4948
4930
|
}
|
|
4949
4931
|
queryParams = _.cloneDeep(param);
|
|
4950
4932
|
}
|
|
4951
4933
|
}
|
|
4952
4934
|
if (currentParam.paramType === 'Header') {
|
|
4953
4935
|
if (currentParam.paramName) {
|
|
4954
|
-
if (currentParam.paramName ===
|
|
4936
|
+
if (currentParam.paramName === Symbols_old.MDC_KEY) {
|
|
4955
4937
|
// parese MDC
|
|
4956
4938
|
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4957
4939
|
}
|
|
@@ -4970,7 +4952,7 @@ class EndpointContext {
|
|
|
4970
4952
|
}
|
|
4971
4953
|
if (currentParam.paramType === 'Body') {
|
|
4972
4954
|
if (currentParam.paramName) {
|
|
4973
|
-
if (
|
|
4955
|
+
if (ClassHelpers_getName(bodyObject) === 'FormData') {
|
|
4974
4956
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
4975
4957
|
Use this:
|
|
4976
4958
|
// ...
|
|
@@ -4983,35 +4965,35 @@ instead
|
|
|
4983
4965
|
// ...
|
|
4984
4966
|
`);
|
|
4985
4967
|
}
|
|
4986
|
-
const mapping =
|
|
4968
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4987
4969
|
if (mapping) {
|
|
4988
|
-
rest.headers.set(`${
|
|
4970
|
+
rest.headers.set(`${Symbols_old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4989
4971
|
}
|
|
4990
4972
|
bodyObject[currentParam.paramName] = param;
|
|
4991
4973
|
}
|
|
4992
4974
|
else {
|
|
4993
|
-
const mapping =
|
|
4975
|
+
const mapping = Mapping_decode(param, !ctx.isProductionMode);
|
|
4994
4976
|
if (mapping) {
|
|
4995
|
-
rest.headers.set(
|
|
4977
|
+
rest.headers.set(Symbols_old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
4996
4978
|
}
|
|
4997
4979
|
bodyObject = param;
|
|
4998
4980
|
}
|
|
4999
4981
|
}
|
|
5000
4982
|
});
|
|
5001
4983
|
if (typeof bodyObject === 'object' &&
|
|
5002
|
-
|
|
4984
|
+
ClassHelpers_getName(bodyObject) !== 'FormData') {
|
|
5003
4985
|
let circuralFromItem = [];
|
|
5004
4986
|
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
5005
4987
|
circuralFromItem = circs;
|
|
5006
4988
|
}));
|
|
5007
|
-
rest.headers.set(
|
|
4989
|
+
rest.headers.set(Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
5008
4990
|
}
|
|
5009
4991
|
if (typeof queryParams === 'object') {
|
|
5010
4992
|
let circuralFromQueryParams = [];
|
|
5011
4993
|
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
5012
4994
|
circuralFromQueryParams = circs;
|
|
5013
4995
|
}));
|
|
5014
|
-
rest.headers.set(
|
|
4996
|
+
rest.headers.set(Symbols_old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
5015
4997
|
}
|
|
5016
4998
|
//#endregion
|
|
5017
4999
|
const httpResultObj = {
|
|
@@ -5077,7 +5059,7 @@ class TaonAdminService {
|
|
|
5077
5059
|
|
|
5078
5060
|
class ContextsEndpointStorage {
|
|
5079
5061
|
constructor() {
|
|
5080
|
-
this.SPECIAL_APP_READY_MESSAGE =
|
|
5062
|
+
this.SPECIAL_APP_READY_MESSAGE = CoreModels_SPECIAL_APP_READY_MESSAGE;
|
|
5081
5063
|
this.taonEndpointContexts = new Map();
|
|
5082
5064
|
// Private constructor to prevent direct instantiation
|
|
5083
5065
|
}
|
|
@@ -5186,9 +5168,9 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5186
5168
|
return classFun;
|
|
5187
5169
|
//#region old
|
|
5188
5170
|
// TODO hmmmm for now context for controller inside api service
|
|
5189
|
-
// const allContexts = Object.values(classFun[
|
|
5171
|
+
// const allContexts = Object.values(classFun[Symbols_orignalClassClonesObj] || {}).map(classFn => {
|
|
5190
5172
|
// return {
|
|
5191
|
-
// ctx: classFn[
|
|
5173
|
+
// ctx: classFn[Symbols_ctxInClassOrClassObj] as EndpointContext,
|
|
5192
5174
|
// classFn,
|
|
5193
5175
|
// }
|
|
5194
5176
|
// })
|
|
@@ -5208,7 +5190,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5208
5190
|
return await new Promise(async (resolve, reject) => {
|
|
5209
5191
|
//#region init in set timeout
|
|
5210
5192
|
setTimeout(async () => {
|
|
5211
|
-
if (
|
|
5193
|
+
if (UtilsOs_isRunningInDocker()) {
|
|
5212
5194
|
const activeContext = config?.activeContext || null;
|
|
5213
5195
|
if (_.isString(activeContext) &&
|
|
5214
5196
|
activeContext !== '' &&
|
|
@@ -5245,7 +5227,7 @@ const createContextFn = (configFn, cloneOptions) => {
|
|
|
5245
5227
|
keepWebsqlDbDataAfterReload =
|
|
5246
5228
|
TaonAdminService.Instance?.keepWebsqlDbDataAfterReload;
|
|
5247
5229
|
if (keepWebsqlDbDataAfterReload) {
|
|
5248
|
-
!
|
|
5230
|
+
!UtilsOs_isRunningInCliMode() &&
|
|
5249
5231
|
Helpers.info(`[taon] Keeping websql data after reload ` +
|
|
5250
5232
|
`(context=${endpointContextRef.contextName}).`);
|
|
5251
5233
|
}
|
|
@@ -5323,7 +5305,7 @@ const inject = (entity) => {
|
|
|
5323
5305
|
return () => false;
|
|
5324
5306
|
}
|
|
5325
5307
|
const ctor = entity();
|
|
5326
|
-
const contextFromClass = ctor[
|
|
5308
|
+
const contextFromClass = ctor[Symbols_ctxInClassOrClassObj];
|
|
5327
5309
|
const resultContext = contextFromClass;
|
|
5328
5310
|
if (resultContext) {
|
|
5329
5311
|
let instance = resultContext.inject(ctor, {
|
|
@@ -5336,7 +5318,7 @@ const inject = (entity) => {
|
|
|
5336
5318
|
if (propName === 'getOriginalConstructor') {
|
|
5337
5319
|
return () => instance.constructor;
|
|
5338
5320
|
}
|
|
5339
|
-
const methods = ctor[
|
|
5321
|
+
const methods = ctor[Symbols_classMethodsNames] || [];
|
|
5340
5322
|
const isMethods = methods.includes(propName);
|
|
5341
5323
|
const methodOrProperty = isMethods
|
|
5342
5324
|
? instance[propName].bind(instance)
|
|
@@ -5374,7 +5356,7 @@ const inject = (entity) => {
|
|
|
5374
5356
|
// const subscriberClassFN: typeof TaonBaseClass =
|
|
5375
5357
|
// subscriberClassResolveFn() as any;
|
|
5376
5358
|
// const ctx = subscriberClassFN[
|
|
5377
|
-
//
|
|
5359
|
+
// Symbols_ctxInClassOrClassObj
|
|
5378
5360
|
// ] as EndpointContext;
|
|
5379
5361
|
// if (!ctx) {
|
|
5380
5362
|
// throw new Error(
|
|
@@ -5415,12 +5397,12 @@ const getTransformFunction = (target) => {
|
|
|
5415
5397
|
if (!target) {
|
|
5416
5398
|
return;
|
|
5417
5399
|
}
|
|
5418
|
-
// const className =
|
|
5400
|
+
// const className = ClassHelpers_getName(target)
|
|
5419
5401
|
// target = ClassHelpers.getBy(className);
|
|
5420
5402
|
if (!target) {
|
|
5421
5403
|
return void 0;
|
|
5422
5404
|
}
|
|
5423
|
-
const configs =
|
|
5405
|
+
const configs = ClassHelpers_getControllerConfigs(target);
|
|
5424
5406
|
// console.log(`CONFIGS TO CHECK`, configs)
|
|
5425
5407
|
const functions = configs
|
|
5426
5408
|
.map(c => {
|
|
@@ -5445,13 +5427,13 @@ const getTransformFunction = (target) => {
|
|
|
5445
5427
|
* @deprecated
|
|
5446
5428
|
*/
|
|
5447
5429
|
const singleTransform = (json) => {
|
|
5448
|
-
let ptarget =
|
|
5430
|
+
let ptarget = ClassHelpers_getClassFnFromObject(json);
|
|
5449
5431
|
let pbrowserTransformFn = getTransformFunction(ptarget);
|
|
5450
5432
|
if (pbrowserTransformFn) {
|
|
5451
5433
|
const newValue = pbrowserTransformFn(json);
|
|
5452
5434
|
if (!_.isObject(newValue)) {
|
|
5453
5435
|
console.error(`Please return object in transform function for class: ` +
|
|
5454
|
-
`${
|
|
5436
|
+
`${ClassHelpers_getName(json)}`);
|
|
5455
5437
|
}
|
|
5456
5438
|
else {
|
|
5457
5439
|
json = newValue;
|
|
@@ -5529,7 +5511,7 @@ class EntityProcess {
|
|
|
5529
5511
|
//#region set headers
|
|
5530
5512
|
setHeaders() {
|
|
5531
5513
|
const { include } = { include: [] };
|
|
5532
|
-
const className =
|
|
5514
|
+
const className = ClassHelpers_getName(this.data);
|
|
5533
5515
|
const doNothing = _.isNil(this.data) ||
|
|
5534
5516
|
[
|
|
5535
5517
|
'Object',
|
|
@@ -5542,10 +5524,10 @@ class EntityProcess {
|
|
|
5542
5524
|
breadthWalk: true,
|
|
5543
5525
|
include,
|
|
5544
5526
|
});
|
|
5545
|
-
this.entityMapping =
|
|
5546
|
-
this.response.set(
|
|
5527
|
+
this.entityMapping = Mapping_decode(cleaned, !this.advancedManipulation);
|
|
5528
|
+
this.response.set(Symbols_old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
|
|
5547
5529
|
if (this.advancedManipulation) {
|
|
5548
|
-
this.response.set(
|
|
5530
|
+
this.response.set(Symbols_old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
|
|
5549
5531
|
}
|
|
5550
5532
|
}
|
|
5551
5533
|
}
|
|
@@ -5562,10 +5544,10 @@ class EntityProcess {
|
|
|
5562
5544
|
_.set(toSend, lodashPath, null);
|
|
5563
5545
|
}
|
|
5564
5546
|
else {
|
|
5565
|
-
const fun = getTransformFunction(
|
|
5547
|
+
const fun = getTransformFunction(ClassHelpers_getClassFnFromObject(value));
|
|
5566
5548
|
if (_.isFunction(fun)) {
|
|
5567
5549
|
_.set(toSend, `${lodashPath}.${browserKey}`, value[browserKey]);
|
|
5568
|
-
const indexProp =
|
|
5550
|
+
const indexProp = ClassHelpers_getUniqueKey(value);
|
|
5569
5551
|
_.set(toSend, `${lodashPath}.${indexProp}`, value[indexProp]);
|
|
5570
5552
|
// skipObject()
|
|
5571
5553
|
}
|
|
@@ -5575,7 +5557,7 @@ class EntityProcess {
|
|
|
5575
5557
|
}
|
|
5576
5558
|
}, { checkCircural: true, breadthWalk: true, include });
|
|
5577
5559
|
if (!_.isArray(this.data)) {
|
|
5578
|
-
let funParent = getTransformFunction(
|
|
5560
|
+
let funParent = getTransformFunction(ClassHelpers_getClassFnFromObject(this.data));
|
|
5579
5561
|
// if (this.mdc && this.mdc.exclude && this.mdc.exclude.length > 0) {
|
|
5580
5562
|
// console.log(`funParent !!! have fun? ${!!funParent} `)
|
|
5581
5563
|
// }
|
|
@@ -5589,12 +5571,12 @@ class EntityProcess {
|
|
|
5589
5571
|
const v = this.data[prop];
|
|
5590
5572
|
if (!((include.length > 0 && !include.includes(prop)) ||
|
|
5591
5573
|
(exclude.length > 0 && exclude.includes(prop)))) {
|
|
5592
|
-
if (
|
|
5593
|
-
_.isFunction(getTransformFunction(
|
|
5574
|
+
if (ClassHelpers_isContextClassObject(v) &&
|
|
5575
|
+
_.isFunction(getTransformFunction(ClassHelpers_getClassFnFromObject(v)))) {
|
|
5594
5576
|
toSend[prop] = {
|
|
5595
5577
|
[browserKey]: v[browserKey],
|
|
5596
5578
|
};
|
|
5597
|
-
const indexProp =
|
|
5579
|
+
const indexProp = ClassHelpers_getUniqueKey(v);
|
|
5598
5580
|
toSend[prop][indexProp] = this.data[prop][indexProp];
|
|
5599
5581
|
for (const key in v) {
|
|
5600
5582
|
if (_.isObject(v) &&
|
|
@@ -5663,7 +5645,7 @@ class TaonBaseClass {
|
|
|
5663
5645
|
console.log(overrideObjOrFn);
|
|
5664
5646
|
throw new Error('String is not supported as .clone() method argument');
|
|
5665
5647
|
}
|
|
5666
|
-
const classFn =
|
|
5648
|
+
const classFn = ClassHelpers_getClassFnFromObject(this);
|
|
5667
5649
|
if (_.isFunction(overrideObjOrFn)) {
|
|
5668
5650
|
// console.log('clone with fn');
|
|
5669
5651
|
const oldValues = (_.cloneDeep(this) || {});
|
|
@@ -5782,12 +5764,12 @@ function TaonEntity(options) {
|
|
|
5782
5764
|
return function (constructor) {
|
|
5783
5765
|
options = options || {};
|
|
5784
5766
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5785
|
-
|
|
5786
|
-
|
|
5767
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
5768
|
+
Mapping_DefaultModelWithMapping(options?.defaultModelValues || {}, _.merge(options?.defaultModelMapping || {}, (options?.defaultModelMappingDeep || {})))(constructor);
|
|
5787
5769
|
// TODO when entit metadata generator read use this
|
|
5788
|
-
|
|
5789
|
-
Reflect.defineMetadata(
|
|
5790
|
-
Reflect.defineMetadata(
|
|
5770
|
+
Mapping_DefaultModelWithMapping(void 0, {})(constructor);
|
|
5771
|
+
Reflect.defineMetadata(Symbols_metadata.options.entity, options, constructor);
|
|
5772
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5791
5773
|
/* */
|
|
5792
5774
|
/* */
|
|
5793
5775
|
CLASS.setName(constructor, options?.className); // TODO QUICK_FIX for ng2-rest
|
|
@@ -5812,9 +5794,9 @@ TAON_GLOBAL_STATE = __decorate([
|
|
|
5812
5794
|
*/
|
|
5813
5795
|
function TaonController(options) {
|
|
5814
5796
|
return function (constructor) {
|
|
5815
|
-
|
|
5816
|
-
Reflect.defineMetadata(
|
|
5817
|
-
const cfg =
|
|
5797
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
5798
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5799
|
+
const cfg = ClassHelpers_ensureClassConfig(constructor);
|
|
5818
5800
|
options = options || {};
|
|
5819
5801
|
cfg.className = options.className || constructor.name;
|
|
5820
5802
|
cfg.path = options.path || '';
|
|
@@ -5824,7 +5806,7 @@ function TaonController(options) {
|
|
|
5824
5806
|
}
|
|
5825
5807
|
|
|
5826
5808
|
const metaReq = (method, path, target, propertyKey, descriptor, pathOrOptions, pathIsGlobal) => {
|
|
5827
|
-
const methodConfig =
|
|
5809
|
+
const methodConfig = ClassHelpers_ensureMethodConfig(target, propertyKey);
|
|
5828
5810
|
let options;
|
|
5829
5811
|
if (typeof pathOrOptions === 'object') {
|
|
5830
5812
|
options = pathOrOptions;
|
|
@@ -5875,7 +5857,7 @@ function GET(pathOrOptions, pathIsGlobal = false) {
|
|
|
5875
5857
|
* ...
|
|
5876
5858
|
* // in your taon controller
|
|
5877
5859
|
* ..Taon.Http.HTML()
|
|
5878
|
-
* sendHtmlDummyWebsite():
|
|
5860
|
+
* sendHtmlDummyWebsite(): Taon_ResponseHtml {
|
|
5879
5861
|
* return `
|
|
5880
5862
|
<html>
|
|
5881
5863
|
<head>
|
|
@@ -5925,7 +5907,7 @@ function DELETE(pathOrOptions, pathIsGlobal = false) {
|
|
|
5925
5907
|
}
|
|
5926
5908
|
|
|
5927
5909
|
function metaParam(param, name, expire, defaultValue = undefined, target, propertyKey, parameterIndex) {
|
|
5928
|
-
const methodCfg =
|
|
5910
|
+
const methodCfg = ClassHelpers_ensureMethodConfig(target, propertyKey);
|
|
5929
5911
|
const nameKey = name ? name : param;
|
|
5930
5912
|
// const key = name || `${param}_${parameterIndex}`;
|
|
5931
5913
|
methodCfg.parameters[nameKey] = {
|
|
@@ -5971,9 +5953,9 @@ function Body(name) {
|
|
|
5971
5953
|
*/
|
|
5972
5954
|
function TaonMiddleware(options) {
|
|
5973
5955
|
return function (constructor) {
|
|
5974
|
-
Reflect.defineMetadata(
|
|
5975
|
-
Reflect.defineMetadata(
|
|
5976
|
-
|
|
5956
|
+
Reflect.defineMetadata(Symbols_metadata.options.provider, options, constructor);
|
|
5957
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
5958
|
+
ClassHelpers_setName(constructor, options?.className || constructor.name);
|
|
5977
5959
|
};
|
|
5978
5960
|
}
|
|
5979
5961
|
class TaonMiddlewareOptions extends DecoratorAbstractOpt {
|
|
@@ -5995,7 +5977,7 @@ class TaonBaseInjector {
|
|
|
5995
5977
|
* Current endpoint context
|
|
5996
5978
|
*/
|
|
5997
5979
|
get __endpoint_context__() {
|
|
5998
|
-
return this[
|
|
5980
|
+
return this[Symbols_ctxInClassOrClassObj];
|
|
5999
5981
|
}
|
|
6000
5982
|
/**
|
|
6001
5983
|
* get current endpoint context
|
|
@@ -6024,7 +6006,7 @@ class TaonBaseInjector {
|
|
|
6024
6006
|
localInstance: true,
|
|
6025
6007
|
locaInstanceConstructorArgs: [
|
|
6026
6008
|
() => {
|
|
6027
|
-
const classToProcess = this.ctx.allClassesInstances[
|
|
6009
|
+
const classToProcess = this.ctx.allClassesInstances[ClassHelpers_getName(cutomRepositoryClass)];
|
|
6028
6010
|
return classToProcess.entityClassResolveFn();
|
|
6029
6011
|
},
|
|
6030
6012
|
],
|
|
@@ -6099,7 +6081,7 @@ class TaonBaseInjector {
|
|
|
6099
6081
|
const contextClassInstance = this;
|
|
6100
6082
|
return new Proxy({}, {
|
|
6101
6083
|
get: (__, propName) => {
|
|
6102
|
-
const contextFromClass = ctor && ctor[
|
|
6084
|
+
const contextFromClass = ctor && ctor[Symbols_ctxInClassOrClassObj];
|
|
6103
6085
|
const resultContext = contextFromClass
|
|
6104
6086
|
? contextFromClass
|
|
6105
6087
|
: this.__endpoint_context__;
|
|
@@ -6114,17 +6096,17 @@ class TaonBaseInjector {
|
|
|
6114
6096
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6115
6097
|
});
|
|
6116
6098
|
if (!instance) {
|
|
6117
|
-
throw new Error(`Not able to inject "${
|
|
6118
|
-
`property "${propName?.toString()}" on class "${
|
|
6099
|
+
throw new Error(`Not able to inject "${ClassHelpers_getName(ctor) || ctor.name}" inside ` +
|
|
6100
|
+
`property "${propName?.toString()}" on class "${ClassHelpers_getName(this)}".
|
|
6119
6101
|
|
|
6120
|
-
Please add "${
|
|
6102
|
+
Please add "${ClassHelpers_getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6121
6103
|
|
|
6122
6104
|
`);
|
|
6123
6105
|
}
|
|
6124
6106
|
const result = typeof instance[propName] === 'function'
|
|
6125
6107
|
? instance[propName].bind(instance)
|
|
6126
6108
|
: instance[propName];
|
|
6127
|
-
// console.log(`Accessing injected "${propName?.toString()}" from "${
|
|
6109
|
+
// console.log(`Accessing injected "${propName?.toString()}" from "${ClassHelpers_getName(ctor) || ctor.name}"`,result)
|
|
6128
6110
|
return result;
|
|
6129
6111
|
}
|
|
6130
6112
|
//#region @browser
|
|
@@ -6132,7 +6114,7 @@ class TaonBaseInjector {
|
|
|
6132
6114
|
//#endregion
|
|
6133
6115
|
},
|
|
6134
6116
|
set: (__, propName, value) => {
|
|
6135
|
-
const contextFromClass = ctor && ctor[
|
|
6117
|
+
const contextFromClass = ctor && ctor[Symbols_ctxInClassOrClassObj];
|
|
6136
6118
|
const resultContext = contextFromClass
|
|
6137
6119
|
? contextFromClass
|
|
6138
6120
|
: this.__endpoint_context__;
|
|
@@ -6147,11 +6129,11 @@ class TaonBaseInjector {
|
|
|
6147
6129
|
parentInstanceThatWillGetInjectedStuff: this,
|
|
6148
6130
|
});
|
|
6149
6131
|
if (!instance) {
|
|
6150
|
-
const classNameNotResolved =
|
|
6132
|
+
const classNameNotResolved = ClassHelpers_getName(ctor) || ctor.name;
|
|
6151
6133
|
throw new Error(`Not able to inject "${classNameNotResolved}" inside ` +
|
|
6152
|
-
`property "${propName?.toString()}" on class "${
|
|
6134
|
+
`property "${propName?.toString()}" on class "${ClassHelpers_getName(this)}".
|
|
6153
6135
|
|
|
6154
|
-
Please add "${
|
|
6136
|
+
Please add "${ClassHelpers_getName(ctor) || ctor.name}" to (entites or contorllers or providers or repositories or middlewares)
|
|
6155
6137
|
|
|
6156
6138
|
`);
|
|
6157
6139
|
}
|
|
@@ -6330,7 +6312,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6330
6312
|
let i = 0;
|
|
6331
6313
|
let httpErrorsCount = 0;
|
|
6332
6314
|
while (true) {
|
|
6333
|
-
await
|
|
6315
|
+
await UtilsTerminal_waitMilliseconds(poolingInterval);
|
|
6334
6316
|
try {
|
|
6335
6317
|
const resp = await taonRequest({
|
|
6336
6318
|
reqIndexNum: i,
|
|
@@ -6344,7 +6326,7 @@ let TaonBaseController = class TaonBaseController extends TaonBaseInjector {
|
|
|
6344
6326
|
httpErrorsCount++;
|
|
6345
6327
|
if (options.loopRequestsOnBackendError) {
|
|
6346
6328
|
const isProperTaonError = error instanceof HttpResponseError &&
|
|
6347
|
-
error.body.json[
|
|
6329
|
+
error.body.json[CoreModels_TaonHttpErrorCustomProp];
|
|
6348
6330
|
const isHttpError = error instanceof HttpResponseError && !isProperTaonError;
|
|
6349
6331
|
const isUnknownError = !(error instanceof HttpResponseError);
|
|
6350
6332
|
const resBool = await options.loopRequestsOnBackendError({
|
|
@@ -6402,23 +6384,23 @@ let TaonBaseCrudController = class TaonBaseCrudController extends TaonBaseContro
|
|
|
6402
6384
|
//#region init
|
|
6403
6385
|
async _() {
|
|
6404
6386
|
if (!_.isFunction(this.entityClassResolveFn)) {
|
|
6405
|
-
Helpers.warn(`Skipping initing CRUD controller ${
|
|
6387
|
+
Helpers.warn(`Skipping initing CRUD controller ${ClassHelpers_getName(this)} because entityClassResolveFn is not provided.`);
|
|
6406
6388
|
return;
|
|
6407
6389
|
}
|
|
6408
6390
|
let entityClassFn = this.entityClassResolveFn();
|
|
6409
6391
|
this.db = this.injectRepo(entityClassFn);
|
|
6410
6392
|
if (entityClassFn) {
|
|
6411
|
-
const configEntity = Reflect.getMetadata(
|
|
6393
|
+
const configEntity = Reflect.getMetadata(Symbols_metadata.options.entity, ClassHelpers_getClassFnFromObject(this));
|
|
6412
6394
|
if (configEntity?.createTable === false) {
|
|
6413
|
-
Helpers.warn(`Table for entity ${
|
|
6395
|
+
Helpers.warn(`Table for entity ${ClassHelpers_getName(entityClassFn)} will not be created. Crud will not work properly.`);
|
|
6414
6396
|
}
|
|
6415
6397
|
}
|
|
6416
6398
|
else {
|
|
6417
|
-
Helpers.error(`Entity class not provided for controller ${
|
|
6399
|
+
Helpers.error(`Entity class not provided for controller ${ClassHelpers_getName(this)}.
|
|
6418
6400
|
|
|
6419
6401
|
Please provide entity as class property entityClassFn:
|
|
6420
6402
|
|
|
6421
|
-
class ${
|
|
6403
|
+
class ${ClassHelpers_getName(this)} extends TaonBaseCrudController<Entity> {
|
|
6422
6404
|
// ...
|
|
6423
6405
|
entityClassResolveFn = ()=> MyEntityClass;
|
|
6424
6406
|
// ...
|
|
@@ -6697,9 +6679,9 @@ TaonBaseCrudController = __decorate([
|
|
|
6697
6679
|
*/
|
|
6698
6680
|
function TaonRepository(options) {
|
|
6699
6681
|
return function (constructor) {
|
|
6700
|
-
Reflect.defineMetadata(
|
|
6701
|
-
Reflect.defineMetadata(
|
|
6702
|
-
|
|
6682
|
+
Reflect.defineMetadata(Symbols_metadata.options.repository, options, constructor);
|
|
6683
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
6684
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
6703
6685
|
};
|
|
6704
6686
|
}
|
|
6705
6687
|
class TaonRepositoryOptions extends DecoratorAbstractOpt {
|
|
@@ -7449,9 +7431,9 @@ class TaonBaseProvider extends TaonBaseInjector {
|
|
|
7449
7431
|
*/
|
|
7450
7432
|
function TaonProvider(options) {
|
|
7451
7433
|
return function (constructor) {
|
|
7452
|
-
Reflect.defineMetadata(
|
|
7453
|
-
Reflect.defineMetadata(
|
|
7454
|
-
|
|
7434
|
+
Reflect.defineMetadata(Symbols_metadata.options.provider, options, constructor);
|
|
7435
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
7436
|
+
ClassHelpers_setName(constructor, options?.className || constructor.name);
|
|
7455
7437
|
};
|
|
7456
7438
|
}
|
|
7457
7439
|
class TaonProviderOptions extends DecoratorAbstractOpt {
|
|
@@ -7482,9 +7464,9 @@ TaonGlobalStateMiddleware = __decorate([
|
|
|
7482
7464
|
*/
|
|
7483
7465
|
function TaonSubscriber(options) {
|
|
7484
7466
|
return function (constructor) {
|
|
7485
|
-
Reflect.defineMetadata(
|
|
7486
|
-
Reflect.defineMetadata(
|
|
7487
|
-
|
|
7467
|
+
Reflect.defineMetadata(Symbols_metadata.options.subscriber, options, constructor);
|
|
7468
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
7469
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
7488
7470
|
};
|
|
7489
7471
|
}
|
|
7490
7472
|
class TaonSubscriberOptions extends DecoratorAbstractOpt {
|
|
@@ -7692,13 +7674,13 @@ class TaonBaseMigration extends TaonBaseInjector {
|
|
|
7692
7674
|
return true;
|
|
7693
7675
|
}
|
|
7694
7676
|
getDescription() {
|
|
7695
|
-
return _.startCase(
|
|
7677
|
+
return _.startCase(ClassHelpers_getName(this));
|
|
7696
7678
|
}
|
|
7697
7679
|
async up(queryRunner) {
|
|
7698
|
-
console.log(`[TaonBaseMigration] Running migration UP "${
|
|
7680
|
+
console.log(`[TaonBaseMigration] Running migration UP "${ClassHelpers_getName(this)}"`);
|
|
7699
7681
|
}
|
|
7700
7682
|
async down(queryRunner) {
|
|
7701
|
-
console.log(`[TaonBaseMigration] Running migration DOWN "${
|
|
7683
|
+
console.log(`[TaonBaseMigration] Running migration DOWN "${ClassHelpers_getName(this)}"`);
|
|
7702
7684
|
}
|
|
7703
7685
|
}
|
|
7704
7686
|
|
|
@@ -7857,7 +7839,7 @@ function typeFromEntity(component, entity) {
|
|
|
7857
7839
|
if (isArray) {
|
|
7858
7840
|
entity = _.first(entity);
|
|
7859
7841
|
}
|
|
7860
|
-
let name =
|
|
7842
|
+
let name = ClassHelpers_getName(component);
|
|
7861
7843
|
let res = { name, component, entity, isArray };
|
|
7862
7844
|
// console.log(res);
|
|
7863
7845
|
return res;
|
|
@@ -7879,7 +7861,7 @@ function RegisterComponentType(className, ...optionslNames) {
|
|
|
7879
7861
|
RegisterComponentType.prototype.types = [];
|
|
7880
7862
|
}
|
|
7881
7863
|
return function (target, propertyKey, descriptor) {
|
|
7882
|
-
|
|
7864
|
+
ClassHelpers_setName(target, className);
|
|
7883
7865
|
RegisterComponentType.prototype.types.push(typeFromEntity(target));
|
|
7884
7866
|
optionslNames.forEach(name => {
|
|
7885
7867
|
RegisterComponentType.prototype.types.push(typeFromName(target, name));
|
|
@@ -7901,7 +7883,7 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7901
7883
|
if (level === maxLevel) {
|
|
7902
7884
|
return [];
|
|
7903
7885
|
}
|
|
7904
|
-
const mapping =
|
|
7886
|
+
const mapping = Mapping_getModelsMapping(target);
|
|
7905
7887
|
// console.log('mapping', mapping)
|
|
7906
7888
|
const fieldNames = CLASS.describeProperites(target);
|
|
7907
7889
|
const checkExclude = _.isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
@@ -8158,90 +8140,90 @@ const SimpleJsonColumn = () => Column({ type: 'simple-json', nullable: true });
|
|
|
8158
8140
|
const BooleanColumn = (defaultValue) => Column({ type: 'boolean', nullable: true, default: defaultValue });
|
|
8159
8141
|
const DateTimeColumn = (defaultValue = null) => Column({ type: 'datetime', nullable: true, default: defaultValue });
|
|
8160
8142
|
|
|
8143
|
+
//end of namespace RealtimeModels
|
|
8144
|
+
|
|
8161
8145
|
/**
|
|
8162
8146
|
* Migration decorator
|
|
8163
8147
|
*/
|
|
8164
8148
|
function TaonMigration(options) {
|
|
8165
8149
|
return function (constructor) {
|
|
8166
|
-
Reflect.defineMetadata(
|
|
8167
|
-
Reflect.defineMetadata(
|
|
8168
|
-
|
|
8150
|
+
Reflect.defineMetadata(Symbols_metadata.options.migration, options, constructor);
|
|
8151
|
+
Reflect.defineMetadata(Symbols_metadata.className, options?.className || constructor.name, constructor);
|
|
8152
|
+
ClassHelpers_setName(constructor, options?.className);
|
|
8169
8153
|
};
|
|
8170
8154
|
}
|
|
8171
8155
|
class TaonMigrationOptions extends DecoratorAbstractOpt {
|
|
8172
8156
|
}
|
|
8173
8157
|
|
|
8174
8158
|
// TODO export all things
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
body.style.backgroundColor = '';
|
|
8189
|
-
}
|
|
8190
|
-
resolve();
|
|
8191
|
-
}, afterMS);
|
|
8192
|
-
});
|
|
8193
|
-
};
|
|
8194
|
-
Taon.error = (opt) => {
|
|
8195
|
-
throw () => {
|
|
8196
|
-
if (typeof opt === 'string') {
|
|
8197
|
-
opt = {
|
|
8198
|
-
message: opt,
|
|
8199
|
-
};
|
|
8159
|
+
//namespace Taon
|
|
8160
|
+
/**
|
|
8161
|
+
* Remove global taon loader from env.ts [loading.preAngularBootstrap]
|
|
8162
|
+
*/
|
|
8163
|
+
const Taon_removeLoader = (afterMS = 0) => {
|
|
8164
|
+
return new Promise(resolve => {
|
|
8165
|
+
setTimeout(() => {
|
|
8166
|
+
globalThis?.window?.document
|
|
8167
|
+
?.getElementById('taonpreloadertoremove')
|
|
8168
|
+
?.remove();
|
|
8169
|
+
const body = globalThis?.window?.document?.body;
|
|
8170
|
+
if (body && body.style) {
|
|
8171
|
+
body.style.backgroundColor = '';
|
|
8200
8172
|
}
|
|
8201
|
-
|
|
8202
|
-
};
|
|
8203
|
-
};
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8214
|
-
//#endregion
|
|
8215
|
-
//#region aliases to helpers
|
|
8216
|
-
Taon.isBrowser = coreHelpers.Helpers.isBrowser;
|
|
8217
|
-
Taon.isNode = coreHelpers.Helpers.isNode;
|
|
8218
|
-
Taon.isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
8219
|
-
Taon.isElectron = coreHelpers.Helpers.isElectron;
|
|
8220
|
-
//#endregion
|
|
8221
|
-
Taon.createContext = createContext;
|
|
8222
|
-
Taon.createContextTemplate = createContextTemplate;
|
|
8223
|
-
Taon.inject = inject;
|
|
8224
|
-
Taon.symbols = Symbols;
|
|
8225
|
-
/**
|
|
8226
|
-
* @deprecated
|
|
8227
|
-
* use createContext instead
|
|
8228
|
-
*/
|
|
8229
|
-
Taon.init = async (options) => {
|
|
8230
|
-
const TaonBaseContext = (await Promise.resolve().then(function () { return baseContext; }))
|
|
8231
|
-
.TaonBaseContext;
|
|
8232
|
-
const context = Taon.createContext(() => ({
|
|
8233
|
-
appId: 'default-app-not-used-anymore',
|
|
8234
|
-
contextName: 'default',
|
|
8235
|
-
host: options.host,
|
|
8236
|
-
contexts: { TaonBaseContext },
|
|
8237
|
-
database: true,
|
|
8238
|
-
entities: Array.from(options.entities),
|
|
8239
|
-
controllers: Array.from(options.controllers),
|
|
8240
|
-
}));
|
|
8241
|
-
await context.initialize();
|
|
8242
|
-
return context;
|
|
8173
|
+
resolve();
|
|
8174
|
+
}, afterMS);
|
|
8175
|
+
});
|
|
8176
|
+
};
|
|
8177
|
+
const Taon_error = (opt) => {
|
|
8178
|
+
throw () => {
|
|
8179
|
+
if (typeof opt === 'string') {
|
|
8180
|
+
opt = {
|
|
8181
|
+
message: opt,
|
|
8182
|
+
};
|
|
8183
|
+
}
|
|
8184
|
+
return opt;
|
|
8243
8185
|
};
|
|
8244
|
-
}
|
|
8186
|
+
};
|
|
8187
|
+
const Taon_getResponseValue = getResponseValue;
|
|
8188
|
+
//#region class decorators
|
|
8189
|
+
// TODO new 5.8 typescript is not allowing this
|
|
8190
|
+
// export import Controller = controllerDecorator.TaonController;
|
|
8191
|
+
// export import Entity = entityDecorator.TaonEntity;
|
|
8192
|
+
// export import Provider = providerDecorator.TaonProvider;
|
|
8193
|
+
// export import Repository = repositoryDecorator.TaonRepository;
|
|
8194
|
+
// export import Subscriber = subscriberDecorator.TaonSubscriber;
|
|
8195
|
+
// export import Migration = migrationDecorator.TaonMigration;
|
|
8196
|
+
// export import Middleware = middlewareDecorator.TaonMiddleware;
|
|
8197
|
+
//#endregion
|
|
8198
|
+
//#region aliases to helpers
|
|
8199
|
+
const Taon_isBrowser = coreHelpers.Helpers.isBrowser;
|
|
8200
|
+
const Taon_isNode = coreHelpers.Helpers.isNode;
|
|
8201
|
+
const Taon_isWebSQL = coreHelpers.Helpers.isWebSQL;
|
|
8202
|
+
const Taon_isElectron = coreHelpers.Helpers.isElectron;
|
|
8203
|
+
//#endregion
|
|
8204
|
+
const Taon_createContext = createContext;
|
|
8205
|
+
const Taon_createContextTemplate = createContextTemplate;
|
|
8206
|
+
const Taon_inject = inject;
|
|
8207
|
+
/**
|
|
8208
|
+
* @deprecated
|
|
8209
|
+
* use createContext instead
|
|
8210
|
+
*/
|
|
8211
|
+
const Taon_init = async (options) => {
|
|
8212
|
+
const TaonBaseContext = (await Promise.resolve().then(function () { return baseContext; }))
|
|
8213
|
+
.TaonBaseContext;
|
|
8214
|
+
const context = Taon_createContext(() => ({
|
|
8215
|
+
appId: 'default-app-not-used-anymore',
|
|
8216
|
+
contextName: 'default',
|
|
8217
|
+
host: options.host,
|
|
8218
|
+
contexts: { TaonBaseContext },
|
|
8219
|
+
database: true,
|
|
8220
|
+
entities: Array.from(options.entities),
|
|
8221
|
+
controllers: Array.from(options.controllers),
|
|
8222
|
+
}));
|
|
8223
|
+
await context.initialize();
|
|
8224
|
+
return context;
|
|
8225
|
+
};
|
|
8226
|
+
//end of namespace Taon
|
|
8245
8227
|
//#region taon flattening map
|
|
8246
8228
|
const TAON_FLATTEN_MAPPING = {
|
|
8247
8229
|
'taon/src': {
|
|
@@ -8363,5 +8345,5 @@ const TAON_FLATTEN_MAPPING = {
|
|
|
8363
8345
|
* Generated bundle index. Do not edit.
|
|
8364
8346
|
*/
|
|
8365
8347
|
|
|
8366
|
-
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL,
|
|
8348
|
+
export { BaseTaonClassesNames, Body, BooleanColumn, CURRENT_HOST_BACKEND_PORT, CURRENT_HOST_URL, ClassHelpers_asyncHandler, ClassHelpers_ensureClassConfig, ClassHelpers_ensureMethodConfig, ClassHelpers_getClassConfig, ClassHelpers_getClassFnFromObject, ClassHelpers_getControllerConfigs, ClassHelpers_getFullInternalName, ClassHelpers_getMethodsNames, ClassHelpers_getName, ClassHelpers_getOrginalClass, ClassHelpers_getUniqueKey, ClassHelpers_hasParentClassWithName, ClassHelpers_isContextClassObject, ClassHelpers_setName, ContextDbMigrations, ContextsEndpointStorage, ControllerConfig, Cookie, DELETE, DITaonContainer, DateTimeColumn, DecimalNumberColumn, DecoratorAbstractOpt, EndpointContext, EntityProcess, FormlyHorizontalWrapper, GET, HEAD, HTML, Header, MethodConfig, MockNamespaceIpc, MockServerIpc, MockSocketIpc, Models_ClassType, Models_ClassTypeKey, Models_DatabaseConfig, Models_DatabaseConfigTypeOrm, Models_DatabasesFolder, NumberColumn, PATCH, POST, PUT, ParamConfig, Path, Query, RealtimeClient, RealtimeCore, RealtimeServer, RealtimeStrategy, RealtimeStrategyIpc, RealtimeStrategyMock, RealtimeStrategySocketIO, RealtimeSubsManager, RegisterComponentType, RegisterComponentTypeForEntity, RepeatTypeComponent, SimpleJsonColumn, String100Column, String200Column, String20Column, String45Column, String500Column, StringColumn, Symbols_REALTIME, Symbols_classMethodsNames, Symbols_classNameStaticProperty, Symbols_ctxInClassOrClassObj, Symbols_fullClassNameStaticProperty, Symbols_metadata, Symbols_old, Symbols_orignalClass, Symbols_orignalClassClonesObj, TAON_CONTEXT, TAON_FLATTEN_MAPPING, TaonAdminService, TaonBaseAbstractEntity, TaonBaseAngularService, TaonBaseClass, TaonBaseContext, TaonBaseController, TaonBaseCrudController, TaonBaseCustomRepository, TaonBaseEntity, TaonBaseFileUploadMiddleware, TaonBaseInjector, TaonBaseMiddleware, TaonBaseMigration, TaonBaseProvider, TaonBaseRepository, TaonBaseSubscriberForEntity, TaonController, TaonControllerOptions, TaonEntity, TaonEntityKeysToOmitArr, TaonEntityOptions, TaonHelpers_defaultType, TaonHelpers_fillUpTo, TaonHelpers_firstStringOrElemFromArray, TaonHelpers_getExpressPath, TaonHelpers_ipcKeyNameRequest, TaonHelpers_ipcKeyNameResponse, TaonHelpers_isGoodPath, TaonHelpers_isPlainFileOrFolder, TaonHelpers_parseJSONwithStringJSONs, TaonHelpers_tryTransformParam, TaonHelpers_websqlMocks, TaonMiddleware, TaonMiddlewareOptions, TaonMigration, TaonMigrationOptions, TaonProvider, TaonProviderOptions, TaonRepository, TaonRepositoryOptions, TaonRestResponseWrapper, TaonSubscriber, TaonSubscriberOptions, TaonTempDatabasesFolder, TaonTempRoutesFolder, Taon_createContext, Taon_createContextTemplate, Taon_error, Taon_getResponseValue, Taon_init, Taon_inject, Taon_isBrowser, Taon_isElectron, Taon_isNode, Taon_isWebSQL, Taon_removeLoader, Validators_checkIfMethodsWithReponseTYpeAlowed, Validators_classNameVlidation, Validators_preventUndefinedModel, Validators_validateClassFunctions, apiPrefix, cloneObj, controllerConfigFrom, createContext, createContextTemplate, findTypeForEntity, getFromlyConfigFor, getRegisteredComponents, getResponseValue, getTransformFunction, inject, singleTransform, typeFromEntity, typeFromName };
|
|
8367
8349
|
//# sourceMappingURL=taon-browser.mjs.map
|