@powerhousedao/academy 5.0.0-staging.9 → 5.0.1-staging.2
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/.vscode/settings.json +1 -1
- package/CHANGELOG.md +400 -0
- package/README.md +3 -3
- package/babel.config.js +1 -1
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +25 -24
- package/blog/TheChallengeOfChange.md +21 -21
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +67 -30
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +38 -21
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +24 -19
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +44 -41
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +10 -10
- package/docs/academy/01-GetStarted/05-VetraStudio.md +164 -0
- package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
- package/docs/academy/01-GetStarted/home.mdx +185 -90
- package/docs/academy/01-GetStarted/images/Modules.png +0 -0
- package/docs/academy/01-GetStarted/images/VetraStudioDrive.png +0 -0
- package/docs/academy/01-GetStarted/styles.module.css +5 -5
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/01-Prerequisites.md +46 -18
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/02-StandardDocumentModelWorkflow.md +118 -68
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +75 -33
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/_category_.json +6 -6
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/01-WhatIsADocumentModel.md +30 -21
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +41 -37
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +29 -25
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +36 -37
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +128 -109
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +95 -86
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +7 -9
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/_category_.json +6 -6
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +65 -47
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/02-ConfiguringDrives.md +77 -62
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/03-BuildingADriveExplorer.md +360 -349
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +16 -10
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +10 -7
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/02-RevisionHistoryTimeline.md +25 -17
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/_category_.json +6 -6
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/01-RenownAuthenticationFlow.md +14 -7
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/02-Authorization.md +0 -1
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/_category_.json +5 -5
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/_category_.json +1 -1
- package/docs/academy/02-MasteryTrack/04-WorkWithData/01-GraphQLAtPowerhouse.md +45 -33
- package/docs/academy/02-MasteryTrack/04-WorkWithData/02-UsingTheAPI.mdx +61 -18
- package/docs/academy/02-MasteryTrack/04-WorkWithData/03-UsingSubgraphs.md +50 -54
- package/docs/academy/02-MasteryTrack/04-WorkWithData/04-analytics-processor.md +126 -110
- package/docs/academy/02-MasteryTrack/04-WorkWithData/05-RelationalDbProcessor.md +75 -45
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/GraphQL References/QueryingADocumentWithGraphQL.md +23 -21
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/best-practices.md +9 -9
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/graphql/index.md +11 -23
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/graphql/integration.md +25 -9
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/intro.md +10 -10
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/benchmarks.md +1 -1
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/index.md +16 -11
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/memory.md +6 -5
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/schema.md +2 -2
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/utilities.md +7 -5
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/use-cases/maker.md +32 -58
- package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/use-cases/processors.md +1 -1
- package/docs/academy/02-MasteryTrack/04-WorkWithData/07-drive-analytics.md +105 -71
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_01-SetupBuilderEnvironment.md +22 -0
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_02-CreateNewPowerhouseProject.md +9 -8
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_03-GenerateAnAnalyticsProcessor.md +28 -32
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_04-UpdateAnalyticsProcessor.md +25 -26
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_category_.json +1 -1
- package/docs/academy/02-MasteryTrack/04-WorkWithData/_category_.json +7 -7
- package/docs/academy/02-MasteryTrack/05-Launch/01-IntroductionToPackages.md +3 -4
- package/docs/academy/02-MasteryTrack/05-Launch/02-PublishYourProject.md +69 -45
- package/docs/academy/02-MasteryTrack/05-Launch/03-SetupEnvironment.md +70 -40
- package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -0
- package/docs/academy/02-MasteryTrack/05-Launch/_category_.json +7 -7
- package/docs/academy/02-MasteryTrack/_category_.json +6 -6
- package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +5 -3
- package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +38 -37
- package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +45 -41
- package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +14 -14
- package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +6 -6
- package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
- package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +104 -43
- package/docs/academy/04-APIReferences/01-ReactHooks.md +177 -129
- package/docs/academy/04-APIReferences/04-RelationalDatabase.md +121 -113
- package/docs/academy/04-APIReferences/05-PHDocumentMigrationGuide.md +48 -41
- package/docs/academy/04-APIReferences/_category_.json +6 -6
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +1 -2
- package/docs/academy/05-Architecture/01-WorkingWithTheReactor.md +11 -8
- package/docs/academy/05-Architecture/05-DocumentModelTheory/_category_.json +1 -1
- package/docs/academy/05-Architecture/_category_.json +6 -6
- package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +25 -23
- package/docs/academy/06-ComponentLibrary/02-CreateCustomScalars.md +105 -93
- package/docs/academy/06-ComponentLibrary/03-IntegrateIntoAReactComponent.md +1 -0
- package/docs/academy/06-ComponentLibrary/_category_.json +7 -7
- package/docs/academy/07-Cookbook.md +268 -35
- package/docs/academy/08-Glossary.md +7 -1
- package/docs/bookofpowerhouse/01-Overview.md +2 -2
- package/docs/bookofpowerhouse/02-GeneralFrameworkAndPhilosophy.md +1 -7
- package/docs/bookofpowerhouse/03-PowerhouseSoftwareArchitecture.md +10 -7
- package/docs/bookofpowerhouse/04-DevelopmentApproaches.md +10 -4
- package/docs/bookofpowerhouse/05-SNOsandANewModelForOSSandPublicGoods.md +23 -30
- package/docs/bookofpowerhouse/06-SNOsInActionAndPlatformEconomies.md +0 -7
- package/docusaurus.config.ts +64 -66
- package/package.json +9 -7
- package/scripts/generate-combined-cli-docs.ts +43 -13
- package/sidebars.ts +2 -0
- package/src/components/HomepageFeatures/index.tsx +171 -78
- package/src/components/HomepageFeatures/styles.module.css +1 -2
- package/src/css/custom.css +89 -89
- package/src/pages/_archive-homepage.tsx +17 -16
- package/src/theme/DocCardList/index.tsx +9 -8
- package/static.json +6 -6
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
# Powerhouse builder tooling
|
|
2
2
|
|
|
3
|
-
This page provides an overview of all the builder tooling offered by the Powerhouse ecosystem.
|
|
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
|
|
7
|
-
___
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
### Installing the Powerhouse CLI
|
|
11
|
+
|
|
10
12
|
:::tip
|
|
11
|
-
The Powerhouse CLI tool is the only essential tool to install on this page.
|
|
13
|
+
The Powerhouse CLI tool is the only essential tool to install on this page.
|
|
12
14
|
Once you've installed it with the command below you can continue to the next steps.
|
|
13
15
|
:::
|
|
14
16
|
|
|
15
17
|
The Powerhouse CLI (`ph-cmd`) is a command-line interface tool that provides essential commands for managing Powerhouse projects. You can get access to the Powerhouse ecosystem tools by installing them globally using:
|
|
18
|
+
|
|
16
19
|
```bash
|
|
17
20
|
pnpm install -g ph-cmd
|
|
18
|
-
```
|
|
21
|
+
```
|
|
19
22
|
|
|
20
23
|
Key commands include:
|
|
24
|
+
|
|
21
25
|
- `ph connect` for running the Connect application locally
|
|
22
26
|
- `ph switchboard` or `ph reactor` for starting the API service
|
|
23
27
|
- `ph init` to start a new project and build a Document Model
|
|
@@ -30,19 +34,20 @@ This tool will be fundamental on your journey when creating, building, and runni
|
|
|
30
34
|
|
|
31
35
|
When installing or using the Powerhouse CLI commands you are able to make use of the dev & staging branches. These branches contain more experimental features then the latest stable release the PH CLI uses by default. They can be used to get access to a bugfix or features under development.
|
|
32
36
|
|
|
33
|
-
| Command
|
|
34
|
-
|
|
35
|
-
| **pnpm install -g ph-cmd**
|
|
36
|
-
| **pnpm install -g ph-cmd@dev**
|
|
37
|
-
| **pnpm install -g ph-cmd@staging** | Install staging version
|
|
38
|
-
| **ph init**
|
|
39
|
-
| **ph init --dev**
|
|
40
|
-
| **ph init --staging**
|
|
41
|
-
| **ph use**
|
|
42
|
-
| **ph use dev**
|
|
43
|
-
| **ph use prod**
|
|
37
|
+
| Command | Description |
|
|
38
|
+
| ---------------------------------- | ----------------------------------------------------- |
|
|
39
|
+
| **pnpm install -g ph-cmd** | Install latest stable version |
|
|
40
|
+
| **pnpm install -g ph-cmd@dev** | Install development version |
|
|
41
|
+
| **pnpm install -g ph-cmd@staging** | Install staging version |
|
|
42
|
+
| **ph init** | Use latest stable version of the boilerplate |
|
|
43
|
+
| **ph init --dev** | Use development version of the boilerplate |
|
|
44
|
+
| **ph init --staging** | Use staging version of the boilerplate |
|
|
45
|
+
| **ph use** | Switch all dependencies to latest production versions |
|
|
46
|
+
| **ph use dev** | Switch all dependencies to development versions |
|
|
47
|
+
| **ph use prod** | Switch all dependencies to production versions |
|
|
44
48
|
|
|
45
49
|
Please be aware that these versions can contain bugs and experimental features that aren't fully tested.
|
|
50
|
+
|
|
46
51
|
</details>
|
|
47
52
|
|
|
48
53
|
<details>
|
|
@@ -54,16 +59,19 @@ Please be aware that these versions can contain bugs and experimental features t
|
|
|
54
59
|
If you need to perform a clean reinstallation of the Powerhouse CLI (`ph-cmd`), follow these steps:
|
|
55
60
|
|
|
56
61
|
1. First, uninstall the global ph-cmd package:
|
|
62
|
+
|
|
57
63
|
```bash
|
|
58
64
|
pnpm uninstall -g ph-cmd
|
|
59
65
|
```
|
|
60
66
|
|
|
61
67
|
2. Remove the Powerhouse configuration directory:
|
|
68
|
+
|
|
62
69
|
```bash
|
|
63
70
|
rm -rf ~/.ph
|
|
64
71
|
```
|
|
65
72
|
|
|
66
73
|
3. Reinstall the CLI tool (choose one):
|
|
74
|
+
|
|
67
75
|
```bash
|
|
68
76
|
# For the latest stable version
|
|
69
77
|
pnpm install -g ph-cmd
|
|
@@ -76,20 +84,24 @@ pnpm install -g ph-cmd@<version>
|
|
|
76
84
|
```
|
|
77
85
|
|
|
78
86
|
This process ensures a clean slate by removing both the CLI tool and its configuration files before installing the desired version. It's particularly useful when:
|
|
87
|
+
|
|
79
88
|
- Troubleshooting CLI issues
|
|
80
89
|
- Upgrading to a new version
|
|
81
90
|
- Switching between stable and staging versions
|
|
82
|
-
- Resolving configuration conflicts
|
|
91
|
+
- Resolving configuration conflicts
|
|
83
92
|
|
|
84
93
|
</details>
|
|
85
94
|
|
|
86
95
|
### The use command
|
|
96
|
+
|
|
87
97
|
The use command allows you to switch between different environments for your Powerhouse project dependencies.
|
|
88
98
|
|
|
89
99
|
```bash
|
|
90
100
|
ph use <environment> [localPath]
|
|
91
|
-
```
|
|
101
|
+
```
|
|
102
|
+
|
|
92
103
|
**Available Environments**
|
|
104
|
+
|
|
93
105
|
- latest - Uses the latest stable version of all Powerhouse packages.
|
|
94
106
|
- dev - Uses development versions of the packages.
|
|
95
107
|
- prod - Uses production versions of the packages.
|
|
@@ -98,26 +110,31 @@ ph use <environment> [localPath]
|
|
|
98
110
|
**Examples**
|
|
99
111
|
|
|
100
112
|
#### Switch to latest stable versions
|
|
113
|
+
|
|
101
114
|
```bash
|
|
102
115
|
ph use latest
|
|
103
|
-
```
|
|
116
|
+
```
|
|
104
117
|
|
|
105
118
|
#### Switch to development versions
|
|
119
|
+
|
|
106
120
|
```bash
|
|
107
121
|
ph use dev
|
|
108
|
-
```
|
|
122
|
+
```
|
|
109
123
|
|
|
110
124
|
#### Use local versions from a specific path
|
|
125
|
+
|
|
111
126
|
```bash
|
|
112
127
|
ph use local /path/to/local/packages
|
|
113
|
-
```
|
|
128
|
+
```
|
|
114
129
|
|
|
115
130
|
#### Use a specific package manager
|
|
131
|
+
|
|
116
132
|
```bash
|
|
117
133
|
ph use latest --package-manager pnpm
|
|
118
|
-
```
|
|
134
|
+
```
|
|
119
135
|
|
|
120
136
|
### The update command
|
|
137
|
+
|
|
121
138
|
The update command allows you to update your Powerhouse dependencies to their latest versions based on the version ranges specified in your package.json.
|
|
122
139
|
|
|
123
140
|
```bash
|
|
@@ -125,22 +142,27 @@ ph update [options]
|
|
|
125
142
|
```
|
|
126
143
|
|
|
127
144
|
**Examples**
|
|
145
|
+
|
|
128
146
|
#### Update dependencies based on package.json ranges
|
|
147
|
+
|
|
129
148
|
```bash
|
|
130
149
|
ph update
|
|
131
150
|
```
|
|
132
151
|
|
|
133
152
|
#### Force update to latest dev versions
|
|
153
|
+
|
|
134
154
|
```bash
|
|
135
155
|
ph update --force dev
|
|
136
156
|
```
|
|
137
157
|
|
|
138
158
|
#### Force update to latest stable versions
|
|
159
|
+
|
|
139
160
|
```bash
|
|
140
161
|
ph update --force prod
|
|
141
162
|
```
|
|
142
163
|
|
|
143
164
|
#### Use a specific package manager
|
|
165
|
+
|
|
144
166
|
```bash
|
|
145
167
|
ph update --package-manager pnpm
|
|
146
168
|
```
|
|
@@ -148,11 +170,13 @@ ph update --package-manager pnpm
|
|
|
148
170
|
## **Key differences**
|
|
149
171
|
|
|
150
172
|
### **Use command**
|
|
173
|
+
|
|
151
174
|
- For switching between different **environments**.
|
|
152
175
|
- Requires you to specify an environment.
|
|
153
176
|
- Can work with **local packages**.
|
|
154
177
|
|
|
155
178
|
### **Update command**
|
|
179
|
+
|
|
156
180
|
- Updating **dependencies** within your current environment.
|
|
157
181
|
- Optional with its parameters.
|
|
158
182
|
- Focused on updating **remote package** versions.
|
|
@@ -160,12 +184,15 @@ ph update --package-manager pnpm
|
|
|
160
184
|
Both commands support multiple package managers (npm, yarn, pnpm, and bun) and will automatically detect your project's package manager based on the lockfile present in your project directory.
|
|
161
185
|
|
|
162
186
|
## Boilerplate
|
|
163
|
-
___
|
|
164
|
-
The Document Model Boilerplate is a foundational template that is used for code generation when scaffolding your editors and models. It ensures compatibility with host applications like Connect and Switchboard for seamless Document Model and editor integration.
|
|
165
187
|
|
|
166
|
-
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
The Document Model Boilerplate is a foundational template that is used for code generation when scaffolding your editors and models. It ensures compatibility with host applications like Connect and Switchboard for seamless Document Model and editor integration.
|
|
191
|
+
|
|
192
|
+
After installing `ph-cmd`, you will run `ph init` to initialize a project directory and structure. This initialization command makes use of the boilerplate.
|
|
167
193
|
|
|
168
194
|
The boilerplate includes essential commands with NPM/PNPM scripts for:
|
|
195
|
+
|
|
169
196
|
- Generating code
|
|
170
197
|
- Linting
|
|
171
198
|
- Formatting
|
|
@@ -173,8 +200,11 @@ The boilerplate includes essential commands with NPM/PNPM scripts for:
|
|
|
173
200
|
- Testing
|
|
174
201
|
|
|
175
202
|
## Design system
|
|
176
|
-
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
177
206
|
The Powerhouse Design System is a collection of reusable front-end components based on GraphQL scalars, including custom scalars specific to the web3 ecosystem. It provides:
|
|
207
|
+
|
|
178
208
|
- Consistent UI components across Powerhouse applications
|
|
179
209
|
- Automatic inclusion as a dependency in new Document Model projects
|
|
180
210
|
- Customization options using CSS variables
|
|
@@ -182,29 +212,37 @@ The Powerhouse Design System is a collection of reusable front-end components ba
|
|
|
182
212
|
We cover some of these topics in our design system documentation. Read more about the [design system here](/academy/ComponentLibrary/DocumentEngineering)
|
|
183
213
|
|
|
184
214
|
## Reactor libraries
|
|
185
|
-
|
|
186
|
-
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
Reactors are the nodes in the Powerhouse network that handle document storage, conflict resolution, and operation verification.
|
|
187
219
|
The Reactor Libraries include:
|
|
188
220
|
|
|
189
221
|
### API
|
|
222
|
+
|
|
190
223
|
- **Subgraphs**: Modular GraphQL services that connect to the Reactor for structured data access
|
|
191
224
|
- **Processors**: Event-driven components that react to document changes and process data
|
|
192
225
|
|
|
193
226
|
### Browser
|
|
227
|
+
|
|
194
228
|
Handles client-side interactions
|
|
195
229
|
|
|
196
230
|
### Local
|
|
231
|
+
|
|
197
232
|
Manages local storage and offline functionality
|
|
198
233
|
|
|
199
234
|
### Drive app
|
|
200
|
-
|
|
235
|
+
|
|
236
|
+
Handles document organization and storage management, but can also be customized to offer specific functionality, categorization, or tailored interfaces for your documents.
|
|
201
237
|
|
|
202
238
|
## Code generators
|
|
203
|
-
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
204
242
|
Powerhouse provides several code generation tools to streamline development:
|
|
205
243
|
|
|
206
244
|
### Document model scaffolding
|
|
207
|
-
Generates the basic structure for new Document Models with the command `ph init` based on the boilerplate.
|
|
245
|
+
Generates the basic structure for new Document Models with the command `ph init` based on the boilerplate.
|
|
208
246
|
|
|
209
247
|
### Editor generator
|
|
210
248
|
Creates template code for Document Model editors with the command `ph generate --editor <name> --document-types <documenttype>`
|
|
@@ -222,14 +260,18 @@ Powerhouse provides several code generation tools to streamline development:
|
|
|
222
260
|
Creates specialized processors for analytics tracking
|
|
223
261
|
|
|
224
262
|
## Analytics engine
|
|
225
|
-
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
226
266
|
The Analytics Engine is a system that allows tracking and analyzing operations and state changes on Document Models. Features include:
|
|
267
|
+
|
|
227
268
|
- Custom dashboard and report generation
|
|
228
269
|
- Document Model-specific analytics
|
|
229
270
|
- Metric and dimension tracking
|
|
230
271
|
- Data combination from multiple Document Models
|
|
231
272
|
|
|
232
273
|
Generate an analytics processor using:
|
|
274
|
+
|
|
233
275
|
```bash
|
|
234
276
|
ph generate --processor-type analytics
|
|
235
|
-
```
|
|
277
|
+
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"label": "Builder environment",
|
|
3
|
+
"link": {
|
|
4
|
+
"type": "doc",
|
|
5
|
+
"id": "academy/MasteryTrack/BuilderEnvironment/Prerequisites"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# What is a document model?
|
|
2
2
|
|
|
3
3
|
:::tip
|
|
4
|
-
This chapter on **Document Model Creation** will help you with an in depth practicial understanding while building an **advanced to-do list** document model.
|
|
4
|
+
This chapter on **Document Model Creation** will help you with an in depth practicial understanding while building an **advanced to-do list** document model.
|
|
5
5
|
Although not required, if you have completed the 'Get Started' tutorial you will revisit familiar topics and can update your existing document model.
|
|
6
6
|
:::
|
|
7
7
|
|
|
8
8
|
:::info **Definition: What is a Document Model?**
|
|
9
9
|
A Document Model is a programmable document structure that defines how data is stored, changed, and interpreted in a decentralized system. It acts like a living blueprint—capturing state, tracking changes, and enabling interaction through defined operations.
|
|
10
10
|
|
|
11
|
-
For instance, an invoice document model might define fields like
|
|
11
|
+
For instance, an invoice document model might define fields like _issuer_, _lineItems_, and _status_, with operations such as _AddLineItem_ and _MarkAsPaid_.
|
|
12
12
|
:::
|
|
13
13
|
|
|
14
|
-
A Document Model can be understood as:
|
|
15
|
-
|
|
16
|
-
- A
|
|
17
|
-
- A
|
|
14
|
+
A Document Model can be understood as:
|
|
15
|
+
|
|
16
|
+
- A structured software framework that represents and **manages business logic** within a digital environment.
|
|
17
|
+
- A sophisticated template that **encapsulates the essential aspects of a digital process or a set of data**.
|
|
18
|
+
- A blueprints that define how data is **captured, manipulated, and visualised** within a system.
|
|
18
19
|
- A **standardized way to store, modify, and query data** in scalable, decentralized applications.
|
|
19
20
|
|
|
20
21
|
### **How does a document model function?**
|
|
@@ -27,7 +28,7 @@ Each document model consists of three key components:
|
|
|
27
28
|
2. **Document Operations** – Defines how the document can be modified.
|
|
28
29
|
3. **Event History** – Maintains an append-only log of changes.
|
|
29
30
|
|
|
30
|
-
Document models leverage **event sourcing, CQRS (Command Query Responsibility Segregation), and an append-only architecture** to ensure immutability, auditability, and scalability.
|
|
31
|
+
Document models leverage **event sourcing, CQRS (Command Query Responsibility Segregation), and an append-only architecture** to ensure immutability, auditability, and scalability.
|
|
31
32
|
|
|
32
33
|
---
|
|
33
34
|
|
|
@@ -43,19 +44,19 @@ Example of a **GraphQL-like state schema** for an invoice document:
|
|
|
43
44
|
|
|
44
45
|
```graphql
|
|
45
46
|
type InvoiceState {
|
|
46
|
-
id: OID!
|
|
47
|
-
issuer: OID!
|
|
48
|
-
recipient: OID!
|
|
49
|
-
status: String
|
|
50
|
-
dueDate: DateTime
|
|
47
|
+
id: OID! # Unique identifier for the invoice
|
|
48
|
+
issuer: OID! # Reference to the issuing entity
|
|
49
|
+
recipient: OID! # Reference to the recipient entity
|
|
50
|
+
status: String # (value: "DRAFT") # Invoice status
|
|
51
|
+
dueDate: DateTime # Payment due date
|
|
51
52
|
lineItems: [LineItem!]! # List of line items
|
|
52
|
-
totalAmount: Currency
|
|
53
|
+
totalAmount: Currency # Computed field for total invoice value
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
type LineItem {
|
|
56
57
|
id: OID!
|
|
57
58
|
description: String
|
|
58
|
-
quantity: Int
|
|
59
|
+
quantity: Int
|
|
59
60
|
unitPrice: Currency
|
|
60
61
|
}
|
|
61
62
|
```
|
|
@@ -80,7 +81,7 @@ Example operations for modifying an invoice:
|
|
|
80
81
|
input AddLineItemInput {
|
|
81
82
|
invoiceId: OID!
|
|
82
83
|
description: String
|
|
83
|
-
quantity: Int
|
|
84
|
+
quantity: Int
|
|
84
85
|
unitPrice: Currency
|
|
85
86
|
}
|
|
86
87
|
|
|
@@ -94,7 +95,7 @@ input MarkAsPaidInput {
|
|
|
94
95
|
}
|
|
95
96
|
```
|
|
96
97
|
|
|
97
|
-
Each operation **modifies the document state** without altering past data.
|
|
98
|
+
Each operation **modifies the document state** without altering past data.
|
|
98
99
|
Instead, a new event is appended to the document history.
|
|
99
100
|
|
|
100
101
|
---
|
|
@@ -109,7 +110,7 @@ Every operation applied to a document is **stored as an event** in an append-onl
|
|
|
109
110
|
[
|
|
110
111
|
{ "timestamp": 1700000001, "operation": "CREATE_INVOICE", "data": { "id": "inv-001", "issuer": "company-123", "recipient": "client-456" } },
|
|
111
112
|
{ "timestamp": 1700000100, "operation": "ADD_LINE_ITEM", "data": { "description": "Software Development", "quantity": 10, "unitPrice": 100 } },
|
|
112
|
-
{ "timestamp": 1700000200, "operation": "MARK_AS_PAID", "data": {}
|
|
113
|
+
{ "timestamp": 1700000200, "operation": "MARK_AS_PAID", "data": {}
|
|
113
114
|
```
|
|
114
115
|
|
|
115
116
|
### **Event history benefits:**
|
|
@@ -136,7 +137,11 @@ Document models in Powerhouse rely on **event-driven architecture, event sourcin
|
|
|
136
137
|
```json
|
|
137
138
|
{
|
|
138
139
|
"operation": "CREATE_INVOICE",
|
|
139
|
-
"data": {
|
|
140
|
+
"data": {
|
|
141
|
+
"id": "inv-001",
|
|
142
|
+
"issuer": "company-123",
|
|
143
|
+
"recipient": "client-456"
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
```
|
|
142
147
|
|
|
@@ -155,7 +160,11 @@ Adding a line item:
|
|
|
155
160
|
```json
|
|
156
161
|
{
|
|
157
162
|
"operation": "ADD_LINE_ITEM",
|
|
158
|
-
"data": {
|
|
163
|
+
"data": {
|
|
164
|
+
"description": "Software Development",
|
|
165
|
+
"quantity": 10,
|
|
166
|
+
"unitPrice": 100
|
|
167
|
+
}
|
|
159
168
|
}
|
|
160
169
|
```
|
|
161
170
|
|
|
@@ -198,8 +207,8 @@ Document Models offer a range of features that can be leveraged to create sophis
|
|
|
198
207
|
- **Collaboration**: Empower decentralized teams to build, modify, and share documents asynchronously.
|
|
199
208
|
- **Extensibility**: Add new fields, operations, and integrations over time without rewriting logic.
|
|
200
209
|
|
|
201
|
-
Document Models are a powerful primitive within the Powerhouse vision, offering a flexible, structured, and efficient way to manage business logic and data.
|
|
210
|
+
Document Models are a powerful primitive within the Powerhouse vision, offering a flexible, structured, and efficient way to manage business logic and data.
|
|
202
211
|
|
|
203
212
|
### Up next: How to build a document model
|
|
204
213
|
|
|
205
|
-
In the next chapters, we'll teach you how to build a To-do List document model while explaining all of the theory that is involved.
|
|
214
|
+
In the next chapters, we'll teach you how to build a To-do List document model while explaining all of the theory that is involved.
|
|
@@ -5,29 +5,34 @@ The state schema is the backbone of your document model. It defines the structur
|
|
|
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 `ToDoList` document, you might have a `ToDoListState` type and a `ToDoItem` type.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
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).
|
|
12
13
|
|
|
13
14
|
### Fields
|
|
15
|
+
|
|
14
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!`.
|
|
15
17
|
|
|
16
18
|
### Scalars
|
|
19
|
+
|
|
17
20
|
GraphQL has a set of built-in **scalar types**:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
- `String`: A UTF‐8 character sequence.
|
|
23
|
+
- `Int`: A signed 32‐bit integer.
|
|
24
|
+
- `Float`: A signed double-precision floating-point value.
|
|
25
|
+
- `Boolean`: `true` or `false`.
|
|
26
|
+
- `ID`: A unique identifier, often used as a key for a field. It is serialized in the same way as a String; however, it is not intended to be human-readable.
|
|
23
27
|
|
|
24
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.
|
|
25
29
|
|
|
26
30
|
### Lists and non-null
|
|
27
31
|
|
|
28
32
|
You can modify types using lists and non-null indicators:
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
|
|
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.
|
|
31
36
|
|
|
32
37
|
## Example: ToDoList state schema
|
|
33
38
|
|
|
@@ -56,21 +61,21 @@ type ToDoListStats {
|
|
|
56
61
|
|
|
57
62
|
### Breakdown:
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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.
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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.
|
|
72
|
+
- `text: String!`: The textual description of the to-do item. It cannot be null, ensuring every to-do has a description.
|
|
73
|
+
- `checked: Boolean!`: Indicates whether the to-do item is completed. It defaults to a boolean value (true or false) and cannot be null.
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
- **`ToDoListStats` type**: This type holds the summary statistics for the to-do list.
|
|
76
|
+
- `total: Int!`: The total count of all to-do items. This field must be an integer and cannot be null.
|
|
77
|
+
- `checked: Int!`: The number of to-do items that are marked as completed. This must be an integer and cannot be null.
|
|
78
|
+
- `unchecked: Int!`: The number of to-do items that are still pending. This also must be an integer and cannot be null.
|
|
74
79
|
|
|
75
80
|
## Best practices for designing your state schema
|
|
76
81
|
|
|
@@ -78,9 +83,9 @@ type ToDoListStats {
|
|
|
78
83
|
2. **Clarity and Explicitness**: Name your types and fields clearly and descriptively. This makes the schema easier to understand and maintain.
|
|
79
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.
|
|
80
85
|
4. **Normalize vs. Denormalize**:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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`.
|
|
88
|
+
- The choice depends on your specific use case, query patterns, and how data is updated.
|
|
84
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.
|
|
85
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.
|
|
86
91
|
|
|
@@ -91,26 +96,26 @@ By carefully defining your state schema, you lay a solid foundation for your Pow
|
|
|
91
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.
|
|
92
97
|
|
|
93
98
|
<details>
|
|
94
|
-
<summary>Tutorial: The state schema specification</summary>
|
|
99
|
+
<summary>Tutorial: The state schema specification</summary>
|
|
95
100
|
|
|
96
101
|
### Prerequisites
|
|
97
102
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
103
|
+
- You have a Powerhouse project set up. If not, please follow the [Create a new Powerhouse Project](../../GetStarted/CreateNewPowerhouseProject) tutorial.
|
|
104
|
+
- Connect Studio is running. If not, navigate to your project directory in the terminal and run `ph connect`.
|
|
100
105
|
|
|
101
106
|
### Steps
|
|
102
107
|
|
|
103
108
|
1. **Create a New Document Model**:
|
|
104
|
-
-
|
|
105
|
-
-
|
|
109
|
+
- With Connect Studio open in your browser, navigate into your local drive.
|
|
110
|
+
- At the bottom of the page in the 'New Document' section, click the `DocumentModel` button to create a new document model specification.
|
|
106
111
|
|
|
107
112
|
2. **Define Document Metadata**:
|
|
108
|
-
-
|
|
109
|
-
-
|
|
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`.
|
|
110
115
|
|
|
111
116
|
3. **Specify the State Schema**:
|
|
112
|
-
-
|
|
113
|
-
-
|
|
117
|
+
- In the code editor provided, you'll see a template for a GraphQL schema.
|
|
118
|
+
- Replace the entire content of the editor with the advanced `ToDoList` schema we've designed in this chapter:
|
|
114
119
|
|
|
115
120
|
```graphql
|
|
116
121
|
# The state of our ToDoList
|
|
@@ -134,8 +139,8 @@ Now that you understand the concepts behind the state schema, let's put it into
|
|
|
134
139
|
```
|
|
135
140
|
|
|
136
141
|
4. **Sync Schema and View Initial State**:
|
|
137
|
-
-
|
|
138
|
-
-
|
|
142
|
+
- After pasting the schema, click the **'Sync with schema'** button.
|
|
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.
|
|
139
144
|
|
|
140
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.
|
|
141
146
|
|
|
@@ -144,4 +149,3 @@ By completing these steps, you have successfully specified the data structure fo
|
|
|
144
149
|
</details>
|
|
145
150
|
|
|
146
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.
|
|
147
|
-
|