@infrab4a/connect 4.0.0-beta.25 → 4.0.0-beta.27

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 (152) hide show
  1. package/domain/catalog/helpers/RoundProdutcPriceHelper.d.ts +4 -0
  2. package/domain/catalog/helpers/index.d.ts +1 -0
  3. package/domain/catalog/index.d.ts +1 -0
  4. package/domain/catalog/models/category-collection-children.d.ts +13 -0
  5. package/domain/catalog/models/category-filter.d.ts +1 -1
  6. package/domain/catalog/models/category.d.ts +3 -3
  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/index.d.ts +1 -0
  10. package/domain/catalog/models/kit-product.d.ts +1 -1
  11. package/domain/catalog/models/product.d.ts +1 -2
  12. package/domain/catalog/models/types/category-product.d.ts +4 -0
  13. package/domain/catalog/models/types/index.d.ts +1 -0
  14. package/domain/catalog/models/variant.d.ts +1 -2
  15. package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
  16. package/domain/catalog/repositories/category.repository.d.ts +1 -0
  17. package/domain/catalog/repositories/index.d.ts +1 -0
  18. package/domain/generic/model/base.model.d.ts +9 -5
  19. package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
  20. package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
  21. package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
  22. package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
  23. package/domain/generic/repository/get.repository.d.ts +2 -2
  24. package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
  25. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
  26. package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
  27. package/domain/location/models/address.d.ts +5 -3
  28. package/domain/shopping/models/checkout.d.ts +5 -6
  29. package/domain/shopping/models/subscription/checkout.d.ts +3 -4
  30. package/domain/users/models/subscription/subscription.d.ts +3 -3
  31. package/domain/users/models/user-address.d.ts +1 -2
  32. package/domain/users/models/user.d.ts +2 -3
  33. package/esm2020/domain/catalog/helpers/RoundProdutcPriceHelper.mjs +15 -0
  34. package/esm2020/domain/catalog/helpers/index.mjs +2 -0
  35. package/esm2020/domain/catalog/index.mjs +2 -1
  36. package/esm2020/domain/catalog/models/category-collection-children.mjs +13 -0
  37. package/esm2020/domain/catalog/models/category-filter.mjs +1 -1
  38. package/esm2020/domain/catalog/models/category.mjs +1 -4
  39. package/esm2020/domain/catalog/models/filter-option.mjs +1 -4
  40. package/esm2020/domain/catalog/models/filter.mjs +1 -4
  41. package/esm2020/domain/catalog/models/index.mjs +2 -1
  42. package/esm2020/domain/catalog/models/kit-product.mjs +2 -2
  43. package/esm2020/domain/catalog/models/product.mjs +1 -4
  44. package/esm2020/domain/catalog/models/types/category-product.mjs +2 -0
  45. package/esm2020/domain/catalog/models/types/index.mjs +2 -1
  46. package/esm2020/domain/catalog/models/variant.mjs +1 -4
  47. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +2 -0
  48. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  49. package/esm2020/domain/catalog/repositories/index.mjs +2 -1
  50. package/esm2020/domain/generic/model/base.model.mjs +3 -2
  51. package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +1 -1
  52. package/esm2020/domain/generic/model/types/identifier-model.type.mjs +1 -1
  53. package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +1 -1
  54. package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +1 -1
  55. package/esm2020/domain/generic/repository/get.repository.mjs +1 -1
  56. package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +1 -1
  57. package/esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs +1 -1
  58. package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +1 -1
  59. package/esm2020/domain/location/models/address.mjs +2 -2
  60. package/esm2020/domain/shopping/models/checkout.mjs +6 -7
  61. package/esm2020/domain/shopping/models/order.mjs +1 -1
  62. package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
  63. package/esm2020/domain/users/models/subscription/subscription.mjs +6 -6
  64. package/esm2020/domain/users/models/user-address.mjs +1 -1
  65. package/esm2020/domain/users/models/user.mjs +3 -3
  66. package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
  67. package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +1 -1
  68. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +2 -2
  69. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
  70. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +1 -1
  71. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +3 -3
  72. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +1 -1
  73. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +1 -1
  74. package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
  75. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +1 -1
  76. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +1 -1
  77. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +4 -1
  78. package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +1 -1
  79. package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +1 -1
  80. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
  81. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +1 -1
  82. package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +5 -4
  83. package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
  84. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +25 -20
  85. package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +5 -3
  86. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
  87. package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +5 -3
  88. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +21 -4
  89. package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +5 -3
  90. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +12 -5
  91. package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +7 -5
  92. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +38 -0
  93. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +26 -2
  94. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +2 -1
  95. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +3 -2
  96. package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
  97. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
  98. package/esm2020/utils/decorators/debug.class.decorator.mjs +7 -0
  99. package/esm2020/utils/decorators/index.mjs +3 -0
  100. package/esm2020/utils/decorators/trace.method.decorator.mjs +81 -0
  101. package/esm2020/utils/helpers/class-name.helper.mjs +15 -0
  102. package/esm2020/utils/helpers/debug-decorator.helper.mjs +18 -0
  103. package/esm2020/utils/helpers/debug.helper.mjs +150 -0
  104. package/esm2020/utils/helpers/index.mjs +5 -0
  105. package/esm2020/utils/helpers/reflect.helper.mjs +165 -0
  106. package/esm2020/utils/index.mjs +4 -1
  107. package/esm2020/utils/log.utils.mjs +9 -0
  108. package/fesm2015/infrab4a-connect.mjs +620 -78
  109. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  110. package/fesm2020/infrab4a-connect.mjs +622 -78
  111. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  112. package/infra/elasticsearch/adapters/axios.adapter.d.ts +2 -2
  113. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
  114. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -1
  115. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +2 -2
  116. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
  117. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
  118. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
  119. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +2 -2
  120. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -2
  121. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  122. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -0
  123. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
  124. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
  125. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +1 -1
  126. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +9 -3
  127. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
  128. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +4 -2
  129. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -5
  130. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +2 -1
  131. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +1 -1
  132. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +1 -1
  133. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +11 -9
  134. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +7 -6
  135. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
  136. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
  137. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
  138. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -0
  139. package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  140. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +7 -5
  141. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +7 -3
  142. package/package.json +2 -1
  143. package/utils/decorators/debug.class.decorator.d.ts +2 -0
  144. package/utils/decorators/index.d.ts +2 -0
  145. package/utils/decorators/trace.method.decorator.d.ts +14 -0
  146. package/utils/helpers/class-name.helper.d.ts +3 -0
  147. package/utils/helpers/debug-decorator.helper.d.ts +9 -0
  148. package/utils/helpers/debug.helper.d.ts +60 -0
  149. package/utils/helpers/index.d.ts +4 -0
  150. package/utils/helpers/reflect.helper.d.ts +50 -0
  151. package/utils/index.d.ts +3 -0
  152. package/utils/log.utils.d.ts +7 -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 { get as get$1, 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 as get$1, 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 { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
@@ -14,7 +16,8 @@ import { mutation, query as query$1 } from 'gql-query-builder';
14
16
  class BaseModel {
15
17
  get identifier() {
16
18
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
17
- return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
19
+ const data = this;
20
+ return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
18
21
  }
19
22
  get identifiersFields() {
20
23
  return this.constructor.identifiersFields;
@@ -460,12 +463,438 @@ __decorate([
460
463
  __metadata("design:type", Payment)
461
464
  ], SubscriptionPayment.prototype, "payment", void 0);
462
465
 
463
- class Address extends BaseModel {
464
- static get identifiersFields() {
465
- return ['id'];
466
+ var DebugNamespaces;
467
+ (function (DebugNamespaces) {
468
+ DebugNamespaces["ROOT"] = "connect";
469
+ DebugNamespaces["TRACE"] = "trace";
470
+ DebugNamespaces["ERROR"] = "error";
471
+ })(DebugNamespaces || (DebugNamespaces = {}));
472
+ const Logger = debug(DebugNamespaces.ROOT);
473
+
474
+ class ReflectHelper {
475
+ static get items() {
476
+ return this._items;
477
+ }
478
+ static get keys() {
479
+ return Object.keys(ReflectHelper.items);
480
+ }
481
+ static has(key, target, property) {
482
+ return (!isNil(key) &&
483
+ !isNil(ReflectHelper.items[key]) &&
484
+ (isNil(target) ||
485
+ (!isNil(ReflectHelper.items[key][target]) &&
486
+ (isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
487
+ }
488
+ static get({ key, target, property, own = true }) {
489
+ try {
490
+ if (own) {
491
+ return Reflect.getOwnMetadata(key, target, property) || null;
492
+ }
493
+ else {
494
+ return Reflect.getMetadata(key, target, property) || null;
495
+ }
496
+ }
497
+ catch (_err) {
498
+ return null;
499
+ }
500
+ }
501
+ static first({ key, target, property, own = true }) {
502
+ const values = ReflectHelper.get({ key, target, property, own });
503
+ return isArray(values) ? first(values) : values;
504
+ }
505
+ static last({ key, target, property, own = true }) {
506
+ const values = ReflectHelper.get({ key, target, property, own });
507
+ return isArray(values) ? last(values) : values;
508
+ }
509
+ static set({ key, target, property, value, propertyDescriptor }) {
510
+ Reflect.defineMetadata(key, value, target, property);
511
+ ReflectHelper.put({ key, target, property, value, propertyDescriptor });
512
+ }
513
+ static add({ key, target, property, value, propertyDescriptor }) {
514
+ let values = ReflectHelper.get({ key, target, property }) || new Array();
515
+ if (!Array.isArray(values))
516
+ values = [values];
517
+ values.push(value);
518
+ ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
519
+ }
520
+ static all({ key }) {
521
+ const items = ReflectHelper.items[key] || {};
522
+ return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
523
+ }
524
+ static allFrom(key, target) {
525
+ return Object.keys(target)
526
+ .filter((property) => property !== 'object')
527
+ .map((property) => this.allValuesFrom(key, target, property));
528
+ }
529
+ static allValuesFrom(key, target, property) {
530
+ const values = target[property];
531
+ let value = values.value;
532
+ const propertyDescriptor = values.propertyDescriptor;
533
+ if (!isArray(value))
534
+ value = [value];
535
+ return flatten(value.map((val) => {
536
+ return {
537
+ key,
538
+ target: target.object,
539
+ property,
540
+ value: val,
541
+ propertyDescriptor,
542
+ };
543
+ }));
544
+ }
545
+ static delete({ key, target, property }) {
546
+ Reflect.deleteMetadata(key, target, property);
547
+ return ReflectHelper.remove(key, target, property);
548
+ }
549
+ static clear(key) {
550
+ if (!key) {
551
+ ReflectHelper.keys.forEach((storedKey) => {
552
+ ReflectHelper.clear(storedKey);
553
+ });
554
+ }
555
+ else {
556
+ if (ReflectHelper.keys.includes(key)) {
557
+ Object.values(ReflectHelper.items[key]).forEach((target) => {
558
+ if (ReflectHelper.has(key, target)) {
559
+ Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
560
+ ReflectHelper.delete({
561
+ key,
562
+ target: target.object,
563
+ property: String(property),
564
+ });
565
+ ReflectHelper.remove(key, target, String(property));
566
+ });
567
+ }
568
+ ReflectHelper.delete({ key, target: target.object });
569
+ ReflectHelper.remove(key, target);
570
+ });
571
+ }
572
+ }
573
+ }
574
+ static getType({ target, propertyKey }) {
575
+ return Reflect.getMetadata('design:type', target, propertyKey);
576
+ }
577
+ static getReturntype({ target, propertyKey }) {
578
+ return Reflect.getMetadata('design:returntype', target, propertyKey);
579
+ }
580
+ static getAllMethods(target) {
581
+ const props = [];
582
+ let obj = target;
583
+ do {
584
+ props.push(...Object.getOwnPropertyNames(obj));
585
+ } while ((obj = Object.getPrototypeOf(obj)));
586
+ return props.sort().filter((e, i, arr) => {
587
+ if ([
588
+ '__defineGetter__',
589
+ '__defineSetter__',
590
+ '__lookupGetter__',
591
+ '__lookupSetter__',
592
+ 'constructor',
593
+ 'hasOwnProperty',
594
+ 'isPrototypeOf',
595
+ 'propertyIsEnumerable',
596
+ 'toLocaleString',
597
+ 'toString',
598
+ 'valueOf',
599
+ ].includes(e))
600
+ return false;
601
+ if (e != arr[i + 1] && typeof target[e] === 'function')
602
+ return true;
603
+ });
604
+ }
605
+ static put({ key, target, property, value, propertyDescriptor }) {
606
+ const index = target.constructor.name;
607
+ ReflectHelper.items[key] = ReflectHelper.items[key] || {};
608
+ ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
609
+ ReflectHelper.items[key][index].object = target;
610
+ if (isNil(property)) {
611
+ ReflectHelper.items[key][index].value = {
612
+ value,
613
+ propertyDescriptor,
614
+ };
615
+ }
616
+ else {
617
+ ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
618
+ ReflectHelper.items[key][index][String(property)] = {
619
+ value,
620
+ propertyDescriptor,
621
+ };
622
+ }
623
+ }
624
+ static remove(key, target, property) {
625
+ if (ReflectHelper.has(key, target, property))
626
+ return delete ReflectHelper.items[key][target][String(property)];
627
+ else if (ReflectHelper.has(key, target))
628
+ return delete ReflectHelper.items[key][target];
629
+ else if (ReflectHelper.has(key))
630
+ return delete ReflectHelper.items[key];
631
+ else
632
+ return false;
633
+ }
634
+ }
635
+ ReflectHelper._items = {};
636
+
637
+ class DebugDecoratorHelper {
638
+ static set(target, options) {
639
+ ReflectHelper.add({
640
+ key: DebugDecoratorHelper.DebugNamingMetadataKey,
641
+ target,
642
+ value: options,
643
+ });
644
+ }
645
+ static get(target) {
646
+ return ReflectHelper.first({
647
+ key: DebugDecoratorHelper.DebugNamingMetadataKey,
648
+ target,
649
+ });
650
+ }
651
+ }
652
+ DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
653
+
654
+ class ClassNameHelper {
655
+ static get(clazz) {
656
+ if (!clazz)
657
+ return null;
658
+ const prototype = Object.getPrototypeOf(clazz);
659
+ const names = compact([
660
+ get$1(clazz, 'constructor.name'),
661
+ get$1(prototype, 'constructor.name'),
662
+ get$1(prototype, '__proto__.constructor.name'),
663
+ ]);
664
+ return names.find((name) => name !== 'class_1');
466
665
  }
467
666
  }
468
667
 
668
+ const isDebuggable = (object) => {
669
+ return 'debug' in object;
670
+ };
671
+ class DebugHelper {
672
+ constructor(...namespace) {
673
+ this.namespaces = new Set();
674
+ this.push(...namespace);
675
+ }
676
+ static namespacesFor(target) {
677
+ if (isNil(target))
678
+ return [];
679
+ const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
680
+ const namespaces = get$1(decorator, 'namespaces', []);
681
+ const name = get$1(decorator, 'name', ClassNameHelper.get(target));
682
+ return [...namespaces, name];
683
+ }
684
+ static as(...namespaces) {
685
+ return new DebugHelper(...namespaces);
686
+ }
687
+ static for(target, ...namespaces) {
688
+ const targetNamespaces = this.namespacesFor(target);
689
+ return new DebugHelper(...targetNamespaces, ...namespaces);
690
+ }
691
+ static from(target, ...namespaces) {
692
+ if (this.isDebuggable(target)) {
693
+ const debug = target.debug;
694
+ if (namespaces)
695
+ debug.push(...namespaces);
696
+ return debug;
697
+ }
698
+ return DebugHelper.for(target, ...namespaces);
699
+ }
700
+ static clonedFrom(target, ...namespaces) {
701
+ if (this.isDebuggable(target)) {
702
+ namespaces.push(...target.debug.entries);
703
+ }
704
+ else if (!isNil(target)) {
705
+ namespaces.push(...this.namespacesFor(target));
706
+ }
707
+ return DebugHelper.for(target, ...namespaces);
708
+ }
709
+ static clone(target, ...namespaces) {
710
+ let original;
711
+ if (this.isDebuggable(target)) {
712
+ original = target.debug;
713
+ namespaces.push(...original.entries);
714
+ }
715
+ return {
716
+ original,
717
+ debug: DebugHelper.for(target, ...namespaces),
718
+ };
719
+ }
720
+ static replace(target, attrs) {
721
+ if (this.isDebuggable(target))
722
+ target.debug = attrs.with;
723
+ }
724
+ static mock(target, ...namespaces) {
725
+ const { original, debug } = DebugHelper.clone(target, ...namespaces);
726
+ DebugHelper.replace(target, { with: debug });
727
+ return { original, debug };
728
+ }
729
+ get entries() {
730
+ return Array.from(get$1(this, 'namespaces', []));
731
+ }
732
+ get namespace() {
733
+ return compact(flatten(this.entries)).join(':');
734
+ }
735
+ log(message, ...args) {
736
+ this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
737
+ DebugHelper.logs$.next({ namespace: this.namespace, message, args });
738
+ return this;
739
+ }
740
+ trace(message, ...args) {
741
+ this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
742
+ DebugHelper.traces$.next({ namespace: this.namespace, message, args });
743
+ return this;
744
+ }
745
+ error(error, ...args) {
746
+ this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
747
+ DebugHelper.errors$.next({ namespace: this.namespace, error, args });
748
+ return this;
749
+ }
750
+ build() {
751
+ this.logger = Logger;
752
+ this.tracer = Logger;
753
+ this.err = Logger;
754
+ this.entries.forEach((namespace) => {
755
+ this.logger = this.logger.extend(namespace);
756
+ this.tracer = this.tracer.extend(namespace);
757
+ this.err = this.err.extend(namespace);
758
+ });
759
+ return this;
760
+ }
761
+ with(...namespace) {
762
+ return new DebugHelper(...this.entries, ...namespace);
763
+ }
764
+ push(...namespace) {
765
+ if (namespace) {
766
+ namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
767
+ }
768
+ return this.build();
769
+ }
770
+ unshift(...namespace) {
771
+ if (namespace) {
772
+ return this.reset(...namespace, ...this.entries);
773
+ }
774
+ return this;
775
+ }
776
+ reset(...namespace) {
777
+ this.namespaces = new Set(flatten(compact(namespace)));
778
+ return this.build();
779
+ }
780
+ startWith(...namespace) {
781
+ const current = this.namespaces;
782
+ this.namespaces = new Set(flatten([compact(namespace), ...current]));
783
+ return this.build();
784
+ }
785
+ shift() {
786
+ const list = this.entries;
787
+ list.shift();
788
+ return this.reset(...list);
789
+ }
790
+ pop() {
791
+ const list = this.entries;
792
+ list.pop();
793
+ return this.reset(...list);
794
+ }
795
+ clear() {
796
+ return this.reset();
797
+ }
798
+ remove(...namespace) {
799
+ if (namespace) {
800
+ namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
801
+ }
802
+ return this.build();
803
+ }
804
+ puts(...args) {
805
+ return [`[${this.namespace}]`, ...args].join(' ');
806
+ }
807
+ }
808
+ DebugHelper.logs$ = new Subject();
809
+ DebugHelper.traces$ = new Subject();
810
+ DebugHelper.errors$ = new Subject();
811
+ DebugHelper.isDebuggable = isDebuggable;
812
+
813
+ function Debug(opts) {
814
+ return function (target) {
815
+ DebugDecoratorHelper.set(target.prototype, opts);
816
+ };
817
+ }
818
+
819
+ const ASYNC_IDENTIFIER = 'async';
820
+ function Log(options = {}) {
821
+ return Trace(Object.assign({ level: 'log' }, options));
822
+ }
823
+ function Trace(options = {}) {
824
+ return function (target, propertyKey, propertyDescriptor) {
825
+ const method = propertyDescriptor.value;
826
+ const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
827
+ const args = {
828
+ options,
829
+ method,
830
+ target,
831
+ propertyKey,
832
+ propertyDescriptor,
833
+ };
834
+ propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
835
+ return propertyDescriptor;
836
+ };
837
+ }
838
+ const traceCall = function ({ target, propertyKey, propertyDescriptor, args }) {
839
+ if (!target.debug)
840
+ target.debug = DebugHelper.for(target, propertyKey);
841
+ return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
842
+ };
843
+ const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
844
+ return function (...args) {
845
+ return new Promise((resolve, reject) => {
846
+ const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
847
+ if (get$1(options, 'level', '') === 'log') {
848
+ debug.with('params').log(args);
849
+ }
850
+ return method
851
+ .apply(this, args)
852
+ .then((result) => {
853
+ if (options.callbackFn) {
854
+ options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
855
+ }
856
+ if (get$1(options, 'level', '') === 'log') {
857
+ debug.with('returns').log(result === undefined ? 'void' : result);
858
+ }
859
+ return resolve(result);
860
+ })
861
+ .catch((error) => {
862
+ debug.error(error, ...args);
863
+ debug.with('stack').error(error.stack).pop();
864
+ return reject(error);
865
+ })
866
+ .finally(() => {
867
+ return debug.trace('finally', { args }).pop();
868
+ });
869
+ });
870
+ };
871
+ };
872
+ const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
873
+ return function (...args) {
874
+ const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
875
+ if (get$1(options, 'level', '') === 'log') {
876
+ debug.with('params').log(args);
877
+ }
878
+ let result;
879
+ try {
880
+ result = method.apply(this, args);
881
+ if (options.callbackFn)
882
+ options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
883
+ if (get$1(options, 'level', '') === 'log') {
884
+ debug.with('returns').log(result === undefined ? 'void' : result);
885
+ }
886
+ return result;
887
+ }
888
+ catch (error) {
889
+ debug.error(error, ...args).pop();
890
+ throw error;
891
+ }
892
+ finally {
893
+ debug.trace('finally', { args }).pop();
894
+ }
895
+ };
896
+ };
897
+
469
898
  const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
470
899
 
471
900
  function is(value) {
@@ -579,7 +1008,7 @@ class User extends BaseModel {
579
1008
  const instance = super.toInstance(data);
580
1009
  if (!isNil(data.firstName))
581
1010
  instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
582
- return instance;
1011
+ return;
583
1012
  }
584
1013
  toPlain() {
585
1014
  const plain = super.toPlain();
@@ -595,6 +1024,18 @@ __decorate([
595
1024
  __metadata("design:type", BeautyProfile)
596
1025
  ], User.prototype, "beautyProfile", void 0);
597
1026
 
1027
+ class Address extends BaseModel {
1028
+ static get identifiersFields() {
1029
+ return ['id'];
1030
+ }
1031
+ }
1032
+
1033
+ class UserAddress extends Address {
1034
+ static get identifiersFields() {
1035
+ return ['id', 'userId'];
1036
+ }
1037
+ }
1038
+
598
1039
  class Subscription extends BaseModel {
599
1040
  static get identifiersFields() {
600
1041
  return ['id'];
@@ -609,12 +1050,12 @@ __decorate([
609
1050
  __metadata("design:type", SubscriptionPlan)
610
1051
  ], Subscription.prototype, "subscriptionPlan", void 0);
611
1052
  __decorate([
612
- Type(() => Address),
613
- __metadata("design:type", Address)
1053
+ Type(() => UserAddress),
1054
+ __metadata("design:type", UserAddress)
614
1055
  ], Subscription.prototype, "shippingAddress", void 0);
615
1056
  __decorate([
616
- Type(() => Address),
617
- __metadata("design:type", Address)
1057
+ Type(() => UserAddress),
1058
+ __metadata("design:type", UserAddress)
618
1059
  ], Subscription.prototype, "billingAddress", void 0);
619
1060
  __decorate([
620
1061
  Type(() => Coupon),
@@ -629,12 +1070,6 @@ __decorate([
629
1070
  __metadata("design:type", Array)
630
1071
  ], Subscription.prototype, "payment", void 0);
631
1072
 
632
- class UserAddress extends Address {
633
- static get identifiersFields() {
634
- return ['id', 'userId'];
635
- }
636
- }
637
-
638
1073
  class UserPaymentMethod extends BaseModel {
639
1074
  static get identifiersFields() {
640
1075
  return ['id', 'userId'];
@@ -667,7 +1102,7 @@ class Authentication {
667
1102
  return __awaiter(this, void 0, void 0, function* () {
668
1103
  const method = this.getServiceByMethod(signInMethod);
669
1104
  const userAuth = yield this.authService[method]({ email, password });
670
- const user = this.userRepository.get(userAuth);
1105
+ const user = this.userRepository.get({ id: userAuth.id });
671
1106
  if (!isNil(user))
672
1107
  return user;
673
1108
  if (/^.+@b4a.com.br$/.test(userAuth.email))
@@ -755,18 +1190,12 @@ class RecoveryPassword {
755
1190
  }
756
1191
 
757
1192
  class Filter extends BaseModel {
758
- identifierFields() {
759
- return ['id'];
760
- }
761
1193
  static get identifiersFields() {
762
1194
  return ['id'];
763
1195
  }
764
1196
  }
765
1197
 
766
1198
  class Category extends BaseModel {
767
- identifierFields() {
768
- return ['id'];
769
- }
770
1199
  static get identifiersFields() {
771
1200
  return ['id'];
772
1201
  }
@@ -780,6 +1209,16 @@ __decorate([
780
1209
  __metadata("design:type", Array)
781
1210
  ], Category.prototype, "filters", void 0);
782
1211
 
1212
+ class CategoryCollectionChildren extends BaseModel {
1213
+ static get identifiersFields() {
1214
+ return ['collectionId', 'categoryId'];
1215
+ }
1216
+ }
1217
+ __decorate([
1218
+ Type(() => CategoryCollectionChildren),
1219
+ __metadata("design:type", CategoryCollectionChildren)
1220
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
1221
+
783
1222
  class CategoryFilter extends BaseModel {
784
1223
  static get identifiersFields() {
785
1224
  return ['id'];
@@ -806,9 +1245,6 @@ var Shops;
806
1245
  })(Shops || (Shops = {}));
807
1246
 
808
1247
  class FilterOption extends BaseModel {
809
- identifierFields() {
810
- return ['id'];
811
- }
812
1248
  static get identifiersFields() {
813
1249
  return ['id'];
814
1250
  }
@@ -833,9 +1269,6 @@ class Product extends BaseModel {
833
1269
  this.reviewsTotal = evaluation.count || this.reviewsTotal;
834
1270
  this.rate = evaluation.rating || this.rate;
835
1271
  }
836
- identifierFields() {
837
- return ['id'];
838
- }
839
1272
  static get identifiersFields() {
840
1273
  return ['id'];
841
1274
  }
@@ -851,7 +1284,7 @@ __decorate([
851
1284
 
852
1285
  class KitProduct extends BaseModel {
853
1286
  static get identifiersFields() {
854
- return ['productId', 'kitProducId'];
1287
+ return ['productId', 'kitProductId'];
855
1288
  }
856
1289
  }
857
1290
  __decorate([
@@ -864,9 +1297,6 @@ __decorate([
864
1297
  ], KitProduct.prototype, "product", void 0);
865
1298
 
866
1299
  class Variant extends BaseModel {
867
- identifierFields() {
868
- return ['id'];
869
- }
870
1300
  static get identifiersFields() {
871
1301
  return ['id', 'productId'];
872
1302
  }
@@ -917,12 +1347,12 @@ __decorate([
917
1347
  __metadata("design:type", User)
918
1348
  ], Checkout.prototype, "user", void 0);
919
1349
  __decorate([
920
- Type(() => Address),
921
- __metadata("design:type", Address)
1350
+ Type(() => UserAddress),
1351
+ __metadata("design:type", UserAddress)
922
1352
  ], Checkout.prototype, "shippingAddress", void 0);
923
1353
  __decorate([
924
- Type(() => Address),
925
- __metadata("design:type", Address)
1354
+ Type(() => UserAddress),
1355
+ __metadata("design:type", UserAddress)
926
1356
  ], Checkout.prototype, "billingAddress", void 0);
927
1357
  __decorate([
928
1358
  Type(() => ShippingMethod),
@@ -958,12 +1388,12 @@ class CheckoutSubscription extends BaseModel {
958
1388
  }
959
1389
  }
960
1390
  __decorate([
961
- Type(() => Address),
962
- __metadata("design:type", Address)
1391
+ Type(() => UserAddress),
1392
+ __metadata("design:type", UserAddress)
963
1393
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
964
1394
  __decorate([
965
- Type(() => Address),
966
- __metadata("design:type", Address)
1395
+ Type(() => UserAddress),
1396
+ __metadata("design:type", UserAddress)
967
1397
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
968
1398
  __decorate([
969
1399
  Type(() => SubscriptionPlan),
@@ -974,6 +1404,20 @@ __decorate([
974
1404
  __metadata("design:type", Coupon)
975
1405
  ], CheckoutSubscription.prototype, "coupon", void 0);
976
1406
 
1407
+ class RoundProductPricesHelper {
1408
+ static roundProductPrices(product) {
1409
+ product.price.price = Number(product.price.price.toFixed(2));
1410
+ product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
1411
+ if (product.price.subscriberPrice) {
1412
+ product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1413
+ }
1414
+ if (product instanceof LineItem && product.pricePaid) {
1415
+ product.pricePaid = Number(product.pricePaid.toFixed(2));
1416
+ }
1417
+ return product;
1418
+ }
1419
+ }
1420
+
977
1421
  var FilterType;
978
1422
  (function (FilterType) {
979
1423
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1488,7 +1932,7 @@ const withFindFirestore = (MixinBase) => {
1488
1932
  const queries = [];
1489
1933
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
1490
1934
  if (this.model.isModel(limits.offset))
1491
- queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[(_a = limits.offset.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]))));
1935
+ queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
1492
1936
  else if (isNumber(limits.offset) || isString(limits.offset))
1493
1937
  queries.push(startAt(limits.offset));
1494
1938
  }
@@ -1524,7 +1968,7 @@ const withCreateFirestore = (MixinBase) => {
1524
1968
  save(data) {
1525
1969
  var _a, _b;
1526
1970
  return __awaiter(this, void 0, void 0, function* () {
1527
- const id = (_b = data.identifier[(_a = data.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]) === null || _b === void 0 ? void 0 : _b.toString();
1971
+ const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
1528
1972
  const collectionPath = this.buildCollectionPathForAdd(data);
1529
1973
  const collection = this.collection(collectionPath);
1530
1974
  if (isEmpty(id))
@@ -1834,6 +2278,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1834
2278
  return is(products);
1835
2279
  });
1836
2280
  }
2281
+ getCategoryByShop(shop) {
2282
+ return;
2283
+ }
1837
2284
  }
1838
2285
 
1839
2286
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
@@ -2325,11 +2772,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2325
2772
  }, {});
2326
2773
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2327
2774
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2328
- if (!Array.isArray(options) &&
2775
+ const isNestedField = !Array.isArray(options) &&
2329
2776
  isObject(options) &&
2330
2777
  isNil(options === null || options === void 0 ? void 0 : options.operator) &&
2331
2778
  isNil(options === null || options === void 0 ? void 0 : options.value) &&
2332
- isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
2779
+ isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
2780
+ if (isNestedField)
2333
2781
  return Object.keys(options).reduce((variables, key) => {
2334
2782
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2335
2783
  const columnName = fieldOptions.columnName;
@@ -2340,7 +2788,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2340
2788
  return {
2341
2789
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2342
2790
  };
2343
- if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2791
+ if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2344
2792
  options = Object.values(options)[0];
2345
2793
  return Array.isArray(options)
2346
2794
  ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
@@ -2372,28 +2820,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2372
2820
  if (field === 'affected_rows')
2373
2821
  return field;
2374
2822
  const fieldName = Object.keys(field).shift();
2375
- const fieldValue = field[fieldName];
2823
+ const fieldValue = is(field[fieldName]);
2376
2824
  if (Array.isArray(fieldValue))
2377
2825
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2378
2826
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2379
- return null;
2380
- if (fieldValue.fields)
2381
- return !fieldValue.filters
2382
- ? {
2383
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2384
- }
2385
- : {
2386
- operation: fieldValue.columnName || fieldName,
2387
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2388
- variables: {
2389
- [`${fieldValue.columnName}_where`]: {
2390
- name: 'where',
2391
- type: fieldValue.filters.filterType,
2392
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2393
- required: true,
2394
- },
2395
- },
2396
- };
2827
+ return;
2828
+ const isNestedField = !!fieldValue.fields;
2829
+ if (isNestedField)
2830
+ return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2397
2831
  return fieldValue.columnName;
2398
2832
  }).filter((field) => !!field);
2399
2833
  };
@@ -2456,6 +2890,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2456
2890
  return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
2457
2891
  }, {});
2458
2892
  };
2893
+ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2894
+ const hasCustomFilters = !!fieldValue.filters;
2895
+ if (hasCustomFilters)
2896
+ return {
2897
+ operation: fieldValue.columnName || fieldName,
2898
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2899
+ variables: {
2900
+ [`${fieldValue.columnName}_where`]: {
2901
+ name: 'where',
2902
+ type: fieldValue.filters.filterType,
2903
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2904
+ required: true,
2905
+ },
2906
+ },
2907
+ };
2908
+ return {
2909
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2910
+ };
2911
+ };
2459
2912
 
2460
2913
  const withCreateHasuraGraphQL = (MixinBase) => {
2461
2914
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -2467,6 +2920,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2467
2920
  }
2468
2921
  create(data) {
2469
2922
  return __awaiter(this, void 0, void 0, function* () {
2923
+ this.logger = DebugHelper.from(this, 'create');
2470
2924
  const newData = yield this.save(this.model.toInstance(data));
2471
2925
  return this.model.toInstance(newData);
2472
2926
  });
@@ -2483,8 +2937,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2483
2937
  {
2484
2938
  [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
2485
2939
  var _a;
2486
- return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
2487
- foreignKeyField;
2940
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
2488
2941
  }),
2489
2942
  },
2490
2943
  ]);
@@ -2509,9 +2962,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
2509
2962
  }
2510
2963
  delete(identifiers) {
2511
2964
  return __awaiter(this, void 0, void 0, function* () {
2965
+ this.logger = DebugHelper.from(this, 'delete');
2512
2966
  const instance = this.model.toInstance(identifiers);
2513
2967
  yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
2514
- if (isNil(instance[identifier]))
2968
+ const identifierBinded = identifier;
2969
+ if (isNil(instance.identifier[identifierBinded]))
2515
2970
  return ids;
2516
2971
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2517
2972
  const value = columnOption.to(identifiers[identifier], instance);
@@ -2536,6 +2991,7 @@ const withHasuraGraphQL = (MixinBase) => {
2536
2991
  this.authOptions = options.authOptions;
2537
2992
  this.model = options.model;
2538
2993
  this.fields = options.fields || this.model.identifiersFields;
2994
+ this.logger = DebugHelper.from(this);
2539
2995
  }
2540
2996
  get headers() {
2541
2997
  var _a, _b, _c, _d, _e, _f, _g;
@@ -2559,7 +3015,11 @@ const withHasuraGraphQL = (MixinBase) => {
2559
3015
  query(operation, fields, variables) {
2560
3016
  var _a, _b, _c, _d;
2561
3017
  return __awaiter(this, void 0, void 0, function* () {
2562
- const builded = this.buildHasuraQueryFields({ operation, fields, variables });
3018
+ const builded = this.buildHasuraQueryFields({
3019
+ operation,
3020
+ fields: fields,
3021
+ variables,
3022
+ });
2563
3023
  const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
2564
3024
  const resultQuery = query$1(interpected);
2565
3025
  const result = yield this.fetch(resultQuery);
@@ -2568,6 +3028,7 @@ const withHasuraGraphQL = (MixinBase) => {
2568
3028
  }
2569
3029
  fetch(params) {
2570
3030
  return __awaiter(this, void 0, void 0, function* () {
3031
+ this.logger.with('params').log(params);
2571
3032
  const headers = this.headers;
2572
3033
  const { data: result } = yield axios({
2573
3034
  url: `${this.endpoint}`,
@@ -2577,6 +3038,7 @@ const withHasuraGraphQL = (MixinBase) => {
2577
3038
  });
2578
3039
  if (!isNil(result.errors))
2579
3040
  throw new Error(JSON.stringify(result.errors));
3041
+ this.logger.with('returns').log(result);
2580
3042
  return result.data;
2581
3043
  });
2582
3044
  }
@@ -2603,8 +3065,8 @@ const withHasuraGraphQL = (MixinBase) => {
2603
3065
  return value;
2604
3066
  return date;
2605
3067
  }
2606
- convertDataFromHasura(data) {
2607
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3068
+ convertDataFromHasura(data, fields) {
3069
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2608
3070
  return this.model.toInstance(plain);
2609
3071
  }
2610
3072
  convertDataToHasura(instance, update = false) {
@@ -2646,6 +3108,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2646
3108
  }
2647
3109
  update(data) {
2648
3110
  return __awaiter(this, void 0, void 0, function* () {
3111
+ this.logger = DebugHelper.from(this, 'update');
2649
3112
  const plainData = this.paramsToPlain(data);
2650
3113
  yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
2651
3114
  _set: {
@@ -2670,10 +3133,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2670
3133
  const instance = this.model.toInstance(data);
2671
3134
  return this.model.identifiersFields.reduce((ids, identifier) => {
2672
3135
  var _a;
2673
- if (isNil(instance[identifier]))
3136
+ const identifierBinded = identifier;
3137
+ if (isNil(instance.identifier[identifierBinded]))
2674
3138
  return ids;
2675
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2676
- const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier], instance)) || data[columnOption.attributeName];
3139
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3140
+ 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];
2677
3141
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
2678
3142
  }, {});
2679
3143
  }
@@ -2689,10 +3153,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
2689
3153
  }
2690
3154
  get(identifiers) {
2691
3155
  return __awaiter(this, void 0, void 0, function* () {
3156
+ this.logger = DebugHelper.from(this, 'get');
2692
3157
  const instance = this.model.toInstance(identifiers);
2693
3158
  const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
2694
3159
  var _a;
2695
- if (isNil(instance[identifier]))
3160
+ const identifierBinded = identifier;
3161
+ if (isNil(instance[identifierBinded]))
2696
3162
  return ids;
2697
3163
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2698
3164
  const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
@@ -2714,12 +3180,26 @@ const withGetHasuraGraphQL = (MixinBase) => {
2714
3180
 
2715
3181
  const withFindHasuraGraphQL = (MixinBase) => {
2716
3182
  return class FindHasuraGraphQLMixin extends MixinBase {
3183
+ constructor() {
3184
+ super(...arguments);
3185
+ this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
3186
+ .columnName]: orderBy[current] })), {});
3187
+ }
2717
3188
  find(params) {
2718
3189
  var _a;
2719
3190
  return __awaiter(this, void 0, void 0, function* () {
3191
+ this.logger = DebugHelper.from(this, 'find');
2720
3192
  const { filters, limits, orderBy, options } = params || {};
2721
3193
  const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
2722
- const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
3194
+ const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
3195
+ ? {}
3196
+ : {
3197
+ order_by: {
3198
+ type: `${this.tableName}_order_by!`,
3199
+ list: true,
3200
+ value: this.bindOrderByAttributes(orderBy, this.fields),
3201
+ },
3202
+ })), (isNil(filters)
2723
3203
  ? {}
2724
3204
  : {
2725
3205
  where: {
@@ -2793,6 +3273,41 @@ class VariantHasuraGraphQL extends Variant {
2793
3273
  }
2794
3274
  }
2795
3275
 
3276
+ class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3277
+ constructor(endpoint, authOptions) {
3278
+ super({
3279
+ tableName: 'category_collection_children',
3280
+ model: CategoryCollectionChildren,
3281
+ endpoint,
3282
+ authOptions,
3283
+ fields: [
3284
+ { collectionId: { columnName: 'collection_id' } },
3285
+ { categoryId: { columnName: 'category_id' } },
3286
+ 'name',
3287
+ 'slug',
3288
+ 'reference',
3289
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3290
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3291
+ {
3292
+ parent: {
3293
+ columnName: 'parent',
3294
+ foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3295
+ fields: [
3296
+ { collectionId: { columnName: 'collection_id' } },
3297
+ { categoryId: { columnName: 'category_id' } },
3298
+ 'name',
3299
+ 'slug',
3300
+ 'reference',
3301
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3302
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3303
+ ],
3304
+ },
3305
+ },
3306
+ ],
3307
+ });
3308
+ }
3309
+ }
3310
+
2796
3311
  class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2797
3312
  constructor({ endpoint, authOptions, interceptors, }) {
2798
3313
  super({
@@ -2862,6 +3377,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2862
3377
  'image',
2863
3378
  'published',
2864
3379
  'shop',
3380
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
2865
3381
  'slug',
2866
3382
  { brandCategory: { columnName: 'brand_category' } },
2867
3383
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -2973,7 +3489,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2973
3489
  return __awaiter(this, void 0, void 0, function* () {
2974
3490
  if (!slug)
2975
3491
  return null;
2976
- const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
3492
+ const { data } = yield this.find({
3493
+ filters: {
3494
+ slug,
3495
+ shops: { operator: Where.IN, value: [shop] },
3496
+ published: { operator: Where.EQUALS, value: true },
3497
+ },
3498
+ options: {
3499
+ enableCount: false,
3500
+ },
3501
+ });
2977
3502
  if (!data.length)
2978
3503
  throw new NotFoundError(`Category with slug ${slug} not found`);
2979
3504
  if (data.length > 1)
@@ -2981,6 +3506,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2981
3506
  return data.shift();
2982
3507
  });
2983
3508
  }
3509
+ getCategoryByShop(shop) {
3510
+ return __awaiter(this, void 0, void 0, function* () {
3511
+ if (!shop)
3512
+ return;
3513
+ const { data } = yield this.find({
3514
+ filters: {
3515
+ shops: { operator: Where.IN, value: [shop] },
3516
+ published: { operator: Where.EQUALS, value: true },
3517
+ },
3518
+ options: {
3519
+ enableCount: false,
3520
+ },
3521
+ });
3522
+ return data;
3523
+ });
3524
+ }
2984
3525
  getCategoriesForHome(categoryIds, limit = 4, gender) {
2985
3526
  return __awaiter(this, void 0, void 0, function* () {
2986
3527
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
@@ -3561,6 +4102,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3561
4102
  },
3562
4103
  });
3563
4104
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
4105
+ RoundProductPricesHelper.roundProductPrices(product);
3564
4106
  return product;
3565
4107
  });
3566
4108
  }
@@ -3916,5 +4458,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3916
4458
  * Generated bundle index. Do not edit.
3917
4459
  */
3918
4460
 
3919
- 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, 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, 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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4461
+ 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, get, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3920
4462
  //# sourceMappingURL=infrab4a-connect.mjs.map