@infrab4a/connect 4.4.0-beta.2 → 4.4.0-beta.5

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 (26) hide show
  1. package/index.cjs.js +178 -36
  2. package/index.esm.js +178 -39
  3. package/package.json +1 -1
  4. package/src/domain/catalog/repositories/product.repository.d.ts +1 -1
  5. package/src/domain/shopping/models/subscription/checkout.d.ts +0 -1
  6. package/src/infra/firebase/firestore/index.d.ts +2 -1
  7. package/src/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
  8. package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
  9. package/src/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
  10. package/src/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
  11. package/src/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
  12. package/src/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
  13. package/src/infra/firebase/firestore/services/connect-collection-reference.d.ts +21 -0
  14. package/src/infra/firebase/firestore/services/connect-collection.service.d.ts +32 -0
  15. package/src/infra/firebase/firestore/services/connect-document-reference.d.ts +12 -0
  16. package/src/infra/firebase/firestore/services/connect-document.service.d.ts +17 -0
  17. package/src/infra/firebase/firestore/services/connect-firestore.d.ts +7 -0
  18. package/src/infra/firebase/firestore/services/connect-firestore.service.d.ts +11 -0
  19. package/src/infra/firebase/firestore/services/index.d.ts +6 -0
  20. package/src/infra/firebase/firestore/types/connect-firestore/connect-document-data.type.d.ts +5 -0
  21. package/src/infra/firebase/firestore/types/connect-firestore/connect-document-snapshop.type.d.ts +7 -0
  22. package/src/infra/firebase/firestore/types/connect-firestore/connect-query-snapshot.type.d.ts +7 -0
  23. package/src/infra/firebase/firestore/types/connect-firestore/connect-where-option.type.d.ts +2 -0
  24. package/src/infra/firebase/firestore/types/connect-firestore/index.d.ts +4 -0
  25. package/src/infra/firebase/firestore/types/firestore.repository.type.d.ts +7 -5
  26. package/src/infra/firebase/firestore/types/index.d.ts +1 -0
package/index.cjs.js CHANGED
@@ -2772,7 +2772,7 @@ const withFirestore = (MixinBase) => {
2772
2772
  this.interceptors = options.interceptors;
2773
2773
  }
2774
2774
  collection(path) {
2775
- return firestore.collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
2775
+ return this.firestore.getCollection(path || this.collectionName).withConverter(this.buildModelInstance());
2776
2776
  }
2777
2777
  buildModelInstance() {
2778
2778
  return {
@@ -2823,7 +2823,9 @@ const withGetFirestore = (MixinBase) => {
2823
2823
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
2824
2824
  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 }));
2825
2825
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2826
- const docRef = await firestore.getDoc(firestore.doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
2826
+ const docRef = await this.collection(this.buildCollectionPathForGet(identifiers))
2827
+ .getDoc(Object.values(builded.identifier).shift().toString())
2828
+ .get();
2827
2829
  const data = docRef.data();
2828
2830
  if (lodash.isNil(data))
2829
2831
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
@@ -2874,21 +2876,24 @@ const withFindFirestore = (MixinBase) => {
2874
2876
  (this.fields[firestoreFieldName] ===
2875
2877
  FirestoreFieldType.Array ||
2876
2878
  !this.fields[firestoreFieldName]))
2877
- return [firestore.where(firestoreFieldName, 'array-contains-any', options.value)];
2878
- return [firestore.where(firestoreFieldName, '>=', options.value), firestore.where(firestoreFieldName, '<=', `${options.value}~`)];
2879
+ return [[firestoreFieldName, 'array-contains-any', options.value]];
2880
+ return [
2881
+ [firestoreFieldName, '>=', options.value],
2882
+ [firestoreFieldName, '<=', `${options.value}~`],
2883
+ ];
2879
2884
  }
2880
2885
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN &&
2881
2886
  Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2882
2887
  (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
2883
2888
  !this.fields[firestoreFieldName]))
2884
- return [firestore.where(firestoreFieldName, 'array-contains', options.value)];
2889
+ return [[firestoreFieldName, 'array-contains', options.value]];
2885
2890
  if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value)) {
2886
2891
  return Object.keys(options).reduce((queries, key) => [
2887
2892
  ...queries,
2888
2893
  ...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
2889
2894
  ], []);
2890
2895
  }
2891
- return [firestore.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options)];
2896
+ return [[firestoreFieldName, ((options === null || options === void 0 ? void 0 : options.operator) || '=='), (options === null || options === void 0 ? void 0 : options.value) || options]];
2892
2897
  };
2893
2898
  this.makeFirestoreOrderBy = (filters, fieldsToOrderBy) => {
2894
2899
  const orderByKeys = Object.keys(fieldsToOrderBy || {});
@@ -2899,7 +2904,10 @@ const withFindFirestore = (MixinBase) => {
2899
2904
  filtersKeysWithUnordered.forEach((filterKey) => (fieldsToOrderBy = Object.assign(Object.assign({}, (![exports.Where.EQUALS].includes(is(filters[filterKey]).operator)
2900
2905
  ? { [filterKey]: 'asc' }
2901
2906
  : {})), fieldsToOrderBy)));
2902
- return Object.keys(fieldsToOrderBy).map((fieldName) => firestore.orderBy(fieldName, fieldsToOrderBy[fieldName]));
2907
+ return Object.keys(fieldsToOrderBy).map((fieldName) => [
2908
+ fieldName,
2909
+ fieldsToOrderBy[fieldName],
2910
+ ]);
2903
2911
  };
2904
2912
  }
