@infrab4a/connect 3.13.3 → 3.13.6-beta.1

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 (155) hide show
  1. package/bundles/infrab4a-connect.umd.js +725 -116
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/helpers/index.d.ts +1 -1
  4. package/domain/catalog/models/category-collection-children.d.ts +1 -2
  5. package/domain/catalog/models/category-filter.d.ts +1 -1
  6. package/domain/catalog/models/category.d.ts +1 -2
  7. package/domain/catalog/models/filter-option.d.ts +1 -2
  8. package/domain/catalog/models/filter.d.ts +1 -2
  9. package/domain/catalog/models/kit-product.d.ts +1 -1
  10. package/domain/catalog/models/product.d.ts +1 -2
  11. package/domain/catalog/models/variant.d.ts +1 -2
  12. package/domain/generic/model/base.model.d.ts +9 -5
  13. package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
  14. package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
  15. package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
  16. package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
  17. package/domain/generic/repository/get.repository.d.ts +2 -2
  18. package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
  19. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
  20. package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
  21. package/domain/location/models/address.d.ts +4 -3
  22. package/domain/shopping/models/checkout.d.ts +5 -6
  23. package/domain/shopping/models/subscription/checkout.d.ts +3 -4
  24. package/domain/users/models/subscription/subscription.d.ts +3 -3
  25. package/domain/users/models/user-address.d.ts +1 -1
  26. package/domain/users/models/user.d.ts +3 -4
  27. package/esm2015/domain/catalog/helpers/index.js +2 -2
  28. package/esm2015/domain/catalog/helpers/round-product-price.helper.js +15 -0
  29. package/esm2015/domain/catalog/models/category-collection-children.js +1 -4
  30. package/esm2015/domain/catalog/models/category-filter.js +1 -4
  31. package/esm2015/domain/catalog/models/category.js +1 -4
  32. package/esm2015/domain/catalog/models/filter-option.js +1 -4
  33. package/esm2015/domain/catalog/models/filter.js +1 -4
  34. package/esm2015/domain/catalog/models/kit-product.js +2 -2
  35. package/esm2015/domain/catalog/models/product.js +1 -4
  36. package/esm2015/domain/catalog/models/variant.js +1 -4
  37. package/esm2015/domain/generic/model/base.model.js +3 -2
  38. package/esm2015/domain/generic/model/types/base-model-builder.type.js +1 -1
  39. package/esm2015/domain/generic/model/types/identifier-model.type.js +1 -1
  40. package/esm2015/domain/generic/model/types/model-base-structure.type.js +1 -1
  41. package/esm2015/domain/generic/model/types/non-function-property-name.type.js +1 -1
  42. package/esm2015/domain/generic/repository/get.repository.js +1 -1
  43. package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +1 -1
  44. package/esm2015/domain/generic/repository/types/repository-order-by-list.type.js +1 -1
  45. package/esm2015/domain/generic/repository/types/repository-update-params.type.js +1 -1
  46. package/esm2015/domain/location/models/address.js +2 -2
  47. package/esm2015/domain/shopping/models/checkout.js +6 -7
  48. package/esm2015/domain/shopping/models/order.js +1 -1
  49. package/esm2015/domain/shopping/models/subscription/checkout.js +6 -6
  50. package/esm2015/domain/users/models/subscription/subscription.js +6 -6
  51. package/esm2015/domain/users/models/user-address.js +1 -1
  52. package/esm2015/domain/users/models/user.js +3 -3
  53. package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +1 -1
  54. package/esm2015/infra/elasticsearch/indexes/products-index.js +8 -3
  55. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +3 -3
  56. package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +1 -1
  57. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +1 -1
  58. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +1 -1
  59. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +1 -1
  60. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +2 -2
  61. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
  62. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
  63. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +1 -1
  64. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +2 -2
  65. package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +1 -1
  66. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
  67. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
  68. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +1 -1
  69. package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +19 -14
  70. package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +1 -1
  71. package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +23 -18
  72. package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +19 -3
  73. package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +2 -2
  74. package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +5 -3
  75. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +18 -4
  76. package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +5 -3
  77. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +7 -4
  78. package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +7 -5
  79. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
  80. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
  81. package/esm2015/utils/decorators/debug.class.decorator.js +7 -0
  82. package/esm2015/utils/decorators/index.js +3 -0
  83. package/esm2015/utils/decorators/trace.method.decorator.js +81 -0
  84. package/esm2015/utils/helpers/class-name.helper.js +15 -0
  85. package/esm2015/utils/helpers/debug-decorator.helper.js +18 -0
  86. package/esm2015/utils/helpers/debug.helper.js +150 -0
  87. package/esm2015/utils/helpers/index.js +5 -0
  88. package/esm2015/utils/helpers/reflect.helper.js +165 -0
  89. package/esm2015/utils/index.js +4 -1
  90. package/esm2015/utils/log.utils.js +9 -0
  91. package/fesm2015/infrab4a-connect.js +557 -90
  92. package/fesm2015/infrab4a-connect.js.map +1 -1
  93. package/infra/elasticsearch/adapters/axios.adapter.d.ts +2 -2
  94. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
  95. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +3 -3
  96. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -3
  97. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
  98. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +1 -1
  99. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -3
  100. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +4 -4
  101. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +4 -4
  102. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  103. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
  104. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -1
  105. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +1 -1
  106. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +1 -1
  107. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +1 -1
  108. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +1 -1
  109. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +1 -1
  110. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +1 -1
  111. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +1 -1
  112. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +1 -1
  113. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +1 -1
  114. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +1 -1
  115. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +1 -1
  116. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +1 -1
  117. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +1 -1
  118. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +1 -1
  119. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +1 -1
  120. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +1 -1
  121. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +1 -1
  122. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +1 -1
  123. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +1 -1
  124. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +1 -1
  125. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -1
  126. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +1 -1
  127. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
  128. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
  129. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +1 -1
  130. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +5 -3
  131. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
  132. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +4 -2
  133. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +6 -5
  134. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +2 -1
  135. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +4 -4
  136. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +2 -2
  137. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +11 -9
  138. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +5 -4
  139. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
  140. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
  141. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +5 -3
  142. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +7 -3
  143. package/package.json +3 -2
  144. package/utils/decorators/debug.class.decorator.d.ts +2 -0
  145. package/utils/decorators/index.d.ts +2 -0
  146. package/utils/decorators/trace.method.decorator.d.ts +14 -0
  147. package/utils/helpers/class-name.helper.d.ts +3 -0
  148. package/utils/helpers/debug-decorator.helper.d.ts +9 -0
  149. package/utils/helpers/debug.helper.d.ts +60 -0
  150. package/utils/helpers/index.d.ts +4 -0
  151. package/utils/helpers/reflect.helper.d.ts +50 -0
  152. package/utils/index.d.ts +3 -0
  153. package/utils/log.utils.d.ts +7 -0
  154. package/esm2015/domain/catalog/helpers/RoundProdutcPriceHelper.js +0 -15
  155. /package/domain/catalog/helpers/{RoundProdutcPriceHelper.d.ts → round-product-price.helper.d.ts} +0 -0
