@infrab4a/connect 4.4.0-beta.7 → 4.4.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.
- package/index.cjs.js +11 -6
- package/index.esm.js +11 -6
- package/package.json +1 -1
- package/src/infra/firebase/firestore/services/connect-collection-reference.d.ts +4 -4
- package/src/infra/firebase/firestore/services/connect-collection.service.d.ts +5 -5
- package/src/infra/firebase/firestore/services/connect-document-reference.d.ts +3 -3
- package/src/infra/firebase/firestore/services/connect-document.service.d.ts +3 -3
- package/src/infra/firebase/firestore/types/connect-firestore/{connect-document-snapshop.type.d.ts → connect-document-snapshot.type.d.ts} +4 -1
- package/src/infra/firebase/firestore/types/connect-firestore/connect-query-snapshot.type.d.ts +2 -2
- package/src/infra/firebase/firestore/types/connect-firestore/index.d.ts +1 -1
- package/teste2.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -3639,7 +3639,6 @@ class ConnectDocumentService {
|
|
|
3639
3639
|
return this.reference.id;
|
|
3640
3640
|
}
|
|
3641
3641
|
async save(data) {
|
|
3642
|
-
console.log('save ConnectDocumentService', data);
|
|
3643
3642
|
const doc = await firestore.getDoc(this.reference);
|
|
3644
3643
|
if (doc.exists())
|
|
3645
3644
|
await firestore.updateDoc(this.reference, data);
|
|
@@ -3651,7 +3650,10 @@ class ConnectDocumentService {
|
|
|
3651
3650
|
await firestore.deleteDoc(this.reference);
|
|
3652
3651
|
}
|
|
3653
3652
|
withConverter(params) {
|
|
3654
|
-
this.reference = this.reference.withConverter(
|
|
3653
|
+
this.reference = this.reference.withConverter({
|
|
3654
|
+
toFirestore: (data) => params.toFirestore(data),
|
|
3655
|
+
fromFirestore: (snapshot, options) => params.fromFirestore(snapshot, options),
|
|
3656
|
+
});
|
|
3655
3657
|
return this;
|
|
3656
3658
|
}
|
|
3657
3659
|
}
|
|
@@ -3670,7 +3672,7 @@ class ConnectCollectionService {
|
|
|
3670
3672
|
}
|
|
3671
3673
|
async add(data, id) {
|
|
3672
3674
|
const newDoc = await this.save(data, id);
|
|
3673
|
-
return new ConnectDocumentService(newDoc.path, this.firestore);
|
|
3675
|
+
return new ConnectDocumentService(newDoc.path, this.firestore).withConverter(this.converter);
|
|
3674
3676
|
}
|
|
3675
3677
|
async getDocs() {
|
|
3676
3678
|
const constraints = [
|
|
@@ -3684,7 +3686,7 @@ class ConnectCollectionService {
|
|
|
3684
3686
|
return firestore.getDocs(firestore.query(this.reference, ...constraints));
|
|
3685
3687
|
}
|
|
3686
3688
|
getDoc(id) {
|
|
3687
|
-
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.
|
|
3689
|
+
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.converter);
|
|
3688
3690
|
}
|
|
3689
3691
|
where(attribute, operator, value) {
|
|
3690
3692
|
this.wheres.push(firestore.where(attribute, operator, value));
|
|
@@ -3711,11 +3713,14 @@ class ConnectCollectionService {
|
|
|
3711
3713
|
return this;
|
|
3712
3714
|
}
|
|
3713
3715
|
withConverter(params) {
|
|
3714
|
-
this.
|
|
3716
|
+
this.converter = {
|
|
3717
|
+
toFirestore: (data) => params.toFirestore(data),
|
|
3718
|
+
fromFirestore: (snapshot, options) => params.fromFirestore(snapshot, options),
|
|
3719
|
+
};
|
|
3720
|
+
this.reference = this.reference.withConverter(this.converter);
|
|
3715
3721
|
return this;
|
|
3716
3722
|
}
|
|
3717
3723
|
async save(data, id) {
|
|
3718
|
-
console.log('save ConnectCollectionService', data, id);
|
|
3719
3724
|
if (lodash.isEmpty(id))
|
|
3720
3725
|
return firestore.addDoc(this.reference, data);
|
|
3721
3726
|
const docRef = firestore.doc(this.reference, id);
|
package/index.esm.js
CHANGED
|
@@ -3615,7 +3615,6 @@ class ConnectDocumentService {
|
|
|
3615
3615
|
return this.reference.id;
|
|
3616
3616
|
}
|
|
3617
3617
|
async save(data) {
|
|
3618
|
-
console.log('save ConnectDocumentService', data);
|
|
3619
3618
|
const doc = await getDoc(this.reference);
|
|
3620
3619
|
if (doc.exists())
|
|
3621
3620
|
await updateDoc(this.reference, data);
|
|
@@ -3627,7 +3626,10 @@ class ConnectDocumentService {
|
|
|
3627
3626
|
await deleteDoc(this.reference);
|
|
3628
3627
|
}
|
|
3629
3628
|
withConverter(params) {
|
|
3630
|
-
this.reference = this.reference.withConverter(
|
|
3629
|
+
this.reference = this.reference.withConverter({
|
|
3630
|
+
toFirestore: (data) => params.toFirestore(data),
|
|
3631
|
+
fromFirestore: (snapshot, options) => params.fromFirestore(snapshot, options),
|
|
3632
|
+
});
|
|
3631
3633
|
return this;
|
|
3632
3634
|
}
|
|
3633
3635
|
}
|
|
@@ -3646,7 +3648,7 @@ class ConnectCollectionService {
|
|
|
3646
3648
|
}
|
|
3647
3649
|
async add(data, id) {
|
|
3648
3650
|
const newDoc = await this.save(data, id);
|
|
3649
|
-
return new ConnectDocumentService(newDoc.path, this.firestore);
|
|
3651
|
+
return new ConnectDocumentService(newDoc.path, this.firestore).withConverter(this.converter);
|
|
3650
3652
|
}
|
|
3651
3653
|
async getDocs() {
|
|
3652
3654
|
const constraints = [
|
|
@@ -3660,7 +3662,7 @@ class ConnectCollectionService {
|
|
|
3660
3662
|
return getDocs(query(this.reference, ...constraints));
|
|
3661
3663
|
}
|
|
3662
3664
|
getDoc(id) {
|
|
3663
|
-
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.
|
|
3665
|
+
return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.converter);
|
|
3664
3666
|
}
|
|
3665
3667
|
where(attribute, operator, value) {
|
|
3666
3668
|
this.wheres.push(where(attribute, operator, value));
|
|
@@ -3687,11 +3689,14 @@ class ConnectCollectionService {
|
|
|
3687
3689
|
return this;
|
|
3688
3690
|
}
|
|
3689
3691
|
withConverter(params) {
|
|
3690
|
-
this.
|
|
3692
|
+
this.converter = {
|
|
3693
|
+
toFirestore: (data) => params.toFirestore(data),
|
|
3694
|
+
fromFirestore: (snapshot, options) => params.fromFirestore(snapshot, options),
|
|
3695
|
+
};
|
|
3696
|
+
this.reference = this.reference.withConverter(this.converter);
|
|
3691
3697
|
return this;
|
|
3692
3698
|
}
|
|
3693
3699
|
async save(data, id) {
|
|
3694
|
-
console.log('save ConnectCollectionService', data, id);
|
|
3695
3700
|
if (isEmpty(id))
|
|
3696
3701
|
return addDoc(this.reference, data);
|
|
3697
3702
|
const docRef = doc(this.reference, id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectQuerySnapshot, ConnectWhereOption } from '../types';
|
|
2
2
|
import { ConnectDocumentData } from '../types/connect-firestore/connect-document-data.type';
|
|
3
|
-
import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-
|
|
3
|
+
import { ConnectDocumentSnapshot, ConnectSnapshotOptions } from '../types/connect-firestore/connect-document-snapshot.type';
|
|
4
4
|
import { ConnectDocumentReference } from './connect-document-reference';
|
|
5
5
|
export interface ConnectCollectionReference<T extends ConnectDocumentData> {
|
|
6
6
|
add(data: Partial<T>, id?: string): Promise<ConnectDocumentReference<T>>;
|
|
@@ -14,8 +14,8 @@ export interface ConnectCollectionReference<T extends ConnectDocumentData> {
|
|
|
14
14
|
fromStartAfter(startAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
|
|
15
15
|
withConverter(converter: {
|
|
16
16
|
toFirestore: (data: T) => ConnectDocumentData<T>;
|
|
17
|
-
fromFirestore: (
|
|
17
|
+
fromFirestore: (snapshot: ConnectDocumentSnapshot<T>, options?: ConnectSnapshotOptions) => T;
|
|
18
18
|
}): ConnectCollectionReference<T>;
|
|
19
19
|
getDoc(id?: string): ConnectDocumentReference<T>;
|
|
20
|
-
getDocs(): Promise<
|
|
20
|
+
getDocs(): Promise<ConnectQuerySnapshot<T>>;
|
|
21
21
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Firestore } from 'firebase/firestore';
|
|
2
|
-
import { ConnectDocumentData,
|
|
3
|
-
import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-snapshop.type';
|
|
2
|
+
import { ConnectDocumentData, ConnectDocumentSnapshot, ConnectQuerySnapshot, ConnectSnapshotOptions, ConnectWhereOption } from '../types';
|
|
4
3
|
import { ConnectCollectionReference } from './connect-collection-reference';
|
|
5
4
|
import { ConnectDocumentReference } from './connect-document-reference';
|
|
6
5
|
export declare class ConnectCollectionService<T extends ConnectDocumentData> implements ConnectCollectionReference<T> {
|
|
@@ -12,9 +11,10 @@ export declare class ConnectCollectionService<T extends ConnectDocumentData> imp
|
|
|
12
11
|
private offsetBy;
|
|
13
12
|
private statingAt;
|
|
14
13
|
private startingAfter;
|
|
14
|
+
private converter;
|
|
15
15
|
constructor(path: string, firestore: Firestore);
|
|
16
16
|
add(data: T, id?: string): Promise<ConnectDocumentReference<T>>;
|
|
17
|
-
getDocs(): Promise<
|
|
17
|
+
getDocs(): Promise<ConnectQuerySnapshot<T>>;
|
|
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>;
|
|
@@ -25,8 +25,8 @@ export declare class ConnectCollectionService<T extends ConnectDocumentData> imp
|
|
|
25
25
|
fromStartAfter(startingAt: number): ConnectCollectionReference<T>;
|
|
26
26
|
fromStartAfter(startingAt: ConnectDocumentReference<T>): ConnectCollectionReference<T>;
|
|
27
27
|
withConverter(params: {
|
|
28
|
-
toFirestore: (data: T) => T
|
|
29
|
-
fromFirestore: (snapshot: ConnectDocumentSnapshot
|
|
28
|
+
toFirestore: (data: T) => ConnectDocumentData<T>;
|
|
29
|
+
fromFirestore: (snapshot: ConnectDocumentSnapshot, options?: ConnectSnapshotOptions) => T;
|
|
30
30
|
}): ConnectCollectionReference<T>;
|
|
31
31
|
private save;
|
|
32
32
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ConnectDocumentData } from '../types/connect-firestore/connect-document-data.type';
|
|
2
|
-
import { ConnectDocumentSnapshot } from '../types/connect-firestore/connect-document-
|
|
2
|
+
import { ConnectDocumentSnapshot, ConnectSnapshotOptions } from '../types/connect-firestore/connect-document-snapshot.type';
|
|
3
3
|
export interface ConnectDocumentReference<T extends ConnectDocumentData> {
|
|
4
4
|
get(): Promise<ConnectDocumentSnapshot<T>>;
|
|
5
5
|
getId(): string;
|
|
6
6
|
save(data: T): Promise<ConnectDocumentReference<T>>;
|
|
7
7
|
delete(): Promise<void>;
|
|
8
8
|
withConverter(converter: {
|
|
9
|
-
toFirestore: (data: T) => T
|
|
10
|
-
fromFirestore: (
|
|
9
|
+
toFirestore: (data: T) => ConnectDocumentData<T>;
|
|
10
|
+
fromFirestore: (snapshot: ConnectDocumentSnapshot<T>, options?: ConnectSnapshotOptions) => T;
|
|
11
11
|
}): ConnectDocumentReference<T>;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Firestore } from 'firebase/firestore';
|
|
2
|
-
import { ConnectDocumentData, ConnectDocumentSnapshot } from '../types';
|
|
2
|
+
import { ConnectDocumentData, ConnectDocumentSnapshot, ConnectSnapshotOptions } from '../types';
|
|
3
3
|
import { ConnectDocumentReference } from './connect-document-reference';
|
|
4
4
|
export declare class ConnectDocumentService<T extends ConnectDocumentData> implements ConnectDocumentReference<T> {
|
|
5
5
|
private path;
|
|
@@ -11,7 +11,7 @@ export declare class ConnectDocumentService<T extends ConnectDocumentData> imple
|
|
|
11
11
|
save(data: T): Promise<ConnectDocumentReference<T>>;
|
|
12
12
|
delete(): Promise<void>;
|
|
13
13
|
withConverter(params: {
|
|
14
|
-
toFirestore: (data: T) => T
|
|
15
|
-
fromFirestore: (snapshot: ConnectDocumentSnapshot<T
|
|
14
|
+
toFirestore: (data: T) => ConnectDocumentData<T>;
|
|
15
|
+
fromFirestore: (snapshot: ConnectDocumentSnapshot<T>, options?: ConnectSnapshotOptions) => T;
|
|
16
16
|
}): ConnectDocumentReference<T>;
|
|
17
17
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ConnectDocumentData } from './connect-document-data.type';
|
|
2
|
+
export type ConnectSnapshotOptions = {
|
|
3
|
+
serverTimestamps?: 'estimate' | 'previous' | 'none';
|
|
4
|
+
};
|
|
2
5
|
export type ConnectDocumentSnapshot<T extends ConnectDocumentData = ConnectDocumentData> = {
|
|
3
6
|
exists(): boolean;
|
|
4
|
-
data(): T
|
|
7
|
+
data(options?: ConnectSnapshotOptions): T;
|
|
5
8
|
get(fieldPath: string): any;
|
|
6
9
|
id: string;
|
|
7
10
|
};
|
package/src/infra/firebase/firestore/types/connect-firestore/connect-query-snapshot.type.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectDocumentData } from './connect-document-data.type';
|
|
2
|
-
import { ConnectDocumentSnapshot } from './connect-document-
|
|
3
|
-
export type
|
|
2
|
+
import { ConnectDocumentSnapshot } from './connect-document-snapshot.type';
|
|
3
|
+
export type ConnectQuerySnapshot<T extends ConnectDocumentData> = {
|
|
4
4
|
docs: ConnectDocumentSnapshot<T>[];
|
|
5
5
|
size: number;
|
|
6
6
|
empty: boolean;
|
package/teste2.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|