ng2-rest 21.0.17 → 21.0.20
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 +11 -12
- package/browser/fesm2022/ng2-rest-browser.mjs.map +1 -1
- package/browser/package.json +1 -1
- package/browser/types/ng2-rest-browser.d.ts +5 -6
- package/browser-prod/fesm2022/ng2-rest-browser.mjs +100 -102
- 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 +107 -110
- package/browser-prod.split-namespaces.json +68 -62
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/helpers.d.ts +4 -7
- package/lib/helpers.js +8 -12
- package/lib/helpers.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/rest-request.js +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 +6 -11
- package/lib-prod/helpers.js +19 -22
- package/lib-prod/helpers.js.map +1 -1
- package/lib-prod/mapping.d.ts +6 -6
- package/lib-prod/mapping.js +52 -52
- package/lib-prod/mapping.js.map +1 -1
- package/lib-prod/models.d.ts +54 -54
- package/lib-prod/models.js +23 -23
- 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 +4 -4
- package/lib-prod/params.js.map +1 -1
- package/lib-prod/resource-service.d.ts +7 -7
- package/lib-prod/resource-service.js +1 -1
- package/lib-prod/resource-service.js.map +1 -1
- package/lib-prod/rest-request.d.ts +8 -8
- package/lib-prod/rest-request.js +12 -12
- 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 +68 -62
- package/package.json +3 -2
- package/websql/fesm2022/ng2-rest-websql.mjs +11 -12
- package/websql/fesm2022/ng2-rest-websql.mjs.map +1 -1
- package/websql/package.json +1 -1
- package/websql/types/ng2-rest-websql.d.ts +5 -6
- package/websql-prod/fesm2022/ng2-rest-websql.mjs +100 -102
- 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 +107 -110
- package/websql-prod.split-namespaces.json +68 -62
package/browser/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import { Circ
|
|
2
|
+
import { Circ } from 'json10/browser';
|
|
3
3
|
import { Observable, Subject } from 'rxjs';
|
|
4
4
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
5
|
-
import { CoreModels
|
|
5
|
+
import { CoreModels } from 'tnp-core/browser';
|
|
6
6
|
import express from 'express';
|
|
7
7
|
|
|
8
8
|
declare class Cookie {
|
|
@@ -372,13 +372,12 @@ declare class Resource<E, T, TA> {
|
|
|
372
372
|
private api;
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
declare
|
|
376
|
-
|
|
377
|
-
static get Mapping(): {
|
|
375
|
+
declare namespace Helpers {
|
|
376
|
+
const getMapping: () => {
|
|
378
377
|
encode<T = Function>(json: Object, mapping: Mapping.Mapping): T;
|
|
379
378
|
decode(json: Object, autodetect?: boolean): Mapping.Mapping;
|
|
380
379
|
};
|
|
381
|
-
|
|
380
|
+
const checkValidUrl: (url: string) => boolean;
|
|
382
381
|
}
|
|
383
382
|
|
|
384
383
|
declare const CONTENT_TYPE: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { from, firstValueFrom, Subject, Observable } from 'rxjs';
|
|
2
2
|
import { diffChars } from 'diff';
|
|
3
|
-
import {
|
|
3
|
+
import { ___NS__isUndefined, ___NS__isArray, ___NS__first, ___NS__merge, ___NS__isString, ___NS__isBoolean, ___NS__isNumber, ___NS__isFunction, ___NS__cloneDeep, UtilsOs__NS__isBrowser, ___NS__isNull, ___NS__get, ___NS__set, ___NS__isObject, ___NS__omit, CoreModels__NS__TaonHttpErrorCustomProp, Helpers__NS__isBlob, UtilsOs__NS__isSSRMode } from 'tnp-core/browser-prod';
|
|
4
4
|
import { Log, Level } from 'ng2-logger/browser-prod';
|
|
5
5
|
import { walk } from 'lodash-walk-object/browser-prod';
|
|
6
6
|
import { CLASS, SYMBOL } from 'typescript-class-helpers/browser-prod';
|
|
7
|
-
import { JSON10 } from 'json10/browser-prod';
|
|
8
7
|
import axios from 'axios';
|
|
8
|
+
import { JSON10 } from 'json10/browser-prod';
|
|
9
9
|
|
|
10
10
|
class Cookie {
|
|
11
11
|
static get Instance() {
|
|
@@ -36,27 +36,27 @@ 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
|
-
if (
|
|
41
|
+
if (___NS__isUndefined(json)) {
|
|
42
42
|
return void 0;
|
|
43
43
|
}
|
|
44
|
-
let mapping = decodeFromDecorator(
|
|
44
|
+
let mapping = decodeFromDecorator(___NS__isArray(json) ? ___NS__first(json) : json, !autodetect);
|
|
45
45
|
if (autodetect) {
|
|
46
|
-
mapping =
|
|
46
|
+
mapping = ___NS__merge(getMappingNaive(json), mapping);
|
|
47
47
|
}
|
|
48
48
|
return mapping;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
if (
|
|
50
|
+
function Mapping__NS__encode(json, mapping, circular = []) {
|
|
51
|
+
if (___NS__isString(json) || ___NS__isBoolean(json) || ___NS__isNumber(json)) {
|
|
52
52
|
return json;
|
|
53
53
|
}
|
|
54
54
|
if (mapping['']) {
|
|
55
|
-
const decoratorMapping =
|
|
56
|
-
mapping =
|
|
55
|
+
const decoratorMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping['']));
|
|
56
|
+
mapping = ___NS__merge(mapping, decoratorMapping);
|
|
57
57
|
}
|
|
58
58
|
let res;
|
|
59
|
-
if (
|
|
59
|
+
if (___NS__isArray(circular) && circular.length > 0) {
|
|
60
60
|
res = setMappingCirc(json, mapping, circular);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
@@ -66,34 +66,34 @@ 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
|
|
73
|
-
if (!
|
|
72
|
+
function Mapping__NS__getModelsMapping(entity) {
|
|
73
|
+
if (!___NS__isFunction(entity) || entity === Object) {
|
|
74
74
|
return {};
|
|
75
75
|
}
|
|
76
76
|
const className = CLASS.getName(entity);
|
|
77
77
|
// console.log(`getMaping for: '${className}' `)
|
|
78
|
-
let enityOWnMapping =
|
|
78
|
+
let enityOWnMapping = ___NS__isArray(entity[SYMBOL.MODELS_MAPPING])
|
|
79
79
|
? entity[SYMBOL.MODELS_MAPPING]
|
|
80
80
|
: [{ '': className }];
|
|
81
81
|
let res = {};
|
|
82
82
|
let parents = enityOWnMapping
|
|
83
|
-
.filter(m => !
|
|
83
|
+
.filter(m => !___NS__isUndefined(m['']) && m[''] !== className)
|
|
84
84
|
.map(m => m['']);
|
|
85
85
|
enityOWnMapping.reverse().forEach(m => {
|
|
86
|
-
m =
|
|
86
|
+
m = ___NS__cloneDeep(m);
|
|
87
87
|
// console.log(`'${className}' m:`, m)
|
|
88
88
|
Object.keys(m).forEach(key => {
|
|
89
89
|
const v = m[key];
|
|
90
|
-
const isArr =
|
|
91
|
-
const model = isArr ?
|
|
90
|
+
const isArr = ___NS__isArray(v);
|
|
91
|
+
const model = isArr ? ___NS__first(v) : v;
|
|
92
92
|
if (parents.includes(model)) {
|
|
93
93
|
m[key] = isArr ? [className] : className;
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
res =
|
|
96
|
+
res = ___NS__merge(res, m);
|
|
97
97
|
});
|
|
98
98
|
res[''] = className;
|
|
99
99
|
// console.log(`mapping for ${className} : ${JSON.stringify(res)}`)
|
|
@@ -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
|
}
|
|
@@ -143,7 +143,7 @@ function getMappingNaive(c, path = '', mapping = {}, level = 0) {
|
|
|
143
143
|
return;
|
|
144
144
|
add(c, path, mapping);
|
|
145
145
|
for (var p in c) {
|
|
146
|
-
if (
|
|
146
|
+
if (___NS__isFunction(c.hasOwnProperty) && c.hasOwnProperty(p)) {
|
|
147
147
|
const v = c[p];
|
|
148
148
|
if (Array.isArray(v) && v.length > 0) {
|
|
149
149
|
// reducer as impovement
|
|
@@ -163,7 +163,7 @@ function getMappingNaive(c, path = '', mapping = {}, level = 0) {
|
|
|
163
163
|
return mapping;
|
|
164
164
|
}
|
|
165
165
|
function getMappingPathFrom(pathLodhas) {
|
|
166
|
-
if (!
|
|
166
|
+
if (!___NS__isString(pathLodhas)) {
|
|
167
167
|
return void 0;
|
|
168
168
|
}
|
|
169
169
|
const regex = /\[([0-9a-zA-Z]|\'|\")*\]/g;
|
|
@@ -174,32 +174,32 @@ function getMappingPathFrom(pathLodhas) {
|
|
|
174
174
|
return pathLodhas;
|
|
175
175
|
}
|
|
176
176
|
function setMappingCirc(json, mapping = {}, circular = []) {
|
|
177
|
-
const mainClassFn = !
|
|
177
|
+
const mainClassFn = !___NS__isArray(json) && CLASS.getBy(mapping['']);
|
|
178
178
|
// console.log(mapping)
|
|
179
179
|
walk.Object(json, (v, lodashPath, changeValue) => {
|
|
180
|
-
if (!
|
|
180
|
+
if (!___NS__isUndefined(v) && !___NS__isNull(v)) {
|
|
181
181
|
const mappingPath = getMappingPathFrom(lodashPath);
|
|
182
|
-
if (!
|
|
183
|
-
const isArray =
|
|
182
|
+
if (!___NS__isUndefined(mapping[mappingPath])) {
|
|
183
|
+
const isArray = ___NS__isArray(mapping[mappingPath]);
|
|
184
184
|
if (!isArray) {
|
|
185
185
|
const className = isArray
|
|
186
|
-
?
|
|
186
|
+
? ___NS__first(mapping[mappingPath])
|
|
187
187
|
: mapping[mappingPath];
|
|
188
188
|
const classFN = CLASS.getBy(className);
|
|
189
|
-
if (
|
|
189
|
+
if (___NS__isFunction(classFN)) {
|
|
190
190
|
// console.log(`mapping: '${mappingPath}', lp: '${lodashPath}' class: '${className}' , set `, v.location)
|
|
191
|
-
changeValue(
|
|
191
|
+
changeValue(___NS__merge(new classFN(), v));
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
circular.forEach(c => {
|
|
198
|
-
const ref =
|
|
199
|
-
|
|
198
|
+
const ref = ___NS__get(json, c.circuralTargetPath);
|
|
199
|
+
___NS__set(json, c.pathToObj, ref);
|
|
200
200
|
});
|
|
201
|
-
if (
|
|
202
|
-
json =
|
|
201
|
+
if (___NS__isFunction(mainClassFn)) {
|
|
202
|
+
json = ___NS__merge(new mainClassFn(), json);
|
|
203
203
|
}
|
|
204
204
|
return json;
|
|
205
205
|
}
|
|
@@ -216,14 +216,14 @@ function setMapping(json, mapping = {}) {
|
|
|
216
216
|
// if (mainClassFn && mainClassFn.name === 'Project') {
|
|
217
217
|
// // console.log(`OWn property: "${key}"`)
|
|
218
218
|
// }
|
|
219
|
-
if (
|
|
219
|
+
if (___NS__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
|
-
else if (
|
|
226
|
-
const objMapping =
|
|
225
|
+
else if (___NS__isObject(json[key])) {
|
|
226
|
+
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[key]));
|
|
227
227
|
json[key] = setMapping(json[key], objMapping);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -237,31 +237,31 @@ 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 =
|
|
241
|
-
const input =
|
|
242
|
-
if (!
|
|
240
|
+
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[lodasPath]));
|
|
241
|
+
const input = ___NS__get(json, lodasPath);
|
|
242
|
+
if (!___NS__isUndefined(input)) {
|
|
243
243
|
const res = setMapping(input, objMapping);
|
|
244
|
-
|
|
244
|
+
___NS__set(json, lodasPath, res);
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
if (!mainClassFn) {
|
|
248
248
|
return json;
|
|
249
249
|
}
|
|
250
|
-
return
|
|
250
|
+
return ___NS__merge(new mainClassFn(), json);
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function Mapping__NS__DefaultModelWithMapping(defaultModelValues, mapping) {
|
|
253
253
|
return function (target) {
|
|
254
|
-
if (!
|
|
254
|
+
if (!___NS__isArray(target[SYMBOL.MODELS_MAPPING])) {
|
|
255
255
|
target[SYMBOL.MODELS_MAPPING] = [];
|
|
256
256
|
}
|
|
257
257
|
target[SYMBOL.MODELS_MAPPING].push({
|
|
258
258
|
'': CLASS.getName(target),
|
|
259
259
|
});
|
|
260
|
-
if (
|
|
260
|
+
if (___NS__isObject(mapping)) {
|
|
261
261
|
target[SYMBOL.MODELS_MAPPING] = target[SYMBOL.MODELS_MAPPING].concat(mapping);
|
|
262
262
|
Object.keys(mapping).forEach(key => {
|
|
263
263
|
const v = mapping;
|
|
264
|
-
if (
|
|
264
|
+
if (___NS__isUndefined(v) || ___NS__isFunction(v)) {
|
|
265
265
|
throw `
|
|
266
266
|
|
|
267
267
|
|
|
@@ -271,7 +271,7 @@ function Mapping_DefaultModelWithMapping(defaultModelValues, mapping) {
|
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
|
-
if (
|
|
274
|
+
if (___NS__isObject(defaultModelValues)) {
|
|
275
275
|
const toMerge = {};
|
|
276
276
|
const describedTarget = CLASS.describeProperites(target).filter(prop => /^([a-zA-Z0-9]|\_|\#)+$/.test(prop));
|
|
277
277
|
// console.log(`describedTarget: ${describedTarget} for ${target.name}`)
|
|
@@ -290,36 +290,34 @@ function Mapping_DefaultModelWithMapping(defaultModelValues, mapping) {
|
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
// console.log(`merge "${JSON.stringify(target.prototype)}" with "${JSON.stringify(defaultModelValues)}"`)
|
|
293
|
-
target[SYMBOL.DEFAULT_MODEL] =
|
|
293
|
+
target[SYMBOL.DEFAULT_MODEL] = ___NS__merge(toMerge, defaultModelValues);
|
|
294
294
|
const propsToOmmit = Object.keys(target[SYMBOL.DEFAULT_MODEL]).filter(key => {
|
|
295
295
|
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
|
|
296
296
|
return !!descriptor;
|
|
297
297
|
});
|
|
298
|
-
|
|
298
|
+
___NS__merge(target.prototype, ___NS__omit(target[SYMBOL.DEFAULT_MODEL], propsToOmmit));
|
|
299
299
|
// console.log(`DEFAULT VALUE MERGE for ${target.name}`)
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
//end of namespace Mapping
|
|
304
304
|
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
}
|
|
305
|
+
//namespace Helpers
|
|
306
|
+
const Helpers__NS__getMapping = () => {
|
|
307
|
+
return {
|
|
308
|
+
encode(json, mapping) {
|
|
309
|
+
return Mapping__NS__encode(json, mapping);
|
|
310
|
+
},
|
|
311
|
+
decode(json, autodetect = false) {
|
|
312
|
+
return Mapping__NS__decode(json, autodetect);
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
const Helpers__NS__checkValidUrl = (url) => {
|
|
317
|
+
let regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
|
|
318
|
+
return regex.test(url);
|
|
319
|
+
};
|
|
320
|
+
//end of namespace Helpers
|
|
323
321
|
|
|
324
322
|
const log = Log.create('[ng2-rest] params', Level.__NOTHING);
|
|
325
323
|
/** check if string is a valid pattern */
|
|
@@ -327,7 +325,7 @@ function isValid(pattern) {
|
|
|
327
325
|
return (new RegExp('\/:[a-zA-Z]*', 'g')).test(pattern.replace('://', ''));
|
|
328
326
|
}
|
|
329
327
|
function check(url, pattern) {
|
|
330
|
-
if (!
|
|
328
|
+
if (!Helpers__NS__checkValidUrl(url)) {
|
|
331
329
|
log.error(`Incorrect url: ${url}`);
|
|
332
330
|
return false;
|
|
333
331
|
}
|
|
@@ -420,7 +418,7 @@ function cutUrlModel(params, models, output) {
|
|
|
420
418
|
// log.i('cut param', param)
|
|
421
419
|
let model = m.match(/[a-zA-Z0-9]+\//)[0].replace('\/', '');
|
|
422
420
|
if (params === void 0 ||
|
|
423
|
-
(paramIsPath ?
|
|
421
|
+
(paramIsPath ? ___NS__get(params, param) === void 0 : params[param] === void 0) ||
|
|
424
422
|
param === 'undefined') {
|
|
425
423
|
output.length = 0;
|
|
426
424
|
output.unshift(model);
|
|
@@ -429,7 +427,7 @@ function cutUrlModel(params, models, output) {
|
|
|
429
427
|
else {
|
|
430
428
|
if (paramIsPath) {
|
|
431
429
|
// log.i('param is path', param)
|
|
432
|
-
let mrep = m.replace(new RegExp(`:${param}`, 'g'), `${
|
|
430
|
+
let mrep = m.replace(new RegExp(`:${param}`, 'g'), `${___NS__get(params, param)}`);
|
|
433
431
|
output.unshift(mrep);
|
|
434
432
|
return cutUrlModel(params, models, output);
|
|
435
433
|
}
|
|
@@ -474,7 +472,7 @@ function interpolateParamsToUrl(params, url) {
|
|
|
474
472
|
let c = e.replace('\/:', '');
|
|
475
473
|
// log.i('c', c)
|
|
476
474
|
if (regexisPath.test(c)) {
|
|
477
|
-
url = url.replace(e, `/${
|
|
475
|
+
url = url.replace(e, `/${___NS__get(params, c)}`);
|
|
478
476
|
}
|
|
479
477
|
else {
|
|
480
478
|
url = url.replace(e, `/${params[c]}`);
|
|
@@ -645,7 +643,7 @@ class RestResponseWrapper extends RestCommonHttpResponseWrapper {
|
|
|
645
643
|
class RestErrorResponseWrapper extends RestCommonHttpResponseWrapper {
|
|
646
644
|
}
|
|
647
645
|
[];
|
|
648
|
-
class
|
|
646
|
+
class Models__NS__BaseBody {
|
|
649
647
|
toJSON(data, opt) {
|
|
650
648
|
opt = opt || { isJSONArray: false };
|
|
651
649
|
let r = opt.isJSONArray ? [] : {};
|
|
@@ -655,8 +653,8 @@ class Models_BaseBody {
|
|
|
655
653
|
if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
|
|
656
654
|
parsed = JSON.parse(parsed);
|
|
657
655
|
}
|
|
658
|
-
if (opt.parsingError && parsed[
|
|
659
|
-
return
|
|
656
|
+
if (opt.parsingError && parsed[CoreModels__NS__TaonHttpErrorCustomProp]) {
|
|
657
|
+
return ___NS__merge(new RestErrorResponseWrapper(), parsed);
|
|
660
658
|
}
|
|
661
659
|
return parsed;
|
|
662
660
|
}
|
|
@@ -668,7 +666,7 @@ class Models_BaseBody {
|
|
|
668
666
|
return r;
|
|
669
667
|
}
|
|
670
668
|
}
|
|
671
|
-
class
|
|
669
|
+
class Models__NS__HttpBody extends Models__NS__BaseBody {
|
|
672
670
|
constructor(responseText, isArray = false, entity, circular) {
|
|
673
671
|
super();
|
|
674
672
|
this.responseText = responseText;
|
|
@@ -680,17 +678,17 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
680
678
|
return this.responseText;
|
|
681
679
|
}
|
|
682
680
|
get booleanValue() {
|
|
683
|
-
if (!
|
|
681
|
+
if (!Helpers__NS__isBlob(this.responseText)) {
|
|
684
682
|
return ['ok', 'true'].includes(this.responseText?.trim());
|
|
685
683
|
}
|
|
686
684
|
}
|
|
687
685
|
get numericValue() {
|
|
688
|
-
if (!
|
|
686
|
+
if (!Helpers__NS__isBlob(this.responseText)) {
|
|
689
687
|
return Number(this.responseText?.trim());
|
|
690
688
|
}
|
|
691
689
|
}
|
|
692
690
|
get rawJson() {
|
|
693
|
-
if (!
|
|
691
|
+
if (!Helpers__NS__isBlob(this.responseText)) {
|
|
694
692
|
let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
|
|
695
693
|
if (this.circular && Array.isArray(this.circular)) {
|
|
696
694
|
res = JSON10.parse(JSON.stringify(res), this.circular);
|
|
@@ -699,7 +697,7 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
699
697
|
}
|
|
700
698
|
}
|
|
701
699
|
get json() {
|
|
702
|
-
const isBlob =
|
|
700
|
+
const isBlob = Helpers__NS__isBlob(this.responseText);
|
|
703
701
|
if (isBlob) {
|
|
704
702
|
return void 0;
|
|
705
703
|
}
|
|
@@ -710,7 +708,7 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
710
708
|
const json = this.toJSON(this.responseText, {
|
|
711
709
|
isJSONArray: this.isArray,
|
|
712
710
|
});
|
|
713
|
-
return
|
|
711
|
+
return Mapping__NS__encode(json, this.entity, this.circular);
|
|
714
712
|
}
|
|
715
713
|
let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
|
|
716
714
|
if (this.circular && Array.isArray(this.circular)) {
|
|
@@ -722,14 +720,14 @@ class Models_HttpBody extends Models_BaseBody {
|
|
|
722
720
|
* undefined when blob
|
|
723
721
|
*/
|
|
724
722
|
get text() {
|
|
725
|
-
if (!
|
|
723
|
+
if (!Helpers__NS__isBlob(this.responseText)) {
|
|
726
724
|
return this.responseText
|
|
727
725
|
.replace(/^\"/, '')
|
|
728
726
|
.replace(/\"$/, '');
|
|
729
727
|
}
|
|
730
728
|
}
|
|
731
729
|
}
|
|
732
|
-
class
|
|
730
|
+
class Models__NS__ErrorBody extends Models__NS__BaseBody {
|
|
733
731
|
constructor(data) {
|
|
734
732
|
super();
|
|
735
733
|
this.data = data;
|
|
@@ -741,10 +739,10 @@ class Models_ErrorBody extends Models_BaseBody {
|
|
|
741
739
|
return this.data;
|
|
742
740
|
}
|
|
743
741
|
}
|
|
744
|
-
class
|
|
742
|
+
class Models__NS__BaseResponse {
|
|
745
743
|
static { this.cookies = Cookie.Instance; }
|
|
746
744
|
get cookies() {
|
|
747
|
-
return
|
|
745
|
+
return Models__NS__BaseResponse.cookies;
|
|
748
746
|
}
|
|
749
747
|
constructor(responseText, headers, statusCode, isArray = false) {
|
|
750
748
|
this.responseText = responseText;
|
|
@@ -753,7 +751,7 @@ class Models_BaseResponse {
|
|
|
753
751
|
this.isArray = isArray;
|
|
754
752
|
}
|
|
755
753
|
}
|
|
756
|
-
class
|
|
754
|
+
class Models__NS__HttpResponse extends Models__NS__BaseResponse {
|
|
757
755
|
// public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
|
|
758
756
|
// public get totalElements(): number {
|
|
759
757
|
// return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
|
|
@@ -788,7 +786,7 @@ class Models_HttpResponse extends Models_BaseResponse {
|
|
|
788
786
|
this.circular = JSON.parse(circuralJSON.join());
|
|
789
787
|
}
|
|
790
788
|
}
|
|
791
|
-
this.body = new
|
|
789
|
+
this.body = new Models__NS__HttpBody(this.responseText, this.isArray, this.entity, this.circular);
|
|
792
790
|
}
|
|
793
791
|
}
|
|
794
792
|
/* */
|
|
@@ -798,7 +796,7 @@ class Models_HttpResponse extends Models_BaseResponse {
|
|
|
798
796
|
/* */
|
|
799
797
|
/* */
|
|
800
798
|
//end of namespace Models
|
|
801
|
-
class HttpResponseError extends
|
|
799
|
+
class HttpResponseError extends Models__NS__BaseResponse {
|
|
802
800
|
// public tryRecconect() {
|
|
803
801
|
// }
|
|
804
802
|
constructor(message, responseText, headers, statusCode, jobid, sourceRequest) {
|
|
@@ -806,7 +804,7 @@ class HttpResponseError extends Models_BaseResponse {
|
|
|
806
804
|
this.message = message;
|
|
807
805
|
this.jobid = jobid;
|
|
808
806
|
this.sourceRequest = sourceRequest;
|
|
809
|
-
this.body = new
|
|
807
|
+
this.body = new Models__NS__ErrorBody(responseText);
|
|
810
808
|
}
|
|
811
809
|
}
|
|
812
810
|
|
|
@@ -979,7 +977,7 @@ class RestRequest {
|
|
|
979
977
|
//#region fields
|
|
980
978
|
static { this.jobId = 0; }
|
|
981
979
|
handlerResult(options, sourceRequest) {
|
|
982
|
-
if (
|
|
980
|
+
if (___NS__isUndefined(options)) {
|
|
983
981
|
options = {};
|
|
984
982
|
}
|
|
985
983
|
// log.d(`HANDLE RESULT (jobid:${options.jobid}) ${sourceRequest.url}`);
|
|
@@ -987,7 +985,7 @@ class RestRequest {
|
|
|
987
985
|
if (typeof res !== 'object') {
|
|
988
986
|
throw new Error('No resposnse for request. ');
|
|
989
987
|
}
|
|
990
|
-
if (
|
|
988
|
+
if (UtilsOs__NS__isBrowser) {
|
|
991
989
|
res.headers = RestHeaders.from(res.headers);
|
|
992
990
|
}
|
|
993
991
|
// error no internet
|
|
@@ -998,7 +996,7 @@ class RestRequest {
|
|
|
998
996
|
const entity = this.meta[jobid].entity;
|
|
999
997
|
const circular = this.meta[jobid].circular;
|
|
1000
998
|
const success = Resource['_listenSuccess'];
|
|
1001
|
-
const reqResp = new
|
|
999
|
+
const reqResp = new Models__NS__HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
|
|
1002
1000
|
success.next(reqResp);
|
|
1003
1001
|
this.subjectInuUse[jobid].next(reqResp);
|
|
1004
1002
|
this.meta[jobid] = void 0;
|
|
@@ -1161,15 +1159,15 @@ class RestRequest {
|
|
|
1161
1159
|
getReplay(method, meta, onlyGetLastReplayForMethod) {
|
|
1162
1160
|
let replay;
|
|
1163
1161
|
//#region prevent empty tree
|
|
1164
|
-
if (
|
|
1162
|
+
if (___NS__isUndefined(this.replaySubjects[meta.endpoint])) {
|
|
1165
1163
|
// log.i(`(${meta.endpoint}) `);
|
|
1166
1164
|
this.replaySubjects[meta.endpoint] = {};
|
|
1167
1165
|
}
|
|
1168
|
-
if (
|
|
1166
|
+
if (___NS__isUndefined(this.replaySubjects[meta.endpoint][meta.path])) {
|
|
1169
1167
|
// log.i(`(${meta.endpoint})(${meta.path}) `);
|
|
1170
1168
|
this.replaySubjects[meta.endpoint][meta.path] = {};
|
|
1171
1169
|
}
|
|
1172
|
-
if (
|
|
1170
|
+
if (___NS__isUndefined(this.replaySubjects[meta.endpoint][meta.path][method])) {
|
|
1173
1171
|
// log.i(`(${meta.endpoint})(${meta.path}) `);
|
|
1174
1172
|
this.replaySubjects[meta.endpoint][meta.path][method] = {};
|
|
1175
1173
|
}
|
|
@@ -1178,7 +1176,7 @@ class RestRequest {
|
|
|
1178
1176
|
if (onlyGetLastReplayForMethod && objectIDToCreateOrLast === 0) {
|
|
1179
1177
|
return replay;
|
|
1180
1178
|
}
|
|
1181
|
-
if (
|
|
1179
|
+
if (___NS__isUndefined(this.replaySubjects[meta.endpoint][meta.path][method][objectIDToCreateOrLast])) {
|
|
1182
1180
|
// log.i(`(${meta.endpoint})(${meta.path})(${method}) `);
|
|
1183
1181
|
this.replaySubjects[meta.endpoint][meta.path][method][objectIDToCreateOrLast] = {
|
|
1184
1182
|
subject: new Subject(),
|
|
@@ -1187,7 +1185,7 @@ class RestRequest {
|
|
|
1187
1185
|
}
|
|
1188
1186
|
replay =
|
|
1189
1187
|
this.replaySubjects[meta.endpoint][meta.path][method][objectIDToCreateOrLast];
|
|
1190
|
-
if (!
|
|
1188
|
+
if (!___NS__isNumber(replay.id)) {
|
|
1191
1189
|
if (RestRequest.jobId === Number.MAX_SAFE_INTEGER) {
|
|
1192
1190
|
RestRequest.jobId = 0;
|
|
1193
1191
|
}
|
|
@@ -1225,8 +1223,8 @@ class RestRequest {
|
|
|
1225
1223
|
});
|
|
1226
1224
|
//#region DISPOSE @UNCOMMENT AFTER TESTS
|
|
1227
1225
|
// if (objectIDToCreateOrLast > 2) {
|
|
1228
|
-
// const oldReq:
|
|
1229
|
-
// if (
|
|
1226
|
+
// const oldReq: Models__NS__ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
|
|
1227
|
+
// if (___NS__isUndefined(this.meta[oldReq.id])) {
|
|
1230
1228
|
// // cant delete this - for counter purpose
|
|
1231
1229
|
// this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)] = {};
|
|
1232
1230
|
// delete this.subjectInuUse[oldReq.id];
|
|
@@ -1269,7 +1267,7 @@ class RestRequest {
|
|
|
1269
1267
|
}
|
|
1270
1268
|
jsonp(url, body, headers, meta, isArray, mockHttp, axiosOptions) {
|
|
1271
1269
|
const method = 'jsonp';
|
|
1272
|
-
if (
|
|
1270
|
+
if (UtilsOs__NS__isSSRMode) {
|
|
1273
1271
|
const emptyStuff = Promise.resolve();
|
|
1274
1272
|
emptyStuff.observable = new Observable();
|
|
1275
1273
|
console.warn(`Cannot perform jsonp request in SSR mode`);
|
|
@@ -1540,7 +1538,7 @@ Instead use nested approach: /book/:bookid/author/:authorid
|
|
|
1540
1538
|
url = url.slice(0, url.length - 1);
|
|
1541
1539
|
// log.i('url after', url);
|
|
1542
1540
|
if (Resource.endpoints[e] !== void 0) {
|
|
1543
|
-
//
|
|
1541
|
+
// Helpers__NS__log(
|
|
1544
1542
|
// 'Cannot use map function at the same API endpoint again (' +
|
|
1545
1543
|
// Resource.endpoints[e].url +
|
|
1546
1544
|
// ')',
|
|
@@ -1783,5 +1781,5 @@ class SimpleResource {
|
|
|
1783
1781
|
* Generated bundle index. Do not edit.
|
|
1784
1782
|
*/
|
|
1785
1783
|
|
|
1786
|
-
export { AxiosBackendHandler, CONTENT_TYPE,
|
|
1784
|
+
export { AxiosBackendHandler, CONTENT_TYPE, Helpers__NS__checkValidUrl, Helpers__NS__getMapping, 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
1785
|
//# sourceMappingURL=ng2-rest-browser.mjs.map
|