@powerhousedao/academy 4.1.0-dev.9 → 5.0.0-staging.1

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.
@@ -29,185 +29,645 @@ It's important to note that a function should only be named and treated as a hoo
29
29
 
30
30
  </details>
31
31
 
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:
32
+ # Editor state management hooks
34
33
 
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')
34
+ 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.
42
35
 
36
+ Learn more about the [Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingDocumentEditors)
37
+ Learn more about the [Drive Editors](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
43
38
 
44
- // Read-only value
45
- const invoiceName = useReadDocumentField('docId', 'name')
39
+ ## Key concepts
46
40
 
47
- // Write-only updater
48
- const updateInvoiceName = useUpdateDocumentField('docId', 'name')
41
+ ### Reactor
49
42
 
50
- // Combined read + write (like useState)
51
- const [invoiceName, updateInvoiceName] = useDocumentField('docId', 'name')
43
+ 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)
44
+
45
+
46
+ ### Selected drives, folders and documents
47
+ In the application, there are certain items that can be set as "selected".
48
+
49
+ - selected drive
50
+ - selected folder
51
+ - selected document
52
+
53
+ We provide hooks for getting the selected item for each:
54
+
55
+ `useSelectedDrive`
56
+ `useSelectedFolder`
57
+ `useSelectedDocument`
58
+
59
+ Folders and documents are part of a given drive, so they will both be undefined if the selected drive is undefined.
60
+
61
+ _Either_ a folder or a document can be selected but not both, so if one is defined then the other will be undefined.
62
+
63
+ To set the selected drive, we provide a function `setSelectedDrive` which takes either a `DocumentDriveDocument` or a `DocumentDriveDocument['header']['slug']`.
64
+
65
+ To set the selected document/folder, we provide a function `setSelectedNode` which returns a setter function which can be used for _both_ documents and folders. This function takes either a `Node` or a slug which can be the url slug or the node's id.
66
+
67
+ ## Hooks
68
+
69
+ <details>
70
+ <summary>Reactor</summary>
71
+ ```ts
72
+ function useReactor(): Reactor | undefined
73
+ ```
74
+
75
+ Returns the reactor instance.
76
+
77
+ Usage
78
+ ```jsx
79
+ import { useReactor } from '@powerhousedao/state`
80
+
81
+ function MyEditorComponent() {
82
+ const reactor = useReactor();
83
+ }
52
84
  ```
53
- Initial documentation about the hooks can be found [here](https://github.com/powerhouse-inc/powerhouse/blob/main/packages/common/state/README.md)
85
+ </details>
54
86
 
55
- ### Temporary use of new hooks on custom drive editors.
87
+ ### Drives
56
88
 
89
+ <details>
90
+ <summary>useDrives</summary>
57
91
 
58
- To use the new hooks in custom components or editors today, devs must:
92
+ ```ts
93
+ function useDrives(): DocumentDriveDocument[] | undefined
94
+ ```
95
+ Returns the drives for a reactor.
59
96
 
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:
97
+ Usage
63
98
 
64
- const refresh = useSyncDrivesAndDocumentsWithReactor();
99
+ ```jsx
100
+ import { useDrives } from '@powerhousedao/state';
65
101
 
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..
102
+ function MyEditorComponent() {
103
+ const drives = useDrives();
104
+ }
105
+ ```
106
+ </details>
67
107
 
68
- Example:
108
+ <details>
109
+ <summary>useDriveById</summary>
69
110
 
111
+ ```ts
112
+ function useDriveById(id: string | null | undefined): DocumentDriveDocument | undefined
70
113
  ```
71
- +import { AtomStoreProvider } from "@powerhousedao/common";
72
114
 
73
- export default function Editor(props: IProps) {
115
+ Returns a drive by id.
116
+
117
+ Usage
118
+
119
+ ```jsx
120
+ import { useDriveById } from '@powerhousedao/state';
121
+
122
+ function MyEditorComponent() {
123
+ const driveById = useDriveById();
124
+ }
125
+ ```
126
+ </details>
127
+
128
+ <details>
129
+ <summary>useSelectedDrive</summary>
130
+
131
+ ```ts
132
+ function useSelectedDrive(): DocumentDriveDocument | undefined
133
+ ```
134
+
135
+ Returns the selected drive. You can use the selected drive with `setSelectedDrive`.
136
+
137
+ Usage
138
+
139
+ ```jsx
140
+ import { useSelectedDrive } from '@powerhousedao/state';
141
+
142
+ function MyEditorComponent() {
143
+ const selectedDrive = useSelectedDrive();
144
+ }
145
+ ```
146
+ </details>
147
+
148
+ <details>
149
+ <summary>drive properties convenience hooks</summary>
150
+
151
+ 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.
152
+
153
+ ```ts
154
+ /** Returns the remote URL for a drive. */
155
+ function useDriveRemoteUrl(driveId: string | null | undefined): string | undefined
156
+
157
+ /** Returns the pull responder trigger for a drive. */
158
+ function useDrivePullResponderTrigger(
159
+ driveId: string | null | undefined,
160
+ ): Trigger | undefined
161
+
162
+ /** Returns the pull responder URL for a drive. */
163
+ function useDrivePullResponderUrl(driveId: string | null | undefined): string | undefined
164
+
165
+ /** Returns whether a drive is remote. */
166
+ function useDriveIsRemote(driveId: string | null | undefined): boolean
167
+
168
+ /** Returns the sharing type for a drive. */
169
+ function useDriveSharingType(driveId: string | null | undefined): SharingType | undefined
170
+
171
+ /** Returns whether a drive is available offline. */
172
+ function useDriveAvailableOffline(driveId: string | null | undefined): boolean
173
+ ```
174
+
175
+ Usage
176
+
177
+ ```jsx
178
+ import {
179
+ useDriveRemoteUrl,
180
+ useDrivePullResponderTrigger,
181
+ useDrivePullResponderUrl,
182
+ useDriveIsRemote,
183
+ useDriveSharingType,
184
+ useDriveAvailableOffline,
185
+ } from '@powerhousedao/state';
186
+
187
+ function MyEditorComponent() {
188
+ const myDriveId = "some-drive-id";
189
+ const driveRemoteUrl = useDriveRemoteUrl(myDriveId);
190
+ const drivePullResponderTrigger = useDrivePullResponderTrigger(myDriveId);
191
+ const drivePullResponderUrl = useDrivePullResponderUrl(myDriveId);
192
+ const driveIsRemote = useDriveIsRemote(myDriveId);
193
+ const driveSharingType = useDriveSharingType(myDriveId);
194
+ const driveAvailableOffline = useDriveAvailableOffline(myDriveId);
195
+
196
+ console.log({
197
+ driveRemoteUrl,
198
+ drivePullResponderTrigger,
199
+ drivePullResponderUrl,
200
+ driveIsRemote,
201
+ driveSharingType,
202
+ driveAvailableOffline,
203
+ })
204
+ }
205
+ ```
206
+ </details>
207
+
208
+ ### Documents
209
+
210
+ <details>
211
+ <summary>useAllDocuments/useSelectedDriveDocuments</summary>
212
+
213
+ ```ts
214
+ function useAllDocuments(): PHDocument[] | undefined
215
+ ```
216
+ Returns all of the documents in the reactor.
217
+
218
+ ```ts
219
+ function useSelectedDriveDocuments(): PHDocument[] | undefined
220
+ ```
221
+ Returns the documents in the reactor for the selected drive.
222
+
223
+ Usage
224
+
225
+ ```jsx
226
+ import { useAllDocuments, useSelectedDriveDocuments } from '@powerhousedao/state';
227
+
228
+ function MyEditorComponent() {
229
+ const allDocuments = useAllDocuments();
230
+ const selectedDriveDocuments = useSelectedDriveDocuments();
231
+ }
232
+ ```
233
+ </details>
234
+
235
+ <details>
236
+ <summary>useSelectedDocument</summary>
237
+
238
+ ```ts
239
+ function useSelectedDocument(): PHDocument | undefined
240
+ ```
241
+ Returns the selected document. You can set the selected document with `setSelectedNode`.
242
+
243
+ Usage
244
+
245
+ ```jsx
246
+ import { useSelectedDocument } from '@powerhousedao/state';
247
+
248
+ function MyEditorComponent() {
249
+ const selectedDocument = useSelectedDocument();
250
+ }
251
+ ```
252
+ </details>
253
+
254
+ <details>
255
+ <summary>useDocumentById</summary>
256
+
257
+ ```ts
258
+ function useDocumentById(id: string | null | undefined): PHDocument | undefined
259
+ ```
260
+ Returns a document by id.
261
+
262
+ Usage
263
+
264
+ ```jsx
265
+ import { useDocumentById } from '@powerhousedao/state';
266
+
267
+ function MyEditorComponent() {
268
+ const myDocumentId = 'some-document-id';
269
+ const documentById = useDocumentById(myDocumentId);
270
+ }
271
+ ```
272
+ </details>
273
+
274
+ ### Nodes
275
+
276
+ "Nodes" refers to the items found in a given drive's `state.global.nodes` array. Nodes can represent both files (documents) and folders.
277
+
278
+ A document in a drive will have a node in the drive's node list which has the same id as the document.
279
+
280
+ 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.
281
+
282
+ 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.
283
+
284
+ ```ts
285
+ type FileNode = {
286
+ documentType: string;
287
+ id: string;
288
+ kind: string;
289
+ name: string;
290
+ parentFolder: string | null | undefined;
291
+ }
292
+
293
+ type FolderNode = {
294
+ id: string;
295
+ kind: string;
296
+ name: string;
297
+ parentFolder: string | null | undefined;
298
+ }
299
+
300
+ type Node = FileNode | FolderNode;
301
+ ```
302
+
303
+ <details>
304
+ <summary>useNodes</summary>
305
+
306
+ 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.
307
+
308
+ ```ts
309
+ function useNodes(): Node[] | undefined
310
+ ```
311
+ Returns the nodes for a drive.
312
+
313
+ Usage
314
+
315
+ ```jsx
316
+ import { useNodes} from '@powerhousedao/state';
317
+
318
+ function MyEditorComponent() {
319
+ const nodes = useNodes();
320
+ }
321
+ ```
322
+ </details>
323
+
324
+ <details>
325
+ <summary>useNodeById</summary>
326
+
327
+ ```ts
328
+ function useNodeById(id: string | null | undefined): Node | undefined
329
+ ```
330
+ Returns a node in the selected drive by id.
331
+
332
+ Usage
333
+
334
+ ```jsx
335
+ import { useNodeById } from '@powerhousedao/state';
336
+
337
+ function MyEditorComponent() {
338
+ const myFolderId = 'some-folder-id';
339
+ const myDocumentId = 'some-document-id';
340
+ const myFolderNode = useNodeById(myFolderId);
341
+ const myFileNode = useNodeById(myDocumentId);
342
+ }
343
+ ```
344
+ </details>
345
+
346
+ <details>
347
+ <summary>useSelectedFolder</summary>
348
+
349
+ ```ts
350
+ function useSelectedFolder(): FolderNode | undefined
351
+ ```
352
+ Returns the selected folder. You can set the selected folder with `setSelectedNode`
353
+
354
+ Usage
355
+
356
+ ```jsx
357
+ import { useSelectedFolder } from '@powerhousedao/state';
358
+
359
+ function MyEditorComponent() {
360
+ const selectedFolder = useSelectedFolder();
361
+ }
362
+ ```
363
+ </details>
364
+
365
+ <details>
366
+ <summary>useSelectedNodePath</summary>
367
+
368
+ ```ts
369
+ function useSelectedNodePath(): Node[]
370
+ ```
371
+ Returns the path to the selected node. Useful for navigational components like breadcrumbs.
372
+
373
+ Usage
374
+
375
+ ```jsx
376
+ import { useSelectedNodePath } from '@powerhousedao/state';
377
+
378
+ function MyEditorComponent() {
379
+ const nodes = useSelectedNodePath();
380
+
381
+ return <Breadcrumbs nodes={nodes}>
382
+ }
383
+ ```
384
+ </details>
385
+
386
+ <details>
387
+ <summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
388
+
389
+ ```ts
390
+ function useChildNodes(): Node[]
391
+ ```
392
+ Returns the child nodes for the selected drive or folder.
393
+
394
+ ```ts
395
+ function useFolderChildNodes(): FolderNode[]
396
+ ```
397
+ Returns the folder child nodes for the selected drive or folder.
398
+
399
+ ```ts
400
+ function useFileChildNodes(): FileNode[]
401
+ ```
402
+ Returns the file (document) child nodes for the selected drive or folder.
403
+
404
+ Usage
405
+
406
+ ```jsx
407
+ import { useChildNodes, useFolderChildNodes, useFileChildNodes } from '@powerhousedao/state';
408
+
409
+ function MyEditorComponent() {
410
+ const nodes = useChildNodes();
411
+ const fileNodes = useChildFileNodes();
412
+ const folderNodes = useChildFolderNodes();
413
+
414
+ return (
415
+ <div>
416
+ <FilesAndFolders nodes={nodes}>
417
+ <Files fileNodes={fileNodes}>
418
+ <Folders folderNodes={folderNodes}>
419
+ </div>
420
+ )
421
+ }
422
+ ```
423
+ </details>
424
+
425
+ <details>
426
+ <summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
427
+
428
+ ```ts
429
+ function useChildNodesForId(id: string | null | undefined): Node[]
430
+ ```
431
+ Returns the child nodes for a drive or folder by id.
432
+ ```ts
433
+ function useFolderChildNodesForId(id: string | null | undefined): FolderNode[]
434
+ ```
435
+ Returns the folder child nodes for a drive or folder by id.
436
+ ```ts
437
+ function useFileChildNodesForId(id: string | null | undefined): FileNode[]
438
+ ```
439
+ Returns the file (document) child nodes for a drive or folder by id.
440
+
441
+ Usage
442
+
443
+ ```jsx
444
+ import { useChildNodesForId, useFolderChildNodesForId, useFileChildNodesForId } from '@powerhousedao/state';
445
+
446
+ function MyEditorComponent() {
447
+ const driveOrFolderId = 'some-drive-or-folder-id';
448
+ const nodes = useChildNodesForId(driveOrFolderId);
449
+ const fileNodes = useFileChildNodesForId(driveOrFolderId);
450
+ const folderNodes = useFolderChildNodesForId(driveOrFolderId);
451
+
74
452
  return (
75
- + <AtomStoreProvider reactor={props.context.reactor}>
76
- <DriveContextProvider value={props.context}>
77
- <WagmiContext>
78
- <BaseEditor {...props} />
79
- </WagmiContext>
80
- </DriveContextProvider>
81
- + </AtomStoreProvider>
82
- );
453
+ <div>
454
+ <FilesAndFolders nodes={nodes}>
455
+ <Files fileNodes={fileNodes}>
456
+ <Folders folderNodes={folderNodes}>
457
+ </div>
458
+ )
459
+ }
460
+ ```
461
+ </details>
462
+
463
+ <details>
464
+ <summary>useNodeName/useNodeKind</summary>
465
+
466
+ ```ts
467
+ function useNodeName(id: string | null | undefined): string | undefined
468
+ ```
469
+ Returns the name of a node.
470
+ ```ts
471
+ function useNodeKind(id: string | null | undefined): NodeKind | undefined
472
+ ```
473
+ Returns the kind of a node.
474
+
475
+ Usage
476
+
477
+ ```jsx
478
+ import { useNodeName, useNodeKind } from '@powerhousedao/state';
479
+
480
+ function MyEditorComponent() {
481
+ const nodeId = 'some-node-id';
482
+ const nodeName = useNodeName(nodeId);
483
+ const nodeKind = useNodeKind(nodeId);
484
+
485
+ if (nodeKind === 'file') {
486
+ return <File name={nodeName} />;
487
+ }
488
+
489
+ if (nodeKind === 'folder') {
490
+ return <Folder name={nodeName} />;
491
+ }
492
+ }
493
+ ```
494
+ </details>
495
+
496
+ ### Vetra packages and modules
497
+
498
+ 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.
499
+
500
+ These modules can be for:
501
+
502
+ - document models
503
+ - editors
504
+ - subgraphs
505
+ - import scripts
506
+ - processors
507
+
508
+ Each Vetra package contains a `modules` field which optionally contains lists of these modules.
509
+
510
+ <details>
511
+ <summary>useVetraPackages</summary>
512
+
513
+ ```ts
514
+ function useVetraPackages(): VetraPackage[] | undefined
515
+ ```
516
+
517
+ Returns all of the Vetra packages in your Connect app.
518
+
519
+ Usage
520
+
521
+ ```jsx
522
+ import { useVetraPackages } from '@powerhousedao/state'
523
+
524
+ function MyEditorComponent() {
525
+ const vetraPackages = useVetraPackages()
526
+ }
527
+ ```
528
+ </details>
529
+
530
+ <details>
531
+ <summary>useDocumentModelModules</summary>
532
+
533
+ ```ts
534
+ function useDocumentModelModules(): DocumentModelModule[] | undefined
535
+ ```
536
+
537
+ Returns the document model modules from your Vetra packages.
538
+
539
+ Usage
540
+
541
+ ```jsx
542
+ import { useDocumentModelModules } from '@powerhousedao/state'
543
+
544
+ function MyEditorComponent() {
545
+ const documentModelModules = useDocumentModelModules()
546
+ }
547
+ ```
548
+ </details>
549
+
550
+ <details>
551
+ <summary>useDocumentModelModuleById</summary>
552
+
553
+ ```ts
554
+ function useDocumentModelModuleById(): DocumentModelModule[] | undefined
555
+ ```
556
+
557
+ Returns the document model for a given id (document type).
558
+ *NOTE* What we call here an id is really the value in the "document type" field in the document model editor
559
+ *NOTE* Connect assumes that these document types (ids) are unique. It is your responsibility to enforce this.
560
+
561
+ Usage
562
+
563
+ ```jsx
564
+ import { useDocumentModelModuleById } from '@powerhousedao/state'
565
+
566
+ function MyEditorComponent() {
567
+ const documentType = 'my-org/my-document';
568
+ const documentModelModuleById = useDocumentModelModuleById(documentType)
569
+ }
570
+ ```
571
+ </details>
572
+
573
+ <details>
574
+ <summary>useEditorModules</summary>
575
+
576
+ ```ts
577
+ function useEditorModules(): EditorModule[] | undefined
578
+ ```
579
+
580
+ Returns the editor modules from your Vetra packages.
581
+
582
+ Usage
583
+
584
+ ```jsx
585
+ import { useEditorModules } from '@powerhousedao/state'
586
+
587
+ function MyEditorComponent() {
588
+ const editorModules = useEditorModules()
589
+ }
590
+ ```
591
+ </details>
592
+
593
+ <details>
594
+ <summary>useDriveEditorModules</summary>
595
+
596
+ ```ts
597
+ function useDriveEditorModules(): DriveEditorModule[] | undefined
598
+ ```
599
+
600
+ Returns the drive editor modules from your Vetra packages.
601
+
602
+ Usage
603
+
604
+ ```jsx
605
+ import { useDriveEditorModules } from '@powerhousedao/state'
606
+
607
+ function MyDriveEditorComponent() {
608
+ const driveEditorModules = useDriveEditorModules()
83
609
  }
