tinybase 6.2.0-beta.1 → 6.2.0-beta.3
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/@types/common/index.d.ts +124 -0
- package/@types/common/with-schemas/index.d.ts +124 -0
- package/@types/index.d.ts +1 -1
- package/@types/mergeable-store/index.d.ts +2 -14
- package/@types/mergeable-store/with-schemas/index.d.ts +2 -14
- package/@types/omni/index.d.ts +54 -0
- package/@types/omni/with-schemas/index.d.ts +54 -0
- package/@types/persisters/index.d.ts +2 -2
- package/@types/persisters/with-schemas/index.d.ts +2 -2
- package/@types/relationships/index.d.ts +2 -2
- package/@types/relationships/with-schemas/index.d.ts +2 -2
- package/@types/store/index.d.ts +1 -1
- package/@types/store/with-schemas/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +1 -1
- package/@types/with-schemas/index.d.ts +1 -1
- package/common/index.js +108 -4
- package/common/with-schemas/index.js +108 -4
- package/index.js +107 -86
- package/mergeable-store/index.js +73 -54
- package/mergeable-store/with-schemas/index.js +73 -54
- package/min/common/index.js +1 -1
- package/min/common/index.js.gz +0 -0
- package/min/common/with-schemas/index.js +1 -1
- package/min/common/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -0
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -0
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +10596 -0
- package/omni/with-schemas/index.js +10596 -0
- package/package.json +432 -396
- package/readme.md +2 -2
- package/releases.md +17 -3
- package/synchronizers/index.js +0 -1
- package/synchronizers/synchronizer-broadcast-channel/index.js +0 -1
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +0 -1
- package/synchronizers/synchronizer-local/index.js +0 -1
- package/synchronizers/synchronizer-local/with-schemas/index.js +0 -1
- package/synchronizers/synchronizer-ws-client/index.js +0 -1
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +0 -1
- package/synchronizers/synchronizer-ws-server/index.js +0 -1
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +0 -1
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +0 -1
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +0 -1
- package/synchronizers/with-schemas/index.js +0 -1
- package/with-schemas/index.js +107 -86
package/@types/common/index.d.ts
CHANGED
|
@@ -65,6 +65,34 @@ export type Callback = () => void;
|
|
|
65
65
|
*/
|
|
66
66
|
export type SortKey = string | number | boolean;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The GetNow type is used to represent a function that returns the current time
|
|
70
|
+
* in milliseconds.
|
|
71
|
+
*
|
|
72
|
+
* This is used internally within the mergeable-store module, but is used for
|
|
73
|
+
* the createMergeableStore function's second optional argument to allow
|
|
74
|
+
* applications to override the clock used to generate timestamps.
|
|
75
|
+
* @category Stamps
|
|
76
|
+
* @since v6.2.0
|
|
77
|
+
*/
|
|
78
|
+
export type GetNow = () => number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The Hlc type is a string that represents a Hybrid Logical Clock (HLC) value.
|
|
82
|
+
*
|
|
83
|
+
* HLCs are used to provide a globally unique timestamp that can be used to
|
|
84
|
+
* order events across distributed systems. The Hlc type in TinyBase is a
|
|
85
|
+
* sortable 16 character string that encodes a timestamp, a counter, and the
|
|
86
|
+
* hash of a unique client identifier.
|
|
87
|
+
*
|
|
88
|
+
* - 42 bits (7 chars) for the time in milliseconds (~139 years).
|
|
89
|
+
* - 24 bits (4 chars) for the counter (~16 million).
|
|
90
|
+
* - 30 bits (5 chars) for the hash of unique client id (~1 billion).
|
|
91
|
+
* @category Stamps
|
|
92
|
+
* @since v6.2.0
|
|
93
|
+
*/
|
|
94
|
+
export type Hlc = string;
|
|
95
|
+
|
|
68
96
|
/**
|
|
69
97
|
* The defaultSorter function is provided as a convenience to sort keys
|
|
70
98
|
* alphanumerically, and can be provided to the `sliceIdSorter` and
|
|
@@ -156,3 +184,99 @@ export function defaultSorter(sortKey1: SortKey, sortKey2: SortKey): number;
|
|
|
156
184
|
* @since v5.0.0
|
|
157
185
|
*/
|
|
158
186
|
export function getUniqueId(length?: number): Id;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The getHlcFunctions function returns a set of utility functions for working
|
|
190
|
+
* with the TinyBase Hybrid Logical Clock (HLC).
|
|
191
|
+
*
|
|
192
|
+
* An HLC is a sortable 16 character string that encodes a timestamp, a counter,
|
|
193
|
+
* and the hash of a unique client identifier. You should provide that unique
|
|
194
|
+
* client identifier as the `uniqueId` parameter to the function. Otherwise it
|
|
195
|
+
* will be defaulted and the client suffix of the HLCs the `getNextHlc` function
|
|
196
|
+
* generates will be non-deterministic.
|
|
197
|
+
*
|
|
198
|
+
* You can also provide a `getNow` function that returns the current time in
|
|
199
|
+
* milliseconds, which is useful for testing purposes where fully deterministic
|
|
200
|
+
* HLCs are required, rather than the current time.
|
|
201
|
+
*
|
|
202
|
+
* The stateful functions returned by this function are as follows.
|
|
203
|
+
*
|
|
204
|
+
* - `getNextHlc`: a function that returns the next HLC for this client based on
|
|
205
|
+
* the time and any other HLC values from other clients that have been seen.
|
|
206
|
+
* - `seenHlc`: a function that takes an HLC and updates the internal state of
|
|
207
|
+
* the functions to ensure that the next HLC returned by `getNextHlc` is
|
|
208
|
+
* greater than the given seen HLC.
|
|
209
|
+
* - `encodeHlc`: a function that takes a timestamp, a counter (and optionally a
|
|
210
|
+
* different `clientId`) and encodes the them into an HLC string.
|
|
211
|
+
* - `decodeHlc`: a function that takes an HLC and returns an array containing
|
|
212
|
+
* the logical time, counter, and client Id parts.
|
|
213
|
+
* - `getLastLogicalTime`: a function that returns the last logical time either
|
|
214
|
+
* generated or seen by this client.
|
|
215
|
+
* - `getLastCounter`: a function that returns the last counter either generated
|
|
216
|
+
* or seen by this client.
|
|
217
|
+
* - `getClientId`: a function that returns the client Id for this client;
|
|
218
|
+
* either uniquely generated or derived from the `uniqueId` parameter.
|
|
219
|
+
* @param uniqueId An optional unique Id for the client.
|
|
220
|
+
* @param getNow An optional function that generates millisecond timestamps,
|
|
221
|
+
* defaulting to `Date.now`.
|
|
222
|
+
* @returns An array of seven stateful functions as described above.
|
|
223
|
+
* @category Stamps
|
|
224
|
+
* @since v6.2.0
|
|
225
|
+
* @example
|
|
226
|
+
* This example gets the HLC functions (for a given client Id and a fixed time;
|
|
227
|
+
* both for illustrative purposes), and then uses them:
|
|
228
|
+
*
|
|
229
|
+
* ```js
|
|
230
|
+
* import {getHlcFunctions} from 'tinybase';
|
|
231
|
+
*
|
|
232
|
+
* const [
|
|
233
|
+
* getNextHlc,
|
|
234
|
+
* seenHlc,
|
|
235
|
+
* encodeHlc,
|
|
236
|
+
* decodeHlc,
|
|
237
|
+
* getLastLogicalTime,
|
|
238
|
+
* getLastCounter,
|
|
239
|
+
* getClientId,
|
|
240
|
+
* ] = getHlcFunctions('client1', () => 73267200000); // This client is in 1972.
|
|
241
|
+
*
|
|
242
|
+
* // Generate an HLC based on the fixed time and the client Id.
|
|
243
|
+
* console.log(getNextHlc());
|
|
244
|
+
* // -> '03E3B------mmxrx'
|
|
245
|
+
*
|
|
246
|
+
* // Generate the next HLC. The time has not changed, so the counter does.
|
|
247
|
+
* console.log(getNextHlc());
|
|
248
|
+
* // -> '03E3B-----0mmxrx'
|
|
249
|
+
*
|
|
250
|
+
* // Another client thinks it is 1973.
|
|
251
|
+
* seenHlc('0WakTk-----jmx_3');
|
|
252
|
+
* // Generate the next HLC.
|
|
253
|
+
*
|
|
254
|
+
* // What is the state for the current client?
|
|
255
|
+
* console.log(getLastLogicalTime());
|
|
256
|
+
* // -> 104803200000
|
|
257
|
+
* console.log(getLastCounter());
|
|
258
|
+
* // -> 0
|
|
259
|
+
* console.log(getClientId());
|
|
260
|
+
* // -> 'mmxrx'
|
|
261
|
+
*
|
|
262
|
+
* // Encode an arbitrary HLC.
|
|
263
|
+
* console.log(encodeHlc(73267203600, 7, 'client3'));
|
|
264
|
+
* // -> '03E3BsF---6kmxfM'
|
|
265
|
+
*
|
|
266
|
+
* // Decode it again.
|
|
267
|
+
* console.log(decodeHlc('03E3BsF---6kmxfM'));
|
|
268
|
+
* // -> [73267203600, 7, 'kmxfM']
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export function getHlcFunctions(
|
|
272
|
+
uniqueId?: Id,
|
|
273
|
+
getNow?: GetNow,
|
|
274
|
+
): [
|
|
275
|
+
getNextHlc: () => Hlc,
|
|
276
|
+
seenHlc: (remoteHlc: Hlc) => void,
|
|
277
|
+
encodeHlc: (logicalTime: number, counter: number, clientId?: Id) => Hlc,
|
|
278
|
+
decodeHlc: (hlc: Hlc) => [logicalTime: number, counter: number, clientId: Id],
|
|
279
|
+
getLastLogicalTime: () => number,
|
|
280
|
+
getLastCounter: () => number,
|
|
281
|
+
getClientId: () => Id,
|
|
282
|
+
];
|
|
@@ -65,6 +65,34 @@ export type Callback = () => void;
|
|
|
65
65
|
*/
|
|
66
66
|
export type SortKey = string | number | boolean;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The GetNow type is used to represent a function that returns the current time
|
|
70
|
+
* in milliseconds.
|
|
71
|
+
*
|
|
72
|
+
* This is used internally within the mergeable-store module, but is used for
|
|
73
|
+
* the createMergeableStore function's second optional argument to allow
|
|
74
|
+
* applications to override the clock used to generate timestamps.
|
|
75
|
+
* @category Stamps
|
|
76
|
+
* @since v6.2.0
|
|
77
|
+
*/
|
|
78
|
+
export type GetNow = () => number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The Hlc type is a string that represents a Hybrid Logical Clock (HLC) value.
|
|
82
|
+
*
|
|
83
|
+
* HLCs are used to provide a globally unique timestamp that can be used to
|
|
84
|
+
* order events across distributed systems. The Hlc type in TinyBase is a
|
|
85
|
+
* sortable 16 character string that encodes a timestamp, a counter, and the
|
|
86
|
+
* hash of a unique client identifier.
|
|
87
|
+
*
|
|
88
|
+
* - 42 bits (7 chars) for the time in milliseconds (~139 years).
|
|
89
|
+
* - 24 bits (4 chars) for the counter (~16 million).
|
|
90
|
+
* - 30 bits (5 chars) for the hash of unique client id (~1 billion).
|
|
91
|
+
* @category Stamps
|
|
92
|
+
* @since v6.2.0
|
|
93
|
+
*/
|
|
94
|
+
export type Hlc = string;
|
|
95
|
+
|
|
68
96
|
/**
|
|
69
97
|
* The defaultSorter function is provided as a convenience to sort keys
|
|
70
98
|
* alphanumerically, and can be provided to the `sliceIdSorter` and
|
|
@@ -156,3 +184,99 @@ export function defaultSorter(sortKey1: SortKey, sortKey2: SortKey): number;
|
|
|
156
184
|
* @since v5.0.0
|
|
157
185
|
*/
|
|
158
186
|
export function getUniqueId(length?: number): Id;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The getHlcFunctions function returns a set of utility functions for working
|
|
190
|
+
* with the TinyBase Hybrid Logical Clock (HLC).
|
|
191
|
+
*
|
|
192
|
+
* An HLC is a sortable 16 character string that encodes a timestamp, a counter,
|
|
193
|
+
* and the hash of a unique client identifier. You should provide that unique
|
|
194
|
+
* client identifier as the `uniqueId` parameter to the function. Otherwise it
|
|
195
|
+
* will be defaulted and the client suffix of the HLCs the `getNextHlc` function
|
|
196
|
+
* generates will be non-deterministic.
|
|
197
|
+
*
|
|
198
|
+
* You can also provide a `getNow` function that returns the current time in
|
|
199
|
+
* milliseconds, which is useful for testing purposes where fully deterministic
|
|
200
|
+
* HLCs are required, rather than the current time.
|
|
201
|
+
*
|
|
202
|
+
* The stateful functions returned by this function are as follows.
|
|
203
|
+
*
|
|
204
|
+
* - `getNextHlc`: a function that returns the next HLC for this client based on
|
|
205
|
+
* the time and any other HLC values from other clients that have been seen.
|
|
206
|
+
* - `seenHlc`: a function that takes an HLC and updates the internal state of
|
|
207
|
+
* the functions to ensure that the next HLC returned by `getNextHlc` is
|
|
208
|
+
* greater than the given seen HLC.
|
|
209
|
+
* - `encodeHlc`: a function that takes a timestamp, a counter (and optionally a
|
|
210
|
+
* different `clientId`) and encodes the them into an HLC string.
|
|
211
|
+
* - `decodeHlc`: a function that takes an HLC and returns an array containing
|
|
212
|
+
* the logical time, counter, and client Id parts.
|
|
213
|
+
* - `getLastLogicalTime`: a function that returns the last logical time either
|
|
214
|
+
* generated or seen by this client.
|
|
215
|
+
* - `getLastCounter`: a function that returns the last counter either generated
|
|
216
|
+
* or seen by this client.
|
|
217
|
+
* - `getClientId`: a function that returns the client Id for this client;
|
|
218
|
+
* either uniquely generated or derived from the `uniqueId` parameter.
|
|
219
|
+
* @param uniqueId An optional unique Id for the client.
|
|
220
|
+
* @param getNow An optional function that generates millisecond timestamps,
|
|
221
|
+
* defaulting to `Date.now`.
|
|
222
|
+
* @returns An array of seven stateful functions as described above.
|
|
223
|
+
* @category Stamps
|
|
224
|
+
* @since v6.2.0
|
|
225
|
+
* @example
|
|
226
|
+
* This example gets the HLC functions (for a given client Id and a fixed time;
|
|
227
|
+
* both for illustrative purposes), and then uses them:
|
|
228
|
+
*
|
|
229
|
+
* ```js
|
|
230
|
+
* import {getHlcFunctions} from 'tinybase';
|
|
231
|
+
*
|
|
232
|
+
* const [
|
|
233
|
+
* getNextHlc,
|
|
234
|
+
* seenHlc,
|
|
235
|
+
* encodeHlc,
|
|
236
|
+
* decodeHlc,
|
|
237
|
+
* getLastLogicalTime,
|
|
238
|
+
* getLastCounter,
|
|
239
|
+
* getClientId,
|
|
240
|
+
* ] = getHlcFunctions('client1', () => 73267200000); // This client is in 1972.
|
|
241
|
+
*
|
|
242
|
+
* // Generate an HLC based on the fixed time and the client Id.
|
|
243
|
+
* console.log(getNextHlc());
|
|
244
|
+
* // -> '03E3B------mmxrx'
|
|
245
|
+
*
|
|
246
|
+
* // Generate the next HLC. The time has not changed, so the counter does.
|
|
247
|
+
* console.log(getNextHlc());
|
|
248
|
+
* // -> '03E3B-----0mmxrx'
|
|
249
|
+
*
|
|
250
|
+
* // Another client thinks it is 1973.
|
|
251
|
+
* seenHlc('0WakTk-----jmx_3');
|
|
252
|
+
* // Generate the next HLC.
|
|
253
|
+
*
|
|
254
|
+
* // What is the state for the current client?
|
|
255
|
+
* console.log(getLastLogicalTime());
|
|
256
|
+
* // -> 104803200000
|
|
257
|
+
* console.log(getLastCounter());
|
|
258
|
+
* // -> 0
|
|
259
|
+
* console.log(getClientId());
|
|
260
|
+
* // -> 'mmxrx'
|
|
261
|
+
*
|
|
262
|
+
* // Encode an arbitrary HLC.
|
|
263
|
+
* console.log(encodeHlc(73267203600, 7, 'client3'));
|
|
264
|
+
* // -> '03E3BsF---6kmxfM'
|
|
265
|
+
*
|
|
266
|
+
* // Decode it again.
|
|
267
|
+
* console.log(decodeHlc('03E3BsF---6kmxfM'));
|
|
268
|
+
* // -> [73267203600, 7, 'kmxfM']
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export function getHlcFunctions(
|
|
272
|
+
uniqueId?: Id,
|
|
273
|
+
getNow?: GetNow,
|
|
274
|
+
): [
|
|
275
|
+
getNextHlc: () => Hlc,
|
|
276
|
+
seenHlc: (remoteHlc: Hlc) => void,
|
|
277
|
+
encodeHlc: (logicalTime: number, counter: number, clientId?: Id) => Hlc,
|
|
278
|
+
decodeHlc: (hlc: Hlc) => [logicalTime: number, counter: number, clientId: Id],
|
|
279
|
+
getLastLogicalTime: () => number,
|
|
280
|
+
getLastCounter: () => number,
|
|
281
|
+
getClientId: () => Id,
|
|
282
|
+
];
|
package/@types/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @module mergeable-store
|
|
20
20
|
* @since v5.0.0
|
|
21
21
|
*/
|
|
22
|
-
import type {Id} from '../common/index.d.ts';
|
|
22
|
+
import type {GetNow, Id} from '../common/index.d.ts';
|
|
23
23
|
import type {
|
|
24
24
|
CellOrUndefined,
|
|
25
25
|
Content,
|
|
@@ -27,18 +27,6 @@ import type {
|
|
|
27
27
|
ValueOrUndefined,
|
|
28
28
|
} from '../store/index.d.ts';
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* The GetNow type is used to represent a function that returns the current time
|
|
32
|
-
* in milliseconds.
|
|
33
|
-
*
|
|
34
|
-
* This is used internally within the mergeable-store module, but is used for
|
|
35
|
-
* the createMergeableStore function's second optional argument to allow
|
|
36
|
-
* applications to override the clock used to generate timestamps.
|
|
37
|
-
* @category Stamps
|
|
38
|
-
* @since v6.1.0
|
|
39
|
-
*/
|
|
40
|
-
export type GetNow = () => number;
|
|
41
|
-
|
|
42
30
|
/**
|
|
43
31
|
* The Hash type is used within the mergeable-store module to quickly compare
|
|
44
32
|
* the content of two objects.
|
|
@@ -1061,7 +1049,7 @@ export interface MergeableStore extends Store {
|
|
|
1061
1049
|
* method).
|
|
1062
1050
|
* @param uniqueId An optional unique Id for the MergeableStore.
|
|
1063
1051
|
* @param getNow An optional function that generates millisecond timestamps,
|
|
1064
|
-
* since v6.1.0.
|
|
1052
|
+
* since v6.1.0, defaulting to `Date.now`.
|
|
1065
1053
|
* @returns A reference to the new MergeableStore.
|
|
1066
1054
|
* @example
|
|
1067
1055
|
* This example creates a MergeableStore.
|
|
@@ -24,7 +24,7 @@ import type {
|
|
|
24
24
|
TableIdFromSchema,
|
|
25
25
|
ValueIdFromSchema,
|
|
26
26
|
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
27
|
-
import type {Id} from '../../common/with-schemas/index.d.ts';
|
|
27
|
+
import type {GetNow, Id} from '../../common/with-schemas/index.d.ts';
|
|
28
28
|
import type {
|
|
29
29
|
CellOrUndefined,
|
|
30
30
|
Content,
|
|
@@ -40,18 +40,6 @@ import type {
|
|
|
40
40
|
ValuesSchema,
|
|
41
41
|
} from '../../store/with-schemas/index.d.ts';
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* The GetNow type is used to represent a function that returns the current time
|
|
45
|
-
* in milliseconds.
|
|
46
|
-
*
|
|
47
|
-
* This is used internally within the mergeable-store module, but is used for
|
|
48
|
-
* the createMergeableStore function's second optional argument to allow
|
|
49
|
-
* applications to override the clock used to generate timestamps.
|
|
50
|
-
* @category Stamps
|
|
51
|
-
* @since v6.1.0
|
|
52
|
-
*/
|
|
53
|
-
export type GetNow = () => number;
|
|
54
|
-
|
|
55
43
|
/**
|
|
56
44
|
* The Hash type is used within the mergeable-store module to quickly compare
|
|
57
45
|
* the content of two objects.
|
|
@@ -1553,7 +1541,7 @@ export interface MergeableStore<Schemas extends OptionalSchemas>
|
|
|
1553
1541
|
* method).
|
|
1554
1542
|
* @param uniqueId An optional unique Id for the MergeableStore.
|
|
1555
1543
|
* @param getNow An optional function that generates millisecond timestamps,
|
|
1556
|
-
* since v6.1.0.
|
|
1544
|
+
* since v6.1.0, defaulting to `Date.now`.
|
|
1557
1545
|
* @returns A reference to the new MergeableStore.
|
|
1558
1546
|
* @example
|
|
1559
1547
|
* This example creates a MergeableStore.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a package containing every TinyBase module.
|
|
3
|
+
*
|
|
4
|
+
* Use this if you are importing multiple persisters or synchronizers, for
|
|
5
|
+
* example, and you want to reduce duplication of their shared code.
|
|
6
|
+
*
|
|
7
|
+
* However, this approach assumes that you will tree-shake the resulting bundle
|
|
8
|
+
* to remove the unused code of all the other persisters and synchronizers that
|
|
9
|
+
* you do NOT use.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
* @since v1.0.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
+
// @ts-nocheck
|
|
16
|
+
|
|
17
|
+
export * from '../checkpoints/index.d.ts';
|
|
18
|
+
export * from '../common/index.d.ts';
|
|
19
|
+
export * from '../indexes/index.d.ts';
|
|
20
|
+
export * from '../mergeable-store/index.d.ts';
|
|
21
|
+
export * from '../metrics/index.d.ts';
|
|
22
|
+
export * from '../persisters/index.d.ts';
|
|
23
|
+
export * from '../persisters/persister-automerge/index.d.ts';
|
|
24
|
+
export * from '../persisters/persister-browser/index.d.ts';
|
|
25
|
+
export * from '../persisters/persister-cr-sqlite-wasm/index.d.ts';
|
|
26
|
+
export * from '../persisters/persister-durable-object-storage/index.d.ts';
|
|
27
|
+
export * from '../persisters/persister-electric-sql/index.d.ts';
|
|
28
|
+
export * from '../persisters/persister-expo-sqlite/index.d.ts';
|
|
29
|
+
export * from '../persisters/persister-file/index.d.ts';
|
|
30
|
+
export * from '../persisters/persister-indexed-db/index.d.ts';
|
|
31
|
+
export * from '../persisters/persister-libsql/index.d.ts';
|
|
32
|
+
export * from '../persisters/persister-partykit-client/index.d.ts';
|
|
33
|
+
export * from '../persisters/persister-partykit-server/index.d.ts';
|
|
34
|
+
export * from '../persisters/persister-pglite/index.d.ts';
|
|
35
|
+
export * from '../persisters/persister-postgres/index.d.ts';
|
|
36
|
+
export * from '../persisters/persister-powersync/index.d.ts';
|
|
37
|
+
export * from '../persisters/persister-remote/index.d.ts';
|
|
38
|
+
export * from '../persisters/persister-sqlite-bun/index.d.ts';
|
|
39
|
+
export * from '../persisters/persister-sqlite-wasm/index.d.ts';
|
|
40
|
+
export * from '../persisters/persister-sqlite3/index.d.ts';
|
|
41
|
+
export * from '../persisters/persister-yjs/index.d.ts';
|
|
42
|
+
export * from '../queries/index.d.ts';
|
|
43
|
+
export * from '../relationships/index.d.ts';
|
|
44
|
+
export * from '../store/index.d.ts';
|
|
45
|
+
export * from '../synchronizers/index.d.ts';
|
|
46
|
+
export * from '../synchronizers/synchronizer-broadcast-channel/index.d.ts';
|
|
47
|
+
export * from '../synchronizers/synchronizer-local/index.d.ts';
|
|
48
|
+
export * from '../synchronizers/synchronizer-ws-client/index.d.ts';
|
|
49
|
+
export * from '../synchronizers/synchronizer-ws-server-durable-object/index.d.ts';
|
|
50
|
+
export * from '../synchronizers/synchronizer-ws-server-simple/index.d.ts';
|
|
51
|
+
export * from '../synchronizers/synchronizer-ws-server/index.d.ts';
|
|
52
|
+
export * from '../ui-react-dom/index.d.ts';
|
|
53
|
+
export * from '../ui-react-inspector/index.d.ts';
|
|
54
|
+
export * from '../ui-react/index.d.ts';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a package containing every TinyBase module.
|
|
3
|
+
*
|
|
4
|
+
* Use this if you are importing multiple persisters or synchronizers, for
|
|
5
|
+
* example, and you want to reduce duplication of their shared code.
|
|
6
|
+
*
|
|
7
|
+
* However, this approach assumes that you will tree-shake the resulting bundle
|
|
8
|
+
* to remove the unused code of all the other persisters and synchronizers that
|
|
9
|
+
* you do NOT use.
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
* @since v1.0.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
+
// @ts-nocheck
|
|
16
|
+
|
|
17
|
+
export * from '../../checkpoints/with-schemas/index.d.ts';
|
|
18
|
+
export * from '../../common/with-schemas/index.d.ts';
|
|
19
|
+
export * from '../../indexes/with-schemas/index.d.ts';
|
|
20
|
+
export * from '../../mergeable-store/with-schemas/index.d.ts';
|
|
21
|
+
export * from '../../metrics/with-schemas/index.d.ts';
|
|
22
|
+
export * from '../../persisters/persister-automerge/with-schemas/index.d.ts';
|
|
23
|
+
export * from '../../persisters/persister-browser/with-schemas/index.d.ts';
|
|
24
|
+
export * from '../../persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts';
|
|
25
|
+
export * from '../../persisters/persister-durable-object-storage/with-schemas/index.d.ts';
|
|
26
|
+
export * from '../../persisters/persister-electric-sql/with-schemas/index.d.ts';
|
|
27
|
+
export * from '../../persisters/persister-expo-sqlite/with-schemas/index.d.ts';
|
|
28
|
+
export * from '../../persisters/persister-file/with-schemas/index.d.ts';
|
|
29
|
+
export * from '../../persisters/persister-indexed-db/with-schemas/index.d.ts';
|
|
30
|
+
export * from '../../persisters/persister-libsql/with-schemas/index.d.ts';
|
|
31
|
+
export * from '../../persisters/persister-partykit-client/with-schemas/index.d.ts';
|
|
32
|
+
export * from '../../persisters/persister-partykit-server/with-schemas/index.d.ts';
|
|
33
|
+
export * from '../../persisters/persister-pglite/with-schemas/index.d.ts';
|
|
34
|
+
export * from '../../persisters/persister-postgres/with-schemas/index.d.ts';
|
|
35
|
+
export * from '../../persisters/persister-powersync/with-schemas/index.d.ts';
|
|
36
|
+
export * from '../../persisters/persister-remote/with-schemas/index.d.ts';
|
|
37
|
+
export * from '../../persisters/persister-sqlite-bun/with-schemas/index.d.ts';
|
|
38
|
+
export * from '../../persisters/persister-sqlite-wasm/with-schemas/index.d.ts';
|
|
39
|
+
export * from '../../persisters/persister-sqlite3/with-schemas/index.d.ts';
|
|
40
|
+
export * from '../../persisters/persister-yjs/with-schemas/index.d.ts';
|
|
41
|
+
export * from '../../persisters/with-schemas/index.d.ts';
|
|
42
|
+
export * from '../../queries/with-schemas/index.d.ts';
|
|
43
|
+
export * from '../../relationships/with-schemas/index.d.ts';
|
|
44
|
+
export * from '../../store/with-schemas/index.d.ts';
|
|
45
|
+
export * from '../../synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.ts';
|
|
46
|
+
export * from '../../synchronizers/synchronizer-local/with-schemas/index.d.ts';
|
|
47
|
+
export * from '../../synchronizers/synchronizer-ws-client/with-schemas/index.d.ts';
|
|
48
|
+
export * from '../../synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts';
|
|
49
|
+
export * from '../../synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.ts';
|
|
50
|
+
export * from '../../synchronizers/synchronizer-ws-server/with-schemas/index.d.ts';
|
|
51
|
+
export * from '../../synchronizers/with-schemas/index.d.ts';
|
|
52
|
+
export * from '../../ui-react-dom/with-schemas/index.d.ts';
|
|
53
|
+
export * from '../../ui-react-inspector/with-schemas/index.d.ts';
|
|
54
|
+
export * from '../../ui-react/with-schemas/index.d.ts';
|
|
@@ -200,9 +200,9 @@ export type PersistedChanges<
|
|
|
200
200
|
* neither are present, the content will be loaded using the Persister's load
|
|
201
201
|
* method. Prior to v5.0, these parameters were callbacks and the overall type
|
|
202
202
|
* was non-generic.
|
|
203
|
-
* @param content If provided, this is a Content object from the
|
|
203
|
+
* @param content If provided, this is a Content object from the Persister
|
|
204
204
|
* that will be used to immediately wholesale update the Store.
|
|
205
|
-
* @param changes If provided, this is a Changes object from the
|
|
205
|
+
* @param changes If provided, this is a Changes object from the Persister
|
|
206
206
|
* that will be used to immediately incrementally update the Store. This takes
|
|
207
207
|
* priority over the content argument above if present.
|
|
208
208
|
* @category Creation
|
|
@@ -255,9 +255,9 @@ export type PersistedChanges<
|
|
|
255
255
|
* neither are present, the content will be loaded using the Persister's load
|
|
256
256
|
* method. Prior to v5.0, these parameters were callbacks and the overall type
|
|
257
257
|
* was non-generic.
|
|
258
|
-
* @param content If provided, this is a Content object from the
|
|
258
|
+
* @param content If provided, this is a Content object from the Persister
|
|
259
259
|
* that will be used to immediately wholesale update the Store.
|
|
260
|
-
* @param changes If provided, this is a Changes object from the
|
|
260
|
+
* @param changes If provided, this is a Changes object from the Persister
|
|
261
261
|
* that will be used to immediately incrementally update the Store. This takes
|
|
262
262
|
* priority over the content argument above if present.
|
|
263
263
|
* @category Creation
|
|
@@ -125,10 +125,10 @@ export type LocalRowIdsListener = (
|
|
|
125
125
|
*
|
|
126
126
|
* When called, a LinkedRowIdsListener is given a reference to the Relationships
|
|
127
127
|
* object, the Id of the Relationship that changed, and the Id of the first Row
|
|
128
|
-
* of the
|
|
128
|
+
* of the linked list whose members changed.
|
|
129
129
|
* @param relationships A reference to the Relationships object that changed.
|
|
130
130
|
* @param relationshipId The Id of the Relationship that changed.
|
|
131
|
-
* @param firstRowId The Id of the first Row of the
|
|
131
|
+
* @param firstRowId The Id of the first Row of the linked list whose
|
|
132
132
|
* members changed.
|
|
133
133
|
* @category Listener
|
|
134
134
|
* @since v1.0.0
|
|
@@ -182,10 +182,10 @@ export type LocalRowIdsListener<Schemas extends OptionalSchemas> = (
|
|
|
182
182
|
*
|
|
183
183
|
* When called, a LinkedRowIdsListener is given a reference to the Relationships
|
|
184
184
|
* object, the Id of the Relationship that changed, and the Id of the first Row
|
|
185
|
-
* of the
|
|
185
|
+
* of the linked list whose members changed.
|
|
186
186
|
* @param relationships A reference to the Relationships object that changed.
|
|
187
187
|
* @param relationshipId The Id of the Relationship that changed.
|
|
188
|
-
* @param firstRowId The Id of the first Row of the
|
|
188
|
+
* @param firstRowId The Id of the first Row of the linked list whose
|
|
189
189
|
* members changed.
|
|
190
190
|
* @category Listener
|
|
191
191
|
* @since v1.0.0
|
package/@types/store/index.d.ts
CHANGED
|
@@ -1389,7 +1389,7 @@ export type ChangedValues = {
|
|
|
1389
1389
|
* transaction, primarily used so that you can indicate whether the transaction
|
|
1390
1390
|
* should be rolled back.
|
|
1391
1391
|
*
|
|
1392
|
-
* It provides both the
|
|
1392
|
+
* It provides both the old and new Values in a two-part array. These
|
|
1393
1393
|
* describe the state of the changed Value in the Store at the _start_ of the
|
|
1394
1394
|
* transaction, and by the _end_ of the transaction.
|
|
1395
1395
|
*
|
|
@@ -2315,7 +2315,7 @@ export type ChangedValues<Schema extends OptionalValuesSchema> = {
|
|
|
2315
2315
|
* ];
|
|
2316
2316
|
* ```
|
|
2317
2317
|
*
|
|
2318
|
-
* It provides both the
|
|
2318
|
+
* It provides both the old and new Values in a two-part array. These
|
|
2319
2319
|
* describe the state of the changed Value in the Store at the _start_ of the
|
|
2320
2320
|
* transaction, and by the _end_ of the transaction.
|
|
2321
2321
|
*
|
|
@@ -213,7 +213,7 @@ export class WsServerDurableObject<Env = unknown> extends DurableObject<Env> {
|
|
|
213
213
|
*
|
|
214
214
|
* This is useful if you want to debug the synchronization process, though be
|
|
215
215
|
* aware that this method is called very frequently. It is called with the Id
|
|
216
|
-
* of the client the message came _from_, the
|
|
216
|
+
* of the client the message came _from_, the Id of the client the message
|
|
217
217
|
* is to be forwarded _to_, and the remainder of the message itself.
|
|
218
218
|
*
|
|
219
219
|
* Since this method is called often, it should be performant. The path Id is
|
|
@@ -233,7 +233,7 @@ export class WsServerDurableObject<
|
|
|
233
233
|
*
|
|
234
234
|
* This is useful if you want to debug the synchronization process, though be
|
|
235
235
|
* aware that this method is called very frequently. It is called with the Id
|
|
236
|
-
* of the client the message came _from_, the
|
|
236
|
+
* of the client the message came _from_, the Id of the client the message
|
|
237
237
|
* is to be forwarded _to_, and the remainder of the message itself.
|
|
238
238
|
*
|
|
239
239
|
* Since this method is called often, it should be performant. The path Id is
|