@infrab4a/connect-nestjs 1.5.1 → 1.5.3-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.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/index";
1
+ export * from "./src\\index";
package/index.cjs.js CHANGED
@@ -408,6 +408,27 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
408
408
  };
409
409
  await this.documentClient.deleteDocument(request);
410
410
  }
411
+ async bulkProducts(products) {
412
+ try {
413
+ const batchSize = 100;
414
+ let total = 0;
415
+ for (let index = 0; index < products.length; index += batchSize) {
416
+ const bulkProducts = products.slice(index, index + batchSize);
417
+ const [operation] = await this.documentClient.importDocuments({
418
+ parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch`,
419
+ inlineSource: {
420
+ documents: bulkProducts,
421
+ },
422
+ });
423
+ total += bulkProducts.length;
424
+ const [response] = await operation.promise();
425
+ console.log(`Imported: ${total} documents`, ((total / products.length) * 100).toFixed(2) + '%', `Erros: `, response.errorSamples ? response.errorSamples : []);
426
+ }
427
+ }
428
+ catch (error) {
429
+ console.log(error);
430
+ }
431
+ }
411
432
  };
412
433
  exports.DiscoveryEngineVertexAdapter = __decorate([
413
434
  common.Injectable(),
package/index.esm.js CHANGED
@@ -404,6 +404,27 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
404
404
  };
405
405
  await this.documentClient.deleteDocument(request);
406
406
  }
407
+ async bulkProducts(products) {
408
+ try {
409
+ const batchSize = 100;
410
+ let total = 0;
411
+ for (let index = 0; index < products.length; index += batchSize) {
412
+ const bulkProducts = products.slice(index, index + batchSize);
413
+ const [operation] = await this.documentClient.importDocuments({
414
+ parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch`,
415
+ inlineSource: {
416
+ documents: bulkProducts,
417
+ },
418
+ });
419
+ total += bulkProducts.length;
420
+ const [response] = await operation.promise();
421
+ console.log(`Imported: ${total} documents`, ((total / products.length) * 100).toFixed(2) + '%', `Erros: `, response.errorSamples ? response.errorSamples : []);
422
+ }
423
+ }
424
+ catch (error) {
425
+ console.log(error);
426
+ }
427
+ }
407
428
  };
408
429
  DiscoveryEngineVertexAdapter = __decorate([
409
430
  Injectable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect-nestjs",
3
- "version": "1.5.1",
3
+ "version": "1.5.3-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/B4AGroup/b4a-firebase-libs"
10
10
  },
11
11
  "peerDependencies": {
12
- "@infrab4a/connect": "4.15.0",
12
+ "@infrab4a/connect": "^4.15.2-beta.0",
13
13
  "@nestjs/common": "^10.3.3",
14
14
  "@nestjs/core": "^10.3.3",
15
15
  "firebase-admin": "^12.0.0"
@@ -1,4 +1,4 @@
1
- import { ProductHasuraGraphQL, ProductSearch, VertexSearchAdapter } from '@infrab4a/connect';
1
+ import { ProductBulk, ProductHasuraGraphQL, ProductSearch, VertexSearchAdapter } from '@infrab4a/connect';
2
2
  import { VertexConfig } from '../types';
3
3
  export declare class DiscoveryEngineVertexAdapter implements VertexSearchAdapter<ProductSearch> {
4
4
  private config;
@@ -13,4 +13,5 @@ export declare class DiscoveryEngineVertexAdapter implements VertexSearchAdapter
13
13
  query(term: string, total: number, gender?: string): Promise<ProductSearch[]>;
14
14
  get(id: string): Promise<any>;
15
15
  delete(id: string): Promise<void>;
16
+ bulkProducts(products: ProductBulk[]): Promise<void>;
16
17
  }