@infrab4a/connect 4.13.1-beta.0 → 4.14.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
@@ -6259,12 +6259,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6259
6259
  options: {
6260
6260
  enableCount: false,
6261
6261
  },
6262
- orderBy: {
6263
- id: 'asc',
6264
- },
6265
- limits: {
6266
- limit: 1,
6267
- },
6268
6262
  });
6269
6263
  if (!data.length)
6270
6264
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
@@ -6406,6 +6400,178 @@ tslib.__decorate([
6406
6400
  tslib.__metadata("design:returntype", Promise)
6407
6401
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6408
6402
 
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.');
6419
+ }
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);
6433
+ }
6434
+ 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',
6450
+ },
6451
+ };
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',
6464
+ },
6465
+ };
6466
+ // Run request
6467
+ await this.client.updateDocument(request);
6468
+ }
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}`,
6472
+ };
6473
+ await this.client.deleteDocument(request);
6474
+ }
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,
6498
+ };
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
+ : [];
6527
+ }
6528
+ }
6529
+
6530
+ class ProductsVertexSearch {
6531
+ constructor(adapter) {
6532
+ this.adapter = adapter;
6533
+ }
6534
+ async getById(id) {
6535
+ const data = await this.adapter.get(id);
6536
+ return data;
6537
+ }
6538
+ async search(searchTerm, total, gender) {
6539
+ try {
6540
+ const result = await this.adapter.query(searchTerm, total, gender);
6541
+ return result;
6542
+ }
6543
+ catch (error) {
6544
+ console.error(error);
6545
+ }
6546
+ }
6547
+ async save(product) {
6548
+ try {
6549
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6550
+ const newProduct = Product.toInstance(data);
6551
+ this.adapter.save(newProduct);
6552
+ }
6553
+ catch (error) {
6554
+ console.error(error);
6555
+ }
6556
+ }
6557
+ async update(product) {
6558
+ try {
6559
+ await this.adapter.update(product.id, product);
6560
+ }
6561
+ catch (error) {
6562
+ console.error(error);
6563
+ }
6564
+ }
6565
+ async delete(id) {
6566
+ try {
6567
+ await this.adapter.delete(id);
6568
+ }
6569
+ catch (error) {
6570
+ console.error(error);
6571
+ }
6572
+ }
6573
+ }
6574
+
6409
6575
  Object.defineProperty(exports, 'add', {
6410
6576
  enumerable: true,
6411
6577
  get: function () { return dateFns.add; }
@@ -6560,6 +6726,7 @@ exports.CouponFirestoreRepository = CouponFirestoreRepository;
6560
6726
  exports.Debug = Debug;
6561
6727
  exports.DebugDecoratorHelper = DebugDecoratorHelper;
6562
6728
  exports.DebugHelper = DebugHelper;
6729
+ exports.DiscoveryEngineSearch = DiscoveryEngineSearch;
6563
6730
  exports.DuplicatedResultsError = DuplicatedResultsError;
6564
6731
  exports.Edition = Edition;
6565
6732
  exports.Filter = Filter;
@@ -6595,6 +6762,7 @@ exports.ProductStockNotification = ProductStockNotification;
6595
6762
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6596
6763
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6597
6764
  exports.ProductsIndex = ProductsIndex;
6765
+ exports.ProductsVertexSearch = ProductsVertexSearch;
6598
6766
  exports.RecoveryPassword = RecoveryPassword;
6599
6767
  exports.ReflectHelper = ReflectHelper;
6600
6768
  exports.Register = Register;
package/index.esm.js CHANGED
@@ -6253,12 +6253,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6253
6253
  options: {
6254
6254
  enableCount: false,
6255
6255
  },
6256
- orderBy: {
6257
- id: 'asc',
6258
- },
6259
- limits: {
6260
- limit: 1,
6261
- },
6262
6256
  });
6263
6257
  if (!data.length)
6264
6258
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
@@ -6400,4 +6394,176 @@ __decorate([
6400
6394
  __metadata("design:returntype", Promise)
6401
6395
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6402
6396
 
6403
- 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 };
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.');
6413
+ }
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);
6427
+ }
6428
+ 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',
6444
+ },
6445
+ };
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',
6458
+ },
6459
+ };
6460
+ // Run request
6461
+ await this.client.updateDocument(request);
6462
+ }
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}`,
6466
+ };
6467
+ await this.client.deleteDocument(request);
6468
+ }
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,
6492
+ };
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
+ : [];
6521
+ }
6522
+ }
6523
+
6524
+ class ProductsVertexSearch {
6525
+ constructor(adapter) {
6526
+ this.adapter = adapter;
6527
+ }
6528
+ async getById(id) {
6529
+ const data = await this.adapter.get(id);
6530
+ return data;
6531
+ }
6532
+ async search(searchTerm, total, gender) {
6533
+ try {
6534
+ const result = await this.adapter.query(searchTerm, total, gender);
6535
+ return result;
6536
+ }
6537
+ catch (error) {
6538
+ console.error(error);
6539
+ }
6540
+ }
6541
+ async save(product) {
6542
+ try {
6543
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6544
+ const newProduct = Product.toInstance(data);
6545
+ this.adapter.save(newProduct);
6546
+ }
6547
+ catch (error) {
6548
+ console.error(error);
6549
+ }
6550
+ }
6551
+ async update(product) {
6552
+ try {
6553
+ await this.adapter.update(product.id, product);
6554
+ }
6555
+ catch (error) {
6556
+ console.error(error);
6557
+ }
6558
+ }
6559
+ async delete(id) {
6560
+ try {
6561
+ await this.adapter.delete(id);
6562
+ }
6563
+ catch (error) {
6564
+ console.error(error);
6565
+ }
6566
+ }
6567
+ }
6568
+
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.13.1-beta.0",
3
+ "version": "4.14.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,6 +9,7 @@
9
9
  "url": "https://github.com/B4AGroup/b4a-firebase-libs"
10
10
  },
11
11
  "dependencies": {
12
+ "@google-cloud/discoveryengine": "^1.14.0",
12
13
  "axios": "^0.27.2",
13
14
  "class-transformer": "^0.5.1",
14
15
  "date-fns": "^2.28.0",
@@ -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<T extends Category = Category> extends CrudRepository<T> {
5
+ export interface CategoryRepository extends CrudRepository<Category> {
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<Wishlist> {
5
+ export interface WishlistRepository extends CategoryRepository {
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,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,19 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './discovery-engine-adapter';
2
+ export * from './vertex-ai-search-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): any;
7
+ update(id: string, data: Product): any;
8
+ delete(id: string): Promise<void>;
9
+ }
@@ -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,12 @@
1
+ import { ProductHasuraGraphQL } from '../../hasura-graphql';
2
+ import { VertexSearchAdapter } from '../adapters';
3
+ import { ProductSearch } from '../types';
4
+ export declare class ProductsVertexSearch {
5
+ private readonly adapter;
6
+ constructor(adapter: VertexSearchAdapter<ProductSearch>);
7
+ getById(id: string): Promise<ProductSearch>;
8
+ search(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
9
+ save(product: ProductHasuraGraphQL): Promise<void>;
10
+ update(product: ProductHasuraGraphQL): Promise<void>;
11
+ delete(id: string): Promise<void>;
12
+ }
@@ -0,0 +1,3 @@
1
+ export * from './product-search';
2
+ export * from './vertex-config';
3
+ export * from './vertex-search-result';
@@ -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
+ };
@@ -0,0 +1,23 @@
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
+ };
@@ -0,0 +1,18 @@
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 {};