shelving 1.91.2 → 1.92.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.
Files changed (98) hide show
  1. package/db/Change.d.ts +19 -20
  2. package/db/Change.js +22 -21
  3. package/db/CollectionReference.d.ts +103 -0
  4. package/db/CollectionReference.js +127 -0
  5. package/db/Database.d.ts +21 -23
  6. package/db/Database.js +18 -18
  7. package/db/{Item.d.ts → ItemReference.d.ts} +13 -14
  8. package/db/{Item.js → ItemReference.js} +14 -17
  9. package/db/ItemState.d.ts +3 -3
  10. package/db/{Query.d.ts → QueryReference.d.ts} +25 -33
  11. package/db/QueryReference.js +101 -0
  12. package/db/QueryState.d.ts +10 -10
  13. package/db/QueryState.js +20 -18
  14. package/db/index.d.ts +3 -3
  15. package/db/index.js +3 -3
  16. package/firestore/client/FirestoreClientProvider.d.ts +13 -13
  17. package/firestore/client/FirestoreClientProvider.js +55 -84
  18. package/firestore/lite/FirestoreLiteProvider.d.ts +11 -11
  19. package/firestore/lite/FirestoreLiteProvider.js +52 -83
  20. package/firestore/server/FirestoreServerProvider.d.ts +13 -13
  21. package/firestore/server/FirestoreServerProvider.js +51 -84
  22. package/index.d.ts +0 -2
  23. package/index.js +0 -2
  24. package/package.json +1 -3
  25. package/provider/CacheProvider.d.ts +7 -7
  26. package/provider/CacheProvider.js +14 -14
  27. package/provider/DebugProvider.d.ts +11 -11
  28. package/provider/DebugProvider.js +28 -29
  29. package/provider/MemoryProvider.d.ts +17 -17
  30. package/provider/MemoryProvider.js +41 -43
  31. package/provider/Provider.d.ts +15 -15
  32. package/provider/ThroughProvider.d.ts +12 -12
  33. package/provider/ThroughProvider.js +20 -20
  34. package/provider/ValidationProvider.d.ts +11 -11
  35. package/provider/ValidationProvider.js +16 -12
  36. package/react/useData.d.ts +5 -5
  37. package/react/useData.js +2 -2
  38. package/state/DataState.d.ts +4 -8
  39. package/state/DataState.js +6 -16
  40. package/state/DictionaryState.d.ts +4 -6
  41. package/state/DictionaryState.js +4 -9
  42. package/test/basics.d.ts +1 -1
  43. package/test/people.d.ts +1 -1
  44. package/test/util.d.ts +1 -1
  45. package/test/util.js +1 -1
  46. package/util/data.d.ts +2 -2
  47. package/util/equal.js +5 -5
  48. package/util/hydrate.d.ts +13 -26
  49. package/util/hydrate.js +44 -60
  50. package/util/index.d.ts +2 -0
  51. package/util/index.js +2 -0
  52. package/util/iterate.d.ts +2 -0
  53. package/util/match.d.ts +2 -10
  54. package/util/match.js +4 -8
  55. package/util/query.d.ts +83 -0
  56. package/util/query.js +129 -0
  57. package/util/sort.d.ts +8 -15
  58. package/util/sort.js +15 -19
  59. package/util/transform.d.ts +26 -45
  60. package/util/transform.js +24 -29
  61. package/util/update.d.ts +22 -0
  62. package/util/update.js +42 -0
  63. package/util/validate.js +2 -2
  64. package/constraint/Constraint.d.ts +0 -7
  65. package/constraint/Constraint.js +0 -3
  66. package/constraint/Constraints.d.ts +0 -20
  67. package/constraint/Constraints.js +0 -34
  68. package/constraint/Filter.d.ts +0 -34
  69. package/constraint/Filter.js +0 -89
  70. package/constraint/Filters.d.ts +0 -27
  71. package/constraint/Filters.js +0 -41
  72. package/constraint/Sort.d.ts +0 -18
  73. package/constraint/Sort.js +0 -33
  74. package/constraint/Sorts.d.ts +0 -26
  75. package/constraint/Sorts.js +0 -47
  76. package/constraint/Statement.d.ts +0 -45
  77. package/constraint/Statement.js +0 -79
  78. package/constraint/index.d.ts +0 -7
  79. package/constraint/index.js +0 -7
  80. package/db/Collection.d.ts +0 -64
  81. package/db/Collection.js +0 -83
  82. package/db/Query.js +0 -94
  83. package/update/ArrayUpdate.d.ts +0 -17
  84. package/update/ArrayUpdate.js +0 -31
  85. package/update/DataUpdate.d.ts +0 -37
  86. package/update/DataUpdate.js +0 -44
  87. package/update/Delete.d.ts +0 -10
  88. package/update/Delete.js +0 -12
  89. package/update/DictionaryUpdate.d.ts +0 -31
  90. package/update/DictionaryUpdate.js +0 -62
  91. package/update/Increment.d.ts +0 -18
  92. package/update/Increment.js +0 -22
  93. package/update/Update.d.ts +0 -8
  94. package/update/Update.js +0 -6
  95. package/update/hydrations.d.ts +0 -3
  96. package/update/hydrations.js +0 -13
  97. package/update/index.d.ts +0 -7
  98. package/update/index.js +0 -7
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable no-console */
2
- import { Statement } from "../constraint/Statement.js";
3
2
  /** Provider that logs operations to a source provider to the console. */
