@dittolive/ditto 2.1.0 → 3.0.0-alpha2
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 +2 -2
- 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/types/ditto.d.ts +216 -303
- 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
|
@@ -509,7 +509,7 @@ declare function validateDocumentIDCBOR(idCBOR: Uint8Array): Uint8Array;
|
|
|
509
509
|
/**
|
|
510
510
|
* The types of an {@link UpdateResult}.
|
|
511
511
|
*/
|
|
512
|
-
declare type UpdateResultType = 'set' | '
|
|
512
|
+
declare type UpdateResultType = 'set' | 'incremented' | 'removed';
|
|
513
513
|
declare class UpdateResult {
|
|
514
514
|
/** The update result's type. */
|
|
515
515
|
readonly type: UpdateResultType;
|
|
@@ -518,15 +518,8 @@ declare class UpdateResult {
|
|
|
518
518
|
/** The path to the key in the document that was updated. */
|
|
519
519
|
readonly path: string;
|
|
520
520
|
/**
|
|
521
|
-
* The associated value
|
|
522
|
-
*
|
|
523
|
-
* - For type `set`, it's the new value at the key `path`.
|
|
524
|
-
* - For type `inserted`, it's the new value that was inserted into the array at
|
|
525
|
-
* index encoded into key `path`.
|
|
526
|
-
* - For type `pushed`, it's the new value that was inserted into the array at
|
|
527
|
-
* key `path`.
|
|
528
|
-
* - For type `popped`, it's the value that was popped off the array the
|
|
529
|
-
key `path`.
|
|
521
|
+
* The associated value for `set` operations. The value will be the new value
|
|
522
|
+
* at the key path.
|
|
530
523
|
*
|
|
531
524
|
* All other types of update results do not have this property set.
|
|
532
525
|
*/
|
|
@@ -536,18 +529,10 @@ declare class UpdateResult {
|
|
|
536
529
|
/** @internal */
|
|
537
530
|
static set(docID: DocumentID, path: string, value?: any): UpdateResult;
|
|
538
531
|
/** @internal */
|
|
539
|
-
static replacedWithCounter(docID: DocumentID, path: string): UpdateResult;
|
|
540
|
-
/** @internal */
|
|
541
532
|
static incremented(docID: DocumentID, path: string, amount: number): UpdateResult;
|
|
542
533
|
/** @internal */
|
|
543
|
-
static inserted(docID: DocumentID, path: string, value?: any): UpdateResult;
|
|
544
|
-
/** @internal */
|
|
545
534
|
static removed(docID: DocumentID, path: string): UpdateResult;
|
|
546
535
|
/** @internal */
|
|
547
|
-
static pushed(docID: DocumentID, path: string, value?: any): UpdateResult;
|
|
548
|
-
/** @internal */
|
|
549
|
-
static popped(docID: DocumentID, path: string, value?: any): UpdateResult;
|
|
550
|
-
/** @internal */
|
|
551
536
|
private constructor();
|
|
552
537
|
}
|
|
553
538
|
|
|
@@ -636,113 +621,23 @@ declare class MutableRegister extends Register {
|
|
|
636
621
|
}
|
|
637
622
|
|
|
638
623
|
/**
|
|
639
|
-
* Represents a CRDT Replicated Growable Array (RGA)
|
|
640
|
-
*
|
|
641
|
-
*
|
|
624
|
+
* Represents a CRDT Replicated Growable Array (RGA).
|
|
625
|
+
*
|
|
626
|
+
* RGAs are deprecated and you should instead use a `Register` containing an
|
|
627
|
+
* array.
|
|
642
628
|
*/
|
|
643
629
|
declare class RGA {
|
|
644
630
|
/** The array representation of the RGA. */
|
|
645
631
|
get value(): any[];
|
|
646
|
-
/**
|
|
647
|
-
* Constructs a new RGA that can be used as part of a document's content.
|
|
648
|
-
*
|
|
649
|
-
* @param array - The array to use as the RGA's representation.
|
|
650
|
-
*/
|
|
651
|
-
constructor(array?: any[]);
|
|
652
632
|
/** @internal */
|
|
653
|
-
|
|
633
|
+
private constructor();
|
|
654
634
|
/** @internal */
|
|
655
|
-
|
|
635
|
+
static '@ditto.create'(path: any, value: any): RGA;
|
|
656
636
|
/** @internal */
|
|
657
637
|
protected '@ditto.path': any;
|
|
658
638
|
/** @internal */
|
|
659
639
|
protected '@ditto.value': any;
|
|
660
640
|
}
|
|
661
|
-
/**
|
|
662
|
-
* Represents a mutable CRDT Replicated Growable Array (RGA) that can be
|
|
663
|
-
* mutated as part of updating a document.
|
|
664
|
-
*
|
|
665
|
-
* This class can't be instantiated directly, it's returned automatically for
|
|
666
|
-
* any `rga` property of a document within an update block via {@link MutableDocumentPath.rga}.
|
|
667
|
-
*/
|
|
668
|
-
declare class MutableRGA extends RGA {
|
|
669
|
-
/** Returns the value of the RGA. */
|
|
670
|
-
get value(): any[];
|
|
671
|
-
/**
|
|
672
|
-
* Set a value at the specified index.
|
|
673
|
-
*
|
|
674
|
-
* Only valid within the `update` closure of
|
|
675
|
-
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
676
|
-
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
677
|
-
* otherwise an exception is thrown.
|
|
678
|
-
*
|
|
679
|
-
* @param value - The value to set at the specified index.
|
|
680
|
-
* @param index - The index at which to set the provided value.
|
|
681
|
-
*
|
|
682
|
-
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
683
|
-
* instead.
|
|
684
|
-
*/
|
|
685
|
-
setAt(value: any, index: number): void;
|
|
686
|
-
/**
|
|
687
|
-
* Remove a value at the specified index.
|
|
688
|
-
*
|
|
689
|
-
* Only valid within the `update` closure of
|
|
690
|
-
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
691
|
-
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
692
|
-
* otherwise an exception is thrown.
|
|
693
|
-
*
|
|
694
|
-
* @param index - The index of the element to remove.
|
|
695
|
-
*
|
|
696
|
-
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
697
|
-
* instead.
|
|
698
|
-
*/
|
|
699
|
-
removeAt(index: number): void;
|
|
700
|
-
/**
|
|
701
|
-
* Push a value on to the end of the RGA.
|
|
702
|
-
*
|
|
703
|
-
* Only valid within the `update` closure of
|
|
704
|
-
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
705
|
-
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
706
|
-
* otherwise an exception is thrown.
|
|
707
|
-
*
|
|
708
|
-
* @param value - The value to push on to the RGA.
|
|
709
|
-
*
|
|
710
|
-
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
711
|
-
* instead.
|
|
712
|
-
*/
|
|
713
|
-
push(value: any): void;
|
|
714
|
-
/**
|
|
715
|
-
* Pop a value off the end of the RGA.
|
|
716
|
-
*
|
|
717
|
-
* Only valid within the `update` closure of
|
|
718
|
-
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
719
|
-
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
720
|
-
* otherwise an exception is thrown.
|
|
721
|
-
*
|
|
722
|
-
* @return The value popped off from the end of the RGA.
|
|
723
|
-
*
|
|
724
|
-
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
725
|
-
* instead.
|
|
726
|
-
*/
|
|
727
|
-
pop(): any | null;
|
|
728
|
-
/**
|
|
729
|
-
* Inserts a value into the RGA at the index specified.
|
|
730
|
-
*
|
|
731
|
-
* Only valid within the `update` closure of
|
|
732
|
-
* {@link PendingCursorOperation.update | PendingCursorOperation.update()} and
|
|
733
|
-
* {@link PendingIDSpecificOperation.update | PendingIDSpecificOperation.update()},
|
|
734
|
-
* otherwise an exception is thrown.
|
|
735
|
-
*
|
|
736
|
-
* @param value - The value to insert into the RGA.
|
|
737
|
-
* @param index - The index at which to insert the provided value.
|
|
738
|
-
*
|
|
739
|
-
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
740
|
-
* instead.
|
|
741
|
-
*/
|
|
742
|
-
insertAt(value: any, index: number): void;
|
|
743
|
-
/** @internal */
|
|
744
|
-
constructor(value: any);
|
|
745
|
-
}
|
|
746
641
|
|
|
747
642
|
/**
|
|
748
643
|
* Serves as a token for a specific attachment that you can pass to a call to
|
|
@@ -877,12 +772,16 @@ declare class MutableDocumentPath {
|
|
|
877
772
|
get register(): MutableRegister | null;
|
|
878
773
|
/**
|
|
879
774
|
* Returns the value at the previously specified key in the document as a
|
|
880
|
-
* {@link
|
|
775
|
+
* {@link RGA} if possible, otherwise returns `null`.
|
|
776
|
+
*
|
|
777
|
+
* Note that the returned type, {@link RGA}, is deprecated and does not allow
|
|
778
|
+
* any mutation. RGAs cannot be created or mutated with this version of the
|
|
779
|
+
* SDK; they can only be read and this is for backwards compatibility reasons.
|
|
881
780
|
*
|
|
882
781
|
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
883
782
|
* instead.
|
|
884
783
|
*/
|
|
885
|
-
get rga():
|
|
784
|
+
get rga(): RGA | null;
|
|
886
785
|
/**
|
|
887
786
|
* Returns the value at the previously specified key in the document as a
|
|
888
787
|
* {@link AttachmentToken} if possible, otherwise returns `null`.
|
|
@@ -912,13 +811,7 @@ declare class MutableDocumentPath {
|
|
|
912
811
|
/** @internal */
|
|
913
812
|
'@ditto.set'(value: any, isDefault?: boolean): void;
|
|
914
813
|
/** @internal */
|
|
915
|
-
'@ditto.pop'(): any;
|
|
916
|
-
/** @internal */
|
|
917
814
|
'@ditto.remove'(): void;
|
|
918
|
-
/** @internal */
|
|
919
|
-
'@ditto.push'(value: any): void;
|
|
920
|
-
/** @internal */
|
|
921
|
-
'@ditto.insert'(value: any): void;
|
|
922
815
|
/** @private */
|
|
923
816
|
private updateInMemory;
|
|
924
817
|
/** @private */
|
|
@@ -1198,8 +1091,8 @@ declare class UpdateResultsMap {
|
|
|
1198
1091
|
* {@link PendingCursorOperation} object. It handles the logic for calling the
|
|
1199
1092
|
* event handler that is provided to `observeLocal()` calls.
|
|
1200
1093
|
*
|
|
1201
|
-
* Ditto will prevent the process from exiting as long as there are
|
|
1202
|
-
*
|
|
1094
|
+
* Ditto will prevent the process from exiting as long as there are active live
|
|
1095
|
+
* queries (not relevant when running in the browser).
|
|
1203
1096
|
*
|
|
1204
1097
|
* `LiveQuery` objects must be kept in scope for as long as you wish to have
|
|
1205
1098
|
* your event handler be called when there is an update to a document matching
|
|
@@ -1377,14 +1270,16 @@ declare type QueryObservationHandler = (documents: Document[], event: LiveQueryE
|
|
|
1377
1270
|
* {@link Document | documents} as an immediate return value, or you can
|
|
1378
1271
|
* establish either a live query or a subscription, which both work over time.
|
|
1379
1272
|
*
|
|
1380
|
-
* A live query, established by calling
|
|
1381
|
-
*
|
|
1273
|
+
* A live query, established by calling
|
|
1274
|
+
* {@link PendingCursorOperation.observeLocal | observeLocal()}, will notify you
|
|
1275
|
+
* every time there's an update to a document that matches the query you
|
|
1382
1276
|
* provided in the preceding `find`-like call.
|
|
1383
1277
|
*
|
|
1384
|
-
* A subscription, established by calling
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1278
|
+
* A subscription, established by calling
|
|
1279
|
+
* {@link PendingCursorOperation.subscribe | subscribe()}, will act as a signal
|
|
1280
|
+
* to other peers that the device connects to that you would like to receive
|
|
1281
|
+
* updates from them about documents that match the query you provided in the
|
|
1282
|
+
* preceding `find`-like call.
|
|
1388
1283
|
*
|
|
1389
1284
|
* Update and remove functionality is also exposed through this object.
|
|
1390
1285
|
*/
|
|
@@ -1454,55 +1349,6 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1454
1349
|
* query specified in the preceding chain.
|
|
1455
1350
|
*/
|
|
1456
1351
|
subscribe(): Subscription;
|
|
1457
|
-
/**
|
|
1458
|
-
* Enables you to listen for changes that occur in a collection locally and
|
|
1459
|
-
* remotely.
|
|
1460
|
-
*
|
|
1461
|
-
* The `handler` block will be called when local or remote changes are
|
|
1462
|
-
* made to documents that match the query generated by the chain of operations
|
|
1463
|
-
* that precedes the call to {@link PendingCursorOperation.observe | observe()}. The returned
|
|
1464
|
-
* {@link LiveQuery} object must be kept in scope for as long as you want the
|
|
1465
|
-
* provided `handler` to be called when an update occurs.
|
|
1466
|
-
*
|
|
1467
|
-
* @param handler A closure that will be called every time there is a
|
|
1468
|
-
* transaction committed to the store that involves modifications to
|
|
1469
|
-
* documents matching the query in the collection that this method was called
|
|
1470
|
-
* on.
|
|
1471
|
-
*
|
|
1472
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1473
|
-
* as you want to keep receiving updates.
|
|
1474
|
-
*
|
|
1475
|
-
* @deprecated Use {@link PendingCursorOperation.observeLocal | observeLocal()}
|
|
1476
|
-
* and {@link PendingCursorOperation.subscribe | subscribe()} individually
|
|
1477
|
-
* instead. For more info, please consult the
|
|
1478
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1479
|
-
*/
|
|
1480
|
-
observe(handler: QueryObservationHandler): LiveQuery;
|
|
1481
|
-
/**
|
|
1482
|
-
* Enables you to listen for changes that occur in a collection locally and
|
|
1483
|
-
* remotely and to signal when you are ready for the live query to deliver
|
|
1484
|
-
* the next event.
|
|
1485
|
-
*
|
|
1486
|
-
* The `handler` block will be called when local or remote changes are
|
|
1487
|
-
* made to documents that match the query generated by the chain of operations
|
|
1488
|
-
* that precedes the call to {@link PendingCursorOperation.observeWithNextSignal | observeWithNextSignal()}. The returned
|
|
1489
|
-
* {@link LiveQuery} object must be kept in scope for as long as you want the
|
|
1490
|
-
* provided `handler` to be called when an update occurs.
|
|
1491
|
-
*
|
|
1492
|
-
* @param handler A closure that will be called every time there is a
|
|
1493
|
-
* transaction committed to the store that involves modifications to
|
|
1494
|
-
* documents matching the query in the collection that this method was called
|
|
1495
|
-
* on.
|
|
1496
|
-
*
|
|
1497
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1498
|
-
* as you want to keep receiving updates.
|
|
1499
|
-
*
|
|
1500
|
-
* @deprecated Use {@link PendingCursorOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
1501
|
-
* and {@link PendingCursorOperation.subscribe | subscribe()} individually
|
|
1502
|
-
* instead. For more info, please consult the
|
|
1503
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1504
|
-
*/
|
|
1505
|
-
observeWithNextSignal(handler: QueryObservationHandler): LiveQuery;
|
|
1506
1352
|
/**
|
|
1507
1353
|
* Enables you to listen for changes that occur in a collection locally.
|
|
1508
1354
|
*
|
|
@@ -1617,7 +1463,8 @@ declare type SingleObservationHandler = (document: Document | null, event: Singl
|
|
|
1617
1463
|
* return value, or you can establish either a live query or a subscription,
|
|
1618
1464
|
* which both work over time.
|
|
1619
1465
|
*
|
|
1620
|
-
* A live query, established by calling
|
|
1466
|
+
* A live query, established by calling
|
|
1467
|
+
* {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, will notify
|
|
1621
1468
|
* you every time there's an update to the document with the ID you provided in
|
|
1622
1469
|
* the preceding {@link Collection.findByID | findByID()} call.
|
|
1623
1470
|
*
|
|
@@ -1648,57 +1495,6 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1648
1495
|
* long as you want to keep receiving updates for the document.
|
|
1649
1496
|
*/
|
|
1650
1497
|
subscribe(): Subscription;
|
|
1651
|
-
/**
|
|
1652
|
-
* Enables you to listen for changes that occur in relation to a document
|
|
1653
|
-
* locally and remotely.
|
|
1654
|
-
*
|
|
1655
|
-
* The `handler` closure will be called when local or remote changes are
|
|
1656
|
-
* made to the document referenced by the {@link Collection.findByID | findByID()} call
|
|
1657
|
-
* that precedes the call to {@link PendingIDSpecificOperation.observe | observe()}.
|
|
1658
|
-
*
|
|
1659
|
-
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
1660
|
-
* you want the provided `handler` to be called when an update occurs.
|
|
1661
|
-
*
|
|
1662
|
-
* @param handler A closure that will be called every time there is a
|
|
1663
|
-
* transaction committed to the store that involves a modification to the
|
|
1664
|
-
* document with the relevant ID in the collection that
|
|
1665
|
-
* {@link PendingIDSpecificOperation.observe | observe()} was called on.
|
|
1666
|
-
*
|
|
1667
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1668
|
-
* as you want to keep receiving updates.
|
|
1669
|
-
*
|
|
1670
|
-
* @deprecated Use {@link PendingIDSpecificOperation.observeLocal | observeLocal()}
|
|
1671
|
-
* and {@link PendingIDSpecificOperation.subscribe | subscribe()} individually
|
|
1672
|
-
* instead. For more info, please consult the
|
|
1673
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1674
|
-
*/
|
|
1675
|
-
observe(handler: SingleObservationHandler): LiveQuery;
|
|
1676
|
-
/**
|
|
1677
|
-
* Enables you to listen for changes that occur in relation to a document
|
|
1678
|
-
* locally and remotely, and to signal when you are ready for the live query
|
|
1679
|
-
* to deliver the next event.
|
|
1680
|
-
*
|
|
1681
|
-
* The `handler` closure will be called when local or remote changes are
|
|
1682
|
-
* made to the document referenced by the {@link Collection.findByID | findByID()} call
|
|
1683
|
-
* that precedes the call to {@link PendingIDSpecificOperation.observeWithNextSignal | observeWithNextSignal()}.
|
|
1684
|
-
*
|
|
1685
|
-
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
1686
|
-
* you want the provided `handler` to be called when an update occurs.
|
|
1687
|
-
*
|
|
1688
|
-
* @param handler A closure that will be called every time there is a
|
|
1689
|
-
* transaction committed to the store that involves a modification to the
|
|
1690
|
-
* document with the relevant ID in the collection that
|
|
1691
|
-
* {@link PendingIDSpecificOperation.observeWithNextSignal | observeWithNextSignal()} was called on.
|
|
1692
|
-
*
|
|
1693
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1694
|
-
* as you want to keep receiving updates.
|
|
1695
|
-
*
|
|
1696
|
-
* @deprecated Use {@link PendingIDSpecificOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
1697
|
-
* and {@link PendingIDSpecificOperation.subscribe | subscribe()} individually
|
|
1698
|
-
* instead. For more info, please consult the
|
|
1699
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1700
|
-
*/
|
|
1701
|
-
observeWithNextSignal(handler: SingleObservationHandler): LiveQuery;
|
|
1702
1498
|
/**
|
|
1703
1499
|
* Enables you to listen for changes that occur in relation to a document
|
|
1704
1500
|
* locally.
|
|
@@ -1810,20 +1606,20 @@ declare class Collection {
|
|
|
1810
1606
|
* Generates a {@link PendingCursorOperation} using the provided query.
|
|
1811
1607
|
*
|
|
1812
1608
|
* The returned object can be used to find and return the documents or you can
|
|
1813
|
-
* chain a call to `observeLocal()` or `subscribe()` if you want to get
|
|
1814
|
-
* about the list of matching documents over time. It can also be used
|
|
1815
|
-
* update, remove or evict the matching documents.
|
|
1816
|
-
*
|
|
1817
|
-
* You can incorporate dynamic data into the query string with placeholders
|
|
1818
|
-
*
|
|
1819
|
-
* dictionary in the form of `{ "my_arg_name": "some value" }`.
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1823
|
-
* example.
|
|
1609
|
+
* chain a call to `observeLocal()` or `subscribe()` if you want to get
|
|
1610
|
+
* updates about the list of matching documents over time. It can also be used
|
|
1611
|
+
* to update, remove or evict the matching documents.
|
|
1612
|
+
*
|
|
1613
|
+
* You can incorporate dynamic data into the query string with placeholders in
|
|
1614
|
+
* the form of `$args.my_arg_name`, along with providing an accompanying
|
|
1615
|
+
* dictionary in the form of `{ "my_arg_name": "some value" }`. The
|
|
1616
|
+
* placeholders will be appropriately replaced by the corresponding argument
|
|
1617
|
+
* contained in `queryArgs`. This includes handling things like wrapping
|
|
1618
|
+
* strings in quotation marks and arrays in square brackets, for example.
|
|
1824
1619
|
*
|
|
1825
1620
|
* @param query The query to run against the collection.
|
|
1826
|
-
* @param queryArgs The arguments to use to replace placeholders in the
|
|
1621
|
+
* @param queryArgs The arguments to use to replace placeholders in the
|
|
1622
|
+
* provided query.
|
|
1827
1623
|
*/
|
|
1828
1624
|
find(query: string, queryArgs?: QueryArguments): PendingCursorOperation;
|
|
1829
1625
|
/**
|
|
@@ -1836,9 +1632,11 @@ declare class Collection {
|
|
|
1836
1632
|
* ID.
|
|
1837
1633
|
*
|
|
1838
1634
|
* The returned object can be used to find and return the document or you can
|
|
1839
|
-
* chain a call to
|
|
1840
|
-
*
|
|
1841
|
-
*
|
|
1635
|
+
* chain a call to
|
|
1636
|
+
* {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, or
|
|
1637
|
+
* {@link PendingIDSpecificOperation.subscribe | subscribe()} if you want to
|
|
1638
|
+
* get updates about the document over time. It can also be used to update,
|
|
1639
|
+
* remove or evict the document.
|
|
1842
1640
|
*
|
|
1843
1641
|
* @param id The ID of the document to find.
|
|
1844
1642
|
*/
|
|
@@ -1875,8 +1673,8 @@ declare class Collection {
|
|
|
1875
1673
|
* }
|
|
1876
1674
|
* ```
|
|
1877
1675
|
*
|
|
1878
|
-
* @param pathOrData The path to the file that you want to create an
|
|
1879
|
-
* with or the raw data.
|
|
1676
|
+
* @param pathOrData The path to the file that you want to create an
|
|
1677
|
+
* attachment with or the raw data.
|
|
1880
1678
|
*
|
|
1881
1679
|
* @param metadata Metadata relating to the attachment.
|
|
1882
1680
|
*/
|
|
@@ -1982,17 +1780,18 @@ declare class CollectionsEvent {
|
|
|
1982
1780
|
*/
|
|
1983
1781
|
declare type CollectionsObservationHandler = (event: CollectionsEvent, signalNext?: () => void) => void | Promise<void>;
|
|
1984
1782
|
/**
|
|
1985
|
-
* These objects are returned when calling
|
|
1986
|
-
* on {@link Store}.
|
|
1783
|
+
* These objects are returned when calling
|
|
1784
|
+
* {@link Store.collections | collections()} on {@link Store}.
|
|
1987
1785
|
*
|
|
1988
1786
|
* They allow chaining of further collections-related functions. You can either
|
|
1989
1787
|
* call {@link exec | exec()} on the object to get an array of
|
|
1990
1788
|
* {@link Collection}s as an immediate return value, or you can establish either
|
|
1991
1789
|
* a live query or a subscription, which both work over time.
|
|
1992
1790
|
*
|
|
1993
|
-
* A live query, established by calling
|
|
1994
|
-
*
|
|
1995
|
-
*
|
|
1791
|
+
* A live query, established by calling
|
|
1792
|
+
* {@link PendingCollectionsOperation.observeLocal | observeLocal()}, will
|
|
1793
|
+
* notify you every time there's a change in the collections that the device
|
|
1794
|
+
* knows about.
|
|
1996
1795
|
*
|
|
1997
1796
|
* A subscription, established by calling {@link subscribe | subscribe()}, will
|
|
1998
1797
|
* act as a signal to other peers that the device connects to that you would
|
|
@@ -2048,47 +1847,6 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
|
|
|
2048
1847
|
* collections that they know about.
|
|
2049
1848
|
*/
|
|
2050
1849
|
subscribe(): Subscription;
|
|
2051
|
-
/**
|
|
2052
|
-
* Enables you to listen for changes that occur in relation to the collections
|
|
2053
|
-
* that are known about. A closure gets called when an update is received
|
|
2054
|
-
* either locally or remotely.
|
|
2055
|
-
*
|
|
2056
|
-
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
2057
|
-
* you want the provided `handler` to be called when an update occurs.
|
|
2058
|
-
*
|
|
2059
|
-
* @param handler A closure that will be called every time there is an update
|
|
2060
|
-
* about the list of known about collections.
|
|
2061
|
-
*
|
|
2062
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2063
|
-
* as you want to keep receiving updates.
|
|
2064
|
-
*
|
|
2065
|
-
* @deprecated Use {@link PendingCollectionsOperation.observeLocal | observeLocal()}
|
|
2066
|
-
* and {@link PendingCollectionsOperation.subscribe | subscribe()}
|
|
2067
|
-
* individually instead. For more info, please consult the
|
|
2068
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
2069
|
-
*/
|
|
2070
|
-
observe(handler: CollectionsObservationHandler): LiveQuery;
|
|
2071
|
-
/**
|
|
2072
|
-
* Enables you to listen for changes that occur in relation to the collections
|
|
2073
|
-
* that are known about. A block gets called when an update is received either
|
|
2074
|
-
* locally or remotely. You can signal when you are ready for the next event
|
|
2075
|
-
* to be delivered.
|
|
2076
|
-
*
|
|
2077
|
-
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
2078
|
-
* you want the provided `handler` to be called when an update occurs.
|
|
2079
|
-
*
|
|
2080
|
-
* @param handler A closure that will be called every time there is an update
|
|
2081
|
-
* about the list of known about collections.
|
|
2082
|
-
*
|
|
2083
|
-
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2084
|
-
* as you want to keep receiving updates.
|
|
2085
|
-
*
|
|
2086
|
-
* @deprecated Use {@link PendingCollectionsOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
2087
|
-
* and {@link PendingCollectionsOperation.subscribe | subscribe()}
|
|
2088
|
-
* individually instead. For more info, please consult the
|
|
2089
|
-
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
2090
|
-
*/
|
|
2091
|
-
observeWithNextSignal(handler: CollectionsObservationHandler): LiveQuery;
|
|
2092
1850
|
/**
|
|
2093
1851
|
* Enables you to listen for changes that occur in relation to the collections
|
|
2094
1852
|
* that are known about locally.
|
|
@@ -2220,13 +1978,132 @@ declare class Observer {
|
|
|
2220
1978
|
private static finalize;
|
|
2221
1979
|
}
|
|
2222
1980
|
|
|
1981
|
+
/** Types of connections that can be established between two peers. */
|
|
1982
|
+
declare type ConnectionType = 'P2PWiFi' | 'WebSocket' | 'AccessPoint' | 'Bluetooth';
|
|
1983
|
+
/**
|
|
1984
|
+
* An opaque address uniquely identifying another peer on the Ditto mesh
|
|
1985
|
+
* network.
|
|
1986
|
+
*
|
|
1987
|
+
* IMPORTANT: You should not rely on the individual components of the address,
|
|
1988
|
+
* those can change at any time. Please use
|
|
1989
|
+
* {@link addressToString | addressToString()} to compare individual addresses
|
|
1990
|
+
* with each other.
|
|
1991
|
+
*/
|
|
1992
|
+
declare type Address = {
|
|
1993
|
+
siteId: string;
|
|
1994
|
+
pubkey: Uint8Array;
|
|
1995
|
+
};
|
|
1996
|
+
/**
|
|
1997
|
+
* Returns a string representation of the given address. Use this function
|
|
1998
|
+
* to compare multiple addresses or whenever you need the address to be a key
|
|
1999
|
+
* in a hash object.
|
|
2000
|
+
*/
|
|
2001
|
+
declare function addressToString(address: Address): string;
|
|
2002
|
+
/** Represents a connection between two peers on the Ditto mesh network. */
|
|
2003
|
+
declare type Connection = {
|
|
2004
|
+
/** Unique identifier for the connection. */
|
|
2005
|
+
id: string;
|
|
2006
|
+
/** Type of transport enabling this connection. */
|
|
2007
|
+
type: ConnectionType;
|
|
2008
|
+
/** The address of the peer at one end of the connection. */
|
|
2009
|
+
peer1: Address;
|
|
2010
|
+
/** The address of the peer at one end of the connection. */
|
|
2011
|
+
peer2: Address;
|
|
2012
|
+
approximateDistanceInMeters?: number;
|
|
2013
|
+
};
|
|
2014
|
+
/** An instance of Ditto taking part in the Ditto mesh network. */
|
|
2015
|
+
declare type Peer = {
|
|
2016
|
+
/**
|
|
2017
|
+
* Address to contact this peer via Ditto Bus, unique with a Ditto mesh
|
|
2018
|
+
* network.
|
|
2019
|
+
*/
|
|
2020
|
+
address: Address;
|
|
2021
|
+
/**
|
|
2022
|
+
* The human-readable device name of the peer. This defaults to the hostname
|
|
2023
|
+
* but can be manually set by the application developer of the other peer.
|
|
2024
|
+
* It is not necessarily unique.
|
|
2025
|
+
*/
|
|
2026
|
+
deviceName: string;
|
|
2027
|
+
/**
|
|
2028
|
+
* Currently active connections of the peer.
|
|
2029
|
+
*/
|
|
2030
|
+
connections: Connection[];
|
|
2031
|
+
/**
|
|
2032
|
+
* Indicates whether the peer is connected to Ditto Cloud.
|
|
2033
|
+
*/
|
|
2034
|
+
isConnectedToDittoCloud: boolean;
|
|
2035
|
+
/** The operating system the peer is running on, `undefined` if (yet) unknown. */
|
|
2036
|
+
os?: string;
|
|
2037
|
+
/** The Ditto SDK version the peer is running with, `undefined` if (yet) unknown. */
|
|
2038
|
+
dittoSDKVersion?: string;
|
|
2039
|
+
};
|
|
2040
|
+
/**
|
|
2041
|
+
* Represents the Ditto mesh network of peers and their connections between each
|
|
2042
|
+
* other. The `localPeer` is the entry point, all others are remote peers known
|
|
2043
|
+
* by the local peer (either directly or via other remote peers).
|
|
2044
|
+
*/
|
|
2045
|
+
declare type PresenceGraph = {
|
|
2046
|
+
/**
|
|
2047
|
+
* Returns the local peer (usually the peer that is represented by the
|
|
2048
|
+
* currently running Ditto instance). The `localPeer` is the entry point, all
|
|
2049
|
+
* others are remote peers known by the local peer (either directly or via
|
|
2050
|
+
* other remote peers).
|
|
2051
|
+
*/
|
|
2052
|
+
localPeer: Peer;
|
|
2053
|
+
/**
|
|
2054
|
+
* Returns all remote peers known by the `localPeer`, either directly or via
|
|
2055
|
+
* other remote peers.
|
|
2056
|
+
*/
|
|
2057
|
+
remotePeers: Peer[];
|
|
2058
|
+
/**
|
|
2059
|
+
* Returns the underlying CBOR data if the presence graph has been initialized
|
|
2060
|
+
* with CBOR. All of Ditto API returning a presence graph has this property
|
|
2061
|
+
* set.
|
|
2062
|
+
*/
|
|
2063
|
+
underlyingCBOR?: Uint8Array;
|
|
2064
|
+
};
|
|
2065
|
+
/**
|
|
2066
|
+
* The entrypoint for all actions that relate presence of other peers known by
|
|
2067
|
+
* the current peer, either directly or through other peers.
|
|
2068
|
+
*
|
|
2069
|
+
* You don't create one directly but can access it from a particular `Ditto`
|
|
2070
|
+
* instance via its `presence` property.
|
|
2071
|
+
*/
|
|
2072
|
+
declare class Presence {
|
|
2073
|
+
/** The Ditto instance this object belongs to. */
|
|
2074
|
+
readonly ditto: Ditto;
|
|
2075
|
+
/**
|
|
2076
|
+
* Returns the current presence graph capturing all known peers and
|
|
2077
|
+
* connections between them.
|
|
2078
|
+
*/
|
|
2079
|
+
get graph(): PresenceGraph;
|
|
2080
|
+
/**
|
|
2081
|
+
* Request information about Ditto peers in range of this device.
|
|
2082
|
+
*
|
|
2083
|
+
* This method returns an observer which should be held as long as updates are
|
|
2084
|
+
* required. A newly registered observer will have a peers update delivered to
|
|
2085
|
+
* it immediately. From then on it will be invoked repeatedly when Ditto
|
|
2086
|
+
* devices come and go, or the active connections to them change.
|
|
2087
|
+
*/
|
|
2088
|
+
observe(didChangeHandler: (presenceGraph: PresenceGraph) => void): Observer;
|
|
2089
|
+
/** @internal */
|
|
2090
|
+
constructor(ditto: Ditto);
|
|
2091
|
+
private observerManager;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2223
2094
|
/** Types of connections that can be established between two peers. */
|
|
2224
2095
|
declare type TransportCondition = 'Unknown' | 'OK' | 'GenericFailure' | 'AppInBackground' | 'MDNSFailure' | 'TCPListenFailure' | 'NoBLECentralPermission' | 'NoBLEPeripheralPermission' | 'CannotEstablishConnection' | 'BLEDisabled' | 'NoBLEHardware' | 'WiFiDisabled' | 'TemporarilyUnavailable';
|
|
2225
2096
|
/** The source for a transport condition. */
|
|
2226
2097
|
declare type ConditionSource = 'BLE' | 'TCP' | 'AWDL' | 'MDNS';
|
|
2227
|
-
/**
|
|
2098
|
+
/**
|
|
2099
|
+
* Types of connections that can be established between two peers.
|
|
2100
|
+
* @deprecated replaced by {@link ConnectionType}.
|
|
2101
|
+
*/
|
|
2228
2102
|
declare type PresenceConnectionType = 'WiFi' | 'WebSocket' | 'AWDL' | 'BLE';
|
|
2229
|
-
/**
|
|
2103
|
+
/**
|
|
2104
|
+
* A peer object with information about an observed peer.
|
|
2105
|
+
* @deprecated replaced by {@link Peer}.
|
|
2106
|
+
*/
|
|
2230
2107
|
declare type RemotePeer = {
|
|
2231
2108
|
networkID: string;
|
|
2232
2109
|
deviceName: string;
|
|
@@ -2241,7 +2118,7 @@ declare class Ditto {
|
|
|
2241
2118
|
/**
|
|
2242
2119
|
* Configure a custom identifier for the current device.
|
|
2243
2120
|
*
|
|
2244
|
-
* When using {@link
|
|
2121
|
+
* When using {@link Presence.observe | presence.observe()}, each remote peer is
|
|
2245
2122
|
* represented by a short UTF-8 "device name". By default this will be a
|
|
2246
2123
|
* truncated version of the device's hostname. It does not need to be unique
|
|
2247
2124
|
* among peers. Configure the device name before calling
|
|
@@ -2263,6 +2140,10 @@ declare class Ditto {
|
|
|
2263
2140
|
* Provides access to the SDK's store functionality.
|
|
2264
2141
|
*/
|
|
2265
2142
|
readonly store: Store;
|
|
2143
|
+
/**
|
|
2144
|
+
* Provides access to the SDK's presence functionality.
|
|
2145
|
+
*/
|
|
2146
|
+
readonly presence: Presence;
|
|
2266
2147
|
/**
|
|
2267
2148
|
* Provides access to authentication methods for logging on to Ditto Cloud.
|
|
2268
2149
|
*/
|
|
@@ -2382,6 +2263,8 @@ declare class Ditto {
|
|
|
2382
2263
|
* in range and whenever that state changes. Then it will be invoked
|
|
2383
2264
|
* repeatedly when Ditto devices come and go, or the active connections to
|
|
2384
2265
|
* them change.
|
|
2266
|
+
*
|
|
2267
|
+
* @deprecated please use {@link Presence.observe | presence.observe()} instead.
|
|
2385
2268
|
*/
|
|
2386
2269
|
observePeers(callback: (peersData: RemotePeer[]) => void): Observer;
|
|
2387
2270
|
/**
|
|
@@ -2410,6 +2293,16 @@ declare class Ditto {
|
|
|
2410
2293
|
* Only available in Node environments at the moment, no-op in the browser.
|
|
2411
2294
|
*/
|
|
2412
2295
|
runGarbageCollection(): void;
|
|
2296
|
+
/**
|
|
2297
|
+
* Explicitly opt-in to disabling the ability to sync with Ditto peers running
|
|
2298
|
+
* any version of the SDK in the v2 series of releases.
|
|
2299
|
+
*
|
|
2300
|
+
* Assuming this succeeds then this peer will only be able to sync with other
|
|
2301
|
+
* peers using SDKs in the v3 series of releases. Note that this disabling of
|
|
2302
|
+
* sync spreads to peers that sync with a peer that has disabled, or has
|
|
2303
|
+
* (transitively) had disabled, syncing with v2 SDK peers.
|
|
2304
|
+
*/
|
|
2305
|
+
disableSyncWithV2(): void;
|
|
2413
2306
|
/** @internal */
|
|
2414
2307
|
keepAlive: KeepAlive;
|
|
2415
2308
|
private sync;
|
|
@@ -2428,27 +2321,47 @@ declare const dittoBridge: Bridge<Ditto, "CDitto_t">;
|
|
|
2428
2321
|
/** @internal */
|
|
2429
2322
|
declare type ObserverToken = string;
|
|
2430
2323
|
/** @internal */
|
|
2324
|
+
declare type ObserverManagerConstructorOptions = {
|
|
2325
|
+
keepAlive?: KeepAlive;
|
|
2326
|
+
register?: (callback: (...args: any[]) => void) => void;
|
|
2327
|
+
unregister?: () => void;
|
|
2328
|
+
process?: (...args: any[]) => any[];
|
|
2329
|
+
};
|
|
2330
|
+
/** @internal */
|
|
2431
2331
|
declare class ObserverManager {
|
|
2432
2332
|
/** @internal */
|
|
2433
2333
|
readonly id: string;
|
|
2434
2334
|
/** @internal */
|
|
2435
2335
|
readonly keepAlive: KeepAlive | null;
|
|
2436
2336
|
/** @internal */
|
|
2437
|
-
constructor(id: string,
|
|
2337
|
+
constructor(id: string, options?: ObserverManagerConstructorOptions);
|
|
2438
2338
|
/** @internal */
|
|
2439
2339
|
addObserver(callback: any): ObserverToken;
|
|
2440
2340
|
/** @internal */
|
|
2441
2341
|
removeObserver(token: ObserverToken): void;
|
|
2442
2342
|
/** @internal */
|
|
2443
2343
|
notify(...args: any[]): void;
|
|
2444
|
-
/**
|
|
2344
|
+
/**
|
|
2345
|
+
* Can be injected and replaced via constructor options.
|
|
2346
|
+
*
|
|
2347
|
+
* @abstract
|
|
2348
|
+
*/
|
|
2445
2349
|
protected register(callback: (...args: any[]) => void): void;
|
|
2446
|
-
/**
|
|
2350
|
+
/**
|
|
2351
|
+
* Can be injected and replaced via constructor options.
|
|
2352
|
+
*
|
|
2353
|
+
* @abstract
|
|
2354
|
+
*/
|
|
2447
2355
|
protected unregister(): void;
|
|
2448
|
-
/**
|
|
2449
|
-
|
|
2356
|
+
/**
|
|
2357
|
+
* Can be injected and replaced via constructor options.
|
|
2358
|
+
*
|
|
2359
|
+
* @abstract
|
|
2360
|
+
*/
|
|
2361
|
+
protected process(...args: any[]): any[];
|
|
2450
2362
|
private isRegistered;
|
|
2451
2363
|
private callbacksByToken;
|
|
2364
|
+
private constructorOptions;
|
|
2452
2365
|
private hasObservers;
|
|
2453
2366
|
private registerIfNeeded;
|
|
2454
2367
|
private unregisterIfNeeded;
|
|
@@ -2710,5 +2623,5 @@ declare class CBOR {
|
|
|
2710
2623
|
static decode(data: Uint8Array): any;
|
|
2711
2624
|
}
|
|
2712
2625
|
|
|
2713
|
-
export { Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue, Identity, IdentityManual, IdentityOfflinePlayground, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, InitOptions, KeepAlive, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath,
|
|
2626
|
+
export { Address, Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, CBOR, Collection, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Connection, ConnectionType, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue, Identity, IdentityManual, IdentityOfflinePlayground, IdentityOnlinePlayground, IdentityOnlineWithAuthentication, IdentitySharedKey, IdentityTypesRequiringOfflineLicenseToken, InitOptions, KeepAlive, LiveQuery, LiveQueryEvent, LiveQueryEventInitial, LiveQueryEventUpdate, LiveQueryEventUpdateParams, LiveQueryMove, LogLevel, Logger, MutableCounter, MutableDocument, MutableDocumentPath, MutableRegister, NotAvailableAuthenticator, Observer, ObserverOptions, OnlineAuthenticator, Peer, PendingCollectionsOperation, PendingCursorOperation, PendingIDSpecificOperation, Presence, PresenceConnectionType, PresenceGraph, QueryArguments, QueryObservationHandler, RGA, Register, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, UpsertOptions, Value, WebAssemblyModule, WriteStrategy, addressToString, attachmentBridge, dittoBridge, documentBridge, init, mutableDocumentBridge, validateDocumentIDCBOR, validateDocumentIDValue };
|
|
2714
2627
|
//# sourceMappingURL=ditto.d.ts.map
|