ng2-rest 21.0.15 → 21.0.17

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 (60) hide show
  1. package/browser/fesm2022/ng2-rest-browser.mjs +3 -5
  2. package/browser/fesm2022/ng2-rest-browser.mjs.map +1 -1
  3. package/browser/package.json +1 -1
  4. package/browser/types/ng2-rest-browser.d.ts +2 -8
  5. package/browser-prod/fesm2022/ng2-rest-browser.mjs +376 -393
  6. package/browser-prod/fesm2022/ng2-rest-browser.mjs.map +1 -1
  7. package/browser-prod/package.json +23 -0
  8. package/browser-prod/types/ng2-rest-browser.d.ts +194 -204
  9. package/browser-prod.split-namespaces.json +72 -0
  10. package/lib/build-info._auto-generated_.d.ts +1 -1
  11. package/lib/build-info._auto-generated_.js +1 -1
  12. package/lib/models.d.ts +2 -8
  13. package/lib/models.js +2 -4
  14. package/lib/models.js.map +1 -1
  15. package/lib/package.json +4 -0
  16. package/lib/rest-request.js.map +1 -1
  17. package/lib/rest.class.js +0 -1
  18. package/lib/rest.class.js.map +1 -1
  19. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  20. package/lib-prod/build-info._auto-generated_.js +1 -1
  21. package/lib-prod/helpers.d.ts +3 -3
  22. package/lib-prod/helpers.js +2 -2
  23. package/lib-prod/helpers.js.map +1 -1
  24. package/lib-prod/mapping.d.ts +10 -12
  25. package/lib-prod/mapping.js +238 -240
  26. package/lib-prod/mapping.js.map +1 -1
  27. package/lib-prod/models.d.ts +141 -149
  28. package/lib-prod/models.js +153 -160
  29. package/lib-prod/models.js.map +1 -1
  30. package/lib-prod/other/simple-resource.d.ts +11 -11
  31. package/lib-prod/package.json +4 -0
  32. package/lib-prod/params.d.ts +2 -2
  33. package/lib-prod/resource-service.d.ts +7 -7
  34. package/lib-prod/rest-request.d.ts +8 -8
  35. package/lib-prod/rest-request.js +3 -3
  36. package/lib-prod/rest-request.js.map +1 -1
  37. package/lib-prod/rest.class.d.ts +18 -18
  38. package/lib-prod/rest.class.js +0 -1
  39. package/lib-prod/rest.class.js.map +1 -1
  40. package/lib-prod.split-namespaces.json +72 -0
  41. package/package.json +1 -1
  42. package/websql/fesm2022/ng2-rest-websql.mjs +3 -5
  43. package/websql/fesm2022/ng2-rest-websql.mjs.map +1 -1
  44. package/websql/package.json +1 -1
  45. package/websql/types/ng2-rest-websql.d.ts +2 -8
  46. package/websql-prod/fesm2022/ng2-rest-websql.mjs +376 -393
  47. package/websql-prod/fesm2022/ng2-rest-websql.mjs.map +1 -1
  48. package/websql-prod/package.json +23 -0
  49. package/websql-prod/types/ng2-rest-websql.d.ts +194 -204
  50. package/websql-prod.split-namespaces.json +72 -0
  51. package/lib/request-cache.d.ts +0 -18
  52. package/lib/request-cache.js +0 -118
  53. package/lib/request-cache.js.map +0 -1
  54. package/migrations/index.d.ts +0 -1
  55. package/migrations/index.js +0 -19
  56. package/migrations/index.js.map +0 -1
  57. package/migrations/migrations_index._auto-generated_.d.ts +0 -0
  58. package/migrations/migrations_index._auto-generated_.js +0 -4
  59. package/migrations/migrations_index._auto-generated_.js.map +0 -1
  60. package/tmp-environment.json +0 -43
@@ -1,9 +1,9 @@
1
1
  import { from, firstValueFrom, Subject, Observable } from 'rxjs';
2
2
  import { diffChars } from 'diff';
3
- import { _, UtilsOs, CoreHelpers, CoreModels, Helpers as Helpers$1 } from 'tnp-core/websql-prod';
3
+ import { _, UtilsOs_isBrowser, CoreHelpers, CoreModels_TaonHttpErrorCustomProp, Helpers as Helpers$1, UtilsOs_isSSRMode } from 'tnp-core/websql-prod';
4
4
  import { Log, Level } from 'ng2-logger/websql-prod';
5
5
  import { walk } from 'lodash-walk-object/websql-prod';
6
- import { CLASS, SYMBOL, Models as Models$1 } from 'typescript-class-helpers/websql-prod';
6
+ import { CLASS, SYMBOL } from 'typescript-class-helpers/websql-prod';
7
7
  import { JSON10 } from 'json10/websql-prod';
8
8
  import axios from 'axios';
9
9
 
@@ -35,277 +35,272 @@ class Cookie {
35
35
  }
36
36
 
37
37
  /* */
