@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,273 @@
|
|
|
1
|
+
import { DateTime, Effect, Equal, Inspectable, Option, Order as Order$1 } from "effect";
|
|
2
|
+
declare namespace Timestamp_d_exports {
|
|
3
|
+
export { Order, Timestamp, fromDateTime, fromDateTimeUnsafe, fromMillis, fromMillisUnsafe, isTimestamp, make, makeUnsafe, now, toDateTime, toMillis };
|
|
4
|
+
}
|
|
5
|
+
declare const TypeId = "~@visiolab/effect-firebase/firestore/Timestamp";
|
|
6
|
+
/**
|
|
7
|
+
* An instant, stored the way Firestore stores it.
|
|
8
|
+
*
|
|
9
|
+
* **When to use**
|
|
10
|
+
*
|
|
11
|
+
* Use when a document is read, written back, and has to come out unchanged.
|
|
12
|
+
* Firestore keeps timestamps to the microsecond, which `DateTime.Utc` and
|
|
13
|
+
* `Date` cannot hold, so this is the only representation that round-trips
|
|
14
|
+
* exactly.
|
|
15
|
+
*
|
|
16
|
+
* **Details**
|
|
17
|
+
*
|
|
18
|
+
* Two timestamps are equal when their `seconds` and `nanoseconds` are.
|
|
19
|
+
* Firestore addresses instants from the start of year 1 to the end of year
|
|
20
|
+
* 9999, and every constructor here checks for that range.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link FirestoreSchema.Timestamp} for the schema of this value
|
|
23
|
+
*
|
|
24
|
+
* @stability unstable
|
|
25
|
+
* @category models
|
|
26
|
+
* @since 0.2.0
|
|
27
|
+
*/
|
|
28
|
+
export interface Timestamp extends Equal.Equal, Inspectable.Inspectable {
|
|
29
|
+
readonly [TypeId]: typeof TypeId;
|
|
30
|
+
/** Seconds since the Unix epoch, negative before it. */
|
|
31
|
+
readonly seconds: number;
|
|
32
|
+
/** The fraction of that second, from 0 to 999,999,999. */
|
|
33
|
+
readonly nanoseconds: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether `u` is a {@link Timestamp} built by this module.
|
|
37
|
+
*
|
|
38
|
+
* An SDK's own `Timestamp` is not one.
|
|
39
|
+
*
|
|
40
|
+
* @stability unstable
|
|
41
|
+
* @category guards
|
|
42
|
+
* @since 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
export declare const isTimestamp: (u: unknown) => u is Timestamp;
|
|
45
|
+
/**
|
|
46
|
+
* Builds a timestamp from seconds and nanoseconds, throwing on values
|
|
47
|
+
* Firestore cannot store.
|
|
48
|
+
*
|
|
49
|
+
* **When to use**
|
|
50
|
+
*
|
|
51
|
+
* Use for values known to be valid, such as constants. Use {@link make} for
|
|
52
|
+
* values you have not checked.
|
|
53
|
+
*
|
|
54
|
+
* **Details**
|
|
55
|
+
*
|
|
56
|
+
* Throws unless `seconds` is an integer from year 1 to year 9999, and
|
|
57
|
+
* `nanoseconds` is an integer from 0 to 999,999,999.
|
|
58
|
+
*
|
|
59
|
+
* @example Building a timestamp
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
62
|
+
*
|
|
63
|
+
* const epoch = Timestamp.makeUnsafe(0, 0);
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @see {@link make} for the same check returning an `Option`
|
|
67
|
+
* @see {@link fromMillisUnsafe} for building one from milliseconds
|
|
68
|
+
*
|
|
69
|
+
* @stability unstable
|
|
70
|
+
* @category constructors
|
|
71
|
+
* @since 0.2.0
|
|
72
|
+
*/
|
|
73
|
+
export declare const makeUnsafe: (seconds: number, nanoseconds: number) => Timestamp;
|
|
74
|
+
/**
|
|
75
|
+
* Builds a timestamp from seconds and nanoseconds, or `None` for values
|
|
76
|
+
* Firestore cannot store.
|
|
77
|
+
*
|
|
78
|
+
* **When to use**
|
|
79
|
+
*
|
|
80
|
+
* Use when the fields come from outside the program, such as a request body,
|
|
81
|
+
* and may be invalid.
|
|
82
|
+
*
|
|
83
|
+
* **Details**
|
|
84
|
+
*
|
|
85
|
+
* Returns `None` unless `seconds` is an integer from year 1 to year 9999, and
|
|
86
|
+
* `nanoseconds` is an integer from 0 to 999,999,999.
|
|
87
|
+
*
|
|
88
|
+
* @example Building a timestamp from untrusted input
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { Option } from "effect";
|
|
91
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
92
|
+
*
|
|
93
|
+
* const valid = Timestamp.make(1_700_000_000, 500); // Option.some(...)
|
|
94
|
+
* const invalid = Timestamp.make(0, -1); // Option.none()
|
|
95
|
+
*
|
|
96
|
+
* Option.isSome(valid); // true
|
|
97
|
+
* Option.isNone(invalid); // true
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @see {@link makeUnsafe} for the same check throwing instead
|
|
101
|
+
* @see {@link fromMillis} for building one from milliseconds
|
|
102
|
+
*
|
|
103
|
+
* @stability unstable
|
|
104
|
+
* @category constructors
|
|
105
|
+
* @since 0.2.0
|
|
106
|
+
*/
|
|
107
|
+
export declare const make: (seconds: number, nanoseconds: number) => Option.Option<Timestamp>;
|
|
108
|
+
/**
|
|
109
|
+
* Builds a timestamp from milliseconds since the Unix epoch, throwing outside
|
|
110
|
+
* the range Firestore stores.
|
|
111
|
+
*
|
|
112
|
+
* **When to use**
|
|
113
|
+
*
|
|
114
|
+
* Use with millisecond values known to be in range, such as `Date.now()`.
|
|
115
|
+
*
|
|
116
|
+
* @example Building a timestamp from milliseconds
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
119
|
+
*
|
|
120
|
+
* const timestamp = Timestamp.fromMillisUnsafe(Date.now());
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @see {@link fromMillis} for the same check returning an `Option`
|
|
124
|
+
* @see {@link makeUnsafe} for building one from seconds and nanoseconds
|
|
125
|
+
*
|
|
126
|
+
* @stability unstable
|
|
127
|
+
* @category constructors
|
|
128
|
+
* @since 0.2.0
|
|
129
|
+
*/
|
|
130
|
+
export declare const fromMillisUnsafe: (millis: number) => Timestamp;
|
|
131
|
+
/**
|
|
132
|
+
* Builds a timestamp from milliseconds since the Unix epoch, or `None` outside
|
|
133
|
+
* the range Firestore stores.
|
|
134
|
+
*
|
|
135
|
+
* **When to use**
|
|
136
|
+
*
|
|
137
|
+
* Use with millisecond values that may be out of range or not finite.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link fromMillisUnsafe} for the same check throwing instead
|
|
140
|
+
* @see {@link toMillis} for the reverse conversion
|
|
141
|
+
*
|
|
142
|
+
* @stability unstable
|
|
143
|
+
* @category constructors
|
|
144
|
+
* @since 0.2.0
|
|
145
|
+
*/
|
|
146
|
+
export declare const fromMillis: (millis: number) => Option.Option<Timestamp>;
|
|
147
|
+
/**
|
|
148
|
+
* Builds a timestamp from a `DateTime.Utc`, throwing outside the range
|
|
149
|
+
* Firestore stores.
|
|
150
|
+
*
|
|
151
|
+
* **When to use**
|
|
152
|
+
*
|
|
153
|
+
* Use with a `DateTime` known to fall between year 1 and year 9999, which
|
|
154
|
+
* covers almost every real date.
|
|
155
|
+
*
|
|
156
|
+
* **Details**
|
|
157
|
+
*
|
|
158
|
+
* A `DateTime.Utc` only carries milliseconds, so the result has no finer
|
|
159
|
+
* digits.
|
|
160
|
+
*
|
|
161
|
+
* @example Converting a DateTime
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { DateTime } from "effect";
|
|
164
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
165
|
+
*
|
|
166
|
+
* const timestamp = Timestamp.fromDateTimeUnsafe(DateTime.makeUnsafe("2024-01-01T00:00:00Z"));
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @see {@link fromDateTime} for the same check returning an `Option`
|
|
170
|
+
* @see {@link toDateTime} for the reverse conversion
|
|
171
|
+
*
|
|
172
|
+
* @stability unstable
|
|
173
|
+
* @category constructors
|
|
174
|
+
* @since 0.2.0
|
|
175
|
+
*/
|
|
176
|
+
export declare const fromDateTimeUnsafe: (dateTime: DateTime.Utc) => Timestamp;
|
|
177
|
+
/**
|
|
178
|
+
* Builds a timestamp from a `DateTime.Utc`, or `None` outside the range
|
|
179
|
+
* Firestore stores.
|
|
180
|
+
*
|
|
181
|
+
* **When to use**
|
|
182
|
+
*
|
|
183
|
+
* Use with a `DateTime` that may fall outside year 1 to year 9999, such as one
|
|
184
|
+
* parsed from user input.
|
|
185
|
+
*
|
|
186
|
+
* **Details**
|
|
187
|
+
*
|
|
188
|
+
* A `DateTime.Utc` only carries milliseconds, so the result has no finer
|
|
189
|
+
* digits.
|
|
190
|
+
*
|
|
191
|
+
* @see {@link fromDateTimeUnsafe} for the same check throwing instead
|
|
192
|
+
* @see {@link toDateTime} for the reverse conversion
|
|
193
|
+
*
|
|
194
|
+
* @stability unstable
|
|
195
|
+
* @category constructors
|
|
196
|
+
* @since 0.2.0
|
|
197
|
+
*/
|
|
198
|
+
export declare const fromDateTime: (dateTime: DateTime.Utc) => Option.Option<Timestamp>;
|
|
199
|
+
/**
|
|
200
|
+
* The current instant, read from Effect's `Clock`, to the millisecond.
|
|
201
|
+
*
|
|
202
|
+
* **When to use**
|
|
203
|
+
*
|
|
204
|
+
* Use when the time this program sees is the one to store, and when a test
|
|
205
|
+
* should control it through `TestClock`.
|
|
206
|
+
*
|
|
207
|
+
* **Details**
|
|
208
|
+
*
|
|
209
|
+
* This is the local clock, not the database's. Clients with skewed clocks
|
|
210
|
+
* write different times for the same moment.
|
|
211
|
+
*
|
|
212
|
+
* @example Reading the current time
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { Effect } from "effect";
|
|
215
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
216
|
+
*
|
|
217
|
+
* const program = Effect.gen(function* () {
|
|
218
|
+
* const now = yield* Timestamp.now;
|
|
219
|
+
* return Timestamp.toMillis(now);
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @see {@link FieldValue.serverTimestamp} for the time the server applies the write
|
|
224
|
+
*
|
|
225
|
+
* @stability unstable
|
|
226
|
+
* @category constructors
|
|
227
|
+
* @since 0.2.0
|
|
228
|
+
*/
|
|
229
|
+
export declare const now: Effect.Effect<Timestamp>;
|
|
230
|
+
/**
|
|
231
|
+
* Converts a timestamp to milliseconds since the Unix epoch, dropping the
|
|
232
|
+
* finer digits.
|
|
233
|
+
*
|
|
234
|
+
* @see {@link fromMillis} for the reverse conversion
|
|
235
|
+
* @see {@link toDateTime} for converting to a `DateTime.Utc`
|
|
236
|
+
*
|
|
237
|
+
* @stability unstable
|
|
238
|
+
* @category conversions
|
|
239
|
+
* @since 0.2.0
|
|
240
|
+
*/
|
|
241
|
+
export declare const toMillis: (self: Timestamp) => number;
|
|
242
|
+
/**
|
|
243
|
+
* Converts a timestamp to a `DateTime.Utc`, dropping the digits finer than a
|
|
244
|
+
* millisecond.
|
|
245
|
+
*
|
|
246
|
+
* @see {@link fromDateTime} for the reverse conversion
|
|
247
|
+
* @see {@link toMillis} for converting to milliseconds
|
|
248
|
+
*
|
|
249
|
+
* @stability unstable
|
|
250
|
+
* @category conversions
|
|
251
|
+
* @since 0.2.0
|
|
252
|
+
*/
|
|
253
|
+
export declare const toDateTime: (self: Timestamp) => DateTime.Utc;
|
|
254
|
+
/**
|
|
255
|
+
* Orders timestamps from earliest to latest, at full precision.
|
|
256
|
+
*
|
|
257
|
+
* @example Sorting timestamps
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { Array } from "effect";
|
|
260
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
261
|
+
*
|
|
262
|
+
* const sorted = Array.sort(
|
|
263
|
+
* [Timestamp.makeUnsafe(2, 0), Timestamp.makeUnsafe(1, 500)],
|
|
264
|
+
* Timestamp.Order,
|
|
265
|
+
* );
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @stability unstable
|
|
269
|
+
* @category ordering
|
|
270
|
+
* @since 0.2.0
|
|
271
|
+
*/
|
|
272
|
+
export declare const Order: Order$1.Order<Timestamp>;
|
|
273
|
+
export { Timestamp_d_exports };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { Order as Order$1, fromDateTime as fromDateTime$1, fromDateTimeUnsafe as fromDateTimeUnsafe$1, fromMillis as fromMillis$1, fromMillisUnsafe as fromMillisUnsafe$1, isTimestamp as isTimestamp$1, make as make$1, makeUnsafe as makeUnsafe$1, now as now$1, toDateTime as toDateTime$1, toMillis as toMillis$1 } from "./internal/timestamp.mjs";
|
|
3
|
+
// src/firestore/Timestamp.ts
|
|
4
|
+
var Timestamp_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Order: () => Order,
|
|
6
|
+
fromDateTime: () => fromDateTime,
|
|
7
|
+
fromDateTimeUnsafe: () => fromDateTimeUnsafe,
|
|
8
|
+
fromMillis: () => fromMillis,
|
|
9
|
+
fromMillisUnsafe: () => fromMillisUnsafe,
|
|
10
|
+
isTimestamp: () => isTimestamp,
|
|
11
|
+
make: () => make,
|
|
12
|
+
makeUnsafe: () => makeUnsafe,
|
|
13
|
+
now: () => now,
|
|
14
|
+
toDateTime: () => toDateTime,
|
|
15
|
+
toMillis: () => toMillis
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether `u` is a {@link Timestamp} built by this module.
|
|
19
|
+
*
|
|
20
|
+
* An SDK's own `Timestamp` is not one.
|
|
21
|
+
*
|
|
22
|
+
* @stability unstable
|
|
23
|
+
* @category guards
|
|
24
|
+
* @since 0.2.0
|
|
25
|
+
*/
|
|
26
|
+
const isTimestamp = isTimestamp$1;
|
|
27
|
+
/**
|
|
28
|
+
* Builds a timestamp from seconds and nanoseconds, throwing on values
|
|
29
|
+
* Firestore cannot store.
|
|
30
|
+
*
|
|
31
|
+
* **When to use**
|
|
32
|
+
*
|
|
33
|
+
* Use for values known to be valid, such as constants. Use {@link make} for
|
|
34
|
+
* values you have not checked.
|
|
35
|
+
*
|
|
36
|
+
* **Details**
|
|
37
|
+
*
|
|
38
|
+
* Throws unless `seconds` is an integer from year 1 to year 9999, and
|
|
39
|
+
* `nanoseconds` is an integer from 0 to 999,999,999.
|
|
40
|
+
*
|
|
41
|
+
* @example Building a timestamp
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
44
|
+
*
|
|
45
|
+
* const epoch = Timestamp.makeUnsafe(0, 0);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see {@link make} for the same check returning an `Option`
|
|
49
|
+
* @see {@link fromMillisUnsafe} for building one from milliseconds
|
|
50
|
+
*
|
|
51
|
+
* @stability unstable
|
|
52
|
+
* @category constructors
|
|
53
|
+
* @since 0.2.0
|
|
54
|
+
*/
|
|
55
|
+
const makeUnsafe = makeUnsafe$1;
|
|
56
|
+
/**
|
|
57
|
+
* Builds a timestamp from seconds and nanoseconds, or `None` for values
|
|
58
|
+
* Firestore cannot store.
|
|
59
|
+
*
|
|
60
|
+
* **When to use**
|
|
61
|
+
*
|
|
62
|
+
* Use when the fields come from outside the program, such as a request body,
|
|
63
|
+
* and may be invalid.
|
|
64
|
+
*
|
|
65
|
+
* **Details**
|
|
66
|
+
*
|
|
67
|
+
* Returns `None` unless `seconds` is an integer from year 1 to year 9999, and
|
|
68
|
+
* `nanoseconds` is an integer from 0 to 999,999,999.
|
|
69
|
+
*
|
|
70
|
+
* @example Building a timestamp from untrusted input
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { Option } from "effect";
|
|
73
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
74
|
+
*
|
|
75
|
+
* const valid = Timestamp.make(1_700_000_000, 500); // Option.some(...)
|
|
76
|
+
* const invalid = Timestamp.make(0, -1); // Option.none()
|
|
77
|
+
*
|
|
78
|
+
* Option.isSome(valid); // true
|
|
79
|
+
* Option.isNone(invalid); // true
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @see {@link makeUnsafe} for the same check throwing instead
|
|
83
|
+
* @see {@link fromMillis} for building one from milliseconds
|
|
84
|
+
*
|
|
85
|
+
* @stability unstable
|
|
86
|
+
* @category constructors
|
|
87
|
+
* @since 0.2.0
|
|
88
|
+
*/
|
|
89
|
+
const make = make$1;
|
|
90
|
+
/**
|
|
91
|
+
* Builds a timestamp from milliseconds since the Unix epoch, throwing outside
|
|
92
|
+
* the range Firestore stores.
|
|
93
|
+
*
|
|
94
|
+
* **When to use**
|
|
95
|
+
*
|
|
96
|
+
* Use with millisecond values known to be in range, such as `Date.now()`.
|
|
97
|
+
*
|
|
98
|
+
* @example Building a timestamp from milliseconds
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
101
|
+
*
|
|
102
|
+
* const timestamp = Timestamp.fromMillisUnsafe(Date.now());
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @see {@link fromMillis} for the same check returning an `Option`
|
|
106
|
+
* @see {@link makeUnsafe} for building one from seconds and nanoseconds
|
|
107
|
+
*
|
|
108
|
+
* @stability unstable
|
|
109
|
+
* @category constructors
|
|
110
|
+
* @since 0.2.0
|
|
111
|
+
*/
|
|
112
|
+
const fromMillisUnsafe = fromMillisUnsafe$1;
|
|
113
|
+
/**
|
|
114
|
+
* Builds a timestamp from milliseconds since the Unix epoch, or `None` outside
|
|
115
|
+
* the range Firestore stores.
|
|
116
|
+
*
|
|
117
|
+
* **When to use**
|
|
118
|
+
*
|
|
119
|
+
* Use with millisecond values that may be out of range or not finite.
|
|
120
|
+
*
|
|
121
|
+
* @see {@link fromMillisUnsafe} for the same check throwing instead
|
|
122
|
+
* @see {@link toMillis} for the reverse conversion
|
|
123
|
+
*
|
|
124
|
+
* @stability unstable
|
|
125
|
+
* @category constructors
|
|
126
|
+
* @since 0.2.0
|
|
127
|
+
*/
|
|
128
|
+
const fromMillis = fromMillis$1;
|
|
129
|
+
/**
|
|
130
|
+
* Builds a timestamp from a `DateTime.Utc`, throwing outside the range
|
|
131
|
+
* Firestore stores.
|
|
132
|
+
*
|
|
133
|
+
* **When to use**
|
|
134
|
+
*
|
|
135
|
+
* Use with a `DateTime` known to fall between year 1 and year 9999, which
|
|
136
|
+
* covers almost every real date.
|
|
137
|
+
*
|
|
138
|
+
* **Details**
|
|
139
|
+
*
|
|
140
|
+
* A `DateTime.Utc` only carries milliseconds, so the result has no finer
|
|
141
|
+
* digits.
|
|
142
|
+
*
|
|
143
|
+
* @example Converting a DateTime
|
|
144
|
+
* ```ts
|
|
145
|
+
* import { DateTime } from "effect";
|
|
146
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
147
|
+
*
|
|
148
|
+
* const timestamp = Timestamp.fromDateTimeUnsafe(DateTime.makeUnsafe("2024-01-01T00:00:00Z"));
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @see {@link fromDateTime} for the same check returning an `Option`
|
|
152
|
+
* @see {@link toDateTime} for the reverse conversion
|
|
153
|
+
*
|
|
154
|
+
* @stability unstable
|
|
155
|
+
* @category constructors
|
|
156
|
+
* @since 0.2.0
|
|
157
|
+
*/
|
|
158
|
+
const fromDateTimeUnsafe = fromDateTimeUnsafe$1;
|
|
159
|
+
/**
|
|
160
|
+
* Builds a timestamp from a `DateTime.Utc`, or `None` outside the range
|
|
161
|
+
* Firestore stores.
|
|
162
|
+
*
|
|
163
|
+
* **When to use**
|
|
164
|
+
*
|
|
165
|
+
* Use with a `DateTime` that may fall outside year 1 to year 9999, such as one
|
|
166
|
+
* parsed from user input.
|
|
167
|
+
*
|
|
168
|
+
* **Details**
|
|
169
|
+
*
|
|
170
|
+
* A `DateTime.Utc` only carries milliseconds, so the result has no finer
|
|
171
|
+
* digits.
|
|
172
|
+
*
|
|
173
|
+
* @see {@link fromDateTimeUnsafe} for the same check throwing instead
|
|
174
|
+
* @see {@link toDateTime} for the reverse conversion
|
|
175
|
+
*
|
|
176
|
+
* @stability unstable
|
|
177
|
+
* @category constructors
|
|
178
|
+
* @since 0.2.0
|
|
179
|
+
*/
|
|
180
|
+
const fromDateTime = fromDateTime$1;
|
|
181
|
+
/**
|
|
182
|
+
* The current instant, read from Effect's `Clock`, to the millisecond.
|
|
183
|
+
*
|
|
184
|
+
* **When to use**
|
|
185
|
+
*
|
|
186
|
+
* Use when the time this program sees is the one to store, and when a test
|
|
187
|
+
* should control it through `TestClock`.
|
|
188
|
+
*
|
|
189
|
+
* **Details**
|
|
190
|
+
*
|
|
191
|
+
* This is the local clock, not the database's. Clients with skewed clocks
|
|
192
|
+
* write different times for the same moment.
|
|
193
|
+
*
|
|
194
|
+
* @example Reading the current time
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { Effect } from "effect";
|
|
197
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
198
|
+
*
|
|
199
|
+
* const program = Effect.gen(function* () {
|
|
200
|
+
* const now = yield* Timestamp.now;
|
|
201
|
+
* return Timestamp.toMillis(now);
|
|
202
|
+
* });
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* @see {@link FieldValue.serverTimestamp} for the time the server applies the write
|
|
206
|
+
*
|
|
207
|
+
* @stability unstable
|
|
208
|
+
* @category constructors
|
|
209
|
+
* @since 0.2.0
|
|
210
|
+
*/
|
|
211
|
+
const now = now$1;
|
|
212
|
+
/**
|
|
213
|
+
* Converts a timestamp to milliseconds since the Unix epoch, dropping the
|
|
214
|
+
* finer digits.
|
|
215
|
+
*
|
|
216
|
+
* @see {@link fromMillis} for the reverse conversion
|
|
217
|
+
* @see {@link toDateTime} for converting to a `DateTime.Utc`
|
|
218
|
+
*
|
|
219
|
+
* @stability unstable
|
|
220
|
+
* @category conversions
|
|
221
|
+
* @since 0.2.0
|
|
222
|
+
*/
|
|
223
|
+
const toMillis = toMillis$1;
|
|
224
|
+
/**
|
|
225
|
+
* Converts a timestamp to a `DateTime.Utc`, dropping the digits finer than a
|
|
226
|
+
* millisecond.
|
|
227
|
+
*
|
|
228
|
+
* @see {@link fromDateTime} for the reverse conversion
|
|
229
|
+
* @see {@link toMillis} for converting to milliseconds
|
|
230
|
+
*
|
|
231
|
+
* @stability unstable
|
|
232
|
+
* @category conversions
|
|
233
|
+
* @since 0.2.0
|
|
234
|
+
*/
|
|
235
|
+
const toDateTime = toDateTime$1;
|
|
236
|
+
/**
|
|
237
|
+
* Orders timestamps from earliest to latest, at full precision.
|
|
238
|
+
*
|
|
239
|
+
* @example Sorting timestamps
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { Array } from "effect";
|
|
242
|
+
* import { Timestamp } from "@visiolab/effect-firebase/firestore";
|
|
243
|
+
*
|
|
244
|
+
* const sorted = Array.sort(
|
|
245
|
+
* [Timestamp.makeUnsafe(2, 0), Timestamp.makeUnsafe(1, 500)],
|
|
246
|
+
* Timestamp.Order,
|
|
247
|
+
* );
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @stability unstable
|
|
251
|
+
* @category ordering
|
|
252
|
+
* @since 0.2.0
|
|
253
|
+
*/
|
|
254
|
+
const Order = Order$1;
|
|
255
|
+
export { Order, Timestamp_exports, fromDateTime, fromDateTimeUnsafe, fromMillis, fromMillisUnsafe, isTimestamp, make, makeUnsafe, now, toDateTime, toMillis };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DocumentSnapshot_d_exports } from "./DocumentSnapshot.mjs";
|
|
2
|
+
import { DocumentPath_d_exports } from "./DocumentPath.mjs";
|
|
3
|
+
import { FieldValue_d_exports } from "./FieldValue.mjs";
|
|
4
|
+
import { GeoPoint_d_exports } from "./GeoPoint.mjs";
|
|
5
|
+
import { Timestamp_d_exports } from "./Timestamp.mjs";
|
|
6
|
+
import { FirestoreSchema_d_exports } from "./FirestoreSchema.mjs";
|
|
7
|
+
import { Patch_d_exports } from "./Patch.mjs";
|
|
8
|
+
import { FirestoreModel_d_exports } from "./FirestoreModel.mjs";
|
|
9
|
+
import { Collection_d_exports } from "./Collection.mjs";
|
|
10
|
+
import { FirestoreValue_d_exports } from "./FirestoreValue.mjs";
|
|
11
|
+
import { QuerySnapshot_d_exports } from "./QuerySnapshot.mjs";
|
|
12
|
+
import { Firestore_d_exports } from "./Firestore.mjs";
|
|
13
|
+
import { CollectionGroup_d_exports } from "./CollectionGroup.mjs";
|
|
14
|
+
export { Collection_d_exports as Collection, CollectionGroup_d_exports as CollectionGroup, DocumentPath_d_exports as DocumentPath, DocumentSnapshot_d_exports as DocumentSnapshot, FieldValue_d_exports as FieldValue, Firestore_d_exports as Firestore, FirestoreModel_d_exports as FirestoreModel, FirestoreSchema_d_exports as FirestoreSchema, FirestoreValue_d_exports as FirestoreValue, GeoPoint_d_exports as GeoPoint, Patch_d_exports as Patch, QuerySnapshot_d_exports as QuerySnapshot, Timestamp_d_exports as Timestamp };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Collection_exports } from "./Collection.mjs";
|
|
2
|
+
import { CollectionGroup_exports } from "./CollectionGroup.mjs";
|
|
3
|
+
import { DocumentPath_exports } from "./DocumentPath.mjs";
|
|
4
|
+
import { DocumentSnapshot_exports } from "./DocumentSnapshot.mjs";
|
|
5
|
+
import { FieldValue_exports } from "./FieldValue.mjs";
|
|
6
|
+
import { Firestore_exports } from "./Firestore.mjs";
|
|
7
|
+
import { FirestoreModel_exports } from "./FirestoreModel.mjs";
|
|
8
|
+
import { FirestoreSchema_exports } from "./FirestoreSchema.mjs";
|
|
9
|
+
import { FirestoreValue_exports } from "./FirestoreValue.mjs";
|
|
10
|
+
import { GeoPoint_exports } from "./GeoPoint.mjs";
|
|
11
|
+
import { Patch_exports } from "./Patch.mjs";
|
|
12
|
+
import { QuerySnapshot_exports } from "./QuerySnapshot.mjs";
|
|
13
|
+
import { Timestamp_exports } from "./Timestamp.mjs";
|
|
14
|
+
export { Collection_exports as Collection, CollectionGroup_exports as CollectionGroup, DocumentPath_exports as DocumentPath, DocumentSnapshot_exports as DocumentSnapshot, FieldValue_exports as FieldValue, Firestore_exports as Firestore, FirestoreModel_exports as FirestoreModel, FirestoreSchema_exports as FirestoreSchema, FirestoreValue_exports as FirestoreValue, GeoPoint_exports as GeoPoint, Patch_exports as Patch, QuerySnapshot_exports as QuerySnapshot, Timestamp_exports as Timestamp };
|