@infrab4a/connect 5.4.0-alpha.3 → 5.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -20,7 +20,25 @@ var storage = require('firebase/storage');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
23
- var serializeJavascript__default = /*#__PURE__*/_interopDefaultLegacy(serializeJavascript);
23
+ function _interopNamespace(e) {
24
+ if (e && e.__esModule) return e;
25
+ var n = Object.create(null);
26
+ if (e) {
27
+ Object.keys(e).forEach(function (k) {
28
+ if (k !== 'default') {
29
+ var d = Object.getOwnPropertyDescriptor(e, k);
30
+ Object.defineProperty(n, k, d.get ? d : {
31
+ enumerable: true,
32
+ get: function () { return e[k]; }
33
+ });
34
+ }
35
+ });
36
+ }
37
+ n["default"] = e;
38
+ return Object.freeze(n);
39
+ }
40
+
41
+ var serializeJavascript__namespace = /*#__PURE__*/_interopNamespace(serializeJavascript);
24
42
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
25
43
 
26
44
  exports.AntifraudProviders = void 0;
@@ -626,7 +644,7 @@ const deserialize = (data) => {
626
644
  return eval('(' + data + ')');
627
645
  };
628
646
  const serialize = (data) => {
629
- return serializeJavascript__default["default"](data);
647
+ return serializeJavascript__namespace(data);
630
648
  };
631
649
 
632
650
  class BaseModel {
@@ -853,7 +871,11 @@ class Variant extends ProductBase {
853
871
  static get identifiersFields() {
854
872
  return ['id', 'productId'];
855
873
  }
856
- }
874
+ }
875
+ tslib.__decorate([
876
+ classTransformer.Type(() => Product),
877
+ tslib.__metadata("design:type", Product)
878
+ ], Variant.prototype, "product", void 0);
857
879
 
858
880
  class Product extends ProductBase {
859
881
  }
