@infrab4a/connect 5.3.0-beta.0 → 5.3.0-beta.2

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
@@ -1592,7 +1592,7 @@ exports.OrderStatus = void 0;
1592
1592
  OrderStatus["ENVIADO"] = "Enviado";
1593
1593
  OrderStatus["ENTREGUE"] = "Entregue";
1594
1594
  OrderStatus["CANCELADO"] = "Cancelado";
1595
- OrderStatus["CREDIT_CARD"] = "credit_card";
1595
+ OrderStatus["PENDENTE_REENVIO"] = "Pendente reenvio";
1596
1596
  })(exports.OrderStatus || (exports.OrderStatus = {}));
1597
1597
 
1598
1598
  class Order extends Checkout {
@@ -4891,6 +4891,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
4891
4891
  productVariantFullReport() {
4892
4892
  return;
4893
4893
  }
4894
+ getByEAN(EAN, options) {
4895
+ return;
4896
+ }
4894
4897
  }
4895
4898
  tslib.__decorate([
4896
4899
  Log(),
@@ -4916,6 +4919,9 @@ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirest
4916
4919
  });
4917
4920
  this.parentRepository = parentRepository;
4918
4921
  }
4922
+ getByEAN(EAN) {
4923
+ return;
4924
+ }
4919
4925
  }
4920
4926
 
4921
4927
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
@@ -6152,7 +6158,8 @@ class CategoryProductOperationsHelper {
6152
6158
  'isKit',
6153
6159
  'sku',
6154
6160
  'rate',
6155
- 'tags',
6161
+ 'tagsProfile',
6162
+ 'tagsCollection',
6156
6163
  'type',
6157
6164
  'shoppingCount',
6158
6165
  'gender',
@@ -7373,7 +7380,7 @@ const commonFields = [
7373
7380
  'weight',
7374
7381
  'gender',
7375
7382
  { intGender: { columnName: 'int_gender' } },
7376
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7383
+ // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7377
7384
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7378
7385
  { isKit: { columnName: 'is_kit' } },
7379
7386
  { createdAt: { columnName: 'created_at' } },
@@ -7391,6 +7398,9 @@ const commonFields = [
7391
7398
  },
7392
7399
  'group',
7393
7400
  'validity',
7401
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7402
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7403
+ { daysOfUse: { columnName: 'days_of_use' } },
7394
7404
  ];
7395
7405
  const fieldsConfiguration$2 = [
7396
7406
  ...commonFields,
@@ -7448,6 +7458,13 @@ const fieldsConfiguration$2 = [
7448
7458
  }),
7449
7459
  },
7450
7460
  },
7461
+ {
7462
+ variants: {
7463
+ columnName: 'variants',
7464
+ foreignKeyColumn: { product_id: 'id' },
7465
+ fields: ['id', 'ean', 'grade', 'price', 'published', 'stock', 'tagsProfile'],
7466
+ },
7467
+ },
7451
7468
  ];
7452
7469
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7453
7470
  get reviewsFields() {
@@ -7573,6 +7590,39 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7573
7590
  }
7574
7591
  return product;
7575
7592
  }
7593
+ async getByEAN(EAN, options) {
7594
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7595
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7596
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7597
+ if (cachedData) {
7598
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7599
+ return this.model.toInstance(deserialize(cachedData));
7600
+ }
7601
+ }
7602
+ const result = await this.find({
7603
+ filters: {
7604
+ EAN,
7605
+ },
7606
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
7607
+ options: {
7608
+ enableCount: false,
7609
+ },
7610
+ });
7611
+ if (!result.data.length)
7612
+ return null;
7613
+ const product = result?.data?.shift();
7614
+ RoundProductPricesHelper.roundProductPrices(product);
7615
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7616
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7617
+ await this.cache.cacheAdapter.set({
7618
+ key: cacheKey,
7619
+ data: serialize(product),
7620
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7621
+ });
7622
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7623
+ }
7624
+ return product;
7625
+ }
7576
7626
  async update(params) {
7577
7627
  const { kitProducts, reviews, id: checkId, metadata, ...data } = lodash.omit(params, ['categories', 'rate']);
7578
7628
  const plainData = this.paramsToPlain({ id: checkId });
@@ -7817,6 +7867,12 @@ tslib.__decorate([
7817
7867
  tslib.__metadata("design:paramtypes", [String, Object]),
7818
7868
  tslib.__metadata("design:returntype", Promise)
7819
7869
  ], ProductHasuraGraphQLRepository.prototype, "getBySlug", null);
7870
+ tslib.__decorate([
7871
+ Log(),
7872
+ tslib.__metadata("design:type", Function),
7873
+ tslib.__metadata("design:paramtypes", [String, Object]),
7874
+ tslib.__metadata("design:returntype", Promise)
7875
+ ], ProductHasuraGraphQLRepository.prototype, "getByEAN", null);
7820
7876
  tslib.__decorate([
7821
7877
  Log(),
7822
7878
  tslib.__metadata("design:type", Function),
@@ -7872,6 +7928,13 @@ class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
7872
7928
  { orderId: { columnName: 'order_id' } },
7873
7929
  { createdAt: { columnName: 'created_at' } },
7874
7930
  { updatedAt: { columnName: 'updated_at' } },
7931
+ {
7932
+ product: {
7933
+ columnName: 'product',
7934
+ foreignKeyColumn: { id: 'productId' },
7935
+ fields: ['id', 'ean', 'sku', 'name', 'brand', 'slug', 'images', 'grade', 'gender'],
7936
+ },
7937
+ },
7875
7938
  ],
7876
7939
  cache,
7877
7940
  });
