@signaldb/core 2.0.0-beta.6 → 2.0.0-beta.8
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 +118 -84
- package/dist/AsyncDataAdapter.d.ts +4 -6
- package/dist/AutoFetchDataAdapter.d.ts +4 -6
- package/dist/Collection/Cursor.d.ts +3 -3
- package/dist/Collection/index.d.ts +8 -9
- package/dist/Collection/types.d.ts +2 -2
- package/dist/DataAdapter.d.ts +3 -4
- package/dist/DefaultDataAdapter.d.ts +3 -5
- package/dist/WorkerDataAdapter.d.ts +2 -4
- package/dist/WorkerDataAdapterHost.d.ts +5 -5
- package/dist/createIndex.d.ts +2 -2
- package/dist/createIndexProvider.d.ts +2 -2
- package/dist/createReactivityAdapter.d.ts +2 -2
- package/dist/createStorageAdapter.d.ts +1 -1
- package/dist/getIndexInfo.d.ts +3 -4
- package/dist/index.cjs.js +33 -34
- package/dist/index.mjs +17 -35
- package/dist/index10.cjs.js +23 -0
- package/dist/index10.mjs +21 -17
- package/dist/index11.cjs.js +45 -0
- package/dist/index11.mjs +44 -15
- package/dist/index12.cjs.js +22 -0
- package/dist/index12.mjs +21 -47
- package/dist/index13.cjs.js +45 -0
- package/dist/index13.mjs +44 -365
- package/dist/index14.cjs.js +86 -0
- package/dist/index14.mjs +85 -416
- package/dist/index15.cjs.js +15 -0
- package/dist/index15.mjs +14 -206
- package/dist/index16.cjs.js +136 -0
- package/dist/index16.mjs +135 -388
- package/dist/index17.cjs.js +47 -0
- package/dist/index17.mjs +45 -578
- package/dist/index18.cjs.js +15 -0
- package/dist/index18.mjs +14 -157
- package/dist/index19.cjs.js +23 -0
- package/dist/index19.mjs +22 -26
- package/dist/index2.cjs.js +33 -0
- package/dist/index2.mjs +32 -258
- package/dist/index20.cjs.js +37 -0
- package/dist/index20.mjs +36 -41
- package/dist/index21.cjs.js +35 -0
- package/dist/index21.mjs +34 -16
- package/dist/index22.cjs.js +25 -0
- package/dist/index22.mjs +24 -104
- package/dist/index23.cjs.js +19 -0
- package/dist/index23.mjs +18 -128
- package/dist/index24.cjs.js +342 -0
- package/dist/index24.mjs +340 -6
- package/dist/index25.cjs.js +519 -0
- package/dist/index25.mjs +518 -27
- package/dist/index26.cjs.js +11 -0
- package/dist/index26.mjs +10 -10
- package/dist/index27.cjs.js +11 -0
- package/dist/index27.mjs +10 -29
- package/dist/index28.cjs.js +90 -0
- package/dist/index28.mjs +88 -46
- package/dist/index29.cjs.js +370 -0
- package/dist/index29.mjs +369 -8
- package/dist/index3.cjs.js +19 -0
- package/dist/index3.mjs +18 -539
- package/dist/index30.cjs.js +72 -0
- package/dist/index30.mjs +71 -9
- package/dist/index31.cjs.js +191 -0
- package/dist/index31.mjs +190 -7
- package/dist/index32.cjs.js +21 -0
- package/dist/index32.mjs +20 -42
- package/dist/index33.cjs.js +336 -0
- package/dist/index33.mjs +335 -29
- package/dist/index34.cjs.js +539 -0
- package/dist/index34.mjs +537 -4
- package/dist/index4.cjs.js +150 -0
- package/dist/index4.mjs +149 -5
- package/dist/index5.cjs.js +254 -0
- package/dist/index5.mjs +252 -4
- package/dist/index6.cjs.js +125 -0
- package/dist/index6.mjs +124 -29
- package/dist/index7.cjs.js +33 -0
- package/dist/index7.mjs +32 -12
- package/dist/index8.cjs.js +12 -0
- package/dist/index8.mjs +10 -4
- package/dist/index9.cjs.js +11 -0
- package/dist/index9.mjs +10 -133
- package/dist/types/IndexProvider.d.ts +2 -2
- package/dist/types/Modifier.d.ts +1 -1
- package/dist/types/ReactivityAdapter.d.ts +1 -1
- package/dist/utils/createSignal.d.ts +2 -2
- package/dist/utils/getMatchingKeys.d.ts +2 -2
- package/dist/utils/isFieldExpression.d.ts +1 -1
- package/dist/utils/match.d.ts +1 -1
- package/dist/utils/modify.d.ts +1 -1
- package/dist/utils/queryId.d.ts +2 -2
- package/package.json +1 -1
- package/dist/index.cjs10.js +0 -18
- package/dist/index.cjs11.js +0 -15
- package/dist/index.cjs12.js +0 -48
- package/dist/index.cjs13.js +0 -365
- package/dist/index.cjs14.js +0 -416
- package/dist/index.cjs15.js +0 -206
- package/dist/index.cjs16.js +0 -388
- package/dist/index.cjs17.js +0 -579
- package/dist/index.cjs18.js +0 -157
- package/dist/index.cjs19.js +0 -26
- package/dist/index.cjs2.js +0 -259
- package/dist/index.cjs20.js +0 -42
- package/dist/index.cjs21.js +0 -16
- package/dist/index.cjs22.js +0 -104
- package/dist/index.cjs23.js +0 -129
- package/dist/index.cjs24.js +0 -7
- package/dist/index.cjs25.js +0 -27
- package/dist/index.cjs26.js +0 -10
- package/dist/index.cjs27.js +0 -29
- package/dist/index.cjs28.js +0 -46
- package/dist/index.cjs29.js +0 -8
- package/dist/index.cjs3.js +0 -540
- package/dist/index.cjs30.js +0 -9
- package/dist/index.cjs31.js +0 -7
- package/dist/index.cjs32.js +0 -42
- package/dist/index.cjs33.js +0 -29
- package/dist/index.cjs34.js +0 -5
- package/dist/index.cjs4.js +0 -5
- package/dist/index.cjs5.js +0 -5
- package/dist/index.cjs6.js +0 -29
- package/dist/index.cjs7.js +0 -12
- package/dist/index.cjs8.js +0 -5
- package/dist/index.cjs9.js +0 -133
package/dist/index.cjs.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
2
|
+
const require_isEqual = require("./index2.cjs.js");
|
|
3
|
+
const require_Cursor = require("./index5.cjs.js");
|
|
4
|
+
const require_EventEmitter = require("./index6.cjs.js");
|
|
5
|
+
const require_randomId = require("./index8.cjs.js");
|
|
6
|
+
const require_get = require("./index10.cjs.js");
|
|
7
|
+
const require_serializeValue = require("./index12.cjs.js");
|
|
8
|
+
const require_modify = require("./index19.cjs.js");
|
|
9
|
+
const require_DefaultDataAdapter = require("./index24.cjs.js");
|
|
10
|
+
const require_index = require("./index25.cjs.js");
|
|
11
|
+
const require_createStorageAdapter = require("./index26.cjs.js");
|
|
12
|
+
const require_createReactivityAdapter = require("./index27.cjs.js");
|
|
13
|
+
const require_reactiveOrAsync = require("./index28.cjs.js");
|
|
14
|
+
const require_AsyncDataAdapter = require("./index29.cjs.js");
|
|
15
|
+
const require_WorkerDataAdapter = require("./index31.cjs.js");
|
|
16
|
+
const require_WorkerDataAdapterHost = require("./index33.cjs.js");
|
|
17
|
+
const require_AutoFetchDataAdapter = require("./index34.cjs.js");
|
|
18
|
+
exports.AsyncDataAdapter = require_AsyncDataAdapter.default;
|
|
19
|
+
exports.AutoFetchDataAdapter = require_AutoFetchDataAdapter.default;
|
|
20
|
+
exports.Collection = require_index.default;
|
|
21
|
+
exports.Cursor = require_Cursor.default;
|
|
22
|
+
exports.DefaultDataAdapter = require_DefaultDataAdapter.default;
|
|
23
|
+
exports.EventEmitter = require_EventEmitter.default;
|
|
24
|
+
exports.WorkerDataAdapter = require_WorkerDataAdapter.default;
|
|
25
|
+
exports.WorkerDataAdapterHost = require_WorkerDataAdapterHost.default;
|
|
26
|
+
exports.createReactivityAdapter = require_createReactivityAdapter.default;
|
|
27
|
+
exports.createStorageAdapter = require_createStorageAdapter.default;
|
|
28
|
+
exports.get = require_get.default;
|
|
29
|
+
exports.isEqual = require_isEqual.default;
|
|
30
|
+
exports.modify = require_modify.default;
|
|
31
|
+
exports.randomId = require_randomId.default;
|
|
32
|
+
exports.reactiveOrAsync = require_reactiveOrAsync.default;
|
|
33
|
+
exports.serializeValue = require_serializeValue.default;
|
|
34
|
+
exports.unwrap = require_reactiveOrAsync.unwrap;
|
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
export {
|
|
18
|
-
default14 as AsyncDataAdapter,
|
|
19
|
-
default17 as AutoFetchDataAdapter,
|
|
20
|
-
default3 as Collection,
|
|
21
|
-
default2 as Cursor,
|
|
22
|
-
default13 as DefaultDataAdapter,
|
|
23
|
-
default9 as EventEmitter,
|
|
24
|
-
default15 as WorkerDataAdapter,
|
|
25
|
-
default16 as WorkerDataAdapterHost,
|
|
26
|
-
default5 as createReactivityAdapter,
|
|
27
|
-
default4 as createStorageAdapter,
|
|
28
|
-
default10 as get,
|
|
29
|
-
default6 as isEqual,
|
|
30
|
-
default7 as modify,
|
|
31
|
-
default8 as randomId,
|
|
32
|
-
default12 as reactiveOrAsync,
|
|
33
|
-
default11 as serializeValue,
|
|
34
|
-
unwrap
|
|
35
|
-
};
|
|
1
|
+
import isEqual from "./index2.mjs";
|
|
2
|
+
import Cursor from "./index5.mjs";
|
|
3
|
+
import EventEmitter from "./index6.mjs";
|
|
4
|
+
import randomId from "./index8.mjs";
|
|
5
|
+
import get from "./index10.mjs";
|
|
6
|
+
import serializeValue from "./index12.mjs";
|
|
7
|
+
import modify from "./index19.mjs";
|
|
8
|
+
import DefaultDataAdapter from "./index24.mjs";
|
|
9
|
+
import Collection from "./index25.mjs";
|
|
10
|
+
import createStorageAdapter from "./index26.mjs";
|
|
11
|
+
import createReactivityAdapter from "./index27.mjs";
|
|
12
|
+
import reactiveOrAsync, { unwrap } from "./index28.mjs";
|
|
13
|
+
import AsyncDataAdapter from "./index29.mjs";
|
|
14
|
+
import WorkerDataAdapter from "./index31.mjs";
|
|
15
|
+
import WorkerDataAdapterHost from "./index33.mjs";
|
|
16
|
+
import AutoFetchDataAdapter from "./index34.mjs";
|
|
17
|
+
export { AsyncDataAdapter, AutoFetchDataAdapter, Collection, Cursor, DefaultDataAdapter, EventEmitter, WorkerDataAdapter, WorkerDataAdapterHost, createReactivityAdapter, createStorageAdapter, get, isEqual, modify, randomId, reactiveOrAsync, serializeValue, unwrap };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/utils/get.ts
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the value at a specified path within an object.
|
|
4
|
+
* Supports dot and bracket notation for navigating nested properties.
|
|
5
|
+
* @template T - The type of the object to retrieve the value from.
|
|
6
|
+
* @param value - The object to navigate.
|
|
7
|
+
* @param path - The path (dot or bracket notation) to the desired value.
|
|
8
|
+
* @returns The value at the specified path, or `undefined` if the path does not exist.
|
|
9
|
+
*/
|
|
10
|
+
function get(value, path) {
|
|
11
|
+
const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
|
|
12
|
+
if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) return;
|
|
13
|
+
const segments = normalized.split(".");
|
|
14
|
+
let current = value;
|
|
15
|
+
for (const key of segments) {
|
|
16
|
+
if (current == null) return;
|
|
17
|
+
current = current[key];
|
|
18
|
+
}
|
|
19
|
+
if (current === void 0) return;
|
|
20
|
+
return current;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.default = get;
|
package/dist/index10.mjs
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
//#region src/utils/get.ts
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the value at a specified path within an object.
|
|
4
|
+
* Supports dot and bracket notation for navigating nested properties.
|
|
5
|
+
* @template T - The type of the object to retrieve the value from.
|
|
6
|
+
* @param value - The object to navigate.
|
|
7
|
+
* @param path - The path (dot or bracket notation) to the desired value.
|
|
8
|
+
* @returns The value at the specified path, or `undefined` if the path does not exist.
|
|
9
|
+
*/
|
|
1
10
|
function get(value, path) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (current === void 0)
|
|
14
|
-
return;
|
|
15
|
-
return current;
|
|
11
|
+
const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
|
|
12
|
+
if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) return;
|
|
13
|
+
const segments = normalized.split(".");
|
|
14
|
+
let current = value;
|
|
15
|
+
for (const key of segments) {
|
|
16
|
+
if (current == null) return;
|
|
17
|
+
current = current[key];
|
|
18
|
+
}
|
|
19
|
+
if (current === void 0) return;
|
|
20
|
+
return current;
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { get as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/utils/isFieldExpression.ts
|
|
2
|
+
var expressionKeys = new Set([
|
|
3
|
+
"$eq",
|
|
4
|
+
"$gt",
|
|
5
|
+
"$gte",
|
|
6
|
+
"$lt",
|
|
7
|
+
"$lte",
|
|
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
|
+
/**
|
|
29
|
+
* Determines whether a given object is a valid field expression.
|
|
30
|
+
* A field expression is an object containing query operators supported by MongoDB-style queries.
|
|
31
|
+
* @template T - The type of the field expression.
|
|
32
|
+
* @param expression - The object to test.
|
|
33
|
+
* @returns A boolean indicating whether the object is a valid field expression.
|
|
34
|
+
* - `true` if the object contains only recognized query operators.
|
|
35
|
+
* - `false` otherwise.
|
|
36
|
+
*/
|
|
37
|
+
function isFieldExpression(expression) {
|
|
38
|
+
if (typeof expression !== "object" || expression == null) return false;
|
|
39
|
+
const keys = Object.keys(expression);
|
|
40
|
+
if (keys.length === 0) return false;
|
|
41
|
+
if (keys.some((key) => !expressionKeys.has(key))) return false;
|
|
42
|
+
return keys.every((key) => expressionKeys.has(key));
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.default = isFieldExpression;
|
package/dist/index11.mjs
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
//#region src/utils/isFieldExpression.ts
|
|
2
|
+
var expressionKeys = new Set([
|
|
3
|
+
"$eq",
|
|
4
|
+
"$gt",
|
|
5
|
+
"$gte",
|
|
6
|
+
"$lt",
|
|
7
|
+
"$lte",
|
|
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
|
+
/**
|
|
29
|
+
* Determines whether a given object is a valid field expression.
|
|
30
|
+
* A field expression is an object containing query operators supported by MongoDB-style queries.
|
|
31
|
+
* @template T - The type of the field expression.
|
|
32
|
+
* @param expression - The object to test.
|
|
33
|
+
* @returns A boolean indicating whether the object is a valid field expression.
|
|
34
|
+
* - `true` if the object contains only recognized query operators.
|
|
35
|
+
* - `false` otherwise.
|
|
36
|
+
*/
|
|
37
|
+
function isFieldExpression(expression) {
|
|
38
|
+
if (typeof expression !== "object" || expression == null) return false;
|
|
39
|
+
const keys = Object.keys(expression);
|
|
40
|
+
if (keys.length === 0) return false;
|
|
41
|
+
if (keys.some((key) => !expressionKeys.has(key))) return false;
|
|
42
|
+
return keys.every((key) => expressionKeys.has(key));
|
|
13
43
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { isFieldExpression as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils/serializeValue.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a value into a string representation.
|
|
4
|
+
* Handles various types, including strings, numbers, booleans, dates, and objects.
|
|
5
|
+
* Falls back to JSON stringification for unsupported types.
|
|
6
|
+
* @param value - The value to serialize.
|
|
7
|
+
* - Strings are returned as-is.
|
|
8
|
+
* - Numbers and booleans are converted to their string representation.
|
|
9
|
+
* - Dates are converted to ISO string format.
|
|
10
|
+
* - Other values are stringified using `JSON.stringify`.
|
|
11
|
+
* @returns A string representation of the value.
|
|
12
|
+
*/
|
|
13
|
+
function serializeValue(value) {
|
|
14
|
+
if (value == null) return null;
|
|
15
|
+
if (typeof value === "string") return value;
|
|
16
|
+
if (typeof value === "number") return value.toString();
|
|
17
|
+
if (typeof value === "boolean") return value.toString();
|
|
18
|
+
if (value instanceof Date) return value.toISOString();
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.default = serializeValue;
|
package/dist/index12.mjs
CHANGED
|
@@ -1,48 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/utils/serializeValue.ts
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a value into a string representation.
|
|
4
|
+
* Handles various types, including strings, numbers, booleans, dates, and objects.
|
|
5
|
+
* Falls back to JSON stringification for unsupported types.
|
|
6
|
+
* @param value - The value to serialize.
|
|
7
|
+
* - Strings are returned as-is.
|
|
8
|
+
* - Numbers and booleans are converted to their string representation.
|
|
9
|
+
* - Dates are converted to ISO string format.
|
|
10
|
+
* - Other values are stringified using `JSON.stringify`.
|
|
11
|
+
* @returns A string representation of the value.
|
|
12
|
+
*/
|
|
13
|
+
function serializeValue(value) {
|
|
14
|
+
if (value == null) return null;
|
|
15
|
+
if (typeof value === "string") return value;
|
|
16
|
+
if (typeof value === "number") return value.toString();
|
|
17
|
+
if (typeof value === "boolean") return value.toString();
|
|
18
|
+
if (value instanceof Date) return value.toISOString();
|
|
19
|
+
return JSON.stringify(value);
|
|
5
20
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function runReactiveOrAsync(thisArgument, mode, gen) {
|
|
10
|
-
const a = !!mode?.async;
|
|
11
|
-
const it = gen.call(thisArgument, a);
|
|
12
|
-
if (!a) {
|
|
13
|
-
let step = it.next();
|
|
14
|
-
while (!step.done) {
|
|
15
|
-
const y = step.value;
|
|
16
|
-
if (isThenable(y))
|
|
17
|
-
throw new Error("Promise yielded in sync flow");
|
|
18
|
-
step = it.next(y);
|
|
19
|
-
}
|
|
20
|
-
return step.value;
|
|
21
|
-
}
|
|
22
|
-
return (async function() {
|
|
23
|
-
let step = it.next();
|
|
24
|
-
while (!step.done) {
|
|
25
|
-
const y = step.value;
|
|
26
|
-
const v = isThenable(y) ? await y : y;
|
|
27
|
-
step = it.next(v);
|
|
28
|
-
}
|
|
29
|
-
return step.value;
|
|
30
|
-
})();
|
|
31
|
-
}
|
|
32
|
-
function reactiveOrAsync(gen) {
|
|
33
|
-
function method(...allArguments) {
|
|
34
|
-
const last = allArguments.length > 0 ? allArguments.at(-1) : void 0;
|
|
35
|
-
const hasMode = typeof last === "object" && last !== null && "async" in last;
|
|
36
|
-
const mode = hasMode ? last : void 0;
|
|
37
|
-
const parameters = hasMode ? allArguments.slice(0, -1) : allArguments;
|
|
38
|
-
return runReactiveOrAsync(this, mode, function* (a) {
|
|
39
|
-
return yield* gen.call(this, a, ...parameters);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
method.generator = gen;
|
|
43
|
-
return method;
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
reactiveOrAsync as default,
|
|
47
|
-
unwrap
|
|
48
|
-
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { serializeValue as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const require_isFieldExpression = require("./index11.cjs.js");
|
|
2
|
+
const require_serializeValue = require("./index12.cjs.js");
|
|
3
|
+
//#region src/utils/getMatchingKeys.ts
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the matching and excluded keys for a given field in a selector.
|
|
6
|
+
* Supports serialized values and `$in`/`$nin` field expressions for optimization.
|
|
7
|
+
* Returns `null` for include/exclude if the field cannot be optimized.
|
|
8
|
+
* @template T - The type of the items in the selector.
|
|
9
|
+
* @template I - The type of the unique identifier for the items.
|
|
10
|
+
* @param field - The name of the field to extract matching keys for.
|
|
11
|
+
* @param selector - The selector object containing query criteria.
|
|
12
|
+
* @returns An object containing arrays of serialized included and excluded keys,
|
|
13
|
+
* or `null` if the field cannot be optimized.
|
|
14
|
+
*/
|
|
15
|
+
function getMatchingKeys(field, selector) {
|
|
16
|
+
const result = {
|
|
17
|
+
include: null,
|
|
18
|
+
exclude: null
|
|
19
|
+
};
|
|
20
|
+
const fieldSelector = selector[field];
|
|
21
|
+
if (fieldSelector instanceof RegExp) return result;
|
|
22
|
+
if (fieldSelector == null) return result;
|
|
23
|
+
if (require_isFieldExpression.default(fieldSelector)) {
|
|
24
|
+
if (fieldSelector.$ne != null) {
|
|
25
|
+
result.exclude = [require_serializeValue.default(fieldSelector.$ne)];
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(fieldSelector.$in) && fieldSelector.$in.length > 0) {
|
|
29
|
+
result.include = fieldSelector.$in.map(require_serializeValue.default);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(fieldSelector.$nin) && fieldSelector.$nin.length > 0) {
|
|
33
|
+
result.exclude = fieldSelector.$nin.map(require_serializeValue.default);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
include: null,
|
|
38
|
+
exclude: null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
result.include = [require_serializeValue.default(fieldSelector)];
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.default = getMatchingKeys;
|