@epam/ai-dial-chat-hooks 1.1.0-dev.422 → 1.1.0-dev.426

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.
Files changed (178) hide show
  1. package/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
  2. package/api-transport/create-csrf-middleware.js +21 -0
  3. package/api-transport/create-unauthorized-middleware.js +41 -0
  4. package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
  5. package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
  6. package/attachments.js +3 -2
  7. package/catalog/catalog-derivations.js +10 -0
  8. package/catalog/catalog-primary-action.js +21 -0
  9. package/catalog/create-publish-api.js +27 -0
  10. package/catalog/deployment-endpoint-url.js +34 -0
  11. package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
  12. package/catalog/entity-details.js +6 -0
  13. package/catalog/map-deployment-limits-to-catalog.js +73 -0
  14. package/catalog/map-deployment-limits-to-input.js +14 -0
  15. package/catalog/map-deployment-to-catalog-item.js +92 -0
  16. package/catalog/map-entity-details-to-catalog.js +350 -0
  17. package/catalog/map-prompt-to-catalog-item.js +49 -0
  18. package/catalog/map-skill-to-catalog-item.js +123 -0
  19. package/catalog/mcp-endpoint-url.js +26 -0
  20. package/catalog/publish.js +18 -0
  21. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
  22. package/catalog/useCatalogItemDetails.js +101 -0
  23. package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
  24. package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
  25. package/catalog/usePublishFolders/usePublishFolders.js +72 -0
  26. package/catalog.js +22 -3
  27. package/conversation/announcement-message.js +42 -0
  28. package/conversation/conversation-transfer/async.js +18 -0
  29. package/conversation/conversation-transfer/attachment-refs.js +11 -0
  30. package/conversation/conversation-transfer/build-upload-path.js +27 -0
  31. package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
  32. package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
  33. package/conversation/conversation-transfer/export-conversation.js +32 -0
  34. package/conversation/conversation-transfer/import-conversation.js +93 -0
  35. package/conversation/conversation-transfer/progress.js +39 -0
  36. package/conversation/conversation-transfer/queue.js +84 -0
  37. package/conversation/conversation-transfer/types.js +9 -0
  38. package/conversation/conversation-transfer/zip-export.js +19 -0
  39. package/conversation/conversation-transfer/zip-import.js +29 -0
  40. package/conversation/create-chat-stream-api.js +96 -0
  41. package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
  42. package/conversation/display-name-watch.js +5 -0
  43. package/conversation/footer-message.js +23 -0
  44. package/conversation/get-model-id-from-conversation-id.js +14 -0
  45. package/conversation/greeting.js +7 -0
  46. package/conversation/message-factory.js +19 -0
  47. package/conversation/message-utils.js +13 -0
  48. package/conversation/overlay-messages.js +8 -0
  49. package/conversation/quick-app-conversation-starters.js +29 -0
  50. package/conversation/starter-option.js +27 -0
  51. package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
  52. package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
  53. package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
  54. package/conversation/useConversationExport/useConversationExport.js +285 -0
  55. package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
  56. package/conversation/useConversationHandlers/message-factory.js +21 -0
  57. package/conversation/useConversationHandlers/message-utils.js +8 -0
  58. package/conversation/useConversationHandlers/starter-option.js +11 -0
  59. package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
  60. package/conversation/useConversationImport/useConversationImport.js +239 -0
  61. package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
  62. package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
  63. package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
  64. package/conversation/useConversationStream/apply-chunk.js +78 -0
  65. package/conversation/useConversationStream/buffered-generation.js +18 -0
  66. package/conversation/useConversationStream/conversation-path.js +8 -0
  67. package/conversation/useConversationStream/generation-resume.js +126 -0
  68. package/conversation/useConversationStream/useConversationStream.js +148 -0
  69. package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
  70. package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
  71. package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
  72. package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
  73. package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
  74. package/conversation-sources.js +1 -1
  75. package/conversation-transfer.js +7 -3
  76. package/conversation.d.ts +66 -0
  77. package/conversation.js +31 -2
  78. package/file-manager.d.ts +3 -4
  79. package/file-manager.js +28 -3
  80. package/files/annotation.js +15 -0
  81. package/files/attachment-canvas.js +218 -0
  82. package/files/attachment-dto-to-display.js +15 -0
  83. package/files/attachment-types.js +16 -0
  84. package/files/create-files-api.js +40 -0
  85. package/files/create-upload-file-with-progress.js +42 -0
  86. package/files/dial-file-manager-copy-move.util.js +55 -0
  87. package/files/dial-file-manager-mapping.util.js +140 -0
  88. package/files/dial-file-manager-path.util.js +72 -0
  89. package/files/dial-file-manager.model.js +25 -0
  90. package/files/dial-file-manager.types.js +10 -0
  91. package/files/dial-file-to-attachment.js +37 -0
  92. package/files/dial-file.js +30 -0
  93. package/files/dial-files-api.js +6 -0
  94. package/files/download-destination.js +6 -0
  95. package/files/file-manager-variant.js +11 -0
  96. package/files/file-name.js +19 -0
  97. package/files/prepare-download-destination.js +24 -0
  98. package/files/resolve-dial-file-api-path.js +33 -0
  99. package/files/source-content.js +37 -0
  100. package/files/useDialFileListing/useDialFileListing.js +295 -0
  101. package/files/useDialFileManager/useDialFileManager.js +146 -0
  102. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
  103. package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
  104. package/files/useDialFileMutations/useDialFileMutations.js +359 -0
  105. package/files/useDialFileSharing/useDialFileSharing.js +70 -0
  106. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
  107. package/index.d.ts +69 -4
  108. package/index.js +134 -28
  109. package/mcp-apps/mcp-apps-api-client.js +48 -0
  110. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
  111. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
  112. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
  113. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
  114. package/mcp-apps.js +6 -2
  115. package/oauth/authorize-url.js +12 -0
  116. package/oauth/handshake.js +65 -0
  117. package/oauth/popup.js +29 -0
  118. package/oauth/toolset-id.js +10 -0
  119. package/oauth/types.js +24 -0
  120. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
  121. package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
  122. package/oauth.js +9 -3
  123. package/package.json +35 -23
  124. package/prompt/export-prompt.js +28 -0
  125. package/prompt/prompt-resource.js +15 -0
  126. package/prompt/prompt.js +12 -0
  127. package/prompt/usePromptsState/usePromptsState.js +42 -0
  128. package/scheduled-task/scheduled-task-mapping.js +6 -0
  129. package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
  130. package/scheduled-tasks.js +3 -2
  131. package/scroll-anchoring.js +1 -1
  132. package/shared/application-schema.js +4 -0
  133. package/shared/browser-timezone.js +10 -0
  134. package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
  135. package/shared/custom-apps.js +30 -0
  136. package/shared/external-services.js +18 -0
  137. package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
  138. package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
  139. package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
  140. package/shared/toolset-login-events.js +13 -0
  141. package/sharing.js +3 -3
  142. package/skill/skill-file-batch-validation.js +48 -0
  143. package/skill/skill-file-preview.js +15 -0
  144. package/skill/skill-manifest.js +70 -0
  145. package/skill/skill-types.js +15 -0
  146. package/skill/skill.js +48 -0
  147. package/skill/useSkillEditorLoad.js +103 -0
  148. package/skill/useSkillEditorSubmit.js +135 -0
  149. package/skill/useSkillFileActions.js +99 -0
  150. package/skill/useSkillFilePreview.js +29 -0
  151. package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
  152. package/skill-editor.js +8 -3
  153. package/skills-state.js +1 -1
  154. package/source-content.d.ts +29 -0
  155. package/source-content.js +2 -0
  156. package/usage/useUsageData/useUsageData.js +32 -0
  157. package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
  158. package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
  159. package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
  160. package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
  161. package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
  162. package/useToolsMenu/useToolsMenu.js +50 -0
  163. package/useViewportWidth/useViewportWidth.js +12 -0
  164. package/utils.js +17 -7
  165. package/viewport-layout.js +4 -2
  166. package/attachment-types-AAoN9E95.js +0 -7760
  167. package/browser-Btsa0Lmr.js +0 -607
  168. package/skill-manifest-CeG6-WSK.js +0 -4056
  169. package/useAttachmentValidation-CkMTd5lA.js +0 -102
  170. package/useConversationImport-CDRs7JF1.js +0 -826
  171. package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
  172. package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
  173. package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
  174. package/useSkillFileActions-B-VaGD20.js +0 -373
  175. package/useSkillFilePreview-B5o1n_0F.js +0 -1244
  176. package/useToolsMenu-zURpMEn1.js +0 -1882
  177. package/useToolsetLogin-B05m134e.js +0 -195
  178. package/useUsageData-D7BxloKZ.js +0 -201