2905
2913
  async find(find = {}) {
@@ -2911,8 +2919,9 @@ const withFindFirestore = (MixinBase) => {
2911
2919
  const queries = this.makeFirestoreWhere(filters || {});
2912
2920
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
2913
2921
  const offsets = await this.defineLimits(filters, limits);
2914
- const queryArgumments = [...queries, ...ordination, ...offsets];
2915
- const docs = await firestore.getDocs(firestore.query(collection, ...queryArgumments));
2922
+ const docs = await queries
2923
+ .reduce((collection, where) => collection.where(...where), ordination.reduce((collection, ordination) => collection.order(...ordination), offsets.reduce((collection, offset) => collection[offset[0]](offset[1]), collection)))
2924
+ .getDocs();
2916
2925
  const data = docs.docs.map((doc) => doc.data());
2917
2926
  return {
2918
2927
  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,
@@ -2931,12 +2940,17 @@ const withFindFirestore = (MixinBase) => {
2931
2940
  const queries = [];
2932
2941
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
2933
2942
  if (this.model.isModel(limits.offset))
2934
- queries.push(firestore.startAfter(await firestore.getDoc(firestore.doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
2943
+ queries.push([
2944
+ 'fromStartAfter',
2945
+ await this.collection(this.buildCollectionPathForFind(filters))
2946
+ .getDoc((_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString())
2947
+ .get(),
2948
+ ]);
2935
2949
  else if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
2936
- queries.push(firestore.startAt(limits.offset));
2950
+ queries.push(['fromStartAt', limits.offset]);
2937
2951
  }
2938
2952
  if (limits === null || limits === void 0 ? void 0 : limits.limit)
2939
- queries.push(firestore.limit(limits.limit));
2953
+ queries.push(['limit', limits.limit]);
2940
2954
  return queries;
2941
2955
  }
2942
2956
  calculateCount(data, limits) {
@@ -2957,20 +2971,14 @@ const withCreateFirestore = (MixinBase) => {
2957
2971
  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 }));
2958
2972
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2959
2973
  const docRef = await this.save(builded);
2960
- const doc = await firestore.getDoc(docRef);
2961
- 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.data(), intercepted))) || doc.data();
2974
+ const doc = (await docRef.get()).data();
2975
+ 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;
2962
2976
  return docBuilded;
2963
2977
  }
2964
2978
  async save(data) {
2965
- var _a, _b;
2966
- const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
2967
2979
  const collectionPath = this.buildCollectionPathForAdd(data);
2968
2980
  const collection = this.collection(collectionPath);
2969
- if (lodash.isEmpty(id))
2970
- return firestore.addDoc(collection, data);
2971
- const docRef = firestore.doc(collection, id);
2972
- await firestore.setDoc(docRef, data);
2973
- return docRef;
2981
+ return collection.add(data);
2974
2982
  }
2975
2983
  buildCollectionPathForAdd(identifiers) {
2976
2984
  return this.isSubCollection(this)
@@ -3007,13 +3015,13 @@ const withUpdateFirestore = (MixinBase) => {
3007
3015
  var _a, _b, _c, _d;
3008
3016
  const model = new this.model();
3009
3017
  const keyField = model.identifiersFields.shift();
3010
- const docRef = firestore.doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
3018
+ const docRef = this.collection(this.buildCollectionPathForUpdate(data)).getDoc(getValueFromParams(data, keyField).toString());
3011
3019
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
3012
3020
  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 }));
3013
3021
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
3014
- await firestore.setDoc(docRef, builded.toPlain(), { merge: true });
3015
- const docData = await firestore.getDoc(docRef).then((doc) => doc.data());
3016
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
3022
+ await docRef.save(builded.toPlain());
3023
+ const docData = await docRef.get();
3024
+ 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();
3017
3025
  }
3018
3026
  buildCollectionPathForUpdate(identifiers) {
3019
3027
  return this.isSubCollection(this)
@@ -3036,7 +3044,9 @@ const withDeleteFirestore = (MixinBase) => {
3036
3044
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
3037
3045
  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 }));
3038
3046
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3039
- await firestore.deleteDoc(firestore.doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
3047
+ await this.collection(this.buildCollectionPathForRemove(identifiers))
3048
+ .getDoc(Object.values(builded.identifier).shift().toString())
3049
+ .delete();
3040
3050
  await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
3041
3051
  }
3042
3052
  buildCollectionPathForRemove(identifiers) {
@@ -3192,11 +3202,18 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
3192
3202
  };
3193
3203
  }
3194
3204
  async getBeautyProfile(userId) {
3195
- const beautyProfile = await firestore.getDoc(firestore.doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3205
+ const beautyProfile = await this.firestore
3206
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3207
+ .withConverter(this.buildBeautyProfileModelInstance())
3208
+ .getDoc('beautyProfile')
3209
+ .get();
3196
3210
  return beautyProfile.data();
3197
3211
  }
3198
3212
  async checkIfIsSubscriber(userId) {
3199
- const docs = await firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')));
3213
+ const docs = await this.collection('subscription')
3214
+ .where('user.id', '==', userId)
3215
+ .where('status', '==', 'active')
3216
+ .getDocs();
3200
3217
  return !!docs && !!docs.size;
3201
3218
  }
3202
3219
  buildBeautyProfileModelInstance() {
@@ -3230,7 +3247,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3230
3247
  });
3231
3248
  }
3232
3249
  async getCategoryBySlug(slug, shop) {
3233
- const categoryDocs = await firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('slug', '==', slug), firestore.where('shop', '==', shop), firestore.where('published', '==', true)));
3250
+ const categoryDocs = await this.collection(this.collectionName)
3251
+ .where('slug', '==', slug)
3252
+ .where('shop', '==', shop)
3253
+ .where('published', '==', true)
3254
+ .getDocs();
3234
3255
  if (categoryDocs.size > 1)
3235
3256
  throw new DuplicatedResultsError('Query returned duplicated values');
3236
3257
  if (categoryDocs.empty)
@@ -3238,7 +3259,10 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3238
3259
  return categoryDocs.docs[0].data();
3239
3260
  }
3240
3261
  async getCategoriesForHome(categoryIds, limit = 4, gender) {
3241
- const categorySnap = await firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('id', 'in', categoryIds.filter(Boolean)), firestore.where('published', '==', true)));
3262
+ const categorySnap = await this.collection(this.collectionName)
3263
+ .where('id', 'in', categoryIds.filter(Boolean))
3264
+ .where('published', '==', true)
3265
+ .getDocs();
3242
3266
  if (categorySnap.empty)
3243
3267
  throw new NotFoundError('Categories not found');
3244
3268
  const categories = categorySnap.docs.map((doc) => doc.data());
@@ -3257,14 +3281,16 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3257
3281
  for (const productIds of chunks) {
3258
3282
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3259
3283
  break;
3260
- wheres.push(firestore.where('published', '==', true), firestore.where('id', 'in', productIds));
3284
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3261
3285
  if (options === null || options === void 0 ? void 0 : options.hasStock)
3262
- wheres.push(firestore.where('stock.quantity', '>', 0));
3286
+ wheres.push(['stock.quantity', '>', 0]);
3263
3287
  if (options === null || options === void 0 ? void 0 : options.gender)
3264
- wheres.push(firestore.where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
3265
- if (options === null || options === void 0 ? void 0 : options.limit)
3266
- wheres.push(firestore.limit(options === null || options === void 0 ? void 0 : options.limit));
3267
- const productSnap = await firestore.getDocs(firestore.query(this.collection('productsErpVitrine'), ...wheres));
3288
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3289
+ const productSnap = await wheres
3290
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3291
+ ? this.collection('productsErpVitrine').limit(options.limit)
3292
+ : this.collection('productsErpVitrine'))
3293
+ .getDocs();
3268
3294
  if (productSnap.empty)
3269
3295
  continue;
3270
3296
  products.push(...productSnap.docs);
@@ -3595,6 +3621,119 @@ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(with
3595
3621
  }
3596
3622
  }
