typescript-class-helpers 21.0.16 → 21.0.18

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 (45) hide show
  1. package/browser/package.json +1 -1
  2. package/browser-prod/fesm2022/typescript-class-helpers-browser.mjs +196 -210
  3. package/browser-prod/fesm2022/typescript-class-helpers-browser.mjs.map +1 -1
  4. package/browser-prod/package.json +23 -0
  5. package/browser-prod/types/typescript-class-helpers-browser.d.ts +83 -93
  6. package/browser-prod.split-namespaces.json +36 -0
  7. package/lib/build-info._auto-generated_.d.ts +1 -1
  8. package/lib/build-info._auto-generated_.js +1 -1
  9. package/lib/package.json +4 -0
  10. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  11. package/lib-prod/build-info._auto-generated_.js +1 -1
  12. package/lib-prod/classname.d.ts +14 -16
  13. package/lib-prod/classname.js +163 -165
  14. package/lib-prod/classname.js.map +1 -1
  15. package/lib-prod/index.d.ts +6 -6
  16. package/lib-prod/index.js +15 -13
  17. package/lib-prod/index.js.map +1 -1
  18. package/lib-prod/models.d.ts +72 -74
  19. package/lib-prod/models.js +52 -54
  20. package/lib-prod/models.js.map +1 -1
  21. package/lib-prod/package.json +4 -0
  22. package/lib-prod/registerd-db.d.ts +2 -2
  23. package/lib-prod/registerd-db.js.map +1 -1
  24. package/lib-prod/set-class-name.d.ts +2 -2
  25. package/lib-prod/set-class-name.js +3 -3
  26. package/lib-prod/set-class-name.js.map +1 -1
  27. package/lib-prod/symbols.js +1 -1
  28. package/lib-prod/symbols.js.map +1 -1
  29. package/lib-prod.split-namespaces.json +36 -0
  30. package/package.json +1 -1
  31. package/websql/package.json +1 -1
  32. package/websql-prod/fesm2022/typescript-class-helpers-websql.mjs +195 -209
  33. package/websql-prod/fesm2022/typescript-class-helpers-websql.mjs.map +1 -1
  34. package/websql-prod/package.json +23 -0
  35. package/websql-prod/types/typescript-class-helpers-websql.d.ts +84 -94
  36. package/websql-prod.split-namespaces.json +36 -0
  37. package/migrations/index.d.ts +0 -1
  38. package/migrations/index.js +0 -19
  39. package/migrations/index.js.map +0 -1
  40. package/migrations/migrations_index._auto-generated_.d.ts +0 -0
  41. package/migrations/migrations_index._auto-generated_.js +0 -4
  42. package/migrations/migrations_index._auto-generated_.js.map +0 -1
  43. package/package.json_devDependencies.json +0 -223
  44. package/package.json_tnp.json5 +0 -56
  45. package/tmp-environment.json +0 -43
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-class-helpers/browser",
3
- "version": "21.0.16",
3
+ "version": "21.0.18",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -1,45 +1,40 @@
1
- import { CoreModels, _, Helpers } from 'tnp-core/browser-prod';
1
+ import { CoreModels__NS__ClassNameStaticProperty, _, Helpers } from 'tnp-core/browser-prod';
2
2
 
