@infrab4a/connect-nestjs 1.4.0-beta.7 → 1.5.1-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 +52 -58
- package/index.esm.js +52 -58
- package/package.json +2 -2
- package/src/infra/vertex-ai/adapters/discovery-engine-adapter.d.ts +3 -5
- package/src/infra/vertex-ai/helpers/index.d.ts +1 -0
- package/src/infra/vertex-ai/helpers/product-vertex-ai.helper.d.ts +7 -0
- package/src/infra/vertex-ai/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -290,6 +290,54 @@ class ConnectFirestoreService {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
class ProductVertexHelper {
|
|
294
|
+
constructor() { }
|
|
295
|
+
static productMapper(product) {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
298
|
+
return {
|
|
299
|
+
id: product.id.toString(),
|
|
300
|
+
miniatures: image,
|
|
301
|
+
icon: image,
|
|
302
|
+
name: product.name,
|
|
303
|
+
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,
|
|
304
|
+
ean: product.EAN,
|
|
305
|
+
sku: product.sku,
|
|
306
|
+
slug: product.slug,
|
|
307
|
+
published: product.published,
|
|
308
|
+
gender: product.gender,
|
|
309
|
+
stock: product.stock.quantity,
|
|
310
|
+
rating: product.rate,
|
|
311
|
+
shoppingCount: product.shoppingCount,
|
|
312
|
+
description: product.description.description,
|
|
313
|
+
fullPrice: product.fullPrice,
|
|
314
|
+
price: product.price.price,
|
|
315
|
+
subscriberPrice: product.subscriberPrice,
|
|
316
|
+
outlet: product.outlet,
|
|
317
|
+
createdAt: product.createdAt,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
static resultProductMapper(result) {
|
|
321
|
+
return result[0].length
|
|
322
|
+
? result[0].map((result) => {
|
|
323
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
324
|
+
return {
|
|
325
|
+
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
326
|
+
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
327
|
+
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
328
|
+
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
329
|
+
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
330
|
+
gender: result.document.structData.fields.gender.stringValue,
|
|
331
|
+
slug: result.document.structData.fields.slug.stringValue,
|
|
332
|
+
sku: result.document.structData.fields.sku.stringValue,
|
|
333
|
+
ean: result.document.structData.fields.ean.stringValue,
|
|
334
|
+
description: result.document.structData.fields.description.stringValue,
|
|
335
|
+
};
|
|
336
|
+
})
|
|
337
|
+
: [];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
293
341
|
exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
294
342
|
constructor(configuration) {
|
|
295
343
|
this.config = configuration;
|
|
@@ -306,7 +354,7 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
306
354
|
this.servingConfig = this.searchClient.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
|
|
307
355
|
}
|
|
308
356
|
async save(product) {
|
|
309
|
-
const productSearch =
|
|
357
|
+
const productSearch = ProductVertexHelper.productMapper(product);
|
|
310
358
|
const request = {
|
|
311
359
|
parent: this.parentEngine,
|
|
312
360
|
allowMissing: true,
|
|
@@ -320,7 +368,7 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
320
368
|
return response;
|
|
321
369
|
}
|
|
322
370
|
async update(id, data) {
|
|
323
|
-
const productSearch =
|
|
371
|
+
const productSearch = ProductVertexHelper.productMapper(data);
|
|
324
372
|
const request = {
|
|
325
373
|
parent: this.parentEngine,
|
|
326
374
|
allowMissing: true,
|
|
@@ -334,18 +382,17 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
334
382
|
return response;
|
|
335
383
|
}
|
|
336
384
|
async query(term, total, gender) {
|
|
337
|
-
const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
|
|
338
385
|
const response = (await this.searchClient.search({
|
|
339
386
|
pageSize: total,
|
|
340
387
|
query: term,
|
|
341
|
-
filter:
|
|
388
|
+
filter: '',
|
|
342
389
|
languageCode: 'pt-BR',
|
|
343
390
|
servingConfig: this.servingConfig,
|
|
344
391
|
relevanceThreshold: 'MEDIUM',
|
|
345
392
|
}, {
|
|
346
393
|
autoPaginate: false,
|
|
347
394
|
}));
|
|
348
|
-
return
|
|
395
|
+
return ProductVertexHelper.resultProductMapper(response);
|
|
349
396
|
}
|
|
350
397
|
async get(id) {
|
|
351
398
|
const request = {
|
|
@@ -361,59 +408,6 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
361
408
|
};
|
|
362
409
|
await this.documentClient.deleteDocument(request);
|
|
363
410
|
}
|
|
364
|
-
productMapper(product) {
|
|
365
|
-
var _a, _b;
|
|
366
|
-
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
367
|
-
return {
|
|
368
|
-
id: product.id.toString(),
|
|
369
|
-
miniatures: image,
|
|
370
|
-
icon: image,
|
|
371
|
-
name: product.name,
|
|
372
|
-
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,
|
|
373
|
-
ean: product.EAN,
|
|
374
|
-
sku: product.sku,
|
|
375
|
-
slug: product.slug,
|
|
376
|
-
published: product.published,
|
|
377
|
-
gender: product.gender,
|
|
378
|
-
stock: product.stock.quantity,
|
|
379
|
-
rating: product.rate,
|
|
380
|
-
shoppingCount: product.shoppingCount,
|
|
381
|
-
description: product.description.description,
|
|
382
|
-
fullPrice: product.fullPrice,
|
|
383
|
-
price: product.price.price,
|
|
384
|
-
subscriberPrice: product.subscriberPrice,
|
|
385
|
-
outlet: product.outlet,
|
|
386
|
-
createdAt: product.createdAt,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
resultProductMapper(result) {
|
|
390
|
-
return result[0].length
|
|
391
|
-
? result[0].map((result) => {
|
|
392
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
393
|
-
return {
|
|
394
|
-
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
395
|
-
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
396
|
-
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
397
|
-
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
398
|
-
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
399
|
-
// gender: result.document.structData.fields.gender.stringValue,
|
|
400
|
-
// createdAt: result.document.structData.fields.createdAt.stringValue,
|
|
401
|
-
// description: result.document.structData.fields.gender.stringValue,
|
|
402
|
-
// ean: result.document.structData.fields.gender.stringValue,
|
|
403
|
-
// fullPrice: result.document.structData.fields.gender.stringValue,
|
|
404
|
-
// icon: result.document.structData.fields.gender.stringValue,
|
|
405
|
-
// outlet: result.document.structData.fields.gender.stringValue,
|
|
406
|
-
// slug: result.document.structData.fields.gender.stringValue,
|
|
407
|
-
// price: result.document.structData.fields.gender.stringValue,
|
|
408
|
-
// published: result.document.structData.fields.gender.stringValue,
|
|
409
|
-
// shoppingCount: result.document.structData.fields.gender.stringValue,
|
|
410
|
-
// sku: result.document.structData.fields.gender.stringValue,
|
|
411
|
-
// subscriberPrice: result.document.structData.fields.gender.stringValue,
|
|
412
|
-
// miniatures: result.document.structData.fields.gender.stringValue,
|
|
413
|
-
};
|
|
414
|
-
})
|
|
415
|
-
: [];
|
|
416
|
-
}
|
|
417
411
|
};
|
|
418
412
|
exports.DiscoveryEngineVertexAdapter = __decorate([
|
|
419
413
|
common.Injectable(),
|
package/index.esm.js
CHANGED
|
@@ -286,6 +286,54 @@ class ConnectFirestoreService {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
class ProductVertexHelper {
|
|
290
|
+
constructor() { }
|
|
291
|
+
static productMapper(product) {
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
294
|
+
return {
|
|
295
|
+
id: product.id.toString(),
|
|
296
|
+
miniatures: image,
|
|
297
|
+
icon: image,
|
|
298
|
+
name: product.name,
|
|
299
|
+
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,
|
|
300
|
+
ean: product.EAN,
|
|
301
|
+
sku: product.sku,
|
|
302
|
+
slug: product.slug,
|
|
303
|
+
published: product.published,
|
|
304
|
+
gender: product.gender,
|
|
305
|
+
stock: product.stock.quantity,
|
|
306
|
+
rating: product.rate,
|
|
307
|
+
shoppingCount: product.shoppingCount,
|
|
308
|
+
description: product.description.description,
|
|
309
|
+
fullPrice: product.fullPrice,
|
|
310
|
+
price: product.price.price,
|
|
311
|
+
subscriberPrice: product.subscriberPrice,
|
|
312
|
+
outlet: product.outlet,
|
|
313
|
+
createdAt: product.createdAt,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
static resultProductMapper(result) {
|
|
317
|
+
return result[0].length
|
|
318
|
+
? result[0].map((result) => {
|
|
319
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
320
|
+
return {
|
|
321
|
+
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
322
|
+
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
323
|
+
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
324
|
+
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
325
|
+
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
326
|
+
gender: result.document.structData.fields.gender.stringValue,
|
|
327
|
+
slug: result.document.structData.fields.slug.stringValue,
|
|
328
|
+
sku: result.document.structData.fields.sku.stringValue,
|
|
329
|
+
ean: result.document.structData.fields.ean.stringValue,
|
|
330
|
+
description: result.document.structData.fields.description.stringValue,
|
|
331
|
+
};
|
|
332
|
+
})
|
|
333
|
+
: [];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
289
337
|
let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
290
338
|
constructor(configuration) {
|
|
291
339
|
this.config = configuration;
|
|
@@ -302,7 +350,7 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
302
350
|
this.servingConfig = this.searchClient.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
|
|
303
351
|
}
|
|
304
352
|
async save(product) {
|
|
305
|
-
const productSearch =
|
|
353
|
+
const productSearch = ProductVertexHelper.productMapper(product);
|
|
306
354
|
const request = {
|
|
307
355
|
parent: this.parentEngine,
|
|
308
356
|
allowMissing: true,
|
|
@@ -316,7 +364,7 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
316
364
|
return response;
|
|
317
365
|
}
|
|
318
366
|
async update(id, data) {
|
|
319
|
-
const productSearch =
|
|
367
|
+
const productSearch = ProductVertexHelper.productMapper(data);
|
|
320
368
|
const request = {
|
|
321
369
|
parent: this.parentEngine,
|
|
322
370
|
allowMissing: true,
|
|
@@ -330,18 +378,17 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
330
378
|
return response;
|
|
331
379
|
}
|
|
332
380
|
async query(term, total, gender) {
|
|
333
|
-
const defaultFilter = gender ? `gender: ANY(${gender}, "unisex")` : '';
|
|
334
381
|
const response = (await this.searchClient.search({
|
|
335
382
|
pageSize: total,
|
|
336
383
|
query: term,
|
|
337
|
-
filter:
|
|
384
|
+
filter: '',
|
|
338
385
|
languageCode: 'pt-BR',
|
|
339
386
|
servingConfig: this.servingConfig,
|
|
340
387
|
relevanceThreshold: 'MEDIUM',
|
|
341
388
|
}, {
|
|
342
389
|
autoPaginate: false,
|
|
343
390
|
}));
|
|
344
|
-
return
|
|
391
|
+
return ProductVertexHelper.resultProductMapper(response);
|
|
345
392
|
}
|
|
346
393
|
async get(id) {
|
|
347
394
|
const request = {
|
|
@@ -357,59 +404,6 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
357
404
|
};
|
|
358
405
|
await this.documentClient.deleteDocument(request);
|
|
359
406
|
}
|
|
360
|
-
productMapper(product) {
|
|
361
|
-
var _a, _b;
|
|
362
|
-
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
363
|
-
return {
|
|
364
|
-
id: product.id.toString(),
|
|
365
|
-
miniatures: image,
|
|
366
|
-
icon: image,
|
|
367
|
-
name: product.name,
|
|
368
|
-
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,
|
|
369
|
-
ean: product.EAN,
|
|
370
|
-
sku: product.sku,
|
|
371
|
-
slug: product.slug,
|
|
372
|
-
published: product.published,
|
|
373
|
-
gender: product.gender,
|
|
374
|
-
stock: product.stock.quantity,
|
|
375
|
-
rating: product.rate,
|
|
376
|
-
shoppingCount: product.shoppingCount,
|
|
377
|
-
description: product.description.description,
|
|
378
|
-
fullPrice: product.fullPrice,
|
|
379
|
-
price: product.price.price,
|
|
380
|
-
subscriberPrice: product.subscriberPrice,
|
|
381
|
-
outlet: product.outlet,
|
|
382
|
-
createdAt: product.createdAt,
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
resultProductMapper(result) {
|
|
386
|
-
return result[0].length
|
|
387
|
-
? result[0].map((result) => {
|
|
388
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
389
|
-
return {
|
|
390
|
-
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
391
|
-
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
392
|
-
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
393
|
-
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
394
|
-
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
395
|
-
// gender: result.document.structData.fields.gender.stringValue,
|
|
396
|
-
// createdAt: result.document.structData.fields.createdAt.stringValue,
|
|
397
|
-
// description: result.document.structData.fields.gender.stringValue,
|
|
398
|
-
// ean: result.document.structData.fields.gender.stringValue,
|
|
399
|
-
// fullPrice: result.document.structData.fields.gender.stringValue,
|
|
400
|
-
// icon: result.document.structData.fields.gender.stringValue,
|
|
401
|
-
// outlet: result.document.structData.fields.gender.stringValue,
|
|
402
|
-
// slug: result.document.structData.fields.gender.stringValue,
|
|
403
|
-
// price: result.document.structData.fields.gender.stringValue,
|
|
404
|
-
// published: result.document.structData.fields.gender.stringValue,
|
|
405
|
-
// shoppingCount: result.document.structData.fields.gender.stringValue,
|
|
406
|
-
// sku: result.document.structData.fields.gender.stringValue,
|
|
407
|
-
// subscriberPrice: result.document.structData.fields.gender.stringValue,
|
|
408
|
-
// miniatures: result.document.structData.fields.gender.stringValue,
|
|
409
|
-
};
|
|
410
|
-
})
|
|
411
|
-
: [];
|
|
412
|
-
}
|
|
413
407
|
};
|
|
414
408
|
DiscoveryEngineVertexAdapter = __decorate([
|
|
415
409
|
Injectable(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infrab4a/connect-nestjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1-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.
|
|
12
|
+
"@infrab4a/connect": "4.15.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 {
|
|
1
|
+
import { 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;
|
|
@@ -8,11 +8,9 @@ export declare class DiscoveryEngineVertexAdapter implements VertexSearchAdapter
|
|
|
8
8
|
private searchClient;
|
|
9
9
|
private documentClient;
|
|
10
10
|
constructor(configuration: VertexConfig);
|
|
11
|
-
save(product:
|
|
12
|
-
update(id: string, data:
|
|
11
|
+
save(product: ProductHasuraGraphQL): 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: ProductHasuraGraphQL): 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
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
|
-
private productMapper;
|
|
17
|
-
private resultProductMapper;
|
|
18
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './product-vertex-ai.helper';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProductHasuraGraphQL, ProductSearch } from '@infrab4a/connect';
|
|
2
|
+
import { VertexSearchResult } from '../types';
|
|
3
|
+
export default class ProductVertexHelper {
|
|
4
|
+
constructor();
|
|
5
|
+
static productMapper(product: ProductHasuraGraphQL): ProductSearch;
|
|
6
|
+
static resultProductMapper(result: VertexSearchResult<ProductSearch>): ProductSearch[];
|
|
7
|
+
}
|