3597
3623
 
3624
+ class ConnectDocumentService {
3625
+ constructor(path, firestore$1) {
3626
+ this.path = path;
3627
+ this.firestore = firestore$1;
3628
+ this.reference = firestore.doc(this.firestore, this.path).withConverter({
3629
+ toFirestore: (data) => data,
3630
+ fromFirestore: (snapshot) => {
3631
+ return Object.assign({ id: snapshot.id }, snapshot.data());
3632
+ },
3633
+ });
3634
+ }
3635
+ async get() {
3636
+ return await firestore.getDoc(this.reference);
3637
+ }
3638
+ getId() {
3639
+ return this.reference.id;
3640
+ }
3641
+ async save(data) {
3642
+ const doc = await firestore.getDoc(this.reference);
3643
+ if (doc.exists())
3644
+ await firestore.updateDoc(this.reference, data);
3645
+ else
3646
+ await firestore.addDoc(this.reference.parent, data);
3647
+ return this;
3648
+ }
3649
+ async delete() {
3650
+ await firestore.deleteDoc(this.reference);
3651
+ }
3652
+ withConverter(params) {
3653
+ this.reference.withConverter(params);
3654
+ return this;
3655
+ }
3656
+ }
3657
+
3658
+ class ConnectCollectionService {
3659
+ constructor(path, firestore$1) {
3660
+ this.firestore = firestore$1;
3661
+ this.wheres = [];
3662
+ this.orderBys = [];
3663
+ this.reference = firestore.collection(firestore$1, path).withConverter({
3664
+ toFirestore: (data) => data,
3665
+ fromFirestore: (snapshot) => {
3666
+ return Object.assign({ id: snapshot.id }, snapshot.data());
3667
+ },
3668
+ });
3669
+ }
3670
+ async add(data, id) {
3671
+ const newDoc = await this.save(data, id);
3672
+ return new ConnectDocumentService(newDoc.path, this.firestore);
3673
+ }
3674
+ async getDocs() {
3675
+ const constraints = [
3676
+ ...this.wheres,
3677
+ ...this.orderBys,
3678
+ ...(this.limitBy ? [this.limitBy] : []),
3679
+ ...(this.offsetBy ? [this.offsetBy] : []),
3680
+ ...(this.statingAt ? [this.statingAt] : []),
3681
+ ...(this.startingAfter ? [this.startingAfter] : []),
3682
+ ];
3683
+ return firestore.getDocs(firestore.query(this.reference, ...constraints));
3684
+ }
3685
+ getDoc(id) {
3686
+ return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore);
3687
+ }
3688
+ where(attribute, operator, value) {
3689
+ this.wheres.push(firestore.where(attribute, operator, value));
3690
+ return this;
3691
+ }
3692
+ order(attribute, order) {
3693
+ this.orderBys.push(firestore.orderBy(attribute, order));
3694
+ return this;
3695
+ }
3696
+ limit(quantity) {
3697
+ this.limitBy = firestore.limit(quantity);
3698
+ return this;
3699
+ }
3700
+ offset(offsetBy) {
3701
+ this.offsetBy = firestore.startAfter(offsetBy);
3702
+ return this;
3703
+ }
3704
+ fromStartAt(startingAt) {
3705
+ this.statingAt = firestore.startAt(startingAt);
3706
+ return this;
3707
+ }
3708
+ fromStartAfter(startingAt) {
3709
+ this.startingAfter = firestore.startAfter(startingAt);
3710
+ return this;
3711
+ }
3712
+ withConverter(params) {
3713
+ this.reference.withConverter(params);
3714
+ return this;
3715
+ }
3716
+ async save(data, id) {
3717
+ if (lodash.isEmpty(id))
3718
+ return firestore.addDoc(this.reference, data);
3719
+ const docRef = firestore.doc(this.reference, id);
3720
+ await firestore.updateDoc(docRef, data);
3721
+ return docRef;
3722
+ }
3723
+ }
3724
+
3725
+ class ConnectFirestoreService {
3726
+ constructor(firestore) {
3727
+ this.firestore = firestore;
3728
+ }
3729
+ getCollection(path) {
3730
+ return new ConnectCollectionService(path, this.firestore);
3731
+ }
3732
+ getDocument(path) {
3733
+ return new ConnectDocumentService(path, this.firestore);
3734
+ }
3735
+ }
3736
+
3598
3737
  class FirebaseFileUploaderService {
3599
3738
  constructor(storage, baseUrl) {
3600
3739
  this.storage = storage;
@@ -5861,6 +6000,9 @@ exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
5861
6000
  exports.CheckoutSubscription = CheckoutSubscription;
5862
6001
  exports.CheckoutSubscriptionFirestoreRepository = CheckoutSubscriptionFirestoreRepository;
5863
6002
  exports.ClassNameHelper = ClassNameHelper;
6003
+ exports.ConnectCollectionService = ConnectCollectionService;
6004
+ exports.ConnectDocumentService = ConnectDocumentService;
6005
+ exports.ConnectFirestoreService = ConnectFirestoreService;
5864
6006
  exports.Coupon = Coupon;
5865
6007
  exports.CouponFirestoreRepository = CouponFirestoreRepository;
5866
6008
  exports.Debug = Debug;
package/index.esm.js CHANGED
@@ -4,13 +4,13 @@ import { __decorate, __metadata, __rest } from 'tslib';
4
4
  import { plainToInstance, instanceToPlain, Type, Expose } from 'class-transformer';
5
5
  import { parseISO } from 'date-fns';
6
6
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
7
- import { isNil, isArray as isArray$1, first, last, flatten, compact, get, isString, each, unset, isObject as isObject$1, set, isNumber, isEmpty, chunk, isDate, isBoolean, isInteger, isNaN as isNaN$1, sortBy, omit } from 'lodash';
7
+ import { isNil, isArray as isArray$1, first, last, flatten, compact, get, isString, each, unset, isObject as isObject$1, set, isNumber, chunk, isEmpty, isDate, isBoolean, isInteger, isNaN as isNaN$1, sortBy, omit } from 'lodash';
8
8
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
9
9
  import { debug } from 'debug';
10
10
  import { CustomError } from 'ts-custom-error';
11
11
  import axios from 'axios';
12
12
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
13
- import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
13
+ import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, addDoc, deleteDoc, collection, getDocs, query, where, orderBy, limit, startAfter, startAt } from 'firebase/firestore';
14
14
  import { ref, uploadBytes } from 'firebase/storage';
15
15
  import { mutation, query as query$1 } from 'gql-query-builder';
16
16
 
@@ -2748,7 +2748,7 @@ const withFirestore = (MixinBase) => {
2748
2748
  this.interceptors = options.interceptors;
2749
2749
  }
2750
2750
  collection(path) {
2751
- return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
2751
+ return this.firestore.getCollection(path || this.collectionName).withConverter(this.buildModelInstance());
2752
2752
  }
2753
2753
  buildModelInstance() {
2754
2754
  return {
@@ -2799,7 +2799,9 @@ const withGetFirestore = (MixinBase) => {
2799
2799
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
2800
2800
  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 }));
2801
2801
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2802
- const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
2802
+ const docRef = await this.collection(this.buildCollectionPathForGet(identifiers))
2803
+ .getDoc(Object.values(builded.identifier).shift().toString())
2804
+ .get();
2803
2805
  const data = docRef.data();
2804
2806
  if (isNil(data))
2805
2807
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
@@ -2850,21 +2852,24 @@ const withFindFirestore = (MixinBase) => {
2850
2852
  (this.fields[firestoreFieldName] ===
2851
2853
  FirestoreFieldType.Array ||
2852
2854
  !this.fields[firestoreFieldName]))
2853
- return [where(firestoreFieldName, 'array-contains-any', options.value)];
2854
- return [where(firestoreFieldName, '>=', options.value), where(firestoreFieldName, '<=', `${options.value}~`)];
2855
+ return [[firestoreFieldName, 'array-contains-any', options.value]];
2856
+ return [
2857
+ [firestoreFieldName, '>=', options.value],
2858
+ [firestoreFieldName, '<=', `${options.value}~`],
2859
+ ];
2855
2860
  }
