ng2-rest 18.0.19 → 18.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.
Files changed (46) hide show
  1. package/README.md +135 -135
  2. package/assets/shared/shared_folder_info.txt +1 -1
  3. package/browser/README.md +24 -24
  4. package/client/README.md +24 -24
  5. package/index.js +15 -2
  6. package/index.js.map +1 -1
  7. package/lib/build-info._auto-generated_.js.map +1 -1
  8. package/lib/content-type.js +1 -1
  9. package/lib/content-type.js.map +1 -1
  10. package/lib/cookie.js +16 -20
  11. package/lib/cookie.js.map +1 -1
  12. package/lib/helpers.js +18 -29
  13. package/lib/helpers.js.map +1 -1
  14. package/lib/index._auto-generated_.d.ts +1 -0
  15. package/lib/index._auto-generated_.js.map +1 -1
  16. package/lib/index.js +22 -9
  17. package/lib/index.js.map +1 -1
  18. package/lib/mapping.js +84 -81
  19. package/lib/mapping.js.map +1 -1
  20. package/lib/models.js +144 -181
  21. package/lib/models.js.map +1 -1
  22. package/lib/other/simple-resource.js +92 -94
  23. package/lib/other/simple-resource.js.map +1 -1
  24. package/lib/params.js +69 -70
  25. package/lib/params.js.map +1 -1
  26. package/lib/request-cache.js +37 -41
  27. package/lib/request-cache.js.map +1 -1
  28. package/lib/resource-service.js +98 -102
  29. package/lib/resource-service.js.map +1 -1
  30. package/lib/rest-headers.js +56 -61
  31. package/lib/rest-headers.js.map +1 -1
  32. package/lib/rest-request.js +232 -250
  33. package/lib/rest-request.js.map +1 -1
  34. package/lib/rest.class.js +101 -116
  35. package/lib/rest.class.js.map +1 -1
  36. package/migrations/index.js +15 -2
  37. package/migrations/index.js.map +1 -1
  38. package/migrations/migrations_index._auto-generated_.d.ts +1 -0
  39. package/migrations/migrations_index._auto-generated_.js.map +1 -1
  40. package/package.json +19 -73
  41. package/src.d.ts +1 -1
  42. package/tmp-environment.json +8 -406
  43. package/websql/README.md +24 -24
  44. package/browser/package.json +0 -25
  45. package/taon.jsonc +0 -52
  46. package/websql/package.json +0 -25
@@ -1,41 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RestRequest = void 0;
4
- var tslib_1 = require("tslib");
5
- var rxjs_1 = require("rxjs");
6
- var rxjs_2 = require("rxjs");
7
- var tnp_core_1 = require("tnp-core");
8
- var models_1 = require("./models");
9
- var rest_headers_1 = require("./rest-headers");
10
- var tnp_core_2 = require("tnp-core");
11
- var ng2_logger_1 = require("ng2-logger");
12
- var axios_1 = require("axios");
13
- var resource_service_1 = require("./resource-service");
14
- var ng2_logger_2 = require("ng2-logger");
15
- var request_cache_1 = require("./request-cache");
16
- var log = ng2_logger_2.Log.create('[ng2-rest] rest-request', ng2_logger_1.Level.__NOTHING);
4
+ const rxjs_1 = require("rxjs");
5
+ const rxjs_2 = require("rxjs");
6
+ const tnp_core_1 = require("tnp-core");
7
+ const models_1 = require("./models");
8
+ const rest_headers_1 = require("./rest-headers");
9
+ const tnp_core_2 = require("tnp-core");
10
+ const ng2_logger_1 = require("ng2-logger");
11
+ const axios_1 = require("axios");
12
+ const resource_service_1 = require("./resource-service");
13
+ const ng2_logger_2 = require("ng2-logger");
14
+ const request_cache_1 = require("./request-cache");
15
+ const log = ng2_logger_2.Log.create('[ng2-rest] rest-request', ng2_logger_1.Level.__NOTHING);
17
16
  /**
18
17
  * TODO refactor this (remove jobid)
19
18
  */