3
- var Models;
4
- (function (Models) {
5
- /**
6
- * @deprecated
7
- */
8
- class ParamConfig {
9
- }
10
- Models.ParamConfig = ParamConfig;
11
- /**
12
- * @deprecated
13
- */
14
- class MethodConfig {
15
- constructor() {
16
- /* */
17
- /* */
18
- this.parameters = {};
19
- }
3
+ /**
4
+ * @deprecated
5
+ */
6
+ class Models__NS__ParamConfig {
7
+ }
8
+ /**
9
+ * @deprecated
10
+ */
11
+ class Models__NS__MethodConfig {
12
+ constructor() {
13
+ /* */
14
+ /* */
15
+ this.parameters = {};
20
16
  }
21
- Models.MethodConfig = MethodConfig;
22
- /**
23
- * @deprecated
24
- */
25
- class ClassConfig {
26
- constructor() {
27
- // @ts-ignore
28
- this.singleton = void 0;
29
- this.injections = [];
30
- this.vChildren = [];
31
- this.methods = {};
32
- }
17
+ }
18
+ /**
19
+ * @deprecated
20
+ */
21
+ class Models__NS__ClassConfig {
22
+ constructor() {
23
+ // @ts-ignore
24
+ this.singleton = void 0;
25
+ this.injections = [];
26
+ this.vChildren = [];
27
+ this.methods = {};
33
28
  }
34
- Models.ClassConfig = ClassConfig;
35
- })(Models || (Models = {}));
29
+ }
30
+ //end of namespace Models
36
31
 
37
32
  const SYMBOL = {
38
33
  MODELS_MAPPING: Symbol(),
39
34
  DEFAULT_MODEL: Symbol(),
40
35
  STORAGE: 'classesstorage',
41
36
  CLASSES: 'classes',
42
- ClassNameStaticProperty: CoreModels.ClassNameStaticProperty,
37
+ ClassNameStaticProperty: CoreModels__NS__ClassNameStaticProperty,
43
38
  };
44
39
 
45
40
  function defaultValues() {
@@ -82,7 +77,7 @@ function setClassName(target, className, options) {
82
77
  uniqueKey = 'id';
83
78
  }
84
79
  if (target) {
85
- const config = _.first(CLASSNAME.getClassConfig(target));
80
+ const config = _.first(CLASSNAME__NS__getClassConfig(target));
86
81
  config.className = className;
87
82
  config.uniqueKey = uniqueKey;
88
83
  config.classNameInBrowser = classNameInBrowser;
@@ -108,8 +103,8 @@ function setClassName(target, className, options) {
108
103
  if (!_.isFunction(parent) || parent.name === 'Object' || parent.name === '') {
109
104
  return className;
110
105
  }
111
- const classNameNew = CLASSNAME.getClassName(parent);
112
- return CLASSNAME.getClassFamilyByClassName(classNameNew);
106
+ const classNameNew = CLASSNAME__NS__getClassName(parent);
107
+ return CLASSNAME__NS__getClassFamilyByClassName(classNameNew);
113
108
  }
114
109
  });
115
110
  }
@@ -177,184 +172,175 @@ function getClasses() {
177
172
  const s = getStorage();
178
173
  return s[SYMBOL.CLASSES];
179
174
  }
180
- var CLASSNAME;
181
- (function (CLASSNAME_1) {
182
- function getClassConfig(target, configs = [], callerTarget) {
183
- if (!_.isFunction(target)) {
184
- throw `[typescript-class-helper][getClassConfig] Cannot get class config from: ${target}`;
185
- }
186
- let config;
187
- const parentClass = Object.getPrototypeOf(target);
188
- const isValidParent = _.isFunction(parentClass) && parentClass.name !== '';
189
- if (registerd.classes.includes(target)) {
190
- config =
191
- registerd.configs[registerd.classes.findIndex(c => c === target)];
192
- }
193
- else {
194
- config = new Models.ClassConfig();
195
- config.classReference = target;
196
- registerd.classes.push(target);
197
- }
198
- registerd.configs[registerd.classes.findIndex(c => c === target)] = config;
199
- if (callerTarget) {
200
- const callerTargetConfig = registerd.configs[registerd.classes.findIndex(c => c === callerTarget)];
201
- if (!config.vChildren.includes(callerTargetConfig)) {
202
- config.vChildren.push(callerTargetConfig);
203
- }
204
- callerTargetConfig.vParent = config;
205
- }
206
- configs.push(config);
207
- return isValidParent
208
- ? getClassConfig(parentClass, configs, target)
209
- : configs;
175
+ //namespace CLASSNAME
176
+ function CLASSNAME__NS__getClassConfig(target, configs = [], callerTarget) {
177
+ if (!_.isFunction(target)) {
178
+ throw `[typescript-class-helper][getClassConfig] Cannot get class config from: ${target}`;
210
179
  }
211
- CLASSNAME_1.getClassConfig = getClassConfig;
212
- /**
213
- * PLEASE PROVIDE NAME AS TYPED STRING, NOT VARIABLE
214
- * Decorator requred for production mode
215
- * @param name Name of class
216
- */
217
- function CLASSNAME(className, options) {
218
- return function (target) {
219
- // console.log(`CLASSNAME Inited ${className}`)
220
- return setClassName(target, className, options);
221
- };
180
+ let config;
181
+ const parentClass = Object.getPrototypeOf(target);
182
+ const isValidParent = _.isFunction(parentClass) && parentClass.name !== '';
183
+ if (registerd.classes.includes(target)) {
184
+ config =
185
+ registerd.configs[registerd.classes.findIndex(c => c === target)];
222
186
  }
223
- CLASSNAME_1.CLASSNAME = CLASSNAME;
224
- function getClassName(target, production = false) {
225
- if (_.isNil(target)) {
226
- // console.log(target);
227
- // Helpers.warn(`[typescript-class-helpers][getClassName] target is nil`)
228
- return void 0;
229
- }
230
- if (_.isString(target)) {
231
- // console.log(target);
232
- Helpers.log(`[typescript-class-helpers][getClassName] target is string: '${target}', produciton: ${production}`);
233
- return target;
234
- }
235
- if (target === Date) {
236
- return 'Date';
237
- }
238
- if (target === FormData) {
239
- return 'FormData';
240
- }
241
- if (!_.isFunction(target)) {
242
- // console.log(target);
243
- Helpers.log(`[typescript-class-helpers][getClassName] target is not a class`);
244
- return void 0;
245
- }
246
- if (target[SYMBOL.ClassNameStaticProperty]) {
247
- return target[SYMBOL.ClassNameStaticProperty];
248
- }
249
- const configs = getClassConfig(target);
250
- const config = _.first(configs);
251
- const classNameInBrowser = config?.classNameInBrowser;
252
- if (Helpers.isBrowser && _.isString(classNameInBrowser)) {
253
- return classNameInBrowser;
254
- }
255
- const className = config?.className;
256
- if (typeof className === 'string') {
257
- return className;
258
- }
259
- if (production) {
260
- console.log('class without @CLASS.NAME deocrator', target);
261
- throw new Error(ERROR_MSG_CLASS_WITHOUT_DECORATOR);
262
- }
263
- else {
264
- // Helpers.log('check for ' + target.name)
265
- // setTimeout(() => {
266
- // // Helpers.log('check for ' + target.name + ' === ' + config.className)/
267
- // // TODO this may work, but not yet in singleton/morphi
268
- // if (!config.className) {
269
- // if (target?.name && target.name !== 'Object') {
270
- // ConfigHelpers.log(`[typescript-class-helpers] Please use @CLASS.NAME`
271
- // + `('${(target?.name && !!target.name) ? target.name : '...'}') decorator for class ${target?.name}`)
272
- // }
273
- // }
274
- // })
275
- }
276
- // special thing when cloning classes
277
- if (target.name?.startsWith('class_')) {
278
- return '';
279
- }
280
- return target.name;
187
+ else {
188
+ config = new Models__NS__ClassConfig();
189
+ config.classReference = target;
190
+ registerd.classes.push(target);
281
191
  }
282
- CLASSNAME_1.getClassName = getClassName;
283
- // @ts-ignore
284
- function getObjectIndexPropertyValue(obj) {
285
- const className = TchHelpers.getNameFromObject(obj);
286
- // console.log('className',className)
287
- let c = getClasses().find(c => c.className === className);
288
- // console.log('c',c)
289
- if (c) {
290
- return c.uniqueKey;
192
+ registerd.configs[registerd.classes.findIndex(c => c === target)] = config;
193
+ if (callerTarget) {
194
+ const callerTargetConfig = registerd.configs[registerd.classes.findIndex(c => c === callerTarget)];
195
+ if (!config.vChildren.includes(callerTargetConfig)) {
196
+ config.vChildren.push(callerTargetConfig);
291
197
  }
198
+ callerTargetConfig.vParent = config;
292
199
  }
293
- CLASSNAME_1.getObjectIndexPropertyValue = getObjectIndexPropertyValue;
294
- // @ts-ignore
295
- function getClassFamilyByClassName(className) {
296
- let c = getClasses().find(c => c.className === className);
297
- // console.log('getClasses()', getClasses())
298
- if (c) {
299
- return c.classFamily;
300
- }
200
+ configs.push(config);
201
+ return isValidParent
202
+ ? CLASSNAME__NS__getClassConfig(parentClass, configs, target)
203
+ : configs;
204
+ }
205
+ /**
206
+ * PLEASE PROVIDE NAME AS TYPED STRING, NOT VARIABLE
207
+ * Decorator requred for production mode
208
+ * @param name Name of class
209
+ */
210
+ function CLASSNAME__NS__CLASSNAME(className, options) {
211
+ return function (target) {
212
+ // console.log(`CLASSNAME Inited ${className}`)
213
+ return setClassName(target, className, options);
214
+ };
215
+ }
216
+ function CLASSNAME__NS__getClassName(target, production = false) {
217
+ if (_.isNil(target)) {
218
+ // console.log(target);
219
+ // Helpers.warn(`[typescript-class-helpers][getClassName] target is nil`)
220
+ return void 0;
301
221
  }
302
- CLASSNAME_1.getClassFamilyByClassName = getClassFamilyByClassName;
303
- // @ts-ignore
304
- function getObjectClassFamily(obj) {
305
- const className = TchHelpers.getNameFromObject(obj);
306
- // console.log('className',className)
307
- let c = getClasses().find(c => c.className === className);
308
- // console.log('c',c)
309
- if (c) {
310
- return c.classFamily;
311
- }
222
+ if (_.isString(target)) {
223
+ // console.log(target);
224
+ Helpers.log(`[typescript-class-helpers][getClassName] target is string: '${target}', produciton: ${production}`);
225
+ return target;
312
226
  }
313
- CLASSNAME_1.getObjectClassFamily = getObjectClassFamily;
314
- function getObjectIndexValue(obj) {
315
- const className = TchHelpers.getNameFromObject(obj);
316
- // console.log('className',className)
317
- let c = getClasses().find(c => c.className === className);
318
- // console.log('c',c)
319
- if (c && _.isString(c.uniqueKey)) {
320
- return obj[c.uniqueKey];
321
- }
227
+ if (target === Date) {
228
+ return 'Date';
229
+ }
230
+ if (target === FormData) {
231
+ return 'FormData';
232
+ }
233
+ if (!_.isFunction(target)) {
234
+ // console.log(target);
235
+ Helpers.log(`[typescript-class-helpers][getClassName] target is not a class`);
236
+ return void 0;
237
+ }
238
+ if (target[SYMBOL.ClassNameStaticProperty]) {
239
+ return target[SYMBOL.ClassNameStaticProperty];
240
+ }
241
+ const configs = CLASSNAME__NS__getClassConfig(target);
242
+ const config = _.first(configs);
243
+ const classNameInBrowser = config?.classNameInBrowser;
244
+ if (Helpers.isBrowser && _.isString(classNameInBrowser)) {
245
+ return classNameInBrowser;
246
+ }
247
+ const className = config?.className;
248
+ if (typeof className === 'string') {
249
+ return className;
250
+ }
251
+ if (production) {
252
+ console.log('class without @CLASS.NAME deocrator', target);
253
+ throw new Error(ERROR_MSG_CLASS_WITHOUT_DECORATOR);
254
+ }
255
+ else {
256
+ // Helpers.log('check for ' + target.name)
257
+ // setTimeout(() => {
258
+ // // Helpers.log('check for ' + target.name + ' === ' + config.className)/
259
+ // // TODO this may work, but not yet in singleton/morphi
260
+ // if (!config.className) {
261
+ // if (target?.name && target.name !== 'Object') {
262
+ // ConfigHelpers.log(`[typescript-class-helpers] Please use @CLASS.NAME`
263
+ // + `('${(target?.name && !!target.name) ? target.name : '...'}') decorator for class ${target?.name}`)
264
+ // }
265
+ // }
266
+ // })
267
+ }
268
+ // special thing when cloning classes
269
+ if (target.name?.startsWith('class_')) {
270
+ return '';
271
+ }
272
+ return target.name;
273
+ }
274
+ // @ts-ignore
275
+ function CLASSNAME__NS__getObjectIndexPropertyValue(obj) {
276
+ const className = TchHelpers.getNameFromObject(obj);
277
+ // console.log('className',className)
278
+ let c = getClasses().find(c => c.className === className);
279
+ // console.log('c',c)
280
+ if (c) {
281
+ return c.uniqueKey;
322
282
  }
323
- CLASSNAME_1.getObjectIndexValue = getObjectIndexValue;
324
- function getClassBy(className) {
325
- let res;
326
- if (Array.isArray(className)) {
327
- if (className.length !== 1) {
328
- throw `Mapping error... please use proper class names:
283
+ }
284
+ // @ts-ignore
285
+ function CLASSNAME__NS__getClassFamilyByClassName(className) {
286
+ let c = getClasses().find(c => c.className === className);
287
+ // console.log('getClasses()', getClasses())
288
+ if (c) {
289
+ return c.classFamily;
290
+ }
291
+ }
292
+ // @ts-ignore
293
+ function CLASSNAME__NS__getObjectClassFamily(obj) {
294
+ const className = TchHelpers.getNameFromObject(obj);
295
+ // console.log('className',className)
296
+ let c = getClasses().find(c => c.className === className);
297
+ // console.log('c',c)
298
+ if (c) {
299
+ return c.classFamily;
300
+ }
301
+ }
302
+ function CLASSNAME__NS__getObjectIndexValue(obj) {
303
+ const className = TchHelpers.getNameFromObject(obj);
304
+ // console.log('className',className)
305
+ let c = getClasses().find(c => c.className === className);
306
+ // console.log('c',c)
307
+ if (c && _.isString(c.uniqueKey)) {
308
+ return obj[c.uniqueKey];
309
+ }
310
+ }
311
+ function CLASSNAME__NS__getClassBy(className) {
312
+ let res;
313
+ if (Array.isArray(className)) {
314
+ if (className.length !== 1) {
315
+ throw `Mapping error... please use proper class names:
329
316
  {
330
317
  propertyObject: 'MyClassName',
331
318
  propertyWithArray: ['MyClassName']
332
319
  }
333
320
 
334
321
  `;
335
- }
336
- className = className[0];
337
- }
338
- if (typeof className === 'function') {
339
- // TODO QUICK_FIX
340
- res = className;
341
322
  }
342
- if (className === 'Date') {
343
- res = Date;
344
- }
345
- if (className === 'FormData') {
346
- res = FormData;
347
- }
348
- let c = getClasses().find(c => c.className === className);
349
- if (c) {
350
- res = c.target;
351
- }
352
- // console.log(`getClassBy "${className} return \n\n ${res} \n\n`)
353
- // @ts-ignore
354
- return res;
323
+ className = className[0];
324
+ }
325
+ if (typeof className === 'function') {
326
+ // TODO QUICK_FIX
327
+ res = className;
355
328
  }
356
- CLASSNAME_1.getClassBy = getClassBy;
357
- })(CLASSNAME || (CLASSNAME = {}));
329
+ if (className === 'Date') {
330
+ res = Date;
331
+ }
332
+ if (className === 'FormData') {
333
+ res = FormData;
334
+ }
335
+ let c = getClasses().find(c => c.className === className);
336
+ if (c) {
337
+ res = c.target;
338
+ }
339
+ // console.log(`getClassBy "${className} return \n\n ${res} \n\n`)
340
+ // @ts-ignore
341
+ return res;
342
+ }
343
+ //end of namespace CLASSNAME
358
344
 
359
345
  /**
360
346
  * @DEPRECATED
@@ -429,7 +415,7 @@ function describeByDefaultModelsAndMapping(target) {
429
415
 
430
416
  class TchHelpers {
431
417
  static getBy(className) {
432
- return CLASSNAME.getClassBy(className);
418
+ return CLASSNAME__NS__getClassBy(className);
433
419
  }
434
420
  static getFromObject(o) {
435
421
  if (_.isUndefined(o) || _.isNull(o)) {
@@ -442,14 +428,14 @@ class TchHelpers {
442
428
  return p && p.constructor;
443
429
  }
444
430
  static getName(target, production = false) {
445
- return CLASSNAME.getClassName(target, production);
431
+ return CLASSNAME__NS__getClassName(target, production);
446
432
  }
447
433
  static getNameFromObject(o) {
448
434
  const fnCLass = this.getFromObject(o);
449
435
  return this.getName(fnCLass);
450
436
  }
451
437
  static getConfigs(target) {
452
- return CLASSNAME.getClassConfig(target);
438
+ return CLASSNAME__NS__getClassConfig(target);
453
439
  }
454
440
  static describeProperites(target) {
455
441
  const d1 = describeFromClassStringify(target);
@@ -496,7 +482,7 @@ const getMethodsNames = (classOrClassInstance, allMethodsNames = []) => {
496
482
  return getMethodsNames(Object.getPrototypeOf(classFun), allMethodsNames);
497
483
  };
498
484
  const CLASS = {
499
- NAME: CLASSNAME.CLASSNAME,
485
+ NAME: CLASSNAME__NS__CLASSNAME,
500
486
  setName: setClassName,
501
487
  getBy: TchHelpers.getBy,
502
488
  /**
@@ -559,10 +545,10 @@ const CLASS = {
559
545
  OBJECT: (obj) => {
560
546
  return {
561
547
  get indexValue() {
562
- return CLASSNAME.getObjectIndexValue(obj);
548
+ return CLASSNAME__NS__getObjectIndexValue(obj);
563
549
  },
564
550
  get indexProperty() {
565
- return CLASSNAME.getObjectIndexPropertyValue(obj);
551
+ return CLASSNAME__NS__getObjectIndexPropertyValue(obj);
566
552
  },
567
553
  get isClassObject() {
568
554
  if (!_.isObject(obj) || _.isArray(obj) || _.isRegExp(obj) ||
@@ -583,12 +569,12 @@ const CLASS = {
583
569
  // console.log(`EQ v1: , v2: - class1 ${CLASS.getNameFromObject(obj)}, class2 ${CLASS.getNameFromObject(anotherObj)}`, obj, anotherObj)
584
570
  return true;
585
571
  }
586
- const v1 = CLASSNAME.getObjectIndexValue(obj);
587
- const v2 = CLASSNAME.getObjectIndexValue(anotherObj);
588
- const f1 = CLASSNAME.getObjectClassFamily(obj);
589
- const f2 = CLASSNAME.getObjectClassFamily(anotherObj);
572
+ const v1 = CLASSNAME__NS__getObjectIndexValue(obj);
573
+ const v2 = CLASSNAME__NS__getObjectIndexValue(anotherObj);
574
+ const f1 = CLASSNAME__NS__getObjectClassFamily(obj);
575
+ const f2 = CLASSNAME__NS__getObjectClassFamily(anotherObj);
590
576
  const isFamilyDiff = (!_.isString(f1) || !_.isString(f2) || (f1 !== f2));
591
- // console.log(`DIFF FAMILY ${isFamilyDiff} v1: ${CLASSNAME.getObjectClassFamily(obj)}, v2: ${CLASSNAME.getObjectClassFamily(anotherObj)} - class1 ${CLASS.getNameFromObject(obj)}, class2 ${CLASS.getNameFromObject(anotherObj)}`)
577
+ // console.log(`DIFF FAMILY ${isFamilyDiff} v1: ${CLASSNAME__NS__getObjectClassFamily(obj)}, v2: ${CLASSNAME__NS__getObjectClassFamily(anotherObj)} - class1 ${CLASS.getNameFromObject(obj)}, class2 ${CLASS.getNameFromObject(anotherObj)}`)
592
578
  if (isFamilyDiff) {
593
579
  // console.log(`DIFF v1: ${v1}, v2: ${v2} - class1 ${CLASS.getNameFromObject(obj)}, class2 ${CLASS.getNameFromObject(anotherObj)}`)
594
580
  return false;
@@ -619,5 +605,5 @@ const CLASS = {
619
605
  * Generated bundle index. Do not edit.
620
606
  */
621
607
 
622
- export { CLASS, Models, SYMBOL, TchHelpers };
608
+ export { CLASS, Models__NS__ClassConfig, Models__NS__MethodConfig, Models__NS__ParamConfig, SYMBOL, TchHelpers };
623
609
  //# sourceMappingURL=typescript-class-helpers-browser.mjs.map