jazz-tools 2.0.0-alpha.60 → 2.0.0-alpha.62
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/README.md +1 -1
- package/bin/jazz-tools.js +3 -0
- package/dist/_dev/native-account-session.d.ts +8 -1
- package/dist/_dev/native-account-session.d.ts.map +1 -1
- package/dist/_dev/native-account-session.js +10 -0
- package/dist/_dev/native-account-session.js.map +1 -1
- package/dist/accounts/account-manager-core.d.ts +6 -0
- package/dist/accounts/account-manager-core.d.ts.map +1 -1
- package/dist/accounts/account-manager-core.js +26 -2
- package/dist/accounts/account-manager-core.js.map +1 -1
- package/dist/accounts/enrollment.d.ts.map +1 -1
- package/dist/accounts/enrollment.js +13 -4
- package/dist/accounts/enrollment.js.map +1 -1
- package/dist/accounts/exports.d.ts +1 -2
- package/dist/accounts/exports.d.ts.map +1 -1
- package/dist/accounts/exports.js +4 -1
- package/dist/accounts/exports.js.map +1 -1
- package/dist/accounts/persistence.d.ts +38 -2
- package/dist/accounts/persistence.d.ts.map +1 -1
- package/dist/accounts/persistence.js +123 -6
- package/dist/accounts/persistence.js.map +1 -1
- package/dist/accounts/registry-client.d.ts +29 -0
- package/dist/accounts/registry-client.d.ts.map +1 -1
- package/dist/accounts/registry-client.js +45 -0
- package/dist/accounts/registry-client.js.map +1 -1
- package/dist/accounts/state.d.ts.map +1 -1
- package/dist/accounts/state.js +2 -1
- package/dist/accounts/state.js.map +1 -1
- package/dist/backend/create-jazz-context.d.ts +7 -0
- package/dist/backend/create-jazz-context.d.ts.map +1 -1
- package/dist/backend/create-jazz-context.js +115 -18
- package/dist/backend/create-jazz-context.js.map +1 -1
- package/dist/backend/create-jazz-session.d.ts +9 -7
- package/dist/backend/create-jazz-session.d.ts.map +1 -1
- package/dist/backend/create-jazz-session.js +55 -17
- package/dist/backend/create-jazz-session.js.map +1 -1
- package/dist/backend/create-jazz.d.ts +196 -38
- package/dist/backend/create-jazz.d.ts.map +1 -1
- package/dist/backend/create-jazz.js +935 -147
- package/dist/backend/create-jazz.js.map +1 -1
- package/dist/backend/early-db.d.ts.map +1 -1
- package/dist/backend/early-db.js +1 -0
- package/dist/backend/early-db.js.map +1 -1
- package/dist/backend/external-jwt.d.ts.map +1 -1
- package/dist/backend/external-jwt.js +34 -10
- package/dist/backend/external-jwt.js.map +1 -1
- package/dist/backend/from-jwt.d.ts +6 -4
- package/dist/backend/from-jwt.d.ts.map +1 -1
- package/dist/backend/from-jwt.js +11 -3
- package/dist/backend/from-jwt.js.map +1 -1
- package/dist/backend/index.d.ts +2 -1
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +3 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/inspect-ui.d.ts +14 -0
- package/dist/backend/inspect-ui.d.ts.map +1 -0
- package/dist/backend/inspect-ui.js +156 -0
- package/dist/backend/inspect-ui.js.map +1 -0
- package/dist/backend/inspect.d.ts +133 -0
- package/dist/backend/inspect.d.ts.map +1 -0
- package/dist/backend/inspect.js +983 -0
- package/dist/backend/inspect.js.map +1 -0
- package/dist/backend/inspector-ui/0.js +2 -0
- package/dist/backend/inspector-ui/1.js +2 -0
- package/dist/backend/inspector-ui/10.js +2 -0
- package/dist/backend/inspector-ui/11.js +2 -0
- package/dist/backend/inspector-ui/12.js +2 -0
- package/dist/backend/inspector-ui/13.js +2 -0
- package/dist/backend/inspector-ui/14.js +2 -0
- package/dist/backend/inspector-ui/15.js +2 -0
- package/dist/backend/inspector-ui/16.js +2 -0
- package/dist/backend/inspector-ui/17.js +2 -0
- package/dist/backend/inspector-ui/18.js +2 -0
- package/dist/backend/inspector-ui/19.js +2 -0
- package/dist/backend/inspector-ui/2.js +2 -0
- package/dist/backend/inspector-ui/20.js +2 -0
- package/dist/backend/inspector-ui/3.js +2 -0
- package/dist/backend/inspector-ui/4.js +2 -0
- package/dist/backend/inspector-ui/5.js +2 -0
- package/dist/backend/inspector-ui/6.js +2 -0
- package/dist/backend/inspector-ui/7.js +2 -0
- package/dist/backend/inspector-ui/8.js +2 -0
- package/dist/backend/inspector-ui/9.js +2 -0
- package/dist/backend/inspector-ui-files.d.ts +4 -0
- package/dist/backend/inspector-ui-files.d.ts.map +1 -0
- package/dist/backend/inspector-ui-files.js +25 -0
- package/dist/backend/request-auth.d.ts +11 -0
- package/dist/backend/request-auth.d.ts.map +1 -1
- package/dist/backend/request-auth.js +14 -0
- package/dist/backend/request-auth.js.map +1 -1
- package/dist/backend/session-expiry.d.ts +61 -0
- package/dist/backend/session-expiry.d.ts.map +1 -0
- package/dist/backend/session-expiry.js +102 -0
- package/dist/backend/session-expiry.js.map +1 -0
- package/dist/backend/signing-key.d.ts +10 -0
- package/dist/backend/signing-key.d.ts.map +1 -0
- package/dist/backend/signing-key.js +15 -0
- package/dist/backend/signing-key.js.map +1 -0
- package/dist/backend/store-log.d.ts +3 -0
- package/dist/backend/store-log.d.ts.map +1 -0
- package/dist/backend/store-log.js +16 -0
- package/dist/backend/store-log.js.map +1 -0
- package/dist/backend/upgrade-status.d.ts +19 -0
- package/dist/backend/upgrade-status.d.ts.map +1 -0
- package/dist/backend/upgrade-status.js +55 -0
- package/dist/backend/upgrade-status.js.map +1 -0
- package/dist/backend/vercel-store.d.ts +88 -12
- package/dist/backend/vercel-store.d.ts.map +1 -1
- package/dist/backend/vercel-store.js +303 -44
- package/dist/backend/vercel-store.js.map +1 -1
- package/dist/backend/ws-peer.d.ts +32 -0
- package/dist/backend/ws-peer.d.ts.map +1 -0
- package/dist/backend/ws-peer.js +40 -0
- package/dist/backend/ws-peer.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts +134 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js +121 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/schema.d.ts +2 -1
- package/dist/better-auth-adapter/fixtures/schema.d.ts.map +1 -1
- package/dist/better-auth-adapter/fixtures/schema.js +2 -1
- package/dist/better-auth-adapter/fixtures/schema.js.map +1 -1
- package/dist/better-auth-adapter/index.d.ts.map +1 -1
- package/dist/better-auth-adapter/index.js +47 -0
- package/dist/better-auth-adapter/index.js.map +1 -1
- package/dist/classic-api.d.ts.map +1 -1
- package/dist/classic-api.js +36 -0
- package/dist/classic-api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +54 -11
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +2 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -3
- package/dist/client/index.js.map +1 -1
- package/dist/cloud/credentials.d.ts +1 -1
- package/dist/cloud/credentials.d.ts.map +1 -1
- package/dist/cloud/credentials.js.map +1 -1
- package/dist/dev/catalogue-project.d.ts +12 -3
- package/dist/dev/catalogue-project.d.ts.map +1 -1
- package/dist/dev/catalogue-project.js +29 -4
- package/dist/dev/catalogue-project.js.map +1 -1
- package/dist/dev/catalogue.d.ts +12 -0
- package/dist/dev/catalogue.d.ts.map +1 -1
- package/dist/dev/catalogue.js +94 -15
- package/dist/dev/catalogue.js.map +1 -1
- package/dist/dev/dev-server.d.ts +4 -1
- package/dist/dev/dev-server.d.ts.map +1 -1
- package/dist/dev/dev-server.js +41 -3
- package/dist/dev/dev-server.js.map +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/backend-C6JfNAB2.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-B8Fn7-qJ.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-C3BWHq-S.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-DC_mAoiW.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C_pcvEcg.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-Cv6-V0tc.js} +787 -608
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-Db-pNME-.js +5 -0
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-CTwPHZcZ.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-HpkRDlj-.wasm} +0 -0
- package/dist/dev/inspector-overlay/embedded/assets/src-B5UtjtXQ.js +22 -0
- package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
- package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
- package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/host-bridge.js +4 -1
- package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
- package/dist/dev/inspector-overlay/loader.d.ts +12 -1
- package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/loader.js +31 -4
- package/dist/dev/inspector-overlay/loader.js.map +1 -1
- package/dist/dev/migrations.d.ts.map +1 -1
- package/dist/dev/migrations.js +53 -7
- package/dist/dev/migrations.js.map +1 -1
- package/dist/drivers/schema-wire.d.ts +6 -2
- package/dist/drivers/schema-wire.d.ts.map +1 -1
- package/dist/drivers/schema-wire.js +6 -2
- package/dist/drivers/schema-wire.js.map +1 -1
- package/dist/effect/jazz.d.ts +12 -5
- package/dist/effect/jazz.d.ts.map +1 -1
- package/dist/effect/jazz.js +28 -5
- package/dist/effect/jazz.js.map +1 -1
- package/dist/expo/create-account-manager.d.ts +1 -1
- package/dist/expo/create-account-manager.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.d.ts +37 -17
- package/dist/expo/create-jazz-session.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.js +53 -10
- package/dist/expo/create-jazz-session.js.map +1 -1
- package/dist/expo/index.d.ts +5 -8
- package/dist/expo/index.d.ts.map +1 -1
- package/dist/expo/index.js +5 -7
- package/dist/expo/index.js.map +1 -1
- package/dist/expo/metro.d.ts +20 -0
- package/dist/expo/metro.d.ts.map +1 -0
- package/dist/expo/metro.js +58 -0
- package/dist/expo/metro.js.map +1 -0
- package/dist/expo/provider.d.ts +6 -3
- package/dist/expo/provider.d.ts.map +1 -1
- package/dist/expo/provider.js +7 -6
- package/dist/expo/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspect/cli.d.ts +12 -0
- package/dist/inspect/cli.d.ts.map +1 -0
- package/dist/inspect/cli.js +320 -0
- package/dist/inspect/cli.js.map +1 -0
- package/dist/inspect/client.d.ts +67 -0
- package/dist/inspect/client.d.ts.map +1 -0
- package/dist/inspect/client.js +254 -0
- package/dist/inspect/client.js.map +1 -0
- package/dist/inspect/mcp.d.ts +28 -0
- package/dist/inspect/mcp.d.ts.map +1 -0
- package/dist/inspect/mcp.js +441 -0
- package/dist/inspect/mcp.js.map +1 -0
- package/dist/inspect/protocol.d.ts +317 -0
- package/dist/inspect/protocol.d.ts.map +1 -0
- package/dist/inspect/protocol.js +544 -0
- package/dist/inspect/protocol.js.map +1 -0
- package/dist/inspector/index.d.ts +10 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +27 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/local-first/index.d.ts +2 -0
- package/dist/local-first/index.d.ts.map +1 -1
- package/dist/local-first/index.js +2 -0
- package/dist/local-first/index.js.map +1 -1
- package/dist/migrations.d.ts +23 -3
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +28 -6
- package/dist/migrations.js.map +1 -1
- package/dist/module-interop.d.ts +17 -0
- package/dist/module-interop.d.ts.map +1 -0
- package/dist/module-interop.js +32 -0
- package/dist/module-interop.js.map +1 -0
- package/dist/permissions/index.d.ts +1 -1
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +31 -10
- package/dist/permissions/index.js.map +1 -1
- package/dist/prosemirror/sync.d.ts.map +1 -1
- package/dist/prosemirror/sync.js +43 -21
- package/dist/prosemirror/sync.js.map +1 -1
- package/dist/react/index.d.ts +4 -9
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -6
- package/dist/react/index.js.map +1 -1
- package/dist/react/provider-props.d.ts +7 -0
- package/dist/react/provider-props.d.ts.map +1 -0
- package/dist/react/provider-props.js +15 -0
- package/dist/react/provider-props.js.map +1 -0
- package/dist/react/provider.d.ts +9 -15
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +19 -38
- package/dist/react/provider.js.map +1 -1
- package/dist/react-core/index.d.ts +3 -4
- package/dist/react-core/index.d.ts.map +1 -1
- package/dist/react-core/index.js +8 -4
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/provider.d.ts +6 -6
- package/dist/react-core/provider.d.ts.map +1 -1
- package/dist/react-core/provider.js +5 -6
- package/dist/react-core/provider.js.map +1 -1
- package/dist/react-core/session.d.ts +41 -33
- package/dist/react-core/session.d.ts.map +1 -1
- package/dist/react-core/session.js +42 -90
- package/dist/react-core/session.js.map +1 -1
- package/dist/react-native/account-session.js +1 -1
- package/dist/react-native/account-session.js.map +1 -1
- package/dist/react-native/create-account-manager.d.ts +1 -1
- package/dist/react-native/create-account-manager.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.d.ts +37 -17
- package/dist/react-native/create-jazz-session.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.js +53 -10
- package/dist/react-native/create-jazz-session.js.map +1 -1
- package/dist/react-native/index.d.ts +5 -10
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +5 -7
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/native-foreground-db.d.ts +21 -0
- package/dist/react-native/native-foreground-db.d.ts.map +1 -1
- package/dist/react-native/native-foreground-db.js +47 -1
- package/dist/react-native/native-foreground-db.js.map +1 -1
- package/dist/react-native/provider.d.ts +14 -19
- package/dist/react-native/provider.d.ts.map +1 -1
- package/dist/react-native/provider.js +19 -18
- package/dist/react-native/provider.js.map +1 -1
- package/dist/react-native/runtime-source.d.ts +22 -0
- package/dist/react-native/runtime-source.d.ts.map +1 -1
- package/dist/react-native/runtime-source.js +68 -5
- package/dist/react-native/runtime-source.js.map +1 -1
- package/dist/removed-api.d.ts +87 -0
- package/dist/removed-api.d.ts.map +1 -0
- package/dist/removed-api.js +95 -0
- package/dist/removed-api.js.map +1 -0
- package/dist/runtime/auth-secret-store.d.ts +0 -44
- package/dist/runtime/auth-secret-store.d.ts.map +1 -1
- package/dist/runtime/auth-secret-store.js +1 -103
- package/dist/runtime/auth-secret-store.js.map +1 -1
- package/dist/runtime/authority-changed-error.d.ts +5 -3
- package/dist/runtime/authority-changed-error.d.ts.map +1 -1
- package/dist/runtime/authority-changed-error.js +5 -3
- package/dist/runtime/authority-changed-error.js.map +1 -1
- package/dist/runtime/browser-worker-assets.d.ts +19 -1
- package/dist/runtime/browser-worker-assets.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.js +23 -1
- package/dist/runtime/browser-worker-assets.js.map +1 -1
- package/dist/runtime/browser-worker-assets.metro.d.ts +28 -0
- package/dist/runtime/browser-worker-assets.metro.d.ts.map +1 -0
- package/dist/runtime/browser-worker-assets.metro.js +52 -0
- package/dist/runtime/browser-worker-assets.metro.js.map +1 -0
- package/dist/runtime/browser-worker-assets.native.d.ts +2 -0
- package/dist/runtime/browser-worker-assets.native.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.native.js +2 -0
- package/dist/runtime/browser-worker-assets.native.js.map +1 -1
- package/dist/runtime/browser-worker-config.d.ts +23 -0
- package/dist/runtime/browser-worker-config.d.ts.map +1 -1
- package/dist/runtime/browser-worker-config.js +72 -4
- package/dist/runtime/browser-worker-config.js.map +1 -1
- package/dist/runtime/client-migrations.d.ts +6 -4
- package/dist/runtime/client-migrations.d.ts.map +1 -1
- package/dist/runtime/client-migrations.js +20 -2
- package/dist/runtime/client-migrations.js.map +1 -1
- package/dist/runtime/client.d.ts +46 -6
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +65 -13
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts +5 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.js +38 -2
- package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts +3 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.js +7 -3
- package/dist/runtime/connection-manager/direct-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/types.d.ts +23 -2
- package/dist/runtime/connection-manager/types.d.ts.map +1 -1
- package/dist/runtime/connection-manager/types.js +49 -6
- package/dist/runtime/connection-manager/types.js.map +1 -1
- package/dist/runtime/context.d.ts +5 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/core-tick-failed-error.d.ts +31 -0
- package/dist/runtime/core-tick-failed-error.d.ts.map +1 -0
- package/dist/runtime/core-tick-failed-error.js +45 -0
- package/dist/runtime/core-tick-failed-error.js.map +1 -0
- package/dist/runtime/credentialed-transport.d.ts +18 -3
- package/dist/runtime/credentialed-transport.d.ts.map +1 -1
- package/dist/runtime/credentialed-transport.js +34 -11
- package/dist/runtime/credentialed-transport.js.map +1 -1
- package/dist/runtime/db-replaced-error.d.ts +3 -1
- package/dist/runtime/db-replaced-error.d.ts.map +1 -1
- package/dist/runtime/db-replaced-error.js +4 -2
- package/dist/runtime/db-replaced-error.js.map +1 -1
- package/dist/runtime/db.d.ts +40 -8
- package/dist/runtime/db.d.ts.map +1 -1
- package/dist/runtime/db.js +76 -9
- package/dist/runtime/db.js.map +1 -1
- package/dist/runtime/default-runtime-source.d.ts.map +1 -1
- package/dist/runtime/default-runtime-source.js +6 -1
- package/dist/runtime/default-runtime-source.js.map +1 -1
- package/dist/runtime/delete-local-first-store.d.ts +12 -0
- package/dist/runtime/delete-local-first-store.d.ts.map +1 -0
- package/dist/runtime/delete-local-first-store.js +12 -0
- package/dist/runtime/delete-local-first-store.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-first-upgrade.d.ts +9 -0
- package/dist/runtime/local-first-upgrade.d.ts.map +1 -1
- package/dist/runtime/local-first-upgrade.js.map +1 -1
- package/dist/runtime/metro-setup-error.d.ts +20 -0
- package/dist/runtime/metro-setup-error.d.ts.map +1 -0
- package/dist/runtime/metro-setup-error.js +22 -0
- package/dist/runtime/metro-setup-error.js.map +1 -0
- package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +4 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js +3 -0
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +34 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js +61 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts +6 -1
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-follower-connection.js +9 -3
- package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +12 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js +140 -7
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +29 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
- package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.js +148 -44
- package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.js +1 -0
- package/dist/runtime/native-runtime/native-error-code.js.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +105 -7
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.js +306 -27
- package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts +48 -0
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts.map +1 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js +107 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts +22 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js +69 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js.map +1 -0
- package/dist/runtime/native-runtime/websocket.d.ts +51 -1
- package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/websocket.js +187 -7
- package/dist/runtime/native-runtime/websocket.js.map +1 -1
- package/dist/runtime/page-handle.d.ts +83 -0
- package/dist/runtime/page-handle.d.ts.map +1 -0
- package/dist/runtime/page-handle.js +151 -0
- package/dist/runtime/page-handle.js.map +1 -0
- package/dist/runtime/removed-provider-props.d.ts +17 -0
- package/dist/runtime/removed-provider-props.d.ts.map +1 -0
- package/dist/runtime/removed-provider-props.js +16 -0
- package/dist/runtime/removed-provider-props.js.map +1 -0
- package/dist/runtime/row-transformer.d.ts.map +1 -1
- package/dist/runtime/row-transformer.js +20 -0
- package/dist/runtime/row-transformer.js.map +1 -1
- package/dist/runtime/runtime-config.d.ts +5 -1
- package/dist/runtime/runtime-config.d.ts.map +1 -1
- package/dist/runtime/runtime-config.js +5 -1
- package/dist/runtime/runtime-config.js.map +1 -1
- package/dist/runtime/runtime-source.d.ts +6 -1
- package/dist/runtime/runtime-source.d.ts.map +1 -1
- package/dist/runtime/runtime-source.js.map +1 -1
- package/dist/runtime/schema-metadata.d.ts +17 -0
- package/dist/runtime/schema-metadata.d.ts.map +1 -1
- package/dist/runtime/schema-metadata.js +28 -0
- package/dist/runtime/schema-metadata.js.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
- package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.js +11 -0
- package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
- package/dist/runtime/sync-status.d.ts +60 -1
- package/dist/runtime/sync-status.d.ts.map +1 -1
- package/dist/runtime/sync-status.js +64 -4
- package/dist/runtime/sync-status.js.map +1 -1
- package/dist/runtime/wasm-loader.d.ts.map +1 -1
- package/dist/runtime/wasm-loader.js +8 -1
- package/dist/runtime/wasm-loader.js.map +1 -1
- package/dist/schema-loader.d.ts +2 -0
- package/dist/schema-loader.d.ts.map +1 -1
- package/dist/schema-loader.js +7 -2
- package/dist/schema-loader.js.map +1 -1
- package/dist/schema-permissions.d.ts.map +1 -1
- package/dist/schema-permissions.js +19 -0
- package/dist/schema-permissions.js.map +1 -1
- package/dist/schema-source.d.ts.map +1 -1
- package/dist/schema-source.js +14 -0
- package/dist/schema-source.js.map +1 -1
- package/dist/session/backend-watch.d.ts +56 -15
- package/dist/session/backend-watch.d.ts.map +1 -1
- package/dist/session/backend-watch.js +127 -31
- package/dist/session/backend-watch.js.map +1 -1
- package/dist/session/config-options.d.ts +15 -0
- package/dist/session/config-options.d.ts.map +1 -0
- package/dist/session/config-options.js +55 -0
- package/dist/session/config-options.js.map +1 -0
- package/dist/session/consumer.d.ts +1 -1
- package/dist/session/consumer.js +1 -1
- package/dist/session/consumer.js.map +1 -1
- package/dist/session/create-jazz-session.d.ts +55 -21
- package/dist/session/create-jazz-session.d.ts.map +1 -1
- package/dist/session/create-jazz-session.js +215 -166
- package/dist/session/create-jazz-session.js.map +1 -1
- package/dist/session/follow-user.d.ts +30 -11
- package/dist/session/follow-user.d.ts.map +1 -1
- package/dist/session/follow-user.js +49 -9
- package/dist/session/follow-user.js.map +1 -1
- package/dist/session/jazz-session.d.ts +182 -0
- package/dist/session/jazz-session.d.ts.map +1 -0
- package/dist/session/jazz-session.js +459 -0
- package/dist/session/jazz-session.js.map +1 -0
- package/dist/session/no-kept-device-account-error.d.ts +6 -0
- package/dist/session/no-kept-device-account-error.d.ts.map +1 -0
- package/dist/session/no-kept-device-account-error.js +8 -0
- package/dist/session/no-kept-device-account-error.js.map +1 -0
- package/dist/session/replica-ledger.d.ts +164 -0
- package/dist/session/replica-ledger.d.ts.map +1 -0
- package/dist/session/replica-ledger.js +450 -0
- package/dist/session/replica-ledger.js.map +1 -0
- package/dist/session/state.d.ts +50 -13
- package/dist/session/state.d.ts.map +1 -1
- package/dist/session/state.js +158 -29
- package/dist/session/state.js.map +1 -1
- package/dist/solid/index.d.ts +3 -9
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.js +8 -11
- package/dist/solid/index.ssr.js +3 -6
- package/dist/solid/provider.d.ts +3 -3
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.js +23 -39
- package/dist/solid/provider.js.map +1 -1
- package/dist/solid/provider.ssr.js +6 -23
- package/dist/solid/provider.ssr.js.map +1 -1
- package/dist/solid/session.d.ts +42 -12
- package/dist/solid/session.d.ts.map +1 -1
- package/dist/solid/session.js +82 -35
- package/dist/solid/session.js.map +1 -1
- package/dist/solid/session.ssr.js +86 -23
- package/dist/solid/session.ssr.js.map +1 -1
- package/dist/svelte/JazzProvider.svelte +54 -20
- package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
- package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteProvider.svelte +5 -4
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/index.d.ts +4 -12
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +4 -8
- package/dist/svelte/session-state.d.ts +14 -4
- package/dist/svelte/session-state.d.ts.map +1 -1
- package/dist/svelte/session-state.js +10 -4
- package/dist/testing/client-migrations.d.ts +8 -1
- package/dist/testing/client-migrations.d.ts.map +1 -1
- package/dist/testing/client-migrations.js +11 -0
- package/dist/testing/client-migrations.js.map +1 -1
- package/dist/testing/policy-test-app.d.ts.map +1 -1
- package/dist/testing/policy-test-app.js +5 -4
- package/dist/testing/policy-test-app.js.map +1 -1
- package/dist/testing/test-jazz.d.ts +2 -2
- package/dist/testing/test-jazz.d.ts.map +1 -1
- package/dist/testing/test-jazz.js +6 -3
- package/dist/testing/test-jazz.js.map +1 -1
- package/dist/thin/index.d.ts +7 -10
- package/dist/thin/index.d.ts.map +1 -1
- package/dist/thin/index.js +28 -11
- package/dist/thin/index.js.map +1 -1
- package/dist/thin/thin-runtime.d.ts +53 -3
- package/dist/thin/thin-runtime.d.ts.map +1 -1
- package/dist/thin/thin-runtime.js +256 -33
- package/dist/thin/thin-runtime.js.map +1 -1
- package/dist/typed-app.d.ts +10 -4
- package/dist/typed-app.d.ts.map +1 -1
- package/dist/typed-app.js +44 -18
- package/dist/typed-app.js.map +1 -1
- package/dist/vue/index.d.ts +3 -8
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +3 -5
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/provider.d.ts +6 -27
- package/dist/vue/provider.d.ts.map +1 -1
- package/dist/vue/provider.js +10 -19
- package/dist/vue/provider.js.map +1 -1
- package/dist/vue/session.d.ts +29 -28
- package/dist/vue/session.d.ts.map +1 -1
- package/dist/vue/session.js +80 -23
- package/dist/vue/session.js.map +1 -1
- package/dist/web/create-jazz-client.d.ts +5 -1
- package/dist/web/create-jazz-client.d.ts.map +1 -1
- package/dist/web/create-jazz-client.js +30 -3
- package/dist/web/create-jazz-client.js.map +1 -1
- package/dist/window-client-storage.d.ts +4 -30
- package/dist/window-client-storage.d.ts.map +1 -1
- package/dist/window-client-storage.js +2 -63
- package/dist/window-client-storage.js.map +1 -1
- package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
- package/dist/worker/jazz-broker-worker-core.js +118 -20
- package/dist/worker/jazz-broker-worker-core.js.map +1 -1
- package/dist/worker/jazz-broker-worker.js +787 -608
- package/dist/worker/jazz_wasm_bg.wasm +0 -0
- package/dist/worker/runtime-admission.d.ts +19 -0
- package/dist/worker/runtime-admission.d.ts.map +1 -0
- package/dist/worker/runtime-admission.js +34 -0
- package/dist/worker/runtime-admission.js.map +1 -0
- package/dist/worker/vite-dev-broker.d.ts +2 -0
- package/dist/worker/vite-dev-broker.d.ts.map +1 -0
- package/dist/worker/vite-dev-broker.js +8 -0
- package/dist/worker/vite-dev-broker.js.map +1 -0
- package/package.json +30 -10
- package/dist/backend/session-recheck.d.ts +0 -18
- package/dist/backend/session-recheck.d.ts.map +0 -1
- package/dist/backend/session-recheck.js +0 -57
- package/dist/backend/session-recheck.js.map +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
- package/dist/dev/inspector-overlay/serve.d.ts +0 -46
- package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
- package/dist/dev/inspector-overlay/serve.js +0 -131
- package/dist/dev/inspector-overlay/serve.js.map +0 -1
- package/dist/dev-tools/auto-attach.d.ts +0 -11
- package/dist/dev-tools/auto-attach.d.ts.map +0 -1
- package/dist/dev-tools/auto-attach.js +0 -26
- package/dist/dev-tools/auto-attach.js.map +0 -1
- package/dist/expo/auth-secret-store.d.ts +0 -37
- package/dist/expo/auth-secret-store.d.ts.map +0 -1
- package/dist/expo/auth-secret-store.js +0 -139
- package/dist/expo/auth-secret-store.js.map +0 -1
- package/dist/expo/session.d.ts +0 -10
- package/dist/expo/session.d.ts.map +0 -1
- package/dist/expo/session.js +0 -5
- package/dist/expo/session.js.map +0 -1
- package/dist/expo/use-local-first-auth.d.ts +0 -12
- package/dist/expo/use-local-first-auth.d.ts.map +0 -1
- package/dist/expo/use-local-first-auth.js +0 -13
- package/dist/expo/use-local-first-auth.js.map +0 -1
- package/dist/react/devtools-auto-attach.d.ts +0 -2
- package/dist/react/devtools-auto-attach.d.ts.map +0 -1
- package/dist/react/devtools-auto-attach.js +0 -11
- package/dist/react/devtools-auto-attach.js.map +0 -1
- package/dist/react/session.d.ts +0 -18
- package/dist/react/session.d.ts.map +0 -1
- package/dist/react/session.js +0 -28
- package/dist/react/session.js.map +0 -1
- package/dist/react/use-local-first-auth.d.ts +0 -11
- package/dist/react/use-local-first-auth.d.ts.map +0 -1
- package/dist/react/use-local-first-auth.js +0 -13
- package/dist/react/use-local-first-auth.js.map +0 -1
- package/dist/react-core/app.d.ts +0 -31
- package/dist/react-core/app.d.ts.map +0 -1
- package/dist/react-core/app.js +0 -65
- package/dist/react-core/app.js.map +0 -1
- package/dist/react-core/use-account-state.d.ts +0 -4
- package/dist/react-core/use-account-state.d.ts.map +0 -1
- package/dist/react-core/use-account-state.js +0 -6
- package/dist/react-core/use-account-state.js.map +0 -1
- package/dist/react-core/use-local-first-auth.d.ts +0 -12
- package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-core/use-local-first-auth.js +0 -14
- package/dist/react-core/use-local-first-auth.js.map +0 -1
- package/dist/react-native/session.d.ts +0 -10
- package/dist/react-native/session.d.ts.map +0 -1
- package/dist/react-native/session.js +0 -5
- package/dist/react-native/session.js.map +0 -1
- package/dist/react-native/use-local-first-auth.d.ts +0 -15
- package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-native/use-local-first-auth.js +0 -14
- package/dist/react-native/use-local-first-auth.js.map +0 -1
- package/dist/runtime/local-first-auth-controller.d.ts +0 -29
- package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
- package/dist/runtime/local-first-auth-controller.js +0 -101
- package/dist/runtime/local-first-auth-controller.js.map +0 -1
- package/dist/session/app.d.ts +0 -58
- package/dist/session/app.d.ts.map +0 -1
- package/dist/session/app.js +0 -325
- package/dist/session/app.js.map +0 -1
- package/dist/session/create-jazz-app.d.ts +0 -11
- package/dist/session/create-jazz-app.d.ts.map +0 -1
- package/dist/session/create-jazz-app.js +0 -11
- package/dist/session/create-jazz-app.js.map +0 -1
- package/dist/session/left-behind-replicas.d.ts +0 -62
- package/dist/session/left-behind-replicas.d.ts.map +0 -1
- package/dist/session/left-behind-replicas.js +0 -146
- package/dist/session/left-behind-replicas.js.map +0 -1
- package/dist/solid/app.d.ts +0 -30
- package/dist/solid/app.d.ts.map +0 -1
- package/dist/solid/app.js +0 -95
- package/dist/solid/app.js.map +0 -1
- package/dist/solid/app.ssr.js +0 -109
- package/dist/solid/app.ssr.js.map +0 -1
- package/dist/solid/create-account-state.d.ts +0 -4
- package/dist/solid/create-account-state.d.ts.map +0 -1
- package/dist/solid/create-account-state.js +0 -10
- package/dist/solid/create-account-state.js.map +0 -1
- package/dist/solid/create-account-state.ssr.js +0 -12
- package/dist/solid/create-account-state.ssr.js.map +0 -1
- package/dist/solid/use-local-first-auth.d.ts +0 -11
- package/dist/solid/use-local-first-auth.d.ts.map +0 -1
- package/dist/solid/use-local-first-auth.js +0 -30
- package/dist/solid/use-local-first-auth.js.map +0 -1
- package/dist/solid/use-local-first-auth.ssr.js +0 -31
- package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
- package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/JazzSessionProvider.svelte +0 -68
- package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
- package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/account-state.d.ts +0 -5
- package/dist/svelte/account-state.d.ts.map +0 -1
- package/dist/svelte/account-state.js +0 -9
- package/dist/svelte/auth-state.d.ts +0 -23
- package/dist/svelte/auth-state.d.ts.map +0 -1
- package/dist/svelte/auth-state.js +0 -16
- package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
- package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
- package/dist/svelte/local-first-auth.svelte.js +0 -58
- package/dist/vue/app.d.ts +0 -76
- package/dist/vue/app.d.ts.map +0 -1
- package/dist/vue/app.js +0 -100
- package/dist/vue/app.js.map +0 -1
- package/dist/vue/use-account-state.d.ts +0 -5
- package/dist/vue/use-account-state.d.ts.map +0 -1
- package/dist/vue/use-account-state.js +0 -10
- package/dist/vue/use-account-state.js.map +0 -1
- package/dist/vue/use-local-first-auth.d.ts +0 -53
- package/dist/vue/use-local-first-auth.d.ts.map +0 -1
- package/dist/vue/use-local-first-auth.js +0 -67
- package/dist/vue/use-local-first-auth.js.map +0 -1
- /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
- /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseSnapshotRef } from "../runtime/snapshot-ref.js";
|
|
2
|
-
import { CONNECTED, CONNECTING, offlineLink } from "../runtime/sync-status.js";
|
|
2
|
+
import { CONNECTED, CONNECTING, linkFailureOf, offlineLink, } from "../runtime/sync-status.js";
|
|
3
3
|
import { streamingChunks } from "../runtime/streaming-source.js";
|
|
4
4
|
import { runtimeRandomBytes } from "../runtime/runtime-entropy.js";
|
|
5
5
|
import { writeRow } from "../runtime/write-row.js";
|
|
@@ -9,7 +9,7 @@ import { canonicalAuthorSubject } from "../runtime/author-id.js";
|
|
|
9
9
|
import { PostcardReader, readNativeSubscriptionDelta, } from "../runtime/native-runtime/native-codec.js";
|
|
10
10
|
import { addNestedOuterColumns, assertNoUnsupportedPermissionIntrospection, assertSupportedReadOptions, branchViewFromWriteContext, decodeSubscriptionDelta, effectiveUpdatedAtMs, encodeCellsForPatch, encodeCellsForRow, encodeCellsForStreamingPatch, encodeCellsForStreamingRow, encodeQueryJson, openTransactionIdFromOptions, parseUuid, queryHasArraySubqueries, queryIncludesDeleted, readOptions, readRelationSnapshot, readRowBatches, rowsFromBatches, rowsFromRelationSnapshot, subscriptionOutputColumns, txIdFromContext, } from "../runtime/native-runtime/native-runtime-adapter.js";
|
|
11
11
|
import { encodeSchema } from "../runtime/native-runtime/schema-codec.js";
|
|
12
|
-
import { WebSocketCarrier, peerIdentityForWebSocketAuth, wireAuthFailureReason, } from "../runtime/native-runtime/websocket.js";
|
|
12
|
+
import { WebSocketCarrier, peerIdentityForWebSocketAuth, isReauthenticateWireError, wireAuthFailureReason, } from "../runtime/native-runtime/websocket.js";
|
|
13
13
|
import { FEATURE_THIN_RESULTS, decodeThinResponse, encodeThinRequest, MAX_THIN_MESSAGE_BYTES, ThinAssembler, thinWireFrames, isThinResponse, } from "./wire.js";
|
|
14
14
|
/** A request failed on the server. `code` is the engine's stable error code. */
|
|
15
15
|
export class ThinRemoteError extends Error {
|
|
@@ -50,6 +50,14 @@ export class ThinTransactionLostError extends Error {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
const DEFAULT_RECONNECT_DELAYS_MS = [250, 500, 1_000, 2_000, 5_000];
|
|
53
|
+
/**
|
|
54
|
+
* How long after a keyed write was first sent it may still be sent again
|
|
55
|
+
* (SPEC 8 §8.14). The authority keeps a thin write's dedupe entry for an
|
|
56
|
+
* hour on its own clock, recorded no earlier than the first send, so every
|
|
57
|
+
* resend inside this window still finds it. Past it, a write whose answer
|
|
58
|
+
* was lost ends with its fate unknown.
|
|
59
|
+
*/
|
|
60
|
+
export const THIN_WRITE_RESEND_WINDOW_MS = 10 * 60_000;
|
|
53
61
|
/** Standalone writes the server dedups by their `writeKey` (SPEC 8 §8.14). */
|
|
54
62
|
const RESENDABLE_WRITES = new Set([
|
|
55
63
|
"insert",
|
|
@@ -78,6 +86,8 @@ export class ThinRuntime {
|
|
|
78
86
|
authJson;
|
|
79
87
|
/** Requests and live queries go out only once the schema is bound. */
|
|
80
88
|
bound = false;
|
|
89
|
+
/** A planned re-authentication is reconnecting a bound connection (see `lost`). */
|
|
90
|
+
reauthenticating = false;
|
|
81
91
|
wanted = false;
|
|
82
92
|
closed = false;
|
|
83
93
|
attempt = 0;
|
|
@@ -86,12 +96,19 @@ export class ThinRuntime {
|
|
|
86
96
|
reconnectTimer;
|
|
87
97
|
/** The server refused the credential: nothing reconnects until `updateAuth`. */
|
|
88
98
|
refused = false;
|
|
99
|
+
/** How the server put that refusal, for the writes it leaves unsent at close. */
|
|
100
|
+
refusal;
|
|
89
101
|
/** The connection ended for good (`fatal`, `close`). */
|
|
90
102
|
stopped = false;
|
|
91
103
|
/** When connecting started failing; cleared once connected or refused. */
|
|
92
104
|
failingSince;
|
|
93
105
|
outagePublished = false;
|
|
94
106
|
outageReportMs;
|
|
107
|
+
/** Why the latest connection ended, in the server's words when it said. */
|
|
108
|
+
lastLostMessage;
|
|
109
|
+
/** The way the link is failing now, to record each failure once. */
|
|
110
|
+
failingAs = null;
|
|
111
|
+
lastFailure = null;
|
|
95
112
|
nextRequestId = 1;
|
|
96
113
|
oneShots = new Map();
|
|
97
114
|
nextHandle = 1;
|
|
@@ -101,13 +118,19 @@ export class ThinRuntime {
|
|
|
101
118
|
/** This runtime's writer node: with {@link nextWriteSeq}, each write's
|
|
102
119
|
* `writeKey`. The server commits the write under a node it derives from
|
|
103
120
|
* this one and the session's author, so one node serves every identity
|
|
104
|
-
* the runtime writes as.
|
|
105
|
-
|
|
121
|
+
* the runtime writes as. It is marked as bounding its resends
|
|
122
|
+
* ({@link boundedWriterNode}). */
|
|
123
|
+
writerNode = bytesToHex(boundedWriterNode());
|
|
106
124
|
nextWriteSeq = 1;
|
|
107
125
|
/** Writes the server has not answered yet. */
|
|
108
126
|
unanswered = 0;
|
|
127
|
+
/** Writes the server rejected, and the latest rejection. */
|
|
128
|
+
rejected = 0;
|
|
129
|
+
lastRejection = null;
|
|
109
130
|
syncStatusListeners = new Set();
|
|
110
131
|
transactions = new Map();
|
|
132
|
+
/** Streaming writes still sending their value; each settles once its write is made. */
|
|
133
|
+
streamsInFlight = new Set();
|
|
111
134
|
mutationErrorCallback;
|
|
112
135
|
authFailureCallback;
|
|
113
136
|
constructor(schema, options = {}) {
|
|
@@ -176,16 +199,22 @@ export class ThinRuntime {
|
|
|
176
199
|
this.closed = true;
|
|
177
200
|
this.wanted = false;
|
|
178
201
|
this.stop();
|
|
179
|
-
|
|
180
|
-
|
|
202
|
+
// Closed while the server refused this client's sign-in (its user's
|
|
203
|
+
// access was revoked, or their session ended, and they signed out):
|
|
204
|
+
// what never reached the server says so, not just that it closed.
|
|
205
|
+
const why = this.refused
|
|
206
|
+
? `the server refused this client's sign-in (${this.refusal?.message ?? "auth_failed"}), and the thin runtime closed before it signed in again`
|
|
207
|
+
: "the thin runtime is closed";
|
|
208
|
+
const closed = new ThinConnectionLostError(why, {
|
|
209
|
+
cause: new RuntimeClosedError(why),
|
|
181
210
|
});
|
|
182
211
|
this.dropConnection(closed);
|
|
183
212
|
// Nothing connects again: a request not sent yet ends too (a write
|
|
184
213
|
// waiting to go out again with its fate unknown), so a read the app made
|
|
185
214
|
// while the server was down asks the Db's successor instead.
|
|
186
|
-
this.endWaitingRequests(closed, new ThinRequestNotSentError(
|
|
187
|
-
|
|
188
|
-
|
|
215
|
+
this.endWaitingRequests(closed, new ThinRequestNotSentError(this.refused
|
|
216
|
+
? `the request never reached the server: ${why}`
|
|
217
|
+
: "the thin runtime closed before sending the request", { cause: closed.cause }));
|
|
189
218
|
for (const live of this.liveQueries.values())
|
|
190
219
|
live.callback = undefined;
|
|
191
220
|
this.liveQueries.clear();
|
|
@@ -203,6 +232,12 @@ export class ThinRuntime {
|
|
|
203
232
|
authJson: this.authJson,
|
|
204
233
|
WebSocket: this.WebSocketImpl,
|
|
205
234
|
onFrame: (frame) => this.receive(carrier, frame),
|
|
235
|
+
// The server's planned re-authentication arrives as an error on an open
|
|
236
|
+
// connection, ahead of its close: handle it as the connection's end.
|
|
237
|
+
onError: (error) => {
|
|
238
|
+
if (isReauthenticateWireError(error))
|
|
239
|
+
this.lost(carrier, error);
|
|
240
|
+
},
|
|
206
241
|
onTerminal: (error) => this.lost(carrier, error),
|
|
207
242
|
});
|
|
208
243
|
this.carrier = carrier;
|
|
@@ -232,7 +267,9 @@ export class ThinRuntime {
|
|
|
232
267
|
}
|
|
233
268
|
this.attempt = 0;
|
|
234
269
|
this.bound = true;
|
|
270
|
+
this.reauthenticating = false;
|
|
235
271
|
this.refused = false;
|
|
272
|
+
this.refusal = undefined;
|
|
236
273
|
this.stopped = false;
|
|
237
274
|
this.clearOutage();
|
|
238
275
|
this.notifySyncStatus();
|
|
@@ -268,12 +305,27 @@ export class ThinRuntime {
|
|
|
268
305
|
if (this.carrier !== carrier)
|
|
269
306
|
return;
|
|
270
307
|
const lostError = new ThinConnectionLostError(`${error.code}: ${error.message}`);
|
|
308
|
+
const wasBound = this.bound;
|
|
309
|
+
this.lastLostMessage = error.message;
|
|
310
|
+
// A planned swap that ends any other way is reported as that ending.
|
|
311
|
+
this.reauthenticating = false;
|
|
312
|
+
if (isReauthenticateWireError(error) && wasBound) {
|
|
313
|
+
// The session reached the expiry the app's auth gave it: connect again
|
|
314
|
+
// at once so `authenticate` decides with the current credential. The
|
|
315
|
+
// app keeps seeing a connected link meanwhile; unanswered writes go
|
|
316
|
+
// out again on the new connection.
|
|
317
|
+
this.reauthenticating = true;
|
|
318
|
+
this.dropConnection(lostError, true);
|
|
319
|
+
this.open();
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
271
322
|
const authFailure = wireAuthFailureReason(error);
|
|
272
323
|
if (authFailure) {
|
|
273
324
|
// Refused before the drop publishes, so the link never reads
|
|
274
325
|
// "connecting" in between.
|
|
275
326
|
this.clearOutage();
|
|
276
327
|
this.refused = true;
|
|
328
|
+
this.refusal = lostError;
|
|
277
329
|
// Writes left unanswered wait for the renewed credential's connection.
|
|
278
330
|
this.dropConnection(lostError, this.wanted && !this.closed && error.retry !== "never");
|
|
279
331
|
this.notifySyncStatus();
|
|
@@ -288,11 +340,14 @@ export class ThinRuntime {
|
|
|
288
340
|
return;
|
|
289
341
|
}
|
|
290
342
|
this.dropConnection(lostError, this.wanted && !this.closed);
|
|
291
|
-
// An attempt that fails past the window reports the outage.
|
|
343
|
+
// An attempt that fails past the window reports the outage. A server that
|
|
344
|
+
// answered and refused this connection for now (`backpressure` before
|
|
345
|
+
// admission, such as the connection cap per user) is reported at once:
|
|
346
|
+
// there is nothing to wait out, and its message says why.
|
|
292
347
|
if (!this.stopped &&
|
|
293
348
|
!this.outagePublished &&
|
|
294
|
-
|
|
295
|
-
|
|
349
|
+
((!wasBound && error.code === "backpressure") ||
|
|
350
|
+
(this.failingSince !== undefined && Date.now() - this.failingSince >= this.outageReportMs))) {
|
|
296
351
|
this.outagePublished = true;
|
|
297
352
|
}
|
|
298
353
|
this.notifySyncStatus();
|
|
@@ -346,9 +401,15 @@ export class ThinRuntime {
|
|
|
346
401
|
// write sent once, unless this drop ends its resends.
|
|
347
402
|
if (!oneShot.sent && !(oneShot.resending && !resend))
|
|
348
403
|
continue;
|
|
349
|
-
if (oneShot.sent && resend && oneShot.resendable) {
|
|
404
|
+
if (oneShot.sent && resend && oneShot.resendable && !resendWindowPassed(oneShot)) {
|
|
350
405
|
oneShot.sent = false;
|
|
351
406
|
oneShot.resending = true;
|
|
407
|
+
this.endAtResendWindow(id, oneShot);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (oneShot.sent && resend && oneShot.resendable) {
|
|
411
|
+
this.oneShots.delete(id);
|
|
412
|
+
oneShot.reject(resendWindowEnded(error));
|
|
352
413
|
continue;
|
|
353
414
|
}
|
|
354
415
|
this.oneShots.delete(id);
|
|
@@ -364,6 +425,7 @@ export class ThinRuntime {
|
|
|
364
425
|
fatal(error) {
|
|
365
426
|
this.wanted = false;
|
|
366
427
|
this.failure = error;
|
|
428
|
+
this.lastLostMessage = error.message;
|
|
367
429
|
this.stop();
|
|
368
430
|
// A write the server may have taken ends with its fate unknown, not as
|
|
369
431
|
// the server's rejection of it.
|
|
@@ -433,7 +495,9 @@ export class ThinRuntime {
|
|
|
433
495
|
this.oneShots.set(id, oneShot);
|
|
434
496
|
if (this.bound)
|
|
435
497
|
this.transmit(id, oneShot);
|
|
436
|
-
})
|
|
498
|
+
})
|
|
499
|
+
.finally(() => clearTimeout(oneShot?.windowTimer))
|
|
500
|
+
.then((body) => {
|
|
437
501
|
if (body.type === "error")
|
|
438
502
|
throw new ThinRemoteError(body.code, body.message);
|
|
439
503
|
return body;
|
|
@@ -441,13 +505,35 @@ export class ThinRuntime {
|
|
|
441
505
|
return { answer, oneShot };
|
|
442
506
|
}
|
|
443
507
|
transmit(id, oneShot) {
|
|
508
|
+
// Past its window, a resend could find its dedupe entry gone and be
|
|
509
|
+
// written again: it ends with its fate unknown instead.
|
|
510
|
+
if (oneShot.resending && resendWindowPassed(oneShot)) {
|
|
511
|
+
this.oneShots.delete(id);
|
|
512
|
+
oneShot.reject(resendWindowEnded());
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
444
515
|
const sent = this.sendFrame(this.carrier, encodeThinRequest(id, oneShot.op), (bytes) => {
|
|
445
516
|
// Refused here: the server would refuse it.
|
|
446
517
|
this.oneShots.delete(id);
|
|
447
518
|
oneShot.reject(tooLarge(oneShot.op.type, bytes));
|
|
448
519
|
});
|
|
449
|
-
if (sent)
|
|
520
|
+
if (sent) {
|
|
450
521
|
oneShot.sent = true;
|
|
522
|
+
oneShot.firstSentAt ??= Date.now();
|
|
523
|
+
clearTimeout(oneShot.windowTimer);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
/** End `oneShot`, waiting to go out again, once its resend window passes
|
|
527
|
+
* (it may wait offline far longer). */
|
|
528
|
+
endAtResendWindow(id, oneShot) {
|
|
529
|
+
clearTimeout(oneShot.windowTimer);
|
|
530
|
+
const left = (oneShot.firstSentAt ?? Date.now()) + THIN_WRITE_RESEND_WINDOW_MS - Date.now();
|
|
531
|
+
oneShot.windowTimer = setTimeout(() => {
|
|
532
|
+
if (this.oneShots.get(id) !== oneShot || oneShot.sent)
|
|
533
|
+
return;
|
|
534
|
+
this.oneShots.delete(id);
|
|
535
|
+
oneShot.reject(resendWindowEnded());
|
|
536
|
+
}, Math.max(0, left));
|
|
451
537
|
}
|
|
452
538
|
receive(carrier, piece) {
|
|
453
539
|
if (this.carrier !== carrier)
|
|
@@ -523,7 +609,7 @@ export class ThinRuntime {
|
|
|
523
609
|
operation,
|
|
524
610
|
transaction: txIdFromContext(writeContext),
|
|
525
611
|
branchView: branchViewFromWriteContext(writeContext),
|
|
526
|
-
updatedAtMs: effectiveUpdatedAtMs(writeContext) ??
|
|
612
|
+
updatedAtMs: effectiveUpdatedAtMs(writeContext) ?? undefined,
|
|
527
613
|
};
|
|
528
614
|
}
|
|
529
615
|
async query(queryJson, sessionJson, tier, optionsJson) {
|
|
@@ -717,6 +803,16 @@ export class ThinRuntime {
|
|
|
717
803
|
});
|
|
718
804
|
}
|
|
719
805
|
async streamingMutation(mutation, table, values, column, source, writeContext, objectId) {
|
|
806
|
+
const running = this.runStreamingMutation(mutation, table, values, column, source, writeContext, objectId);
|
|
807
|
+
// Until its value is sent and its write made, a graceful shutdown (the
|
|
808
|
+
// drain after the local-first upgrade) waits for it: see
|
|
809
|
+
// `waitForPendingWrites`.
|
|
810
|
+
const settled = running.then(() => undefined, () => undefined);
|
|
811
|
+
this.streamsInFlight.add(settled);
|
|
812
|
+
void settled.then(() => this.streamsInFlight.delete(settled));
|
|
813
|
+
return running;
|
|
814
|
+
}
|
|
815
|
+
async runStreamingMutation(mutation, table, values, column, source, writeContext, objectId) {
|
|
720
816
|
const operation = mutation === "insert" ? "Insert" : mutation === "update" ? "Update" : "Upsert";
|
|
721
817
|
const context = this.writeTarget(writeContext, operation);
|
|
722
818
|
const transaction = context.transaction
|
|
@@ -744,6 +840,8 @@ export class ThinRuntime {
|
|
|
744
840
|
}, stream);
|
|
745
841
|
// Chunks go one window at a time: each waits for the server to apply
|
|
746
842
|
// the one before, which bounds what a slow server buffers.
|
|
843
|
+
// Set when the runtime, not the app's source, failed the stream.
|
|
844
|
+
let runtimeFailed = false;
|
|
747
845
|
const push = async (bytes) => {
|
|
748
846
|
const windowBytes = 64 * 1024;
|
|
749
847
|
for (let offset = 0; offset < bytes.byteLength; offset += windowBytes) {
|
|
@@ -751,13 +849,19 @@ export class ThinRuntime {
|
|
|
751
849
|
type: "streamChunk",
|
|
752
850
|
stream,
|
|
753
851
|
chunk: bytes.subarray(offset, offset + windowBytes),
|
|
852
|
+
}).catch((error) => {
|
|
853
|
+
runtimeFailed = true;
|
|
854
|
+
throw error;
|
|
754
855
|
});
|
|
755
856
|
}
|
|
756
857
|
};
|
|
757
858
|
const encoder = new TextEncoder();
|
|
758
859
|
let pendingHighSurrogate = "";
|
|
759
860
|
try {
|
|
760
|
-
await begun
|
|
861
|
+
await begun.catch((error) => {
|
|
862
|
+
runtimeFailed = true;
|
|
863
|
+
throw error;
|
|
864
|
+
});
|
|
761
865
|
for await (const chunk of streamingChunks(source)) {
|
|
762
866
|
if (typeof chunk === "string") {
|
|
763
867
|
if (kind === "Bytea")
|
|
@@ -788,6 +892,14 @@ export class ThinRuntime {
|
|
|
788
892
|
}
|
|
789
893
|
catch (error) {
|
|
790
894
|
void this.request({ type: "abortStream", stream }).catch(() => undefined);
|
|
895
|
+
// The drain after the upgrade lets a stream finish; only the app
|
|
896
|
+
// shutting the client down (a sign-out, an account switch, a close)
|
|
897
|
+
// ends one. Say so, and that the value was not written: the stream
|
|
898
|
+
// never finished, so nothing committed. (The source's own errors
|
|
899
|
+
// stay as they are. A source that never yields again leaves the
|
|
900
|
+
// stream pending: it ends at the source's next step.)
|
|
901
|
+
if (runtimeFailed && this.closed && this.handedOver)
|
|
902
|
+
throw new ThinConnectionLostError("the thin runtime closed before this stream finished: its Db had upgraded to local-first, and the app then shut the client down (a sign-out, an account switch or a close), so the value was not written. Write it again on the Db now in use.", { cause: error });
|
|
791
903
|
throw error;
|
|
792
904
|
}
|
|
793
905
|
const written = context.branchView ? [] : [{ table, id: formatUuid(row) }];
|
|
@@ -942,11 +1054,13 @@ export class ThinRuntime {
|
|
|
942
1054
|
return offlineLink("stopped");
|
|
943
1055
|
if (this.refused)
|
|
944
1056
|
return offlineLink("auth");
|
|
945
|
-
if (this.bound)
|
|
1057
|
+
if (this.bound || this.reauthenticating)
|
|
946
1058
|
return CONNECTED;
|
|
947
1059
|
return this.outagePublished ? offlineLink("network") : CONNECTING;
|
|
948
1060
|
}
|
|
949
1061
|
setRefused(refused) {
|
|
1062
|
+
if (!refused)
|
|
1063
|
+
this.refusal = undefined;
|
|
950
1064
|
if (this.refused === refused)
|
|
951
1065
|
return;
|
|
952
1066
|
this.refused = refused;
|
|
@@ -972,6 +1086,22 @@ export class ThinRuntime {
|
|
|
972
1086
|
pendingUploadCount() {
|
|
973
1087
|
return this.unanswered;
|
|
974
1088
|
}
|
|
1089
|
+
/** The writes waiting for the server's answer, and what it rejected, for the sync status. */
|
|
1090
|
+
uploadStatus() {
|
|
1091
|
+
let oldestPendingAt = null;
|
|
1092
|
+
for (const write of this.writes.values()) {
|
|
1093
|
+
if (write.answered)
|
|
1094
|
+
continue;
|
|
1095
|
+
if (oldestPendingAt === null || write.madeAt < oldestPendingAt)
|
|
1096
|
+
oldestPendingAt = write.madeAt;
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
pending: this.unanswered,
|
|
1100
|
+
oldestPendingAt,
|
|
1101
|
+
rejected: this.rejected,
|
|
1102
|
+
lastRejection: this.lastRejection,
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
975
1105
|
/** Observe changes of {@link pendingUploadCount} and {@link upstreamLinkStatus}. */
|
|
976
1106
|
onSyncStatusChange(listener, signal) {
|
|
977
1107
|
if (signal.aborted)
|
|
@@ -982,25 +1112,73 @@ export class ThinRuntime {
|
|
|
982
1112
|
});
|
|
983
1113
|
}
|
|
984
1114
|
notifySyncStatus() {
|
|
1115
|
+
this.noteLinkFailure();
|
|
985
1116
|
for (const listener of [...this.syncStatusListeners])
|
|
986
1117
|
listener();
|
|
987
1118
|
}
|
|
988
|
-
/**
|
|
1119
|
+
/** The latest time the link failed, and how; it stays after the link recovers. */
|
|
1120
|
+
lastLinkFailure() {
|
|
1121
|
+
this.noteLinkFailure();
|
|
1122
|
+
return this.lastFailure;
|
|
1123
|
+
}
|
|
1124
|
+
/** Record a failure the first time the link is seen failing that way. */
|
|
1125
|
+
noteLinkFailure() {
|
|
1126
|
+
const link = this.upstreamLinkStatus();
|
|
1127
|
+
const failing = link.state === "offline" ? link.reason : null;
|
|
1128
|
+
if (failing === this.failingAs)
|
|
1129
|
+
return;
|
|
1130
|
+
this.failingAs = failing;
|
|
1131
|
+
const failure = linkFailureOf(link, this.lastLostMessage);
|
|
1132
|
+
if (failure)
|
|
1133
|
+
this.lastFailure = failure;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Every write made so far has been answered. Every write is global once
|
|
1137
|
+
* answered. With `inFlightStreams`, streaming writes still sending their
|
|
1138
|
+
* value finish first, and their writes count too, until that signal
|
|
1139
|
+
* aborts: then only the writes made so far count.
|
|
1140
|
+
*/
|
|
989
1141
|
async waitForPendingWrites(_tier, options = {}) {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1142
|
+
const answered = (async () => {
|
|
1143
|
+
// The drain after the local-first upgrade lets a stream finish rather
|
|
1144
|
+
// than closing the connection under it, until the app shuts down.
|
|
1145
|
+
const streams = options.inFlightStreams;
|
|
1146
|
+
if (streams && !streams.aborted && this.streamsInFlight.size > 0) {
|
|
1147
|
+
const ended = new Promise((resolve) => streams.addEventListener("abort", () => resolve(), { once: true }));
|
|
1148
|
+
while (!streams.aborted && this.streamsInFlight.size > 0)
|
|
1149
|
+
await Promise.race([Promise.all(this.streamsInFlight), ended]);
|
|
1150
|
+
}
|
|
1151
|
+
// Only writes still waiting for their answer, like a local-first client:
|
|
1152
|
+
// a rejection the app already had doesn't fail every later wait.
|
|
1153
|
+
const dones = [...this.writes.values()]
|
|
1154
|
+
.filter((write) => !write.answered)
|
|
1155
|
+
.map((write) => write.done);
|
|
1156
|
+
// Waiting for sync fails on the server's rejection. A write whose
|
|
1157
|
+
// connection ended unanswered is not rejected, and the shutdown drain
|
|
1158
|
+
// only waits for every write to be answered.
|
|
1159
|
+
const settled = options.throughOutage
|
|
1160
|
+
? Promise.all(dones.map((done) => done.catch((error) => {
|
|
1161
|
+
if (error instanceof ThinRemoteError)
|
|
1162
|
+
throw error;
|
|
1163
|
+
})))
|
|
1164
|
+
: Promise.allSettled(dones);
|
|
1165
|
+
if (options.throughOutage || dones.length === 0)
|
|
1166
|
+
return void (await settled);
|
|
1167
|
+
// The upgrade's drain (`inFlightStreams`) runs beside the app, which
|
|
1168
|
+
// may still renew a refused credential: it waits through a refusal
|
|
1169
|
+
// until the app shuts down (the signal aborts).
|
|
1170
|
+
if (streams && !streams.aborted) {
|
|
1171
|
+
const stopping = new Promise((resolve) => streams.addEventListener("abort", () => resolve(false), { once: true }));
|
|
1172
|
+
if (await Promise.race([settled.then(() => true), stopping]))
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
// A shutdown is final: no new credential comes for a runtime that is
|
|
1176
|
+
// stopping, so while the server refuses this client's sign-in (now or
|
|
1177
|
+
// once the shutdown started) nothing will answer those writes, and the
|
|
1178
|
+
// drain fails instead of waiting for good. (`waitForSync` waits
|
|
1179
|
+
// through a refusal, which the app may renew.)
|
|
1180
|
+
await this.unlessRefused(settled);
|
|
1181
|
+
})();
|
|
1004
1182
|
const signal = options.signal;
|
|
1005
1183
|
if (!signal) {
|
|
1006
1184
|
await answered;
|
|
@@ -1014,6 +1192,21 @@ export class ThinRuntime {
|
|
|
1014
1192
|
})),
|
|
1015
1193
|
]);
|
|
1016
1194
|
}
|
|
1195
|
+
/** `pending`, failing as soon as the server refuses this client's sign-in. */
|
|
1196
|
+
unlessRefused(pending) {
|
|
1197
|
+
const stop = new AbortController();
|
|
1198
|
+
const refused = new Promise((_, reject) => {
|
|
1199
|
+
const check = () => {
|
|
1200
|
+
if (!this.refused)
|
|
1201
|
+
return;
|
|
1202
|
+
stop.abort();
|
|
1203
|
+
reject(new ThinConnectionLostError(`the server refused this client's sign-in (${this.refusal?.message ?? "auth_failed"}), so its writes can't upload`, { cause: this.refusal }));
|
|
1204
|
+
};
|
|
1205
|
+
check();
|
|
1206
|
+
this.onSyncStatusChange(check, stop.signal);
|
|
1207
|
+
});
|
|
1208
|
+
return Promise.race([pending, refused]).finally(() => stop.abort());
|
|
1209
|
+
}
|
|
1017
1210
|
write(op, rows = []) {
|
|
1018
1211
|
const txId = `thin:${this.nextRequestId}`;
|
|
1019
1212
|
const write = {
|
|
@@ -1022,6 +1215,7 @@ export class ThinRuntime {
|
|
|
1022
1215
|
answered: false,
|
|
1023
1216
|
confirmed: false,
|
|
1024
1217
|
rows,
|
|
1218
|
+
madeAt: Date.now(),
|
|
1025
1219
|
done: Promise.resolve(),
|
|
1026
1220
|
};
|
|
1027
1221
|
// A standalone write goes under this runtime's next write id, so it can
|
|
@@ -1050,6 +1244,11 @@ export class ThinRuntime {
|
|
|
1050
1244
|
await read(rows).catch(() => undefined);
|
|
1051
1245
|
}, (error) => {
|
|
1052
1246
|
const failure = error instanceof Error ? error : new Error(String(error));
|
|
1247
|
+
// The sync status counts a rejection whether or not a wait takes it.
|
|
1248
|
+
if (failure instanceof ThinRemoteError) {
|
|
1249
|
+
this.rejected++;
|
|
1250
|
+
this.lastRejection = { code: failure.code, message: failure.message, at: Date.now() };
|
|
1251
|
+
}
|
|
1053
1252
|
// A failure no wait observes is reported once, like a local-first
|
|
1054
1253
|
// client's rejected write.
|
|
1055
1254
|
queueMicrotask(() => {
|
|
@@ -1144,6 +1343,21 @@ function viewOptions(context) {
|
|
|
1144
1343
|
updatedAtMs: context.updatedAtMs,
|
|
1145
1344
|
};
|
|
1146
1345
|
}
|
|
1346
|
+
/**
|
|
1347
|
+
* A writer node marked as bounding its resends to
|
|
1348
|
+
* {@link THIN_WRITE_RESEND_WINDOW_MS} (SPEC 8 §8.14): the tag `jzRB`, then
|
|
1349
|
+
* random bits, as an RFC 9562 version-8 UUID. The authority drops the
|
|
1350
|
+
* dedupe entries of only such a writer's writes; an unmarked node (an
|
|
1351
|
+
* earlier client's, which may resend any time) keeps them.
|
|
1352
|
+
*/
|
|
1353
|
+
/** @internal Exported for its contract test. */
|
|
1354
|
+
export function boundedWriterNode() {
|
|
1355
|
+
const bytes = runtimeRandomBytes(16);
|
|
1356
|
+
bytes.set([0x6a, 0x7a, 0x52, 0x42], 0);
|
|
1357
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x80;
|
|
1358
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
1359
|
+
return bytes;
|
|
1360
|
+
}
|
|
1147
1361
|
/** A UUIDv7: a millisecond timestamp, then random bits. */
|
|
1148
1362
|
function uuidv7() {
|
|
1149
1363
|
const bytes = runtimeRandomBytes(16);
|
|
@@ -1187,4 +1401,13 @@ function unknownOutcome(cause) {
|
|
|
1187
1401
|
? cause
|
|
1188
1402
|
: new ThinConnectionLostError(`the connection ended before the server answered: ${cause.message}`, { cause });
|
|
1189
1403
|
}
|
|
1404
|
+
function resendWindowPassed(oneShot) {
|
|
1405
|
+
return (oneShot.firstSentAt !== undefined &&
|
|
1406
|
+
Date.now() - oneShot.firstSentAt >= THIN_WRITE_RESEND_WINDOW_MS);
|
|
1407
|
+
}
|
|
1408
|
+
/** A write whose answer was lost, past its resend window: it may have
|
|
1409
|
+
* committed, so its fate is unknown. */
|
|
1410
|
+
function resendWindowEnded(cause) {
|
|
1411
|
+
return new ThinConnectionLostError(`the connection ended before the server answered, and the write was first sent more than ${THIN_WRITE_RESEND_WINDOW_MS / 60_000} minutes ago, so it is not sent again: it may or may not have been made`, cause ? { cause } : undefined);
|
|
1412
|
+
}
|
|
1190
1413
|
//# sourceMappingURL=thin-runtime.js.map
|