{"version":3,"file":"shares.cjs","names":[],"sources":["../../../../src/rest/commands/utils/shares.ts"],"sourcesContent":["import type { AuthenticationData, AuthenticationMode } from '../../../index.js';\nimport type { RestCommand } from '../../types.js';\n\n/**\n * Authenticate as a share user.\n *\n * @param share The ID of the share.\n * @param password Password for the share, if one is configured.\n * @param mode Whether to retrieve the refresh token in the JSON response, or in a httpOnly cookie. One of `json`, `cookie` or `session`. Defaults to `cookie`.\n *\n * @returns Authentication data.\n */\nexport const authenticateShare =\n\t<Schema>(\n\t\tshare: string,\n\t\tpassword?: string,\n\t\tmode: AuthenticationMode = 'cookie',\n\t): RestCommand<AuthenticationData, Schema> =>\n\t() => {\n\t\tconst data = { share, password, mode };\n\t\treturn { path: '/shares/auth', method: 'POST', body: JSON.stringify(data) };\n\t};\n\n/**\n * Sends an email to the provided email addresses with a link to the share.\n *\n * @param share Primary key of the share you're inviting people to.\n * @param emails Array of email strings to send the share link to.\n *\n * @returns Nothing\n */\nexport const inviteShare =\n\t<Schema>(share: string, emails: string[]): RestCommand<void, Schema> =>\n\t() => ({\n\t\tpath: `/shares/invite`,\n\t\tmethod: 'POST',\n\t\tbody: JSON.stringify({ share, emails }),\n\t});\n\n/**\n * Allows unauthenticated users to retrieve information about the share.\n *\n * @param id Primary key of the share you're viewing.\n *\n * @returns The share objects for the given UUID, if it's still valid.\n */\nexport const readShareInfo =\n\t<Schema>(\n\t\tid: string,\n\t): RestCommand<\n\t\t{\n\t\t\tid: string;\n\t\t\tcollection: string;\n\t\t\titem: string;\n\t\t\tpassword: string | null;\n\t\t\tdate_start: string | null;\n\t\t\tdate_end: string | null;\n\t\t\ttimes_used: number | null;\n\t\t\tmax_uses: number | null;\n\t\t},\n\t\tSchema\n\t> =>\n\t() => ({\n\t\tpath: `/shares/info/${id}`,\n\t\tmethod: 'GET',\n\t});\n"],"mappings":"AAYA,MAAa,GAEX,EACA,EACA,EAA2B,eAEtB,CACL,IAAM,EAAO,CAAE,QAAO,WAAU,OAAM,CACtC,MAAO,CAAE,KAAM,eAAgB,OAAQ,OAAQ,KAAM,KAAK,UAAU,EAAK,CAAE,EAWhE,GACH,EAAe,SACjB,CACN,KAAM,iBACN,OAAQ,OACR,KAAM,KAAK,UAAU,CAAE,QAAO,SAAQ,CAAC,CACvC,EASW,EAEX,QAcM,CACN,KAAM,gBAAgB,IACtB,OAAQ,MACR"}