firetender-admin 0.11.1 → 0.12.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/dist/FiretenderCollection.d.ts +16 -5
- package/dist/FiretenderCollection.js +26 -3
- package/dist/FiretenderCollection.js.map +1 -1
- package/dist/FiretenderDoc.d.ts +41 -8
- package/dist/FiretenderDoc.js +62 -14
- package/dist/FiretenderDoc.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/timestamps.d.ts +14 -5
- package/dist/timestamps.js +22 -8
- package/dist/timestamps.js.map +1 -1
- package/package.json +1 -1
- package/src/FiretenderCollection.ts +34 -7
- package/src/FiretenderDoc.ts +113 -19
- package/src/index.ts +2 -2
- package/src/timestamps.ts +21 -6
|
@@ -10,14 +10,16 @@ import { DeepPartial } from "./ts-helpers";
|
|
|
10
10
|
* are covered by a FiretenderCollection for the path ["foo", "bar"].
|
|
11
11
|
*/
|
|
12
12
|
export declare class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
13
|
-
/** Zod schema used to parse and validate the document's data */
|
|
13
|
+
/** Zod schema used to parse and validate the document's data. */
|
|
14
14
|
readonly schema: SchemaType;
|
|
15
|
-
/** Firestore object: the thing you get from getFirestore() */
|
|
15
|
+
/** Firestore object: the thing you get from getFirestore(). */
|
|
16
16
|
readonly firestore: Firestore;
|
|
17
|
-
/** The collection path of this object: a series of collection names */
|
|
17
|
+
/** The collection path of this object: a series of collection names. */
|
|
18
18
|
readonly collectionPath: string[];
|
|
19
19
|
/** Function to return the initial values when creating a new document. */
|
|
20
|
-
readonly baseInitialDataFactory
|
|
20
|
+
private readonly baseInitialDataFactory;
|
|
21
|
+
/** Default options to send to docs in this collection. */
|
|
22
|
+
private readonly defaultDocOptions;
|
|
21
23
|
/**
|
|
22
24
|
* @param schema the Zod object schema describing the documents in this
|
|
23
25
|
* collection.
|
|
@@ -26,8 +28,11 @@ export declare class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
26
28
|
* of any parent collections and of this collection.
|
|
27
29
|
* @param baseInitialData (optional) an object or object factory providing
|
|
28
30
|
* default field values for this collection.
|
|
31
|
+
* @param options default optional parameters for the resulting FiretenderDoc;
|
|
32
|
+
* see FiretenderDocOptions for detail. Options passed to `.newDoc()` and
|
|
33
|
+
* `.existingDoc()` override these.
|
|
29
34
|
*/
|
|
30
|
-
constructor(schema: SchemaType, firestore: Firestore, collectionPath: [string, ...string[]] | string, baseInitialData?: (() => DeepPartial<z.input<SchemaType>>) | DeepPartial<z.input<SchemaType>> | undefined);
|
|
35
|
+
constructor(schema: SchemaType, firestore: Firestore, collectionPath: [string, ...string[]] | string, baseInitialData?: (() => DeepPartial<z.input<SchemaType>>) | DeepPartial<z.input<SchemaType>> | undefined, options?: FiretenderDocOptions);
|
|
31
36
|
/**
|
|
32
37
|
* Returns a FiretenderDoc representing a new document in this collection.
|
|
33
38
|
*
|
|
@@ -98,6 +103,12 @@ export declare class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
98
103
|
* @param id the ID or array of IDs specifying the desired collection.
|
|
99
104
|
*/
|
|
100
105
|
makeCollectionRef(id?: string[] | string | undefined): CollectionReference;
|
|
106
|
+
/**
|
|
107
|
+
* Convenience method to provide a single patcher function for this
|
|
108
|
+
* collection's documents. Patchers can also be passed in the options
|
|
109
|
+
* argument of this class's constructor.
|
|
110
|
+
*/
|
|
111
|
+
patch(patcher: (data: DeepPartial<z.input<SchemaType>>) => boolean): void;
|
|
101
112
|
/**
|
|
102
113
|
* Builds a doc ref from the given IDs, or returns "undefined" if the IDs do
|
|
103
114
|
* not correctly specify a doc path.
|
|
@@ -20,8 +20,11 @@ class FiretenderCollection {
|
|
|
20
20
|
* of any parent collections and of this collection.
|
|
21
21
|
* @param baseInitialData (optional) an object or object factory providing
|
|
22
22
|
* default field values for this collection.
|
|
23
|
+
* @param options default optional parameters for the resulting FiretenderDoc;
|
|
24
|
+
* see FiretenderDocOptions for detail. Options passed to `.newDoc()` and
|
|
25
|
+
* `.existingDoc()` override these.
|
|
23
26
|
*/
|
|
24
|
-
constructor(schema, firestore, collectionPath, baseInitialData = undefined) {
|
|
27
|
+
constructor(schema, firestore, collectionPath, baseInitialData = undefined, options = {}) {
|
|
25
28
|
this.schema = schema;
|
|
26
29
|
this.firestore = firestore;
|
|
27
30
|
this.collectionPath = [collectionPath].flat();
|
|
@@ -33,6 +36,7 @@ class FiretenderCollection {
|
|
|
33
36
|
this.baseInitialDataFactory = () => baseInitialData;
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
this.defaultDocOptions = options;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Returns a FiretenderDoc representing a new document in this collection.
|
|
@@ -64,7 +68,10 @@ class FiretenderCollection {
|
|
|
64
68
|
if (initialData) {
|
|
65
69
|
Object.assign(data, initialData);
|
|
66
70
|
}
|
|
67
|
-
return FiretenderDoc_1.FiretenderDoc.createNewDoc(this.schema, ref, data,
|
|
71
|
+
return FiretenderDoc_1.FiretenderDoc.createNewDoc(this.schema, ref, data, {
|
|
72
|
+
...this.defaultDocOptions,
|
|
73
|
+
...options,
|
|
74
|
+
});
|
|
68
75
|
}
|
|
69
76
|
/**
|
|
70
77
|
* Returns a FiretenderDoc representing an existing Firestore document in this
|
|
@@ -82,7 +89,10 @@ class FiretenderCollection {
|
|
|
82
89
|
if (!ref) {
|
|
83
90
|
throw new errors_1.FiretenderUsageError("existingDoc() requires a full ID path for this collection and its parent collections, if any.");
|
|
84
91
|
}
|
|
85
|
-
return new FiretenderDoc_1.FiretenderDoc(this.schema, ref,
|
|
92
|
+
return new FiretenderDoc_1.FiretenderDoc(this.schema, ref, {
|
|
93
|
+
...this.defaultDocOptions,
|
|
94
|
+
...options,
|
|
95
|
+
});
|
|
86
96
|
}
|
|
87
97
|
/**
|
|
88
98
|
* Returns an array of all the documents in this collection.
|
|
@@ -179,6 +189,19 @@ class FiretenderCollection {
|
|
|
179
189
|
}
|
|
180
190
|
return ref;
|
|
181
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Convenience method to provide a single patcher function for this
|
|
194
|
+
* collection's documents. Patchers can also be passed in the options
|
|
195
|
+
* argument of this class's constructor.
|
|
196
|
+
*/
|
|
197
|
+
patch(patcher) {
|
|
198
|
+
if (!this.defaultDocOptions.patchers) {
|
|
199
|
+
this.defaultDocOptions.patchers = [patcher];
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.defaultDocOptions.patchers.push(patcher);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
182
205
|
//////////////////////////////////////////////////////////////////////////////
|
|
183
206
|
// Private functions
|
|
184
207
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiretenderCollection.js","sourceRoot":"","sources":["../src/FiretenderCollection.ts"],"names":[],"mappings":";;;AAEA,qCAAmE;AACnE,qDAa0B;AAC1B,mDAAsE;AAGtE;;;;;;GAMG;AACH,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"FiretenderCollection.js","sourceRoot":"","sources":["../src/FiretenderCollection.ts"],"names":[],"mappings":";;;AAEA,qCAAmE;AACnE,qDAa0B;AAC1B,mDAAsE;AAGtE;;;;;;GAMG;AACH,MAAa,oBAAoB;IAkB/B;;;;;;;;;;;OAWG;IACH,YACE,MAAkB,EAClB,SAAoB,EACpB,cAA8C,EAC9C,kBAGgB,SAAS,EACzB,UAAgC,EAAE;QAElC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,IAAI,eAAe,EAAE;YACnB,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;gBACzC,IAAI,CAAC,sBAAsB,GAAG,eAAe,CAAC;aAC/C;iBAAM;gBACL,IAAI,CAAC,sBA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AC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,OAAO,IAAA,2BAAU,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,cAAc,CAC1B,KAAkC;QAElC,IAAI,aAA4B,CAAC;QACjC,IAAI;YACF,aAAa,GAAG,MAAM,IAAA,wBAAO,EAAC,KAAK,CAAC,CAAC;SACtC;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,0BAAiB,EACf,KAAK,EACL,SAAS,EACT,KAAK,YAAY,oCAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CACzD,CAAC;YACF,MAAM,KAAK,CAAC;SACb;QACD,OAAO,aAAa,CAAC,IAAI,CAAC,GAAG,CAC3B,CAAC,QAAQ,EAAE,EAAE,CACX,IAAI,6BAAa,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE;YAC3C,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE;SAC7B,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AAtTD,oDAsTC"}
|
package/dist/FiretenderDoc.d.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CollectionReference, DocumentReference, DocumentSnapshot } from "./firestore-deps";
|
|
3
3
|
import { DeepReadonly } from "./ts-helpers";
|
|
4
|
+
export type Patcher = (data: any) => boolean;
|
|
4
5
|
/**
|
|
5
6
|
* Public options for initializing a FiretenderDoc object.
|
|
6
|
-
*
|
|
7
|
-
* These will be added as needed (e.g., "readonly" for issue #1, possibly
|
|
8
|
-
* "queryPageLength" for issue #21).
|
|
9
7
|
*/
|
|
10
|
-
export type FiretenderDocOptions = {
|
|
8
|
+
export type FiretenderDocOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* If set, using the `.w` accessor or `.update()` method will throw an error
|
|
11
|
+
* and any data patches will not be written.
|
|
12
|
+
*/
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Functions that modify the data from Firestore before it is parsed by Zod.
|
|
16
|
+
* If any of these functions returns true, the data is asynchronously updated
|
|
17
|
+
* on Firestore half a second later, if it hasn't already been written back.
|
|
18
|
+
*
|
|
19
|
+
* The patchers are applied to the data in the order given, each receiving the
|
|
20
|
+
* output of the previous. The output of the last is fed to Zod.
|
|
21
|
+
*/
|
|
22
|
+
patchers?: Patcher[] | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* If false, don't write the data back to Firestore, even if a patcher returns
|
|
25
|
+
* true. Otherwise, the delay in milliseconds before patching. This delay
|
|
26
|
+
* avoids an extra write in the case of a quick read/modify/write cycle.
|
|
27
|
+
* Defaults to 500, for a half-second delay.
|
|
28
|
+
*/
|
|
29
|
+
savePatchAfterDelay?: false | number;
|
|
30
|
+
};
|
|
11
31
|
/**
|
|
12
32
|
* All options when initializing a FiretenderDoc object.
|
|
13
33
|
*
|
|
@@ -60,10 +80,16 @@ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
60
80
|
private ref;
|
|
61
81
|
/** Firestore document ID; undefined for new docs not yet on Firestore */
|
|
62
82
|
private docID;
|
|
83
|
+
/** If set, writes will throw and patches will not be written. */
|
|
84
|
+
readonly isReadonly: boolean;
|
|
63
85
|
/** Is this a doc we presume does not yet exist in Firestore? */
|
|
64
86
|
private isNewDoc;
|
|
65
87
|
/** Use addDoc or setDoc to write all the data? If not, use updateDoc. */
|
|
66
88
|
private isSettingNewContents;
|
|
89
|
+
/** Patcher functions given in options; applied to the raw data in order. */
|
|
90
|
+
private readonly patchers;
|
|
91
|
+
/** Don't save patches if false; delay in milliseconds if set. */
|
|
92
|
+
private readonly savePatchAfterDelay;
|
|
67
93
|
/** Local copy of the document data, parsed into the Zod type */
|
|
68
94
|
private data;
|
|
69
95
|
/** Proxy to intercept write (.w) access to the data and track the changes */
|
|
@@ -143,20 +169,20 @@ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
143
169
|
/**
|
|
144
170
|
* Is this a new doc that has not yet been written to Firestore?
|
|
145
171
|
*/
|
|
146
|
-
isNew(): boolean;
|
|
172
|
+
get isNew(): boolean;
|
|
147
173
|
/**
|
|
148
174
|
* Does the document contain data, either because it was successfully loaded
|
|
149
175
|
* or is newly created?
|
|
150
176
|
*/
|
|
151
|
-
isLoaded(): boolean;
|
|
177
|
+
get isLoaded(): boolean;
|
|
152
178
|
/**
|
|
153
179
|
* Does this document contain data that has not yet been written to Firestore?
|
|
154
180
|
*/
|
|
155
|
-
isPendingWrite(): boolean;
|
|
181
|
+
get isPendingWrite(): boolean;
|
|
156
182
|
/**
|
|
157
183
|
* Are we listening for changes to this document?
|
|
158
184
|
*/
|
|
159
|
-
isListening(): boolean;
|
|
185
|
+
get isListening(): boolean;
|
|
160
186
|
/**
|
|
161
187
|
* Loads this document's data from Firestore.
|
|
162
188
|
*
|
|
@@ -198,6 +224,13 @@ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
198
224
|
* changes to it.
|
|
199
225
|
*/
|
|
200
226
|
update(mutator: (data: z.infer<SchemaType>) => void): Promise<this>;
|
|
227
|
+
private throwIfReadonly;
|
|
228
|
+
/**
|
|
229
|
+
* Given a snapshot, patch it, parse it, and save it as this doc's data. If
|
|
230
|
+
* not called from a listener, the patched data may be written to Firestore
|
|
231
|
+
* after a delay.
|
|
232
|
+
*/
|
|
233
|
+
private loadFromSnapshot;
|
|
201
234
|
/**
|
|
202
235
|
* Adds a field and its new value to the list of updates to be passed to
|
|
203
236
|
* Firestore's updateDoc(). Called when the proxies detect changes to the
|
package/dist/FiretenderDoc.js
CHANGED
|
@@ -27,14 +27,20 @@ class FiretenderDoc {
|
|
|
27
27
|
this.updates = new Map();
|
|
28
28
|
this.schema = schema;
|
|
29
29
|
this.ref = ref;
|
|
30
|
+
this.isReadonly = options.readonly ?? false;
|
|
30
31
|
this.isNewDoc = options.createDoc ?? false;
|
|
32
|
+
if (this.isReadonly && this.isNewDoc) {
|
|
33
|
+
throw new errors_1.FiretenderUsageError("Cannot create new docs in readonly mode.");
|
|
34
|
+
}
|
|
31
35
|
this.isSettingNewContents = this.isNewDoc;
|
|
32
36
|
if (options.initialData) {
|
|
33
37
|
this.data = schema.parse(options.initialData);
|
|
34
38
|
}
|
|
35
39
|
else if (this.isNewDoc) {
|
|
36
|
-
throw
|
|
40
|
+
throw new errors_1.FiretenderUsageError("Initial data must be given when creating a new doc.");
|
|
37
41
|
}
|
|
42
|
+
this.patchers = options.patchers;
|
|
43
|
+
this.savePatchAfterDelay = options.savePatchAfterDelay ?? 500;
|
|
38
44
|
if (this.ref instanceof firestore_deps_1.DocumentReference) {
|
|
39
45
|
this.docID = this.ref.path.split("/").pop();
|
|
40
46
|
}
|
|
@@ -160,26 +166,26 @@ class FiretenderDoc {
|
|
|
160
166
|
/**
|
|
161
167
|
* Is this a new doc that has not yet been written to Firestore?
|
|
162
168
|
*/
|
|
163
|
-
isNew() {
|
|
169
|
+
get isNew() {
|
|
164
170
|
return this.isNewDoc;
|
|
165
171
|
}
|
|
166
172
|
/**
|
|
167
173
|
* Does the document contain data, either because it was successfully loaded
|
|
168
174
|
* or is newly created?
|
|
169
175
|
*/
|
|
170
|
-
isLoaded() {
|
|
176
|
+
get isLoaded() {
|
|
171
177
|
return this.data !== undefined;
|
|
172
178
|
}
|
|
173
179
|
/**
|
|
174
180
|
* Does this document contain data that has not yet been written to Firestore?
|
|
175
181
|
*/
|
|
176
|
-
isPendingWrite() {
|
|
182
|
+
get isPendingWrite() {
|
|
177
183
|
return this.isSettingNewContents || this.updates.size > 0;
|
|
178
184
|
}
|
|
179
185
|
/**
|
|
180
186
|
* Are we listening for changes to this document?
|
|
181
187
|
*/
|
|
182
|
-
isListening() {
|
|
188
|
+
get isListening() {
|
|
183
189
|
return this.detachListener !== undefined;
|
|
184
190
|
}
|
|
185
191
|
/**
|
|
@@ -218,7 +224,7 @@ class FiretenderDoc {
|
|
|
218
224
|
initialResolve(newSnapshot);
|
|
219
225
|
return;
|
|
220
226
|
}
|
|
221
|
-
if (this.isPendingWrite
|
|
227
|
+
if (this.isPendingWrite) {
|
|
222
228
|
// Drop changes when a write is pending. This listener will be called
|
|
223
229
|
// again when the write happens, at which point it will include both
|
|
224
230
|
// the locally written changes and the remote changes.
|
|
@@ -233,9 +239,8 @@ class FiretenderDoc {
|
|
|
233
239
|
callback?.(this, newSnapshot);
|
|
234
240
|
return;
|
|
235
241
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.dataProxy = undefined;
|
|
242
|
+
if (!this.loadFromSnapshot(newSnapshot, true))
|
|
243
|
+
return;
|
|
239
244
|
callback?.(this, newSnapshot);
|
|
240
245
|
};
|
|
241
246
|
let detach;
|
|
@@ -264,9 +269,7 @@ class FiretenderDoc {
|
|
|
264
269
|
this.resolvesWaitingForLoad.forEach((wait) => wait.reject(error));
|
|
265
270
|
throw error;
|
|
266
271
|
}
|
|
267
|
-
this.
|
|
268
|
-
// Dereference the old proxy, if any, to force a recapture of data.
|
|
269
|
-
this.dataProxy = undefined;
|
|
272
|
+
this.loadFromSnapshot(snapshot, false);
|
|
270
273
|
this.resolvesWaitingForLoad.forEach((wait) => wait.resolve());
|
|
271
274
|
this.resolvesWaitingForLoad = undefined;
|
|
272
275
|
return this;
|
|
@@ -296,6 +299,7 @@ class FiretenderDoc {
|
|
|
296
299
|
* considerably more efficient when reading.
|
|
297
300
|
*/
|
|
298
301
|
get w() {
|
|
302
|
+
this.throwIfReadonly();
|
|
299
303
|
if (this.isSettingNewContents) {
|
|
300
304
|
// No need to monitor changes if we're setting rather than updating.
|
|
301
305
|
return this.data;
|
|
@@ -313,6 +317,7 @@ class FiretenderDoc {
|
|
|
313
317
|
* Writable accessor to overwrite all the document data.
|
|
314
318
|
*/
|
|
315
319
|
set w(newData) {
|
|
320
|
+
this.throwIfReadonly();
|
|
316
321
|
this.data = this.schema.parse(newData);
|
|
317
322
|
this.isSettingNewContents = true;
|
|
318
323
|
this.dataProxy = undefined;
|
|
@@ -321,16 +326,22 @@ class FiretenderDoc {
|
|
|
321
326
|
* Writes the document or any updates to Firestore.
|
|
322
327
|
*/
|
|
323
328
|
async write() {
|
|
329
|
+
this.throwIfReadonly();
|
|
324
330
|
// For new docs, this.data should contain its initial state.
|
|
325
331
|
if (this.isSettingNewContents) {
|
|
326
332
|
if (!this.data) {
|
|
327
333
|
throw Error("New documents must be given data before calling write().");
|
|
328
334
|
}
|
|
335
|
+
const wasNewDoc = this.isNewDoc;
|
|
336
|
+
this.isSettingNewContents = false;
|
|
337
|
+
this.isNewDoc = false;
|
|
329
338
|
if (this.ref instanceof firestore_deps_1.DocumentReference) {
|
|
330
339
|
try {
|
|
331
340
|
await (0, firestore_deps_1.setDoc)(this.ref, this.data);
|
|
332
341
|
}
|
|
333
342
|
catch (error) {
|
|
343
|
+
this.isSettingNewContents = true; // Assume the write didn't happen.
|
|
344
|
+
this.isNewDoc = wasNewDoc;
|
|
334
345
|
(0, errors_1.addContextToError)(error, "setDoc", this.ref, this.data);
|
|
335
346
|
throw error;
|
|
336
347
|
}
|
|
@@ -340,13 +351,13 @@ class FiretenderDoc {
|
|
|
340
351
|
this.ref = await (0, firestore_deps_1.addDoc)(this.ref, this.data);
|
|
341
352
|
}
|
|
342
353
|
catch (error) {
|
|
354
|
+
this.isSettingNewContents = true; // Assume the write didn't happen.
|
|
355
|
+
this.isNewDoc = wasNewDoc;
|
|
343
356
|
(0, errors_1.addContextToError)(error, "addDoc", this.ref, this.data);
|
|
344
357
|
throw error;
|
|
345
358
|
}
|
|
346
359
|
this.docID = this.ref.path.split("/").pop(); // ID is last part of path.
|
|
347
360
|
}
|
|
348
|
-
this.isSettingNewContents = false;
|
|
349
|
-
this.isNewDoc = false;
|
|
350
361
|
}
|
|
351
362
|
// For existing docs, this.updates should contain a list of changes.
|
|
352
363
|
else {
|
|
@@ -379,6 +390,7 @@ class FiretenderDoc {
|
|
|
379
390
|
* changes to it.
|
|
380
391
|
*/
|
|
381
392
|
async update(mutator) {
|
|
393
|
+
this.throwIfReadonly();
|
|
382
394
|
await this.load();
|
|
383
395
|
mutator(this.w);
|
|
384
396
|
await this.write();
|
|
@@ -386,6 +398,42 @@ class FiretenderDoc {
|
|
|
386
398
|
}
|
|
387
399
|
//////////////////////////////////////////////////////////////////////////////
|
|
388
400
|
// Private functions
|
|
401
|
+
throwIfReadonly() {
|
|
402
|
+
if (this.isReadonly) {
|
|
403
|
+
throw new errors_1.FiretenderUsageError(`An attempt was made to modify or write a read-only doc: ${this.docID}`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Given a snapshot, patch it, parse it, and save it as this doc's data. If
|
|
408
|
+
* not called from a listener, the patched data may be written to Firestore
|
|
409
|
+
* after a delay.
|
|
410
|
+
*/
|
|
411
|
+
loadFromSnapshot(snapshot, isListener = false) {
|
|
412
|
+
const data = snapshot.data();
|
|
413
|
+
if (!data) {
|
|
414
|
+
// I'm not sure why this ever happens given that the snapshot claims to
|
|
415
|
+
// exists, but I've seen it in listeners in real-world use. I can't
|
|
416
|
+
// duplicate in test. Not much we can do but ignore it.
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
if (this.patchers) {
|
|
420
|
+
const wasPatched = this.patchers.reduce((wasPatched, patcher) => patcher(data) || wasPatched, false);
|
|
421
|
+
this.isSettingNewContents = true;
|
|
422
|
+
if (wasPatched) {
|
|
423
|
+
// Listeners don't update the data on Firestore, as that would cause an
|
|
424
|
+
// infinite loop of updates if a patcher always returns true.
|
|
425
|
+
if (!isListener &&
|
|
426
|
+
!this.isReadonly &&
|
|
427
|
+
this.savePatchAfterDelay !== false) {
|
|
428
|
+
setTimeout(() => this.write(), this.savePatchAfterDelay);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
this.data = this.schema.parse(data);
|
|
433
|
+
// Dereference the old proxy to force a recapture of data.
|
|
434
|
+
this.dataProxy = undefined;
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
389
437
|
/**
|
|
390
438
|
* Adds a field and its new value to the list of updates to be passed to
|
|
391
439
|
* Firestore's updateDoc(). Called when the proxies detect changes to the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiretenderDoc.js","sourceRoot":"","sources":["../src/FiretenderDoc.ts"],"names":[],"mappings":";;;AAEA,qCAKkB;AAClB,qDAa0B;AAC1B,mCAA0C;AA4D1C;;GAEG;AACH,MAAa,aAAa;IAoCxB;;;;;;;OAOG;IACH,YACE,MAAkB,EAClB,GAA4C,EAC5C,UAAmC,EAAE;QAxCvC,yEAAyE;QACjE,UAAK,GAAuB,SAAS,CAAC;QAQ9C,gEAAgE;QACxD,SAAI,GAAoC,SAAS,CAAC;QAE1D,6EAA6E;QACrE,cAAS,GAAkD,SAAS,CAAC;QAE7E,2EAA2E;QACnE,YAAO,GAAG,IAAI,GAAG,EAAe,CAAC;QA0BvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC3C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC1C,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SAC/C;aAAM,IAAI,IAAI,CAAC,QAAQ,EAAE;YACxB,MAAM,cAAc,CAClB,qDAAqD,CACtD,CAAC;SACH;QACD,IAAI,IAAI,CAAC,GAAG,YAAY,kCAAiB,EAAE;YAC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CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE;YACzB,yEAAyE;YACzE,oEAAoE;YACpE,oEAAoE;YACpE,mEAAmE;YACnE,IACE,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;gBAC1B,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC3D,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAClE,CAAC,CAAC,EACF;gBACA,OAAO;aACR;YACD,wDAAwD;YACxD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAClC,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;oBAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;iBAC1B;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,8DAA8D;YAC9D,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AA1jBD,sCA0jBC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { Timestamp, where } from "./firestore-deps";
|
|
|
3
3
|
import { FiretenderCollection } from "./FiretenderCollection";
|
|
4
4
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
5
5
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
6
|
-
import {
|
|
7
|
-
export { FiretenderCollection, FiretenderDoc, FiretenderDocOptions, FiretenderError, FiretenderInternalError, FiretenderIOError, FiretenderUsageError,
|
|
6
|
+
import { futureTimestamp, serverTimestamp, serverTimestampWithClientTime, timestampSchema } from "./timestamps";
|
|
7
|
+
export { FiretenderCollection, FiretenderDoc, FiretenderDocOptions, FiretenderError, FiretenderInternalError, FiretenderIOError, FiretenderUsageError, futureTimestamp, serverTimestamp, serverTimestampWithClientTime, Timestamp, timestampSchema, where, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.where = exports.timestampSchema = exports.Timestamp = exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.
|
|
3
|
+
exports.where = exports.timestampSchema = exports.Timestamp = exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.futureTimestamp = exports.FiretenderUsageError = exports.FiretenderIOError = exports.FiretenderInternalError = exports.FiretenderError = exports.FiretenderDoc = exports.FiretenderCollection = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
Object.defineProperty(exports, "FiretenderError", { enumerable: true, get: function () { return errors_1.FiretenderError; } });
|
|
6
6
|
Object.defineProperty(exports, "FiretenderInternalError", { enumerable: true, get: function () { return errors_1.FiretenderInternalError; } });
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "FiretenderCollection", { enumerable: true, get:
|
|
|
14
14
|
const FiretenderDoc_1 = require("./FiretenderDoc");
|
|
15
15
|
Object.defineProperty(exports, "FiretenderDoc", { enumerable: true, get: function () { return FiretenderDoc_1.FiretenderDoc; } });
|
|
16
16
|
const timestamps_1 = require("./timestamps");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "futureTimestamp", { enumerable: true, get: function () { return timestamps_1.futureTimestamp; } });
|
|
18
18
|
Object.defineProperty(exports, "serverTimestamp", { enumerable: true, get: function () { return timestamps_1.serverTimestamp; } });
|
|
19
19
|
Object.defineProperty(exports, "serverTimestampWithClientTime", { enumerable: true, get: function () { return timestamps_1.serverTimestampWithClientTime; } });
|
|
20
20
|
Object.defineProperty(exports, "timestampSchema", { enumerable: true, get: function () { return timestamps_1.timestampSchema; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKkB;AAgBhB,gGApBA,wBAAe,OAoBA;AACf,wGApBA,gCAAuB,OAoBA;AACvB,kGApBA,0BAAiB,OAoBA;AACjB,qGApBA,6BAAoB,OAoBA;AAlBtB,qDAAoD;AAsBlD,0FAtBO,0BAAS,OAsBP;AAET,sFAxBkB,sBAAK,OAwBlB;AAvBP,iEAA8D;AAW5D,qGAXO,2CAAoB,OAWP;AATtB,mDAAgD;AAU9C,8FAVO,6BAAa,OAUP;AATf,6CAKsB;AAUpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKkB;AAgBhB,gGApBA,wBAAe,OAoBA;AACf,wGApBA,gCAAuB,OAoBA;AACvB,kGApBA,0BAAiB,OAoBA;AACjB,qGApBA,6BAAoB,OAoBA;AAlBtB,qDAAoD;AAsBlD,0FAtBO,0BAAS,OAsBP;AAET,sFAxBkB,sBAAK,OAwBlB;AAvBP,iEAA8D;AAW5D,qGAXO,2CAAoB,OAWP;AATtB,mDAAgD;AAU9C,8FAVO,6BAAa,OAUP;AATf,6CAKsB;AAUpB,gGAdA,4BAAe,OAcA;AACf,gGAdA,4BAAe,OAcA;AACf,8GAdA,0CAA6B,OAcA;AAE7B,gGAfA,4BAAe,OAeA"}
|
package/dist/timestamps.d.ts
CHANGED
|
@@ -9,13 +9,22 @@ export declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timesta
|
|
|
9
9
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
10
10
|
* used for writing TTLs.
|
|
11
11
|
*
|
|
12
|
-
* The client's clock
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
13
|
+
* future, this is generally not a concern. However, this function should not
|
|
14
|
+
* be depended on for short offsets.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
17
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
18
|
+
*
|
|
19
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
17
20
|
*/
|
|
18
|
-
export declare function
|
|
21
|
+
export declare function futureTimestamp(interval: {
|
|
22
|
+
days?: number;
|
|
23
|
+
hours?: number;
|
|
24
|
+
minutes?: number;
|
|
25
|
+
seconds?: number;
|
|
26
|
+
millis?: number;
|
|
27
|
+
}): Timestamp;
|
|
19
28
|
/**
|
|
20
29
|
* Returns a sentinel to include a server-generated timestamp in the written
|
|
21
30
|
* data.
|
package/dist/timestamps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.
|
|
3
|
+
exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.futureTimestamp = exports.timestampSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const firestore_deps_1 = require("./firestore-deps");
|
|
6
6
|
/**
|
|
@@ -12,16 +12,30 @@ exports.timestampSchema = zod_1.z.custom((data) => data instanceof firestore_dep
|
|
|
12
12
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
13
13
|
* used for writing TTLs.
|
|
14
14
|
*
|
|
15
|
-
* The client's clock
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
16
|
+
* future, this is generally not a concern. However, this function should not
|
|
17
|
+
* be depended on for short offsets.
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
20
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
21
|
+
*
|
|
22
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
20
23
|
*/
|
|
21
|
-
function
|
|
22
|
-
|
|
24
|
+
function futureTimestamp(interval) {
|
|
25
|
+
let utcMillis = Date.now();
|
|
26
|
+
if (interval.days)
|
|
27
|
+
utcMillis += interval.days * 24 * 60 * 60 * 1000;
|
|
28
|
+
if (interval.hours)
|
|
29
|
+
utcMillis += interval.hours * 60 * 60 * 1000;
|
|
30
|
+
if (interval.minutes)
|
|
31
|
+
utcMillis += interval.minutes * 60 * 1000;
|
|
32
|
+
if (interval.seconds)
|
|
33
|
+
utcMillis += interval.seconds * 1000;
|
|
34
|
+
if (interval.millis)
|
|
35
|
+
utcMillis += interval.millis;
|
|
36
|
+
return firestore_deps_1.Timestamp.fromMillis(utcMillis);
|
|
23
37
|
}
|
|
24
|
-
exports.
|
|
38
|
+
exports.futureTimestamp = futureTimestamp;
|
|
25
39
|
/**
|
|
26
40
|
* Returns a sentinel to include a server-generated timestamp in the written
|
|
27
41
|
* data.
|
package/dist/timestamps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qDAI0B;AAE1B;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CACrC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,YAAY,0BAAS,IAAI,IAAA,kCAAiB,EAAC,IAAI,CAAC,CACpE,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qDAI0B;AAE1B;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CACrC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,YAAY,0BAAS,IAAI,IAAA,kCAAiB,EAAC,IAAI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G,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvD,QAAgB,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvD,QAAgB,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACtD,+DAA+D;IAC/D,iFAAiF;IACjF,sEAAsE;IACtE,OAAO,QAAqB,CAAC;AAC/B,CAAC;AAbD,sEAaC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "firetender-admin",
|
|
3
3
|
"displayName": "Firetender (for firebase-admin/firestore)",
|
|
4
4
|
"description": "Typescript wrapper for Firestore documents",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.12.0",
|
|
6
6
|
"author": "Jake Hartman",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/jakes-space/firetender",
|
|
@@ -26,20 +26,23 @@ import { DeepPartial } from "./ts-helpers";
|
|
|
26
26
|
* are covered by a FiretenderCollection for the path ["foo", "bar"].
|
|
27
27
|
*/
|
|
28
28
|
export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
29
|
-
/** Zod schema used to parse and validate the document's data */
|
|
29
|
+
/** Zod schema used to parse and validate the document's data. */
|
|
30
30
|
readonly schema: SchemaType;
|
|
31
31
|
|
|
32
|
-
/** Firestore object: the thing you get from getFirestore() */
|
|
32
|
+
/** Firestore object: the thing you get from getFirestore(). */
|
|
33
33
|
readonly firestore: Firestore;
|
|
34
34
|
|
|
35
|
-
/** The collection path of this object: a series of collection names */
|
|
35
|
+
/** The collection path of this object: a series of collection names. */
|
|
36
36
|
readonly collectionPath: string[];
|
|
37
37
|
|
|
38
38
|
/** Function to return the initial values when creating a new document. */
|
|
39
|
-
readonly baseInitialDataFactory:
|
|
39
|
+
private readonly baseInitialDataFactory:
|
|
40
40
|
| (() => DeepPartial<z.input<SchemaType>>)
|
|
41
41
|
| undefined;
|
|
42
42
|
|
|
43
|
+
/** Default options to send to docs in this collection. */
|
|
44
|
+
private readonly defaultDocOptions: FiretenderDocOptions;
|
|
45
|
+
|
|
43
46
|
/**
|
|
44
47
|
* @param schema the Zod object schema describing the documents in this
|
|
45
48
|
* collection.
|
|
@@ -48,6 +51,9 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
48
51
|
* of any parent collections and of this collection.
|
|
49
52
|
* @param baseInitialData (optional) an object or object factory providing
|
|
50
53
|
* default field values for this collection.
|
|
54
|
+
* @param options default optional parameters for the resulting FiretenderDoc;
|
|
55
|
+
* see FiretenderDocOptions for detail. Options passed to `.newDoc()` and
|
|
56
|
+
* `.existingDoc()` override these.
|
|
51
57
|
*/
|
|
52
58
|
constructor(
|
|
53
59
|
schema: SchemaType,
|
|
@@ -56,7 +62,8 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
56
62
|
baseInitialData:
|
|
57
63
|
| (() => DeepPartial<z.input<SchemaType>>)
|
|
58
64
|
| DeepPartial<z.input<SchemaType>>
|
|
59
|
-
| undefined = undefined
|
|
65
|
+
| undefined = undefined,
|
|
66
|
+
options: FiretenderDocOptions = {}
|
|
60
67
|
) {
|
|
61
68
|
this.schema = schema;
|
|
62
69
|
this.firestore = firestore;
|
|
@@ -68,6 +75,7 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
68
75
|
this.baseInitialDataFactory = () => baseInitialData;
|
|
69
76
|
}
|
|
70
77
|
}
|
|
78
|
+
this.defaultDocOptions = options;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
/**
|
|
@@ -107,7 +115,10 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
107
115
|
if (initialData) {
|
|
108
116
|
Object.assign(data, initialData);
|
|
109
117
|
}
|
|
110
|
-
return FiretenderDoc.createNewDoc(this.schema, ref, data,
|
|
118
|
+
return FiretenderDoc.createNewDoc(this.schema, ref, data, {
|
|
119
|
+
...this.defaultDocOptions,
|
|
120
|
+
...options,
|
|
121
|
+
});
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
/**
|
|
@@ -131,7 +142,10 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
131
142
|
"existingDoc() requires a full ID path for this collection and its parent collections, if any."
|
|
132
143
|
);
|
|
133
144
|
}
|
|
134
|
-
return new FiretenderDoc(this.schema, ref,
|
|
145
|
+
return new FiretenderDoc(this.schema, ref, {
|
|
146
|
+
...this.defaultDocOptions,
|
|
147
|
+
...options,
|
|
148
|
+
});
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
/**
|
|
@@ -254,6 +268,19 @@ export class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
|
254
268
|
return ref;
|
|
255
269
|
}
|
|
256
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Convenience method to provide a single patcher function for this
|
|
273
|
+
* collection's documents. Patchers can also be passed in the options
|
|
274
|
+
* argument of this class's constructor.
|
|
275
|
+
*/
|
|
276
|
+
patch(patcher: (data: DeepPartial<z.input<SchemaType>>) => boolean) {
|
|
277
|
+
if (!this.defaultDocOptions.patchers) {
|
|
278
|
+
this.defaultDocOptions.patchers = [patcher];
|
|
279
|
+
} else {
|
|
280
|
+
this.defaultDocOptions.patchers.push(patcher);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
257
284
|
//////////////////////////////////////////////////////////////////////////////
|
|
258
285
|
// Private functions
|
|
259
286
|
|
package/src/FiretenderDoc.ts
CHANGED
|
@@ -23,14 +23,41 @@ import {
|
|
|
23
23
|
import { watchForChanges } from "./proxy";
|
|
24
24
|
import { DeepReadonly } from "./ts-helpers";
|
|
25
25
|
|
|
26
|
+
/*
|
|
27
|
+
* Patcher functions serially modify the data from Firestore before it is parsed by Zod.
|
|
28
|
+
* If any of these functions returns true, the data is asynchronously updated
|
|
29
|
+
* on Firestore half a second later, if it hasn't already been written back.
|
|
30
|
+
*/
|
|
31
|
+
export type Patcher = (data: any) => boolean;
|
|
32
|
+
|
|
26
33
|
/**
|
|
27
34
|
* Public options for initializing a FiretenderDoc object.
|
|
28
|
-
*
|
|
29
|
-
* These will be added as needed (e.g., "readonly" for issue #1, possibly
|
|
30
|
-
* "queryPageLength" for issue #21).
|
|
31
35
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
export type FiretenderDocOptions = {
|
|
37
|
+
/**
|
|
38
|
+
* If set, using the `.w` accessor or `.update()` method will throw an error
|
|
39
|
+
* and any data patches will not be written.
|
|
40
|
+
*/
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Functions that modify the data from Firestore before it is parsed by Zod.
|
|
45
|
+
* If any of these functions returns true, the data is asynchronously updated
|
|
46
|
+
* on Firestore half a second later, if it hasn't already been written back.
|
|
47
|
+
*
|
|
48
|
+
* The patchers are applied to the data in the order given, each receiving the
|
|
49
|
+
* output of the previous. The output of the last is fed to Zod.
|
|
50
|
+
*/
|
|
51
|
+
patchers?: Patcher[] | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If false, don't write the data back to Firestore, even if a patcher returns
|
|
55
|
+
* true. Otherwise, the delay in milliseconds before patching. This delay
|
|
56
|
+
* avoids an extra write in the case of a quick read/modify/write cycle.
|
|
57
|
+
* Defaults to 500, for a half-second delay.
|
|
58
|
+
*/
|
|
59
|
+
savePatchAfterDelay?: false | number;
|
|
60
|
+
};
|
|
34
61
|
|
|
35
62
|
/**
|
|
36
63
|
* All options when initializing a FiretenderDoc object.
|
|
@@ -93,12 +120,21 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
93
120
|
/** Firestore document ID; undefined for new docs not yet on Firestore */
|
|
94
121
|
private docID: string | undefined = undefined;
|
|
95
122
|
|
|
123
|
+
/** If set, writes will throw and patches will not be written. */
|
|
124
|
+
readonly isReadonly: boolean;
|
|
125
|
+
|
|
96
126
|
/** Is this a doc we presume does not yet exist in Firestore? */
|
|
97
127
|
private isNewDoc: boolean;
|
|
98
128
|
|
|
99
129
|
/** Use addDoc or setDoc to write all the data? If not, use updateDoc. */
|
|
100
130
|
private isSettingNewContents: boolean;
|
|
101
131
|
|
|
132
|
+
/** Patcher functions given in options; applied to the raw data in order. */
|
|
133
|
+
private readonly patchers: Patcher[] | undefined;
|
|
134
|
+
|
|
135
|
+
/** Don't save patches if false; delay in milliseconds if set. */
|
|
136
|
+
private readonly savePatchAfterDelay: false | number;
|
|
137
|
+
|
|
102
138
|
/** Local copy of the document data, parsed into the Zod type */
|
|
103
139
|
private data: z.infer<SchemaType> | undefined = undefined;
|
|
104
140
|
|
|
@@ -134,15 +170,23 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
134
170
|
) {
|
|
135
171
|
this.schema = schema;
|
|
136
172
|
this.ref = ref;
|
|
173
|
+
this.isReadonly = options.readonly ?? false;
|
|
137
174
|
this.isNewDoc = options.createDoc ?? false;
|
|
175
|
+
if (this.isReadonly && this.isNewDoc) {
|
|
176
|
+
throw new FiretenderUsageError(
|
|
177
|
+
"Cannot create new docs in readonly mode."
|
|
178
|
+
);
|
|
179
|
+
}
|
|
138
180
|
this.isSettingNewContents = this.isNewDoc;
|
|
139
181
|
if (options.initialData) {
|
|
140
182
|
this.data = schema.parse(options.initialData);
|
|
141
183
|
} else if (this.isNewDoc) {
|
|
142
|
-
throw
|
|
184
|
+
throw new FiretenderUsageError(
|
|
143
185
|
"Initial data must be given when creating a new doc."
|
|
144
186
|
);
|
|
145
187
|
}
|
|
188
|
+
this.patchers = options.patchers;
|
|
189
|
+
this.savePatchAfterDelay = options.savePatchAfterDelay ?? 500;
|
|
146
190
|
if (this.ref instanceof DocumentReference) {
|
|
147
191
|
this.docID = this.ref.path.split("/").pop();
|
|
148
192
|
} else if (!this.isNewDoc) {
|
|
@@ -295,7 +339,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
295
339
|
/**
|
|
296
340
|
* Is this a new doc that has not yet been written to Firestore?
|
|
297
341
|
*/
|
|
298
|
-
isNew(): boolean {
|
|
342
|
+
get isNew(): boolean {
|
|
299
343
|
return this.isNewDoc;
|
|
300
344
|
}
|
|
301
345
|
|
|
@@ -303,21 +347,21 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
303
347
|
* Does the document contain data, either because it was successfully loaded
|
|
304
348
|
* or is newly created?
|
|
305
349
|
*/
|
|
306
|
-
isLoaded(): boolean {
|
|
350
|
+
get isLoaded(): boolean {
|
|
307
351
|
return this.data !== undefined;
|
|
308
352
|
}
|
|
309
353
|
|
|
310
354
|
/**
|
|
311
355
|
* Does this document contain data that has not yet been written to Firestore?
|
|
312
356
|
*/
|
|
313
|
-
isPendingWrite(): boolean {
|
|
357
|
+
get isPendingWrite(): boolean {
|
|
314
358
|
return this.isSettingNewContents || this.updates.size > 0;
|
|
315
359
|
}
|
|
316
360
|
|
|
317
361
|
/**
|
|
318
362
|
* Are we listening for changes to this document?
|
|
319
363
|
*/
|
|
320
|
-
isListening(): boolean {
|
|
364
|
+
get isListening(): boolean {
|
|
321
365
|
return this.detachListener !== undefined;
|
|
322
366
|
}
|
|
323
367
|
|
|
@@ -367,7 +411,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
367
411
|
initialResolve(newSnapshot);
|
|
368
412
|
return;
|
|
369
413
|
}
|
|
370
|
-
if (this.isPendingWrite
|
|
414
|
+
if (this.isPendingWrite) {
|
|
371
415
|
// Drop changes when a write is pending. This listener will be called
|
|
372
416
|
// again when the write happens, at which point it will include both
|
|
373
417
|
// the locally written changes and the remote changes.
|
|
@@ -382,9 +426,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
382
426
|
callback?.(this, newSnapshot);
|
|
383
427
|
return;
|
|
384
428
|
}
|
|
385
|
-
|
|
386
|
-
// Dereference the old proxy to force a recapture of data.
|
|
387
|
-
this.dataProxy = undefined;
|
|
429
|
+
if (!this.loadFromSnapshot(newSnapshot, true)) return;
|
|
388
430
|
callback?.(this, newSnapshot);
|
|
389
431
|
};
|
|
390
432
|
let detach: Unsubscribe | undefined;
|
|
@@ -414,9 +456,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
414
456
|
this.resolvesWaitingForLoad.forEach((wait) => wait.reject(error));
|
|
415
457
|
throw error;
|
|
416
458
|
}
|
|
417
|
-
this.
|
|
418
|
-
// Dereference the old proxy, if any, to force a recapture of data.
|
|
419
|
-
this.dataProxy = undefined;
|
|
459
|
+
this.loadFromSnapshot(snapshot, false);
|
|
420
460
|
this.resolvesWaitingForLoad.forEach((wait) => wait.resolve());
|
|
421
461
|
this.resolvesWaitingForLoad = undefined;
|
|
422
462
|
return this;
|
|
@@ -451,6 +491,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
451
491
|
* considerably more efficient when reading.
|
|
452
492
|
*/
|
|
453
493
|
get w(): z.infer<SchemaType> {
|
|
494
|
+
this.throwIfReadonly();
|
|
454
495
|
if (this.isSettingNewContents) {
|
|
455
496
|
// No need to monitor changes if we're setting rather than updating.
|
|
456
497
|
return this.data as z.infer<SchemaType>;
|
|
@@ -476,6 +517,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
476
517
|
* Writable accessor to overwrite all the document data.
|
|
477
518
|
*/
|
|
478
519
|
set w(newData: z.input<SchemaType>) {
|
|
520
|
+
this.throwIfReadonly();
|
|
479
521
|
this.data = this.schema.parse(newData);
|
|
480
522
|
this.isSettingNewContents = true;
|
|
481
523
|
this.dataProxy = undefined;
|
|
@@ -485,15 +527,21 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
485
527
|
* Writes the document or any updates to Firestore.
|
|
486
528
|
*/
|
|
487
529
|
async write(): Promise<this> {
|
|
530
|
+
this.throwIfReadonly();
|
|
488
531
|
// For new docs, this.data should contain its initial state.
|
|
489
532
|
if (this.isSettingNewContents) {
|
|
490
533
|
if (!this.data) {
|
|
491
534
|
throw Error("New documents must be given data before calling write().");
|
|
492
535
|
}
|
|
536
|
+
const wasNewDoc = this.isNewDoc;
|
|
537
|
+
this.isSettingNewContents = false;
|
|
538
|
+
this.isNewDoc = false;
|
|
493
539
|
if (this.ref instanceof DocumentReference) {
|
|
494
540
|
try {
|
|
495
541
|
await setDoc(this.ref, this.data);
|
|
496
542
|
} catch (error) {
|
|
543
|
+
this.isSettingNewContents = true; // Assume the write didn't happen.
|
|
544
|
+
this.isNewDoc = wasNewDoc;
|
|
497
545
|
addContextToError(error, "setDoc", this.ref, this.data);
|
|
498
546
|
throw error;
|
|
499
547
|
}
|
|
@@ -501,13 +549,13 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
501
549
|
try {
|
|
502
550
|
this.ref = await addDoc(this.ref, this.data);
|
|
503
551
|
} catch (error: any) {
|
|
552
|
+
this.isSettingNewContents = true; // Assume the write didn't happen.
|
|
553
|
+
this.isNewDoc = wasNewDoc;
|
|
504
554
|
addContextToError(error, "addDoc", this.ref, this.data);
|
|
505
555
|
throw error;
|
|
506
556
|
}
|
|
507
557
|
this.docID = this.ref.path.split("/").pop(); // ID is last part of path.
|
|
508
558
|
}
|
|
509
|
-
this.isSettingNewContents = false;
|
|
510
|
-
this.isNewDoc = false;
|
|
511
559
|
}
|
|
512
560
|
// For existing docs, this.updates should contain a list of changes.
|
|
513
561
|
else {
|
|
@@ -542,6 +590,7 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
542
590
|
* changes to it.
|
|
543
591
|
*/
|
|
544
592
|
async update(mutator: (data: z.infer<SchemaType>) => void): Promise<this> {
|
|
593
|
+
this.throwIfReadonly();
|
|
545
594
|
await this.load();
|
|
546
595
|
mutator(this.w);
|
|
547
596
|
await this.write();
|
|
@@ -551,6 +600,51 @@ export class FiretenderDoc<SchemaType extends z.SomeZodObject> {
|
|
|
551
600
|
//////////////////////////////////////////////////////////////////////////////
|
|
552
601
|
// Private functions
|
|
553
602
|
|
|
603
|
+
private throwIfReadonly() {
|
|
604
|
+
if (this.isReadonly) {
|
|
605
|
+
throw new FiretenderUsageError(
|
|
606
|
+
`An attempt was made to modify or write a read-only doc: ${this.docID}`
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Given a snapshot, patch it, parse it, and save it as this doc's data. If
|
|
613
|
+
* not called from a listener, the patched data may be written to Firestore
|
|
614
|
+
* after a delay.
|
|
615
|
+
*/
|
|
616
|
+
private loadFromSnapshot(snapshot: DocumentSnapshot, isListener = false) {
|
|
617
|
+
const data = snapshot.data();
|
|
618
|
+
if (!data) {
|
|
619
|
+
// I'm not sure why this ever happens given that the snapshot claims to
|
|
620
|
+
// exists, but I've seen it in listeners in real-world use. I can't
|
|
621
|
+
// duplicate in test. Not much we can do but ignore it.
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
if (this.patchers) {
|
|
625
|
+
const wasPatched = this.patchers.reduce(
|
|
626
|
+
(wasPatched, patcher) => patcher(data) || wasPatched,
|
|
627
|
+
false
|
|
628
|
+
);
|
|
629
|
+
this.isSettingNewContents = true;
|
|
630
|
+
if (wasPatched) {
|
|
631
|
+
// Listeners don't update the data on Firestore, as that would cause an
|
|
632
|
+
// infinite loop of updates if a patcher always returns true.
|
|
633
|
+
if (
|
|
634
|
+
!isListener &&
|
|
635
|
+
!this.isReadonly &&
|
|
636
|
+
this.savePatchAfterDelay !== false
|
|
637
|
+
) {
|
|
638
|
+
setTimeout(() => this.write(), this.savePatchAfterDelay);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
this.data = this.schema.parse(data);
|
|
643
|
+
// Dereference the old proxy to force a recapture of data.
|
|
644
|
+
this.dataProxy = undefined;
|
|
645
|
+
return true;
|
|
646
|
+
}
|
|
647
|
+
|
|
554
648
|
/**
|
|
555
649
|
* Adds a field and its new value to the list of updates to be passed to
|
|
556
650
|
* Firestore's updateDoc(). Called when the proxies detect changes to the
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { FiretenderCollection } from "./FiretenderCollection";
|
|
|
9
9
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
10
10
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
futureTimestamp,
|
|
13
13
|
serverTimestamp,
|
|
14
14
|
serverTimestampWithClientTime,
|
|
15
15
|
timestampSchema,
|
|
@@ -23,7 +23,7 @@ export {
|
|
|
23
23
|
FiretenderInternalError,
|
|
24
24
|
FiretenderIOError,
|
|
25
25
|
FiretenderUsageError,
|
|
26
|
-
|
|
26
|
+
futureTimestamp,
|
|
27
27
|
serverTimestamp,
|
|
28
28
|
serverTimestampWithClientTime,
|
|
29
29
|
Timestamp,
|
package/src/timestamps.ts
CHANGED
|
@@ -18,14 +18,29 @@ export const timestampSchema = z.custom<Timestamp>(
|
|
|
18
18
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
19
19
|
* used for writing TTLs.
|
|
20
20
|
*
|
|
21
|
-
* The client's clock
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
22
|
+
* future, this is generally not a concern. However, this function should not
|
|
23
|
+
* be depended on for short offsets.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
26
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
27
|
+
*
|
|
28
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
26
29
|
*/
|
|
27
|
-
export function
|
|
28
|
-
|
|
30
|
+
export function futureTimestamp(interval: {
|
|
31
|
+
days?: number;
|
|
32
|
+
hours?: number;
|
|
33
|
+
minutes?: number;
|
|
34
|
+
seconds?: number;
|
|
35
|
+
millis?: number;
|
|
36
|
+
}) {
|
|
37
|
+
let utcMillis = Date.now();
|
|
38
|
+
if (interval.days) utcMillis += interval.days * 24 * 60 * 60 * 1000;
|
|
39
|
+
if (interval.hours) utcMillis += interval.hours * 60 * 60 * 1000;
|
|
40
|
+
if (interval.minutes) utcMillis += interval.minutes * 60 * 1000;
|
|
41
|
+
if (interval.seconds) utcMillis += interval.seconds * 1000;
|
|
42
|
+
if (interval.millis) utcMillis += interval.millis;
|
|
43
|
+
return Timestamp.fromMillis(utcMillis);
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
/**
|