@epam/ai-dial-chat-hooks 1.2.0-dev.99 → 1.3.0-dev.5

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 (84) hide show
  1. package/api-error/api-error.js +7 -4
  2. package/catalog/catalog-derivations.js +1 -1
  3. package/catalog/deployment-id.js +8 -2
  4. package/catalog/map-deployment-limits-to-catalog.js +16 -24
  5. package/catalog/map-deployment-limits-to-input.js +81 -9
  6. package/catalog/map-deployment-to-catalog-item.js +34 -34
  7. package/catalog/map-entity-details-to-catalog.js +237 -192
  8. package/catalog/map-skill-to-catalog-item.js +61 -54
  9. package/catalog/publish.js +4 -4
  10. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
  11. package/catalog/useCatalogItemDetails.js +9 -8
  12. package/catalog/usePublishFolders/usePublishFolders.js +1 -1
  13. package/catalog.d.ts +171 -34
  14. package/catalog.js +23 -23
  15. package/conversation/conversation-transfer/export-conversation.js +24 -16
  16. package/conversation/conversation-transfer/import-conversation.js +80 -31
  17. package/conversation/create-chat-stream-api.js +89 -49
  18. package/conversation/get-model-id-from-conversation-id.js +15 -9
  19. package/conversation/message-utils.js +44 -2
  20. package/conversation/stage.js +6 -2
  21. package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
  22. package/conversation/useConversationExport/useConversationExport.js +9 -9
  23. package/conversation/useConversationHandlers/message-utils.js +8 -5
  24. package/conversation/useConversationHandlers/useConversationHandlers.js +181 -167
  25. package/conversation/useConversationImport/useConversationImport.js +123 -121
  26. package/conversation/useConversationPanelItems/useConversationPanelItems.js +49 -31
  27. package/conversation/useConversationStream/frame-scheduler.js +39 -0
  28. package/conversation/useConversationStream/generation-resume.js +122 -64
  29. package/conversation/useConversationStream/useConversationStream.js +298 -118
  30. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  31. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  32. package/conversation-sources.d.ts +1 -1
  33. package/conversation-transfer.d.ts +2 -1
  34. package/conversation.d.ts +218 -22
  35. package/conversation.js +32 -31
  36. package/file-manager-canvas.d.ts +27 -7
  37. package/file-manager.d.ts +87 -32
  38. package/file-manager.js +25 -24
  39. package/files/attachment-canvas.js +67 -44
  40. package/files/dial-file-manager-copy-move.util.js +9 -8
  41. package/files/dial-file-manager-mapping.util.js +2 -1
  42. package/files/dial-file-manager-path.util.js +24 -2
  43. package/files/dial-file-manager.model.js +23 -19
  44. package/files/dial-file-manager.types.js +3 -3
  45. package/files/file-manager-variant.js +1 -1
  46. package/files/resolve-dial-file-api-path.js +11 -12
  47. package/files/useDialFileListing/useDialFileListing.js +140 -127
  48. package/files/useDialFileManager/useDialFileManager.js +139 -135
  49. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  50. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -15
  51. package/files/useDialFileMutations/useDialFileMutations.js +65 -60
  52. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  53. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +28 -23
  54. package/index.d.ts +643 -128
  55. package/index.js +136 -134
  56. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  57. package/oauth/authorize-url.js +3 -3
  58. package/oauth/toolset-id.js +5 -3
  59. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  60. package/oauth.d.ts +34 -2
  61. package/oauth.js +9 -9
  62. package/package.json +19 -23
  63. package/scheduled-task/scheduled-task-description.js +43 -39
  64. package/scheduled-task/scheduled-task-trigger.js +74 -71
  65. package/scheduled-task/use-scheduled-task-runs.js +162 -50
  66. package/scheduled-task/use-scheduled-tasks.js +52 -48
  67. package/scheduled-tasks.d.ts +27 -6
  68. package/scheduled-tasks.js +2 -2
  69. package/shared/application-schema.js +5 -2
  70. package/shared/cron-day-of-month.js +13 -0
  71. package/skill/skill-archive.js +19 -0
  72. package/skill/skill-types.js +8 -7
  73. package/skill/skill.js +52 -29
  74. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +38 -34
  75. package/skill/useSkillEditorLoad.js +65 -59
  76. package/skill/useSkillEditorSubmit.js +105 -93
  77. package/skill/useSkillFileActions.js +70 -58
  78. package/skill-editor.d.ts +62 -13
  79. package/skill-editor.js +9 -9
  80. package/usage/map-user-usage-to-model-limits.js +137 -95
  81. package/usage.d.ts +8 -3
  82. package/usePageFileDrag/usePageFileDrag.js +3 -3
  83. package/utils.d.ts +26 -6
  84. package/utils.js +10 -10
