@dxos/protocols 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660

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.
Files changed (196) hide show
  1. package/README.md +1 -1
  2. package/dist/src/FeedProtocol.d.ts +528 -0
  3. package/dist/src/FeedProtocol.d.ts.map +1 -0
  4. package/dist/src/FeedProtocol.js +237 -0
  5. package/dist/src/FeedProtocol.js.map +1 -0
  6. package/dist/src/FunctionProtocol.d.ts +8 -2
  7. package/dist/src/FunctionProtocol.d.ts.map +1 -1
  8. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts +231 -0
  9. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts.map +1 -0
  10. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js +44 -0
  11. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js.map +1 -0
  12. package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts +5 -1
  13. package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts.map +1 -1
  14. package/dist/src/buf/proto/gen/dxos/client/services_pb.js +5 -1
  15. package/dist/src/buf/proto/gen/dxos/client/services_pb.js.map +1 -1
  16. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts +12 -2
  17. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts.map +1 -1
  18. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js +1 -1
  19. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js.map +1 -1
  20. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts +55 -9
  21. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts.map +1 -1
  22. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js +15 -5
  23. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js.map +1 -1
  24. package/dist/src/buf/proto/gen/dxos/google_pb.js +1 -1
  25. package/dist/src/buf/proto/gen/dxos/google_pb.js.map +1 -1
  26. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts +1 -0
  27. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts.map +1 -1
  28. package/dist/src/buf/proto/gen/dxos/iframe_pb.js.map +1 -1
  29. package/dist/src/buf/proto/gen/dxos/tracing_pb.js +1 -1
  30. package/dist/src/buf/proto/gen/dxos/tracing_pb.js.map +1 -1
  31. package/dist/src/codec.test.js +1 -1
  32. package/dist/src/edge/EdgeFunctionEnv.d.ts +39 -26
  33. package/dist/src/edge/EdgeFunctionEnv.d.ts.map +1 -1
  34. package/dist/src/edge/edge.d.ts +24 -13
  35. package/dist/src/edge/edge.d.ts.map +1 -1
  36. package/dist/src/edge/edge.js +24 -10
  37. package/dist/src/edge/edge.js.map +1 -1
  38. package/dist/src/edge/errors.d.ts +1 -1
  39. package/dist/src/edge/errors.js +1 -1
  40. package/dist/src/edge/index.d.ts +3 -3
  41. package/dist/src/edge/index.js +3 -3
  42. package/dist/src/errors/base-errors.d.ts +18 -24
  43. package/dist/src/errors/base-errors.d.ts.map +1 -1
  44. package/dist/src/errors/base-errors.js +3 -3
  45. package/dist/src/errors/base-errors.js.map +1 -1
  46. package/dist/src/errors/encoding.d.ts +1 -1
  47. package/dist/src/errors/encoding.js +1 -1
  48. package/dist/src/errors/errors.d.ts +133 -177
  49. package/dist/src/errors/errors.d.ts.map +1 -1
  50. package/dist/src/errors/errors.js +45 -45
  51. package/dist/src/errors/errors.js.map +1 -1
  52. package/dist/src/errors/errors.test.js +1 -1
  53. package/dist/src/errors/helpers.d.ts +1 -1
  54. package/dist/src/errors/index.d.ts +5 -5
  55. package/dist/src/errors/index.js +5 -5
  56. package/dist/src/index.d.ts +12 -13
  57. package/dist/src/index.d.ts.map +1 -1
  58. package/dist/src/index.js +11 -13
  59. package/dist/src/index.js.map +1 -1
  60. package/dist/src/indexing.test.js +1 -1
  61. package/dist/src/proto/gen/dxos/client/services.d.ts +982 -854
  62. package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
  63. package/dist/src/proto/gen/dxos/client/services.js +95 -94
  64. package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
  65. package/dist/src/proto/gen/dxos/devtools/host.d.ts +31 -31
  66. package/dist/src/proto/gen/dxos/devtools/host.d.ts.map +1 -1
  67. package/dist/src/proto/gen/dxos/echo/query.d.ts +17 -1
  68. package/dist/src/proto/gen/dxos/echo/query.d.ts.map +1 -1
  69. package/dist/src/proto/gen/dxos/echo/query.js.map +1 -1
  70. package/dist/src/proto/gen/dxos/echo/service.d.ts +34 -8
  71. package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
  72. package/dist/src/proto/gen/google/protobuf.d.ts +326 -40
  73. package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
  74. package/dist/src/proto/gen/google/protobuf.js +127 -1
  75. package/dist/src/proto/gen/google/protobuf.js.map +1 -1
  76. package/dist/src/proto/gen/index.d.ts +33 -0
  77. package/dist/src/proto/gen/index.d.ts.map +1 -1
  78. package/dist/src/proto/gen/index.js +1 -1
  79. package/dist/src/proto/gen/index.js.map +1 -1
  80. package/dist/src/proto/index.d.ts +2 -2
  81. package/dist/src/proto/index.js +1 -1
  82. package/dist/src/proto/types.d.ts +1 -1
  83. package/dist/src/types.d.ts +2 -2
  84. package/dist/tsconfig.tsbuildinfo +1 -1
  85. package/package.json +19 -15
  86. package/src/FeedProtocol.ts +320 -0
  87. package/src/FunctionProtocol.ts +8 -6
  88. package/src/buf/proto/gen/dxos/agent/dashboard_pb.ts +1 -1
  89. package/src/buf/proto/gen/dxos/agent/echo-proxy_pb.ts +1 -1
  90. package/src/buf/proto/gen/dxos/agent/epoch_pb.ts +1 -1
  91. package/src/buf/proto/gen/dxos/agent/functions_pb.ts +1 -1
  92. package/src/buf/proto/gen/dxos/bot_pb.ts +1 -1
  93. package/src/buf/proto/gen/dxos/client/invitation_pb.ts +1 -1
  94. package/src/buf/proto/gen/dxos/client/logging_pb.ts +1 -1
  95. package/src/buf/proto/gen/dxos/client/queue_pb.ts +280 -0
  96. package/src/buf/proto/gen/dxos/client/services_pb.ts +7 -2
  97. package/src/buf/proto/gen/dxos/config_pb.ts +1 -1
  98. package/src/buf/proto/gen/dxos/devtools/diagnostics_pb.ts +1 -1
  99. package/src/buf/proto/gen/dxos/devtools/host_pb.ts +1 -1
  100. package/src/buf/proto/gen/dxos/devtools/swarm_pb.ts +1 -1
  101. package/src/buf/proto/gen/dxos/echo/blob_pb.ts +1 -1
  102. package/src/buf/proto/gen/dxos/echo/feed_pb.ts +1 -1
  103. package/src/buf/proto/gen/dxos/echo/filter_pb.ts +1 -1
  104. package/src/buf/proto/gen/dxos/echo/indexing_pb.ts +1 -1
  105. package/src/buf/proto/gen/dxos/echo/metadata_pb.ts +1 -1
  106. package/src/buf/proto/gen/dxos/echo/model/document_pb.ts +1 -1
  107. package/src/buf/proto/gen/dxos/echo/model/messenger_pb.ts +1 -1
  108. package/src/buf/proto/gen/dxos/echo/model/text_pb.ts +1 -1
  109. package/src/buf/proto/gen/dxos/echo/object_pb.ts +1 -1
  110. package/src/buf/proto/gen/dxos/echo/query_pb.ts +16 -4
  111. package/src/buf/proto/gen/dxos/echo/service_pb.ts +68 -16
  112. package/src/buf/proto/gen/dxos/echo/snapshot_pb.ts +1 -1
  113. package/src/buf/proto/gen/dxos/echo/timeframe_pb.ts +1 -1
  114. package/src/buf/proto/gen/dxos/edge/calls_pb.ts +1 -1
  115. package/src/buf/proto/gen/dxos/edge/messenger_pb.ts +1 -1
  116. package/src/buf/proto/gen/dxos/edge/signal_pb.ts +1 -1
  117. package/src/buf/proto/gen/dxos/error_pb.ts +1 -1
  118. package/src/buf/proto/gen/dxos/field_options_pb.ts +1 -1
  119. package/src/buf/proto/gen/dxos/google_pb.ts +1 -1
  120. package/src/buf/proto/gen/dxos/gravity_pb.ts +1 -1
  121. package/src/buf/proto/gen/dxos/halo/credentials/auth_pb.ts +1 -1
  122. package/src/buf/proto/gen/dxos/halo/credentials/greet_pb.ts +1 -1
  123. package/src/buf/proto/gen/dxos/halo/credentials/identity_pb.ts +1 -1
  124. package/src/buf/proto/gen/dxos/halo/credentials_pb.ts +1 -1
  125. package/src/buf/proto/gen/dxos/halo/invitations_pb.ts +1 -1
  126. package/src/buf/proto/gen/dxos/halo/keyring_pb.ts +1 -1
  127. package/src/buf/proto/gen/dxos/halo/keys_pb.ts +1 -1
  128. package/src/buf/proto/gen/dxos/halo/signed_pb.ts +1 -1
  129. package/src/buf/proto/gen/dxos/iframe_pb.ts +2 -1
  130. package/src/buf/proto/gen/dxos/keys_pb.ts +1 -1
  131. package/src/buf/proto/gen/dxos/mesh/bridge_pb.ts +1 -1
  132. package/src/buf/proto/gen/dxos/mesh/broadcast_pb.ts +1 -1
  133. package/src/buf/proto/gen/dxos/mesh/messaging_pb.ts +1 -1
  134. package/src/buf/proto/gen/dxos/mesh/muxer_pb.ts +1 -1
  135. package/src/buf/proto/gen/dxos/mesh/presence_pb.ts +1 -1
  136. package/src/buf/proto/gen/dxos/mesh/protocol_pb.ts +1 -1
  137. package/src/buf/proto/gen/dxos/mesh/replicator_pb.ts +1 -1
  138. package/src/buf/proto/gen/dxos/mesh/signal_pb.ts +1 -1
  139. package/src/buf/proto/gen/dxos/mesh/swarm_pb.ts +1 -1
  140. package/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.ts +1 -1
  141. package/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.ts +1 -1
  142. package/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.ts +1 -1
  143. package/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.ts +1 -1
  144. package/src/buf/proto/gen/dxos/mesh/teleport/control_pb.ts +1 -1
  145. package/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.ts +1 -1
  146. package/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.ts +1 -1
  147. package/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.ts +1 -1
  148. package/src/buf/proto/gen/dxos/registry_pb.ts +1 -1
  149. package/src/buf/proto/gen/dxos/rpc_pb.ts +1 -1
  150. package/src/buf/proto/gen/dxos/service/agentmanager_pb.ts +1 -1
  151. package/src/buf/proto/gen/dxos/service/publisher_pb.ts +1 -1
  152. package/src/buf/proto/gen/dxos/service/supervisor_pb.ts +1 -1
  153. package/src/buf/proto/gen/dxos/service/tunnel_pb.ts +1 -1
  154. package/src/buf/proto/gen/dxos/tracing_pb.ts +1 -1
  155. package/src/buf/proto/gen/dxos/type_pb.ts +1 -1
  156. package/src/buf/proto/gen/dxos/value_pb.ts +1 -1
  157. package/src/buf/proto/gen/example/testing/data_pb.ts +1 -1
  158. package/src/buf/proto/gen/example/testing/rpc_pb.ts +1 -1
  159. package/src/codec.test.ts +1 -1
  160. package/src/edge/EdgeFunctionEnv.ts +50 -28
  161. package/src/edge/edge.ts +27 -22
  162. package/src/edge/errors.ts +1 -1
  163. package/src/edge/index.ts +3 -3
  164. package/src/errors/base-errors.ts +3 -3
  165. package/src/errors/encoding.ts +2 -2
  166. package/src/errors/errors.test.ts +1 -1
  167. package/src/errors/errors.ts +46 -46
  168. package/src/errors/helpers.ts +1 -1
  169. package/src/errors/index.ts +5 -5
  170. package/src/index.ts +12 -15
  171. package/src/indexing.test.ts +1 -1
  172. package/src/proto/dxos/client/queue.proto +78 -0
  173. package/src/proto/dxos/client/services.proto +1 -0
  174. package/src/proto/dxos/config.proto +1 -1
  175. package/src/proto/dxos/echo/query.proto +4 -1
  176. package/src/proto/dxos/echo/service.proto +27 -6
  177. package/src/proto/dxos/iframe.proto +1 -0
  178. package/src/proto/gen/dxos/client/services.ts +982 -854
  179. package/src/proto/gen/dxos/devtools/host.ts +31 -31
  180. package/src/proto/gen/dxos/echo/query.ts +17 -1
  181. package/src/proto/gen/dxos/echo/service.ts +33 -8
  182. package/src/proto/gen/google/protobuf.ts +326 -40
  183. package/src/proto/gen/index.ts +34 -1
  184. package/src/proto/index.ts +2 -2
  185. package/src/proto/types.ts +1 -1
  186. package/src/types.ts +2 -2
  187. package/dist/src/query.d.ts +0 -5
  188. package/dist/src/query.d.ts.map +0 -1
  189. package/dist/src/query.js +0 -8
  190. package/dist/src/query.js.map +0 -1
  191. package/dist/src/queue.d.ts +0 -37
  192. package/dist/src/queue.d.ts.map +0 -1
  193. package/dist/src/queue.js +0 -8
  194. package/dist/src/queue.js.map +0 -1
  195. package/src/query.ts +0 -8
  196. package/src/queue.ts +0 -51
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- // @generated by protoc-gen-es v2.9.0 with parameter "target=ts,import_extension=js"
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { schema } from './proto/index.js';
7
+ import { schema } from './proto/index.ts';
8
8
 
