@powerhousedao/reactor-browser 5.1.0 → 5.2.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.
- package/README.md +282 -482
- package/dist/src/actions/dispatch.d.ts +16 -2
- package/dist/src/actions/dispatch.d.ts.map +1 -1
- package/dist/src/actions/dispatch.js +17 -2
- package/dist/src/actions/dispatch.js.map +1 -1
- package/dist/src/actions/document.d.ts +7 -4
- package/dist/src/actions/document.d.ts.map +1 -1
- package/dist/src/actions/document.js +297 -123
- package/dist/src/actions/document.js.map +1 -1
- package/dist/src/actions/drive.d.ts +2 -2
- package/dist/src/actions/drive.d.ts.map +1 -1
- package/dist/src/actions/drive.js +153 -50
- package/dist/src/actions/drive.js.map +1 -1
- package/dist/src/actions/queue.d.ts.map +1 -1
- package/dist/src/actions/queue.js +48 -24
- package/dist/src/actions/queue.js.map +1 -1
- package/dist/src/actions/sign.js +1 -1
- package/dist/src/actions/sign.js.map +1 -1
- package/dist/src/hooks/add-ph-event-handlers.d.ts.map +1 -1
- package/dist/src/hooks/add-ph-event-handlers.js +9 -2
- package/dist/src/hooks/add-ph-event-handlers.js.map +1 -1
- package/dist/src/hooks/config/connect.d.ts +2 -2
- package/dist/src/hooks/connect.d.ts +1 -1
- package/dist/src/hooks/connect.d.ts.map +1 -1
- package/dist/src/hooks/connect.js +1 -1
- package/dist/src/hooks/connect.js.map +1 -1
- package/dist/src/hooks/crypto.d.ts +7 -1
- package/dist/src/hooks/crypto.d.ts.map +1 -1
- package/dist/src/hooks/crypto.js +7 -1
- package/dist/src/hooks/crypto.js.map +1 -1
- package/dist/src/hooks/dispatch.d.ts +7 -2
- package/dist/src/hooks/dispatch.d.ts.map +1 -1
- package/dist/src/hooks/dispatch.js +13 -3
- package/dist/src/hooks/dispatch.js.map +1 -1
- package/dist/src/hooks/document-by-id.d.ts +1 -1
- package/dist/src/hooks/document-by-id.d.ts.map +1 -1
- package/dist/src/hooks/features.d.ts +5 -0
- package/dist/src/hooks/features.d.ts.map +1 -0
- package/dist/src/hooks/features.js +6 -0
- package/dist/src/hooks/features.js.map +1 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/reactor.d.ts +39 -6
- package/dist/src/hooks/reactor.d.ts.map +1 -1
- package/dist/src/hooks/reactor.js +41 -6
- package/dist/src/hooks/reactor.js.map +1 -1
- package/dist/src/hooks/renown.d.ts +3 -2
- package/dist/src/hooks/renown.d.ts.map +1 -1
- package/dist/src/hooks/renown.js.map +1 -1
- package/dist/src/hooks/selected-document.d.ts +1 -1
- package/dist/src/hooks/selected-document.d.ts.map +1 -1
- package/dist/src/hooks/selected-drive.d.ts.map +1 -1
- package/dist/src/hooks/selected-drive.js +3 -3
- package/dist/src/hooks/selected-drive.js.map +1 -1
- package/dist/src/hooks/selected-node.d.ts.map +1 -1
- package/dist/src/hooks/selected-node.js +3 -3
- package/dist/src/hooks/selected-node.js.map +1 -1
- package/dist/src/hooks/use-feature-flags.d.ts +44 -0
- package/dist/src/hooks/use-feature-flags.d.ts.map +1 -0
- package/dist/src/hooks/use-feature-flags.js +65 -0
- package/dist/src/hooks/use-feature-flags.js.map +1 -0
- package/dist/src/hooks/user.d.ts +7 -1
- package/dist/src/hooks/user.d.ts.map +1 -1
- package/dist/src/hooks/user.js +7 -1
- package/dist/src/hooks/user.js.map +1 -1
- package/dist/src/hooks/vetra-packages.js +1 -1
- package/dist/src/hooks/vetra-packages.js.map +1 -1
- package/dist/src/pglite/drop.d.ts +3 -0
- package/dist/src/pglite/drop.d.ts.map +1 -0
- package/dist/src/pglite/drop.js +18 -0
- package/dist/src/pglite/drop.js.map +1 -0
- package/dist/src/pglite/index.d.ts +1 -0
- package/dist/src/pglite/index.d.ts.map +1 -1
- package/dist/src/pglite/index.js +1 -0
- package/dist/src/pglite/index.js.map +1 -1
- package/dist/src/reactor.d.ts +5 -3
- package/dist/src/reactor.d.ts.map +1 -1
- package/dist/src/reactor.js +36 -5
- package/dist/src/reactor.js.map +1 -1
- package/dist/src/renown/constants.d.ts +1 -1
- package/dist/src/renown/constants.d.ts.map +1 -1
- package/dist/src/renown/constants.js +1 -1
- package/dist/src/renown/constants.js.map +1 -1
- package/dist/src/renown/utils.d.ts +2 -2
- package/dist/src/renown/utils.d.ts.map +1 -1
- package/dist/src/renown/utils.js +1 -1
- package/dist/src/renown/utils.js.map +1 -1
- package/dist/src/types/documents.d.ts +1 -1
- package/dist/src/types/documents.d.ts.map +1 -1
- package/dist/src/types/global.d.ts +13 -1
- package/dist/src/types/global.d.ts.map +1 -1
- package/dist/src/types/modals.d.ts +2 -0
- package/dist/src/types/modals.d.ts.map +1 -1
- package/dist/src/utils/drives.d.ts.map +1 -1
- package/dist/src/utils/drives.js +41 -24
- package/dist/src/utils/drives.js.map +1 -1
- package/dist/src/utils/url.d.ts +4 -0
- package/dist/src/utils/url.d.ts.map +1 -1
- package/dist/src/utils/url.js +7 -0
- package/dist/src/utils/url.js.map +1 -1
- package/dist/test/drop.test.d.ts +2 -0
- package/dist/test/drop.test.d.ts.map +1 -0
- package/dist/test/drop.test.js +88 -0
- package/dist/test/drop.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -5
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { Action, PHDocument } from "document-model";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Dispatches actions to a document.
|
|
4
|
+
* @param actionOrActions - The action or actions to dispatch.
|
|
5
|
+
* @param document - The document to dispatch actions to.
|
|
6
|
+
* @param onErrors - Callback invoked with any errors that occurred during action execution.
|
|
7
|
+
* @returns The updated document, or undefined if the dispatch failed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dispatchActions<TDocument = PHDocument, TAction = Action>(actionOrActions: TAction[] | TAction | undefined, document: TDocument | undefined, onErrors?: (errors: Error[]) => void): Promise<PHDocument | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Dispatches actions to a document.
|
|
12
|
+
* @param actionOrActions - The action or actions to dispatch.
|
|
13
|
+
* @param documentId - The ID of the document to dispatch actions to.
|
|
14
|
+
* @param onErrors - Callback invoked with any errors that occurred during action execution.
|
|
15
|
+
* @returns The updated document, or undefined if the dispatch failed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function dispatchActions(actionOrActions: Action[] | Action | undefined, documentId: string, onErrors?: (errors: Error[]) => void): Promise<PHDocument | undefined>;
|
|
4
18
|
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/actions/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/actions/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA4BzD;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,SAAS,GAAG,UAAU,EAAE,OAAO,GAAG,MAAM,EAC5E,eAAe,EAAE,OAAO,EAAE,GAAG,OAAO,GAAG,SAAS,EAChD,QAAQ,EAAE,SAAS,GAAG,SAAS,EAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,GACnC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;AACnC;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,GACnC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC"}
|
|
@@ -3,14 +3,23 @@ import { queueActions } from "./queue.js";
|
|
|
3
3
|
import { makeSignedActionsWithContext } from "./sign.js";
|
|
4
4
|
async function getDocument(documentId) {
|
|
5
5
|
try {
|
|
6
|
-
return await window.ph?.
|
|
6
|
+
return await window.ph?.legacyReactor?.getDocument(documentId);
|
|
7
7
|
}
|
|
8
8
|
catch (error) {
|
|
9
9
|
logger.debug(`Failed to get document with id ${documentId}:`, error);
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
function getActionErrors(result, actions) {
|
|
14
|
+
return actions.reduce((errors, a) => {
|
|
15
|
+
const op = result.operations[a.scope].findLast((op) => op.action.id === a.id);
|
|
16
|
+
if (op?.error) {
|
|
17
|
+
errors.push(new Error(op.error));
|
|
18
|
+
}
|
|
19
|
+
return errors;
|
|
20
|
+
}, new Array());
|
|
21
|
+
}
|
|
22
|
+
export async function dispatchActions(actionOrActions, documentOrDocumentId, onErrors) {
|
|
14
23
|
const document = typeof documentOrDocumentId === "string"
|
|
15
24
|
? await getDocument(documentOrDocumentId)
|
|
16
25
|
: documentOrDocumentId;
|
|
@@ -24,6 +33,12 @@ export async function dispatchActions(actionOrActions, documentOrDocumentId) {
|
|
|
24
33
|
return;
|
|
25
34
|
}
|
|
26
35
|
const result = await queueActions(document, signedActionsWithContext);
|
|
36
|
+
if (onErrors && result) {
|
|
37
|
+
const errors = getActionErrors(result, signedActionsWithContext);
|
|
38
|
+
if (errors.length) {
|
|
39
|
+
onErrors(errors);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
return result;
|
|
28
43
|
}
|
|
29
44
|
//# sourceMappingURL=dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/actions/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEzD,KAAK,UAAU,WAAW,CACxB,UAAkB;IAElB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/actions/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEzD,KAAK,UAAU,WAAW,CACxB,UAAkB;IAElB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;QACrE,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAkB,EAAE,OAAiB;IAC5D,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAClC,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAC5C,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAC9B,CAAC;QAEF,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,IAAI,KAAK,EAAS,CAAC,CAAC;AACzB,CAAC;AA0BD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,eAA8C,EAC9C,oBAAqD,EACrD,QAAoC;IAEpC,MAAM,QAAQ,GACZ,OAAO,oBAAoB,KAAK,QAAQ;QACtC,CAAC,CAAC,MAAM,WAAW,CAAC,oBAAoB,CAAC;QACzC,CAAC,CAAC,oBAAoB,CAAC;IAE3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,CAAC,KAAK,CACV,oBAAoB,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,YAAY,CACrE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,wBAAwB,GAAG,MAAM,4BAA4B,CACjE,eAAe,EACf,QAAQ,CACT,CAAC;IACF,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;IAEtE,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,14 +3,17 @@ import type { Node } from "document-drive";
|
|
|
3
3
|
import type { PHDocument } from "document-model";
|
|
4
4
|
export declare function downloadFile(document: PHDocument, fileName: string): void;
|
|
5
5
|
export declare function exportFile(document: PHDocument, suggestedName?: string): Promise<void | FileSystemFileHandle>;
|
|
6
|
-
export declare function loadFile(path: string | File): Promise<PHDocument<import("document-model").PHBaseState
|
|
7
|
-
export declare function addDocument(driveId: string, name: string, documentType: string, parentFolder?: string, document?: PHDocument, id?: string, preferredEditor?: string): Promise<import("document-drive").FileNode
|
|
6
|
+
export declare function loadFile(path: string | File): Promise<PHDocument<import("document-model").PHBaseState>>;
|
|
7
|
+
export declare function addDocument(driveId: string, name: string, documentType: string, parentFolder?: string, document?: PHDocument, id?: string, preferredEditor?: string): Promise<import("document-drive").FileNode>;
|
|
8
8
|
export declare function addFile(file: string | File, driveId: string, name?: string, parentFolder?: string): Promise<void>;
|
|
9
9
|
export declare function addFileWithProgress(file: string | File, driveId: string, name?: string, parentFolder?: string, onProgress?: FileUploadProgressCallback, documentTypes?: string[], resolveConflict?: ConflictResolution): Promise<import("document-drive").FileNode | undefined>;
|
|
10
10
|
export declare function updateFile(driveId: string, nodeId: string, documentType?: string, name?: string, parentFolder?: string): Promise<import("document-drive").FileNode | undefined>;
|
|
11
|
-
export declare function addFolder(driveId: string, name: string, parentFolder?: string): Promise<
|
|
11
|
+
export declare function addFolder(driveId: string, name: string, parentFolder?: string): Promise<Node>;
|
|
12
12
|
export declare function deleteNode(driveId: string, nodeId: string): Promise<void>;
|
|
13
13
|
export declare function renameNode(driveId: string, nodeId: string, name: string): Promise<Node | undefined>;
|
|
14
|
-
export declare function moveNode(driveId: string, src: Node, target: Node | undefined): Promise<PHDocument |
|
|
14
|
+
export declare function moveNode(driveId: string, src: Node, target: Node | undefined): Promise<PHDocument | {
|
|
15
|
+
source: PHDocument;
|
|
16
|
+
target: PHDocument;
|
|
17
|
+
} | undefined>;
|
|
15
18
|
export declare function copyNode(driveId: string, src: Node, target: Node | undefined): Promise<PHDocument | undefined>;
|
|
16
19
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/actions/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAElB,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAGV,IAAI,EACL,MAAM,gBAAgB,CAAC;AAexB,OAAO,KAAK,EAGV,UAAU,EACX,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/actions/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAElB,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAGV,IAAI,EACL,MAAM,gBAAgB,CAAC;AAexB,OAAO,KAAK,EAGV,UAAU,EACX,MAAM,gBAAgB,CAAC;AAuJxB,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,QAgBlE;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,MAAM,wCAyC5E;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,6DA2CjD;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,UAAU,EACrB,EAAE,CAAC,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,MAAM,8CAsFzB;AAED,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,iBA8GtB;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,0BAA0B,EACvC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,0DAuKrC;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,0DA6BtB;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,iBA8DtB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAsB/D;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CA2C3B;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,IAAI,GAAG,SAAS;;;eAmCzB;AA4BD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,IAAI,GAAG,SAAS,mCA2EzB"}
|
|
@@ -2,39 +2,73 @@ import { addFile as baseAddFile, addFolder as baseAddFolder, copyNode as baseCop
|
|
|
2
2
|
import { documentModelDocumentType } from "document-model";
|
|
3
3
|
import { baseLoadFromInput, baseSaveToFileHandle, createPresignedHeader, createZip, generateId, replayDocument, } from "document-model/core";
|
|
4
4
|
import { UnsupportedDocumentTypeError } from "../errors.js";
|
|
5
|
+
import { isLegacyReadEnabledSync, isLegacyWriteEnabledSync, } from "../hooks/use-feature-flags.js";
|
|
5
6
|
import { isDocumentTypeSupported } from "../utils/documents.js";
|
|
6
7
|
import { getUserPermissions } from "../utils/user.js";
|
|
7
8
|
import { queueActions, queueOperations, uploadOperations } from "./queue.js";
|
|
8
9
|
async function isDocumentInLocation(document, driveId, parentFolder) {
|
|
9
|
-
const
|
|
10
|
-
if (!reactor) {
|
|
11
|
-
return { isDuplicate: false };
|
|
12
|
-
}
|
|
10
|
+
const useLegacy = isLegacyReadEnabledSync();
|
|
13
11
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
if (useLegacy) {
|
|
13
|
+
const reactor = window.ph?.legacyReactor;
|
|
14
|
+
if (!reactor) {
|
|
15
|
+
throw new Error("Legacy reactor not initialized");
|
|
16
|
+
}
|
|
17
|
+
// Get the drive and check its nodes
|
|
18
|
+
const drive = await reactor.getDrive(driveId);
|
|
19
|
+
// Case 1: Check for duplicate by ID
|
|
20
|
+
const nodeById = drive.state.global.nodes.find((node) => node.id === document.header.id);
|
|
21
|
+
if (nodeById && nodeById.parentFolder === (parentFolder ?? null)) {
|
|
22
|
+
return {
|
|
23
|
+
isDuplicate: true,
|
|
24
|
+
duplicateType: "id",
|
|
25
|
+
nodeId: nodeById.id,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Case 2: Check for duplicate by name + type in same parent folder
|
|
29
|
+
const nodeByNameAndType = drive.state.global.nodes.find((node) => isFileNode(node) &&
|
|
30
|
+
node.name === document.header.name &&
|
|
31
|
+
node.documentType === document.header.documentType &&
|
|
32
|
+
node.parentFolder === (parentFolder ?? null));
|
|
33
|
+
if (nodeByNameAndType) {
|
|
34
|
+
return {
|
|
35
|
+
isDuplicate: true,
|
|
36
|
+
duplicateType: "name",
|
|
37
|
+
nodeId: nodeByNameAndType.id,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return { isDuplicate: false };
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const reactorClient = window.ph?.reactorClient;
|
|
44
|
+
if (!reactorClient) {
|
|
45
|
+
throw new Error("ReactorClient not initialized");
|
|
46
|
+
}
|
|
47
|
+
// Get the drive and check its nodes
|
|
48
|
+
const { document: drive } = await reactorClient.get(driveId);
|
|
49
|
+
// Case 1: Check for duplicate by ID
|
|
50
|
+
const nodeById = drive.state.global.nodes.find((node) => node.id === document.header.id);
|
|
51
|
+
if (nodeById && nodeById.parentFolder === (parentFolder ?? null)) {
|
|
52
|
+
return {
|
|
53
|
+
isDuplicate: true,
|
|
54
|
+
duplicateType: "id",
|
|
55
|
+
nodeId: nodeById.id,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Case 2: Check for duplicate by name + type in same parent folder
|
|
59
|
+
const nodeByNameAndType = drive.state.global.nodes.find((node) => isFileNode(node) &&
|
|
60
|
+
node.name === document.header.name &&
|
|
61
|
+
node.documentType === document.header.documentType &&
|
|
62
|
+
node.parentFolder === (parentFolder ?? null));
|
|
63
|
+
if (nodeByNameAndType) {
|
|
64
|
+
return {
|
|
65
|
+
isDuplicate: true,
|
|
66
|
+
duplicateType: "name",
|
|
67
|
+
nodeId: nodeByNameAndType.id,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { isDuplicate: false };
|
|
36
71
|
}
|
|
37
|
-
return { isDuplicate: false };
|
|
38
72
|
}
|
|
39
73
|
catch {
|
|
40
74
|
// Drive doesn't exist or other error
|
|
@@ -87,9 +121,17 @@ export function downloadFile(document, fileName) {
|
|
|
87
121
|
.catch(logger.error);
|
|
88
122
|
}
|
|
89
123
|
export async function exportFile(document, suggestedName) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
// Ensure we have either reactor available for consistency
|
|
125
|
+
const useLegacy = isLegacyReadEnabledSync();
|
|
126
|
+
if (useLegacy) {
|
|
127
|
+
if (!window.ph?.legacyReactor) {
|
|
128
|
+
throw new Error("Legacy reactor not initialized");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
if (!window.ph?.reactorClient) {
|
|
133
|
+
throw new Error("ReactorClient not initialized");
|
|
134
|
+
}
|
|
93
135
|
}
|
|
94
136
|
let extension = "";
|
|
95
137
|
if (document.header.documentType === documentModelDocumentType) {
|
|
@@ -118,81 +160,147 @@ export async function exportFile(document, suggestedName) {
|
|
|
118
160
|
}
|
|
119
161
|
}
|
|
120
162
|
export async function loadFile(path) {
|
|
121
|
-
const
|
|
122
|
-
if (!reactor) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const documentModelModules = reactor.getDocumentModelModules();
|
|
163
|
+
const useLegacy = isLegacyReadEnabledSync();
|
|
126
164
|
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
165
|
+
if (useLegacy) {
|
|
166
|
+
const reactor = window.ph?.legacyReactor;
|
|
167
|
+
if (!reactor) {
|
|
168
|
+
throw new Error("Legacy reactor not initialized");
|
|
169
|
+
}
|
|
170
|
+
const documentModelModules = reactor.getDocumentModelModules();
|
|
171
|
+
const documentModelModule = documentModelModules.find((module) => module.documentModel.global.id === baseDocument.header.documentType);
|
|
172
|
+
if (!documentModelModule) {
|
|
173
|
+
throw new Error(`Document "${baseDocument.header.documentType}" is not supported`);
|
|
174
|
+
}
|
|
175
|
+
return documentModelModule.utils.loadFromInput(path);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const reactorClient = window.ph?.reactorClient;
|
|
179
|
+
if (!reactorClient) {
|
|
180
|
+
throw new Error("ReactorClient not initialized");
|
|
181
|
+
}
|
|
182
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModels();
|
|
183
|
+
const documentModelModule = documentModelModules.find((module) => module.documentModel.global.id === baseDocument.header.documentType);
|
|
184
|
+
if (!documentModelModule) {
|
|
185
|
+
throw new Error(`Document "${baseDocument.header.documentType}" is not supported`);
|
|
186
|
+
}
|
|
187
|
+
return documentModelModule.utils.loadFromInput(path);
|
|
130
188
|
}
|
|
131
|
-
return documentModelModule.utils.loadFromInput(path);
|
|
132
189
|
}
|
|
133
190
|
export async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
|
|
134
|
-
const reactor = window.ph?.reactor;
|
|
135
|
-
if (!reactor) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
191
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
139
192
|
if (!isAllowedToCreateDocuments) {
|
|
140
193
|
throw new Error("User is not allowed to create documents");
|
|
141
194
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
195
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
196
|
+
if (useLegacy) {
|
|
197
|
+
const reactor = window.ph?.legacyReactor;
|
|
198
|
+
if (!reactor) {
|
|
199
|
+
throw new Error("Legacy reactor not initialized");
|
|
200
|
+
}
|
|
201
|
+
const drive = await reactor.getDrive(driveId);
|
|
202
|
+
const documentId = id ?? generateId();
|
|
203
|
+
const reactorDocumentModelModules = reactor.getDocumentModelModules();
|
|
204
|
+
const documentModelModuleFromReactor = reactorDocumentModelModules.find((module) => module.documentModel.global.id === documentType);
|
|
205
|
+
if (!documentModelModuleFromReactor) {
|
|
206
|
+
throw new Error(`Document model module for type ${documentType} not found`);
|
|
207
|
+
}
|
|
208
|
+
const newDocument = documentModelModuleFromReactor.utils.createDocument({
|
|
209
|
+
...document?.state,
|
|
210
|
+
});
|
|
211
|
+
newDocument.header = createPresignedHeader(documentId, documentType);
|
|
212
|
+
newDocument.header.name = name;
|
|
213
|
+
const documentMeta = preferredEditor ? { preferredEditor } : undefined;
|
|
214
|
+
await reactor.addDocument(newDocument, documentMeta);
|
|
215
|
+
const action = baseAddFile({
|
|
216
|
+
id: documentId,
|
|
217
|
+
name,
|
|
218
|
+
documentType,
|
|
219
|
+
parentFolder: parentFolder ?? null,
|
|
220
|
+
});
|
|
221
|
+
const unsafeCastAsDrive = (await queueActions(drive, action));
|
|
222
|
+
const node = unsafeCastAsDrive.state.global.nodes.find((node) => node.id === documentId);
|
|
223
|
+
if (!node || !isFileNode(node)) {
|
|
224
|
+
throw new Error("There was an error adding document");
|
|
225
|
+
}
|
|
226
|
+
return node;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const reactorClient = window.ph?.reactorClient;
|
|
230
|
+
if (!reactorClient) {
|
|
231
|
+
throw new Error("ReactorClient not initialized");
|
|
232
|
+
}
|
|
233
|
+
// Create document using ReactorClient
|
|
234
|
+
const newDoc = await reactorClient.createEmpty(documentType, driveId);
|
|
235
|
+
// Rename if name provided
|
|
236
|
+
if (name) {
|
|
237
|
+
await reactorClient.rename(newDoc.header.id, name);
|
|
238
|
+
}
|
|
239
|
+
// If parentFolder specified, we need to move the document into that folder
|
|
240
|
+
// The document is already a child of driveId, but needs to be in parentFolder
|
|
241
|
+
if (parentFolder) {
|
|
242
|
+
await reactorClient.moveChildren(driveId, parentFolder, [
|
|
243
|
+
newDoc.header.id,
|
|
244
|
+
]);
|
|
245
|
+
}
|
|
246
|
+
// Return a file node structure for compatibility
|
|
247
|
+
return {
|
|
248
|
+
id: newDoc.header.id,
|
|
249
|
+
name: name || newDoc.header.name,
|
|
250
|
+
documentType,
|
|
251
|
+
parentFolder: parentFolder ?? null,
|
|
252
|
+
kind: "file",
|
|
253
|
+
};
|
|
166
254
|
}
|
|
167
|
-
return node;
|
|
168
255
|
}
|
|
169
256
|
export async function addFile(file, driveId, name, parentFolder) {
|
|
170
257
|
logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
171
|
-
const reactor = window.ph?.reactor;
|
|
172
|
-
if (!reactor) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
258
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
176
259
|
if (!isAllowedToCreateDocuments) {
|
|
177
260
|
throw new Error("User is not allowed to create files");
|
|
178
261
|
}
|
|
262
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
179
263
|
const document = await loadFile(file);
|
|
180
264
|
if (!document) {
|
|
181
265
|
throw new Error("No document loaded");
|
|
182
266
|
}
|
|
183
|
-
const documentModule = reactor
|
|
184
|
-
.getDocumentModelModules()
|
|
185
|
-
.find((module) => module.documentModel.global.id === document.header.documentType);
|
|
186
|
-
if (!documentModule) {
|
|
187
|
-
throw new Error(`Document model module for type ${document.header.documentType} not found`);
|
|
188
|
-
}
|
|
189
267
|
let duplicateId = false;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
268
|
+
if (useLegacy) {
|
|
269
|
+
const reactor = window.ph?.legacyReactor;
|
|
270
|
+
if (!reactor) {
|
|
271
|
+
throw new Error("Legacy reactor not initialized");
|
|
272
|
+
}
|
|
273
|
+
const documentModule = reactor
|
|
274
|
+
.getDocumentModelModules()
|
|
275
|
+
.find((module) => module.documentModel.global.id === document.header.documentType);
|
|
276
|
+
if (!documentModule) {
|
|
277
|
+
throw new Error(`Document model module for type ${document.header.documentType} not found`);
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
await reactor.getDocument(document.header.id);
|
|
281
|
+
duplicateId = true;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// document id not found
|
|
285
|
+
}
|
|
193
286
|
}
|
|
194
|
-
|
|
195
|
-
|
|
287
|
+
else {
|
|
288
|
+
const reactorClient = window.ph?.reactorClient;
|
|
289
|
+
if (!reactorClient) {
|
|
290
|
+
throw new Error("ReactorClient not initialized");
|
|
291
|
+
}
|
|
292
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModels();
|
|
293
|
+
const documentModule = documentModelModules.find((module) => module.documentModel.global.id === document.header.documentType);
|
|
294
|
+
if (!documentModule) {
|
|
295
|
+
throw new Error(`Document model module for type ${document.header.documentType} not found`);
|
|
296
|
+
}
|
|
297
|
+
try {
|
|
298
|
+
await reactorClient.get(document.header.id);
|
|
299
|
+
duplicateId = true;
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// document id not found
|
|
303
|
+
}
|
|
196
304
|
}
|
|
197
305
|
const documentId = duplicateId ? generateId() : document.header.id;
|
|
198
306
|
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
@@ -220,7 +328,7 @@ export async function addFile(file, driveId, name, parentFolder) {
|
|
|
220
328
|
}
|
|
221
329
|
export async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
222
330
|
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
223
|
-
const reactor = window.ph?.
|
|
331
|
+
const reactor = window.ph?.legacyReactor;
|
|
224
332
|
if (!reactor) {
|
|
225
333
|
return;
|
|
226
334
|
}
|
|
@@ -342,7 +450,7 @@ export async function addFileWithProgress(file, driveId, name, parentFolder, onP
|
|
|
342
450
|
}
|
|
343
451
|
}
|
|
344
452
|
export async function updateFile(driveId, nodeId, documentType, name, parentFolder) {
|
|
345
|
-
const reactor = window.ph?.
|
|
453
|
+
const reactor = window.ph?.legacyReactor;
|
|
346
454
|
if (!reactor) {
|
|
347
455
|
return;
|
|
348
456
|
}
|
|
@@ -364,67 +472,133 @@ export async function updateFile(driveId, nodeId, documentType, name, parentFold
|
|
|
364
472
|
return node;
|
|
365
473
|
}
|
|
366
474
|
export async function addFolder(driveId, name, parentFolder) {
|
|
367
|
-
const reactor = window.ph?.reactor;
|
|
368
|
-
if (!reactor) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
475
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
372
476
|
if (!isAllowedToCreateDocuments) {
|
|
373
477
|
throw new Error("User is not allowed to create folders");
|
|
374
478
|
}
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
479
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
480
|
+
if (useLegacy) {
|
|
481
|
+
const reactor = window.ph?.legacyReactor;
|
|
482
|
+
if (!reactor) {
|
|
483
|
+
throw new Error("Legacy reactor not initialized");
|
|
484
|
+
}
|
|
485
|
+
const folderId = generateId();
|
|
486
|
+
const drive = await reactor.getDrive(driveId);
|
|
487
|
+
const unsafeCastAsDrive = (await queueActions(drive, baseAddFolder({
|
|
488
|
+
id: folderId,
|
|
489
|
+
name,
|
|
490
|
+
parentFolder,
|
|
491
|
+
})));
|
|
492
|
+
const node = unsafeCastAsDrive.state.global.nodes.find((node) => node.id === folderId);
|
|
493
|
+
if (!node || !isFolderNode(node)) {
|
|
494
|
+
throw new Error("There was an error adding folder");
|
|
495
|
+
}
|
|
496
|
+
return node;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
const reactorClient = window.ph?.reactorClient;
|
|
500
|
+
if (!reactorClient) {
|
|
501
|
+
throw new Error("ReactorClient not initialized");
|
|
502
|
+
}
|
|
503
|
+
// Get the drive document and add folder action
|
|
504
|
+
const { document: drive } = await reactorClient.get(driveId);
|
|
505
|
+
const folderId = generateId();
|
|
506
|
+
const updatedDrive = await reactorClient.execute(driveId, "main", [
|
|
507
|
+
baseAddFolder({
|
|
508
|
+
id: folderId,
|
|
509
|
+
name,
|
|
510
|
+
parentFolder,
|
|
511
|
+
}),
|
|
512
|
+
]);
|
|
513
|
+
const node = updatedDrive.state.global.nodes.find((node) => node.id === folderId);
|
|
514
|
+
if (!node || !isFolderNode(node)) {
|
|
515
|
+
throw new Error("There was an error adding folder");
|
|
516
|
+
}
|
|
517
|
+
return node;
|
|
385
518
|
}
|
|
386
|
-
return node;
|
|
387
519
|
}
|
|
388
520
|
export async function deleteNode(driveId, nodeId) {
|
|
389
|
-
const reactor = window.ph?.reactor;
|
|
390
|
-
if (!reactor) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
521
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
394
522
|
if (!isAllowedToCreateDocuments) {
|
|
395
523
|
throw new Error("User is not allowed to delete documents");
|
|
396
524
|
}
|
|
397
|
-
const
|
|
398
|
-
|
|
525
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
526
|
+
if (useLegacy) {
|
|
527
|
+
const reactor = window.ph?.legacyReactor;
|
|
528
|
+
if (!reactor) {
|
|
529
|
+
throw new Error("Legacy reactor not initialized");
|
|
530
|
+
}
|
|
531
|
+
const drive = await reactor.getDrive(driveId);
|
|
532
|
+
await queueActions(drive, baseDeleteNode({ id: nodeId }));
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
const reactorClient = window.ph?.reactorClient;
|
|
536
|
+
if (!reactorClient) {
|
|
537
|
+
throw new Error("ReactorClient not initialized");
|
|
538
|
+
}
|
|
539
|
+
await reactorClient.deleteDocument(nodeId);
|
|
540
|
+
}
|
|
399
541
|
}
|
|
400
542
|
export async function renameNode(driveId, nodeId, name) {
|
|
401
|
-
const reactor = window.ph?.reactor;
|
|
402
|
-
if (!reactor) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
543
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
406
544
|
if (!isAllowedToCreateDocuments) {
|
|
407
545
|
throw new Error("User is not allowed to rename documents");
|
|
408
546
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
547
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
548
|
+
if (useLegacy) {
|
|
549
|
+
const reactor = window.ph?.legacyReactor;
|
|
550
|
+
if (!reactor) {
|
|
551
|
+
throw new Error("Legacy reactor not initialized");
|
|
552
|
+
}
|
|
553
|
+
const drive = await reactor.getDrive(driveId);
|
|
554
|
+
const unsafeCastAsDrive = (await queueActions(drive, updateNode({ id: nodeId, name })));
|
|
555
|
+
const node = unsafeCastAsDrive.state.global.nodes.find((node) => node.id === nodeId);
|
|
556
|
+
if (!node) {
|
|
557
|
+
throw new Error("There was an error renaming node");
|
|
558
|
+
}
|
|
559
|
+
return node;
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
const reactorClient = window.ph?.reactorClient;
|
|
563
|
+
if (!reactorClient) {
|
|
564
|
+
throw new Error("ReactorClient not initialized");
|
|
565
|
+
}
|
|
566
|
+
await reactorClient.rename(nodeId, name);
|
|
567
|
+
// Fetch the updated drive to return the node
|
|
568
|
+
const { document: drive } = await reactorClient.get(driveId);
|
|
569
|
+
const node = drive.state.global.nodes.find((n) => n.id === nodeId);
|
|
570
|
+
if (!node) {
|
|
571
|
+
throw new Error("There was an error renaming node");
|
|
572
|
+
}
|
|
573
|
+
return node;
|
|
414
574
|
}
|
|
415
|
-
return node;
|
|
416
575
|
}
|
|
417
576
|
export async function moveNode(driveId, src, target) {
|
|
418
|
-
const reactor = window.ph?.reactor;
|
|
419
|
-
if (!reactor) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
577
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
423
578
|
if (!isAllowedToCreateDocuments) {
|
|
424
579
|
throw new Error("User is not allowed to move documents");
|
|
425
580
|
}
|
|
426
|
-
const
|
|
427
|
-
|
|
581
|
+
const useLegacy = isLegacyWriteEnabledSync();
|
|
582
|
+
if (useLegacy) {
|
|
583
|
+
const reactor = window.ph?.legacyReactor;
|
|
584
|
+
if (!reactor) {
|
|
585
|
+
throw new Error("Legacy reactor not initialized");
|
|
586
|
+
}
|
|
587
|
+
const drive = await reactor.getDrive(driveId);
|
|
588
|
+
return await queueActions(drive, baseMoveNode({ srcFolder: src.id, targetParentFolder: target?.id }));
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
const reactorClient = window.ph?.reactorClient;
|
|
592
|
+
if (!reactorClient) {
|
|
593
|
+
throw new Error("ReactorClient not initialized");
|
|
594
|
+
}
|
|
595
|
+
// Get current parent folder from source node
|
|
596
|
+
const sourceParent = src.parentFolder ?? driveId;
|
|
597
|
+
const targetParent = target?.id ?? driveId;
|
|
598
|
+
return await reactorClient.moveChildren(sourceParent, targetParent, [
|
|
599
|
+
src.id,
|
|
600
|
+
]);
|
|
601
|
+
}
|
|
428
602
|
}
|
|
429
603
|
function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
430
604
|
const documentModule = reactor
|
|
@@ -436,7 +610,7 @@ function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
436
610
|
return replayDocument(document.initialState, document.operations, documentModule.reducer, undefined, createPresignedHeader(newId, document.header.documentType));
|
|
437
611
|
}
|
|
438
612
|
export async function copyNode(driveId, src, target) {
|
|
439
|
-
const reactor = window.ph?.
|
|
613
|
+
const reactor = window.ph?.legacyReactor;
|
|
440
614
|
if (!reactor) {
|
|
441
615
|
return;
|
|
442
616
|
}
|