@dxos/protocols 0.8.4-main.b97322e → 0.8.4-main.f5c0578

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/protocols",
3
- "version": "0.8.4-main.b97322e",
3
+ "version": "0.8.4-main.f5c0578",
4
4
  "description": "Protobuf definitions for DXOS protocols.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -60,18 +60,18 @@
60
60
  ],
61
61
  "dependencies": {
62
62
  "@bufbuild/protobuf": "^2.1.0",
63
- "@dxos/codec-protobuf": "0.8.4-main.b97322e",
64
- "@dxos/invariant": "0.8.4-main.b97322e",
65
- "@dxos/keys": "0.8.4-main.b97322e",
66
- "@dxos/timeframe": "0.8.4-main.b97322e",
67
- "@dxos/util": "0.8.4-main.b97322e",
68
- "@dxos/effect": "0.8.4-main.b97322e"
63
+ "@dxos/codec-protobuf": "0.8.4-main.f5c0578",
64
+ "@dxos/effect": "0.8.4-main.f5c0578",
65
+ "@dxos/invariant": "0.8.4-main.f5c0578",
66
+ "@dxos/timeframe": "0.8.4-main.f5c0578",
67
+ "@dxos/util": "0.8.4-main.f5c0578",
68
+ "@dxos/keys": "0.8.4-main.f5c0578"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@bufbuild/buf": "^1.43.0",
72
72
  "@bufbuild/protoc-gen-es": "^2.1.0",
73
- "effect": "3.17.0",
74
- "@dxos/protobuf-compiler": "0.8.4-main.b97322e"
73
+ "effect": "3.17.7",
74
+ "@dxos/protobuf-compiler": "0.8.4-main.f5c0578"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "effect": "^3.13.3"
package/src/edge.ts CHANGED
@@ -6,12 +6,14 @@ import { Schema } from 'effect';
6
6
 
7
7
  import { SpaceId } from '@dxos/keys';
8
8
 
9
- // TODO(burdon): Rename EdgerRouterEndpoint?
9
+ // TODO(burdon): Rename EdgerRouterEndpoint.
10
+ // If we would rename it, we need to be careful to not break composer production.
10
11
  export enum EdgeService {
11
12
  AUTOMERGE_REPLICATOR = 'automerge-replicator',
12
13
  FEED_REPLICATOR = 'feed-replicator',
13
14
  SWARM = 'swarm',
14
15
  SIGNAL = 'signal',
16
+ STATUS = 'status',
15
17
  }
16
18
 
17
19
  export type EdgeHttpSuccess<T> = {
@@ -138,12 +140,18 @@ export type UploadFunctionResponseBody = {
138
140
  };
139
141
 
140
142
  export type CreateSpaceRequest = {
143
+ /**
144
+ * HEX encoded public key of the agent.
145
+ */
141
146
  agentKey: string;
142
147
  };
143
148
 
144
149
  export type CreateSpaceResponseBody = {
150
+ /**
151
+ * HEX encoded public key of the space.
152
+ */
145
153
  spaceKey: string;
146
- spaceId: string; // TODO(burdon): Use SpaceId.
154
+ spaceId: SpaceId;
147
155
  automergeRoot: string;
148
156
  };
149
157
 
@@ -220,3 +228,49 @@ export type EdgeStatus = {
220
228
  fetchError?: string;
221
229
  };
222
230
  };
231
+
232
+ //
233
+ // Space import/export.
234
+ //
235
+
236
+ export type ImportBundleRequest = {
237
+ bundle: {
238
+ /**
239
+ * DocumentId.
240
+ */
241
+ documentId: string;
242
+ /**
243
+ * Encoded mutation.
244
+ */
245
+ mutation: string;
246
+ /**
247
+ * Heads of the document.
248
+ */
249
+ heads: string[];
250
+ }[];
251
+ };
252
+
253
+ export type ExportBundleRequest = {
254
+ /**
255
+ * DocumentId -> Heads (decoded heads since which we want to export).
256
+ */
257
+ docHeads: Record<string, string[]>;
258
+ };
259
+
260
+ export type ExportBundleResponse = {
261
+ bundle: {
262
+ /**
263
+ * DocumentId.
264
+ */
265
+ documentId: string;
266
+ /**
267
+ * Encoded mutation.
268
+ */
269
+ mutation: string;
270
+ }[];
271
+ };
272
+
273
+ export const DocumentCodec = {
274
+ encode: (doc: Uint8Array) => Buffer.from(doc).toString('base64'),
275
+ decode: (doc: string) => new Uint8Array(Buffer.from(doc, 'base64')),
276
+ };
@@ -2,9 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { reconstructError } from './helpers.js';
6
5
  import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
7
6
 
7
+ import { reconstructError } from './helpers.js';
8
+
8
9
  export const encodeError = (err: any): SerializedErrorProto => {
9
10
  if (typeof err === 'object' && err?.message) {
10
11
  return {
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { PublicKey } from '@dxos/keys';
6
6
 
7
+ import type { ObjectId } from '../types.js';
8
+
7
9
  import { ApiError, BaseError, DatabaseError, SystemError } from './base-errors.js';
8
10
  import { registerError, registerErrorMessageContext, registerErrorNoArgs } from './helpers.js';
9
- import type { ObjectId } from '../types.js';
10
11
 
11
12
  /**
12
13
  * Thrown when request was terminated because the RPC endpoint has been closed.
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { invariant } from '@dxos/invariant';
6
6
 
7
- import { SystemError } from './base-errors.js';
8
7
  import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
9
8
 
9
+ import { SystemError } from './base-errors.js';
10
+
10
11
  export const reconstructError = (error: SerializedErrorProto) => {
11
12
  const { name, message, context } = error;
12
13
  return errorFromCode(name, message, context);
@@ -65,37 +65,6 @@ import * as dxos_value from "../value.js";
65
65
  import * as example_testing_data from "../../example/testing/data.js";
66
66
  import * as example_testing_rpc from "../../example/testing/rpc.js";
67
67
  import * as google_protobuf from "../../google/protobuf.js";
68
- /**
69
- * Defined in:
70
- * {@link file://./../../../dxos/devtools/diagnostics.proto}
71
- */
72
- export interface Services {
73
- spaces?: SpaceStats[];
74
- }
75
- /**
76
- * Defined in:
77
- * {@link file://./../../../dxos/devtools/diagnostics.proto}
78
- */
79
- export interface SpaceStats {
80
- key: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
81
- peers?: PeerStats[];
82
- }
83
- /**
84
- * Defined in:
85
- * {@link file://./../../../dxos/devtools/diagnostics.proto}
86
- */
87
- export interface PeerStats {
88
- controlFeed: FeedStats;
89
- dataFeed: FeedStats;
90
- }
91
- /**
92
- * Defined in:
93
- * {@link file://./../../../dxos/devtools/diagnostics.proto}
94
- */
95
- export interface FeedStats {
96
- key: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
97
- length: number;
98
- }
99
68
  /**
100
69
  * Defined in:
101
70
  * {@link file://./../../../dxos/devtools/host.proto}
@@ -531,3 +500,34 @@ export interface SubscribeToSwarmInfoRequest {
531
500
  export interface SubscribeToSwarmInfoResponse {
532
501
  data?: dxos_devtools_swarm.SwarmInfo[];
533
502
  }
503
+ /**
504
+ * Defined in:
505
+ * {@link file://./../../../dxos/devtools/diagnostics.proto}
506
+ */
507
+ export interface Services {
508
+ spaces?: SpaceStats[];
509
+ }
510
+ /**
511
+ * Defined in:
512
+ * {@link file://./../../../dxos/devtools/diagnostics.proto}
513
+ */
514
+ export interface SpaceStats {
515
+ key: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
516
+ peers?: PeerStats[];
517
+ }
518
+ /**
519
+ * Defined in:
520
+ * {@link file://./../../../dxos/devtools/diagnostics.proto}
521
+ */
522
+ export interface PeerStats {
523
+ controlFeed: FeedStats;
524
+ dataFeed: FeedStats;
525
+ }
526
+ /**
527
+ * Defined in:
528
+ * {@link file://./../../../dxos/devtools/diagnostics.proto}
529
+ */
530
+ export interface FeedStats {
531
+ key: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
532
+ length: number;
533
+ }