@powerhousedao/academy 4.1.0-dev.8 → 4.1.0-dev.81

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 (108) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/CHANGELOG.md +616 -0
  3. package/README.md +3 -3
  4. package/babel.config.js +1 -1
  5. package/blog/BeyondCommunication-ABlueprintForDevelopment.md +25 -24
  6. package/blog/TheChallengeOfChange.md +21 -21
  7. package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +67 -30
  8. package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +38 -21
  9. package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +24 -19
  10. package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +44 -41
  11. package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +10 -10
  12. package/docs/academy/01-GetStarted/05-VetraStudio.md +164 -0
  13. package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
  14. package/docs/academy/01-GetStarted/home.mdx +185 -90
  15. package/docs/academy/01-GetStarted/images/Modules.png +0 -0
  16. package/docs/academy/01-GetStarted/images/VetraStudioDrive.png +0 -0
  17. package/docs/academy/01-GetStarted/styles.module.css +5 -5
  18. package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/01-Prerequisites.md +46 -18
  19. package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/02-StandardDocumentModelWorkflow.md +118 -68
  20. package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +75 -33
  21. package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/_category_.json +6 -6
  22. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/01-WhatIsADocumentModel.md +30 -21
  23. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +41 -37
  24. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +29 -25
  25. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +36 -37
  26. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +128 -109
  27. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +95 -86
  28. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +7 -9
  29. package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/_category_.json +6 -6
  30. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +65 -47
  31. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/02-ConfiguringDrives.md +77 -62
  32. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/03-BuildingADriveExplorer.md +360 -349
  33. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +16 -10
  34. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +10 -7
  35. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/02-RevisionHistoryTimeline.md +25 -17
  36. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/_category_.json +6 -6
  37. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/01-RenownAuthenticationFlow.md +14 -7
  38. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/02-Authorization.md +0 -1
  39. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/07-Authorization/_category_.json +5 -5
  40. package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/_category_.json +1 -1
  41. package/docs/academy/02-MasteryTrack/04-WorkWithData/01-GraphQLAtPowerhouse.md +45 -33
  42. package/docs/academy/02-MasteryTrack/04-WorkWithData/02-UsingTheAPI.mdx +61 -18
  43. package/docs/academy/02-MasteryTrack/04-WorkWithData/03-UsingSubgraphs.md +105 -456
  44. package/docs/academy/02-MasteryTrack/04-WorkWithData/04-analytics-processor.md +126 -110
  45. package/docs/academy/02-MasteryTrack/04-WorkWithData/05-RelationalDbProcessor.md +98 -65
  46. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/GraphQL References/QueryingADocumentWithGraphQL.md +23 -21
  47. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/best-practices.md +9 -9
  48. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/graphql/index.md +11 -23
  49. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/graphql/integration.md +25 -9
  50. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/intro.md +10 -10
  51. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/benchmarks.md +1 -1
  52. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/index.md +16 -11
  53. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/memory.md +6 -5
  54. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/schema.md +2 -2
  55. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/typescript/utilities.md +7 -5
  56. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/use-cases/maker.md +32 -58
  57. package/docs/academy/02-MasteryTrack/04-WorkWithData/06-Analytics Engine/use-cases/processors.md +1 -1
  58. package/docs/academy/02-MasteryTrack/04-WorkWithData/07-drive-analytics.md +105 -71
  59. package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_01-SetupBuilderEnvironment.md +22 -0
  60. package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_02-CreateNewPowerhouseProject.md +9 -8
  61. package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_03-GenerateAnAnalyticsProcessor.md +28 -32
  62. package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_04-UpdateAnalyticsProcessor.md +25 -26
  63. package/docs/academy/02-MasteryTrack/04-WorkWithData/_ARCHIVE-AnalyticsProcessorTutorial/_category_.json +1 -1
  64. package/docs/academy/02-MasteryTrack/04-WorkWithData/_category_.json +7 -7
  65. package/docs/academy/02-MasteryTrack/05-Launch/01-IntroductionToPackages.md +3 -4
  66. package/docs/academy/02-MasteryTrack/05-Launch/02-PublishYourProject.md +69 -45
  67. package/docs/academy/02-MasteryTrack/05-Launch/03-SetupEnvironment.md +70 -40
  68. package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -0
  69. package/docs/academy/02-MasteryTrack/05-Launch/_category_.json +7 -7
  70. package/docs/academy/02-MasteryTrack/_category_.json +6 -6
  71. package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +5 -3
  72. package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +38 -37
  73. package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +45 -41
  74. package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +14 -14
  75. package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +6 -6
  76. package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
  77. package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +140 -61
  78. package/docs/academy/04-APIReferences/01-ReactHooks.md +649 -141
  79. package/docs/academy/04-APIReferences/04-RelationalDatabase.md +121 -113
  80. package/docs/academy/04-APIReferences/05-PHDocumentMigrationGuide.md +48 -41
  81. package/docs/academy/04-APIReferences/_category_.json +6 -6
  82. package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +1 -2
  83. package/docs/academy/05-Architecture/01-WorkingWithTheReactor.md +11 -8
  84. package/docs/academy/05-Architecture/05-DocumentModelTheory/_category_.json +1 -1
  85. package/docs/academy/05-Architecture/_category_.json +6 -6
  86. package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +25 -23
  87. package/docs/academy/06-ComponentLibrary/02-CreateCustomScalars.md +105 -93
  88. package/docs/academy/06-ComponentLibrary/03-IntegrateIntoAReactComponent.md +1 -0
  89. package/docs/academy/06-ComponentLibrary/_category_.json +7 -7
  90. package/docs/academy/07-Cookbook.md +268 -35
  91. package/docs/academy/08-Glossary.md +7 -1
  92. package/docs/bookofpowerhouse/01-Overview.md +2 -2
  93. package/docs/bookofpowerhouse/02-GeneralFrameworkAndPhilosophy.md +1 -7
  94. package/docs/bookofpowerhouse/03-PowerhouseSoftwareArchitecture.md +10 -7
  95. package/docs/bookofpowerhouse/04-DevelopmentApproaches.md +10 -4
  96. package/docs/bookofpowerhouse/05-SNOsandANewModelForOSSandPublicGoods.md +23 -30
  97. package/docs/bookofpowerhouse/06-SNOsInActionAndPlatformEconomies.md +0 -7
  98. package/docusaurus.config.ts +64 -66
  99. package/package.json +9 -7
  100. package/scripts/generate-combined-cli-docs.ts +43 -13
  101. package/sidebars.ts +2 -0
  102. package/src/components/HomepageFeatures/index.tsx +171 -78
  103. package/src/components/HomepageFeatures/styles.module.css +1 -2
  104. package/src/css/custom.css +89 -89
  105. package/src/pages/_archive-homepage.tsx +17 -16
  106. package/src/theme/DocCardList/index.tsx +9 -8
  107. package/static.json +6 -6
  108. package/tsconfig.tsbuildinfo +1 -0
