@dxos/plugin-pipeline 0.8.4-main.2244d791bb → 0.8.4-main.3fbcb4aa9b

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 (160) hide show
  1. package/dist/lib/neutral/PipelineContainer-7MK2SS76.mjs +69 -0
  2. package/dist/lib/neutral/PipelineContainer-7MK2SS76.mjs.map +7 -0
  3. package/dist/lib/neutral/PipelinePlugin.mjs +26 -0
  4. package/dist/lib/neutral/PipelinePlugin.mjs.map +7 -0
  5. package/dist/lib/neutral/PipelinePlugin.node.mjs +21 -0
  6. package/dist/lib/neutral/PipelinePlugin.node.mjs.map +7 -0
  7. package/dist/lib/{browser/PipelineSettings-R54RTVWZ.mjs → neutral/PipelineProperties-RRPQ3V6I.mjs} +45 -56
  8. package/dist/lib/neutral/PipelineProperties-RRPQ3V6I.mjs.map +7 -0
  9. package/dist/lib/neutral/app-graph-builder-ZLGRWRJU.mjs +44 -0
  10. package/dist/lib/neutral/app-graph-builder-ZLGRWRJU.mjs.map +7 -0
  11. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  12. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  13. package/dist/lib/{browser/chunk-QWNKLHBY.mjs → neutral/chunk-ULB5DKWO.mjs} +2 -9
  14. package/dist/lib/{browser/chunk-QWNKLHBY.mjs.map → neutral/chunk-ULB5DKWO.mjs.map} +3 -3
  15. package/dist/lib/neutral/components/index.mjs +206 -0
  16. package/dist/lib/neutral/components/index.mjs.map +7 -0
  17. package/dist/lib/neutral/containers/index.mjs +9 -0
  18. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  19. package/dist/lib/neutral/create-object-ZJYFACOI.mjs +25 -0
  20. package/dist/lib/neutral/create-object-ZJYFACOI.mjs.map +7 -0
  21. package/dist/lib/neutral/hooks/index.mjs +70 -0
  22. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  23. package/dist/lib/neutral/index.mjs +7 -0
  24. package/dist/lib/neutral/meta.json +1 -0
  25. package/dist/lib/neutral/meta.mjs +7 -0
  26. package/dist/lib/neutral/meta.mjs.map +7 -0
  27. package/dist/lib/neutral/plugin.mjs +11 -0
  28. package/dist/lib/neutral/plugin.mjs.map +7 -0
  29. package/dist/lib/neutral/react-surface-TW6TRMO6.mjs +49 -0
  30. package/dist/lib/neutral/react-surface-TW6TRMO6.mjs.map +7 -0
  31. package/dist/lib/neutral/translations.mjs +38 -0
  32. package/dist/lib/neutral/translations.mjs.map +7 -0
  33. package/dist/lib/neutral/types/index.mjs +1 -0
  34. package/dist/lib/neutral/types/index.mjs.map +7 -0
  35. package/dist/types/src/PipelinePlugin.d.ts +1 -0
  36. package/dist/types/src/PipelinePlugin.d.ts.map +1 -1
  37. package/dist/types/src/PipelinePlugin.node.d.ts +4 -0
  38. package/dist/types/src/PipelinePlugin.node.d.ts.map +1 -0
  39. package/dist/types/src/PipelinePlugin.test.d.ts +2 -0
  40. package/dist/types/src/PipelinePlugin.test.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  42. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  44. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/index.d.ts +9 -3
  46. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  48. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  49. package/dist/types/src/components/{PipelineColumn.d.ts → PipelineComponent/PipelineColumn.d.ts} +4 -4
  50. package/dist/types/src/components/PipelineComponent/PipelineColumn.d.ts.map +1 -0
  51. package/dist/types/src/components/PipelineComponent/PipelineComponent.d.ts +53 -0
  52. package/dist/types/src/components/PipelineComponent/PipelineComponent.d.ts.map +1 -0
  53. package/dist/types/src/components/PipelineComponent/PipelineComponent.stories.d.ts +62 -0
  54. package/dist/types/src/components/PipelineComponent/PipelineComponent.stories.d.ts.map +1 -0
  55. package/dist/types/src/components/PipelineComponent/index.d.ts +3 -0
  56. package/dist/types/src/components/PipelineComponent/index.d.ts.map +1 -0
  57. package/dist/types/src/components/index.d.ts +1 -4
  58. package/dist/types/src/components/index.d.ts.map +1 -1
  59. package/dist/types/src/containers/PipelineContainer/PipelineContainer.d.ts +6 -0
  60. package/dist/types/src/containers/PipelineContainer/PipelineContainer.d.ts.map +1 -0
  61. package/dist/types/src/containers/PipelineContainer/PipelineContainer.stories.d.ts +76 -0
  62. package/dist/types/src/containers/PipelineContainer/PipelineContainer.stories.d.ts.map +1 -0
  63. package/dist/types/src/containers/PipelineContainer/index.d.ts +2 -0
  64. package/dist/types/src/containers/PipelineContainer/index.d.ts.map +1 -0
  65. package/dist/types/src/containers/PipelineProperties/PipelineProperties.d.ts +11 -0
  66. package/dist/types/src/containers/PipelineProperties/PipelineProperties.d.ts.map +1 -0
  67. package/dist/types/src/containers/PipelineProperties/index.d.ts +2 -0
  68. package/dist/types/src/containers/PipelineProperties/index.d.ts.map +1 -0
  69. package/dist/types/src/containers/index.d.ts +4 -0
  70. package/dist/types/src/containers/index.d.ts.map +1 -0
  71. package/dist/types/src/hooks/index.d.ts +2 -0
  72. package/dist/types/src/hooks/index.d.ts.map +1 -0
  73. package/dist/types/src/hooks/usePipelineBoardModel.d.ts +6 -0
  74. package/dist/types/src/hooks/usePipelineBoardModel.d.ts.map +1 -0
  75. package/dist/types/src/index.d.ts +0 -1
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/plugin.d.ts +3 -0
  78. package/dist/types/src/plugin.d.ts.map +1 -0
  79. package/dist/types/src/templates/research.d.ts.map +1 -1
  80. package/dist/types/src/translations.d.ts +44 -25
  81. package/dist/types/src/translations.d.ts.map +1 -1
  82. package/dist/types/src/types/index.d.ts +0 -2
  83. package/dist/types/src/types/index.d.ts.map +1 -1
  84. package/dist/types/tsconfig.tsbuildinfo +1 -1
  85. package/package.json +100 -54
  86. package/src/PipelinePlugin.node.ts +19 -0
  87. package/src/PipelinePlugin.test.ts +27 -0
  88. package/src/PipelinePlugin.tsx +7 -31
  89. package/src/capabilities/app-graph-builder.ts +40 -0
  90. package/src/capabilities/create-object.ts +29 -0
  91. package/src/capabilities/index.ts +5 -3
  92. package/src/capabilities/react-surface.tsx +53 -0
  93. package/src/components/{PipelineColumn.tsx → PipelineComponent/PipelineColumn.tsx} +67 -48
  94. package/src/components/{PipelineComponent.stories.tsx → PipelineComponent/PipelineComponent.stories.tsx} +40 -32
  95. package/src/components/PipelineComponent/PipelineComponent.tsx +140 -0
  96. package/src/components/PipelineComponent/index.ts +6 -0
  97. package/src/components/index.ts +1 -7
  98. package/src/containers/PipelineContainer/PipelineContainer.stories.tsx +230 -0
  99. package/src/containers/PipelineContainer/PipelineContainer.tsx +84 -0
  100. package/src/containers/PipelineContainer/index.ts +5 -0
  101. package/src/{components/PipelineSettings.tsx → containers/PipelineProperties/PipelineProperties.tsx} +50 -43
  102. package/src/containers/PipelineProperties/index.ts +5 -0
  103. package/src/containers/index.ts +8 -0
  104. package/src/hooks/index.ts +5 -0
  105. package/src/hooks/usePipelineBoardModel.ts +79 -0
  106. package/src/index.ts +0 -1
  107. package/src/meta.ts +1 -1
  108. package/src/plugin.ts +9 -0
  109. package/src/templates/research.ts +16 -17
  110. package/src/translations.ts +22 -21
  111. package/src/types/index.ts +0 -3
  112. package/dist/lib/browser/PipelineContainer-2BRZPECS.mjs +0 -289
  113. package/dist/lib/browser/PipelineContainer-2BRZPECS.mjs.map +0 -7
  114. package/dist/lib/browser/PipelineSettings-R54RTVWZ.mjs.map +0 -7
  115. package/dist/lib/browser/app-graph-builder-NUJB33F7.mjs +0 -65
  116. package/dist/lib/browser/app-graph-builder-NUJB33F7.mjs.map +0 -7
  117. package/dist/lib/browser/chunk-7GVESVYR.mjs +0 -42
  118. package/dist/lib/browser/chunk-7GVESVYR.mjs.map +0 -7
  119. package/dist/lib/browser/index.mjs +0 -109
  120. package/dist/lib/browser/index.mjs.map +0 -7
  121. package/dist/lib/browser/meta.json +0 -1
  122. package/dist/lib/browser/react-surface-CMTEEE6F.mjs +0 -57
  123. package/dist/lib/browser/react-surface-CMTEEE6F.mjs.map +0 -7
  124. package/dist/lib/browser/types/index.mjs +0 -10
  125. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
  126. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
  127. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
  128. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
  129. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -2
  130. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  131. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  132. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  133. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  134. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  135. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  136. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  137. package/dist/types/src/components/PipelineColumn.d.ts.map +0 -1
  138. package/dist/types/src/components/PipelineComponent.d.ts +0 -44
  139. package/dist/types/src/components/PipelineComponent.d.ts.map +0 -1
  140. package/dist/types/src/components/PipelineComponent.stories.d.ts +0 -42
  141. package/dist/types/src/components/PipelineComponent.stories.d.ts.map +0 -1
  142. package/dist/types/src/components/PipelineContainer.d.ts +0 -7
  143. package/dist/types/src/components/PipelineContainer.d.ts.map +0 -1
  144. package/dist/types/src/components/PipelineContainer.stories.d.ts +0 -56
  145. package/dist/types/src/components/PipelineContainer.stories.d.ts.map +0 -1
  146. package/dist/types/src/components/PipelineSettings.d.ts +0 -12
  147. package/dist/types/src/components/PipelineSettings.d.ts.map +0 -1
  148. package/dist/types/src/types/PipelineAction.d.ts +0 -25
  149. package/dist/types/src/types/PipelineAction.d.ts.map +0 -1
  150. package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -51
  151. package/src/capabilities/app-graph-builder/index.ts +0 -7
  152. package/src/capabilities/operation-resolver/index.ts +0 -5
  153. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -29
  154. package/src/capabilities/react-surface/index.ts +0 -7
  155. package/src/capabilities/react-surface/react-surface.tsx +0 -50
  156. package/src/components/PipelineComponent.tsx +0 -186
  157. package/src/components/PipelineContainer.stories.tsx +0 -226
  158. package/src/components/PipelineContainer.tsx +0 -61
  159. package/src/types/PipelineAction.ts +0 -29
  160. /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
