@dxos/protocols 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

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 (192) hide show
  1. package/dist/src/FunctionProtocol.d.ts +82 -0
  2. package/dist/src/FunctionProtocol.d.ts.map +1 -0
  3. package/dist/src/FunctionProtocol.js +4 -0
  4. package/dist/src/FunctionProtocol.js.map +1 -0
  5. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts +189 -0
  6. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts.map +1 -0
  7. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js +39 -0
  8. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js.map +1 -0
  9. package/dist/src/buf/proto/gen/dxos/config_pb.d.ts +4 -0
  10. package/dist/src/buf/proto/gen/dxos/config_pb.d.ts.map +1 -1
  11. package/dist/src/buf/proto/gen/dxos/config_pb.js +1 -1
  12. package/dist/src/buf/proto/gen/dxos/config_pb.js.map +1 -1
  13. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts +12 -2
  14. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts.map +1 -1
  15. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js +1 -1
  16. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js.map +1 -1
  17. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts +55 -9
  18. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts.map +1 -1
  19. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js +15 -5
  20. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js.map +1 -1
  21. package/dist/src/buf/proto/gen/dxos/google_pb.js +1 -1
  22. package/dist/src/buf/proto/gen/dxos/google_pb.js.map +1 -1
  23. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts +1 -0
  24. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts.map +1 -1
  25. package/dist/src/buf/proto/gen/dxos/iframe_pb.js.map +1 -1
  26. package/dist/src/buf/proto/gen/dxos/tracing_pb.js +1 -1
  27. package/dist/src/buf/proto/gen/dxos/tracing_pb.js.map +1 -1
  28. package/dist/src/edge/EdgeFunctionEnv.d.ts +120 -0
  29. package/dist/src/edge/EdgeFunctionEnv.d.ts.map +1 -0
  30. package/dist/src/edge/EdgeFunctionEnv.js +4 -0
  31. package/dist/src/edge/EdgeFunctionEnv.js.map +1 -0
  32. package/dist/src/{edge.d.ts → edge/edge.d.ts} +47 -20
  33. package/dist/src/edge/edge.d.ts.map +1 -0
  34. package/dist/src/{edge.js → edge/edge.js} +24 -7
  35. package/dist/src/edge/edge.js.map +1 -0
  36. package/dist/src/{edge-error.d.ts → edge/errors.d.ts} +5 -6
  37. package/dist/src/edge/errors.d.ts.map +1 -0
  38. package/dist/src/{edge-error.js → edge/errors.js} +13 -14
  39. package/dist/src/edge/errors.js.map +1 -0
  40. package/dist/src/edge/index.d.ts +4 -0
  41. package/dist/src/edge/index.d.ts.map +1 -0
  42. package/dist/src/edge/index.js +7 -0
  43. package/dist/src/edge/index.js.map +1 -0
  44. package/dist/src/errors/base-errors.d.ts +86 -8
  45. package/dist/src/errors/base-errors.d.ts.map +1 -1
  46. package/dist/src/errors/base-errors.js +4 -20
  47. package/dist/src/errors/base-errors.js.map +1 -1
  48. package/dist/src/errors/encoding.d.ts +1 -1
  49. package/dist/src/errors/encoding.d.ts.map +1 -1
  50. package/dist/src/errors/errors.d.ts +618 -41
  51. package/dist/src/errors/errors.d.ts.map +1 -1
  52. package/dist/src/errors/errors.js +49 -103
  53. package/dist/src/errors/errors.js.map +1 -1
  54. package/dist/src/errors/errors.test.js +1 -1
  55. package/dist/src/errors/errors.test.js.map +1 -1
  56. package/dist/src/errors/helpers.d.ts +8 -4
  57. package/dist/src/errors/helpers.d.ts.map +1 -1
  58. package/dist/src/errors/helpers.js +3 -3
  59. package/dist/src/errors/helpers.js.map +1 -1
  60. package/dist/src/feed-replication.d.ts.map +1 -1
  61. package/dist/src/index.d.ts +3 -3
  62. package/dist/src/index.d.ts.map +1 -1
  63. package/dist/src/index.js +4 -3
  64. package/dist/src/index.js.map +1 -1
  65. package/dist/src/messenger.d.ts +16 -0
  66. package/dist/src/messenger.d.ts.map +1 -0
  67. package/dist/src/messenger.js +4 -0
  68. package/dist/src/messenger.js.map +1 -0
  69. package/dist/src/proto/gen/dxos/client/services.d.ts +103 -0
  70. package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
  71. package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
  72. package/dist/src/proto/gen/dxos/config.d.ts +5 -0
  73. package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
  74. package/dist/src/proto/gen/dxos/config.js.map +1 -1
  75. package/dist/src/proto/gen/dxos/echo/query.d.ts +17 -1
  76. package/dist/src/proto/gen/dxos/echo/query.d.ts.map +1 -1
  77. package/dist/src/proto/gen/dxos/echo/query.js.map +1 -1
  78. package/dist/src/proto/gen/dxos/echo/service.d.ts +34 -8
  79. package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
  80. package/dist/src/proto/gen/index.d.ts +8 -0
  81. package/dist/src/proto/gen/index.d.ts.map +1 -1
  82. package/dist/src/proto/gen/index.js +1 -1
  83. package/dist/src/proto/gen/index.js.map +1 -1
  84. package/dist/src/queue.d.ts +1 -26
  85. package/dist/src/queue.d.ts.map +1 -1
  86. package/dist/src/queue.js +1 -4
  87. package/dist/src/queue.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +19 -15
  90. package/src/FunctionProtocol.ts +104 -0
  91. package/src/buf/proto/gen/dxos/agent/dashboard_pb.ts +1 -1
  92. package/src/buf/proto/gen/dxos/agent/echo-proxy_pb.ts +1 -1
  93. package/src/buf/proto/gen/dxos/agent/epoch_pb.ts +1 -1
  94. package/src/buf/proto/gen/dxos/agent/functions_pb.ts +1 -1
  95. package/src/buf/proto/gen/dxos/bot_pb.ts +1 -1
  96. package/src/buf/proto/gen/dxos/client/invitation_pb.ts +1 -1
  97. package/src/buf/proto/gen/dxos/client/logging_pb.ts +1 -1
  98. package/src/buf/proto/gen/dxos/client/queue_pb.ts +231 -0
  99. package/src/buf/proto/gen/dxos/client/services_pb.ts +1 -1
  100. package/src/buf/proto/gen/dxos/config_pb.ts +7 -2
  101. package/src/buf/proto/gen/dxos/devtools/diagnostics_pb.ts +1 -1
  102. package/src/buf/proto/gen/dxos/devtools/host_pb.ts +1 -1
  103. package/src/buf/proto/gen/dxos/devtools/swarm_pb.ts +1 -1
  104. package/src/buf/proto/gen/dxos/echo/blob_pb.ts +1 -1
  105. package/src/buf/proto/gen/dxos/echo/feed_pb.ts +1 -1
  106. package/src/buf/proto/gen/dxos/echo/filter_pb.ts +1 -1
  107. package/src/buf/proto/gen/dxos/echo/indexing_pb.ts +1 -1
  108. package/src/buf/proto/gen/dxos/echo/metadata_pb.ts +1 -1
  109. package/src/buf/proto/gen/dxos/echo/model/document_pb.ts +1 -1
  110. package/src/buf/proto/gen/dxos/echo/model/messenger_pb.ts +1 -1
  111. package/src/buf/proto/gen/dxos/echo/model/text_pb.ts +1 -1
  112. package/src/buf/proto/gen/dxos/echo/object_pb.ts +1 -1
  113. package/src/buf/proto/gen/dxos/echo/query_pb.ts +16 -4
  114. package/src/buf/proto/gen/dxos/echo/service_pb.ts +68 -16
  115. package/src/buf/proto/gen/dxos/echo/snapshot_pb.ts +1 -1
  116. package/src/buf/proto/gen/dxos/echo/timeframe_pb.ts +1 -1
  117. package/src/buf/proto/gen/dxos/edge/calls_pb.ts +1 -1
  118. package/src/buf/proto/gen/dxos/edge/messenger_pb.ts +1 -1
  119. package/src/buf/proto/gen/dxos/edge/signal_pb.ts +1 -1
  120. package/src/buf/proto/gen/dxos/error_pb.ts +1 -1
  121. package/src/buf/proto/gen/dxos/field_options_pb.ts +1 -1
  122. package/src/buf/proto/gen/dxos/google_pb.ts +1 -1
  123. package/src/buf/proto/gen/dxos/gravity_pb.ts +1 -1
  124. package/src/buf/proto/gen/dxos/halo/credentials/auth_pb.ts +1 -1
  125. package/src/buf/proto/gen/dxos/halo/credentials/greet_pb.ts +1 -1
  126. package/src/buf/proto/gen/dxos/halo/credentials/identity_pb.ts +1 -1
  127. package/src/buf/proto/gen/dxos/halo/credentials_pb.ts +1 -1
  128. package/src/buf/proto/gen/dxos/halo/invitations_pb.ts +1 -1
  129. package/src/buf/proto/gen/dxos/halo/keyring_pb.ts +1 -1
  130. package/src/buf/proto/gen/dxos/halo/keys_pb.ts +1 -1
  131. package/src/buf/proto/gen/dxos/halo/signed_pb.ts +1 -1
  132. package/src/buf/proto/gen/dxos/iframe_pb.ts +2 -1
  133. package/src/buf/proto/gen/dxos/keys_pb.ts +1 -1
  134. package/src/buf/proto/gen/dxos/mesh/bridge_pb.ts +1 -1
  135. package/src/buf/proto/gen/dxos/mesh/broadcast_pb.ts +1 -1
  136. package/src/buf/proto/gen/dxos/mesh/messaging_pb.ts +1 -1
  137. package/src/buf/proto/gen/dxos/mesh/muxer_pb.ts +1 -1
  138. package/src/buf/proto/gen/dxos/mesh/presence_pb.ts +1 -1
  139. package/src/buf/proto/gen/dxos/mesh/protocol_pb.ts +1 -1
  140. package/src/buf/proto/gen/dxos/mesh/replicator_pb.ts +1 -1
  141. package/src/buf/proto/gen/dxos/mesh/signal_pb.ts +1 -1
  142. package/src/buf/proto/gen/dxos/mesh/swarm_pb.ts +1 -1
  143. package/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.ts +1 -1
  144. package/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.ts +1 -1
  145. package/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.ts +1 -1
  146. package/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.ts +1 -1
  147. package/src/buf/proto/gen/dxos/mesh/teleport/control_pb.ts +1 -1
  148. package/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.ts +1 -1
  149. package/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.ts +1 -1
  150. package/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.ts +1 -1
  151. package/src/buf/proto/gen/dxos/registry_pb.ts +1 -1
  152. package/src/buf/proto/gen/dxos/rpc_pb.ts +1 -1
  153. package/src/buf/proto/gen/dxos/service/agentmanager_pb.ts +1 -1
  154. package/src/buf/proto/gen/dxos/service/publisher_pb.ts +1 -1
  155. package/src/buf/proto/gen/dxos/service/supervisor_pb.ts +1 -1
  156. package/src/buf/proto/gen/dxos/service/tunnel_pb.ts +1 -1
  157. package/src/buf/proto/gen/dxos/tracing_pb.ts +1 -1
  158. package/src/buf/proto/gen/dxos/type_pb.ts +1 -1
  159. package/src/buf/proto/gen/dxos/value_pb.ts +1 -1
  160. package/src/buf/proto/gen/example/testing/data_pb.ts +1 -1
  161. package/src/buf/proto/gen/example/testing/rpc_pb.ts +1 -1
  162. package/src/edge/EdgeFunctionEnv.ts +193 -0
  163. package/src/{edge.ts → edge/edge.ts} +57 -27
  164. package/src/{edge-error.ts → edge/errors.ts} +14 -15
  165. package/src/edge/index.ts +7 -0
  166. package/src/errors/base-errors.ts +4 -22
  167. package/src/errors/errors.test.ts +1 -1
  168. package/src/errors/errors.ts +55 -121
  169. package/src/errors/helpers.ts +5 -6
  170. package/src/feed-replication.ts +1 -0
  171. package/src/index.ts +5 -3
  172. package/src/messenger.ts +22 -0
  173. package/src/proto/dxos/client/queue.proto +67 -0
  174. package/src/proto/dxos/config.proto +2 -0
  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 +103 -0
  179. package/src/proto/gen/dxos/config.ts +5 -0
  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/index.ts +9 -1
  183. package/src/queue.ts +9 -33
  184. package/dist/src/edge-error.d.ts.map +0 -1
  185. package/dist/src/edge-error.js.map +0 -1
  186. package/dist/src/edge.d.ts.map +0 -1
  187. package/dist/src/edge.js.map +0 -1
  188. package/dist/src/query.d.ts +0 -5
  189. package/dist/src/query.d.ts.map +0 -1
  190. package/dist/src/query.js +0 -8
  191. package/dist/src/query.js.map +0 -1
  192. package/src/query.ts +0 -8