84
610
  ```
611
+ </details>
85
612
 
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.
613
+ <details>
614
+ <summary>useProcessorModules</summary>
615
+
616
+ ```ts
617
+ function useProcessorModules(): ProcessorModule[] | undefined
618
+ ```
87
619
 
620
+ Returns the processor modules from your Vetra packages.
88
621
 
622
+ Usage
89
623
 
624
+ ```jsx
625
+ import { useProcessorModules } from '@powerhousedao/state'
90
626
 
91
- ## An overview of currently available hooks
92
-
93
- ### 1. Getting or changing data
94
- These are tools you can use in your app to get or change data:
627
+ function MyProcessorComponent() {
628
+ const processorModules = useProcessorModules()
629
+ }
630
+ ```
631
+ </details>
95
632
 
96
633
  <details>
97
- <summary>`useDrives`, `useDriveById(id)`: Lets you access folders (called "drives").</summary>
634
+ <summary>useSubgraphModules</summary>
635
+
636
+ ```ts
637
+ function useSubgraphModules(): SubgraphModule[] | undefined
638
+ ```
98
639
 
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
- </details>
114
-
115
- <details>
116
- <summary>`useDocuments`, `useDocumentById(id)`: Lets you access files (called "documents").</summary>
117
-
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
- </details>
133
-
134
- <details>
135
- <summary>`useEditorModules`, `useEditor(documentType)`: Loads the relevant editor UI/tools for a document.</summary>
136
-
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
- </details>
152
-
153
- <details>
154
- <summary>`useDocumentModule`, `useDocumentModel(documentType)`: Gets the technical model behind a document type—like its schema and operations.</summary>
155
-
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
- </details>
171
-
172
- ### 2. Managing selection state
173
- You can now use the following to manage and track what's currently selected:
174
-
175
- <details>
176
- <summary>`useSelectedDrive` and `useSetSelectedDrive(driveId)`: Get/set the selected folder.</summary>
177
-
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.
640
+ Returns the subgraph modules from your Vetra packages.
641
+
642
+ Usage
643
+
644
+ ```jsx
645
+ import { useSubgraphModules } from '@powerhousedao/state'
646
+
647
+ function MySubgraphComponent() {
648
+ const subgraphModules = useSubgraphModules()
649
+ }
650
+ ```
651
+ </details>
652
+
653
+ <details>
654
+ <summary>useImportScriptModules</summary>
655
+
656
+ ```ts
657
+ function useImportScriptModules(): ImportScriptModule[] | undefined
658
+ ```
659
+
660
+ Returns the import script modules from your Vetra packages.
661
+
662
+ Usage
663
+
664
+ ```jsx
665
+ import { useImportScriptModules } from '@powerhousedao/state'
666
+
667
+ function MyImportScriptComponent() {
668
+ const importScriptModules = useImportScriptModules()
669
+ }
670
+ ```
211
671
  </details>
212
672
 
213
673
  ## More documentation coming soon!