@infrab4a/connect 4.25.0-beta.7 → 4.25.0-beta.8

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.
Files changed (40) hide show
  1. package/index.cjs.js +150 -56
  2. package/index.esm.js +150 -56
  3. package/package.json +1 -1
  4. package/src/infra/firebase/firestore/mixins/helpers/cache-key-generator.helper.d.ts +9 -0
  5. package/src/infra/firebase/firestore/mixins/helpers/index.d.ts +1 -0
  6. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  7. package/src/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +1 -1
  8. package/src/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +1 -1
  9. package/src/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +1 -1
  10. package/src/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +1 -1
  11. package/src/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +1 -1
  12. package/src/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +1 -1
  13. package/src/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +1 -1
  14. package/src/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +1 -1
  15. package/src/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +1 -1
  16. package/src/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +1 -1
  17. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +1 -1
  18. package/src/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +1 -1
  19. package/src/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +1 -1
  20. package/src/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +1 -1
  21. package/src/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +1 -1
  22. package/src/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +1 -1
  23. package/src/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +1 -1
  24. package/src/infra/firebase/firestore/repositories/users/subscription-materialization-firestore.repository.d.ts +1 -1
  25. package/src/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +1 -1
  26. package/src/infra/firebase/firestore/repositories/users/subscription-summary-firestore.repository.d.ts +1 -1
  27. package/src/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +1 -1
  28. package/src/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +1 -1
  29. package/src/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -1
  30. package/src/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +1 -1
  31. package/src/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +1 -1
  32. package/src/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +1 -1
  33. package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +1 -1
  34. package/src/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +1 -1
  35. package/src/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +1 -1
  36. package/src/infra/hasura-graphql/repositories/catalog/product-errors-hasura-graphql.repository.d.ts +1 -1
  37. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +1 -1
  38. package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -1
  39. package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +1 -1
  40. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +1 -1
package/index.esm.js CHANGED
@@ -3598,24 +3598,39 @@ class MD5GeneratorHelper {
3598
3598
  }
3599
3599
  }
3600
3600
 
3601
+ class FirestoreCacheKeyGeneratorHelper {
3602
+ static generateGetCacheKey(model, identifiers) {
3603
+ const sortedEntries = Object.entries(identifiers).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
3604
+ const keyParts = [];
3605
+ for (const [key, value] of sortedEntries) {
3606
+ keyParts.push(`${key}:${value}`);
3607
+ }
3608
+ return `${model.name.toLowerCase()}:get:${keyParts.join(':')}`;
3609
+ }
3610
+ static generateFindCacheKey(model, findParams) {
3611
+ const md5 = MD5GeneratorHelper.generateMD5(findParams);
3612
+ return `${model.name.toLowerCase()}:find:${md5}`;
3613
+ }
3614
+ }
3615
+
3601
3616
  const withGetFirestore = (MixinBase) => {
3602
3617
  return class GetFirestore extends MixinBase {
3603
- async get(identifiers) {
3604
- var _a, _b, _c, _d, _e, _f;
3618
+ async get(identifiers, options) {
3619
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3605
3620
  const logger = this.logger.with('get');
3606
3621
  const collectionName = this.buildCollectionPathForGet(identifiers);
3607
3622
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
3608
3623
  const req = { collection: collectionName, data: identifiers };
3609
- if ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) {
3610
- const cacheKey = CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(this.model, identifiers);
3624
+ if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled) !== false) {
3625
+ const cacheKey = FirestoreCacheKeyGeneratorHelper.generateGetCacheKey(this.model, identifiers);
3611
3626
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
3612
3627
  if (cachedData) {
3613
3628
  logger.log({ req, res: 'Dados recuperados do cache', cacheKey });
3614
- return this.model.toInstance(cachedData);
3629
+ return this.model.toInstance(JSON.parse(cachedData));
3615
3630
  }
3616
3631
  }
3617
3632
  try {
3618
- const intercepted = await ((_c = (_b = this.interceptors) === null || _b === void 0 ? void 0 : _b.request) === null || _c === void 0 ? void 0 : _c.call(_b, { instance }));
3633
+ const intercepted = await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { instance }));
3619
3634
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3620
3635
  const docRef = await this.collection(collectionName)
3621
3636
  .getDoc(Object.values(builded.identifier).shift().toString())
@@ -3623,14 +3638,14 @@ const withGetFirestore = (MixinBase) => {
3623
3638
  const data = docRef.data();
3624
3639
  if (isNil(data))
3625
3640
  throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers).shift()}' not found`);
