@infrab4a/connect 4.14.0-beta.0 → 4.14.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
@@ -2596,7 +2596,9 @@ class ProductsIndex {
2596
2596
  RoundProductPricesHelper.roundProductPrices(hit._source);
2597
2597
  return hit;
2598
2598
  });
2599
- return search;
2599
+ return search.hits.map((hit) => {
2600
+ return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2601
+ });
2600
2602
  }
2601
2603
  async save(product) {
2602
2604
  try {
@@ -6400,130 +6402,109 @@ tslib.__decorate([
6400
6402
  tslib.__metadata("design:returntype", Promise)
6401
6403
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6402
6404
 
6403
- const { SearchServiceClient } = require('@google-cloud/discoveryengine').v1beta;
6404
- // import { SearchServiceClient } from '@google-cloud/discoveryengine'
6405
- class DiscoveryEngineSearch {
6406
- constructor(configuration) {
6407
- // console.log('DiscoveryEngineSearch', configuration)
6408
- this.config = configuration;
6409
- this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
6410
- this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
6411
- this.client = new SearchServiceClient({
6412
- apiEndpoint: configuration.apiEndpoint,
6413
- credentials: configuration.credentials,
6414
- });
6415
- this.servingConfig = this.client.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
6416
- }
6417
- save(data) {
6418
- throw new Error('Method not implemented.');
6405
+ class VertexAxiosAdapter {
6406
+ constructor(config) {
6407
+ this.config = config;
6408
+ this.logger = DebugHelper.from(this);
6419
6409
  }
6420
- async query(term, total, gender) {
6421
- const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
6422
- const response = await this.client.search({
6423
- pageSize: total,
6424
- query: term,
6425
- filter: defaultFilter,
6426
- languageCode: 'pt-BR',
6427
- servingConfig: this.servingConfig,
6428
- relevanceThreshold: 'MEDIUM',
6429
- }, {
6430
- autoPaginate: false,
6431
- });
6432
- return this.resultProductMapper(response);
6410
+ async query(searchTerm, total, gender) {
6411
+ const logger = this.logger.with('query');
6412
+ const req = {
6413
+ url: `${this.config.url}/search`,
6414
+ method: 'POST',
6415
+ responseType: 'json',
6416
+ headers: {
6417
+ Accept: 'application/json',
6418
+ },
6419
+ data: { searchTerm, total, gender },
6420
+ };
6421
+ try {
6422
+ const { data } = await axios__default["default"](req);
6423
+ console.log('response vertex axios', data);
6424
+ return data;
6425
+ }
6426
+ catch (error) {
6427
+ logger.error({ req, res: error });
6428
+ throw error;
6429
+ }
6433
6430
  }
6434
6431
  async get(id) {
6435
- const request = {
6436
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6437
- };
6438
- const response = await this.client.getDocument(request);
6439
- const document = JSON.parse(response[0].jsonData);
6440
- return document;
6441
- }
6442
- async create(product) {
6443
- const request = {
6444
- parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
6445
- allowMissing: true,
6446
- document: {
6447
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${product.id.toString()}`,
6448
- jsonData: JSON.stringify(product),
6449
- data: 'jsonData',
6432
+ const logger = this.logger.with('update');
6433
+ const req = {
6434
+ url: `${this.config.url}/${id}`,
6435
+ method: 'GET',
6436
+ responseType: 'json',
6437
+ headers: {
6438
+ Accept: 'application/json',
6450
6439
  },
6451
6440
  };
6452
- // Run request
6453
- const response = await this.client.updateDocument(request);
6454
- console.log(response);
6455
- }
6456
- async update(id, product) {
6457
- const request = {
6458
- parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
6459
- allowMissing: false,
6460
- document: {
6461
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6462
- jsonData: JSON.stringify(product),
6463
- data: 'jsonData',
6441
+ try {
6442
+ const { data } = await axios__default["default"](req);
6443
+ return data;
6444
+ }
6445
+ catch (error) {
6446
+ logger.error({ req, res: error });
6447
+ throw error;
6448
+ }
6449
+ }
6450
+ async save(data) {
6451
+ const logger = this.logger.with('save');
6452
+ const req = {
6453
+ url: `${this.config.url}/sync`,
6454
+ method: 'POST',
6455
+ responseType: 'json',
6456
+ headers: {
6457
+ Accept: 'application/json',
6464
6458
  },
6459
+ data,
6465
6460
  };
6466
- // Run request
6467
- await this.client.updateDocument(request);
6461
+ try {
6462
+ const { data } = await axios__default["default"](req);
6463
+ return data;
6464
+ }
6465
+ catch (error) {
6466
+ logger.error({ req, res: error });
6467
+ throw error;
6468
+ }
6468
6469
  }
6469
- async delete(id) {
6470
- const request = {
6471
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6470
+ async update(id, data) {
6471
+ const logger = this.logger.with('update');
6472
+ const req = {
6473
+ url: `${this.config.url}/${id}`,
6474
+ method: 'PUT',
6475
+ responseType: 'json',
6476
+ headers: {
6477
+ Accept: 'application/json',
6478
+ },
6479
+ data,
6472
6480
  };
6473
- await this.client.deleteDocument(request);
6481
+ try {
6482
+ const { data } = await axios__default["default"](req);
6483
+ return data;
6484
+ }
6485
+ catch (error) {
6486
+ logger.error({ req, res: error });
6487
+ throw error;
6488
+ }
6474
6489
  }
6475
- productMapper(product) {
6476
- var _a, _b;
6477
- const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
6478
- return {
6479
- id: product.id.toString(),
6480
- miniatures: image,
6481
- icon: image,
6482
- name: product.name,
6483
- brand: ((_a = product.brand) === null || _a === void 0 ? void 0 : _a.toString().trim()) ? (_b = product.brand) === null || _b === void 0 ? void 0 : _b.toString().trim() : null,
6484
- ean: product.EAN,
6485
- sku: product.sku,
6486
- slug: product.slug,
6487
- published: product.published,
6488
- gender: product.gender,
6489
- stock: product.stock.quantity,
6490
- rating: product.rate,
6491
- shoppingCount: product.shoppingCount,
6492
- description: product.description.description,
6493
- fullPrice: product.fullPrice,
6494
- price: product.price.price,
6495
- subscriberPrice: product.subscriberPrice,
6496
- outlet: product.outlet,
6497
- createdAt: product.createdAt,
6490
+ async delete(id) {
6491
+ const logger = this.logger.with('delete');
6492
+ const req = {
6493
+ url: `${this.config.url}/${id}`,
6494
+ method: 'DELETE',
6495
+ responseType: 'json',
6496
+ headers: {
6497
+ Accept: 'application/json',
6498
+ },
6498
6499
  };
6499
- }
6500
- resultProductMapper(result) {
6501
- return result[0].length
6502
- ? result[0].map((result) => {
6503
- var _a, _b;
6504
- return {
6505
- id: result.document.structData.fields.id.stringValue,
6506
- name: result.document.structData.fields.name.stringValue,
6507
- brand: result.document.structData.fields.brand.stringValue,
6508
- stock: (_a = result.document.structData.fields.stock) === null || _a === void 0 ? void 0 : _a.numberValue,
6509
- rating: (_b = result.document.structData.fields.rating) === null || _b === void 0 ? void 0 : _b.stringValue,
6510
- // gender: result.document.structData.fields.gender.stringValue,
6511
- // createdAt: result.document.structData.fields.createdAt.stringValue,
6512
- // description: result.document.structData.fields.gender.stringValue,
6513
- // ean: result.document.structData.fields.gender.stringValue,
6514
- // fullPrice: result.document.structData.fields.gender.stringValue,
6515
- // icon: result.document.structData.fields.gender.stringValue,
6516
- // outlet: result.document.structData.fields.gender.stringValue,
6517
- // slug: result.document.structData.fields.gender.stringValue,
6518
- // price: result.document.structData.fields.gender.stringValue,
6519
- // published: result.document.structData.fields.gender.stringValue,
6520
- // shoppingCount: result.document.structData.fields.gender.stringValue,
6521
- // sku: result.document.structData.fields.gender.stringValue,
6522
- // subscriberPrice: result.document.structData.fields.gender.stringValue,
6523
- // miniatures: result.document.structData.fields.gender.stringValue,
6524
- };
6525
- })
6526
- : [];
6500
+ try {
6501
+ const { data } = await axios__default["default"](req);
6502
+ return data;
6503
+ }
6504
+ catch (error) {
6505
+ logger.error({ req, res: error });
6506
+ throw error;
6507
+ }
6527
6508
  }
6528
6509
  }
6529
6510
 
@@ -6726,7 +6707,6 @@ exports.CouponFirestoreRepository = CouponFirestoreRepository;
6726
6707
  exports.Debug = Debug;
6727
6708
  exports.DebugDecoratorHelper = DebugDecoratorHelper;
6728
6709
  exports.DebugHelper = DebugHelper;
6729
- exports.DiscoveryEngineSearch = DiscoveryEngineSearch;
6730
6710
  exports.DuplicatedResultsError = DuplicatedResultsError;
6731
6711
  exports.Edition = Edition;
6732
6712
  exports.Filter = Filter;
@@ -6801,6 +6781,7 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6801
6781
  exports.Variant = Variant;
6802
6782
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6803
6783
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6784
+ exports.VertexAxiosAdapter = VertexAxiosAdapter;
6804
6785
  exports.WeakPasswordError = WeakPasswordError;
6805
6786
  exports.Wishlist = Wishlist;
6806
6787
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
package/index.esm.js CHANGED
@@ -2590,7 +2590,9 @@ class ProductsIndex {
2590
2590
  RoundProductPricesHelper.roundProductPrices(hit._source);
2591
2591
  return hit;
2592
2592
  });
2593
- return search;
2593
+ return search.hits.map((hit) => {
2594
+ return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
2595
+ });
2594
2596
  }
2595
2597
  async save(product) {
2596
2598
  try {
@@ -6394,130 +6396,109 @@ __decorate([
6394
6396
  __metadata("design:returntype", Promise)
6395
6397
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6396
6398
 
6397
- const { SearchServiceClient } = require('@google-cloud/discoveryengine').v1beta;
6398
- // import { SearchServiceClient } from '@google-cloud/discoveryengine'
6399
- class DiscoveryEngineSearch {
6400
- constructor(configuration) {
6401
- // console.log('DiscoveryEngineSearch', configuration)
6402
- this.config = configuration;
6403
- this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
6404
- this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
6405
- this.client = new SearchServiceClient({
6406
- apiEndpoint: configuration.apiEndpoint,
6407
- credentials: configuration.credentials,
6408
- });
6409
- this.servingConfig = this.client.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
6410
- }
6411
- save(data) {
6412
- throw new Error('Method not implemented.');
6399
+ class VertexAxiosAdapter {
6400
+ constructor(config) {
6401
+ this.config = config;
6402
+ this.logger = DebugHelper.from(this);
6413
6403
  }
6414
- async query(term, total, gender) {
6415
- const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
6416
- const response = await this.client.search({
6417
- pageSize: total,
6418
- query: term,
6419
- filter: defaultFilter,
6420
- languageCode: 'pt-BR',
6421
- servingConfig: this.servingConfig,
6422
- relevanceThreshold: 'MEDIUM',
6423
- }, {
6424
- autoPaginate: false,
6425
- });
6426
- return this.resultProductMapper(response);
6404
+ async query(searchTerm, total, gender) {
6405
+ const logger = this.logger.with('query');
6406
+ const req = {
6407
+ url: `${this.config.url}/search`,
6408
+ method: 'POST',
6409
+ responseType: 'json',
6410
+ headers: {
6411
+ Accept: 'application/json',
6412
+ },
6413
+ data: { searchTerm, total, gender },
6414
+ };
6415
+ try {
6416
+ const { data } = await axios(req);
6417
+ console.log('response vertex axios', data);
6418
+ return data;
6419
+ }
6420
+ catch (error) {
6421
+ logger.error({ req, res: error });
6422
+ throw error;
6423
+ }
6427
6424
  }
6428
6425
  async get(id) {
6429
- const request = {
6430
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6431
- };
6432
- const response = await this.client.getDocument(request);
6433
- const document = JSON.parse(response[0].jsonData);
6434
- return document;
6435
- }
6436
- async create(product) {
6437
- const request = {
6438
- parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
6439
- allowMissing: true,
6440
- document: {
6441
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${product.id.toString()}`,
6442
- jsonData: JSON.stringify(product),
6443
- data: 'jsonData',
6426
+ const logger = this.logger.with('update');
6427
+ const req = {
6428
+ url: `${this.config.url}/${id}`,
6429
+ method: 'GET',
6430
+ responseType: 'json',
6431
+ headers: {
6432
+ Accept: 'application/json',
6444
6433
  },
6445
6434
  };
6446
- // Run request
6447
- const response = await this.client.updateDocument(request);
6448
- console.log(response);
6449
- }
6450
- async update(id, product) {
6451
- const request = {
6452
- parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
6453
- allowMissing: false,
6454
- document: {
6455
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6456
- jsonData: JSON.stringify(product),
6457
- data: 'jsonData',
6435
+ try {
6436
+ const { data } = await axios(req);
6437
+ return data;
6438
+ }
6439
+ catch (error) {
6440
+ logger.error({ req, res: error });
6441
+ throw error;
6442
+ }
6443
+ }
6444
+ async save(data) {
6445
+ const logger = this.logger.with('save');
6446
+ const req = {
6447
+ url: `${this.config.url}/sync`,
6448
+ method: 'POST',
6449
+ responseType: 'json',
6450
+ headers: {
6451
+ Accept: 'application/json',
6458
6452
  },
6453
+ data,
6459
6454
  };
6460
- // Run request
6461
- await this.client.updateDocument(request);
6455
+ try {
6456
+ const { data } = await axios(req);
6457
+ return data;
6458
+ }
6459
+ catch (error) {
6460
+ logger.error({ req, res: error });
6461
+ throw error;
6462
+ }
6462
6463
  }
6463
- async delete(id) {
6464
- const request = {
6465
- name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${id}`,
6464
+ async update(id, data) {
6465
+ const logger = this.logger.with('update');
6466
+ const req = {
6467
+ url: `${this.config.url}/${id}`,
6468
+ method: 'PUT',
6469
+ responseType: 'json',
6470
+ headers: {
6471
+ Accept: 'application/json',
6472
+ },
6473
+ data,
6466
6474
  };
6467
- await this.client.deleteDocument(request);
6475
+ try {
6476
+ const { data } = await axios(req);
6477
+ return data;
6478
+ }
6479
+ catch (error) {
6480
+ logger.error({ req, res: error });
6481
+ throw error;
6482
+ }
6468
6483
  }
6469
- productMapper(product) {
6470
- var _a, _b;
6471
- const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
6472
- return {
6473
- id: product.id.toString(),
6474
- miniatures: image,
6475
- icon: image,
6476
- name: product.name,
6477
- brand: ((_a = product.brand) === null || _a === void 0 ? void 0 : _a.toString().trim()) ? (_b = product.brand) === null || _b === void 0 ? void 0 : _b.toString().trim() : null,
6478
- ean: product.EAN,
6479
- sku: product.sku,
6480
- slug: product.slug,
6481
- published: product.published,
6482
- gender: product.gender,
6483
- stock: product.stock.quantity,
6484
- rating: product.rate,
6485
- shoppingCount: product.shoppingCount,
6486
- description: product.description.description,
6487
- fullPrice: product.fullPrice,
6488
- price: product.price.price,
6489
- subscriberPrice: product.subscriberPrice,
6490
- outlet: product.outlet,
6491
- createdAt: product.createdAt,
6484
+ async delete(id) {
6485
+ const logger = this.logger.with('delete');
6486
+ const req = {
6487
+ url: `${this.config.url}/${id}`,
6488
+ method: 'DELETE',
6489
+ responseType: 'json',
6490
+ headers: {
6491
+ Accept: 'application/json',
6492
+ },
6492
6493
  };
6493
- }
6494
- resultProductMapper(result) {
6495
- return result[0].length
6496
- ? result[0].map((result) => {
6497
- var _a, _b;
6498
- return {
6499
- id: result.document.structData.fields.id.stringValue,
6500
- name: result.document.structData.fields.name.stringValue,
6501
- brand: result.document.structData.fields.brand.stringValue,
6502
- stock: (_a = result.document.structData.fields.stock) === null || _a === void 0 ? void 0 : _a.numberValue,
6503
- rating: (_b = result.document.structData.fields.rating) === null || _b === void 0 ? void 0 : _b.stringValue,
6504
- // gender: result.document.structData.fields.gender.stringValue,
6505
- // createdAt: result.document.structData.fields.createdAt.stringValue,
6506
- // description: result.document.structData.fields.gender.stringValue,
6507
- // ean: result.document.structData.fields.gender.stringValue,
6508
- // fullPrice: result.document.structData.fields.gender.stringValue,
6509
- // icon: result.document.structData.fields.gender.stringValue,
6510
- // outlet: result.document.structData.fields.gender.stringValue,
6511
- // slug: result.document.structData.fields.gender.stringValue,
6512
- // price: result.document.structData.fields.gender.stringValue,
6513
- // published: result.document.structData.fields.gender.stringValue,
6514
- // shoppingCount: result.document.structData.fields.gender.stringValue,
6515
- // sku: result.document.structData.fields.gender.stringValue,
6516
- // subscriberPrice: result.document.structData.fields.gender.stringValue,
6517
- // miniatures: result.document.structData.fields.gender.stringValue,
6518
- };
6519
- })
6520
- : [];
6494
+ try {
6495
+ const { data } = await axios(req);
6496
+ return data;
6497
+ }
6498
+ catch (error) {
6499
+ logger.error({ req, res: error });
6500
+ throw error;
6501
+ }
6521
6502
  }
6522
6503
  }
6523
6504
 
@@ -6566,4 +6547,4 @@ class ProductsVertexSearch {
6566
6547
  }
6567
6548
  }
6568
6549
 
6569
- 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, DiscoveryEngineSearch, 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, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6550
+ 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, 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.14.0-beta.0",
3
+ "version": "4.14.0-beta.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,7 +9,6 @@
9
9
  "url": "https://github.com/B4AGroup/b4a-firebase-libs"
10
10
  },
11
11
  "dependencies": {
12
- "@google-cloud/discoveryengine": "^1.14.0",
13
12
  "axios": "^0.27.2",
14
13
  "class-transformer": "^0.5.1",
15
14
  "date-fns": "^2.28.0",
@@ -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
+ }
@@ -6,7 +6,42 @@ 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
+ }[]>;
10
45
  save(product: ProductHasuraGraphQL): Promise<void>;
11
46
  update(product: ProductHasuraGraphQL): Promise<void>;
12
47
  delete(id: string): Promise<void>;
@@ -1,19 +0,0 @@
1
- import { Product } from '../../../domain';
2
- import { ProductSearch, VertexConfig } from '../types';
3
- import { VertexSearchAdapter } from './vertex-ai-search-adapter';
4
- export declare class DiscoveryEngineSearch implements VertexSearchAdapter<ProductSearch> {
5
- private config;
6
- private parentEngine;
7
- private parentDataStore;
8
- private servingConfig;
9
- private client;
10
- constructor(configuration: VertexConfig);
11
- save(data: Product): void;
12
- query(term: string, total: number, gender?: string): Promise<ProductSearch[]>;
13
- get(id: string): Promise<any>;
14
- create(product: Product): Promise<void>;
15
- update(id: string, product: Product): Promise<void>;
16
- delete(id: string): Promise<void>;
17
- private productMapper;
18
- private resultProductMapper;
19
- }
@@ -1,2 +1,2 @@
1
- export * from './discovery-engine-adapter';
2
- export * from './vertex-ai-search-adapter';
1
+ export * from './vertex-ai-search.adapter';
2
+ export * from './vertex-axios.adapter';
@@ -3,7 +3,7 @@ import { ProductSearch } from '../types';
3
3
  export interface VertexSearchAdapter<T> {
4
4
  query(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
5
5
  get(id: string): Promise<T>;
6
- save(data: Product): any;
7
- update(id: string, data: Product): any;
6
+ save(data: Product): Promise<any>;
7
+ update(id: string, data: Product): Promise<any>;
8
8
  delete(id: string): Promise<void>;
9
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(searchTerm: 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
+ }
@@ -1,11 +1,12 @@
1
+ import { ProductSearchIndex } from '../../../domain';
1
2
  import { ProductHasuraGraphQL } from '../../hasura-graphql';
2
3
  import { VertexSearchAdapter } from '../adapters';
3
4
  import { ProductSearch } from '../types';
4
- export declare class ProductsVertexSearch {
5
+ export declare class ProductsVertexSearch implements ProductSearchIndex {
5
6
  private readonly adapter;
6
7
  constructor(adapter: VertexSearchAdapter<ProductSearch>);
7
8
  getById(id: string): Promise<ProductSearch>;
8
- search(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
9
+ search<ProductSearch>(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
9
10
  save(product: ProductHasuraGraphQL): Promise<void>;
10
11
  update(product: ProductHasuraGraphQL): Promise<void>;
11
12
  delete(id: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export type VertexSearchConfig = {
2
+ url: string;
3
+ token?: string;
4
+ };
@@ -1,3 +1,2 @@
1
+ export * from './axios-vertex-search-config';
1
2
  export * from './product-search';
2
- export * from './vertex-config';
3
- export * from './vertex-search-result';
@@ -1,23 +0,0 @@
1
- export type VertexConfig = {
2
- apiEndpoint: string;
3
- credentials: {
4
- type: string;
5
- project_id: string;
6
- private_key_id: string;
7
- private_key: string;
8
- client_email: string;
9
- client_id: string;
10
- auth_uri: string;
11
- token_uri: string;
12
- auth_provider_x509_cert_url: string;
13
- client_x509_cert_url: string;
14
- apiKey: string;
15
- authDomain: string;
16
- };
17
- projectId: string;
18
- location: string;
19
- dataStoreId: string;
20
- collectionId: string;
21
- engine: string;
22
- servingConfigId: string;
23
- };
@@ -1,18 +0,0 @@
1
- import { protos } from '@google-cloud/discoveryengine';
2
- export type VertexSearchResult<T> = [
3
- VertexResult<T>[],
4
- protos.google.cloud.discoveryengine.v1.ISearchRequest | null,
5
- protos.google.cloud.discoveryengine.v1.ISearchResponse
6
- ];
7
- type VertexResult<T> = {
8
- id?: string | null;
9
- document?: {
10
- structData: {
11
- fields: {
12
- [P in keyof T]: any;
13
- };
14
- };
15
- };
16
- chunk?: protos.google.cloud.discoveryengine.v1.IChunk;
17
- };
18
- export {};