@signaldb/core 1.6.0 → 1.7.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.
- package/dist/index.cjs24.js +6 -6
- package/dist/index24.mjs +6 -6
- package/dist/types/Modifier.d.ts +17 -10
- package/dist/types/Selector.d.ts +1 -7
- package/package.json +1 -1
package/dist/index.cjs24.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
function get(value, path) {
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
|
|
4
|
+
if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const segments = normalized.split(".");
|
|
8
8
|
let current = value;
|
|
9
9
|
for (const key of segments) {
|
|
10
|
-
if (current == null
|
|
10
|
+
if (current == null)
|
|
11
11
|
return;
|
|
12
12
|
current = current[key];
|
|
13
13
|
}
|
package/dist/index24.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function get(value, path) {
|
|
2
|
-
const
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const normalized = path.replaceAll(/\[(\w+)\]/g, ".$1");
|
|
3
|
+
if (normalized.includes("..") || normalized.startsWith(".") || normalized.endsWith(".")) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const segments = normalized.split(".");
|
|
7
7
|
let current = value;
|
|
8
8
|
for (const key of segments) {
|
|
9
|
-
if (current == null
|
|
9
|
+
if (current == null)
|
|
10
10
|
return;
|
|
11
11
|
current = current[key];
|
|
12
12
|
}
|
package/dist/types/Modifier.d.ts
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
+
import type { DotNotation, GetType } from './Selector';
|
|
1
2
|
type Dictionary<T> = Record<string, T>;
|
|
2
|
-
type PartialMapTo<T, M> = Partial<Record<
|
|
3
|
+
type PartialMapTo<T, M> = Partial<Record<DotNotation<T>, M>> & Dictionary<M>;
|
|
3
4
|
type OnlyElementsOfArrays<T> = T extends any[] ? Partial<T[0]> : never;
|
|
4
5
|
type ElementsOf<T> = {
|
|
5
|
-
[P in
|
|
6
|
+
[P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>>;
|
|
6
7
|
};
|
|
7
8
|
type PushModifier<T> = {
|
|
8
|
-
[P in
|
|
9
|
-
$each?: T
|
|
9
|
+
[P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>> | {
|
|
10
|
+
$each?: GetType<T, P> | undefined;
|
|
10
11
|
$position?: number | undefined;
|
|
11
12
|
$slice?: number | undefined;
|
|
12
13
|
$sort?: 1 | -1 | Dictionary<number> | undefined;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
type ArraysOrEach<T> = {
|
|
16
|
-
[P in
|
|
17
|
-
$each: T
|
|
17
|
+
[P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>> | {
|
|
18
|
+
$each: GetType<T, P>;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
21
|
type CurrentDateModifier = {
|
|
21
22
|
$type: 'timestamp' | 'date';
|
|
22
23
|
} | true;
|
|
23
24
|
type Modifier<T extends Dictionary<any> = Dictionary<any>> = {
|
|
24
|
-
$currentDate?: (Partial<Record<
|
|
25
|
+
$currentDate?: (Partial<Record<DotNotation<T>, CurrentDateModifier>> & Dictionary<CurrentDateModifier>) | undefined;
|
|
25
26
|
$inc?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
|
|
26
27
|
$min?: (PartialMapTo<T, Date | number> & Dictionary<Date | number>) | undefined;
|
|
27
28
|
$max?: (PartialMapTo<T, Date | number> & Dictionary<Date | number>) | undefined;
|
|
28
29
|
$mul?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
|
|
29
30
|
$rename?: (PartialMapTo<T, string> & Dictionary<string>) | undefined;
|
|
30
|
-
$set?: (
|
|
31
|
-
|
|
31
|
+
$set?: ({
|
|
32
|
+
[P in DotNotation<T>]?: GetType<T, P>;
|
|
33
|
+
} & Dictionary<any>) | undefined;
|
|
34
|
+
$setOnInsert?: ({
|
|
35
|
+
[P in DotNotation<T>]?: GetType<T, P>;
|
|
36
|
+
} & Dictionary<any>) | undefined;
|
|
32
37
|
$unset?: (PartialMapTo<T, string | boolean | 1 | 0> & Dictionary<any>) | undefined;
|
|
33
38
|
$addToSet?: (ArraysOrEach<T> & Dictionary<any>) | undefined;
|
|
34
39
|
$push?: (PushModifier<T> & Dictionary<any>) | undefined;
|
|
35
40
|
$pull?: (ElementsOf<T> & Dictionary<any>) | undefined;
|
|
36
|
-
$pullAll?: (
|
|
41
|
+
$pullAll?: ({
|
|
42
|
+
[P in DotNotation<T>]?: GetType<T, P>;
|
|
43
|
+
} & Dictionary<any>) | undefined;
|
|
37
44
|
$pop?: (PartialMapTo<T, 1 | -1> & Dictionary<1 | -1>) | undefined;
|
|
38
45
|
};
|
|
39
46
|
export default Modifier;
|
package/dist/types/Selector.d.ts
CHANGED
|
@@ -14,13 +14,7 @@ export interface FieldExpression<T> {
|
|
|
14
14
|
$mod?: number[];
|
|
15
15
|
$regex?: RegExp | string;
|
|
16
16
|
$options?: string;
|
|
17
|
-
$
|
|
18
|
-
$search: string;
|
|
19
|
-
$language?: string;
|
|
20
|
-
$caseSensitive?: boolean;
|
|
21
|
-
$diacriticSensitive?: boolean;
|
|
22
|
-
};
|
|
23
|
-
$where?: string | ((item: T) => boolean);
|
|
17
|
+
$where?: string | ((this: T) => boolean);
|
|
24
18
|
$all?: T[];
|
|
25
19
|
$elemMatch?: T extends object ? Query<T> : FieldExpression<T>;
|
|
26
20
|
$size?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaldb/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && vite build",
|