@@ -2,208 +2,142 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
+ import { BaseError } from '@dxos/errors';
5
6
  import { PublicKey } from '@dxos/keys';
6
7
 
7
8
  import type { ObjectId } from '../types.js';
8
9
 
9
- import { ApiError, BaseError, DatabaseError, SystemError } from './base-errors.js';
10
10
  import { registerError, registerErrorMessageContext, registerErrorNoArgs } from './helpers.js';
11
11
 
12
12
  /**
13
13
  * Thrown when request was terminated because the RPC endpoint has been closed.
14
14
  */
15
- export class RpcClosedError extends SystemError {
16
- constructor() {
17
- super('RPC_CLOSED', 'Request was terminated because the RPC endpoint is closed.');
18
- }
19
- }
15
+ export class RpcClosedError extends BaseError.extend(
16
+ 'RpcClosedError',
17
+ 'Request was terminated because the RPC endpoint is closed.',
18
+ ) {}
20
19
 
21
- registerErrorNoArgs('RPC_CLOSED', RpcClosedError);
20
+ registerErrorNoArgs('RpcClosedError', RpcClosedError);
22
21
 
23
22
  /**
24
23
  * Thrown when `request` is called when RPC has not been opened.
25
24
  */
26
- export class RpcNotOpenError extends SystemError {
27
- constructor() {
28
- super('RPC_NOT_OPEN', 'RPC has not been opened.');
29
- }
30
- }
25
+ export class RpcNotOpenError extends BaseError.extend('RpcNotOpenError', 'RPC has not been opened.') {}
31
26
 
