@infrab4a/connect 5.4.0-beta.8 → 5.4.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.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) };
@@ -7192,280 +7192,6 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7192
7192
  }
7193
7193
  }
7194
7194
 
7195
- const commonFields$1 = [
7196
- {
7197
- id: {
7198
- columnName: 'id',
7199
- to: (value) => +value,
7200
- from: (value) => value.toString(),
7201
- },
7202
- },
7203
- { firestoreId: { columnName: 'firestore_id' } },
7204
- { productId: { columnName: 'main_product_id' } },
7205
- { CEST: { columnName: 'cest' } },
7206
- { EAN: { columnName: 'ean' } },
7207
- { NCM: { columnName: 'ncm' } },
7208
- 'brand',
7209
- { costPrice: { columnName: 'cost_price' } },
7210
- {
7211
- description: {
7212
- columnName: 'description',
7213
- from: (description, data) => ({
7214
- description,
7215
- differentials: data.differentials,
7216
- whoMustUse: data.who_must_use,
7217
- howToUse: data.how_to_use,
7218
- brand: data.brand_description,
7219
- ingredients: data.ingredients,
7220
- purpose: data.purpose,
7221
- }),
7222
- bindFindFilter: (filters) => {
7223
- return {
7224
- ...(filters?.description && { description: filters.description }),
7225
- ...(filters.differentials && { differentials: filters.differentials }),
7226
- ...(filters.whoMustUse && {
7227
- who_must_use: filters.whoMustUse,
7228
- }),
7229
- ...(filters.howToUse && {
7230
- how_to_use: filters.howToUse,
7231
- }),
7232
- ...(filters.brand && {
7233
- brand_description: filters.brand,
7234
- }),
7235
- ...(filters.ingredients && {
7236
- ingredients: filters.ingredients,
7237
- }),
7238
- ...(filters.purpose && {
7239
- purpose: filters.purpose,
7240
- }),
7241
- };
7242
- },
7243
- bindPersistData: (descriptionData) => ({
7244
- ...(descriptionData?.description && { description: descriptionData.description }),
7245
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7246
- ...(descriptionData.whoMustUse && {
7247
- who_must_use: descriptionData.whoMustUse,
7248
- }),
7249
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7250
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7251
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7252
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7253
- }),
7254
- },
7255
- },
7256
- { differentials: { columnName: 'differentials' } },
7257
- { whoMustUse: { columnName: 'who_must_use' } },
7258
- { howToUse: { columnName: 'how_to_use' } },
7259
- { brandDescription: { columnName: 'brand_description' } },
7260
- { ingredients: { columnName: 'ingredients' } },
7261
- { purpose: { columnName: 'purpose' } },
7262
- { hasVariants: { columnName: 'has_variants' } },
7263
- {
7264
- images: {
7265
- columnName: 'images',
7266
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7267
- },
7268
- },
7269
- {
7270
- miniatures: {
7271
- columnName: 'miniatures',
7272
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7273
- },
7274
- },
7275
- {
7276
- imagesCard: {
7277
- columnName: 'images_card',
7278
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7279
- },
7280
- },
7281
- 'name',
7282
- {
7283
- price: {
7284
- columnName: 'price',
7285
- from: (price, data) => ({
7286
- price,
7287
- fullPrice: data.full_price,
7288
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
7289
- fullPriceDiscountPercentage: data.full_price_discount_percentage,
7290
- subscriberPrice: data.subscriber_price,
7291
- }),
7292
- bindFindFilter: (filters) => {
7293
- return {
7294
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7295
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7296
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7297
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7298
- }),
7299
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7300
- subscriber_price: filters.subscriberPrice,
7301
- }),
7302
- ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7303
- full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7304
- }),
7305
- };
7306
- },
7307
- bindPersistData: (priceData) => ({
7308
- ...(priceData?.price >= 0 && { price: priceData.price }),
7309
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7310
- ...(priceData.subscriberDiscountPercentage >= 0 && {
7311
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7312
- }),
7313
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7314
- ...(priceData.fullPriceDiscountPercentage >= 0 && {
7315
- full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7316
- }),
7317
- }),
7318
- },
7319
- },
7320
- { fullPrice: { columnName: 'full_price' } },
7321
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7322
- { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7323
- { subscriberPrice: { columnName: 'subscriber_price' } },
7324
- 'published',
7325
- 'outlet',
7326
- 'label',
7327
- 'sku',
7328
- {
7329
- stock: {
7330
- columnName: 'stock',
7331
- from: (quantity) => ({ quantity }),
7332
- to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7333
- },
7334
- },
7335
- { hasStock: { columnName: 'has_stock' } },
7336
- 'slug',
7337
- 'type',
7338
- 'video',
7339
- 'weight',
7340
- 'gender',
7341
- { intGender: { columnName: 'int_gender' } },
7342
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7343
- { isKit: { columnName: 'is_kit' } },
7344
- { createdAt: { columnName: 'created_at' } },
7345
- { updatedAt: { columnName: 'updated_at' } },
7346
- { rate: { columnName: 'rating' } },
7347
- { reviewsTotal: { columnName: 'reviews_total' } },
7348
- { shoppingCount: { columnName: 'shopping_count' } },
7349
- { categoryId: { columnName: 'category_id' } },
7350
- {
7351
- category: {
7352
- columnName: 'category',
7353
- foreignKeyColumn: { id: 'categoryId' },
7354
- fields: ['id', 'name', 'reference', 'slug'],
7355
- },
7356
- },
7357
- 'group',
7358
- 'validity',
7359
- { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7360
- { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7361
- { daysOfUse: { columnName: 'days_of_use' } },
7362
- { showVariants: { columnName: 'show_variants' } },
7363
- { variantSlug: { columnName: 'variant_slug' } },
7364
- ];
7365
- class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7366
- constructor({ endpoint, authOptions, interceptors, cache, }) {
7367
- super({
7368
- tableName: 'product_catalog',
7369
- model: ProductHasuraGraphQL,
7370
- endpoint,
7371
- authOptions,
7372
- interceptors,
7373
- fields: commonFields$1,
7374
- cache,
7375
- });
7376
- }
7377
- async get({ id }) {
7378
- return super
7379
- .find({
7380
- filters: {
7381
- id,
7382
- },
7383
- limits: {
7384
- limit: 1,
7385
- },
7386
- })
7387
- .then((res) => res.data.at(0));
7388
- }
7389
- async getByEAN(EAN, options) {
7390
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7391
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7392
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7393
- if (cachedData) {
7394
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7395
- return this.model.toInstance(deserialize(cachedData));
7396
- }
7397
- }
7398
- const product = await super
7399
- .find({
7400
- filters: {
7401
- EAN,
7402
- },
7403
- limits: {
7404
- limit: 1,
7405
- },
7406
- })
7407
- .then((res) => res.data.at(0));
7408
- if (!product)
7409
- return null;
7410
- RoundProductPricesHelper.roundProductPrices(product);
7411
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7412
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7413
- await this.cache.cacheAdapter.set({
7414
- key: cacheKey,
7415
- data: serialize(product),
7416
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7417
- });
7418
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7419
- }
7420
- return product;
7421
- }
7422
- async find(params, optionsParams) {
7423
- const { filters, fields, ...options } = params || {};
7424
- const bindFields = fields ||
7425
- this.fields
7426
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7427
- .filter((field) => field !== 'reviews' && field !== 'categories');
7428
- if (options.options?.minimal?.includes('price'))
7429
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7430
- if (options.options?.maximum?.includes('price'))
7431
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7432
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7433
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7434
- return super.find({
7435
- ...options,
7436
- filters: { ...filters },
7437
- fields: [
7438
- ...bindFields,
7439
- ...(bindFields.includes('price')
7440
- ? [
7441
- 'subscriberPrice',
7442
- 'subscriberDiscountPercentage',
7443
- 'fullPrice',
7444
- ]
7445
- : []),
7446
- ],
7447
- }, optionsParams);
7448
- }
7449
- async findCatalog(params, mainGender, options) {
7450
- const result = await this.find({
7451
- ...params,
7452
- filters: { ...params.filters, published: true },
7453
- orderBy: {
7454
- hasStock: 'desc',
7455
- ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7456
- ...omit(params.orderBy, ['hasStock', 'intGender']),
7457
- },
7458
- }, options);
7459
- return result;
7460
- }
7461
- }
7462
- __decorate([
7463
- Log(),
7464
- __metadata("design:type", Function),
7465
- __metadata("design:paramtypes", [Object, Object, Object]),
7466
- __metadata("design:returntype", Promise)
7467
- ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7468
-
7469
7195
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7470
7196
  constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7471
7197
  super({
@@ -7709,8 +7435,6 @@ const commonFields = [
7709
7435
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7710
7436
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7711
7437
  { daysOfUse: { columnName: 'days_of_use' } },
7712
- { showVariants: { columnName: 'show_variants' } },
7713
- { variantSlug: { columnName: 'variant_slug' } },
7714
7438
  ];
7715
7439
  const fieldsConfiguration$2 = [
7716
7440
  ...commonFields,
@@ -7774,61 +7498,9 @@ const fieldsConfiguration$2 = [
7774
7498
  foreignKeyColumn: { product_id: 'id' },
7775
7499
  fields: [
7776
7500
  'id',
7777
- 'name',
7778
7501
  'ean',
7779
7502
  'sku',
7780
- {
7781
- description: {
7782
- columnName: 'description',
7783
- from: (description, data) => ({
7784
- description,
7785
- differentials: data.differentials,
7786
- whoMustUse: data.who_must_use,
7787
- howToUse: data.how_to_use,
7788
- brand: data.brand_description,
7789
- ingredients: data.ingredients,
7790
- purpose: data.purpose,
7791
- }),
7792
- bindFindFilter: (filters) => {
7793
- return {
7794
- ...(filters?.description && { description: filters.description }),
7795
- ...(filters.differentials && { differentials: filters.differentials }),
7796
- ...(filters.whoMustUse && {
7797
- who_must_use: filters.whoMustUse,
7798
- }),
7799
- ...(filters.howToUse && {
7800
- how_to_use: filters.howToUse,
7801
- }),
7802
- ...(filters.brand && {
7803
- brand_description: filters.brand,
7804
- }),
7805
- ...(filters.ingredients && {
7806
- ingredients: filters.ingredients,
7807
- }),
7808
- ...(filters.purpose && {
7809
- purpose: filters.purpose,
7810
- }),
7811
- };
7812
- },
7813
- bindPersistData: (descriptionData) => ({
7814
- ...(descriptionData?.description && { description: descriptionData.description }),
7815
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7816
- ...(descriptionData.whoMustUse && {
7817
- who_must_use: descriptionData.whoMustUse,
7818
- }),
7819
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7820
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7821
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7822
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7823
- }),
7824
- },
7825
- },
7826
- { differentials: { columnName: 'differentials' } },
7827
- { whoMustUse: { columnName: 'who_must_use' } },
7828
- { howToUse: { columnName: 'how_to_use' } },
7829
- { brandDescription: { columnName: 'brand_description' } },
7830
- { ingredients: { columnName: 'ingredients' } },
7831
- { purpose: { columnName: 'purpose' } },
7503
+ 'description',
7832
7504
  {
7833
7505
  grade: {
7834
7506
  columnName: 'grade',
@@ -7874,6 +7546,10 @@ const fieldsConfiguration$2 = [
7874
7546
  }),
7875
7547
  },
7876
7548
  },
7549
+ { fullPrice: { columnName: 'full_price' } },
7550
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7551
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7552
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7877
7553
  'published',
7878
7554
  {
7879
7555
  stock: {
@@ -7902,29 +7578,6 @@ const fieldsConfiguration$2 = [
7902
7578
  },
7903
7579
  { tagsProfile: { columnName: 'tags_profile' } },
7904
7580
  { tagsCollection: { columnName: 'tags_collection' } },
7905
- { variantSlug: { columnName: 'variant_slug' } },
7906
- {
7907
- reviews: {
7908
- columnName: 'reviews',
7909
- foreignKeyColumn: { product_id: 'id' },
7910
- fields: [
7911
- 'id',
7912
- 'shop',
7913
- 'rate',
7914
- 'author',
7915
- 'email',
7916
- 'location',
7917
- 'review',
7918
- 'status',
7919
- 'title',
7920
- { personId: { columnName: 'person_id' } },
7921
- 'points',
7922
- { orderId: { columnName: 'order_id' } },
7923
- { createdAt: { columnName: 'created_at' } },
7924
- { updatedAt: { columnName: 'updated_at' } },
7925
- ],
7926
- },
7927
- },
7928
7581
  ],
7929
7582
  },
7930
7583
  },
@@ -7990,12 +7643,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7990
7643
  : await super.get(identifiers, options);
7991
7644
  if (product.productId)
7992
7645
  throw new NotFoundError('Product not found, it is a variant');
7993
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
7994
- if (!product.variants?.length) {
7995
- for (const [index, variant] of product.variants.entries()) {
7996
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
7997
- }
7998
- }
7646
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
7999
7647
  return product;
8000
7648
  }
8001
7649
  async find(params, optionsParams) {
@@ -8012,7 +7660,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8012
7660
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8013
7661
  return super.find({
8014
7662
  ...options,
8015
- filters: { ...filters },
7663
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
8016
7664
  fields: [
8017
7665
  ...bindFields,
8018
7666
  ...(bindFields.includes('price')
@@ -8037,9 +7685,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8037
7685
  const result = await this.find({
8038
7686
  filters: {
8039
7687
  slug,
8040
- productId: {
8041
- operator: Where.ISNULL,
8042
- },
8043
7688
  },
8044
7689
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
8045
7690
  options: {
@@ -8049,11 +7694,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8049
7694
  if (!result.data.length)
8050
7695
  return null;
8051
7696
  const product = result?.data?.shift();
8052
- if (!product.variants?.length) {
8053
- for (const [index, variant] of product.variants.entries()) {
8054
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8055
- }
8056
- }
8057
7697
  RoundProductPricesHelper.roundProductPrices(product);
8058
7698
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
8059
7699
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -8255,7 +7895,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8255
7895
  return data?.[0]?.id;
8256
7896
  throw new NotFoundError(`Product with id ${id} not found`);
8257
7897
  }
8258
- async findReviewsByProduct(productId, onlyApproved, options) {
7898
+ async findReviewsByProduct(productId, options) {
8259
7899
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8260
7900
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
8261
7901
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -8268,16 +7908,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8268
7908
  where: {
8269
7909
  value: {
8270
7910
  product_id: { _eq: productId },
8271
- ...(onlyApproved && { status: { _eq: true } }),
8272
7911
  },
8273
7912
  type: 'product_review_bool_exp',
8274
7913
  required: true,
8275
7914
  },
8276
- order_by: {
8277
- type: '[product_review_order_by]',
8278
- value: [{ createdAt: 'desc' }],
8279
- required: true,
8280
- },
8281
7915
  });
8282
7916
  const reviews = data?.map((review) => this.bindReviewToModel(review));
8283
7917
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8382,7 +8016,7 @@ __decorate([
8382
8016
  __decorate([
8383
8017
  Log(),
8384
8018
  __metadata("design:type", Function),
8385
- __metadata("design:paramtypes", [Number, Boolean, Object]),
8019
+ __metadata("design:paramtypes", [Number, Object]),
8386
8020
  __metadata("design:returntype", Promise)
8387
8021
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8388
8022
 
@@ -8630,106 +8264,6 @@ const fieldsConfiguration$1 = [
8630
8264
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8631
8265
  },
8632
8266
  },
8633
- 'slug',
8634
- 'brand',
8635
- 'name',
8636
- 'sku',
8637
- { NCM: { columnName: 'ncm' } },
8638
- { CEST: { columnName: 'cest' } },
8639
- {
8640
- description: {
8641
- columnName: 'description',
8642
- from: (description, data) => ({
8643
- description,
8644
- differentials: data.differentials,
8645
- whoMustUse: data.who_must_use,
8646
- howToUse: data.how_to_use,
8647
- brand: data.brand_description,
8648
- ingredients: data.ingredients,
8649
- purpose: data.purpose,
8650
- }),
8651
- bindFindFilter: (filters) => {
8652
- return {
8653
- ...(filters?.description && { description: filters.description }),
8654
- ...(filters.differentials && { differentials: filters.differentials }),
8655
- ...(filters.whoMustUse && {
8656
- who_must_use: filters.whoMustUse,
8657
- }),
8658
- ...(filters.howToUse && {
8659
- how_to_use: filters.howToUse,
8660
- }),
8661
- ...(filters.brand && {
8662
- brand_description: filters.brand,
8663
- }),
8664
- ...(filters.ingredients && {
8665
- ingredients: filters.ingredients,
8666
- }),
8667
- ...(filters.purpose && {
8668
- purpose: filters.purpose,
8669
- }),
8670
- };
8671
- },
8672
- bindPersistData: (descriptionData) => ({
8673
- ...(descriptionData?.description && { description: descriptionData.description }),
8674
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8675
- ...(descriptionData.whoMustUse && {
8676
- who_must_use: descriptionData.whoMustUse,
8677
- }),
8678
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8679
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8680
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8681
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8682
- }),
8683
- },
8684
- },
8685
- { differentials: { columnName: 'differentials' } },
8686
- { whoMustUse: { columnName: 'who_must_use' } },
8687
- { howToUse: { columnName: 'how_to_use' } },
8688
- { brandDescription: { columnName: 'brand_description' } },
8689
- { ingredients: { columnName: 'ingredients' } },
8690
- { purpose: { columnName: 'purpose' } },
8691
- 'gender',
8692
- { intGender: { columnName: 'int_gender' } },
8693
- 'label',
8694
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8695
- { rate: { columnName: 'rating' } },
8696
- { reviewsTotal: { columnName: 'reviews_total' } },
8697
- { shoppingCount: { columnName: 'shopping_count' } },
8698
- { categoryId: { columnName: 'category_id' } },
8699
- {
8700
- metadata: {
8701
- columnName: 'metadata',
8702
- fields: ['title', 'description'],
8703
- bindPersistData: (value) => ({
8704
- metadata: { data: value },
8705
- }),
8706
- },
8707
- },
8708
- {
8709
- reviews: {
8710
- columnName: 'reviews',
8711
- foreignKeyColumn: { product_id: 'id' },
8712
- fields: [
8713
- 'id',
8714
- 'shop',
8715
- 'rate',
8716
- 'author',
8717
- 'email',
8718
- 'location',
8719
- 'review',
8720
- 'status',
8721
- 'title',
8722
- { personId: { columnName: 'person_id' } },
8723
- 'points',
8724
- { orderId: { columnName: 'order_id' } },
8725
- { createdAt: { columnName: 'created_at' } },
8726
- { updatedAt: { columnName: 'updated_at' } },
8727
- ],
8728
- },
8729
- },
8730
- { variantSlug: { columnName: 'variant_slug' } },
8731
- { createdAt: { columnName: 'created_at' } },
8732
- { updatedAt: { columnName: 'updated_at' } },
8733
8267
  ];
8734
8268
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8735
8269
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8770,37 +8304,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8770
8304
  return data.at(0);
8771
8305
  }
8772
8306
  async update(params) {
8773
- const { productId, id: checkId, metadata, ...data } = params;
8307
+ const { productId, id: checkId, ...data } = params;
8774
8308
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8775
8309
  if (!dataWithProductId.id) {
8776
8310
  throw new NotFoundError('Variant ID is required for update');
8777
8311
  }
8778
8312
  const id = await this.getId(dataWithProductId.id);
8779
8313
  const product = await super.update({ id, ...data });
8780
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8781
8314
  if (dataWithProductId.productId) {
8782
8315
  product.productId = dataWithProductId.productId;
8783
8316
  }
8784
8317
  return product;
8785
8318
  }
8786
- async updateMetadata(productId, { metadata }) {
8787
- const plainData = this.paramsToPlain({ metadata });
8788
- if (!plainData.metadata)
8789
- return null;
8790
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8791
- pk_columns: {
8792
- value: { product_id: productId },
8793
- type: 'product_metadata_pk_columns_input',
8794
- required: true,
8795
- },
8796
- _set: {
8797
- value: omit(metadata, ['product_id']),
8798
- type: 'product_metadata_set_input',
8799
- required: true,
8800
- },
8801
- });
8802
- return plainData.metadata;
8803
- }
8804
8319
  async getId(id) {
8805
8320
  if (!Number.isNaN(+id))
8806
8321
  return id;
@@ -10128,4 +9643,4 @@ class ProductsVertexSearch {
10128
9643
  }
10129
9644
  }
10130
9645
 
10131
- 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, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.4.0-beta.8",
3
+ "version": "5.4.1-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "axios": "^0.27.2",
13
13
  "class-transformer": "^0.5.1",
14
- "date-fns": "^2.28.0",
15
- "date-fns-tz": "^3.2.0",
14
+ "date-fns": "2.28.0",
15
+ "date-fns-tz": "2.0.1",
16
16
  "debug": "^4.3.4",
17
17
  "firebase": "^9.22.0",
18
18
  "gql-query-builder": "3.7.0",