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
package/lib/endpoint-context.js
CHANGED
|
@@ -714,22 +714,17 @@ class EndpointContext {
|
|
|
714
714
|
}
|
|
715
715
|
return class extends TaonBaseClass {
|
|
716
716
|
// static ['_'] = TaonBaseClass['_'];
|
|
717
|
-
|
|
718
|
-
static [symbols_1.Symbols.orignalClass] = TaonBaseClass;
|
|
719
|
-
// @ts-ignore
|
|
717
|
+
static [lib_9.CoreModels.OrignalClassKey] = TaonBaseClass;
|
|
720
718
|
static [symbols_1.Symbols.fullClassNameStaticProperty] = `${ctx.contextName}.${className}`;
|
|
721
|
-
|
|
722
|
-
static [symbols_1.Symbols.classNameStaticProperty] = className;
|
|
719
|
+
static [lib_9.CoreModels.ClassNameStaticProperty] = className;
|
|
723
720
|
static [symbols_1.Symbols.ctxInClassOrClassObj] = ctx;
|
|
724
721
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
725
722
|
static __getFullPathForClass__(arr = []) {
|
|
726
723
|
const name = this[symbols_1.Symbols.fullClassNameStaticProperty];
|
|
727
724
|
arr.push(name);
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
this[
|
|
731
|
-
// @ts-ignore
|
|
732
|
-
this[symbols_1.Symbols.orignalClass].__getFullPathForClass__(arr);
|
|
725
|
+
if (this[lib_9.CoreModels.OrignalClassKey] &&
|
|
726
|
+
this[lib_9.CoreModels.OrignalClassKey].__getFullPathForClass__) {
|
|
727
|
+
this[lib_9.CoreModels.OrignalClassKey].__getFullPathForClass__(arr);
|
|
733
728
|
}
|
|
734
729
|
return arr.join('/');
|
|
735
730
|
}
|
|
@@ -780,7 +775,7 @@ class EndpointContext {
|
|
|
780
775
|
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
781
776
|
// }
|
|
782
777
|
className = className || key;
|
|
783
|
-
TaonBaseClass[
|
|
778
|
+
TaonBaseClass[lib_9.CoreModels.ClassNameStaticProperty] = className;
|
|
784
779
|
const clonedClass = this.cloneClassWithNewMetadata({
|
|
785
780
|
TaonBaseClass,
|
|
786
781
|
className,
|
|
@@ -1559,7 +1554,8 @@ class EndpointContext {
|
|
|
1559
1554
|
})).map(f => {
|
|
1560
1555
|
const [method, expressPath] = f.split(' ');
|
|
1561
1556
|
if (method.toUpperCase() === 'GET' && this.isRunningInsideDocker) {
|
|
1562
|
-
this.logRoutes &&
|
|
1557
|
+
this.logRoutes &&
|
|
1558
|
+
console.log(`apk add curl && curl http://localhost:${this.uriPort}${expressPath}`);
|
|
1563
1559
|
}
|
|
1564
1560
|
return (`\n### ${lib_13._.startCase(lib_13._.last(expressPath.split('/')))}\n` +
|
|
1565
1561
|
taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ' ', 10) +
|
|
@@ -1603,7 +1599,7 @@ class EndpointContext {
|
|
|
1603
1599
|
middlewares.forEach(middlewareInstanceName => {
|
|
1604
1600
|
const contextName = this.contextName;
|
|
1605
1601
|
const interceptorName = `${contextName}-${class_helpers_1.ClassHelpers.getName(middlewareInstanceName)}`;
|
|
1606
|
-
lib_3.Resource.
|
|
1602
|
+
lib_3.Resource.globalInterceptors.set(interceptorName, {
|
|
1607
1603
|
intercept: ({ req, next }) => {
|
|
1608
1604
|
const url = new url_1.URL(req.url);
|
|
1609
1605
|
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${contextName}/`)) {
|
|
@@ -1815,45 +1811,58 @@ class EndpointContext {
|
|
|
1815
1811
|
let tParams = req.params;
|
|
1816
1812
|
let tQuery = req.query;
|
|
1817
1813
|
if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY]) {
|
|
1814
|
+
//#region handle circural item in body params
|
|
1818
1815
|
try {
|
|
1819
1816
|
tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY])));
|
|
1820
1817
|
}
|
|
1821
1818
|
catch (e) { }
|
|
1819
|
+
//#endregion
|
|
1822
1820
|
}
|
|
1823
1821
|
if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]) {
|
|
1822
|
+
//#region handle circular items in query params
|
|
1824
1823
|
try {
|
|
1825
1824
|
tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM])));
|
|
1826
1825
|
}
|
|
1827
1826
|
catch (e) { }
|
|
1827
|
+
//#endregion
|
|
1828
1828
|
}
|
|
1829
1829
|
// make class instance from body
|
|
1830
1830
|
// console.log('req.headers', req.headers)
|
|
1831
1831
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1832
|
+
//#region encode entity or enties in body from header mapping
|
|
1832
1833
|
try {
|
|
1833
|
-
const
|
|
1834
|
-
tBody = lib_3.
|
|
1834
|
+
const mappinForEntityBody = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]));
|
|
1835
|
+
tBody = (0, lib_3.encodeMapping)(tBody, mappinForEntityBody);
|
|
1835
1836
|
}
|
|
1836
1837
|
catch (e) { }
|
|
1838
|
+
//#endregion
|
|
1837
1839
|
}
|
|
1838
1840
|
else {
|
|
1841
|
+
// TODO why do i need this ????
|
|
1842
|
+
//#region encode entity or enties in body from header mapping
|
|
1839
1843
|
Object.keys(tBody).forEach(paramName => {
|
|
1840
1844
|
try {
|
|
1841
|
-
const
|
|
1842
|
-
tBody[paramName] = lib_3.
|
|
1845
|
+
const mappingForEntityBodyForParam = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]));
|
|
1846
|
+
tBody[paramName] = (0, lib_3.encodeMapping)(tBody[paramName], mappingForEntityBodyForParam);
|
|
1843
1847
|
}
|
|
1844
1848
|
catch (e) { }
|
|
1845
1849
|
});
|
|
1850
|
+
//#endregion
|
|
1846
1851
|
}
|
|
1847
1852
|
// make class instance from query params
|
|
1848
1853
|
// console.log('req.headers', tQuery)
|
|
1849
1854
|
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1855
|
+
//#region encode entity or enties in query parms from header mapping
|
|
1850
1856
|
try {
|
|
1851
1857
|
const entity = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]));
|
|
1852
|
-
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(lib_3.
|
|
1858
|
+
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs((0, lib_3.encodeMapping)(tQuery, entity));
|
|
1853
1859
|
}
|
|
1854
1860
|
catch (e) { }
|
|
1861
|
+
//#endregion
|
|
1855
1862
|
}
|
|
1856
1863
|
else {
|
|
1864
|
+
// TODO why do i need this ????
|
|
1865
|
+
//#region encode entity or enties in query parms from header mapping
|
|
1857
1866
|
Object.keys(tQuery).forEach(queryParamName => {
|
|
1858
1867
|
try {
|
|
1859
1868
|
const entityForParam = JSON.parse(taon_helpers_1.TaonHelpers.firstStringOrElemFromArray(req.headers[`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
|
|
@@ -1865,13 +1874,15 @@ class EndpointContext {
|
|
|
1865
1874
|
}
|
|
1866
1875
|
catch (e) { }
|
|
1867
1876
|
}
|
|
1868
|
-
const afterEncoding = lib_3.
|
|
1877
|
+
const afterEncoding = (0, lib_3.encodeMapping)(beforeTransofrm, entityForParam);
|
|
1869
1878
|
tQuery[queryParamName] =
|
|
1870
1879
|
taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(afterEncoding);
|
|
1871
1880
|
}
|
|
1872
1881
|
catch (e) { }
|
|
1873
1882
|
});
|
|
1883
|
+
//#endregion
|
|
1874
1884
|
}
|
|
1885
|
+
//#region set proper arguments for backend function
|
|
1875
1886
|
Object.keys(methodConfig.parameters).forEach(paramName => {
|
|
1876
1887
|
let p = methodConfig.parameters[paramName];
|
|
1877
1888
|
if (p.paramType === 'Path' && tParams) {
|
|
@@ -1901,6 +1912,7 @@ class EndpointContext {
|
|
|
1901
1912
|
}
|
|
1902
1913
|
});
|
|
1903
1914
|
//#endregion
|
|
1915
|
+
//#endregion
|
|
1904
1916
|
const resolvedParams = args
|
|
1905
1917
|
.reverse()
|
|
1906
1918
|
.map(v => taon_helpers_1.TaonHelpers.tryTransformParam(v));
|
|
@@ -1917,8 +1929,7 @@ class EndpointContext {
|
|
|
1917
1929
|
return;
|
|
1918
1930
|
}
|
|
1919
1931
|
if (result instanceof Blob &&
|
|
1920
|
-
methodConfig.responseType ===
|
|
1921
|
-
'blob') {
|
|
1932
|
+
methodConfig.responseType === 'blob') {
|
|
1922
1933
|
// console.log('INSTANCE OF BLOB')
|
|
1923
1934
|
//#region processs blob result type
|
|
1924
1935
|
const blob = result;
|
|
@@ -1931,8 +1942,7 @@ class EndpointContext {
|
|
|
1931
1942
|
//#endregion
|
|
1932
1943
|
}
|
|
1933
1944
|
else if (lib_13._.isString(result) &&
|
|
1934
|
-
methodConfig.responseType ===
|
|
1935
|
-
'blob') {
|
|
1945
|
+
methodConfig.responseType === 'blob') {
|
|
1936
1946
|
// console.log('BASE64')
|
|
1937
1947
|
//#region process string buffer TODO refacetor
|
|
1938
1948
|
const img_base64 = result;
|
|
@@ -1951,7 +1961,7 @@ class EndpointContext {
|
|
|
1951
1961
|
}
|
|
1952
1962
|
else {
|
|
1953
1963
|
//#region process json request
|
|
1954
|
-
await entity_process_1.EntityProcess
|
|
1964
|
+
await new entity_process_1.EntityProcess(result, res).run();
|
|
1955
1965
|
//#endregion
|
|
1956
1966
|
}
|
|
1957
1967
|
}
|
|
@@ -2032,7 +2042,7 @@ class EndpointContext {
|
|
|
2032
2042
|
const middlewareName = class_helpers_1.ClassHelpers.getName(instance);
|
|
2033
2043
|
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
2034
2044
|
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
2035
|
-
lib_3.Resource.
|
|
2045
|
+
lib_3.Resource.methodsInterceptors.set(interceptorKey, {
|
|
2036
2046
|
intercept: ({ req, next }) => {
|
|
2037
2047
|
return instance.interceptClientMethod({
|
|
2038
2048
|
req,
|
|
@@ -2098,6 +2108,9 @@ class EndpointContext {
|
|
|
2098
2108
|
/* */
|
|
2099
2109
|
/* */
|
|
2100
2110
|
/* */
|
|
2111
|
+
/* */
|
|
2112
|
+
/* */
|
|
2113
|
+
/* */
|
|
2101
2114
|
});
|
|
2102
2115
|
received['observable'] = (0, rxjs_1.from)(received);
|
|
2103
2116
|
return {
|
|
@@ -2273,28 +2286,51 @@ class EndpointContext {
|
|
|
2273
2286
|
storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
2274
2287
|
const endpoints = storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG];
|
|
2275
2288
|
let rest;
|
|
2289
|
+
const requestHeaders = lib_3.RestHeaders.from({});
|
|
2276
2290
|
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
2277
|
-
let headers = {};
|
|
2278
2291
|
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
2279
|
-
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath,
|
|
2292
|
+
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath, {
|
|
2293
|
+
responseMapping: {
|
|
2294
|
+
entity: symbols_1.Symbols.old.MAPPING_CONFIG_HEADER,
|
|
2295
|
+
circular: symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
2296
|
+
},
|
|
2297
|
+
});
|
|
2298
|
+
requestHeaders.apply({
|
|
2280
2299
|
'Content-Type': methodConfig.contentType,
|
|
2281
2300
|
Accept: methodConfig.contentType,
|
|
2282
|
-
})
|
|
2301
|
+
});
|
|
2283
2302
|
}
|
|
2284
2303
|
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
2285
|
-
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath,
|
|
2304
|
+
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath, {
|
|
2305
|
+
responseMapping: {
|
|
2306
|
+
entity: symbols_1.Symbols.old.MAPPING_CONFIG_HEADER,
|
|
2307
|
+
circular: symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
2308
|
+
},
|
|
2309
|
+
});
|
|
2310
|
+
requestHeaders.apply({
|
|
2286
2311
|
'Content-Type': methodConfig.contentType,
|
|
2287
2312
|
Accept: methodConfig.contentType,
|
|
2288
2313
|
responsetypeaxios: methodConfig.responseType,
|
|
2289
|
-
})
|
|
2314
|
+
});
|
|
2290
2315
|
}
|
|
2291
2316
|
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
2292
|
-
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath,
|
|
2317
|
+
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath, {
|
|
2318
|
+
responseMapping: {
|
|
2319
|
+
entity: symbols_1.Symbols.old.MAPPING_CONFIG_HEADER,
|
|
2320
|
+
circular: symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
2321
|
+
},
|
|
2322
|
+
});
|
|
2323
|
+
requestHeaders.apply({
|
|
2293
2324
|
responsetypeaxios: methodConfig.responseType,
|
|
2294
|
-
})
|
|
2325
|
+
});
|
|
2295
2326
|
}
|
|
2296
2327
|
else {
|
|
2297
|
-
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath,
|
|
2328
|
+
rest = lib_3.Resource.create(ctx.uriOrigin, expressPath, {
|
|
2329
|
+
responseMapping: {
|
|
2330
|
+
entity: symbols_1.Symbols.old.MAPPING_CONFIG_HEADER,
|
|
2331
|
+
circular: symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
2332
|
+
},
|
|
2333
|
+
});
|
|
2298
2334
|
}
|
|
2299
2335
|
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
2300
2336
|
}
|
|
@@ -2323,47 +2359,60 @@ class EndpointContext {
|
|
|
2323
2359
|
//#endregion
|
|
2324
2360
|
throw new Error(errorMessage);
|
|
2325
2361
|
}
|
|
2362
|
+
const optionsDecodeHeader = {
|
|
2363
|
+
useFirstArrayItemClassNameForAllElements: true,
|
|
2364
|
+
};
|
|
2326
2365
|
if (currentParam.paramType === 'Path') {
|
|
2366
|
+
//#region handle path params
|
|
2327
2367
|
pathPrams[currentParam.paramName] = param;
|
|
2368
|
+
//#endregion
|
|
2328
2369
|
}
|
|
2329
2370
|
if (currentParam.paramType === 'Query') {
|
|
2371
|
+
//#region handle query params
|
|
2330
2372
|
if (currentParam.paramName) {
|
|
2331
|
-
const mapping = lib_3.
|
|
2373
|
+
const mapping = (0, lib_3.decodeMappingForHeaderJson)(param, optionsDecodeHeader);
|
|
2332
2374
|
if (mapping) {
|
|
2333
|
-
|
|
2375
|
+
requestHeaders.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2334
2376
|
}
|
|
2335
2377
|
queryParams[currentParam.paramName] = param;
|
|
2336
2378
|
}
|
|
2337
2379
|
else {
|
|
2338
|
-
const mapping = lib_3.
|
|
2380
|
+
const mapping = (0, lib_3.decodeMappingForHeaderJson)(param, optionsDecodeHeader);
|
|
2339
2381
|
if (mapping) {
|
|
2340
|
-
|
|
2382
|
+
requestHeaders.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2341
2383
|
}
|
|
2342
2384
|
queryParams = lib_13._.cloneDeep(param);
|
|
2343
2385
|
}
|
|
2386
|
+
//#endregion
|
|
2344
2387
|
}
|
|
2345
2388
|
if (currentParam.paramType === 'Header') {
|
|
2389
|
+
//#region handler header params
|
|
2346
2390
|
if (currentParam.paramName) {
|
|
2347
2391
|
if (currentParam.paramName === symbols_1.Symbols.old.MDC_KEY) {
|
|
2348
2392
|
// parese MDC
|
|
2349
|
-
|
|
2393
|
+
requestHeaders.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
2350
2394
|
}
|
|
2351
2395
|
else {
|
|
2352
|
-
|
|
2396
|
+
requestHeaders.set(currentParam.paramName, param);
|
|
2353
2397
|
}
|
|
2354
2398
|
}
|
|
2355
2399
|
else {
|
|
2356
2400
|
for (let header in param) {
|
|
2357
|
-
|
|
2401
|
+
requestHeaders.set(header, param[header]);
|
|
2358
2402
|
}
|
|
2359
2403
|
}
|
|
2404
|
+
//#endregion
|
|
2360
2405
|
}
|
|
2361
2406
|
if (currentParam.paramType === 'Cookie') {
|
|
2407
|
+
//#region handle cookie params
|
|
2362
2408
|
lib_3.Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
2409
|
+
//#endregion
|
|
2363
2410
|
}
|
|
2364
2411
|
if (currentParam.paramType === 'Body') {
|
|
2412
|
+
//#region handle body params
|
|
2365
2413
|
if (currentParam.paramName) {
|
|
2366
2414
|
if (class_helpers_1.ClassHelpers.getName(bodyObject) === 'FormData') {
|
|
2415
|
+
//#region prevent posting/putting not full body as FormData
|
|
2367
2416
|
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
2368
2417
|
Use this:
|
|
2369
2418
|
// ...
|
|
@@ -2375,45 +2424,52 @@ instead
|
|
|
2375
2424
|
(@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
|
|
2376
2425
|
// ...
|
|
2377
2426
|
`);
|
|
2427
|
+
//#endregion
|
|
2378
2428
|
}
|
|
2379
|
-
const mapping = lib_3.
|
|
2429
|
+
const mapping = (0, lib_3.decodeMappingForHeaderJson)(param, optionsDecodeHeader);
|
|
2380
2430
|
if (mapping) {
|
|
2381
|
-
|
|
2431
|
+
requestHeaders.set(`${symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2382
2432
|
}
|
|
2383
2433
|
bodyObject[currentParam.paramName] = param;
|
|
2384
2434
|
}
|
|
2385
2435
|
else {
|
|
2386
|
-
const mapping = lib_3.
|
|
2436
|
+
const mapping = (0, lib_3.decodeMappingForHeaderJson)(param, optionsDecodeHeader);
|
|
2387
2437
|
if (mapping) {
|
|
2388
|
-
|
|
2438
|
+
requestHeaders.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
2389
2439
|
}
|
|
2390
2440
|
bodyObject = param;
|
|
2391
2441
|
}
|
|
2442
|
+
//#endregion
|
|
2392
2443
|
}
|
|
2393
2444
|
});
|
|
2394
2445
|
if (typeof bodyObject === 'object' &&
|
|
2395
2446
|
class_helpers_1.ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
2447
|
+
//#region handle circular objects in body params
|
|
2396
2448
|
let circuralFromItem = [];
|
|
2397
2449
|
bodyObject = lib_1.JSON10.parse(lib_1.JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
2398
2450
|
circuralFromItem = circs;
|
|
2399
2451
|
}));
|
|
2400
|
-
|
|
2452
|
+
requestHeaders.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, lib_1.JSON10.stringify(circuralFromItem));
|
|
2453
|
+
//#endregion
|
|
2401
2454
|
}
|
|
2402
2455
|
if (typeof queryParams === 'object') {
|
|
2456
|
+
//#region handle circular objects in query params
|
|
2403
2457
|
let circuralFromQueryParams = [];
|
|
2404
2458
|
queryParams = lib_1.JSON10.parse(lib_1.JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
2405
2459
|
circuralFromQueryParams = circs;
|
|
2406
2460
|
}));
|
|
2407
|
-
|
|
2461
|
+
requestHeaders.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, lib_1.JSON10.stringify(circuralFromQueryParams));
|
|
2462
|
+
//#endregion
|
|
2408
2463
|
}
|
|
2409
2464
|
//#endregion
|
|
2410
2465
|
const httpResultObj = {
|
|
2411
2466
|
get received() {
|
|
2412
|
-
return rest
|
|
2467
|
+
return rest
|
|
2468
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams]);
|
|
2413
2469
|
},
|
|
2414
2470
|
request(axiosConfig) {
|
|
2415
2471
|
return rest
|
|
2416
|
-
.model(pathPrams)[method](bodyObject, [queryParams], axiosConfig);
|
|
2472
|
+
.model(pathPrams, { headers: requestHeaders })[method](bodyObject, [queryParams], axiosConfig);
|
|
2417
2473
|
},
|
|
2418
2474
|
};
|
|
2419
2475
|
return httpResultObj;
|