2856
2861
  if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
2857
2862
  Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
2858
2863
  (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
2859
2864
  !this.fields[firestoreFieldName]))
2860
- return [where(firestoreFieldName, 'array-contains', options.value)];
2865
+ return [[firestoreFieldName, 'array-contains', options.value]];
2861
2866
  if (isObject$1(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
2862
2867
  return Object.keys(options).reduce((queries, key) => [
2863
2868
  ...queries,
2864
2869
  ...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
2865
2870
  ], []);
2866
2871
  }
2867
- return [where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options)];
2872
+ return [[firestoreFieldName, ((options === null || options === void 0 ? void 0 : options.operator) || '=='), (options === null || options === void 0 ? void 0 : options.value) || options]];
2868
2873
  };
2869
2874
  this.makeFirestoreOrderBy = (filters, fieldsToOrderBy) => {
2870
2875
  const orderByKeys = Object.keys(fieldsToOrderBy || {});
@@ -2875,7 +2880,10 @@ const withFindFirestore = (MixinBase) => {
2875
2880
  filtersKeysWithUnordered.forEach((filterKey) => (fieldsToOrderBy = Object.assign(Object.assign({}, (![Where.EQUALS].includes(is(filters[filterKey]).operator)
2876
2881
  ? { [filterKey]: 'asc' }
2877
2882
  : {})), fieldsToOrderBy)));
2878
- return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
2883
+ return Object.keys(fieldsToOrderBy).map((fieldName) => [
2884
+ fieldName,
2885
+ fieldsToOrderBy[fieldName],
2886
+ ]);
2879
2887
  };
2880
2888
  }
2881
2889
  async find(find = {}) {
@@ -2887,8 +2895,9 @@ const withFindFirestore = (MixinBase) => {
2887
2895
  const queries = this.makeFirestoreWhere(filters || {});
2888
2896
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
2889
2897
  const offsets = await this.defineLimits(filters, limits);
2890
- const queryArgumments = [...queries, ...ordination, ...offsets];
2891
- const docs = await getDocs(query(collection, ...queryArgumments));
2898
+ const docs = await queries
2899
+ .reduce((collection, where) => collection.where(...where), ordination.reduce((collection, ordination) => collection.order(...ordination), offsets.reduce((collection, offset) => collection[offset[0]](offset[1]), collection)))
2900
+ .getDocs();
2892
2901
  const data = docs.docs.map((doc) => doc.data());
2893
2902
  return {
2894
2903
  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,
@@ -2907,12 +2916,17 @@ const withFindFirestore = (MixinBase) => {
2907
2916
  const queries = [];
2908
2917
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
2909
2918
  if (this.model.isModel(limits.offset))
2910
- queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
2919
+ queries.push([
2920
+ 'fromStartAfter',
2921
+ await this.collection(this.buildCollectionPathForFind(filters))
2922
+ .getDoc((_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString())
2923
+ .get(),
2924
+ ]);
2911
2925
  else if (isNumber(limits.offset) || isString(limits.offset))
2912
- queries.push(startAt(limits.offset));
2926
+ queries.push(['fromStartAt', limits.offset]);
2913
2927
  }
2914
2928
  if (limits === null || limits === void 0 ? void 0 : limits.limit)
2915
- queries.push(limit(limits.limit));
2929
+ queries.push(['limit', limits.limit]);
2916
2930
  return queries;
2917
2931
  }
2918
2932
  calculateCount(data, limits) {
@@ -2933,20 +2947,14 @@ const withCreateFirestore = (MixinBase) => {
2933
2947
  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 }));
2934
2948
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2935
2949
  const docRef = await this.save(builded);
2936
- const doc = await getDoc(docRef);
2937
- 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.data(), intercepted))) || doc.data();
2950
+ const doc = (await docRef.get()).data();
2951
+ 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;
2938
2952
  return docBuilded;
2939
2953
  }
2940
2954
  async save(data) {
2941
- var _a, _b;
2942
- const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
2943
2955
  const collectionPath = this.buildCollectionPathForAdd(data);
2944
2956
  const collection = this.collection(collectionPath);
2945
- if (isEmpty(id))
2946
- return addDoc(collection, data);
2947
- const docRef = doc(collection, id);
2948
- await setDoc(docRef, data);
2949
- return docRef;
2957
+ return collection.add(data);
2950
2958
  }
2951
2959
  buildCollectionPathForAdd(identifiers) {
2952
2960
  return this.isSubCollection(this)
@@ -2983,13 +2991,13 @@ const withUpdateFirestore = (MixinBase) => {
2983
2991
  var _a, _b, _c, _d;
2984
2992
  const model = new this.model();
2985
2993
  const keyField = model.identifiersFields.shift();
2986
- const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
2994
+ const docRef = this.collection(this.buildCollectionPathForUpdate(data)).getDoc(getValueFromParams(data, keyField).toString());
2987
2995
  const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2988
2996
  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 }));
2989
2997
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
2990
- await setDoc(docRef, builded.toPlain(), { merge: true });
2991
- const docData = await getDoc(docRef).then((doc) => doc.data());
2992
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
2998
+ await docRef.save(builded.toPlain());
2999
+ const docData = await docRef.get();
3000
+ 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();
2993
3001
  }
