@dxos/protocols 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/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/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 +69 -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 +31 -22
- 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 +121 -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 +300 -145
- package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.js +37 -33
- 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 +31 -31
- package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/src/proto/gen/google/protobuf.js.map +1 -1
- package/dist/src/proto/gen/index.d.ts +10 -0
- package/dist/src/proto/gen/index.d.ts.map +1 -1
- package/dist/src/proto/gen/index.js +1 -1
- package/dist/src/proto/gen/index.js.map +1 -1
- package/dist/src/proto/index.d.ts +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/automerge.ts +8 -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 +87 -27
- 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 +203 -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 +21 -3
- 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 +300 -145
- 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 +31 -31
- package/src/proto/gen/index.ts +11 -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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
// @generated by protoc-gen-es v2.
|
|
5
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
6
6
|
// @generated from file dxos/service/tunnel.proto (package dxos.service.tunnel, syntax proto3)
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es v2.
|
|
1
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
2
2
|
// @generated from file dxos/tracing.proto (package dxos.tracing, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
// @generated by protoc-gen-es v2.
|
|
5
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
6
6
|
// @generated from file dxos/type.proto (package dxos.type, syntax proto3)
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
// @generated by protoc-gen-es v2.
|
|
5
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
6
6
|
// @generated from file dxos/value.proto (package dxos.value, syntax proto3)
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
// @generated by protoc-gen-es v2.
|
|
5
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
6
6
|
// @generated from file example/testing/data.proto (package example.testing.data, syntax proto3)
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2020 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
// @generated by protoc-gen-es v2.
|
|
5
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=js"
|
|
6
6
|
// @generated from file example/testing/rpc.proto (package example.testing.rpc, syntax proto3)
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
|
package/src/codec.test.ts
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type SpaceId } from '@dxos/keys';
|
|
6
|
+
|
|
7
|
+
import type * as FeedProtocol from '../FeedProtocol';
|
|
8
|
+
import { type CreateDocumentRequest, type CreateDocumentResponse } from '../proto/gen/dxos/echo/service';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
|
|
12
|
+
API for the edge functions service.
|
|
13
|
+
A function module should be a valid cloudflare worker module.
|
|
14
|
+
|
|
15
|
+
# Fetching metadata (done on deploy)
|
|
16
|
+
|
|
17
|
+
GET http://functions.dxos.internal/
|
|
18
|
+
X-DXOS-Function-Route: meta
|
|
19
|
+
|
|
20
|
+
Expected to return `FunctionMetadata` in JSON:
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
key: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
inputSchema?: JsonSchemaType;
|
|
27
|
+
outputSchema?: JsonSchemaType;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Invoking the function
|
|
31
|
+
|
|
32
|
+
POST http://functions.dxos.internal/
|
|
33
|
+
Content-Type: application/json
|
|
34
|
+
X-Trace-Queue-Dxn: dxn:queue:trace:AAAAAA:BBBBBB
|
|
35
|
+
X-Invocation-Id: XXXXXXX
|
|
36
|
+
X-Edge-Env: production
|
|
37
|
+
|
|
38
|
+
{input_data}
|
|
39
|
+
|
|
40
|
+
Expected to return `EdgeEnvelope` with the output data:
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
success: true,
|
|
44
|
+
data: unknown
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
On Error returns `EdgeEnvelope` with error:
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
success: false,
|
|
51
|
+
message: string
|
|
52
|
+
error: EncodedError
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Environment available to the function running on Cloudflare.
|
|
59
|
+
*/
|
|
60
|
+
export interface Env {
|
|
61
|
+
QUEUE_SERVICE: QueueService;
|
|
62
|
+
DATA_SERVICE: DataService;
|
|
63
|
+
FUNCTIONS_AI_SERVICE: FunctionsAiService;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Use to trace the execution across multiple services.
|
|
68
|
+
*
|
|
69
|
+
* NOTE: Currently unused in functions.
|
|
70
|
+
*/
|
|
71
|
+
export interface ExecutionContext {}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Database API for other CF services like functions.
|
|
75
|
+
*/
|
|
76
|
+
export interface DataService {
|
|
77
|
+
getSpaceMeta(ctx: ExecutionContext, spaceId: SpaceId): Promise<RpcResult<SpaceMeta | undefined>>;
|
|
78
|
+
getDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string): Promise<RpcResult<RawDocument | undefined>>;
|
|
79
|
+
|
|
80
|
+
query(ctx: ExecutionContext, request: QueryRequest): Promise<RpcResult<QueryResponse>>;
|
|
81
|
+
queryDocuments(ctx: ExecutionContext, request: QueryRequest): Promise<RpcResult<QueryDocumentsResponse>>;
|
|
82
|
+
queryReferences(ctx: ExecutionContext, request: QueryReferencesRequest): Promise<RpcResult<QueryReferencesResponse>>;
|
|
83
|
+
|
|
84
|
+
createDocument(ctx: ExecutionContext, request: CreateDocumentRequest): Promise<RpcResult<CreateDocumentResponse>>;
|
|
85
|
+
|
|
86
|
+
// TODO(burdon): Update? Return DocumentEntry?
|
|
87
|
+
changeDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface QueueService {
|
|
91
|
+
queryQueue: (
|
|
92
|
+
ctx: ExecutionContext,
|
|
93
|
+
request: FeedProtocol.QueryQueueRequest,
|
|
94
|
+
) => Promise<RpcResult<FeedProtocol.QueryResult>>;
|
|
95
|
+
insertIntoQueue: (
|
|
96
|
+
ctx: ExecutionContext,
|
|
97
|
+
request: FeedProtocol.InsertIntoQueueRequest,
|
|
98
|
+
) => Promise<RpcResult<RpcDisposable>>;
|
|
99
|
+
deleteFromQueue: (
|
|
100
|
+
ctx: ExecutionContext,
|
|
101
|
+
request: FeedProtocol.DeleteFromQueueRequest,
|
|
102
|
+
) => Promise<RpcResult<RpcDisposable>>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* FunctionsAiService API for other CF services like functions.
|
|
107
|
+
*/
|
|
108
|
+
export interface FunctionsAiService {
|
|
109
|
+
/**
|
|
110
|
+
* Enables proxying HTTP requests to the AI service from other workers.
|
|
111
|
+
*/
|
|
112
|
+
fetch(request: Request): Promise<RpcResult<Response>>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ObjectDocumentJson = {
|
|
116
|
+
type?: string;
|
|
117
|
+
objectId: string;
|
|
118
|
+
documentId: string;
|
|
119
|
+
/** Base64 encoding of a document. */
|
|
120
|
+
document: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type SpaceMeta = {
|
|
124
|
+
spaceKey: string;
|
|
125
|
+
rootDocumentId: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type QueryRequest = {
|
|
129
|
+
spaceId: string;
|
|
130
|
+
type?: string;
|
|
131
|
+
where?: Record<string, any>;
|
|
132
|
+
objectIds?: string[];
|
|
133
|
+
cursor?: string;
|
|
134
|
+
limit?: number;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type QueryResponse = {
|
|
138
|
+
results: ObjectSnapshot[];
|
|
139
|
+
cursor?: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* TODO(yaroslav): make Indexer return EchoObject after create() can properly reconstruct an object
|
|
144
|
+
* from this structure (meta, id and type aren't handled properly)
|
|
145
|
+
*/
|
|
146
|
+
export type ObjectSnapshot = {
|
|
147
|
+
type?: string;
|
|
148
|
+
documentId: string;
|
|
149
|
+
objectId: string;
|
|
150
|
+
// TODO(mykola): Use ObjectStructure from @dxos/echo-protocol.
|
|
151
|
+
object: unknown;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type ObjectReference = {
|
|
155
|
+
fromId: string;
|
|
156
|
+
toId: string;
|
|
157
|
+
fieldName: string;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type QueryDocumentsResponse = {
|
|
161
|
+
results: RawObject[];
|
|
162
|
+
cursor?: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type RawDocument = {
|
|
166
|
+
documentId: string;
|
|
167
|
+
data: Uint8Array;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type RawObject = {
|
|
171
|
+
type?: string;
|
|
172
|
+
objectId: string;
|
|
173
|
+
document: RawDocument;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type QueryReferencesRequest = {
|
|
177
|
+
spaceId: string;
|
|
178
|
+
objectId: string;
|
|
179
|
+
referenceType: 'from' | 'to';
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type QueryReferencesResponse = {
|
|
183
|
+
references: ObjectReference[];
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Cloudflare Workers RPC returns objects/arrays/stubs that may need to be explicitly disposed.
|
|
188
|
+
*
|
|
189
|
+
* See: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
190
|
+
*/
|
|
191
|
+
export interface RpcDisposable {
|
|
192
|
+
/**
|
|
193
|
+
* Disposes the RPC stub / returned value and releases any server-side resources it references.
|
|
194
|
+
*/
|
|
195
|
+
[Symbol.dispose](): void;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Wraps a return type so that any non-primitive value is marked as disposable.
|
|
200
|
+
*
|
|
201
|
+
* This models Workers RPC behavior where any returned object (including arrays) gets a disposer added.
|
|
202
|
+
*/
|
|
203
|
+
export type RpcResult<T> = T extends object ? T & RpcDisposable : T;
|