@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 CHANGED
@@ -1859,9 +1859,6 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
1859
1859
  return function (...args) {
1860
1860
  return new Promise((resolve, reject) => {
1861
1861
  const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
1862
- if (lodash.get(options, 'level', '') === 'log') {
1863
- debug.with('params').log(args);
1864
- }
1865
1862
  return method
1866
1863
  .apply(this, args)
1867
1864
  .then((result) => {
@@ -1869,17 +1866,13 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
1869
1866
  options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
1870
1867
  }
1871
1868
  if (lodash.get(options, 'level', '') === 'log') {
1872
- debug.with('returns').log(result === undefined ? 'void' : result);
1869
+ debug.log({ req: args, res: result === undefined ? 'void' : result });
1873
1870
  }
1874
1871
  return resolve(result);
1875
1872
  })
1876
1873
  .catch((error) => {
1877
- debug.error(error, ...args);
1878
- debug.with('stack').error(error.stack).pop();
1874
+ debug.error({ req: args, res: error, stack: error.stack });
1879
1875
  return reject(error);
1880
- })
1881
- .finally(() => {
1882
- return debug.trace('finally', { args }).pop();
1883
1876
  });
1884
1877
  });
1885
1878
  };
@@ -1887,26 +1880,21 @@ const promiseTracer = function ({ options, method, propertyKey, propertyDescript
1887
1880
  const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
1888
1881
  return function (...args) {
1889
1882
  const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
1890
- if (lodash.get(options, 'level', '') === 'log') {
1891
- debug.with('params').log(args);
1892
- }
1893
1883
  let result;
1894
1884
  try {
1895
1885
  result = method.apply(this, args);
1896
1886
  if (options.callbackFn)
1897
1887
  options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
1898
1888
  if (lodash.get(options, 'level', '') === 'log') {
1899
- debug.with('returns').log(result === undefined ? 'void' : result);
1889
+ debug.log({ req: args, res: result === undefined ? 'void' : result });
1900
1890
  }
1901
1891
  return result;
1902
1892
  }
1903
1893
  catch (error) {
1904
- debug.error(error, ...args).pop();
1894
+ if (error instanceof Error)
1895
+ debug.error({ req: args, res: error, stack: error.stack });
1905
1896
  throw error;
1906
1897
  }
1907
- finally {
1908
- debug.trace('finally', { args }).pop();
1909
- }
1910
1898
  };
1911
1899
  };
1912
1900
 
@@ -2249,6 +2237,9 @@ class UpdateUserImage {
2249
2237
  }
2250
2238
 
2251
2239
  class LineItem extends Product {
2240
+ get pricePaidWithDiscount() {
2241
+ return this.pricePaid - this.discount;
2242
+ }
2252
2243
  }
2253
2244
 
2254
2245
  class ShippingMethod extends BaseModel {
@@ -2791,6 +2782,7 @@ const withFirestore = (MixinBase) => {
2791
2782
  this.model = options.model;
2792
2783
  this.fields = options.fields;
2793
2784
  this.interceptors = options.interceptors;
2785
+ this.logger = DebugHelper.from(this);
2794
2786
  }
2795
2787
  collection(path) {
2796
2788
  return this.firestore.getCollection(path || this.collectionName).withConverter(this.buildModelInstance());
@@ -2841,16 +2833,28 @@ const withGetFirestore = (MixinBase) => {
2841
2833
  return class GetFirestore extends MixinBase {
2842
2834
  async get(identifiers) {
2843
2835
  var _a, _b, _c, _d;
2836
+ const logger = this.logger.with('get');
2837
+ const collectionName = this.buildCollectionPathForGet(identifiers);
2844
2838
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
2845
- 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 }));
2846
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2847
- const docRef = await this.collection(this.buildCollectionPathForGet(identifiers))
2848
- .getDoc(Object.values(builded.identifier).shift().toString())
2849
- .get();
2850
- const data = docRef.data();
2851
- if (lodash.isNil(data))
2852
- throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
2853
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
2839
+ const req = { collection: collectionName, data: identifiers };
2840
+ try {
2841
+ 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 }));
2842
+ const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2843
+ const docRef = await this.collection(collectionName)
2844
+ .getDoc(Object.values(builded.identifier).shift().toString())
2845
+ .get();
2846
+ const data = docRef.data();
2847
+ if (lodash.isNil(data))
2848
+ throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
2849
+ 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;
2850
+ logger.log({ req, res });
2851
+ return res;
2852
+ }
2853
+ catch (error) {
2854
+ if (error instanceof Error)
2855
+ logger.log({ req, res: error, stack: error.stack });
2856
+ throw error;
2857
+ }
2854
2858
  }
