@epam/ai-dial-chat-hooks 1.2.0-dev.20 → 1.2.0-dev.201

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 (88) hide show
  1. package/api-error/api-error.js +5 -4
  2. package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
  3. package/attachments.d.ts +10 -4
  4. package/catalog/catalog-derivations.js +1 -1
  5. package/catalog/deployment-id.js +8 -2
  6. package/catalog/map-deployment-limits-to-input.js +81 -9
  7. package/catalog/map-deployment-to-catalog-item.js +34 -34
  8. package/catalog/map-entity-details-to-catalog.js +7 -0
  9. package/catalog/map-skill-to-catalog-item.js +30 -27
  10. package/catalog/publish.js +6 -5
  11. package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
  12. package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
  13. package/catalog/useSkillItemDetails.js +17 -13
  14. package/catalog.d.ts +116 -20
  15. package/catalog.js +23 -22
  16. package/conversation/conversation-transfer/export-conversation.js +24 -16
  17. package/conversation/conversation-transfer/import-conversation.js +80 -31
  18. package/conversation/conversation-transfer/queue.js +8 -5
  19. package/conversation/create-chat-stream-api.js +85 -49
  20. package/conversation/message-utils.js +44 -2
  21. package/conversation/stage.js +23 -0
  22. package/conversation/useConversationExport/useConversationExport.js +9 -9
  23. package/conversation/useConversationImport/useConversationImport.js +123 -121
  24. package/conversation/useConversationPanelItems/useConversationPanelItems.js +2 -3
  25. package/conversation/useConversationScroll/useConversationScroll.js +68 -64
  26. package/conversation/useConversationStream/apply-chunk.js +1 -1
  27. package/conversation/useConversationStream/generation-resume.js +104 -63
  28. package/conversation/useConversationStream/useConversationStream.js +183 -108
  29. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  30. package/conversation-overlay.d.ts +7 -0
  31. package/conversation-overlay.js +2 -0
  32. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  33. package/conversation-sources.d.ts +1 -1
  34. package/conversation-transfer.d.ts +2 -1
  35. package/conversation.d.ts +241 -13
  36. package/conversation.js +32 -30
  37. package/file-manager-canvas.d.ts +398 -0
  38. package/file-manager-canvas.js +2 -0
  39. package/file-manager.d.ts +153 -350
  40. package/file-manager.js +25 -24
  41. package/files/attachment-canvas.js +40 -1
  42. package/files/attachment-types.js +14 -13
  43. package/files/dial-file-manager-mapping.util.js +2 -1
  44. package/files/dial-file-manager-path.util.js +23 -1
  45. package/files/dial-file-manager.model.js +23 -19
  46. package/files/dial-file-manager.types.js +3 -3
  47. package/files/useDialFileListing/useDialFileListing.js +157 -145
  48. package/files/useDialFileManager/useDialFileManager.js +132 -128
  49. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  50. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
  51. package/files/useDialFileMutations/useDialFileMutations.js +33 -32
  52. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  53. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
  54. package/index.d.ts +1066 -81
  55. package/index.js +136 -122
  56. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
  57. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
  58. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  59. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
  60. package/mcp-apps.d.ts +8 -6
  61. package/oauth/toolset-id.js +5 -3
  62. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  63. package/oauth.d.ts +32 -0
  64. package/oauth.js +9 -9
  65. package/package.json +36 -21
  66. package/scheduled-task/scheduled-task-description.js +77 -0
  67. package/scheduled-task/scheduled-task-preparation.js +24 -0
  68. package/scheduled-task/scheduled-task-trigger.js +7 -2
  69. package/scheduled-task/scheduled-tasks-api-client.js +19 -0
  70. package/scheduled-task/use-scheduled-task-runs.js +194 -0
  71. package/scheduled-task/use-scheduled-tasks.js +93 -0
  72. package/scheduled-tasks.d.ts +195 -3
  73. package/scheduled-tasks.js +7 -2
  74. package/skill/skill-archive.js +19 -0
  75. package/skill/skill-types.js +8 -7
  76. package/skill/skill.js +42 -27
  77. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +75 -0
  78. package/skill/useSkillEditorLoad.js +29 -28
  79. package/skill/useSkillEditorSubmit.js +108 -84
  80. package/skill/useSkillFileActions.js +70 -58
  81. package/skill-editor.d.ts +131 -3
  82. package/skill-editor.js +9 -8
  83. package/usage/map-usage-data-to-dashboard.js +66 -0
  84. package/usage/map-user-usage-to-model-limits.js +202 -0
  85. package/usage.d.ts +125 -0
  86. package/usage.js +3 -0
  87. package/usePageFileDrag/usePageFileDrag.js +3 -3
  88. package/utils.d.ts +8 -6
