@infrab4a/connect 4.14.0-beta.0 → 4.14.0-beta.2
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 +96 -115
- package/index.esm.js +96 -115
- package/package.json +1 -2
- package/src/domain/general/index.d.ts +1 -0
- package/src/domain/general/search/index.d.ts +1 -0
- package/src/domain/general/search/product-search-index.d.ts +3 -0
- package/src/infra/elasticsearch/indexes/products-index.d.ts +36 -1
- package/src/infra/vertex-ai/adapters/discovery-engine-adapter.d.ts +0 -19
- package/src/infra/vertex-ai/adapters/index.d.ts +2 -2
- package/src/infra/vertex-ai/adapters/{vertex-ai-search-adapter.d.ts → vertex-ai-search.adapter.d.ts} +2 -2
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +14 -0
- package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +3 -2
- package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +4 -0
- package/src/infra/vertex-ai/types/index.d.ts +1 -2
- package/src/infra/vertex-ai/types/vertex-config.d.ts +0 -23
- package/src/infra/vertex-ai/types/vertex-search-result.d.ts +0 -18
package/index.cjs.js
CHANGED
|
@@ -2596,7 +2596,9 @@ class ProductsIndex {
|
|
|
2596
2596
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2597
2597
|
return hit;
|
|
2598
2598
|
});
|
|
2599
|
-
return search
|
|
2599
|
+
return search.hits.map((hit) => {
|
|
2600
|
+
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2601
|
+
});
|
|
2600
2602
|
}
|
|
2601
2603
|
async save(product) {
|
|
2602
2604
|
try {
|
|
@@ -6400,130 +6402,109 @@ tslib.__decorate([
|
|
|
6400
6402
|
tslib.__metadata("design:returntype", Promise)
|
|
6401
6403
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6402
6404
|
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
// console.log('DiscoveryEngineSearch', configuration)
|
|
6408
|
-
this.config = configuration;
|
|
6409
|
-
this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
|
|
6410
|
-
this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
|
|
6411
|
-
this.client = new SearchServiceClient({
|
|
6412
|
-
apiEndpoint: configuration.apiEndpoint,
|
|
6413
|
-
credentials: configuration.credentials,
|
|
6414
|
-
});
|
|
6415
|
-
this.servingConfig = this.client.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
|
|
6416
|
-
}
|
|
6417
|
-
save(data) {
|
|
6418
|
-
throw new Error('Method not implemented.');
|
|
6405
|
+
class VertexAxiosAdapter {
|
|
6406
|
+
constructor(config) {
|
|
6407
|
+
this.config = config;
|
|
6408
|
+
this.logger = DebugHelper.from(this);
|
|
6419
6409
|
}
|
|
6420
|
-
async query(
|
|
6421
|
-
const
|
|
6422
|
-
const
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6410
|
+
async query(searchTerm, total, gender) {
|
|
6411
|
+
const logger = this.logger.with('query');
|
|
6412
|
+
const req = {
|
|
6413
|
+
url: `${this.config.url}/search`,
|
|
6414
|
+
method: 'POST',
|
|
6415
|
+
responseType: 'json',
|
|
6416
|
+
headers: {
|
|
6417
|
+
Accept: 'application/json',
|
|
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
|
+
return data;
|
|
6425
|
+
}
|
|
6426
|
+
catch (error) {
|
|
6427
|
+
logger.error({ req, res: error });
|
|
6428
|
+
throw error;
|
|
6429
|
+
}
|
|
6433
6430
|
}
|
|
6434
6431
|
async get(id) {
|
|
6435
|
-
const
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
async create(product) {
|
|
6443
|
-
const request = {
|
|
6444
|
-
parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
|
|
6445
|
-
allowMissing: true,
|
|
6446
|
-
document: {
|
|
6447
|
-
name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${product.id.toString()}`,
|
|
6448
|
-
jsonData: JSON.stringify(product),
|
|
6449
|
-
data: 'jsonData',
|
|
6432
|
+
const logger = this.logger.with('update');
|
|
6433
|
+
const req = {
|
|
6434
|
+
url: `${this.config.url}/${id}`,
|
|
6435
|
+
method: 'GET',
|
|
6436
|
+
responseType: 'json',
|
|
6437
|
+
headers: {
|
|
6438
|
+
Accept: 'application/json',
|
|
6450
6439
|
},
|
|
6451
6440
|
};
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6441
|
+
try {
|
|
6442
|
+
const { data } = await axios__default["default"](req);
|
|
6443
|
+
return data;
|
|
6444
|
+
}
|
|
6445
|
+
catch (error) {
|
|
6446
|
+
logger.error({ req, res: error });
|
|
6447
|
+
throw error;
|
|
6448
|
+
}
|
|
6449
|
+
}
|
|
6450
|
+
async save(data) {
|
|
6451
|
+
const logger = this.logger.with('save');
|
|
6452
|
+
const req = {
|
|
6453
|
+
url: `${this.config.url}/sync`,
|
|
6454
|
+
method: 'POST',
|
|
6455
|
+
responseType: 'json',
|
|
6456
|
+
headers: {
|
|
6457
|
+
Accept: 'application/json',
|
|
6464
6458
|
},
|
|
6459
|
+
data,
|
|
6465
6460
|
};
|
|
6466
|
-
|
|
6467
|
-
|
|
6461
|
+
try {
|
|
6462
|
+
const { data } = await axios__default["default"](req);
|
|
6463
|
+
return data;
|
|
6464
|
+
}
|
|
6465
|
+
catch (error) {
|
|
6466
|
+
logger.error({ req, res: error });
|
|
6467
|
+
throw error;
|
|
6468
|
+
}
|
|
6468
6469
|
}
|
|
6469
|
-
async
|
|
6470
|
-
const
|
|
6471
|
-
|
|
6470
|
+
async update(id, data) {
|
|
6471
|
+
const logger = this.logger.with('update');
|
|
6472
|
+
const req = {
|
|
6473
|
+
url: `${this.config.url}/${id}`,
|
|
6474
|
+
method: 'PUT',
|
|
6475
|
+
responseType: 'json',
|
|
6476
|
+
headers: {
|
|
6477
|
+
Accept: 'application/json',
|
|
6478
|
+
},
|
|
6479
|
+
data,
|
|
6472
6480
|
};
|
|
6473
|
-
|
|
6481
|
+
try {
|
|
6482
|
+
const { data } = await axios__default["default"](req);
|
|
6483
|
+
return data;
|
|
6484
|
+
}
|
|
6485
|
+
catch (error) {
|
|
6486
|
+
logger.error({ req, res: error });
|
|
6487
|
+
throw error;
|
|
6488
|
+
}
|
|
6474
6489
|
}
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
const
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
ean: product.EAN,
|
|
6485
|
-
sku: product.sku,
|
|
6486
|
-
slug: product.slug,
|
|
6487
|
-
published: product.published,
|
|
6488
|
-
gender: product.gender,
|
|
6489
|
-
stock: product.stock.quantity,
|
|
6490
|
-
rating: product.rate,
|
|
6491
|
-
shoppingCount: product.shoppingCount,
|
|
6492
|
-
description: product.description.description,
|
|
6493
|
-
fullPrice: product.fullPrice,
|
|
6494
|
-
price: product.price.price,
|
|
6495
|
-
subscriberPrice: product.subscriberPrice,
|
|
6496
|
-
outlet: product.outlet,
|
|
6497
|
-
createdAt: product.createdAt,
|
|
6490
|
+
async delete(id) {
|
|
6491
|
+
const logger = this.logger.with('delete');
|
|
6492
|
+
const req = {
|
|
6493
|
+
url: `${this.config.url}/${id}`,
|
|
6494
|
+
method: 'DELETE',
|
|
6495
|
+
responseType: 'json',
|
|
6496
|
+
headers: {
|
|
6497
|
+
Accept: 'application/json',
|
|
6498
|
+
},
|
|
6498
6499
|
};
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
brand: result.document.structData.fields.brand.stringValue,
|
|
6508
|
-
stock: (_a = result.document.structData.fields.stock) === null || _a === void 0 ? void 0 : _a.numberValue,
|
|
6509
|
-
rating: (_b = result.document.structData.fields.rating) === null || _b === void 0 ? void 0 : _b.stringValue,
|
|
6510
|
-
// gender: result.document.structData.fields.gender.stringValue,
|
|
6511
|
-
// createdAt: result.document.structData.fields.createdAt.stringValue,
|
|
6512
|
-
// description: result.document.structData.fields.gender.stringValue,
|
|
6513
|
-
// ean: result.document.structData.fields.gender.stringValue,
|
|
6514
|
-
// fullPrice: result.document.structData.fields.gender.stringValue,
|
|
6515
|
-
// icon: result.document.structData.fields.gender.stringValue,
|
|
6516
|
-
// outlet: result.document.structData.fields.gender.stringValue,
|
|
6517
|
-
// slug: result.document.structData.fields.gender.stringValue,
|
|
6518
|
-
// price: result.document.structData.fields.gender.stringValue,
|
|
6519
|
-
// published: result.document.structData.fields.gender.stringValue,
|
|
6520
|
-
// shoppingCount: result.document.structData.fields.gender.stringValue,
|
|
6521
|
-
// sku: result.document.structData.fields.gender.stringValue,
|
|
6522
|
-
// subscriberPrice: result.document.structData.fields.gender.stringValue,
|
|
6523
|
-
// miniatures: result.document.structData.fields.gender.stringValue,
|
|
6524
|
-
};
|
|
6525
|
-
})
|
|
6526
|
-
: [];
|
|
6500
|
+
try {
|
|
6501
|
+
const { data } = await axios__default["default"](req);
|
|
6502
|
+
return data;
|
|
6503
|
+
}
|
|
6504
|
+
catch (error) {
|
|
6505
|
+
logger.error({ req, res: error });
|
|
6506
|
+
throw error;
|
|
6507
|
+
}
|
|
6527
6508
|
}
|
|
6528
6509
|
}
|
|
6529
6510
|
|
|
@@ -6726,7 +6707,6 @@ exports.CouponFirestoreRepository = CouponFirestoreRepository;
|
|
|
6726
6707
|
exports.Debug = Debug;
|
|
6727
6708
|
exports.DebugDecoratorHelper = DebugDecoratorHelper;
|
|
6728
6709
|
exports.DebugHelper = DebugHelper;
|
|
6729
|
-
exports.DiscoveryEngineSearch = DiscoveryEngineSearch;
|
|
6730
6710
|
exports.DuplicatedResultsError = DuplicatedResultsError;
|
|
6731
6711
|
exports.Edition = Edition;
|
|
6732
6712
|
exports.Filter = Filter;
|
|
@@ -6801,6 +6781,7 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
|
|
|
6801
6781
|
exports.Variant = Variant;
|
|
6802
6782
|
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
6803
6783
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|
|
6784
|
+
exports.VertexAxiosAdapter = VertexAxiosAdapter;
|
|
6804
6785
|
exports.WeakPasswordError = WeakPasswordError;
|
|
6805
6786
|
exports.Wishlist = Wishlist;
|
|
6806
6787
|
exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
|
package/index.esm.js
CHANGED
|
@@ -2590,7 +2590,9 @@ class ProductsIndex {
|
|
|
2590
2590
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2591
2591
|
return hit;
|
|
2592
2592
|
});
|
|
2593
|
-
return search
|
|
2593
|
+
return search.hits.map((hit) => {
|
|
2594
|
+
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2595
|
+
});
|
|
2594
2596
|
}
|
|
2595
2597
|
async save(product) {
|
|
2596
2598
|
try {
|
|
@@ -6394,130 +6396,109 @@ __decorate([
|
|
|
6394
6396
|
__metadata("design:returntype", Promise)
|
|
6395
6397
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6396
6398
|
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
// console.log('DiscoveryEngineSearch', configuration)
|
|
6402
|
-
this.config = configuration;
|
|
6403
|
-
this.parentEngine = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`;
|
|
6404
|
-
this.parentDataStore = `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
|
|
6405
|
-
this.client = new SearchServiceClient({
|
|
6406
|
-
apiEndpoint: configuration.apiEndpoint,
|
|
6407
|
-
credentials: configuration.credentials,
|
|
6408
|
-
});
|
|
6409
|
-
this.servingConfig = this.client.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
|
|
6410
|
-
}
|
|
6411
|
-
save(data) {
|
|
6412
|
-
throw new Error('Method not implemented.');
|
|
6399
|
+
class VertexAxiosAdapter {
|
|
6400
|
+
constructor(config) {
|
|
6401
|
+
this.config = config;
|
|
6402
|
+
this.logger = DebugHelper.from(this);
|
|
6413
6403
|
}
|
|
6414
|
-
async query(
|
|
6415
|
-
const
|
|
6416
|
-
const
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6404
|
+
async query(searchTerm, total, gender) {
|
|
6405
|
+
const logger = this.logger.with('query');
|
|
6406
|
+
const req = {
|
|
6407
|
+
url: `${this.config.url}/search`,
|
|
6408
|
+
method: 'POST',
|
|
6409
|
+
responseType: 'json',
|
|
6410
|
+
headers: {
|
|
6411
|
+
Accept: 'application/json',
|
|
6412
|
+
},
|
|
6413
|
+
data: { searchTerm, total, gender },
|
|
6414
|
+
};
|
|
6415
|
+
try {
|
|
6416
|
+
const { data } = await axios(req);
|
|
6417
|
+
console.log('response vertex axios', data);
|
|
6418
|
+
return data;
|
|
6419
|
+
}
|
|
6420
|
+
catch (error) {
|
|
6421
|
+
logger.error({ req, res: error });
|
|
6422
|
+
throw error;
|
|
6423
|
+
}
|
|
6427
6424
|
}
|
|
6428
6425
|
async get(id) {
|
|
6429
|
-
const
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
async create(product) {
|
|
6437
|
-
const request = {
|
|
6438
|
-
parent: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/engines/${this.config.dataStoreId}`,
|
|
6439
|
-
allowMissing: true,
|
|
6440
|
-
document: {
|
|
6441
|
-
name: `projects/${this.config.projectId}/locations/${this.config.location}/collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents/${product.id.toString()}`,
|
|
6442
|
-
jsonData: JSON.stringify(product),
|
|
6443
|
-
data: 'jsonData',
|
|
6426
|
+
const logger = this.logger.with('update');
|
|
6427
|
+
const req = {
|
|
6428
|
+
url: `${this.config.url}/${id}`,
|
|
6429
|
+
method: 'GET',
|
|
6430
|
+
responseType: 'json',
|
|
6431
|
+
headers: {
|
|
6432
|
+
Accept: 'application/json',
|
|
6444
6433
|
},
|
|
6445
6434
|
};
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6435
|
+
try {
|
|
6436
|
+
const { data } = await axios(req);
|
|
6437
|
+
return data;
|
|
6438
|
+
}
|
|
6439
|
+
catch (error) {
|
|
6440
|
+
logger.error({ req, res: error });
|
|
6441
|
+
throw error;
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
async save(data) {
|
|
6445
|
+
const logger = this.logger.with('save');
|
|
6446
|
+
const req = {
|
|
6447
|
+
url: `${this.config.url}/sync`,
|
|
6448
|
+
method: 'POST',
|
|
6449
|
+
responseType: 'json',
|
|
6450
|
+
headers: {
|
|
6451
|
+
Accept: 'application/json',
|
|
6458
6452
|
},
|
|
6453
|
+
data,
|
|
6459
6454
|
};
|
|
6460
|
-
|
|
6461
|
-
|
|
6455
|
+
try {
|
|
6456
|
+
const { data } = await axios(req);
|
|
6457
|
+
return data;
|
|
6458
|
+
}
|
|
6459
|
+
catch (error) {
|
|
6460
|
+
logger.error({ req, res: error });
|
|
6461
|
+
throw error;
|
|
6462
|
+
}
|
|
6462
6463
|
}
|
|
6463
|
-
async
|
|
6464
|
-
const
|
|
6465
|
-
|
|
6464
|
+
async update(id, data) {
|
|
6465
|
+
const logger = this.logger.with('update');
|
|
6466
|
+
const req = {
|
|
6467
|
+
url: `${this.config.url}/${id}`,
|
|
6468
|
+
method: 'PUT',
|
|
6469
|
+
responseType: 'json',
|
|
6470
|
+
headers: {
|
|
6471
|
+
Accept: 'application/json',
|
|
6472
|
+
},
|
|
6473
|
+
data,
|
|
6466
6474
|
};
|
|
6467
|
-
|
|
6475
|
+
try {
|
|
6476
|
+
const { data } = await axios(req);
|
|
6477
|
+
return data;
|
|
6478
|
+
}
|
|
6479
|
+
catch (error) {
|
|
6480
|
+
logger.error({ req, res: error });
|
|
6481
|
+
throw error;
|
|
6482
|
+
}
|
|
6468
6483
|
}
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
const
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
ean: product.EAN,
|
|
6479
|
-
sku: product.sku,
|
|
6480
|
-
slug: product.slug,
|
|
6481
|
-
published: product.published,
|
|
6482
|
-
gender: product.gender,
|
|
6483
|
-
stock: product.stock.quantity,
|
|
6484
|
-
rating: product.rate,
|
|
6485
|
-
shoppingCount: product.shoppingCount,
|
|
6486
|
-
description: product.description.description,
|
|
6487
|
-
fullPrice: product.fullPrice,
|
|
6488
|
-
price: product.price.price,
|
|
6489
|
-
subscriberPrice: product.subscriberPrice,
|
|
6490
|
-
outlet: product.outlet,
|
|
6491
|
-
createdAt: product.createdAt,
|
|
6484
|
+
async delete(id) {
|
|
6485
|
+
const logger = this.logger.with('delete');
|
|
6486
|
+
const req = {
|
|
6487
|
+
url: `${this.config.url}/${id}`,
|
|
6488
|
+
method: 'DELETE',
|
|
6489
|
+
responseType: 'json',
|
|
6490
|
+
headers: {
|
|
6491
|
+
Accept: 'application/json',
|
|
6492
|
+
},
|
|
6492
6493
|
};
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
brand: result.document.structData.fields.brand.stringValue,
|
|
6502
|
-
stock: (_a = result.document.structData.fields.stock) === null || _a === void 0 ? void 0 : _a.numberValue,
|
|
6503
|
-
rating: (_b = result.document.structData.fields.rating) === null || _b === void 0 ? void 0 : _b.stringValue,
|
|
6504
|
-
// gender: result.document.structData.fields.gender.stringValue,
|
|
6505
|
-
// createdAt: result.document.structData.fields.createdAt.stringValue,
|
|
6506
|
-
// description: result.document.structData.fields.gender.stringValue,
|
|
6507
|
-
// ean: result.document.structData.fields.gender.stringValue,
|
|
6508
|
-
// fullPrice: result.document.structData.fields.gender.stringValue,
|
|
6509
|
-
// icon: result.document.structData.fields.gender.stringValue,
|
|
6510
|
-
// outlet: result.document.structData.fields.gender.stringValue,
|
|
6511
|
-
// slug: result.document.structData.fields.gender.stringValue,
|
|
6512
|
-
// price: result.document.structData.fields.gender.stringValue,
|
|
6513
|
-
// published: result.document.structData.fields.gender.stringValue,
|
|
6514
|
-
// shoppingCount: result.document.structData.fields.gender.stringValue,
|
|
6515
|
-
// sku: result.document.structData.fields.gender.stringValue,
|
|
6516
|
-
// subscriberPrice: result.document.structData.fields.gender.stringValue,
|
|
6517
|
-
// miniatures: result.document.structData.fields.gender.stringValue,
|
|
6518
|
-
};
|
|
6519
|
-
})
|
|
6520
|
-
: [];
|
|
6494
|
+
try {
|
|
6495
|
+
const { data } = await axios(req);
|
|
6496
|
+
return data;
|
|
6497
|
+
}
|
|
6498
|
+
catch (error) {
|
|
6499
|
+
logger.error({ req, res: error });
|
|
6500
|
+
throw error;
|
|
6501
|
+
}
|
|
6521
6502
|
}
|
|
6522
6503
|
}
|
|
6523
6504
|
|
|
@@ -6566,4 +6547,4 @@ class ProductsVertexSearch {
|
|
|
6566
6547
|
}
|
|
6567
6548
|
}
|
|
6568
6549
|
|
|
6569
|
-
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,
|
|
6550
|
+
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.14.0-beta.
|
|
3
|
+
"version": "4.14.0-beta.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"url": "https://github.com/B4AGroup/b4a-firebase-libs"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@google-cloud/discoveryengine": "^1.14.0",
|
|
13
12
|
"axios": "^0.27.2",
|
|
14
13
|
"class-transformer": "^0.5.1",
|
|
15
14
|
"date-fns": "^2.28.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './product-search-index';
|
|
@@ -6,7 +6,42 @@ export declare class ProductsIndex {
|
|
|
6
6
|
private index;
|
|
7
7
|
constructor(adapter: ElasticSearchAdapter<Product>);
|
|
8
8
|
getById(id: string): Promise<Product>;
|
|
9
|
-
search(searchTerm: string, total: number, shop?: string): Promise<
|
|
9
|
+
search(searchTerm: string, total: number, shop?: string): Promise<{
|
|
10
|
+
stock: number;
|
|
11
|
+
category: import("../../../domain/catalog/models/category-for-product").CategoryForProduct;
|
|
12
|
+
kitProducts?: import("../../../domain").KitProduct[];
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
description: import("../../../domain").ShopDescription;
|
|
17
|
+
sku: string;
|
|
18
|
+
price: import("../../../domain").ShopPrice;
|
|
19
|
+
hasVariants: boolean;
|
|
20
|
+
NCM: string;
|
|
21
|
+
EAN: string;
|
|
22
|
+
CEST: string;
|
|
23
|
+
weight: number;
|
|
24
|
+
costPrice: number;
|
|
25
|
+
images?: string[];
|
|
26
|
+
miniatures?: string[];
|
|
27
|
+
published: boolean;
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
updatedAt?: Date;
|
|
30
|
+
brand: string;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
filters?: string[];
|
|
33
|
+
type?: string;
|
|
34
|
+
categories?: string[];
|
|
35
|
+
reviews?: import("../../../domain").ProductReview[];
|
|
36
|
+
variants?: import("../../../domain").Variant[];
|
|
37
|
+
video?: string;
|
|
38
|
+
isKit?: boolean;
|
|
39
|
+
rate?: number;
|
|
40
|
+
gender?: import("../../../domain").ProductGender;
|
|
41
|
+
shoppingCount?: number;
|
|
42
|
+
metadata: import("../../../domain").ProductMetadata;
|
|
43
|
+
outlet?: boolean;
|
|
44
|
+
}[]>;
|
|
10
45
|
save(product: ProductHasuraGraphQL): Promise<void>;
|
|
11
46
|
update(product: ProductHasuraGraphQL): Promise<void>;
|
|
12
47
|
delete(id: string): Promise<void>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Product } from '../../../domain';
|
|
2
|
-
import { ProductSearch, VertexConfig } from '../types';
|
|
3
|
-
import { VertexSearchAdapter } from './vertex-ai-search-adapter';
|
|
4
|
-
export declare class DiscoveryEngineSearch implements VertexSearchAdapter<ProductSearch> {
|
|
5
|
-
private config;
|
|
6
|
-
private parentEngine;
|
|
7
|
-
private parentDataStore;
|
|
8
|
-
private servingConfig;
|
|
9
|
-
private client;
|
|
10
|
-
constructor(configuration: VertexConfig);
|
|
11
|
-
save(data: Product): void;
|
|
12
|
-
query(term: string, total: number, gender?: string): Promise<ProductSearch[]>;
|
|
13
|
-
get(id: string): Promise<any>;
|
|
14
|
-
create(product: Product): Promise<void>;
|
|
15
|
-
update(id: string, product: Product): Promise<void>;
|
|
16
|
-
delete(id: string): Promise<void>;
|
|
17
|
-
private productMapper;
|
|
18
|
-
private resultProductMapper;
|
|
19
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './vertex-
|
|
1
|
+
export * from './vertex-ai-search.adapter';
|
|
2
|
+
export * from './vertex-axios.adapter';
|
package/src/infra/vertex-ai/adapters/{vertex-ai-search-adapter.d.ts → vertex-ai-search.adapter.d.ts}
RENAMED
|
@@ -3,7 +3,7 @@ import { ProductSearch } from '../types';
|
|
|
3
3
|
export interface VertexSearchAdapter<T> {
|
|
4
4
|
query(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
|
|
5
5
|
get(id: string): Promise<T>;
|
|
6
|
-
save(data: Product): any
|
|
7
|
-
update(id: string, data: Product): any
|
|
6
|
+
save(data: Product): Promise<any>;
|
|
7
|
+
update(id: string, data: Product): Promise<any>;
|
|
8
8
|
delete(id: string): Promise<void>;
|
|
9
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): Promise<any>;
|
|
12
|
+
update(id: string, data: Product): Promise<any>;
|
|
13
|
+
delete(id: string): Promise<void>;
|
|
14
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { ProductSearchIndex } from '../../../domain';
|
|
1
2
|
import { ProductHasuraGraphQL } from '../../hasura-graphql';
|
|
2
3
|
import { VertexSearchAdapter } from '../adapters';
|
|
3
4
|
import { ProductSearch } from '../types';
|
|
4
|
-
export declare class ProductsVertexSearch {
|
|
5
|
+
export declare class ProductsVertexSearch implements ProductSearchIndex {
|
|
5
6
|
private readonly adapter;
|
|
6
7
|
constructor(adapter: VertexSearchAdapter<ProductSearch>);
|
|
7
8
|
getById(id: string): Promise<ProductSearch>;
|
|
8
|
-
search(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
|
|
9
|
+
search<ProductSearch>(searchTerm: string, total: number, gender?: String): Promise<ProductSearch[]>;
|
|
9
10
|
save(product: ProductHasuraGraphQL): Promise<void>;
|
|
10
11
|
update(product: ProductHasuraGraphQL): Promise<void>;
|
|
11
12
|
delete(id: string): Promise<void>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type VertexConfig = {
|
|
2
|
-
apiEndpoint: string;
|
|
3
|
-
credentials: {
|
|
4
|
-
type: string;
|
|
5
|
-
project_id: string;
|
|
6
|
-
private_key_id: string;
|
|
7
|
-
private_key: string;
|
|
8
|
-
client_email: string;
|
|
9
|
-
client_id: string;
|
|
10
|
-
auth_uri: string;
|
|
11
|
-
token_uri: string;
|
|
12
|
-
auth_provider_x509_cert_url: string;
|
|
13
|
-
client_x509_cert_url: string;
|
|
14
|
-
apiKey: string;
|
|
15
|
-
authDomain: string;
|
|
16
|
-
};
|
|
17
|
-
projectId: string;
|
|
18
|
-
location: string;
|
|
19
|
-
dataStoreId: string;
|
|
20
|
-
collectionId: string;
|
|
21
|
-
engine: string;
|
|
22
|
-
servingConfigId: string;
|
|
23
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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 {};
|