2855
2859
  buildCollectionPathForGet(identifiers) {
2856
2860
  return this.isSubCollection(this)
@@ -2933,21 +2937,33 @@ const withFindFirestore = (MixinBase) => {
2933
2937
  }
2934
2938
  async find(find = {}) {
2935
2939
  var _a, _b, _c, _d, _e, _f;
2936
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
2940
+ const logger = this.logger.with('find');
2941
+ const collectionName = this.buildCollectionPathForFind(find.filters);
2942
+ const collection = this.collection(collectionName);
2937
2943
  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;
2938
- 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 }));
2939
- const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
2940
- const queries = this.makeFirestoreWhere(filters || {});
2941
- const ordination = this.makeFirestoreOrderBy(filters, orderBy);
2942
- const offsets = await this.defineLimits(filters, limits);
2943
- const docs = await queries
2944
- .reduce((collection, where) => collection.where(...where), ordination.reduce((collection, ordination) => collection.order(...ordination), offsets.reduce((collection, offset) => collection[offset[0]](offset[1]), collection)))
2945
- .getDocs();
2946
- const data = docs.docs.map((doc) => doc.data());
2947
- return {
2948
- 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,
2949
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
2950
- };
2944
+ const req = { collection: collectionName, data: find };
2945
+ try {
2946
+ 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 }));
2947
+ const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
2948
+ const queries = this.makeFirestoreWhere(filters || {});
2949
+ const ordination = this.makeFirestoreOrderBy(filters, orderBy);
2950
+ const offsets = await this.defineLimits(filters, limits);
2951
+ const docs = await queries
2952
+ .reduce((collection, where) => collection.where(...where), ordination.reduce((collection, ordination) => collection.order(...ordination), offsets.reduce((collection, offset) => collection[offset[0]](offset[1]), collection)))
2953
+ .getDocs();
2954
+ const data = docs.docs.map((doc) => doc.data());
2955
+ const res = {
2956
+ 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,
2957
+ count: enableCount ? this.calculateCount(data, limits) : Infinity,
2958
+ };
2959
+ logger.log({ req, queries, ordination, offsets, res });
2960
+ return res;
2961
+ }
2962
+ catch (error) {
2963
+ if (error instanceof Error)
2964
+ logger.log({ req, res: error, stack: error.stack });
2965
+ throw error;
2966
+ }
2951
2967
  }
2952
2968
  buildCollectionPathForFind(filters) {
2953
2969
  if (!this.isSubCollection(this))
@@ -2988,13 +3004,23 @@ const withCreateFirestore = (MixinBase) => {
2988
3004
  return class CreateFirestore extends MixinBase {
2989
3005
  async create(data) {
2990
3006
  var _a, _b, _c, _d;
3007
+ const logger = this.logger.with('create');
2991
3008
  const instance = this.model.toInstance(data);
2992
3009
  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 }));
2993
3010
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2994
- const docRef = await this.save(builded);
2995
- const doc = (await docRef.get()).data();
2996
- 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;
2997
- return docBuilded;
3011
+ const req = { collection: this.buildCollectionPathForAdd(builded), data };
3012
+ try {
3013
+ const docRef = await this.save(builded);
3014
+ const doc = (await docRef.get()).data();
3015
+ 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;
3016
+ logger.log({ req, res: docBuilded });
3017
+ return docBuilded;
3018
+ }
3019
+ catch (error) {
3020
+ if (error instanceof Error)
3021
+ logger.log({ req, res: error, stack: error.stack });
3022
+ throw error;
3023
+ }
2998
3024
  }
