@dxos/plugin-kanban 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.
- package/dist/lib/browser/blueprint-definition-GGL6Y5GN.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-GGL6Y5GN.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs +35 -0
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs.map +7 -0
- package/dist/lib/browser/chunk-XYQO4VL7.mjs +150 -0
- package/dist/lib/browser/chunk-XYQO4VL7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +66 -72
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-RFQU4VAB.mjs +162 -0
- package/dist/lib/browser/operation-resolver-RFQU4VAB.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FZQDOE3J.mjs +237 -0
- package/dist/lib/browser/react-surface-FZQDOE3J.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AMIOYZSF.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-AMIOYZSF.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs +152 -0
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs +36 -0
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +66 -72
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-J4JUSY74.mjs +163 -0
- package/dist/lib/node-esm/operation-resolver-J4JUSY74.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-KOQ56TL6.mjs +238 -0
- package/dist/lib/node-esm/react-surface-KOQ56TL6.mjs.map +7 -0
- package/dist/lib/node-esm/{types.mjs → types/index.mjs} +7 -6
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/KanbanPlugin.d.ts +2 -1
- package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts +22 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +10 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/KanbanContainer.d.ts +4 -5
- package/dist/types/src/components/KanbanContainer.d.ts.map +1 -1
- package/dist/types/src/components/KanbanContainer.stories.d.ts +71 -6
- package/dist/types/src/components/KanbanContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/KanbanViewEditor.d.ts +3 -3
- package/dist/types/src/components/KanbanViewEditor.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +36 -53
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +122 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +4 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +65 -44
- package/src/KanbanPlugin.tsx +39 -55
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/kanban-blueprint.ts +24 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +150 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +24 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +133 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +87 -0
- package/src/components/KanbanContainer.stories.tsx +212 -118
- package/src/components/KanbanContainer.tsx +38 -46
- package/src/components/KanbanViewEditor.tsx +34 -79
- package/src/index.ts +2 -1
- package/src/meta.ts +9 -7
- package/src/translations.ts +10 -10
- package/src/types/index.ts +6 -0
- package/src/types/schema.ts +120 -0
- package/src/types/types.ts +7 -0
- package/dist/lib/browser/artifact-definition-6HNQFL2M.mjs +0 -178
- package/dist/lib/browser/artifact-definition-6HNQFL2M.mjs.map +0 -7
- package/dist/lib/browser/chunk-6JEDX6HA.mjs +0 -85
- package/dist/lib/browser/chunk-6JEDX6HA.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-QQOH5EV2.mjs +0 -297
- package/dist/lib/browser/intent-resolver-QQOH5EV2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-HJL2JRJP.mjs +0 -305
- package/dist/lib/browser/react-surface-HJL2JRJP.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -13
- package/dist/lib/node/artifact-definition-GRCAYCVG.cjs +0 -193
- package/dist/lib/node/artifact-definition-GRCAYCVG.cjs.map +0 -7
- package/dist/lib/node/chunk-ATDUVDIE.cjs +0 -108
- package/dist/lib/node/chunk-ATDUVDIE.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -128
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-6ZNOIHKY.cjs +0 -308
- package/dist/lib/node/intent-resolver-6ZNOIHKY.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-G2J6F7U5.cjs +0 -322
- package/dist/lib/node/react-surface-G2J6F7U5.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -35
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-FA2IAAUQ.mjs +0 -179
- package/dist/lib/node-esm/artifact-definition-FA2IAAUQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7DHZSNGQ.mjs +0 -87
- package/dist/lib/node-esm/chunk-7DHZSNGQ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-4TYFDM4E.mjs +0 -298
- package/dist/lib/node-esm/intent-resolver-4TYFDM4E.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-257WTPQZ.mjs +0 -306
- package/dist/lib/node-esm/react-surface-257WTPQZ.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -3
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/initialize-kanban.d.ts +0 -17
- package/dist/types/src/testing/initialize-kanban.d.ts.map +0 -1
- package/dist/types/src/testing/kanban-manager.d.ts +0 -7
- package/dist/types/src/testing/kanban-manager.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/smoke.spec.d.ts +0 -2
- package/dist/types/src/testing/playwright/smoke.spec.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -76
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -136
- package/src/capabilities/intent-resolver.ts +0 -71
- package/src/capabilities/react-surface.tsx +0 -81
- package/src/testing/index.ts +0 -6
- package/src/testing/initialize-kanban.ts +0 -128
- package/src/testing/kanban-manager.ts +0 -13
- package/src/testing/playwright/playwright.config.cts +0 -18
- package/src/testing/playwright/smoke.spec.ts +0 -7
- package/src/types.ts +0 -95
- /package/dist/lib/browser/{types.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema, pipe } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { createTool, ToolResult } from '@dxos/ai';
|
|
8
|
-
import { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import { defineArtifact } from '@dxos/artifact';
|
|
10
|
-
import { createArtifactElement } from '@dxos/assistant';
|
|
11
|
-
import { Obj } from '@dxos/echo';
|
|
12
|
-
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
-
import { Filter, fullyQualifiedId, type Space } from '@dxos/react-client/echo';
|
|
15
|
-
import { KanbanType } from '@dxos/react-ui-kanban';
|
|
16
|
-
|
|
17
|
-
import { meta } from '../meta';
|
|
18
|
-
import { KanbanAction } from '../types';
|
|
19
|
-
|
|
20
|
-
const QualifiedId = Schema.String.annotations({
|
|
21
|
-
description: 'The fully qualified ID of the kanban `spaceID:objectID`',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
declare global {
|
|
25
|
-
interface ToolContextExtensions {
|
|
26
|
-
space?: Space;
|
|
27
|
-
dispatch?: PromiseIntentDispatcher;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default () => {
|
|
32
|
-
const definition = defineArtifact({
|
|
33
|
-
id: `artifact:${meta.id}`,
|
|
34
|
-
name: meta.name,
|
|
35
|
-
instructions: `
|
|
36
|
-
- Before adding items to a kanban board, inspect the board to see its schema
|
|
37
|
-
- When adding items, you must not include the 'id' field -- it is automatically generated
|
|
38
|
-
- BEFORE adding items, always make sure the board has been shown to the user!
|
|
39
|
-
`,
|
|
40
|
-
schema: KanbanType,
|
|
41
|
-
tools: [
|
|
42
|
-
createTool(meta.id, {
|
|
43
|
-
name: 'create',
|
|
44
|
-
description: `
|
|
45
|
-
Create a new kanban board using an existing schema.
|
|
46
|
-
Use schema_create first to create a schema, or schema_list to choose an existing one.`,
|
|
47
|
-
caption: 'Creating kanban board...',
|
|
48
|
-
schema: Schema.Struct({
|
|
49
|
-
typename: Schema.String.annotations({
|
|
50
|
-
description: 'The fully qualified typename of the schema to use for the kanban cards.',
|
|
51
|
-
}),
|
|
52
|
-
pivotColumn: Schema.optional(Schema.String).annotations({
|
|
53
|
-
description: 'Optional field name to use as the column pivot.',
|
|
54
|
-
}),
|
|
55
|
-
}),
|
|
56
|
-
execute: async ({ typename, pivotColumn }, { extensions }) => {
|
|
57
|
-
invariant(extensions?.space, 'No space');
|
|
58
|
-
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
59
|
-
|
|
60
|
-
// Validate schema exists first
|
|
61
|
-
const schema = await extensions.space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
62
|
-
if (!schema) {
|
|
63
|
-
return ToolResult.Error(`Schema not found: ${typename}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const intent = pipe(
|
|
67
|
-
createIntent(KanbanAction.Create, {
|
|
68
|
-
space: extensions.space,
|
|
69
|
-
typename,
|
|
70
|
-
initialPivotColumn: pivotColumn,
|
|
71
|
-
}),
|
|
72
|
-
chain(SpaceAction.AddObject, { target: extensions.space }),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const { data, error } = await extensions.dispatch(intent);
|
|
76
|
-
if (!data || error) {
|
|
77
|
-
return ToolResult.Error(error?.message ?? 'Failed to create kanban board');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return ToolResult.Success(createArtifactElement(data.id));
|
|
81
|
-
},
|
|
82
|
-
}),
|
|
83
|
-
createTool(meta.id, {
|
|
84
|
-
name: 'list',
|
|
85
|
-
description: 'List all kanban boards in the current space.',
|
|
86
|
-
caption: 'Listing kanban boards...',
|
|
87
|
-
schema: Schema.Struct({}),
|
|
88
|
-
execute: async (_input, { extensions }) => {
|
|
89
|
-
invariant(extensions?.space, 'No space');
|
|
90
|
-
const space = extensions.space;
|
|
91
|
-
const { objects: boards } = await space.db.query(Filter.type(KanbanType)).run();
|
|
92
|
-
|
|
93
|
-
const boardInfo = await Promise.all(
|
|
94
|
-
boards.map(async (board: KanbanType) => {
|
|
95
|
-
const view = await board.cardView?.load();
|
|
96
|
-
return {
|
|
97
|
-
id: fullyQualifiedId(board),
|
|
98
|
-
typename: view?.query.typename,
|
|
99
|
-
};
|
|
100
|
-
}),
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
return ToolResult.Success(boardInfo);
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
createTool(meta.id, {
|
|
107
|
-
name: 'inspect',
|
|
108
|
-
description: 'Get details about a specific kanban board.',
|
|
109
|
-
caption: 'Inspecting kanban board...',
|
|
110
|
-
schema: Schema.Struct({ id: QualifiedId }),
|
|
111
|
-
execute: async ({ id }, { extensions }) => {
|
|
112
|
-
invariant(extensions?.space, 'No space');
|
|
113
|
-
const space = extensions.space;
|
|
114
|
-
const { objects: boards } = await space.db.query(Filter.type(KanbanType)).run();
|
|
115
|
-
const board = boards.find((board: KanbanType) => fullyQualifiedId(board) === id);
|
|
116
|
-
invariant(Obj.instanceOf(KanbanType, board));
|
|
117
|
-
|
|
118
|
-
const view = await board.cardView?.load();
|
|
119
|
-
invariant(view);
|
|
120
|
-
|
|
121
|
-
const typename = view.query.typename;
|
|
122
|
-
const schema = await space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
123
|
-
invariant(schema);
|
|
124
|
-
|
|
125
|
-
return ToolResult.Success({
|
|
126
|
-
schema,
|
|
127
|
-
columnField: board.columnFieldId,
|
|
128
|
-
viewFields: view.fields,
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
}),
|
|
132
|
-
],
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return contributes(Capabilities.ArtifactDefinition, definition);
|
|
136
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { contributes, Capabilities, createResolver, type PluginContext } from '@dxos/app-framework';
|
|
6
|
-
import { invariant } from '@dxos/invariant';
|
|
7
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
8
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
9
|
-
import { ViewProjection } from '@dxos/schema';
|
|
10
|
-
|
|
11
|
-
import { KANBAN_PLUGIN } from '../meta';
|
|
12
|
-
import { initializeKanban } from '../testing';
|
|
13
|
-
import { KanbanAction } from '../types';
|
|
14
|
-
|
|
15
|
-
export default (context: PluginContext) =>
|
|
16
|
-
contributes(Capabilities.IntentResolver, [
|
|
17
|
-
createResolver({
|
|
18
|
-
intent: KanbanAction.Create,
|
|
19
|
-
resolve: async ({ space, name, typename, initialPivotColumn }) => {
|
|
20
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
21
|
-
const { kanban } = await initializeKanban({ client, space, name, typename, initialPivotColumn });
|
|
22
|
-
return { data: { object: kanban } };
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
createResolver({
|
|
26
|
-
intent: KanbanAction.DeleteCardField,
|
|
27
|
-
resolve: ({ kanban, fieldId, deletionData }, undo) => {
|
|
28
|
-
invariant(kanban.cardView);
|
|
29
|
-
invariant(kanban.cardView.target?.query.typename);
|
|
30
|
-
|
|
31
|
-
const schema =
|
|
32
|
-
kanban.cardView.target &&
|
|
33
|
-
getSpace(kanban)?.db.schemaRegistry.getSchema(kanban.cardView.target.query.typename);
|
|
34
|
-
invariant(schema);
|
|
35
|
-
invariant(kanban.cardView.target);
|
|
36
|
-
const projection = new ViewProjection(schema.jsonSchema, kanban.cardView.target);
|
|
37
|
-
|
|
38
|
-
if (!undo) {
|
|
39
|
-
const { deleted, index } = projection.deleteFieldProjection(fieldId);
|
|
40
|
-
return {
|
|
41
|
-
undoable: {
|
|
42
|
-
message: ['card field deleted label', { ns: KANBAN_PLUGIN }],
|
|
43
|
-
data: { deletionData: { ...deleted, index } },
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
} else if (undo && deletionData) {
|
|
47
|
-
const { field, props, index } = deletionData;
|
|
48
|
-
projection.setFieldProjection({ field, props }, index);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
createResolver({
|
|
53
|
-
intent: KanbanAction.DeleteCard,
|
|
54
|
-
resolve: ({ card }, undo) => {
|
|
55
|
-
const space = getSpace(card);
|
|
56
|
-
invariant(space);
|
|
57
|
-
|
|
58
|
-
if (!undo) {
|
|
59
|
-
space.db.remove(card);
|
|
60
|
-
return {
|
|
61
|
-
undoable: {
|
|
62
|
-
message: ['card deleted label', { ns: KANBAN_PLUGIN }],
|
|
63
|
-
data: { card },
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
} else {
|
|
67
|
-
space.db.add(card);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
}),
|
|
71
|
-
]);
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Capabilities, contributes, createSurface, useCapabilities } from '@dxos/app-framework';
|
|
9
|
-
import { Type } from '@dxos/echo';
|
|
10
|
-
import { findAnnotation } from '@dxos/effect';
|
|
11
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
-
import { getSpace, isSpace, type Space } from '@dxos/react-client/echo';
|
|
13
|
-
import { type InputProps, SelectInput, useFormValues } from '@dxos/react-ui-form';
|
|
14
|
-
import { type KanbanType } from '@dxos/react-ui-kanban';
|
|
15
|
-
import { type DataType } from '@dxos/schema';
|
|
16
|
-
|
|
17
|
-
import { KanbanContainer, KanbanViewEditor } from '../components';
|
|
18
|
-
import { KANBAN_PLUGIN } from '../meta';
|
|
19
|
-
import { isKanban, PivotColumnAnnotationId } from '../types';
|
|
20
|
-
|
|
21
|
-
export default () =>
|
|
22
|
-
contributes(Capabilities.ReactSurface, [
|
|
23
|
-
createSurface({
|
|
24
|
-
id: `${KANBAN_PLUGIN}/kanban`,
|
|
25
|
-
role: ['article', 'section'],
|
|
26
|
-
filter: (data): data is { subject: KanbanType } => isKanban(data.subject),
|
|
27
|
-
component: ({ data, role }) => <KanbanContainer kanban={data.subject} role={role} />,
|
|
28
|
-
}),
|
|
29
|
-
createSurface({
|
|
30
|
-
id: `${KANBAN_PLUGIN}/object-settings`,
|
|
31
|
-
role: 'object-settings',
|
|
32
|
-
filter: (data): data is { subject: KanbanType } => isKanban(data.subject),
|
|
33
|
-
component: ({ data }) => <KanbanViewEditor kanban={data.subject} />,
|
|
34
|
-
}),
|
|
35
|
-
createSurface({
|
|
36
|
-
id: `${KANBAN_PLUGIN}/create-initial-schema-form-[pivot-column]`,
|
|
37
|
-
role: 'form-input',
|
|
38
|
-
filter: (
|
|
39
|
-
data,
|
|
40
|
-
): data is { prop: string; schema: Schema.Schema<any>; target: Space | DataType.Collection | undefined } => {
|
|
41
|
-
const annotation = findAnnotation<boolean>((data.schema as Schema.Schema.All).ast, PivotColumnAnnotationId);
|
|
42
|
-
return !!annotation;
|
|
43
|
-
},
|
|
44
|
-
component: ({ data: { target }, ...inputProps }) => {
|
|
45
|
-
const props = inputProps as any as InputProps;
|
|
46
|
-
const space = isSpace(target) ? target : getSpace(target);
|
|
47
|
-
if (!space) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const { typename } = useFormValues();
|
|
51
|
-
// TODO(wittjosiah): Unify this schema lookup.
|
|
52
|
-
const schemaWhitelists = useCapabilities(ClientCapabilities.SchemaWhiteList);
|
|
53
|
-
const staticSchema = schemaWhitelists.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
54
|
-
const [selectedSchema] = space?.db.schemaRegistry.query({ typename }).runSync();
|
|
55
|
-
|
|
56
|
-
const singleSelectColumns = useMemo(() => {
|
|
57
|
-
const properties = staticSchema
|
|
58
|
-
? Type.toJsonSchema(staticSchema).properties
|
|
59
|
-
: selectedSchema?.jsonSchema?.properties;
|
|
60
|
-
if (!properties) {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const columns = Object.entries(properties).reduce<string[]>((acc, [key, value]) => {
|
|
65
|
-
if (typeof value === 'object' && value?.format === 'single-select') {
|
|
66
|
-
acc.push(key);
|
|
67
|
-
}
|
|
68
|
-
return acc;
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
return columns;
|
|
72
|
-
}, [selectedSchema?.jsonSchema, staticSchema]);
|
|
73
|
-
|
|
74
|
-
if (!typename) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return <SelectInput {...props} options={singleSelectColumns.map((column) => ({ value: column }))} />;
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
]);
|
package/src/testing/index.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
-
import { TypedObject, FormatEnum, TypeEnum, type JsonProp } from '@dxos/echo-schema';
|
|
9
|
-
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { type Client, PublicKey } from '@dxos/react-client';
|
|
11
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
12
|
-
import { KanbanType } from '@dxos/react-ui-kanban';
|
|
13
|
-
import { createView, ViewProjection, createFieldId, getSchemaProperties } from '@dxos/schema';
|
|
14
|
-
import { capitalize } from '@dxos/util';
|
|
15
|
-
|
|
16
|
-
// TODO(wittjosiah): UI package shouldn't depend on client.
|
|
17
|
-
|
|
18
|
-
type InitializeKanbanProps = {
|
|
19
|
-
client: Client;
|
|
20
|
-
space: Space;
|
|
21
|
-
name?: string;
|
|
22
|
-
typename?: string;
|
|
23
|
-
initialPivotColumn?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const createDefaultTaskSchema = () => {
|
|
27
|
-
const stateOptions = [
|
|
28
|
-
{ id: PublicKey.random().truncate(), title: 'Draft', color: 'indigo' },
|
|
29
|
-
{ id: PublicKey.random().truncate(), title: 'Active', color: 'cyan' },
|
|
30
|
-
{ id: PublicKey.random().truncate(), title: 'Completed', color: 'emerald' },
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const schema = TypedObject({
|
|
34
|
-
typename: `example.com/type/${PublicKey.random().truncate()}`,
|
|
35
|
-
version: '0.1.0',
|
|
36
|
-
})({
|
|
37
|
-
title: Schema.optional(Schema.String).annotations({ title: 'Title' }),
|
|
38
|
-
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
39
|
-
state: Schema.optional(Schema.String),
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return { schema, stateOptions };
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const initializeKanban = async ({
|
|
46
|
-
client,
|
|
47
|
-
space,
|
|
48
|
-
name,
|
|
49
|
-
typename,
|
|
50
|
-
initialPivotColumn,
|
|
51
|
-
}: InitializeKanbanProps): Promise<{ kanban: KanbanType; schema?: Type.Schema }> => {
|
|
52
|
-
if (typename) {
|
|
53
|
-
const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
54
|
-
const schema = await space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
55
|
-
|
|
56
|
-
const ast = staticSchema?.ast ?? schema?.ast;
|
|
57
|
-
const jsonSchema = staticSchema ? Type.toJsonSchema(staticSchema) : schema?.jsonSchema;
|
|
58
|
-
invariant(ast, `Schema not found: ${typename}`);
|
|
59
|
-
invariant(jsonSchema, `Schema not found: ${typename}`);
|
|
60
|
-
|
|
61
|
-
const fields = getSchemaProperties(ast)
|
|
62
|
-
.filter((prop) => prop.type !== 'object' || prop.format === FormatEnum.Ref)
|
|
63
|
-
.map((prop) => prop.name);
|
|
64
|
-
|
|
65
|
-
const view = createView({
|
|
66
|
-
name: "Kanban's card view",
|
|
67
|
-
typename,
|
|
68
|
-
jsonSchema,
|
|
69
|
-
fields,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const kanban = Obj.make(KanbanType, { cardView: Ref.make(view), columnFieldId: undefined, name });
|
|
73
|
-
if (initialPivotColumn) {
|
|
74
|
-
const viewProjection = new ViewProjection(jsonSchema, view);
|
|
75
|
-
const fieldId = viewProjection.getFieldId(initialPivotColumn);
|
|
76
|
-
if (fieldId) {
|
|
77
|
-
kanban.columnFieldId = fieldId;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return { kanban, schema };
|
|
81
|
-
} else {
|
|
82
|
-
const { schema: taskSchema, stateOptions } = createDefaultTaskSchema();
|
|
83
|
-
const [schema] = await space.db.schemaRegistry.register([taskSchema]);
|
|
84
|
-
|
|
85
|
-
const view = createView({
|
|
86
|
-
name: "Kanban's card view",
|
|
87
|
-
typename: schema.typename,
|
|
88
|
-
jsonSchema: schema.jsonSchema,
|
|
89
|
-
fields: ['title', 'description'],
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const viewProjection = new ViewProjection(schema.jsonSchema, view);
|
|
93
|
-
|
|
94
|
-
// Set description field to Markdown format.
|
|
95
|
-
const descriptionFieldId = viewProjection.getFieldId('description');
|
|
96
|
-
if (descriptionFieldId) {
|
|
97
|
-
const fieldProjection = viewProjection.getFieldProjection(descriptionFieldId);
|
|
98
|
-
if (fieldProjection) {
|
|
99
|
-
viewProjection.setFieldProjection({
|
|
100
|
-
...fieldProjection,
|
|
101
|
-
props: { ...fieldProjection.props, format: FormatEnum.Markdown },
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const initialPivotField = 'state';
|
|
107
|
-
viewProjection.setFieldProjection({
|
|
108
|
-
field: {
|
|
109
|
-
id: createFieldId(),
|
|
110
|
-
path: initialPivotField as JsonProp,
|
|
111
|
-
size: 150,
|
|
112
|
-
},
|
|
113
|
-
props: {
|
|
114
|
-
property: initialPivotField as JsonProp,
|
|
115
|
-
type: TypeEnum.String,
|
|
116
|
-
format: FormatEnum.SingleSelect,
|
|
117
|
-
title: capitalize(initialPivotField),
|
|
118
|
-
options: stateOptions,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const fieldId = viewProjection.getFieldId(initialPivotField);
|
|
123
|
-
invariant(fieldId);
|
|
124
|
-
|
|
125
|
-
const kanban = Obj.make(KanbanType, { cardView: Ref.make(view), columnFieldId: fieldId });
|
|
126
|
-
return { kanban, schema };
|
|
127
|
-
}
|
|
128
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { nxE2EPreset } from '@nx/playwright/preset';
|
|
6
|
-
import { defineConfig } from '@playwright/test';
|
|
7
|
-
|
|
8
|
-
import { e2ePreset } from '@dxos/test-utils/playwright';
|
|
9
|
-
|
|
10
|
-
export default defineConfig({
|
|
11
|
-
...nxE2EPreset(__filename, { testDir: __dirname }),
|
|
12
|
-
...e2ePreset(__dirname),
|
|
13
|
-
webServer: {
|
|
14
|
-
command: 'pnpm -w nx storybook-e2e stories',
|
|
15
|
-
port: 9009,
|
|
16
|
-
reuseExistingServer: !process.env.CI,
|
|
17
|
-
},
|
|
18
|
-
});
|
package/src/types.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
8
|
-
import { KanbanType } from '@dxos/react-ui-kanban';
|
|
9
|
-
import { FieldSchema, TypenameAnnotationId } from '@dxos/schema';
|
|
10
|
-
|
|
11
|
-
import { KANBAN_PLUGIN } from './meta';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Kanban data model.
|
|
15
|
-
* A Kanban board is a collection of columns, each of which contains a collection of items.
|
|
16
|
-
* The layout of columns and items is controlled by models.
|
|
17
|
-
* The underlying data model may be represented by direct object relationships
|
|
18
|
-
* (e.g., a column object containing an array of ordered items) or projections constructed
|
|
19
|
-
* by the model (e.g., a query of items based on metadata within a column object).
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// TODO(wittjosiah): Factor out?
|
|
23
|
-
export const PivotColumnAnnotationId = Symbol.for('@dxos/plugin-kanban/annotation/PivotColumn');
|
|
24
|
-
|
|
25
|
-
export const CreateKanbanSchema = Schema.Struct({
|
|
26
|
-
name: Schema.optional(Schema.String),
|
|
27
|
-
typename: Schema.optional(
|
|
28
|
-
Schema.String.annotations({
|
|
29
|
-
[TypenameAnnotationId]: ['limited-static', 'dynamic'],
|
|
30
|
-
title: 'Select card schema (leave empty to start fresh)',
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
initialPivotColumn: Schema.optional(
|
|
34
|
-
Schema.String.annotations({
|
|
35
|
-
[PivotColumnAnnotationId]: true,
|
|
36
|
-
title: 'Pivot column',
|
|
37
|
-
}),
|
|
38
|
-
),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export type CreateKanbanType = Schema.Schema.Type<typeof CreateKanbanSchema>;
|
|
42
|
-
|
|
43
|
-
export namespace KanbanAction {
|
|
44
|
-
const KANBAN_ACTION = `${KANBAN_PLUGIN}/action`;
|
|
45
|
-
|
|
46
|
-
export class Create extends Schema.TaggedClass<Create>()(`${KANBAN_ACTION}/create`, {
|
|
47
|
-
input: Schema.extend(Schema.Struct({ space: SpaceSchema }), CreateKanbanSchema),
|
|
48
|
-
output: Schema.Struct({
|
|
49
|
-
object: KanbanType,
|
|
50
|
-
}),
|
|
51
|
-
}) {}
|
|
52
|
-
|
|
53
|
-
export class DeleteCardField extends Schema.TaggedClass<DeleteCardField>()(`${KANBAN_ACTION}/delete-card-field`, {
|
|
54
|
-
input: Schema.Struct({
|
|
55
|
-
kanban: KanbanType,
|
|
56
|
-
fieldId: Schema.String,
|
|
57
|
-
// TODO(wittjosiah): Separate fields for undo data?
|
|
58
|
-
deletionData: Schema.optional(
|
|
59
|
-
Schema.Struct({
|
|
60
|
-
field: FieldSchema,
|
|
61
|
-
// TODO(wittjosiah): This creates a type error.
|
|
62
|
-
// props: PropertySchema,
|
|
63
|
-
props: Schema.Any,
|
|
64
|
-
index: Schema.Number,
|
|
65
|
-
}),
|
|
66
|
-
),
|
|
67
|
-
}),
|
|
68
|
-
output: Schema.Void,
|
|
69
|
-
}) {}
|
|
70
|
-
|
|
71
|
-
export class DeleteCard extends Schema.TaggedClass<DeleteCard>()(`${KANBAN_ACTION}/delete-card`, {
|
|
72
|
-
input: Schema.Struct({
|
|
73
|
-
card: Schema.Any, // The card object to delete
|
|
74
|
-
}),
|
|
75
|
-
output: Schema.Void,
|
|
76
|
-
}) {}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// TODO(burdon): Undo?
|
|
80
|
-
// TODO(burdon): Typescript types (replace proto with annotations?)
|
|
81
|
-
// TODO(burdon): Should pure components depend on ECHO? Relationship between ECHO object/array and Observable.
|
|
82
|
-
// TODO(burdon): Can the plugin configure the object based on the data? E.g., how are the models constructed?
|
|
83
|
-
// TODO(burdon): Create models. Simple first based on actual data.
|
|
84
|
-
// Model is always a projection since the dragging state is tentative.
|
|
85
|
-
|
|
86
|
-
// TODO(burdon): Extend model for moving items (in and across columns).
|
|
87
|
-
export interface KanbanModel {
|
|
88
|
-
root: KanbanType;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type Location = {
|
|
92
|
-
idx?: number;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const isKanban = (object: unknown): object is KanbanType => object != null && object instanceof KanbanType;
|
|
File without changes
|
|
File without changes
|