@infrab4a/connect 3.13.3-beta.2 → 3.13.5

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