32
- registerErrorNoArgs('RPC_NOT_OPEN', RpcNotOpenError);
27
+ registerErrorNoArgs('RpcNotOpenError', RpcNotOpenError);
33
28
 
34
- export class CancelledError extends SystemError {
35
- constructor(message?: string, context?: Record<string, any>) {
36
- super('CANCELLED', message, context);
37
- }
38
- }
29
+ export class CancelledError extends BaseError.extend('CancelledError') {}
39
30
 
40
- registerErrorMessageContext('CANCELLED', CancelledError);
31
+ registerErrorMessageContext('CancelledError', CancelledError);
41
32
 
42
- export class InvalidConfigError extends ApiError {
43
- constructor(message?: string, context?: Record<string, any>) {
44
- super('INVALID_CONFIG', message, context);
45
- }
46
- }
33
+ export class InvalidConfigError extends BaseError.extend('InvalidConfigError') {}
47
34
 
48
- registerErrorMessageContext('INVALID_CONFIG', InvalidConfigError);
35
+ registerErrorMessageContext('InvalidConfigError', InvalidConfigError);
49
36
 
50
37
  /**
51
38
  * Explicit failure to connect with remote client services.
52
39
  */
53
- export class RemoteServiceConnectionError extends ApiError {
54
- constructor(message?: string, context?: Record<string, any>) {
55
- super('REMOTE_SERVICE_CONNECTION_ERROR', message, context);
56
- }
57
- }
40
+ export class RemoteServiceConnectionError extends BaseError.extend('RemoteServiceConnectionError') {}
58
41
 
