@dxos/cli-util 0.8.4-main.9735255 → 0.8.4-main.bcb3aa67d6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/cli-util",
3
- "version": "0.8.4-main.9735255",
3
+ "version": "0.8.4-main.bcb3aa67d6",
4
4
  "description": "Shared CLI utilities for DXOS CLI commands and plugins",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -30,26 +30,27 @@
30
30
  "src"
31
31
  ],
32
32
  "dependencies": {
33
- "@effect/cli": "0.72.1",
33
+ "@effect/cli": "0.73.2",
34
34
  "@effect/printer": "0.47.0",
35
35
  "@effect/printer-ansi": "0.47.0",
36
- "@dxos/client": "0.8.4-main.9735255",
37
- "@dxos/echo": "0.8.4-main.9735255",
38
- "@dxos/debug": "0.8.4-main.9735255",
39
- "@dxos/errors": "0.8.4-main.9735255",
40
- "@dxos/functions": "0.8.4-main.9735255",
41
- "@dxos/effect": "0.8.4-main.9735255",
42
- "@dxos/log": "0.8.4-main.9735255",
43
- "@dxos/protocols": "0.8.4-main.9735255",
44
- "@dxos/util": "0.8.4-main.9735255"
36
+ "@dxos/app-toolkit": "0.8.4-main.bcb3aa67d6",
37
+ "@dxos/debug": "0.8.4-main.bcb3aa67d6",
38
+ "@dxos/client": "0.8.4-main.bcb3aa67d6",
39
+ "@dxos/echo": "0.8.4-main.bcb3aa67d6",
40
+ "@dxos/effect": "0.8.4-main.bcb3aa67d6",
41
+ "@dxos/errors": "0.8.4-main.bcb3aa67d6",
42
+ "@dxos/functions": "0.8.4-main.bcb3aa67d6",
43
+ "@dxos/log": "0.8.4-main.bcb3aa67d6",
44
+ "@dxos/protocols": "0.8.4-main.bcb3aa67d6",
45
+ "@dxos/util": "0.8.4-main.bcb3aa67d6"
45
46
  },
46
47
  "devDependencies": {
47
- "effect": "3.19.11",
48
+ "effect": "3.20.0",
48
49
  "typescript": "^5.9.3",
49
50
  "vitest": "3.2.4"
50
51
  },
51
52
  "peerDependencies": {
52
- "effect": "3.19.11"
53
+ "effect": "3.20.0"
53
54
  },
54
55
  "publishConfig": {
55
56
  "access": "public"
@@ -8,7 +8,7 @@ import { ClientService } from '@dxos/client';
8
8
  import { type Type } from '@dxos/echo';
9
9
 
10
10
  /** @deprecated Migrate to providing types via plugin capabilities. */
11
- export const withTypes: (...types: Type.Entity.Any[]) => Effect.Effect<void, never, ClientService> = (...types) =>
11
+ export const withTypes: (...types: Type.AnyEntity[]) => Effect.Effect<void, never, ClientService> = (...types) =>
12
12
  Effect.gen(function* () {
13
13
  const client = yield* ClientService;
14
14
  yield* Effect.promise(() => client.addTypes(types));
package/src/util/space.ts CHANGED
@@ -8,6 +8,7 @@ import * as Layer from 'effect/Layer';
8
8
  import * as Match from 'effect/Match';
9
9
  import * as Option from 'effect/Option';
10
10
 
11
+ import { getPersonalSpace } from '@dxos/app-toolkit';
11
12
  import { ClientService } from '@dxos/client';
12
13
  import { type Space } from '@dxos/client/echo';
13
14
  import { Database, type Key } from '@dxos/echo';
@@ -26,26 +27,25 @@ export const getSpace = (spaceId: Key.SpaceId): Effect.Effect<Space, SpaceNotFou
26
27
  export const spaceIdWithDefault = (spaceId: Option.Option<Key.SpaceId>) =>
27
28
  Effect.gen(function* () {
28
29
  const client = yield* ClientService;
29
- yield* Effect.promise(() => client.spaces.waitUntilReady());
30
- return Option.getOrElse(spaceId, () => client.spaces.default.id);
30
+ return Option.getOrElse(spaceId, () => {
31
+ const personal = getPersonalSpace(client);
32
+ if (!personal) {
33
+ throw new Error('No space ID provided and no personal space found.');
34
+ }
35
+ return personal.id;
36
+ });
31
37
  });
32
38
 
33
39
  // TODO(wittjosiah): Factor out.
34
40
  export const spaceLayer = (
35
41
  spaceId$: Option.Option<Key.SpaceId>,
36
- fallbackToDefaultSpace = false,
42
+ fallbackToPersonalSpace = false,
37
43
  ): Layer.Layer<Database.Service | QueueService, never, ClientService> => {
38
44
  const getSpace = Effect.fn(function* () {
39
45
  const client = yield* ClientService;
40
- yield* Effect.promise(() => client.spaces.waitUntilReady());
41
-
42
- const spaceId = Match.value(fallbackToDefaultSpace).pipe(
43
- Match.when(true, () =>
44
- spaceId$.pipe(
45
- Option.getOrElse(() => client.spaces.default.id),
46
- Option.some,
47
- ),
48
- ),
46
+
47
+ const spaceId = Match.value(fallbackToPersonalSpace).pipe(
48
+ Match.when(true, () => spaceId$.pipe(Option.orElse(() => Option.fromNullable(getPersonalSpace(client)?.id)))),
49
49
  Match.when(false, () => spaceId$),
50
50
  Match.exhaustive,
51
51
  );
@@ -75,7 +75,7 @@ export const spaceLayer = (
75
75
  }
76
76
  return { db: space.db };
77
77
  }),
78
- ({ db }) => Effect.promise(() => db.flush({ indexes: true })),
78
+ ({ db }) => Effect.promise(() => db.flush()),
79
79
  ),
80
80
  );
81
81
 
@@ -129,8 +129,8 @@ export const waitForSync = Effect.fn(function* (space: Space) {
129
129
  });
130
130
 
131
131
  export const flushAndSync = Effect.fn(function* (opts?: Database.FlushOptions) {
132
- yield* Database.Service.flush(opts);
133
- const spaceId = yield* Database.Service.spaceId;
132
+ yield* Database.flush(opts);
133
+ const spaceId = yield* Database.spaceId;
134
134
  const space = yield* getSpace(spaceId);
135
135
  yield* waitForSync(space);
136
136
  });