2994
3002
  buildCollectionPathForUpdate(identifiers) {
2995
3003
  return this.isSubCollection(this)
@@ -3012,7 +3020,9 @@ const withDeleteFirestore = (MixinBase) => {
3012
3020
  const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
3013
3021
  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 }));
3014
3022
  const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
3015
- await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
3023
+ await this.collection(this.buildCollectionPathForRemove(identifiers))
3024
+ .getDoc(Object.values(builded.identifier).shift().toString())
3025
+ .delete();
3016
3026
  await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
3017
3027
  }
3018
3028
  buildCollectionPathForRemove(identifiers) {
@@ -3168,11 +3178,18 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
3168
3178
  };
3169
3179
  }
3170
3180
  async getBeautyProfile(userId) {
3171
- const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3181
+ const beautyProfile = await this.firestore
3182
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3183
+ .withConverter(this.buildBeautyProfileModelInstance())
3184
+ .getDoc('beautyProfile')
3185
+ .get();
3172
3186
  return beautyProfile.data();
3173
3187
  }
3174
3188
  async checkIfIsSubscriber(userId) {
3175
- const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
3189
+ const docs = await this.collection('subscription')
3190
+ .where('user.id', '==', userId)
3191
+ .where('status', '==', 'active')
3192
+ .getDocs();
3176
3193
  return !!docs && !!docs.size;
3177
3194
  }
3178
3195
  buildBeautyProfileModelInstance() {
@@ -3206,7 +3223,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3206
3223
  });
3207
3224
  }
3208
3225
  async getCategoryBySlug(slug, shop) {
3209
- const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
3226
+ const categoryDocs = await this.collection(this.collectionName)
3227
+ .where('slug', '==', slug)
3228
+ .where('shop', '==', shop)
3229
+ .where('published', '==', true)
3230
+ .getDocs();
3210
3231
  if (categoryDocs.size > 1)
3211
3232
  throw new DuplicatedResultsError('Query returned duplicated values');
3212
3233
  if (categoryDocs.empty)
@@ -3214,7 +3235,10 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3214
3235
  return categoryDocs.docs[0].data();
3215
3236
  }
3216
3237
  async getCategoriesForHome(categoryIds, limit = 4, gender) {
3217
- const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
3238
+ const categorySnap = await this.collection(this.collectionName)
3239
+ .where('id', 'in', categoryIds.filter(Boolean))
3240
+ .where('published', '==', true)
3241
+ .getDocs();
3218
3242
  if (categorySnap.empty)
3219
3243
  throw new NotFoundError('Categories not found');
3220
3244
  const categories = categorySnap.docs.map((doc) => doc.data());
@@ -3233,14 +3257,16 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3233
3257
  for (const productIds of chunks) {
3234
3258
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
3235
3259
  break;
3236
- wheres.push(where('published', '==', true), where('id', 'in', productIds));
3260
+ wheres.push(['published', '==', true], ['id', 'in', productIds]);
3237
3261
  if (options === null || options === void 0 ? void 0 : options.hasStock)
3238
- wheres.push(where('stock.quantity', '>', 0));
3262
+ wheres.push(['stock.quantity', '>', 0]);
3239
3263
  if (options === null || options === void 0 ? void 0 : options.gender)
3240
- wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
3241
- if (options === null || options === void 0 ? void 0 : options.limit)
3242
- wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
3243
- const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
3264
+ wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
3265
+ const productSnap = await wheres
3266
+ .reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
3267
+ ? this.collection('productsErpVitrine').limit(options.limit)
3268
+ : this.collection('productsErpVitrine'))
3269
+ .getDocs();
3244
3270
  if (productSnap.empty)
3245
3271
  continue;
3246
3272
  products.push(...productSnap.docs);
@@ -3571,6 +3597,119 @@ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(with
3571
3597
  }
3572
3598
  }
3573
3599
 
3600
+ class ConnectDocumentService {
3601
+ constructor(path, firestore) {
3602
+ this.path = path;
3603
+ this.firestore = firestore;
3604
+ this.reference = doc(this.firestore, this.path).withConverter({
3605
+ toFirestore: (data) => data,
3606
+ fromFirestore: (snapshot) => {
3607
+ return Object.assign({ id: snapshot.id }, snapshot.data());
3608
+ },
3609
+ });
3610
+ }
3611
+ async get() {
3612
+ return await getDoc(this.reference);
3613
+ }
3614
+ getId() {
3615
+ return this.reference.id;
3616
+ }
3617
+ async save(data) {
3618
+ const doc = await getDoc(this.reference);
3619
+ if (doc.exists())
3620
+ await updateDoc(this.reference, data);
3621
+ else
3622
+ await addDoc(this.reference.parent, data);
3623
+ return this;
3624
+ }
3625
+ async delete() {
3626
+ await deleteDoc(this.reference);
3627
+ }
3628
+ withConverter(params) {
3629
+ this.reference.withConverter(params);
3630
+ return this;
3631
+ }
3632
+ }
3633
+
3634
+ class ConnectCollectionService {
3635
+ constructor(path, firestore) {
3636
+ this.firestore = firestore;
3637
+ this.wheres = [];
3638
+ this.orderBys = [];
3639
+ this.reference = collection(firestore, path).withConverter({
3640
+ toFirestore: (data) => data,
3641
+ fromFirestore: (snapshot) => {
3642
+ return Object.assign({ id: snapshot.id }, snapshot.data());
3643
+ },
3644
+ });
3645
+ }
3646
+ async add(data, id) {
3647
+ const newDoc = await this.save(data, id);
3648
+ return new ConnectDocumentService(newDoc.path, this.firestore);
3649
+ }
3650
+ async getDocs() {
3651
+ const constraints = [
3652
+ ...this.wheres,
3653
+ ...this.orderBys,
3654
+ ...(this.limitBy ? [this.limitBy] : []),
3655
+ ...(this.offsetBy ? [this.offsetBy] : []),
3656
+ ...(this.statingAt ? [this.statingAt] : []),
3657
+ ...(this.startingAfter ? [this.startingAfter] : []),
3658
+ ];
3659
+ return getDocs(query(this.reference, ...constraints));
3660
+ }
3661
+ getDoc(id) {
3662
+ return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore);
3663
+ }
3664
+ where(attribute, operator, value) {
3665
+ this.wheres.push(where(attribute, operator, value));
3666
+ return this;
3667
+ }
3668
+ order(attribute, order) {
3669
+ this.orderBys.push(orderBy(attribute, order));
3670
+ return this;
3671
+ }
3672
+ limit(quantity) {
3673
+ this.limitBy = limit(quantity);
3674
+ return this;
3675
+ }
3676
+ offset(offsetBy) {
3677
+ this.offsetBy = startAfter(offsetBy);
3678
+ return this;
3679
+ }
3680
+ fromStartAt(startingAt) {
3681
+ this.statingAt = startAt(startingAt);
3682
+ return this;
3683
+ }
3684
+ fromStartAfter(startingAt) {
3685
+ this.startingAfter = startAfter(startingAt);
3686
+ return this;
3687
+ }
3688
+ withConverter(params) {
3689
+ this.reference.withConverter(params);
3690
+ return this;
3691
+ }
3692
+ async save(data, id) {
3693
+ if (isEmpty(id))
3694
+ return addDoc(this.reference, data);
3695
+ const docRef = doc(this.reference, id);
3696
+ await updateDoc(docRef, data);
3697
+ return docRef;
3698
+ }
3699
+ }
3700
+
3701
+ class ConnectFirestoreService {
3702
+ constructor(firestore) {
3703
+ this.firestore = firestore;
3704
+ }
3705
+ getCollection(path) {
3706
+ return new ConnectCollectionService(path, this.firestore);
3707
+ }
3708
+ getDocument(path) {
3709
+ return new ConnectDocumentService(path, this.firestore);
3710
+ }
3711
+ }
3712
+
3574
3713
  class FirebaseFileUploaderService {
3575
3714
  constructor(storage, baseUrl) {
3576
3715
  this.storage = storage;
@@ -5692,4 +5831,4 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5692
5831
  }
5693
5832
  }