2999
3025
  async save(data) {
3000
3026
  const collectionPath = this.buildCollectionPathForAdd(data);
@@ -3034,15 +3060,28 @@ const withUpdateFirestore = (MixinBase) => {
3034
3060
  return class UpdateFirestore extends MixinBase {
3035
3061
  async update(data) {
3036
3062
  var _a, _b, _c, _d;
3063
+ const logger = this.logger.with('update');
3064
+ const collectionName = this.buildCollectionPathForUpdate(data);
3037
3065
  const model = new this.model();
3038
3066
  const keyField = model.identifiersFields.shift();
3039
- const docRef = this.collection(this.buildCollectionPathForUpdate(data)).getDoc(getValueFromParams(data, keyField).toString());
3040
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3041
- 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 }));
3042
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
3043
- await docRef.save(builded.toPlain());
3044
- const docData = await docRef.get();
3045
- return ((_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();
3067
+ const req = { collection: collectionName, data };
3068
+ try {
3069
+ const identifiers = getValueFromParams(data, keyField);
3070
+ const docRef = this.collection().getDoc(identifiers.toString());
3071
+ const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3072
+ 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 }));
3073
+ const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
3074
+ await docRef.save(builded.toPlain());
3075
+ const docData = await docRef.get();
3076
+ 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();
3077
+ logger.log({ req, res, identifiers });
3078
+ return res;
3079
+ }
3080
+ catch (error) {
3081
+ if (error instanceof Error)
3082
+ logger.log({ req, res: error, stack: error.stack });
3083
+ throw error;
3084
+ }
3046
3085
  }
3047
3086
  buildCollectionPathForUpdate(identifiers) {
3048
3087
  return this.isSubCollection(this)
@@ -3062,13 +3101,22 @@ const withDeleteFirestore = (MixinBase) => {
3062
3101
  return class DeleteFirestore extends MixinBase {
3063
3102
  async delete(identifiers) {
3064
3103
  var _a, _b, _c, _d;
3104
+ const logger = this.logger.with('delete');
3105
+ const collectionName = this.buildCollectionPathForRemove(identifiers);
3065
3106
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
3066
- 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 }));
3067
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3068
- await this.collection(this.buildCollectionPathForRemove(identifiers))
3069
- .getDoc(Object.values(builded.identifier).shift().toString())
3070
- .delete();
3071
- await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
3107
+ const req = { collection: collectionName, data: identifiers };
3108
+ try {
3109
+ 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 }));
3110
+ const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3111
+ await this.collection(collectionName).getDoc(Object.values(builded.identifier).shift().toString()).delete();
3112
+ await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
3113
+ logger.log({ req, res: undefined });
3114
+ }
3115
+ catch (error) {
3116
+ if (error instanceof Error)
3117
+ logger.log({ req, res: error, stack: error.stack });
3118
+ throw error;
3119
+ }
3072
3120
  }
3073
3121
  buildCollectionPathForRemove(identifiers) {
3074
3122
  return this.isSubCollection(this)
@@ -3243,7 +3291,19 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
3243
3291
  fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3244
3292
  };
3245
3293
  }
