@dittolive/ditto 1.1.9 → 2.0.0-alpha1
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/README.md +3 -3
- package/index.html +1 -1
- package/node/ditto.cjs.js +1 -1
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +1 -1
- package/playground.cjs +1 -1
- package/types/ditto.d.ts +322 -515
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
package/types/ditto.d.ts
CHANGED
|
@@ -9,10 +9,6 @@ declare type SortDirection = 'ascending' | 'descending';
|
|
|
9
9
|
* - `merge`: the existing document will be merged with the document being
|
|
10
10
|
* inserted, if there is a pre-existing document.
|
|
11
11
|
*
|
|
12
|
-
* - `overwrite`: an existing document will be overwritten. This can be thought
|
|
13
|
-
* of as first removing the existing document completely and then inserting
|
|
14
|
-
* the new document in its place, if there is a pre-existing document.
|
|
15
|
-
*
|
|
16
12
|
* - `insertIfAbsent`: insert the document only if there is not already a
|
|
17
13
|
* document with the same ID in the store. If there is already a document in
|
|
18
14
|
* the store with the same ID then this will be a no-op.
|
|
@@ -25,7 +21,7 @@ declare type SortDirection = 'ascending' | 'descending';
|
|
|
25
21
|
* data amongst all peers and that you expect to be mutated or overwritten in
|
|
26
22
|
* due course.
|
|
27
23
|
*/
|
|
28
|
-
declare type WriteStrategy = 'merge' | '
|
|
24
|
+
declare type WriteStrategy = 'merge' | 'insertIfAbsent' | 'insertDefaultIfAbsent';
|
|
29
25
|
/**
|
|
30
26
|
* Represents a dictionary of values to be incorporated into a query keyed
|
|
31
27
|
* by the placeholder used within that query. See method
|
|
@@ -41,11 +37,14 @@ declare type Pointer<Type> = {
|
|
|
41
37
|
addr: string;
|
|
42
38
|
};
|
|
43
39
|
/** @internal */
|
|
44
|
-
declare type
|
|
40
|
+
declare type FFIAuthClient = 'CAuthClient_t';
|
|
41
|
+
/** @internal */
|
|
45
42
|
declare type OrderBy = {
|
|
46
43
|
query: string;
|
|
47
44
|
direction: 'Ascending' | 'Descending';
|
|
48
45
|
};
|
|
46
|
+
/** @internal */
|
|
47
|
+
declare type PathAccessorType = 'String' | 'Number' | 'Int' | 'UInt' | 'Float' | 'Double' | 'Bool' | 'Null' | 'Object' | 'Array' | 'Any' | 'Counter' | 'Register' | 'Attachment' | 'Rga' | 'RWMap';
|
|
49
48
|
/** Various options to pass the web assembly module to Ditto. */
|
|
50
49
|
declare type WebAssemblyModule = RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null;
|
|
51
50
|
|
|
@@ -237,31 +236,6 @@ declare class TransportConfig {
|
|
|
237
236
|
static areListenHTTPsEqual(left: TransportConfigListenHTTP, right: TransportConfigListenHTTP): boolean;
|
|
238
237
|
}
|
|
239
238
|
|
|
240
|
-
/**
|
|
241
|
-
* An identity to be used while in development when you want to control the app
|
|
242
|
-
* name and the site ID of the peer.
|
|
243
|
-
*
|
|
244
|
-
* @deprecated Renamed to {@link IdentityOfflinePlayground}, please use that
|
|
245
|
-
* instead.
|
|
246
|
-
*/
|
|
247
|
-
interface IdentityDevelopment {
|
|
248
|
-
type: 'development';
|
|
249
|
-
/**
|
|
250
|
-
* The app ID for the Ditto instance. This property is marked optional for
|
|
251
|
-
* backwards compatibility with the now deprecated {@link appName}. One of
|
|
252
|
-
* those must be given otherwise Ditto will throw an exception at
|
|
253
|
-
* construction time.
|
|
254
|
-
*/
|
|
255
|
-
appID?: string;
|
|
256
|
-
/**
|
|
257
|
-
* The `siteID` needs to be an unsigned 64 bit integer >= 0, i.e. either a
|
|
258
|
-
* regular non-fractional `number` or a `BigInt` in the range between 0 and
|
|
259
|
-
* 2^64 - 1 (inclusive). If `siteID` is `0`, Ditto will generate an
|
|
260
|
-
* appropriate site ID and persist it when needed. Default is `0`.
|
|
261
|
-
*/
|
|
262
|
-
siteID?: number | BigInt;
|
|
263
|
-
appName?: string;
|
|
264
|
-
}
|
|
265
239
|
/**
|
|
266
240
|
* An identity to be used while in development when you want to control the app
|
|
267
241
|
* name and the site ID of the peer.
|
|
@@ -269,12 +243,9 @@ interface IdentityDevelopment {
|
|
|
269
243
|
interface IdentityOfflinePlayground {
|
|
270
244
|
type: 'offlinePlayground';
|
|
271
245
|
/**
|
|
272
|
-
* The app ID for the Ditto instance.
|
|
273
|
-
* backwards compatibility with the now deprecated {@link appName}. One of
|
|
274
|
-
* those must be given otherwise Ditto will throw an exception at
|
|
275
|
-
* construction time.
|
|
246
|
+
* The app ID for the Ditto instance.
|
|
276
247
|
*/
|
|
277
|
-
appID
|
|
248
|
+
appID: string;
|
|
278
249
|
/**
|
|
279
250
|
* The `siteID` needs to be an unsigned 64 bit integer >= 0, i.e. either a
|
|
280
251
|
* regular non-fractional `number` or a `BigInt` in the range between 0 and
|
|
@@ -282,7 +253,6 @@ interface IdentityOfflinePlayground {
|
|
|
282
253
|
* appropriate site ID and persist it when needed. Default is `0`.
|
|
283
254
|
*/
|
|
284
255
|
siteID?: number | BigInt;
|
|
285
|
-
appName?: string;
|
|
286
256
|
}
|
|
287
257
|
/**
|
|
288
258
|
* An identity with intermediate level of security where all users and devices
|
|
@@ -295,12 +265,9 @@ interface IdentityOfflinePlayground {
|
|
|
295
265
|
interface IdentitySharedKey {
|
|
296
266
|
type: 'sharedKey';
|
|
297
267
|
/**
|
|
298
|
-
* The app ID for the Ditto instance.
|
|
299
|
-
* backwards compatibility with the now deprecated {@link appName}. One of
|
|
300
|
-
* those must be given otherwise Ditto will throw an exception at
|
|
301
|
-
* construction time.
|
|
268
|
+
* The app ID for the Ditto instance.
|
|
302
269
|
*/
|
|
303
|
-
appID
|
|
270
|
+
appID: string;
|
|
304
271
|
/**
|
|
305
272
|
* The `siteID` needs to be an unsigned 64 bit integer >= 0, i.e. either a
|
|
306
273
|
* regular non-fractional `number` or a `BigInt` in the range between 0 and
|
|
@@ -313,53 +280,21 @@ interface IdentitySharedKey {
|
|
|
313
280
|
* between devices for a single app.
|
|
314
281
|
*/
|
|
315
282
|
sharedKey: string;
|
|
316
|
-
appName?: string;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* The identity to use when in production. This accepts a certificate bundle,
|
|
320
|
-
* which includes identity information, as a base 64 encoded string.
|
|
321
|
-
*
|
|
322
|
-
* @deprecated Renamed to {@link IdentityManual}, please use that instead.
|
|
323
|
-
*/
|
|
324
|
-
interface IdentityProduction {
|
|
325
|
-
type: 'production';
|
|
326
|
-
certificate: string;
|
|
327
283
|
}
|
|
328
284
|
/**
|
|
329
285
|
* A manually-provided certificate identity. This accepts a
|
|
330
|
-
* base64-encoded bundle.
|
|
286
|
+
* base64-encoded bundle.
|
|
331
287
|
*/
|
|
332
288
|
interface IdentityManual {
|
|
333
289
|
type: 'manual';
|
|
334
290
|
certificate: string;
|
|
335
291
|
}
|
|
336
|
-
/**
|
|
337
|
-
* Deprecated - use `IdentityOnlinePlaygroundV2` instead.
|
|
338
|
-
*
|
|
339
|
-
* Test a Ditto Cloud app without authentication ("Playground mode"). This mode
|
|
340
|
-
* offers no security and must only be used for development.
|
|
341
|
-
*/
|
|
342
|
-
interface IdentityOnlinePlayground {
|
|
343
|
-
type: 'onlinePlayground';
|
|
344
|
-
/**
|
|
345
|
-
* An ID identifying this app registration on the Ditto portal, which can be
|
|
346
|
-
* found at https://portal.ditto.live.
|
|
347
|
-
*/
|
|
348
|
-
appID: string;
|
|
349
|
-
/** If true, auto-configure sync with Ditto Cloud. Default is `true`. */
|
|
350
|
-
enableDittoCloudSync?: boolean;
|
|
351
|
-
/**
|
|
352
|
-
* A custom Ditto Cloud URL.
|
|
353
|
-
* @internal
|
|
354
|
-
*/
|
|
355
|
-
customDittoCloudURL?: string;
|
|
356
|
-
}
|
|
357
292
|
/**
|
|
358
293
|
* Test a Ditto Cloud app with weak shared token authentication ("Playground
|
|
359
294
|
* mode"). This mode is not secure and must only be used for development.
|
|
360
295
|
*/
|
|
361
|
-
interface
|
|
362
|
-
type: '
|
|
296
|
+
interface IdentityOnlinePlayground {
|
|
297
|
+
type: 'onlinePlayground';
|
|
363
298
|
/**
|
|
364
299
|
* An ID identifying this app registration on the Ditto portal, which can be
|
|
365
300
|
* found at https://portal.ditto.live.
|
|
@@ -383,56 +318,6 @@ interface IdentityOnlinePlaygroundV2 {
|
|
|
383
318
|
*/
|
|
384
319
|
customDittoCloudURL?: string;
|
|
385
320
|
}
|
|
386
|
-
/**
|
|
387
|
-
* Deprecated - use `IdentityOnlineWithAuthentication` instead.
|
|
388
|
-
*
|
|
389
|
-
* Run Ditto in secure production mode, logging on to Ditto Cloud or an
|
|
390
|
-
* on-premises authentication server. User permissions are centrally managed.
|
|
391
|
-
* Sync will not work until a successful login has occurred.
|
|
392
|
-
*
|
|
393
|
-
* The only required configuration is the application's UUID, which can be found
|
|
394
|
-
* on the Ditto portal where the app is registered.
|
|
395
|
-
*
|
|
396
|
-
* By default cloud sync is enabled. This means the SDK will sync to a Big Peer
|
|
397
|
-
* in Ditto's cloud when an internet connection is available. This is controlled
|
|
398
|
-
* by the `enableCloudSync` parameter. If `true` (default), a suitable wss://
|
|
399
|
-
* URL will be added to the `TransportConfig`. To prevent cloud sync, or to
|
|
400
|
-
* specify your own URL later, pass `false`.
|
|
401
|
-
*
|
|
402
|
-
* Authentication requests are handled by Ditto's cloud by default, configured
|
|
403
|
-
* in the portal at https://portal.ditto.live.
|
|
404
|
-
*
|
|
405
|
-
* To use a different or on-premises authentication service, pass a custom HTTPS
|
|
406
|
-
* base URL as the `customAuthUrl` parameter.
|
|
407
|
-
*
|
|
408
|
-
* @deprecated Renamed to {@link IdentityOnlineWithAuthentication}, please use
|
|
409
|
-
* that instead.
|
|
410
|
-
*/
|
|
411
|
-
interface IdentityOnline {
|
|
412
|
-
type: 'online';
|
|
413
|
-
/**
|
|
414
|
-
* An ID identifying this app registration on the Ditto portal, which can be
|
|
415
|
-
* found at https://portal.ditto.live.
|
|
416
|
-
*/
|
|
417
|
-
appID: string;
|
|
418
|
-
/**
|
|
419
|
-
* If true, auto-configure sync with Ditto Cloud. Default is `true`.
|
|
420
|
-
*/
|
|
421
|
-
enableDittoCloudSync?: boolean;
|
|
422
|
-
/**
|
|
423
|
-
* A handler for when Ditto requires (re)authentication.
|
|
424
|
-
*/
|
|
425
|
-
authHandler: AuthenticationHandler;
|
|
426
|
-
/**
|
|
427
|
-
* If specified, use a custom authentication service instead of Ditto Cloud.
|
|
428
|
-
*/
|
|
429
|
-
customAuthURL?: string;
|
|
430
|
-
/**
|
|
431
|
-
* A custom Ditto Cloud URL.
|
|
432
|
-
* @internal
|
|
433
|
-
*/
|
|
434
|
-
customDittoCloudURL?: string;
|
|
435
|
-
}
|
|
436
321
|
/**
|
|
437
322
|
* Run Ditto in secure production mode, logging on to Ditto Cloud or an
|
|
438
323
|
* on-premises authentication server. User permissions are centrally managed.
|
|
@@ -482,7 +367,7 @@ interface IdentityOnlineWithAuthentication {
|
|
|
482
367
|
* The various identity configurations that you can use when initializing a
|
|
483
368
|
* `Ditto` instance.
|
|
484
369
|
*/
|
|
485
|
-
declare type Identity =
|
|
370
|
+
declare type Identity = IdentityOfflinePlayground | IdentitySharedKey | IdentityManual | IdentityOnlinePlayground | IdentityOnlineWithAuthentication;
|
|
486
371
|
/** The list of identity types that require activation through an offlineLicenseToken */
|
|
487
372
|
declare const IdentityTypesRequiringOfflineLicenseToken: string[];
|
|
488
373
|
|
|
@@ -585,6 +470,165 @@ declare class UpdateResult {
|
|
|
585
470
|
private constructor();
|
|
586
471
|
}
|
|
587
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Represents a CRDT counter that can be upserted as part of a document or
|
|
475
|
+
* assigned to a property during an update of a document.
|
|
476
|
+
*/
|
|
477
|
+
declare class Counter {
|
|
478
|
+
/** The value of the counter. */
|
|
479
|
+
readonly value: number;
|
|
480
|
+
/**
|
|
481
|
+
* Creates a new counter that can be used as part of a document's content.
|
|
482
|
+
*/
|
|
483
|
+
constructor();
|
|
484
|
+
/** @internal */
|
|
485
|
+
static '@ditto.create'(mutDoc: any, path: any, value: any): any;
|
|
486
|
+
private mutDoc;
|
|
487
|
+
private path;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Represents a mutable CRDT counter that can be incremented by a specific
|
|
491
|
+
* amount while updating a document.
|
|
492
|
+
*
|
|
493
|
+
* This class can't be instantiated directly, it's returned automatically for
|
|
494
|
+
* any counter property within an update block via {@link MutableDocumentPath.counter}.
|
|
495
|
+
*/
|
|
496
|
+
declare class MutableCounter extends Counter {
|
|
497
|
+
constructor();
|
|
498
|
+
/**
|
|
499
|
+
* Increments the counter by `amount`, which can be any valid number. Only
|
|
500
|
+
* valid within the closure of {@link Collection}'s {@link Collection.update | update()}
|
|
501
|
+
* method, otherwise an exception is thrown.
|
|
502
|
+
*/
|
|
503
|
+
increment(amount: number): void;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Represents a CRDT register that can be upserted as part of a document or
|
|
508
|
+
* assigned to a property during an update of a document.
|
|
509
|
+
*/
|
|
510
|
+
declare class Register {
|
|
511
|
+
/** Returns the value of the register. */
|
|
512
|
+
get value(): any;
|
|
513
|
+
/**
|
|
514
|
+
* Creates a new Register that can be used as part of a document's content.
|
|
515
|
+
*/
|
|
516
|
+
constructor(value: any);
|
|
517
|
+
/** @internal */
|
|
518
|
+
static '@ditto.create'(mutableDocument: any, path: any, value: any): any;
|
|
519
|
+
/** @internal */
|
|
520
|
+
protected '@ditto.mutableDocument': any;
|
|
521
|
+
/** @internal */
|
|
522
|
+
protected '@ditto.path': any;
|
|
523
|
+
/** @internal */
|
|
524
|
+
protected '@ditto.value': any;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Represents a mutable CRDT register that can be set to a specific value when
|
|
528
|
+
* updating a document.
|
|
529
|
+
*
|
|
530
|
+
* This class can't be instantiated directly, it's returned automatically for
|
|
531
|
+
* any register property of a document within an update block via {@link MutableDocumentPath.register}.
|
|
532
|
+
*/
|
|
533
|
+
declare class MutableRegister extends Register {
|
|
534
|
+
constructor(value: any);
|
|
535
|
+
/** Returns the value of the register. */
|
|
536
|
+
get value(): any;
|
|
537
|
+
/**
|
|
538
|
+
* Sets the register to the provided value. Only valid within the closure of
|
|
539
|
+
* {@link Collection}'s {@link Collection.update | update()}
|
|
540
|
+
* method, otherwise an exception is thrown.
|
|
541
|
+
*/
|
|
542
|
+
set value(value: any);
|
|
543
|
+
set(value: any): void;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Represents a CRDT Replicated Growable Array (RGA) that can be
|
|
548
|
+
* upserted as part of a document or assigned to a property during an
|
|
549
|
+
* update of a document.
|
|
550
|
+
*/
|
|
551
|
+
declare class RGA {
|
|
552
|
+
/** The array representation of the RGA. */
|
|
553
|
+
get value(): any[];
|
|
554
|
+
/**
|
|
555
|
+
* Constructs a new RGA that can be used as part of a document's content.
|
|
556
|
+
*
|
|
557
|
+
* @param array - The array to use as the RGA's representation.
|
|
558
|
+
*/
|
|
559
|
+
constructor(array?: any[]);
|
|
560
|
+
/** @internal */
|
|
561
|
+
static '@ditto.create'(mutableDocument: any, path: any, value: any): any;
|
|
562
|
+
/** @internal */
|
|
563
|
+
protected '@ditto.mutableDocument': any;
|
|
564
|
+
/** @internal */
|
|
565
|
+
protected '@ditto.path': any;
|
|
566
|
+
/** @internal */
|
|
567
|
+
protected '@ditto.value': any;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Represents a mutable CRDT RGA that can be set to a specific value when
|
|
571
|
+
* updating a document.
|
|
572
|
+
*
|
|
573
|
+
* This class can't be instantiated directly, it's returned automatically for
|
|
574
|
+
* any `rga` property of a document within an update block via {@link MutableDocumentPath.rga}.
|
|
575
|
+
*/
|
|
576
|
+
declare class MutableRGA extends RGA {
|
|
577
|
+
constructor(value: any);
|
|
578
|
+
/** Returns the value of the RGA. */
|
|
579
|
+
get value(): any[];
|
|
580
|
+
/**
|
|
581
|
+
* Set a value at the specified index.
|
|
582
|
+
*
|
|
583
|
+
* @param value - The value to set at the specified index.
|
|
584
|
+
* @param index - The index at which to set the provided value.
|
|
585
|
+
*/
|
|
586
|
+
setAt(value: any, index: number): void;
|
|
587
|
+
/**
|
|
588
|
+
* Remove a value at the specified index.
|
|
589
|
+
*
|
|
590
|
+
* @param index - The index of the element to remove.
|
|
591
|
+
*/
|
|
592
|
+
removeAt(index: number): void;
|
|
593
|
+
/**
|
|
594
|
+
* Push a value on to the end of the RGA.
|
|
595
|
+
*
|
|
596
|
+
* @param value - The value to push on to the RGA.
|
|
597
|
+
*/
|
|
598
|
+
push(value: any): void;
|
|
599
|
+
/**
|
|
600
|
+
* Pop a value off the end of the RGA.
|
|
601
|
+
*
|
|
602
|
+
* @return The value popped off from the end of the RGA.
|
|
603
|
+
*/
|
|
604
|
+
pop(): any | null;
|
|
605
|
+
/**
|
|
606
|
+
* Inserts a value into an the RGA at the index specified.
|
|
607
|
+
*
|
|
608
|
+
* @param value - The value to insert into the RGA.
|
|
609
|
+
* @param index - The index at which to insert the provided value.
|
|
610
|
+
*/
|
|
611
|
+
insertAt(value: any, index: number): void;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Serves as a token for a specific attachment that you can pass to a call to
|
|
616
|
+
* {@link Collection.fetchAttachment | fetchAttachment()} on a
|
|
617
|
+
* {@link Collection}.
|
|
618
|
+
*/
|
|
619
|
+
declare class AttachmentToken {
|
|
620
|
+
/** @internal */
|
|
621
|
+
readonly id: Uint8Array;
|
|
622
|
+
/** @internal */
|
|
623
|
+
readonly len: number;
|
|
624
|
+
/** @internal */
|
|
625
|
+
readonly metadata: {
|
|
626
|
+
[key: string]: string;
|
|
627
|
+
};
|
|
628
|
+
/** @internal */
|
|
629
|
+
constructor(jsObj: object);
|
|
630
|
+
}
|
|
631
|
+
|
|
588
632
|
/**
|
|
589
633
|
* Provides an interface to specify a path to a key in a document that you can
|
|
590
634
|
* then call a function on to get the value at the specified key as a specific
|
|
@@ -597,25 +641,54 @@ declare class DocumentPath {
|
|
|
597
641
|
/** The full document path so far. */
|
|
598
642
|
readonly path: string;
|
|
599
643
|
/**
|
|
600
|
-
* Returns a new document path instance with the passed in
|
|
601
|
-
*
|
|
644
|
+
* Returns a new document path instance with the passed in key-path or
|
|
645
|
+
* index appended.
|
|
646
|
+
*
|
|
647
|
+
* A key-path can be a single property name or multiple property names
|
|
648
|
+
* separated by a dot. Indexes can also be specified as part of the key
|
|
649
|
+
* path using square brackets syntax. The empty string returns a document path
|
|
650
|
+
* representing the same portion of the document as the receiver. If a key
|
|
651
|
+
* path starts with a property name and is prefixed by a dot, the dot is
|
|
652
|
+
* ignored.
|
|
653
|
+
*
|
|
654
|
+
* Examples:
|
|
655
|
+
*
|
|
656
|
+
* - `documentPath.at('mileage')`
|
|
657
|
+
* - `documentPath.at('driver.name')`
|
|
658
|
+
* - `documentPath.at('passengers[2]')`
|
|
659
|
+
* - `documentPath.at('passengers[2].belongings[1].kind')`
|
|
660
|
+
* - `documentPath.at('.mileage')`
|
|
602
661
|
*/
|
|
603
662
|
at(keyPathOrIndex: string | number): DocumentPath;
|
|
604
663
|
/**
|
|
605
664
|
* Traverses the document with the key path represented by the receiver and
|
|
606
665
|
* returns the corresponding object or value.
|
|
607
666
|
*/
|
|
608
|
-
value(): any;
|
|
609
|
-
/** @internal */
|
|
610
|
-
constructor(document: Document, path: string);
|
|
667
|
+
get value(): any | undefined;
|
|
611
668
|
/**
|
|
612
|
-
* Returns
|
|
613
|
-
*
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
669
|
+
* Returns the value at the previously specified key in the document as a
|
|
670
|
+
* `Counter` if possible, otherwise returns `null`.
|
|
671
|
+
*/
|
|
672
|
+
get counter(): Counter | null;
|
|
673
|
+
/**
|
|
674
|
+
* Returns the value at the previously specified key in the document as a
|
|
675
|
+
* `Register` if possible, otherwise returns `null`.
|
|
676
|
+
*/
|
|
677
|
+
get register(): Register | null;
|
|
678
|
+
/**
|
|
679
|
+
* Returns the value at the previously specified key in the document as a
|
|
680
|
+
* `RGA` if possible, otherwise returns `null`.
|
|
681
|
+
*/
|
|
682
|
+
get rga(): RGA | null;
|
|
683
|
+
/**
|
|
684
|
+
* Returns the value at the previously specified key in the document as a
|
|
685
|
+
* `AttachmentToken` if possible, otherwise returns `null`.
|
|
617
686
|
*/
|
|
618
|
-
|
|
687
|
+
get attachmentToken(): AttachmentToken | null;
|
|
688
|
+
/** @internal */
|
|
689
|
+
constructor(document: Document, path: string, validate: boolean);
|
|
690
|
+
/** @internal */
|
|
691
|
+
underlyingValueForPathType(pathType: PathAccessorType): any | undefined;
|
|
619
692
|
}
|
|
620
693
|
/**
|
|
621
694
|
* Mutable version of {@link DocumentPath} allowing you to mutate a document at
|
|
@@ -628,15 +701,50 @@ declare class MutableDocumentPath {
|
|
|
628
701
|
/** The full document path so far. */
|
|
629
702
|
readonly path: string;
|
|
630
703
|
/**
|
|
631
|
-
* Returns a new mutable document path instance with the passed in
|
|
632
|
-
* appended
|
|
704
|
+
* Returns a new mutable document path instance with the passed in key-path or
|
|
705
|
+
* index appended.
|
|
706
|
+
*
|
|
707
|
+
* A key-path can be a single property name or multiple property names
|
|
708
|
+
* separated by a dot. Indexes can also be specified as part of the key
|
|
709
|
+
* path using square brackets syntax. The empty string returns a document path
|
|
710
|
+
* representing the same portion of the document as the receiver. If a key
|
|
711
|
+
* path starts with a property name and is prefixed by a dot, the dot is
|
|
712
|
+
* ignored.
|
|
713
|
+
*
|
|
714
|
+
* Examples:
|
|
715
|
+
*
|
|
716
|
+
* - `mutableDocumentPath.at('mileage')`
|
|
717
|
+
* - `mutableDocumentPath.at('driver.name')`
|
|
718
|
+
* - `mutableDocumentPath.at('passengers[2]')`
|
|
719
|
+
* - `mutableDocumentPath.at('passengers[2].belongings[1].kind')`
|
|
720
|
+
* - `mutableDocumentPath.at('.mileage')`
|
|
633
721
|
*/
|
|
634
722
|
at(keyPathOrIndex: string | number): MutableDocumentPath;
|
|
635
723
|
/**
|
|
636
724
|
* Traverses the document with the key path represented by the receiver and
|
|
637
725
|
* returns the corresponding object or value.
|
|
638
726
|
*/
|
|
639
|
-
value(): any;
|
|
727
|
+
get value(): any | undefined;
|
|
728
|
+
/**
|
|
729
|
+
* Returns the value at the previously specified key in the document as a
|
|
730
|
+
* `MutableCounter` if possible, otherwise returns `null`.
|
|
731
|
+
*/
|
|
732
|
+
get counter(): MutableCounter | null;
|
|
733
|
+
/**
|
|
734
|
+
* Returns the value at the previously specified key in the document as a
|
|
735
|
+
* `MutableRegister` if possible, otherwise returns `null`.
|
|
736
|
+
*/
|
|
737
|
+
get register(): MutableRegister | null;
|
|
738
|
+
/**
|
|
739
|
+
* Returns the value at the previously specified key in the document as a
|
|
740
|
+
* `MutableRGA` if possible, otherwise returns `null`.
|
|
741
|
+
*/
|
|
742
|
+
get rga(): MutableRGA | null;
|
|
743
|
+
/**
|
|
744
|
+
* Returns the value at the previously specified key in the document as a
|
|
745
|
+
* `AttachmentToken` if possible, otherwise returns `null`.
|
|
746
|
+
*/
|
|
747
|
+
get attachmentToken(): AttachmentToken | null;
|
|
640
748
|
/**
|
|
641
749
|
* Sets a value at the document's key path defined by the receiver.
|
|
642
750
|
*
|
|
@@ -648,83 +756,34 @@ declare class MutableDocumentPath {
|
|
|
648
756
|
set(value: any, isDefault?: boolean): void;
|
|
649
757
|
/**
|
|
650
758
|
* Removes a value at the document's key path defined by the receiver.
|
|
651
|
-
* If removing an index from an
|
|
759
|
+
* If removing an index from an `RGA`, any subsequent indexes will be shifted
|
|
652
760
|
* left to fill the gap.
|
|
653
761
|
*/
|
|
654
762
|
remove(): void;
|
|
655
|
-
/**
|
|
656
|
-
* Replaces a value at the document's key path defined by the receiver.
|
|
657
|
-
*
|
|
658
|
-
* @param isDefault Represents whether or not the value is being replaced with
|
|
659
|
-
* a counter that should serve as a default value. Set this to `true` if you
|
|
660
|
-
* want to set a default value that you expect to be overwritten by other
|
|
661
|
-
* devices in the network. The default value is `false`.
|
|
662
|
-
*/
|
|
663
|
-
replaceWithCounter(isDefault?: boolean): void;
|
|
664
|
-
/**
|
|
665
|
-
* Increments a counter at the document's key path defined by the receiver.
|
|
666
|
-
* This will only succeed if the value at this key path is a counter,
|
|
667
|
-
* otherwise throws an exception.
|
|
668
|
-
*
|
|
669
|
-
* @param amount The amount to increment the counter by. This can be a
|
|
670
|
-
* positive or a negative value.
|
|
671
|
-
*/
|
|
672
|
-
increment(amount: number): void;
|
|
673
|
-
/**
|
|
674
|
-
* Pushes a value on to the end of an array at the document's key path defined
|
|
675
|
-
* by the receiver. This will only succeed if the value at this key path
|
|
676
|
-
* is an array. Otherwise throws an exception.
|
|
677
|
-
*
|
|
678
|
-
* @param value The value to push on to the array.
|
|
679
|
-
*/
|
|
680
|
-
push(value: any): void;
|
|
681
|
-
/**
|
|
682
|
-
* Pops a value off the end of an array at the document's key path defined by
|
|
683
|
-
* the receiver. This will only succeed if the value at this key path is an
|
|
684
|
-
* array. Otherwise throws an exception.
|
|
685
|
-
*
|
|
686
|
-
* @returns The value popped off from the end of the array.
|
|
687
|
-
*/
|
|
688
|
-
pop(): any;
|
|
689
|
-
/**
|
|
690
|
-
* Inserts a value into an array at the index defined by this key path. This
|
|
691
|
-
* will only succeed if the value at the last component of this key path is an
|
|
692
|
-
* index and the preceding key path points to an array. Otherwise throws an
|
|
693
|
-
* exception.
|
|
694
|
-
*
|
|
695
|
-
* @param value The value to insert into the array.
|
|
696
|
-
*/
|
|
697
|
-
insert(value: any): void;
|
|
698
763
|
/** @internal */
|
|
699
|
-
constructor(mutableDocument: MutableDocument, path: string);
|
|
764
|
+
constructor(mutableDocument: MutableDocument, path: string, validate: boolean);
|
|
765
|
+
/** @internal */
|
|
766
|
+
underlyingValueForPathType(pathType: PathAccessorType): any | null;
|
|
767
|
+
/** @internal */
|
|
768
|
+
'@ditto.increment'(amount: number): void;
|
|
769
|
+
/** @internal */
|
|
770
|
+
'@ditto.set'(value: any, isDefault?: boolean): void;
|
|
771
|
+
/** @internal */
|
|
772
|
+
'@ditto.pop'(): any;
|
|
773
|
+
/** @internal */
|
|
774
|
+
'@ditto.remove'(): void;
|
|
775
|
+
/** @internal */
|
|
776
|
+
'@ditto.push'(value: any): void;
|
|
777
|
+
/** @internal */
|
|
778
|
+
'@ditto.insert'(value: any): void;
|
|
700
779
|
/** @private */
|
|
701
780
|
private updateInMemory;
|
|
702
781
|
/** @private */
|
|
703
|
-
private updateInMemoryByReloadingLastPathComponent;
|
|
704
|
-
/** @private */
|
|
705
782
|
private recordUpdateResult;
|
|
706
|
-
/**
|
|
707
|
-
* Returns a new mutable document path instance with the passed in `index`
|
|
708
|
-
* appended (wrapped by square brackets). Throws if `index` is less than 0
|
|
709
|
-
* or not an integer.
|
|
710
|
-
*
|
|
711
|
-
* @deprecated Use {@link at | at() instead}.
|
|
712
|
-
*/
|
|
713
|
-
atIndex(index: number): MutableDocumentPath;
|
|
714
783
|
}
|
|
715
784
|
|
|
716
785
|
/** Represents a unique identifier for a {@link Document}. */
|
|
717
786
|
declare type DocumentIDValue = any;
|
|
718
|
-
/**
|
|
719
|
-
* This is used whenever you can access the document content properties
|
|
720
|
-
* directly via the document.
|
|
721
|
-
*/
|
|
722
|
-
declare type DocumentLike = Document | DocumentValue | any;
|
|
723
|
-
/**
|
|
724
|
-
* This is used whenever you can access and update the document content
|
|
725
|
-
* properties directly via the document.
|
|
726
|
-
*/
|
|
727
|
-
declare type MutableDocumentLike = MutableDocument | DocumentValue | any;
|
|
728
787
|
/**
|
|
729
788
|
* A document value is a JavaScript object containing values for keys that
|
|
730
789
|
* can be serialized via CBOR.
|
|
@@ -732,30 +791,6 @@ declare type MutableDocumentLike = MutableDocument | DocumentValue | any;
|
|
|
732
791
|
declare type DocumentValue = Record<string, any>;
|
|
733
792
|
/** A document belonging to a {@link Collection} with an inner value. */
|
|
734
793
|
declare class Document {
|
|
735
|
-
/**
|
|
736
|
-
* Returns the ID of the document.
|
|
737
|
-
*/
|
|
738
|
-
readonly _id: DocumentIDValue;
|
|
739
|
-
/**
|
|
740
|
-
* Returns the content (aka value) of the document.
|
|
741
|
-
*/
|
|
742
|
-
readonly _value: DocumentValue;
|
|
743
|
-
/**
|
|
744
|
-
* Returns the content (aka inner value) of a document at the given path.
|
|
745
|
-
*/
|
|
746
|
-
readonly _valueAt: (path: string) => any;
|
|
747
|
-
/**
|
|
748
|
-
* Returns the document path at a specified key.
|
|
749
|
-
*/
|
|
750
|
-
readonly _pathAt: (key: string) => DocumentPath;
|
|
751
|
-
/**
|
|
752
|
-
* Returns the ID for a document.
|
|
753
|
-
*/
|
|
754
|
-
static id(document: DocumentLike): DocumentIDValue;
|
|
755
|
-
/**
|
|
756
|
-
* Returns the content (aka inner value) of a document.
|
|
757
|
-
*/
|
|
758
|
-
static value(document: DocumentLike): DocumentValue;
|
|
759
794
|
/**
|
|
760
795
|
* Returns a string representation of the passed in document ID value.
|
|
761
796
|
*
|
|
@@ -773,30 +808,34 @@ declare class Document {
|
|
|
773
808
|
*/
|
|
774
809
|
static base64StringForID(documentID: DocumentIDValue): string;
|
|
775
810
|
/**
|
|
776
|
-
* Returns
|
|
811
|
+
* Returns a hash that represents the passed in document(s).
|
|
777
812
|
*/
|
|
778
|
-
static
|
|
813
|
+
static hash(documentOrMany: Document | Document[]): BigInt;
|
|
779
814
|
/**
|
|
780
|
-
* Returns a
|
|
815
|
+
* Returns a pattern of words that together create a mnemonic, which
|
|
816
|
+
* represents the passed in document(s).
|
|
781
817
|
*/
|
|
782
|
-
static
|
|
818
|
+
static hashMnemonic(documentOrMany: Document | Document[]): string;
|
|
783
819
|
/**
|
|
784
|
-
* Returns
|
|
820
|
+
* Returns the document ID as value.
|
|
785
821
|
*/
|
|
786
|
-
|
|
822
|
+
get _id(): DocumentIDValue;
|
|
787
823
|
/**
|
|
788
|
-
* Returns
|
|
789
|
-
* represents the passed in document(s).
|
|
824
|
+
* Returns the document path at the root of the document.
|
|
790
825
|
*/
|
|
791
|
-
|
|
826
|
+
get path(): DocumentPath;
|
|
792
827
|
/**
|
|
793
|
-
*
|
|
828
|
+
* Convenience property, same as calling `path.value`. The value is cached on
|
|
829
|
+
* first access and returned on subsequent calls without calling `path.value`
|
|
830
|
+
* again.
|
|
794
831
|
*/
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
|
|
832
|
+
get value(): DocumentValue;
|
|
833
|
+
/**
|
|
834
|
+
* Convenience method, same as calling `path.at()`.
|
|
835
|
+
*/
|
|
836
|
+
at(keyPathOrIndex: string | number): DocumentPath;
|
|
798
837
|
/** @internal */
|
|
799
|
-
static idCBOR(document:
|
|
838
|
+
static idCBOR(document: Document): Uint8Array;
|
|
800
839
|
/** @internal */
|
|
801
840
|
static canonicalizedIDCBOR(idCBOR: Uint8Array): Uint8Array;
|
|
802
841
|
/** @internal */
|
|
@@ -814,69 +853,25 @@ declare class MutableDocument {
|
|
|
814
853
|
/**
|
|
815
854
|
* Returns the ID of the document.
|
|
816
855
|
*/
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* Returns the content (aka value) of the document. What you actually get is
|
|
820
|
-
* a proxy that you can freely manipulate and Ditto will register the changes,
|
|
821
|
-
* commiting them at the end of the
|
|
822
|
-
* {@link PendingCursorOperation.update | update closure}.
|
|
823
|
-
*/
|
|
824
|
-
readonly _value: DocumentValue;
|
|
825
|
-
/**
|
|
826
|
-
* Returns the content (aka inner value) of a document at the given path.
|
|
827
|
-
* If the value is a dictionary or an array, what you actually get is
|
|
828
|
-
* a proxy that you can freely manipulate and Ditto will register the changes,
|
|
829
|
-
* commiting them at the end of the
|
|
830
|
-
* {@link PendingCursorOperation.update | update closure}.
|
|
831
|
-
*/
|
|
832
|
-
readonly _valueAt: (path: string) => any;
|
|
833
|
-
/**
|
|
834
|
-
* Returns the mutable document path at a specified key.
|
|
835
|
-
*/
|
|
836
|
-
readonly _pathAt: (key: string) => MutableDocumentPath;
|
|
856
|
+
get _id(): DocumentIDValue;
|
|
837
857
|
/**
|
|
838
|
-
*
|
|
858
|
+
* Returns the document path at the root of the document.
|
|
839
859
|
*/
|
|
840
|
-
|
|
860
|
+
get path(): MutableDocumentPath;
|
|
841
861
|
/**
|
|
842
|
-
* Convenience
|
|
843
|
-
* the passed in `keyPath` via {@link pathAt | pathAt()} followed by
|
|
844
|
-
* {@link MutableDocumentPath.increment | increment()} on that.
|
|
862
|
+
* Convenience property, same as `path.value`.
|
|
845
863
|
*/
|
|
846
|
-
|
|
847
|
-
/** Returns the ID for a mutable document. */
|
|
848
|
-
static id(mutableDocument: MutableDocumentLike): DocumentIDValue;
|
|
864
|
+
get value(): DocumentValue;
|
|
849
865
|
/**
|
|
850
|
-
*
|
|
866
|
+
* Convenience method, same as calling `path.at()`.
|
|
851
867
|
*/
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Returns the content (aka inner value) of a document at the given path.
|
|
855
|
-
*/
|
|
856
|
-
static valueAt(mutableDocument: DocumentLike, path: string): any;
|
|
857
|
-
/**
|
|
858
|
-
* Returns a mutable document path object for a given key-path for a
|
|
859
|
-
* mutable document.
|
|
860
|
-
*/
|
|
861
|
-
static pathAt(mutableDocument: MutableDocumentLike, keyPath: string, skipValidation?: boolean): MutableDocumentPath;
|
|
862
|
-
/**
|
|
863
|
-
* Turns the value of `mutableDocument` at the given `keyPath` into a counter.
|
|
864
|
-
*/
|
|
865
|
-
static replaceWithCounterAt(mutableDocument: MutableDocumentLike, keyPath: string, skipValidation?: boolean): void;
|
|
866
|
-
/**
|
|
867
|
-
* Increments the counter of `mutableDocument` at the given `keyPath`.
|
|
868
|
-
*/
|
|
869
|
-
static incrementCounterAt(mutableDocument: MutableDocumentLike, keyPath: string, amount: number, skipValidation?: boolean): void;
|
|
870
|
-
/**
|
|
871
|
-
* Support for JSON-stringifying a mutable document directly.
|
|
872
|
-
*/
|
|
873
|
-
toJSON(): DocumentValue;
|
|
868
|
+
at(keyPathOrIndex: string | number): MutableDocumentPath;
|
|
874
869
|
/** @internal */
|
|
875
870
|
constructor();
|
|
876
871
|
/** @internal */
|
|
877
872
|
readonly '@ditto.updateResults': UpdateResult[];
|
|
878
873
|
/** @internal */
|
|
879
|
-
static idCBOR(mutableDocument:
|
|
874
|
+
static idCBOR(mutableDocument: MutableDocument): Uint8Array;
|
|
880
875
|
/** @internal */
|
|
881
876
|
static canonicalizedIDCBOR: typeof Document.canonicalizedIDCBOR;
|
|
882
877
|
/** @internal */
|
|
@@ -891,27 +886,11 @@ declare const documentBridge: Bridge<Document, "CDocument_t">;
|
|
|
891
886
|
/** @internal */
|
|
892
887
|
declare const mutableDocumentBridge: Bridge<MutableDocument, "CDocument_t">;
|
|
893
888
|
|
|
894
|
-
/**
|
|
895
|
-
* Serves as a token for a specific attachment that you can pass to a call to
|
|
896
|
-
* {@link Collection.fetchAttachment | fetchAttachment()} on a
|
|
897
|
-
* {@link Collection}.
|
|
898
|
-
*/
|
|
899
|
-
declare class AttachmentToken {
|
|
900
|
-
/** @internal */
|
|
901
|
-
readonly id: Uint8Array;
|
|
902
|
-
/** @internal */
|
|
903
|
-
readonly len: number;
|
|
904
|
-
/** @internal */
|
|
905
|
-
readonly metadata: {
|
|
906
|
-
[key: string]: string;
|
|
907
|
-
};
|
|
908
|
-
/** @internal */
|
|
909
|
-
constructor(jsObj: object);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
889
|
/**
|
|
913
890
|
* Represents an attachment and can be used to insert the associated attachment
|
|
914
|
-
* into a document at a specific key.
|
|
891
|
+
* into a document at a specific key-path. You can't instantiate an attachment
|
|
892
|
+
* directly, please use the {@link Collection.newAttachment | newAttachment()}
|
|
893
|
+
* method of {@link Collection} instead.
|
|
915
894
|
*/
|
|
916
895
|
declare class Attachment {
|
|
917
896
|
/** @internal */
|
|
@@ -985,7 +964,7 @@ declare type AttachmentFetchEvent = AttachmentFetchEventCompleted | AttachmentFe
|
|
|
985
964
|
|
|
986
965
|
/**
|
|
987
966
|
* These objects are returned by calls to
|
|
988
|
-
* {@link Collection.fetchAttachment | fetchAttachment()} on {@link Collection}
|
|
967
|
+
* {@link Collection.fetchAttachment | fetchAttachment()} on {@link Collection}
|
|
989
968
|
* and allow you to stop an in-flight attachment fetch.
|
|
990
969
|
*/
|
|
991
970
|
declare class AttachmentFetcher implements PromiseLike<Attachment | null> {
|
|
@@ -993,13 +972,13 @@ declare class AttachmentFetcher implements PromiseLike<Attachment | null> {
|
|
|
993
972
|
* Returns a promise for the attachment that you can `await`. The promise
|
|
994
973
|
* resolves to either an attachment or `null` if the attachment has been
|
|
995
974
|
* deleted meanwhile. The promise is rejected if an error occurs during
|
|
996
|
-
* the fetch. Note that the AttachmentFetcher itself implementes
|
|
997
|
-
* `PromiseLike`, so you `await` it directly.
|
|
975
|
+
* the fetch. Note that the `AttachmentFetcher` itself implementes
|
|
976
|
+
* `PromiseLike`, so you can `await` it directly.
|
|
998
977
|
*/
|
|
999
978
|
readonly attachment: Promise<Attachment | null>;
|
|
1000
979
|
/**
|
|
1001
|
-
* Stops fetching the
|
|
1002
|
-
*
|
|
980
|
+
* Stops fetching the associated attachment and cleans up any associated
|
|
981
|
+
* resources.
|
|
1003
982
|
*
|
|
1004
983
|
* Note that you are not required to call `stop()` once your attachment fetch
|
|
1005
984
|
* operation has finished. The method primarily exists to allow you to cancel
|
|
@@ -1265,7 +1244,7 @@ declare class SingleDocumentLiveQueryEvent {
|
|
|
1265
1244
|
* The closure that is called whenever the documents covered by a live query
|
|
1266
1245
|
* change.
|
|
1267
1246
|
*/
|
|
1268
|
-
declare type QueryObservationHandler = (documents:
|
|
1247
|
+
declare type QueryObservationHandler = (documents: Document[], event: LiveQueryEvent, signalNext?: () => void) => void | Promise<void>;
|
|
1269
1248
|
/**
|
|
1270
1249
|
* These objects are returned when using `find`-like functionality on
|
|
1271
1250
|
* {@link Collection}.
|
|
@@ -1295,7 +1274,7 @@ declare type QueryObservationHandler = (documents: DocumentLike[], event: LiveQu
|
|
|
1295
1274
|
*
|
|
1296
1275
|
* Update and remove functionality is also exposed through this object.
|
|
1297
1276
|
*/
|
|
1298
|
-
declare class PendingCursorOperation implements PromiseLike<
|
|
1277
|
+
declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
1299
1278
|
/** The query the receiver is operating with. */
|
|
1300
1279
|
readonly query: string;
|
|
1301
1280
|
/** The named arguments for the {@link query}. */
|
|
@@ -1460,7 +1439,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1460
1439
|
* @returns An array promise containing {@link Document | documents} matching
|
|
1461
1440
|
* the query generated by the preceding function chaining.
|
|
1462
1441
|
*/
|
|
1463
|
-
exec(): Promise<
|
|
1442
|
+
exec(): Promise<Document[]>;
|
|
1464
1443
|
/**
|
|
1465
1444
|
* Updates documents that match the query generated by the preceding function
|
|
1466
1445
|
* chaining.
|
|
@@ -1473,7 +1452,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1473
1452
|
* of {@link UpdateResult | update results} that describe the updates that
|
|
1474
1453
|
* were performed for each document.
|
|
1475
1454
|
*/
|
|
1476
|
-
update(closure: (documents:
|
|
1455
|
+
update(closure: (documents: MutableDocument[]) => void): Promise<UpdateResultsMap>;
|
|
1477
1456
|
/** @internal */
|
|
1478
1457
|
constructor(query: string, queryArgs: QueryArguments | null, collection: Collection);
|
|
1479
1458
|
/** @internal */
|
|
@@ -1489,7 +1468,7 @@ declare class PendingCursorOperation implements PromiseLike<DocumentLike[]> {
|
|
|
1489
1468
|
* The closure that is called whenever a single documunent covered by a
|
|
1490
1469
|
* live query changes.
|
|
1491
1470
|
*/
|
|
1492
|
-
declare type SingleObservationHandler = (document:
|
|
1471
|
+
declare type SingleObservationHandler = (document: Document | null, event: SingleDocumentLiveQueryEvent, signalNext?: () => void) => void | Promise<void>;
|
|
1493
1472
|
/**
|
|
1494
1473
|
* These objects are returned when using {@link findByID | findByID()}
|
|
1495
1474
|
* functionality on {@link Collection | collections}.
|
|
@@ -1515,7 +1494,7 @@ declare type SingleObservationHandler = (document: DocumentLike | null, event: S
|
|
|
1515
1494
|
*
|
|
1516
1495
|
* Update and remove functionality is also exposed through this object.
|
|
1517
1496
|
*/
|
|
1518
|
-
declare class PendingIDSpecificOperation implements PromiseLike<
|
|
1497
|
+
declare class PendingIDSpecificOperation implements PromiseLike<Document | undefined> {
|
|
1519
1498
|
/** The ID of the document this operation operates on. */
|
|
1520
1499
|
readonly documentID: DocumentIDValue;
|
|
1521
1500
|
/** The collection the receiver is operating on. */
|
|
@@ -1644,7 +1623,7 @@ declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | u
|
|
|
1644
1623
|
* {@link findByID | findByID()} call or `undefined` if the document was
|
|
1645
1624
|
* not found.
|
|
1646
1625
|
*/
|
|
1647
|
-
exec(): Promise<
|
|
1626
|
+
exec(): Promise<Document | undefined>;
|
|
1648
1627
|
/**
|
|
1649
1628
|
* Updates the document with the matching ID.
|
|
1650
1629
|
*
|
|
@@ -1656,7 +1635,7 @@ declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | u
|
|
|
1656
1635
|
* @return An array promise of {@link UpdateResult | update results} that
|
|
1657
1636
|
* describe the updates that were performed on the document.
|
|
1658
1637
|
*/
|
|
1659
|
-
update(closure: (document:
|
|
1638
|
+
update(closure: (document: MutableDocument) => void): Promise<UpdateResult[]>;
|
|
1660
1639
|
/** @internal */
|
|
1661
1640
|
constructor(documentID: DocumentIDValue, collection: Collection, skipIDEncodingAndValidation?: boolean);
|
|
1662
1641
|
/** @internal */
|
|
@@ -1666,11 +1645,6 @@ declare class PendingIDSpecificOperation implements PromiseLike<DocumentLike | u
|
|
|
1666
1645
|
private _observe;
|
|
1667
1646
|
}
|
|
1668
1647
|
|
|
1669
|
-
declare type InsertOptions = {
|
|
1670
|
-
id?: any;
|
|
1671
|
-
isDefault?: boolean;
|
|
1672
|
-
writeStrategy?: WriteStrategy;
|
|
1673
|
-
};
|
|
1674
1648
|
declare type UpsertOptions = {
|
|
1675
1649
|
writeStrategy?: WriteStrategy;
|
|
1676
1650
|
};
|
|
@@ -1735,28 +1709,6 @@ declare class Collection {
|
|
|
1735
1709
|
* document, defaults to `'merge'`.
|
|
1736
1710
|
*/
|
|
1737
1711
|
upsert(value: DocumentValue, options?: UpsertOptions): Promise<DocumentIDValue>;
|
|
1738
|
-
/**
|
|
1739
|
-
* Inserts a new document into the collection and returns its ID.
|
|
1740
|
-
*
|
|
1741
|
-
* @param value The content for the new document to insert.
|
|
1742
|
-
*
|
|
1743
|
-
* @param options.id The ID to use for the document. If `null` or `undefined`
|
|
1744
|
-
* then Ditto will automatically generate an ID.
|
|
1745
|
-
*
|
|
1746
|
-
* @param options.isDefault This option is now deprecated. You should instead
|
|
1747
|
-
* specify a `writeStrategy` if you wish to insert data as default data. If
|
|
1748
|
-
* you set this to `true` and specify an explicit `writeStrategy` then the
|
|
1749
|
-
* `writeStrategy` will take precedence. This controls whether or not the data
|
|
1750
|
-
* being inserted should be treated as default data. Set this to `true` if you
|
|
1751
|
-
* want to set a default value that you expect to be overwritten by other
|
|
1752
|
-
* devices in the network. The default value is `false`.
|
|
1753
|
-
*
|
|
1754
|
-
* @param options.writeStrategy Specifies the desired strategy for inserting a
|
|
1755
|
-
* document. The default value is `'overwrite'`.
|
|
1756
|
-
*
|
|
1757
|
-
* @deprecated: use `upsert()` instead.
|
|
1758
|
-
*/
|
|
1759
|
-
insert(value: DocumentValue, options?: InsertOptions): Promise<DocumentIDValue>;
|
|
1760
1712
|
/**
|
|
1761
1713
|
* Creates a new {@link Attachment} object, which can then be inserted into a
|
|
1762
1714
|
* document. Node only, throws when running in the web browser.
|
|
@@ -1774,7 +1726,7 @@ declare class Collection {
|
|
|
1774
1726
|
*
|
|
1775
1727
|
* ``` JavaScript
|
|
1776
1728
|
* const attachment = await collection.newAttachment('/path/to/my/file.pdf')
|
|
1777
|
-
* await collection.
|
|
1729
|
+
* await collection.upsert({ _id: '123', attachment, other: 'some-string' })
|
|
1778
1730
|
* }
|
|
1779
1731
|
* ```
|
|
1780
1732
|
*
|
|
@@ -1811,8 +1763,6 @@ declare class Collection {
|
|
|
1811
1763
|
constructor(name: string, store: Store);
|
|
1812
1764
|
/** @internal */
|
|
1813
1765
|
findByIDCBOR(idCBOR: Uint8Array): PendingIDSpecificOperation;
|
|
1814
|
-
/** @private */
|
|
1815
|
-
private _insert;
|
|
1816
1766
|
}
|
|
1817
1767
|
|
|
1818
1768
|
/** @internal */
|
|
@@ -2083,18 +2033,13 @@ declare type RemotePeer = {
|
|
|
2083
2033
|
* Ditto is the entry point for accessing Ditto-related functionality.
|
|
2084
2034
|
*/
|
|
2085
2035
|
declare class Ditto {
|
|
2086
|
-
/**
|
|
2087
|
-
* @deprecated Pass `webAssemblyModule` option to {@link init | init()} instead.
|
|
2088
|
-
* @internal
|
|
2089
|
-
*/
|
|
2090
|
-
static webAssemblyModule: RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null;
|
|
2091
2036
|
/**
|
|
2092
2037
|
* Configure a custom identifier for the current device.
|
|
2093
2038
|
*
|
|
2094
2039
|
* When using {@link observePeers | observePeers()}, each remote peer is
|
|
2095
2040
|
* represented by a short UTF-8 "device name". By default this will be a
|
|
2096
2041
|
* truncated version of the device's hostname. It does not need to be unique
|
|
2097
|
-
* among peers. Configure the device name before calling `
|
|
2042
|
+
* among peers. Configure the device name before calling `startSync()`. If it
|
|
2098
2043
|
* is too long it may be truncated.
|
|
2099
2044
|
*/
|
|
2100
2045
|
deviceName: string;
|
|
@@ -2128,17 +2073,10 @@ declare class Ditto {
|
|
|
2128
2073
|
*/
|
|
2129
2074
|
readonly isActivated: boolean;
|
|
2130
2075
|
/**
|
|
2131
|
-
* Returns `true` if sync active, otherwise returns `false`. Use
|
|
2132
|
-
*
|
|
2076
|
+
* Returns `true` if sync is active, otherwise returns `false`. Use
|
|
2077
|
+
* `startSync()` to activate and `stopSync()` to deactivate sync.
|
|
2133
2078
|
*/
|
|
2134
2079
|
readonly isSyncActive: boolean;
|
|
2135
|
-
/**
|
|
2136
|
-
* Returns `true` if sync has been started, returns `false` if it has
|
|
2137
|
-
* been stopped. Returns `false` if sync has never been started for this
|
|
2138
|
-
* instance.
|
|
2139
|
-
* @deprecated: use isSyncActive instead.
|
|
2140
|
-
*/
|
|
2141
|
-
get isSyncEnabled(): boolean;
|
|
2142
2080
|
/**
|
|
2143
2081
|
* Initializes a new `Ditto` instance.
|
|
2144
2082
|
*
|
|
@@ -2159,29 +2097,6 @@ declare class Ditto {
|
|
|
2159
2097
|
* @see {@link path}
|
|
2160
2098
|
*/
|
|
2161
2099
|
constructor(identity?: Identity, path?: string);
|
|
2162
|
-
/**
|
|
2163
|
-
* @deprecated use {@link setOfflineOnlyLicenseToken | setOfflineOnlyLicenseToken()} instead.
|
|
2164
|
-
* Activate a `Ditto` instance by setting an offline only license token. You cannot initiate sync
|
|
2165
|
-
* with `Ditto` before you have activated it. The offline license token is only valid for identities
|
|
2166
|
-
* of type `development`, `manual`, `offlinePlayground`, and `sharedKey`.
|
|
2167
|
-
*
|
|
2168
|
-
* @param licenseToken the license token to activate the `Ditto` instance
|
|
2169
|
-
* with. You can find yours on the [Ditto portal](https://portal.ditto.live).
|
|
2170
|
-
*/
|
|
2171
|
-
setAccessLicense(accessLicense: string): void;
|
|
2172
|
-
/**
|
|
2173
|
-
* Activate a `Ditto` instance by setting an offline only license token. You cannot initiate sync
|
|
2174
|
-
* with `Ditto` before you have activated it. The offline license token is only valid for identities
|
|
2175
|
-
* of type `development`, `manual`, `offlinePlayground`, and `sharedKey`.
|
|
2176
|
-
*
|
|
2177
|
-
* @deprecated use {@link setOfflineOnlyLicenseToken} for identities of type `development`, `manual`,
|
|
2178
|
-
* `offlinePlayground`, and `sharedKey`.
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
* @param licenseToken the license token to activate the `Ditto` instance
|
|
2182
|
-
* with. You can find yours on the [Ditto portal](https://portal.ditto.live).
|
|
2183
|
-
*/
|
|
2184
|
-
setLicenseToken(licenseToken: string): void;
|
|
2185
2100
|
/**
|
|
2186
2101
|
* Activate a `Ditto` instance by setting an offline only license token. You cannot initiate sync
|
|
2187
2102
|
* with `Ditto` before you have activated it. The offline license token is only valid for identities
|
|
@@ -2219,14 +2134,6 @@ declare class Ditto {
|
|
|
2219
2134
|
* allowing it to mutate as needed, and sets that updated copy afterwards.
|
|
2220
2135
|
*/
|
|
2221
2136
|
updateTransportConfig(update: (transportConfig: TransportConfig) => void): Ditto;
|
|
2222
|
-
/**
|
|
2223
|
-
* Alias for {@link startSync | startSync()}.
|
|
2224
|
-
*
|
|
2225
|
-
* This method and {@link startSync | startSync()} are semantically equivalent
|
|
2226
|
-
* in the JS SDK while differing for languages like Swift or ObjC. Therefore
|
|
2227
|
-
* the alias.
|
|
2228
|
-
*/
|
|
2229
|
-
tryStartSync(): void;
|
|
2230
2137
|
/**
|
|
2231
2138
|
* Starts the network transports. Ditto will connect to other devices.
|
|
2232
2139
|
*
|
|
@@ -2304,7 +2211,7 @@ declare class Ditto {
|
|
|
2304
2211
|
private transportConditionsManager;
|
|
2305
2212
|
private authClientValidityChanged;
|
|
2306
2213
|
private validateIdentity;
|
|
2307
|
-
private
|
|
2214
|
+
private setSyncActive;
|
|
2308
2215
|
private makeDefaultTransportConfig;
|
|
2309
2216
|
}
|
|
2310
2217
|
/** @internal */
|
|
@@ -2403,25 +2310,6 @@ declare class Authenticator {
|
|
|
2403
2310
|
Returns the current authentication status.
|
|
2404
2311
|
*/
|
|
2405
2312
|
readonly status: AuthenticationStatus;
|
|
2406
|
-
/**
|
|
2407
|
-
* Query whether Ditto has a valid authentication token.
|
|
2408
|
-
*
|
|
2409
|
-
* This will only be `true` when using an `OnlineWithAuthentication` or an
|
|
2410
|
-
* `Online` identity, after a successful login. If the authentication token is
|
|
2411
|
-
* allowed to expire then it will return `false` instead.
|
|
2412
|
-
*
|
|
2413
|
-
* @deprecated: use `status.isAuthenticated` property instead.
|
|
2414
|
-
*/
|
|
2415
|
-
get isAuthenticated(): boolean;
|
|
2416
|
-
/**
|
|
2417
|
-
* Return the currently logged-in user ID.
|
|
2418
|
-
*
|
|
2419
|
-
* This will be `null` if there is no valid authentication or
|
|
2420
|
-
* `OnlineWithAuthentication`/`Online` mode is not being used.
|
|
2421
|
-
*
|
|
2422
|
-
* @deprecated: use `status.userID` property instead.
|
|
2423
|
-
*/
|
|
2424
|
-
get userID(): string | null;
|
|
2425
2313
|
/**
|
|
2426
2314
|
* Log in to Ditto with a third-party token. Throws if authentication is not
|
|
2427
2315
|
* available, which can be checked with {@link loginSupported}.
|
|
@@ -2456,9 +2344,9 @@ declare class Authenticator {
|
|
|
2456
2344
|
/** @internal */
|
|
2457
2345
|
constructor(keepAlive: KeepAlive);
|
|
2458
2346
|
/** @internal */
|
|
2459
|
-
'@ditto.authenticationExpiring'
|
|
2347
|
+
'@ditto.authenticationExpiring'(number: any): void;
|
|
2460
2348
|
/** @internal */
|
|
2461
|
-
'@ditto.authClientValidityChanged'
|
|
2349
|
+
'@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void;
|
|
2462
2350
|
/** @internal */
|
|
2463
2351
|
protected keepAlive: KeepAlive;
|
|
2464
2352
|
/** @internal */
|
|
@@ -2469,12 +2357,12 @@ declare class OnlineAuthenticator extends Authenticator {
|
|
|
2469
2357
|
loginWithToken(token: string, provider: string): Promise<void>;
|
|
2470
2358
|
loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void>;
|
|
2471
2359
|
logout(cleanupFn?: (Ditto: any) => void): Promise<void>;
|
|
2472
|
-
readonly authClientPointer: Pointer<
|
|
2360
|
+
readonly authClientPointer: Pointer<FFIAuthClient>;
|
|
2473
2361
|
readonly authenticationHandler: AuthenticationHandler;
|
|
2474
2362
|
private ditto;
|
|
2475
|
-
constructor(keepAlive: KeepAlive, authClientPointer: Pointer<
|
|
2476
|
-
'@ditto.authenticationExpiring'
|
|
2477
|
-
'@ditto.authClientValidityChanged'
|
|
2363
|
+
constructor(keepAlive: KeepAlive, authClientPointer: Pointer<FFIAuthClient>, ditto: Ditto, authenticationHandler: AuthenticationHandler);
|
|
2364
|
+
'@ditto.authenticationExpiring'(secondsRemaining: number): void;
|
|
2365
|
+
'@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void;
|
|
2478
2366
|
private updateAndNotify;
|
|
2479
2367
|
private static finalizationRegistry;
|
|
2480
2368
|
private static finalize;
|
|
@@ -2484,8 +2372,8 @@ declare class NotAvailableAuthenticator extends Authenticator {
|
|
|
2484
2372
|
loginWithToken(token: string, provider: string): Promise<void>;
|
|
2485
2373
|
loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void>;
|
|
2486
2374
|
logout(cleanupFn?: (Ditto: any) => void): Promise<void>;
|
|
2487
|
-
'@ditto.authenticationExpiring'
|
|
2488
|
-
'@ditto.authClientValidityChanged'
|
|
2375
|
+
'@ditto.authenticationExpiring'(secondsRemaining: any): void;
|
|
2376
|
+
'@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void;
|
|
2489
2377
|
}
|
|
2490
2378
|
|
|
2491
2379
|
/** @internal */
|
|
@@ -2495,33 +2383,6 @@ declare class Value {
|
|
|
2495
2383
|
constructor(value: unknown, options?: unknown);
|
|
2496
2384
|
}
|
|
2497
2385
|
|
|
2498
|
-
declare class Counter {
|
|
2499
|
-
/** The value of the counter. */
|
|
2500
|
-
readonly value: number;
|
|
2501
|
-
/** Whether the counter is set as a default value. */
|
|
2502
|
-
readonly isDefault: boolean;
|
|
2503
|
-
/**
|
|
2504
|
-
* Creates a new counter with an initial value that can be used as part
|
|
2505
|
-
* of a document's content.
|
|
2506
|
-
*
|
|
2507
|
-
* @param isDefault Represents whether or not the value should be set as a
|
|
2508
|
-
* default value. Set this to `true` if you want to set a default value that
|
|
2509
|
-
* you expect to be overwritten by other devices in the network. The default
|
|
2510
|
-
* value is `false`.
|
|
2511
|
-
*/
|
|
2512
|
-
constructor(value: number, isDefault?: boolean);
|
|
2513
|
-
/**
|
|
2514
|
-
* Increments the counter by `amount`, which can be any valid number. Only
|
|
2515
|
-
* valid within the closure of {@link Collection}'s {@link Collection.update | update()}
|
|
2516
|
-
* method, otherwise an exception is thrown.
|
|
2517
|
-
*/
|
|
2518
|
-
increment(amount: number): void;
|
|
2519
|
-
/** @internal */
|
|
2520
|
-
static __newInternal(mutDoc: any, path: any, value: any): Counter;
|
|
2521
|
-
private mutDoc;
|
|
2522
|
-
private path;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
2386
|
/** The log levels supported by Ditto. */
|
|
2526
2387
|
declare type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose';
|
|
2527
2388
|
/**
|
|
@@ -2529,14 +2390,6 @@ declare type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose';
|
|
|
2529
2390
|
* log callback on {@link Logger}.
|
|
2530
2391
|
*/
|
|
2531
2392
|
declare type CustomLogCallback = (logLevel: LogLevel, message: string) => void;
|
|
2532
|
-
/**
|
|
2533
|
-
* Internal function used for testing the Wasm logging module.
|
|
2534
|
-
* @param level
|
|
2535
|
-
* @param message
|
|
2536
|
-
* @internal
|
|
2537
|
-
* @deprecated
|
|
2538
|
-
*/
|
|
2539
|
-
declare function __log(level: LogLevel, message: string): void;
|
|
2540
2393
|
/**
|
|
2541
2394
|
* Class with static methods to customize the logging behavior from Ditto and
|
|
2542
2395
|
* log messages with the Ditto logging infrastructure.
|
|
@@ -2639,52 +2492,6 @@ declare class Logger {
|
|
|
2639
2492
|
* {@link LogLevel} `Verbose`.
|
|
2640
2493
|
*/
|
|
2641
2494
|
static verbose(message: string): void;
|
|
2642
|
-
/**
|
|
2643
|
-
* @internal
|
|
2644
|
-
* @deprecated
|
|
2645
|
-
*/
|
|
2646
|
-
readonly logFile?: string;
|
|
2647
|
-
/**
|
|
2648
|
-
* @internal
|
|
2649
|
-
* @deprecated
|
|
2650
|
-
*/
|
|
2651
|
-
setLogFile(path: string | null): void;
|
|
2652
|
-
/**
|
|
2653
|
-
* @internal
|
|
2654
|
-
* @deprecated
|
|
2655
|
-
*/
|
|
2656
|
-
setLogFileURL(url: URL | undefined): void;
|
|
2657
|
-
/**
|
|
2658
|
-
* @internal
|
|
2659
|
-
* @deprecated
|
|
2660
|
-
*/
|
|
2661
|
-
enabled: boolean;
|
|
2662
|
-
/**
|
|
2663
|
-
* @internal
|
|
2664
|
-
* @deprecated
|
|
2665
|
-
*/
|
|
2666
|
-
emojiLogLevelHeadingsEnabled: boolean;
|
|
2667
|
-
/**
|
|
2668
|
-
* @internal
|
|
2669
|
-
* @deprecated
|
|
2670
|
-
*/
|
|
2671
|
-
minimumLogLevel: LogLevel;
|
|
2672
|
-
/**
|
|
2673
|
-
* @internal
|
|
2674
|
-
* @deprecated
|
|
2675
|
-
*/
|
|
2676
|
-
readonly customLogCallback?: CustomLogCallback;
|
|
2677
|
-
/**
|
|
2678
|
-
* @internal
|
|
2679
|
-
* @deprecated
|
|
2680
|
-
*/
|
|
2681
|
-
setCustomLogCallback(callback: CustomLogCallback | undefined): Promise<void>;
|
|
2682
|
-
/**
|
|
2683
|
-
* Returns the shared Logger instance.
|
|
2684
|
-
*
|
|
2685
|
-
* @deprecated, use the `Logger` directly instead.
|
|
2686
|
-
*/
|
|
2687
|
-
static shared(): any;
|
|
2688
2495
|
private constructor();
|
|
2689
2496
|
}
|
|
2690
2497
|
|
|
@@ -2696,5 +2503,5 @@ declare class CBOR {
|
|
|
2696
2503
|
static decode(data: Uint8Array): any;
|
|
2697
2504
|
}
|
|
2698
2505
|
|
|
2699
|
-
export { Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, ConditionSource, Counter, CustomLogCallback, Ditto, Document, DocumentIDValue,
|
|
2506
|
+
export { Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, ConditionSource, Counter, CustomLogCallback, Ditto, Document, DocumentIDValue, DocumentPath, DocumentValue, Identity, IdentityManual, IdentityOfflinePlayground, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, InitOptions, KeepAlive, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRGA, MutableRegister, NotAvailableAuthenticator, Observer, ObserverOptions, OnlineAuthenticator, PendingCursorOperation, PendingIDSpecificOperation, PresenceConnectionType, QueryArguments, QueryObservationHandler, RGA, Register, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, SubscriptionContextInfo, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, UpsertOptions, Value, WebAssemblyModule, WriteStrategy, attachmentBridge, dittoBridge, documentBridge, init, mutableDocumentBridge, validateDocumentIDCBOR, validateDocumentIDValue };
|
|
2700
2507
|
//# sourceMappingURL=ditto.d.ts.map
|