5694
5833
 
5695
- 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, 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 };
5834
+ 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, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.4.0-beta.2",
3
+ "version": "4.4.0-beta.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -11,5 +11,5 @@ export interface ProductRepository extends CrudRepository<Product> {
11
11
  getBySlug(slug: string): Promise<Product>;
12
12
  fetchReviews(status: ReviewStatusParams): Promise<ReviewWithProductData[]>;
13
13
  cleanShoppingCountFromIds(ids: string[]): Promise<any>;
14
- findCatalog(params: FindRepositoryParams<Product>, mainGender?: Extract<ProductGender, 'female' | 'male'>): Promise<RepositoryFindResult<Product>>;
14
+ findCatalog(params: FindRepositoryParams<Product>, mainGender?: Extract<ProductGender, 'female' | 'male' | 'unisex'>): Promise<RepositoryFindResult<Product>>;
15
15
  }
@@ -11,7 +11,6 @@ export declare class CheckoutSubscription extends BaseModel<CheckoutSubscription
11
11
  userId?: string;
12
12
  discount?: number;
13
13
  subTotalPrice?: number;
14
- shippingPrice?: number;
15
14
  totalPrice?: number;
16
15
  shippingAddress: UserAddress;
17
16
  billingAddress?: UserAddress;
@@ -1,3 +1,4 @@
1
1
  export * from './mixins';
2
- export * from './types';
3
2
  export * from './repositories';
3
+ export * from './services';
4
+ export * from './types';
@@ -1,10 +1,10 @@
1
- import { Firestore } from 'firebase/firestore';
2
1
  import { BaseModelBuilder, ModelBaseStructure, NonFunctionAndIdentifierPropertyNames } from '../../../../domain';
3
2
  import { MergeConstructorParams, MixinCtor } from '../../../../utils';
4
3
  import { FirestoreFieldType } from '../enums';
4
+ import { ConnectFirestore } from '../services';
5
5
  import { FirestoreInterceptors, FirestoreRepository } from '../types';
6
6
  export type FirestoreConstructorParams<Model extends ModelBaseStructure<Model>> = {
7
- firestore: Firestore;
7
+ firestore: ConnectFirestore;
8
8
  collectionName: string;
9
9
  model: BaseModelBuilder<Model>;
10
10
  fields?: Partial<Record<NonFunctionAndIdentifierPropertyNames<Model>, FirestoreFieldType>>;
@@ -1,6 +1,6 @@
1
1
  import { Category, CategoryRepository, Product, Shops } from '../../../../../domain';
2
2
  import { FirestoreConstructorParams } from '../../mixins';
3
- declare const CategoryFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Category> & import("../../../../../domain").CrudRepository<Category, import("../../../../../domain").CrudParams<Category>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Category>, ...any[]]>;
3
+ declare const CategoryFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../../types").FirestoreRepository<Category> & import("../../../../../domain").CrudRepository<Category, import("../../../../../domain").CrudParams<Category>> & import("../../types").FirestoreHelpers, [FirestoreConstructorParams<Category>, ...any[]]>;
4
4
  export declare class CategoryFirestoreRepository extends CategoryFirestoreRepository_base implements CategoryRepository {
5
5
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Category>, 'firestore' | 'interceptors'>);
6
6
  getCategoryBySlug(slug: string, shop: Shops): Promise<Category>;
@@ -1,12 +1,12 @@
1
- import { DocumentData, QueryDocumentSnapshot } from 'firebase/firestore';
2
1
  import { Home, HomeRepository } from '../../../../../domain';
3
2
  import { FirestoreConstructorParams } from '../../mixins';
4
- declare const HomeFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Home> & import("../../../../../domain").CrudRepository<Home, import("../../../../../domain").CrudParams<Home>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Home>, ...any[]]>;
3
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from '../../types';
4
+ declare const HomeFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../../types").FirestoreRepository<Home> & import("../../../../../domain").CrudRepository<Home, import("../../../../../domain").CrudParams<Home>> & import("../../types").FirestoreHelpers, [FirestoreConstructorParams<Home>, ...any[]]>;
5
5
  export declare class HomeFirestoreRepository extends HomeFirestoreRepository_base implements HomeRepository {
6
6
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Home>, 'firestore' | 'interceptors'>);
7
7
  buildModelInstance(): {
8
- toFirestore: (data: Home) => DocumentData;
9
- fromFirestore: (snap: QueryDocumentSnapshot<Home>) => Home;
8
+ toFirestore: (data: Home) => ConnectDocumentData<Home>;
9
+ fromFirestore: (snap: ConnectDocumentSnapshot<Home>) => Home;
10
10
  };
11
11
  private homeToFirestore;
12
12
  private homeCategoryGroupToPlain;
@@ -1,12 +1,12 @@
1
- import { DocumentData, QueryDocumentSnapshot } from 'firebase/firestore';
2
1
  import { Coupon, CouponRepository } from '../../../../../domain';
3
2
  import { FirestoreConstructorParams } from '../../mixins';
