@signaldb/core 1.7.1 → 2.0.0-beta.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/dist/.vite/manifest.json +138 -82
- package/dist/AsyncDataAdapter.d.ts +64 -0
- package/dist/AutoFetchDataAdapter.d.ts +112 -0
- package/dist/Collection/Cursor.d.ts +9 -9
- package/dist/Collection/Observer.d.ts +3 -2
- package/dist/Collection/index.d.ts +54 -46
- package/dist/Collection/types.d.ts +4 -9
- package/dist/DataAdapter.d.ts +34 -0
- package/dist/DefaultDataAdapter.d.ts +33 -0
- package/dist/WorkerDataAdapter.d.ts +25 -0
- package/dist/WorkerDataAdapterHost.d.ts +62 -0
- package/dist/createIndex.d.ts +7 -0
- package/dist/createStorageAdapter.d.ts +9 -0
- package/dist/{Collection/getIndexInfo.d.ts → getIndexInfo.d.ts} +17 -19
- package/dist/index.cjs.js +21 -17
- package/dist/index.cjs10.js +15 -26
- package/dist/index.cjs11.js +13 -10
- package/dist/index.cjs12.js +348 -3
- package/dist/index.cjs13.js +396 -110
- package/dist/index.cjs14.js +178 -68
- package/dist/index.cjs15.js +384 -8
- package/dist/index.cjs16.js +572 -20
- package/dist/index.cjs17.js +12 -4
- package/dist/index.cjs18.js +24 -5
- package/dist/index.cjs2.js +29 -32
- package/dist/index.cjs20.js +5 -13
- package/dist/index.cjs21.js +99 -21
- package/dist/index.cjs22.js +108 -58
- package/dist/index.cjs23.js +5 -82
- package/dist/index.cjs24.js +23 -14
- package/dist/index.cjs25.js +8 -27
- package/dist/index.cjs26.js +27 -7
- package/dist/index.cjs27.js +44 -5
- package/dist/index.cjs28.js +6 -27
- package/dist/index.cjs29.js +7 -40
- package/dist/index.cjs3.js +198 -444
- package/dist/index.cjs30.js +5 -0
- package/dist/index.cjs31.js +7 -0
- package/dist/index.cjs32.js +29 -0
- package/dist/index.cjs33.js +42 -0
- package/dist/index.cjs4.js +3 -165
- package/dist/index.cjs5.js +3 -66
- package/dist/index.cjs6.js +27 -3
- package/dist/index.cjs7.js +10 -3
- package/dist/index.cjs8.js +3 -3
- package/dist/index.cjs9.js +131 -3
- package/dist/index.d.ts +11 -8
- package/dist/index.mjs +15 -11
- package/dist/index10.mjs +15 -26
- package/dist/index11.mjs +13 -10
- package/dist/index12.mjs +348 -3
- package/dist/index13.mjs +396 -110
- package/dist/index14.mjs +178 -67
- package/dist/index15.mjs +384 -8
- package/dist/index16.mjs +572 -20
- package/dist/index17.mjs +12 -4
- package/dist/index18.mjs +24 -5
- package/dist/index2.mjs +29 -32
- package/dist/index20.mjs +5 -13
- package/dist/index21.mjs +99 -21
- package/dist/index22.mjs +108 -58
- package/dist/index23.mjs +5 -81
- package/dist/index24.mjs +23 -14
- package/dist/index25.mjs +8 -27
- package/dist/index26.mjs +27 -7
- package/dist/index27.mjs +44 -5
- package/dist/index28.mjs +6 -27
- package/dist/index29.mjs +7 -40
- package/dist/index3.mjs +198 -445
- package/dist/index30.mjs +6 -0
- package/dist/index31.mjs +8 -0
- package/dist/index32.mjs +30 -0
- package/dist/index33.mjs +43 -0
- package/dist/index4.mjs +3 -165
- package/dist/index5.mjs +3 -65
- package/dist/index6.mjs +27 -3
- package/dist/index7.mjs +10 -3
- package/dist/index8.mjs +3 -3
- package/dist/index9.mjs +131 -3
- package/dist/types/IndexProvider.d.ts +12 -7
- package/dist/types/StorageAdapter.d.ts +20 -0
- package/dist/utils/batchOnNextTick.d.ts +16 -0
- package/dist/utils/objectId.d.ts +8 -0
- package/dist/utils/queryId.d.ts +9 -0
- package/package.json +1 -1
- package/dist/AutoFetchCollection.d.ts +0 -60
- package/dist/Collection/createIndex.d.ts +0 -15
- package/dist/ReplicatedCollection.d.ts +0 -60
- package/dist/createMemoryAdapter.d.ts +0 -7
- package/dist/persistence/combinePersistenceAdapters.d.ts +0 -32
- package/dist/persistence/createPersistenceAdapter.d.ts +0 -9
- package/dist/types/MemoryAdapter.d.ts +0 -15
- package/dist/types/PersistenceAdapter.d.ts +0 -20
package/dist/index.cjs26.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const isFieldExpression = require("./index.cjs33.js");
|
|
3
|
+
const serializeValue = require("./index.cjs11.js");
|
|
4
|
+
function getMatchingKeys(field, selector) {
|
|
5
|
+
const result = { include: null, exclude: null };
|
|
6
|
+
const fieldSelector = selector[field];
|
|
7
|
+
if (fieldSelector instanceof RegExp)
|
|
8
|
+
return result;
|
|
9
|
+
if (fieldSelector == null)
|
|
10
|
+
return result;
|
|
11
|
+
if (isFieldExpression(fieldSelector)) {
|
|
12
|
+
if (fieldSelector.$ne != null) {
|
|
13
|
+
result.exclude = [serializeValue(fieldSelector.$ne)];
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
|
|
17
|
+
result.include = fieldSelector.$in.map(serializeValue);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
|
|
21
|
+
result.exclude = fieldSelector.$nin.map(serializeValue);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
return { include: null, exclude: null };
|
|
25
|
+
}
|
|
26
|
+
result.include = [serializeValue(fieldSelector)];
|
|
27
|
+
return result;
|
|
8
28
|
}
|
|
9
|
-
module.exports =
|
|
29
|
+
module.exports = getMatchingKeys;
|
package/dist/index.cjs27.js
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
function batchOnNextTick(onFlush) {
|
|
3
|
+
const queues = /* @__PURE__ */ new Map();
|
|
4
|
+
function enqueue(key, args) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
let q = queues.get(key);
|
|
7
|
+
if (!q) {
|
|
8
|
+
q = {
|
|
9
|
+
timer: null,
|
|
10
|
+
items: [],
|
|
11
|
+
flush: () => flush(key)
|
|
12
|
+
};
|
|
13
|
+
queues.set(key, q);
|
|
14
|
+
}
|
|
15
|
+
q.items.push({ args, resolve, reject });
|
|
16
|
+
if (q.timer == null) {
|
|
17
|
+
q.timer = setTimeout(() => {
|
|
18
|
+
q.timer = null;
|
|
19
|
+
void q.flush();
|
|
20
|
+
}, 0);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function flush(key) {
|
|
25
|
+
const q = queues.get(key);
|
|
26
|
+
if (!q || q.items.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
if (q.timer != null) {
|
|
29
|
+
clearTimeout(q.timer);
|
|
30
|
+
q.timer = null;
|
|
31
|
+
}
|
|
32
|
+
const items = q.items.splice(0);
|
|
33
|
+
onFlush(key, items.map((i) => i.args)).then((results) => {
|
|
34
|
+
for (const [index, result] of results.entries()) {
|
|
35
|
+
const { resolve } = items[index];
|
|
36
|
+
resolve(result);
|
|
37
|
+
}
|
|
38
|
+
}).catch((error) => {
|
|
39
|
+
for (const { reject } of items) {
|
|
40
|
+
reject(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return { enqueue, flush };
|
|
6
45
|
}
|
|
7
|
-
module.exports =
|
|
46
|
+
module.exports = batchOnNextTick;
|
package/dist/index.cjs28.js
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function getMatchingKeys(field, selector) {
|
|
5
|
-
const result = { include: null, exclude: null };
|
|
6
|
-
const fieldSelector = selector[field];
|
|
7
|
-
if (fieldSelector instanceof RegExp)
|
|
8
|
-
return result;
|
|
9
|
-
if (fieldSelector == null)
|
|
10
|
-
return result;
|
|
11
|
-
if (isFieldExpression(fieldSelector)) {
|
|
12
|
-
if (fieldSelector.$ne != null) {
|
|
13
|
-
result.exclude = [serializeValue(fieldSelector.$ne)];
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
|
|
17
|
-
result.include = fieldSelector.$in.map(serializeValue);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
|
|
21
|
-
result.exclude = fieldSelector.$nin.map(serializeValue);
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
return { include: null, exclude: null };
|
|
25
|
-
}
|
|
26
|
-
result.include = [serializeValue(fieldSelector)];
|
|
27
|
-
return result;
|
|
2
|
+
function truthy(value) {
|
|
3
|
+
return !!value;
|
|
28
4
|
}
|
|
29
|
-
|
|
5
|
+
function compact(array) {
|
|
6
|
+
return array.filter(truthy);
|
|
7
|
+
}
|
|
8
|
+
module.exports = compact;
|
package/dist/index.cjs29.js
CHANGED
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"$in",
|
|
9
|
-
"$nin",
|
|
10
|
-
"$ne",
|
|
11
|
-
"$exists",
|
|
12
|
-
"$not",
|
|
13
|
-
"$expr",
|
|
14
|
-
"$jsonSchema",
|
|
15
|
-
"$mod",
|
|
16
|
-
"$regex",
|
|
17
|
-
"$options",
|
|
18
|
-
"$text",
|
|
19
|
-
"$where",
|
|
20
|
-
"$all",
|
|
21
|
-
"$elemMatch",
|
|
22
|
-
"$size",
|
|
23
|
-
"$bitsAllClear",
|
|
24
|
-
"$bitsAllSet",
|
|
25
|
-
"$bitsAnyClear",
|
|
26
|
-
"$bitsAnySet"
|
|
27
|
-
]);
|
|
28
|
-
function isFieldExpression(expression) {
|
|
29
|
-
if (typeof expression !== "object" || expression == null) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const keys = Object.keys(expression);
|
|
33
|
-
if (keys.length === 0) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
|
|
37
|
-
if (hasInvalidKeys)
|
|
38
|
-
return false;
|
|
39
|
-
const hasValidKeys = keys.every((key) => expressionKeys.has(key));
|
|
40
|
-
return hasValidKeys;
|
|
2
|
+
function uniqueBy(array, fn) {
|
|
3
|
+
const set = /* @__PURE__ */ new Set();
|
|
4
|
+
return array.filter((element) => {
|
|
5
|
+
const value = typeof fn === "function" ? fn(element) : element[fn];
|
|
6
|
+
return !set.has(value) && set.add(value);
|
|
7
|
+
});
|
|
41
8
|
}
|
|
42
|
-
module.exports =
|
|
9
|
+
module.exports = uniqueBy;
|