@syncular/server 0.0.6-95 → 0.1.0
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 -2
- package/dist/auth-leases.d.ts +85 -0
- package/dist/auth-leases.d.ts.map +1 -0
- package/dist/auth-leases.js +368 -0
- package/dist/auth-leases.js.map +1 -0
- package/dist/better-sqlite3.d.ts +22 -0
- package/dist/better-sqlite3.d.ts.map +1 -0
- package/dist/better-sqlite3.js +16 -0
- package/dist/better-sqlite3.js.map +1 -0
- package/dist/blobs/access.d.ts +35 -0
- package/dist/blobs/access.d.ts.map +1 -0
- package/dist/blobs/access.js +149 -0
- package/dist/blobs/access.js.map +1 -0
- package/dist/blobs/adapters/database.d.ts +26 -9
- package/dist/blobs/adapters/database.d.ts.map +1 -1
- package/dist/blobs/adapters/database.js +68 -23
- package/dist/blobs/adapters/database.js.map +1 -1
- package/dist/blobs/index.d.ts +1 -0
- package/dist/blobs/index.d.ts.map +1 -1
- package/dist/blobs/index.js +5 -4
- package/dist/blobs/index.js.map +1 -1
- package/dist/blobs/manager.d.ts +69 -44
- package/dist/blobs/manager.d.ts.map +1 -1
- package/dist/blobs/manager.js +250 -65
- package/dist/blobs/manager.js.map +1 -1
- package/dist/blobs/migrate.d.ts.map +1 -1
- package/dist/blobs/migrate.js +16 -8
- package/dist/blobs/migrate.js.map +1 -1
- package/dist/blobs/types.d.ts +4 -0
- package/dist/blobs/types.d.ts.map +1 -1
- package/dist/bun-sqlite.d.ts +19 -0
- package/dist/bun-sqlite.d.ts.map +1 -0
- package/dist/bun-sqlite.js +19 -0
- package/dist/bun-sqlite.js.map +1 -0
- package/dist/clients.d.ts +1 -0
- package/dist/clients.d.ts.map +1 -1
- package/dist/clients.js.map +1 -1
- package/dist/cloudflare/durable-object.d.ts +93 -0
- package/dist/cloudflare/durable-object.d.ts.map +1 -0
- package/dist/cloudflare/durable-object.js +210 -0
- package/dist/cloudflare/durable-object.js.map +1 -0
- package/dist/cloudflare/index.d.ts +22 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +22 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/r2.d.ts +180 -0
- package/dist/cloudflare/r2.d.ts.map +1 -0
- package/dist/cloudflare/r2.js +258 -0
- package/dist/cloudflare/r2.js.map +1 -0
- package/dist/cloudflare/scope-cache.d.ts +54 -0
- package/dist/cloudflare/scope-cache.d.ts.map +1 -0
- package/dist/cloudflare/scope-cache.js +223 -0
- package/dist/cloudflare/scope-cache.js.map +1 -0
- package/dist/cloudflare/sentry.d.ts +47 -0
- package/dist/cloudflare/sentry.d.ts.map +1 -0
- package/dist/cloudflare/sentry.js +163 -0
- package/dist/cloudflare/sentry.js.map +1 -0
- package/dist/cloudflare/worker.d.ts +46 -0
- package/dist/cloudflare/worker.d.ts.map +1 -0
- package/dist/cloudflare/worker.js +63 -0
- package/dist/cloudflare/worker.js.map +1 -0
- package/dist/commit-integrity.d.ts +38 -0
- package/dist/commit-integrity.d.ts.map +1 -0
- package/dist/commit-integrity.js +260 -0
- package/dist/commit-integrity.js.map +1 -0
- package/dist/compaction.js.map +1 -1
- package/dist/crdt-yjs/index.d.ts +99 -0
- package/dist/crdt-yjs/index.d.ts.map +1 -0
- package/dist/crdt-yjs/index.js +629 -0
- package/dist/crdt-yjs/index.js.map +1 -0
- package/dist/d1.d.ts +13 -0
- package/dist/d1.d.ts.map +1 -0
- package/dist/d1.js +14 -0
- package/dist/d1.js.map +1 -0
- package/dist/dialect/base.d.ts +11 -1
- package/dist/dialect/base.d.ts.map +1 -1
- package/dist/dialect/base.js +43 -6
- package/dist/dialect/base.js.map +1 -1
- package/dist/dialect/helpers.d.ts +6 -0
- package/dist/dialect/helpers.d.ts.map +1 -1
- package/dist/dialect/helpers.js +24 -0
- package/dist/dialect/helpers.js.map +1 -1
- package/dist/dialect/index.js +3 -3
- package/dist/dialect/types.d.ts +40 -0
- package/dist/dialect/types.d.ts.map +1 -1
- package/dist/encrypted-crdt.d.ts +67 -0
- package/dist/encrypted-crdt.d.ts.map +1 -0
- package/dist/encrypted-crdt.js +426 -0
- package/dist/encrypted-crdt.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/filesystem/index.d.ts +44 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/dist/filesystem/index.js +164 -0
- package/dist/filesystem/index.js.map +1 -0
- package/dist/handlers/collection.d.ts +11 -3
- package/dist/handlers/collection.d.ts.map +1 -1
- package/dist/handlers/collection.js +34 -56
- package/dist/handlers/collection.js.map +1 -1
- package/dist/handlers/create-handler.d.ts +31 -7
- package/dist/handlers/create-handler.d.ts.map +1 -1
- package/dist/handlers/create-handler.js +332 -115
- package/dist/handlers/create-handler.js.map +1 -1
- package/dist/handlers/index.js +3 -3
- package/dist/handlers/types.d.ts +86 -1
- package/dist/handlers/types.d.ts.map +1 -1
- package/dist/helpers/conflict.js.map +1 -1
- package/dist/helpers/emitted-change.js.map +1 -1
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +6 -4
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/paginate.js.map +1 -1
- package/dist/helpers/scope-authorization.d.ts +7 -0
- package/dist/helpers/scope-authorization.d.ts.map +1 -0
- package/dist/helpers/scope-authorization.js +19 -0
- package/dist/helpers/scope-authorization.js.map +1 -0
- package/dist/helpers/scope-commit-index.d.ts +12 -0
- package/dist/helpers/scope-commit-index.d.ts.map +1 -0
- package/dist/helpers/scope-commit-index.js +35 -0
- package/dist/helpers/scope-commit-index.js.map +1 -0
- package/dist/helpers/scope-strings.js.map +1 -1
- package/dist/hono/api-key-auth.d.ts +49 -0
- package/dist/hono/api-key-auth.d.ts.map +1 -0
- package/dist/hono/api-key-auth.js +108 -0
- package/dist/hono/api-key-auth.js.map +1 -0
- package/dist/hono/audit-redaction.d.ts +20 -0
- package/dist/hono/audit-redaction.d.ts.map +1 -0
- package/dist/hono/audit-redaction.js +85 -0
- package/dist/hono/audit-redaction.js.map +1 -0
- package/dist/hono/blobs.d.ts +75 -0
- package/dist/hono/blobs.d.ts.map +1 -0
- package/dist/hono/blobs.js +586 -0
- package/dist/hono/blobs.js.map +1 -0
- package/dist/hono/console/gateway.d.ts +42 -0
- package/dist/hono/console/gateway.d.ts.map +1 -0
- package/dist/hono/console/gateway.js +2158 -0
- package/dist/hono/console/gateway.js.map +1 -0
- package/dist/hono/console/live-auth.d.ts +7 -0
- package/dist/hono/console/live-auth.d.ts.map +1 -0
- package/dist/hono/console/live-auth.js +39 -0
- package/dist/hono/console/live-auth.js.map +1 -0
- package/dist/hono/console/route-descriptor.d.ts +6 -0
- package/dist/hono/console/route-descriptor.d.ts.map +1 -0
- package/dist/hono/console/route-descriptor.js +16 -0
- package/dist/hono/console/route-descriptor.js.map +1 -0
- package/dist/hono/console/routes/api-keys.d.ts +8 -0
- package/dist/hono/console/routes/api-keys.d.ts.map +1 -0
- package/dist/hono/console/routes/api-keys.js +575 -0
- package/dist/hono/console/routes/api-keys.js.map +1 -0
- package/dist/hono/console/routes/clients.d.ts +8 -0
- package/dist/hono/console/routes/clients.d.ts.map +1 -0
- package/dist/hono/console/routes/clients.js +322 -0
- package/dist/hono/console/routes/clients.js.map +1 -0
- package/dist/hono/console/routes/commits.d.ts +8 -0
- package/dist/hono/console/routes/commits.d.ts.map +1 -0
- package/dist/hono/console/routes/commits.js +882 -0
- package/dist/hono/console/routes/commits.js.map +1 -0
- package/dist/hono/console/routes/context.d.ts +188 -0
- package/dist/hono/console/routes/context.d.ts.map +1 -0
- package/dist/hono/console/routes/context.js +633 -0
- package/dist/hono/console/routes/context.js.map +1 -0
- package/dist/hono/console/routes/events.d.ts +8 -0
- package/dist/hono/console/routes/events.d.ts.map +1 -0
- package/dist/hono/console/routes/events.js +501 -0
- package/dist/hono/console/routes/events.js.map +1 -0
- package/dist/hono/console/routes/maintenance.d.ts +8 -0
- package/dist/hono/console/routes/maintenance.d.ts.map +1 -0
- package/dist/hono/console/routes/maintenance.js +341 -0
- package/dist/hono/console/routes/maintenance.js.map +1 -0
- package/dist/hono/console/routes/shared.d.ts +174 -0
- package/dist/hono/console/routes/shared.d.ts.map +1 -0
- package/dist/hono/console/routes/shared.js +583 -0
- package/dist/hono/console/routes/shared.js.map +1 -0
- package/dist/hono/console/routes/stats.d.ts +8 -0
- package/dist/hono/console/routes/stats.d.ts.map +1 -0
- package/dist/hono/console/routes/stats.js +295 -0
- package/dist/hono/console/routes/stats.js.map +1 -0
- package/dist/hono/console/routes/storage.d.ts +8 -0
- package/dist/hono/console/routes/storage.d.ts.map +1 -0
- package/dist/hono/console/routes/storage.js +121 -0
- package/dist/hono/console/routes/storage.js.map +1 -0
- package/dist/hono/console/routes.d.ts +36 -0
- package/dist/hono/console/routes.d.ts.map +1 -0
- package/dist/hono/console/routes.js +112 -0
- package/dist/hono/console/routes.js.map +1 -0
- package/dist/hono/console/schema-errors.d.ts +2 -0
- package/dist/hono/console/schema-errors.d.ts.map +1 -0
- package/dist/hono/console/schema-errors.js +17 -0
- package/dist/hono/console/schema-errors.js.map +1 -0
- package/dist/hono/console/schemas.d.ts +1515 -0
- package/dist/hono/console/schemas.d.ts.map +1 -0
- package/dist/hono/console/schemas.js +661 -0
- package/dist/hono/console/schemas.js.map +1 -0
- package/dist/hono/console/types.d.ts +213 -0
- package/dist/hono/console/types.d.ts.map +1 -0
- package/dist/hono/console/types.js +2 -0
- package/dist/hono/console/types.js.map +1 -0
- package/dist/hono/console/ui.d.ts +38 -0
- package/dist/hono/console/ui.d.ts.map +1 -0
- package/dist/hono/console/ui.js +43 -0
- package/dist/hono/console/ui.js.map +1 -0
- package/dist/hono/create-server.d.ts +71 -0
- package/dist/hono/create-server.d.ts.map +1 -0
- package/dist/hono/create-server.js +121 -0
- package/dist/hono/create-server.js.map +1 -0
- package/dist/hono/errors.d.ts +13 -0
- package/dist/hono/errors.d.ts.map +1 -0
- package/dist/hono/errors.js +21 -0
- package/dist/hono/errors.js.map +1 -0
- package/dist/hono/index.d.ts +20 -0
- package/dist/hono/index.d.ts.map +1 -0
- package/dist/hono/index.js +31 -0
- package/dist/hono/index.js.map +1 -0
- package/dist/hono/openapi.d.ts +72 -0
- package/dist/hono/openapi.d.ts.map +1 -0
- package/dist/hono/openapi.js +99 -0
- package/dist/hono/openapi.js.map +1 -0
- package/dist/hono/proxy/connection-manager.d.ts +78 -0
- package/dist/hono/proxy/connection-manager.d.ts.map +1 -0
- package/dist/hono/proxy/connection-manager.js +251 -0
- package/dist/hono/proxy/connection-manager.js.map +1 -0
- package/dist/hono/proxy/index.d.ts +8 -0
- package/dist/hono/proxy/index.d.ts.map +1 -0
- package/dist/hono/proxy/index.js +8 -0
- package/dist/hono/proxy/index.js.map +1 -0
- package/dist/hono/proxy/routes.d.ts +86 -0
- package/dist/hono/proxy/routes.d.ts.map +1 -0
- package/dist/hono/proxy/routes.js +183 -0
- package/dist/hono/proxy/routes.js.map +1 -0
- package/dist/hono/rate-limit.d.ts +101 -0
- package/dist/hono/rate-limit.d.ts.map +1 -0
- package/dist/hono/rate-limit.js +184 -0
- package/dist/hono/rate-limit.js.map +1 -0
- package/dist/hono/realtime-sync-packs.d.ts +43 -0
- package/dist/hono/realtime-sync-packs.d.ts.map +1 -0
- package/dist/hono/realtime-sync-packs.js +219 -0
- package/dist/hono/realtime-sync-packs.js.map +1 -0
- package/dist/hono/routes/audit.d.ts +12 -0
- package/dist/hono/routes/audit.d.ts.map +1 -0
- package/dist/hono/routes/audit.js +385 -0
- package/dist/hono/routes/audit.js.map +1 -0
- package/dist/hono/routes/auth-leases.d.ts +8 -0
- package/dist/hono/routes/auth-leases.d.ts.map +1 -0
- package/dist/hono/routes/auth-leases.js +88 -0
- package/dist/hono/routes/auth-leases.js.map +1 -0
- package/dist/hono/routes/combined.d.ts +8 -0
- package/dist/hono/routes/combined.d.ts.map +1 -0
- package/dist/hono/routes/combined.js +392 -0
- package/dist/hono/routes/combined.js.map +1 -0
- package/dist/hono/routes/context.d.ts +314 -0
- package/dist/hono/routes/context.d.ts.map +1 -0
- package/dist/hono/routes/context.js +1147 -0
- package/dist/hono/routes/context.js.map +1 -0
- package/dist/hono/routes/health.d.ts +8 -0
- package/dist/hono/routes/health.d.ts.map +1 -0
- package/dist/hono/routes/health.js +16 -0
- package/dist/hono/routes/health.js.map +1 -0
- package/dist/hono/routes/realtime.d.ts +9 -0
- package/dist/hono/routes/realtime.d.ts.map +1 -0
- package/dist/hono/routes/realtime.js +626 -0
- package/dist/hono/routes/realtime.js.map +1 -0
- package/dist/hono/routes/shared.d.ts +689 -0
- package/dist/hono/routes/shared.d.ts.map +1 -0
- package/dist/hono/routes/shared.js +972 -0
- package/dist/hono/routes/shared.js.map +1 -0
- package/dist/hono/routes/snapshots.d.ts +10 -0
- package/dist/hono/routes/snapshots.d.ts.map +1 -0
- package/dist/hono/routes/snapshots.js +281 -0
- package/dist/hono/routes/snapshots.js.map +1 -0
- package/dist/hono/routes.d.ts +19 -0
- package/dist/hono/routes.d.ts.map +1 -0
- package/dist/hono/routes.js +37 -0
- package/dist/hono/routes.js.map +1 -0
- package/dist/hono/validation.d.ts +5 -0
- package/dist/hono/validation.d.ts.map +1 -0
- package/dist/hono/validation.js +47 -0
- package/dist/hono/validation.js.map +1 -0
- package/dist/hono/websocket-origin.d.ts +9 -0
- package/dist/hono/websocket-origin.d.ts.map +1 -0
- package/dist/hono/websocket-origin.js +96 -0
- package/dist/hono/websocket-origin.js.map +1 -0
- package/dist/hono/ws.d.ts +341 -0
- package/dist/hono/ws.d.ts.map +1 -0
- package/dist/hono/ws.js +711 -0
- package/dist/hono/ws.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/dist/libsql.d.ts +29 -0
- package/dist/libsql.d.ts.map +1 -0
- package/dist/libsql.js +25 -0
- package/dist/libsql.js.map +1 -0
- package/dist/migrate.js.map +1 -1
- package/dist/neon.d.ts +21 -0
- package/dist/neon.d.ts.map +1 -0
- package/dist/neon.js +22 -0
- package/dist/neon.js.map +1 -0
- package/dist/notify.d.ts +30 -0
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +160 -41
- package/dist/notify.js.map +1 -1
- package/dist/pglite.d.ts +37 -0
- package/dist/pglite.d.ts.map +1 -0
- package/dist/pglite.js +37 -0
- package/dist/pglite.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +73 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +30 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/postgres/index.d.ts +68 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +924 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/proxy/collection.d.ts +0 -2
- package/dist/proxy/collection.d.ts.map +1 -1
- package/dist/proxy/collection.js +2 -17
- package/dist/proxy/collection.js.map +1 -1
- package/dist/proxy/handler.d.ts +1 -1
- package/dist/proxy/handler.d.ts.map +1 -1
- package/dist/proxy/handler.js +3 -4
- package/dist/proxy/handler.js.map +1 -1
- package/dist/proxy/index.d.ts +1 -1
- package/dist/proxy/index.d.ts.map +1 -1
- package/dist/proxy/index.js +3 -3
- package/dist/proxy/index.js.map +1 -1
- package/dist/proxy/mutation-detector.js.map +1 -1
- package/dist/proxy/oplog.d.ts.map +1 -1
- package/dist/proxy/oplog.js +32 -8
- package/dist/proxy/oplog.js.map +1 -1
- package/dist/prune.d.ts +8 -1
- package/dist/prune.d.ts.map +1 -1
- package/dist/prune.js +68 -28
- package/dist/prune.js.map +1 -1
- package/dist/pull.d.ts +31 -0
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +1014 -474
- package/dist/pull.js.map +1 -1
- package/dist/push.d.ts +36 -2
- package/dist/push.d.ts.map +1 -1
- package/dist/push.js +603 -358
- package/dist/push.js.map +1 -1
- package/dist/realtime/in-memory.js.map +1 -1
- package/dist/realtime/index.d.ts +2 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +2 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime/types.d.ts +12 -0
- package/dist/realtime/types.d.ts.map +1 -1
- package/dist/realtime/types.js +13 -1
- package/dist/realtime/types.js.map +1 -1
- package/dist/relay/client-role/forward-engine.d.ts +63 -0
- package/dist/relay/client-role/forward-engine.d.ts.map +1 -0
- package/dist/relay/client-role/forward-engine.js +267 -0
- package/dist/relay/client-role/forward-engine.js.map +1 -0
- package/dist/relay/client-role/index.d.ts +9 -0
- package/dist/relay/client-role/index.d.ts.map +1 -0
- package/dist/relay/client-role/index.js +9 -0
- package/dist/relay/client-role/index.js.map +1 -0
- package/dist/relay/client-role/pull-engine.d.ts +72 -0
- package/dist/relay/client-role/pull-engine.d.ts.map +1 -0
- package/dist/relay/client-role/pull-engine.js +249 -0
- package/dist/relay/client-role/pull-engine.js.map +1 -0
- package/dist/relay/client-role/sequence-mapper.d.ts +65 -0
- package/dist/relay/client-role/sequence-mapper.d.ts.map +1 -0
- package/dist/relay/client-role/sequence-mapper.js +161 -0
- package/dist/relay/client-role/sequence-mapper.js.map +1 -0
- package/dist/relay/evaluation/relay-paths.d.ts +41 -0
- package/dist/relay/evaluation/relay-paths.d.ts.map +1 -0
- package/dist/relay/evaluation/relay-paths.js +504 -0
- package/dist/relay/evaluation/relay-paths.js.map +1 -0
- package/dist/relay/evaluation/rust-boundary.d.ts +47 -0
- package/dist/relay/evaluation/rust-boundary.d.ts.map +1 -0
- package/dist/relay/evaluation/rust-boundary.js +220 -0
- package/dist/relay/evaluation/rust-boundary.js.map +1 -0
- package/dist/relay/index.d.ts +37 -0
- package/dist/relay/index.d.ts.map +1 -0
- package/dist/relay/index.js +44 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/migrate.d.ts +18 -0
- package/dist/relay/migrate.d.ts.map +1 -0
- package/dist/relay/migrate.js +99 -0
- package/dist/relay/migrate.js.map +1 -0
- package/dist/relay/mode-manager.d.ts +60 -0
- package/dist/relay/mode-manager.d.ts.map +1 -0
- package/dist/relay/mode-manager.js +114 -0
- package/dist/relay/mode-manager.js.map +1 -0
- package/dist/relay/realtime.d.ts +90 -0
- package/dist/relay/realtime.d.ts.map +1 -0
- package/dist/relay/realtime.js +147 -0
- package/dist/relay/realtime.js.map +1 -0
- package/dist/relay/relay.d.ts +190 -0
- package/dist/relay/relay.d.ts.map +1 -0
- package/dist/relay/relay.js +320 -0
- package/dist/relay/relay.js.map +1 -0
- package/dist/relay/schema.d.ts +158 -0
- package/dist/relay/schema.d.ts.map +1 -0
- package/dist/relay/schema.js +7 -0
- package/dist/relay/schema.js.map +1 -0
- package/dist/relay/server-role/index.d.ts +56 -0
- package/dist/relay/server-role/index.d.ts.map +1 -0
- package/dist/relay/server-role/index.js +193 -0
- package/dist/relay/server-role/index.js.map +1 -0
- package/dist/relay/server-role/pull.d.ts +27 -0
- package/dist/relay/server-role/pull.d.ts.map +1 -0
- package/dist/relay/server-role/pull.js +24 -0
- package/dist/relay/server-role/pull.js.map +1 -0
- package/dist/relay/server-role/push.d.ts +29 -0
- package/dist/relay/server-role/push.d.ts.map +1 -0
- package/dist/relay/server-role/push.js +122 -0
- package/dist/relay/server-role/push.js.map +1 -0
- package/dist/s3/index.d.ts +83 -0
- package/dist/s3/index.d.ts.map +1 -0
- package/dist/s3/index.js +223 -0
- package/dist/s3/index.js.map +1 -0
- package/dist/schema.d.ts +137 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/schema.js.map +1 -1
- package/dist/service-worker/index.d.ts +114 -0
- package/dist/service-worker/index.d.ts.map +1 -0
- package/dist/service-worker/index.js +487 -0
- package/dist/service-worker/index.js.map +1 -0
- package/dist/snapshot-artifacts/sqlite-bun.d.ts +15 -0
- package/dist/snapshot-artifacts/sqlite-bun.d.ts.map +1 -0
- package/dist/snapshot-artifacts/sqlite-bun.js +128 -0
- package/dist/snapshot-artifacts/sqlite-bun.js.map +1 -0
- package/dist/snapshot-artifacts.d.ts +206 -0
- package/dist/snapshot-artifacts.d.ts.map +1 -0
- package/dist/snapshot-artifacts.js +545 -0
- package/dist/snapshot-artifacts.js.map +1 -0
- package/dist/snapshot-chunks/db-metadata.d.ts +18 -0
- package/dist/snapshot-chunks/db-metadata.d.ts.map +1 -1
- package/dist/snapshot-chunks/db-metadata.js +91 -63
- package/dist/snapshot-chunks/db-metadata.js.map +1 -1
- package/dist/snapshot-chunks/index.js +2 -2
- package/dist/snapshot-chunks/types.d.ts +2 -0
- package/dist/snapshot-chunks/types.d.ts.map +1 -1
- package/dist/snapshot-chunks.d.ts +33 -3
- package/dist/snapshot-chunks.d.ts.map +1 -1
- package/dist/snapshot-chunks.js +136 -55
- package/dist/snapshot-chunks.js.map +1 -1
- package/dist/sqlite/index.d.ts +53 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +795 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite3.d.ts +22 -0
- package/dist/sqlite3.d.ts.map +1 -0
- package/dist/sqlite3.js +99 -0
- package/dist/sqlite3.js.map +1 -0
- package/dist/stats.d.ts +8 -0
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +45 -13
- package/dist/stats.js.map +1 -1
- package/dist/subscriptions/cache.d.ts +3 -0
- package/dist/subscriptions/cache.d.ts.map +1 -1
- package/dist/subscriptions/cache.js +44 -0
- package/dist/subscriptions/cache.js.map +1 -1
- package/dist/subscriptions/index.js +2 -2
- package/dist/subscriptions/resolve.d.ts +3 -1
- package/dist/subscriptions/resolve.d.ts.map +1 -1
- package/dist/subscriptions/resolve.js +91 -52
- package/dist/subscriptions/resolve.js.map +1 -1
- package/dist/sync.d.ts +3 -0
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +9 -5
- package/dist/sync.js.map +1 -1
- package/package.json +297 -8
- package/src/auth-leases.ts +649 -0
- package/src/better-sqlite3.ts +35 -0
- package/src/blobs/access.ts +244 -0
- package/src/blobs/adapters/database.ts +125 -43
- package/src/blobs/index.ts +1 -0
- package/src/blobs/manager.ts +366 -65
- package/src/blobs/migrate.ts +16 -8
- package/src/blobs/types.ts +4 -0
- package/src/bun-sqlite-ambient.d.ts +19 -0
- package/src/bun-sqlite.ts +27 -0
- package/src/clients.ts +1 -0
- package/src/cloudflare/durable-object.ts +289 -0
- package/src/cloudflare/index.ts +22 -0
- package/src/cloudflare/r2.ts +526 -0
- package/src/cloudflare/scope-cache.ts +341 -0
- package/src/cloudflare/sentry.ts +230 -0
- package/src/cloudflare/worker.ts +77 -0
- package/src/commit-integrity.ts +371 -0
- package/src/crdt-yjs/index.ts +931 -0
- package/src/d1.ts +16 -0
- package/src/dialect/base.ts +71 -5
- package/src/dialect/helpers.ts +31 -0
- package/src/dialect/types.ts +47 -0
- package/src/encrypted-crdt.ts +786 -0
- package/src/errors.ts +22 -0
- package/src/filesystem/index.ts +262 -0
- package/src/handlers/collection.ts +78 -78
- package/src/handlers/create-handler.ts +540 -147
- package/src/handlers/types.ts +116 -0
- package/src/helpers/index.ts +2 -0
- package/src/helpers/scope-authorization.ts +27 -0
- package/src/helpers/scope-commit-index.ts +52 -0
- package/src/hono/api-key-auth.ts +177 -0
- package/src/hono/audit-redaction.ts +135 -0
- package/src/hono/blobs.ts +851 -0
- package/src/hono/console/gateway.ts +3046 -0
- package/src/hono/console/live-auth.ts +46 -0
- package/src/hono/console/route-descriptor.ts +22 -0
- package/src/hono/console/routes/api-keys.ts +721 -0
- package/src/hono/console/routes/clients.ts +447 -0
- package/src/hono/console/routes/commits.ts +1137 -0
- package/src/hono/console/routes/context.ts +956 -0
- package/src/hono/console/routes/events.ts +669 -0
- package/src/hono/console/routes/maintenance.ts +461 -0
- package/src/hono/console/routes/shared.ts +816 -0
- package/src/hono/console/routes/stats.ts +392 -0
- package/src/hono/console/routes/storage.ts +159 -0
- package/src/hono/console/routes.ts +146 -0
- package/src/hono/console/schema-errors.ts +23 -0
- package/src/hono/console/schemas.ts +914 -0
- package/src/hono/console/types.ts +223 -0
- package/src/hono/console/ui.ts +100 -0
- package/src/hono/create-server.ts +230 -0
- package/src/hono/errors.ts +50 -0
- package/src/hono/index.ts +54 -0
- package/src/hono/openapi.ts +139 -0
- package/src/hono/proxy/connection-manager.ts +340 -0
- package/src/hono/proxy/index.ts +8 -0
- package/src/hono/proxy/routes.ts +272 -0
- package/src/hono/rate-limit.ts +319 -0
- package/src/hono/realtime-sync-packs.ts +354 -0
- package/src/hono/routes/audit.ts +499 -0
- package/src/hono/routes/auth-leases.ts +119 -0
- package/src/hono/routes/combined.ts +583 -0
- package/src/hono/routes/context.ts +1629 -0
- package/src/hono/routes/health.ts +26 -0
- package/src/hono/routes/realtime.ts +808 -0
- package/src/hono/routes/shared.ts +1626 -0
- package/src/hono/routes/snapshots.ts +345 -0
- package/src/hono/routes.ts +68 -0
- package/src/hono/validation.ts +81 -0
- package/src/hono/websocket-origin.ts +131 -0
- package/src/hono/ws.ts +1134 -0
- package/src/index.ts +6 -0
- package/src/libsql.ts +51 -0
- package/src/neon.ts +28 -0
- package/src/notify.ts +224 -44
- package/src/pglite.ts +68 -0
- package/src/plugins/index.ts +1 -0
- package/src/plugins/types.ts +144 -0
- package/src/postgres/index.ts +1291 -0
- package/src/proxy/collection.ts +5 -27
- package/src/proxy/handler.ts +2 -2
- package/src/proxy/index.ts +0 -2
- package/src/proxy/oplog.ts +41 -10
- package/src/prune.ts +137 -36
- package/src/pull.ts +1504 -591
- package/src/push.ts +881 -443
- package/src/realtime/index.ts +2 -0
- package/src/realtime/types.ts +35 -0
- package/src/relay/bun-types.d.ts +50 -0
- package/src/relay/client-role/forward-engine.ts +355 -0
- package/src/relay/client-role/index.ts +9 -0
- package/src/relay/client-role/pull-engine.ts +329 -0
- package/src/relay/client-role/sequence-mapper.ts +201 -0
- package/src/relay/evaluation/relay-paths.ts +699 -0
- package/src/relay/evaluation/rust-boundary.ts +464 -0
- package/src/relay/index.ts +50 -0
- package/src/relay/migrate.ts +113 -0
- package/src/relay/mode-manager.ts +142 -0
- package/src/relay/realtime.ts +207 -0
- package/src/relay/relay.ts +431 -0
- package/src/relay/schema.ts +171 -0
- package/src/relay/server-role/index.ts +338 -0
- package/src/relay/server-role/pull.ts +43 -0
- package/src/relay/server-role/push.ts +164 -0
- package/src/s3/index.ts +346 -0
- package/src/schema.ts +141 -1
- package/src/service-worker/index.ts +773 -0
- package/src/snapshot-artifacts/sqlite-bun.ts +168 -0
- package/src/snapshot-artifacts.ts +896 -0
- package/src/snapshot-chunks/db-metadata.ts +131 -72
- package/src/snapshot-chunks/types.ts +2 -0
- package/src/snapshot-chunks.ts +194 -70
- package/src/sqlite/index.ts +1064 -0
- package/src/sqlite3.ts +137 -0
- package/src/stats.ts +76 -13
- package/src/subscriptions/cache.ts +58 -0
- package/src/subscriptions/resolve.ts +99 -58
- package/src/sync.ts +16 -6
- package/src/blobs/adapters/database.test.ts +0 -67
- package/src/notify.test.ts +0 -520
- package/src/proxy/handler.test.ts +0 -126
- package/src/proxy/mutation-detector.test.ts +0 -71
- package/src/snapshot-chunks/db-metadata.test.ts +0 -172
- package/src/subscriptions/resolve.test.ts +0 -180
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /realtime (optional WebSocket deltas and recovery wake-ups), including
|
|
3
|
+
* the websocket push pipeline (ws-push) helpers.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
captureSyncException,
|
|
8
|
+
countSyncMetric,
|
|
9
|
+
createSyncTimer,
|
|
10
|
+
distributionSyncMetric,
|
|
11
|
+
logSyncEvent,
|
|
12
|
+
SYNC_PACK_ENCODING_BINARY_V1,
|
|
13
|
+
SyncPushRequestSchema,
|
|
14
|
+
} from '@syncular/core';
|
|
15
|
+
import type { SqlFamily, SyncCoreDb } from '@syncular/server';
|
|
16
|
+
import { createSyncRealtimeShardKey } from '@syncular/server';
|
|
17
|
+
import { syncError } from '../errors';
|
|
18
|
+
import { isWebSocketOriginAllowed } from '../websocket-origin';
|
|
19
|
+
import {
|
|
20
|
+
createRealtimeSessionId,
|
|
21
|
+
createWebSocketConnection,
|
|
22
|
+
createWebSocketConnectionOwnerKey,
|
|
23
|
+
type WebSocketConnection,
|
|
24
|
+
type WebSocketRealtimeSubscription,
|
|
25
|
+
} from '../ws';
|
|
26
|
+
import type { SyncRoutesContext } from './context';
|
|
27
|
+
import {
|
|
28
|
+
applyPartitionToScopeKeys,
|
|
29
|
+
createSyncCorsOriginDeniedResponse,
|
|
30
|
+
emitConsoleLiveEvent,
|
|
31
|
+
measureWebSocketMessageBytes,
|
|
32
|
+
normalizeResponseStatus,
|
|
33
|
+
normalizeScopeKeyForPartition,
|
|
34
|
+
parsePersistedRealtimeSubscriptions,
|
|
35
|
+
type RequestPayloadSnapshot,
|
|
36
|
+
readClientState,
|
|
37
|
+
readOriginHeader,
|
|
38
|
+
readTraceContextFromMessage,
|
|
39
|
+
readTransportPath,
|
|
40
|
+
recordRealtimeAck,
|
|
41
|
+
type SyncAuthResult,
|
|
42
|
+
scopeValuesToScopeKeys,
|
|
43
|
+
type TraceContext,
|
|
44
|
+
uniqueScopeKeys,
|
|
45
|
+
} from './shared';
|
|
46
|
+
|
|
47
|
+
export function registerRealtimeRoutes<
|
|
48
|
+
DB extends SyncCoreDb = SyncCoreDb,
|
|
49
|
+
Auth extends SyncAuthResult = SyncAuthResult,
|
|
50
|
+
F extends SqlFamily = SqlFamily,
|
|
51
|
+
>(ctx: SyncRoutesContext<DB, Auth, F>): void {
|
|
52
|
+
const {
|
|
53
|
+
routes,
|
|
54
|
+
getAuth,
|
|
55
|
+
options,
|
|
56
|
+
websocketConfig,
|
|
57
|
+
corsConfig,
|
|
58
|
+
wsConnectionManager,
|
|
59
|
+
consoleLiveEmitter,
|
|
60
|
+
recordRealtimeEventInBackground,
|
|
61
|
+
recordRequestEventInBackground,
|
|
62
|
+
serializeRealtimeSubscriptions,
|
|
63
|
+
logAsyncFailureOnce,
|
|
64
|
+
maxOperationsPerPush,
|
|
65
|
+
executePushCommitWithSideEffects,
|
|
66
|
+
triggerAutoMaintenance,
|
|
67
|
+
shouldCaptureRequestPayloadSnapshots,
|
|
68
|
+
} = ctx;
|
|
69
|
+
|
|
70
|
+
// -------------------------------------------------------------------------
|
|
71
|
+
// GET /realtime (optional WebSocket deltas and recovery wake-ups)
|
|
72
|
+
// -------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
if (wsConnectionManager && websocketConfig?.enabled) {
|
|
75
|
+
routes.get('/realtime', async (c) => {
|
|
76
|
+
const auth = await getAuth(c);
|
|
77
|
+
if (!auth) return syncError(c, 401, 'sync.auth_required');
|
|
78
|
+
if (!isWebSocketOriginAllowed(c, websocketConfig.allowedOrigins)) {
|
|
79
|
+
const origin = readOriginHeader(c);
|
|
80
|
+
if (origin && corsConfig) {
|
|
81
|
+
return createSyncCorsOriginDeniedResponse(origin);
|
|
82
|
+
}
|
|
83
|
+
return syncError(
|
|
84
|
+
c,
|
|
85
|
+
403,
|
|
86
|
+
'sync.forbidden',
|
|
87
|
+
'Forbidden websocket origin'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
const partitionId = auth.partitionId ?? 'default';
|
|
91
|
+
|
|
92
|
+
const clientId = c.req.query('clientId');
|
|
93
|
+
if (!clientId || typeof clientId !== 'string') {
|
|
94
|
+
return syncError(
|
|
95
|
+
c,
|
|
96
|
+
400,
|
|
97
|
+
'sync.invalid_request',
|
|
98
|
+
'clientId query param is required'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const realtimeTransportPath = readTransportPath(
|
|
102
|
+
c,
|
|
103
|
+
c.req.query('transportPath')
|
|
104
|
+
);
|
|
105
|
+
const syncPackEncoding =
|
|
106
|
+
c.req.query('syncPackEncoding') === SYNC_PACK_ENCODING_BINARY_V1
|
|
107
|
+
? SYNC_PACK_ENCODING_BINARY_V1
|
|
108
|
+
: null;
|
|
109
|
+
const connectionOwnerKey = createWebSocketConnectionOwnerKey({
|
|
110
|
+
partitionId,
|
|
111
|
+
actorId: auth.actorId,
|
|
112
|
+
clientId,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Load last-known effective scopes for this client (best-effort).
|
|
116
|
+
// Keeps /realtime lightweight and avoids sending large subscription payloads over the URL.
|
|
117
|
+
let initialScopeKeys: string[] = [];
|
|
118
|
+
let initialRealtimeSubscriptions: WebSocketRealtimeSubscription[] = [];
|
|
119
|
+
let lastAckedCursor = -1;
|
|
120
|
+
let latestCommitSeq = 0;
|
|
121
|
+
try {
|
|
122
|
+
const clientState = await readClientState(
|
|
123
|
+
options.db,
|
|
124
|
+
partitionId,
|
|
125
|
+
clientId
|
|
126
|
+
);
|
|
127
|
+
if (clientState.hasConflict || clientState.ownerActorId !== null) {
|
|
128
|
+
if (
|
|
129
|
+
clientState.ownerActorId !== auth.actorId ||
|
|
130
|
+
clientState.hasConflict
|
|
131
|
+
) {
|
|
132
|
+
return syncError(
|
|
133
|
+
c,
|
|
134
|
+
400,
|
|
135
|
+
'sync.invalid_client_id',
|
|
136
|
+
clientState.hasConflict
|
|
137
|
+
? 'clientId has conflicting ownership history'
|
|
138
|
+
: 'clientId is already bound to a different actor'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const raw = clientState.effectiveScopes;
|
|
144
|
+
let parsed: unknown = raw;
|
|
145
|
+
if (typeof raw === 'string') {
|
|
146
|
+
try {
|
|
147
|
+
parsed = JSON.parse(raw);
|
|
148
|
+
} catch {
|
|
149
|
+
parsed = null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
initialScopeKeys = applyPartitionToScopeKeys(
|
|
154
|
+
partitionId,
|
|
155
|
+
scopeValuesToScopeKeys(parsed)
|
|
156
|
+
);
|
|
157
|
+
initialRealtimeSubscriptions = parsePersistedRealtimeSubscriptions(
|
|
158
|
+
clientState.realtimeSubscriptions,
|
|
159
|
+
partitionId
|
|
160
|
+
);
|
|
161
|
+
if (initialRealtimeSubscriptions.length > 0) {
|
|
162
|
+
initialScopeKeys = uniqueScopeKeys(
|
|
163
|
+
initialRealtimeSubscriptions.flatMap(
|
|
164
|
+
(subscription) => subscription.scopeKeys
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
lastAckedCursor = clientState.cursor ?? -1;
|
|
169
|
+
latestCommitSeq = clientState.latestCommitSeq;
|
|
170
|
+
} catch {
|
|
171
|
+
// ignore; realtime is best-effort
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const maxConnectionsTotal = websocketConfig.maxConnectionsTotal ?? 5000;
|
|
175
|
+
const maxConnectionsPerClient =
|
|
176
|
+
websocketConfig.maxConnectionsPerClient ?? 3;
|
|
177
|
+
const maxMessageBytes = websocketConfig.maxMessageBytes ?? 1024 * 1024;
|
|
178
|
+
const maxMessagesPerWindow = websocketConfig.maxMessagesPerWindow ?? 120;
|
|
179
|
+
const messageRateWindowMs = websocketConfig.messageRateWindowMs ?? 10000;
|
|
180
|
+
let messageRateWindowStartedAtMs = Date.now();
|
|
181
|
+
let messageRateWindowCount = 0;
|
|
182
|
+
|
|
183
|
+
if (
|
|
184
|
+
maxConnectionsTotal > 0 &&
|
|
185
|
+
wsConnectionManager.getTotalConnections() >= maxConnectionsTotal
|
|
186
|
+
) {
|
|
187
|
+
recordRealtimeEventInBackground({
|
|
188
|
+
partitionId,
|
|
189
|
+
actorId: auth.actorId,
|
|
190
|
+
clientId,
|
|
191
|
+
transportPath: realtimeTransportPath,
|
|
192
|
+
eventType: 'rejected',
|
|
193
|
+
reason: 'max_total',
|
|
194
|
+
cursor: lastAckedCursor,
|
|
195
|
+
latestCursor: latestCommitSeq,
|
|
196
|
+
scopeCount: initialScopeKeys.length,
|
|
197
|
+
syncPackEncoding,
|
|
198
|
+
});
|
|
199
|
+
logSyncEvent({
|
|
200
|
+
event: 'sync.realtime.rejected',
|
|
201
|
+
userId: auth.actorId,
|
|
202
|
+
reason: 'max_total',
|
|
203
|
+
});
|
|
204
|
+
return syncError(c, 429, 'sync.websocket_connection_limit');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
maxConnectionsPerClient > 0 &&
|
|
209
|
+
wsConnectionManager.getScopedConnectionCount(connectionOwnerKey) >=
|
|
210
|
+
maxConnectionsPerClient
|
|
211
|
+
) {
|
|
212
|
+
recordRealtimeEventInBackground({
|
|
213
|
+
partitionId,
|
|
214
|
+
actorId: auth.actorId,
|
|
215
|
+
clientId,
|
|
216
|
+
transportPath: realtimeTransportPath,
|
|
217
|
+
eventType: 'rejected',
|
|
218
|
+
reason: 'max_per_client',
|
|
219
|
+
cursor: lastAckedCursor,
|
|
220
|
+
latestCursor: latestCommitSeq,
|
|
221
|
+
scopeCount: initialScopeKeys.length,
|
|
222
|
+
syncPackEncoding,
|
|
223
|
+
});
|
|
224
|
+
logSyncEvent({
|
|
225
|
+
event: 'sync.realtime.rejected',
|
|
226
|
+
userId: auth.actorId,
|
|
227
|
+
reason: 'max_per_client',
|
|
228
|
+
});
|
|
229
|
+
return syncError(c, 429, 'sync.websocket_connection_limit');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
logSyncEvent({ event: 'sync.realtime.connect', userId: auth.actorId });
|
|
233
|
+
|
|
234
|
+
let unregister: (() => void) | null = null;
|
|
235
|
+
let connRef: ReturnType<typeof createWebSocketConnection> | null = null;
|
|
236
|
+
const connectionCountBeforeUpgrade =
|
|
237
|
+
wsConnectionManager.getScopedConnectionCount(connectionOwnerKey);
|
|
238
|
+
let sessionStartedAtMs: number | null = null;
|
|
239
|
+
let sessionEnded = false;
|
|
240
|
+
|
|
241
|
+
const finishRealtimeSession = (reason: 'closed' | 'error') => {
|
|
242
|
+
if (sessionEnded) return;
|
|
243
|
+
sessionEnded = true;
|
|
244
|
+
if (sessionStartedAtMs === null) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const durationMs = Math.max(0, Date.now() - sessionStartedAtMs);
|
|
248
|
+
countSyncMetric('sync.sessions.ended', 1, {
|
|
249
|
+
attributes: {
|
|
250
|
+
transportPath: realtimeTransportPath,
|
|
251
|
+
reason,
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
distributionSyncMetric('sync.sessions.duration_ms', durationMs, {
|
|
255
|
+
unit: 'millisecond',
|
|
256
|
+
attributes: {
|
|
257
|
+
transportPath: realtimeTransportPath,
|
|
258
|
+
reason,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const teardownRealtimeConnection = (args: {
|
|
264
|
+
reason: 'closed' | 'error';
|
|
265
|
+
action: 'realtime_disconnected' | 'realtime_error';
|
|
266
|
+
}) => {
|
|
267
|
+
recordRealtimeEventInBackground({
|
|
268
|
+
partitionId,
|
|
269
|
+
actorId: auth.actorId,
|
|
270
|
+
clientId,
|
|
271
|
+
transportPath: realtimeTransportPath,
|
|
272
|
+
eventType: args.reason === 'closed' ? 'disconnected' : 'error',
|
|
273
|
+
reason: args.reason,
|
|
274
|
+
cursor: lastAckedCursor,
|
|
275
|
+
latestCursor: latestCommitSeq,
|
|
276
|
+
scopeCount: initialScopeKeys.length,
|
|
277
|
+
syncPackEncoding,
|
|
278
|
+
});
|
|
279
|
+
unregister?.();
|
|
280
|
+
unregister = null;
|
|
281
|
+
connRef = null;
|
|
282
|
+
finishRealtimeSession(args.reason);
|
|
283
|
+
logSyncEvent({
|
|
284
|
+
event: 'sync.realtime.disconnect',
|
|
285
|
+
userId: auth.actorId,
|
|
286
|
+
});
|
|
287
|
+
emitConsoleLiveEvent(consoleLiveEmitter, 'client_update', () => ({
|
|
288
|
+
action: args.action,
|
|
289
|
+
actorId: auth.actorId,
|
|
290
|
+
clientId,
|
|
291
|
+
partitionId,
|
|
292
|
+
}));
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const logPresenceRejected = (scopeKey: string) => {
|
|
296
|
+
logSyncEvent({
|
|
297
|
+
event: 'sync.realtime.presence.rejected',
|
|
298
|
+
userId: auth.actorId,
|
|
299
|
+
reason: 'scope_not_authorized',
|
|
300
|
+
scopeKey,
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const upgradeWebSocket = websocketConfig.upgradeWebSocket;
|
|
305
|
+
if (!upgradeWebSocket) {
|
|
306
|
+
return syncError(c, 500, 'sync.websocket_not_configured');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return upgradeWebSocket(c, {
|
|
310
|
+
onOpen(_evt, ws) {
|
|
311
|
+
const requiresInitialSync =
|
|
312
|
+
initialScopeKeys.length > 0 && latestCommitSeq > lastAckedCursor;
|
|
313
|
+
const shardKey = createSyncRealtimeShardKey({ partitionId });
|
|
314
|
+
const conn = createWebSocketConnection(ws, {
|
|
315
|
+
actorId: auth.actorId,
|
|
316
|
+
clientId,
|
|
317
|
+
ownerKey: connectionOwnerKey,
|
|
318
|
+
transportPath: realtimeTransportPath,
|
|
319
|
+
syncPackEncoding,
|
|
320
|
+
});
|
|
321
|
+
connRef = conn;
|
|
322
|
+
sessionStartedAtMs = Date.now();
|
|
323
|
+
countSyncMetric('sync.sessions.started', 1, {
|
|
324
|
+
attributes: {
|
|
325
|
+
transportPath: realtimeTransportPath,
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
if (connectionCountBeforeUpgrade > 0) {
|
|
329
|
+
countSyncMetric('sync.transport.reconnects', 1, {
|
|
330
|
+
attributes: {
|
|
331
|
+
transportPath: realtimeTransportPath,
|
|
332
|
+
source: 'server',
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
unregister = wsConnectionManager.register(conn, initialScopeKeys);
|
|
338
|
+
if (initialRealtimeSubscriptions.length > 0) {
|
|
339
|
+
wsConnectionManager.updateConnectionSubscriptions(
|
|
340
|
+
connectionOwnerKey,
|
|
341
|
+
initialRealtimeSubscriptions
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
conn.sendHello({
|
|
345
|
+
protocolVersion: 1,
|
|
346
|
+
sessionId: createRealtimeSessionId(),
|
|
347
|
+
shardKey,
|
|
348
|
+
actorId: auth.actorId,
|
|
349
|
+
clientId,
|
|
350
|
+
transportPath: realtimeTransportPath,
|
|
351
|
+
syncPackEncoding,
|
|
352
|
+
cursor: lastAckedCursor,
|
|
353
|
+
latestCursor: latestCommitSeq,
|
|
354
|
+
scopeCount: initialScopeKeys.length,
|
|
355
|
+
requiresSync: requiresInitialSync,
|
|
356
|
+
});
|
|
357
|
+
recordRealtimeEventInBackground({
|
|
358
|
+
partitionId,
|
|
359
|
+
actorId: auth.actorId,
|
|
360
|
+
clientId,
|
|
361
|
+
transportPath: realtimeTransportPath,
|
|
362
|
+
eventType: 'connected',
|
|
363
|
+
reason: requiresInitialSync ? 'requires_sync' : null,
|
|
364
|
+
cursor: lastAckedCursor,
|
|
365
|
+
latestCursor: latestCommitSeq,
|
|
366
|
+
scopeCount: initialScopeKeys.length,
|
|
367
|
+
syncPackEncoding,
|
|
368
|
+
});
|
|
369
|
+
conn.sendHeartbeat();
|
|
370
|
+
if (requiresInitialSync) {
|
|
371
|
+
const replayed = wsConnectionManager.replayScopeKeys(
|
|
372
|
+
conn,
|
|
373
|
+
initialScopeKeys,
|
|
374
|
+
lastAckedCursor,
|
|
375
|
+
latestCommitSeq
|
|
376
|
+
);
|
|
377
|
+
if (!replayed) {
|
|
378
|
+
conn.sendSync(latestCommitSeq, {
|
|
379
|
+
reason: 'reconnect-catchup',
|
|
380
|
+
requiresPull: true,
|
|
381
|
+
});
|
|
382
|
+
recordRealtimeEventInBackground({
|
|
383
|
+
partitionId,
|
|
384
|
+
actorId: auth.actorId,
|
|
385
|
+
clientId,
|
|
386
|
+
transportPath: realtimeTransportPath,
|
|
387
|
+
eventType: 'pull_required',
|
|
388
|
+
reason: 'reconnect-catchup',
|
|
389
|
+
cursor: lastAckedCursor,
|
|
390
|
+
latestCursor: latestCommitSeq,
|
|
391
|
+
commitSeq: latestCommitSeq,
|
|
392
|
+
scopeCount: initialScopeKeys.length,
|
|
393
|
+
syncPackEncoding,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
emitConsoleLiveEvent(consoleLiveEmitter, 'client_update', () => ({
|
|
398
|
+
action: 'realtime_connected',
|
|
399
|
+
actorId: auth.actorId,
|
|
400
|
+
clientId,
|
|
401
|
+
partitionId,
|
|
402
|
+
transportPath: realtimeTransportPath,
|
|
403
|
+
scopeCount: initialScopeKeys.length,
|
|
404
|
+
}));
|
|
405
|
+
},
|
|
406
|
+
onClose(_evt, _ws) {
|
|
407
|
+
teardownRealtimeConnection({
|
|
408
|
+
reason: 'closed',
|
|
409
|
+
action: 'realtime_disconnected',
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
onError(_evt, _ws) {
|
|
413
|
+
teardownRealtimeConnection({
|
|
414
|
+
reason: 'error',
|
|
415
|
+
action: 'realtime_error',
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
onMessage(evt, _ws) {
|
|
419
|
+
if (!connRef) return;
|
|
420
|
+
try {
|
|
421
|
+
const messageBytes = measureWebSocketMessageBytes(evt.data);
|
|
422
|
+
if (messageBytes > maxMessageBytes) {
|
|
423
|
+
recordRealtimeEventInBackground({
|
|
424
|
+
partitionId,
|
|
425
|
+
actorId: auth.actorId,
|
|
426
|
+
clientId,
|
|
427
|
+
transportPath: realtimeTransportPath,
|
|
428
|
+
eventType: 'error',
|
|
429
|
+
reason: 'message_too_large',
|
|
430
|
+
cursor: lastAckedCursor,
|
|
431
|
+
latestCursor: latestCommitSeq,
|
|
432
|
+
scopeCount: initialScopeKeys.length,
|
|
433
|
+
syncPackEncoding,
|
|
434
|
+
});
|
|
435
|
+
connRef.sendError(
|
|
436
|
+
`WebSocket message exceeds max size (${maxMessageBytes} bytes)`
|
|
437
|
+
);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (maxMessagesPerWindow > 0 && messageRateWindowMs > 0) {
|
|
441
|
+
const nowMs = Date.now();
|
|
442
|
+
if (nowMs - messageRateWindowStartedAtMs >= messageRateWindowMs) {
|
|
443
|
+
messageRateWindowStartedAtMs = nowMs;
|
|
444
|
+
messageRateWindowCount = 0;
|
|
445
|
+
}
|
|
446
|
+
messageRateWindowCount += 1;
|
|
447
|
+
if (messageRateWindowCount > maxMessagesPerWindow) {
|
|
448
|
+
recordRealtimeEventInBackground({
|
|
449
|
+
partitionId,
|
|
450
|
+
actorId: auth.actorId,
|
|
451
|
+
clientId,
|
|
452
|
+
transportPath: realtimeTransportPath,
|
|
453
|
+
eventType: 'error',
|
|
454
|
+
reason: 'message_rate_exceeded',
|
|
455
|
+
cursor: lastAckedCursor,
|
|
456
|
+
latestCursor: latestCommitSeq,
|
|
457
|
+
scopeCount: initialScopeKeys.length,
|
|
458
|
+
syncPackEncoding,
|
|
459
|
+
});
|
|
460
|
+
connRef.sendError(
|
|
461
|
+
`WebSocket message rate exceeded (${maxMessagesPerWindow}/${messageRateWindowMs}ms)`
|
|
462
|
+
);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const raw =
|
|
467
|
+
typeof evt.data === 'string' ? evt.data : String(evt.data);
|
|
468
|
+
const msg = JSON.parse(raw);
|
|
469
|
+
if (!msg || typeof msg !== 'object') return;
|
|
470
|
+
|
|
471
|
+
if (msg.type === 'ack') {
|
|
472
|
+
const cursor =
|
|
473
|
+
typeof msg.cursor === 'number' &&
|
|
474
|
+
Number.isSafeInteger(msg.cursor)
|
|
475
|
+
? msg.cursor
|
|
476
|
+
: null;
|
|
477
|
+
if (cursor !== null && cursor > lastAckedCursor) {
|
|
478
|
+
lastAckedCursor = cursor;
|
|
479
|
+
wsConnectionManager.recordAck(connRef, cursor);
|
|
480
|
+
recordRealtimeEventInBackground({
|
|
481
|
+
partitionId,
|
|
482
|
+
actorId: auth.actorId,
|
|
483
|
+
clientId,
|
|
484
|
+
transportPath: realtimeTransportPath,
|
|
485
|
+
eventType: 'ack',
|
|
486
|
+
reason: null,
|
|
487
|
+
cursor,
|
|
488
|
+
latestCursor: latestCommitSeq,
|
|
489
|
+
scopeCount: initialScopeKeys.length,
|
|
490
|
+
syncPackEncoding,
|
|
491
|
+
});
|
|
492
|
+
void recordRealtimeAck({
|
|
493
|
+
db: options.db,
|
|
494
|
+
dialect: options.dialect,
|
|
495
|
+
actorId: auth.actorId,
|
|
496
|
+
clientId,
|
|
497
|
+
cursor,
|
|
498
|
+
partitionId,
|
|
499
|
+
realtimeSubscriptions: serializeRealtimeSubscriptions(
|
|
500
|
+
wsConnectionManager.getConnectionSubscriptions(
|
|
501
|
+
connectionOwnerKey
|
|
502
|
+
)
|
|
503
|
+
),
|
|
504
|
+
}).catch((error) => {
|
|
505
|
+
logAsyncFailureOnce('sync.realtime.ack_record_failed', {
|
|
506
|
+
event: 'sync.realtime.ack_record_failed',
|
|
507
|
+
userId: auth.actorId,
|
|
508
|
+
clientId,
|
|
509
|
+
error:
|
|
510
|
+
error instanceof Error ? error.message : String(error),
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (msg.type === 'push') {
|
|
518
|
+
void handleWsPush(msg, connRef, auth, clientId);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (msg.type !== 'presence' || !msg.scopeKey) return;
|
|
523
|
+
|
|
524
|
+
const scopeKey = normalizeScopeKeyForPartition(
|
|
525
|
+
partitionId,
|
|
526
|
+
String(msg.scopeKey)
|
|
527
|
+
);
|
|
528
|
+
if (!scopeKey) return;
|
|
529
|
+
|
|
530
|
+
switch (msg.action) {
|
|
531
|
+
case 'join':
|
|
532
|
+
if (
|
|
533
|
+
!wsConnectionManager.joinPresence(
|
|
534
|
+
connectionOwnerKey,
|
|
535
|
+
scopeKey,
|
|
536
|
+
msg.metadata
|
|
537
|
+
)
|
|
538
|
+
) {
|
|
539
|
+
logPresenceRejected(scopeKey);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
// Send presence snapshot back to the joining client
|
|
543
|
+
{
|
|
544
|
+
const entries = wsConnectionManager.getPresence(scopeKey);
|
|
545
|
+
connRef.sendPresence({
|
|
546
|
+
action: 'snapshot',
|
|
547
|
+
scopeKey,
|
|
548
|
+
entries,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
break;
|
|
552
|
+
case 'leave':
|
|
553
|
+
wsConnectionManager.leavePresence(connectionOwnerKey, scopeKey);
|
|
554
|
+
break;
|
|
555
|
+
case 'update':
|
|
556
|
+
if (
|
|
557
|
+
!wsConnectionManager.updatePresenceMetadata(
|
|
558
|
+
connectionOwnerKey,
|
|
559
|
+
scopeKey,
|
|
560
|
+
msg.metadata ?? {}
|
|
561
|
+
) &&
|
|
562
|
+
!wsConnectionManager.isConnectionSubscribedToScopeKey(
|
|
563
|
+
connectionOwnerKey,
|
|
564
|
+
scopeKey
|
|
565
|
+
)
|
|
566
|
+
) {
|
|
567
|
+
logPresenceRejected(scopeKey);
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
} catch {
|
|
572
|
+
// Ignore malformed messages
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const recordWsPushFailure = (args: {
|
|
580
|
+
partitionId: string;
|
|
581
|
+
requestId: string;
|
|
582
|
+
traceContext: TraceContext;
|
|
583
|
+
actorId: string;
|
|
584
|
+
clientId: string;
|
|
585
|
+
transportPath: 'direct' | 'relay';
|
|
586
|
+
statusCode: number;
|
|
587
|
+
outcome: 'rejected' | 'error';
|
|
588
|
+
durationMs: number;
|
|
589
|
+
errorCode: string;
|
|
590
|
+
errorMessage: string;
|
|
591
|
+
operationCount?: number | null;
|
|
592
|
+
payloadSnapshot?: RequestPayloadSnapshot | null;
|
|
593
|
+
}): void => {
|
|
594
|
+
recordRequestEventInBackground(() => ({
|
|
595
|
+
partitionId: args.partitionId,
|
|
596
|
+
requestId: args.requestId,
|
|
597
|
+
traceId: args.traceContext.traceId,
|
|
598
|
+
spanId: args.traceContext.spanId,
|
|
599
|
+
eventType: 'push',
|
|
600
|
+
syncPath: 'ws-push',
|
|
601
|
+
actorId: args.actorId,
|
|
602
|
+
clientId: args.clientId,
|
|
603
|
+
transportPath: args.transportPath,
|
|
604
|
+
statusCode: args.statusCode,
|
|
605
|
+
outcome: args.outcome,
|
|
606
|
+
responseStatus: normalizeResponseStatus(args.statusCode, args.outcome),
|
|
607
|
+
durationMs: args.durationMs,
|
|
608
|
+
errorCode: args.errorCode,
|
|
609
|
+
errorMessage: args.errorMessage,
|
|
610
|
+
operationCount: args.operationCount ?? null,
|
|
611
|
+
payloadSnapshot: args.payloadSnapshot ?? null,
|
|
612
|
+
}));
|
|
613
|
+
|
|
614
|
+
emitConsoleLiveEvent(consoleLiveEmitter, 'push', () => ({
|
|
615
|
+
partitionId: args.partitionId,
|
|
616
|
+
requestId: args.requestId,
|
|
617
|
+
traceId: args.traceContext.traceId,
|
|
618
|
+
spanId: args.traceContext.spanId,
|
|
619
|
+
actorId: args.actorId,
|
|
620
|
+
clientId: args.clientId,
|
|
621
|
+
transportPath: args.transportPath,
|
|
622
|
+
syncPath: 'ws-push',
|
|
623
|
+
outcome: args.outcome,
|
|
624
|
+
statusCode: args.statusCode,
|
|
625
|
+
durationMs: args.durationMs,
|
|
626
|
+
operationCount: args.operationCount ?? null,
|
|
627
|
+
errorCode: args.errorCode,
|
|
628
|
+
}));
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
async function handleWsPush(
|
|
632
|
+
msg: Record<string, unknown>,
|
|
633
|
+
conn: WebSocketConnection,
|
|
634
|
+
auth: Auth,
|
|
635
|
+
clientId: string
|
|
636
|
+
): Promise<void> {
|
|
637
|
+
const actorId = auth.actorId;
|
|
638
|
+
const partitionId = auth.partitionId ?? 'default';
|
|
639
|
+
const requestId = typeof msg.requestId === 'string' ? msg.requestId : '';
|
|
640
|
+
if (!requestId) return;
|
|
641
|
+
const traceContext = readTraceContextFromMessage(msg);
|
|
642
|
+
const timer = createSyncTimer();
|
|
643
|
+
|
|
644
|
+
try {
|
|
645
|
+
// Validate the push payload
|
|
646
|
+
const parsed = SyncPushRequestSchema.omit({ clientId: true }).safeParse(
|
|
647
|
+
msg
|
|
648
|
+
);
|
|
649
|
+
if (!parsed.success) {
|
|
650
|
+
const invalidDurationMs = timer();
|
|
651
|
+
const errorMessage = 'Invalid push payload';
|
|
652
|
+
conn.sendPushResponse({
|
|
653
|
+
requestId,
|
|
654
|
+
ok: false,
|
|
655
|
+
status: 'rejected',
|
|
656
|
+
results: [{ opIndex: 0, status: 'error', error: errorMessage }],
|
|
657
|
+
});
|
|
658
|
+
recordWsPushFailure({
|
|
659
|
+
partitionId,
|
|
660
|
+
requestId,
|
|
661
|
+
actorId,
|
|
662
|
+
clientId,
|
|
663
|
+
transportPath: conn.transportPath,
|
|
664
|
+
statusCode: 400,
|
|
665
|
+
outcome: 'rejected',
|
|
666
|
+
durationMs: invalidDurationMs,
|
|
667
|
+
errorCode: 'INVALID_PUSH_PAYLOAD',
|
|
668
|
+
errorMessage,
|
|
669
|
+
traceContext,
|
|
670
|
+
payloadSnapshot: shouldCaptureRequestPayloadSnapshots
|
|
671
|
+
? {
|
|
672
|
+
request: msg,
|
|
673
|
+
response: {
|
|
674
|
+
ok: false,
|
|
675
|
+
status: 'rejected',
|
|
676
|
+
reason: 'invalid_push_payload',
|
|
677
|
+
},
|
|
678
|
+
}
|
|
679
|
+
: null,
|
|
680
|
+
});
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const pushOps = parsed.data.operations ?? [];
|
|
685
|
+
if (pushOps.length > maxOperationsPerPush) {
|
|
686
|
+
const rejectedDurationMs = timer();
|
|
687
|
+
const errorMessage = `Maximum ${maxOperationsPerPush} operations per push`;
|
|
688
|
+
conn.sendPushResponse({
|
|
689
|
+
requestId,
|
|
690
|
+
ok: false,
|
|
691
|
+
status: 'rejected',
|
|
692
|
+
results: [
|
|
693
|
+
{
|
|
694
|
+
opIndex: 0,
|
|
695
|
+
status: 'error',
|
|
696
|
+
error: errorMessage,
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
});
|
|
700
|
+
recordWsPushFailure({
|
|
701
|
+
partitionId,
|
|
702
|
+
requestId,
|
|
703
|
+
actorId,
|
|
704
|
+
clientId,
|
|
705
|
+
transportPath: conn.transportPath,
|
|
706
|
+
statusCode: 400,
|
|
707
|
+
outcome: 'rejected',
|
|
708
|
+
durationMs: rejectedDurationMs,
|
|
709
|
+
errorCode: 'MAX_OPERATIONS_EXCEEDED',
|
|
710
|
+
errorMessage,
|
|
711
|
+
traceContext,
|
|
712
|
+
operationCount: pushOps.length,
|
|
713
|
+
payloadSnapshot: shouldCaptureRequestPayloadSnapshots
|
|
714
|
+
? {
|
|
715
|
+
request: {
|
|
716
|
+
clientId,
|
|
717
|
+
clientCommitId: parsed.data.clientCommitId,
|
|
718
|
+
schemaVersion: parsed.data.schemaVersion,
|
|
719
|
+
authLease: parsed.data.authLease,
|
|
720
|
+
operations: parsed.data.operations,
|
|
721
|
+
},
|
|
722
|
+
response: {
|
|
723
|
+
ok: false,
|
|
724
|
+
status: 'rejected',
|
|
725
|
+
reason: 'max_operations_exceeded',
|
|
726
|
+
},
|
|
727
|
+
}
|
|
728
|
+
: null,
|
|
729
|
+
});
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const pushed = await executePushCommitWithSideEffects(
|
|
734
|
+
{
|
|
735
|
+
auth,
|
|
736
|
+
clientId,
|
|
737
|
+
partitionId,
|
|
738
|
+
requestId,
|
|
739
|
+
traceContext,
|
|
740
|
+
transportPath: conn.transportPath,
|
|
741
|
+
syncPath: 'ws-push',
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
clientCommitId: parsed.data.clientCommitId,
|
|
745
|
+
operations: parsed.data.operations,
|
|
746
|
+
schemaVersion: parsed.data.schemaVersion,
|
|
747
|
+
authLease: parsed.data.authLease,
|
|
748
|
+
},
|
|
749
|
+
{ countConflictsMetric: true }
|
|
750
|
+
);
|
|
751
|
+
|
|
752
|
+
triggerAutoMaintenance({
|
|
753
|
+
actorId,
|
|
754
|
+
clientId,
|
|
755
|
+
partitionId,
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
conn.sendPushResponse({
|
|
759
|
+
requestId,
|
|
760
|
+
ok: pushed.response.ok,
|
|
761
|
+
status: pushed.response.status,
|
|
762
|
+
commitSeq: pushed.response.commitSeq,
|
|
763
|
+
results: pushed.response.results,
|
|
764
|
+
});
|
|
765
|
+
} catch (err) {
|
|
766
|
+
const failedDurationMs = timer();
|
|
767
|
+
captureSyncException(err, {
|
|
768
|
+
event: 'sync.realtime.push_failed',
|
|
769
|
+
requestId,
|
|
770
|
+
clientId,
|
|
771
|
+
actorId,
|
|
772
|
+
partitionId,
|
|
773
|
+
});
|
|
774
|
+
const message =
|
|
775
|
+
err instanceof Error ? err.message : 'Internal server error';
|
|
776
|
+
recordWsPushFailure({
|
|
777
|
+
partitionId,
|
|
778
|
+
requestId,
|
|
779
|
+
actorId,
|
|
780
|
+
clientId,
|
|
781
|
+
transportPath: conn.transportPath,
|
|
782
|
+
statusCode: 500,
|
|
783
|
+
outcome: 'error',
|
|
784
|
+
durationMs: failedDurationMs,
|
|
785
|
+
errorCode: 'INTERNAL_SERVER_ERROR',
|
|
786
|
+
errorMessage: message,
|
|
787
|
+
traceContext,
|
|
788
|
+
payloadSnapshot: shouldCaptureRequestPayloadSnapshots
|
|
789
|
+
? {
|
|
790
|
+
request: msg,
|
|
791
|
+
response: {
|
|
792
|
+
ok: false,
|
|
793
|
+
status: 'rejected',
|
|
794
|
+
reason: 'internal_server_error',
|
|
795
|
+
message,
|
|
796
|
+
},
|
|
797
|
+
}
|
|
798
|
+
: null,
|
|
799
|
+
});
|
|
800
|
+
conn.sendPushResponse({
|
|
801
|
+
requestId,
|
|
802
|
+
ok: false,
|
|
803
|
+
status: 'rejected',
|
|
804
|
+
results: [{ opIndex: 0, status: 'error', error: message }],
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|