@infrab4a/connect 4.4.2-beta.1 → 4.7.0-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 +121 -6
- package/index.esm.js +120 -7
- package/package.json +1 -1
- package/src/domain/catalog/models/index.d.ts +1 -0
- package/src/domain/catalog/models/product-stock-notification.d.ts +9 -0
- package/src/domain/catalog/repositories/index.d.ts +1 -0
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +5 -0
- package/src/domain/catalog/repositories/product.repository.d.ts +13 -0
- package/src/domain/generic/repository/enums/where.enum.d.ts +2 -1
- package/src/domain/generic/repository/types/repository-find-filters.type.d.ts +2 -0
- package/src/domain/shopping/models/line-item.d.ts +0 -2
- package/src/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +3 -1
- package/src/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +4 -1
- package/src/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +2 -0
- package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +11 -0
package/index.cjs.js
CHANGED
|
@@ -220,6 +220,12 @@ class ProductReviews extends BaseModel {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
class ProductStockNotification extends BaseModel {
|
|
224
|
+
static get identifiersFields() {
|
|
225
|
+
return ['id'];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
223
229
|
class Variant extends BaseModel {
|
|
224
230
|
static get identifiersFields() {
|
|
225
231
|
return ['id', 'productId'];
|
|
@@ -256,6 +262,7 @@ exports.Where = void 0;
|
|
|
256
262
|
Where["NOTLIKE"] = "not like";
|
|
257
263
|
Where["ISNULL"] = "is null";
|
|
258
264
|
Where["ISNOTNULL"] = "is not null";
|
|
265
|
+
Where["IREGEX"] = "iregex";
|
|
259
266
|
})(exports.Where || (exports.Where = {}));
|
|
260
267
|
|
|
261
268
|
exports.UpdateOptionActions = void 0;
|
|
@@ -2248,9 +2255,6 @@ class UpdateUserImage {
|
|
|
2248
2255
|
}
|
|
2249
2256
|
|
|
2250
2257
|
class LineItem extends Product {
|
|
2251
|
-
get pricePaidWithDiscount() {
|
|
2252
|
-
return this.pricePaid - this.discount;
|
|
2253
|
-
}
|
|
2254
2258
|
}
|
|
2255
2259
|
|
|
2256
2260
|
class ShippingMethod extends BaseModel {
|
|
@@ -3341,6 +3345,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3341
3345
|
});
|
|
3342
3346
|
this.reviews = {};
|
|
3343
3347
|
}
|
|
3348
|
+
fetchProductReviews(filters) {
|
|
3349
|
+
throw new Error('Method not implemented.');
|
|
3350
|
+
}
|
|
3344
3351
|
async getBySlug(slug) {
|
|
3345
3352
|
var _a;
|
|
3346
3353
|
const result = await this.find({
|
|
@@ -3382,6 +3389,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3382
3389
|
findCatalog(params) {
|
|
3383
3390
|
return this.find(params);
|
|
3384
3391
|
}
|
|
3392
|
+
async fetchPaginatedReviews() {
|
|
3393
|
+
return Promise.resolve([]);
|
|
3394
|
+
}
|
|
3385
3395
|
}
|
|
3386
3396
|
|
|
3387
3397
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
@@ -3836,11 +3846,14 @@ var HasuraGraphQLWhere;
|
|
|
3836
3846
|
HasuraGraphQLWhere["LT"] = "_lt";
|
|
3837
3847
|
HasuraGraphQLWhere["LTE"] = "_lte";
|
|
3838
3848
|
HasuraGraphQLWhere["LIKE"] = "_like";
|
|
3849
|
+
HasuraGraphQLWhere["ILIKE"] = "_ilike";
|
|
3839
3850
|
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
3840
3851
|
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
3841
3852
|
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
3842
3853
|
HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
|
|
3843
3854
|
HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
|
|
3855
|
+
HasuraGraphQLWhere["IREGEX"] = "_iregex";
|
|
3856
|
+
HasuraGraphQLWhere["REGEX"] = "_regex";
|
|
3844
3857
|
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
3845
3858
|
|
|
3846
3859
|
var HasuraGraphQLColumnType;
|
|
@@ -3871,9 +3884,47 @@ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
|
3871
3884
|
: (value) => filter.operator === exports.Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
|
|
3872
3885
|
? `%${value}%`
|
|
3873
3886
|
: value;
|
|
3874
|
-
|
|
3887
|
+
const converterResult = Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
|
|
3875
3888
|
? filter.value.map((fieldValue) => converter(fieldValue))
|
|
3876
3889
|
: converter(filter.value);
|
|
3890
|
+
const newValue = filter.ignoreCase && !filter.ignoreAccent && !Array.isArray(filter.value) && converterResult.indexOf('%') < 0
|
|
3891
|
+
? `%${converterResult}%`
|
|
3892
|
+
: converterResult;
|
|
3893
|
+
return filter.ignoreAccent && !Array.isArray(filter.value)
|
|
3894
|
+
? FilterOptionHelper.buildInsensitiveSentence(newValue)
|
|
3895
|
+
: newValue;
|
|
3896
|
+
};
|
|
3897
|
+
FilterOptionHelper.buildInsensitiveSentence = (value) => {
|
|
3898
|
+
const valueWithoutAccents = FilterOptionHelper.removeAccents(value);
|
|
3899
|
+
let result = '';
|
|
3900
|
+
for (const char of valueWithoutAccents) {
|
|
3901
|
+
const allCharOptions = [];
|
|
3902
|
+
if (['a', 'e', 'i', 'o', 'u', 'c', 'A', 'E', 'I', 'O', 'U', 'C'].includes(char)) {
|
|
3903
|
+
const charOptions = {
|
|
3904
|
+
a: ['á', 'â', 'ã', 'à', 'a'],
|
|
3905
|
+
e: ['é', 'ê', 'ẽ', 'è', 'e'],
|
|
3906
|
+
i: ['í', 'î', 'ĩ', 'ì', 'i'],
|
|
3907
|
+
o: ['ó', 'ô', 'õ', 'ò', 'o'],
|
|
3908
|
+
u: ['ú', 'û', 'ũ', 'ù', 'u'],
|
|
3909
|
+
c: ['ç', 'c'],
|
|
3910
|
+
A: ['Á', 'Â', 'Ã', 'À', 'A'],
|
|
3911
|
+
E: ['É', 'Ê', 'Ẽ', 'È', 'E'],
|
|
3912
|
+
I: ['Í', 'Î', 'Ĩ', 'Ì', 'I'],
|
|
3913
|
+
O: ['Ó', 'Ô', 'Õ', 'Ò', 'O'],
|
|
3914
|
+
U: ['Ú', 'Û', 'Ũ', 'Ù', 'U'],
|
|
3915
|
+
C: ['Ç', 'C'],
|
|
3916
|
+
};
|
|
3917
|
+
allCharOptions.push(...charOptions[char]);
|
|
3918
|
+
result += `[${allCharOptions.join('')}]`;
|
|
3919
|
+
}
|
|
3920
|
+
else {
|
|
3921
|
+
result += char;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
return result;
|
|
3925
|
+
};
|
|
3926
|
+
FilterOptionHelper.removeAccents = (text) => {
|
|
3927
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
3877
3928
|
};
|
|
3878
3929
|
|
|
3879
3930
|
class BindFilterQueryHelper {
|
|
@@ -3917,8 +3968,14 @@ BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
|
3917
3968
|
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3918
3969
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
3919
3970
|
? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
|
|
3920
|
-
:
|
|
3921
|
-
|
|
3971
|
+
: options.operator === exports.Where.LIKE && options.ignoreCase && options.ignoreAccent
|
|
3972
|
+
? HasuraGraphQLWhere.IREGEX
|
|
3973
|
+
: options.operator === exports.Where.LIKE && options.ignoreAccent
|
|
3974
|
+
? HasuraGraphQLWhere.REGEX
|
|
3975
|
+
: options.operator === exports.Where.LIKE && options.ignoreCase
|
|
3976
|
+
? HasuraGraphQLWhere.ILIKE
|
|
3977
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3978
|
+
Object.keys(exports.Where).find((operator) => exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
3922
3979
|
: HasuraGraphQLWhere.EQUALS;
|
|
3923
3980
|
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === exports.Where.IN
|
|
3924
3981
|
? HasuraGraphQLWhere.JSON_CONTAINS
|
|
@@ -5331,6 +5388,30 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5331
5388
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
5332
5389
|
return product;
|
|
5333
5390
|
}
|
|
5391
|
+
async fetchProductReviews() {
|
|
5392
|
+
let data = [];
|
|
5393
|
+
let count = 0;
|
|
5394
|
+
let offset = 0;
|
|
5395
|
+
const limit = 500;
|
|
5396
|
+
do {
|
|
5397
|
+
const result = await super.find(Object.assign({ fields: ['id', 'name', 'sku', 'reviews'] }, ({
|
|
5398
|
+
limits: {
|
|
5399
|
+
offset,
|
|
5400
|
+
limit,
|
|
5401
|
+
},
|
|
5402
|
+
})));
|
|
5403
|
+
data = data.concat(result.data);
|
|
5404
|
+
count = result.data.length;
|
|
5405
|
+
offset += limit;
|
|
5406
|
+
} while (count === limit);
|
|
5407
|
+
return data.reduce((reviews, product) => [
|
|
5408
|
+
...reviews,
|
|
5409
|
+
...product.reviews.map((review) => (Object.assign(Object.assign({}, review), { reviewStatus: this.getReviewStatus(review), productId: product.id, productName: product.name, productSku: product.sku }))),
|
|
5410
|
+
], []);
|
|
5411
|
+
}
|
|
5412
|
+
getReviewStatus(review) {
|
|
5413
|
+
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5414
|
+
}
|
|
5334
5415
|
async fetchReviews(status) {
|
|
5335
5416
|
const reviewsExpression = {
|
|
5336
5417
|
status: status === 'pending'
|
|
@@ -5569,6 +5650,38 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5569
5650
|
}
|
|
5570
5651
|
}
|
|
5571
5652
|
|
|
5653
|
+
class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5654
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5655
|
+
super({
|
|
5656
|
+
tableName: 'product_stock_notification',
|
|
5657
|
+
model: ProductStockNotification,
|
|
5658
|
+
endpoint,
|
|
5659
|
+
authOptions,
|
|
5660
|
+
interceptors,
|
|
5661
|
+
fields: [
|
|
5662
|
+
'id',
|
|
5663
|
+
{ productId: { columnName: 'product_id' } },
|
|
5664
|
+
'email',
|
|
5665
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
5666
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
5667
|
+
],
|
|
5668
|
+
});
|
|
5669
|
+
}
|
|
5670
|
+
async addCustomerEmail(productId, email) {
|
|
5671
|
+
const notification = await this.find({
|
|
5672
|
+
filters: {
|
|
5673
|
+
productId,
|
|
5674
|
+
email,
|
|
5675
|
+
},
|
|
5676
|
+
}).then((data) => data.data.shift());
|
|
5677
|
+
if (!notification)
|
|
5678
|
+
this.create({
|
|
5679
|
+
productId,
|
|
5680
|
+
email,
|
|
5681
|
+
});
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5684
|
+
|
|
5572
5685
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5573
5686
|
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5574
5687
|
super({
|
|
@@ -6088,6 +6201,8 @@ exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
|
|
|
6088
6201
|
exports.ProductHasuraGraphQLRepository = ProductHasuraGraphQLRepository;
|
|
6089
6202
|
exports.ProductReviews = ProductReviews;
|
|
6090
6203
|
exports.ProductReviewsHasuraGraphQLRepository = ProductReviewsHasuraGraphQLRepository;
|
|
6204
|
+
exports.ProductStockNotification = ProductStockNotification;
|
|
6205
|
+
exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
|
|
6091
6206
|
exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
|
|
6092
6207
|
exports.ProductsIndex = ProductsIndex;
|
|
6093
6208
|
exports.RecoveryPassword = RecoveryPassword;
|
package/index.esm.js
CHANGED
|
@@ -196,6 +196,12 @@ class ProductReviews extends BaseModel {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
class ProductStockNotification extends BaseModel {
|
|
200
|
+
static get identifiersFields() {
|
|
201
|
+
return ['id'];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
199
205
|
class Variant extends BaseModel {
|
|
200
206
|
static get identifiersFields() {
|
|
201
207
|
return ['id', 'productId'];
|
|
@@ -232,6 +238,7 @@ var Where;
|
|
|
232
238
|
Where["NOTLIKE"] = "not like";
|
|
233
239
|
Where["ISNULL"] = "is null";
|
|
234
240
|
Where["ISNOTNULL"] = "is not null";
|
|
241
|
+
Where["IREGEX"] = "iregex";
|
|
235
242
|
})(Where || (Where = {}));
|
|
236
243
|
|
|
237
244
|
var UpdateOptionActions;
|
|
@@ -2224,9 +2231,6 @@ class UpdateUserImage {
|
|
|
2224
2231
|
}
|
|
2225
2232
|
|
|
2226
2233
|
class LineItem extends Product {
|
|
2227
|
-
get pricePaidWithDiscount() {
|
|
2228
|
-
return this.pricePaid - this.discount;
|
|
2229
|
-
}
|
|
2230
2234
|
}
|
|
2231
2235
|
|
|
2232
2236
|
class ShippingMethod extends BaseModel {
|
|
@@ -3317,6 +3321,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3317
3321
|
});
|
|
3318
3322
|
this.reviews = {};
|
|
3319
3323
|
}
|
|
3324
|
+
fetchProductReviews(filters) {
|
|
3325
|
+
throw new Error('Method not implemented.');
|
|
3326
|
+
}
|
|
3320
3327
|
async getBySlug(slug) {
|
|
3321
3328
|
var _a;
|
|
3322
3329
|
const result = await this.find({
|
|
@@ -3358,6 +3365,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3358
3365
|
findCatalog(params) {
|
|
3359
3366
|
return this.find(params);
|
|
3360
3367
|
}
|
|
3368
|
+
async fetchPaginatedReviews() {
|
|
3369
|
+
return Promise.resolve([]);
|
|
3370
|
+
}
|
|
3361
3371
|
}
|
|
3362
3372
|
|
|
3363
3373
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
@@ -3812,11 +3822,14 @@ var HasuraGraphQLWhere;
|
|
|
3812
3822
|
HasuraGraphQLWhere["LT"] = "_lt";
|
|
3813
3823
|
HasuraGraphQLWhere["LTE"] = "_lte";
|
|
3814
3824
|
HasuraGraphQLWhere["LIKE"] = "_like";
|
|
3825
|
+
HasuraGraphQLWhere["ILIKE"] = "_ilike";
|
|
3815
3826
|
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
3816
3827
|
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
3817
3828
|
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
3818
3829
|
HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
|
|
3819
3830
|
HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
|
|
3831
|
+
HasuraGraphQLWhere["IREGEX"] = "_iregex";
|
|
3832
|
+
HasuraGraphQLWhere["REGEX"] = "_regex";
|
|
3820
3833
|
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
3821
3834
|
|
|
3822
3835
|
var HasuraGraphQLColumnType;
|
|
@@ -3847,9 +3860,47 @@ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
|
3847
3860
|
: (value) => filter.operator === Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
|
|
3848
3861
|
? `%${value}%`
|
|
3849
3862
|
: value;
|
|
3850
|
-
|
|
3863
|
+
const converterResult = Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
|
|
3851
3864
|
? filter.value.map((fieldValue) => converter(fieldValue))
|
|
3852
3865
|
: converter(filter.value);
|
|
3866
|
+
const newValue = filter.ignoreCase && !filter.ignoreAccent && !Array.isArray(filter.value) && converterResult.indexOf('%') < 0
|
|
3867
|
+
? `%${converterResult}%`
|
|
3868
|
+
: converterResult;
|
|
3869
|
+
return filter.ignoreAccent && !Array.isArray(filter.value)
|
|
3870
|
+
? FilterOptionHelper.buildInsensitiveSentence(newValue)
|
|
3871
|
+
: newValue;
|
|
3872
|
+
};
|
|
3873
|
+
FilterOptionHelper.buildInsensitiveSentence = (value) => {
|
|
3874
|
+
const valueWithoutAccents = FilterOptionHelper.removeAccents(value);
|
|
3875
|
+
let result = '';
|
|
3876
|
+
for (const char of valueWithoutAccents) {
|
|
3877
|
+
const allCharOptions = [];
|
|
3878
|
+
if (['a', 'e', 'i', 'o', 'u', 'c', 'A', 'E', 'I', 'O', 'U', 'C'].includes(char)) {
|
|
3879
|
+
const charOptions = {
|
|
3880
|
+
a: ['á', 'â', 'ã', 'à', 'a'],
|
|
3881
|
+
e: ['é', 'ê', 'ẽ', 'è', 'e'],
|
|
3882
|
+
i: ['í', 'î', 'ĩ', 'ì', 'i'],
|
|
3883
|
+
o: ['ó', 'ô', 'õ', 'ò', 'o'],
|
|
3884
|
+
u: ['ú', 'û', 'ũ', 'ù', 'u'],
|
|
3885
|
+
c: ['ç', 'c'],
|
|
3886
|
+
A: ['Á', 'Â', 'Ã', 'À', 'A'],
|
|
3887
|
+
E: ['É', 'Ê', 'Ẽ', 'È', 'E'],
|
|
3888
|
+
I: ['Í', 'Î', 'Ĩ', 'Ì', 'I'],
|
|
3889
|
+
O: ['Ó', 'Ô', 'Õ', 'Ò', 'O'],
|
|
3890
|
+
U: ['Ú', 'Û', 'Ũ', 'Ù', 'U'],
|
|
3891
|
+
C: ['Ç', 'C'],
|
|
3892
|
+
};
|
|
3893
|
+
allCharOptions.push(...charOptions[char]);
|
|
3894
|
+
result += `[${allCharOptions.join('')}]`;
|
|
3895
|
+
}
|
|
3896
|
+
else {
|
|
3897
|
+
result += char;
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
return result;
|
|
3901
|
+
};
|
|
3902
|
+
FilterOptionHelper.removeAccents = (text) => {
|
|
3903
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
3853
3904
|
};
|
|
3854
3905
|
|
|
3855
3906
|
class BindFilterQueryHelper {
|
|
@@ -3893,8 +3944,14 @@ BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
|
3893
3944
|
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3894
3945
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
3895
3946
|
? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
|
|
3896
|
-
:
|
|
3897
|
-
|
|
3947
|
+
: options.operator === Where.LIKE && options.ignoreCase && options.ignoreAccent
|
|
3948
|
+
? HasuraGraphQLWhere.IREGEX
|
|
3949
|
+
: options.operator === Where.LIKE && options.ignoreAccent
|
|
3950
|
+
? HasuraGraphQLWhere.REGEX
|
|
3951
|
+
: options.operator === Where.LIKE && options.ignoreCase
|
|
3952
|
+
? HasuraGraphQLWhere.ILIKE
|
|
3953
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3954
|
+
Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
3898
3955
|
: HasuraGraphQLWhere.EQUALS;
|
|
3899
3956
|
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
|
|
3900
3957
|
? HasuraGraphQLWhere.JSON_CONTAINS
|
|
@@ -5307,6 +5364,30 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5307
5364
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
5308
5365
|
return product;
|
|
5309
5366
|
}
|
|
5367
|
+
async fetchProductReviews() {
|
|
5368
|
+
let data = [];
|
|
5369
|
+
let count = 0;
|
|
5370
|
+
let offset = 0;
|
|
5371
|
+
const limit = 500;
|
|
5372
|
+
do {
|
|
5373
|
+
const result = await super.find(Object.assign({ fields: ['id', 'name', 'sku', 'reviews'] }, ({
|
|
5374
|
+
limits: {
|
|
5375
|
+
offset,
|
|
5376
|
+
limit,
|
|
5377
|
+
},
|
|
5378
|
+
})));
|
|
5379
|
+
data = data.concat(result.data);
|
|
5380
|
+
count = result.data.length;
|
|
5381
|
+
offset += limit;
|
|
5382
|
+
} while (count === limit);
|
|
5383
|
+
return data.reduce((reviews, product) => [
|
|
5384
|
+
...reviews,
|
|
5385
|
+
...product.reviews.map((review) => (Object.assign(Object.assign({}, review), { reviewStatus: this.getReviewStatus(review), productId: product.id, productName: product.name, productSku: product.sku }))),
|
|
5386
|
+
], []);
|
|
5387
|
+
}
|
|
5388
|
+
getReviewStatus(review) {
|
|
5389
|
+
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5390
|
+
}
|
|
5310
5391
|
async fetchReviews(status) {
|
|
5311
5392
|
const reviewsExpression = {
|
|
5312
5393
|
status: status === 'pending'
|
|
@@ -5545,6 +5626,38 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5545
5626
|
}
|
|
5546
5627
|
}
|
|
5547
5628
|
|
|
5629
|
+
class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5630
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5631
|
+
super({
|
|
5632
|
+
tableName: 'product_stock_notification',
|
|
5633
|
+
model: ProductStockNotification,
|
|
5634
|
+
endpoint,
|
|
5635
|
+
authOptions,
|
|
5636
|
+
interceptors,
|
|
5637
|
+
fields: [
|
|
5638
|
+
'id',
|
|
5639
|
+
{ productId: { columnName: 'product_id' } },
|
|
5640
|
+
'email',
|
|
5641
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
5642
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
5643
|
+
],
|
|
5644
|
+
});
|
|
5645
|
+
}
|
|
5646
|
+
async addCustomerEmail(productId, email) {
|
|
5647
|
+
const notification = await this.find({
|
|
5648
|
+
filters: {
|
|
5649
|
+
productId,
|
|
5650
|
+
email,
|
|
5651
|
+
},
|
|
5652
|
+
}).then((data) => data.data.shift());
|
|
5653
|
+
if (!notification)
|
|
5654
|
+
this.create({
|
|
5655
|
+
productId,
|
|
5656
|
+
email,
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5548
5661
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5549
5662
|
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5550
5663
|
super({
|
|
@@ -5881,4 +5994,4 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5881
5994
|
}
|
|
5882
5995
|
}
|
|
5883
5996
|
|
|
5884
|
-
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, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, 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, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
5997
|
+
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, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, 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, 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
|
@@ -7,6 +7,7 @@ export * from './filter-option';
|
|
|
7
7
|
export * from './kit-product';
|
|
8
8
|
export * from './product';
|
|
9
9
|
export * from './product-reviews';
|
|
10
|
+
export * from './product-stock-notification';
|
|
10
11
|
export * from './types';
|
|
11
12
|
export * from './variant';
|
|
12
13
|
export * from './wishlist';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseModel, GenericIdentifier } from '../../generic/model';
|
|
2
|
+
export declare class ProductStockNotification extends BaseModel<ProductStockNotification> {
|
|
3
|
+
id: number;
|
|
4
|
+
productId: string;
|
|
5
|
+
email: string;
|
|
6
|
+
createdAt?: Date;
|
|
7
|
+
updatedAt?: Date;
|
|
8
|
+
static get identifiersFields(): GenericIdentifier[];
|
|
9
|
+
}
|
|
@@ -4,6 +4,7 @@ export * from './category.repository';
|
|
|
4
4
|
export * from './filter-option.repository';
|
|
5
5
|
export * from './filter.repository';
|
|
6
6
|
export * from './product-reviews.repository';
|
|
7
|
+
export * from './product-stock-notification.repository';
|
|
7
8
|
export * from './product.repository';
|
|
8
9
|
export * from './subscription-product.repository';
|
|
9
10
|
export * from './variant.repository';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CrudRepository } from '../../generic/repository/crud.repository';
|
|
2
|
+
import { ProductStockNotification } from '../models';
|
|
3
|
+
export interface ProductStockNotificationRepository extends CrudRepository<ProductStockNotification> {
|
|
4
|
+
addCustomerEmail(productId: string, email: string): Promise<void>;
|
|
5
|
+
}
|
|
@@ -6,10 +6,23 @@ export type ReviewWithProductData = ProductReview & {
|
|
|
6
6
|
productId: string;
|
|
7
7
|
productName: string;
|
|
8
8
|
productSku: string;
|
|
9
|
+
reviewStatus?: 'pending' | 'approved' | 'rejected';
|
|
10
|
+
};
|
|
11
|
+
export type PaginatedReviewFilters = {
|
|
12
|
+
sku?: string;
|
|
13
|
+
status: ReviewStatusParams;
|
|
14
|
+
email?: string;
|
|
15
|
+
rate?: number;
|
|
16
|
+
period?: {
|
|
17
|
+
start: Date;
|
|
18
|
+
end: Date;
|
|
19
|
+
};
|
|
20
|
+
limit?: number;
|
|
9
21
|
};
|
|
10
22
|
export interface ProductRepository extends CrudRepository<Product> {
|
|
11
23
|
getBySlug(slug: string): Promise<Product>;
|
|
12
24
|
fetchReviews(status: ReviewStatusParams): Promise<ReviewWithProductData[]>;
|
|
25
|
+
fetchProductReviews(filters: PaginatedReviewFilters): Promise<ReviewWithProductData[]>;
|
|
13
26
|
cleanShoppingCountFromIds(ids: string[]): Promise<any>;
|
|
14
27
|
findCatalog(params: FindRepositoryParams<Product>, mainGender?: Extract<ProductGender, 'female' | 'male' | 'unisex'>): Promise<RepositoryFindResult<Product>>;
|
|
15
28
|
}
|
|
@@ -5,6 +5,8 @@ import { Where } from '../enums/where.enum';
|
|
|
5
5
|
export type RepositoryFindFieltersOptions<Model, FieldName extends keyof Model> = {
|
|
6
6
|
operator: Where;
|
|
7
7
|
value?: PropType<Model, FieldName> | PropType<Model, FieldName>[];
|
|
8
|
+
ignoreCase?: boolean;
|
|
9
|
+
ignoreAccent?: boolean;
|
|
8
10
|
};
|
|
9
11
|
export type RepositoryFindField<Model, FieldName extends keyof Model> = RepositoryFindFieltersOptions<Model, FieldName> | RepositoryFindFieltersOptions<Model, FieldName>[] | Partial<PropType<Model, FieldName>>;
|
|
10
12
|
export type NestedRepositoryFindFieltersOptions<Model> = {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { FindRepositoryParams, Product, ProductRepository, RepositoryFindResult, ReviewStatusParams, ReviewWithProductData } from '../../../../../domain';
|
|
1
|
+
import { FindRepositoryParams, PaginatedReviewFilters, Product, ProductRepository, RepositoryFindResult, ReviewStatusParams, ReviewWithProductData } from '../../../../../domain';
|
|
2
2
|
import { FirestoreConstructorParams } from '../../mixins';
|
|
3
3
|
declare const ProductFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Product> & import("../../../../../domain").CrudRepository<Product, import("../../../../../domain").CrudParams<Product>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Product>, ...any[]]>;
|
|
4
4
|
export declare class ProductFirestoreRepository extends ProductFirestoreRepository_base implements ProductRepository {
|
|
5
5
|
private reviews;
|
|
6
6
|
constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Product>, 'firestore' | 'interceptors'>);
|
|
7
|
+
fetchProductReviews(filters: PaginatedReviewFilters): Promise<ReviewWithProductData[]>;
|
|
7
8
|
getBySlug(slug: string): Promise<Product>;
|
|
8
9
|
fetchReviews(status: ReviewStatusParams): Promise<ReviewWithProductData[]>;
|
|
9
10
|
cleanShoppingCountFromIds(): Promise<void>;
|
|
10
11
|
findCatalog(params: FindRepositoryParams<Product>): Promise<RepositoryFindResult<Product>>;
|
|
12
|
+
fetchPaginatedReviews(): Promise<ReviewWithProductData[]>;
|
|
11
13
|
}
|
|
12
14
|
export {};
|
|
@@ -7,9 +7,12 @@ export declare enum HasuraGraphQLWhere {
|
|
|
7
7
|
LT = "_lt",
|
|
8
8
|
LTE = "_lte",
|
|
9
9
|
LIKE = "_like",
|
|
10
|
+
ILIKE = "_ilike",
|
|
10
11
|
NOTLIKE = "_nlike",
|
|
11
12
|
ISNULL = "_is_null",
|
|
12
13
|
ISNOTNULL = "_is_null",
|
|
13
14
|
JSON_CONTAINS = "_contains",
|
|
14
|
-
JSON_HAS_KEYS_ANY = "_has_keys_any"
|
|
15
|
+
JSON_HAS_KEYS_ANY = "_has_keys_any",
|
|
16
|
+
IREGEX = "_iregex",
|
|
17
|
+
REGEX = "_regex"
|
|
15
18
|
}
|
|
@@ -5,4 +5,6 @@ export declare class FilterOptionHelper {
|
|
|
5
5
|
identifiersFields: any[];
|
|
6
6
|
}, any>>(filter: any) => filter is RepositoryFindFieltersOptions<Model, any>;
|
|
7
7
|
static GetValueFromFilter: <Model extends ModelBaseStructure<Model, Model["identifiersFields"][number]>>(filter: RepositoryFindFieltersOptions<Model, any>, fieldOption: ColumnOptions<any, any>) => any;
|
|
8
|
+
private static buildInsensitiveSentence;
|
|
9
|
+
private static removeAccents;
|
|
8
10
|
}
|
|
@@ -5,5 +5,6 @@ export * from './filter-hasura-graphql.repository';
|
|
|
5
5
|
export * from './filter-option-hasura-graphql.repository';
|
|
6
6
|
export * from './product-hasura-graphql.repository';
|
|
7
7
|
export * from './product-review-hasura-graphql.repository';
|
|
8
|
+
export * from './product-stock-notification-hasura-graphql.repository';
|
|
8
9
|
export * from './variant-hasura-graphql.repository';
|
|
9
10
|
export * from './wishlist-hasura-graphql.repository';
|
package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class ProductHasuraGraphQLRepository extends ProductHasuraGraphQL
|
|
|
12
12
|
find(params?: FindRepositoryParams<ProductHasuraGraphQL>): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
|
|
13
13
|
getBySlug(slug: string): Promise<ProductHasuraGraphQL>;
|
|
14
14
|
update(params: UpdateRepositoryParams<ProductHasuraGraphQL>): Promise<ProductHasuraGraphQL>;
|
|
15
|
+
fetchProductReviews(): Promise<ReviewWithProductData[]>;
|
|
16
|
+
private getReviewStatus;
|
|
15
17
|
fetchReviews(status: ReviewStatusParams): Promise<ReviewWithProductData[]>;
|
|
16
18
|
findCatalog(params: FindRepositoryParams<ProductHasuraGraphQL>, mainGender?: Extract<ProductGender, 'female' | 'male'>): Promise<RepositoryFindResult<ProductHasuraGraphQL>>;
|
|
17
19
|
private updateCategories;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Filter, ProductStockNotification } from '../../../../domain';
|
|
2
|
+
import { ProductStockNotificationRepository } from '../../../../domain/catalog/repositories';
|
|
3
|
+
import { HasuraConstructorParams } from '../../mixins';
|
|
4
|
+
declare const ProductStockNotificationHasuraGraphQLRepository_base: import("../../../../utils").MixinCtor<import("../..").GraphQLRepository<ProductStockNotification> & import("../../../../domain").CrudRepository<ProductStockNotification, import("../../../../domain").CrudParams<ProductStockNotification>> & import("../../../../domain").UpdateRepository<ProductStockNotification, import("../../../../domain").RepositoryUpdateParams<ProductStockNotification>> & {
|
|
5
|
+
paramsToPlain(params: import("../../../../domain").RepositoryUpdateParams<ProductStockNotification>): Partial<ProductStockNotification>;
|
|
6
|
+
}, [HasuraConstructorParams<ProductStockNotification> & import("../../mixins").CreateConstructorParams & import("../../mixins").DeleteConstructorParams & import("../../mixins").GetConstructorParams & import("../../mixins").UpdateConstructorParams, ...any[]]>;
|
|
7
|
+
export declare class ProductStockNotificationHasuraGraphQLRepository extends ProductStockNotificationHasuraGraphQLRepository_base implements ProductStockNotificationRepository {
|
|
8
|
+
constructor({ endpoint, authOptions, interceptors, }: Pick<HasuraConstructorParams<Filter>, 'endpoint' | 'authOptions' | 'interceptors'>);
|
|
9
|
+
addCustomerEmail(productId: string, email: string): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|