@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.esm.js CHANGED
@@ -3,8 +3,8 @@ import { __decorate, __metadata } from 'tslib';
3
3
  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
- import { toZonedTime } from 'date-fns-tz';
7
- export { formatInTimeZone, fromZonedTime, toZonedTime } from 'date-fns-tz';
6
+ import { 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';
@@ -1791,7 +1791,7 @@ class AntifraudCardService {
1791
1791
  }
1792
1792
  getTodayDateRange() {
1793
1793
  const timeZone = 'America/Sao_Paulo';
1794
- const today = toZonedTime(new Date(), timeZone);
1794
+ const today = utcToZonedTime(new Date(), timeZone);
1795
1795
  const day = startOfDay(today);
1796
1796
  const endOfDay$1 = endOfDay(today);
1797
1797
  return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
@@ -5827,9 +5827,6 @@ __decorate([
5827
5827
  __metadata("design:type", Product)
5828
5828
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
5829
5829
 
5830
- class ProductCatalogHasuraGraphQL extends Product {
5831
- }
5832
-
5833
5830
  class ProductHasuraGraphQL extends Product {
5834
5831
  }
5835
5832
  __decorate([
@@ -7195,300 +7192,6 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7195
7192
  }
7196
7193
  }
7197
7194
 
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
-
7492
7195
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7493
7196
  constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7494
7197
  super({
@@ -7732,8 +7435,6 @@ const commonFields = [
7732
7435
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7733
7436
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7734
7437
  { daysOfUse: { columnName: 'days_of_use' } },
7735
- { showVariants: { columnName: 'show_variants' } },
7736
- { variantSlug: { columnName: 'variant_slug' } },
7737
7438
  ];
7738
7439
  const fieldsConfiguration$2 = [
7739
7440
  ...commonFields,
@@ -7797,61 +7498,9 @@ const fieldsConfiguration$2 = [
7797
7498
  foreignKeyColumn: { product_id: 'id' },
7798
7499
  fields: [
7799
7500
  'id',
7800
- 'name',
7801
7501
  'ean',
7802
7502
  'sku',
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' } },
7503
+ 'description',
7855
7504
  {
7856
7505
  grade: {
7857
7506
  columnName: 'grade',
@@ -7897,6 +7546,10 @@ const fieldsConfiguration$2 = [
7897
7546
  }),
7898
7547
  },
7899
7548
  },
7549
+ { fullPrice: { columnName: 'full_price' } },
7550
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7551
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7552
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7900
7553
  'published',
7901
7554
  {
7902
7555
  stock: {
@@ -7925,29 +7578,6 @@ const fieldsConfiguration$2 = [
7925
7578
  },
7926
7579
  { tagsProfile: { columnName: 'tags_profile' } },
7927
7580
  { tagsCollection: { columnName: 'tags_collection' } },
7928
- { variantSlug: { columnName: 'variant_slug' } },
7929
- {
7930
- reviews: {
7931
- columnName: 'reviews',
7932
- foreignKeyColumn: { product_id: 'id' },
7933
- fields: [
7934
- 'id',
7935
- 'shop',
7936
- 'rate',
7937
- 'author',
7938
- 'email',
7939
- 'location',
7940
- 'review',
7941
- 'status',
7942
- 'title',
7943
- { personId: { columnName: 'person_id' } },
7944
- 'points',
7945
- { orderId: { columnName: 'order_id' } },
7946
- { createdAt: { columnName: 'created_at' } },
7947
- { updatedAt: { columnName: 'updated_at' } },
7948
- ],
7949
- },
7950
- },
7951
7581
  ],
7952
7582
  },
7953
7583
  },
@@ -8013,12 +7643,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8013
7643
  : await super.get(identifiers, options);
8014
7644
  if (product.productId)
8015
7645
  throw new NotFoundError('Product not found, it is a variant');
8016
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
8017
- if (!product.variants?.length) {
8018
- for (const [index, variant] of product.variants.entries()) {
8019
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8020
- }
8021
- }
7646
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
8022
7647
  return product;
8023
7648
  }
8024
7649
  async find(params, optionsParams) {
@@ -8035,7 +7660,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8035
7660
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8036
7661
  return super.find({
8037
7662
  ...options,
8038
- filters: { ...filters },
7663
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
8039
7664
  fields: [
8040
7665
  ...bindFields,
8041
7666
  ...(bindFields.includes('price')
@@ -8060,9 +7685,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8060
7685
  const result = await this.find({
8061
7686
  filters: {
8062
7687
  slug,
8063
- productId: {
8064
- operator: Where.ISNULL,
8065
- },
8066
7688
  },
8067
7689
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
8068
7690
  options: {
@@ -8072,11 +7694,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8072
7694
  if (!result.data.length)
8073
7695
  return null;
8074
7696
  const product = result?.data?.shift();
8075
- if (!product.variants?.length) {
8076
- for (const [index, variant] of product.variants.entries()) {
8077
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8078
- }
8079
- }
8080
7697
  RoundProductPricesHelper.roundProductPrices(product);
8081
7698
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
8082
7699
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -8278,7 +7895,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8278
7895
  return data?.[0]?.id;
8279
7896
  throw new NotFoundError(`Product with id ${id} not found`);
8280
7897
  }
8281
- async findReviewsByProduct(productId, onlyApproved, options) {
7898
+ async findReviewsByProduct(productId, options) {
8282
7899
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8283
7900
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
8284
7901
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -8291,16 +7908,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8291
7908
  where: {
8292
7909
  value: {
8293
7910
  product_id: { _eq: productId },
8294
- ...(onlyApproved && { status: { _eq: true } }),
8295
7911
  },
8296
7912
  type: 'product_review_bool_exp',
8297
7913
  required: true,
8298
7914
  },
8299
- order_by: {
8300
- type: '[product_review_order_by]',
8301
- value: [{ createdAt: 'desc' }],
8302
- required: true,
8303
- },
8304
7915
  });
8305
7916
  const reviews = data?.map((review) => this.bindReviewToModel(review));
8306
7917
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8405,7 +8016,7 @@ __decorate([
8405
8016
  __decorate([
8406
8017
  Log(),
8407
8018
  __metadata("design:type", Function),
8408
- __metadata("design:paramtypes", [Number, Boolean, Object]),
8019
+ __metadata("design:paramtypes", [Number, Object]),
8409
8020
  __metadata("design:returntype", Promise)
8410
8021
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8411
8022
 
@@ -8653,106 +8264,6 @@ const fieldsConfiguration$1 = [
8653
8264
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8654
8265
  },
8655
8266
  },
8656
- 'slug',
8657
- 'brand',
8658
- 'name',
8659
- 'sku',
8660
- { NCM: { columnName: 'ncm' } },
8661
- { CEST: { columnName: 'cest' } },
8662
- {
8663
- description: {
8664
- columnName: 'description',
8665
- from: (description, data) => ({
8666
- description,
8667
- differentials: data.differentials,
8668
- whoMustUse: data.who_must_use,
8669
- howToUse: data.how_to_use,
8670
- brand: data.brand_description,
8671
- ingredients: data.ingredients,
8672
- purpose: data.purpose,
8673
- }),
8674
- bindFindFilter: (filters) => {
8675
- return {
8676
- ...(filters?.description && { description: filters.description }),
8677
- ...(filters.differentials && { differentials: filters.differentials }),
8678
- ...(filters.whoMustUse && {
8679
- who_must_use: filters.whoMustUse,
8680
- }),
8681
- ...(filters.howToUse && {
8682
- how_to_use: filters.howToUse,
8683
- }),
8684
- ...(filters.brand && {
8685
- brand_description: filters.brand,
8686
- }),
8687
- ...(filters.ingredients && {
8688
- ingredients: filters.ingredients,
8689
- }),
8690
- ...(filters.purpose && {
8691
- purpose: filters.purpose,
8692
- }),
8693
- };
8694
- },
8695
- bindPersistData: (descriptionData) => ({
8696
- ...(descriptionData?.description && { description: descriptionData.description }),
8697
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8698
- ...(descriptionData.whoMustUse && {
8699
- who_must_use: descriptionData.whoMustUse,
8700
- }),
8701
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8702
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8703
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8704
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8705
- }),
8706
- },
8707
- },
8708
- { differentials: { columnName: 'differentials' } },
8709
- { whoMustUse: { columnName: 'who_must_use' } },
8710
- { howToUse: { columnName: 'how_to_use' } },
8711
- { brandDescription: { columnName: 'brand_description' } },
8712
- { ingredients: { columnName: 'ingredients' } },
8713
- { purpose: { columnName: 'purpose' } },
8714
- 'gender',
8715
- { intGender: { columnName: 'int_gender' } },
8716
- 'label',
8717
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8718
- { rate: { columnName: 'rating' } },
8719
- { reviewsTotal: { columnName: 'reviews_total' } },
8720
- { shoppingCount: { columnName: 'shopping_count' } },
8721
- { categoryId: { columnName: 'category_id' } },
8722
- {
8723
- metadata: {
8724
- columnName: 'metadata',
8725
- fields: ['title', 'description'],
8726
- bindPersistData: (value) => ({
8727
- metadata: { data: value },
8728
- }),
8729
- },
8730
- },
8731
- {
8732
- reviews: {
8733
- columnName: 'reviews',
8734
- foreignKeyColumn: { product_id: 'id' },
8735
- fields: [
8736
- 'id',
8737
- 'shop',
8738
- 'rate',
8739
- 'author',
8740
- 'email',
8741
- 'location',
8742
- 'review',
8743
- 'status',
8744
- 'title',
8745
- { personId: { columnName: 'person_id' } },
8746
- 'points',
8747
- { orderId: { columnName: 'order_id' } },
8748
- { createdAt: { columnName: 'created_at' } },
8749
- { updatedAt: { columnName: 'updated_at' } },
8750
- ],
8751
- },
8752
- },
8753
- { variantSlug: { columnName: 'variant_slug' } },
8754
- { createdAt: { columnName: 'created_at' } },
8755
- { updatedAt: { columnName: 'updated_at' } },
8756
8267
  ];
8757
8268
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8758
8269
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8793,37 +8304,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8793
8304
  return data.at(0);
8794
8305
  }
8795
8306
  async update(params) {
8796
- const { productId, id: checkId, metadata, ...data } = params;
8307
+ const { productId, id: checkId, ...data } = params;
8797
8308
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8798
8309
  if (!dataWithProductId.id) {
8799
8310
  throw new NotFoundError('Variant ID is required for update');
8800
8311
  }
8801
8312
  const id = await this.getId(dataWithProductId.id);
8802
8313
  const product = await super.update({ id, ...data });
8803
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8804
8314
  if (dataWithProductId.productId) {
8805
8315
  product.productId = dataWithProductId.productId;
8806
8316
  }
8807
8317
  return product;
8808
8318
  }
8809
- async updateMetadata(productId, { metadata }) {
8810
- const plainData = this.paramsToPlain({ metadata });
8811
- if (!plainData.metadata)
8812
- return null;
8813
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8814
- pk_columns: {
8815
- value: { product_id: productId },
8816
- type: 'product_metadata_pk_columns_input',
8817
- required: true,
8818
- },
8819
- _set: {
8820
- value: omit(metadata, ['product_id']),
8821
- type: 'product_metadata_set_input',
8822
- required: true,
8823
- },
8824
- });
8825
- return plainData.metadata;
8826
- }
8827
8319
  async getId(id) {
8828
8320
  if (!Number.isNaN(+id))
8829
8321
  return id;
@@ -10151,4 +9643,4 @@ class ProductsVertexSearch {
10151
9643
  }
10152
9644
  }
10153
9645
 
10154
- 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 };
9646
+ 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 };