@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 } 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, [field]: this[field] }), {});
19
+ const data = this;
20
+ return fields.reduce((object, field) => ({ ...object, [field]: data[field] }), {});
18
21
  }
19
22
  get identifiersFields() {
20
23
  return this.constructor.identifiersFields;
@@ -460,11 +463,437 @@ __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');
665
+ }
666
+ }
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();
466
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({ 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
+ };
467
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
+ };
468
897
 
469
898
  const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
470
899
 
@@ -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'];
@@ -666,7 +1101,7 @@ class Authentication {
666
1101
  async signIn({ email, password }, signInMethod) {
667
1102
  const method = this.getServiceByMethod(signInMethod);
668
1103
  const userAuth = await this.authService[method]({ email, password });
669
- const user = this.userRepository.get(userAuth);
1104
+ const user = this.userRepository.get({ id: userAuth.id });
670
1105
  if (!isNil(user))
671
1106
  return user;
672
1107
  if (/^.+@b4a.com.br$/.test(userAuth.email))
@@ -760,18 +1195,12 @@ class RecoveryPassword {
760
1195
  }
761
1196
 
762
1197
  class Filter extends BaseModel {
763
- identifierFields() {
764
- return ['id'];
765
- }
766
1198
  static get identifiersFields() {
767
1199
  return ['id'];
768
1200
  }
769
1201
  }
770
1202
 
771
1203
  class Category extends BaseModel {
772
- identifierFields() {
773
- return ['id'];
774
- }
775
1204
  static get identifiersFields() {
776
1205
  return ['id'];
777
1206
  }
@@ -785,6 +1214,16 @@ __decorate([
785
1214
  __metadata("design:type", Array)
786
1215
  ], Category.prototype, "filters", void 0);
787
1216
 
1217
+ class CategoryCollectionChildren extends BaseModel {
1218
+ static get identifiersFields() {
1219
+ return ['collectionId', 'categoryId'];
1220
+ }
1221
+ }
1222
+ __decorate([
1223
+ Type(() => CategoryCollectionChildren),
1224
+ __metadata("design:type", CategoryCollectionChildren)
1225
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
1226
+
788
1227
  class CategoryFilter extends BaseModel {
789
1228
  static get identifiersFields() {
790
1229
  return ['id'];
@@ -811,9 +1250,6 @@ var Shops;
811
1250
  })(Shops || (Shops = {}));
812
1251
 
813
1252
  class FilterOption extends BaseModel {
814
- identifierFields() {
815
- return ['id'];
816
- }
817
1253
  static get identifiersFields() {
818
1254
  return ['id'];
819
1255
  }
@@ -838,9 +1274,6 @@ class Product extends BaseModel {
838
1274
  this.reviewsTotal = evaluation.count || this.reviewsTotal;
839
1275
  this.rate = evaluation.rating || this.rate;
840
1276
  }
841
- identifierFields() {
842
- return ['id'];
843
- }
844
1277
  static get identifiersFields() {
845
1278
  return ['id'];
846
1279
  }
@@ -856,7 +1289,7 @@ __decorate([
856
1289
 
857
1290
  class KitProduct extends BaseModel {
858
1291
  static get identifiersFields() {
859
- return ['productId', 'kitProducId'];
1292
+ return ['productId', 'kitProductId'];
860
1293
  }
861
1294
  }
862
1295
  __decorate([
@@ -869,9 +1302,6 @@ __decorate([
869
1302
  ], KitProduct.prototype, "product", void 0);
870
1303
 
871
1304
  class Variant extends BaseModel {
872
- identifierFields() {
873
- return ['id'];
874
- }
875
1305
  static get identifiersFields() {
876
1306
  return ['id', 'productId'];
877
1307
  }
@@ -922,12 +1352,12 @@ __decorate([
922
1352
  __metadata("design:type", User)
923
1353
  ], Checkout.prototype, "user", void 0);
924
1354
  __decorate([
925
- Type(() => Address),
926
- __metadata("design:type", Address)
1355
+ Type(() => UserAddress),
1356
+ __metadata("design:type", UserAddress)
927
1357
  ], Checkout.prototype, "shippingAddress", void 0);
928
1358
  __decorate([
929
- Type(() => Address),
930
- __metadata("design:type", Address)
1359
+ Type(() => UserAddress),
1360
+ __metadata("design:type", UserAddress)
931
1361
  ], Checkout.prototype, "billingAddress", void 0);
932
1362
  __decorate([
933
1363
  Type(() => ShippingMethod),
@@ -963,12 +1393,12 @@ class CheckoutSubscription extends BaseModel {
963
1393
  }
964
1394
  }
965
1395
  __decorate([
966
- Type(() => Address),
967
- __metadata("design:type", Address)
1396
+ Type(() => UserAddress),
1397
+ __metadata("design:type", UserAddress)
968
1398
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
969
1399
  __decorate([
970
- Type(() => Address),
971
- __metadata("design:type", Address)
1400
+ Type(() => UserAddress),
1401
+ __metadata("design:type", UserAddress)
972
1402
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
973
1403
  __decorate([
974
1404
  Type(() => SubscriptionPlan),
@@ -979,6 +1409,20 @@ __decorate([
979
1409
  __metadata("design:type", Coupon)
980
1410
  ], CheckoutSubscription.prototype, "coupon", void 0);
981
1411
 
1412
+ class RoundProductPricesHelper {
1413
+ static roundProductPrices(product) {
1414
+ product.price.price = Number(product.price.price.toFixed(2));
1415
+ product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
1416
+ if (product.price.subscriberPrice) {
1417
+ product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1418
+ }
1419
+ if (product instanceof LineItem && product.pricePaid) {
1420
+ product.pricePaid = Number(product.pricePaid.toFixed(2));
1421
+ }
1422
+ return product;
1423
+ }
1424
+ }
1425
+
982
1426
  var FilterType;
983
1427
  (function (FilterType) {
984
1428
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1471,7 +1915,7 @@ const withFindFirestore = (MixinBase) => {
1471
1915
  const queries = [];
1472
1916
  if (limits?.offset) {
1473
1917
  if (this.model.isModel(limits.offset))
1474
- queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[limits.offset.identifiersFields?.shift()]))));
1918
+ queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), Object.values(limits.offset.identifier).shift()?.toString()))));
1475
1919
  else if (isNumber(limits.offset) || isString(limits.offset))
1476
1920
  queries.push(startAt(limits.offset));
1477
1921
  }
@@ -1501,7 +1945,7 @@ const withCreateFirestore = (MixinBase) => {
1501
1945
  return docBuilded;
1502
1946
  }
1503
1947
  async save(data) {
1504
- const id = data.identifier[data.identifiersFields?.shift()]?.toString();
1948
+ const id = Object.values(data.identifier)?.shift()?.toString();
1505
1949
  const collectionPath = this.buildCollectionPathForAdd(data);
1506
1950
  const collection = this.collection(collectionPath);
1507
1951
  if (isEmpty(id))
@@ -1785,6 +2229,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1785
2229
  }
1786
2230
  return is(products);
1787
2231
  }
2232
+ getCategoryByShop(shop) {
2233
+ return;
2234
+ }
1788
2235
  }
1789
2236
 
1790
2237
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
@@ -2263,11 +2710,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2263
2710
  }, {});
2264
2711
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2265
2712
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2266
- if (!Array.isArray(options) &&
2713
+ const isNestedField = !Array.isArray(options) &&
2267
2714
  isObject(options) &&
2268
2715
  isNil(options?.operator) &&
2269
2716
  isNil(options?.value) &&
2270
- isNil(fieldSentenceOptions?.to))
2717
+ isNil(fieldSentenceOptions?.to);
2718
+ if (isNestedField)
2271
2719
  return Object.keys(options).reduce((variables, key) => {
2272
2720
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fieldSentenceOptions?.fields || fields);
2273
2721
  const columnName = fieldOptions.columnName;
@@ -2281,7 +2729,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2281
2729
  return {
2282
2730
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2283
2731
  };
2284
- if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2732
+ if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2285
2733
  options = Object.values(options)[0];
2286
2734
  return Array.isArray(options)
2287
2735
  ? options.reduce((whereSentence, option) => ({
@@ -2317,28 +2765,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2317
2765
  if (field === 'affected_rows')
2318
2766
  return field;
2319
2767
  const fieldName = Object.keys(field).shift();
2320
- const fieldValue = field[fieldName];
2768
+ const fieldValue = is(field[fieldName]);
2321
2769
  if (Array.isArray(fieldValue))
2322
2770
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2323
2771
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2324
- return null;
2325
- if (fieldValue.fields)
2326
- return !fieldValue.filters
2327
- ? {
2328
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2329
- }
2330
- : {
2331
- operation: fieldValue.columnName || fieldName,
2332
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2333
- variables: {
2334
- [`${fieldValue.columnName}_where`]: {
2335
- name: 'where',
2336
- type: fieldValue.filters.filterType,
2337
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2338
- required: true,
2339
- },
2340
- },
2341
- };
2772
+ return;
2773
+ const isNestedField = !!fieldValue.fields;
2774
+ if (isNestedField)
2775
+ return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2342
2776
  return fieldValue.columnName;
2343
2777
  })
2344
2778
  .filter((field) => !!field);
@@ -2421,6 +2855,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2421
2855
  return { ...result, [columnName]: data[attributeName] };
2422
2856
  }, {});
2423
2857
  };
2858
+ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2859
+ const hasCustomFilters = !!fieldValue.filters;
2860
+ if (hasCustomFilters)
2861
+ return {
2862
+ operation: fieldValue.columnName || fieldName,
2863
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2864
+ variables: {
2865
+ [`${fieldValue.columnName}_where`]: {
2866
+ name: 'where',
2867
+ type: fieldValue.filters.filterType,
2868
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2869
+ required: true,
2870
+ },
2871
+ },
2872
+ };
2873
+ return {
2874
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2875
+ };
2876
+ };
2424
2877
 
2425
2878
  const withCreateHasuraGraphQL = (MixinBase) => {
2426
2879
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -2431,6 +2884,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2431
2884
  this.insertGraphQLObjectType = options?.insertGraphQLObjectType || `${this.tableName}_insert_input`;
2432
2885
  }
2433
2886
  async create(data) {
2887
+ this.logger = DebugHelper.from(this, 'create');
2434
2888
  const newData = await this.save(this.model.toInstance(data));
2435
2889
  return this.model.toInstance(newData);
2436
2890
  }
@@ -2443,8 +2897,8 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2443
2897
  columnOptions.foreignKeyColumn && [
2444
2898
  ...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)?.columnName),
2445
2899
  {
2446
- [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)?.columnName ||
2447
- foreignKeyField),
2900
+ [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
2901
+ ?.columnName || foreignKeyField),
2448
2902
  },
2449
2903
  ]);
2450
2904
  })
