@powerhousedao/academy 5.1.0-dev.9 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +43 -1108
  2. package/blog/BeyondCommunication-ABlueprintForDevelopment.md +1 -2
  3. package/blog/TheChallengeOfChange.md +0 -1
  4. package/docs/academy/00-EthereumArgentinaHackathon.md +207 -0
  5. package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +27 -24
  6. package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +9 -118
  7. package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +28 -110
  8. package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +145 -191
  9. package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +218 -0
  10. package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/05-VetraStudio.md +6 -48
  11. package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
  12. package/docs/academy/01-GetStarted/_04-BuildToDoListEditor +1 -1
  13. package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +2 -2
  14. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +44 -75
  15. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +22 -28
  16. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +31 -28
  17. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +206 -211
  18. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +62 -176
  19. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +0 -21
  20. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +319 -309
  21. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +0 -4
  22. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +0 -4
  23. package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -1
  24. package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +35 -111
  25. package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +76 -255
  26. package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +160 -281
  27. package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +35 -188
  28. package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +7 -95
  29. package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
  30. package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +2 -6
  31. package/docs/academy/04-APIReferences/01-ReactHooks.md +501 -291
  32. package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +39 -7
  33. package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
  34. package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
  35. package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +24 -72
  36. package/docs/academy/08-Glossary.md +0 -7
  37. package/docusaurus.config.ts +3 -28
  38. package/package.json +1 -1
  39. package/sidebars.ts +12 -49
  40. package/src/css/custom.css +18 -26
  41. package/docs/academy/01-GetStarted/04-WriteDocumentModelTests.md +0 -378
  42. package/docs/academy/01-GetStarted/05-BuildToDoListEditor.md +0 -560
  43. package/docs/academy/03-ExampleUsecases/TodoList/00-GetTheStarterCode.md +0 -24
  44. package/docs/academy/03-ExampleUsecases/TodoList/01-GenerateTodoListDocumentModel.md +0 -211
  45. package/docs/academy/03-ExampleUsecases/TodoList/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
  46. package/docs/academy/03-ExampleUsecases/TodoList/03-AddTestsForTodoListActions.md +0 -462
  47. package/docs/academy/03-ExampleUsecases/TodoList/04-GenerateTodoListDocumentEditor.md +0 -45
  48. package/docs/academy/03-ExampleUsecases/TodoList/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
  49. package/docs/academy/03-ExampleUsecases/TodoList/06-GenerateTodoDriveExplorer.md +0 -61
  50. package/docs/academy/03-ExampleUsecases/TodoList/07-AddSharedComponentForShowingTodoListStats.md +0 -384
  51. package/docs/academy/03-ExampleUsecases/TodoList/_category_.json +0 -8
  52. package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/VetraPackageLibrary.md +0 -7
  53. package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/_category_.json +0 -9
  54. package/docs/academy/04-APIReferences/06-VetraRemoteDrive.md +0 -160
  55. package/docs/academy/04-APIReferences/renown-sdk/00-Overview.md +0 -316
  56. package/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md +0 -672
  57. package/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md +0 -957
  58. package/docs/academy/04-APIReferences/renown-sdk/_category_.json +0 -8
  59. package/docs/academy/10-TodoListTutorial/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
  60. package/docs/academy/10-TodoListTutorial/03-AddTestsForTodoListActions.md +0 -462
  61. package/docs/academy/10-TodoListTutorial/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
  62. package/docs/academy/10-TodoListTutorial/07-AddSharedComponentForShowingTodoListStats.md +0 -370
  63. package/static/img/Vetra-logo-dark.svg +0 -11
  64. package/static/img/vetra-logo-light.svg +0 -11
  65. /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/Modules.png +0 -0
  66. /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/VetraStudioDrive.png +0 -0
  67. /package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/{02-RevisionHistoryTimeline/360/237/232/247" → 02-RevisionHistoryTimeline} +0 -0
  68. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /01-WhatIsADocumentModel" → 01-WhatIsADocumentModel} +0 -0
  69. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-DAOandDocumentsModelsQ+A" → 02-DAOandDocumentsModelsQ+A} +0 -0
  70. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-domain-modeling" → 02-domain-modeling} +0 -0
  71. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /03-BenefitsOfDocumentModels" → 03-BenefitsOfDocumentModels} +0 -0
  72. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /04-UtilitiesAndTips" → 04-UtilitiesAndTips} +0 -0
  73. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /05-best-practices" → 05-best-practices} +0 -0
  74. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /_category_.json" → _category_.json} +0 -0
  75. /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /three-data-layers.png" → three-data-layers.png} +0 -0
@@ -6,7 +6,7 @@ In the previous section, we defined the state schema for our document model. Now
6
6
 
7
7
  In Powerhouse, document models adhere to event sourcing principles. This means that every change to a document's state is the result of a sequence of operations (or events). Instead of directly mutating the state, you define specific, named operations that describe the intended change.
8
8
 
9
- For example, in our `TodoList` document model, operations might include:
9
+ For example, in our `To-do List` document model, operations might include:
10
10
 
11
11
  - `ADD_TODO_ITEM`: To add a new task.
12
12
  - `UPDATE_TODO_ITEM`: To modify an existing task (e.g., change its text or mark it as completed).
@@ -16,38 +16,35 @@ Each operation acts as a command that, when applied, transitions the document fr
16
16
 
17
17
  ## Connecting operations to the schema
18
18
 
19
- In the "Define TodoList Document Model" chapter in the "Get Started" guide, we used GraphQL `input` types to define the structure of the data required for each operation. Let's revisit that:
19
+ In the "Define To-do List Document Model" chapter in the "Get Started" guide, we used GraphQL `input` types to define the structure of the data required for each operation. Let's revisit that:
20
20
 
21
21
  ```graphql
22
22
  # Defines a GraphQL input type for adding a new to-do item
23
23
  input AddTodoItemInput {
24
+ id: ID!
24
25
  text: String!
25
26
  }
26
27
 
27
28
  # Defines a GraphQL input type for updating a to-do item
28
29
  input UpdateTodoItemInput {
29
- id: OID!
30
+ id: ID!
30
31
  text: String
31
32
  checked: Boolean
32
33
  }
33
34
 
34
35
  # Defines a GraphQL input type for deleting a to-do item
35
36
  input DeleteTodoItemInput {
36
- id: OID!
37
+ id: ID!
37
38
  }
38
39
  ```
39
40
 
40
41
  These `input` types are not just abstract definitions; they are the **specifications for our document operations**.
41
42
 
42
- - **`AddTodoItemInput`** specifies that to execute an `ADD_TODO_ITEM` operation, we only need the `text` for the new item. The `id` is automatically generated by the reducer using Powerhouse's `generateId()` function.
43
+ - **`AddTodoItemInput`** specifies that to execute an `ADD_TODO_ITEM` operation, we need an `id` and `text` for the new item.
43
44
  - **`UpdateTodoItemInput`** specifies that for an `UPDATE_TODO_ITEM` operation, we need the `id` of the item to update, and optionally new `text` or a `checked` status.
44
45
  - **`DeleteTodoItemInput`** specifies that a `DELETE_TODO_ITEM` operation requires the `id` of the item to be removed.
45
46
 
46
- :::tip ID Generation
47
- Notice that `AddTodoItemInput` only requires `text` — not an `id`. This is because the ID is generated automatically in the reducer using `generateId()` from `document-model/core`. This ensures unique, consistent IDs and follows the pattern used in the [todo-demo repository](https://github.com/powerhouse-inc/todo-demo).
48
- :::
49
-
50
- The Powerhouse Connect application uses these GraphQL input types when you define operations within a module (e.g., the `todos` module with operations `ADD_TODO_ITEM`, `UPDATE_TODO_ITEM`, `DELETE_TODO_ITEM`).
47
+ The Powerhouse Connect application uses these GraphQL input types when you define operations within a module (e.g., the `to_do_list` module with operations `ADD_TODO_ITEM`, `UPDATE_TODO_ITEM`, `DELETE_TODO_ITEM`).
51
48
 
52
49
  ## Designing effective document operations
53
50
 
@@ -59,7 +56,7 @@ Operations should be granular enough to represent distinct user intentions or lo
59
56
 
60
57
  - **Too coarse:** An operation like `MODIFY_TODOLIST` that takes a whole new list of items would be too broad. It would be hard to track specific changes and could lead to complex reducer logic.
61
58
  - **Too fine:** While possible, having separate operations like `SET_TODO_ITEM_TEXT` and `SET_TODO_ITEM_CHECKED_STATUS` might be overly verbose if these are often updated together. `UPDATE_TODO_ITEM` with optional fields offers a good balance.
62
- - **Just right:** The `ADD_TODO_ITEM`, `UPDATE_TODO_ITEM`, and `DELETE_TODO_ITEM` operations for our `TodoList` are good examples. They represent clear, atomic changes.
59
+ - **Just right:** The `ADD_TODO_ITEM`, `UPDATE_TODO_ITEM`, and `DELETE_TODO_ITEM` operations for our `ToDoList` are good examples. They represent clear, atomic changes.
63
60
 
64
61
  ### 2. Naming conventions
65
62
 
@@ -93,25 +90,25 @@ While not specified in the operation definition itself, remember that the _imple
93
90
 
94
91
  Specifying your document operations is the bridge between defining your data structure (the state schema) and implementing the logic that changes that data (the reducers).
95
92
 
96
- 1. **You define the state schema** (e.g., `TodoListState`, `TodoItem`).
93
+ 1. **You define the state schema** (e.g., `ToDoListState`, `ToDoItem`).
97
94
  2. **You specify the operations** that can alter this state, along with their required input data (e.g., `ADD_TODO_ITEM` with `AddTodoItemInput`).
98
95
  3. **Next, you will implement reducers** for each specified operation. Each reducer will take the current state and an operation's input, and produce a new state.
99
96
 
100
97
  The generated code from `ph generate` (as seen in `03-ImplementOperationReducers.md`) will create a structure for your reducers based on the operations you specified in the Connect application (which, in turn, were based on your GraphQL input types).
101
98
 
102
- For example, the `TodoListTodosOperations` type generated by Powerhouse will expect methods corresponding to `addTodoItemOperation`, `updateTodoItemOperation`, and `deleteTodoItemOperation`.
99
+ For example, the `ToDoListToDoListOperations` type generated by Powerhouse will expect methods corresponding to `addTodoItemOperation`, `updateTodoItemOperation`, and `deleteTodoItemOperation`.
103
100
 
104
101
  ```typescript
105
- import type { TodoListTodosOperations } from "../../gen/todos/operations.js";
102
+ import { ToDoListToDoListOperations } from "../../gen/to-do-list/operations.js";
106
103
 
107
- export const todoListTodosOperations: TodoListTodosOperations = {
108
- addTodoItemOperation(state, action) {
104
+ export const reducer: ToDoListToDoListOperations = {
105
+ addTodoItemOperation(state, action, dispatch) {
109
106
  // Implementation uses action.input which matches AddTodoItemInput
110
107
  },
111
- updateTodoItemOperation(state, action) {
108
+ updateTodoItemOperation(state, action, dispatch) {
112
109
  // Implementation uses action.input which matches UpdateTodoItemInput
113
110
  },
114
- deleteTodoItemOperation(state, action) {
111
+ deleteTodoItemOperation(state, action, dispatch) {
115
112
  // Implementation uses action.input which matches DeleteTodoItemInput
116
113
  },
117
114
  };
@@ -119,16 +116,16 @@ export const todoListTodosOperations: TodoListTodosOperations = {
119
116
 
120
117
  ## Practical implementation: Defining operations in Connect
121
118
 
122
- Now that you understand the theory, let's walk through the practical steps of defining these operations for our `TodoList` document model within the Powerhouse Connect application.
119
+ Now that you understand the theory, let's walk through the practical steps of defining these operations for our `To-do List` document model within the Powerhouse Connect application.
123
120
 
124
121
  <details>
125
- <summary>Tutorial: Specifying TodoList operations</summary>
122
+ <summary>Tutorial: Specifying To-do List operations</summary>
126
123
 
127
- Assuming you have already defined the state schema for the `TodoList` as covered in the previous section, follow these steps to add the operations:
124
+ Assuming you have already defined the state schema for the `To-do List` as covered in the previous section, follow these steps to add the operations:
128
125
 
129
126
  1. **Create a Module for Operations:**
130
127
  Below the schema editor in Connect, find the input field labeled `Add module`. Modules help organize your operations.
131
- - Type `todos` into the field and press Enter.
128
+ - Type `to_do_list` into the field and press Enter.
132
129
 
133
130
  2. **Add the `ADD_TODO_ITEM` Operation:**
134
131
  A new field, `Add operation`, will appear under your new module.
@@ -138,14 +135,11 @@ Assuming you have already defined the state schema for the `TodoList` as covered
138
135
  ```graphql
139
136
  # Defines a GraphQL input type for adding a new to-do item
140
137
  input AddTodoItemInput {
138
+ id: ID!
141
139
  text: String!
142
140
  }
143
141
  ```
144
142
 
145
- :::info
146
- Notice we don't include `id` in the input — the reducer will generate it automatically using `generateId()` from `document-model/core`.
147
- :::
148
-
149
143
  3. **Add the `UPDATE_TODO_ITEM` Operation:**
150
144
  - In the `Add operation` field again, type `UPDATE_TODO_ITEM` and press Enter.
151
145
  - Paste the corresponding `input` definition into its editor:
@@ -153,7 +147,7 @@ Assuming you have already defined the state schema for the `TodoList` as covered
153
147
  ```graphql
154
148
  # Defines a GraphQL input type for updating a to-do item
155
149
  input UpdateTodoItemInput {
156
- id: OID!
150
+ id: ID!
157
151
  text: String
158
152
  checked: Boolean
159
153
  }
@@ -166,7 +160,7 @@ Assuming you have already defined the state schema for the `TodoList` as covered
166
160
  ```graphql
167
161
  # Defines a GraphQL input type for deleting a to-do item
168
162
  input DeleteTodoItemInput {
169
- id: OID!
163
+ id: ID!
170
164
  }
171
165
  ```
172
166
 
@@ -1,8 +1,8 @@
1
1
  # Use the document model generator
2
2
 
3
- In the Powerhouse Document Model development workflow, after specifying your document model's state schema and operations within the Connect application and exporting it as a `.phd` file, the next crucial step is to translate this specification into a tangible codebase. This is where the Powerhouse Document Model Generator comes into play.
3
+ In the Powerhouse Document Model development workflow, after specifying your document model's state schema and operations within the Connect application and exporting it as a `.phdm.zip` file, the next crucial step is to translate this specification into a tangible codebase. This is where the Powerhouse Document Model Generator comes into play.
4
4
 
5
- The Document Model Generator is a powerful command-line tool (`ph generate`) that processes your exported `.phd` file and scaffolds the necessary directory structure and foundational code for your document model. It automates the creation of boilerplate code, ensuring consistency, type safety, and adherence to Powerhouse conventions, thereby significantly accelerating the development process.
5
+ The Document Model Generator is a powerful command-line tool (`ph generate`) that processes your exported `.phdm.zip` file and scaffolds the necessary directory structure and foundational code for your document model. It automates the creation of boilerplate code, ensuring consistency, type safety, and adherence to Powerhouse conventions, thereby significantly accelerating the development process.
6
6
 
7
7
  This document provides a deep dive into using the Document Model Generator, understanding its output, and appreciating its role in the broader context of document model creation.
8
8
 
@@ -11,20 +11,20 @@ This document provides a deep dive into using the Document Model Generator, unde
11
11
  Before you can use the Document Model Generator, ensure you have the following:
12
12
 
13
13
  1. **Powerhouse CLI (`ph-cmd`) Installed:** The generator is part of the Powerhouse CLI. If you haven't installed it, refer to the [Builder Tools documentation](/academy/MasteryTrack/BuilderEnvironment/BuilderTools#installing-the-powerhouse-cli).
14
- 2. **Document Model Specification File (`.phd`):** You must have already defined your document model in Connect and exported it. This file (e.g., `TodoList.phd`) contains the GraphQL schema for your document's state and operations. This process is typically covered in a preceding step, such as "Define TodoList Document Model."
14
+ 2. **Document Model Specification File (`.phdm.zip`):** You must have already defined your document model in Connect and exported it. This file (e.g., `YourModelName.phdm.zip`) contains the GraphQL schema for your document's state and operations. This process is typically covered in a preceding step, such as "Define [YourModelName] Document Model."
15
15
 
16
16
  ## The command
17
17
 
18
18
  The core command to invoke the Document Model Generator is:
19
19
 
20
20
  ```bash
21
- ph generate <YourModelName.phd>
21
+ ph generate <YourModelName.phdm.zip>
22
22
  ```
23
23
 
24
- Replace `<YourModelName.phd>` with the actual filename of your exported document model specification. For instance, if your exported file is named `TodoList.phd`, the command would be:
24
+ Replace `<YourModelName.phdm.zip>` with the actual filename of your exported document model specification. For instance, if your exported file is named `Invoice.phdm.zip`, the command would be:
25
25
 
26
26
  ```bash
27
- ph generate TodoList.phd
27
+ ph generate Invoice.phdm.zip
28
28
  ```
29
29
 
30
30
  When executed, this command reads and parses the specification file and generates a set of files and directories within your Powerhouse project.
@@ -34,12 +34,12 @@ When executed, this command reads and parses the specification file and generate
34
34
  Running `ph generate` triggers a series of actions that lay the groundwork for your document model's implementation. Let's explore the typical output structure and the significance of each generated component.
35
35
 
36
36
  The generator creates a new directory specific to your document model, usually located at:
37
- `document-models/<your-model-name>/`
37
+ `document-models/<YourModelName>/`
38
38
 
39
- For example, using `TodoList.phd` would result in a directory structure under `document-models/todo-list/`. Inside this directory, you will find:
39
+ For example, using `Invoice.phdm.zip` would result in a directory structure under `document-models/invoice/`. Inside this directory, you will find:
40
40
 
41
- 1. **`todo-list.json` (or similar JSON representation):**
42
- - **Purpose:** This file is a JSON representation of your document model specification, derived directly from the `.phd` file. It contains the parsed schema, operation definitions, document type, and other metadata.
41
+ 1. **`spec.json` (or similar JSON representation):**
42
+ - **Purpose:** This file is a JSON representation of your document model specification, derived directly from the `.phdm.zip` file. It contains the parsed schema, operation definitions, document type, and other metadata.
43
43
  - **Significance:** It serves as the canonical, machine-readable definition of your model within the project, which other tools or processes might reference.
44
44
 
45
45
  2. **`schema.graphql`:**
@@ -50,12 +50,12 @@ For example, using `TodoList.phd` would result in a directory structure under `d
50
50
  This directory is pivotal as it houses all the code automatically generated by the tool. **You should generally avoid manually editing files within the `gen/` directory**, as they will be overwritten if you regenerate the model.
51
51
  Key files within `gen/` include:
52
52
  - **`types.ts`:**
53
- - **Purpose:** Contains TypeScript interfaces and type definitions derived from your GraphQL schema. This includes types for your document's state (e.g., `TodoListState`), any complex types used within the state (e.g., `TodoItem`), and types for the inputs of each defined operation (e.g., `AddTodoItemInput`).
53
+ - **Purpose:** Contains TypeScript interfaces and type definitions derived from your GraphQL schema. This includes types for your document's state (e.g., `InvoiceState`), any complex types used within the state (e.g., `LineItem`), and types for the inputs of each defined operation (e.g., `AddLineItemInput`).
54
54
  - **Significance:** This is the cornerstone of type safety in your document model implementation. By using these generated types, you ensure that your reducer logic and any client-side interactions adhere to the defined data structures, catching errors at compile-time rather than runtime.
55
55
 
56
- - **`creators.ts` (or `actions.ts`):**
56
+ - **`operations.ts` (or `creators.ts`, `actions.ts`):**
57
57
  - **Purpose:** This file exports "action creator" functions for each operation defined in your schema. These functions take the input parameters for an operation and return a correctly structured action object that can be processed by the reducer system.
58
- - **Significance:** Action creators simplify the process of creating and dispatching operations, reduce the likelihood of errors in action formatting, and improve code readability. For example, instead of manually constructing an action object like `{ type: "ADD_TODO_ITEM", input: { ... } }`, you'd use a function like `addTodoItem({ text: 'Buy groceries' })`.
58
+ - **Significance:** Action creators simplify the process of creating and dispatching operations, reduce the likelihood of errors in action formatting, and improve code readability. For example, instead of manually constructing an action object like `{ type: "ADD_LINE_ITEM", input: { ... } }`, you'd use a function like `creators.addLineItem({ ... })`.
59
59
 
60
60
  - **`utils.ts`:**
61
61
  - **Purpose:** Often includes utility functions related to your document model. A common utility is a function to create an empty or initial instance of your document (e.g., `utils.createDocument()`). This is based on the default values and structure defined in your state schema.
@@ -68,11 +68,14 @@ For example, using `TodoList.phd` would result in a directory structure under `d
68
68
  4. **The `src/` Directory (Source Code for Your Implementation):**
69
69
  This directory is where you, the developer, will write the custom logic for your document model. Unlike the `gen/` directory, files here are meant to be manually edited.
70
70
  - **`reducers/`:**
71
- - **`todos.ts`:** This is the most important file you'll work with after generation. It's where you implement the **reducer functions** for each operation. The generator usually creates a skeleton file with function stubs for each operation, which you then fill in with the actual state transition logic.
71
+ - **`your-model-name.ts` (e.g., `invoice.ts`):** This is the most important file you'll work with after generation. It's where you implement the **reducer functions** for each operation. The generator usually creates a skeleton file with function stubs for each operation, which you then fill in with the actual state transition logic.
72
72
  - **Significance:** This is the heart of your document model's behavior, defining how the state changes in response to each operation. The next step in the Mastery Track will typically focus on implementing these reducers.
73
- - **`tests/`:**
74
- - **`todos.test.ts`:** A placeholder or basic test file is often generated here, encouraging you to write unit tests for your reducer logic.
73
+ - **`reducers/tests/`:**
74
+ - **`your-model-name.test.ts` (e.g., `invoice.test.ts`):** A placeholder or basic test file is often generated here, encouraging you to write unit tests for your reducer logic.
75
75
  - **Significance:** Emphasizes the importance of testing your document model's core logic to ensure correctness and reliability.
76
+ - **`utils/` (optional):**
77
+ - **Purpose:** You can create this directory for any custom utility functions specific to your document model's implementation that don't fit directly into the reducers.
78
+ - **Significance:** Helps in organizing shared logic or complex computations that might be used across multiple reducers or other parts of your model's ecosystem.
76
79
 
77
80
  ## Benefits of using the document model generator
78
81
 
@@ -85,39 +88,39 @@ Leveraging the `ph generate` command offers numerous advantages:
85
88
  5. **Alignment with Powerhouse Ecosystem:** The generated code is designed to integrate seamlessly with other parts of the Powerhouse ecosystem, such as the reducer execution engine and UI components.
86
89
  6. **Single Source of Truth:** Ensures that your codebase (especially types and action creators) stays synchronized with the document model specification defined in Connect. If the specification changes, regenerating the model will update these components accordingly.
87
90
 
88
- ## Practical implementation: Generating the `TodoList` model
91
+ ## Practical implementation: Generating the `To-do List` model
89
92
 
90
- Now that you understand what the Document Model Generator does, let's walk through the practical steps of using it with our `TodoList` example.
93
+ Now that you understand what the Document Model Generator does, let's walk through the practical steps of using it with our `To-do List` example.
91
94
 
92
95
  <details>
93
- <summary>Tutorial: Generating the TodoList document model</summary>
96
+ <summary>Tutorial: Generating the `To-do List` document model</summary>
94
97
 
95
- This tutorial assumes you have completed the previous steps in this Mastery Track, where you defined the state schema and operations for the `TodoList` model in Connect and exported it.
98
+ This tutorial assumes you have completed the previous steps in this Mastery Track, where you defined the state schema and operations for the `To-do List` model in Connect and exported it.
96
99
 
97
100
  ### Prerequisites
98
101
 
99
- - **`TodoList.phd` file**: You must have the document model specification file exported from Connect. If you do not have this file, please revisit the previous sections on specifying the state schema and operations.
102
+ - **`ToDoList.phdm.zip` file**: You must have the document model specification file exported from Connect. If you do not have this file, please revisit the previous sections on specifying the state schema and operations.
100
103
 
101
104
  ### Steps
102
105
 
103
106
  1. **Place the Specification File in Your Project**:
104
107
  - Navigate to the root directory of your Powerhouse project.
105
- - Move or copy your `TodoList.phd` file into this directory.
108
+ - Move or copy your `ToDoList.phdm.zip` file into this directory.
106
109
 
107
110
  2. **Run the Generator Command**:
108
111
  - Open your terminal in the root directory of your Powerhouse project.
109
112
  - Execute the `ph generate` command, pointing to your specification file:
110
113
 
111
114
  ```bash
112
- ph generate TodoList.phd
115
+ ph generate ToDoList.phdm.zip
113
116
  ```
114
117
 
115
118
  3. **Explore the Generated Files**:
116
- - After the command completes successfully, you will find a new directory: `document-models/todo-list/`.
119
+ - After the command completes successfully, you will find a new directory: `document-models/to-do-list/`.
117
120
  - Take a moment to explore its contents, which will match the structure described earlier in this document:
118
- - `todo-list.json` and `schema.graphql`: The definition of your model.
119
- - `gen/`: Type-safe, generated code including `types.ts`, `creators.ts`, etc.
120
- - `src/`: The skeleton for your implementation, most importantly `src/reducers/todos.ts`, which will contain empty functions for `addTodoItemOperation`, `updateTodoItemOperation`, and `deleteTodoItemOperation`, ready for you to implement.
121
+ - `spec.json` and `schema.graphql`: The definition of your model.
122
+ - `gen/`: Type-safe, generated code including `types.ts`, `operations.ts`, etc.
123
+ - `src/`: The skeleton for your implementation, most importantly `src/reducers/to-do-list.ts`, which will contain empty functions for `addTodoItemOperation`, `updateTodoItemOperation`, and `deleteTodoItemOperation`, ready for you to implement.
121
124
 
122
125
  With these files generated, you have successfully scaffolded your document model. The project is now set up for you to implement the core business logic.
123
126
 
@@ -125,7 +128,7 @@ With these files generated, you have successfully scaffolded your document model
125
128
 
126
129
  ## Next steps
127
130
 
128
- Once the Document Model Generator has successfully scaffolded your project, the immediate next step is to implement the logic for each operation within the generated reducer files (e.g., `document-models/todo-list/src/reducers/todos.ts`). This involves taking the current state and the action input, and returning the new state of the document.
131
+ Once the Document Model Generator has successfully scaffolded your project, the immediate next step is to implement the logic for each operation within the generated reducer files (e.g., `document-models/YourModelName/src/reducers/your-model-name.ts`). This involves taking the current state and the action input, and returning the new state of the document.
129
132
 
130
133
  Subsequently, you will write unit tests for these reducers to ensure they behave as expected under various conditions. This iterative process of defining, generating, implementing, and testing forms the core loop of document model development in Powerhouse.
131
134