4
- declare const CouponFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Coupon> & import("../../../../../domain").CrudRepository<Coupon, import("../../../../../domain").CrudParams<Coupon>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Coupon>, ...any[]]>;
3
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from '../../types';
4
+ declare const CouponFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../../types").FirestoreRepository<Coupon> & import("../../../../../domain").CrudRepository<Coupon, import("../../../../../domain").CrudParams<Coupon>> & import("../../types").FirestoreHelpers, [FirestoreConstructorParams<Coupon>, ...any[]]>;
5
5
  export declare class CouponFirestoreRepository extends CouponFirestoreRepository_base implements CouponRepository {
6
6
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Coupon>, 'firestore' | 'interceptors'>);
7
7
  buildModelInstance(): {
8
- toFirestore: (data: Coupon) => DocumentData;
9
- fromFirestore: (snap: QueryDocumentSnapshot<Coupon>) => Coupon;
8
+ toFirestore: (data: Coupon) => ConnectDocumentData<Coupon>;
9
+ fromFirestore: (snap: ConnectDocumentSnapshot<Coupon>) => Coupon;
10
10
  };
11
11
  }
12
12
  export {};
@@ -1,12 +1,12 @@
1
- import { DocumentData, QueryDocumentSnapshot } from 'firebase/firestore';
2
1
  import { Order, OrderRepository } from '../../../../../domain';
3
2
  import { FirestoreConstructorParams } from '../../mixins';
4
- declare const OrderFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<Order> & import("../../../../../domain").CrudRepository<Order, import("../../../../../domain").CrudParams<Order>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<Order>, ...any[]]>;
3
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from '../../types';
4
+ declare const OrderFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../../types").FirestoreRepository<Order> & import("../../../../../domain").CrudRepository<Order, import("../../../../../domain").CrudParams<Order>> & import("../../types").FirestoreHelpers, [FirestoreConstructorParams<Order>, ...any[]]>;
5
5
  export declare class OrderFirestoreRepository extends OrderFirestoreRepository_base implements OrderRepository {
6
6
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Order>, 'firestore' | 'interceptors'>);
7
7
  buildModelInstance(): {
8
- toFirestore: (data: Order) => DocumentData;
9
- fromFirestore: (snap: QueryDocumentSnapshot<Order>) => Order;
8
+ toFirestore: (data: Order) => ConnectDocumentData<Order>;
9
+ fromFirestore: (snap: ConnectDocumentSnapshot<Order>) => Order;
10
10
  };
11
11
  private orderFromFirestore;
12
12
  }
@@ -1,14 +1,14 @@
1
- import { DocumentData, QueryDocumentSnapshot } from 'firebase/firestore';
2
1
  import { User, UserRepository } from '../../../../../domain';
3
2
  import { FirestoreConstructorParams } from '../../mixins';
4
- declare const UserFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<User> & import("../../../../../domain").CrudRepository<User, import("../../../../../domain").CrudParams<User>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<User>, ...any[]]>;
3
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from '../../types';
4
+ declare const UserFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../../types").FirestoreRepository<User> & import("../../../../../domain").CrudRepository<User, import("../../../../../domain").CrudParams<User>> & import("../../types").FirestoreHelpers, [FirestoreConstructorParams<User>, ...any[]]>;
5
5
  export declare class UserFirestoreRepository extends UserFirestoreRepository_base implements UserRepository {
6
6
  constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<User>, 'firestore' | 'interceptors'>);
7
7
  get(identifiers: Partial<User>): Promise<User>;
8
8
  checkIfExistsByField(field: string, value: string): Promise<boolean>;
9
9
  buildModelInstance(): {
10
- toFirestore: (data: User) => DocumentData;
11
- fromFirestore: (snap: QueryDocumentSnapshot<User>) => User;
10
+ toFirestore: (data: User) => ConnectDocumentData<User>;
11
+ fromFirestore: (snap: ConnectDocumentSnapshot<User>) => User;
12
12
  };
13
13
  private getBeautyProfile;
14
14
  private checkIfIsSubscriber;
