@dxos/protocols 0.1.57 → 0.1.58-main.0009f6a

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 (130) hide show
  1. package/dist/cjs/src/errors/encoding.d.ts +7 -0
  2. package/dist/cjs/src/errors/encoding.d.ts.map +1 -0
  3. package/dist/cjs/src/errors/encoding.js +41 -0
  4. package/dist/cjs/src/errors/encoding.js.map +1 -0
  5. package/dist/cjs/src/errors/errors.d.ts +99 -0
  6. package/dist/cjs/src/errors/errors.d.ts.map +1 -0
  7. package/dist/cjs/src/errors/errors.js +171 -0
  8. package/dist/cjs/src/errors/errors.js.map +1 -0
  9. package/dist/cjs/src/errors/errors.test.d.ts +2 -0
  10. package/dist/cjs/src/errors/errors.test.d.ts.map +1 -0
  11. package/dist/cjs/src/errors/errors.test.js +45 -0
  12. package/dist/cjs/src/errors/errors.test.js.map +1 -0
  13. package/dist/cjs/src/errors/helpers.d.ts +5 -0
  14. package/dist/cjs/src/errors/helpers.d.ts.map +1 -0
  15. package/dist/cjs/src/errors/helpers.js +74 -0
  16. package/dist/cjs/src/errors/helpers.js.map +1 -0
  17. package/dist/cjs/src/errors/index.d.ts +4 -0
  18. package/dist/cjs/src/errors/index.d.ts.map +1 -0
  19. package/dist/cjs/src/errors/index.js +23 -0
  20. package/dist/cjs/src/errors/index.js.map +1 -0
  21. package/dist/cjs/src/index.d.ts +2 -2
  22. package/dist/cjs/src/index.d.ts.map +1 -1
  23. package/dist/cjs/src/index.js +2 -2
  24. package/dist/cjs/src/index.js.map +1 -1
  25. package/dist/cjs/src/proto/gen/dxos/client/services.d.ts +7 -1
  26. package/dist/cjs/src/proto/gen/dxos/client/services.d.ts.map +1 -1
  27. package/dist/cjs/src/proto/gen/dxos/client/services.js +1 -0
  28. package/dist/cjs/src/proto/gen/dxos/client/services.js.map +1 -1
  29. package/dist/cjs/src/proto/gen/dxos/config.d.ts +5 -5
  30. package/dist/cjs/src/proto/gen/dxos/config.d.ts.map +1 -1
  31. package/dist/cjs/src/proto/gen/dxos/error.d.ts +6 -0
  32. package/dist/cjs/src/proto/gen/dxos/error.d.ts.map +1 -1
  33. package/dist/cjs/src/proto/gen/dxos/halo/credentials.d.ts +14 -1
  34. package/dist/cjs/src/proto/gen/dxos/halo/credentials.d.ts.map +1 -1
  35. package/dist/cjs/src/proto/gen/dxos/halo/credentials.js.map +1 -1
  36. package/dist/cjs/src/proto/gen/dxos/iframe.d.ts +5 -10
  37. package/dist/cjs/src/proto/gen/dxos/iframe.d.ts.map +1 -1
  38. package/dist/cjs/src/proto/gen/dxos/iframe.js +5 -3
  39. package/dist/cjs/src/proto/gen/dxos/iframe.js.map +1 -1
  40. package/dist/cjs/src/proto/gen/google/protobuf.d.ts +4 -4
  41. package/dist/cjs/src/proto/gen/google/protobuf.d.ts.map +1 -1
  42. package/dist/cjs/src/proto/gen/google/protobuf.js.map +1 -1
  43. package/dist/cjs/src/proto/gen/index.d.ts +1 -0
  44. package/dist/cjs/src/proto/gen/index.d.ts.map +1 -1
  45. package/dist/cjs/src/proto/gen/index.js +1 -1
  46. package/dist/cjs/src/proto/gen/index.js.map +1 -1
  47. package/dist/cjs/src/storage.d.ts +2 -3
  48. package/dist/cjs/src/storage.d.ts.map +1 -1
  49. package/dist/cjs/src/storage.js +2 -3
  50. package/dist/cjs/src/storage.js.map +1 -1
  51. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  52. package/dist/esm/src/errors/encoding.d.ts +7 -0
  53. package/dist/esm/src/errors/encoding.d.ts.map +1 -0
  54. package/dist/esm/src/errors/encoding.js +35 -0
  55. package/dist/esm/src/errors/encoding.js.map +1 -0
  56. package/dist/esm/src/errors/errors.d.ts +99 -0
  57. package/dist/esm/src/errors/errors.d.ts.map +1 -0
  58. package/dist/esm/src/errors/errors.js +148 -0
  59. package/dist/esm/src/errors/errors.js.map +1 -0
  60. package/dist/esm/src/errors/errors.test.d.ts +2 -0
  61. package/dist/esm/src/errors/errors.test.d.ts.map +1 -0
  62. package/dist/esm/src/errors/errors.test.js +17 -0
  63. package/dist/esm/src/errors/errors.test.js.map +1 -0
  64. package/dist/esm/src/errors/helpers.d.ts +5 -0
  65. package/dist/esm/src/errors/helpers.d.ts.map +1 -0
  66. package/dist/esm/src/errors/helpers.js +69 -0
  67. package/dist/esm/src/errors/helpers.js.map +1 -0
  68. package/dist/esm/src/errors/index.d.ts +4 -0
  69. package/dist/esm/src/errors/index.d.ts.map +1 -0
  70. package/dist/esm/src/errors/index.js +7 -0
  71. package/dist/esm/src/errors/index.js.map +1 -0
  72. package/dist/esm/src/index.d.ts +2 -2
  73. package/dist/esm/src/index.d.ts.map +1 -1
  74. package/dist/esm/src/index.js +2 -2
  75. package/dist/esm/src/index.js.map +1 -1
  76. package/dist/esm/src/proto/gen/dxos/client/services.d.ts +7 -1
  77. package/dist/esm/src/proto/gen/dxos/client/services.d.ts.map +1 -1
  78. package/dist/esm/src/proto/gen/dxos/client/services.js +1 -0
  79. package/dist/esm/src/proto/gen/dxos/client/services.js.map +1 -1
  80. package/dist/esm/src/proto/gen/dxos/config.d.ts +5 -5
  81. package/dist/esm/src/proto/gen/dxos/config.d.ts.map +1 -1
  82. package/dist/esm/src/proto/gen/dxos/error.d.ts +6 -0
  83. package/dist/esm/src/proto/gen/dxos/error.d.ts.map +1 -1
  84. package/dist/esm/src/proto/gen/dxos/halo/credentials.d.ts +14 -1
  85. package/dist/esm/src/proto/gen/dxos/halo/credentials.d.ts.map +1 -1
  86. package/dist/esm/src/proto/gen/dxos/halo/credentials.js.map +1 -1
  87. package/dist/esm/src/proto/gen/dxos/iframe.d.ts +5 -10
  88. package/dist/esm/src/proto/gen/dxos/iframe.d.ts.map +1 -1
  89. package/dist/esm/src/proto/gen/dxos/iframe.js +5 -3
  90. package/dist/esm/src/proto/gen/dxos/iframe.js.map +1 -1
  91. package/dist/esm/src/proto/gen/google/protobuf.d.ts +4 -4
  92. package/dist/esm/src/proto/gen/google/protobuf.d.ts.map +1 -1
  93. package/dist/esm/src/proto/gen/google/protobuf.js.map +1 -1
  94. package/dist/esm/src/proto/gen/index.d.ts +1 -0
  95. package/dist/esm/src/proto/gen/index.d.ts.map +1 -1
  96. package/dist/esm/src/proto/gen/index.js +1 -1
  97. package/dist/esm/src/proto/gen/index.js.map +1 -1
  98. package/dist/esm/src/storage.d.ts +2 -3
  99. package/dist/esm/src/storage.d.ts.map +1 -1
  100. package/dist/esm/src/storage.js +2 -3
  101. package/dist/esm/src/storage.js.map +1 -1
  102. package/package.json +5 -4
  103. package/src/errors/encoding.ts +40 -0
  104. package/src/errors/errors.test.ts +22 -0
  105. package/src/errors/errors.ts +170 -0
  106. package/src/errors/helpers.ts +113 -0
  107. package/src/errors/index.ts +7 -0
  108. package/src/index.ts +2 -2
  109. package/src/proto/dxos/client/services.proto +2 -0
  110. package/src/proto/dxos/config.proto +13 -9
  111. package/src/proto/dxos/error.proto +1 -0
  112. package/src/proto/dxos/halo/credentials.proto +8 -1
  113. package/src/proto/dxos/iframe.proto +6 -5
  114. package/src/proto/gen/dxos/client/services.ts +7 -1
  115. package/src/proto/gen/dxos/config.ts +5 -5
  116. package/src/proto/gen/dxos/error.ts +5 -0
  117. package/src/proto/gen/dxos/halo/credentials.ts +14 -1
  118. package/src/proto/gen/dxos/iframe.ts +5 -10
  119. package/src/proto/gen/google/protobuf.ts +4 -4
  120. package/src/proto/gen/index.ts +2 -1
  121. package/src/storage.ts +2 -3
  122. package/dist/cjs/src/errors.d.ts +0 -25
  123. package/dist/cjs/src/errors.d.ts.map +0 -1
  124. package/dist/cjs/src/errors.js +0 -78
  125. package/dist/cjs/src/errors.js.map +0 -1
  126. package/dist/esm/src/errors.d.ts +0 -25
  127. package/dist/esm/src/errors.d.ts.map +0 -1
  128. package/dist/esm/src/errors.js +0 -69
  129. package/dist/esm/src/errors.js.map +0 -1
  130. package/src/errors.ts +0 -80
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/proto/gen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAuDhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AA8e7C,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,44zFAA44zF,CAAC,CAAC,CAAC;AACr8zF,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAkB,UAAU,EAAE,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/proto/gen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAuDhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AA+e7C,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,gn0FAAgn0F,CAAC,CAAC,CAAC;AACzq0F,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAkB,UAAU,EAAE,aAAa,CAAC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
3
- *
4
- * Should be incremented every time there's a breaking change to the stored data.
3
+ * update when making breaking changes to the protocols or other stored data.
5
4
  */
