@infrab4a/connect 4.0.0-beta.18 → 4.0.0-beta.2
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.
- package/domain/catalog/models/category.d.ts +2 -3
- package/domain/catalog/models/index.d.ts +0 -3
- package/domain/catalog/models/product.d.ts +0 -1
- package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
- package/domain/catalog/models/types/index.d.ts +1 -0
- package/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/domain/catalog/repositories/index.d.ts +0 -3
- package/domain/catalog/repositories/product.repository.d.ts +0 -1
- package/domain/generic/repository/find.repository.d.ts +0 -3
- package/domain/shop-settings/models/index.d.ts +0 -1
- package/domain/shop-settings/models/types/index.d.ts +1 -6
- package/domain/shop-settings/repositories/index.d.ts +0 -1
- package/domain/shopping/models/buy-2-win.d.ts +1 -3
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/esm2020/domain/catalog/models/category.mjs +1 -8
- package/esm2020/domain/catalog/models/index.mjs +1 -4
- package/esm2020/domain/catalog/models/product.mjs +1 -1
- package/esm2020/domain/catalog/models/types/category-filter.type.mjs +2 -0
- package/esm2020/domain/catalog/models/types/index.mjs +2 -1
- package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
- package/esm2020/domain/catalog/repositories/index.mjs +1 -4
- package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
- package/esm2020/domain/shop-settings/models/index.mjs +1 -2
- package/esm2020/domain/shop-settings/models/types/index.mjs +2 -7
- package/esm2020/domain/shop-settings/repositories/index.mjs +1 -2
- package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
- package/esm2020/domain/shopping/models/index.mjs +5 -6
- package/esm2020/domain/shopping/repositories/index.mjs +3 -5
- package/esm2020/domain/users/models/subscription/edition.mjs +1 -1
- package/esm2020/domain/users/models/subscription/payment.mjs +1 -1
- package/esm2020/domain/users/models/user-payment-method.mjs +1 -1
- package/esm2020/infra/elasticsearch/indexes/products-index.mjs +1 -2
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +3 -7
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +2 -6
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +6 -9
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +3 -11
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +3 -9
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +3 -5
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +4 -7
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +8 -12
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +6 -11
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +1 -2
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +4 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +4 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +9 -11
- package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +6 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +8 -10
- package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/index.mjs +3 -4
- package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +2 -2
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +2 -5
- package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +12 -16
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +17 -23
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +12 -95
- package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +1 -4
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +5 -23
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +7 -8
- package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
- package/esm2020/utils/index.mjs +3 -2
- package/fesm2015/infrab4a-connect.mjs +225 -692
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +225 -671
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -2
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +4 -13
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -6
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +5 -5
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -1
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +4 -3
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +0 -2
- package/infra/firebase/firestore/types/index.d.ts +2 -3
- package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +9 -4
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +3 -14
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +5 -9
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -3
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -4
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +2 -1
- package/utils/index.d.ts +21 -1
- package/domain/catalog/models/category-filter.d.ts +0 -11
- package/domain/catalog/models/filter-option.d.ts +0 -10
- package/domain/catalog/models/filter.d.ts +0 -13
- package/domain/catalog/repositories/category-filter.repository.d.ts +0 -5
- package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
- package/domain/catalog/repositories/filter.repository.d.ts +0 -4
- package/domain/shop-settings/models/shop-settings.d.ts +0 -9
- package/domain/shop-settings/models/types/shop-banner.type.d.ts +0 -12
- package/domain/shop-settings/models/types/shop-brands.type.d.ts +0 -10
- package/domain/shop-settings/models/types/shop-carousel.type.d.ts +0 -5
- package/domain/shop-settings/models/types/shop-collection.type.d.ts +0 -9
- package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -9
- package/domain/shop-settings/repositories/shop-settings.repository.d.ts +0 -4
- package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
- package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
- package/esm2020/domain/catalog/models/category-filter.mjs +0 -14
- package/esm2020/domain/catalog/models/filter-option.mjs +0 -10
- package/esm2020/domain/catalog/models/filter.mjs +0 -10
- package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +0 -2
- package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +0 -2
- package/esm2020/domain/catalog/repositories/filter.repository.mjs +0 -2
- package/esm2020/domain/shop-settings/models/shop-settings.mjs +0 -7
- package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +0 -2
- package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +0 -2
- package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +0 -2
- package/esm2020/domain/shopping/models/campaign-dashboard.mjs +0 -7
- package/esm2020/domain/shopping/models/campaign-hashtag.mjs +0 -7
- package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +0 -2
- package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +0 -2
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +0 -14
- package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +0 -2
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +0 -55
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +0 -104
- package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +0 -21
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +0 -7
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +0 -14
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -11
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
|
@@ -3,13 +3,14 @@ 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
|
|
7
|
-
|
|
6
|
+
import * as lodash from 'lodash';
|
|
7
|
+
import { get as get$1, isString as isString$1 } from 'lodash';
|
|
8
8
|
import { CustomError } from 'ts-custom-error';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
11
11
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
12
12
|
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
13
|
+
import fetch from 'node-fetch';
|
|
13
14
|
|
|
14
15
|
class BaseModel {
|
|
15
16
|
get identifier() {
|
|
@@ -472,7 +473,7 @@ function is(value) {
|
|
|
472
473
|
return value;
|
|
473
474
|
}
|
|
474
475
|
|
|
475
|
-
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);
|
|
476
|
+
const isUUID = (value) => isString$1(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);
|
|
476
477
|
|
|
477
478
|
class Base {
|
|
478
479
|
constructor(...args) {
|
|
@@ -481,7 +482,7 @@ class Base {
|
|
|
481
482
|
}
|
|
482
483
|
|
|
483
484
|
const parseDateTime = (value) => {
|
|
484
|
-
if (!isString(value))
|
|
485
|
+
if (!isString$1(value))
|
|
485
486
|
return value;
|
|
486
487
|
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
|
|
487
488
|
!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
|
|
@@ -492,6 +493,8 @@ const parseDateTime = (value) => {
|
|
|
492
493
|
return date;
|
|
493
494
|
};
|
|
494
495
|
|
|
496
|
+
const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
|
|
497
|
+
|
|
495
498
|
var CheckoutTypes;
|
|
496
499
|
(function (CheckoutTypes) {
|
|
497
500
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
@@ -754,15 +757,6 @@ class RecoveryPassword {
|
|
|
754
757
|
}
|
|
755
758
|
}
|
|
756
759
|
|
|
757
|
-
class Filter extends BaseModel {
|
|
758
|
-
identifierFields() {
|
|
759
|
-
return ['id'];
|
|
760
|
-
}
|
|
761
|
-
static get identifiersFields() {
|
|
762
|
-
return ['id'];
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
760
|
class Category extends BaseModel {
|
|
767
761
|
identifierFields() {
|
|
768
762
|
return ['id'];
|
|
@@ -771,20 +765,6 @@ class Category extends BaseModel {
|
|
|
771
765
|
return ['id'];
|
|
772
766
|
}
|
|
773
767
|
}
|
|
774
|
-
__decorate([
|
|
775
|
-
Type(() => Filter),
|
|
776
|
-
__metadata("design:type", Array)
|
|
777
|
-
], Category.prototype, "filters", void 0);
|
|
778
|
-
|
|
779
|
-
class CategoryFilter extends BaseModel {
|
|
780
|
-
static get identifiersFields() {
|
|
781
|
-
return ['id'];
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
__decorate([
|
|
785
|
-
Type(() => Filter),
|
|
786
|
-
__metadata("design:type", Filter)
|
|
787
|
-
], CategoryFilter.prototype, "filter", void 0);
|
|
788
768
|
|
|
789
769
|
var GenderDestination;
|
|
790
770
|
(function (GenderDestination) {
|
|
@@ -801,15 +781,6 @@ var Shops;
|
|
|
801
781
|
Shops["ALL"] = "ALL";
|
|
802
782
|
})(Shops || (Shops = {}));
|
|
803
783
|
|
|
804
|
-
class FilterOption extends BaseModel {
|
|
805
|
-
identifierFields() {
|
|
806
|
-
return ['id'];
|
|
807
|
-
}
|
|
808
|
-
static get identifiersFields() {
|
|
809
|
-
return ['id'];
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
784
|
class Product extends BaseModel {
|
|
814
785
|
identifierFields() {
|
|
815
786
|
return ['id'];
|
|
@@ -846,27 +817,17 @@ class Variant extends BaseModel {
|
|
|
846
817
|
}
|
|
847
818
|
}
|
|
848
819
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
]
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
static get identifiersFields() {
|
|
861
|
-
return ['id'];
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
class CampaignHashtag extends BaseModel {
|
|
866
|
-
static get identifiersFields() {
|
|
867
|
-
return ['id'];
|
|
868
|
-
}
|
|
869
|
-
}
|
|
820
|
+
var OrderStatus;
|
|
821
|
+
(function (OrderStatus) {
|
|
822
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
823
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
824
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
825
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
826
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
827
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
828
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
829
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
830
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
870
831
|
|
|
871
832
|
class LineItem extends Product {
|
|
872
833
|
}
|
|
@@ -907,18 +868,6 @@ __decorate([
|
|
|
907
868
|
__metadata("design:type", Coupon)
|
|
908
869
|
], Checkout.prototype, "coupon", void 0);
|
|
909
870
|
|
|
910
|
-
var OrderStatus;
|
|
911
|
-
(function (OrderStatus) {
|
|
912
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
913
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
914
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
915
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
916
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
917
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
918
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
919
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
920
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
921
|
-
|
|
922
871
|
class Order extends Checkout {
|
|
923
872
|
}
|
|
924
873
|
__decorate([
|
|
@@ -948,6 +897,16 @@ __decorate([
|
|
|
948
897
|
__metadata("design:type", Coupon)
|
|
949
898
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
950
899
|
|
|
900
|
+
class Buy2Win extends BaseModel {
|
|
901
|
+
static get identifiersFields() {
|
|
902
|
+
return ['id'];
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
__decorate([
|
|
906
|
+
Type(() => Category),
|
|
907
|
+
__metadata("design:type", Array)
|
|
908
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
909
|
+
|
|
951
910
|
var FilterType;
|
|
952
911
|
(function (FilterType) {
|
|
953
912
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1047,12 +1006,6 @@ class ShopMenu extends BaseModel {
|
|
|
1047
1006
|
}
|
|
1048
1007
|
}
|
|
1049
1008
|
|
|
1050
|
-
class ShopSettings extends BaseModel {
|
|
1051
|
-
static get identifiersFields() {
|
|
1052
|
-
return ['id'];
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
1009
|
class InvalidArgumentError extends CustomError {
|
|
1057
1010
|
constructor(message) {
|
|
1058
1011
|
super(message);
|
|
@@ -1163,7 +1116,6 @@ class ProductsIndex {
|
|
|
1163
1116
|
'stock',
|
|
1164
1117
|
'weight',
|
|
1165
1118
|
'tags',
|
|
1166
|
-
'filters',
|
|
1167
1119
|
'hasVariants',
|
|
1168
1120
|
'type',
|
|
1169
1121
|
];
|
|
@@ -1254,17 +1206,9 @@ const withFirestore = (MixinBase) => {
|
|
|
1254
1206
|
: bindDate(data[key], key) })), {});
|
|
1255
1207
|
};
|
|
1256
1208
|
return class extends MixinBase {
|
|
1257
|
-
constructor(
|
|
1258
|
-
|
|
1259
|
-
super(...params);
|
|
1260
|
-
this.fields = {};
|
|
1261
|
-
this.interceptors = {};
|
|
1209
|
+
constructor() {
|
|
1210
|
+
super(...arguments);
|
|
1262
1211
|
this.collectionName = '';
|
|
1263
|
-
this.firestore = options.firestore;
|
|
1264
|
-
this.collectionName = options.collectionName;
|
|
1265
|
-
this.model = options.model;
|
|
1266
|
-
this.fields = options.fields;
|
|
1267
|
-
this.interceptors = options.interceptors;
|
|
1268
1212
|
}
|
|
1269
1213
|
collection(path) {
|
|
1270
1214
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
@@ -1311,19 +1255,12 @@ const withHelpers = (MixinBase) => {
|
|
|
1311
1255
|
const withGetFirestore = (MixinBase) => {
|
|
1312
1256
|
return class GetFirestore extends MixinBase {
|
|
1313
1257
|
get(identifiers) {
|
|
1314
|
-
var _a, _b, _c, _d;
|
|
1315
1258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1316
|
-
|
|
1317
|
-
console.log(this.firestore);
|
|
1318
|
-
console.log(this.collection(this.buildCollectionPathForGet(identifiers)));
|
|
1319
|
-
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
1320
|
-
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
1321
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1322
|
-
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1259
|
+
const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
|
|
1323
1260
|
const data = docRef.data();
|
|
1324
1261
|
if (isNil(data))
|
|
1325
1262
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1326
|
-
return
|
|
1263
|
+
return data;
|
|
1327
1264
|
});
|
|
1328
1265
|
}
|
|
1329
1266
|
buildCollectionPathForGet(identifiers) {
|
|
@@ -1402,13 +1339,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1402
1339
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1403
1340
|
};
|
|
1404
1341
|
}
|
|
1405
|
-
find(
|
|
1406
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1342
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1407
1343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1408
|
-
const collection = this.collection(this.buildCollectionPathForFind(
|
|
1409
|
-
const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
|
|
1410
|
-
const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
|
|
1411
|
-
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1344
|
+
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1412
1345
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1413
1346
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1414
1347
|
const offsets = yield this.defineLimits(filters, limits);
|
|
@@ -1416,8 +1349,8 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1416
1349
|
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1417
1350
|
const data = docs.docs.map((doc) => doc.data());
|
|
1418
1351
|
return {
|
|
1419
|
-
data
|
|
1420
|
-
count:
|
|
1352
|
+
data,
|
|
1353
|
+
count: this.calculateCount(data, limits),
|
|
1421
1354
|
};
|
|
1422
1355
|
});
|
|
1423
1356
|
}
|
|
@@ -1429,12 +1362,11 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1429
1362
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1430
1363
|
}
|
|
1431
1364
|
defineLimits(filters, limits) {
|
|
1432
|
-
var _a;
|
|
1433
1365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1434
1366
|
const queries = [];
|
|
1435
1367
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1436
1368
|
if (this.model.isModel(limits.offset))
|
|
1437
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier
|
|
1369
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
1438
1370
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1439
1371
|
queries.push(startAt(limits.offset));
|
|
1440
1372
|
}
|
|
@@ -1456,15 +1388,10 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1456
1388
|
const withCreateFirestore = (MixinBase) => {
|
|
1457
1389
|
return class CreateFirestore extends MixinBase {
|
|
1458
1390
|
create(data) {
|
|
1459
|
-
var _a, _b, _c, _d;
|
|
1460
1391
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1461
|
-
const
|
|
1462
|
-
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
1463
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1464
|
-
const docRef = yield this.save(builded);
|
|
1392
|
+
const docRef = yield this.save(this.model.toInstance(data));
|
|
1465
1393
|
const doc = yield getDoc(docRef);
|
|
1466
|
-
|
|
1467
|
-
return docBuilded;
|
|
1394
|
+
return doc.data();
|
|
1468
1395
|
});
|
|
1469
1396
|
}
|
|
1470
1397
|
save(data) {
|
|
@@ -1512,17 +1439,13 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1512
1439
|
};
|
|
1513
1440
|
return class UpdateFirestore extends MixinBase {
|
|
1514
1441
|
update(data) {
|
|
1515
|
-
var _a, _b, _c, _d;
|
|
1516
1442
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1517
1443
|
const model = new this.model();
|
|
1518
1444
|
const keyField = model.identifiersFields.shift();
|
|
1519
1445
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1520
|
-
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1523
|
-
yield setDoc(docRef, builded.toPlain(), { merge: true });
|
|
1524
|
-
const docData = yield getDoc(docRef).then((doc) => doc.data());
|
|
1525
|
-
return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
|
|
1446
|
+
yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
|
|
1447
|
+
const docData = yield getDoc(docRef);
|
|
1448
|
+
return docData.data();
|
|
1526
1449
|
});
|
|
1527
1450
|
}
|
|
1528
1451
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -1542,13 +1465,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1542
1465
|
const withDeleteFirestore = (MixinBase) => {
|
|
1543
1466
|
return class DeleteFirestore extends MixinBase {
|
|
1544
1467
|
delete(identifiers) {
|
|
1545
|
-
var _a, _b, _c, _d;
|
|
1546
1468
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1547
|
-
|
|
1548
|
-
const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
1549
|
-
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
1550
|
-
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1551
|
-
yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
|
|
1469
|
+
yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
|
|
1552
1470
|
});
|
|
1553
1471
|
}
|
|
1554
1472
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -1561,10 +1479,8 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1561
1479
|
|
|
1562
1480
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
1563
1481
|
return class SubCollectionMix extends MixinBase {
|
|
1564
|
-
constructor(...
|
|
1565
|
-
|
|
1566
|
-
super(...params);
|
|
1567
|
-
this.parentIdField = options.parentIdField;
|
|
1482
|
+
constructor(...args) {
|
|
1483
|
+
super(args);
|
|
1568
1484
|
}
|
|
1569
1485
|
collection(path) {
|
|
1570
1486
|
return super.collection(path);
|
|
@@ -1578,87 +1494,73 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1578
1494
|
};
|
|
1579
1495
|
|
|
1580
1496
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1581
|
-
constructor(
|
|
1582
|
-
super(
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
interceptors,
|
|
1587
|
-
});
|
|
1497
|
+
constructor(firestore) {
|
|
1498
|
+
super();
|
|
1499
|
+
this.firestore = firestore;
|
|
1500
|
+
this.collectionName = 'leads';
|
|
1501
|
+
this.model = Lead;
|
|
1588
1502
|
}
|
|
1589
1503
|
}
|
|
1590
1504
|
|
|
1591
1505
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1592
|
-
constructor(
|
|
1593
|
-
super(
|
|
1594
|
-
|
|
1595
|
-
collectionName: 'editions',
|
|
1596
|
-
parentIdField: 'subscriptionId',
|
|
1597
|
-
model: Edition,
|
|
1598
|
-
interceptors,
|
|
1599
|
-
});
|
|
1506
|
+
constructor(firestore, parentRepository) {
|
|
1507
|
+
super();
|
|
1508
|
+
this.firestore = firestore;
|
|
1600
1509
|
this.parentRepository = parentRepository;
|
|
1510
|
+
this.collectionName = 'editions';
|
|
1511
|
+
this.parentIdField = 'subscriptionId';
|
|
1512
|
+
this.model = Edition;
|
|
1601
1513
|
}
|
|
1602
1514
|
}
|
|
1603
1515
|
|
|
1604
1516
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1605
|
-
constructor(
|
|
1606
|
-
super(
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
interceptors,
|
|
1611
|
-
});
|
|
1517
|
+
constructor(firestore) {
|
|
1518
|
+
super();
|
|
1519
|
+
this.firestore = firestore;
|
|
1520
|
+
this.collectionName = 'subscription';
|
|
1521
|
+
this.model = Subscription;
|
|
1612
1522
|
}
|
|
1613
1523
|
}
|
|
1614
1524
|
|
|
1615
1525
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1616
|
-
constructor(
|
|
1617
|
-
super(
|
|
1618
|
-
|
|
1619
|
-
collectionName: 'payments',
|
|
1620
|
-
parentIdField: 'subscriptionId',
|
|
1621
|
-
model: SubscriptionPayment,
|
|
1622
|
-
interceptors,
|
|
1623
|
-
});
|
|
1526
|
+
constructor(firestore, parentRepository) {
|
|
1527
|
+
super();
|
|
1528
|
+
this.firestore = firestore;
|
|
1624
1529
|
this.parentRepository = parentRepository;
|
|
1530
|
+
this.collectionName = 'payments';
|
|
1531
|
+
this.parentIdField = 'subscriptionId';
|
|
1532
|
+
this.model = SubscriptionPayment;
|
|
1625
1533
|
}
|
|
1626
1534
|
}
|
|
1627
1535
|
|
|
1628
1536
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1629
|
-
constructor(
|
|
1630
|
-
super(
|
|
1631
|
-
|
|
1632
|
-
collectionName: 'address',
|
|
1633
|
-
parentIdField: 'userId',
|
|
1634
|
-
model: UserAddress,
|
|
1635
|
-
interceptors,
|
|
1636
|
-
});
|
|
1537
|
+
constructor(firestore, parentRepository) {
|
|
1538
|
+
super();
|
|
1539
|
+
this.firestore = firestore;
|
|
1637
1540
|
this.parentRepository = parentRepository;
|
|
1541
|
+
this.collectionName = 'address';
|
|
1542
|
+
this.parentIdField = 'userId';
|
|
1543
|
+
this.model = UserAddress;
|
|
1638
1544
|
}
|
|
1639
1545
|
}
|
|
1640
1546
|
|
|
1641
1547
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1642
|
-
constructor(
|
|
1643
|
-
super(
|
|
1644
|
-
|
|
1645
|
-
collectionName: 'CX',
|
|
1646
|
-
parentIdField: 'userId',
|
|
1647
|
-
model: BeautyProfile,
|
|
1648
|
-
interceptors,
|
|
1649
|
-
});
|
|
1548
|
+
constructor(firestore, parentRepository) {
|
|
1549
|
+
super();
|
|
1550
|
+
this.firestore = firestore;
|
|
1650
1551
|
this.parentRepository = parentRepository;
|
|
1552
|
+
this.collectionName = 'CX';
|
|
1553
|
+
this.parentIdField = 'userId';
|
|
1554
|
+
this.model = BeautyProfile;
|
|
1651
1555
|
}
|
|
1652
1556
|
}
|
|
1653
1557
|
|
|
1654
1558
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1655
|
-
constructor(
|
|
1656
|
-
super(
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
interceptors,
|
|
1661
|
-
});
|
|
1559
|
+
constructor(firestore) {
|
|
1560
|
+
super();
|
|
1561
|
+
this.firestore = firestore;
|
|
1562
|
+
this.collectionName = 'users';
|
|
1563
|
+
this.model = User;
|
|
1662
1564
|
}
|
|
1663
1565
|
get(identifiers) {
|
|
1664
1566
|
const _super = Object.create(null, {
|
|
@@ -1709,26 +1611,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1709
1611
|
}
|
|
1710
1612
|
|
|
1711
1613
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1712
|
-
constructor(
|
|
1713
|
-
super(
|
|
1714
|
-
|
|
1715
|
-
collectionName: 'payment_method',
|
|
1716
|
-
parentIdField: 'userId',
|
|
1717
|
-
model: UserPaymentMethod,
|
|
1718
|
-
interceptors,
|
|
1719
|
-
});
|
|
1614
|
+
constructor(firestore, parentRepository) {
|
|
1615
|
+
super();
|
|
1616
|
+
this.firestore = firestore;
|
|
1720
1617
|
this.parentRepository = parentRepository;
|
|
1618
|
+
this.collectionName = 'payment_method';
|
|
1619
|
+
this.parentIdField = 'userId';
|
|
1620
|
+
this.model = UserPaymentMethod;
|
|
1721
1621
|
}
|
|
1722
1622
|
}
|
|
1723
1623
|
|
|
1724
1624
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1725
|
-
constructor(
|
|
1726
|
-
super(
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
interceptors,
|
|
1731
|
-
});
|
|
1625
|
+
constructor(firestore) {
|
|
1626
|
+
super();
|
|
1627
|
+
this.firestore = firestore;
|
|
1628
|
+
this.collectionName = 'categories';
|
|
1629
|
+
this.model = Category;
|
|
1732
1630
|
}
|
|
1733
1631
|
getCategoryBySlug(slug, shop) {
|
|
1734
1632
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1740,7 +1638,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1740
1638
|
return categoryDocs.docs[0].data();
|
|
1741
1639
|
});
|
|
1742
1640
|
}
|
|
1743
|
-
getCategoriesForHome(categoryIds, limit = 4
|
|
1641
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
1744
1642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1745
1643
|
const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
|
|
1746
1644
|
if (categorySnap.empty)
|
|
@@ -1749,7 +1647,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1749
1647
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
1750
1648
|
return ({
|
|
1751
1649
|
category,
|
|
1752
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
1650
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
1753
1651
|
});
|
|
1754
1652
|
})));
|
|
1755
1653
|
return homeSections;
|
|
@@ -1768,8 +1666,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1768
1666
|
wheres.push(where('published', '==', true), where('id', 'in', productIds));
|
|
1769
1667
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1770
1668
|
wheres.push(where('stock.quantity', '>', 0));
|
|
1771
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
1772
|
-
wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
|
|
1773
1669
|
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1774
1670
|
wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
|
|
1775
1671
|
const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
|
|
@@ -1783,14 +1679,12 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1783
1679
|
}
|
|
1784
1680
|
|
|
1785
1681
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1786
|
-
constructor(
|
|
1787
|
-
super(
|
|
1788
|
-
|
|
1789
|
-
collectionName: 'productsErpVitrine',
|
|
1790
|
-
model: Product,
|
|
1791
|
-
interceptors,
|
|
1792
|
-
});
|
|
1682
|
+
constructor(firestore) {
|
|
1683
|
+
super();
|
|
1684
|
+
this.firestore = firestore;
|
|
1793
1685
|
this.reviews = {};
|
|
1686
|
+
this.collectionName = 'productsErpVitrine';
|
|
1687
|
+
this.model = Product;
|
|
1794
1688
|
}
|
|
1795
1689
|
getBySlug(slug) {
|
|
1796
1690
|
var _a;
|
|
@@ -1831,98 +1725,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1831
1725
|
return this.reviews[status];
|
|
1832
1726
|
});
|
|
1833
1727
|
}
|
|
1834
|
-
cleanShoppingCountFromIds() {
|
|
1835
|
-
return;
|
|
1836
|
-
}
|
|
1837
1728
|
}
|
|
1838
1729
|
|
|
1839
1730
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
1840
|
-
constructor(
|
|
1841
|
-
super(
|
|
1842
|
-
|
|
1843
|
-
collectionName: 'variants',
|
|
1844
|
-
parentIdField: 'productId',
|
|
1845
|
-
model: Variant,
|
|
1846
|
-
interceptors,
|
|
1847
|
-
});
|
|
1731
|
+
constructor(firestore, parentRepository) {
|
|
1732
|
+
super();
|
|
1733
|
+
this.firestore = firestore;
|
|
1848
1734
|
this.parentRepository = parentRepository;
|
|
1735
|
+
this.collectionName = 'variants';
|
|
1736
|
+
this.parentIdField = 'productId';
|
|
1737
|
+
this.model = Variant;
|
|
1849
1738
|
}
|
|
1850
1739
|
}
|
|
1851
1740
|
|
|
1852
1741
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1853
|
-
constructor(
|
|
1854
|
-
super(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
interceptors,
|
|
1859
|
-
});
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1864
|
-
constructor({ firestore, interceptors }) {
|
|
1865
|
-
super({
|
|
1866
|
-
firestore,
|
|
1867
|
-
collectionName: 'buy2win',
|
|
1868
|
-
model: Buy2Win,
|
|
1869
|
-
interceptors,
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1875
|
-
constructor({ firestore, interceptors, }) {
|
|
1876
|
-
super({
|
|
1877
|
-
firestore,
|
|
1878
|
-
collectionName: 'dashboardCampaignsAuto',
|
|
1879
|
-
model: CampaignDashboard,
|
|
1880
|
-
interceptors,
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1886
|
-
constructor({ firestore, interceptors, }) {
|
|
1887
|
-
super({
|
|
1888
|
-
firestore,
|
|
1889
|
-
collectionName: 'hashtagCampaignsAuto',
|
|
1890
|
-
model: CampaignHashtag,
|
|
1891
|
-
interceptors,
|
|
1892
|
-
});
|
|
1742
|
+
constructor(firestore) {
|
|
1743
|
+
super();
|
|
1744
|
+
this.firestore = firestore;
|
|
1745
|
+
this.collectionName = 'subscriptionProducts';
|
|
1746
|
+
this.model = Product;
|
|
1893
1747
|
}
|
|
1894
1748
|
}
|
|
1895
1749
|
|
|
1896
1750
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1897
|
-
constructor(
|
|
1898
|
-
super(
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
interceptors,
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1908
|
-
constructor({ firestore, interceptors, }) {
|
|
1909
|
-
super({
|
|
1910
|
-
firestore,
|
|
1911
|
-
collectionName: 'checkoutsSubscription',
|
|
1912
|
-
model: CheckoutSubscription,
|
|
1913
|
-
interceptors,
|
|
1914
|
-
});
|
|
1751
|
+
constructor(firestore) {
|
|
1752
|
+
super();
|
|
1753
|
+
this.firestore = firestore;
|
|
1754
|
+
this.collectionName = 'checkouts';
|
|
1755
|
+
this.model = Checkout;
|
|
1915
1756
|
}
|
|
1916
1757
|
}
|
|
1917
1758
|
|
|
1918
1759
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1919
|
-
constructor(
|
|
1920
|
-
super(
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
interceptors,
|
|
1925
|
-
});
|
|
1760
|
+
constructor(firestore) {
|
|
1761
|
+
super();
|
|
1762
|
+
this.firestore = firestore;
|
|
1763
|
+
this.collectionName = 'coupons';
|
|
1764
|
+
this.model = Coupon;
|
|
1926
1765
|
}
|
|
1927
1766
|
buildModelInstance() {
|
|
1928
1767
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1944,16 +1783,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1944
1783
|
}
|
|
1945
1784
|
|
|
1946
1785
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1947
|
-
constructor(
|
|
1948
|
-
super(
|
|
1949
|
-
|
|
1950
|
-
collectionName: 'orders',
|
|
1951
|
-
model: Order,
|
|
1952
|
-
interceptors,
|
|
1953
|
-
fields: {
|
|
1954
|
-
status: FirestoreFieldType.String,
|
|
1955
|
-
},
|
|
1956
|
-
});
|
|
1786
|
+
constructor(firestore) {
|
|
1787
|
+
super();
|
|
1788
|
+
this.firestore = firestore;
|
|
1957
1789
|
this.orderFromFirestore = (order) => {
|
|
1958
1790
|
var _a;
|
|
1959
1791
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -1967,6 +1799,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1967
1799
|
}
|
|
1968
1800
|
return order;
|
|
1969
1801
|
};
|
|
1802
|
+
this.collectionName = 'orders';
|
|
1803
|
+
this.model = Order;
|
|
1804
|
+
this.fields = {
|
|
1805
|
+
status: FirestoreFieldType.String,
|
|
1806
|
+
};
|
|
1970
1807
|
}
|
|
1971
1808
|
buildModelInstance() {
|
|
1972
1809
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1980,46 +1817,54 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1980
1817
|
}
|
|
1981
1818
|
}
|
|
1982
1819
|
|
|
1983
|
-
class
|
|
1984
|
-
constructor(
|
|
1985
|
-
super(
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
this.collectionName = 'legacyOrders';
|
|
1820
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1821
|
+
constructor(firestore) {
|
|
1822
|
+
super();
|
|
1823
|
+
this.firestore = firestore;
|
|
1824
|
+
this.collectionName = 'payments';
|
|
1825
|
+
this.model = Payment;
|
|
1990
1826
|
}
|
|
1991
1827
|
}
|
|
1992
1828
|
|
|
1993
|
-
class
|
|
1994
|
-
constructor(
|
|
1995
|
-
super(
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
interceptors,
|
|
2000
|
-
});
|
|
1829
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1830
|
+
constructor(firestore) {
|
|
1831
|
+
super();
|
|
1832
|
+
this.firestore = firestore;
|
|
1833
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1834
|
+
this.model = CheckoutSubscription;
|
|
2001
1835
|
}
|
|
2002
1836
|
}
|
|
2003
1837
|
|
|
2004
1838
|
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2005
|
-
constructor(
|
|
2006
|
-
super(
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1839
|
+
constructor(firestore) {
|
|
1840
|
+
super();
|
|
1841
|
+
this.firestore = firestore;
|
|
1842
|
+
this.collectionName = 'subscriptionPlans';
|
|
1843
|
+
this.model = SubscriptionPlan;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1848
|
+
constructor(firestore) {
|
|
1849
|
+
super();
|
|
1850
|
+
this.firestore = firestore;
|
|
1851
|
+
this.collectionName = 'buy2win';
|
|
1852
|
+
this.model = Buy2Win;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1857
|
+
constructor(firestore) {
|
|
1858
|
+
super(firestore);
|
|
1859
|
+
this.firestore = firestore;
|
|
1860
|
+
this.collectionName = 'legacyOrders';
|
|
2012
1861
|
}
|
|
2013
1862
|
}
|
|
2014
1863
|
|
|
2015
1864
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2016
|
-
constructor(
|
|
2017
|
-
super(
|
|
2018
|
-
|
|
2019
|
-
collectionName: 'dms',
|
|
2020
|
-
model: Home,
|
|
2021
|
-
interceptors,
|
|
2022
|
-
});
|
|
1865
|
+
constructor(firestore) {
|
|
1866
|
+
super();
|
|
1867
|
+
this.firestore = firestore;
|
|
2023
1868
|
this.homeToFirestore = (home) => {
|
|
2024
1869
|
var _a;
|
|
2025
1870
|
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
@@ -2050,6 +1895,8 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2050
1895
|
category: Category.toInstance(homeCategoryGroup.category),
|
|
2051
1896
|
products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
|
|
2052
1897
|
});
|
|
1898
|
+
this.collectionName = 'dms';
|
|
1899
|
+
this.model = Home;
|
|
2053
1900
|
}
|
|
2054
1901
|
buildModelInstance() {
|
|
2055
1902
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -2067,24 +1914,11 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
2067
1914
|
}
|
|
2068
1915
|
|
|
2069
1916
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2070
|
-
constructor(
|
|
2071
|
-
super(
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
interceptors,
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
|
|
2080
|
-
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2081
|
-
constructor({ firestore, interceptors, }) {
|
|
2082
|
-
super({
|
|
2083
|
-
firestore,
|
|
2084
|
-
collectionName: 'shopSettings',
|
|
2085
|
-
model: ShopSettings,
|
|
2086
|
-
interceptors,
|
|
2087
|
-
});
|
|
1917
|
+
constructor(firestore) {
|
|
1918
|
+
super();
|
|
1919
|
+
this.firestore = firestore;
|
|
1920
|
+
this.collectionName = 'shopMenus';
|
|
1921
|
+
this.model = ShopMenu;
|
|
2088
1922
|
}
|
|
2089
1923
|
}
|
|
2090
1924
|
|
|
@@ -2174,7 +2008,7 @@ class AttributeOptionHelper {
|
|
|
2174
2008
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2175
2009
|
var _a;
|
|
2176
2010
|
if (fields.includes(attributeName))
|
|
2177
|
-
return { columnName: attributeName.toString(), attributeName
|
|
2011
|
+
return { columnName: attributeName.toString(), attributeName };
|
|
2178
2012
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2179
2013
|
const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
|
|
2180
2014
|
if (isNil(fieldOption))
|
|
@@ -2349,7 +2183,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2349
2183
|
}
|
|
2350
2184
|
if (!!from)
|
|
2351
2185
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2352
|
-
return Object.assign(Object.assign({}, result), { [attributeName]:
|
|
2186
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2353
2187
|
}, {});
|
|
2354
2188
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2355
2189
|
var _a;
|
|
@@ -2490,24 +2324,30 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2490
2324
|
});
|
|
2491
2325
|
}
|
|
2492
2326
|
query(operation, fields, variables) {
|
|
2493
|
-
var _a, _b, _c, _d;
|
|
2494
2327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2328
|
+
const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2329
|
+
? query$1(operation.map((option) => ({
|
|
2330
|
+
operation: option.operation,
|
|
2331
|
+
variables: option.variables,
|
|
2332
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2333
|
+
})))
|
|
2334
|
+
: query$1({
|
|
2335
|
+
operation,
|
|
2336
|
+
variables,
|
|
2337
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2338
|
+
});
|
|
2339
|
+
return this.fetch(resultQuery);
|
|
2500
2340
|
});
|
|
2501
2341
|
}
|
|
2502
2342
|
fetch(params) {
|
|
2503
2343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2504
2344
|
const headers = this.headers;
|
|
2505
|
-
const
|
|
2506
|
-
url: `${this.endpoint}`,
|
|
2345
|
+
const response = yield fetch(`${this.endpoint}`, {
|
|
2507
2346
|
method: 'POST',
|
|
2508
|
-
|
|
2347
|
+
body: JSON.stringify(params),
|
|
2509
2348
|
headers,
|
|
2510
2349
|
});
|
|
2350
|
+
const result = yield response.json();
|
|
2511
2351
|
if (!isNil(result.errors))
|
|
2512
2352
|
throw new Error(JSON.stringify(result.errors));
|
|
2513
2353
|
return result.data;
|
|
@@ -2543,19 +2383,6 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2543
2383
|
convertDataToHasura(instance, update = false) {
|
|
2544
2384
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2545
2385
|
}
|
|
2546
|
-
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
2547
|
-
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2548
|
-
? operation.map((option) => ({
|
|
2549
|
-
operation: option.operation,
|
|
2550
|
-
variables: option.variables,
|
|
2551
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2552
|
-
}))
|
|
2553
|
-
: {
|
|
2554
|
-
operation,
|
|
2555
|
-
variables,
|
|
2556
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2557
|
-
};
|
|
2558
|
-
}
|
|
2559
2386
|
};
|
|
2560
2387
|
};
|
|
2561
2388
|
|
|
@@ -2647,11 +2474,9 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2647
2474
|
|
|
2648
2475
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2649
2476
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2650
|
-
find(
|
|
2651
|
-
var _a;
|
|
2477
|
+
find(options) {
|
|
2652
2478
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2653
|
-
const { filters, limits, orderBy
|
|
2654
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2479
|
+
const { filters, limits, orderBy } = options || {};
|
|
2655
2480
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2656
2481
|
? {}
|
|
2657
2482
|
: {
|
|
@@ -2665,8 +2490,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2665
2490
|
const result = yield this.query([
|
|
2666
2491
|
{
|
|
2667
2492
|
operation: this.tableName,
|
|
2668
|
-
fields:
|
|
2669
|
-
?
|
|
2493
|
+
fields: options.fields
|
|
2494
|
+
? options.fields
|
|
2670
2495
|
.map((fieldName) => {
|
|
2671
2496
|
var _a;
|
|
2672
2497
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2675,18 +2500,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2675
2500
|
: this.fields,
|
|
2676
2501
|
variables,
|
|
2677
2502
|
},
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
variables: variablesCount,
|
|
2684
|
-
},
|
|
2685
|
-
]
|
|
2686
|
-
: []),
|
|
2503
|
+
{
|
|
2504
|
+
operation: `${this.tableName}_aggregate`,
|
|
2505
|
+
fields: [{ aggregate: ['count'] }],
|
|
2506
|
+
variables: variablesCount,
|
|
2507
|
+
},
|
|
2687
2508
|
]);
|
|
2688
2509
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2689
|
-
|
|
2510
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2511
|
+
return { count, data };
|
|
2690
2512
|
});
|
|
2691
2513
|
}
|
|
2692
2514
|
};
|
|
@@ -2726,66 +2548,13 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2726
2548
|
}
|
|
2727
2549
|
}
|
|
2728
2550
|
|
|
2729
|
-
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2730
|
-
constructor(endpoint, authOptions) {
|
|
2731
|
-
super({
|
|
2732
|
-
tableName: 'category_filter',
|
|
2733
|
-
model: CategoryFilter,
|
|
2734
|
-
endpoint,
|
|
2735
|
-
authOptions,
|
|
2736
|
-
fields: [
|
|
2737
|
-
'id',
|
|
2738
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
2739
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
2740
|
-
{
|
|
2741
|
-
filter: {
|
|
2742
|
-
columnName: 'filter',
|
|
2743
|
-
foreignKeyColumn: { id: 'filterId' },
|
|
2744
|
-
fields: [
|
|
2745
|
-
'id',
|
|
2746
|
-
'description',
|
|
2747
|
-
'slug',
|
|
2748
|
-
'enabled',
|
|
2749
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2750
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2751
|
-
{
|
|
2752
|
-
options: {
|
|
2753
|
-
columnName: 'options',
|
|
2754
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
2755
|
-
fields: [
|
|
2756
|
-
'id',
|
|
2757
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
2758
|
-
'description',
|
|
2759
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2760
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2761
|
-
],
|
|
2762
|
-
},
|
|
2763
|
-
},
|
|
2764
|
-
],
|
|
2765
|
-
},
|
|
2766
|
-
},
|
|
2767
|
-
],
|
|
2768
|
-
});
|
|
2769
|
-
}
|
|
2770
|
-
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
2771
|
-
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
2772
|
-
where: {
|
|
2773
|
-
type: 'category_filter_bool_exp',
|
|
2774
|
-
required: true,
|
|
2775
|
-
value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
|
|
2776
|
-
},
|
|
2777
|
-
});
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
2551
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2782
|
-
constructor(
|
|
2552
|
+
constructor(endpoint, authOptions, productRepository) {
|
|
2783
2553
|
super({
|
|
2784
2554
|
tableName: 'category',
|
|
2785
2555
|
model: Category,
|
|
2786
2556
|
endpoint,
|
|
2787
2557
|
authOptions,
|
|
2788
|
-
interceptors,
|
|
2789
2558
|
fields: [
|
|
2790
2559
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2791
2560
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2819,17 +2588,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2819
2588
|
},
|
|
2820
2589
|
},
|
|
2821
2590
|
},
|
|
2822
|
-
|
|
2823
|
-
filters: {
|
|
2824
|
-
columnName: 'filters',
|
|
2825
|
-
foreignKeyColumn: { filter_id: 'id' },
|
|
2826
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
2827
|
-
bindPersistData: (value) => ({
|
|
2828
|
-
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
2829
|
-
}),
|
|
2830
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
2831
|
-
},
|
|
2832
|
-
},
|
|
2591
|
+
'filters',
|
|
2833
2592
|
{ createdAt: { columnName: 'created_at' } },
|
|
2834
2593
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
2835
2594
|
{
|
|
@@ -2854,7 +2613,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2854
2613
|
],
|
|
2855
2614
|
});
|
|
2856
2615
|
this.productRepository = productRepository;
|
|
2857
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
2858
2616
|
}
|
|
2859
2617
|
create(params) {
|
|
2860
2618
|
const _super = Object.create(null, {
|
|
@@ -2872,7 +2630,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2872
2630
|
var _a;
|
|
2873
2631
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2874
2632
|
return Number.isNaN(+identifiers.id)
|
|
2875
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2633
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2876
2634
|
: _super.get.call(this, identifiers);
|
|
2877
2635
|
});
|
|
2878
2636
|
}
|
|
@@ -2881,13 +2639,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2881
2639
|
update: { get: () => super.update }
|
|
2882
2640
|
});
|
|
2883
2641
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2884
|
-
const { products, id: checkId, metadata
|
|
2642
|
+
const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
|
|
2885
2643
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2886
2644
|
const id = yield this.getId(plainData.id);
|
|
2887
2645
|
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2888
2646
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
2889
2647
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
2890
|
-
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
2891
2648
|
return category;
|
|
2892
2649
|
});
|
|
2893
2650
|
}
|
|
@@ -2895,15 +2652,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2895
2652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2896
2653
|
if (!slug)
|
|
2897
2654
|
return null;
|
|
2898
|
-
const { data } = yield this.find({ filters: { slug, shop, published: true }
|
|
2899
|
-
if (
|
|
2900
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2901
|
-
if (data.length > 1)
|
|
2655
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2656
|
+
if (count > 1)
|
|
2902
2657
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2658
|
+
if (!count)
|
|
2659
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2903
2660
|
return data.shift();
|
|
2904
2661
|
});
|
|
2905
2662
|
}
|
|
2906
|
-
getCategoriesForHome(categoryIds, limit = 4
|
|
2663
|
+
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2907
2664
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2908
2665
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2909
2666
|
return [];
|
|
@@ -2923,7 +2680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2923
2680
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2924
2681
|
return ({
|
|
2925
2682
|
category,
|
|
2926
|
-
products: yield this.mountCategory(category, { limit, hasStock: true
|
|
2683
|
+
products: yield this.mountCategory(category, { limit, hasStock: true }),
|
|
2927
2684
|
});
|
|
2928
2685
|
})));
|
|
2929
2686
|
return homeSections;
|
|
@@ -2935,7 +2692,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2935
2692
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2936
2693
|
return [];
|
|
2937
2694
|
const products = [];
|
|
2938
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2695
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2939
2696
|
'id',
|
|
2940
2697
|
'name',
|
|
2941
2698
|
'slug',
|
|
@@ -2959,8 +2716,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2959
2716
|
'tags',
|
|
2960
2717
|
'type',
|
|
2961
2718
|
'shoppingCount',
|
|
2962
|
-
|
|
2963
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2719
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2964
2720
|
products.push(...productsData);
|
|
2965
2721
|
return products;
|
|
2966
2722
|
});
|
|
@@ -2970,7 +2726,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2970
2726
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2971
2727
|
if (!Number.isNaN(+id))
|
|
2972
2728
|
return id;
|
|
2973
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2729
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2974
2730
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2975
2731
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2976
2732
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -3028,218 +2784,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3028
2784
|
return plainData.metadata;
|
|
3029
2785
|
});
|
|
3030
2786
|
}
|
|
3031
|
-
updateFilters(categoryId, { filters }) {
|
|
3032
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3033
|
-
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
3034
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
3035
|
-
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
|
|
3036
|
-
}
|
|
3037
|
-
return [];
|
|
3038
|
-
}
|
|
3039
|
-
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3040
|
-
let filtersList = [];
|
|
3041
|
-
for (let i = 0; i < filters.value.length; i++) {
|
|
3042
|
-
try {
|
|
3043
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
3044
|
-
.find({
|
|
3045
|
-
filters: {
|
|
3046
|
-
categoryId,
|
|
3047
|
-
filterId: filters.value[i].id,
|
|
3048
|
-
},
|
|
3049
|
-
})
|
|
3050
|
-
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3051
|
-
if (hasFilter) {
|
|
3052
|
-
filtersList.push(hasFilter);
|
|
3053
|
-
}
|
|
3054
|
-
else {
|
|
3055
|
-
yield this.categoryFilterRepository.create({
|
|
3056
|
-
filterId: filters.value[i].id,
|
|
3057
|
-
categoryId,
|
|
3058
|
-
});
|
|
3059
|
-
filtersList.push(filters.value[i]);
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
catch (error) {
|
|
3063
|
-
console.log('catch error: ', error);
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
return filtersList;
|
|
3067
|
-
}
|
|
3068
|
-
if (Array.isArray(filters) && filters.length) {
|
|
3069
|
-
let filtersList = [];
|
|
3070
|
-
for (let i = 0; i < filters.length; i++) {
|
|
3071
|
-
try {
|
|
3072
|
-
const hasFilter = yield this.categoryFilterRepository
|
|
3073
|
-
.find({
|
|
3074
|
-
filters: {
|
|
3075
|
-
categoryId,
|
|
3076
|
-
filterId: filters[i].id,
|
|
3077
|
-
},
|
|
3078
|
-
})
|
|
3079
|
-
.then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
|
|
3080
|
-
if (hasFilter) {
|
|
3081
|
-
filtersList.push(hasFilter);
|
|
3082
|
-
}
|
|
3083
|
-
else {
|
|
3084
|
-
yield this.categoryFilterRepository.create({
|
|
3085
|
-
filterId: filters[i].id,
|
|
3086
|
-
categoryId,
|
|
3087
|
-
});
|
|
3088
|
-
filtersList.push(filters[i]);
|
|
3089
|
-
}
|
|
3090
|
-
}
|
|
3091
|
-
catch (error) {
|
|
3092
|
-
console.log('catch error: ', error);
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
return filtersList;
|
|
3096
|
-
}
|
|
3097
|
-
return [];
|
|
3098
|
-
});
|
|
3099
|
-
}
|
|
3100
|
-
}
|
|
3101
|
-
|
|
3102
|
-
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3103
|
-
constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
|
|
3104
|
-
super({
|
|
3105
|
-
tableName: 'filter',
|
|
3106
|
-
model: Filter,
|
|
3107
|
-
endpoint,
|
|
3108
|
-
authOptions,
|
|
3109
|
-
fields: [
|
|
3110
|
-
'id',
|
|
3111
|
-
'description',
|
|
3112
|
-
'slug',
|
|
3113
|
-
'enabled',
|
|
3114
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3115
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3116
|
-
{
|
|
3117
|
-
options: {
|
|
3118
|
-
columnName: 'options',
|
|
3119
|
-
foreignKeyColumn: { filterId: 'id' },
|
|
3120
|
-
fields: [
|
|
3121
|
-
'id',
|
|
3122
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3123
|
-
'description',
|
|
3124
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3125
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3126
|
-
],
|
|
3127
|
-
},
|
|
3128
|
-
},
|
|
3129
|
-
],
|
|
3130
|
-
});
|
|
3131
|
-
this.filterOptionRepository = filterOptionRepository;
|
|
3132
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
3133
|
-
}
|
|
3134
|
-
update(params) {
|
|
3135
|
-
const _super = Object.create(null, {
|
|
3136
|
-
update: { get: () => super.update }
|
|
3137
|
-
});
|
|
3138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3139
|
-
const { options } = params, data = __rest(params, ["options"]);
|
|
3140
|
-
const filter = yield _super.update.call(this, data);
|
|
3141
|
-
filter.options = yield this.updateOptions(+data.id, { options });
|
|
3142
|
-
return filter;
|
|
3143
|
-
});
|
|
3144
|
-
}
|
|
3145
|
-
updateOptions(filterId, { options }) {
|
|
3146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3147
|
-
if (!options)
|
|
3148
|
-
return [];
|
|
3149
|
-
if ('action' in options && options.action === 'remove' && options.value.length) {
|
|
3150
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3151
|
-
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
3152
|
-
}
|
|
3153
|
-
return [];
|
|
3154
|
-
}
|
|
3155
|
-
if ('action' in options && options.action === 'merge' && options.value.length) {
|
|
3156
|
-
let filterOptions = [];
|
|
3157
|
-
for (let i = 0; i < options.value.length; i++) {
|
|
3158
|
-
try {
|
|
3159
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
3160
|
-
if (hasFilter)
|
|
3161
|
-
filterOptions.push(hasFilter);
|
|
3162
|
-
}
|
|
3163
|
-
catch (error) {
|
|
3164
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
|
|
3165
|
-
filterOptions.push(newOption);
|
|
3166
|
-
}
|
|
3167
|
-
}
|
|
3168
|
-
return filterOptions;
|
|
3169
|
-
}
|
|
3170
|
-
if (Array.isArray(options) && options.length) {
|
|
3171
|
-
let filterOptions = [];
|
|
3172
|
-
for (let i = 0; i < options.length; i++) {
|
|
3173
|
-
try {
|
|
3174
|
-
const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
|
|
3175
|
-
if (hasFilter)
|
|
3176
|
-
filterOptions.push(hasFilter);
|
|
3177
|
-
}
|
|
3178
|
-
catch (error) {
|
|
3179
|
-
const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
|
|
3180
|
-
filterOptions.push(newOption);
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
}
|
|
3184
|
-
return [];
|
|
3185
|
-
});
|
|
3186
|
-
}
|
|
3187
|
-
delete(params) {
|
|
3188
|
-
const _super = Object.create(null, {
|
|
3189
|
-
delete: { get: () => super.delete }
|
|
3190
|
-
});
|
|
3191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3192
|
-
const { data: categoryFilters } = yield this.categoryFilterRepository.find({
|
|
3193
|
-
filters: {
|
|
3194
|
-
filterId: params.id,
|
|
3195
|
-
},
|
|
3196
|
-
});
|
|
3197
|
-
if (categoryFilters.length)
|
|
3198
|
-
throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
|
|
3199
|
-
yield this.deleteOptions(+params.id);
|
|
3200
|
-
yield _super.delete.call(this, { id: +params.id });
|
|
3201
|
-
return;
|
|
3202
|
-
});
|
|
3203
|
-
}
|
|
3204
|
-
deleteOptions(filterId) {
|
|
3205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3206
|
-
yield this.mutation('delete_filter_option', ['affected_rows'], {
|
|
3207
|
-
where: {
|
|
3208
|
-
type: 'filter_option_bool_exp',
|
|
3209
|
-
required: true,
|
|
3210
|
-
value: { filter_id: { _eq: filterId } },
|
|
3211
|
-
},
|
|
3212
|
-
});
|
|
3213
|
-
});
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
|
|
3217
|
-
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3218
|
-
constructor(endpoint, authOptions) {
|
|
3219
|
-
super({
|
|
3220
|
-
tableName: 'filter_option',
|
|
3221
|
-
model: FilterOption,
|
|
3222
|
-
endpoint,
|
|
3223
|
-
authOptions,
|
|
3224
|
-
fields: [
|
|
3225
|
-
'id',
|
|
3226
|
-
'description',
|
|
3227
|
-
{ filterId: { columnName: 'filter_id' } },
|
|
3228
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3229
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3230
|
-
],
|
|
3231
|
-
});
|
|
3232
|
-
}
|
|
3233
2787
|
}
|
|
3234
2788
|
|
|
3235
2789
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3236
|
-
constructor(
|
|
2790
|
+
constructor(endpoint, authOptions) {
|
|
3237
2791
|
super({
|
|
3238
2792
|
tableName: 'product',
|
|
3239
2793
|
model: ProductHasuraGraphQL,
|
|
3240
2794
|
endpoint,
|
|
3241
2795
|
authOptions,
|
|
3242
|
-
interceptors,
|
|
3243
2796
|
fields: [],
|
|
3244
2797
|
});
|
|
3245
2798
|
this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
|
|
@@ -3336,7 +2889,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3336
2889
|
'weight',
|
|
3337
2890
|
'gender',
|
|
3338
2891
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3339
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3340
2892
|
{ isKit: { columnName: 'is_kit' } },
|
|
3341
2893
|
{ createdAt: { columnName: 'created_at' } },
|
|
3342
2894
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
@@ -3438,7 +2990,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3438
2990
|
var _a;
|
|
3439
2991
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3440
2992
|
const product = Number.isNaN(+identifiers.id)
|
|
3441
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2993
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
3442
2994
|
: yield _super.get.call(this, identifiers);
|
|
3443
2995
|
if (product.productId)
|
|
3444
2996
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3466,12 +3018,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3466
3018
|
filters: {
|
|
3467
3019
|
slug,
|
|
3468
3020
|
},
|
|
3469
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3470
|
-
options: {
|
|
3471
|
-
enableCount: false,
|
|
3472
|
-
},
|
|
3473
3021
|
});
|
|
3474
3022
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3023
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
3475
3024
|
return product;
|
|
3476
3025
|
});
|
|
3477
3026
|
}
|
|
@@ -3634,7 +3183,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3634
3183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3635
3184
|
if (!Number.isNaN(+id))
|
|
3636
3185
|
return id;
|
|
3637
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3186
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3638
3187
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3639
3188
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3640
3189
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3690,31 +3239,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3690
3239
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
3691
3240
|
});
|
|
3692
3241
|
}
|
|
3693
|
-
cleanShoppingCountFromIds(ids) {
|
|
3694
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3695
|
-
return yield this.mutation('update_product', ['affected_rows'], {
|
|
3696
|
-
where: {
|
|
3697
|
-
value: { id: { _nin: ids } },
|
|
3698
|
-
type: 'product_bool_exp',
|
|
3699
|
-
required: true,
|
|
3700
|
-
},
|
|
3701
|
-
_set: {
|
|
3702
|
-
value: { shopping_count: 0 },
|
|
3703
|
-
type: 'product_set_input',
|
|
3704
|
-
},
|
|
3705
|
-
});
|
|
3706
|
-
});
|
|
3707
|
-
}
|
|
3708
3242
|
}
|
|
3709
3243
|
|
|
3710
3244
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3711
|
-
constructor(
|
|
3245
|
+
constructor(endpoint, authOptions) {
|
|
3712
3246
|
super({
|
|
3713
3247
|
tableName: 'product',
|
|
3714
3248
|
model: VariantHasuraGraphQL,
|
|
3715
3249
|
endpoint,
|
|
3716
3250
|
authOptions,
|
|
3717
|
-
interceptors,
|
|
3718
3251
|
fields: [
|
|
3719
3252
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3720
3253
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3744,9 +3277,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3744
3277
|
subscriber_price: filters.subscriberPrice,
|
|
3745
3278
|
}));
|
|
3746
3279
|
},
|
|
3747
|
-
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((
|
|
3280
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
3748
3281
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3749
|
-
})), (
|
|
3282
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3750
3283
|
},
|
|
3751
3284
|
},
|
|
3752
3285
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -3815,7 +3348,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3815
3348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3816
3349
|
if (!Number.isNaN(+id))
|
|
3817
3350
|
return id;
|
|
3818
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3351
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3819
3352
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3820
3353
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3821
3354
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3827,5 +3360,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3827
3360
|
* Generated bundle index. Do not edit.
|
|
3828
3361
|
*/
|
|
3829
3362
|
|
|
3830
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
3363
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, 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, 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, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3831
3364
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|