@@ -1,6 +1,6 @@
1
1
  # React Hooks
2
2
 
3
- On this page we're providing an overview of the available hooks you can make use of as a builder.
3
+ On this page we're providing an overview of the available hooks you can make use of as a builder.
4
4
 
5
5
  <details>
6
6
  <summary>Need a refresher on React Hooks?</summary>
@@ -9,11 +9,13 @@ React Hooks allow you to use various React features directly within your functio
9
9
 
10
10
  **What are Custom Hooks?**
11
11
  A custom hook is a JavaScript function whose name starts with "use" and that calls other Hooks. They are used to:
12
+
12
13
  - Reuse stateful logic between components.
13
14
  - Abstract complex logic into a simpler interface.
14
15
  - Isolate side effects, particularly those managed by `useEffect`.
15
16
 
16
17
  **Key Built-in Hooks Examples:**
18
+
17
19
  - `useState`: Lets a component "remember" information (state).
18
20
  - `useEffect`: Lets a component perform side effects (e.g., data fetching, subscriptions, manually changing the DOM).
19
21
  - `useContext`: Lets a component receive information from distant parent components without explicitly passing props through every level of the component tree.
@@ -22,6 +24,7 @@ A custom hook is a JavaScript function whose name starts with "use" and that cal
22
24
  Hook names must always start with `use` followed by a capital letter (e.g., `useState`, `useOnlineStatus`).
23
25
 
24
26
  **Rules of Hooks:**