@@ -1,50 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Effect from 'effect/Effect';
6
- import React from 'react';
7
-
8
- import { Capabilities, Capability } from '@dxos/app-framework';
9
- import { Surface } from '@dxos/app-framework/ui';
10
- import { InvocationTraceContainer } from '@dxos/devtools';
11
- import { Obj } from '@dxos/echo';
12
- import { Layout } from '@dxos/react-ui';
13
- import { Pipeline } from '@dxos/types';
14
-
15
- import { PipelineContainer, PipelineObjectSettings } from '../../components';
16
- import { meta } from '../../meta';
17
-
18
- export default Capability.makeModule(() =>
19
- Effect.succeed(
20
- Capability.contributes(Capabilities.ReactSurface, [
21
- Surface.create({
22
- id: meta.id,
23
- role: 'article',
24
- filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),
25
- component: ({ data, role }) => <PipelineContainer role={role} subject={data.subject} />,
26
- }),
27
- Surface.create({
28
- id: `${meta.id}/companion/invocations`,
29
- role: 'article',
30
- filter: (data): data is { companionTo: Pipeline.Pipeline } =>
31
- Obj.instanceOf(Pipeline.Pipeline, data.companionTo) && data.subject === 'invocations',
32
- component: ({ data, role }) => {
33
- const db = Obj.getDatabase(data.companionTo);
34
- // TODO(wittjosiah): Filter the invocations to those relevant to the project.
35
- return (
36
- <Layout.Main role={role}>
37
- <InvocationTraceContainer db={db} detailAxis='block' />
38
- </Layout.Main>
39
- );
40
- },
41
- }),
42
- Surface.create({
43
- id: `${meta.id}/object-settings`,
44
- role: 'object-settings',
45
- filter: (data): data is { subject: Pipeline.Pipeline } => Obj.instanceOf(Pipeline.Pipeline, data.subject),
46
- component: ({ data }) => <PipelineObjectSettings pipeline={data.subject} />,
47
- }),
48
- ]),
49
- ),
50
- );
@@ -1,186 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Atom, type Registry, useAtomValue } from '@effect-atom/atom-react';
6
- import { createContext } from '@radix-ui/react-context';
7
- import * as Schema from 'effect/Schema';
8
- import React, { type FC, type PropsWithChildren, useMemo } from 'react';
9
-
10
- import { Obj, Query } from '@dxos/echo';
11
- import { AtomObj, AtomQuery } from '@dxos/echo-atom';
12
- import { getQueryTarget } from '@dxos/plugin-space';
13
- import { getSpace, isSpace } from '@dxos/react-client/echo';
14
- import { Toolbar, type ToolbarRootProps, useTranslation } from '@dxos/react-ui';
15
- import { Board, type BoardModel, useBoard, useEventHandlerAdapter } from '@dxos/react-ui-mosaic';
16
- import { type ProjectionModel } from '@dxos/schema';
17
- import { Pipeline, type Pipeline as PipelineType } from '@dxos/types';
18
-
19
- import { meta } from '../meta';
20
-
21
- import { PipelineColumn } from './PipelineColumn';
22
-
23
- type ItemProps = {
24
- item: Obj.Unknown;
25
- projectionModel?: ProjectionModel;
26
- };
27
-
28
- const itemNoOp = ({ item }: ItemProps) => <span>{item.id}</span>;
29
-
30
- type PipelineContextValue = {
31
- Item: FC<ItemProps>;
32
- // TODO(wittjosiah): Support adding items.
33
- // If the created item doesn't match the current query, it will not be visible.
34
- // onAddItem?: (schema: Schema.Schema.AnyNoContext) => void;
35
- onAddColumn?: () => void;
36
- };
37
-
38
- //
39
- // Root
40
- //
41
-
42
- type PipelineRootProps = PropsWithChildren<
43
- PipelineContextValue & {
44
- model: BoardModel<PipelineType.Column, Obj.Unknown>;
45
- }
46
- >;
47
-
48
- const PIPELINE_ROOT = 'Pipeline.Root';
49
-
50
- const [PipelineRootContext, usePipeline] = createContext<PipelineContextValue>(PIPELINE_ROOT, {
51
- Item: itemNoOp,
52
- });
53
-
54
- const PipelineRoot = ({ model, children, ...contextValue }: PipelineRootProps) => (
55
- <PipelineRootContext {...contextValue}>
56
- <Board.Root model={model}>{children}</Board.Root>
57
- </PipelineRootContext>
58
- );
59
-
60
- PipelineRoot.displayName = PIPELINE_ROOT;
61
-
62
- //
63
- // usePipelineBoardModel
64
- //
65
-
66
- const emptyColumnsAtom = Atom.make(() => [] as PipelineType.Column[]);
67
- const emptyItemsAtom = Atom.make(() => [] as Obj.Unknown[]);
68
- const emptyPipelineModel: BoardModel<PipelineType.Column, Obj.Unknown> = {
69
- getColumnId: (data) => (data as PipelineType.Column).view.dxn.toString(),
70
- getItemId: (data) => (data as Obj.Unknown).id,
71
- isColumn: (obj: unknown): obj is PipelineType.Column => Schema.is(Pipeline.Column)(obj),
72
- isItem: (obj): obj is Obj.Unknown => Obj.isObject(obj),
73
- columns: emptyColumnsAtom,
74
- items: () => emptyItemsAtom,
75
- getColumns: () => [],
76
- getItems: () => [],
77
- };
78
-
79
- const usePipelineBoardModel = (
80
- pipeline: PipelineType.Pipeline | undefined,
81
- registry: Registry.Registry,
82
- ): BoardModel<PipelineType.Column, Obj.Unknown> =>
83
- useMemo<BoardModel<PipelineType.Column, Obj.Unknown>>(() => {
84
- if (pipeline == null) {
85
- return emptyPipelineModel;
86
- }
87
- const space = getSpace(pipeline);
88
- const columnsAtom = AtomObj.makeProperty(pipeline, 'columns');
89
- const columnAtomFamily = Atom.family<string, Atom.Atom<PipelineType.Column | undefined>>((viewKey: string) =>
90
- Atom.make((get) => {
91
- const columns = get(columnsAtom);
92
- return columns.find((c) => c.view.dxn.toString() === viewKey);
93
- }),
94
- );
95
- const itemsAtomFamily = Atom.family<string, Atom.Atom<Obj.Unknown[]>>((viewKey: string) =>
96
- Atom.make((get) => {
97
- const column = get(columnAtomFamily(viewKey));
98
- if (column == null) {
99
- return [];
100
- }
101
- const viewSnapshot = get(AtomObj.make(column.view));
102
- if (!viewSnapshot?.query?.ast) {
103
- return [];
104
- }
105
- const query = Query.fromAst(JSON.parse(JSON.stringify(viewSnapshot.query.ast)));
106
- const queryTarget = space ? getQueryTarget(query.ast, space) : undefined;
107
- if (!queryTarget) {
108
- return [];
109
- }
110
- const raw = get(AtomQuery.make(queryTarget, query));
111
- return isSpace(queryTarget) ? raw : [...raw].reverse();
112
- }),
113
- );
114
- return {
115
- getColumnId: (data) => (data as PipelineType.Column).view.dxn.toString(),
116
- getItemId: (data) => (data as Obj.Unknown).id,
117
- isColumn: (obj: unknown): obj is PipelineType.Column => Schema.is(Pipeline.Column)(obj),
118
- isItem: (obj: unknown): obj is Obj.Unknown => Obj.isObject(obj),
119
- columns: columnsAtom,
120
- items: (column) => itemsAtomFamily(column.view.dxn.toString()),
121
- getColumns: () => [...registry.get(columnsAtom)],
122
- getItems: (column) => registry.get(itemsAtomFamily(column.view.dxn.toString())) ?? [],
123
- };
124
- }, [pipeline, registry]);
125
-
126
- //
127
- // Content
128
- //
129
-
130
- const PIPELINE_CONTENT_NAME = 'Pipeline.Content';
131
-
132
- type PipelineContentProps = {
133
- pipeline: PipelineType.Pipeline;
134
- };
135
-
136
- const PipelineContent = ({ pipeline }: PipelineContentProps) => {
137
- const { model } = useBoard(PIPELINE_CONTENT_NAME);
138
- const columns = useAtomValue(model.columns);
139
- const eventHandler = useEventHandlerAdapter<PipelineType.Column, Obj.Unknown>({
140
- id: pipeline.id,
141
- // TODO(wittjosiah): Cast because columns array is readonly.
142
- items: columns as any,
143
- getId: model.getColumnId,
144
- get: (data) => data as unknown as Obj.Unknown,
145
- make: (object) => object as unknown as PipelineType.Column,
146
- canDrop: ({ source }) => model.isColumn(source.data),
147
- onChange: (mutate) => Obj.change(pipeline, (p) => mutate(p.columns)),
148
- });
149
-
150
- return <Board.Content id='pipeline' eventHandler={eventHandler} Tile={PipelineColumn} />;
151
- };
152
-
153
- PipelineContent.displayName = PIPELINE_CONTENT_NAME;
154
-
155
- //
156
- // Toolbar
157
- //
158
-
159
- const PIPELINE_TOOLBAR_NAME = 'Pipeline.Toolbar';
160
-
161
- export const PipelineToolbar = (props: ToolbarRootProps) => {
162
- const { t } = useTranslation(meta.id);
163
- const { onAddColumn } = usePipeline(PIPELINE_TOOLBAR_NAME);
164
-
165
- return (
166
- <Toolbar.Root {...props}>
167
- <Toolbar.IconButton icon='ph--plus--regular' iconOnly label={t('add column label')} onClick={onAddColumn} />
168
- </Toolbar.Root>
169
- );
170
- };
171
-
172
- PipelineToolbar.displayName = PIPELINE_TOOLBAR_NAME;
173
-
174
- //
175
- // Project
176
- //
177
-
178
- export const PipelineComponent = {
179
- Root: PipelineRoot,
180
- Content: PipelineContent,
181
- Toolbar: PipelineToolbar,
182
- };
183
-
184
- export { usePipeline, usePipelineBoardModel };
185
-
186
- export type { ItemProps, PipelineContextValue, PipelineRootProps };
@@ -1,226 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import * as Effect from 'effect/Effect';
7
- import React from 'react';
8
-
9
- import { withPluginManager } from '@dxos/app-framework/testing';
10
- import { Filter, Ref } from '@dxos/client/echo';
11
- import { Obj, Query, Tag, Type } from '@dxos/echo';
12
- import { ClientPlugin } from '@dxos/plugin-client';
13
- import { InboxPlugin } from '@dxos/plugin-inbox';
14
- import { PreviewPlugin } from '@dxos/plugin-preview';
15
- import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
16
- import { faker } from '@dxos/random';
17
- import { useDatabase, useQuery } from '@dxos/react-client/echo';
18
- import { withTheme } from '@dxos/react-ui/testing';
19
- import { translations as stackTranslations } from '@dxos/react-ui-stack';
20
- import { Stack } from '@dxos/react-ui-stack';
21
- import { Collection, View } from '@dxos/schema';
22
- import { createObjectFactory } from '@dxos/schema/testing';
23
- import { Message, Organization, Person, Pipeline, Task } from '@dxos/types';
24
-
25
- import { translations } from '../translations';
26
-
27
- import { PipelineContainer } from './PipelineContainer';
28
- import { PipelineObjectSettings } from './PipelineSettings';
29
-
30
- faker.seed(0);
31
-
32
- const DefaultStory = () => {
33
- const db = useDatabase();
34
- const pipelines = useQuery(db, Filter.type(Pipeline.Pipeline));
35
- const pipeline = pipelines[0];
36
-
37
- if (!pipeline) {
38
- return <p>Loading…</p>;
39
- }
40
-
41
- return (
42
- <Stack orientation='horizontal' size='split' rail={false} classNames='pli-0 bs-full'>
43
- <PipelineContainer role='article' subject={pipeline} />
44
- <PipelineObjectSettings pipeline={pipeline} classNames='border-is border-separator' />
45
- </Stack>
46
- );
47
- };
48
-
49
- const meta = {
50
- title: 'plugins/plugin-pipeline/PipelineContainer',
51
- render: DefaultStory,
52
- decorators: [
53
- withTheme(),
54
- withPluginManager({
55
- plugins: [
56
- ...corePlugins(),
57
- StorybookPlugin({}),
58
- ClientPlugin({
59
- types: [
60
- Tag.Tag,
61
- Pipeline.Pipeline,
62
- View.View,
63
- Collection.Collection,
64
- Organization.Organization,
65
- Task.Task,
66
- Person.Person,
67
- Message.Message,
68
- ],
69
- onClientInitialized: ({ client }) =>
70
- Effect.gen(function* () {
71
- yield* Effect.promise(() => client.halo.createIdentity());
72
- yield* Effect.promise(() => client.spaces.waitUntilReady());
73
- const space = client.spaces.default;
74
- yield* Effect.promise(() => space.waitUntilReady());
75
-
76
- const tag = space.db.add(Tag.make({ label: 'important', hue: 'green' }));
77
- const tagDxn = Obj.getDXN(tag).toString();
78
-
79
- // Create a view for Contacts.
80
- const personView = View.make({
81
- query: Query.select(Filter.type(Person.Person)),
82
- jsonSchema: Type.toJsonSchema(Person.Person),
83
- });
84
-
85
- // Create a view for Organizations.
86
- const organizationView = View.make({
87
- query: Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn)),
88
- jsonSchema: Type.toJsonSchema(Organization.Organization),
89
- });
90
-
91
- // Create a view for Tasks.
92
- const taskView = View.make({
93
- query: Query.select(Filter.type(Task.Task)).select(Filter.tag(tagDxn)),
94
- jsonSchema: Type.toJsonSchema(Task.Task),
95
- });
96
-
97
- // Create a view for Project-Projects.
98
- const projectView = View.make({
99
- query: Query.select(Filter.type(Pipeline.Pipeline)),
100
- jsonSchema: Type.toJsonSchema(Pipeline.Pipeline),
101
- });
102
-
103
- // Create a view for Messages.
104
- const messageQueue = space.queues.create();
105
- const messageView = View.make({
106
- query: Query.select(Filter.type(Message.Message)).options({
107
- queues: [messageQueue.dxn.toString()],
108
- }),
109
- jsonSchema: Type.toJsonSchema(Message.Message),
110
- });
111
-
112
- // Create pipline with columns.
113
- const pipeline = Pipeline.make({
114
- columns: [
115
- {
116
- name: 'Contacts',
117
- view: Ref.make(personView),
118
- order: [],
119
- },
120
- {
121
- name: 'Organizations',
122
- view: Ref.make(organizationView),
123
- order: [],
124
- },
125
- {
126
- name: 'Tasks',
127
- view: Ref.make(taskView),
128
- order: [],
129
- },
130
- {
131
- name: 'Projects',
132
- view: Ref.make(projectView),
133
- order: [],
134
- },
135
- {
136
- name: 'Messages',
137
- view: Ref.make(messageView),
138
- order: [],
139
- },
140
- ],
141
- });
142
-
143
- // Add pipeline to space.
144
- space.db.add(pipeline);
145
-
146
- // Generate sample Organizations
147
- Array.from({ length: 20 }).forEach(() => {
148
- const org = Obj.make(
149
- Organization.Organization,
150
- {
151
- name: faker.company.name(),
152
- website: faker.internet.url(),
153
- description: faker.lorem.paragraph(),
154
- image: faker.image.url(),
155
- },
156
- {
157
- tags: faker.datatype.boolean() ? [Obj.getDXN(tag).toString()] : [],
158
- },
159
- );
160
- space.db.add(org);
161
- });
162
-
163
- // Generate sample Tasks
164
- Array.from({ length: 20 }).forEach(() => {
165
- const task = Obj.make(
166
- Task.Task,
167
- {
168
- title: faker.lorem.sentence(),
169
- status: faker.helpers.arrayElement(['todo', 'in-progress', 'done']) as any,
170
- priority: faker.helpers.arrayElement(['low', 'medium', 'high']) as any,
171
- },
172
- {
173
- tags: faker.datatype.boolean() ? [Obj.getDXN(tag).toString()] : [],
174
- },
175
- );
176
- space.db.add(task);
177
- });
178
-
179
- // Generate sample Contacts
180
- const factory = createObjectFactory(space.db, faker as any);
181
- yield* Effect.promise(() => factory([{ type: Person.Person, count: 12 }]));
182
-
183
- // Generate sample Projects
184
- Array.from({ length: 20 }).forEach(() => {
185
- const nestedProject = Pipeline.make({
186
- name: faker.commerce.productName(),
187
- description: faker.lorem.sentence(),
188
- });
189
- space.db.add(nestedProject);
190
- });
191
-
192
- // Generate sample Messages
193
- const messages = Array.from({ length: 20 }).map(() => {
194
- const message = Obj.make(Message.Message, {
195
- created: faker.date.recent().toISOString(),
196
- sender: { role: 'user' },
197
- blocks: [
198
- {
199
- _tag: 'text' as const,
200
- text: faker.lorem.sentences(2),
201
- },
202
- ],
203
- });
204
- return message;
205
- });
206
-
207
- yield* Effect.promise(() => messageQueue.append(messages));
208
- }),
209
- }),
210
-
211
- InboxPlugin(),
212
- PreviewPlugin(),
213
- ],
214
- }),
215
- ],
216
- parameters: {
217
- layout: 'fullscreen',
218
- translations: [...translations, ...stackTranslations],
219
- },
220
- } satisfies Meta<typeof PipelineContainer>;
221
-
222
- export default meta;
223
-
224
- type Story = StoryObj<typeof meta>;
225
-
226
- export const Default: Story = {};
@@ -1,61 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { useCallback } from 'react';
6
-
7
- import { Capabilities } from '@dxos/app-framework';
8
- import { useCapability } from '@dxos/app-framework/ui';
9
- import { useOperationInvoker } from '@dxos/app-framework/ui';
10
- import { Surface } from '@dxos/app-framework/ui';
11
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
12
- import { Obj } from '@dxos/echo';
13
- import { ATTENDABLE_PATH_SEPARATOR, DeckOperation } from '@dxos/plugin-deck/types';
14
- import { Layout } from '@dxos/react-ui';
15
- import { useAttention } from '@dxos/react-ui-attention';
16
- import { type Pipeline as PipelineType } from '@dxos/types';
17
-
18
- import { type ItemProps, PipelineComponent, usePipelineBoardModel } from './PipelineComponent';
19
-
20
- export type PipelineContainerProps = SurfaceComponentProps<PipelineType.Pipeline>;
21
-
22
- export const PipelineContainer = ({ role, subject: pipeline }: PipelineContainerProps) => {
23
- const registry = useCapability(Capabilities.AtomRegistry);
24
- const model = usePipelineBoardModel(pipeline, registry);
25
- const { invokePromise } = useOperationInvoker();
26
- const attendableId = Obj.getDXN(pipeline).toString();
27
- const { hasAttention } = useAttention(attendableId);
28
-
29
- const handleColumnAdd = useCallback(
30
- () =>
31
- invokePromise(DeckOperation.ChangeCompanion, {
32
- primary: attendableId,
33
- companion: `${attendableId}${ATTENDABLE_PATH_SEPARATOR}settings`,
34
- }),
35
- [invokePromise, attendableId],
36
- );
37
-
38
- return (
39
- <Layout.Main role={role} toolbar>
40
- <PipelineComponent.Root Item={PipelineItem} model={model} onAddColumn={handleColumnAdd}>
41
- <PipelineComponent.Toolbar disabled={!hasAttention} />
42
- <PipelineComponent.Content pipeline={pipeline} />
43
- </PipelineComponent.Root>
44
- </Layout.Main>
45
- );
46
- };
47
-
48
- const PipelineItem = ({ item, projectionModel }: ItemProps) => {
49
- return (
50
- <Surface.Surface
51
- role='card--content'
52
- data={{
53
- subject: item,
54
- projection: projectionModel,
55
- }}
56
- limit={1}
57
- />
58
- );
59
- };
60
-
61
- export default PipelineContainer;
@@ -1,29 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Schema from 'effect/Schema';
6
-
7
- import { Capability } from '@dxos/app-framework';
8
- import { Operation } from '@dxos/operation';
9
- import { SpaceSchema } from '@dxos/react-client/echo';
10
- import { Collection } from '@dxos/schema';
11
-
12
- import { meta } from '../meta';
13
-
14
- const PIPELINE_OPERATION = `${meta.id}/operation`;
15
-
16
- export namespace PipelineOperation {
17
- export const OnCreateSpace = Operation.make({
18
- meta: { key: `${PIPELINE_OPERATION}/on-create-space`, name: 'On Create Space' },
19
- services: [Capability.Service],
20
- schema: {
21
- input: Schema.Struct({
22
- space: SpaceSchema,
23
- rootCollection: Collection.Collection,
24
- isDefault: Schema.optional(Schema.Boolean),
25
- }),
26
- output: Schema.Void,
27
- },
28
- });
29
- }