@dxos/cli-util 0.8.4-main.fcc0d83b33 → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/dist/lib/node-esm/index.mjs +11 -24
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/util/space.d.ts +2 -3
- package/dist/types/src/util/space.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -18
- package/src/util/form-builder.test.ts +10 -10
- package/src/util/space-format.ts +2 -2
- package/src/util/space.ts +7 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/cli-util",
|
|
3
|
-
"version": "0.8.4-
|
|
3
|
+
"version": "0.8.4-staging.60fe92afc8",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"type": "module",
|
|
@@ -30,27 +30,29 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@effect/cli": "0.
|
|
34
|
-
"@effect/printer": "0.
|
|
35
|
-
"@effect/printer-ansi": "0.
|
|
36
|
-
"@dxos/app-toolkit": "0.8.4-
|
|
37
|
-
"@dxos/client": "0.8.4-
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
33
|
+
"@effect/cli": "0.75.2",
|
|
34
|
+
"@effect/printer": "0.49.0",
|
|
35
|
+
"@effect/printer-ansi": "0.49.0",
|
|
36
|
+
"@dxos/app-toolkit": "0.8.4-staging.60fe92afc8",
|
|
37
|
+
"@dxos/client": "0.8.4-staging.60fe92afc8",
|
|
38
|
+
"@dxos/compute": "0.8.4-staging.60fe92afc8",
|
|
39
|
+
"@dxos/debug": "0.8.4-staging.60fe92afc8",
|
|
40
|
+
"@dxos/echo-client": "0.8.4-staging.60fe92afc8",
|
|
41
|
+
"@dxos/effect": "0.8.4-staging.60fe92afc8",
|
|
42
|
+
"@dxos/echo": "0.8.4-staging.60fe92afc8",
|
|
43
|
+
"@dxos/errors": "0.8.4-staging.60fe92afc8",
|
|
44
|
+
"@dxos/log": "0.8.4-staging.60fe92afc8",
|
|
45
|
+
"@dxos/functions": "0.8.4-staging.60fe92afc8",
|
|
46
|
+
"@dxos/protocols": "0.8.4-staging.60fe92afc8",
|
|
47
|
+
"@dxos/util": "0.8.4-staging.60fe92afc8"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"effect": "3.
|
|
50
|
+
"effect": "3.21.3",
|
|
49
51
|
"typescript": "^6.0.3",
|
|
50
|
-
"vitest": "4.1.
|
|
52
|
+
"vitest": "4.1.7"
|
|
51
53
|
},
|
|
52
54
|
"peerDependencies": {
|
|
53
|
-
"effect": "3.
|
|
55
|
+
"effect": "3.21.3"
|
|
54
56
|
},
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"access": "public"
|
|
@@ -8,11 +8,11 @@ import * as Effect from 'effect/Effect';
|
|
|
8
8
|
import * as Option from 'effect/Option';
|
|
9
9
|
|
|
10
10
|
import { FormBuilder, print } from '@dxos/cli-util';
|
|
11
|
-
import {
|
|
11
|
+
import { EffectEx } from '@dxos/effect';
|
|
12
12
|
|
|
13
13
|
describe('FormBuilder', () => {
|
|
14
14
|
it('option', () =>
|
|
15
|
-
runAndForwardErrors(
|
|
15
|
+
EffectEx.runAndForwardErrors(
|
|
16
16
|
Effect.gen(function* () {
|
|
17
17
|
const builder = FormBuilder.make({ title: 'Option Test' }).pipe(
|
|
18
18
|
FormBuilder.option('some', Option.some('value')),
|
|
@@ -25,7 +25,7 @@ describe('FormBuilder', () => {
|
|
|
25
25
|
));
|
|
26
26
|
|
|
27
27
|
it('when', () =>
|
|
28
|
-
runAndForwardErrors(
|
|
28
|
+
EffectEx.runAndForwardErrors(
|
|
29
29
|
Effect.gen(function* () {
|
|
30
30
|
const builder = FormBuilder.make({ title: 'When Test' }).pipe(
|
|
31
31
|
FormBuilder.when(true, FormBuilder.set('included', 'true')),
|
|
@@ -38,7 +38,7 @@ describe('FormBuilder', () => {
|
|
|
38
38
|
));
|
|
39
39
|
|
|
40
40
|
it('each', () =>
|
|
41
|
-
runAndForwardErrors(
|
|
41
|
+
EffectEx.runAndForwardErrors(
|
|
42
42
|
Effect.gen(function* () {
|
|
43
43
|
const items = ['a', 'b', 'c'];
|
|
44
44
|
const builder = FormBuilder.make({ title: 'Each Test' }).pipe(
|
|
@@ -51,7 +51,7 @@ describe('FormBuilder', () => {
|
|
|
51
51
|
));
|
|
52
52
|
|
|
53
53
|
it('build', () =>
|
|
54
|
-
runAndForwardErrors(
|
|
54
|
+
EffectEx.runAndForwardErrors(
|
|
55
55
|
Effect.gen(function* () {
|
|
56
56
|
const builder = FormBuilder.make({ title: 'Test' }).pipe(
|
|
57
57
|
FormBuilder.set('foo', 100),
|
|
@@ -64,7 +64,7 @@ describe('FormBuilder', () => {
|
|
|
64
64
|
));
|
|
65
65
|
|
|
66
66
|
it('nest', () =>
|
|
67
|
-
runAndForwardErrors(
|
|
67
|
+
EffectEx.runAndForwardErrors(
|
|
68
68
|
Effect.gen(function* () {
|
|
69
69
|
const nested = FormBuilder.make({ title: 'Nested' }).pipe(
|
|
70
70
|
FormBuilder.set('nested1', 'value1'),
|
|
@@ -83,7 +83,7 @@ describe('FormBuilder', () => {
|
|
|
83
83
|
));
|
|
84
84
|
|
|
85
85
|
it('nestedOption', () =>
|
|
86
|
-
runAndForwardErrors(
|
|
86
|
+
EffectEx.runAndForwardErrors(
|
|
87
87
|
Effect.gen(function* () {
|
|
88
88
|
const nested = FormBuilder.make({ title: 'Nested' }).pipe(FormBuilder.set('key', 'value'));
|
|
89
89
|
|
|
@@ -98,7 +98,7 @@ describe('FormBuilder', () => {
|
|
|
98
98
|
));
|
|
99
99
|
|
|
100
100
|
it('multi-level nesting', () =>
|
|
101
|
-
runAndForwardErrors(
|
|
101
|
+
EffectEx.runAndForwardErrors(
|
|
102
102
|
Effect.gen(function* () {
|
|
103
103
|
const grandchild = FormBuilder.make({ title: 'Grandchild' }).pipe(
|
|
104
104
|
FormBuilder.set('grandchild1', 'value1'),
|
|
@@ -123,7 +123,7 @@ describe('FormBuilder', () => {
|
|
|
123
123
|
));
|
|
124
124
|
|
|
125
125
|
it('pipeable build', () =>
|
|
126
|
-
runAndForwardErrors(
|
|
126
|
+
EffectEx.runAndForwardErrors(
|
|
127
127
|
Effect.gen(function* () {
|
|
128
128
|
const doc = FormBuilder.make({ title: 'Pipeable' }).pipe(
|
|
129
129
|
FormBuilder.set('foo', 100),
|
|
@@ -135,7 +135,7 @@ describe('FormBuilder', () => {
|
|
|
135
135
|
));
|
|
136
136
|
|
|
137
137
|
it('dual calling styles', () =>
|
|
138
|
-
runAndForwardErrors(
|
|
138
|
+
EffectEx.runAndForwardErrors(
|
|
139
139
|
Effect.gen(function* () {
|
|
140
140
|
// Curried style (pipe)
|
|
141
141
|
const builder1 = FormBuilder.make({ title: 'Curried' }).pipe(
|
package/src/util/space-format.ts
CHANGED
|
@@ -86,14 +86,14 @@ export const formatSpace = Effect.fn(function* (space: Space, options: FormatSpa
|
|
|
86
86
|
|
|
87
87
|
// The sync-state read does IO; cap it so a stuck space can't hang the
|
|
88
88
|
// command. Falls back to a "no peers" placeholder.
|
|
89
|
-
const syncStateRaw = yield* tryWithFallback('getSyncState', () => space.internal.db.
|
|
89
|
+
const syncStateRaw = yield* tryWithFallback('getSyncState', () => space.internal.db.getSyncState(), {
|
|
90
90
|
peers: {},
|
|
91
91
|
} as SpaceSyncState);
|
|
92
92
|
const syncState = aggregateSyncState(syncStateRaw);
|
|
93
93
|
|
|
94
94
|
const name = ready ? tryWithFallbackSync(() => space.properties.name, undefined) : 'loading...';
|
|
95
95
|
const members = tryWithFallbackSync(() => space.members.get().length, 0);
|
|
96
|
-
const objects = tryWithFallbackSync(() => space.internal.db.
|
|
96
|
+
const objects = tryWithFallbackSync(() => space.internal.db.getAllObjectIds().length, 0);
|
|
97
97
|
const key = options.truncateKeys
|
|
98
98
|
? tryWithFallbackSync(() => space.key.truncate(), '')
|
|
99
99
|
: tryWithFallbackSync(() => space.key.toHex(), '');
|
package/src/util/space.ts
CHANGED
|
@@ -10,8 +10,8 @@ import * as Option from 'effect/Option';
|
|
|
10
10
|
import { getPersonalSpace } from '@dxos/app-toolkit';
|
|
11
11
|
import { ClientService } from '@dxos/client';
|
|
12
12
|
import { type Space } from '@dxos/client/echo';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { Database, Feed, type Key } from '@dxos/echo';
|
|
14
|
+
import { createFeedServiceLayer } from '@dxos/echo-client';
|
|
15
15
|
import { BaseError, type BaseErrorOptions } from '@dxos/errors';
|
|
16
16
|
import { log } from '@dxos/log';
|
|
17
17
|
import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
@@ -39,7 +39,7 @@ export const spaceIdWithDefault = (spaceId: Option.Option<Key.SpaceId>) =>
|
|
|
39
39
|
export const spaceLayer = (
|
|
40
40
|
spaceId$: Option.Option<Key.SpaceId>,
|
|
41
41
|
fallbackToPersonalSpace = false,
|
|
42
|
-
): Layer.Layer<Database.Service |
|
|
42
|
+
): Layer.Layer<Database.Service | Feed.FeedService, never, ClientService> => {
|
|
43
43
|
const getSpace = Effect.fn(function* () {
|
|
44
44
|
const client = yield* ClientService;
|
|
45
45
|
|
|
@@ -93,31 +93,17 @@ export const spaceLayer = (
|
|
|
93
93
|
),
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
-
const
|
|
97
|
-
QueueService,
|
|
96
|
+
const feed = Layer.unwrapEffect(
|
|
98
97
|
Effect.gen(function* () {
|
|
99
98
|
const space = yield* getSpace();
|
|
100
99
|
if (!space) {
|
|
101
|
-
return
|
|
102
|
-
queues: {
|
|
103
|
-
get: (_dxn) => {
|
|
104
|
-
throw new Error('Queues not available');
|
|
105
|
-
},
|
|
106
|
-
create: () => {
|
|
107
|
-
throw new Error('Queues not available');
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
queue: undefined,
|
|
111
|
-
};
|
|
100
|
+
return Feed.notAvailable;
|
|
112
101
|
}
|
|
113
|
-
return
|
|
114
|
-
queues: space.queues,
|
|
115
|
-
queue: undefined,
|
|
116
|
-
};
|
|
102
|
+
return createFeedServiceLayer(space.queues);
|
|
117
103
|
}),
|
|
118
104
|
);
|
|
119
105
|
|
|
120
|
-
return Layer.merge(db,
|
|
106
|
+
return Layer.merge(db, feed);
|
|
121
107
|
};
|
|
122
108
|
|
|
123
109
|
// TODO(dmaretskyi): There a race condition with edge connection not showing up.
|