@infrab4a/connect-nestjs 1.5.0 → 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.d.ts +1 -1
- package/index.cjs.js +51 -47
- package/index.esm.js +51 -47
- package/package.json +1 -1
- 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.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src
|
|
1
|
+
export * from "./src\\index";
|
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,
|
|
@@ -344,7 +392,7 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
344
392
|
}, {
|
|
345
393
|
autoPaginate: false,
|
|
346
394
|
}));
|
|
347
|
-
return
|
|
395
|
+
return ProductVertexHelper.resultProductMapper(response);
|
|
348
396
|
}
|
|
349
397
|
async get(id) {
|
|
350
398
|
const request = {
|
|
@@ -360,50 +408,6 @@ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
360
408
|
};
|
|
361
409
|
await this.documentClient.deleteDocument(request);
|
|
362
410
|
}
|
|
363
|
-
productMapper(product) {
|
|
364
|
-
var _a, _b;
|
|
365
|
-
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
366
|
-
return {
|
|
367
|
-
id: product.id.toString(),
|
|
368
|
-
miniatures: image,
|
|
369
|
-
icon: image,
|
|
370
|
-
name: product.name,
|
|
371
|
-
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,
|
|
372
|
-
ean: product.EAN,
|
|
373
|
-
sku: product.sku,
|
|
374
|
-
slug: product.slug,
|
|
375
|
-
published: product.published,
|
|
376
|
-
gender: product.gender,
|
|
377
|
-
stock: product.stock.quantity,
|
|
378
|
-
rating: product.rate,
|
|
379
|
-
shoppingCount: product.shoppingCount,
|
|
380
|
-
description: product.description.description,
|
|
381
|
-
fullPrice: product.fullPrice,
|
|
382
|
-
price: product.price.price,
|
|
383
|
-
subscriberPrice: product.subscriberPrice,
|
|
384
|
-
outlet: product.outlet,
|
|
385
|
-
createdAt: product.createdAt,
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
resultProductMapper(result) {
|
|
389
|
-
return result[0].length
|
|
390
|
-
? result[0].map((result) => {
|
|
391
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
392
|
-
return {
|
|
393
|
-
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
394
|
-
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
395
|
-
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
396
|
-
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
397
|
-
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
398
|
-
gender: result.document.structData.fields.gender.stringValue,
|
|
399
|
-
slug: result.document.structData.fields.slug.stringValue,
|
|
400
|
-
sku: result.document.structData.fields.sku.stringValue,
|
|
401
|
-
ean: result.document.structData.fields.ean.stringValue,
|
|
402
|
-
description: result.document.structData.fields.description.stringValue,
|
|
403
|
-
};
|
|
404
|
-
})
|
|
405
|
-
: [];
|
|
406
|
-
}
|
|
407
411
|
};
|
|
408
412
|
exports.DiscoveryEngineVertexAdapter = __decorate([
|
|
409
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,
|
|
@@ -340,7 +388,7 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
340
388
|
}, {
|
|
341
389
|
autoPaginate: false,
|
|
342
390
|
}));
|
|
343
|
-
return
|
|
391
|
+
return ProductVertexHelper.resultProductMapper(response);
|
|
344
392
|
}
|
|
345
393
|
async get(id) {
|
|
346
394
|
const request = {
|
|
@@ -356,50 +404,6 @@ let DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
|
|
|
356
404
|
};
|
|
357
405
|
await this.documentClient.deleteDocument(request);
|
|
358
406
|
}
|
|
359
|
-
productMapper(product) {
|
|
360
|
-
var _a, _b;
|
|
361
|
-
const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
|
|
362
|
-
return {
|
|
363
|
-
id: product.id.toString(),
|
|
364
|
-
miniatures: image,
|
|
365
|
-
icon: image,
|
|
366
|
-
name: product.name,
|
|
367
|
-
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,
|
|
368
|
-
ean: product.EAN,
|
|
369
|
-
sku: product.sku,
|
|
370
|
-
slug: product.slug,
|
|
371
|
-
published: product.published,
|
|
372
|
-
gender: product.gender,
|
|
373
|
-
stock: product.stock.quantity,
|
|
374
|
-
rating: product.rate,
|
|
375
|
-
shoppingCount: product.shoppingCount,
|
|
376
|
-
description: product.description.description,
|
|
377
|
-
fullPrice: product.fullPrice,
|
|
378
|
-
price: product.price.price,
|
|
379
|
-
subscriberPrice: product.subscriberPrice,
|
|
380
|
-
outlet: product.outlet,
|
|
381
|
-
createdAt: product.createdAt,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
resultProductMapper(result) {
|
|
385
|
-
return result[0].length
|
|
386
|
-
? result[0].map((result) => {
|
|
387
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
388
|
-
return {
|
|
389
|
-
id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
|
|
390
|
-
name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
|
|
391
|
-
brand: (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand.stringValue,
|
|
392
|
-
stock: (_e = (_d = result.document) === null || _d === void 0 ? void 0 : _d.structData.fields.stock) === null || _e === void 0 ? void 0 : _e.numberValue,
|
|
393
|
-
rating: (_g = (_f = result.document) === null || _f === void 0 ? void 0 : _f.structData.fields.rating) === null || _g === void 0 ? void 0 : _g.stringValue,
|
|
394
|
-
gender: result.document.structData.fields.gender.stringValue,
|
|
395
|
-
slug: result.document.structData.fields.slug.stringValue,
|
|
396
|
-
sku: result.document.structData.fields.sku.stringValue,
|
|
397
|
-
ean: result.document.structData.fields.ean.stringValue,
|
|
398
|
-
description: result.document.structData.fields.description.stringValue,
|
|
399
|
-
};
|
|
400
|
-
})
|
|
401
|
-
: [];
|
|
402
|
-
}
|
|
403
407
|
};
|
|
404
408
|
DiscoveryEngineVertexAdapter = __decorate([
|
|
405
409
|
Injectable(),
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|