@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
@@ -36,503 +36,713 @@ It's important to note that a function should only be named and treated as a hoo
36
36
 
37
37
  This library provides hooks intended to be used by editors (including drive editors) which will be rendered inside of Powerhouse host-applications such as Connect, Switchboard, Fusion or a Vetra Studio Drive.
38
38
 
39
- - Learn more about the [Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingDocumentEditors)
40
- - Learn more about the [Drive Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
39
+ Learn more about the [Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingDocumentEditors)
40
+ Learn more about the [Drive Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
41
41
 
42
42
  ## Key concepts
43
43
 
44
44
  ### Reactor
45
45
 
46
46
  All of the data used by these hooks is ultimately derived from the `Reactor`, which manages the asynchronous eventually consistent state of drives and documents. Learn more about the [Reactor](/academy/Architecture/WorkingWithTheReactor)
47
- # Reactor Browser Hooks API Documentation
48
47
 
49
- This document contains all documentation comments for the hooks exported from `packages/reactor-browser/src/hooks/index.ts`.
50
-
51
- ## Table of Contents
52
-
53
- - [Allowed Document Model Modules](#allowed-document-model-modules)
54
- - [Child Nodes](#child-nodes)
55
- - [Config: Editor](#config-editor)
56
- - [Config: Set Config by Object](#config-set-config-by-object)
57
- - [Config: Use Value by Key](#config-use-value-by-key)
58
- - [Document by ID](#document-by-id)
59
- - [Document Cache](#document-cache)
60
- - [Document of Type](#document-of-type)
61
- - [Document Types](#document-types)
62
- - [Drives](#drives)
63
- - [Items in Selected Drive](#items-in-selected-drive)
64
- - [Items in Selected Folder](#items-in-selected-folder)
65
- - [Modals](#modals)
66
- - [Node by ID](#node-by-id)
67
- - [Node Path](#node-path)
68
- - [Revision History](#revision-history)
69
- - [Selected Document](#selected-document)
70
- - [Selected Drive](#selected-drive)
71
- - [Selected Folder](#selected-folder)
72
- - [Selected Node](#selected-node)
73
- - [Selected Timeline Item](#selected-timeline-item)
74
- - [Supported Document Types](#supported-document-types)
75
- - [Timeline Revision](#timeline-revision)
76
- - [Use Get Switchboard Link](#use-get-switchboard-link)
77
- - [Vetra Packages](#vetra-packages)
78
-
79
- ---
80
-
81
- ## Allowed Document Model Modules
82
-
83
- ### `useAllowedDocumentModelModules`
84
-
85
- No documentation available.
86
-
87
- ---
88
-
89
- ## Child Nodes
90
-
91
- ### `useNodesInSelectedDriveOrFolder`
92
-
93
- Returns the child nodes for the selected drive or folder.
94
-
95
- ---
96
-
97
- ## Document by ID
98
-
99
- ### `useDocumentById`
100
-
101
- Returns a document by id.
102
-
103
- ### `useDocumentsByIds`
104
-
105
- Returns documents by ids.
106
-
107
- ---
108
-
109
- ## Document Cache
110
-
111
- ### `useDocumentCache`
112
-
113
- Returns all documents in the reactor.
114
-
115
- ### `setDocumentCache`
116
-
117
- Sets all of the documents in the reactor.
48
+ <details>
49
+ <summary>useReactor</summary>
118
50
 
119
- ### `addDocumentCacheEventHandler`
51
+ ```ts
52
+ function useReactor(): Reactor | undefined;
53
+ ```
120
54
 
121
- Adds an event handler for all of the documents in the reactor.
55
+ Returns the reactor instance.
122
56
 
123
- ### `useGetDocument`
57
+ Usage
124
58
 
125
- Retrieves a document from the reactor and subscribes to changes using React Suspense.
126
- This hook will suspend rendering while the document is loading.
59
+ ```jsx
60
+ import { useReactor } from "@powerhousedao/state";
127
61
 
128
- **Parameters:**
129
- - `id` - The document ID to retrieve, or null/undefined to skip retrieval
62
+ function MyEditorComponent() {
63
+ const reactor = useReactor();
64
+ }
65
+ ```
130
66
 
131
- **Returns:** The document if found, or undefined if id is null/undefined
67
+ </details>
132
68
 
133
- ### `useGetDocuments`
69
+ ### Drives
134
70
 
135
- Retrieves multiple documents from the reactor using React Suspense.
136
- This hook will suspend rendering while any of the documents are loading.
71
+ <details>
72
+ <summary>useDrives</summary>
137
73
 
138
- **Parameters:**
139
- - `ids` - Array of document IDs to retrieve, or null/undefined to skip retrieval
74
+ ```ts
75
+ function useDrives(): DocumentDriveDocument[] | undefined;
76
+ ```
140
77
 
141
- **Returns:** An array of documents if found, or undefined if ids is null/undefined
78
+ Returns the drives for a reactor.
142
79
 
143
- ### `useGetDocumentAsync`
80
+ Usage
144
81
 
145
- Retrieves a document from the reactor without suspending rendering.
146
- Returns the current state of the document loading operation.
82
+ ```jsx
83
+ import { useDrives } from "@powerhousedao/state";
147
84
 
148
- **Parameters:**
149
- - `id` - The document ID to retrieve, or null/undefined to skip retrieval
85
+ function MyEditorComponent() {
86
+ const drives = useDrives();
87
+ }
88
+ ```
150
89
 
151
- **Returns:** An object containing:
152
- - `status`: "initial" | "pending" | "success" | "error"
153
- - `data`: The document if successfully loaded
154
- - `isPending`: Boolean indicating if the document is currently loading
155
- - `error`: Any error that occurred during loading
156
- - `reload`: Function to force reload the document from cache
90
+ </details>
157
91
 
158
- ---
92
+ <details>
93
+ <summary>useDriveById</summary>
159
94
 
160
- ## Document of Type
95
+ ```ts
96
+ function useDriveById(
97
+ id: string | null | undefined,
98
+ ): DocumentDriveDocument | undefined;
99
+ ```
161
100
 
162
- ### `useDocumentOfType`
101
+ Returns a drive by id.
163
102
 
164
- Returns a document of a specific type, throws an error if the found document has a different type.
103
+ Usage
165
104
 
166
- ---
105
+ ```jsx
106
+ import { useDriveById } from "@powerhousedao/state";
167
107
 
168
- ## Document Types
108
+ function MyEditorComponent() {
109
+ const driveById = useDriveById("some-id");
110
+ }
111
+ ```
169
112
 
170
- ### `useDocumentTypes`
113
+ </details>
171
114
 
172
- Returns the document types a drive editor supports.
115
+ <details>
116
+ <summary>useSelectedDrive</summary>
173
117
 
174
- If present, uses the `allowedDocumentTypes` config value.
175
- Otherwise, uses the supported document types from the reactor.
118
+ ```ts
119
+ function useSelectedDrive(): DocumentDriveDocument | undefined;
120
+ ```
176
121
 
177
- ---
122
+ Returns the selected drive. You can set the selected drive with `setSelectedDrive`.
178
123
 
179
- ## Drives
124
+ Usage
180
125
 
181
- ### `useDrives`
126
+ ```jsx
127
+ import { useSelectedDrive } from "@powerhousedao/state";
182
128
 
183
- Returns all of the drives in the reactor.
129
+ function MyEditorComponent() {
130
+ const selectedDrive = useSelectedDrive();
131
+ }
132
+ ```
184
133
 
185
- ### `setDrives`
134
+ </details>
186
135
 
187
- Sets the drives in the reactor.
136
+ <details>
137
+ <summary>Drive Properties Convenience Hooks</summary>
138
+
139
+ We provide hooks for accessing various properties on the drive object for your convenience. These use the above hooks to get a drive and then return properties in the object.
140
+
141
+ ```ts
142
+ /** Returns the remote URL for a drive. */
143
+ function useDriveRemoteUrl(
144
+ driveId: string | null | undefined,
145
+ ): string | undefined;
146
+
147
+ /** Returns the pull responder trigger for a drive. */
148
+ function useDrivePullResponderTrigger(
149
+ driveId: string | null | undefined,
150
+ ): Trigger | undefined;
151
+
152
+ /** Returns the pull responder URL for a drive. */
153
+ function useDrivePullResponderUrl(
154
+ driveId: string | null | undefined,
155
+ ): string | undefined;
156
+
157
+ /** Returns whether a drive is remote. */
158
+ function useDriveIsRemote(driveId: string | null | undefined): boolean;
159
+
160
+ /** Returns the sharing type for a drive. */
161
+ function useDriveSharingType(
162
+ driveId: string | null | undefined,
163
+ ): SharingType | undefined;
164
+
165
+ /** Returns whether a drive is available offline. */
166
+ function useDriveAvailableOffline(driveId: string | null | undefined): boolean;
167
+ ```
168
+
169
+ Usage
170
+
171
+ ```jsx
172
+ import {
173
+ useDriveRemoteUrl,
174
+ useDrivePullResponderTrigger,
175
+ useDrivePullResponderUrl,
176
+ useDriveIsRemote,
177
+ useDriveSharingType,
178
+ useDriveAvailableOffline,
179
+ } from "@powerhousedao/state";
180
+
181
+ function MyEditorComponent() {
182
+ const myDriveId = "some-drive-id";
183
+ const driveRemoteUrl = useDriveRemoteUrl(myDriveId);
184
+ const drivePullResponderTrigger = useDrivePullResponderTrigger(myDriveId);
185
+ const drivePullResponderUrl = useDrivePullResponderUrl(myDriveId);
186
+ const driveIsRemote = useDriveIsRemote(myDriveId);
187
+ const driveSharingType = useDriveSharingType(myDriveId);
188
+ const driveAvailableOffline = useDriveAvailableOffline(myDriveId);
189
+
190
+ console.log({
191
+ driveRemoteUrl,
192
+ drivePullResponderTrigger,
193
+ drivePullResponderUrl,
194
+ driveIsRemote,
195
+ driveSharingType,
196
+ driveAvailableOffline,
197
+ });
198
+ }
199
+ ```
188
200
 
189
- ### `addDrivesEventHandler`
201
+ </details>
190
202
 
191
- Adds an event handler for the drives.
203
+ ### Documents
192
204
 
193
- ---
205
+ <details>
206
+ <summary>useAllDocuments/useSelectedDriveDocuments</summary>
194
207
 
195
- ## Items in Selected Drive
208
+ ```ts
209
+ function useAllDocuments(): PHDocument[] | undefined;
210
+ ```
196
211
 
197
- ### `useNodesInSelectedDrive`
212
+ Returns all of the documents in the reactor.
198
213
 
199
- Returns the nodes in the selected drive.
214
+ ```ts
215
+ function useSelectedDriveDocuments(): PHDocument[] | undefined;
216
+ ```
200
217
 
201
- ### `useFileNodesInSelectedDrive`
218
+ Returns the documents in the reactor for the selected drive.
202
219
 
203
- Returns the file nodes in the selected drive.
220
+ Usage
204
221
 
205
- ### `useFolderNodesInSelectedDrive`
222
+ ```jsx
223
+ import {
224
+ useAllDocuments,
225
+ useSelectedDriveDocuments,
226
+ } from "@powerhousedao/state";
206
227
 
207
- Returns the folder nodes in the selected drive.
228
+ function MyEditorComponent() {
229
+ const allDocuments = useAllDocuments();
230
+ const selectedDriveDocuments = useSelectedDriveDocuments();
231
+ }
232
+ ```
208
233
 
209
- ### `useDocumentsInSelectedDrive`
234
+ </details>
210
235
 
211
- Returns the documents in the selected drive.
236
+ <details>
237
+ <summary>useSelectedDocument</summary>
212
238
 
213
- ### `useDocumentTypesInSelectedDrive`
239
+ ```ts
240
+ function useSelectedDocument(): PHDocument | undefined;
241
+ ```
214
242
 
215
- Returns the document types supported by the selected drive, as defined by the document model documents present in the drive.
243
+ Returns the selected document. You can set the selected document with `setSelectedNode`.
216
244
 
217
- ---
245
+ Usage
218
246
 
219
- ## Items in Selected Folder
247
+ ```jsx
248
+ import { useSelectedDocument } from "@powerhousedao/state";
220
249
 
221
- ### `useNodesInSelectedFolder`
250
+ function MyEditorComponent() {
251
+ const selectedDocument = useSelectedDocument();
252
+ }
253
+ ```
222
254
 
223
- Returns the nodes in the selected folder.
255
+ </details>
224
256
 
225
- ### `useFileNodesInSelectedFolder`
257
+ <details>
258
+ <summary>useDocumentById</summary>
226
259
 
227
- Returns the file nodes in the selected folder.
260
+ ```ts
261
+ function useDocumentById(id: string | null | undefined): PHDocument | undefined;
262
+ ```
228
263
 
229
- ### `useFolderNodesInSelectedFolder`
264
+ Returns a document by id.
230
265
 
231
- Returns the folder nodes in the selected folder.
266
+ Usage
232
267
 
233
- ### `useDocumentsInSelectedFolder`
268
+ ```jsx
269
+ import { useDocumentById } from "@powerhousedao/state";
234
270
 
235
- Returns the documents in the selected folder.
271
+ function MyEditorComponent() {
272
+ const myDocumentId = "some-document-id";
273
+ const documentById = useDocumentById(myDocumentId);
274
+ }
275
+ ```
236
276
 
237
- ---
277
+ </details>
238
278
 
239
- ## Modals
279
+ ### Nodes
240
280
 
241
- ### `usePHModal`
281
+ "Nodes" refers to the items found in a given drive's `state.global.nodes` array. Nodes can represent both files (documents) and folders.
242
282
 
243
- Returns the current modal.
283
+ A document in a drive will have a node in the drive's node list which has the same id as the document.
244
284
 
245
- ### `setPHModal`
285
+ Nodes have an optional `parentFolder` field, which is the id of a folder node in the drive when it is defined. If it is undefined, the node is a direct child of the drive.
246
286
 
247
- Sets the current modal.
287
+ A given folder node's children are the nodes in the drive's node list which have their parent folder set to the folder node's id.
248
288
 
249
- ### `addModalEventHandler`
289
+ ```ts
290
+ type FileNode = {
291
+ documentType: string;
292
+ id: string;
293
+ kind: string;
294
+ name: string;
295
+ parentFolder: string | null | undefined;
296
+ };
250
297
 
251
- Adds an event handler for the modal.
298
+ type FolderNode = {
299
+ id: string;
300
+ kind: string;
301
+ name: string;
302
+ parentFolder: string | null | undefined;
303
+ };
252
304
 
253
- ### `showPHModal`
305
+ type Node = FileNode | FolderNode;
306
+ ```
254
307
 
255
- Shows a modal.
308
+ <details>
309
+ <summary>useNodes</summary>
256
310
 
257
- ### `closePHModal`
311
+ Ideally you should not need to handle the list of nodes directly, since we already provide documents and folders. But these hooks are provided just in case.
258
312
 
259
- Closes the current modal.
313
+ ```ts
314
+ function useNodes(): Node[] | undefined;
315
+ ```
260
316
 
261
- ### `showCreateDocumentModal`
317
+ Returns the nodes for a drive.
262
318
 
263
- Shows the create document modal.
319
+ Usage
264
320
 
265
- ### `showDeleteNodeModal`
321
+ ```jsx
322
+ import { useNodes } from "@powerhousedao/state";
266
323
 
267
- Shows the delete node modal.
324
+ function MyEditorComponent() {
325
+ const nodes = useNodes();
326
+ }
327
+ ```
268
328
 
269
- ---
329
+ </details>
270
330
 
271
- ## Node by ID
331
+ <details>
332
+ <summary>useNodeById</summary>
272
333
 
273
- ### `useNodeById`
334
+ ```ts
335
+ function useNodeById(id: string | null | undefined): Node | undefined;
336
+ ```
274
337
 
275
338
  Returns a node in the selected drive by id.
276
339
 
277
- ---
278
-
279
- ## Node Path
340
+ Usage
280
341
 
281
- ### `useNodePathById`
342
+ ```jsx
343
+ import { useNodeById } from "@powerhousedao/state";
282
344
 
283
- Returns the path to a node in the selected drive.
345
+ function MyEditorComponent() {
346
+ const myFolderId = "some-folder-id";
347
+ const myDocumentId = "some-document-id";
348
+ const myFolderNode = useNodeById(myFolderId);
349
+ const myFileNode = useNodeById(myDocumentId);
350
+ }
351
+ ```
284
352
 
285
- ### `useSelectedNodePath`
286
-
287
- Returns the path to the currently selected node in the selected drive.
353
+ </details>
288
354
 
289
- ---
355
+ <details>
356
+ <summary>useSelectedFolder</summary>
290
357
 
291
- ## Revision History
358
+ ```ts
359
+ function useSelectedFolder(): FolderNode | undefined;
360
+ ```
292
361
 
293
- ### `useRevisionHistoryVisible`
362
+ Returns the selected folder. You can set the selected folder with `setSelectedNode`
294
363
 
295
- Returns whether revision history is visible.
364
+ Usage
296
365
 
297
- ### `setRevisionHistoryVisible`
366
+ ```jsx
367
+ import { useSelectedFolder } from "@powerhousedao/state";
298
368
 
299
- Sets revision history visibility.
369
+ function MyEditorComponent() {
370
+ const selectedFolder = useSelectedFolder();
371
+ }
372
+ ```
300
373
 
301
- ### `addRevisionHistoryVisibleEventHandler`
374
+ </details>
302
375
 
303
- Adds event handler for revision history visibility.
376
+ <details>
377
+ <summary>useSelectedNodePath</summary>
304
378
 
305
- ### `showRevisionHistory`
379
+ ```ts
380
+ function useSelectedNodePath(): Node[];
381
+ ```
306
382
 
307
- Shows the revision history.
383
+ Returns the path to the selected node. Useful for navigational components like breadcrumbs.
308
384
 
309
- ### `hideRevisionHistory`
385
+ Usage
310
386
 
311
- Hides the revision history.
387
+ ```jsx
388
+ import { useSelectedNodePath } from "@powerhousedao/state";
312
389
 
313
- ---
390
+ function MyEditorComponent() {
391
+ const nodes = useSelectedNodePath();
314
392
 
315
- ## Selected Document
393
+ return <Breadcrumbs nodes={nodes} />;
394
+ }
395
+ ```
316
396
 
317
- ### `useSelectedDocumentId`
397
+ </details>
318
398
 
319
- Returns the selected document id.
399
+ <details>
400
+ <summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
320
401
 
321
- ### `useSelectedDocument`
402
+ ```ts
403
+ function useChildNodes(): Node[];
404
+ ```
322
405
 
323
- Returns the selected document.
406
+ Returns the child nodes for the selected drive or folder.
324
407
 
325
- ### `useSelectedDocumentOfType`
408
+ ```ts
409
+ function useFolderChildNodes(): FolderNode[];
410
+ ```
326
411
 
327
- Returns the selected document of a specific type, throws an error if the found document has a different type.
412
+ Returns the folder child nodes for the selected drive or folder.
328
413
 
329
- ---
414
+ ```ts
415
+ function useFileChildNodes(): FileNode[];
416
+ ```
330
417
 
331
- ## Selected Drive
418
+ Returns the file (document) child nodes for the selected drive or folder.
332
419
 
333
- ### `useSelectedDriveId`
420
+ Usage
334
421
 
335
- Returns the selected drive id.
422
+ ```jsx
423
+ import {
424
+ useChildNodes,
425
+ useFolderChildNodes,
426
+ useFileChildNodes,
427
+ } from "@powerhousedao/state";
336
428
 
337
- ### `setSelectedDriveId`
429
+ function MyEditorComponent() {
430
+ const nodes = useChildNodes();
431
+ const fileNodes = useFileChildNodes();
432
+ const folderNodes = useFolderChildNodes();
338
433
 
339
- Sets the selected drive id.
434
+ return (
435
+ <div>
436
+ <FilesAndFolders nodes={nodes} />
437
+ <Files fileNodes={fileNodes} />
438
+ <Folders folderNodes={folderNodes} />
439
+ </div>
440
+ );
441
+ }
442
+ ```
340
443
 
341
- ### `addSelectedDriveIdEventHandler`
444
+ </details>
342
445
 
343
- Adds an event handler for the selected drive id.
446
+ <details>
447
+ <summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
344
448
 
345
- ### `useSelectedDrive`
449
+ ```ts
450
+ function useChildNodesForId(id: string | null | undefined): Node[];
451
+ ```
346
452
 
347
- Returns the selected drive.
453
+ Returns the child nodes for a drive or folder by id.
348
454
 
349
- ### `useSelectedDriveSafe`
455
+ ```ts
456
+ function useFolderChildNodesForId(id: string | null | undefined): FolderNode[];
457
+ ```
350
458
 
351
- Returns the selected drive, or undefined if no drive is selected.
459
+ Returns the folder child nodes for a drive or folder by id.
352
460
 
353
- ---
461
+ ```ts
462
+ function useFileChildNodesForId(id: string | null | undefined): FileNode[];
463
+ ```
354
464
 
355
- ## Selected Folder
465
+ Returns the file (document) child nodes for a drive or folder by id.
356
466
 
357
- ### `useSelectedFolder`
467
+ Usage
358
468
 
359
- Returns the selected folder.
469
+ ```jsx
470
+ import {
471
+ useChildNodesForId,
472
+ useFolderChildNodesForId,
473
+ useFileChildNodesForId,
474
+ } from "@powerhousedao/state";
360
475
 
361
- ---
476
+ function MyEditorComponent() {
477
+ const driveOrFolderId = "some-drive-or-folder-id";
478
+ const nodes = useChildNodesForId(driveOrFolderId);
479
+ const fileNodes = useFileChildNodesForId(driveOrFolderId);
480
+ const folderNodes = useFolderChildNodesForId(driveOrFolderId);
362
481
 
363
- ## Selected Node
482
+ return (
483
+ <div>
484
+ <FilesAndFolders nodes={nodes} />
485
+ <Files fileNodes={fileNodes} />
486
+ <Folders folderNodes={folderNodes} />
487
+ </div>
488
+ );
489
+ }
490
+ ```
364
491
 
365
- ### `useSelectedNode`
492
+ </details>
366
493
 
367
- Returns the selected node.
494
+ <details>
495
+ <summary>useNodeName/useNodeKind</summary>
368
496
 
369
- ### `setSelectedNode`
497
+ ```ts
498
+ function useNodeName(id: string | null | undefined): string | undefined;
499
+ ```
370
500
 
371
- Sets the selected node (file or folder).
501
+ Returns the name of a node.
372
502
 
373
- ---
503
+ ```ts
504
+ function useNodeKind(id: string | null | undefined): NodeKind | undefined;
505
+ ```
374
506
 
375
- ## Selected Timeline Item
507
+ Returns the kind of a node.
376
508
 
377
- ### `useSelectedTimelineItem`
509
+ Usage
378
510
 
379
- Returns the selected timeline item.
511
+ ```jsx
512
+ import { useNodeName, useNodeKind } from "@powerhousedao/state";
380
513
 
381
- ### `setSelectedTimelineItem`
514
+ function MyEditorComponent() {
515
+ const nodeId = "some-node-id";
516
+ const nodeName = useNodeName(nodeId);
517
+ const nodeKind = useNodeKind(nodeId);
382
518
 
383
- Sets the selected timeline item.
519
+ if (nodeKind === "file") {
520
+ return <File name={nodeName} />;
521
+ }
384
522
 
385
- ### `addSelectedTimelineItemEventHandler`
523
+ if (nodeKind === "folder") {
524
+ return <Folder name={nodeName} />;
525
+ }
526
+ }
527
+ ```
386
528
 
387
- Adds event handler for selected timeline item.
529
+ </details>
388
530
 
389
- ---
531
+ ### Vetra Packages and Modules
390
532
 
391
- ## Supported Document Types
533
+ Vetra packages hold code which can plug into your Connect application. This includes common default modules like the document model document model editor and document drive document model, as well as the modules from your local project and the various packages you have installed.
392
534
 
393
- ### `useSupportedDocumentTypesInReactor`
535
+ These modules can be for:
394
536
 
395
- Returns the supported document types for the reactor (derived from the document model modules).
537
+ - document models
538
+ - editors
539
+ - subgraphs
540
+ - import scripts
541
+ - processors
396
542
 
397
- ---
543
+ Each Vetra package contains a `modules` field which optionally contains lists of these modules.
398
544
 
399
- ## Timeline Revision
545
+ <details>
546
+ <summary>useVetraPackages</summary>
400
547
 
401
- ### `useSelectedTimelineRevision`
548
+ ```ts
549
+ function useVetraPackages(): VetraPackage[] | undefined;
550
+ ```
402
551
 
403
- Returns the selected timeline revision.
552
+ Returns all of the Vetra packages in your Connect app.
404
553
 
405
- ### `setSelectedTimelineRevision`
554
+ Usage
406
555
 
407
- Sets the selected timeline revision.
556
+ ```jsx
557
+ import { useVetraPackages } from "@powerhousedao/state";
408
558
 
409
- ### `addSelectedTimelineRevisionEventHandler`
559
+ function MyEditorComponent() {
560
+ const vetraPackages = useVetraPackages();
561
+ }
562
+ ```
410
563
 
411
- Adds an event handler for the selected timeline revision.
564
+ </details>
412
565
 
413
- ---
566
+ <details>
567
+ <summary>useDocumentModelModules</summary>
414
568
 
415
- ## Use Get Switchboard Link
569
+ ```ts
570
+ function useDocumentModelModules(): DocumentModelModule[] | undefined;
571
+ ```
416
572
 
417
- ### `useGetSwitchboardLink`
573
+ Returns the document model modules from your Vetra packages.
418
574
 
419
- Hook that returns a function to generate a document's switchboard URL.
420
- Only returns a function for documents in remote drives.
421
- Returns null for local drives or when the document/drive cannot be determined.
575
+ Usage
422
576
 
423
- The returned function generates a fresh bearer token and builds the switchboard URL
424
- with authentication when called.
577
+ ```jsx
578
+ import { useDocumentModelModules } from "@powerhousedao/state";
425
579
 
426
- **Parameters:**
427
- - `document` - The document to create a switchboard URL generator for
580
+ function MyEditorComponent() {
581
+ const documentModelModules = useDocumentModelModules();
582
+ }
583
+ ```
428
584
 
429
- **Returns:** An async function that returns the switchboard URL, or null if not applicable
585
+ </details>
430
586
 
431
- ---
587
+ <details>
588
+ <summary>useDocumentModelModuleById</summary>
432
589
 
433
- ## Vetra Packages
590
+ ```ts
591
+ function useDocumentModelModuleById(): DocumentModelModule[] | undefined;
592
+ ```
434
593
 
435
- ### `useVetraPackages`
594
+ Returns the document model for a given id (document type).
595
+ _NOTE_ What we call here an id is really the value in the "document type" field in the document model editor
596
+ _NOTE_ Connect assumes that these document types (ids) are unique. It is your responsibility to enforce this.
436
597
 
437
- Returns all of the Vetra packages loaded by the Connect instance.
598
+ Usage
438
599
 
439
- ### `addVetraPackagesEventHandler`
600
+ ```jsx
601
+ import { useDocumentModelModuleById } from "@powerhousedao/state";
440
602
 
441
- Adds the Vetra packages event handler.
603
+ function MyEditorComponent() {
604
+ const documentType = "my-org/my-document";
605
+ const documentModelModuleById = useDocumentModelModuleById(documentType);
606
+ }
607
+ ```
442
608
 
443
- ### `setVetraPackages`
609
+ </details>
444
610
 
445
- Sets the Vetra packages for the Connect instance.
611
+ <details>
612
+ <summary>useEditorModules</summary>
446
613
 
447
- ---
614
+ ```ts
615
+ function useEditorModules(): EditorModule[] | undefined;
616
+ ```
448
617
 
618
+ Returns the editor modules from your Vetra packages.
449
619
 
450
- ## Config: Editor
620
+ Usage
451
621
 
452
- ### `setIsExternalControlsEnabled`
622
+ ```jsx
623
+ import { useEditorModules } from "@powerhousedao/state";
453
624
 
454
- Sets whether external controls are enabled for a given editor.
625
+ function MyEditorComponent() {
626
+ const editorModules = useEditorModules();
627
+ }
628
+ ```
455
629
 
456
- ### `useIsExternalControlsEnabled`
630
+ </details>
457
631
 
458
- Gets whether external controls are enabled for a given editor.
632
+ <details>
633
+ <summary>useDriveEditorModules</summary>
459
634
 
460
- ### `addIsExternalControlsEnabledEventHandler`
635
+ ```ts
636
+ function useDriveEditorModules(): DriveEditorModule[] | undefined;
637
+ ```
461
638
 
462
- Adds an event handler for when the external controls enabled state changes.
639
+ Returns the drive editor modules from your Vetra packages.
463
640
 
464
- ### `setIsDragAndDropEnabled`
641
+ Usage
465
642
 
466
- Sets whether drag and drop is enabled for a given drive editor.
643
+ ```jsx
644
+ import { useDriveEditorModules } from "@powerhousedao/state";
467
645
 
468
- ### `useIsDragAndDropEnabled`
646
+ function MyDriveEditorComponent() {
647
+ const driveEditorModules = useDriveEditorModules();
648
+ }
649
+ ```
469
650
 
470
- Gets whether drag and drop is enabled for a given drive editor.
651
+ </details>
471
652
 
472
- ### `addIsDragAndDropEnabledEventHandler`
653
+ <details>
654
+ <summary>useProcessorModules</summary>
473
655
 
474
- Adds an event handler for when the drag and drop enabled state changes.
656
+ ```ts
657
+ function useProcessorModules(): ProcessorModule[] | undefined;
658
+ ```
475
659
 
476
- ### `setAllowedDocumentTypes`
660
+ Returns the processor modules from your Vetra packages.
477
661
 
478
- Sets the allowed document types for a given drive editor.
662
+ Usage
479
663
 
480
- ### `useAllowedDocumentTypes`
664
+ ```jsx
665
+ import { useProcessorModules } from "@powerhousedao/state";
481
666
 
482
- Defines the document types a drive supports.
667
+ function MyProcessorComponent() {
668
+ const processorModules = useProcessorModules();
669
+ }
670
+ ```
483
671
 
484
- Defaults to all of the document types registered in the reactor.
672
+ </details>
485
673
 
486
- ### `addAllowedDocumentTypesEventHandler`
674
+ <details>
675
+ <summary>useSubgraphModules</summary>
487
676
 
488
- Adds an event handler for when the allowed document types for a given drive editor changes.
677
+ ```ts
678
+ function useSubgraphModules(): SubgraphModule[] | undefined;
679
+ ```
489
680
 
490
- ---
681
+ Returns the subgraph modules from your Vetra packages.
491
682
 
492
- ## Config: Set Config by Object
683
+ Usage
493
684
 
494
- ### `setPHDriveEditorConfig`
685
+ ```jsx
686
+ import { useSubgraphModules } from "@powerhousedao/state";
495
687
 
496
- Sets the global drive config.
688
+ function MySubgraphComponent() {
689
+ const subgraphModules = useSubgraphModules();
690
+ }
691
+ ```
497
692
 
498
- Pass in a partial object of the global drive config to set.
693
+ </details>
499
694
 
500
- ### `setPHDocumentEditorConfig`
695
+ <details>
696
+ <summary>useImportScriptModules</summary>
501
697
 
502
- Sets the global document config.
698
+ ```ts
699
+ function useImportScriptModules(): ImportScriptModule[] | undefined;
700
+ ```
503
701
 
504
- Pass in a partial object of the global document config to set.
702
+ Returns the import script modules from your Vetra packages.
505
703
 
506
- ### `useSetPHDriveEditorConfig`
704
+ Usage
507
705
 
508
- Wrapper hook for setting the global drive editor config.
706
+ ```jsx
707
+ import { useImportScriptModules } from "@powerhousedao/state";
509
708
 
510
- Automatically sets the global drive editor config when the component mounts.
709
+ function MyImportScriptComponent() {
710
+ const importScriptModules = useImportScriptModules();
711
+ }
712
+ ```
511
713
 
512
- Pass in a partial object of the global drive editor config to set.
714
+ </details>
513
715
 
514
- ### `useSetPHDocumentEditorConfig`
716
+ ## More documentation coming soon!
515
717
 
516
- Wrapper hook for setting the global document editor config.
718
+ Global access to drive state: A top-level, possibly context-based, way to introspect and interact with any document and its state tree without manually passing things around.
517
719
 
518
- Automatically sets the global document editor config when the component mounts.
720
+ Global dispatcher access: A utility or API (probably a hook or service function) where they give a document ID and get back all the relevant dispatch functions — kind of like a command palette for document ops.
519
721
 
520
- Pass in a partial object of the global document editor config to set.
722
+ ### Core Hooks & Patterns
521
723
 
522
- ---
724
+ - useDocumentField
725
+ - useReadDocumentField
726
+ - useUpdateDocumentField
727
+ - useDocumentDispatch(docId): updateX, delete, ...
523
728
 
524
- ## Config: Use Value by Key
729
+ ### Global Drive Access
525
730
 
526
- ### `usePHDriveEditorConfigByKey`
731
+ - How to access and manipulate the global document tree
732
+ - How to inspect children from parent context
733
+ - Tree traversal utilities (if any)
527
734
 
528
- Gets the value of an item in the global drive config for a given key.
735
+ ### Convenience APIs
529
736
 
530
- Strongly typed, inferred from type definition for the key.
737
+ - Utility functions like getDispatchFunctions(docId)
738
+ - "Quick Start" to manipulate any document like a pro
531
739
 
532
- ### `usePHDocumentEditorConfigByKey`
740
+ ### Working with Context
533
741
 
534
- Gets the value of an item in the global document config for a given key.
742
+ - DriveContext: what lives there, how to use it
743
+ - Example: using context to get current doc, sibling docs
535
744
 
536
- Strongly typed, inferred from type definition for the key.
745
+ ### Best Practices & Patterns
537
746
 
538
- ---
747
+ - When to use useDocumentField vs getDispatch
748
+ - Composing document fields into custom logic