@infrab4a/connect 4.9.8 → 4.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js
CHANGED
|
@@ -46,7 +46,11 @@ class Filter extends BaseModel {
|
|
|
46
46
|
static get identifiersFields() {
|
|
47
47
|
return ['id'];
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
|
+
tslib.__decorate([
|
|
51
|
+
classTransformer.Type(() => Category),
|
|
52
|
+
tslib.__metadata("design:type", Array)
|
|
53
|
+
], Filter.prototype, "categories", void 0);
|
|
50
54
|
|
|
51
55
|
class CategoryBase extends BaseModel {
|
|
52
56
|
static get identifiersFields() {
|
|
@@ -2862,7 +2866,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
2862
2866
|
const req = { collection: collectionName, data: find };
|
|
2863
2867
|
try {
|
|
2864
2868
|
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 }));
|
|
2865
|
-
const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
|
|
2869
|
+
const { fields, filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
|
|
2866
2870
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
2867
2871
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
2868
2872
|
const offsets = await this.defineLimits(filters, limits);
|
|
@@ -2901,8 +2905,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
2901
2905
|
.getDoc((_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString())
|
|
2902
2906
|
.get(),
|
|
2903
2907
|
]);
|
|
2904
|
-
else if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
|
|
2908
|
+
else if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset)) {
|
|
2905
2909
|
queries.push(['fromStartAt', limits.offset]);
|
|
2910
|
+
}
|
|
2906
2911
|
}
|
|
2907
2912
|
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
2908
2913
|
queries.push(['limit', limits.limit]);
|
|
@@ -3727,19 +3732,21 @@ class ConnectCollectionService {
|
|
|
3727
3732
|
return new ConnectDocumentService(newDoc.path, this.firestore).withConverter(this.converter);
|
|
3728
3733
|
}
|
|
3729
3734
|
async getDocs() {
|
|
3735
|
+
if (this.startingAt > 0)
|
|
3736
|
+
this.limitBy += this.startingAt;
|
|
3730
3737
|
const constraints = [
|
|
3731
3738
|
...this.wheres,
|
|
3732
3739
|
...this.orderBys,
|
|
3733
|
-
...(this.limitBy ? [this.limitBy] : []),
|
|
3734
|
-
...(this.offsetBy ? [this.offsetBy] : []),
|
|
3735
|
-
...(this.statingAt ? [this.statingAt] : []),
|
|
3736
|
-
...(this.startingAfter ? [this.startingAfter] : []),
|
|
3740
|
+
...(this.limitBy ? [firestore.limit(this.limitBy)] : []),
|
|
3737
3741
|
];
|
|
3738
|
-
return firestore.getDocs(firestore.query(this.reference, ...constraints)).then((docs) =>
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3742
|
+
return firestore.getDocs(firestore.query(this.reference, ...constraints)).then((docs) => {
|
|
3743
|
+
const docsPaginated = this.startingAt > 0 ? docs.docs.slice(this.startingAt, this.limitBy) : docs.docs;
|
|
3744
|
+
return {
|
|
3745
|
+
empty: Boolean(docsPaginated.length),
|
|
3746
|
+
size: docsPaginated.length,
|
|
3747
|
+
docs: docsPaginated.map((doc) => new ConnectBaseDocumentSnapshot(doc)),
|
|
3748
|
+
};
|
|
3749
|
+
});
|
|
3743
3750
|
}
|
|
3744
3751
|
getDoc(id) {
|
|
3745
3752
|
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.converter);
|
|
@@ -3753,15 +3760,15 @@ class ConnectCollectionService {
|
|
|
3753
3760
|
return this;
|
|
3754
3761
|
}
|
|
3755
3762
|
limit(quantity) {
|
|
3756
|
-
this.limitBy =
|
|
3763
|
+
this.limitBy = quantity;
|
|
3757
3764
|
return this;
|
|
3758
3765
|
}
|
|
3759
3766
|
offset(offsetBy) {
|
|
3760
|
-
this.offsetBy =
|
|
3767
|
+
this.offsetBy = offsetBy;
|
|
3761
3768
|
return this;
|
|
3762
3769
|
}
|
|
3763
3770
|
fromStartAt(startingAt) {
|
|
3764
|
-
this.
|
|
3771
|
+
this.startingAt = startingAt;
|
|
3765
3772
|
return this;
|
|
3766
3773
|
}
|
|
3767
3774
|
fromStartAfter(startingAt) {
|
|
@@ -5082,6 +5089,17 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5082
5089
|
],
|
|
5083
5090
|
},
|
|
5084
5091
|
},
|
|
5092
|
+
{
|
|
5093
|
+
categories: {
|
|
5094
|
+
columnName: 'categories',
|
|
5095
|
+
foreignKeyColumn: { category_id: 'id' },
|
|
5096
|
+
fields: [{ category: ['id', 'name', 'slug'] }],
|
|
5097
|
+
bindPersistData: (value) => ({
|
|
5098
|
+
categories: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
5099
|
+
}),
|
|
5100
|
+
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => category === null || category === void 0 ? void 0 : category.category)) || [],
|
|
5101
|
+
},
|
|
5102
|
+
},
|
|
5085
5103
|
],
|
|
5086
5104
|
});
|
|
5087
5105
|
this.filterOptionRepository = filterOptionRepository;
|
package/index.esm.js
CHANGED
|
@@ -9,7 +9,7 @@ import { debug } from 'debug';
|
|
|
9
9
|
import { CustomError } from 'ts-custom-error';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
12
|
-
import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, setDoc, deleteDoc, collection, getDocs, query, where, orderBy,
|
|
12
|
+
import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, setDoc, deleteDoc, collection, limit, getDocs, query, where, orderBy, startAfter, addDoc } from 'firebase/firestore';
|
|
13
13
|
import { ref, uploadBytes } from 'firebase/storage';
|
|
14
14
|
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
15
15
|
|
|
@@ -40,7 +40,11 @@ class Filter extends BaseModel {
|
|
|
40
40
|
static get identifiersFields() {
|
|
41
41
|
return ['id'];
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
__decorate([
|
|
45
|
+
Type(() => Category),
|
|
46
|
+
__metadata("design:type", Array)
|
|
47
|
+
], Filter.prototype, "categories", void 0);
|
|
44
48
|
|
|
45
49
|
class CategoryBase extends BaseModel {
|
|
46
50
|
static get identifiersFields() {
|
|
@@ -2856,7 +2860,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
2856
2860
|
const req = { collection: collectionName, data: find };
|
|
2857
2861
|
try {
|
|
2858
2862
|
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 }));
|
|
2859
|
-
const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
|
|
2863
|
+
const { fields, filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
|
|
2860
2864
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
2861
2865
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
2862
2866
|
const offsets = await this.defineLimits(filters, limits);
|
|
@@ -2895,8 +2899,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
2895
2899
|
.getDoc((_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString())
|
|
2896
2900
|
.get(),
|
|
2897
2901
|
]);
|
|
2898
|
-
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
2902
|
+
else if (isNumber(limits.offset) || isString(limits.offset)) {
|
|
2899
2903
|
queries.push(['fromStartAt', limits.offset]);
|
|
2904
|
+
}
|
|
2900
2905
|
}
|
|
2901
2906
|
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
2902
2907
|
queries.push(['limit', limits.limit]);
|
|
@@ -3721,19 +3726,21 @@ class ConnectCollectionService {
|
|
|
3721
3726
|
return new ConnectDocumentService(newDoc.path, this.firestore).withConverter(this.converter);
|
|
3722
3727
|
}
|
|
3723
3728
|
async getDocs() {
|
|
3729
|
+
if (this.startingAt > 0)
|
|
3730
|
+
this.limitBy += this.startingAt;
|
|
3724
3731
|
const constraints = [
|
|
3725
3732
|
...this.wheres,
|
|
3726
3733
|
...this.orderBys,
|
|
3727
|
-
...(this.limitBy ? [this.limitBy] : []),
|
|
3728
|
-
...(this.offsetBy ? [this.offsetBy] : []),
|
|
3729
|
-
...(this.statingAt ? [this.statingAt] : []),
|
|
3730
|
-
...(this.startingAfter ? [this.startingAfter] : []),
|
|
3734
|
+
...(this.limitBy ? [limit(this.limitBy)] : []),
|
|
3731
3735
|
];
|
|
3732
|
-
return getDocs(query(this.reference, ...constraints)).then((docs) =>
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3736
|
+
return getDocs(query(this.reference, ...constraints)).then((docs) => {
|
|
3737
|
+
const docsPaginated = this.startingAt > 0 ? docs.docs.slice(this.startingAt, this.limitBy) : docs.docs;
|
|
3738
|
+
return {
|
|
3739
|
+
empty: Boolean(docsPaginated.length),
|
|
3740
|
+
size: docsPaginated.length,
|
|
3741
|
+
docs: docsPaginated.map((doc) => new ConnectBaseDocumentSnapshot(doc)),
|
|
3742
|
+
};
|
|
3743
|
+
});
|
|
3737
3744
|
}
|
|
3738
3745
|
getDoc(id) {
|
|
3739
3746
|
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.converter);
|
|
@@ -3747,15 +3754,15 @@ class ConnectCollectionService {
|
|
|
3747
3754
|
return this;
|
|
3748
3755
|
}
|
|
3749
3756
|
limit(quantity) {
|
|
3750
|
-
this.limitBy =
|
|
3757
|
+
this.limitBy = quantity;
|
|
3751
3758
|
return this;
|
|
3752
3759
|
}
|
|
3753
3760
|
offset(offsetBy) {
|
|
3754
|
-
this.offsetBy =
|
|
3761
|
+
this.offsetBy = offsetBy;
|
|
3755
3762
|
return this;
|
|
3756
3763
|
}
|
|
3757
3764
|
fromStartAt(startingAt) {
|
|
3758
|
-
this.
|
|
3765
|
+
this.startingAt = startingAt;
|
|
3759
3766
|
return this;
|
|
3760
3767
|
}
|
|
3761
3768
|
fromStartAfter(startingAt) {
|
|
@@ -5076,6 +5083,17 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5076
5083
|
],
|
|
5077
5084
|
},
|
|
5078
5085
|
},
|
|
5086
|
+
{
|
|
5087
|
+
categories: {
|
|
5088
|
+
columnName: 'categories',
|
|
5089
|
+
foreignKeyColumn: { category_id: 'id' },
|
|
5090
|
+
fields: [{ category: ['id', 'name', 'slug'] }],
|
|
5091
|
+
bindPersistData: (value) => ({
|
|
5092
|
+
categories: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
5093
|
+
}),
|
|
5094
|
+
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => category === null || category === void 0 ? void 0 : category.category)) || [],
|
|
5095
|
+
},
|
|
5096
|
+
},
|
|
5079
5097
|
],
|
|
5080
5098
|
});
|
|
5081
5099
|
this.filterOptionRepository = filterOptionRepository;
|
package/package.json
CHANGED
|
@@ -9,12 +9,12 @@ export declare class ConnectCollectionService<T extends ConnectDocumentData> imp
|
|
|
9
9
|
private orderBys;
|
|
10
10
|
private limitBy;
|
|
11
11
|
private offsetBy;
|
|
12
|
-
private
|
|
12
|
+
private startingAt;
|
|
13
13
|
private startingAfter;
|
|
14
14
|
private converter;
|
|
15
15
|
constructor(path: string, firestore: Firestore);
|
|
16
16
|
add(data: T, id?: string): Promise<ConnectDocumentReference<T>>;
|
|
17
|
-
getDocs(): Promise<ConnectQuerySnapshot<T
|
|
17
|
+
getDocs(): Promise<ConnectQuerySnapshot<T> | any>;
|
|
18
18
|
getDoc(id?: string): ConnectDocumentReference<T>;
|
|
19
19
|
where(attribute: string, operator: ConnectWhereOption, value: any): ConnectCollectionReference<T>;
|
|
20
20
|
order(attribute: string, order: 'asc' | 'desc'): ConnectCollectionReference<T>;
|