27
+
25
28
  1. **Only Call Hooks at the Top Level**: Don't call Hooks inside loops, conditions, or nested functions.
26
29
  2. **Only Call Hooks from React Functions**: Call Hooks from React functional components or from custom Hooks.
27
30
 
@@ -29,185 +32,685 @@ It's important to note that a function should only be named and treated as a hoo
29
32
 
30
33
  </details>
31
34
 
32
- The idea is to make the usage of our hooks feel as simple and familiar as using `useState`.
33
- The Powerhouse team is currently working on a happy path for builders that look like this:
35
+ # Editor state management hooks
36
+
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
+
39
+ Learn more about the [Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingDocumentEditors)
40
+ Learn more about the [Drive Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
34
41
 
35
- ```js
36
- // in a component that only needs to read a value, you can use
37
- const invoiceName = useReadDocumentField('myInvoiceDocumentId', 'name') // returns a string which is the `name`
38
- // and for documents that need to update data as well, you would have
39
- const updateInvoiceName = useUpdateDocumentField('myInvoiceDocumentId', 'name') // returns a function that takes a new string for the new name and dispatches the update
40
- // finally, we can combine these into a single hook which works like react's useState hook returning both the value and updater function
41
- const [invoiceName, updateInvoiceName] = useDocumentField('myInvoiceDocumentId', 'name')
42
+ ## Key concepts
42
43
 
44
+ ### Reactor
43
45
 
44
- // Read-only value
45
- const invoiceName = useReadDocumentField('docId', 'name')
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)
46
47
 
47
- // Write-only updater
48
- const updateInvoiceName = useUpdateDocumentField('docId', 'name')
48
+ <details>
49
+ <summary>useReactor</summary>
49
50
 
50
- // Combined read + write (like useState)
51
- const [invoiceName, updateInvoiceName] = useDocumentField('docId', 'name')
51
+ ```ts
52
+ function useReactor(): Reactor | undefined;
52
53
  ```
53
- Initial documentation about the hooks can be found [here](https://github.com/powerhouse-inc/powerhouse/blob/main/packages/common/state/README.md)
54
54
 
55
- ### Temporary use of new hooks on custom drive editors.
55
+ Returns the reactor instance.
56
56
 
57
+ Usage
57
58
 
58
- To use the new hooks in custom components or editors today, devs must:
59
+ ```jsx
60
+ import { useReactor } from "@powerhousedao/state";
59
61
 
60
- 1. Pass in the existing Reactor instance as a prop (createReactor).
61
- 2. Call useInitializeReactor(props.createReactor, false) in the custom component.
62
- 3. Optionally wrap dispatch() to trigger a refresh manually, using:
62
+ function MyEditorComponent() {
63
+ const reactor = useReactor();
64
+ }
65
+ ```
63
66
 
64
- const refresh = useSyncDrivesAndDocumentsWithReactor();
67
+ </details>
65
68
 
66
- For maximum compatibility, consider passing data and set functions (drives, documents, etc.) directly as props instead of using the hooks inside the custom editor..
69
+ ### Drives
67
70
 
68
- Example:
71
+ <details>
72
+ <summary>useDrives</summary>
69
73
 
74
+ ```ts
75
+ function useDrives(): DocumentDriveDocument[] | undefined;
70
76
  ```
71
- +import { AtomStoreProvider } from "@powerhousedao/common";
72
77
 
73
- export default function Editor(props: IProps) {
78
+ Returns the drives for a reactor.
79
+
80
+ Usage
81
+
82
+ ```jsx
83
+ import { useDrives } from "@powerhousedao/state";
84
+
85
+ function MyEditorComponent() {
86
+ const drives = useDrives();
87
+ }
88
+ ```
89
+
90
+ </details>
91
+
92
+ <details>
93
+ <summary>useDriveById</summary>
94
+
95
+ ```ts
96
+ function useDriveById(
97
+ id: string | null | undefined,
98
+ ): DocumentDriveDocument | undefined;
99
+ ```
100
+
101
+ Returns a drive by id.
102
+
103
+ Usage
104
+
105
+ ```jsx
106
+ import { useDriveById } from "@powerhousedao/state";
107
+
108
+ function MyEditorComponent() {
109
+ const driveById = useDriveById("some-id");
110
+ }
111
+ ```
112
+
113
+ </details>
114
+
115
+ <details>
116
+ <summary>useSelectedDrive</summary>
117
+
118
+ ```ts
119
+ function useSelectedDrive(): DocumentDriveDocument | undefined;
120
+ ```
121
+
122
+ Returns the selected drive. You can set the selected drive with `setSelectedDrive`.
123
+
124
+ Usage
125
+
126
+ ```jsx
127
+ import { useSelectedDrive } from "@powerhousedao/state";
128
+
129
+ function MyEditorComponent() {
130
+ const selectedDrive = useSelectedDrive();
131
+ }
132
+ ```
133
+
134
+ </details>
135
+
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
+ ```
200
+
201
+ </details>
202
+
203
+ ### Documents
204
+
205
+ <details>
206
+ <summary>useAllDocuments/useSelectedDriveDocuments</summary>
207
+
208
+ ```ts
209
+ function useAllDocuments(): PHDocument[] | undefined;
210
+ ```
211
+
212
+ Returns all of the documents in the reactor.
213
+
214
+ ```ts
215
+ function useSelectedDriveDocuments(): PHDocument[] | undefined;
216
+ ```
217
+
218
+ Returns the documents in the reactor for the selected drive.
219
+
220
+ Usage
221
+
222
+ ```jsx
223
+ import {
224
+ useAllDocuments,
225
+ useSelectedDriveDocuments,
226
+ } from "@powerhousedao/state";
227
+
228
+ function MyEditorComponent() {
229
+ const allDocuments = useAllDocuments();
230
+ const selectedDriveDocuments = useSelectedDriveDocuments();
231
+ }
232
+ ```
233
+
234
+ </details>
235
+
236
+ <details>
237
+ <summary>useSelectedDocument</summary>
238
+
239
+ ```ts
240
+ function useSelectedDocument(): PHDocument | undefined;
241
+ ```
242
+
243
+ Returns the selected document. You can set the selected document with `setSelectedNode`.
244
+
245
+ Usage
246
+
247
+ ```jsx
248
+ import { useSelectedDocument } from "@powerhousedao/state";
249
+
250
+ function MyEditorComponent() {
251
+ const selectedDocument = useSelectedDocument();
252
+ }
253
+ ```
254
+
255
+ </details>
256
+
257
+ <details>
258
+ <summary>useDocumentById</summary>
259
+
260
+ ```ts
261
+ function useDocumentById(id: string | null | undefined): PHDocument | undefined;
262
+ ```
263
+
264
+ Returns a document by id.
265
+
266
+ Usage
267
+
268
+ ```jsx
269
+ import { useDocumentById } from "@powerhousedao/state";
270
+
271
+ function MyEditorComponent() {
272
+ const myDocumentId = "some-document-id";
273
+ const documentById = useDocumentById(myDocumentId);
274
+ }
275
+ ```
276
+
277
+ </details>
278
+
279
+ ### Nodes
280
+
281
+ "Nodes" refers to the items found in a given drive's `state.global.nodes` array. Nodes can represent both files (documents) and folders.
282
+
283
+ A document in a drive will have a node in the drive's node list which has the same id as the document.
284
+
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.
286
+
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.
288
+
289
+ ```ts
290
+ type FileNode = {
291
+ documentType: string;
292
+ id: string;
293
+ kind: string;
294
+ name: string;
295
+ parentFolder: string | null | undefined;
296
+ };
297
+
298
+ type FolderNode = {
299
+ id: string;
300
+ kind: string;
301
+ name: string;
302
+ parentFolder: string | null | undefined;
303
+ };
304
+
305
+ type Node = FileNode | FolderNode;
306
+ ```
307
+
308
+ <details>
309
+ <summary>useNodes</summary>
310
+
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.
312
+
313
+ ```ts
314
+ function useNodes(): Node[] | undefined;
315
+ ```
316
+
317
+ Returns the nodes for a drive.
318
+
319
+ Usage
320
+
321
+ ```jsx
322
+ import { useNodes } from "@powerhousedao/state";
323
+
324
+ function MyEditorComponent() {
325
+ const nodes = useNodes();
326
+ }
327
+ ```
328
+
329
+ </details>
330
+
331
+ <details>
332
+ <summary>useNodeById</summary>
333
+
334
+ ```ts
335
+ function useNodeById(id: string | null | undefined): Node | undefined;
336
+ ```
337
+
338
+ Returns a node in the selected drive by id.
339
+
340
+ Usage
341
+
342
+ ```jsx
343
+ import { useNodeById } from "@powerhousedao/state";
344
+
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
+ ```
352
+
353
+ </details>
354
+
355
+ <details>
356
+ <summary>useSelectedFolder</summary>
357
+
358
+ ```ts
359
+ function useSelectedFolder(): FolderNode | undefined;
360
+ ```
361
+
362
+ Returns the selected folder. You can set the selected folder with `setSelectedNode`
363
+
364
+ Usage
365
+
366
+ ```jsx
367
+ import { useSelectedFolder } from "@powerhousedao/state";
368
+
369
+ function MyEditorComponent() {
370
+ const selectedFolder = useSelectedFolder();
371
+ }
372
+ ```
373
+
374
+ </details>
375
+
376
+ <details>
377
+ <summary>useSelectedNodePath</summary>
378
+
379
+ ```ts
380
+ function useSelectedNodePath(): Node[];
381
+ ```
382
+
383
+ Returns the path to the selected node. Useful for navigational components like breadcrumbs.
384
+
385
+ Usage
386
+
387
+ ```jsx
388
+ import { useSelectedNodePath } from "@powerhousedao/state";
389
+
390
+ function MyEditorComponent() {
391
+ const nodes = useSelectedNodePath();
392
+
393
+ return <Breadcrumbs nodes={nodes} />;
394
+ }
395
+ ```
396
+
397
+ </details>
398
+
399
+ <details>
400
+ <summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
401
+
402
+ ```ts
403
+ function useChildNodes(): Node[];
404
+ ```
405
+
406
+ Returns the child nodes for the selected drive or folder.
407
+
408
+ ```ts
409
+ function useFolderChildNodes(): FolderNode[];
410
+ ```
411
+
412
+ Returns the folder child nodes for the selected drive or folder.
413
+
414
+ ```ts
415
+ function useFileChildNodes(): FileNode[];
416
+ ```
417
+
418
+ Returns the file (document) child nodes for the selected drive or folder.
419
+
420
+ Usage
421
+
422
+ ```jsx
423
+ import {
424
+ useChildNodes,
425
+ useFolderChildNodes,
426
+ useFileChildNodes,
427
+ } from "@powerhousedao/state";
428
+
429
+ function MyEditorComponent() {
430
+ const nodes = useChildNodes();
431
+ const fileNodes = useFileChildNodes();
432
+ const folderNodes = useFolderChildNodes();
433
+
434
+ return (
435
+ <div>
436
+ <FilesAndFolders nodes={nodes} />
437
+ <Files fileNodes={fileNodes} />
438
+ <Folders folderNodes={folderNodes} />
439
+ </div>
440
+ );
441
+ }
442
+ ```
443
+
444
+ </details>
445
+
446
+ <details>
447
+ <summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
448
+
449
+ ```ts
450
+ function useChildNodesForId(id: string | null | undefined): Node[];
451
+ ```
452
+
453
+ Returns the child nodes for a drive or folder by id.
454
+
455
+ ```ts
456
+ function useFolderChildNodesForId(id: string | null | undefined): FolderNode[];
457
+ ```
458
+
459
+ Returns the folder child nodes for a drive or folder by id.
460
+
461
+ ```ts
462
+ function useFileChildNodesForId(id: string | null | undefined): FileNode[];
463
+ ```
464
+
465
+ Returns the file (document) child nodes for a drive or folder by id.
466
+
467
+ Usage
468
+
469
+ ```jsx
470
+ import {
471
+ useChildNodesForId,
472
+ useFolderChildNodesForId,
473
+ useFileChildNodesForId,
474
+ } from "@powerhousedao/state";
475
+
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);
481
+
74
482
  return (
75
- + <AtomStoreProvider reactor={props.context.reactor}>
76
- <DriveContextProvider value={props.context}>
77
- <WagmiContext>
78
- <BaseEditor {...props} />
79
- </WagmiContext>
80
- </DriveContextProvider>
81
- + </AtomStoreProvider>
483
+ <div>
484
+ <FilesAndFolders nodes={nodes} />
485
+ <Files fileNodes={fileNodes} />
486
+ <Folders folderNodes={folderNodes} />
487
+ </div>
82
488
  );
83
489
  }
84
490
  ```
85
491
 
86
- Until the hooks are fully integrated and event handling is granular, the team will need to handle some of this manually or limit their use to experimental side projects and internal demos.
492
+ </details>
493
+
494
+ <details>
495
+ <summary>useNodeName/useNodeKind</summary>
496
+
497
+ ```ts
498
+ function useNodeName(id: string | null | undefined): string | undefined;
499
+ ```
500
+
501
+ Returns the name of a node.
502
+
503
+ ```ts
504
+ function useNodeKind(id: string | null | undefined): NodeKind | undefined;
505
+ ```
506
+
507
+ Returns the kind of a node.
508
+
509
+ Usage
510
+
511
+ ```jsx
512
+ import { useNodeName, useNodeKind } from "@powerhousedao/state";
513
+
514
+ function MyEditorComponent() {
515
+ const nodeId = "some-node-id";
516
+ const nodeName = useNodeName(nodeId);
517
+ const nodeKind = useNodeKind(nodeId);
518
+
519
+ if (nodeKind === "file") {
520
+ return <File name={nodeName} />;
521
+ }
522
+
523
+ if (nodeKind === "folder") {
524
+ return <Folder name={nodeName} />;
525
+ }
526
+ }
527
+ ```
528
+
529
+ </details>
530
+
531
+ ### Vetra Packages and Modules
532
+
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.
534
+
535
+ These modules can be for:
536
+
537
+ - document models
538
+ - editors
539
+ - subgraphs
540
+ - import scripts
541
+ - processors
542
+
543
+ Each Vetra package contains a `modules` field which optionally contains lists of these modules.
544
+
545
+ <details>
546
+ <summary>useVetraPackages</summary>
547
+
548
+ ```ts
549
+ function useVetraPackages(): VetraPackage[] | undefined;
550
+ ```
551
+
552
+ Returns all of the Vetra packages in your Connect app.
553
+
554
+ Usage
555
+
556
+ ```jsx
557
+ import { useVetraPackages } from "@powerhousedao/state";
558
+
559
+ function MyEditorComponent() {
560
+ const vetraPackages = useVetraPackages();
561
+ }
562
+ ```
563
+
564
+ </details>
565
+
566
+ <details>
567
+ <summary>useDocumentModelModules</summary>
87
568
 
569
+ ```ts
570
+ function useDocumentModelModules(): DocumentModelModule[] | undefined;
571
+ ```
88
572
 
573
+ Returns the document model modules from your Vetra packages.
89
574
 
575
+ Usage
90
576
 
91
- ## An overview of currently available hooks
577
+ ```jsx
578
+ import { useDocumentModelModules } from "@powerhousedao/state";
92
579
 
93
- ### 1. Getting or changing data
94
- These are tools you can use in your app to get or change data:
580
+ function MyEditorComponent() {
581
+ const documentModelModules = useDocumentModelModules();
582
+ }
583
+ ```
584
+
585
+ </details>
95
586
 
96
587
  <details>
97
- <summary>`useDrives`, `useDriveById(id)`: Lets you access folders (called "drives").</summary>
588
+ <summary>useDocumentModelModuleById</summary>
589
+
590
+ ```ts
591
+ function useDocumentModelModuleById(): DocumentModelModule[] | undefined;
592
+ ```
593
+
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.
597
+
598
+ Usage
599
+
600
+ ```jsx
601
+ import { useDocumentModelModuleById } from "@powerhousedao/state";
602
+
603
+ function MyEditorComponent() {
604
+ const documentType = "my-org/my-document";
605
+ const documentModelModuleById = useDocumentModelModuleById(documentType);
606
+ }
607
+ ```
98
608
 
99
- ### Hook Name and Signature
100
- The name of the hook and its TypeScript (or JavaScript) signature.
101
- ### Description
102
- A brief explanation of what the hook does and when to use it.
103
- ### Usage Example
104
- A code snippet showing how to use the hook in a real-world scenario.
105
- ### Parameters
106
- A table or list describing each parameter, its type, and its purpose.
107
- ### Return Value
108
- A description (and sometimes a table) of what the hook returns.
109
- ### Notes / Caveats
110
- Any important details, gotchas, or best practices.
111
- ### Related Hooks
112
- Links to other relevant hooks or documentation.
113
609
  </details>
114
610
 
115
611
  <details>
116
- <summary>`useDocuments`, `useDocumentById(id)`: Lets you access files (called "documents").</summary>
612
+ <summary>useEditorModules</summary>
613
+
614
+ ```ts
615
+ function useEditorModules(): EditorModule[] | undefined;
616
+ ```
617
+
618
+ Returns the editor modules from your Vetra packages.
619
+
620
+ Usage
621
+
622
+ ```jsx
623
+ import { useEditorModules } from "@powerhousedao/state";
624
+
625
+ function MyEditorComponent() {
626
+ const editorModules = useEditorModules();
627
+ }
628
+ ```
117
629
 
118
- ### Hook Name and Signature
119
- The name of the hook and its TypeScript (or JavaScript) signature.
120
- ### Description
121
- A brief explanation of what the hook does and when to use it.
122
- ### Usage Example
123
- A code snippet showing how to use the hook in a real-world scenario.
124
- ### Parameters
125
- A table or list describing each parameter, its type, and its purpose.
126
- ### Return Value
127
- A description (and sometimes a table) of what the hook returns.
128
- ### Notes / Caveats
129
- Any important details, gotchas, or best practices.
130
- ### Related Hooks
131
- Links to other relevant hooks or documentation.
132
630
  </details>
133
631
 
134
632
  <details>
135
- <summary>`useEditorModules`, `useEditor(documentType)`: Loads the relevant editor UI/tools for a document.</summary>
633
+ <summary>useDriveEditorModules</summary>
634
+
635
+ ```ts
636
+ function useDriveEditorModules(): DriveEditorModule[] | undefined;
637
+ ```
638
+
639
+ Returns the drive editor modules from your Vetra packages.
640
+
641
+ Usage
642
+
643
+ ```jsx
644
+ import { useDriveEditorModules } from "@powerhousedao/state";
645
+
646
+ function MyDriveEditorComponent() {
647
+ const driveEditorModules = useDriveEditorModules();
648
+ }
649
+ ```
136
650
 
137
- ### Hook Name and Signature
138
- The name of the hook and its TypeScript (or JavaScript) signature.
139
- ### Description
140
- A brief explanation of what the hook does and when to use it.
141
- ### Usage Example
142
- A code snippet showing how to use the hook in a real-world scenario.
143
- ### Parameters
144
- A table or list describing each parameter, its type, and its purpose.
145
- ### Return Value
146
- A description (and sometimes a table) of what the hook returns.
147
- ### Notes / Caveats
148
- Any important details, gotchas, or best practices.
149
- ### Related Hooks
150
- Links to other relevant hooks or documentation.
151
651
  </details>
152
652
 
153
653
  <details>
154
- <summary>`useDocumentModule`, `useDocumentModel(documentType)`: Gets the technical model behind a document type—like its schema and operations.</summary>
654
+ <summary>useProcessorModules</summary>
655
+
656
+ ```ts
657
+ function useProcessorModules(): ProcessorModule[] | undefined;
658
+ ```
659
+
660
+ Returns the processor modules from your Vetra packages.
661
+
662
+ Usage
663
+
664
+ ```jsx
665
+ import { useProcessorModules } from "@powerhousedao/state";
666
+
667
+ function MyProcessorComponent() {
668
+ const processorModules = useProcessorModules();
669
+ }
670
+ ```
155
671
 
156
- ### Hook Name and Signature
157
- The name of the hook and its TypeScript (or JavaScript) signature.
158
- ### Description
159
- A brief explanation of what the hook does and when to use it.
160
- ### Usage Example
161
- A code snippet showing how to use the hook in a real-world scenario.
162
- ### Parameters
163
- A table or list describing each parameter, its type, and its purpose.
164
- ### Return Value
165
- A description (and sometimes a table) of what the hook returns.
166
- ### Notes / Caveats
167
- Any important details, gotchas, or best practices.
168
- ### Related Hooks
169
- Links to other relevant hooks or documentation.
170
672
  </details>
171
673
 
172
- ### 2. Managing selection state
173
- You can now use the following to manage and track what's currently selected:
674
+ <details>
675
+ <summary>useSubgraphModules</summary>
676
+
677
+ ```ts
678
+ function useSubgraphModules(): SubgraphModule[] | undefined;
679
+ ```
680
+
681
+ Returns the subgraph modules from your Vetra packages.
682
+
683
+ Usage
684
+
685
+ ```jsx
686
+ import { useSubgraphModules } from "@powerhousedao/state";
687
+
688
+ function MySubgraphComponent() {
689
+ const subgraphModules = useSubgraphModules();
690
+ }
691
+ ```
692
+
693
+ </details>
174
694
 
175
695
  <details>
176
- <summary>`useSelectedDrive` and `useSetSelectedDrive(driveId)`: Get/set the selected folder.</summary>
696
+ <summary>useImportScriptModules</summary>
697
+
698
+ ```ts
699
+ function useImportScriptModules(): ImportScriptModule[] | undefined;
700
+ ```
701
+
702
+ Returns the import script modules from your Vetra packages.
703
+
704
+ Usage
705
+
706
+ ```jsx
707
+ import { useImportScriptModules } from "@powerhousedao/state";
708
+
709
+ function MyImportScriptComponent() {
710
+ const importScriptModules = useImportScriptModules();
711
+ }
712
+ ```
177
713
 
178
- ### Hook Name and Signature
179
- The name of the hook and its TypeScript (or JavaScript) signature.
180
- ### Description
181
- A brief explanation of what the hook does and when to use it.
182
- ### Usage Example
183
- A code snippet showing how to use the hook in a real-world scenario.
184
- ### Parameters
185
- A table or list describing each parameter, its type, and its purpose.
186
- ### Return Value
187
- A description (and sometimes a table) of what the hook returns.
188
- ### Notes / Caveats
189
- Any important details, gotchas, or best practices.
190
- ### Related Hooks
191
- Links to other relevant hooks or documentation.
192
- </details>
193
-
194
- <details>
195
- <summary>`useSelectedDocument` and `useSetSelectedDocument(documentId)`: Get/set the selected file.</summary>
196
-
197
- ### Hook Name and Signature
198
- The name of the hook and its TypeScript (or JavaScript) signature.
199
- ### Description
200
- A brief explanation of what the hook does and when to use it.
201
- ### Usage Example
202
- A code snippet showing how to use the hook in a real-world scenario.
203
- ### Parameters
204
- A table or list describing each parameter, its type, and its purpose.
205
- ### Return Value
206
- A description (and sometimes a table) of what the hook returns.
207
- ### Notes / Caveats
208
- Any important details, gotchas, or best practices.
209
- ### Related Hooks
210
- Links to other relevant hooks or documentation.
211
714
  </details>
212
715
 
213
716
  ## More documentation coming soon!
@@ -216,25 +719,30 @@ Global access to drive state: A top-level, possibly context-based, way to intros
216
719
 
217
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.
218
721
 
219
- ### Core Hooks & Patterns
722
+ ### Core Hooks & Patterns
723
+
220
724
  - useDocumentField
221
725
  - useReadDocumentField
222
726
  - useUpdateDocumentField
223
- - useDocumentDispatch(docId): updateX, delete, ...
727
+ - useDocumentDispatch(docId): updateX, delete, ...
728
+
729
+ ### Global Drive Access
224
730
 
225
- ### Global Drive Access
226
731
  - How to access and manipulate the global document tree
227
732
  - How to inspect children from parent context
228
733
  - Tree traversal utilities (if any)
229
734
 
230
- ### Convenience APIs
735
+ ### Convenience APIs
736
+
231
737
  - Utility functions like getDispatchFunctions(docId)
232
738
  - "Quick Start" to manipulate any document like a pro
233
739
 
234
- ### Working with Context
740
+ ### Working with Context
741
+
235
742
  - DriveContext: what lives there, how to use it
236
743
  - Example: using context to get current doc, sibling docs
237
744
 
238
- ### Best Practices & Patterns
745
+ ### Best Practices & Patterns
746
+
239
747
  - When to use useDocumentField vs getDispatch
240
- - Composing document fields into custom logic
748
+ - Composing document fields into custom logic