@signaldb/core 2.0.0-beta.2 → 2.0.0-beta.21

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 (145) hide show
  1. package/dist/.vite/manifest.json +183 -80
  2. package/dist/AsyncDataAdapter.d.ts +53 -7
  3. package/dist/AutoFetchDataAdapter.d.ts +4 -6
  4. package/dist/Collection/Cursor.d.ts +56 -4
  5. package/dist/Collection/Observer.d.ts +33 -0
  6. package/dist/Collection/index.d.ts +66 -19
  7. package/dist/Collection/types.d.ts +9 -2
  8. package/dist/DataAdapter.d.ts +24 -6
  9. package/dist/DefaultDataAdapter.d.ts +5 -5
  10. package/dist/WorkerDataAdapter.d.ts +57 -5
  11. package/dist/WorkerDataAdapterHost.d.ts +9 -7
  12. package/dist/createIndex.d.ts +2 -2
  13. package/dist/createIndexProvider.d.ts +2 -2
  14. package/dist/createReactivityAdapter.d.ts +2 -2
  15. package/dist/createStorageAdapter.d.ts +1 -1
  16. package/dist/getIndexInfo.d.ts +3 -4
  17. package/dist/index.cjs.js +33 -31
  18. package/dist/index.d.ts +6 -1
  19. package/dist/index.mjs +17 -32
  20. package/dist/index10.cjs.js +11 -0
  21. package/dist/index10.mjs +10 -18
  22. package/dist/index11.cjs.js +23 -0
  23. package/dist/index11.mjs +22 -15
  24. package/dist/index12.cjs.js +45 -0
  25. package/dist/index12.mjs +44 -353
  26. package/dist/index13.cjs.js +22 -0
  27. package/dist/index13.mjs +21 -419
  28. package/dist/index14.cjs.js +45 -0
  29. package/dist/index14.mjs +44 -206
  30. package/dist/index15.cjs.js +86 -0
  31. package/dist/index15.mjs +85 -388
  32. package/dist/index16.cjs.js +15 -0
  33. package/dist/index16.mjs +14 -579
  34. package/dist/index17.cjs.js +141 -0
  35. package/dist/index17.mjs +140 -152
  36. package/dist/index18.cjs.js +47 -0
  37. package/dist/index18.mjs +46 -26
  38. package/dist/index19.cjs.js +15 -0
  39. package/dist/index19.mjs +14 -41
  40. package/dist/index2.cjs.js +33 -0
  41. package/dist/index2.mjs +32 -258
  42. package/dist/index20.cjs.js +23 -0
  43. package/dist/index20.mjs +22 -16
  44. package/dist/index21.cjs.js +37 -0
  45. package/dist/index21.mjs +36 -104
  46. package/dist/index22.cjs.js +35 -0
  47. package/dist/index22.mjs +34 -128
  48. package/dist/index23.cjs.js +21 -0
  49. package/dist/index23.mjs +20 -7
  50. package/dist/index24.cjs.js +19 -0
  51. package/dist/index24.mjs +18 -27
  52. package/dist/index25.cjs.js +157 -0
  53. package/dist/index25.mjs +156 -11
  54. package/dist/index26.cjs.js +38 -0
  55. package/dist/index26.mjs +37 -29
  56. package/dist/index27.cjs.js +42 -0
  57. package/dist/index27.mjs +41 -46
  58. package/dist/index28.cjs.js +347 -0
  59. package/dist/index28.mjs +345 -7
  60. package/dist/index29.cjs.js +602 -0
  61. package/dist/index29.mjs +601 -7
  62. package/dist/index3.cjs.js +19 -0
  63. package/dist/index3.mjs +18 -556
  64. package/dist/index30.cjs.js +11 -0
  65. package/dist/index30.mjs +10 -42
  66. package/dist/index31.cjs.js +11 -0
  67. package/dist/index31.mjs +10 -29
  68. package/dist/index32.cjs.js +90 -0
  69. package/dist/index32.mjs +89 -10
  70. package/dist/index33.cjs.js +53 -0
  71. package/dist/index33.mjs +52 -5
  72. package/dist/index34.cjs.js +453 -0
  73. package/dist/index34.mjs +453 -0
  74. package/dist/index35.cjs.js +72 -0
  75. package/dist/index35.mjs +72 -0
  76. package/dist/index36.cjs.js +580 -0
  77. package/dist/index36.mjs +580 -0
  78. package/dist/index37.cjs.js +21 -0
  79. package/dist/index37.mjs +21 -0
  80. package/dist/index38.cjs.js +363 -0
  81. package/dist/index38.mjs +363 -0
  82. package/dist/index39.cjs.js +513 -0
  83. package/dist/index39.mjs +513 -0
  84. package/dist/index4.cjs.js +209 -0
  85. package/dist/index4.mjs +204 -5
  86. package/dist/index5.cjs.js +187 -0
  87. package/dist/index5.mjs +186 -5
  88. package/dist/index6.cjs.js +303 -0
  89. package/dist/index6.mjs +301 -28
  90. package/dist/index7.cjs.js +125 -0
  91. package/dist/index7.mjs +124 -12
  92. package/dist/index8.cjs.js +33 -0
  93. package/dist/index8.mjs +32 -5
  94. package/dist/index9.cjs.js +12 -0
  95. package/dist/index9.mjs +11 -133
  96. package/dist/types/IndexProvider.d.ts +2 -2
  97. package/dist/types/Modifier.d.ts +1 -1
  98. package/dist/types/ReactivityAdapter.d.ts +1 -1
  99. package/dist/types/StorageAdapter.d.ts +9 -1
  100. package/dist/utils/applyQueryOptions.d.ts +15 -0
  101. package/dist/utils/createSignal.d.ts +2 -2
  102. package/dist/utils/getMatchingKeys.d.ts +2 -2
  103. package/dist/utils/idIndexQuery.d.ts +20 -0
  104. package/dist/utils/incrementalQueryUpdate.d.ts +62 -0
  105. package/dist/utils/isFieldExpression.d.ts +1 -1
  106. package/dist/utils/match.d.ts +1 -1
  107. package/dist/utils/modify.d.ts +1 -1
  108. package/dist/utils/projectItems.d.ts +12 -0
  109. package/dist/utils/queryDelta.d.ts +83 -0
  110. package/dist/utils/queryId.d.ts +2 -2
  111. package/dist/utils/reactiveOrAsync.d.ts +59 -0
  112. package/dist/utils/storageIndexQuery.d.ts +20 -0
  113. package/package.json +1 -1
  114. package/dist/index.cjs10.js +0 -18
  115. package/dist/index.cjs11.js +0 -15
  116. package/dist/index.cjs12.js +0 -353
  117. package/dist/index.cjs13.js +0 -419
  118. package/dist/index.cjs14.js +0 -206
  119. package/dist/index.cjs15.js +0 -388
  120. package/dist/index.cjs16.js +0 -579
  121. package/dist/index.cjs17.js +0 -152
  122. package/dist/index.cjs18.js +0 -26
  123. package/dist/index.cjs19.js +0 -42
  124. package/dist/index.cjs2.js +0 -259
  125. package/dist/index.cjs20.js +0 -16
  126. package/dist/index.cjs21.js +0 -104
  127. package/dist/index.cjs22.js +0 -129
  128. package/dist/index.cjs23.js +0 -7
  129. package/dist/index.cjs24.js +0 -27
  130. package/dist/index.cjs25.js +0 -10
  131. package/dist/index.cjs26.js +0 -29
  132. package/dist/index.cjs27.js +0 -46
  133. package/dist/index.cjs28.js +0 -8
  134. package/dist/index.cjs29.js +0 -7
  135. package/dist/index.cjs3.js +0 -557
  136. package/dist/index.cjs30.js +0 -42
  137. package/dist/index.cjs31.js +0 -29
  138. package/dist/index.cjs32.js +0 -9
  139. package/dist/index.cjs33.js +0 -5
  140. package/dist/index.cjs4.js +0 -5
  141. package/dist/index.cjs5.js +0 -5
  142. package/dist/index.cjs6.js +0 -29
  143. package/dist/index.cjs7.js +0 -12
  144. package/dist/index.cjs8.js +0 -5
  145. package/dist/index.cjs9.js +0 -133
