firetender 0.3.1 → 0.4.1
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 +20 -0
- package/README.md +38 -31
- package/dist/FiretenderCollection.d.ts +15 -0
- package/dist/FiretenderCollection.js +51 -0
- package/dist/FiretenderCollection.js.map +1 -0
- package/dist/FiretenderDoc.d.ts +2 -8
- package/dist/FiretenderDoc.js +6 -11
- package/dist/FiretenderDoc.js.map +1 -1
- package/dist/Timestamps.js +2 -2
- package/dist/Timestamps.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/proxies.js +2 -4
- package/dist/proxies.js.map +1 -1
- package/dist/ts-helpers.d.ts +3 -0
- package/dist/ts-helpers.js.map +1 -1
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Jacob M. Hartman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -34,20 +34,25 @@ const app = initializeApp(firebaseConfig);
|
|
|
34
34
|
const firestore = getFirestore(app);
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
### Define
|
|
37
|
+
### Define a collection and its schema
|
|
38
38
|
|
|
39
|
-
Firetender uses [Zod](https://github.com/colinhacks/zod) to define the
|
|
40
|
-
|
|
41
|
-
Zod very similar. In the example below, I've defined a schema for
|
|
42
|
-
pizza. I was a little hungry when I wrote this.
|
|
39
|
+
Firetender uses [Zod](https://github.com/colinhacks/zod) to define the schema
|
|
40
|
+
and validation rules for a collection's documents; if you've used Joi or Yup,
|
|
41
|
+
you will find Zod very similar. In the example below, I've defined a schema for
|
|
42
|
+
types of pizza. I was a little hungry when I wrote this.
|
|
43
43
|
|
|
44
44
|
```javascript
|
|
45
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
FiretenderCollection,
|
|
47
|
+
nowTimestamp,
|
|
48
|
+
timestampSchema
|
|
49
|
+
} from "firetender";
|
|
46
50
|
import { z } from "zod";
|
|
47
51
|
|
|
48
52
|
const pizzaSchema = z.object({
|
|
49
53
|
name: z.string(),
|
|
50
54
|
description: z.string().optional(),
|
|
55
|
+
creationTime: timestampSchema,
|
|
51
56
|
toppings: z.record(
|
|
52
57
|
z.string(),
|
|
53
58
|
z.object({
|
|
@@ -63,22 +68,23 @@ const pizzaSchema = z.object({
|
|
|
63
68
|
tags: z.array(z.string()).default([]),
|
|
64
69
|
});
|
|
65
70
|
|
|
66
|
-
const
|
|
71
|
+
const pizzaCollection = new FiretenderCollection(
|
|
72
|
+
pizzaSchema,
|
|
73
|
+
[firestore, "pizzas"],
|
|
74
|
+
{ creationTime: nowTimestamp() }
|
|
75
|
+
);
|
|
67
76
|
```
|
|
68
77
|
|
|
69
|
-
The static `FiretenderDoc.makeClassFactory()` method simplifies document
|
|
70
|
-
creation by capturing the schema.
|
|
71
|
-
|
|
72
78
|
Optional records and arrays should typically use `.default()` to provide an
|
|
73
|
-
empty
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
empty instances when missing. That isn't required, but it makes accessing these
|
|
80
|
+
fields simpler because they will always be defined. The downside is that empty
|
|
81
|
+
fields are not pruned and will appear in Firestore.
|
|
76
82
|
|
|
77
83
|
### Add a document
|
|
78
84
|
|
|
79
85
|
Let's add a document to the `pizzas` collection, with an ID of `margherita`. We
|
|
80
|
-
use the
|
|
81
|
-
new document, initialized with validated data. This object is purely local
|
|
86
|
+
use the collection's `.createNewDoc()` to produce a `FiretenderDoc` representing
|
|
87
|
+
a new document, initialized with validated data. This object is purely local
|
|
82
88
|
until it is written to Firestore by calling `.write()`. Don't forget to do
|
|
83
89
|
that.
|
|
84
90
|
|
|
@@ -99,14 +105,14 @@ from `.id` or `.docRef`.
|
|
|
99
105
|
|
|
100
106
|
### Read and modify a document
|
|
101
107
|
|
|
102
|
-
To access an existing document, pass its reference to the
|
|
103
|
-
|
|
104
|
-
property; see the example below. To make changes, use `.w` then call
|
|
108
|
+
To access an existing document, pass its reference to the collection's
|
|
109
|
+
`.getExistingDoc()` method. To read it, call `.load()` and access its data with
|
|
110
|
+
the `.r` property; see the example below. To make changes, use `.w` then call
|
|
105
111
|
`.write()`. Reading and updating can be done in combination:
|
|
106
112
|
|
|
107
113
|
```javascript
|
|
108
114
|
const meats = ["pepperoni", "chicken", "sausage"];
|
|
109
|
-
const pizza = await
|
|
115
|
+
const pizza = await pizzaCollection.getExistingDoc(docRef).load();
|
|
110
116
|
const isMeatIncluded = Object.entries(pizza.r.toppings).some(
|
|
111
117
|
([name, topping]) => topping.isIncluded && name in meats
|
|
112
118
|
);
|
|
@@ -128,7 +134,7 @@ The copy is solely local until `.write()` is called.
|
|
|
128
134
|
|
|
129
135
|
```javascript
|
|
130
136
|
const sourceRef = doc(db, "pizza", "margherita");
|
|
131
|
-
const sourcePizza = await
|
|
137
|
+
const sourcePizza = await pizzaCollection.getExistingDoc(sourceRef).load();
|
|
132
138
|
const newPizza = sourcePizza.copy("meaty margh");
|
|
133
139
|
newPizza.name = "Meaty Margh";
|
|
134
140
|
newPizza.toppings.sausage = {};
|
|
@@ -145,25 +151,26 @@ array items.
|
|
|
145
151
|
|
|
146
152
|
## TODO
|
|
147
153
|
|
|
154
|
+
The [full list of issues](https://github.com/jakes-space/firetender/issues) is
|
|
155
|
+
tracked on Github. Here are some features on the roadmap:
|
|
156
|
+
|
|
148
157
|
* Javadoc
|
|
158
|
+
* Document the code!
|
|
159
|
+
([#12](https://github.com/jakes-space/firetender/issues/12))
|
|
149
160
|
* Compile them to an API reference page in markdown.
|
|
161
|
+
([#13](https://github.com/jakes-space/firetender/issues/13))
|
|
150
162
|
* Concurrency
|
|
151
163
|
* Listen for changes and update the object if it has not been locally
|
|
152
164
|
modified. Provide an onChange() callback option.
|
|
165
|
+
([#14](https://github.com/jakes-space/firetender/issues/14))
|
|
153
166
|
* Support the Firestore transaction API.
|
|
167
|
+
([#15](https://github.com/jakes-space/firetender/issues/15))
|
|
154
168
|
* Queries
|
|
169
|
+
([#16](https://github.com/jakes-space/firetender/issues/16))
|
|
155
170
|
* Document deletion
|
|
156
|
-
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
* Automate github & npm releases, either using semantic versioning
|
|
160
|
-
([video](https://egghead.io/lessons/javascript-automating-releases-with-semantic-release),
|
|
161
|
-
[package](https://github.com/semantic-release/semantic-release)) or github
|
|
162
|
-
workflows
|
|
163
|
-
([tutorial](https://writeabout.net/2021/10/15/releasing-github-npm-packages/),
|
|
164
|
-
[Zod's
|
|
165
|
-
yaml](https://github.com/colinhacks/zod/blob/master/.github/workflows/release.yml))
|
|
166
|
-
or some combination.
|
|
171
|
+
([#17](https://github.com/jakes-space/firetender/issues/17))
|
|
172
|
+
* Improved timestamp handling, tests ([multiple
|
|
173
|
+
issues](https://github.com/jakes-space/firetender/issues?q=timestamp))
|
|
167
174
|
|
|
168
175
|
## Alternatives
|
|
169
176
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Firestore } from "firebase/firestore";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { FiretenderDoc, FiretenderDocOptions } from "./FiretenderDoc";
|
|
4
|
+
import { DeepPartial } from "./ts-helpers";
|
|
5
|
+
export declare class FiretenderCollection<SchemaType extends z.SomeZodObject> {
|
|
6
|
+
readonly schema: SchemaType;
|
|
7
|
+
readonly firestore: Firestore;
|
|
8
|
+
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
|
+
private makeDocRef;
|
|
14
|
+
private makeCollectionRef;
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiretenderCollection = void 0;
|
|
4
|
+
const firestore_1 = require("firebase/firestore");
|
|
5
|
+
const FiretenderDoc_1 = require("./FiretenderDoc");
|
|
6
|
+
class FiretenderCollection {
|
|
7
|
+
constructor(schema, collectionPath, baseInitialData) {
|
|
8
|
+
this.schema = schema;
|
|
9
|
+
this.firestore = collectionPath[0];
|
|
10
|
+
this.collectionNames = collectionPath.slice(1);
|
|
11
|
+
this.baseInitialData = baseInitialData;
|
|
12
|
+
}
|
|
13
|
+
createNewDoc(id = undefined, initialData = undefined, options = {}) {
|
|
14
|
+
const ids = id instanceof Array ? id : id ? [id] : [];
|
|
15
|
+
let ref = this.makeDocRef(ids);
|
|
16
|
+
if (!ref) {
|
|
17
|
+
ref = this.makeCollectionRef(ids);
|
|
18
|
+
}
|
|
19
|
+
if (!ref) {
|
|
20
|
+
throw Error("createNewDoc() requires an ID for all collections and subcollections except the last.");
|
|
21
|
+
}
|
|
22
|
+
const data = this.baseInitialData;
|
|
23
|
+
if (initialData) {
|
|
24
|
+
Object.assign(data, initialData);
|
|
25
|
+
}
|
|
26
|
+
return FiretenderDoc_1.FiretenderDoc.createNewDoc(this.schema, ref, data, options);
|
|
27
|
+
}
|
|
28
|
+
getExistingDoc(id, options = {}) {
|
|
29
|
+
const ref = this.makeDocRef([id].flat());
|
|
30
|
+
if (!ref) {
|
|
31
|
+
throw Error("getExistingDoc() requires an ID for the collection and IDs for each of its subcollections (if any).");
|
|
32
|
+
}
|
|
33
|
+
return new FiretenderDoc_1.FiretenderDoc(this.schema, ref, options);
|
|
34
|
+
}
|
|
35
|
+
makeDocRef(ids) {
|
|
36
|
+
if (ids.length !== this.collectionNames.length) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const path = ids.flatMap((id, i) => [this.collectionNames[i], id]);
|
|
40
|
+
return (0, firestore_1.doc)(this.firestore, path[0], ...path.slice(1));
|
|
41
|
+
}
|
|
42
|
+
makeCollectionRef(ids) {
|
|
43
|
+
if (ids.length !== this.collectionNames.length - 1) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const subPath = ids.flatMap((id, i) => [id, this.collectionNames[i + 1]]);
|
|
47
|
+
return (0, firestore_1.collection)(this.firestore, this.collectionNames[0], ...subPath);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.FiretenderCollection = FiretenderCollection;
|
|
51
|
+
//# sourceMappingURL=FiretenderCollection.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{ DeepReadonly } from "./ts-helpers";
|
|
4
4
|
export declare type FiretenderDocOptions = {
|
|
5
5
|
createDoc?: true;
|
|
6
|
-
initialData?: any
|
|
6
|
+
initialData?: Record<string, any>;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Helper class for reading and writing Firestore data based on Zod schemas.
|
|
@@ -22,18 +22,12 @@ export declare class FiretenderDoc<SchemaType extends z.SomeZodObject, DataType
|
|
|
22
22
|
static createNewDoc<SchemaType1 extends z.SomeZodObject, InputType extends {
|
|
23
23
|
[x: string]: any;
|
|
24
24
|
} = z.input<SchemaType1>>(schema: SchemaType1, ref: DocumentReference | CollectionReference, initialData: InputType, options?: FiretenderDocOptions): FiretenderDoc<SchemaType1, z.TypeOf<SchemaType1>>;
|
|
25
|
-
static makeClassFactoryFor<SchemaType1 extends z.SomeZodObject, InputType extends {
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
} = z.input<SchemaType1>>(schema: SchemaType1): {
|
|
28
|
-
createNewDoc: (ref: DocumentReference | CollectionReference, initialData: InputType, options?: FiretenderDocOptions) => FiretenderDoc<SchemaType1, z.TypeOf<SchemaType1>>;
|
|
29
|
-
wrapExistingDoc: (ref: DocumentReference | CollectionReference, options?: FiretenderDocOptions) => FiretenderDoc<SchemaType1, z.TypeOf<SchemaType1>>;
|
|
30
|
-
};
|
|
31
25
|
get id(): string | undefined;
|
|
32
26
|
get docRef(): DocumentReference;
|
|
33
27
|
copy(dest?: DocumentReference | CollectionReference | string | undefined, options?: FiretenderDocOptions): FiretenderDoc<SchemaType, DataType>;
|
|
34
28
|
load(force?: boolean): Promise<this>;
|
|
35
29
|
get r(): DeepReadonly<DataType>;
|
|
36
30
|
get w(): DataType;
|
|
37
|
-
write(): Promise<
|
|
31
|
+
write(): Promise<this>;
|
|
38
32
|
private onChange;
|
|
39
33
|
}
|
package/dist/FiretenderDoc.js
CHANGED
|
@@ -26,7 +26,7 @@ class FiretenderDoc {
|
|
|
26
26
|
this.docID = this.ref.path.split("/").pop();
|
|
27
27
|
}
|
|
28
28
|
else if (!this.isNewDoc) {
|
|
29
|
-
throw TypeError("Firetender can only take a collection reference when creating a new document. Use Firetender.
|
|
29
|
+
throw TypeError("Firetender can only take a collection reference when creating a new document. Use Firetender.createNewDoc() if this is your intent.");
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
static createNewDoc(schema, ref, initialData, options = {}) {
|
|
@@ -37,12 +37,6 @@ class FiretenderDoc {
|
|
|
37
37
|
};
|
|
38
38
|
return new FiretenderDoc(schema, ref, mergedOptions);
|
|
39
39
|
}
|
|
40
|
-
static makeClassFactoryFor(schema) {
|
|
41
|
-
return {
|
|
42
|
-
createNewDoc: (ref, initialData, options = {}) => FiretenderDoc.createNewDoc(schema, ref, initialData, options),
|
|
43
|
-
wrapExistingDoc: (ref, options = {}) => new FiretenderDoc(schema, ref, options),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
40
|
get id() {
|
|
47
41
|
return this.docID;
|
|
48
42
|
}
|
|
@@ -122,17 +116,18 @@ class FiretenderDoc {
|
|
|
122
116
|
}
|
|
123
117
|
this.isNewDoc = false;
|
|
124
118
|
}
|
|
119
|
+
// If existing doc:
|
|
125
120
|
else {
|
|
126
121
|
if (!(this.ref.type === "document")) {
|
|
127
122
|
// We should never get here.
|
|
128
123
|
throw Error("Internal error. Firetender object should always reference a document when updating an existing doc.");
|
|
129
124
|
}
|
|
130
|
-
if (this.updates.size
|
|
131
|
-
|
|
125
|
+
if (this.updates.size > 0) {
|
|
126
|
+
const flatUpdateList = Array.from(this.updates.entries()).flat();
|
|
127
|
+
await (0, firestore_1.updateDoc)(this.ref, flatUpdateList[0], flatUpdateList[1], ...flatUpdateList.slice(2));
|
|
132
128
|
}
|
|
133
|
-
const flatUpdateList = Array.from(this.updates.entries()).flat();
|
|
134
|
-
await (0, firestore_1.updateDoc)(this.ref, flatUpdateList[0], flatUpdateList[1], ...flatUpdateList.slice(2));
|
|
135
129
|
}
|
|
130
|
+
return this;
|
|
136
131
|
}
|
|
137
132
|
onChange(fieldPath, newValue) {
|
|
138
133
|
this.updates.set(fieldPath.join("."), newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiretenderDoc.js","sourceRoot":"","sources":["../src/FiretenderDoc.ts"],"names":[],"mappings":";;;AAAA,kDAQ4B;
|
|
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,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;gBACxB,MAAM,cAAc,CAClB,qDAAqD,CACtD,CAAC;aACH;YACD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SAC/C;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE;YAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;SAC7C;aAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACzB,MAAM,SAAS,CACb,sIAAsI,CACvI,CAAC;SACH;IACH,CAAC;IAED,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,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF;AAlLD,sCAkLC"}
|
package/dist/Timestamps.js
CHANGED
|
@@ -15,7 +15,7 @@ function dateFromTimestamp(timestamp) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.dateFromTimestamp = dateFromTimestamp;
|
|
17
17
|
function makeTTL(daysFromNow = 30) {
|
|
18
|
-
// TODO: is there a way to use the server time rather than Date.now()?
|
|
18
|
+
// TODO: #10 is there a way to use the server time rather than Date.now()?
|
|
19
19
|
return timestampFromUnixMillis(Date.now() + daysFromNow * 24 * 60 * 60 * 1000);
|
|
20
20
|
}
|
|
21
21
|
exports.makeTTL = makeTTL;
|
|
@@ -31,7 +31,7 @@ function timestampFromUnixMillis(msSinceEpoch) {
|
|
|
31
31
|
}
|
|
32
32
|
exports.timestampFromUnixMillis = timestampFromUnixMillis;
|
|
33
33
|
function nowTimestamp() {
|
|
34
|
-
// TODO: is there a way to use the server time rather than Date.now()?
|
|
34
|
+
// TODO: #9 is there a way to use the server time rather than Date.now()?
|
|
35
35
|
return timestampFromUnixMillis(Date.now());
|
|
36
36
|
}
|
|
37
37
|
exports.nowTimestamp = nowTimestamp;
|
package/dist/Timestamps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timestamps.js","sourceRoot":"","sources":["../src/Timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE;IACpC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE;CAC5C,CAAC,CAAC;AAGH,SAAgB,iBAAiB,CAAC,SAAwB;IACxD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,GAA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;IACzE,OAAO,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7C,CAAC;AAHD,oCAGC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.FiretenderDoc = void 0;
|
|
17
|
+
exports.FiretenderDoc = exports.FiretenderCollection = void 0;
|
|
18
|
+
var FiretenderCollection_1 = require("./FiretenderCollection");
|
|
19
|
+
Object.defineProperty(exports, "FiretenderCollection", { enumerable: true, get: function () { return FiretenderCollection_1.FiretenderCollection; } });
|
|
18
20
|
var FiretenderDoc_1 = require("./FiretenderDoc");
|
|
19
21
|
Object.defineProperty(exports, "FiretenderDoc", { enumerable: true, get: function () { return FiretenderDoc_1.FiretenderDoc; } });
|
|
20
22
|
__exportStar(require("./Timestamps"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,+CAA6B"}
|
package/dist/proxies.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.watchFieldForChanges = exports.watchArrayForChanges = void 0;
|
|
4
|
-
const ts_helpers_1 = require("./ts-helpers");
|
|
5
4
|
const firestore_1 = require("firebase/firestore");
|
|
6
5
|
const zod_1 = require("zod");
|
|
6
|
+
const ts_helpers_1 = require("./ts-helpers");
|
|
7
7
|
function unwrapSchema(schema) {
|
|
8
8
|
if (schema instanceof zod_1.z.ZodOptional || schema instanceof zod_1.z.ZodNullable) {
|
|
9
9
|
return unwrapSchema(schema.unwrap());
|
|
@@ -36,9 +36,7 @@ function watchArrayForChanges(arrayPath, array, fieldSchema, field, onChange) {
|
|
|
36
36
|
const property = target[propertyKey];
|
|
37
37
|
if (property instanceof Function) {
|
|
38
38
|
const result = (...args) => property.apply(field, args);
|
|
39
|
-
// TODO
|
|
40
|
-
// TODO (harder): also handle at, foreach, etc. methods to chain proxies
|
|
41
|
-
// down from them. But life's too short for that.
|
|
39
|
+
// TODO: #11 Only mark the change for mutating function calls.
|
|
42
40
|
onChange(arrayPath, array);
|
|
43
41
|
return result;
|
|
44
42
|
}
|
package/dist/proxies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../src/proxies.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../src/proxies.ts"],"names":[],"mappings":";;;AAAA,kDAA8D;AAC9D,6BAAwB;AAExB,6CAAiD;AAEjD,SAAS,YAAY,CAAC,MAAoB;IACxC,IAAI,MAAM,YAAY,OAAC,CAAC,WAAW,IAAI,MAAM,YAAY,OAAC,CAAC,WAAW,EAAE;QACtE,OAAO,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;KACtC;IACD,IAAI,MAAM,YAAY,OAAC,CAAC,UAAU,EAAE;QAClC,OAAO,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;KAC7C;IACD,IAAI,MAAM,YAAY,OAAC,CAAC,UAAU,EAAE;QAClC,OAAO,YAAY,CAAC,MAAM,C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GAAE,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AA7CD,oDA6CC"}
|
package/dist/ts-helpers.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Typescript-related helper functions and types.
|
|
3
3
|
*/
|
|
4
|
+
export declare type DeepPartial<T> = T extends object ? {
|
|
5
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
6
|
+
} : T;
|
|
4
7
|
export declare type DeepReadonly<T> = T extends Array<infer ArrKey> ? ReadonlyArray<DeepReadonly<ArrKey>> : T extends Map<infer MapKey, infer MapVal> ? ReadonlyMap<DeepReadonly<MapKey>, DeepReadonly<MapVal>> : T extends Set<infer SetKey> ? ReadonlySet<DeepReadonly<SetKey>> : T extends Record<any, unknown> ? {
|
|
5
8
|
readonly [ObjKey in keyof T]: DeepReadonly<T[ObjKey]>;
|
|
6
9
|
} : T;
|
package/dist/ts-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-helpers.js","sourceRoot":"","sources":["../src/ts-helpers.ts"],"names":[],"mappings":";AAAA;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"ts-helpers.js","sourceRoot":"","sources":["../src/ts-helpers.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0BH,SAAgB,eAAe,CAAI,KAAQ;IACzC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC;KAChD;AACH,CAAC;AAJD,0CAIC;AAED,SAAgB,iBAAiB,CAAC,GAAQ;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,SAAS,CAAC,iDAAiD,CAAC,CAAC;KACpE;AACH,CAAC;AAJD,8CAIC"}
|
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
|
+
"version": "0.4.1",
|
|
6
6
|
"author": "Jake Hartman",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/jakes-space/firetender",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"eslint-import-resolver-typescript": "^3.5.2",
|
|
56
56
|
"eslint-plugin-import": "^2.26.0",
|
|
57
57
|
"eslint-plugin-prettier": "^4.2.1",
|
|
58
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
58
59
|
"husky": "^8.0.1",
|
|
59
60
|
"jest": "^29.2.2",
|
|
60
61
|
"prettier": "^2.7.1",
|