3626
- const res = ((_e = (_d = this.interceptors) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.call(_d, data, intercepted)) || data;
3641
+ const res = (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;
3627
3642
  logger.log({ req, res });
3628
- if ((_f = this.cache) === null || _f === void 0 ? void 0 : _f.cacheAdapter) {
3629
- const cacheKey = CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(this.model, identifiers);
3643
+ if (((_g = this.cache) === null || _g === void 0 ? void 0 : _g.cacheAdapter) && ((_h = options === null || options === void 0 ? void 0 : options.cache) === null || _h === void 0 ? void 0 : _h.enabled) !== false) {
3644
+ const cacheKey = FirestoreCacheKeyGeneratorHelper.generateGetCacheKey(this.model, identifiers);
3630
3645
  await this.cache.cacheAdapter.set({
3631
3646
  key: cacheKey,
3632
- data: res,
3633
- expirationInSeconds: this.cache.ttlDefault,
3647
+ data: JSON.stringify((res === null || res === void 0 ? void 0 : res.toPlain()) || res),
3648
+ expirationInSeconds: ((_j = options === null || options === void 0 ? void 0 : options.cache) === null || _j === void 0 ? void 0 : _j.ttl) || this.cache.ttlDefault,
3634
3649
  });
3635
3650
  logger.log({ req, message: 'Dados salvos no cache', cacheKey });
3636
3651
  }
@@ -3723,15 +3738,26 @@ const withFindFirestore = (MixinBase) => {
3723
3738
  ]);
3724
3739
  };
3725
3740
  }
3726
- async find(find = {}) {
3727
- var _a, _b, _c, _d, _e, _f;
3741
+ generateCacheKey(findParams) {
3742
+ return FirestoreCacheKeyGeneratorHelper.generateFindCacheKey(this.model, findParams);
3743
+ }
3744
+ async find(find = {}, options) {
3745
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
3728
3746
  const logger = this.logger.with('find');
3747
+ if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled) !== false) {
3748
+ const cacheKey = this.generateCacheKey(find);
3749
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
3750
+ if (cachedData) {
3751
+ logger.log(`Dados recuperados do cache: ${cacheKey}`);
3752
+ return JSON.parse(cachedData);
3753
+ }
3754
+ }
3729
3755
  const collectionName = this.buildCollectionPathForFind(find.filters);
3730
3756
  const collection = this.collection(collectionName);
3731
- 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;
3757
+ const enableCount = (_d = (_c = find === null || find === void 0 ? void 0 : find.options) === null || _c === void 0 ? void 0 : _c.enableCount) !== null && _d !== void 0 ? _d : true;
3732
3758
  const req = { collection: collectionName, data: find };
