@infrab4a/connect 4.9.7-beta.22 → 4.9.7-beta.24

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.
Files changed (29) hide show
  1. package/index.cjs.js +187 -11
  2. package/index.esm.js +186 -12
  3. package/package.json +2 -2
  4. package/src/domain/catalog/models/product-base.d.ts +2 -1
  5. package/src/domain/catalog/models/types/index.d.ts +1 -0
  6. package/src/domain/catalog/models/types/product-label.type.d.ts +1 -0
  7. package/src/domain/catalog/repositories/category.repository.d.ts +1 -1
  8. package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -1
  9. package/src/domain/general/index.d.ts +1 -0
  10. package/src/domain/general/search/index.d.ts +1 -0
  11. package/src/domain/general/search/product-search-index.d.ts +3 -0
  12. package/src/domain/shopping/models/coupons/coupon.d.ts +2 -2
  13. package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +16 -0
  14. package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +2 -1
  15. package/src/domain/shopping/models/coupons/enums/index.d.ts +2 -1
  16. package/src/domain/shopping/models/order.d.ts +4 -0
  17. package/src/domain/shopping/types/index.d.ts +1 -0
  18. package/src/domain/shopping/types/order-tracking-events.type.d.ts +14 -0
  19. package/src/infra/elasticsearch/indexes/products-index.d.ts +37 -1
  20. package/src/infra/index.d.ts +1 -0
  21. package/src/infra/vertex-ai/adapters/index.d.ts +2 -0
  22. package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +9 -0
  23. package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +14 -0
  24. package/src/infra/vertex-ai/index.d.ts +3 -0
  25. package/src/infra/vertex-ai/indexes/index.d.ts +1 -0
  26. package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +13 -0
  27. package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +4 -0
  28. package/src/infra/vertex-ai/types/index.d.ts +2 -0
  29. package/src/infra/vertex-ai/types/product-search.d.ts +21 -0
package/index.cjs.js CHANGED
@@ -1850,15 +1850,23 @@ exports.CheckoutTypes = void 0;
1850
1850
  CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1851
1851
  })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
1852
1852
 
1853
- exports.CouponTypes = void 0;
1854
- (function (CouponTypes) {
1855
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1856
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1857
- // FINANCIAL = 1,
1858
- // PRODUCT,
1859
- // GIFTCARD,
1860
- // VOUCHER,
1861
- })(exports.CouponTypes || (exports.CouponTypes = {}));
1853
+ exports.CouponCategory = void 0;
1854
+ (function (CouponCategory) {
1855
+ CouponCategory["Reembolso"] = "Reembolso";
1856
+ CouponCategory["Desculpas"] = "Desculpas";
1857
+ CouponCategory["BFlu"] = "BFlu";
1858
+ CouponCategory["ROYAL"] = "Royal";
1859
+ CouponCategory["Glamqueens"] = "Glamqueens";
1860
+ CouponCategory["Glamgirls"] = "Glamgirls";
1861
+ CouponCategory["Glamdiva"] = "Glamdiva";
1862
+ CouponCategory["Impulsionamento"] = "Impulsionamento";
1863
+ CouponCategory["PaidMedia"] = "Paid Media";
1864
+ CouponCategory["Organic"] = "Organic";
1865
+ CouponCategory["Direct"] = "Direct";
1866
+ CouponCategory["CRM"] = "CRM";
1867
+ CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
1868
+ CouponCategory["Outros"] = "Outros";
1869
+ })(exports.CouponCategory || (exports.CouponCategory = {}));
1862
1870
 
1863
1871
  exports.CouponSubtypes = void 0;
1864
1872
  (function (CouponSubtypes) {
@@ -1866,6 +1874,13 @@ exports.CouponSubtypes = void 0;
1866
1874
  CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1867
1875
  })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
1868
1876
 
1877
+ exports.CouponTypes = void 0;
1878
+ (function (CouponTypes) {
1879
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1880
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1881
+ CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
1882
+ })(exports.CouponTypes || (exports.CouponTypes = {}));
1883
+
1869
1884
  exports.Exclusivities = void 0;
