@dxos/protocols 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe
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 +76 -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/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 +1 -1
- package/dist/src/buf/proto/gen/dxos/config_pb.js +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 +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.js +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/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 +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.js +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/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-error.d.ts +11 -7
- package/dist/src/edge-error.d.ts.map +1 -1
- package/dist/src/edge-error.js +22 -54
- package/dist/src/edge-error.js.map +1 -1
- package/dist/src/edge.d.ts +93 -6
- package/dist/src/edge.d.ts.map +1 -1
- package/dist/src/edge.js +109 -3
- package/dist/src/edge.js.map +1 -1
- package/dist/src/index.d.ts +8 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -6
- 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/proto/gen/dxos/client/services.d.ts +30 -3
- package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.js +9 -6
- package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/src/proto/gen/index.d.ts +1 -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/queue.d.ts +9 -0
- package/dist/src/queue.d.ts.map +1 -1
- package/dist/src/queue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -16
- package/src/FunctionProtocol.ts +100 -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/services_pb.ts +84 -29
- package/src/buf/proto/gen/dxos/config_pb.ts +3 -3
- 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 +3 -3
- package/src/buf/proto/gen/dxos/echo/service_pb.ts +3 -3
- 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 +3 -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-error.ts +23 -71
- package/src/edge.ts +205 -7
- package/src/index.ts +8 -7
- package/src/indexing.ts +1 -1
- package/src/invitation.ts +1 -1
- package/src/proto/dxos/client/services.proto +20 -3
- package/src/proto/gen/dxos/client/services.ts +30 -3
- package/src/proto/gen/index.ts +2 -1
- package/src/queue.ts +13 -0
package/src/edge.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
+
import { BaseError } from '@dxos/errors';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
7
9
|
import { SpaceId } from '@dxos/keys';
|
|
8
10
|
|
|
9
11
|
// TODO(burdon): Rename EdgerRouterEndpoint.
|
|
@@ -16,20 +18,43 @@ export enum EdgeService {
|
|
|
16
18
|
STATUS = 'status',
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export type
|
|
21
|
+
export type EdgeSuccess<T> = {
|
|
20
22
|
success: true;
|
|
21
23
|
data: T;
|
|
22
24
|
};
|
|
23
25
|
|
|
26
|
+
export type SerializedError = {
|
|
27
|
+
code?: string;
|
|
28
|
+
message?: string;
|
|
29
|
+
context?: Record<string, unknown>;
|
|
30
|
+
stack?: string;
|
|
31
|
+
cause?: SerializedError;
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
export type EdgeErrorData = { type: string } & Record<string, any>;
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
/**
|
|
37
|
+
* This is the shape of the error response from the Edge service,
|
|
38
|
+
* when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
|
|
39
|
+
*/
|
|
40
|
+
// TODO(dmaretskyi): Refactor this type to just be { success: false, error: SerializedError }
|
|
41
|
+
// reason -> error.message
|
|
42
|
+
// cause -> error.cause
|
|
43
|
+
// errorData.type -> error.code
|
|
44
|
+
// ...errorData -> error.context
|
|
45
|
+
export type EdgeFailure = {
|
|
46
|
+
/**
|
|
47
|
+
* Branded Type.
|
|
48
|
+
*/
|
|
28
49
|
success: false;
|
|
29
50
|
/**
|
|
30
51
|
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
31
52
|
*/
|
|
32
53
|
reason: string;
|
|
54
|
+
/**
|
|
55
|
+
* Cause Error captured on the EDGE service to aid debugging on the client.
|
|
56
|
+
*/
|
|
57
|
+
cause?: SerializedError;
|
|
33
58
|
/**
|
|
34
59
|
* Information that can be used to retry the request such that it will succeed, for example:
|
|
35
60
|
* 1. { type: 'auth_required', challenge: string }
|
|
@@ -43,7 +68,87 @@ export type EdgeHttpFailure = {
|
|
|
43
68
|
errorData?: EdgeErrorData;
|
|
44
69
|
};
|
|
45
70
|
|
|
46
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Represents a body response from the Edge service.
|
|
73
|
+
*/
|
|
74
|
+
export type EdgeBody<T> = EdgeSuccess<T> | EdgeFailure;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Use this to create a response from the Edge service.
|
|
78
|
+
*/
|
|
79
|
+
export const EdgeResponse = Object.freeze({
|
|
80
|
+
success: <T>(data: T, status: number = 200): Response => {
|
|
81
|
+
invariant(status >= 200 && status < 300, 'Status code must be in the 2xx range');
|
|
82
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
83
|
+
return new Response(
|
|
84
|
+
JSON.stringify({
|
|
85
|
+
success: true,
|
|
86
|
+
data,
|
|
87
|
+
} satisfies EdgeSuccess<T>),
|
|
88
|
+
{
|
|
89
|
+
status,
|
|
90
|
+
headers,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
failure: ({
|
|
95
|
+
reason,
|
|
96
|
+
cause,
|
|
97
|
+
errorData,
|
|
98
|
+
shouldRetryAfter,
|
|
99
|
+
status = 500,
|
|
100
|
+
}: {
|
|
101
|
+
/**
|
|
102
|
+
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
103
|
+
*/
|
|
104
|
+
reason: string;
|
|
105
|
+
/**
|
|
106
|
+
* Error that caused the failure.
|
|
107
|
+
* Useful for debugging.
|
|
108
|
+
*/
|
|
109
|
+
cause?: Error;
|
|
110
|
+
/**
|
|
111
|
+
* Information that can be used to retry the request such that it will succeed, for example:
|
|
112
|
+
* 1. { type: 'auth_required', challenge: string }
|
|
113
|
+
* Requires retrying the request with challenge signature included.
|
|
114
|
+
* 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
|
|
115
|
+
* Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
|
|
116
|
+
* if the user confirms.
|
|
117
|
+
* When errorData is returned simply retrying the request won't have any effect.
|
|
118
|
+
* EdgeHttpClient should parse well-known errorData into Error types and throw.
|
|
119
|
+
*/
|
|
120
|
+
errorData?: EdgeErrorData;
|
|
121
|
+
/**
|
|
122
|
+
* If provided, this request will be marked as retryable and the client will wait for the specified number of milliseconds before retrying.
|
|
123
|
+
* If not provided, the client will not retry the request.
|
|
124
|
+
*/
|
|
125
|
+
shouldRetryAfter?: number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Status code of the response.
|
|
129
|
+
* @default 500
|
|
130
|
+
*/
|
|
131
|
+
status?: number;
|
|
132
|
+
}): Response => {
|
|
133
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
134
|
+
if (shouldRetryAfter) {
|
|
135
|
+
headers.set('Retry-After', String(shouldRetryAfter));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return new Response(
|
|
139
|
+
JSON.stringify({
|
|
140
|
+
success: false,
|
|
141
|
+
reason,
|
|
142
|
+
errorData,
|
|
143
|
+
cause: cause ? ErrorCodec.encode(cause) : undefined,
|
|
144
|
+
} satisfies EdgeFailure),
|
|
145
|
+
{
|
|
146
|
+
status,
|
|
147
|
+
headers,
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
});
|
|
47
152
|
|
|
48
153
|
export type GetNotarizationResponseBody = {
|
|
49
154
|
awaitingNotarization: { credentials: string[] };
|
|
@@ -122,8 +227,26 @@ export type UploadFunctionRequest = {
|
|
|
122
227
|
ownerPublicKey: string;
|
|
123
228
|
entryPoint: string;
|
|
124
229
|
assets: Record<string, Uint8Array>;
|
|
230
|
+
/**
|
|
231
|
+
* Runtime in Edge that will be used to run the function.
|
|
232
|
+
* Runtime cannot be changed once the function was deployed.
|
|
233
|
+
* @default Runtime.WORKERS_FOR_PLATFORMS
|
|
234
|
+
*/
|
|
235
|
+
runtime?: Runtime;
|
|
125
236
|
};
|
|
126
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
|
|
240
|
+
*/
|
|
241
|
+
export enum Runtime {
|
|
242
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
243
|
+
WORKERS_FOR_PLATFORMS = 'WORKERS_FOR_PLATFORMS',
|
|
244
|
+
// https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
|
|
245
|
+
WORKER_LOADER = 'WORKER_LOADER',
|
|
246
|
+
// Local worker dispatcher for testing.
|
|
247
|
+
TEST = 'TEST',
|
|
248
|
+
}
|
|
249
|
+
|
|
127
250
|
export type UploadFunctionResponseBody = {
|
|
128
251
|
functionId: string;
|
|
129
252
|
version: string;
|
|
@@ -273,7 +396,82 @@ export type ExportBundleResponse = {
|
|
|
273
396
|
}[];
|
|
274
397
|
};
|
|
275
398
|
|
|
276
|
-
export const DocumentCodec = {
|
|
399
|
+
export const DocumentCodec = Object.freeze({
|
|
277
400
|
encode: (doc: Uint8Array) => Buffer.from(doc).toString('base64'),
|
|
278
401
|
decode: (doc: string) => new Uint8Array(Buffer.from(doc, 'base64')),
|
|
279
|
-
};
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const MAX_ERROR_DEPTH = 3;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Codec for serializing and deserializing Edge Errors.
|
|
408
|
+
*/
|
|
409
|
+
export const ErrorCodec = Object.freeze({
|
|
410
|
+
encode: (err: Error, depth: number = 0): SerializedError => ({
|
|
411
|
+
code: 'code' in err ? (err as any).code : undefined,
|
|
412
|
+
message: err.message,
|
|
413
|
+
stack: err.stack,
|
|
414
|
+
cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
|
|
415
|
+
}),
|
|
416
|
+
decode: (serializedError: SerializedError, depth: number = 0): Error => {
|
|
417
|
+
let err: Error;
|
|
418
|
+
if (typeof serializedError.code === 'string') {
|
|
419
|
+
err = new BaseError(serializedError.code, {
|
|
420
|
+
message: serializedError.message ?? 'Unknown error',
|
|
421
|
+
cause:
|
|
422
|
+
serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
423
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
424
|
+
: undefined,
|
|
425
|
+
context: serializedError.context,
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
if (serializedError.stack) {
|
|
429
|
+
Object.defineProperty(err, 'stack', {
|
|
430
|
+
value: serializedError.stack,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
} else {
|
|
434
|
+
err = new Error(serializedError.message ?? 'Unknown error', {
|
|
435
|
+
cause:
|
|
436
|
+
serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
437
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
438
|
+
: undefined,
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
if (serializedError.stack) {
|
|
442
|
+
Object.defineProperty(err, 'stack', {
|
|
443
|
+
value: serializedError.stack,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return err;
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Codec for serializing and deserializing Edge unhandled HTTP errors.
|
|
454
|
+
*/
|
|
455
|
+
export const EdgeHttpErrorCodec = Object.freeze({
|
|
456
|
+
encode: (err: Error): Response =>
|
|
457
|
+
new Response(
|
|
458
|
+
JSON.stringify({
|
|
459
|
+
error: ErrorCodec.encode(err),
|
|
460
|
+
}),
|
|
461
|
+
{ status: 500 },
|
|
462
|
+
),
|
|
463
|
+
|
|
464
|
+
decode: async (response: Response): Promise<Error | undefined> => {
|
|
465
|
+
if (response.headers.get('Content-Type') !== 'application/json') {
|
|
466
|
+
const body = await response.clone().text();
|
|
467
|
+
return new Error(body.slice(0, 256));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const body = await response.clone().json();
|
|
471
|
+
if (!('error' in body)) {
|
|
472
|
+
return undefined;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return ErrorCodec.decode(body.error);
|
|
476
|
+
},
|
|
477
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export * from './automerge.js';
|
|
6
|
+
export * from './edge-error.js';
|
|
7
|
+
export * from './edge.js';
|
|
5
8
|
export * from './errors/index.js';
|
|
6
9
|
export * from './indexing.js';
|
|
7
|
-
export * from './storage.js';
|
|
8
|
-
export * from './tracing.js';
|
|
9
|
-
export type * from './types.js';
|
|
10
|
-
export * from './query.js';
|
|
11
10
|
export * from './profile-archive.js';
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './edge.js';
|
|
11
|
+
export * from './query.js';
|
|
14
12
|
export * from './queue.js';
|
|
15
13
|
export * from './space-archive.js';
|
|
16
|
-
export * from './
|
|
14
|
+
export * from './storage.js';
|
|
15
|
+
export * from './tracing.js';
|
|
16
|
+
export type * from './types.js';
|
|
17
|
+
export * as FunctionProtocol from './FunctionProtocol.js';
|
package/src/indexing.ts
CHANGED
package/src/invitation.ts
CHANGED
|
@@ -596,9 +596,26 @@ service EdgeAgentService {
|
|
|
596
596
|
rpc QueryAgentStatus(google.protobuf.Empty) returns (stream QueryAgentStatusResponse);
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
599
|
+
message EdgeStatus {
|
|
600
|
+
enum ConnectionState {
|
|
601
|
+
NOT_CONNECTED = 0;
|
|
602
|
+
CONNECTED = 1;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
ConnectionState state = 1;
|
|
606
|
+
/** Latency in ms */
|
|
607
|
+
int32 rtt = 2;
|
|
608
|
+
|
|
609
|
+
/** How long the connection has been up */
|
|
610
|
+
int32 uptime = 3;
|
|
611
|
+
|
|
612
|
+
/** Upload rate in bytes per second */
|
|
613
|
+
int32 rate_bytes_up = 4;
|
|
614
|
+
/** Download rate in bytes per second */
|
|
615
|
+
int32 rate_bytes_down = 5;
|
|
616
|
+
|
|
617
|
+
int32 messages_sent = 6;
|
|
618
|
+
int32 messages_received = 7;
|
|
602
619
|
}
|
|
603
620
|
|
|
604
621
|
message QueryEdgeStatusResponse {
|
|
@@ -1399,9 +1399,36 @@ export interface EdgeAgentService {
|
|
|
1399
1399
|
* Defined in:
|
|
1400
1400
|
* {@link file://./../../../dxos/client/services.proto}
|
|
1401
1401
|
*/
|
|
1402
|
-
export
|
|
1403
|
-
|
|
1404
|
-
|
|
1402
|
+
export interface EdgeStatus {
|
|
1403
|
+
state: EdgeStatus.ConnectionState;
|
|
1404
|
+
/**
|
|
1405
|
+
* Latency in ms
|
|
1406
|
+
*/
|
|
1407
|
+
rtt: number;
|
|
1408
|
+
/**
|
|
1409
|
+
* How long the connection has been up
|
|
1410
|
+
*/
|
|
1411
|
+
uptime: number;
|
|
1412
|
+
/**
|
|
1413
|
+
* Upload rate in bytes per second
|
|
1414
|
+
*/
|
|
1415
|
+
rateBytesUp: number;
|
|
1416
|
+
/**
|
|
1417
|
+
* Download rate in bytes per second
|
|
1418
|
+
*/
|
|
1419
|
+
rateBytesDown: number;
|
|
1420
|
+
messagesSent: number;
|
|
1421
|
+
messagesReceived: number;
|
|
1422
|
+
}
|
|
1423
|
+
export namespace EdgeStatus {
|
|
1424
|
+
/**
|
|
1425
|
+
* Defined in:
|
|
1426
|
+
* {@link file://./../../../dxos/client/services.proto}
|
|
1427
|
+
*/
|
|
1428
|
+
export enum ConnectionState {
|
|
1429
|
+
NOT_CONNECTED = 0,
|
|
1430
|
+
CONNECTED = 1
|
|
1431
|
+
}
|
|
1405
1432
|
}
|
|
1406
1433
|
/**
|
|
1407
1434
|
* Defined in:
|