3733
3759
  try {
3734
- 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 }));
3760
+ const intercepted = await ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.request) === null || _f === void 0 ? void 0 : _f.call(_e, { find }));
3735
3761
  const { fields, filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
3736
3762
  const queries = this.makeFirestoreWhere(filters || {});
3737
3763
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
@@ -3741,10 +3767,19 @@ const withFindFirestore = (MixinBase) => {
3741
3767
  .getDocs();
3742
3768
  const data = docs.docs.map((doc) => doc.data());
3743
3769
  const res = {
3744
- 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,
3770
+ data: (await ((_h = (_g = this.interceptors) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.call(_g, data, intercepted))) || data,
3745
3771
  count: enableCount ? this.calculateCount(data, limits) : Infinity,
3746
3772
  };
3747
3773
  logger.log({ req, queries, ordination, offsets, res });
3774
+ if (((_j = this.cache) === null || _j === void 0 ? void 0 : _j.cacheAdapter) && ((_k = options === null || options === void 0 ? void 0 : options.cache) === null || _k === void 0 ? void 0 : _k.enabled) !== false) {
3775
+ const cacheKey = this.generateCacheKey(find);
3776
+ await this.cache.cacheAdapter.set({
3777
+ key: cacheKey,
3778
+ data: JSON.stringify(res),
3779
+ expirationInSeconds: ((_l = options === null || options === void 0 ? void 0 : options.cache) === null || _l === void 0 ? void 0 : _l.ttl) || this.cache.ttlDefault,
3780
+ });
3781
+ logger.log(`Dados salvos no cache: ${cacheKey}`);
3782
+ }
3748
3783
  return res;
3749
3784
  }
3750
3785
  catch (error) {
@@ -3848,24 +3883,41 @@ const withUpdateFirestore = (MixinBase) => {
3848
3883
  return options === null || options === void 0 ? void 0 : options.value;
3849
3884
  };
3850
3885
  return class UpdateFirestore extends MixinBase {
3886
+ getIdentifiersFromData(data) {
3887
+ const identifiers = {};
3888
+ const model = new this.model();
3889
+ const keyField = model.identifiersFields.shift();
3890
+ const identifierValue = getValueFromParams(data, keyField);
3891
+ identifiers[keyField] = identifierValue;
3892
+ return identifiers;
3893
+ }
3894
+ generateCacheKey(identifiers) {
3895
+ return FirestoreCacheKeyGeneratorHelper.generateGetCacheKey(this.model, identifiers);
3896
+ }
3851
3897
  async update(data) {
3852
- var _a, _b, _c, _d;
3898
+ var _a, _b, _c, _d, _e;
3853
3899
  const logger = this.logger.with('update');
3854
3900
  const collectionName = this.buildCollectionPathForUpdate(data);
3855
3901
  const model = new this.model();
3856
3902
  const keyField = model.identifiersFields.shift();
3857
3903
  const req = { collection: collectionName, data };
3904
+ if ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) {
3905
+ const identifiers = this.getIdentifiersFromData(data);
3906
+ const cacheKey = this.generateCacheKey(identifiers);
3907
+ await this.cache.cacheAdapter.remove(cacheKey);
3908
+ logger.log(`Cache removido: ${cacheKey}`);
3909
+ }
3858
3910
  try {
3859
3911
  const identifiers = getValueFromParams(data, keyField);
3860
3912
  const docRef = this.collection(collectionName).getDoc(identifiers.toString());
3861
3913
  if (!(await docRef.get()).data())
3862
3914
  throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
3863
3915
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3864
- 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 }));
3916
+ const intercepted = await ((_c = (_b = this.interceptors) === null || _b === void 0 ? void 0 : _b.request) === null || _c === void 0 ? void 0 : _c.call(_b, { instance: plainFromData }));
3865
3917
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
3866
3918
  await docRef.save(builded.toPlain());
3867
3919
  const docData = await docRef.get();
3868
- 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();
3920
+ const res = ((_e = (_d = this.interceptors) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.call(_d, docData.data(), intercepted)) || docData.data();
3869
3921
  logger.log({ req, res, identifiers });
3870
3922
  return res;
3871
3923
  }
@@ -3891,17 +3943,25 @@ const withUpdateFirestore = (MixinBase) => {
3891
3943
 
3892
3944
  const withDeleteFirestore = (MixinBase) => {
3893
3945
  return class DeleteFirestore extends MixinBase {
3946
+ generateCacheKey(identifiers) {
3947
+ return FirestoreCacheKeyGeneratorHelper.generateGetCacheKey(this.model, identifiers);
3948
+ }
3894
3949
  async delete(identifiers) {
3895
- var _a, _b, _c, _d;
3950
+ var _a, _b, _c, _d, _e;
3896
3951
  const logger = this.logger.with('delete');
3897
3952
  const collectionName = this.buildCollectionPathForRemove(identifiers);
3898
3953
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
3899
3954
  const req = { collection: collectionName, data: identifiers };
3955
+ if ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) {
3956
+ const cacheKey = this.generateCacheKey(identifiers);
3957
+ await this.cache.cacheAdapter.remove(cacheKey);
3958
+ logger.log(`Cache removido: ${cacheKey}`);
3959
+ }
3900
3960
  try {
3901
- 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 }));
3961
+ const intercepted = await ((_c = (_b = this.interceptors) === null || _b === void 0 ? void 0 : _b.request) === null || _c === void 0 ? void 0 : _c.call(_b, { instance }));
3902
3962
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3903
3963
  await this.collection(collectionName).getDoc(Object.values(builded.identifier).shift().toString()).delete();
3904
- await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
3964
+ await ((_e = (_d = this.interceptors) === null || _d === void 0 ? void 0 : _d.response) === null || _e === void 0 ? void 0 : _e.call(_d, instance, intercepted));
3905
3965
  logger.log({ req, res: undefined });
3906
3966
  }
3907
3967
  catch (error) {
@@ -4146,12 +4206,13 @@ class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFire
4146
4206
  }
4147
4207
 
4148
4208
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4149
- constructor({ firestore, interceptors }) {
4209
+ constructor({ firestore, interceptors, cache, }) {
4150
4210
  super({
4151
4211
  firestore,
4152
4212
  collectionName: 'dms',
4153
4213
  model: Home,
4154
4214
  interceptors,
4215
+ cache,
4155
4216
  });
4156
4217
  this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
4157
4218
  var _a, _b, _c;
@@ -4208,89 +4269,97 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
4208
4269
  }
4209
4270
 
4210
4271
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4211
- constructor({ firestore, interceptors }) {
4272
+ constructor({ firestore, interceptors, cache, }) {
4212
4273
  super({
4213
4274
  firestore,
4214
4275
  collectionName: 'shopMenus',
4215
4276
  model: ShopMenu,
4216
4277
  interceptors,
4278
+ cache,
4217
4279
  });
4218
4280
  }
4219
4281
  }
4220
4282
 
4221
4283
  class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4222
- constructor({ firestore, interceptors, }) {
4284
+ constructor({ firestore, interceptors, cache, }) {
4223
4285
  super({
4224
4286
  firestore,
4225
4287
  collectionName: 'shopSettings',
4226
4288
  model: ShopSettings,
4227
4289
  interceptors,
4290
+ cache,
4228
4291
  });
4229
4292
  }
4230
4293
  }
4231
4294
 
4232
4295
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4233
- constructor({ firestore, interceptors }) {
4296
+ constructor({ firestore, interceptors, cache, }) {
4234
4297
  super({
4235
4298
  firestore,
4236
4299
  collectionName: 'buy2win',
4237
4300
  model: Buy2Win,
4238
4301
  interceptors,
4302
+ cache,
4239
4303
  });
4240
4304
  }
4241
4305
  }
4242
4306
 
4243
4307
  class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4244
- constructor({ firestore, interceptors, }) {
4308
+ constructor({ firestore, interceptors, cache, }) {
4245
4309
  super({
4246
4310
  firestore,
4247
4311
  collectionName: 'dashboardCampaignsAuto',
4248
4312
  model: CampaignDashboard,
4249
4313
  interceptors,
4314
+ cache,
4250
4315
  });
4251
4316
  }
4252
4317
  }
4253
4318
 
4254
4319
  class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4255
- constructor({ firestore, interceptors, }) {
4320
+ constructor({ firestore, interceptors, cache, }) {
4256
4321
  super({
4257
4322
  firestore,
4258
4323
  collectionName: 'hashtagCampaignsAuto',
4259
4324
  model: CampaignHashtag,
4260
4325
  interceptors,
4326
+ cache,
4261
4327
  });
4262
4328
  }
4263
4329
  }
4264
4330
 
4265
4331
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4266
- constructor({ firestore, interceptors }) {
4332
+ constructor({ firestore, interceptors, cache, }) {
4267
4333
  super({
4268
4334
  firestore,
4269
4335
  collectionName: 'checkouts',
4270
4336
  model: Checkout,
4271
4337
  interceptors,
4338
+ cache,
4272
4339
  });
4273
4340
  }
4274
4341
  }
4275
4342
 
4276
4343
  class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4277
- constructor({ firestore, interceptors, }) {
4344
+ constructor({ firestore, interceptors, cache, }) {
4278
4345
  super({
4279
4346
  firestore,
4280
4347
  collectionName: 'checkoutsSubscription',
4281
4348
  model: CheckoutSubscription,
4282
4349
  interceptors,
4350
+ cache,
4283
4351
  });
4284
4352
  }
4285
4353
  }
4286
4354
 
4287
4355
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4288
- constructor({ firestore, interceptors }) {
4356
+ constructor({ firestore, interceptors, cache, }) {
4289
4357
  super({
4290
4358
  firestore,
4291
4359
  collectionName: 'coupons',
4292
4360
  model: Coupon,
4293
4361
  interceptors,
4362
+ cache,
4294
4363
  });
4295
4364
  }
4296
4365
  buildModelInstance() {
@@ -4313,12 +4382,13 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
4313
4382
  }
4314
4383
 
4315
4384
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4316
- constructor({ firestore, interceptors }) {
4385
+ constructor({ firestore, interceptors, cache, }) {
4317
4386
  super({
4318
4387
  firestore,
4319
4388
  collectionName: 'orders',
4320
4389
  model: Order,
4321
4390
  interceptors,
4391
+ cache,
4322
4392
  fields: {
4323
4393
  status: FirestoreFieldType.String,
4324
4394
  },
@@ -4350,22 +4420,24 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
4350
4420
  }
4351
4421
 
4352
4422
  class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
4353
- constructor({ firestore, interceptors }) {
4423
+ constructor({ firestore, interceptors, cache, }) {
4354
4424
  super({
4355
4425
  firestore,
4356
4426
  interceptors,
4427
+ cache,
4357
4428
  });
4358
4429
  this.collectionName = 'legacyOrders';
4359
4430
  }
4360
4431
  }
4361
4432
 
4362
4433
  class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4363
- constructor({ firestore, interceptors, }) {
4434
+ constructor({ firestore, interceptors, cache, }) {
4364
4435
  super({
4365
4436
  firestore,
4366
4437
  collectionName: 'paymentBlockedAttempts',
4367
4438
  model: OrderBlocked,
4368
4439
  interceptors,
4440
+ cache,
4369
4441
  });
4370
4442
  }
4371
4443
  async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
@@ -4397,130 +4469,141 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
4397
4469
  }
4398
4470
 
4399
4471
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4400
- constructor({ firestore, interceptors }) {
4472
+ constructor({ firestore, interceptors, cache, }) {
4401
4473
  super({
4402
4474
  firestore,
4403
4475
  collectionName: 'payments',
4404
4476
  model: Payment,
4405
4477
  interceptors,
4478
+ cache,
4406
4479
  });
4407
4480
  }
4408
4481
  }
4409
4482
 
4410
4483
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4411
- constructor({ firestore, interceptors, }) {
4484
+ constructor({ firestore, interceptors, cache, }) {
4412
4485
  super({
4413
4486
  firestore,
4414
4487
  collectionName: 'subscriptionPlans',
4415
4488
  model: SubscriptionPlan,
4416
4489
  interceptors,
4490
+ cache,
4417
4491
  });
4418
4492
  }
4419
4493
  }
4420
4494
 
4421
4495
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4422
- constructor({ firestore, interceptors }) {
4496
+ constructor({ firestore, interceptors, cache, }) {
4423
4497
  super({
4424
4498
  firestore,
4425
4499
  collectionName: 'leads',
4426
4500
  model: Lead,
4427
4501
  interceptors,
4502
+ cache,
4428
4503
  });
4429
4504
  }
4430
4505
  }
4431
4506
 
4432
4507
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4433
- constructor({ firestore, interceptors }, parentRepository) {
4508
+ constructor({ firestore, interceptors, cache, }, parentRepository) {
4434
4509
  super({
4435
4510
  firestore,
4436
4511
  collectionName: 'editions',
4437
4512
  parentIdField: 'subscriptionId',
4438
4513
  model: Edition,
4439
4514
  interceptors,
4515
+ cache,
4440
4516
  });
4441
4517
  this.parentRepository = parentRepository;
4442
4518
  }
4443
4519
  }
4444
4520
 
4445
4521
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4446
- constructor({ firestore, interceptors, }) {
4522
+ constructor({ firestore, interceptors, cache, }) {
4447
4523
  super({
4448
4524
  firestore,
4449
4525
  collectionName: 'subscription',
4450
4526
  model: Subscription,
4451
4527
  interceptors,
4528
+ cache,
4452
4529
  });
4453
4530
  }
4454
4531
  }
4455
4532
 
4456
4533
  class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4457
- constructor({ firestore, interceptors }) {
4534
+ constructor({ firestore, interceptors, cache, }) {
4458
4535
  super({
4459
4536
  firestore,
4460
4537
  collectionName: 'subscriptionMaterialization',
4461
4538
  model: SubscriptionMaterialization,
4462
4539
  interceptors,
4540
+ cache,
4463
4541
  });
4464
4542
  }
4465
4543
  }
4466
4544
 
4467
4545
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4468
- constructor({ firestore, interceptors }, parentRepository) {
4546
+ constructor({ firestore, interceptors, cache, }, parentRepository) {
4469
4547
  super({
4470
4548
  firestore,
4471
4549
  collectionName: 'payments',
4472
4550
  parentIdField: 'subscriptionId',
4473
4551
  model: SubscriptionPayment,
4474
4552
  interceptors,
4553
+ cache,
4475
4554
  });
4476
4555
  this.parentRepository = parentRepository;
4477
4556
  }
4478
4557
  }
4479
4558
 
4480
4559
  class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4481
- constructor({ firestore, interceptors, }) {
4560
+ constructor({ firestore, interceptors, cache, }) {
4482
4561
  super({
4483
4562
  firestore,
4484
4563
  collectionName: 'subscriptionSummary',
4485
4564
  model: SubscriptionSummary,
4486
4565
  interceptors,
4566
+ cache,
4487
4567
  });
4488
4568
  }
4489
4569
  }
4490
4570
 
4491
4571
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4492
- constructor({ firestore, interceptors }, parentRepository) {
4572
+ constructor({ firestore, interceptors, cache, }, parentRepository) {
4493
4573
  super({
4494
4574
  firestore,
4495
4575
  collectionName: 'address',
4496
4576
  parentIdField: 'userId',
4497
4577
  model: UserAddress,
4498
4578
  interceptors,
4579
+ cache,
4499
4580
  });
4500
4581
  this.parentRepository = parentRepository;
4501
4582
  }
4502
4583
  }
4503
4584
 
4504
4585
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4505
- constructor({ firestore, interceptors }, parentRepository) {
4586
+ constructor({ firestore, interceptors, cache, }, parentRepository) {
4506
4587
  super({
4507
4588
  firestore,
4508
4589
  collectionName: 'CX',
4509
4590
  parentIdField: 'userId',
4510
4591
  model: BeautyProfile,
4511
4592
  interceptors,
4593
+ cache,
4512
4594
  });
4513
4595
  this.parentRepository = parentRepository;
4514
4596
  }
4515
4597
  }
4516
4598
 
4517
4599
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4518
- constructor({ firestore, interceptors }) {
4600
+ constructor({ firestore, interceptors, cache, }) {
4519
4601
  super({
4520
4602
  firestore,
4521
4603
  collectionName: 'users',
4522
4604
  model: User,
4523
4605
  interceptors,
4606
+ cache,
4524
4607
  });
4525
4608
  }
4526
4609
  async get(identifiers) {
@@ -4580,13 +4663,14 @@ __decorate([
4580
4663
  ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
4581
4664
 
4582
4665
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4583
- constructor({ firestore, interceptors }, parentRepository) {
4666
+ constructor({ firestore, interceptors, cache, }, parentRepository) {
4584
4667
  super({
4585
4668
  firestore,
4586
4669
  collectionName: 'payment_method',
4587
4670
  parentIdField: 'userId',
4588
4671
  model: UserPaymentMethod,
4589
4672
  interceptors,
4673
+ cache,
4590
4674
  });
4591
4675
  this.parentRepository = parentRepository;
4592
4676
  }
@@ -5253,7 +5337,7 @@ __decorate([
5253
5337
  ], ProductErrorsHasuraGraphQL.prototype, "product", void 0);
5254
5338
 
5255
5339
  class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5256
- constructor({ endpoint, authOptions, interceptors, }) {
5340
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
5257
5341
  super({
5258
5342
  tableName: 'category_collection_children',
5259
5343
  model: CategoryCollectionChildren,
@@ -5284,12 +5368,13 @@ class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGr
5284
5368
  },
5285
5369
  },
5286
5370
  ],
5371
+ cache,
5287
5372
  });
5288
5373
  }
5289
5374
  }
5290
5375
 
5291
5376
  class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5292
- constructor({ endpoint, authOptions, interceptors, }) {
5377
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
5293
5378
  super({
5294
5379
  tableName: 'category_filter',
5295
5380
  model: CategoryFilter,
@@ -5371,6 +5456,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
5371
5456
  },
5372
5457
  },
5373
5458
  ],
5459
+ cache,
5374
5460
  });
5375
5461
  }
5376
5462
  deleteByCategory(categoryId) {
@@ -5840,7 +5926,7 @@ __decorate([
5840
5926
  ], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
5841
5927
 
5842
5928
  class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5843
- constructor({ endpoint, authOptions, interceptors, }) {
5929
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
5844
5930
  super({
5845
5931
  tableName: 'category_product',
5846
5932
  model: CategoryProduct,
@@ -5848,6 +5934,7 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
5848
5934
  authOptions,
5849
5935
  interceptors,
5850
5936
  fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
5937
+ cache,
5851
5938
  });
5852
5939
  }
5853
5940
  async removeProductFromCategory(categoryId, productId) {
@@ -5874,7 +5961,7 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
5874
5961
  }
5875
5962
 
5876
5963
  class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5877
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
5964
+ constructor({ endpoint, authOptions, interceptors, cache, }, filterOptionRepository, categoryFilterRepository) {
5878
5965
  super({
5879
5966
  tableName: 'filter',
5880
5967
  model: Filter,
@@ -5914,6 +6001,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
5914
6001
  },
5915
6002
  },
5916
6003
  ],
6004
+ cache,
5917
6005
  });
5918
6006
  this.filterOptionRepository = filterOptionRepository;
5919
6007
  this.categoryFilterRepository = categoryFilterRepository;
@@ -6000,7 +6088,7 @@ __decorate([
6000
6088
  ], FilterHasuraGraphQLRepository.prototype, "deleteOptions", null);
6001
6089
 
6002
6090
  class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6003
- constructor({ endpoint, authOptions, interceptors, }) {
6091
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
6004
6092
  super({
6005
6093
  tableName: 'filter_option',
6006
6094
  model: FilterOption,
@@ -6014,18 +6102,20 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
6014
6102
  { createdAt: { columnName: 'created_at' } },
6015
6103
  { updatedAt: { columnName: 'updated_at' } },
6016
6104
  ],
6105
+ cache,
6017
6106
  });
6018
6107
  }
6019
6108
  }
6020
6109
 
6021
6110
  class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6022
- constructor({ endpoint, authOptions, interceptors, }, productRepository) {
6111
+ constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
6023
6112
  super({
6024
6113
  tableName: 'product_errors',
6025
6114
  model: ProductErrorsHasuraGraphQL,
6026
6115
  endpoint,
6027
6116
  authOptions,
6028
6117
  interceptors,
6118
+ cache,
6029
6119
  fields: [
6030
6120
  {
6031
6121
  productId: {
@@ -6739,7 +6829,7 @@ __decorate([
6739
6829
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
6740
6830
 
6741
6831
  class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6742
- constructor({ endpoint, authOptions, interceptors, }) {
6832
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
6743
6833
  super({
6744
6834
  tableName: 'product_review',
6745
6835
  model: ProductReview,
@@ -6763,6 +6853,7 @@ class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
6763
6853
  { createdAt: { columnName: 'created_at' } },
6764
6854
  { updatedAt: { columnName: 'updated_at' } },
6765
6855
  ],
6856
+ cache,
6766
6857
  });
6767
6858
  }
6768
6859
  async updateManyStatus(reviews) {
@@ -6804,13 +6895,14 @@ __decorate([
6804
6895
  ], ProductReviewHasuraGraphQLRepository.prototype, "disaproveReview", null);
6805
6896
 
6806
6897
  class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6807
- constructor({ endpoint, authOptions, interceptors, }) {
6898
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
6808
6899
  super({
6809
6900
  tableName: 'product_stock_notification',
6810
6901
  model: ProductStockNotification,
6811
6902
  endpoint,
6812
6903
  authOptions,
6813
6904
  interceptors,
6905
+ cache,
6814
6906
  fields: [
6815
6907
  'id',
6816
6908
  { productId: { columnName: 'product_id' } },
@@ -6865,13 +6957,14 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
6865
6957
  }
6866
6958
 
6867
6959
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6868
- constructor({ endpoint, authOptions, interceptors, }) {
6960
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
6869
6961
  super({
6870
6962
  tableName: 'product',
6871
6963
  model: VariantHasuraGraphQL,
6872
6964
  endpoint,
6873
6965
  authOptions,
6874
6966
  interceptors,
6967
+ cache,
6875
6968
  fields: [
6876
6969
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
6877
6970
  { firestoreId: { columnName: 'firestore_id' } },
@@ -6978,13 +7071,14 @@ class WishlistHasuraGraphQL extends Wishlist {
6978
7071
  }
6979
7072
 
6980
7073
  class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
6981
- constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
7074
+ constructor({ endpoint, authOptions, interceptors, cache, }, categoryProductRepository) {
6982
7075
  super({
6983
7076
  tableName: 'category',
6984
7077
  model: WishlistHasuraGraphQL,
6985
7078
  endpoint,
6986
7079
  authOptions,
6987
7080
  interceptors,
7081
+ cache,
6988
7082
  fields: [
6989
7083
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
6990
7084
  { firestoreId: { columnName: 'firestore_id' } },