@epam/ai-dial-chat-hooks 1.3.0-dev.10 → 1.3.0-dev.14
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/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +136 -119
- package/catalog.d.ts +3 -0
- package/file-manager.d.ts +13 -2
- package/files/dial-file-manager.types.js +1 -1
- package/files/useDialFileListing/useDialFileListing.js +22 -12
- package/files/useDialFileManager/useDialFileManager.js +3 -1
- package/files/useDialFileSharing/useDialFileSharing.js +45 -39
- package/index.d.ts +16 -2
- package/package.json +16 -16
|
@@ -5,126 +5,143 @@ import { getRunnerSchemas as r, isQuickAppSchema as i } from "../../shared/appli
|
|
|
5
5
|
import { CatalogEntityType as a } from "@epam/ai-dial-chat-shared";
|
|
6
6
|
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
7
7
|
//#region src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts
|
|
8
|
-
var l = ({ deployments:
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
onClick: k
|
|
96
|
-
}], i = t(D.createSkill) ? r : r.filter((e) => t(String(e.label)));
|
|
97
|
-
return i.length > 0 && n.push({
|
|
98
|
-
key: "skill",
|
|
99
|
-
label: D.createSkill,
|
|
100
|
-
children: i
|
|
101
|
-
}), m && t(D.createPrompt) && n.push({
|
|
8
|
+
var l = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(t.label ?? ""), void 0, { sensitivity: "base" })), u = ({ deployments: u, isCustomAppsEnabled: d, isSchemaAppsEnabled: f, isHideCustomAppCreationEnabled: p, isToolsetsEnabled: m, isPromptsEnabled: h, schemas: g, urls: _, onNavigate: v, deletePrompt: y, deleteToolset: b, deleteSkill: x, deleteApplication: S, refetchPrompts: C, refetchToolsets: w, refetchSkills: T, refetchDeployments: E, onDeleteSuccess: D, labels: O, onNotify: k, onSkillUploadClick: A }) => {
|
|
9
|
+
let j = s(() => r(g), [g]), [M, N] = c(""), P = f && !p, F = o((e) => {
|
|
10
|
+
if (e.type === a.Prompt) {
|
|
11
|
+
v(_.buildPromptEditUrl(e.id));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (e.type === a.Skill) {
|
|
15
|
+
v(_.buildSkillEditUrl(e.id));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (e.type === a.Toolset) {
|
|
19
|
+
v(_.buildToolsetEditUrl(e.id));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let n = t(u, e.id);
|
|
23
|
+
if (d && n != null && !n.applicationTypeSchemaId) {
|
|
24
|
+
v(_.buildCustomAppEditUrl(e.id));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let r = j.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? j.find((e) => i(e))?.id;
|
|
28
|
+
r && v(_.buildQuickAppEditUrl(r, e.id));
|
|
29
|
+
}, [
|
|
30
|
+
u,
|
|
31
|
+
d,
|
|
32
|
+
j,
|
|
33
|
+
v,
|
|
34
|
+
_
|
|
35
|
+
]), I = o(async (t) => {
|
|
36
|
+
try {
|
|
37
|
+
if (t.type === a.Prompt) await y(t.id), await C();
|
|
38
|
+
else if (t.type === a.Toolset) await b(t.id), await w();
|
|
39
|
+
else if (t.type === a.Skill) {
|
|
40
|
+
let e = n(t.id);
|
|
41
|
+
if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
|
|
42
|
+
await x(e.bucket, e.path), await T();
|
|
43
|
+
} else await S(t.id), await E();
|
|
44
|
+
D(t);
|
|
45
|
+
} catch (t) {
|
|
46
|
+
let { traceId: n } = await e(t);
|
|
47
|
+
throw k({
|
|
48
|
+
message: O.deleteError,
|
|
49
|
+
requestId: n
|
|
50
|
+
}), t;
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
y,
|
|
54
|
+
b,
|
|
55
|
+
x,
|
|
56
|
+
S,
|
|
57
|
+
w,
|
|
58
|
+
E,
|
|
59
|
+
C,
|
|
60
|
+
T,
|
|
61
|
+
D,
|
|
62
|
+
O,
|
|
63
|
+
k
|
|
64
|
+
]), L = s(() => {
|
|
65
|
+
let e = M.trim().toLocaleLowerCase(), t = (t) => !e || t.toLocaleLowerCase().includes(e), n = P ? j.map((e) => ({
|
|
66
|
+
id: e.id,
|
|
67
|
+
label: e.displayName || e.id
|
|
68
|
+
})).filter((e) => t(e.label)).map((e) => ({
|
|
69
|
+
key: `runner:${e.id}`,
|
|
70
|
+
label: e.label,
|
|
71
|
+
onClick: () => v(_.buildQuickAppCreateUrl(e.id))
|
|
72
|
+
})) : [], r = m && t(O.createToolset) ? {
|
|
73
|
+
key: "toolset",
|
|
74
|
+
label: O.createToolset,
|
|
75
|
+
onClick: () => v(_.buildToolsetCreateUrl())
|
|
76
|
+
} : void 0, i = d && !p && t(O.createCustomApp) ? {
|
|
77
|
+
key: "custom-app",
|
|
78
|
+
label: O.createCustomApp,
|
|
79
|
+
onClick: () => v(_.buildCustomAppCreateUrl())
|
|
80
|
+
} : void 0, a = [{
|
|
81
|
+
key: "skill-write-instructions",
|
|
82
|
+
label: O.createSkillWriteInstructions,
|
|
83
|
+
onClick: () => v(_.buildSkillCreateUrl())
|
|
84
|
+
}, {
|
|
85
|
+
key: "skill-upload",
|
|
86
|
+
label: O.createSkillUpload,
|
|
87
|
+
onClick: A
|
|
88
|
+
}];
|
|
89
|
+
return {
|
|
90
|
+
runnerOptions: n,
|
|
91
|
+
toolsetOption: r,
|
|
92
|
+
customAppOption: i,
|
|
93
|
+
visibleSkillChildren: t(O.createSkill) ? a : a.filter((e) => t(String(e.label))),
|
|
94
|
+
promptOption: h && t(O.createPrompt) ? {
|
|
102
95
|
key: "prompt",
|
|
103
|
-
label:
|
|
104
|
-
onClick: () => _
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
96
|
+
label: O.createPrompt,
|
|
97
|
+
onClick: () => v(_.buildPromptCreateUrl())
|
|
98
|
+
} : void 0
|
|
99
|
+
};
|
|
100
|
+
}, [
|
|
101
|
+
M,
|
|
102
|
+
P,
|
|
103
|
+
j,
|
|
104
|
+
v,
|
|
105
|
+
_,
|
|
106
|
+
h,
|
|
107
|
+
O,
|
|
108
|
+
p,
|
|
109
|
+
m,
|
|
110
|
+
d,
|
|
111
|
+
A
|
|
112
|
+
]), R = s(() => {
|
|
113
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = L, a = [...e];
|
|
114
|
+
return t && a.push(t), n && a.push(n), r.length > 0 && a.push({
|
|
115
|
+
key: "skill",
|
|
116
|
+
label: O.createSkill,
|
|
117
|
+
children: r
|
|
118
|
+
}), i && a.push(i), l(a);
|
|
119
|
+
}, [L, O.createSkill]), z = s(() => P && j.length > 0 ? {
|
|
120
|
+
value: M,
|
|
121
|
+
onChange: N
|
|
122
|
+
} : void 0, [
|
|
123
|
+
P,
|
|
124
|
+
j.length,
|
|
125
|
+
M
|
|
126
|
+
]);
|
|
127
|
+
return {
|
|
128
|
+
handleEdit: F,
|
|
129
|
+
handleDelete: I,
|
|
130
|
+
createOptions: R,
|
|
131
|
+
createSearch: z,
|
|
132
|
+
createMenuByType: s(() => {
|
|
133
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = L;
|
|
134
|
+
return {
|
|
135
|
+
[a.Agent]: {
|
|
136
|
+
options: l(n ? [...e, n] : e),
|
|
137
|
+
search: z
|
|
138
|
+
},
|
|
139
|
+
[a.Toolset]: { options: t ? [t] : [] },
|
|
140
|
+
[a.Skill]: { options: r },
|
|
141
|
+
[a.Prompt]: { options: i ? [i] : [] }
|
|
142
|
+
};
|
|
143
|
+
}, [L, z])
|
|
127
144
|
};
|
|
128
145
|
};
|
|
129
146
|
//#endregion
|
|
130
|
-
export {
|
|
147
|
+
export { u as useCatalogEditNavigation };
|
package/catalog.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { CatalogItemDetailsFetchResult } from '@epam/ai-dial-catalog';
|
|
|
10
10
|
import { CatalogItemLimits } from '@epam/ai-dial-catalog';
|
|
11
11
|
import { CatalogItemOverview } from '@epam/ai-dial-catalog';
|
|
12
12
|
import { CatalogItemTabData } from '@epam/ai-dial-catalog';
|
|
13
|
+
import { CatalogTabCreateMenu } from '@epam/ai-dial-catalog';
|
|
13
14
|
import { CredentialsLevel } from '@epam/ai-dial-catalog';
|
|
14
15
|
import { DeploymentDetailsDto } from '@epam/ai-dial-chat-api-client';
|
|
15
16
|
import { DeploymentItemDto } from '@epam/ai-dial-chat-api-client';
|
|
@@ -1114,6 +1115,8 @@ export declare interface UseCatalogEditNavigationResult {
|
|
|
1114
1115
|
createOptions: DropdownItem[];
|
|
1115
1116
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
1116
1117
|
createSearch: CatalogCreateSearch | undefined;
|
|
1118
|
+
/** The Create menu narrowed to each entity type; models have no entry since they cannot be created. */
|
|
1119
|
+
createMenuByType: Partial<Record<CatalogEntityType, CatalogTabCreateMenu>>;
|
|
1117
1120
|
}
|
|
1118
1121
|
|
|
1119
1122
|
/**
|
package/file-manager.d.ts
CHANGED
|
@@ -407,7 +407,9 @@ export declare enum FileOperationKind {
|
|
|
407
407
|
FilesMoved = "filesMoved",
|
|
408
408
|
/** A copy whose every item landed in its own source folder (Duplicate). */
|
|
409
409
|
FileDuplicated = "fileDuplicated",
|
|
410
|
-
FilesDuplicated = "filesDuplicated"
|
|
410
|
+
FilesDuplicated = "filesDuplicated",
|
|
411
|
+
/** One or more shared-with-me items were removed from the Shared tab. */
|
|
412
|
+
FilesUnshared = "filesUnshared"
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
/**
|
|
@@ -775,6 +777,11 @@ export declare interface UseDialFileListingResult {
|
|
|
775
777
|
mergeCreatedFolder: (parentApiPath: string, created: CreateFolderResponseDto, inheritedPermissions?: string[]) => void;
|
|
776
778
|
/** Forces the listing effect to re-fetch the currently browsed folder. */
|
|
777
779
|
bumpRetry: () => void;
|
|
780
|
+
/**
|
|
781
|
+
* Drops the named root rows from the Shared tab's cached listing, so an
|
|
782
|
+
* unshared item disappears at once instead of waiting for the refetch.
|
|
783
|
+
*/
|
|
784
|
+
removeSharedRootItems: (names: string[]) => void;
|
|
778
785
|
}
|
|
779
786
|
|
|
780
787
|
/**
|
|
@@ -1096,7 +1103,7 @@ export declare interface UseDialFileMutationsResult {
|
|
|
1096
1103
|
* shared retry counter after each mutation settles rather than holding its
|
|
1097
1104
|
* own cache copy.
|
|
1098
1105
|
*/
|
|
1099
|
-
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
1106
|
+
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, onOperationSuccess, removeSharedRootItems, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
1100
1107
|
|
|
1101
1108
|
/** Options accepted by `useDialFileSharing`. */
|
|
1102
1109
|
export declare interface UseDialFileSharingOptions {
|
|
@@ -1110,6 +1117,10 @@ export declare interface UseDialFileSharingOptions {
|
|
|
1110
1117
|
bumpRetry: () => void;
|
|
1111
1118
|
/** Called when a sharing mutation fails and should surface a toast notification. */
|
|
1112
1119
|
onNotification?: (notification: FileManagerNotification) => void;
|
|
1120
|
+
/** Called with a structured event once an unshare succeeds, so the host can show its success toast. */
|
|
1121
|
+
onOperationSuccess?: (event: FileOperationSuccessEvent) => void;
|
|
1122
|
+
/** Removes the unshared root rows from the cached Shared listing ahead of the refetch. */
|
|
1123
|
+
removeSharedRootItems?: (names: string[]) => void;
|
|
1113
1124
|
}
|
|
1114
1125
|
|
|
1115
1126
|
/** Values returned by `useDialFileSharing`. */
|
|
@@ -4,7 +4,7 @@ var e = /* @__PURE__ */ function(e) {
|
|
|
4
4
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
5
|
return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e;
|
|
6
6
|
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
-
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e.FileDuplicated = "fileDuplicated", e.FilesDuplicated = "filesDuplicated", e;
|
|
7
|
+
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e.FileDuplicated = "fileDuplicated", e.FilesDuplicated = "filesDuplicated", e.FilesUnshared = "filesUnshared", e;
|
|
8
8
|
}({});
|
|
9
9
|
//#endregion
|
|
10
10
|
export { e as FileManagerNotificationReason, t as FileNameValidationErrorReason, n as FileOperationKind };
|
|
@@ -144,6 +144,15 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
144
144
|
]), ve = l((e, t, n) => {
|
|
145
145
|
E((r) => re(r, e, t, n));
|
|
146
146
|
}, []), ye = l((e) => {
|
|
147
|
+
if (e.length === 0) return;
|
|
148
|
+
let t = new Set(e);
|
|
149
|
+
E((e) => {
|
|
150
|
+
let n = e.get("");
|
|
151
|
+
if (n == null) return e;
|
|
152
|
+
let r = new Map(e);
|
|
153
|
+
return r.set("", n.filter((e) => !t.has(e.name))), r;
|
|
154
|
+
}), F((t) => t?.filter((t) => !e.some((e) => t === `/${y}/${e}`)));
|
|
155
|
+
}, [y]), be = l((e) => {
|
|
147
156
|
if (!S) return;
|
|
148
157
|
let n = e == null ? "" : o(e, y), r = e ?? `/${y}`;
|
|
149
158
|
if (J((e) => {
|
|
@@ -185,7 +194,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
185
194
|
S,
|
|
186
195
|
x,
|
|
187
196
|
y
|
|
188
|
-
]),
|
|
197
|
+
]), xe = d(() => {
|
|
189
198
|
let e = /* @__PURE__ */ new Set(), t = new Set([...W, ...q]);
|
|
190
199
|
for (let n of t) {
|
|
191
200
|
let t = o(n, y);
|
|
@@ -197,7 +206,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
197
206
|
q,
|
|
198
207
|
T,
|
|
199
208
|
y
|
|
200
|
-
]),
|
|
209
|
+
]), Se = l((e) => {
|
|
201
210
|
S && (W.forEach((t) => {
|
|
202
211
|
e.has(t) || U.current.delete(o(t, y));
|
|
203
212
|
}), G(e), [...e].filter((e) => {
|
|
@@ -230,9 +239,9 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
230
239
|
S,
|
|
231
240
|
x,
|
|
232
241
|
y
|
|
233
|
-
]),
|
|
242
|
+
]), Ce = l(() => {
|
|
234
243
|
B.current != null && (clearTimeout(B.current), B.current = null), V.current?.(), V.current = null, z(null), R(!1);
|
|
235
|
-
}, []),
|
|
244
|
+
}, []), we = l((e, t) => {
|
|
236
245
|
if (S) {
|
|
237
246
|
if (B.current != null && (clearTimeout(B.current), B.current = null), V.current?.(), V.current = null, !t.trim()) {
|
|
238
247
|
z(null), R(!1);
|
|
@@ -267,7 +276,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
267
276
|
C,
|
|
268
277
|
S,
|
|
269
278
|
y
|
|
270
|
-
]), $ = C ? `/${y}/${C}` : `/${y}`,
|
|
279
|
+
]), $ = C ? `/${y}/${C}` : `/${y}`, Te = d(() => {
|
|
271
280
|
let e = Z[0];
|
|
272
281
|
if (e) return a($) === a(`/${y}`) ? e : i(e.items ?? [], $);
|
|
273
282
|
}, [
|
|
@@ -283,25 +292,26 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
283
292
|
folderPath: C,
|
|
284
293
|
onPathChange: he,
|
|
285
294
|
retry: Q,
|
|
286
|
-
onSearchFiles:
|
|
295
|
+
onSearchFiles: we,
|
|
287
296
|
isSearching: fe,
|
|
288
297
|
searchResults: pe,
|
|
289
|
-
clearSearchResults:
|
|
298
|
+
clearSearchResults: Ce,
|
|
290
299
|
expandedPaths: W,
|
|
291
|
-
loadedPaths:
|
|
292
|
-
onExpandedPathsChange:
|
|
293
|
-
onFolderPopupPathChange:
|
|
300
|
+
loadedPaths: xe,
|
|
301
|
+
onExpandedPathsChange: Se,
|
|
302
|
+
onFolderPopupPathChange: be,
|
|
294
303
|
folderPopupLoadingPaths: me,
|
|
295
304
|
sharedWithMeIds: d(() => b === g.Shared ? P : void 0, [b, P]),
|
|
296
305
|
sharedByMePaths: de,
|
|
297
|
-
currentFolder:
|
|
306
|
+
currentFolder: Te,
|
|
298
307
|
cache: T,
|
|
299
308
|
listingPermissionsCache: O,
|
|
300
309
|
sharedRootMetaRef: L,
|
|
301
310
|
setFolderPath: w,
|
|
302
311
|
invalidateFolders: _e,
|
|
303
312
|
mergeCreatedFolder: ve,
|
|
304
|
-
bumpRetry: ge
|
|
313
|
+
bumpRetry: ge,
|
|
314
|
+
removeSharedRootItems: ye
|
|
305
315
|
};
|
|
306
316
|
};
|
|
307
317
|
//#endregion
|
|
@@ -51,7 +51,9 @@ var b = ({ filesApi: b, bucket: x, rootLabel: S = "My files", activeTab: C = y.M
|
|
|
51
51
|
bucket: x,
|
|
52
52
|
rootLabel: S,
|
|
53
53
|
bumpRetry: L.bumpRetry,
|
|
54
|
-
onNotification: E
|
|
54
|
+
onNotification: E,
|
|
55
|
+
onOperationSuccess: D,
|
|
56
|
+
removeSharedRootItems: L.removeSharedRootItems
|
|
55
57
|
}), V = l({
|
|
56
58
|
filesApi: b,
|
|
57
59
|
bucket: x,
|
|
@@ -1,70 +1,76 @@
|
|
|
1
|
-
import { FileManagerNotificationReason as e } from "../dial-file-manager.types.js";
|
|
2
|
-
import { resolveDialFileApiPath as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { NotificationVariant as
|
|
1
|
+
import { FileManagerNotificationReason as e, FileOperationKind as t } from "../dial-file-manager.types.js";
|
|
2
|
+
import { resolveDialFileApiPath as n } from "../resolve-dial-file-api-path.js";
|
|
3
|
+
import { useCallback as r, useState as i } from "react";
|
|
4
|
+
import { NotificationVariant as a } from "@epam/ai-dial-ui-kit";
|
|
5
5
|
//#region src/files/useDialFileSharing/useDialFileSharing.ts
|
|
6
|
-
var
|
|
7
|
-
let [
|
|
6
|
+
var o = ({ filesApi: o, bucket: s, rootLabel: c, bumpRetry: l, onNotification: u, onOperationSuccess: d, removeSharedRootItems: f }) => {
|
|
7
|
+
let [p, m] = i(!1), [h, g] = i(!1);
|
|
8
8
|
return {
|
|
9
|
-
isUnsharing:
|
|
10
|
-
isRemovingAccess:
|
|
11
|
-
onUnshareFiles:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
let
|
|
9
|
+
isUnsharing: p,
|
|
10
|
+
isRemovingAccess: h,
|
|
11
|
+
onUnshareFiles: r((r) => {
|
|
12
|
+
r.length !== 0 && (async () => {
|
|
13
|
+
m(!0);
|
|
14
|
+
let i = r.map((e) => {
|
|
15
|
+
let t = e.bucket ?? s;
|
|
16
16
|
return {
|
|
17
|
-
bucket:
|
|
18
|
-
path:
|
|
17
|
+
bucket: t,
|
|
18
|
+
path: n(e, t, c)
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
try {
|
|
22
|
-
await
|
|
22
|
+
await o.discardShared(i), f?.(r.map((e) => e.name)), d?.({
|
|
23
|
+
kind: t.FilesUnshared,
|
|
24
|
+
name: r[0].name,
|
|
25
|
+
count: r.length
|
|
26
|
+
}), l();
|
|
23
27
|
} catch {
|
|
24
|
-
|
|
25
|
-
variant:
|
|
28
|
+
u?.({
|
|
29
|
+
variant: a.Error,
|
|
26
30
|
reason: e.UnshareFailed
|
|
27
31
|
});
|
|
28
32
|
} finally {
|
|
29
|
-
|
|
33
|
+
m(!1);
|
|
30
34
|
}
|
|
31
35
|
})();
|
|
32
36
|
}, [
|
|
33
|
-
o,
|
|
34
37
|
s,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
c,
|
|
39
|
+
u,
|
|
40
|
+
d,
|
|
41
|
+
f,
|
|
42
|
+
o,
|
|
43
|
+
l
|
|
38
44
|
]),
|
|
39
|
-
onRemoveFilesAccess:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let r =
|
|
43
|
-
let
|
|
45
|
+
onRemoveFilesAccess: r((t) => {
|
|
46
|
+
t.length !== 0 && (async () => {
|
|
47
|
+
g(!0);
|
|
48
|
+
let r = t.map((e) => {
|
|
49
|
+
let t = e.bucket ?? s;
|
|
44
50
|
return {
|
|
45
|
-
bucket:
|
|
46
|
-
path:
|
|
51
|
+
bucket: t,
|
|
52
|
+
path: n(e, t, c)
|
|
47
53
|
};
|
|
48
54
|
});
|
|
49
55
|
try {
|
|
50
|
-
await
|
|
56
|
+
await o.revokeAccess(r), l();
|
|
51
57
|
} catch {
|
|
52
|
-
|
|
53
|
-
variant:
|
|
58
|
+
u?.({
|
|
59
|
+
variant: a.Error,
|
|
54
60
|
reason: e.RemoveAccessFailed
|
|
55
61
|
});
|
|
56
62
|
} finally {
|
|
57
|
-
|
|
63
|
+
g(!1);
|
|
58
64
|
}
|
|
59
65
|
})();
|
|
60
66
|
}, [
|
|
61
|
-
o,
|
|
62
67
|
s,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
c,
|
|
69
|
+
u,
|
|
70
|
+
o,
|
|
71
|
+
l
|
|
66
72
|
])
|
|
67
73
|
};
|
|
68
74
|
};
|
|
69
75
|
//#endregion
|
|
70
|
-
export {
|
|
76
|
+
export { o as useDialFileSharing };
|
package/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { CatalogItemDetailsFetchResult } from '@epam/ai-dial-catalog';
|
|
|
20
20
|
import { CatalogItemLimits } from '@epam/ai-dial-catalog';
|
|
21
21
|
import { CatalogItemOverview } from '@epam/ai-dial-catalog';
|
|
22
22
|
import { CatalogItemTabData } from '@epam/ai-dial-catalog';
|
|
23
|
+
import { CatalogTabCreateMenu } from '@epam/ai-dial-catalog';
|
|
23
24
|
import { ChangeEvent } from 'react';
|
|
24
25
|
import { Conversation } from '@epam/ai-dial-chat-shared';
|
|
25
26
|
import { ConversationListItemDto } from '@epam/ai-dial-chat-api-client';
|
|
@@ -1742,7 +1743,9 @@ export declare enum FileOperationKind {
|
|
|
1742
1743
|
FilesMoved = "filesMoved",
|
|
1743
1744
|
/** A copy whose every item landed in its own source folder (Duplicate). */
|
|
1744
1745
|
FileDuplicated = "fileDuplicated",
|
|
1745
|
-
FilesDuplicated = "filesDuplicated"
|
|
1746
|
+
FilesDuplicated = "filesDuplicated",
|
|
1747
|
+
/** One or more shared-with-me items were removed from the Shared tab. */
|
|
1748
|
+
FilesUnshared = "filesUnshared"
|
|
1746
1749
|
}
|
|
1747
1750
|
|
|
1748
1751
|
/**
|
|
@@ -4927,6 +4930,8 @@ export declare interface UseCatalogEditNavigationResult {
|
|
|
4927
4930
|
createOptions: DropdownItem[];
|
|
4928
4931
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
4929
4932
|
createSearch: CatalogCreateSearch | undefined;
|
|
4933
|
+
/** The Create menu narrowed to each entity type; models have no entry since they cannot be created. */
|
|
4934
|
+
createMenuByType: Partial<Record<CatalogEntityType, CatalogTabCreateMenu>>;
|
|
4930
4935
|
}
|
|
4931
4936
|
|
|
4932
4937
|
/**
|
|
@@ -5518,6 +5523,11 @@ export declare interface UseDialFileListingResult {
|
|
|
5518
5523
|
mergeCreatedFolder: (parentApiPath: string, created: CreateFolderResponseDto, inheritedPermissions?: string[]) => void;
|
|
5519
5524
|
/** Forces the listing effect to re-fetch the currently browsed folder. */
|
|
5520
5525
|
bumpRetry: () => void;
|
|
5526
|
+
/**
|
|
5527
|
+
* Drops the named root rows from the Shared tab's cached listing, so an
|
|
5528
|
+
* unshared item disappears at once instead of waiting for the refetch.
|
|
5529
|
+
*/
|
|
5530
|
+
removeSharedRootItems: (names: string[]) => void;
|
|
5521
5531
|
}
|
|
5522
5532
|
|
|
5523
5533
|
/**
|
|
@@ -5839,7 +5849,7 @@ export declare interface UseDialFileMutationsResult {
|
|
|
5839
5849
|
* shared retry counter after each mutation settles rather than holding its
|
|
5840
5850
|
* own cache copy.
|
|
5841
5851
|
*/
|
|
5842
|
-
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
5852
|
+
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, onOperationSuccess, removeSharedRootItems, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
5843
5853
|
|
|
5844
5854
|
/** Options accepted by `useDialFileSharing`. */
|
|
5845
5855
|
export declare interface UseDialFileSharingOptions {
|
|
@@ -5853,6 +5863,10 @@ export declare interface UseDialFileSharingOptions {
|
|
|
5853
5863
|
bumpRetry: () => void;
|
|
5854
5864
|
/** Called when a sharing mutation fails and should surface a toast notification. */
|
|
5855
5865
|
onNotification?: (notification: FileManagerNotification) => void;
|
|
5866
|
+
/** Called with a structured event once an unshare succeeds, so the host can show its success toast. */
|
|
5867
|
+
onOperationSuccess?: (event: FileOperationSuccessEvent) => void;
|
|
5868
|
+
/** Removes the unshared root rows from the cached Shared listing ahead of the refetch. */
|
|
5869
|
+
removeSharedRootItems?: (names: string[]) => void;
|
|
5856
5870
|
}
|
|
5857
5871
|
|
|
5858
5872
|
/** Values returned by `useDialFileSharing`. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-hooks",
|
|
3
3
|
"description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
|
|
4
|
-
"version": "1.3.0-dev.
|
|
4
|
+
"version": "1.3.0-dev.14",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@epam/ai-dial-chat-api-client": "1.3.0-dev.
|
|
114
|
+
"@epam/ai-dial-chat-api-client": "1.3.0-dev.14",
|
|
115
115
|
"dompurify": "3.4.16",
|
|
116
116
|
"fflate": "^0.8.3",
|
|
117
117
|
"lru-cache": "^10.4.3",
|
|
@@ -120,21 +120,21 @@
|
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"react": "^19.2.8",
|
|
123
|
-
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.
|
|
124
|
-
"@epam/ai-dial-attachment-input": "1.3.0-dev.
|
|
125
|
-
"@epam/ai-dial-catalog": "1.3.0-dev.
|
|
126
|
-
"@epam/ai-dial-chat-overlay": "1.3.0-dev.
|
|
127
|
-
"@epam/ai-dial-chat-shared": "1.3.0-dev.
|
|
128
|
-
"@epam/ai-dial-mcp-apps": "1.3.0-dev.
|
|
129
|
-
"@epam/ai-dial-publish-panel": "1.3.0-dev.
|
|
130
|
-
"@epam/ai-dial-quotations": "1.3.0-dev.
|
|
123
|
+
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.14",
|
|
124
|
+
"@epam/ai-dial-attachment-input": "1.3.0-dev.14",
|
|
125
|
+
"@epam/ai-dial-catalog": "1.3.0-dev.14",
|
|
126
|
+
"@epam/ai-dial-chat-overlay": "1.3.0-dev.14",
|
|
127
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.14",
|
|
128
|
+
"@epam/ai-dial-mcp-apps": "1.3.0-dev.14",
|
|
129
|
+
"@epam/ai-dial-publish-panel": "1.3.0-dev.14",
|
|
130
|
+
"@epam/ai-dial-quotations": "1.3.0-dev.14",
|
|
131
131
|
"@epam/ai-dial-react-file-manager": "^0.3.0",
|
|
132
|
-
"@epam/ai-dial-scheduled-tasks": "1.3.0-dev.
|
|
133
|
-
"@epam/ai-dial-share": "1.3.0-dev.
|
|
134
|
-
"@epam/ai-dial-skill-editor": "1.3.0-dev.
|
|
135
|
-
"@epam/ai-dial-source-panel": "1.3.0-dev.
|
|
136
|
-
"@epam/ai-dial-ui-kit": "^0.15.
|
|
137
|
-
"@epam/ai-dial-usage-dashboard": "1.3.0-dev.
|
|
132
|
+
"@epam/ai-dial-scheduled-tasks": "1.3.0-dev.14",
|
|
133
|
+
"@epam/ai-dial-share": "1.3.0-dev.14",
|
|
134
|
+
"@epam/ai-dial-skill-editor": "1.3.0-dev.14",
|
|
135
|
+
"@epam/ai-dial-source-panel": "1.3.0-dev.14",
|
|
136
|
+
"@epam/ai-dial-ui-kit": "^0.15.1",
|
|
137
|
+
"@epam/ai-dial-usage-dashboard": "1.3.0-dev.14",
|
|
138
138
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
139
139
|
"@epam/pdf-highlighter-kit": "^0.0.19",
|
|
140
140
|
"@mcp-ui/client": "^7.1.1"
|