firetender 0.5.2 → 0.5.3

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/README.md CHANGED
@@ -193,13 +193,15 @@ const cityLandmarkCollection = new FiretenderCollection(
193
193
  {}
194
194
  );
195
195
 
196
- const beijingParks = cityLandmarkCollection.query(
196
+ const beijingParks = await cityLandmarkCollection.query(
197
197
  "BJ",
198
198
  where("type", "==", "park"))
199
199
  );
200
200
  // Resulting array contains the document for Jingshan Park.
201
201
 
202
- const allParks = cityLandmarkCollection.query(where("type", "==", "park"));
202
+ const allParks = await cityLandmarkCollection.query(
203
+ where("type", "==", "park")
204
+ );
203
205
  // Resulting array has docs for Griffith Park, Ueno Park, and Jingshan Park.
204
206
  ```
205
207
 
@@ -212,7 +214,7 @@ const citySchema = z.object({ /* ... */ });
212
214
  const cityCollection = new FiretenderCollection(
213
215
  citySchema, [firestore, "cities"], {}
214
216
  );
215
- cityCollection.delete("LA");
217
+ await cityCollection.delete("LA");
216
218
  ```
217
219
 
218
220
  Subcollections are not deleted; in this example, the LA landmark docs would
@@ -226,10 +228,8 @@ server environment.
226
228
  The [full list of issues](https://github.com/jakes-space/firetender/issues) is
227
229
  tracked on Github. Here are some features on the roadmap:
228
230
 
229
- * Javadoc
230
- * Document the code!
231
- ([#12](https://github.com/jakes-space/firetender/issues/12))
232
- * Compile them to an API reference page in markdown.
231
+ * Dcoumentation
232
+ * Compile JSDoc to an API reference page in markdown.
233
233
  ([#13](https://github.com/jakes-space/firetender/issues/13))
234
234
  * Concurrency
235
235
  * Listen for changes and update the object if it has not been locally
@@ -1,30 +1,95 @@
1
1
  import { Firestore, QueryConstraint } from "firebase/firestore";
2
2
  import { z } from "zod";
3
- import { FiretenderDoc, FiretenderDocOptions } from "./FiretenderDoc";
3
+ import { FiretenderDoc, PublicFiretenderDocOptions } from "./FiretenderDoc";
4
4
  import { DeepPartial } from "./ts-helpers";
5
- export declare class FiretenderCollection<SchemaType extends z.SomeZodObject> {
5
+ /**
6
+ * A representation of a Firestore collection or subcollection.
7
+ */
8
+ export declare class FiretenderCollection<SchemaType extends z.SomeZodObject, DataType extends z.infer<SchemaType> = z.infer<SchemaType>, InputType extends z.input<SchemaType> = z.input<SchemaType>> {
6
9
  readonly schema: SchemaType;
7
10
  readonly firestore: Firestore;
8
11
  readonly collectionNames: string[];
9
- readonly baseInitialData: DeepPartial<z.infer<SchemaType>>;
10
- constructor(schema: SchemaType, collectionPath: [Firestore, ...string[]], baseInitialData: DeepPartial<z.infer<SchemaType>>);
11
- createNewDoc(id?: string[] | string | undefined, initialData?: DeepPartial<z.infer<SchemaType>> | undefined, options?: FiretenderDocOptions): FiretenderDoc<SchemaType, z.TypeOf<SchemaType>>;
12
- getExistingDoc(id: string[] | string, options?: FiretenderDocOptions): FiretenderDoc<SchemaType, z.TypeOf<SchemaType>>;
13
- getAllDocs(id?: string[] | string | undefined): Promise<FiretenderDoc<SchemaType, z.TypeOf<SchemaType>>[]>;
14
- query(idOrWhereClause: string | string[] | QueryConstraint, ...moreWhereClauses: QueryConstraint[]): Promise<FiretenderDoc<SchemaType, z.TypeOf<SchemaType>>[]>;
12
+ readonly baseInitialData: DeepPartial<InputType> | undefined;
13
+ /**
14
+ * @param schema the Zod object schema describing the documents in this
15
+ * collection.
16
+ * @param collectionPath the path of this collection in Firestore. The first
17
+ * entry must be a Firestore object, followed by the names of any parent
18
+ * collections and of this collection.
19
+ * @param baseInitialData (optional) default field values for this collection.
20
+ */
21
+ constructor(schema: SchemaType, collectionPath: [Firestore, ...string[]], baseInitialData?: DeepPartial<z.input<SchemaType>> | undefined);
22
+ /**
23
+ * Returns a FiretenderDoc representing a new document in this collection.
24
+ *
25
+ * This method initializes the FiretenderDoc but does not create it in
26
+ * Firestore. To do so, call the doc's write() method.
27
+ *
28
+ * @param id the ID or array of IDs giving the path of the new document.
29
+ * Firestore will generate a random doc ID if it is omitted. If this is a
30
+ * subcollection, the ID(s) for the parent collection(s) are required.
31
+ * @param initialData the document's initial data, which is merged with (and
32
+ * potentially overwrites) field values specified in the constructor.
33
+ * @param options optional parameters for the resulting FiretenderDoc; see
34
+ * FiretenderDocOptions for detail.
35
+ */
36
+ createNewDoc(id?: string[] | string | undefined, initialData?: DeepPartial<InputType> | undefined, options?: PublicFiretenderDocOptions): FiretenderDoc<SchemaType, DataType>;
37
+ /**
38
+ * Returns a FiretenderDoc representing an existing Firestore document in this
39
+ * collection.
40
+ *
41
+ * This method initializes the FiretenderDoc but does not load its data. If
42
+ * the doc does not exist in Firestore, calling load() will throw an error.
43
+ *
44
+ * @param id the ID or array of IDs specifying the desired document.
45
+ * @param options optional parameters for the resulting FiretenderDoc; see
46
+ * FiretenderDocOptions for detail.
47
+ */
48
+ getExistingDoc(id: string[] | string, options?: PublicFiretenderDocOptions): FiretenderDoc<SchemaType, DataType>;
49
+ /**
50
+ * Returns an array of all the documents in this collection.
51
+ *
52
+ * If the collection may contain a large number of documents, use query() with
53
+ * the limit() and startAfter() contraints to paginate the results.
54
+ *
55
+ * @param id (optional) when querying a subcollection, the ID(s) of its parent
56
+ * collection(s).
57
+ */
58
+ getAllDocs(id?: string[] | string | undefined): Promise<FiretenderDoc<SchemaType, DataType>[]>;
59
+ /**
60
+ * Returns an array of the documents matching the given query.
61
+ *
62
+ * @param id (optional) when querying a subcollection, the ID(s) of its parent
63
+ * collection(s); omit when querying a top-level collection or when querying
64
+ * all docs in this subcollection, regardless of parent.
65
+ * @param ...whereClauses the where(), limit(), orderBy(), startAfter(), etc.
66
+ * constraints defining this query.
67
+ */
68
+ query(idOrWhereClause: string | string[] | QueryConstraint, ...moreWhereClauses: QueryConstraint[]): Promise<FiretenderDoc<SchemaType, DataType>[]>;
15
69
  /**
16
70
  * Deletes the given document from this collection.
17
71
  *
18
- * Subcollections (if any) are not deleted. To also delete a document's
19
- * subcollections, use query() to get lists of the subcollections' docs, then
20
- * call delete() on each one. Please note that the Firestore guide recommends
21
- * only performing such unbounded batched deletions from a trusted server
22
- * environment.
72
+ * The document's subcollections (if any) are not deleted. To delete them,
73
+ * first use query() to get its subcollection docs, then call delete() on each
74
+ * one. Please note that the Firestore guide recommends only performing such
75
+ * unbounded batched deletions from a trusted server environment.
23
76
  *
24
77
  * @param id full path ID of the target document.
25
78
  */
26
79
  delete(id: string[] | string): Promise<void>;
80
+ /**
81
+ * Builds a doc ref from the given IDs, or returns "undefined" if the IDs do
82
+ * not correctly specify a doc path.
83
+ */
27
84
  private makeDocRef;
85
+ /**
86
+ * Builds a collection ref from the given IDs, or returns "undefined" if the
87
+ * IDs do not correctly specify a collection path.
88
+ */
28
89
  private makeCollectionRef;
90
+ /**
91
+ * Executes the given query and returns an array of the results, wrapped in
92
+ * FiretenderDoc objects.
93
+ */
29
94
  private getAndWrapDocs;
30
95
  }
@@ -3,13 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FiretenderCollection = void 0;
4
4
  const firestore_1 = require("firebase/firestore");
5
5
  const FiretenderDoc_1 = require("./FiretenderDoc");
6
+ /**
7
+ * A representation of a Firestore collection or subcollection.
8
+ */
6
9
  class FiretenderCollection {
7
- constructor(schema, collectionPath, baseInitialData) {
10
+ /**
11
+ * @param schema the Zod object schema describing the documents in this
12
+ * collection.
13
+ * @param collectionPath the path of this collection in Firestore. The first
14
+ * entry must be a Firestore object, followed by the names of any parent
15
+ * collections and of this collection.
16
+ * @param baseInitialData (optional) default field values for this collection.
17
+ */
18
+ constructor(schema, collectionPath, baseInitialData = undefined) {
8
19
  this.schema = schema;
9
20
  this.firestore = collectionPath[0];
10
21
  this.collectionNames = collectionPath.slice(1);
11
- this.baseInitialData = baseInitialData;
22
+ if (baseInitialData) {
23
+ this.baseInitialData = baseInitialData;
24
+ }
12
25
  }
26
+ /**
27
+ * Returns a FiretenderDoc representing a new document in this collection.
28
+ *
29
+ * This method initializes the FiretenderDoc but does not create it in
30
+ * Firestore. To do so, call the doc's write() method.
31
+ *
32
+ * @param id the ID or array of IDs giving the path of the new document.
33
+ * Firestore will generate a random doc ID if it is omitted. If this is a
34
+ * subcollection, the ID(s) for the parent collection(s) are required.
35
+ * @param initialData the document's initial data, which is merged with (and
36
+ * potentially overwrites) field values specified in the constructor.
37
+ * @param options optional parameters for the resulting FiretenderDoc; see
38
+ * FiretenderDocOptions for detail.
39
+ */
13
40
  createNewDoc(id = undefined, initialData = undefined, options = {}) {
14
41
  const ids = id instanceof Array ? id : id ? [id] : [];
15
42
  let ref = this.makeDocRef(ids);
@@ -17,29 +44,61 @@ class FiretenderCollection {
17
44
  ref = this.makeCollectionRef(ids);
18
45
  }
19
46
  if (!ref) {
20
- throw Error("createNewDoc() requires an ID for all collections and subcollections except optionally the last.");
47
+ throw Error("createNewDoc() requires an ID path for all collections and subcollections, except optionally the last.");
48
+ }
49
+ const data = {};
50
+ if (this.baseInitialData) {
51
+ Object.assign(data, this.baseInitialData);
21
52
  }
22
- const data = this.baseInitialData;
23
53
  if (initialData) {
24
54
  Object.assign(data, initialData);
25
55
  }
26
56
  return FiretenderDoc_1.FiretenderDoc.createNewDoc(this.schema, ref, data, options);
27
57
  }
58
+ /**
59
+ * Returns a FiretenderDoc representing an existing Firestore document in this
60
+ * collection.
61
+ *
62
+ * This method initializes the FiretenderDoc but does not load its data. If
63
+ * the doc does not exist in Firestore, calling load() will throw an error.
64
+ *
65
+ * @param id the ID or array of IDs specifying the desired document.
66
+ * @param options optional parameters for the resulting FiretenderDoc; see
67
+ * FiretenderDocOptions for detail.
68
+ */
28
69
  getExistingDoc(id, options = {}) {
29
70
  const ref = this.makeDocRef([id].flat());
30
71
  if (!ref) {
31
- throw Error("getExistingDoc() requires an ID for the collection and IDs for each of its subcollections (if any).");
72
+ throw Error("getExistingDoc() requires a full ID path for this collection and its parent collections, if any.");
32
73
  }
33
74
  return new FiretenderDoc_1.FiretenderDoc(this.schema, ref, options);
34
75
  }
76
+ /**
77
+ * Returns an array of all the documents in this collection.
78
+ *
79
+ * If the collection may contain a large number of documents, use query() with
80
+ * the limit() and startAfter() contraints to paginate the results.
81
+ *
82
+ * @param id (optional) when querying a subcollection, the ID(s) of its parent
83
+ * collection(s).
84
+ */
35
85
  async getAllDocs(id = undefined) {
36
86
  const ids = id instanceof Array ? id : id ? [id] : [];
37
87
  const collectionRef = this.makeCollectionRef(ids);
38
88
  if (!collectionRef) {
39
- throw Error("getAllDocs() requires an ID for all collections and subcollections except the last.");
89
+ throw Error("When querying a subcollection, getAllDocs() requires the IDs of all parent collections.");
40
90
  }
41
91
  return this.getAndWrapDocs(collectionRef);
42
92
  }
93
+ /**
94
+ * Returns an array of the documents matching the given query.
95
+ *
96
+ * @param id (optional) when querying a subcollection, the ID(s) of its parent
97
+ * collection(s); omit when querying a top-level collection or when querying
98
+ * all docs in this subcollection, regardless of parent.
99
+ * @param ...whereClauses the where(), limit(), orderBy(), startAfter(), etc.
100
+ * constraints defining this query.
101
+ */
43
102
  async query(idOrWhereClause, ...moreWhereClauses) {
44
103
  let ids;
45
104
  let whereClauses;
@@ -64,11 +123,10 @@ class FiretenderCollection {
64
123
  /**
65
124
  * Deletes the given document from this collection.
66
125
  *
67
- * Subcollections (if any) are not deleted. To also delete a document's
68
- * subcollections, use query() to get lists of the subcollections' docs, then
69
- * call delete() on each one. Please note that the Firestore guide recommends
70
- * only performing such unbounded batched deletions from a trusted server
71
- * environment.
126
+ * The document's subcollections (if any) are not deleted. To delete them,
127
+ * first use query() to get its subcollection docs, then call delete() on each
128
+ * one. Please note that the Firestore guide recommends only performing such
129
+ * unbounded batched deletions from a trusted server environment.
72
130
  *
73
131
  * @param id full path ID of the target document.
74
132
  */
@@ -79,6 +137,12 @@ class FiretenderCollection {
79
137
  }
80
138
  await (0, firestore_1.deleteDoc)(ref);
81
139
  }
140
+ //////////////////////////////////////////////////////////////////////////////
141
+ // Private functions
142
+ /**
143
+ * Builds a doc ref from the given IDs, or returns "undefined" if the IDs do
144
+ * not correctly specify a doc path.
145
+ */
82
146
  makeDocRef(ids) {
83
147
  if (ids.length !== this.collectionNames.length) {
84
148
  return undefined;
@@ -86,6 +150,10 @@ class FiretenderCollection {
86
150
  const path = ids.flatMap((id, i) => [this.collectionNames[i], id]);
87
151
  return (0, firestore_1.doc)(this.firestore, path[0], ...path.slice(1));
88
152
  }
153
+ /**
154
+ * Builds a collection ref from the given IDs, or returns "undefined" if the
155
+ * IDs do not correctly specify a collection path.
156
+ */
89
157
  makeCollectionRef(ids) {
90
158
  if (ids.length !== this.collectionNames.length - 1) {
91
159
  return undefined;
@@ -93,6 +161,10 @@ class FiretenderCollection {
93
161
  const subPath = ids.flatMap((id, i) => [id, this.collectionNames[i + 1]]);
94
162
  return (0, firestore_1.collection)(this.firestore, this.collectionNames[0], ...subPath);
95
163
  }
164
+ /**
165
+ * Executes the given query and returns an array of the results, wrapped in
166
+ * FiretenderDoc objects.
167
+ */
96
168
  async getAndWrapDocs(query) {
97
169
  const querySnapshot = await (0, firestore_1.getDocs)(query);
98
170
  return querySnapshot.docs.map((queryDoc) => new FiretenderDoc_1.FiretenderDoc(this.schema, queryDoc.ref, {
@@ -1 +1 @@
1
- {"version":3,"file":"FiretenderCollection.js","sourceRoot":"","sources":["../src/FiretenderCollection.ts"],"names":[],"mappings":";;;AAAA,kDAY4B;AAG5B,mDAAsE;AAGtE,MAAa,oBAAoB;IAM/B,YACE,MAAkB,EAClB,cAAwC,EACxC,eAAiD;QAEjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAa,CAAC;QAC3D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,YAAY,CACV,KAAoC,SAAS,EAC7C,cAA4D,SAAS,EACrE,UAAgC,EAAE;QAElC,MAAM,GAAG,GAAG,EAAE,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAA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EAAE;YAClD,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,IAAA,sBAAU,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,cAAc,CAC1B,KAAkC;QAElC,MAAM,aAAa,GAAG,MAAM,IAAA,mBAAO,EAAC,KAAK,CAAC,CAAC;QAC3C,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;AArND,oDAqNC"}
@@ -1,16 +1,29 @@
1
1
  import { CollectionReference, DocumentReference } from "firebase/firestore";
2
2
  import { z } from "zod";
3
3
  import { DeepReadonly } from "./ts-helpers";
4
+ /**
5
+ * Options when initializing a FiretenderDoc object.
6
+ */
4
7
  export declare type FiretenderDocOptions = {
8
+ /**
9
+ * Does this FiretenderDoc represent a new document in Firestore?
10
+ */
5
11
  createDoc?: true;
12
+ /**
13
+ * The document's initial data, which must define a valid instance of the
14
+ * document according to its schema.
15
+ */
6
16
  initialData?: Record<string, any>;
7
17
  };
8
18
  /**
9
- * Helper class for reading and writing Firestore data based on Zod schemas.
19
+ * Options when initializing a FiretenderDoc object, omitting options that are
20
+ * intended principally for internal use.
21
+ */
22
+ export declare type PublicFiretenderDocOptions = Omit<FiretenderDocOptions, "createDoc" | "initialData">;
23
+ /**
24
+ * A representation of a Firestore document.
10
25
  */
11
- export declare class FiretenderDoc<SchemaType extends z.SomeZodObject, DataType extends {
12
- [x: string]: any;
13
- } = z.infer<SchemaType>> {
26
+ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject, DataType extends z.infer<SchemaType> = z.infer<SchemaType>> {
14
27
  readonly schema: SchemaType;
15
28
  private ref;
16
29
  private isNewDoc;
@@ -18,16 +31,84 @@ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject, DataType
18
31
  private data;
19
32
  private dataProxy;
20
33
  private updates;
34
+ /**
35
+ * @param schema the Zod object schema describing this document's data.
36
+ * @param ref either a document reference specifying the full path of the
37
+ * document, or a collection reference specifying where a new document will
38
+ * be created.
39
+ * @param options optional parameters for the resulting FiretenderDoc; see
40
+ * FiretenderDocOptions for detail.
41
+ */
21
42
  constructor(schema: SchemaType, ref: DocumentReference | CollectionReference, options?: FiretenderDocOptions);
22
- static createNewDoc<SchemaType1 extends z.SomeZodObject, InputType extends {
23
- [x: string]: any;
24
- } = z.input<SchemaType1>>(schema: SchemaType1, ref: DocumentReference | CollectionReference, initialData: InputType, options?: FiretenderDocOptions): FiretenderDoc<SchemaType1, z.TypeOf<SchemaType1>>;
25
- get id(): string | undefined;
26
- get docRef(): DocumentReference;
43
+ /**
44
+ * Returns a FiretenderDoc representing a new Firestore document.
45
+ *
46
+ * This method does not create the document in Firestore. To do so, call the
47
+ * write() method.
48
+ *
49
+ * @param schema the Zod object schema describing this document's data.
50
+ * @param ref either a document reference specifying the full path of the
51
+ * document, or a collection reference specifying where a new document will
52
+ * be created.
53
+ * @param initialData the document's initial data, which must define a valid
54
+ * instance of this document according to its schema.
55
+ * @param options optional parameters for the resulting FiretenderDoc; see
56
+ * FiretenderDocOptions for detail.
57
+ */
58
+ static createNewDoc<SchemaType1 extends z.SomeZodObject, InputType extends z.input<SchemaType1> = z.input<SchemaType1>>(schema: SchemaType1, ref: DocumentReference | CollectionReference, initialData: InputType, options?: PublicFiretenderDocOptions): FiretenderDoc<SchemaType1, z.infer<SchemaType1>>;
59
+ /**
60
+ * Create a copy of this document. Returns a deep copy of its data with a new
61
+ * Firestore ID and reference.
62
+ *
63
+ * This method does not create the document in Firestore. To do so, call the
64
+ * write() method.
65
+ *
66
+ * @param dest the destination can be a string or undefined to create a copy
67
+ * in the same collection, or a document or collection reference to create
68
+ * it elsewhere. Firestore will assign a random doc ID if dest is undefined
69
+ * or a collection reference.
70
+ * @param options optional parameters for the resulting FiretenderDoc; see
71
+ * FiretenderDocOptions for detail.
72
+ */
27
73
  copy(dest?: DocumentReference | CollectionReference | string | undefined, options?: FiretenderDocOptions): FiretenderDoc<SchemaType, DataType>;
74
+ /**
75
+ * The document's ID string.
76
+ *
77
+ * @throws Throws an error if the document does not yet have an ID.
78
+ */
79
+ get id(): string;
80
+ /**
81
+ * The document's Firestore reference.
82
+ *
83
+ * @throws Throws an error if the document does not yet have a reference.
84
+ */
85
+ get docRef(): DocumentReference;
86
+ /**
87
+ * Load this document's data from Firestore.
88
+ *
89
+ * @param force force a read from Firestore. Normally load() does nothing if
90
+ * the document already contains data.
91
+ */
28
92
  load(force?: boolean): Promise<this>;
93
+ /**
94
+ * Read-only accessor to the contents of this document.
95
+ */
29
96
  get r(): DeepReadonly<DataType>;
97
+ /**
98
+ * Writable accessor to the contents of this document.
99
+ *
100
+ * Only use this accessor when making changes to the doc. The .r accessor is
101
+ * considerably more efficient when reading.
102
+ */
30
103
  get w(): DataType;
104
+ /**
105
+ * Write the document or any updates to Firestore.
106
+ */
31
107
  write(): Promise<this>;
108
+ /**
109
+ * Does this document contain data that has not yet been written to Firestore?
110
+ */
111
+ isPendingWrite(): boolean;
112
+ /** Add the field and its new value to the list of updates. */
32
113
  private onChange;
33
114
  }
@@ -5,9 +5,17 @@ const firestore_1 = require("firebase/firestore");
5
5
  const proxies_1 = require("./proxies");
6
6
  const ts_helpers_1 = require("./ts-helpers");
7
7
  /**
8
- * Helper class for reading and writing Firestore data based on Zod schemas.
8
+ * A representation of a Firestore document.
9
9
  */
10
10
  class FiretenderDoc {
11
+ /**
12
+ * @param schema the Zod object schema describing this document's data.
13
+ * @param ref either a document reference specifying the full path of the
14
+ * document, or a collection reference specifying where a new document will
15
+ * be created.
16
+ * @param options optional parameters for the resulting FiretenderDoc; see
17
+ * FiretenderDocOptions for detail.
18
+ */
11
19
  constructor(schema, ref, options = {}) {
12
20
  this.docID = undefined;
13
21
  this.data = undefined;
@@ -29,6 +37,21 @@ class FiretenderDoc {
29
37
  throw TypeError("Firetender can only take a collection reference when creating a new document. Use Firetender.createNewDoc() if this is your intent.");
30
38
  }
31
39
  }
40
+ /**
41
+ * Returns a FiretenderDoc representing a new Firestore document.
42
+ *
43
+ * This method does not create the document in Firestore. To do so, call the
44
+ * write() method.
45
+ *
46
+ * @param schema the Zod object schema describing this document's data.
47
+ * @param ref either a document reference specifying the full path of the
48
+ * document, or a collection reference specifying where a new document will
49
+ * be created.
50
+ * @param initialData the document's initial data, which must define a valid
51
+ * instance of this document according to its schema.
52
+ * @param options optional parameters for the resulting FiretenderDoc; see
53
+ * FiretenderDocOptions for detail.
54
+ */
32
55
  static createNewDoc(schema, ref, initialData, options = {}) {
33
56
  const mergedOptions = {
34
57
  ...options,
@@ -37,15 +60,20 @@ class FiretenderDoc {
37
60
  };
38
61
  return new FiretenderDoc(schema, ref, mergedOptions);
39
62
  }
40
- get id() {
41
- return this.docID;
42
- }
43
- get docRef() {
44
- if (this.ref.type === "document") {
45
- return this.ref;
46
- }
47
- throw Error("docRef can only be accessed after the new doc has been written.");
48
- }
63
+ /**
64
+ * Create a copy of this document. Returns a deep copy of its data with a new
65
+ * Firestore ID and reference.
66
+ *
67
+ * This method does not create the document in Firestore. To do so, call the
68
+ * write() method.
69
+ *
70
+ * @param dest the destination can be a string or undefined to create a copy
71
+ * in the same collection, or a document or collection reference to create
72
+ * it elsewhere. Firestore will assign a random doc ID if dest is undefined
73
+ * or a collection reference.
74
+ * @param options optional parameters for the resulting FiretenderDoc; see
75
+ * FiretenderDocOptions for detail.
76
+ */
49
77
  copy(dest = undefined, options = {}) {
50
78
  if (!this.data) {
51
79
  throw Error("You must call load() before making a copy.");
@@ -70,6 +98,34 @@ class FiretenderDoc {
70
98
  };
71
99
  return new FiretenderDoc(this.schema, ref, mergedOptions);
72
100
  }
101
+ /**
102
+ * The document's ID string.
103
+ *
104
+ * @throws Throws an error if the document does not yet have an ID.
105
+ */
106
+ get id() {
107
+ if (!this.docID) {
108
+ throw Error("id can only be accessed after the new doc has been written.");
109
+ }
110
+ return this.docID;
111
+ }
112
+ /**
113
+ * The document's Firestore reference.
114
+ *
115
+ * @throws Throws an error if the document does not yet have a reference.
116
+ */
117
+ get docRef() {
118
+ if (this.ref.type !== "document") {
119
+ throw Error("docRef can only be accessed after the new doc has been written.");
120
+ }
121
+ return this.ref;
122
+ }
123
+ /**
124
+ * Load this document's data from Firestore.
125
+ *
126
+ * @param force force a read from Firestore. Normally load() does nothing if
127
+ * the document already contains data.
128
+ */
73
129
  async load(force = false) {
74
130
  if (this.isNewDoc || this.ref.type === "collection") {
75
131
  throw Error("load() should not be called for new documents.");
@@ -85,12 +141,21 @@ class FiretenderDoc {
85
141
  }
86
142
  return this;
87
143
  }
144
+ /**
145
+ * Read-only accessor to the contents of this document.
146
+ */
88
147
  get r() {
89
148
  if (!this.data) {
90
149
  throw Error("load() must be called before reading the document.");
91
150
  }
92
151
  return this.data;
93
152
  }
153
+ /**
154
+ * Writable accessor to the contents of this document.
155
+ *
156
+ * Only use this accessor when making changes to the doc. The .r accessor is
157
+ * considerably more efficient when reading.
158
+ */
94
159
  get w() {
95
160
  if (this.isNewDoc) {
96
161
  // No need to monitor changes if we're creating rather than updating.
@@ -104,6 +169,9 @@ class FiretenderDoc {
104
169
  }
105
170
  return this.dataProxy;
106
171
  }
172
+ /**
173
+ * Write the document or any updates to Firestore.
174
+ */
107
175
  async write() {
108
176
  if (this.isNewDoc) {
109
177
  (0, ts_helpers_1.assertIsDefined)(this.data);
@@ -125,10 +193,20 @@ class FiretenderDoc {
125
193
  if (this.updates.size > 0) {
126
194
  const flatUpdateList = Array.from(this.updates.entries()).flat();
127
195
  await (0, firestore_1.updateDoc)(this.ref, flatUpdateList[0], flatUpdateList[1], ...flatUpdateList.slice(2));
196
+ this.updates.clear();
128
197
  }
129
198
  }
130
199
  return this;
131
200
  }
201
+ /**
202
+ * Does this document contain data that has not yet been written to Firestore?
203
+ */
204
+ isPendingWrite() {
205
+ return this.isNewDoc || this.updates.size > 0;
206
+ }
207
+ //////////////////////////////////////////////////////////////////////////////
208
+ // Private functions
209
+ /** Add the field and its new value to the list of updates. */
132
210
  onChange(fieldPath, newValue) {
133
211
  let pathString = "";
134
212
  if (this.updates.size > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"FiretenderDoc.js","sourceRoot":"","sources":["../src/FiretenderDoc.ts"],"names":[],"mappings":";;;AAAA,kDAQ4B;AAG5B,uCAAiD;AACjD,6CAA6D;AAQ7D;;GAEG;AACH,MAAa,aAAa;IAYxB,YACE,MAAkB,EAClB,GAA4C,EAC5C,UAAgC,EAAE;QAR5B,UAAK,GAAuB,SAAS,CAAC;QACtC,SAAI,GAAyB,SAAS,CAAC;QACvC,cAAS,GAAuC,SAAS,CAAC;QAC1D,YAAO,GAAG,IAAI,GAAG,EAAe,CAAC;QAOvC,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,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,CAAC,IAAI,KAAK,UAAU,EAAE;YAChC,IA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,oBAAoB;IAEpB,8DAA8D;IACtD,QAAQ,CACd,SAAmB,EACnB,QAAkC;QAElC,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE;YACzB,0EAA0E;YAC1E,wEAAwE;YACxE,yEAAyE;YACzE,8CAA8C;YAC9C,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;AA3RD,sCA2RC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "firetender",
3
3
  "displayName": "Firetender",
4
4
  "description": "Typescript wrapper for Firestore documents",
5
- "version": "0.5.2",
5
+ "version": "0.5.3",
6
6
  "author": "Jake Hartman",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/jakes-space/firetender",