@dxos/protocols 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/FunctionProtocol.d.ts +6 -0
- package/dist/src/FunctionProtocol.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts +189 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts.map +1 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.js +39 -0
- package/dist/src/buf/proto/gen/dxos/client/queue_pb.js.map +1 -0
- package/dist/src/buf/proto/gen/dxos/config_pb.d.ts +4 -0
- package/dist/src/buf/proto/gen/dxos/config_pb.d.ts.map +1 -1
- package/dist/src/buf/proto/gen/dxos/config_pb.js +1 -1
- package/dist/src/buf/proto/gen/dxos/config_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/edge/EdgeFunctionEnv.d.ts +35 -10
- package/dist/src/edge/EdgeFunctionEnv.d.ts.map +1 -1
- package/dist/src/edge/edge.d.ts +17 -13
- package/dist/src/edge/edge.d.ts.map +1 -1
- package/dist/src/edge/edge.js +15 -10
- package/dist/src/edge/edge.js.map +1 -1
- package/dist/src/errors/base-errors.d.ts +18 -24
- package/dist/src/errors/base-errors.d.ts.map +1 -1
- package/dist/src/errors/base-errors.js +3 -3
- package/dist/src/errors/base-errors.js.map +1 -1
- package/dist/src/errors/errors.d.ts +132 -176
- package/dist/src/errors/errors.d.ts.map +1 -1
- package/dist/src/errors/errors.js +44 -44
- package/dist/src/errors/errors.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.d.ts +239 -136
- package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/client/services.js +27 -27
- package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/src/proto/gen/dxos/config.d.ts +5 -0
- package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/config.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/query.d.ts +17 -1
- package/dist/src/proto/gen/dxos/echo/query.d.ts.map +1 -1
- package/dist/src/proto/gen/dxos/echo/query.js.map +1 -1
- package/dist/src/proto/gen/dxos/echo/service.d.ts +34 -8
- package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
- package/dist/src/proto/gen/index.d.ts +8 -0
- package/dist/src/proto/gen/index.d.ts.map +1 -1
- package/dist/src/proto/gen/index.js +1 -1
- package/dist/src/proto/gen/index.js.map +1 -1
- package/dist/src/queue.d.ts +1 -35
- package/dist/src/queue.d.ts.map +1 -1
- package/dist/src/queue.js +1 -4
- package/dist/src/queue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -15
- package/src/FunctionProtocol.ts +6 -2
- 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 +231 -0
- package/src/buf/proto/gen/dxos/client/services_pb.ts +1 -1
- package/src/buf/proto/gen/dxos/config_pb.ts +7 -2
- 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/edge/EdgeFunctionEnv.ts +38 -10
- package/src/edge/edge.ts +18 -22
- package/src/errors/base-errors.ts +3 -3
- package/src/errors/errors.ts +44 -44
- package/src/index.ts +0 -1
- package/src/proto/dxos/client/queue.proto +67 -0
- package/src/proto/dxos/config.proto +2 -0
- 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 +239 -136
- package/src/proto/gen/dxos/config.ts +5 -0
- package/src/proto/gen/dxos/echo/query.ts +17 -1
- package/src/proto/gen/dxos/echo/service.ts +33 -8
- package/src/proto/gen/index.ts +9 -1
- package/src/queue.ts +9 -46
- package/dist/src/query.d.ts +0 -5
- package/dist/src/query.d.ts.map +0 -1
- package/dist/src/query.js +0 -8
- package/dist/src/query.js.map +0 -1
- package/src/query.ts +0 -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.10.1 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
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type SpaceId } from '@dxos/keys';
|
|
6
6
|
|
|
7
|
+
import { type CreateDocumentRequest, type CreateDocumentResponse } from '../proto/gen/dxos/echo/service';
|
|
7
8
|
import { type QueryResult, type QueueQuery } from '../queue';
|
|
8
9
|
|
|
9
10
|
/*
|
|
@@ -59,6 +60,7 @@ On Error returns `EdgeEnvelope` with error:
|
|
|
59
60
|
export interface Env {
|
|
60
61
|
QUEUE_SERVICE: QueueService;
|
|
61
62
|
DATA_SERVICE: DataService;
|
|
63
|
+
FUNCTIONS_AI_SERVICE: FunctionsAiService;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -72,22 +74,34 @@ export interface ExecutionContext {}
|
|
|
72
74
|
* Database API for other CF services like functions.
|
|
73
75
|
*/
|
|
74
76
|
export interface DataService {
|
|
75
|
-
getSpaceMeta(ctx: ExecutionContext, spaceId: SpaceId): Promise<SpaceMeta | undefined
|
|
76
|
-
getDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string): Promise<RawDocument | undefined
|
|
77
|
+
getSpaceMeta(ctx: ExecutionContext, spaceId: SpaceId): Promise<RpcResult<SpaceMeta | undefined>>;
|
|
78
|
+
getDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string): Promise<RpcResult<RawDocument | undefined>>;
|
|
77
79
|
|
|
78
|
-
query(ctx: ExecutionContext, request: QueryRequest): Promise<QueryResponse
|
|
79
|
-
queryDocuments(ctx: ExecutionContext, request: QueryRequest): Promise<QueryDocumentsResponse
|
|
80
|
-
queryReferences(ctx: ExecutionContext, request: QueryReferencesRequest): Promise<QueryReferencesResponse
|
|
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>>;
|
|
81
85
|
|
|
82
86
|
// TODO(burdon): Update? Return DocumentEntry?
|
|
83
87
|
changeDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
export interface QueueService {
|
|
87
|
-
query(ctx: ExecutionContext, queueDXN: string, query: Omit<QueueQuery, 'queueId'>): Promise<QueryResult
|
|
91
|
+
query(ctx: ExecutionContext, queueDXN: string, query: Omit<QueueQuery, 'queueId'>): Promise<RpcResult<QueryResult>>;
|
|
88
92
|
append(ctx: ExecutionContext, queueDXN: string, objects: unknown[]): Promise<void>;
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/**
|
|
96
|
+
* FunctionsAiService API for other CF services like functions.
|
|
97
|
+
*/
|
|
98
|
+
export interface FunctionsAiService {
|
|
99
|
+
/**
|
|
100
|
+
* Enables proxying HTTP requests to the AI service from other workers.
|
|
101
|
+
*/
|
|
102
|
+
fetch(request: Request): Promise<RpcResult<Response>>;
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
export type ObjectDocumentJson = {
|
|
92
106
|
type?: string;
|
|
93
107
|
objectId: string;
|
|
@@ -159,7 +173,21 @@ export type QueryReferencesResponse = {
|
|
|
159
173
|
references: ObjectReference[];
|
|
160
174
|
};
|
|
161
175
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Cloudflare Workers RPC returns objects/arrays/stubs that may need to be explicitly disposed.
|
|
178
|
+
*
|
|
179
|
+
* See: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
|
|
180
|
+
*/
|
|
181
|
+
export interface RpcDisposable {
|
|
182
|
+
/**
|
|
183
|
+
* Disposes the RPC stub / returned value and releases any server-side resources it references.
|
|
184
|
+
*/
|
|
185
|
+
[Symbol.dispose](): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Wraps a return type so that any non-primitive value is marked as disposable.
|
|
190
|
+
*
|
|
191
|
+
* This models Workers RPC behavior where any returned object (including arrays) gets a disposer added.
|
|
192
|
+
*/
|
|
193
|
+
export type RpcResult<T> = T extends object ? T & RpcDisposable : T;
|
package/src/edge/edge.ts
CHANGED
|
@@ -23,13 +23,15 @@ export type EdgeSuccess<T> = {
|
|
|
23
23
|
data: T;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
message
|
|
29
|
-
context
|
|
30
|
-
stack
|
|
31
|
-
cause
|
|
32
|
-
};
|
|
26
|
+
const _SerializedError = Schema.Struct({
|
|
27
|
+
name: Schema.optional(Schema.String),
|
|
28
|
+
message: Schema.optional(Schema.String),
|
|
29
|
+
context: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
30
|
+
stack: Schema.optional(Schema.String),
|
|
31
|
+
cause: Schema.optional(Schema.suspend(() => SerializedError)),
|
|
32
|
+
});
|
|
33
|
+
export interface SerializedError extends Schema.Schema.Type<typeof _SerializedError> {}
|
|
34
|
+
export const SerializedError: Schema.Schema<SerializedError, SerializedError, never> = _SerializedError;
|
|
33
35
|
|
|
34
36
|
export type EdgeErrorData = { type: string } & Record<string, any>;
|
|
35
37
|
|
|
@@ -37,11 +39,6 @@ export type EdgeErrorData = { type: string } & Record<string, any>;
|
|
|
37
39
|
* This is the shape of the error response from the Edge service,
|
|
38
40
|
* when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
|
|
39
41
|
*/
|
|
40
|
-
// TODO(dmaretskyi): Refactor this type to just be { success: false, error: SerializedError }
|
|
41
|
-
// reason -> error.message
|
|
42
|
-
// cause -> error.cause
|
|
43
|
-
// data.type -> error.code
|
|
44
|
-
// ...data -> error.context
|
|
45
42
|
export type EdgeFailure = {
|
|
46
43
|
/**
|
|
47
44
|
* Branded Type.
|
|
@@ -243,20 +240,19 @@ export type UploadFunctionRequest = {
|
|
|
243
240
|
* Runtime cannot be changed once the function was deployed.
|
|
244
241
|
* @default Runtime.WORKERS_FOR_PLATFORMS
|
|
245
242
|
*/
|
|
246
|
-
runtime?:
|
|
243
|
+
runtime?: FunctionRuntimeKind;
|
|
247
244
|
};
|
|
248
245
|
|
|
249
246
|
/**
|
|
250
247
|
* Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
|
|
251
248
|
*/
|
|
252
|
-
export
|
|
249
|
+
export const FunctionRuntimeKind = Schema.Enums({
|
|
253
250
|
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
254
|
-
WORKERS_FOR_PLATFORMS
|
|
251
|
+
WORKERS_FOR_PLATFORMS: 'WORKERS_FOR_PLATFORMS',
|
|
255
252
|
// https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
|
|
256
|
-
WORKER_LOADER
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
253
|
+
WORKER_LOADER: 'WORKER_LOADER',
|
|
254
|
+
});
|
|
255
|
+
export type FunctionRuntimeKind = Schema.Schema.Type<typeof FunctionRuntimeKind>;
|
|
260
256
|
|
|
261
257
|
export type UploadFunctionResponseBody = {
|
|
262
258
|
functionId: string;
|
|
@@ -419,15 +415,15 @@ const MAX_ERROR_DEPTH = 3;
|
|
|
419
415
|
*/
|
|
420
416
|
export const ErrorCodec = Object.freeze({
|
|
421
417
|
encode: (err: Error, depth: number = 0): SerializedError => ({
|
|
422
|
-
|
|
418
|
+
name: 'name' in err ? err.name : (err as any).code || 'Error',
|
|
423
419
|
message: err.message,
|
|
424
420
|
stack: err.stack,
|
|
425
421
|
cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
|
|
426
422
|
}),
|
|
427
423
|
decode: (serializedError: SerializedError, depth: number = 0): Error => {
|
|
428
424
|
let err: Error;
|
|
429
|
-
if (typeof serializedError.
|
|
430
|
-
err = new BaseError(serializedError.
|
|
425
|
+
if (typeof serializedError.name === 'string') {
|
|
426
|
+
err = new BaseError(serializedError.name, {
|
|
431
427
|
message: serializedError.message ?? 'Unknown error',
|
|
432
428
|
cause:
|
|
433
429
|
serializedError.cause && depth < MAX_ERROR_DEPTH
|
|
@@ -12,15 +12,15 @@ import { BaseError } from '@dxos/errors';
|
|
|
12
12
|
* User facing API Errors.
|
|
13
13
|
* E.g., something was misconfigured.
|
|
14
14
|
*/
|
|
15
|
-
export class ApiError extends BaseError.extend('
|
|
15
|
+
export class ApiError extends BaseError.extend('ApiError') {}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal system errors.
|
|
19
19
|
* E.g., unexpected/unrecoverable runtime error.
|
|
20
20
|
*/
|
|
21
|
-
export class SystemError extends BaseError.extend('
|
|
21
|
+
export class SystemError extends BaseError.extend('SystemError') {}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Database errors.
|
|
25
25
|
*/
|
|
26
|
-
export class DatabaseError extends BaseError.extend('
|
|
26
|
+
export class DatabaseError extends BaseError.extend('DatabaseError') {}
|
package/src/errors/errors.ts
CHANGED
|
@@ -13,90 +13,90 @@ import { registerError, registerErrorMessageContext, registerErrorNoArgs } from
|
|
|
13
13
|
* Thrown when request was terminated because the RPC endpoint has been closed.
|
|
14
14
|
*/
|
|
15
15
|
export class RpcClosedError extends BaseError.extend(
|
|
16
|
-
'
|
|
16
|
+
'RpcClosedError',
|
|
17
17
|
'Request was terminated because the RPC endpoint is closed.',
|
|
18
18
|
) {}
|
|
19
19
|
|
|
20
|
-
registerErrorNoArgs('
|
|
20
|
+
registerErrorNoArgs('RpcClosedError', RpcClosedError);
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Thrown when `request` is called when RPC has not been opened.
|
|
24
24
|
*/
|
|
25
|
-
export class RpcNotOpenError extends BaseError.extend('
|
|
25
|
+
export class RpcNotOpenError extends BaseError.extend('RpcNotOpenError', 'RPC has not been opened.') {}
|
|
26
26
|
|
|
27
|
-
registerErrorNoArgs('
|
|
27
|
+
registerErrorNoArgs('RpcNotOpenError', RpcNotOpenError);
|
|
28
28
|
|
|
29
|
-
export class CancelledError extends BaseError.extend('
|
|
29
|
+
export class CancelledError extends BaseError.extend('CancelledError') {}
|
|
30
30
|
|
|
31
|
-
registerErrorMessageContext('
|
|
31
|
+
registerErrorMessageContext('CancelledError', CancelledError);
|
|
32
32
|
|
|
33
|
-
export class InvalidConfigError extends BaseError.extend('
|
|
33
|
+
export class InvalidConfigError extends BaseError.extend('InvalidConfigError') {}
|
|
34
34
|
|
|
35
|
-
registerErrorMessageContext('
|
|
35
|
+
registerErrorMessageContext('InvalidConfigError', InvalidConfigError);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Explicit failure to connect with remote client services.
|
|
39
39
|
*/
|
|
40
|
-
export class RemoteServiceConnectionError extends BaseError.extend('
|
|
40
|
+
export class RemoteServiceConnectionError extends BaseError.extend('RemoteServiceConnectionError') {}
|
|
41
41
|
|
|
42
|
-
registerErrorMessageContext('
|
|
42
|
+
registerErrorMessageContext('RemoteServiceConnectionError', RemoteServiceConnectionError);
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Failed to open a connection to remote client services.
|
|
46
46
|
*/
|
|
47
|
-
export class RemoteServiceConnectionTimeout extends BaseError.extend('
|
|
47
|
+
export class RemoteServiceConnectionTimeout extends BaseError.extend('RemoteServiceConnectionTimeout') {}
|
|
48
48
|
|
|
49
|
-
registerErrorMessageContext('
|
|
49
|
+
registerErrorMessageContext('RemoteServiceConnectionTimeout', RemoteServiceConnectionTimeout);
|
|
50
50
|
|
|
51
|
-
export class DataCorruptionError extends BaseError.extend('
|
|
51
|
+
export class DataCorruptionError extends BaseError.extend('DataCorruptionError') {}
|
|
52
52
|
|
|
53
|
-
registerErrorMessageContext('
|
|
53
|
+
registerErrorMessageContext('DataCorruptionError', DataCorruptionError);
|
|
54
54
|
|
|
55
|
-
export class InvalidInvitationExtensionRoleError extends BaseError.extend('
|
|
55
|
+
export class InvalidInvitationExtensionRoleError extends BaseError.extend('InvalidInvitationExtensionRoleError') {}
|
|
56
56
|
|
|
57
|
-
registerErrorMessageContext('
|
|
57
|
+
registerErrorMessageContext('InvalidInvitationExtensionRoleError', InvalidInvitationExtensionRoleError);
|
|
58
58
|
|
|
59
|
-
export class IdentityNotInitializedError extends BaseError.extend('
|
|
59
|
+
export class IdentityNotInitializedError extends BaseError.extend('IdentityNotInitializedError') {}
|
|
60
60
|
|
|
61
|
-
registerErrorMessageContext('
|
|
61
|
+
registerErrorMessageContext('IdentityNotInitializedError', IdentityNotInitializedError);
|
|
62
62
|
|
|
63
|
-
export class InvalidInvitationError extends BaseError.extend('
|
|
63
|
+
export class InvalidInvitationError extends BaseError.extend('InvalidInvitationError') {}
|
|
64
64
|
|
|
65
|
-
registerErrorMessageContext('
|
|
65
|
+
registerErrorMessageContext('InvalidInvitationError', InvalidInvitationError);
|
|
66
66
|
|
|
67
|
-
export class AlreadyJoinedError extends BaseError.extend('
|
|
67
|
+
export class AlreadyJoinedError extends BaseError.extend('AlreadyJoinedError') {}
|
|
68
68
|
|
|
69
|
-
registerErrorMessageContext('
|
|
69
|
+
registerErrorMessageContext('AlreadyJoinedError', AlreadyJoinedError);
|
|
70
70
|
|
|
71
|
-
export class ConnectionResetError extends BaseError.extend('
|
|
71
|
+
export class ConnectionResetError extends BaseError.extend('ConnectionResetError') {}
|
|
72
72
|
|
|
73
|
-
registerErrorMessageContext('
|
|
73
|
+
registerErrorMessageContext('ConnectionResetError', ConnectionResetError);
|
|
74
74
|
|
|
75
|
-
export class TimeoutError extends BaseError.extend('
|
|
75
|
+
export class TimeoutError extends BaseError.extend('TimeoutError') {}
|
|
76
76
|
|
|
77
|
-
registerErrorMessageContext('
|
|
77
|
+
registerErrorMessageContext('TimeoutError', TimeoutError);
|
|
78
78
|
|
|
79
79
|
// General protocol error.
|
|
80
|
-
export class ProtocolError extends BaseError.extend('
|
|
80
|
+
export class ProtocolError extends BaseError.extend('ProtocolError') {}
|
|
81
81
|
|
|
82
|
-
registerErrorMessageContext(ProtocolError.
|
|
82
|
+
registerErrorMessageContext(ProtocolError.name, ProtocolError);
|
|
83
83
|
|
|
84
84
|
// General connectivity errors.
|
|
85
|
-
export class ConnectivityError extends BaseError.extend('
|
|
85
|
+
export class ConnectivityError extends BaseError.extend('ConnectivityError') {}
|
|
86
86
|
|
|
87
|
-
registerErrorMessageContext('
|
|
87
|
+
registerErrorMessageContext('ConnectivityError', ConnectivityError);
|
|
88
88
|
|
|
89
|
-
export class RateLimitExceededError extends BaseError.extend('
|
|
89
|
+
export class RateLimitExceededError extends BaseError.extend('RateLimitExceededError') {}
|
|
90
90
|
|
|
91
|
-
registerErrorMessageContext('
|
|
91
|
+
registerErrorMessageContext('RateLimitExceededError', RateLimitExceededError);
|
|
92
92
|
|
|
93
93
|
// TODO(nf): Rename? the protocol isn't what's unknown...
|
|
94
|
-
export class UnknownProtocolError extends BaseError.extend('
|
|
94
|
+
export class UnknownProtocolError extends BaseError.extend('UnknownProtocolError') {}
|
|
95
95
|
|
|
96
|
-
registerError(UnknownProtocolError.
|
|
96
|
+
registerError(UnknownProtocolError.name, (message, context) => new UnknownProtocolError({ message, context }));
|
|
97
97
|
|
|
98
98
|
export class InvalidStorageVersionError extends BaseError.extend(
|
|
99
|
-
'
|
|
99
|
+
'InvalidStorageVersionError',
|
|
100
100
|
'Invalid storage version.',
|
|
101
101
|
) {
|
|
102
102
|
constructor(expected: number, actual: number) {
|
|
@@ -104,40 +104,40 @@ export class InvalidStorageVersionError extends BaseError.extend(
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
registerError('
|
|
107
|
+
registerError('InvalidStorageVersionError', (_, context) => {
|
|
108
108
|
return new InvalidStorageVersionError(context.expected ?? NaN, context.actual ?? NaN);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
export class SpaceNotFoundError extends BaseError.extend('
|
|
111
|
+
export class SpaceNotFoundError extends BaseError.extend('SpaceNotFoundError', 'Space not found.') {
|
|
112
112
|
constructor(spaceKey: PublicKey) {
|
|
113
113
|
super({ context: { spaceKey } });
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
registerError('
|
|
117
|
+
registerError('SpaceNotFoundError', (_, context) => {
|
|
118
118
|
return new SpaceNotFoundError(PublicKey.safeFrom(context.spaceKey) ?? PublicKey.from('00'));
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
export class EntityNotFoundError extends BaseError.extend('
|
|
121
|
+
export class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Item not found.') {
|
|
122
122
|
constructor(entityId: ObjectId) {
|
|
123
123
|
super({ context: { entityId } });
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
registerError('
|
|
127
|
+
registerError('EntityNotFoundError', (_, context) => {
|
|
128
128
|
return new EntityNotFoundError(context.entityId);
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
export class UnknownModelError extends BaseError.extend('
|
|
131
|
+
export class UnknownModelError extends BaseError.extend('UnknownModelError', 'Unknown model.') {
|
|
132
132
|
constructor(model: string) {
|
|
133
133
|
super({ context: { model } });
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
registerError('
|
|
137
|
+
registerError('UnknownModelError', (_, context) => {
|
|
138
138
|
return new UnknownModelError(context.model);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
export class AuthorizationError extends BaseError.extend('
|
|
141
|
+
export class AuthorizationError extends BaseError.extend('AuthorizationError') {}
|
|
142
142
|
|
|
143
|
-
registerErrorMessageContext('
|
|
143
|
+
registerErrorMessageContext('AuthorizationError', AuthorizationError);
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './errors/index.js';
|
|
|
10
10
|
export * from './indexing.js';
|
|
11
11
|
export * from './messenger.js';
|
|
12
12
|
export * from './profile-archive.js';
|
|
13
|
-
export * from './query.js';
|
|
14
13
|
export * from './queue.js';
|
|
15
14
|
export * from './space-archive.js';
|
|
16
15
|
export * from './storage.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package dxos.client.services;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/struct.proto";
|
|
6
|
+
import "google/protobuf/empty.proto";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
message QueueQuery {
|
|
10
|
+
string space_id = 1;
|
|
11
|
+
|
|
12
|
+
optional string queues_namespace = 2;
|
|
13
|
+
|
|
14
|
+
/// Queries the whole space if missing.
|
|
15
|
+
repeated string queue_ids = 3;
|
|
16
|
+
|
|
17
|
+
/// Filter items after this cursor. Exclusive.
|
|
18
|
+
optional string after = 4;
|
|
19
|
+
|
|
20
|
+
/// Filter items before this cursor. Exclusive.
|
|
21
|
+
optional string before = 5;
|
|
22
|
+
|
|
23
|
+
/// Filter items after this position. Inclusive.
|
|
24
|
+
optional int64 begin_position = 6;
|
|
25
|
+
|
|
26
|
+
/// Filter items before this position. Exclusive.
|
|
27
|
+
optional int64 end_position = 7;
|
|
28
|
+
|
|
29
|
+
optional int32 limit = 8;
|
|
30
|
+
optional bool reverse = 9;
|
|
31
|
+
|
|
32
|
+
// TODO(dmaretskyi): Remove this field -- raw queues dont index object IDs anymore.
|
|
33
|
+
repeated string object_ids = 100;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
message QueueQueryResult {
|
|
37
|
+
repeated google.protobuf.Struct objects = 1;
|
|
38
|
+
|
|
39
|
+
/// Cursor to query the next items. Can be passed to `after` in query to keep querying.
|
|
40
|
+
string next_cursor = 2;
|
|
41
|
+
|
|
42
|
+
string prev_cursor = 3;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message QueryQueueRequest {
|
|
46
|
+
QueueQuery query = 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
message InsertIntoQueueRequest {
|
|
50
|
+
string subspace_tag = 1;
|
|
51
|
+
string space_id = 2;
|
|
52
|
+
string queue_id = 3;
|
|
53
|
+
repeated google.protobuf.Struct objects = 4;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message DeleteFromQueueRequest {
|
|
57
|
+
string subspace_tag = 1;
|
|
58
|
+
string space_id = 2;
|
|
59
|
+
string queue_id = 3;
|
|
60
|
+
repeated string object_ids = 4;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
service QueueService {
|
|
64
|
+
rpc QueryQueue(QueryQueueRequest) returns (QueueQueryResult);
|
|
65
|
+
rpc InsertIntoQueue(InsertIntoQueueRequest) returns (google.protobuf.Empty);
|
|
66
|
+
rpc DeleteFromQueue(DeleteFromQueueRequest) returns (google.protobuf.Empty);
|
|
67
|
+
}
|
|
@@ -36,9 +36,12 @@ message Heads {
|
|
|
36
36
|
message QueryResult {
|
|
37
37
|
string id = 1;
|
|
38
38
|
string spaceId = 4;
|
|
39
|
-
string documentId = 5;
|
|
39
|
+
optional string documentId = 5;
|
|
40
|
+
optional string queueId = 6;
|
|
41
|
+
optional string queueNamespace = 7;
|
|
40
42
|
float rank = 3;
|
|
41
43
|
|
|
44
|
+
/// In the ECHO Json object format.
|
|
42
45
|
optional string document_json = 10;
|
|
43
46
|
optional bytes document_automerge = 11;
|
|
44
47
|
|
|
@@ -6,6 +6,7 @@ syntax = "proto3";
|
|
|
6
6
|
|
|
7
7
|
import "dxos/keys.proto";
|
|
8
8
|
import "google/protobuf/empty.proto";
|
|
9
|
+
import "google/protobuf/struct.proto";
|
|
9
10
|
|
|
10
11
|
package dxos.echo.service;
|
|
11
12
|
|
|
@@ -61,12 +62,6 @@ message DocumentUpdate {
|
|
|
61
62
|
* Value returned by `Automerge.saveSince()`.
|
|
62
63
|
*/
|
|
63
64
|
bytes mutation = 2;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Set to true for init mutation of document.
|
|
67
|
-
* default: undefined.
|
|
68
|
-
*/
|
|
69
|
-
optional bool is_new = 3;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
message DocHeadsList {
|
|
@@ -94,6 +89,26 @@ message ReIndexHeadsRequest {
|
|
|
94
89
|
repeated string document_ids = 1;
|
|
95
90
|
}
|
|
96
91
|
|
|
92
|
+
message CreateDocumentRequest {
|
|
93
|
+
/**
|
|
94
|
+
* Space id where the document will be created.
|
|
95
|
+
*/
|
|
96
|
+
string space_id = 1;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Automerge encoded initial document value.
|
|
100
|
+
* Optional - if not provided, an empty document will be created.
|
|
101
|
+
*/
|
|
102
|
+
optional google.protobuf.Struct initial_value = 2;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
message CreateDocumentResponse {
|
|
106
|
+
/**
|
|
107
|
+
* The generated document id.
|
|
108
|
+
*/
|
|
109
|
+
string document_id = 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
97
112
|
message GetSpaceSyncStateRequest {
|
|
98
113
|
string space_id = 1;
|
|
99
114
|
}
|
|
@@ -157,6 +172,12 @@ service DataService {
|
|
|
157
172
|
*/
|
|
158
173
|
rpc UpdateSubscription(UpdateSubscriptionRequest) returns (google.protobuf.Empty);
|
|
159
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Create a new automerge document.
|
|
177
|
+
* Returns the generated document id which is controlled by the host.
|
|
178
|
+
*/
|
|
179
|
+
rpc CreateDocument(CreateDocumentRequest) returns (CreateDocumentResponse);
|
|
180
|
+
|
|
160
181
|
/**
|
|
161
182
|
* Write incremental updates to multiple automerge documents.
|
|
162
183
|
* Used to propagate changes from client to services.
|