@dxos/plugin-kanban 0.8.4-main.c85a9c8dae → 0.8.4-main.dfabb4ec29
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/neutral/KanbanContainer-QK6LNCYT.mjs +132 -0
- package/dist/lib/neutral/KanbanContainer-QK6LNCYT.mjs.map +7 -0
- package/dist/lib/neutral/KanbanPlugin.mjs +36 -0
- package/dist/lib/neutral/KanbanPlugin.mjs.map +7 -0
- package/dist/lib/neutral/KanbanPlugin.node.mjs +27 -0
- package/dist/lib/neutral/KanbanPlugin.node.mjs.map +7 -0
- package/dist/lib/{browser/KanbanViewEditor-IH5CJ6BW.mjs → neutral/KanbanSettings-G6M47NSK.mjs} +36 -19
- package/dist/lib/neutral/KanbanSettings-G6M47NSK.mjs.map +7 -0
- package/dist/lib/{browser/blueprint-definition-HFEKGFJK.mjs → neutral/blueprint-definition-FHVIEKTQ.mjs} +4 -6
- package/dist/lib/neutral/blueprint-definition-FHVIEKTQ.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/blueprints/index.mjs +1 -1
- package/dist/lib/neutral/capabilities/index.mjs +19 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-E65AME5F.mjs +255 -0
- package/dist/lib/neutral/chunk-E65AME5F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KDPM77BD.mjs +21 -0
- package/dist/lib/neutral/chunk-KDPM77BD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z7O5CETK.mjs +8 -0
- package/dist/lib/neutral/chunk-Z7O5CETK.mjs.map +7 -0
- package/dist/lib/{browser/chunk-TLYZSC7O.mjs → neutral/chunk-ZTQW5KQS.mjs} +3 -6
- package/dist/lib/neutral/chunk-ZTQW5KQS.mjs.map +7 -0
- package/dist/lib/{browser/KanbanContainer-BCXSJ6KS.mjs → neutral/components/index.mjs} +78 -139
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-DKBSI46K.mjs +40 -0
- package/dist/lib/neutral/create-object-DKBSI46K.mjs.map +7 -0
- package/dist/lib/neutral/delete-card-QKT6OXGP.mjs +24 -0
- package/dist/lib/neutral/delete-card-QKT6OXGP.mjs.map +7 -0
- package/dist/lib/neutral/delete-card-field-XQKM7ZXE.mjs +42 -0
- package/dist/lib/neutral/delete-card-field-XQKM7ZXE.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-CSL3HF2X.mjs → neutral/hooks/index.mjs} +128 -82
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/migrations-4NS6H7U2.mjs +31 -0
- package/dist/lib/neutral/migrations-4NS6H7U2.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-B7IW6MXU.mjs +13 -0
- package/dist/lib/neutral/operation-handler-B7IW6MXU.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-FOMOGFVW.mjs → neutral/react-surface-6RVSCHMJ.mjs} +21 -27
- package/dist/lib/neutral/react-surface-6RVSCHMJ.mjs.map +7 -0
- package/dist/lib/neutral/restore-card-XW7AHMPO.mjs +21 -0
- package/dist/lib/neutral/restore-card-XW7AHMPO.mjs.map +7 -0
- package/dist/lib/neutral/restore-card-field-QOAUY3RJ.mjs +40 -0
- package/dist/lib/neutral/restore-card-field-QOAUY3RJ.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +60 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +44 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +7 -5
- package/dist/lib/neutral/undo-mappings-6CHW6BOF.mjs +42 -0
- package/dist/lib/neutral/undo-mappings-6CHW6BOF.mjs.map +7 -0
- package/dist/types/src/KanbanPlugin.d.ts +1 -0
- package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
- package/dist/types/src/KanbanPlugin.node.d.ts +4 -0
- package/dist/types/src/KanbanPlugin.node.d.ts.map +1 -0
- package/dist/types/src/KanbanPlugin.test.d.ts +2 -0
- package/dist/types/src/KanbanPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +13 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +5 -0
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts +17 -38
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts +48 -46
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts +2 -3
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts +2 -3
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/context.d.ts +38 -0
- package/dist/types/src/components/KanbanBoard/context.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts +4 -4
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts +48 -46
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/index.d.ts +1 -2
- package/dist/types/src/containers/KanbanContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts +13 -0
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts +2 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts +1 -1
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useItemsProjection.d.ts +10 -0
- package/dist/types/src/hooks/useItemsProjection.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts +2 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts +1 -1
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts +2 -2
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts +2 -2
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/delete-card-field.d.ts +5 -0
- package/dist/types/src/operations/delete-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/delete-card.d.ts +5 -0
- package/dist/types/src/operations/delete-card.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card-field.d.ts +5 -0
- package/dist/types/src/operations/restore-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card.d.ts +5 -0
- package/dist/types/src/operations/restore-card.d.ts.map +1 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts +4 -2
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +48 -46
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Kanban.d.ts +78 -6
- package/dist/types/src/types/Kanban.d.ts.map +1 -1
- package/dist/types/src/types/KanbanOperation.d.ts +52 -0
- package/dist/types/src/types/KanbanOperation.d.ts.map +1 -0
- package/dist/types/src/types/constants.d.ts +3 -3
- package/dist/types/src/types/constants.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/migrations.test.d.ts +2 -0
- package/dist/types/src/types/migrations.test.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +15 -104
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/util/arrangement.d.ts +8 -4
- package/dist/types/src/util/arrangement.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -65
- package/src/KanbanPlugin.node.ts +21 -0
- package/src/KanbanPlugin.test.ts +31 -0
- package/src/KanbanPlugin.tsx +21 -29
- package/src/blueprints/kanban-blueprint.ts +4 -8
- package/src/capabilities/{artifact-definition/artifact-definition.ts → artifact-definition.ts} +4 -4
- package/src/capabilities/{blueprint-definition/blueprint-definition.ts → blueprint-definition.ts} +3 -1
- package/src/capabilities/create-object.ts +40 -0
- package/src/capabilities/index.ts +13 -3
- package/src/capabilities/migrations.ts +35 -0
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +22 -13
- package/src/capabilities/undo-mappings.ts +34 -0
- package/src/components/KanbanBoard/KanbanBoard.stories.tsx +20 -16
- package/src/components/KanbanBoard/KanbanBoard.tsx +44 -64
- package/src/components/KanbanBoard/KanbanCard.tsx +77 -63
- package/src/components/KanbanBoard/KanbanColumn.tsx +19 -16
- package/src/components/KanbanBoard/context.ts +54 -0
- package/src/containers/KanbanContainer/KanbanContainer.stories.tsx +44 -30
- package/src/containers/KanbanContainer/KanbanContainer.tsx +118 -27
- package/src/containers/KanbanContainer/index.ts +1 -3
- package/src/containers/KanbanSettings/KanbanSettings.tsx +94 -0
- package/src/containers/KanbanSettings/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useEchoChangeCallback.ts +3 -3
- package/src/hooks/useItemsProjection.ts +44 -0
- package/src/hooks/{useKanbanBoardModel.test.ts → useKanbanBoardModel.browser.test.ts} +5 -5
- package/src/hooks/useKanbanBoardModel.ts +20 -6
- package/src/hooks/useKanbanColumnEventHandler.ts +1 -1
- package/src/hooks/useKanbanItemEventHandler.ts +1 -1
- package/src/hooks/useProjectionModel.ts +3 -3
- package/src/index.ts +3 -2
- package/src/meta.ts +1 -1
- package/src/operations/delete-card-field.ts +47 -0
- package/src/operations/delete-card.ts +23 -0
- package/src/operations/index.ts +10 -0
- package/src/operations/restore-card-field.ts +41 -0
- package/src/operations/restore-card.ts +21 -0
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/plugin.ts +11 -0
- package/src/testing/KanbanCardTileSimple.tsx +25 -19
- package/src/translations.ts +26 -25
- package/src/types/Kanban.ts +98 -14
- package/src/types/KanbanOperation.ts +67 -0
- package/src/types/index.ts +3 -1
- package/src/types/migrations.test.ts +83 -0
- package/src/types/schema.ts +20 -78
- package/src/types/types.ts +2 -2
- package/src/util/arrangement.test.ts +11 -1
- package/src/util/arrangement.ts +25 -15
- package/dist/lib/browser/KanbanContainer-BCXSJ6KS.mjs.map +0 -7
- package/dist/lib/browser/KanbanViewEditor-IH5CJ6BW.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-HFEKGFJK.mjs.map +0 -7
- package/dist/lib/browser/chunk-QSWCFMEB.mjs +0 -385
- package/dist/lib/browser/chunk-QSWCFMEB.mjs.map +0 -7
- package/dist/lib/browser/chunk-RNFIFE2P.mjs +0 -213
- package/dist/lib/browser/chunk-RNFIFE2P.mjs.map +0 -7
- package/dist/lib/browser/chunk-TLYZSC7O.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -101
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs +0 -162
- package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FOMOGFVW.mjs.map +0 -7
- package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs +0 -305
- package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs.map +0 -7
- package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs +0 -67
- package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs +0 -18
- package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -9
- package/dist/lib/node-esm/chunk-4AWDHQVY.mjs +0 -214
- package/dist/lib/node-esm/chunk-4AWDHQVY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CSL3HF2X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-X3UJUQIV.mjs +0 -31
- package/dist/lib/node-esm/chunk-X3UJUQIV.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -102
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs +0 -163
- package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-AITKFRBE.mjs +0 -100
- package/dist/lib/node-esm/react-surface-AITKFRBE.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -21
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -6
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts +0 -6
- package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts.map +0 -1
- package/dist/types/src/containers/KanbanViewEditor/index.d.ts +0 -3
- package/dist/types/src/containers/KanbanViewEditor/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts +0 -2
- package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts.map +0 -1
- package/src/capabilities/artifact-definition/index.ts +0 -7
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -133
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/containers/KanbanViewEditor/KanbanViewEditor.tsx +0 -63
- package/src/containers/KanbanViewEditor/index.ts +0 -7
- /package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprints/index.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/types/index.mjs.map} +0 -0
- /package/dist/types/src/capabilities/{artifact-definition/artifact-definition.d.ts → artifact-definition.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.kanban',
|
|
10
10
|
name: 'Kanban',
|
|
11
11
|
description: trim`
|
|
12
12
|
Visual project management using customizable kanban boards to track workflow progress.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
import { Operation } from '@dxos/compute';
|
|
7
|
+
import { JsonSchema, Obj } from '@dxos/echo';
|
|
8
|
+
import { type EchoSchema } from '@dxos/echo/internal';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ProjectionModel, createEchoChangeCallback, getTypenameFromQuery } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { KanbanOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.DeleteCardField> = KanbanOperation.DeleteCardField.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ view, fieldId }) {
|
|
17
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
18
|
+
const db = Obj.getDatabase(view);
|
|
19
|
+
invariant(db, 'Database not found');
|
|
20
|
+
const schema = yield* Effect.promise(() =>
|
|
21
|
+
db.schemaRegistry
|
|
22
|
+
.query({
|
|
23
|
+
typename: getTypenameFromQuery(view.query.ast)!,
|
|
24
|
+
location: ['database', 'runtime'],
|
|
25
|
+
})
|
|
26
|
+
.first(),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const projection = new ProjectionModel({
|
|
30
|
+
registry,
|
|
31
|
+
view,
|
|
32
|
+
baseSchema: JsonSchema.toJsonSchema(schema),
|
|
33
|
+
change: createEchoChangeCallback(view, schema as EchoSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const result = projection.deleteFieldProjection(fieldId);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
field: result.deleted.field,
|
|
40
|
+
props: result.deleted.props,
|
|
41
|
+
index: result.index,
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default handler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Operation } from '@dxos/compute';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
|
|
9
|
+
import { KanbanOperation } from '../types';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.DeleteCard> = KanbanOperation.DeleteCard.pipe(
|
|
12
|
+
Operation.withHandler(({ card }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
const db = Obj.getDatabase(card);
|
|
15
|
+
invariant(db);
|
|
16
|
+
db.remove(card);
|
|
17
|
+
|
|
18
|
+
return { card };
|
|
19
|
+
}),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default handler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
4
|
+
|
|
5
|
+
export const KanbanOperationHandlerSet = OperationHandlerSet.lazy(
|
|
6
|
+
() => import('./delete-card'),
|
|
7
|
+
() => import('./delete-card-field'),
|
|
8
|
+
() => import('./restore-card'),
|
|
9
|
+
() => import('./restore-card-field'),
|
|
10
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
import { Operation } from '@dxos/compute';
|
|
7
|
+
import { JsonSchema, Obj } from '@dxos/echo';
|
|
8
|
+
import { type EchoSchema } from '@dxos/echo/internal';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ProjectionModel, createEchoChangeCallback, getTypenameFromQuery } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { KanbanOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.RestoreCardField> = KanbanOperation.RestoreCardField.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ view, field, props, index }) {
|
|
17
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
18
|
+
const db = Obj.getDatabase(view);
|
|
19
|
+
invariant(db, 'Database not found');
|
|
20
|
+
const schema = yield* Effect.promise(() =>
|
|
21
|
+
db.schemaRegistry
|
|
22
|
+
.query({
|
|
23
|
+
typename: getTypenameFromQuery(view.query.ast)!,
|
|
24
|
+
location: ['database', 'runtime'],
|
|
25
|
+
})
|
|
26
|
+
.first(),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const projection = new ProjectionModel({
|
|
30
|
+
registry,
|
|
31
|
+
view,
|
|
32
|
+
baseSchema: JsonSchema.toJsonSchema(schema),
|
|
33
|
+
change: createEchoChangeCallback(view, schema as EchoSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
projection.setFieldProjection({ field, props }, index);
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export default handler;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Operation } from '@dxos/compute';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
|
|
9
|
+
import { KanbanOperation } from '../types';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.RestoreCard> = KanbanOperation.RestoreCard.pipe(
|
|
12
|
+
Operation.withHandler(({ card }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
const db = Obj.getDatabase(card);
|
|
15
|
+
invariant(db);
|
|
16
|
+
db.add(card);
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default handler;
|
|
@@ -49,7 +49,7 @@ test.describe('Kanban MutableSchema', () => {
|
|
|
49
49
|
expect(secondLabel).not.toBeNull();
|
|
50
50
|
|
|
51
51
|
// Drag first item below the second item.
|
|
52
|
-
await column.item(0).dragTo(column.item(1).locator, { x: 0, y: 200 });
|
|
52
|
+
await column.item(0).dragTo(column.item(1).locator, { x: 0, y: 200 }, 'bottom');
|
|
53
53
|
|
|
54
54
|
// Item count should stay the same.
|
|
55
55
|
await expect(column.items()).toHaveCount(countBefore);
|
|
@@ -71,8 +71,8 @@ test.describe('Kanban MutableSchema', () => {
|
|
|
71
71
|
const draggedLabel = await col1.item(0).title().textContent();
|
|
72
72
|
expect(draggedLabel).not.toBeNull();
|
|
73
73
|
|
|
74
|
-
// Drop above first item.
|
|
75
|
-
await col1.item(0).dragTo(col2.item(0).locator, { x: 0, y: -30 });
|
|
74
|
+
// Drop above first item.
|
|
75
|
+
await col1.item(0).dragTo(col2.item(0).locator, { x: 0, y: -30 }, 'top');
|
|
76
76
|
|
|
77
77
|
await expect(col1.items()).toHaveCount(col1CountBefore - 1);
|
|
78
78
|
await expect(col2.items()).toHaveCount(col2CountBefore + 1);
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const KanbanPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { KanbanOperationHandlerSet } from './operations';
|
|
@@ -9,12 +9,14 @@ import { Card, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
|
9
9
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
10
10
|
import { Focus, Mosaic, useBoard } from '@dxos/react-ui-mosaic';
|
|
11
11
|
|
|
12
|
-
import { type KanbanCardProps, useKanbanBoard } from '
|
|
13
|
-
import { meta } from '
|
|
12
|
+
import { type KanbanCardProps, useKanbanBoard } from '#components';
|
|
13
|
+
import { meta } from '#meta';
|
|
14
14
|
|
|
15
15
|
const KANBAN_CARD_TILE_SIMPLE_NAME = 'KanbanCardTileSimple';
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Card tile without Surface; for stories and tests when plugin manager is not available.
|
|
19
|
+
*/
|
|
18
20
|
export const KanbanCardTileSimple = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
19
21
|
({ data, location, debug }, forwardedRef) => {
|
|
20
22
|
const { t } = useTranslation(meta.id);
|
|
@@ -28,7 +30,7 @@ export const KanbanCardTileSimple = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
|
28
30
|
onCardRemove
|
|
29
31
|
? [
|
|
30
32
|
createMenuAction('remove', () => onCardRemove(data), {
|
|
31
|
-
label: t('remove
|
|
33
|
+
label: t('remove-card.label'),
|
|
32
34
|
icon: 'ph--trash--regular',
|
|
33
35
|
}),
|
|
34
36
|
]
|
|
@@ -37,16 +39,16 @@ export const KanbanCardTileSimple = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
|
37
39
|
);
|
|
38
40
|
|
|
39
41
|
return (
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
42
|
+
<Menu.Root>
|
|
43
|
+
<Mosaic.Tile
|
|
44
|
+
asChild
|
|
45
|
+
id={model.getItemId(data)}
|
|
46
|
+
data={data}
|
|
47
|
+
location={location}
|
|
48
|
+
debug={debug}
|
|
49
|
+
dragHandle={dragHandle}
|
|
50
|
+
>
|
|
51
|
+
<Focus.Item asChild>
|
|
50
52
|
<Card.Root ref={forwardedRef} data-testid='board-item'>
|
|
51
53
|
<Card.Toolbar>
|
|
52
54
|
<Card.DragHandle ref={dragHandleRef} />
|
|
@@ -57,18 +59,22 @@ export const KanbanCardTileSimple = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
|
57
59
|
iconOnly
|
|
58
60
|
variant='ghost'
|
|
59
61
|
icon='ph--dots-three-vertical--regular'
|
|
60
|
-
label={t('action
|
|
62
|
+
label={t('action-menu.label')}
|
|
61
63
|
/>
|
|
62
64
|
</Menu.Trigger>
|
|
63
65
|
<Menu.Content items={menuItems} />
|
|
64
66
|
</Card.Toolbar>
|
|
65
67
|
<Card.Content>
|
|
66
|
-
<
|
|
68
|
+
<Card.Section>
|
|
69
|
+
<pre className='p-2 text-xs text-description whitespace-pre-wrap'>
|
|
70
|
+
{JSON.stringify(data, null, 2)}
|
|
71
|
+
</pre>
|
|
72
|
+
</Card.Section>
|
|
67
73
|
</Card.Content>
|
|
68
74
|
</Card.Root>
|
|
69
|
-
</
|
|
70
|
-
</
|
|
71
|
-
</
|
|
75
|
+
</Focus.Item>
|
|
76
|
+
</Mosaic.Tile>
|
|
77
|
+
</Menu.Root>
|
|
72
78
|
);
|
|
73
79
|
},
|
|
74
80
|
);
|
package/src/translations.ts
CHANGED
|
@@ -5,38 +5,39 @@
|
|
|
5
5
|
import { Type } from '@dxos/echo';
|
|
6
6
|
import { type Resource } from '@dxos/react-ui';
|
|
7
7
|
|
|
8
|
-
import { meta } from '
|
|
9
|
-
import { Kanban } from '
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
import { Kanban } from '#types';
|
|
10
10
|
|
|
11
11
|
export const translations = [
|
|
12
12
|
{
|
|
13
13
|
'en-US': {
|
|
14
14
|
[Type.getTypename(Kanban.Kanban)]: {
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'typename
|
|
19
|
-
'object
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'object
|
|
15
|
+
'typename.label': 'Kanban',
|
|
16
|
+
'typename.label_zero': 'Kanbans',
|
|
17
|
+
'typename.label_one': 'Kanban',
|
|
18
|
+
'typename.label_other': 'Kanbans',
|
|
19
|
+
'object-name.placeholder': 'New kanban',
|
|
20
|
+
'add-object.label': 'Add kanban',
|
|
21
|
+
'rename-object.label': 'Rename kanban',
|
|
22
|
+
'delete-object.label': 'Delete kanban',
|
|
23
|
+
'object-deleted.label': 'Kanban deleted',
|
|
23
24
|
},
|
|
24
25
|
[meta.id]: {
|
|
25
|
-
'action
|
|
26
|
-
'plugin
|
|
27
|
-
'kanban
|
|
28
|
-
'column
|
|
29
|
-
'column
|
|
30
|
-
'add
|
|
31
|
-
'add
|
|
32
|
-
'new
|
|
33
|
-
'remove
|
|
34
|
-
'remove
|
|
35
|
-
'column
|
|
36
|
-
'delete
|
|
37
|
-
'card
|
|
38
|
-
'card
|
|
39
|
-
'select
|
|
26
|
+
'action-menu.label': 'Actions',
|
|
27
|
+
'plugin.name': 'Kanban',
|
|
28
|
+
'kanban-title.label': 'Title',
|
|
29
|
+
'column-title.label': 'Column title',
|
|
30
|
+
'column-title.placeholder': 'New column',
|
|
31
|
+
'add-column.label': 'Add column',
|
|
32
|
+
'add-card.label': 'Add card',
|
|
33
|
+
'new-column-name.label': 'New column name',
|
|
34
|
+
'remove-card.label': 'Remove card',
|
|
35
|
+
'remove-empty-column.label': 'Remove empty column',
|
|
36
|
+
'column-drag-handle.label': 'Drag to rearrange',
|
|
37
|
+
'delete-column.label': 'Delete column',
|
|
38
|
+
'card-field-deleted.label': 'Card field deleted',
|
|
39
|
+
'card-deleted.label': 'Card deleted',
|
|
40
|
+
'select-pivot.placeholder': 'Select a pivot column in board settings to display columns.',
|
|
40
41
|
},
|
|
41
42
|
},
|
|
42
43
|
},
|
package/src/types/Kanban.ts
CHANGED
|
@@ -4,15 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
7
|
+
import { Annotation, Obj, Ref, Type } from '@dxos/echo';
|
|
8
8
|
import { View } from '@dxos/echo';
|
|
9
9
|
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
10
|
import { ViewAnnotation } from '@dxos/schema';
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Per-column entry: ordered card ids plus an optional `hidden` flag that
|
|
14
|
+
* removes the column from the rendered board (and from the model's column
|
|
15
|
+
* list). Today only the uncategorized column is exposed in settings, but
|
|
16
|
+
* the data structure supports per-column hiding generally.
|
|
17
|
+
*/
|
|
13
18
|
const ArrangementColumnEntry = Schema.Struct({
|
|
14
19
|
ids: Schema.Array(Obj.ID),
|
|
15
|
-
hidden: Schema.
|
|
20
|
+
hidden: Schema.Boolean.pipe(Schema.optional),
|
|
16
21
|
});
|
|
17
22
|
|
|
18
23
|
/** Keyed by columnValue. */
|
|
@@ -29,39 +34,118 @@ export const Arrangement = Schema.Struct({
|
|
|
29
34
|
|
|
30
35
|
export type Arrangement = Schema.Schema.Type<typeof Arrangement>;
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
/**
|
|
38
|
+
* v1: pre-existing Kanban shape. Retained as the source for the v1→v2 migration.
|
|
39
|
+
*/
|
|
40
|
+
export const KanbanV1 = Schema.Struct({
|
|
41
|
+
name: Schema.String.pipe(Schema.optional),
|
|
42
|
+
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
43
|
+
arrangement: Arrangement,
|
|
44
|
+
}).pipe(
|
|
45
|
+
Type.object({
|
|
46
|
+
typename: 'org.dxos.type.kanban',
|
|
47
|
+
version: '0.1.0',
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
34
50
|
|
|
51
|
+
//
|
|
52
|
+
// v2 — `spec` is a discriminated union of how items are sourced.
|
|
53
|
+
//
|
|
54
|
+
// Mirrors the canonical DXOS pattern (see `Trigger.Spec` in
|
|
55
|
+
// `@dxos/functions/src/types/Trigger.ts` and `Sequence.Source` in
|
|
56
|
+
// `@dxos/plugin-zen`): the `Type.object` schema is a flat `Schema.Struct`,
|
|
57
|
+
// and the discriminated union lives one level down as a single field whose
|
|
58
|
+
// variants are tagged with a `kind` literal.
|
|
59
|
+
//
|
|
60
|
+
|
|
61
|
+
/** View-variant: items come from running the View's query (the original behaviour). */
|
|
62
|
+
export const KanbanViewSpec = Schema.Struct({
|
|
63
|
+
kind: Schema.Literal('view').pipe(FormInputAnnotation.set(false)),
|
|
35
64
|
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
65
|
+
});
|
|
66
|
+
export type KanbanViewSpec = Schema.Schema.Type<typeof KanbanViewSpec>;
|
|
67
|
+
|
|
68
|
+
/** Items-variant: kanban owns its items as an explicit ref array (used by externally-synced kanbans). */
|
|
69
|
+
export const KanbanItemsSpec = Schema.Struct({
|
|
70
|
+
kind: Schema.Literal('items').pipe(FormInputAnnotation.set(false)),
|
|
71
|
+
/** Property path on each item that drives column membership (e.g. `'listName'`). */
|
|
72
|
+
pivotField: Schema.String,
|
|
73
|
+
/** Items owned directly by the kanban. */
|
|
74
|
+
items: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(FormInputAnnotation.set(false)),
|
|
75
|
+
});
|
|
76
|
+
export type KanbanItemsSpec = Schema.Schema.Type<typeof KanbanItemsSpec>;
|
|
36
77
|
|
|
37
|
-
|
|
78
|
+
/** Discriminated union of source specs. Distinguished by `kind`. */
|
|
79
|
+
export const KanbanSpec = Schema.Union(KanbanViewSpec, KanbanItemsSpec);
|
|
80
|
+
export type KanbanSpec = Schema.Schema.Type<typeof KanbanSpec>;
|
|
81
|
+
|
|
82
|
+
export const Kanban = Schema.Struct({
|
|
83
|
+
name: Schema.String.pipe(Schema.optional),
|
|
38
84
|
arrangement: Arrangement,
|
|
85
|
+
/** How this kanban sources its items. Discriminated by `spec.kind`. */
|
|
86
|
+
spec: KanbanSpec,
|
|
39
87
|
}).pipe(
|
|
40
88
|
Type.object({
|
|
41
|
-
typename: 'dxos.
|
|
42
|
-
version: '0.
|
|
89
|
+
typename: 'org.dxos.type.kanban',
|
|
90
|
+
version: '0.2.0',
|
|
43
91
|
}),
|
|
44
92
|
LabelAnnotation.set(['name']),
|
|
45
|
-
ViewAnnotation.set(
|
|
93
|
+
ViewAnnotation.set(['spec', 'view']),
|
|
94
|
+
Annotation.IconAnnotation.set({
|
|
95
|
+
icon: 'ph--kanban--regular',
|
|
96
|
+
hue: 'green',
|
|
97
|
+
}),
|
|
46
98
|
);
|
|
47
99
|
|
|
48
|
-
/** Instance type;
|
|
100
|
+
/** Instance type; narrow on `kanban.spec.kind` (or use the guards below). */
|
|
49
101
|
export interface Kanban extends Schema.Schema.Type<typeof Kanban> {}
|
|
50
102
|
|
|
51
|
-
|
|
103
|
+
/** Narrowed view-variant kanban. */
|
|
104
|
+
export type KanbanView = Kanban & { spec: KanbanViewSpec };
|
|
105
|
+
|
|
106
|
+
/** Narrowed items-variant kanban. */
|
|
107
|
+
export type KanbanItems = Kanban & { spec: KanbanItemsSpec };
|
|
108
|
+
|
|
109
|
+
export const isKanbanView = (kanban: Kanban): kanban is KanbanView => kanban.spec.kind === 'view';
|
|
110
|
+
export const isKanbanItems = (kanban: Kanban): kanban is KanbanItems => kanban.spec.kind === 'items';
|
|
111
|
+
|
|
112
|
+
type MakeViewProps = {
|
|
113
|
+
name?: string;
|
|
52
114
|
view: View.View;
|
|
115
|
+
arrangement?: Arrangement;
|
|
53
116
|
};
|
|
54
117
|
|
|
55
118
|
/**
|
|
56
|
-
* Make a kanban
|
|
119
|
+
* Make a view-variant kanban (items sourced via the View's query).
|
|
57
120
|
*/
|
|
58
|
-
export const make = (props:
|
|
121
|
+
export const make = (props: MakeViewProps): Kanban => {
|
|
59
122
|
const { name, view, arrangement } = props;
|
|
60
123
|
const order = arrangement?.order ?? [];
|
|
61
124
|
const columns = arrangement?.columns ?? {};
|
|
62
125
|
return Obj.make(Kanban, {
|
|
63
126
|
name,
|
|
64
|
-
view: Ref.make(view),
|
|
65
127
|
arrangement: { order, columns },
|
|
128
|
+
spec: { kind: 'view' as const, view: Ref.make(view) },
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type MakeItemsProps = {
|
|
133
|
+
name?: string;
|
|
134
|
+
arrangement?: Arrangement;
|
|
135
|
+
pivotField: string;
|
|
136
|
+
items?: ReadonlyArray<Ref.Ref<Obj.Unknown>>;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Make an items-variant kanban (items list owned by the kanban itself, e.g. populated by a sync integration).
|
|
141
|
+
*/
|
|
142
|
+
export const makeItems = (props: MakeItemsProps): Kanban => {
|
|
143
|
+
const { name, arrangement, pivotField, items = [] } = props;
|
|
144
|
+
const order = arrangement?.order ?? [];
|
|
145
|
+
const columns = arrangement?.columns ?? {};
|
|
146
|
+
return Obj.make(Kanban, {
|
|
147
|
+
name,
|
|
148
|
+
arrangement: { order, columns },
|
|
149
|
+
spec: { kind: 'items' as const, pivotField, items },
|
|
66
150
|
});
|
|
67
151
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Capability } from '@dxos/app-framework';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { View } from '@dxos/echo';
|
|
12
|
+
|
|
13
|
+
import { meta } from '#meta';
|
|
14
|
+
|
|
15
|
+
const KANBAN_OPERATION = `${meta.id}.operation`;
|
|
16
|
+
|
|
17
|
+
export const DeleteCardFieldOutput = Schema.Struct({
|
|
18
|
+
field: View.FieldSchema.annotations({ description: 'The deleted field schema.' }),
|
|
19
|
+
props: Schema.Any.annotations({ description: 'The deleted field properties.' }),
|
|
20
|
+
index: Schema.Number.annotations({ description: 'The index the field was at.' }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type DeleteCardFieldOutput = Schema.Schema.Type<typeof DeleteCardFieldOutput>;
|
|
24
|
+
|
|
25
|
+
export const DeleteCardField = Operation.make({
|
|
26
|
+
meta: { key: `${KANBAN_OPERATION}.delete-card-field`, name: 'Delete Card Field' },
|
|
27
|
+
services: [Capability.Service],
|
|
28
|
+
input: Schema.Struct({
|
|
29
|
+
view: View.View,
|
|
30
|
+
fieldId: Schema.String,
|
|
31
|
+
}),
|
|
32
|
+
output: DeleteCardFieldOutput,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const DeleteCardOutput = Schema.Struct({
|
|
36
|
+
card: Schema.Any.annotations({ description: 'The deleted card.' }),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type DeleteCardOutput = Schema.Schema.Type<typeof DeleteCardOutput>;
|
|
40
|
+
|
|
41
|
+
export const DeleteCard = Operation.make({
|
|
42
|
+
meta: { key: `${KANBAN_OPERATION}.delete-card`, name: 'Delete Card' },
|
|
43
|
+
input: Schema.Struct({
|
|
44
|
+
card: Schema.Any,
|
|
45
|
+
}),
|
|
46
|
+
output: DeleteCardOutput,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const RestoreCardField = Operation.make({
|
|
50
|
+
meta: { key: `${KANBAN_OPERATION}.restore-card-field`, name: 'Restore Card Field' },
|
|
51
|
+
services: [Capability.Service],
|
|
52
|
+
input: Schema.Struct({
|
|
53
|
+
view: View.View.annotations({ description: 'The view to restore the field to.' }),
|
|
54
|
+
field: View.FieldSchema.annotations({ description: 'The field schema to restore.' }),
|
|
55
|
+
props: Schema.Any.annotations({ description: 'The field properties to restore.' }),
|
|
56
|
+
index: Schema.Number.annotations({ description: 'The index to restore the field at.' }),
|
|
57
|
+
}),
|
|
58
|
+
output: Schema.Void,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const RestoreCard = Operation.make({
|
|
62
|
+
meta: { key: `${KANBAN_OPERATION}.restore-card`, name: 'Restore Card' },
|
|
63
|
+
input: Schema.Struct({
|
|
64
|
+
card: Schema.Any.annotations({ description: 'The card to restore.' }),
|
|
65
|
+
}),
|
|
66
|
+
output: Schema.Void,
|
|
67
|
+
});
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { afterEach, beforeEach, describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { defineObjectMigration } from '@dxos/client/echo';
|
|
9
|
+
import { Filter, JsonSchema, Obj, Query, Ref, Type, View } from '@dxos/echo';
|
|
10
|
+
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
11
|
+
import { ViewModel } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { Kanban } from './Kanban';
|
|
14
|
+
import { KanbanV1 } from './Kanban';
|
|
15
|
+
|
|
16
|
+
const TestCardSchema = Schema.Struct({ id: Schema.String }).pipe(
|
|
17
|
+
Type.object({ typename: 'com.example/TestCard', version: '0.1.0' }),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* v0.1.0 → v0.2.0 migration: nests `view` under `spec: { kind: 'view', view }`.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors the migration registered in `capabilities/migrations.ts`. Running it
|
|
24
|
+
* here against a real ECHO database verifies that the transform produces a
|
|
25
|
+
* v0.2.0-shaped object that's queryable as `Kanban.Kanban`.
|
|
26
|
+
*/
|
|
27
|
+
describe('Kanban migration v1 → v2', () => {
|
|
28
|
+
let builder: EchoTestBuilder;
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
builder = await new EchoTestBuilder().open();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
await builder.close();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const migration = defineObjectMigration({
|
|
39
|
+
from: KanbanV1,
|
|
40
|
+
to: Kanban,
|
|
41
|
+
transform: async (from) => ({
|
|
42
|
+
name: from.name,
|
|
43
|
+
arrangement: from.arrangement,
|
|
44
|
+
spec: { kind: 'view' as const, view: from.view },
|
|
45
|
+
}),
|
|
46
|
+
onMigration: async () => {},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('migrates a v1 Kanban into the v2 view-variant shape', async ({ expect }) => {
|
|
50
|
+
const { db, graph } = await builder.createDatabase();
|
|
51
|
+
await graph.schemaRegistry.register([KanbanV1, Kanban, View.View]);
|
|
52
|
+
|
|
53
|
+
// Build a real View object so the v1 Kanban has a valid ref to migrate.
|
|
54
|
+
const view = ViewModel.make({
|
|
55
|
+
query: Query.select(Filter.type(TestCardSchema)),
|
|
56
|
+
jsonSchema: JsonSchema.toJsonSchema(TestCardSchema),
|
|
57
|
+
});
|
|
58
|
+
db.add(view);
|
|
59
|
+
|
|
60
|
+
db.add(
|
|
61
|
+
Obj.make(KanbanV1, {
|
|
62
|
+
name: 'My Board',
|
|
63
|
+
view: Ref.make(view),
|
|
64
|
+
arrangement: { order: ['todo'], columns: { todo: { ids: [] } } },
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
await db.flush();
|
|
68
|
+
|
|
69
|
+
await db.runMigrations([migration]);
|
|
70
|
+
|
|
71
|
+
const results = await db.query(Filter.type(Kanban)).run();
|
|
72
|
+
expect(results).toHaveLength(1);
|
|
73
|
+
|
|
74
|
+
const migrated = results[0];
|
|
75
|
+
expect(migrated.name).toBe('My Board');
|
|
76
|
+
expect(migrated.arrangement.order).toEqual(['todo']);
|
|
77
|
+
expect(migrated.spec.kind).toBe('view');
|
|
78
|
+
if (migrated.spec.kind === 'view') {
|
|
79
|
+
expect(migrated.spec.view.dxn.toString()).toBe(Ref.make(view).dxn.toString());
|
|
80
|
+
}
|
|
81
|
+
expect(Type.getVersion(Obj.getSchema(migrated)!)).toBe('0.2.0');
|
|
82
|
+
});
|
|
83
|
+
});
|