@@ -2466,9 +2920,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
2466
2920
  this.deleteGraphQLOperation = options?.deleteGraphQLOperation || `delete_${this.tableName}_by_pk`;
2467
2921
  }
2468
2922
  async delete(identifiers) {
2923
+ this.logger = DebugHelper.from(this, 'delete');
2469
2924
  const instance = this.model.toInstance(identifiers);
2470
2925
  await this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
2471
- if (isNil(instance[identifier]))
2926
+ const identifierBinded = identifier;
2927
+ if (isNil(instance.identifier[identifierBinded]))
2472
2928
  return ids;
2473
2929
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2474
2930
  const value = columnOption.to(identifiers[identifier], instance);
@@ -2495,6 +2951,7 @@ const withHasuraGraphQL = (MixinBase) => {
2495
2951
  this.authOptions = options.authOptions;
2496
2952
  this.model = options.model;
2497
2953
  this.fields = options.fields || this.model.identifiersFields;
2954
+ this.logger = DebugHelper.from(this);
2498
2955
  }
2499
2956
  get headers() {
2500
2957
  return {
@@ -2518,13 +2975,18 @@ const withHasuraGraphQL = (MixinBase) => {
2518
2975
  return this.fetch(resultQuery);
2519
2976
  }
2520
2977
  async query(operation, fields, variables) {
2521
- const builded = this.buildHasuraQueryFields({ operation, fields, variables });
2978
+ const builded = this.buildHasuraQueryFields({
2979
+ operation,
2980
+ fields: fields,
2981
+ variables,
2982
+ });
2522
2983
  const interpected = (await this.interceptors?.request?.(builded)) || builded;
2523
2984
  const resultQuery = query$1(interpected);
2524
2985
  const result = await this.fetch(resultQuery);
2525
2986
  return (await this.interceptors?.response?.(result, interpected)) || result;
2526
2987
  }
2527
2988
  async fetch(params) {
2989
+ this.logger.with('params').log(params);
2528
2990
  const headers = this.headers;
2529
2991
  const { data: result } = await axios({
2530
2992
  url: `${this.endpoint}`,
@@ -2534,6 +2996,7 @@ const withHasuraGraphQL = (MixinBase) => {
2534
2996
  });
2535
2997
  if (!isNil(result.errors))
2536
2998
  throw new Error(JSON.stringify(result.errors));
2999
+ this.logger.with('returns').log(result);
2537
3000
  return result.data;
2538
3001
  }
2539
3002
  getAttributeGraphQLTypeOf(value) {
@@ -2559,8 +3022,8 @@ const withHasuraGraphQL = (MixinBase) => {
2559
3022
  return value;
2560
3023
  return date;
2561
3024
  }
2562
- convertDataFromHasura(data) {
2563
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3025
+ convertDataFromHasura(data, fields) {
3026
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2564
3027
  return this.model.toInstance(plain);
2565
3028
  }
2566
3029
  convertDataToHasura(instance, update = false) {
@@ -2601,6 +3064,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2601
3064
  this.updateGraphQLPKType = options?.updateGraphQLPKType || `${this.tableName}_pk_columns_input`;
2602
3065
  }
2603
3066
  async update(data) {
3067
+ this.logger = DebugHelper.from(this, 'update');
2604
3068
  const plainData = this.paramsToPlain(data);
2605
3069
  await this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
2606
3070
  _set: {
@@ -2626,10 +3090,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2626
3090
  getUpdateModelKeys(data) {
2627
3091
  const instance = this.model.toInstance(data);
2628
3092
  return this.model.identifiersFields.reduce((ids, identifier) => {
2629
- if (isNil(instance[identifier]))
3093
+ const identifierBinded = identifier;
3094
+ if (isNil(instance.identifier[identifierBinded]))
2630
3095
  return ids;
2631
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2632
- const value = columnOption?.to?.(data[identifier], instance) || data[columnOption.attributeName];
3096
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3097
+ const value = columnOption?.to?.(data[identifierBinded], instance) || data[columnOption.attributeName];
2633
3098
  return {
2634
3099
  ...ids,
2635
3100
  [columnOption.columnName]: value,
@@ -2647,9 +3112,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
2647
3112
  this.getGraphQLOperation = options?.getGraphQLOperation || `${this.tableName}_by_pk`;
2648
3113
  }
2649
3114
  async get(identifiers) {
3115
+ this.logger = DebugHelper.from(this, 'get');
2650
3116
  const instance = this.model.toInstance(identifiers);
2651
3117
  const result = await this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
2652
- if (isNil(instance[identifier]))
3118
+ const identifierBinded = identifier;
3119
+ if (isNil(instance[identifierBinded]))
2653
3120
  return ids;
2654
3121
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2655
3122
  const value = columnOption?.to?.(identifiers[identifier], instance) ||
@@ -2673,11 +3140,28 @@ const withGetHasuraGraphQL = (MixinBase) => {
2673
3140
 
2674
3141
  const withFindHasuraGraphQL = (MixinBase) => {
2675
3142
  return class FindHasuraGraphQLMixin extends MixinBase {
3143
+ constructor() {
3144
+ super(...arguments);
3145
+ this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => ({
3146
+ ...acc,
3147
+ [AttributeOptionHelper.FindByAttribute(current, fields)
3148
+ .columnName]: orderBy[current],
3149
+ }), {});
3150
+ }
2676
3151
  async find(params) {
3152
+ this.logger = DebugHelper.from(this, 'find');
2677
3153
  const { filters, limits, orderBy, options } = params || {};
2678
3154
  const enableCount = options?.enableCount ?? true;
2679
3155
  const variablesCount = {
2680
- ...(isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } }),
3156
+ ...(isNil(orderBy)
3157
+ ? {}
3158
+ : {
3159
+ order_by: {
3160
+ type: `${this.tableName}_order_by!`,
3161
+ list: true,
3162
+ value: this.bindOrderByAttributes(orderBy, this.fields),
3163
+ },
3164
+ }),
2681
3165
  ...(isNil(filters)
2682
3166
  ? {}
2683
3167
  : {
@@ -2753,6 +3237,41 @@ class VariantHasuraGraphQL extends Variant {
2753
3237
  }
2754
3238
  }
2755
3239
 
3240
+ class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3241
+ constructor(endpoint, authOptions) {
3242
+ super({
3243
+ tableName: 'category_collection_children',
3244
+ model: CategoryCollectionChildren,
3245
+ endpoint,
3246
+ authOptions,
3247
+ fields: [
3248
+ { collectionId: { columnName: 'collection_id' } },
3249
+ { categoryId: { columnName: 'category_id' } },
3250
+ 'name',
3251
+ 'slug',
3252
+ 'reference',
3253
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3254
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3255
+ {
3256
+ parent: {
3257
+ columnName: 'parent',
3258
+ foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3259
+ fields: [
3260
+ { collectionId: { columnName: 'collection_id' } },
3261
+ { categoryId: { columnName: 'category_id' } },
3262
+ 'name',
3263
+ 'slug',
3264
+ 'reference',
3265
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3266
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3267
+ ],
3268
+ },
3269
+ },
3270
+ ],
3271
+ });
3272
+ }
3273
+ }
3274
+
2756
3275
  class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2757
3276
  constructor({ endpoint, authOptions, interceptors, }) {
2758
3277
  super({
@@ -2822,6 +3341,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2822
3341
  'image',
2823
3342
  'published',
2824
3343
  'shop',
3344
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
2825
3345
  'slug',
2826
3346
  { brandCategory: { columnName: 'brand_category' } },
2827
3347
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -2919,13 +3439,36 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2919
3439
  async getCategoryBySlug(slug, shop) {
2920
3440
  if (!slug)
2921
3441
  return null;
2922
- const { data } = await this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
3442
+ const { data } = await this.find({
3443
+ filters: {
3444
+ slug,
3445
+ shops: { operator: Where.IN, value: [shop] },
3446
+ published: { operator: Where.EQUALS, value: true },
3447
+ },
3448
+ options: {
3449
+ enableCount: false,
3450
+ },
3451
+ });
2923
3452
  if (!data.length)
2924
3453
  throw new NotFoundError(`Category with slug ${slug} not found`);
2925
3454
  if (data.length > 1)
2926
3455
  throw new DuplicatedResultsError('Query returned duplicated values');
2927
3456
  return data.shift();
2928
3457
  }
3458
+ async getCategoryByShop(shop) {
3459
+ if (!shop)
3460
+ return;
3461
+ const { data } = await this.find({
3462
+ filters: {
3463
+ shops: { operator: Where.IN, value: [shop] },
3464
+ published: { operator: Where.EQUALS, value: true },
3465
+ },
3466
+ options: {
3467
+ enableCount: false,
3468
+ },
3469
+ });
3470
+ return data;
3471
+ }
2929
3472
  async getCategoriesForHome(categoryIds, limit = 4, gender) {
2930
3473
  if (!categoryIds?.length)
2931
3474
  return [];
@@ -3504,6 +4047,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3504
4047
  },
3505
4048
  });
3506
4049
  const product = result?.data?.shift();
4050
+ RoundProductPricesHelper.roundProductPrices(product);
3507
4051
  return product;
3508
4052
  }
3509
4053
  async update(params) {
@@ -3835,5 +4379,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3835
4379
  * Generated bundle index. Do not edit.
3836
4380
  */
3837
4381
 
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, 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 };
4382
+ 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 };
3839
4383
  //# sourceMappingURL=infrab4a-connect.mjs.map