9
9
  describe('Codec', () => {
10
10
  test('encodes and decodes messages', async () => {
@@ -4,7 +4,9 @@
4
4
 
5
5
  import { type SpaceId } from '@dxos/keys';
6
6
 
7
- import { type QueryResult, type QueueQuery } from '../queue';
7
+ import type * as FeedProtocol from '../FeedProtocol';
8
+ import { type CreateDocumentRequest, type CreateDocumentResponse } from '../proto/gen/dxos/echo/service';
9
+ import { type QueryRequest, type QueryResponse } from '../proto/gen/dxos/echo/query';
8
10
 
9
11
  /*
10
12
 
@@ -59,6 +61,7 @@ On Error returns `EdgeEnvelope` with error:
59
61
  export interface Env {
60
62
  QUEUE_SERVICE: QueueService;
61
63
  DATA_SERVICE: DataService;
64
+ FUNCTIONS_AI_SERVICE: FunctionsAiService;
62
65
  }
63
66
 
64
67
  /**
@@ -66,26 +69,45 @@ export interface Env {
66
69
  *
67
70
  * NOTE: Currently unused in functions.
68
71
  */
69
- export interface ExecutionContext {}
72
+ export interface TraceContext {}
70
73
 
71
74
  /**
72
75
  * Database API for other CF services like functions.
73
76
  */
74
77
  export interface DataService {
75
- getSpaceMeta(ctx: ExecutionContext, spaceId: SpaceId): Promise<SpaceMeta | undefined>;
76
- getDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string): Promise<RawDocument | undefined>;
78
+ getSpaceMeta(ctx: TraceContext, spaceId: SpaceId): Promise<RpcResult<SpaceMeta | undefined>>;
79
+ getDocument(ctx: TraceContext, spaceId: SpaceId, documentId: string): Promise<RpcResult<RawDocument | undefined>>;
77
80
 
78
- query(ctx: ExecutionContext, request: QueryRequest): Promise<QueryResponse>;
79
- queryDocuments(ctx: ExecutionContext, request: QueryRequest): Promise<QueryDocumentsResponse>;
80
- queryReferences(ctx: ExecutionContext, request: QueryReferencesRequest): Promise<QueryReferencesResponse>;
81
+ execQuery(ctx: TraceContext, request: QueryRequest): Promise<RpcResult<QueryResponse>>;
82
+ createDocument(ctx: TraceContext, request: CreateDocumentRequest): Promise<RpcResult<CreateDocumentResponse>>;
81
83
 
82
84
  // TODO(burdon): Update? Return DocumentEntry?
83
- changeDocument(ctx: ExecutionContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
85
+ changeDocument(ctx: TraceContext, spaceId: SpaceId, documentId: string, changes: Uint8Array): Promise<void>;
84
86
  }
85
87
 
86
88
  export interface QueueService {
87
- query(ctx: ExecutionContext, queueDXN: string, query: Omit<QueueQuery, 'queueId'>): Promise<QueryResult>;
88
- append(ctx: ExecutionContext, queueDXN: string, objects: unknown[]): Promise<void>;
89
+ queryQueue: (
90
+ ctx: TraceContext,
91
+ request: FeedProtocol.QueryQueueRequest,
92
+ ) => Promise<RpcResult<FeedProtocol.QueryResult>>;
93
+ insertIntoQueue: (
94
+ ctx: TraceContext,
95
+ request: FeedProtocol.InsertIntoQueueRequest,
96
+ ) => Promise<RpcResult<RpcDisposable>>;
97
+ deleteFromQueue: (
98
+ ctx: TraceContext,
99
+ request: FeedProtocol.DeleteFromQueueRequest,
100
+ ) => Promise<RpcResult<RpcDisposable>>;
101
+ }
102
+
103
+ /**
104
+ * FunctionsAiService API for other CF services like functions.
105
+ */
106
+ export interface FunctionsAiService {
107
+ /**
108
+ * Enables proxying HTTP requests to the AI service from other workers.
109
+ */
110
+ fetch(request: Request): Promise<RpcResult<Response>>;
89
111
  }
90
112
 
91
113
  export type ObjectDocumentJson = {
@@ -101,20 +123,6 @@ export type SpaceMeta = {
101
123
  rootDocumentId: string;
102
124
  };
103
125
 
104
- export type QueryRequest = {
105
- spaceId: string;
106
- type?: string;
107
- where?: Record<string, any>;
108
- objectIds?: string[];
109
- cursor?: string;
110
- limit?: number;
111
- };
112
-
113
- export type QueryResponse = {
114
- results: ObjectSnapshot[];
115
- cursor?: string;
116
- };
117
-
118
126
  /**
119
127
  * TODO(yaroslav): make Indexer return EchoObject after create() can properly reconstruct an object
120
128
  * from this structure (meta, id and type aren't handled properly)
@@ -159,7 +167,21 @@ export type QueryReferencesResponse = {
159
167
  references: ObjectReference[];
160
168
  };
161
169
 
162
- export type CreateDocumentResponse = {
163
- /** Automerge document ID. */
164
- documentId: string;
165
- };
170
+ /**
171
+ * Cloudflare Workers RPC returns objects/arrays/stubs that may need to be explicitly disposed.
172
+ *
173
+ * See: https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
174
+ */
175
+ export interface RpcDisposable {
176
+ /**
177
+ * Disposes the RPC stub / returned value and releases any server-side resources it references.
178
+ */
179
+ [Symbol.dispose](): void;
180
+ }
181
+
182
+ /**
183
+ * Wraps a return type so that any non-primitive value is marked as disposable.
184
+ *
185
+ * This models Workers RPC behavior where any returned object (including arrays) gets a disposer added.
186
+ */
187
+ export type RpcResult<T> = T extends object ? T & RpcDisposable : T;
package/src/edge/edge.ts CHANGED
@@ -12,7 +12,16 @@ import { SpaceId } from '@dxos/keys';
12
12
  // If we would rename it, we need to be careful to not break composer production.
13
13
  export enum EdgeService {
14
14
  AUTOMERGE_REPLICATOR = 'automerge-replicator',
15
+ /**
16
+ * Control feed replicator (hypercore append only logs) for the space.
17
+ */
18
+ // TODO(mykola): Remove once we migrate to keyhive for access control.
15
19
  FEED_REPLICATOR = 'feed-replicator',
20
+ /**
21
+ * Feed replicator (ordered data list) for the space.
22
+ */
23
+ // TODO(mykola): Rename to FEED_REPLICATOR when we migrate to keyhive for access control.
24
+ QUEUE_REPLICATOR = 'queue-replicator',
16
25
  SWARM = 'swarm',
17
26
  SIGNAL = 'signal',
18
27
  STATUS = 'status',
@@ -23,13 +32,15 @@ export type EdgeSuccess<T> = {
23
32
  data: T;
24
33
  };
25
34
 
26
- export type SerializedError = {
27
- code?: string;
28
- message?: string;
29
- context?: Record<string, unknown>;
30
- stack?: string;
31
- cause?: SerializedError;
32
- };
35
+ const _SerializedError = Schema.Struct({
36
+ name: Schema.optional(Schema.String),
37
+ message: Schema.optional(Schema.String),
38
+ context: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
39
+ stack: Schema.optional(Schema.String),
40
+ cause: Schema.optional(Schema.suspend(() => SerializedError)),
41
+ });
42
+ export interface SerializedError extends Schema.Schema.Type<typeof _SerializedError> {}
43
+ export const SerializedError: Schema.Schema<SerializedError, SerializedError, never> = _SerializedError;
33
44
 
34
45
  export type EdgeErrorData = { type: string } & Record<string, any>;
35
46
 
@@ -37,11 +48,6 @@ export type EdgeErrorData = { type: string } & Record<string, any>;
37
48
  * This is the shape of the error response from the Edge service,
38
49
  * when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
39
50
  */
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
51
  export type EdgeFailure = {
46
52
  /**
47
53
  * Branded Type.
@@ -243,20 +249,19 @@ export type UploadFunctionRequest = {
243
249
  * Runtime cannot be changed once the function was deployed.
244
250
  * @default Runtime.WORKERS_FOR_PLATFORMS
245
251
  */
246
- runtime?: Runtime;
252
+ runtime?: FunctionRuntimeKind;
247
253
  };
248
254
 
249
255
  /**
250
256
  * Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
251
257
  */
252
- export enum Runtime {
258
+ export const FunctionRuntimeKind = Schema.Enums({
253
259
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
254
- WORKERS_FOR_PLATFORMS = 'WORKERS_FOR_PLATFORMS',
260
+ WORKERS_FOR_PLATFORMS: 'WORKERS_FOR_PLATFORMS',
255
261
  // https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
256
- WORKER_LOADER = 'WORKER_LOADER',
257
- // Local worker dispatcher for testing.
258
- TEST = 'TEST',
259
- }
262
+ WORKER_LOADER: 'WORKER_LOADER',
263
+ });
264
+ export type FunctionRuntimeKind = Schema.Schema.Type<typeof FunctionRuntimeKind>;
260
265
 
261
266
  export type UploadFunctionResponseBody = {
262
267
  functionId: string;
@@ -419,15 +424,15 @@ const MAX_ERROR_DEPTH = 3;
419
424
  */
420
425
  export const ErrorCodec = Object.freeze({
421
426
  encode: (err: Error, depth: number = 0): SerializedError => ({
422
- code: 'code' in err ? (err as any).code : undefined,
427
+ name: 'name' in err ? err.name : (err as any).code || 'Error',
423
428
  message: err.message,
424
429
  stack: err.stack,
425
430
  cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
426
431
  }),
427
432
  decode: (serializedError: SerializedError, depth: number = 0): Error => {
428
433
  let err: Error;
429
- if (typeof serializedError.code === 'string') {
430
- err = new BaseError(serializedError.code, {
434
+ if (typeof serializedError.name === 'string') {
435
+ err = new BaseError(serializedError.name, {
431
436
  message: serializedError.message ?? 'Unknown error',
432
437
  cause:
433
438
  serializedError.cause && depth < MAX_ERROR_DEPTH
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type EdgeErrorData, type EdgeFailure, EdgeHttpErrorCodec, ErrorCodec } from './edge.js';
5
+ import { type EdgeErrorData, type EdgeFailure, EdgeHttpErrorCodec, ErrorCodec } from './edge.ts';
6
6
 
7
7
  // TODO(burdon): Reconcile with @dxos/errors.
8
8
  /**
package/src/edge/index.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './edge.js';
6
- export * as EdgeFunctionEnv from './EdgeFunctionEnv.js';
7
- export * from './errors.js';
5
+ export * from './edge.ts';
6
+ export * as EdgeFunctionEnv from './EdgeFunctionEnv.ts';
7
+ export * from './errors.ts';
@@ -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('API') {}
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('SYSTEM') {}
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('DATABASE') {}
26
+ export class DatabaseError extends BaseError.extend('DatabaseError') {}
@@ -2,9 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
5
+ import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.ts';
6
6
 
7
- import { reconstructError } from './helpers.js';
7
+ import { reconstructError } from './helpers.ts';
8
8
 
9
9
  export const encodeError = (err: any): SerializedErrorProto => {
10
10
  if (typeof err === 'object' && err?.message) {
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { ApiError } from './base-errors.js';
7
+ import { ApiError } from './base-errors.ts';
8
8
 
9
9
  describe('Errors', () => {
10
10
  test('test', async () => {
@@ -5,98 +5,98 @@
5
5
  import { BaseError } from '@dxos/errors';
6
6
  import { PublicKey } from '@dxos/keys';
7
7
 
8
- import type { ObjectId } from '../types.js';
8
+ import type { ObjectId } from '../types.ts';
9
9
 
10
- import { registerError, registerErrorMessageContext, registerErrorNoArgs } from './helpers.js';
10
+ import { registerError, registerErrorMessageContext, registerErrorNoArgs } from './helpers.ts';
11
11
 
12
12
  /**
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
- 'RPC_CLOSED',
16
+ 'RpcClosedError',
17
17
  'Request was terminated because the RPC endpoint is closed.',
18
18
  ) {}
19
19
 
20
- registerErrorNoArgs('RPC_CLOSED', RpcClosedError);
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('RPC_NOT_OPEN', 'RPC has not been opened.') {}
25
+ export class RpcNotOpenError extends BaseError.extend('RpcNotOpenError', 'RPC has not been opened.') {}
26
26
 
27
- registerErrorNoArgs('RPC_NOT_OPEN', RpcNotOpenError);
27
+ registerErrorNoArgs('RpcNotOpenError', RpcNotOpenError);
28
28
 
29
- export class CancelledError extends BaseError.extend('CANCELLED') {}
29
+ export class CancelledError extends BaseError.extend('CancelledError') {}
30
30
 
31
- registerErrorMessageContext('CANCELLED', CancelledError);
31
+ registerErrorMessageContext('CancelledError', CancelledError);
32
32
 
33
- export class InvalidConfigError extends BaseError.extend('INVALID_CONFIG') {}
33
+ export class InvalidConfigError extends BaseError.extend('InvalidConfigError') {}
34
34
 
35
- registerErrorMessageContext('INVALID_CONFIG', InvalidConfigError);
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('REMOTE_SERVICE_CONNECTION_ERROR') {}
40
+ export class RemoteServiceConnectionError extends BaseError.extend('RemoteServiceConnectionError') {}
41
41
 
42
- registerErrorMessageContext('REMOTE_SERVICE_CONNECTION_ERROR', RemoteServiceConnectionError);
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('REMOTE_SERVICE_CONNECTION_TIMEOUT') {}
47
+ export class RemoteServiceConnectionTimeout extends BaseError.extend('RemoteServiceConnectionTimeout') {}
48
48
 
49
- registerErrorMessageContext('REMOTE_SERVICE_CONNECTION_TIMEOUT', RemoteServiceConnectionTimeout);
49
+ registerErrorMessageContext('RemoteServiceConnectionTimeout', RemoteServiceConnectionTimeout);
50
50
 
51
- export class DataCorruptionError extends BaseError.extend('DATA_CORRUPTION') {}
51
+ export class DataCorruptionError extends BaseError.extend('DataCorruptionError') {}
52
52
 
53
- registerErrorMessageContext('DATA_CORRUPTION', DataCorruptionError);
53
+ registerErrorMessageContext('DataCorruptionError', DataCorruptionError);
54
54
 
55
- export class InvalidInvitationExtensionRoleError extends BaseError.extend('INVALID_INVITATION_EXTENSION_ROLE') {}
55
+ export class InvalidInvitationExtensionRoleError extends BaseError.extend('InvalidInvitationExtensionRoleError') {}
56
56
 
57
- registerErrorMessageContext('INVALID_INVITATION_EXTENSION_ROLE', InvalidInvitationExtensionRoleError);
57
+ registerErrorMessageContext('InvalidInvitationExtensionRoleError', InvalidInvitationExtensionRoleError);
58
58
 
59
- export class IdentityNotInitializedError extends BaseError.extend('IDENTITY_NOT_INITIALIZED') {}
59
+ export class IdentityNotInitializedError extends BaseError.extend('IdentityNotInitializedError') {}
60
60
 
61
- registerErrorMessageContext('IDENTITY_NOT_INITIALIZED', IdentityNotInitializedError);
61
+ registerErrorMessageContext('IdentityNotInitializedError', IdentityNotInitializedError);
62
62
 
63
- export class InvalidInvitationError extends BaseError.extend('INVALID_INVITATION') {}
63
+ export class InvalidInvitationError extends BaseError.extend('InvalidInvitationError') {}
64
64
 
65
- registerErrorMessageContext('INVALID_INVITATION', InvalidInvitationError);
65
+ registerErrorMessageContext('InvalidInvitationError', InvalidInvitationError);
66
66
 
67
- export class AlreadyJoinedError extends BaseError.extend('ALREADY_JOINED') {}
67
+ export class AlreadyJoinedError extends BaseError.extend('AlreadyJoinedError') {}
68
68
 
69
- registerErrorMessageContext('ALREADY_JOINED', AlreadyJoinedError);
69
+ registerErrorMessageContext('AlreadyJoinedError', AlreadyJoinedError);
70
70
 
71
- export class ConnectionResetError extends BaseError.extend('CONNECTION_RESET') {}
71
+ export class ConnectionResetError extends BaseError.extend('ConnectionResetError') {}
72
72
 
73
- registerErrorMessageContext('CONNECTION_RESET', ConnectionResetError);
73
+ registerErrorMessageContext('ConnectionResetError', ConnectionResetError);
74
74
 
75
- export class TimeoutError extends BaseError.extend('TIMEOUT') {}
75
+ export class TimeoutError extends BaseError.extend('TimeoutError') {}
76
76
 
77
- registerErrorMessageContext('TIMEOUT', TimeoutError);
77
+ registerErrorMessageContext('TimeoutError', TimeoutError);
78
78
 
79
79
  // General protocol error.
80
- export class ProtocolError extends BaseError.extend('PROTOCOL_ERROR') {}
80
+ export class ProtocolError extends BaseError.extend('ProtocolError') {}
81
81
 
82
- registerErrorMessageContext(ProtocolError.code, ProtocolError);
82
+ registerErrorMessageContext(ProtocolError.name, ProtocolError);
83
83
 
84
84
  // General connectivity errors.
85
- export class ConnectivityError extends BaseError.extend('CONNECTIVITY_ERROR') {}
85
+ export class ConnectivityError extends BaseError.extend('ConnectivityError') {}
86
86
 
87
- registerErrorMessageContext('CONNECTIVITY_ERROR', ConnectivityError);
87
+ registerErrorMessageContext('ConnectivityError', ConnectivityError);
88
88
 
89
- export class RateLimitExceededError extends BaseError.extend('RATE_LIMIT_EXCEEDED') {}
89
+ export class RateLimitExceededError extends BaseError.extend('RateLimitExceededError') {}
90
90
 
91
- registerErrorMessageContext('RATE_LIMIT_EXCEEDED', RateLimitExceededError);
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('UNKNOWN_PROTOCOL_ERROR') {}
94
+ export class UnknownProtocolError extends BaseError.extend('UnknownProtocolError') {}
95
95
 
96
- registerError(UnknownProtocolError.code, (message, context) => new UnknownProtocolError({ message, context }));
96
+ registerError(UnknownProtocolError.name, (message, context) => new UnknownProtocolError({ message, context }));
97
97
 
98
98
  export class InvalidStorageVersionError extends BaseError.extend(
99
- 'INVALID_STORAGE_VERSION',
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('INVALID_STORAGE_VERSION', (_, context) => {
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('SPACE_NOT_FOUND', 'Space not found.') {
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('SPACE_NOT_FOUND', (_, context) => {
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('ITEM_NOT_FOUND', 'Item not found.') {
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('ITEM_NOT_FOUND', (_, context) => {
127
+ registerError('EntityNotFoundError', (_, context) => {
128
128
  return new EntityNotFoundError(context.entityId);
129
129
  });
130
130
 
131
- export class UnknownModelError extends BaseError.extend('UNKNOWN_MODEL', 'Unknown model.') {
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('UNKNOWN_MODEL', (_, context) => {
137
+ registerError('UnknownModelError', (_, context) => {
138
138
  return new UnknownModelError(context.model);
139
139
  });
140
140
 
141
- export class AuthorizationError extends BaseError.extend('AUTHORIZATION_ERROR') {}
141
+ export class AuthorizationError extends BaseError.extend('AuthorizationError') {}
142
142
 
143
- registerErrorMessageContext('AUTHORIZATION_ERROR', AuthorizationError);
143
+ registerErrorMessageContext('AuthorizationError', AuthorizationError);
@@ -5,7 +5,7 @@
5
5
  import { BaseError } from '@dxos/errors';
6
6
  import { invariant } from '@dxos/invariant';
7
7
 
8
- import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
8
+ import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.ts';
9
9
 
10
10
  export const reconstructError = (error: SerializedErrorProto) => {
11
11
  const { name, message, context } = error;
@@ -2,8 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- export * from './encoding.js';
6
- export * from './errors.js';
7
- export * from './helpers.js';
8
- export * from './base-errors.js';
9
- export * from './parameter.js';
5
+ export * from './encoding.ts';
6
+ export * from './errors.ts';
7
+ export * from './helpers.ts';
8
+ export * from './base-errors.ts';
9
+ export * from './parameter.ts';
package/src/index.ts CHANGED
@@ -2,18 +2,15 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- // TODO(burdon): Why export .js?
6
-
7
- export * from './automerge.js';
8
- export * from './edge/index.js';
9
- export * from './errors/index.js';
10
- export * from './indexing.js';
11
- export * from './messenger.js';
12
- export * from './profile-archive.js';
13
- export * from './query.js';
14
- export * from './queue.js';
15
- export * from './space-archive.js';
16
- export * from './storage.js';
17
- export * from './tracing.js';
18
- export type * from './types.js';
19
- export * as FunctionProtocol from './FunctionProtocol.js';
5
+ export * from './automerge.ts';
6
+ export * from './edge/index.ts';
7
+ export * from './errors/index.ts';
8
+ export * from './indexing.ts';
9
+ export * from './messenger.ts';
10
+ export * from './profile-archive.ts';
11
+ export * from './space-archive.ts';
12
+ export * from './storage.ts';
13
+ export * from './tracing.ts';
14
+ export type * from './types.ts';
15
+ export * as FunctionProtocol from './FunctionProtocol.ts';
16
+ export * as FeedProtocol from './FeedProtocol.ts';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { ObjectPointerVersion, objectPointerCodec } from './indexing.js';
7
+ import { ObjectPointerVersion, objectPointerCodec } from './indexing.ts';
8
8
 
9
9
  describe('Indexing object pointer codec', () => {
10
10
  test('getVersion', async () => {
@@ -0,0 +1,78 @@
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
+ message SyncQueueRequest {
64
+ string subspace_tag = 1;
65
+ string space_id = 2;
66
+ string queue_id = 3;
67
+ /// Whether to push local changes to the server. Defaults to true.
68
+ optional bool should_push = 4;
69
+ /// Whether to pull remote changes from the server. Defaults to true.
70
+ optional bool should_pull = 5;
71
+ }
72
+
73
+ service QueueService {
74
+ rpc QueryQueue(QueryQueueRequest) returns (QueueQueryResult);
75
+ rpc InsertIntoQueue(InsertIntoQueueRequest) returns (google.protobuf.Empty);
76
+ rpc DeleteFromQueue(DeleteFromQueueRequest) returns (google.protobuf.Empty);
77
+ rpc SyncQueue(SyncQueueRequest) returns (google.protobuf.Empty);
78
+ }
@@ -72,6 +72,7 @@ message Platform {
72
72
  BROWSER = 0;
73
73
  SHARED_WORKER = 1;
74
74
  NODE = 2;
75
+ DEDICATED_WORKER = 3;
75
76
  }
76
77
 
77
78
  PLATFORM_TYPE type = 1;
@@ -59,7 +59,7 @@ message Module {
59
59
  optional string id = 8; // TODO(burdon): Ensured FQ (e.g., 'dxos.app.xxx')
60
60
  optional string name = 1; // TODO(burdon): Replace with id (or key?)
61
61
  optional string type = 2; // TODO(burdon): Define namespace (e.g.,
62
- // 'dxos.org/type/frame' vs. 'dxos.type.frame')
62
+ // 'org.dxos.type.frame')
63
63
 
64
64
  // TODO(burdon): Developer info message.
65
65