@infrab4a/connect 5.4.0-beta.9 → 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 -529
- package/index.esm.js +14 -522
- 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/models/index.d.ts +0 -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/models/product-catalog-hasura-graphql.d.ts +0 -16
- package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +0 -22
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) };
|
|
@@ -5851,9 +5851,6 @@ tslib.__decorate([
|
|
|
5851
5851
|
tslib.__metadata("design:type", Product)
|
|
5852
5852
|
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
5853
5853
|
|
|
5854
|
-
class ProductCatalogHasuraGraphQL extends Product {
|
|
5855
|
-
}
|
|
5856
|
-
|
|
5857
5854
|
class ProductHasuraGraphQL extends Product {
|
|
5858
5855
|
}
|
|
5859
5856
|
tslib.__decorate([
|
|
@@ -7219,300 +7216,6 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
|
|
|
7219
7216
|
}
|
|
7220
7217
|
}
|
|
7221
7218
|
|
|
7222
|
-
const commonFields$1 = [
|
|
7223
|
-
{
|
|
7224
|
-
id: {
|
|
7225
|
-
columnName: 'id',
|
|
7226
|
-
to: (value) => +value,
|
|
7227
|
-
from: (value) => value.toString(),
|
|
7228
|
-
},
|
|
7229
|
-
},
|
|
7230
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
7231
|
-
{ productId: { columnName: 'main_product_id' } },
|
|
7232
|
-
{ CEST: { columnName: 'cest' } },
|
|
7233
|
-
{ EAN: { columnName: 'ean' } },
|
|
7234
|
-
{ NCM: { columnName: 'ncm' } },
|
|
7235
|
-
'brand',
|
|
7236
|
-
{ costPrice: { columnName: 'cost_price' } },
|
|
7237
|
-
{
|
|
7238
|
-
description: {
|
|
7239
|
-
columnName: 'description',
|
|
7240
|
-
from: (description, data) => ({
|
|
7241
|
-
description,
|
|
7242
|
-
differentials: data.differentials,
|
|
7243
|
-
whoMustUse: data.who_must_use,
|
|
7244
|
-
howToUse: data.how_to_use,
|
|
7245
|
-
brand: data.brand_description,
|
|
7246
|
-
ingredients: data.ingredients,
|
|
7247
|
-
purpose: data.purpose,
|
|
7248
|
-
}),
|
|
7249
|
-
bindFindFilter: (filters) => {
|
|
7250
|
-
return {
|
|
7251
|
-
...(filters?.description && { description: filters.description }),
|
|
7252
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
7253
|
-
...(filters.whoMustUse && {
|
|
7254
|
-
who_must_use: filters.whoMustUse,
|
|
7255
|
-
}),
|
|
7256
|
-
...(filters.howToUse && {
|
|
7257
|
-
how_to_use: filters.howToUse,
|
|
7258
|
-
}),
|
|
7259
|
-
...(filters.brand && {
|
|
7260
|
-
brand_description: filters.brand,
|
|
7261
|
-
}),
|
|
7262
|
-
...(filters.ingredients && {
|
|
7263
|
-
ingredients: filters.ingredients,
|
|
7264
|
-
}),
|
|
7265
|
-
...(filters.purpose && {
|
|
7266
|
-
purpose: filters.purpose,
|
|
7267
|
-
}),
|
|
7268
|
-
};
|
|
7269
|
-
},
|
|
7270
|
-
bindPersistData: (descriptionData) => ({
|
|
7271
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
7272
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
7273
|
-
...(descriptionData.whoMustUse && {
|
|
7274
|
-
who_must_use: descriptionData.whoMustUse,
|
|
7275
|
-
}),
|
|
7276
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
7277
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
7278
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
7279
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
7280
|
-
}),
|
|
7281
|
-
},
|
|
7282
|
-
},
|
|
7283
|
-
{ differentials: { columnName: 'differentials' } },
|
|
7284
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
7285
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
7286
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
7287
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
7288
|
-
{ purpose: { columnName: 'purpose' } },
|
|
7289
|
-
{ hasVariants: { columnName: 'has_variants' } },
|
|
7290
|
-
{
|
|
7291
|
-
images: {
|
|
7292
|
-
columnName: 'images',
|
|
7293
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7294
|
-
},
|
|
7295
|
-
},
|
|
7296
|
-
{
|
|
7297
|
-
miniatures: {
|
|
7298
|
-
columnName: 'miniatures',
|
|
7299
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7300
|
-
},
|
|
7301
|
-
},
|
|
7302
|
-
{
|
|
7303
|
-
imagesCard: {
|
|
7304
|
-
columnName: 'images_card',
|
|
7305
|
-
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7306
|
-
},
|
|
7307
|
-
},
|
|
7308
|
-
'name',
|
|
7309
|
-
{
|
|
7310
|
-
price: {
|
|
7311
|
-
columnName: 'price',
|
|
7312
|
-
from: (price, data) => ({
|
|
7313
|
-
price,
|
|
7314
|
-
fullPrice: data.full_price,
|
|
7315
|
-
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
7316
|
-
fullPriceDiscountPercentage: data.full_price_discount_percentage,
|
|
7317
|
-
subscriberPrice: data.subscriber_price,
|
|
7318
|
-
}),
|
|
7319
|
-
bindFindFilter: (filters) => {
|
|
7320
|
-
return {
|
|
7321
|
-
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7322
|
-
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7323
|
-
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7324
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7325
|
-
}),
|
|
7326
|
-
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7327
|
-
subscriber_price: filters.subscriberPrice,
|
|
7328
|
-
}),
|
|
7329
|
-
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7330
|
-
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7331
|
-
}),
|
|
7332
|
-
};
|
|
7333
|
-
},
|
|
7334
|
-
bindPersistData: (priceData) => ({
|
|
7335
|
-
...(priceData?.price >= 0 && { price: priceData.price }),
|
|
7336
|
-
...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
|
|
7337
|
-
...(priceData.subscriberDiscountPercentage >= 0 && {
|
|
7338
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
7339
|
-
}),
|
|
7340
|
-
...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
7341
|
-
...(priceData.fullPriceDiscountPercentage >= 0 && {
|
|
7342
|
-
full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
|
|
7343
|
-
}),
|
|
7344
|
-
}),
|
|
7345
|
-
},
|
|
7346
|
-
},
|
|
7347
|
-
{ fullPrice: { columnName: 'full_price' } },
|
|
7348
|
-
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7349
|
-
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7350
|
-
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7351
|
-
'published',
|
|
7352
|
-
'outlet',
|
|
7353
|
-
'label',
|
|
7354
|
-
'sku',
|
|
7355
|
-
{
|
|
7356
|
-
stock: {
|
|
7357
|
-
columnName: 'stock',
|
|
7358
|
-
from: (quantity) => ({ quantity }),
|
|
7359
|
-
to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
|
|
7360
|
-
},
|
|
7361
|
-
},
|
|
7362
|
-
{ hasStock: { columnName: 'has_stock' } },
|
|
7363
|
-
'slug',
|
|
7364
|
-
'type',
|
|
7365
|
-
'video',
|
|
7366
|
-
'weight',
|
|
7367
|
-
'gender',
|
|
7368
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
7369
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7370
|
-
{ isKit: { columnName: 'is_kit' } },
|
|
7371
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
7372
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
7373
|
-
{ rate: { columnName: 'rating' } },
|
|
7374
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
7375
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
7376
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
7377
|
-
{
|
|
7378
|
-
category: {
|
|
7379
|
-
columnName: 'category',
|
|
7380
|
-
foreignKeyColumn: { id: 'categoryId' },
|
|
7381
|
-
fields: ['id', 'name', 'reference', 'slug'],
|
|
7382
|
-
},
|
|
7383
|
-
},
|
|
7384
|
-
'group',
|
|
7385
|
-
'validity',
|
|
7386
|
-
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7387
|
-
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7388
|
-
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7389
|
-
{ showVariants: { columnName: 'show_variants' } },
|
|
7390
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7391
|
-
];
|
|
7392
|
-
class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7393
|
-
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
7394
|
-
super({
|
|
7395
|
-
tableName: 'product_catalog',
|
|
7396
|
-
model: ProductCatalogHasuraGraphQL,
|
|
7397
|
-
endpoint,
|
|
7398
|
-
authOptions,
|
|
7399
|
-
interceptors,
|
|
7400
|
-
fields: commonFields$1,
|
|
7401
|
-
cache,
|
|
7402
|
-
});
|
|
7403
|
-
}
|
|
7404
|
-
async get({ id }, options) {
|
|
7405
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7406
|
-
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7407
|
-
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7408
|
-
if (cachedData) {
|
|
7409
|
-
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7410
|
-
return this.model.toInstance(deserialize(cachedData));
|
|
7411
|
-
}
|
|
7412
|
-
}
|
|
7413
|
-
const product = await super
|
|
7414
|
-
.find({
|
|
7415
|
-
filters: {
|
|
7416
|
-
id,
|
|
7417
|
-
},
|
|
7418
|
-
limits: {
|
|
7419
|
-
limit: 1,
|
|
7420
|
-
},
|
|
7421
|
-
})
|
|
7422
|
-
.then((res) => res.data.at(0));
|
|
7423
|
-
if (!product)
|
|
7424
|
-
throw new NotFoundError(`Product not found`);
|
|
7425
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7426
|
-
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7427
|
-
await this.cache.cacheAdapter.set({
|
|
7428
|
-
key: cacheKey,
|
|
7429
|
-
data: serialize(product),
|
|
7430
|
-
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7431
|
-
});
|
|
7432
|
-
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7433
|
-
}
|
|
7434
|
-
return product;
|
|
7435
|
-
}
|
|
7436
|
-
async getByEAN(EAN, options) {
|
|
7437
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7438
|
-
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7439
|
-
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7440
|
-
if (cachedData) {
|
|
7441
|
-
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7442
|
-
return this.model.toInstance(deserialize(cachedData));
|
|
7443
|
-
}
|
|
7444
|
-
}
|
|
7445
|
-
const product = await super
|
|
7446
|
-
.find({
|
|
7447
|
-
filters: {
|
|
7448
|
-
EAN,
|
|
7449
|
-
},
|
|
7450
|
-
limits: {
|
|
7451
|
-
limit: 1,
|
|
7452
|
-
},
|
|
7453
|
-
})
|
|
7454
|
-
.then((res) => res.data.at(0));
|
|
7455
|
-
if (!product)
|
|
7456
|
-
return null;
|
|
7457
|
-
RoundProductPricesHelper.roundProductPrices(product);
|
|
7458
|
-
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7459
|
-
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7460
|
-
await this.cache.cacheAdapter.set({
|
|
7461
|
-
key: cacheKey,
|
|
7462
|
-
data: serialize(product),
|
|
7463
|
-
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7464
|
-
});
|
|
7465
|
-
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7466
|
-
}
|
|
7467
|
-
return product;
|
|
7468
|
-
}
|
|
7469
|
-
async find(params, optionsParams) {
|
|
7470
|
-
const { filters, fields, ...options } = params || {};
|
|
7471
|
-
const bindFields = fields ||
|
|
7472
|
-
this.fields
|
|
7473
|
-
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
7474
|
-
.filter((field) => field !== 'reviews' && field !== 'categories');
|
|
7475
|
-
if (options.options?.minimal?.includes('price'))
|
|
7476
|
-
options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7477
|
-
if (options.options?.maximum?.includes('price'))
|
|
7478
|
-
options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7479
|
-
options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
|
|
7480
|
-
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
7481
|
-
return super.find({
|
|
7482
|
-
...options,
|
|
7483
|
-
filters: { ...filters },
|
|
7484
|
-
fields: [
|
|
7485
|
-
...bindFields,
|
|
7486
|
-
...(bindFields.includes('price')
|
|
7487
|
-
? [
|
|
7488
|
-
'subscriberPrice',
|
|
7489
|
-
'subscriberDiscountPercentage',
|
|
7490
|
-
'fullPrice',
|
|
7491
|
-
]
|
|
7492
|
-
: []),
|
|
7493
|
-
],
|
|
7494
|
-
}, optionsParams);
|
|
7495
|
-
}
|
|
7496
|
-
async findCatalog(params, mainGender, options) {
|
|
7497
|
-
const result = await this.find({
|
|
7498
|
-
...params,
|
|
7499
|
-
filters: { ...params.filters, published: true },
|
|
7500
|
-
orderBy: {
|
|
7501
|
-
hasStock: 'desc',
|
|
7502
|
-
...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
|
|
7503
|
-
...lodash.omit(params.orderBy, ['hasStock', 'intGender']),
|
|
7504
|
-
},
|
|
7505
|
-
}, options);
|
|
7506
|
-
return result;
|
|
7507
|
-
}
|
|
7508
|
-
}
|
|
7509
|
-
tslib.__decorate([
|
|
7510
|
-
Log(),
|
|
7511
|
-
tslib.__metadata("design:type", Function),
|
|
7512
|
-
tslib.__metadata("design:paramtypes", [Object, Object, Object]),
|
|
7513
|
-
tslib.__metadata("design:returntype", Promise)
|
|
7514
|
-
], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
|
|
7515
|
-
|
|
7516
7219
|
class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7517
7220
|
constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
|
|
7518
7221
|
super({
|
|
@@ -7756,8 +7459,6 @@ const commonFields = [
|
|
|
7756
7459
|
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7757
7460
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7758
7461
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7759
|
-
{ showVariants: { columnName: 'show_variants' } },
|
|
7760
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7761
7462
|
];
|
|
7762
7463
|
const fieldsConfiguration$2 = [
|
|
7763
7464
|
...commonFields,
|
|
@@ -7821,61 +7522,9 @@ const fieldsConfiguration$2 = [
|
|
|
7821
7522
|
foreignKeyColumn: { product_id: 'id' },
|
|
7822
7523
|
fields: [
|
|
7823
7524
|
'id',
|
|
7824
|
-
'name',
|
|
7825
7525
|
'ean',
|
|
7826
7526
|
'sku',
|
|
7827
|
-
|
|
7828
|
-
description: {
|
|
7829
|
-
columnName: 'description',
|
|
7830
|
-
from: (description, data) => ({
|
|
7831
|
-
description,
|
|
7832
|
-
differentials: data.differentials,
|
|
7833
|
-
whoMustUse: data.who_must_use,
|
|
7834
|
-
howToUse: data.how_to_use,
|
|
7835
|
-
brand: data.brand_description,
|
|
7836
|
-
ingredients: data.ingredients,
|
|
7837
|
-
purpose: data.purpose,
|
|
7838
|
-
}),
|
|
7839
|
-
bindFindFilter: (filters) => {
|
|
7840
|
-
return {
|
|
7841
|
-
...(filters?.description && { description: filters.description }),
|
|
7842
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
7843
|
-
...(filters.whoMustUse && {
|
|
7844
|
-
who_must_use: filters.whoMustUse,
|
|
7845
|
-
}),
|
|
7846
|
-
...(filters.howToUse && {
|
|
7847
|
-
how_to_use: filters.howToUse,
|
|
7848
|
-
}),
|
|
7849
|
-
...(filters.brand && {
|
|
7850
|
-
brand_description: filters.brand,
|
|
7851
|
-
}),
|
|
7852
|
-
...(filters.ingredients && {
|
|
7853
|
-
ingredients: filters.ingredients,
|
|
7854
|
-
}),
|
|
7855
|
-
...(filters.purpose && {
|
|
7856
|
-
purpose: filters.purpose,
|
|
7857
|
-
}),
|
|
7858
|
-
};
|
|
7859
|
-
},
|
|
7860
|
-
bindPersistData: (descriptionData) => ({
|
|
7861
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
7862
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
7863
|
-
...(descriptionData.whoMustUse && {
|
|
7864
|
-
who_must_use: descriptionData.whoMustUse,
|
|
7865
|
-
}),
|
|
7866
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
7867
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
7868
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
7869
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
7870
|
-
}),
|
|
7871
|
-
},
|
|
7872
|
-
},
|
|
7873
|
-
{ differentials: { columnName: 'differentials' } },
|
|
7874
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
7875
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
7876
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
7877
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
7878
|
-
{ purpose: { columnName: 'purpose' } },
|
|
7527
|
+
'description',
|
|
7879
7528
|
{
|
|
7880
7529
|
grade: {
|
|
7881
7530
|
columnName: 'grade',
|
|
@@ -7921,6 +7570,10 @@ const fieldsConfiguration$2 = [
|
|
|
7921
7570
|
}),
|
|
7922
7571
|
},
|
|
7923
7572
|
},
|
|
7573
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
7574
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
7575
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
7576
|
+
{ fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
|
|
7924
7577
|
'published',
|
|
7925
7578
|
{
|
|
7926
7579
|
stock: {
|
|
@@ -7949,29 +7602,6 @@ const fieldsConfiguration$2 = [
|
|
|
7949
7602
|
},
|
|
7950
7603
|
{ tagsProfile: { columnName: 'tags_profile' } },
|
|
7951
7604
|
{ tagsCollection: { columnName: 'tags_collection' } },
|
|
7952
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7953
|
-
{
|
|
7954
|
-
reviews: {
|
|
7955
|
-
columnName: 'reviews',
|
|
7956
|
-
foreignKeyColumn: { product_id: 'id' },
|
|
7957
|
-
fields: [
|
|
7958
|
-
'id',
|
|
7959
|
-
'shop',
|
|
7960
|
-
'rate',
|
|
7961
|
-
'author',
|
|
7962
|
-
'email',
|
|
7963
|
-
'location',
|
|
7964
|
-
'review',
|
|
7965
|
-
'status',
|
|
7966
|
-
'title',
|
|
7967
|
-
{ personId: { columnName: 'person_id' } },
|
|
7968
|
-
'points',
|
|
7969
|
-
{ orderId: { columnName: 'order_id' } },
|
|
7970
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
7971
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
7972
|
-
],
|
|
7973
|
-
},
|
|
7974
|
-
},
|
|
7975
7605
|
],
|
|
7976
7606
|
},
|
|
7977
7607
|
},
|
|
@@ -8037,12 +7667,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8037
7667
|
: await super.get(identifiers, options);
|
|
8038
7668
|
if (product.productId)
|
|
8039
7669
|
throw new NotFoundError('Product not found, it is a variant');
|
|
8040
|
-
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id,
|
|
8041
|
-
if (!product.variants?.length) {
|
|
8042
|
-
for (const [index, variant] of product.variants.entries()) {
|
|
8043
|
-
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8044
|
-
}
|
|
8045
|
-
}
|
|
7670
|
+
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
|
|
8046
7671
|
return product;
|
|
8047
7672
|
}
|
|
8048
7673
|
async find(params, optionsParams) {
|
|
@@ -8059,7 +7684,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8059
7684
|
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
8060
7685
|
return super.find({
|
|
8061
7686
|
...options,
|
|
8062
|
-
filters: { ...filters },
|
|
7687
|
+
filters: { ...filters, productId: { operator: exports.Where.ISNULL } },
|
|
8063
7688
|
fields: [
|
|
8064
7689
|
...bindFields,
|
|
8065
7690
|
...(bindFields.includes('price')
|
|
@@ -8084,9 +7709,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8084
7709
|
const result = await this.find({
|
|
8085
7710
|
filters: {
|
|
8086
7711
|
slug,
|
|
8087
|
-
productId: {
|
|
8088
|
-
operator: exports.Where.ISNULL,
|
|
8089
|
-
},
|
|
8090
7712
|
},
|
|
8091
7713
|
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
8092
7714
|
options: {
|
|
@@ -8096,11 +7718,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8096
7718
|
if (!result.data.length)
|
|
8097
7719
|
return null;
|
|
8098
7720
|
const product = result?.data?.shift();
|
|
8099
|
-
if (!product.variants?.length) {
|
|
8100
|
-
for (const [index, variant] of product.variants.entries()) {
|
|
8101
|
-
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8102
|
-
}
|
|
8103
|
-
}
|
|
8104
7721
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
8105
7722
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
8106
7723
|
const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
|
|
@@ -8302,7 +7919,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8302
7919
|
return data?.[0]?.id;
|
|
8303
7920
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
8304
7921
|
}
|
|
8305
|
-
async findReviewsByProduct(productId,
|
|
7922
|
+
async findReviewsByProduct(productId, options) {
|
|
8306
7923
|
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
8307
7924
|
const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
|
|
8308
7925
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
@@ -8315,16 +7932,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8315
7932
|
where: {
|
|
8316
7933
|
value: {
|
|
8317
7934
|
product_id: { _eq: productId },
|
|
8318
|
-
...(onlyApproved && { status: { _eq: true } }),
|
|
8319
7935
|
},
|
|
8320
7936
|
type: 'product_review_bool_exp',
|
|
8321
7937
|
required: true,
|
|
8322
7938
|
},
|
|
8323
|
-
order_by: {
|
|
8324
|
-
type: '[product_review_order_by]',
|
|
8325
|
-
value: [{ createdAt: 'desc' }],
|
|
8326
|
-
required: true,
|
|
8327
|
-
},
|
|
8328
7939
|
});
|
|
8329
7940
|
const reviews = data?.map((review) => this.bindReviewToModel(review));
|
|
8330
7941
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
|
|
@@ -8429,7 +8040,7 @@ tslib.__decorate([
|
|
|
8429
8040
|
tslib.__decorate([
|
|
8430
8041
|
Log(),
|
|
8431
8042
|
tslib.__metadata("design:type", Function),
|
|
8432
|
-
tslib.__metadata("design:paramtypes", [Number,
|
|
8043
|
+
tslib.__metadata("design:paramtypes", [Number, Object]),
|
|
8433
8044
|
tslib.__metadata("design:returntype", Promise)
|
|
8434
8045
|
], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
|
|
8435
8046
|
|
|
@@ -8677,106 +8288,6 @@ const fieldsConfiguration$1 = [
|
|
|
8677
8288
|
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
8678
8289
|
},
|
|
8679
8290
|
},
|
|
8680
|
-
'slug',
|
|
8681
|
-
'brand',
|
|
8682
|
-
'name',
|
|
8683
|
-
'sku',
|
|
8684
|
-
{ NCM: { columnName: 'ncm' } },
|
|
8685
|
-
{ CEST: { columnName: 'cest' } },
|
|
8686
|
-
{
|
|
8687
|
-
description: {
|
|
8688
|
-
columnName: 'description',
|
|
8689
|
-
from: (description, data) => ({
|
|
8690
|
-
description,
|
|
8691
|
-
differentials: data.differentials,
|
|
8692
|
-
whoMustUse: data.who_must_use,
|
|
8693
|
-
howToUse: data.how_to_use,
|
|
8694
|
-
brand: data.brand_description,
|
|
8695
|
-
ingredients: data.ingredients,
|
|
8696
|
-
purpose: data.purpose,
|
|
8697
|
-
}),
|
|
8698
|
-
bindFindFilter: (filters) => {
|
|
8699
|
-
return {
|
|
8700
|
-
...(filters?.description && { description: filters.description }),
|
|
8701
|
-
...(filters.differentials && { differentials: filters.differentials }),
|
|
8702
|
-
...(filters.whoMustUse && {
|
|
8703
|
-
who_must_use: filters.whoMustUse,
|
|
8704
|
-
}),
|
|
8705
|
-
...(filters.howToUse && {
|
|
8706
|
-
how_to_use: filters.howToUse,
|
|
8707
|
-
}),
|
|
8708
|
-
...(filters.brand && {
|
|
8709
|
-
brand_description: filters.brand,
|
|
8710
|
-
}),
|
|
8711
|
-
...(filters.ingredients && {
|
|
8712
|
-
ingredients: filters.ingredients,
|
|
8713
|
-
}),
|
|
8714
|
-
...(filters.purpose && {
|
|
8715
|
-
purpose: filters.purpose,
|
|
8716
|
-
}),
|
|
8717
|
-
};
|
|
8718
|
-
},
|
|
8719
|
-
bindPersistData: (descriptionData) => ({
|
|
8720
|
-
...(descriptionData?.description && { description: descriptionData.description }),
|
|
8721
|
-
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
8722
|
-
...(descriptionData.whoMustUse && {
|
|
8723
|
-
who_must_use: descriptionData.whoMustUse,
|
|
8724
|
-
}),
|
|
8725
|
-
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
8726
|
-
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
8727
|
-
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
8728
|
-
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
8729
|
-
}),
|
|
8730
|
-
},
|
|
8731
|
-
},
|
|
8732
|
-
{ differentials: { columnName: 'differentials' } },
|
|
8733
|
-
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
8734
|
-
{ howToUse: { columnName: 'how_to_use' } },
|
|
8735
|
-
{ brandDescription: { columnName: 'brand_description' } },
|
|
8736
|
-
{ ingredients: { columnName: 'ingredients' } },
|
|
8737
|
-
{ purpose: { columnName: 'purpose' } },
|
|
8738
|
-
'gender',
|
|
8739
|
-
{ intGender: { columnName: 'int_gender' } },
|
|
8740
|
-
'label',
|
|
8741
|
-
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
8742
|
-
{ rate: { columnName: 'rating' } },
|
|
8743
|
-
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
8744
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
8745
|
-
{ categoryId: { columnName: 'category_id' } },
|
|
8746
|
-
{
|
|
8747
|
-
metadata: {
|
|
8748
|
-
columnName: 'metadata',
|
|
8749
|
-
fields: ['title', 'description'],
|
|
8750
|
-
bindPersistData: (value) => ({
|
|
8751
|
-
metadata: { data: value },
|
|
8752
|
-
}),
|
|
8753
|
-
},
|
|
8754
|
-
},
|
|
8755
|
-
{
|
|
8756
|
-
reviews: {
|
|
8757
|
-
columnName: 'reviews',
|
|
8758
|
-
foreignKeyColumn: { product_id: 'id' },
|
|
8759
|
-
fields: [
|
|
8760
|
-
'id',
|
|
8761
|
-
'shop',
|
|
8762
|
-
'rate',
|
|
8763
|
-
'author',
|
|
8764
|
-
'email',
|
|
8765
|
-
'location',
|
|
8766
|
-
'review',
|
|
8767
|
-
'status',
|
|
8768
|
-
'title',
|
|
8769
|
-
{ personId: { columnName: 'person_id' } },
|
|
8770
|
-
'points',
|
|
8771
|
-
{ orderId: { columnName: 'order_id' } },
|
|
8772
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
8773
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
8774
|
-
],
|
|
8775
|
-
},
|
|
8776
|
-
},
|
|
8777
|
-
{ variantSlug: { columnName: 'variant_slug' } },
|
|
8778
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
8779
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
8780
8291
|
];
|
|
8781
8292
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
8782
8293
|
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
@@ -8817,37 +8328,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8817
8328
|
return data.at(0);
|
|
8818
8329
|
}
|
|
8819
8330
|
async update(params) {
|
|
8820
|
-
const { productId, id: checkId,
|
|
8331
|
+
const { productId, id: checkId, ...data } = params;
|
|
8821
8332
|
const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
|
|
8822
8333
|
if (!dataWithProductId.id) {
|
|
8823
8334
|
throw new NotFoundError('Variant ID is required for update');
|
|
8824
8335
|
}
|
|
8825
8336
|
const id = await this.getId(dataWithProductId.id);
|
|
8826
8337
|
const product = await super.update({ id, ...data });
|
|
8827
|
-
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
8828
8338
|
if (dataWithProductId.productId) {
|
|
8829
8339
|
product.productId = dataWithProductId.productId;
|
|
8830
8340
|
}
|
|
8831
8341
|
return product;
|
|
8832
8342
|
}
|
|
8833
|
-
async updateMetadata(productId, { metadata }) {
|
|
8834
|
-
const plainData = this.paramsToPlain({ metadata });
|
|
8835
|
-
if (!plainData.metadata)
|
|
8836
|
-
return null;
|
|
8837
|
-
await this.mutation('update_product_metadata_by_pk', ['product_id'], {
|
|
8838
|
-
pk_columns: {
|
|
8839
|
-
value: { product_id: productId },
|
|
8840
|
-
type: 'product_metadata_pk_columns_input',
|
|
8841
|
-
required: true,
|
|
8842
|
-
},
|
|
8843
|
-
_set: {
|
|
8844
|
-
value: lodash.omit(metadata, ['product_id']),
|
|
8845
|
-
type: 'product_metadata_set_input',
|
|
8846
|
-
required: true,
|
|
8847
|
-
},
|
|
8848
|
-
});
|
|
8849
|
-
return plainData.metadata;
|
|
8850
|
-
}
|
|
8851
8343
|
async getId(id) {
|
|
8852
8344
|
if (!Number.isNaN(+id))
|
|
8853
8345
|
return id;
|
|
@@ -10227,14 +9719,6 @@ Object.defineProperty(exports, 'formatInTimeZone', {
|
|
|
10227
9719
|
enumerable: true,
|
|
10228
9720
|
get: function () { return dateFnsTz.formatInTimeZone; }
|
|
10229
9721
|
});
|
|
10230
|
-
Object.defineProperty(exports, 'fromZonedTime', {
|
|
10231
|
-
enumerable: true,
|
|
10232
|
-
get: function () { return dateFnsTz.fromZonedTime; }
|
|
10233
|
-
});
|
|
10234
|
-
Object.defineProperty(exports, 'toZonedTime', {
|
|
10235
|
-
enumerable: true,
|
|
10236
|
-
get: function () { return dateFnsTz.toZonedTime; }
|
|
10237
|
-
});
|
|
10238
9722
|
Object.defineProperty(exports, 'chunk', {
|
|
10239
9723
|
enumerable: true,
|
|
10240
9724
|
get: function () { return lodash.chunk; }
|
|
@@ -10399,8 +9883,6 @@ exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
|
10399
9883
|
exports.PaymentProviderFactory = PaymentProviderFactory;
|
|
10400
9884
|
exports.PaymentTransaction = PaymentTransaction;
|
|
10401
9885
|
exports.Product = Product;
|
|
10402
|
-
exports.ProductCatalogHasuraGraphQL = ProductCatalogHasuraGraphQL;
|
|
10403
|
-
exports.ProductCatalogHasuraGraphQLRepository = ProductCatalogHasuraGraphQLRepository;
|
|
10404
9886
|
exports.ProductErrors = ProductErrors;
|
|
10405
9887
|
exports.ProductErrorsHasuraGraphQL = ProductErrorsHasuraGraphQL;
|
|
10406
9888
|
exports.ProductErrorsHasuraGraphQLRepository = ProductErrorsHasuraGraphQLRepository;
|