38
- var Mapping;
39
- (function (Mapping) {
40
- function decode(json, autodetect = false) {
41
- // console.log('DECODE isBrowser', HelpersLog.isBrowser)
42
- if (_.isUndefined(json)) {
43
- return void 0;
44
- }
45
- let mapping = decodeFromDecorator(_.isArray(json) ? _.first(json) : json, !autodetect);
46
- if (autodetect) {
47
- mapping = _.merge(getMappingNaive(json), mapping);
48
- }
49
- return mapping;
38
+ //namespace Mapping
39
+ function Mapping_decode(json, autodetect = false) {
40
+ // console.log('DECODE isBrowser', HelpersLog.isBrowser)
41
+ if (_.isUndefined(json)) {
42
+ return void 0;
50
43
  }
51
- Mapping.decode = decode;
52
- function encode(json, mapping, circular = []) {
53
- if (_.isString(json) || _.isBoolean(json) || _.isNumber(json)) {
54
- return json;
55
- }
56
- if (mapping['']) {
57
- const decoratorMapping = getModelsMapping(CLASS.getBy(mapping['']));
58
- mapping = _.merge(mapping, decoratorMapping);
59
- }
60
- let res;
61
- if (_.isArray(circular) && circular.length > 0) {
62
- res = setMappingCirc(json, mapping, circular);
63
- }
64
- else {
65
- res = setMapping(json, mapping);
66
- }
67
- return res;
44
+ let mapping = decodeFromDecorator(_.isArray(json) ? _.first(json) : json, !autodetect);
45
+ if (autodetect) {
46
+ mapping = _.merge(getMappingNaive(json), mapping);
68
47
  }
69
- Mapping.encode = encode;
70
- function decodeFromDecorator(json, production = false) {
71
- const entityClass = CLASS.getFromObject(json);
72
- const mappings = getModelsMapping(entityClass);
73
- return mappings;
74
- }
75
- function getModelsMapping(entity) {
76
- if (!_.isFunction(entity) || entity === Object) {
77
- return {};
78
- }
79
- const className = CLASS.getName(entity);
80
- // console.log(`getMaping for: '${className}' `)
81
- let enityOWnMapping = _.isArray(entity[SYMBOL.MODELS_MAPPING])
82
- ? entity[SYMBOL.MODELS_MAPPING]
83
- : [{ '': className }];
84
- let res = {};
85
- let parents = enityOWnMapping
86
- .filter(m => !_.isUndefined(m['']) && m[''] !== className)
87
- .map(m => m['']);
88
- enityOWnMapping.reverse().forEach(m => {
89
- m = _.cloneDeep(m);
90
- // console.log(`'${className}' m:`, m)
91
- Object.keys(m).forEach(key => {
92
- const v = m[key];
93
- const isArr = _.isArray(v);
94
- const model = isArr ? _.first(v) : v;
95
- if (parents.includes(model)) {
96
- m[key] = isArr ? [className] : className;
97
- }
98
- });
99
- res = _.merge(res, m);
48
+ return mapping;
49
+ }
50
+ function Mapping_encode(json, mapping, circular = []) {
51
+ if (_.isString(json) || _.isBoolean(json) || _.isNumber(json)) {
52
+ return json;
53
+ }
54
+ if (mapping['']) {
55
+ const decoratorMapping = Mapping_getModelsMapping(CLASS.getBy(mapping['']));
56
+ mapping = _.merge(mapping, decoratorMapping);
57
+ }
58
+ let res;
59
+ if (_.isArray(circular) && circular.length > 0) {
60
+ res = setMappingCirc(json, mapping, circular);
61
+ }
62
+ else {
63
+ res = setMapping(json, mapping);
64
+ }
65
+ return res;
66
+ }
67
+ function decodeFromDecorator(json, production = false) {
68
+ const entityClass = CLASS.getFromObject(json);
69
+ const mappings = Mapping_getModelsMapping(entityClass);
70
+ return mappings;
71
+ }
72
+ function Mapping_getModelsMapping(entity) {
73
+ if (!_.isFunction(entity) || entity === Object) {
74
+ return {};
75
+ }
76
+ const className = CLASS.getName(entity);
77
+ // console.log(`getMaping for: '${className}' `)
78
+ let enityOWnMapping = _.isArray(entity[SYMBOL.MODELS_MAPPING])
79
+ ? entity[SYMBOL.MODELS_MAPPING]
80
+ : [{ '': className }];
81
+ let res = {};
82
+ let parents = enityOWnMapping
83
+ .filter(m => !_.isUndefined(m['']) && m[''] !== className)
84
+ .map(m => m['']);
85
+ enityOWnMapping.reverse().forEach(m => {
86
+ m = _.cloneDeep(m);
87
+ // console.log(`'${className}' m:`, m)
88
+ Object.keys(m).forEach(key => {
89
+ const v = m[key];
90
+ const isArr = _.isArray(v);
91
+ const model = isArr ? _.first(v) : v;
92
+ if (parents.includes(model)) {
93
+ m[key] = isArr ? [className] : className;
94
+ }
100
95
  });
101
- res[''] = className;
102
- // console.log(`mapping for ${className} : ${JSON.stringify(res)}`)
103
- return res;
96
+ res = _.merge(res, m);
97
+ });
98
+ res[''] = className;
99
+ // console.log(`mapping for ${className} : ${JSON.stringify(res)}`)
100
+ return res;
101
+ }
102
+ function add(o, path, mapping = {}) {
103
+ if (!o || Array.isArray(o) || typeof o !== 'object')
104
+ return;
105
+ const proptotypeObj = Object.getPrototypeOf(o);
106
+ if (!proptotypeObj) {
107
+ return;
104
108
  }
105
- Mapping.getModelsMapping = getModelsMapping;
106
- function add(o, path, mapping = {}) {
107
- if (!o || Array.isArray(o) || typeof o !== 'object')
108
- return;
109
- const proptotypeObj = Object.getPrototypeOf(o);
110
- if (!proptotypeObj) {
111
- return;
112
- }
113
- const objectClassName = CLASS.getName(proptotypeObj.constructor);
114
- const resolveClass = CLASS.getBy(objectClassName);
115
- if (!resolveClass) {
116
- if (objectClassName !== 'Object') {
117
- if (UtilsOs.isBrowser) {
118
- console.error(`Cannot resolve class "${objectClassName}" while mapping.`);
119
- }
109
+ const objectClassName = CLASS.getName(proptotypeObj.constructor);
110
+ const resolveClass = CLASS.getBy(objectClassName);
111
+ if (!resolveClass) {
112
+ if (objectClassName !== 'Object') {
113
+ if (UtilsOs_isBrowser) {
114
+ console.error(`Cannot resolve class "${objectClassName}" while mapping.`);
120
115
  }
121
- return;
122
116
  }
123
- if (!mapping[path])
124
- mapping[path] = CLASS.getName(resolveClass);
117
+ return;
125
118
  }
126
- /**
127
- * USE ONLY IN DEVELOPMENT
128
- * @param c
129
- * @param path
130
- * @param mapping
131
- * @param level
132
- */
133
- function getMappingNaive(c, path = '', mapping = {}, level = 0) {
134
- if (c === null || c === undefined) {
135
- return;
136
- }
137
- /* */
138
- /* */
139
- /* */
140
- /* */
141
- // console.log({c})
142
- if (Array.isArray(c)) {
143
- c.forEach(c => getMappingNaive(c, path, mapping, level));
144
- return mapping;
145
- }
146
- if (++level === 16)
147
- return;
148
- add(c, path, mapping);
149
- for (var p in c) {
150
- if (_.isFunction(c.hasOwnProperty) && c.hasOwnProperty(p)) {
151
- const v = c[p];
152
- if (Array.isArray(v) && v.length > 0) {
153
- // reducer as impovement
154
- v.forEach((elem, i) => {
155
- // const currentPaht = [`path[${i}]`, p].filter(c => c.trim() != '').join('.');
156
- const currentPaht = [path, p].filter(c => c.trim() != '').join('.');
157
- getMappingNaive(elem, currentPaht, mapping, level);
158
- });
159
- }
160
- else if (typeof v === 'object') {
119
+ if (!mapping[path])
120
+ mapping[path] = CLASS.getName(resolveClass);
121
+ }
122
+ /**
123
+ * USE ONLY IN DEVELOPMENT
124
+ * @param c
125
+ * @param path
126
+ * @param mapping
127
+ * @param level
128
+ */
129
+ function getMappingNaive(c, path = '', mapping = {}, level = 0) {
130
+ if (c === null || c === undefined) {
131
+ return;
132
+ }
133
+ /* */
134
+ /* */
135
+ /* */
136
+ /* */
137
+ // console.log({c})
138
+ if (Array.isArray(c)) {
139
+ c.forEach(c => getMappingNaive(c, path, mapping, level));
140
+ return mapping;
141
+ }
142
+ if (++level === 16)
143
+ return;
144
+ add(c, path, mapping);
145
+ for (var p in c) {
146
+ if (_.isFunction(c.hasOwnProperty) && c.hasOwnProperty(p)) {
147
+ const v = c[p];
148
+ if (Array.isArray(v) && v.length > 0) {
149
+ // reducer as impovement
150
+ v.forEach((elem, i) => {
151
+ // const currentPaht = [`path[${i}]`, p].filter(c => c.trim() != '').join('.');
161
152
  const currentPaht = [path, p].filter(c => c.trim() != '').join('.');
162
- add(v, currentPaht, mapping);
163
- getMappingNaive(v, currentPaht, mapping, level);
164
- }
153
+ getMappingNaive(elem, currentPaht, mapping, level);
154
+ });
155
+ }
156
+ else if (typeof v === 'object') {
157
+ const currentPaht = [path, p].filter(c => c.trim() != '').join('.');
158
+ add(v, currentPaht, mapping);
159
+ getMappingNaive(v, currentPaht, mapping, level);
165
160
  }
166
161
  }
167
- return mapping;
168
162
  }
169
- function getMappingPathFrom(pathLodhas) {
170
- if (!_.isString(pathLodhas)) {
171
- return void 0;
172
- }
173
- const regex = /\[([0-9a-zA-Z]|\'|\")*\]/g;
174
- pathLodhas = pathLodhas.replace(regex, '').replace('..', '.');
175
- if (pathLodhas.startsWith('.')) {
176
- pathLodhas = pathLodhas.slice(1);
177
- }
178
- return pathLodhas;
179
- }
180
- function setMappingCirc(json, mapping = {}, circular = []) {
181
- const mainClassFn = !_.isArray(json) && CLASS.getBy(mapping['']);
182
- // console.log(mapping)
183
- walk.Object(json, (v, lodashPath, changeValue) => {
184
- if (!_.isUndefined(v) && !_.isNull(v)) {
185
- const mappingPath = getMappingPathFrom(lodashPath);
186
- if (!_.isUndefined(mapping[mappingPath])) {
187
- const isArray = _.isArray(mapping[mappingPath]);
188
- if (!isArray) {
189
- const className = isArray
190
- ? _.first(mapping[mappingPath])
191
- : mapping[mappingPath];
192
- const classFN = CLASS.getBy(className);
193
- if (_.isFunction(classFN)) {
194
- // console.log(`mapping: '${mappingPath}', lp: '${lodashPath}' class: '${className}' , set `, v.location)
195
- changeValue(_.merge(new classFN(), v));
196
- }
163
+ return mapping;
164
+ }
165
+ function getMappingPathFrom(pathLodhas) {
166
+ if (!_.isString(pathLodhas)) {
167
+ return void 0;
168
+ }
169
+ const regex = /\[([0-9a-zA-Z]|\'|\")*\]/g;
170
+ pathLodhas = pathLodhas.replace(regex, '').replace('..', '.');
171
+ if (pathLodhas.startsWith('.')) {
172
+ pathLodhas = pathLodhas.slice(1);
173
+ }
174
+ return pathLodhas;
175
+ }
176
+ function setMappingCirc(json, mapping = {}, circular = []) {
177
+ const mainClassFn = !_.isArray(json) && CLASS.getBy(mapping['']);
178
+ // console.log(mapping)
179
+ walk.Object(json, (v, lodashPath, changeValue) => {
180
+ if (!_.isUndefined(v) && !_.isNull(v)) {
181
+ const mappingPath = getMappingPathFrom(lodashPath);
182
+ if (!_.isUndefined(mapping[mappingPath])) {
183
+ const isArray = _.isArray(mapping[mappingPath]);
184
+ if (!isArray) {
185
+ const className = isArray
186
+ ? _.first(mapping[mappingPath])
187
+ : mapping[mappingPath];
188
+ const classFN = CLASS.getBy(className);
189
+ if (_.isFunction(classFN)) {
190
+ // console.log(`mapping: '${mappingPath}', lp: '${lodashPath}' class: '${className}' , set `, v.location)
191
+ changeValue(_.merge(new classFN(), v));
197
192
  }
198
193
  }
199
194
  }
200
- });
201
- circular.forEach(c => {
202
- const ref = _.get(json, c.circuralTargetPath);
203
- _.set(json, c.pathToObj, ref);
204
- });
205
- if (_.isFunction(mainClassFn)) {
206
- json = _.merge(new mainClassFn(), json);
207
195
  }
208
- return json;
196
+ });
197
+ circular.forEach(c => {
198
+ const ref = _.get(json, c.circuralTargetPath);
199
+ _.set(json, c.pathToObj, ref);
200
+ });
201
+ if (_.isFunction(mainClassFn)) {
202
+ json = _.merge(new mainClassFn(), json);
209
203
  }
210
- function setMapping(json, mapping = {}) {
211
- // console.log('mapping', mapping)
212
- if (Array.isArray(json)) {
213
- return json.map(j => {
214
- return setMapping(j, mapping);
215
- });
216
- }
217
- const mainClassFn = CLASS.getBy(mapping['']);
218
- for (const key in json) {
219
- if (json.hasOwnProperty(key)) {
220
- // if (mainClassFn && mainClassFn.name === 'Project') {
221
- // // console.log(`OWn property: "${key}"`)
222
- // }
223
- if (_.isArray(json[key])) {
224
- json[key] = json[key].map(arrObj => {
225
- const objMapping = getModelsMapping(CLASS.getBy(mapping[key]));
226
- return setMapping(arrObj, objMapping);
227
- });
228
- }
229
- else if (_.isObject(json[key])) {
230
- const objMapping = getModelsMapping(CLASS.getBy(mapping[key]));
231
- json[key] = setMapping(json[key], objMapping);
232
- }
233
- }
234
- // else {
235
- // if (mainClassFn && mainClassFn.name === 'Project') {
236
- // // console.log(`Not own property: "${key}"`)
237
- // }
204
+ return json;
205
+ }
206
+ function setMapping(json, mapping = {}) {
207
+ // console.log('mapping', mapping)
208
+ if (Array.isArray(json)) {
209
+ return json.map(j => {
210
+ return setMapping(j, mapping);
211
+ });
212
+ }
213
+ const mainClassFn = CLASS.getBy(mapping['']);
214
+ for (const key in json) {
215
+ if (json.hasOwnProperty(key)) {
216
+ // if (mainClassFn && mainClassFn.name === 'Project') {
217
+ // // console.log(`OWn property: "${key}"`)
238
218
  // }
239
- }
240
- Object.keys(mapping)
241
- .filter(key => key !== '' && key.split('.').length >= 2)
242
- .forEach(lodasPath => {
243
- // console.log(`Loadsh path: ${lodasPath}`)
244
- const objMapping = getModelsMapping(CLASS.getBy(mapping[lodasPath]));
245
- const input = _.get(json, lodasPath);
246
- if (!_.isUndefined(input)) {
247
- const res = setMapping(input, objMapping);
248
- _.set(json, lodasPath, res);
219
+ if (_.isArray(json[key])) {
220
+ json[key] = json[key].map(arrObj => {
221
+ const objMapping = Mapping_getModelsMapping(CLASS.getBy(mapping[key]));
222
+ return setMapping(arrObj, objMapping);
223
+ });
224
+ }
225
+ else if (_.isObject(json[key])) {
226
+ const objMapping = Mapping_getModelsMapping(CLASS.getBy(mapping[key]));
227
+ json[key] = setMapping(json[key], objMapping);
249
228
  }
250
- });
251
- if (!mainClassFn) {
252
- return json;
253
229
  }
254
- return _.merge(new mainClassFn(), json);
230
+ // else {
231
+ // if (mainClassFn && mainClassFn.name === 'Project') {
232
+ // // console.log(`Not own property: "${key}"`)
233
+ // }
234
+ // }
255
235
  }
256
- function DefaultModelWithMapping(defaultModelValues, mapping) {
257
- return function (target) {
258
- if (!_.isArray(target[SYMBOL.MODELS_MAPPING])) {
259
- target[SYMBOL.MODELS_MAPPING] = [];
260
- }
261
- target[SYMBOL.MODELS_MAPPING].push({
262
- '': CLASS.getName(target),
263
- });
264
- if (_.isObject(mapping)) {
265
- target[SYMBOL.MODELS_MAPPING] = target[SYMBOL.MODELS_MAPPING].concat(mapping);
266
- Object.keys(mapping).forEach(key => {
267
- const v = mapping;
268
- if (_.isUndefined(v) || _.isFunction(v)) {
269
- throw `
236
+ Object.keys(mapping)
237
+ .filter(key => key !== '' && key.split('.').length >= 2)
238
+ .forEach(lodasPath => {
239
+ // console.log(`Loadsh path: ${lodasPath}`)
240
+ const objMapping = Mapping_getModelsMapping(CLASS.getBy(mapping[lodasPath]));
241
+ const input = _.get(json, lodasPath);
242
+ if (!_.isUndefined(input)) {
243
+ const res = setMapping(input, objMapping);
244
+ _.set(json, lodasPath, res);
245
+ }
246
+ });
247
+ if (!mainClassFn) {
248
+ return json;
249
+ }
250
+ return _.merge(new mainClassFn(), json);
251
+ }
252
+ function Mapping_DefaultModelWithMapping(defaultModelValues, mapping) {
253
+ return function (target) {
254
+ if (!_.isArray(target[SYMBOL.MODELS_MAPPING])) {
255
+ target[SYMBOL.MODELS_MAPPING] = [];
256
+ }
257
+ target[SYMBOL.MODELS_MAPPING].push({
258
+ '': CLASS.getName(target),
259
+ });
260
+ if (_.isObject(mapping)) {
261
+ target[SYMBOL.MODELS_MAPPING] = target[SYMBOL.MODELS_MAPPING].concat(mapping);
262
+ Object.keys(mapping).forEach(key => {
263
+ const v = mapping;
264
+ if (_.isUndefined(v) || _.isFunction(v)) {
265
+ throw `
270
266
 
271
267
 
272
268
  Class: '${target.name}'
273
269
  [ng2rest] Bad mapping value for path: ${key} , please use type: <string> or [<string>]
274
270
  `;
275
- }
276
- });
277
- }
278
- if (_.isObject(defaultModelValues)) {
279
- const toMerge = {};
280
- const describedTarget = CLASS.describeProperites(target).filter(prop => /^([a-zA-Z0-9]|\_|\#)+$/.test(prop));
281
- // console.log(`describedTarget: ${describedTarget} for ${target.name}`)
282
- describedTarget.forEach(propDefInConstr => {
283
- if (defaultModelValues[propDefInConstr]) {
284
- console.warn(`
271
+ }
272
+ });
273
+ }
274
+ if (_.isObject(defaultModelValues)) {
275
+ const toMerge = {};
276
+ const describedTarget = CLASS.describeProperites(target).filter(prop => /^([a-zA-Z0-9]|\_|\#)+$/.test(prop));
277
+ // console.log(`describedTarget: ${describedTarget} for ${target.name}`)
278
+ describedTarget.forEach(propDefInConstr => {
279
+ if (defaultModelValues[propDefInConstr]) {
280
+ console.warn(`
285
281
 
286
282
  CONFLICT: default value for property: "${propDefInConstr}"
287
283
  in class "${target.name}" already defined as typescript
288
284
  default class proprty value.
289
285
 
290
286
  `);
291
- }
292
- else {
293
- toMerge[propDefInConstr] = null; // TODO from toString I can't know that
294
- }
295
- });
296
- // console.log(`merge "${JSON.stringify(target.prototype)}" with "${JSON.stringify(defaultModelValues)}"`)
297
- target[SYMBOL.DEFAULT_MODEL] = _.merge(toMerge, defaultModelValues);
298
- const propsToOmmit = Object.keys(target[SYMBOL.DEFAULT_MODEL]).filter(key => {
299
- const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
300
- return !!descriptor;
301
- });
302
- _.merge(target.prototype, _.omit(target[SYMBOL.DEFAULT_MODEL], propsToOmmit));
303
- // console.log(`DEFAULT VALUE MERGE for ${target.name}`)
304
- }
305
- };
306
- }
307
- Mapping.DefaultModelWithMapping = DefaultModelWithMapping;
308
- })(Mapping || (Mapping = {}));
287
+ }
288
+ else {
289
+ toMerge[propDefInConstr] = null; // TODO from toString I can't know that
290
+ }
291
+ });
292
+ // console.log(`merge "${JSON.stringify(target.prototype)}" with "${JSON.stringify(defaultModelValues)}"`)
293
+ target[SYMBOL.DEFAULT_MODEL] = _.merge(toMerge, defaultModelValues);
294
+ const propsToOmmit = Object.keys(target[SYMBOL.DEFAULT_MODEL]).filter(key => {
295
+ const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
296
+ return !!descriptor;
297
+ });
298
+ _.merge(target.prototype, _.omit(target[SYMBOL.DEFAULT_MODEL], propsToOmmit));
299
+ // console.log(`DEFAULT VALUE MERGE for ${target.name}`)
300
+ }
301
+ };
302
+ }
303
+ //end of namespace Mapping
309
304
 
310
305
  // @ts-ignore
311
306
  class Helpers extends CoreHelpers {
@@ -313,10 +308,10 @@ class Helpers extends CoreHelpers {
313
308
  static get Mapping() {
314
309
  return {
315
310
  encode(json, mapping) {
316
- return Mapping.encode(json, mapping);
311
+ return Mapping_encode(json, mapping);
317
312
  },
318
313
  decode(json, autodetect = false) {
319
- return Mapping.decode(json, autodetect);
314
+ return Mapping_decode(json, autodetect);
320
315
  }
321
316
  };
322
317
  }
@@ -649,172 +644,161 @@ class RestResponseWrapper extends RestCommonHttpResponseWrapper {
649
644
  }
650
645
  class RestErrorResponseWrapper extends RestCommonHttpResponseWrapper {
651
646
  }
652
- // const log = Log.create('rest namespace', Level.__NOTHING)
653
- var Models;
654
- (function (Models) {
655
- Models.MethodConfig = Models$1.MethodConfig;
656
- Models.ClassConfig = Models$1.ClassConfig;
657
- Models.ParamConfig = Models$1.ParamConfig;
658
- [];
659
- class BaseBody {
660
- toJSON(data, opt) {
661
- opt = opt || { isJSONArray: false };
662
- let r = opt.isJSONArray ? [] : {};
663
- if (typeof data === 'string') {
664
- try {
665
- let parsed = JSON.parse(data);
666
- if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
667
- parsed = JSON.parse(parsed);
668
- }
669
- if (opt.parsingError && parsed[CoreModels.TaonHttpErrorCustomProp]) {
670
- return _.merge(new RestErrorResponseWrapper(), parsed);
671
- }
672
- return parsed;
647
+ [];
648
+ class Models_BaseBody {
649
+ toJSON(data, opt) {
650
+ opt = opt || { isJSONArray: false };
651
+ let r = opt.isJSONArray ? [] : {};
652
+ if (typeof data === 'string') {
653
+ try {
654
+ let parsed = JSON.parse(data);
655
+ if (typeof parsed === 'string' && parsed.trim().startsWith('{')) {
656
+ parsed = JSON.parse(parsed);
673
657
  }
674
- catch (e) { }
675
- }
676
- else if (typeof data === 'object') {
677
- return data;
658
+ if (opt.parsingError && parsed[CoreModels_TaonHttpErrorCustomProp]) {
659
+ return _.merge(new RestErrorResponseWrapper(), parsed);
660
+ }
661
+ return parsed;
678
662
  }
679
- return r;
663
+ catch (e) { }
680
664
  }
681
- }
682
- Models.BaseBody = BaseBody;
683
- class HttpBody extends BaseBody {
684
- constructor(responseText, isArray = false, entity, circular) {
685
- super();
686
- this.responseText = responseText;
687
- this.isArray = isArray;
688
- this.entity = entity;
689
- this.circular = circular;
690
- }
691
- get blob() {
692
- return this.responseText;
665
+ else if (typeof data === 'object') {
666
+ return data;
693
667
  }
694
- get booleanValue() {
695
- if (!Helpers$1.isBlob(this.responseText)) {
696
- return ['ok', 'true'].includes(this.responseText?.trim());
697
- }
698
- }
699
- get numericValue() {
700
- if (!Helpers$1.isBlob(this.responseText)) {
701
- return Number(this.responseText?.trim());
702
- }
668
+ return r;
669
+ }
670
+ }
671
+ class Models_HttpBody extends Models_BaseBody {
672
+ constructor(responseText, isArray = false, entity, circular) {
673
+ super();
674
+ this.responseText = responseText;
675
+ this.isArray = isArray;
676
+ this.entity = entity;
677
+ this.circular = circular;
678
+ }
679
+ get blob() {
680
+ return this.responseText;
681
+ }
682
+ get booleanValue() {
683
+ if (!Helpers$1.isBlob(this.responseText)) {
684
+ return ['ok', 'true'].includes(this.responseText?.trim());
703
685
  }
704
- get rawJson() {
705
- if (!Helpers$1.isBlob(this.responseText)) {
706
- let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
707
- if (this.circular && Array.isArray(this.circular)) {
708
- res = JSON10.parse(JSON.stringify(res), this.circular);
709
- }
710
- return res;
711
- }
686
+ }
687
+ get numericValue() {
688
+ if (!Helpers$1.isBlob(this.responseText)) {
689
+ return Number(this.responseText?.trim());
712
690
  }
713
- get json() {
714
- const isBlob = Helpers$1.isBlob(this.responseText);
715
- if (isBlob) {
716
- return void 0;
717
- }
718
- if (this.entity && typeof this.entity === 'function') {
719
- return this.entity(); // @LAST
720
- }
721
- if (this.entity && typeof this.entity === 'object') {
722
- const json = this.toJSON(this.responseText, {
723
- isJSONArray: this.isArray,
724
- });
725
- return Mapping.encode(json, this.entity, this.circular);
726
- }
691
+ }
692
+ get rawJson() {
693
+ if (!Helpers$1.isBlob(this.responseText)) {
727
694
  let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
728
695
  if (this.circular && Array.isArray(this.circular)) {
729
696
  res = JSON10.parse(JSON.stringify(res), this.circular);
730
697
  }
731
698
  return res;
732
699
  }
733
- /**
734
- * undefined when blob
735
- */
736
- get text() {
737
- if (!Helpers$1.isBlob(this.responseText)) {
738
- return this.responseText
739
- .replace(/^\"/, '')
740
- .replace(/\"$/, '');
741
- }
742
- }
743
700
  }
744
- Models.HttpBody = HttpBody;
745
- class ErrorBody extends BaseBody {
746
- constructor(data) {
747
- super();
748
- this.data = data;
701
+ get json() {
702
+ const isBlob = Helpers$1.isBlob(this.responseText);
703
+ if (isBlob) {
704
+ return void 0;
705
+ }
706
+ if (this.entity && typeof this.entity === 'function') {
707
+ return this.entity(); // @LAST
749
708
  }
750
- get json() {
751
- return this.toJSON(this.data, { parsingError: true });
709
+ if (this.entity && typeof this.entity === 'object') {
710
+ const json = this.toJSON(this.responseText, {
711
+ isJSONArray: this.isArray,
712
+ });
713
+ return Mapping_encode(json, this.entity, this.circular);
752
714
  }
753
- get text() {
754
- return this.data;
715
+ let res = this.toJSON(this.responseText, { isJSONArray: this.isArray });
716
+ if (this.circular && Array.isArray(this.circular)) {
717
+ res = JSON10.parse(JSON.stringify(res), this.circular);
755
718
  }
719
+ return res;
756
720
  }
757
- Models.ErrorBody = ErrorBody;
758
- class BaseResponse {
759
- static { this.cookies = Cookie.Instance; }
760
- get cookies() {
761
- return BaseResponse.cookies;
762
- }
763
- constructor(responseText, headers, statusCode, isArray = false) {
764
- this.responseText = responseText;
765
- this.headers = headers;
766
- this.statusCode = statusCode;
767
- this.isArray = isArray;
721
+ /**
722
+ * undefined when blob
723
+ */
724
+ get text() {
725
+ if (!Helpers$1.isBlob(this.responseText)) {
726
+ return this.responseText
727
+ .replace(/^\"/, '')
728
+ .replace(/\"$/, '');
768
729
  }
769
730
  }
770
- Models.BaseResponse = BaseResponse;
771
- class HttpResponse extends BaseResponse {
772
- // public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
773
- // public get totalElements(): number {
774
- // return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
775
- // }
776
- constructor(sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray = false) {
777
- // console.log({
778
- // sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray
779
- // })
780
- super(responseText, headers, statusCode, isArray);
781
- this.sourceRequest = sourceRequest;
782
- this.responseText = responseText;
783
- this.headers = headers;
784
- this.statusCode = statusCode;
785
- this.entity = entity;
786
- this.circular = circular;
787
- this.jobid = jobid;
788
- this.isArray = isArray;
789
- this.init();
790
- }
791
- init() {
792
- if (typeof this.entity === 'string') {
793
- // const headerWithMapping = headers.get(entity);
794
- let entityJSON = this.headers?.getAll(this.entity);
795
- if (!!entityJSON) {
796
- this.entity = JSON.parse(entityJSON.join());
797
- }
731
+ }
732
+ class Models_ErrorBody extends Models_BaseBody {
733
+ constructor(data) {
734
+ super();
735
+ this.data = data;
736
+ }
737
+ get json() {
738
+ return this.toJSON(this.data, { parsingError: true });
739
+ }
740
+ get text() {
741
+ return this.data;
742
+ }
743
+ }
744
+ class Models_BaseResponse {
745
+ static { this.cookies = Cookie.Instance; }
746
+ get cookies() {
747
+ return Models_BaseResponse.cookies;
748
+ }
749
+ constructor(responseText, headers, statusCode, isArray = false) {
750
+ this.responseText = responseText;
751
+ this.headers = headers;
752
+ this.statusCode = statusCode;
753
+ this.isArray = isArray;
754
+ }
755
+ }
756
+ class Models_HttpResponse extends Models_BaseResponse {
757
+ // public readonly TOTAL_COUNT_HEADER = 'X-Total-Count'.toLowerCase();
758
+ // public get totalElements(): number {
759
+ // return Number(this.headers.get(this.TOTAL_COUNT_HEADER));
760
+ // }
761
+ constructor(sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray = false) {
762
+ // console.log({
763
+ // sourceRequest, responseText, headers, statusCode, entity, circular, jobid, isArray
764
+ // })
765
+ super(responseText, headers, statusCode, isArray);
766
+ this.sourceRequest = sourceRequest;
767
+ this.responseText = responseText;
768
+ this.headers = headers;
769
+ this.statusCode = statusCode;
770
+ this.entity = entity;
771
+ this.circular = circular;
772
+ this.jobid = jobid;
773
+ this.isArray = isArray;
774
+ this.init();
775
+ }
776
+ init() {
777
+ if (typeof this.entity === 'string') {
778
+ // const headerWithMapping = headers.get(entity);
779
+ let entityJSON = this.headers?.getAll(this.entity);
780
+ if (!!entityJSON) {
781
+ this.entity = JSON.parse(entityJSON.join());
798
782
  }
799
- if (typeof this.circular === 'string') {
800
- // const headerWithMapping = headers.get(circular);
801
- let circuralJSON = this.headers?.getAll(this.circular);
802
- if (!!circuralJSON) {
803
- this.circular = JSON.parse(circuralJSON.join());
804
- }
783
+ }
784
+ if (typeof this.circular === 'string') {
785
+ // const headerWithMapping = headers.get(circular);
786
+ let circuralJSON = this.headers?.getAll(this.circular);
787
+ if (!!circuralJSON) {
788
+ this.circular = JSON.parse(circuralJSON.join());
805
789
  }
806
- this.body = new HttpBody(this.responseText, this.isArray, this.entity, this.circular);
807
790
  }
791
+ this.body = new Models_HttpBody(this.responseText, this.isArray, this.entity, this.circular);
808
792
  }
809
- Models.HttpResponse = HttpResponse;
810
- /* */
811
- /* */
812
- /* */
813
- /* */
814
- /* */
815
- /* */
816
- })(Models || (Models = {}));
817
- class HttpResponseError extends Models.BaseResponse {
793
+ }
794
+ /* */
795
+ /* */
796
+ /* */
797
+ /* */
798
+ /* */
799
+ /* */
800
+ //end of namespace Models
801
+ class HttpResponseError extends Models_BaseResponse {
818
802
  // public tryRecconect() {
819
803
  // }
820
804
  constructor(message, responseText, headers, statusCode, jobid, sourceRequest) {
@@ -822,7 +806,7 @@ class HttpResponseError extends Models.BaseResponse {
822
806
  this.message = message;
823
807
  this.jobid = jobid;
824
808
  this.sourceRequest = sourceRequest;
825
- this.body = new Models.ErrorBody(responseText);
809
+ this.body = new Models_ErrorBody(responseText);
826
810
  }
827
811
  }
828
812
 
@@ -1014,7 +998,7 @@ class RestRequest {
1014
998
  const entity = this.meta[jobid].entity;
1015
999
  const circular = this.meta[jobid].circular;
1016
1000
  const success = Resource['_listenSuccess'];
1017
- const reqResp = new Models.HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
1001
+ const reqResp = new Models_HttpResponse(sourceRequest, res.data, res.headers, res.code, entity, circular, jobid, isArray);
1018
1002
  success.next(reqResp);
1019
1003
  this.subjectInuUse[jobid].next(reqResp);
1020
1004
  this.meta[jobid] = void 0;
@@ -1241,7 +1225,7 @@ class RestRequest {
1241
1225
  });
1242
1226
  //#region DISPOSE @UNCOMMENT AFTER TESTS
1243
1227
  // if (objectIDToCreateOrLast > 2) {
1244
- // const oldReq: Models.ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
1228
+ // const oldReq: Models_ReplayData = this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)];
1245
1229
  // if (_.isUndefined(this.meta[oldReq.id])) {
1246
1230
  // // cant delete this - for counter purpose
1247
1231
  // this.replaySubjects[meta.endpoint][meta.path][method][(objectIDToCreateOrLast - 2)] = {};
@@ -1285,7 +1269,7 @@ class RestRequest {
1285
1269
  }
1286
1270
  jsonp(url, body, headers, meta, isArray, mockHttp, axiosOptions) {
1287
1271
  const method = 'jsonp';
1288
- if (UtilsOs.isSSRMode) {
1272
+ if (UtilsOs_isSSRMode) {
1289
1273
  const emptyStuff = Promise.resolve();
1290
1274
  emptyStuff.observable = new Observable();
1291
1275
  console.warn(`Cannot perform jsonp request in SSR mode`);
@@ -1340,7 +1324,6 @@ const CONTENT_TYPE = {
1340
1324
 
1341
1325
  //#region import
1342
1326
  // import { Log, Level } from 'ng2-logger/src';
1343
- // const log = Log.create('rest.class', Level.__NOTHING)
1344
1327
  //#endregion
1345
1328
  class Rest {
1346
1329
  mock(mock) {
@@ -1800,5 +1783,5 @@ class SimpleResource {
1800
1783
  * Generated bundle index. Do not edit.
1801
1784
  */
1802
1785
 
1803
- export { AxiosBackendHandler, CONTENT_TYPE, Helpers, HttpResponseError, Mapping, Models, Resource, Rest, RestErrorResponseWrapper, RestHeaders, RestResponseWrapper, SimpleResource, buildInterceptorChain, interpolateParamsToUrl };
1786
+ export { AxiosBackendHandler, CONTENT_TYPE, Helpers, HttpResponseError, Mapping_DefaultModelWithMapping, Mapping_decode, Mapping_encode, Mapping_getModelsMapping, Models_BaseBody, Models_BaseResponse, Models_ErrorBody, Models_HttpBody, Models_HttpResponse, Resource, Rest, RestErrorResponseWrapper, RestHeaders, RestResponseWrapper, SimpleResource, buildInterceptorChain, interpolateParamsToUrl };
1804
1787
  //# sourceMappingURL=ng2-rest-websql.mjs.map