@dxos/client-protocol 0.8.4-main.dedc0f3 → 0.8.4-main.e00bdcdb52

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 (47) hide show
  1. package/dist/lib/browser/chunk-GCBXMPTW.mjs +51 -0
  2. package/dist/lib/browser/chunk-GCBXMPTW.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +59 -68
  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 +13 -0
  7. package/dist/lib/browser/types/index.mjs.map +7 -0
  8. package/dist/lib/node-esm/chunk-2RN4CLEW.mjs +53 -0
  9. package/dist/lib/node-esm/chunk-2RN4CLEW.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +58 -68
  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 +14 -0
  14. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  15. package/dist/types/src/config.d.ts +24 -8
  16. package/dist/types/src/config.d.ts.map +1 -1
  17. package/dist/types/src/echo.d.ts +9 -23
  18. package/dist/types/src/echo.d.ts.map +1 -1
  19. package/dist/types/src/index.d.ts +3 -3
  20. package/dist/types/src/index.d.ts.map +1 -1
  21. package/dist/types/src/invitations/encoder.d.ts.map +1 -1
  22. package/dist/types/src/invitations/invitations.d.ts +2 -2
  23. package/dist/types/src/invitations/invitations.d.ts.map +1 -1
  24. package/dist/types/src/{service-definitions.d.ts → service.d.ts} +18 -9
  25. package/dist/types/src/service.d.ts.map +1 -0
  26. package/dist/types/src/space.d.ts +47 -16
  27. package/dist/types/src/space.d.ts.map +1 -1
  28. package/dist/types/src/timeouts.d.ts +4 -0
  29. package/dist/types/src/timeouts.d.ts.map +1 -1
  30. package/dist/types/src/types/SpaceProperties.d.ts +67 -0
  31. package/dist/types/src/types/SpaceProperties.d.ts.map +1 -0
  32. package/dist/types/src/types/index.d.ts +2 -0
  33. package/dist/types/src/types/index.d.ts.map +1 -0
  34. package/dist/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +25 -21
  36. package/src/config.ts +33 -14
  37. package/src/echo.ts +10 -31
  38. package/src/index.ts +3 -3
  39. package/src/{service-definitions.ts → service.ts} +24 -14
  40. package/src/space.ts +69 -26
  41. package/src/timeouts.ts +5 -0
  42. package/src/types/SpaceProperties.ts +76 -0
  43. package/src/types/index.ts +5 -0
  44. package/dist/types/src/schema.d.ts +0 -22
  45. package/dist/types/src/schema.d.ts.map +0 -1
  46. package/dist/types/src/service-definitions.d.ts.map +0 -1
  47. package/src/schema.ts +0 -29
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/client-protocol",
3
- "version": "0.8.4-main.dedc0f3",
3
+ "version": "0.8.4-main.e00bdcdb52",
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
  ".": {
@@ -15,34 +18,35 @@
15
18
  "types": "./dist/types/src/index.d.ts",
16
19
  "browser": "./dist/lib/browser/index.mjs",
17
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"
18
27
  }
19
28
  },
20
29
  "types": "dist/types/src/index.d.ts",
21
- "typesVersions": {
22
- "*": {}
23
- },
24
30
  "files": [
25
31
  "dist",
26
32
  "src"
27
33
  ],
28
34
  "dependencies": {
29
- "base-x": "~3.0.9",
30
- "effect": "3.17.7",
31
- "@dxos/async": "0.8.4-main.dedc0f3",
32
- "@dxos/config": "0.8.4-main.dedc0f3",
33
- "@dxos/context": "0.8.4-main.dedc0f3",
34
- "@dxos/credentials": "0.8.4-main.dedc0f3",
35
- "@dxos/echo": "0.8.4-main.dedc0f3",
36
- "@dxos/echo-db": "0.8.4-main.dedc0f3",
37
- "@dxos/echo-schema": "0.8.4-main.dedc0f3",
38
- "@dxos/invariant": "0.8.4-main.dedc0f3",
39
- "@dxos/keys": "0.8.4-main.dedc0f3",
40
- "@dxos/node-std": "0.8.4-main.dedc0f3",
41
- "@dxos/protocols": "0.8.4-main.dedc0f3",
42
- "@dxos/rpc": "0.8.4-main.dedc0f3"
35
+ "base-x": "~3.0.11",
36
+ "effect": "3.20.0",
37
+ "@dxos/async": "0.8.4-main.e00bdcdb52",
38
+ "@dxos/context": "0.8.4-main.e00bdcdb52",
39
+ "@dxos/echo": "0.8.4-main.e00bdcdb52",
40
+ "@dxos/invariant": "0.8.4-main.e00bdcdb52",
41
+ "@dxos/echo-db": "0.8.4-main.e00bdcdb52",
42
+ "@dxos/node-std": "0.8.4-main.e00bdcdb52",
43
+ "@dxos/protocols": "0.8.4-main.e00bdcdb52",
44
+ "@dxos/rpc": "0.8.4-main.e00bdcdb52",
45
+ "@dxos/credentials": "0.8.4-main.e00bdcdb52",
46
+ "@dxos/keys": "0.8.4-main.e00bdcdb52"
43
47
  },