@@ -6,141 +6,145 @@ import { useDialFileMetadata as u } from "../useDialFileMetadata/useDialFileMeta
6
6
  import { useDialFileMutations as d } from "../useDialFileMutations/useDialFileMutations.js";
7
7
  import { useDialFileSharing as f } from "../useDialFileSharing/useDialFileSharing.js";
8
8
  import { useDialFileUploadBatch as p } from "../useDialFileUploadBatch/useDialFileUploadBatch.js";
9
- import { useCallback as m, useMemo as h } from "react";
10
- import { DialFileManagerActions as g, DialFileManagerTabs as _ } from "@epam/ai-dial-react-file-manager";
9
+ import { isUploadInProgress as m } from "@epam/ai-dial-chat-shared";
10
+ import { useCallback as h, useMemo as g } from "react";
11
+ import { DialFileManagerActions as _, DialFileManagerTabs as v } from "@epam/ai-dial-react-file-manager";
11
12
  //#region src/files/useDialFileManager/useDialFileManager.ts
12
- var v = ({ filesApi: v, bucket: y, rootLabel: b = "My files", activeTab: x = _.MyFiles, onNotification: S, onOperationSuccess: C, forbiddenSymbolsRegExp: w, variant: T = i.Attach, actionProfile: E, labels: D, locale: O, disabledNewButtonTooltip: k, downloadDestination: A, buildValidationErrorMessage: j }) => {
13
- let M = E ?? a(T), N = l({
14
- filesApi: v,
15
- bucket: y,
16
- rootLabel: b,
17
- activeTab: x,
18
- onNotification: S
19
- }), P = p({
20
- filesApi: v,
21
- bucket: y,
22
- rootLabel: b,
23
- activeTab: x,
24
- cache: N.cache,
25
- sharedRootMetaRef: N.sharedRootMetaRef,
26
- invalidateFolders: N.invalidateFolders,
27
- bumpRetry: N.bumpRetry,
28
- onNotification: S
29
- }), F = d({
30
- filesApi: v,
31
- bucket: y,
32
- rootLabel: b,
33
- activeTab: x,
34
- folderPath: N.folderPath,
35
- currentFolder: N.currentFolder,
36
- sharedRootMetaRef: N.sharedRootMetaRef,
37
- listingPermissionsCache: N.listingPermissionsCache,
38
- invalidateFolders: N.invalidateFolders,
39
- bumpRetry: N.bumpRetry,
40
- mergeCreatedFolder: N.mergeCreatedFolder,
41
- setFolderPath: N.setFolderPath,
42
- onNotification: S,
43
- onOperationSuccess: C,
44
- downloadDestination: A,
45
- forbiddenSymbolsRegExp: w
46
- }), I = f({
47
- filesApi: v,
48
- bucket: y,
49
- rootLabel: b,
50
- bumpRetry: N.bumpRetry,
51
- onNotification: S
52
- }), L = u({
53
- filesApi: v,
54
- bucket: y,
55
- rootLabel: b,
56
- onNotification: S
57
- }), R = o(N.currentFolder), z = h(() => x === _.Organization || x === _.Shared && N.folderPath === "" ? !1 : R, [
58
- x,
59
- N.folderPath,
60
- R
61
- ]), B = h(() => x === _.Shared ? t : e, [x]), V = h(() => {
13
+ var y = ({ filesApi: y, bucket: b, rootLabel: x = "My files", activeTab: S = v.MyFiles, isActive: C, sessionKey: w, onNotification: T, onOperationSuccess: E, forbiddenSymbolsRegExp: D, variant: O = i.Attach, actionProfile: k, labels: A, locale: j, disabledNewButtonTooltip: M, downloadDestination: N, buildValidationErrorMessage: P }) => {
14
+ let F = k ?? a(O), I = l({
15
+ filesApi: y,
16
+ bucket: b,
17
+ rootLabel: x,
18
+ activeTab: S,
19
+ onNotification: T,
20
+ isActive: C,
21
+ sessionKey: w
22
+ }), L = p({
23
+ filesApi: y,
24
+ bucket: b,
25
+ rootLabel: x,
26
+ activeTab: S,
27
+ cache: I.cache,
28
+ sharedRootMetaRef: I.sharedRootMetaRef,
29
+ invalidateFolders: I.invalidateFolders,
30
+ bumpRetry: I.bumpRetry,
31
+ onNotification: T
32
+ }), R = d({
33
+ filesApi: y,
34
+ bucket: b,
35
+ rootLabel: x,
36
+ activeTab: S,
37
+ folderPath: I.folderPath,
38
+ currentFolder: I.currentFolder,
39
+ sharedRootMetaRef: I.sharedRootMetaRef,
40
+ listingPermissionsCache: I.listingPermissionsCache,
41
+ invalidateFolders: I.invalidateFolders,
42
+ bumpRetry: I.bumpRetry,
43
+ mergeCreatedFolder: I.mergeCreatedFolder,
44
+ setFolderPath: I.setFolderPath,
45
+ onNotification: T,
46
+ onOperationSuccess: E,
47
+ downloadDestination: N,
48
+ forbiddenSymbolsRegExp: D
49
+ }), z = f({
50
+ filesApi: y,
51
+ bucket: b,
52
+ rootLabel: x,
53
+ bumpRetry: I.bumpRetry,
54
+ onNotification: T
55
+ }), B = u({
56
+ filesApi: y,
57
+ bucket: b,
58
+ rootLabel: x,
59
+ onNotification: T
60
+ }), V = o(I.currentFolder), H = g(() => S === v.Organization || S === v.Shared && I.folderPath === "" ? !1 : V, [
61
+ S,
62
+ I.folderPath,
63
+ V
64
+ ]), U = g(() => S === v.Shared ? t : e, [S]), W = g(() => {
62
65
  let e = {}, t = (t) => {
63
- let n = D[t];
66
+ let n = A[t];
64
67
  n != null && (e[t] = n);
65
68
  };
66
- return t(g.Download), x === _.MyFiles ? (t(g.Delete), z && (t(g.Rename), s(M) && (t(g.Copy), t(g.Move), t(g.Duplicate))), c(M) && t(g.RemoveAccess)) : x === _.Shared && c(M) && t(g.Unshare), M === r.Full && t(g.Info), e;
69
+ return t(_.Download), S === v.MyFiles ? (t(_.Delete), H && (t(_.Rename), s(F) && (t(_.Copy), t(_.Move), t(_.Duplicate))), c(F) && t(_.RemoveAccess)) : S === v.Shared && c(F) && t(_.Unshare), F === r.Full && t(_.Info), e;
67
70
  }, [
68
- x,
69
- z,
70
- M,
71
- D
72
- ]), H = h(() => F.isCreatingFolder || F.isDownloading || F.isDeleting || F.isRenaming || F.isCopying || F.isMoving || I.isUnsharing || I.isRemovingAccess || P.uploadBatchState != null, [
73
- F.isCreatingFolder,
74
- F.isDownloading,
75
- F.isDeleting,
76
- F.isRenaming,
77
- F.isCopying,
78
- F.isMoving,
79
- I.isUnsharing,
80
- I.isRemovingAccess,
81
- P.uploadBatchState
82
- ]), U = m((e, t) => {
83
- let n = F.onCreateFolderValidate(e, t);
84
- return n ? j(n) : null;
85
- }, [F, j]), W = m((e, t) => {
86
- let n = F.onRenameValidate(e, t);
87
- return n ? j(n, t) : null;
88
- }, [F, j]);
71
+ S,
72
+ H,
73
+ F,
74
+ A
75
+ ]), G = g(() => R.isCreatingFolder || R.isDownloading || R.isDeleting || R.isRenaming || R.isCopying || R.isMoving || z.isUnsharing || z.isRemovingAccess || m(L.uploadBatchState), [
76
+ R.isCreatingFolder,
77
+ R.isDownloading,
78
+ R.isDeleting,
79
+ R.isRenaming,
80
+ R.isCopying,
81
+ R.isMoving,
82
+ z.isUnsharing,
83
+ z.isRemovingAccess,
84
+ L.uploadBatchState
85
+ ]), K = h((e, t) => {
86
+ let n = R.onCreateFolderValidate(e, t);
87
+ return n ? P(n) : null;
88
+ }, [R, P]), q = h((e, t) => {
89
+ let n = R.onRenameValidate(e, t);
90
+ return n ? P(n, t) : null;
91
+ }, [R, P]);
89
92
  return {
90
- items: N.items,
91
- isLoading: N.isLoading,
92
- error: N.error,
93
- path: N.path,
94
- onPathChange: N.onPathChange,
95
- retry: N.retry,
96
- onSearchFiles: N.onSearchFiles,
97
- isSearching: N.isSearching,
98
- searchResults: N.searchResults,
99
- clearSearchResults: N.clearSearchResults,
100
- expandedPaths: N.expandedPaths,
101
- loadedPaths: N.loadedPaths,
102
- onExpandedPathsChange: N.onExpandedPathsChange,
103
- onFolderPopupPathChange: N.onFolderPopupPathChange,
104
- folderPopupLoadingPaths: N.folderPopupLoadingPaths,
105
- onUploadFiles: P.onUploadFiles,
106
- onUploadArchive: P.onUploadArchive,
107
- onValidateUpload: P.onValidateUpload,
108
- uploadBatchState: P.uploadBatchState,
109
- cancelUpload: P.cancelUpload,
110
- clearUploadBatch: P.clearUploadBatch,
111
- onCreateFolder: F.onCreateFolder,
112
- onCreateFolderValidate: U,
113
- isCreatingFolder: F.isCreatingFolder,
114
- onDownloadFiles: F.onDownloadFiles,
115
- isDownloading: F.isDownloading,
116
- onDeleteFiles: F.onDeleteFiles,
117
- isDeleting: F.isDeleting,
118
- onRenameValidate: W,
119
- onMoveToFiles: F.onMoveToFiles,
120
- isRenaming: F.isRenaming,
121
- onCopyFiles: F.onCopyFiles,
122
- isCopying: F.isCopying,
123
- isMoving: F.isMoving,
124
- cancelCopyMove: F.cancelCopyMove,
125
- uploadEnabled: z,
126
- isNewButtonDisabled: !z,
127
- disabledNewButtonTooltip: k,
128
- visibleColumns: B,
129
- dateLocale: O,
93
+ items: I.items,
94
+ isLoading: I.isLoading,
95
+ error: I.error,
96
+ path: I.path,
97
+ onPathChange: I.onPathChange,
98
+ retry: I.retry,
99
+ onSearchFiles: I.onSearchFiles,
100
+ isSearching: I.isSearching,
101
+ searchResults: I.searchResults,
102
+ clearSearchResults: I.clearSearchResults,
103
+ expandedPaths: I.expandedPaths,
104
+ loadedPaths: I.loadedPaths,
105
+ onExpandedPathsChange: I.onExpandedPathsChange,
106
+ onFolderPopupPathChange: I.onFolderPopupPathChange,
107
+ folderPopupLoadingPaths: I.folderPopupLoadingPaths,
108
+ onUploadFiles: L.onUploadFiles,
109
+ onUploadArchive: L.onUploadArchive,
110
+ onValidateUpload: L.onValidateUpload,
111
+ uploadBatchState: L.uploadBatchState,
112
+ cancelUpload: L.cancelUpload,
113
+ cancelUploadFile: L.cancelUploadFile,
114
+ clearUploadBatch: L.clearUploadBatch,
115
+ onCreateFolder: R.onCreateFolder,
116
+ onCreateFolderValidate: K,
117
+ isCreatingFolder: R.isCreatingFolder,
118
+ onDownloadFiles: R.onDownloadFiles,
119
+ isDownloading: R.isDownloading,
120
+ onDeleteFiles: R.onDeleteFiles,
121
+ isDeleting: R.isDeleting,
122
+ onRenameValidate: q,
123
+ onMoveToFiles: R.onMoveToFiles,
124
+ isRenaming: R.isRenaming,
125
+ onCopyFiles: R.onCopyFiles,
126
+ isCopying: R.isCopying,
127
+ isMoving: R.isMoving,
128
+ cancelCopyMove: R.cancelCopyMove,
129
+ uploadEnabled: H,
130
+ isNewButtonDisabled: !H,
131
+ disabledNewButtonTooltip: M,
132
+ visibleColumns: U,
133
+ dateLocale: j,
130
134
  dateOptions: n,
131
- actionLabels: V,
132
- sharedWithMeIds: N.sharedWithMeIds,
133
- sharedByMePaths: N.sharedByMePaths,
134
- onUnshareFiles: I.onUnshareFiles,
135
- isUnsharing: I.isUnsharing,
136
- onRemoveFilesAccess: I.onRemoveFilesAccess,
137
- isRemovingAccess: I.isRemovingAccess,
138
- fileMetadata: L.fileMetadata,
139
- isFileMetadataLoading: L.isFileMetadataLoading,
140
- onGetInfo: L.onGetInfo,
141
- clearMetadata: L.clearMetadata,
142
- isAnyOperationInProgress: H
135
+ actionLabels: W,
136
+ sharedWithMeIds: I.sharedWithMeIds,
137
+ sharedByMePaths: I.sharedByMePaths,
138
+ onUnshareFiles: z.onUnshareFiles,
139
+ isUnsharing: z.isUnsharing,
140
+ onRemoveFilesAccess: z.onRemoveFilesAccess,
141
+ isRemovingAccess: z.isRemovingAccess,
142
+ fileMetadata: B.fileMetadata,
143
+ isFileMetadataLoading: B.isFileMetadataLoading,
144
+ onGetInfo: B.onGetInfo,
145
+ clearMetadata: B.clearMetadata,
146
+ isAnyOperationInProgress: G
143
147
  };
144
148
  };
145
149
  //#endregion
146
- export { v as useDialFileManager };
150
+ export { y as useDialFileManager };
@@ -0,0 +1,155 @@
1
+ import { FileManagerNotificationReason as e } from "../dial-file-manager.types.js";
2
+ import { DIAL_FILE_MANAGER_SECTION_TABS as t } from "../dial-file-manager.model.js";
3
+ import { hasSamePaths as n, resolveSectionByPath as r, unionPathSets as i, withRoutableRootLabels as ee } from "../dial-file-manager-path.util.js";
4
+ import { useDialFileManager as a } from "../useDialFileManager/useDialFileManager.js";
5
+ import { useEffect as te, useMemo as ne, useRef as re, useState as o } from "react";
6
+ import { NotificationVariant as s } from "@epam/ai-dial-ui-kit";
7
+ import { DialFileManagerTabs as c } from "@epam/ai-dial-react-file-manager";
8
+ //#region src/files/useDialFileManagerSections/useDialFileManagerSections.ts
9
+ var l = ({ activeTab: l, sections: u, ...d }) => {
10
+ let f = ne(() => ee(u.filter((e) => t.includes(e.tab))), [u]), p = l === c.All, m = (e) => {
11
+ let t = f.find((t) => t.tab === e);
12
+ return {
13
+ ...d,
14
+ activeTab: e,
15
+ rootLabel: t?.rootLabel ?? e,
16
+ isActive: t != null && (p || l === e),
17
+ sessionKey: l
18
+ };
19
+ }, h = a(m(c.MyFiles)), g = a(m(c.Shared)), ie = a(m(c.Organization)), _ = (e) => {
20
+ switch (e) {
21
+ case c.MyFiles: return h;
22
+ case c.Shared: return g;
23
+ case c.Organization: return ie;
24
+ default: throw Error(`Not a file-manager section tab: ${e}`);
25
+ }
26
+ }, [v, y] = o(null), [b, x] = o(null), [S, C] = o(l);
27
+ S !== l && (C(l), y(null), x(null));
28
+ let w = (e) => f.some((t) => t.tab === e), ae = f[0]?.tab ?? c.MyFiles, T = v != null && w(v) ? v : ae, oe = b != null && w(b) ? b : T, E = (e) => e == null ? void 0 : r(e, f)?.tab, D = (e) => _(E(e) ?? T), O = (e, t) => {
29
+ let n = /* @__PURE__ */ new Map();
30
+ return e.forEach((e) => {
31
+ let r = E(t(e)) ?? T;
32
+ n.set(r, [...n.get(r) ?? [], e]);
33
+ }), [...n];
34
+ }, { onNotification: k } = d, A = re(/* @__PURE__ */ new Set());
35
+ te(() => {
36
+ let t = A.current;
37
+ if (!p) {
38
+ t.clear();
39
+ return;
40
+ }
41
+ f.forEach(({ tab: n }) => {
42
+ if (_(n).error == null) {
43
+ t.delete(n);
44
+ return;
45
+ }
46
+ t.has(n) || (t.add(n), n !== T && k?.({
47
+ variant: s.Error,
48
+ reason: e.FolderLoadFailed
49
+ }));
50
+ });
51
+ }, [
52
+ f.map(({ tab: e }) => `${e}:${_(e).error ?? ""}`).join("|"),
53
+ p,
54
+ T,
55
+ k
56
+ ]);
57
+ let j = () => {
58
+ k?.({
59
+ variant: s.Warning,
60
+ reason: e.CrossSectionTransferUnsupported
61
+ });
62
+ }, M = (e, t) => {
63
+ let n = new Set(e.map(E));
64
+ if (n.size !== 1) return;
65
+ let [r] = n;
66
+ if (r != null) return (t ? E(t) : r) === r ? r : void 0;
67
+ }, N = (e) => {
68
+ if (e == null) {
69
+ _(T).onPathChange();
70
+ return;
71
+ }
72
+ let t = E(e);
73
+ t != null && (y(t), _(t).onPathChange(e));
74
+ }, P = (e) => {
75
+ f.forEach(({ tab: t }) => {
76
+ let r = _(t), i = new Set([...e].filter((e) => E(e) === t));
77
+ n(i, r.expandedPaths) || r.onExpandedPathsChange(i);
78
+ });
79
+ }, F = (e) => D(e).onFolderPopupPathChange(e), I = (e, t) => D(t).onUploadFiles(e, t), L = (e, t, n) => D(n).onUploadArchive(e, t, n), R = (e, t, n) => D(n).onValidateUpload(e, t, n), z = (e, t, n) => D(t).onCreateFolder(e, t, n), B = (e, t) => D(t.path).onCreateFolderValidate(e, t), V = (e) => O(e, (e) => e.path).forEach(([e, t]) => _(e).onDownloadFiles(t)), H = (e, t) => {
80
+ let n = E(t);
81
+ O(e, (e) => e.sourceUrl ?? t).forEach(([e, r]) => _(e).onDeleteFiles(r, e === n ? t : ""));
82
+ }, U = (e, t) => D(t.path).onRenameValidate(e, t), W = (e) => O(e, (e) => e.path).forEach(([e, t]) => _(e).onUnshareFiles(t)), G = (e) => O(e, (e) => e.path).forEach(([e, t]) => _(e).onRemoveFilesAccess(t)), K = (e) => {
83
+ let t = E(e.path) ?? T;
84
+ x(t), _(t).onGetInfo(e);
85
+ }, q = (e, t) => {
86
+ if (e.length === 0) return;
87
+ let n = M(e.map((e) => e.sourceUrl), t);
88
+ if (n == null) {
89
+ j();
90
+ return;
91
+ }
92
+ _(n).onCopyFiles(e, t);
93
+ }, se = (e, t, n) => {
94
+ if (e.length === 0) return;
95
+ let r = M(e.map((e) => e.sourceUrl ?? t), n);
96
+ if (r == null) {
97
+ j();
98
+ return;
99
+ }
100
+ _(r).onMoveToFiles(e, t, n);
101
+ }, ce = () => f.forEach(({ tab: e }) => _(e).cancelCopyMove());
102
+ if (!p) {
103
+ let e = t.includes(l) ? l : c.MyFiles;
104
+ return {
105
+ ..._(e),
106
+ sectionTab: e
107
+ };
108
+ }
109
+ let J = f.map(({ tab: e }) => _(e)), Y = _(T), X = _(oe), Z = [Y, ...J].find((e) => e.uploadBatchState != null) ?? Y, Q = (e) => J.some(e), $ = J.map((e) => e.sharedWithMeIds).filter((e) => e != null), le = new Set(f.filter(({ tab: e }) => e !== T && _(e).isLoading).map(({ tab: e }) => _(e).path));
110
+ return {
111
+ ...Y,
112
+ items: J.map((e) => e.items[0]).filter((e) => e != null),
113
+ onPathChange: N,
114
+ expandedPaths: i(J.map((e) => e.expandedPaths)),
115
+ loadedPaths: i(J.map((e) => e.loadedPaths)),
116
+ onExpandedPathsChange: P,
117
+ onFolderPopupPathChange: F,
118
+ folderPopupLoadingPaths: i([...J.map((e) => e.folderPopupLoadingPaths), le]),
119
+ onUploadFiles: I,
120
+ onUploadArchive: L,
121
+ onValidateUpload: R,
122
+ uploadBatchState: Z.uploadBatchState,
123
+ cancelUpload: Z.cancelUpload,
124
+ cancelUploadFile: Z.cancelUploadFile,
125
+ clearUploadBatch: Z.clearUploadBatch,
126
+ onCreateFolder: z,
127
+ onCreateFolderValidate: B,
128
+ isCreatingFolder: Q((e) => e.isCreatingFolder),
129
+ onDownloadFiles: V,
130
+ isDownloading: Q((e) => e.isDownloading),
131
+ onDeleteFiles: H,
132
+ isDeleting: Q((e) => e.isDeleting),
133
+ onRenameValidate: U,
134
+ onMoveToFiles: se,
135
+ isRenaming: Q((e) => e.isRenaming),
136
+ onCopyFiles: q,
137
+ isCopying: Q((e) => e.isCopying),
138
+ isMoving: Q((e) => e.isMoving),
139
+ cancelCopyMove: ce,
140
+ sharedWithMeIds: $.length > 0 ? $.flat() : void 0,
141
+ sharedByMePaths: i(J.map((e) => e.sharedByMePaths)),
142
+ onUnshareFiles: W,
143
+ isUnsharing: Q((e) => e.isUnsharing),
144
+ onRemoveFilesAccess: G,
145
+ isRemovingAccess: Q((e) => e.isRemovingAccess),
146
+ fileMetadata: X.fileMetadata,
147
+ isFileMetadataLoading: X.isFileMetadataLoading,
148
+ onGetInfo: K,
149
+ clearMetadata: X.clearMetadata,
150
+ isAnyOperationInProgress: Q((e) => e.isAnyOperationInProgress),
151
+ sectionTab: T
152
+ };
153
+ };
154
+ //#endregion
155
+ export { l as useDialFileManagerSections };
@@ -1,23 +1,24 @@
1
- import { useCallback as e, useEffect as t, useMemo as n } from "react";
2
- import { DialFileManagerTabs as r } from "@epam/ai-dial-react-file-manager";
1
+ import { DIAL_FILE_MANAGER_SECTION_TABS as e } from "../dial-file-manager.model.js";
2
+ import { useCallback as t, useEffect as n, useMemo as r } from "react";
3
+ import { DialFileManagerTabs as i } from "@epam/ai-dial-react-file-manager";
3
4
  //#region src/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.ts
4
- var i = [
5
- r.MyFiles,
6
- r.Shared,
7
- r.Organization
8
- ], a = (a, o, s, c) => {
9
- let l = e((e) => c == null || c.includes(e), [c]), u = n(() => s?.filter((e) => l(e.id)).flatMap(({ id: e, label: t, disabled: n }) => typeof t == "string" ? [{
10
- id: e,
11
- label: t,
12
- disabled: n
13
- }] : []), [s, l]);
14
- return t(() => {
15
- l(a) || o(i.find((e) => l(e)) ?? r.MyFiles);
5
+ var a = [
6
+ i.All,
7
+ i.MyFiles,
8
+ i.Shared,
9
+ i.Organization
10
+ ], o = 2, s = (s, c, l, u) => {
11
+ let d = t((t) => {
12
+ let n = (e) => u == null || u.includes(e);
13
+ return n(t) ? t === i.All ? e.filter((e) => n(e)).length >= o : !0 : !1;
14
+ }, [u]), f = r(() => l?.filter((e) => d(e.value)), [l, d]);
15
+ return n(() => {
16
+ d(s) || c(a.find((e) => d(e)) ?? i.MyFiles);
16
17
  }, [
17
- l,
18
- a,
19
- o
20
- ]), { tabs: u };
18
+ d,
19
+ s,
20
+ c
21
+ ]), { tabs: f };
21
22
  };
22
23
  //#endregion
23
- export { a as useDialFileManagerTabConfig };
24
+ export { s as useDialFileManagerTabConfig };
@@ -6,19 +6,18 @@ import { prepareCopyItems as f, prepareMoveRenameItems as p } from "../dial-file
6
6
  import { findFirstSuccessfulCopyMoveItem as m } from "../dial-file-manager-mapping.util.js";
7
7
  import { DownloadDestinationType as h } from "../download-destination.js";
8
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";
9
+ import { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as te } from "@epam/ai-dial-chat-api-client";
10
10
  import { NOT_ALLOWED_SYMBOLS as S, NotificationVariant as C } from "@epam/ai-dial-ui-kit";
11
11
  import { DialFileManagerTabs as w, DialFileNodeType as T } from "@epam/ai-dial-react-file-manager";
12
12
  //#region src/files/useDialFileMutations/useDialFileMutations.ts
13
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) => {
14
+ 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
15
  let i = null;
16
16
  if (!e || e.trim() === "") i = { reason: t.Empty };
17
17
  else if (o(e, V)) i = {
18
18
  reason: t.ForbiddenSymbols,
19
19
  symbols: S
20
20
  };
21
- else if (e.startsWith(".")) i = { reason: t.LeadingDot };
22
21
  else if (e === r) i = { reason: t.ReservedName };
23
22
  else if (e.length > 255) i = {
24
23
  reason: t.TooLong,
@@ -32,7 +31,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
32
31
  });
33
32
  }