3246
- }
3294
+ }
3295
+ tslib_1.__decorate([
3296
+ Log(),
3297
+ tslib_1.__metadata("design:type", Function),
3298
+ tslib_1.__metadata("design:paramtypes", [Object]),
3299
+ tslib_1.__metadata("design:returntype", Promise)
3300
+ ], UserFirestoreRepository.prototype, "get", null);
3301
+ tslib_1.__decorate([
3302
+ Log(),
3303
+ tslib_1.__metadata("design:type", Function),
3304
+ tslib_1.__metadata("design:paramtypes", [String, String]),
3305
+ tslib_1.__metadata("design:returntype", Promise)
3306
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3247
3307
 
3248
3308
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3249
3309
  constructor({ firestore, interceptors }, parentRepository) {
@@ -3327,7 +3387,25 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3327
3387
  isChild(id, parentId) {
3328
3388
  return;
3329
3389
  }
3330
- }
3390
+ }
3391
+ tslib_1.__decorate([
3392
+ Log(),
3393
+ tslib_1.__metadata("design:type", Function),
3394
+ tslib_1.__metadata("design:paramtypes", [String, String]),
3395
+ tslib_1.__metadata("design:returntype", Promise)
3396
+ ], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
3397
+ tslib_1.__decorate([
3398
+ Log(),
3399
+ tslib_1.__metadata("design:type", Function),
3400
+ tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
3401
+ tslib_1.__metadata("design:returntype", Promise)
3402
+ ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3403
+ tslib_1.__decorate([
3404
+ Log(),
3405
+ tslib_1.__metadata("design:type", Function),
3406
+ tslib_1.__metadata("design:paramtypes", [Category, Object]),
3407
+ tslib_1.__metadata("design:returntype", Promise)
3408
+ ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3331
3409
 
3332
3410
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3333
3411
  constructor({ firestore, interceptors }) {
@@ -3386,7 +3464,19 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3386
3464
  async fetchPaginatedReviews() {
3387
3465
  return Promise.resolve([]);
3388
3466
  }
3389
- }
3467
+ }
3468
+ tslib_1.__decorate([
3469
+ Log(),
3470
+ tslib_1.__metadata("design:type", Function),
3471
+ tslib_1.__metadata("design:paramtypes", [String]),
3472
+ tslib_1.__metadata("design:returntype", Promise)
3473
+ ], ProductFirestoreRepository.prototype, "getBySlug", null);
3474
+ tslib_1.__decorate([
3475
+ Log(),
3476
+ tslib_1.__metadata("design:type", Function),
3477
+ tslib_1.__metadata("design:paramtypes", [String]),
3478
+ tslib_1.__metadata("design:returntype", Promise)
3479
+ ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3390
3480
 
3391
3481
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3392
3482
  constructor({ firestore, interceptors }, parentRepository) {
@@ -4185,18 +4275,20 @@ const withHasuraGraphQL = (MixinBase) => {
4185
4275
  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;
4186
4276
  }
4187
4277
  async fetch(params) {
4188
- this.logger.with('params').log(params);
4189
4278
  const headers = this.headers;
4190
- const { data: result } = await axios__default["default"]({
4279
+ const request = {
4191
4280
  url: `${this.endpoint}`,
4192
4281
  method: 'POST',
4193
4282
  data: params,
4194
4283
  headers,
4195
- });
4196
- if (!lodash.isNil(result.errors))
4197
- throw new Error(JSON.stringify(result.errors));
4198
- this.logger.with('returns').log(result);
4199
- return result.data;
4284
+ };
4285
+ const response = await axios__default["default"](request);
4286
+ if (!lodash.isNil(response.data.errors)) {
4287
+ this.logger.error({ req: request, res: response.data.errors });
4288
+ throw new Error(response.data.errors);
4289
+ }
4290
+ this.logger.log({ req: request, res: response.data });
4291
+ return response.data.data;
4200
4292
  }
4201
4293
  getAttributeGraphQLTypeOf(value) {
4202
4294
  if (isUUID(value))
@@ -4643,7 +4735,19 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
4643
4735
  },
4644
4736
  });
4645
4737
  }
4646
- }
4738
+ }
4739
+ tslib_1.__decorate([
4740
+ Log(),
4741
+ tslib_1.__metadata("design:type", Function),
4742
+ tslib_1.__metadata("design:paramtypes", [Number]),
4743
+ tslib_1.__metadata("design:returntype", Promise)
4744
+ ], CategoryFilterHasuraGraphQLRepository.prototype, "deleteByCategory", null);
4745
+ tslib_1.__decorate([
4746
+ Log(),
4747
+ tslib_1.__metadata("design:type", Function),
4748
+ tslib_1.__metadata("design:paramtypes", [Number, Number]),
4749
+ tslib_1.__metadata("design:returntype", Promise)
4750
+ ], CategoryFilterHasuraGraphQLRepository.prototype, "deleteByCategoryAndFilter", null);
4647
4751
 
4648
4752
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4649
4753
  constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
@@ -4849,6 +4953,20 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4849
4953
  products.push(...productsData);
4850
4954
  return products;
4851
4955
  }
4956
+ async getChildren(parentId) {
4957
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
4958
+ args: {
4959
+ type: 'category_tree_args',
4960
+ value: { parentid: parentId },
4961
+ required: true,
4962
+ },
4963
+ });
4964
+ return category_tree.map((category) => Category.toInstance(category));
4965
+ }
4966
+ async isChild(id, parentId) {
4967
+ const categoryTree = await this.getChildren(parentId);
4968
+ return categoryTree.some((c) => c.id == id.toString());
4969
+ }
4852
4970
  async getId(id) {
4853
4971
  var _a, _b;
4854
4972
  if (!Number.isNaN(+id))
@@ -4978,21 +5096,43 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4978
5096
  return filters;
4979
5097
  }
