shelving 1.41.0 → 1.44.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/db/Database.d.ts CHANGED
@@ -29,10 +29,10 @@ export declare class Database<V extends Validators<Datas> = Validators<Datas>> {
29
29
  }
30
30
  /** A documents reference within a specific database. */
31
31
  export declare class DatabaseQuery<T extends Data = Data> extends Query<T> implements Observable<Results<T>>, Validatable<Entries<T>>, Iterable<Entry<T>> {
32
- readonly provider: Provider;
32
+ readonly db: Database;
33
33
  readonly validator: Validator<T>;
34
34
  readonly collection: string;
35
- constructor(provider: Provider, validator: Validator<T>, collection: string, filters?: Filters<T>, sorts?: Sorts<T>, limit?: number | null);
35
+ constructor(db: Database, validator: Validator<T>, collection: string, filters?: Filters<T>, sorts?: Sorts<T>, limit?: number | null);
36
36
  /** Reference a document in this query's collection. */
37
37
  doc(id: string): DatabaseDocument<T>;
38
38
  /**
@@ -114,11 +114,11 @@ export declare class DatabaseQuery<T extends Data = Data> extends Query<T> imple
114
114
  export declare function getQueryData<T extends Data>(entries: Entries<T>, ref: DatabaseQuery<T>): Entry<T>;
115
115
  /** A document reference within a specific database. */
116
116
  export declare class DatabaseDocument<T extends Data = Data> implements Observable<Result<T>>, Validatable<T> {
117
- readonly provider: Provider;
117
+ readonly db: Database;
118
118
  readonly validator: Validator<T>;
119
119
  readonly collection: string;
120
120
  readonly id: string;
121
- constructor(provider: Provider, validator: Validator<T>, collection: string, id: string);
121
+ constructor(db: Database, validator: Validator<T>, collection: string, id: string);
122
122
  /** Create a query on this document's collection. */
123
123
  query(filters?: Filters<T>, sorts?: Sorts<T>, limit?: number | null): DatabaseQuery<T>;
124
124
  /** Get an 'optional' reference to this document (uses a `ModelQuery` with an `id` filter). */
package/db/Database.js CHANGED
@@ -18,11 +18,11 @@ export class Database {
18
18
  }
19
19
  /** Create a query on a collection in this model. */
20
20
  query(collection, filters, sorts, limit) {
21
- return new DatabaseQuery(this.provider, this.validators[collection], collection, filters, sorts, limit);
21
+ return new DatabaseQuery(this, this.validators[collection], collection, filters, sorts, limit);
22
22
  }
23
23
  /** Reference a document in a collection in this model. */
24
24
  doc(collection, id) {
25
- return new DatabaseDocument(this.provider, this.validators[collection], collection, id);
25
+ return new DatabaseDocument(this, this.validators[collection], collection, id);
26
26
  }
27
27
  /**
28
28
  * Create a new document with a random ID.
@@ -38,15 +38,15 @@ export class Database {
38
38
  }
39
39
  /** A documents reference within a specific database. */
40
40
  export class DatabaseQuery extends Query {
41
- constructor(provider, validator, collection, filters, sorts, limit) {
41
+ constructor(db, validator, collection, filters, sorts, limit) {
42
42
  super(filters, sorts, limit);
43
- this.provider = provider;
43
+ this.db = db;
44
44
  this.validator = validator;
45
45
  this.collection = collection;
46
46
  }
47
47
  /** Reference a document in this query's collection. */
48
48
  doc(id) {
49
- return new DatabaseDocument(this.provider, this.validator, this.collection, id);
49
+ return new DatabaseDocument(this.db, this.validator, this.collection, id);
50
50
  }
51
51
  /**
52
52
  * Create a new document with a random ID.
@@ -56,21 +56,21 @@ export class DatabaseQuery extends Query {
56
56
  * @return String ID for the created document (possibly promised).
57
57
  */
58
58
  add(data) {
59
- return this.provider.add(this, data);
59
+ return this.db.provider.add(this, data);
60
60
  }
61
61
  /**
62
62
  * Get an iterable that yields the results of this entry.
63
63
  * @return Map containing the results.
64
64
  */
65
65
  get entries() {
66
- return this.provider.getQuery(this);
66
+ return this.db.provider.getQuery(this);
67
67
  }
68
68
  /**
69
69
  * Get an iterable that yields the results of this entry.
70
70
  * @return Map containing the results.
71
71
  */
72
72
  get results() {
73
- return callAsync(getMap, this.provider.getQuery(this));
73
+ return callAsync(getMap, this.db.provider.getQuery(this));
74
74
  }
75
75
  /**
76
76
  * Count the number of results of this set of documents.
@@ -84,7 +84,7 @@ export class DatabaseQuery extends Query {
84
84
  * @return `true` if a document exists or `false` otherwise (possibly promised).
85
85
  */
86
86
  get exists() {
87
- return callAsync(hasItems, this.provider.getQuery(this.max(1)));
87
+ return callAsync(hasItems, this.db.provider.getQuery(this.max(1)));
88
88
  }
89
89
  /**
90
90
  * Get an entry for the first document matched by this query or `undefined` if this query has no results.
@@ -93,7 +93,7 @@ export class DatabaseQuery extends Query {
93
93
  * @throws RequiredError if there were no results for this query.
94
94
  */
95
95
  get result() {
96
- return callAsync(getFirstItem, this.provider.getQuery(this.max(1)));
96
+ return callAsync(getFirstItem, this.db.provider.getQuery(this.max(1)));
97
97
  }
98
98
  /**
99
99
  * Get an entry for the first document matched by this query.
@@ -102,7 +102,7 @@ export class DatabaseQuery extends Query {
102
102
  * @throws RequiredError if there were no results for this query.
103
103
  */
104
104
  get data() {
105
- return callAsync(getQueryData, this.provider.getQuery(this.max(1)), this);
105
+ return callAsync(getQueryData, this.db.provider.getQuery(this.max(1)), this);
106
106
  }
107
107
  /**
108
108
  * Subscribe to all matching documents.
@@ -112,7 +112,7 @@ export class DatabaseQuery extends Query {
112
112
  * @return Function that ends the subscription.
113
113
  */
114
114
  subscribe(next) {
115
- return this.provider.subscribeQuery(this, new ResultsObserver(typeof next === "function" ? { next } : next));
115
+ return this.db.provider.subscribeQuery(this, new ResultsObserver(typeof next === "function" ? { next } : next));
116
116
  }
117
117
  /**
118
118
  * Set all matching documents to the same exact value.
@@ -121,7 +121,7 @@ export class DatabaseQuery extends Query {
121
121
  * @return Nothing (possibly promised).
122
122
  */
123
123
  set(data) {
124
- return this.provider.setQuery(this, data);
124
+ return this.db.provider.setQuery(this, data);
125
125
  }
126
126
  /**
127
127
  * Update all matching documents with the same partial value.
@@ -130,14 +130,14 @@ export class DatabaseQuery extends Query {
130
130
  * @return Nothing (possibly promised).
131
131
  */
132
132
  update(updates) {
133
- return this.provider.updateQuery(this, updates instanceof Update ? updates : new DataUpdate(updates));
133
+ return this.db.provider.updateQuery(this, updates instanceof Update ? updates : new DataUpdate(updates));
134
134
  }
135
135
  /**
136
136
  * Delete all matching documents.
137
137
  * @return Nothing (possibly promised).
138
138
  */
139
139
  delete() {
140
- return this.provider.deleteQuery(this);
140
+ return this.db.provider.deleteQuery(this);
141
141
  }
142
142
  /** Iterate over the resuls (will throw `Promise` if the results are asynchronous). */
143
143
  [Symbol.iterator]() {
@@ -175,33 +175,33 @@ export function getQueryData(entries, ref) {
175
175
  }
176
176
  /** A document reference within a specific database. */
177
177
  export class DatabaseDocument {
178
- constructor(provider, validator, collection, id) {
179
- this.provider = provider;
178
+ constructor(db, validator, collection, id) {
179
+ this.db = db;
180
180
  this.validator = validator;
181
181
  this.collection = collection;
182
182
  this.id = id;
183
183
  }
184
184
  /** Create a query on this document's collection. */
185
185
  query(filters, sorts, limit) {
186
- return new DatabaseQuery(this.provider, this.validator, this.collection, filters, sorts, limit);
186
+ return new DatabaseQuery(this.db, this.validator, this.collection, filters, sorts, limit);
187
187
  }
188
188
  /** Get an 'optional' reference to this document (uses a `ModelQuery` with an `id` filter). */
189
189
  get optional() {
190
- return new DatabaseQuery(this.provider, this.validator, this.collection, new Filters(new EqualFilter("id", this.id)));
190
+ return new DatabaseQuery(this.db, this.validator, this.collection, new Filters(new EqualFilter("id", this.id)));
191
191
  }
192
192
  /**
193
193
  * Does this document exist?
194
194
  * @return `true` if a document exists or `false` otherwise (possibly promised).
195
195
  */
196
196
  get exists() {
197
- return callAsync(Boolean, this.provider.get(this));
197
+ return callAsync(Boolean, this.db.provider.get(this));
198
198
  }
199
199
  /**
200
200
  * Get the result of this document.
201
201
  * @return Document's data, or `undefined` if the document doesn't exist (possibly promised).
202
202
  */
203
203
  get result() {
204
- return this.provider.get(this);
204
+ return this.db.provider.get(this);
205
205
  }
206
206
  /**
207
207
  * Get the data of this document.
@@ -211,7 +211,7 @@ export class DatabaseDocument {
211
211
  * @throws RequiredError if the document's result was undefined.
212
212
  */
213
213
  get data() {
214
- return callAsync(getDocumentData, this.provider.get(this), this);
214
+ return callAsync(getDocumentData, this.db.provider.get(this), this);
215
215
  }
216
216
  /**
217
217
  * Subscribe to the result of this document (indefinitely).
@@ -221,19 +221,19 @@ export class DatabaseDocument {
221
221
  * @return Function that ends the subscription.
222
222
  */
223
223
  subscribe(next) {
224
- return this.provider.subscribe(this, typeof next === "function" ? { next } : next);
224
+ return this.db.provider.subscribe(this, typeof next === "function" ? { next } : next);
225
225
  }
226
226
  /** Set the complete data of this document. */
227
227
  set(data) {
228
- return this.provider.set(this, data);
228
+ return this.db.provider.set(this, data);
229
229
  }
230
230
  /** Update this document. */
231
231
  update(updates) {
232
- return this.provider.update(this, updates instanceof Update ? updates : new DataUpdate(updates));
232
+ return this.db.provider.update(this, updates instanceof Update ? updates : new DataUpdate(updates));
233
233
  }
234
234
  /** Delete this document. */
235
235
  delete() {
236
- return this.provider.delete(this);
236
+ return this.db.provider.delete(this);
237
237
  }
238
238
  /** Validate data for this query reference. */
239
239
  validate(unsafeData) {
@@ -0,0 +1,82 @@
1
+ import { PropUpdates, Update } from "../update/index.js";
2
+ import { ImmutableArray, Nullish, Data, Key } from "../util/index.js";
3
+ import type { Database, DatabaseDocument, DatabaseQuery } from "./Database.js";
4
+ /** Represent a write operation on a database. */
5
+ export declare abstract class Operation {
6
+ /** Run this operation and return the result operation. */
7
+ abstract run(db: Database): Promise<Operation>;
8
+ }
9
+ /** Represent a list of write operations on a database run in series. */
10
+ export declare class Operations extends Operation {
11
+ /** Return a new write operations list with a set of write operations. */
12
+ static with(...operations: Nullish<Operation>[]): Operations;
13
+ readonly operations: ImmutableArray<Operation>;
14
+ constructor(operations: ImmutableArray<Nullish<Operation>>);
15
+ run(db: Database): Promise<Operations>;
16
+ /** Return a new write operations list with an additional write operation added. */
17
+ with(...operations: Nullish<Operation>[]): {
18
+ __proto__: any;
19
+ } & this & {
20
+ operations: (Operation | Nullish<Operation>[])[];
21
+ };
22
+ }
23
+ /** Represent a add operation made to a collection in a database. */
24
+ export declare class AddOperation<T extends Data> extends Operation {
25
+ /** Create a new add operation on a collection. */
26
+ static on<X extends Data>({ collection }: DatabaseDocument<X> | DatabaseQuery<X>, data: X): AddOperation<X>;
27
+ /** Run a new add operation on a collection and return the result operation. */
28
+ static run<X extends Data>({ collection, db }: DatabaseDocument<X> | DatabaseQuery<X>, data: X): Promise<SetOperation<X>>;
29
+ readonly collection: string;
30
+ readonly data: T;
31
+ constructor(collection: string, data: T);
32
+ run(db: Database): Promise<SetOperation<T>>;
33
+ /** Set one of the props on this set operation to a different value. */
34
+ with<K extends Key<T>>(key: Nullish<K>, value: T[K]): this;
35
+ }
36
+ /** Represent a set operation made to a single document in a database. */
37
+ export declare class SetOperation<T extends Data> extends Operation {
38
+ /** Create a new add operation on a collection. */
39
+ static on<X extends Data>({ collection, id }: DatabaseDocument<X>, data: X): SetOperation<X>;
40
+ /** Run a new set operation on a collection and return the result operation. */
41
+ static run<X extends Data>({ collection, id, db }: DatabaseDocument<X>, data: X): Promise<SetOperation<X>>;
42
+ readonly collection: string;
43
+ readonly id: string;
44
+ readonly data: T;
45
+ constructor(collection: string, id: string, data: T);
46
+ run(db: Database): Promise<this>;
47
+ /** Set one of the props on this set operation to a different value. */
48
+ with<K extends Key<T>>(key: Nullish<K>, value: T[K]): this;
49
+ }
50
+ /** Represent an update operation made to a single document in a database. */
51
+ export declare class UpdateOperation<T extends Data> extends Operation {
52
+ /** Create a new update operation on a document. */
53
+ static on<X extends Data>({ collection, id }: DatabaseDocument<X>, updates: PropUpdates<X>): UpdateOperation<X>;
54
+ /** Run a new set operation on a collection and return the result operation. */
55
+ static run<X extends Data>({ collection, id, db }: DatabaseDocument<X>, updates: PropUpdates<X>): Promise<UpdateOperation<X>>;
56
+ readonly collection: string;
57
+ readonly id: string;
58
+ readonly updates: PropUpdates<T>;
59
+ constructor(collection: string, id: string, updates: PropUpdates<T>);
60
+ run(db: Database): Promise<this>;
61
+ /** update one of the props on this set operation to a different value. */
62
+ with<K extends Key<T>>(key: Nullish<K>, value: T[K] | Update<T[K]>): this;
63
+ }
64
+ /** Represent a delete operation made to a single document in a database. */
65
+ export declare class DeleteOperation extends Operation {
66
+ /** Create a new delete operation on a document. */
67
+ static on<X extends Data>({ collection, id }: DatabaseDocument<X>): DeleteOperation;
68
+ /** Run a new delete operation on a document. */
69
+ static run<X extends Data>({ collection, id, db }: DatabaseDocument<X>): Promise<DeleteOperation>;
70
+ readonly collection: string;
71
+ readonly id: string;
72
+ constructor(collection: string, id: string);
73
+ run(db: Database): Promise<this>;
74
+ }
75
+ /** Set of hydrations for all change classes. */
76
+ export declare const OPERATION_HYDRATIONS: {
77
+ Operations: typeof Operations;
78
+ AddOperation: typeof AddOperation;
79
+ SetOperation: typeof SetOperation;
80
+ UpdateOperation: typeof UpdateOperation;
81
+ DeleteOperation: typeof DeleteOperation;
82
+ };
@@ -0,0 +1,132 @@
1
+ import { callAsyncSeries, isNotNullish, isNullish } from "../util/index.js";
2
+ /** Represent a write operation on a database. */
3
+ export class Operation {
4
+ }
5
+ /** Represent a list of write operations on a database run in series. */
6
+ export class Operations extends Operation {
7
+ constructor(operations) {
8
+ super();
9
+ this.operations = operations.filter(isNotNullish);
10
+ }
11
+ /** Return a new write operations list with a set of write operations. */
12
+ static with(...operations) {
13
+ return new Operations(operations);
14
+ }
15
+ async run(db) {
16
+ return new Operations(await callAsyncSeries(_write, this.operations, db));
17
+ }
18
+ /** Return a new write operations list with an additional write operation added. */
19
+ with(...operations) {
20
+ return { __proto__: Object.getPrototypeOf(this), ...this, operations: [...this.operations, operations] };
21
+ }
22
+ }
23
+ const _write = (operation, db) => operation.run(db);
24
+ /** Represent a add operation made to a collection in a database. */
25
+ export class AddOperation extends Operation {
26
+ constructor(collection, data) {
27
+ super();
28
+ this.collection = collection;
29
+ this.data = data;
30
+ }
31
+ /** Create a new add operation on a collection. */
32
+ static on({ collection }, data) {
33
+ return new AddOperation(collection, data);
34
+ }
35
+ /** Run a new add operation on a collection and return the result operation. */
36
+ static run({ collection, db }, data) {
37
+ return new AddOperation(collection, data).run(db);
38
+ }
39
+ async run(db) {
40
+ const id = await db.query(this.collection).add(this.data);
41
+ return new SetOperation(this.collection, id, this.data); // When an add operation is run it returns a set operation so the operation is repeatable.
42
+ }
43
+ /** Set one of the props on this set operation to a different value. */
44
+ with(key, value) {
45
+ if (isNullish(key))
46
+ return this;
47
+ return { __proto__: Object.getPrototypeOf(this), ...this, data: { ...this.data, [key]: value } };
48
+ }
49
+ }
50
+ /** Represent a set operation made to a single document in a database. */
51
+ export class SetOperation extends Operation {
52
+ constructor(collection, id, data) {
53
+ super();
54
+ this.collection = collection;
55
+ this.id = id;
56
+ this.data = data;
57
+ }
58
+ /** Create a new add operation on a collection. */
59
+ static on({ collection, id }, data) {
60
+ return new SetOperation(collection, id, data);
61
+ }
62
+ /** Run a new set operation on a collection and return the result operation. */
63
+ static run({ collection, id, db }, data) {
64
+ return new SetOperation(collection, id, data).run(db);
65
+ }
66
+ async run(db) {
67
+ await db.doc(this.collection, this.id).set(this.data);
68
+ return this;
69
+ }
70
+ /** Set one of the props on this set operation to a different value. */
71
+ with(key, value) {
72
+ if (isNullish(key))
73
+ return this;
74
+ return { __proto__: Object.getPrototypeOf(this), ...this, data: { ...this.data, [key]: value } };
75
+ }
76
+ }
77
+ /** Represent an update operation made to a single document in a database. */
78
+ export class UpdateOperation extends Operation {
79
+ constructor(collection, id, updates) {
80
+ super();
81
+ this.collection = collection;
82
+ this.id = id;
83
+ this.updates = updates;
84
+ }
85
+ /** Create a new update operation on a document. */
86
+ static on({ collection, id }, updates) {
87
+ return new UpdateOperation(collection, id, updates);
88
+ }
89
+ /** Run a new set operation on a collection and return the result operation. */
90
+ static run({ collection, id, db }, updates) {
91
+ return new UpdateOperation(collection, id, updates).run(db);
92
+ }
93
+ async run(db) {
94
+ await db.doc(this.collection, this.id).update(this.updates);
95
+ return this;
96
+ }
97
+ /** update one of the props on this set operation to a different value. */
98
+ with(key, value) {
99
+ if (isNullish(key))
100
+ return this;
101
+ return { __proto__: Object.getPrototypeOf(this), ...this, updates: { ...this.updates, [key]: value } };
102
+ }
103
+ }
104
+ /** Represent a delete operation made to a single document in a database. */
105
+ export class DeleteOperation extends Operation {
106
+ constructor(collection, id) {
107
+ super();
108
+ this.collection = collection;
109
+ this.id = id;
110
+ }
111
+ /** Create a new delete operation on a document. */
112
+ static on({ collection, id }) {
113
+ return new DeleteOperation(collection, id);
114
+ }
115
+ /** Run a new delete operation on a document. */
116
+ static run({ collection, id, db }) {
117
+ return new DeleteOperation(collection, id).run(db);
118
+ }
119
+ async run(db) {
120
+ await db.doc(this.collection, this.id).delete();
121
+ return this;
122
+ }
123
+ }
124
+ /** Set of hydrations for all change classes. */
125
+ export const OPERATION_HYDRATIONS = {
126
+ Operations: Operations,
127
+ AddOperation,
128
+ SetOperation,
129
+ UpdateOperation,
130
+ DeleteOperation,
131
+ };
132
+ OPERATION_HYDRATIONS;
package/db/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./Database.js";
2
+ export * from "./Operation.js";
2
3
  export * from "./Pagination.js";
3
4
  export * from "./errors.js";
package/db/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./Database.js";
2
+ export * from "./Operation.js";
2
3
  export * from "./Pagination.js";
3
4
  export * from "./errors.js";
package/index.d.ts CHANGED
@@ -13,5 +13,4 @@ export * from "./feedback/index.js";
13
13
  export * from "./markup/index.js";
14
14
  export * from "./stream/index.js";
15
15
  export * from "./update/index.js";
16
- export * from "./operation/index.js";
17
16
  export * from "./util/index.js";
package/index.js CHANGED
@@ -15,7 +15,6 @@ export * from "./feedback/index.js";
15
15
  export * from "./markup/index.js";
16
16
  export * from "./stream/index.js";
17
17
  export * from "./update/index.js";
18
- export * from "./operation/index.js";
19
18
  export * from "./util/index.js";
20
19
  // Integrations.
21
20
  // export * from "./react/index.js"; // Not exported.
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.41.0",
14
+ "version": "1.44.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -63,14 +63,14 @@
63
63
  "@types/jest": "^27.4.0",
64
64
  "@types/react": "^17.0.38",
65
65
  "@types/react-dom": "^17.0.11",
66
- "@typescript-eslint/eslint-plugin": "^5.8.1",
67
- "@typescript-eslint/parser": "^5.8.1",
66
+ "@typescript-eslint/eslint-plugin": "^5.9.0",
67
+ "@typescript-eslint/parser": "^5.9.0",
68
68
  "eslint": "^8.6.0",
69
69
  "eslint-config-prettier": "^8.3.0",
70
- "eslint-plugin-import": "^2.25.3",
70
+ "eslint-plugin-import": "^2.25.4",
71
71
  "eslint-plugin-prettier": "^4.0.0",
72
- "firebase": "^9.6.1",
73
- "jest": "^27.4.5",
72
+ "firebase": "^9.6.2",
73
+ "jest": "^27.4.7",
74
74
  "jest-ts-webcompat-resolver": "^1.0.0",
75
75
  "prettier": "^2.5.1",
76
76
  "react": "^17.0.2",
@@ -30,13 +30,13 @@ export function useAsyncDocument(ref, maxAge = 1000) {
30
30
  function getCachedResult(ref) {
31
31
  if (!ref)
32
32
  return undefined;
33
- const provider = findSourceProvider(ref.provider, CacheProvider);
33
+ const provider = findSourceProvider(ref.db.provider, CacheProvider);
34
34
  return provider.isCached(ref) ? provider.cache.get(ref) : NOVALUE;
35
35
  }
36
36
  /** Effect that subscribes a component to the cache for a reference. */
37
37
  function subscribeEffect(ref, maxAge, next, error) {
38
38
  if (ref) {
39
- const provider = findSourceProvider(ref.provider, CacheProvider);
39
+ const provider = findSourceProvider(ref.db.provider, CacheProvider);
40
40
  const stopCache = provider.cache.subscribe(ref, { next, error });
41
41
  if (maxAge === true) {
42
42
  // If `maxAge` is true subscribe to the source for as long as this component is attached.
package/react/useQuery.js CHANGED
@@ -30,18 +30,18 @@ export function useAsyncQuery(ref, maxAge = 1000) {
30
30
  function getCachedResults(ref) {
31
31
  if (!ref)
32
32
  return undefined;
33
- const provider = findSourceProvider(ref.provider, CacheProvider);
33
+ const provider = findSourceProvider(ref.db.provider, CacheProvider);
34
34
  return provider.isCached(ref) ? getMap(provider.cache.getQuery(ref)) : NOVALUE;
35
35
  }
36
36
  /** Effect that subscribes a component to the cache for a reference. */
37
37
  function subscribeEffect(ref, maxAge, next, error) {
38
38
  if (ref) {
39
- const provider = findSourceProvider(ref.provider, CacheProvider);
39
+ const provider = findSourceProvider(ref.db.provider, CacheProvider);
40
40
  const observer = new ResultsObserver({ next, error });
41
41
  const stopCache = provider.cache.subscribeQuery(ref, observer);
42
42
  if (maxAge === true) {
43
43
  // If `maxAge` is true subscribe to the source for as long as this component is attached.
44
- const stopSource = ref.provider.subscribeQuery(ref, observer);
44
+ const stopSource = ref.db.provider.subscribeQuery(ref, observer);
45
45
  return () => {
46
46
  stopCache();
47
47
  stopSource();
@@ -12,10 +12,12 @@ export declare type PropUpdates<T extends Data> = {
12
12
  };
13
13
  /** Update that can be applied to a data object to update its props. */
14
14
  export declare class DataUpdate<T extends Data> extends Update<T> implements Iterable<Prop<PropUpdates<T>>>, Transformable<T, T> {
15
+ /** Return a data update with a specific prop marked for update. */
16
+ static with<X extends Data, K extends Key<X>>(key: Nullish<K>, value: X[K] | Update<X[K]>): DataUpdate<X>;
15
17
  readonly updates: PropUpdates<T>;
16
18
  constructor(props: PropUpdates<T>);
17
19
  transform(existing: T): T;
18
- /** Return a new object with the specified additional transform for a prop. */
20
+ /** Return a data update with a specific prop marked for update. */
19
21
  with<K extends Key<T>>(key: Nullish<K>, value: T[K] | Update<T[K]>): this;
20
22
  /** Iterate over the transforms in this object. */
21
23
  [Symbol.iterator](): Iterator<Prop<PropUpdates<T>>, void>;
@@ -6,10 +6,14 @@ export class DataUpdate extends Update {
6
6
  super();
7
7
  this.updates = props;
8
8
  }
9
+ /** Return a data update with a specific prop marked for update. */
10
+ static with(key, value) {
11
+ return new DataUpdate(!isNullish(key) ? { [key]: value } : {});
12
+ }
9
13
  transform(existing) {
10
14
  return transformProps(existing, this.updates);
11
15
  }
12
- /** Return a new object with the specified additional transform for a prop. */
16
+ /** Return a data update with a specific prop marked for update. */
13
17
  with(key, value) {
14
18
  if (isNullish(key))
15
19
  return this;