MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / linkToEncryptedNode

Function linkToEncryptedNode

client/js/src/internal/nodes/apiService.ts:688–761  ·  view source on GitHub ↗
(
    logger: Logger,
    volumeId: string,
    link: Pick<PostLoadLinksMetadataResponse['Links'][0], 'Link' | 'Membership' | 'Sharing' | 'Folder' | 'File'>,
    isAdmin: boolean,
)

Source from the content-addressed store, hash-verified

686};
687
688function* handleResponseErrors(
689 nodeUids: string[],
690 volumeId: string,
691 responses: LinkResponse[] = [],
692): Generator<NodeResult> {
693 const errors = new Map();
694
695 responses.forEach((response) => {
696 if (!response.Response.Code || !isCodeOk(response.Response.Code) || response.Response.Error) {
697 const nodeUid = makeNodeUid(volumeId, response.LinkID);
698 errors.set(nodeUid, getErrorFromResult(response.Response));
699 }
700 });
701
702 for (const uid of nodeUids) {
703 const error = errors.get(uid);
704 if (error) {
705 yield { uid, ok: false, error };
706 } else {
707 yield { uid, ok: true };
708 }
709 }
710}
711
712function handleNodeWithSameNameExistsValidationError(volumeId: string, error: unknown): void {
713 if (error instanceof ValidationError) {
714 if (error.code === ErrorCode.ALREADY_EXISTS) {
715 const typedDetails = error.details as
716 | {
717 ConflictLinkID: string;
718 }
719 | undefined;
720
721 const existingNodeUid = typedDetails?.ConflictLinkID
722 ? makeNodeUid(volumeId, typedDetails.ConflictLinkID)
723 : undefined;
724
725 throw new NodeWithSameNameExistsValidationError(error.message, error.code, existingNodeUid);
726 }
727 }
728}
729
730export function linkToEncryptedNode(
731 logger: Logger,
732 volumeId: string,
733 link: Pick<PostLoadLinksMetadataResponse['Links'][0], 'Link' | 'Membership' | 'Sharing' | 'Folder' | 'File'>,
734 isAdmin: boolean,
735): EncryptedNode | undefined {
736 const { baseNodeMetadata, baseCryptoNodeMetadata } = linkToEncryptedNodeBaseMetadata(
737 logger,
738 volumeId,
739 link,
740 isAdmin,
741 );
742
743 if (link.Link.Type === 1 && link.Folder) {
744 return {
745 ...baseNodeMetadata,

Callers 3

linkToEncryptedNodeMethod · 0.90
linkToEncryptedNodeMethod · 0.90
linkToEncryptedNodeMethod · 0.85

Calls 4

makeNodeRevisionUidFunction · 0.90
transformThumbnailFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected