@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.
- package/CHANGELOG.md +43 -1108
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +1 -2
- package/blog/TheChallengeOfChange.md +0 -1
- package/docs/academy/00-EthereumArgentinaHackathon.md +207 -0
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.mdx +27 -24
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +9 -118
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +28 -110
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +145 -191
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +218 -0
- package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/05-VetraStudio.md +6 -48
- package/docs/academy/01-GetStarted/06-ReactorMCP.md +58 -0
- package/docs/academy/01-GetStarted/_04-BuildToDoListEditor +1 -1
- package/docs/academy/02-MasteryTrack/01-BuilderEnvironment/03-BuilderTools.md +2 -2
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +44 -75
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/03-SpecifyDocumentOperations.md +22 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/04-UseTheDocumentModelGenerator.md +31 -28
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/05-ImplementDocumentReducers.md +206 -211
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/06-ImplementDocumentModelTests.md +62 -176
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/07-ExampleToDoListRepository.md +0 -21
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +319 -309
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/00-DocumentToolbar.mdx +0 -4
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/01-OperationHistory.md +0 -4
- package/docs/academy/02-MasteryTrack/05-Launch/04-ConfigureEnvironment.md +1 -1
- package/docs/academy/03-ExampleUsecases/Chatroom/02-CreateNewPowerhouseProject.md +35 -111
- package/docs/academy/03-ExampleUsecases/Chatroom/03-DefineChatroomDocumentModel.md +76 -255
- package/docs/academy/03-ExampleUsecases/Chatroom/04-ImplementOperationReducers.md +160 -281
- package/docs/academy/03-ExampleUsecases/Chatroom/05-ImplementChatroomEditor.md +35 -188
- package/docs/academy/03-ExampleUsecases/Chatroom/06-LaunchALocalReactor.md +7 -95
- package/docs/academy/03-ExampleUsecases/Chatroom/_category_.json +1 -1
- package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +2 -6
- package/docs/academy/04-APIReferences/01-ReactHooks.md +501 -291
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +39 -7
- package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
- package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
- package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +24 -72
- package/docs/academy/08-Glossary.md +0 -7
- package/docusaurus.config.ts +3 -28
- package/package.json +1 -1
- package/sidebars.ts +12 -49
- package/src/css/custom.css +18 -26
- package/docs/academy/01-GetStarted/04-WriteDocumentModelTests.md +0 -378
- package/docs/academy/01-GetStarted/05-BuildToDoListEditor.md +0 -560
- package/docs/academy/03-ExampleUsecases/TodoList/00-GetTheStarterCode.md +0 -24
- package/docs/academy/03-ExampleUsecases/TodoList/01-GenerateTodoListDocumentModel.md +0 -211
- package/docs/academy/03-ExampleUsecases/TodoList/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/03-ExampleUsecases/TodoList/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/03-ExampleUsecases/TodoList/04-GenerateTodoListDocumentEditor.md +0 -45
- package/docs/academy/03-ExampleUsecases/TodoList/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/03-ExampleUsecases/TodoList/06-GenerateTodoDriveExplorer.md +0 -61
- package/docs/academy/03-ExampleUsecases/TodoList/07-AddSharedComponentForShowingTodoListStats.md +0 -384
- package/docs/academy/03-ExampleUsecases/TodoList/_category_.json +0 -8
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/VetraPackageLibrary.md +0 -7
- package/docs/academy/03-ExampleUsecases/VetraPackageLibrary/_category_.json +0 -9
- package/docs/academy/04-APIReferences/06-VetraRemoteDrive.md +0 -160
- package/docs/academy/04-APIReferences/renown-sdk/00-Overview.md +0 -316
- package/docs/academy/04-APIReferences/renown-sdk/01-Authentication.md +0 -672
- package/docs/academy/04-APIReferences/renown-sdk/02-APIReference.md +0 -957
- package/docs/academy/04-APIReferences/renown-sdk/_category_.json +0 -8
- package/docs/academy/10-TodoListTutorial/02-ImplementTodoListDocumentModelReducerOperationHandlers.md +0 -171
- package/docs/academy/10-TodoListTutorial/03-AddTestsForTodoListActions.md +0 -462
- package/docs/academy/10-TodoListTutorial/05-ImplementTodoListDocumentEditorUIComponents.md +0 -422
- package/docs/academy/10-TodoListTutorial/07-AddSharedComponentForShowingTodoListStats.md +0 -370
- package/static/img/Vetra-logo-dark.svg +0 -11
- package/static/img/vetra-logo-light.svg +0 -11
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/Modules.png +0 -0
- /package/docs/academy/{02-MasteryTrack/01-BuilderEnvironment → 01-GetStarted}/images/VetraStudioDrive.png +0 -0
- /package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/06-DocumentTools/{02-RevisionHistoryTimeline/360/237/232/247" → 02-RevisionHistoryTimeline} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /01-WhatIsADocumentModel" → 01-WhatIsADocumentModel} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-DAOandDocumentsModelsQ+A" → 02-DAOandDocumentsModelsQ+A} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /02-domain-modeling" → 02-domain-modeling} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /03-BenefitsOfDocumentModels" → 03-BenefitsOfDocumentModels} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /04-UtilitiesAndTips" → 04-UtilitiesAndTips} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /05-best-practices" → 05-best-practices} +0 -0
- /package/docs/academy/05-Architecture/05-DocumentModelTheory/{360/237/232/247 /_category_.json" → _category_.json} +0 -0
- /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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
+
```ts
|
|
52
|
+
function useReactor(): Reactor | undefined;
|
|
53
|
+
```
|
|
120
54
|
|
|
121
|
-
|
|
55
|
+
Returns the reactor instance.
|
|
122
56
|
|
|
123
|
-
|
|
57
|
+
Usage
|
|
124
58
|
|
|
125
|
-
|
|
126
|
-
|
|
59
|
+
```jsx
|
|
60
|
+
import { useReactor } from "@powerhousedao/state";
|
|
127
61
|
|
|
128
|
-
|
|
129
|
-
|
|
62
|
+
function MyEditorComponent() {
|
|
63
|
+
const reactor = useReactor();
|
|
64
|
+
}
|
|
65
|
+
```
|
|
130
66
|
|
|
131
|
-
|
|
67
|
+
</details>
|
|
132
68
|
|
|
133
|
-
###
|
|
69
|
+
### Drives
|
|
134
70
|
|
|
135
|
-
|
|
136
|
-
|
|
71
|
+
<details>
|
|
72
|
+
<summary>useDrives</summary>
|
|
137
73
|
|
|
138
|
-
|
|
139
|
-
|
|
74
|
+
```ts
|
|
75
|
+
function useDrives(): DocumentDriveDocument[] | undefined;
|
|
76
|
+
```
|
|
140
77
|
|
|
141
|
-
|
|
78
|
+
Returns the drives for a reactor.
|
|
142
79
|
|
|
143
|
-
|
|
80
|
+
Usage
|
|
144
81
|
|
|
145
|
-
|
|
146
|
-
|
|
82
|
+
```jsx
|
|
83
|
+
import { useDrives } from "@powerhousedao/state";
|
|
147
84
|
|
|
148
|
-
|
|
149
|
-
|
|
85
|
+
function MyEditorComponent() {
|
|
86
|
+
const drives = useDrives();
|
|
87
|
+
}
|
|
88
|
+
```
|
|
150
89
|
|
|
151
|
-
|
|
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
|
-
|
|
95
|
+
```ts
|
|
96
|
+
function useDriveById(
|
|
97
|
+
id: string | null | undefined,
|
|
98
|
+
): DocumentDriveDocument | undefined;
|
|
99
|
+
```
|
|
161
100
|
|
|
162
|
-
|
|
101
|
+
Returns a drive by id.
|
|
163
102
|
|
|
164
|
-
|
|
103
|
+
Usage
|
|
165
104
|
|
|
166
|
-
|
|
105
|
+
```jsx
|
|
106
|
+
import { useDriveById } from "@powerhousedao/state";
|
|
167
107
|
|
|
168
|
-
|
|
108
|
+
function MyEditorComponent() {
|
|
109
|
+
const driveById = useDriveById("some-id");
|
|
110
|
+
}
|
|
111
|
+
```
|
|
169
112
|
|
|
170
|
-
|
|
113
|
+
</details>
|
|
171
114
|
|
|
172
|
-
|
|
115
|
+
<details>
|
|
116
|
+
<summary>useSelectedDrive</summary>
|
|
173
117
|
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
124
|
+
Usage
|
|
180
125
|
|
|
181
|
-
|
|
126
|
+
```jsx
|
|
127
|
+
import { useSelectedDrive } from "@powerhousedao/state";
|
|
182
128
|
|
|
183
|
-
|
|
129
|
+
function MyEditorComponent() {
|
|
130
|
+
const selectedDrive = useSelectedDrive();
|
|
131
|
+
}
|
|
132
|
+
```
|
|
184
133
|
|
|
185
|
-
|
|
134
|
+
</details>
|
|
186
135
|
|
|
187
|
-
|
|
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
|
-
|
|
201
|
+
</details>
|
|
190
202
|
|
|
191
|
-
|
|
203
|
+
### Documents
|
|
192
204
|
|
|
193
|
-
|
|
205
|
+
<details>
|
|
206
|
+
<summary>useAllDocuments/useSelectedDriveDocuments</summary>
|
|
194
207
|
|
|
195
|
-
|
|
208
|
+
```ts
|
|
209
|
+
function useAllDocuments(): PHDocument[] | undefined;
|
|
210
|
+
```
|
|
196
211
|
|
|
197
|
-
|
|
212
|
+
Returns all of the documents in the reactor.
|
|
198
213
|
|
|
199
|
-
|
|
214
|
+
```ts
|
|
215
|
+
function useSelectedDriveDocuments(): PHDocument[] | undefined;
|
|
216
|
+
```
|
|
200
217
|
|
|
201
|
-
|
|
218
|
+
Returns the documents in the reactor for the selected drive.
|
|
202
219
|
|
|
203
|
-
|
|
220
|
+
Usage
|
|
204
221
|
|
|
205
|
-
|
|
222
|
+
```jsx
|
|
223
|
+
import {
|
|
224
|
+
useAllDocuments,
|
|
225
|
+
useSelectedDriveDocuments,
|
|
226
|
+
} from "@powerhousedao/state";
|
|
206
227
|
|
|
207
|
-
|
|
228
|
+
function MyEditorComponent() {
|
|
229
|
+
const allDocuments = useAllDocuments();
|
|
230
|
+
const selectedDriveDocuments = useSelectedDriveDocuments();
|
|
231
|
+
}
|
|
232
|
+
```
|
|
208
233
|
|
|
209
|
-
|
|
234
|
+
</details>
|
|
210
235
|
|
|
211
|
-
|
|
236
|
+
<details>
|
|
237
|
+
<summary>useSelectedDocument</summary>
|
|
212
238
|
|
|
213
|
-
|
|
239
|
+
```ts
|
|
240
|
+
function useSelectedDocument(): PHDocument | undefined;
|
|
241
|
+
```
|
|
214
242
|
|
|
215
|
-
Returns the document
|
|
243
|
+
Returns the selected document. You can set the selected document with `setSelectedNode`.
|
|
216
244
|
|
|
217
|
-
|
|
245
|
+
Usage
|
|
218
246
|
|
|
219
|
-
|
|
247
|
+
```jsx
|
|
248
|
+
import { useSelectedDocument } from "@powerhousedao/state";
|
|
220
249
|
|
|
221
|
-
|
|
250
|
+
function MyEditorComponent() {
|
|
251
|
+
const selectedDocument = useSelectedDocument();
|
|
252
|
+
}
|
|
253
|
+
```
|
|
222
254
|
|
|
223
|
-
|
|
255
|
+
</details>
|
|
224
256
|
|
|
225
|
-
|
|
257
|
+
<details>
|
|
258
|
+
<summary>useDocumentById</summary>
|
|
226
259
|
|
|
227
|
-
|
|
260
|
+
```ts
|
|
261
|
+
function useDocumentById(id: string | null | undefined): PHDocument | undefined;
|
|
262
|
+
```
|
|
228
263
|
|
|
229
|
-
|
|
264
|
+
Returns a document by id.
|
|
230
265
|
|
|
231
|
-
|
|
266
|
+
Usage
|
|
232
267
|
|
|
233
|
-
|
|
268
|
+
```jsx
|
|
269
|
+
import { useDocumentById } from "@powerhousedao/state";
|
|
234
270
|
|
|
235
|
-
|
|
271
|
+
function MyEditorComponent() {
|
|
272
|
+
const myDocumentId = "some-document-id";
|
|
273
|
+
const documentById = useDocumentById(myDocumentId);
|
|
274
|
+
}
|
|
275
|
+
```
|
|
236
276
|
|
|
237
|
-
|
|
277
|
+
</details>
|
|
238
278
|
|
|
239
|
-
|
|
279
|
+
### Nodes
|
|
240
280
|
|
|
241
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
+
type FolderNode = {
|
|
299
|
+
id: string;
|
|
300
|
+
kind: string;
|
|
301
|
+
name: string;
|
|
302
|
+
parentFolder: string | null | undefined;
|
|
303
|
+
};
|
|
252
304
|
|
|
253
|
-
|
|
305
|
+
type Node = FileNode | FolderNode;
|
|
306
|
+
```
|
|
254
307
|
|
|
255
|
-
|
|
308
|
+
<details>
|
|
309
|
+
<summary>useNodes</summary>
|
|
256
310
|
|
|
257
|
-
|
|
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
|
-
|
|
313
|
+
```ts
|
|
314
|
+
function useNodes(): Node[] | undefined;
|
|
315
|
+
```
|
|
260
316
|
|
|
261
|
-
|
|
317
|
+
Returns the nodes for a drive.
|
|
262
318
|
|
|
263
|
-
|
|
319
|
+
Usage
|
|
264
320
|
|
|
265
|
-
|
|
321
|
+
```jsx
|
|
322
|
+
import { useNodes } from "@powerhousedao/state";
|
|
266
323
|
|
|
267
|
-
|
|
324
|
+
function MyEditorComponent() {
|
|
325
|
+
const nodes = useNodes();
|
|
326
|
+
}
|
|
327
|
+
```
|
|
268
328
|
|
|
269
|
-
|
|
329
|
+
</details>
|
|
270
330
|
|
|
271
|
-
|
|
331
|
+
<details>
|
|
332
|
+
<summary>useNodeById</summary>
|
|
272
333
|
|
|
273
|
-
|
|
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
|
-
|
|
342
|
+
```jsx
|
|
343
|
+
import { useNodeById } from "@powerhousedao/state";
|
|
282
344
|
|
|
283
|
-
|
|
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
|
-
|
|
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
|
-
|
|
358
|
+
```ts
|
|
359
|
+
function useSelectedFolder(): FolderNode | undefined;
|
|
360
|
+
```
|
|
292
361
|
|
|
293
|
-
|
|
362
|
+
Returns the selected folder. You can set the selected folder with `setSelectedNode`
|
|
294
363
|
|
|
295
|
-
|
|
364
|
+
Usage
|
|
296
365
|
|
|
297
|
-
|
|
366
|
+
```jsx
|
|
367
|
+
import { useSelectedFolder } from "@powerhousedao/state";
|
|
298
368
|
|
|
299
|
-
|
|
369
|
+
function MyEditorComponent() {
|
|
370
|
+
const selectedFolder = useSelectedFolder();
|
|
371
|
+
}
|
|
372
|
+
```
|
|
300
373
|
|
|
301
|
-
|
|
374
|
+
</details>
|
|
302
375
|
|
|
303
|
-
|
|
376
|
+
<details>
|
|
377
|
+
<summary>useSelectedNodePath</summary>
|
|
304
378
|
|
|
305
|
-
|
|
379
|
+
```ts
|
|
380
|
+
function useSelectedNodePath(): Node[];
|
|
381
|
+
```
|
|
306
382
|
|
|
307
|
-
|
|
383
|
+
Returns the path to the selected node. Useful for navigational components like breadcrumbs.
|
|
308
384
|
|
|
309
|
-
|
|
385
|
+
Usage
|
|
310
386
|
|
|
311
|
-
|
|
387
|
+
```jsx
|
|
388
|
+
import { useSelectedNodePath } from "@powerhousedao/state";
|
|
312
389
|
|
|
313
|
-
|
|
390
|
+
function MyEditorComponent() {
|
|
391
|
+
const nodes = useSelectedNodePath();
|
|
314
392
|
|
|
315
|
-
|
|
393
|
+
return <Breadcrumbs nodes={nodes} />;
|
|
394
|
+
}
|
|
395
|
+
```
|
|
316
396
|
|
|
317
|
-
|
|
397
|
+
</details>
|
|
318
398
|
|
|
319
|
-
|
|
399
|
+
<details>
|
|
400
|
+
<summary>useChildNodes/useFolderChildNodes/useFileChildNodes</summary>
|
|
320
401
|
|
|
321
|
-
|
|
402
|
+
```ts
|
|
403
|
+
function useChildNodes(): Node[];
|
|
404
|
+
```
|
|
322
405
|
|
|
323
|
-
Returns the selected
|
|
406
|
+
Returns the child nodes for the selected drive or folder.
|
|
324
407
|
|
|
325
|
-
|
|
408
|
+
```ts
|
|
409
|
+
function useFolderChildNodes(): FolderNode[];
|
|
410
|
+
```
|
|
326
411
|
|
|
327
|
-
Returns the
|
|
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
|
-
|
|
418
|
+
Returns the file (document) child nodes for the selected drive or folder.
|
|
332
419
|
|
|
333
|
-
|
|
420
|
+
Usage
|
|
334
421
|
|
|
335
|
-
|
|
422
|
+
```jsx
|
|
423
|
+
import {
|
|
424
|
+
useChildNodes,
|
|
425
|
+
useFolderChildNodes,
|
|
426
|
+
useFileChildNodes,
|
|
427
|
+
} from "@powerhousedao/state";
|
|
336
428
|
|
|
337
|
-
|
|
429
|
+
function MyEditorComponent() {
|
|
430
|
+
const nodes = useChildNodes();
|
|
431
|
+
const fileNodes = useFileChildNodes();
|
|
432
|
+
const folderNodes = useFolderChildNodes();
|
|
338
433
|
|
|
339
|
-
|
|
434
|
+
return (
|
|
435
|
+
<div>
|
|
436
|
+
<FilesAndFolders nodes={nodes} />
|
|
437
|
+
<Files fileNodes={fileNodes} />
|
|
438
|
+
<Folders folderNodes={folderNodes} />
|
|
439
|
+
</div>
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
```
|
|
340
443
|
|
|
341
|
-
|
|
444
|
+
</details>
|
|
342
445
|
|
|
343
|
-
|
|
446
|
+
<details>
|
|
447
|
+
<summary>useChildNodesForId/useFolderChildNodesForId/useFileChildNodesForId</summary>
|
|
344
448
|
|
|
345
|
-
|
|
449
|
+
```ts
|
|
450
|
+
function useChildNodesForId(id: string | null | undefined): Node[];
|
|
451
|
+
```
|
|
346
452
|
|
|
347
|
-
Returns the
|
|
453
|
+
Returns the child nodes for a drive or folder by id.
|
|
348
454
|
|
|
349
|
-
|
|
455
|
+
```ts
|
|
456
|
+
function useFolderChildNodesForId(id: string | null | undefined): FolderNode[];
|
|
457
|
+
```
|
|
350
458
|
|
|
351
|
-
Returns the
|
|
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
|
-
|
|
465
|
+
Returns the file (document) child nodes for a drive or folder by id.
|
|
356
466
|
|
|
357
|
-
|
|
467
|
+
Usage
|
|
358
468
|
|
|
359
|
-
|
|
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
|
-
|
|
482
|
+
return (
|
|
483
|
+
<div>
|
|
484
|
+
<FilesAndFolders nodes={nodes} />
|
|
485
|
+
<Files fileNodes={fileNodes} />
|
|
486
|
+
<Folders folderNodes={folderNodes} />
|
|
487
|
+
</div>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
```
|
|
364
491
|
|
|
365
|
-
|
|
492
|
+
</details>
|
|
366
493
|
|
|
367
|
-
|
|
494
|
+
<details>
|
|
495
|
+
<summary>useNodeName/useNodeKind</summary>
|
|
368
496
|
|
|
369
|
-
|
|
497
|
+
```ts
|
|
498
|
+
function useNodeName(id: string | null | undefined): string | undefined;
|
|
499
|
+
```
|
|
370
500
|
|
|
371
|
-
|
|
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
|
-
|
|
507
|
+
Returns the kind of a node.
|
|
376
508
|
|
|
377
|
-
|
|
509
|
+
Usage
|
|
378
510
|
|
|
379
|
-
|
|
511
|
+
```jsx
|
|
512
|
+
import { useNodeName, useNodeKind } from "@powerhousedao/state";
|
|
380
513
|
|
|
381
|
-
|
|
514
|
+
function MyEditorComponent() {
|
|
515
|
+
const nodeId = "some-node-id";
|
|
516
|
+
const nodeName = useNodeName(nodeId);
|
|
517
|
+
const nodeKind = useNodeKind(nodeId);
|
|
382
518
|
|
|
383
|
-
|
|
519
|
+
if (nodeKind === "file") {
|
|
520
|
+
return <File name={nodeName} />;
|
|
521
|
+
}
|
|
384
522
|
|
|
385
|
-
|
|
523
|
+
if (nodeKind === "folder") {
|
|
524
|
+
return <Folder name={nodeName} />;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
```
|
|
386
528
|
|
|
387
|
-
|
|
529
|
+
</details>
|
|
388
530
|
|
|
389
|
-
|
|
531
|
+
### Vetra Packages and Modules
|
|
390
532
|
|
|
391
|
-
|
|
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
|
-
|
|
535
|
+
These modules can be for:
|
|
394
536
|
|
|
395
|
-
|
|
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
|
-
|
|
545
|
+
<details>
|
|
546
|
+
<summary>useVetraPackages</summary>
|
|
400
547
|
|
|
401
|
-
|
|
548
|
+
```ts
|
|
549
|
+
function useVetraPackages(): VetraPackage[] | undefined;
|
|
550
|
+
```
|
|
402
551
|
|
|
403
|
-
Returns the
|
|
552
|
+
Returns all of the Vetra packages in your Connect app.
|
|
404
553
|
|
|
405
|
-
|
|
554
|
+
Usage
|
|
406
555
|
|
|
407
|
-
|
|
556
|
+
```jsx
|
|
557
|
+
import { useVetraPackages } from "@powerhousedao/state";
|
|
408
558
|
|
|
409
|
-
|
|
559
|
+
function MyEditorComponent() {
|
|
560
|
+
const vetraPackages = useVetraPackages();
|
|
561
|
+
}
|
|
562
|
+
```
|
|
410
563
|
|
|
411
|
-
|
|
564
|
+
</details>
|
|
412
565
|
|
|
413
|
-
|
|
566
|
+
<details>
|
|
567
|
+
<summary>useDocumentModelModules</summary>
|
|
414
568
|
|
|
415
|
-
|
|
569
|
+
```ts
|
|
570
|
+
function useDocumentModelModules(): DocumentModelModule[] | undefined;
|
|
571
|
+
```
|
|
416
572
|
|
|
417
|
-
|
|
573
|
+
Returns the document model modules from your Vetra packages.
|
|
418
574
|
|
|
419
|
-
|
|
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
|
-
|
|
424
|
-
|
|
577
|
+
```jsx
|
|
578
|
+
import { useDocumentModelModules } from "@powerhousedao/state";
|
|
425
579
|
|
|
426
|
-
|
|
427
|
-
|
|
580
|
+
function MyEditorComponent() {
|
|
581
|
+
const documentModelModules = useDocumentModelModules();
|
|
582
|
+
}
|
|
583
|
+
```
|
|
428
584
|
|
|
429
|
-
|
|
585
|
+
</details>
|
|
430
586
|
|
|
431
|
-
|
|
587
|
+
<details>
|
|
588
|
+
<summary>useDocumentModelModuleById</summary>
|
|
432
589
|
|
|
433
|
-
|
|
590
|
+
```ts
|
|
591
|
+
function useDocumentModelModuleById(): DocumentModelModule[] | undefined;
|
|
592
|
+
```
|
|
434
593
|
|
|
435
|
-
|
|
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
|
-
|
|
598
|
+
Usage
|
|
438
599
|
|
|
439
|
-
|
|
600
|
+
```jsx
|
|
601
|
+
import { useDocumentModelModuleById } from "@powerhousedao/state";
|
|
440
602
|
|
|
441
|
-
|
|
603
|
+
function MyEditorComponent() {
|
|
604
|
+
const documentType = "my-org/my-document";
|
|
605
|
+
const documentModelModuleById = useDocumentModelModuleById(documentType);
|
|
606
|
+
}
|
|
607
|
+
```
|
|
442
608
|
|
|
443
|
-
|
|
609
|
+
</details>
|
|
444
610
|
|
|
445
|
-
|
|
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
|
-
|
|
620
|
+
Usage
|
|
451
621
|
|
|
452
|
-
|
|
622
|
+
```jsx
|
|
623
|
+
import { useEditorModules } from "@powerhousedao/state";
|
|
453
624
|
|
|
454
|
-
|
|
625
|
+
function MyEditorComponent() {
|
|
626
|
+
const editorModules = useEditorModules();
|
|
627
|
+
}
|
|
628
|
+
```
|
|
455
629
|
|
|
456
|
-
|
|
630
|
+
</details>
|
|
457
631
|
|
|
458
|
-
|
|
632
|
+
<details>
|
|
633
|
+
<summary>useDriveEditorModules</summary>
|
|
459
634
|
|
|
460
|
-
|
|
635
|
+
```ts
|
|
636
|
+
function useDriveEditorModules(): DriveEditorModule[] | undefined;
|
|
637
|
+
```
|
|
461
638
|
|
|
462
|
-
|
|
639
|
+
Returns the drive editor modules from your Vetra packages.
|
|
463
640
|
|
|
464
|
-
|
|
641
|
+
Usage
|
|
465
642
|
|
|
466
|
-
|
|
643
|
+
```jsx
|
|
644
|
+
import { useDriveEditorModules } from "@powerhousedao/state";
|
|
467
645
|
|
|
468
|
-
|
|
646
|
+
function MyDriveEditorComponent() {
|
|
647
|
+
const driveEditorModules = useDriveEditorModules();
|
|
648
|
+
}
|
|
649
|
+
```
|
|
469
650
|
|
|
470
|
-
|
|
651
|
+
</details>
|
|
471
652
|
|
|
472
|
-
|
|
653
|
+
<details>
|
|
654
|
+
<summary>useProcessorModules</summary>
|
|
473
655
|
|
|
474
|
-
|
|
656
|
+
```ts
|
|
657
|
+
function useProcessorModules(): ProcessorModule[] | undefined;
|
|
658
|
+
```
|
|
475
659
|
|
|
476
|
-
|
|
660
|
+
Returns the processor modules from your Vetra packages.
|
|
477
661
|
|
|
478
|
-
|
|
662
|
+
Usage
|
|
479
663
|
|
|
480
|
-
|
|
664
|
+
```jsx
|
|
665
|
+
import { useProcessorModules } from "@powerhousedao/state";
|
|
481
666
|
|
|
482
|
-
|
|
667
|
+
function MyProcessorComponent() {
|
|
668
|
+
const processorModules = useProcessorModules();
|
|
669
|
+
}
|
|
670
|
+
```
|
|
483
671
|
|
|
484
|
-
|
|
672
|
+
</details>
|
|
485
673
|
|
|
486
|
-
|
|
674
|
+
<details>
|
|
675
|
+
<summary>useSubgraphModules</summary>
|
|
487
676
|
|
|
488
|
-
|
|
677
|
+
```ts
|
|
678
|
+
function useSubgraphModules(): SubgraphModule[] | undefined;
|
|
679
|
+
```
|
|
489
680
|
|
|
490
|
-
|
|
681
|
+
Returns the subgraph modules from your Vetra packages.
|
|
491
682
|
|
|
492
|
-
|
|
683
|
+
Usage
|
|
493
684
|
|
|
494
|
-
|
|
685
|
+
```jsx
|
|
686
|
+
import { useSubgraphModules } from "@powerhousedao/state";
|
|
495
687
|
|
|
496
|
-
|
|
688
|
+
function MySubgraphComponent() {
|
|
689
|
+
const subgraphModules = useSubgraphModules();
|
|
690
|
+
}
|
|
691
|
+
```
|
|
497
692
|
|
|
498
|
-
|
|
693
|
+
</details>
|
|
499
694
|
|
|
500
|
-
|
|
695
|
+
<details>
|
|
696
|
+
<summary>useImportScriptModules</summary>
|
|
501
697
|
|
|
502
|
-
|
|
698
|
+
```ts
|
|
699
|
+
function useImportScriptModules(): ImportScriptModule[] | undefined;
|
|
700
|
+
```
|
|
503
701
|
|
|
504
|
-
|
|
702
|
+
Returns the import script modules from your Vetra packages.
|
|
505
703
|
|
|
506
|
-
|
|
704
|
+
Usage
|
|
507
705
|
|
|
508
|
-
|
|
706
|
+
```jsx
|
|
707
|
+
import { useImportScriptModules } from "@powerhousedao/state";
|
|
509
708
|
|
|
510
|
-
|
|
709
|
+
function MyImportScriptComponent() {
|
|
710
|
+
const importScriptModules = useImportScriptModules();
|
|
711
|
+
}
|
|
712
|
+
```
|
|
511
713
|
|
|
512
|
-
|
|
714
|
+
</details>
|
|
513
715
|
|
|
514
|
-
|
|
716
|
+
## More documentation coming soon!
|
|
515
717
|
|
|
516
|
-
|
|
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
|
-
|
|
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
|
-
|
|
722
|
+
### Core Hooks & Patterns
|
|
521
723
|
|
|
522
|
-
|
|
724
|
+
- useDocumentField
|
|
725
|
+
- useReadDocumentField
|
|
726
|
+
- useUpdateDocumentField
|
|
727
|
+
- useDocumentDispatch(docId): updateX, delete, ...
|
|
523
728
|
|
|
524
|
-
|
|
729
|
+
### Global Drive Access
|
|
525
730
|
|
|
526
|
-
|
|
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
|
-
|
|
735
|
+
### Convenience APIs
|
|
529
736
|
|
|
530
|
-
|
|
737
|
+
- Utility functions like getDispatchFunctions(docId)
|
|
738
|
+
- "Quick Start" to manipulate any document like a pro
|
|
531
739
|
|
|
532
|
-
###
|
|
740
|
+
### Working with Context
|
|
533
741
|
|
|
534
|
-
|
|
742
|
+
- DriveContext: what lives there, how to use it
|
|
743
|
+
- Example: using context to get current doc, sibling docs
|
|
535
744
|
|
|
536
|
-
|
|
745
|
+
### Best Practices & Patterns
|
|
537
746
|
|
|
538
|
-
|
|
747
|
+
- When to use useDocumentField vs getDispatch
|
|
748
|
+
- Composing document fields into custom logic
|