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, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath, config,
|
|
2
|
+
import { _, CoreModels, Utils, UtilsMigrations, Helpers, UtilsOs, crossPlatformPath, config, UtilsTerminal } from 'tnp-core/websql';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { JSON10 } from 'json10/websql';
|
|
5
5
|
import { walk } from 'lodash-walk-object/websql';
|
|
6
|
-
import { RestResponseWrapper, Resource,
|
|
6
|
+
import { RestResponseWrapper, Resource, HttpResponse, RestHeaders, decodeMappingForHeaderJson, DefaultMapping, DefaultModel, HttpResponseError } from 'ng2-rest/websql';
|
|
7
7
|
import { Observable, Subject, from } from 'rxjs';
|
|
8
|
-
import {
|
|
8
|
+
import { Table, TableIndex, EventSubscriber, Entity, DataSource, Column, PrimaryGeneratedColumn, VersionColumn, CreateDateColumn } from 'taon-typeorm/websql';
|
|
9
9
|
export { AfterInsert, AfterLoad, AfterRecover, AfterRemove, AfterSoftRemove, AfterUpdate, BeforeInsert, BeforeRecover, BeforeRemove, BeforeSoftRemove, BeforeUpdate, Column, Connection, CreateDateColumn, Column as CustomColumn, DeleteDateColumn, Generated, Generated as GeneratedColumn, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Repository, TreeChildren, TreeParent, UpdateDateColumn, VersionColumn, VirtualColumn } from 'taon-typeorm/websql';
|
|
10
10
|
import * as i0 from '@angular/core';
|
|
11
11
|
import { InjectionToken, inject as inject$1, PLATFORM_ID, Injectable, ViewContainerRef, ViewChild, Component } from '@angular/core';
|
|
12
|
-
import {
|
|
12
|
+
import { CLASS } from 'typescript-class-helpers/websql';
|
|
13
13
|
import * as JSON5 from 'json5';
|
|
14
14
|
import { io } from 'socket.io-client';
|
|
15
15
|
import { __decorate, __metadata, __param } from 'tslib';
|
|
@@ -228,9 +228,7 @@ class Realtime {
|
|
|
228
228
|
var Symbols;
|
|
229
229
|
(function (Symbols) {
|
|
230
230
|
Symbols.ctxInClassOrClassObj = Symbol();
|
|
231
|
-
Symbols.classNameStaticProperty = SYMBOL.ClassNameStaticProperty;
|
|
232
231
|
Symbols.fullClassNameStaticProperty = `$$fullclassName$$`;
|
|
233
|
-
Symbols.orignalClass = OrignalClassKey;
|
|
234
232
|
Symbols.orignalClassClonesObj = `$$originalClassClonesObj$$`;
|
|
235
233
|
Symbols.classMethodsNames = `$$classMethodsNames$$`;
|
|
236
234
|
Symbols.REALTIME = new Realtime();
|
|
@@ -383,14 +381,14 @@ var ClassHelpers;
|
|
|
383
381
|
console.error('OBJECT OR CLASS', classFnOrObject);
|
|
384
382
|
throw new Error(`Cannot get name from this object or class.`);
|
|
385
383
|
}
|
|
386
|
-
return ((classFnOrObject[
|
|
387
|
-
? classFnOrObject[
|
|
388
|
-
: classFnOrObject?.constructor[
|
|
384
|
+
return ((classFnOrObject[CoreModels.ClassNameStaticProperty]
|
|
385
|
+
? classFnOrObject[CoreModels.ClassNameStaticProperty]
|
|
386
|
+
: classFnOrObject?.constructor[CoreModels.ClassNameStaticProperty]) ||
|
|
389
387
|
(_.isFunction(classFnOrObject) ? CLASS.getName(classFnOrObject) : void 0));
|
|
390
388
|
};
|
|
391
389
|
//#endregion
|
|
392
390
|
ClassHelpers.getOrginalClass = (classFnOrObject) => {
|
|
393
|
-
const org = classFnOrObject[
|
|
391
|
+
const org = classFnOrObject[CoreModels.OrignalClassKey];
|
|
394
392
|
if (!org) {
|
|
395
393
|
return classFnOrObject;
|
|
396
394
|
}
|
|
@@ -412,8 +410,11 @@ var ClassHelpers;
|
|
|
412
410
|
ClassHelpers.getUniqueKey = (classFnOrObject) => {
|
|
413
411
|
const classFn = _.isFunction(classFnOrObject)
|
|
414
412
|
? classFnOrObject
|
|
415
|
-
: classFnOrObject
|
|
413
|
+
: classFnOrObject?.constructor;
|
|
416
414
|
const config = Reflect.getMetadata(Symbols.metadata.options.entity, classFn);
|
|
415
|
+
if (!config) {
|
|
416
|
+
return void 0;
|
|
417
|
+
}
|
|
417
418
|
return config.uniqueKeyProp;
|
|
418
419
|
};
|
|
419
420
|
//#endregion
|
|
@@ -437,7 +438,7 @@ var ClassHelpers;
|
|
|
437
438
|
ClassHelpers.setName = (target, className) => {
|
|
438
439
|
// console.log('setName', className, target.name)
|
|
439
440
|
Validators.classNameVlidation(className, target);
|
|
440
|
-
target[
|
|
441
|
+
target[CoreModels.ClassNameStaticProperty] = className;
|
|
441
442
|
};
|
|
442
443
|
//#endregion
|
|
443
444
|
//#region has parent with class name
|
|
@@ -1298,7 +1299,7 @@ class RealtimeClient {
|
|
|
1298
1299
|
* ...
|
|
1299
1300
|
*/
|
|
1300
1301
|
listenChangesEntity(entityClassFnOrObj, options) {
|
|
1301
|
-
options = options || {};
|
|
1302
|
+
options = _.cloneDeep(options || {});
|
|
1302
1303
|
if (_.isObject(entityClassFnOrObj)) {
|
|
1303
1304
|
const orgObj = entityClassFnOrObj;
|
|
1304
1305
|
entityClassFnOrObj =
|
|
@@ -2534,23 +2535,18 @@ class EndpointContext {
|
|
|
2534
2535
|
// You can override prototype properties or methods here if needed
|
|
2535
2536
|
// static properties override allowed
|
|
2536
2537
|
}
|
|
2537
|
-
static { _a =
|
|
2538
|
-
// @ts-ignore
|
|
2538
|
+
static { _a = CoreModels.OrignalClassKey, _b = Symbols.fullClassNameStaticProperty, _c = CoreModels.ClassNameStaticProperty, _d = Symbols.ctxInClassOrClassObj, _e = Symbols.ctxInClassOrClassObj; }
|
|
2539
2539
|
static { this[_a] = TaonBaseClass; }
|
|
2540
|
-
// @ts-ignore
|
|
2541
2540
|
static { this[_b] = `${ctx.contextName}.${className}`; }
|
|
2542
|
-
// @ts-ignore
|
|
2543
2541
|
static { this[_c] = className; }
|
|
2544
2542
|
static { this[_d] = ctx; }
|
|
2545
2543
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
2546
2544
|
static __getFullPathForClass__(arr = []) {
|
|
2547
2545
|
const name = this[Symbols.fullClassNameStaticProperty];
|
|
2548
2546
|
arr.push(name);
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
this[
|
|
2552
|
-
// @ts-ignore
|
|
2553
|
-
this[Symbols.orignalClass].__getFullPathForClass__(arr);
|
|
2547
|
+
if (this[CoreModels.OrignalClassKey] &&
|
|
2548
|
+
this[CoreModels.OrignalClassKey].__getFullPathForClass__) {
|
|
2549
|
+
this[CoreModels.OrignalClassKey].__getFullPathForClass__(arr);
|
|
2554
2550
|
}
|
|
2555
2551
|
return arr.join('/');
|
|
2556
2552
|
}
|
|
@@ -2600,7 +2596,7 @@ class EndpointContext {
|
|
|
2600
2596
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
2601
2597
|
// }
|
|
2602
2598
|
className = className || key;
|
|
2603
|
-
TaonBaseClass[
|
|
2599
|
+
TaonBaseClass[CoreModels.ClassNameStaticProperty] = className;
|
|
2604
2600
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
2605
2601
|
TaonBaseClass,
|
|
2606
2602
|
className,
|
|
@@ -3877,7 +3873,8 @@ class EndpointContext {
|
|
|
3877
3873
|
})).map(f => {
|
|
3878
3874
|
const [method, expressPath] = f.split(' ');
|
|
3879
3875
|
if (method.toUpperCase() === 'GET' && this.isRunningInsideDocker) {
|
|
3880
|
-
this.logRoutes &&
|
|
3876
|
+
this.logRoutes &&
|
|
3877
|
+
console.log(`apk add curl && curl http://localhost:${this.uriPort}${expressPath}`);
|
|
3881
3878
|
}
|
|
3882
3879
|
return (`\n### ${_.startCase(_.last(expressPath.split('/')))}\n` +
|
|
3883
3880
|
TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
@@ -3919,7 +3916,7 @@ class EndpointContext {
|
|
|
3919
3916
|
middlewares.forEach(middlewareInstanceName => {
|
|
3920
3917
|
const contextName = this.contextName;
|
|
3921
3918
|
const interceptorName = `${contextName}-${ClassHelpers.getName(middlewareInstanceName)}`;
|
|
3922
|
-
Resource.
|
|
3919
|
+
Resource.globalInterceptors.set(interceptorName, {
|
|
3923
3920
|
intercept: ({ req, next }) => {
|
|
3924
3921
|
const url = new URL(req.url);
|
|
3925
3922
|
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${apiPrefix}/${contextName}/`)) {
|
|
@@ -4149,6 +4146,9 @@ class EndpointContext {
|
|
|
4149
4146
|
/* */
|
|
4150
4147
|
/* */
|
|
4151
4148
|
/* */
|
|
4149
|
+
/* */
|
|
4150
|
+
/* */
|
|
4151
|
+
/* */
|
|
4152
4152
|
}
|
|
4153
4153
|
if (!this.isRemoteHost) {
|
|
4154
4154
|
//#region apply dummy websql express routers
|
|
@@ -4375,6 +4375,24 @@ class EndpointContext {
|
|
|
4375
4375
|
/* */
|
|
4376
4376
|
/* */
|
|
4377
4377
|
/* */
|
|
4378
|
+
/* */
|
|
4379
|
+
/* */
|
|
4380
|
+
/* */
|
|
4381
|
+
/* */
|
|
4382
|
+
/* */
|
|
4383
|
+
/* */
|
|
4384
|
+
/* */
|
|
4385
|
+
/* */
|
|
4386
|
+
/* */
|
|
4387
|
+
/* */
|
|
4388
|
+
/* */
|
|
4389
|
+
/* */
|
|
4390
|
+
/* */
|
|
4391
|
+
/* */
|
|
4392
|
+
/* */
|
|
4393
|
+
/* */
|
|
4394
|
+
/* */
|
|
4395
|
+
/* */
|
|
4378
4396
|
}
|
|
4379
4397
|
return {
|
|
4380
4398
|
expressPath: expressPath,
|
|
@@ -4436,7 +4454,7 @@ class EndpointContext {
|
|
|
4436
4454
|
const middlewareName = ClassHelpers.getName(instance);
|
|
4437
4455
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
4438
4456
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
4439
|
-
Resource.
|
|
4457
|
+
Resource.methodsInterceptors.set(interceptorKey, {
|
|
4440
4458
|
intercept: ({ req, next }) => {
|
|
4441
4459
|
return instance.interceptClientMethod({
|
|
4442
4460
|
req,
|
|
@@ -4472,15 +4490,15 @@ class EndpointContext {
|
|
|
4472
4490
|
console.log({ responseData });
|
|
4473
4491
|
try {
|
|
4474
4492
|
const body = res;
|
|
4475
|
-
|
|
4476
|
-
body: void 0,
|
|
4477
|
-
isArray: void 0,
|
|
4478
|
-
method: methodConfig.type,
|
|
4479
|
-
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4480
|
-
}${methodConfig.path} `,
|
|
4481
|
-
}, Helpers.isBlob(body) || _.isString(body)
|
|
4493
|
+
const responseStrinOrBlob = Helpers.isBlob(body) || _.isString(body)
|
|
4482
4494
|
? body
|
|
4483
|
-
: JSON.stringify(body)
|
|
4495
|
+
: JSON.stringify(body);
|
|
4496
|
+
res = new HttpResponse(`${ctx.uriOrigin}${'' // TODO express path
|
|
4497
|
+
}${methodConfig.path} `, methodConfig.type, responseStrinOrBlob, RestHeaders.from(headers), 200, {
|
|
4498
|
+
// responseMapping: {
|
|
4499
|
+
// // entity: ()=> TODO for electron
|
|
4500
|
+
// },
|
|
4501
|
+
}, false);
|
|
4484
4502
|
resolve(res);
|
|
4485
4503
|
}
|
|
4486
4504
|
catch (error) {
|
|
@@ -4588,15 +4606,12 @@ class EndpointContext {
|
|
|
4588
4606
|
res = await res.received;
|
|
4589
4607
|
}
|
|
4590
4608
|
const body = res;
|
|
4591
|
-
|
|
4592
|
-
body: void 0,
|
|
4593
|
-
isArray: void 0,
|
|
4594
|
-
method: methodConfig.type,
|
|
4595
|
-
url: `${ctx.uriOrigin}${'' // TODO express path
|
|
4596
|
-
}${methodConfig.path} `,
|
|
4597
|
-
}, Helpers.isBlob(body) || _.isString(body)
|
|
4609
|
+
const stringOrBlobData = Helpers.isBlob(body) || _.isString(body)
|
|
4598
4610
|
? body
|
|
4599
|
-
: JSON.stringify(body)
|
|
4611
|
+
: JSON.stringify(body);
|
|
4612
|
+
// TODO SHOULD BE IMPLEMENTED IN NG2-REST
|
|
4613
|
+
res = new HttpResponse(`${ctx.uriOrigin}${'' // TODO express path
|
|
4614
|
+
}${methodConfig.path} `, methodConfig.type, stringOrBlobData, RestHeaders.from(headers), 200, {}, false);
|
|
4600
4615
|
// TODO blob should be blob not json
|
|
4601
4616
|
// console.log('NEXT', res);
|
|
4602
4617
|
// target.prototype[methodConfig.methodName][subjectHandler].next(res);
|
|
@@ -4641,28 +4656,51 @@ class EndpointContext {
|
|
|
4641
4656
|
storage[Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
4642
4657
|
const endpoints = storage[Symbols.old.ENDPOINT_META_CONFIG];
|
|
4643
4658
|
let rest;
|
|
4659
|
+
const requestHeaders = RestHeaders.from({});
|
|
4644
4660
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
4645
|
-
let headers = {};
|
|
4646
4661
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
4647
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4662
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4663
|
+
responseMapping: {
|
|
4664
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4665
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4666
|
+
},
|
|
4667
|
+
});
|
|
4668
|
+
requestHeaders.apply({
|
|
4648
4669
|
'Content-Type': methodConfig.contentType,
|
|
4649
4670
|
Accept: methodConfig.contentType,
|
|
4650
|
-
})
|
|
4671
|
+
});
|
|
4651
4672
|
}
|
|
4652
4673
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
4653
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4674
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4675
|
+
responseMapping: {
|
|
4676
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4677
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4678
|
+
},
|
|
4679
|
+
});
|
|
4680
|
+
requestHeaders.apply({
|
|
4654
4681
|
'Content-Type': methodConfig.contentType,
|
|
4655
4682
|
Accept: methodConfig.contentType,
|
|
4656
4683
|
responsetypeaxios: methodConfig.responseType,
|
|
4657
|
-
})
|
|
4684
|
+
});
|
|
4658
4685
|
}
|
|
4659
4686
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
4660
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4687
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4688
|
+
responseMapping: {
|
|
4689
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4690
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4691
|
+
},
|
|
4692
|
+
});
|
|
4693
|
+
requestHeaders.apply({
|
|
4661
4694
|
responsetypeaxios: methodConfig.responseType,
|
|
4662
|
-
})
|
|
4695
|
+
});
|
|
4663
4696
|
}
|
|
4664
4697
|
else {
|
|
4665
|
-
rest = Resource.create(ctx.uriOrigin, expressPath,
|
|
4698
|
+
rest = Resource.create(ctx.uriOrigin, expressPath, {
|
|
4699
|
+
responseMapping: {
|
|
4700
|
+
entity: Symbols.old.MAPPING_CONFIG_HEADER,
|
|
4701
|
+
circular: Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
4702
|
+
},
|
|
4703
|
+
});
|
|
4666
4704
|
}
|
|
4667
4705
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
4668
4706
|
}
|
|
@@ -4690,47 +4728,60 @@ class EndpointContext {
|
|
|
4690
4728
|
/* */
|
|
4691
4729
|
throw new Error(errorMessage);
|
|
4692
4730
|
}
|
|
4731
|
+
const optionsDecodeHeader = {
|
|
4732
|
+
useFirstArrayItemClassNameForAllElements: true,
|
|
4733
|
+
};
|
|
4693
4734
|
if (currentParam.paramType === 'Path') {
|
|
4735
|
+
//#region handle path params
|
|
4694
4736
|
pathPrams[currentParam.paramName] = param;
|
|
4737
|
+
//#endregion
|
|
4695
4738
|
}
|
|
4696
4739
|
if (currentParam.paramType === 'Query') {
|
|
4740
|
+
//#region handle query params
|
|
4697
4741
|
if (currentParam.paramName) {
|
|
4698
|
-
const mapping =
|
|
4742
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4699
4743
|
if (mapping) {
|
|
4700
|
-
|
|
4744
|
+
requestHeaders.set(`${Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4701
4745
|
}
|
|
4702
4746
|
queryParams[currentParam.paramName] = param;
|
|
4703
4747
|
}
|
|
4704
4748
|
else {
|
|
4705
|
-
const mapping =
|
|
4749
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4706
4750
|
if (mapping) {
|
|
4707
|
-
|
|
4751
|
+
requestHeaders.set(Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
4708
4752
|
}
|
|
4709
4753
|
queryParams = _.cloneDeep(param);
|
|
4710
4754
|
}
|
|
4755
|
+
//#endregion
|
|
4711
4756
|
}
|
|
4712
4757
|
if (currentParam.paramType === 'Header') {
|
|
4758
|
+
//#region handler header params
|
|
4713
4759
|
if (currentParam.paramName) {
|
|
4714
4760
|
if (currentParam.paramName === Symbols.old.MDC_KEY) {
|
|
4715
4761
|
// parese MDC
|
|
4716
|
-
|
|
4762
|
+
requestHeaders.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
4717
4763
|
}
|
|
4718
4764
|
else {
|
|
4719
|
-
|
|
4765
|
+
requestHeaders.set(currentParam.paramName, param);
|
|
4720
4766
|
}
|
|
4721
4767
|
}
|
|
4722
4768
|
else {
|
|
4723
4769
|
for (let header in param) {
|
|
4724
|
-
|
|
4770
|
+
requestHeaders.set(header, param[header]);
|
|
4725
4771
|
}
|
|
4726
4772
|
}
|
|
4773
|
+
//#endregion
|
|
4727
4774
|
}
|
|
4728
4775
|
if (currentParam.paramType === 'Cookie') {
|
|
4776
|
+
//#region handle cookie params
|
|
4729
4777
|
Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
4778
|
+
//#endregion
|
|
4730
4779
|
}
|
|
4731
4780
|
if (currentParam.paramType === 'Body') {
|
|
4781
|
+
//#region handle body params
|
|
4732
4782
|
if (currentParam.paramName) {
|
|
4733
4783
|
if (ClassHelpers.getName(bodyObject) === 'FormData') {
|
|
4784
|
+
//#region prevent posting/putting not full body as FormData
|
|
4734
4785
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
4735
4786
|
Use this:
|
|
4736
4787
|
// ...
|
|
@@ -4742,45 +4793,52 @@ instead
|
|
|
4742
4793
|
(@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
|
|
4743
4794
|
// ...
|
|
4744
4795
|
`);
|
|
4796
|
+
//#endregion
|
|
4745
4797
|
}
|
|
4746
|
-
const mapping =
|
|
4798
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4747
4799
|
if (mapping) {
|
|
4748
|
-
|
|
4800
|
+
requestHeaders.set(`${Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
4749
4801
|
}
|
|
4750
4802
|
bodyObject[currentParam.paramName] = param;
|
|
4751
4803
|
}
|
|
4752
4804
|
else {
|
|
4753
|
-
const mapping =
|
|
4805
|
+
const mapping = decodeMappingForHeaderJson(param, optionsDecodeHeader);
|
|
4754
4806
|
if (mapping) {
|
|
4755
|
-
|
|
4807
|
+
requestHeaders.set(Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
4756
4808
|
}
|
|
4757
4809
|
bodyObject = param;
|
|
4758
4810
|
}
|
|
4811
|
+
//#endregion
|
|
4759
4812
|
}
|
|
4760
4813
|
});
|
|
4761
4814
|
if (typeof bodyObject === 'object' &&
|
|
4762
4815
|
ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
4816
|
+
//#region handle circular objects in body params
|
|
4763
4817
|
let circuralFromItem = [];
|
|
4764
4818
|
bodyObject = JSON10.parse(JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
4765
4819
|
circuralFromItem = circs;
|
|
4766
4820
|
}));
|
|
4767
|
-
|
|
4821
|
+
requestHeaders.set(Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, JSON10.stringify(circuralFromItem));
|
|
4822
|
+
//#endregion
|
|
4768
4823
|
}
|
|
4769
4824
|
if (typeof queryParams === 'object') {
|
|
4825
|
+
//#region handle circular objects in query params
|
|
4770
4826
|
let circuralFromQueryParams = [];
|
|
4771
4827
|
queryParams = JSON10.parse(JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
4772
4828
|
circuralFromQueryParams = circs;
|
|
4773
4829
|
}));
|
|
4774
|
-
|
|
4830
|
+
requestHeaders.set(Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, JSON10.stringify(circuralFromQueryParams));
|
|
4831
|
+
//#endregion
|
|
4775
4832
|
}
|
|
4776
4833
|
//#endregion
|
|
4777
4834
|
const httpResultObj = {
|
|
4778
4835
|
get received() {
|
|
4779
|
-
return rest
|
|
4836
|
+
return rest
|
|
4837
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams]);
|
|
4780
4838
|
},
|
|
4781
4839
|
request(axiosConfig) {
|
|
4782
4840
|
return rest
|
|
4783
|
-
.model(pathPrams)[method](bodyObject, [queryParams], axiosConfig);
|
|
4841
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams], axiosConfig);
|
|
4784
4842
|
},
|
|
4785
4843
|
};
|
|
4786
4844
|
return httpResultObj;
|
|
@@ -5175,10 +5233,6 @@ const singleTransform = (json) => {
|
|
|
5175
5233
|
};
|
|
5176
5234
|
//#endregion
|
|
5177
5235
|
class EntityProcess {
|
|
5178
|
-
//#region init
|
|
5179
|
-
static async init(result, response) {
|
|
5180
|
-
return await new EntityProcess(result, response).run();
|
|
5181
|
-
}
|
|
5182
5236
|
//#endregion
|
|
5183
5237
|
//#region constructor
|
|
5184
5238
|
constructor(
|
|
@@ -5252,11 +5306,15 @@ class EntityProcess {
|
|
|
5252
5306
|
].includes(className);
|
|
5253
5307
|
// console.log('doNothing', doNothing)
|
|
5254
5308
|
if (!doNothing) {
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5309
|
+
// TODO not needed ?
|
|
5310
|
+
// const cleaned = JSON10.cleaned(this.data, void 0, {
|
|
5311
|
+
// breadthWalk: true,
|
|
5312
|
+
// include,
|
|
5313
|
+
// });
|
|
5314
|
+
// decodeMappingForHeaderJson is handling nested objects ok
|
|
5315
|
+
this.entityMapping = decodeMappingForHeaderJson(this.data, {
|
|
5316
|
+
useFirstArrayItemClassNameForAllElements: !this.advancedManipulation,
|
|
5258
5317
|
});
|
|
5259
|
-
this.entityMapping = Mapping.decode(cleaned, !this.advancedManipulation);
|
|
5260
5318
|
this.response.set(Symbols.old.MAPPING_CONFIG_HEADER, JSON.stringify(this.entityMapping));
|
|
5261
5319
|
if (this.advancedManipulation) {
|
|
5262
5320
|
this.response.set(Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, JSON.stringify(this.circural));
|
|
@@ -5682,10 +5740,21 @@ function TaonEntity(options) {
|
|
|
5682
5740
|
return function (constructor) {
|
|
5683
5741
|
options = options || {};
|
|
5684
5742
|
options.uniqueKeyProp = options.uniqueKeyProp || 'id';
|
|
5743
|
+
if (!options.className) {
|
|
5744
|
+
const nameForClass = constructor?.name || 'AnyClass';
|
|
5745
|
+
throw `Please define 'classname' property inside decorator of class '${nameForClass}':
|
|
5746
|
+
|
|
5747
|
+
@TaonEntity({
|
|
5748
|
+
className: '${nameForClass}'
|
|
5749
|
+
})
|
|
5750
|
+
class ${constructor?.name} {
|
|
5751
|
+
//...
|
|
5752
|
+
|
|
5753
|
+
`;
|
|
5754
|
+
}
|
|
5685
5755
|
ClassHelpers.setName(constructor, options?.className);
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
Mapping.DefaultModelWithMapping(void 0, {})(constructor);
|
|
5756
|
+
DefaultMapping(options?.defaultModelMapping)(constructor);
|
|
5757
|
+
DefaultModel(options.defaultModelMapping)(constructor);
|
|
5689
5758
|
Reflect.defineMetadata(Symbols.metadata.options.entity, options, constructor);
|
|
5690
5759
|
Reflect.defineMetadata(Symbols.metadata.className, options?.className || constructor.name, constructor);
|
|
5691
5760
|
//#region @websql
|
|
@@ -7801,9 +7870,9 @@ function getFromlyConfigFor(target, options = {}) {
|
|
|
7801
7870
|
if (level === maxLevel) {
|
|
7802
7871
|
return [];
|
|
7803
7872
|
}
|
|
7804
|
-
const mapping =
|
|
7873
|
+
const mapping = decodeMappingForHeaderJson(target);
|
|
7805
7874
|
// console.log('mapping', mapping)
|
|
7806
|
-
const fieldNames =
|
|
7875
|
+
const fieldNames = Object.keys(mapping);
|
|
7807
7876
|
const checkExclude = _.isArray(keysPathesToExclude) && keysPathesToExclude.length > 0;
|
|
7808
7877
|
const checkInclude = _.isArray(keysPathesToInclude) && keysPathesToInclude.length > 0;
|
|
7809
7878
|
if (checkExclude && checkInclude) {
|