@@ -1,24 +1,24 @@
1
1
  import { FileManagerNotificationReason as e, FileNameValidationErrorReason as t, FileOperationKind as n } from "../dial-file-manager.types.js";
2
2
  import { RESERVED_MARKER_NAME as r } from "../dial-file-manager.model.js";
3
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";
4
+ import { resolveDialFileApiPath as l, virtualPathToApiPath as u } from "../resolve-dial-file-api-path.js";
5
+ import { prepareCopyItems as d, prepareMoveRenameItems as f } from "../dial-file-manager-copy-move.util.js";
6
+ import { findFirstSuccessfulCopyMoveItem as p } from "../dial-file-manager-mapping.util.js";
7
+ import { DownloadDestinationType as m } from "../download-destination.js";
8
+ import { getParentFolderPath as h } from "@epam/ai-dial-chat-shared";
8
9
  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 { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as te } from "@epam/ai-dial-chat-api-client";
10
11
  import { NOT_ALLOWED_SYMBOLS as S, NotificationVariant as C } from "@epam/ai-dial-ui-kit";
11
12
  import { DialFileManagerTabs as w, DialFileNodeType as T } from "@epam/ai-dial-react-file-manager";
12
13
  //#region src/files/useDialFileMutations/useDialFileMutations.ts
13
14
  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 [ne, H] = v(!1), [re, U] = v(!1), [ie, W] = v(!1), [G, K] = v(!1), [q, J] = v(!1), [Y, X] = v(!1), Z = _(null), Q = _(null), $ = g((e, n) => {
15
16
  let i = null;
16
17
  if (!e || e.trim() === "") i = { reason: t.Empty };
17
18
  else if (o(e, V)) i = {
18
19
  reason: t.ForbiddenSymbols,
19
20
  symbols: S
20
21
  };
21
- else if (e.startsWith(".")) i = { reason: t.LeadingDot };
22
22
  else if (e === r) i = { reason: t.ReservedName };
23
23
  else if (e.length > 255) i = {
24
24
  reason: t.TooLong,
@@ -32,8 +32,8 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
32
32
  });
33
33
  }