59
- registerErrorMessageContext('REMOTE_SERVICE_CONNECTION_ERROR', RemoteServiceConnectionError);
42
+ registerErrorMessageContext('RemoteServiceConnectionError', RemoteServiceConnectionError);
60
43
 
61
44
  /**
62
45
  * Failed to open a connection to remote client services.
63
46
  */
64
- export class RemoteServiceConnectionTimeout extends ApiError {
65
- constructor(message?: string, context?: Record<string, any>) {
66
- super('REMOTE_SERVICE_CONNECTION_TIMEOUT', message, context);
67
- }
68
- }
47
+ export class RemoteServiceConnectionTimeout extends BaseError.extend('RemoteServiceConnectionTimeout') {}
69
48
 
70
- registerErrorMessageContext('REMOTE_SERVICE_CONNECTION_TIMEOUT', RemoteServiceConnectionTimeout);
49
+ registerErrorMessageContext('RemoteServiceConnectionTimeout', RemoteServiceConnectionTimeout);
71
50
 
72
- export class DataCorruptionError extends SystemError {
73
- constructor(message?: string, context?: Record<string, any>) {
74
- super('DATA_CORRUPTION', message, context);
75
- }
76
- }
51
+ export class DataCorruptionError extends BaseError.extend('DataCorruptionError') {}
77
52
 
