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