@dittolive/ditto 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/node/ditto.cjs.js +7949 -6746
- 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/ditto.win32-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +3 -3
- package/types/ditto.d.ts +312 -58
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dittolive/ditto",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Ditto is a cross-platform embeddable NoSQL database that can sync with or without an internet connection.",
|
|
5
5
|
"homepage": "https://ditto.live",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"cbor-redux": "^0.
|
|
44
|
+
"cbor-redux": "^1.0.0"
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"serve": "^14.
|
|
48
|
+
"serve": "^14.2.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/types/ditto.d.ts
CHANGED
|
@@ -750,6 +750,21 @@ declare class UpdateResultsMap {
|
|
|
750
750
|
private updateResultsByDocumentIDString;
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Restore a `TransportConfig` from its serializable representation.
|
|
755
|
+
*
|
|
756
|
+
* @internal
|
|
757
|
+
*/
|
|
758
|
+
declare function transportConfigFromDeserializable(serialized: any): TransportConfig;
|
|
759
|
+
/**
|
|
760
|
+
* Convert a `TransportConfig` to a serializable representation.
|
|
761
|
+
*
|
|
762
|
+
* This mainly involves converting the `TransportConfig`'s properties to have the expected key names
|
|
763
|
+
* and casing.
|
|
764
|
+
*
|
|
765
|
+
* @internal
|
|
766
|
+
*/
|
|
767
|
+
declare function transportConfigToSerializable(config: TransportConfig): any;
|
|
753
768
|
/**
|
|
754
769
|
* Part of {@link TransportConfig} type, configuration for listening for TCP
|
|
755
770
|
* connections.
|
|
@@ -1096,6 +1111,8 @@ interface IdentitySharedKey {
|
|
|
1096
1111
|
/**
|
|
1097
1112
|
* A manually-provided certificate identity. This accepts a
|
|
1098
1113
|
* base64-encoded bundle.
|
|
1114
|
+
*
|
|
1115
|
+
* A manual identity's `appID` is encoded in its certificate.
|
|
1099
1116
|
*/
|
|
1100
1117
|
interface IdentityManual {
|
|
1101
1118
|
type: 'manual';
|
|
@@ -1195,7 +1212,7 @@ type ConnectionType = 'P2PWiFi' | 'WebSocket' | 'AccessPoint' | 'Bluetooth';
|
|
|
1195
1212
|
* with each other.
|
|
1196
1213
|
*/
|
|
1197
1214
|
type Address = {
|
|
1198
|
-
siteId:
|
|
1215
|
+
siteId: number | BigInt;
|
|
1199
1216
|
pubkey: Uint8Array;
|
|
1200
1217
|
};
|
|
1201
1218
|
/**
|
|
@@ -1206,13 +1223,28 @@ type Address = {
|
|
|
1206
1223
|
declare function addressToString(address: Address): string;
|
|
1207
1224
|
/** Represents a connection between two peers on the Ditto mesh network. */
|
|
1208
1225
|
type Connection = {
|
|
1209
|
-
/** Unique identifier for the connection.
|
|
1226
|
+
/** Unique identifier for the connection.
|
|
1227
|
+
*
|
|
1228
|
+
* These IDs are stable for any two peer keys and a given connection type.
|
|
1229
|
+
*
|
|
1230
|
+
* **Example ID**
|
|
1231
|
+
*
|
|
1232
|
+
* "1<->2:Bluetooth"
|
|
1233
|
+
*/
|
|
1210
1234
|
id: string;
|
|
1211
1235
|
/** Type of transport enabling this connection. */
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1236
|
+
connectionType: ConnectionType;
|
|
1237
|
+
/**
|
|
1238
|
+
* Peer key of the peer at one end of the connection.
|
|
1239
|
+
*
|
|
1240
|
+
* This peer key is lexicographically smaller than `peer2`.
|
|
1241
|
+
*/
|
|
1214
1242
|
peer1: Uint8Array;
|
|
1215
|
-
/**
|
|
1243
|
+
/**
|
|
1244
|
+
* Peer key of the peer at the other end of the connection.
|
|
1245
|
+
*
|
|
1246
|
+
* This peer key is lexicographically larger than `peer1`.
|
|
1247
|
+
*/
|
|
1216
1248
|
peer2: Uint8Array;
|
|
1217
1249
|
approximateDistanceInMeters?: number;
|
|
1218
1250
|
};
|
|
@@ -1431,11 +1463,15 @@ declare class LiveQueryEventInitial {
|
|
|
1431
1463
|
readonly isInitial = true;
|
|
1432
1464
|
/**
|
|
1433
1465
|
* Returns a hash that represents the set of matching documents.
|
|
1466
|
+
*
|
|
1467
|
+
* @deprecated use {@link Document.hash | Document.hash()} instead.
|
|
1434
1468
|
*/
|
|
1435
1469
|
hash(documents: Document[]): BigInt;
|
|
1436
1470
|
/**
|
|
1437
1471
|
* Returns a pattern of words that together create a mnemonic, which
|
|
1438
1472
|
* represents the set of matching documents.
|
|
1473
|
+
*
|
|
1474
|
+
* @deprecated use {@link Document.hashMnemonic | Document.hashMnemonic()} instead.
|
|
1439
1475
|
*/
|
|
1440
1476
|
hashMnemonic(documents: Document[]): string;
|
|
1441
1477
|
}
|
|
@@ -1478,11 +1514,15 @@ declare class LiveQueryEventUpdate {
|
|
|
1478
1514
|
readonly moves: LiveQueryMove[];
|
|
1479
1515
|
/**
|
|
1480
1516
|
* Returns a hash that represents the set of matching documents.
|
|
1517
|
+
*
|
|
1518
|
+
* @deprecated use {@link Document.hash | Document.hash()} instead.
|
|
1481
1519
|
*/
|
|
1482
1520
|
hash(documents: Document[]): BigInt;
|
|
1483
1521
|
/**
|
|
1484
1522
|
* Returns a pattern of words that together create a mnemonic, which
|
|
1485
1523
|
* represents the set of matching documents.
|
|
1524
|
+
*
|
|
1525
|
+
* @deprecated use {@link Document.hashMnemonic | Document.hashMnemonic()} instead.
|
|
1486
1526
|
*/
|
|
1487
1527
|
hashMnemonic(documents: Document[]): string;
|
|
1488
1528
|
/** @internal */
|
|
@@ -1506,11 +1546,15 @@ declare class SingleDocumentLiveQueryEvent {
|
|
|
1506
1546
|
readonly oldDocument?: Document;
|
|
1507
1547
|
/**
|
|
1508
1548
|
* Returns a hash that represents the set of matching documents.
|
|
1549
|
+
*
|
|
1550
|
+
* @deprecated use {@link Document.hash | Document.hash()} instead.
|
|
1509
1551
|
*/
|
|
1510
1552
|
hash(document: Document | null): BigInt;
|
|
1511
1553
|
/**
|
|
1512
1554
|
* Returns a pattern of words that together create a mnemonic, which
|
|
1513
1555
|
* represents the set of matching documents.
|
|
1556
|
+
*
|
|
1557
|
+
* @deprecated use {@link Document.hashMnemonic | Document.hashMnemonic()} instead.
|
|
1514
1558
|
*/
|
|
1515
1559
|
hashMnemonic(document: Document | null): string;
|
|
1516
1560
|
/** @internal */
|
|
@@ -1865,8 +1909,18 @@ declare class Ditto {
|
|
|
1865
1909
|
/**
|
|
1866
1910
|
* The path this Ditto instance was initialized with, if no path was given at
|
|
1867
1911
|
* construction time, the default value is returned (see constructor).
|
|
1912
|
+
*
|
|
1913
|
+
* @deprecated `Ditto.path` is deprecated. Please update your code to use the
|
|
1914
|
+
* new 'Ditto.persistenceDirectory' property instead.
|
|
1868
1915
|
*/
|
|
1869
|
-
|
|
1916
|
+
get path(): string;
|
|
1917
|
+
/**
|
|
1918
|
+
* Path to the local directory used for persistent data storage.
|
|
1919
|
+
*
|
|
1920
|
+
* Defaults to 'ditto'. In environments without file system access, such as
|
|
1921
|
+
* browsers, this is used as a namespace for the internal data store.
|
|
1922
|
+
*/
|
|
1923
|
+
readonly persistenceDirectory: string;
|
|
1870
1924
|
/**
|
|
1871
1925
|
* Provides access to the SDK's store functionality.
|
|
1872
1926
|
*/
|
|
@@ -1896,10 +1950,15 @@ declare class Ditto {
|
|
|
1896
1950
|
readonly isClosed: boolean;
|
|
1897
1951
|
/**
|
|
1898
1952
|
* Returns `true` if sync is active, otherwise returns `false`. Use
|
|
1899
|
-
* {@link startSync | startSync()} to activate and
|
|
1900
|
-
* to deactivate sync.
|
|
1953
|
+
* {@link startSync | startSync()} to activate and
|
|
1954
|
+
* {@link stopSync | stopSync()} to deactivate sync.
|
|
1901
1955
|
*/
|
|
1902
1956
|
readonly isSyncActive: boolean;
|
|
1957
|
+
/**
|
|
1958
|
+
* Application ID associated with the {@link Identity | identity} used by this
|
|
1959
|
+
* Ditto instance.
|
|
1960
|
+
* */
|
|
1961
|
+
readonly appID: string;
|
|
1903
1962
|
/**
|
|
1904
1963
|
* Initializes a new `Ditto` instance.
|
|
1905
1964
|
*
|
|
@@ -1910,15 +1969,13 @@ declare class Ditto {
|
|
|
1910
1969
|
* @param identity - Identity for the new Ditto instance, defaults to
|
|
1911
1970
|
* `offlinePlayground` with `appID` being the empty string `''`.
|
|
1912
1971
|
*
|
|
1913
|
-
* @param
|
|
1914
|
-
*
|
|
1915
|
-
* browser, `path` is used as an internal namespace for the in-memory storage.
|
|
1916
|
-
* Defaults to `"ditto"`.
|
|
1972
|
+
* @param persistenceDirectory optional string containing a directory path
|
|
1973
|
+
* that Ditto will use for persistence. Defaults to `"ditto"`.
|
|
1917
1974
|
*
|
|
1918
1975
|
* @see {@link Ditto.identity}
|
|
1919
|
-
* @see {@link Ditto.
|
|
1976
|
+
* @see {@link Ditto.persistenceDirectory}
|
|
1920
1977
|
*/
|
|
1921
|
-
constructor(identity?: Identity,
|
|
1978
|
+
constructor(identity?: Identity, persistenceDirectory?: string);
|
|
1922
1979
|
/**
|
|
1923
1980
|
* Don't terminate the process when callbacks are pending for a long time.
|
|
1924
1981
|
*
|
|
@@ -1964,9 +2021,22 @@ declare class Ditto {
|
|
|
1964
2021
|
*/
|
|
1965
2022
|
static isEnvironmentSupported(): boolean;
|
|
1966
2023
|
/**
|
|
1967
|
-
*
|
|
1968
|
-
*
|
|
1969
|
-
*
|
|
2024
|
+
* Validates and creates the given directory and returns its path.
|
|
2025
|
+
*
|
|
2026
|
+
* Any string containing non-whitespace characters is considered valid.
|
|
2027
|
+
* Defaults to `ditto` if no path or an invalid path is given. In web
|
|
2028
|
+
* environments, the given path is returned as-is if it is valid.
|
|
2029
|
+
*
|
|
2030
|
+
* @param path optional string containing a writable directory path
|
|
2031
|
+
* @returns validated path
|
|
2032
|
+
* @internal
|
|
2033
|
+
*/
|
|
2034
|
+
static initPersistenceDirectory(path?: string): string;
|
|
2035
|
+
/**
|
|
2036
|
+
* Activate a `Ditto` instance by setting an offline only license token. You
|
|
2037
|
+
* cannot initiate sync with `Ditto` before you have activated it. The offline
|
|
2038
|
+
* license token is only valid for identities of type `development`, `manual`,
|
|
2039
|
+
* `offlinePlayground`, and `sharedKey`.
|
|
1970
2040
|
*
|
|
1971
2041
|
* @param licenseToken the license token to activate the `Ditto` instance
|
|
1972
2042
|
* with. You can find yours on the [Ditto portal](https://portal.ditto.live).
|
|
@@ -2053,7 +2123,7 @@ declare class Ditto {
|
|
|
2053
2123
|
* transport conditions observers (not relevant when running in the browser).
|
|
2054
2124
|
*
|
|
2055
2125
|
* @param callback called when underlying transport conditions change with
|
|
2056
|
-
* the changed `condition` and
|
|
2126
|
+
* the changed `condition` and its `source`.
|
|
2057
2127
|
*/
|
|
2058
2128
|
observeTransportConditions(callback: (condition: TransportCondition, source: ConditionSource) => void): Observer;
|
|
2059
2129
|
/**
|
|
@@ -2137,7 +2207,14 @@ declare class Ditto {
|
|
|
2137
2207
|
private setSyncActive;
|
|
2138
2208
|
private makeDefaultTransportConfig;
|
|
2139
2209
|
}
|
|
2140
|
-
/**
|
|
2210
|
+
/**
|
|
2211
|
+
* Returns true if the current JS environment supports all required APIs.
|
|
2212
|
+
*
|
|
2213
|
+
* @param _globalObject optional global object to test this function without
|
|
2214
|
+
* having to mock `global`.
|
|
2215
|
+
* @returns `true` iff all required APIs exist on `global`.
|
|
2216
|
+
* @internal
|
|
2217
|
+
*/
|
|
2141
2218
|
declare const checkAPIs: (_globalObject?: Window | typeof globalThis) => boolean;
|
|
2142
2219
|
/**
|
|
2143
2220
|
* Disable deadlock timeout when Node.js is running with `--inspect` parameter.
|
|
@@ -2639,27 +2716,151 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
|
|
|
2639
2716
|
}
|
|
2640
2717
|
|
|
2641
2718
|
/**
|
|
2642
|
-
*
|
|
2719
|
+
* A change listener starts out in the `active` state and can be stopped by
|
|
2720
|
+
* calling {@link ExperimentalChangeListener.stop | `stop()`} or letting it
|
|
2721
|
+
* go out of scope.
|
|
2722
|
+
*
|
|
2723
|
+
* @internal
|
|
2724
|
+
*/
|
|
2725
|
+
type ExperimentalChangeListenerStatus = 'active' | 'stopped';
|
|
2726
|
+
/**
|
|
2727
|
+
* A change listener invokes a change handler whenever results for its query
|
|
2728
|
+
* change.
|
|
2729
|
+
*
|
|
2730
|
+
* Create a listener by calling
|
|
2731
|
+
* {@link ExperimentalStore.addChangeListener | `ditto.store.experimental.addChangeListener()`}.
|
|
2732
|
+
*
|
|
2733
|
+
* @internal
|
|
2734
|
+
*/
|
|
2735
|
+
declare class ExperimentalChangeListener {
|
|
2736
|
+
/**
|
|
2737
|
+
* The DQL query this listener is reacting to.
|
|
2738
|
+
*/
|
|
2739
|
+
readonly query: string;
|
|
2740
|
+
/**
|
|
2741
|
+
* The arguments to this listener's query.
|
|
2742
|
+
*/
|
|
2743
|
+
readonly queryArgs?: QueryArguments;
|
|
2744
|
+
/** @internal */
|
|
2745
|
+
constructor(store: ExperimentalStore, query: string, queryArgs: QueryArguments | null, onChange: ChangeHandler | ChangeHandlerWithSignalNext, onError?: ErrorHandler, withSignalNext?: boolean);
|
|
2746
|
+
/**
|
|
2747
|
+
* A change listener starts out in the `active` state and can be stopped by
|
|
2748
|
+
* calling {@link ExperimentalChangeListener.stop | `stop()`} or letting it go
|
|
2749
|
+
* out of scope.
|
|
2750
|
+
*/
|
|
2751
|
+
get status(): ExperimentalChangeListenerStatus;
|
|
2752
|
+
/**
|
|
2753
|
+
* Stops the listener from receiving any more updates.
|
|
2754
|
+
*/
|
|
2755
|
+
stop(): void;
|
|
2756
|
+
/**
|
|
2757
|
+
* The ID of this listener's live query.
|
|
2758
|
+
*
|
|
2759
|
+
* @internal
|
|
2760
|
+
*/
|
|
2761
|
+
readonly liveQueryID: number;
|
|
2762
|
+
/**
|
|
2763
|
+
* Closes the listener, preventing it from receiving any more updates.
|
|
2764
|
+
*
|
|
2765
|
+
* @internal
|
|
2766
|
+
* */
|
|
2767
|
+
close(): void;
|
|
2768
|
+
private store;
|
|
2769
|
+
private _status;
|
|
2770
|
+
/**
|
|
2771
|
+
* Signals to Ditto Core that the listener is ready for the next event.
|
|
2772
|
+
*/
|
|
2773
|
+
private signalNext;
|
|
2774
|
+
/**
|
|
2775
|
+
* Creates bridged arguments for the user's change handler from the raw C callback arguments.
|
|
2776
|
+
*/
|
|
2777
|
+
private static bridgeEventArguments;
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
/**
|
|
2781
|
+
* A change handler is called whenever an active change listener receives new
|
|
2782
|
+
* results.
|
|
2783
|
+
*
|
|
2784
|
+
* @internal
|
|
2785
|
+
*/
|
|
2786
|
+
type ChangeHandler = (result: Document[], event: LiveQueryEvent) => void;
|
|
2787
|
+
/**
|
|
2788
|
+
* A change handler is called whenever an active change listener receives new
|
|
2789
|
+
* results.
|
|
2790
|
+
*
|
|
2791
|
+
* Call `signalNext()` to signal that the handler is ready to receive the next
|
|
2792
|
+
* callback from the change listener.
|
|
2793
|
+
*
|
|
2794
|
+
* @internal
|
|
2795
|
+
*/
|
|
2796
|
+
type ChangeHandlerWithSignalNext = (result: Document[], event: LiveQueryEvent, signalNext: () => void) => void;
|
|
2797
|
+
/**
|
|
2798
|
+
* An error handler is called when a change handler throws an error.
|
|
2799
|
+
*
|
|
2800
|
+
* @internal
|
|
2801
|
+
*/
|
|
2802
|
+
type ErrorHandler = (error: Error) => void;
|
|
2803
|
+
/**
|
|
2804
|
+
* Manages `ExperimentalChangeListener` instances and removes them when Ditto is closed.
|
|
2805
|
+
*
|
|
2806
|
+
* @internal
|
|
2807
|
+
*/
|
|
2808
|
+
declare class ExperimentalChangeListenerManager {
|
|
2809
|
+
constructor(ditto: Ditto);
|
|
2810
|
+
/**
|
|
2811
|
+
* Register and start a change listener in core, also registering it in the listener manager.
|
|
2812
|
+
*
|
|
2813
|
+
* @internal
|
|
2814
|
+
*/
|
|
2815
|
+
addChangeListener(listener: ExperimentalChangeListener): void;
|
|
2816
|
+
/**
|
|
2817
|
+
* Mark all change listeners as closed while deferring the closing of Ditto.
|
|
2818
|
+
*
|
|
2819
|
+
* @internal
|
|
2820
|
+
*/
|
|
2821
|
+
close(): void;
|
|
2822
|
+
/**
|
|
2823
|
+
* Remove a change listener from the listener manager and stop it in core.
|
|
2824
|
+
*
|
|
2825
|
+
* @internal
|
|
2826
|
+
* @param listener The change listener to remove.
|
|
2827
|
+
*/
|
|
2828
|
+
removeChangeListener(listener: ExperimentalChangeListener): void;
|
|
2829
|
+
private readonly ditto;
|
|
2830
|
+
private readonly keepAlive;
|
|
2831
|
+
private readonly listenersById;
|
|
2832
|
+
/**
|
|
2833
|
+
* Keeps track of change listeners by live query ID.
|
|
2834
|
+
*/
|
|
2835
|
+
private readonly finalizationRegistry;
|
|
2836
|
+
/**
|
|
2837
|
+
* Remove a change listener without unregistering it from the finalization registry.
|
|
2838
|
+
*/
|
|
2839
|
+
private stopLiveQuery;
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
/**
|
|
2843
|
+
* Manages `ExperimentalReplicationSubscription` instances and removes them when Ditto is
|
|
2643
2844
|
* closed.
|
|
2644
2845
|
*
|
|
2645
2846
|
* @internal
|
|
2646
2847
|
*/
|
|
2647
|
-
declare class
|
|
2848
|
+
declare class ExperimentalReplicationSubscriptionManager {
|
|
2648
2849
|
constructor(ditto: Ditto);
|
|
2649
2850
|
/**
|
|
2650
|
-
* Begin tracking a subscription instance and start it.
|
|
2851
|
+
* Begin tracking a replication subscription instance and start it.
|
|
2651
2852
|
*
|
|
2652
2853
|
* @internal
|
|
2653
2854
|
*/
|
|
2654
|
-
addSubscription(subscription:
|
|
2855
|
+
addSubscription(subscription: ExperimentalReplicationSubscription): void;
|
|
2655
2856
|
/**
|
|
2656
|
-
* Stop tracking a subscription instance and cancel it.
|
|
2857
|
+
* Stop tracking a replication subscription instance and cancel it.
|
|
2657
2858
|
*
|
|
2658
2859
|
* @internal
|
|
2659
2860
|
*/
|
|
2660
|
-
removeSubscription(subscription:
|
|
2861
|
+
removeSubscription(subscription: ExperimentalReplicationSubscription): void;
|
|
2661
2862
|
/**
|
|
2662
|
-
* Stop tracking all subscriptions and cancel them.
|
|
2863
|
+
* Stop tracking all replication subscriptions and cancel them.
|
|
2663
2864
|
*
|
|
2664
2865
|
* @internal
|
|
2665
2866
|
*/
|
|
@@ -2668,54 +2869,53 @@ declare class ExperimentalSubscriptionManager {
|
|
|
2668
2869
|
private subscriptions;
|
|
2669
2870
|
private finalizationRegistry;
|
|
2670
2871
|
/**
|
|
2671
|
-
* Remove tracked subscription without unregistering from
|
|
2672
|
-
* registry.
|
|
2673
|
-
*
|
|
2674
|
-
* @internal
|
|
2872
|
+
* Remove tracked replication subscription without unregistering from
|
|
2873
|
+
* finalization registry.
|
|
2675
2874
|
*/
|
|
2676
2875
|
private removeWithContextInfo;
|
|
2677
2876
|
}
|
|
2678
2877
|
|
|
2679
2878
|
/**
|
|
2680
|
-
* Contains all information required to deregister a subscription
|
|
2681
|
-
*
|
|
2879
|
+
* Contains all information required to deregister a replication subscription in
|
|
2880
|
+
* Ditto Core, even when the replication subscription instance itself has
|
|
2682
2881
|
* already been garbage collected.
|
|
2683
2882
|
*
|
|
2684
2883
|
* @internal
|
|
2685
2884
|
*/
|
|
2686
|
-
type
|
|
2885
|
+
type ExperimentalReplicationSubscriptionContextInfo = {
|
|
2687
2886
|
/** Unique ID per `ExperimentalSubscription` instance. */
|
|
2688
2887
|
id: string;
|
|
2689
2888
|
query: string;
|
|
2690
2889
|
queryArgsCBOR: Uint8Array | null;
|
|
2691
2890
|
};
|
|
2692
2891
|
/**
|
|
2693
|
-
* Create a subscription to receive updates from remote peers about
|
|
2694
|
-
* matching the subscription's query.
|
|
2892
|
+
* Create a replication subscription to receive updates from remote peers about
|
|
2893
|
+
* documents matching the replication subscription's query.
|
|
2695
2894
|
*
|
|
2696
|
-
* The subscription will remain active until
|
|
2697
|
-
*
|
|
2895
|
+
* The replication subscription will remain active until
|
|
2896
|
+
* {@link cancel | cancel()} is called or the replication subscription object
|
|
2897
|
+
* goes out of scope and is garbage collected.
|
|
2698
2898
|
*
|
|
2699
2899
|
* @internal
|
|
2700
2900
|
*/
|
|
2701
|
-
declare class
|
|
2901
|
+
declare class ExperimentalReplicationSubscription {
|
|
2702
2902
|
/**
|
|
2703
|
-
* Documents matching this query will be included in the subscription.
|
|
2903
|
+
* Documents matching this query will be included in the replication subscription.
|
|
2704
2904
|
*/
|
|
2705
2905
|
readonly query: string;
|
|
2706
2906
|
/**
|
|
2707
2907
|
* `true` when {@link cancel | cancel()} has been called or the Ditto instance
|
|
2708
|
-
* managing this subscription has been closed.
|
|
2908
|
+
* managing this replication subscription has been closed.
|
|
2709
2909
|
*/
|
|
2710
2910
|
readonly isCancelled = false;
|
|
2711
2911
|
/**
|
|
2712
|
-
* Cancels a subscription and releases all associated resources.
|
|
2912
|
+
* Cancels a replication subscription and releases all associated resources.
|
|
2713
2913
|
*/
|
|
2714
2914
|
cancel(): void;
|
|
2715
2915
|
/** @internal */
|
|
2716
|
-
constructor(manager:
|
|
2916
|
+
constructor(manager: ExperimentalReplicationSubscriptionManager, query: string, queryArgsCBOR: Uint8Array | null);
|
|
2717
2917
|
/** @internal */
|
|
2718
|
-
contextInfo:
|
|
2918
|
+
contextInfo: ExperimentalReplicationSubscriptionContextInfo;
|
|
2719
2919
|
/**
|
|
2720
2920
|
* The corresponding named arguments for {@link query}, if any.
|
|
2721
2921
|
*
|
|
@@ -2739,7 +2939,69 @@ declare class ExperimentalStore {
|
|
|
2739
2939
|
* */
|
|
2740
2940
|
readonly ditto: Ditto;
|
|
2741
2941
|
/** @internal */
|
|
2942
|
+
readonly listenerManager: ExperimentalChangeListenerManager;
|
|
2943
|
+
/** @internal */
|
|
2742
2944
|
constructor(ditto: Ditto);
|
|
2945
|
+
/**
|
|
2946
|
+
* Register a handler to be called whenever a query's results change in the
|
|
2947
|
+
* local store.
|
|
2948
|
+
*
|
|
2949
|
+
* The returned {@link ExperimentalChangeListener} must be kept in scope for
|
|
2950
|
+
* as long as the change handler should be called with new change events.
|
|
2951
|
+
*
|
|
2952
|
+
* The given query may not modify any documents and must be a valid Ditto
|
|
2953
|
+
* Query Language query.
|
|
2954
|
+
*
|
|
2955
|
+
* If no `onError` argument is provided, errors that are thrown in the
|
|
2956
|
+
* provided change handler will be logged to the console.
|
|
2957
|
+
*
|
|
2958
|
+
* The first invocation of `onChange` will always happen after this method
|
|
2959
|
+
* returns. The next call to `onChange` will always wait until the previous
|
|
2960
|
+
* call has returned. Use
|
|
2961
|
+
* {@link ExperimentalStore.addChangeListenerWithSignalNext | addChangeListenerWithSignalNext()}
|
|
2962
|
+
* if you want to control the rate of callbacks yourself.
|
|
2963
|
+
*
|
|
2964
|
+
* @internal
|
|
2965
|
+
*/
|
|
2966
|
+
addChangeListener(query: string, onChange: ChangeHandler, onError?: ErrorHandler, queryArgs?: QueryArguments): ExperimentalChangeListener;
|
|
2967
|
+
/**
|
|
2968
|
+
* Register a handler to be called whenever a query's results change in the
|
|
2969
|
+
* local store and control when the next invocation of the change handler
|
|
2970
|
+
* happens.
|
|
2971
|
+
*
|
|
2972
|
+
* Here, a function is passed as an additional argument to the change handler.
|
|
2973
|
+
* Call this function as soon as the change handler is ready to process the
|
|
2974
|
+
* the next change event. This allows the change handler to control how often
|
|
2975
|
+
* it is called.
|
|
2976
|
+
*
|
|
2977
|
+
* Otherwise identical to
|
|
2978
|
+
* {@link ExperimentalStore.addChangeListener | addChangeListener()}.
|
|
2979
|
+
*
|
|
2980
|
+
* @internal
|
|
2981
|
+
*/
|
|
2982
|
+
addChangeListenerWithSignalNext(query: string, onChange: ChangeHandlerWithSignalNext, onError?: ErrorHandler, queryArgs?: QueryArguments): ExperimentalChangeListener;
|
|
2983
|
+
/**
|
|
2984
|
+
* Registers a URL to be called whenever the given query observes changes.
|
|
2985
|
+
*
|
|
2986
|
+
* This API will stay internal-only as it is only used in the portal.
|
|
2987
|
+
*
|
|
2988
|
+
* @internal
|
|
2989
|
+
* @returns a promise for a document id that acts as a webhook id
|
|
2990
|
+
*/
|
|
2991
|
+
addChangeListenerWebhook(query: string, url: string, queryArgs?: QueryArguments): Promise<DocumentID>;
|
|
2992
|
+
/**
|
|
2993
|
+
* Run the provided query on the device of connected peers and send the
|
|
2994
|
+
* results of the query back to the local peer's data store.
|
|
2995
|
+
*
|
|
2996
|
+
* The returned {@link ExperimentalReplicationSubscription} object must be kept in scope
|
|
2997
|
+
* for as long as you want to keep receiving updates.
|
|
2998
|
+
*
|
|
2999
|
+
* @internal
|
|
3000
|
+
* @param query a Ditto Query Language query string of the form SELECT * FROM
|
|
3001
|
+
* collection WHERE expression
|
|
3002
|
+
* @returns {@link ExperimentalReplicationSubscription} object
|
|
3003
|
+
*/
|
|
3004
|
+
addReplicationSubscription(query: string): ExperimentalReplicationSubscription;
|
|
2743
3005
|
/** @internal */
|
|
2744
3006
|
close(): void;
|
|
2745
3007
|
/**
|
|
@@ -2757,20 +3019,7 @@ declare class ExperimentalStore {
|
|
|
2757
3019
|
* @returns a promise for an array of Ditto documents matching the query
|
|
2758
3020
|
*/
|
|
2759
3021
|
execute(query: string): Promise<Document[]>;
|
|
2760
|
-
|
|
2761
|
-
* Subscribes the device to updates specified by a DQL query to collections
|
|
2762
|
-
* that other devices know about.
|
|
2763
|
-
*
|
|
2764
|
-
* The returned {@link ExperimentalSubscription} object must be kept in scope
|
|
2765
|
-
* for as long as you want to keep receiving updates.
|
|
2766
|
-
*
|
|
2767
|
-
* @internal
|
|
2768
|
-
* @param query a Ditto Query Language query string of the form SELECT * FROM
|
|
2769
|
-
* collection WHERE expression
|
|
2770
|
-
* @returns {@link ExperimentalSubscription} object
|
|
2771
|
-
*/
|
|
2772
|
-
subscribe(query: string): ExperimentalSubscription;
|
|
2773
|
-
private subscriptionManager;
|
|
3022
|
+
private replicationSubscriptionManager;
|
|
2774
3023
|
}
|
|
2775
3024
|
|
|
2776
3025
|
/**
|
|
@@ -2948,6 +3197,11 @@ declare class Store {
|
|
|
2948
3197
|
* Returns the collection for the given name. If the collection doesn't
|
|
2949
3198
|
* exist yet, it will be created automatically as soon as the first
|
|
2950
3199
|
* entry is inserted.
|
|
3200
|
+
* A collection name is valid if:
|
|
3201
|
+
* * its length is less than 100
|
|
3202
|
+
* * it is not empty
|
|
3203
|
+
* * it does not contain the char '\0'
|
|
3204
|
+
* * it does not begin with "$TS_"
|
|
2951
3205
|
*/
|
|
2952
3206
|
collection(name: string): Collection;
|
|
2953
3207
|
/**
|
|
@@ -3166,5 +3420,5 @@ declare class CBOR {
|
|
|
3166
3420
|
static decode(data: Uint8Array): any;
|
|
3167
3421
|
}
|
|
3168
3422
|
|
|
3169
|
-
export { Address, Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, Collection, CollectionInterface, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Connection, ConnectionType, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue,
|
|
3423
|
+
export { Address, Attachment, AttachmentFetchEvent, AttachmentFetchEventCompleted, AttachmentFetchEventDeleted, AttachmentFetchEventProgress, AttachmentFetchEventType, AttachmentFetcher, AttachmentToken, AuthenticationHandler, AuthenticationStatus, Authenticator, BasePendingCursorOperation, BasePendingIDSpecificOperation, CBOR, ChangeHandler, ChangeHandlerWithSignalNext, Collection, CollectionInterface, CollectionsEvent, CollectionsEventParams, CollectionsObservationHandler, ConditionSource, Connection, ConnectionType, Counter, CustomLogCallback, Ditto, Document, DocumentID, DocumentIDValue, DocumentPath, DocumentValue, ErrorHandler, ExperimentalChangeListener, ExperimentalChangeListenerManager, ExperimentalChangeListenerStatus, ExperimentalReplicationSubscription, ExperimentalReplicationSubscriptionContextInfo, ExperimentalReplicationSubscriptionManager, ExperimentalStore, 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, Register, RemotePeer, SingleDocumentLiveQueryEvent, SingleObservationHandler, SortDirection, Store, Subscription, TransportCondition, TransportConfig, TransportConfigConnect, TransportConfigGlobal, TransportConfigLan, TransportConfigListen, TransportConfigListenHTTP, TransportConfigListenTCP, TransportConfigPeerToPeer, UpdateResult, UpdateResultType, UpdateResultsMap, UpsertOptions, Value, WebAssemblyModule, WriteStrategy, WriteTransaction, WriteTransactionCollection, WriteTransactionPendingCursorOperation, WriteTransactionPendingIDSpecificOperation, WriteTransactionResult, addressToString, checkAPIs, disableDeadlockTimeoutWhenDebugging, getBridgeLoad, init, transportConfigFromDeserializable, transportConfigToSerializable, validateDocumentIDCBOR, validateDocumentIDValue };
|
|
3170
3424
|
//# sourceMappingURL=ditto.d.ts.map
|