4980
5098
  }
4981
- async getChildren(parentId) {
4982
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
4983
- args: {
4984
- type: 'category_tree_args',
4985
- value: { parentid: parentId },
4986
- required: true,
4987
- },
4988
- });
4989
- return category_tree.map((category) => Category.toInstance(category));
4990
- }
4991
- async isChild(id, parentId) {
4992
- const categoryTree = await this.getChildren(parentId);
4993
- return categoryTree.some((c) => c.id == id.toString());
4994
- }
4995
- }
5099
+ }
5100
+ tslib_1.__decorate([
5101
+ Log(),
5102
+ tslib_1.__metadata("design:type", Function),
5103
+ tslib_1.__metadata("design:paramtypes", [String, String]),
5104
+ tslib_1.__metadata("design:returntype", Promise)
5105
+ ], CategoryHasuraGraphQLRepository.prototype, "getCategoryBySlug", null);
5106
+ tslib_1.__decorate([
5107
+ Log(),
5108
+ tslib_1.__metadata("design:type", Function),
5109
+ tslib_1.__metadata("design:paramtypes", [String]),
5110
+ tslib_1.__metadata("design:returntype", Promise)
5111
+ ], CategoryHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
5112
+ tslib_1.__decorate([
5113
+ Log(),
5114
+ tslib_1.__metadata("design:type", Function),
5115
+ tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
5116
+ tslib_1.__metadata("design:returntype", Promise)
5117
+ ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5118
+ tslib_1.__decorate([
5119
+ Log(),
5120
+ tslib_1.__metadata("design:type", Function),
5121
+ tslib_1.__metadata("design:paramtypes", [Category, Object]),
5122
+ tslib_1.__metadata("design:returntype", Promise)
5123
+ ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5124
+ tslib_1.__decorate([
5125
+ Log(),
5126
+ tslib_1.__metadata("design:type", Function),
5127
+ tslib_1.__metadata("design:paramtypes", [Number]),
5128
+ tslib_1.__metadata("design:returntype", Promise)
5129
+ ], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
5130
+ tslib_1.__decorate([
5131
+ Log(),
5132
+ tslib_1.__metadata("design:type", Function),
5133
+ tslib_1.__metadata("design:paramtypes", [Number, Number]),
5134
+ tslib_1.__metadata("design:returntype", Promise)
5135
+ ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
4996
5136
 
4997
5137
  class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4998
5138
  constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
@@ -5094,7 +5234,19 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5094
5234
  },
5095
5235
  });
5096
5236
  }
5097
- }
5237
+ }
5238
+ tslib_1.__decorate([
5239
+ Log(),
5240
+ tslib_1.__metadata("design:type", Function),
5241
+ tslib_1.__metadata("design:paramtypes", [Number, Object]),
5242
+ tslib_1.__metadata("design:returntype", Promise)
5243
+ ], FilterHasuraGraphQLRepository.prototype, "updateOptions", null);
5244
+ tslib_1.__decorate([
5245
+ Log(),
5246
+ tslib_1.__metadata("design:type", Function),
5247
+ tslib_1.__metadata("design:paramtypes", [Number]),
5248
+ tslib_1.__metadata("design:returntype", Promise)
5249
+ ], FilterHasuraGraphQLRepository.prototype, "deleteOptions", null);
5098
5250
 
5099
5251
  class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5100
5252
  constructor({ endpoint, authOptions, interceptors, }) {
@@ -5404,9 +5556,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5404
5556
  ...product.reviews.map((review) => (Object.assign(Object.assign({}, review), { reviewStatus: this.getReviewStatus(review), productId: product.id, productName: product.name, productSku: product.sku }))),
5405
5557
  ], []);
5406
5558
  }