1870
1885
  (function (Exclusivities) {
1871
1886
  Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
@@ -2596,7 +2611,9 @@ class ProductsIndex {
2596
2611
  RoundProductPricesHelper.roundProductPrices(hit._source);
2597
2612
  return hit;
2598
2613
  });
2599
- return search;
2614
+ return search.hits.map((hit) => {
2615
+ return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2616
+ });
2600
2617
  }
2601
2618
  async save(product) {
2602
2619
  try {
@@ -4808,7 +4825,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4808
4825
  bindPersistData: (value) => ({
4809
4826
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4810
4827
  }),
4811
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4828
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter).filter((filter) => filter.enabled)) || [],
4812
4829
  },
4813
4830
  },
4814
4831
  { createdAt: { columnName: 'created_at' } },
@@ -5447,6 +5464,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5447
5464
  { subscriberPrice: { columnName: 'subscriber_price' } },
5448
5465
  'published',
5449
5466
  'outlet',
5467
+ 'label',
5450
5468
  'sku',
5451
5469
  {
5452
5470
  stock: {
@@ -6259,6 +6277,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6259
6277
  options: {
6260
6278
  enableCount: false,
6261
6279
  },
6280
+ orderBy: {
6281
+ id: 'asc',
6282
+ },
6283
+ limits: {
6284
+ limit: 1,
6285
+ },
6262
6286
  });
6263
6287
  if (!data.length)
