@powerhousedao/academy 0.1.0-dev.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/.vscode/settings.json +3 -0
- package/CHANGELOG.md +9 -0
- package/Dockerfile +31 -0
- package/ProcFile +1 -0
- package/README.md +43 -0
- package/babel.config.js +3 -0
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +88 -0
- package/blog/TheChallengeOfChange.md +86 -0
- package/blog/images/Iteration.png +0 -0
- package/blog/images/RAD.png +0 -0
- package/docs/academy/01-GetStarted/00-GetStarted.mdx +181 -0
- package/docs/academy/01-GetStarted/01_InstallDemoPackage.md +38 -0
- package/docs/academy/01-GetStarted/02-ToDoList/01-CreateNewPowerhouseProject.md +97 -0
- package/docs/academy/01-GetStarted/02-ToDoList/02-DefineToDoListDocumentModel.md +86 -0
- package/docs/academy/01-GetStarted/02-ToDoList/03-ImplementOperationReducers.md +201 -0
- package/docs/academy/01-GetStarted/02-ToDoList/04-BuildToDoListEditor.md +494 -0
- package/docs/academy/01-GetStarted/02-ToDoList/_category_.json +8 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/DocumentModelHeader.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/DocumentModelOperations.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/OpenDocumentModelEditor.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/completeEditor.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/connectApp.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/form.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/mytodolist.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/reducers.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/vscode.png +0 -0
- package/docs/academy/01-GetStarted/styles.module.css +99 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/00-BuilderTools.md +234 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/01-SetupBuilderEnvironment.md +247 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/04-UtilitiesAndTips.md +79 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/01-SetupBuilderEnvironment.md +216 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/02-CreateNewPowerhouseProject.md +78 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/03-DefineChatroomDocumentModel.md +139 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/04-ImplementOperationReducers.md +364 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/05-ImplementChatroomEditor.md +194 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/06-LaunchALocalReactor.md +15 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-1.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-2.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-3.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-4.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-5.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/ChatRoomConnectApp.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/ChatRoomTest.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/completeEditor.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/form.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/reducers.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/vscode.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-StandardDocumentModelWorkflow.md +229 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/01-BuildingBeautifulDocumentEditors.md +109 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/02-ConfiguringDrives.md +51 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/03-BuildingADriveExplorer.md +174 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/01-OperationHistory.md +67 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/02-RevisionHistoryTimeline.md +132 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/_category_.json +7 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/committer-address-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/revision-hash-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/revision-history-list.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/signature-details-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/images/CreateDrive.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/images/mytodolist.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/01-ReadingAndWritingThroughTheAPI.mdx +121 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/02-GraphQLAtPowerhouse.md +156 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/02-GraphQLAndSubgraphs.mdx +119 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/03-WorkingWithSubgraphs.md +312 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/04-analytics-processor.md +342 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/01-SetupBuilderEnvironment.md +215 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/02-CreateNewPowerhouseProject.md +55 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/03-GenerateAnAnalyticsProcessor.md +173 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/04-UpdateAnalyticsProcessor.md +223 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-SPV.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-a-new-asset.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-a-transaction.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Transaction-table.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/create-a-new-RWA-document.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/granularity.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/QueryingADocumentWithGraphQL.md +244 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/listener-raw.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/raw-reports1.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/raw-reports2.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/rwaRegister.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/apse.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/best-practices.md +60 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/filter.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/filteroptions.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/graphql/index.md +166 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/graphql/integration.md +75 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/dbs.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/high-level.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/indexeddb.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/libs-core.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/libs.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/lod.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/logo.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/navbar.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-1.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-2.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-3.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-4.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-5.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-6.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/paths-1.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/paths-2.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/intro.md +149 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/benchmarks.md +27 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/browser.md +77 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/compatibility.md +14 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/index.md +230 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/memory.md +72 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/pg.md +63 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/schema.md +14 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/utilities.md +102 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/index.md +7 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/maker.md +652 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/processors.md +3 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/OperationHistory.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/OperationsQuery.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/QueryDocumentID.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/SwitchboardButton.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/00-IntegrateInAFront-End +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/01-IntroducingFusion +18 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/02-IntroductionToPackages.md +79 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/02-PublishYourProject.md +230 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/03-RunOnACloudServer.md +279 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/03-SetupEnvironment.md +436 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/04-GraphQLNamespacing +44 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/05-LaunchYourBackend.md +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/06-LaunchYourFrontend.md +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/SSHConnection.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/homedesign.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/keyconcepts.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/tutorialschema.png +0 -0
- package/docs/academy/02-AdvancedTutorial/06-Authorization/Authorization.md +100 -0
- package/docs/academy/02-AdvancedTutorial/_category_.json +7 -0
- package/docs/academy/03-APIReferences/00-PowerhouseCLI.md +1 -0
- package/docs/academy/03-APIReferences/_category_.json +7 -0
- package/docs/academy/04-ComponentLibrary/01-PowerhouseDesignSystem.md +94 -0
- package/docs/academy/04-ComponentLibrary/02-BuildingWithScalars.md +54 -0
- package/docs/academy/04-ComponentLibrary/03-Scalar-Components/01-phid-field.mdx +72 -0
- package/docs/academy/04-ComponentLibrary/03-Scalar-Components/02-input-field.mdx +0 -0
- package/docs/academy/04-ComponentLibrary/04-Complex-Components/01-sidebar.mdx +36 -0
- package/docs/academy/04-ComponentLibrary/05-Layout-Components/01-test-toupdate.mdx +61 -0
- package/docs/academy/04-ComponentLibrary/06-Fragments/01-test-toupdate.mdx +61 -0
- package/docs/academy/04-ComponentLibrary/_category_.json +8 -0
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +50 -0
- package/docs/academy/05-Architecture/01-WorkingWithTheReactor.md +48 -0
- package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
- package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/01-WhatIsADocumentModel.md +188 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/02-DAOandDocumentsModelsQ+A.md +177 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/02-domain-modeling.md +103 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/03-BenefitsOfDocumentModels.md +95 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/05-best-practices.md +257 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/_category_.json +8 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/three-data-layers.png +0 -0
- package/docs/academy/05-Architecture/_category_.json +7 -0
- package/docs/academy/05-Architecture/images/image.png +0 -0
- package/docs/academy/06-Cookbook.md +905 -0
- package/docs/academy/07-Glossary.md +50 -0
- package/docs/bookofpowerhouse/01-Overview.md +29 -0
- package/docs/bookofpowerhouse/02-GeneralFrameworkAndPhilosophy.md +15 -0
- package/docs/bookofpowerhouse/03-PowerhouseSoftwareArchitecture.md +33 -0
- package/docs/bookofpowerhouse/04-DevelopmentApproaches.md +36 -0
- package/docs/bookofpowerhouse/05-SNOsandANewModelForOSSandPublicGoods.md +73 -0
- package/docs/bookofpowerhouse/06-SNOsInActionAndPlatformEconomies.md +17 -0
- package/docs/renown/01-intro.md +18 -0
- package/docs/renown/02-renown-login-flow.md +60 -0
- package/docusaurus +0 -0
- package/docusaurus.config.ts +170 -0
- package/package.json +50 -0
- package/powerhouse-docs@0.0.0 +0 -0
- package/sidebars.ts +33 -0
- package/src/components/HomepageFeatures/index.tsx +250 -0
- package/src/components/HomepageFeatures/styles.module.css +267 -0
- package/src/css/custom.css +450 -0
- package/src/pages/index.module.css +37 -0
- package/src/pages/index.tsx +42 -0
- package/src/pages/markdown-page.md +7 -0
- package/static/.nojekyll +0 -0
- package/static/fonts/FranieBold.otf +0 -0
- package/static/fonts/FranieRegular.otf +0 -0
- package/static/img/Powerhouse Website Drive.png +0 -0
- package/static/img/Powerhouse Website Storage Layer (1).png +0 -0
- package/static/img/Powerhouse Website Storage Layer.png +0 -0
- package/static/img/Powerhouse-main-light.svg +13 -0
- package/static/img/Powerhouse-main.svg +13 -0
- package/static/img/Renown Intro Diagram.png +0 -0
- package/static/img/Union.svg +3 -0
- package/static/img/academy/icons/Advanced.svg +4 -0
- package/static/img/academy/icons/Book.svg +5 -0
- package/static/img/academy/icons/Cookbook.svg +3 -0
- package/static/img/academy/icons/Create.svg +3 -0
- package/static/img/academy/icons/Data.svg +3 -0
- package/static/img/academy/icons/Editor.svg +3 -0
- package/static/img/academy/icons/Flash.svg +3 -0
- package/static/img/academy/icons/Launch.svg +3 -0
- package/static/img/academy-icon.png +0 -0
- package/static/img/connect-icon.png +0 -0
- package/static/img/connect.png +0 -0
- package/static/img/docusaurus-social-card.jpg +0 -0
- package/static/img/docusaurus.png +0 -0
- package/static/img/empty-background.png +0 -0
- package/static/img/favicon.ico +0 -0
- package/static/img/fusion-icon.png +0 -0
- package/static/img/fusion.png +0 -0
- package/static/img/ph-icon-light.svg +3 -0
- package/static/img/powerhouse-layer.png +0 -0
- package/static/img/powerhouse-storage-layer.png +0 -0
- package/static/img/reactor.png +0 -0
- package/static/img/renown-icon.png +0 -0
- package/static/img/renown.png +0 -0
- package/static/img/switchboard-icon.png +0 -0
- package/static/img/switchboard.png +0 -0
- package/static/img/undraw_docusaurus_mountain.svg +171 -0
- package/static/img/undraw_docusaurus_react.svg +170 -0
- package/static/img/undraw_docusaurus_tree.svg +40 -0
- package/static/img/video-placeholder.svg +16 -0
- package/static.json +7 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Powerhouse Builder Tooling
|
|
2
|
+
|
|
3
|
+
This page provides an overview of all the builder tooling offered by the Powerhouse ecosystem.
|
|
4
|
+
|
|
5
|
+
## Powerhouse Command Line Interface
|
|
6
|
+
___
|
|
7
|
+
|
|
8
|
+
### Installing the Powerhouse CLI
|
|
9
|
+
:::tip
|
|
10
|
+
The Powerhouse CLI tool is the only essential tool to install on this page.
|
|
11
|
+
Once you've installed it with the command below you can continue to the next steps.
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
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:
|
|
15
|
+
```bash
|
|
16
|
+
pnpm install -g ph-cmd
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Key commands include:
|
|
20
|
+
- `ph connect` for running the Connect application locally
|
|
21
|
+
- `ph switchboard` or `ph reactor` for starting the API service
|
|
22
|
+
- `ph init` to start a new project and build a Document Model
|
|
23
|
+
- `ph help` to get an overview of all the available commands
|
|
24
|
+
|
|
25
|
+
This tool will be fundamental on your journey when creating, building, and running Document Models
|
|
26
|
+
|
|
27
|
+
<details>
|
|
28
|
+
<summary> How to make use of different branches? </summary>
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
| Command | Description |
|
|
33
|
+
|---------|-------------|
|
|
34
|
+
| **pnpm install -g ph-cmd** | Install latest stable version |
|
|
35
|
+
| **pnpm install -g ph-cmd@dev** | Install development version |
|
|
36
|
+
| **pnpm install -g ph-cmd@staging** | Install staging version |
|
|
37
|
+
| **ph init** | Use latest stable version of the boilerplate |
|
|
38
|
+
| **ph init --dev** | Use development version of the boilerplate |
|
|
39
|
+
| **ph init --staging** | Use staging version of the boilerplate |
|
|
40
|
+
| **ph use** | Switch all dependencies to latest production versions |
|
|
41
|
+
| **ph use dev** | Switch all dependencies to development versions |
|
|
42
|
+
| **ph use prod** | Switch all dependencies to production versions |
|
|
43
|
+
|
|
44
|
+
Please be aware that these versions can contain bugs and experimental features that aren't fully tested.
|
|
45
|
+
</details>
|
|
46
|
+
|
|
47
|
+
<details>
|
|
48
|
+
|
|
49
|
+
<summary> How to clean your system of the Powerhouse CLI?</summary>
|
|
50
|
+
|
|
51
|
+
### Cleaning and Updating ph-cmd
|
|
52
|
+
|
|
53
|
+
If you need to perform a clean reinstallation of the Powerhouse CLI (`ph-cmd`), follow these steps:
|
|
54
|
+
|
|
55
|
+
1. First, uninstall the global ph-cmd package:
|
|
56
|
+
```bash
|
|
57
|
+
pnpm uninstall -g ph-cmd
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. Remove the Powerhouse configuration directory:
|
|
61
|
+
```bash
|
|
62
|
+
rm -rf ~/.ph
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
3. Reinstall the CLI tool (choose one):
|
|
66
|
+
```bash
|
|
67
|
+
# For the latest stable version
|
|
68
|
+
pnpm install -g ph-cmd
|
|
69
|
+
|
|
70
|
+
# For the staging version
|
|
71
|
+
pnpm install -g ph-cmd@staging
|
|
72
|
+
|
|
73
|
+
# For a specific version
|
|
74
|
+
pnpm install -g ph-cmd@<version>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
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:
|
|
78
|
+
- Troubleshooting CLI issues
|
|
79
|
+
- Upgrading to a new version
|
|
80
|
+
- Switching between stable and staging versions
|
|
81
|
+
- Resolving configuration conflicts
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
### The Use Command
|
|
86
|
+
The use command allows you to switch between different environments for your Powerhouse project dependencies.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
ph use <environment> [localPath]
|
|
90
|
+
```
|
|
91
|
+
**Available Environments**
|
|
92
|
+
- latest - Uses the latest stable version of all Powerhouse packages.
|
|
93
|
+
- dev - Uses development versions of the packages.
|
|
94
|
+
- prod - Uses production versions of the packages.
|
|
95
|
+
- local - Uses local versions of the packages from a specified path.
|
|
96
|
+
|
|
97
|
+
**Examples**
|
|
98
|
+
|
|
99
|
+
#### Switch to latest stable versions
|
|
100
|
+
```bash
|
|
101
|
+
ph use latest
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Switch to development versions
|
|
105
|
+
```bash
|
|
106
|
+
ph use dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Use local versions from a specific path
|
|
110
|
+
```bash
|
|
111
|
+
ph use local /path/to/local/packages
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Use a specific package manager
|
|
115
|
+
```bash
|
|
116
|
+
ph use latest --package-manager pnpm
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### The Update Command
|
|
120
|
+
The update command allows you to update your Powerhouse dependencies to their latest versions based on the version ranges specified in your package.json.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
ph update [options]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Examples**
|
|
127
|
+
#### Update dependencies based on package.json ranges
|
|
128
|
+
```bash
|
|
129
|
+
ph update
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Force update to latest dev versions
|
|
133
|
+
```bash
|
|
134
|
+
ph update --force dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Force update to latest stable versions
|
|
138
|
+
```bash
|
|
139
|
+
ph update --force prod
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Use a specific package manager
|
|
143
|
+
```bash
|
|
144
|
+
ph update --package-manager pnpm
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## **Key Differences**
|
|
148
|
+
|
|
149
|
+
### **Use command**
|
|
150
|
+
- For switching between different **environments**.
|
|
151
|
+
- Requires you to specify an environment.
|
|
152
|
+
- Can work with **local packages**.
|
|
153
|
+
|
|
154
|
+
### **Update command**
|
|
155
|
+
- Updating **dependencies** within your current environment.
|
|
156
|
+
- Optional with its parameters.
|
|
157
|
+
- Focused on updating **remote package** versions.
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
## Boilerplate
|
|
162
|
+
___
|
|
163
|
+
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.
|
|
164
|
+
|
|
165
|
+
After installing `ph-cmd`, you will run `ph init` to initialize a project directory and structure. This initialization command makes use of the boilerplate.
|
|
166
|
+
|
|
167
|
+
The boilerplate includes essential commands with NPM/PNPM scripts for:
|
|
168
|
+
- Generating code
|
|
169
|
+
- Linting
|
|
170
|
+
- Formatting
|
|
171
|
+
- Building
|
|
172
|
+
- Testing
|
|
173
|
+
|
|
174
|
+
## Design System
|
|
175
|
+
___
|
|
176
|
+
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:
|
|
177
|
+
- Consistent UI components across Powerhouse applications
|
|
178
|
+
- Automatic inclusion as a dependency in new Document Model projects
|
|
179
|
+
- Customization options using CSS variables
|
|
180
|
+
|
|
181
|
+
Read more about the [design system here](/docs/academy/ComponentLibrary/PowerhouseDesignSystem)
|
|
182
|
+
|
|
183
|
+
## Reactor Libraries
|
|
184
|
+
___
|
|
185
|
+
Reactors are the nodes in the Powerhouse network that handle document storage, conflict resolution, and operation verification.
|
|
186
|
+
The Reactor Libraries include:
|
|
187
|
+
|
|
188
|
+
### API
|
|
189
|
+
- **Subgraphs**: Modular GraphQL services that connect to the Reactor for structured data access
|
|
190
|
+
- **Processors**: Event-driven components that react to document changes and process data
|
|
191
|
+
|
|
192
|
+
### Browser
|
|
193
|
+
Handles client-side interactions
|
|
194
|
+
|
|
195
|
+
### Local
|
|
196
|
+
Manages local storage and offline functionality
|
|
197
|
+
|
|
198
|
+
### Drive App
|
|
199
|
+
Handles document organization and storage management, but can also be customized to offer specific functionality, categorization, or tailored interfaces for your documents.
|
|
200
|
+
|
|
201
|
+
## Code Generators
|
|
202
|
+
___
|
|
203
|
+
Powerhouse provides several code generation tools to streamline development:
|
|
204
|
+
|
|
205
|
+
### Document Model Scaffolding
|
|
206
|
+
Generates the basic structure for new Document Models with the command `ph init` based on the boilerplate.
|
|
207
|
+
|
|
208
|
+
### Editor Generator
|
|
209
|
+
Creates template code for Document Model editors with the command `ph generate --editor <name> --document-types <documenttype>`
|
|
210
|
+
|
|
211
|
+
### Drive Editor Generator
|
|
212
|
+
Builds scaffolding for custom Drive interfaces with the command `ph generate --drive-editor <name>`
|
|
213
|
+
|
|
214
|
+
### Subgraph Generator
|
|
215
|
+
Creates GraphQL subgraph templates for data access automatically upon `ph reactor`
|
|
216
|
+
|
|
217
|
+
### Processor Generator
|
|
218
|
+
Generates processor templates for event handling automatically upon `ph reactor`
|
|
219
|
+
|
|
220
|
+
### Analytics Processor Generator
|
|
221
|
+
Creates specialized processors for analytics tracking
|
|
222
|
+
|
|
223
|
+
## Analytics Engine
|
|
224
|
+
___
|
|
225
|
+
The Analytics Engine is a system that allows tracking and analyzing operations and state changes on Document Models. Features include:
|
|
226
|
+
- Custom dashboard and report generation
|
|
227
|
+
- Document Model-specific analytics
|
|
228
|
+
- Metric and dimension tracking
|
|
229
|
+
- Data combination from multiple Document Models
|
|
230
|
+
|
|
231
|
+
Generate an analytics processor using:
|
|
232
|
+
```bash
|
|
233
|
+
ph generate --processor-type analytics
|
|
234
|
+
```
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Setup Builder Environment
|
|
2
|
+
|
|
3
|
+
Let's set up your machine to start building your first Document Model. Don't worry if this is your first time setting up a development environment - we'll guide you through each step!
|
|
4
|
+
|
|
5
|
+
:::info
|
|
6
|
+
If you've already set up Git, Node, and pnpm, your most important step is to install the Powerhouse CLI with the command `pnpm install ph-cmd`. A global install is recommended if you want to use the command from any directory as a power user. In this case use `pnpm install -g ph-cmd`. The Powerhouse CLI is used to create, build, and run your Document Models and gives you direct access to a series of [Powerhouse Builder Tools](../Create/BuilderTools)
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
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:
|
|
10
|
+
```bash
|
|
11
|
+
pnpm install -g ph-cmd
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Key commands include:
|
|
15
|
+
- `ph connect` for running the Connect application locally
|
|
16
|
+
- `ph switchboard` or `ph reactor` for starting the API service
|
|
17
|
+
- `ph init` to start a new project and build a document model
|
|
18
|
+
- `ph help` to get an overview of all the available commands
|
|
19
|
+
|
|
20
|
+
This tool will be fundamental on your journey when creating, building, and running Document Models.
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary> How to make use of different branches? </summary>
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
| Command | Description |
|
|
28
|
+
|---------|-------------|
|
|
29
|
+
| **pnpm install -g ph-cmd** | Install latest stable version |
|
|
30
|
+
| **pnpm install -g ph-cmd@dev** | Install development version |
|
|
31
|
+
| **pnpm install -g ph-cmd@staging** | Install staging version |
|
|
32
|
+
| **ph init** | Use latest stable version of the boilerplate |
|
|
33
|
+
| **ph init --dev** | Use development version of the boilerplate |
|
|
34
|
+
| **ph init --staging** | Use staging version of the boilerplate |
|
|
35
|
+
| **ph use** | Switch all dependencies to latest production versions |
|
|
36
|
+
| **ph use dev** | Switch all dependencies to development versions |
|
|
37
|
+
| **ph use prod** | Switch all dependencies to production versions |
|
|
38
|
+
|
|
39
|
+
Please be aware that these versions can contain bugs and experimental features that aren't fully tested.
|
|
40
|
+
</details>
|
|
41
|
+
___
|
|
42
|
+
|
|
43
|
+
## Table of Contents
|
|
44
|
+
- [Prerequisites](#prerequisites)
|
|
45
|
+
- [Installing node.js 22](#installing-nodejs)
|
|
46
|
+
- [For Windows](#for-windows)
|
|
47
|
+
- [For macOS](#for-macos)
|
|
48
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian)
|
|
49
|
+
- [Installing Visual Studio Code](#installing-visual-studio-code)
|
|
50
|
+
- [For Windows](#for-windows-1)
|
|
51
|
+
- [For macOS](#for-macos-1)
|
|
52
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian-1)
|
|
53
|
+
- [Install Git](#install-git)
|
|
54
|
+
- [For Windows](#for-windows-2)
|
|
55
|
+
- [For macOS](#for-macos-2)
|
|
56
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian-2)
|
|
57
|
+
- [Configure Git](#configure-git-all-systems)
|
|
58
|
+
- [Verify Installation](#verify-installation)
|
|
59
|
+
|
|
60
|
+
## Prerequisites
|
|
61
|
+
|
|
62
|
+
Before we begin building our Document Model, we need to install some software on your machine. We'll need three main tools: node.js 22, which helps us run our code, Visual Studio Code (VS Code), which is where we'll write our code, and Git, which helps us manage our code. Follow the steps below based on your computer's operating system.
|
|
63
|
+
|
|
64
|
+
### Installing node.js 22
|
|
65
|
+
|
|
66
|
+
node.js 22 is a tool that lets us run our application. Let's install it step by step.
|
|
67
|
+
|
|
68
|
+
#### For Windows:
|
|
69
|
+
1. **Set up PowerShell for running commands:**
|
|
70
|
+
- Press the Windows key
|
|
71
|
+
- Type "PowerShell"
|
|
72
|
+
- Right-click on "Windows PowerShell" and select "Run as administrator"
|
|
73
|
+
- In the PowerShell window, type this command and press Enter:
|
|
74
|
+
```powershell
|
|
75
|
+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
76
|
+
```
|
|
77
|
+
- Type 'A' when prompted to confirm
|
|
78
|
+
- You can now close this window and open PowerShell normally for the remaining steps
|
|
79
|
+
|
|
80
|
+
2. **Install node.js 22:**
|
|
81
|
+
- Visit the [node.js 22 official website](https://nodejs.org/)
|
|
82
|
+
- Click the big green button that says "LTS" (this means Long Term Support - it's the most stable version)
|
|
83
|
+
- Once the installer downloads, double-click it to start installation
|
|
84
|
+
- Click "Next" through the installation wizard, leaving all settings at their defaults
|
|
85
|
+
|
|
86
|
+
3. **Verify Installation:**
|
|
87
|
+
- Open PowerShell (no need for admin mode)
|
|
88
|
+
- Type these commands one at a time and press Enter after each:
|
|
89
|
+
```powershell
|
|
90
|
+
node --version
|
|
91
|
+
pnpm --version
|
|
92
|
+
```
|
|
93
|
+
- You should see version numbers appear after each command (e.g., v18.17.0). If you do, congratulations - node.js 22 is installed!
|
|
94
|
+
|
|
95
|
+
> **Note**: If node.js 22 commands don't work in VS Code, restart VS Code to refresh environment variables.
|
|
96
|
+
|
|
97
|
+
#### For macOS:
|
|
98
|
+
1. **Install Homebrew:**
|
|
99
|
+
- Open Terminal (press Command + Space and type "Terminal")
|
|
100
|
+
- Copy and paste this command into Terminal and press Enter:
|
|
101
|
+
```bash
|
|
102
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
103
|
+
```
|
|
104
|
+
- Follow any additional instructions that appear
|
|
105
|
+
|
|
106
|
+
2. **Install node.js 22:**
|
|
107
|
+
- In the same Terminal window, type this command and press Enter:
|
|
108
|
+
```bash
|
|
109
|
+
brew install node
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
3. **Verify Installation:**
|
|
113
|
+
- In Terminal, type these commands one at a time and press Enter after each:
|
|
114
|
+
```bash
|
|
115
|
+
node --version
|
|
116
|
+
pnpm --version
|
|
117
|
+
```
|
|
118
|
+
- If you see version numbers, you've successfully installed node.js 22!
|
|
119
|
+
|
|
120
|
+
#### For Linux (Ubuntu/Debian):
|
|
121
|
+
1. **Open Terminal:**
|
|
122
|
+
- Press Ctrl + Alt + T on your keyboard, or
|
|
123
|
+
- Click the Activities button and type "Terminal"
|
|
124
|
+
|
|
125
|
+
2. **Update Package List:**
|
|
126
|
+
```bash
|
|
127
|
+
sudo apt update
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
3. **Install node.js 22 and pnpm:**
|
|
131
|
+
```bash
|
|
132
|
+
sudo apt install nodejs pnpm
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
4. **Verify Installation:**
|
|
136
|
+
- Type these commands one at a time and press Enter after each:
|
|
137
|
+
```bash
|
|
138
|
+
node --version
|
|
139
|
+
pnpm --version
|
|
140
|
+
```
|
|
141
|
+
- If you see version numbers, you're all set!
|
|
142
|
+
|
|
143
|
+
### Installing Visual Studio Code
|
|
144
|
+
|
|
145
|
+
VS Code is the editor we'll use to write our code. Here's how to install it:
|
|
146
|
+
|
|
147
|
+
#### For Windows:
|
|
148
|
+
1. Visit the [Visual Studio Code website](https://code.visualstudio.com/)
|
|
149
|
+
2. Click the blue "Download for Windows" button
|
|
150
|
+
3. Once the installer downloads, double-click it
|
|
151
|
+
4. Accept the license agreement and click "Next"
|
|
152
|
+
5. Leave the default installation location and click "Next"
|
|
153
|
+
6. In the Select Additional Tasks window, make sure "Add to PATH" is checked
|
|
154
|
+
7. Click "Next" and then "Install"
|
|
155
|
+
8. When installation is complete, click "Finish"
|
|
156
|
+
|
|
157
|
+
#### For macOS:
|
|
158
|
+
1. Visit the [Visual Studio Code website](https://code.visualstudio.com/)
|
|
159
|
+
2. Click the blue "Download for Mac" button
|
|
160
|
+
3. Once the .zip file downloads, double-click it to extract
|
|
161
|
+
4. Drag Visual Studio Code.app to the Applications folder
|
|
162
|
+
5. Double-click the app to launch it
|
|
163
|
+
6. To make VS Code available in your terminal:
|
|
164
|
+
- Open VS Code
|
|
165
|
+
- Press Command + Shift + P
|
|
166
|
+
- Type "shell command" and select "Install 'code' command in PATH"
|
|
167
|
+
|
|
168
|
+
#### For Linux (Ubuntu/Debian):
|
|
169
|
+
1. Open Terminal (Ctrl + Alt + T)
|
|
170
|
+
2. First, update the packages list:
|
|
171
|
+
```bash
|
|
172
|
+
sudo apt update
|
|
173
|
+
```
|
|
174
|
+
3. Install the dependencies needed to add Microsoft's repository:
|
|
175
|
+
```bash
|
|
176
|
+
sudo apt install software-properties-common apt-transport-https wget
|
|
177
|
+
```
|
|
178
|
+
4. Import Microsoft's GPG key:
|
|
179
|
+
```bash
|
|
180
|
+
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
|
|
181
|
+
```
|
|
182
|
+
5. Add the VS Code repository:
|
|
183
|
+
```bash
|
|
184
|
+
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
|
|
185
|
+
```
|
|
186
|
+
6. Install VS Code:
|
|
187
|
+
```bash
|
|
188
|
+
sudo apt install code
|
|
189
|
+
```
|
|
190
|
+
7. Once installed, you can launch VS Code by:
|
|
191
|
+
- Typing `code` in the terminal, or
|
|
192
|
+
- Finding it in your Applications menu
|
|
193
|
+
|
|
194
|
+
### Install Git
|
|
195
|
+
|
|
196
|
+
#### For Windows
|
|
197
|
+
1. Open PowerShell (press Windows key, type "PowerShell", and press Enter)
|
|
198
|
+
2. Visit the [Git website](https://git-scm.com/)
|
|
199
|
+
3. Download the latest version for Windows
|
|
200
|
+
4. Run the installer and use the recommended settings
|
|
201
|
+
5. Verify installation by opening PowerShell:
|
|
202
|
+
```powershell
|
|
203
|
+
git --version
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### For macOS
|
|
207
|
+
1. Install using Homebrew:
|
|
208
|
+
```bash
|
|
209
|
+
brew install git
|
|
210
|
+
```
|
|
211
|
+
2. Verify installation:
|
|
212
|
+
```bash
|
|
213
|
+
git --version
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### For Linux (Ubuntu/Debian)
|
|
217
|
+
1. Update package list:
|
|
218
|
+
```bash
|
|
219
|
+
sudo apt update
|
|
220
|
+
```
|
|
221
|
+
2. Install Git:
|
|
222
|
+
```bash
|
|
223
|
+
sudo apt install git
|
|
224
|
+
```
|
|
225
|
+
3. Verify installation:
|
|
226
|
+
```bash
|
|
227
|
+
git --version
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Configure Git (All Systems)
|
|
231
|
+
|
|
232
|
+
After installation, set up your identity:
|
|
233
|
+
```bash
|
|
234
|
+
git config --global user.name "Your Name"
|
|
235
|
+
git config --global user.email "your.email@example.com"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Verify Installation
|
|
239
|
+
|
|
240
|
+
Open your terminal (command prompt) and run the following commands to verify your setup:
|
|
241
|
+
```bash
|
|
242
|
+
node --version
|
|
243
|
+
pnpm --version
|
|
244
|
+
git --version
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
You should see version numbers displayed for all commands. You're now ready to start building your first Document Model!
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Utilities and Tips
|
|
2
|
+
|
|
3
|
+
## What will be produced for you on your next document model:
|
|
4
|
+
|
|
5
|
+
To help you along your way in document model generation we've set you up with a couple of tools that help you write your reducers. Alongside we'll offer you a series of tips that make your life a bit easier while defining document models.
|
|
6
|
+
|
|
7
|
+
### 1. Introducing Zod
|
|
8
|
+
|
|
9
|
+
The reducer's input, output, and possibly internal state are defined and enforced using the Zod library. Zod is a TypeScript-first schema declaration and validation library that allows developers to create schemas that describe the shape and constraints of data. By using Zod to strongly type a reducer, you leverage TypeScript's static type checking along with Zod's runtime validation to ensure that the data flowing through the reducer conforms to expected types and structures at both compile-time and runtime.
|
|
10
|
+
|
|
11
|
+
### 2. Introducing Immer
|
|
12
|
+
|
|
13
|
+
Immer is a library designed to simplify the process of working with immutable state in JavaScript applications, particularly in contexts like Redux reducers, where immutability is a key principle. Immer allows you to write code that appears to mutate state directly while actually producing new immutable states behind the scenes. This approach significantly simplifies the reducer logic, especially when dealing with complex state shapes or deep updates.
|
|
14
|
+
|
|
15
|
+
### 3. Generate Mock Data
|
|
16
|
+
|
|
17
|
+
The GenerateMock function is designed to simplify the creation of mock data for testing purposes. By taking a Zod schema as its input, it leverages the capabilities of Faker.js to automatically generate fake, yet plausible, values for each element defined within the schema. This allows developers to efficiently produce mock data corresponding to the structure and constraints specified in their Zod schemas, facilitating thorough testing and validation of application functionality without the need for manually crafting mock data sets for each schema.
|
|
18
|
+
|
|
19
|
+
### 4. Making use of utility Functions
|
|
20
|
+
|
|
21
|
+
Embedding detailed business logic directly within reducers can lead to bulky, hard-to-test code. To mitigate this, we recommend abstracting business logic into discrete utility functions. Reducers become straightforward maps between action types and state transformations, with the heavy lifting offloaded to utility functions. This offers several advantages to your document model.
|
|
22
|
+
|
|
23
|
+
1. Modularity: Utility functions encapsulate specific pieces of business logic, making your codebase more organized and modular.
|
|
24
|
+
|
|
25
|
+
2. Granular Testing: By isolating business logic in utility functions, you can write more focused and granular tests.
|
|
26
|
+
|
|
27
|
+
3. Reusability: Utility functions can be reused across different parts of your application, including multiple reducers.
|
|
28
|
+
|
|
29
|
+
4. Reducer Simplicity: Keeping reducers lean by focusing on state transition mechanisms rather than detailed logic makes them more predictable and easier to maintain.
|
|
30
|
+
|
|
31
|
+
### 5. Working with derived fields
|
|
32
|
+
|
|
33
|
+
Understand that inputs to reducers don't have to directly map to the schema's state fields. This is particularly important for derived fields, which are computed based on other data or transactions within the model.
|
|
34
|
+
|
|
35
|
+
- **Derived Fields**: Certain fields within a state object, such as for example 'an asset', do not hold values provided directly by user input but are calculated from other data, like a series of transactions.
|
|
36
|
+
|
|
37
|
+
- **Reducer Inputs and State Updates**: The input to a reducer function responsible for updating the state of such an asset doesn't need to include these derived fields explicitly. Instead, the reducer needs sufficient information to identify the asset and perform calculations to update these derived fields based on new transactions and the latest state.
|
|
38
|
+
|
|
39
|
+
- **Example of Updating Derived Fields**: When a new 'transaction' occurs, such as the sale of 'an asset', the relevant reducer function computes the necessary updates to the derived fields (e.g., "purchase price") of the associated asset. This computation is based on the details of the transaction and the existing data of the asset within the state.
|
|
40
|
+
|
|
41
|
+
Even in scenarios involving intricate relationships between different parts of the state (such as our example above: transactions affecting assets), the reducer treats the state as a single cohesive object. It performs all necessary computations and updates within the context of a single operation, returning a new, updated state object that reflects all changes.
|
|
42
|
+
|
|
43
|
+
### 6. `getDifferences` function
|
|
44
|
+
|
|
45
|
+
Even though we're receiving all of the fields in the form, at the moment we're submitting an edit for an item, we first check which fields are actually different with the previous state with the getDifferences function. This allows us to only publish an edit operation action that only contains the changed fields. We don't include all of the fields, which it might to by default, but only the 'differences' in the data. Making it much easier to keep track of operations going forward.
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
input : {
|
|
49
|
+
id : "0.4019292477011591"
|
|
50
|
+
text : "New task"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 8. How reducers & editors go hand in hand.
|
|
55
|
+
|
|
56
|
+
In developing a document model, it's crucial to distinguish between derived and stored states to maintain efficiency and simplicity. For instance, the state of our checked to-dos in our to-do list application doesn't need to be persistently saved in the document model, as their count can be dynamically derived from the current state.
|
|
57
|
+
|
|
58
|
+
Reducers help manage and update states based on actions, while editors provide functionalities such as counting checked to-dos through specific functions. Both derived states, like the count of checked to-dos or unit prices in a portfolio, and the tools to manage them (reducers and editors) reside within the same repository, so it's most effective to develop and update reducers and editors concurrently. Keeping this in mind while developing ensures that only essential data is stored, while derived data is efficiently calculated as needed.
|
|
59
|
+
|
|
60
|
+
### 9. No need for asynchronous operations
|
|
61
|
+
|
|
62
|
+
Asynchronous operations should be handled outside of the document model, ensuring that reducers remain pure functions of the state
|
|
63
|
+
|
|
64
|
+
Document models primary focus is on capturing the data specific to a business domain rather than facilitating user interface interactions. The document model's role is to represent and capture the business logic and rules inherent to the domain model.
|
|
65
|
+
For instance, in the context of a real asset portfolio, the document model is concerned with operations such as adding a new transaction to an asset and how such actions affect the total value of the asset—essentially, the core calculations and data manipulations that reflect business events and their impacts on the domain state.
|
|
66
|
+
|
|
67
|
+
This focus on the business logic side, rather than on asynchronous operations typically associated with user interface interactions (like fetching data or updating UI elements in response to user actions), means that the document model serves as a portable module. It's designed to be used across different contexts within the applications of powerhouse, prioritising the accurate representation and manipulation of business data (through Fusion or Switchboard) over UI concerns.
|
|
68
|
+
|
|
69
|
+
### Additional Tips
|
|
70
|
+
|
|
71
|
+
- Design state schemas with clear distinctions between directly inputted data and derived/computed fields.
|
|
72
|
+
|
|
73
|
+
- Implement reducers that can handle complex operations by computing necessary updates based on actions without requiring explicit inputs for derived fields.
|
|
74
|
+
|
|
75
|
+
- Maintain the purity of reducer functions by ensuring they do not mutate the existing state but instead return new instances of the state with the required updates.
|
|
76
|
+
|
|
77
|
+
- Validation and Leniency: While some validation is necessary, aim to be as lenient as possible without allowing unrecoverable states.
|
|
78
|
+
|
|
79
|
+
- The strict ts-eslint rules set by the core developers at Powerhouse will help you maintain code quality, consistency, and adherence to best practices across the project.
|