5407
- getReviewStatus(review) {
5408
- return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
5409
- }
5410
5559
  async fetchReviews(status) {
5411
5560
  const reviewsExpression = {
5412
5561
  status: status === 'pending'
@@ -5428,6 +5577,22 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5428
5577
  async findCatalog(params, mainGender) {
5429
5578
  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' })), lodash.omit(params.orderBy, ['hasStock', 'intGender'])) }));
5430
5579
  }
5580
+ async cleanShoppingCountFromIds(ids) {
5581
+ return await this.mutation('update_product', ['affected_rows'], {
5582
+ where: {
5583
+ value: { id: { _nin: ids } },
5584
+ type: 'product_bool_exp',
5585
+ required: true,
5586
+ },
5587
+ _set: {
5588
+ value: { shopping_count: 0 },
5589
+ type: 'product_set_input',
5590
+ },
5591
+ });
5592
+ }
5593
+ getReviewStatus(review) {
5594
+ return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
5595
+ }
5431
5596
  async updateCategories(productId, { categories }) {
5432
5597
  if ('action' in categories && categories.action === 'remove') {
5433
5598
  await this.mutation('delete_category_product', ['affected_rows'], {
@@ -5595,20 +5760,37 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5595
5760
  });
5596
5761
  return data && data[0] && this.bindReviewToModel(data[0]);
5597
5762
  }
5598
- async cleanShoppingCountFromIds(ids) {
5599
- return await this.mutation('update_product', ['affected_rows'], {
5600
- where: {
5601
- value: { id: { _nin: ids } },
5602
- type: 'product_bool_exp',
5603
- required: true,
5604
- },
5605
- _set: {
5606
- value: { shopping_count: 0 },
5607
- type: 'product_set_input',
5608
- },
5609
- });
5610
- }
5611
- }
5763
+ }
5764
+ tslib_1.__decorate([
5765
+ Log(),
5766
+ tslib_1.__metadata("design:type", Function),
5767
+ tslib_1.__metadata("design:paramtypes", [String]),
5768
+ tslib_1.__metadata("design:returntype", Promise)
5769
+ ], ProductHasuraGraphQLRepository.prototype, "getBySlug", null);
5770
+ tslib_1.__decorate([
5771
+ Log(),
5772
+ tslib_1.__metadata("design:type", Function),
5773
+ tslib_1.__metadata("design:paramtypes", []),
5774
+ tslib_1.__metadata("design:returntype", Promise)
5775
+ ], ProductHasuraGraphQLRepository.prototype, "fetchProductReviews", null);
5776
+ tslib_1.__decorate([
5777
+ Log(),
5778
+ tslib_1.__metadata("design:type", Function),
5779
+ tslib_1.__metadata("design:paramtypes", [String]),
5780
+ tslib_1.__metadata("design:returntype", Promise)
5781
+ ], ProductHasuraGraphQLRepository.prototype, "fetchReviews", null);
5782
+ tslib_1.__decorate([
5783
+ Log(),
5784
+ tslib_1.__metadata("design:type", Function),
5785
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
5786
+ tslib_1.__metadata("design:returntype", Promise)
5787
+ ], ProductHasuraGraphQLRepository.prototype, "findCatalog", null);
5788
+ tslib_1.__decorate([
5789
+ Log(),
5790
+ tslib_1.__metadata("design:type", Function),
5791
+ tslib_1.__metadata("design:paramtypes", [Array]),
5792
+ tslib_1.__metadata("design:returntype", Promise)
5793
+ ], ProductHasuraGraphQLRepository.prototype, "cleanShoppingCountFromIds", null);
5612
5794
 
5613
5795
  class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5614
5796
  constructor({ endpoint, authOptions, interceptors, }) {
@@ -5643,7 +5825,19 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5643
5825
  disaproveReview(id) {
5644
5826
  return this.update({ id, status: false });
5645
5827
  }
5646
- }
5828
+ }
5829
+ tslib_1.__decorate([
5830
+ Log(),
5831
+ tslib_1.__metadata("design:type", Function),
5832
+ tslib_1.__metadata("design:paramtypes", [Number]),
5833
+ tslib_1.__metadata("design:returntype", void 0)
5834
+ ], ProductReviewsHasuraGraphQLRepository.prototype, "aproveReview", null);
5835
+ tslib_1.__decorate([
5836
+ Log(),
5837
+ tslib_1.__metadata("design:type", Function),
5838
+ tslib_1.__metadata("design:paramtypes", [Number]),
5839
+ tslib_1.__metadata("design:returntype", void 0)
5840
+ ], ProductReviewsHasuraGraphQLRepository.prototype, "disaproveReview", null);
5647
5841
 
