@signaldb/core 1.7.2 → 1.8.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 +88 -59
- package/dist/AutoFetchCollection.d.ts +3 -3
- package/dist/Collection/Cursor.d.ts +10 -7
- package/dist/Collection/index.d.ts +27 -11
- package/dist/Collection/types.d.ts +1 -0
- package/dist/ReplicatedCollection.d.ts +4 -4
- package/dist/index.cjs.js +26 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +14 -28
- package/dist/index10.cjs.js +265 -0
- package/dist/index10.mjs +263 -28
- package/dist/index11.cjs.js +125 -0
- package/dist/index11.mjs +124 -12
- package/dist/index12.cjs.js +15 -0
- package/dist/index12.mjs +14 -5
- package/dist/index13.cjs.js +23 -0
- package/dist/index13.mjs +22 -133
- package/dist/index14.cjs.js +12 -0
- package/dist/index14.mjs +11 -73
- package/dist/index15.cjs.js +22 -0
- package/dist/index15.mjs +21 -10
- package/dist/index16.cjs.js +33 -0
- package/dist/index16.mjs +32 -27
- package/dist/index17.cjs.js +15 -0
- package/dist/index17.mjs +14 -142
- package/dist/index18.cjs.js +98 -0
- package/dist/index18.mjs +97 -7
- package/dist/index19.cjs.js +11 -0
- package/dist/index19.mjs +10 -41
- package/dist/index2.cjs.js +23 -0
- package/dist/index2.mjs +22 -260
- package/dist/index20.cjs.js +45 -0
- package/dist/index20.mjs +44 -15
- package/dist/index21.cjs.js +45 -0
- package/dist/index21.mjs +44 -26
- package/dist/index22.cjs.js +69 -0
- package/dist/index22.mjs +66 -77
- package/dist/index23.cjs.js +778 -0
- package/dist/index23.mjs +775 -81
- package/dist/index24.cjs.js +11 -0
- package/dist/index24.mjs +10 -18
- package/dist/index25.cjs.js +81 -0
- package/dist/index25.mjs +80 -29
- package/dist/index26.cjs.js +98 -0
- package/dist/index26.mjs +96 -8
- package/dist/index27.cjs.js +154 -0
- package/dist/index27.mjs +153 -7
- package/dist/index28.cjs.js +11 -0
- package/dist/index28.mjs +10 -29
- package/dist/index29.cjs.js +11 -0
- package/dist/index29.mjs +10 -42
- package/dist/index3.cjs.js +19 -0
- package/dist/index3.mjs +18 -788
- package/dist/index4.cjs.js +37 -0
- package/dist/index4.mjs +36 -167
- package/dist/index5.cjs.js +35 -0
- package/dist/index5.mjs +34 -67
- package/dist/index6.cjs.js +47 -0
- package/dist/index6.mjs +46 -5
- package/dist/index7.cjs.js +33 -0
- package/dist/index7.mjs +32 -5
- package/dist/index8.cjs.js +19 -0
- package/dist/index8.mjs +18 -5
- package/dist/index9.cjs.js +139 -0
- package/dist/index9.mjs +138 -5
- package/dist/utils/deepClone.d.ts +1 -1
- package/package.json +3 -3
- package/dist/index.cjs10.js +0 -29
- package/dist/index.cjs11.js +0 -12
- package/dist/index.cjs12.js +0 -5
- package/dist/index.cjs13.js +0 -133
- package/dist/index.cjs14.js +0 -74
- package/dist/index.cjs15.js +0 -10
- package/dist/index.cjs16.js +0 -27
- package/dist/index.cjs17.js +0 -142
- package/dist/index.cjs18.js +0 -7
- package/dist/index.cjs19.js +0 -42
- package/dist/index.cjs2.js +0 -261
- package/dist/index.cjs20.js +0 -15
- package/dist/index.cjs21.js +0 -26
- package/dist/index.cjs22.js +0 -79
- package/dist/index.cjs23.js +0 -84
- package/dist/index.cjs24.js +0 -18
- package/dist/index.cjs25.js +0 -29
- package/dist/index.cjs26.js +0 -9
- package/dist/index.cjs27.js +0 -7
- package/dist/index.cjs28.js +0 -29
- package/dist/index.cjs29.js +0 -42
- package/dist/index.cjs3.js +0 -788
- package/dist/index.cjs4.js +0 -167
- package/dist/index.cjs5.js +0 -68
- package/dist/index.cjs6.js +0 -5
- package/dist/index.cjs7.js +0 -5
- package/dist/index.cjs8.js +0 -5
- package/dist/index.cjs9.js +0 -5
package/dist/.vite/manifest.json
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"src/AutoFetchCollection.ts": {
|
|
3
|
-
"file": "
|
|
3
|
+
"file": "index27.cjs.js",
|
|
4
4
|
"name": "AutoFetchCollection",
|
|
5
5
|
"src": "src/AutoFetchCollection.ts",
|
|
6
|
+
"isDynamicEntry": true,
|
|
6
7
|
"imports": [
|
|
7
8
|
"src/ReplicatedCollection.ts",
|
|
8
9
|
"src/utils/createSignal.ts"
|
|
9
10
|
]
|
|
10
11
|
},
|
|
11
12
|
"src/Collection/Cursor.ts": {
|
|
12
|
-
"file": "
|
|
13
|
+
"file": "index10.cjs.js",
|
|
13
14
|
"name": "Collection/Cursor",
|
|
14
15
|
"src": "src/Collection/Cursor.ts",
|
|
16
|
+
"isDynamicEntry": true,
|
|
15
17
|
"imports": [
|
|
16
|
-
"src/
|
|
18
|
+
"src/Collection/Observer.ts",
|
|
19
|
+
"src/utils/deepClone.ts",
|
|
17
20
|
"src/utils/project.ts",
|
|
18
|
-
"src/
|
|
21
|
+
"src/utils/sortItems.ts"
|
|
19
22
|
]
|
|
20
23
|
},
|
|
21
24
|
"src/Collection/Observer.ts": {
|
|
22
|
-
"file": "
|
|
25
|
+
"file": "index9.cjs.js",
|
|
23
26
|
"name": "Collection/Observer",
|
|
24
27
|
"src": "src/Collection/Observer.ts",
|
|
28
|
+
"isDynamicEntry": true,
|
|
25
29
|
"imports": [
|
|
26
30
|
"src/utils/isEqual.ts",
|
|
27
31
|
"src/utils/uniqueBy.ts"
|
|
28
32
|
]
|
|
29
33
|
},
|
|
30
34
|
"src/Collection/createIndex.ts": {
|
|
31
|
-
"file": "
|
|
35
|
+
"file": "index22.cjs.js",
|
|
32
36
|
"name": "Collection/createIndex",
|
|
33
37
|
"src": "src/Collection/createIndex.ts",
|
|
38
|
+
"isDynamicEntry": true,
|
|
34
39
|
"imports": [
|
|
35
40
|
"src/createIndexProvider.ts",
|
|
36
41
|
"src/utils/get.ts",
|
|
@@ -39,35 +44,38 @@
|
|
|
39
44
|
]
|
|
40
45
|
},
|
|
41
46
|
"src/Collection/getIndexInfo.ts": {
|
|
42
|
-
"file": "
|
|
47
|
+
"file": "index18.cjs.js",
|
|
43
48
|
"name": "Collection/getIndexInfo",
|
|
44
49
|
"src": "src/Collection/getIndexInfo.ts",
|
|
50
|
+
"isDynamicEntry": true,
|
|
45
51
|
"imports": [
|
|
46
52
|
"src/utils/intersection.ts"
|
|
47
53
|
]
|
|
48
54
|
},
|
|
49
55
|
"src/Collection/index.ts": {
|
|
50
|
-
"file": "
|
|
56
|
+
"file": "index23.cjs.js",
|
|
51
57
|
"name": "Collection/index",
|
|
52
58
|
"src": "src/Collection/index.ts",
|
|
59
|
+
"isDynamicEntry": true,
|
|
53
60
|
"imports": [
|
|
61
|
+
"src/Collection/Cursor.ts",
|
|
62
|
+
"src/Collection/createIndex.ts",
|
|
63
|
+
"src/Collection/getIndexInfo.ts",
|
|
54
64
|
"src/utils/EventEmitter.ts",
|
|
65
|
+
"src/utils/createSignal.ts",
|
|
66
|
+
"src/utils/deepClone.ts",
|
|
67
|
+
"src/utils/isEqual.ts",
|
|
55
68
|
"src/utils/match.ts",
|
|
56
69
|
"src/utils/modify.ts",
|
|
57
|
-
"src/utils/isEqual.ts",
|
|
58
70
|
"src/utils/randomId.ts",
|
|
59
|
-
"src/utils/
|
|
60
|
-
"src/utils/serializeValue.ts",
|
|
61
|
-
"src/utils/createSignal.ts",
|
|
62
|
-
"src/Collection/Cursor.ts",
|
|
63
|
-
"src/Collection/getIndexInfo.ts",
|
|
64
|
-
"src/Collection/createIndex.ts"
|
|
71
|
+
"src/utils/serializeValue.ts"
|
|
65
72
|
]
|
|
66
73
|
},
|
|
67
74
|
"src/ReplicatedCollection.ts": {
|
|
68
|
-
"file": "
|
|
75
|
+
"file": "index26.cjs.js",
|
|
69
76
|
"name": "ReplicatedCollection",
|
|
70
77
|
"src": "src/ReplicatedCollection.ts",
|
|
78
|
+
"isDynamicEntry": true,
|
|
71
79
|
"imports": [
|
|
72
80
|
"src/Collection/index.ts",
|
|
73
81
|
"src/persistence/combinePersistenceAdapters.ts",
|
|
@@ -76,19 +84,22 @@
|
|
|
76
84
|
]
|
|
77
85
|
},
|
|
78
86
|
"src/createIndexProvider.ts": {
|
|
79
|
-
"file": "
|
|
87
|
+
"file": "index19.cjs.js",
|
|
80
88
|
"name": "createIndexProvider",
|
|
81
|
-
"src": "src/createIndexProvider.ts"
|
|
89
|
+
"src": "src/createIndexProvider.ts",
|
|
90
|
+
"isDynamicEntry": true
|
|
82
91
|
},
|
|
83
92
|
"src/createMemoryAdapter.ts": {
|
|
84
|
-
"file": "
|
|
93
|
+
"file": "index28.cjs.js",
|
|
85
94
|
"name": "createMemoryAdapter",
|
|
86
|
-
"src": "src/createMemoryAdapter.ts"
|
|
95
|
+
"src": "src/createMemoryAdapter.ts",
|
|
96
|
+
"isDynamicEntry": true
|
|
87
97
|
},
|
|
88
98
|
"src/createReactivityAdapter.ts": {
|
|
89
|
-
"file": "
|
|
99
|
+
"file": "index29.cjs.js",
|
|
90
100
|
"name": "createReactivityAdapter",
|
|
91
|
-
"src": "src/createReactivityAdapter.ts"
|
|
101
|
+
"src": "src/createReactivityAdapter.ts",
|
|
102
|
+
"isDynamicEntry": true
|
|
92
103
|
},
|
|
93
104
|
"src/index.ts": {
|
|
94
105
|
"file": "index.cjs.js",
|
|
@@ -96,126 +107,144 @@
|
|
|
96
107
|
"src": "src/index.ts",
|
|
97
108
|
"isEntry": true,
|
|
98
109
|
"imports": [
|
|
110
|
+
"src/AutoFetchCollection.ts",
|
|
99
111
|
"src/Collection/Cursor.ts",
|
|
112
|
+
"src/Collection/createIndex.ts",
|
|
100
113
|
"src/Collection/index.ts",
|
|
101
|
-
"src/AutoFetchCollection.ts",
|
|
102
|
-
"src/persistence/combinePersistenceAdapters.ts",
|
|
103
114
|
"src/createIndexProvider.ts",
|
|
104
115
|
"src/createMemoryAdapter.ts",
|
|
105
|
-
"src/persistence/createPersistenceAdapter.ts",
|
|
106
116
|
"src/createReactivityAdapter.ts",
|
|
117
|
+
"src/persistence/combinePersistenceAdapters.ts",
|
|
118
|
+
"src/persistence/createPersistenceAdapter.ts",
|
|
119
|
+
"src/utils/EventEmitter.ts",
|
|
107
120
|
"src/utils/isEqual.ts",
|
|
108
121
|
"src/utils/modify.ts",
|
|
109
|
-
"src/utils/randomId.ts"
|
|
110
|
-
"src/utils/EventEmitter.ts",
|
|
111
|
-
"src/Collection/createIndex.ts"
|
|
122
|
+
"src/utils/randomId.ts"
|
|
112
123
|
]
|
|
113
124
|
},
|
|
114
125
|
"src/persistence/combinePersistenceAdapters.ts": {
|
|
115
|
-
"file": "
|
|
126
|
+
"file": "index25.cjs.js",
|
|
116
127
|
"name": "persistence/combinePersistenceAdapters",
|
|
117
128
|
"src": "src/persistence/combinePersistenceAdapters.ts",
|
|
129
|
+
"isDynamicEntry": true,
|
|
118
130
|
"imports": [
|
|
119
131
|
"src/persistence/createPersistenceAdapter.ts"
|
|
120
132
|
]
|
|
121
133
|
},
|
|
122
134
|
"src/persistence/createPersistenceAdapter.ts": {
|
|
123
|
-
"file": "
|
|
135
|
+
"file": "index24.cjs.js",
|
|
124
136
|
"name": "persistence/createPersistenceAdapter",
|
|
125
|
-
"src": "src/persistence/createPersistenceAdapter.ts"
|
|
137
|
+
"src": "src/persistence/createPersistenceAdapter.ts",
|
|
138
|
+
"isDynamicEntry": true
|
|
126
139
|
},
|
|
127
140
|
"src/utils/EventEmitter.ts": {
|
|
128
|
-
"file": "
|
|
141
|
+
"file": "index11.cjs.js",
|
|
129
142
|
"name": "utils/EventEmitter",
|
|
130
|
-
"src": "src/utils/EventEmitter.ts"
|
|
143
|
+
"src": "src/utils/EventEmitter.ts",
|
|
144
|
+
"isDynamicEntry": true
|
|
131
145
|
},
|
|
132
146
|
"src/utils/createSignal.ts": {
|
|
133
|
-
"file": "
|
|
147
|
+
"file": "index16.cjs.js",
|
|
134
148
|
"name": "utils/createSignal",
|
|
135
|
-
"src": "src/utils/createSignal.ts"
|
|
149
|
+
"src": "src/utils/createSignal.ts",
|
|
150
|
+
"isDynamicEntry": true
|
|
136
151
|
},
|
|
137
152
|
"src/utils/deepClone.ts": {
|
|
138
|
-
"file": "
|
|
153
|
+
"file": "index6.cjs.js",
|
|
139
154
|
"name": "utils/deepClone",
|
|
140
|
-
"src": "src/utils/deepClone.ts"
|
|
155
|
+
"src": "src/utils/deepClone.ts",
|
|
156
|
+
"isDynamicEntry": true
|
|
141
157
|
},
|
|
142
158
|
"src/utils/get.ts": {
|
|
143
|
-
"file": "
|
|
159
|
+
"file": "index2.cjs.js",
|
|
144
160
|
"name": "utils/get",
|
|
145
|
-
"src": "src/utils/get.ts"
|
|
161
|
+
"src": "src/utils/get.ts",
|
|
162
|
+
"isDynamicEntry": true
|
|
146
163
|
},
|
|
147
164
|
"src/utils/getMatchingKeys.ts": {
|
|
148
|
-
"file": "
|
|
165
|
+
"file": "index21.cjs.js",
|
|
149
166
|
"name": "utils/getMatchingKeys",
|
|
150
167
|
"src": "src/utils/getMatchingKeys.ts",
|
|
168
|
+
"isDynamicEntry": true,
|
|
151
169
|
"imports": [
|
|
152
170
|
"src/utils/isFieldExpression.ts",
|
|
153
171
|
"src/utils/serializeValue.ts"
|
|
154
172
|
]
|
|
155
173
|
},
|
|
156
174
|
"src/utils/intersection.ts": {
|
|
157
|
-
"file": "
|
|
175
|
+
"file": "index17.cjs.js",
|
|
158
176
|
"name": "utils/intersection",
|
|
159
|
-
"src": "src/utils/intersection.ts"
|
|
177
|
+
"src": "src/utils/intersection.ts",
|
|
178
|
+
"isDynamicEntry": true
|
|
160
179
|
},
|
|
161
180
|
"src/utils/isEqual.ts": {
|
|
162
|
-
"file": "
|
|
181
|
+
"file": "index7.cjs.js",
|
|
163
182
|
"name": "utils/isEqual",
|
|
164
|
-
"src": "src/utils/isEqual.ts"
|
|
183
|
+
"src": "src/utils/isEqual.ts",
|
|
184
|
+
"isDynamicEntry": true
|
|
165
185
|
},
|
|
166
186
|
"src/utils/isFieldExpression.ts": {
|
|
167
|
-
"file": "
|
|
187
|
+
"file": "index20.cjs.js",
|
|
168
188
|
"name": "utils/isFieldExpression",
|
|
169
|
-
"src": "src/utils/isFieldExpression.ts"
|
|
189
|
+
"src": "src/utils/isFieldExpression.ts",
|
|
190
|
+
"isDynamicEntry": true
|
|
170
191
|
},
|
|
171
192
|
"src/utils/match.ts": {
|
|
172
|
-
"file": "
|
|
193
|
+
"file": "index12.cjs.js",
|
|
173
194
|
"name": "utils/match",
|
|
174
|
-
"src": "src/utils/match.ts"
|
|
195
|
+
"src": "src/utils/match.ts",
|
|
196
|
+
"isDynamicEntry": true
|
|
175
197
|
},
|
|
176
198
|
"src/utils/modify.ts": {
|
|
177
|
-
"file": "
|
|
199
|
+
"file": "index13.cjs.js",
|
|
178
200
|
"name": "utils/modify",
|
|
179
201
|
"src": "src/utils/modify.ts",
|
|
202
|
+
"isDynamicEntry": true,
|
|
180
203
|
"imports": [
|
|
181
204
|
"src/utils/deepClone.ts"
|
|
182
205
|
]
|
|
183
206
|
},
|
|
184
207
|
"src/utils/project.ts": {
|
|
185
|
-
"file": "
|
|
208
|
+
"file": "index5.cjs.js",
|
|
186
209
|
"name": "utils/project",
|
|
187
210
|
"src": "src/utils/project.ts",
|
|
211
|
+
"isDynamicEntry": true,
|
|
188
212
|
"imports": [
|
|
189
213
|
"src/utils/get.ts",
|
|
190
214
|
"src/utils/set.ts"
|
|
191
215
|
]
|
|
192
216
|
},
|
|
193
217
|
"src/utils/randomId.ts": {
|
|
194
|
-
"file": "
|
|
218
|
+
"file": "index14.cjs.js",
|
|
195
219
|
"name": "utils/randomId",
|
|
196
|
-
"src": "src/utils/randomId.ts"
|
|
220
|
+
"src": "src/utils/randomId.ts",
|
|
221
|
+
"isDynamicEntry": true
|
|
197
222
|
},
|
|
198
223
|
"src/utils/serializeValue.ts": {
|
|
199
|
-
"file": "
|
|
224
|
+
"file": "index15.cjs.js",
|
|
200
225
|
"name": "utils/serializeValue",
|
|
201
|
-
"src": "src/utils/serializeValue.ts"
|
|
226
|
+
"src": "src/utils/serializeValue.ts",
|
|
227
|
+
"isDynamicEntry": true
|
|
202
228
|
},
|
|
203
229
|
"src/utils/set.ts": {
|
|
204
|
-
"file": "
|
|
230
|
+
"file": "index4.cjs.js",
|
|
205
231
|
"name": "utils/set",
|
|
206
|
-
"src": "src/utils/set.ts"
|
|
232
|
+
"src": "src/utils/set.ts",
|
|
233
|
+
"isDynamicEntry": true
|
|
207
234
|
},
|
|
208
235
|
"src/utils/sortItems.ts": {
|
|
209
|
-
"file": "
|
|
236
|
+
"file": "index3.cjs.js",
|
|
210
237
|
"name": "utils/sortItems",
|
|
211
238
|
"src": "src/utils/sortItems.ts",
|
|
239
|
+
"isDynamicEntry": true,
|
|
212
240
|
"imports": [
|
|
213
241
|
"src/utils/get.ts"
|
|
214
242
|
]
|
|
215
243
|
},
|
|
216
244
|
"src/utils/uniqueBy.ts": {
|
|
217
|
-
"file": "
|
|
245
|
+
"file": "index8.cjs.js",
|
|
218
246
|
"name": "utils/uniqueBy",
|
|
219
|
-
"src": "src/utils/uniqueBy.ts"
|
|
247
|
+
"src": "src/utils/uniqueBy.ts",
|
|
248
|
+
"isDynamicEntry": true
|
|
220
249
|
}
|
|
221
250
|
}
|
|
@@ -10,11 +10,11 @@ interface AutoFetchOptions<T extends {
|
|
|
10
10
|
registerRemoteChange?: (onChange: () => Promise<void>) => Promise<void>;
|
|
11
11
|
mergeItems?: (itemA: T, itemB: T) => T;
|
|
12
12
|
}
|
|
13
|
-
export type AutoFetchCollectionOptions<T extends BaseItem<I>, I, U =
|
|
13
|
+
export type AutoFetchCollectionOptions<T extends BaseItem<I>, I, E extends BaseItem = T, U = E> = Omit<ReplicatedCollectionOptions<T, I, E, U>, 'pull' | 'registerRemoteChange'> & AutoFetchOptions<T, I>;
|
|
14
14
|
/**
|
|
15
15
|
* A special collection that automatically fetches items when they are needed.
|
|
16
16
|
*/
|
|
17
|
-
export default class AutoFetchCollection<T extends BaseItem<I> = BaseItem, I = any, U =
|
|
17
|
+
export default class AutoFetchCollection<T extends BaseItem<I> = BaseItem, I = any, E extends BaseItem = T, U = E> extends ReplicatedCollection<T, I, E, U> {
|
|
18
18
|
private activeObservers;
|
|
19
19
|
private observerTimeouts;
|
|
20
20
|
private purgeDelay;
|
|
@@ -31,7 +31,7 @@ export default class AutoFetchCollection<T extends BaseItem<I> = BaseItem, I = a
|
|
|
31
31
|
* @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.
|
|
32
32
|
* @param options.purgeDelay {Number} - The delay in milliseconds before purging an item from the cache.
|
|
33
33
|
*/
|
|
34
|
-
constructor(options: AutoFetchCollectionOptions<T, I, U>);
|
|
34
|
+
constructor(options: AutoFetchCollectionOptions<T, I, E, U>);
|
|
35
35
|
/**
|
|
36
36
|
* Registers a query manually that items should be fetched for it
|
|
37
37
|
* @param selector {Object} Selector of the query
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ReactivityAdapter from '../types/ReactivityAdapter';
|
|
2
|
-
import type { BaseItem, FindOptions, Transform } from './types';
|
|
2
|
+
import type { BaseItem, FindOptions, Transform, TransformAll } from './types';
|
|
3
3
|
import type { ObserveCallbacks } from './Observer';
|
|
4
4
|
/**
|
|
5
5
|
* Checks if the current scope is reactive, considering the provided reactivity adapter.
|
|
@@ -7,17 +7,19 @@ import type { ObserveCallbacks } from './Observer';
|
|
|
7
7
|
* @returns A boolean indicating if the current scope is reactive.
|
|
8
8
|
*/
|
|
9
9
|
export declare function isInReactiveScope(reactivity: ReactivityAdapter | undefined | false): boolean;
|
|
10
|
-
export interface CursorOptions<T extends BaseItem, U =
|
|
11
|
-
|
|
10
|
+
export interface CursorOptions<T extends BaseItem, E extends BaseItem = T, U = E> extends FindOptions<T> {
|
|
11
|
+
transformAll?: TransformAll<T, E>;
|
|
12
|
+
transform?: Transform<E, U>;
|
|
12
13
|
bindEvents?: (requery: () => void) => () => void;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Represents a cursor for querying and observing a filtered, sorted, and transformed
|
|
16
17
|
* subset of items from a collection. Supports reactivity and field tracking.
|
|
17
18
|
* @template T - The type of the items in the collection.
|
|
18
|
-
* @template
|
|
19
|
+
* @template E - The transformed item type after applying transformAll (default is T).
|
|
20
|
+
* @template U - The transformed item type after applying transform (default is E).
|
|
19
21
|
*/
|
|
20
|
-
export default class Cursor<T extends BaseItem, U =
|
|
22
|
+
export default class Cursor<T extends BaseItem, E extends BaseItem = T, U = E> {
|
|
21
23
|
private observer;
|
|
22
24
|
private getFilteredItems;
|
|
23
25
|
private options;
|
|
@@ -37,8 +39,9 @@ export default class Cursor<T extends BaseItem, U = T> {
|
|
|
37
39
|
* @param options.limit - The maximum number of items to return in the result set.
|
|
38
40
|
* @param options.reactive - A reactivity adapter to enable observing changes in the cursor's result set.
|
|
39
41
|
* @param options.fieldTracking - A boolean to enable fine-grained field tracking for reactivity.
|
|
42
|
+
* @param options.transformAll - A function that will be able to solve the n+1 problem
|
|
40
43
|
*/
|
|
41
|
-
constructor(getItems: () => T[], options?: CursorOptions<T, U>);
|
|
44
|
+
constructor(getItems: () => T[], options?: CursorOptions<T, E, U>);
|
|
42
45
|
private addGetters;
|
|
43
46
|
private transform;
|
|
44
47
|
private getItems;
|
|
@@ -102,7 +105,7 @@ export default class Cursor<T extends BaseItem, U = T> {
|
|
|
102
105
|
* @param skipInitial - A boolean indicating whether to skip the initial notification of the current result set.
|
|
103
106
|
* @returns A function to stop observing changes.
|
|
104
107
|
*/
|
|
105
|
-
observeChanges(callbacks: ObserveCallbacks<
|
|
108
|
+
observeChanges(callbacks: ObserveCallbacks<E>, skipInitial?: boolean): () => void;
|
|
106
109
|
/**
|
|
107
110
|
* Forces the cursor to re-evaluate its result set by re-fetching items
|
|
108
111
|
* from the collection. This is useful when the underlying data or query
|
|
@@ -6,23 +6,24 @@ import type Selector from '../types/Selector';
|
|
|
6
6
|
import type Modifier from '../types/Modifier';
|
|
7
7
|
import type IndexProvider from '../types/IndexProvider';
|
|
8
8
|
import Cursor from './Cursor';
|
|
9
|
-
import type { BaseItem, FindOptions, Transform } from './types';
|
|
10
|
-
export type { BaseItem, Transform, SortSpecifier, FieldSpecifier, FindOptions } from './types';
|
|
9
|
+
import type { BaseItem, FindOptions, Transform, TransformAll } from './types';
|
|
10
|
+
export type { BaseItem, Transform, TransformAll, SortSpecifier, FieldSpecifier, FindOptions } from './types';
|
|
11
11
|
export type { CursorOptions } from './Cursor';
|
|
12
12
|
export type { ObserveCallbacks } from './Observer';
|
|
13
13
|
export { default as createIndex } from './createIndex';
|
|
14
|
-
export interface CollectionOptions<T extends BaseItem<I>, I, U =
|
|
14
|
+
export interface CollectionOptions<T extends BaseItem<I>, I, E extends BaseItem = T, U = E> {
|
|
15
15
|
name?: string;
|
|
16
16
|
memory?: MemoryAdapter;
|
|
17
17
|
reactivity?: ReactivityAdapter;
|
|
18
|
-
transform?: Transform<
|
|
18
|
+
transform?: Transform<E, U>;
|
|
19
19
|
persistence?: PersistenceAdapter<T, I>;
|
|
20
20
|
indices?: IndexProvider<T, I>[];
|
|
21
21
|
enableDebugMode?: boolean;
|
|
22
22
|
fieldTracking?: boolean;
|
|
23
|
+
transformAll?: TransformAll<T, E>;
|
|
23
24
|
primaryKeyGenerator?: (item: Omit<T, 'id'>) => I;
|
|
24
25
|
}
|
|
25
|
-
interface CollectionEvents<T extends BaseItem, U =
|
|
26
|
+
interface CollectionEvents<T extends BaseItem, E extends BaseItem = T, U = E> {
|
|
26
27
|
'added': (item: T) => void;
|
|
27
28
|
'changed': (item: T, modifier: Modifier<T>) => void;
|
|
28
29
|
'removed': (item: T) => void;
|
|
@@ -37,7 +38,7 @@ interface CollectionEvents<T extends BaseItem, U = T> {
|
|
|
37
38
|
'observer.created': <O extends FindOptions<T>>(selector?: Selector<T>, options?: O) => void;
|
|
38
39
|
'observer.disposed': <O extends FindOptions<T>>(selector?: Selector<T>, options?: O) => void;
|
|
39
40
|
'getItems': (selector: Selector<T> | undefined) => void;
|
|
40
|
-
'find': <O extends FindOptions<T>>(selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, U>) => void;
|
|
41
|
+
'find': <O extends FindOptions<T>>(selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, E, U>) => void;
|
|
41
42
|
'findOne': <O extends FindOptions<T>>(selector: Selector<T>, options: O | undefined, item: U | undefined) => void;
|
|
42
43
|
'insert': (item: Omit<T, 'id'> & Partial<Pick<T, 'id'>>) => void;
|
|
43
44
|
'updateOne': (selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
@@ -47,7 +48,7 @@ interface CollectionEvents<T extends BaseItem, U = T> {
|
|
|
47
48
|
'removeMany': (selector: Selector<T>) => void;
|
|
48
49
|
'validate': (item: T) => void;
|
|
49
50
|
'_debug.getItems': (callstack: string, selector: Selector<T> | undefined, measuredTime: number) => void;
|
|
50
|
-
'_debug.find': <O extends FindOptions<T>>(callstack: string, selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, U>) => void;
|
|
51
|
+
'_debug.find': <O extends FindOptions<T>>(callstack: string, selector: Selector<T> | undefined, options: O | undefined, cursor: Cursor<T, E, U>) => void;
|
|
51
52
|
'_debug.findOne': <O extends FindOptions<T>>(callstack: string, selector: Selector<T>, options: O | undefined, item: U | undefined) => void;
|
|
52
53
|
'_debug.insert': (callstack: string, item: Omit<T, 'id'> & Partial<Pick<T, 'id'>>) => void;
|
|
53
54
|
'_debug.updateOne': (callstack: string, selector: Selector<T>, modifier: Modifier<T>) => void;
|
|
@@ -64,14 +65,14 @@ interface CollectionEvents<T extends BaseItem, U = T> {
|
|
|
64
65
|
* @template I - The type of the unique identifier for the items.
|
|
65
66
|
* @template U - The transformed item type after applying transformations (default is T).
|
|
66
67
|
*/
|
|
67
|
-
export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U =
|
|
68
|
+
export default class Collection<T extends BaseItem<I> = BaseItem, I = any, E extends BaseItem = T, U = E> extends EventEmitter<CollectionEvents<T, E, U>> {
|
|
68
69
|
private static collections;
|
|
69
70
|
private static debugMode;
|
|
70
71
|
private static batchOperationInProgress;
|
|
71
72
|
private static fieldTracking;
|
|
72
73
|
private static onCreationCallbacks;
|
|
73
74
|
private static onDisposeCallbacks;
|
|
74
|
-
static getCollections(): Collection<any, any, any>[];
|
|
75
|
+
static getCollections(): Collection<any, any, any, any>[];
|
|
75
76
|
static onCreation(callback: (collection: Collection<any>) => void): void;
|
|
76
77
|
static onDispose(callback: (collection: Collection<any>) => void): void;
|
|
77
78
|
/**
|
|
@@ -105,6 +106,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
105
106
|
private postBatchCallbacks;
|
|
106
107
|
private fieldTracking;
|
|
107
108
|
private persistenceReadyPromise;
|
|
109
|
+
private pendingUpdates;
|
|
108
110
|
/**
|
|
109
111
|
* Initializes a new instance of the `Collection` class with optional configuration.
|
|
110
112
|
* Sets up memory, persistence, reactivity, and indices as specified in the options.
|
|
@@ -120,8 +122,21 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
120
122
|
* @param options.indices - An array of index providers for optimized querying.
|
|
121
123
|
* @param options.enableDebugMode - A boolean to enable or disable debug mode.
|
|
122
124
|
* @param options.fieldTracking - A boolean to enable or disable field tracking by default.
|
|
125
|
+
* @param options.transformAll - A function that will be able to solve the n+1 problem
|
|
123
126
|
*/
|
|
124
|
-
constructor(options?: CollectionOptions<T, I, U>);
|
|
127
|
+
constructor(options?: CollectionOptions<T, I, E, U>);
|
|
128
|
+
/**
|
|
129
|
+
* Resets the collection's data by clearing the in-memory items and reloading from the persistence adapter.
|
|
130
|
+
* @returns A promise that resolves when the data has been reset and reloaded.
|
|
131
|
+
*/
|
|
132
|
+
resetData(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Loads data from the persistence adapter and updates the in-memory collection accordingly.
|
|
135
|
+
* @param data - Optional data to load, containing either a full list of items or a set of changes. If not provided, data will be loaded from the persistence adapter.
|
|
136
|
+
* @param hasOngoingSaves - A boolean indicating whether there are ongoing save operations. If `true`, the method will skip loading data to avoid conflicts with pending updates.
|
|
137
|
+
* @returns A promise that resolves when the data has been loaded and the in-memory collection has been updated.
|
|
138
|
+
*/
|
|
139
|
+
private loadPersistentData;
|
|
125
140
|
/**
|
|
126
141
|
* Checks whether the collection is currently performing a pull operation
|
|
127
142
|
* ⚡️ this function is reactive!
|
|
@@ -183,6 +198,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
183
198
|
private memory;
|
|
184
199
|
private memoryArray;
|
|
185
200
|
private transform;
|
|
201
|
+
private transformAll;
|
|
186
202
|
private getItems;
|
|
187
203
|
/**
|
|
188
204
|
* Disposes the collection, unregisters persistence adapters, clears memory, and
|
|
@@ -198,7 +214,7 @@ export default class Collection<T extends BaseItem<I> = BaseItem, I = any, U = T
|
|
|
198
214
|
* @param [options] - Options for the find operation, such as limit and sort.
|
|
199
215
|
* @returns A cursor to fetch and observe the matching items.
|
|
200
216
|
*/
|
|
201
|
-
find<O extends FindOptions<T>>(selector?: Selector<T>, options?: O): Cursor<T, U>;
|
|
217
|
+
find<O extends FindOptions<T>>(selector?: Selector<T>, options?: O): Cursor<T, E, U>;
|
|
202
218
|
/**
|
|
203
219
|
* Finds a single item in the collection based on a selector and optional options.
|
|
204
220
|
* ⚡️ this function is reactive!
|
|
@@ -3,6 +3,7 @@ export type BaseItem<I = any> = {
|
|
|
3
3
|
id: I;
|
|
4
4
|
} & Record<string, any>;
|
|
5
5
|
export type Transform<T, U = T> = ((document: T) => U) | null | undefined;
|
|
6
|
+
export type TransformAll<T extends BaseItem, O extends BaseItem = T> = ((items: T[], fields: FieldSpecifier<O> | undefined) => O[]) | null | undefined;
|
|
6
7
|
export type SortSpecifier<T> = {
|
|
7
8
|
[P in keyof T]?: -1 | 1;
|
|
8
9
|
} & Record<string, -1 | 1>;
|
|
@@ -21,8 +21,8 @@ interface ReplicationOptions<T extends {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function createReplicationAdapter<T extends {
|
|
23
23
|
id: I;
|
|
24
|
-
} & Record<string, any>, I>(options: ReplicationOptions<T, I>): import("
|
|
25
|
-
export type ReplicatedCollectionOptions<T extends BaseItem<I>, I, U =
|
|
24
|
+
} & Record<string, any>, I>(options: ReplicationOptions<T, I>): import(".").PersistenceAdapter<T, unknown>;
|
|
25
|
+
export type ReplicatedCollectionOptions<T extends BaseItem<I>, I, E extends BaseItem = T, U = E> = CollectionOptions<T, I, E, U> & ReplicationOptions<T, I>;
|
|
26
26
|
/**
|
|
27
27
|
* Extends the `Collection` class to support replication with remote sources.
|
|
28
28
|
* Handles pull and push operations, remote change registration, and enhanced loading states.
|
|
@@ -30,7 +30,7 @@ export type ReplicatedCollectionOptions<T extends BaseItem<I>, I, U = T> = Colle
|
|
|
30
30
|
* @template I - The type of the unique identifier for the items.
|
|
31
31
|
* @template U - The transformed item type after applying transformations (default is T).
|
|
32
32
|
*/
|
|
33
|
-
export default class ReplicatedCollection<T extends BaseItem<I> = BaseItem, I = any, U =
|
|
33
|
+
export default class ReplicatedCollection<T extends BaseItem<I> = BaseItem, I = any, E extends BaseItem = T, U = E> extends Collection<T, I, E, U> {
|
|
34
34
|
private isPullingRemoteSignal;
|
|
35
35
|
private isPushingRemoteSignal;
|
|
36
36
|
/**
|
|
@@ -47,7 +47,7 @@ export default class ReplicatedCollection<T extends BaseItem<I> = BaseItem, I =
|
|
|
47
47
|
* @param options.indices - An array of index providers for optimized querying.
|
|
48
48
|
* @param options.enableDebugMode - A boolean to enable or disable debug mode.
|
|
49
49
|
*/
|
|
50
|
-
constructor(options: ReplicatedCollectionOptions<T, I, U>);
|
|
50
|
+
constructor(options: ReplicatedCollectionOptions<T, I, E, U>);
|
|
51
51
|
/**
|
|
52
52
|
* Checks whether the collection is currently performing any loading operation,
|
|
53
53
|
* including pulling or pushing data from/to the remote source, or standard
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
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
|
-
exports.
|
|
17
|
-
exports.Collection =
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
2
|
+
const require_isEqual = require("./index7.cjs.js");
|
|
3
|
+
const require_Cursor = require("./index10.cjs.js");
|
|
4
|
+
const require_EventEmitter = require("./index11.cjs.js");
|
|
5
|
+
const require_modify = require("./index13.cjs.js");
|
|
6
|
+
const require_randomId = require("./index14.cjs.js");
|
|
7
|
+
const require_createIndexProvider = require("./index19.cjs.js");
|
|
8
|
+
const require_createIndex = require("./index22.cjs.js");
|
|
9
|
+
const require_index = require("./index23.cjs.js");
|
|
10
|
+
const require_createPersistenceAdapter = require("./index24.cjs.js");
|
|
11
|
+
const require_combinePersistenceAdapters = require("./index25.cjs.js");
|
|
12
|
+
const require_AutoFetchCollection = require("./index27.cjs.js");
|
|
13
|
+
const require_createMemoryAdapter = require("./index28.cjs.js");
|
|
14
|
+
const require_createReactivityAdapter = require("./index29.cjs.js");
|
|
15
|
+
exports.AutoFetchCollection = require_AutoFetchCollection;
|
|
16
|
+
exports.Collection = require_index;
|
|
17
|
+
exports.Cursor = require_Cursor;
|
|
18
|
+
exports.EventEmitter = require_EventEmitter;
|
|
19
|
+
exports.combinePersistenceAdapters = require_combinePersistenceAdapters;
|
|
20
|
+
exports.createIndex = require_createIndex;
|
|
21
|
+
exports.createIndexProvider = require_createIndexProvider;
|
|
22
|
+
exports.createMemoryAdapter = require_createMemoryAdapter;
|
|
23
|
+
exports.createPersistenceAdapter = require_createPersistenceAdapter;
|
|
24
|
+
exports.createReactivityAdapter = require_createReactivityAdapter;
|
|
25
|
+
exports.isEqual = require_isEqual;
|
|
26
|
+
exports.modify = require_modify;
|
|
27
|
+
exports.randomId = require_randomId;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { default as MemoryAdapter } from './types/MemoryAdapter';
|
|
|
3
3
|
export type { default as PersistenceAdapter, Changeset, LoadResponse, } from './types/PersistenceAdapter';
|
|
4
4
|
export type { default as Selector } from './types/Selector';
|
|
5
5
|
export type { default as Modifier } from './types/Modifier';
|
|
6
|
-
export type { BaseItem, ObserveCallbacks, CursorOptions, Transform, SortSpecifier, FieldSpecifier, FindOptions, CollectionOptions, } from './Collection';
|
|
6
|
+
export type { BaseItem, ObserveCallbacks, CursorOptions, Transform, TransformAll, SortSpecifier, FieldSpecifier, FindOptions, CollectionOptions, } from './Collection';
|
|
7
7
|
export { default as Cursor } from './Collection/Cursor';
|
|
8
8
|
export { default as Collection, createIndex } from './Collection';
|
|
9
9
|
export { default as AutoFetchCollection } from './AutoFetchCollection';
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
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
|
-
export {
|
|
15
|
-
default4 as AutoFetchCollection,
|
|
16
|
-
default3 as Collection,
|
|
17
|
-
default2 as Cursor,
|
|
18
|
-
default13 as EventEmitter,
|
|
19
|
-
default5 as combinePersistenceAdapters,
|
|
20
|
-
default14 as createIndex,
|
|
21
|
-
default6 as createIndexProvider,
|
|
22
|
-
default7 as createMemoryAdapter,
|
|
23
|
-
default8 as createPersistenceAdapter,
|
|
24
|
-
default9 as createReactivityAdapter,
|
|
25
|
-
default10 as isEqual,
|
|
26
|
-
default11 as modify,
|
|
27
|
-
default12 as randomId
|
|
28
|
-
};
|
|
1
|
+
import isEqual from "./index7.mjs";
|
|
2
|
+
import Cursor from "./index10.mjs";
|
|
3
|
+
import EventEmitter from "./index11.mjs";
|
|
4
|
+
import modify from "./index13.mjs";
|
|
5
|
+
import randomId from "./index14.mjs";
|
|
6
|
+
import createIndexProvider from "./index19.mjs";
|
|
7
|
+
import createIndex from "./index22.mjs";
|
|
8
|
+
import Collection from "./index23.mjs";
|
|
9
|
+
import createPersistenceAdapter from "./index24.mjs";
|
|
10
|
+
import combinePersistenceAdapters from "./index25.mjs";
|
|
11
|
+
import AutoFetchCollection from "./index27.mjs";
|
|
12
|
+
import createMemoryAdapter from "./index28.mjs";
|
|
13
|
+
import createReactivityAdapter from "./index29.mjs";
|
|
14
|
+
export { AutoFetchCollection, Collection, Cursor, EventEmitter, combinePersistenceAdapters, createIndex, createIndexProvider, createMemoryAdapter, createPersistenceAdapter, createReactivityAdapter, isEqual, modify, randomId };
|