6
- export declare const STORAGE_VERSION = 1;
5
+ export declare const STORAGE_VERSION = 2;
7
6
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/storage.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/storage.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC"}
@@ -3,8 +3,7 @@
3
3
  //
4
4
  /**
5
5
  * Version for the schema of the stored data as defined in dxos.echo.metadata.EchoMetadata.
6
- *
7
- * Should be incremented every time there's a breaking change to the stored data.
6
+ * update when making breaking changes to the protocols or other stored data.
8
7
  */
9
- export const STORAGE_VERSION = 1;
8
+ export const STORAGE_VERSION = 2;
10
9
  //# sourceMappingURL=storage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/storage.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/storage.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/protocols",
3
- "version": "0.1.57",
3
+ "version": "0.1.58-main.0009f6a",
4
4
  "description": "Protobuf definitions for DXOS protocols.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -33,9 +33,10 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@dxos/codec-protobuf": "0.1.57",
37
- "@dxos/keys": "0.1.57",
38
- "@dxos/timeframe": "0.1.57"
36
+ "@dxos/codec-protobuf": "0.1.58-main.0009f6a",
37
+ "@dxos/invariant": "0.1.58-main.0009f6a",
38
+ "@dxos/keys": "0.1.58-main.0009f6a",
39
+ "@dxos/timeframe": "0.1.58-main.0009f6a"
39
40
  },