5648
5842
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5649
5843
  constructor({ endpoint, authOptions, interceptors, }) {
@@ -5893,6 +6087,36 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5893
6087
  throw new NotFoundError(`Wishlists from person ${personId} not found`);
5894
6088
  return data;
5895
6089
  }
6090
+ getCategoryBySlug(slug, _shop) {
6091
+ return this.getWishlistBySlug(slug);
6092
+ }
6093
+ async getCategoryByShop(shop) {
6094
+ if (!shop)
6095
+ return;
6096
+ const { data } = await this.find({
6097
+ filters: {
6098
+ shops: { operator: exports.Where.IN, value: [shop] },
6099
+ published: { operator: exports.Where.EQUALS, value: true },
6100
+ isWishlist: { operator: exports.Where.EQUALS, value: true },
6101
+ },
6102
+ options: {
6103
+ enableCount: false,
6104
+ },
6105
+ });
6106
+ return data;
6107
+ }
6108
+ getCategoriesForHome(categoryIds, limit, gender) {
6109
+ return;
6110
+ }
6111
+ mountCategory(category, options) {
6112
+ return;
6113
+ }
6114
+ getChildren(parentId) {
6115
+ return;
6116
+ }
6117
+ isChild(id, parentId) {
6118
+ return;
6119
+ }
5896
6120
  async updateProducts(categoryId, { products }) {
5897
6121
  if ('action' in products && products.action === 'remove') {
5898
6122
  await this.mutation('delete_category_product', ['affected_rows'], {
@@ -5949,37 +6173,25 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5949
6173
  });
5950
6174
  return plainData.metadata;
5951
6175
  }
5952
- getCategoryBySlug(slug, _shop) {
5953
- return this.getWishlistBySlug(slug);
5954
- }
5955
- async getCategoryByShop(shop) {
5956
- if (!shop)
5957
- return;
5958
- const { data } = await this.find({
5959
- filters: {
5960
- shops: { operator: exports.Where.IN, value: [shop] },
5961
- published: { operator: exports.Where.EQUALS, value: true },
5962
- isWishlist: { operator: exports.Where.EQUALS, value: true },
5963
- },
5964
- options: {
5965
- enableCount: false,
5966
- },
5967
- });
5968
- return data;
5969
- }
5970
- getCategoriesForHome(categoryIds, limit, gender) {
5971
- return;
5972
- }
5973
- mountCategory(category, options) {
5974
- return;
5975
- }
5976
- getChildren(parentId) {
5977
- return;
5978
- }
5979
- isChild(id, parentId) {
5980
- return;
5981
- }
5982
- }
6176
+ }
6177
+ tslib_1.__decorate([
6178
+ Log(),
6179
+ tslib_1.__metadata("design:type", Function),
6180
+ tslib_1.__metadata("design:paramtypes", [String]),
6181
+ tslib_1.__metadata("design:returntype", Promise)
6182
+ ], WishlistHasuraGraphQLRepository.prototype, "getWishlistBySlug", null);
6183
+ tslib_1.__decorate([
6184
+ Log(),
6185
+ tslib_1.__metadata("design:type", Function),
6186
+ tslib_1.__metadata("design:paramtypes", [String]),
6187
+ tslib_1.__metadata("design:returntype", Promise)
6188
+ ], WishlistHasuraGraphQLRepository.prototype, "getWishlistByPerson", null);
6189
+ tslib_1.__decorate([
6190
+ Log(),
6191
+ tslib_1.__metadata("design:type", Function),
6192
+ tslib_1.__metadata("design:paramtypes", [String]),
6193
+ tslib_1.__metadata("design:returntype", Promise)
6194
+ ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
5983
6195
 
5984
6196
  Object.defineProperty(exports, 'add', {
5985
6197
  enumerable: true,