@dxos/client-protocol 0.8.3 → 0.8.4-main.1068cf700f

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 (53) hide show
  1. package/dist/lib/browser/chunk-N7EC364H.mjs +36 -0
  2. package/dist/lib/browser/chunk-N7EC364H.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +48 -40
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types/index.mjs +9 -0
  7. package/dist/lib/browser/types/index.mjs.map +7 -0
  8. package/dist/lib/node-esm/chunk-EM6VN4X6.mjs +38 -0
  9. package/dist/lib/node-esm/chunk-EM6VN4X6.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +47 -40
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/types/index.mjs +10 -0
  14. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  15. package/dist/types/src/config.d.ts +22 -8
  16. package/dist/types/src/config.d.ts.map +1 -1
  17. package/dist/types/src/echo.d.ts +9 -15
  18. package/dist/types/src/echo.d.ts.map +1 -1
  19. package/dist/types/src/halo.d.ts +1 -1
  20. package/dist/types/src/halo.d.ts.map +1 -1
  21. package/dist/types/src/index.d.ts +5 -5
  22. package/dist/types/src/index.d.ts.map +1 -1
  23. package/dist/types/src/{service-definitions.d.ts → service.d.ts} +18 -7
  24. package/dist/types/src/service.d.ts.map +1 -0
  25. package/dist/types/src/shell.d.ts +1 -1
  26. package/dist/types/src/shell.d.ts.map +1 -1
  27. package/dist/types/src/space.d.ts +31 -22
  28. package/dist/types/src/space.d.ts.map +1 -1
  29. package/dist/types/src/timeouts.d.ts +4 -0
  30. package/dist/types/src/timeouts.d.ts.map +1 -1
  31. package/dist/types/src/types/SpaceProperties.d.ts +27 -0
  32. package/dist/types/src/types/SpaceProperties.d.ts.map +1 -0
  33. package/dist/types/src/types/index.d.ts +2 -0
  34. package/dist/types/src/types/index.d.ts.map +1 -0
  35. package/dist/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +30 -18
  37. package/src/config.ts +34 -15
  38. package/src/echo.ts +11 -20
  39. package/src/halo.ts +1 -1
  40. package/src/index.ts +5 -5
  41. package/src/{service-definitions.ts → service.ts} +26 -12
  42. package/src/shell.ts +1 -1
  43. package/src/space.ts +51 -35
  44. package/src/timeouts.ts +5 -0
  45. package/src/types/SpaceProperties.ts +49 -0
  46. package/src/types/index.ts +5 -0
  47. package/dist/lib/node/index.cjs +0 -289
  48. package/dist/lib/node/index.cjs.map +0 -7
  49. package/dist/lib/node/meta.json +0 -1
  50. package/dist/types/src/schema.d.ts +0 -27
  51. package/dist/types/src/schema.d.ts.map +0 -1
  52. package/dist/types/src/service-definitions.d.ts.map +0 -1
  53. package/src/schema.ts +0 -28
