@visiolab/effect-firebase 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +81 -2
- package/dist/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/app/App.d.mts +27 -0
- package/dist/app/App.mjs +27 -0
- package/dist/app/index.d.mts +2 -0
- package/dist/app/index.mjs +1 -0
- package/dist/firestore/Collection.d.mts +423 -0
- package/dist/firestore/Collection.mjs +133 -0
- package/dist/firestore/CollectionGroup.d.mts +164 -0
- package/dist/firestore/CollectionGroup.mjs +84 -0
- package/dist/firestore/DocumentPath.d.mts +95 -0
- package/dist/firestore/DocumentPath.mjs +71 -0
- package/dist/firestore/DocumentSnapshot.d.mts +239 -0
- package/dist/firestore/DocumentSnapshot.mjs +134 -0
- package/dist/firestore/FieldValue.d.mts +332 -0
- package/dist/firestore/FieldValue.mjs +256 -0
- package/dist/firestore/Firestore.d.mts +1165 -0
- package/dist/firestore/Firestore.mjs +274 -0
- package/dist/firestore/FirestoreModel.d.mts +1232 -0
- package/dist/firestore/FirestoreModel.mjs +586 -0
- package/dist/firestore/FirestoreSchema.d.mts +567 -0
- package/dist/firestore/FirestoreSchema.mjs +419 -0
- package/dist/firestore/FirestoreValue.d.mts +145 -0
- package/dist/firestore/FirestoreValue.mjs +87 -0
- package/dist/firestore/GeoPoint.d.mts +90 -0
- package/dist/firestore/GeoPoint.mjs +75 -0
- package/dist/firestore/Patch.d.mts +73 -0
- package/dist/firestore/Patch.mjs +57 -0
- package/dist/firestore/QuerySnapshot.d.mts +107 -0
- package/dist/firestore/QuerySnapshot.mjs +43 -0
- package/dist/firestore/Timestamp.d.mts +273 -0
- package/dist/firestore/Timestamp.mjs +255 -0
- package/dist/firestore/index.d.mts +14 -0
- package/dist/firestore/index.mjs +14 -0
- package/dist/firestore/internal/collection.mjs +156 -0
- package/dist/firestore/internal/collectionGroup.mjs +64 -0
- package/dist/firestore/internal/documentPath.d.mts +4 -0
- package/dist/firestore/internal/documentPath.mjs +42 -0
- package/dist/firestore/internal/documentSnapshot.mjs +63 -0
- package/dist/firestore/internal/fieldValue.d.mts +11 -0
- package/dist/firestore/internal/fieldValue.mjs +88 -0
- package/dist/firestore/internal/firestore.mjs +145 -0
- package/dist/firestore/internal/firestoreError.d.mts +29 -0
- package/dist/firestore/internal/firestoreError.mjs +30 -0
- package/dist/firestore/internal/firestoreModel.mjs +719 -0
- package/dist/firestore/internal/firestoreSchema.mjs +123 -0
- package/dist/firestore/internal/firestoreValue.mjs +108 -0
- package/dist/firestore/internal/firestoreValueWalk.d.mts +58 -0
- package/dist/firestore/internal/firestoreValueWalk.mjs +223 -0
- package/dist/firestore/internal/geoPoint.d.mts +4 -0
- package/dist/firestore/internal/geoPoint.mjs +39 -0
- package/dist/firestore/internal/patch.mjs +19 -0
- package/dist/firestore/internal/querySnapshot.mjs +24 -0
- package/dist/firestore/internal/schemaAST.mjs +35 -0
- package/dist/firestore/internal/snapshotExtra.mjs +35 -0
- package/dist/firestore/internal/streamFromListener.mjs +12 -0
- package/dist/firestore/internal/timestamp.d.mts +4 -0
- package/dist/firestore/internal/timestamp.mjs +66 -0
- package/dist/firestore/internal/timestampSchema.mjs +31 -0
- package/dist/firestore/internal/transactionFromCallback.mjs +66 -0
- package/dist/functions/Callable.d.mts +654 -0
- package/dist/functions/Callable.mjs +450 -0
- package/dist/functions/CallableError.d.mts +297 -0
- package/dist/functions/CallableError.mjs +256 -0
- package/dist/functions/CallableMiddleware.d.mts +213 -0
- package/dist/functions/CallableMiddleware.mjs +52 -0
- package/dist/functions/CallableRequest.d.mts +166 -0
- package/dist/functions/CallableRequest.mjs +18 -0
- package/dist/functions/Caller.d.mts +103 -0
- package/dist/functions/Caller.mjs +115 -0
- package/dist/functions/DocumentTrigger.d.mts +795 -0
- package/dist/functions/DocumentTrigger.mjs +566 -0
- package/dist/functions/FirebaseFunction.d.mts +79 -0
- package/dist/functions/FirebaseFunction.mjs +4 -0
- package/dist/functions/FunctionGroup.d.mts +175 -0
- package/dist/functions/FunctionGroup.mjs +64 -0
- package/dist/functions/index.d.mts +9 -0
- package/dist/functions/index.mjs +9 -0
- package/dist/functions/internal/callable.mjs +167 -0
- package/dist/functions/internal/callableMiddleware.d.mts +19 -0
- package/dist/functions/internal/callableMiddleware.mjs +15 -0
- package/dist/functions/internal/callableRequest.mjs +6 -0
- package/dist/functions/internal/documentTrigger.d.mts +10 -0
- package/dist/functions/internal/documentTrigger.mjs +73 -0
- package/dist/functions/internal/firebaseFunction.d.mts +5 -0
- package/dist/functions/internal/firebaseFunction.mjs +24 -0
- package/dist/functions/internal/functionGroup.mjs +36 -0
- package/package.json +66 -3
- package/src/app/App.ts +24 -0
- package/src/app/index.ts +7 -0
- package/src/firestore/Collection.ts +520 -0
- package/src/firestore/CollectionGroup.ts +245 -0
- package/src/firestore/DocumentPath.ts +114 -0
- package/src/firestore/DocumentSnapshot.ts +308 -0
- package/src/firestore/FieldValue.ts +375 -0
- package/src/firestore/Firestore.ts +1432 -0
- package/src/firestore/FirestoreModel.ts +1884 -0
- package/src/firestore/FirestoreSchema.ts +643 -0
- package/src/firestore/FirestoreValue.ts +207 -0
- package/src/firestore/GeoPoint.ts +105 -0
- package/src/firestore/Patch.ts +117 -0
- package/src/firestore/QuerySnapshot.ts +150 -0
- package/src/firestore/Timestamp.ts +302 -0
- package/src/firestore/index.ts +67 -0
- package/src/firestore/internal/collection.ts +246 -0
- package/src/firestore/internal/collectionGroup.ts +81 -0
- package/src/firestore/internal/documentPath.ts +53 -0
- package/src/firestore/internal/documentSnapshot.ts +117 -0
- package/src/firestore/internal/fieldValue.ts +119 -0
- package/src/firestore/internal/firestore.ts +322 -0
- package/src/firestore/internal/firestoreError.ts +36 -0
- package/src/firestore/internal/firestoreModel.ts +1242 -0
- package/src/firestore/internal/firestoreSchema.ts +218 -0
- package/src/firestore/internal/firestoreValue.ts +202 -0
- package/src/firestore/internal/firestoreValueWalk.ts +349 -0
- package/src/firestore/internal/geoPoint.ts +59 -0
- package/src/firestore/internal/patch.ts +21 -0
- package/src/firestore/internal/querySnapshot.ts +39 -0
- package/src/firestore/internal/schemaAST.ts +83 -0
- package/src/firestore/internal/snapshotExtra.ts +47 -0
- package/src/firestore/internal/streamFromListener.ts +27 -0
- package/src/firestore/internal/timestamp.ts +119 -0
- package/src/firestore/internal/timestampSchema.ts +42 -0
- package/src/firestore/internal/transactionFromCallback.ts +106 -0
- package/src/functions/Callable.ts +855 -0
- package/src/functions/CallableError.ts +348 -0
- package/src/functions/CallableMiddleware.ts +279 -0
- package/src/functions/CallableRequest.ts +207 -0
- package/src/functions/Caller.ts +141 -0
- package/src/functions/DocumentTrigger.ts +927 -0
- package/src/functions/FirebaseFunction.ts +96 -0
- package/src/functions/FunctionGroup.ts +225 -0
- package/src/functions/index.ts +62 -0
- package/src/functions/internal/callable.ts +272 -0
- package/src/functions/internal/callableMiddleware.ts +54 -0
- package/src/functions/internal/callableRequest.ts +8 -0
- package/src/functions/internal/documentTrigger.ts +143 -0
- package/src/functions/internal/firebaseFunction.ts +58 -0
- package/src/functions/internal/functionGroup.ts +47 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Equal, Inspectable, Option } from "effect";
|
|
2
|
+
declare namespace GeoPoint_d_exports {
|
|
3
|
+
export { GeoPoint, isGeoPoint, make, makeUnsafe };
|
|
4
|
+
}
|
|
5
|
+
declare const TypeId = "~@visiolab/effect-firebase/firestore/GeoPoint";
|
|
6
|
+
/**
|
|
7
|
+
* A place on the globe, stored the way Firestore stores it.
|
|
8
|
+
*
|
|
9
|
+
* Two geopoints are equal when their latitudes and longitudes are.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link FirestoreSchema.GeoPoint} for the schema of this value
|
|
12
|
+
*
|
|
13
|
+
* @stability unstable
|
|
14
|
+
* @category models
|
|
15
|
+
* @since 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
export interface GeoPoint extends Equal.Equal, Inspectable.Inspectable {
|
|
18
|
+
readonly [TypeId]: typeof TypeId;
|
|
19
|
+
/** Degrees north of the equator, between -90 and 90. */
|
|
20
|
+
readonly latitude: number;
|
|
21
|
+
/** Degrees east of the prime meridian, between -180 and 180. */
|
|
22
|
+
readonly longitude: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether `u` is a {@link GeoPoint} built by this module.
|
|
26
|
+
*
|
|
27
|
+
* An SDK's own `GeoPoint` is not one.
|
|
28
|
+
*
|
|
29
|
+
* @stability unstable
|
|
30
|
+
* @category guards
|
|
31
|
+
* @since 0.2.0
|
|
32
|
+
*/
|
|
33
|
+
export declare const isGeoPoint: (u: unknown) => u is GeoPoint;
|
|
34
|
+
/**
|
|
35
|
+
* Builds a geopoint from a latitude and a longitude, throwing when either is
|
|
36
|
+
* out of range.
|
|
37
|
+
*
|
|
38
|
+
* **When to use**
|
|
39
|
+
*
|
|
40
|
+
* Use for coordinates known to be valid, such as constants. Use {@link make}
|
|
41
|
+
* for coordinates you have not checked.
|
|
42
|
+
*
|
|
43
|
+
* **Details**
|
|
44
|
+
*
|
|
45
|
+
* Throws unless `latitude` is a number from -90 to 90 and `longitude` a number
|
|
46
|
+
* from -180 to 180.
|
|
47
|
+
*
|
|
48
|
+
* @example Building a geopoint
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { GeoPoint } from "@visiolab/effect-firebase/firestore";
|
|
51
|
+
*
|
|
52
|
+
* const berlin = GeoPoint.makeUnsafe(52.52, 13.405);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @see {@link make} for the same check returning an `Option`
|
|
56
|
+
*
|
|
57
|
+
* @stability unstable
|
|
58
|
+
* @category constructors
|
|
59
|
+
* @since 0.2.0
|
|
60
|
+
*/
|
|
61
|
+
export declare const makeUnsafe: (latitude: number, longitude: number) => GeoPoint;
|
|
62
|
+
/**
|
|
63
|
+
* Builds a geopoint from a latitude and a longitude, or `None` when either is
|
|
64
|
+
* out of range.
|
|
65
|
+
*
|
|
66
|
+
* **When to use**
|
|
67
|
+
*
|
|
68
|
+
* Use when the coordinates come from outside the program and may be invalid.
|
|
69
|
+
*
|
|
70
|
+
* **Details**
|
|
71
|
+
*
|
|
72
|
+
* Returns `None` unless `latitude` is a number from -90 to 90 and `longitude`
|
|
73
|
+
* a number from -180 to 180.
|
|
74
|
+
*
|
|
75
|
+
* @example Building a geopoint from untrusted input
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { GeoPoint } from "@visiolab/effect-firebase/firestore";
|
|
78
|
+
*
|
|
79
|
+
* GeoPoint.make(52.52, 13.405); // Option.some(...)
|
|
80
|
+
* GeoPoint.make(91, 0); // Option.none()
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @see {@link makeUnsafe} for the same check throwing instead
|
|
84
|
+
*
|
|
85
|
+
* @stability unstable
|
|
86
|
+
* @category constructors
|
|
87
|
+
* @since 0.2.0
|
|
88
|
+
*/
|
|
89
|
+
export declare const make: (latitude: number, longitude: number) => Option.Option<GeoPoint>;
|
|
90
|
+
export { GeoPoint_d_exports };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { isGeoPoint as isGeoPoint$1, make as make$1, makeUnsafe as makeUnsafe$1 } from "./internal/geoPoint.mjs";
|
|
3
|
+
// src/firestore/GeoPoint.ts
|
|
4
|
+
var GeoPoint_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
isGeoPoint: () => isGeoPoint,
|
|
6
|
+
make: () => make,
|
|
7
|
+
makeUnsafe: () => makeUnsafe
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether `u` is a {@link GeoPoint} built by this module.
|
|
11
|
+
*
|
|
12
|
+
* An SDK's own `GeoPoint` is not one.
|
|
13
|
+
*
|
|
14
|
+
* @stability unstable
|
|
15
|
+
* @category guards
|
|
16
|
+
* @since 0.2.0
|
|
17
|
+
*/
|
|
18
|
+
const isGeoPoint = isGeoPoint$1;
|
|
19
|
+
/**
|
|
20
|
+
* Builds a geopoint from a latitude and a longitude, throwing when either is
|
|
21
|
+
* out of range.
|
|
22
|
+
*
|
|
23
|
+
* **When to use**
|
|
24
|
+
*
|
|
25
|
+
* Use for coordinates known to be valid, such as constants. Use {@link make}
|
|
26
|
+
* for coordinates you have not checked.
|
|
27
|
+
*
|
|
28
|
+
* **Details**
|
|
29
|
+
*
|
|
30
|
+
* Throws unless `latitude` is a number from -90 to 90 and `longitude` a number
|
|
31
|
+
* from -180 to 180.
|
|
32
|
+
*
|
|
33
|
+
* @example Building a geopoint
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { GeoPoint } from "@visiolab/effect-firebase/firestore";
|
|
36
|
+
*
|
|
37
|
+
* const berlin = GeoPoint.makeUnsafe(52.52, 13.405);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @see {@link make} for the same check returning an `Option`
|
|
41
|
+
*
|
|
42
|
+
* @stability unstable
|
|
43
|
+
* @category constructors
|
|
44
|
+
* @since 0.2.0
|
|
45
|
+
*/
|
|
46
|
+
const makeUnsafe = makeUnsafe$1;
|
|
47
|
+
/**
|
|
48
|
+
* Builds a geopoint from a latitude and a longitude, or `None` when either is
|
|
49
|
+
* out of range.
|
|
50
|
+
*
|
|
51
|
+
* **When to use**
|
|
52
|
+
*
|
|
53
|
+
* Use when the coordinates come from outside the program and may be invalid.
|
|
54
|
+
*
|
|
55
|
+
* **Details**
|
|
56
|
+
*
|
|
57
|
+
* Returns `None` unless `latitude` is a number from -90 to 90 and `longitude`
|
|
58
|
+
* a number from -180 to 180.
|
|
59
|
+
*
|
|
60
|
+
* @example Building a geopoint from untrusted input
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { GeoPoint } from "@visiolab/effect-firebase/firestore";
|
|
63
|
+
*
|
|
64
|
+
* GeoPoint.make(52.52, 13.405); // Option.some(...)
|
|
65
|
+
* GeoPoint.make(91, 0); // Option.none()
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @see {@link makeUnsafe} for the same check throwing instead
|
|
69
|
+
*
|
|
70
|
+
* @stability unstable
|
|
71
|
+
* @category constructors
|
|
72
|
+
* @since 0.2.0
|
|
73
|
+
*/
|
|
74
|
+
const make = make$1;
|
|
75
|
+
export { GeoPoint_exports, isGeoPoint, make, makeUnsafe };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Inspectable } from "effect";
|
|
2
|
+
declare namespace Patch_d_exports {
|
|
3
|
+
export { Replace, isReplace, replace };
|
|
4
|
+
}
|
|
5
|
+
declare const ReplaceTypeId = "~@visiolab/effect-firebase/firestore/Patch/Replace";
|
|
6
|
+
/**
|
|
7
|
+
* A struct written whole, as the map `value`. Built by {@link replace}.
|
|
8
|
+
*
|
|
9
|
+
* **Details**
|
|
10
|
+
*
|
|
11
|
+
* Unlike the sentinels in {@link FieldValue}, it never reaches Firestore. It
|
|
12
|
+
* only tells the update how to write the struct, and is the plain map by the
|
|
13
|
+
* time the update is encoded.
|
|
14
|
+
*
|
|
15
|
+
* @stability unstable
|
|
16
|
+
* @category models
|
|
17
|
+
* @since 0.2.0
|
|
18
|
+
*/
|
|
19
|
+
export interface Replace<A> extends Inspectable.Inspectable {
|
|
20
|
+
readonly [ReplaceTypeId]: typeof ReplaceTypeId;
|
|
21
|
+
/** What the struct holds once the update lands. */
|
|
22
|
+
readonly value: A;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether `u` is a {@link Replace}.
|
|
26
|
+
*
|
|
27
|
+
* @stability unstable
|
|
28
|
+
* @category guards
|
|
29
|
+
* @since 0.2.0
|
|
30
|
+
*/
|
|
31
|
+
export declare const isReplace: (u: unknown) => u is Replace<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Marks a {@link FirestoreModel.Struct} field in a patch to be written whole,
|
|
34
|
+
* rather than field by field.
|
|
35
|
+
*
|
|
36
|
+
* **When to use**
|
|
37
|
+
*
|
|
38
|
+
* Use to replace a struct field outright, dropping any keys the new value leaves
|
|
39
|
+
* out. It is also the safe choice when the struct may not be in the document
|
|
40
|
+
* yet: a nested patch writes only some of its fields there, while `replace`
|
|
41
|
+
* writes all of them.
|
|
42
|
+
*
|
|
43
|
+
* **Details**
|
|
44
|
+
*
|
|
45
|
+
* `value` is the whole struct, in the shape `setDoc` writes it in. A plain
|
|
46
|
+
* object in the same place is a nested patch that only touches the fields it
|
|
47
|
+
* names. A field declared with a plain `Schema.Struct` is a value, always
|
|
48
|
+
* written whole, and takes neither.
|
|
49
|
+
*
|
|
50
|
+
* @example Replacing a struct
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { Schema } from "effect";
|
|
53
|
+
* import { FirestoreModel, Patch } from "@visiolab/effect-firebase/firestore";
|
|
54
|
+
*
|
|
55
|
+
* class User extends FirestoreModel.Class<User>("User")({
|
|
56
|
+
* address: FirestoreModel.Struct({ city: Schema.String, zip: Schema.String }),
|
|
57
|
+
* }) {}
|
|
58
|
+
*
|
|
59
|
+
* // Writes `address` as `{ city: "Berlin", zip: "10115" }`, whatever it held.
|
|
60
|
+
* User.update.make({ address: Patch.replace({ city: "Berlin", zip: "10115" }) });
|
|
61
|
+
*
|
|
62
|
+
* // Writes `address.city` only, and leaves `address.zip` as it is.
|
|
63
|
+
* User.update.make({ address: { city: "Berlin" } });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @see {@link Firestore.With.updateDoc} for writing the patch
|
|
67
|
+
*
|
|
68
|
+
* @stability unstable
|
|
69
|
+
* @category constructors
|
|
70
|
+
* @since 0.2.0
|
|
71
|
+
*/
|
|
72
|
+
export declare const replace: <const A>(value: A) => Replace<A>;
|
|
73
|
+
export { Patch_d_exports };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { isReplace as isReplace$1, replace as replace$1 } from "./internal/patch.mjs";
|
|
3
|
+
// src/firestore/Patch.ts
|
|
4
|
+
var Patch_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
isReplace: () => isReplace,
|
|
6
|
+
replace: () => replace
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether `u` is a {@link Replace}.
|
|
10
|
+
*
|
|
11
|
+
* @stability unstable
|
|
12
|
+
* @category guards
|
|
13
|
+
* @since 0.2.0
|
|
14
|
+
*/
|
|
15
|
+
const isReplace = isReplace$1;
|
|
16
|
+
/**
|
|
17
|
+
* Marks a {@link FirestoreModel.Struct} field in a patch to be written whole,
|
|
18
|
+
* rather than field by field.
|
|
19
|
+
*
|
|
20
|
+
* **When to use**
|
|
21
|
+
*
|
|
22
|
+
* Use to replace a struct field outright, dropping any keys the new value leaves
|
|
23
|
+
* out. It is also the safe choice when the struct may not be in the document
|
|
24
|
+
* yet: a nested patch writes only some of its fields there, while `replace`
|
|
25
|
+
* writes all of them.
|
|
26
|
+
*
|
|
27
|
+
* **Details**
|
|
28
|
+
*
|
|
29
|
+
* `value` is the whole struct, in the shape `setDoc` writes it in. A plain
|
|
30
|
+
* object in the same place is a nested patch that only touches the fields it
|
|
31
|
+
* names. A field declared with a plain `Schema.Struct` is a value, always
|
|
32
|
+
* written whole, and takes neither.
|
|
33
|
+
*
|
|
34
|
+
* @example Replacing a struct
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { Schema } from "effect";
|
|
37
|
+
* import { FirestoreModel, Patch } from "@visiolab/effect-firebase/firestore";
|
|
38
|
+
*
|
|
39
|
+
* class User extends FirestoreModel.Class<User>("User")({
|
|
40
|
+
* address: FirestoreModel.Struct({ city: Schema.String, zip: Schema.String }),
|
|
41
|
+
* }) {}
|
|
42
|
+
*
|
|
43
|
+
* // Writes `address` as `{ city: "Berlin", zip: "10115" }`, whatever it held.
|
|
44
|
+
* User.update.make({ address: Patch.replace({ city: "Berlin", zip: "10115" }) });
|
|
45
|
+
*
|
|
46
|
+
* // Writes `address.city` only, and leaves `address.zip` as it is.
|
|
47
|
+
* User.update.make({ address: { city: "Berlin" } });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see {@link Firestore.With.updateDoc} for writing the patch
|
|
51
|
+
*
|
|
52
|
+
* @stability unstable
|
|
53
|
+
* @category constructors
|
|
54
|
+
* @since 0.2.0
|
|
55
|
+
*/
|
|
56
|
+
const replace = replace$1;
|
|
57
|
+
export { Patch_exports, isReplace, replace };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Existing as Existing$1 } from "./DocumentSnapshot.mjs";
|
|
2
|
+
import { Any } from "./Collection.mjs";
|
|
3
|
+
import { Inspectable } from "effect";
|
|
4
|
+
declare namespace QuerySnapshot_d_exports {
|
|
5
|
+
export { Existing, ExtraOf, QuerySnapshot, isQuerySnapshot, make };
|
|
6
|
+
}
|
|
7
|
+
declare const TypeId = "~@visiolab/effect-firebase/firestore/QuerySnapshot";
|
|
8
|
+
/**
|
|
9
|
+
* A {@link DocumentSnapshot.Existing} snapshot in whichever of the collections
|
|
10
|
+
* `C` it is in.
|
|
11
|
+
*
|
|
12
|
+
* **Details**
|
|
13
|
+
*
|
|
14
|
+
* For a union `C` it is `Existing<A> | Existing<B>` rather than
|
|
15
|
+
* `Existing<A | B>`, so a document's id, ancestors, reference and data all
|
|
16
|
+
* belong to the same collection.
|
|
17
|
+
*
|
|
18
|
+
* @stability unstable
|
|
19
|
+
* @category models
|
|
20
|
+
* @since 0.2.0
|
|
21
|
+
*/
|
|
22
|
+
export type Existing<C extends Any> = C extends Any ? Existing$1<C> : never;
|
|
23
|
+
/**
|
|
24
|
+
* The documents of `C` that a read of many documents found.
|
|
25
|
+
*
|
|
26
|
+
* **Details**
|
|
27
|
+
*
|
|
28
|
+
* {@link Firestore.With.getDocs} returns one, and
|
|
29
|
+
* {@link Firestore.With.streamDocs} emits one per change. `C` is a union when
|
|
30
|
+
* the read was of a Collection Group with several members, and each document
|
|
31
|
+
* is then in one of them.
|
|
32
|
+
*
|
|
33
|
+
* `DocumentExtra` is what a backend adds to each document beyond the portable
|
|
34
|
+
* snapshot, such as the client's `metadata`. What it adds to the read as a
|
|
35
|
+
* whole is not part of this type: it is intersected where the snapshot is
|
|
36
|
+
* used, as `QuerySnapshot<C, E> & E`.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link DocumentSnapshot.DocumentSnapshot} for the result of a read of one document
|
|
39
|
+
*
|
|
40
|
+
* @stability unstable
|
|
41
|
+
* @category models
|
|
42
|
+
* @since 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
export interface QuerySnapshot<C extends Any, DocumentExtra extends object = {}> extends Inspectable.Inspectable {
|
|
45
|
+
readonly [TypeId]: typeof TypeId;
|
|
46
|
+
/**
|
|
47
|
+
* Every document the read found, in the order Firestore returned them.
|
|
48
|
+
* Empty when there were none.
|
|
49
|
+
*
|
|
50
|
+
* **Details**
|
|
51
|
+
*
|
|
52
|
+
* Each was there when it was read, so each is a
|
|
53
|
+
* {@link DocumentSnapshot.Existing} in the collection of `C` it lives in,
|
|
54
|
+
* with the `DocumentExtra` of the read.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link Collection.Collection.contains} for keeping the documents of one collection
|
|
57
|
+
*/
|
|
58
|
+
readonly docs: ReadonlyArray<Existing<C> & DocumentExtra>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The fields a document snapshot `D` has beyond the portable
|
|
62
|
+
* {@link DocumentSnapshot.Existing}, such as the client's `metadata`.
|
|
63
|
+
*
|
|
64
|
+
* @stability unstable
|
|
65
|
+
* @category models
|
|
66
|
+
* @since 0.3.0
|
|
67
|
+
*/
|
|
68
|
+
export type ExtraOf<D extends Existing$1<Any>> = { [K in keyof D as K extends keyof Existing$1<Any> ? never : K]: D[K]; };
|
|
69
|
+
/**
|
|
70
|
+
* Checks whether a value is a {@link QuerySnapshot}.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link DocumentSnapshot.isDocumentSnapshot} for a snapshot of one document
|
|
73
|
+
*
|
|
74
|
+
* @stability unstable
|
|
75
|
+
* @category guards
|
|
76
|
+
* @since 0.2.0
|
|
77
|
+
*/
|
|
78
|
+
export declare const isQuerySnapshot: (u: unknown) => u is QuerySnapshot<Any>;
|
|
79
|
+
/**
|
|
80
|
+
* Builds a {@link QuerySnapshot} from the documents a read found.
|
|
81
|
+
*
|
|
82
|
+
* **When to use**
|
|
83
|
+
*
|
|
84
|
+
* Use when implementing a backend or a test double. Application code gets
|
|
85
|
+
* query snapshots from {@link Firestore.With.getDocs} instead.
|
|
86
|
+
*
|
|
87
|
+
* **Details**
|
|
88
|
+
*
|
|
89
|
+
* An SDK that knows more about the read as a whole, such as the client's
|
|
90
|
+
* `metadata`, passes it as `extra`: each of its fields is put on the snapshot
|
|
91
|
+
* and shown when it prints, as {@link DocumentSnapshot.make} does for one
|
|
92
|
+
* document. Its fields must not have the same names as the snapshot's own.
|
|
93
|
+
*
|
|
94
|
+
* The documents are kept as given, so any extra fields on them stay, and stay
|
|
95
|
+
* in the snapshot's type.
|
|
96
|
+
*
|
|
97
|
+
* @see {@link DocumentSnapshot.existing} for building each document
|
|
98
|
+
*
|
|
99
|
+
* @stability unstable
|
|
100
|
+
* @category constructors
|
|
101
|
+
* @since 0.2.0
|
|
102
|
+
*/
|
|
103
|
+
export declare const make: {
|
|
104
|
+
<C extends Any, D extends Existing$1<C> = Existing$1<C>>(docs: ReadonlyArray<D> & ReadonlyArray<Existing$1<C>>): QuerySnapshot<C, ExtraOf<D>>;
|
|
105
|
+
<C extends Any, D extends Existing$1<C>, E extends object>(docs: ReadonlyArray<D> & ReadonlyArray<Existing$1<C>>, extra: E): QuerySnapshot<C, ExtraOf<D>> & E;
|
|
106
|
+
};
|
|
107
|
+
export { QuerySnapshot_d_exports };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { isQuerySnapshot as isQuerySnapshot$1, make as make$1 } from "./internal/querySnapshot.mjs";
|
|
3
|
+
// src/firestore/QuerySnapshot.ts
|
|
4
|
+
var QuerySnapshot_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
isQuerySnapshot: () => isQuerySnapshot,
|
|
6
|
+
make: () => make
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether a value is a {@link QuerySnapshot}.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link DocumentSnapshot.isDocumentSnapshot} for a snapshot of one document
|
|
12
|
+
*
|
|
13
|
+
* @stability unstable
|
|
14
|
+
* @category guards
|
|
15
|
+
* @since 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
const isQuerySnapshot = isQuerySnapshot$1;
|
|
18
|
+
/**
|
|
19
|
+
* Builds a {@link QuerySnapshot} from the documents a read found.
|
|
20
|
+
*
|
|
21
|
+
* **When to use**
|
|
22
|
+
*
|
|
23
|
+
* Use when implementing a backend or a test double. Application code gets
|
|
24
|
+
* query snapshots from {@link Firestore.With.getDocs} instead.
|
|
25
|
+
*
|
|
26
|
+
* **Details**
|
|
27
|
+
*
|
|
28
|
+
* An SDK that knows more about the read as a whole, such as the client's
|
|
29
|
+
* `metadata`, passes it as `extra`: each of its fields is put on the snapshot
|
|
30
|
+
* and shown when it prints, as {@link DocumentSnapshot.make} does for one
|
|
31
|
+
* document. Its fields must not have the same names as the snapshot's own.
|
|
32
|
+
*
|
|
33
|
+
* The documents are kept as given, so any extra fields on them stay, and stay
|
|
34
|
+
* in the snapshot's type.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link DocumentSnapshot.existing} for building each document
|
|
37
|
+
*
|
|
38
|
+
* @stability unstable
|
|
39
|
+
* @category constructors
|
|
40
|
+
* @since 0.2.0
|
|
41
|
+
*/
|
|
42
|
+
const make = make$1;
|
|
43
|
+
export { QuerySnapshot_exports, isQuerySnapshot, make };
|