@infrab4a/connect 4.9.0-beta.0 → 4.9.0-beta.1
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 +345 -133
- package/index.esm.js +345 -133
- package/package.json +2 -2
- package/src/domain/shopping/models/line-item.d.ts +2 -0
- package/src/infra/firebase/firestore/types/firestore.repository.type.d.ts +2 -0
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +2 -2
package/index.esm.js
CHANGED
|
@@ -1835,9 +1835,6 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
|
|
|
1835
1835
|
return function (...args) {
|
|
1836
1836
|
return new Promise((resolve, reject) => {
|
|
1837
1837
|
const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
|
|
1838
|
-
if (get(options, 'level', '') === 'log') {
|
|
1839
|
-
debug.with('params').log(args);
|
|
1840
|
-
}
|
|
1841
1838
|
return method
|
|
1842
1839
|
.apply(this, args)
|
|
1843
1840
|
.then((result) => {
|
|
@@ -1845,17 +1842,13 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
|
|
|
1845
1842
|
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
1846
1843
|
}
|
|
1847
1844
|
if (get(options, 'level', '') === 'log') {
|
|
1848
|
-
debug.
|
|
1845
|
+
debug.log({ req: args, res: result === undefined ? 'void' : result });
|
|
1849
1846
|
}
|
|
1850
1847
|
return resolve(result);
|
|
1851
1848
|
})
|
|
1852
1849
|
.catch((error) => {
|
|
1853
|
-
debug.error(error,
|
|
1854
|
-
debug.with('stack').error(error.stack).pop();
|
|
1850
|
+
debug.error({ req: args, res: error, stack: error.stack });
|
|
1855
1851
|
return reject(error);
|
|
1856
|
-
})
|
|
1857
|
-
.finally(() => {
|
|
1858
|
-
return debug.trace('finally', { args }).pop();
|
|
1859
1852
|
});
|
|
1860
1853
|
});
|
|
1861
1854
|
};
|
|
@@ -1863,26 +1856,21 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
|
|
|
1863
1856
|
const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
|
|
1864
1857
|
return function (...args) {
|
|
1865
1858
|
const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
|
|
1866
|
-
if (get(options, 'level', '') === 'log') {
|
|
1867
|
-
debug.with('params').log(args);
|
|
1868
|
-
}
|
|
1869
1859
|
let result;
|
|
1870
1860
|
try {
|
|
1871
1861
|
result = method.apply(this, args);
|
|
1872
1862
|
if (options.callbackFn)
|
|
1873
1863
|
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
1874
1864
|
if (get(options, 'level', '') === 'log') {
|
|
1875
|
-
debug.
|
|
1865
|
+
debug.log({ req: args, res: result === undefined ? 'void' : result });
|
|
1876
1866
|
}
|
|
1877
1867
|
return result;
|
|
1878
1868
|
}
|
|
1879
1869
|
catch (error) {
|
|
1880
|
-
|
|
1870
|
+
if (error instanceof Error)
|
|
1871
|
+
debug.error({ req: args, res: error, stack: error.stack });
|
|
1881
1872
|
throw error;
|
|
1882
1873
|
}
|
|
1883
|
-
finally {
|
|
1884
|
-
debug.trace('finally', { args }).pop();
|
|
1885
|
-
}
|
|
1886
1874
|
};
|
|
1887
1875
|
};
|
|
1888
1876
|
|
|
@@ -2225,6 +2213,9 @@ class UpdateUserImage {
|
|
|
2225
2213
|
}
|
|
2226
2214
|
|
|
2227
2215
|
class LineItem extends Product {
|
|
2216
|
+
get pricePaidWithDiscount() {
|
|
2217
|
+
return this.pricePaid - this.discount;
|
|
2218
|
+
}
|
|
2228
2219
|
}
|
|
2229
2220
|
|
|
2230
2221
|
class ShippingMethod extends BaseModel {
|
|
@@ -2767,6 +2758,7 @@ const withFirestore = (MixinBase) => {
|
|
|
2767
2758
|
this.model = options.model;
|
|
2768
2759
|
this.fields = options.fields;
|
|
2769
2760
|
this.interceptors = options.interceptors;
|
|
2761
|
+
this.logger = DebugHelper.from(this);
|
|
2770
2762
|
}
|
|
2771
2763
|
collection(path) {
|
|
2772
2764
|
return this.firestore.getCollection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
@@ -2817,16 +2809,28 @@ const withGetFirestore = (MixinBase) => {
|
|
|
2817
2809
|
return class GetFirestore extends MixinBase {
|
|
2818
2810
|
async get(identifiers) {
|
|
2819
2811
|
var _a, _b, _c, _d;
|
|
2812
|
+
const logger = this.logger.with('get');
|
|
2813
|
+
const collectionName = this.buildCollectionPathForGet(identifiers);
|
|
2820
2814
|
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
2821
|
-
const
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
.
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2815
|
+
const req = { collection: collectionName, data: identifiers };
|
|
2816
|
+
try {
|
|
2817
|
+
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
2818
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2819
|
+
const docRef = await this.collection(collectionName)
|
|
2820
|
+
.getDoc(Object.values(builded.identifier).shift().toString())
|
|
2821
|
+
.get();
|
|
2822
|
+
const data = docRef.data();
|
|
2823
|
+
if (isNil(data))
|
|
2824
|
+
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
2825
|
+
const res = ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
|
|
2826
|
+
logger.log({ req, res });
|
|
2827
|
+
return res;
|
|
2828
|
+
}
|
|
2829
|
+
catch (error) {
|
|
2830
|
+
if (error instanceof Error)
|
|
2831
|
+
logger.log({ req, res: error, stack: error.stack });
|
|
2832
|
+
throw error;
|
|
2833
|
+
}
|
|
2830
2834
|
}
|
|
2831
2835
|
buildCollectionPathForGet(identifiers) {
|
|
2832
2836
|
return this.isSubCollection(this)
|
|
@@ -2909,21 +2913,33 @@ const withFindFirestore = (MixinBase) => {
|
|
|
2909
2913
|
}
|
|
2910
2914
|
async find(find = {}) {
|
|
2911
2915
|
var _a, _b, _c, _d, _e, _f;
|
|
2912
|
-
const
|
|
2916
|
+
const logger = this.logger.with('find');
|
|
2917
|
+
const collectionName = this.buildCollectionPathForFind(find.filters);
|
|
2918
|
+
const collection = this.collection(collectionName);
|
|
2913
2919
|
const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
|
|
2914
|
-
const
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
data
|
|
2925
|
-
|
|
2926
|
-
|
|
2920
|
+
const req = { collection: collectionName, data: find };
|
|
2921
|
+
try {
|
|
2922
|
+
const intercepted = await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
|
|
2923
|
+
const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
|
|
2924
|
+
const queries = this.makeFirestoreWhere(filters || {});
|
|
2925
|
+
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
2926
|
+
const offsets = await this.defineLimits(filters, limits);
|
|
2927
|
+
const docs = await queries
|
|
2928
|
+
.reduce((collection, where) => collection.where(...where), ordination.reduce((collection, ordination) => collection.order(...ordination), offsets.reduce((collection, offset) => collection[offset[0]](offset[1]), collection)))
|
|
2929
|
+
.getDocs();
|
|
2930
|
+
const data = docs.docs.map((doc) => doc.data());
|
|
2931
|
+
const res = {
|
|
2932
|
+
data: (await ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
|
|
2933
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
2934
|
+
};
|
|
2935
|
+
logger.log({ req, queries, ordination, offsets, res });
|
|
2936
|
+
return res;
|
|
2937
|
+
}
|
|
2938
|
+
catch (error) {
|
|
2939
|
+
if (error instanceof Error)
|
|
2940
|
+
logger.log({ req, res: error, stack: error.stack });
|
|
2941
|
+
throw error;
|
|
2942
|
+
}
|
|
2927
2943
|
}
|
|
2928
2944
|
buildCollectionPathForFind(filters) {
|
|
2929
2945
|
if (!this.isSubCollection(this))
|
|
@@ -2964,13 +2980,23 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
2964
2980
|
return class CreateFirestore extends MixinBase {
|
|
2965
2981
|
async create(data) {
|
|
2966
2982
|
var _a, _b, _c, _d;
|
|
2983
|
+
const logger = this.logger.with('create');
|
|
2967
2984
|
const instance = this.model.toInstance(data);
|
|
2968
2985
|
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
2969
2986
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2987
|
+
const req = { collection: this.buildCollectionPathForAdd(builded), data };
|
|
2988
|
+
try {
|
|
2989
|
+
const docRef = await this.save(builded);
|
|
2990
|
+
const doc = (await docRef.get()).data();
|
|
2991
|
+
const docBuilded = (await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, doc, intercepted))) || doc;
|
|
2992
|
+
logger.log({ req, res: docBuilded });
|
|
2993
|
+
return docBuilded;
|
|
2994
|
+
}
|
|
2995
|
+
catch (error) {
|
|
2996
|
+
if (error instanceof Error)
|
|
2997
|
+
logger.log({ req, res: error, stack: error.stack });
|
|
2998
|
+
throw error;
|
|
2999
|
+
}
|
|
2974
3000
|
}
|
|
2975
3001
|
async save(data) {
|
|
2976
3002
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
@@ -3010,15 +3036,28 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
3010
3036
|
return class UpdateFirestore extends MixinBase {
|
|
3011
3037
|
async update(data) {
|
|
3012
3038
|
var _a, _b, _c, _d;
|
|
3039
|
+
const logger = this.logger.with('update');
|
|
3040
|
+
const collectionName = this.buildCollectionPathForUpdate(data);
|
|
3013
3041
|
const model = new this.model();
|
|
3014
3042
|
const keyField = model.identifiersFields.shift();
|
|
3015
|
-
const
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3043
|
+
const req = { collection: collectionName, data };
|
|
3044
|
+
try {
|
|
3045
|
+
const identifiers = getValueFromParams(data, keyField);
|
|
3046
|
+
const docRef = this.collection().getDoc(identifiers.toString());
|
|
3047
|
+
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
3048
|
+
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
|
|
3049
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
3050
|
+
await docRef.save(builded.toPlain());
|
|
3051
|
+
const docData = await docRef.get();
|
|
3052
|
+
const res = ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData.data(), intercepted)) || docData.data();
|
|
3053
|
+
logger.log({ req, res, identifiers });
|
|
3054
|
+
return res;
|
|
3055
|
+
}
|
|
3056
|
+
catch (error) {
|
|
3057
|
+
if (error instanceof Error)
|
|
3058
|
+
logger.log({ req, res: error, stack: error.stack });
|
|
3059
|
+
throw error;
|
|
3060
|
+
}
|
|
3022
3061
|
}
|
|
3023
3062
|
buildCollectionPathForUpdate(identifiers) {
|
|
3024
3063
|
return this.isSubCollection(this)
|
|
@@ -3038,13 +3077,22 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
3038
3077
|
return class DeleteFirestore extends MixinBase {
|
|
3039
3078
|
async delete(identifiers) {
|
|
3040
3079
|
var _a, _b, _c, _d;
|
|
3080
|
+
const logger = this.logger.with('delete');
|
|
3081
|
+
const collectionName = this.buildCollectionPathForRemove(identifiers);
|
|
3041
3082
|
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
|
|
3042
|
-
const
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
.delete();
|
|
3047
|
-
|
|
3083
|
+
const req = { collection: collectionName, data: identifiers };
|
|
3084
|
+
try {
|
|
3085
|
+
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
|
|
3086
|
+
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
|
|
3087
|
+
await this.collection(collectionName).getDoc(Object.values(builded.identifier).shift().toString()).delete();
|
|
3088
|
+
await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
|
|
3089
|
+
logger.log({ req, res: undefined });
|
|
3090
|
+
}
|
|
3091
|
+
catch (error) {
|
|
3092
|
+
if (error instanceof Error)
|
|
3093
|
+
logger.log({ req, res: error, stack: error.stack });
|
|
3094
|
+
throw error;
|
|
3095
|
+
}
|
|
3048
3096
|
}
|
|
3049
3097
|
buildCollectionPathForRemove(identifiers) {
|
|
3050
3098
|
return this.isSubCollection(this)
|
|
@@ -3219,7 +3267,19 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
3219
3267
|
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3220
3268
|
};
|
|
3221
3269
|
}
|
|
3222
|
-
}
|
|
3270
|
+
}
|
|
3271
|
+
__decorate([
|
|
3272
|
+
Log(),
|
|
3273
|
+
__metadata("design:type", Function),
|
|
3274
|
+
__metadata("design:paramtypes", [Object]),
|
|
3275
|
+
__metadata("design:returntype", Promise)
|
|
3276
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3277
|
+
__decorate([
|
|
3278
|
+
Log(),
|
|
3279
|
+
__metadata("design:type", Function),
|
|
3280
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3281
|
+
__metadata("design:returntype", Promise)
|
|
3282
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3223
3283
|
|
|
3224
3284
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3225
3285
|
constructor({ firestore, interceptors }, parentRepository) {
|
|
@@ -3303,7 +3363,25 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3303
3363
|
isChild(id, parentId) {
|
|
3304
3364
|
return;
|
|
3305
3365
|
}
|
|
3306
|
-
}
|
|
3366
|
+
}
|
|
3367
|
+
__decorate([
|
|
3368
|
+
Log(),
|
|
3369
|
+
__metadata("design:type", Function),
|
|
3370
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3371
|
+
__metadata("design:returntype", Promise)
|
|
3372
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3373
|
+
__decorate([
|
|
3374
|
+
Log(),
|
|
3375
|
+
__metadata("design:type", Function),
|
|
3376
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
3377
|
+
__metadata("design:returntype", Promise)
|
|
3378
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3379
|
+
__decorate([
|
|
3380
|
+
Log(),
|
|
3381
|
+
__metadata("design:type", Function),
|
|
3382
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
3383
|
+
__metadata("design:returntype", Promise)
|
|
3384
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3307
3385
|
|
|
3308
3386
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3309
3387
|
constructor({ firestore, interceptors }) {
|
|
@@ -3362,7 +3440,19 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3362
3440
|
async fetchPaginatedReviews() {
|
|
3363
3441
|
return Promise.resolve([]);
|
|
3364
3442
|
}
|
|
3365
|
-
}
|
|
3443
|
+
}
|
|
3444
|
+
__decorate([
|
|
3445
|
+
Log(),
|
|
3446
|
+
__metadata("design:type", Function),
|
|
3447
|
+
__metadata("design:paramtypes", [String]),
|
|
3448
|
+
__metadata("design:returntype", Promise)
|
|
3449
|
+
], ProductFirestoreRepository.prototype, "getBySlug", null);
|
|
3450
|
+
__decorate([
|
|
3451
|
+
Log(),
|
|
3452
|
+
__metadata("design:type", Function),
|
|
3453
|
+
__metadata("design:paramtypes", [String]),
|
|
3454
|
+
__metadata("design:returntype", Promise)
|
|
3455
|
+
], ProductFirestoreRepository.prototype, "fetchReviews", null);
|
|
3366
3456
|
|
|
3367
3457
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3368
3458
|
constructor({ firestore, interceptors }, parentRepository) {
|
|
@@ -4161,18 +4251,20 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4161
4251
|
return (await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
|
|
4162
4252
|
}
|
|
4163
4253
|
async fetch(params) {
|
|
4164
|
-
this.logger.with('params').log(params);
|
|
4165
4254
|
const headers = this.headers;
|
|
4166
|
-
const
|
|
4255
|
+
const request = {
|
|
4167
4256
|
url: `${this.endpoint}`,
|
|
4168
4257
|
method: 'POST',
|
|
4169
4258
|
data: params,
|
|
4170
4259
|
headers,
|
|
4171
|
-
}
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4260
|
+
};
|
|
4261
|
+
const response = await axios(request);
|
|
4262
|
+
if (!isNil(response.data.errors)) {
|
|
4263
|
+
this.logger.error({ req: request, res: response.data.errors });
|
|
4264
|
+
throw new Error(response.data.errors);
|
|
4265
|
+
}
|
|
4266
|
+
this.logger.log({ req: request, res: response.data });
|
|
4267
|
+
return response.data.data;
|
|
4176
4268
|
}
|
|
4177
4269
|
getAttributeGraphQLTypeOf(value) {
|
|
4178
4270
|
if (isUUID(value))
|
|
@@ -4619,7 +4711,19 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4619
4711
|
},
|
|
4620
4712
|
});
|
|
4621
4713
|
}
|
|
4622
|
-
}
|
|
4714
|
+
}
|
|
4715
|
+
__decorate([
|
|
4716
|
+
Log(),
|
|
4717
|
+
__metadata("design:type", Function),
|
|
4718
|
+
__metadata("design:paramtypes", [Number]),
|
|
4719
|
+
__metadata("design:returntype", Promise)
|
|
4720
|
+
], CategoryFilterHasuraGraphQLRepository.prototype, "deleteByCategory", null);
|
|
4721
|
+
__decorate([
|
|
4722
|
+
Log(),
|
|
4723
|
+
__metadata("design:type", Function),
|
|
4724
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
4725
|
+
__metadata("design:returntype", Promise)
|
|
4726
|
+
], CategoryFilterHasuraGraphQLRepository.prototype, "deleteByCategoryAndFilter", null);
|
|
4623
4727
|
|
|
4624
4728
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4625
4729
|
constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
|
|
@@ -4825,6 +4929,20 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4825
4929
|
products.push(...productsData);
|
|
4826
4930
|
return products;
|
|
4827
4931
|
}
|
|
4932
|
+
async getChildren(parentId) {
|
|
4933
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
4934
|
+
args: {
|
|
4935
|
+
type: 'category_tree_args',
|
|
4936
|
+
value: { parentid: parentId },
|
|
4937
|
+
required: true,
|
|
4938
|
+
},
|
|
4939
|
+
});
|
|
4940
|
+
return category_tree.map((category) => Category.toInstance(category));
|
|
4941
|
+
}
|
|
4942
|
+
async isChild(id, parentId) {
|
|
4943
|
+
const categoryTree = await this.getChildren(parentId);
|
|
4944
|
+
return categoryTree.some((c) => c.id == id.toString());
|
|
4945
|
+
}
|
|
4828
4946
|
async getId(id) {
|
|
4829
4947
|
var _a, _b;
|
|
4830
4948
|
if (!Number.isNaN(+id))
|
|
@@ -4954,21 +5072,43 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4954
5072
|
return filters;
|
|
4955
5073
|
}
|
|
4956
5074
|
}
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
5075
|
+
}
|
|
5076
|
+
__decorate([
|
|
5077
|
+
Log(),
|
|
5078
|
+
__metadata("design:type", Function),
|
|
5079
|
+
__metadata("design:paramtypes", [String, String]),
|
|
5080
|
+
__metadata("design:returntype", Promise)
|
|
5081
|
+
], CategoryHasuraGraphQLRepository.prototype, "getCategoryBySlug", null);
|
|
5082
|
+
__decorate([
|
|
5083
|
+
Log(),
|
|
5084
|
+
__metadata("design:type", Function),
|
|
5085
|
+
__metadata("design:paramtypes", [String]),
|
|
5086
|
+
__metadata("design:returntype", Promise)
|
|
5087
|
+
], CategoryHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
5088
|
+
__decorate([
|
|
5089
|
+
Log(),
|
|
5090
|
+
__metadata("design:type", Function),
|
|
5091
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
5092
|
+
__metadata("design:returntype", Promise)
|
|
5093
|
+
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5094
|
+
__decorate([
|
|
5095
|
+
Log(),
|
|
5096
|
+
__metadata("design:type", Function),
|
|
5097
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
5098
|
+
__metadata("design:returntype", Promise)
|
|
5099
|
+
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5100
|
+
__decorate([
|
|
5101
|
+
Log(),
|
|
5102
|
+
__metadata("design:type", Function),
|
|
5103
|
+
__metadata("design:paramtypes", [Number]),
|
|
5104
|
+
__metadata("design:returntype", Promise)
|
|
5105
|
+
], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
|
|
5106
|
+
__decorate([
|
|
5107
|
+
Log(),
|
|
5108
|
+
__metadata("design:type", Function),
|
|
5109
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
5110
|
+
__metadata("design:returntype", Promise)
|
|
5111
|
+
], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
|
|
4972
5112
|
|
|
4973
5113
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4974
5114
|
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
@@ -5070,7 +5210,19 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5070
5210
|
},
|
|
5071
5211
|
});
|
|
5072
5212
|
}
|
|
5073
|
-
}
|
|
5213
|
+
}
|
|
5214
|
+
__decorate([
|
|
5215
|
+
Log(),
|
|
5216
|
+
__metadata("design:type", Function),
|
|
5217
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
5218
|
+
__metadata("design:returntype", Promise)
|
|
5219
|
+
], FilterHasuraGraphQLRepository.prototype, "updateOptions", null);
|
|
5220
|
+
__decorate([
|
|
5221
|
+
Log(),
|
|
5222
|
+
__metadata("design:type", Function),
|
|
5223
|
+
__metadata("design:paramtypes", [Number]),
|
|
5224
|
+
__metadata("design:returntype", Promise)
|
|
5225
|
+
], FilterHasuraGraphQLRepository.prototype, "deleteOptions", null);
|
|
5074
5226
|
|
|
5075
5227
|
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5076
5228
|
constructor({ endpoint, authOptions, interceptors, }) {
|
|
@@ -5380,9 +5532,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5380
5532
|
...product.reviews.map((review) => (Object.assign(Object.assign({}, review), { reviewStatus: this.getReviewStatus(review), productId: product.id, productName: product.name, productSku: product.sku }))),
|
|
5381
5533
|
], []);
|
|
5382
5534
|
}
|
|
5383
|
-
getReviewStatus(review) {
|
|
5384
|
-
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5385
|
-
}
|
|
5386
5535
|
async fetchReviews(status) {
|
|
5387
5536
|
const reviewsExpression = {
|
|
5388
5537
|
status: status === 'pending'
|
|
@@ -5404,6 +5553,22 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5404
5553
|
async findCatalog(params, mainGender) {
|
|
5405
5554
|
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
5406
5555
|
}
|
|
5556
|
+
async cleanShoppingCountFromIds(ids) {
|
|
5557
|
+
return await this.mutation('update_product', ['affected_rows'], {
|
|
5558
|
+
where: {
|
|
5559
|
+
value: { id: { _nin: ids } },
|
|
5560
|
+
type: 'product_bool_exp',
|
|
5561
|
+
required: true,
|
|
5562
|
+
},
|
|
5563
|
+
_set: {
|
|
5564
|
+
value: { shopping_count: 0 },
|
|
5565
|
+
type: 'product_set_input',
|
|
5566
|
+
},
|
|
5567
|
+
});
|
|
5568
|
+
}
|
|
5569
|
+
getReviewStatus(review) {
|
|
5570
|
+
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5571
|
+
}
|
|
5407
5572
|
async updateCategories(productId, { categories }) {
|
|
5408
5573
|
if ('action' in categories && categories.action === 'remove') {
|
|
5409
5574
|
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
@@ -5571,20 +5736,37 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5571
5736
|
});
|
|
5572
5737
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
5573
5738
|
}
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5739
|
+
}
|
|
5740
|
+
__decorate([
|
|
5741
|
+
Log(),
|
|
5742
|
+
__metadata("design:type", Function),
|
|
5743
|
+
__metadata("design:paramtypes", [String]),
|
|
5744
|
+
__metadata("design:returntype", Promise)
|
|
5745
|
+
], ProductHasuraGraphQLRepository.prototype, "getBySlug", null);
|
|
5746
|
+
__decorate([
|
|
5747
|
+
Log(),
|
|
5748
|
+
__metadata("design:type", Function),
|
|
5749
|
+
__metadata("design:paramtypes", []),
|
|
5750
|
+
__metadata("design:returntype", Promise)
|
|
5751
|
+
], ProductHasuraGraphQLRepository.prototype, "fetchProductReviews", null);
|
|
5752
|
+
__decorate([
|
|
5753
|
+
Log(),
|
|
5754
|
+
__metadata("design:type", Function),
|
|
5755
|
+
__metadata("design:paramtypes", [String]),
|
|
5756
|
+
__metadata("design:returntype", Promise)
|
|
5757
|
+
], ProductHasuraGraphQLRepository.prototype, "fetchReviews", null);
|
|
5758
|
+
__decorate([
|
|
5759
|
+
Log(),
|
|
5760
|
+
__metadata("design:type", Function),
|
|
5761
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
5762
|
+
__metadata("design:returntype", Promise)
|
|
5763
|
+
], ProductHasuraGraphQLRepository.prototype, "findCatalog", null);
|
|
5764
|
+
__decorate([
|
|
5765
|
+
Log(),
|
|
5766
|
+
__metadata("design:type", Function),
|
|
5767
|
+
__metadata("design:paramtypes", [Array]),
|
|
5768
|
+
__metadata("design:returntype", Promise)
|
|
5769
|
+
], ProductHasuraGraphQLRepository.prototype, "cleanShoppingCountFromIds", null);
|
|
5588
5770
|
|
|
5589
5771
|
class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5590
5772
|
constructor({ endpoint, authOptions, interceptors, }) {
|
|
@@ -5619,7 +5801,19 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5619
5801
|
disaproveReview(id) {
|
|
5620
5802
|
return this.update({ id, status: false });
|
|
5621
5803
|
}
|
|
5622
|
-
}
|
|
5804
|
+
}
|
|
5805
|
+
__decorate([
|
|
5806
|
+
Log(),
|
|
5807
|
+
__metadata("design:type", Function),
|
|
5808
|
+
__metadata("design:paramtypes", [Number]),
|
|
5809
|
+
__metadata("design:returntype", void 0)
|
|
5810
|
+
], ProductReviewsHasuraGraphQLRepository.prototype, "aproveReview", null);
|
|
5811
|
+
__decorate([
|
|
5812
|
+
Log(),
|
|
5813
|
+
__metadata("design:type", Function),
|
|
5814
|
+
__metadata("design:paramtypes", [Number]),
|
|
5815
|
+
__metadata("design:returntype", void 0)
|
|
5816
|
+
], ProductReviewsHasuraGraphQLRepository.prototype, "disaproveReview", null);
|
|
5623
5817
|
|
|
5624
5818
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5625
5819
|
constructor({ endpoint, authOptions, interceptors, }) {
|
|
@@ -5869,6 +6063,36 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5869
6063
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
5870
6064
|
return data;
|
|
5871
6065
|
}
|
|
6066
|
+
getCategoryBySlug(slug, _shop) {
|
|
6067
|
+
return this.getWishlistBySlug(slug);
|
|
6068
|
+
}
|
|
6069
|
+
async getCategoryByShop(shop) {
|
|
6070
|
+
if (!shop)
|
|
6071
|
+
return;
|
|
6072
|
+
const { data } = await this.find({
|
|
6073
|
+
filters: {
|
|
6074
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
6075
|
+
published: { operator: Where.EQUALS, value: true },
|
|
6076
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
6077
|
+
},
|
|
6078
|
+
options: {
|
|
6079
|
+
enableCount: false,
|
|
6080
|
+
},
|
|
6081
|
+
});
|
|
6082
|
+
return data;
|
|
6083
|
+
}
|
|
6084
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6085
|
+
return;
|
|
6086
|
+
}
|
|
6087
|
+
mountCategory(category, options) {
|
|
6088
|
+
return;
|
|
6089
|
+
}
|
|
6090
|
+
getChildren(parentId) {
|
|
6091
|
+
return;
|
|
6092
|
+
}
|
|
6093
|
+
isChild(id, parentId) {
|
|
6094
|
+
return;
|
|
6095
|
+
}
|
|
5872
6096
|
async updateProducts(categoryId, { products }) {
|
|
5873
6097
|
if ('action' in products && products.action === 'remove') {
|
|
5874
6098
|
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
@@ -5925,36 +6149,24 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5925
6149
|
});
|
|
5926
6150
|
return plainData.metadata;
|
|
5927
6151
|
}
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
return;
|
|
5948
|
-
}
|
|
5949
|
-
mountCategory(category, options) {
|
|
5950
|
-
return;
|
|
5951
|
-
}
|
|
5952
|
-
getChildren(parentId) {
|
|
5953
|
-
return;
|
|
5954
|
-
}
|
|
5955
|
-
isChild(id, parentId) {
|
|
5956
|
-
return;
|
|
5957
|
-
}
|
|
5958
|
-
}
|
|
6152
|
+
}
|
|
6153
|
+
__decorate([
|
|
6154
|
+
Log(),
|
|
6155
|
+
__metadata("design:type", Function),
|
|
6156
|
+
__metadata("design:paramtypes", [String]),
|
|
6157
|
+
__metadata("design:returntype", Promise)
|
|
6158
|
+
], WishlistHasuraGraphQLRepository.prototype, "getWishlistBySlug", null);
|
|
6159
|
+
__decorate([
|
|
6160
|
+
Log(),
|
|
6161
|
+
__metadata("design:type", Function),
|
|
6162
|
+
__metadata("design:paramtypes", [String]),
|
|
6163
|
+
__metadata("design:returntype", Promise)
|
|
6164
|
+
], WishlistHasuraGraphQLRepository.prototype, "getWishlistByPerson", null);
|
|
6165
|
+
__decorate([
|
|
6166
|
+
Log(),
|
|
6167
|
+
__metadata("design:type", Function),
|
|
6168
|
+
__metadata("design:paramtypes", [String]),
|
|
6169
|
+
__metadata("design:returntype", Promise)
|
|
6170
|
+
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
5959
6171
|
|
|
5960
6172
|
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 };
|