@signaldb/core 2.0.0-beta.13 → 2.0.0-beta.15
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 +72 -46
- package/dist/AsyncDataAdapter.d.ts +11 -2
- package/dist/Collection/Cursor.d.ts +11 -1
- package/dist/Collection/Observer.d.ts +31 -0
- package/dist/Collection/index.d.ts +40 -0
- package/dist/DataAdapter.d.ts +15 -2
- package/dist/WorkerDataAdapter.d.ts +25 -2
- package/dist/WorkerDataAdapterHost.d.ts +2 -0
- package/dist/index.cjs.js +15 -15
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +15 -15
- package/dist/index10.cjs.js +7 -19
- package/dist/index10.mjs +7 -19
- package/dist/index11.cjs.js +19 -41
- package/dist/index11.mjs +19 -41
- package/dist/index12.cjs.js +41 -18
- package/dist/index12.mjs +41 -18
- package/dist/index13.cjs.js +18 -41
- package/dist/index13.mjs +18 -41
- package/dist/index14.cjs.js +39 -80
- package/dist/index14.mjs +39 -80
- package/dist/index15.cjs.js +82 -11
- package/dist/index15.mjs +82 -11
- package/dist/index16.cjs.js +11 -132
- package/dist/index16.mjs +11 -132
- package/dist/index17.cjs.js +127 -38
- package/dist/index17.mjs +127 -38
- package/dist/index18.cjs.js +43 -11
- package/dist/index18.mjs +43 -11
- package/dist/index19.cjs.js +10 -18
- package/dist/index19.mjs +11 -19
- package/dist/index20.cjs.js +19 -33
- package/dist/index20.mjs +19 -33
- package/dist/index21.cjs.js +33 -31
- package/dist/index21.mjs +33 -31
- package/dist/index22.cjs.js +31 -21
- package/dist/index22.mjs +31 -21
- package/dist/index23.cjs.js +16 -14
- package/dist/index23.mjs +16 -14
- package/dist/index24.cjs.js +15 -338
- package/dist/index24.mjs +15 -338
- package/dist/index25.cjs.js +122 -554
- package/dist/index25.mjs +121 -554
- package/dist/index26.cjs.js +34 -7
- package/dist/index26.mjs +34 -7
- package/dist/index27.cjs.js +339 -7
- package/dist/index27.mjs +339 -7
- package/dist/index28.cjs.js +595 -83
- package/dist/index28.mjs +595 -82
- package/dist/index29.cjs.js +8 -422
- package/dist/index29.mjs +8 -422
- package/dist/index30.cjs.js +7 -68
- package/dist/index30.mjs +7 -68
- package/dist/index31.cjs.js +86 -28
- package/dist/index31.mjs +85 -28
- package/dist/index32.cjs.js +446 -278
- package/dist/index32.mjs +446 -278
- package/dist/index33.cjs.js +68 -17
- package/dist/index33.mjs +68 -17
- package/dist/index34.cjs.js +460 -304
- package/dist/index34.mjs +460 -304
- package/dist/index35.cjs.js +14 -532
- package/dist/index35.mjs +14 -532
- package/dist/index36.cjs.js +389 -0
- package/dist/index36.mjs +389 -0
- package/dist/index37.cjs.js +539 -0
- package/dist/index37.mjs +539 -0
- package/dist/index4.cjs.js +199 -140
- package/dist/index4.mjs +195 -140
- package/dist/index5.cjs.js +152 -253
- package/dist/index5.mjs +152 -253
- package/dist/index6.cjs.js +267 -89
- package/dist/index6.mjs +267 -89
- package/dist/index7.cjs.js +121 -29
- package/dist/index7.mjs +121 -29
- package/dist/index8.cjs.js +29 -8
- package/dist/index8.mjs +29 -8
- package/dist/index9.cjs.js +8 -7
- package/dist/index9.mjs +8 -7
- package/dist/utils/incrementalQueryUpdate.d.ts +60 -0
- package/dist/utils/projectItems.d.ts +12 -0
- package/dist/utils/queryDelta.d.ts +83 -0
- package/package.json +1 -1
package/dist/index20.mjs
CHANGED
|
@@ -1,37 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import deepClone from "./index18.mjs";
|
|
2
|
+
import { update } from "mingo";
|
|
3
|
+
//#region src/utils/modify.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
5
|
+
* Applies a modifier to an object and returns a new modified object.
|
|
6
|
+
* @template T - The type of the object to be modified.
|
|
7
|
+
* @param item - The object to be modified.
|
|
8
|
+
* @param modifier - The modifier to apply. This can be any transformation logic.
|
|
9
|
+
* @returns - Returns a new object with the modifications applied.
|
|
10
|
+
* @example
|
|
11
|
+
* const item = { a: 1, b: 2 }
|
|
12
|
+
* const modifier = { $set: { b: 3, c: 4 } }
|
|
13
|
+
* const result = modify(item, modifier)
|
|
14
|
+
* // result: { a: 1, b: 3, c: 4 }
|
|
13
15
|
*/
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const apply = (node) => {
|
|
20
|
-
if (segments.length > 1) {
|
|
21
|
-
const key = segments.shift();
|
|
22
|
-
const nextIsNumber = !Number.isNaN(Number.parseInt(segments[0], 10));
|
|
23
|
-
if (node[key] === void 0) node[key] = nextIsNumber ? [] : {};
|
|
24
|
-
apply(node[key]);
|
|
25
|
-
} else {
|
|
26
|
-
if (deleteIfUndefined && value === void 0) {
|
|
27
|
-
delete node[segments[0]];
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
node[segments[0]] = value;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
apply(object);
|
|
34
|
-
return object;
|
|
16
|
+
function modify(item, modifier) {
|
|
17
|
+
if (!Object.keys(modifier).some((key) => key.startsWith("$"))) return modifier;
|
|
18
|
+
const clonedItem = deepClone(item);
|
|
19
|
+
update(clonedItem, modifier);
|
|
20
|
+
return clonedItem;
|
|
35
21
|
}
|
|
36
22
|
//#endregion
|
|
37
|
-
export {
|
|
23
|
+
export { modify as default };
|
package/dist/index21.cjs.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
const require_set = require("./index20.cjs.js");
|
|
3
|
-
//#region src/utils/project.ts
|
|
1
|
+
//#region src/utils/set.ts
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @template T - The type of the object
|
|
9
|
-
* @
|
|
10
|
-
* @param
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
*
|
|
3
|
+
* Sets a value at a specified path within an object. Creates nested structures
|
|
4
|
+
* (arrays or objects) as needed to set the value at the correct location. Supports
|
|
5
|
+
* deleting the key if the value is `undefined` and the `deleteIfUndefined` flag is set to `true`.
|
|
6
|
+
* @template T - The type of the object to modify.
|
|
7
|
+
* @template K - The type of the value to set.
|
|
8
|
+
* @param object - The object to modify. The object is mutated directly.
|
|
9
|
+
* @param path - The path (dot or bracket notation) where the value should be set.
|
|
10
|
+
* @param value - The value to set at the specified path.
|
|
11
|
+
* @param deleteIfUndefined - A boolean indicating whether to delete the key if the value is `undefined` (default: `false`).
|
|
12
|
+
* @returns The modified object.
|
|
15
13
|
*/
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
function set(object, path, value, deleteIfUndefined = false) {
|
|
15
|
+
if (object == null) return object;
|
|
16
|
+
const segments = path.split(/[.[\]]/g);
|
|
17
|
+
if (segments[0] === "") segments.shift();
|
|
18
|
+
if (segments.at(-1) === "") segments.pop();
|
|
19
|
+
const apply = (node) => {
|
|
20
|
+
if (segments.length > 1) {
|
|
21
|
+
const key = segments.shift();
|
|
22
|
+
const nextIsNumber = !Number.isNaN(Number.parseInt(segments[0], 10));
|
|
23
|
+
if (node[key] === void 0) node[key] = nextIsNumber ? [] : {};
|
|
24
|
+
apply(node[key]);
|
|
25
|
+
} else {
|
|
26
|
+
if (deleteIfUndefined && value === void 0) {
|
|
27
|
+
delete node[segments[0]];
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
node[segments[0]] = value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
apply(object);
|
|
34
|
+
return object;
|
|
33
35
|
}
|
|
34
36
|
//#endregion
|
|
35
|
-
exports.default =
|
|
37
|
+
exports.default = set;
|
package/dist/index21.mjs
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import set from "./index20.mjs";
|
|
3
|
-
//#region src/utils/project.ts
|
|
1
|
+
//#region src/utils/set.ts
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @template T - The type of the object
|
|
9
|
-
* @
|
|
10
|
-
* @param
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
*
|
|
3
|
+
* Sets a value at a specified path within an object. Creates nested structures
|
|
4
|
+
* (arrays or objects) as needed to set the value at the correct location. Supports
|
|
5
|
+
* deleting the key if the value is `undefined` and the `deleteIfUndefined` flag is set to `true`.
|
|
6
|
+
* @template T - The type of the object to modify.
|
|
7
|
+
* @template K - The type of the value to set.
|
|
8
|
+
* @param object - The object to modify. The object is mutated directly.
|
|
9
|
+
* @param path - The path (dot or bracket notation) where the value should be set.
|
|
10
|
+
* @param value - The value to set at the specified path.
|
|
11
|
+
* @param deleteIfUndefined - A boolean indicating whether to delete the key if the value is `undefined` (default: `false`).
|
|
12
|
+
* @returns The modified object.
|
|
15
13
|
*/
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
function set(object, path, value, deleteIfUndefined = false) {
|
|
15
|
+
if (object == null) return object;
|
|
16
|
+
const segments = path.split(/[.[\]]/g);
|
|
17
|
+
if (segments[0] === "") segments.shift();
|
|
18
|
+
if (segments.at(-1) === "") segments.pop();
|
|
19
|
+
const apply = (node) => {
|
|
20
|
+
if (segments.length > 1) {
|
|
21
|
+
const key = segments.shift();
|
|
22
|
+
const nextIsNumber = !Number.isNaN(Number.parseInt(segments[0], 10));
|
|
23
|
+
if (node[key] === void 0) node[key] = nextIsNumber ? [] : {};
|
|
24
|
+
apply(node[key]);
|
|
25
|
+
} else {
|
|
26
|
+
if (deleteIfUndefined && value === void 0) {
|
|
27
|
+
delete node[segments[0]];
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
node[segments[0]] = value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
apply(object);
|
|
34
|
+
return object;
|
|
33
35
|
}
|
|
34
36
|
//#endregion
|
|
35
|
-
export {
|
|
37
|
+
export { set as default };
|
package/dist/index22.cjs.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
const require_get = require("./index11.cjs.js");
|
|
2
|
+
const require_set = require("./index21.cjs.js");
|
|
3
|
+
//#region src/utils/project.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
5
|
+
* Projects the fields of an object based on a specified fields configuration.
|
|
6
|
+
* Supports inclusion (`1`) and exclusion (`0`) of specific fields. Creates a new object
|
|
7
|
+
* with the desired fields included or excluded, based on the configuration.
|
|
8
|
+
* @template T - The type of the object being projected.
|
|
9
|
+
* @param item - The original object to project fields from.
|
|
10
|
+
* @param fields - An object defining the fields to include (`1`) or exclude (`0`).
|
|
11
|
+
* - Keys are the field names, and values are either `1` (include) or `0` (exclude).
|
|
12
|
+
* @returns A new object with the specified fields included or excluded.
|
|
13
|
+
* - If all fields are set to `0`, the excluded fields are removed from the result.
|
|
14
|
+
* - If fields are set to `1`, only the included fields are retained.
|
|
8
15
|
*/
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
function project(item, fields) {
|
|
17
|
+
if (Object.values(fields).every((value) => value === 0)) {
|
|
18
|
+
const result = { ...item };
|
|
19
|
+
Object.keys(fields).forEach((key) => {
|
|
20
|
+
if (require_get.default(item, key) === void 0) return;
|
|
21
|
+
require_set.default(result, key, void 0, true);
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const result = {};
|
|
26
|
+
Object.entries(fields).forEach(([key, value]) => {
|
|
27
|
+
const fieldValue = require_get.default(item, key);
|
|
28
|
+
if (fieldValue === void 0) return;
|
|
29
|
+
if (fieldValue == null && value !== 1) return;
|
|
30
|
+
require_set.default(result, key, value === 1 ? fieldValue : void 0);
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
23
33
|
}
|
|
24
34
|
//#endregion
|
|
25
|
-
exports.default =
|
|
35
|
+
exports.default = project;
|
package/dist/index22.mjs
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import get from "./index11.mjs";
|
|
2
|
+
import set from "./index21.mjs";
|
|
3
|
+
//#region src/utils/project.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
5
|
+
* Projects the fields of an object based on a specified fields configuration.
|
|
6
|
+
* Supports inclusion (`1`) and exclusion (`0`) of specific fields. Creates a new object
|
|
7
|
+
* with the desired fields included or excluded, based on the configuration.
|
|
8
|
+
* @template T - The type of the object being projected.
|
|
9
|
+
* @param item - The original object to project fields from.
|
|
10
|
+
* @param fields - An object defining the fields to include (`1`) or exclude (`0`).
|
|
11
|
+
* - Keys are the field names, and values are either `1` (include) or `0` (exclude).
|
|
12
|
+
* @returns A new object with the specified fields included or excluded.
|
|
13
|
+
* - If all fields are set to `0`, the excluded fields are removed from the result.
|
|
14
|
+
* - If fields are set to `1`, only the included fields are retained.
|
|
8
15
|
*/
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
function project(item, fields) {
|
|
17
|
+
if (Object.values(fields).every((value) => value === 0)) {
|
|
18
|
+
const result = { ...item };
|
|
19
|
+
Object.keys(fields).forEach((key) => {
|
|
20
|
+
if (get(item, key) === void 0) return;
|
|
21
|
+
set(result, key, void 0, true);
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const result = {};
|
|
26
|
+
Object.entries(fields).forEach(([key, value]) => {
|
|
27
|
+
const fieldValue = get(item, key);
|
|
28
|
+
if (fieldValue === void 0) return;
|
|
29
|
+
if (fieldValue == null && value !== 1) return;
|
|
30
|
+
set(result, key, value === 1 ? fieldValue : void 0);
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
23
33
|
}
|
|
24
34
|
//#endregion
|
|
25
|
-
export {
|
|
35
|
+
export { project as default };
|
package/dist/index23.cjs.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
//#region src/utils/sortItems.ts
|
|
1
|
+
const require_project = require("./index22.cjs.js");
|
|
2
|
+
//#region src/utils/projectItems.ts
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
* @param
|
|
10
|
-
*
|
|
11
|
-
* @returns
|
|
4
|
+
* Applies a query's field projection to a list of items, keeping the primary key unless the
|
|
5
|
+
* projection excludes it outright. Returns the items untouched when there is no projection, so a
|
|
6
|
+
* caller does not have to check for one first.
|
|
7
|
+
* @template T - The type of the items.
|
|
8
|
+
* @param items - The items to project.
|
|
9
|
+
* @param fields - The projection, or `undefined` for none.
|
|
10
|
+
* @returns The projected items.
|
|
12
11
|
*/
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function projectItems(items, fields) {
|
|
13
|
+
if (!fields) return items;
|
|
14
|
+
const idExcluded = fields.id === 0;
|
|
15
|
+
return items.map((item) => ({
|
|
16
|
+
...idExcluded ? {} : { id: item.id },
|
|
17
|
+
...require_project.default(item, fields)
|
|
16
18
|
}));
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
19
|
-
exports.default =
|
|
21
|
+
exports.default = projectItems;
|
package/dist/index23.mjs
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/utils/sortItems.ts
|
|
1
|
+
import project from "./index22.mjs";
|
|
2
|
+
//#region src/utils/projectItems.ts
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
* @param
|
|
10
|
-
*
|
|
11
|
-
* @returns
|
|
4
|
+
* Applies a query's field projection to a list of items, keeping the primary key unless the
|
|
5
|
+
* projection excludes it outright. Returns the items untouched when there is no projection, so a
|
|
6
|
+
* caller does not have to check for one first.
|
|
7
|
+
* @template T - The type of the items.
|
|
8
|
+
* @param items - The items to project.
|
|
9
|
+
* @param fields - The projection, or `undefined` for none.
|
|
10
|
+
* @returns The projected items.
|
|
12
11
|
*/
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function projectItems(items, fields) {
|
|
13
|
+
if (!fields) return items;
|
|
14
|
+
const idExcluded = fields.id === 0;
|
|
15
|
+
return items.map((item) => ({
|
|
16
|
+
...idExcluded ? {} : { id: item.id },
|
|
17
|
+
...project(item, fields)
|
|
16
18
|
}));
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
19
|
-
export {
|
|
21
|
+
export { projectItems as default };
|