ng2-rest 21.0.18 → 21.0.21
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 +76 -78
- 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 +8 -11
- package/browser-prod.re-export.json +1 -0
- package/browser-prod.split-namespaces.json +6 -0
- 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 +5 -10
- package/lib-prod/helpers.js +19 -22
- package/lib-prod/helpers.js.map +1 -1
- package/lib-prod/mapping.js +38 -38
- package/lib-prod/mapping.js.map +1 -1
- package/lib-prod/models.js +6 -6
- package/lib-prod/models.js.map +1 -1
- package/lib-prod/package.json +1 -1
- package/lib-prod/params.js +4 -4
- package/lib-prod/params.js.map +1 -1
- package/lib-prod/resource-service.js +1 -1
- package/lib-prod/resource-service.js.map +1 -1
- package/lib-prod/rest-request.js +9 -9
- package/lib-prod/rest-request.js.map +1 -1
- package/lib-prod.re-export.json +1 -0
- package/lib-prod.split-namespaces.json +6 -0
- 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 +76 -78
- 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 +8 -11
- package/websql-prod.re-export.json +1 -0
- package/websql-prod.split-namespaces.json +6 -0
package/websql/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import { Circ
|
|
2
|
+
import { Circ } from 'json10/websql';
|
|
3
3
|
import { Observable, Subject } from 'rxjs';
|
|
4
4
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
5
|
-
import { CoreModels
|
|
5
|
+
import { CoreModels } from 'tnp-core/websql';
|
|
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/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';
|
|
7
|
-
import { JSON10 } from 'json10/websql-prod';
|
|
8
7
|
import axios from 'axios';
|
|
8
|
+
import { JSON10 } from 'json10/websql-prod';
|
|
9
9
|
|
|
10
10
|
class Cookie {
|
|
11
11
|
static get Instance() {
|
|
@@ -38,25 +38,25 @@ class Cookie {
|
|
|
38
38
|
//namespace Mapping
|
|
39
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
50
|
function Mapping__NS__encode(json, mapping, circular = []) {
|
|
51
|
-
if (
|
|
51
|
+
if (___NS__isString(json) || ___NS__isBoolean(json) || ___NS__isNumber(json)) {
|
|
52
52
|
return json;
|
|
53
53
|
}
|
|
54
54
|
if (mapping['']) {
|
|
55
55
|
const decoratorMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping['']));
|
|
56
|
-
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 {
|
|
@@ -70,30 +70,30 @@ function decodeFromDecorator(json, production = false) {
|
|
|
70
70
|
return mappings;
|
|
71
71
|
}
|
|
72
72
|
function Mapping__NS__getModelsMapping(entity) {
|
|
73
|
-
if (!
|
|
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)}`)
|
|
@@ -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,13 +216,13 @@ 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
221
|
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[key]));
|
|
222
222
|
return setMapping(arrObj, objMapping);
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
-
else if (
|
|
225
|
+
else if (___NS__isObject(json[key])) {
|
|
226
226
|
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[key]));
|
|
227
227
|
json[key] = setMapping(json[key], objMapping);
|
|
228
228
|
}
|
|
@@ -238,30 +238,30 @@ function setMapping(json, mapping = {}) {
|
|
|
238
238
|
.forEach(lodasPath => {
|
|
239
239
|
// console.log(`Loadsh path: ${lodasPath}`)
|
|
240
240
|
const objMapping = Mapping__NS__getModelsMapping(CLASS.getBy(mapping[lodasPath]));
|
|
241
|
-
const input =
|
|
242
|
-
if (!
|
|
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
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__NS__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__NS__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]}`);
|
|
@@ -656,7 +654,7 @@ class Models__NS__BaseBody {
|
|
|
656
654
|
parsed = JSON.parse(parsed);
|
|
657
655
|
}
|
|
658
656
|
if (opt.parsingError && parsed[CoreModels__NS__TaonHttpErrorCustomProp]) {
|
|
659
|
-
return
|
|
657
|
+
return ___NS__merge(new RestErrorResponseWrapper(), parsed);
|
|
660
658
|
}
|
|
661
659
|
return parsed;
|
|
662
660
|
}
|
|
@@ -680,17 +678,17 @@ class Models__NS__HttpBody extends Models__NS__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__NS__HttpBody extends Models__NS__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
|
}
|
|
@@ -722,7 +720,7 @@ class Models__NS__HttpBody extends Models__NS__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(/\"$/, '');
|
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -1226,7 +1224,7 @@ class RestRequest {
|
|
|
1226
1224
|
//#region DISPOSE @UNCOMMENT AFTER TESTS
|
|
1227
1225
|
// if (objectIDToCreateOrLast > 2) {
|
|
1228
1226
|
// const oldReq: Models__NS__ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
|
|
1229
|
-
// if (
|
|
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];
|
|
@@ -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-websql.mjs.map
|