@@ -8063,8 +8126,11 @@ const fieldsConfiguration$1 = [
8063
8126
  },
8064
8127
  'group',
8065
8128
  'validity',
8066
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8129
+ // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8067
8130
  'published',
8131
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8132
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8133
+ { daysOfUse: { columnName: 'days_of_use' } },
8068
8134
  ];
8069
8135
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8070
8136
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8093,6 +8159,17 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8093
8159
  const { filters, ...options } = params || {};
8094
8160
  return super.find({ ...options, filters: { productId: { operator: exports.Where.ISNOTNULL }, ...filters } });
8095
8161
  }
8162
+ async getByEAN(EAN) {
8163
+ const { data } = await this.find({
8164
+ filters: {
8165
+ EAN,
8166
+ },
8167
+ options: {
8168
+ enableCount: false,
8169
+ },
8170
+ });
8171
+ return data.at(0);
8172
+ }
8096
8173
  async update(params) {
8097
8174
  const { productId, id: checkId, ...data } = params;
8098
8175
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
package/index.esm.js CHANGED
@@ -1567,7 +1567,7 @@ var OrderStatus;
1567
1567
  OrderStatus["ENVIADO"] = "Enviado";
1568
1568
  OrderStatus["ENTREGUE"] = "Entregue";
1569
1569
  OrderStatus["CANCELADO"] = "Cancelado";
1570
- OrderStatus["CREDIT_CARD"] = "credit_card";
1570
+ OrderStatus["PENDENTE_REENVIO"] = "Pendente reenvio";
1571
1571
  })(OrderStatus || (OrderStatus = {}));
1572
1572
 
1573
1573
  class Order extends Checkout {
@@ -4866,6 +4866,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
4866
4866
  productVariantFullReport() {
4867
4867
  return;
4868
4868
  }
4869
+ getByEAN(EAN, options) {
4870
+ return;
4871
+ }
4869
4872
  }
4870
4873
  __decorate([
4871
4874
  Log(),
@@ -4891,6 +4894,9 @@ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirest
4891
4894
  });
4892
4895
  this.parentRepository = parentRepository;
4893
4896
  }
4897
+ getByEAN(EAN) {
4898
+ return;
4899
+ }
4894
4900
  }
4895
4901
 
4896
4902
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
@@ -6127,7 +6133,8 @@ class CategoryProductOperationsHelper {
6127
6133
  'isKit',
6128
6134
  'sku',
6129
6135
  'rate',
6130
- 'tags',
6136
+ 'tagsProfile',
6137
+ 'tagsCollection',
6131
6138
  'type',
6132
6139
  'shoppingCount',
6133
6140
  'gender',
@@ -7348,7 +7355,7 @@ const commonFields = [
7348
7355
  'weight',
7349
7356
  'gender',
7350
7357
  { intGender: { columnName: 'int_gender' } },
7351
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7358
+ // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7352
7359
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7353
7360
  { isKit: { columnName: 'is_kit' } },
7354
7361
  { createdAt: { columnName: 'created_at' } },
@@ -7366,6 +7373,9 @@ const commonFields = [
7366
7373
  },
7367
7374
  'group',
7368
7375
  'validity',
7376
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7377
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7378
+ { daysOfUse: { columnName: 'days_of_use' } },
7369
7379
  ];
7370
7380
  const fieldsConfiguration$2 = [
7371
7381
  ...commonFields,
@@ -7423,6 +7433,13 @@ const fieldsConfiguration$2 = [
7423
7433
  }),
7424
7434
  },
7425
7435
  },
7436
+ {
7437
+ variants: {
7438
+ columnName: 'variants',
7439
+ foreignKeyColumn: { product_id: 'id' },
7440
+ fields: ['id', 'ean', 'grade', 'price', 'published', 'stock', 'tagsProfile'],
7441
+ },
7442
+ },
7426
7443
  ];
7427
7444
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7428
7445
  get reviewsFields() {
@@ -7548,6 +7565,39 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7548
7565
  }