44
48
  "peerDependencies": {
45
- "effect": "^3.13.3"
49
+ "effect": "3.20.0"
46
50
  },
47
51
  "publishConfig": {
48
52
  "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,19 +14,18 @@ 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
27
  const HOME = typeof process !== 'undefined' ? (process?.env?.HOME ?? '') : '';
22
28
 
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}` : '');
29
-
30
29
  // XDG_CONFIG_HOME (Analogous to /etc.)
31
30
  export const DX_CONFIG = `${HOME}/.config/dx`;
32
31
 
@@ -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
+ // Profile layout: profile/<name> is the profile dir; profile/<name>.yml is the config file.
64
+ export const getProfilePath = (root: string, profile: string, file?: string) =>
65
+ `${root}/profile/${profile}` + (file ? `/${file}` : '');
66
+
67
+ /** Path to the profile config file (profile/<name>.yml). */
68
+ export const getProfileConfigPath = (root: string, profile: string) => `${getProfilePath(root, profile)}.yml`;
package/src/echo.ts CHANGED
@@ -3,32 +3,20 @@
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
+ import type { MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';
9
10
 
10
11
  import type { AuthenticatingInvitation } from './invitations';
11
- import type { PropertiesTypeProps } from './schema';
12
12
  import type { Space } from './space';
13
+ import type { SpaceProperties } from './types';
13
14
 
14
15
  /**
15
- * TODO(burdon): Public API (move comments here).
16
+ * Public database API.
16
17
  */
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
-
26
- /**
27
- * Observable which indicates when the default space is available.
28
- */
29
- // TODO(wittjosiah): Remove. Ensure default space is always available.
30
- get isReady(): MulticastObservable<boolean>;
31
-
18
+ // TODO(wittjosiah): Rename Database (not product name).
19
+ export interface Echo extends MulticastObservable<Space[]>, Database.Queryable {
32
20
  /**
33
21
  * Returns the list of spaces.
34
22
  */
@@ -45,15 +33,13 @@ export interface Echo extends MulticastObservable<Space[]> {
45
33
  */
46
34
  get(spaceKey: PublicKey): Space | undefined;
47
35
 
48
- /**
49
- * Returns the default space.
50
- */
51
- get default(): Space;
52
-
53
36
  /**
54
37
  * Creates a new space.
55
38
  */
56
- create(meta?: PropertiesTypeProps): Promise<Space>;
39
+ create(
40
+ props?: Pick<SpaceProperties, 'name' | 'hue' | 'icon' | 'invocationTraceFeed'>,
41
+ options?: { tags?: string[]; membershipPolicy?: MembershipPolicy },
42
+ ): Promise<Space>;
57
43
 
58
44
  /**
59
45
  * Creates a space from the given archive.
@@ -66,11 +52,4 @@ export interface Echo extends MulticastObservable<Space[]> {
66
52
  join(invitation: Invitation | string): AuthenticatingInvitation;
67
53
 
68
54
  joinBySpaceKey(spaceKey: PublicKey): Promise<Space>;
69
-
70
- /**
71
- * Query all spaces.
72
- * @param filter
73
- * @param options
74
- */
75
- query: QueryFn;
76
55
  }
package/src/index.ts CHANGED
@@ -7,8 +7,8 @@ export * from './config';
7
7
  export type * from './echo';
8
8
  export type * from './halo';
9
9
  export * from './invitations';
10
- export * from './service-definitions';
10
+ export * from './service';
11
11
  export type * from './shell';
12
- export type * from './space';
12
+ export * from './space';
13
13
  export * from './timeouts';
14
- export * from './schema';
14
+ export * from './types';
@@ -4,7 +4,6 @@
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 {
9
8
  ContactsService,
10
9
  DevicesService,
@@ -13,6 +12,7 @@ import type {
13
12
  InvitationsService,
14
13
  LoggingService,
15
14
  NetworkService,
15
+ QueueService,
16
16
  SpacesService,
17
17
  SystemService,
18
18
  } from '@dxos/protocols/proto/dxos/client/services';
@@ -21,9 +21,10 @@ import type { QueryService } from '@dxos/protocols/proto/dxos/echo/query';
21
21
  import type { DataService } from '@dxos/protocols/proto/dxos/echo/service';
22
22
  import type { AppService, ShellService, WorkerService } from '@dxos/protocols/proto/dxos/iframe';
23
23
  import type { BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
24
- import type { TracingService } from '@dxos/protocols/proto/dxos/tracing';
25
24
  import { type ServiceBundle, createServiceBundle } from '@dxos/rpc';
26
25
 
26
+ export type { QueueService } from '@dxos/protocols/proto/dxos/client/services';
27
+
27
28
  //
28
29
  // NOTE: Should contain client/proxy dependencies only.
29
30
  //
@@ -35,19 +36,18 @@ export type ClientServices = {
35
36
 
36
37
  IdentityService: IdentityService;
37
38
  InvitationsService: InvitationsService;
38
- QueryService: QueryService;
39
39
  DevicesService: DevicesService;
40
40
  SpacesService: SpacesService;
41
+
41
42
  DataService: DataService;
43
+ QueryService: QueryService;
44
+ QueueService: QueueService;
45
+
42
46
  ContactsService: ContactsService;
43
47
  EdgeAgentService: EdgeAgentService;
44
48
 
45
- FunctionRegistryService: FunctionRegistryService;
46
-
47
49
  // TODO(burdon): Deprecated.
48
50
  DevtoolsHost: DevtoolsHost;
49
-
50
- TracingService: TracingService;
51
51
  };
52
52
 
53
53
  /**
@@ -59,12 +59,26 @@ export interface ClientServicesProvider {
59
59
  * This should fire if the services disconnect unexpectedly or during a client reset.
60
60
  */
61
61
  closed: Event<Error | undefined>;
62
+
63
+ /**
64
+ * The underlying service connection was re-established.
65
+ * Fires after all reconnection callbacks have completed.
66
+ */
67
+ reconnected?: Event<void>;
68
+
69
+ /**
70
+ * Register a callback to be invoked when services reconnect.
71
+ * The callback should re-establish any RPC streams.
72
+ * Reconnection waits for all callbacks to complete before emitting `reconnected`.
73
+ */
74
+ onReconnect?: (callback: () => Promise<void>) => void;
75
+
62
76
  descriptors: ServiceBundle<ClientServices>;
63
77
  services: Partial<ClientServices>;
64
78
 
65
79
  // TODO(burdon): Should take context from parent?
66
- open(): Promise<void>;
67
- close(): Promise<void>;
80
+ open(): Promise<unknown>;
81
+ close(): Promise<unknown>;
68
82
  }
69
83
 
70
84
  /**
@@ -83,14 +97,10 @@ export const clientServiceBundle = createServiceBundle<ClientServices>({
83
97
  DataService: schema.getService('dxos.echo.service.DataService'),
84
98
  ContactsService: schema.getService('dxos.client.services.ContactsService'),
85
99
  EdgeAgentService: schema.getService('dxos.client.services.EdgeAgentService'),
86
-
87
- // Agent-only.
88
- FunctionRegistryService: schema.getService('dxos.agent.functions.FunctionRegistryService'),
100
+ QueueService: schema.getService('dxos.client.services.QueueService'),
89
101
 
90
102
  // TODO(burdon): Deprecated.
91
103
  DevtoolsHost: schema.getService('dxos.devtools.host.DevtoolsHost'),
92
-
93
- TracingService: schema.getService('dxos.tracing.TracingService'),
94
104
  });
95
105
 
96
106
  export type IframeServiceBundle = {
package/src/space.ts CHANGED
@@ -2,15 +2,19 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { type CleanupFn, type MulticastObservable } 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 AnyLiveObject, type EchoDatabase, type QueueFactory } 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 SpaceArchive,
17
+ SpaceArchive,
14
18
  type Space as SpaceData,
15
19
  type SpaceMember,
16
20
  type SpaceState,
@@ -18,28 +22,40 @@ import {
18
22
  } from '@dxos/protocols/proto/dxos/client/services';
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
- import { type Credential, type Epoch } from '@dxos/protocols/proto/dxos/halo/credentials';
22
- import { type GossipMessage } from '@dxos/protocols/proto/dxos/mesh/teleport/gossip';
25
+ import { type Credential, type Epoch, type MembershipPolicy } from '@dxos/protocols/proto/dxos/halo/credentials';
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;
28
32
  automergeRootUrl?: string;
29
33
  };
30
34
 
35
+ export type ExportSpaceOptions = {
36
+ /**
37
+ * Archive format.
38
+ * @default SpaceArchive.Format.BINARY
39
+ */
40
+ format?: SpaceArchive.Format;
41
+ };
42
+
31
43
  export interface SpaceInternal {
44
+ get db(): EchoDatabase;
32
45
  get data(): SpaceData;
33
46
 
34
- // TODO(dmaretskyi): Return epoch info.
35
- createEpoch(options?: CreateEpochOptions): Promise<void>;
36
-
37
47
  getCredentials(): Promise<Credential[]>;
38
48
 
39
49
  getEpochs(): Promise<SpecificCredential<Epoch>[]>;
40
50
 
51
+ // TODO(dmaretskyi): Return epoch info.
52
+ createEpoch(options?: CreateEpochOptions): Promise<void>;
53
+
54
+ // TOOD(burdon): Start to factor out credentials.
41
55
  removeMember(memberKey: PublicKey): Promise<void>;
42
56
 
57
+ export(options?: ExportSpaceOptions): Promise<SpaceArchive>;
58
+
43
59
  /**
44
60
  * Migrate space data to the latest version.
45
61
  */
@@ -47,37 +63,55 @@ export interface SpaceInternal {
47
63
 
48
64
  setEdgeReplicationPreference(setting: EdgeReplicationSetting): Promise<void>;
49
65
 
50
- export(): Promise<SpaceArchive>;
51
- }
52
-
53
- // TODO(burdon): Separate public API form implementation (move comments here).
54
- export interface Space {
55
66
  /**
56
- * Unique space identifier.
67
+ * Waits until the space is fully synced with EDGE.
68
+ * @throws If the EDGE sync is disabled.
57
69
  */
58
- get id(): SpaceId;
70
+ syncToEdge(opts?: {
71
+ onProgress: (state: SpaceSyncState.PeerState | undefined) => void;
72
+ timeout?: number;
73
+ }): Promise<void>;
74
+ }
75
+
76
+ export const SPACE_TAG = Symbol('dxos.client.protocol.Space');
77
+
78
+ export interface Space extends Messenger {
79
+ readonly [SPACE_TAG]: true;
59
80
 
60
81
  /**
61
82
  * @deprecated Use `id`.
62
83
  */
63
84
  get key(): PublicKey;
64
85
 
86
+ /**
87
+ * Unique space identifier.
88
+ */
89
+ get id(): SpaceId;
90
+
65
91
  /**
66
92
  * Echo database.
67
93
  */
68
- get db(): EchoDatabase;
94
+ get db(): Database.Database;
69
95
 
70
96
  /**
71
97
  * Access to queues.
72
98
  */
73
99
  get queues(): QueueFactory;
74
100
 
101
+ // TODO(burdon): Replace with state?
75
102
  get isOpen(): boolean;
76
103
 
77
104
  /**
78
- * Properties object.
105
+ * Immutable tags assigned at space creation time.
106
+ * Available on closed spaces.
79
107
  */
80
- get properties(): AnyLiveObject<any>;
108
+ get tags(): string[];
109
+
110
+ /**
111
+ * Immutable membership policy assigned at space creation time.
112
+ * Available on closed spaces.
113
+ */
114
+ get membershipPolicy(): MembershipPolicy;
81
115
 
82
116
  /**
83
117
  * Current state of the space.
@@ -86,6 +120,11 @@ export interface Space {
86
120
  */
87
121
  get state(): MulticastObservable<SpaceState>;
88
122
 
123
+ /**
124
+ * Properties object.
125
+ */
126
+ get properties(): Obj.OfShape<SpaceProperties>;
127
+
89
128
  /**
90
129
  * Current state of space pipeline.
91
130
  */
@@ -98,14 +137,14 @@ export interface Space {
98
137
  /**
99
138
  * @deprecated
100
139
  */
101
- // TODO(wittjosiah): Remove. This should not be exposed.
140
+ // TODO(wittjosiah): Audit and remove. This should not be exposed (or marked as internal).
102
141
  get internal(): SpaceInternal;
103
142
 
104
- // TODO(wittjosiah): Rename activate/deactivate?
105
143
  /**
106
144
  * Activates the space enabling the use of the database and starts replication with peers.
107
145
  * The setting is persisted on the local device.
108
146
  */
147
+ // TODO(wittjosiah): Rename activate/deactivate?
109
148
  open(): Promise<void>;
110
149
 
111
150
  /**
@@ -123,13 +162,17 @@ export interface Space {
123
162
  createSnapshot(): Promise<SpaceSnapshot>;
124
163
 
125
164
  // TODO(burdon): Create invitation?
165
+ // TODO(burdon): Factor out membership, etc.
126
166
  share(options?: Partial<Invitation>): CancellableInvitation;
127
-
128
167
  admitContact(contact: Contact): Promise<void>;
129
-
130
168
  updateMemberRole(request: Omit<UpdateMemberRoleRequest, 'spaceKey'>): Promise<void>;
131
-
132
- // TODO(wittjosiah): Gather into messaging abstraction?
133
- postMessage: (channel: string, message: any) => Promise<void>;
134
- listen: (channel: string, callback: (message: GossipMessage) => void) => CleanupFn;
135
169
  }
170
+
171
+ export const isSpace = (object: unknown): object is Space =>
172
+ typeof object === 'object' && object != null && (object as Space)[SPACE_TAG] === true;
173
+
174
+ // TODO(burdon): Create lower-level definition (HasId, db, etc.) and move to @dxos/echo.
175
+ export const SpaceSchema: Schema.Schema<Space> = Schema.Any.pipe(
176
+ Schema.filter((space) => isSpace(space)),
177
+ Schema.annotations({ title: 'Space' }),
178
+ );
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,76 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { Annotation, Feed, Ref, Type } from '@dxos/echo';
8
+
9
+ /**
10
+ * Where do triggers get executed.
11
+ */
12
+ export const ComputeEnvironment = Schema.Literal('disabled', 'local', 'edge');
13
+ export type ComputeEnvironment = Schema.Schema.Type<typeof ComputeEnvironment>;
14
+
15
+ export const SpacePropertiesSchema = Schema.Struct(
16
+ {
17
+ //
18
+ // System properties.
19
+ //
20
+
21
+ archived: Schema.optional(Schema.Boolean.annotations({ title: 'Archive Space' })),
22
+ // TODO(burdon): Change to mode (no booleans?)
23
+ // TODO(wittjosiah): Make optional with default value.
24
+ edgeReplication: Schema.optional(Schema.Boolean),
25
+
26
+ /**
27
+ * @deprecated
28
+ */
29
+ invocationTraceFeed: Schema.optional(Ref.Ref(Feed.Feed)),
30
+
31
+ /**
32
+ * Preference for trigger execution.
33
+ * *disabled* - triggers do not run locally or on EDGE.
34
+ * *local* - triggers are executed locally on the client, edge is not running triggers.
35
+ * *edge* - triggers are executed on the edge, triggers are not run locally.
36
+ */
37
+ computeEnvironment: Schema.optional(ComputeEnvironment),
38
+
39
+ //
40
+ // User properties.
41
+ //
42
+
43
+ name: Schema.optional(Schema.String),
44
+ icon: Schema.optional(Schema.String),
45
+ hue: Schema.optional(Schema.String),
46
+ },
47
+ {
48
+ key: Schema.String,
49
+ value: Schema.Any,
50
+ },
51
+ );
52
+
53
+ export type SpacePropertiesSchema = Schema.Schema.Type<typeof SpacePropertiesSchema>;
54
+
55
+ /** @deprecated Use SpaceProperties instead. */
56
+ export const LegacySpaceProperties = SpacePropertiesSchema.pipe(
57
+ Type.object({
58
+ typename: 'org.dxos.type.space-properties',
59
+ version: '0.1.0',
60
+ }),
61
+ Annotation.SystemTypeAnnotation.set(true),
62
+ );
63
+
64
+ export interface LegacySpaceProperties extends Schema.Schema.Type<typeof LegacySpaceProperties> {}
65
+
66
+ // TODO(burdon): Pipe Schem.optional, or partial to entire struct to make everything optional?
67
+ // TODO(burdon): Is separate schema def required for forms? Can it be extracted from SpaceProperties?
68
+ export const SpaceProperties = SpacePropertiesSchema.pipe(
69
+ Type.object({
70
+ typename: 'org.dxos.type.spaceProperties',
71
+ version: '0.1.0',
72
+ }),
73
+ Annotation.SystemTypeAnnotation.set(true),
74
+ );
75
+
76
+ 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';
@@ -1,22 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { Type } from '@dxos/echo';
3
- import { Queue } from '@dxos/echo-db';
4
- export declare const TYPE_PROPERTIES = "dxos.org/type/Properties";
5
- declare const PropertiesType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<{
6
- name: Schema.optional<typeof Schema.String>;
7
- hue: Schema.optional<typeof Schema.String>;
8
- icon: Schema.optional<typeof Schema.String>;
9
- invocationTraceQueue: Schema.optional<Type.ref<Schema.Schema<Queue<import("@dxos/echo/Obj").Any | import("@dxos/echo/Relation").Any>, Queue<import("@dxos/echo/Obj").Any | import("@dxos/echo/Relation").Any>, never>>>;
10
- }, {
11
- record: true;
12
- }>, Schema.Struct.Encoded<{
13
- name: Schema.optional<typeof Schema.String>;
14
- hue: Schema.optional<typeof Schema.String>;
15
- icon: Schema.optional<typeof Schema.String>;
16
- invocationTraceQueue: Schema.optional<Type.ref<Schema.Schema<Queue<import("@dxos/echo/Obj").Any | import("@dxos/echo/Relation").Any>, Queue<import("@dxos/echo/Obj").Any | import("@dxos/echo/Relation").Any>, never>>>;
17
- }>>;
18
- export declare class PropertiesType extends PropertiesType_base {
19
- }
20
- export type PropertiesTypeProps = Pick<PropertiesType, 'name' | 'hue' | 'icon' | 'invocationTraceQueue'>;
21
- export {};
22
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,eAAO,MAAM,eAAe,6BAA6B,CAAC;;;;;;;;;;;;;;AAG1D,qBAAa,cAAe,SAAQ,mBAYnC;CAAG;AAGJ,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,sBAAsB,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-definitions.d.ts","sourceRoot":"","sources":["../../../src/service-definitions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACjG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,WAAW,CAAC;AAMpE,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,cAAc,CAAC;IAE/B,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,uBAAuB,EAAE,uBAAuB,CAAC;IAGjD,YAAY,EAAE,YAAY,CAAC;IAE3B,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACjC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAGlC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,+BAqB9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,mBAAmB,CAElE,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,mBAAmB,CAElE,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,gBAAgB,CAE5D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,CAEhE,CAAC"}
package/src/schema.ts DELETED
@@ -1,29 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { Type } from '@dxos/echo';
8
- import { Queue } from '@dxos/echo-db';
9
- import { TypedObject } from '@dxos/echo-schema';
10
-
11
- export const TYPE_PROPERTIES = 'dxos.org/type/Properties';
12
-
13
- // TODO(burdon): Factor out (co-locate with TYPE_PROPERTIES).
14
- export class PropertiesType extends TypedObject({
15
- typename: TYPE_PROPERTIES,
16
- version: '0.1.0',
17
- })(
18
- {
19
- name: Schema.optional(Schema.String),
20
- // TODO(wittjosiah): Make generic?
21
- hue: Schema.optional(Schema.String),
22
- icon: Schema.optional(Schema.String),
23
- invocationTraceQueue: Schema.optional(Type.Ref(Queue)),
24
- },
25
- { record: true },
26
- ) {}
27
-
28
- // TODO(burdon): Remove? Use PropertiesType instead?
29
- export type PropertiesTypeProps = Pick<PropertiesType, 'name' | 'hue' | 'icon' | 'invocationTraceQueue'>;