@infrab4a/connect-nestjs 1.4.0-beta.2 → 1.4.0-beta.4

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
@@ -5,6 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var elasticsearch = require('@elastic/elasticsearch');
6
6
  var connect = require('@infrab4a/connect');
7
7
  var common = require('@nestjs/common');
8
+ var discoveryengine = require('@google-cloud/discoveryengine');
9
+ var v1beta = require('@google-cloud/discoveryengine/build/src/v1beta');
8
10
  var nestjsFirebase = require('nestjs-firebase');
9
11
 
10
12
  const ES_CONFIG = 'ES_CONFIG';
@@ -13,6 +15,8 @@ const HASURA_OPTIONS = 'HASURA_OPTIONS';
13
15
 
14
16
  const FIREBASE_STORAGE = 'FIREBASE_STORAGE';
15
17
 
18
+ const VERTEX_CONFIG = 'VERTEX_CONFIG';
19
+
16
20
  /******************************************************************************
17
21
  Copyright (c) Microsoft Corporation.
18
22
 
@@ -286,6 +290,138 @@ class ConnectFirestoreService {
286
290
  }
287
291
  }
288
292
 
293
+ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
294
+ constructor(configuration) {
295
+ this.config = configuration;
296
+ this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
297
+ this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
298
+ this.searchClient = new v1beta.SearchServiceClient({
299
+ apiEndpoint: configuration.apiEndpoint,
300
+ credentials: configuration.credentials,
301
+ });
302
+ this.documentClient = new discoveryengine.DocumentServiceClient({
303
+ apiEndpoint: configuration.apiEndpoint,
304
+ credentials: configuration.credentials,
305
+ });
306
+ this.servingConfig = this.searchClient.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
307
+ }
308
+ async save(product) {
309
+ const productSearch = this.productMapper(product);
310
+ const request = {
311
+ parent: this.parentEngine,
312
+ allowMissing: true,
313
+ document: {
314
+ name: this.parentDataStore + `/${product.id}`,
315
+ jsonData: JSON.stringify(productSearch),
316
+ data: 'jsonData',
317
+ },
318
+ };
319
+ const response = await this.documentClient.updateDocument(request);
320
+ return response;
321
+ }
322
+ async update(id, data) {
323
+ const productSearch = this.productMapper(data);
324
+ const request = {
325
+ parent: this.parentEngine,
326
+ allowMissing: true,
327
+ document: {
328
+ name: this.parentDataStore + `/${id}`,
329
+ jsonData: JSON.stringify(productSearch),
330
+ data: 'jsonData',
331
+ },
332
+ };
333
+ const response = await this.documentClient.updateDocument(request);
334
+ return response;
335
+ }
336
+ async query(term, total, gender) {
337
+ console.log('adapter query', term, total, gender);
338
+ const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
339
+ const response = (await this.searchClient.search({
340
+ pageSize: total,
341
+ query: term,
342
+ filter: defaultFilter,
343
+ languageCode: 'pt-BR',
344
+ servingConfig: this.servingConfig,
345
+ relevanceThreshold: 'MEDIUM',
346
+ }, {
347
+ autoPaginate: false,
348
+ }));
349
+ return this.resultProductMapper(response);
350
+ }
351
+ async get(id) {
352
+ const request = {
353
+ name: this.parentDataStore + `/${id}`,
354
+ };
355
+ const response = await this.documentClient.getDocument(request);
356
+ const document = JSON.parse(response[0].jsonData);
357
+ return document;
358
+ }
359
+ async delete(id) {
360
+ const request = {
361
+ name: this.parentDataStore + `/${id}`,
362
+ };
363
+ await this.documentClient.deleteDocument(request);
364
+ }
365
+ productMapper(product) {
366
+ var _a, _b;
367
+ const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
368
+ return {
369
+ id: product.id.toString(),
370
+ miniatures: image,
371
+ icon: image,
372
+ name: product.name,
373
+ 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,
374
+ ean: product.EAN,
375
+ sku: product.sku,
376
+ slug: product.slug,
377
+ published: product.published,
378
+ gender: product.gender,
379
+ stock: product.stock.quantity,
380
+ rating: product.rate,
381
+ shoppingCount: product.shoppingCount,
382
+ description: product.description.description,
383
+ fullPrice: product.fullPrice,
384
+ price: product.price.price,
385
+ subscriberPrice: product.subscriberPrice,
386
+ outlet: product.outlet,
387
+ createdAt: product.createdAt,
388
+ };
389
+ }
390
+ resultProductMapper(result) {
391
+ return result[0].length
392
+ ? result[0].map((result) => {
393
+ var _a, _b, _c, _d, _e, _f, _g;
394
+ return {
395
+ id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
396
+ name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
397
+ brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
398
+ stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
399
+ rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
400
+ // gender: result.document.structData.fields.gender.stringValue,
401
+ // createdAt: result.document.structData.fields.createdAt.stringValue,
402
+ // description: result.document.structData.fields.gender.stringValue,
403
+ // ean: result.document.structData.fields.gender.stringValue,
404
+ // fullPrice: result.document.structData.fields.gender.stringValue,
405
+ // icon: result.document.structData.fields.gender.stringValue,
406
+ // outlet: result.document.structData.fields.gender.stringValue,
407
+ // slug: result.document.structData.fields.gender.stringValue,
408
+ // price: result.document.structData.fields.gender.stringValue,
409
+ // published: result.document.structData.fields.gender.stringValue,
410
+ // shoppingCount: result.document.structData.fields.gender.stringValue,
411
+ // sku: result.document.structData.fields.gender.stringValue,
412
+ // subscriberPrice: result.document.structData.fields.gender.stringValue,
413
+ // miniatures: result.document.structData.fields.gender.stringValue,
414
+ };
415
+ })
416
+ : [];
417
+ }
418
+ };
419
+ exports.DiscoveryEngineVertexAdapter = __decorate([
420
+ common.Injectable(),
421
+ __param(0, common.Inject(VERTEX_CONFIG)),
422
+ __metadata("design:paramtypes", [Object])
423
+ ], exports.DiscoveryEngineVertexAdapter);
424
+
289
425
  var NestElasticSeachModule_1;
290
426
  exports.NestElasticSeachModule = NestElasticSeachModule_1 = class NestElasticSeachModule {
291
427
  static initializeApp(options) {
@@ -741,6 +877,30 @@ exports.NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = __decorate([
741
877
  })
742
878
  ], exports.NestHasuraGraphQLModule);
743
879
 
880
+ var NestVertexSeachModule_1;
881
+ let NestVertexSeachModule = NestVertexSeachModule_1 = class NestVertexSeachModule {
882
+ static initializeApp(options) {
883
+ return {
884
+ module: NestVertexSeachModule_1,
885
+ providers: [{ provide: VERTEX_CONFIG, useValue: options }],
886
+ exports: [VERTEX_CONFIG],
887
+ };
888
+ }
889
+ };
890
+ NestVertexSeachModule = NestVertexSeachModule_1 = __decorate([
891
+ common.Module({
892
+ providers: [
893
+ exports.DiscoveryEngineVertexAdapter,
894
+ {
895
+ provide: 'ProductsVertexIndex',
896
+ useFactory: (adapter) => new connect.ProductsVertexSearch(adapter),
897
+ inject: [exports.DiscoveryEngineVertexAdapter],
898
+ },
899
+ ],
900
+ exports: [connect.ProductsVertexSearch],
901
+ })
902
+ ], NestVertexSeachModule);
903
+
744
904
  var NestConnectModule_1;
745
905
  exports.NestConnectModule = NestConnectModule_1 = class NestConnectModule {
746
906
  static initializeApp(options) {
@@ -750,11 +910,13 @@ exports.NestConnectModule = NestConnectModule_1 = class NestConnectModule {
750
910
  ...(options.firebase ? [exports.NestFirestoreModule.initializeApp({ firebase: options.firebase })] : []),
751
911
  ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule.initializeApp(options.hasura)]),
752
912
  ...(connect.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [exports.NestElasticSeachModule.initializeApp(options.elasticSearch)]),
913
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule.initializeApp(options.vertex)]),
753
914
  ],
754
915
  exports: [
755
916
  ...(options.firebase ? [exports.NestFirestoreModule] : []),
756
917
  ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule]),
757
918
  ...(connect.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [exports.NestElasticSeachModule]),
919
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule]),
758
920
  ],
759
921
  };
760
922
  }
@@ -769,3 +931,4 @@ exports.ConnectFirestoreService = ConnectFirestoreService;
769
931
  exports.ES_CONFIG = ES_CONFIG;
770
932
  exports.FIREBASE_STORAGE = FIREBASE_STORAGE;
771
933
  exports.HASURA_OPTIONS = HASURA_OPTIONS;
934
+ exports.VERTEX_CONFIG = VERTEX_CONFIG;
package/index.esm.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Client } from '@elastic/elasticsearch';
2
- import { DebugHelper, isEmpty, NotFoundError, ProductsIndex, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, isNil } from '@infrab4a/connect';
2
+ import { DebugHelper, isEmpty, NotFoundError, ProductsIndex, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, isNil } from '@infrab4a/connect';
3
3
  import { Injectable, Inject, Module } from '@nestjs/common';
4
+ import { DocumentServiceClient } from '@google-cloud/discoveryengine';
5
+ import { SearchServiceClient } from '@google-cloud/discoveryengine/build/src/v1beta';
4
6
  import { FirebaseConstants, FirebaseModule } from 'nestjs-firebase';
5
7
 
6
8
  const ES_CONFIG = 'ES_CONFIG';
@@ -9,6 +11,8 @@ const HASURA_OPTIONS = 'HASURA_OPTIONS';
9
11
 
10
12
  const FIREBASE_STORAGE = 'FIREBASE_STORAGE';
11
13
 
14
+ const VERTEX_CONFIG = 'VERTEX_CONFIG';
15
+
12
16
  /******************************************************************************
13
17
  Copyright (c) Microsoft Corporation.
14
18
 
@@ -282,6 +286,138 @@ class ConnectFirestoreService {
282
286
  }
283
287
  }
284
288
 
289
+ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
290
+ constructor(configuration) {
291
+ this.config = configuration;
292
+ this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
293
+ this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
294
+ this.searchClient = new SearchServiceClient({
295
+ apiEndpoint: configuration.apiEndpoint,
296
+ credentials: configuration.credentials,
297
+ });
298
+ this.documentClient = new DocumentServiceClient({
299
+ apiEndpoint: configuration.apiEndpoint,
300
+ credentials: configuration.credentials,
301
+ });
302
+ this.servingConfig = this.searchClient.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
303
+ }
304
+ async save(product) {
305
+ const productSearch = this.productMapper(product);
306
+ const request = {
307
+ parent: this.parentEngine,
308
+ allowMissing: true,
309
+ document: {
310
+ name: this.parentDataStore + `/${product.id}`,
311
+ jsonData: JSON.stringify(productSearch),
312
+ data: 'jsonData',
313
+ },
314
+ };
315
+ const response = await this.documentClient.updateDocument(request);
316
+ return response;
317
+ }
318
+ async update(id, data) {
319
+ const productSearch = this.productMapper(data);
320
+ const request = {
321
+ parent: this.parentEngine,
322
+ allowMissing: true,
323
+ document: {
324
+ name: this.parentDataStore + `/${id}`,
325
+ jsonData: JSON.stringify(productSearch),
326
+ data: 'jsonData',
327
+ },
328
+ };
329
+ const response = await this.documentClient.updateDocument(request);
330
+ return response;
331
+ }
332
+ async query(term, total, gender) {
333
+ console.log('adapter query', term, total, gender);
334
+ const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
335
+ const response = (await this.searchClient.search({
336
+ pageSize: total,
337
+ query: term,
338
+ filter: defaultFilter,
339
+ languageCode: 'pt-BR',
340
+ servingConfig: this.servingConfig,
341
+ relevanceThreshold: 'MEDIUM',
342
+ }, {
343
+ autoPaginate: false,
344
+ }));
345
+ return this.resultProductMapper(response);
346
+ }
347
+ async get(id) {
348
+ const request = {
349
+ name: this.parentDataStore + `/${id}`,
350
+ };
351
+ const response = await this.documentClient.getDocument(request);
352
+ const document = JSON.parse(response[0].jsonData);
353
+ return document;
354
+ }
355
+ async delete(id) {
356
+ const request = {
357
+ name: this.parentDataStore + `/${id}`,
358
+ };
359
+ await this.documentClient.deleteDocument(request);
360
+ }
361
+ productMapper(product) {
362
+ var _a, _b;
363
+ const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
364
+ return {
365
+ id: product.id.toString(),
366
+ miniatures: image,
367
+ icon: image,
368
+ name: product.name,
369
+ 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,
370
+ ean: product.EAN,
371
+ sku: product.sku,
372
+ slug: product.slug,
373
+ published: product.published,
374
+ gender: product.gender,
375
+ stock: product.stock.quantity,
376
+ rating: product.rate,
377
+ shoppingCount: product.shoppingCount,
378
+ description: product.description.description,
379
+ fullPrice: product.fullPrice,
380
+ price: product.price.price,
381
+ subscriberPrice: product.subscriberPrice,
382
+ outlet: product.outlet,
383
+ createdAt: product.createdAt,
384
+ };
385
+ }
386
+ resultProductMapper(result) {
387
+ return result[0].length
388
+ ? result[0].map((result) => {
389
+ var _a, _b, _c, _d, _e, _f, _g;
390
+ return {
391
+ id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
392
+ name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
393
+ brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
394
+ stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
395
+ rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
396
+ // gender: result.document.structData.fields.gender.stringValue,
397
+ // createdAt: result.document.structData.fields.createdAt.stringValue,
398
+ // description: result.document.structData.fields.gender.stringValue,
399
+ // ean: result.document.structData.fields.gender.stringValue,
400
+ // fullPrice: result.document.structData.fields.gender.stringValue,
401
+ // icon: result.document.structData.fields.gender.stringValue,
402
+ // outlet: result.document.structData.fields.gender.stringValue,
403
+ // slug: result.document.structData.fields.gender.stringValue,
404
+ // price: result.document.structData.fields.gender.stringValue,
405
+ // published: result.document.structData.fields.gender.stringValue,
406
+ // shoppingCount: result.document.structData.fields.gender.stringValue,
407
+ // sku: result.document.structData.fields.gender.stringValue,
408
+ // subscriberPrice: result.document.structData.fields.gender.stringValue,
409
+ // miniatures: result.document.structData.fields.gender.stringValue,
410
+ };
411
+ })
412
+ : [];
413
+ }
414
+ };
415
+ DiscoveryEngineVertexAdapter = __decorate([
416
+ Injectable(),
417
+ __param(0, Inject(VERTEX_CONFIG)),
418
+ __metadata("design:paramtypes", [Object])
419
+ ], DiscoveryEngineVertexAdapter);
420
+
285
421
  var NestElasticSeachModule_1;
286
422
  let NestElasticSeachModule = NestElasticSeachModule_1 = class NestElasticSeachModule {
287
423
  static initializeApp(options) {
@@ -737,6 +873,30 @@ NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = __decorate([
737
873
  })
738
874
  ], NestHasuraGraphQLModule);
739
875
 
876
+ var NestVertexSeachModule_1;
877
+ let NestVertexSeachModule = NestVertexSeachModule_1 = class NestVertexSeachModule {
878
+ static initializeApp(options) {
879
+ return {
880
+ module: NestVertexSeachModule_1,
881
+ providers: [{ provide: VERTEX_CONFIG, useValue: options }],
882
+ exports: [VERTEX_CONFIG],
883
+ };
884
+ }
885
+ };
886
+ NestVertexSeachModule = NestVertexSeachModule_1 = __decorate([
887
+ Module({
888
+ providers: [
889
+ DiscoveryEngineVertexAdapter,
890
+ {
891
+ provide: 'ProductsVertexIndex',
892
+ useFactory: (adapter) => new ProductsVertexSearch(adapter),
893
+ inject: [DiscoveryEngineVertexAdapter],
894
+ },
895
+ ],
896
+ exports: [ProductsVertexSearch],
897
+ })
898
+ ], NestVertexSeachModule);
899
+
740
900
  var NestConnectModule_1;
741
901
  let NestConnectModule = NestConnectModule_1 = class NestConnectModule {
742
902
  static initializeApp(options) {
@@ -746,11 +906,13 @@ let NestConnectModule = NestConnectModule_1 = class NestConnectModule {
746
906
  ...(options.firebase ? [NestFirestoreModule.initializeApp({ firebase: options.firebase })] : []),
747
907
  ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [NestHasuraGraphQLModule.initializeApp(options.hasura)]),
748
908
  ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [NestElasticSeachModule.initializeApp(options.elasticSearch)]),
909
+ ...(isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule.initializeApp(options.vertex)]),
749
910
  ],
750
911
  exports: [
751
912
  ...(options.firebase ? [NestFirestoreModule] : []),
752
913
  ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [NestHasuraGraphQLModule]),
753
914
  ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [NestElasticSeachModule]),
915
+ ...(isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule]),
754
916
  ],
755
917
  };
756
918
  }
@@ -759,4 +921,4 @@ NestConnectModule = NestConnectModule_1 = __decorate([
759
921
  Module({})
760
922
  ], NestConnectModule);
761
923
 
762
- export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, ES_CONFIG, FIREBASE_STORAGE, HASURA_OPTIONS, NativeElasticSearchAdapter, NestConnectModule, NestElasticSeachModule, NestFirestoreModule, NestHasuraGraphQLModule, NestStorageModule };
924
+ export { ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, DiscoveryEngineVertexAdapter, ES_CONFIG, FIREBASE_STORAGE, HASURA_OPTIONS, NativeElasticSearchAdapter, NestConnectModule, NestElasticSeachModule, NestFirestoreModule, NestHasuraGraphQLModule, NestStorageModule, VERTEX_CONFIG };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect-nestjs",
3
- "version": "1.4.0-beta.2",
3
+ "version": "1.4.0-beta.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,13 +9,14 @@
9
9
  "url": "https://github.com/B4AGroup/b4a-firebase-libs"
10
10
  },
11
11
  "peerDependencies": {
12
- "@infrab4a/connect": "4.14.0-beta.2",
12
+ "@infrab4a/connect": "4.14.0-beta.4",
13
13
  "@nestjs/common": "^10.3.3",
14
14
  "@nestjs/core": "^10.3.3",
15
15
  "firebase-admin": "^12.0.0"
16
16
  },
17
17
  "dependencies": {
18
18
  "@elastic/elasticsearch": "^8.13.1",
19
+ "@google-cloud/discoveryengine": "^1.14.0",
19
20
  "nestjs-firebase": "^10.4.0"
20
21
  },
21
22
  "exports": {
@@ -1,3 +1,4 @@
1
1
  export * from './es-config.const';
2
2
  export * from './hasura-options.const';
3
3
  export * from './storage.const';
4
+ export * from './vertex-config.const';
@@ -0,0 +1 @@
1
+ export declare const VERTEX_CONFIG = "VERTEX_CONFIG";
@@ -1,2 +1,3 @@
1
1
  export * from './elasticsearch';
2
2
  export * from './firebase';
3
+ export * from './vertex-ai';
@@ -0,0 +1,18 @@
1
+ import { Product, ProductSearch, VertexSearchAdapter } from '@infrab4a/connect';
2
+ import { VertexConfig } from '../types';
3
+ export declare class DiscoveryEngineVertexAdapter implements VertexSearchAdapter<ProductSearch> {
4
+ private config;
5
+ private parentEngine;
6
+ private parentDataStore;
7
+ private servingConfig;
8
+ private searchClient;
9
+ private documentClient;
10
+ constructor(configuration: VertexConfig);
11
+ save(product: Product): Promise<[import("@google-cloud/discoveryengine/build/protos/protos").google.cloud.discoveryengine.v1.IDocument, import("@google-cloud/discoveryengine/build/protos/protos").google.cloud.discoveryengine.v1.IUpdateDocumentRequest, {}]>;
12
+ update(id: string, data: Product): Promise<[import("@google-cloud/discoveryengine/build/protos/protos").google.cloud.discoveryengine.v1.IDocument, import("@google-cloud/discoveryengine/build/protos/protos").google.cloud.discoveryengine.v1.IUpdateDocumentRequest, {}]>;
13
+ query(term: string, total: number, gender?: string): Promise<ProductSearch[]>;
14
+ get(id: string): Promise<any>;
15
+ delete(id: string): Promise<void>;
16
+ private productMapper;
17
+ private resultProductMapper;
18
+ }
@@ -0,0 +1 @@
1
+ export * from './discovery-engine-adapter';
@@ -0,0 +1,2 @@
1
+ export * from './adapters';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export * from './vertex-config';
2
+ export * from './vertex-search-result';
@@ -0,0 +1,23 @@
1
+ export type VertexConfig = {
2
+ credentials: {
3
+ type: string;
4
+ project_id: string;
5
+ private_key_id: string;
6
+ private_key: string;
7
+ client_email: string;
8
+ client_id: string;
9
+ auth_uri?: string;
10
+ token_uri?: string;
11
+ auth_provider_x509_cert_url?: string;
12
+ client_x509_cert_url?: string;
13
+ apiKey?: string;
14
+ authDomain?: string;
15
+ };
16
+ apiEndpoint: string;
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 {};
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { ESClientOptions } from './infra';
2
+ import { ESClientOptions, VertexConfig } from './infra';
3
3
  import { HasuraGraphQLOptions } from './nest-hasura-graphql.module';
4
4
  export declare class NestConnectModule {
5
5
  static initializeApp(options: {
@@ -8,5 +8,6 @@ export declare class NestConnectModule {
8
8
  };
9
9
  elasticSearch?: ESClientOptions;
10
10
  hasura: HasuraGraphQLOptions;
11
+ vertex: VertexConfig;
11
12
  }): DynamicModule;
12
13
  }
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { VertexConfig } from './infra';
3
+ export declare class NestVertexSeachModule {
4
+ static initializeApp(options: VertexConfig): DynamicModule;
5
+ }