7549
7566
  return product;
7550
7567
  }
7568
+ async getByEAN(EAN, options) {
7569
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7570
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7571
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7572
+ if (cachedData) {
7573
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7574
+ return this.model.toInstance(deserialize(cachedData));
7575
+ }
7576
+ }
7577
+ const result = await this.find({
7578
+ filters: {
7579
+ EAN,
7580
+ },
7581
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
7582
+ options: {
7583
+ enableCount: false,
7584
+ },
7585
+ });
7586
+ if (!result.data.length)
7587
+ return null;
7588
+ const product = result?.data?.shift();
7589
+ RoundProductPricesHelper.roundProductPrices(product);
7590
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7591
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7592
+ await this.cache.cacheAdapter.set({
7593
+ key: cacheKey,
7594
+ data: serialize(product),
7595
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7596
+ });
7597
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7598
+ }
7599
+ return product;
7600
+ }
7551
7601
  async update(params) {
7552
7602
  const { kitProducts, reviews, id: checkId, metadata, ...data } = omit(params, ['categories', 'rate']);
7553
7603
  const plainData = this.paramsToPlain({ id: checkId });
@@ -7792,6 +7842,12 @@ __decorate([
7792
7842
  __metadata("design:paramtypes", [String, Object]),
7793
7843
  __metadata("design:returntype", Promise)
7794
7844
  ], ProductHasuraGraphQLRepository.prototype, "getBySlug", null);
7845
+ __decorate([
7846
+ Log(),
7847
+ __metadata("design:type", Function),
7848
+ __metadata("design:paramtypes", [String, Object]),
7849
+ __metadata("design:returntype", Promise)
7850
+ ], ProductHasuraGraphQLRepository.prototype, "getByEAN", null);
7795
7851
  __decorate([
7796
7852
  Log(),
7797
7853
  __metadata("design:type", Function),
@@ -7847,6 +7903,13 @@ class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
7847
7903
  { orderId: { columnName: 'order_id' } },
7848
7904
  { createdAt: { columnName: 'created_at' } },
7849
7905
  { updatedAt: { columnName: 'updated_at' } },
7906
+ {
7907
+ product: {
7908
+ columnName: 'product',
7909
+ foreignKeyColumn: { id: 'productId' },
7910
+ fields: ['id', 'ean', 'sku', 'name', 'brand', 'slug', 'images', 'grade', 'gender'],
7911
+ },
7912
+ },
7850
7913
  ],
7851
7914
  cache,
7852
7915
  });
@@ -8038,8 +8101,11 @@ const fieldsConfiguration$1 = [
8038
8101
  },
8039
8102
  'group',
8040
8103
  'validity',
8041
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8104
+ // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8042
8105
  'published',
8106
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8107
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8108
+ { daysOfUse: { columnName: 'days_of_use' } },
8043
8109
  ];
8044
8110
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8045
8111
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8068,6 +8134,17 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8068
8134
  const { filters, ...options } = params || {};
8069
8135
  return super.find({ ...options, filters: { productId: { operator: Where.ISNOTNULL }, ...filters } });
8070
8136
  }
