@dxos/protocols 0.8.4-main.406dc2a → 0.8.4-main.40e3dcdf1b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/FeedProtocol.d.ts +528 -0
- package/dist/src/FeedProtocol.d.ts.map +1 -0
- package/dist/src/FeedProtocol.js +237 -0
- package/dist/src/FeedProtocol.js.map +1 -0
- 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/buf/proto/gen/dxos/client/queue_pb.d.ts +231 -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 +44 -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 +5 -1
- 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 +5 -1
- package/dist/src/buf/proto/gen/dxos/client/services_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts +12 -2
- 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 +1 -1
- 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 +55 -9
- 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 +15 -5
- package/dist/src/buf/proto/gen/dxos/echo/service_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/google_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/google_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts +1 -0
- package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/iframe_pb.js.map +1 -1
- package/dist/src/buf/proto/gen/dxos/tracing_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/tracing_pb.js.map +1 -1
- package/dist/src/codec.test.js +1 -1
- package/dist/src/edge/EdgeFunctionEnv.d.ts +108 -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.d.ts → edge/edge.d.ts} +117 -10
- package/dist/src/edge/edge.d.ts.map +1 -0
- package/dist/src/edge/edge.js +169 -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 -20
- package/dist/src/errors/base-errors.js.map +1 -1
- package/dist/src/errors/encoding.d.ts +2 -2
- package/dist/src/errors/encoding.d.ts.map +1 -1
- package/dist/src/errors/encoding.js +1 -1
- package/dist/src/errors/errors.d.ts +619 -42
- package/dist/src/errors/errors.d.ts.map +1 -1
- package/dist/src/errors/errors.js +50 -104
- package/dist/src/errors/errors.js.map +1 -1
- package/dist/src/errors/errors.test.js +2 -2
- package/dist/src/errors/errors.test.js.map +1 -1
- package/dist/src/errors/helpers.d.ts +9 -5
- 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/errors/index.d.ts +5 -5
- package/dist/src/errors/index.js +5 -5
- package/dist/src/feed-replication.d.ts.map +1 -1
- package/dist/src/index.d.ts +12 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/indexing.test.js +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 +982 -854
- package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.js +95 -94
- package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/src/proto/gen/dxos/devtools/host.d.ts +31 -31
- package/dist/src/proto/gen/dxos/devtools/host.d.ts.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 +34 -8
- package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
- package/dist/src/proto/gen/google/protobuf.d.ts +326 -40
- package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/src/proto/gen/google/protobuf.js +127 -1
- package/dist/src/proto/gen/google/protobuf.js.map +1 -1
- package/dist/src/proto/gen/index.d.ts +33 -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 +2 -2
- package/dist/src/proto/index.js +1 -1
- package/dist/src/proto/types.d.ts +1 -1
- package/dist/src/types.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -15
- package/src/FeedProtocol.ts +320 -0
- package/src/FunctionProtocol.ts +102 -0
- package/src/buf/proto/gen/dxos/agent/dashboard_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/agent/echo-proxy_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/agent/epoch_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/agent/functions_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/bot_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/client/invitation_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/client/logging_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/client/queue_pb.ts +280 -0
- package/src/buf/proto/gen/dxos/client/services_pb.ts +7 -2
- package/src/buf/proto/gen/dxos/config_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/devtools/diagnostics_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/devtools/host_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/devtools/swarm_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/blob_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/feed_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/filter_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/indexing_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/metadata_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/model/document_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/model/messenger_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/model/text_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/object_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/query_pb.ts +16 -4
- package/src/buf/proto/gen/dxos/echo/service_pb.ts +68 -16
- package/src/buf/proto/gen/dxos/echo/snapshot_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/echo/timeframe_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/edge/calls_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/edge/messenger_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/edge/signal_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/error_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/field_options_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/google_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/gravity_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/credentials/auth_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/credentials/greet_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/credentials/identity_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/credentials_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/invitations_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/keyring_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/keys_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/halo/signed_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/iframe_pb.ts +2 -1
- package/src/buf/proto/gen/dxos/keys_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/bridge_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/broadcast_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/messaging_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/muxer_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/presence_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/protocol_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/replicator_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/signal_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/swarm_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/control_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/registry_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/rpc_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/service/agentmanager_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/service/publisher_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/service/supervisor_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/service/tunnel_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/tracing_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/type_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/value_pb.ts +1 -1
- package/src/buf/proto/gen/example/testing/data_pb.ts +1 -1
- package/src/buf/proto/gen/example/testing/rpc_pb.ts +1 -1
- package/src/codec.test.ts +1 -1
- package/src/edge/EdgeFunctionEnv.ts +187 -0
- package/src/edge/edge.ts +493 -0
- package/src/edge/errors.ts +85 -0
- package/src/edge/index.ts +7 -0
- package/src/errors/base-errors.ts +4 -22
- package/src/errors/encoding.ts +2 -2
- package/src/errors/errors.test.ts +2 -2
- package/src/errors/errors.ts +57 -123
- package/src/errors/helpers.ts +6 -7
- package/src/errors/index.ts +5 -5
- package/src/feed-replication.ts +1 -0
- package/src/index.ts +12 -12
- package/src/indexing.test.ts +1 -1
- package/src/messenger.ts +22 -0
- package/src/proto/dxos/client/queue.proto +78 -0
- package/src/proto/dxos/client/services.proto +1 -0
- package/src/proto/dxos/config.proto +1 -1
- package/src/proto/dxos/echo/query.proto +4 -1
- package/src/proto/dxos/echo/service.proto +27 -6
- package/src/proto/dxos/iframe.proto +1 -0
- package/src/proto/gen/dxos/client/services.ts +982 -854
- package/src/proto/gen/dxos/devtools/host.ts +31 -31
- package/src/proto/gen/dxos/echo/query.ts +17 -1
- package/src/proto/gen/dxos/echo/service.ts +33 -8
- package/src/proto/gen/google/protobuf.ts +326 -40
- package/src/proto/gen/index.ts +34 -1
- package/src/proto/index.ts +2 -2
- package/src/proto/types.ts +1 -1
- package/src/types.ts +2 -2
- 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 -102
- package/dist/src/edge-error.js.map +0 -1
- package/dist/src/edge.d.ts.map +0 -1
- package/dist/src/edge.js +0 -49
- 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/dist/src/queue.d.ts +0 -28
- package/dist/src/queue.d.ts.map +0 -1
- package/dist/src/queue.js +0 -8
- package/dist/src/queue.js.map +0 -1
- package/src/edge-error.ts +0 -134
- package/src/edge.ts +0 -279
- package/src/query.ts +0 -8
- package/src/queue.ts +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing_pb.js","sourceRoot":"","sources":["../../../../../../src/buf/proto/gen/dxos/tracing_pb.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"tracing_pb.js","sourceRoot":"","sources":["../../../../../../src/buf/proto/gen/dxos/tracing_pb.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,gFAAgF;AAChF,oBAAoB;AAGpB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE5F,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAY,aAAa,CACrD,QAAQ,CAAC,o+EAAo+E,EAAE,CAAC,2BAA2B,EAAE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/dist/src/codec.test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
|
-
import { schema } from
|
|
5
|
+
import { schema } from "./proto/index.js";
|
|
6
6
|
describe('Codec', () => {
|
|
7
7
|
test('encodes and decodes messages', async () => {
|
|
8
8
|
const codec = schema.getCodecForType('example.testing.data.TestItemMutation');
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type SpaceId } from '@dxos/keys';
|
|
2
|
+
import type * as FeedProtocol from '../FeedProtocol';
|
|
3
|
+
import { type CreateDocumentRequest, type CreateDocumentResponse } from '../proto/gen/dxos/echo/service';
|
|
4
|
+
import { type QueryRequest, type QueryResponse } from '../proto/gen/dxos/echo/query';
|
|
5
|
+
/**
|
|
6
|
+
* Environment available to the function running on Cloudflare.
|
|
7
|
+
*/
|
|
8
|
+
export interface Env {
|
|
9
|
+
QUEUE_SERVICE: QueueService;
|
|
10
|
+
DATA_SERVICE: DataService;
|
|
11
|
+
FUNCTIONS_AI_SERVICE: FunctionsAiService;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Use to trace the execution across multiple services.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Currently unused in functions.
|
|
17
|
+
*/
|
|
18
|
+
export interface TraceContext {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Database API for other CF services like functions.
|
|
22
|
+
*/
|
|
23
|
+
export interface DataService {
|
|
24
|
+
getSpaceMeta(ctx: TraceContext, spaceId: SpaceId): Promise<RpcResult<SpaceMeta | undefined>>;
|
|
25
|
+
getDocument(ctx: TraceContext, spaceId: SpaceId, documentId: string): Promise<RpcResult<RawDocument | undefined>>;
|
|
26
|
+
execQuery(ctx: TraceContext, request: QueryRequest): Promise<RpcResult<QueryResponse>>;
|
|
27
|
+
createDocument(ctx: TraceContext, request: CreateDocumentRequest): Promise<RpcResult<CreateDocumentResponse>>;
|
|
28
|
+
changeDocument(ctx: TraceContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export interface QueueService {
|
|
31
|
+
queryQueue: (ctx: TraceContext, request: FeedProtocol.QueryQueueRequest) => Promise<RpcResult<FeedProtocol.QueryResult>>;
|
|
32
|
+
insertIntoQueue: (ctx: TraceContext, request: FeedProtocol.InsertIntoQueueRequest) => Promise<RpcResult<RpcDisposable>>;
|
|
33
|
+
deleteFromQueue: (ctx: TraceContext, request: FeedProtocol.DeleteFromQueueRequest) => Promise<RpcResult<RpcDisposable>>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* FunctionsAiService API for other CF services like functions.
|
|
37
|
+
*/
|
|
38
|
+
export interface FunctionsAiService {
|
|
39
|
+
/**
|
|
40
|
+
* Enables proxying HTTP requests to the AI service from other workers.
|
|
41
|
+
*/
|
|
42
|
+
fetch(request: Request): Promise<RpcResult<Response>>;
|
|
43
|
+
}
|
|
44
|
+
export type ObjectDocumentJson = {
|
|
45
|
+
type?: string;
|
|
46
|
+
objectId: string;
|
|
47
|
+
documentId: string;
|
|
48
|
+
/** Base64 encoding of a document. */
|
|
49
|
+
document: string;
|
|
50
|
+
};
|
|
51
|
+
export type SpaceMeta = {
|
|
52
|
+
spaceKey: string;
|
|
53
|
+
rootDocumentId: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* TODO(yaroslav): make Indexer return EchoObject after create() can properly reconstruct an object
|
|
57
|
+
* from this structure (meta, id and type aren't handled properly)
|
|
58
|
+
*/
|
|
59
|
+
export type ObjectSnapshot = {
|
|
60
|
+
type?: string;
|
|
61
|
+
documentId: string;
|
|
62
|
+
objectId: string;
|
|
63
|
+
object: unknown;
|
|
64
|
+
};
|
|
65
|
+
export type ObjectReference = {
|
|
66
|
+
fromId: string;
|
|
67
|
+
toId: string;
|
|
68
|
+
fieldName: string;
|
|
69
|
+
};
|
|
70
|
+
export type QueryDocumentsResponse = {
|
|
71
|
+
results: RawObject[];
|
|
72
|
+
cursor?: string;
|
|
73
|
+
};
|
|
74
|
+
export type RawDocument = {
|
|
75
|
+
documentId: string;
|
|
76
|
+
data: Uint8Array;
|
|
77
|
+
};
|
|
78
|
+
export type RawObject = {
|
|
79
|
+
type?: string;
|
|
80
|
+
objectId: string;
|
|
81
|
+
document: RawDocument;
|
|
82
|
+
};
|
|
83
|
+
export type QueryReferencesRequest = {
|
|
84
|
+
spaceId: string;
|
|
85
|
+
objectId: string;
|
|
86
|
+
referenceType: 'from' | 'to';
|
|
87
|
+
};
|
|
88
|
+
export type QueryReferencesResponse = {
|
|
89
|
+
references: ObjectReference[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Cloudflare Workers RPC returns objects/arrays/stubs that may need to be explicitly disposed.
|
|
93
|
+
*
|
|
94
|
+
* See: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
95
|
+
*/
|
|
96
|
+
export interface RpcDisposable {
|
|
97
|
+
/**
|
|
98
|
+
* Disposes the RPC stub / returned value and releases any server-side resources it references.
|
|
99
|
+
*/
|
|
100
|
+
[Symbol.dispose](): void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Wraps a return type so that any non-primitive value is marked as disposable.
|
|
104
|
+
*
|
|
105
|
+
* This models Workers RPC behavior where any returned object (including arrays) gets a disposer added.
|
|
106
|
+
*/
|
|
107
|
+
export type RpcResult<T> = T extends object ? T & RpcDisposable : T;
|
|
108
|
+
//# sourceMappingURL=EdgeFunctionEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeFunctionEnv.d.ts","sourceRoot":"","sources":["../../../src/edge/EdgeFunctionEnv.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,KAAK,YAAY,MAAM,iBAAiB,CAAC;AACrD,O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AM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,aAAa,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeFunctionEnv.js","sourceRoot":"","sources":["../../../src/edge/EdgeFunctionEnv.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE"}
|
|
@@ -2,24 +2,52 @@ import * as Schema from 'effect/Schema';
|
|
|
2
2
|
import { SpaceId } from '@dxos/keys';
|
|
3
3
|
export declare enum EdgeService {
|
|
4
4
|
AUTOMERGE_REPLICATOR = "automerge-replicator",
|
|
5
|
+
/**
|
|
6
|
+
* Control feed replicator (hypercore append only logs) for the space.
|
|
7
|
+
*/
|
|
5
8
|
FEED_REPLICATOR = "feed-replicator",
|
|
9
|
+
/**
|
|
10
|
+
* Feed replicator (ordered data list) for the space.
|
|
11
|
+
*/
|
|
12
|
+
QUEUE_REPLICATOR = "queue-replicator",
|
|
6
13
|
SWARM = "swarm",
|
|
7
14
|
SIGNAL = "signal",
|
|
8
15
|
STATUS = "status"
|
|
9
16
|
}
|
|
10
|
-
export type
|
|
17
|
+
export type EdgeSuccess<T> = {
|
|
11
18
|
success: true;
|
|
12
19
|
data: T;
|
|
13
20
|
};
|
|
21
|
+
declare const _SerializedError: Schema.Struct<{
|
|
22
|
+
name: Schema.optional<typeof Schema.String>;
|
|
23
|
+
message: Schema.optional<typeof Schema.String>;
|
|
24
|
+
context: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
25
|
+
stack: Schema.optional<typeof Schema.String>;
|
|
26
|
+
cause: Schema.optional<Schema.suspend<SerializedError, SerializedError, never>>;
|
|
27
|
+
}>;
|
|
28
|
+
export interface SerializedError extends Schema.Schema.Type<typeof _SerializedError> {
|
|
29
|
+
}
|
|
30
|
+
export declare const SerializedError: Schema.Schema<SerializedError, SerializedError, never>;
|
|
14
31
|
export type EdgeErrorData = {
|
|
15
32
|
type: string;
|
|
16
33
|
} & Record<string, any>;
|
|
17
|
-
|
|
34
|
+
/**
|
|
35
|
+
* This is the shape of the error response from the Edge service,
|
|
36
|
+
* when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
|
|
37
|
+
*/
|
|
38
|
+
export type EdgeFailure = {
|
|
39
|
+
/**
|
|
40
|
+
* Branded Type.
|
|
41
|
+
*/
|
|
18
42
|
success: false;
|
|
19
43
|
/**
|
|
20
44
|
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
21
45
|
*/
|
|
22
|
-
|
|
46
|
+
message: string;
|
|
47
|
+
/**
|
|
48
|
+
* Cause Error captured on the EDGE service to aid debugging on the client.
|
|
49
|
+
*/
|
|
50
|
+
error?: SerializedError;
|
|
23
51
|
/**
|
|
24
52
|
* Information that can be used to retry the request such that it will succeed, for example:
|
|
25
53
|
* 1. { type: 'auth_required', challenge: string }
|
|
@@ -27,12 +55,62 @@ export type EdgeHttpFailure = {
|
|
|
27
55
|
* 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
|
|
28
56
|
* Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
|
|
29
57
|
* if the user confirms.
|
|
30
|
-
* When
|
|
31
|
-
* EdgeHttpClient should parse well-known
|
|
58
|
+
* When data is returned simply retrying the request won't have any effect.
|
|
59
|
+
* EdgeHttpClient should parse well-known data into Error types and throw.
|
|
32
60
|
*/
|
|
33
|
-
|
|
61
|
+
data?: EdgeErrorData;
|
|
34
62
|
};
|
|
35
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Represents a body response from the Edge service.
|
|
65
|
+
*/
|
|
66
|
+
export type EdgeEnvelope<T> = EdgeSuccess<T> | EdgeFailure;
|
|
67
|
+
/**
|
|
68
|
+
* Use this to create a response from the Edge service.
|
|
69
|
+
*/
|
|
70
|
+
export declare const EdgeResponse: Readonly<{
|
|
71
|
+
success: <T>(data: T, status?: number) => Response;
|
|
72
|
+
failure: ({ message, error, errorEncoded, data, shouldRetryAfter, status, }: {
|
|
73
|
+
/**
|
|
74
|
+
* An explanation of why the call failed. Used mostly for logging and monitoring.
|
|
75
|
+
*/
|
|
76
|
+
message: string;
|
|
77
|
+
/**
|
|
78
|
+
* Error that caused the failure.
|
|
79
|
+
* Useful for debugging.
|
|
80
|
+
*
|
|
81
|
+
* Use only one of the fields `error` or `errorEncoded`.s
|
|
82
|
+
*/
|
|
83
|
+
error?: Error;
|
|
84
|
+
/**
|
|
85
|
+
* Encoded Error that caused the failure.
|
|
86
|
+
* Useful for debugging.
|
|
87
|
+
*
|
|
88
|
+
* Use only one of the fields `error` or `errorEncoded`.
|
|
89
|
+
*/
|
|
90
|
+
errorEncoded?: SerializedError;
|
|
91
|
+
/**
|
|
92
|
+
* Information that can be used to retry the request such that it will succeed, for example:
|
|
93
|
+
* 1. { type: 'auth_required', challenge: string }
|
|
94
|
+
* Requires retrying the request with challenge signature included.
|
|
95
|
+
* 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
|
|
96
|
+
* Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
|
|
97
|
+
* if the user confirms.
|
|
98
|
+
* When data is returned simply retrying the request won't have any effect.
|
|
99
|
+
* EdgeHttpClient should parse well-known data into Error types and throw.
|
|
100
|
+
*/
|
|
101
|
+
data?: EdgeErrorData;
|
|
102
|
+
/**
|
|
103
|
+
* If provided, this request will be marked as retryable and the client will wait for the specified number of milliseconds before retrying.
|
|
104
|
+
* If not provided, the client will not retry the request.
|
|
105
|
+
*/
|
|
106
|
+
shouldRetryAfter?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Status code of the response.
|
|
109
|
+
* @default 500
|
|
110
|
+
*/
|
|
111
|
+
status?: number;
|
|
112
|
+
}) => Response;
|
|
113
|
+
}>;
|
|
36
114
|
export type GetNotarizationResponseBody = {
|
|
37
115
|
awaitingNotarization: {
|
|
38
116
|
credentials: string[];
|
|
@@ -98,7 +176,21 @@ export type UploadFunctionRequest = {
|
|
|
98
176
|
ownerPublicKey: string;
|
|
99
177
|
entryPoint: string;
|
|
100
178
|
assets: Record<string, Uint8Array>;
|
|
179
|
+
/**
|
|
180
|
+
* Runtime in Edge that will be used to run the function.
|
|
181
|
+
* Runtime cannot be changed once the function was deployed.
|
|
182
|
+
* @default Runtime.WORKERS_FOR_PLATFORMS
|
|
183
|
+
*/
|
|
184
|
+
runtime?: FunctionRuntimeKind;
|
|
101
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
|
|
188
|
+
*/
|
|
189
|
+
export declare const FunctionRuntimeKind: Schema.Enums<{
|
|
190
|
+
WORKERS_FOR_PLATFORMS: string;
|
|
191
|
+
WORKER_LOADER: string;
|
|
192
|
+
}>;
|
|
193
|
+
export type FunctionRuntimeKind = Schema.Schema.Type<typeof FunctionRuntimeKind>;
|
|
102
194
|
export type UploadFunctionResponseBody = {
|
|
103
195
|
functionId: string;
|
|
104
196
|
version: string;
|
|
@@ -147,7 +239,7 @@ export declare const InitiateOAuthFlowRequestSchema: Schema.Struct<{
|
|
|
147
239
|
provider: Schema.Enums<typeof OAuthProvider>;
|
|
148
240
|
spaceId: Schema.refine<string & {
|
|
149
241
|
__SpaceId: true;
|
|
150
|
-
}, Schema.Schema<
|
|
242
|
+
}, Schema.Schema<unknown, string, never>>;
|
|
151
243
|
accessTokenId: typeof Schema.String;
|
|
152
244
|
scopes: Schema.mutable<Schema.Array$<typeof Schema.String>>;
|
|
153
245
|
noRefresh: Schema.optional<typeof Schema.Boolean>;
|
|
@@ -239,8 +331,23 @@ export type ExportBundleResponse = {
|
|
|
239
331
|
mutation: string;
|
|
240
332
|
}[];
|
|
241
333
|
};
|
|
242
|
-
export declare const DocumentCodec: {
|
|
334
|
+
export declare const DocumentCodec: Readonly<{
|
|
243
335
|
encode: (doc: Uint8Array) => string;
|
|
244
336
|
decode: (doc: string) => Uint8Array<ArrayBuffer>;
|
|
245
|
-
}
|
|
337
|
+
}>;
|
|
338
|
+
/**
|
|
339
|
+
* Codec for serializing and deserializing Edge Errors.
|
|
340
|
+
*/
|
|
341
|
+
export declare const ErrorCodec: Readonly<{
|
|
342
|
+
encode: (err: Error, depth?: number) => SerializedError;
|
|
343
|
+
decode: (serializedError: SerializedError, depth?: number) => Error;
|
|
344
|
+
}>;
|
|
345
|
+
/**
|
|
346
|
+
* Codec for serializing and deserializing Edge unhandled HTTP errors.
|
|
347
|
+
*/
|
|
348
|
+
export declare const EdgeHttpErrorCodec: Readonly<{
|
|
349
|
+
encode: (err: Error) => Response;
|
|
350
|
+
decode: (response: Response) => Promise<Error | undefined>;
|
|
351
|
+
}>;
|
|
352
|
+
export {};
|
|
246
353
|
//# sourceMappingURL=edge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../../src/edge/edge.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,oBAAY,WAAW;IACrB,oBAAoB,yBAAyB;IAC7C;;OAEG;IAEH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,MAAM,KAAO,KAAK;EAkCpE,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;kBACf,KAAK,KAAG,QAAQ;uBAQL,QAAQ,KAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;EAa9D,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
import * as Schema from 'effect/Schema';
|
|
5
|
+
import { BaseError } from '@dxos/errors';
|
|
6
|
+
import { invariant } from '@dxos/invariant';
|
|
7
|
+
import { SpaceId } from '@dxos/keys';
|
|
8
|
+
// TODO(burdon): Rename EdgerRouterEndpoint.
|
|
9
|
+
// If we would rename it, we need to be careful to not break composer production.
|
|
10
|
+
export var EdgeService;
|
|
11
|
+
(function (EdgeService) {
|
|
12
|
+
EdgeService["AUTOMERGE_REPLICATOR"] = "automerge-replicator";
|
|
13
|
+
/**
|
|
14
|
+
* Control feed replicator (hypercore append only logs) for the space.
|
|
15
|
+
*/
|
|
16
|
+
// TODO(mykola): Remove once we migrate to keyhive for access control.
|
|
17
|
+
EdgeService["FEED_REPLICATOR"] = "feed-replicator";
|
|
18
|
+
/**
|
|
19
|
+
* Feed replicator (ordered data list) for the space.
|
|
20
|
+
*/
|
|
21
|
+
// TODO(mykola): Rename to FEED_REPLICATOR when we migrate to keyhive for access control.
|
|
22
|
+
EdgeService["QUEUE_REPLICATOR"] = "queue-replicator";
|
|
23
|
+
EdgeService["SWARM"] = "swarm";
|
|
24
|
+
EdgeService["SIGNAL"] = "signal";
|
|
25
|
+
EdgeService["STATUS"] = "status";
|
|
26
|
+
})(EdgeService || (EdgeService = {}));
|
|
27
|
+
const _SerializedError = Schema.Struct({
|
|
28
|
+
name: Schema.optional(Schema.String),
|
|
29
|
+
message: Schema.optional(Schema.String),
|
|
30
|
+
context: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
31
|
+
stack: Schema.optional(Schema.String),
|
|
32
|
+
cause: Schema.optional(Schema.suspend(() => SerializedError)),
|
|
33
|
+
});
|
|
34
|
+
export const SerializedError = _SerializedError;
|
|
35
|
+
/**
|
|
36
|
+
* Use this to create a response from the Edge service.
|
|
37
|
+
*/
|
|
38
|
+
export const EdgeResponse = Object.freeze({
|
|
39
|
+
success: (data, status = 200) => {
|
|
40
|
+
invariant(status >= 200 && status < 300, 'Status code must be in the 2xx range');
|
|
41
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
42
|
+
return new Response(JSON.stringify({
|
|
43
|
+
success: true,
|
|
44
|
+
data,
|
|
45
|
+
}), {
|
|
46
|
+
status,
|
|
47
|
+
headers,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
failure: ({ message, error, errorEncoded, data, shouldRetryAfter, status = 500, }) => {
|
|
51
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
52
|
+
if (shouldRetryAfter) {
|
|
53
|
+
headers.set('Retry-After', String(shouldRetryAfter));
|
|
54
|
+
}
|
|
55
|
+
return new Response(JSON.stringify({
|
|
56
|
+
success: false,
|
|
57
|
+
message,
|
|
58
|
+
data,
|
|
59
|
+
error: error ? ErrorCodec.encode(error) : errorEncoded,
|
|
60
|
+
}), {
|
|
61
|
+
status,
|
|
62
|
+
headers,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
|
|
68
|
+
*/
|
|
69
|
+
export const FunctionRuntimeKind = Schema.Enums({
|
|
70
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
71
|
+
WORKERS_FOR_PLATFORMS: 'WORKERS_FOR_PLATFORMS',
|
|
72
|
+
// https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
|
|
73
|
+
WORKER_LOADER: 'WORKER_LOADER',
|
|
74
|
+
});
|
|
75
|
+
export var EdgeAgentStatus;
|
|
76
|
+
(function (EdgeAgentStatus) {
|
|
77
|
+
EdgeAgentStatus["ACTIVE"] = "active";
|
|
78
|
+
EdgeAgentStatus["INACTIVE"] = "inactive";
|
|
79
|
+
EdgeAgentStatus["NOT_FOUND"] = "not_found";
|
|
80
|
+
})(EdgeAgentStatus || (EdgeAgentStatus = {}));
|
|
81
|
+
export var OAuthProvider;
|
|
82
|
+
(function (OAuthProvider) {
|
|
83
|
+
OAuthProvider["GOOGLE"] = "google";
|
|
84
|
+
OAuthProvider["BLUESKY"] = "bluesky";
|
|
85
|
+
})(OAuthProvider || (OAuthProvider = {}));
|
|
86
|
+
export const InitiateOAuthFlowRequestSchema = Schema.Struct({
|
|
87
|
+
provider: Schema.Enums(OAuthProvider),
|
|
88
|
+
spaceId: Schema.String.pipe(Schema.filter(SpaceId.isValid)), // TODO(burdon): Use SpaceId.
|
|
89
|
+
accessTokenId: Schema.String,
|
|
90
|
+
scopes: Schema.mutable(Schema.Array(Schema.String)),
|
|
91
|
+
// Set to true if we don't want periodic token refreshes in background, for cases like account connect
|
|
92
|
+
noRefresh: Schema.optional(Schema.Boolean),
|
|
93
|
+
// Provider-specific (user handle or did for bluesky) hint for auth server resolution
|
|
94
|
+
loginHint: Schema.optional(Schema.String),
|
|
95
|
+
});
|
|
96
|
+
export var EdgeWebsocketProtocol;
|
|
97
|
+
(function (EdgeWebsocketProtocol) {
|
|
98
|
+
EdgeWebsocketProtocol["V0"] = "edge-ws-v0";
|
|
99
|
+
/**
|
|
100
|
+
* Enables message framing and muxing by service-id.
|
|
101
|
+
*/
|
|
102
|
+
EdgeWebsocketProtocol["V1"] = "edge-ws-v1";
|
|
103
|
+
})(EdgeWebsocketProtocol || (EdgeWebsocketProtocol = {}));
|
|
104
|
+
export const DocumentCodec = Object.freeze({
|
|
105
|
+
encode: (doc) => Buffer.from(doc).toString('base64'),
|
|
106
|
+
decode: (doc) => new Uint8Array(Buffer.from(doc, 'base64')),
|
|
107
|
+
});
|
|
108
|
+
const MAX_ERROR_DEPTH = 3;
|
|
109
|
+
/**
|
|
110
|
+
* Codec for serializing and deserializing Edge Errors.
|
|
111
|
+
*/
|
|
112
|
+
export const ErrorCodec = Object.freeze({
|
|
113
|
+
encode: (err, depth = 0) => ({
|
|
114
|
+
name: 'name' in err ? err.name : err.code || 'Error',
|
|
115
|
+
message: err.message,
|
|
116
|
+
stack: err.stack,
|
|
117
|
+
cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
|
|
118
|
+
}),
|
|
119
|
+
decode: (serializedError, depth = 0) => {
|
|
120
|
+
let err;
|
|
121
|
+
if (typeof serializedError.name === 'string') {
|
|
122
|
+
err = new BaseError(serializedError.name, {
|
|
123
|
+
message: serializedError.message ?? 'Unknown error',
|
|
124
|
+
cause: serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
125
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
126
|
+
: undefined,
|
|
127
|
+
context: serializedError.context,
|
|
128
|
+
});
|
|
129
|
+
if (serializedError.stack) {
|
|
130
|
+
Object.defineProperty(err, 'stack', {
|
|
131
|
+
value: serializedError.stack,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
err = new Error(serializedError.message ?? 'Unknown error', {
|
|
137
|
+
cause: serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
138
|
+
? ErrorCodec.decode(serializedError.cause, depth + 1)
|
|
139
|
+
: undefined,
|
|
140
|
+
});
|
|
141
|
+
if (serializedError.stack) {
|
|
142
|
+
Object.defineProperty(err, 'stack', {
|
|
143
|
+
value: serializedError.stack,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return err;
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Codec for serializing and deserializing Edge unhandled HTTP errors.
|
|
152
|
+
*/
|
|
153
|
+
export const EdgeHttpErrorCodec = Object.freeze({
|
|
154
|
+
encode: (err) => new Response(JSON.stringify({
|
|
155
|
+
error: ErrorCodec.encode(err),
|
|
156
|
+
}), { status: 500 }),
|
|
157
|
+
decode: async (response) => {
|
|
158
|
+
if (response.headers.get('Content-Type') !== 'application/json') {
|
|
159
|
+
const body = await response.clone().text();
|
|
160
|
+
return new Error(body.slice(0, 256));
|
|
161
|
+
}
|
|
162
|
+
const body = await response.clone().json();
|
|
163
|
+
if (!('error' in body)) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
return ErrorCodec.decode(body.error);
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=edge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../../src/edge/edge.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;AAEF,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,4CAA4C;AAC5C,iFAAiF;AACjF,MAAM,CAAN,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB,4DAA6C,CAAA;IAC7C;;OAEG;IACH,sEAAsE;IACtE,kDAAmC,CAAA;IACnC;;OAEG;IACH,yFAAyF;IACzF,oDAAqC,CAAA;IACrC,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,gCAAiB,CAAA;AACnB,CAAC,EAfW,WAAW,KAAX,WAAW,QAetB;AAOD,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC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MAAM,CAAC,GAAG,CAAC;KAC9B,CAAC,EACF,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB;IAEH,MAAM,EAAE,KAAK,EAAE,QAAkB,EAA8B,EAAE;QAC/D,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,kBAAkB,EAAE,CAAC;YAChE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YAC3C,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type EdgeErrorData, type EdgeFailure } from './edge.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a call to the Edge service fails.
|
|
4
|
+
* There 3 possible sources of failure:
|
|
5
|
+
* 1. EdgeFailure (JSON body with { success: false }) -> Processing the request failed and was gracefully handled by EDGE service.
|
|
6
|
+
* 2. Http failure (non-ok code) -> The HTTP request failed (e.g. timeout, network error).
|
|
7
|
+
* -> Unhandled exception on EDGE side, EDGE would provide serialized error in the response body.
|
|
8
|
+
* 3. Processing failure -> Unhandled exception on client side while processing the response.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EdgeCallFailedError extends Error {
|
|
11
|
+
static fromUnsuccessfulResponse(response: Response, body: EdgeFailure): EdgeCallFailedError;
|
|
12
|
+
static fromHttpFailure(response: Response): Promise<EdgeCallFailedError>;
|
|
13
|
+
static fromProcessingFailureCause(cause: Error): EdgeCallFailedError;
|
|
14
|
+
readonly data?: EdgeErrorData;
|
|
15
|
+
readonly isRetryable?: boolean;
|
|
16
|
+
readonly retryAfterMs?: number;
|
|
17
|
+
constructor(args: {
|
|
18
|
+
message: string;
|
|
19
|
+
isRetryable?: boolean;
|
|
20
|
+
data?: EdgeErrorData;
|
|
21
|
+
retryAfterMs?: number;
|
|
22
|
+
cause?: Error;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export declare class EdgeAuthChallengeError extends EdgeCallFailedError {
|
|
26
|
+
readonly challenge: string;
|
|
27
|
+
constructor(challenge: string, data: EdgeErrorData);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/edge/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAkC,MAAM,WAAW,CAAC;AAGjG;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;WAC9B,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,mBAAmB;WAY9E,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC;WASvE,0BAA0B,CAAC,KAAK,EAAE,KAAK,GAAG,mBAAmB;IAQ3E,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEnB,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,IAAI,CAAC,EAAE,aAAa,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAOF;AAED,qBAAa,sBAAuB,SAAQ,mBAAmB;aAE3C,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM,EACjC,IAAI,EAAE,aAAa;CAItB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
import { EdgeHttpErrorCodec, ErrorCodec } from "./edge.js";
|
|
5
|
+
// TODO(burdon): Reconcile with @dxos/errors.
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a call to the Edge service fails.
|
|
8
|
+
* There 3 possible sources of failure:
|
|
9
|
+
* 1. EdgeFailure (JSON body with { success: false }) -> Processing the request failed and was gracefully handled by EDGE service.
|
|
10
|
+
* 2. Http failure (non-ok code) -> The HTTP request failed (e.g. timeout, network error).
|
|
11
|
+
* -> Unhandled exception on EDGE side, EDGE would provide serialized error in the response body.
|
|
12
|
+
* 3. Processing failure -> Unhandled exception on client side while processing the response.
|
|
13
|
+
*/
|
|
14
|
+
export class EdgeCallFailedError extends Error {
|
|
15
|
+
static fromUnsuccessfulResponse(response, body) {
|
|
16
|
+
const error = new EdgeCallFailedError({
|
|
17
|
+
message: body.message,
|
|
18
|
+
data: body.data,
|
|
19
|
+
isRetryable: body.data == null && response.headers.has('Retry-After'),
|
|
20
|
+
retryAfterMs: getRetryAfterMillis(response),
|
|
21
|
+
cause: body.error ? ErrorCodec.decode(body.error) : undefined,
|
|
22
|
+
});
|
|
23
|
+
return error;
|
|
24
|
+
}
|
|
25
|
+
static async fromHttpFailure(response) {
|
|
26
|
+
return new EdgeCallFailedError({
|
|
27
|
+
message: `HTTP code ${response.status}: ${response.statusText}.`,
|
|
28
|
+
isRetryable: isRetryableCode(response.status),
|
|
29
|
+
retryAfterMs: getRetryAfterMillis(response),
|
|
30
|
+
cause: await EdgeHttpErrorCodec.decode(response),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static fromProcessingFailureCause(cause) {
|
|
34
|
+
return new EdgeCallFailedError({
|
|
35
|
+
message: 'Error processing request.',
|
|
36
|
+
isRetryable: true,
|
|
37
|
+
cause,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
data;
|
|
41
|
+
isRetryable;
|
|
42
|
+
retryAfterMs;
|
|
43
|
+
constructor(args) {
|
|
44
|
+
super(args.message, { cause: args.cause });
|
|
45
|
+
this.message = args.message;
|
|
46
|
+
this.data = args.data;
|
|
47
|
+
this.retryAfterMs = args.retryAfterMs;
|
|
48
|
+
this.isRetryable = Boolean(args.isRetryable);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class EdgeAuthChallengeError extends EdgeCallFailedError {
|
|
52
|
+
challenge;
|
|
53
|
+
constructor(challenge, data) {
|
|
54
|
+
super({ message: 'Auth challenge.', data, isRetryable: false });
|
|
55
|
+
this.challenge = challenge;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const getRetryAfterMillis = (response) => {
|
|
59
|
+
const retryAfter = Number(response.headers.get('Retry-After'));
|
|
60
|
+
return Number.isNaN(retryAfter) || retryAfter === 0 ? undefined : retryAfter * 1000;
|
|
61
|
+
};
|
|
62
|
+
const isRetryableCode = (status) => {
|
|
63
|
+
if (status === 501) {
|
|
64
|
+
// Not Implemented
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return !(status >= 400 && status < 500);
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/edge/errors.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;AAEF,OAAO,EAAwC,kBAAkB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjG,6CAA6C;AAC7C;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACrC,MAAM,CAAC,wBAAwB,CAA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IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAE3C;IADlB,YACkB,SAAiB,EACjC,IAAmB;QAEnB,KAAK,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QAHhD,cAAS,GAAT,SAAS,CAAQ;IAInC,CAAC;CACF;AAED,MAAM,mBAAmB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,EAAE;IACzC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,kBAAkB;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/edge/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/edge/index.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;AAEF,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,cAAc,aAAa,CAAC"}
|