@dxos/edge-client 0.8.3 → 0.8.4-main.1da679c
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/lib/browser/{chunk-VHS3XEIX.mjs → chunk-IKP53CBQ.mjs} +51 -18
- package/dist/lib/browser/{chunk-VHS3XEIX.mjs.map → chunk-IKP53CBQ.mjs.map} +3 -3
- package/dist/lib/browser/edge-ws-muxer.mjs +1 -1
- package/dist/lib/browser/index.mjs +566 -350
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +61 -16
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-HGQUUFIJ.mjs → chunk-DR5YNW5K.mjs} +51 -18
- package/dist/lib/node-esm/{chunk-HGQUUFIJ.mjs.map → chunk-DR5YNW5K.mjs.map} +3 -3
- package/dist/lib/node-esm/edge-ws-muxer.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +566 -350
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +61 -16
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/edge-client.d.ts +15 -15
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +52 -30
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.test.d.ts +2 -0
- package/dist/types/src/edge-http-client.test.d.ts.map +1 -0
- package/dist/types/src/edge-ws-connection.d.ts +1 -0
- package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
- package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
- package/dist/types/src/http-client.d.ts +22 -0
- package/dist/types/src/http-client.d.ts.map +1 -0
- package/dist/types/src/http-client.test.d.ts +2 -0
- package/dist/types/src/http-client.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-server.d.ts +9 -0
- package/dist/types/src/testing/test-server.d.ts.map +1 -0
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -14
- package/src/edge-client.ts +40 -40
- package/src/edge-http-client.test.ts +22 -0
- package/src/edge-http-client.ts +330 -140
- package/src/edge-ws-connection.ts +11 -3
- package/src/edge-ws-muxer.ts +1 -1
- package/src/http-client.test.ts +55 -0
- package/src/http-client.ts +67 -0
- package/src/index.ts +4 -3
- package/src/testing/index.ts +1 -0
- package/src/testing/test-server.ts +45 -0
- package/src/testing/test-utils.ts +2 -2
- package/src/websocket.test.ts +1 -1
- package/dist/lib/node/chunk-XNHBUTNB.cjs +0 -317
- package/dist/lib/node/chunk-XNHBUTNB.cjs.map +0 -7
- package/dist/lib/node/edge-ws-muxer.cjs +0 -33
- package/dist/lib/node/edge-ws-muxer.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -1060
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -169
- package/dist/lib/node/testing/index.cjs.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/test-utils.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { MessageSchema, TextMessageSchema
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,OAAOA,eAAe;AAEtB,SAASC,eAAe;AACxB,SAASC,
|
|
6
|
-
"names": ["WebSocket", "Trigger", "log", "EdgeWebsocketProtocol", "buf", "MessageSchema", "TextMessageSchema", "DEFAULT_PORT", "createTestEdgeWsServer", "port", "params", "wsServer", "WebSocket", "Server", "verifyClient", "createConnectionDelayHandler", "handleProtocols", "EdgeWebsocketProtocol", "V1", "connection", "messageSink", "messageSourceLog", "closeTrigger", "Trigger", "sendResponseMessage", "createResponseSender", "muxer", "on", "ws", "WebSocketMuxer", "err", "log", "catch", "data", "String", "send", "message", "receiveData", "toUint8Array", "request", "requestPayload", "decodePayload", "push", "source", "messageHandler", "responsePayload", "payload", "undefined", "wake", "server", "endpoint", "cleanup", "close", "currentConnection", "sendMessage", "msg", "closeConnection", "reset", "wait", "_", "callback", "admitConnection", "then", "recipient", "buf", "create", "MessageSchema", "identityKey", "peerKey", "serviceId", "value", "payloadDecoder", "protocol", "getPayload", "TextMessageSchema"]
|
|
3
|
+
"sources": ["../../../../src/testing/test-server.ts", "../../../../src/testing/test-utils.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport http from 'node:http';\n\nimport { log } from '@dxos/log';\n\nexport type TestServer = {\n url: string;\n close: () => void;\n};\n\nexport type ResponseHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void;\n\nexport const createTestServer = (responseHandler: ResponseHandler) => {\n const server = http.createServer(responseHandler);\n\n return new Promise<TestServer>((resolve) => {\n server.listen(0, () => {\n const address = server.address();\n const port = typeof address === 'object' && address ? address.port : 0;\n resolve({\n url: `http://localhost:${port}`,\n close: () => server.close(),\n });\n });\n });\n};\n\nexport const responseHandler = (cb: (attempt: number) => false | object): ResponseHandler => {\n let attempt = 0;\n return (req, res) => {\n const data = cb(++attempt) ?? {};\n if (data === false) {\n log('simulating failure', { attempt });\n res.statusCode = 500;\n res.statusMessage = 'Simulating failure';\n res.end('');\n } else {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ success: true, data }));\n }\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema, TextMessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from '../defs';\nimport { WebSocketMuxer } from '../edge-ws-muxer';\nimport { toUint8Array } from '../protocol';\n\nexport const DEFAULT_PORT = 8080;\n\ntype TestEdgeWsServerParams = {\n admitConnection?: Trigger;\n payloadDecoder?: (payload: Uint8Array) => any;\n messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;\n};\n\nexport const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestEdgeWsServerParams) => {\n const wsServer = new WebSocket.Server({\n port,\n verifyClient: createConnectionDelayHandler(params),\n handleProtocols: () => EdgeWebsocketProtocol.V1,\n });\n\n let connection: { ws: WebSocket; muxer: WebSocketMuxer } | undefined;\n\n const messageSink: any[] = [];\n const messageSourceLog: any[] = [];\n const closeTrigger = new Trigger();\n const sendResponseMessage = createResponseSender(() => connection!.muxer);\n\n wsServer.on('connection', (ws) => {\n const muxer = new WebSocketMuxer(ws);\n connection = { ws, muxer };\n ws.on('error', (err) => log.catch(err));\n ws.on('message', async (data) => {\n if (String(data) === '__ping__') {\n ws.send('__pong__');\n return;\n }\n const message = muxer.receiveData(await toUint8Array(data));\n if (!message) {\n return;\n }\n const { request, requestPayload } = await decodePayload(message, params);\n messageSourceLog.push(request.source);\n if (params?.messageHandler) {\n const responsePayload = await params.messageHandler(requestPayload);\n if (responsePayload && connection) {\n sendResponseMessage(request, responsePayload);\n }\n }\n log('message', { payload: requestPayload });\n messageSink.push(requestPayload);\n });\n\n ws.on('close', () => {\n connection = undefined;\n closeTrigger.wake();\n });\n });\n\n return {\n server: wsServer,\n messageSink,\n messageSourceLog,\n endpoint: `ws://127.0.0.1:${port}`,\n cleanup: () => wsServer.close(),\n currentConnection: () => connection,\n sendResponseMessage,\n sendMessage: (msg: Message) => {\n return connection!.muxer.send(msg);\n },\n closeConnection: () => {\n closeTrigger.reset();\n connection!.ws.close(1011);\n return closeTrigger.wait();\n },\n };\n};\n\nconst createConnectionDelayHandler = (params: TestEdgeWsServerParams | undefined) => {\n return (_: any, callback: (admit: boolean) => void) => {\n if (params?.admitConnection) {\n log('delaying edge connection admission');\n void params.admitConnection.wait().then(() => {\n callback(true);\n log('edge connection admitted');\n });\n } else {\n callback(true);\n }\n };\n};\n\nconst createResponseSender = (connection: () => WebSocketMuxer) => {\n return (request: Message, responsePayload: Uint8Array) => {\n const recipient = request.source!;\n void connection().send(\n buf.create(MessageSchema, {\n source: {\n identityKey: recipient.identityKey,\n peerKey: recipient.peerKey,\n },\n serviceId: request.serviceId!,\n payload: { value: responsePayload },\n }),\n );\n };\n};\n\nconst decodePayload = async (request: Message, params: TestEdgeWsServerParams | undefined) => {\n const requestPayload = params?.payloadDecoder\n ? params.payloadDecoder(request.payload!.value!)\n : protocol.getPayload(request, TextMessageSchema);\n return { request, requestPayload };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,OAAOA,UAAU;AAEjB,SAASC,WAAW;;AASb,IAAMC,mBAAmB,CAACC,qBAAAA;AAC/B,QAAMC,SAASJ,KAAKK,aAAaF,gBAAAA;AAEjC,SAAO,IAAIG,QAAoB,CAACC,YAAAA;AAC9BH,WAAOI,OAAO,GAAG,MAAA;AACf,YAAMC,UAAUL,OAAOK,QAAO;AAC9B,YAAMC,OAAO,OAAOD,YAAY,YAAYA,UAAUA,QAAQC,OAAO;AACrEH,cAAQ;QACNI,KAAK,oBAAoBD,IAAAA;QACzBE,OAAO,MAAMR,OAAOQ,MAAK;MAC3B,CAAA;IACF,CAAA;EACF,CAAA;AACF;AAEO,IAAMT,kBAAkB,CAACU,OAAAA;AAC9B,MAAIC,UAAU;AACd,SAAO,CAACC,KAAKC,QAAAA;AACX,UAAMC,O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xB,WAAAA,EAAagB,KAChB6B,IAAIC,OAAOC,eAAe;MACxBvB,QAAQ;QACNwB,aAAaJ,UAAUI;QACvBC,SAASL,UAAUK;MACrB;MACAC,WAAW9B,QAAQ8B;MACnBvB,SAAS;QAAEwB,OAAOzB;MAAgB;IACpC,CAAA,CAAA;EAEJ;AACF;AAEA,IAAMJ,gBAAgB,OAAOF,SAAkB7B,WAAAA;AAC7C,QAAM8B,iBAAiB9B,QAAQ6D,iBAC3B7D,OAAO6D,eAAehC,QAAQO,QAASwB,KAAK,IAC5CE,SAASC,WAAWlC,SAASmC,iBAAAA;AACjC,SAAO;IAAEnC;IAASC;EAAe;AACnC;",
|
|
6
|
+
"names": ["http", "log", "createTestServer", "responseHandler", "server", "createServer", "Promise", "resolve", "listen", "address", "port", "url", "close", "cb", "attempt", "req", "res", "data", "statusCode", "statusMessage", "end", "writeHead", "JSON", "stringify", "success", "WebSocket", "Trigger", "log", "EdgeWebsocketProtocol", "buf", "MessageSchema", "TextMessageSchema", "DEFAULT_PORT", "createTestEdgeWsServer", "port", "params", "wsServer", "WebSocket", "Server", "verifyClient", "createConnectionDelayHandler", "handleProtocols", "EdgeWebsocketProtocol", "V1", "connection", "messageSink", "messageSourceLog", "closeTrigger", "Trigger", "sendResponseMessage", "createResponseSender", "muxer", "on", "ws", "WebSocketMuxer", "err", "log", "catch", "data", "String", "send", "message", "receiveData", "toUint8Array", "request", "requestPayload", "decodePayload", "push", "source", "messageHandler", "responsePayload", "payload", "undefined", "wake", "server", "endpoint", "cleanup", "close", "currentConnection", "sendMessage", "msg", "closeConnection", "reset", "wait", "_", "callback", "admitConnection", "then", "recipient", "buf", "create", "MessageSchema", "identityKey", "peerKey", "serviceId", "value", "payloadDecoder", "protocol", "getPayload", "TextMessageSchema"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
|
-
import {
|
|
2
|
+
import { type Lifecycle, Resource } from '@dxos/context';
|
|
3
3
|
import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
4
4
|
import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
|
|
5
5
|
import { type EdgeIdentity } from './edge-identity';
|
|
6
6
|
import { type Protocol } from './protocol';
|
|
7
7
|
export type MessageListener = (message: Message) => void;
|
|
8
8
|
export type ReconnectListener = () => void;
|
|
9
|
+
export type MessengerConfig = {
|
|
10
|
+
socketEndpoint: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
protocol?: Protocol;
|
|
13
|
+
disableAuth?: boolean;
|
|
14
|
+
};
|
|
9
15
|
export interface EdgeConnection extends Required<Lifecycle> {
|
|
10
16
|
statusChanged: Event<EdgeStatus>;
|
|
11
17
|
get info(): any;
|
|
@@ -14,16 +20,10 @@ export interface EdgeConnection extends Required<Lifecycle> {
|
|
|
14
20
|
get isOpen(): boolean;
|
|
15
21
|
get status(): EdgeStatus;
|
|
16
22
|
setIdentity(identity: EdgeIdentity): void;
|
|
23
|
+
send(message: Message): Promise<void>;
|
|
17
24
|
onMessage(listener: MessageListener): () => void;
|
|
18
25
|
onReconnected(listener: ReconnectListener): () => void;
|
|
19
|
-
send(message: Message): Promise<void>;
|
|
20
26
|
}
|
|
21
|
-
export type MessengerConfig = {
|
|
22
|
-
socketEndpoint: string;
|
|
23
|
-
timeout?: number;
|
|
24
|
-
protocol?: Protocol;
|
|
25
|
-
disableAuth?: boolean;
|
|
26
|
-
};
|
|
27
27
|
/**
|
|
28
28
|
* Messenger client for EDGE:
|
|
29
29
|
* - While open, uses PersistentLifecycle to keep an open EdgeWsConnection, reconnecting on failures.
|
|
@@ -52,8 +52,13 @@ export declare class EdgeClient extends Resource implements EdgeConnection {
|
|
|
52
52
|
get identityKey(): string;
|
|
53
53
|
get peerKey(): string;
|
|
54
54
|
setIdentity(identity: EdgeIdentity): void;
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Send message.
|
|
57
|
+
* NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
|
|
58
|
+
*/
|
|
59
|
+
send(message: Message): Promise<void>;
|
|
60
|
+
onMessage(listener: MessageListener): () => boolean;
|
|
61
|
+
onReconnected(listener: () => void): () => boolean;
|
|
57
62
|
/**
|
|
58
63
|
* Open connection to messaging service.
|
|
59
64
|
*/
|
|
@@ -67,11 +72,6 @@ export declare class EdgeClient extends Resource implements EdgeConnection {
|
|
|
67
72
|
private _closeCurrentConnection;
|
|
68
73
|
private _notifyReconnected;
|
|
69
74
|
private _notifyMessageReceived;
|
|
70
|
-
/**
|
|
71
|
-
* Send message.
|
|
72
|
-
* NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
|
|
73
|
-
*/
|
|
74
|
-
send(message: Message): Promise<void>;
|
|
75
75
|
private _createAuthHeader;
|
|
76
76
|
private _isActive;
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../../src/edge-client.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../../src/edge-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAGxE,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAE3C,MAAM,MAAM,eAAe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MAOd;IAED,IAAI,MAAM,eAIT;IAED,IAAI,WAAW,WAEd;IAED,IAAI,OAAO,WAEV;IAED,WAAW,CAAC,QAAQ,EAAE,YAAY;IASlC;;;OAGG;IACU,IAAI,CAAC,OAAO,EAAE,OAAO;IAoB3B,SAAS,CAAC,QAAQ,EAAE,eAAe;IAKnC,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI;IAmBzC;;OAEG;cACsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/C;;OAEG;cACsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAMlC,QAAQ;YA0DR,WAAW;IAKzB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,sBAAsB;YAUhB,iBAAiB;IAY/B,OAAO,CAAC,SAAS,CAA4E;CAC9F"}
|
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { Context } from '@dxos/context';
|
|
2
2
|
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
3
|
-
import { type
|
|
3
|
+
import { type CreateAgentRequestBody, type CreateAgentResponseBody, type CreateSpaceRequest, type CreateSpaceResponseBody, type EdgeStatus, type ExecuteWorkflowResponseBody, type ExportBundleRequest, type ExportBundleResponse, type GetAgentStatusResponseBody, type GetNotarizationResponseBody, type ImportBundleRequest, type InitiateOAuthFlowRequest, type InitiateOAuthFlowResponse, type JoinSpaceRequest, type JoinSpaceResponseBody, type ObjectId, type PostNotarizationRequestBody, type QueryResult, type QueueQuery, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
4
4
|
import { type EdgeIdentity } from './edge-identity';
|
|
5
|
+
export type RetryConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* A number of call retries, not counting the initial request.
|
|
8
|
+
*/
|
|
9
|
+
count: number;
|
|
10
|
+
/**
|
|
11
|
+
* Delay before retries in ms.
|
|
12
|
+
*/
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/**
|
|
15
|
+
* A random amount of time before retrying to help prevent large bursts of requests.
|
|
16
|
+
*/
|
|
17
|
+
jitter?: number;
|
|
18
|
+
};
|
|
19
|
+
type EdgeHttpRequestArgs = {
|
|
20
|
+
method: string;
|
|
21
|
+
context?: Context;
|
|
22
|
+
retry?: RetryConfig;
|
|
23
|
+
body?: any;
|
|
24
|
+
/**
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
json?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Do not expect a standard EDGE JSON response with a `success` field.
|
|
30
|
+
*/
|
|
31
|
+
rawResponse?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type EdgeHttpGetArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry'>;
|
|
34
|
+
export type EdgeHttpPostArgs = Pick<EdgeHttpRequestArgs, 'context' | 'retry' | 'body'>;
|
|
5
35
|
export declare class EdgeHttpClient {
|
|
6
36
|
private readonly _baseUrl;
|
|
7
37
|
private _edgeIdentity;
|
|
@@ -12,47 +42,39 @@ export declare class EdgeHttpClient {
|
|
|
12
42
|
constructor(baseUrl: string);
|
|
13
43
|
get baseUrl(): string;
|
|
14
44
|
setIdentity(identity: EdgeIdentity): void;
|
|
45
|
+
getStatus(args?: EdgeHttpGetArgs): Promise<EdgeStatus>;
|
|
15
46
|
createAgent(body: CreateAgentRequestBody, args?: EdgeHttpGetArgs): Promise<CreateAgentResponseBody>;
|
|
16
47
|
getAgentStatus(request: {
|
|
17
48
|
ownerIdentityKey: PublicKey;
|
|
18
49
|
}, args?: EdgeHttpGetArgs): Promise<GetAgentStatusResponseBody>;
|
|
19
50
|
getCredentialsForNotarization(spaceId: SpaceId, args?: EdgeHttpGetArgs): Promise<GetNotarizationResponseBody>;
|
|
20
51
|
notarizeCredentials(spaceId: SpaceId, body: PostNotarizationRequestBody, args?: EdgeHttpGetArgs): Promise<void>;
|
|
21
|
-
joinSpaceByInvitation(spaceId: SpaceId, body: JoinSpaceRequest, args?: EdgeHttpGetArgs): Promise<JoinSpaceResponseBody>;
|
|
22
52
|
recoverIdentity(body: RecoverIdentityRequest, args?: EdgeHttpGetArgs): Promise<RecoverIdentityResponseBody>;
|
|
23
|
-
|
|
24
|
-
uploadFunction(pathParts: {
|
|
25
|
-
functionId?: string;
|
|
26
|
-
}, body: UploadFunctionRequest, args?: EdgeHttpGetArgs): Promise<UploadFunctionResponseBody>;
|
|
53
|
+
joinSpaceByInvitation(spaceId: SpaceId, body: JoinSpaceRequest, args?: EdgeHttpGetArgs): Promise<JoinSpaceResponseBody>;
|
|
27
54
|
initiateOAuthFlow(body: InitiateOAuthFlowRequest, args?: EdgeHttpGetArgs): Promise<InitiateOAuthFlowResponse>;
|
|
55
|
+
createSpace(body: CreateSpaceRequest, args?: EdgeHttpGetArgs): Promise<CreateSpaceResponseBody>;
|
|
28
56
|
queryQueue(subspaceTag: string, spaceId: SpaceId, query: QueueQuery, args?: EdgeHttpGetArgs): Promise<QueryResult>;
|
|
29
57
|
insertIntoQueue(subspaceTag: string, spaceId: SpaceId, queueId: ObjectId, objects: unknown[], args?: EdgeHttpGetArgs): Promise<void>;
|
|
30
58
|
deleteFromQueue(subspaceTag: string, spaceId: SpaceId, queueId: ObjectId, objectIds: ObjectId[], args?: EdgeHttpGetArgs): Promise<void>;
|
|
31
|
-
|
|
59
|
+
uploadFunction(pathParts: {
|
|
60
|
+
functionId?: string;
|
|
61
|
+
}, body: UploadFunctionRequest, args?: EdgeHttpGetArgs): Promise<UploadFunctionResponseBody>;
|
|
62
|
+
listFunctions(args?: EdgeHttpGetArgs): Promise<any>;
|
|
63
|
+
invokeFunction(params: {
|
|
64
|
+
functionId: string;
|
|
65
|
+
version?: string;
|
|
66
|
+
spaceId?: SpaceId;
|
|
67
|
+
cpuTimeLimit?: number;
|
|
68
|
+
subrequestsLimit?: number;
|
|
69
|
+
}, input: unknown, args?: EdgeHttpGetArgs): Promise<any>;
|
|
70
|
+
executeWorkflow(spaceId: SpaceId, graphId: ObjectId, input: any, args?: EdgeHttpGetArgs): Promise<ExecuteWorkflowResponseBody>;
|
|
71
|
+
getCronTriggers(spaceId: SpaceId): Promise<unknown>;
|
|
72
|
+
importBundle(spaceId: SpaceId, //
|
|
73
|
+
body: ImportBundleRequest, args?: EdgeHttpGetArgs): Promise<void>;
|
|
74
|
+
exportBundle(spaceId: SpaceId, body: ExportBundleRequest, args?: EdgeHttpGetArgs): Promise<ExportBundleResponse>;
|
|
75
|
+
private _fetch;
|
|
32
76
|
private _call;
|
|
33
77
|
private _handleUnauthorized;
|
|
34
78
|
}
|
|
35
|
-
export
|
|
36
|
-
/**
|
|
37
|
-
* A number of call retries, not counting the initial request.
|
|
38
|
-
*/
|
|
39
|
-
count: number;
|
|
40
|
-
/**
|
|
41
|
-
* Delay before retries in ms.
|
|
42
|
-
*/
|
|
43
|
-
timeout?: number;
|
|
44
|
-
/**
|
|
45
|
-
* A random amount of time before retrying to help prevent large bursts of requests.
|
|
46
|
-
*/
|
|
47
|
-
jitter?: number;
|
|
48
|
-
};
|
|
49
|
-
export type EdgeHttpGetArgs = {
|
|
50
|
-
context?: Context;
|
|
51
|
-
retry?: RetryConfig;
|
|
52
|
-
};
|
|
53
|
-
export type EdgeHttpPostArgs = {
|
|
54
|
-
context?: Context;
|
|
55
|
-
body?: any;
|
|
56
|
-
retry?: RetryConfig;
|
|
57
|
-
};
|
|
79
|
+
export {};
|
|
58
80
|
//# sourceMappingURL=edge-http-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edge-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,YA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EAAE,EAAE;IACpB,IAAI,EAAE,mBAAmB,EACzB,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,IAAI,CAAC;IAIH,YAAY,CACvB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,mBAAmB,EACzB,IAAI,CAAC,EAAE,eAAe,GACrB,OAAO,CAAC,oBAAoB,CAAC;YAYlB,MAAM;YAaN,KAAK;YAqDL,mBAAmB;CASlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-http-client.test.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -13,6 +13,7 @@ export declare class EdgeWsConnection extends Resource {
|
|
|
13
13
|
private _inactivityTimeoutCtx;
|
|
14
14
|
private _ws;
|
|
15
15
|
private _wsMuxer;
|
|
16
|
+
private _lastReceivedMessageTimestamp;
|
|
16
17
|
constructor(_identity: EdgeIdentity, _connectionInfo: {
|
|
17
18
|
url: URL;
|
|
18
19
|
protocolHeader?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-ws-connection.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKlD,OAAO,
|
|
1
|
+
{"version":3,"file":"edge-ws-connection.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKlD,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,4CAA4C,CAAC;AAGzF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAOpD,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,QAAQ;IAO1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR7B,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,GAAG,CAAwB;IACnC,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,6BAA6B,CAAc;gBAGhC,SAAS,EAAE,YAAY,EACvB,eAAe,EAAE;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EACtD,UAAU,EAAE,yBAAyB;IAKxD,IACW,IAAI;;;;MAMd;IAEM,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;cAoBV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAgEtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBhD,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,2BAA2B;CAuBpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-ws-muxer.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-muxer.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"edge-ws-muxer.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-muxer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,4CAA4C,CAAC;AAkBzF;;GAEG;AACH,eAAO,MAAM,4BAA4B,QAAc,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAmB,CAAC;AAMzD,qBAAa,cAAc;IAUvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATtB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA+B;IACrE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IACvE,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAA6B;IAEzE,OAAO,CAAC,YAAY,CAAkB;IAEtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGtB,GAAG,EAAE,eAAe,EACrC,MAAM,CAAC,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;IAKrC;;OAEG;IACU,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgD3C,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS;IAuBlD,OAAO,IAAI,IAAI;IAatB,OAAO,CAAC,oBAAoB;IA0C5B,OAAO,CAAC,eAAe;CAWxB;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,eAAe,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;CAC/D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type HttpClient } from '@effect/platform';
|
|
2
|
+
import { type HttpClientError } from '@effect/platform/HttpClientError';
|
|
3
|
+
import { type HttpClientResponse } from '@effect/platform/HttpClientResponse';
|
|
4
|
+
import { Context, Duration, Effect, Layer } from 'effect';
|
|
5
|
+
export type RetryOptions = {
|
|
6
|
+
timeout: Duration.Duration;
|
|
7
|
+
retryTimes: number;
|
|
8
|
+
retryBaseDelay: Duration.Duration;
|
|
9
|
+
};
|
|
10
|
+
declare const HttpConfig_base: Context.TagClass<HttpConfig, "HttpConfig", RetryOptions>;
|
|
11
|
+
export declare class HttpConfig extends HttpConfig_base {
|
|
12
|
+
static default: Layer.Layer<HttpConfig, never, never>;
|
|
13
|
+
}
|
|
14
|
+
export declare const withRetry: (effect: Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.HttpClient>, { timeout, retryBaseDelay, retryTimes, }?: Partial<RetryOptions>) => Effect.Effect<unknown, Error | HttpClientError | import("effect/Cause").TimeoutException, HttpClient.HttpClient>;
|
|
15
|
+
export declare const withRetryConfig: (effect: Effect.Effect<HttpClientResponse, HttpClientError, HttpClient.HttpClient>) => Effect.Effect<unknown, Error | HttpClientError, HttpConfig | HttpClient.HttpClient>;
|
|
16
|
+
export declare const withLogging: <A extends HttpClientResponse, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare const encodeAuthHeader: (challenge: Uint8Array) => string;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/http-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,QAAQ,CAAC;AAMpE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC;CACnC,CAAC;;AAGF,qBAAa,UAAW,SAAQ,eAAqD;IACnF,MAAM,CAAC,OAAO,wCAIX;CACJ;AAGD,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,CAAC,EACjF,2CAIG,OAAO,CAAC,YAAY,CAAM,qHAa9B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,CAAC,wFAI7G,CAAC;AAEL,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,kBAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2BACd,CAAC;AAEjF;;GAEG;AAEH,eAAO,MAAM,gBAAgB,GAAI,WAAW,UAAU,WAGrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.test.d.ts","sourceRoot":"","sources":["../../../src/http-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './auth';
|
|
3
3
|
export * from './defs';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './edge-client';
|
|
5
5
|
export * from './errors';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './protocol';
|
|
7
7
|
export * from './edge-http-client';
|
|
8
8
|
export * from './edge-identity';
|
|
9
9
|
export * from './edge-ws-muxer';
|
|
10
|
+
export * from './http-client';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,4CAA4C,CAAC;AAE3D,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,4CAA4C,CAAC;AAE3D,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
export type TestServer = {
|
|
3
|
+
url: string;
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type ResponseHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
7
|
+
export declare const createTestServer: (responseHandler: ResponseHandler) => Promise<TestServer>;
|
|
8
|
+
export declare const responseHandler: (cb: (attempt: number) => false | object) => ResponseHandler;
|
|
9
|
+
//# sourceMappingURL=test-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-server.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-server.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC;AAE5F,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,eAAe,wBAahE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,GAAG,MAAM,KAAG,eAczE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,OAAO,
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,OAAO,EAAE,KAAK,OAAO,EAAoC,MAAM,4CAA4C,CAAC;AAG5G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,KAAK,sBAAsB,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,GAAG,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CACpE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAU,aAAmB,EAAE,SAAS,sBAAsB;;;;;;;YAOzE,SAAS;eAAS,cAAc;;mCAwErC,OAAO,mBAAmB,UAAU;uBA1BhC,OAAO;;EAS7B,CAAC"}
|