@connecttomahdi/rxdb 17.1.0 → 17.1.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/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -10
- package/dist/cjs/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/cjs/plugins/utils/utils-premium.js +4 -4
- package/dist/cjs/plugins/utils/utils-premium.js.map +1 -1
- package/dist/esm/package.json +1 -0
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js +10 -10
- package/dist/esm/plugins/storage-dexie/rx-storage-instance-dexie.js.map +1 -1
- package/dist/esm/plugins/utils/utils-premium.js +4 -4
- package/dist/esm/plugins/utils/utils-premium.js.map +1 -1
- package/dist/types/index.d.ts +26 -25
- package/dist/types/types/conflict-handling.d.ts +48 -0
- package/dist/types/types/couchdb.d.ts +293 -0
- package/dist/types/types/index.d.ts +32 -0
- package/dist/types/types/modules/index.d.ts +0 -0
- package/dist/types/types/modules/mocha.parallel.d.ts +1 -0
- package/dist/types/types/plugins/backup.d.ts +35 -0
- package/dist/types/types/plugins/cleanup.d.ts +38 -0
- package/dist/types/types/plugins/crdt.d.ts +76 -0
- package/dist/types/types/plugins/dexie.d.ts +30 -0
- package/dist/types/types/plugins/local-documents.d.ts +49 -0
- package/dist/types/types/plugins/migration.d.ts +14 -0
- package/dist/types/types/plugins/reactivity.d.ts +40 -0
- package/dist/types/types/plugins/replication-graphql.d.ts +98 -0
- package/dist/types/types/plugins/replication.d.ts +175 -0
- package/dist/types/types/plugins/state.d.ts +4 -0
- package/dist/types/types/plugins/update.d.ts +23 -0
- package/dist/types/types/plugins/webmcp.d.ts +40 -0
- package/dist/types/types/query-planner.d.ts +47 -0
- package/dist/types/types/replication-protocol.d.ts +296 -0
- package/dist/types/types/rx-attachment.d.ts +46 -0
- package/dist/types/types/rx-change-event.d.ts +85 -0
- package/dist/types/types/rx-collection.d.ts +117 -0
- package/dist/types/types/rx-database-internal-store.d.ts +54 -0
- package/dist/types/types/rx-database.d.ts +124 -0
- package/dist/types/types/rx-document.d.ts +160 -0
- package/dist/types/types/rx-error.d.ts +225 -0
- package/dist/types/types/rx-plugin.d.ts +167 -0
- package/dist/types/types/rx-query.d.ts +144 -0
- package/dist/types/types/rx-schema.d.ts +214 -0
- package/dist/types/types/rx-storage.d.ts +347 -0
- package/dist/types/types/rx-storage.interface.d.ts +312 -0
- package/dist/types/types/util.d.ts +180 -0
- package/package.json +732 -732
- package/scripts/copy-path.mjs +20 -0
- package/scripts/fix-types.mjs +15 -8
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MangoQuery,
|
|
3
|
+
MangoQuerySelector,
|
|
4
|
+
MangoQuerySortPart
|
|
5
|
+
} from './rx-query.d.ts';
|
|
6
|
+
import type { BulkWriteRow } from './rx-storage.d.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This file contains types that are CouchDB specific
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface CouchReplicationOptions {
|
|
13
|
+
live?: boolean;
|
|
14
|
+
retry?: boolean;
|
|
15
|
+
filter?: Function;
|
|
16
|
+
doc_ids?: string[];
|
|
17
|
+
query_params?: any;
|
|
18
|
+
view?: any;
|
|
19
|
+
since?: number | 'now';
|
|
20
|
+
heartbeat?: number;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
batch_size?: number;
|
|
23
|
+
batches_limit?: number;
|
|
24
|
+
back_off_function?: Function;
|
|
25
|
+
checkpoint?: false | 'source' | 'target';
|
|
26
|
+
include_docs?: boolean;
|
|
27
|
+
limit?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CouchChangesOptionsBase {
|
|
31
|
+
include_docs?: boolean;
|
|
32
|
+
conflicts?: boolean;
|
|
33
|
+
attachments?: boolean;
|
|
34
|
+
binary?: boolean;
|
|
35
|
+
descending?: boolean;
|
|
36
|
+
since?: any;
|
|
37
|
+
limit?: number;
|
|
38
|
+
timeout?: any;
|
|
39
|
+
heartbeat?: number | boolean;
|
|
40
|
+
filter?: any;
|
|
41
|
+
doc_ids?: string | string[];
|
|
42
|
+
query_param?: any;
|
|
43
|
+
view?: any;
|
|
44
|
+
return_docs?: boolean;
|
|
45
|
+
batch_size?: number;
|
|
46
|
+
style?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface CouchChangesOptionsLive extends CouchChangesOptionsBase {
|
|
50
|
+
live: true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface CouchChangesOptionsNonLive extends CouchChangesOptionsBase {
|
|
54
|
+
live: false;
|
|
55
|
+
}
|
|
56
|
+
interface CouchChangesOnChangeEvent {
|
|
57
|
+
on: (eventName: string, handler: Function) => void;
|
|
58
|
+
off: (eventName: string, handler: Function) => void;
|
|
59
|
+
cancel(): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type CouchWriteError = {
|
|
63
|
+
/**
|
|
64
|
+
* status code from couchdb
|
|
65
|
+
* 409 for 'conflict'
|
|
66
|
+
*/
|
|
67
|
+
status: number;
|
|
68
|
+
error: true;
|
|
69
|
+
/**
|
|
70
|
+
* primary key value of the errored document
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* possible couch-settings
|
|
77
|
+
* @link https://couchdb.com/api.html#create_database
|
|
78
|
+
*/
|
|
79
|
+
export interface CouchSettings {
|
|
80
|
+
auto_compaction?: boolean;
|
|
81
|
+
revs_limit?: number;
|
|
82
|
+
ajax?: any;
|
|
83
|
+
fetch?: any;
|
|
84
|
+
auth?: any;
|
|
85
|
+
skip_setup?: boolean;
|
|
86
|
+
storage?: any;
|
|
87
|
+
size?: number;
|
|
88
|
+
location?: string;
|
|
89
|
+
iosDatabaseLocation?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* options for couch.allDocs()
|
|
94
|
+
* @link https://couchdb.com/api.html#batch_fetch
|
|
95
|
+
*/
|
|
96
|
+
export type CouchAllDocsOptions = {
|
|
97
|
+
include_docs?: boolean;
|
|
98
|
+
conflicts?: boolean;
|
|
99
|
+
attachments?: boolean;
|
|
100
|
+
binary?: boolean;
|
|
101
|
+
startkey?: string;
|
|
102
|
+
endkey?: string;
|
|
103
|
+
inclusive_end?: boolean;
|
|
104
|
+
limit?: number;
|
|
105
|
+
skip?: number;
|
|
106
|
+
descending?: boolean;
|
|
107
|
+
key?: string;
|
|
108
|
+
keys?: string[];
|
|
109
|
+
update_seq?: string;
|
|
110
|
+
|
|
111
|
+
// undocument but needed
|
|
112
|
+
revs?: boolean;
|
|
113
|
+
deleted?: 'ok';
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type CouchSyncHandlerEvents = 'change' | 'paused' | 'active' | 'error' | 'complete';
|
|
117
|
+
export type CouchSyncHandler = {
|
|
118
|
+
on(ev: CouchSyncHandlerEvents, fn: (el: any) => void): void;
|
|
119
|
+
off(ev: CouchSyncHandlerEvents, fn: any): void;
|
|
120
|
+
cancel(): void;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type CouchChangeRow = {
|
|
124
|
+
id: string;
|
|
125
|
+
seq: number;
|
|
126
|
+
deleted?: true;
|
|
127
|
+
changes: {
|
|
128
|
+
rev: 'string';
|
|
129
|
+
}[];
|
|
130
|
+
/**
|
|
131
|
+
* only if include_docs === true
|
|
132
|
+
*/
|
|
133
|
+
doc?: CouchChangeDoc;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type CouchAttachmentMeta = {
|
|
137
|
+
digest: string;
|
|
138
|
+
content_type: string;
|
|
139
|
+
length: number;
|
|
140
|
+
stub: boolean;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 'revpos indicates the generation number (numeric prefix in the revID) at which the attachment was last altered'
|
|
144
|
+
* @link https://github.com/couchbase/couchbase-lite-ios/issues/1200#issuecomment-206444554
|
|
145
|
+
*/
|
|
146
|
+
revpos: number;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type CouchAttachmentWithData = CouchAttachmentMeta & {
|
|
150
|
+
/**
|
|
151
|
+
* Base64 string with the data
|
|
152
|
+
* or directly a buffer
|
|
153
|
+
*/
|
|
154
|
+
data: Blob;
|
|
155
|
+
type: string;
|
|
156
|
+
/**
|
|
157
|
+
* If set, must be false
|
|
158
|
+
* because we have the full data and not only a stub.
|
|
159
|
+
*/
|
|
160
|
+
stub?: false;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type CouchChangeDoc = {
|
|
164
|
+
_id: string;
|
|
165
|
+
_rev: string;
|
|
166
|
+
/**
|
|
167
|
+
* True if the document is deleted.
|
|
168
|
+
*/
|
|
169
|
+
_deleted?: boolean;
|
|
170
|
+
_attachments: {
|
|
171
|
+
[attachmentId: string]: CouchAttachmentMeta;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type WithAttachments<Data> = Data & {
|
|
176
|
+
/**
|
|
177
|
+
* Intentional optional,
|
|
178
|
+
* if the document has no attachments,
|
|
179
|
+
* we do NOT have an empty object.
|
|
180
|
+
*/
|
|
181
|
+
_attachments?: {
|
|
182
|
+
[attachmentId: string]: CouchAttachmentMeta;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export type WithAttachmentsData<Data> = Data & {
|
|
186
|
+
/**
|
|
187
|
+
* Intentional optional,
|
|
188
|
+
* if the document has no attachments,
|
|
189
|
+
* we do NOT have an empty object.
|
|
190
|
+
*/
|
|
191
|
+
_attachments?: {
|
|
192
|
+
[attachmentId: string]: CouchAttachmentWithData;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
export type WithCouchMeta<Data> = Data & {
|
|
198
|
+
_rev: string;
|
|
199
|
+
_attachments?: {
|
|
200
|
+
[attachmentId: string]: CouchAttachmentMeta;
|
|
201
|
+
};
|
|
202
|
+
_deleted?: boolean;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export type CouchdbChangesResult = {
|
|
206
|
+
results: CouchChangeRow[];
|
|
207
|
+
last_seq: number;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
declare type Debug = {
|
|
211
|
+
enable(what: string): void;
|
|
212
|
+
disable(): void;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type CouchDbSorting = (string | string[] | { [k: string]: 'asc' | 'desc' | 1 | -1; })[];
|
|
216
|
+
|
|
217
|
+
// this is not equal to the standard MangoQuery
|
|
218
|
+
// because of different sorting
|
|
219
|
+
export type CouchdbQuery = MangoQuery & {
|
|
220
|
+
sort?: CouchDbSorting;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type CouchBulkDocResultRow = {
|
|
224
|
+
ok: boolean;
|
|
225
|
+
id: string;
|
|
226
|
+
rev: string;
|
|
227
|
+
|
|
228
|
+
error?: 'conflict';
|
|
229
|
+
reason?: string;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type CouchCheckpoint = {
|
|
233
|
+
sequence: number;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export type CouchBulkDocOptions = {
|
|
237
|
+
new_edits?: boolean;
|
|
238
|
+
|
|
239
|
+
// custom options for RxDB
|
|
240
|
+
isDeeper?: boolean;
|
|
241
|
+
custom?: {
|
|
242
|
+
primaryPath: string;
|
|
243
|
+
writeRowById: Map<string, BulkWriteRow<any>>;
|
|
244
|
+
insertDocsById: Map<string, any>;
|
|
245
|
+
previousDocsInDb: Map<string, any>;
|
|
246
|
+
context: string;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export type CouchMangoQuery<DocType> = MangoQuery<DocType> & {
|
|
251
|
+
index: undefined;
|
|
252
|
+
use_index?: string;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export type ExplainedCouchQuery<DocType> = {
|
|
256
|
+
dbname: string;
|
|
257
|
+
index: {
|
|
258
|
+
ddoc: string | null;
|
|
259
|
+
name: string; // 'idx-rxdb-index-age,_id'
|
|
260
|
+
type: 'json';
|
|
261
|
+
def: {
|
|
262
|
+
fields: MangoQuerySortPart<DocType>[];
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
selector: MangoQuerySelector<DocType>;
|
|
266
|
+
range: {
|
|
267
|
+
start_key: any[];
|
|
268
|
+
end_key: any[];
|
|
269
|
+
};
|
|
270
|
+
opts: {
|
|
271
|
+
use_index: string[];
|
|
272
|
+
bookmark: string;
|
|
273
|
+
sort: MangoQuerySortPart<DocType>[];
|
|
274
|
+
conflicts: boolean;
|
|
275
|
+
r: any[];
|
|
276
|
+
};
|
|
277
|
+
skip: number;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export type CouchAllDocsResponse = {
|
|
281
|
+
offset: number;
|
|
282
|
+
rows: {
|
|
283
|
+
id: string;
|
|
284
|
+
doc: any;
|
|
285
|
+
key: string;
|
|
286
|
+
value: {
|
|
287
|
+
rev: string;
|
|
288
|
+
deleted?: boolean;
|
|
289
|
+
};
|
|
290
|
+
error?: 'not_found' | string;
|
|
291
|
+
}[];
|
|
292
|
+
total_rows: number;
|
|
293
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type * from './couchdb.d.ts';
|
|
2
|
+
export type * from './rx-attachment.d.ts';
|
|
3
|
+
export type * from './rx-collection.d.ts';
|
|
4
|
+
export type * from './rx-database.d.ts';
|
|
5
|
+
export type * from './rx-database-internal-store.d.ts';
|
|
6
|
+
export type * from './rx-document.d.ts';
|
|
7
|
+
export type * from './rx-error.d.ts';
|
|
8
|
+
export type * from './rx-plugin.d.ts';
|
|
9
|
+
export type * from './rx-query.d.ts';
|
|
10
|
+
export type * from './rx-schema.d.ts';
|
|
11
|
+
export type * from './rx-storage.d.ts';
|
|
12
|
+
export type * from './rx-storage.interface.d.ts';
|
|
13
|
+
export type * from './replication-protocol.d.ts';
|
|
14
|
+
export type * from './conflict-handling.d.ts';
|
|
15
|
+
export type * from './rx-change-event.d.ts';
|
|
16
|
+
export type * from './query-planner.d.ts';
|
|
17
|
+
export type * from './util.d.ts';
|
|
18
|
+
|
|
19
|
+
// plugins
|
|
20
|
+
export type * from './plugins/replication.d.ts';
|
|
21
|
+
export type * from './plugins/replication-graphql.d.ts';
|
|
22
|
+
export type * from './plugins/replication.d.ts';
|
|
23
|
+
export type * from './plugins/local-documents.d.ts';
|
|
24
|
+
export type * from './plugins/migration.d.ts';
|
|
25
|
+
export type * from './plugins/backup.d.ts';
|
|
26
|
+
export type * from './plugins/cleanup.d.ts';
|
|
27
|
+
export type * from './plugins/dexie.d.ts';
|
|
28
|
+
export type * from './plugins/reactivity.d.ts';
|
|
29
|
+
export type * from './plugins/update.d.ts';
|
|
30
|
+
export type * from './plugins/crdt.d.ts';
|
|
31
|
+
export type * from './plugins/state.d.ts';
|
|
32
|
+
export type * from './plugins/webmcp.d.ts';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'mocha.parallel';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type BackupOptions = {
|
|
2
|
+
live: boolean;
|
|
3
|
+
directory: string;
|
|
4
|
+
/**
|
|
5
|
+
* If true,
|
|
6
|
+
* attachments will also be saved
|
|
7
|
+
*/
|
|
8
|
+
attachments?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* How many documents can be processed in one batch
|
|
11
|
+
* [default=10]
|
|
12
|
+
*/
|
|
13
|
+
batchSize?: number;
|
|
14
|
+
/**
|
|
15
|
+
* If not set, all collections will be backed up.
|
|
16
|
+
*/
|
|
17
|
+
collections?: string[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type BackupMetaFileContent = {
|
|
21
|
+
createdAt: number;
|
|
22
|
+
updatedAt: number;
|
|
23
|
+
collectionStates: {
|
|
24
|
+
[collectionName: string]: {
|
|
25
|
+
checkpoint?: any;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type RxBackupWriteEvent = {
|
|
31
|
+
collectionName: string;
|
|
32
|
+
documentId: string;
|
|
33
|
+
files: string[];
|
|
34
|
+
deleted: boolean;
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type RxCleanupPolicy = {
|
|
2
|
+
/**
|
|
3
|
+
* The minimum time in milliseconds
|
|
4
|
+
* of how long a document must have been deleted
|
|
5
|
+
* until it is purged by the cleanup.
|
|
6
|
+
* This should be higher then the time you expect
|
|
7
|
+
* your user to be offline for.
|
|
8
|
+
* If this is too low, deleted documents might not
|
|
9
|
+
* replicate their deletion state.
|
|
10
|
+
*/
|
|
11
|
+
minimumDeletedTime: number;
|
|
12
|
+
/**
|
|
13
|
+
* The minimum amount of time that the RxCollection must have existed.
|
|
14
|
+
* This ensures that at the initial page load, more important
|
|
15
|
+
* tasks are not slowed down because a cleanup process is running.
|
|
16
|
+
*/
|
|
17
|
+
minimumCollectionAge: number;
|
|
18
|
+
/**
|
|
19
|
+
* After the initial cleanup is done,
|
|
20
|
+
* a new cleanup is started after [runEach] milliseconds
|
|
21
|
+
*/
|
|
22
|
+
runEach: number;
|
|
23
|
+
/**
|
|
24
|
+
* If set to true,
|
|
25
|
+
* RxDB will await all running replications
|
|
26
|
+
* to not have a replication cycle running.
|
|
27
|
+
* This ensures we do not remove deleted documents
|
|
28
|
+
* when they might not have already been replicated.
|
|
29
|
+
*/
|
|
30
|
+
awaitReplicationsInSync: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If true, it will only start the cleanup
|
|
33
|
+
* when the current instance is also the leader.
|
|
34
|
+
* This ensures that when RxDB is used in multiInstance mode,
|
|
35
|
+
* only one instance will start the cleanup.
|
|
36
|
+
*/
|
|
37
|
+
waitForLeadership: boolean;
|
|
38
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { MangoQuerySelector } from '../rx-query.d.ts';
|
|
2
|
+
import type { StringKeys } from '../util.d.ts';
|
|
3
|
+
import type { UpdateQuery } from './update.d.ts';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type CRDTEntry<RxDocType> = {
|
|
7
|
+
selector?: MangoQuerySelector<RxDocType>;
|
|
8
|
+
ifMatch?: UpdateQuery<RxDocType>;
|
|
9
|
+
ifNotMatch?: UpdateQuery<RxDocType>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for the crdt plugin.
|
|
14
|
+
* We set these in the schema because changing them
|
|
15
|
+
* is not possible on the fly because it would
|
|
16
|
+
* close the document state in an unpredictable way.
|
|
17
|
+
*/
|
|
18
|
+
export type CRDTSchemaOptions<RxDocType> = {
|
|
19
|
+
/**
|
|
20
|
+
* Determines which field of the document must be used
|
|
21
|
+
* to store the crdt operations.
|
|
22
|
+
* The given field must exist with the content of "CRDT_FIELD_SCHEMA" in the
|
|
23
|
+
* properties part of your schema.
|
|
24
|
+
*/
|
|
25
|
+
field: StringKeys<RxDocType> | string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* After BOTH of the limits
|
|
29
|
+
* maxOperations/maxTTL is reached,
|
|
30
|
+
* the document will clean up the stored operations
|
|
31
|
+
* and merged them together to ensure
|
|
32
|
+
* that not too many operations are stored which could slow down the
|
|
33
|
+
* database operations.
|
|
34
|
+
*/
|
|
35
|
+
// TODO not implemented yet, make a pull request if you need that.
|
|
36
|
+
// maxOperations: number;
|
|
37
|
+
// maxTTL: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export type CRDTOperation<RxDocType> = {
|
|
42
|
+
body: CRDTEntry<RxDocType>[];
|
|
43
|
+
/**
|
|
44
|
+
* A string to uniquely represent the creator
|
|
45
|
+
* of this operation.
|
|
46
|
+
* Mostly you would use the RxDatabase().storageToken().
|
|
47
|
+
*/
|
|
48
|
+
creator: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Unix time in milliseconds
|
|
52
|
+
* that determines when the operation was created.
|
|
53
|
+
* Used to properly clean up old operations.
|
|
54
|
+
*/
|
|
55
|
+
time: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export type CRDTDocumentField<RxDocType> = {
|
|
60
|
+
/**
|
|
61
|
+
* An array with arrays of CRDT operations.
|
|
62
|
+
* The index of the top level array is equal
|
|
63
|
+
* to the revision height where the operations
|
|
64
|
+
* belong to.
|
|
65
|
+
* Sorted by revision height ascending.
|
|
66
|
+
* If we have a conflict and we need a rebuild,
|
|
67
|
+
* the operations will be run in the revision height
|
|
68
|
+
* sort order to make everything deterministic.
|
|
69
|
+
*/
|
|
70
|
+
operations: CRDTOperation<RxDocType>[][];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A hash to uniquely define the whole operations state.
|
|
74
|
+
*/
|
|
75
|
+
hash: string;
|
|
76
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Dexie,
|
|
3
|
+
DexieOptions,
|
|
4
|
+
Table as DexieTable
|
|
5
|
+
} from 'dexie';
|
|
6
|
+
import type { MaybePromise } from '../util';
|
|
7
|
+
|
|
8
|
+
export type DexieSettings = DexieOptions & {
|
|
9
|
+
onCreate?: (db: Dexie, dbName: string) => MaybePromise<void>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The internals is a Promise that resolves
|
|
14
|
+
* when the database has fully opened
|
|
15
|
+
* and Dexie.on.ready was called
|
|
16
|
+
* @link https://dexie.org/docs/Dexie/Dexie.on.ready
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export type DexieStorageInternals = Promise<{
|
|
20
|
+
dexieDb: Dexie;
|
|
21
|
+
/**
|
|
22
|
+
* Contains all normal documents. Deleted ones and non-deleted ones.
|
|
23
|
+
*/
|
|
24
|
+
dexieTable: DexieTable;
|
|
25
|
+
// contains the attachments data
|
|
26
|
+
dexieAttachmentsTable: DexieTable;
|
|
27
|
+
|
|
28
|
+
// these must be transformed because indexeddb does not allow boolean indexing
|
|
29
|
+
booleanIndexes: string[];
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import type { DocumentCache } from '../../doc-cache.d.ts';
|
|
3
|
+
import type { IncrementalWriteQueue } from '../../incremental-write.d.ts';
|
|
4
|
+
import type { RxCollection } from '../rx-collection.d.ts';
|
|
5
|
+
import type { RxDatabase } from '../rx-database.d.ts';
|
|
6
|
+
import type { RxDocumentBase } from '../rx-document.d.ts';
|
|
7
|
+
import type { RxStorageInstance } from '../rx-storage.interface.d.ts';
|
|
8
|
+
import type { Override } from '../util.d.ts';
|
|
9
|
+
|
|
10
|
+
export type LocalDocumentParent = RxDatabase | RxCollection;
|
|
11
|
+
export type LocalDocumentState = {
|
|
12
|
+
database: RxDatabase;
|
|
13
|
+
parent: LocalDocumentParent;
|
|
14
|
+
storageInstance: RxStorageInstance<RxLocalDocumentData, any, any>;
|
|
15
|
+
docCache: DocumentCache<RxLocalDocumentData, {}>;
|
|
16
|
+
incrementalWriteQueue: IncrementalWriteQueue<RxLocalDocumentData>;
|
|
17
|
+
};
|
|
18
|
+
export type RxLocalDocumentData<
|
|
19
|
+
Data = {
|
|
20
|
+
// local documents are schemaless and contain any data
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
> = {
|
|
24
|
+
id: string;
|
|
25
|
+
data: Data;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare type LocalDocumentModifyFunction<Data> = (
|
|
29
|
+
doc: Data,
|
|
30
|
+
rxLocalDocument: RxLocalDocument<any, Data>
|
|
31
|
+
) => Data | Promise<Data>;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export declare type RxLocalDocument<Parent, Data = any, Reactivity = unknown> = Override<
|
|
35
|
+
RxDocumentBase<RxLocalDocumentData<Data>, {}, Reactivity>,
|
|
36
|
+
{
|
|
37
|
+
readonly parent: Parent;
|
|
38
|
+
isLocal(): true;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Because local documents store their relevant data inside of the 'data' property,
|
|
42
|
+
* the incremental mutation methods are changed a bit to only allow to change parts of the data property.
|
|
43
|
+
*/
|
|
44
|
+
incrementalModify(mutationFunction: LocalDocumentModifyFunction<Data>): Promise<RxLocalDocument<Parent, Data, Reactivity>>;
|
|
45
|
+
incrementalPatch(patch: Partial<Data>): Promise<RxLocalDocument<Parent, Data, Reactivity>>;
|
|
46
|
+
|
|
47
|
+
$: Observable<RxLocalDocument<Parent, Data, Reactivity>>;
|
|
48
|
+
}
|
|
49
|
+
>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WithAttachments
|
|
3
|
+
} from '../couchdb.d.ts';
|
|
4
|
+
import type { RxCollection } from '../rx-collection.d.ts';
|
|
5
|
+
import type { MaybePromise } from '../util.d.ts';
|
|
6
|
+
|
|
7
|
+
export type MigrationStrategy<DocData = any> = (
|
|
8
|
+
oldDocumentData: WithAttachments<DocData>,
|
|
9
|
+
collection: RxCollection
|
|
10
|
+
) => MaybePromise<WithAttachments<DocData> | null>;
|
|
11
|
+
|
|
12
|
+
export type MigrationStrategies<DocData = any> = {
|
|
13
|
+
[toVersion: number]: MigrationStrategy<DocData>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import type { RxDatabase } from '../rx-database';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for encoding Higher Kinded Types (HKT) in TypeScript.
|
|
6
|
+
* Reactivity plugins extend this to define a type-level function
|
|
7
|
+
* that maps a data type T to a reactive container (e.g. Signal<T>, Ref<T>).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Preact signals plugin defines:
|
|
11
|
+
* interface PreactSignalReactivityLambda extends ReactivityLambda {
|
|
12
|
+
* readonly _result: Signal<this['_data']>;
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export interface ReactivityLambda {
|
|
16
|
+
readonly _data: unknown;
|
|
17
|
+
readonly _result: unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Applies a reactivity type-level function to a data type.
|
|
22
|
+
* Given a ReactivityLambda and a data type T, returns the concrete
|
|
23
|
+
* reactive container type (e.g. Signal<T>, Ref<T>).
|
|
24
|
+
*
|
|
25
|
+
* For backwards compatibility, if the Reactivity parameter is not
|
|
26
|
+
* a ReactivityLambda (e.g. it is `Signal<any>` directly), it is
|
|
27
|
+
* returned as-is.
|
|
28
|
+
*/
|
|
29
|
+
export type Reactified<Reactivity, T> =
|
|
30
|
+
Reactivity extends ReactivityLambda
|
|
31
|
+
? (Reactivity & { readonly _data: T })['_result']
|
|
32
|
+
: Reactivity;
|
|
33
|
+
|
|
34
|
+
export interface RxReactivityFactory<Reactivity> {
|
|
35
|
+
fromObservable<Data, InitData>(
|
|
36
|
+
obs: Observable<Data>,
|
|
37
|
+
initialValue: InitData,
|
|
38
|
+
rxDatabase: RxDatabase<any, any, any, Reactivity>
|
|
39
|
+
): Reactified<Reactivity, Data | InitData>;
|
|
40
|
+
}
|