1 import { HTTP_STATUS_CODE } from '@proton/shared/lib/constants';
3 import { EXPENSIVE_REQUEST_TIMEOUT } from '../../drive/constants';
4 import { API_CUSTOM_ERROR_CODES } from '../../errors';
5 import type { MoveLink } from '../../interfaces/drive/link';
6 import type { CreateDrivePhotosShare, CreateDriveShare } from '../../interfaces/drive/share';
8 export const queryCreateShare = (volumeID: string, data: CreateDriveShare) => ({
10 url: `drive/volumes/${volumeID}/shares`,
13 export const queryCreatePhotosShare = (volumeID: string, data: CreateDrivePhotosShare) => ({
15 url: `drive/volumes/${volumeID}/photos/share`,
19 export const queryUserShares = (ShowAll = 1) => ({
26 export const queryShareMeta = (shareID: string) => ({
28 url: `drive/shares/${shareID}`,
29 silence: [API_CUSTOM_ERROR_CODES.NOT_ALLOWED],
32 export const queryRenameLink = (
35 data: { Name: string; MIMEType?: string; Hash: string; SignatureAddress: string; OriginalHash: string }
38 url: `drive/shares/${shareID}/links/${linkID}/rename`,
42 export const queryMoveLink = (shareID: string, linkID: string, data: MoveLink) => ({
44 url: `drive/shares/${shareID}/links/${linkID}/move`,
48 export const queryEvents = (shareID: string, eventID: string) => ({
49 timeout: EXPENSIVE_REQUEST_TIMEOUT,
50 url: `drive/shares/${shareID}/events/${eventID}`,
54 export const queryLatestEvents = (shareID: string) => ({
55 url: `drive/shares/${shareID}/events/latest`,
59 export const queryDeleteShare = (
61 { Force, silence }: { Force?: 0 | 1; silence?: boolean } = { Force: 0 }
63 url: `drive/shares/${shareID}`,
70 export const queryShareMembers = (shareID: string) => ({
71 url: `drive/shares/${shareID}/members`,
75 export const queryRemoveShareMember = (shareID: string, memberID: string) => ({
77 url: `drive/shares/${shareID}/members/${memberID}`,
80 export const queryAcceptShareInvite = (
90 SessionKeySignature: string;
94 url: `drive/shares/${shareID}/members/invitations/${memberID}`,
102 /* Shares migration */
103 export const queryUnmigratedShares = () => ({
104 url: 'drive/migrations/shareaccesswithnode/unmigrated',
106 silence: [HTTP_STATUS_CODE.NOT_FOUND],
109 export const queryMigrateLegacyShares = (data: {
110 PassphraseNodeKeyPackets: { PassphraseNodeKeyPacket: string; ShareID: string }[];
111 UnreadableShareIDs?: string[];
113 url: 'drive/migrations/shareaccesswithnode',
116 silence: [HTTP_STATUS_CODE.NOT_FOUND],
119 export const queryResolveContextShare = ({ volumeId, linkId }: { volumeId: string; linkId: string }) => ({
120 url: `drive/volumes/${volumeId}/links/${linkId}/context`,