@dxos/protocols 0.8.4-main.f9ba587 → 0.8.4-main.fbb7a13
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/dist/src/FunctionProtocol.d.ts +82 -0
- package/dist/src/FunctionProtocol.d.ts.map +1 -0
- package/dist/src/FunctionProtocol.js +4 -0
- package/dist/src/FunctionProtocol.js.map +1 -0
- package/dist/src/automerge.d.ts +8 -0
- package/dist/src/automerge.d.ts.map +1 -1
- package/dist/src/automerge.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/dashboard_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/dashboard_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/echo-proxy_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/echo-proxy_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/epoch_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/epoch_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/functions_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/agent/functions_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/bot_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/bot_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/client/invitation_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/client/invitation_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/client/logging_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/client/logging_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts +189 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts.map +1 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.js +39 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.js.map +1 -0
- package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts +65 -19
- package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/client/services_pb.js +28 -23
- package/dist/src/buf/proto/gen/dxos/client/services_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/config_pb.d.ts +40 -7
- package/dist/src/buf/proto/gen/dxos/config_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/config_pb.js +7 -2
- package/dist/src/buf/proto/gen/dxos/config_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/diagnostics_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/diagnostics_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/host_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/host_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/swarm_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/devtools/swarm_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/blob_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/blob_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/feed_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/feed_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/filter_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/filter_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/indexing_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/indexing_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/document_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/document_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/messenger_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/messenger_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/text_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/model/text_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/object_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/object_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts +13 -3
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.js +2 -2
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts +71 -10
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.js +16 -6
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/snapshot_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/snapshot_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/timeframe_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/timeframe_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/calls_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/calls_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/signal_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/edge/signal_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/error_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/error_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/field_options_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/field_options_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/google_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/google_pb.js +2 -2
- package/dist/src/buf/proto/gen/dxos/google_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/gravity_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/gravity_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/auth_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/auth_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/greet_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/greet_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/identity_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials/identity_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/invitations_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/invitations_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/keyring_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/keyring_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/keys_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/keys_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/signed_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/halo/signed_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts +2 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/keys_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/keys_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/bridge_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/bridge_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/broadcast_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/broadcast_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/messaging_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/messaging_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/muxer_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/muxer_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/presence_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/presence_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/protocol_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/protocol_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/replicator_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/replicator_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/signal_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/signal_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/swarm_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/swarm_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/control_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/control_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/registry_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/registry_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/rpc_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/rpc_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/service/agentmanager_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/service/agentmanager_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/service/publisher_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/service/publisher_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/service/supervisor_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/service/supervisor_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/service/tunnel_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/service/tunnel_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/tracing_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/tracing_pb.js +2 -2
- package/dist/src/buf/proto/gen/dxos/tracing_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/type_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/type_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/value_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/value_pb.js +1 -1
- package/dist/src/buf/proto/gen/example/testing/data_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/example/testing/data_pb.js +1 -1
- package/dist/src/buf/proto/gen/example/testing/rpc_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/example/testing/rpc_pb.js +1 -1
- package/dist/src/edge/EdgeFunctionEnv.d.ts +120 -0
- package/dist/src/edge/EdgeFunctionEnv.d.ts.map +1 -0
- package/dist/src/edge/EdgeFunctionEnv.js +4 -0
- package/dist/src/edge/EdgeFunctionEnv.js.map +1 -0
- package/dist/src/edge/edge.d.ts +346 -0
- package/dist/src/edge/edge.d.ts.map +1 -0
- package/dist/src/edge/edge.js +160 -0
- package/dist/src/edge/edge.js.map +1 -0
- package/dist/src/edge/errors.d.ts +29 -0
- package/dist/src/edge/errors.d.ts.map +1 -0
- package/dist/src/edge/errors.js +69 -0
- package/dist/src/edge/errors.js.map +1 -0
- package/dist/src/edge/index.d.ts +4 -0
- package/dist/src/edge/index.d.ts.map +1 -0
- package/dist/src/edge/index.js +7 -0
- package/dist/src/edge/index.js.map +1 -0
- package/dist/src/errors/base-errors.d.ts +86 -8
- package/dist/src/errors/base-errors.d.ts.map +1 -1
- package/dist/src/errors/base-errors.js +4 -19
- package/dist/src/errors/base-errors.js.map +1 -1
- package/dist/src/errors/encoding.d.ts +1 -1
- package/dist/src/errors/encoding.d.ts.map +1 -1
- package/dist/src/errors/encoding.js.map +1 -1
- package/dist/src/errors/errors.d.ts +618 -41
- package/dist/src/errors/errors.d.ts.map +1 -1
- package/dist/src/errors/errors.js +49 -103
- package/dist/src/errors/errors.js.map +1 -1
- package/dist/src/errors/errors.test.js +1 -1
- package/dist/src/errors/errors.test.js.map +1 -1
- package/dist/src/errors/helpers.d.ts +8 -4
- package/dist/src/errors/helpers.d.ts.map +1 -1
- package/dist/src/errors/helpers.js +3 -3
- package/dist/src/errors/helpers.js.map +1 -1
- package/dist/src/feed-replication.d.ts.map +1 -1
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/indexing.d.ts +1 -1
- package/dist/src/indexing.d.ts.map +1 -1
- package/dist/src/indexing.js +1 -1
- package/dist/src/indexing.js.map +1 -1
- package/dist/src/invitation.d.ts +1 -1
- package/dist/src/invitation.d.ts.map +1 -1
- package/dist/src/invitation.js +1 -1
- package/dist/src/invitation.js.map +1 -1
- package/dist/src/messenger.d.ts +16 -0
- package/dist/src/messenger.d.ts.map +1 -0
- package/dist/src/messenger.js +4 -0
- package/dist/src/messenger.js.map +1 -0
- package/dist/src/proto/gen/dxos/client/services.d.ts +895 -765
- package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.js +103 -100
- package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/src/proto/gen/dxos/config.d.ts +33 -2
- package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/config.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/query.d.ts +17 -1
- package/dist/src/proto/gen/dxos/echo/query.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/query.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/service.d.ts +43 -8
- package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
- package/dist/src/proto/gen/index.d.ts +10 -0
- package/dist/src/proto/gen/index.d.ts.map +1 -1
- package/dist/src/proto/gen/index.js +1 -1
- package/dist/src/proto/gen/index.js.map +1 -1
- package/dist/src/proto/index.d.ts +1 -1
- package/dist/src/proto/index.d.ts.map +1 -1
- package/dist/src/proto/index.js +0 -1
- package/dist/src/proto/index.js.map +1 -1
- package/dist/src/queue.d.ts +2 -23
- package/dist/src/queue.d.ts.map +1 -1
- package/dist/src/queue.js +2 -1
- package/dist/src/queue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -17
- package/src/FunctionProtocol.ts +104 -0
- package/src/automerge.ts +8 -0
- package/src/buf/proto/gen/dxos/agent/dashboard_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/agent/echo-proxy_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/agent/epoch_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/agent/functions_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/bot_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/client/invitation_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/client/logging_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/client/queue_pb.ts +231 -0
- package/src/buf/proto/gen/dxos/client/services_pb.ts +84 -29
- package/src/buf/proto/gen/dxos/config_pb.ts +48 -10
- package/src/buf/proto/gen/dxos/devtools/diagnostics_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/devtools/host_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/devtools/swarm_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/blob_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/feed_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/filter_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/indexing_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/metadata_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/model/document_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/model/messenger_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/model/text_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/object_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/query_pb.ts +18 -6
- package/src/buf/proto/gen/dxos/echo/service_pb.ts +87 -18
- package/src/buf/proto/gen/dxos/echo/snapshot_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/echo/timeframe_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/edge/calls_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/edge/messenger_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/edge/signal_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/error_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/field_options_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/google_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/gravity_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/credentials/auth_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/credentials/greet_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/credentials/identity_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/credentials_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/invitations_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/keyring_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/keys_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/halo/signed_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/iframe_pb.ts +4 -3
- package/src/buf/proto/gen/dxos/keys_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/bridge_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/broadcast_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/messaging_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/muxer_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/presence_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/protocol_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/replicator_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/signal_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/swarm_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/control_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/registry_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/rpc_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/service/agentmanager_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/service/publisher_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/service/supervisor_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/service/tunnel_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/tracing_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/type_pb.ts +3 -3
- package/src/buf/proto/gen/dxos/value_pb.ts +3 -3
- package/src/buf/proto/gen/example/testing/data_pb.ts +3 -3
- package/src/buf/proto/gen/example/testing/rpc_pb.ts +3 -3
- package/src/edge/EdgeFunctionEnv.ts +193 -0
- package/src/edge/edge.ts +484 -0
- package/src/edge/errors.ts +85 -0
- package/src/edge/index.ts +7 -0
- package/src/errors/base-errors.ts +4 -20
- package/src/errors/encoding.ts +2 -1
- package/src/errors/errors.test.ts +1 -1
- package/src/errors/errors.ts +57 -122
- package/src/errors/helpers.ts +5 -5
- package/src/feed-replication.ts +1 -0
- package/src/index.ts +9 -7
- package/src/indexing.ts +1 -1
- package/src/invitation.ts +1 -1
- package/src/messenger.ts +22 -0
- package/src/proto/dxos/client/queue.proto +67 -0
- package/src/proto/dxos/client/services.proto +20 -3
- package/src/proto/dxos/config.proto +38 -40
- package/src/proto/dxos/echo/query.proto +4 -1
- package/src/proto/dxos/echo/service.proto +38 -6
- package/src/proto/dxos/iframe.proto +1 -0
- package/src/proto/gen/dxos/client/services.ts +895 -765
- package/src/proto/gen/dxos/config.ts +33 -2
- package/src/proto/gen/dxos/echo/query.ts +17 -1
- package/src/proto/gen/dxos/echo/service.ts +42 -8
- package/src/proto/gen/index.ts +11 -1
- package/src/proto/index.ts +1 -1
- package/src/queue.ts +10 -29
- package/dist/src/edge-error.d.ts +0 -26
- package/dist/src/edge-error.d.ts.map +0 -1
- package/dist/src/edge-error.js +0 -62
- package/dist/src/edge-error.js.map +0 -1
- package/dist/src/edge.d.ts +0 -198
- package/dist/src/edge.d.ts.map +0 -1
- package/dist/src/edge.js +0 -43
- package/dist/src/edge.js.map +0 -1
- package/dist/src/query.d.ts +0 -5
- package/dist/src/query.d.ts.map +0 -1
- package/dist/src/query.js +0 -8
- package/dist/src/query.js.map +0 -1
- package/src/edge-error.ts +0 -79
- package/src/edge.ts +0 -222
- package/src/query.ts +0 -8
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type SpaceId } from '@dxos/keys';
|
|
6
|
+
|
|
7
|
+
import { type CreateDocumentRequest, type CreateDocumentResponse } from '../proto/gen/dxos/echo/service';
|
|
8
|
+
import { type QueryResult, type QueueQuery } from '../queue';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
|
|
12
|
+
API for the edge functions service.
|
|
13
|
+
A function module should be a valid cloudflare worker module.
|
|
14
|
+
|
|
15
|
+
# Fetching metadata (done on deploy)
|
|
16
|
+
|
|
17
|
+
GET http://functions.dxos.internal/
|
|
18
|
+
X-DXOS-Function-Route: meta
|
|
19
|
+
|
|
20
|
+
Expected to return `FunctionMetadata` in JSON:
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
key: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
inputSchema?: JsonSchemaType;
|
|
27
|
+
outputSchema?: JsonSchemaType;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Invoking the function
|
|
31
|
+
|
|
32
|
+
POST http://functions.dxos.internal/
|
|
33
|
+
Content-Type: application/json
|
|
34
|
+
X-Trace-Queue-Dxn: dxn:queue:trace:AAAAAA:BBBBBB
|
|
35
|
+
X-Invocation-Id: XXXXXXX
|
|
36
|
+
X-Edge-Env: production
|
|
37
|
+
|
|
38
|
+
{input_data}
|
|
39
|
+
|
|
40
|
+
Expected to return `EdgeEnvelope` with the output data:
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
success: true,
|
|
44
|
+
data: unknown
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
On Error returns `EdgeEnvelope` with error:
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
success: false,
|
|
51
|
+
message: string
|
|
52
|
+
error: EncodedError
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Environment available to the function running on Cloudflare.
|
|
59
|
+
*/
|
|
60
|
+
export interface Env {
|
|
61
|
+
QUEUE_SERVICE: QueueService;
|
|
62
|
+
DATA_SERVICE: DataService;
|
|
63
|
+
FUNCTIONS_AI_SERVICE: FunctionsAiService;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Use to trace the execution across multiple services.
|
|
68
|
+
*
|
|
69
|
+
* NOTE: Currently unused in functions.
|
|
70
|
+
*/
|
|
71
|
+
export interface ExecutionContext {}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Database API for other CF services like functions.
|
|
75
|
+
*/
|
|
76
|
+
export interface DataService {
|
|
77
|
+
getSpaceMeta(ctx: ExecutionContext, spaceId: SpaceId): Promise<RpcResult<SpaceMeta | undefined>>;
|
|
78
|
+
getDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string): Promise<RpcResult<RawDocument | undefined>>;
|
|
79
|
+
|
|
80
|
+
query(ctx: ExecutionContext, request: QueryRequest): Promise<RpcResult<QueryResponse>>;
|
|
81
|
+
queryDocuments(ctx: ExecutionContext, request: QueryRequest): Promise<RpcResult<QueryDocumentsResponse>>;
|
|
82
|
+
queryReferences(ctx: ExecutionContext, request: QueryReferencesRequest): Promise<RpcResult<QueryReferencesResponse>>;
|
|
83
|
+
|
|
84
|
+
createDocument(ctx: ExecutionContext, request: CreateDocumentRequest): Promise<RpcResult<CreateDocumentResponse>>;
|
|
85
|
+
|
|
86
|
+
// TODO(burdon): Update? Return DocumentEntry?
|
|
87
|
+
changeDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface QueueService {
|
|
91
|
+
query(ctx: ExecutionContext, queueDXN: string, query: Omit<QueueQuery, 'queueId'>): Promise<RpcResult<QueryResult>>;
|
|
92
|
+
append(ctx: ExecutionContext, queueDXN: string, objects: unknown[]): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* FunctionsAiService API for other CF services like functions.
|
|
97
|
+
*/
|
|
98
|
+
export interface FunctionsAiService {
|
|
99
|
+
/**
|
|
100
|
+
* Enables proxying HTTP requests to the AI service from other workers.
|
|
101
|
+
*/
|
|
102
|
+
fetch(request: Request): Promise<RpcResult<Response>>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type ObjectDocumentJson = {
|
|
106
|
+
type?: string;
|
|
107
|
+
objectId: string;
|
|
108
|
+
documentId: string;
|
|
109
|
+
/** Base64 encoding of a document. */
|
|
110
|
+
document: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type SpaceMeta = {
|
|
114
|
+
spaceKey: string;
|
|
115
|
+
rootDocumentId: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type QueryRequest = {
|
|
119
|
+
spaceId: string;
|
|
120
|
+
type?: string;
|
|
121
|
+
where?: Record<string, any>;
|
|
122
|
+
objectIds?: string[];
|
|
123
|
+
cursor?: string;
|
|
124
|
+
limit?: number;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type QueryResponse = {
|
|
128
|
+
results: ObjectSnapshot[];
|
|
129
|
+
cursor?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* TODO(yaroslav): make Indexer return EchoObject after create() can properly reconstruct an object
|
|
134
|
+
* from this structure (meta, id and type aren't handled properly)
|
|
135
|
+
*/
|
|
136
|
+
export type ObjectSnapshot = {
|
|
137
|
+
type?: string;
|
|
138
|
+
documentId: string;
|
|
139
|
+
objectId: string;
|
|
140
|
+
// TODO(mykola): Use ObjectStructure from @dxos/echo-protocol.
|
|
141
|
+
object: unknown;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type ObjectReference = {
|
|
145
|
+
fromId: string;
|
|
146
|
+
toId: string;
|
|
147
|
+
fieldName: string;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type QueryDocumentsResponse = {
|
|
151
|
+
results: RawObject[];
|
|
152
|
+
cursor?: string;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export type RawDocument = {
|
|
156
|
+
documentId: string;
|
|
157
|
+
data: Uint8Array;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type RawObject = {
|
|
161
|
+
type?: string;
|
|
162
|
+
objectId: string;
|
|
163
|
+
document: RawDocument;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type QueryReferencesRequest = {
|
|
167
|
+
spaceId: string;
|
|
168
|
+
objectId: string;
|
|
169
|
+
referenceType: 'from' | 'to';
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type QueryReferencesResponse = {
|
|
173
|
+
references: ObjectReference[];
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Cloudflare Workers RPC returns objects/arrays/stubs that may need to be explicitly disposed.
|
|
178
|
+
*
|
|
179
|
+
* See: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
180
|
+
*/
|
|
181
|
+
export interface RpcDisposable {
|
|
182
|
+
/**
|
|
183
|
+
* Disposes the RPC stub / returned value and releases any server-side resources it references.
|
|
184
|
+
*/
|
|
185
|
+
[Symbol.dispose](): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Wraps a return type so that any non-primitive value is marked as disposable.
|
|
190
|
+
*
|
|
191
|
+
* This models Workers RPC behavior where any returned object (including arrays) gets a disposer added.
|
|
192
|
+
*/
|
|
193
|
+
export type RpcResult<T> = T extends object ? T & RpcDisposable : T;
|
package/src/edge/edge.ts
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { BaseError } from '@dxos/errors';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { SpaceId } from '@dxos/keys';
|
|
10
|
+
|
|
11
|
+
// TODO(burdon): Rename EdgerRouterEndpoint.
|
|
12
|
+
// If we would rename it, we need to be careful to not break composer production.
|
|
13
|
+
export enum EdgeService {
|
|
14
|
+
AUTOMERGE_REPLICATOR = 'automerge-replicator',
|
|
15
|
+
FEED_REPLICATOR = 'feed-replicator',
|
|
16
|
+
SWARM = 'swarm',
|
|
17
|
+
SIGNAL = 'signal',
|
|
18
|
+
STATUS = 'status',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type EdgeSuccess<T> = {
|
|
22
|
+
success: true;
|
|
23
|
+
data: T;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const _SerializedError = Schema.Struct({
|
|
27
|
+
name: Schema.optional(Schema.String),
|
|
28
|
+
message: Schema.optional(Schema.String),
|
|
29
|
+
context: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
30
|
+
stack: Schema.optional(Schema.String),
|
|
31
|
+
cause: Schema.optional(Schema.suspend(() => SerializedError)),
|
|
32
|
+
});
|
|
33
|
+
export interface SerializedError extends Schema.Schema.Type<typeof _SerializedError> {}
|
|
34
|
+
export const SerializedError: Schema.Schema<SerializedError, SerializedError, never> = _SerializedError;
|
|
35
|
+
|
|
36
|
+
export type EdgeErrorData = { type: string } & Record<string, any>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This is the shape of the error response from the Edge service,
|
|
40
|
+
* when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
|
|
41
|
+
*/
|
|
42
|
+
export type EdgeFailure = {
|
|
43
|
+
/**
|
|
44
|
+
* Branded Type.
|
|
45
|
+
*/
|
|
46
|
+
success: false;
|
|
47
|
+
/**
|
|
48
|
+
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
49
|
+
*/
|
|
50
|
+
message: string;
|
|
51
|
+
/**
|
|
52
|
+
* Cause Error captured on the EDGE service to aid debugging on the client.
|
|
53
|
+
*/
|
|
54
|
+
error?: SerializedError;
|
|
55
|
+
/**
|
|
56
|
+
* Information that can be used to retry the request such that it will succeed, for example:
|
|
57
|
+
* 1. { type: 'auth_required', challenge: string }
|
|
58
|
+
* Requires retrying the request with challenge signature included.
|
|
59
|
+
* 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
|
|
60
|
+
* Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
|
|
61
|
+
* if the user confirms.
|
|
62
|
+
* When data is returned simply retrying the request won't have any effect.
|
|
63
|
+
* EdgeHttpClient should parse well-known data into Error types and throw.
|
|
64
|
+
*/
|
|
65
|
+
data?: EdgeErrorData;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Represents a body response from the Edge service.
|
|
70
|
+
*/
|
|
71
|
+
export type EdgeEnvelope<T> = EdgeSuccess<T> | EdgeFailure;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Use this to create a response from the Edge service.
|
|
75
|
+
*/
|
|
76
|
+
export const EdgeResponse = Object.freeze({
|
|
77
|
+
success: <T>(data: T, status: number = 200): Response => {
|
|
78
|
+
invariant(status >= 200 && status < 300, 'Status code must be in the 2xx range');
|
|
79
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
80
|
+
return new Response(
|
|
81
|
+
JSON.stringify({
|
|
82
|
+
success: true,
|
|
83
|
+
data,
|
|
84
|
+
} satisfies EdgeSuccess<T>),
|
|
85
|
+
{
|
|
86
|
+
status,
|
|
87
|
+
headers,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
failure: ({
|
|
92
|
+
message,
|
|
93
|
+
error,
|
|
94
|
+
errorEncoded,
|
|
95
|
+
data,
|
|
96
|
+
shouldRetryAfter,
|
|
97
|
+
status = 500,
|
|
98
|
+
}: {
|
|
99
|
+
/**
|
|
100
|
+
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
101
|
+
*/
|
|
102
|
+
message: string;
|
|
103
|
+
/**
|
|
104
|
+
* Error that caused the failure.
|
|
105
|
+
* Useful for debugging.
|
|
106
|
+
*
|
|
107
|
+
* Use only one of the fields `error` or `errorEncoded`.s
|
|
108
|
+
*/
|
|
109
|
+
error?: Error;
|
|
110
|
+
/**
|
|
111
|
+
* Encoded Error that caused the failure.
|
|
112
|
+
* Useful for debugging.
|
|
113
|
+
*
|
|
114
|
+
* Use only one of the fields `error` or `errorEncoded`.
|
|
115
|
+
*/
|
|
116
|
+
errorEncoded?: SerializedError;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Information that can be used to retry the request such that it will succeed, for example:
|
|
120
|
+
* 1. { type: 'auth_required', challenge: string }
|
|
121
|
+
* Requires retrying the request with challenge signature included.
|
|
122
|
+
* 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
|
|
123
|
+
* Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
|
|
124
|
+
* if the user confirms.
|
|
125
|
+
* When data is returned simply retrying the request won't have any effect.
|
|
126
|
+
* EdgeHttpClient should parse well-known data into Error types and throw.
|
|
127
|
+
*/
|
|
128
|
+
data?: EdgeErrorData;
|
|
129
|
+
/**
|
|
130
|
+
* If provided, this request will be marked as retryable and the client will wait for the specified number of milliseconds before retrying.
|
|
131
|
+
* If not provided, the client will not retry the request.
|
|
132
|
+
*/
|
|
133
|
+
shouldRetryAfter?: number;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Status code of the response.
|
|
137
|
+
* @default 500
|
|
138
|
+
*/
|
|
139
|
+
status?: number;
|
|
140
|
+
}): Response => {
|
|
141
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
142
|
+
if (shouldRetryAfter) {
|
|
143
|
+
headers.set('Retry-After', String(shouldRetryAfter));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return new Response(
|
|
147
|
+
JSON.stringify({
|
|
148
|
+
success: false,
|
|
149
|
+
message,
|
|
150
|
+
data,
|
|
151
|
+
error: error ? ErrorCodec.encode(error) : errorEncoded,
|
|
152
|
+
} satisfies EdgeFailure),
|
|
153
|
+
{
|
|
154
|
+
status,
|
|
155
|
+
headers,
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
export type GetNotarizationResponseBody = {
|
|
162
|
+
awaitingNotarization: { credentials: string[] };
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type ExecuteWorkflowResponseBody = {
|
|
166
|
+
success: boolean;
|
|
167
|
+
reason?: string;
|
|
168
|
+
output?: any;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export type PostNotarizationRequestBody = {
|
|
172
|
+
credentials: string[];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type JoinSpaceRequest = {
|
|
176
|
+
invitationId: string;
|
|
177
|
+
identityKey: string;
|
|
178
|
+
/**
|
|
179
|
+
* Base64 encoded signed challenge.
|
|
180
|
+
* Used to verify the IdentityKey in case of `invitation.authMethod === Invitation.AuthMethod.KNOWN_PUBLIC_KEY`
|
|
181
|
+
*/
|
|
182
|
+
signature?: string;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export type JoinSpaceResponseBody = {
|
|
186
|
+
spaceMemberCredential: string;
|
|
187
|
+
spaceGenesisFeedKey: string;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export type RecoverIdentitySignature =
|
|
191
|
+
| string
|
|
192
|
+
// This is the format of the signature from the WebAuthn authenticator.
|
|
193
|
+
| {
|
|
194
|
+
signature: string;
|
|
195
|
+
clientDataJson: string;
|
|
196
|
+
authenticatorData: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type RecoverIdentityRequest = {
|
|
200
|
+
deviceKey: string;
|
|
201
|
+
controlFeedKey: string;
|
|
202
|
+
lookupKey?: string;
|
|
203
|
+
signature?: RecoverIdentitySignature;
|
|
204
|
+
token?: string;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export type RecoverIdentityResponseBody = {
|
|
208
|
+
identityKey: string;
|
|
209
|
+
haloSpaceKey: string;
|
|
210
|
+
genesisFeedKey: string;
|
|
211
|
+
deviceAuthCredential: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type CreateAgentRequestBody = {
|
|
215
|
+
identityKey: string;
|
|
216
|
+
haloSpaceId: SpaceId;
|
|
217
|
+
haloSpaceKey: string;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type CreateAgentResponseBody = {
|
|
221
|
+
deviceKey: string;
|
|
222
|
+
feedKey: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type GetAgentStatusResponseBody = {
|
|
226
|
+
agent: {
|
|
227
|
+
deviceKey?: string;
|
|
228
|
+
status: EdgeAgentStatus;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type UploadFunctionRequest = {
|
|
233
|
+
name?: string;
|
|
234
|
+
version: string;
|
|
235
|
+
ownerPublicKey: string;
|
|
236
|
+
entryPoint: string;
|
|
237
|
+
assets: Record<string, Uint8Array>;
|
|
238
|
+
/**
|
|
239
|
+
* Runtime in Edge that will be used to run the function.
|
|
240
|
+
* Runtime cannot be changed once the function was deployed.
|
|
241
|
+
* @default Runtime.WORKERS_FOR_PLATFORMS
|
|
242
|
+
*/
|
|
243
|
+
runtime?: FunctionRuntimeKind;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
|
|
248
|
+
*/
|
|
249
|
+
export const FunctionRuntimeKind = Schema.Enums({
|
|
250
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
251
|
+
WORKERS_FOR_PLATFORMS: 'WORKERS_FOR_PLATFORMS',
|
|
252
|
+
// https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
|
|
253
|
+
WORKER_LOADER: 'WORKER_LOADER',
|
|
254
|
+
});
|
|
255
|
+
export type FunctionRuntimeKind = Schema.Schema.Type<typeof FunctionRuntimeKind>;
|
|
256
|
+
|
|
257
|
+
export type UploadFunctionResponseBody = {
|
|
258
|
+
functionId: string;
|
|
259
|
+
version: string;
|
|
260
|
+
meta: {
|
|
261
|
+
key?: string;
|
|
262
|
+
name?: string;
|
|
263
|
+
description?: string;
|
|
264
|
+
/**
|
|
265
|
+
* JSON Schema for the input of the function.
|
|
266
|
+
*/
|
|
267
|
+
inputSchema?: object;
|
|
268
|
+
/**
|
|
269
|
+
* JSON Schema for the output of the function.
|
|
270
|
+
*/
|
|
271
|
+
outputSchema?: object;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export type CreateSpaceRequest = {
|
|
276
|
+
/**
|
|
277
|
+
* HEX encoded public key of the agent.
|
|
278
|
+
*/
|
|
279
|
+
agentKey: string;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export type CreateSpaceResponseBody = {
|
|
283
|
+
/**
|
|
284
|
+
* HEX encoded public key of the space.
|
|
285
|
+
*/
|
|
286
|
+
spaceKey: string;
|
|
287
|
+
spaceId: SpaceId;
|
|
288
|
+
automergeRoot: string;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export enum EdgeAgentStatus {
|
|
292
|
+
ACTIVE = 'active',
|
|
293
|
+
INACTIVE = 'inactive',
|
|
294
|
+
NOT_FOUND = 'not_found',
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export type EdgeAuthChallenge = {
|
|
298
|
+
type: 'auth_challenge';
|
|
299
|
+
challenge: string;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export enum OAuthProvider {
|
|
303
|
+
GOOGLE = 'google',
|
|
304
|
+
BLUESKY = 'bluesky',
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const InitiateOAuthFlowRequestSchema = Schema.Struct({
|
|
308
|
+
provider: Schema.Enums(OAuthProvider),
|
|
309
|
+
spaceId: Schema.String.pipe(Schema.filter(SpaceId.isValid)), // TODO(burdon): Use SpaceId.
|
|
310
|
+
accessTokenId: Schema.String,
|
|
311
|
+
scopes: Schema.mutable(Schema.Array(Schema.String)),
|
|
312
|
+
// Set to true if we don't want periodic token refreshes in background, for cases like account connect
|
|
313
|
+
noRefresh: Schema.optional(Schema.Boolean),
|
|
314
|
+
// Provider-specific (user handle or did for bluesky) hint for auth server resolution
|
|
315
|
+
loginHint: Schema.optional(Schema.String),
|
|
316
|
+
});
|
|
317
|
+
export type InitiateOAuthFlowRequest = Schema.Schema.Type<typeof InitiateOAuthFlowRequestSchema>;
|
|
318
|
+
|
|
319
|
+
export type InitiateOAuthFlowResponse = {
|
|
320
|
+
authUrl: string;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export type OAuthFlowResult =
|
|
324
|
+
| { success: true; accessToken: string; accessTokenId: string }
|
|
325
|
+
| { success: false; reason: string };
|
|
326
|
+
|
|
327
|
+
export enum EdgeWebsocketProtocol {
|
|
328
|
+
V0 = 'edge-ws-v0',
|
|
329
|
+
/**
|
|
330
|
+
* Enables message framing and muxing by service-id.
|
|
331
|
+
*/
|
|
332
|
+
V1 = 'edge-ws-v1',
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// TODO(mykola): Reconcile with type in EDGE repo.
|
|
336
|
+
export type EdgeStatus = {
|
|
337
|
+
problems: string[];
|
|
338
|
+
agent: {
|
|
339
|
+
agentStatus?: string;
|
|
340
|
+
agentKey?: string;
|
|
341
|
+
haloSpaceId?: SpaceId;
|
|
342
|
+
fetchError?: string;
|
|
343
|
+
};
|
|
344
|
+
router: {
|
|
345
|
+
connectedDevices?: {
|
|
346
|
+
peerKey: string;
|
|
347
|
+
topics: string[];
|
|
348
|
+
}[];
|
|
349
|
+
metrics?: {
|
|
350
|
+
sentMessages: number;
|
|
351
|
+
receivedMessages: number;
|
|
352
|
+
sentBytes: number;
|
|
353
|
+
receivedBytes: number;
|
|
354
|
+
failedMessages: number;
|
|
355
|
+
failedBytes: number;
|
|
356
|
+
};
|
|
357
|
+
fetchError?: string;
|
|
358
|
+
};
|
|
359
|
+
spaces: {
|
|
360
|
+
data: Record<SpaceId, { diagnostics?: any & { redFlags: string[] }; fetchError?: string }>;
|
|
361
|
+
fetchError?: string;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
//
|
|
366
|
+
// Space import/export.
|
|
367
|
+
//
|
|
368
|
+
|
|
369
|
+
export type ImportBundleRequest = {
|
|
370
|
+
bundle: {
|
|
371
|
+
/**
|
|
372
|
+
* DocumentId.
|
|
373
|
+
*/
|
|
374
|
+
documentId: string;
|
|
375
|
+
/**
|
|
376
|
+
* Encoded mutation.
|
|
377
|
+
*/
|
|
378
|
+
mutation: string;
|
|
379
|
+
/**
|
|
380
|
+
* Heads of the document.
|
|
381
|
+
*/
|
|
382
|
+
heads: string[];
|
|
383
|
+
}[];
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export type ExportBundleRequest = {
|
|
387
|
+
/**
|
|
388
|
+
* DocumentId -> Heads (decoded heads since which we want to export).
|
|
389
|
+
*/
|
|
390
|
+
docHeads: Record<string, string[]>;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export type ExportBundleResponse = {
|
|
394
|
+
bundle: {
|
|
395
|
+
/**
|
|
396
|
+
* DocumentId.
|
|
397
|
+
*/
|
|
398
|
+
documentId: string;
|
|
399
|
+
/**
|
|
400
|
+
* Encoded mutation.
|
|
401
|
+
*/
|
|
402
|
+
mutation: string;
|
|
403
|
+
}[];
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
export const DocumentCodec = Object.freeze({
|
|
407
|
+
encode: (doc: Uint8Array) => Buffer.from(doc).toString('base64'),
|
|
408
|
+
decode: (doc: string) => new Uint8Array(Buffer.from(doc, 'base64')),
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const MAX_ERROR_DEPTH = 3;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Codec for serializing and deserializing Edge Errors.
|
|
415
|
+
*/
|
|
416
|
+
export const ErrorCodec = Object.freeze({
|
|
417
|
+
encode: (err: Error, depth: number = 0): SerializedError => ({
|
|
418
|
+
name: 'name' in err ? err.name : (err as any).code || 'Error',
|
|
419
|
+
message: err.message,
|
|
420
|
+
stack: err.stack,
|
|
421
|
+
cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
|
|
422
|
+
}),
|
|
423
|
+
decode: (serializedError: SerializedError, depth: number = 0): Error => {
|
|
424
|
+
let err: Error;
|
|
425
|
+
if (typeof serializedError.name === 'string') {
|
|
426
|
+
err = new BaseError(serializedError.name, {
|
|
427
|
+
message: serializedError.message ?? 'Unknown error',
|
|
428
|
+
cause:
|
|
429
|
+
serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
430
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
431
|
+
: undefined,
|
|
432
|
+
context: serializedError.context,
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
if (serializedError.stack) {
|
|
436
|
+
Object.defineProperty(err, 'stack', {
|
|
437
|
+
value: serializedError.stack,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
err = new Error(serializedError.message ?? 'Unknown error', {
|
|
442
|
+
cause:
|
|
443
|
+
serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
444
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
445
|
+
: undefined,
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
if (serializedError.stack) {
|
|
449
|
+
Object.defineProperty(err, 'stack', {
|
|
450
|
+
value: serializedError.stack,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return err;
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Codec for serializing and deserializing Edge unhandled HTTP errors.
|
|
461
|
+
*/
|
|
462
|
+
export const EdgeHttpErrorCodec = Object.freeze({
|
|
463
|
+
encode: (err: Error): Response =>
|
|
464
|
+
new Response(
|
|
465
|
+
JSON.stringify({
|
|
466
|
+
error: ErrorCodec.encode(err),
|
|
467
|
+
}),
|
|
468
|
+
{ status: 500 },
|
|
469
|
+
),
|
|
470
|
+
|
|
471
|
+
decode: async (response: Response): Promise<Error | undefined> => {
|
|
472
|
+
if (response.headers.get('Content-Type') !== 'application/json') {
|
|
473
|
+
const body = await response.clone().text();
|
|
474
|
+
return new Error(body.slice(0, 256));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const body = await response.clone().json();
|
|
478
|
+
if (!('error' in body)) {
|
|
479
|
+
return undefined;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return ErrorCodec.decode(body.error);
|
|
483
|
+
},
|
|
484
|
+
});
|