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,195 +0,0 @@
1
- /**
2
- * The persister-partykit-client module of the TinyBase project contains the
3
- * client portion of the PartyKit integration.
4
- *
5
- * It contains a Persister which, when run in a PartyKit client environment,
6
- * lets you save and load Store data from the client to the durable PartyKit
7
- * cloud storage of a server (that is using the complementary
8
- * persister-partykit-server module).
9
- *
10
- * This enables synchronization of the same Store across multiple clients in a
11
- * PartyKit party room.
12
- *
13
- * Note that both the client and server parts of this Persister are currently
14
- * experimental as PartyKit is new and still maturing.
15
- * @see Persistence guides
16
- * @packageDocumentation
17
- * @module persister-partykit-client
18
- * @since v4.3.0
19
- */
20
- import type {PartySocket} from 'partysocket';
21
- import type {Store} from '../../store/index.d.cts';
22
- import type {Persister} from '../index.d.cts';
23
-
24
- /**
25
- * The PartyKitPersister interface represents a Persister that lets you save and
26
- * load Store data from the client to the durable PartyKit cloud storage of a
27
- * server.
28
- *
29
- * You should use the createPartyKitPersister function to create a
30
- * PartyKitPersister object.
31
- *
32
- * It is a minor extension to the Persister interface and simply provides an
33
- * extra getConnection method for accessing the PartySocket the Store is being
34
- * persisted to.
35
- * @category Persister
36
- * @since v4.3.14
37
- */
38
- export interface PartyKitPersister extends Persister {
39
- /**
40
- * The getConnection method returns the PartySocket the Store is being
41
- * persisted to.
42
- * @returns The PartySocket.
43
- * @example
44
- * This example creates a Persister object against a newly-created Store and
45
- * then gets the PartySocket back out again.
46
- *
47
- * ```js yolo
48
- * import {PartySocket} from 'partysocket';
49
- * import {createStore} from 'tinybase';
50
- * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
51
- *
52
- * const partySocket = new PartySocket({
53
- * host: '127.0.0.1:1999',
54
- * room: 'my_room',
55
- * });
56
- * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
57
- * const persister = createPartyKitPersister(store, partySocket);
58
- *
59
- * console.log(persister.getConnection() == partySocket);
60
- * // -> true
61
- *
62
- * persister.destroy();
63
- * ```
64
- * @category Getter
65
- * @since v4.3.14
66
- */
67
- getConnection(): PartySocket;
68
- }
69
-
70
- /**
71
- * The PartyKitPersisterConfig type describes the configuration of a PartyKit
72
- * Persister on the client side.
73
- *
74
- * The defaults (if used on both the server and client) will work fine, but if
75
- * you are building more complex PartyKit apps and you need to configure path
76
- * names, for example, then this is the thing to use.
77
- * @example
78
- * When applied to a PartyKit Persister, this PartyKitPersisterConfig will load
79
- * and save a JSON serialization from and to an end point in your room called
80
- * `/my_tinybase`, and use HTTP (rather than the default HTTPS) as the protocol.
81
- *
82
- * Note that this would require you to also add the matching storePath setting
83
- * to the TinyBasePartyKitServerConfig on the server side.
84
- *
85
- * ```js
86
- * export const partyKitPersisterConfig = {
87
- * storeProtocol: 'http',
88
- * storePath: '/my_tinybase',
89
- * };
90
- * ```
91
- * @category Configuration
92
- * @since v4.3.9
93
- */
94
- export type PartyKitPersisterConfig = {
95
- /**
96
- * The HTTP protocol to use (in addition to the websocket channel). This
97
- * defaults to 'https' but you may wish to use 'http' for local PartyKit
98
- * development.
99
- * @category Configuration
100
- * @since v4.3.0
101
- */
102
- storeProtocol?: 'http' | 'https';
103
- /**
104
- * The path used to set and get the whole Store over HTTP(S) on the server.
105
- * This must match the storePath property of the TinyBasePartyKitServerConfig
106
- * object used on the server. Both default to '/store'.
107
- * @category Configuration
108
- * @since v4.3.0
109
- */
110
- storePath?: string;
111
- /**
112
- * The prefix at the beginning of the web socket messages sent between the
113
- * client and the server when synchronizing the Store. Use this to make sure
114
- * they do not collide with any other message syntax that your room is using.
115
- * This must match the messagePrefix property of the
116
- * TinyBasePartyKitServerConfig object used on the server. Both default to an
117
- * empty string.
118
- * @category Configuration
119
- * @since v4.3.0
120
- */
121
- messagePrefix?: string;
122
- };
123
-
124
- /**
125
- * The createPartyKitPersister function creates a PartyKitPersister object that
126
- * can persist the Store to durable PartyKit storage, enabling synchronization
127
- * of the same Store across multiple clients.
128
- *
129
- * A PartyKitPersister only supports regular Store objects, and cannot be used
130
- * to persist the metadata of a MergeableStore.
131
- *
132
- * As well as providing a reference to the Store to persist, you must provide a
133
- * `connection` parameter which is a PartyKit PartySocket that you have already
134
- * instantiated with details of the host and room.
135
- *
136
- * All suitably-equipped TinyBase clients connecting to that room will get to
137
- * share synchronized Store state.
138
- *
139
- * The server room's Store is considered the source of truth. If it is a
140
- * newly-created room, then calling the save method on this Persister will
141
- * initiate it. If, however, there is already a Store present on the server, the
142
- * save method will fail gracefully.
143
- *
144
- * In general, you are strongly recommended to use the auto-save and auto-load
145
- * functionality to stay in sync incrementally with the server, as per the
146
- * example below. This pattern will handle newly-created servers and
147
- * newly-created clients - and the synchronization involved in joining rooms,
148
- * leaving them, or temporarily going offline.
149
- *
150
- * See the [PartyKit client socket API
151
- * documentation](https://docs.partykit.io/reference/partysocket-api/) for more
152
- * details.
153
- * @param store The Store to persist.
154
- * @param connection The PartySocket to use for participating in the PartyKit
155
- * room.
156
- * @param configOrStoreProtocol The PartyKitPersisterConfig configuration for
157
- * the Persister, (or a string to specify a HTTP protocol to use, defaulting to
158
- * 'https').
159
- * @param onIgnoredError An optional handler for the errors that the Persister
160
- * would otherwise ignore when trying to save or load data. This is suitable for
161
- * debugging persistence issues in a development environment.
162
- * @returns A reference to the new PartyKitPersister object.
163
- * @example
164
- * This example creates a PartyKitPersister object and persists the Store to the
165
- * browser's IndexedDB storage.
166
- *
167
- * ```js yolo
168
- * import {PartySocket} from 'partysocket';
169
- * import {createStore} from 'tinybase';
170
- * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
171
- *
172
- * const store = createStore()
173
- * .setTable('pets', {fido: {species: 'dog'}})
174
- * .setTable('species', {dog: {price: 5}})
175
- * .setValues({open: true});
176
- * const partySocket = new PartySocket({
177
- * host: '127.0.0.1:1999',
178
- * room: 'my_room',
179
- * });
180
- * const persister = createPartyKitPersister(store, partySocket);
181
- * await persister.startAutoLoad();
182
- * await persister.startAutoSave();
183
- * // Store will now be synchronized with the room.
184
- *
185
- * persister.destroy();
186
- * ```
187
- * @category Creation
188
- * @since v4.3.0
189
- */
190
- export function createPartyKitPersister(
191
- store: Store,
192
- connection: PartySocket,
193
- configOrStoreProtocol?: PartyKitPersisterConfig | 'http' | 'https',
194
- onIgnoredError?: (error: any) => void,
195
- ): PartyKitPersister;
@@ -1,210 +0,0 @@
1
- /**
2
- * The persister-partykit-client module of the TinyBase project contains the
3
- * client portion of the PartyKit integration.
4
- *
5
- * It contains a Persister which, when run in a PartyKit client environment,
6
- * lets you save and load Store data from the client to the durable PartyKit
7
- * cloud storage of a server (that is using the complementary
8
- * persister-partykit-server module).
9
- *
10
- * This enables synchronization of the same Store across multiple clients in a
11
- * PartyKit party room.
12
- *
13
- * Note that both the client and server parts of this Persister are currently
14
- * experimental as PartyKit is new and still maturing.
15
- * @see Persistence guides
16
- * @packageDocumentation
17
- * @module persister-partykit-client
18
- * @since v4.3.0
19
- */
20
- import type {PartySocket} from 'partysocket';
21
- import type {
22
- OptionalSchemas,
23
- Store,
24
- } from '../../../store/with-schemas/index.d.cts';
25
- import type {Persister} from '../../with-schemas/index.d.cts';
26
-
27
- /**
28
- * The PartyKitPersister interface represents a Persister that lets you save and
29
- * load Store data from the client to the durable PartyKit cloud storage of a
30
- * server.
31
- *
32
- * You should use the createPartyKitPersister function to create a
33
- * PartyKitPersister object.
34
- *
35
- * It is a minor extension to the Persister interface and simply provides an
36
- * extra getConnection method for accessing the PartySocket the Store is being
37
- * persisted to.
38
- * @category Persister
39
- * @since v4.3.14
40
- */
41
- export interface PartyKitPersister<Schemas extends OptionalSchemas>
42
- extends Persister<Schemas> {
43
- /**
44
- * The getConnection method returns the PartySocket the Store is being
45
- * persisted to.
46
- * @returns The PartySocket.
47
- * @example
48
- * This example creates a Persister object against a newly-created Store and
49
- * then gets the PartySocket back out again.
50
- *
51
- * ```js yolo
52
- * import {PartySocket} from 'partysocket';
53
- * import {createStore} from 'tinybase';
54
- * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
55
- *
56
- * const partySocket = new PartySocket({
57
- * host: '127.0.0.1:1999',
58
- * room: 'my_room',
59
- * });
60
- * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
61
- * const persister = createPartyKitPersister(store, partySocket);
62
- *
63
- * console.log(persister.getConnection() == partySocket);
64
- * // -> true
65
- *
66
- * persister.destroy();
67
- * ```
68
- * @category Getter
69
- * @since v4.3.14
70
- */
71
- getConnection(): PartySocket;
72
- }
73
-
74
- /**
75
- * The PartyKitPersisterConfig type describes the configuration of a PartyKit
76
- * Persister on the client side.
77
- *
78
- * The defaults (if used on both the server and client) will work fine, but if
79
- * you are building more complex PartyKit apps and you need to configure path
80
- * names, for example, then this is the thing to use.
81
- * @example
82
- * When applied to a PartyKit Persister, this PartyKitPersisterConfig will load
83
- * and save a JSON serialization from and to an end point in your room called
84
- * `/my_tinybase`, and use HTTP (rather than the default HTTPS) as the protocol.
85
- *
86
- * Note that this would require you to also add the matching storePath setting
87
- * to the TinyBasePartyKitServerConfig on the server side.
88
- *
89
- * ```js
90
- * export const partyKitPersisterConfig = {
91
- * storeProtocol: 'http',
92
- * storePath: '/my_tinybase',
93
- * };
94
- * ```
95
- * @category Configuration
96
- * @since v4.3.9
97
- */
98
- export type PartyKitPersisterConfig = {
99
- /**
100
- * The HTTP protocol to use (in addition to the websocket channel). This
101
- * defaults to 'https' but you may wish to use 'http' for local PartyKit
102
- * development.
103
- * @category Configuration
104
- * @since v4.3.0
105
- */
106
- storeProtocol?: 'http' | 'https';
107
- /**
108
- * The path used to set and get the whole Store over HTTP(S) on the server.
109
- * This must match the storePath property of the TinyBasePartyKitServerConfig
110
- * object used on the server. Both default to '/store'.
111
- * @category Configuration
112
- * @since v4.3.0
113
- */
114
- storePath?: string;
115
- /**
116
- * The prefix at the beginning of the web socket messages sent between the
117
- * client and the server when synchronizing the Store. Use this to make sure
118
- * they do not collide with any other message syntax that your room is using.
119
- * This must match the messagePrefix property of the
120
- * TinyBasePartyKitServerConfig object used on the server. Both default to an
121
- * empty string.
122
- * @category Configuration
123
- * @since v4.3.0
124
- */
125
- messagePrefix?: string;
126
- };
127
-
128
- /**
129
- * The createPartyKitPersister function creates a PartyKitPersister object that
130
- * can persist the Store to durable PartyKit storage, enabling synchronization
131
- * of the same Store across multiple clients.
132
- *
133
- * This has schema-based typing. The following is a simplified representation:
134
- *
135
- * ```ts override
136
- * createPartyKitPersister(
137
- * store: Store,
138
- * connection: PartySocket,
139
- * configOrStoreProtocol?: PartyKitPersisterConfig | 'http' | 'https',
140
- * onIgnoredError?: (error: any) => void,
141
- * ): PartyKitPersister;
142
- * ```
143
- *
144
- * A PartyKitPersister only supports regular Store objects, and cannot be used
145
- * to persist the metadata of a MergeableStore.
146
- *
147
- * As well as providing a reference to the Store to persist, you must provide a
148
- * `connection` parameter which is a PartyKit PartySocket that you have already
149
- * instantiated with details of the host and room.
150
- *
151
- * All suitably-equipped TinyBase clients connecting to that room will get to
152
- * share synchronized Store state.
153
- *
154
- * The server room's Store is considered the source of truth. If it is a
155
- * newly-created room, then calling the save method on this Persister will
156
- * initiate it. If, however, there is already a Store present on the server, the
157
- * save method will fail gracefully.
158
- *
159
- * In general, you are strongly recommended to use the auto-save and auto-load
160
- * functionality to stay in sync incrementally with the server, as per the
161
- * example below. This pattern will handle newly-created servers and
162
- * newly-created clients - and the synchronization involved in joining rooms,
163
- * leaving them, or temporarily going offline.
164
- *
165
- * See the [PartyKit client socket API
166
- * documentation](https://docs.partykit.io/reference/partysocket-api/) for more
167
- * details.
168
- * @param store The Store to persist.
169
- * @param connection The PartySocket to use for participating in the PartyKit
170
- * room.
171
- * @param configOrStoreProtocol The PartyKitPersisterConfig configuration for
172
- * the Persister, (or a string to specify a HTTP protocol to use, defaulting to
173
- * 'https').
174
- * @param onIgnoredError An optional handler for the errors that the Persister
175
- * would otherwise ignore when trying to save or load data. This is suitable for
176
- * debugging persistence issues in a development environment.
177
- * @returns A reference to the new PartyKitPersister object.
178
- * @example
179
- * This example creates a PartyKitPersister object and persists the Store to the
180
- * browser's IndexedDB storage.
181
- *
182
- * ```js yolo
183
- * import {PartySocket} from 'partysocket';
184
- * import {createStore} from 'tinybase';
185
- * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
186
- *
187
- * const store = createStore()
188
- * .setTable('pets', {fido: {species: 'dog'}})
189
- * .setTable('species', {dog: {price: 5}})
190
- * .setValues({open: true});
191
- * const partySocket = new PartySocket({
192
- * host: '127.0.0.1:1999',
193
- * room: 'my_room',
194
- * });
195
- * const persister = createPartyKitPersister(store, partySocket);
196
- * await persister.startAutoLoad();
197
- * await persister.startAutoSave();
198
- * // Store will now be synchronized with the room.
199
- *
200
- * persister.destroy();
201
- * ```
202
- * @category Creation
203
- * @since v4.3.0
204
- */
205
- export function createPartyKitPersister<Schemas extends OptionalSchemas>(
206
- store: Store<Schemas>,
207
- connection: PartySocket,
208
- configOrStoreProtocol?: PartyKitPersisterConfig | 'http' | 'https',
209
- onIgnoredError?: (error: any) => void,
210
- ): PartyKitPersister<Schemas>;