@@ -0,0 +1,363 @@
1
+ import isEqual from "./index2.mjs";
2
+ import { diffQueryResults, isEmptyQueryDelta } from "./index4.mjs";
3
+ import getIndexInfo from "./index17.mjs";
4
+ import deepClone from "./index18.mjs";
5
+ import match from "./index19.mjs";
6
+ import modify from "./index20.mjs";
7
+ import projectItems from "./index23.mjs";
8
+ import sortItems from "./index24.mjs";
9
+ import incrementalQueryUpdate from "./index25.mjs";
10
+ import queryId from "./index26.mjs";
11
+ import idIndexQuery from "./index27.mjs";
12
+ import storageIndexQuery from "./index33.mjs";
13
+ import compact from "./index37.mjs";
14
+ //#region src/WorkerDataAdapterHost.ts
15
+ /**
16
+ * Turns the item states a write produced into the upsert/delete split a query update needs.
17
+ *
18
+ * The two lists are not symmetric: an item that is still there after the write is described by
19
+ * its new state, while an item that is gone — removed, or given a new id — is described by the id
20
+ * it used to have and nothing else. Mixing the states from before and after a write into one list
21
+ * loses exactly that distinction.
22
+ * @template T - The type of the items.
23
+ * @param previousItems - The items as they were before the write.
24
+ * @param modifiedItems - The items as they are after it.
25
+ * @returns The changeset describing the write.
26
+ */
27
+ function toChangeset(previousItems, modifiedItems) {
28
+ const modifiedIds = new Set(modifiedItems.map((item) => item.id));
29
+ return {
30
+ upserts: modifiedItems,
31
+ deletes: previousItems.map((item) => item.id).filter((id) => !modifiedIds.has(id))
32
+ };
33
+ }
34
+ var WorkerDataAdapterHost = class {
35
+ workerContext;
36
+ options;
37
+ id;
38
+ log = () => {};
39
+ storageAdapters = /* @__PURE__ */ new Map();
40
+ storageAdapterReady = /* @__PURE__ */ new Map();
41
+ collectionIndices = /* @__PURE__ */ new Map();
42
+ queries = /* @__PURE__ */ new Map();
43
+ onError = (error) => {
44
+ console.error(error);
45
+ };
46
+ constructor(workerContext, options) {
47
+ this.workerContext = workerContext;
48
+ this.options = options;
49
+ this.id = this.options.id || "default-worker-data-adapter";
50
+ if (this.options.onError) this.onError = this.options.onError;
51
+ if (this.options.log) this.log = this.options.log;
52
+ this.workerContext.addEventListener("message", async (event) => {
53
+ try {
54
+ const { workerId, id, method, args } = event.data;
55
+ await this.handleMessage(workerId, id, method, args);
56
+ } catch (error) {
57
+ this.onError(error);
58
+ }
59
+ });
60
+ this.respond("ready", null, null, "ready");
61
+ }
62
+ respond(id, data, error = null, type = "response") {
63
+ this.workerContext.postMessage({
64
+ id,
65
+ workerId: this.id,
66
+ type,
67
+ data,
68
+ error
69
+ });
70
+ }
71
+ async handleMessage(workerId, id, method, args) {
72
+ if (workerId !== this.id) return;
73
+ const fn = this[method];
74
+ if (typeof fn !== "function") {
75
+ this.respond(id, null, /* @__PURE__ */ new Error(`Method ${method} not found`));
76
+ return;
77
+ }
78
+ this.log(method, ...args);
79
+ await this.isReady(args[0]);
80
+ try {
81
+ const result = await fn.apply(this, args);
82
+ this.respond(id, result);
83
+ } catch (error) {
84
+ this.respond(id, null, error);
85
+ }
86
+ }
87
+ async getIndexInfo(collectionName, selector) {
88
+ const storageAdapter = this.storageAdapters.get(collectionName);
89
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
90
+ if (selector != null && Object.keys(selector).length === 1 && "id" in selector) {
91
+ const idResult = idIndexQuery(selector);
92
+ if (idResult.matched) return {
93
+ matched: true,
94
+ ids: compact(idResult.ids),
95
+ optimizedSelector: {}
96
+ };
97
+ }
98
+ if (selector == null) return {
99
+ matched: false,
100
+ ids: [],
101
+ optimizedSelector: {}
102
+ };
103
+ return getIndexInfo((this.collectionIndices.get(collectionName) ?? []).map((field) => storageIndexQuery(storageAdapter, field)), selector);
104
+ }
105
+ async queryItems(collectionName, selector) {
106
+ const storageAdapter = this.storageAdapters.get(collectionName);
107
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
108
+ const indexInfo = await this.getIndexInfo(collectionName, selector);
109
+ const matchItems = (item) => {
110
+ if (indexInfo.optimizedSelector == null) return true;
111
+ if (Object.keys(indexInfo.optimizedSelector).length <= 0) return true;
112
+ return match(item, indexInfo.optimizedSelector);
113
+ };
114
+ if (indexInfo.matched) {
115
+ const items = await storageAdapter.readIds(indexInfo.ids);
116
+ if (isEqual(indexInfo.optimizedSelector, {})) return items;
117
+ return items.filter(matchItems);
118
+ } else {
119
+ const allItems = await storageAdapter.readAll();
120
+ if (isEqual(selector, {})) return allItems;
121
+ return allItems.filter(matchItems);
122
+ }
123
+ }
124
+ async executeQuery(collectionName, selector, options) {
125
+ if (selector === null) return [];
126
+ const items = await this.queryItems(collectionName, selector || {});
127
+ const { sort, skip, limit, fields } = options || {};
128
+ const sorted = sort ? sortItems(items, sort) : items;
129
+ const skipped = skip ? sorted.slice(skip) : sorted;
130
+ return projectItems(limit ? skipped.slice(0, limit) : skipped, fields);
131
+ }
132
+ ensureQuery(collectionName, selector, options) {
133
+ const id = queryId(selector, options);
134
+ if (!this.queries.get(collectionName)) throw new Error(`Collection ${collectionName} not initialized!`);
135
+ let query = this.queries.get(collectionName)?.get(id);
136
+ if (!query) {
137
+ query = {
138
+ selector,
139
+ options,
140
+ items: null
141
+ };
142
+ this.queries.get(collectionName)?.set(id, query);
143
+ }
144
+ return query;
145
+ }
146
+ setQueryItems(query, items) {
147
+ query.items = items;
148
+ query.itemIds = void 0;
149
+ }
150
+ queryItemIds(query) {
151
+ if (!query.itemIds) query.itemIds = new Set((query.items ?? []).map((item) => item.id));
152
+ return query.itemIds;
153
+ }
154
+ emitQueryUpdate(collectionName, selector, options, state, error, items, delta) {
155
+ const id = queryId(selector, options);
156
+ if (!this.queries.get(collectionName)) throw new Error(`Collection ${collectionName} not initialized!`);
157
+ this.respond(id, {
158
+ collectionName,
159
+ qid: id,
160
+ selector,
161
+ options,
162
+ state,
163
+ error,
164
+ items,
165
+ delta
166
+ }, null, "queryUpdate");
167
+ }
168
+ ensureStorageAdapter(name) {
169
+ if (this.storageAdapters.has(name)) return;
170
+ const adapter = this.options.storage(name);
171
+ if (!adapter) return;
172
+ this.storageAdapters.set(name, adapter);
173
+ }
174
+ async checkQueryUpdates(collectionName, changes) {
175
+ const queries = this.queries.get(collectionName);
176
+ if (!queries) throw new Error(`Collection ${collectionName} not initialized!`);
177
+ if (changes.upserts.length === 0 && changes.deletes.length === 0) return;
178
+ const affectedQueries = [...queries.values()].filter((query) => {
179
+ const ids = this.queryItemIds(query);
180
+ if (changes.deletes.some((id) => ids.has(id))) return true;
181
+ return changes.upserts.some((item) => ids.has(item.id) || match(item, query.selector));
182
+ });
183
+ if (affectedQueries.length === 0) return;
184
+ await Promise.all(affectedQueries.map(async (query) => {
185
+ const { selector, options } = query;
186
+ const previous = query.items;
187
+ const incremental = previous == null ? null : incrementalQueryUpdate(previous, selector, options, changes);
188
+ if (incremental != null) {
189
+ const delta = diffQueryResults(previous, incremental);
190
+ if (isEmptyQueryDelta(delta)) return;
191
+ this.setQueryItems(query, incremental);
192
+ this.emitQueryUpdate(collectionName, selector, options, "complete", null, void 0, delta);
193
+ return;
194
+ }
195
+ this.emitQueryUpdate(collectionName, selector, options, "active", null);
196
+ const queryItems = await this.executeQuery(collectionName, selector, options);
197
+ if (previous == null) {
198
+ this.setQueryItems(query, queryItems);
199
+ this.emitQueryUpdate(collectionName, selector, options, "complete", null, queryItems);
200
+ return;
201
+ }
202
+ const delta = diffQueryResults(previous, queryItems);
203
+ this.setQueryItems(query, queryItems);
204
+ this.emitQueryUpdate(collectionName, selector, options, "complete", null, void 0, delta);
205
+ }));
206
+ }
207
+ registerCollection = async (collectionName, indices) => {
208
+ this.collectionIndices.set(collectionName, indices);
209
+ this.queries.set(collectionName, /* @__PURE__ */ new Map());
210
+ this.ensureStorageAdapter(collectionName);
211
+ const storageAdapter = this.storageAdapters.get(collectionName);
212
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
213
+ const setupPromise = (async () => {
214
+ await storageAdapter.setup();
215
+ await Promise.all(indices.map((index) => storageAdapter.createIndex(index)));
216
+ })();
217
+ this.storageAdapterReady.set(collectionName, setupPromise);
218
+ await setupPromise;
219
+ };
220
+ unregisterCollection = async (collectionName) => {
221
+ this.storageAdapters.delete(collectionName);
222
+ this.queries.delete(collectionName);
223
+ };
224
+ registerQuery = async (collectionName, selector, options) => {
225
+ const query = this.ensureQuery(collectionName, selector, options);
226
+ const queryItems = await this.executeQuery(collectionName, selector, options);
227
+ this.setQueryItems(query, queryItems);
228
+ this.emitQueryUpdate(collectionName, selector, options, "complete", null, queryItems);
229
+ };
230
+ unregisterQuery = async (collectionName, selector, options) => {
231
+ const id = queryId(selector, options);
232
+ if (!this.queries.get(collectionName)) throw new Error(`Collection ${collectionName} not initialized!`);
233
+ this.queries.get(collectionName)?.delete(id);
234
+ };
235
+ insert = async (collectionName, input) => {
236
+ const storageAdapter = this.storageAdapters.get(collectionName);
237
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
238
+ const existingItems = await this.executeQuery(collectionName, { id: { $in: input.map((i) => i[0].id) } });
239
+ const result = input.map(([item]) => {
240
+ if (item.id == null) return /* @__PURE__ */ new Error("Item must have an id");
241
+ if (existingItems.some((existing) => existing.id === item.id)) return /* @__PURE__ */ new Error(`Item with id ${item.id} already exists`);
242
+ return item;
243
+ });
244
+ const newItems = result.filter((item) => !(item instanceof Error));
245
+ await storageAdapter.insert(newItems);
246
+ await this.checkQueryUpdates(collectionName, {
247
+ upserts: newItems,
248
+ deletes: []
249
+ });
250
+ return result;
251
+ };
252
+ updateOne = async (collectionName, parameters) => {
253
+ const storageAdapter = this.storageAdapters.get(collectionName);
254
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
255
+ const previousItems = [];
256
+ const result = await Promise.all(parameters.map(async ([selector, modifier]) => {
257
+ const item = await this.executeQuery(collectionName, selector, { limit: 1 }).then((items) => items[0] ?? null);
258
+ const { $setOnInsert, ...restModifier } = modifier;
259
+ if (item == null) return [];
260
+ previousItems.push(item);
261
+ const modifiedItem = modify(deepClone(item), restModifier);
262
+ if (item.id !== modifiedItem.id) {
263
+ if ((await this.executeQuery(collectionName, { id: modifiedItem.id }, { limit: 1 })).length > 0) return /* @__PURE__ */ new Error(`Item with id ${modifiedItem.id} already exists`);
264
+ }
265
+ return [modifiedItem];
266
+ }));
267
+ const modifiedItems = compact(result.filter((item) => !(item instanceof Error)).flat());
268
+ if (modifiedItems.length > 0) {
269
+ await storageAdapter.replace(modifiedItems);
270
+ await this.checkQueryUpdates(collectionName, toChangeset(previousItems, modifiedItems));
271
+ }
272
+ return result;
273
+ };
274
+ updateMany = async (collectionName, parameters) => {
275
+ const storageAdapter = this.storageAdapters.get(collectionName);
276
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
277
+ const previousItems = [];
278
+ const result = await Promise.all(parameters.map(async ([selector, modifier]) => {
279
+ const items = await this.executeQuery(collectionName, selector);
280
+ if (items.length === 0) return [];
281
+ const { $setOnInsert, ...restModifier } = modifier;
282
+ try {
283
+ return await Promise.all(items.map(async (item) => {
284
+ const modifiedItem = modify(deepClone(item), restModifier);
285
+ if (item.id !== modifiedItem.id) {
286
+ if ((await this.executeQuery(collectionName, { id: modifiedItem.id }, { limit: 1 })).length > 0) throw new Error(`Item with id ${modifiedItem.id} already exists`);
287
+ }
288
+ previousItems.push(item);
289
+ return modifiedItem;
290
+ }));
291
+ } catch (error) {
292
+ return error;
293
+ }
294
+ }));
295
+ const modifiedItems = compact(result.filter((item) => !(item instanceof Error)).flat());
296
+ if (modifiedItems.length > 0) {
297
+ await storageAdapter.replace(modifiedItems);
298
+ await this.checkQueryUpdates(collectionName, toChangeset(previousItems, modifiedItems));
299
+ }
300
+ return result;
301
+ };
302
+ replaceOne = async (collectionName, parameters) => {
303
+ const storageAdapter = this.storageAdapters.get(collectionName);
304
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
305
+ const previousItems = [];
306
+ const result = await Promise.all(parameters.map(async ([selector, replacement]) => {
307
+ const item = await this.executeQuery(collectionName, selector, { limit: 1 }).then((items) => items[0] ?? null);
308
+ if (item == null) return [];
309
+ previousItems.push(item);
310
+ const modifiedItem = {
311
+ ...replacement,
312
+ id: replacement.id ?? item.id
313
+ };
314
+ if (item.id !== modifiedItem.id) {
315
+ if ((await this.executeQuery(collectionName, { id: modifiedItem.id }, { limit: 1 })).length > 0) return /* @__PURE__ */ new Error(`Item with id ${modifiedItem.id} already exists`);
316
+ }
317
+ return [modifiedItem];
318
+ }));
319
+ const modifiedItems = compact(result.filter((item) => !(item instanceof Error)).flat());
320
+ if (modifiedItems.length > 0) {
321
+ await storageAdapter.replace(modifiedItems);
322
+ await this.checkQueryUpdates(collectionName, toChangeset(previousItems, modifiedItems));
323
+ }
324
+ return result;
325
+ };
326
+ removeOne = async (collectionName, selectors) => {
327
+ const storageAdapter = this.storageAdapters.get(collectionName);
328
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
329
+ const result = await Promise.all(selectors.map(async ([selector]) => {
330
+ const item = await this.executeQuery(collectionName, selector, { limit: 1 }).then((items) => items[0] ?? null);
331
+ if (item == null) return [];
332
+ return [item];
333
+ }));
334
+ const items = result.flat();
335
+ if (items.length > 0) {
336
+ await storageAdapter.remove(items);
337
+ await this.checkQueryUpdates(collectionName, {
338
+ upserts: [],
339
+ deletes: items.map((item) => item.id)
340
+ });
341
+ }
342
+ return result;
343
+ };
344
+ removeMany = async (collectionName, selectors) => {
345
+ const storageAdapter = this.storageAdapters.get(collectionName);
346
+ if (!storageAdapter) throw new Error(`No persistence adapter for collection ${collectionName}`);
347
+ const result = await Promise.all(selectors.map(async ([selector]) => this.executeQuery(collectionName, selector)));
348
+ const items = result.flat();
349
+ if (items.length > 0) {
350
+ await storageAdapter.remove(items);
351
+ await this.checkQueryUpdates(collectionName, {
352
+ upserts: [],
353
+ deletes: items.map((item) => item.id)
354
+ });
355
+ }
356
+ return result;
357
+ };
358
+ isReady = async (collectionName) => {
359
+ return this.storageAdapterReady.get(collectionName);
360
+ };
361
+ };
362
+ //#endregion
363
+ export { WorkerDataAdapterHost as default };