@@ -0,0 +1,359 @@
1
+ import { FileManagerNotificationReason as e, FileNameValidationErrorReason as t, FileOperationKind as n } from "../dial-file-manager.types.js";
2
+ import { RESERVED_MARKER_NAME as r } from "../dial-file-manager.model.js";
3
+ import { formatOperationFolderName as i, getVirtualPathName as a, hasForbiddenNameSymbols as o, parseNewFolderVirtualPath as s, resolveOwnerCoords as c } from "../dial-file-manager-path.util.js";
4
+ import { getParentFolderPath as l, resolveDialFileApiPath as u, virtualPathToApiPath as d } from "../resolve-dial-file-api-path.js";
5
+ import { prepareCopyItems as f, prepareMoveRenameItems as p } from "../dial-file-manager-copy-move.util.js";
6
+ import { findFirstSuccessfulCopyMoveItem as m } from "../dial-file-manager-mapping.util.js";
7
+ import { DownloadDestinationType as h } from "../download-destination.js";
8
+ import { useCallback as g, useRef as _, useState as v } from "react";
9
+ import { ArchiveItemDtoNodeTypeEnum as y, DeleteItemDtoNodeTypeEnum as b, RenameItemDtoNodeTypeEnum as x } from "@epam/ai-dial-chat-api-client";
10
+ import { NOT_ALLOWED_SYMBOLS as S, NotificationVariant as C } from "@epam/ai-dial-ui-kit";
11
+ import { DialFileManagerTabs as w, DialFileNodeType as T } from "@epam/ai-dial-react-file-manager";
12
+ //#region src/files/useDialFileMutations/useDialFileMutations.ts
13
+ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, currentFolder: j, sharedRootMetaRef: M, listingPermissionsCache: N, invalidateFolders: P, bumpRetry: F, mergeCreatedFolder: I, setFolderPath: L, onNotification: R, onOperationSuccess: z, downloadDestination: B, forbiddenSymbolsRegExp: V }) => {
14
+ let [ee, H] = v(!1), [te, U] = v(!1), [ne, W] = v(!1), [G, K] = v(!1), [q, J] = v(!1), [Y, X] = v(!1), Z = _(null), Q = _(null), $ = g((e, n) => {
15
+ let i = null;
16
+ if (!e || e.trim() === "") i = { reason: t.Empty };
17
+ else if (o(e, V)) i = {
18
+ reason: t.ForbiddenSymbols,
19
+ symbols: S
20
+ };
21
+ else if (e.startsWith(".")) i = { reason: t.LeadingDot };
22
+ else if (e === r) i = { reason: t.ReservedName };
23
+ else if (e.length > 255) i = {
24
+ reason: t.TooLong,
25
+ maxLength: 255
26
+ };
27
+ else {
28
+ let r = n.items ?? [], a = e.toLowerCase(), o = r.find((e) => e.name.toLowerCase() === a);
29
+ o && (i = {
30
+ reason: t.DuplicateName,
31
+ existingName: o.name
32
+ });
33
+ }
34
+ return Q.current = i, i;
35
+ }, [V]), re = g(async (t, r, i) => {
36
+ let { parentVirtualPath: a, name: o } = s(r, O), l = d(a, O), u = j && A === l ? j : {
37
+ id: l,
38
+ path: l,
39
+ name: a.split("/").filter(Boolean).pop() ?? "",
40
+ folderId: l,
41
+ nodeType: T.FOLDER,
42
+ items: []
43
+ }, f = Q.current;
44
+ if (Q.current = null, $(o, u) || f) return;
45
+ H(!0);
46
+ let { bucket: p, path: m } = k === w.Shared ? c(l, M.current, D) : {
47
+ bucket: D,
48
+ path: l
49
+ };
50
+ try {
51
+ I(l, await E.createFolder({
52
+ bucket: p,
53
+ parentPath: m,
54
+ name: o
55
+ }), N.get(l)), F(), z?.({
56
+ kind: n.FolderCreated,
57
+ name: o
58
+ });
59
+ } catch {
60
+ R?.({
61
+ variant: C.Error,
62
+ reason: e.FolderCreateFailed
63
+ });
64
+ } finally {
65
+ H(!1);
66
+ }
67
+ }, [
68
+ k,
69
+ D,
70
+ j,
71
+ E,
72
+ A,
73
+ $,
74
+ O,
75
+ N,
76
+ I,
77
+ F,
78
+ z,
79
+ M,
80
+ R
81
+ ]), ie = g((t) => {
82
+ (async () => {
83
+ U(!0);
84
+ try {
85
+ let e = t.length === 1 ? t[0].nodeType === T.ITEM ? t[0].name : `${t[0].name}.zip` : "files.zip", r = await B.resolveDestination(e, t.length === 1 && t[0].nodeType === T.ITEM ? t[0].contentType ?? "application/octet-stream" : "application/zip");
86
+ if (r.type === h.Cancelled) return;
87
+ if (t.length === 1 && t[0].nodeType === T.ITEM) {
88
+ let e = t[0];
89
+ if (!e.bucket) throw Error("File is missing bucket");
90
+ let i = u(e, e.bucket, O), a = await E.downloadFile(e.bucket, i);
91
+ if (!a.ok) throw Error(`Download failed with status ${a.status}`);
92
+ let o = await B.triggerDownload(a, e.name, r);
93
+ z?.({
94
+ kind: n.FileDownloaded,
95
+ name: o,
96
+ count: 1
97
+ });
98
+ } else {
99
+ let i = t.map((e) => ({
100
+ bucket: e.bucket ?? D,
101
+ path: u(e, e.bucket ?? D, O),
102
+ name: e.name,
103
+ nodeType: e.nodeType === T.FOLDER ? y.Folder : y.Item
104
+ })), a = await E.downloadArchive(i);
105
+ if (!a.ok) throw Error(`Download failed with status ${a.status}`);
106
+ let o = await B.triggerDownload(a, e, r);
107
+ t.length === 1 ? z?.({
108
+ kind: n.FileDownloaded,
109
+ name: o
110
+ }) : z?.({
111
+ kind: n.FilesDownloaded,
112
+ count: t.length
113
+ });
114
+ }
115
+ } catch {
116
+ R?.({
117
+ variant: C.Error,
118
+ reason: t.length === 1 ? e.DownloadFileFailed : e.DownloadFilesFailed
119
+ });
120
+ } finally {
121
+ U(!1);
122
+ }
123
+ })();
124
+ }, [
125
+ D,
126
+ O,
127
+ z,
128
+ R,
129
+ E,
130
+ B
131
+ ]), ae = g((t, n) => {
132
+ t.length !== 0 && (async () => {
133
+ W(!0);
134
+ let r = t.map((e) => {
135
+ let t = e.nodeType === T.FOLDER, n = d(e.sourceUrl, O), r = t ? n : n.replace(/\/$/, ""), i = a(e.sourceUrl, r), { bucket: o, path: s } = k === w.Shared ? c(r, M.current, D) : {
136
+ bucket: D,
137
+ path: r
138
+ };
139
+ return {
140
+ bucket: o,
141
+ path: s,
142
+ name: i,
143
+ nodeType: t ? b.Folder : b.Item
144
+ };
145
+ });
146
+ try {
147
+ let { results: t } = await E.deleteFiles(r), i = t.filter((e) => !e.success), a = i.length, o = t.length - a, s = t.find((e) => e.success), c = r.find((e) => e.path === s?.path) ?? r[0];
148
+ if (o > 0 && R?.({
149
+ variant: C.Success,
150
+ reason: e.FilesDeleted,
151
+ count: o,
152
+ name: c?.name,
153
+ folder: n || O
154
+ }), a > 0) {
155
+ let t = i.slice(0, 3).map((e) => r.find((t) => t.path === e.path)?.name ?? e.path), n = a - t.length;
156
+ R?.({
157
+ variant: C.Error,
158
+ reason: e.FilesDeletePartiallyFailed,
159
+ names: t,
160
+ restCount: n
161
+ });
162
+ }
163
+ } catch {
164
+ R?.({
165
+ variant: C.Error,
166
+ reason: e.DeleteFailed
167
+ });
168
+ }
169
+ let i = r.filter((e) => e.nodeType === b.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
170
+ P([...new Set(r.map((e) => {
171
+ if (e.nodeType === b.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
172
+ let t = e.path.lastIndexOf("/");
173
+ return t > 0 ? e.path.slice(0, t + 1) : "";
174
+ }))]), i.some((e) => A === e || A.startsWith(e)) && L((e) => e.replace(/[^/]+\/$/, "")), F(), W(!1);
175
+ })();
176
+ }, [
177
+ k,
178
+ D,
179
+ O,
180
+ A,
181
+ R,
182
+ E,
183
+ M,
184
+ P,
185
+ F,
186
+ L
187
+ ]), oe = g((e, n) => {
188
+ if (!e || e.trim() === "") return { reason: t.Empty };
189
+ if (e === r) return { reason: t.ReservedName };
190
+ if (o(e, V)) return {
191
+ reason: t.ForbiddenSymbols,
192
+ symbols: S
193
+ };
194
+ if (e.length > 255) return {
195
+ reason: t.TooLong,
196
+ maxLength: 255
197
+ };
198
+ let i = j?.items ?? [], a = e.toLowerCase(), s = i.find((e) => e.path !== n.path && e.name.toLowerCase() === a);
199
+ return s ? {
200
+ reason: t.DuplicateName,
201
+ existingName: s.name
202
+ } : null;
203
+ }, [V, j]), se = g((t, r) => {
204
+ if (t.length === 0 || q || Y) return;
205
+ let a = new AbortController();
206
+ Z.current = a, (async () => {
207
+ J(!0);
208
+ let o = f(t, D, O), s = o.map(({ dto: e }) => e);
209
+ try {
210
+ let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
211
+ if (l > 0) {
212
+ let e = m(o, t);
213
+ z?.({
214
+ kind: l === 1 ? n.FileCopied : n.FilesCopied,
215
+ name: e?.destinationName,
216
+ count: l,
217
+ destinationFolderName: i(r, O)
218
+ });
219
+ }
220
+ c > 0 && c < t.length ? R?.({
221
+ variant: C.Error,
222
+ reason: e.CopyPartiallyFailed,
223
+ count: c
224
+ }) : c === t.length && R?.({
225
+ variant: C.Error,
226
+ reason: e.CopyFailed
227
+ });
228
+ } catch {
229
+ a.signal.aborted || R?.({
230
+ variant: C.Error,
231
+ reason: e.CopyFailed
232
+ });
233
+ } finally {
234
+ P([...new Set(s.flatMap((e) => [l(e.sourcePath), l(e.destinationPath)]))]), F(), J(!1), Z.current = null;
235
+ }
236
+ })();
237
+ }, [
238
+ D,
239
+ O,
240
+ R,
241
+ z,
242
+ E,
243
+ q,
244
+ Y,
245
+ P,
246
+ F
247
+ ]), ce = g(() => {
248
+ Z.current?.abort();
249
+ }, []);
250
+ return {
251
+ isCreatingFolder: ee,
252
+ isDownloading: te,
253
+ isDeleting: ne,
254
+ isRenaming: G,
255
+ isCopying: q,
256
+ isMoving: Y,
257
+ onCreateFolder: re,
258
+ onCreateFolderValidate: $,
259
+ onDownloadFiles: ie,
260
+ onDeleteFiles: ae,
261
+ onRenameValidate: oe,
262
+ onMoveToFiles: g((t, r, o) => {
263
+ if (t.length === 0 || q || Y || G) return;
264
+ let { renameDtos: s, preparedMoveItems: c } = p(t, D, O), u = c.map(({ dto: e }) => e), d = new AbortController();
265
+ u.length > 0 && (Z.current = d), (async () => {
266
+ s.length > 0 && K(!0), u.length > 0 && X(!0);
267
+ let [t, r] = await Promise.all([(async () => {
268
+ if (s.length === 0) return {
269
+ results: [],
270
+ threw: !1
271
+ };
272
+ try {
273
+ let { results: e } = await E.renameFiles(s);
274
+ return {
275
+ results: e,
276
+ threw: !1
277
+ };
278
+ } catch {
279
+ return {
280
+ results: [],
281
+ threw: !0
282
+ };
283
+ }
284
+ })(), (async () => {
285
+ if (u.length === 0) return {
286
+ results: [],
287
+ threw: !1,
288
+ aborted: !1
289
+ };
290
+ try {
291
+ let { results: e } = await E.moveFiles(u, d.signal);
292
+ return {
293
+ results: e,
294
+ threw: !1,
295
+ aborted: !1
296
+ };
297
+ } catch {
298
+ return {
299
+ results: [],
300
+ threw: !0,
301
+ aborted: d.signal.aborted
302
+ };
303
+ }
304
+ })()]), f = t.threw ? s.length : t.results.filter((e) => !e.success).length, p = r.threw && r.aborted, h = p ? 0 : u.length, g = p ? 0 : r.threw ? u.length : r.results.filter((e) => !e.success).length, _ = r.threw ? 0 : r.results.filter((e) => e.success).length, v = s.length + h, y = f + g, b = g > 0;
305
+ if (_ > 0) {
306
+ let e = m(c, r.results);
307
+ z?.({
308
+ kind: _ === 1 ? n.FileMoved : n.FilesMoved,
309
+ name: e?.destinationName,
310
+ count: _,
311
+ destinationFolderName: i(o, O)
312
+ });
313
+ }
314
+ if (s.length === 1 && f === 0) {
315
+ let [e] = s;
316
+ z?.({
317
+ kind: n.FileRenamed,
318
+ name: a(e.destinationPath, e.destinationPath),
319
+ isFolder: e.nodeType === x.Folder
320
+ });
321
+ }
322
+ y > 0 && (y === v ? R?.({
323
+ variant: C.Error,
324
+ reason: b ? e.MoveFailed : e.RenameFailed
325
+ }) : R?.({
326
+ variant: C.Error,
327
+ reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
328
+ count: y
329
+ }));
330
+ let S = s.find((e) => e.nodeType === x.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
331
+ if (S != null) {
332
+ let e = S.sourcePath.endsWith("/") ? S.sourcePath : `${S.sourcePath}/`;
333
+ if (A === e || A.startsWith(e)) {
334
+ let t = S.destinationPath.endsWith("/") ? S.destinationPath : `${S.destinationPath}/`;
335
+ L(A.replace(e, t));
336
+ }
337
+ }
338
+ P([...new Set([...s, ...u].flatMap((e) => [l(e.sourcePath), l(e.destinationPath)]))]), F(), K(!1), X(!1), u.length > 0 && (Z.current = null);
339
+ })();
340
+ }, [
341
+ D,
342
+ O,
343
+ A,
344
+ z,
345
+ R,
346
+ E,
347
+ q,
348
+ Y,
349
+ G,
350
+ P,
351
+ F,
352
+ L
353
+ ]),
354
+ onCopyFiles: se,
355
+ cancelCopyMove: ce
356
+ };
357
+ };
358
+ //#endregion
359
+ export { E as useDialFileMutations };
@@ -0,0 +1,70 @@
1
+ import { FileManagerNotificationReason as e } from "../dial-file-manager.types.js";
2
+ import { resolveDialFileApiPath as t } from "../resolve-dial-file-api-path.js";
3
+ import { useCallback as n, useState as r } from "react";
4
+ import { NotificationVariant as i } from "@epam/ai-dial-ui-kit";
5
+ //#region src/files/useDialFileSharing/useDialFileSharing.ts
6
+ var a = ({ filesApi: a, bucket: o, rootLabel: s, bumpRetry: c, onNotification: l }) => {
7
+ let [u, d] = r(!1), [f, p] = r(!1);
8
+ return {
9
+ isUnsharing: u,
10
+ isRemovingAccess: f,
11
+ onUnshareFiles: n((n) => {
12
+ n.length !== 0 && (async () => {
13
+ d(!0);
14
+ let r = n.map((e) => {
15
+ let n = e.bucket ?? o;
16
+ return {
17
+ bucket: n,
18
+ path: t(e, n, s)
19
+ };
20
+ });
21
+ try {
22
+ await a.discardShared(r), c();
23
+ } catch {
24
+ l?.({
25
+ variant: i.Error,
26
+ reason: e.UnshareFailed
27
+ });
28
+ } finally {
29
+ d(!1);
30
+ }
31
+ })();
32
+ }, [
33
+ o,
34
+ s,
35
+ l,
36
+ a,
37
+ c
38
+ ]),
39
+ onRemoveFilesAccess: n((n) => {
40
+ n.length !== 0 && (async () => {
41
+ p(!0);
42
+ let r = n.map((e) => {
43
+ let n = e.bucket ?? o;
44
+ return {
45
+ bucket: n,
46
+ path: t(e, n, s)
47
+ };
48
+ });
49
+ try {
50
+ await a.revokeAccess(r), c();
51
+ } catch {
52
+ l?.({
53
+ variant: i.Error,
54
+ reason: e.RemoveAccessFailed
55
+ });
56
+ } finally {
57
+ p(!1);
58
+ }
59
+ })();
60
+ }, [
61
+ o,
62
+ s,
63
+ l,
64
+ a,
65
+ c
66
+ ])
67
+ };
68
+ };
69
+ //#endregion
70
+ export { a as useDialFileSharing };
@@ -0,0 +1,156 @@
1
+ import { DialFilesApiUploadMode as e } from "../dial-files-api.js";
2
+ import { FileManagerNotificationReason as t } from "../dial-file-manager.types.js";
3
+ import "../dial-file-manager.model.js";
4
+ import { resolveOwnerCoords as n } from "../dial-file-manager-path.util.js";
5
+ import { virtualPathToApiPath as r } from "../resolve-dial-file-api-path.js";
6
+ import { updateEntry as i } from "../dial-file-manager-mapping.util.js";
7
+ import { sanitizeFileName as a } from "../file-name.js";
8
+ import { FileUploadStatus as o } from "@epam/ai-dial-chat-shared";
9
+ import { useCallback as s, useRef as c, useState as l } from "react";
10
+ import { NotificationVariant as u } from "@epam/ai-dial-ui-kit";
11
+ import { DialFileManagerTabs as d } from "@epam/ai-dial-react-file-manager";
12
+ //#region src/files/useDialFileUploadBatch/useDialFileUploadBatch.ts
13
+ var f = 5, p = (e) => e.error ? `${e.path} (${e.error})` : e.path, m = (e) => {
14
+ let t = e.slice(0, f);
15
+ return {
16
+ names: t.map(p),
17
+ restCount: e.length - t.length
18
+ };
19
+ }, h = (e, t) => `${e}${t}/`, g = (e) => /\.zip$/i.test(e), _ = (e) => {
20
+ let [t] = e;
21
+ if (!(e.length !== 1 || t == null)) return g(t.fileContent.name) && !g(t.name) ? t : void 0;
22
+ }, v = ({ filesApi: f, bucket: p, rootLabel: g, activeTab: v, cache: y, sharedRootMetaRef: b, invalidateFolders: x, bumpRetry: S, onNotification: C }) => {
23
+ let [w, T] = l(null), E = c(null), D = s((e, n, i) => {
24
+ let a = r(i, g);
25
+ T({
26
+ files: [{
27
+ id: `${Date.now()}-archive`,
28
+ name: n,
29
+ status: o.Uploading
30
+ }],
31
+ isOpen: !0
32
+ }), (async () => {
33
+ try {
34
+ let { results: r } = await f.uploadArchive(e, p, h(a, n)), i = r.filter((e) => e.success).length, o = r.filter((e) => !e.success), s = o.length, { names: c, restCount: l } = m(o);
35
+ r.length > 0 && i === 0 ? C?.({
36
+ variant: u.Error,
37
+ reason: t.UploadArchiveFailed,
38
+ names: c,
39
+ restCount: l
40
+ }) : s > 0 && C?.({
41
+ variant: u.Error,
42
+ reason: t.UploadArchivePartiallyFailed,
43
+ count: s,
44
+ names: c,
45
+ restCount: l
46
+ });
47
+ } catch {
48
+ C?.({
49
+ variant: u.Error,
50
+ reason: t.UploadArchiveRequestFailed
51
+ });
52
+ } finally {
53
+ x([a]), S(), T(null);
54
+ }
55
+ })();
56
+ }, [
57
+ p,
58
+ g,
59
+ C,
60
+ f,
61
+ x,
62
+ S
63
+ ]);
64
+ return {
65
+ onUploadFiles: s((a, s) => {
66
+ if (a.length === 0) return;
67
+ let c = _(a);
68
+ if (c != null) {
69
+ D(c.fileContent, c.name, s);
70
+ return;
71
+ }
72
+ let l = new AbortController();
73
+ E.current = l, T({
74
+ files: a.map((e, t) => ({
75
+ id: `${Date.now()}-${t}`,
76
+ name: e.name,
77
+ status: o.Queued
78
+ })),
79
+ isOpen: !0
80
+ });
81
+ let m = r(s, g), { bucket: h, path: w } = v === d.Shared ? n(m, b.current, p) : {
82
+ bucket: p,
83
+ path: m
84
+ }, O = new Set((y.get(m) ?? []).map((e) => e.name.toLowerCase()));
85
+ (async () => {
86
+ let n = 0, r = 0, s = 0, c = async () => {
87
+ for (; n < a.length;) {
88
+ let t = n++, c = a[t];
89
+ if (l.signal.aborted) {
90
+ T((e) => i(e, t, o.Cancelled));
91
+ continue;
92
+ }
93
+ T((e) => i(e, t, {
94
+ status: o.Uploading,
95
+ percent: 0
96
+ }));
97
+ let u = O.has(c.name.toLowerCase()) ? e.Overwrite : e.CreateOnly;
98
+ try {
99
+ await f.uploadFile(h, `${w}${c.name}`, c.fileContent, {
100
+ signal: l.signal,
101
+ uploadMode: u,
102
+ onProgress: (e) => {
103
+ T((n) => i(n, t, {
104
+ status: o.Uploading,
105
+ percent: e
106
+ }));
107
+ }
108
+ }), T((e) => i(e, t, {
109
+ status: o.Completed,
110
+ percent: 100
111
+ })), r += 1;
112
+ } catch {
113
+ let e = l.signal.aborted ? o.Cancelled : o.Failed;
114
+ e === o.Failed && (s += 1), T((n) => i(n, t, e));
115
+ }
116
+ }
117
+ };
118
+ await Promise.all(Array.from({ length: 3 }, () => c())), l.signal.aborted || (r === 0 && s > 0 ? C?.({
119
+ variant: u.Error,
120
+ reason: t.UploadFailed
121
+ }) : C?.({
122
+ variant: u.Success,
123
+ reason: t.UploadCompleted,
124
+ folder: w || g
125
+ })), x([m]), S(), E.current = null, T(null);
126
+ })();
127
+ }, [
128
+ v,
129
+ p,
130
+ y,
131
+ g,
132
+ C,
133
+ f,
134
+ b,
135
+ x,
136
+ S,
137
+ D
138
+ ]),
139
+ onUploadArchive: s((e, t, n) => {
140
+ D(e, t, n);
141
+ }, [D]),
142
+ onValidateUpload: s(async (e, t, n) => {
143
+ for (let t of e) t.name = a(t.name);
144
+ return { valid: !0 };
145
+ }, []),
146
+ uploadBatchState: w,
147
+ cancelUpload: s(() => {
148
+ E.current?.abort();
149
+ }, []),
150
+ clearUploadBatch: s(() => {
151
+ T(null);
152
+ }, [])
153
+ };
154
+ };
155
+ //#endregion
156
+ export { v as useDialFileUploadBatch };
package/index.d.ts CHANGED
@@ -135,6 +135,7 @@ import { ToolMenuItem } from '@epam/ai-dial-chat-shared';
135
135
  import { ToolsetLoginBodyDto } from '@epam/ai-dial-chat-api-client';
136
136
  import { ToolsetLogoutBodyDto } from '@epam/ai-dial-chat-api-client';
137
137
  import { ToolsetsApi } from '@epam/ai-dial-chat-api-client';
138
+ import { TranscriptionApi } from '@epam/ai-dial-chat-api-client';
138
139
  import { UnpublishCatalogEntityDto } from '@epam/ai-dial-chat-api-client';
139
140
  import { UnpublishResultDto } from '@epam/ai-dial-chat-api-client';
140
141
  import { UpdateScheduledTaskBodyDto } from '@epam/ai-dial-chat-api-client';
@@ -324,6 +325,26 @@ export declare enum AttachmentValidationErrorReason {
324
325
  UnsupportedType = "unsupportedType"
325
326
  }
326
327
 
328
+ /** Thrown by `transcribeAudio`; carries a machine-readable `reason` instead of translated text. */
329
+ export declare class AudioTranscriptionError extends Error {
330
+ readonly reason: AudioTranscriptionErrorReason;
331
+ /** The size limit that was exceeded, present only when `reason` is `TooLarge`. */
332
+ readonly limitBytes?: number;
333
+ constructor(reason: AudioTranscriptionErrorReason, limitBytes?: number);
334
+ }
335
+
336
+ /** Reason a {@link useTranscribeAudio} call failed, translation-free — the host maps it to text. */
337
+ export declare enum AudioTranscriptionErrorReason {
338
+ /** No usable ASR model or deployment is configured for the current bucket. */
339
+ Unavailable = "unavailable",
340
+ /** The recording exceeds the caller's configured size limit. */
341
+ TooLarge = "tooLarge",
342
+ /** The upstream ASR provider stayed rate-limited or unavailable after retrying. */
343
+ Busy = "busy",
344
+ /** Recognition failed for any other reason. */
345
+ Failed = "failed"
346
+ }
347
+
327
348
  /** Toolset authentication mechanism as reported by DIAL Core. */
328
349
  export declare enum AuthenticationType {
329
350
  None = "NONE",
@@ -2735,10 +2756,9 @@ export declare type ResolveDownloadUrl = (fileId: string) => string | undefined;
2735
2756
  /**
2736
2757
  * Returns the content type to trust for an external citation source: `contentType`
2737
2758
  * unchanged when it is already an image/audio/PDF/document-renderer marker,
2738
- * otherwise the type implied by `url`'s path extension (`MIMEType.PDF` for
2739
- * `.pdf`, the
2740
- * canonical MIME for `.docx`/`.xlsx`/`.pptx`/`.csv`) when that extension is
2741
- * recognized, otherwise `contentType` unchanged.
2759
+ * otherwise the type implied by `url`'s path extension (`application/pdf` for
2760
+ * `.pdf`, the canonical MIME for `.docx`/`.xlsx`/`.pptx`/`.csv`) when that
2761
+ * extension is recognized, otherwise `contentType` unchanged.
2742
2762
  *
2743
2763
  * Web-search grounding APIs label every reference — PDFs and Office documents
2744
2764
  * included — as `text/markdown`, so a mislabeled `contentType` must not win
@@ -3511,6 +3531,14 @@ export declare const toPublishEntityType: (type: CatalogEntityType) => CatalogPu
3511
3531
  */
3512
3532
  export declare const toPublishRuleDto: (rule: PublicationRule) => PublishRuleDto;
3513
3533
 
3534
+ /** Request shape the host's selected-deployment recognition call accepts. */
3535
+ export declare interface TranscribeWithDeploymentParams {
3536
+ audioUrl: string;
3537
+ mimeType: string;
3538
+ deployment: string;
3539
+ signal: AbortSignal;
3540
+ }
3541
+
3514
3542
  export declare const trimFileNameToByteLimit: (name: string, limit?: number) => string;
3515
3543
 
3516
3544
  /** An error thrown to indicate the caller is unauthenticated. */
@@ -5265,6 +5293,43 @@ export declare type UseToolsMenuResult = {
5265
5293
  restoreToolConfiguration: (configurationValue: Record<string, unknown> | undefined) => void;
5266
5294
  };
5267
5295
 
5296
+ /**
5297
+ * Uploads a complete voice recording to DIAL Core storage and recognizes it,
5298
+ * preferring the configured ASR model and falling back to the selected
5299
+ * deployment. Retries transient upstream failures. Error text is not this
5300
+ * library's concern — callers translate `AudioTranscriptionErrorReason` at
5301
+ * the call site.
5302
+ */
5303
+ export declare const useTranscribeAudio: ({ transcriptionApi, filesApi, transcribeWithDeployment, bucket, asrModelId, selectedDeploymentId, maxSizeBytes, }: UseTranscribeAudioParams) => UseTranscribeAudioResult;
5304
+
5305
+ /** Parameters for {@link useTranscribeAudio}. */
5306
+ export declare interface UseTranscribeAudioParams {
5307
+ /** Already-configured generated-client instance used for the ASR-model path. */
5308
+ transcriptionApi?: Pick<TranscriptionApi, 'transcribeAudio'>;
5309
+ /** Already-configured generated-client instance used to upload the recording. */
5310
+ filesApi: Pick<FilesApi, 'uploadFile'>;
5311
+ /**
5312
+ * Host-configured call for the selected-deployment path. The generated
5313
+ * chat-completions client cannot express this endpoint's `custom_content`
5314
+ * request shape, so the host supplies its own raw request.
5315
+ */
5316
+ transcribeWithDeployment?: (params: TranscribeWithDeploymentParams) => Promise<string>;
5317
+ /** DIAL Core bucket the recording is uploaded into. */
5318
+ bucket: string | undefined | null;
5319
+ /** Recognizes via `transcriptionApi` when set; otherwise `selectedDeploymentId` is used. */
5320
+ asrModelId?: string;
5321
+ /** Deployment id used for recognition when `asrModelId` is not set. */
5322
+ selectedDeploymentId?: string | null;
5323
+ /** Recordings larger than this are rejected with `TooLarge` before upload. */
5324
+ maxSizeBytes: number;
5325
+ }
5326
+
5327
+ /** Return value of {@link useTranscribeAudio}. */
5328
+ export declare interface UseTranscribeAudioResult {
5329
+ /** Uploads and recognizes one complete recording; rejects with an {@link AudioTranscriptionError}. */
5330
+ transcribeAudio: (file: File, signal: AbortSignal) => Promise<string>;
5331
+ }
5332
+
5268
5333
  /**
5269
5334
  * Fetches usage stats via the provided `getUserUsage` function on mount.
5270
5335
  *