78
- registerErrorMessageContext('DATA_CORRUPTION', DataCorruptionError);
53
+ registerErrorMessageContext('DataCorruptionError', DataCorruptionError);
79
54
 
80
- export class InvalidInvitationExtensionRoleError extends SystemError {
81
- constructor(message?: string, context?: Record<string, any>) {
82
- super('INVALID_INVITATION_EXTENSION_ROLE', message, context);
83
- }
84
- }
55
+ export class InvalidInvitationExtensionRoleError extends BaseError.extend('InvalidInvitationExtensionRoleError') {}
85
56
 
86
- registerErrorMessageContext('INVALID_INVITATION_EXTENSION_ROLE', InvalidInvitationExtensionRoleError);
57
+ registerErrorMessageContext('InvalidInvitationExtensionRoleError', InvalidInvitationExtensionRoleError);
87
58
 
88
- export class IdentityNotInitializedError extends DatabaseError {
89
- constructor(message?: string, context?: Record<string, any>) {
90
- super('IDENTITY_NOT_INITIALIZED', message, context);
91
- }
92
- }
59
+ export class IdentityNotInitializedError extends BaseError.extend('IdentityNotInitializedError') {}
93
60
 
94
- registerErrorMessageContext('IDENTITY_NOT_INITIALIZED', IdentityNotInitializedError);
61
+ registerErrorMessageContext('IdentityNotInitializedError', IdentityNotInitializedError);
95
62
 
96
- export class InvalidInvitationError extends DatabaseError {
97
- constructor(message?: string, context?: Record<string, any>) {
98
- super('INVALID_INVITATION', message, context);
99
- }
100
- }
63
+ export class InvalidInvitationError extends BaseError.extend('InvalidInvitationError') {}
101
64
 
102
- registerErrorMessageContext('INVALID_INVITATION', InvalidInvitationError);
65
+ registerErrorMessageContext('InvalidInvitationError', InvalidInvitationError);
103
66
 
104
- export class AlreadyJoinedError extends DatabaseError {
105
- constructor(message?: string, context?: Record<string, any>) {
106
- super('ALREADY_JOINED', message, context);
107
- }
108
- }
67
+ export class AlreadyJoinedError extends BaseError.extend('AlreadyJoinedError') {}
109
68
 
110
- registerErrorMessageContext('ALREADY_JOINED', AlreadyJoinedError);
69
+ registerErrorMessageContext('AlreadyJoinedError', AlreadyJoinedError);
111
70
 
112
- export class ConnectionResetError extends BaseError {
113
- constructor(message?: string, context?: any) {
114
- super('CONNECTION_RESET', message, context);
115
- }
116
- }
71
+ export class ConnectionResetError extends BaseError.extend('ConnectionResetError') {}
117
72
 
118
- registerErrorMessageContext('CONNECTION_RESET', ConnectionResetError);
73
+ registerErrorMessageContext('ConnectionResetError', ConnectionResetError);
119
74
 
120
- export class TimeoutError extends BaseError {
121
- constructor(message?: string, context?: any) {
122
- super('TIMEOUT', message, context);
123
- }
124
- }
75
+ export class TimeoutError extends BaseError.extend('TimeoutError') {}
125
76
 
126
- registerErrorMessageContext('TIMEOUT', TimeoutError);
77
+ registerErrorMessageContext('TimeoutError', TimeoutError);
127
78
 
128
79
  // General protocol error.
129
- export class ProtocolError extends BaseError {
130
- constructor(message?: string, context?: any) {
131
- super('PROTOCOL_ERROR', message, context);
132
- }
133
- }
80
+ export class ProtocolError extends BaseError.extend('ProtocolError') {}
134
81
 
135
- registerErrorMessageContext('PROTOCOL_ERROR', ProtocolError);
82
+ registerErrorMessageContext(ProtocolError.name, ProtocolError);
136
83
 
137
84
  // General connectivity errors.
138
- export class ConnectivityError extends BaseError {
139
- constructor(message?: string, context?: any) {
140
- super('CONNECTIVITY_ERROR', message, context);
141
- }
142
- }
85
+ export class ConnectivityError extends BaseError.extend('ConnectivityError') {}
143
86
 
144
- registerErrorMessageContext('CONNECTIVITY_ERROR', ConnectivityError);
87
+ registerErrorMessageContext('ConnectivityError', ConnectivityError);
145
88
 
