ng2-rest 13.1.5 → 13.1.7

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 (115) hide show
  1. package/app.d.ts +0 -1
  2. package/app.js +3 -3
  3. package/browser/esm2020/lib/content-type.mjs +2 -1
  4. package/browser/esm2020/lib/cookie.mjs +3 -1
  5. package/browser/esm2020/lib/helpers.mjs +3 -1
  6. package/browser/esm2020/lib/index.mjs +3 -1
  7. package/browser/esm2020/lib/mapping.mjs +3 -21
  8. package/browser/esm2020/lib/models.mjs +3 -9
  9. package/browser/esm2020/lib/other/simple-resource.mjs +3 -2
  10. package/browser/esm2020/lib/params.mjs +3 -29
  11. package/browser/esm2020/lib/request-cache.mjs +3 -1
  12. package/browser/esm2020/lib/resource.service.mjs +3 -38
  13. package/browser/esm2020/lib/rest-headers.mjs +3 -3
  14. package/browser/esm2020/lib/rest-request.mjs +3 -36
  15. package/browser/esm2020/lib/rest.class.mjs +3 -11
  16. package/browser/fesm2015/ng2-rest.mjs +26 -141
  17. package/browser/fesm2020/ng2-rest.mjs +26 -141
  18. package/browser/lib/content-type.d.ts +2 -1
  19. package/browser/lib/cookie.d.ts +2 -1
  20. package/browser/lib/helpers.d.ts +2 -1
  21. package/browser/lib/index.d.ts +2 -1
  22. package/browser/lib/mapping.d.ts +2 -1
  23. package/browser/lib/models.d.ts +2 -1
  24. package/browser/lib/other/simple-resource.d.ts +2 -1
  25. package/browser/lib/params.d.ts +2 -1
  26. package/browser/lib/request-cache.d.ts +2 -1
  27. package/browser/lib/resource.service.d.ts +2 -1
  28. package/browser/lib/rest-headers.d.ts +2 -1
  29. package/browser/lib/rest-request.d.ts +2 -1
  30. package/browser/lib/rest.class.d.ts +2 -1
  31. package/browser/ng2-rest.d.ts +2 -1
  32. package/browser/public-api.d.ts +2 -1
  33. package/client/esm2020/lib/content-type.mjs +2 -1
  34. package/client/esm2020/lib/cookie.mjs +3 -1
  35. package/client/esm2020/lib/helpers.mjs +3 -1
  36. package/client/esm2020/lib/index.mjs +3 -1
  37. package/client/esm2020/lib/mapping.mjs +3 -21
  38. package/client/esm2020/lib/models.mjs +3 -9
  39. package/client/esm2020/lib/other/simple-resource.mjs +3 -2
  40. package/client/esm2020/lib/params.mjs +3 -29
  41. package/client/esm2020/lib/request-cache.mjs +3 -1
  42. package/client/esm2020/lib/resource.service.mjs +3 -38
  43. package/client/esm2020/lib/rest-headers.mjs +3 -3
  44. package/client/esm2020/lib/rest-request.mjs +3 -36
  45. package/client/esm2020/lib/rest.class.mjs +3 -11
  46. package/client/fesm2015/ng2-rest.mjs +26 -141
  47. package/client/fesm2020/ng2-rest.mjs +26 -141
  48. package/client/lib/content-type.d.ts +2 -1
  49. package/client/lib/cookie.d.ts +2 -1
  50. package/client/lib/helpers.d.ts +2 -1
  51. package/client/lib/index.d.ts +2 -1
  52. package/client/lib/mapping.d.ts +2 -1
  53. package/client/lib/models.d.ts +2 -1
  54. package/client/lib/other/simple-resource.d.ts +2 -1
  55. package/client/lib/params.d.ts +2 -1
  56. package/client/lib/request-cache.d.ts +2 -1
  57. package/client/lib/resource.service.d.ts +2 -1
  58. package/client/lib/rest-headers.d.ts +2 -1
  59. package/client/lib/rest-request.d.ts +2 -1
  60. package/client/lib/rest.class.d.ts +2 -1
  61. package/client/ng2-rest.d.ts +2 -1
  62. package/client/public-api.d.ts +2 -1
  63. package/package.json +9 -9
  64. package/tmp-environment.json +163 -161
  65. package/websql/esm2020/lib/content-type.mjs +2 -1
  66. package/websql/esm2020/lib/cookie.mjs +3 -1
  67. package/websql/esm2020/lib/helpers.mjs +3 -1
  68. package/websql/esm2020/lib/index.mjs +3 -1
  69. package/websql/esm2020/lib/mapping.mjs +3 -21
  70. package/websql/esm2020/lib/models.mjs +3 -9
  71. package/websql/esm2020/lib/other/simple-resource.mjs +3 -2
  72. package/websql/esm2020/lib/params.mjs +3 -29
  73. package/websql/esm2020/lib/request-cache.mjs +3 -1
  74. package/websql/esm2020/lib/resource.service.mjs +3 -38
  75. package/websql/esm2020/lib/rest-headers.mjs +3 -3
  76. package/websql/esm2020/lib/rest-request.mjs +3 -36
  77. package/websql/esm2020/lib/rest.class.mjs +3 -11
  78. package/websql/fesm2015/ng2-rest.mjs +26 -141
  79. package/websql/fesm2020/ng2-rest.mjs +26 -141
  80. package/websql/lib/content-type.d.ts +2 -1
  81. package/websql/lib/cookie.d.ts +2 -1
  82. package/websql/lib/helpers.d.ts +2 -1
  83. package/websql/lib/index.d.ts +2 -1
  84. package/websql/lib/mapping.d.ts +2 -1
  85. package/websql/lib/models.d.ts +2 -1
  86. package/websql/lib/other/simple-resource.d.ts +2 -1
  87. package/websql/lib/params.d.ts +2 -1
  88. package/websql/lib/request-cache.d.ts +2 -1
  89. package/websql/lib/resource.service.d.ts +2 -1
  90. package/websql/lib/rest-headers.d.ts +2 -1
  91. package/websql/lib/rest-request.d.ts +2 -1
  92. package/websql/lib/rest.class.d.ts +2 -1
  93. package/websql/ng2-rest.d.ts +2 -1
  94. package/websql/public-api.d.ts +2 -1
  95. package/app.js.map +0 -1
  96. package/browser/fesm2015/ng2-rest.mjs.map +0 -1
  97. package/browser/fesm2020/ng2-rest.mjs.map +0 -1
  98. package/client/fesm2015/ng2-rest.mjs.map +0 -1
  99. package/client/fesm2020/ng2-rest.mjs.map +0 -1
  100. package/index.js.map +0 -1
  101. package/lib/content-type.js.map +0 -1
  102. package/lib/cookie.js.map +0 -1
  103. package/lib/helpers.js.map +0 -1
  104. package/lib/index.js.map +0 -1
  105. package/lib/mapping.js.map +0 -1
  106. package/lib/models.js.map +0 -1
  107. package/lib/other/simple-resource.js.map +0 -1
  108. package/lib/params.js.map +0 -1
  109. package/lib/request-cache.js.map +0 -1
  110. package/lib/resource.service.js.map +0 -1
  111. package/lib/rest-headers.js.map +0 -1
  112. package/lib/rest-request.js.map +0 -1
  113. package/lib/rest.class.js.map +0 -1
  114. package/websql/fesm2015/ng2-rest.mjs.map +0 -1
  115. package/websql/fesm2020/ng2-rest.mjs.map +0 -1
