@secrecy/lib 1.61.0 → 1.61.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.
|
@@ -532,13 +532,16 @@ export class SecrecyCloudClient {
|
|
|
532
532
|
}
|
|
533
533
|
perNode = async (nodeId, publicKey) => {
|
|
534
534
|
let node = nodesCache.get(nodeId);
|
|
535
|
-
if (node === undefined) {
|
|
535
|
+
if (node === undefined || !('history' in node)) {
|
|
536
536
|
await this.node({ id: nodeId });
|
|
537
537
|
node = nodesCache.get(nodeId);
|
|
538
538
|
if (node === undefined) {
|
|
539
539
|
return null;
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
+
if (!('history' in node) || node.history.length === 0) {
|
|
543
|
+
throw new Error("Can't share a node whitout data!");
|
|
544
|
+
}
|
|
542
545
|
const nameKey = node.access?.nameKey;
|
|
543
546
|
return {
|
|
544
547
|
id: node.id,
|
|
@@ -24,6 +24,18 @@ export async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
24
24
|
users: apiNode.users,
|
|
25
25
|
parentId: apiNode.parentId ?? null,
|
|
26
26
|
currentDataId: apiNode.currentDataId ?? null,
|
|
27
|
+
parent: 'parent' in apiNode && apiNode.parent
|
|
28
|
+
? await apiNodeToInternal(apiNode.parent, keyPair)
|
|
29
|
+
: null,
|
|
30
|
+
children: 'children' in apiNode && apiNode.children
|
|
31
|
+
? await Promise.all(apiNode.children.map((children) => apiNodeToInternal(children, keyPair)))
|
|
32
|
+
: [],
|
|
33
|
+
current: 'current' in apiNode && apiNode.current
|
|
34
|
+
? apiDataToInternal(apiNode.current, keyPair)
|
|
35
|
+
: undefined,
|
|
36
|
+
history: 'history' in apiNode && apiNode.history
|
|
37
|
+
? apiNode.history.map((history) => apiDataToInternal(history, keyPair))
|
|
38
|
+
: [],
|
|
27
39
|
};
|
|
28
40
|
internal.access = { ...apiNode.access };
|
|
29
41
|
if (apiNode.access.nameKey !== null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node, ApiNode, InternalNode, ApiNodeFull, InternalNodeFull, NodeFull, KeyPair, ApiNodeParent } from '../types/index.js';
|
|
2
|
-
export declare function apiNodeToInternal(apiNode: ApiNode | ApiNodeParent | ApiNodeFull, keyPair: KeyPair): Promise<InternalNode>;
|
|
2
|
+
export declare function apiNodeToInternal(apiNode: ApiNode | ApiNodeParent | ApiNodeFull, keyPair: KeyPair): Promise<InternalNode | InternalNodeFull>;
|
|
3
3
|
export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull, keyPair: KeyPair): Promise<InternalNodeFull>;
|
|
4
4
|
export declare function internalNodeToNode(internal: InternalNode): Node;
|
|
5
5
|
export declare function internalNodeFullToNodeFull(internal: InternalNodeFull): NodeFull;
|
package/package.json
CHANGED