6264
6288
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
@@ -6400,6 +6424,156 @@ tslib.__decorate([
6400
6424
  tslib.__metadata("design:returntype", Promise)
6401
6425
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6402
6426
 
6427
+ class VertexAxiosAdapter {
6428
+ constructor(config) {
6429
+ this.config = config;
6430
+ this.logger = DebugHelper.from(this);
6431
+ }
6432
+ async query(term, total, gender) {
6433
+ const logger = this.logger.with('query');
6434
+ const req = {
6435
+ url: `${this.config.url}/search`,
6436
+ method: 'POST',
6437
+ responseType: 'json',
6438
+ headers: {
6439
+ Accept: 'application/json',
6440
+ },
6441
+ data: { term, total, gender },
6442
+ };
6443
+ try {
6444
+ const { data } = await axios__default["default"](req);
6445
+ return data;
6446
+ }
6447
+ catch (error) {
6448
+ logger.error({ req, res: error });
6449
+ throw error;
6450
+ }
6451
+ }
6452
+ async get(id) {
6453
+ const logger = this.logger.with('update');
6454
+ const req = {
6455
+ url: `${this.config.url}/${id}`,
6456
+ method: 'GET',
6457
+ responseType: 'json',
6458
+ headers: {
6459
+ Accept: 'application/json',
6460
+ },
6461
+ };
6462
+ try {
6463
+ const { data } = await axios__default["default"](req);
6464
+ return data;
6465
+ }
6466
+ catch (error) {
6467
+ logger.error({ req, res: error });
6468
+ throw error;
6469
+ }
6470
+ }
6471
+ async save(data) {
6472
+ const logger = this.logger.with('save');
6473
+ const req = {
6474
+ url: `${this.config.url}/sync`,
6475
+ method: 'POST',
6476
+ responseType: 'json',
6477
+ headers: {
6478
+ Accept: 'application/json',
6479
+ },
6480
+ data,
6481
+ };
6482
+ try {
6483
+ const { data } = await axios__default["default"](req);
6484
+ return data;
6485
+ }
6486
+ catch (error) {
6487
+ logger.error({ req, res: error });
6488
+ throw error;
6489
+ }
6490
+ }
6491
+ async update(id, data) {
6492
+ const logger = this.logger.with('update');
6493
+ const req = {
6494
+ url: `${this.config.url}/${id}`,
6495
+ method: 'PUT',
6496
+ responseType: 'json',
6497
+ headers: {
6498
+ Accept: 'application/json',
6499
+ },
6500
+ data,
6501
+ };
6502
+ try {
6503
+ const { data } = await axios__default["default"](req);
6504
+ return data;
6505
+ }
6506
+ catch (error) {
6507
+ logger.error({ req, res: error });
6508
+ throw error;
6509
+ }
6510
+ }
6511
+ async delete(id) {
6512
+ const logger = this.logger.with('delete');
6513
+ const req = {
6514
+ url: `${this.config.url}/${id}`,
6515
+ method: 'DELETE',
6516
+ responseType: 'json',
6517
+ headers: {
6518
+ Accept: 'application/json',
6519
+ },
6520
+ };
6521
+ try {
6522
+ const { data } = await axios__default["default"](req);
6523
+ return data;
6524
+ }
6525
+ catch (error) {
6526
+ logger.error({ req, res: error });
6527
+ throw error;
6528
+ }
6529
+ }
6530
+ }
6531
+
6532
+ class ProductsVertexSearch {
6533
+ constructor(adapter) {
6534
+ this.adapter = adapter;
6535
+ }
6536
+ async getById(id) {
6537
+ const data = await this.adapter.get(id);
6538
+ return data;
6539
+ }
6540
+ async search(searchTerm, total, gender) {
6541
+ try {
6542
+ const result = await this.adapter.query(searchTerm, total, gender);
6543
+ return result;
6544
+ }
6545
+ catch (error) {
6546
+ console.error(error);
6547
+ }
6548
+ }
6549
+ async save(product) {
6550
+ try {
6551
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6552
+ const newProduct = Product.toInstance(data);
6553
+ await this.adapter.save(newProduct);
6554
+ }
6555
+ catch (error) {
6556
+ console.error(error);
6557
+ }
6558
+ }
6559
+ async update(product) {
6560
+ try {
6561
+ await this.adapter.update(product.id, product);
6562
+ }
6563
+ catch (error) {
6564
+ console.error(error);
6565
+ }
6566
+ }
6567
+ async delete(id) {
6568
+ try {
6569
+ await this.adapter.delete(id);
6570
+ }
6571
+ catch (error) {
6572
+ console.error(error);
6573
+ }
6574
+ }
6575
+ }
6576
+
6403
6577
  Object.defineProperty(exports, 'add', {
6404
6578
  enumerable: true,
6405
6579
  get: function () { return dateFns.add; }
@@ -6589,6 +6763,7 @@ exports.ProductStockNotification = ProductStockNotification;
6589
6763
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6590
6764
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6591
6765
  exports.ProductsIndex = ProductsIndex;
6766
+ exports.ProductsVertexSearch = ProductsVertexSearch;
6592
6767
  exports.RecoveryPassword = RecoveryPassword;
6593
6768
  exports.ReflectHelper = ReflectHelper;
6594
6769
  exports.Register = Register;
@@ -6627,6 +6802,7 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6627
6802
  exports.Variant = Variant;
6628
6803
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6629
6804
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6805
+ exports.VertexAxiosAdapter = VertexAxiosAdapter;
6630
6806
  exports.WeakPasswordError = WeakPasswordError;
6631
6807
  exports.Wishlist = Wishlist;
6632
6808
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
package/index.esm.js CHANGED
@@ -1844,15 +1844,23 @@ var CheckoutTypes;
1844
1844
  CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
1845
1845
  })(CheckoutTypes || (CheckoutTypes = {}));
1846
1846
 
1847
- var CouponTypes;
1848
- (function (CouponTypes) {
1849
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1850
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1851
- // FINANCIAL = 1,
1852
- // PRODUCT,
1853
- // GIFTCARD,
1854
- // VOUCHER,
1855
- })(CouponTypes || (CouponTypes = {}));
1847
+ var CouponCategory;
1848
+ (function (CouponCategory) {
1849
+ CouponCategory["Reembolso"] = "Reembolso";
1850
+ CouponCategory["Desculpas"] = "Desculpas";
1851
+ CouponCategory["BFlu"] = "BFlu";
1852
+ CouponCategory["ROYAL"] = "Royal";
1853
+ CouponCategory["Glamqueens"] = "Glamqueens";
1854
+ CouponCategory["Glamgirls"] = "Glamgirls";
1855
+ CouponCategory["Glamdiva"] = "Glamdiva";
1856
+ CouponCategory["Impulsionamento"] = "Impulsionamento";
1857
+ CouponCategory["PaidMedia"] = "Paid Media";
1858
+ CouponCategory["Organic"] = "Organic";
1859
+ CouponCategory["Direct"] = "Direct";
1860
+ CouponCategory["CRM"] = "CRM";
1861
+ CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
1862
+ CouponCategory["Outros"] = "Outros";
1863
+ })(CouponCategory || (CouponCategory = {}));
1856
1864
 
1857
1865
  var CouponSubtypes;
1858
1866
  (function (CouponSubtypes) {
@@ -1860,6 +1868,13 @@ var CouponSubtypes;
1860
1868
  CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1861
1869
  })(CouponSubtypes || (CouponSubtypes = {}));
1862
1870
 
1871
+ var CouponTypes;
1872
+ (function (CouponTypes) {
1873
+ CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1874
+ CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1875
+ CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
1876
+ })(CouponTypes || (CouponTypes = {}));
1877
+
1863
1878
  var Exclusivities;
1864
1879
  (function (Exclusivities) {
1865
1880
  Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
@@ -2590,7 +2605,9 @@ class ProductsIndex {
2590
2605
  RoundProductPricesHelper.roundProductPrices(hit._source);
2591
2606
  return hit;
2592
2607
  });
2593
- return search;
2608
+ return search.hits.map((hit) => {
2609
+ return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2610
+ });
2594
2611
  }
2595
2612
  async save(product) {
2596
2613
  try {
@@ -4802,7 +4819,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4802
4819
  bindPersistData: (value) => ({
4803
4820
  filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4804
4821
  }),
4805
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4822
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter).filter((filter) => filter.enabled)) || [],
4806
4823
  },
4807
4824
  },
