@infrab4a/connect 5.4.0-beta.0 → 5.4.0-beta.10
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 +153 -32
- package/index.esm.js +153 -33
- package/package.json +1 -1
- package/src/domain/catalog/models/product-base.d.ts +1 -0
- package/src/domain/catalog/models/variant.d.ts +0 -2
- package/src/domain/catalog/repositories/index.d.ts +1 -0
- package/src/domain/catalog/repositories/product-catalog.repository.d.ts +17 -0
- package/src/domain/shopping/models/order.d.ts +1 -0
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/hasura-graphql/models/index.d.ts +1 -0
- package/src/infra/hasura-graphql/models/product-catalog-hasura-graphql.d.ts +16 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +13 -5
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +0 -1
package/index.cjs.js
CHANGED
|
@@ -871,11 +871,7 @@ class Variant extends ProductBase {
|
|
|
871
871
|
static get identifiersFields() {
|
|
872
872
|
return ['id', 'productId'];
|
|
873
873
|
}
|
|
874
|
-
}
|
|
875
|
-
tslib.__decorate([
|
|
876
|
-
classTransformer.Type(() => Product),
|
|
877
|
-
tslib.__metadata("design:type", Product)
|
|
878
|
-
], Variant.prototype, "product", void 0);
|
|
874
|
+
}
|
|
879
875
|
|
|
880
876
|
class Product extends ProductBase {
|
|
881
877
|
}
|
|
@@ -3396,8 +3392,6 @@ class HasuraQueryBuilderHelper {
|
|
|
3396
3392
|
class HasuraRequestHelper {
|
|
3397
3393
|
static async fetch(params) {
|
|
3398
3394
|
const { variables, query, endpoint, headers, logger } = params;
|
|
3399
|
-
console.warn('variables', variables);
|
|
3400
|
-
console.warn('query', query);
|
|
3401
3395
|
const request = {
|
|
3402
3396
|
url: endpoint,
|
|
3403
3397
|
method: 'POST',
|
|
@@ -5857,6 +5851,9 @@ tslib.__decorate([
|
|
|
5857
5851
|
tslib.__metadata("design:type", Product)
|
|
5858
5852
|
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
5859
5853
|
|
|
5854
|
+
class ProductCatalogHasuraGraphQL extends Product {
|
|
5855
|
+
}
|
|
5856
|
+
|
|
5860
5857
|
class ProductHasuraGraphQL extends Product {
|
|
5861
5858
|
}
|
|
5862
5859
|
tslib.__decorate([
|
|
@@ -7377,18 +7374,26 @@ const commonFields$1 = [
|
|
|
7377
7374
|
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
7378
7375
|
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
7379
7376
|
{ categoryId: { columnName: 'category_id' } },
|
|
7377
|
+
{
|
|
7378
|
+
category: {
|
|
7379
|
+
columnName: 'category',
|
|
7380
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
7381
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
7382
|
+
},
|
|
7383
|
+
},
|
|
7380
7384
|
'group',
|
|
7381
7385
|
'validity',
|
|
7382
7386
|
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7383
7387
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7384
7388
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7385
7389
|
{ showVariants: { columnName: 'show_variants' } },
|
|
7390
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7386
7391
|
];
|
|
7387
7392
|
class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7388
7393
|
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
7389
7394
|
super({
|
|
7390
7395
|
tableName: 'product_catalog',
|
|
7391
|
-
model:
|
|
7396
|
+
model: ProductCatalogHasuraGraphQL,
|
|
7392
7397
|
endpoint,
|
|
7393
7398
|
authOptions,
|
|
7394
7399
|
interceptors,
|
|
@@ -7396,6 +7401,71 @@ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHa
|
|
|
7396
7401
|
cache,
|
|
7397
7402
|
});
|
|
7398
7403
|
}
|
|
7404
|
+
async get({ id }, options) {
|
|
7405
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7406
|
+
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7407
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7408
|
+
if (cachedData) {
|
|
7409
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7410
|
+
return this.model.toInstance(deserialize(cachedData));
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7413
|
+
const product = await super
|
|
7414
|
+
.find({
|
|
7415
|
+
filters: {
|
|
7416
|
+
id,
|
|
7417
|
+
},
|
|
7418
|
+
limits: {
|
|
7419
|
+
limit: 1,
|
|
7420
|
+
},
|
|
7421
|
+
})
|
|
7422
|
+
.then((res) => res.data.at(0));
|
|
7423
|
+
if (!product)
|
|
7424
|
+
throw new NotFoundError(`Product not found`);
|
|
7425
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7426
|
+
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7427
|
+
await this.cache.cacheAdapter.set({
|
|
7428
|
+
key: cacheKey,
|
|
7429
|
+
data: serialize(product),
|
|
7430
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7431
|
+
});
|
|
7432
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7433
|
+
}
|
|
7434
|
+
return product;
|
|
7435
|
+
}
|
|
7436
|
+
async getByEAN(EAN, options) {
|
|
7437
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7438
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7439
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7440
|
+
if (cachedData) {
|
|
7441
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7442
|
+
return this.model.toInstance(deserialize(cachedData));
|
|
7443
|
+
}
|
|
7444
|
+
}
|
|
7445
|
+
const product = await super
|
|
7446
|
+
.find({
|
|
7447
|
+
filters: {
|
|
7448
|
+
EAN,
|
|
7449
|
+
},
|
|
7450
|
+
limits: {
|
|
7451
|
+
limit: 1,
|
|
7452
|
+
},
|
|
7453
|
+
})
|
|
7454
|
+
.then((res) => res.data.at(0));
|
|
7455
|
+
if (!product)
|
|
7456
|
+
return null;
|
|
7457
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
7458
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7459
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7460
|
+
await this.cache.cacheAdapter.set({
|
|
7461
|
+
key: cacheKey,
|
|
7462
|
+
data: serialize(product),
|
|
7463
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7464
|
+
});
|
|
7465
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7466
|
+
}
|
|
7467
|
+
return product;
|
|
7468
|
+
}
|
|
7399
7469
|
async find(params, optionsParams) {
|
|
7400
7470
|
const { filters, fields, ...options } = params || {};
|
|
7401
7471
|
const bindFields = fields ||
|
|
@@ -7687,6 +7757,7 @@ const commonFields = [
|
|
|
7687
7757
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7688
7758
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7689
7759
|
{ showVariants: { columnName: 'show_variants' } },
|
|
7760
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7690
7761
|
];
|
|
7691
7762
|
const fieldsConfiguration$2 = [
|
|
7692
7763
|
...commonFields,
|
|
@@ -7878,6 +7949,29 @@ const fieldsConfiguration$2 = [
|
|
|
7878
7949
|
},
|
|
7879
7950
|
{ tagsProfile: { columnName: 'tags_profile' } },
|
|
7880
7951
|
{ tagsCollection: { columnName: 'tags_collection' } },
|
|
7952
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7953
|
+
{
|
|
7954
|
+
reviews: {
|
|
7955
|
+
columnName: 'reviews',
|
|
7956
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
7957
|
+
fields: [
|
|
7958
|
+
'id',
|
|
7959
|
+
'shop',
|
|
7960
|
+
'rate',
|
|
7961
|
+
'author',
|
|
7962
|
+
'email',
|
|
7963
|
+
'location',
|
|
7964
|
+
'review',
|
|
7965
|
+
'status',
|
|
7966
|
+
'title',
|
|
7967
|
+
{ personId: { columnName: 'person_id' } },
|
|
7968
|
+
'points',
|
|
7969
|
+
{ orderId: { columnName: 'order_id' } },
|
|
7970
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
7971
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
7972
|
+
],
|
|
7973
|
+
},
|
|
7974
|
+
},
|
|
7881
7975
|
],
|
|
7882
7976
|
},
|
|
7883
7977
|
},
|
|
@@ -7941,10 +8035,14 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7941
8035
|
? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
|
|
7942
8036
|
.data?.[0]
|
|
7943
8037
|
: await super.get(identifiers, options);
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
8038
|
+
if (product.productId)
|
|
8039
|
+
throw new NotFoundError('Product not found, it is a variant');
|
|
8040
|
+
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
|
|
8041
|
+
if (!product.variants?.length) {
|
|
8042
|
+
for (const [index, variant] of product.variants.entries()) {
|
|
8043
|
+
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
7948
8046
|
return product;
|
|
7949
8047
|
}
|
|
7950
8048
|
async find(params, optionsParams) {
|
|
@@ -7962,8 +8060,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7962
8060
|
return super.find({
|
|
7963
8061
|
...options,
|
|
7964
8062
|
filters: { ...filters },
|
|
7965
|
-
// filters: { ...filters, hasVariants: { operator: Where.EQUALS, value: false } },
|
|
7966
|
-
// filters: { ...filters, productId: { operator: Where.ISNULL } },
|
|
7967
8063
|
fields: [
|
|
7968
8064
|
...bindFields,
|
|
7969
8065
|
...(bindFields.includes('price')
|
|
@@ -7988,6 +8084,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7988
8084
|
const result = await this.find({
|
|
7989
8085
|
filters: {
|
|
7990
8086
|
slug,
|
|
8087
|
+
productId: {
|
|
8088
|
+
operator: exports.Where.ISNULL,
|
|
8089
|
+
},
|
|
7991
8090
|
},
|
|
7992
8091
|
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
7993
8092
|
options: {
|
|
@@ -7997,12 +8096,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7997
8096
|
if (!result.data.length)
|
|
7998
8097
|
return null;
|
|
7999
8098
|
const product = result?.data?.shift();
|
|
8000
|
-
if (product.
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
console.warn('entrou');
|
|
8005
|
-
product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
|
|
8099
|
+
if (!product.variants?.length) {
|
|
8100
|
+
for (const [index, variant] of product.variants.entries()) {
|
|
8101
|
+
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8102
|
+
}
|
|
8006
8103
|
}
|
|
8007
8104
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
8008
8105
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
@@ -8016,18 +8113,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8016
8113
|
}
|
|
8017
8114
|
return product;
|
|
8018
8115
|
}
|
|
8019
|
-
async getBySlugVariantData(product) {
|
|
8020
|
-
if (!product.reviews.length && product.rate > 0) {
|
|
8021
|
-
product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
|
|
8022
|
-
}
|
|
8023
|
-
// if (!product.metadata) {
|
|
8024
|
-
// product.metadata = await this.findReviewsByProduct(
|
|
8025
|
-
// (product.productId ? product.productId : product.id) as number,
|
|
8026
|
-
// true,
|
|
8027
|
-
// )
|
|
8028
|
-
// }
|
|
8029
|
-
return product;
|
|
8030
|
-
}
|
|
8031
8116
|
async getByEAN(EAN, options) {
|
|
8032
8117
|
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
8033
8118
|
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
@@ -8235,6 +8320,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8235
8320
|
type: 'product_review_bool_exp',
|
|
8236
8321
|
required: true,
|
|
8237
8322
|
},
|
|
8323
|
+
order_by: {
|
|
8324
|
+
type: '[product_review_order_by]',
|
|
8325
|
+
value: [{ createdAt: 'desc' }],
|
|
8326
|
+
required: true,
|
|
8327
|
+
},
|
|
8238
8328
|
});
|
|
8239
8329
|
const reviews = data?.map((review) => this.bindReviewToModel(review));
|
|
8240
8330
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
|
|
@@ -8653,6 +8743,13 @@ const fieldsConfiguration$1 = [
|
|
|
8653
8743
|
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
8654
8744
|
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
8655
8745
|
{ categoryId: { columnName: 'category_id' } },
|
|
8746
|
+
{
|
|
8747
|
+
category: {
|
|
8748
|
+
columnName: 'category',
|
|
8749
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
8750
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
8751
|
+
},
|
|
8752
|
+
},
|
|
8656
8753
|
{
|
|
8657
8754
|
metadata: {
|
|
8658
8755
|
columnName: 'metadata',
|
|
@@ -8662,6 +8759,29 @@ const fieldsConfiguration$1 = [
|
|
|
8662
8759
|
}),
|
|
8663
8760
|
},
|
|
8664
8761
|
},
|
|
8762
|
+
{
|
|
8763
|
+
reviews: {
|
|
8764
|
+
columnName: 'reviews',
|
|
8765
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
8766
|
+
fields: [
|
|
8767
|
+
'id',
|
|
8768
|
+
'shop',
|
|
8769
|
+
'rate',
|
|
8770
|
+
'author',
|
|
8771
|
+
'email',
|
|
8772
|
+
'location',
|
|
8773
|
+
'review',
|
|
8774
|
+
'status',
|
|
8775
|
+
'title',
|
|
8776
|
+
{ personId: { columnName: 'person_id' } },
|
|
8777
|
+
'points',
|
|
8778
|
+
{ orderId: { columnName: 'order_id' } },
|
|
8779
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
8780
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
8781
|
+
],
|
|
8782
|
+
},
|
|
8783
|
+
},
|
|
8784
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
8665
8785
|
{ createdAt: { columnName: 'created_at' } },
|
|
8666
8786
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
8667
8787
|
];
|
|
@@ -10286,6 +10406,7 @@ exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
|
10286
10406
|
exports.PaymentProviderFactory = PaymentProviderFactory;
|
|
10287
10407
|
exports.PaymentTransaction = PaymentTransaction;
|
|
10288
10408
|
exports.Product = Product;
|
|
10409
|
+
exports.ProductCatalogHasuraGraphQL = ProductCatalogHasuraGraphQL;
|
|
10289
10410
|
exports.ProductCatalogHasuraGraphQLRepository = ProductCatalogHasuraGraphQLRepository;
|
|
10290
10411
|
exports.ProductErrors = ProductErrors;
|
|
10291
10412
|
exports.ProductErrorsHasuraGraphQL = ProductErrorsHasuraGraphQL;
|
package/index.esm.js
CHANGED
|
@@ -847,11 +847,7 @@ class Variant extends ProductBase {
|
|
|
847
847
|
static get identifiersFields() {
|
|
848
848
|
return ['id', 'productId'];
|
|
849
849
|
}
|
|
850
|
-
}
|
|
851
|
-
__decorate([
|
|
852
|
-
Type(() => Product),
|
|
853
|
-
__metadata("design:type", Product)
|
|
854
|
-
], Variant.prototype, "product", void 0);
|
|
850
|
+
}
|
|
855
851
|
|
|
856
852
|
class Product extends ProductBase {
|
|
857
853
|
}
|
|
@@ -3372,8 +3368,6 @@ class HasuraQueryBuilderHelper {
|
|
|
3372
3368
|
class HasuraRequestHelper {
|
|
3373
3369
|
static async fetch(params) {
|
|
3374
3370
|
const { variables, query, endpoint, headers, logger } = params;
|
|
3375
|
-
console.warn('variables', variables);
|
|
3376
|
-
console.warn('query', query);
|
|
3377
3371
|
const request = {
|
|
3378
3372
|
url: endpoint,
|
|
3379
3373
|
method: 'POST',
|
|
@@ -5833,6 +5827,9 @@ __decorate([
|
|
|
5833
5827
|
__metadata("design:type", Product)
|
|
5834
5828
|
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
5835
5829
|
|
|
5830
|
+
class ProductCatalogHasuraGraphQL extends Product {
|
|
5831
|
+
}
|
|
5832
|
+
|
|
5836
5833
|
class ProductHasuraGraphQL extends Product {
|
|
5837
5834
|
}
|
|
5838
5835
|
__decorate([
|
|
@@ -7353,18 +7350,26 @@ const commonFields$1 = [
|
|
|
7353
7350
|
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
7354
7351
|
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
7355
7352
|
{ categoryId: { columnName: 'category_id' } },
|
|
7353
|
+
{
|
|
7354
|
+
category: {
|
|
7355
|
+
columnName: 'category',
|
|
7356
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
7357
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
7358
|
+
},
|
|
7359
|
+
},
|
|
7356
7360
|
'group',
|
|
7357
7361
|
'validity',
|
|
7358
7362
|
{ tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7359
7363
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7360
7364
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7361
7365
|
{ showVariants: { columnName: 'show_variants' } },
|
|
7366
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7362
7367
|
];
|
|
7363
7368
|
class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
7364
7369
|
constructor({ endpoint, authOptions, interceptors, cache, }) {
|
|
7365
7370
|
super({
|
|
7366
7371
|
tableName: 'product_catalog',
|
|
7367
|
-
model:
|
|
7372
|
+
model: ProductCatalogHasuraGraphQL,
|
|
7368
7373
|
endpoint,
|
|
7369
7374
|
authOptions,
|
|
7370
7375
|
interceptors,
|
|
@@ -7372,6 +7377,71 @@ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHa
|
|
|
7372
7377
|
cache,
|
|
7373
7378
|
});
|
|
7374
7379
|
}
|
|
7380
|
+
async get({ id }, options) {
|
|
7381
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7382
|
+
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7383
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7384
|
+
if (cachedData) {
|
|
7385
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7386
|
+
return this.model.toInstance(deserialize(cachedData));
|
|
7387
|
+
}
|
|
7388
|
+
}
|
|
7389
|
+
const product = await super
|
|
7390
|
+
.find({
|
|
7391
|
+
filters: {
|
|
7392
|
+
id,
|
|
7393
|
+
},
|
|
7394
|
+
limits: {
|
|
7395
|
+
limit: 1,
|
|
7396
|
+
},
|
|
7397
|
+
})
|
|
7398
|
+
.then((res) => res.data.at(0));
|
|
7399
|
+
if (!product)
|
|
7400
|
+
throw new NotFoundError(`Product not found`);
|
|
7401
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7402
|
+
const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
|
|
7403
|
+
await this.cache.cacheAdapter.set({
|
|
7404
|
+
key: cacheKey,
|
|
7405
|
+
data: serialize(product),
|
|
7406
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7407
|
+
});
|
|
7408
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7409
|
+
}
|
|
7410
|
+
return product;
|
|
7411
|
+
}
|
|
7412
|
+
async getByEAN(EAN, options) {
|
|
7413
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7414
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7415
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7416
|
+
if (cachedData) {
|
|
7417
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
7418
|
+
return this.model.toInstance(deserialize(cachedData));
|
|
7419
|
+
}
|
|
7420
|
+
}
|
|
7421
|
+
const product = await super
|
|
7422
|
+
.find({
|
|
7423
|
+
filters: {
|
|
7424
|
+
EAN,
|
|
7425
|
+
},
|
|
7426
|
+
limits: {
|
|
7427
|
+
limit: 1,
|
|
7428
|
+
},
|
|
7429
|
+
})
|
|
7430
|
+
.then((res) => res.data.at(0));
|
|
7431
|
+
if (!product)
|
|
7432
|
+
return null;
|
|
7433
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
7434
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7435
|
+
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
7436
|
+
await this.cache.cacheAdapter.set({
|
|
7437
|
+
key: cacheKey,
|
|
7438
|
+
data: serialize(product),
|
|
7439
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7440
|
+
});
|
|
7441
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7442
|
+
}
|
|
7443
|
+
return product;
|
|
7444
|
+
}
|
|
7375
7445
|
async find(params, optionsParams) {
|
|
7376
7446
|
const { filters, fields, ...options } = params || {};
|
|
7377
7447
|
const bindFields = fields ||
|
|
@@ -7663,6 +7733,7 @@ const commonFields = [
|
|
|
7663
7733
|
{ tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
|
|
7664
7734
|
{ daysOfUse: { columnName: 'days_of_use' } },
|
|
7665
7735
|
{ showVariants: { columnName: 'show_variants' } },
|
|
7736
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7666
7737
|
];
|
|
7667
7738
|
const fieldsConfiguration$2 = [
|
|
7668
7739
|
...commonFields,
|
|
@@ -7854,6 +7925,29 @@ const fieldsConfiguration$2 = [
|
|
|
7854
7925
|
},
|
|
7855
7926
|
{ tagsProfile: { columnName: 'tags_profile' } },
|
|
7856
7927
|
{ tagsCollection: { columnName: 'tags_collection' } },
|
|
7928
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
7929
|
+
{
|
|
7930
|
+
reviews: {
|
|
7931
|
+
columnName: 'reviews',
|
|
7932
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
7933
|
+
fields: [
|
|
7934
|
+
'id',
|
|
7935
|
+
'shop',
|
|
7936
|
+
'rate',
|
|
7937
|
+
'author',
|
|
7938
|
+
'email',
|
|
7939
|
+
'location',
|
|
7940
|
+
'review',
|
|
7941
|
+
'status',
|
|
7942
|
+
'title',
|
|
7943
|
+
{ personId: { columnName: 'person_id' } },
|
|
7944
|
+
'points',
|
|
7945
|
+
{ orderId: { columnName: 'order_id' } },
|
|
7946
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
7947
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
7948
|
+
],
|
|
7949
|
+
},
|
|
7950
|
+
},
|
|
7857
7951
|
],
|
|
7858
7952
|
},
|
|
7859
7953
|
},
|
|
@@ -7917,10 +8011,14 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7917
8011
|
? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
|
|
7918
8012
|
.data?.[0]
|
|
7919
8013
|
: await super.get(identifiers, options);
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
8014
|
+
if (product.productId)
|
|
8015
|
+
throw new NotFoundError('Product not found, it is a variant');
|
|
8016
|
+
product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
|
|
8017
|
+
if (!product.variants?.length) {
|
|
8018
|
+
for (const [index, variant] of product.variants.entries()) {
|
|
8019
|
+
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8020
|
+
}
|
|
8021
|
+
}
|
|
7924
8022
|
return product;
|
|
7925
8023
|
}
|
|
7926
8024
|
async find(params, optionsParams) {
|
|
@@ -7938,8 +8036,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7938
8036
|
return super.find({
|
|
7939
8037
|
...options,
|
|
7940
8038
|
filters: { ...filters },
|
|
7941
|
-
// filters: { ...filters, hasVariants: { operator: Where.EQUALS, value: false } },
|
|
7942
|
-
// filters: { ...filters, productId: { operator: Where.ISNULL } },
|
|
7943
8039
|
fields: [
|
|
7944
8040
|
...bindFields,
|
|
7945
8041
|
...(bindFields.includes('price')
|
|
@@ -7964,6 +8060,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7964
8060
|
const result = await this.find({
|
|
7965
8061
|
filters: {
|
|
7966
8062
|
slug,
|
|
8063
|
+
productId: {
|
|
8064
|
+
operator: Where.ISNULL,
|
|
8065
|
+
},
|
|
7967
8066
|
},
|
|
7968
8067
|
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
7969
8068
|
options: {
|
|
@@ -7973,12 +8072,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7973
8072
|
if (!result.data.length)
|
|
7974
8073
|
return null;
|
|
7975
8074
|
const product = result?.data?.shift();
|
|
7976
|
-
if (product.
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
console.warn('entrou');
|
|
7981
|
-
product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
|
|
8075
|
+
if (!product.variants?.length) {
|
|
8076
|
+
for (const [index, variant] of product.variants.entries()) {
|
|
8077
|
+
product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
|
|
8078
|
+
}
|
|
7982
8079
|
}
|
|
7983
8080
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
7984
8081
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
@@ -7992,18 +8089,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7992
8089
|
}
|
|
7993
8090
|
return product;
|
|
7994
8091
|
}
|
|
7995
|
-
async getBySlugVariantData(product) {
|
|
7996
|
-
if (!product.reviews.length && product.rate > 0) {
|
|
7997
|
-
product.reviews = await this.findReviewsByProduct((product.productId ? product.productId : product.id), true);
|
|
7998
|
-
}
|
|
7999
|
-
// if (!product.metadata) {
|
|
8000
|
-
// product.metadata = await this.findReviewsByProduct(
|
|
8001
|
-
// (product.productId ? product.productId : product.id) as number,
|
|
8002
|
-
// true,
|
|
8003
|
-
// )
|
|
8004
|
-
// }
|
|
8005
|
-
return product;
|
|
8006
|
-
}
|
|
8007
8092
|
async getByEAN(EAN, options) {
|
|
8008
8093
|
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
8009
8094
|
const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
|
|
@@ -8211,6 +8296,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
8211
8296
|
type: 'product_review_bool_exp',
|
|
8212
8297
|
required: true,
|
|
8213
8298
|
},
|
|
8299
|
+
order_by: {
|
|
8300
|
+
type: '[product_review_order_by]',
|
|
8301
|
+
value: [{ createdAt: 'desc' }],
|
|
8302
|
+
required: true,
|
|
8303
|
+
},
|
|
8214
8304
|
});
|
|
8215
8305
|
const reviews = data?.map((review) => this.bindReviewToModel(review));
|
|
8216
8306
|
if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
|
|
@@ -8629,6 +8719,13 @@ const fieldsConfiguration$1 = [
|
|
|
8629
8719
|
{ reviewsTotal: { columnName: 'reviews_total' } },
|
|
8630
8720
|
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
8631
8721
|
{ categoryId: { columnName: 'category_id' } },
|
|
8722
|
+
{
|
|
8723
|
+
category: {
|
|
8724
|
+
columnName: 'category',
|
|
8725
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
8726
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
8727
|
+
},
|
|
8728
|
+
},
|
|
8632
8729
|
{
|
|
8633
8730
|
metadata: {
|
|
8634
8731
|
columnName: 'metadata',
|
|
@@ -8638,6 +8735,29 @@ const fieldsConfiguration$1 = [
|
|
|
8638
8735
|
}),
|
|
8639
8736
|
},
|
|
8640
8737
|
},
|
|
8738
|
+
{
|
|
8739
|
+
reviews: {
|
|
8740
|
+
columnName: 'reviews',
|
|
8741
|
+
foreignKeyColumn: { product_id: 'id' },
|
|
8742
|
+
fields: [
|
|
8743
|
+
'id',
|
|
8744
|
+
'shop',
|
|
8745
|
+
'rate',
|
|
8746
|
+
'author',
|
|
8747
|
+
'email',
|
|
8748
|
+
'location',
|
|
8749
|
+
'review',
|
|
8750
|
+
'status',
|
|
8751
|
+
'title',
|
|
8752
|
+
{ personId: { columnName: 'person_id' } },
|
|
8753
|
+
'points',
|
|
8754
|
+
{ orderId: { columnName: 'order_id' } },
|
|
8755
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
8756
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
8757
|
+
],
|
|
8758
|
+
},
|
|
8759
|
+
},
|
|
8760
|
+
{ variantSlug: { columnName: 'variant_slug' } },
|
|
8641
8761
|
{ createdAt: { columnName: 'created_at' } },
|
|
8642
8762
|
{ updatedAt: { columnName: 'updated_at' } },
|
|
8643
8763
|
];
|
|
@@ -10038,4 +10158,4 @@ class ProductsVertexSearch {
|
|
|
10038
10158
|
}
|
|
10039
10159
|
}
|
|
10040
10160
|
|
|
10041
|
-
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
10161
|
+
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Product } from './product';
|
|
2
1
|
import { ProductBase } from './product-base';
|
|
3
2
|
import { VariantGrade } from './types';
|
|
4
3
|
export type ProductVariantIdentifiers = 'id' | 'productId';
|
|
5
4
|
export declare class Variant extends ProductBase<Variant, ProductVariantIdentifiers> {
|
|
6
5
|
productId: string;
|
|
7
6
|
grade?: VariantGrade[];
|
|
8
|
-
product?: Product;
|
|
9
7
|
static get identifiersFields(): ProductVariantIdentifiers[];
|
|
10
8
|
}
|
|
@@ -5,6 +5,7 @@ export * from './category.repository';
|
|
|
5
5
|
export * from './filter-option.repository';
|
|
6
6
|
export * from './filter.repository';
|
|
7
7
|
export * from './group.repository';
|
|
8
|
+
export * from './product-catalog.repository';
|
|
8
9
|
export * from './product-errors.repository';
|
|
9
10
|
export * from './product-reviews.repository';
|
|
10
11
|
export * from './product-stock-notification.repository';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProductHasuraGraphQL } from '../../../infra';
|
|
2
|
+
import { FindRepositoryParams, RepositoryCacheOptions, RepositoryFindResult } from '../../generic';
|
|
3
|
+
import { Product, ProductGender } from '../models';
|
|
4
|
+
export interface ProductCatalogRepository {
|
|
5
|
+
get({ id }: {
|
|
6
|
+
id: string;
|
|
7
|
+
}): Promise<Product>;
|
|
8
|
+
find(params?: FindRepositoryParams<ProductHasuraGraphQL>, optionsParams?: {
|
|
9
|
+
cache?: RepositoryCacheOptions;
|
|
10
|
+
}): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
|
|
11
|
+
getByEAN(EAN: string, options?: {
|
|
12
|
+
cache?: RepositoryCacheOptions;
|
|
13
|
+
}): Promise<Product>;
|
|
14
|
+
findCatalog(params: FindRepositoryParams<Product>, mainGender?: Extract<ProductGender, 'female' | 'male' | 'unisex'>, options?: {
|
|
15
|
+
cache?: RepositoryCacheOptions;
|
|
16
|
+
}): Promise<RepositoryFindResult<Product>>;
|
|
17
|
+
}
|
|
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
|
|
|
5
5
|
export declare const withHelpers: <TMixinBase extends MixinCtor<any, any[]> = MixinCtor<any, any[]>>(MixinBase: MixinCtor<any, any[]> & TMixinBase) => {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
[x: string]: any;
|
|
8
|
-
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T
|
|
8
|
+
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
|
|
9
9
|
isSubCollection<T_1 extends ModelBaseStructure<T_1, T_1["identifiersFields"][number]>, E extends ModelBaseStructure<E, E["identifiersFields"][number]>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
|
|
10
10
|
};
|
|
11
11
|
} & TMixinBase;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './category-hasura-graphql';
|
|
2
2
|
export * from './kit-product-hasura-graphql';
|
|
3
|
+
export * from './product-catalog-hasura-graphql';
|
|
3
4
|
export * from './product-errors-hasura-graphql';
|
|
4
5
|
export * from './product-hasura-graphql';
|
|
5
6
|
export * from './variant-hasura-graphql';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Product } from '../../../domain';
|
|
2
|
+
export declare class ProductCatalogHasuraGraphQL extends Product {
|
|
3
|
+
firestoreId?: string;
|
|
4
|
+
fullPrice?: number;
|
|
5
|
+
subscriberDiscountPercentage?: number;
|
|
6
|
+
subscriberPrice?: number;
|
|
7
|
+
productId?: number;
|
|
8
|
+
differentials?: string;
|
|
9
|
+
whoMustUse?: string;
|
|
10
|
+
howToUse?: string;
|
|
11
|
+
brandDescription?: string;
|
|
12
|
+
categoryId?: number;
|
|
13
|
+
ingredients?: string;
|
|
14
|
+
hasStock?: boolean;
|
|
15
|
+
intGender?: number;
|
|
16
|
+
}
|
package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { FindRepositoryParams, ProductGender, RepositoryCacheOptions, RepositoryFindResult } from '../../../../domain';
|
|
1
|
+
import { FindRepositoryParams, Product, ProductCatalogRepository, ProductGender, RepositoryCacheOptions, RepositoryFindResult } from '../../../../domain';
|
|
2
2
|
import { HasuraConstructorParams } from '../../mixins';
|
|
3
|
-
import { ProductHasuraGraphQL } from '../../models';
|
|
4
|
-
declare const ProductCatalogHasuraGraphQLRepository_base: import("../../../../utils").MixinCtor<import("../../types").GraphQLRepository<
|
|
5
|
-
export declare class ProductCatalogHasuraGraphQLRepository extends ProductCatalogHasuraGraphQLRepository_base {
|
|
6
|
-
constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<
|
|
3
|
+
import { ProductCatalogHasuraGraphQL, ProductHasuraGraphQL } from '../../models';
|
|
4
|
+
declare const ProductCatalogHasuraGraphQLRepository_base: import("../../../../utils").MixinCtor<import("../../types").GraphQLRepository<ProductCatalogHasuraGraphQL> & import("../../../../domain").FindRepository<ProductCatalogHasuraGraphQL, FindRepositoryParams<ProductCatalogHasuraGraphQL>>, any[]>;
|
|
5
|
+
export declare class ProductCatalogHasuraGraphQLRepository extends ProductCatalogHasuraGraphQLRepository_base implements ProductCatalogRepository {
|
|
6
|
+
constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<ProductCatalogHasuraGraphQL>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>);
|
|
7
|
+
get({ id }: {
|
|
8
|
+
id: string;
|
|
9
|
+
}, options?: {
|
|
10
|
+
cache?: RepositoryCacheOptions;
|
|
11
|
+
}): Promise<Product>;
|
|
12
|
+
getByEAN(EAN: string, options?: {
|
|
13
|
+
cache?: RepositoryCacheOptions;
|
|
14
|
+
}): Promise<Product>;
|
|
7
15
|
find(params?: FindRepositoryParams<ProductHasuraGraphQL>, optionsParams?: {
|
|
8
16
|
cache?: RepositoryCacheOptions;
|
|
9
17
|
}): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
|
package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare class ProductHasuraGraphQLRepository extends ProductHasuraGraphQL
|
|
|
15
15
|
getBySlug(slug: string, options?: {
|
|
16
16
|
cache?: RepositoryCacheOptions;
|
|
17
17
|
}): Promise<ProductHasuraGraphQL>;
|
|
18
|
-
private getBySlugVariantData;
|
|
19
18
|
getByEAN(EAN: string, options?: {
|
|
20
19
|
cache?: RepositoryCacheOptions;
|
|
21
20
|
}): Promise<ProductHasuraGraphQL>;
|