@infrab4a/connect 5.4.0-beta.8 → 5.4.1-beta.0
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 +11 -505
- package/index.esm.js +14 -499
- package/package.json +3 -3
- package/src/domain/catalog/models/product-base.d.ts +0 -1
- package/src/domain/catalog/models/product.d.ts +0 -1
- package/src/domain/catalog/repositories/index.d.ts +0 -1
- package/src/domain/shopping/models/order.d.ts +7 -1
- package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +0 -1
- package/src/utils/index.d.ts +2 -2
- package/src/domain/catalog/repositories/product-catalog.repository.d.ts +0 -17
- package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +0 -20
package/index.cjs.js
CHANGED
|
@@ -1815,7 +1815,7 @@ class AntifraudCardService {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
getTodayDateRange() {
|
|
1817
1817
|
const timeZone = 'America/Sao_Paulo';
|
|
1818
|
-
const today = dateFnsTz.
|
|
1818
|
+
const today = dateFnsTz.utcToZonedTime(new Date(), timeZone);
|
|
1819
1819
|
const day = dateFns.startOfDay(today);
|
|
1820
1820
|
const endOfDay = dateFns.endOfDay(today);
|
|
1821
1821
|
return { day: dateFns.addHours(day, 3), endOfDay: dateFns.addHours(endOfDay, 3) };
|
|
@@ -7216,280 +7216,6 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
|
|
|
7216
7216
|
}
|
|
7217
7217
|
}
|
|
7218
7218
|
|
|
7219
|
-
const commonFields$1 = [
|
|
7220
|
-
{
|
|
7221
|
-
id: {
|
|
7222
|
-
columnName: 'id',
|
|
7223
|
-
to: (value) => +value,
|
|
7224
|
-
from: (value) => value.toString(),
|
|
7225
|
-
},
|
|
7226
|
-
},
|
|
7227
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
7228
|
-
{ productId: { columnName: 'main_product_id' } },
|
|
7229
|
-
{ CEST: { columnName: 'cest' } },
|
|
7230
|
-
{ EAN: { columnName: 'ean' } },
|
|
7231
|
-
{ NCM: { columnName: 'ncm' } },
|
|
7232
|
-
'brand',
|
|
7233
|
-
{ costPrice: { columnName: 'cost_price' } },
|
|
7234
|
-
{
|
|
7235
|
-
description: {
|
|
7236
|
-
columnName: 'description',
|
|
7237
|
-
from: (description, data) => ({
|
|
7238
|
-
description,
|
|
7239
|
-
differentials: data.differentials,
|
|
7240
|
-
whoMustUse: data.who_must_use,
|
|
7241
|
-
howToUse: data.how_to_use,
|
|
7242
|
-
brand: data.brand_description,
|
|
7243
|
-
ingredients: data.ingredients,
|
|
7244
|
-
purpose: data.purpose,
|
|
7245
|
-
}),
|
|
7246
|
-
bindFindFilter: (filters) => {
|
|
7247
|
-
return {
|
|
7248
|
-
...(filters?.description && { description: filters.description }),
|
|
7249
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
7250
|
-
...(filters.whoMustUse && {
|
|
7251
|
-
who_must_use: filters.whoMustUse,
|
|
7252
|
-
}),
|
|
7253
|
-
...(filters.howToUse && {
|
|
7254
|
-
how_to_use: filters.howToUse,
|
|
7255
|
-
}),
|
|
7256
|
-
...(filters.brand && {
|
|
7257
|
-
brand_description: filters.brand,
|
|
7258
|
-
}),
|
|
7259
|
-
...(filters.ingredients && {
|
|
7260
|
-
ingredients: filters.ingredients,
|
|
7261
|
-
}),
|
|
7262
|
-
...(filters.purpose && {
|
|
7263
|
-
purpose: filters.purpose,
|
|
7264
|
-
}),
|
|
7265
|
-
};
|
|
7266
|
-
},
|
|
7267
|
-
bindPersistData: (descriptionData) => ({
|
|
7268
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
7269
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
7270
|
-
...(descriptionData.whoMustUse && {
|
|
7271
|
-
who_must_use: descriptionData.whoMustUse,
|
|
7272
|
-
}),
|
|
7273
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
7274
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
7275
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
7276
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
7277
|
-
}),
|
|
7278
|
-
},
|
|
7279
|
-
},
|
|
7280
|
-
{ differentials: { columnName: 'differentials' } },
|
|
7281
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
7282
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
7283
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
7284
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
7285
|
-
{ purpose: { columnName: 'purpose' } },
|
|
7286
|
-
{ hasVariants: { columnName: 'has_variants' } },
|
|
7287
|
-
{
|
|
7288
|
-
images: {
|
|
7289
|
-
columnName: 'images',
|
|
7290
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7291
|
-
},
|
|
7292
|
-
},
|
|
7293
|
-
{
|
|
7294
|
-
miniatures: {
|
|
7295
|
-
columnName: 'miniatures',
|
|
7296
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7297
|
-
},
|
|
7298
|
-
},
|
|
7299
|
-
{
|
|
7300
|
-
imagesCard: {
|
|
7301
|
-
columnName: 'images_card',
|
|
7302
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7303
|
-
},
|
|
7304
|
-
},
|
|
7305
|
-
'name',
|
|
7306
|
-
{
|
|
7307
|
-
price: {
|
|
7308
|
-
columnName: 'price',
|
|
7309
|
-
from: (price, data) => ({
|
|
7310
|
-
price,
|
|
7311
|
-
fullPrice: data.full_price,
|
|
7312
|
-
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
7313
|
-
fullPriceDiscountPercentage: data.full_price_discount_percentage,
|
|
7314
|
-
subscriberPrice: data.subscriber_price,
|
|
7315
|
-
}),
|
|
7316
|
-
bindFindFilter: (filters) => {
|
|
7317
|
-
return {
|
|
7318
|
-
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7319
|
-
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7320
|
-
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7321
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7322
|
-
}),
|
|
7323
|
-
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7324
|
-
subscriber_price: filters.subscriberPrice,
|
|
7325
|
-
}),
|
|
7326
|
-
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7327
|
-
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7328
|
-
}),
|
|
7329
|
-
};
|
|
7330
|
-
},
|
|
7331
|
-
bindPersistData: (priceData) => ({
|
|
7332
|
-
...(priceData?.price >= 0 && { price: priceData.price }),
|
|
7333
|
-
...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
|
|
7334
|
-
...(priceData.subscriberDiscountPercentage >= 0 && {
|
|
7335
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
7336
|
-
}),
|
|
7337
|
-
...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
7338
|
-
...(priceData.fullPriceDiscountPercentage >= 0 && {
|
|
7339
|
-
full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
|
|
7340
|
-
}),
|
|
7341
|
-
}),
|
|
7342
|
-
},
|
|
7343
|
-
},
|
|
7344
|
-
{ fullPrice: { columnName: 'full_price' } },
|
|
7345
|
-
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7346
|
-
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7347
|
-
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7348
|
-
'published',
|
|
7349
|
-
'outlet',
|
|
7350
|
-
'label',
|
|
7351
|
-
'sku',
|
|
7352
|
-
{
|
|
7353
|
-
stock: {
|
|
7354
|
-
columnName: 'stock',
|
|
7355
|
-
from: (quantity) => ({ quantity }),
|
|
7356
|
-
to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
|
|
7357
|
-
},
|
|
7358
|
-
},
|
|
7359
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
7360
|
-
'slug',
|
|
7361
|
-
'type',
|
|
7362
|
-
'video',
|
|
7363
|
-
'weight',
|
|
7364
|
-
'gender',
|
|
7365
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
7366
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7367
|
-
{ isKit: { columnName: 'is_kit' } },
|
|
7368
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
7369
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
7370
|
-
{ rate: { columnName: 'rating' } },
|
|
7371
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
7372
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
7373
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
7374
|
-
{
|
|
7375
|
-
category: {
|
|
7376
|
-
columnName: 'category',
|
|
7377
|
-
foreignKeyColumn: { id: 'categoryId' },
|
|
7378
|
-
fields: ['id', 'name', 'reference', 'slug'],
|
|
7379
|
-
},
|
|
7380
|
-
},
|
|
7381
|
-
'group',
|
|
7382
|
-
'validity',
|
|
7383
|
-
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7384
|
-
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7385
|
-
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7386
|
-
{ showVariants: { columnName: 'show_variants' } },
|
|
7387
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7388
|
-
];
|
|
7389
|
-
class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7390
|
-
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
7391
|
-
super({
|
|
7392
|
-
tableName: 'product_catalog',
|
|
7393
|
-
model: ProductHasuraGraphQL,
|
|
7394
|
-
endpoint,
|
|
7395
|
-
authOptions,
|
|
7396
|
-
interceptors,
|
|
7397
|
-
fields: commonFields$1,
|
|
7398
|
-
cache,
|
|
7399
|
-
});
|
|
7400
|
-
}
|
|
7401
|
-
async get({ id }) {
|
|
7402
|
-
return super
|
|
7403
|
-
.find({
|
|
7404
|
-
filters: {
|
|
7405
|
-
id,
|
|
7406
|
-
},
|
|
7407
|
-
limits: {
|
|
7408
|
-
limit: 1,
|
|
7409
|
-
},
|
|
7410
|
-
})
|
|
7411
|
-
.then((res) => res.data.at(0));
|
|
7412
|
-
}
|
|
7413
|
-
async getByEAN(EAN, options) {
|
|
7414
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7415
|
-
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7416
|
-
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7417
|
-
if (cachedData) {
|
|
7418
|
-
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7419
|
-
return this.model.toInstance(deserialize(cachedData));
|
|
7420
|
-
}
|
|
7421
|
-
}
|
|
7422
|
-
const product = await super
|
|
7423
|
-
.find({
|
|
7424
|
-
filters: {
|
|
7425
|
-
EAN,
|
|
7426
|
-
},
|
|
7427
|
-
limits: {
|
|
7428
|
-
limit: 1,
|
|
7429
|
-
},
|
|
7430
|
-
})
|
|
7431
|
-
.then((res) => res.data.at(0));
|
|
7432
|
-
if (!product)
|
|
7433
|
-
return null;
|
|
7434
|
-
RoundProductPricesHelper.roundProductPrices(product);
|
|
7435
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7436
|
-
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7437
|
-
await this.cache.cacheAdapter.set({
|
|
7438
|
-
key: cacheKey,
|
|
7439
|
-
data: serialize(product),
|
|
7440
|
-
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7441
|
-
});
|
|
7442
|
-
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7443
|
-
}
|
|
7444
|
-
return product;
|
|
7445
|
-
}
|
|
7446
|
-
async find(params, optionsParams) {
|
|
7447
|
-
const { filters, fields, ...options } = params || {};
|
|
7448
|
-
const bindFields = fields ||
|
|
7449
|
-
this.fields
|
|
7450
|
-
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
7451
|
-
.filter((field) => field !== 'reviews' && field !== 'categories');
|
|
7452
|
-
if (options.options?.minimal?.includes('price'))
|
|
7453
|
-
options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7454
|
-
if (options.options?.maximum?.includes('price'))
|
|
7455
|
-
options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7456
|
-
options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
|
|
7457
|
-
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
7458
|
-
return super.find({
|
|
7459
|
-
...options,
|
|
7460
|
-
filters: { ...filters },
|
|
7461
|
-
fields: [
|
|
7462
|
-
...bindFields,
|
|
7463
|
-
...(bindFields.includes('price')
|
|
7464
|
-
? [
|
|
7465
|
-
'subscriberPrice',
|
|
7466
|
-
'subscriberDiscountPercentage',
|
|
7467
|
-
'fullPrice',
|
|
7468
|
-
]
|
|
7469
|
-
: []),
|
|
7470
|
-
],
|
|
7471
|
-
}, optionsParams);
|
|
7472
|
-
}
|
|
7473
|
-
async findCatalog(params, mainGender, options) {
|
|
7474
|
-
const result = await this.find({
|
|
7475
|
-
...params,
|
|
7476
|
-
filters: { ...params.filters, published: true },
|
|
7477
|
-
orderBy: {
|
|
7478
|
-
hasStock: 'desc',
|
|
7479
|
-
...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
|
|
7480
|
-
...lodash.omit(params.orderBy, ['hasStock', 'intGender']),
|
|
7481
|
-
},
|
|
7482
|
-
}, options);
|
|
7483
|
-
return result;
|
|
7484
|
-
}
|
|
7485
|
-
}
|
|
7486
|
-
tslib.__decorate([
|
|
7487
|
-
Log(),
|
|
7488
|
-
tslib.__metadata("design:type", Function),
|
|
7489
|
-
tslib.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
7490
|
-
tslib.__metadata("design:returntype", Promise)
|
|
7491
|
-
], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
|
|
7492
|
-
|
|
7493
7219
|
class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7494
7220
|
constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
|
|
7495
7221
|
super({
|
|
@@ -7733,8 +7459,6 @@ const commonFields = [
|
|
|
7733
7459
|
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7734
7460
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7735
7461
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7736
|
-
{ showVariants: { columnName: 'show_variants' } },
|
|
7737
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7738
7462
|
];
|
|
7739
7463
|
const fieldsConfiguration$2 = [
|
|
7740
7464
|
...commonFields,
|
|
@@ -7798,61 +7522,9 @@ const fieldsConfiguration$2 = [
|
|
|
7798
7522
|
foreignKeyColumn: { product_id: 'id' },
|
|
7799
7523
|
fields: [
|
|
7800
7524
|
'id',
|
|
7801
|
-
'name',
|
|
7802
7525
|
'ean',
|
|
7803
7526
|
'sku',
|
|
7804
|
-
|
|
7805
|
-
description: {
|
|
7806
|
-
columnName: 'description',
|
|
7807
|
-
from: (description, data) => ({
|
|
7808
|
-
description,
|
|
7809
|
-
differentials: data.differentials,
|
|
7810
|
-
whoMustUse: data.who_must_use,
|
|
7811
|
-
howToUse: data.how_to_use,
|
|
7812
|
-
brand: data.brand_description,
|
|
7813
|
-
ingredients: data.ingredients,
|
|
7814
|
-
purpose: data.purpose,
|
|
7815
|
-
}),
|
|
7816
|
-
bindFindFilter: (filters) => {
|
|
7817
|
-
return {
|
|
7818
|
-
...(filters?.description && { description: filters.description }),
|
|
7819
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
7820
|
-
...(filters.whoMustUse && {
|
|
7821
|
-
who_must_use: filters.whoMustUse,
|
|
7822
|
-
}),
|
|
7823
|
-
...(filters.howToUse && {
|
|
7824
|
-
how_to_use: filters.howToUse,
|
|
7825
|
-
}),
|
|
7826
|
-
...(filters.brand && {
|
|
7827
|
-
brand_description: filters.brand,
|
|
7828
|
-
}),
|
|
7829
|
-
...(filters.ingredients && {
|
|
7830
|
-
ingredients: filters.ingredients,
|
|
7831
|
-
}),
|
|
7832
|
-
...(filters.purpose && {
|
|
7833
|
-
purpose: filters.purpose,
|
|
7834
|
-
}),
|
|
7835
|
-
};
|
|
7836
|
-
},
|
|
7837
|
-
bindPersistData: (descriptionData) => ({
|
|
7838
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
7839
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
7840
|
-
...(descriptionData.whoMustUse && {
|
|
7841
|
-
who_must_use: descriptionData.whoMustUse,
|
|
7842
|
-
}),
|
|
7843
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
7844
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
7845
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
7846
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
7847
|
-
}),
|
|
7848
|
-
},
|
|
7849
|
-
},
|
|
7850
|
-
{ differentials: { columnName: 'differentials' } },
|
|
7851
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
7852
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
7853
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
7854
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
7855
|
-
{ purpose: { columnName: 'purpose' } },
|
|
7527
|
+
'description',
|
|
7856
7528
|
{
|
|
7857
7529
|
grade: {
|
|
7858
7530
|
columnName: 'grade',
|
|
@@ -7898,6 +7570,10 @@ const fieldsConfiguration$2 = [
|
|
|
7898
7570
|
}),
|
|
7899
7571
|
},
|
|
7900
7572
|
},
|
|
7573
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
7574
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7575
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7576
|
+
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7901
7577
|
'published',
|
|
7902
7578
|
{
|
|
7903
7579
|
stock: {
|
|
@@ -7926,29 +7602,6 @@ const fieldsConfiguration$2 = [
|
|
|
7926
7602
|
},
|
|
7927
7603
|
{ tagsProfile: { columnName: 'tags_profile' } },
|
|
7928
7604
|
{ tagsCollection: { columnName: 'tags_collection' } },
|
|
7929
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7930
|
-
{
|
|
7931
|
-
reviews: {
|
|
7932
|
-
columnName: 'reviews',
|
|
7933
|
-
foreignKeyColumn: { product_id: 'id' },
|
|
7934
|
-
fields: [
|
|
7935
|
-
'id',
|
|
7936
|
-
'shop',
|
|
7937
|
-
'rate',
|
|
7938
|
-
'author',
|
|
7939
|
-
'email',
|
|
7940
|
-
'location',
|
|
7941
|
-
'review',
|
|
7942
|
-
'status',
|
|
7943
|
-
'title',
|
|
7944
|
-
{ personId: { columnName: 'person_id' } },
|
|
7945
|
-
'points',
|
|
7946
|
-
{ orderId: { columnName: 'order_id' } },
|
|
7947
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
7948
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
7949
|
-
],
|
|
7950
|
-
},
|
|
7951
|
-
},
|
|
7952
7605
|
],
|
|
7953
7606
|
},
|
|
7954
7607
|
},
|
|
@@ -8014,12 +7667,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8014
7667
|
: await super.get(identifiers, options);
|
|
8015
7668
|
if (product.productId)
|
|
8016
7669
|
throw new NotFoundError('Product not found, it is a variant');
|
|
8017
|
-
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id,
|
|
8018
|
-
if (!product.variants?.length) {
|
|
8019
|
-
for (const [index, variant] of product.variants.entries()) {
|
|
8020
|
-
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8021
|
-
}
|
|
8022
|
-
}
|
|
7670
|
+
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
|
|
8023
7671
|
return product;
|
|
8024
7672
|
}
|
|
8025
7673
|
async find(params, optionsParams) {
|
|
@@ -8036,7 +7684,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8036
7684
|
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
8037
7685
|
return super.find({
|
|
8038
7686
|
...options,
|
|
8039
|
-
filters: { ...filters },
|
|
7687
|
+
filters: { ...filters, productId: { operator: exports.Where.ISNULL } },
|
|
8040
7688
|
fields: [
|
|
8041
7689
|
...bindFields,
|
|
8042
7690
|
...(bindFields.includes('price')
|
|
@@ -8061,9 +7709,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8061
7709
|
const result = await this.find({
|
|
8062
7710
|
filters: {
|
|
8063
7711
|
slug,
|
|
8064
|
-
productId: {
|
|
8065
|
-
operator: exports.Where.ISNULL,
|
|
8066
|
-
},
|
|
8067
7712
|
},
|
|
8068
7713
|
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
8069
7714
|
options: {
|
|
@@ -8073,11 +7718,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8073
7718
|
if (!result.data.length)
|
|
8074
7719
|
return null;
|
|
8075
7720
|
const product = result?.data?.shift();
|
|
8076
|
-
if (!product.variants?.length) {
|
|
8077
|
-
for (const [index, variant] of product.variants.entries()) {
|
|
8078
|
-
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8079
|
-
}
|
|
8080
|
-
}
|
|
8081
7721
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
8082
7722
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
8083
7723
|
const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
|
|
@@ -8279,7 +7919,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8279
7919
|
return data?.[0]?.id;
|
|
8280
7920
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
8281
7921
|
}
|
|
8282
|
-
async findReviewsByProduct(productId,
|
|
7922
|
+
async findReviewsByProduct(productId, options) {
|
|
8283
7923
|
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
8284
7924
|
const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
|
|
8285
7925
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
@@ -8292,16 +7932,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8292
7932
|
where: {
|
|
8293
7933
|
value: {
|
|
8294
7934
|
product_id: { _eq: productId },
|
|
8295
|
-
...(onlyApproved && { status: { _eq: true } }),
|
|
8296
7935
|
},
|
|
8297
7936
|
type: 'product_review_bool_exp',
|
|
8298
7937
|
required: true,
|
|
8299
7938
|
},
|
|
8300
|
-
order_by: {
|
|
8301
|
-
type: '[product_review_order_by]',
|
|
8302
|
-
value: [{ createdAt: 'desc' }],
|
|
8303
|
-
required: true,
|
|
8304
|
-
},
|
|
8305
7939
|
});
|
|
8306
7940
|
const reviews = data?.map((review) => this.bindReviewToModel(review));
|
|
8307
7941
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
|
|
@@ -8406,7 +8040,7 @@ tslib.__decorate([
|
|
|
8406
8040
|
tslib.__decorate([
|
|
8407
8041
|
Log(),
|
|
8408
8042
|
tslib.__metadata("design:type", Function),
|
|
8409
|
-
tslib.__metadata("design:paramtypes", [Number,
|
|
8043
|
+
tslib.__metadata("design:paramtypes", [Number, Object]),
|
|
8410
8044
|
tslib.__metadata("design:returntype", Promise)
|
|
8411
8045
|
], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
|
|
8412
8046
|
|
|
@@ -8654,106 +8288,6 @@ const fieldsConfiguration$1 = [
|
|
|
8654
8288
|
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
8655
8289
|
},
|
|
8656
8290
|
},
|
|
8657
|
-
'slug',
|
|
8658
|
-
'brand',
|
|
8659
|
-
'name',
|
|
8660
|
-
'sku',
|
|
8661
|
-
{ NCM: { columnName: 'ncm' } },
|
|
8662
|
-
{ CEST: { columnName: 'cest' } },
|
|
8663
|
-
{
|
|
8664
|
-
description: {
|
|
8665
|
-
columnName: 'description',
|
|
8666
|
-
from: (description, data) => ({
|
|
8667
|
-
description,
|
|
8668
|
-
differentials: data.differentials,
|
|
8669
|
-
whoMustUse: data.who_must_use,
|
|
8670
|
-
howToUse: data.how_to_use,
|
|
8671
|
-
brand: data.brand_description,
|
|
8672
|
-
ingredients: data.ingredients,
|
|
8673
|
-
purpose: data.purpose,
|
|
8674
|
-
}),
|
|
8675
|
-
bindFindFilter: (filters) => {
|
|
8676
|
-
return {
|
|
8677
|
-
...(filters?.description && { description: filters.description }),
|
|
8678
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
8679
|
-
...(filters.whoMustUse && {
|
|
8680
|
-
who_must_use: filters.whoMustUse,
|
|
8681
|
-
}),
|
|
8682
|
-
...(filters.howToUse && {
|
|
8683
|
-
how_to_use: filters.howToUse,
|
|
8684
|
-
}),
|
|
8685
|
-
...(filters.brand && {
|
|
8686
|
-
brand_description: filters.brand,
|
|
8687
|
-
}),
|
|
8688
|
-
...(filters.ingredients && {
|
|
8689
|
-
ingredients: filters.ingredients,
|
|
8690
|
-
}),
|
|
8691
|
-
...(filters.purpose && {
|
|
8692
|
-
purpose: filters.purpose,
|
|
8693
|
-
}),
|
|
8694
|
-
};
|
|
8695
|
-
},
|
|
8696
|
-
bindPersistData: (descriptionData) => ({
|
|
8697
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
8698
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
8699
|
-
...(descriptionData.whoMustUse && {
|
|
8700
|
-
who_must_use: descriptionData.whoMustUse,
|
|
8701
|
-
}),
|
|
8702
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
8703
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
8704
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
8705
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
8706
|
-
}),
|
|
8707
|
-
},
|
|
8708
|
-
},
|
|
8709
|
-
{ differentials: { columnName: 'differentials' } },
|
|
8710
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
8711
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
8712
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
8713
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
8714
|
-
{ purpose: { columnName: 'purpose' } },
|
|
8715
|
-
'gender',
|
|
8716
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
8717
|
-
'label',
|
|
8718
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
8719
|
-
{ rate: { columnName: 'rating' } },
|
|
8720
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
8721
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
8722
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
8723
|
-
{
|
|
8724
|
-
metadata: {
|
|
8725
|
-
columnName: 'metadata',
|
|
8726
|
-
fields: ['title', 'description'],
|
|
8727
|
-
bindPersistData: (value) => ({
|
|
8728
|
-
metadata: { data: value },
|
|
8729
|
-
}),
|
|
8730
|
-
},
|
|
8731
|
-
},
|
|
8732
|
-
{
|
|
8733
|
-
reviews: {
|
|
8734
|
-
columnName: 'reviews',
|
|
8735
|
-
foreignKeyColumn: { product_id: 'id' },
|
|
8736
|
-
fields: [
|
|
8737
|
-
'id',
|
|
8738
|
-
'shop',
|
|
8739
|
-
'rate',
|
|
8740
|
-
'author',
|
|
8741
|
-
'email',
|
|
8742
|
-
'location',
|
|
8743
|
-
'review',
|
|
8744
|
-
'status',
|
|
8745
|
-
'title',
|
|
8746
|
-
{ personId: { columnName: 'person_id' } },
|
|
8747
|
-
'points',
|
|
8748
|
-
{ orderId: { columnName: 'order_id' } },
|
|
8749
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
8750
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
8751
|
-
],
|
|
8752
|
-
},
|
|
8753
|
-
},
|
|
8754
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
8755
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
8756
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
8757
8291
|
];
|
|
8758
8292
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
8759
8293
|
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
@@ -8794,37 +8328,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8794
8328
|
return data.at(0);
|
|
8795
8329
|
}
|
|
8796
8330
|
async update(params) {
|
|
8797
|
-
const { productId, id: checkId,
|
|
8331
|
+
const { productId, id: checkId, ...data } = params;
|
|
8798
8332
|
const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
|
|
8799
8333
|
if (!dataWithProductId.id) {
|
|
8800
8334
|
throw new NotFoundError('Variant ID is required for update');
|
|
8801
8335
|
}
|
|
8802
8336
|
const id = await this.getId(dataWithProductId.id);
|
|
8803
8337
|
const product = await super.update({ id, ...data });
|
|
8804
|
-
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
8805
8338
|
if (dataWithProductId.productId) {
|
|
8806
8339
|
product.productId = dataWithProductId.productId;
|
|
8807
8340
|
}
|
|
8808
8341
|
return product;
|
|
8809
8342
|
}
|
|
8810
|
-
async updateMetadata(productId, { metadata }) {
|
|
8811
|
-
const plainData = this.paramsToPlain({ metadata });
|
|
8812
|
-
if (!plainData.metadata)
|
|
8813
|
-
return null;
|
|
8814
|
-
await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8815
|
-
pk_columns: {
|
|
8816
|
-
value: { product_id: productId },
|
|
8817
|
-
type: 'product_metadata_pk_columns_input',
|
|
8818
|
-
required: true,
|
|
8819
|
-
},
|
|
8820
|
-
_set: {
|
|
8821
|
-
value: lodash.omit(metadata, ['product_id']),
|
|
8822
|
-
type: 'product_metadata_set_input',
|
|
8823
|
-
required: true,
|
|
8824
|
-
},
|
|
8825
|
-
});
|
|
8826
|
-
return plainData.metadata;
|
|
8827
|
-
}
|
|
8828
8343
|
async getId(id) {
|
|
8829
8344
|
if (!Number.isNaN(+id))
|
|
8830
8345
|
return id;
|
|
@@ -10204,14 +9719,6 @@ Object.defineProperty(exports, 'formatInTimeZone', {
|
|
|
10204
9719
|
enumerable: true,
|
|
10205
9720
|
get: function () { return dateFnsTz.formatInTimeZone; }
|
|
10206
9721
|
});
|
|
10207
|
-
Object.defineProperty(exports, 'fromZonedTime', {
|
|
10208
|
-
enumerable: true,
|
|
10209
|
-
get: function () { return dateFnsTz.fromZonedTime; }
|
|
10210
|
-
});
|
|
10211
|
-
Object.defineProperty(exports, 'toZonedTime', {
|
|
10212
|
-
enumerable: true,
|
|
10213
|
-
get: function () { return dateFnsTz.toZonedTime; }
|
|
10214
|
-
});
|
|
10215
9722
|
Object.defineProperty(exports, 'chunk', {
|
|
10216
9723
|
enumerable: true,
|
|
10217
9724
|
get: function () { return lodash.chunk; }
|
|
@@ -10376,7 +9883,6 @@ exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
|
10376
9883
|
exports.PaymentProviderFactory = PaymentProviderFactory;
|
|
10377
9884
|
exports.PaymentTransaction = PaymentTransaction;
|
|
10378
9885
|
exports.Product = Product;
|
|
10379
|
-
exports.ProductCatalogHasuraGraphQLRepository = ProductCatalogHasuraGraphQLRepository;
|
|
10380
9886
|
exports.ProductErrors = ProductErrors;
|
|
10381
9887
|
exports.ProductErrorsHasuraGraphQL = ProductErrorsHasuraGraphQL;
|
|
10382
9888
|
exports.ProductErrorsHasuraGraphQLRepository = ProductErrorsHasuraGraphQLRepository;
|