@@ -10,7 +10,6 @@ import axios from 'axios';
10
10
  var Mapping;
11
11
  (function (Mapping) {
12
12
  function decode(json, autodetect = false) {
13
- // console.log('DECODE isBrowser', HelpersLog.isBrowser)
14
13
  if (_.isUndefined(json)) {
15
14
  return void 0;
16
15
  }
@@ -49,7 +48,6 @@ var Mapping;
49
48
  return {};
50
49
  }
51
50
  const className = CLASS.getName(entity);
52
- // console.log(`getMaping for: '${className}' `)
53
51
  let enityOWnMapping = _.isArray(entity[SYMBOL.MODELS_MAPPING]) ?
54
52
  entity[SYMBOL.MODELS_MAPPING] : [{ '': className }];
55
53
  let res = {};
@@ -58,7 +56,6 @@ var Mapping;
58
56
  .map(m => m['']);
59
57
  enityOWnMapping.reverse().forEach(m => {
60
58
  m = _.cloneDeep(m);
61
- // console.log(`'${className}' m:`, m)
62
59
  Object.keys(m).forEach(key => {
63
60
  const v = m[key];
64
61
  const isArr = _.isArray(v);
@@ -70,7 +67,6 @@ var Mapping;
70
67
  res = _.merge(res, m);
71
68
  });
72
69
  res[''] = className;
73
- // console.log(`mapping for ${className} : ${JSON.stringify(res)}`)
74
70
  return res;
75
71
  }
76
72
  Mapping.getModelsMapping = getModelsMapping;
@@ -111,7 +107,6 @@ var Mapping;
111
107
  const v = c[p];
112
108
  if (Array.isArray(v) && v.length > 0) { // reducer as impovement
113
109
  v.forEach((elem, i) => {
114
- // const currentPaht = [`path[${i}]`, p].filter(c => c.trim() != '').join('.');
115
110
  const currentPaht = [path, p].filter(c => c.trim() != '').join('.');
116
111
  getMappingNaive(elem, currentPaht, mapping, level);
117
112
  });
@@ -140,7 +135,6 @@ var Mapping;
140
135
  }
141
136
  function setMappingCirc(json, mapping = {}, circular = []) {
142
137
  const mainClassFn = !_.isArray(json) && CLASS.getBy(mapping['']);
143
- // console.log(mapping)
144
138
  walk.Object(json, (v, lodashPath, changeValue) => {
145
139
  if (!_.isUndefined(v) && !_.isNull(v)) {
146
140
  const mappingPath = getMappingPathFrom(lodashPath);
@@ -150,7 +144,6 @@ var Mapping;
150
144
  const className = isArray ? _.first(mapping[mappingPath]) : mapping[mappingPath];
151
145
  const classFN = CLASS.getBy(className);
152
146
  if (_.isFunction(classFN)) {
153
- // console.log(`mapping: '${mappingPath}', lp: '${lodashPath}' class: '${className}' , set `, v.location)
154
147
  changeValue(_.merge(new classFN(), v));
155
148
  }
156
149
  }
@@ -167,7 +160,6 @@ var Mapping;
167
160
  return json;
168
161
  }
169
162
  function setMapping(json, mapping = {}) {
170
- // console.log('mapping', mapping)
171
163
  if (Array.isArray(json)) {
172
164
  return json.map(j => {
173
165
  return setMapping(j, mapping);
@@ -176,9 +168,6 @@ var Mapping;
176
168
  const mainClassFn = CLASS.getBy(mapping['']);
177
169
  for (const key in json) {
178
170
  if (json.hasOwnProperty(key)) {
179
- // if (mainClassFn && mainClassFn.name === 'Project') {
180
- // // console.log(`OWn property: "${key}"`)
181
- // }
182
171
  if (_.isArray(json[key])) {
183
172
  json[key] = json[key].map(arrObj => {
184
173
  const objMapping = getModelsMapping(CLASS.getBy(mapping[key]));
@@ -190,17 +179,11 @@ var Mapping;
190
179
  json[key] = setMapping(json[key], objMapping);
191
180
  }
192
181
  }
193
- // else {
194
- // if (mainClassFn && mainClassFn.name === 'Project') {
195
- // // console.log(`Not own property: "${key}"`)
196
- // }
197
- // }
198
182
  }
199
183
  Object
200
184
  .keys(mapping)
201
185
  .filter(key => key !== '' && key.split('.').length >= 2)
202
186
  .forEach(lodasPath => {
203
- // console.log(`Loadsh path: ${lodasPath}`)
204
187
  const objMapping = getModelsMapping(CLASS.getBy(mapping[lodasPath]));
205
188
  const input = _.get(json, lodasPath);
206
189
  if (!_.isUndefined(input)) {
@@ -239,7 +222,6 @@ var Mapping;
239
222
  const describedTarget = CLASS
240
223
  .describeProperites(target)
241
224
  .filter(prop => /^([a-zA-Z0-9]|\_|\#)+$/.test(prop));
242
- // console.log(`describedTarget: ${describedTarget} for ${target.name}`)
243
225
  describedTarget.forEach(propDefInConstr => {
244
226
  if (defaultModelValues[propDefInConstr]) {
245
227
  console.warn(`
@@ -254,7 +236,6 @@ var Mapping;
254
236
  toMerge[propDefInConstr] = null; // TODO from toString I can't know that
255
237
  }
256
238
  });
257
- // console.log(`merge "${JSON.stringify(target.prototype)}" with "${JSON.stringify(defaultModelValues)}"`)
258
239
  target[SYMBOL.DEFAULT_MODEL] = _.merge(toMerge, defaultModelValues);
259
240
  const propsToOmmit = Object
260
241
  .keys(target[SYMBOL.DEFAULT_MODEL])
@@ -264,12 +245,13 @@ var Mapping;
264
245
  return !!descriptor;
265
246
  });
266
247
  _.merge(target.prototype, _.omit(target[SYMBOL.DEFAULT_MODEL], propsToOmmit));
267
- // console.log(`DEFAULT VALUE MERGE for ${target.name}`)
268
248
  }
269
249
  };
270
250
  }
271
251
  Mapping.DefaultModelWithMapping = DefaultModelWithMapping;
272
252
  })(Mapping || (Mapping = {}));
253
+ ;
254
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/mapping.ts
273
255
 
274
256
  // @ts-ignore
275
257
  class Helpers extends CoreHelpers {
@@ -289,6 +271,8 @@ class Helpers extends CoreHelpers {
289
271
  }
290
272
  }
291
273
  Helpers.JSON = JSON10;
274
+ ;
275
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/helpers.ts
292
276
 
293
277
  const log$3 = Log.create('[ng2-rest] params', Level.__NOTHING);
294
278
  /** check if string is a valid pattern */
@@ -323,12 +307,9 @@ function getRestPramsNames(pattern) {
323
307
  function containsModels(url, models) {
324
308
  if (url.charAt(0) !== '/')
325
309
  url = '/' + url;
326
- // url = url.replace(new RegExp('\/', 'g'), '');
327
310
  let res = models.filter(m => {
328
311
  let word = '/' + m;
329
- // log.d('word', word)
330
312
  let iii = url.indexOf(word);
331
- // log.d('iii', iii)
332
313
  if (iii + word.length < url.length && url.charAt(iii + word.length) !== '/') {
333
314
  return false;
334
315
  }
@@ -338,7 +319,6 @@ function containsModels(url, models) {
338
319
  }
339
320
  return false;
340
321
  }).length;
341
- // log.d('containsModels', res);
342
322
  return res === models.length;
343
323
  }
344
324
  function stars(n) {
@@ -350,13 +330,11 @@ function stars(n) {
350
330
  function getRestParams(url, pattern) {
351
331
  let res = {};
352
332
  let models = getRestPramsNames(pattern);
353
- // log.d('models', models);
354
333
  models.forEach(m => {
355
334
  pattern = pattern.replace(`:${m}`, stars(m.length));
356
335
  });
357
336
  let currentModel = void 0;
358
337
  diffChars(pattern, url).forEach(d => {
359
- // log.d('d', d);
360
338
  if (d.added) {
361
339
  if (!isNaN(Number(d.value)))
362
340
  res[currentModel] = Number(d.value);
@@ -369,7 +347,6 @@ function getRestParams(url, pattern) {
369
347
  currentModel = void 0;
370
348
  }
371
349
  let m = d.value.replace(':', "");
372
- // log.d('model m', m)
373
350
  if (d.removed) {
374
351
  currentModel = models.shift();
375
352
  }
@@ -386,7 +363,6 @@ function cutUrlModel(params, models, output) {
386
363
  let m = models.pop();
387
364
  let param = m.match(/:[a-zA-Z0-9\.]+/)[0].replace(':', '');
388
365
  const paramIsPath = regexisPath.test(param);
389
- // log.i('cut param', param)
390
366
  let model = m.match(/[a-zA-Z0-9]+\//)[0].replace('\/', '');
391
367
  if (params === void 0 ||
392
368
  (paramIsPath ? _.get(params, param) === void 0 : params[param] === void 0) ||
@@ -397,13 +373,11 @@ function cutUrlModel(params, models, output) {
397
373
  }
398
374
  else {
399
375
  if (paramIsPath) {
400
- // log.i('param is path', param)
401
376
  let mrep = m.replace(new RegExp(`:${param}`, 'g'), `${_.get(params, param)}`);
402
377
  output.unshift(mrep);
403
378
  return cutUrlModel(params, models, output);
404
379
  }
405
380
  else {
406
- // log.i('param is normal', param)
407
381
  let mrep = m.replace(new RegExp(`:${param}`, 'g'), `${params[param]}`);
408
382
  output.unshift(mrep);
409
383
  return cutUrlModel(params, models, output);
@@ -413,13 +387,10 @@ function cutUrlModel(params, models, output) {
413
387
  function interpolateParamsToUrl(params, url) {
414
388
  const regexInt = /\[\[([^\..]+\.[^\..]+)+\]\]/g;
415
389
  url = url.split('/').map(p => {
416
- // log.d('url parts', p)
417
390
  let isParam = p.startsWith(':');
418
391
  if (isParam) {
419
392
  let part = p.slice(1);
420
- // log.d('url param part', p)
421
393
  if (regexInt.test(part)) {
422
- // let level = (url.split('.').length - 1)
423
394
  part = part.replace('[[', '');
424
395
  part = part.replace(']]', '');
425
396
  }
@@ -427,35 +398,28 @@ function interpolateParamsToUrl(params, url) {
427
398
  }
428
399
  return p;
429
400
  }).join('/');
430
- // log.i('URL TO EXPOSE', url)
431
- // log.i('params', params)
432
401
  let slash = {
433
402
  start: url.charAt(0) === '\/',
434
403
  end: url.charAt(url.length - 1) === '\/'
435
404
  };
436
405
  let morePramsOnEnd = url.match(/(\/:[a-zA-Z0-9\.]+){2,10}/g);
437
406
  if (morePramsOnEnd && (Array.isArray(morePramsOnEnd) && morePramsOnEnd.length === 1)) {
438
- // log.i('morePramsOnEnd', morePramsOnEnd)
439
407
  let m = morePramsOnEnd[0];
440
408
  let match = m.match(/\/:[a-zA-Z0-9\.]+/g);
441
- // log.i('match', match)
442
409
  match.forEach(e => {
443
410
  let c = e.replace('\/:', '');
444
- // log.i('c', c)
445
411
  if (regexisPath.test(c)) {
446
412
  url = url.replace(e, `/${_.get(params, c)}`);
447
413
  }
448
414
  else {
449
415
  url = url.replace(e, `/${params[c]}`);
450
416
  }
451
- // log.i('prog url', url)
452
417
  });
453
418
  return url;
454
419
  }
455
420
  let nestedParams = url.match(/[a-zA-Z0-9]+\/:[a-zA-Z0-9\.]+/g);
456
421
  if (!nestedParams || (Array.isArray(nestedParams) && nestedParams.length === 0))
457
422
  return url;
458
- // check alone params
459
423
  if (!slash.end)
460
424
  url = `${url}/`;
461
425
  let addUndefinedForAlone = (!/:[a-zA-Z0-9\.]+\/$/g.test(url) && /[a-zA-Z0-9]+\/$/g.test(url));
@@ -492,14 +456,12 @@ function decodeUrl(url) {
492
456
  continue;
493
457
  }
494
458
  if (paramsObject.hasOwnProperty(p)) {
495
- // chcek if property is number
496
459
  let n = Number(params[p]);
497
460
  if (!isNaN(n)) {
498
461
  params[p] = n;
499
462
  continue;
500
463
  }
501
464
  if (typeof params[p] === 'string') {
502
- // check if property is object
503
465
  let json;
504
466
  try {
505
467
  json = JSON.parse(params[p]);
@@ -509,12 +471,6 @@ function decodeUrl(url) {
509
471
  params[p] = json;
510
472
  continue;
511
473
  }
512
- // chcek if property value is like regular rexpression
513
- // let regexExpression;
514
- // try {
515
- // regexExpression = new RegExp(params[p]);
516
- // } catch (e) { }
517
- // if (regexExpression !== undefined) params[p] = regexExpression;
518
474
  }
519
475
  }
520
476
  }
@@ -590,6 +546,8 @@ function prepareUrlOldWay(params) {
590
546
  }
591
547
  return this.endpoint + '/' + params;
592
548
  }
549
+ ;
550
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/params.ts
593
551
 
594
552
  class RestHeaders {
595
553
  constructor(headers) {
@@ -693,11 +651,9 @@ class RestHeaders {
693
651
  /**
694
652
  * Returns string of all headers.
695
653
  */
696
- // TODO(vicb): returns {[name: string]: string[]}
697
654
  toJSON() {
698
655
  const serialized = {};
699
656
  if (!this._headers) {
700
- // debugger
701
657
  }
702
658
  this._headers.forEach((values, name) => {
703
659
  const split = [];
@@ -719,6 +675,8 @@ class RestHeaders {
719
675
  }
720
676
  }
721
677
  }
678
+ ;
679
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/rest-headers.ts
722
680
 
723
681
  const CONTENT_TYPE = {
724
682
  APPLICATION_JSON: RestHeaders.from({
@@ -730,17 +688,14 @@ const CONTENT_TYPE = {
730
688
  'Accept': 'application/vnd.api+json'
731
689
  }),
732
690
  };
691
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/content-type.ts
733
692
 
734
- //#endregion
735
693
  class Rest {
736
694
  constructor(endpoint, request, meta, customContentType) {
737
695
  this.request = request;
738
696
  this.meta = meta;
739
697
  this.customContentType = customContentType;
740
- //#endregion
741
- //#region constructor
742
698
  this._headers = RestHeaders.from(CONTENT_TYPE.APPLICATION_JSON);
743
- //#endregion
744
699
  this.array = {
745
700
  get: (params = void 0, doNotSerializeParams) => {
746
701
  return this.req('get', void 0, params, doNotSerializeParams, true);
@@ -801,12 +756,9 @@ class Rest {
801
756
  get headers() {
802
757
  return this._headers;
803
758
  }
804
- //#endregion
805
- //#region req
806
759
  req(method, item, params, doNotSerializeParams = false, isArray = false) {
807
760
  const modelUrl = this.creatUrl(params, doNotSerializeParams);
808
761
  const body = item ? JSON.stringify(item) : void 0;
809
- // console.log('this.customContentType', this.customContentType)
810
762
  if (this.customContentType) {
811
763
  const customHeaderKeys = this.customContentType.keys();
812
764
  const currentHeaderKeys = this._headers.keys();
@@ -824,9 +776,6 @@ class Rest {
824
776
  this.mockHttp = void 0;
825
777
  return result;
826
778
  }
827
- //#endregion
828
- //#region http methods
829
- //#region replay
830
779
  replay(method) {
831
780
  this.request.replay(method, this.meta);
832
781
  }
@@ -852,6 +801,8 @@ class Rest {
852
801
  return this.req('jsonp', void 0, params, doNotSerializeParams);
853
802
  }
854
803
  }
804
+ ;
805
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/rest.class.ts
855
806
 
856
807
  class Cookie {
857
808
  constructor() {
@@ -879,6 +830,8 @@ class Cookie {
879
830
  this.write(name, "", -1);
880
831
  }
881
832
  }
833
+ ;
834
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/cookie.ts
882
835
 
883
836
  const log$2 = Log.create('request-cache', Level.__NOTHING);
884
837
  class RequestCache {
@@ -970,8 +923,9 @@ class RequestCache {
970
923
  RequestCache.LOCAL_STORAGE_KEY = 'ng2restrequestcache';
971
924
  RequestCache.cached = [];
972
925
  RequestCache.isRestoredFromLocalStorage = false;
926
+ ;
927
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/request-cache.ts
973
928
 
974
- // const log = Log.create('rest namespace', Level.__NOTHING)
975
929
  var Models;
976
930
  (function (Models) {
977
931
  Models.MethodConfig = Models$1.MethodConfig;
@@ -1070,21 +1024,16 @@ var Models;
1070
1024
  this.circular = circular;
1071
1025
  this.jobid = jobid;
1072
1026
  this.isArray = isArray;
1073
- // console.log({
1074
- // sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray
1075
- // })
1076
1027
  this.init();
1077
1028
  }
1078
1029
  init() {
1079
1030
  if (typeof this.entity === 'string') {
1080
- // const headerWithMapping = headers.get(entity);
1081
1031
  let entityJSON = this.headers.getAll(this.entity);
1082
1032
  if (!!entityJSON) {
1083
1033
  this.entity = JSON.parse(entityJSON.join());
1084
1034
  }
1085
1035
  }
1086
1036
  if (typeof this.circular === 'string') {
1087
- // const headerWithMapping = headers.get(circular);
1088
1037
  let circuralJSON = this.headers.getAll(this.circular);
1089
1038
  if (!!circuralJSON) {
1090
1039
  this.circular = JSON.parse(circuralJSON.join());
@@ -1101,8 +1050,6 @@ var Models;
1101
1050
  }
1102
1051
  Models.HttpResponse = HttpResponse;
1103
1052
  class HttpResponseError extends BaseResponse {
1104
- // public tryRecconect() {
1105
- // }
1106
1053
  constructor(message, responseText, headers, statusCode, jobid) {
1107
1054
  super(responseText, headers, statusCode);
1108
1055
  this.message = message;
@@ -1112,26 +1059,24 @@ var Models;
1112
1059
  }
1113
1060
  Models.HttpResponseError = HttpResponseError;
1114
1061
  })(Models || (Models = {}));
1062
+ ;
1063
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/models.ts
1115
1064
 
1116
1065
  const log$1 = Log.create('[ng2-rest] rest-request', Level.__NOTHING);
1117
1066
  const jobIDkey = 'jobID';
1118
1067
  const customObs = 'customObs';
1119
1068
  const cancelFn = 'cancelFn';
1120
1069
  const isCanceled = 'isCanceled';
1121
- //#region mock request
1122
- //#endregion
1123
1070
  class RestRequest {
1124
1071
  constructor() {
1125
1072
  this.subjectInuUse = {};
1126
1073
  this.meta = {};
1127
- //#endregion
1128
1074
  this.replaySubjects = {};
1129
1075
  }
1130
1076
  handlerResult(options, sourceRequest) {
1131
1077
  if (_.isUndefined(options)) {
1132
1078
  options = {};
1133
1079
  }
1134
- // log.d(`HANDLE RESULT (jobid:${options.jobid}) ${sourceRequest.url}`);
1135
1080
  const { res, jobid, isArray, method } = options;
1136
1081
  if (typeof res !== 'object') {
1137
1082
  throw new Error('No resposnse for request. ');
@@ -1139,7 +1084,6 @@ class RestRequest {
1139
1084
  if (Helpers$1.isBrowser) {
1140
1085
  res.headers = RestHeaders.from(res.headers);
1141
1086
  }
1142
- // error no internet
1143
1087
  if (res.error) {
1144
1088
  this.subjectInuUse[jobid].error(new Models.HttpResponseError(res.error, res.data, res.headers, res.code, jobid));
1145
1089
  return;
@@ -1163,7 +1107,6 @@ class RestRequest {
1163
1107
  this.subjectInuUse[jobid].complete();
1164
1108
  return true;
1165
1109
  }
1166
- // log.i(`cache not exists for jobid ${jobid}`)
1167
1110
  return false;
1168
1111
  }
1169
1112
  async req(url, method, headers, body, jobid, isArray = false, mockHttp) {
@@ -1202,8 +1145,6 @@ class RestRequest {
1202
1145
  }
1203
1146
  try {
1204
1147
  if (!response) {
1205
- // console.log(`[${method}] (jobid=${jobid}) request to: ${url}`);
1206
- // console.log(headers.toJSON())
1207
1148
  response = await axios({
1208
1149
  url,
1209
1150
  method,
@@ -1211,9 +1152,7 @@ class RestRequest {
1211
1152
  responseType: 'text',
1212
1153
  headers: headers.toJSON(),
1213
1154
  cancelToken: source.token,
1214
- // withCredentials: true, // this can be done manually
1215
1155
  });
1216
- // log.d(`after response of jobid: ${jobid}`);
1217
1156
  }
1218
1157
  if (this.subjectInuUse[jobid][isCanceled]) {
1219
1158
  return;
@@ -1240,8 +1179,6 @@ class RestRequest {
1240
1179
  if (this.subjectInuUse[jobid][isCanceled]) {
1241
1180
  return;
1242
1181
  }
1243
- // console.log('ERROR RESPONESE catchedError typeof ', typeof catchedError)
1244
- // console.log('ERROR RESPONESE catchedError', catchedError)
1245
1182
  if (typeof catchedError === 'object' && catchedError.response && catchedError.response.data) {
1246
1183
  const err = catchedError.response.data;
1247
1184
  const msg = catchedError.response.data.message || '';
@@ -1276,27 +1213,21 @@ class RestRequest {
1276
1213
  }
1277
1214
  getReplay(method, meta, onlyGetLastReplayForMethod) {
1278
1215
  let replay;
1279
- //#region prevent empty tree
1280
1216
  if (_.isUndefined(this.replaySubjects[meta.endpoint])) {
1281
- // log.i(`(${meta.endpoint}) `);
1282
1217
  this.replaySubjects[meta.endpoint] = {};
1283
1218
  }
1284
1219
  if (_.isUndefined(this.replaySubjects[meta.endpoint][meta.path])) {
1285
- // log.i(`(${meta.endpoint})(${meta.path}) `);
1286
1220
  this.replaySubjects[meta.endpoint][meta.path] = {};
1287
1221
  }
1288
1222
  if (_.isUndefined(this.replaySubjects[meta.endpoint][meta.path][method])) {
1289
- // log.i(`(${meta.endpoint})(${meta.path}) `);
1290
1223
  this.replaySubjects[meta.endpoint][meta.path][method] = {};
1291
1224
  }
1292
- //#endregion
1293
1225
  const objectIDToCreateOrLast = (Object.keys(this.replaySubjects[meta.endpoint][meta.path][method]).length) +
1294
1226
  (onlyGetLastReplayForMethod ? 0 : 1);
1295
1227
  if (onlyGetLastReplayForMethod && (objectIDToCreateOrLast === 0)) {
1296
1228
  return replay;
1297
1229
  }
1298
1230
  if (_.isUndefined(this.replaySubjects[meta.endpoint][meta.path][method][objectIDToCreateOrLast])) {
1299
- // log.i(`(${meta.endpoint})(${meta.path})(${method}) `);
1300
1231
  this.replaySubjects[meta.endpoint][meta.path][method][objectIDToCreateOrLast] = {
1301
1232
  subject: new Subject(),
1302
1233
  data: void 0,
@@ -1314,10 +1245,7 @@ class RestRequest {
1314
1245
  this.meta[jobid] = meta;
1315
1246
  this.subjectInuUse[jobid] = subject;
1316
1247
  this.subjectInuUse[jobid][customObs] = new Observable((observer) => {
1317
- // observer.remove(() => {
1318
- // });
1319
1248
  observer.add(() => {
1320
- // console.log(`cancel observable job${jobid}`)
1321
1249
  if (!this.subjectInuUse[jobid][isCanceled]) {
1322
1250
  this.subjectInuUse[jobid][isCanceled] = true;
1323
1251
  if (typeof this.subjectInuUse[jobid][cancelFn] === 'function') {
@@ -1325,7 +1253,6 @@ class RestRequest {
1325
1253
  }
1326
1254
  }
1327
1255
  else {
1328
- // console.log(`somehow second time cancel ${jobid}`)
1329
1256
  }
1330
1257
  });
1331
1258
  const sub = subject.subscribe({
@@ -1337,26 +1264,13 @@ class RestRequest {
1337
1264
  },
1338
1265
  });
1339
1266
  });
1340
- //#region DISPOSE @UNCOMMENT AFTER TESTS
1341
- // if (objectIDToCreateOrLast > 2) {
1342
- // const oldReq: Models.ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
1343
- // if (_.isUndefined(this.meta[oldReq.id])) {
1344
- // // cant delete this - for counter purpose
1345
- // this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)] = {};
1346
- // delete this.subjectInuUse[oldReq.id];
1347
- // delete this.meta[oldReq.id];
1348
- // }
1349
- // }
1350
- //#endregion
1351
1267
  }
1352
1268
  return replay;
1353
1269
  }
1354
- //#region http methods
1355
1270
  generalReq(method, url, body, headers, meta, isArray, mockHttp) {
1356
1271
  const replay = this.getReplay(method, meta, false);
1357
1272
  replay.data = { url, body, headers, isArray };
1358
1273
  ((pthis, purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp) => {
1359
- // log.d(`for ${purl} jobid ${pid}`);
1360
1274
  setTimeout(() => pthis.req(purl, pmethod, pheaders, pbody, pid, pisArray, pmockHttp));
1361
1275
  })(this, url, method, headers, body, replay.id, isArray, mockHttp);
1362
1276
  const resp = firstValueFrom(replay.subject[customObs]);
@@ -1455,11 +1369,11 @@ class RestRequest {
1455
1369
  }
1456
1370
  }
1457
1371
  RestRequest.jobId = 0;
1372
+ ;
1373
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/rest-request.ts
1458
1374
 
1459
1375
  const log = Log.create('resouce-service', Level.__NOTHING);
1460
1376
  class Resource {
1461
- //#endregion
1462
- //#region constructor
1463
1377
  constructor() {
1464
1378
  setTimeout(() => {
1465
1379
  const zone = this.getZone();
@@ -1475,7 +1389,6 @@ class Resource {
1475
1389
  static get listenSuccessOperations() {
1476
1390
  return this._listenSuccess.asObservable();
1477
1391
  }
1478
- //#region private mthods and fields
1479
1392
  getZone() {
1480
1393
  const isNode = (typeof window === 'undefined');
1481
1394
  if (isNode) {
@@ -1515,7 +1428,6 @@ class Resource {
1515
1428
  RestRequest.zone = zone;
1516
1429
  }
1517
1430
  checkNestedModels(model, allModels) {
1518
- // if (model.indexOf('/') !== -1) { //TODO make this better, becouse now I unecesary checking shit
1519
1431
  for (let p in allModels) {
1520
1432
  if (allModels.hasOwnProperty(p)) {
1521
1433
  let m = allModels[p];
@@ -1528,7 +1440,6 @@ class Resource {
1528
1440
  }
1529
1441
  }
1530
1442
  }
1531
- // }
1532
1443
  return model;
1533
1444
  }
1534
1445
  static getModel(endpoint, model) {
@@ -1540,8 +1451,6 @@ class Resource {
1540
1451
  const r = Resource.endpoints[endpoint].models[model];
1541
1452
  return Resource.endpoints[endpoint].models[model];
1542
1453
  }
1543
- //#endregion
1544
- //#region create
1545
1454
  static create(e, model, entityMapping, circular, customContentType) {
1546
1455
  const badRestRegEX = new RegExp('((\/:)[a-z]+)+', 'g');
1547
1456
  const matchArr = model.match(badRestRegEX) || [];
@@ -1559,7 +1468,6 @@ Instead use nested approach: /book/:bookid/author/:authorid
1559
1468
  ;
1560
1469
  Resource.map(e, e);
1561
1470
  Resource.instance.add(e, model ? model : '', entityMapping, circular, customContentType);
1562
- // if (model.charAt(model.length - 1) !== '/') model = `${model}/`;
1563
1471
  return {
1564
1472
  model: (params) => Resource.instance.api(e, interpolateParamsToUrl(params, model)),
1565
1473
  replay: (method) => {
@@ -1570,12 +1478,9 @@ Instead use nested approach: /book/:bookid/author/:authorid
1570
1478
  }
1571
1479
  };
1572
1480
  }
1573
- //#endregion
1574
- //#region reset
1575
1481
  static reset() {
1576
1482
  Resource.endpoints = {};
1577
1483
  }
1578
- //#region map
1579
1484
  static map(endpoint, url) {
1580
1485
  log.i('url', url);
1581
1486
  let regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
@@ -1599,7 +1504,6 @@ Instead use nested approach: /book/:bookid/author/:authorid
1599
1504
  log.i('enpoints', Resource.endpoints);
1600
1505
  return true;
1601
1506
  }
1602
- //#endregion
1603
1507
  static prepareModel(model) {
1604
1508
  if (model.charAt(model.length - 1) === '/')
1605
1509
  model = model.slice(0, model.length - 1);
@@ -1607,7 +1511,6 @@ Instead use nested approach: /book/:bookid/author/:authorid
1607
1511
  model = model.slice(1, model.length);
1608
1512
  return model;
1609
1513
  }
1610
- //#region add
1611
1514
  /**
1612
1515
  * And enipoint to application
1613
1516
  *
@@ -1640,8 +1543,6 @@ Instead use nested approach: /book/:bookid/author/:authorid
1640
1543
  }, customContentType); // TODO put custom content type in meta ?
1641
1544
  return;
1642
1545
  }
1643
- //#endregion
1644
- //#region api
1645
1546
  /**
1646
1547
  * Access api throught endpoint
1647
1548
  *
@@ -1650,10 +1551,6 @@ Instead use nested approach: /book/:bookid/author/:authorid
1650
1551
  * @returns {Rest<T, TA>}
1651
1552
  */
1652
1553
  api(endpoint, model) {
1653
- // log.i(`[api]
1654
- // creating for endpoint: "${endpoint}"
1655
- // model: "${model}"
1656
- // `)
1657
1554
  if (model.charAt(0) === '/')
1658
1555
  model = model.slice(1, model.length);
1659
1556
  let e = (endpoint).toString();
@@ -1664,26 +1561,17 @@ Instead use nested approach: /book/:bookid/author/:authorid
1664
1561
  let orgModel = model;
1665
1562
  model = this.checkNestedModels(model, allModels);
1666
1563
  if (Resource.endpoints[e].models[model] === void 0) {
1667
- // log.d('Resource.endpoints', Resource.endpoints);
1668
1564
  throw `Model '${model}' is undefined in endpoint: ${Resource.endpoints[e].url} `;
1669
1565
  }
1670
1566
  let res = Resource.endpoints[(endpoint).toString()].models[model];
1671
- // log.d(`
1672
- // orgModel: ${orgModel}
1673
- // model: ${model}
1674
- // `)
1675
1567
  if (orgModel !== model) {
1676
1568
  let baseUrl = Resource.endpoints[(endpoint).toString()].url;
1677
- // log.d('base', Resource.endpoints[<string>(endpoint).toString()])
1678
- // log.d('baseUrl', baseUrl)
1679
- // log.d('orgModel', orgModel)
1680
1569
  res.__rest_endpoint = `${baseUrl}/${orgModel}`;
1681
1570
  }
1682
1571
  else {
1683
1572
  res.__rest_endpoint = void 0;
1684
1573
  }
1685
1574
  ;
1686
- // log.i(`Resource.endpoints`, Resource.endpoints)
1687
1575
  return res;
1688
1576
  }
1689
1577
  }
@@ -1693,16 +1581,9 @@ Resource.enableWarnings = true;
1693
1581
  Resource.instance = new Resource();
1694
1582
  Resource.endpoints = {};
1695
1583
  Resource.request = new RestRequest();
1696
- //#endregion
1697
1584
  Resource.Cookies = Cookie.Instance;
1698
- // const res = Resource.create('')
1699
- // res.model()
1700
- // .mock({
1701
- // code: 500,
1702
- // data: {},
1703
- // isArray: true
1704
- // })
1705
- // .array.
1585
+ ;
1586
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/resource.service.ts
1706
1587
 
1707
1588
  /**
1708
1589
  *
@@ -1717,7 +1598,6 @@ Resource.Cookies = Cookie.Instance;
1717
1598
  * @template QP query parameter type
1718
1599
  */
1719
1600
  class ExtendedResource {
1720
- // add(endpoint: E, model: string, group?: string, name?: string, description?: string) { }
1721
1601
  constructor(endpoint, path_model) {
1722
1602
  this.endpoint = endpoint;
1723
1603
  this.path_model = path_model;
@@ -1818,6 +1698,11 @@ class SimpleResource {
1818
1698
  }
1819
1699
  }
1820
1700
  SimpleResource._isSetQueryParamsSerialization = false;
1701
+ ;
1702
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/other/simple-resource.ts
1703
+
1704
+ ;
1705
+ ({}); // @--end-of-file-for-module=ng2-rest tmp-src-bundle/lib/index.ts
1821
1706
 
1822
1707
  /**
1823
1708
  * Generated bundle index. Do not edit.