40
41
  "devDependencies": {
41
42
  "glob": "~7.1.6"
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { reconstructError } from './helpers';
6
+ import { Error as SerializedErrorProto } from '../proto/gen/dxos/error';
7
+
8
+ export const encodeError = (err: any): SerializedErrorProto => {
9
+ if (typeof err === 'object' && err?.message) {
10
+ return {
11
+ name: err.name,
12
+ message: err.message,
13
+ context: err.context,
14
+ stack: err.stack,
15
+ };
16
+ } else if (typeof err === 'string') {
17
+ return {
18
+ message: err,
19
+ };
20
+ } else {
21
+ return {
22
+ message: JSON.stringify(err),
23
+ };
24
+ }
25
+ };
26
+
27
+ export type DecodeOptions = {
28
+ appendStack?: string;
29
+ };
30
+
31
+ export const decodeError = (err: SerializedErrorProto, { appendStack }: DecodeOptions = {}) => {
32
+ const error = reconstructError(err);
33
+ if (appendStack) {
34
+ error.stack = (err.stack ?? `${error.message}\n`) + appendStack;
35
+ } else {
36
+ error.stack = err.stack;
37
+ }
38
+
39
+ return error;
40
+ };
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import chai, { expect } from 'chai';
6
+ import chaiAsPromised from 'chai-as-promised';
7
+
8
+ import { describe, test } from '@dxos/test';
9
+
10
+ import { ApiError } from './errors';
11
+
12
+ chai.use(chaiAsPromised);
13
+
14
+ describe('Errors', () => {
15
+ test('test', async () => {
16
+ const runTest = async () => {
17
+ throw new ApiError('Test error');
18
+ };
19
+
20
+ await expect(runTest()).to.be.rejectedWith('Test error');
21
+ });
22
+ });
@@ -0,0 +1,170 @@
1
+ //
2
+ // Copyright 2021 DXOS.org
3
+ //
4
+
5
+ import type { PublicKey } from '@dxos/keys';
6
+
7
+ import type { ItemID } from '../types';
8
+
9
+ /**
10
+ * NOTE: Messages should be sentences (Start with a capital letter and end with a period).
11
+ * Errors can optionally include a JSON context object.
12
+ */
13
+ class BaseError extends Error {
14
+ constructor(
15
+ readonly code: string,
16
+ message?: string,
17
+ readonly context?: Record<string, any>,
18
+ ) {
19
+ super(message ?? code);
20
+ this.name = code;
21
+ // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).
22
+ Object.setPrototypeOf(this, new.target.prototype);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * User facing API Errors.
28
+ * E.g., something was misconfigured.
29
+ */
30
+ export class ApiError extends BaseError {}
31
+
32
+ /**
33
+ * Internal system errors.
34
+ * E.g., unexpected/unrecoverable runtime error.
35
+ */
36
+ export class SystemError extends BaseError {}
37
+
38
+ /**
39
+ * Database errors.
40
+ */
41
+ // TODO(wittjosiah): Same as ApiError?
42
+ export class DatabaseError extends BaseError {}
43
+
44
+ /**
45
+ * Thrown when request was terminated because the RPC endpoint has been closed.
46
+ */
47
+ export class RpcClosedError extends SystemError {
48
+ constructor() {
49
+ super('RPC_CLOSED', 'Request was terminated because the RPC endpoint is closed.');
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Thrown when `request` is called when RPC has not been opened.
55
+ */
56
+ export class RpcNotOpenError extends SystemError {
57
+ constructor() {
58
+ super('RPC_NOT_OPEN', 'RPC has not been opened.');
59
+ }
60
+ }
61
+
62
+ export class CancelledError extends SystemError {
63
+ constructor(message?: string, context?: Record<string, any>) {
64
+ super('CANCELLED', message, context);
65
+ }
66
+ }
67
+
68
+ export class InvalidConfigError extends ApiError {
69
+ constructor(message?: string, context?: Record<string, any>) {
70
+ super('INVALID_CONFIG', message, context);
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Explicit failure to connect with remote client services.
76
+ */
77
+ export class RemoteServiceConnectionError extends ApiError {
78
+ constructor(message?: string, context?: Record<string, any>) {
79
+ super('REMOTE_SERVICE_CONNECTION_ERROR', message, context);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Failed to open a connection to remote client services.
85
+ */
86
+ export class RemoteServiceConnectionTimeout extends ApiError {
87
+ constructor(message?: string, context?: Record<string, any>) {
88
+ super('REMOTE_SERVICE_CONNECTION_TIMEOUT', message, context);
89
+ }
90
+ }
91
+
92
+ export class DataCorruptionError extends SystemError {
93
+ constructor(message?: string, context?: Record<string, any>) {
94
+ super('DATA_CORRUPTION', message, context);
95
+ }
96
+ }
97
+
98
+ export class InvalidInvitationExtensionRoleError extends SystemError {
99
+ constructor(message?: string, context?: Record<string, any>) {
100
+ super('INVALID_INVITATION_EXTENSION_ROLE', message, context);
101
+ }
102
+ }
103
+
104
+ export class IdentityNotInitializedError extends DatabaseError {
105
+ constructor(message?: string, context?: Record<string, any>) {
106
+ super('IDENTITY_NOT_INITIALIZED', message, context);
107
+ }
108
+ }
109
+
110
+ export class InvalidInvitationError extends DatabaseError {
111
+ constructor(message?: string, context?: Record<string, any>) {
112
+ super('INVALID_INVITATION', message, context);
113
+ }
114
+ }
115
+
116
+ export class ConnectionResetError extends BaseError {
117
+ constructor(message?: string, context?: any) {
118
+ super('CONNECTION_RESET', message, context);
119
+ }
120
+ }
121
+
122
+ export class TimeoutError extends BaseError {
123
+ constructor(message?: string, context?: any) {
124
+ super('TIMEOUT', message, context);
125
+ }
126
+ }
127
+
128
+ // General protocol error.
129
+ export class ProtocolError extends BaseError {
130
+ constructor(message?: string, context?: any) {
131
+ super('PROTOCOL_ERROR', message, context);
132
+ }
133
+ }
134
+
135
+ // General connectivity errors.
136
+ export class ConnectivityError extends BaseError {
137
+ constructor(message?: string, context?: any) {
138
+ super('CONNECTIVITY_ERROR', message, context);
139
+ }
140
+ }
141
+
142
+ // TODO(nf): Rename? the protocol isn't what's unknown...
143
+ export class UnknownProtocolError extends BaseError {
144
+ constructor(message?: string, innerError?: Error) {
145
+ super('UNKNOWN_PROTOCOL_ERROR', message, innerError);
146
+ }
147
+ }
148
+ export class InvalidStorageVersionError extends DatabaseError {
149
+ constructor(expected: number, actual: number) {
150
+ super('INVALID_STORAGE_VERSION', 'Invalid storage version.', { expected, actual });
151
+ }
152
+ }
153
+
154
+ export class SpaceNotFoundError extends DatabaseError {
155
+ constructor(spaceKey: PublicKey) {
156
+ super('SPACE_NOT_FOUND', 'Space not found.', { spaceKey });
157
+ }
158
+ }
159
+
160
+ export class EntityNotFoundError extends DatabaseError {
161
+ constructor(entityId: ItemID) {
162
+ super('ITEM_NOT_FOUND', 'Item not found.', { entityId });
163
+ }
164
+ }
165
+
166
+ export class UnknownModelError extends DatabaseError {
167
+ constructor(model: string) {
168
+ super('UNKNOWN_MODEL', 'Unknown model.', { model });
169
+ }
170
+ }
@@ -0,0 +1,113 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { invariant } from '@dxos/invariant';
6
+ import { PublicKey } from '@dxos/keys';
7
+
8
+ import {
9
+ CancelledError,
10
+ ConnectionResetError,
11
+ ConnectivityError,
12
+ DataCorruptionError,
13
+ EntityNotFoundError,
14
+ IdentityNotInitializedError,
15
+ InvalidConfigError,
16
+ InvalidInvitationError,
17
+ InvalidInvitationExtensionRoleError,
18
+ InvalidStorageVersionError,
19
+ ProtocolError,
20
+ RemoteServiceConnectionError,
21
+ RemoteServiceConnectionTimeout,
22
+ RpcClosedError,
23
+ RpcNotOpenError,
24
+ SpaceNotFoundError,
25
+ SystemError,
26
+ TimeoutError,
27
+ UnknownModelError,
28
+ UnknownProtocolError,
29
+ } from './errors';
30
+ import { Error as SerializedErrorProto } from '../proto/gen/dxos/error';
31
+
32
+ export const reconstructError = (error: SerializedErrorProto) => {
33
+ const { name, message, context } = error;
34
+ return errorFromCode(name, message, context);
35
+ };
36
+
37
+ export const errorFromCode = (code?: string, message?: string, context?: any) => {
38
+ switch (code) {
39
+ case 'RPC_CLOSED':
40
+ return new RpcClosedError();
41
+
42
+ case 'RPC_NOT_OPEN':
43
+ return new RpcNotOpenError();
44
+
45
+ case 'CANCELLED':
46
+ return new CancelledError(message, context);
47
+
48
+ case 'INVALID_CONFIG':
49
+ return new InvalidConfigError(message, context);
50
+
51
+ case 'REMOTE_SERVICE_CONNECTION_ERROR':
52
+ return new RemoteServiceConnectionError(message, context);
53
+
54
+ case 'REMOTE_SERVICE_CONNECTION_TIMEOUT':
55
+ return new RemoteServiceConnectionTimeout(message, context);
56
+
57
+ case 'DATA_CORRUPTION':
58
+ return new DataCorruptionError(message, context);
59
+
60
+ case 'INVALID_INVITATION_EXTENSION_ROLE':
61
+ return new InvalidInvitationExtensionRoleError(message, context);
62
+
63
+ case 'CONNECTION_RESET':
64
+ return new ConnectionResetError(message, context);
65
+
66
+ case 'TIMEOUT':
67
+ return new TimeoutError(message, context);
68
+
69
+ case 'PROTOCOL_ERROR':
70
+ return new ProtocolError(message, context);
71
+
72
+ case 'CONNECTIVITY_ERROR':
73
+ return new ConnectivityError(message, context);
74
+
75
+ case 'UNKNOWN_PROTOCOL_ERROR':
76
+ return new UnknownProtocolError(message, context);
77
+
78
+ case 'IDENTITY_NOT_INITIALIZED':
79
+ return new IdentityNotInitializedError(message, context);
80
+
81
+ case 'INVALID_INVITATION':
82
+ return new InvalidInvitationError(message, context);
83
+
84
+ case 'INVALID_STORAGE_VERSION': {
85
+ const { expected, actual } = context;
86
+ invariant(expected);
87
+ invariant(actual);
88
+ return new InvalidStorageVersionError(expected, actual);
89
+ }
90
+
91
+ case 'SPACE_NOT_FOUND': {
92
+ const { spaceKey: key } = context;
93
+ const spaceKey = PublicKey.safeFrom(key);
94
+ invariant(spaceKey);
95
+ return new SpaceNotFoundError(spaceKey);
96
+ }
97
+
98
+ case 'ITEM_NOT_FOUND': {
99
+ const { entityId } = context;
100
+ invariant(typeof entityId === 'string');
101
+ return new EntityNotFoundError(entityId);
102
+ }
103
+
104
+ case 'UNKNOWN_MODEL': {
105
+ const { model } = context;
106
+ invariant(typeof model === 'string');
107
+ return new UnknownModelError(model);
108
+ }
109
+
110
+ default:
111
+ return new SystemError(code ?? 'Error', message, context);
112
+ }
113
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export * from './encoding';
6
+ export * from './errors';
7
+ export * from './helpers';
package/src/index.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
+ export * from './errors';
5
6
  export * from './proto';
6
7
  export * from './storage';
7
8
  export * from './testing';
8
- export * from './types';
9
9
  export * from './tracing';
10
- export * from './errors';
10
+ export * from './types';
@@ -163,6 +163,7 @@ message SpaceMember {
163
163
  enum PresenceState {
164
164
  OFFLINE = 0;
165
165
  ONLINE = 1;
166
+ REMOVED = 2;
166
167
  }
167
168
 
168
169
  Identity identity = 1;
@@ -301,6 +302,7 @@ message WriteCredentialsRequest {
301
302
 
302
303
  message QueryCredentialsRequest {
303
304
  dxos.keys.PublicKey space_key = 1;
305
+ optional bool no_tail = 2;
304
306
  }
305
307
 
306
308
  message CreateEpochRequest {
@@ -45,6 +45,9 @@ message Repo {
45
45
  optional string version = 3;
46
46
  }
47
47
 
48
+ //
49
+ // Unit of deployment.
50
+ //
48
51
  message Module {
49
52
  message Build {
50
53
  optional string command = 1;
@@ -55,22 +58,23 @@ message Module {
55
58
  optional google.protobuf.Struct env = 10;
56
59
  }
57
60
 
58
- optional string name = 1; // TODO(burdon): Replace with id (or key?)
59
61
  optional string id = 8; // TODO(burdon): Ensured FQ (e.g., 'dxos.app.xxx')
60
- optional string type = 2; // TODO(burdon): Define namespace (e.g., 'dxos:type/frame' vs. 'dxos.type.frame')
62
+ optional string name = 1; // TODO(burdon): Replace with id (or key?)
63
+ optional string type = 2; // TODO(burdon): Define namespace (e.g., 'dxos.org/type/frame' vs. 'dxos.type.frame')
61
64
 
62
65
  // TODO(burdon): Developer info message.
63
66
 
67
+ // TODO(burdon): Start at 10.
64
68
  optional string display_name = 3;
65
69
  optional string description = 4;
66
70
  repeated string tags = 5;
67
- optional bytes bundle = 6;
71
+ optional bytes bundle = 6; // TODO(burdon): ???
68
72
 
69
73
  // TODO(burdon): Remove.
70
74
  optional bool tunnel = 7;
71
75
 
76
+ // TODO(burdon): Start at 100.
72
77
  repeated Module deps = 10; // TODO(burdon): E.g., types.
73
-
74
78
  optional Build build = 100;
75
79
  repeated Repo repos = 101;
76
80
 
@@ -90,15 +94,15 @@ message Runtime {
90
94
  NODE = 4;
91
95
  WEBFS = 5;
92
96
 
93
- // Key storage only
97
+ // Key storage only.
94
98
  LEVELJS = 11;
95
99
  JSONDOWN = 12;
96
100
  }
97
101
 
98
- optional bool persistent = 1; // TODO(burdon): Replace with type.
99
- optional StorageDriver key_storage = 3; // TODO(burdon): Rename key_store.
100
- optional StorageDriver storage_type = 2; // TODO(burdon): Rename data_store.
101
- optional string path = 4; // TODO(burdon): Rename data_path.
102
+ optional bool persistent = 1;
103
+ optional StorageDriver key_store = 2;
104
+ optional StorageDriver data_store = 3;
105
+ optional string data_root = 4;
102
106
  }
103
107
 
104
108
  message Log {
@@ -12,5 +12,6 @@ option go_package = "github.com/dxos/kube/proto/def/dxos/error";
12
12
  message Error {
13
13
  optional string name = 1;
14
14
  optional string message = 2;
15
+ optional google.protobuf.Struct context = 4;
15
16
  optional string stack = 3;
16
17
  }
@@ -38,6 +38,13 @@ message SpaceGenesis {
38
38
  // Claims can be written directly to a feed or used within Credentials.
39
39
  //
40
40
 
41
+ /**
42
+ * Revocation of another credential.
43
+ * Subject must be the credential id being revoked.
44
+ */
45
+ message Revocation {
46
+ }
47
+
41
48
  // TODO(burdon): Reconcile with dxos.client.SpaceMember.
42
49
  // [ASSERTION]: Agent is authorized to access Space.
43
50
  message SpaceMember {
@@ -219,7 +226,7 @@ message Credential {
219
226
  optional google.protobuf.Timestamp expiration_date = 4;
220
227
  optional bytes expiration_ref = 5; // Could reference blockchain or epoch number.
221
228
  Claim subject = 10;
222
- Proof proof = 11;
229
+ optional Proof proof = 11;
223
230
  }
224
231
 
225
232
  //
@@ -31,10 +31,9 @@ enum ShellDisplay {
31
31
  message AppContextRequest {
32
32
  /// The display mode that shell should use
33
33
  optional ShellDisplay display = 1;
34
+
34
35
  /// The key of the joined space
35
36
  optional dxos.keys.PublicKey space_key = 2;
36
- /// The invitation code which has become invalidated
37
- optional string invalidated_invitation_code = 3;
38
37
  }
39
38
 
40
39
  /// App RPCs for the shell.
@@ -45,9 +44,11 @@ service AppService {
45
44
  enum ShellLayout {
46
45
  DEFAULT = 0;
47
46
  INITIALIZE_IDENTITY = 1;
48
- DEVICE_INVITATIONS = 2;
49
- SPACE_INVITATIONS = 3;
50
- JOIN_SPACE = 4;
47
+ IDENTITY = 2;
48
+ SHARE_IDENTITY = 3;
49
+ EDIT_PROFILE = 4;
50
+ SPACE = 5;
51
+ JOIN_SPACE = 6;
51
52
  }
52
53
 
53
54
  message LayoutRequest {
@@ -442,7 +442,8 @@ export namespace SpaceMember {
442
442
  */
443
443
  export enum PresenceState {
444
444
  OFFLINE = 0,
445
- ONLINE = 1
445
+ ONLINE = 1,
446
+ REMOVED = 2
446
447
  }
447
448
  }
448
449
  /**
@@ -678,6 +679,11 @@ export interface WriteCredentialsRequest {
678
679
  */
679
680
  export interface QueryCredentialsRequest {
680
681
  spaceKey: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
682
+ /**
683
+ * Options:
684
+ * - proto3_optional = true
685
+ */
686
+ noTail?: boolean;
681
687
  }
682
688
  /**
683
689
  * Defined in:
@@ -117,12 +117,12 @@ export interface Module {
117
117
  * Options:
118
118
  * - proto3_optional = true
119
119
  */
120
- name?: string;
120
+ id?: string;
121
121
  /**
122
122
  * Options:
123
123
  * - proto3_optional = true
124
124
  */
125
- id?: string;
125
+ name?: string;
126
126
  /**
127
127
  * Options:
128
128
  * - proto3_optional = true
@@ -307,17 +307,17 @@ export namespace Runtime {
307
307
  * Options:
308
308
  * - proto3_optional = true
309
309
  */
310
- keyStorage?: Runtime.Client.Storage.StorageDriver;
310
+ keyStore?: Runtime.Client.Storage.StorageDriver;
311
311
  /**
312
312
  * Options:
313
313
  * - proto3_optional = true
314
314
  */
315
- storageType?: Runtime.Client.Storage.StorageDriver;
315
+ dataStore?: Runtime.Client.Storage.StorageDriver;
316
316
  /**
317
317
  * Options:
318
318
  * - proto3_optional = true
319
319
  */
320
- path?: string;
320
+ dataRoot?: string;
321
321
  }
322
322
  export namespace Storage {
323
323
  /**
@@ -70,6 +70,11 @@ export interface Error {
70
70
  * - proto3_optional = true
71
71
  */
72
72
  message?: string;
73
+ /**
74
+ * Options:
75
+ * - proto3_optional = true
76
+ */
77
+ context?: ReturnType<(typeof substitutions)["google.protobuf.Struct"]["decode"]>;
73
78
  /**
74
79
  * Options:
75
80
  * - proto3_optional = true
@@ -60,6 +60,15 @@ import * as google_protobuf from "../../google/protobuf";
60
60
  export interface SpaceGenesis {
61
61
  spaceKey: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
62
62
  }
63
+ /**
64
+ * Revocation of another credential.
65
+ * Subject must be the credential id being revoked.
66
+ *
67
+ * Defined in:
68
+ * {@link file://./../../../dxos/halo/credentials.proto}
69
+ */
70
+ export interface Revocation {
71
+ }
63
72
  /**
64
73
  * Defined in:
65
74
  * {@link file://./../../../dxos/halo/credentials.proto}
@@ -314,7 +323,11 @@ export interface Credential {
314
323
  */
315
324
  expirationRef?: Uint8Array;
316
325
  subject: Claim;
317
- proof: Proof;
326
+ /**
327
+ * Options:
328
+ * - proto3_optional = true
329
+ */
330
+ proof?: Proof;
318
331
  }
319
332
  /**
320
333
  * Defined in: