tinybase 4.3.11 → 4.3.13

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 (38) hide show
  1. package/lib/cjs/persisters/persister-partykit-client.cjs +1 -1
  2. package/lib/cjs/persisters/persister-partykit-client.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  4. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  5. package/lib/cjs-es6/persisters/persister-partykit-client.cjs +1 -1
  6. package/lib/cjs-es6/persisters/persister-partykit-client.cjs.gz +0 -0
  7. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  8. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  9. package/lib/debug/persisters/persister-partykit-client.js +29 -19
  10. package/lib/debug/persisters/persister-partykit-server.js +160 -78
  11. package/lib/es6/persisters/persister-partykit-client.js +1 -1
  12. package/lib/es6/persisters/persister-partykit-client.js.gz +0 -0
  13. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  14. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  15. package/lib/persisters/persister-partykit-client.js +1 -1
  16. package/lib/persisters/persister-partykit-client.js.gz +0 -0
  17. package/lib/persisters/persister-partykit-server.js +1 -1
  18. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  19. package/lib/types/persisters/persister-indexed-db.d.ts +4 -5
  20. package/lib/types/persisters/persister-partykit-client.d.ts +19 -8
  21. package/lib/types/persisters/persister-partykit-server.d.ts +350 -12
  22. package/lib/types/tools.d.ts +4 -6
  23. package/lib/types/ui-react.d.ts +4 -4
  24. package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +4 -5
  25. package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +19 -8
  26. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +383 -12
  27. package/lib/types/with-schemas/tools.d.ts +4 -6
  28. package/lib/types/with-schemas/ui-react.d.ts +4 -4
  29. package/lib/umd/persisters/persister-partykit-client.js +1 -1
  30. package/lib/umd/persisters/persister-partykit-client.js.gz +0 -0
  31. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  32. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  33. package/lib/umd-es6/persisters/persister-partykit-client.js +1 -1
  34. package/lib/umd-es6/persisters/persister-partykit-client.js.gz +0 -0
  35. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  36. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  37. package/package.json +15 -15
  38. package/readme.md +2 -2
@@ -40,11 +40,10 @@ import {Store} from '../store';
40
40
  * browser's IndexedDB storage.
41
41
  *
42
42
  * ```js
43
- * const store =
44
- * createStore()
45
- * .setTable('pets', {fido: {species: 'dog'}})
46
- * .setTable('species', {dog: {price: 5}})
47
- * .setValues({open: true});
43
+ * const store = createStore()
44
+ * .setTable('pets', {fido: {species: 'dog'}})
45
+ * .setTable('species', {dog: {price: 5}})
46
+ * .setValues({open: true});
48
47
  * const persister = createIndexedDbPersister(store, 'petStore');
49
48
  *
50
49
  * await persister.save();
@@ -39,7 +39,7 @@ import {Store} from '../store';
39
39
  * to the TinyBasePartyKitServerConfig on the server side.
40
40
  *
41
41
  * ```js
42
- * const partyKitPersisterConfig: PartyKitPersisterConfig = {
42
+ * const partyKitPersisterConfig = {
43
43
  * storeProtocol: 'http',
44
44
  * storePath: '/my_tinybase',
45
45
  * };
@@ -57,9 +57,18 @@ export type PartyKitPersisterConfig = {
57
57
  /**
58
58
  * The path used to set and get the whole Store over HTTP(S) on the server.
59
59
  * This must match the storePath property of the TinyBasePartyKitServerConfig
60
- * object on the server. Both default to '/store'.
60
+ * object used on the server. Both default to '/store'.
61
61
  */
62
62
  storePath?: string;
63
+ /**
64
+ * The prefix at the beginning of the web socket messages sent between the
65
+ * client and the server when synchronizing the Store. Use this to make sure
66
+ * they do not collide with any other message syntax that your room is using.
67
+ * This must match the messagePrefix property of the
68
+ * TinyBasePartyKitServerConfig object used on the server. Both default to an
69
+ * empty string.
70
+ */
71
+ messagePrefix?: string;
63
72
  };
64
73
 
65
74
  /**
@@ -103,12 +112,14 @@ export type PartyKitPersisterConfig = {
103
112
  * browser's IndexedDB storage.
104
113
  *
105
114
  * ```js yolo
106
- * const store =
107
- * createStore()
108
- * .setTable('pets', {fido: {species: 'dog'}})
109
- * .setTable('species', {dog: {price: 5}})
110
- * .setValues({open: true});
111
- * const partySocket = new PartySocket({host: PARTYKIT_HOST, room: 'my_room'});
115
+ * const store = createStore()
116
+ * .setTable('pets', {fido: {species: 'dog'}})
117
+ * .setTable('species', {dog: {price: 5}})
118
+ * .setValues({open: true});
119
+ * const partySocket = new PartySocket({
120
+ * host: PARTYKIT_HOST,
121
+ * room: 'my_room',
122
+ * });
112
123
  * const persister = createPartyKitPersister(store, partySocket);
113
124
  * await persister.startAutoLoad();
114
125
  * await persister.startAutoSave();
@@ -18,7 +18,9 @@
18
18
  * @since 4.3.0
19
19
  */
20
20
 
21
+ import {Cell, CellOrUndefined, Value, ValueOrUndefined} from '../store';
21
22
  import {Connection, Party, Request, Server} from 'partykit/server';
23
+ import {Id} from '../common';
22
24
 
23
25
  /**
24
26
  * The TinyBasePartyKitServerConfig type describes the configuration of a
@@ -38,13 +40,13 @@ import {Connection, Party, Request, Server} from 'partykit/server';
38
40
  * 'tinybase_' in case you are worried about colliding with other data stored
39
41
  * in the room.
40
42
  *
41
- * ```js yolo
42
- * export default class extends TinyBasePartyServer {
43
- * readonly config: TinyBasePartyKitServerConfig = {
43
+ * ```js
44
+ * class MyServer extends TinyBasePartyKitServer {
45
+ * readonly config = {
44
46
  * storePath: '/my_tinybase',
45
47
  * storagePrefix: 'tinybase_',
46
48
  * };
47
- * };
49
+ * }
48
50
  * ```
49
51
  * @category Configuration
50
52
  * @since v4.3.9
@@ -56,6 +58,14 @@ export type TinyBasePartyKitServerConfig = {
56
58
  * on the client. Both default to '/store'.
57
59
  */
58
60
  storePath?: string;
61
+ /**
62
+ * The prefix at the beginning of the web socket messages between the client
63
+ * and the server when synchronizing the Store. Use this to make sure they do
64
+ * not collide with any other message syntax that your room is using. This
65
+ * must match the messagePrefix property of the PartyKitPersisterConfig object
66
+ * used on the client. Both default to an empty string.
67
+ */
68
+ messagePrefix?: string;
59
69
  /**
60
70
  * The prefix used before all the keys in the server's durable storage. Use
61
71
  * this in case you are worried about the Store data colliding with other data
@@ -98,7 +108,7 @@ export type TinyBasePartyKitServerConfig = {
98
108
  * ```js
99
109
  * // This is your PartyKit server entry point.
100
110
  *
101
- * export default class extends TinyBasePartyServer {
111
+ * class MyServer extends TinyBasePartyKitServer {
102
112
  * constructor(party) {
103
113
  * super(party);
104
114
  * // custom constructor code
@@ -109,8 +119,8 @@ export type TinyBasePartyKitServerConfig = {
109
119
  * console.log('Server started');
110
120
  * }
111
121
  *
112
- * async onMessage(message, client) {
113
- * await super.onMessage(message, client);
122
+ * async onMessage(message, connection) {
123
+ * await super.onMessage(message, connection);
114
124
  * // custom onMessage code
115
125
  * }
116
126
  *
@@ -124,6 +134,8 @@ export type TinyBasePartyKitServerConfig = {
124
134
  * See the [PartyKit server API
125
135
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
126
136
  * more details.
137
+ * @category Creation
138
+ * @since v4.3.0
127
139
  */
128
140
  export class TinyBasePartyKitServer implements Server {
129
141
  constructor(party: Party);
@@ -132,6 +144,8 @@ export class TinyBasePartyKitServer implements Server {
132
144
  * object of the TinyBasePartyKitServerConfig type.
133
145
  *
134
146
  * See the documentation for that type for more details.
147
+ * @category Configuration
148
+ * @since v4.3.9
135
149
  */
136
150
  readonly config: TinyBasePartyKitServerConfig;
137
151
  /**
@@ -143,7 +157,7 @@ export class TinyBasePartyKitServer implements Server {
143
157
  * synchronization stays supported:
144
158
  *
145
159
  * ```js
146
- * export default class extends TinyBasePartyServer {
160
+ * class MyServer extends TinyBasePartyKitServer {
147
161
  * async onRequest(request) {
148
162
  * // custom onRequest code, else:
149
163
  * return await super.onRequest(request);
@@ -154,6 +168,8 @@ export class TinyBasePartyKitServer implements Server {
154
168
  * See the [PartyKit server API
155
169
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
156
170
  * more details.
171
+ * @category Connection
172
+ * @since v4.3.0
157
173
  */
158
174
  onRequest(request: Request): Promise<Response>;
159
175
  /**
@@ -165,9 +181,9 @@ export class TinyBasePartyKitServer implements Server {
165
181
  * synchronization stays supported:
166
182
  *
167
183
  * ```js
168
- * export default class extends TinyBasePartyServer {
169
- * async onMessage(message, client) {
170
- * await super.onMessage(message, client);
184
+ * class MyServer extends TinyBasePartyKitServer {
185
+ * async onMessage(message, connection) {
186
+ * await super.onMessage(message, connection);
171
187
  * // custom onMessage code
172
188
  * }
173
189
  * }
@@ -176,6 +192,328 @@ export class TinyBasePartyKitServer implements Server {
176
192
  * See the [PartyKit server API
177
193
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
178
194
  * more details.
195
+ * @category Connection
196
+ * @since v4.3.0
197
+ */
198
+ onMessage(message: string, connection: Connection): Promise<void>;
199
+ /**
200
+ * The canSetTable method lets you allow or disallow any changes to a Table
201
+ * stored on the server, as sent from a client.
202
+ *
203
+ * This is one of the functions use to sanitize the data that is being sent
204
+ * from a client. Perhaps you might want to make sure the server-stored data
205
+ * adheres to a particular schema, or you might want to make certain data
206
+ * read-only. Remember that you cannot trust the client to only send data that
207
+ * the server considers valid or safe.
208
+ *
209
+ * This method is passed the Table Id that the client is trying to change. The
210
+ * `initialSave` parameter distinguishes between the first bulk save of the
211
+ * Store to the PartyKit room over HTTP (`true`), and subsequent incremental
212
+ * updates over a web sockets (`false`).
213
+ *
214
+ * The `requestOrConnection` parameter will either be the HTTP(S) request or
215
+ * the web socket connection, in those two cases respectively. You can, for
216
+ * instance, use this to distinguish between different users.
217
+ *
218
+ * Since v4.3.13, the final parameter is the Cell previously stored on the
219
+ * server, if any. Use this to distinguish between the addition of a new Cell
220
+ * (in which case it will be undefined) and the updating of an existing one.
221
+ *
222
+ * Return `false` from this method to disallow changes to this Table on the
223
+ * server, or `true` to allow them (subject to subsequent canSetRow method,
224
+ * canDelRow method, canSetCell method, and canSetCell method checks). The
225
+ * default implementation returns `true` to allow all changes.
226
+ * @example
227
+ * The following implementation will strip out any attempts by the client to
228
+ * update any 'user' tabular data after the initial save:
229
+ *
230
+ * ```js
231
+ * class MyServer extends TinyBasePartyKitServer {
232
+ * canSetTable(tableId, initialSave) {
233
+ * return initialSave || tableId != 'user';
234
+ * }
235
+ * }
236
+ * ```
237
+ * @category Sanitization
238
+ * @since v4.3.12
239
+ */
240
+ canSetTable(
241
+ tableId: Id,
242
+ initialSave: boolean,
243
+ requestOrConnection: Request | Connection,
244
+ ): boolean;
245
+ /**
246
+ * The canDelTable method lets you allow or disallow deletions of a Table
247
+ * stored on the server, as sent from a client.
248
+ *
249
+ * This is one of the functions use to sanitize the data that is being sent
250
+ * from a client. Perhaps you might want to make sure the server-stored data
251
+ * adheres to a particular schema, or you might want to make certain data
252
+ * read-only. Remember that you cannot trust the client to only send data that
253
+ * the server considers valid or safe.
254
+ *
255
+ * This method is passed the Table Id that the client is trying to delete. The
256
+ * `connection` parameter will be the web socket connection of that client.
257
+ * You can, for instance, use this to distinguish between different users.
258
+ *
259
+ * Return `false` from this method to disallow this Table from being deleted
260
+ * on the server, or `true` to allow it. The default implementation returns
261
+ * `true` to allow deletion.
262
+ * @example
263
+ * The following implementation will strip out any attempts by the client to
264
+ * delete the 'user' Table:
265
+ *
266
+ * ```js
267
+ * class MyServer extends TinyBasePartyKitServer {
268
+ * canDelTable(tableId) {
269
+ * return tableId != 'user';
270
+ * }
271
+ * }
272
+ * ```
273
+ * @category Sanitization
274
+ * @since v4.3.12
275
+ */
276
+ canDelTable(tableId: Id, connection: Connection): boolean;
277
+ /**
278
+ * The canSetRow method lets you allow or disallow any changes to a Row stored
279
+ * on the server, as sent from a client.
280
+ *
281
+ * This is one of the functions use to sanitize the data that is being sent
282
+ * from a client. Perhaps you might want to make sure the server-stored data
283
+ * adheres to a particular schema, or you might want to make certain data
284
+ * read-only. Remember that you cannot trust the client to only send data that
285
+ * the server considers valid or safe.
286
+ *
287
+ * This method is passed the Table Id and Row Id that the client is trying to
288
+ * change. The `initialSave` parameter distinguishes between the first bulk
289
+ * save of the Store to the PartyKit room over HTTP (`true`), and subsequent
290
+ * incremental updates over a web sockets (`false`).
291
+ *
292
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
293
+ * request or the web socket connection, in those two cases respectively. You
294
+ * can, for instance, use this to distinguish between different users.
295
+ *
296
+ * Return `false` from this method to disallow changes to this Row on the
297
+ * server, or `true` to allow them (subject to subsequent canSetCell method
298
+ * and canSetCell method checks). The default implementation returns `true` to
299
+ * allow all changes.
300
+ * @example
301
+ * The following implementation will strip out any attempts by the client to
302
+ * update the 'me' Row of the 'user' Table after the initial save:
303
+ *
304
+ * ```js
305
+ * class MyServer extends TinyBasePartyKitServer {
306
+ * canSetRow(tableId, rowId, initialSave) {
307
+ * return initialSave || tableId != 'user' || rowId != 'me';
308
+ * }
309
+ * }
310
+ * ```
311
+ * @category Sanitization
312
+ * @since v4.3.12
313
+ */
314
+ canSetRow(
315
+ tableId: Id,
316
+ rowId: Id,
317
+ initialSave: boolean,
318
+ requestOrConnection: Request | Connection,
319
+ ): boolean;
320
+ /**
321
+ * The canDelRow method lets you allow or disallow deletions of a Row stored
322
+ * on the server, as sent from a client.
323
+ *
324
+ * This is one of the functions use to sanitize the data that is being sent
325
+ * from a client. Perhaps you might want to make sure the server-stored data
326
+ * adheres to a particular schema, or you might want to make certain data
327
+ * read-only. Remember that you cannot trust the client to only send data that
328
+ * the server considers valid or safe.
329
+ *
330
+ * This method is passed the Table Id and Row Id that the client is trying to
331
+ * delete. The `connection` parameter will be the web socket connection of
332
+ * that client. You can, for instance, use this to distinguish between
333
+ * different users.
334
+ *
335
+ * Return `false` from this method to disallow this Row from being deleted
336
+ * on the server, or `true` to allow it. The default implementation returns
337
+ * `true` to allow deletion.
338
+ * @example
339
+ * The following implementation will strip out any attempts by the client to
340
+ * delete the 'me' Row of the 'user' Table:
341
+ *
342
+ * ```js
343
+ * class MyServer extends TinyBasePartyKitServer {
344
+ * canDelRow(tableId, rowId) {
345
+ * return tableId != 'user' || rowId != 'me';
346
+ * }
347
+ * }
348
+ * ```
349
+ * @category Sanitization
350
+ * @since v4.3.12
351
+ */
352
+ canDelRow(tableId: Id, rowId: Id, connection: Connection): boolean;
353
+ /**
354
+ * The canSetCell method lets you allow or disallow any changes to a Cell
355
+ * stored on the server, as sent from a client.
356
+ *
357
+ * This is one of the functions use to sanitize the data that is being sent
358
+ * from a client. Perhaps you might want to make sure the server-stored data
359
+ * adheres to a particular schema, or you might want to make certain data
360
+ * read-only. Remember that you cannot trust the client to only send data that
361
+ * the server considers valid or safe.
362
+ *
363
+ * This method is passed the Table Id, Row Id, and Cell Id that the client is
364
+ * trying to change - as well as the Cell value itself. The `initialSave`
365
+ * parameter distinguishes between the first bulk save of the Store to the
366
+ * PartyKit room over HTTP (`true`), and subsequent incremental updates over a
367
+ * web sockets (`false`).
368
+ *
369
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
370
+ * request or the web socket connection, in those two cases respectively. You
371
+ * can, for instance, use this to distinguish between different users.
372
+ *
373
+ * Return `false` from this method to disallow changes to this Cell on the
374
+ * server, or `true` to allow them. The default implementation returns `true`
375
+ * to allow all changes.
376
+ * @example
377
+ * The following implementation will strip out any attempts by the client to
378
+ * update the 'name' Cell of the 'me' Row of the 'user' Table after the
379
+ * initial save:
380
+ *
381
+ * ```js
382
+ * class MyServer extends TinyBasePartyKitServer {
383
+ * canSetCell(tableId, rowId, cellId, cell, initialSave) {
384
+ * return (
385
+ * initialSave || tableId != 'user' || rowId != 'me' || cellId != 'name'
386
+ * );
387
+ * }
388
+ * }
389
+ * ```
390
+ * @category Sanitization
391
+ * @since v4.3.12
392
+ */
393
+ canSetCell(
394
+ tableId: Id,
395
+ rowId: Id,
396
+ cellId: Id,
397
+ cell: Cell,
398
+ initialSave: boolean,
399
+ requestOrConnection: Request | Connection,
400
+ oldCell: CellOrUndefined,
401
+ ): boolean;
402
+ /**
403
+ * The canDelCell method lets you allow or disallow deletions of a Cell stored
404
+ * on the server, as sent from a client.
405
+ *
406
+ * This is one of the functions use to sanitize the data that is being sent
407
+ * from a client. Perhaps you might want to make sure the server-stored data
408
+ * adheres to a particular schema, or you might want to make certain data
409
+ * read-only. Remember that you cannot trust the client to only send data that
410
+ * the server considers valid or safe.
411
+ *
412
+ * This method is passed the Table Id, Row Id, and Cell Id that the client is
413
+ * trying to delete. The `connection` parameter will be the web socket
414
+ * connection of that client. You can, for instance, use this to distinguish
415
+ * between different users.
416
+ *
417
+ * Return `false` from this method to disallow this Cell from being deleted on
418
+ * the server, or `true` to allow it. The default implementation returns
419
+ * `true` to allow deletion.
420
+ * @example
421
+ * The following implementation will strip out any attempts by the client to
422
+ * delete the 'name' Cell of the 'me' Row of the 'user' Table:
423
+ *
424
+ * ```js
425
+ * class MyServer extends TinyBasePartyKitServer {
426
+ * canDelCell(tableId, rowId, cellId) {
427
+ * return tableId != 'user' || rowId != 'me' || cellId != 'name';
428
+ * }
429
+ * }
430
+ * ```
431
+ * @category Sanitization
432
+ * @since v4.3.12
433
+ */
434
+ canDelCell(
435
+ tableId: Id,
436
+ rowId: Id,
437
+ cellId: Id,
438
+ connection: Connection,
439
+ ): boolean;
440
+ /**
441
+ * The canSetValue method lets you allow or disallow any changes to a Value
442
+ * stored on the server, as sent from a client.
443
+ *
444
+ * This is one of the functions use to sanitize the data that is being sent
445
+ * from a client. Perhaps you might want to make sure the server-stored data
446
+ * adheres to a particular schema, or you might want to make certain data
447
+ * read-only. Remember that you cannot trust the client to only send data that
448
+ * the server considers valid or safe.
449
+ *
450
+ * This method is passed the Value Id that the client is trying to change - as
451
+ * well as the Value itself. The `initialSave` parameter distinguishes between
452
+ * the first bulk save of the Store to the PartyKit room over HTTP (`true`),
453
+ * and subsequent incremental updates over a web sockets (`false`).
454
+ *
455
+ * The `requestOrConnection` parameter will either be the HTTP(S) request or
456
+ * the web socket connection, in those two cases respectively. You can, for
457
+ * instance, use this to distinguish between different users.
458
+ *
459
+ * Since v4.3.13, the final parameter is the Value previously stored on the
460
+ * server, if any. Use this to distinguish between the addition of a new Value
461
+ * (in which case it will be undefined) and the updating of an existing one.
462
+ *
463
+ * Return `false` from this method to disallow changes to this Value on the
464
+ * server, or `true` to allow them. The default implementation returns `true`
465
+ * to allow all changes.
466
+ * @example
467
+ * The following implementation will strip out any attempts by the client to
468
+ * update the 'userId' Value after the initial save:
469
+ *
470
+ * ```js
471
+ * class MyServer extends TinyBasePartyKitServer {
472
+ * canSetValue(valueId, value, initialSave) {
473
+ * return initialSave || userId != 'userId';
474
+ * }
475
+ * }
476
+ * ```
477
+ * @category Sanitization
478
+ * @since v4.3.12
479
+ */
480
+ canSetValue(
481
+ valueId: Id,
482
+ value: Value,
483
+ initialSave: boolean,
484
+ requestOrConnection: Request | Connection,
485
+ oldValue: ValueOrUndefined,
486
+ ): boolean;
487
+ /**
488
+ * The canDelValue method lets you allow or disallow deletions of a Value
489
+ * stored on the server, as sent from a client.
490
+ *
491
+ * This is one of the functions use to sanitize the data that is being sent
492
+ * from a client. Perhaps you might want to make sure the server-stored data
493
+ * adheres to a particular schema, or you might want to make certain data
494
+ * read-only. Remember that you cannot trust the client to only send data that
495
+ * the server considers valid or safe.
496
+ *
497
+ * This method is passed the Value Id that the client is trying to delete. The
498
+ * `connection` parameter will be the web socket connection of that client.
499
+ * You can, for instance, use this to distinguish between different users.
500
+ *
501
+ * Return `false` from this method to disallow this Value from being deleted
502
+ * on the server, or `true` to allow it. The default implementation returns
503
+ * `true` to allow deletion.
504
+ * @example
505
+ * The following implementation will strip out any attempts by the client to
506
+ * delete the 'userId' Value:
507
+ *
508
+ * ```js
509
+ * class MyServer extends TinyBasePartyKitServer {
510
+ * canDelValue(valueId) {
511
+ * return valueId != 'userId';
512
+ * }
513
+ * }
514
+ * ```
515
+ * @category Sanitization
516
+ * @since v4.3.12
179
517
  */
180
- onMessage(message: string, client: Connection): void;
518
+ canDelValue(valueId: Id, connection: Connection): boolean;
181
519
  }
@@ -413,9 +413,8 @@ export interface Tools {
413
413
  * },
414
414
  * });
415
415
  * const tools = createTools(store);
416
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
417
- * store,
418
- * ).getPrettyStoreApi('shop');
416
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
417
+ * await createTools(store).getPrettyStoreApi('shop');
419
418
  *
420
419
  * const dTsLines = dTs.split('\n');
421
420
  * console.log(dTsLines[17]);
@@ -434,9 +433,8 @@ export interface Tools {
434
433
  * felix: {price: 4},
435
434
  * });
436
435
  * const tools = createTools(store);
437
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
438
- * store,
439
- * ).getPrettyStoreApi('shop');
436
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
437
+ * await createTools(store).getPrettyStoreApi('shop');
440
438
  *
441
439
  * const dTsLines = dTs.split('\n');
442
440
  * console.log(dTsLines[17]);
@@ -3708,8 +3708,8 @@ export function useStartTransactionListener(
3708
3708
  * </Provider>
3709
3709
  * );
3710
3710
  * const Pane = () => {
3711
- * useWillFinishTransactionListener(
3712
- * () => console.log('Will finish transaction'),
3711
+ * useWillFinishTransactionListener(() =>
3712
+ * console.log('Will finish transaction'),
3713
3713
  * );
3714
3714
  * return <span>App</span>;
3715
3715
  * };
@@ -3767,8 +3767,8 @@ export function useWillFinishTransactionListener(
3767
3767
  * </Provider>
3768
3768
  * );
3769
3769
  * const Pane = () => {
3770
- * useDidFinishTransactionListener(
3771
- * () => console.log('Did finish transaction'),
3770
+ * useDidFinishTransactionListener(() =>
3771
+ * console.log('Did finish transaction'),
3772
3772
  * );
3773
3773
  * return <span>App</span>;
3774
3774
  * };
@@ -51,11 +51,10 @@ import {Persister} from '../persisters';
51
51
  * browser's IndexedDB storage.
52
52
  *
53
53
  * ```js
54
- * const store =
55
- * createStore()
56
- * .setTable('pets', {fido: {species: 'dog'}})
57
- * .setTable('species', {dog: {price: 5}})
58
- * .setValues({open: true});
54
+ * const store = createStore()
55
+ * .setTable('pets', {fido: {species: 'dog'}})
56
+ * .setTable('species', {dog: {price: 5}})
57
+ * .setValues({open: true});
59
58
  * const persister = createIndexedDbPersister(store, 'petStore');
60
59
  *
61
60
  * await persister.save();
@@ -39,7 +39,7 @@ import {Persister} from '../persisters';
39
39
  * to the TinyBasePartyKitServerConfig on the server side.
40
40
  *
41
41
  * ```js
42
- * const partyKitPersisterConfig: PartyKitPersisterConfig = {
42
+ * const partyKitPersisterConfig = {
43
43
  * storeProtocol: 'http',
44
44
  * storePath: '/my_tinybase',
45
45
  * };
@@ -57,9 +57,18 @@ export type PartyKitPersisterConfig = {
57
57
  /**
58
58
  * The path used to set and get the whole Store over HTTP(S) on the server.
59
59
  * This must match the storePath property of the TinyBasePartyKitServerConfig
60
- * object on the server. Both default to '/store'.
60
+ * object used on the server. Both default to '/store'.
61
61
  */
62
62
  storePath?: string;
63
+ /**
64
+ * The prefix at the beginning of the web socket messages sent between the
65
+ * client and the server when synchronizing the Store. Use this to make sure
66
+ * they do not collide with any other message syntax that your room is using.
67
+ * This must match the messagePrefix property of the
68
+ * TinyBasePartyKitServerConfig object used on the server. Both default to an
69
+ * empty string.
70
+ */
71
+ messagePrefix?: string;
63
72
  };
64
73
 
65
74
  /**
@@ -114,12 +123,14 @@ export type PartyKitPersisterConfig = {
114
123
  * browser's IndexedDB storage.
115
124
  *
116
125
  * ```js yolo
117
- * const store =
118
- * createStore()
119
- * .setTable('pets', {fido: {species: 'dog'}})
120
- * .setTable('species', {dog: {price: 5}})
121
- * .setValues({open: true});
122
- * const partySocket = new PartySocket({host: PARTYKIT_HOST, room: 'my_room'});
126
+ * const store = createStore()
127
+ * .setTable('pets', {fido: {species: 'dog'}})
128
+ * .setTable('species', {dog: {price: 5}})
129
+ * .setValues({open: true});
130
+ * const partySocket = new PartySocket({
131
+ * host: PARTYKIT_HOST,
132
+ * room: 'my_room',
133
+ * });
123
134
  * const persister = createPartyKitPersister(store, partySocket);
124
135
  * await persister.startAutoLoad();
125
136
  * await persister.startAutoSave();