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