@burdenoff/microfe-files 2026.1023.1 → 2026.1101.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/dist/files/hooks/useCreateFolderShare.d.ts +7 -20
- package/dist/files/hooks/useCreateFolderShare.d.ts.map +1 -1
- package/dist/files/hooks/useCreateFolderShare.js +48 -21
- package/dist/files/hooks/useCreateFolderShare.js.map +1 -1
- package/dist/files/hooks/useCreateShare.d.ts +18 -19
- package/dist/files/hooks/useCreateShare.d.ts.map +1 -1
- package/dist/files/hooks/useCreateShare.js +51 -22
- package/dist/files/hooks/useCreateShare.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +61 -210
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +675 -402
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +12 -0
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +3 -7
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ShareCreationResult } from './useCreateShare';
|
|
2
2
|
export interface CreateFolderShareInput {
|
|
3
3
|
folderId: string;
|
|
4
4
|
shareType: "PUBLIC_LINK" | "EMAIL_INVITE" | "GROUP_SHARE";
|
|
@@ -9,26 +9,13 @@ export interface CreateFolderShareInput {
|
|
|
9
9
|
invitedEmail?: string;
|
|
10
10
|
invitedUserIds?: string[];
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a folder share through the consolidated ShareGrant stack (BOFF-5302).
|
|
14
|
+
* Same cutover as useCreateShare: public links become PUBLIC_LINK grants,
|
|
15
|
+
* email invites become PENDING grants + accept email.
|
|
16
|
+
*/
|
|
12
17
|
export declare const useCreateFolderShare: () => {
|
|
13
|
-
mutateAsync: (input: CreateFolderShareInput) => Promise<
|
|
14
|
-
id: string;
|
|
15
|
-
folderId: string;
|
|
16
|
-
shareType: FileShareType;
|
|
17
|
-
accessLevel: FileShareAccessLevel;
|
|
18
|
-
token: string | null;
|
|
19
|
-
invitedEmail: string | null;
|
|
20
|
-
requiresPassword: boolean;
|
|
21
|
-
expiresAt: string | null;
|
|
22
|
-
maxDownloads: number | null;
|
|
23
|
-
accessCount: number;
|
|
24
|
-
downloadCount: number;
|
|
25
|
-
lastAccessedAt: string | null;
|
|
26
|
-
revokedAt: string | null;
|
|
27
|
-
revokedBy: string | null;
|
|
28
|
-
createdById: string;
|
|
29
|
-
createdAt: string;
|
|
30
|
-
updatedAt: string;
|
|
31
|
-
} | undefined>;
|
|
18
|
+
mutateAsync: (input: CreateFolderShareInput) => Promise<ShareCreationResult>;
|
|
32
19
|
isPending: boolean;
|
|
33
20
|
error: import('@apollo/client').ErrorLike | undefined;
|
|
34
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateFolderShare.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useCreateFolderShare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCreateFolderShare.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useCreateFolderShare.ts"],"names":[],"mappings":"AAcA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC;IAC1D,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAgBD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;yBAWpB,sBAAsB,KAC5B,OAAO,CAAC,mBAAmB,CAAC;;;CAgDlC,CAAC"}
|
|
@@ -1,29 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CreateFolderShareLinkDocument as e, ShareFolderDocument as t } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { extractShareToken as n } from "./useCreateShare.js";
|
|
3
3
|
import { useMutation as r } from "@apollo/client/react";
|
|
4
4
|
//#region src/files/hooks/useCreateFolderShare.ts
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function i(e) {
|
|
6
|
+
switch (e) {
|
|
7
|
+
case "COMMENT": return "COMMENTER";
|
|
8
|
+
case "EDIT": return "EDITOR";
|
|
9
|
+
default: return "VIEWER";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
var a = () => {
|
|
13
|
+
let [a, { loading: o, error: s }] = r(t), [c, { loading: l, error: u }] = r(e);
|
|
7
14
|
return {
|
|
8
|
-
mutateAsync: async (e) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
mutateAsync: async (e) => {
|
|
16
|
+
let t = e.accessLevel.toUpperCase();
|
|
17
|
+
if (e.shareType === "PUBLIC_LINK") {
|
|
18
|
+
let r = {
|
|
19
|
+
input: {
|
|
20
|
+
resourceId: e.folderId,
|
|
21
|
+
role: i(e.accessLevel),
|
|
22
|
+
expiresAt: e.expiresAt ?? null
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
password: e.password ?? null,
|
|
26
|
+
maxDownloads: e.maxDownloads ?? null,
|
|
27
|
+
accessLevel: t
|
|
28
|
+
}
|
|
29
|
+
}, a = await c({ variables: r });
|
|
30
|
+
return { token: n(a.data?.createFolderShareLink.shareUrl ?? "") };
|
|
31
|
+
}
|
|
32
|
+
if (e.shareType !== "EMAIL_INVITE" || !e.invitedEmail) throw Error("Email invite shares require an invitedEmail");
|
|
33
|
+
let r = {
|
|
34
|
+
input: {
|
|
35
|
+
resourceId: e.folderId,
|
|
36
|
+
email: e.invitedEmail,
|
|
37
|
+
role: i(e.accessLevel),
|
|
38
|
+
message: null,
|
|
39
|
+
expiresAt: e.expiresAt ?? null
|
|
40
|
+
},
|
|
41
|
+
options: {
|
|
42
|
+
password: e.password ?? null,
|
|
43
|
+
maxDownloads: e.maxDownloads ?? null,
|
|
44
|
+
accessLevel: t
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return await a({ variables: r }), { token: "" };
|
|
48
|
+
},
|
|
49
|
+
isPending: o || l,
|
|
50
|
+
error: s ?? u
|
|
24
51
|
};
|
|
25
52
|
};
|
|
26
53
|
//#endregion
|
|
27
|
-
export {
|
|
54
|
+
export { a as useCreateFolderShare };
|
|
28
55
|
|
|
29
56
|
//# sourceMappingURL=useCreateFolderShare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateFolderShare.js","names":["useCreateFolderShare","
|
|
1
|
+
{"version":3,"file":"useCreateFolderShare.js","names":["toShareRole","accessLevel","useCreateFolderShare","shareFolderMutation","inviteLoading","inviteError","useMutation","ShareFolderDocument","createLinkMutation","linkLoading","linkError","CreateFolderShareLinkDocument","input","variables","result","extractShareToken"],"sources":["../../../src/files/hooks/useCreateFolderShare.ts"],"sourcesContent":["import { useMutation } from \"@apollo/client/react\";\n\nimport {\n CreateFolderShareLinkDocument,\n ShareFolderDocument,\n} from \"../../generated/wspace-operations\";\nimport type {\n FileShareAccessLevel,\n ShareRole,\n} from \"../../generated/wspace-types\";\nimport type {\n CreateFolderShareLinkMutationVariables,\n ShareFolderMutationVariables,\n} from \"../../generated/wspace-operations\";\nimport { extractShareToken, type ShareCreationResult } from \"./useCreateShare\";\n\nexport interface CreateFolderShareInput {\n folderId: string;\n shareType: \"PUBLIC_LINK\" | \"EMAIL_INVITE\" | \"GROUP_SHARE\";\n accessLevel: \"VIEW\" | \"COMMENT\" | \"DOWNLOAD\" | \"EDIT\";\n expiresAt?: string;\n password?: string;\n maxDownloads?: number;\n invitedEmail?: string;\n invitedUserIds?: string[];\n}\n\n/** Generic ShareRole for the legacy access levels (DOWNLOAD has no dedicated role). */\nfunction toShareRole(\n accessLevel: CreateFolderShareInput[\"accessLevel\"],\n): ShareRole {\n switch (accessLevel) {\n case \"COMMENT\":\n return \"COMMENTER\" as ShareRole;\n case \"EDIT\":\n return \"EDITOR\" as ShareRole;\n default:\n return \"VIEWER\" as ShareRole;\n }\n}\n\n/**\n * Create a folder share through the consolidated ShareGrant stack (BOFF-5302).\n * Same cutover as useCreateShare: public links become PUBLIC_LINK grants,\n * email invites become PENDING grants + accept email.\n */\nexport const useCreateFolderShare = () => {\n const [shareFolderMutation, { loading: inviteLoading, error: inviteError }] =\n useMutation(ShareFolderDocument);\n const [createLinkMutation, { loading: linkLoading, error: linkError }] =\n useMutation(CreateFolderShareLinkDocument);\n\n const loading = inviteLoading || linkLoading;\n const error = inviteError ?? linkError;\n\n return {\n mutateAsync: async (\n input: CreateFolderShareInput,\n ): Promise<ShareCreationResult> => {\n const accessLevel = input.accessLevel.toUpperCase() as\n \"VIEW\" | \"COMMENT\" | \"DOWNLOAD\" | \"EDIT\";\n if (input.shareType === \"PUBLIC_LINK\") {\n const variables: CreateFolderShareLinkMutationVariables = {\n input: {\n resourceId: input.folderId,\n role: toShareRole(input.accessLevel),\n expiresAt: input.expiresAt ?? null,\n },\n options: {\n password: input.password ?? null,\n maxDownloads: input.maxDownloads ?? null,\n accessLevel: accessLevel as unknown as FileShareAccessLevel,\n },\n };\n const result = await createLinkMutation({ variables });\n return {\n token: extractShareToken(\n result.data?.createFolderShareLink.shareUrl ?? \"\",\n ),\n };\n }\n\n if (input.shareType !== \"EMAIL_INVITE\" || !input.invitedEmail) {\n throw new Error(\"Email invite shares require an invitedEmail\");\n }\n\n const variables: ShareFolderMutationVariables = {\n input: {\n resourceId: input.folderId,\n email: input.invitedEmail,\n role: toShareRole(input.accessLevel),\n message: null,\n expiresAt: input.expiresAt ?? null,\n },\n options: {\n password: input.password ?? null,\n maxDownloads: input.maxDownloads ?? null,\n accessLevel: accessLevel as unknown as FileShareAccessLevel,\n },\n };\n await shareFolderMutation({ variables });\n return { token: \"\" };\n },\n isPending: loading,\n error,\n };\n};\n"],"mappings":";;;;AA4BA,SAASA,EACP,GACW;CACX,QAAQC,GAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAOA,IAAaC,UAA6B;CACxC,IAAM,CAACC,GAAqB,EAAE,SAASC,GAAe,OAAOC,OAC3DC,EAAYC,CAAmB,GAC3B,CAACC,GAAoB,EAAE,SAASC,GAAa,OAAOC,OACxDJ,EAAYK,CAA6B;CAK3C,OAAO;EACL,aAAa,OACX,MACiC;GACjC,IAAMV,IAAcW,EAAM,YAAY,YAAY;GAElD,IAAIA,EAAM,cAAc,eAAe;IACrC,IAAMC,IAAoD;KACxD,OAAO;MACL,YAAYD,EAAM;MAClB,MAAMZ,EAAYY,EAAM,WAAW;MACnC,WAAWA,EAAM,aAAa;KAChC;KACA,SAAS;MACP,UAAUA,EAAM,YAAY;MAC5B,cAAcA,EAAM,gBAAgB;MACvB;KACf;IACF,GACME,IAAS,MAAMN,EAAmB,EAAE,aAAU,CAAC;IACrD,OAAO,EACL,OAAOO,EACLD,EAAO,MAAM,sBAAsB,YAAY,EACjD,EACF;GACF;GAEA,IAAIF,EAAM,cAAc,kBAAkB,CAACA,EAAM,cAC/C,MAAU,MAAM,6CAA6C;GAG/D,IAAMC,IAA0C;IAC9C,OAAO;KACL,YAAYD,EAAM;KAClB,OAAOA,EAAM;KACb,MAAMZ,EAAYY,EAAM,WAAW;KACnC,SAAS;KACT,WAAWA,EAAM,aAAa;IAChC;IACA,SAAS;KACP,UAAUA,EAAM,YAAY;KAC5B,cAAcA,EAAM,gBAAgB;KACvB;IACf;GACF;GAEA,OADA,MAAMT,EAAoB,EAAE,aAAU,CAAC,GAChC,EAAE,OAAO,GAAG;EACrB;EACA,WAnDcC,KAAiBK;EAoD/B,OAnDYJ,KAAeK;CAoD7B;AACF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FileShareAccessLevel, FileShareType } from '../../generated/wspace-types';
|
|
2
1
|
export interface CreateShareInput {
|
|
3
2
|
fileId: string;
|
|
4
3
|
shareType: "PUBLIC_LINK" | "EMAIL_INVITE" | "GROUP_SHARE";
|
|
@@ -9,25 +8,25 @@ export interface CreateShareInput {
|
|
|
9
8
|
invitedEmail?: string;
|
|
10
9
|
invitedUserIds?: string[];
|
|
11
10
|
}
|
|
11
|
+
export interface ShareCreationResult {
|
|
12
|
+
/** Raw share token (public links only) — drives the `/files/share/:token` URL. */
|
|
13
|
+
token: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extract the raw share token from a grant `shareUrl`
|
|
17
|
+
* (`{origin}/share/accept/{token}`). Falls back to the trimmed whole string
|
|
18
|
+
* when no path segment is present.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractShareToken(shareUrl: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Create a file share through the consolidated ShareGrant stack (BOFF-5302).
|
|
23
|
+
* Public links become PUBLIC_LINK grants; email invites become PENDING
|
|
24
|
+
* grants + a `resource-shared` accept email from the service. The legacy
|
|
25
|
+
* access level is preserved on the grant so the token-access path keeps
|
|
26
|
+
* issuing download URLs for DOWNLOAD shares.
|
|
27
|
+
*/
|
|
12
28
|
export declare const useCreateShare: () => {
|
|
13
|
-
mutateAsync: (input: CreateShareInput) => Promise<
|
|
14
|
-
id: string;
|
|
15
|
-
fileId: string;
|
|
16
|
-
shareType: FileShareType;
|
|
17
|
-
accessLevel: FileShareAccessLevel;
|
|
18
|
-
token: string | null;
|
|
19
|
-
invitedEmail: string | null;
|
|
20
|
-
requiresPassword: boolean;
|
|
21
|
-
expiresAt: string | null;
|
|
22
|
-
maxDownloads: number | null;
|
|
23
|
-
accessCount: number;
|
|
24
|
-
downloadCount: number;
|
|
25
|
-
lastAccessedAt: string | null;
|
|
26
|
-
revokedAt: string | null;
|
|
27
|
-
createdById: string;
|
|
28
|
-
createdAt: string;
|
|
29
|
-
updatedAt: string;
|
|
30
|
-
} | undefined>;
|
|
29
|
+
mutateAsync: (input: CreateShareInput) => Promise<ShareCreationResult>;
|
|
31
30
|
isPending: boolean;
|
|
32
31
|
error: import('@apollo/client').ErrorLike | undefined;
|
|
33
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateShare.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useCreateShare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCreateShare.d.ts","sourceRoot":"","sources":["../../../src/files/hooks/useCreateShare.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC;IAC1D,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;CACf;AAcD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;yBAWd,gBAAgB,KACtB,OAAO,CAAC,mBAAmB,CAAC;;;CAiDlC,CAAC"}
|
|
@@ -1,29 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useMutation as r } from "@apollo/client/react";
|
|
1
|
+
import { CreateFileShareLinkDocument as e, ShareFileDocument as t } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useMutation as n } from "@apollo/client/react";
|
|
4
3
|
//#region src/files/hooks/useCreateShare.ts
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function r(e) {
|
|
5
|
+
switch (e) {
|
|
6
|
+
case "COMMENT": return "COMMENTER";
|
|
7
|
+
case "EDIT": return "EDITOR";
|
|
8
|
+
default: return "VIEWER";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function i(e) {
|
|
12
|
+
return (e.match(/\/share\/accept\/([^/?#]+)$/)?.[1] ?? e).trim();
|
|
13
|
+
}
|
|
14
|
+
var a = () => {
|
|
15
|
+
let [a, { loading: o, error: s }] = n(t), [c, { loading: l, error: u }] = n(e);
|
|
7
16
|
return {
|
|
8
|
-
mutateAsync: async (e) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
mutateAsync: async (e) => {
|
|
18
|
+
let t = e.accessLevel.toUpperCase();
|
|
19
|
+
if (e.shareType === "PUBLIC_LINK") {
|
|
20
|
+
let n = {
|
|
21
|
+
input: {
|
|
22
|
+
resourceId: e.fileId,
|
|
23
|
+
role: r(e.accessLevel),
|
|
24
|
+
expiresAt: e.expiresAt ?? null
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
password: e.password ?? null,
|
|
28
|
+
maxDownloads: e.maxDownloads ?? null,
|
|
29
|
+
accessLevel: t
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return { token: i((await c({ variables: n })).data?.createFileShareLink.shareUrl ?? "") };
|
|
33
|
+
}
|
|
34
|
+
if (e.shareType !== "EMAIL_INVITE" || !e.invitedEmail) throw Error("Email invite shares require an invitedEmail");
|
|
35
|
+
let n = {
|
|
36
|
+
input: {
|
|
37
|
+
resourceId: e.fileId,
|
|
38
|
+
email: e.invitedEmail,
|
|
39
|
+
role: r(e.accessLevel),
|
|
40
|
+
message: null,
|
|
41
|
+
expiresAt: e.expiresAt ?? null
|
|
42
|
+
},
|
|
43
|
+
options: {
|
|
44
|
+
password: e.password ?? null,
|
|
45
|
+
maxDownloads: e.maxDownloads ?? null,
|
|
46
|
+
accessLevel: t
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return await a({ variables: n }), { token: "" };
|
|
50
|
+
},
|
|
51
|
+
isPending: o || l,
|
|
52
|
+
error: s ?? u
|
|
24
53
|
};
|
|
25
54
|
};
|
|
26
55
|
//#endregion
|
|
27
|
-
export { i as useCreateShare };
|
|
56
|
+
export { i as extractShareToken, a as useCreateShare };
|
|
28
57
|
|
|
29
58
|
//# sourceMappingURL=useCreateShare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateShare.js","names":["useCreateShare","
|
|
1
|
+
{"version":3,"file":"useCreateShare.js","names":["toShareRole","accessLevel","extractShareToken","shareUrl","useCreateShare","shareFileMutation","inviteLoading","inviteError","useMutation","ShareFileDocument","createLinkMutation","linkLoading","linkError","CreateFileShareLinkDocument","input","variables"],"sources":["../../../src/files/hooks/useCreateShare.ts"],"sourcesContent":["import { useMutation } from \"@apollo/client/react\";\n\nimport {\n CreateFileShareLinkDocument,\n ShareFileDocument,\n} from \"../../generated/wspace-operations\";\nimport type {\n FileShareAccessLevel,\n ShareRole,\n} from \"../../generated/wspace-types\";\nimport type {\n CreateFileShareLinkMutationVariables,\n ShareFileMutationVariables,\n} from \"../../generated/wspace-operations\";\n\nexport interface CreateShareInput {\n fileId: string;\n shareType: \"PUBLIC_LINK\" | \"EMAIL_INVITE\" | \"GROUP_SHARE\";\n accessLevel: \"VIEW\" | \"COMMENT\" | \"DOWNLOAD\" | \"EDIT\";\n expiresAt?: string;\n password?: string;\n maxDownloads?: number;\n invitedEmail?: string;\n invitedUserIds?: string[];\n}\n\nexport interface ShareCreationResult {\n /** Raw share token (public links only) — drives the `/files/share/:token` URL. */\n token: string;\n}\n\n/** Generic ShareRole for the legacy access levels (DOWNLOAD has no dedicated role). */\nfunction toShareRole(accessLevel: CreateShareInput[\"accessLevel\"]): ShareRole {\n switch (accessLevel) {\n case \"COMMENT\":\n return \"COMMENTER\" as ShareRole;\n case \"EDIT\":\n return \"EDITOR\" as ShareRole;\n default:\n return \"VIEWER\" as ShareRole;\n }\n}\n\n/**\n * Extract the raw share token from a grant `shareUrl`\n * (`{origin}/share/accept/{token}`). Falls back to the trimmed whole string\n * when no path segment is present.\n */\nexport function extractShareToken(shareUrl: string): string {\n const match = shareUrl.match(/\\/share\\/accept\\/([^/?#]+)$/);\n return (match?.[1] ?? shareUrl).trim();\n}\n\n/**\n * Create a file share through the consolidated ShareGrant stack (BOFF-5302).\n * Public links become PUBLIC_LINK grants; email invites become PENDING\n * grants + a `resource-shared` accept email from the service. The legacy\n * access level is preserved on the grant so the token-access path keeps\n * issuing download URLs for DOWNLOAD shares.\n */\nexport const useCreateShare = () => {\n const [shareFileMutation, { loading: inviteLoading, error: inviteError }] =\n useMutation(ShareFileDocument);\n const [createLinkMutation, { loading: linkLoading, error: linkError }] =\n useMutation(CreateFileShareLinkDocument);\n\n const loading = inviteLoading || linkLoading;\n const error = inviteError ?? linkError;\n\n return {\n mutateAsync: async (\n input: CreateShareInput,\n ): Promise<ShareCreationResult> => {\n const accessLevel = input.accessLevel.toUpperCase() as\n \"VIEW\" | \"COMMENT\" | \"DOWNLOAD\" | \"EDIT\";\n if (input.shareType === \"PUBLIC_LINK\") {\n const variables: CreateFileShareLinkMutationVariables = {\n input: {\n resourceId: input.fileId,\n role: toShareRole(input.accessLevel),\n expiresAt: input.expiresAt ?? null,\n },\n options: {\n password: input.password ?? null,\n maxDownloads: input.maxDownloads ?? null,\n accessLevel: accessLevel as unknown as FileShareAccessLevel,\n },\n };\n const result = await createLinkMutation({ variables });\n return {\n token: extractShareToken(\n result.data?.createFileShareLink.shareUrl ?? \"\",\n ),\n };\n }\n\n if (input.shareType !== \"EMAIL_INVITE\" || !input.invitedEmail) {\n throw new Error(\"Email invite shares require an invitedEmail\");\n }\n\n const variables: ShareFileMutationVariables = {\n input: {\n resourceId: input.fileId,\n email: input.invitedEmail,\n role: toShareRole(input.accessLevel),\n message: null,\n expiresAt: input.expiresAt ?? null,\n },\n options: {\n password: input.password ?? null,\n maxDownloads: input.maxDownloads ?? null,\n accessLevel: accessLevel as unknown as FileShareAccessLevel,\n },\n };\n await shareFileMutation({ variables });\n // Invites are opened through the accept flow, not a public URL.\n return { token: \"\" };\n },\n isPending: loading,\n error,\n };\n};\n"],"mappings":";;;AAgCA,SAASA,EAAY,GAAyD;CAC5E,QAAQC,GAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAOA,SAAgBC,EAAkB,GAA0B;CAE1D,QADcC,EAAS,MAAM,6BACrB,CAAA,GAAQ,MAAMA,EAAA,CAAU,KAAK;AACvC;AASA,IAAaC,UAAuB;CAClC,IAAM,CAACC,GAAmB,EAAE,SAASC,GAAe,OAAOC,OACzDC,EAAYC,CAAiB,GACzB,CAACC,GAAoB,EAAE,SAASC,GAAa,OAAOC,OACxDJ,EAAYK,CAA2B;CAKzC,OAAO;EACL,aAAa,OACX,MACiC;GACjC,IAAMZ,IAAca,EAAM,YAAY,YAAY;GAElD,IAAIA,EAAM,cAAc,eAAe;IACrC,IAAMC,IAAkD;KACtD,OAAO;MACL,YAAYD,EAAM;MAClB,MAAMd,EAAYc,EAAM,WAAW;MACnC,WAAWA,EAAM,aAAa;KAChC;KACA,SAAS;MACP,UAAUA,EAAM,YAAY;MAC5B,cAAcA,EAAM,gBAAgB;MACvB;KACf;IACF;IAEA,OAAO,EACL,OAAOZ,GACL,MAHiBQ,EAAmB,EAAE,aAAU,CAAC,EAAA,CAG1C,MAAM,oBAAoB,YAAY,EAC/C,EACF;GACF;GAEA,IAAII,EAAM,cAAc,kBAAkB,CAACA,EAAM,cAC/C,MAAU,MAAM,6CAA6C;GAG/D,IAAMC,IAAwC;IAC5C,OAAO;KACL,YAAYD,EAAM;KAClB,OAAOA,EAAM;KACb,MAAMd,EAAYc,EAAM,WAAW;KACnC,SAAS;KACT,WAAWA,EAAM,aAAa;IAChC;IACA,SAAS;KACP,UAAUA,EAAM,YAAY;KAC5B,cAAcA,EAAM,gBAAgB;KACvB;IACf;GACF;GAGA,OAFA,MAAMT,EAAkB,EAAE,aAAU,CAAC,GAE9B,EAAE,OAAO,GAAG;EACrB;EACA,WApDcC,KAAiBK;EAqD/B,OApDYJ,KAAeK;CAqD7B;AACF"}
|