8137
+ async getByEAN(EAN) {
8138
+ const { data } = await this.find({
8139
+ filters: {
8140
+ EAN,
8141
+ },
8142
+ options: {
8143
+ enableCount: false,
8144
+ },
8145
+ });
8146
+ return data.at(0);
8147
+ }
8071
8148
  async update(params) {
8072
8149
  const { productId, id: checkId, ...data } = params;
8073
8150
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.3.0-beta.0",
3
+ "version": "5.3.0-beta.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -23,7 +23,8 @@ export declare class ProductBase<T extends ProductBase<T, I>, I = ProductIdentif
23
23
  createdAt?: Date;
24
24
  updatedAt?: Date;
25
25
  brand: string;
26
- tags?: string[];
26
+ tagsCollection?: string[];
27
+ tagsProfile?: string[];
27
28
  filters?: string[];
28
29
  type?: string;
29
30
  categories?: string[];
@@ -37,6 +38,7 @@ export declare class ProductBase<T extends ProductBase<T, I>, I = ProductIdentif
37
38
  label?: ProductLabel;
38
39
  group?: number;
39
40
  validity: boolean;
41
+ daysOfUse?: number;
40
42
  category: Category;
41
43
  kitProducts?: KitProduct[];
42
44
  reviews?: ProductReview[];
@@ -23,6 +23,9 @@ export interface ProductRepository extends CrudRepository<Product> {
23
23
  getBySlug(slug: string, options?: {
24
24
  cache?: RepositoryCacheOptions;
25
25
  }): Promise<Product>;
26
+ getByEAN(EAN: string, options?: {
27
+ cache?: RepositoryCacheOptions;
28
+ }): Promise<Product>;
26
29
  fetchReviews(status: ReviewStatusParams, options?: {
27
30
  cache?: RepositoryCacheOptions;
28
31
  }): Promise<ReviewWithProductData[]>;
@@ -1,4 +1,5 @@
1
1
  import { CrudRepository } from '../../generic/repository/crud.repository';
2
2
  import { Variant } from '../models/variant';
3
3
  export interface VariantRepository extends CrudRepository<Variant> {
4
+ getByEAN(EAN: string): Promise<Variant>;
4
5
  }
@@ -6,5 +6,5 @@ export declare enum OrderStatus {
6
6
  ENVIADO = "Enviado",
7
7
  ENTREGUE = "Entregue",
8
8
  CANCELADO = "Cancelado",
9
- CREDIT_CARD = "credit_card"
9
+ PENDENTE_REENVIO = "Pendente reenvio"
10
10
  }
@@ -11,4 +11,7 @@ export declare class Order extends Checkout {
11
11
  deliveredAt?: string;
12
12
  trackingEvents?: OrderTrackingEvent[];
13
13
  payment: PaymentTransaction;
14
+ reshipmentOrderId?: string;
15
+ isChange?: boolean;
16
+ isReshipment?: boolean;
14
17
  }
@@ -1,4 +1,4 @@
1
- import { FindRepositoryParams, PaginatedReviewFilters, Product, ProductRepository, ProductVariantReport, RepositoryFindResult, ReviewStatusParams, ReviewWithProductData } from '../../../../../domain';
1
+ import { FindRepositoryParams, PaginatedReviewFilters, Product, ProductRepository, ProductVariantReport, RepositoryCacheOptions, RepositoryFindResult, ReviewStatusParams, ReviewWithProductData } from '../../../../../domain';
2
2
  import { FirestoreConstructorParams } from '../../mixins';
3
3
  declare const ProductFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Product> & import("../../../../../domain").CrudRepository<Product, import("../../../../../domain").CrudParams<Product>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Product>, ...any[]]>;
4
4
  export declare class ProductFirestoreRepository extends ProductFirestoreRepository_base implements ProductRepository {
@@ -11,5 +11,8 @@ export declare class ProductFirestoreRepository extends ProductFirestoreReposito
11
11
  findCatalog(params: FindRepositoryParams<Product>): Promise<RepositoryFindResult<Product>>;
12
12
  fetchPaginatedReviews(): Promise<ReviewWithProductData[]>;
13
13
  productVariantFullReport(): Promise<ProductVariantReport[]>;
14
+ getByEAN(EAN: string, options?: {
15
+ cache?: RepositoryCacheOptions;
16
+ }): Promise<Product>;
14
17
  }
15
18
  export {};
@@ -8,5 +8,6 @@ declare const ProductVariantFirestoreRepository_base: import("../../../../../uti
8
8
  export declare class ProductVariantFirestoreRepository extends ProductVariantFirestoreRepository_base implements VariantRepository {
9
9
  readonly parentRepository: ProductFirestoreRepository;
10
10
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Variant>, 'firestore' | 'interceptors'>, parentRepository: ProductFirestoreRepository);
11
+ getByEAN(EAN: string): Promise<Variant>;
11
12
  }
12
13
  export {};
@@ -15,6 +15,9 @@ export declare class ProductHasuraGraphQLRepository extends ProductHasuraGraphQL
15
15
  getBySlug(slug: string, options?: {
16
16
  cache?: RepositoryCacheOptions;
17
17
  }): Promise<ProductHasuraGraphQL>;
18
+ getByEAN(EAN: string, options?: {
19
+ cache?: RepositoryCacheOptions;
20
+ }): Promise<ProductHasuraGraphQL>;
18
21
  update(params: UpdateRepositoryParams<ProductHasuraGraphQL>): Promise<ProductHasuraGraphQL>;
19
22
  fetchProductReviews(filters: PaginatedReviewFilters, options?: {
20
23
  cache?: RepositoryCacheOptions;
@@ -6,6 +6,7 @@ export declare class VariantHasuraGraphQLRepository extends VariantHasuraGraphQL
6
6
  constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<VariantHasuraGraphQL>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>);
7
7
  get(identifiers: GetRepositoryParams<VariantHasuraGraphQL>): Promise<VariantHasuraGraphQL>;
8
8
  find(params?: FindRepositoryParams<VariantHasuraGraphQL>): Promise<RepositoryFindResult<VariantHasuraGraphQL>>;
9
+ getByEAN(EAN: string): Promise<VariantHasuraGraphQL>;
9
10
  update(params: UpdateRepositoryParams<VariantHasuraGraphQL>): Promise<VariantHasuraGraphQL>;
10
11
  private getId;
11
12
  }