20
- var jobIDkey = 'jobID';
21
- var customObs = 'customObs';
22
- var cancelFn = 'cancelFn';
23
- var isCanceled = 'isCanceled';
19
+ const jobIDkey = 'jobID';
20
+ const customObs = 'customObs';
21
+ const cancelFn = 'cancelFn';
22
+ const isCanceled = 'isCanceled';
24
23
  //#region mock request
25
24
  //#endregion
26
- var RestRequest = /** @class */ (function () {
27
- function RestRequest() {
28
- this.subjectInuUse = {};
29
- this.meta = {};
30
- //#endregion
31
- this.replaySubjects = {};
32
- }
33
- RestRequest.prototype.handlerResult = function (options, sourceRequest) {
25
+ class RestRequest {
26
+ static zone;
27
+ static jobId = 0;
28
+ subjectInuUse = {};
29
+ meta = {};
30
+ handlerResult(options, sourceRequest) {
34
31
  if (tnp_core_1._.isUndefined(options)) {
35
32
  options = {};
36
33
  }
37
34
  // log.d(`HANDLE RESULT (jobid:${options.jobid}) ${sourceRequest.url}`);
38
- var res = options.res, jobid = options.jobid, isArray = options.isArray, method = options.method;
35
+ const { res, jobid, isArray, method } = options;
39
36
  if (typeof res !== 'object') {
40
37
  throw new Error('No resposnse for request. ');
41
38
  }
@@ -47,20 +44,20 @@ var RestRequest = /** @class */ (function () {
47
44
  this.subjectInuUse[jobid].error(new models_1.Models.HttpResponseError(res.error, res.data, res.headers, res.code, jobid));
48
45
  return;
49
46
  }
50
- var entity = this.meta[jobid].entity;
51
- var circular = this.meta[jobid].circular;
52
- var success = resource_service_1.Resource['_listenSuccess'];
53
- var reqResp = new models_1.Models.HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
47
+ const entity = this.meta[jobid].entity;
48
+ const circular = this.meta[jobid].circular;
49
+ const success = resource_service_1.Resource['_listenSuccess'];
50
+ const reqResp = new models_1.Models.HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
54
51
  success.next(reqResp);
55
52
  this.subjectInuUse[jobid].next(reqResp);
56
53
  this.meta[jobid] = void 0;
57
54
  this.subjectInuUse[jobid].complete();
58
- };
59
- RestRequest.prototype.checkCache = function (sourceRequest, jobid) {
60
- var existedInCache = request_cache_1.RequestCache.findBy(sourceRequest);
55
+ }
56
+ checkCache(sourceRequest, jobid) {
57
+ const existedInCache = request_cache_1.RequestCache.findBy(sourceRequest);
61
58
  if (existedInCache) {
62
59
  // log.i('cache exists', existedInCache)
63
- var success = resource_service_1.Resource['_listenSuccess'];
60
+ const success = resource_service_1.Resource['_listenSuccess'];
64
61
  success.next(existedInCache.response);
65
62
  this.subjectInuUse[jobid].next(existedInCache);
66
63
  this.subjectInuUse[jobid].complete();
@@ -68,136 +65,124 @@ var RestRequest = /** @class */ (function () {
68
65
  }
69
66
  // log.i(`cache not exists for jobid ${jobid}`)
70
67
  return false;
71
- };
72
- RestRequest.prototype.req = function (url_1, method_1, headers_1, body_1, jobid_1) {
73
- return tslib_1.__awaiter(this, arguments, void 0, function (url, method, headers, body, jobid, isArray, mockHttp) {
74
- var CancelToken, source, response, r, headersJson, responseType, catchedError_1, err, msg, stack, errObs, error;
75
- if (isArray === void 0) { isArray = false; }
76
- return tslib_1.__generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- if (this.checkCache({
80
- url: url,
81
- body: body,
82
- isArray: isArray,
83
- method: method
84
- }, jobid)) {
85
- return [2 /*return*/];
86
- }
87
- CancelToken = axios_1.default.CancelToken;
88
- source = CancelToken.source();
89
- this.subjectInuUse[jobid][cancelFn] = source.cancel;
90
- if (mockHttp) {
91
- if (typeof mockHttp === 'object') {
92
- response = {
93
- data: mockHttp.data,
94
- status: mockHttp.code,
95
- headers: mockHttp.headers,
96
- statusText: mockHttp.error,
97
- config: {}
98
- };
99
- }
100
- else if (typeof mockHttp === 'function') {
101
- r = mockHttp(url, method, headers, body);
102
- response = {
103
- data: r.data,
104
- status: r.code,
105
- headers: r.headers,
106
- statusText: r.error,
107
- config: {}
108
- };
109
- }
110
- }
111
- headersJson = headers.toJSON();
112
- responseType = headersJson.responsetypeaxios ? headersJson.responsetypeaxios : 'text';
113
- _a.label = 1;
114
- case 1:
115
- _a.trys.push([1, 4, , 5]);
116
- if (!!response) return [3 /*break*/, 3];
117
- return [4 /*yield*/, (0, axios_1.default)({
118
- url: url,
119
- method: method,
120
- data: body,
121
- responseType: responseType,
122
- headers: headersJson,
123
- cancelToken: source.token,
124
- // withCredentials: true, // this can be done manually
125
- })];
126
- case 2:
127
- // console.log(`[${method}] (jobid=${jobid}) request to: ${url}`);
128
- // console.log('headers axios:', headers.toJSON())
129
- // console.log({ responseType, headersJson, body, method, url })
130
- response = _a.sent();
131
- _a.label = 3;
132
- case 3:
133
- // console.log('AXIOS RESPONES', response)
134
- if (this.subjectInuUse[jobid][isCanceled]) {
135
- return [2 /*return*/];
136
- }
137
- this.handlerResult({
138
- res: {
139
- code: response.status,
140
- data: response.data,
141
- isArray: isArray,
142
- jobid: jobid,
143
- headers: rest_headers_1.RestHeaders.from(response.headers)
144
- },
145
- method: method,
146
- jobid: jobid,
147
- isArray: isArray
148
- }, {
149
- url: url,
150
- body: body,
151
- method: method,
152
- isArray: isArray,
153
- });
154
- return [3 /*break*/, 5];
155
- case 4:
156
- catchedError_1 = _a.sent();
157
- if (this.subjectInuUse[jobid][isCanceled]) {
158
- return [2 /*return*/];
159
- }
160
- // console.log('ERROR RESPONESE catchedError typeof ', typeof catchedError)
161
- // console.log('ERROR RESPONESE catchedError', catchedError)
162
- if (typeof catchedError_1 === 'object' && catchedError_1.response && catchedError_1.response.data) {
163
- err = catchedError_1.response.data;
164
- msg = catchedError_1.response.data.message || '';
165
- stack = (err.stack || '').split('\n');
166
- errObs = resource_service_1.Resource['_listenErrors'];
167
- errObs.next({
168
- msg: msg,
169
- stack: stack,
170
- data: catchedError_1.response.data
171
- });
172
- }
173
- error = (catchedError_1 && catchedError_1.response) ? "[".concat(catchedError_1.response.statusText, "]: ") : '';
174
- this.handlerResult({
175
- res: {
176
- code: (catchedError_1 && catchedError_1.response) ? catchedError_1.response.status : void 0,
177
- error: "".concat(error).concat(catchedError_1.message),
178
- data: (catchedError_1 && catchedError_1.response) ? JSON.stringify(catchedError_1.response.data) : void 0,
179
- isArray: isArray,
180
- jobid: jobid,
181
- headers: rest_headers_1.RestHeaders.from(catchedError_1 && catchedError_1.response && catchedError_1.response.headers)
182
- },
183
- method: method,
184
- jobid: jobid,
185
- isArray: isArray
186
- }, {
187
- url: url,
188
- body: body,
189
- isArray: isArray,
190
- method: method
191
- });
192
- return [3 /*break*/, 5];
193
- case 5: return [2 /*return*/];
194
- }
68
+ }
69
+ async req(url, method, headers, body, jobid, isArray = false, mockHttp) {
70
+ if (this.checkCache({
71
+ url,
72
+ body,
73
+ isArray,
74
+ method
75
+ }, jobid)) {
76
+ return;
77
+ }
78
+ const CancelToken = axios_1.default.CancelToken;
79
+ const source = CancelToken.source();
80
+ this.subjectInuUse[jobid][cancelFn] = source.cancel;
81
+ var response;
82
+ if (mockHttp) {
83
+ if (typeof mockHttp === 'object') {
84
+ response = {
85
+ data: mockHttp.data,
86
+ status: mockHttp.code,
87
+ headers: mockHttp.headers,
88
+ statusText: mockHttp.error,
89
+ config: {}
90
+ };
91
+ }
92
+ else if (typeof mockHttp === 'function') {
93
+ const r = mockHttp(url, method, headers, body);
94
+ response = {
95
+ data: r.data,
96
+ status: r.code,
97
+ headers: r.headers,
98
+ statusText: r.error,
99
+ config: {}
100
+ };
101
+ }
102
+ }
103
+ const headersJson = headers.toJSON();
104
+ const responseType = headersJson.responsetypeaxios ? headersJson.responsetypeaxios : 'text';
105
+ try {
106
+ if (!response) {
107
+ // console.log(`[${method}] (jobid=${jobid}) request to: ${url}`);
108
+ // console.log('headers axios:', headers.toJSON())
109
+ // console.log({ responseType, headersJson, body, method, url })
110
+ response = await (0, axios_1.default)({
111
+ url,
112
+ method,
113
+ data: body,
114
+ responseType,
115
+ headers: headersJson,
116
+ cancelToken: source.token,
117
+ // withCredentials: true, // this can be done manually
118
+ });
119
+ // log.d(`after response of jobid: ${jobid}`);
120
+ }
121
+ // console.log('AXIOS RESPONES', response)
122
+ if (this.subjectInuUse[jobid][isCanceled]) {
123
+ return;
124
+ }
125
+ this.handlerResult({
126
+ res: {
127
+ code: response.status,
128
+ data: response.data,
129
+ isArray,
130
+ jobid,
131
+ headers: rest_headers_1.RestHeaders.from(response.headers)
132
+ },
133
+ method,
134
+ jobid,
135
+ isArray
136
+ }, {
137
+ url,
138
+ body,
139
+ method,
140
+ isArray,
195
141
  });
196
- });
197
- };
198
- RestRequest.prototype.getReplay = function (method, meta, onlyGetLastReplayForMethod) {
199
- var _this = this;
200
- var replay;
142
+ }
143
+ catch (catchedError) {
144
+ if (this.subjectInuUse[jobid][isCanceled]) {
145
+ return;
146
+ }
147
+ // console.log('ERROR RESPONESE catchedError typeof ', typeof catchedError)
148
+ // console.log('ERROR RESPONESE catchedError', catchedError)
149
+ if (typeof catchedError === 'object' && catchedError.response && catchedError.response.data) {
150
+ const err = catchedError.response.data;
151
+ const msg = catchedError.response.data.message || '';
152
+ // console.log({
153
+ // 'err.stack': err?.stack
154
+ // })
155
+ let stack = (err.stack || '').split('\n');
156
+ const errObs = resource_service_1.Resource['_listenErrors'];
157
+ errObs.next({
158
+ msg,
159
+ stack,
160
+ data: catchedError.response.data
161
+ });
162
+ }
163
+ const error = (catchedError && catchedError.response) ? `[${catchedError.response.statusText}]: ` : '';
164
+ this.handlerResult({
165
+ res: {
166
+ code: (catchedError && catchedError.response) ? catchedError.response.status : void 0,
167
+ error: `${error}${catchedError.message}`,
168
+ data: (catchedError && catchedError.response) ? JSON.stringify(catchedError.response.data) : void 0,
169
+ isArray,
170
+ jobid,
171
+ headers: rest_headers_1.RestHeaders.from(catchedError && catchedError.response && catchedError.response.headers)
172
+ },
173
+ method,
174
+ jobid,
175
+ isArray
176
+ }, {
177
+ url,
178
+ body,
179
+ isArray,
180
+ method
181
+ });
182
+ }
183
+ }
184
+ getReplay(method, meta, onlyGetLastReplayForMethod) {
185
+ let replay;
201
186
  //#region prevent empty tree
202
187
  if (tnp_core_1._.isUndefined(this.replaySubjects[meta.endpoint])) {
203
188
  // log.i(`(${meta.endpoint}) `);
@@ -212,7 +197,7 @@ var RestRequest = /** @class */ (function () {
212
197
  this.replaySubjects[meta.endpoint][meta.path][method] = {};
213
198
  }
214
199
  //#endregion
215
- var objectIDToCreateOrLast = (Object.keys(this.replaySubjects[meta.endpoint][meta.path][method]).length) +
200
+ const objectIDToCreateOrLast = (Object.keys(this.replaySubjects[meta.endpoint][meta.path][method]).length) +
216
201
  (onlyGetLastReplayForMethod ? 0 : 1);
217
202
  if (onlyGetLastReplayForMethod && (objectIDToCreateOrLast === 0)) {
218
203
  return replay;
@@ -229,31 +214,31 @@ var RestRequest = /** @class */ (function () {
229
214
  if (RestRequest.jobId === Number.MAX_SAFE_INTEGER) {
230
215
  RestRequest.jobId = 0;
231
216
  }
232
- var jobid_1 = RestRequest.jobId++;
233
- replay.id = jobid_1;
234
- var subject_1 = replay.subject;
235
- subject_1[jobIDkey] = jobid_1; // modify internal rxjs subject obj
236
- this.meta[jobid_1] = meta;
237
- this.subjectInuUse[jobid_1] = subject_1;
238
- this.subjectInuUse[jobid_1][customObs] = new rxjs_1.Observable(function (observer) {
217
+ const jobid = RestRequest.jobId++;
218
+ replay.id = jobid;
219
+ const subject = replay.subject;
220
+ subject[jobIDkey] = jobid; // modify internal rxjs subject obj
221
+ this.meta[jobid] = meta;
222
+ this.subjectInuUse[jobid] = subject;
223
+ this.subjectInuUse[jobid][customObs] = new rxjs_1.Observable((observer) => {
239
224
  // observer.remove(() => {
240
225
  // });
241
- observer.add(function () {
226
+ observer.add(() => {
242
227
  // console.log(`cancel observable job${jobid}`)
243
- if (!_this.subjectInuUse[jobid_1][isCanceled]) {
244
- _this.subjectInuUse[jobid_1][isCanceled] = true;
245
- if (typeof _this.subjectInuUse[jobid_1][cancelFn] === 'function') {
246
- _this.subjectInuUse[jobid_1][cancelFn]('[ng2-rest] on purpose canceled http request');
228
+ if (!this.subjectInuUse[jobid][isCanceled]) {
229
+ this.subjectInuUse[jobid][isCanceled] = true;
230
+ if (typeof this.subjectInuUse[jobid][cancelFn] === 'function') {
231
+ this.subjectInuUse[jobid][cancelFn]('[ng2-rest] on purpose canceled http request');
247
232
  }
248
233
  }
249
234
  else {
250
235
  // console.log(`somehow second time cancel ${jobid}`)
251
236
  }
252
237
  });
253
- var sub = subject_1.subscribe({
254
- next: function (a) { return observer.next(a); },
255
- error: function (a) { return observer.error(a); },
256
- complete: function () {
238
+ const sub = subject.subscribe({
239
+ next: a => observer.next(a),
240
+ error: a => observer.error(a),
241
+ complete: () => {
257
242
  sub.unsubscribe();
258
243
  observer.complete();
259
244
  },
@@ -272,114 +257,111 @@ var RestRequest = /** @class */ (function () {
272
257
  //#endregion
273
258
  }
274
259
  return replay;
275
- };
260
+ }
276
261
  //#region http methods
277
- RestRequest.prototype.generalReq = function (method, url, body, headers, meta, isArray, mockHttp) {
278
- var replay = this.getReplay(method, meta, false);
279
- replay.data = { url: url, body: body, headers: headers, isArray: isArray };
280
- (function (pthis, purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp) {
262
+ generalReq(method, url, body, headers, meta, isArray, mockHttp) {
263
+ const replay = this.getReplay(method, meta, false);
264
+ replay.data = { url, body, headers, isArray };
265
+ ((pthis, purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp) => {
281
266
  // log.d(`for ${purl} jobid ${pid}`);
282
- setTimeout(function () { return pthis.req(purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp); });
267
+ setTimeout(() => pthis.req(purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp));
283
268
  })(this, url, method, headers, body, replay.id, isArray, mockHttp);
284
- var resp = (0, rxjs_1.firstValueFrom)(replay.subject[customObs]);
269
+ const resp = (0, rxjs_1.firstValueFrom)(replay.subject[customObs]);
285
270
  resp.observable = replay.subject[customObs];
286
271
  resp.cache = request_cache_1.RequestCache.findBy({
287
- body: body,
288
- isArray: isArray,
289
- method: method,
290
- url: url
272
+ body,
273
+ isArray,
274
+ method,
275
+ url
291
276
  });
292
277
  return resp;
293
- };
294
- RestRequest.prototype.get = function (url, body, headers, meta, isArray, mockHttp) {
278
+ }
279
+ get(url, body, headers, meta, isArray, mockHttp) {
295
280
  return this.generalReq('get', url, body, headers, meta, isArray, mockHttp);
296
- };
297
- RestRequest.prototype.head = function (url, body, headers, meta, isArray, mockHttp) {
281
+ }
282
+ head(url, body, headers, meta, isArray, mockHttp) {
298
283
  return this.generalReq('head', url, body, headers, meta, isArray, mockHttp);
299
- };
300
- RestRequest.prototype.delete = function (url, body, headers, meta, isArray, mockHttp) {
284
+ }
285
+ delete(url, body, headers, meta, isArray, mockHttp) {
301
286
  return this.generalReq('delete', url, body, headers, meta, isArray, mockHttp);
302
- };
303
- RestRequest.prototype.post = function (url, body, headers, meta, isArray, mockHttp) {
287
+ }
288
+ post(url, body, headers, meta, isArray, mockHttp) {
304
289
  return this.generalReq('post', url, body, headers, meta, isArray, mockHttp);
305
- };
306
- RestRequest.prototype.put = function (url, body, headers, meta, isArray, mockHttp) {
290
+ }
291
+ put(url, body, headers, meta, isArray, mockHttp) {
307
292
  return this.generalReq('put', url, body, headers, meta, isArray, mockHttp);
308
- };
309
- RestRequest.prototype.patch = function (url, body, headers, meta, isArray, mockHttp) {
293
+ }
294
+ patch(url, body, headers, meta, isArray, mockHttp) {
310
295
  return this.generalReq('patch', url, body, headers, meta, isArray, mockHttp);
311
- };
312
- RestRequest.prototype.jsonp = function (url, body, headers, meta, isArray, mockHttp) {
313
- var _this = this;
314
- var replay = this.getReplay('jsonp', meta, false);
315
- var jobid = replay.id;
316
- var method = 'jsonp';
317
- setTimeout(function () {
296
+ }
297
+ jsonp(url, body, headers, meta, isArray, mockHttp) {
298
+ const replay = this.getReplay('jsonp', meta, false);
299
+ const jobid = replay.id;
300
+ const method = 'jsonp';
301
+ setTimeout(() => {
318
302
  if (url.endsWith('/'))
319
303
  url = url.slice(0, url.length - 1);
320
- var num = Math.round(10000 * Math.random());
321
- var callbackMethodName = "cb_" + num;
322
- window[callbackMethodName] = function (data) {
323
- if (_this.checkCache({
324
- url: url,
325
- body: body,
326
- isArray: isArray,
327
- method: method
304
+ let num = Math.round(10000 * Math.random());
305
+ let callbackMethodName = "cb_" + num;
306
+ window[callbackMethodName] = (data) => {
307
+ if (this.checkCache({
308
+ url,
309
+ body,
310
+ isArray,
311
+ method
328
312
  }, jobid)) {
329
313
  return;
330
314
  }
331
- _this.handlerResult({
315
+ this.handlerResult({
332
316
  res: {
333
- data: data,
334
- isArray: isArray
317
+ data, isArray
335
318
  },
336
- method: method,
337
- jobid: jobid,
338
- isArray: isArray
319
+ method,
320
+ jobid,
321
+ isArray
339
322
  }, {
340
- url: url,
341
- body: body,
342
- isArray: isArray,
343
- method: method,
323
+ url,
324
+ body,
325
+ isArray,
326
+ method,
344
327
  });
345
328
  };
346
- var sc = document.createElement('script');
347
- sc.src = "".concat(url, "?callback=").concat(callbackMethodName);
329
+ let sc = document.createElement('script');
330
+ sc.src = `${url}?callback=${callbackMethodName}`;
348
331
  document.body.appendChild(sc);
349
332
  document.body.removeChild(sc);
350
333
  });
351
- var resp = (0, rxjs_1.firstValueFrom)(replay.subject[customObs]);
334
+ const resp = (0, rxjs_1.firstValueFrom)(replay.subject[customObs]);
352
335
  resp.observable = replay.subject[customObs];
353
336
  console.log('assiging custom observable');
354
337
  resp.cache = request_cache_1.RequestCache.findBy({
355
- body: body,
356
- isArray: isArray,
357
- method: method,
358
- url: url
338
+ body,
339
+ isArray,
340
+ method,
341
+ url
359
342
  });
360
343
  return resp;
361
- };
362
- RestRequest.prototype.replay = function (method, meta) {
363
- var _this = this;
364
- var replay = this.getReplay(method, meta, true);
344
+ }
345
+ //#endregion
346
+ replaySubjects = {};
347
+ replay(method, meta) {
348
+ const replay = this.getReplay(method, meta, true);
365
349
  if (!replay || !replay.data) {
366
- console.warn("Canno replay first ".concat(method, " request from ").concat(meta.endpoint, "/").concat(meta.path));
350
+ console.warn(`Canno replay first ${method} request from ${meta.endpoint}/${meta.path}`);
367
351
  return;
368
352
  }
369
353
  ;
370
354
  if (replay && replay.subject && Array.isArray(replay.subject.observers) &&
371
355
  replay.subject.observers.length === 0) {
372
- console.warn("No observators for ".concat(method, " request from ").concat(meta.endpoint, "/").concat(meta.path));
356
+ console.warn(`No observators for ${method} request from ${meta.endpoint}/${meta.path}`);
373
357
  return;
374
358
  }
375
- var url = replay.data.url;
376
- var headers = replay.data.headers;
377
- var body = replay.data.body;
378
- var isArray = replay.data.isArray;
379
- setTimeout(function () { return _this.req(url, method, headers, body, replay.id, isArray); });
380
- };
381
- RestRequest.jobId = 0;
382
- return RestRequest;
383
- }());
359
+ const url = replay.data.url;
360
+ const headers = replay.data.headers;
361
+ const body = replay.data.body;
362
+ const isArray = replay.data.isArray;
363
+ setTimeout(() => this.req(url, method, headers, body, replay.id, isArray));
364
+ }
365
+ }
384
366
  exports.RestRequest = RestRequest;
385
367
  //# sourceMappingURL=rest-request.js.map