34
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 : {
35
+ }, [V]), ae = g(async (t, r, i) => {
36
+ let { parentVirtualPath: a, name: o } = s(r, O), l = u(a, O), d = j && A === l ? j : {
37
37
  id: l,
38
38
  path: l,
39
39
  name: a.split("/").filter(Boolean).pop() ?? "",
@@ -41,7 +41,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
41
41
  nodeType: T.FOLDER,
42
42
  items: []
43
43
  }, f = Q.current;
44
- if (Q.current = null, $(o, u) || f) return;
44
+ if (Q.current = null, $(o, d) || f) return;
45
45
  H(!0);
46
46
  let { bucket: p, path: m } = k === w.Shared ? c(l, M.current, D) : {
47
47
  bucket: D,
@@ -78,16 +78,16 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
78
78
  z,
79
79
  M,
80
80
  R
81
- ]), ie = g((t) => {
81
+ ]), oe = g((t) => {
82
82
  (async () => {
83
83
  U(!0);
84
84
  try {
85
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;
86
+ if (r.type === m.Cancelled) return;
87
87
  if (t.length === 1 && t[0].nodeType === T.ITEM) {
88
88
  let e = t[0];
89
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);
90
+ let i = l(e, e.bucket, O), a = await E.downloadFile(e.bucket, i);
91
91
  if (!a.ok) throw Error(`Download failed with status ${a.status}`);
92
92
  let o = await B.triggerDownload(a, e.name, r);
93
93
  z?.({
@@ -98,7 +98,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
98
98
  } else {
99
99
  let i = t.map((e) => ({
100
100
  bucket: e.bucket ?? D,
101
- path: u(e, e.bucket ?? D, O),
101
+ path: l(e, e.bucket ?? D, O),
102
102
  name: e.name,
103
103
  nodeType: e.nodeType === T.FOLDER ? y.Folder : y.Item
104
104
  })), a = await E.downloadArchive(i);
@@ -128,23 +128,25 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
128
128
  R,
129
129
  E,
130
130
  B
131
- ]), ae = g((t, n) => {
131
+ ]), se = g((t, n) => {
132
132
  t.length !== 0 && (async () => {
133
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) : {
134
+ let r = [], i = t.map((e) => {
135
+ let t = e.nodeType === T.FOLDER, n = u(e.sourceUrl, O), i = t ? n : n.replace(/\/$/, "");
136
+ t && i !== "" && r.push(i.endsWith("/") ? i : `${i}/`);
137
+ let o = a(e.sourceUrl, i), { bucket: s, path: l } = k === w.Shared ? c(i, M.current, D) : {
136
138
  bucket: D,
137
- path: r
139
+ path: i
138
140
  };
139
141
  return {
140
- bucket: o,
141
- path: s,
142
- name: i,
143
- nodeType: t ? b.Folder : b.Item
142
+ bucket: s,
143
+ path: l,
144
+ name: o,
145
+ nodeType: t ? x.Folder : x.Item
144
146
  };
145
147
  });
146
148
  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];
149
+ let { results: t } = await E.deleteFiles(i), r = t.filter((e) => !e.success), a = r.length, o = t.length - a, s = t.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
148
150
  if (o > 0 && R?.({
149
151
  variant: C.Success,
150
152
  reason: e.FilesDeleted,
@@ -152,7 +154,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
152
154
  name: c?.name,
153
155
  folder: n || O
154
156
  }), 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;
157
+ let t = r.slice(0, 3).map((e) => i.find((t) => t.path === e.path)?.name ?? e.path), n = a - t.length;
156
158
  R?.({
157
159
  variant: C.Error,
158
160
  reason: e.FilesDeletePartiallyFailed,
@@ -166,12 +168,13 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
166
168
  reason: e.DeleteFailed
167
169
  });
168
170
  }
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}/`;
171
+ P([...new Set(i.map((e) => {
172
+ if (e.nodeType === x.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
172
173
  let t = e.path.lastIndexOf("/");
173
174
  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
+ let o = r.filter((e) => A.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
177
+ o != null && L(h(o)), F(), W(!1);
175
178
  })();
176
179
  }, [
177
180
  k,
@@ -184,7 +187,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
184
187
  P,
185
188
  F,
186
189
  L
187
- ]), oe = g((e, n) => {
190
+ ]), ce = g((e, n) => {
188
191
  if (!e || e.trim() === "") return { reason: t.Empty };
189
192
  if (e === r) return { reason: t.ReservedName };
190
193
  if (o(e, V)) return {
@@ -200,20 +203,21 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
200
203
  reason: t.DuplicateName,
201
204
  existingName: s.name
202
205
  } : null;
203
- }, [V, j]), se = g((t, r) => {
206
+ }, [V, j]), le = g((t, r) => {
204
207
  if (t.length === 0 || q || Y) return;
205
208
  let a = new AbortController();
206
209
  Z.current = a, (async () => {
207
210
  J(!0);
208
- let o = f(t, D, O), s = o.map(({ dto: e }) => e);
211
+ let o = d(t, D, O), s = o.map(({ dto: e }) => e);
209
212
  try {
210
213
  let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
211
214
  if (l > 0) {
212
- let e = m(o, t);
213
- z?.({
214
- kind: l === 1 ? n.FileCopied : n.FilesCopied,
215
+ let e = p(o, t), a = s.every((e) => h(e.sourcePath) === h(e.destinationPath)), c;
216
+ c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied, z?.({
217
+ kind: c,
215
218
  name: e?.destinationName,
216
219
  count: l,
220
+ isFolder: e?.dto.nodeType === b.Folder,
217
221
  destinationFolderName: i(r, O)
218
222
  });
219
223
  }
@@ -231,7 +235,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
231
235
  reason: e.CopyFailed
232
236
  });
233
237
  } finally {
234
- P([...new Set(s.flatMap((e) => [l(e.sourcePath), l(e.destinationPath)]))]), F(), J(!1), Z.current = null;
238
+ P([...new Set(s.flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), J(!1), Z.current = null;
235
239
  }
236
240
  })();
237
241
  }, [
@@ -244,26 +248,26 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
244
248
  Y,
245
249
  P,
246
250
  F
247
- ]), ce = g(() => {
251
+ ]), ue = g(() => {
248
252
  Z.current?.abort();
249
253
  }, []);
250
254
  return {
251
- isCreatingFolder: ee,
252
- isDownloading: te,
253
- isDeleting: ne,
255
+ isCreatingFolder: ne,
256
+ isDownloading: re,
257
+ isDeleting: ie,
254
258
  isRenaming: G,
255
259
  isCopying: q,
256
260
  isMoving: Y,
257
- onCreateFolder: re,
261
+ onCreateFolder: ae,
258
262
  onCreateFolderValidate: $,
259
- onDownloadFiles: ie,
260
- onDeleteFiles: ae,
261
- onRenameValidate: oe,
263
+ onDownloadFiles: oe,
264
+ onDeleteFiles: se,
265
+ onRenameValidate: ce,
262
266
  onMoveToFiles: g((t, r, o) => {
263
267
  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);
268
+ let { renameDtos: s, preparedMoveItems: c } = f(t, D, O), l = c.map(({ dto: e }) => e), u = new AbortController();
269
+ l.length > 0 && (Z.current = u), (async () => {
270
+ s.length > 0 && K(!0), l.length > 0 && X(!0);
267
271
  let [t, r] = await Promise.all([(async () => {
268
272
  if (s.length === 0) return {
269
273
  results: [],
@@ -282,13 +286,13 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
282
286
  };
283
287
  }
284
288
  })(), (async () => {
285
- if (u.length === 0) return {
289
+ if (l.length === 0) return {
286
290
  results: [],
287
291
  threw: !1,
288
292
  aborted: !1
289
293
  };
290
294
  try {
291
- let { results: e } = await E.moveFiles(u, d.signal);
295
+ let { results: e } = await E.moveFiles(l, u.signal);
292
296
  return {
293
297
  results: e,
294
298
  threw: !1,
@@ -298,25 +302,26 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
298
302
  return {
299
303
  results: [],
300
304
  threw: !0,
301
- aborted: d.signal.aborted
305
+ aborted: u.signal.aborted
302
306
  };
303
307
  }
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;
308
+ })()]), d = t.threw ? s.length : t.results.filter((e) => !e.success).length, f = r.threw && r.aborted, m = f ? 0 : l.length, g = f ? 0 : r.threw ? l.length : r.results.filter((e) => !e.success).length, _ = r.threw ? 0 : r.results.filter((e) => e.success).length, v = s.length + m, y = d + g, b = g > 0;
305
309
  if (_ > 0) {
306
- let e = m(c, r.results);
310
+ let e = p(c, r.results);
307
311
  z?.({
308
312
  kind: _ === 1 ? n.FileMoved : n.FilesMoved,
309
313
  name: e?.destinationName,
310
314
  count: _,
315
+ isFolder: e?.dto.nodeType === ee.Folder,
311
316
  destinationFolderName: i(o, O)
312
317
  });
313
318
  }
314
- if (s.length === 1 && f === 0) {
319
+ if (s.length === 1 && d === 0) {
315
320
  let [e] = s;
316
321
  z?.({
317
322
  kind: n.FileRenamed,
318
323
  name: a(e.destinationPath, e.destinationPath),
319
- isFolder: e.nodeType === x.Folder
324
+ isFolder: e.nodeType === te.Folder
320
325
  });
321
326
  }
322
327
  y > 0 && (y === v ? R?.({
@@ -327,15 +332,15 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
327
332
  reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
328
333
  count: y
329
334
  }));
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}/`;
335
+ let x = s.find((e) => e.nodeType === te.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
336
+ if (x != null) {
337
+ let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
333
338
  if (A === e || A.startsWith(e)) {
334
- let t = S.destinationPath.endsWith("/") ? S.destinationPath : `${S.destinationPath}/`;
339
+ let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
335
340
  L(A.replace(e, t));
336
341
  }
337
342
  }
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);
343
+ P([...new Set([...s, ...l].flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), K(!1), X(!1), l.length > 0 && (Z.current = null);
339
344
  })();
340
345
  }, [
341
346
  D,
@@ -351,8 +356,8 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
351
356
  F,
352
357
  L
353
358
  ]),
354
- onCopyFiles: se,
355
- cancelCopyMove: ce
359
+ onCopyFiles: le,
360
+ cancelCopyMove: ue
356
361
  };
357
362
  };
358
363
  //#endregion
@@ -19,138 +19,145 @@ var f = 5, p = (e) => e.error ? `${e.path} (${e.error})` : e.path, m = (e) => {
19
19
  }, h = (e, t) => `${e}${t}/`, g = (e) => /\.zip$/i.test(e), _ = (e) => {
20
20
  let [t] = e;
21
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, t, r) => {
24
- let a = i(r, g);
25
- T({
26
- files: [{
27
- id: `${Date.now()}-archive`,
28
- name: t,
29
- status: o.Uploading
30
- }],
31
- isOpen: !0
32
- }), (async () => {
22
+ }, v = 0, y = () => (v += 1, `${Date.now()}-${v}`), b = (e, t) => ({
23
+ files: [...e?.files ?? [], ...t],
24
+ isOpen: !0
25
+ }), x = ({ filesApi: f, bucket: p, rootLabel: g, activeTab: v, cache: x, sharedRootMetaRef: S, invalidateFolders: C, bumpRetry: w, onNotification: T }) => {
26
+ let [E, D] = l(null), O = c(/* @__PURE__ */ new Map()), k = s((e, t, r) => {
27
+ let s = i(r, g), c = y();
28
+ D((e) => b(e, [{
29
+ id: c,
30
+ name: t,
31
+ status: o.Uploading
32
+ }])), (async () => {
33
+ let r = o.Failed;
33
34
  try {
34
- let { results: r } = await f.uploadArchive(e, p, h(a, t)), 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?.({
35
+ let { results: i } = await f.uploadArchive(e, p, h(s, t)), a = i.filter((e) => e.success).length, c = i.filter((e) => !e.success), l = c.length, { names: d, restCount: g } = m(c);
36
+ i.length > 0 && a === 0 ? T?.({
36
37
  variant: u.Error,
37
38
  reason: n.UploadArchiveFailed,
38
- names: c,
39
- restCount: l
40
- }) : s > 0 && C?.({
39
+ names: d,
40
+ restCount: g
41
+ }) : (r = o.Completed, l > 0 && T?.({
41
42
  variant: u.Error,
42
43
  reason: n.UploadArchivePartiallyFailed,
43
- count: s,
44
- names: c,
45
- restCount: l
46
- });
44
+ count: l,
45
+ names: d,
46
+ restCount: g
47
+ }));
47
48
  } catch {
48
- C?.({
49
+ T?.({
49
50
  variant: u.Error,
50
51
  reason: n.UploadArchiveRequestFailed
51
52
  });
52
53
  } finally {
53
- x([a]), S(), T(null);
54
+ C([s]), w(), D((e) => a(e, c, {
55
+ status: r,
56
+ percent: 100
57
+ }));
54
58
  }
55
59
  })();
56
60
  }, [
57
61
  p,
58
62
  g,
59
- C,
63
+ T,
60
64
  f,
65
+ C,
66
+ w
67
+ ]), A = s((e, s) => {
68
+ if (e.length === 0) return;
69
+ let c = _(e);
70
+ if (c != null) {
71
+ k(c.fileContent, c.name, s);
72
+ return;
73
+ }
74
+ let l = e.map((e) => ({
75
+ id: y(),
76
+ name: e.name,
77
+ status: o.Queued
78
+ })), m = O.current;
79
+ for (let e of l) m.set(e.id, new AbortController());
80
+ D((e) => b(e, l));
81
+ let h = i(s, g), { bucket: E, path: A } = v === d.Shared ? r(h, S.current, p) : {
82
+ bucket: p,
83
+ path: h
84
+ }, j = new Set((x.get(h) ?? []).map((e) => e.name.toLowerCase()));
85
+ (async () => {
86
+ let r = 0, i = 0, s = 0, c = 0, d = async () => {
87
+ for (; r < e.length;) {
88
+ let n = r++, u = e[n], { id: d } = l[n], p = m.get(d);
89
+ if (p == null || p.signal.aborted) {
90
+ c += 1, m.delete(d), D((e) => a(e, d, o.Cancelled));
91
+ continue;
92
+ }
93
+ D((e) => a(e, d, {
94
+ status: o.Uploading,
95
+ percent: 0
96
+ }));
97
+ let h = j.has(u.name.toLowerCase()) ? t.Overwrite : t.CreateOnly;
98
+ try {
99
+ await f.uploadFile(E, `${A}${u.name}`, u.fileContent, {
100
+ signal: p.signal,
101
+ uploadMode: h,
102
+ onProgress: (e) => {
103
+ D((t) => a(t, d, {
104
+ status: o.Uploading,
105
+ percent: e
106
+ }));
107
+ }
108
+ }), D((e) => a(e, d, {
109
+ status: o.Completed,
110
+ percent: 100
111
+ })), i += 1;
112
+ } catch {
113
+ let e = o.Failed;
114
+ p.signal.aborted ? (e = o.Cancelled, c += 1) : s += 1, D((t) => a(t, d, e));
115
+ } finally {
116
+ m.delete(d);
117
+ }
118
+ }
119
+ };
120
+ await Promise.all(Array.from({ length: 3 }, () => d())), c < e.length && (i === 0 && s > 0 ? T?.({
121
+ variant: u.Error,
122
+ reason: n.UploadFailed
123
+ }) : i > 0 && T?.({
124
+ variant: u.Success,
125
+ reason: n.UploadCompleted,
126
+ folder: A || g
127
+ })), C([h]), w();
128
+ })();
129
+ }, [
130
+ v,
131
+ p,
61
132
  x,
62
- S
63
- ]);
133
+ g,
134
+ T,
135
+ f,
136
+ S,
137
+ C,
138
+ w,
139
+ k
140
+ ]), j = s((e, t, n) => {
141
+ k(e, t, n);
142
+ }, [k]), M = s(async (t, n, r) => {
143
+ for (let n of t) n.name = e(n.name);
144
+ return { valid: !0 };
145
+ }, []), N = s((e) => {
146
+ O.current.get(e)?.abort();
147
+ }, []);
64
148
  return {
65
- onUploadFiles: s((e, s) => {
66
- if (e.length === 0) return;
67
- let c = _(e);
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: e.map((e, t) => ({
75
- id: `${Date.now()}-${t}`,
76
- name: e.name,
77
- status: o.Queued
78
- })),
79
- isOpen: !0
80
- });
81
- let m = i(s, g), { bucket: h, path: w } = v === d.Shared ? r(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 r = 0, i = 0, s = 0, c = async () => {
87
- for (; r < e.length;) {
88
- let n = r++, c = e[n];
89
- if (l.signal.aborted) {
90
- T((e) => a(e, n, o.Cancelled));
91
- continue;
92
- }
93
- T((e) => a(e, n, {
94
- status: o.Uploading,
95
- percent: 0
96
- }));
97
- let u = O.has(c.name.toLowerCase()) ? t.Overwrite : t.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((t) => a(t, n, {
104
- status: o.Uploading,
105
- percent: e
106
- }));
107
- }
108
- }), T((e) => a(e, n, {
109
- status: o.Completed,
110
- percent: 100
111
- })), i += 1;
112
- } catch {
113
- let e = l.signal.aborted ? o.Cancelled : o.Failed;
114
- e === o.Failed && (s += 1), T((t) => a(t, n, e));
115
- }
116
- }
117
- };
118
- await Promise.all(Array.from({ length: 3 }, () => c())), l.signal.aborted || (i === 0 && s > 0 ? C?.({
119
- variant: u.Error,
120
- reason: n.UploadFailed
121
- }) : C?.({
122
- variant: u.Success,
123
- reason: n.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 (t, n, r) => {
143
- for (let n of t) n.name = e(n.name);
144
- return { valid: !0 };
145
- }, []),
146
- uploadBatchState: w,
149
+ onUploadFiles: A,
150
+ onUploadArchive: j,
151
+ onValidateUpload: M,
152
+ uploadBatchState: E,
147
153
  cancelUpload: s(() => {
148
- E.current?.abort();
154
+ for (let e of O.current.values()) e.abort();
149
155
  }, []),
156
+ cancelUploadFile: N,
150
157
  clearUploadBatch: s(() => {
151
- T(null);
158
+ D(null);
152
159
  }, [])
153
160
  };
154
161
  };
155
162
  //#endregion
156
- export { v as useDialFileUploadBatch };
163
+ export { x as useDialFileUploadBatch };
@@ -1,42 +1,47 @@
1
1
  import { mimeTypesToDialFileAcceptTypes as e } from "../attachment-types.js";
2
- import { DialFileManagerVariant as t } from "../file-manager-variant.js";
3
- import { useDialFileManager as n } from "../useDialFileManager/useDialFileManager.js";
2
+ import { DIAL_FILE_MANAGER_SECTION_TABS as t } from "../dial-file-manager.model.js";
3
+ import { useDialFileManagerSections as n } from "../useDialFileManagerSections/useDialFileManagerSections.js";
4
4
  import { useDialFileManagerTabConfig as r } from "../useDialFileManagerTabConfig/useDialFileManagerTabConfig.js";
5
- import { isHiddenPath as i } from "@epam/ai-dial-chat-shared";
6
- import { useCallback as a, useMemo as o, useState as s } from "react";
7
- import { isMimeTypeAllowed as c } from "@epam/ai-dial-attachment-input";
8
- import { DialFileManagerTabs as l, DialFileNodeType as u, useDialFileManagerTabs as d } from "@epam/ai-dial-react-file-manager";
5
+ import { DialFileManagerVariant as i, isHiddenPath as a } from "@epam/ai-dial-chat-shared";
6
+ import { useCallback as o, useMemo as s, useState as c } from "react";
7
+ import { isMimeTypeAllowed as l } from "@epam/ai-dial-attachment-input";
8
+ import { DialFileNodeType as u, useDialFileManagerTabs as d } from "@epam/ai-dial-react-file-manager";
9
9
  //#region src/files/useFileAttachmentPicker/useFileAttachmentPicker.ts
10
10
  var f = ({ fileManagerOptions: f, bucket: p, forbiddenSymbolsRegExp: m, tabLabels: h, allowedTabs: g, initialTab: _, allowedTypes: v, maxSelectableFileSize: y, canAttachFolders: b = !1 }) => {
11
- let { activeTab: x, handleTabChange: S, tabs: C } = d(h, _), [w, T] = s(() => /* @__PURE__ */ new Set()), E = a((e) => {
12
- T(new Set(e));
13
- }, []), D = a((e) => {
14
- T(/* @__PURE__ */ new Set()), S(e);
15
- }, [S]), { tabs: O } = r(x, D, C, g), k = h[x] || h[l.MyFiles], A = n({
11
+ let { activeTab: x, handleTabChange: S, tabs: C } = d(h, _), w = s(() => t.filter((e) => g == null || g.includes(e)).map((e) => ({
12
+ tab: e,
13
+ rootLabel: h[e]
14
+ })), [g, h]), [T, E] = c(() => /* @__PURE__ */ new Set()), D = o((e) => {
15
+ E(new Set(e));
16
+ }, []), O = o((e) => {
17
+ E(/* @__PURE__ */ new Set()), S(e);
18
+ }, [S]), { tabs: k } = r(x, O, C, g), A = n({
16
19
  ...f,
17
20
  bucket: p,
18
21
  activeTab: x,
19
- rootLabel: k,
20
- variant: t.Attach,
22
+ sections: w,
23
+ variant: i.Attach,
21
24
  forbiddenSymbolsRegExp: m
22
- }), j = a((e) => v == null || v.length === 0 ? !0 : c(e, v), [v]);
25
+ }), [j, M] = c(A.sectionTab);
26
+ j !== A.sectionTab && (M(A.sectionTab), E(/* @__PURE__ */ new Set()));
27
+ let N = o((e) => v == null || v.length === 0 ? !0 : l(e, v), [v]);
23
28
  return {
24
29
  controller: A,
25
30
  activeTab: x,
26
- tabs: O,
27
- onTabChange: D,
28
- selectedPaths: w,
29
- onSelectedPathsChange: E,
30
- isRowSelectable: a((e) => {
31
+ tabs: k,
32
+ onTabChange: O,
33
+ selectedPaths: T,
34
+ onSelectedPathsChange: D,
35
+ isRowSelectable: o((e) => {
31
36
  let t = e.data;
32
- return t == null || i(t.path) ? !1 : t.nodeType === u.FOLDER ? b : t.nodeType === u.ITEM ? !(t.contentType != null && !j(t.contentType) || y != null && t.contentLength != null && t.contentLength > y) : !1;
37
+ return t == null || a(t.path) ? !1 : t.nodeType === u.FOLDER ? b : t.nodeType === u.ITEM ? !(t.contentType != null && !N(t.contentType) || y != null && t.contentLength != null && t.contentLength > y) : !1;
33
38
  }, [
34
39
  b,
35
- j,
40
+ N,
36
41
  y
37
42
  ]),
38
- isFileTypeAllowed: j,
39
- allowedFileTypes: o(() => e(v), [v])
43
+ isFileTypeAllowed: N,
44
+ allowedFileTypes: s(() => e(v), [v])
40
45
  };
41
46
  };
42
47
  //#endregion