taon 21.0.63 → 21.0.71
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 +142 -69
- package/browser/fesm2022/taon-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +13 -16
- package/browser-prod/fesm2022/taon-browser.mjs +147 -74
- package/browser-prod/fesm2022/taon-browser.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-browser.d.ts +15 -18
- package/browser-prod.split-namespaces.json +2 -4
- package/cli.js +1 -1
- package/cli.js.map +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/base-classes/base-controller.d.ts +2 -3
- 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/classes/entity-decorator.d.ts +3 -6
- package/lib/decorators/classes/entity-decorator.js +16 -7
- package/lib/decorators/classes/entity-decorator.js.map +1 -1
- package/lib/decorators/http/http-decorators.d.ts +1 -3
- package/lib/decorators/http/http-decorators.js +4 -2
- package/lib/decorators/http/http-decorators.js.map +1 -1
- package/lib/decorators/http/http-methods-decorators.d.ts +2 -2
- package/lib/endpoint-context.js +104 -48
- package/lib/endpoint-context.js.map +1 -1
- package/lib/entity-process.d.ts +0 -1
- package/lib/entity-process.js +39 -41
- package/lib/entity-process.js.map +1 -1
- package/lib/formly/fromly.js +2 -2
- package/lib/formly/fromly.js.map +1 -1
- package/lib/helpers/class-helpers.d.ts +1 -1
- package/lib/helpers/class-helpers.js +9 -6
- package/lib/helpers/class-helpers.js.map +1 -1
- package/lib/models.d.ts +7 -3
- package/lib/models.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/realtime/realtime-client.js +1 -1
- package/lib/realtime/realtime-client.js.map +1 -1
- package/lib/symbols.d.ts +0 -2
- package/lib/symbols.js +3 -7
- package/lib/symbols.js.map +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-controller.d.ts +2 -3
- package/lib-prod/base-classes/base-controller.js.map +1 -1
- package/lib-prod/base-classes/base-crud-controller.js.map +1 -1
- package/lib-prod/base-classes/base-injector.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +1 -1
- package/lib-prod/build-info._auto-generated_.js +1 -1
- package/lib-prod/context-db-migrations.js.map +1 -1
- package/lib-prod/create-context.js.map +1 -1
- package/lib-prod/decorators/classes/controller-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/entity-decorator.d.ts +3 -6
- package/lib-prod/decorators/classes/entity-decorator.js +17 -8
- package/lib-prod/decorators/classes/entity-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/middleware-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/migration-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/provider-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/repository-decorator.js.map +1 -1
- package/lib-prod/decorators/classes/subscriber-decorator.js.map +1 -1
- package/lib-prod/decorators/http/http-decorators.d.ts +1 -3
- package/lib-prod/decorators/http/http-decorators.js +4 -3
- package/lib-prod/decorators/http/http-decorators.js.map +1 -1
- package/lib-prod/decorators/http/http-methods-decorators.d.ts +2 -2
- package/lib-prod/decorators/http/http-methods-decorators.js.map +1 -1
- package/lib-prod/endpoint-context-storage.js.map +1 -1
- package/lib-prod/endpoint-context.js +108 -52
- package/lib-prod/endpoint-context.js.map +1 -1
- package/lib-prod/entity-process.d.ts +0 -1
- package/lib-prod/entity-process.js +9 -11
- package/lib-prod/entity-process.js.map +1 -1
- package/lib-prod/formly/fromly.js +5 -5
- package/lib-prod/formly/fromly.js.map +1 -1
- package/lib-prod/helpers/class-helpers.d.ts +1 -1
- package/lib-prod/helpers/class-helpers.js +13 -10
- package/lib-prod/helpers/class-helpers.js.map +1 -1
- package/lib-prod/inject.js.map +1 -1
- package/lib-prod/models.d.ts +7 -3
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +2 -2
- package/lib-prod/realtime/realtime-client.js.map +1 -1
- package/lib-prod/realtime/realtime-server.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -1
- package/lib-prod/realtime/realtime-subs-manager.js.map +1 -1
- package/lib-prod/symbols.d.ts +0 -2
- package/lib-prod/symbols.js +0 -4
- package/lib-prod/symbols.js.map +1 -1
- package/lib-prod/ui/index.d.ts +1 -1
- package/lib-prod/ui/index.js +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +1 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -1
- package/lib-prod.split-namespaces.json +2 -4
- package/package.json +1 -1
- package/websql/fesm2022/taon-websql.mjs +147 -78
- package/websql/fesm2022/taon-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +13 -16
- package/websql-prod/fesm2022/taon-websql.mjs +152 -83
- package/websql-prod/fesm2022/taon-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-websql.d.ts +15 -18
- package/websql-prod.split-namespaces.json +2 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { _, Utils, Helpers, UtilsOs, config,
|
|
2
|
+
import { _, CoreModels, Utils, Helpers, UtilsOs, config, crossPlatformPath, UtilsTerminal } from 'tnp-core/browser';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { JSON10 } from 'json10/browser';
|
|
5
5
|
import { walk } from 'lodash-walk-object/browser';
|
|
6
|
-
import { RestResponseWrapper, Resource,
|
|
6
|
+
import { RestResponseWrapper, Resource, HttpResponse, RestHeaders, decodeMappingForHeaderJson, DefaultMapping, DefaultModel, HttpResponseError } from 'ng2-rest/browser';
|
|
7
7
|
import { Observable, from, Subject } from 'rxjs';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
9
|
import { InjectionToken, inject as inject$1, PLATFORM_ID, Injectable, ViewContainerRef, ViewChild, Component } from '@angular/core';
|
|
10
|
-
import { Table,
|
|
10
|
+
import { Table, Column } from 'taon-typeorm/browser';
|
|
11
11
|
export { AfterInsert, AfterLoad, AfterRecover, AfterRemove, AfterSoftRemove, AfterUpdate, BeforeInsert, BeforeRecover, BeforeRemove, BeforeSoftRemove, BeforeUpdate, Column, Connection, CreateDateColumn, Column as CustomColumn, DeleteDateColumn, Generated, Generated as GeneratedColumn, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Repository, TreeChildren, TreeParent, UpdateDateColumn, VersionColumn, VirtualColumn } from 'taon-typeorm/browser';
|
|
12
|
-
import {
|
|
12
|
+
import { CLASS } from 'typescript-class-helpers/browser';
|
|
13
13
|
import * as JSON5 from 'json5';
|
|
14
14
|
import { io } from 'socket.io-client';
|
|
15
15
|
import { isPlatformServer, isPlatformBrowser } from '@angular/common';
|
|
@@ -648,9 +648,7 @@ class Realtime {
|
|
|
648
648
|
var Symbols;
|
|
649
649
|
(function (Symbols) {
|
|
650
650
|
Symbols.ctxInClassOrClassObj = Symbol();
|
|
651
|
-
Symbols.classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
652
651
|
Symbols.fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
653
|
-
Symbols.orignalClass = OrignalClassKey;
|
|
654
652
|
Symbols.orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
655
653
|
Symbols.classMethodsNames = `$$classMethodsNames$$`;
|
|
656
654
|
Symbols.REALTIME = new Realtime();
|
|
@@ -803,14 +801,14 @@ var ClassHelpers;
|
|
|
803
801
|
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
804
802
|
throw new Error(`Cannot get name from this object or class.`);
|
|
805
803
|
}
|
|
806
|
-
return ((classFnOrObject[
|
|
807
|
-
? classFnOrObject[
|
|
808
|
-
: classFnOrObject?.constructor[
|
|
804
|
+
return ((classFnOrObject[CoreModels.ClassNameStaticProperty]
|
|
805
|
+
? classFnOrObject[CoreModels.ClassNameStaticProperty]
|
|
806
|
+
: classFnOrObject?.constructor[CoreModels.ClassNameStaticProperty]) ||
|
|
809
807
|
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
810
808
|
};
|
|
811
809
|
//#endregion
|
|
812
810
|
ClassHelpers.getOrginalClass = (classFnOrObject) => {
|
|
813
|
-
const org = classFnOrObject[
|
|
811
|
+
const org = classFnOrObject[CoreModels.OrignalClassKey];
|
|
814
812
|
if (!org) {
|
|
815
813
|
return classFnOrObject;
|
|
816
814
|
}
|
|
@@ -832,8 +830,11 @@ var ClassHelpers;
|
|
|
832
830
|
ClassHelpers.getUniqueKey = (classFnOrObject) => {
|
|
833
831
|
const classFn = _.isFunction(classFnOrObject)
|
|
834
832
|
? classFnOrObject
|
|
835
|
-
: classFnOrObject
|
|
833
|
+
: classFnOrObject?.constructor;
|
|
836
834
|
const config = Reflect.getMetadata(Symbols.metadata.options.entity, classFn);
|
|
835
|
+
if (!config) {
|
|
836
|
+
return void 0;
|
|
837
|
+
}
|
|
837
838
|
return config.uniqueKeyProp;
|
|
838
839
|
};
|
|
839
840
|
//#endregion
|
|
@@ -857,7 +858,7 @@ var ClassHelpers;
|
|
|
857
858
|
ClassHelpers.setName = (target, className) => {
|
|
858
859
|
// console.log('setName', className, target.name)
|
|
859
860
|
Validators.classNameVlidation(className, target);
|
|
860
|
-
target[
|
|
861
|
+
target[CoreModels.ClassNameStaticProperty] = className;
|
|
861
862
|
};
|
|
862
863
|
//#endregion
|
|
863
864
|
//#region has parent with class name
|
|
@@ -1404,7 +1405,7 @@ class RealtimeClient {
|
|
|
1404
1405
|
* ...
|
|
1405
1406
|
*/
|
|
1406
1407
|
listenChangesEntity(entityClassFnOrObj, options) {
|
|
1407
|
-
options = options || {};
|
|
1408
|
+
options = _.cloneDeep(options || {});
|
|
1408
1409
|
if (_.isObject(entityClassFnOrObj)) {
|
|
1409
1410
|
const orgObj = entityClassFnOrObj;
|
|
1410
1411
|
entityClassFnOrObj =
|
|
@@ -2695,23 +2696,18 @@ class EndpointContext {
|
|
|
2695
2696
|
// You can override prototype properties or methods here if needed
|
|
2696
2697
|
// static properties override allowed
|
|
2697
2698
|
}
|
|
2698
|
-
static { _a =
|
|
2699
|
-
// @ts-ignore
|
|
2699
|
+
static { _a = CoreModels.OrignalClassKey, _b = Symbols.fullClassNameStaticProperty, _c = CoreModels.ClassNameStaticProperty, _d = Symbols.ctxInClassOrClassObj, _e = Symbols.ctxInClassOrClassObj; }
|
|
2700
2700
|
static { this[_a] = TaonBaseClass; }
|
|
2701
|
-
// @ts-ignore
|
|
2702
2701
|
static { this[_b] = `${ctx.contextName}.${className}`; }
|
|
2703
|
-
// @ts-ignore
|
|
2704
2702
|
static { this[_c] = className; }
|
|
2705
2703
|
static { this[_d] = ctx; }
|
|
2706
2704
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2707
2705
|
static __getFullPathForClass__(arr = []) {
|
|
2708
2706
|
const name = this[Symbols.fullClassNameStaticProperty];
|
|
2709
2707
|
arr.push(name);
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
this[
|
|
2713
|
-
// @ts-ignore
|
|
2714
|
-
this[Symbols.orignalClass].__getFullPathForClass__(arr);
|
|
2708
|
+
if (this[CoreModels.OrignalClassKey] &&
|
|
2709
|
+
this[CoreModels.OrignalClassKey].__getFullPathForClass__) {
|
|
2710
|
+
this[CoreModels.OrignalClassKey].__getFullPathForClass__(arr);
|
|
2715
2711
|
}
|
|
2716
2712
|
return arr.join('/');
|
|
2717
2713
|
}
|
|
@@ -2761,7 +2757,7 @@ class EndpointContext {
|
|
|
2761
2757
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
2762
2758
|
// }
|
|
2763
2759
|
className = className || key;
|
|
2764
|
-
TaonBaseClass[
|
|
2760
|
+
TaonBaseClass[CoreModels.ClassNameStaticProperty] = className;
|
|
2765
2761
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
2766
2762
|
TaonBaseClass,
|
|
2767
2763
|
className,
|
|
@@ -4126,6 +4122,8 @@ class EndpointContext {
|
|
|
4126
4122
|
/* */
|
|
4127
4123
|
/* */
|
|
4128
4124
|
/* */
|
|
4125
|
+
/* */
|
|
4126
|
+
/* */
|
|
4129
4127
|
}
|
|
4130
4128
|
//#endregion
|
|
4131
4129
|
//#region methods & getters / middlewares
|
|
@@ -4143,7 +4141,7 @@ class EndpointContext {
|
|
|
4143
4141
|
middlewares.forEach(middlewareInstanceName => {
|
|
4144
4142
|
const contextName = this.contextName;
|
|
4145
4143
|
const interceptorName = `${contextName}-${ClassHelpers.getName(middlewareInstanceName)}`;
|
|
4146
|
-
Resource.
|
|
4144
|
+
Resource.globalInterceptors.set(interceptorName, {
|
|
4147
4145
|
intercept: ({ req, next }) => {
|
|
4148
4146
|
const url = new URL(req.url);
|
|
4149
4147
|
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${contextName}/`)) {
|
|
@@ -4373,6 +4371,9 @@ class EndpointContext {
|
|
|
4373
4371
|
/* */
|
|
4374
4372
|
/* */
|
|
4375
4373
|
/* */
|
|
4374
|
+
/* */
|
|
4375
|
+
/* */
|
|
4376
|
+
/* */
|
|
4376
4377
|
}
|
|
4377
4378
|
if (!this.isRemoteHost) {
|
|
4378
4379
|
//#region apply dummy websql express routers
|
|
@@ -4598,6 +4599,24 @@ class EndpointContext {
|
|
|
4598
4599
|
/* */
|
|
4599
4600
|
/* */
|
|
4600
4601
|
/* */
|
|
4602
|
+
/* */
|
|
4603
|
+
/* */
|
|
4604
|
+
/* */
|
|
4605
|
+
/* */
|
|
4606
|
+
/* */
|
|
4607
|
+
/* */
|
|
4608
|
+
/* */
|
|
4609
|
+
/* */
|
|
4610
|
+
/* */
|
|
4611
|
+
/* */
|
|
4612
|
+
/* */
|
|
4613
|
+
/* */
|
|
4614
|
+
/* */
|
|
4615
|
+
/* */
|
|
4616
|
+
/* */
|
|
4617
|
+
/* */
|
|
4618
|
+
/* */
|
|
4619
|
+
/* */
|
|
4601
4620
|
}
|
|
4602
4621
|
return {
|
|
4603
4622
|
expressPath: expressPath,
|
|
@@ -4659,7 +4678,7 @@ class EndpointContext {
|
|
|
4659
4678
|
const middlewareName = ClassHelpers.getName(instance);
|
|
4660
4679
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
4661
4680
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
4662
|
-
Resource.
|
|
4681
|
+
Resource.methodsInterceptors.set(interceptorKey, {
|
|
4663
4682
|
intercept: ({ req, next }) => {
|
|
4664
4683
|
return instance.interceptClientMethod({
|
|
4665
4684
|
req,
|
|
@@ -4695,15 +4714,15 @@ class EndpointContext {
|
|
|
4695
4714
|
console.log({ responseData });
|
|
4696
4715
|
try {
|
|
4697
4716
|
const body = res;
|
|
4698
|
-
|
|
4699
|
-
body: void 0,
|
|
4700
|
-
isArray: void 0,
|
|
4701
|
-
method: methodConfig.type,
|
|
4702
|
-
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4703
|
-
}${methodConfig.path} `,
|
|
4704
|
-
}, Helpers.isBlob(body) || _.isString(body)
|
|
4717
|
+
const responseStrinOrBlob = Helpers.isBlob(body) || _.isString(body)
|
|
4705
4718
|
? body
|
|
4706
|
-
: JSON.stringify(body)
|
|
4719
|
+
: JSON.stringify(body);
|
|
4720
|
+
res = new HttpResponse(`${ctx.uriOrigin}${'' // TODO express path
|
|
4721
|
+
}${methodConfig.path} `, methodConfig.type, responseStrinOrBlob, RestHeaders.from(headers), 200, {
|
|
4722
|
+
// responseMapping: {
|
|
4723
|
+
// // entity: ()=> TODO for electron
|
|
4724
|
+
// },
|
|
4725
|
+
}, false);
|
|
4707
4726
|
resolve(res);
|
|
4708
4727
|
}
|
|
4709
4728
|
catch (error) {
|
|
@@ -4888,28 +4907,51 @@ class EndpointContext {
|
|
|
4888
4907
|
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4889
4908
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4890
4909
|
let rest;
|
|
4910
|
+
const requestHeaders = RestHeaders.from({});
|
|
4891
4911
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4892
|
-
let headers = {};
|
|
4893
4912
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4894
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4913
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4914
|
+
responseMapping: {
|
|
4915
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4916
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4917
|
+
},
|
|
4918
|
+
});
|
|
4919
|
+
requestHeaders.apply({
|
|
4895
4920
|
'Content-Type': methodConfig.contentType,
|
|
4896
4921
|
Accept: methodConfig.contentType,
|
|
4897
|
-
})
|
|
4922
|
+
});
|
|
4898
4923
|
}
|
|
4899
4924
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4900
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4925
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4926
|
+
responseMapping: {
|
|
4927
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4928
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4929
|
+
},
|
|
4930
|
+
});
|
|
4931
|
+
requestHeaders.apply({
|
|
4901
4932
|
'Content-Type': methodConfig.contentType,
|
|
4902
4933
|
Accept: methodConfig.contentType,
|
|
4903
4934
|
responsetypeaxios: methodConfig.responseType,
|
|
4904
|
-
})
|
|
4935
|
+
});
|
|
4905
4936
|
}
|
|
4906
4937
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4907
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4938
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4939
|
+
responseMapping: {
|
|
4940
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4941
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4942
|
+
},
|
|
4943
|
+
});
|
|
4944
|
+
requestHeaders.apply({
|
|
4908
4945
|
responsetypeaxios: methodConfig.responseType,
|
|
4909
|
-
})
|
|
4946
|
+
});
|
|
4910
4947
|
}
|
|
4911
4948
|
else {
|
|
4912
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4949
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4950
|
+
responseMapping: {
|
|
4951
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4952
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4953
|
+
},
|
|
4954
|
+
});
|
|
4913
4955
|
}
|
|
4914
4956
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4915
4957
|
}
|
|
@@ -4937,47 +4979,60 @@ class EndpointContext {
|
|
|
4937
4979
|
/* */
|
|
4938
4980
|
throw new Error(errorMessage);
|
|
4939
4981
|
}
|
|
4982
|
+
const optionsDecodeHeader = {
|
|
4983
|
+
useFirstArrayItemClassNameForAllElements: true,
|
|
4984
|
+
};
|
|
4940
4985
|
if (currentParam.paramType === 'Path') {
|
|
4986
|
+
//#region handle path params
|
|
4941
4987
|
pathPrams[currentParam.paramName] = param;
|
|
4988
|
+
//#endregion
|
|
4942
4989
|
}
|
|
4943
4990
|
if (currentParam.paramType === 'Query') {
|
|
4991
|
+
//#region handle query params
|
|
4944
4992
|
if (currentParam.paramName) {
|
|
4945
|
-
const mapping =
|
|
4993
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4946
4994
|
if (mapping) {
|
|
4947
|
-
|
|
4995
|
+
requestHeaders.set(`${Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4948
4996
|
}
|
|
4949
4997
|
queryParams[currentParam.paramName] = param;
|
|
4950
4998
|
}
|
|
4951
4999
|
else {
|
|
4952
|
-
const mapping =
|
|
5000
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4953
5001
|
if (mapping) {
|
|
4954
|
-
|
|
5002
|
+
requestHeaders.set(Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4955
5003
|
}
|
|
4956
5004
|
queryParams = _.cloneDeep(param);
|
|
4957
5005
|
}
|
|
5006
|
+
//#endregion
|
|
4958
5007
|
}
|
|
4959
5008
|
if (currentParam.paramType === 'Header') {
|
|
5009
|
+
//#region handler header params
|
|
4960
5010
|
if (currentParam.paramName) {
|
|
4961
5011
|
if (currentParam.paramName === Symbols.old.MDC_KEY) {
|
|
4962
5012
|
// parese MDC
|
|
4963
|
-
|
|
5013
|
+
requestHeaders.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4964
5014
|
}
|
|
4965
5015
|
else {
|
|
4966
|
-
|
|
5016
|
+
requestHeaders.set(currentParam.paramName, param);
|
|
4967
5017
|
}
|
|
4968
5018
|
}
|
|
4969
5019
|
else {
|
|
4970
5020
|
for (let header in param) {
|
|
4971
|
-
|
|
5021
|
+
requestHeaders.set(header, param[header]);
|
|
4972
5022
|
}
|
|
4973
5023
|
}
|
|
5024
|
+
//#endregion
|
|
4974
5025
|
}
|
|
4975
5026
|
if (currentParam.paramType === 'Cookie') {
|
|
5027
|
+
//#region handle cookie params
|
|
4976
5028
|
Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
5029
|
+
//#endregion
|
|
4977
5030
|
}
|
|
4978
5031
|
if (currentParam.paramType === 'Body') {
|
|
5032
|
+
//#region handle body params
|
|
4979
5033
|
if (currentParam.paramName) {
|
|
4980
5034
|
if (ClassHelpers.getName(bodyObject) === 'FormData') {
|
|
5035
|
+
//#region prevent posting/putting not full body as FormData
|
|
4981
5036
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
4982
5037
|
Use this:
|
|
4983
5038
|
// ...
|
|
@@ -4989,45 +5044,52 @@ instead
|
|
|
4989
5044
|
(@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
|
|
4990
5045
|
// ...
|
|
4991
5046
|
`);
|
|
5047
|
+
//#endregion
|
|
4992
5048
|
}
|
|
4993
|
-
const mapping =
|
|
5049
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4994
5050
|
if (mapping) {
|
|
4995
|
-
|
|
5051
|
+
requestHeaders.set(`${Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4996
5052
|
}
|
|
4997
5053
|
bodyObject[currentParam.paramName] = param;
|
|
4998
5054
|
}
|
|
4999
5055
|
else {
|
|
5000
|
-
const mapping =
|
|
5056
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
5001
5057
|
if (mapping) {
|
|
5002
|
-
|
|
5058
|
+
requestHeaders.set(Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
5003
5059
|
}
|
|
5004
5060
|
bodyObject = param;
|
|
5005
5061
|
}
|
|
5062
|
+
//#endregion
|
|
5006
5063
|
}
|
|
5007
5064
|
});
|
|
5008
5065
|
if (typeof bodyObject === 'object' &&
|
|
5009
5066
|
ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
5067
|
+
//#region handle circular objects in body params
|
|
5010
5068
|
let circuralFromItem = [];
|
|
5011
5069
|
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
5012
5070
|
circuralFromItem = circs;
|
|
5013
5071
|
}));
|
|
5014
|
-
|
|
5072
|
+
requestHeaders.set(Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
5073
|
+
//#endregion
|
|
5015
5074
|
}
|
|
5016
5075
|
if (typeof queryParams === 'object') {
|
|
5076
|
+
//#region handle circular objects in query params
|
|
5017
5077
|
let circuralFromQueryParams = [];
|
|
5018
5078
|
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
5019
5079
|
circuralFromQueryParams = circs;
|
|
5020
5080
|
}));
|
|
5021
|
-
|
|
5081
|
+
requestHeaders.set(Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
5082
|
+
//#endregion
|
|
5022
5083
|
}
|
|
5023
5084
|
//#endregion
|
|
5024
5085
|
const httpResultObj = {
|
|
5025
5086
|
get received() {
|
|
5026
|
-
return rest
|
|
5087
|
+
return rest
|
|
5088
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams]);
|
|
5027
5089
|
},
|
|
5028
5090
|
request(axiosConfig) {
|
|
5029
5091
|
return rest
|
|
5030
|
-
.model(pathPrams)[method](bodyObject, [queryParams], axiosConfig);
|
|
5092
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams], axiosConfig);
|
|
5031
5093
|
},
|
|
5032
5094
|
};
|
|
5033
5095
|
return httpResultObj;
|
|
@@ -5467,10 +5529,6 @@ const singleTransform = (json) => {
|
|
|
5467
5529
|
};
|
|
5468
5530
|
//#endregion
|
|
5469
5531
|
class EntityProcess {
|
|
5470
|
-
//#region init
|
|
5471
|
-
static async init(result, response) {
|
|
5472
|
-
return await new EntityProcess(result, response).run();
|
|
5473
|
-
}
|
|
5474
5532
|
//#endregion
|
|
5475
5533
|
//#region constructor
|
|
5476
5534
|
constructor(
|
|
@@ -5544,11 +5602,15 @@ class EntityProcess {
|
|
|
5544
5602
|
].includes(className);
|
|
5545
5603
|
// console.log('doNothing', doNothing)
|
|
5546
5604
|
if (!doNothing) {
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5605
|
+
// TODO not needed ?
|
|
5606
|
+
// const cleaned = JSON10.cleaned(this.data, void 0, {
|
|
5607
|
+
// breadthWalk: true,
|
|
5608
|
+
// include,
|
|
5609
|
+
// });
|
|
5610
|
+
// decodeMappingForHeaderJson is handling nested objects ok
|
|
5611
|
+
this.entityMapping = decodeMappingForHeaderJson(this.data, {
|
|
5612
|
+
useFirstArrayItemClassNameForAllElements: !this.advancedManipulation,
|
|
5550
5613
|
});
|
|
5551
|
-
this.entityMapping = Mapping.decode(cleaned, !this.advancedManipulation);
|
|
5552
5614
|
this.response.set(Symbols.old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
|
|
5553
5615
|
if (this.advancedManipulation) {
|
|
5554
5616
|
this.response.set(Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
|
|
@@ -5789,10 +5851,21 @@ function TaonEntity(options) {
|
|
|
5789
5851
|
return function (constructor) {
|
|
5790
5852
|
options = options || {};
|
|
5791
5853
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5854
|
+
if (!options.className) {
|
|
5855
|
+
const nameForClass = constructor?.name || 'AnyClass';
|
|
5856
|
+
throw `Please define 'classname' property inside decorator of class '${nameForClass}':
|
|
5857
|
+
|
|
5858
|
+
@TaonEntity({
|
|
5859
|
+
className: '${nameForClass}'
|
|
5860
|
+
})
|
|
5861
|
+
class ${constructor?.name} {
|
|
5862
|
+
//...
|
|
5863
|
+
|
|
5864
|
+
`;
|
|
5865
|
+
}
|
|
5792
5866
|
ClassHelpers.setName(constructor, options?.className);
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
Mapping.DefaultModelWithMapping(void 0, {})(constructor);
|
|
5867
|
+
DefaultMapping(options?.defaultModelMapping)(constructor);
|
|
5868
|
+
DefaultModel(options.defaultModelMapping)(constructor);
|
|
5796
5869
|
Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
|
|
5797
5870
|
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
5798
5871
|
/* */
|
|
@@ -7908,9 +7981,9 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7908
7981
|
if (level === maxLevel) {
|
|
7909
7982
|
return [];
|
|
7910
7983
|
}
|
|
7911
|
-
const mapping =
|
|
7984
|
+
const mapping = decodeMappingForHeaderJson(target);
|
|
7912
7985
|
// console.log('mapping', mapping)
|
|
7913
|
-
const fieldNames =
|
|
7986
|
+
const fieldNames = Object.keys(mapping);
|
|
7914
7987
|
const checkExclude = _.isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
7915
7988
|
const checkInclude = _.isArray(keysPathesToInclude) && keysPathesToInclude.length > 0;
|
|
7916
7989
|
if (checkExclude && checkInclude) {
|