@infrab4a/connect 5.3.0-beta.7 → 5.3.0-beta.8

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.esm.js CHANGED
@@ -4,7 +4,7 @@ import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
4
4
  import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
6
6
  import { utcToZonedTime } from 'date-fns-tz';
7
- export { formatInTimeZone, utcToZonedTime } from 'date-fns-tz';
7
+ export { formatInTimeZone } from 'date-fns-tz';
8
8
  import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
9
9
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
10
10
  import { debug } from 'debug';
@@ -5827,6 +5827,9 @@ __decorate([
5827
5827
  __metadata("design:type", Product)
5828
5828
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
5829
5829
 
5830
+ class ProductCatalogHasuraGraphQL extends Product {
5831
+ }
5832
+
5830
5833
  class ProductHasuraGraphQL extends Product {
5831
5834
  }
5832
5835
  __decorate([
@@ -7192,6 +7195,300 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7192
7195
  }
7193
7196
  }
7194
7197
 
7198
+ const commonFields$1 = [
7199
+ {
7200
+ id: {
7201
+ columnName: 'id',
7202
+ to: (value) => +value,
7203
+ from: (value) => value.toString(),
7204
+ },
7205
+ },
7206
+ { firestoreId: { columnName: 'firestore_id' } },
7207
+ { productId: { columnName: 'main_product_id' } },
7208
+ { CEST: { columnName: 'cest' } },
7209
+ { EAN: { columnName: 'ean' } },
7210
+ { NCM: { columnName: 'ncm' } },
7211
+ 'brand',
7212
+ { costPrice: { columnName: 'cost_price' } },
7213
+ {
7214
+ description: {
7215
+ columnName: 'description',
7216
+ from: (description, data) => ({
7217
+ description,
7218
+ differentials: data.differentials,
7219
+ whoMustUse: data.who_must_use,
7220
+ howToUse: data.how_to_use,
7221
+ brand: data.brand_description,
7222
+ ingredients: data.ingredients,
7223
+ purpose: data.purpose,
7224
+ }),
7225
+ bindFindFilter: (filters) => {
7226
+ return {
7227
+ ...(filters?.description && { description: filters.description }),
7228
+ ...(filters.differentials && { differentials: filters.differentials }),
7229
+ ...(filters.whoMustUse && {
7230
+ who_must_use: filters.whoMustUse,
7231
+ }),
7232
+ ...(filters.howToUse && {
7233
+ how_to_use: filters.howToUse,
7234
+ }),
7235
+ ...(filters.brand && {
7236
+ brand_description: filters.brand,
7237
+ }),
7238
+ ...(filters.ingredients && {
7239
+ ingredients: filters.ingredients,
7240
+ }),
7241
+ ...(filters.purpose && {
7242
+ purpose: filters.purpose,
7243
+ }),
7244
+ };
7245
+ },
7246
+ bindPersistData: (descriptionData) => ({
7247
+ ...(descriptionData?.description && { description: descriptionData.description }),
7248
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7249
+ ...(descriptionData.whoMustUse && {
7250
+ who_must_use: descriptionData.whoMustUse,
7251
+ }),
7252
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7253
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7254
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7255
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7256
+ }),
7257
+ },
7258
+ },
7259
+ { differentials: { columnName: 'differentials' } },
7260
+ { whoMustUse: { columnName: 'who_must_use' } },
7261
+ { howToUse: { columnName: 'how_to_use' } },
7262
+ { brandDescription: { columnName: 'brand_description' } },
7263
+ { ingredients: { columnName: 'ingredients' } },
7264
+ { purpose: { columnName: 'purpose' } },
7265
+ { hasVariants: { columnName: 'has_variants' } },
7266
+ {
7267
+ images: {
7268
+ columnName: 'images',
7269
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7270
+ },
7271
+ },
7272
+ {
7273
+ miniatures: {
7274
+ columnName: 'miniatures',
7275
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7276
+ },
7277
+ },
7278
+ {
7279
+ imagesCard: {
7280
+ columnName: 'images_card',
7281
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7282
+ },
7283
+ },
7284
+ 'name',
7285
+ {
7286
+ price: {
7287
+ columnName: 'price',
7288
+ from: (price, data) => ({
7289
+ price,
7290
+ fullPrice: data.full_price,
7291
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
7292
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
7293
+ subscriberPrice: data.subscriber_price,
7294
+ }),
7295
+ bindFindFilter: (filters) => {
7296
+ return {
7297
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7298
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7299
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7300
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7301
+ }),
7302
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7303
+ subscriber_price: filters.subscriberPrice,
7304
+ }),
7305
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7306
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7307
+ }),
7308
+ };
7309
+ },
7310
+ bindPersistData: (priceData) => ({
7311
+ ...(priceData?.price >= 0 && { price: priceData.price }),
7312
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7313
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
7314
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7315
+ }),
7316
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7317
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
7318
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7319
+ }),
7320
+ }),
7321
+ },
7322
+ },
7323
+ { fullPrice: { columnName: 'full_price' } },
7324
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7325
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7326
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7327
+ 'published',
7328
+ 'outlet',
7329
+ 'label',
7330
+ 'sku',
7331
+ {
7332
+ stock: {
7333
+ columnName: 'stock',
7334
+ from: (quantity) => ({ quantity }),
7335
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7336
+ },
7337
+ },
7338
+ { hasStock: { columnName: 'has_stock' } },
7339
+ 'slug',
7340
+ 'type',
7341
+ 'video',
7342
+ 'weight',
7343
+ 'gender',
7344
+ { intGender: { columnName: 'int_gender' } },
7345
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7346
+ { isKit: { columnName: 'is_kit' } },
7347
+ { createdAt: { columnName: 'created_at' } },
7348
+ { updatedAt: { columnName: 'updated_at' } },
7349
+ { rate: { columnName: 'rating' } },
7350
+ { reviewsTotal: { columnName: 'reviews_total' } },
7351
+ { shoppingCount: { columnName: 'shopping_count' } },
7352
+ { categoryId: { columnName: 'category_id' } },
7353
+ {
7354
+ category: {
7355
+ columnName: 'category',
7356
+ foreignKeyColumn: { id: 'categoryId' },
7357
+ fields: ['id', 'name', 'reference', 'slug'],
7358
+ },
7359
+ },
7360
+ 'group',
7361
+ 'validity',
7362
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7363
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7364
+ { daysOfUse: { columnName: 'days_of_use' } },
7365
+ { showVariants: { columnName: 'show_variants' } },
7366
+ { variantSlug: { columnName: 'variant_slug' } },
7367
+ ];
7368
+ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7369
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
7370
+ super({
7371
+ tableName: 'product_catalog',
7372
+ model: ProductCatalogHasuraGraphQL,
7373
+ endpoint,
7374
+ authOptions,
7375
+ interceptors,
7376
+ fields: commonFields$1,
7377
+ cache,
7378
+ });
7379
+ }
7380
+ async get({ id }, options) {
7381
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7382
+ const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7383
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7384
+ if (cachedData) {
7385
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7386
+ return this.model.toInstance(deserialize(cachedData));
7387
+ }
7388
+ }
7389
+ const product = await super
7390
+ .find({
7391
+ filters: {
7392
+ id,
7393
+ },
7394
+ limits: {
7395
+ limit: 1,
7396
+ },
7397
+ })
7398
+ .then((res) => res.data.at(0));
7399
+ if (!product)
7400
+ throw new NotFoundError(`Product not found`);
7401
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7402
+ const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7403
+ await this.cache.cacheAdapter.set({
7404
+ key: cacheKey,
7405
+ data: serialize(product),
7406
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7407
+ });
7408
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7409
+ }
7410
+ return product;
7411
+ }
7412
+ async getByEAN(EAN, options) {
7413
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7414
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7415
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7416
+ if (cachedData) {
7417
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7418
+ return this.model.toInstance(deserialize(cachedData));
7419
+ }
7420
+ }
7421
+ const product = await super
7422
+ .find({
7423
+ filters: {
7424
+ EAN,
7425
+ },
7426
+ limits: {
7427
+ limit: 1,
7428
+ },
7429
+ })
7430
+ .then((res) => res.data.at(0));
7431
+ if (!product)
7432
+ return null;
7433
+ RoundProductPricesHelper.roundProductPrices(product);
7434
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7435
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7436
+ await this.cache.cacheAdapter.set({
7437
+ key: cacheKey,
7438
+ data: serialize(product),
7439
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7440
+ });
7441
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7442
+ }
7443
+ return product;
7444
+ }
7445
+ async find(params, optionsParams) {
7446
+ const { filters, fields, ...options } = params || {};
7447
+ const bindFields = fields ||
7448
+ this.fields
7449
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7450
+ .filter((field) => field !== 'reviews' && field !== 'categories');
7451
+ if (options.options?.minimal?.includes('price'))
7452
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7453
+ if (options.options?.maximum?.includes('price'))
7454
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7455
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7456
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7457
+ return super.find({
7458
+ ...options,
7459
+ filters: { ...filters },
7460
+ fields: [
7461
+ ...bindFields,
7462
+ ...(bindFields.includes('price')
7463
+ ? [
7464
+ 'subscriberPrice',
7465
+ 'subscriberDiscountPercentage',
7466
+ 'fullPrice',
7467
+ ]
7468
+ : []),
7469
+ ],
7470
+ }, optionsParams);
7471
+ }
7472
+ async findCatalog(params, mainGender, options) {
7473
+ const result = await this.find({
7474
+ ...params,
7475
+ filters: { ...params.filters, published: true },
7476
+ orderBy: {
7477
+ hasStock: 'desc',
7478
+ ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7479
+ ...omit(params.orderBy, ['hasStock', 'intGender']),
7480
+ },
7481
+ }, options);
7482
+ return result;
7483
+ }
7484
+ }
7485
+ __decorate([
7486
+ Log(),
7487
+ __metadata("design:type", Function),
7488
+ __metadata("design:paramtypes", [Object, Object, Object]),
7489
+ __metadata("design:returntype", Promise)
7490
+ ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7491
+
7195
7492
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7196
7493
  constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7197
7494
  super({
@@ -7435,6 +7732,8 @@ const commonFields = [
7435
7732
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7436
7733
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7437
7734
  { daysOfUse: { columnName: 'days_of_use' } },
7735
+ { showVariants: { columnName: 'show_variants' } },
7736
+ { variantSlug: { columnName: 'variant_slug' } },
7438
7737
  ];
7439
7738
  const fieldsConfiguration$2 = [
7440
7739
  ...commonFields,
@@ -7498,9 +7797,61 @@ const fieldsConfiguration$2 = [
7498
7797
  foreignKeyColumn: { product_id: 'id' },
7499
7798
  fields: [
7500
7799
  'id',
7800
+ 'name',
7501
7801
  'ean',
7502
7802
  'sku',
7503
- 'description',
7803
+ {
7804
+ description: {
7805
+ columnName: 'description',
7806
+ from: (description, data) => ({
7807
+ description,
7808
+ differentials: data.differentials,
7809
+ whoMustUse: data.who_must_use,
7810
+ howToUse: data.how_to_use,
7811
+ brand: data.brand_description,
7812
+ ingredients: data.ingredients,
7813
+ purpose: data.purpose,
7814
+ }),
7815
+ bindFindFilter: (filters) => {
7816
+ return {
7817
+ ...(filters?.description && { description: filters.description }),
7818
+ ...(filters.differentials && { differentials: filters.differentials }),
7819
+ ...(filters.whoMustUse && {
7820
+ who_must_use: filters.whoMustUse,
7821
+ }),
7822
+ ...(filters.howToUse && {
7823
+ how_to_use: filters.howToUse,
7824
+ }),
7825
+ ...(filters.brand && {
7826
+ brand_description: filters.brand,
7827
+ }),
7828
+ ...(filters.ingredients && {
7829
+ ingredients: filters.ingredients,
7830
+ }),
7831
+ ...(filters.purpose && {
7832
+ purpose: filters.purpose,
7833
+ }),
7834
+ };
7835
+ },
7836
+ bindPersistData: (descriptionData) => ({
7837
+ ...(descriptionData?.description && { description: descriptionData.description }),
7838
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7839
+ ...(descriptionData.whoMustUse && {
7840
+ who_must_use: descriptionData.whoMustUse,
7841
+ }),
7842
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7843
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7844
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7845
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7846
+ }),
7847
+ },
7848
+ },
7849
+ { differentials: { columnName: 'differentials' } },
7850
+ { whoMustUse: { columnName: 'who_must_use' } },
7851
+ { howToUse: { columnName: 'how_to_use' } },
7852
+ { brandDescription: { columnName: 'brand_description' } },
7853
+ { ingredients: { columnName: 'ingredients' } },
7854
+ { purpose: { columnName: 'purpose' } },
7504
7855
  {
7505
7856
  grade: {
7506
7857
  columnName: 'grade',
@@ -7546,6 +7897,10 @@ const fieldsConfiguration$2 = [
7546
7897
  }),
7547
7898
  },
7548
7899
  },
7900
+ { fullPrice: { columnName: 'full_price' } },
7901
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7902
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7903
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7549
7904
  'published',
7550
7905
  {
7551
7906
  stock: {
@@ -7574,6 +7929,29 @@ const fieldsConfiguration$2 = [
7574
7929
  },
7575
7930
  { tagsProfile: { columnName: 'tags_profile' } },
7576
7931
  { tagsCollection: { columnName: 'tags_collection' } },
7932
+ { variantSlug: { columnName: 'variant_slug' } },
7933
+ {
7934
+ reviews: {
7935
+ columnName: 'reviews',
7936
+ foreignKeyColumn: { product_id: 'id' },
7937
+ fields: [
7938
+ 'id',
7939
+ 'shop',
7940
+ 'rate',
7941
+ 'author',
7942
+ 'email',
7943
+ 'location',
7944
+ 'review',
7945
+ 'status',
7946
+ 'title',
7947
+ { personId: { columnName: 'person_id' } },
7948
+ 'points',
7949
+ { orderId: { columnName: 'order_id' } },
7950
+ { createdAt: { columnName: 'created_at' } },
7951
+ { updatedAt: { columnName: 'updated_at' } },
7952
+ ],
7953
+ },
7954
+ },
7577
7955
  ],
7578
7956
  },
7579
7957
  },
@@ -7639,7 +8017,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7639
8017
  : await super.get(identifiers, options);
7640
8018
  if (product.productId)
7641
8019
  throw new NotFoundError('Product not found, it is a variant');
7642
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
8020
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
8021
+ if (!product.variants?.length) {
8022
+ for (const [index, variant] of product.variants.entries()) {
8023
+ product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8024
+ }
8025
+ }
7643
8026
  return product;
7644
8027
  }
7645
8028
  async find(params, optionsParams) {
@@ -7656,7 +8039,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7656
8039
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7657
8040
  return super.find({
7658
8041
  ...options,
7659
- filters: { ...filters, productId: { operator: Where.ISNULL } },
8042
+ filters: { ...filters },
7660
8043
  fields: [
7661
8044
  ...bindFields,
7662
8045
  ...(bindFields.includes('price')
@@ -7681,6 +8064,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7681
8064
  const result = await this.find({
7682
8065
  filters: {
7683
8066
  slug,
8067
+ productId: {
8068
+ operator: Where.ISNULL,
8069
+ },
7684
8070
  },
7685
8071
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
7686
8072
  options: {
@@ -7690,6 +8076,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7690
8076
  if (!result.data.length)
7691
8077
  return null;
7692
8078
  const product = result?.data?.shift();
8079
+ if (!product.variants?.length) {
8080
+ for (const [index, variant] of product.variants.entries()) {
8081
+ product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8082
+ }
8083
+ }
7693
8084
  RoundProductPricesHelper.roundProductPrices(product);
7694
8085
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7695
8086
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -7891,7 +8282,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7891
8282
  return data?.[0]?.id;
7892
8283
  throw new NotFoundError(`Product with id ${id} not found`);
7893
8284
  }
7894
- async findReviewsByProduct(productId, options) {
8285
+ async findReviewsByProduct(productId, onlyApproved, options) {
7895
8286
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7896
8287
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
7897
8288
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -7904,10 +8295,16 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7904
8295
  where: {
7905
8296
  value: {
7906
8297
  product_id: { _eq: productId },
8298
+ ...(onlyApproved && { status: { _eq: true } }),
7907
8299
  },
7908
8300
  type: 'product_review_bool_exp',
7909
8301
  required: true,
7910
8302
  },
8303
+ order_by: {
8304
+ type: '[product_review_order_by]',
8305
+ value: [{ createdAt: 'desc' }],
8306
+ required: true,
8307
+ },
7911
8308
  });
7912
8309
  const reviews = data?.map((review) => this.bindReviewToModel(review));
7913
8310
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8012,7 +8409,7 @@ __decorate([
8012
8409
  __decorate([
8013
8410
  Log(),
8014
8411
  __metadata("design:type", Function),
8015
- __metadata("design:paramtypes", [Number, Object]),
8412
+ __metadata("design:paramtypes", [Number, Boolean, Object]),
8016
8413
  __metadata("design:returntype", Promise)
8017
8414
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8018
8415
 
@@ -8260,6 +8657,113 @@ const fieldsConfiguration$1 = [
8260
8657
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8261
8658
  },
8262
8659
  },
8660
+ 'slug',
8661
+ 'brand',
8662
+ 'name',
8663
+ 'sku',
8664
+ { NCM: { columnName: 'ncm' } },
8665
+ { CEST: { columnName: 'cest' } },
8666
+ {
8667
+ description: {
8668
+ columnName: 'description',
8669
+ from: (description, data) => ({
8670
+ description,
8671
+ differentials: data.differentials,
8672
+ whoMustUse: data.who_must_use,
8673
+ howToUse: data.how_to_use,
8674
+ brand: data.brand_description,
8675
+ ingredients: data.ingredients,
8676
+ purpose: data.purpose,
8677
+ }),
8678
+ bindFindFilter: (filters) => {
8679
+ return {
8680
+ ...(filters?.description && { description: filters.description }),
8681
+ ...(filters.differentials && { differentials: filters.differentials }),
8682
+ ...(filters.whoMustUse && {
8683
+ who_must_use: filters.whoMustUse,
8684
+ }),
8685
+ ...(filters.howToUse && {
8686
+ how_to_use: filters.howToUse,
8687
+ }),
8688
+ ...(filters.brand && {
8689
+ brand_description: filters.brand,
8690
+ }),
8691
+ ...(filters.ingredients && {
8692
+ ingredients: filters.ingredients,
8693
+ }),
8694
+ ...(filters.purpose && {
8695
+ purpose: filters.purpose,
8696
+ }),
8697
+ };
8698
+ },
8699
+ bindPersistData: (descriptionData) => ({
8700
+ ...(descriptionData?.description && { description: descriptionData.description }),
8701
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8702
+ ...(descriptionData.whoMustUse && {
8703
+ who_must_use: descriptionData.whoMustUse,
8704
+ }),
8705
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8706
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8707
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8708
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8709
+ }),
8710
+ },
8711
+ },
8712
+ { differentials: { columnName: 'differentials' } },
8713
+ { whoMustUse: { columnName: 'who_must_use' } },
8714
+ { howToUse: { columnName: 'how_to_use' } },
8715
+ { brandDescription: { columnName: 'brand_description' } },
8716
+ { ingredients: { columnName: 'ingredients' } },
8717
+ { purpose: { columnName: 'purpose' } },
8718
+ 'gender',
8719
+ { intGender: { columnName: 'int_gender' } },
8720
+ 'label',
8721
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8722
+ { rate: { columnName: 'rating' } },
8723
+ { reviewsTotal: { columnName: 'reviews_total' } },
8724
+ { shoppingCount: { columnName: 'shopping_count' } },
8725
+ { categoryId: { columnName: 'category_id' } },
8726
+ {
8727
+ category: {
8728
+ columnName: 'category',
8729
+ foreignKeyColumn: { id: 'categoryId' },
8730
+ fields: ['id', 'name', 'reference', 'slug'],
8731
+ },
8732
+ },
8733
+ {
8734
+ metadata: {
8735
+ columnName: 'metadata',
8736
+ fields: ['title', 'description'],
8737
+ bindPersistData: (value) => ({
8738
+ metadata: { data: value },
8739
+ }),
8740
+ },
8741
+ },
8742
+ {
8743
+ reviews: {
8744
+ columnName: 'reviews',
8745
+ foreignKeyColumn: { product_id: 'id' },
8746
+ fields: [
8747
+ 'id',
8748
+ 'shop',
8749
+ 'rate',
8750
+ 'author',
8751
+ 'email',
8752
+ 'location',
8753
+ 'review',
8754
+ 'status',
8755
+ 'title',
8756
+ { personId: { columnName: 'person_id' } },
8757
+ 'points',
8758
+ { orderId: { columnName: 'order_id' } },
8759
+ { createdAt: { columnName: 'created_at' } },
8760
+ { updatedAt: { columnName: 'updated_at' } },
8761
+ ],
8762
+ },
8763
+ },
8764
+ { variantSlug: { columnName: 'variant_slug' } },
8765
+ { createdAt: { columnName: 'created_at' } },
8766
+ { updatedAt: { columnName: 'updated_at' } },
8263
8767
  ];
8264
8768
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8265
8769
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8300,18 +8804,37 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8300
8804
  return data.at(0);
8301
8805
  }
8302
8806
  async update(params) {
8303
- const { productId, id: checkId, ...data } = params;
8807
+ const { productId, id: checkId, metadata, ...data } = params;
8304
8808
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8305
8809
  if (!dataWithProductId.id) {
8306
8810
  throw new NotFoundError('Variant ID is required for update');
8307
8811
  }
8308
8812
  const id = await this.getId(dataWithProductId.id);
8309
8813
  const product = await super.update({ id, ...data });
8814
+ product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8310
8815
  if (dataWithProductId.productId) {
8311
8816
  product.productId = dataWithProductId.productId;
8312
8817
  }
8313
8818
  return product;
8314
8819
  }
8820
+ async updateMetadata(productId, { metadata }) {
8821
+ const plainData = this.paramsToPlain({ metadata });
8822
+ if (!plainData.metadata)
8823
+ return null;
8824
+ await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8825
+ pk_columns: {
8826
+ value: { product_id: productId },
8827
+ type: 'product_metadata_pk_columns_input',
8828
+ required: true,
8829
+ },
8830
+ _set: {
8831
+ value: omit(metadata, ['product_id']),
8832
+ type: 'product_metadata_set_input',
8833
+ required: true,
8834
+ },
8835
+ });
8836
+ return plainData.metadata;
8837
+ }
8315
8838
  async getId(id) {
8316
8839
  if (!Number.isNaN(+id))
8317
8840
  return id;
@@ -9639,4 +10162,4 @@ class ProductsVertexSearch {
9639
10162
  }
9640
10163
  }
9641
10164
 
9642
- export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
10165
+ export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };