tinybase 9.4.0-beta.0 → 9.4.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.
- package/@types/persisters/index.d.ts +4 -0
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +9 -2
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +9 -2
- package/@types/persisters/with-schemas/index.d.ts +4 -0
- package/@types/queries/index.d.ts +145 -7
- package/@types/queries/with-schemas/index.d.ts +157 -7
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +7 -3
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +7 -3
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +9 -3
- package/@types/synchronizers/synchronizer-ws-server-simple/index.d.ts +6 -3
- package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.ts +6 -3
- package/index.js +315 -22
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/index.js +1 -1
- package/min/persisters/persister-indexed-db/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
- package/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/index.js +1 -1
- package/min/persisters/persister-partykit-client/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-yjs/index.js +1 -1
- package/min/persisters/persister-yjs/index.js.gz +0 -0
- package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
- package/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +730 -127
- package/omni/with-schemas/index.js +730 -127
- package/package.json +8 -4
- package/persisters/index.js +49 -10
- package/persisters/persister-automerge/index.js +29 -5
- package/persisters/persister-automerge/with-schemas/index.js +29 -5
- package/persisters/persister-browser/index.js +29 -5
- package/persisters/persister-browser/with-schemas/index.js +29 -5
- package/persisters/persister-cr-sqlite-wasm/index.js +29 -5
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +29 -5
- package/persisters/persister-durable-object-sql-storage/index.js +44 -8
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +44 -8
- package/persisters/persister-durable-object-storage/index.js +31 -5
- package/persisters/persister-durable-object-storage/with-schemas/index.js +31 -5
- package/persisters/persister-electric-sql/index.js +29 -5
- package/persisters/persister-electric-sql/with-schemas/index.js +29 -5
- package/persisters/persister-expo-sqlite/index.js +29 -5
- package/persisters/persister-expo-sqlite/with-schemas/index.js +29 -5
- package/persisters/persister-file/index.js +31 -5
- package/persisters/persister-file/with-schemas/index.js +31 -5
- package/persisters/persister-indexed-db/index.js +29 -5
- package/persisters/persister-indexed-db/with-schemas/index.js +29 -5
- package/persisters/persister-libsql/index.js +29 -5
- package/persisters/persister-libsql/with-schemas/index.js +29 -5
- package/persisters/persister-partykit-client/index.js +31 -5
- package/persisters/persister-partykit-client/with-schemas/index.js +31 -5
- package/persisters/persister-pglite/index.js +49 -10
- package/persisters/persister-pglite/with-schemas/index.js +49 -10
- package/persisters/persister-postgres/index.js +49 -10
- package/persisters/persister-postgres/with-schemas/index.js +49 -10
- package/persisters/persister-powersync/index.js +29 -5
- package/persisters/persister-powersync/with-schemas/index.js +29 -5
- package/persisters/persister-react-native-mmkv/index.js +31 -5
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +31 -5
- package/persisters/persister-react-native-sqlite/index.js +29 -5
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +29 -5
- package/persisters/persister-remote/index.js +31 -5
- package/persisters/persister-remote/with-schemas/index.js +31 -5
- package/persisters/persister-sqlite-bun/index.js +29 -5
- package/persisters/persister-sqlite-bun/with-schemas/index.js +29 -5
- package/persisters/persister-sqlite-wasm/index.js +29 -5
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +29 -5
- package/persisters/persister-sqlite3/index.js +29 -5
- package/persisters/persister-sqlite3/with-schemas/index.js +29 -5
- package/persisters/persister-yjs/index.js +29 -5
- package/persisters/persister-yjs/with-schemas/index.js +29 -5
- package/persisters/with-schemas/index.js +49 -10
- package/queries/index.js +334 -22
- package/queries/with-schemas/index.js +334 -22
- package/readme.md +14 -14
- package/releases.md +84 -67
- package/synchronizers/index.js +31 -5
- package/synchronizers/synchronizer-broadcast-channel/index.js +39 -13
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +39 -13
- package/synchronizers/synchronizer-local/index.js +31 -5
- package/synchronizers/synchronizer-local/with-schemas/index.js +31 -5
- package/synchronizers/synchronizer-ws-client/index.js +220 -61
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +220 -61
- package/synchronizers/synchronizer-ws-server/index.js +253 -73
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +253 -73
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +88 -40
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +88 -40
- package/synchronizers/synchronizer-ws-server-simple/index.js +184 -60
- package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +184 -60
- package/synchronizers/with-schemas/index.js +31 -5
- package/ui-react-inspector/index.js +29 -5
- package/ui-react-inspector/with-schemas/index.js +29 -5
- package/ui-solid-inspector/index.js +29 -5
- package/ui-solid-inspector/with-schemas/index.js +29 -5
- package/ui-svelte-inspector/index.js +29 -5
- package/ui-svelte-inspector/with-schemas/index.js +29 -5
- package/with-schemas/index.js +315 -22
|
@@ -1340,6 +1340,10 @@ export interface Persister<Persist extends Persists = Persists.StoreOnly> {
|
|
|
1340
1340
|
* This simply runs the startAutoLoad and startAutoSave methods in sequence,
|
|
1341
1341
|
* and returns a Promise that resolves when both have completed.
|
|
1342
1342
|
*
|
|
1343
|
+
* If the second method fails after either half has partially started, both
|
|
1344
|
+
* halves are stopped again before this method rejects. The original startup
|
|
1345
|
+
* error is preserved if that cleanup also fails.
|
|
1346
|
+
*
|
|
1343
1347
|
* This method can take `initialContent` to pass to the startAutoLoad method.
|
|
1344
1348
|
* See its documentation for more details.
|
|
1345
1349
|
*
|
|
@@ -78,8 +78,15 @@ export type DpcFragmented = {
|
|
|
78
78
|
* This is useful when you have multiple stores or applications sharing the
|
|
79
79
|
* same Durable Object SQL storage and want to avoid table name conflicts.
|
|
80
80
|
*
|
|
81
|
-
*
|
|
82
|
-
* underscores.
|
|
81
|
+
* Empty prefixes and those containing only lower-case ASCII letters, digits,
|
|
82
|
+
* and underscores are used as-is. Other prefixes are encoded so that distinct
|
|
83
|
+
* prefixes cannot resolve to the same tables, including under SQLite's
|
|
84
|
+
* case-insensitive identifier rules.
|
|
85
|
+
*
|
|
86
|
+
* Tables created for prefixes that are now encoded, including uppercase
|
|
87
|
+
* prefixes and those previously changed by lossy sanitization, are not copied
|
|
88
|
+
* automatically because their names may legitimately belong to another
|
|
89
|
+
* prefix. Migrate those tables explicitly before using the new prefix.
|
|
83
90
|
* @example
|
|
84
91
|
* This example shows a configuration using the storagePrefix setting. With a
|
|
85
92
|
* `storagePrefix` of 'user_data_', it creates `user_data_tinybase_tables` and
|
|
@@ -86,8 +86,15 @@ export type DpcFragmented = {
|
|
|
86
86
|
* This is useful when you have multiple stores or applications sharing the
|
|
87
87
|
* same Durable Object SQL storage and want to avoid table name conflicts.
|
|
88
88
|
*
|
|
89
|
-
*
|
|
90
|
-
* underscores.
|
|
89
|
+
* Empty prefixes and those containing only lower-case ASCII letters, digits,
|
|
90
|
+
* and underscores are used as-is. Other prefixes are encoded so that distinct
|
|
91
|
+
* prefixes cannot resolve to the same tables, including under SQLite's
|
|
92
|
+
* case-insensitive identifier rules.
|
|
93
|
+
*
|
|
94
|
+
* Tables created for prefixes that are now encoded, including uppercase
|
|
95
|
+
* prefixes and those previously changed by lossy sanitization, are not copied
|
|
96
|
+
* automatically because their names may legitimately belong to another
|
|
97
|
+
* prefix. Migrate those tables explicitly before using the new prefix.
|
|
91
98
|
* @example
|
|
92
99
|
* This example shows a configuration using the storagePrefix setting. With a
|
|
93
100
|
* `storagePrefix` of 'user_data_', it creates `user_data_tinybase_tables` and
|
|
@@ -1461,6 +1461,10 @@ export interface Persister<
|
|
|
1461
1461
|
* This simply runs the startAutoLoad and startAutoSave methods in sequence,
|
|
1462
1462
|
* and returns a Promise that resolves when both have completed.
|
|
1463
1463
|
*
|
|
1464
|
+
* If the second method fails after either half has partially started, both
|
|
1465
|
+
* halves are stopped again before this method rejects. The original startup
|
|
1466
|
+
* error is preserved if that cleanup also fails.
|
|
1467
|
+
*
|
|
1464
1468
|
* This method can take `initialContent` to pass to the startAutoLoad method.
|
|
1465
1469
|
* See its documentation for more details.
|
|
1466
1470
|
*
|
|
@@ -1011,6 +1011,142 @@ export type Select = {
|
|
|
1011
1011
|
): SelectedAs;
|
|
1012
1012
|
};
|
|
1013
1013
|
|
|
1014
|
+
/**
|
|
1015
|
+
* The CellIdMapper type describes a function used by a SelectAll clause to map
|
|
1016
|
+
* a source Cell Id to a Cell Id in the query result.
|
|
1017
|
+
* @param cellId The Id of a Cell in the source Row.
|
|
1018
|
+
* @returns The Id to use for that Cell in the result Row.
|
|
1019
|
+
* @category Callback
|
|
1020
|
+
* @since v9.4.0
|
|
1021
|
+
*/
|
|
1022
|
+
export type CellIdMapper = (cellId: Id) => Id;
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* The SelectAll type describes a function that lets you select every Cell
|
|
1026
|
+
* present in a source Row.
|
|
1027
|
+
*
|
|
1028
|
+
* The SelectAll function is provided to the third `query` parameter of the
|
|
1029
|
+
* setQueryDefinition method. Different source Rows can contain different Cell
|
|
1030
|
+
* Ids, and each result Row will contain only the Cells present in its
|
|
1031
|
+
* corresponding source Row. The result Table's Cell Ids are therefore the union
|
|
1032
|
+
* of the Cells in its result Rows.
|
|
1033
|
+
*
|
|
1034
|
+
* Source Cell Ids are processed in lexical order, and selection clauses are
|
|
1035
|
+
* processed in the order they are declared. If multiple selected Cells map to
|
|
1036
|
+
* the same result Cell Id, the later one wins.
|
|
1037
|
+
*
|
|
1038
|
+
* When used in a grouped query, the current table-wide union of source Cell Ids
|
|
1039
|
+
* is expanded into individual selections. The query is rebuilt if this union
|
|
1040
|
+
* changes, and any selected Cell that is not grouped becomes a grouping
|
|
1041
|
+
* dimension as usual.
|
|
1042
|
+
*
|
|
1043
|
+
* A cycle between query results is allowed when every SelectAll clause retains
|
|
1044
|
+
* its source Cell Ids. A prefix or CellIdMapper callback in such a cycle is
|
|
1045
|
+
* rejected because it could expand Cell Ids indefinitely.
|
|
1046
|
+
* @category Definition
|
|
1047
|
+
* @since v9.4.0
|
|
1048
|
+
*/
|
|
1049
|
+
export type SelectAll = {
|
|
1050
|
+
/**
|
|
1051
|
+
* Calling this function with no parameters will select every Cell present in
|
|
1052
|
+
* each Row of the query's root Table, retaining the source Cell Ids.
|
|
1053
|
+
* @example
|
|
1054
|
+
* This example selects all the Cells from heterogeneous root Rows:
|
|
1055
|
+
*
|
|
1056
|
+
* ```js
|
|
1057
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1058
|
+
*
|
|
1059
|
+
* const store = createStore().setTable('pets', {
|
|
1060
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
1061
|
+
* felix: {species: 'cat', indoor: true},
|
|
1062
|
+
* });
|
|
1063
|
+
* const queries = createQueries(store);
|
|
1064
|
+
*
|
|
1065
|
+
* queries.setQueryDefinition('query', 'pets', ({selectAll}) => selectAll());
|
|
1066
|
+
*
|
|
1067
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1068
|
+
* // -> {color: 'brown', species: 'dog'}
|
|
1069
|
+
* console.log(queries.getResultRow('query', 'felix'));
|
|
1070
|
+
* // -> {indoor: true, species: 'cat'}
|
|
1071
|
+
* ```
|
|
1072
|
+
* @category Definition
|
|
1073
|
+
* @since v9.4.0
|
|
1074
|
+
*/
|
|
1075
|
+
(): void;
|
|
1076
|
+
/**
|
|
1077
|
+
* Calling this function with a joined Table Id will select every Cell present
|
|
1078
|
+
* in the joined Row.
|
|
1079
|
+
*
|
|
1080
|
+
* An optional second parameter can map each Cell Id with a prefix or
|
|
1081
|
+
* callback.
|
|
1082
|
+
* @param joinedTableId The Id of the joined Table. If the Table was joined
|
|
1083
|
+
* 'as' a different Id, that should instead be used.
|
|
1084
|
+
* @param cellIdPrefixOrMapper An optional prefix to prepend to every Cell Id,
|
|
1085
|
+
* or a CellIdMapper callback that returns each result Cell Id.
|
|
1086
|
+
* @example
|
|
1087
|
+
* This example selects all the Cells from a joined Table, retaining their
|
|
1088
|
+
* Cell Ids:
|
|
1089
|
+
*
|
|
1090
|
+
* ```js
|
|
1091
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1092
|
+
*
|
|
1093
|
+
* const store = createStore()
|
|
1094
|
+
* .setTable('pets', {fido: {ownerId: '1'}})
|
|
1095
|
+
* .setTable('owners', {'1': {name: 'Alice', city: 'London'}});
|
|
1096
|
+
* const queries = createQueries(store);
|
|
1097
|
+
*
|
|
1098
|
+
* queries.setQueryDefinition('query', 'pets', ({selectAll, join}) => {
|
|
1099
|
+
* selectAll('owners');
|
|
1100
|
+
* join('owners', 'ownerId');
|
|
1101
|
+
* });
|
|
1102
|
+
*
|
|
1103
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1104
|
+
* // -> {city: 'London', name: 'Alice'}
|
|
1105
|
+
* ```
|
|
1106
|
+
* @category Definition
|
|
1107
|
+
* @since v9.4.0
|
|
1108
|
+
*/
|
|
1109
|
+
(joinedTableId: Id, cellIdPrefixOrMapper?: Id | CellIdMapper): void;
|
|
1110
|
+
/**
|
|
1111
|
+
* Calling this function with `true` and a joined query Id will select every
|
|
1112
|
+
* Cell present in the joined result Row.
|
|
1113
|
+
*
|
|
1114
|
+
* An optional third parameter can map each Cell Id with a prefix or callback.
|
|
1115
|
+
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1116
|
+
* @param joinedQueryId The Id of the joined query result. If the query result
|
|
1117
|
+
* was joined 'as' a different Id, that should instead be used.
|
|
1118
|
+
* @param cellIdPrefixOrMapper An optional prefix to prepend to every Cell Id,
|
|
1119
|
+
* or a CellIdMapper callback that returns each result Cell Id.
|
|
1120
|
+
* @example
|
|
1121
|
+
* This example selects all the Cells from a joined query result, prefixing
|
|
1122
|
+
* each Cell Id:
|
|
1123
|
+
*
|
|
1124
|
+
* ```js
|
|
1125
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1126
|
+
*
|
|
1127
|
+
* const store = createStore()
|
|
1128
|
+
* .setTable('pets', {fido: {ownerId: '1'}})
|
|
1129
|
+
* .setTable('owners', {'1': {name: 'Alice', city: 'London'}});
|
|
1130
|
+
* const queries = createQueries(store)
|
|
1131
|
+
* .setQueryDefinition('owners', 'owners', ({selectAll}) => selectAll())
|
|
1132
|
+
* .setQueryDefinition('query', 'pets', ({selectAll, join}) => {
|
|
1133
|
+
* selectAll(true, 'owners', 'owner.');
|
|
1134
|
+
* join(true, 'owners', 'ownerId');
|
|
1135
|
+
* });
|
|
1136
|
+
*
|
|
1137
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1138
|
+
* // -> {'owner.city': 'London', 'owner.name': 'Alice'}
|
|
1139
|
+
* ```
|
|
1140
|
+
* @category Definition
|
|
1141
|
+
* @since v9.4.0
|
|
1142
|
+
*/
|
|
1143
|
+
(
|
|
1144
|
+
asQuery: true,
|
|
1145
|
+
joinedQueryId: Id,
|
|
1146
|
+
cellIdPrefixOrMapper?: Id | CellIdMapper,
|
|
1147
|
+
): void;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1014
1150
|
/**
|
|
1015
1151
|
* The SelectedAs type describes an object returned from calling a Select
|
|
1016
1152
|
* function so that the selected Cell Id can be optionally aliased.
|
|
@@ -1257,8 +1393,8 @@ export type Join = {
|
|
|
1257
1393
|
(joinedTableId: Id, on: Id): JoinedAs;
|
|
1258
1394
|
/**
|
|
1259
1395
|
* Calling this function with three parameters (where the first is `true`)
|
|
1260
|
-
* will indicate that the join to a Row in an adjacent query result is made
|
|
1261
|
-
*
|
|
1396
|
+
* will indicate that the join to a Row in an adjacent query result is made by
|
|
1397
|
+
* finding its Id in a Cell of the query's root Table.
|
|
1262
1398
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1263
1399
|
* @param joinedQueryId The Id of the query result to join to.
|
|
1264
1400
|
* @param on The Id of the Cell in the root Table that contains the joined
|
|
@@ -1323,8 +1459,8 @@ export type Join = {
|
|
|
1323
1459
|
*/
|
|
1324
1460
|
(joinedTableId: Id, fromIntermediateJoinedTableId: Id, on: Id): JoinedAs;
|
|
1325
1461
|
/**
|
|
1326
|
-
* Calling this function with four parameters (where the first is `true`)
|
|
1327
|
-
*
|
|
1462
|
+
* Calling this function with four parameters (where the first is `true`) will
|
|
1463
|
+
* indicate that the join to a Row in a distant query result is made by
|
|
1328
1464
|
* finding its Id in a Cell of an intermediately joined Table.
|
|
1329
1465
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1330
1466
|
* @param joinedQueryId The Id of the distant query result to join to.
|
|
@@ -1371,9 +1507,9 @@ export type Join = {
|
|
|
1371
1507
|
): JoinedAs;
|
|
1372
1508
|
/**
|
|
1373
1509
|
* Calling this function with four parameters (where the first is `true` and
|
|
1374
|
-
* the fourth is a function) will indicate that the join to a Row in a
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1510
|
+
* the fourth is a function) will indicate that the join to a Row in a distant
|
|
1511
|
+
* query result is made by calculating its Id from the Cells and the Row Id of
|
|
1512
|
+
* an intermediately joined Table.
|
|
1377
1513
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1378
1514
|
* @param joinedQueryId The Id of the query result to join to.
|
|
1379
1515
|
* @param fromIntermediateJoinedTableId The Id of an intermediate Table (which
|
|
@@ -2102,6 +2238,7 @@ export interface Queries {
|
|
|
2102
2238
|
tableId: Id,
|
|
2103
2239
|
query: (keywords: {
|
|
2104
2240
|
select: Select;
|
|
2241
|
+
selectAll: SelectAll;
|
|
2105
2242
|
join: Join;
|
|
2106
2243
|
where: Where;
|
|
2107
2244
|
group: Group;
|
|
@@ -2116,6 +2253,7 @@ export interface Queries {
|
|
|
2116
2253
|
rootQueryId: Id,
|
|
2117
2254
|
query: (keywords: {
|
|
2118
2255
|
select: Select;
|
|
2256
|
+
selectAll: SelectAll;
|
|
2119
2257
|
join: Join;
|
|
2120
2258
|
where: Where;
|
|
2121
2259
|
group: Group;
|
|
@@ -1158,6 +1158,152 @@ export type Select<
|
|
|
1158
1158
|
): SelectedAs;
|
|
1159
1159
|
};
|
|
1160
1160
|
|
|
1161
|
+
/**
|
|
1162
|
+
* The CellIdMapper type describes a function used by a SelectAll clause to map
|
|
1163
|
+
* a source Cell Id to a Cell Id in the query result.
|
|
1164
|
+
* @param cellId The Id of a Cell in the source Row.
|
|
1165
|
+
* @returns The Id to use for that Cell in the result Row.
|
|
1166
|
+
* @category Callback
|
|
1167
|
+
* @since v9.4.0
|
|
1168
|
+
*/
|
|
1169
|
+
export type CellIdMapper<CellId extends Id = Id> = (cellId: CellId) => Id;
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* The SelectAll type describes a function that lets you select every Cell
|
|
1173
|
+
* present in a source Row.
|
|
1174
|
+
*
|
|
1175
|
+
* The SelectAll function is provided to the third `query` parameter of the
|
|
1176
|
+
* setQueryDefinition method. Different source Rows can contain different Cell
|
|
1177
|
+
* Ids, and each result Row will contain only the Cells present in its
|
|
1178
|
+
* corresponding source Row. The result Table's Cell Ids are therefore the union
|
|
1179
|
+
* of the Cells in its result Rows.
|
|
1180
|
+
*
|
|
1181
|
+
* Source Cell Ids are processed in lexical order, and selection clauses are
|
|
1182
|
+
* processed in the order they are declared. If multiple selected Cells map to
|
|
1183
|
+
* the same result Cell Id, the later one wins.
|
|
1184
|
+
*
|
|
1185
|
+
* When used in a grouped query, the current table-wide union of source Cell Ids
|
|
1186
|
+
* is expanded into individual selections. The query is rebuilt if this union
|
|
1187
|
+
* changes, and any selected Cell that is not grouped becomes a grouping
|
|
1188
|
+
* dimension as usual.
|
|
1189
|
+
*
|
|
1190
|
+
* A cycle between query results is allowed when every SelectAll clause retains
|
|
1191
|
+
* its source Cell Ids. A prefix or CellIdMapper callback in such a cycle is
|
|
1192
|
+
* rejected because it could expand Cell Ids indefinitely.
|
|
1193
|
+
* @category Definition
|
|
1194
|
+
* @since v9.4.0
|
|
1195
|
+
*/
|
|
1196
|
+
export type SelectAll<Schema extends OptionalTablesSchema> = {
|
|
1197
|
+
/**
|
|
1198
|
+
* Calling this function with no parameters will select every Cell present in
|
|
1199
|
+
* each Row of the query's root Table, retaining the source Cell Ids.
|
|
1200
|
+
* @example
|
|
1201
|
+
* This example selects all the Cells from heterogeneous root Rows:
|
|
1202
|
+
*
|
|
1203
|
+
* ```js
|
|
1204
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1205
|
+
*
|
|
1206
|
+
* const store = createStore().setTable('pets', {
|
|
1207
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
1208
|
+
* felix: {species: 'cat', indoor: true},
|
|
1209
|
+
* });
|
|
1210
|
+
* const queries = createQueries(store);
|
|
1211
|
+
*
|
|
1212
|
+
* queries.setQueryDefinition('query', 'pets', ({selectAll}) => selectAll());
|
|
1213
|
+
*
|
|
1214
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1215
|
+
* // -> {color: 'brown', species: 'dog'}
|
|
1216
|
+
* console.log(queries.getResultRow('query', 'felix'));
|
|
1217
|
+
* // -> {indoor: true, species: 'cat'}
|
|
1218
|
+
* ```
|
|
1219
|
+
* @category Definition
|
|
1220
|
+
* @since v9.4.0
|
|
1221
|
+
*/
|
|
1222
|
+
(): void;
|
|
1223
|
+
/**
|
|
1224
|
+
* Calling this function with a joined Table Id will select every Cell present
|
|
1225
|
+
* in the joined Row.
|
|
1226
|
+
*
|
|
1227
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
1228
|
+
*
|
|
1229
|
+
* ```ts override
|
|
1230
|
+
* (joinedTableId: Id, cellIdPrefixOrMapper?: Id | CellIdMapper): void;
|
|
1231
|
+
* ```
|
|
1232
|
+
*
|
|
1233
|
+
* An optional second parameter can map each Cell Id with a prefix or
|
|
1234
|
+
* callback.
|
|
1235
|
+
* @param joinedTableId The Id of the joined Table. If the Table was joined
|
|
1236
|
+
* 'as' a different Id, that should instead be used.
|
|
1237
|
+
* @param cellIdPrefixOrMapper An optional prefix to prepend to every Cell Id,
|
|
1238
|
+
* or a CellIdMapper callback that returns each result Cell Id.
|
|
1239
|
+
* @example
|
|
1240
|
+
* This example selects all the Cells from a joined Table, retaining their
|
|
1241
|
+
* Cell Ids:
|
|
1242
|
+
*
|
|
1243
|
+
* ```js
|
|
1244
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1245
|
+
*
|
|
1246
|
+
* const store = createStore()
|
|
1247
|
+
* .setTable('pets', {fido: {ownerId: '1'}})
|
|
1248
|
+
* .setTable('owners', {'1': {name: 'Alice', city: 'London'}});
|
|
1249
|
+
* const queries = createQueries(store);
|
|
1250
|
+
*
|
|
1251
|
+
* queries.setQueryDefinition('query', 'pets', ({selectAll, join}) => {
|
|
1252
|
+
* selectAll('owners');
|
|
1253
|
+
* join('owners', 'ownerId');
|
|
1254
|
+
* });
|
|
1255
|
+
*
|
|
1256
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1257
|
+
* // -> {city: 'London', name: 'Alice'}
|
|
1258
|
+
* ```
|
|
1259
|
+
* @category Definition
|
|
1260
|
+
* @since v9.4.0
|
|
1261
|
+
*/
|
|
1262
|
+
<JoinedTableId extends TableIdFromSchema<Schema> | Id>(
|
|
1263
|
+
joinedTableId: JoinedTableId,
|
|
1264
|
+
cellIdPrefixOrMapper?:
|
|
1265
|
+
Id | CellIdMapper<JoinedCellIdOrId<Schema, JoinedTableId>>,
|
|
1266
|
+
): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Calling this function with `true` and a joined query Id will select every
|
|
1269
|
+
* Cell present in the joined result Row.
|
|
1270
|
+
*
|
|
1271
|
+
* An optional third parameter can map each Cell Id with a prefix or callback.
|
|
1272
|
+
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1273
|
+
* @param joinedQueryId The Id of the joined query result. If the query result
|
|
1274
|
+
* was joined 'as' a different Id, that should instead be used.
|
|
1275
|
+
* @param cellIdPrefixOrMapper An optional prefix to prepend to every Cell Id,
|
|
1276
|
+
* or a CellIdMapper callback that returns each result Cell Id.
|
|
1277
|
+
* @example
|
|
1278
|
+
* This example selects all the Cells from a joined query result, prefixing
|
|
1279
|
+
* each Cell Id:
|
|
1280
|
+
*
|
|
1281
|
+
* ```js
|
|
1282
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
1283
|
+
*
|
|
1284
|
+
* const store = createStore()
|
|
1285
|
+
* .setTable('pets', {fido: {ownerId: '1'}})
|
|
1286
|
+
* .setTable('owners', {'1': {name: 'Alice', city: 'London'}});
|
|
1287
|
+
* const queries = createQueries(store)
|
|
1288
|
+
* .setQueryDefinition('owners', 'owners', ({selectAll}) => selectAll())
|
|
1289
|
+
* .setQueryDefinition('query', 'pets', ({selectAll, join}) => {
|
|
1290
|
+
* selectAll(true, 'owners', 'owner.');
|
|
1291
|
+
* join(true, 'owners', 'ownerId');
|
|
1292
|
+
* });
|
|
1293
|
+
*
|
|
1294
|
+
* console.log(queries.getResultRow('query', 'fido'));
|
|
1295
|
+
* // -> {'owner.city': 'London', 'owner.name': 'Alice'}
|
|
1296
|
+
* ```
|
|
1297
|
+
* @category Definition
|
|
1298
|
+
* @since v9.4.0
|
|
1299
|
+
*/
|
|
1300
|
+
(
|
|
1301
|
+
asQuery: true,
|
|
1302
|
+
joinedQueryId: Id,
|
|
1303
|
+
cellIdPrefixOrMapper?: Id | CellIdMapper,
|
|
1304
|
+
): void;
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1161
1307
|
/**
|
|
1162
1308
|
* The SelectedAs type describes an object returned from calling a Select
|
|
1163
1309
|
* function so that the selected Cell Id can be optionally aliased.
|
|
@@ -1410,8 +1556,8 @@ export type Join<
|
|
|
1410
1556
|
): JoinedAs;
|
|
1411
1557
|
/**
|
|
1412
1558
|
* Calling this function with three parameters (where the first is `true`)
|
|
1413
|
-
* will indicate that the join to a Row in an adjacent query result is made
|
|
1414
|
-
*
|
|
1559
|
+
* will indicate that the join to a Row in an adjacent query result is made by
|
|
1560
|
+
* finding its Id in a Cell of the query's root Table.
|
|
1415
1561
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1416
1562
|
* @param joinedQueryId The Id of the query result to join to.
|
|
1417
1563
|
* @param on The Id of the Cell in the root Table that contains the joined
|
|
@@ -1491,8 +1637,8 @@ export type Join<
|
|
|
1491
1637
|
on: IntermediateJoinedCellId,
|
|
1492
1638
|
): JoinedAs;
|
|
1493
1639
|
/**
|
|
1494
|
-
* Calling this function with four parameters (where the first is `true`)
|
|
1495
|
-
*
|
|
1640
|
+
* Calling this function with four parameters (where the first is `true`) will
|
|
1641
|
+
* indicate that the join to a Row in a distant query result is made by
|
|
1496
1642
|
* finding its Id in a Cell of an intermediately joined Table.
|
|
1497
1643
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1498
1644
|
* @param joinedQueryId The Id of the distant query result to join to.
|
|
@@ -1553,9 +1699,9 @@ export type Join<
|
|
|
1553
1699
|
): JoinedAs;
|
|
1554
1700
|
/**
|
|
1555
1701
|
* Calling this function with four parameters (where the first is `true` and
|
|
1556
|
-
* the fourth is a function) will indicate that the join to a Row in a
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1702
|
+
* the fourth is a function) will indicate that the join to a Row in a distant
|
|
1703
|
+
* query result is made by calculating its Id from the Cells and the Row Id of
|
|
1704
|
+
* an intermediately joined Table.
|
|
1559
1705
|
* @param asQuery A flag indicating that the next Id is a query Id.
|
|
1560
1706
|
* @param joinedQueryId The Id of the query result to join to.
|
|
1561
1707
|
* @param fromIntermediateJoinedTableId The Id of an intermediate Table (which
|
|
@@ -2256,6 +2402,7 @@ export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
|
2256
2402
|
* tableId: Id,
|
|
2257
2403
|
* query: (keywords: {
|
|
2258
2404
|
* select: Select;
|
|
2405
|
+
* selectAll: SelectAll;
|
|
2259
2406
|
* join: Join;
|
|
2260
2407
|
* where: Where;
|
|
2261
2408
|
* group: Group;
|
|
@@ -2270,6 +2417,7 @@ export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
|
2270
2417
|
* rootQueryId: Id,
|
|
2271
2418
|
* query: (keywords: {
|
|
2272
2419
|
* select: Select;
|
|
2420
|
+
* selectAll: SelectAll;
|
|
2273
2421
|
* join: Join;
|
|
2274
2422
|
* where: Where;
|
|
2275
2423
|
* group: Group;
|
|
@@ -2348,6 +2496,7 @@ export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
|
2348
2496
|
tableId: RootTableId,
|
|
2349
2497
|
query: (keywords: {
|
|
2350
2498
|
select: Select<Schemas[0], RootTableId>;
|
|
2499
|
+
selectAll: SelectAll<Schemas[0]>;
|
|
2351
2500
|
join: Join<Schemas[0], RootTableId>;
|
|
2352
2501
|
where: Where<Schemas[0], RootTableId>;
|
|
2353
2502
|
group: Group;
|
|
@@ -2362,6 +2511,7 @@ export interface Queries<in out Schemas extends OptionalSchemas> {
|
|
|
2362
2511
|
rootQueryId: Id,
|
|
2363
2512
|
query: (keywords: {
|
|
2364
2513
|
select: Select<any, any>;
|
|
2514
|
+
selectAll: SelectAll<any>;
|
|
2365
2515
|
join: Join<any, any>;
|
|
2366
2516
|
where: Where<any, any>;
|
|
2367
2517
|
group: Group;
|
|
@@ -177,7 +177,9 @@ export function createWsSynchronizer<WebSocketType extends WebSocketTypes>(
|
|
|
177
177
|
* Construct the WebSocket with the `tinybase` subprotocol and provide a
|
|
178
178
|
* channel Id as the third argument. The channel Id is appended to the
|
|
179
179
|
* WebSocket URL path to form the server path; it is not taken from the
|
|
180
|
-
* MergeableStore Id.
|
|
180
|
+
* MergeableStore Id. It can contain at most 1,024 UTF-8 bytes, and one shared
|
|
181
|
+
* WebSocket can have at most 100 channels. Creating a 101st channel is
|
|
182
|
+
* rejected without closing the existing shared WebSocket.
|
|
181
183
|
*
|
|
182
184
|
* Destroying the WsSynchronizer unsubscribes its channel. The shared
|
|
183
185
|
* WebSocket is closed only when the last WsSynchronizer using it is
|
|
@@ -188,8 +190,10 @@ export function createWsSynchronizer<WebSocketType extends WebSocketTypes>(
|
|
|
188
190
|
* later. It is not supported by WsServerDurableObject.
|
|
189
191
|
* @param store The MergeableStore to synchronize.
|
|
190
192
|
* @param webSocket The shared WebSocket to send synchronization messages
|
|
191
|
-
* over, constructed with the `tinybase` subprotocol
|
|
192
|
-
*
|
|
193
|
+
* over, constructed with the `tinybase` subprotocol and shared by at most 100
|
|
194
|
+
* channels.
|
|
195
|
+
* @param channelId The channel Id to append to the WebSocket URL path, with
|
|
196
|
+
* at most 1,024 UTF-8 bytes.
|
|
193
197
|
* @param requestTimeoutSeconds An optional time in seconds that the
|
|
194
198
|
* Synchronizer will wait for responses to request messages, defaulting to 1.
|
|
195
199
|
* @param onSend An optional handler for the messages that this Synchronizer
|
|
@@ -211,7 +211,9 @@ export function createWsSynchronizer<
|
|
|
211
211
|
* Construct the WebSocket with the `tinybase` subprotocol and provide a
|
|
212
212
|
* channel Id as the third argument. The channel Id is appended to the
|
|
213
213
|
* WebSocket URL path to form the server path; it is not taken from the
|
|
214
|
-
* MergeableStore Id.
|
|
214
|
+
* MergeableStore Id. It can contain at most 1,024 UTF-8 bytes, and one shared
|
|
215
|
+
* WebSocket can have at most 100 channels. Creating a 101st channel is
|
|
216
|
+
* rejected without closing the existing shared WebSocket.
|
|
215
217
|
*
|
|
216
218
|
* Destroying the WsSynchronizer unsubscribes its channel. The shared
|
|
217
219
|
* WebSocket is closed only when the last WsSynchronizer using it is
|
|
@@ -222,8 +224,10 @@ export function createWsSynchronizer<
|
|
|
222
224
|
* later. It is not supported by WsServerDurableObject.
|
|
223
225
|
* @param store The MergeableStore to synchronize.
|
|
224
226
|
* @param webSocket The shared WebSocket to send synchronization messages
|
|
225
|
-
* over, constructed with the `tinybase` subprotocol
|
|
226
|
-
*
|
|
227
|
+
* over, constructed with the `tinybase` subprotocol and shared by at most 100
|
|
228
|
+
* channels.
|
|
229
|
+
* @param channelId The channel Id to append to the WebSocket URL path, with
|
|
230
|
+
* at most 1,024 UTF-8 bytes.
|
|
227
231
|
* @param requestTimeoutSeconds An optional time in seconds that the
|
|
228
232
|
* Synchronizer will wait for responses to request messages, defaulting to 1.
|
|
229
233
|
* @param onSend An optional handler for the messages that this Synchronizer
|
|
@@ -519,7 +519,11 @@ export interface WsServer {
|
|
|
519
519
|
* Since v9.3, multiple WsSynchronizer instances can share one WebSocket by
|
|
520
520
|
* using channel Ids. Each channel Id is appended to the WebSocket URL path and
|
|
521
521
|
* treated as an ordinary server path. This means a multiplexed channel can
|
|
522
|
-
* interoperate with legacy clients connected directly to that full path.
|
|
522
|
+
* interoperate with legacy clients connected directly to that full path. A
|
|
523
|
+
* channel Id can contain at most 1,024 UTF-8 bytes, and each multiplexed
|
|
524
|
+
* WebSocket can have at most 100 subscribed channels. Pending setup and
|
|
525
|
+
* teardown resources are also bounded. Fragment reassembly and traffic
|
|
526
|
+
* buffered while paths start share limits across the physical WebSocket.
|
|
523
527
|
*
|
|
524
528
|
* The WsServer does not authenticate or authorize URL paths or channel Ids.
|
|
525
529
|
* Once a client WebSocket is accepted on a base path, it can subscribe to any
|
|
@@ -608,7 +612,7 @@ export interface WsServer {
|
|
|
608
612
|
* client connects, it picks up the data the previous two were using.
|
|
609
613
|
*
|
|
610
614
|
* ```js
|
|
611
|
-
* import {rmSync} from 'fs';
|
|
615
|
+
* import {mkdirSync, rmSync} from 'fs';
|
|
612
616
|
* import {createMergeableStore} from 'tinybase';
|
|
613
617
|
* import {createFilePersister} from 'tinybase/persisters/persister-file';
|
|
614
618
|
* import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
|
|
@@ -616,6 +620,7 @@ export interface WsServer {
|
|
|
616
620
|
* import {WebSocket, WebSocketServer} from 'ws';
|
|
617
621
|
*
|
|
618
622
|
* // Server
|
|
623
|
+
* mkdirSync('./tmp', {recursive: true});
|
|
619
624
|
* const server = createWsServer(
|
|
620
625
|
* new WebSocketServer({port: 8047}),
|
|
621
626
|
* (pathId) =>
|
|
@@ -679,7 +684,7 @@ export interface WsServer {
|
|
|
679
684
|
* data once synchronization has started.
|
|
680
685
|
*
|
|
681
686
|
* ```js
|
|
682
|
-
* import {rmSync} from 'fs';
|
|
687
|
+
* import {mkdirSync, rmSync} from 'fs';
|
|
683
688
|
* import {createMergeableStore} from 'tinybase';
|
|
684
689
|
* import {createFilePersister} from 'tinybase/persisters/persister-file';
|
|
685
690
|
* import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
|
|
@@ -687,6 +692,7 @@ export interface WsServer {
|
|
|
687
692
|
* import {WebSocket, WebSocketServer} from 'ws';
|
|
688
693
|
*
|
|
689
694
|
* // Server
|
|
695
|
+
* mkdirSync('./tmp', {recursive: true});
|
|
690
696
|
* const server = createWsServer(
|
|
691
697
|
* new WebSocketServer({port: 8047}),
|
|
692
698
|
* (pathId) => [
|
|
@@ -548,7 +548,11 @@ export interface WsServer {
|
|
|
548
548
|
* Since v9.3, multiple WsSynchronizer instances can share one WebSocket by
|
|
549
549
|
* using channel Ids. Each channel Id is appended to the WebSocket URL path and
|
|
550
550
|
* treated as an ordinary server path. This means a multiplexed channel can
|
|
551
|
-
* interoperate with legacy clients connected directly to that full path.
|
|
551
|
+
* interoperate with legacy clients connected directly to that full path. A
|
|
552
|
+
* channel Id can contain at most 1,024 UTF-8 bytes, and each multiplexed
|
|
553
|
+
* WebSocket can have at most 100 subscribed channels. Pending setup and
|
|
554
|
+
* teardown resources are also bounded. Fragment reassembly and traffic
|
|
555
|
+
* buffered while paths start share limits across the physical WebSocket.
|
|
552
556
|
*
|
|
553
557
|
* The WsServer does not authenticate or authorize URL paths or channel Ids.
|
|
554
558
|
* Once a client WebSocket is accepted on a base path, it can subscribe to any
|
|
@@ -637,7 +641,7 @@ export interface WsServer {
|
|
|
637
641
|
* client connects, it picks up the data the previous two were using.
|
|
638
642
|
*
|
|
639
643
|
* ```js
|
|
640
|
-
* import {rmSync} from 'fs';
|
|
644
|
+
* import {mkdirSync, rmSync} from 'fs';
|
|
641
645
|
* import {createMergeableStore} from 'tinybase';
|
|
642
646
|
* import {createFilePersister} from 'tinybase/persisters/persister-file';
|
|
643
647
|
* import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
|
|
@@ -645,6 +649,7 @@ export interface WsServer {
|
|
|
645
649
|
* import {WebSocket, WebSocketServer} from 'ws';
|
|
646
650
|
*
|
|
647
651
|
* // Server
|
|
652
|
+
* mkdirSync('./tmp', {recursive: true});
|
|
648
653
|
* const server = createWsServer(
|
|
649
654
|
* new WebSocketServer({port: 8047}),
|
|
650
655
|
* (pathId) =>
|
|
@@ -708,7 +713,7 @@ export interface WsServer {
|
|
|
708
713
|
* data once synchronization has started.
|
|
709
714
|
*
|
|
710
715
|
* ```js
|
|
711
|
-
* import {rmSync} from 'fs';
|
|
716
|
+
* import {mkdirSync, rmSync} from 'fs';
|
|
712
717
|
* import {createMergeableStore} from 'tinybase';
|
|
713
718
|
* import {createFilePersister} from 'tinybase/persisters/persister-file';
|
|
714
719
|
* import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
|
|
@@ -716,6 +721,7 @@ export interface WsServer {
|
|
|
716
721
|
* import {WebSocket, WebSocketServer} from 'ws';
|
|
717
722
|
*
|
|
718
723
|
* // Server
|
|
724
|
+
* mkdirSync('./tmp', {recursive: true});
|
|
719
725
|
* const server = createWsServer(
|
|
720
726
|
* new WebSocketServer({port: 8047}),
|
|
721
727
|
* (pathId) => [
|
|
@@ -96,9 +96,12 @@ export interface WsServerSimple {
|
|
|
96
96
|
* Since v9.3, it also supports multiple channel-based WsSynchronizer instances
|
|
97
97
|
* sharing one WebSocket. Once a client WebSocket is accepted on a base path,
|
|
98
98
|
* it can subscribe to any valid channel beneath that path: WsServerSimple does
|
|
99
|
-
* not authenticate or authorize channel Ids.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
99
|
+
* not authenticate or authorize channel Ids. A channel Id can contain at most
|
|
100
|
+
* 1,024 UTF-8 bytes, and each multiplexed WebSocket can have at most 100
|
|
101
|
+
* subscribed channels. Pending channel cleanup is also bounded, and fragment
|
|
102
|
+
* reassembly limits are shared across the physical WebSocket. For untrusted
|
|
103
|
+
* clients, use a separate authenticated WebSocket for each authorized path
|
|
104
|
+
* unless access to all descendants is acceptable.
|
|
102
105
|
* @param webSocketServer A WebSocketServer object from your server environment.
|
|
103
106
|
* @returns A reference to the new WsServerSimple object.
|
|
104
107
|
* @example
|
|
@@ -96,9 +96,12 @@ export interface WsServerSimple {
|
|
|
96
96
|
* Since v9.3, it also supports multiple channel-based WsSynchronizer instances
|
|
97
97
|
* sharing one WebSocket. Once a client WebSocket is accepted on a base path,
|
|
98
98
|
* it can subscribe to any valid channel beneath that path: WsServerSimple does
|
|
99
|
-
* not authenticate or authorize channel Ids.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
99
|
+
* not authenticate or authorize channel Ids. A channel Id can contain at most
|
|
100
|
+
* 1,024 UTF-8 bytes, and each multiplexed WebSocket can have at most 100
|
|
101
|
+
* subscribed channels. Pending channel cleanup is also bounded, and fragment
|
|
102
|
+
* reassembly limits are shared across the physical WebSocket. For untrusted
|
|
103
|
+
* clients, use a separate authenticated WebSocket for each authorized path
|
|
104
|
+
* unless access to all descendants is acceptable.
|
|
102
105
|
* @param webSocketServer A WebSocketServer object from your server environment.
|
|
103
106
|
* @returns A reference to the new WsServerSimple object.
|
|
104
107
|
* @example
|