4808
4825
  { createdAt: { columnName: 'created_at' } },
@@ -5441,6 +5458,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5441
5458
  { subscriberPrice: { columnName: 'subscriber_price' } },
5442
5459
  'published',
5443
5460
  'outlet',
5461
+ 'label',
5444
5462
  'sku',
5445
5463
  {
5446
5464
  stock: {
@@ -6253,6 +6271,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6253
6271
  options: {
6254
6272
  enableCount: false,
6255
6273
  },
6274
+ orderBy: {
6275
+ id: 'asc',
6276
+ },
6277
+ limits: {
6278
+ limit: 1,
6279
+ },
6256
6280
  });
6257
6281
  if (!data.length)
6258
6282
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
@@ -6394,4 +6418,154 @@ __decorate([
6394
6418
  __metadata("design:returntype", Promise)
6395
6419
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6396
6420
 
6397
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6421
+ class VertexAxiosAdapter {
6422
+ constructor(config) {
6423
+ this.config = config;
6424
+ this.logger = DebugHelper.from(this);
6425
+ }
6426
+ async query(term, total, gender) {
6427
+ const logger = this.logger.with('query');
6428
+ const req = {
6429
+ url: `${this.config.url}/search`,
6430
+ method: 'POST',
6431
+ responseType: 'json',
6432
+ headers: {
6433
+ Accept: 'application/json',
6434
+ },
6435
+ data: { term, total, gender },
6436
+ };
6437
+ try {
6438
+ const { data } = await axios(req);
6439
+ return data;
6440
+ }
6441
+ catch (error) {
6442
+ logger.error({ req, res: error });
6443
+ throw error;
6444
+ }
6445
+ }
6446
+ async get(id) {
6447
+ const logger = this.logger.with('update');
6448
+ const req = {
6449
+ url: `${this.config.url}/${id}`,
6450
+ method: 'GET',
6451
+ responseType: 'json',
6452
+ headers: {
6453
+ Accept: 'application/json',
6454
+ },
6455
+ };
6456
+ try {
6457
+ const { data } = await axios(req);
6458
+ return data;
6459
+ }
6460
+ catch (error) {
6461
+ logger.error({ req, res: error });
6462
+ throw error;
6463
+ }
6464
+ }
6465
+ async save(data) {
6466
+ const logger = this.logger.with('save');
6467
+ const req = {
6468
+ url: `${this.config.url}/sync`,
6469
+ method: 'POST',
6470
+ responseType: 'json',
6471
+ headers: {
6472
+ Accept: 'application/json',
6473
+ },
6474
+ data,
6475
+ };
6476
+ try {
6477
+ const { data } = await axios(req);
6478
+ return data;
6479
+ }
6480
+ catch (error) {
6481
+ logger.error({ req, res: error });
6482
+ throw error;
6483
+ }
6484
+ }
6485
+ async update(id, data) {
6486
+ const logger = this.logger.with('update');
6487
+ const req = {
6488
+ url: `${this.config.url}/${id}`,
6489
+ method: 'PUT',
6490
+ responseType: 'json',
6491
+ headers: {
6492
+ Accept: 'application/json',
6493
+ },
6494
+ data,
6495
+ };
6496
+ try {
6497
+ const { data } = await axios(req);
6498
+ return data;
6499
+ }
6500
+ catch (error) {
6501
+ logger.error({ req, res: error });
6502
+ throw error;
6503
+ }
6504
+ }
6505
+ async delete(id) {
6506
+ const logger = this.logger.with('delete');
6507
+ const req = {
6508
+ url: `${this.config.url}/${id}`,
6509
+ method: 'DELETE',
6510
+ responseType: 'json',
6511
+ headers: {
6512
+ Accept: 'application/json',
6513
+ },
6514
+ };
6515
+ try {
6516
+ const { data } = await axios(req);
6517
+ return data;
6518
+ }
6519
+ catch (error) {
6520
+ logger.error({ req, res: error });
6521
+ throw error;
6522
+ }
6523
+ }
6524
+ }
6525
+
6526
+ class ProductsVertexSearch {
6527
+ constructor(adapter) {
6528
+ this.adapter = adapter;
6529
+ }
6530
+ async getById(id) {
6531
+ const data = await this.adapter.get(id);
6532
+ return data;
6533
+ }
6534
+ async search(searchTerm, total, gender) {
6535
+ try {
6536
+ const result = await this.adapter.query(searchTerm, total, gender);
6537
+ return result;
6538
+ }
6539
+ catch (error) {
6540
+ console.error(error);
6541
+ }
6542
+ }
6543
+ async save(product) {
6544
+ try {
6545
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6546
+ const newProduct = Product.toInstance(data);
6547
+ await this.adapter.save(newProduct);
6548
+ }
6549
+ catch (error) {
6550
+ console.error(error);
6551
+ }
6552
+ }
6553
+ async update(product) {
6554
+ try {
6555
+ await this.adapter.update(product.id, product);
6556
+ }
6557
+ catch (error) {
6558
+ console.error(error);
6559
+ }
6560
+ }
6561
+ async delete(id) {
6562
+ try {
6563
+ await this.adapter.delete(id);
6564
+ }
6565
+ catch (error) {
6566
+ console.error(error);
6567
+ }
6568
+ }
6569
+ }
6570
+
6571
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategory, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, 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": "4.9.7-beta.22",
3
+ "version": "4.9.7-beta.24",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "class-transformer": "^0.5.1",
14
14
  "date-fns": "^2.28.0",
15
15
  "debug": "^4.3.4",
16
- "firebase": "10.12.0",
16
+ "firebase": "^10.12.0",
17
17
  "gql-query-builder": "3.7.0",
18
18
  "lodash": "^4.17.21",
19
19
  "reflect-metadata": "^0.1.13",
@@ -1,5 +1,5 @@
1
1
  import { BaseModel, GenericIdentifier, ModelBaseStructure } from '../../generic/model';
2
- import { ProductEvaluation, ProductGender, ProductMetadata, ProductReview, ShopDescription, ShopPrice, Stock } from './types';
2
+ import { ProductEvaluation, ProductGender, ProductLabel, ProductMetadata, ProductReview, ShopDescription, ShopPrice, Stock } from './types';
3
3
  import { Variant } from './variant';
4
4
  export declare class ProductBase<ChildProduct extends ModelBaseStructure<ChildProduct, Identifiers>, Identifiers = ChildProduct['identifiersFields']> extends BaseModel<ChildProduct, Identifiers> {
5
5
  id: string;
@@ -34,6 +34,7 @@ export declare class ProductBase<ChildProduct extends ModelBaseStructure<ChildPr
34
34
  shoppingCount?: number;
35
35
  metadata: ProductMetadata;
36
36
  outlet?: boolean;
37
+ label?: ProductLabel;
37
38
  private reviewsTotal?;
38
39
  get evaluation(): ProductEvaluation;
39
40
  set evaluation(evaluation: ProductEvaluation);
@@ -5,6 +5,7 @@ export * from './category-most-relevant.type';
5
5
  export * from './category-product';
6
6
  export * from './product-evaluation.type';
7
7
  export * from './product-gender.type';
8
+ export * from './product-label.type';
8
9
  export * from './product-metadata.type';
9
10
  export * from './product-review.type';
10
11
  export * from './report-stock-notification.type';
@@ -0,0 +1 @@
1
+ export type ProductLabel = 'outlet' | 'on-sale' | 'last-units' | 'glamstar';
@@ -2,7 +2,7 @@ import { CrudRepository } from '../../generic/repository/crud.repository';
2
2
  import { Product } from '../models';
3
3
  import { Category } from '../models/category';
4
4
  import { Shops } from '../models/enums/shops.enum';
5
- export interface CategoryRepository extends CrudRepository<Category> {
5
+ export interface CategoryRepository<T extends Category = Category> extends CrudRepository<T> {
6
6
  getCategoryBySlug(slug: string, shop: Shops): Promise<Category>;
7
7
  getCategoryByShop(shop: string): Promise<Category[]>;
8
8
  getCategoriesForHome(categoryIds: string[], limit?: number, gender?: string): Promise<{
@@ -2,7 +2,7 @@ import { CategoryRepository } from '.';
2
2
  import { FindRepositoryParams, RepositoryFindResult } from '../../generic';
3
3
  import { Shops } from '../models';
4
4
  import { Wishlist } from '../models/wishlist';
5
- export interface WishlistRepository extends CategoryRepository {
5
+ export interface WishlistRepository extends CategoryRepository<Wishlist> {
6
6
  getWishlistBySlug(slug: string): Promise<Wishlist>;
7
7
  getWishlistByPerson(personId: string): Promise<Wishlist[]>;
8
8
  findBfluOrGlamgirlWishlists(params: FindRepositoryParams<Wishlist>, shops: Shops[]): Promise<RepositoryFindResult<Wishlist>>;
@@ -1 +1,2 @@
1
+ export * from './search';
1
2
  export * from './storage';
@@ -0,0 +1 @@
1
+ export * from './product-search-index';
@@ -0,0 +1,3 @@
1
+ export interface ProductSearchIndex {
2
+ search<T>(searchTerm: string, total: number, gender?: String): Promise<T[]>;
3
+ }
@@ -1,11 +1,11 @@
1
1
  import { Shops } from '../../../catalog/models/enums/shops.enum';
2
2
  import { BaseModel, GenericIdentifier } from '../../../generic/model/base.model';
3
3
  import { CheckoutTypes } from '../enums/checkout-types.enum';
4
- import { CouponTypes, Exclusivities } from './enums';
4
+ import { CouponCategory, CouponTypes, Exclusivities } from './enums';
5
5
  import { ClubeDaMensPlan } from './enums/coupon-club-mens.enum';
6
6
  export declare class Coupon extends BaseModel<Coupon> {
7
7
  id: string;
8
- category?: string;
8
+ category?: CouponCategory;
9
9
  discount: {
10
10
  subscriber: {
11
11
  type: CouponTypes;
@@ -0,0 +1,16 @@
1
+ export declare enum CouponCategory {
2
+ Reembolso = "Reembolso",
3
+ Desculpas = "Desculpas",
4
+ BFlu = "BFlu",
5
+ ROYAL = "Royal",
6
+ Glamqueens = "Glamqueens",
7
+ Glamgirls = "Glamgirls",
8
+ Glamdiva = "Glamdiva",
9
+ Impulsionamento = "Impulsionamento",
10
+ PaidMedia = "Paid Media",
11
+ Organic = "Organic",
12
+ Direct = "Direct",
13
+ CRM = "CRM",
14
+ LOJAUNICO = "Loja \u00FAnico",
15
+ Outros = "Outros"
16
+ }
@@ -1,4 +1,5 @@
1
1
  export declare enum CouponTypes {
2
2
  ABSOLUTE = 1,
3
- PERCENTAGE = 2
3
+ PERCENTAGE = 2,
4
+ SHIPPING = 3
4
5
  }
@@ -1,3 +1,4 @@
1
- export * from './coupon-types.enum';
1
+ export * from './coupon-category.enum';
2
2
  export * from './coupon-subtypes.enum';
3
+ export * from './coupon-types.enum';
3
4
  export * from './exclusivities.enum';
@@ -1,3 +1,4 @@
1
+ import { OrderTrackingEvent } from '../types';
1
2
  import { Checkout } from './checkout';
2
3
  import { OrderStatus } from './enums/order-status.enum';
3
4
  import { Payment } from './payment';
@@ -6,5 +7,8 @@ export declare class Order extends Checkout {
6
7
  orderNumber?: string;
7
8
  trackingCode?: string;
8
9
  trackingUrl?: string;
10
+ sentAt?: string;
11
+ deliveredAt?: string;
12
+ trackingEvents?: OrderTrackingEvent[];
9
13
  payment: Payment;
10
14
  }
@@ -1 +1,2 @@
1
+ export * from './order-tracking-events.type';
1
2
  export * from './payment-card-info.type';
@@ -0,0 +1,14 @@
1
+ export type OrderTrackingEvent = {
2
+ cnpj?: string;
3
+ eventCategory?: string;
4
+ eventDate?: string;
5
+ eventDescription?: string;
6
+ eventTime?: string;
7
+ invoiceNumber?: string;
8
+ observation?: string;
9
+ proofUrl?: string;
10
+ receiverDocument?: string;
11
+ receiverName?: string;
12
+ receiverRelationship?: string;
13
+ shippingCompanyName?: string;
14
+ };
@@ -6,7 +6,43 @@ export declare class ProductsIndex {
6
6
  private index;
7
7
  constructor(adapter: ElasticSearchAdapter<Product>);
8
8
  getById(id: string): Promise<Product>;
9
- search(searchTerm: string, total: number, shop?: string): Promise<import("..").ElasticSearchResult<Product>>;
9
+ search(searchTerm: string, total: number, shop?: string): Promise<{
10
+ stock: number;
11
+ category: import("../../../domain/catalog/models/category-for-product").CategoryForProduct;
12
+ kitProducts?: import("../../../domain").KitProduct[];
13
+ id: string;
14
+ name: string;
15
+ slug: string;
16
+ description: import("../../../domain").ShopDescription;
17
+ sku: string;
18
+ price: import("../../../domain").ShopPrice;
19
+ hasVariants: boolean;
20
+ NCM: string;
21
+ EAN: string;
22
+ CEST: string;
23
+ weight: number;
24
+ costPrice: number;
25
+ images?: string[];
26
+ miniatures?: string[];
27
+ published: boolean;
28
+ createdAt?: Date;
29
+ updatedAt?: Date;
30
+ brand: string;
31
+ tags?: string[];
32
+ filters?: string[];
33
+ type?: string;
34
+ categories?: string[];
35
+ reviews?: import("../../../domain").ProductReview[];
36
+ variants?: import("../../../domain").Variant[];
37
+ video?: string;
38
+ isKit?: boolean;
39
+ rate?: number;
40
+ gender?: import("../../../domain").ProductGender;
41
+ shoppingCount?: number;
42
+ metadata: import("../../../domain").ProductMetadata;
43
+ outlet?: boolean;
44
+ label?: import("../../../domain").ProductLabel;
45
+ }[]>;
10
46
  save(product: ProductHasuraGraphQL): Promise<void>;
11
47
  update(product: ProductHasuraGraphQL): Promise<void>;
12
48
  delete(id: string): Promise<void>;
@@ -1,3 +1,4 @@
1
1
  export * from './elasticsearch';
2
2
  export * from './firebase';
3
3
  export * from './hasura-graphql';
4
+ export * from './vertex-ai';
@@ -0,0 +1,2 @@
1
+ export * from './vertex-ai-search.adapter';
2
+ export * from './vertex-axios.adapter';
@@ -0,0 +1,9 @@
1
+ import { Product } from '../../../domain';
2
+ import { ProductSearch } from '../types';
3
+ export interface VertexSearchAdapter<T> {
4
+ query(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
5
+ get(id: string): Promise<T>;
6
+ save(data: Product): Promise<any>;
7
+ update(id: string, data: Product): Promise<any>;
8
+ delete(id: string): Promise<void>;
9
+ }
@@ -0,0 +1,14 @@
1
+ import { Product } from '../../../domain';
2
+ import { ProductSearch } from '../types';
3
+ import { VertexSearchConfig } from '../types/axios-vertex-search-config';
4
+ import { VertexSearchAdapter } from './vertex-ai-search.adapter';
5
+ export declare class VertexAxiosAdapter implements VertexSearchAdapter<ProductSearch> {
6
+ private readonly config;
7
+ private logger;
8
+ constructor(config: VertexSearchConfig);
9
+ query(term: string, total: number, gender?: String): Promise<ProductSearch[]>;
10
+ get(id: string): Promise<ProductSearch>;
11
+ save(data: Product): Promise<any>;
12
+ update(id: string, data: Product): Promise<any>;
13
+ delete(id: string): Promise<void>;
14
+ }
@@ -0,0 +1,3 @@
1
+ export * from './adapters';
2
+ export * from './indexes';
3
+ export * from './types';
@@ -0,0 +1 @@
1
+ export * from './products-vertex-search';
@@ -0,0 +1,13 @@
1
+ import { ProductSearchIndex } from '../../../domain';
2
+ import { ProductHasuraGraphQL } from '../../hasura-graphql';
3
+ import { VertexSearchAdapter } from '../adapters';
4
+ import { ProductSearch } from '../types';
5
+ export declare class ProductsVertexSearch implements ProductSearchIndex {
6
+ private readonly adapter;
7
+ constructor(adapter: VertexSearchAdapter<ProductSearch>);
8
+ getById(id: string): Promise<ProductSearch>;
9
+ search<ProductSearch>(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
10
+ save(product: ProductHasuraGraphQL): Promise<void>;
11
+ update(product: ProductHasuraGraphQL): Promise<void>;
12
+ delete(id: string): Promise<void>;
13
+ }
@@ -0,0 +1,4 @@
1
+ export type VertexSearchConfig = {
2
+ url: string;
3
+ token?: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ export * from './axios-vertex-search-config';
2
+ export * from './product-search';
@@ -0,0 +1,21 @@
1
+ export type ProductSearch = {
2
+ id: string;
3
+ name: string;
4
+ ean?: string;
5
+ sku: string;
6
+ icon?: string;
7
+ miniatures?: string;
8
+ description?: string;
9
+ slug: string;
10
+ brand: string;
11
+ published: boolean;
12
+ gender: string;
13
+ shoppingCount: number;
14
+ stock: number;
15
+ rating: number;
16
+ fullPrice: number;
17
+ price: number;
18
+ subscriberPrice: number;
19
+ outlet: boolean;
20
+ createdAt: Date;
21
+ };