4
3
  class AbstractDebugProvider {
5
4
  async *getItemSequence(collection, id) {
@@ -16,11 +15,11 @@ class AbstractDebugProvider {
16
15
  console.error("ITERATE", key, thrown);
17
16
  }
18
17
  }
19
- async *getQuerySequence(collection, constraints) {
20
- const key = _getQueryKey(collection, constraints);
18
+ async *getQuerySequence(collection, query) {
19
+ const key = _getQueryKey(collection, query);
21
20
  try {
22
21
  console.log("ITERATE", key, "DATA:");
23
- for await (const items of this.source.getQuerySequence(collection, constraints)) {
22
+ for await (const items of this.source.getQuerySequence(collection, query)) {
24
23
  console.log("ITERATE", key, "ITEMS:", items);
25
24
  yield items;
26
25
  }
@@ -94,10 +93,10 @@ export class DebugProvider extends AbstractDebugProvider {
94
93
  throw reason;
95
94
  }
96
95
  }
97
- getQuery(collection, constraints) {
98
- const key = _getQueryKey(collection, constraints);
96
+ getQuery(collection, query) {
97
+ const key = _getQueryKey(collection, query);
99
98
  try {
100
- const items = this.source.getQuery(collection, constraints);
99
+ const items = this.source.getQuery(collection, query);
101
100
  console.log("GET:", key, "ITEMS:", items);
102
101
  return items;
103
102
  }
@@ -106,10 +105,10 @@ export class DebugProvider extends AbstractDebugProvider {
106
105
  throw reason;
107
106
  }
108
107
  }
109
- setQuery(collection, constraints, data) {
110
- const key = _getQueryKey(collection, constraints);
108
+ setQuery(collection, query, data) {
109
+ const key = _getQueryKey(collection, query);
111
110
  try {
112
- const num = this.source.setQuery(collection, constraints, data);
111
+ const num = this.source.setQuery(collection, query, data);
113
112
  console.log("SET:", key, "DATA:", data, "DONE:", num);
114
113
  return num;
115
114
  }
@@ -118,10 +117,10 @@ export class DebugProvider extends AbstractDebugProvider {
118
117
  throw reason;
119
118
  }
120
119
  }
121
- updateQuery(collection, constraints, updates) {
122
- const key = _getQueryKey(collection, constraints);
120
+ updateQuery(collection, query, updates) {
121
+ const key = _getQueryKey(collection, query);
123
122
  try {
124
- const num = this.source.updateQuery(collection, constraints, updates);
123
+ const num = this.source.updateQuery(collection, query, updates);
125
124
  console.log("UPDATE:", key, "UPDATES:", updates, "DONE:", num);
126
125
  return num;
127
126
  }
@@ -130,10 +129,10 @@ export class DebugProvider extends AbstractDebugProvider {
130
129
  throw reason;
131
130
  }
132
131
  }
133
- deleteQuery(collection, constraints) {
134
- const key = _getQueryKey(collection, constraints);
132
+ deleteQuery(collection, query) {
133
+ const key = _getQueryKey(collection, query);
135
134
  try {
136
- const num = this.source.deleteQuery(collection, constraints);
135
+ const num = this.source.deleteQuery(collection, query);
137
136
  console.log("DELETE:", key, "DONE:", num);
138
137
  return num;
139
138
  }
@@ -211,11 +210,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
211
210
  throw reason;
212
211
  }
213
212
  }
214
- async getQuery(collection, constraints) {
215
- const key = _getQueryKey(collection, constraints);
213
+ async getQuery(collection, query) {
214
+ const key = _getQueryKey(collection, query);
216
215
  try {
217
216
  console.log("GET:", key);
218
- const items = await this.source.getQuery(collection, constraints);
217
+ const items = await this.source.getQuery(collection, query);
219
218
  console.log("GET:", key, "ITEMS:", items);
220
219
  return items;
221
220
  }
@@ -224,11 +223,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
224
223
  throw reason;
225
224
  }
226
225
  }
227
- async setQuery(collection, constraints, data) {
228
- const key = _getQueryKey(collection, constraints);
226
+ async setQuery(collection, query, data) {
227
+ const key = _getQueryKey(collection, query);
229
228
  try {
230
229
  console.log("SET:", key, "DATA:", data);
231
- const num = await this.source.setQuery(collection, constraints, data);
230
+ const num = await this.source.setQuery(collection, query, data);
232
231
  console.log("SET:", key, "DATA:", data, "DONE:", num);
233
232
  return num;
234
233
  }
@@ -237,11 +236,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
237
236
  throw reason;
238
237
  }
239
238
  }
240
- async updateQuery(collection, constraints, updates) {
241
- const key = _getQueryKey(collection, constraints);
239
+ async updateQuery(collection, query, updates) {
240
+ const key = _getQueryKey(collection, query);
242
241
  try {
243
242
  console.log("UPDATE:", key, "UPDATES:", updates);
244
- const num = await this.source.updateQuery(collection, constraints, updates);
243
+ const num = await this.source.updateQuery(collection, query, updates);
245
244
  console.log("UPDATE:", key, "UPDATES:", updates, "DONE:", num);
246
245
  return num;
247
246
  }
@@ -250,11 +249,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
250
249
  throw reason;
251
250
  }
252
251
  }
253
- async deleteQuery(collection, constraints) {
254
- const key = _getQueryKey(collection, constraints);
252
+ async deleteQuery(collection, query) {
253
+ const key = _getQueryKey(collection, query);
255
254
  try {
256
255
  console.log("DELETE:", key);
257
- const num = await this.source.deleteQuery(collection, constraints);
256
+ const num = await this.source.deleteQuery(collection, query);
258
257
  console.log("DELETE:", key, "DONE:", num);
259
258
  return num;
260
259
  }
@@ -265,4 +264,4 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
265
264
  }
266
265
  }
267
266
  const _getItemKey = (collection, id) => `${collection}/${id}`;
268
- const _getQueryKey = (collection, statement) => `${collection}?${Statement.prototype.toString.call(statement)}`;
267
+ const _getQueryKey = (collection, query) => `${collection}?${JSON.stringify(query)}`;
@@ -1,7 +1,7 @@
1
1
  import type { Provider } from "./Provider.js";
2
- import type { ItemArray, ItemData, ItemStatement, ItemValue } from "../db/Item.js";
3
- import type { Updates } from "../update/DataUpdate.js";
2
+ import type { ItemArray, ItemData, ItemQuery, ItemValue } from "../db/ItemReference.js";
4
3
  import type { Data } from "../util/data.js";
4
+ import type { Updates } from "../util/update.js";
5
5
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
6
6
  /**
7
7
  * Fast in-memory store for data.
@@ -20,12 +20,12 @@ export declare class MemoryProvider implements Provider {
20
20
  setItem(collection: string, id: string, data: Data): void;
21
21
  updateItem(collection: string, id: string, updates: Updates): void;
22
22
  deleteItem(collection: string, id: string): void;
23
- getQueryTime(collection: string, constraints: ItemStatement): number | null;
24
- getQuery(collection: string, constraints: ItemStatement): ItemArray;
25
- getQuerySequence(collection: string, constraints: ItemStatement): AsyncIterable<ItemArray>;
26
- setQuery(collection: string, constraints: ItemStatement, data: Data): number;
27
- updateQuery(collection: string, constraints: ItemStatement, updates: Updates): number;
28
- deleteQuery(collection: string, constraints: ItemStatement): number;
23
+ getQueryTime(collection: string, query: ItemQuery): number | null;
24
+ getQuery(collection: string, query: ItemQuery): ItemArray;
25
+ getQuerySequence(collection: string, query: ItemQuery): AsyncIterable<ItemArray>;
26
+ setQuery(collection: string, query: ItemQuery, data: Data): number;
27
+ updateQuery(collection: string, query: ItemQuery, updates: Updates): number;
28
+ deleteQuery(collection: string, query: ItemQuery): number;
29
29
  }
30
30
  /** An individual table of data. */
31
31
  export declare class MemoryTable<T extends Data = Data> {
@@ -47,17 +47,17 @@ export declare class MemoryTable<T extends Data = Data> {
47
47
  setItemValueSequence(id: string, sequence: AsyncIterable<ItemValue<T>>): AsyncIterable<ItemValue>;
48
48
  updateItem(id: string, updates: Updates<T>): void;
49
49
  deleteItem(id: string): void;
50
- getQueryTime(constraints: ItemStatement<T>): number | null;
51
- getQuery(constraints: ItemStatement<T>): ItemArray<T>;
52
- getQuerySequence(constraints: ItemStatement<T>): AsyncIterable<ItemArray<T>>;
50
+ getQueryTime(query: ItemQuery<T>): number | null;
51
+ getQuery(query: ItemQuery<T>): ItemArray<T>;
52
+ getQuerySequence(query: ItemQuery<T>): AsyncIterable<ItemArray<T>>;
53
53
  /** Subscribe to a query in this table, but only if the query has been explicitly set (i.e. has a time). */
54
- getCachedQuerySequence(constraints: ItemStatement<T>): AsyncIterable<ItemArray<T>>;
54
+ getCachedQuerySequence(query: ItemQuery<T>): AsyncIterable<ItemArray<T>>;
55
55
  private _setItems;
56
56
  setItems(items: ItemArray<T>): void;
57
57
  setItemsSequence(sequence: AsyncIterable<ItemArray<T>>): AsyncIterable<ItemArray<T>>;
58
- setQueryItems(constraints: ItemStatement<T>, items: ItemArray<T>): void;
59
- setQueryItemsSequence(constraints: ItemStatement<T>, sequence: AsyncIterable<ItemArray<T>>): AsyncIterable<ItemArray<T>>;
60
- setQuery(constraints: ItemStatement<T>, data: T): number;
61
- updateQuery(constraints: ItemStatement<T>, updates: Updates<T>): number;
62
- deleteQuery(constraints: ItemStatement<T>): number;
58
+ setQueryItems(query: ItemQuery<T>, items: ItemArray<T>): void;
59
+ setQueryItemsSequence(query: ItemQuery<T>, sequence: AsyncIterable<ItemArray<T>>): AsyncIterable<ItemArray<T>>;
60
+ setQuery(query: ItemQuery<T>, data: T): number;
61
+ updateQuery(query: ItemQuery<T>, updates: Updates<T>): number;
62
+ deleteQuery(query: ItemQuery<T>): number;
63
63
  }
@@ -1,10 +1,10 @@
1
- import { Statement } from "../constraint/Statement.js";
2
1
  import { RequiredError } from "../error/RequiredError.js";
3
2
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
4
3
  import { getArray } from "../util/array.js";
5
4
  import { isArrayEqual } from "../util/equal.js";
5
+ import { queryItems, queryWritableItems } from "../util/query.js";
6
6
  import { getRandomKey } from "../util/random.js";
7
- import { transformObject } from "../util/transform.js";
7
+ import { updateData } from "../util/update.js";
8
8
  /**
9
9
  * Fast in-memory store for data.
10
10
  * - Extremely fast (ideal for caching!), but does not persist data after the browser window is closed.
@@ -40,23 +40,23 @@ export class MemoryProvider {
40
40
  deleteItem(collection, id) {
41
41
  return this.getTable(collection).deleteItem(id);
42
42
  }
43
- getQueryTime(collection, constraints) {
44
- return this.getTable(collection).getQueryTime(constraints);
43
+ getQueryTime(collection, query) {
44
+ return this.getTable(collection).getQueryTime(query);
45
45
  }
46
- getQuery(collection, constraints) {
47
- return this.getTable(collection).getQuery(constraints);
46
+ getQuery(collection, query) {
47
+ return this.getTable(collection).getQuery(query);
48
48
  }
49
- getQuerySequence(collection, constraints) {
50
- return this.getTable(collection).getQuerySequence(constraints);
49
+ getQuerySequence(collection, query) {
50
+ return this.getTable(collection).getQuerySequence(query);
51
51
  }
52
- setQuery(collection, constraints, data) {
53
- return this.getTable(collection).setQuery(constraints, data);
52
+ setQuery(collection, query, data) {
53
+ return this.getTable(collection).setQuery(query, data);
54
54
  }
55
- updateQuery(collection, constraints, updates) {
56
- return this.getTable(collection).updateQuery(constraints, updates);
55
+ updateQuery(collection, query, updates) {
56
+ return this.getTable(collection).updateQuery(query, updates);
57
57
  }
58
- deleteQuery(collection, constraints) {
59
- return this.getTable(collection).deleteQuery(constraints);
58
+ deleteQuery(collection, query) {
59
+ return this.getTable(collection).deleteQuery(query);
60
60
  }
61
61
  }
62
62
  /** An individual table of data. */
@@ -132,7 +132,7 @@ export class MemoryTable {
132
132
  const oldItem = this._data.get(id);
133
133
  if (!oldItem)
134
134
  throw new RequiredError(`Document "${id}" does not exist`);
135
- const newItem = transformObject(oldItem, updates);
135
+ const newItem = updateData(oldItem, updates);
136
136
  if (oldItem !== newItem) {
137
137
  this._data.set(id, newItem);
138
138
  this._times.set(id, Date.now());
@@ -146,34 +146,34 @@ export class MemoryTable {
146
146
  this._changed.resolve();
147
147
  }
148
148
  }
149
- getQueryTime(constraints) {
150
- return this._times.get(_getQueryKey(constraints)) || null;
149
+ getQueryTime(query) {
150
+ return this._times.get(_getQueryKey(query)) || null;
151
151
  }
152
- getQuery(constraints) {
153
- return getArray(constraints.transform(this._data.values()));
152
+ getQuery(query) {
153
+ return getArray(queryItems(this._data.values(), query));
154
154
  }
155
- async *getQuerySequence(constraints) {
156
- let last = this.getQuery(constraints);
155
+ async *getQuerySequence(query) {
156
+ let last = this.getQuery(query);
157
157
  yield last;
158
158
  while (true) {
159
159
  await this._changed;
160
- const next = this.getQuery(constraints);
160
+ const next = this.getQuery(query);
161
161
  if (!isArrayEqual(last, next))
162
162
  yield (last = next);
163
163
  }
164
164
  }
165
165
  /** Subscribe to a query in this table, but only if the query has been explicitly set (i.e. has a time). */
166
- async *getCachedQuerySequence(constraints) {
167
- const key = _getQueryKey(constraints);
166
+ async *getCachedQuerySequence(query) {
167
+ const key = _getQueryKey(query);
168
168
  let last = undefined;
169
169
  if (this._times.has(key)) {
170
- last = this.getQuery(constraints);
170
+ last = this.getQuery(query);
171
171
  yield last;
172
172
  }
173
173
  while (true) {
174
174
  await this._changed;
175
175
  if (this._times.has(key)) {
176
- const next = this.getQuery(constraints);
176
+ const next = this.getQuery(query);
177
177
  if (!last || !isArrayEqual(last, next))
178
178
  yield (last = next);
179
179
  }
@@ -194,15 +194,15 @@ export class MemoryTable {
194
194
  yield items;
195
195
  }
196
196
  }
197
- setQueryItems(constraints, items) {
198
- const key = _getQueryKey(constraints);
197
+ setQueryItems(query, items) {
198
+ const key = _getQueryKey(query);
199
199
  const now = Date.now();
200
200
  this._times.set(key, now);
201
201
  this._setItems(items, now);
202
202
  this._changed.resolve();
203
203
  }
204
- async *setQueryItemsSequence(constraints, sequence) {
205
- const key = _getQueryKey(constraints);
204
+ async *setQueryItemsSequence(query, sequence) {
205
+ const key = _getQueryKey(query);
206
206
  for await (const items of sequence) {
207
207
  const now = Date.now();
208
208
  this._times.set(key, now);
@@ -211,26 +211,26 @@ export class MemoryTable {
211
211
  yield items;
212
212
  }
213
213
  }
214
- setQuery(constraints, data) {
214
+ setQuery(query, data) {
215
215
  const now = Date.now();
216
216
  let count = 0;
217
- for (const { id } of _getWriteConstraints(constraints).transform(this._data.values())) {
217
+ for (const { id } of queryWritableItems(this._data.values(), query)) {
218
218
  this._data.set(id, { ...data, id });
219
219
  this._times.set(id, now);
220
220
  count++;
221
221
  }
222
222
  if (count) {
223
- const key = _getQueryKey(constraints);
223
+ const key = _getQueryKey(query);
224
224
  this._times.set(key, now);
225
225
  this._changed.resolve();
226
226
  }
227
227
  return count;
228
228
  }
229
- updateQuery(constraints, updates) {
229
+ updateQuery(query, updates) {
230
230
  const now = Date.now();
231
231
  let count = 0;
232
- for (const oldItem of _getWriteConstraints(constraints).transform(this._data.values())) {
233
- const newItem = transformObject(oldItem, updates);
232
+ for (const oldItem of queryWritableItems(this._data.values(), query)) {
233
+ const newItem = updateData(oldItem, updates);
234
234
  if (oldItem !== newItem) {
235
235
  const id = oldItem.id;
236
236
  this._data.set(id, newItem);
@@ -239,29 +239,27 @@ export class MemoryTable {
239
239
  }
240
240
  }
241
241
  if (count) {
242
- const key = _getQueryKey(constraints);
242
+ const key = _getQueryKey(query);
243
243
  this._times.set(key, now);
244
244
  this._changed.resolve();
245
245
  }
246
246
  return count;
247
247
  }
248
- deleteQuery(constraints) {
248
+ deleteQuery(query) {
249
249
  const now = Date.now();
250
250
  let count = 0;
251
- for (const { id } of _getWriteConstraints(constraints).transform(this._data.values())) {
251
+ for (const { id } of queryWritableItems(this._data.values(), query)) {
252
252
  this._data.delete(id);
253
253
  this._times.set(id, now);
254
254
  count++;
255
255
  }
256
256
  if (count) {
257
- const key = _getQueryKey(constraints);
257
+ const key = _getQueryKey(query);
258
258
  this._times.set(key, now);
259
259
  this._changed.resolve();
260
260
  }
261
261
  return count;
262
262
  }
263
263
  }
264
- // When we're writing data, if there's no limit set the results don't need to be sorted (for performance).
265
- const _getWriteConstraints = (statement) => (statement.limit ? statement : statement.filters);
266
264
  // Queries that have no limit don't care about sorting either.
267
- const _getQueryKey = (statement) => (statement.limit ? `"filters":${statement.filters.toString()}}` : Statement.prototype.toString.call(statement));
265
+ const _getQueryKey = (query) => JSON.stringify(query);
@@ -1,6 +1,6 @@
1
- import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
2
- import type { Updates } from "../update/DataUpdate.js";
1
+ import type { ItemArray, ItemQuery, ItemValue } from "../db/ItemReference.js";
3
2
  import type { Data } from "../util/data.js";
3
+ import type { Updates } from "../util/update.js";
4
4
  /** Provides access to data (e.g. IndexedDB, Firebase, or in-memory cache providers). */
5
5
  declare abstract class AbstractProvider {
6
6
  /**
@@ -42,30 +42,30 @@ declare abstract class AbstractProvider {
42
42
  *
43
43
  * @return Set of values in `id: data` format.
44
44
  */
45
- abstract getQuery(collection: string, constraints: ItemStatement): ItemArray | PromiseLike<ItemArray>;
45
+ abstract getQuery(collection: string, query: ItemQuery): ItemArray | PromiseLike<ItemArray>;
46
46
  /**
47
47
  * Subscribe to all matching items with an async iterator.
48
48
  */
49
- abstract getQuerySequence(collection: string, constraints: ItemStatement): AsyncIterable<ItemArray>;
49
+ abstract getQuerySequence(collection: string, query: ItemQuery): AsyncIterable<ItemArray>;
50
50
  /**
51
51
  * Set the data of all matching items.
52
52
  *
53
53
  * @param data Data to set matching items to.
54
54
  * @return Number of items that were set.
55
55
  */
56
- abstract setQuery(collection: string, constraints: ItemStatement, data: Data): number | PromiseLike<number>;
56
+ abstract setQuery(collection: string, query: ItemQuery, data: Data): number | PromiseLike<number>;
57
57
  /**
58
58
  * Update the data of all matching items.
59
59
  *
60
60
  * @param updates Set of property updates to apply to matching items.
61
61
  * @return Number of items that were updated.
62
62
  */
63
- abstract updateQuery(collection: string, constraints: ItemStatement, updates: Updates): number | PromiseLike<number>;
63
+ abstract updateQuery(collection: string, query: ItemQuery, updates: Updates): number | PromiseLike<number>;
64
64
  /**
65
65
  * Delete all matching items.
66
66
  * @return Number of items that were deleted.
67
67
  */
68
- abstract deleteQuery(collection: string, constraints: ItemStatement): number | PromiseLike<number>;
68
+ abstract deleteQuery(collection: string, query: ItemQuery): number | PromiseLike<number>;
69
69
  }
70
70
  /** Provider with a fully synchronous interface */
71
71
  export declare abstract class Provider extends AbstractProvider {
@@ -74,10 +74,10 @@ export declare abstract class Provider extends AbstractProvider {
74
74
  abstract setItem(collection: string, id: string, data: Data): void;
75
75
  abstract updateItem(collection: string, id: string, updates: Updates): void;
76
76
  abstract deleteItem(collection: string, id: string): void;
77
- abstract getQuery(collection: string, constraints: ItemStatement): ItemArray;
78
- abstract setQuery(collection: string, constraints: ItemStatement, data: Data): number;
79
- abstract updateQuery(collection: string, constraints: ItemStatement, updates: Updates): number;
80
- abstract deleteQuery(collection: string, constraints: ItemStatement): number;
77
+ abstract getQuery(collection: string, query: ItemQuery): ItemArray;
78
+ abstract setQuery(collection: string, query: ItemQuery, data: Data): number;
79
+ abstract updateQuery(collection: string, query: ItemQuery, updates: Updates): number;
80
+ abstract deleteQuery(collection: string, query: ItemQuery): number;
81
81
  }
82
82
  /** Provider with a fully asynchronous interface */
83
83
  export declare abstract class AsyncProvider extends AbstractProvider {
@@ -86,9 +86,9 @@ export declare abstract class AsyncProvider extends AbstractProvider {
86
86
  abstract setItem(collection: string, id: string, data: Data): Promise<void>;
87
87
  abstract updateItem(collection: string, id: string, updates: Updates): Promise<void>;
88
88
  abstract deleteItem(collection: string, id: string): Promise<void>;
89
- abstract getQuery(collection: string, constraints: ItemStatement): Promise<ItemArray>;
90
- abstract setQuery(collection: string, constraints: ItemStatement, data: Data): Promise<number>;
91
- abstract updateQuery(collection: string, constraints: ItemStatement, updates: Updates): Promise<number>;
92
- abstract deleteQuery(collection: string, constraints: ItemStatement): Promise<number>;
89
+ abstract getQuery(collection: string, query: ItemQuery): Promise<ItemArray>;
90
+ abstract setQuery(collection: string, query: ItemQuery, data: Data): Promise<number>;
91
+ abstract updateQuery(collection: string, query: ItemQuery, updates: Updates): Promise<number>;
92
+ abstract deleteQuery(collection: string, query: ItemQuery): Promise<number>;
93
93
  }
94
94
  export {};
@@ -1,8 +1,8 @@
1
1
  import type { AsyncProvider, Provider } from "./Provider.js";
2
- import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
3
- import type { Updates } from "../update/DataUpdate.js";
2
+ import type { ItemArray, ItemQuery, ItemValue } from "../db/ItemReference.js";
4
3
  import type { Data } from "../util/data.js";
5
4
  import type { Sourceable } from "../util/source.js";
5
+ import type { Updates } from "../util/update.js";
6
6
  /** A provider that passes through to a synchronous source. */
7
7
  export declare class ThroughProvider implements Provider, Sourceable<Provider> {
8
8
  readonly source: Provider;
@@ -13,11 +13,11 @@ export declare class ThroughProvider implements Provider, Sourceable<Provider> {
13
13
  setItem(collection: string, id: string, data: Data): void;
14
14
  updateItem(collection: string, id: string, update: Updates): void;
15
15
  deleteItem(collection: string, id: string): void;
16
- getQuery(collection: string, constraints: ItemStatement): ItemArray;
17
- getQuerySequence(collection: string, constraints: ItemStatement): AsyncIterable<ItemArray>;
18
- setQuery(collection: string, constraints: ItemStatement, data: Data): number;
19
- updateQuery(collection: string, constraints: ItemStatement, update: Updates): number;
20
- deleteQuery(collection: string, constraints: ItemStatement): number;
16
+ getQuery(collection: string, query: ItemQuery): ItemArray;
17
+ getQuerySequence(collection: string, query: ItemQuery): AsyncIterable<ItemArray>;
18
+ setQuery(collection: string, query: ItemQuery, data: Data): number;
19
+ updateQuery(collection: string, query: ItemQuery, update: Updates): number;
20
+ deleteQuery(collection: string, query: ItemQuery): number;
21
21
  }
22
22
  /** A provider that passes through to an asynchronous source. */
23
23
  export declare class AsyncThroughProvider implements AsyncProvider, Sourceable<AsyncProvider> {
@@ -29,9 +29,9 @@ export declare class AsyncThroughProvider implements AsyncProvider, Sourceable<A
29
29
  setItem(collection: string, id: string, data: Data): Promise<void>;
30
30
  updateItem(collection: string, id: string, updates: Updates): Promise<void>;
31
31
  deleteItem(collection: string, id: string): Promise<void>;
32
- getQuery(collection: string, constraints: ItemStatement): Promise<ItemArray>;
33
- getQuerySequence(collection: string, constraints: ItemStatement): AsyncIterable<ItemArray>;
34
- setQuery(collection: string, constraints: ItemStatement, data: Data): Promise<number>;
35
- updateQuery(collection: string, constraints: ItemStatement, updates: Updates): Promise<number>;
36
- deleteQuery(collection: string, constraints: ItemStatement): Promise<number>;
32
+ getQuery(collection: string, query: ItemQuery): Promise<ItemArray>;
33
+ getQuerySequence(collection: string, query: ItemQuery): AsyncIterable<ItemArray>;
34
+ setQuery(collection: string, query: ItemQuery, data: Data): Promise<number>;
35
+ updateQuery(collection: string, query: ItemQuery, updates: Updates): Promise<number>;
36
+ deleteQuery(collection: string, query: ItemQuery): Promise<number>;
37
37
  }
@@ -21,20 +21,20 @@ export class ThroughProvider {
21
21
  deleteItem(collection, id) {
22
22
  return this.source.deleteItem(collection, id);
23
23
  }
24
- getQuery(collection, constraints) {
25
- return this.source.getQuery(collection, constraints);
24
+ getQuery(collection, query) {
25
+ return this.source.getQuery(collection, query);
26
26
  }
27
- getQuerySequence(collection, constraints) {
28
- return this.source.getQuerySequence(collection, constraints);
27
+ getQuerySequence(collection, query) {
28
+ return this.source.getQuerySequence(collection, query);
29
29
  }
30
- setQuery(collection, constraints, data) {
31
- return this.source.setQuery(collection, constraints, data);
30
+ setQuery(collection, query, data) {
31
+ return this.source.setQuery(collection, query, data);
32
32
  }
33
- updateQuery(collection, constraints, update) {
34
- return this.source.updateQuery(collection, constraints, update);
33
+ updateQuery(collection, query, update) {
34
+ return this.source.updateQuery(collection, query, update);
35
35
  }
36
- deleteQuery(collection, constraints) {
37
- return this.source.deleteQuery(collection, constraints);
36
+ deleteQuery(collection, query) {
37
+ return this.source.deleteQuery(collection, query);
38
38
  }
39
39
  }
40
40
  /** A provider that passes through to an asynchronous source. */
@@ -60,19 +60,19 @@ export class AsyncThroughProvider {
60
60
  deleteItem(collection, id) {
61
61
  return this.source.deleteItem(collection, id);
62
62
  }
63
- getQuery(collection, constraints) {
64
- return this.source.getQuery(collection, constraints);
63
+ getQuery(collection, query) {
64
+ return this.source.getQuery(collection, query);
65
65
  }
66
- getQuerySequence(collection, constraints) {
67
- return this.source.getQuerySequence(collection, constraints);
66
+ getQuerySequence(collection, query) {
67
+ return this.source.getQuerySequence(collection, query);
68
68
  }
69
- setQuery(collection, constraints, data) {
70
- return this.source.setQuery(collection, constraints, data);
69
+ setQuery(collection, query, data) {
70
+ return this.source.setQuery(collection, query, data);
71
71
  }
72
- updateQuery(collection, constraints, updates) {
73
- return this.source.updateQuery(collection, constraints, updates);
72
+ updateQuery(collection, query, updates) {
73
+ return this.source.updateQuery(collection, query, updates);
74
74
  }
75
- deleteQuery(collection, constraints) {
76
- return this.source.deleteQuery(collection, constraints);
75
+ deleteQuery(collection, query) {
76
+ return this.source.deleteQuery(collection, query);
77
77
  }
78
78
  }
@@ -1,9 +1,9 @@
1
1
  import type { AsyncProvider, Provider } from "./Provider.js";
2
- import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
2
+ import type { ItemArray, ItemQuery, ItemValue } from "../db/ItemReference.js";
3
3
  import type { DataSchema, DataSchemas } from "../schema/DataSchema.js";
4
- import type { Updates } from "../update/DataUpdate.js";
5
4
  import type { DataKey, Datas } from "../util/data.js";
6
5
  import type { Sourceable } from "../util/source.js";
6
+ import type { Updates } from "../util/update.js";
7
7
  /** Validate a source provider (source can have any type because validation guarantees the type). */
8
8
  declare abstract class BaseValidationProvider<T extends Datas> {
9
9
  abstract source: Provider | AsyncProvider;
@@ -11,7 +11,7 @@ declare abstract class BaseValidationProvider<T extends Datas> {
11
11
  constructor(schemas: DataSchemas<T>);
12
12
  getSchema<K extends DataKey<T>>(collection: K): DataSchema<T[K]>;
13
13
  getItemSequence<K extends DataKey<T>>(collection: K, id: string): AsyncIterable<ItemValue<T[K]>>;
14
- getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>): AsyncIterable<ItemArray<T[K]>>;
14
+ getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>): AsyncIterable<ItemArray<T[K]>>;
15
15
  }
16
16
  /** Validate a synchronous source provider (source can have any type because validation guarantees the type). */
17
17
  export declare class ValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements Provider, Sourceable<Provider> {
@@ -22,10 +22,10 @@ export declare class ValidationProvider<T extends Datas> extends BaseValidationP
22
22
  setItem<K extends DataKey<T>>(collection: K, id: string, value: T[K]): void;
23
23
  updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
24
24
  deleteItem<K extends DataKey<T>>(collection: K, id: string): void;
25
- getQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>): ItemArray<T[K]>;
26
- setQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>, value: T[K]): number;
27
- updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>, updates: Updates<T[K]>): number;
28
- deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>): number;
25
+ getQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>): ItemArray<T[K]>;
26
+ setQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>, value: T[K]): number;
27
+ updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>, updates: Updates<T[K]>): number;
28
+ deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>): number;
29
29
  }
30
30
  /** Validate an asynchronous source provider (source can have any type because validation guarantees the type). */
31
31
  export declare class AsyncValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements AsyncProvider, Sourceable<AsyncProvider> {
@@ -36,9 +36,9 @@ export declare class AsyncValidationProvider<T extends Datas> extends BaseValida
36
36
  setItem<K extends DataKey<T>>(collection: K, id: string, value: T[K]): Promise<void>;
37
37
  updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
38
38
  deleteItem<K extends DataKey<T>>(collection: K, id: string): Promise<void>;
39
- getQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>): Promise<ItemArray<T[K]>>;
40
- setQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>, value: T[K]): Promise<number>;
41
- updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>, updates: Updates<T[K]>): Promise<number>;
42
- deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemStatement<T[K]>): Promise<number>;
39
+ getQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>): Promise<ItemArray<T[K]>>;
40
+ setQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>, value: T[K]): Promise<number>;
41
+ updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>, updates: Updates<T[K]>): Promise<number>;
42
+ deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemQuery<T[K]>): Promise<number>;
43
43
  }
44
44
  export {};