@infrab4a/connect 4.9.7-beta.2 → 4.9.7-beta.20
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/index.cjs.js +284 -81
- package/index.esm.js +283 -82
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +17 -1
- package/src/domain/catalog/models/filter.d.ts +3 -1
- package/src/domain/catalog/models/types/category-images.type.d.ts +8 -0
- package/src/domain/catalog/models/types/category-metadata.type.d.ts +2 -0
- package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +4 -0
- package/src/domain/catalog/models/types/index.d.ts +3 -0
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +21 -0
- package/src/domain/catalog/models/wishlist.d.ts +3 -0
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +9 -1
- package/src/domain/catalog/repositories/wishlist.repository.d.ts +3 -0
- package/src/domain/shopping/index.d.ts +1 -0
- package/src/domain/shopping/models/coupons/coupon.d.ts +1 -1
- package/src/domain/shopping/models/index.d.ts +1 -0
- package/src/domain/shopping/models/order-blocked.d.ts +26 -0
- package/src/domain/shopping/repositories/index.d.ts +1 -0
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +6 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/payment-card-info.type.d.ts +4 -0
- package/src/domain/users/models/enums/index.d.ts +1 -0
- package/src/domain/users/models/enums/person-types.enum.d.ts +5 -0
- package/src/domain/users/models/index.d.ts +3 -2
- package/src/domain/users/models/types/index.d.ts +1 -0
- package/src/domain/users/models/types/person.type.d.ts +2 -0
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +9 -0
- package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +4 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +8 -1
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +11 -9
package/index.cjs.js
CHANGED
|
@@ -42,6 +42,21 @@ class BaseModel {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
exports.GenderDestination = void 0;
|
|
46
|
+
(function (GenderDestination) {
|
|
47
|
+
GenderDestination["FEMALE"] = "female";
|
|
48
|
+
GenderDestination["MALE"] = "male";
|
|
49
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
50
|
+
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
51
|
+
|
|
52
|
+
exports.Shops = void 0;
|
|
53
|
+
(function (Shops) {
|
|
54
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
55
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
56
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
57
|
+
Shops["ALL"] = "ALL";
|
|
58
|
+
})(exports.Shops || (exports.Shops = {}));
|
|
59
|
+
|
|
45
60
|
class Filter extends BaseModel {
|
|
46
61
|
static get identifiersFields() {
|
|
47
62
|
return ['id'];
|
|
@@ -56,6 +71,33 @@ class CategoryBase extends BaseModel {
|
|
|
56
71
|
static get identifiersFields() {
|
|
57
72
|
return ['id'];
|
|
58
73
|
}
|
|
74
|
+
get glamImages() {
|
|
75
|
+
return this.images && this.images[exports.Shops.GLAMSHOP]
|
|
76
|
+
? this.images[exports.Shops.GLAMSHOP]
|
|
77
|
+
: {
|
|
78
|
+
brandBanner: null,
|
|
79
|
+
brandBannerMobile: null,
|
|
80
|
+
image: null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
get mensImages() {
|
|
84
|
+
return this.images && this.images[exports.Shops.MENSMARKET]
|
|
85
|
+
? this.images[exports.Shops.MENSMARKET]
|
|
86
|
+
: {
|
|
87
|
+
brandBanner: null,
|
|
88
|
+
brandBannerMobile: null,
|
|
89
|
+
image: null,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
get glamMetadata() {
|
|
93
|
+
return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
|
|
94
|
+
}
|
|
95
|
+
get mensMetadata() {
|
|
96
|
+
return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
|
|
97
|
+
}
|
|
98
|
+
getMostRelevantByShop(shop) {
|
|
99
|
+
return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
|
|
100
|
+
}
|
|
59
101
|
}
|
|
60
102
|
tslib.__decorate([
|
|
61
103
|
classTransformer.Type(() => CategoryBase),
|
|
@@ -164,21 +206,6 @@ tslib.__decorate([
|
|
|
164
206
|
tslib.__metadata("design:type", Category)
|
|
165
207
|
], CategoryFilter.prototype, "category", void 0);
|
|
166
208
|
|
|
167
|
-
exports.GenderDestination = void 0;
|
|
168
|
-
(function (GenderDestination) {
|
|
169
|
-
GenderDestination["FEMALE"] = "female";
|
|
170
|
-
GenderDestination["MALE"] = "male";
|
|
171
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
172
|
-
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
173
|
-
|
|
174
|
-
exports.Shops = void 0;
|
|
175
|
-
(function (Shops) {
|
|
176
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
177
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
178
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
179
|
-
Shops["ALL"] = "ALL";
|
|
180
|
-
})(exports.Shops || (exports.Shops = {}));
|
|
181
|
-
|
|
182
209
|
class FilterOption extends BaseModel {
|
|
183
210
|
static get identifiersFields() {
|
|
184
211
|
return ['id'];
|
|
@@ -271,6 +298,17 @@ class CampaignHashtag extends BaseModel {
|
|
|
271
298
|
}
|
|
272
299
|
}
|
|
273
300
|
|
|
301
|
+
class BeautyProfile extends BaseModel {
|
|
302
|
+
toPlain() {
|
|
303
|
+
const plain = super.toPlain();
|
|
304
|
+
delete plain.id;
|
|
305
|
+
return plain;
|
|
306
|
+
}
|
|
307
|
+
static get identifiersFields() {
|
|
308
|
+
return ['id', 'userId'];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
274
312
|
exports.AccessoryImportances = void 0;
|
|
275
313
|
(function (AccessoryImportances) {
|
|
276
314
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -447,6 +485,13 @@ exports.OfficePosition = void 0;
|
|
|
447
485
|
OfficePosition["Director"] = "Diretor";
|
|
448
486
|
})(exports.OfficePosition || (exports.OfficePosition = {}));
|
|
449
487
|
|
|
488
|
+
exports.PersonTypes = void 0;
|
|
489
|
+
(function (PersonTypes) {
|
|
490
|
+
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
491
|
+
PersonTypes["BFLU"] = "bflu";
|
|
492
|
+
PersonTypes["NONE"] = "none";
|
|
493
|
+
})(exports.PersonTypes || (exports.PersonTypes = {}));
|
|
494
|
+
|
|
450
495
|
exports.ProductSpents = void 0;
|
|
451
496
|
(function (ProductSpents) {
|
|
452
497
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -467,6 +512,12 @@ exports.UserType = void 0;
|
|
|
467
512
|
UserType["Influencer"] = "Influencer";
|
|
468
513
|
})(exports.UserType || (exports.UserType = {}));
|
|
469
514
|
|
|
515
|
+
class Lead extends BaseModel {
|
|
516
|
+
static get identifiersFields() {
|
|
517
|
+
return ['id'];
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
470
521
|
class Edition extends BaseModel {
|
|
471
522
|
static get identifiersFields() {
|
|
472
523
|
return ['id', 'subscriptionId'];
|
|
@@ -1865,17 +1916,6 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1865
1916
|
}
|
|
1866
1917
|
}
|
|
1867
1918
|
|
|
1868
|
-
class BeautyProfile extends BaseModel {
|
|
1869
|
-
toPlain() {
|
|
1870
|
-
const plain = super.toPlain();
|
|
1871
|
-
delete plain.id;
|
|
1872
|
-
return plain;
|
|
1873
|
-
}
|
|
1874
|
-
static get identifiersFields() {
|
|
1875
|
-
return ['id', 'userId'];
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
1919
|
class User extends BaseModel {
|
|
1880
1920
|
static toInstance(data) {
|
|
1881
1921
|
const instance = super.toInstance(data);
|
|
@@ -1989,12 +2029,6 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1989
2029
|
}
|
|
1990
2030
|
}
|
|
1991
2031
|
|
|
1992
|
-
class Lead extends BaseModel {
|
|
1993
|
-
static get identifiersFields() {
|
|
1994
|
-
return ['id'];
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
2032
|
class UnauthorizedError extends tsCustomError.CustomError {
|
|
1999
2033
|
constructor(message) {
|
|
2000
2034
|
super(message);
|
|
@@ -2167,6 +2201,12 @@ tslib.__decorate([
|
|
|
2167
2201
|
tslib.__metadata("design:type", Payment)
|
|
2168
2202
|
], Order.prototype, "payment", void 0);
|
|
2169
2203
|
|
|
2204
|
+
class OrderBlocked extends BaseModel {
|
|
2205
|
+
static get identifiersFields() {
|
|
2206
|
+
return ['id'];
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2170
2210
|
class CheckoutSubscription extends BaseModel {
|
|
2171
2211
|
static get identifiersFields() {
|
|
2172
2212
|
return ['id'];
|
|
@@ -2992,6 +3032,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2992
3032
|
try {
|
|
2993
3033
|
const identifiers = getValueFromParams(data, keyField);
|
|
2994
3034
|
const docRef = this.collection(collectionName).getDoc(identifiers.toString());
|
|
3035
|
+
if (!(await docRef.get()).data())
|
|
3036
|
+
throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
|
|
2995
3037
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
2996
3038
|
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
|
|
2997
3039
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3556,6 +3598,47 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
|
3556
3598
|
}
|
|
3557
3599
|
}
|
|
3558
3600
|
|
|
3601
|
+
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3602
|
+
constructor({ firestore, interceptors, }) {
|
|
3603
|
+
super({
|
|
3604
|
+
firestore,
|
|
3605
|
+
collectionName: 'paymentBlockedAttempts',
|
|
3606
|
+
model: OrderBlocked,
|
|
3607
|
+
interceptors,
|
|
3608
|
+
});
|
|
3609
|
+
}
|
|
3610
|
+
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3611
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3612
|
+
return this.create(OrderBlocked.toInstance({
|
|
3613
|
+
customer: {
|
|
3614
|
+
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3615
|
+
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3616
|
+
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3617
|
+
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3618
|
+
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3619
|
+
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3620
|
+
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3621
|
+
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3622
|
+
},
|
|
3623
|
+
blockType,
|
|
3624
|
+
limiteRange,
|
|
3625
|
+
type,
|
|
3626
|
+
card,
|
|
3627
|
+
checkout: {
|
|
3628
|
+
id: checkout.id,
|
|
3629
|
+
shop: checkout.shop,
|
|
3630
|
+
total: checkout.totalPrice,
|
|
3631
|
+
},
|
|
3632
|
+
date: new Date(),
|
|
3633
|
+
}));
|
|
3634
|
+
}
|
|
3635
|
+
formatZip(zip) {
|
|
3636
|
+
if (zip.length === 8)
|
|
3637
|
+
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3638
|
+
return zip;
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3559
3642
|
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3560
3643
|
constructor({ firestore, interceptors }) {
|
|
3561
3644
|
super({
|
|
@@ -4211,7 +4294,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4211
4294
|
const response = await axios__default["default"](request);
|
|
4212
4295
|
if (!lodash.isNil(response.data.errors)) {
|
|
4213
4296
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4214
|
-
throw new Error(response.data.errors);
|
|
4297
|
+
throw new Error(JSON.stringify(response.data.errors));
|
|
4215
4298
|
}
|
|
4216
4299
|
this.logger.log({ req: request, res: response.data });
|
|
4217
4300
|
return response.data.data;
|
|
@@ -4578,6 +4661,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4578
4661
|
fields: [
|
|
4579
4662
|
'id',
|
|
4580
4663
|
'description',
|
|
4664
|
+
'title',
|
|
4581
4665
|
'slug',
|
|
4582
4666
|
'enabled',
|
|
4583
4667
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4689,6 +4773,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4689
4773
|
'name',
|
|
4690
4774
|
'description',
|
|
4691
4775
|
'image',
|
|
4776
|
+
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4692
4777
|
'published',
|
|
4693
4778
|
'shop',
|
|
4694
4779
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4721,7 +4806,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4721
4806
|
filters: {
|
|
4722
4807
|
columnName: 'filters',
|
|
4723
4808
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4724
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4809
|
+
fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
|
|
4725
4810
|
bindPersistData: (value) => ({
|
|
4726
4811
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4727
4812
|
}),
|
|
@@ -4744,12 +4829,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4744
4829
|
{
|
|
4745
4830
|
metadata: {
|
|
4746
4831
|
columnName: 'metadata',
|
|
4747
|
-
fields: ['title', 'description'],
|
|
4832
|
+
fields: ['shop', 'title', 'description'],
|
|
4748
4833
|
bindPersistData: (value) => ({
|
|
4749
4834
|
metadata: { data: value },
|
|
4750
4835
|
}),
|
|
4751
4836
|
},
|
|
4752
4837
|
},
|
|
4838
|
+
{
|
|
4839
|
+
metadatas: {
|
|
4840
|
+
columnName: 'metadatas',
|
|
4841
|
+
fields: ['shop', 'title', 'description'],
|
|
4842
|
+
bindPersistData: (value) => ({
|
|
4843
|
+
metadatas: { data: value },
|
|
4844
|
+
}),
|
|
4845
|
+
},
|
|
4846
|
+
},
|
|
4753
4847
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4754
4848
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4755
4849
|
'reference',
|
|
@@ -4764,14 +4858,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4764
4858
|
'theme',
|
|
4765
4859
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4766
4860
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4861
|
+
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4767
4862
|
],
|
|
4768
4863
|
});
|
|
4769
4864
|
this.productRepository = productRepository;
|
|
4770
4865
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4771
4866
|
}
|
|
4772
4867
|
async create(params) {
|
|
4773
|
-
const {
|
|
4774
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4868
|
+
const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
4869
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
|
|
4870
|
+
[exports.Shops.GLAMSHOP]: null,
|
|
4871
|
+
[exports.Shops.MENSMARKET]: null,
|
|
4872
|
+
}, images: images || {
|
|
4873
|
+
[exports.Shops.GLAMSHOP]: {
|
|
4874
|
+
brandBanner: null,
|
|
4875
|
+
brandBannerMobile: null,
|
|
4876
|
+
image: null,
|
|
4877
|
+
},
|
|
4878
|
+
[exports.Shops.MENSMARKET]: {
|
|
4879
|
+
brandBanner: null,
|
|
4880
|
+
brandBannerMobile: null,
|
|
4881
|
+
image: null,
|
|
4882
|
+
},
|
|
4883
|
+
} }));
|
|
4775
4884
|
}
|
|
4776
4885
|
async get(identifiers) {
|
|
4777
4886
|
var _a;
|
|
@@ -4780,12 +4889,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4780
4889
|
: super.get(identifiers);
|
|
4781
4890
|
}
|
|
4782
4891
|
async update(params) {
|
|
4783
|
-
const { products, id: checkId,
|
|
4892
|
+
const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
|
|
4784
4893
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4785
4894
|
const id = await this.getId(plainData.id);
|
|
4786
4895
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4787
4896
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4788
|
-
category.
|
|
4897
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
4789
4898
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4790
4899
|
return category;
|
|
4791
4900
|
}
|
|
@@ -4881,7 +4990,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4881
4990
|
return products;
|
|
4882
4991
|
}
|
|
4883
4992
|
async getChildren(parentId) {
|
|
4884
|
-
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
4993
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
4885
4994
|
args: {
|
|
4886
4995
|
type: 'category_tree_args',
|
|
4887
4996
|
value: { parentid: parentId },
|
|
@@ -4961,23 +5070,36 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4961
5070
|
});
|
|
4962
5071
|
return plainData.products;
|
|
4963
5072
|
}
|
|
4964
|
-
async updateMetadata(categoryId, {
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
5073
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
5074
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
5075
|
+
return [];
|
|
5076
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
5077
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5078
|
+
where: {
|
|
5079
|
+
type: 'category_metadata_bool_exp',
|
|
5080
|
+
required: true,
|
|
5081
|
+
value: { category_id: { _eq: categoryId } },
|
|
5082
|
+
},
|
|
5083
|
+
});
|
|
5084
|
+
await this.mutation('insert_category_metadata', ['affected_rows'], {
|
|
5085
|
+
objects: {
|
|
5086
|
+
type: '[category_metadata_insert_input!]',
|
|
5087
|
+
required: true,
|
|
5088
|
+
value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
|
|
5089
|
+
},
|
|
5090
|
+
});
|
|
5091
|
+
return metadatas;
|
|
5092
|
+
}
|
|
5093
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
5094
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5095
|
+
where: {
|
|
5096
|
+
type: 'category_metadata_bool_exp',
|
|
5097
|
+
required: true,
|
|
5098
|
+
value: { category_id: { _eq: categoryId } },
|
|
5099
|
+
},
|
|
5100
|
+
});
|
|
5101
|
+
return [];
|
|
5102
|
+
}
|
|
4981
5103
|
}
|
|
4982
5104
|
async updateFilters(categoryId, { filters }) {
|
|
4983
5105
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5071,6 +5193,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5071
5193
|
interceptors,
|
|
5072
5194
|
fields: [
|
|
5073
5195
|
'id',
|
|
5196
|
+
'title',
|
|
5074
5197
|
'description',
|
|
5075
5198
|
'slug',
|
|
5076
5199
|
'enabled',
|
|
@@ -5458,6 +5581,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5458
5581
|
enableCount: false,
|
|
5459
5582
|
},
|
|
5460
5583
|
});
|
|
5584
|
+
if (!result.data.length)
|
|
5585
|
+
return null;
|
|
5461
5586
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5462
5587
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5463
5588
|
return product;
|
|
@@ -5811,6 +5936,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
5811
5936
|
email,
|
|
5812
5937
|
});
|
|
5813
5938
|
}
|
|
5939
|
+
async getNotificationsReport(params, orderBy, pagination) {
|
|
5940
|
+
const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.productId && { product_id: { _eq: params.productId } })), (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.categoryId && { category_id: { _eq: params.categoryId } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
|
|
5941
|
+
const orderByField = {
|
|
5942
|
+
[orderBy.field]: orderBy.direction,
|
|
5943
|
+
};
|
|
5944
|
+
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
5945
|
+
where: {
|
|
5946
|
+
type: 'report_stock_notification_bool_exp',
|
|
5947
|
+
value: query,
|
|
5948
|
+
required: true,
|
|
5949
|
+
},
|
|
5950
|
+
order_by: {
|
|
5951
|
+
type: '[report_stock_notification_order_by]',
|
|
5952
|
+
value: orderByField,
|
|
5953
|
+
required: true,
|
|
5954
|
+
},
|
|
5955
|
+
});
|
|
5956
|
+
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
5957
|
+
? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, (pagination === null || pagination === void 0 ? void 0 : pagination.offset) + (pagination === null || pagination === void 0 ? void 0 : pagination.limit))
|
|
5958
|
+
: report_stock_notification;
|
|
5959
|
+
return {
|
|
5960
|
+
data,
|
|
5961
|
+
count: report_stock_notification.length,
|
|
5962
|
+
};
|
|
5963
|
+
}
|
|
5814
5964
|
}
|
|
5815
5965
|
|
|
5816
5966
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -5919,11 +6069,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5919
6069
|
}
|
|
5920
6070
|
}
|
|
5921
6071
|
|
|
6072
|
+
class WishlistHasuraGraphQL extends Wishlist {
|
|
6073
|
+
}
|
|
6074
|
+
|
|
5922
6075
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5923
6076
|
constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
|
|
5924
6077
|
super({
|
|
5925
6078
|
tableName: 'category',
|
|
5926
|
-
model:
|
|
6079
|
+
model: WishlistHasuraGraphQL,
|
|
5927
6080
|
endpoint,
|
|
5928
6081
|
authOptions,
|
|
5929
6082
|
interceptors,
|
|
@@ -5984,7 +6137,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5984
6137
|
{
|
|
5985
6138
|
metadata: {
|
|
5986
6139
|
columnName: 'metadata',
|
|
5987
|
-
fields: ['title', 'description'],
|
|
6140
|
+
fields: ['shop', 'title', 'description'],
|
|
5988
6141
|
bindPersistData: (value) => ({
|
|
5989
6142
|
metadata: { data: value },
|
|
5990
6143
|
}),
|
|
@@ -6004,15 +6157,33 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6004
6157
|
{ personId: { columnName: 'person_id' } },
|
|
6005
6158
|
{ personName: { columnName: 'person_name' } },
|
|
6006
6159
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6160
|
+
{ personType: { columnName: 'person_type' } },
|
|
6161
|
+
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6007
6162
|
'theme',
|
|
6008
6163
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6164
|
+
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6009
6165
|
],
|
|
6010
6166
|
});
|
|
6011
6167
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6012
6168
|
}
|
|
6013
6169
|
async create(params) {
|
|
6014
|
-
|
|
6015
|
-
|
|
6170
|
+
var _a;
|
|
6171
|
+
const { images, mostRelevants, metadatas } = params, data = tslib.__rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
6172
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadatas: metadatas || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }], mostRelevants: mostRelevants || {
|
|
6173
|
+
[exports.Shops.GLAMSHOP]: null,
|
|
6174
|
+
[exports.Shops.MENSMARKET]: null,
|
|
6175
|
+
}, images: images || {
|
|
6176
|
+
[exports.Shops.GLAMSHOP]: {
|
|
6177
|
+
brandBanner: null,
|
|
6178
|
+
brandBannerMobile: null,
|
|
6179
|
+
image: null,
|
|
6180
|
+
},
|
|
6181
|
+
[exports.Shops.MENSMARKET]: {
|
|
6182
|
+
brandBanner: null,
|
|
6183
|
+
brandBannerMobile: null,
|
|
6184
|
+
image: null,
|
|
6185
|
+
},
|
|
6186
|
+
} }));
|
|
6016
6187
|
}
|
|
6017
6188
|
async get(identifiers) {
|
|
6018
6189
|
const data = await super.get(identifiers);
|
|
@@ -6025,12 +6196,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6025
6196
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
|
|
6026
6197
|
}
|
|
6027
6198
|
async update(params) {
|
|
6028
|
-
const { products, id: checkId,
|
|
6199
|
+
const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
|
|
6029
6200
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6030
6201
|
const id = plainData.id;
|
|
6031
6202
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
6032
6203
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
6033
|
-
category.
|
|
6204
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
6034
6205
|
return category;
|
|
6035
6206
|
}
|
|
6036
6207
|
async getWishlistBySlug(slug) {
|
|
@@ -6067,7 +6238,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6067
6238
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6068
6239
|
return data;
|
|
6069
6240
|
}
|
|
6070
|
-
getCategoryBySlug(slug, _shop) {
|
|
6241
|
+
async getCategoryBySlug(slug, _shop) {
|
|
6071
6242
|
return this.getWishlistBySlug(slug);
|
|
6072
6243
|
}
|
|
6073
6244
|
async getCategoryByShop(shop) {
|
|
@@ -6085,6 +6256,13 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6085
6256
|
});
|
|
6086
6257
|
return data;
|
|
6087
6258
|
}
|
|
6259
|
+
async findBfluOrGlamgirlWishlists(params, shops) {
|
|
6260
|
+
var _a, _b;
|
|
6261
|
+
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: exports.Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
|
|
6262
|
+
operator: exports.Where.IN,
|
|
6263
|
+
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6264
|
+
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6265
|
+
}
|
|
6088
6266
|
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6089
6267
|
return;
|
|
6090
6268
|
}
|
|
@@ -6135,23 +6313,40 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6135
6313
|
});
|
|
6136
6314
|
return plainData.products;
|
|
6137
6315
|
}
|
|
6138
|
-
async updateMetadata(categoryId, {
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6316
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
6317
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
6318
|
+
return [];
|
|
6319
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
6320
|
+
const metadataUpdated = [];
|
|
6321
|
+
for (const data of metadatas) {
|
|
6322
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6323
|
+
pk_columns: {
|
|
6324
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
6325
|
+
type: 'category_metadata_pk_columns_input',
|
|
6326
|
+
required: true,
|
|
6327
|
+
},
|
|
6328
|
+
_set: {
|
|
6329
|
+
value: lodash.omit(data, ['category_id', 'shop']),
|
|
6330
|
+
type: 'category_metadata_set_input',
|
|
6331
|
+
required: true,
|
|
6332
|
+
},
|
|
6333
|
+
});
|
|
6334
|
+
metadataUpdated.push(update);
|
|
6335
|
+
}
|
|
6336
|
+
return metadataUpdated;
|
|
6337
|
+
}
|
|
6338
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
6339
|
+
for (let i = 0; i < metadatas.value.length; i++) {
|
|
6340
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6341
|
+
where: {
|
|
6342
|
+
type: 'category_metadata_bool_exp',
|
|
6343
|
+
required: true,
|
|
6344
|
+
value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
|
|
6345
|
+
},
|
|
6346
|
+
});
|
|
6347
|
+
}
|
|
6348
|
+
return [];
|
|
6349
|
+
}
|
|
6155
6350
|
}
|
|
6156
6351
|
}
|
|
6157
6352
|
tslib.__decorate([
|
|
@@ -6172,6 +6367,12 @@ tslib.__decorate([
|
|
|
6172
6367
|
tslib.__metadata("design:paramtypes", [String]),
|
|
6173
6368
|
tslib.__metadata("design:returntype", Promise)
|
|
6174
6369
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6370
|
+
tslib.__decorate([
|
|
6371
|
+
Log(),
|
|
6372
|
+
tslib.__metadata("design:type", Function),
|
|
6373
|
+
tslib.__metadata("design:paramtypes", [Object, Array]),
|
|
6374
|
+
tslib.__metadata("design:returntype", Promise)
|
|
6375
|
+
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6175
6376
|
|
|
6176
6377
|
Object.defineProperty(exports, 'add', {
|
|
6177
6378
|
enumerable: true,
|
|
@@ -6347,6 +6548,8 @@ exports.Log = Log;
|
|
|
6347
6548
|
exports.Logger = Logger;
|
|
6348
6549
|
exports.NotFoundError = NotFoundError;
|
|
6349
6550
|
exports.Order = Order;
|
|
6551
|
+
exports.OrderBlocked = OrderBlocked;
|
|
6552
|
+
exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
|
|
6350
6553
|
exports.OrderFirestoreRepository = OrderFirestoreRepository;
|
|
6351
6554
|
exports.Payment = Payment;
|
|
6352
6555
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|