ng2-rest 21.0.17 → 21.0.18
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/ng2-rest-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser-prod/fesm2022/ng2-rest-browser.mjs +28 -28
- package/browser-prod/fesm2022/ng2-rest-browser.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/ng2-rest-browser.d.ts +103 -103
- package/browser-prod.split-namespaces.json +62 -62
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +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/helpers.d.ts +3 -3
- package/lib-prod/helpers.js +2 -2
- package/lib-prod/helpers.js.map +1 -1
- package/lib-prod/mapping.d.ts +6 -6
- package/lib-prod/mapping.js +14 -14
- package/lib-prod/mapping.js.map +1 -1
- package/lib-prod/models.d.ts +54 -54
- package/lib-prod/models.js +17 -17
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/other/simple-resource.d.ts +11 -11
- package/lib-prod/other/simple-resource.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/params.d.ts +2 -2
- package/lib-prod/params.js.map +1 -1
- package/lib-prod/resource-service.d.ts +7 -7
- package/lib-prod/resource-service.js.map +1 -1
- package/lib-prod/rest-request.d.ts +8 -8
- package/lib-prod/rest-request.js +3 -3
- package/lib-prod/rest-request.js.map +1 -1
- package/lib-prod/rest.class.d.ts +18 -18
- package/lib-prod/rest.class.js.map +1 -1
- package/lib-prod.split-namespaces.json +62 -62
- package/package.json +1 -1
- package/websql/fesm2022/ng2-rest-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/fesm2022/ng2-rest-websql.mjs +28 -28
- package/websql-prod/fesm2022/ng2-rest-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/ng2-rest-websql.d.ts +103 -103
- package/websql-prod.split-namespaces.json +62 -62
package/websql/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from, firstValueFrom, Subject, Observable } from 'rxjs';
|
|
2
2
|
import { diffChars } from 'diff';
|
|
3
|
-
import { _,
|
|
3
|
+
import { _, UtilsOs__NS__isBrowser, CoreHelpers, CoreModels__NS__TaonHttpErrorCustomProp, Helpers as Helpers$1, UtilsOs__NS__isSSRMode } from 'tnp-core/websql-prod';
|
|
4
4
|
import { Log, Level } from 'ng2-logger/websql-prod';
|
|
5
5
|
import { walk } from 'lodash-walk-object/websql-prod';
|
|
6
6
|
import { CLASS, SYMBOL } from 'typescript-class-helpers/websql-prod';
|
|
@@ -36,7 +36,7 @@ class Cookie {
|
|
|
36
36
|
|
|
37
37
|
/* */
|
|
38
38
|
//namespace Mapping
|
|
39
|
-
function
|
|
39
|
+
function Mapping__NS__decode(json, autodetect = false) {
|
|
40
40
|
// console.log('DECODE isBrowser', HelpersLog.isBrowser)
|
|
41
41
|
if (_.isUndefined(json)) {
|
|
42
42
|
return void 0;
|
|
@@ -47,12 +47,12 @@ function Mapping_decode(json, autodetect = false) {
|
|
|
47
47
|
}
|
|
48
48
|
return mapping;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Mapping__NS__encode(json, mapping, circular = []) {
|
|
51
51
|
if (_.isString(json) || _.isBoolean(json) || _.isNumber(json)) {
|
|
52
52
|
return json;
|
|
53
53
|
}
|
|
54
54
|
if (mapping['']) {
|
|
55
|
-
const decoratorMapping =
|
|
55
|
+
const decoratorMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping['']));
|
|
56
56
|
mapping = _.merge(mapping, decoratorMapping);
|
|
57
57
|
}
|
|
58
58
|
let res;
|
|
@@ -66,10 +66,10 @@ function Mapping_encode(json, mapping, circular = []) {
|
|
|
66
66
|
}
|
|
67
67
|
function decodeFromDecorator(json, production = false) {
|
|
68
68
|
const entityClass = CLASS.getFromObject(json);
|
|
69
|
-
const mappings =
|
|
69
|
+
const mappings = Mapping__NS__getModelsMapping(entityClass);
|
|
70
70
|
return mappings;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function Mapping__NS__getModelsMapping(entity) {
|
|
73
73
|
if (!_.isFunction(entity) || entity === Object) {
|
|
74
74
|
return {};
|
|
75
75
|
}
|
|
@@ -110,7 +110,7 @@ function add(o, path, mapping = {}) {
|
|
|
110
110
|
const resolveClass = CLASS.getBy(objectClassName);
|
|
111
111
|
if (!resolveClass) {
|
|
112
112
|
if (objectClassName !== 'Object') {
|
|
113
|
-
if (
|
|
113
|
+
if (UtilsOs__NS__isBrowser) {
|
|
114
114
|
console.error(`Cannot resolve class "${objectClassName}" while mapping.`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -218,12 +218,12 @@ function setMapping(json, mapping = {}) {
|
|
|
218
218
|
// }
|
|
219
219
|
if (_.isArray(json[key])) {
|
|
220
220
|
json[key] = json[key].map(arrObj => {
|
|
221
|
-
const objMapping =
|
|
221
|
+
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[key]));
|
|
222
222
|
return setMapping(arrObj, objMapping);
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
225
|
else if (_.isObject(json[key])) {
|
|
226
|
-
const objMapping =
|
|
226
|
+
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[key]));
|
|
227
227
|
json[key] = setMapping(json[key], objMapping);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -237,7 +237,7 @@ function setMapping(json, mapping = {}) {
|
|
|
237
237
|
.filter(key => key !== '' && key.split('.').length >= 2)
|
|
238
238
|
.forEach(lodasPath => {
|
|
239
239
|
// console.log(`Loadsh path: ${lodasPath}`)
|
|
240
|
-
const objMapping =
|
|
240
|
+
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[lodasPath]));
|
|
241
241
|
const input = _.get(json, lodasPath);
|
|
242
242
|
if (!_.isUndefined(input)) {
|
|
243
243
|
const res = setMapping(input, objMapping);
|
|
@@ -249,7 +249,7 @@ function setMapping(json, mapping = {}) {
|
|
|
249
249
|
}
|
|
250
250
|
return _.merge(new mainClassFn(), json);
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function Mapping__NS__DefaultModelWithMapping(defaultModelValues, mapping) {
|
|
253
253
|
return function (target) {
|
|
254
254
|
if (!_.isArray(target[SYMBOL.MODELS_MAPPING])) {
|
|
255
255
|
target[SYMBOL.MODELS_MAPPING] = [];
|
|
@@ -308,10 +308,10 @@ class Helpers extends CoreHelpers {
|
|
|
308
308
|
static get Mapping() {
|
|
309
309
|
return {
|
|
310
310
|
encode(json, mapping) {
|
|
311
|
-
return
|
|
311
|
+
return Mapping__NS__encode(json, mapping);
|
|
312
312
|
},
|
|
313
313
|
decode(json, autodetect = false) {
|
|
314
|
-
return
|
|
314
|
+
return Mapping__NS__decode(json, autodetect);
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
}
|
|
@@ -645,7 +645,7 @@ class RestResponseWrapper extends RestCommonHttpResponseWrapper {
|
|
|
645
645
|
class RestErrorResponseWrapper extends RestCommonHttpResponseWrapper {
|
|
646
646
|
}
|
|
647
647
|
[];
|
|
648
|
-
class
|
|
648
|
+
class Models__NS__BaseBody {
|
|
649
649
|
toJSON(data, opt) {
|
|
650
650
|
opt = opt || { isJSONArray: false };
|
|
651
651
|
let r = opt.isJSONArray ? [] : {};
|
|
@@ -655,7 +655,7 @@ class Models_BaseBody {
|
|
|
655
655
|
if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
|
|
656
656
|
parsed = JSON.parse(parsed);
|
|
657
657
|
}
|
|
658
|
-
if (opt.parsingError && parsed[
|
|
658
|
+
if (opt.parsingError && parsed[CoreModels__NS__TaonHttpErrorCustomProp]) {
|
|
659
659
|
return _.merge(new RestErrorResponseWrapper(), parsed);
|
|
660
660
|
}
|
|
661
661
|
return parsed;
|
|
@@ -668,7 +668,7 @@ class Models_BaseBody {
|
|
|
668
668
|
return r;
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
class
|
|
671
|
+
class Models__NS__HttpBody extends Models__NS__BaseBody {
|
|
672
672
|
constructor(responseText, isArray = false, entity, circular) {
|
|
673
673
|
super();
|
|
674
674
|
this.responseText = responseText;
|
|
@@ -710,7 +710,7 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
710
710
|
const json = this.toJSON(this.responseText, {
|
|
711
711
|
isJSONArray: this.isArray,
|
|
712
712
|
});
|
|
713
|
-
return
|
|
713
|
+
return Mapping__NS__encode(json, this.entity, this.circular);
|
|
714
714
|
}
|
|
715
715
|
let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
|
|
716
716
|
if (this.circular && Array.isArray(this.circular)) {
|
|
@@ -729,7 +729,7 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
-
class
|
|
732
|
+
class Models__NS__ErrorBody extends Models__NS__BaseBody {
|
|
733
733
|
constructor(data) {
|
|
734
734
|
super();
|
|
735
735
|
this.data = data;
|
|
@@ -741,10 +741,10 @@ class Models_ErrorBody extends Models_BaseBody {
|
|
|
741
741
|
return this.data;
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
|
-
class
|
|
744
|
+
class Models__NS__BaseResponse {
|
|
745
745
|
static { this.cookies = Cookie.Instance; }
|
|
746
746
|
get cookies() {
|
|
747
|
-
return
|
|
747
|
+
return Models__NS__BaseResponse.cookies;
|
|
748
748
|
}
|
|
749
749
|
constructor(responseText, headers, statusCode, isArray = false) {
|
|
750
750
|
this.responseText = responseText;
|
|
@@ -753,7 +753,7 @@ class Models_BaseResponse {
|
|
|
753
753
|
this.isArray = isArray;
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
class
|
|
756
|
+
class Models__NS__HttpResponse extends Models__NS__BaseResponse {
|
|
757
757
|
// public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
|
|
758
758
|
// public get totalElements(): number {
|
|
759
759
|
// return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
|
|
@@ -788,7 +788,7 @@ class Models_HttpResponse extends Models_BaseResponse {
|
|
|
788
788
|
this.circular = JSON.parse(circuralJSON.join());
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
this.body = new
|
|
791
|
+
this.body = new Models__NS__HttpBody(this.responseText, this.isArray, this.entity, this.circular);
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
/* */
|
|
@@ -798,7 +798,7 @@ class Models_HttpResponse extends Models_BaseResponse {
|
|
|
798
798
|
/* */
|
|
799
799
|
/* */
|
|
800
800
|
//end of namespace Models
|
|
801
|
-
class HttpResponseError extends
|
|
801
|
+
class HttpResponseError extends Models__NS__BaseResponse {
|
|
802
802
|
// public tryRecconect() {
|
|
803
803
|
// }
|
|
804
804
|
constructor(message, responseText, headers, statusCode, jobid, sourceRequest) {
|
|
@@ -806,7 +806,7 @@ class HttpResponseError extends Models_BaseResponse {
|
|
|
806
806
|
this.message = message;
|
|
807
807
|
this.jobid = jobid;
|
|
808
808
|
this.sourceRequest = sourceRequest;
|
|
809
|
-
this.body = new
|
|
809
|
+
this.body = new Models__NS__ErrorBody(responseText);
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
|
|
@@ -998,7 +998,7 @@ class RestRequest {
|
|
|
998
998
|
const entity = this.meta[jobid].entity;
|
|
999
999
|
const circular = this.meta[jobid].circular;
|
|
1000
1000
|
const success = Resource['_listenSuccess'];
|
|
1001
|
-
const reqResp = new
|
|
1001
|
+
const reqResp = new Models__NS__HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
|
|
1002
1002
|
success.next(reqResp);
|
|
1003
1003
|
this.subjectInuUse[jobid].next(reqResp);
|
|
1004
1004
|
this.meta[jobid] = void 0;
|
|
@@ -1225,7 +1225,7 @@ class RestRequest {
|
|
|
1225
1225
|
});
|
|
1226
1226
|
//#region DISPOSE @UNCOMMENT AFTER TESTS
|
|
1227
1227
|
// if (objectIDToCreateOrLast > 2) {
|
|
1228
|
-
// const oldReq:
|
|
1228
|
+
// const oldReq: Models__NS__ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
|
|
1229
1229
|
// if (_.isUndefined(this.meta[oldReq.id])) {
|
|
1230
1230
|
// // cant delete this - for counter purpose
|
|
1231
1231
|
// this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)] = {};
|
|
@@ -1269,7 +1269,7 @@ class RestRequest {
|
|
|
1269
1269
|
}
|
|
1270
1270
|
jsonp(url, body, headers, meta, isArray, mockHttp, axiosOptions) {
|
|
1271
1271
|
const method = 'jsonp';
|
|
1272
|
-
if (
|
|
1272
|
+
if (UtilsOs__NS__isSSRMode) {
|
|
1273
1273
|
const emptyStuff = Promise.resolve();
|
|
1274
1274
|
emptyStuff.observable = new Observable();
|
|
1275
1275
|
console.warn(`Cannot perform jsonp request in SSR mode`);
|
|
@@ -1783,5 +1783,5 @@ class SimpleResource {
|
|
|
1783
1783
|
* Generated bundle index. Do not edit.
|
|
1784
1784
|
*/
|
|
1785
1785
|
|
|
1786
|
-
export { AxiosBackendHandler, CONTENT_TYPE, Helpers, HttpResponseError,
|
|
1786
|
+
export { AxiosBackendHandler, CONTENT_TYPE, Helpers, HttpResponseError, Mapping__NS__DefaultModelWithMapping, Mapping__NS__decode, Mapping__NS__encode, Mapping__NS__getModelsMapping, Models__NS__BaseBody, Models__NS__BaseResponse, Models__NS__ErrorBody, Models__NS__HttpBody, Models__NS__HttpResponse, Resource, Rest, RestErrorResponseWrapper, RestHeaders, RestResponseWrapper, SimpleResource, buildInterceptorChain, interpolateParamsToUrl };
|
|
1787
1787
|
//# sourceMappingURL=ng2-rest-websql.mjs.map
|