@@ -3374,6 +3396,8 @@ class HasuraQueryBuilderHelper {
3374
3396
  class HasuraRequestHelper {
3375
3397
  static async fetch(params) {
3376
3398
  const { variables, query, endpoint, headers, logger } = params;
3399
+ console.warn('variables', variables);
3400
+ console.warn('query', query);
3377
3401
  const request = {
3378
3402
  url: endpoint,
3379
3403
  method: 'POST',
@@ -7198,6 +7222,227 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7198
7222
  }
7199
7223
  }
7200
7224
 
7225
+ const commonFields$1 = [
7226
+ {
7227
+ id: {
7228
+ columnName: 'id',
7229
+ to: (value) => +value,
7230
+ from: (value) => value.toString(),
7231
+ },
7232
+ },
7233
+ { firestoreId: { columnName: 'firestore_id' } },
7234
+ { productId: { columnName: 'main_product_id' } },
7235
+ { CEST: { columnName: 'cest' } },
7236
+ { EAN: { columnName: 'ean' } },
7237
+ { NCM: { columnName: 'ncm' } },
7238
+ 'brand',
7239
+ { costPrice: { columnName: 'cost_price' } },
7240
+ {
7241
+ description: {
7242
+ columnName: 'description',
7243
+ from: (description, data) => ({
7244
+ description,
7245
+ differentials: data.differentials,
7246
+ whoMustUse: data.who_must_use,
7247
+ howToUse: data.how_to_use,
7248
+ brand: data.brand_description,
7249
+ ingredients: data.ingredients,
7250
+ purpose: data.purpose,
7251
+ }),
7252
+ bindFindFilter: (filters) => {
7253
+ return {
7254
+ ...(filters?.description && { description: filters.description }),
7255
+ ...(filters.differentials && { differentials: filters.differentials }),
7256
+ ...(filters.whoMustUse && {
7257
+ who_must_use: filters.whoMustUse,
7258
+ }),
7259
+ ...(filters.howToUse && {
7260
+ how_to_use: filters.howToUse,
7261
+ }),
7262
+ ...(filters.brand && {
7263
+ brand_description: filters.brand,
7264
+ }),
7265
+ ...(filters.ingredients && {
7266
+ ingredients: filters.ingredients,
7267
+ }),
7268
+ ...(filters.purpose && {
7269
+ purpose: filters.purpose,
7270
+ }),
7271
+ };
7272
+ },
7273
+ bindPersistData: (descriptionData) => ({
7274
+ ...(descriptionData?.description && { description: descriptionData.description }),
7275
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7276
+ ...(descriptionData.whoMustUse && {
7277
+ who_must_use: descriptionData.whoMustUse,
7278
+ }),
7279
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7280
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7281
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7282
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7283
+ }),
7284
+ },
7285
+ },
7286
+ { differentials: { columnName: 'differentials' } },
7287
+ { whoMustUse: { columnName: 'who_must_use' } },
7288
+ { howToUse: { columnName: 'how_to_use' } },
7289
+ { brandDescription: { columnName: 'brand_description' } },
7290
+ { ingredients: { columnName: 'ingredients' } },
7291
+ { purpose: { columnName: 'purpose' } },
7292
+ { hasVariants: { columnName: 'has_variants' } },
7293
+ {
7294
+ images: {
7295
+ columnName: 'images',
7296
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7297
+ },
7298
+ },
7299
+ {
7300
+ miniatures: {
7301
+ columnName: 'miniatures',
7302
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7303
+ },
7304
+ },
7305
+ {
7306
+ imagesCard: {
7307
+ columnName: 'images_card',
7308
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7309
+ },
7310
+ },
7311
+ 'name',
7312
+ {
7313
+ price: {
7314
+ columnName: 'price',
7315
+ from: (price, data) => ({
7316
+ price,
7317
+ fullPrice: data.full_price,
7318
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
7319
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
7320
+ subscriberPrice: data.subscriber_price,
7321
+ }),
7322
+ bindFindFilter: (filters) => {
7323
+ return {
7324
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7325
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7326
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7327
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7328
+ }),
7329
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7330
+ subscriber_price: filters.subscriberPrice,
7331
+ }),
7332
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7333
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7334
+ }),
7335
+ };
7336
+ },
7337
+ bindPersistData: (priceData) => ({
7338
+ ...(priceData?.price >= 0 && { price: priceData.price }),
7339
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7340
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
7341
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7342
+ }),
7343
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7344
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
7345
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7346
+ }),
7347
+ }),
7348
+ },
7349
+ },
7350
+ { fullPrice: { columnName: 'full_price' } },
7351
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7352
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7353
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7354
+ 'published',
7355
+ 'outlet',
7356
+ 'label',
7357
+ 'sku',
7358
+ {
7359
+ stock: {
7360
+ columnName: 'stock',
7361
+ from: (quantity) => ({ quantity }),
7362
+ to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
7363
+ },
7364
+ },
7365
+ { hasStock: { columnName: 'has_stock' } },
7366
+ 'slug',
7367
+ 'type',
7368
+ 'video',
7369
+ 'weight',
7370
+ 'gender',
7371
+ { intGender: { columnName: 'int_gender' } },
7372
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7373
+ { isKit: { columnName: 'is_kit' } },
7374
+ { createdAt: { columnName: 'created_at' } },
7375
+ { updatedAt: { columnName: 'updated_at' } },
7376
+ { rate: { columnName: 'rating' } },
7377
+ { reviewsTotal: { columnName: 'reviews_total' } },
7378
+ { shoppingCount: { columnName: 'shopping_count' } },
7379
+ { categoryId: { columnName: 'category_id' } },
7380
+ 'group',
7381
+ 'validity',
7382
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7383
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7384
+ { daysOfUse: { columnName: 'days_of_use' } },
7385
+ { showVariants: { columnName: 'show_variants' } },
7386
+ ];
7387
+ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7388
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
7389
+ super({
7390
+ tableName: 'product_catalog',
7391
+ model: ProductHasuraGraphQL,
7392
+ endpoint,
7393
+ authOptions,
7394
+ interceptors,
7395
+ fields: commonFields$1,
7396
+ cache,
7397
+ });
7398
+ }
7399
+ async find(params, optionsParams) {
7400
+ const { filters, fields, ...options } = params || {};
7401
+ const bindFields = fields ||
7402
+ this.fields
7403
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7404
+ .filter((field) => field !== 'reviews' && field !== 'categories');
7405
+ if (options.options?.minimal?.includes('price'))
7406
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7407
+ if (options.options?.maximum?.includes('price'))
7408
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7409
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7410
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7411
+ return super.find({
7412
+ ...options,
7413
+ filters: { ...filters },
7414
+ fields: [
7415
+ ...bindFields,
7416
+ ...(bindFields.includes('price')
7417
+ ? [
7418
+ 'subscriberPrice',
7419
+ 'subscriberDiscountPercentage',
7420
+ 'fullPrice',
7421
+ ]
7422
+ : []),
7423
+ ],
7424
+ }, optionsParams);
7425
+ }
7426
+ async findCatalog(params, mainGender, options) {
7427
+ const result = await this.find({
7428
+ ...params,
7429
+ filters: { ...params.filters, published: true },
7430
+ orderBy: {
7431
+ hasStock: 'desc',
7432
+ ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7433
+ ...lodash.omit(params.orderBy, ['hasStock', 'intGender']),
7434
+ },
7435
+ }, options);
7436
+ return result;
7437
+ }
7438
+ }
7439
+ tslib.__decorate([
7440
+ Log(),
7441
+ tslib.__metadata("design:type", Function),
7442
+ tslib.__metadata("design:paramtypes", [Object, Object, Object]),
7443
+ tslib.__metadata("design:returntype", Promise)
7444
+ ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7445
+
7201
7446
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7202
7447
  constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7203
7448
  super({
@@ -7354,6 +7599,12 @@ const commonFields = [
7354
7599
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7355
7600
  },
7356
7601
  },
7602
+ {
7603
+ imagesCard: {
7604
+ columnName: 'images_card',
7605
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7606
+ },
7607
+ },
7357
7608
  'name',
7358
7609
  {
7359
7610
  price: {
@@ -7435,6 +7686,7 @@ const commonFields = [
7435
7686
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7436
7687
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7437
7688
  { daysOfUse: { columnName: 'days_of_use' } },
7689
+ { showVariants: { columnName: 'show_variants' } },
7438
7690
  ];
7439
7691
  const fieldsConfiguration$2 = [
7440
7692
  ...commonFields,
@@ -7498,7 +7750,61 @@ const fieldsConfiguration$2 = [
7498
7750
  foreignKeyColumn: { product_id: 'id' },
7499
7751
  fields: [
7500
7752
  'id',
7753
+ 'name',
7501
7754
  'ean',
7755
+ 'sku',
7756
+ {
7757
+ description: {
7758
+ columnName: 'description',
7759
+ from: (description, data) => ({
7760
+ description,
7761
+ differentials: data.differentials,
7762
+ whoMustUse: data.who_must_use,
7763
+ howToUse: data.how_to_use,
7764
+ brand: data.brand_description,
7765
+ ingredients: data.ingredients,
7766
+ purpose: data.purpose,
7767
+ }),
7768
+ bindFindFilter: (filters) => {
7769
+ return {
7770
+ ...(filters?.description && { description: filters.description }),
7771
+ ...(filters.differentials && { differentials: filters.differentials }),
7772
+ ...(filters.whoMustUse && {
7773
+ who_must_use: filters.whoMustUse,
7774
+ }),
7775
+ ...(filters.howToUse && {
7776
+ how_to_use: filters.howToUse,
7777
+ }),
7778
+ ...(filters.brand && {
7779
+ brand_description: filters.brand,
7780
+ }),
7781
+ ...(filters.ingredients && {
7782
+ ingredients: filters.ingredients,
7783
+ }),
7784
+ ...(filters.purpose && {
7785
+ purpose: filters.purpose,
7786
+ }),
7787
+ };
7788
+ },
7789
+ bindPersistData: (descriptionData) => ({
7790
+ ...(descriptionData?.description && { description: descriptionData.description }),
7791
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7792
+ ...(descriptionData.whoMustUse && {
7793
+ who_must_use: descriptionData.whoMustUse,
7794
+ }),
7795
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7796
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7797
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7798
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7799
+ }),
7800
+ },
7801
+ },
7802
+ { differentials: { columnName: 'differentials' } },
7803
+ { whoMustUse: { columnName: 'who_must_use' } },
7804
+ { howToUse: { columnName: 'how_to_use' } },
7805
+ { brandDescription: { columnName: 'brand_description' } },
7806
+ { ingredients: { columnName: 'ingredients' } },
7807
+ { purpose: { columnName: 'purpose' } },
7502
7808
  {
7503
7809
  grade: {
7504
7810
  columnName: 'grade',
@@ -7552,9 +7858,24 @@ const fieldsConfiguration$2 = [
7552
7858
  to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
7553
7859
  },
7554
7860
  },
7555
- 'description',
7556
- 'images',
7557
- 'miniatures',
7861
+ {
7862
+ images: {
7863
+ columnName: 'images',
7864
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7865
+ },
7866
+ },
7867
+ {
7868
+ miniatures: {
7869
+ columnName: 'miniatures',
7870
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7871
+ },
7872
+ },
7873
+ {
7874
+ imagesCard: {
7875
+ columnName: 'images_card',
7876
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7877
+ },
7878
+ },
7558
7879
  { tagsProfile: { columnName: 'tags_profile' } },
7559
7880
  { tagsCollection: { columnName: 'tags_collection' } },
7560
7881
  ],
@@ -7620,9 +7941,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7620
7941
  ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
7621
7942
  .data?.[0]
7622
7943
  : await super.get(identifiers, options);
7623
- if (product.productId)
7624
- throw new NotFoundError('Product not found, it is a variant');
7625
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
7944
+ // if (product.productId) throw new NotFoundError('Product not found, it is a variant')
7945
+ product.reviews =
7946
+ product.reviews ||
7947
+ (await this.findReviewsByProduct(product.productId ? +product.productId : +product.id, false, options));
7626
7948
  return product;
7627
7949
  }
7628
7950
  async find(params, optionsParams) {
@@ -7639,7 +7961,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7639
7961
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7640
7962
  return super.find({
7641
7963
  ...options,
7642
- filters: { ...filters, productId: { operator: exports.Where.ISNULL } },
7964
+ filters: { ...filters },
7965
+ // filters: { ...filters, hasVariants: { operator: Where.EQUALS, value: false } },
7966
+ // filters: { ...filters, productId: { operator: Where.ISNULL } },
7643
7967
  fields: [
7644
7968
  ...bindFields,
7645
7969
  ...(bindFields.includes('price')
@@ -7673,6 +7997,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7673
7997
  if (!result.data.length)
7674
7998
  return null;
7675
7999
  const product = result?.data?.shift();
8000
+ if (product.productId) ;
8001
+ console.warn('product getBySlug', product);
8002
+ console.warn('vai entrar', !product.reviews.length && product.rate > 0);
8003
+ if (!product.reviews.length && product.rate > 0) {
8004
+ console.warn('entrou');
8005
+ product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
8006
+ }
7676
8007
  RoundProductPricesHelper.roundProductPrices(product);
7677
8008
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7678
8009
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -7685,6 +8016,18 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7685
8016
  }
7686
8017
  return product;
7687
8018
  }
8019
+ async getBySlugVariantData(product) {
8020
+ if (!product.reviews.length && product.rate > 0) {
8021
+ product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
8022
+ }
8023
+ // if (!product.metadata) {
8024
+ // product.metadata = await this.findReviewsByProduct(
8025
+ // (product.productId ? product.productId : product.id) as number,
8026
+ // true,
8027
+ // )
8028
+ // }
8029
+ return product;
8030
+ }
7688
8031
  async getByEAN(EAN, options) {
7689
8032
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7690
8033
  const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
@@ -7874,7 +8217,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7874
8217
  return data?.[0]?.id;
7875
8218
  throw new NotFoundError(`Product with id ${id} not found`);
7876
8219
  }
7877
- async findReviewsByProduct(productId, options) {
8220
+ async findReviewsByProduct(productId, onlyApproved, options) {
7878
8221
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7879
8222
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
7880
8223
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -7887,6 +8230,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7887
8230
  where: {
7888
8231
  value: {
7889
8232
  product_id: { _eq: productId },
8233
+ ...(onlyApproved && { status: { _eq: true } }),
7890
8234
  },
7891
8235
  type: 'product_review_bool_exp',
7892
8236
  required: true,
@@ -7995,7 +8339,7 @@ tslib.__decorate([
7995
8339
  tslib.__decorate([
7996
8340
  Log(),
7997
8341
  tslib.__metadata("design:type", Function),
7998
- tslib.__metadata("design:paramtypes", [Number, Object]),
8342
+ tslib.__metadata("design:paramtypes", [Number, Boolean, Object]),
7999
8343
  tslib.__metadata("design:returntype", Promise)
8000
8344
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8001
8345
 
@@ -8225,8 +8569,101 @@ const fieldsConfiguration$1 = [
8225
8569
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8226
8570
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8227
8571
  { daysOfUse: { columnName: 'days_of_use' } },
8228
- 'images',
8229
- 'miniatures',
8572
+ {
8573
+ images: {
8574
+ columnName: 'images',
8575
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8576
+ },
8577
+ },
8578
+ {
8579
+ miniatures: {
8580
+ columnName: 'miniatures',
8581
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8582
+ },
8583
+ },
8584
+ {
8585
+ imagesCard: {
8586
+ columnName: 'images_card',
8587
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8588
+ },
8589
+ },
8590
+ 'slug',
8591
+ 'brand',
8592
+ 'name',
8593
+ 'sku',
8594
+ { NCM: { columnName: 'ncm' } },
8595
+ { CEST: { columnName: 'cest' } },
8596
+ {
8597
+ description: {
8598
+ columnName: 'description',
8599
+ from: (description, data) => ({
8600
+ description,
8601
+ differentials: data.differentials,
8602
+ whoMustUse: data.who_must_use,
8603
+ howToUse: data.how_to_use,
8604
+ brand: data.brand_description,
8605
+ ingredients: data.ingredients,
8606
+ purpose: data.purpose,
8607
+ }),
8608
+ bindFindFilter: (filters) => {
8609
+ return {
8610
+ ...(filters?.description && { description: filters.description }),
8611
+ ...(filters.differentials && { differentials: filters.differentials }),
8612
+ ...(filters.whoMustUse && {
8613
+ who_must_use: filters.whoMustUse,
8614
+ }),
8615
+ ...(filters.howToUse && {
8616
+ how_to_use: filters.howToUse,
8617
+ }),
8618
+ ...(filters.brand && {
8619
+ brand_description: filters.brand,
8620
+ }),
8621
+ ...(filters.ingredients && {
8622
+ ingredients: filters.ingredients,
8623
+ }),
8624
+ ...(filters.purpose && {
8625
+ purpose: filters.purpose,
8626
+ }),
8627
+ };
8628
+ },
8629
+ bindPersistData: (descriptionData) => ({
8630
+ ...(descriptionData?.description && { description: descriptionData.description }),
8631
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8632
+ ...(descriptionData.whoMustUse && {
8633
+ who_must_use: descriptionData.whoMustUse,
8634
+ }),
8635
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8636
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8637
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8638
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8639
+ }),
8640
+ },
8641
+ },
8642
+ { differentials: { columnName: 'differentials' } },
8643
+ { whoMustUse: { columnName: 'who_must_use' } },
8644
+ { howToUse: { columnName: 'how_to_use' } },
8645
+ { brandDescription: { columnName: 'brand_description' } },
8646
+ { ingredients: { columnName: 'ingredients' } },
8647
+ { purpose: { columnName: 'purpose' } },
8648
+ 'gender',
8649
+ { intGender: { columnName: 'int_gender' } },
8650
+ 'label',
8651
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8652
+ { rate: { columnName: 'rating' } },
8653
+ { reviewsTotal: { columnName: 'reviews_total' } },
8654
+ { shoppingCount: { columnName: 'shopping_count' } },
8655
+ { categoryId: { columnName: 'category_id' } },
8656
+ {
8657
+ metadata: {
8658
+ columnName: 'metadata',
8659
+ fields: ['title', 'description'],
8660
+ bindPersistData: (value) => ({
8661
+ metadata: { data: value },
8662
+ }),
8663
+ },
8664
+ },
8665
+ { createdAt: { columnName: 'created_at' } },
8666
+ { updatedAt: { columnName: 'updated_at' } },
8230
8667
  ];
8231
8668
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8232
8669
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8267,18 +8704,37 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8267
8704
  return data.at(0);
8268
8705
  }
8269
8706
  async update(params) {
8270
- const { productId, id: checkId, ...data } = params;
8707
+ const { productId, id: checkId, metadata, ...data } = params;
8271
8708
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8272
8709
  if (!dataWithProductId.id) {
8273
8710
  throw new NotFoundError('Variant ID is required for update');
8274
8711
  }
8275
8712
  const id = await this.getId(dataWithProductId.id);
8276
8713
  const product = await super.update({ id, ...data });
8714
+ product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8277
8715
  if (dataWithProductId.productId) {
8278
8716
  product.productId = dataWithProductId.productId;
8279
8717
  }
8280
8718
  return product;
8281
8719
  }
8720
+ async updateMetadata(productId, { metadata }) {
8721
+ const plainData = this.paramsToPlain({ metadata });
8722
+ if (!plainData.metadata)
8723
+ return null;
8724
+ await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8725
+ pk_columns: {
8726
+ value: { product_id: productId },
8727
+ type: 'product_metadata_pk_columns_input',
8728
+ required: true,
8729
+ },
8730
+ _set: {
8731
+ value: lodash.omit(metadata, ['product_id']),
8732
+ type: 'product_metadata_set_input',
8733
+ required: true,
8734
+ },
8735
+ });
8736
+ return plainData.metadata;
8737
+ }
8282
8738
  async getId(id) {
8283
8739
  if (!Number.isNaN(+id))
8284
8740
  return id;
@@ -9830,6 +10286,7 @@ exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
9830
10286
  exports.PaymentProviderFactory = PaymentProviderFactory;
9831
10287
  exports.PaymentTransaction = PaymentTransaction;
9832
10288
  exports.Product = Product;
10289
+ exports.ProductCatalogHasuraGraphQLRepository = ProductCatalogHasuraGraphQLRepository;
9833
10290
  exports.ProductErrors = ProductErrors;
9834
10291
  exports.ProductErrorsHasuraGraphQL = ProductErrorsHasuraGraphQL;
9835
10292
  exports.ProductErrorsHasuraGraphQLRepository = ProductErrorsHasuraGraphQLRepository;
package/index.esm.js CHANGED
@@ -8,7 +8,7 @@ export { formatInTimeZone, fromZonedTime, toZonedTime } 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';
11
- import serializeJavascript from 'serialize-javascript';
11
+ import * as serializeJavascript from 'serialize-javascript';
12
12
  import { CustomError } from 'ts-custom-error';
13
13
  import axios, { AxiosError } from 'axios';
14
14
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, browserPopupRedirectResolver, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
@@ -847,7 +847,11 @@ class Variant extends ProductBase {
847
847
  static get identifiersFields() {
848
848
  return ['id', 'productId'];
849
849
  }
850
- }
850
+ }
851
+ __decorate([
852
+ Type(() => Product),
853
+ __metadata("design:type", Product)
854
+ ], Variant.prototype, "product", void 0);
851
855
 
852
856
  class Product extends ProductBase {
853
857
  }
@@ -3368,6 +3372,8 @@ class HasuraQueryBuilderHelper {
3368
3372
  class HasuraRequestHelper {
3369
3373
  static async fetch(params) {
3370
3374
  const { variables, query, endpoint, headers, logger } = params;
3375
+ console.warn('variables', variables);
3376
+ console.warn('query', query);
3371
3377
  const request = {
3372
3378
  url: endpoint,
3373
3379
  method: 'POST',
@@ -7192,6 +7198,227 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7192
7198
  }
7193
7199
  }
7194
7200
 
7201
+ const commonFields$1 = [
7202
+ {
7203
+ id: {
7204
+ columnName: 'id',
7205
+ to: (value) => +value,
7206
+ from: (value) => value.toString(),
7207
+ },
7208
+ },
7209
+ { firestoreId: { columnName: 'firestore_id' } },
7210
+ { productId: { columnName: 'main_product_id' } },
7211
+ { CEST: { columnName: 'cest' } },
7212
+ { EAN: { columnName: 'ean' } },
7213
+ { NCM: { columnName: 'ncm' } },
7214
+ 'brand',
7215
+ { costPrice: { columnName: 'cost_price' } },
7216
+ {
7217
+ description: {
7218
+ columnName: 'description',
7219
+ from: (description, data) => ({
7220
+ description,
7221
+ differentials: data.differentials,
7222
+ whoMustUse: data.who_must_use,
7223
+ howToUse: data.how_to_use,
7224
+ brand: data.brand_description,
7225
+ ingredients: data.ingredients,
7226
+ purpose: data.purpose,
7227
+ }),
7228
+ bindFindFilter: (filters) => {
7229
+ return {
7230
+ ...(filters?.description && { description: filters.description }),
7231
+ ...(filters.differentials && { differentials: filters.differentials }),
7232
+ ...(filters.whoMustUse && {
7233
+ who_must_use: filters.whoMustUse,
7234
+ }),
7235
+ ...(filters.howToUse && {
7236
+ how_to_use: filters.howToUse,
7237
+ }),
7238
+ ...(filters.brand && {
7239
+ brand_description: filters.brand,
7240
+ }),
7241
+ ...(filters.ingredients && {
7242
+ ingredients: filters.ingredients,
7243
+ }),
7244
+ ...(filters.purpose && {
7245
+ purpose: filters.purpose,
7246
+ }),
7247
+ };
7248
+ },
7249
+ bindPersistData: (descriptionData) => ({
7250
+ ...(descriptionData?.description && { description: descriptionData.description }),
7251
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7252
+ ...(descriptionData.whoMustUse && {
7253
+ who_must_use: descriptionData.whoMustUse,
7254
+ }),
7255
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7256
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7257
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7258
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7259
+ }),
7260
+ },
7261
+ },
7262
+ { differentials: { columnName: 'differentials' } },
7263
+ { whoMustUse: { columnName: 'who_must_use' } },
7264
+ { howToUse: { columnName: 'how_to_use' } },
7265
+ { brandDescription: { columnName: 'brand_description' } },
7266
+ { ingredients: { columnName: 'ingredients' } },
7267
+ { purpose: { columnName: 'purpose' } },
7268
+ { hasVariants: { columnName: 'has_variants' } },
7269
+ {
7270
+ images: {
7271
+ columnName: 'images',
7272
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7273
+ },
7274
+ },
7275
+ {
7276
+ miniatures: {
7277
+ columnName: 'miniatures',
7278
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7279
+ },
7280
+ },
7281
+ {
7282
+ imagesCard: {
7283
+ columnName: 'images_card',
7284
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7285
+ },
7286
+ },
7287
+ 'name',
7288
+ {
7289
+ price: {
7290
+ columnName: 'price',
7291
+ from: (price, data) => ({
7292
+ price,
7293
+ fullPrice: data.full_price,
7294
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
7295
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
7296
+ subscriberPrice: data.subscriber_price,
7297
+ }),
7298
+ bindFindFilter: (filters) => {
7299
+ return {
7300
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7301
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7302
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7303
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7304
+ }),
7305
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7306
+ subscriber_price: filters.subscriberPrice,
7307
+ }),
7308
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7309
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7310
+ }),
7311
+ };
7312
+ },
7313
+ bindPersistData: (priceData) => ({
7314
+ ...(priceData?.price >= 0 && { price: priceData.price }),
7315
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7316
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
7317
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7318
+ }),
7319
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7320
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
7321
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7322
+ }),
7323
+ }),
7324
+ },
7325
+ },
7326
+ { fullPrice: { columnName: 'full_price' } },
7327
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7328
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7329
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7330
+ 'published',
7331
+ 'outlet',
7332
+ 'label',
7333
+ 'sku',
7334
+ {
7335
+ stock: {
7336
+ columnName: 'stock',
7337
+ from: (quantity) => ({ quantity }),
7338
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7339
+ },
7340
+ },
7341
+ { hasStock: { columnName: 'has_stock' } },
7342
+ 'slug',
7343
+ 'type',
7344
+ 'video',
7345
+ 'weight',
7346
+ 'gender',
7347
+ { intGender: { columnName: 'int_gender' } },
7348
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7349
+ { isKit: { columnName: 'is_kit' } },
7350
+ { createdAt: { columnName: 'created_at' } },
7351
+ { updatedAt: { columnName: 'updated_at' } },
7352
+ { rate: { columnName: 'rating' } },
7353
+ { reviewsTotal: { columnName: 'reviews_total' } },
7354
+ { shoppingCount: { columnName: 'shopping_count' } },
7355
+ { categoryId: { columnName: 'category_id' } },
7356
+ 'group',
7357
+ 'validity',
7358
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7359
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7360
+ { daysOfUse: { columnName: 'days_of_use' } },
7361
+ { showVariants: { columnName: 'show_variants' } },
7362
+ ];
7363
+ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7364
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
7365
+ super({
7366
+ tableName: 'product_catalog',
7367
+ model: ProductHasuraGraphQL,
7368
+ endpoint,
7369
+ authOptions,
7370
+ interceptors,
7371
+ fields: commonFields$1,
7372
+ cache,
7373
+ });
7374
+ }
7375
+ async find(params, optionsParams) {
7376
+ const { filters, fields, ...options } = params || {};
7377
+ const bindFields = fields ||
7378
+ this.fields
7379
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7380
+ .filter((field) => field !== 'reviews' && field !== 'categories');
7381
+ if (options.options?.minimal?.includes('price'))
7382
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7383
+ if (options.options?.maximum?.includes('price'))
7384
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7385
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7386
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7387
+ return super.find({
7388
+ ...options,
7389
+ filters: { ...filters },
7390
+ fields: [
7391
+ ...bindFields,
7392
+ ...(bindFields.includes('price')
7393
+ ? [
7394
+ 'subscriberPrice',
7395
+ 'subscriberDiscountPercentage',
7396
+ 'fullPrice',
7397
+ ]
7398
+ : []),
7399
+ ],
7400
+ }, optionsParams);
7401
+ }
7402
+ async findCatalog(params, mainGender, options) {
7403
+ const result = await this.find({
7404
+ ...params,
7405
+ filters: { ...params.filters, published: true },
7406
+ orderBy: {
7407
+ hasStock: 'desc',
7408
+ ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7409
+ ...omit(params.orderBy, ['hasStock', 'intGender']),
7410
+ },
7411
+ }, options);
7412
+ return result;
7413
+ }
7414
+ }
7415
+ __decorate([
7416
+ Log(),
7417
+ __metadata("design:type", Function),
7418
+ __metadata("design:paramtypes", [Object, Object, Object]),
7419
+ __metadata("design:returntype", Promise)
7420
+ ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7421
+
7195
7422
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7196
7423
  constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7197
7424
  super({
@@ -7348,6 +7575,12 @@ const commonFields = [
7348
7575
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7349
7576
  },
7350
7577
  },
7578
+ {
7579
+ imagesCard: {
7580
+ columnName: 'images_card',
7581
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7582
+ },
7583
+ },
7351
7584
  'name',
7352
7585
  {
7353
7586
  price: {
@@ -7429,6 +7662,7 @@ const commonFields = [
7429
7662
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7430
7663
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7431
7664
  { daysOfUse: { columnName: 'days_of_use' } },
7665
+ { showVariants: { columnName: 'show_variants' } },
7432
7666
  ];
7433
7667
  const fieldsConfiguration$2 = [
7434
7668
  ...commonFields,
@@ -7492,7 +7726,61 @@ const fieldsConfiguration$2 = [
7492
7726
  foreignKeyColumn: { product_id: 'id' },
7493
7727
  fields: [
7494
7728
  'id',
7729
+ 'name',
7495
7730
  'ean',
7731
+ 'sku',
7732
+ {
7733
+ description: {
7734
+ columnName: 'description',
7735
+ from: (description, data) => ({
7736
+ description,
7737
+ differentials: data.differentials,
7738
+ whoMustUse: data.who_must_use,
7739
+ howToUse: data.how_to_use,
7740
+ brand: data.brand_description,
7741
+ ingredients: data.ingredients,
7742
+ purpose: data.purpose,
7743
+ }),
7744
+ bindFindFilter: (filters) => {
7745
+ return {
7746
+ ...(filters?.description && { description: filters.description }),
7747
+ ...(filters.differentials && { differentials: filters.differentials }),
7748
+ ...(filters.whoMustUse && {
7749
+ who_must_use: filters.whoMustUse,
7750
+ }),
7751
+ ...(filters.howToUse && {
7752
+ how_to_use: filters.howToUse,
7753
+ }),
7754
+ ...(filters.brand && {
7755
+ brand_description: filters.brand,
7756
+ }),
7757
+ ...(filters.ingredients && {
7758
+ ingredients: filters.ingredients,
7759
+ }),
7760
+ ...(filters.purpose && {
7761
+ purpose: filters.purpose,
7762
+ }),
7763
+ };
7764
+ },
7765
+ bindPersistData: (descriptionData) => ({
7766
+ ...(descriptionData?.description && { description: descriptionData.description }),
7767
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7768
+ ...(descriptionData.whoMustUse && {
7769
+ who_must_use: descriptionData.whoMustUse,
7770
+ }),
7771
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7772
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7773
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7774
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7775
+ }),
7776
+ },
7777
+ },
7778
+ { differentials: { columnName: 'differentials' } },
7779
+ { whoMustUse: { columnName: 'who_must_use' } },
7780
+ { howToUse: { columnName: 'how_to_use' } },
7781
+ { brandDescription: { columnName: 'brand_description' } },
7782
+ { ingredients: { columnName: 'ingredients' } },
7783
+ { purpose: { columnName: 'purpose' } },
7496
7784
  {
7497
7785
  grade: {
7498
7786
  columnName: 'grade',
@@ -7546,9 +7834,24 @@ const fieldsConfiguration$2 = [
7546
7834
  to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7547
7835
  },
7548
7836
  },
7549
- 'description',
7550
- 'images',
7551
- 'miniatures',
7837
+ {
7838
+ images: {
7839
+ columnName: 'images',
7840
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7841
+ },
7842
+ },
7843
+ {
7844
+ miniatures: {
7845
+ columnName: 'miniatures',
7846
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7847
+ },
7848
+ },
7849
+ {
7850
+ imagesCard: {
7851
+ columnName: 'images_card',
7852
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7853
+ },
7854
+ },
7552
7855
  { tagsProfile: { columnName: 'tags_profile' } },
7553
7856
  { tagsCollection: { columnName: 'tags_collection' } },
7554
7857
  ],
@@ -7614,9 +7917,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7614
7917
  ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
7615
7918
  .data?.[0]
7616
7919
  : await super.get(identifiers, options);
7617
- if (product.productId)
7618
- throw new NotFoundError('Product not found, it is a variant');
7619
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
7920
+ // if (product.productId) throw new NotFoundError('Product not found, it is a variant')
7921
+ product.reviews =
7922
+ product.reviews ||
7923
+ (await this.findReviewsByProduct(product.productId ? +product.productId : +product.id, false, options));
7620
7924
  return product;
7621
7925
  }
7622
7926
  async find(params, optionsParams) {
@@ -7633,7 +7937,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7633
7937
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7634
7938
  return super.find({
7635
7939
  ...options,
7636
- filters: { ...filters, productId: { operator: Where.ISNULL } },
7940
+ filters: { ...filters },
7941
+ // filters: { ...filters, hasVariants: { operator: Where.EQUALS, value: false } },
7942
+ // filters: { ...filters, productId: { operator: Where.ISNULL } },
7637
7943
  fields: [
7638
7944
  ...bindFields,
7639
7945
  ...(bindFields.includes('price')
@@ -7667,6 +7973,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7667
7973
  if (!result.data.length)
7668
7974
  return null;
7669
7975
  const product = result?.data?.shift();
7976
+ if (product.productId) ;
7977
+ console.warn('product getBySlug', product);
7978
+ console.warn('vai entrar', !product.reviews.length && product.rate > 0);
7979
+ if (!product.reviews.length && product.rate > 0) {
7980
+ console.warn('entrou');
7981
+ product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
7982
+ }
7670
7983
  RoundProductPricesHelper.roundProductPrices(product);
7671
7984
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7672
7985
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -7679,6 +7992,18 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7679
7992
  }
7680
7993
  return product;
7681
7994
  }
7995
+ async getBySlugVariantData(product) {
7996
+ if (!product.reviews.length && product.rate > 0) {
7997
+ product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
7998
+ }
7999
+ // if (!product.metadata) {
8000
+ // product.metadata = await this.findReviewsByProduct(
8001
+ // (product.productId ? product.productId : product.id) as number,
8002
+ // true,
8003
+ // )
8004
+ // }
8005
+ return product;
8006
+ }
7682
8007
  async getByEAN(EAN, options) {
7683
8008
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7684
8009
  const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
@@ -7868,7 +8193,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7868
8193
  return data?.[0]?.id;
7869
8194
  throw new NotFoundError(`Product with id ${id} not found`);
7870
8195
  }
7871
- async findReviewsByProduct(productId, options) {
8196
+ async findReviewsByProduct(productId, onlyApproved, options) {
7872
8197
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7873
8198
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
7874
8199
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -7881,6 +8206,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7881
8206
  where: {
7882
8207
  value: {
7883
8208
  product_id: { _eq: productId },
8209
+ ...(onlyApproved && { status: { _eq: true } }),
7884
8210
  },
7885
8211
  type: 'product_review_bool_exp',
7886
8212
  required: true,
@@ -7989,7 +8315,7 @@ __decorate([
7989
8315
  __decorate([
7990
8316
  Log(),
7991
8317
  __metadata("design:type", Function),
7992
- __metadata("design:paramtypes", [Number, Object]),
8318
+ __metadata("design:paramtypes", [Number, Boolean, Object]),
7993
8319
  __metadata("design:returntype", Promise)
7994
8320
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
7995
8321
 
@@ -8219,8 +8545,101 @@ const fieldsConfiguration$1 = [
8219
8545
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8220
8546
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8221
8547
  { daysOfUse: { columnName: 'days_of_use' } },
8222
- 'images',
8223
- 'miniatures',
8548
+ {
8549
+ images: {
8550
+ columnName: 'images',
8551
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8552
+ },
8553
+ },
8554
+ {
8555
+ miniatures: {
8556
+ columnName: 'miniatures',
8557
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8558
+ },
8559
+ },
8560
+ {
8561
+ imagesCard: {
8562
+ columnName: 'images_card',
8563
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8564
+ },
8565
+ },
8566
+ 'slug',
8567
+ 'brand',
8568
+ 'name',
8569
+ 'sku',
8570
+ { NCM: { columnName: 'ncm' } },
8571
+ { CEST: { columnName: 'cest' } },
8572
+ {
8573
+ description: {
8574
+ columnName: 'description',
8575
+ from: (description, data) => ({
8576
+ description,
8577
+ differentials: data.differentials,
8578
+ whoMustUse: data.who_must_use,
8579
+ howToUse: data.how_to_use,
8580
+ brand: data.brand_description,
8581
+ ingredients: data.ingredients,
8582
+ purpose: data.purpose,
8583
+ }),
8584
+ bindFindFilter: (filters) => {
8585
+ return {
8586
+ ...(filters?.description && { description: filters.description }),
8587
+ ...(filters.differentials && { differentials: filters.differentials }),
8588
+ ...(filters.whoMustUse && {
8589
+ who_must_use: filters.whoMustUse,
8590
+ }),
8591
+ ...(filters.howToUse && {
8592
+ how_to_use: filters.howToUse,
8593
+ }),
8594
+ ...(filters.brand && {
8595
+ brand_description: filters.brand,
8596
+ }),
8597
+ ...(filters.ingredients && {
8598
+ ingredients: filters.ingredients,
8599
+ }),
8600
+ ...(filters.purpose && {
8601
+ purpose: filters.purpose,
8602
+ }),
8603
+ };
8604
+ },
8605
+ bindPersistData: (descriptionData) => ({
8606
+ ...(descriptionData?.description && { description: descriptionData.description }),
8607
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8608
+ ...(descriptionData.whoMustUse && {
8609
+ who_must_use: descriptionData.whoMustUse,
8610
+ }),
8611
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8612
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8613
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8614
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8615
+ }),
8616
+ },
8617
+ },
8618
+ { differentials: { columnName: 'differentials' } },
8619
+ { whoMustUse: { columnName: 'who_must_use' } },
8620
+ { howToUse: { columnName: 'how_to_use' } },
8621
+ { brandDescription: { columnName: 'brand_description' } },
8622
+ { ingredients: { columnName: 'ingredients' } },
8623
+ { purpose: { columnName: 'purpose' } },
8624
+ 'gender',
8625
+ { intGender: { columnName: 'int_gender' } },
8626
+ 'label',
8627
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8628
+ { rate: { columnName: 'rating' } },
8629
+ { reviewsTotal: { columnName: 'reviews_total' } },
8630
+ { shoppingCount: { columnName: 'shopping_count' } },
8631
+ { categoryId: { columnName: 'category_id' } },
8632
+ {
8633
+ metadata: {
8634
+ columnName: 'metadata',
8635
+ fields: ['title', 'description'],
8636
+ bindPersistData: (value) => ({
8637
+ metadata: { data: value },
8638
+ }),
8639
+ },
8640
+ },
8641
+ { createdAt: { columnName: 'created_at' } },
8642
+ { updatedAt: { columnName: 'updated_at' } },
8224
8643
  ];
8225
8644
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8226
8645
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8261,18 +8680,37 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8261
8680
  return data.at(0);
8262
8681
  }
8263
8682
  async update(params) {
8264
- const { productId, id: checkId, ...data } = params;
8683
+ const { productId, id: checkId, metadata, ...data } = params;
8265
8684
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8266
8685
  if (!dataWithProductId.id) {
8267
8686
  throw new NotFoundError('Variant ID is required for update');
8268
8687
  }
8269
8688
  const id = await this.getId(dataWithProductId.id);
8270
8689
  const product = await super.update({ id, ...data });
8690
+ product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8271
8691
  if (dataWithProductId.productId) {
8272
8692
  product.productId = dataWithProductId.productId;
8273
8693
  }
8274
8694
  return product;
8275
8695
  }
8696
+ async updateMetadata(productId, { metadata }) {
8697
+ const plainData = this.paramsToPlain({ metadata });
8698
+ if (!plainData.metadata)
8699
+ return null;
8700
+ await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8701
+ pk_columns: {
8702
+ value: { product_id: productId },
8703
+ type: 'product_metadata_pk_columns_input',
8704
+ required: true,
8705
+ },
8706
+ _set: {
8707
+ value: omit(metadata, ['product_id']),
8708
+ type: 'product_metadata_set_input',
8709
+ required: true,
8710
+ },
8711
+ });
8712
+ return plainData.metadata;
8713
+ }
8276
8714
  async getId(id) {
8277
8715
  if (!Number.isNaN(+id))
8278
8716
  return id;
@@ -9600,4 +10038,4 @@ class ProductsVertexSearch {
9600
10038
  }
9601
10039
  }
9602
10040
 
9603
- 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 };
10041
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.4.0-alpha.3",
3
+ "version": "5.4.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -19,6 +19,7 @@ export declare class ProductBase<T extends ProductBase<T, I>, I = ProductIdentif
19
19
  costPrice: number;
20
20
  images?: string[];
21
21
  miniatures?: string[];
22
+ imagesCard?: string[];
22
23
  published: boolean;
23
24
  createdAt?: Date;
24
25
  updatedAt?: Date;
@@ -2,5 +2,6 @@ import { ProductBase } from './product-base';
2
2
  import { Variant } from './variant';
3
3
  export declare class Product extends ProductBase<Product> {
4
4
  hasVariants: boolean;
5
+ showVariants: boolean;
5
6
  variants?: Variant[];
6
7
  }
@@ -1,8 +1,10 @@
1
+ import { Product } from './product';
1
2
  import { ProductBase } from './product-base';
2
3
  import { VariantGrade } from './types';
3
4
  export type ProductVariantIdentifiers = 'id' | 'productId';
4
5
  export declare class Variant extends ProductBase<Variant, ProductVariantIdentifiers> {
5
6
  productId: string;
6
7
  grade?: VariantGrade[];
8
+ product?: Product;
7
9
  static get identifiersFields(): ProductVariantIdentifiers[];
8
10
  }
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
5
5
  export declare const withHelpers: <TMixinBase extends MixinCtor<any, any[]> = MixinCtor<any, any[]>>(MixinBase: MixinCtor<any, any[]> & TMixinBase) => {
6
6
  new (...args: any[]): {
7
7
  [x: string]: any;
8
- toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
8
+ toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T, import("firebase/firestore").DocumentData> | QueryDocumentSnapshot<T, import("firebase/firestore").DocumentData>[]): T[];
9
9
  isSubCollection<T_1 extends ModelBaseStructure<T_1, T_1["identifiersFields"][number]>, E extends ModelBaseStructure<E, E["identifiersFields"][number]>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
10
10
  };
11
11
  } & TMixinBase;
@@ -4,6 +4,7 @@ export * from './category-hasura-graphql.repository';
4
4
  export * from './category-product-hasura-graphql.repository';
5
5
  export * from './filter-hasura-graphql.repository';
6
6
  export * from './filter-option-hasura-graphql.repository';
7
+ export * from './product-catalog-hasura-graphql.repository';
7
8
  export * from './product-errors-hasura-graphql.repository';
8
9
  export * from './product-hasura-graphql.repository';
9
10
  export * from './product-review-hasura-graphql.repository';
@@ -0,0 +1,14 @@
1
+ import { FindRepositoryParams, ProductGender, RepositoryCacheOptions, RepositoryFindResult } from '../../../../domain';
2
+ import { HasuraConstructorParams } from '../../mixins';
3
+ import { ProductHasuraGraphQL } from '../../models';
4
+ declare const ProductCatalogHasuraGraphQLRepository_base: import("../../../../utils").MixinCtor<import("../../types").GraphQLRepository<ProductHasuraGraphQL> & import("../../../../domain").FindRepository<ProductHasuraGraphQL, FindRepositoryParams<ProductHasuraGraphQL>>, any[]>;
5
+ export declare class ProductCatalogHasuraGraphQLRepository extends ProductCatalogHasuraGraphQLRepository_base {
6
+ constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<ProductHasuraGraphQL>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>);
7
+ find(params?: FindRepositoryParams<ProductHasuraGraphQL>, optionsParams?: {
8
+ cache?: RepositoryCacheOptions;
9
+ }): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
10
+ findCatalog(params: FindRepositoryParams<ProductHasuraGraphQL>, mainGender?: Extract<ProductGender, 'female' | 'male'>, options?: {
11
+ cache?: RepositoryCacheOptions;
12
+ }): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
13
+ }
14
+ export {};
@@ -15,6 +15,7 @@ export declare class ProductHasuraGraphQLRepository extends ProductHasuraGraphQL
15
15
  getBySlug(slug: string, options?: {
16
16
  cache?: RepositoryCacheOptions;
17
17
  }): Promise<ProductHasuraGraphQL>;
18
+ private getBySlugVariantData;
18
19
  getByEAN(EAN: string, options?: {
19
20
  cache?: RepositoryCacheOptions;
20
21
  }): Promise<ProductHasuraGraphQL>;
@@ -8,6 +8,7 @@ export declare class VariantHasuraGraphQLRepository extends VariantHasuraGraphQL
8
8
  find(params?: FindRepositoryParams<VariantHasuraGraphQL>): Promise<RepositoryFindResult<VariantHasuraGraphQL>>;
9
9
  getByEAN(EAN: string): Promise<VariantHasuraGraphQL>;
10
10
  update(params: UpdateRepositoryParams<VariantHasuraGraphQL>): Promise<VariantHasuraGraphQL>;
11
+ private updateMetadata;
11
12
  private getId;
12
13
  }
13
14
  export {};