@@ -0,0 +1,21 @@
1
+ import { ConnectQuerySnapshop, ConnectWhereOption } from '../types';
2
+ import { ConnectDocumentData } from '../types/connect-firestore/connect-document-data.type';
3
+ import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-snapshop.type';
4
+ import { ConnectDocumentReference } from './connect-document-reference';
5
+ export interface ConnectCollectionReference<T extends ConnectDocumentData> {
6
+ add(data: Partial<T>, id?: string): Promise<ConnectDocumentReference<T>>;
7
+ where(attribute: string, operator: ConnectWhereOption, value: any): ConnectCollectionReference<T>;
8
+ order(attribute: string, order: 'asc' | 'desc'): ConnectCollectionReference<T>;
9
+ limit(quantity: number): ConnectCollectionReference<T>;
10
+ offset(offset: number): ConnectCollectionReference<T>;
11
+ fromStartAt(startAt: number): ConnectCollectionReference<T>;
12
+ fromStartAt(startAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
13
+ fromStartAfter(startAt: number): ConnectCollectionReference<T>;
14
+ fromStartAfter(startAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
15
+ withConverter(converter: {
16
+ toFirestore: (data: T) => ConnectDocumentData<T>;
17
+ fromFirestore: (snap: ConnectDocumentSnapshot<T>) => T;
18
+ }): ConnectCollectionReference<T>;
19
+ getDoc(id?: string): ConnectDocumentReference<T>;
20
+ getDocs(): Promise<ConnectQuerySnapshop<T>>;
21
+ }
@@ -0,0 +1,32 @@
1
+ import { Firestore } from 'firebase/firestore';
2
+ import { ConnectDocumentData, ConnectQuerySnapshop, ConnectWhereOption } from '../types';
3
+ import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-snapshop.type';
4
+ import { ConnectCollectionReference } from './connect-collection-reference';
5
+ import { ConnectDocumentReference } from './connect-document-reference';
6
+ export declare class ConnectCollectionService<T extends ConnectDocumentData> implements ConnectCollectionReference<T> {
7
+ private readonly firestore;
8
+ private reference;
9
+ private wheres;
10
+ private orderBys;
11
+ private limitBy;
12
+ private offsetBy;
13
+ private statingAt;
14
+ private startingAfter;
15
+ constructor(path: string, firestore: Firestore);
16
+ add(data: T, id?: string): Promise<ConnectDocumentReference<T>>;
17
+ getDocs(): Promise<ConnectQuerySnapshop<T>>;
18
+ getDoc(id?: string): ConnectDocumentReference<T>;
19
+ where(attribute: string, operator: ConnectWhereOption, value: any): ConnectCollectionReference<T>;
20
+ order(attribute: string, order: 'asc' | 'desc'): ConnectCollectionReference<T>;
21
+ limit(quantity: number): ConnectCollectionReference<T>;
22
+ offset(offsetBy: number): ConnectCollectionReference<T>;
23
+ fromStartAt(startingAt: number): ConnectCollectionReference<T>;
24
+ fromStartAt(startingAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
25
+ fromStartAfter(startingAt: number): ConnectCollectionReference<T>;
26
+ fromStartAfter(startingAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
27
+ withConverter(params: {
28
+ toFirestore: (data: T) => T;
29
+ fromFirestore: (snapshot: ConnectDocumentSnapshot<T>) => T;
30
+ }): ConnectCollectionReference<T>;
31
+ private save;
32
+ }
@@ -0,0 +1,12 @@
1
+ import { ConnectDocumentData } from '../types/connect-firestore/connect-document-data.type';
2
+ import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-snapshop.type';
3
+ export interface ConnectDocumentReference<T extends ConnectDocumentData> {
4
+ get(): Promise<ConnectDocumentSnapshot<T>>;
5
+ getId(): string;
6
+ save(data: T): Promise<ConnectDocumentReference<T>>;
7
+ delete(): Promise<void>;
8
+ withConverter(converter: {
9
+ toFirestore: (data: T) => T;
10
+ fromFirestore: (snap: ConnectDocumentSnapshot<T>) => T;
11
+ }): ConnectDocumentReference<T>;
12
+ }
@@ -0,0 +1,17 @@
1
+ import { Firestore } from 'firebase/firestore';
2
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from '../types';
3
+ import { ConnectDocumentReference } from './connect-document-reference';
4
+ export declare class ConnectDocumentService<T extends ConnectDocumentData> implements ConnectDocumentReference<T> {
5
+ private path;
6
+ private firestore;
7
+ private reference;
8
+ constructor(path: string, firestore: Firestore);
9
+ get(): Promise<ConnectDocumentSnapshot<T>>;
10
+ getId(): string;
11
+ save(data: T): Promise<ConnectDocumentReference<T>>;
12
+ delete(): Promise<void>;
13
+ withConverter(params: {
14
+ toFirestore: (data: T) => T;
15
+ fromFirestore: (snapshot: ConnectDocumentSnapshot<T>) => T;
16
+ }): ConnectDocumentReference<T>;
17
+ }
@@ -0,0 +1,7 @@
1
+ import { ConnectDocumentData } from '../types';
2
+ import { ConnectCollectionReference } from './connect-collection-reference';
3
+ import { ConnectDocumentReference } from './connect-document-reference';
4
+ export interface ConnectFirestore {
5
+ getCollection<T extends ConnectDocumentData>(path: string): ConnectCollectionReference<T>;
6
+ getDocument<T extends ConnectDocumentData>(path: string): ConnectDocumentReference<T>;
7
+ }
@@ -0,0 +1,11 @@
1
+ import { Firestore } from 'firebase/firestore';
2
+ import { ConnectDocumentData } from '../types';
3
+ import { ConnectCollectionReference } from './connect-collection-reference';
4
+ import { ConnectDocumentReference } from './connect-document-reference';
5
+ import { ConnectFirestore } from './connect-firestore';
6
+ export declare class ConnectFirestoreService implements ConnectFirestore {
7
+ private firestore;
8
+ constructor(firestore: Firestore);
9
+ getCollection<T extends ConnectDocumentData>(path: string): ConnectCollectionReference<T>;
10
+ getDocument<T extends ConnectDocumentData>(path: string): ConnectDocumentReference<T>;
11
+ }
@@ -0,0 +1,6 @@
1
+ export * from './connect-collection-reference';
2
+ export * from './connect-collection.service';
3
+ export * from './connect-document-reference';
4
+ export * from './connect-document.service';
5
+ export * from './connect-firestore';
6
+ export * from './connect-firestore.service';
@@ -0,0 +1,5 @@
1
+ export type ConnectDocumentData<T extends Record<string, any> = Record<string, any>> = {
2
+ [K in keyof T]?: any;
3
+ } & {
4
+ id?: string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { ConnectDocumentData } from './connect-document-data.type';
2
+ export type ConnectDocumentSnapshot<T extends ConnectDocumentData = ConnectDocumentData> = {
3
+ exists(): boolean;
4
+ data(): T | undefined;
5
+ get(fieldPath: string): any;
6
+ id: string;
7
+ };
@@ -0,0 +1,7 @@
1
+ import { ConnectDocumentData } from './connect-document-data.type';
2
+ import { ConnectDocumentSnapshot } from './connect-document-snapshop.type';
3
+ export type ConnectQuerySnapshop<T extends ConnectDocumentData> = {
4
+ docs: ConnectDocumentSnapshot<T>[];
5
+ size: number;
6
+ empty: boolean;
7
+ };
@@ -0,0 +1,2 @@
1
+ import { WhereFilterOp } from 'firebase/firestore';
2
+ export type ConnectWhereOption = `${WhereFilterOp}`;
@@ -0,0 +1,4 @@
1
+ export * from './connect-document-data.type';
2
+ export * from './connect-document-snapshop.type';
3
+ export * from './connect-query-snapshot.type';
4
+ export * from './connect-where-option.type';
@@ -1,16 +1,18 @@
1
- import { CollectionReference, DocumentData, Firestore, QueryDocumentSnapshot } from 'firebase/firestore';
2
1
  import { BaseModelBuilder, ModelBaseStructure, NonFunctionAndIdentifierPropertyNames } from '../../../../domain';
3
2
  import { FirestoreFieldType } from '../enums';
3
+ import { ConnectCollectionReference } from '../services/connect-collection-reference';
4
+ import { ConnectFirestore } from '../services/connect-firestore';
5
+ import { ConnectDocumentData, ConnectDocumentSnapshot } from './connect-firestore';
4
6
  import { FirestoreInterceptors } from './firestore-interceptors.type';
5
7
  export type FirestoreRepository<Model extends ModelBaseStructure<Model>> = {
6
- readonly firestore?: Firestore;
8
+ readonly firestore?: ConnectFirestore;
7
9
  collectionName: string;
8
10
  model: BaseModelBuilder<Model>;
9
- collection(path?: string): CollectionReference<Model>;
11
+ collection(path?: string): ConnectCollectionReference<Model>;
10
12
  fields?: Partial<Record<NonFunctionAndIdentifierPropertyNames<Model>, FirestoreFieldType>>;
11
13
  interceptors?: FirestoreInterceptors<Model>;
12
14
  buildModelInstance(): {
13
- toFirestore: (data: Model) => DocumentData;
14
- fromFirestore: (snap: QueryDocumentSnapshot<Model>) => Model;
15
+ toFirestore: (data: Model) => ConnectDocumentData<Model>;
16
+ fromFirestore: (snap: ConnectDocumentSnapshot<Model>) => Model;
15
17
  };
16
18
  };
@@ -1,3 +1,4 @@
1
+ export * from './connect-firestore';
1
2
  export * from './firestore-interceptors.type';
2
3
  export * from './firestore-sub.repository.type';
3
4
  export * from './firestore.helpers.type';