@signaldb/core 1.5.4 → 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/.vite/manifest.json +29 -28
- package/dist/Collection/createIndex.d.ts +1 -1
- package/dist/Collection/index.d.ts +1 -0
- package/dist/index.cjs.js +14 -12
- package/dist/index.cjs10.js +27 -10
- package/dist/index.cjs11.js +10 -3
- package/dist/index.cjs12.js +3 -136
- package/dist/index.cjs13.js +131 -61
- package/dist/index.cjs14.js +72 -5
- package/dist/index.cjs15.js +8 -41
- package/dist/index.cjs16.js +25 -11
- package/dist/index.cjs17.js +143 -23
- package/dist/index.cjs18.js +5 -262
- package/dist/index.cjs19.js +36 -63
- package/dist/index.cjs2.js +210 -732
- package/dist/index.cjs20.js +13 -85
- package/dist/index.cjs21.js +24 -8
- package/dist/index.cjs22.js +67 -24
- package/dist/index.cjs23.js +72 -131
- package/dist/index.cjs24.js +16 -5
- package/dist/index.cjs25.js +22 -11
- package/dist/index.cjs26.js +7 -27
- package/dist/index.cjs27.js +5 -40
- package/dist/index.cjs28.js +26 -26
- package/dist/index.cjs29.js +40 -7
- package/dist/index.cjs3.js +757 -136
- package/dist/index.cjs4.js +165 -62
- package/dist/index.cjs5.js +67 -3
- package/dist/index.cjs6.js +2 -2
- package/dist/index.cjs7.js +2 -2
- package/dist/index.cjs8.js +2 -2
- package/dist/index.cjs9.js +3 -27
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +14 -12
- package/dist/index10.mjs +27 -10
- package/dist/index11.mjs +10 -3
- package/dist/index12.mjs +3 -136
- package/dist/index13.mjs +131 -60
- package/dist/index14.mjs +71 -5
- package/dist/index15.mjs +8 -40
- package/dist/index16.mjs +25 -11
- package/dist/index17.mjs +143 -23
- package/dist/index18.mjs +5 -261
- package/dist/index19.mjs +36 -63
- package/dist/index2.mjs +210 -733
- package/dist/index20.mjs +13 -84
- package/dist/index21.mjs +24 -8
- package/dist/index22.mjs +66 -24
- package/dist/index23.mjs +71 -131
- package/dist/index24.mjs +16 -5
- package/dist/index25.mjs +22 -11
- package/dist/index26.mjs +7 -27
- package/dist/index27.mjs +5 -40
- package/dist/index28.mjs +26 -26
- package/dist/index29.mjs +40 -7
- package/dist/index3.mjs +757 -136
- package/dist/index4.mjs +165 -61
- package/dist/index5.mjs +66 -3
- package/dist/index6.mjs +2 -2
- package/dist/index7.mjs +2 -2
- package/dist/index8.mjs +2 -2
- package/dist/index9.mjs +3 -27
- package/dist/types/IndexProvider.d.ts +2 -0
- package/dist/types/Modifier.d.ts +17 -10
- package/dist/types/Selector.d.ts +1 -7
- package/dist/utils/getMatchingKeys.d.ts +2 -2
- package/dist/utils/serializeValue.d.ts +1 -1
- package/package.json +1 -1
package/dist/index4.mjs
CHANGED
|
@@ -1,69 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import ReplicatedCollection from "./index23.mjs";
|
|
5
|
+
import createSignal from "./index21.mjs";
|
|
6
|
+
class AutoFetchCollection extends ReplicatedCollection {
|
|
7
|
+
/**
|
|
8
|
+
* @param options {Object} - Options for the collection.
|
|
9
|
+
* @param options.fetchQueryItems {Function} - A function that fetches items from the server. It takes the selector as an argument and returns a promise that resolves to an object with an `items` property.
|
|
10
|
+
* @param options.purgeDelay {Number} - The delay in milliseconds before purging an item from the cache.
|
|
11
|
+
*/
|
|
12
|
+
constructor(options) {
|
|
13
|
+
let triggerRemoteChange;
|
|
14
|
+
super({
|
|
15
|
+
...options,
|
|
16
|
+
pull: () => Promise.resolve({
|
|
17
|
+
items: [...this.itemsCache.values()].reduce((memo, items) => {
|
|
18
|
+
const newItems = [...memo];
|
|
19
|
+
items.forEach((item) => {
|
|
20
|
+
const index = newItems.findIndex((i) => i.id === item.id);
|
|
21
|
+
if (index === -1) {
|
|
22
|
+
newItems.push(item);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
newItems[index] = this.mergeItems(newItems[index], item);
|
|
26
|
+
});
|
|
27
|
+
return newItems;
|
|
28
|
+
}, [])
|
|
29
|
+
}),
|
|
30
|
+
registerRemoteChange: async (onChange) => {
|
|
31
|
+
triggerRemoteChange = onChange;
|
|
13
32
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
});
|
|
34
|
+
__publicField(this, "activeObservers", /* @__PURE__ */ new Map());
|
|
35
|
+
__publicField(this, "observerTimeouts", /* @__PURE__ */ new Map());
|
|
36
|
+
__publicField(this, "purgeDelay");
|
|
37
|
+
__publicField(this, "idQueryCache", /* @__PURE__ */ new Map());
|
|
38
|
+
__publicField(this, "itemsCache", /* @__PURE__ */ new Map());
|
|
39
|
+
__publicField(this, "fetchQueryItems");
|
|
40
|
+
__publicField(this, "triggerReload", null);
|
|
41
|
+
__publicField(this, "reactivityAdapter", null);
|
|
42
|
+
__publicField(this, "loadingSignals", /* @__PURE__ */ new Map());
|
|
43
|
+
__publicField(this, "isFetchingSignal");
|
|
44
|
+
__publicField(this, "mergeItems");
|
|
45
|
+
this.mergeItems = options.mergeItems ?? ((itemA, itemB) => ({ ...itemA, ...itemB }));
|
|
46
|
+
this.purgeDelay = options.purgeDelay ?? 1e4;
|
|
47
|
+
this.isFetchingSignal = createSignal(options.reactivity, false);
|
|
48
|
+
if (!triggerRemoteChange)
|
|
49
|
+
throw new Error("No triggerRemoteChange method found. Looks like your persistence adapter was not registered");
|
|
50
|
+
this.triggerReload = triggerRemoteChange;
|
|
51
|
+
this.reactivityAdapter = options.reactivity ?? null;
|
|
52
|
+
this.fetchQueryItems = options.fetchQueryItems;
|
|
53
|
+
this.on("observer.created", (selector) => this.handleObserverCreation(selector ?? {}));
|
|
54
|
+
this.on("observer.disposed", (selector) => setTimeout(() => this.handleObserverDisposal(selector ?? {}), 100));
|
|
55
|
+
if (options.registerRemoteChange) {
|
|
56
|
+
void options.registerRemoteChange(() => this.forceRefetch());
|
|
30
57
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Registers a query manually that items should be fetched for it
|
|
61
|
+
* @param selector {Object} Selector of the query
|
|
62
|
+
*/
|
|
63
|
+
registerQuery(selector) {
|
|
64
|
+
this.handleObserverCreation(selector);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Unregisters a query manually that items are not fetched anymore for it
|
|
68
|
+
* @param selector {Object} Selector of the query
|
|
69
|
+
*/
|
|
70
|
+
unregisterQuery(selector) {
|
|
71
|
+
this.handleObserverDisposal(selector);
|
|
72
|
+
}
|
|
73
|
+
getKeyForSelector(selector) {
|
|
74
|
+
return JSON.stringify(selector);
|
|
75
|
+
}
|
|
76
|
+
async forceRefetch() {
|
|
77
|
+
return Promise.all([...this.activeObservers.values()].map(({ selector }) => this.fetchSelector(selector))).then(() => {
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
fetchSelector(selector) {
|
|
81
|
+
this.isFetchingSignal.set(true);
|
|
82
|
+
return this.fetchQueryItems(selector).then((response) => {
|
|
83
|
+
if (!response.items)
|
|
84
|
+
throw new Error("AutoFetchCollection currently only works with a full item response");
|
|
85
|
+
this.itemsCache.set(this.getKeyForSelector(selector), response.items);
|
|
86
|
+
response.items.forEach((item) => {
|
|
87
|
+
const queries = this.idQueryCache.get(item.id) ?? [];
|
|
88
|
+
queries.push(selector);
|
|
89
|
+
this.idQueryCache.set(item.id, queries);
|
|
90
|
+
});
|
|
91
|
+
this.setLoading(selector, true);
|
|
92
|
+
this.once("persistence.received", () => {
|
|
93
|
+
this.setLoading(selector, false);
|
|
46
94
|
});
|
|
95
|
+
if (!this.triggerReload)
|
|
96
|
+
throw new Error("No triggerReload method found. Looks like your persistence adapter was not registered");
|
|
97
|
+
void this.triggerReload();
|
|
98
|
+
}).catch((error) => {
|
|
99
|
+
this.emit("persistence.error", error);
|
|
100
|
+
}).finally(() => {
|
|
101
|
+
this.isFetchingSignal.set(false);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
handleObserverCreation(selector) {
|
|
105
|
+
var _a;
|
|
106
|
+
const activeObservers = ((_a = this.activeObservers.get(this.getKeyForSelector(selector))) == null ? void 0 : _a.count) ?? 0;
|
|
107
|
+
this.activeObservers.set(this.getKeyForSelector(selector), {
|
|
108
|
+
selector,
|
|
109
|
+
count: activeObservers + 1
|
|
110
|
+
});
|
|
111
|
+
const timeout = this.observerTimeouts.get(this.getKeyForSelector(selector));
|
|
112
|
+
if (timeout)
|
|
113
|
+
clearTimeout(timeout);
|
|
114
|
+
if (activeObservers === 0)
|
|
115
|
+
void this.fetchSelector(selector);
|
|
116
|
+
}
|
|
117
|
+
handleObserverDisposal(selector) {
|
|
118
|
+
var _a;
|
|
119
|
+
const currentObservers = ((_a = this.activeObservers.get(this.getKeyForSelector(selector))) == null ? void 0 : _a.count) ?? 0;
|
|
120
|
+
const activeObservers = currentObservers - 1;
|
|
121
|
+
if (activeObservers > 0) {
|
|
122
|
+
this.activeObservers.set(this.getKeyForSelector(selector), {
|
|
123
|
+
selector,
|
|
124
|
+
count: activeObservers
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const timeout = this.observerTimeouts.get(this.getKeyForSelector(selector));
|
|
129
|
+
if (timeout)
|
|
130
|
+
clearTimeout(timeout);
|
|
131
|
+
const removeObserver = () => {
|
|
132
|
+
this.activeObservers.delete(this.getKeyForSelector(selector));
|
|
133
|
+
this.itemsCache.delete(this.getKeyForSelector(selector));
|
|
134
|
+
if (!this.triggerReload)
|
|
135
|
+
throw new Error("No triggerReload method found. Looks like your persistence adapter was not registered");
|
|
136
|
+
void this.triggerReload();
|
|
137
|
+
};
|
|
138
|
+
if (this.purgeDelay === 0) {
|
|
139
|
+
removeObserver();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.observerTimeouts.set(this.getKeyForSelector(selector), setTimeout(removeObserver, this.purgeDelay));
|
|
143
|
+
}
|
|
144
|
+
ensureSignal(selector) {
|
|
145
|
+
if (!this.reactivityAdapter)
|
|
146
|
+
throw new Error("No reactivity adapter found");
|
|
147
|
+
if (!this.loadingSignals.has(this.getKeyForSelector(selector))) {
|
|
148
|
+
this.loadingSignals.set(this.getKeyForSelector(selector), createSignal(this.reactivityAdapter, false));
|
|
47
149
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
150
|
+
return this.loadingSignals.get(this.getKeyForSelector(selector));
|
|
151
|
+
}
|
|
152
|
+
setLoading(selector, value) {
|
|
153
|
+
const signal = this.ensureSignal(selector);
|
|
154
|
+
signal.set(value);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Indicates wether a query is currently been loaded
|
|
158
|
+
* ⚡️ this function is reactive!
|
|
159
|
+
* @param selector {Object} Selector of the query
|
|
160
|
+
* @returns The loading state
|
|
161
|
+
*/
|
|
162
|
+
isLoading(selector) {
|
|
163
|
+
const isPushing = this.isPushing();
|
|
164
|
+
if (!selector) {
|
|
165
|
+
return this.isFetchingSignal.get() || isPushing;
|
|
63
166
|
}
|
|
64
|
-
|
|
167
|
+
const signal = this.ensureSignal(selector);
|
|
168
|
+
return signal.get() || isPushing;
|
|
169
|
+
}
|
|
65
170
|
}
|
|
66
171
|
export {
|
|
67
|
-
|
|
68
|
-
combinePersistenceAdapters as default
|
|
172
|
+
AutoFetchCollection as default
|
|
69
173
|
};
|
package/dist/index5.mjs
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import createPersistenceAdapter from "./index8.mjs";
|
|
2
|
+
function createTemporaryFallbackExecutor(firstResolvingPromiseFunction, secondResolvingPromiseFunction, options) {
|
|
3
|
+
const cacheTimeout = options == null ? void 0 : options.cacheTimeout;
|
|
4
|
+
let isResolved = false;
|
|
5
|
+
let resolvedValue = null;
|
|
6
|
+
let timeout = null;
|
|
7
|
+
let secondaryPromise = null;
|
|
8
|
+
return (...args) => {
|
|
9
|
+
if (secondaryPromise == null) {
|
|
10
|
+
if (timeout) {
|
|
11
|
+
clearTimeout(timeout);
|
|
12
|
+
timeout = null;
|
|
13
|
+
}
|
|
14
|
+
secondaryPromise = secondResolvingPromiseFunction(...args).then((result) => {
|
|
15
|
+
{
|
|
16
|
+
timeout = setTimeout(() => {
|
|
17
|
+
isResolved = false;
|
|
18
|
+
resolvedValue = null;
|
|
19
|
+
secondaryPromise = null;
|
|
20
|
+
}, cacheTimeout);
|
|
21
|
+
}
|
|
22
|
+
isResolved = true;
|
|
23
|
+
resolvedValue = result;
|
|
24
|
+
if (options == null ? void 0 : options.onResolve)
|
|
25
|
+
options.onResolve(resolvedValue);
|
|
26
|
+
return result;
|
|
27
|
+
});
|
|
28
|
+
} else if (isResolved) {
|
|
29
|
+
return secondaryPromise;
|
|
30
|
+
}
|
|
31
|
+
return firstResolvingPromiseFunction(...args);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function combinePersistenceAdapters(slowAdapter, fastAdapter) {
|
|
35
|
+
let handleChange = null;
|
|
36
|
+
const readExecutor = createTemporaryFallbackExecutor(() => fastAdapter.load(), () => slowAdapter.load(), {
|
|
37
|
+
cacheTimeout: 100,
|
|
38
|
+
onResolve: (result) => {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
if (handleChange)
|
|
41
|
+
void handleChange();
|
|
42
|
+
void fastAdapter.save(result.items || [], {
|
|
43
|
+
added: ((_a = result.changes) == null ? void 0 : _a.added) || [],
|
|
44
|
+
modified: ((_b = result.changes) == null ? void 0 : _b.modified) || [],
|
|
45
|
+
removed: ((_c = result.changes) == null ? void 0 : _c.removed) || []
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return createPersistenceAdapter({
|
|
50
|
+
async register(onChange) {
|
|
51
|
+
handleChange = onChange;
|
|
52
|
+
await Promise.all([slowAdapter.register(onChange), fastAdapter.register(onChange)]);
|
|
53
|
+
},
|
|
54
|
+
async load() {
|
|
55
|
+
const promise = readExecutor();
|
|
56
|
+
return promise;
|
|
57
|
+
},
|
|
58
|
+
async save(items, changes) {
|
|
59
|
+
await Promise.all([
|
|
60
|
+
fastAdapter.save(items, changes),
|
|
61
|
+
slowAdapter.save(items, changes)
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
3
65
|
}
|
|
4
66
|
export {
|
|
5
|
-
|
|
67
|
+
createTemporaryFallbackExecutor,
|
|
68
|
+
combinePersistenceAdapters as default
|
|
6
69
|
};
|
package/dist/index6.mjs
CHANGED
package/dist/index7.mjs
CHANGED
package/dist/index8.mjs
CHANGED
package/dist/index9.mjs
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
return true;
|
|
4
|
-
if (a instanceof RegExp && b instanceof RegExp)
|
|
5
|
-
return a.toString() === b.toString();
|
|
6
|
-
if (a instanceof Date && b instanceof Date)
|
|
7
|
-
return a.getTime() === b.getTime();
|
|
8
|
-
if (typeof a !== "object")
|
|
9
|
-
return false;
|
|
10
|
-
if (typeof b !== "object")
|
|
11
|
-
return false;
|
|
12
|
-
if (a === null)
|
|
13
|
-
return false;
|
|
14
|
-
if (b === null)
|
|
15
|
-
return false;
|
|
16
|
-
const aKeys = Object.keys(a);
|
|
17
|
-
const bKeys = Object.keys(b);
|
|
18
|
-
if (aKeys.length !== bKeys.length)
|
|
19
|
-
return false;
|
|
20
|
-
for (const key of aKeys) {
|
|
21
|
-
if (!bKeys.includes(key))
|
|
22
|
-
return false;
|
|
23
|
-
if (!isEqual(a[key], b[key]))
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
1
|
+
function createReactivityAdapter(definition) {
|
|
2
|
+
return definition;
|
|
27
3
|
}
|
|
28
4
|
export {
|
|
29
|
-
|
|
5
|
+
createReactivityAdapter as default
|
|
30
6
|
};
|
|
@@ -3,10 +3,12 @@ import type { FlatSelector } from './Selector';
|
|
|
3
3
|
type IndexResult = {
|
|
4
4
|
positions: number[];
|
|
5
5
|
fields: string[];
|
|
6
|
+
keepSelector?: boolean;
|
|
6
7
|
matched: true;
|
|
7
8
|
} | {
|
|
8
9
|
positions?: never;
|
|
9
10
|
fields?: never;
|
|
11
|
+
keepSelector?: never;
|
|
10
12
|
matched: false;
|
|
11
13
|
};
|
|
12
14
|
interface IndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
|
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseItem } from '../Collection/types';
|
|
2
2
|
import type { FlatSelector } from '../types/Selector';
|
|
3
3
|
type KeyResult = {
|
|
4
|
-
include: string[] | null;
|
|
5
|
-
exclude: string[] | null;
|
|
4
|
+
include: (string | null)[] | null;
|
|
5
|
+
exclude: (string | null)[] | null;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Extracts the matching and excluded keys for a given field in a selector.
|
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",
|