@infrab4a/connect 4.13.1-beta.0 → 4.14.0-beta.1

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,98 @@ tslib.__decorate([
6406
6400
  tslib.__metadata("design:returntype", Promise)
6407
6401
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6408
6402
 
6403
+ class VertexAxiosAdapter {
6404
+ constructor(config) {
6405
+ this.config = config;
6406
+ this.logger = DebugHelper.from(this);
6407
+ }
6408
+ async query(searchTerm, total, gender) {
6409
+ const logger = this.logger.with('query');
6410
+ const req = {
6411
+ url: `${this.config.url}/search`,
6412
+ method: 'POST',
6413
+ responseType: 'json',
6414
+ headers: {
6415
+ Accept: 'application/json',
6416
+ // 'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
6417
+ // Authorization: `ApiKey ${this.config.credential}`,
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
+ // const res = {
6425
+ // total: data.hits.total.value,
6426
+ // hits: data.hits.hits,
6427
+ // }
6428
+ // logger.log({ req, res })
6429
+ return data;
6430
+ }
6431
+ catch (error) {
6432
+ logger.error({ req, res: error });
6433
+ throw error;
6434
+ }
6435
+ }
6436
+ get(id) {
6437
+ throw new Error('Method not implemented.');
6438
+ }
6439
+ save(data) {
6440
+ throw new Error('Method not implemented.');
6441
+ }
6442
+ update(id, data) {
6443
+ throw new Error('Method not implemented.');
6444
+ }
6445
+ delete(id) {
6446
+ throw new Error('Method not implemented.');
6447
+ }
6448
+ }
6449
+
6450
+ class ProductsVertexSearch {
6451
+ constructor(adapter) {
6452
+ this.adapter = adapter;
6453
+ }
6454
+ async getById(id) {
6455
+ const data = await this.adapter.get(id);
6456
+ return data;
6457
+ }
6458
+ async search(searchTerm, total, gender) {
6459
+ try {
6460
+ const result = await this.adapter.query(searchTerm, total, gender);
6461
+ return result;
6462
+ }
6463
+ catch (error) {
6464
+ console.error(error);
6465
+ }
6466
+ }
6467
+ async save(product) {
6468
+ try {
6469
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6470
+ const newProduct = Product.toInstance(data);
6471
+ this.adapter.save(newProduct);
6472
+ }
6473
+ catch (error) {
6474
+ console.error(error);
6475
+ }
6476
+ }
6477
+ async update(product) {
6478
+ try {
6479
+ await this.adapter.update(product.id, product);
6480
+ }
6481
+ catch (error) {
6482
+ console.error(error);
6483
+ }
6484
+ }
6485
+ async delete(id) {
6486
+ try {
6487
+ await this.adapter.delete(id);
6488
+ }
6489
+ catch (error) {
6490
+ console.error(error);
6491
+ }
6492
+ }
6493
+ }
6494
+
6409
6495
  Object.defineProperty(exports, 'add', {
6410
6496
  enumerable: true,
6411
6497
  get: function () { return dateFns.add; }
@@ -6595,6 +6681,7 @@ exports.ProductStockNotification = ProductStockNotification;
6595
6681
  exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
6596
6682
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
6597
6683
  exports.ProductsIndex = ProductsIndex;
6684
+ exports.ProductsVertexSearch = ProductsVertexSearch;
6598
6685
  exports.RecoveryPassword = RecoveryPassword;
6599
6686
  exports.ReflectHelper = ReflectHelper;
6600
6687
  exports.Register = Register;
@@ -6633,6 +6720,7 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
6633
6720
  exports.Variant = Variant;
6634
6721
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
6635
6722
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
6723
+ exports.VertexAxiosAdapter = VertexAxiosAdapter;
6636
6724
  exports.WeakPasswordError = WeakPasswordError;
6637
6725
  exports.Wishlist = Wishlist;
6638
6726
  exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
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,96 @@ __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
+ class VertexAxiosAdapter {
6398
+ constructor(config) {
6399
+ this.config = config;
6400
+ this.logger = DebugHelper.from(this);
6401
+ }
6402
+ async query(searchTerm, total, gender) {
6403
+ const logger = this.logger.with('query');
6404
+ const req = {
6405
+ url: `${this.config.url}/search`,
6406
+ method: 'POST',
6407
+ responseType: 'json',
6408
+ headers: {
6409
+ Accept: 'application/json',
6410
+ // 'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
6411
+ // Authorization: `ApiKey ${this.config.credential}`,
6412
+ },
6413
+ data: { searchTerm, total, gender },
6414
+ };
6415
+ try {
6416
+ const { data } = await axios(req);
6417
+ console.log('response vertex axios', data);
6418
+ // const res = {
6419
+ // total: data.hits.total.value,
6420
+ // hits: data.hits.hits,
6421
+ // }
6422
+ // logger.log({ req, res })
6423
+ return data;
6424
+ }
6425
+ catch (error) {
6426
+ logger.error({ req, res: error });
6427
+ throw error;
6428
+ }
6429
+ }
6430
+ get(id) {
6431
+ throw new Error('Method not implemented.');
6432
+ }
6433
+ save(data) {
6434
+ throw new Error('Method not implemented.');
6435
+ }
6436
+ update(id, data) {
6437
+ throw new Error('Method not implemented.');
6438
+ }
6439
+ delete(id) {
6440
+ throw new Error('Method not implemented.');
6441
+ }
6442
+ }
6443
+
6444
+ class ProductsVertexSearch {
6445
+ constructor(adapter) {
6446
+ this.adapter = adapter;
6447
+ }
6448
+ async getById(id) {
6449
+ const data = await this.adapter.get(id);
6450
+ return data;
6451
+ }
6452
+ async search(searchTerm, total, gender) {
6453
+ try {
6454
+ const result = await this.adapter.query(searchTerm, total, gender);
6455
+ return result;
6456
+ }
6457
+ catch (error) {
6458
+ console.error(error);
6459
+ }
6460
+ }
6461
+ async save(product) {
6462
+ try {
6463
+ const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
6464
+ const newProduct = Product.toInstance(data);
6465
+ this.adapter.save(newProduct);
6466
+ }
6467
+ catch (error) {
6468
+ console.error(error);
6469
+ }
6470
+ }
6471
+ async update(product) {
6472
+ try {
6473
+ await this.adapter.update(product.id, product);
6474
+ }
6475
+ catch (error) {
6476
+ console.error(error);
6477
+ }
6478
+ }
6479
+ async delete(id) {
6480
+ try {
6481
+ await this.adapter.delete(id);
6482
+ }
6483
+ catch (error) {
6484
+ console.error(error);
6485
+ }
6486
+ }
6487
+ }
6488
+
6489
+ 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.13.1-beta.0",
3
+ "version": "4.14.0-beta.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -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,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): any;
7
+ update(id: string, data: Product): 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(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
10
+ get(id: string): Promise<ProductSearch>;
11
+ save(data: Product): void;
12
+ update(id: string, data: Product): void;
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,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,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
+ };
File without changes