34
33
  return Q.current = i, i;
35
- }, [V]), re = g(async (t, r, i) => {
34
+ }, [V]), ae = g(async (t, r, i) => {
36
35
  let { parentVirtualPath: a, name: o } = s(r, O), l = d(a, O), u = j && A === l ? j : {
37
36
  id: l,
38
37
  path: l,
@@ -78,7 +77,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
78
77
  z,
79
78
  M,
80
79
  R
81
- ]), ie = g((t) => {
80
+ ]), oe = g((t) => {
82
81
  (async () => {
83
82
  U(!0);
84
83
  try {
@@ -128,7 +127,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
128
127
  R,
129
128
  E,
130
129
  B
131
- ]), ae = g((t, n) => {
130
+ ]), se = g((t, n) => {
132
131
  t.length !== 0 && (async () => {
133
132
  W(!0);
134
133
  let r = t.map((e) => {
@@ -140,7 +139,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
140
139
  bucket: o,
141
140
  path: s,
142
141
  name: i,
143
- nodeType: t ? b.Folder : b.Item
142
+ nodeType: t ? x.Folder : x.Item
144
143
  };
145
144
  });
146
145
  try {
@@ -166,9 +165,9 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
166
165
  reason: e.DeleteFailed
167
166
  });
168
167
  }
169
- let i = r.filter((e) => e.nodeType === b.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
168
+ let i = r.filter((e) => e.nodeType === x.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
170
169
  P([...new Set(r.map((e) => {
171
- if (e.nodeType === b.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
170
+ if (e.nodeType === x.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
172
171
  let t = e.path.lastIndexOf("/");
173
172
  return t > 0 ? e.path.slice(0, t + 1) : "";
174
173
  }))]), i.some((e) => A === e || A.startsWith(e)) && L((e) => e.replace(/[^/]+\/$/, "")), F(), W(!1);
@@ -184,7 +183,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
184
183
  P,
185
184
  F,
186
185
  L
187
- ]), oe = g((e, n) => {
186
+ ]), ce = g((e, n) => {
188
187
  if (!e || e.trim() === "") return { reason: t.Empty };
189
188
  if (e === r) return { reason: t.ReservedName };
190
189
  if (o(e, V)) return {
@@ -200,20 +199,21 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
200
199
  reason: t.DuplicateName,
201
200
  existingName: s.name
202
201
  } : null;
203
- }, [V, j]), se = g((t, r) => {
202
+ }, [V, j]), le = g((t, r) => {
204
203
  if (t.length === 0 || q || Y) return;
205
204
  let a = new AbortController();
206
205
  Z.current = a, (async () => {
207
206
  J(!0);
208
207
  let o = f(t, D, O), s = o.map(({ dto: e }) => e);
209
208
  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,
209
+ let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, u = t.length - c;
210
+ if (u > 0) {
211
+ let e = m(o, t), a = s.every((e) => l(e.sourcePath) === l(e.destinationPath)), c;
212
+ c = a ? u === 1 ? n.FileDuplicated : n.FilesDuplicated : u === 1 ? n.FileCopied : n.FilesCopied, z?.({
213
+ kind: c,
215
214
  name: e?.destinationName,
216
- count: l,
215
+ count: u,
216
+ isFolder: e?.dto.nodeType === b.Folder,
217
217
  destinationFolderName: i(r, O)
218
218
  });
219
219
  }
@@ -244,21 +244,21 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
244
244
  Y,
245
245
  P,
246
246
  F
247
- ]), ce = g(() => {
247
+ ]), ue = g(() => {
248
248
  Z.current?.abort();
249
249
  }, []);
250
250
  return {
251
- isCreatingFolder: ee,
252
- isDownloading: te,
253
- isDeleting: ne,
251
+ isCreatingFolder: ne,
252
+ isDownloading: re,
253
+ isDeleting: ie,
254
254
  isRenaming: G,
255
255
  isCopying: q,
256
256
  isMoving: Y,
257
- onCreateFolder: re,
257
+ onCreateFolder: ae,
258
258
  onCreateFolderValidate: $,
259
- onDownloadFiles: ie,
260
- onDeleteFiles: ae,
261
- onRenameValidate: oe,
259
+ onDownloadFiles: oe,
260
+ onDeleteFiles: se,
261
+ onRenameValidate: ce,
262
262
  onMoveToFiles: g((t, r, o) => {
263
263
  if (t.length === 0 || q || Y || G) return;
264
264
  let { renameDtos: s, preparedMoveItems: c } = p(t, D, O), u = c.map(({ dto: e }) => e), d = new AbortController();
@@ -308,6 +308,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
308
308
  kind: _ === 1 ? n.FileMoved : n.FilesMoved,
309
309
  name: e?.destinationName,
310
310
  count: _,
311
+ isFolder: e?.dto.nodeType === ee.Folder,
311
312
  destinationFolderName: i(o, O)
312
313
  });
313
314
  }
@@ -316,7 +317,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
316
317
  z?.({
317
318
  kind: n.FileRenamed,
318
319
  name: a(e.destinationPath, e.destinationPath),
319
- isFolder: e.nodeType === x.Folder
320
+ isFolder: e.nodeType === te.Folder
320
321
  });
321
322
  }
322
323
  y > 0 && (y === v ? R?.({
@@ -327,11 +328,11 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
327
328
  reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
328
329
  count: y
329
330
  }));
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}/`;
331
+ let x = s.find((e) => e.nodeType === te.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
332
+ if (x != null) {
333
+ let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
333
334
  if (A === e || A.startsWith(e)) {
334
- let t = S.destinationPath.endsWith("/") ? S.destinationPath : `${S.destinationPath}/`;
335
+ let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
335
336
  L(A.replace(e, t));
336
337
  }
337
338
  }
@@ -351,8 +352,8 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
351
352
  F,
352
353
  L
353
354
  ]),
354
- onCopyFiles: se,
355
- cancelCopyMove: ce
355
+ onCopyFiles: le,
356
+ cancelCopyMove: ue
356
357
  };
357
358
  };
358
359
  //#endregion