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