@powerhousedao/academy 5.1.0-dev.9 → 5.1.0
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/CHANGELOG.md +43 -1108
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +1 -2
- package/blog/TheChallengeOfChange.md +0 -1
- package/docs/academy/00-EthereumArgentinaHackathon.md +207 -0
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +27 -24
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +9 -118
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +28 -110
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +145 -191
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +218 -0
- package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/05-VetraStudio.md +6 -48
- package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
- package/docs/academy/01-GetStarted/_04-BuildToDoListEditor +1 -1
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +2 -2
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +44 -75
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +22 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +31 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +206 -211
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +62 -176
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +0 -21
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +319 -309
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +0 -4
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +0 -4
- package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -1
- package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +35 -111
- package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +76 -255
- package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +160 -281
- package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +35 -188
- package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +7 -95
- package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
- package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +2 -6
- package/docs/academy/04-APIReferences/01-ReactHooks.md +501 -291
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +39 -7
- package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
- package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
- package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +24 -72
- package/docs/academy/08-Glossary.md +0 -7
- package/docusaurus.config.ts +3 -28
- package/package.json +1 -1
- package/sidebars.ts +12 -49
- package/src/css/custom.css +18 -26
- package/docs/academy/01-GetStarted/04-WriteDocumentModelTests.md +0 -378
- package/docs/academy/01-GetStarted/05-BuildToDoListEditor.md +0 -560
- package/docs/academy/03-ExampleUsecases/TodoList/00-GetTheStarterCode.md +0 -24
- package/docs/academy/03-ExampleUsecases/TodoList/01-GenerateTodoListDocumentModel.md +0 -211
- package/docs/academy/03-ExampleUsecases/TodoList/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/03-ExampleUsecases/TodoList/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/03-ExampleUsecases/TodoList/04-GenerateTodoListDocumentEditor.md +0 -45
- package/docs/academy/03-ExampleUsecases/TodoList/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/03-ExampleUsecases/TodoList/06-GenerateTodoDriveExplorer.md +0 -61
- package/docs/academy/03-ExampleUsecases/TodoList/07-AddSharedComponentForShowingTodoListStats.md +0 -384
- package/docs/academy/03-ExampleUsecases/TodoList/_category_.json +0 -8
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/VetraPackageLibrary.md +0 -7
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/_category_.json +0 -9
- package/docs/academy/04-APIReferences/06-VetraRemoteDrive.md +0 -160
- package/docs/academy/04-APIReferences/renown-sdk/00-Overview.md +0 -316
- package/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md +0 -672
- package/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md +0 -957
- package/docs/academy/04-APIReferences/renown-sdk/_category_.json +0 -8
- package/docs/academy/10-TodoListTutorial/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/10-TodoListTutorial/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/10-TodoListTutorial/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/10-TodoListTutorial/07-AddSharedComponentForShowingTodoListStats.md +0 -370
- package/static/img/Vetra-logo-dark.svg +0 -11
- package/static/img/vetra-logo-light.svg +0 -11
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/Modules.png +0 -0
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/VetraStudioDrive.png +0 -0
- /package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/{02-RevisionHistoryTimeline/360/237/232/247" → 02-RevisionHistoryTimeline} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /01-WhatIsADocumentModel" → 01-WhatIsADocumentModel} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-DAOandDocumentsModelsQ+A" → 02-DAOandDocumentsModelsQ+A} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-domain-modeling" → 02-domain-modeling} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /03-BenefitsOfDocumentModels" → 03-BenefitsOfDocumentModels} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /04-UtilitiesAndTips" → 04-UtilitiesAndTips} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /05-best-practices" → 05-best-practices} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /_category_.json" → _category_.json} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /three-data-layers.png" → three-data-layers.png} +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Build a to-do list editor
|
|
2
|
+
|
|
3
|
+
In this chapter we will continue with the interface or editor implementation of the **To-do List** document model. This means you will create a simple user interface for the **To-do List** document model which will be used inside the Connect app to create, update and delete your ToDoList items.
|
|
4
|
+
|
|
5
|
+
## Generate the editor template
|
|
6
|
+
|
|
7
|
+
Run the command below to generate the editor template for the **To-do List** document model.
|
|
8
|
+
This command reads the **To-do List** document model definition from the `document-models` folder and generates the editor template in the `editors/to-do-list` folder as `editor.tsx`.
|
|
9
|
+
|
|
10
|
+
Notice the `--editor` flag which specifies the **To-do List** document model, and the `--document-types` flag defines the document type `powerhouse/todolist`.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
ph generate --editor ToDoList --document-types powerhouse/todolist
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Once complete, navigate to the `editors/to-do-list/editor.tsx` file and open it in your editor.
|
|
17
|
+
|
|
18
|
+
### Editor implementation options
|
|
19
|
+
|
|
20
|
+
When building your editor component within the Powerhouse ecosystem, you have several options for styling, allowing you to leverage your preferred methods:
|
|
21
|
+
|
|
22
|
+
1. **Default HTML Styling:** Standard HTML tags (`<h1>`, `<p>`, `<button>`, etc.) will render with default styles offered through the boilerplate.
|
|
23
|
+
2. **Tailwind CSS:** Connect Studio comes with Tailwind CSS integrated. You can directly use Tailwind utility classes for rapid, consistent styling without writing separate CSS files.
|
|
24
|
+
3. **Custom CSS Files:** You can import traditional CSS files (`.css`) to apply custom styles or integrate existing style libraries.
|
|
25
|
+
|
|
26
|
+
Connect Studio provides a dynamic local environment, by running `ph connect` to visualize your components instantly as you build them, regardless of the styling method you choose.
|
|
27
|
+
Manual build steps are typically only needed when publishing packages.
|
|
28
|
+
|
|
29
|
+
## To-do List editor
|
|
30
|
+
|
|
31
|
+
Below is the complete code for the To-Do List editor. Paste this code in `editors/to-do-list/editor.tsx`.
|
|
32
|
+
|
|
33
|
+
<details>
|
|
34
|
+
<summary>Complete ToDoList Editor Example (using Tailwind CSS)</summary>
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { EditorProps } from 'document-model';
|
|
38
|
+
import {
|
|
39
|
+
ToDoListState,
|
|
40
|
+
ToDoListAction,
|
|
41
|
+
ToDoListLocalState,
|
|
42
|
+
ToDoItem,
|
|
43
|
+
actions,
|
|
44
|
+
ToDoListDocument,
|
|
45
|
+
} from '../../document-models/to-do-list/index.js';
|
|
46
|
+
import { useState } from 'react';
|
|
47
|
+
|
|
48
|
+
// EditorProps is a generic type that provides the document and a dispatch function.
|
|
49
|
+
// The dispatch function is used to send actions to the document's reducer to update the state.
|
|
50
|
+
export type IProps = EditorProps<ToDoListDocument>;
|
|
51
|
+
|
|
52
|
+
export default function Editor(props: IProps) {
|
|
53
|
+
// Destructure document and dispatch from props.
|
|
54
|
+
const { document, dispatch } = props;
|
|
55
|
+
// Get the global state from the document. This state is shared across all editors of this document.
|
|
56
|
+
const {
|
|
57
|
+
state: { global: state },
|
|
58
|
+
} = document;
|
|
59
|
+
|
|
60
|
+
// React's useState hook is used for local component state.
|
|
61
|
+
// This state is not shared with other components.
|
|
62
|
+
// `todoItem` stores the text of the new to-do item being added.
|
|
63
|
+
const [todoItem, setTodoItem] = useState('');
|
|
64
|
+
// `editingItemId` stores the ID of the item currently being edited.
|
|
65
|
+
const [editingItemId, setEditingItemId] = useState<string | null>(null);
|
|
66
|
+
// `editedText` stores the text of the item while it's being edited.
|
|
67
|
+
const [editedText, setEditedText] = useState('');
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className="p-4 font-sans max-w-lg mx-auto">
|
|
71
|
+
<h1 className="text-2xl font-bold mb-4 text-center">To-do List</h1>
|
|
72
|
+
<div className="w-96 mx-auto">
|
|
73
|
+
<div className="flex mb-4">
|
|
74
|
+
<input
|
|
75
|
+
className="border border-gray-300 p-2 rounded-l-md flex-grow"
|
|
76
|
+
placeholder="Insert task here..."
|
|
77
|
+
value={todoItem}
|
|
78
|
+
onChange={e => setTodoItem(e.target.value)}
|
|
79
|
+
onKeyDown={e => {
|
|
80
|
+
if (e.key === 'Enter') {
|
|
81
|
+
// Dispatch an action to add a new to-do item.
|
|
82
|
+
// `actions.addTodoItem` is an action creator from our document model.
|
|
83
|
+
dispatch(
|
|
84
|
+
actions.addTodoItem({
|
|
85
|
+
id: Math.random().toString(), // In a real app, use a more robust ID generation.
|
|
86
|
+
text: todoItem,
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
setTodoItem('');
|
|
90
|
+
}
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
<button
|
|
94
|
+
className="bg-blue-500 hover:bg-blue-600 text-white p-2 rounded-r-md"
|
|
95
|
+
onClick={() => {
|
|
96
|
+
// Also add item on button click.
|
|
97
|
+
dispatch(
|
|
98
|
+
actions.addTodoItem({
|
|
99
|
+
id: Math.random().toString(),
|
|
100
|
+
text: todoItem,
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
setTodoItem('');
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
Add
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
<ul className="list-none p-0">
|
|
110
|
+
{/* Map over the items in the global state to render each to-do item. */}
|
|
111
|
+
{state.items.map((item: ToDoItem) => (
|
|
112
|
+
<li
|
|
113
|
+
key={item.id}
|
|
114
|
+
className="flex items-center p-2 relative border-b border-gray-200"
|
|
115
|
+
>
|
|
116
|
+
<input
|
|
117
|
+
type="checkbox"
|
|
118
|
+
checked={item.checked}
|
|
119
|
+
className="mr-3"
|
|
120
|
+
onChange={() => {
|
|
121
|
+
// Dispatch an action to update the checked status of an item.
|
|
122
|
+
dispatch(
|
|
123
|
+
actions.updateTodoItem({
|
|
124
|
+
id: item.id,
|
|
125
|
+
checked: !item.checked,
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
{/* Conditional rendering: show an input field if the item is being edited, otherwise show the text. */}
|
|
131
|
+
{editingItemId === item.id ? (
|
|
132
|
+
<input
|
|
133
|
+
value={editedText}
|
|
134
|
+
onChange={e =>
|
|
135
|
+
setEditedText(e.target.value)
|
|
136
|
+
}
|
|
137
|
+
onKeyDown={e => {
|
|
138
|
+
if (e.key === 'Enter') {
|
|
139
|
+
// Dispatch an action to update the item's text.
|
|
140
|
+
dispatch(
|
|
141
|
+
actions.updateTodoItem({
|
|
142
|
+
id: item.id,
|
|
143
|
+
text: editedText,
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
// Exit editing mode.
|
|
147
|
+
setEditingItemId(null);
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
150
|
+
className="flex-grow"
|
|
151
|
+
autoFocus // Automatically focus the input when it appears.
|
|
152
|
+
/>
|
|
153
|
+
) : (
|
|
154
|
+
<div className="flex items-center flex-grow gap-1">
|
|
155
|
+
<span
|
|
156
|
+
onClick={() => {
|
|
157
|
+
// Enter editing mode when the text is clicked.
|
|
158
|
+
setEditingItemId(item.id);
|
|
159
|
+
setEditedText(item.text);
|
|
160
|
+
}}
|
|
161
|
+
className={`cursor-pointer ${
|
|
162
|
+
item.checked
|
|
163
|
+
? 'line-through text-gray-500'
|
|
164
|
+
: ''
|
|
165
|
+
}`}
|
|
166
|
+
>
|
|
167
|
+
{item.text}
|
|
168
|
+
</span>
|
|
169
|
+
<span
|
|
170
|
+
onClick={() =>
|
|
171
|
+
dispatch(
|
|
172
|
+
actions.deleteTodoItem({
|
|
173
|
+
id: item.id,
|
|
174
|
+
})
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
className="text-gray-400 cursor-pointer opacity-40 transition-all duration-200 text-base font-bold inline-flex items-center pl-1 hover:opacity-100 hover:text-red-500"
|
|
178
|
+
>
|
|
179
|
+
×
|
|
180
|
+
</span>
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
</li>
|
|
184
|
+
))}
|
|
185
|
+
</ul>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
</details>
|
|
193
|
+
|
|
194
|
+
Now you can run the Connect app and see the **To-do List** editor in action.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
ph connect
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
In Connect, in the bottom right corner you'll find a new Document Model that you can create: **To-do List**.
|
|
201
|
+
Click on it to create a new To-do List document.
|
|
202
|
+
|
|
203
|
+
:::info
|
|
204
|
+
The editor will update dynamically, so you can play around with your editor styling while seeing your results appear in Connect Studio.
|
|
205
|
+
:::
|
|
206
|
+
|
|
207
|
+
Congratulations!
|
|
208
|
+
If you managed to follow this tutorial until this point, you have successfully implemented the **To-do List** document model with its reducer operations and editor.
|
|
209
|
+
|
|
210
|
+
### Up next: Mastery Track
|
|
211
|
+
|
|
212
|
+
In the [Mastery Track chapther: Document Model Creation](/academy/MasteryTrack/DocumentModelCreation/WhatIsADocumentModel) we guide you through the theoretics of the previous steps while created a more advanced version of the To-do List.
|
|
213
|
+
|
|
214
|
+
You will learn:
|
|
215
|
+
|
|
216
|
+
- The in's & out's of a document model.
|
|
217
|
+
- How to use UI & Scalar components from the Document Engineering system.
|
|
218
|
+
- How to build Custom Drive Apps or Drive Explorers.
|
package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/05-VetraStudio.md
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Vetra Studio
|
|
1
|
+
# Tool: Vetra Studio
|
|
2
2
|
|
|
3
3
|
:::tip Important
|
|
4
4
|
|
|
@@ -77,28 +77,6 @@ You could then add the specific remote Vetra drive to your powerhouse configurat
|
|
|
77
77
|
|
|
78
78
|
An example of a builder team building on the Powerhouse Vetra Ecosystem and it's complementary Vetra Studio Drive specifications for the different packages be found [here](https://vetra.io/builders/bai)
|
|
79
79
|
|
|
80
|
-
<details>
|
|
81
|
-
<summary>📦 Vetra Remote Drive Commands</summary>
|
|
82
|
-
|
|
83
|
-
Remote drives enable collaborative development by syncing specifications across team members.
|
|
84
|
-
|
|
85
|
-
**Key Commands:**
|
|
86
|
-
- `ph init --remote-drive <url>` - Create a NEW project connected to a remote drive
|
|
87
|
-
- `ph checkout --remote-drive <url>` - Clone an EXISTING project from a remote drive
|
|
88
|
-
- `ph vetra --watch` - Start development with a preview drive for testing local changes
|
|
89
|
-
|
|
90
|
-
**Workflows:**
|
|
91
|
-
- **Project Owner**: `ph init --remote-drive` → Create GitHub repo → Push → `ph vetra` to configure
|
|
92
|
-
- **Collaborator**: `ph checkout --remote-drive` → `ph vetra` to start developing
|
|
93
|
-
|
|
94
|
-
**Preview Drive (`--watch` mode):**
|
|
95
|
-
- Main "Vetra" drive syncs with remote and contains stable package configuration
|
|
96
|
-
- "Vetra Preview" drive is created locally for testing document models before syncing
|
|
97
|
-
|
|
98
|
-
→ [Full Vetra Remote Drive Reference](/academy/APIReferences/VetraRemoteDrive)
|
|
99
|
-
|
|
100
|
-
</details>
|
|
101
|
-
|
|
102
80
|
## Vetra Studio Workflow
|
|
103
81
|
|
|
104
82
|
### 1. Launch Vetra Studio
|
|
@@ -168,35 +146,16 @@ Connected to MCP successfully! I can see there's a
|
|
|
168
146
|
running and ready for document model operations.
|
|
169
147
|
```
|
|
170
148
|
|
|
149
|
+
- To learn what is a [Reactor](apps/academy/docs/academy/Architecture/WorkingWithTheReactor) read the reactor article
|
|
150
|
+
- To learn more about the [Reactor MCP](apps/academy/docs/academy/GetStarted/ReactorMCP) read the reactor MCP article
|
|
151
|
+
|
|
171
152
|
### Key Reactor MCP Features
|
|
172
153
|
|
|
173
154
|
- It supports automatic document model creation from natural language descriptions
|
|
174
155
|
- It implements a smart editor based on the underlying document models
|
|
175
156
|
- It automatically triggers code generation when documents reach valid state
|
|
176
|
-
- The MCP server enables the agent to work with both existing and newly created document models
|
|
177
|
-
- Vetra supports integration with custom remote drives, allowing users to create, share and manage documents within these drives
|
|
178
|
-
|
|
179
|
-
<details>
|
|
180
|
-
<summary>🤖 Reactor MCP Overview</summary>
|
|
181
|
-
|
|
182
|
-
**Reactor-mcp** is a Model Context Protocol (MCP) server that bridges AI agents with Powerhouse document operations.
|
|
183
|
-
|
|
184
|
-
**Document Operations:**
|
|
185
|
-
- `createDocument` / `getDocument` / `deleteDocument` - Manage documents
|
|
186
|
-
- `addActions` - Modify document state through operations
|
|
187
|
-
|
|
188
|
-
**Drive Operations:**
|
|
189
|
-
- `getDrives` / `addDrive` / `getDrive` - Manage document drives
|
|
190
|
-
- `addRemoteDrive` - Connect to remote drives
|
|
191
|
-
|
|
192
|
-
**Document Model Operations:**
|
|
193
|
-
- `getDocumentModels` - List available document model types
|
|
194
|
-
- `getDocumentModelSchema` - Get schema for specific models
|
|
195
|
-
|
|
196
|
-
**Document Model Agent:**
|
|
197
|
-
A specialized AI agent that guides users through document model creation with requirements gathering, design confirmation, and implementation including state schema definition, operation creation, and code generation.
|
|
198
|
-
|
|
199
|
-
</details>
|
|
157
|
+
- The MCP server enables the agent to work with both existing and newly created document models.
|
|
158
|
+
- Vetra supports integration with custom remote drives, allowing users to create, share and manage documents within these drives.
|
|
200
159
|
|
|
201
160
|
|
|
202
161
|
### 3. Vetra Studio Package Creation Workflow
|
|
@@ -252,4 +211,3 @@ Support for:
|
|
|
252
211
|
- Verify implementation details in generated code before continuing.
|
|
253
212
|
- Always double-check proposed next actions
|
|
254
213
|
|
|
255
|
-
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Tool: Reactor MCP
|
|
2
|
+
|
|
3
|
+
**Reactor-mcp** is a Model Context Protocol (MCP) server for the Powerhouse ecosystem that provides AI agents and tools with structured access to document model operations.
|
|
4
|
+
It serves as a bridge between AI systems and the Powerhouse document management infrastructure.
|
|
5
|
+
|
|
6
|
+
## Main Functions of the Reactor-mcp
|
|
7
|
+
|
|
8
|
+
**Document Operations**:
|
|
9
|
+
- createDocument - Create new documents
|
|
10
|
+
- getDocument - Retrieve documents by ID
|
|
11
|
+
- addActions - Add actions to modify document state
|
|
12
|
+
- deleteDocument - Remove documents
|
|
13
|
+
|
|
14
|
+
**Drive Operations**:
|
|
15
|
+
- getDrives - List all document drives
|
|
16
|
+
- addDrive - Create new drives
|
|
17
|
+
- getDrive - Retrieve specific drives
|
|
18
|
+
- addRemoteDrive - Connect to remote drives
|
|
19
|
+
|
|
20
|
+
**Document Model Operations**:
|
|
21
|
+
- getDocumentModels - List available document model types
|
|
22
|
+
- getDocumentModelSchema - Get schema for specific document models
|
|
23
|
+
|
|
24
|
+
<details>
|
|
25
|
+
<summary>Architecture Context</summary>
|
|
26
|
+
|
|
27
|
+
Within the broader Powerhouse ecosystem:
|
|
28
|
+
|
|
29
|
+
- Document Model: Defines structure and operations for document types
|
|
30
|
+
- Document Drive: Manages collections of documents with sync capabilities
|
|
31
|
+
- Reactor-MCP: Provides AI/tool access to document operations
|
|
32
|
+
- Connect/Switchboard: User interfaces and synchronization servers
|
|
33
|
+
|
|
34
|
+
The reactor-mcp essentially makes the sophisticated document model system accessible to AI agents and external tools through a standardized protocol, enabling programmatic document creation, modification, and management within the Powerhouse ecosystem.
|
|
35
|
+
|
|
36
|
+
</details>
|
|
37
|
+
|
|
38
|
+
### Document Model Agent
|
|
39
|
+
|
|
40
|
+
Alongside the MCP is a **specialized AI agent** for document model creation:
|
|
41
|
+
|
|
42
|
+
- Purpose: Guide users through creating document models
|
|
43
|
+
- Workflow: Requirements gathering → Design confirmation → Implementation
|
|
44
|
+
- Tools: Comprehensive set of MCP tools for model management
|
|
45
|
+
- Capabilities:
|
|
46
|
+
- State schema definition
|
|
47
|
+
- Operation creation
|
|
48
|
+
- Module organization
|
|
49
|
+
- Code generation
|
|
50
|
+
|
|
51
|
+
:::tip Supports with:
|
|
52
|
+
|
|
53
|
+
1. **AI-Assisted Document Model Creation**: AI agents can use the MCP tools to help users create and modify document models
|
|
54
|
+
2. **Automated Document Management**: Programmatic creation and management of documents and drives
|
|
55
|
+
3. **Integration with AI Tools**: Claude, GPT, or other AI systems can use this as an MCP server to interact with Powerhouse
|
|
56
|
+
4. **Development Tooling**: CLI and development server for working with document models locally
|
|
57
|
+
:::
|
|
58
|
+
|
|
@@ -10,7 +10,7 @@ This command reads the **To-do List** document model definition from the `docume
|
|
|
10
10
|
Notice the `--editor` flag which specifies the **To-do List** document model, and the `--document-types` flag defines the document type `powerhouse/todolist`.
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
13
|
+
ph generate --editor ToDoList --document-types powerhouse/todolist
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Once complete, navigate to the `editors/to-do-list/editor.tsx` file and open it in your editor.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Powerhouse builder tooling
|
|
2
2
|
|
|
3
|
-
This page provides an overview of all the builder tooling offered
|
|
3
|
+
This page provides an overview of all the builder tooling offered by the Powerhouse ecosystem.
|
|
4
4
|
This list will be maintained and updated as our toolkit grows.
|
|
5
5
|
|
|
6
6
|
## Powerhouse command line interface
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Specify the state schema
|
|
2
2
|
|
|
3
|
-
The state schema is the backbone of your document model. It defines the structure, data types, and relationships of the information your document will hold. In Powerhouse, we use the
|
|
3
|
+
The state schema is the backbone of your document model. It defines the structure, data types, and relationships of the information your document will hold. In Powerhouse, we use the GraphQL Schema Definition Language (SDL) to define this schema. A well-defined state schema is crucial for ensuring data integrity, consistency, and for enabling powerful querying and manipulation capabilities.
|
|
4
4
|
|
|
5
5
|
## Core concepts
|
|
6
6
|
|
|
7
7
|
### Types
|
|
8
8
|
|
|
9
|
-
At the heart of GraphQL SDL are **types**. Types define the shape of your data. You can define custom object types that represent the entities in your document. For example, in a `
|
|
9
|
+
At the heart of GraphQL SDL are **types**. Types define the shape of your data. You can define custom object types that represent the entities in your document. For example, in a `ToDoList` document, you might have a `ToDoListState` type and a `ToDoItem` type.
|
|
10
10
|
|
|
11
|
-
- **`
|
|
12
|
-
- **`
|
|
11
|
+
- **`ToDoListState`**: This could be the root type representing the overall state of the to-do list. It might contain a list of `ToDoItem` objects.
|
|
12
|
+
- **`ToDoItem`**: This type would represent an individual to-do item, with properties like an `id`, `text` (the task description), and `checked` (a boolean indicating if the task is completed).
|
|
13
13
|
|
|
14
14
|
### Fields
|
|
15
15
|
|
|
16
|
-
Each type has **fields**, which represent the properties of that type. Each field has a name and a type. For instance, the `
|
|
16
|
+
Each type has **fields**, which represent the properties of that type. Each field has a name and a type. For instance, the `ToDoItem` type would have an `id` field of type `ID!`, a `text` field of type `String!`, and a `checked` field of type `Boolean!`.
|
|
17
17
|
|
|
18
18
|
### Scalars
|
|
19
19
|
|
|
@@ -27,61 +27,32 @@ GraphQL has a set of built-in **scalar types**:
|
|
|
27
27
|
|
|
28
28
|
In addition to these standard types, the Powerhouse Document-Engineering system introduces custom scalars that are linked to reusable front-end components. These scalars are tailored for the web3 ecosystem and will be explored in the Component Library section of the documentation.
|
|
29
29
|
|
|
30
|
-
:::tip Custom Scalar: OID
|
|
31
|
-
Powerhouse provides the `OID` (Object ID) scalar type, which is a custom scalar specifically designed for unique identifiers in document models. It provides automatic ID generation capabilities when used with the `generateId()` function from the document-model core library.
|
|
32
|
-
:::
|
|
33
|
-
|
|
34
30
|
### Lists and non-null
|
|
35
31
|
|
|
36
32
|
You can modify types using lists and non-null indicators:
|
|
37
33
|
|
|
38
|
-
- **Lists**: To indicate that a field will return a list of a certain type, you wrap the type in square brackets, e.g., `[
|
|
39
|
-
- **Non-Null**: To indicate that a field cannot be null, you add an exclamation mark `!` after the type name, e.g., `String!`. This means that the `text` field of a `
|
|
40
|
-
|
|
41
|
-
## Example: TodoList state schema
|
|
34
|
+
- **Lists**: To indicate that a field will return a list of a certain type, you wrap the type in square brackets, e.g., `[ToDoItem!]!`. This means the field `items` in `ToDoListState` will be a list of `ToDoItem` objects.
|
|
35
|
+
- **Non-Null**: To indicate that a field cannot be null, you add an exclamation mark `!` after the type name, e.g., `String!`. This means that the `text` field of a `ToDoItem` must always have a value. The outer `!` in `[ToDoItem!]!` means the list itself cannot be null (it must be at least an empty list), and the inner `!` on `ToDoItem!` means that every item within that list must also be non-null.
|
|
42
36
|
|
|
43
|
-
|
|
37
|
+
## Example: ToDoList state schema
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
This is the same schema you built in the Get Started tutorial:
|
|
39
|
+
Let's revisit the `ToDoList` example from the "Define the ToDoList document specification" tutorial.
|
|
40
|
+
Only this time, we'll also add a 'Stats' type. Since we want to keep track of the number of completed To-Do's.
|
|
48
41
|
|
|
49
42
|
```graphql
|
|
50
|
-
# The state of our
|
|
51
|
-
type
|
|
52
|
-
items: [
|
|
43
|
+
# The state of our ToDoList
|
|
44
|
+
type ToDoListState {
|
|
45
|
+
items: [ToDoItem!]!
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
# A single to-do item
|
|
56
|
-
type
|
|
57
|
-
id:
|
|
49
|
+
type ToDoItem {
|
|
50
|
+
id: ID!
|
|
58
51
|
text: String!
|
|
59
52
|
checked: Boolean!
|
|
60
53
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
### Advanced schema (with statistics tracking)
|
|
64
|
-
|
|
65
|
-
:::info Advanced Feature
|
|
66
|
-
In this Mastery Track, we'll extend the basic schema with a `stats` field to demonstrate how you can add computed statistics to your document model. This is an **optional enhancement** that builds on the foundation from Get Started.
|
|
67
|
-
:::
|
|
68
|
-
|
|
69
|
-
```graphql
|
|
70
|
-
# The state of our TodoList (advanced version with stats)
|
|
71
|
-
type TodoListState {
|
|
72
|
-
items: [TodoItem!]!
|
|
73
|
-
stats: TodoListStats!
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
# A single to-do item
|
|
77
|
-
type TodoItem {
|
|
78
|
-
id: OID!
|
|
79
|
-
text: String!
|
|
80
|
-
checked: Boolean!
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
# The statistics on our to-do's (advanced feature)
|
|
84
|
-
type TodoListStats {
|
|
54
|
+
# The statistics on our to-do's
|
|
55
|
+
type ToDoListStats {
|
|
85
56
|
total: Int!
|
|
86
57
|
checked: Int!
|
|
87
58
|
unchecked: Int!
|
|
@@ -90,19 +61,18 @@ type TodoListStats {
|
|
|
90
61
|
|
|
91
62
|
### Breakdown:
|
|
92
63
|
|
|
93
|
-
- **`
|
|
94
|
-
- `items: [
|
|
95
|
-
- `[
|
|
96
|
-
- `
|
|
97
|
-
- The final `!` after `[
|
|
98
|
-
- `stats: TodoListStats!` *(advanced)*: Holds aggregated statistics about the to-do items.
|
|
64
|
+
- **`ToDoListState` type**:
|
|
65
|
+
- `items: [ToDoItem!]!`: This field defines that our `ToDoListState` contains a list called `items`.
|
|
66
|
+
- `[ToDoItem!]`: This signifies that `items` is a list of `ToDoItem` objects.
|
|
67
|
+
- `ToDoItem!`: The `!` after `ToDoItem` means that no item in the list can be null. Each entry must be a valid `ToDoItem`.
|
|
68
|
+
- The final `!` after `[ToDoItem!]` means that the `items` list itself cannot be null. It can be an empty list `[]`, but it cannot be absent.
|
|
99
69
|
|
|
100
|
-
- **`
|
|
101
|
-
- `id:
|
|
70
|
+
- **`ToDoItem` type**:
|
|
71
|
+
- `id: ID!`: Each `ToDoItem` has a unique identifier that cannot be null. This is crucial for referencing specific items, for example, when updating or deleting them.
|
|
102
72
|
- `text: String!`: The textual description of the to-do item. It cannot be null, ensuring every to-do has a description.
|
|
103
73
|
- `checked: Boolean!`: Indicates whether the to-do item is completed. It defaults to a boolean value (true or false) and cannot be null.
|
|
104
74
|
|
|
105
|
-
- **`
|
|
75
|
+
- **`ToDoListStats` type**: This type holds the summary statistics for the to-do list.
|
|
106
76
|
- `total: Int!`: The total count of all to-do items. This field must be an integer and cannot be null.
|
|
107
77
|
- `checked: Int!`: The number of to-do items that are marked as completed. This must be an integer and cannot be null.
|
|
108
78
|
- `unchecked: Int!`: The number of to-do items that are still pending. This also must be an integer and cannot be null.
|
|
@@ -113,17 +83,17 @@ type TodoListStats {
|
|
|
113
83
|
2. **Clarity and Explicitness**: Name your types and fields clearly and descriptively. This makes the schema easier to understand and maintain.
|
|
114
84
|
3. **Use Non-Null Wisely**: Enforce data integrity by using non-null (`!`) for fields that must always have a value. However, be mindful not to over-constrain if a field can genuinely be optional.
|
|
115
85
|
4. **Normalize vs. Denormalize**:
|
|
116
|
-
- **Normalization**: Similar to relational databases, you can normalize your data by having distinct types and linking them via IDs. This can reduce data redundancy. For example, if you had `User` and `
|
|
117
|
-
- **Denormalization**: Sometimes, for performance or simplicity, you might embed data directly. For instance, if user information associated with a to-do item was very simple and only used in that context, you might embed user fields directly in `
|
|
86
|
+
- **Normalization**: Similar to relational databases, you can normalize your data by having distinct types and linking them via IDs. This can reduce data redundancy. For example, if you had `User` and `ToDoItem` and wanted to assign tasks, you might have an `assigneeId` field in `ToDoItem` that links to a `User`'s `id`.
|
|
87
|
+
- **Denormalization**: Sometimes, for performance or simplicity, you might embed data directly. For instance, if user information associated with a to-do item was very simple and only used in that context, you might embed user fields directly in `ToDoItem`.
|
|
118
88
|
- The choice depends on your specific use case, query patterns, and how data is updated.
|
|
119
|
-
5. **Consider Future Needs**: While you shouldn't over-engineer, think a little about potential future enhancements. For example, adding a `createdAt: String` or `dueDate: String` field to `
|
|
120
|
-
6. **Root State Type**: It's a common pattern to have a single root type for your document state (e.g., `
|
|
89
|
+
5. **Consider Future Needs**: While you shouldn't over-engineer, think a little about potential future enhancements. For example, adding a `createdAt: String` or `dueDate: String` field to `ToDoItem` might be useful later.
|
|
90
|
+
6. **Root State Type**: It's a common pattern to have a single root type for your document state (e.g., `ToDoListState`). This provides a clear entry point for accessing all document data.
|
|
121
91
|
|
|
122
92
|
By carefully defining your state schema, you lay a solid foundation for your Powerhouse document model, making it robust, maintainable, and easy to work with. The schema dictates not only how data is stored but also how it can be queried and mutated through operations, which will be covered in the next section.
|
|
123
93
|
|
|
124
94
|
## Practical implementation: defining the state schema in Connect
|
|
125
95
|
|
|
126
|
-
Now that you understand the concepts behind the state schema, let's put it into practice. This section will guide you through creating a document model specification for the
|
|
96
|
+
Now that you understand the concepts behind the state schema, let's put it into practice. This section will guide you through creating a document model specification for the advanced ToDoList example discussed above.
|
|
127
97
|
|
|
128
98
|
<details>
|
|
129
99
|
<summary>Tutorial: The state schema specification</summary>
|
|
@@ -140,29 +110,28 @@ Now that you understand the concepts behind the state schema, let's put it into
|
|
|
140
110
|
- At the bottom of the page in the 'New Document' section, click the `DocumentModel` button to create a new document model specification.
|
|
141
111
|
|
|
142
112
|
2. **Define Document Metadata**:
|
|
143
|
-
- **Name**: Give your document model a descriptive name
|
|
144
|
-
- **Document Type**: In the 'Document Type' field, enter a unique identifier for this document type: `powerhouse/
|
|
113
|
+
- **Name**: Give your document model a descriptive name, for example, `ToDoList`. **Pay close attention to capitalization, as it influences our code.**
|
|
114
|
+
- **Document Type**: In the 'Document Type' field, enter a unique identifier for this document type: `powerhouse/todolist`.
|
|
145
115
|
|
|
146
116
|
3. **Specify the State Schema**:
|
|
147
117
|
- In the code editor provided, you'll see a template for a GraphQL schema.
|
|
148
|
-
- Replace the entire content of the editor with the advanced `
|
|
118
|
+
- Replace the entire content of the editor with the advanced `ToDoList` schema we've designed in this chapter:
|
|
149
119
|
|
|
150
120
|
```graphql
|
|
151
|
-
# The state of our
|
|
152
|
-
type
|
|
153
|
-
items: [
|
|
154
|
-
stats:
|
|
121
|
+
# The state of our ToDoList
|
|
122
|
+
type ToDoListState {
|
|
123
|
+
items: [ToDoItem!]!
|
|
124
|
+
stats: ToDoListStats!
|
|
155
125
|
}
|
|
156
126
|
|
|
157
127
|
# A single to-do item
|
|
158
|
-
type
|
|
159
|
-
id:
|
|
128
|
+
type ToDoItem {
|
|
129
|
+
id: ID!
|
|
160
130
|
text: String!
|
|
161
131
|
checked: Boolean!
|
|
162
132
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
type TodoListStats {
|
|
133
|
+
# The statistics on our to-do's
|
|
134
|
+
type ToDoListStats {
|
|
166
135
|
total: Int!
|
|
167
136
|
checked: Int!
|
|
168
137
|
unchecked: Int!
|
|
@@ -171,12 +140,12 @@ Now that you understand the concepts behind the state schema, let's put it into
|
|
|
171
140
|
|
|
172
141
|
4. **Sync Schema and View Initial State**:
|
|
173
142
|
- After pasting the schema, click the **'Sync with schema'** button.
|
|
174
|
-
- This action processes your schema and generates an initial JSON state for your document model based on the `
|
|
143
|
+
- This action processes your schema and generates an initial JSON state for your document model based on the `ToDoListState` type. You can view this initial state, which helps you verify that your schema is structured correctly.
|
|
175
144
|
|
|
176
145
|
For now, you can ignore the "Modules & Operations" section. We will define and implement the operations that modify this state in the upcoming sections of this Mastery Track.
|
|
177
146
|
|
|
178
|
-
By completing these steps, you have successfully specified the data structure for the advanced
|
|
147
|
+
By completing these steps, you have successfully specified the data structure for the advanced ToDoList document model. The next step is to define the operations that will allow users to interact with and change this state.
|
|
179
148
|
|
|
180
149
|
</details>
|
|
181
150
|
|
|
182
|
-
For a complete, working example, you can always have a look at the [Example
|
|
151
|
+
For a complete, working example, you can always have a look at the [Example ToDoList Repository](/academy/MasteryTrack/DocumentModelCreation/ExampleToDoListRepository) which contains the full implementation of the concepts discussed in this Mastery Track.
|