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.
Files changed (155) hide show
  1. package/@types/_internal/ui-react/with-schemas/index.d.ts +1 -1
  2. package/@types/common/index.d.ts +4 -4
  3. package/@types/common/with-schemas/index.d.ts +4 -4
  4. package/@types/index.d.ts +1 -1
  5. package/@types/persisters/persister-automerge/index.d.ts +1 -1
  6. package/@types/persisters/persister-automerge/with-schemas/index.d.ts +1 -1
  7. package/@types/persisters/persister-cr-sqlite-wasm/index.d.ts +1 -1
  8. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +1 -1
  9. package/@types/persisters/persister-electric-sql/index.d.ts +4 -4
  10. package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +4 -4
  11. package/@types/persisters/persister-expo-sqlite/index.d.ts +1 -1
  12. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +1 -1
  13. package/@types/persisters/persister-libsql/index.d.ts +1 -1
  14. package/@types/persisters/persister-libsql/with-schemas/index.d.ts +1 -1
  15. package/@types/persisters/persister-partykit-client/index.d.ts +1 -1
  16. package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +1 -1
  17. package/@types/persisters/persister-partykit-server/index.d.ts +7 -7
  18. package/@types/persisters/persister-partykit-server/with-schemas/index.d.ts +1 -1
  19. package/@types/persisters/persister-pglite/index.d.ts +1 -1
  20. package/@types/persisters/persister-pglite/with-schemas/index.d.ts +1 -1
  21. package/@types/persisters/persister-postgres/index.d.ts +1 -1
  22. package/@types/persisters/persister-postgres/with-schemas/index.d.ts +1 -1
  23. package/@types/persisters/persister-powersync/index.d.ts +1 -1
  24. package/@types/persisters/persister-powersync/with-schemas/index.d.ts +1 -1
  25. package/@types/persisters/persister-sqlite3/index.d.ts +1 -1
  26. package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +1 -1
  27. package/@types/persisters/persister-yjs/index.d.ts +1 -1
  28. package/@types/persisters/persister-yjs/with-schemas/index.d.ts +1 -1
  29. package/@types/synchronizers/synchronizer-ws-client/index.d.ts +1 -1
  30. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +1 -1
  31. package/@types/synchronizers/synchronizer-ws-server/index.d.ts +1 -1
  32. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +1 -1
  33. package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +1 -1
  34. package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +1 -1
  35. package/@types/ui-react/index.d.ts +3 -3
  36. package/@types/ui-react/with-schemas/index.d.ts +1 -1
  37. package/@types/ui-react-dom/index.d.ts +1 -1
  38. package/@types/ui-react-dom/with-schemas/index.d.ts +1 -1
  39. package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
  40. package/@types/with-schemas/index.d.ts +1 -1
  41. package/index.js +1579 -1567
  42. package/indexes/index.js +15 -3
  43. package/indexes/with-schemas/index.js +15 -3
  44. package/min/index.js +1 -1
  45. package/min/index.js.gz +0 -0
  46. package/min/indexes/index.js +1 -1
  47. package/min/indexes/index.js.gz +0 -0
  48. package/min/indexes/with-schemas/index.js +1 -1
  49. package/min/indexes/with-schemas/index.js.gz +0 -0
  50. package/min/persisters/index.js +1 -1
  51. package/min/persisters/index.js.gz +0 -0
  52. package/min/persisters/with-schemas/index.js +1 -1
  53. package/min/persisters/with-schemas/index.js.gz +0 -0
  54. package/min/ui-react/index.js +1 -1
  55. package/min/ui-react/index.js.gz +0 -0
  56. package/min/ui-react/with-schemas/index.js +1 -1
  57. package/min/ui-react/with-schemas/index.js.gz +0 -0
  58. package/min/with-schemas/index.js +1 -1
  59. package/min/with-schemas/index.js.gz +0 -0
  60. package/package.json +7 -10
  61. package/persisters/index.js +95 -95
  62. package/persisters/with-schemas/index.js +95 -95
  63. package/readme.md +13 -13
  64. package/releases.md +25 -25
  65. package/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  66. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  67. package/ui-react/index.js +64 -53
  68. package/ui-react/with-schemas/index.js +64 -53
  69. package/ui-react-dom/index.js +3 -3
  70. package/ui-react-dom/with-schemas/index.js +3 -3
  71. package/ui-react-inspector/index.js +4 -4
  72. package/ui-react-inspector/with-schemas/index.js +4 -4
  73. package/with-schemas/index.js +1579 -1567
  74. package/@types/_internal/queries/index.d.cts +0 -0
  75. package/@types/_internal/queries/with-schemas/index.d.cts +0 -22
  76. package/@types/_internal/store/index.d.cts +0 -3
  77. package/@types/_internal/store/with-schemas/index.d.cts +0 -106
  78. package/@types/_internal/ui-react/index.d.cts +0 -0
  79. package/@types/_internal/ui-react/with-schemas/index.d.cts +0 -1130
  80. package/@types/checkpoints/index.d.cts +0 -1059
  81. package/@types/checkpoints/with-schemas/index.d.cts +0 -1151
  82. package/@types/common/index.d.cts +0 -158
  83. package/@types/common/with-schemas/index.d.cts +0 -158
  84. package/@types/index.d.cts +0 -17
  85. package/@types/indexes/index.d.cts +0 -1064
  86. package/@types/indexes/with-schemas/index.d.cts +0 -1210
  87. package/@types/mergeable-store/index.d.cts +0 -1139
  88. package/@types/mergeable-store/with-schemas/index.d.cts +0 -1628
  89. package/@types/metrics/index.d.cts +0 -917
  90. package/@types/metrics/with-schemas/index.d.cts +0 -1004
  91. package/@types/persisters/index.d.cts +0 -1877
  92. package/@types/persisters/persister-automerge/index.d.cts +0 -165
  93. package/@types/persisters/persister-automerge/with-schemas/index.d.cts +0 -180
  94. package/@types/persisters/persister-browser/index.d.cts +0 -185
  95. package/@types/persisters/persister-browser/with-schemas/index.d.cts +0 -208
  96. package/@types/persisters/persister-cr-sqlite-wasm/index.d.cts +0 -159
  97. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.cts +0 -178
  98. package/@types/persisters/persister-durable-object-storage/index.d.cts +0 -122
  99. package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.cts +0 -136
  100. package/@types/persisters/persister-electric-sql/index.d.cts +0 -185
  101. package/@types/persisters/persister-electric-sql/with-schemas/index.d.cts +0 -204
  102. package/@types/persisters/persister-expo-sqlite/index.d.cts +0 -186
  103. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +0 -205
  104. package/@types/persisters/persister-file/index.d.cts +0 -94
  105. package/@types/persisters/persister-file/with-schemas/index.d.cts +0 -107
  106. package/@types/persisters/persister-indexed-db/index.d.cts +0 -120
  107. package/@types/persisters/persister-indexed-db/with-schemas/index.d.cts +0 -135
  108. package/@types/persisters/persister-libsql/index.d.cts +0 -158
  109. package/@types/persisters/persister-libsql/with-schemas/index.d.cts +0 -177
  110. package/@types/persisters/persister-partykit-client/index.d.cts +0 -195
  111. package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +0 -210
  112. package/@types/persisters/persister-partykit-server/index.d.cts +0 -650
  113. package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +0 -695
  114. package/@types/persisters/persister-pglite/index.d.cts +0 -177
  115. package/@types/persisters/persister-pglite/with-schemas/index.d.cts +0 -196
  116. package/@types/persisters/persister-postgres/index.d.cts +0 -166
  117. package/@types/persisters/persister-postgres/with-schemas/index.d.cts +0 -185
  118. package/@types/persisters/persister-powersync/index.d.cts +0 -174
  119. package/@types/persisters/persister-powersync/with-schemas/index.d.cts +0 -193
  120. package/@types/persisters/persister-remote/index.d.cts +0 -117
  121. package/@types/persisters/persister-remote/with-schemas/index.d.cts +0 -133
  122. package/@types/persisters/persister-sqlite-wasm/index.d.cts +0 -175
  123. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.cts +0 -195
  124. package/@types/persisters/persister-sqlite3/index.d.cts +0 -176
  125. package/@types/persisters/persister-sqlite3/with-schemas/index.d.cts +0 -195
  126. package/@types/persisters/persister-yjs/index.d.cts +0 -161
  127. package/@types/persisters/persister-yjs/with-schemas/index.d.cts +0 -176
  128. package/@types/persisters/with-schemas/index.d.cts +0 -2054
  129. package/@types/queries/index.d.cts +0 -3695
  130. package/@types/queries/with-schemas/index.d.cts +0 -4016
  131. package/@types/relationships/index.d.cts +0 -1320
  132. package/@types/relationships/with-schemas/index.d.cts +0 -1474
  133. package/@types/store/index.d.cts +0 -7598
  134. package/@types/store/with-schemas/index.d.cts +0 -9278
  135. package/@types/synchronizers/index.d.cts +0 -485
  136. package/@types/synchronizers/synchronizer-broadcast-channel/index.d.cts +0 -121
  137. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.cts +0 -137
  138. package/@types/synchronizers/synchronizer-local/index.d.cts +0 -95
  139. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.cts +0 -114
  140. package/@types/synchronizers/synchronizer-ws-client/index.d.cts +0 -160
  141. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +0 -179
  142. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +0 -736
  143. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +0 -765
  144. package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.cts +0 -311
  145. package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.cts +0 -349
  146. package/@types/synchronizers/synchronizer-ws-server-simple/index.d.cts +0 -144
  147. package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.cts +0 -144
  148. package/@types/synchronizers/with-schemas/index.d.cts +0 -503
  149. package/@types/ui-react/index.d.cts +0 -16640
  150. package/@types/ui-react/with-schemas/index.d.cts +0 -17281
  151. package/@types/ui-react-dom/index.d.cts +0 -1862
  152. package/@types/ui-react-dom/with-schemas/index.d.cts +0 -1994
  153. package/@types/ui-react-inspector/index.d.cts +0 -79
  154. package/@types/ui-react-inspector/with-schemas/index.d.cts +0 -1985
  155. 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;
@@ -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';