tinybase 6.1.0-beta.0 → 6.1.0-beta.2
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/_internal/ui-react/with-schemas/index.d.ts +1 -1
- package/@types/common/index.d.ts +4 -4
- package/@types/common/with-schemas/index.d.ts +4 -4
- package/@types/index.d.ts +1 -1
- package/@types/persisters/persister-automerge/index.d.ts +1 -1
- package/@types/persisters/persister-automerge/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-cr-sqlite-wasm/index.d.ts +1 -1
- package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-electric-sql/index.d.ts +4 -4
- package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +4 -4
- package/@types/persisters/persister-expo-sqlite/index.d.ts +1 -1
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-libsql/index.d.ts +1 -1
- package/@types/persisters/persister-libsql/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-partykit-client/index.d.ts +1 -1
- package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-partykit-server/index.d.ts +7 -7
- package/@types/persisters/persister-partykit-server/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-pglite/index.d.ts +1 -1
- package/@types/persisters/persister-pglite/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-postgres/index.d.ts +1 -1
- package/@types/persisters/persister-postgres/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-powersync/index.d.ts +1 -1
- package/@types/persisters/persister-powersync/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-sqlite3/index.d.ts +1 -1
- package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +1 -1
- package/@types/persisters/persister-yjs/index.d.ts +1 -1
- package/@types/persisters/persister-yjs/with-schemas/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server/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/ui-react/index.d.ts +3 -3
- package/@types/ui-react/with-schemas/index.d.ts +1 -1
- package/@types/ui-react-dom/index.d.ts +1 -1
- package/@types/ui-react-dom/with-schemas/index.d.ts +1 -1
- package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
- package/@types/with-schemas/index.d.ts +1 -1
- package/index.js +1579 -1567
- package/indexes/index.js +15 -3
- package/indexes/with-schemas/index.js +15 -3
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/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/package.json +7 -10
- package/persisters/index.js +95 -95
- package/persisters/with-schemas/index.js +95 -95
- package/readme.md +13 -13
- package/releases.md +25 -25
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/ui-react/index.js +64 -53
- package/ui-react/with-schemas/index.js +64 -53
- package/ui-react-dom/index.js +3 -3
- package/ui-react-dom/with-schemas/index.js +3 -3
- package/ui-react-inspector/index.js +4 -4
- package/ui-react-inspector/with-schemas/index.js +4 -4
- package/with-schemas/index.js +1579 -1567
- package/@types/_internal/queries/index.d.cts +0 -0
- package/@types/_internal/queries/with-schemas/index.d.cts +0 -22
- package/@types/_internal/store/index.d.cts +0 -3
- package/@types/_internal/store/with-schemas/index.d.cts +0 -106
- package/@types/_internal/ui-react/index.d.cts +0 -0
- package/@types/_internal/ui-react/with-schemas/index.d.cts +0 -1130
- package/@types/checkpoints/index.d.cts +0 -1059
- package/@types/checkpoints/with-schemas/index.d.cts +0 -1151
- package/@types/common/index.d.cts +0 -158
- package/@types/common/with-schemas/index.d.cts +0 -158
- package/@types/index.d.cts +0 -17
- package/@types/indexes/index.d.cts +0 -1064
- package/@types/indexes/with-schemas/index.d.cts +0 -1210
- package/@types/mergeable-store/index.d.cts +0 -1139
- package/@types/mergeable-store/with-schemas/index.d.cts +0 -1628
- package/@types/metrics/index.d.cts +0 -917
- package/@types/metrics/with-schemas/index.d.cts +0 -1004
- package/@types/persisters/index.d.cts +0 -1877
- package/@types/persisters/persister-automerge/index.d.cts +0 -165
- package/@types/persisters/persister-automerge/with-schemas/index.d.cts +0 -180
- package/@types/persisters/persister-browser/index.d.cts +0 -185
- package/@types/persisters/persister-browser/with-schemas/index.d.cts +0 -208
- package/@types/persisters/persister-cr-sqlite-wasm/index.d.cts +0 -159
- package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.cts +0 -178
- package/@types/persisters/persister-durable-object-storage/index.d.cts +0 -122
- package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.cts +0 -136
- package/@types/persisters/persister-electric-sql/index.d.cts +0 -185
- package/@types/persisters/persister-electric-sql/with-schemas/index.d.cts +0 -204
- package/@types/persisters/persister-expo-sqlite/index.d.cts +0 -186
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +0 -205
- package/@types/persisters/persister-file/index.d.cts +0 -94
- package/@types/persisters/persister-file/with-schemas/index.d.cts +0 -107
- package/@types/persisters/persister-indexed-db/index.d.cts +0 -120
- package/@types/persisters/persister-indexed-db/with-schemas/index.d.cts +0 -135
- package/@types/persisters/persister-libsql/index.d.cts +0 -158
- package/@types/persisters/persister-libsql/with-schemas/index.d.cts +0 -177
- package/@types/persisters/persister-partykit-client/index.d.cts +0 -195
- package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +0 -210
- package/@types/persisters/persister-partykit-server/index.d.cts +0 -650
- package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +0 -695
- package/@types/persisters/persister-pglite/index.d.cts +0 -177
- package/@types/persisters/persister-pglite/with-schemas/index.d.cts +0 -196
- package/@types/persisters/persister-postgres/index.d.cts +0 -166
- package/@types/persisters/persister-postgres/with-schemas/index.d.cts +0 -185
- package/@types/persisters/persister-powersync/index.d.cts +0 -174
- package/@types/persisters/persister-powersync/with-schemas/index.d.cts +0 -193
- package/@types/persisters/persister-remote/index.d.cts +0 -117
- package/@types/persisters/persister-remote/with-schemas/index.d.cts +0 -133
- package/@types/persisters/persister-sqlite-wasm/index.d.cts +0 -175
- package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.cts +0 -195
- package/@types/persisters/persister-sqlite3/index.d.cts +0 -176
- package/@types/persisters/persister-sqlite3/with-schemas/index.d.cts +0 -195
- package/@types/persisters/persister-yjs/index.d.cts +0 -161
- package/@types/persisters/persister-yjs/with-schemas/index.d.cts +0 -176
- package/@types/persisters/with-schemas/index.d.cts +0 -2054
- package/@types/queries/index.d.cts +0 -3695
- package/@types/queries/with-schemas/index.d.cts +0 -4016
- package/@types/relationships/index.d.cts +0 -1320
- package/@types/relationships/with-schemas/index.d.cts +0 -1474
- package/@types/store/index.d.cts +0 -7598
- package/@types/store/with-schemas/index.d.cts +0 -9278
- package/@types/synchronizers/index.d.cts +0 -485
- package/@types/synchronizers/synchronizer-broadcast-channel/index.d.cts +0 -121
- package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.cts +0 -137
- package/@types/synchronizers/synchronizer-local/index.d.cts +0 -95
- package/@types/synchronizers/synchronizer-local/with-schemas/index.d.cts +0 -114
- package/@types/synchronizers/synchronizer-ws-client/index.d.cts +0 -160
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +0 -179
- package/@types/synchronizers/synchronizer-ws-server/index.d.cts +0 -736
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +0 -765
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +0 -311
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +0 -349
- package/@types/synchronizers/synchronizer-ws-server-simple/index.d.cts +0 -144
- package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.cts +0 -144
- package/@types/synchronizers/with-schemas/index.d.cts +0 -503
- package/@types/ui-react/index.d.cts +0 -16640
- package/@types/ui-react/with-schemas/index.d.cts +0 -17281
- package/@types/ui-react-dom/index.d.cts +0 -1862
- package/@types/ui-react-dom/with-schemas/index.d.cts +0 -1994
- package/@types/ui-react-inspector/index.d.cts +0 -79
- package/@types/ui-react-inspector/with-schemas/index.d.cts +0 -1985
- package/@types/with-schemas/index.d.cts +0 -17
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The common module of the TinyBase project provides a small collection of
|
|
3
|
-
* common types used across other modules.
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
* @module common
|
|
6
|
-
* @since v1.0.0
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The Json type is a simple alias for a string, but is used to indicate that
|
|
11
|
-
* the string should be considered to be a JSON serialization of an object.
|
|
12
|
-
* @category General
|
|
13
|
-
* @since v1.0.0
|
|
14
|
-
*/
|
|
15
|
-
export type Json = string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The Ids type is a simple alias for an array of strings, but is used to
|
|
19
|
-
* indicate that the strings should be considered to be the keys of objects
|
|
20
|
-
* (such as the Row Id strings used in a Table).
|
|
21
|
-
* @category Identity
|
|
22
|
-
* @since v1.0.0
|
|
23
|
-
*/
|
|
24
|
-
export type Ids = Id[];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The Id type is a simple alias for a string, but is used to indicate that the
|
|
28
|
-
* string should be considered to be the key of an object (such as a Row Id
|
|
29
|
-
* string used in a Table).
|
|
30
|
-
* @category Identity
|
|
31
|
-
* @since v1.0.0
|
|
32
|
-
*/
|
|
33
|
-
export type Id = string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The Id type is a simple alias for the union of a string or `null` value,
|
|
37
|
-
* where the string should be considered to be the key of an objects (such as a
|
|
38
|
-
* Row Id string used in a Table), and typically `null` indicates a wildcard -
|
|
39
|
-
* such as when used in the Store addRowListener method.
|
|
40
|
-
* @category Identity
|
|
41
|
-
* @since v1.0.0
|
|
42
|
-
*/
|
|
43
|
-
export type IdOrNull = Id | null;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The ParameterizedCallback type represents a generic function that will take
|
|
47
|
-
* an optional parameter - such as the handler of a DOM event.
|
|
48
|
-
* @category Callback
|
|
49
|
-
* @since v1.0.0
|
|
50
|
-
*/
|
|
51
|
-
export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The Callback type represents a function that is used as a callback and which
|
|
55
|
-
* does not take a parameter.
|
|
56
|
-
* @category Callback
|
|
57
|
-
* @since v1.0.0
|
|
58
|
-
*/
|
|
59
|
-
export type Callback = () => void;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The SortKey type represents a value that can be used by a sort function.
|
|
63
|
-
* @category Parameter
|
|
64
|
-
* @since v1.0.0
|
|
65
|
-
*/
|
|
66
|
-
export type SortKey = string | number | boolean;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The defaultSorter function is provided as a convenience to sort keys
|
|
70
|
-
* alphanumerically, and can be provided to the `sliceIdSorter` and
|
|
71
|
-
* `rowIdSorter` parameters of the setIndexDefinition method in the indexes
|
|
72
|
-
* module, for example.
|
|
73
|
-
* @param sortKey1 The first item of the pair to compare.
|
|
74
|
-
* @param sortKey2 The second item of the pair to compare.
|
|
75
|
-
* @returns A number indicating how to sort the pair.
|
|
76
|
-
* @example
|
|
77
|
-
* This example creates an Indexes object.
|
|
78
|
-
*
|
|
79
|
-
* ```js
|
|
80
|
-
* import {createIndexes, createStore} from 'tinybase';
|
|
81
|
-
*
|
|
82
|
-
* const store = createStore();
|
|
83
|
-
* const indexes = createIndexes(store);
|
|
84
|
-
* console.log(indexes.getIndexIds());
|
|
85
|
-
* // -> []
|
|
86
|
-
* ```
|
|
87
|
-
* @example
|
|
88
|
-
* This example creates a Store, creates an Indexes object, and defines an
|
|
89
|
-
* Index based on the first letter of the pets' names. The Slice Ids (and Row
|
|
90
|
-
* Ids within them) are alphabetically sorted using the defaultSorter function.
|
|
91
|
-
*
|
|
92
|
-
* ```js
|
|
93
|
-
* import {createIndexes, createStore, defaultSorter} from 'tinybase';
|
|
94
|
-
*
|
|
95
|
-
* const store = createStore().setTable('pets', {
|
|
96
|
-
* fido: {species: 'dog'},
|
|
97
|
-
* felix: {species: 'cat'},
|
|
98
|
-
* cujo: {species: 'dog'},
|
|
99
|
-
* });
|
|
100
|
-
*
|
|
101
|
-
* const indexes = createIndexes(store);
|
|
102
|
-
* indexes.setIndexDefinition(
|
|
103
|
-
* 'byFirst', // indexId
|
|
104
|
-
* 'pets', // tableId
|
|
105
|
-
* (_, rowId) => rowId[0], // each Row's Slice Id
|
|
106
|
-
* (_, rowId) => rowId, // each Row's sort key
|
|
107
|
-
* defaultSorter, // sort Slice Ids
|
|
108
|
-
* defaultSorter, // sort Row Ids by sort key
|
|
109
|
-
* );
|
|
110
|
-
*
|
|
111
|
-
* console.log(indexes.getSliceIds('byFirst'));
|
|
112
|
-
* // -> ['c', 'f']
|
|
113
|
-
* console.log(indexes.getSliceRowIds('byFirst', 'f'));
|
|
114
|
-
* // -> ['felix', 'fido']
|
|
115
|
-
* ```
|
|
116
|
-
* @category Convenience
|
|
117
|
-
* @since v1.0.0
|
|
118
|
-
*/
|
|
119
|
-
export function defaultSorter(sortKey1: SortKey, sortKey2: SortKey): number;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* The getUniqueId function returns a unique string of a given length.
|
|
123
|
-
*
|
|
124
|
-
* This is used internally by TinyBase for the synchronizer protocol and for
|
|
125
|
-
* unique MergeableStore identifiers. But it is useful enough for it to be
|
|
126
|
-
* publicly exposed for purposes such as identifying shared collaboration rooms,
|
|
127
|
-
* or creating other Ids that need to be unique.
|
|
128
|
-
*
|
|
129
|
-
* The string may contain numbers, lower or upper case letters, or the '-' or
|
|
130
|
-
* '_' characters. This makes them URL-safe, and means they can be identified
|
|
131
|
-
* with a regex like `/[-_0-9A-Za-z]+/`.
|
|
132
|
-
*
|
|
133
|
-
* This function prefers to use the `crypto` module to generate random numbers,
|
|
134
|
-
* but where that is not available (such as in React Native), a `Math.random`
|
|
135
|
-
* implementation is used. Whilst that may not be cryptographically sound, it
|
|
136
|
-
* should suffice for most TinyBase-related purposes.
|
|
137
|
-
* @param length The desired length of the unique Id, defaulting to 16.
|
|
138
|
-
* @returns A unique Id of the required length.
|
|
139
|
-
* @example
|
|
140
|
-
* This example creates two 8 character long Ids and compares them.
|
|
141
|
-
*
|
|
142
|
-
* ```js
|
|
143
|
-
* import {getUniqueId} from 'tinybase';
|
|
144
|
-
*
|
|
145
|
-
* const id1 = getUniqueId(8);
|
|
146
|
-
* const id2 = getUniqueId(8);
|
|
147
|
-
*
|
|
148
|
-
* console.log(id1.length);
|
|
149
|
-
* // -> 8
|
|
150
|
-
* console.log(id2.length);
|
|
151
|
-
* // -> 8
|
|
152
|
-
* console.log(id1 == id2);
|
|
153
|
-
* // -> false
|
|
154
|
-
* ```
|
|
155
|
-
* @category Convenience
|
|
156
|
-
* @since v5.0.0
|
|
157
|
-
*/
|
|
158
|
-
export function getUniqueId(length?: number): Id;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The common module of the TinyBase project provides a small collection of
|
|
3
|
-
* common types used across other modules.
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
* @module common
|
|
6
|
-
* @since v1.0.0
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The Json type is a simple alias for a string, but is used to indicate that
|
|
11
|
-
* the string should be considered to be a JSON serialization of an object.
|
|
12
|
-
* @category General
|
|
13
|
-
* @since v1.0.0
|
|
14
|
-
*/
|
|
15
|
-
export type Json = string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The Ids type is a simple alias for an array of strings, but is used to
|
|
19
|
-
* indicate that the strings should be considered to be the keys of objects
|
|
20
|
-
* (such as the Row Id strings used in a Table).
|
|
21
|
-
* @category Identity
|
|
22
|
-
* @since v1.0.0
|
|
23
|
-
*/
|
|
24
|
-
export type Ids = Id[];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The Id type is a simple alias for a string, but is used to indicate that the
|
|
28
|
-
* string should be considered to be the key of an object (such as a Row Id
|
|
29
|
-
* string used in a Table).
|
|
30
|
-
* @category Identity
|
|
31
|
-
* @since v1.0.0
|
|
32
|
-
*/
|
|
33
|
-
export type Id = string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The Id type is a simple alias for the union of a string or `null` value,
|
|
37
|
-
* where the string should be considered to be the key of an objects (such as a
|
|
38
|
-
* Row Id string used in a Table), and typically `null` indicates a wildcard -
|
|
39
|
-
* such as when used in the Store addRowListener method.
|
|
40
|
-
* @category Identity
|
|
41
|
-
* @since v1.0.0
|
|
42
|
-
*/
|
|
43
|
-
export type IdOrNull = Id | null;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The ParameterizedCallback type represents a generic function that will take
|
|
47
|
-
* an optional parameter - such as the handler of a DOM event.
|
|
48
|
-
* @category Callback
|
|
49
|
-
* @since v1.0.0
|
|
50
|
-
*/
|
|
51
|
-
export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The Callback type represents a function that is used as a callback and which
|
|
55
|
-
* does not take a parameter.
|
|
56
|
-
* @category Callback
|
|
57
|
-
* @since v1.0.0
|
|
58
|
-
*/
|
|
59
|
-
export type Callback = () => void;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The SortKey type represents a value that can be used by a sort function.
|
|
63
|
-
* @category Parameter
|
|
64
|
-
* @since v1.0.0
|
|
65
|
-
*/
|
|
66
|
-
export type SortKey = string | number | boolean;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The defaultSorter function is provided as a convenience to sort keys
|
|
70
|
-
* alphanumerically, and can be provided to the `sliceIdSorter` and
|
|
71
|
-
* `rowIdSorter` parameters of the setIndexDefinition method in the indexes
|
|
72
|
-
* module, for example.
|
|
73
|
-
* @param sortKey1 The first item of the pair to compare.
|
|
74
|
-
* @param sortKey2 The second item of the pair to compare.
|
|
75
|
-
* @returns A number indicating how to sort the pair.
|
|
76
|
-
* @example
|
|
77
|
-
* This example creates an Indexes object.
|
|
78
|
-
*
|
|
79
|
-
* ```js
|
|
80
|
-
* import {createIndexes, createStore} from 'tinybase';
|
|
81
|
-
*
|
|
82
|
-
* const store = createStore();
|
|
83
|
-
* const indexes = createIndexes(store);
|
|
84
|
-
* console.log(indexes.getIndexIds());
|
|
85
|
-
* // -> []
|
|
86
|
-
* ```
|
|
87
|
-
* @example
|
|
88
|
-
* This example creates a Store, creates an Indexes object, and defines an
|
|
89
|
-
* Index based on the first letter of the pets' names. The Slice Ids (and Row
|
|
90
|
-
* Ids within them) are alphabetically sorted using the defaultSorter function.
|
|
91
|
-
*
|
|
92
|
-
* ```js
|
|
93
|
-
* import {createIndexes, createStore, defaultSorter} from 'tinybase';
|
|
94
|
-
*
|
|
95
|
-
* const store = createStore().setTable('pets', {
|
|
96
|
-
* fido: {species: 'dog'},
|
|
97
|
-
* felix: {species: 'cat'},
|
|
98
|
-
* cujo: {species: 'dog'},
|
|
99
|
-
* });
|
|
100
|
-
*
|
|
101
|
-
* const indexes = createIndexes(store);
|
|
102
|
-
* indexes.setIndexDefinition(
|
|
103
|
-
* 'byFirst', // indexId
|
|
104
|
-
* 'pets', // tableId
|
|
105
|
-
* (_, rowId) => rowId[0], // each Row's Slice Id
|
|
106
|
-
* (_, rowId) => rowId, // each Row's sort key
|
|
107
|
-
* defaultSorter, // sort Slice Ids
|
|
108
|
-
* defaultSorter, // sort Row Ids by sort key
|
|
109
|
-
* );
|
|
110
|
-
*
|
|
111
|
-
* console.log(indexes.getSliceIds('byFirst'));
|
|
112
|
-
* // -> ['c', 'f']
|
|
113
|
-
* console.log(indexes.getSliceRowIds('byFirst', 'f'));
|
|
114
|
-
* // -> ['felix', 'fido']
|
|
115
|
-
* ```
|
|
116
|
-
* @category Convenience
|
|
117
|
-
* @since v1.0.0
|
|
118
|
-
*/
|
|
119
|
-
export function defaultSorter(sortKey1: SortKey, sortKey2: SortKey): number;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* The getUniqueId function returns a unique string of a given length.
|
|
123
|
-
*
|
|
124
|
-
* This is used internally by TinyBase for the synchronizer protocol and for
|
|
125
|
-
* unique MergeableStore identifiers. But it is useful enough for it to be
|
|
126
|
-
* publicly exposed for purposes such as identifying shared collaboration rooms,
|
|
127
|
-
* or creating other Ids that need to be unique.
|
|
128
|
-
*
|
|
129
|
-
* The string may contain numbers, lower or upper case letters, or the '-' or
|
|
130
|
-
* '_' characters. This makes them URL-safe, and means they can be identified
|
|
131
|
-
* with a regex like `/[-_0-9A-Za-z]+/`.
|
|
132
|
-
*
|
|
133
|
-
* This function prefers to use the `crypto` module to generate random numbers,
|
|
134
|
-
* but where that is not available (such as in React Native), a `Math.random`
|
|
135
|
-
* implementation is used. Whilst that may not be cryptographically sound, it
|
|
136
|
-
* should suffice for most TinyBase-related purposes.
|
|
137
|
-
* @param length The desired length of the unique Id, defaulting to 16.
|
|
138
|
-
* @returns A unique Id of the required length.
|
|
139
|
-
* @example
|
|
140
|
-
* This example creates two 8 character long Ids and compares them.
|
|
141
|
-
*
|
|
142
|
-
* ```js
|
|
143
|
-
* import {getUniqueId} from 'tinybase';
|
|
144
|
-
*
|
|
145
|
-
* const id1 = getUniqueId(8);
|
|
146
|
-
* const id2 = getUniqueId(8);
|
|
147
|
-
*
|
|
148
|
-
* console.log(id1.length);
|
|
149
|
-
* // -> 8
|
|
150
|
-
* console.log(id2.length);
|
|
151
|
-
* // -> 8
|
|
152
|
-
* console.log(id1 == id2);
|
|
153
|
-
* // -> false
|
|
154
|
-
* ```
|
|
155
|
-
* @category Convenience
|
|
156
|
-
* @since v5.0.0
|
|
157
|
-
*/
|
|
158
|
-
export function getUniqueId(length?: number): Id;
|
package/@types/index.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is everything.
|
|
3
|
-
* @packageDocumentation
|
|
4
|
-
* @since v1.0.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
-
// @ts-nocheck
|
|
9
|
-
|
|
10
|
-
export * from './checkpoints/index.d.cts';
|
|
11
|
-
export * from './common/index.d.cts';
|
|
12
|
-
export * from './indexes/index.d.cts';
|
|
13
|
-
export * from './metrics/index.d.cts';
|
|
14
|
-
export * from './queries/index.d.cts';
|
|
15
|
-
export * from './relationships/index.d.cts';
|
|
16
|
-
export * from './mergeable-store/index.d.cts';
|
|
17
|
-
export * from './store/index.d.cts';
|