@powerhousedao/academy 5.1.0-dev.3 → 5.1.0-dev.5
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 +22 -0
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +2 -1
- package/blog/TheChallengeOfChange.md +1 -0
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +24 -27
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +118 -9
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +105 -28
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +259 -116
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +469 -162
- package/docs/academy/01-GetStarted/05-VetraStudio.md +1 -0
- package/docs/academy/01-GetStarted/07-VetraRemoteDrive.md +160 -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 +75 -44
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +28 -22
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +28 -31
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +211 -206
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +176 -62
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +21 -0
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +306 -319
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/VetraPackageLibrary.md +7 -0
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/_category_.json +9 -0
- package/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md +1 -3
- package/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md +1 -3
- package/docs/academy/10-TodoListTutorial/00-GetTheStarterCode.md +24 -0
- package/docs/academy/10-TodoListTutorial/01-GenerateTodoListDocumentModel.md +211 -0
- package/docs/academy/10-TodoListTutorial/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +175 -0
- package/docs/academy/10-TodoListTutorial/03-AddTestsForTodoListActions.md +454 -0
- package/docs/academy/10-TodoListTutorial/04-GenerateTodoListDocumentEditor.md +45 -0
- package/docs/academy/10-TodoListTutorial/05-ImplementTodoListDocumentEditorUIComponents.md +414 -0
- package/docs/academy/10-TodoListTutorial/06-GenerateTodoDriveExplorer.md +61 -0
- package/docs/academy/10-TodoListTutorial/07-AddSharedComponentForShowingTodoListStats.md +370 -0
- package/docusaurus.config.ts +8 -3
- package/package.json +1 -1
- package/sidebars.ts +27 -9
- package/src/css/custom.css +0 -19
- package/static/img/Vetra-logo-dark.svg +11 -0
- package/static/img/vetra-logo-light.svg +11 -0
- package/docs/academy/00-EthereumArgentinaHackathon.md +0 -207
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## 5.1.0-dev.5 (2025-12-04)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- connect crypto signer and verifier ([918fb1fab](https://github.com/powerhouse-inc/powerhouse/commit/918fb1fab))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Benjamin Jordan (@thegoldenmule)
|
|
10
|
+
|
|
11
|
+
## 5.1.0-dev.4 (2025-12-03)
|
|
12
|
+
|
|
13
|
+
### 🚀 Features
|
|
14
|
+
|
|
15
|
+
- **codegen,ph-cli:** add tsx code generator ([#2116](https://github.com/powerhouse-inc/powerhouse/pull/2116))
|
|
16
|
+
- **academy:** add new todo list tutorial content ([b6dc16545](https://github.com/powerhouse-inc/powerhouse/commit/b6dc16545))
|
|
17
|
+
|
|
18
|
+
### ❤️ Thank You
|
|
19
|
+
|
|
20
|
+
- Ryan Wolhuter @ryanwolhuter
|
|
21
|
+
- ryanwolhuter @ryanwolhuter
|
|
22
|
+
|
|
1
23
|
## 5.1.0-dev.3 (2025-12-02)
|
|
2
24
|
|
|
3
25
|
### 🚀 Features
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Beyond Communication - A Blueprint for Development
|
|
3
|
-
description: GraphQL Schema
|
|
3
|
+
description: GraphQL Schema's as a common language for software design
|
|
4
4
|
slug: Graphql-schema-as-a-common-language
|
|
5
|
+
date: 2024-12-02
|
|
5
6
|
authors:
|
|
6
7
|
- name: Call me T.
|
|
7
8
|
title: Product Manager at Powerhouse
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Let's get started
|
|
4
4
|
|
|
5
|
-
To give you a quick idea of how the Powerhouse
|
|
5
|
+
To give you a quick idea of how the Powerhouse Vetra builder platform operates on document models and packages, why don't you try installing a package?
|
|
6
6
|
We will show you how to install the Powerhouse command-line tool `ph-cmd` and then use it to install a pre-built demo package containing a document model, an editor, and a drive app.
|
|
7
7
|
|
|
8
8
|
## Step 1: Install the Powerhouse CLI
|
|
9
9
|
|
|
10
|
-
You will use the Powerhouse CLI to launch a local environment with a "To-do List Demo Package".
|
|
11
|
-
This is also the package that you'll recreate during the tutorials and gets you familiar with Powerhouse.
|
|
10
|
+
You will use the Powerhouse CLI to launch a local environment with a "To-do List Demo Package" installed.
|
|
11
|
+
This is also the package that you'll recreate during the tutorials and gets you familiar with Powerhouse Vetra.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
pnpm install -g ph-cmd
|
|
@@ -20,16 +20,21 @@ Verify the installation:
|
|
|
20
20
|
ph --version
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
## Step 2:
|
|
23
|
+
## Step 2: Initialize a new project
|
|
24
24
|
|
|
25
|
-
Now
|
|
25
|
+
Now use the `ph init` command to initialize a new project and install a Powerhouse package inside the project.
|
|
26
|
+
You'll be asked to name your project. Afterwards, move inside your project with `cd project-name`
|
|
27
|
+
|
|
28
|
+
## Step 3: Install the to-do list demo package
|
|
29
|
+
|
|
30
|
+
Now, use the `ph install` command to install the demo package inside the project.
|
|
26
31
|
|
|
27
32
|
```bash
|
|
28
33
|
# Install the package
|
|
29
|
-
ph install @powerhousedao/todo-demo
|
|
34
|
+
ph install @powerhousedao/todo-demo
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
This command downloads and sets up the `@powerhousedao/todo-demo
|
|
37
|
+
This command downloads and sets up the `@powerhousedao/todo-demo`, making its features available in your Powerhouse project.
|
|
33
38
|
|
|
34
39
|
<details>
|
|
35
40
|
<summary>Expected CLI result</summary>
|
|
@@ -73,9 +78,9 @@ This command downloads and sets up the `@powerhousedao/todo-demo-package`, makin
|
|
|
73
78
|
|
|
74
79
|
</details>
|
|
75
80
|
|
|
76
|
-
You have now successfully installed `ph-cmd
|
|
81
|
+
You have now successfully installed `ph-cmd`, initalized a product project and added your first package!
|
|
77
82
|
|
|
78
|
-
## Step
|
|
83
|
+
## Step 4: Run the connect app in studio mode
|
|
79
84
|
|
|
80
85
|
To run the package locally in Connect Studio (our collaboration and contributor app), run:
|
|
81
86
|
|
|
@@ -91,7 +96,7 @@ Click the returned localhost URL and you should see Connect Studio appear in you
|
|
|
91
96
|
</figure>
|
|
92
97
|
|
|
93
98
|
When you click the settings wheel in the bottom right corner, you'll get access to the **Package Manager**.
|
|
94
|
-
Here, you'll see that you've installed the `@powerhousedao/todo-demo
|
|
99
|
+
Here, you'll see that you've installed the `@powerhousedao/todo-demo`, which contains not only a **Document Model** and its accompanying editor but also a **Drive App** specific to the to-do document model.
|
|
95
100
|
|
|
96
101
|
<figure className="image-container">
|
|
97
102
|
<img
|
|
@@ -103,13 +108,13 @@ Here, you'll see that you've installed the `@powerhousedao/todo-demo-package`, w
|
|
|
103
108
|
</figcaption>
|
|
104
109
|
</figure>
|
|
105
110
|
|
|
106
|
-
## Step
|
|
111
|
+
## Step 5: Create a todo list document
|
|
107
112
|
|
|
108
113
|
:::tip What is a 'drive' at Powerhouse?
|
|
109
114
|
A **drive** is a folder to store and organize your documents in. Powerhouse offers the ability to build customized 'Drive Apps' for your documents. Think of a Drive App as a specialized lens—it offers **different ways to visualize, organize, and interact with** the data stored within a drive, making it more intuitive and efficient for specific use cases. To learn more, visit [Building A Drive App](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
|
|
110
115
|
:::
|
|
111
116
|
|
|
112
|
-
###
|
|
117
|
+
### 5.1 Create a local todolist app drive
|
|
113
118
|
|
|
114
119
|
First, let's create a dedicated drive for your to-do lists:
|
|
115
120
|
|
|
@@ -117,14 +122,14 @@ First, let's create a dedicated drive for your to-do lists:
|
|
|
117
122
|
- In the **Drive App** field, select 'To-do Drive App'
|
|
118
123
|
- This creates a specialized drive that's optimized for to-do list documents
|
|
119
124
|
|
|
120
|
-
###
|
|
125
|
+
### 5.2 Create a todolist document
|
|
121
126
|
|
|
122
127
|
Now move into the drive you've just created:
|
|
123
128
|
|
|
124
129
|
- Click the button at the bottom of the page to create a new to-do list document
|
|
125
130
|
- This opens the to-do list editor where you can start managing your tasks
|
|
126
131
|
|
|
127
|
-
###
|
|
132
|
+
### 5.3 Add a few todos and inspect the document history
|
|
128
133
|
|
|
129
134
|
- Add a few to-dos that are on your mind
|
|
130
135
|
- You'll see a statistics widget that counts the open to-dos
|
|
@@ -134,14 +139,6 @@ This is an example of the **usefulness and impact of Drive Apps**.
|
|
|
134
139
|
They offer a customized interface that works well with the different documents inside your drive.
|
|
135
140
|
Read more about drive apps in the Mastery Track: [Drive Apps and Drive Explorers](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer).
|
|
136
141
|
|
|
137
|
-
<figure className="image-container">
|
|
138
|
-
<img
|
|
139
|
-
src={require("./images/TodoDriveApp.png").default}
|
|
140
|
-
alt="Todo Drive App"
|
|
141
|
-
/>
|
|
142
|
-
<figcaption>A list of todos in the custom todo drive app.</figcaption>
|
|
143
|
-
</figure>
|
|
144
|
-
|
|
145
142
|
A key feature of Connect is the **Operations History**. Every change to a document is stored as an individual operation, creating an immutable and replayable history. This provides complete auditability and transparency, as you can inspect each revision, its details, and any associated signatures. For example, you can see a chronological list of all modifications, along with who made them and when.
|
|
146
143
|
|
|
147
144
|
<figure className="image-container">
|
|
@@ -167,7 +164,7 @@ You can find the button to visit the operations history in the document model to
|
|
|
167
164
|
|
|
168
165
|
Learn more about the [Operations History](../MasteryTrack/BuildingUserExperiences/DocumentTools/OperationHistory) and other document tools you get for free.
|
|
169
166
|
|
|
170
|
-
## Step
|
|
167
|
+
## Step 6: Enable operation signing and verification through Renown
|
|
171
168
|
|
|
172
169
|
Renown is Powerhouse's **decentralized identity and reputation system** designed to address the challenge of trust within open organizations, where contributors often operate under pseudonyms. In traditional organizations, personal identity and reputation are key to establishing trust and accountability. Renown replicates this dynamic in the digital space, allowing contributors to earn experience and build reputation without revealing their real-world identities.
|
|
173
170
|
|
|
@@ -175,7 +172,7 @@ Renown is Powerhouse's **decentralized identity and reputation system** designed
|
|
|
175
172
|
When signing in with Renown, use an Ethereum or blockchain address that can function as your 'identity', as this address will accrue more experience and history over time.
|
|
176
173
|
:::
|
|
177
174
|
|
|
178
|
-
###
|
|
175
|
+
### 6.1 Click the renown icon and connect your Ethereum identity
|
|
179
176
|
|
|
180
177
|
"**Log in with Renown**" is a decentralized authentication flow that enables you to log into applications by signing a credential with your Ethereum wallet. Upon signing in, a Decentralized Identifier (DID) is created based on your Ethereum key.
|
|
181
178
|
|
|
@@ -186,7 +183,7 @@ When signing in with Renown, use an Ethereum or blockchain address that can func
|
|
|
186
183
|
</figcaption>
|
|
187
184
|
</figure>
|
|
188
185
|
|
|
189
|
-
###
|
|
186
|
+
### 6.2 Authorize Connect to sign document edits on your behalf
|
|
190
187
|
|
|
191
188
|
This DID is then associated with a credential that authorizes a specific Connect instance to act on your behalf. That credential is stored securely on Ceramic, a decentralized data network. When you perform actions through the Powerhouse Connect interface, those operations are signed with the DID and transmitted to Switchboard, which serves as the verifier.
|
|
192
189
|
|
|
@@ -208,7 +205,7 @@ This DID is then associated with a credential that authorizes a specific Connect
|
|
|
208
205
|
<figcaption>Confirmation of a successful login with Renown.</figcaption>
|
|
209
206
|
</figure>
|
|
210
207
|
|
|
211
|
-
###
|
|
208
|
+
### 6.3 Verify the signatures of new operations in the todo list
|
|
212
209
|
|
|
213
210
|
By leveraging this system, every operation or modification made to a document is cryptographically signed by the contributor's Renown identity. This ensures that each change is verifiable, traceable, and attributable to a specific pseudonymous user, providing a robust audit trail for all document activity.
|
|
214
211
|
|
|
@@ -224,7 +221,7 @@ Now, return to your to-do list and make some additional changes. You'll notice t
|
|
|
224
221
|
</figcaption>
|
|
225
222
|
</figure>
|
|
226
223
|
|
|
227
|
-
## Step
|
|
224
|
+
## Step 7: Export a document
|
|
228
225
|
|
|
229
226
|
Export the document as a `.phd` (Powerhouse Document) file using the export button in the document toolbar at the top. In this toolbar, you will find all available functionality for your documents. The `.phd` file can be sent through any of your preferred channels to other users on your network.
|
|
230
227
|
|
|
@@ -1,12 +1,100 @@
|
|
|
1
1
|
# Create a new to-do list document
|
|
2
2
|
|
|
3
|
+
:::tip Tutorial Repository
|
|
4
|
+
📦 **Reference Code**: [step-1-initialize-with-ph-init](https://github.com/powerhouse-inc/todo-tutorial/tree/step-1-initialize-with-ph-init)
|
|
5
|
+
|
|
6
|
+
This tutorial step has a corresponding branch in the repository. You can:
|
|
7
|
+
- View the complete code for this step
|
|
8
|
+
- Clone and checkout the branch to see the result
|
|
9
|
+
- Compare your implementation using `git diff`
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
<details>
|
|
13
|
+
<summary>📖 How to use this tutorial</summary>
|
|
14
|
+
|
|
15
|
+
This tutorial is designed for you to **build your own project from scratch** while having access to reference code at each step.
|
|
16
|
+
|
|
17
|
+
### Setup: Create your project and connect to tutorial repo
|
|
18
|
+
|
|
19
|
+
1. **Create your project** following the tutorial:
|
|
20
|
+
```bash
|
|
21
|
+
mkdir ph-projects
|
|
22
|
+
cd ph-projects
|
|
23
|
+
ph init
|
|
24
|
+
# When prompted, enter project name: todo-tutorial
|
|
25
|
+
cd todo-tutorial
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **Add the tutorial repository as a remote** to access reference branches:
|
|
29
|
+
```bash
|
|
30
|
+
git remote add tutorial https://github.com/powerhouse-inc/todo-tutorial.git
|
|
31
|
+
git fetch tutorial --prune
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. **Create your own branch** to keep your work organized:
|
|
35
|
+
```bash
|
|
36
|
+
git checkout -b my-todo-project
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Now you have access to all tutorial step branches while working on your own code!
|
|
40
|
+
|
|
41
|
+
### Compare your work with reference steps
|
|
42
|
+
|
|
43
|
+
At any point, compare what you've built with a tutorial step:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Compare your current work with step-1
|
|
47
|
+
git diff tutorial/step-1-initialize-with-ph-init
|
|
48
|
+
|
|
49
|
+
# See what changed between tutorial steps
|
|
50
|
+
git diff tutorial/step-1-initialize-with-ph-init..tutorial/step-2-generate-todo-list-document-model
|
|
51
|
+
|
|
52
|
+
# Compare specific files
|
|
53
|
+
git diff tutorial/step-1-initialize-with-ph-init -- package.json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Visual diff with GitHub Desktop
|
|
57
|
+
|
|
58
|
+
For a more visual comparison, use GitHub Desktop:
|
|
59
|
+
|
|
60
|
+
1. **First, make your initial commit** (GitHub Desktop won't show your branch until you have at least one commit):
|
|
61
|
+
```bash
|
|
62
|
+
git add .
|
|
63
|
+
git commit -m "Initial project setup"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. **Open GitHub Desktop** and open your repository
|
|
67
|
+
|
|
68
|
+
3. **Compare branches visually**:
|
|
69
|
+
- Click on **Branch** menu in the top menu bar
|
|
70
|
+
- Select **"Compare to Branch..."**
|
|
71
|
+
- Choose the tutorial branch you want to compare with (e.g., `tutorial/step-1-initialize-with-ph-init`)
|
|
72
|
+
- GitHub Desktop will show you all file differences in a visual interface
|
|
73
|
+
|
|
74
|
+
4. **Review the differences**:
|
|
75
|
+
- Click on any file to see side-by-side or unified diff view
|
|
76
|
+
- See exactly what's different between your code and the reference
|
|
77
|
+
|
|
78
|
+
**Tip**: You can also use VS Code's Git Graph extension or the command palette → "Git: Compare with Branch"
|
|
79
|
+
|
|
80
|
+
### If you get stuck
|
|
81
|
+
|
|
82
|
+
Reset your code to match a tutorial step:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Reset to step-2 (WARNING: loses your changes)
|
|
86
|
+
git reset --hard tutorial/step-2-generate-todo-list-document-model
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</details>
|
|
90
|
+
|
|
3
91
|
## Overview
|
|
4
92
|
|
|
5
93
|
This tutorial guides you through creating a simplified version of a 'Powerhouse project' for a **To-do List**.
|
|
6
94
|
A Powerhouse project primarily consists of a document model and its editor.
|
|
7
95
|
As your projects use-case expands you can add data-integrations or a specific drive-app as seen in the demo package.
|
|
8
96
|
|
|
9
|
-
For todays purpose, you'll be using Connect, our user-centric collaboration tool and Vetra Studio, the builder tooling through which developers can access and manage specifications of
|
|
97
|
+
For todays purpose, you'll be using Connect, our user-centric collaboration tool and Vetra Studio, the builder tooling through which developers can access and manage specifications of your project.
|
|
10
98
|
|
|
11
99
|
## Prerequisites
|
|
12
100
|
|
|
@@ -41,19 +129,19 @@ ph init
|
|
|
41
129
|
````bash
|
|
42
130
|
you@yourmachine:~/ph-projects % ph init
|
|
43
131
|
|
|
44
|
-
? What is the project name? ‣
|
|
132
|
+
? What is the project name? ‣ todo-tutorial
|
|
45
133
|
```
|
|
46
134
|
|
|
47
135
|
|
|
48
136
|
Once the project is created, you will see the following output:
|
|
49
137
|
```bash
|
|
50
|
-
Initialized empty Git repository in /Users/you/ph-projects/
|
|
138
|
+
Initialized empty Git repository in /Users/you/ph-projects/todo-tutorial/.git/
|
|
51
139
|
The installation is done!
|
|
52
140
|
```
|
|
53
141
|
|
|
54
142
|
Navigate to the newly created project directory:
|
|
55
143
|
```bash
|
|
56
|
-
cd
|
|
144
|
+
cd todo-tutorial
|
|
57
145
|
```
|
|
58
146
|
|
|
59
147
|
## Develop a single document model in Connect
|
|
@@ -73,20 +161,41 @@ The Connect application will start and you will see the following output:
|
|
|
73
161
|
➜ press h + enter to show help
|
|
74
162
|
```
|
|
75
163
|
|
|
76
|
-
A new browser window will open and you will see the Connect application. If it doesn't open automatically, you can open it manually by navigating to `http://localhost:3000/` in your browser.
|
|
164
|
+
A new browser window will open and you will see the Connect application. If it doesn't open automatically, you can open it manually by navigating to `http://localhost:3000/` in your browser. You will see your local drive and a button to create a new drive.
|
|
77
165
|
|
|
78
|
-
|
|
166
|
+
:::tip
|
|
79
167
|
If you local drive is not present navigate into Settings in the bottom left corner. Settings > Danger Zone > Clear Storage.
|
|
80
168
|
Clear the storage of your localhost application as it might has an old session cached.
|
|
169
|
+
:::
|
|
81
170
|
|
|
82
171
|
4. Move into your local drive.
|
|
83
|
-
Create a new document model by clicking the `DocumentModel` button, found in the 'New Document' section at the bottom of the page.
|
|
172
|
+
Create a new document model by clicking the `DocumentModel` button, found in the 'New Document' section at the bottom of the page. Name your document `TodoList` (PascalCase, no spaces or hyphens).
|
|
173
|
+
|
|
174
|
+
If you've followed the steps correctly, you'll have an empty `TodoList` document where you can define the **'Document Specifications'**.
|
|
175
|
+
|
|
176
|
+
## Verify your setup
|
|
84
177
|
|
|
85
|
-
|
|
178
|
+
At this point, your project structure should match the `step-1-initialize-with-ph-init` branch. You should have:
|
|
86
179
|
|
|
87
|
-
|
|
180
|
+
- Empty `document-models/`, `editors/`, `processors/`, and `subgraphs/` directories
|
|
181
|
+
- Configuration files: `powerhouse.config.json`, `powerhouse.manifest.json`
|
|
182
|
+
- Package management files: `package.json`, `pnpm-lock.yaml`
|
|
183
|
+
- Build configuration: `tsconfig.json`, `vite.config.ts`, `vitest.config.ts`
|
|
88
184
|
|
|
185
|
+
### Compare with reference implementation
|
|
89
186
|
|
|
187
|
+
Verify your initial setup matches the tutorial:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Compare your project structure with step-1
|
|
191
|
+
git diff tutorial/step-1-initialize-with-ph-init
|
|
192
|
+
|
|
193
|
+
# List files in the tutorial's step-1
|
|
194
|
+
git ls-tree -r --name-only tutorial/step-1-initialize-with-ph-init
|
|
195
|
+
|
|
196
|
+
# View a specific config file from step-1
|
|
197
|
+
git show tutorial/step-1-initialize-with-ph-init:package.json
|
|
198
|
+
```
|
|
90
199
|
|
|
91
200
|
## Up next
|
|
92
201
|
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
# Write the document specification
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
:::tip Tutorial Repository
|
|
4
|
+
📦 **Reference Code**: [step-2-generate-todo-list-document-model](https://github.com/powerhouse-inc/todo-tutorial/tree/step-2-generate-todo-list-document-model)
|
|
5
|
+
|
|
6
|
+
This tutorial step has a corresponding branch. After completing this step, your project will have a generated document model with:
|
|
7
|
+
- Document model specification files (`todo-list.json`, `schema.graphql`)
|
|
8
|
+
- Auto-generated TypeScript types and action creators
|
|
9
|
+
- Reducer scaffolding ready for implementation
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
<details>
|
|
13
|
+
<summary>📖 How to use this tutorial</summary>
|
|
14
|
+
|
|
15
|
+
**Prerequisites**: Complete step 1 and set up the tutorial remote (see previous step).
|
|
16
|
+
|
|
17
|
+
### Compare your generated code
|
|
18
|
+
|
|
19
|
+
After running `ph generate TodoList.phdm.zip`, compare with the reference:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Compare all generated files with step-2
|
|
23
|
+
git diff tutorial/step-2-generate-todo-list-document-model
|
|
24
|
+
|
|
25
|
+
# Compare specific directory
|
|
26
|
+
git diff tutorial/step-2-generate-todo-list-document-model -- document-models/todo-list/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### See what was generated
|
|
30
|
+
|
|
31
|
+
View the complete step-2 reference code:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# List files in the tutorial's step-2
|
|
35
|
+
git ls-tree -r --name-only tutorial/step-2-generate-todo-list-document-model document-models/
|
|
36
|
+
|
|
37
|
+
# View a specific file from step-2
|
|
38
|
+
git show tutorial/step-2-generate-todo-list-document-model:document-models/todo-list/schema.graphql
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Visual comparison with GitHub Desktop
|
|
42
|
+
|
|
43
|
+
After making a commit, use GitHub Desktop for visual diff:
|
|
44
|
+
1. **Branch** menu → **"Compare to Branch..."**
|
|
45
|
+
2. Select `tutorial/step-2-generate-todo-list-document-model`
|
|
46
|
+
3. Review all file differences in the visual interface
|
|
47
|
+
|
|
48
|
+
See step 1 for detailed GitHub Desktop instructions.
|
|
49
|
+
|
|
50
|
+
</details>
|
|
51
|
+
|
|
52
|
+
In this tutorial, you will learn how to define the specifications for a **TodoList** document model within the Connect application using its GraphQL schema, and then export the resulting document model specification document for your Powerhouse project.
|
|
4
53
|
If you don't have a document specification file created yet, have a look at the previous step of this tutorial to create a new document specification.
|
|
5
54
|
|
|
6
55
|
Before you start, make sure you have the Connect application running locally with the command:
|
|
@@ -17,14 +66,13 @@ The Connect application will start and you will see the following output:
|
|
|
17
66
|
➜ press h + enter to show help
|
|
18
67
|
```
|
|
19
68
|
|
|
20
|
-
##
|
|
69
|
+
## TodoList document specification
|
|
21
70
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
**Pay close attention to capitalization, as it influences our code.**
|
|
71
|
+
Make sure you have named your document model `TodoList` (PascalCase, no spaces or hyphens).
|
|
72
|
+
**Pay close attention to capitalization, as it influences our code generation.**
|
|
25
73
|
|
|
26
74
|
We'll continue with this project to teach you how to create a document model specification and later an editor for your document model. We use the **GraphQL Schema Definition Language** (SDL) to define the schema for the document model.
|
|
27
|
-
Below, you can see the SDL for the `
|
|
75
|
+
Below, you can see the SDL for the `TodoList` document model.
|
|
28
76
|
|
|
29
77
|
:::info
|
|
30
78
|
This schema defines the **data structure** of the document model and the types involved in its operations, which are detailed further as input types.
|
|
@@ -32,17 +80,17 @@ Documents in Powerhouse leverage **event sourcing principles**, where every stat
|
|
|
32
80
|
:::
|
|
33
81
|
|
|
34
82
|
<details>
|
|
35
|
-
<summary>State schema of our simplified
|
|
83
|
+
<summary>State schema of our simplified TodoList</summary>
|
|
36
84
|
|
|
37
85
|
```graphql
|
|
38
|
-
# The state of our
|
|
39
|
-
type
|
|
40
|
-
items: [
|
|
86
|
+
# The state of our TodoList
|
|
87
|
+
type TodoListState {
|
|
88
|
+
items: [TodoItem!]!
|
|
41
89
|
}
|
|
42
90
|
|
|
43
91
|
# A single to-do item
|
|
44
|
-
type
|
|
45
|
-
id:
|
|
92
|
+
type TodoItem {
|
|
93
|
+
id: OID!
|
|
46
94
|
text: String!
|
|
47
95
|
checked: Boolean!
|
|
48
96
|
}
|
|
@@ -51,29 +99,25 @@ type ToDoItem {
|
|
|
51
99
|
</details>
|
|
52
100
|
|
|
53
101
|
<details>
|
|
54
|
-
<summary>Operations schema of our simplified
|
|
102
|
+
<summary>Operations schema of our simplified TodoList</summary>
|
|
55
103
|
```graphql
|
|
56
104
|
# Defines a GraphQL input type for adding a new to-do item
|
|
57
105
|
input AddTodoItemInput {
|
|
58
|
-
id: ID!
|
|
59
106
|
text: String!
|
|
60
107
|
}
|
|
61
108
|
|
|
62
109
|
# Defines a GraphQL input type for updating a to-do item
|
|
63
|
-
|
|
64
110
|
input UpdateTodoItemInput {
|
|
65
|
-
id:
|
|
66
|
-
text: String
|
|
67
|
-
checked: Boolean
|
|
111
|
+
id: OID!
|
|
112
|
+
text: String
|
|
113
|
+
checked: Boolean
|
|
68
114
|
}
|
|
69
115
|
|
|
70
116
|
# Defines a GraphQL input type for deleting a to-do item
|
|
71
|
-
|
|
72
117
|
input DeleteTodoItemInput {
|
|
73
|
-
id:
|
|
118
|
+
id: OID!
|
|
74
119
|
}
|
|
75
|
-
|
|
76
|
-
````
|
|
120
|
+
```
|
|
77
121
|
</details>
|
|
78
122
|
|
|
79
123
|
## Define the document model specification
|
|
@@ -83,21 +127,20 @@ To be able to define the document model, you need to open the document model edi
|
|
|
83
127
|
### The steps below show you how to do this:
|
|
84
128
|
|
|
85
129
|
1. In the Connect application, click on **'document model'** to open the document model specification editor.
|
|
86
|
-
2. Name your document model
|
|
130
|
+
2. Name your document model `TodoList` (PascalCase, no spaces or hyphens) in the Connect application. **Pay close attention to capitalization, as it influences code generation.**
|
|
87
131
|
3. You'll be presented with a form to fill in metadata about the document model. Fill in the details in the respective fields.
|
|
88
132
|
|
|
89
|
-
In the **Document Type** field, type `powerhouse/
|
|
133
|
+
In the **Document Type** field, type `powerhouse/todo-list` (lowercase with hyphen). This defines the new type of document that will be created with this document model specification.
|
|
90
134
|
|
|
91
|
-

|
|
92
136
|
|
|
93
137
|
4. In the code editor, you can see the SDL for the document model. Replace the existing SDL template with the SDL defined in the [State Schema](#state-schema) section. Only copy and paste the types, leaving the inputs for the next step. You can, however, already press the 'Sync with schema' button to set the initial state of your document model specification based on your Schema Definition Language.
|
|
94
|
-
5. Below the editor, find the input field `Add module`. You'll use this to create and name a module for organizing your input operations. In this case, we will name the module `
|
|
138
|
+
5. Below the editor, find the input field `Add module`. You'll use this to create and name a module for organizing your input operations. In this case, we will name the module `todos`. Press enter.
|
|
95
139
|
6. Now there is a new field, called `Add operation`. Here you will have to add each input operation to the module, one by one.
|
|
96
140
|
7. Inside the `Add operation` field, type `ADD_TODO_ITEM` and press enter. A small editor will appear underneath it, with an empty input type that you have to fill. Copy the first input type from the [Operations Schema](#operations-schema) section and paste it in the editor. The editor should look like this:
|
|
97
141
|
|
|
98
142
|
```graphql
|
|
99
143
|
input AddTodoItemInput {
|
|
100
|
-
id: ID!
|
|
101
144
|
text: String!
|
|
102
145
|
}
|
|
103
146
|
```
|
|
@@ -110,7 +153,41 @@ Check below screenshot for the complete implementation:
|
|
|
110
153
|
|
|
111
154
|

|
|
112
155
|
|
|
156
|
+
## Verify your document model generation
|
|
157
|
+
|
|
158
|
+
After running `pnpm generate TodoList.phd`, your project should have the following structure in `document-models/todo-list/`:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
document-models/todo-list/
|
|
162
|
+
├── gen/ # Auto-generated code (don't edit)
|
|
163
|
+
│ ├── actions.ts
|
|
164
|
+
│ ├── creators.ts # Action creator functions
|
|
165
|
+
│ ├── types.ts # TypeScript type definitions
|
|
166
|
+
│ ├── reducer.ts
|
|
167
|
+
│ └── todos/
|
|
168
|
+
│ └── operations.ts # Operation type definitions
|
|
169
|
+
├── src/ # Your custom implementation
|
|
170
|
+
│ ├── reducers/
|
|
171
|
+
│ │ └── todos.ts # Reducer functions (to implement next)
|
|
172
|
+
│ └── tests/
|
|
173
|
+
│ └── todos.test.ts # Test file scaffolding
|
|
174
|
+
├── todo-list.json # Document model specification
|
|
175
|
+
└── schema.graphql # GraphQL schema
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Compare with reference
|
|
179
|
+
|
|
180
|
+
Verify your generated files match the expected structure:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Compare your generated files with step-2
|
|
184
|
+
git diff tutorial/step-2-generate-todo-list-document-model -- document-models/todo-list/
|
|
185
|
+
|
|
186
|
+
# List what was generated in the reference
|
|
187
|
+
git ls-tree -r --name-only tutorial/step-2-generate-todo-list-document-model document-models/todo-list/
|
|
188
|
+
```
|
|
189
|
+
|
|
113
190
|
### Up next: reducers
|
|
114
191
|
|
|
115
|
-
Up next, you'll learn how to implement the runtime logic and components that will use the `
|
|
192
|
+
Up next, you'll learn how to implement the runtime logic and components that will use the `TodoList` document model specification you've just created and exported.
|
|
116
193
|
|