tinybase 4.4.0-beta.0 → 4.4.0-beta.1
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/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/cjs/checkpoints.cjs +1 -1
- package/lib/cjs/checkpoints.cjs.gz +0 -0
- package/lib/cjs/indexes.cjs +1 -1
- package/lib/cjs/indexes.cjs.gz +0 -0
- package/lib/cjs/metrics.cjs +1 -1
- package/lib/cjs/metrics.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-automerge.cjs +1 -1
- package/lib/cjs/persisters/persister-automerge.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-browser.cjs +1 -1
- package/lib/cjs/persisters/persister-browser.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-expo-sqlite.cjs +1 -1
- package/lib/cjs/persisters/persister-expo-sqlite.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-file.cjs +1 -1
- package/lib/cjs/persisters/persister-file.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-indexed-db.cjs +1 -1
- package/lib/cjs/persisters/persister-indexed-db.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-partykit-client.cjs +1 -1
- package/lib/cjs/persisters/persister-partykit-client.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
- package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-remote.cjs +1 -1
- package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-yjs.cjs +1 -1
- package/lib/cjs/persisters/persister-yjs.cjs.gz +0 -0
- package/lib/cjs/persisters.cjs +1 -1
- package/lib/cjs/persisters.cjs.gz +0 -0
- package/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/relationships.cjs +1 -1
- package/lib/cjs/relationships.cjs.gz +0 -0
- package/lib/cjs/store.cjs +1 -1
- package/lib/cjs/store.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/cjs/ui-react-dom.cjs +1 -1
- package/lib/cjs/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/checkpoints.cjs +1 -1
- package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
- package/lib/cjs-es6/indexes.cjs +1 -1
- package/lib/cjs-es6/indexes.cjs.gz +0 -0
- package/lib/cjs-es6/metrics.cjs +1 -1
- package/lib/cjs-es6/metrics.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-automerge.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-automerge.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-browser.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-browser.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-file.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-file.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-indexed-db.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-indexed-db.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-partykit-client.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-partykit-client.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-remote.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-yjs.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-yjs.cjs.gz +0 -0
- package/lib/cjs-es6/persisters.cjs +1 -1
- package/lib/cjs-es6/persisters.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/relationships.cjs +1 -1
- package/lib/cjs-es6/relationships.cjs.gz +0 -0
- package/lib/cjs-es6/store.cjs +1 -1
- package/lib/cjs-es6/store.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/checkpoints.js +12 -12
- package/lib/debug/indexes.js +9 -9
- package/lib/debug/metrics.js +9 -9
- package/lib/debug/persisters/persister-automerge.js +21 -8
- package/lib/debug/persisters/persister-browser.js +17 -3
- package/lib/debug/persisters/persister-cr-sqlite-wasm.js +27 -12
- package/lib/debug/persisters/persister-expo-sqlite.js +27 -12
- package/lib/debug/persisters/persister-file.js +17 -3
- package/lib/debug/persisters/persister-indexed-db.js +21 -8
- package/lib/debug/persisters/persister-partykit-client.js +54 -20
- package/lib/debug/persisters/persister-partykit-server.js +173 -77
- package/lib/debug/persisters/persister-remote.js +17 -3
- package/lib/debug/persisters/persister-sqlite-wasm.js +27 -12
- package/lib/debug/persisters/persister-sqlite3.js +28 -13
- package/lib/debug/persisters/persister-yjs.js +23 -10
- package/lib/debug/persisters.js +16 -4
- package/lib/debug/queries.js +16 -15
- package/lib/debug/relationships.js +9 -9
- package/lib/debug/store.js +130 -35
- package/lib/debug/tinybase.js +142 -41
- package/lib/debug/tools.js +17 -9
- package/lib/debug/ui-react-dom.js +262 -150
- package/lib/debug/ui-react.js +26 -18
- package/lib/es6/checkpoints.js +1 -1
- package/lib/es6/checkpoints.js.gz +0 -0
- package/lib/es6/indexes.js +1 -1
- package/lib/es6/indexes.js.gz +0 -0
- package/lib/es6/metrics.js +1 -1
- package/lib/es6/metrics.js.gz +0 -0
- package/lib/es6/persisters/persister-automerge.js +1 -1
- package/lib/es6/persisters/persister-automerge.js.gz +0 -0
- package/lib/es6/persisters/persister-browser.js +1 -1
- package/lib/es6/persisters/persister-browser.js.gz +0 -0
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-expo-sqlite.js +1 -1
- package/lib/es6/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/es6/persisters/persister-file.js +1 -1
- package/lib/es6/persisters/persister-file.js.gz +0 -0
- package/lib/es6/persisters/persister-indexed-db.js +1 -1
- package/lib/es6/persisters/persister-indexed-db.js.gz +0 -0
- package/lib/es6/persisters/persister-partykit-client.js +1 -1
- package/lib/es6/persisters/persister-partykit-client.js.gz +0 -0
- package/lib/es6/persisters/persister-partykit-server.js +1 -1
- package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
- package/lib/es6/persisters/persister-remote.js +1 -1
- package/lib/es6/persisters/persister-remote.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite3.js +1 -1
- package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/es6/persisters/persister-yjs.js +1 -1
- package/lib/es6/persisters/persister-yjs.js.gz +0 -0
- package/lib/es6/persisters.js +1 -1
- package/lib/es6/persisters.js.gz +0 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/store.js +1 -1
- package/lib/es6/store.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react-dom-debug.js +1 -1
- package/lib/es6/ui-react-dom-debug.js.gz +0 -0
- package/lib/es6/ui-react-dom.js +1 -1
- package/lib/es6/ui-react-dom.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters/persister-automerge.js +1 -1
- package/lib/persisters/persister-automerge.js.gz +0 -0
- package/lib/persisters/persister-browser.js +1 -1
- package/lib/persisters/persister-browser.js.gz +0 -0
- package/lib/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-expo-sqlite.js +1 -1
- package/lib/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/persisters/persister-file.js +1 -1
- package/lib/persisters/persister-file.js.gz +0 -0
- package/lib/persisters/persister-indexed-db.js +1 -1
- package/lib/persisters/persister-indexed-db.js.gz +0 -0
- package/lib/persisters/persister-partykit-client.js +1 -1
- package/lib/persisters/persister-partykit-client.js.gz +0 -0
- package/lib/persisters/persister-partykit-server.js +1 -1
- package/lib/persisters/persister-partykit-server.js.gz +0 -0
- package/lib/persisters/persister-remote.js +1 -1
- package/lib/persisters/persister-remote.js.gz +0 -0
- package/lib/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-sqlite3.js +1 -1
- package/lib/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/persisters/persister-yjs.js +1 -1
- package/lib/persisters/persister-yjs.js.gz +0 -0
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/types/persisters/persister-automerge.d.ts +36 -3
- package/lib/types/persisters/persister-browser.d.ts +71 -8
- package/lib/types/persisters/persister-cr-sqlite-wasm.d.ts +42 -8
- package/lib/types/persisters/persister-expo-sqlite.d.ts +40 -7
- package/lib/types/persisters/persister-file.d.ts +34 -3
- package/lib/types/persisters/persister-indexed-db.d.ts +40 -9
- package/lib/types/persisters/persister-partykit-client.d.ts +99 -13
- package/lib/types/persisters/persister-partykit-server.d.ts +414 -9
- package/lib/types/persisters/persister-remote.d.ts +40 -4
- package/lib/types/persisters/persister-sqlite-wasm.d.ts +46 -7
- package/lib/types/persisters/persister-sqlite3.d.ts +40 -7
- package/lib/types/persisters/persister-yjs.d.ts +37 -5
- package/lib/types/persisters.d.ts +10 -10
- package/lib/types/queries.d.ts +24 -0
- package/lib/types/store.d.ts +911 -31
- package/lib/types/tools.d.ts +4 -6
- package/lib/types/ui-react-dom.d.ts +13 -2
- package/lib/types/ui-react.d.ts +27 -6
- package/lib/types/with-schemas/persisters/persister-automerge.d.ts +38 -4
- package/lib/types/with-schemas/persisters/persister-browser.d.ts +75 -10
- package/lib/types/with-schemas/persisters/persister-cr-sqlite-wasm.d.ts +44 -9
- package/lib/types/with-schemas/persisters/persister-expo-sqlite.d.ts +42 -8
- package/lib/types/with-schemas/persisters/persister-file.d.ts +36 -4
- package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +42 -10
- package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +102 -15
- package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +447 -9
- package/lib/types/with-schemas/persisters/persister-remote.d.ts +42 -5
- package/lib/types/with-schemas/persisters/persister-sqlite-wasm.d.ts +48 -8
- package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +41 -7
- package/lib/types/with-schemas/persisters/persister-yjs.d.ts +39 -6
- package/lib/types/with-schemas/persisters.d.ts +10 -10
- package/lib/types/with-schemas/queries.d.ts +24 -0
- package/lib/types/with-schemas/store.d.ts +1179 -35
- package/lib/types/with-schemas/tools.d.ts +4 -6
- package/lib/types/with-schemas/ui-react-dom.d.ts +21 -4
- package/lib/types/with-schemas/ui-react.d.ts +29 -6
- package/lib/ui-react-dom.js +1 -1
- package/lib/ui-react-dom.js.gz +0 -0
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/persisters/persister-automerge.js +1 -1
- package/lib/umd/persisters/persister-automerge.js.gz +0 -0
- package/lib/umd/persisters/persister-browser.js +1 -1
- package/lib/umd/persisters/persister-browser.js.gz +0 -0
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-expo-sqlite.js +1 -1
- package/lib/umd/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/umd/persisters/persister-file.js +1 -1
- package/lib/umd/persisters/persister-file.js.gz +0 -0
- package/lib/umd/persisters/persister-indexed-db.js +1 -1
- package/lib/umd/persisters/persister-indexed-db.js.gz +0 -0
- package/lib/umd/persisters/persister-partykit-client.js +1 -1
- package/lib/umd/persisters/persister-partykit-client.js.gz +0 -0
- package/lib/umd/persisters/persister-partykit-server.js +1 -1
- package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
- package/lib/umd/persisters/persister-remote.js +1 -1
- package/lib/umd/persisters/persister-remote.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite3.js +1 -1
- package/lib/umd/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/umd/persisters/persister-yjs.js +1 -1
- package/lib/umd/persisters/persister-yjs.js.gz +0 -0
- package/lib/umd/persisters.js +1 -1
- package/lib/umd/persisters.js.gz +0 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd/ui-react-dom-debug.js +1 -1
- package/lib/umd/ui-react-dom-debug.js.gz +0 -0
- package/lib/umd/ui-react-dom.js +1 -1
- package/lib/umd/ui-react-dom.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/checkpoints.js +1 -1
- package/lib/umd-es6/checkpoints.js.gz +0 -0
- package/lib/umd-es6/indexes.js +1 -1
- package/lib/umd-es6/indexes.js.gz +0 -0
- package/lib/umd-es6/metrics.js +1 -1
- package/lib/umd-es6/metrics.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-automerge.js +1 -1
- package/lib/umd-es6/persisters/persister-automerge.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-browser.js +1 -1
- package/lib/umd-es6/persisters/persister-browser.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-expo-sqlite.js +1 -1
- package/lib/umd-es6/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-file.js +1 -1
- package/lib/umd-es6/persisters/persister-file.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-indexed-db.js +1 -1
- package/lib/umd-es6/persisters/persister-indexed-db.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-partykit-client.js +1 -1
- package/lib/umd-es6/persisters/persister-partykit-client.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
- package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-remote.js +1 -1
- package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite3.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-yjs.js +1 -1
- package/lib/umd-es6/persisters/persister-yjs.js.gz +0 -0
- package/lib/umd-es6/persisters.js +1 -1
- package/lib/umd-es6/persisters.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/relationships.js +1 -1
- package/lib/umd-es6/relationships.js.gz +0 -0
- package/lib/umd-es6/store.js +1 -1
- package/lib/umd-es6/store.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom-debug.js +1 -1
- package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom.js +1 -1
- package/lib/umd-es6/ui-react-dom.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +42 -40
- package/readme.md +2 -2
|
@@ -18,7 +18,76 @@
|
|
|
18
18
|
* @since 4.3.0
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import {Cell, CellOrUndefined, Value, ValueOrUndefined} from '../store';
|
|
22
|
+
import {Connection, Party, Request, Server} from 'partykit/server';
|
|
23
|
+
import {Id} from '../common';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The TinyBasePartyKitServerConfig type describes the configuration of a
|
|
27
|
+
* PartyKit Persister on the server side.
|
|
28
|
+
*
|
|
29
|
+
* The defaults (if used on both the server and client) will work fine, but if
|
|
30
|
+
* you are building more complex PartyKit apps and you need to configure path
|
|
31
|
+
* names, for example, then this is the type to use.
|
|
32
|
+
* @example
|
|
33
|
+
* When set as the config in a TinyBasePartyKitServer, this
|
|
34
|
+
* TinyBasePartyKitServerConfig will expect clients to load and save their JSON
|
|
35
|
+
* serialization from and to an end point in the room called `/my_tinybase`.
|
|
36
|
+
* Note that this would require you to also add the matching storePath setting
|
|
37
|
+
* to the PartyKitPersisterConfig on the client side.
|
|
38
|
+
*
|
|
39
|
+
* It will also store the data in the durable storage with a prefix of
|
|
40
|
+
* 'tinybase_' in case you are worried about colliding with other data stored
|
|
41
|
+
* in the room.
|
|
42
|
+
*
|
|
43
|
+
* ```js
|
|
44
|
+
* class MyServer extends TinyBasePartyKitServer {
|
|
45
|
+
* readonly config = {
|
|
46
|
+
* storePath: '/my_tinybase',
|
|
47
|
+
* storagePrefix: 'tinybase_',
|
|
48
|
+
* };
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
* @category Configuration
|
|
52
|
+
* @since v4.3.9
|
|
53
|
+
*/
|
|
54
|
+
export type TinyBasePartyKitServerConfig = {
|
|
55
|
+
/**
|
|
56
|
+
* The path used to set and get the whole Store over HTTP(S) on the server.
|
|
57
|
+
* This must match the storePath property of the PartyKitPersisterConfig used
|
|
58
|
+
* on the client. Both default to '/store'.
|
|
59
|
+
*/
|
|
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;
|
|
69
|
+
/**
|
|
70
|
+
* The prefix used before all the keys in the server's durable storage. Use
|
|
71
|
+
* this in case you are worried about the Store data colliding with other data
|
|
72
|
+
* stored in the room. Defaults to an empty string.
|
|
73
|
+
*/
|
|
74
|
+
storagePrefix?: string;
|
|
75
|
+
/**
|
|
76
|
+
* An object containing the extra HTTP(S) headers returned to the client from
|
|
77
|
+
* this server. This defaults to the following three headers to allow CORS:
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
* Access-Control-Allow-Origin: *
|
|
81
|
+
* Access-Control-Allow-Methods: *
|
|
82
|
+
* Access-Control-Allow-Headers: *
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* If you set this field, it will override the default completely. So, for
|
|
86
|
+
* example, if you add another header but still want the CORS defaults, you
|
|
87
|
+
* will need to explicitly set the Access-Control-Allow headers above again.
|
|
88
|
+
*/
|
|
89
|
+
responseHeaders?: HeadersInit;
|
|
90
|
+
};
|
|
22
91
|
|
|
23
92
|
/**
|
|
24
93
|
* A TinyBasePartyKitServer is the server component for persisting the Store to
|
|
@@ -39,7 +108,7 @@ import {Connection, Request, Server} from 'partykit/server';
|
|
|
39
108
|
* ```js
|
|
40
109
|
* // This is your PartyKit server entry point.
|
|
41
110
|
*
|
|
42
|
-
*
|
|
111
|
+
* class MyServer extends TinyBasePartyKitServer {
|
|
43
112
|
* constructor(party) {
|
|
44
113
|
* super(party);
|
|
45
114
|
* // custom constructor code
|
|
@@ -50,8 +119,8 @@ import {Connection, Request, Server} from 'partykit/server';
|
|
|
50
119
|
* console.log('Server started');
|
|
51
120
|
* }
|
|
52
121
|
*
|
|
53
|
-
* async onMessage(message,
|
|
54
|
-
* await super.onMessage(message,
|
|
122
|
+
* async onMessage(message, connection) {
|
|
123
|
+
* await super.onMessage(message, connection);
|
|
55
124
|
* // custom onMessage code
|
|
56
125
|
* }
|
|
57
126
|
*
|
|
@@ -65,8 +134,20 @@ import {Connection, Request, Server} from 'partykit/server';
|
|
|
65
134
|
* See the [PartyKit server API
|
|
66
135
|
* documentation](https://docs.partykit.io/reference/partyserver-api/) for
|
|
67
136
|
* more details.
|
|
137
|
+
* @category Creation
|
|
138
|
+
* @since v4.3.0
|
|
68
139
|
*/
|
|
69
140
|
export class TinyBasePartyKitServer implements Server {
|
|
141
|
+
constructor(party: Party);
|
|
142
|
+
/**
|
|
143
|
+
* The config property is used to optionally configure the server, using an
|
|
144
|
+
* object of the TinyBasePartyKitServerConfig type.
|
|
145
|
+
*
|
|
146
|
+
* See the documentation for that type for more details.
|
|
147
|
+
* @category Configuration
|
|
148
|
+
* @since v4.3.9
|
|
149
|
+
*/
|
|
150
|
+
readonly config: TinyBasePartyKitServerConfig;
|
|
70
151
|
/**
|
|
71
152
|
* The onRequest method is called when a HTTP request is made to the party
|
|
72
153
|
* URL.
|
|
@@ -76,7 +157,7 @@ export class TinyBasePartyKitServer implements Server {
|
|
|
76
157
|
* synchronization stays supported:
|
|
77
158
|
*
|
|
78
159
|
* ```js
|
|
79
|
-
*
|
|
160
|
+
* class MyServer extends TinyBasePartyKitServer {
|
|
80
161
|
* async onRequest(request) {
|
|
81
162
|
* // custom onRequest code, else:
|
|
82
163
|
* return await super.onRequest(request);
|
|
@@ -87,6 +168,8 @@ export class TinyBasePartyKitServer implements Server {
|
|
|
87
168
|
* See the [PartyKit server API
|
|
88
169
|
* documentation](https://docs.partykit.io/reference/partyserver-api/) for
|
|
89
170
|
* more details.
|
|
171
|
+
* @category Connection
|
|
172
|
+
* @since v4.3.0
|
|
90
173
|
*/
|
|
91
174
|
onRequest(request: Request): Promise<Response>;
|
|
92
175
|
/**
|
|
@@ -98,9 +181,9 @@ export class TinyBasePartyKitServer implements Server {
|
|
|
98
181
|
* synchronization stays supported:
|
|
99
182
|
*
|
|
100
183
|
* ```js
|
|
101
|
-
*
|
|
102
|
-
* async onMessage(message,
|
|
103
|
-
* await super.onMessage(message,
|
|
184
|
+
* class MyServer extends TinyBasePartyKitServer {
|
|
185
|
+
* async onMessage(message, connection) {
|
|
186
|
+
* await super.onMessage(message, connection);
|
|
104
187
|
* // custom onMessage code
|
|
105
188
|
* }
|
|
106
189
|
* }
|
|
@@ -109,6 +192,328 @@ export class TinyBasePartyKitServer implements Server {
|
|
|
109
192
|
* See the [PartyKit server API
|
|
110
193
|
* documentation](https://docs.partykit.io/reference/partyserver-api/) for
|
|
111
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
|
|
112
517
|
*/
|
|
113
|
-
|
|
518
|
+
canDelValue(valueId: Id, connection: Connection): boolean;
|
|
114
519
|
}
|
|
@@ -9,6 +9,42 @@
|
|
|
9
9
|
import {Persister} from '../persisters';
|
|
10
10
|
import {Store} from '../store';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The RemotePersister interface is a minor extension to the Persister
|
|
14
|
+
* interface.
|
|
15
|
+
*
|
|
16
|
+
* It simply provides an extra getUrls method for accessing the URLs the Store
|
|
17
|
+
* is being persisted to.
|
|
18
|
+
* @since v4.3.14
|
|
19
|
+
*/
|
|
20
|
+
export interface RemotePersister extends Persister {
|
|
21
|
+
/**
|
|
22
|
+
* The getUrls method returns the URLs the Store is being persisted to.
|
|
23
|
+
* @returns The load and save URLs as a two-item array.
|
|
24
|
+
* @example
|
|
25
|
+
* This example creates a RemotePersister object against a newly-created Store
|
|
26
|
+
* and then gets the URLs back out again.
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
30
|
+
* const persister = createRemotePersister(
|
|
31
|
+
* store,
|
|
32
|
+
* 'https://example.com/load',
|
|
33
|
+
* 'https://example.com/save',
|
|
34
|
+
* 5,
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* console.log(persister.getUrls());
|
|
38
|
+
* // -> ['https://example.com/load', 'https://example.com/save']
|
|
39
|
+
*
|
|
40
|
+
* persister.destroy();
|
|
41
|
+
* ```
|
|
42
|
+
* @category Getter
|
|
43
|
+
* @since v4.3.14
|
|
44
|
+
*/
|
|
45
|
+
getUrls: () => [string, string];
|
|
46
|
+
}
|
|
47
|
+
|
|
12
48
|
/**
|
|
13
49
|
* The createRemotePersister function creates a Persister object that can
|
|
14
50
|
* persist the Store to a remote server.
|
|
@@ -29,10 +65,10 @@ import {Store} from '../store';
|
|
|
29
65
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
30
66
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
31
67
|
* debugging persistence issues in a development environment, since v4.0.4.
|
|
32
|
-
* @returns A reference to the new
|
|
68
|
+
* @returns A reference to the new RemotePersister object.
|
|
33
69
|
* @example
|
|
34
|
-
* This example creates a
|
|
35
|
-
* server.
|
|
70
|
+
* This example creates a RemotePersister object and persists the Store to a
|
|
71
|
+
* remote server.
|
|
36
72
|
*
|
|
37
73
|
* ```js yolo
|
|
38
74
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
@@ -59,4 +95,4 @@ export function createRemotePersister(
|
|
|
59
95
|
saveUrl: string,
|
|
60
96
|
autoLoadIntervalSeconds?: number,
|
|
61
97
|
onIgnoredError?: (error: any) => void,
|
|
62
|
-
):
|
|
98
|
+
): RemotePersister;
|
|
@@ -11,6 +11,45 @@
|
|
|
11
11
|
import {DatabasePersisterConfig, Persister} from '../persisters';
|
|
12
12
|
import {Store} from '../store';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The SqliteWasmPersister interface is a minor extension to the Persister
|
|
16
|
+
* interface.
|
|
17
|
+
*
|
|
18
|
+
* It simply provides an extra getDb method for accessing a reference to the
|
|
19
|
+
* database instance the Store is being persisted to.
|
|
20
|
+
* @since v4.3.14
|
|
21
|
+
*/
|
|
22
|
+
export interface SqliteWasmPersister extends Persister {
|
|
23
|
+
/**
|
|
24
|
+
* The getDb method returns a reference to the database instance the Store is
|
|
25
|
+
* being persisted to.
|
|
26
|
+
* @returns A reference to the database instance.
|
|
27
|
+
* @example
|
|
28
|
+
* This example creates a Persister object against a newly-created Store and
|
|
29
|
+
* then gets the database instance back out again.
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* const sqlite3 = await sqlite3InitModule();
|
|
33
|
+
* const db = new sqlite3.oo1.DB(':memory:', 'c');
|
|
34
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
35
|
+
* const persister = createSqliteWasmPersister(
|
|
36
|
+
* store,
|
|
37
|
+
* sqlite3,
|
|
38
|
+
* db,
|
|
39
|
+
* 'my_tinybase',
|
|
40
|
+
* );
|
|
41
|
+
*
|
|
42
|
+
* console.log(persister.getDb() == db);
|
|
43
|
+
* // -> true
|
|
44
|
+
*
|
|
45
|
+
* persister.destroy();
|
|
46
|
+
* ```
|
|
47
|
+
* @category Getter
|
|
48
|
+
* @since v4.3.14
|
|
49
|
+
*/
|
|
50
|
+
getDb: () => any;
|
|
51
|
+
}
|
|
52
|
+
|
|
14
53
|
/**
|
|
15
54
|
* The createSqliteWasmPersister function creates a Persister object that can
|
|
16
55
|
* persist the Store to a local SQLite database (in an appropriate environment).
|
|
@@ -43,11 +82,11 @@ import {Store} from '../store';
|
|
|
43
82
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
44
83
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
45
84
|
* debugging persistence issues in a development environment, since v4.0.4.
|
|
46
|
-
* @returns A reference to the new
|
|
85
|
+
* @returns A reference to the new SqliteWasmPersister object.
|
|
47
86
|
* @example
|
|
48
|
-
* This example creates a
|
|
49
|
-
* SQLite database as a JSON serialization into the `my_tinybase` table.
|
|
50
|
-
* makes a change to the database directly and then reloads it back into the
|
|
87
|
+
* This example creates a SqliteWasmPersister object and persists the Store to a
|
|
88
|
+
* local SQLite database as a JSON serialization into the `my_tinybase` table.
|
|
89
|
+
* It makes a change to the database directly and then reloads it back into the
|
|
51
90
|
* Store.
|
|
52
91
|
*
|
|
53
92
|
* ```js
|
|
@@ -78,8 +117,8 @@ import {Store} from '../store';
|
|
|
78
117
|
* persister.destroy();
|
|
79
118
|
* ```
|
|
80
119
|
* @example
|
|
81
|
-
* This example creates a
|
|
82
|
-
* SQLite database with tabular mapping.
|
|
120
|
+
* This example creates a SqliteWasmPersister object and persists the Store to a
|
|
121
|
+
* local SQLite database with tabular mapping.
|
|
83
122
|
*
|
|
84
123
|
* ```js
|
|
85
124
|
* const sqlite3 = await sqlite3InitModule();
|
|
@@ -111,4 +150,4 @@ export function createSqliteWasmPersister(
|
|
|
111
150
|
configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
112
151
|
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
113
152
|
onIgnoredError?: (error: any) => void,
|
|
114
|
-
):
|
|
153
|
+
): SqliteWasmPersister;
|
|
@@ -12,6 +12,39 @@ import {DatabasePersisterConfig, Persister} from '../persisters';
|
|
|
12
12
|
import {Database} from 'sqlite3';
|
|
13
13
|
import {Store} from '../store';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The Sqlite3Persister interface is a minor extension to the Persister
|
|
17
|
+
* interface.
|
|
18
|
+
*
|
|
19
|
+
* It simply provides an extra getDb method for accessing a reference to the
|
|
20
|
+
* database instance the Store is being persisted to.
|
|
21
|
+
* @since v4.3.14
|
|
22
|
+
*/
|
|
23
|
+
export interface Sqlite3Persister extends Persister {
|
|
24
|
+
/**
|
|
25
|
+
* The getDb method returns a reference to the database instance the Store is
|
|
26
|
+
* being persisted to.
|
|
27
|
+
* @returns A reference to the database instance.
|
|
28
|
+
* @example
|
|
29
|
+
* This example creates a Persister object against a newly-created Store and
|
|
30
|
+
* then gets the database instance back out again.
|
|
31
|
+
*
|
|
32
|
+
* ```js
|
|
33
|
+
* const db = new sqlite3.Database(':memory:');
|
|
34
|
+
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
35
|
+
* const persister = createSqlite3Persister(store, db, 'my_tinybase');
|
|
36
|
+
*
|
|
37
|
+
* console.log(persister.getDb() == db);
|
|
38
|
+
* // -> true
|
|
39
|
+
*
|
|
40
|
+
* persister.destroy();
|
|
41
|
+
* ```
|
|
42
|
+
* @category Getter
|
|
43
|
+
* @since v4.3.14
|
|
44
|
+
*/
|
|
45
|
+
getDb: () => Database;
|
|
46
|
+
}
|
|
47
|
+
|
|
15
48
|
/**
|
|
16
49
|
* The createSqlite3Persister function creates a Persister object that can
|
|
17
50
|
* persist the Store to a local SQLite database (in an appropriate environment).
|
|
@@ -42,11 +75,11 @@ import {Store} from '../store';
|
|
|
42
75
|
* @param onIgnoredError An optional handler for the errors that the Persister
|
|
43
76
|
* would otherwise ignore when trying to save or load data. This is suitable for
|
|
44
77
|
* debugging persistence issues in a development environment, since v4.0.4.
|
|
45
|
-
* @returns A reference to the new
|
|
78
|
+
* @returns A reference to the new Sqlite3Persister object.
|
|
46
79
|
* @example
|
|
47
|
-
* This example creates a
|
|
48
|
-
* SQLite database as a JSON serialization into the `my_tinybase` table.
|
|
49
|
-
* makes a change to the database directly and then reloads it back into the
|
|
80
|
+
* This example creates a Sqlite3Persister object and persists the Store to a
|
|
81
|
+
* local SQLite database as a JSON serialization into the `my_tinybase` table.
|
|
82
|
+
* It makes a change to the database directly and then reloads it back into the
|
|
50
83
|
* Store.
|
|
51
84
|
*
|
|
52
85
|
* ```js
|
|
@@ -78,8 +111,8 @@ import {Store} from '../store';
|
|
|
78
111
|
* persister.destroy();
|
|
79
112
|
* ```
|
|
80
113
|
* @example
|
|
81
|
-
* This example creates a
|
|
82
|
-
* SQLite database with tabular mapping.
|
|
114
|
+
* This example creates a Sqlite3Persister object and persists the Store to a
|
|
115
|
+
* local SQLite database with tabular mapping.
|
|
83
116
|
*
|
|
84
117
|
* ```js
|
|
85
118
|
* const db = new sqlite3.Database(':memory:');
|
|
@@ -118,4 +151,4 @@ export function createSqlite3Persister(
|
|
|
118
151
|
configOrStoreTableName?: DatabasePersisterConfig | string,
|
|
119
152
|
onSqlCommand?: (sql: string, args?: any[]) => void,
|
|
120
153
|
onIgnoredError?: (error: any) => void,
|
|
121
|
-
):
|
|
154
|
+
): Sqlite3Persister;
|