146
- export class RateLimitExceededError extends BaseError {
147
- constructor(message?: string, context?: any) {
148
- super('RATE_LIMIT_EXCEEDED', message, context);
149
- }
150
- }
89
+ export class RateLimitExceededError extends BaseError.extend('RateLimitExceededError') {}
151
90
 
152
- registerErrorMessageContext('RATE_LIMIT_EXCEEDED', RateLimitExceededError);
91
+ registerErrorMessageContext('RateLimitExceededError', RateLimitExceededError);
153
92
 
154
93
  // TODO(nf): Rename? the protocol isn't what's unknown...
155
- export class UnknownProtocolError extends BaseError {
156
- constructor(message?: string, innerError?: Error) {
157
- super('UNKNOWN_PROTOCOL_ERROR', message, innerError);
158
- }
159
- }
94
+ export class UnknownProtocolError extends BaseError.extend('UnknownProtocolError') {}
160
95
 
161
- registerErrorMessageContext('UNKNOWN_PROTOCOL_ERROR', UnknownProtocolError);
96
+ registerError(UnknownProtocolError.name, (message, context) => new UnknownProtocolError({ message, context }));
162
97
 
163
- export class InvalidStorageVersionError extends DatabaseError {
98
+ export class InvalidStorageVersionError extends BaseError.extend(
99
+ 'InvalidStorageVersionError',
100
+ 'Invalid storage version.',
101
+ ) {
164
102
  constructor(expected: number, actual: number) {
165
- super('INVALID_STORAGE_VERSION', 'Invalid storage version.', { expected, actual });
103
+ super({ context: { expected, actual } });
166
104
  }
167
105
  }
168
106
 
169
- registerError('INVALID_STORAGE_VERSION', (_, context) => {
107
+ registerError('InvalidStorageVersionError', (_, context) => {
170
108
  return new InvalidStorageVersionError(context.expected ?? NaN, context.actual ?? NaN);
171
109
  });
172
110
 
173
- export class SpaceNotFoundError extends DatabaseError {
111
+ export class SpaceNotFoundError extends BaseError.extend('SpaceNotFoundError', 'Space not found.') {
174
112
  constructor(spaceKey: PublicKey) {
175
- super('SPACE_NOT_FOUND', 'Space not found.', { spaceKey });
113
+ super({ context: { spaceKey } });
176
114
  }
177
115
  }
178
116
 
179
- registerError('SPACE_NOT_FOUND', (_, context) => {
117
+ registerError('SpaceNotFoundError', (_, context) => {
180
118
  return new SpaceNotFoundError(PublicKey.safeFrom(context.spaceKey) ?? PublicKey.from('00'));
181
119
  });
182
120
 
183
- export class EntityNotFoundError extends DatabaseError {
121
+ export class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Item not found.') {
184
122
  constructor(entityId: ObjectId) {
185
- super('ITEM_NOT_FOUND', 'Item not found.', { entityId });
123
+ super({ context: { entityId } });
186
124
  }
187
125
  }
188
126
 
189
- registerError('ITEM_NOT_FOUND', (_, context) => {
127
+ registerError('EntityNotFoundError', (_, context) => {
190
128
  return new EntityNotFoundError(context.entityId);
191
129
  });
192
130
 
193
- export class UnknownModelError extends DatabaseError {
131
+ export class UnknownModelError extends BaseError.extend('UnknownModelError', 'Unknown model.') {
194
132
  constructor(model: string) {
195
- super('UNKNOWN_MODEL', 'Unknown model.', { model });
133
+ super({ context: { model } });
196
134
  }
197
135
  }
198
136
 
199
- registerError('UNKNOWN_MODEL', (_, context) => {
137
+ registerError('UnknownModelError', (_, context) => {
200
138
  return new UnknownModelError(context.model);
201
139
  });
202
140
 
203
- export class AuthorizationError extends ApiError {
204
- constructor(message?: string, context?: any) {
205
- super('AUTHORIZATION_ERROR', message, context);
206
- }
207
- }
141
+ export class AuthorizationError extends BaseError.extend('AuthorizationError') {}
208
142
 
209
- registerErrorMessageContext('AUTHORIZATION_ERROR', AuthorizationError);
143
+ registerErrorMessageContext('AuthorizationError', AuthorizationError);
@@ -2,12 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { BaseError } from '@dxos/errors';
5
6
  import { invariant } from '@dxos/invariant';
6
7
 
7
8
  import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
8
9
 
9
- import { SystemError } from './base-errors.js';
10
-
11
10
  export const reconstructError = (error: SerializedErrorProto) => {
12
11
  const { name, message, context } = error;
13
12
  return errorFromCode(name, message, context);
@@ -20,21 +19,21 @@ export const registerError = (code: string, make: (message?: string, context?: a
20
19
  errorRegistry.set(code, make);
21
20
  };
22
21
 
23
- export const registerErrorNoArgs = (code: string, Constructor: { new (): Error }) => {
22
+ export const registerErrorNoArgs = (code: string, Constructor: { new (options?: any): Error }) => {
24
23
  registerError(code, () => new Constructor());
25
24
  };
26
25
 
27
26
  export const registerErrorMessageContext = (
28
27
  code: string,
29
- Constructor: { new (message?: string, context?: any): Error },
28
+ Constructor: { new (options?: { message?: string; context?: any }): Error },
30
29
  ) => {
31
- registerError(code, (message?: string, context?: string) => new Constructor(message, context));
30
+ registerError(code, (message?: string, context?: any) => new Constructor({ message, context }));
32
31
  };
33
32
 
34
33
  export const errorFromCode = (code?: string, message?: string, context?: any) => {
35
34
  if (code && errorRegistry.has(code)) {
36
35
  return errorRegistry.get(code)!(message, context);
37
36
  } else {
38
- return new SystemError(code ?? 'Error', message, context);
37
+ return new BaseError(code ?? 'Error', { message, context });
39
38
  }
40
39
  };
@@ -12,6 +12,7 @@ export type FeedBlock = {
12
12
  }[];
13
13
  signature: Uint8Array;
14
14
  };
15
+
15
16
  export type GetMetadataProtocolMessage = {
16
17
  type: 'get-metadata';
17
18
  feedKey: string;
package/src/index.ts CHANGED
@@ -2,15 +2,17 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
+ // TODO(burdon): Why export .js?
6
+
5
7
  export * from './automerge.js';
6
- export * from './edge-error.js';
7
- export * from './edge.js';
8
+ export * from './edge/index.js';
8
9
  export * from './errors/index.js';
9
10
  export * from './indexing.js';
11
+ export * from './messenger.js';
10
12
  export * from './profile-archive.js';
11
- export * from './query.js';
12
13
  export * from './queue.js';
13
14
  export * from './space-archive.js';
14
15
  export * from './storage.js';
15
16
  export * from './tracing.js';
16
17
  export type * from './types.js';
18
+ export * as FunctionProtocol from './FunctionProtocol.js';
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type CleanupFn } from '@dxos/async';
6
+
7
+ import { type GossipMessage } from './proto/gen/dxos/mesh/teleport/gossip';
8
+
9
+ /**
10
+ * Message passing abstraction.
11
+ */
12
+ export interface Messenger {
13
+ /**
14
+ * Register channel listener.
15
+ */
16
+ listen: (channel: string, callback: (message: GossipMessage) => void) => CleanupFn;
17
+
18
+ /**
19
+ * Send message to channel.
20
+ */
21
+ postMessage: (channel: string, message: any) => Promise<void>;
22
+ }
@@ -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
+ }
@@ -155,6 +155,8 @@ message Runtime {
155
155
  optional bool enable_vector_indexing = 12;
156
156
 
157
157
  optional EdgeFeatures edge_features = 11;
158
+
159
+ optional bool enable_local_queues = 13;
158
160
  }
159
161
 
160
162
  message App {
@@ -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.
@@ -39,6 +39,7 @@ message AppContextRequest {
39
39
  /// The key of the joined space.
40
40
  optional dxos.keys.PublicKey space_key = 2;
41
41
 
42
+ // TODO(wittjosiah): Make the generated type be `SpaceId`.
42
43
  /// The id of the joined space.
43
44
  optional string space_id = 5;
44
45
 
@@ -435,6 +435,109 @@ export interface LoggingService {
435
435
  queryMetrics: (request: QueryMetricsRequest, options?: RequestOptions) => Stream<QueryMetricsResponse>;
436
436
  queryLogs: (request: QueryLogsRequest, options?: RequestOptions) => Stream<LogEntry>;
437
437
  }
438
+ /**
439
+ * Defined in:
440
+ * {@link file://./../../../dxos/client/queue.proto}
441
+ */
442
+ export interface QueueQuery {
443
+ spaceId: string;
444
+ /**
445
+ * Options:
446
+ * - proto3_optional = true
447
+ */
448
+ queuesNamespace?: string;
449
+ /**
450
+ * Queries the whole space if missing.
451
+ */
452
+ queueIds?: string[];
453
+ /**
454
+ * Filter items after this cursor. Exclusive.
455
+ *
456
+ * Options:
457
+ * - proto3_optional = true
458
+ */
459
+ after?: string;
460
+ /**
461
+ * Filter items before this cursor. Exclusive.
462
+ *
463
+ * Options:
464
+ * - proto3_optional = true
465
+ */
466
+ before?: string;
467
+ /**
468
+ * Filter items after this position. Inclusive.
469
+ *
470
+ * Options:
471
+ * - proto3_optional = true
472
+ */
473
+ beginPosition?: string;
474
+ /**
475
+ * Filter items before this position. Exclusive.
476
+ *
477
+ * Options:
478
+ * - proto3_optional = true
479
+ */
480
+ endPosition?: string;
481
+ /**
482
+ * Options:
483
+ * - proto3_optional = true
484
+ */
485
+ limit?: number;
486
+ /**
487
+ * Options:
488
+ * - proto3_optional = true
489
+ */
490
+ reverse?: boolean;
491
+ objectIds?: string[];
492
+ }
493
+ /**
494
+ * Defined in:
495
+ * {@link file://./../../../dxos/client/queue.proto}
496
+ */
497
+ export interface QueueQueryResult {
498
+ objects?: ReturnType<(typeof substitutions)["google.protobuf.Struct"]["decode"]>[];
499
+ /**
500
+ * Cursor to query the next items. Can be passed to `after` in query to keep querying.
501
+ */
502
+ nextCursor: string;
503
+ prevCursor: string;
504
+ }
505
+ /**
506
+ * Defined in:
507
+ * {@link file://./../../../dxos/client/queue.proto}
508
+ */
509
+ export interface QueryQueueRequest {
510
+ query: QueueQuery;
511
+ }
512
+ /**
513
+ * Defined in:
514
+ * {@link file://./../../../dxos/client/queue.proto}
515
+ */
516
+ export interface InsertIntoQueueRequest {
517
+ subspaceTag: string;
518
+ spaceId: string;
519
+ queueId: string;
520
+ objects?: ReturnType<(typeof substitutions)["google.protobuf.Struct"]["decode"]>[];
521
+ }
522
+ /**
523
+ * Defined in:
524
+ * {@link file://./../../../dxos/client/queue.proto}
525
+ */
526
+ export interface DeleteFromQueueRequest {
527
+ subspaceTag: string;
528
+ spaceId: string;
529
+ queueId: string;
530
+ objectIds?: string[];
531
+ }
532
+ /**
533
+ * Defined in:
534
+ * {@link file://./../../../dxos/client/queue.proto}
535
+ */
536
+ export interface QueueService {
537
+ queryQueue: (request: QueryQueueRequest, options?: RequestOptions) => Promise<QueueQueryResult>;
538
+ insertIntoQueue: (request: InsertIntoQueueRequest, options?: RequestOptions) => Promise<void>;
539
+ deleteFromQueue: (request: DeleteFromQueueRequest, options?: RequestOptions) => Promise<void>;
540
+ }
438
541
  /**
439
542
  * Defined in:
440
543
  * {@link file://./../../../dxos/client/services.proto}
@@ -332,6 +332,11 @@ export namespace Runtime {
332
332
  * - proto3_optional = true
333
333
  */
334
334
  edgeFeatures?: Runtime.Client.EdgeFeatures;
335
+ /**
336
+ * Options:
337
+ * - proto3_optional = true
338
+ */
339
+ enableLocalQueues?: boolean;
335
340
  }
336
341
  export namespace Client {
337
342
  /**
@@ -106,9 +106,25 @@ export interface Heads {
106
106
  export interface QueryResult {
107
107
  id: string;
108
108
  spaceId: string;
109
- documentId: string;
109
+ /**
110
+ * Options:
111
+ * - proto3_optional = true
112
+ */
113
+ documentId?: string;
114
+ /**
115
+ * Options:
116
+ * - proto3_optional = true
117
+ */
118
+ queueId?: string;
119
+ /**
120
+ * Options:
121
+ * - proto3_optional = true
122
+ */
123
+ queueNamespace?: string;
110
124
  rank: number;
111
125
  /**
126
+ * In the ECHO Json object format.
127
+ *
112
128
  * Options:
113
129
  * - proto3_optional = true
114
130
  */