@@ -3,8 +3,10 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
3
3
  import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
4
4
  import { parseISO } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
- import { isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
6
+ import { isNil, isArray, first, last, flatten, compact, get, isString, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
7
7
  export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
8
+ import { Subject } from 'rxjs';
9
+ import { debug } from 'debug';
8
10
  import { CustomError } from 'ts-custom-error';
9
11
  import axios from 'axios';
10
12
  import firebase from 'firebase';
@@ -13,7 +15,8 @@ import { mutation, query } from 'gql-query-builder';
13
15
  class BaseModel {
14
16
  get identifier() {
15
17
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
16
- return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
18
+ const data = this;
19
+ return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
17
20
  }
18
21
  get identifiersFields() {
19
22
  return this.constructor.identifiersFields;
@@ -459,12 +462,438 @@ __decorate([
459
462
  __metadata("design:type", Payment)
460
463
  ], SubscriptionPayment.prototype, "payment", void 0);
461
464
 
462
- class Address extends BaseModel {
463
- static get identifiersFields() {
464
- return ['id'];
465
+ var DebugNamespaces;
466
+ (function (DebugNamespaces) {
467
+ DebugNamespaces["ROOT"] = "connect";
468
+ DebugNamespaces["TRACE"] = "trace";
469
+ DebugNamespaces["ERROR"] = "error";
470
+ })(DebugNamespaces || (DebugNamespaces = {}));
471
+ const Logger = debug(DebugNamespaces.ROOT);
472
+
473
+ class ReflectHelper {
474
+ static get items() {
475
+ return this._items;
476
+ }
477
+ static get keys() {
478
+ return Object.keys(ReflectHelper.items);
479
+ }
480
+ static has(key, target, property) {
481
+ return (!isNil(key) &&
482
+ !isNil(ReflectHelper.items[key]) &&
483
+ (isNil(target) ||
484
+ (!isNil(ReflectHelper.items[key][target]) &&
485
+ (isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
486
+ }
487
+ static get({ key, target, property, own = true }) {
488
+ try {
489
+ if (own) {
490
+ return Reflect.getOwnMetadata(key, target, property) || null;
491
+ }
492
+ else {
493
+ return Reflect.getMetadata(key, target, property) || null;
494
+ }
495
+ }
496
+ catch (_err) {
497
+ return null;
498
+ }
499
+ }
500
+ static first({ key, target, property, own = true }) {
501
+ const values = ReflectHelper.get({ key, target, property, own });
502
+ return isArray(values) ? first(values) : values;
503
+ }
504
+ static last({ key, target, property, own = true }) {
505
+ const values = ReflectHelper.get({ key, target, property, own });
506
+ return isArray(values) ? last(values) : values;
507
+ }
508
+ static set({ key, target, property, value, propertyDescriptor }) {
509
+ Reflect.defineMetadata(key, value, target, property);
510
+ ReflectHelper.put({ key, target, property, value, propertyDescriptor });
511
+ }
512
+ static add({ key, target, property, value, propertyDescriptor }) {
513
+ let values = ReflectHelper.get({ key, target, property }) || new Array();
514
+ if (!Array.isArray(values))
515
+ values = [values];
516
+ values.push(value);
517
+ ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
518
+ }
519
+ static all({ key }) {
520
+ const items = ReflectHelper.items[key] || {};
521
+ return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
522
+ }
523
+ static allFrom(key, target) {
524
+ return Object.keys(target)
525
+ .filter((property) => property !== 'object')
526
+ .map((property) => this.allValuesFrom(key, target, property));
527
+ }
528
+ static allValuesFrom(key, target, property) {
529
+ const values = target[property];
530
+ let value = values.value;
531
+ const propertyDescriptor = values.propertyDescriptor;
532
+ if (!isArray(value))
533
+ value = [value];
534
+ return flatten(value.map((val) => {
535
+ return {
536
+ key,
537
+ target: target.object,
538
+ property,
539
+ value: val,
540
+ propertyDescriptor,
541
+ };
542
+ }));
543
+ }
544
+ static delete({ key, target, property }) {
545
+ Reflect.deleteMetadata(key, target, property);
546
+ return ReflectHelper.remove(key, target, property);
547
+ }
548
+ static clear(key) {
549
+ if (!key) {
550
+ ReflectHelper.keys.forEach((storedKey) => {
551
+ ReflectHelper.clear(storedKey);
552
+ });
553
+ }
554
+ else {
555
+ if (ReflectHelper.keys.includes(key)) {
556
+ Object.values(ReflectHelper.items[key]).forEach((target) => {
557
+ if (ReflectHelper.has(key, target)) {
558
+ Object.values(ReflectHelper.items[key][target]).forEach((property) => {
559
+ ReflectHelper.delete({
560
+ key,
561
+ target: target.object,
562
+ property: String(property),
563
+ });
564
+ ReflectHelper.remove(key, target, String(property));
565
+ });
566
+ }
567
+ ReflectHelper.delete({ key, target: target.object });
568
+ ReflectHelper.remove(key, target);
569
+ });
570
+ }
571
+ }
572
+ }
573
+ static getType({ target, propertyKey }) {
574
+ return Reflect.getMetadata('design:type', target, propertyKey);
575
+ }
576
+ static getReturntype({ target, propertyKey }) {
577
+ return Reflect.getMetadata('design:returntype', target, propertyKey);
578
+ }
579
+ static getAllMethods(target) {
580
+ const props = [];
581
+ let obj = target;
582
+ do {
583
+ props.push(...Object.getOwnPropertyNames(obj));
584
+ } while ((obj = Object.getPrototypeOf(obj)));
585
+ return props.sort().filter((e, i, arr) => {
586
+ if ([
587
+ '__defineGetter__',
588
+ '__defineSetter__',
589
+ '__lookupGetter__',
590
+ '__lookupSetter__',
591
+ 'constructor',
592
+ 'hasOwnProperty',
593
+ 'isPrototypeOf',
594
+ 'propertyIsEnumerable',
595
+ 'toLocaleString',
596
+ 'toString',
597
+ 'valueOf',
598
+ ].includes(e))
599
+ return false;
600
+ if (e != arr[i + 1] && typeof target[e] === 'function')
601
+ return true;
602
+ });
603
+ }
604
+ static put({ key, target, property, value, propertyDescriptor }) {
605
+ const index = target.constructor.name;
606
+ ReflectHelper.items[key] = ReflectHelper.items[key] || {};
607
+ ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
608
+ ReflectHelper.items[key][index].object = target;
609
+ if (isNil(property)) {
610
+ ReflectHelper.items[key][index].value = {
611
+ value,
612
+ propertyDescriptor,
613
+ };
614
+ }
615
+ else {
616
+ ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
617
+ ReflectHelper.items[key][index][String(property)] = {
618
+ value,
619
+ propertyDescriptor,
620
+ };
621
+ }
622
+ }
623
+ static remove(key, target, property) {
624
+ if (ReflectHelper.has(key, target, property))
625
+ return delete ReflectHelper.items[key][target][String(property)];
626
+ else if (ReflectHelper.has(key, target))
627
+ return delete ReflectHelper.items[key][target];
628
+ else if (ReflectHelper.has(key))
629
+ return delete ReflectHelper.items[key];
630
+ else
631
+ return false;
632
+ }
633
+ }
634
+ ReflectHelper._items = {};
635
+
636
+ class DebugDecoratorHelper {
637
+ static set(target, options) {
638
+ ReflectHelper.add({
639
+ key: DebugDecoratorHelper.DebugNamingMetadataKey,
640
+ target,
641
+ value: options,
642
+ });
643
+ }
644
+ static get(target) {
645
+ return ReflectHelper.first({
646
+ key: DebugDecoratorHelper.DebugNamingMetadataKey,
647
+ target,
648
+ });
649
+ }
650
+ }
651
+ DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
652
+
653
+ class ClassNameHelper {
654
+ static get(clazz) {
655
+ if (!clazz)
656
+ return null;
657
+ const prototype = Object.getPrototypeOf(clazz);
658
+ const names = compact([
659
+ get(clazz, 'constructor.name'),
660
+ get(prototype, 'constructor.name'),
661
+ get(prototype, '__proto__.constructor.name'),
662
+ ]);
663
+ return names.find((name) => name !== 'class_1');
465
664
  }
466
665
  }
467
666
 
667
+ const isDebuggable = (object) => {
668
+ return 'debug' in object;
669
+ };
670
+ class DebugHelper {
671
+ constructor(...namespace) {
672
+ this.namespaces = new Set();
673
+ this.push(...namespace);
674
+ }
675
+ static namespacesFor(target) {
676
+ if (isNil(target))
677
+ return [];
678
+ const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
679
+ const namespaces = get(decorator, 'namespaces', []);
680
+ const name = get(decorator, 'name', ClassNameHelper.get(target));
681
+ return [...namespaces, name];
682
+ }
683
+ static as(...namespaces) {
684
+ return new DebugHelper(...namespaces);
685
+ }
686
+ static for(target, ...namespaces) {
687
+ const targetNamespaces = this.namespacesFor(target);
688
+ return new DebugHelper(...targetNamespaces, ...namespaces);
689
+ }
690
+ static from(target, ...namespaces) {
691
+ if (this.isDebuggable(target)) {
692
+ const debug = target.debug;
693
+ if (namespaces)
694
+ debug.push(...namespaces);
695
+ return debug;
696
+ }
697
+ return DebugHelper.for(target, ...namespaces);
698
+ }
699
+ static clonedFrom(target, ...namespaces) {
700
+ if (this.isDebuggable(target)) {
701
+ namespaces.push(...target.debug.entries);
702
+ }
703
+ else if (!isNil(target)) {
704
+ namespaces.push(...this.namespacesFor(target));
705
+ }
706
+ return DebugHelper.for(target, ...namespaces);
707
+ }
708
+ static clone(target, ...namespaces) {
709
+ let original;
710
+ if (this.isDebuggable(target)) {
711
+ original = target.debug;
712
+ namespaces.push(...original.entries);
713
+ }
714
+ return {
715
+ original,
716
+ debug: DebugHelper.for(target, ...namespaces),
717
+ };
718
+ }
719
+ static replace(target, attrs) {
720
+ if (this.isDebuggable(target))
721
+ target.debug = attrs.with;
722
+ }
723
+ static mock(target, ...namespaces) {
724
+ const { original, debug } = DebugHelper.clone(target, ...namespaces);
725
+ DebugHelper.replace(target, { with: debug });
726
+ return { original, debug };
727
+ }
728
+ get entries() {
729
+ return Array.from(get(this, 'namespaces', []));
730
+ }
731
+ get namespace() {
732
+ return compact(flatten(this.entries)).join(':');
733
+ }
734
+ log(message, ...args) {
735
+ this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
736
+ DebugHelper.logs$.next({ namespace: this.namespace, message, args });
737
+ return this;
738
+ }
739
+ trace(message, ...args) {
740
+ this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
741
+ DebugHelper.traces$.next({ namespace: this.namespace, message, args });
742
+ return this;
743
+ }
744
+ error(error, ...args) {
745
+ this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
746
+ DebugHelper.errors$.next({ namespace: this.namespace, error, args });
747
+ return this;
748
+ }
749
+ build() {
750
+ this.logger = Logger;
751
+ this.tracer = Logger;
752
+ this.err = Logger;
753
+ this.entries.forEach((namespace) => {
754
+ this.logger = this.logger.extend(namespace);
755
+ this.tracer = this.tracer.extend(namespace);
756
+ this.err = this.err.extend(namespace);
757
+ });
758
+ return this;
759
+ }
760
+ with(...namespace) {
761
+ return new DebugHelper(...this.entries, ...namespace);
762
+ }
763
+ push(...namespace) {
764
+ if (namespace) {
765
+ namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
766
+ }
767
+ return this.build();
768
+ }
769
+ unshift(...namespace) {
770
+ if (namespace) {
771
+ return this.reset(...namespace, ...this.entries);
772
+ }
773
+ return this;
774
+ }
775
+ reset(...namespace) {
776
+ this.namespaces = new Set(flatten(compact(namespace)));
777
+ return this.build();
778
+ }
779
+ startWith(...namespace) {
780
+ const current = this.namespaces;
781
+ this.namespaces = new Set(flatten([compact(namespace), ...current]));
782
+ return this.build();
783
+ }
784
+ shift() {
785
+ const list = this.entries;
786
+ list.shift();
787
+ return this.reset(...list);
788
+ }
789
+ pop() {
790
+ const list = this.entries;
791
+ list.pop();
792
+ return this.reset(...list);
793
+ }
794
+ clear() {
795
+ return this.reset();
796
+ }
797
+ remove(...namespace) {
798
+ if (namespace) {
799
+ namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
800
+ }
801
+ return this.build();
802
+ }
803
+ puts(...args) {
804
+ return [`[${this.namespace}]`, ...args].join(' ');
805
+ }
806
+ }
807
+ DebugHelper.logs$ = new Subject();
808
+ DebugHelper.traces$ = new Subject();
809
+ DebugHelper.errors$ = new Subject();
810
+ DebugHelper.isDebuggable = isDebuggable;
811
+
812
+ function Debug(opts) {
813
+ return function (target) {
814
+ DebugDecoratorHelper.set(target.prototype, opts);
815
+ };
816
+ }
817
+
818
+ const ASYNC_IDENTIFIER = 'async';
819
+ function Log(options = {}) {
820
+ return Trace(Object.assign({ level: 'log' }, options));
821
+ }
822
+ function Trace(options = {}) {
823
+ return function (target, propertyKey, propertyDescriptor) {
824
+ const method = propertyDescriptor.value;
825
+ const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
826
+ const args = {
827
+ options,
828
+ method,
829
+ target,
830
+ propertyKey,
831
+ propertyDescriptor,
832
+ };
833
+ propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
834
+ return propertyDescriptor;
835
+ };
836
+ }
837
+ const traceCall = ({ target, propertyKey, propertyDescriptor, args }) => {
838
+ if (!target.debug)
839
+ target.debug = DebugHelper.for(target, propertyKey);
840
+ return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
841
+ };
842
+ const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
843
+ return function (...args) {
844
+ return new Promise((resolve, reject) => {
845
+ const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
846
+ if (get(options, 'level', '') === 'log') {
847
+ debug.with('params').log(args);
848
+ }
849
+ return method
850
+ .apply(this, args)
851
+ .then((result) => {
852
+ if (options.callbackFn) {
853
+ options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
854
+ }
855
+ if (get(options, 'level', '') === 'log') {
856
+ debug.with('returns').log(result === undefined ? 'void' : result);
857
+ }
858
+ return resolve(result);
859
+ })
860
+ .catch((error) => {
861
+ debug.error(error, ...args);
862
+ debug.with('stack').error(error.stack).pop();
863
+ return reject(error);
864
+ })
865
+ .finally(() => {
866
+ return debug.trace('finally', { args }).pop();
867
+ });
868
+ });
869
+ };
870
+ };
871
+ const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
872
+ return function (...args) {
873
+ const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
874
+ if (get(options, 'level', '') === 'log') {
875
+ debug.with('params').log(args);
876
+ }
877
+ let result;
878
+ try {
879
+ result = method.apply(this, args);
880
+ if (options.callbackFn)
881
+ options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
882
+ if (get(options, 'level', '') === 'log') {
883
+ debug.with('returns').log(result === undefined ? 'void' : result);
884
+ }
885
+ return result;
886
+ }
887
+ catch (error) {
888
+ debug.error(error, ...args).pop();
889
+ throw error;
890
+ }
891
+ finally {
892
+ debug.trace('finally', { args }).pop();
893
+ }
894
+ };
895
+ };
896
+
468
897
  const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
469
898
 
470
899
  class Base {
@@ -572,7 +1001,7 @@ class User extends BaseModel {
572
1001
  const instance = super.toInstance(data);
573
1002
  if (!isNil(data.firstName))
574
1003
  instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
575
- return instance;
1004
+ return;
576
1005
  }
577
1006
  toPlain() {
578
1007
  const plain = super.toPlain();
@@ -588,6 +1017,18 @@ __decorate([
588
1017
  __metadata("design:type", BeautyProfile)
589
1018
  ], User.prototype, "beautyProfile", void 0);
590
1019
 
1020
+ class Address extends BaseModel {
1021
+ static get identifiersFields() {
1022
+ return ['id'];
1023
+ }
1024
+ }
1025
+
1026
+ class UserAddress extends Address {
1027
+ static get identifiersFields() {
1028
+ return ['id', 'userId'];
1029
+ }
1030
+ }
1031
+
591
1032
  class Subscription extends BaseModel {
592
1033
  static get identifiersFields() {
593
1034
  return ['id'];
@@ -602,12 +1043,12 @@ __decorate([
602
1043
  __metadata("design:type", SubscriptionPlan)
603
1044
  ], Subscription.prototype, "subscriptionPlan", void 0);
604
1045
  __decorate([
605
- Type(() => Address),
606
- __metadata("design:type", Address)
1046
+ Type(() => UserAddress),
1047
+ __metadata("design:type", UserAddress)
607
1048
  ], Subscription.prototype, "shippingAddress", void 0);
608
1049
  __decorate([
609
- Type(() => Address),
610
- __metadata("design:type", Address)
1050
+ Type(() => UserAddress),
1051
+ __metadata("design:type", UserAddress)
611
1052
  ], Subscription.prototype, "billingAddress", void 0);
612
1053
  __decorate([
613
1054
  Type(() => Coupon),
@@ -622,12 +1063,6 @@ __decorate([
622
1063
  __metadata("design:type", Array)
623
1064
  ], Subscription.prototype, "payment", void 0);
624
1065
 
625
- class UserAddress extends Address {
626
- static get identifiersFields() {
627
- return ['id', 'userId'];
628
- }
629
- }
630
-
631
1066
  class UserPaymentMethod extends BaseModel {
632
1067
  static get identifiersFields() {
633
1068
  return ['id', 'userId'];
@@ -751,18 +1186,12 @@ class RecoveryPassword {
751
1186
  }
752
1187
 
753
1188
  class Filter extends BaseModel {
754
- identifierFields() {
755
- return ['id'];
756
- }
757
1189
  static get identifiersFields() {
758
1190
  return ['id'];
759
1191
  }
760
1192
  }
761
1193
 
762
1194
  class Category extends BaseModel {
763
- identifierFields() {
764
- return ['id'];
765
- }
766
1195
  static get identifiersFields() {
767
1196
  return ['id'];
768
1197
  }
@@ -777,9 +1206,6 @@ __decorate([
777
1206
  ], Category.prototype, "filters", void 0);
778
1207
 
779
1208
  class CategoryCollectionChildren extends BaseModel {
780
- identifierFields() {
781
- return ['collectionId', 'categoryId'];
782
- }
783
1209
  static get identifiersFields() {
784
1210
  return ['collectionId', 'categoryId'];
785
1211
  }
@@ -790,9 +1216,6 @@ __decorate([
790
1216
  ], CategoryCollectionChildren.prototype, "parent", void 0);
791
1217
 
792
1218
  class CategoryFilter extends BaseModel {
793
- // identifierFields(): NonFunctionPropertyNames<CategoryFilter>[] {
794
- // return ['id']
795
- // }
796
1219
  static get identifiersFields() {
797
1220
  return ['id', 'filterId', 'categoryId'];
798
1221
  }
@@ -814,9 +1237,6 @@ var Shops;
814
1237
  })(Shops || (Shops = {}));
815
1238
 
816
1239
  class FilterOption extends BaseModel {
817
- identifierFields() {
818
- return ['id'];
819
- }
820
1240
  static get identifiersFields() {
821
1241
  return ['id'];
822
1242
  }
@@ -841,9 +1261,6 @@ class Product extends BaseModel {
841
1261
  this.reviewsTotal = evaluation.count || this.reviewsTotal;
842
1262
  this.rate = evaluation.rating || this.rate;
843
1263
  }
844
- identifierFields() {
845
- return ['id'];
846
- }
847
1264
  static get identifiersFields() {
848
1265
  return ['id'];
849
1266
  }
@@ -859,7 +1276,7 @@ __decorate([
859
1276
 
860
1277
  class KitProduct extends BaseModel {
861
1278
  static get identifiersFields() {
862
- return ['productId', 'kitProducId'];
1279
+ return ['productId', 'kitProductId'];
863
1280
  }
864
1281
  }
865
1282
  __decorate([
@@ -872,9 +1289,6 @@ __decorate([
872
1289
  ], KitProduct.prototype, "product", void 0);
873
1290
 
874
1291
  class Variant extends BaseModel {
875
- identifierFields() {
876
- return ['id'];
877
- }
878
1292
  static get identifiersFields() {
879
1293
  return ['id', 'productId'];
880
1294
  }
@@ -925,12 +1339,12 @@ __decorate([
925
1339
  __metadata("design:type", User)
926
1340
  ], Checkout.prototype, "user", void 0);
927
1341
  __decorate([
928
- Type(() => Address),
929
- __metadata("design:type", Address)
1342
+ Type(() => UserAddress),
1343
+ __metadata("design:type", UserAddress)
930
1344
  ], Checkout.prototype, "shippingAddress", void 0);
931
1345
  __decorate([
932
- Type(() => Address),
933
- __metadata("design:type", Address)
1346
+ Type(() => UserAddress),
1347
+ __metadata("design:type", UserAddress)
934
1348
  ], Checkout.prototype, "billingAddress", void 0);
935
1349
  __decorate([
936
1350
  Type(() => ShippingMethod),
@@ -966,12 +1380,12 @@ class CheckoutSubscription extends BaseModel {
966
1380
  }
967
1381
  }
968
1382
  __decorate([
969
- Type(() => Address),
970
- __metadata("design:type", Address)
1383
+ Type(() => UserAddress),
1384
+ __metadata("design:type", UserAddress)
971
1385
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
972
1386
  __decorate([
973
- Type(() => Address),
974
- __metadata("design:type", Address)
1387
+ Type(() => UserAddress),
1388
+ __metadata("design:type", UserAddress)
975
1389
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
976
1390
  __decorate([
977
1391
  Type(() => SubscriptionPlan),
@@ -1273,7 +1687,12 @@ class ProductsIndex {
1273
1687
  },
1274
1688
  },
1275
1689
  });
1276
- search.hits = search.hits.filter((e) => e._source.name !== '');
1690
+ search.hits = search.hits
1691
+ .filter((e) => e._source.name !== '')
1692
+ .map((hit) => {
1693
+ RoundProductPricesHelper.roundProductPrices(hit._source);
1694
+ return hit;
1695
+ });
1277
1696
  return search;
1278
1697
  });
1279
1698
  }
@@ -1510,9 +1929,9 @@ const withCreateFirestore = (MixinBase) => {
1510
1929
  });
1511
1930
  }
1512
1931
  save(data) {
1513
- var _a;
1932
+ var _a, _b;
1514
1933
  return __awaiter(this, void 0, void 0, function* () {
1515
- const id = (_a = data[data.identifiersFields.shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1934
+ const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
1516
1935
  const collectionPath = this.buildCollectionPathForAdd(data);
1517
1936
  if (isEmpty(id))
1518
1937
  return this.collection(collectionPath).add(data);
@@ -2250,11 +2669,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2250
2669
  }, {});
2251
2670
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2252
2671
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2253
- if (!Array.isArray(options) &&
2672
+ const isNestedField = !Array.isArray(options) &&
2254
2673
  isObject(options) &&
2255
2674
  isNil(options === null || options === void 0 ? void 0 : options.operator) &&
2256
2675
  isNil(options === null || options === void 0 ? void 0 : options.value) &&
2257
- isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
2676
+ isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
2677
+ if (isNestedField)
2258
2678
  return Object.keys(options).reduce((variables, key) => {
2259
2679
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2260
2680
  const columnName = fieldOptions.columnName;
@@ -2265,7 +2685,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2265
2685
  return {
2266
2686
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2267
2687
  };
2268
- if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2688
+ if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2269
2689
  options = Object.values(options)[0];
2270
2690
  return Array.isArray(options)
2271
2691
  ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
@@ -2274,16 +2694,20 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2274
2694
  BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
2275
2695
  [BindFilterQueryHelper.GetHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
2276
2696
  });
2277
- BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
2278
- ? fieldOption.type === HasuraGraphQLColumnType.Jsonb
2279
- ? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
2280
- : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
2281
- : HasuraGraphQLWhere.EQUALS;
2282
- BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
2283
- ? '_contains'
2284
- : options.operator === Where.LIKE
2285
- ? '_has_keys_any'
2286
- : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
2697
+ BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => {
2698
+ if (!FilterOptionHelper.CheckIfIsFilterOption(options))
2699
+ return HasuraGraphQLWhere.EQUALS;
2700
+ if (fieldOption.type === HasuraGraphQLColumnType.Jsonb)
2701
+ return BindFilterQueryHelper.GetHasuraJsonbOperator(options);
2702
+ return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
2703
+ };
2704
+ BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => {
2705
+ if (options.operator === Where.IN)
2706
+ return '_contains';
2707
+ if (options.operator === Where.LIKE)
2708
+ return '_has_keys_any';
2709
+ return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
2710
+ };
2287
2711
 
2288
2712
  class GraphQLFieldHelper {
2289
2713
  }
@@ -2298,23 +2722,9 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2298
2722
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2299
2723
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2300
2724
  return;
2301
- if (fieldValue.fields)
2302
- return !fieldValue.filters
2303
- ? {
2304
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2305
- }
2306
- : {
2307
- operation: fieldValue.columnName || fieldName,
2308
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2309
- variables: {
2310
- [`${fieldValue.columnName}_where`]: {
2311
- name: 'where',
2312
- type: fieldValue.filters.filterType,
2313
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2314
- required: true,
2315
- },
2316
- },
2317
- };
2725
+ const isNestedField = !!fieldValue.fields;
2726
+ if (isNestedField)
2727
+ return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2318
2728
  return fieldValue.columnName;
2319
2729
  }).filter((field) => !!field);
2320
2730
  };
@@ -2370,6 +2780,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2370
2780
  return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
2371
2781
  }, {});
2372
2782
  };
2783
+ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2784
+ const hasCustomFilters = !!fieldValue.filters;
2785
+ if (hasCustomFilters)
2786
+ return {
2787
+ operation: fieldValue.columnName || fieldName,
2788
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2789
+ variables: {
2790
+ [`${fieldValue.columnName}_where`]: {
2791
+ name: 'where',
2792
+ type: fieldValue.filters.filterType,
2793
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2794
+ required: true,
2795
+ },
2796
+ },
2797
+ };
2798
+ return {
2799
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2800
+ };
2801
+ };
2373
2802
 
2374
2803
  const withCreateHasuraGraphQL = (MixinBase) => {
2375
2804
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -2377,14 +2806,30 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2377
2806
  const options = params === null || params === void 0 ? void 0 : params[0];
2378
2807
  super(...params);
2379
2808
  this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || `insert_${this.tableName}_one`;
2809
+ this.insertAllGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertAllGraphQLOperation) || `insert_${this.tableName}`;
2380
2810
  this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
2381
2811
  }
2382
2812
  create(data) {
2383
2813
  return __awaiter(this, void 0, void 0, function* () {
2814
+ this.logger = DebugHelper.from(this, 'create');
2384
2815
  const newData = yield this.save(this.model.toInstance(data));
2385
2816
  return this.model.toInstance(newData);
2386
2817
  });
2387
2818
  }
2819
+ createAll(data) {
2820
+ return __awaiter(this, void 0, void 0, function* () {
2821
+ this.logger = DebugHelper.from(this, 'createAll');
2822
+ const result = yield this.mutation(this.insertAllGraphQLOperation, [{ returning: this.model.identifiersFields }], {
2823
+ objects: {
2824
+ type: this.insertGraphQLObjectType,
2825
+ required: true,
2826
+ list: true,
2827
+ value: data.map((item) => this.convertDataToHasura(item)),
2828
+ },
2829
+ });
2830
+ return result[this.insertAllGraphQLOperation].returning.map((item, index) => this.model.toInstance(Object.assign(Object.assign({}, data[index]), item)));
2831
+ });
2832
+ }
2388
2833
  save(data) {
2389
2834
  return __awaiter(this, void 0, void 0, function* () {
2390
2835
  const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
@@ -2397,8 +2842,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2397
2842
  {
2398
2843
  [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
2399
2844
  var _a;
2400
- return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
2401
- foreignKeyField;
2845
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
2402
2846
  }),
2403
2847
  },
2404
2848
  ]);
@@ -2423,9 +2867,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
2423
2867
  }
2424
2868
  delete(identifiers) {
2425
2869
  return __awaiter(this, void 0, void 0, function* () {
2870
+ this.logger = DebugHelper.from(this, 'delete');
2426
2871
  const instance = this.model.toInstance(identifiers);
2427
2872
  yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
2428
- if (isNil(instance[identifier]))
2873
+ const identifierBinded = identifier;
2874
+ if (isNil(instance[identifierBinded]))
2429
2875
  return ids;
2430
2876
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2431
2877
  const value = columnOption.to(identifiers[identifier.toString()], instance);
@@ -2450,6 +2896,7 @@ const withHasuraGraphQL = (MixinBase) => {
2450
2896
  this.authOptions = options.authOptions;
2451
2897
  this.model = options.model;
2452
2898
  this.fields = options.fields || this.model.identifiersFields;
2899
+ this.logger = DebugHelper.from(this);
2453
2900
  }
2454
2901
  get headers() {
2455
2902
  return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
@@ -2484,6 +2931,7 @@ const withHasuraGraphQL = (MixinBase) => {
2484
2931
  }
2485
2932
  fetch(params) {
2486
2933
  return __awaiter(this, void 0, void 0, function* () {
2934
+ this.logger.with('params').log(params);
2487
2935
  const headers = this.headers;
2488
2936
  const { data: result } = yield axios({
2489
2937
  url: `${this.endpoint}`,
@@ -2493,6 +2941,7 @@ const withHasuraGraphQL = (MixinBase) => {
2493
2941
  });
2494
2942
  if (!isNil(result.errors))
2495
2943
  throw new Error(JSON.stringify(result.errors));
2944
+ this.logger.with('returns').log(result);
2496
2945
  return result.data;
2497
2946
  });
2498
2947
  }
@@ -2519,8 +2968,8 @@ const withHasuraGraphQL = (MixinBase) => {
2519
2968
  return value;
2520
2969
  return date;
2521
2970
  }
2522
- convertDataFromHasura(data) {
2523
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
2971
+ convertDataFromHasura(data, fields) {
2972
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2524
2973
  return this.model.toInstance(plain);
2525
2974
  }
2526
2975
  convertDataToHasura(instance, update = false) {
@@ -2549,6 +2998,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2549
2998
  }
2550
2999
  update(data) {
2551
3000
  return __awaiter(this, void 0, void 0, function* () {
3001
+ this.logger = DebugHelper.from(this, 'update');
2552
3002
  const plainData = this.paramsToPlain(data);
2553
3003
  yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
2554
3004
  _set: {
@@ -2571,10 +3021,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2571
3021
  const instance = this.model.toInstance(data);
2572
3022
  return this.model.identifiersFields.reduce((ids, identifier) => {
2573
3023
  var _a;
2574
- if (isNil(instance[identifier]))
3024
+ const identifierBinded = identifier;
3025
+ if (isNil(instance[identifierBinded]))
2575
3026
  return ids;
2576
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2577
- const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier.toString()], instance)) || data[columnOption.attributeName];
3027
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3028
+ const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifierBinded], instance)) || data[columnOption.attributeName];
2578
3029
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
2579
3030
  }, {});
2580
3031
  }
@@ -2590,10 +3041,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
2590
3041
  }
2591
3042
  get(identifiers) {
2592
3043
  return __awaiter(this, void 0, void 0, function* () {
3044
+ this.logger = DebugHelper.from(this, 'get');
2593
3045
  const instance = this.model.toInstance(identifiers);
2594
3046
  const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
2595
3047
  var _a;
2596
- if (isNil(instance[identifier]))
3048
+ const identifierBinded = identifier;
3049
+ if (isNil(instance[identifierBinded]))
2597
3050
  return ids;
2598
3051
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2599
3052
  const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
@@ -2614,12 +3067,26 @@ const withGetHasuraGraphQL = (MixinBase) => {
2614
3067
 
2615
3068
  const withFindHasuraGraphQL = (MixinBase) => {
2616
3069
  return class FindHasuraGraphQLMixin extends MixinBase {
3070
+ constructor() {
3071
+ super(...arguments);
3072
+ this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
3073
+ .columnName]: orderBy[current] })), {});
3074
+ }
2617
3075
  find(params) {
2618
3076
  var _a;
2619
3077
  return __awaiter(this, void 0, void 0, function* () {
3078
+ this.logger = DebugHelper.from(this, 'find');
2620
3079
  const { filters, limits, orderBy, options } = params || {};
2621
3080
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
2622
- const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
3081
+ const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
3082
+ ? {}
3083
+ : {
3084
+ order_by: {
3085
+ type: `${this.tableName}_order_by!`,
3086
+ list: true,
3087
+ value: this.bindOrderByAttributes(orderBy, this.fields),
3088
+ },
3089
+ })), (isNil(filters)
2623
3090
  ? {}
2624
3091
  : {
2625
3092
  where: {
@@ -3835,5 +4302,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3835
4302
  * Generated bundle index. Do not edit.
3836
4303
  */
3837
4304
 
3838
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4305
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3839
4306
  //# sourceMappingURL=infrab4a-connect.js.map