package/package.json CHANGED
@@ -1,24 +1,38 @@
1
1
  {
2
2
  "name": "@dxos/client-protocol",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.1068cf700f",
4
4
  "description": "Core DXOS Client API.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
- "repository": "github:dxos/dxos",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
8
11
  "license": "MIT",
9
12
  "author": "DXOS.org",
10
- "sideEffects": true,
13
+ "sideEffects": false,
11
14
  "type": "module",
12
15
  "exports": {
13
16
  ".": {
17
+ "source": "./src/index.ts",
14
18
  "types": "./dist/types/src/index.d.ts",
15
19
  "browser": "./dist/lib/browser/index.mjs",
16
20
  "node": "./dist/lib/node-esm/index.mjs"
21
+ },
22
+ "./types": {
23
+ "source": "./src/types/index.ts",
24
+ "types": "./dist/types/src/types/index.d.ts",
25
+ "browser": "./dist/lib/browser/types/index.mjs",
26
+ "node": "./dist/lib/node-esm/types/index.mjs"
17
27
  }
18
28
  },
19
29
  "types": "dist/types/src/index.d.ts",
20
30
  "typesVersions": {
21
- "*": {}
31
+ "*": {
32
+ "./types": [
33
+ "./dist/types/src/types/index.d.ts"
34
+ ]
35
+ }
22
36
  },
23
37
  "files": [
24
38
  "dist",
@@ -26,22 +40,20 @@
26
40
  ],
27
41
  "dependencies": {
28
42
  "base-x": "~3.0.9",
29
- "effect": "3.14.21",
30
- "@dxos/async": "0.8.3",
31
- "@dxos/config": "0.8.3",
32
- "@dxos/context": "0.8.3",
33
- "@dxos/credentials": "0.8.3",
34
- "@dxos/echo-db": "0.8.3",
35
- "@dxos/echo": "0.8.3",
36
- "@dxos/echo-schema": "0.8.3",
37
- "@dxos/invariant": "0.8.3",
38
- "@dxos/keys": "0.8.3",
39
- "@dxos/node-std": "0.8.3",
40
- "@dxos/protocols": "0.8.3",
41
- "@dxos/rpc": "0.8.3"
43
+ "effect": "3.19.16",
44
+ "@dxos/async": "0.8.4-main.1068cf700f",
45
+ "@dxos/context": "0.8.4-main.1068cf700f",
46
+ "@dxos/credentials": "0.8.4-main.1068cf700f",
47
+ "@dxos/invariant": "0.8.4-main.1068cf700f",
48
+ "@dxos/echo-db": "0.8.4-main.1068cf700f",
49
+ "@dxos/echo": "0.8.4-main.1068cf700f",
50
+ "@dxos/node-std": "0.8.4-main.1068cf700f",
51
+ "@dxos/keys": "0.8.4-main.1068cf700f",
52
+ "@dxos/protocols": "0.8.4-main.1068cf700f",
53
+ "@dxos/rpc": "0.8.4-main.1068cf700f"
42
54
  },
43
55
  "peerDependencies": {
44
- "effect": "^3.13.3"
56
+ "effect": "3.19.16"
45
57
  },
46
58
  "publishConfig": {
47
59
  "access": "public"
package/src/config.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { type ConfigProto } from '@dxos/config';
5
+ // TODO(wittjosiah): Factor out to @dxos/config.
6
6
 
7
- export const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';
8
7
  export const DEFAULT_CLIENT_CHANNEL = 'dxos:app';
8
+ export const DEFAULT_INTERNAL_CHANNEL = 'dxos:vault';
9
9
  export const DEFAULT_SHELL_CHANNEL = 'dxos:shell';
10
10
  export const DEFAULT_WORKER_BROADCAST_CHANNEL = 'dxos:shared-worker';
11
11
 
@@ -14,18 +14,17 @@ export const DEFAULT_WORKER_BROADCAST_CHANNEL = 'dxos:shared-worker';
14
14
  */
15
15
  export const DEFAULT_VAULT_URL = 'https://halo.dxos.org/vault.html';
16
16
 
17
+ /**
18
+ * @deprecated
19
+ */
20
+ // TODO(burdon): Remove need (i.e., make undefined do the right thing).
21
+ export const DEFAULT_PROFILE = 'default';
22
+
17
23
  export const EXPECTED_CONFIG_VERSION = 1;
18
- export const defaultConfig: ConfigProto = { version: 1 };
24
+ export const defaultConfig = { version: 1 };
19
25
 
20
26
  // TODO(burdon): Allow override via env? Generalize since currently NodeJS only.
21
- const HOME = typeof process !== 'undefined' ? process?.env?.HOME ?? '' : '';
22
-
23
- // Base directories.
24
- // TODO(burdon): Consider Windows, Linux, OSX.
25
- // https://wiki.archlinux.org/title/XDG_Base_Directory
26
- // Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.
27
- export const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>
28
- `${root}/profile/${profile}` + (file ? `/${file}` : '');
27
+ const HOME = typeof process !== 'undefined' ? (process?.env?.HOME ?? '') : '';
29
28
 
30
29
  // XDG_CONFIG_HOME (Analogous to /etc.)
31
30
  export const DX_CONFIG = `${HOME}/.config/dx`;
@@ -43,7 +42,27 @@ export const DX_STATE = `${HOME}/.local/state/dx`;
43
42
  // XDG_RUNTIME_DIR (Non-essential files, sockets, etc.)
44
43
  export const DX_RUNTIME = '/tmp/dx/run';
45
44
 
46
- export const ENV_DX_CONFIG = 'DX_CONFIG';
47
- export const ENV_DX_NO_AGENT = 'DX_NO_AGENT';
48
- export const ENV_DX_PROFILE = 'DX_PROFILE';
49
- export const ENV_DX_PROFILE_DEFAULT = 'default';
45
+ export enum DXEnv {
46
+ CONFIG = 'DX_CONFIG',
47
+ DEBUG = 'DX_DEBUG',
48
+ NO_AGENT = 'DX_NO_AGENT',
49
+ PROFILE = 'DX_PROFILE',
50
+ }
51
+
52
+ export namespace DXEnv {
53
+ /**
54
+ * Helper to get the value from process.env
55
+ */
56
+ export function get(variable: DXEnv): string | undefined;
57
+ export function get(variable: DXEnv, defaultValue: string): string;
58
+ export function get(variable: DXEnv, defaultValue?: string): string | undefined {
59
+ return process.env[variable] ?? defaultValue;
60
+ }
61
+ }
62
+
63
+ // Base directories.
64
+ // TODO(burdon): Consider Windows, Linux, OSX.
65
+ // https://wiki.archlinux.org/title/XDG_Base_Directory
66
+ // Each `/dx` directory should contain `/profile/<DX_PROFILE>` subdirectories.
67
+ export const getProfilePath = (root: string, profile: string, file: string | undefined = undefined) =>
68
+ `${root}/profile/${profile}` + (file ? `/${file}` : '');
package/src/echo.ts CHANGED
@@ -3,26 +3,19 @@
3
3
  //
4
4
 
5
5
  import type { MulticastObservable } from '@dxos/async';
6
- import type { QueryFn } from '@dxos/echo-db';
6
+ import type { Database } from '@dxos/echo';
7
7
  import type { PublicKey, SpaceId } from '@dxos/keys';
8
8
  import type { Invitation, SpaceArchive } from '@dxos/protocols/proto/dxos/client/services';
9
9
 
10
10
  import type { AuthenticatingInvitation } from './invitations';
11
- import type { PropertiesTypeProps } from './schema';
12
11
  import type { Space } from './space';
12
+ import type { SpaceProperties } from './types';
13
13
 
14
14
  /**
15
- * TODO(burdon): Public API (move comments here).
15
+ * Public database API.
16
16
  */
17
- // TODO(wittjosiah): Rename?
18
- // https://ts.dev/style/#naming-style
19
- // ClientApi? ClientProtocol?
20
- export interface Echo extends MulticastObservable<Space[]> {
21
- /**
22
- * Resolves when the default space is available.
23
- */
24
- waitUntilReady(): Promise<void>;
25
-
17
+ // TODO(wittjosiah): Rename Database (not product name).
18
+ export interface Echo extends MulticastObservable<Space[]>, Database.Queryable {
26
19
  /**
27
20
  * Observable which indicates when the default space is available.
28
21
  */
@@ -50,10 +43,15 @@ export interface Echo extends MulticastObservable<Space[]> {
50
43
  */
51
44
  get default(): Space;
52
45
 
46
+ /**
47
+ * Resolves when the default space is available.
48
+ */
49
+ waitUntilReady(): Promise<void>;
50
+
53
51
  /**
54
52
  * Creates a new space.
55
53
  */
56
- create(meta?: PropertiesTypeProps): Promise<Space>;
54
+ create(props?: Pick<SpaceProperties, 'name' | 'hue' | 'icon' | 'invocationTraceQueue'>): Promise<Space>;
57
55
 
58
56
  /**
59
57
  * Creates a space from the given archive.
@@ -66,11 +64,4 @@ export interface Echo extends MulticastObservable<Space[]> {
66
64
  join(invitation: Invitation | string): AuthenticatingInvitation;
67
65
 
68
66
  joinBySpaceKey(spaceKey: PublicKey): Promise<Space>;
69
-
70
- /**
71
- * Query all spaces.
72
- * @param filter
73
- * @param options
74
- */
75
- query: QueryFn;
76
67
  }
package/src/halo.ts CHANGED
@@ -6,8 +6,8 @@ import { type MulticastObservable } from '@dxos/async';
6
6
  import { type PublicKey } from '@dxos/keys';
7
7
  import { type Contact, type Device, type Identity, type Invitation } from '@dxos/protocols/proto/dxos/client/services';
8
8
  import {
9
- type DeviceProfileDocument,
10
9
  type Credential,
10
+ type DeviceProfileDocument,
11
11
  type Presentation,
12
12
  type ProfileDocument,
13
13
  } from '@dxos/protocols/proto/dxos/halo/credentials';
package/src/index.ts CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  export * from './client';
6
6
  export * from './config';
7
- export * from './echo';
8
- export * from './halo';
7
+ export type * from './echo';
8
+ export type * from './halo';
9
9
  export * from './invitations';
10
- export * from './service-definitions';
11
- export * from './shell';
10
+ export * from './service';
11
+ export type * from './shell';
12
12
  export * from './space';
13
13
  export * from './timeouts';
14
- export * from './schema';
14
+ export * from './types';
@@ -4,17 +4,17 @@
4
4
 
5
5
  import { type Event } from '@dxos/async';
6
6
  import { schema } from '@dxos/protocols/proto';
7
- import type { FunctionRegistryService } from '@dxos/protocols/proto/dxos/agent/functions';
8
7
  import type {
8
+ ContactsService,
9
9
  DevicesService,
10
+ EdgeAgentService,
10
11
  IdentityService,
11
12
  InvitationsService,
12
13
  LoggingService,
13
14
  NetworkService,
15
+ QueueService,
14
16
  SpacesService,
15
17
  SystemService,
16
- ContactsService,
17
- EdgeAgentService,
18
18
  } from '@dxos/protocols/proto/dxos/client/services';
19
19
  import type { DevtoolsHost } from '@dxos/protocols/proto/dxos/devtools/host';
20
20
  import type { QueryService } from '@dxos/protocols/proto/dxos/echo/query';
@@ -24,6 +24,8 @@ import type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
24
24
  import type { TracingService } from '@dxos/protocols/proto/dxos/tracing';
25
25
  import { type ServiceBundle, createServiceBundle } from '@dxos/rpc';
26
26
 
27
+ export type { QueueService } from '@dxos/protocols/proto/dxos/client/services';
28
+
27
29
  //
28
30
  // NOTE: Should contain client/proxy dependencies only.
29
31
  //
@@ -35,15 +37,16 @@ export type ClientServices = {
35
37
 
36
38
  IdentityService: IdentityService;
37
39
  InvitationsService: InvitationsService;
38
- QueryService: QueryService;
39
40
  DevicesService: DevicesService;
40
41
  SpacesService: SpacesService;
42
+
41
43
  DataService: DataService;
44
+ QueryService: QueryService;
45
+ QueueService: QueueService;
46
+
42
47
  ContactsService: ContactsService;
43
48
  EdgeAgentService: EdgeAgentService;
44
49
 
45
- FunctionRegistryService: FunctionRegistryService;
46
-
47
50
  // TODO(burdon): Deprecated.
48
51
  DevtoolsHost: DevtoolsHost;
49
52
 
@@ -59,12 +62,26 @@ export interface ClientServicesProvider {
59
62
  * This should fire if the services disconnect unexpectedly or during a client reset.
60
63
  */
61
64
  closed: Event<Error | undefined>;
65
+
66
+ /**
67
+ * The underlying service connection was re-established.
68
+ * Fires after all reconnection callbacks have completed.
69
+ */
70
+ reconnected?: Event<void>;
71
+
72
+ /**
73
+ * Register a callback to be invoked when services reconnect.
74
+ * The callback should re-establish any RPC streams.
75
+ * Reconnection waits for all callbacks to complete before emitting `reconnected`.
76
+ */
77
+ onReconnect?: (callback: () => Promise<void>) => void;
78
+
62
79
  descriptors: ServiceBundle<ClientServices>;
63
80
  services: Partial<ClientServices>;
64
81
 
65
82
  // TODO(burdon): Should take context from parent?
66
- open(): Promise<void>;
67
- close(): Promise<void>;
83
+ open(): Promise<unknown>;
84
+ close(): Promise<unknown>;
68
85
  }
69
86
 
70
87
  /**
@@ -83,13 +100,10 @@ export const clientServiceBundle = createServiceBundle<ClientServices>({
83
100
  DataService: schema.getService('dxos.echo.service.DataService'),
84
101
  ContactsService: schema.getService('dxos.client.services.ContactsService'),
85
102
  EdgeAgentService: schema.getService('dxos.client.services.EdgeAgentService'),
86
-
87
- // Agent-only.
88
- FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),
103
+ QueueService: schema.getService('dxos.client.services.QueueService'),
89
104
 
90
105
  // TODO(burdon): Deprecated.
91
106
  DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),
92
-
93
107
  TracingService: schema.getService('dxos.tracing.TracingService'),
94
108
  });
95
109
 
package/src/shell.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  import { type Event } from '@dxos/async';
6
6
  import { type PublicKey } from '@dxos/keys';
7
7
  import {
8
- type InvitationUrlRequest,
9
8
  type AppContextRequest,
9
+ type InvitationUrlRequest,
10
10
  type LayoutRequest,
11
11
  type ShellLayout,
12
12
  } from '@dxos/protocols/proto/dxos/iframe';
package/src/space.ts CHANGED
@@ -2,16 +2,20 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { type MulticastObservable, type CleanupFn } from '@dxos/async';
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { type MulticastObservable } from '@dxos/async';
6
8
  import { type SpecificCredential } from '@dxos/credentials';
7
- import { type QueueFactory, type CoreDatabase, type EchoDatabase, type AnyLiveObject } from '@dxos/echo-db';
9
+ import { type Database, type Obj } from '@dxos/echo';
10
+ import { type EchoDatabase, type QueueFactory, type SpaceSyncState } from '@dxos/echo-db';
8
11
  import { type PublicKey, type SpaceId } from '@dxos/keys';
12
+ import { type Messenger } from '@dxos/protocols';
9
13
  import {
10
14
  type Contact,
11
15
  type CreateEpochRequest,
12
16
  type Invitation,
13
- type Space as SpaceData,
14
17
  type SpaceArchive,
18
+ type Space as SpaceData,
15
19
  type SpaceMember,
16
20
  type SpaceState,
17
21
  type UpdateMemberRoleRequest,
@@ -19,9 +23,9 @@ import {
19
23
  import { type EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
20
24
  import { type SpaceSnapshot } from '@dxos/protocols/proto/dxos/echo/snapshot';
21
25
  import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
22
- import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
23
26
 
24
27
  import { type CancellableInvitation } from './invitations';
28
+ import { type SpaceProperties } from './types';
25
29
 
26
30
  export type CreateEpochOptions = {
27
31
  migration?: CreateEpochRequest.Migration;
@@ -29,17 +33,21 @@ export type CreateEpochOptions = {
29
33
  };
30
34
 
31
35
  export interface SpaceInternal {
36
+ get db(): EchoDatabase;
32
37
  get data(): SpaceData;
33
38
 
34
- // TODO(dmaretskyi): Return epoch info.
35
- createEpoch(options?: CreateEpochOptions): Promise<void>;
36
-
37
39
  getCredentials(): Promise<Credential[]>;
38
40
 
39
41
  getEpochs(): Promise<SpecificCredential<Epoch>[]>;
40
42
 
43
+ // TODO(dmaretskyi): Return epoch info.
44
+ createEpoch(options?: CreateEpochOptions): Promise<void>;
45
+
46
+ // TOOD(burdon): Start to factor out credentials.
41
47
  removeMember(memberKey: PublicKey): Promise<void>;
42
48
 
49
+ export(): Promise<SpaceArchive>;
50
+
43
51
  /**
44
52
  * Migrate space data to the latest version.
45
53
  */
@@ -47,15 +55,20 @@ export interface SpaceInternal {
47
55
 
48
56
  setEdgeReplicationPreference(setting: EdgeReplicationSetting): Promise<void>;
49
57
 
50
- export(): Promise<SpaceArchive>;
51
- }
52
-
53
- // TODO(burdon): Separate public API form implementation (move comments here).
54
- export interface Space {
55
58
  /**
56
- * Unique space identifier.
59
+ * Waits until the space is fully synced with EDGE.
60
+ * @throws If the EDGE sync is disabled.
57
61
  */
58
- get id(): SpaceId;
62
+ syncToEdge(opts?: {
63
+ onProgress: (state: SpaceSyncState.PeerState | undefined) => void;
64
+ timeout?: number;
65
+ }): Promise<void>;
66
+ }
67
+
68
+ export const SPACE_TAG = Symbol('dxos.client.protocol.Space');
69
+
70
+ export interface Space extends Messenger {
71
+ readonly [SPACE_TAG]: true;
59
72
 
60
73
  /**
61
74
  * @deprecated Use `id`.
@@ -63,29 +76,23 @@ export interface Space {
63
76
  get key(): PublicKey;
64
77
 
65
78
  /**
66
- * Echo database.
79
+ * Unique space identifier.
67
80
  */
68
- get db(): EchoDatabase;
81
+ get id(): SpaceId;
69
82
 
70
83
  /**
71
- * Access to queues.
84
+ * Echo database.
72
85
  */
73
- get queues(): QueueFactory;
86
+ get db(): Database.Database;
74
87
 
75
88
  /**
76
- * Echo database CRUD API.
77
- * @deprecated Use the database api with the `plain` format.
89
+ * Access to queues.
78
90
  */
79
- // TODO(burdon): Remove.
80
- get crud(): CoreDatabase;
91
+ get queues(): QueueFactory;
81
92
 
93
+ // TODO(burdon): Replace with state?
82
94
  get isOpen(): boolean;
83
95
 
84
- /**
85
- * Properties object.
86
- */
87
- get properties(): AnyLiveObject<any>;
88
-
89
96
  /**
90
97
  * Current state of the space.
91
98
  * The database is ready to be used in `SpaceState.SPACE_READY` state.
@@ -93,6 +100,11 @@ export interface Space {
93
100
  */
94
101
  get state(): MulticastObservable<SpaceState>;
95
102
 
103
+ /**
104
+ * Properties object.
105
+ */
106
+ get properties(): Obj.Obj<SpaceProperties>;
107
+
96
108
  /**
97
109
  * Current state of space pipeline.
98
110
  */
@@ -105,14 +117,14 @@ export interface Space {
105
117
  /**
106
118
  * @deprecated
107
119
  */
108
- // TODO(wittjosiah): Remove. This should not be exposed.
120
+ // TODO(wittjosiah): Audit and remove. This should not be exposed (or marked as internal).
109
121
  get internal(): SpaceInternal;
110
122
 
111
- // TODO(wittjosiah): Rename activate/deactivate?
112
123
  /**
113
124
  * Activates the space enabling the use of the database and starts replication with peers.
114
125
  * The setting is persisted on the local device.
115
126
  */
127
+ // TODO(wittjosiah): Rename activate/deactivate?
116
128
  open(): Promise<void>;
117
129
 
118
130
  /**
@@ -130,13 +142,17 @@ export interface Space {
130
142
  createSnapshot(): Promise<SpaceSnapshot>;
131
143
 
132
144
  // TODO(burdon): Create invitation?
145
+ // TODO(burdon): Factor out membership, etc.
133
146
  share(options?: Partial<Invitation>): CancellableInvitation;
134
-
135
147
  admitContact(contact: Contact): Promise<void>;
136
-
137
148
  updateMemberRole(request: Omit<UpdateMemberRoleRequest, 'spaceKey'>): Promise<void>;
138
-
139
- // TODO(wittjosiah): Gather into messaging abstraction?
140
- postMessage: (channel: string, message: any) => Promise<void>;
141
- listen: (channel: string, callback: (message: GossipMessage) => void) => CleanupFn;
142
149
  }
150
+
151
+ export const isSpace = (object: unknown): object is Space =>
152
+ typeof object === 'object' && object != null && (object as Space)[SPACE_TAG] === true;
153
+
154
+ // TODO(burdon): Create lower-level definition (HasId, db, etc.) and move to @dxos/echo.
155
+ export const SpaceSchema: Schema.Schema<Space> = Schema.Any.pipe(
156
+ Schema.filter((space) => isSpace(space)),
157
+ Schema.annotations({ title: 'Space' }),
158
+ );
package/src/timeouts.ts CHANGED
@@ -33,6 +33,11 @@ export const LOAD_PROPERTIES_TIMEOUT = 3_000;
33
33
  */
34
34
  export const CREATE_SPACE_TIMEOUT = 5_000;
35
35
 
36
+ /**
37
+ * Timeout for creating new spaces.
38
+ */
39
+ export const IMPORT_SPACE_TIMEOUT = 30_000;
40
+
36
41
  /**
37
42
  * Timeout for loading of control feeds.
38
43
  */
@@ -0,0 +1,49 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { Annotation, Type } from '@dxos/echo';
8
+ import { Queue } from '@dxos/echo-db';
9
+
10
+ export const SpacePropertiesSchema = Schema.Struct(
11
+ {
12
+ //
13
+ // System properties.
14
+ //
15
+
16
+ archived: Schema.optional(Schema.Boolean.annotations({ title: 'Archive Space' })),
17
+ // TODO(burdon): Change to mode (no booleans?)
18
+ // TODO(wittjosiah): Make optional with default value.
19
+ edgeReplication: Schema.optional(Schema.Boolean),
20
+ invocationTraceQueue: Schema.optional(Type.Ref(Queue)),
21
+
22
+ //
23
+ // User properties.
24
+ //
25
+
26
+ name: Schema.optional(Schema.String),
27
+ icon: Schema.optional(Schema.String),
28
+ hue: Schema.optional(Schema.String),
29
+ },
30
+ {
31
+ key: Schema.String,
32
+ value: Schema.Any,
33
+ },
34
+ );
35
+
36
+ export type SpacePropertiesSchema = Schema.Schema.Type<typeof SpacePropertiesSchema>;
37
+
38
+ // TODO(burdon): Pipe Schem.optional, or partial to entire struct to make everything optional?
39
+ // TODO(burdon): Is separate schema def required for forms? Can it be extracted from SpaceProperties?
40
+ export const SpaceProperties = SpacePropertiesSchema.pipe(
41
+ Type.object({
42
+ // TODO(burdon): Rename SpaceProperties.
43
+ typename: 'dxos.org/type/Properties',
44
+ version: '0.1.0',
45
+ }),
46
+ Annotation.SystemTypeAnnotation.set(true),
47
+ );
48
+
49
+ export interface SpaceProperties extends Schema.Schema.Type<typeof SpaceProperties> {}
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './SpaceProperties';