@epam/ai-dial-chat-hooks 1.1.0-dev.423 → 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.
- package/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
- package/api-transport/create-csrf-middleware.js +21 -0
- package/api-transport/create-unauthorized-middleware.js +41 -0
- package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
- package/attachments.js +3 -2
- package/catalog/catalog-derivations.js +10 -0
- package/catalog/catalog-primary-action.js +21 -0
- package/catalog/create-publish-api.js +27 -0
- package/catalog/deployment-endpoint-url.js +34 -0
- package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
- package/catalog/entity-details.js +6 -0
- package/catalog/map-deployment-limits-to-catalog.js +73 -0
- package/catalog/map-deployment-limits-to-input.js +14 -0
- package/catalog/map-deployment-to-catalog-item.js +92 -0
- package/catalog/map-entity-details-to-catalog.js +350 -0
- package/catalog/map-prompt-to-catalog-item.js +49 -0
- package/catalog/map-skill-to-catalog-item.js +123 -0
- package/catalog/mcp-endpoint-url.js +26 -0
- package/catalog/publish.js +18 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
- package/catalog/useCatalogItemDetails.js +101 -0
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
- package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
- package/catalog/usePublishFolders/usePublishFolders.js +72 -0
- package/catalog.js +22 -3
- package/conversation/announcement-message.js +42 -0
- package/conversation/conversation-transfer/async.js +18 -0
- package/conversation/conversation-transfer/attachment-refs.js +11 -0
- package/conversation/conversation-transfer/build-upload-path.js +27 -0
- package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
- package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
- package/conversation/conversation-transfer/export-conversation.js +32 -0
- package/conversation/conversation-transfer/import-conversation.js +93 -0
- package/conversation/conversation-transfer/progress.js +39 -0
- package/conversation/conversation-transfer/queue.js +84 -0
- package/conversation/conversation-transfer/types.js +9 -0
- package/conversation/conversation-transfer/zip-export.js +19 -0
- package/conversation/conversation-transfer/zip-import.js +29 -0
- package/conversation/create-chat-stream-api.js +96 -0
- package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
- package/conversation/display-name-watch.js +5 -0
- package/conversation/footer-message.js +23 -0
- package/conversation/get-model-id-from-conversation-id.js +14 -0
- package/conversation/greeting.js +7 -0
- package/conversation/message-factory.js +19 -0
- package/conversation/message-utils.js +13 -0
- package/conversation/overlay-messages.js +8 -0
- package/conversation/quick-app-conversation-starters.js +29 -0
- package/conversation/starter-option.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
- package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
- package/conversation/useConversationExport/useConversationExport.js +285 -0
- package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
- package/conversation/useConversationHandlers/message-factory.js +21 -0
- package/conversation/useConversationHandlers/message-utils.js +8 -0
- package/conversation/useConversationHandlers/starter-option.js +11 -0
- package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
- package/conversation/useConversationImport/useConversationImport.js +239 -0
- package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
- package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
- package/conversation/useConversationStream/apply-chunk.js +78 -0
- package/conversation/useConversationStream/buffered-generation.js +18 -0
- package/conversation/useConversationStream/conversation-path.js +8 -0
- package/conversation/useConversationStream/generation-resume.js +126 -0
- package/conversation/useConversationStream/useConversationStream.js +148 -0
- package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
- package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
- package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
- package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
- package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
- package/conversation-sources.js +1 -1
- package/conversation-transfer.js +7 -3
- package/conversation.d.ts +66 -0
- package/conversation.js +31 -2
- package/file-manager.d.ts +3 -4
- package/file-manager.js +28 -3
- package/files/annotation.js +15 -0
- package/files/attachment-canvas.js +218 -0
- package/files/attachment-dto-to-display.js +15 -0
- package/files/attachment-types.js +16 -0
- package/files/create-files-api.js +40 -0
- package/files/create-upload-file-with-progress.js +42 -0
- package/files/dial-file-manager-copy-move.util.js +55 -0
- package/files/dial-file-manager-mapping.util.js +140 -0
- package/files/dial-file-manager-path.util.js +72 -0
- package/files/dial-file-manager.model.js +25 -0
- package/files/dial-file-manager.types.js +10 -0
- package/files/dial-file-to-attachment.js +37 -0
- package/files/dial-file.js +30 -0
- package/files/dial-files-api.js +6 -0
- package/files/download-destination.js +6 -0
- package/files/file-manager-variant.js +11 -0
- package/files/file-name.js +19 -0
- package/files/prepare-download-destination.js +24 -0
- package/files/resolve-dial-file-api-path.js +33 -0
- package/files/source-content.js +37 -0
- package/files/useDialFileListing/useDialFileListing.js +295 -0
- package/files/useDialFileManager/useDialFileManager.js +146 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
- package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
- package/files/useDialFileMutations/useDialFileMutations.js +359 -0
- package/files/useDialFileSharing/useDialFileSharing.js +70 -0
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
- package/index.d.ts +69 -4
- package/index.js +134 -28
- package/mcp-apps/mcp-apps-api-client.js +48 -0
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
- package/mcp-apps.js +6 -2
- package/oauth/authorize-url.js +12 -0
- package/oauth/handshake.js +65 -0
- package/oauth/popup.js +29 -0
- package/oauth/toolset-id.js +10 -0
- package/oauth/types.js +24 -0
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
- package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
- package/oauth.js +9 -3
- package/package.json +35 -23
- package/prompt/export-prompt.js +28 -0
- package/prompt/prompt-resource.js +15 -0
- package/prompt/prompt.js +12 -0
- package/prompt/usePromptsState/usePromptsState.js +42 -0
- package/scheduled-task/scheduled-task-mapping.js +6 -0
- package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
- package/scheduled-tasks.js +3 -2
- package/scroll-anchoring.js +1 -1
- package/shared/application-schema.js +4 -0
- package/shared/browser-timezone.js +10 -0
- package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
- package/shared/custom-apps.js +30 -0
- package/shared/external-services.js +18 -0
- package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
- package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
- package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
- package/shared/toolset-login-events.js +13 -0
- package/sharing.js +3 -3
- package/skill/skill-file-batch-validation.js +48 -0
- package/skill/skill-file-preview.js +15 -0
- package/skill/skill-manifest.js +70 -0
- package/skill/skill-types.js +15 -0
- package/skill/skill.js +48 -0
- package/skill/useSkillEditorLoad.js +103 -0
- package/skill/useSkillEditorSubmit.js +135 -0
- package/skill/useSkillFileActions.js +99 -0
- package/skill/useSkillFilePreview.js +29 -0
- package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
- package/skill-editor.js +8 -3
- package/skills-state.js +1 -1
- package/source-content.d.ts +29 -0
- package/source-content.js +2 -0
- package/usage/useUsageData/useUsageData.js +32 -0
- package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
- package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
- package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
- package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
- package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
- package/useToolsMenu/useToolsMenu.js +50 -0
- package/useViewportWidth/useViewportWidth.js +12 -0
- package/utils.js +17 -7
- package/viewport-layout.js +4 -2
- package/attachment-types-AAoN9E95.js +0 -7760
- package/browser-Btsa0Lmr.js +0 -607
- package/skill-manifest-CeG6-WSK.js +0 -4056
- package/useAttachmentValidation-CkMTd5lA.js +0 -102
- package/useConversationImport-CDRs7JF1.js +0 -826
- package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
- package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
- package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
- package/useSkillFileActions-B-VaGD20.js +0 -373
- package/useSkillFilePreview-B5o1n_0F.js +0 -1244
- package/useToolsMenu-zURpMEn1.js +0 -1882
- package/useToolsetLogin-B05m134e.js +0 -195
- package/useUsageData-D7BxloKZ.js +0 -201
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/files/create-upload-file-with-progress.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let { uploadUrl: t, xhrFactory: n = () => new XMLHttpRequest() } = e;
|
|
4
|
+
return (r, i, a, { signal: o, onProgress: s, uploadMode: c } = {}) => new Promise((l, u) => {
|
|
5
|
+
let d = n();
|
|
6
|
+
d.open("POST", t), d.withCredentials = !0;
|
|
7
|
+
let f = e.getCsrfToken();
|
|
8
|
+
f != null && d.setRequestHeader("X-CSRF-Token", f);
|
|
9
|
+
let p = new FormData();
|
|
10
|
+
if (p.append("file", a), p.append("bucket", r), p.append("path", i), c != null && p.append("uploadMode", c), d.upload.addEventListener("progress", (e) => {
|
|
11
|
+
!s || !e.lengthComputable || e.total <= 0 || s(Math.min(100, Math.round(e.loaded / e.total * 100)));
|
|
12
|
+
}), d.addEventListener("load", () => {
|
|
13
|
+
let n = d.getResponseHeader("x-csrf-token");
|
|
14
|
+
if (n && e.setCsrfToken(n), d.status >= 200 && d.status < 300) {
|
|
15
|
+
try {
|
|
16
|
+
l(JSON.parse(d.responseText));
|
|
17
|
+
} catch {
|
|
18
|
+
u(/* @__PURE__ */ Error("Upload response was not valid JSON"));
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (d.status === 401) {
|
|
23
|
+
e.notifyUnauthorized(t), u(e.createUnauthorizedError(t));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
u(/* @__PURE__ */ Error(`Upload failed with status ${d.status}`));
|
|
27
|
+
}), d.addEventListener("error", () => {
|
|
28
|
+
u(/* @__PURE__ */ Error("Upload failed"));
|
|
29
|
+
}), d.addEventListener("abort", () => {
|
|
30
|
+
u(new DOMException("Upload aborted", "AbortError"));
|
|
31
|
+
}), o != null) {
|
|
32
|
+
if (o.aborted) {
|
|
33
|
+
d.abort();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
o.addEventListener("abort", () => d.abort(), { once: !0 });
|
|
37
|
+
}
|
|
38
|
+
d.send(p);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { e as createUploadFileWithProgress };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getVirtualPathName as e } from "./dial-file-manager-path.util.js";
|
|
2
|
+
import { getParentFolderPath as t, virtualPathToApiPath as n } from "./resolve-dial-file-api-path.js";
|
|
3
|
+
import { CopyItemDtoNodeTypeEnum as r, MoveItemDtoNodeTypeEnum as i, RenameItemDtoNodeTypeEnum as a } from "@epam/ai-dial-chat-api-client";
|
|
4
|
+
import { DialFileNodeType as o } from "@epam/ai-dial-react-file-manager";
|
|
5
|
+
//#region src/files/dial-file-manager-copy-move.util.ts
|
|
6
|
+
var s = (t, i, a) => t.map((t) => {
|
|
7
|
+
let s = t.nodeType === o.FOLDER, c = n(t.sourceUrl, a), l = n(t.destinationUrl, a), u = e(t.sourceUrl, c);
|
|
8
|
+
return {
|
|
9
|
+
destinationName: e(t.destinationUrl, l),
|
|
10
|
+
dto: {
|
|
11
|
+
bucket: i,
|
|
12
|
+
sourcePath: s ? c.endsWith("/") ? c : `${c}/` : c.replace(/\/$/, ""),
|
|
13
|
+
destinationPath: s ? l.endsWith("/") ? l : `${l}/` : l.replace(/\/$/, ""),
|
|
14
|
+
overwrite: t.overwrite === !0,
|
|
15
|
+
nodeType: s ? r.Folder : r.Item,
|
|
16
|
+
name: u
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}), c = (r, s, c) => {
|
|
20
|
+
let l = r.map((r) => {
|
|
21
|
+
let i = r.nodeType === o.FOLDER, a = n(r.sourceUrl, c), s = n(r.destinationUrl, c), l = e(r.sourceUrl, a), u = e(r.destinationUrl, s), d = i ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, ""), f = i ? s.endsWith("/") ? s : `${s}/` : s.replace(/\/$/, "");
|
|
22
|
+
return {
|
|
23
|
+
isFolder: i,
|
|
24
|
+
name: l,
|
|
25
|
+
destinationName: u,
|
|
26
|
+
overwrite: r.overwrite === !0,
|
|
27
|
+
sourcePath: d,
|
|
28
|
+
destinationPath: f,
|
|
29
|
+
sourceParent: t(d),
|
|
30
|
+
destinationParent: t(f)
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
renameDtos: l.filter((e) => e.sourceParent === e.destinationParent).map((e) => ({
|
|
35
|
+
bucket: s,
|
|
36
|
+
sourcePath: e.sourcePath,
|
|
37
|
+
destinationPath: e.destinationPath,
|
|
38
|
+
nodeType: e.isFolder ? a.Folder : a.Item,
|
|
39
|
+
name: e.name
|
|
40
|
+
})),
|
|
41
|
+
preparedMoveItems: l.filter((e) => e.sourceParent !== e.destinationParent).map((e) => ({
|
|
42
|
+
destinationName: e.destinationName,
|
|
43
|
+
dto: {
|
|
44
|
+
bucket: s,
|
|
45
|
+
sourcePath: e.sourcePath,
|
|
46
|
+
destinationPath: e.destinationPath,
|
|
47
|
+
overwrite: e.overwrite,
|
|
48
|
+
nodeType: e.isFolder ? i.Folder : i.Item,
|
|
49
|
+
name: e.name
|
|
50
|
+
}
|
|
51
|
+
}))
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { s as prepareCopyItems, c as prepareMoveRenameItems };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { CORE_PERMISSION_MAP as e } from "./dial-file-manager.model.js";
|
|
2
|
+
import { buildSharedItemVirtualPath as t, dialCorePathToRelative as n } from "./dial-file-manager-path.util.js";
|
|
3
|
+
import { ListFilesItemDtoNodeTypeEnum as r } from "@epam/ai-dial-chat-api-client";
|
|
4
|
+
import { DialFileManagerTabs as i, DialFileNodeType as a } from "@epam/ai-dial-react-file-manager";
|
|
5
|
+
//#region src/files/dial-file-manager-mapping.util.ts
|
|
6
|
+
var o = (t) => {
|
|
7
|
+
if (!t?.length) return;
|
|
8
|
+
let n = t.map((t) => e[t.toUpperCase()]).filter((e) => e != null);
|
|
9
|
+
return n.length > 0 ? n : void 0;
|
|
10
|
+
}, s = (e, t) => {
|
|
11
|
+
let n = t.find((e) => e.success);
|
|
12
|
+
if (n != null) return e.find(({ dto: e }) => e.sourcePath === n.sourcePath && e.destinationPath === n.destinationPath) ?? e.find(({ dto: e }) => e.destinationPath === n.destinationPath) ?? e[0];
|
|
13
|
+
}, c = (e, t, n, i, s) => {
|
|
14
|
+
let l = e.get(n);
|
|
15
|
+
if (l == null) return [];
|
|
16
|
+
let u = i.replace(/\/$/, "");
|
|
17
|
+
return l.map((l) => {
|
|
18
|
+
let d = l.nodeType === r.Folder, f = l.name, p = d ? `${u}/${f}/` : `${u}/${f}`, m = {
|
|
19
|
+
id: l.path,
|
|
20
|
+
name: f,
|
|
21
|
+
path: p,
|
|
22
|
+
url: l.url,
|
|
23
|
+
parentPath: i,
|
|
24
|
+
nodeType: d ? a.FOLDER : a.ITEM,
|
|
25
|
+
folderId: s,
|
|
26
|
+
bucket: l.bucket,
|
|
27
|
+
author: l.author,
|
|
28
|
+
resourceType: l.resourceType,
|
|
29
|
+
contentLength: l.contentLength,
|
|
30
|
+
contentType: l.contentType,
|
|
31
|
+
updatedAt: l.updatedAt ? new Date(l.updatedAt).toISOString() : void 0
|
|
32
|
+
};
|
|
33
|
+
if (d) {
|
|
34
|
+
let r = `${n}${f}/`;
|
|
35
|
+
m.permissions = o(l.permissions) ?? o(t.get(r)), m.items = c(e, t, r, p, l.path);
|
|
36
|
+
}
|
|
37
|
+
return m;
|
|
38
|
+
});
|
|
39
|
+
}, l = (e, t, n, i) => {
|
|
40
|
+
let a = new Map(e), o = [...a.get(t) ?? []], s = {
|
|
41
|
+
name: n.name,
|
|
42
|
+
path: n.path,
|
|
43
|
+
folderId: n.folderId,
|
|
44
|
+
nodeType: r.Folder,
|
|
45
|
+
bucket: n.bucket,
|
|
46
|
+
parentPath: n.parentPath || void 0,
|
|
47
|
+
url: n.path,
|
|
48
|
+
permissions: i
|
|
49
|
+
};
|
|
50
|
+
return o.some((e) => e.name.toLowerCase() === n.name.toLowerCase()) || o.push(s), a.set(t, o), a;
|
|
51
|
+
}, u = (e, t, n) => {
|
|
52
|
+
if (!e) return e;
|
|
53
|
+
let r = typeof n == "string" ? { status: n } : n, i = e.files.map((e, n) => n === t ? {
|
|
54
|
+
...e,
|
|
55
|
+
...r
|
|
56
|
+
} : e);
|
|
57
|
+
return {
|
|
58
|
+
...e,
|
|
59
|
+
files: i
|
|
60
|
+
};
|
|
61
|
+
}, d = (e, t, r, a, o) => {
|
|
62
|
+
if (t === i.Shared) {
|
|
63
|
+
if (a === "") return e.listSharedFiles({ path: void 0 }).then((e) => ({ items: e.items }));
|
|
64
|
+
let t = a.indexOf("/"), r = t === -1 ? a : a.slice(0, t), i = o.get(r);
|
|
65
|
+
if (i) {
|
|
66
|
+
let r = n(i.dialCorePath, i.bucket) + (t === -1 ? "" : a.slice(t + 1));
|
|
67
|
+
return e.listFiles({
|
|
68
|
+
bucket: i.bucket,
|
|
69
|
+
path: r,
|
|
70
|
+
permissions: !0
|
|
71
|
+
}).then((e) => ({
|
|
72
|
+
items: e.items,
|
|
73
|
+
permissions: e.permissions
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
return Promise.resolve({ items: [] });
|
|
77
|
+
}
|
|
78
|
+
return t === i.Organization ? e.listPublicFiles({ path: a || void 0 }).then((e) => ({ items: e.items })) : e.listFiles({
|
|
79
|
+
bucket: r,
|
|
80
|
+
path: a,
|
|
81
|
+
permissions: !0
|
|
82
|
+
}).then((e) => ({
|
|
83
|
+
items: e.items,
|
|
84
|
+
permissions: e.permissions
|
|
85
|
+
}));
|
|
86
|
+
}, f = async (e, t, r, a, o) => {
|
|
87
|
+
if (t === i.Shared) {
|
|
88
|
+
let t = a.indexOf("/"), r = t === -1 ? a : a.slice(0, t), i = o.get(r);
|
|
89
|
+
if (!i) return { items: [] };
|
|
90
|
+
let s = n(i.dialCorePath, i.bucket) + (t === -1 ? "" : a.slice(t + 1)), { items: c } = await e.listFiles({
|
|
91
|
+
bucket: i.bucket,
|
|
92
|
+
path: s,
|
|
93
|
+
permissions: !0,
|
|
94
|
+
recursive: !0
|
|
95
|
+
});
|
|
96
|
+
return { items: c };
|
|
97
|
+
}
|
|
98
|
+
if (t === i.Organization) {
|
|
99
|
+
let { items: t } = await e.listPublicFiles({
|
|
100
|
+
path: a || void 0,
|
|
101
|
+
recursive: !0
|
|
102
|
+
});
|
|
103
|
+
return { items: t };
|
|
104
|
+
}
|
|
105
|
+
let { items: s } = await e.listFiles({
|
|
106
|
+
bucket: r,
|
|
107
|
+
path: a,
|
|
108
|
+
permissions: !0,
|
|
109
|
+
recursive: !0
|
|
110
|
+
});
|
|
111
|
+
return { items: s };
|
|
112
|
+
}, p = (e, i, o) => {
|
|
113
|
+
let s = e.nodeType === r.Folder, c = e.name, l = e.bucket ?? i, u = n(e.url ?? e.path ?? "", l).replace(/\/$/, ""), d = u.lastIndexOf("/"), f = t(d > 0 ? u.slice(0, d) : "", o, !1), p = s ? `${f}/${c}/` : `${f}/${c}`;
|
|
114
|
+
return {
|
|
115
|
+
id: e.path,
|
|
116
|
+
name: c,
|
|
117
|
+
path: p,
|
|
118
|
+
url: e.url,
|
|
119
|
+
parentPath: f,
|
|
120
|
+
nodeType: s ? a.FOLDER : a.ITEM,
|
|
121
|
+
folderId: e.folderId,
|
|
122
|
+
bucket: l,
|
|
123
|
+
author: e.author,
|
|
124
|
+
contentLength: e.contentLength,
|
|
125
|
+
contentType: e.contentType,
|
|
126
|
+
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : void 0
|
|
127
|
+
};
|
|
128
|
+
}, m = (e, t) => ({
|
|
129
|
+
...t,
|
|
130
|
+
bucket: e.bucket ?? t.bucket,
|
|
131
|
+
author: e.author,
|
|
132
|
+
contentLength: e.contentLength,
|
|
133
|
+
contentType: e.contentType,
|
|
134
|
+
resourceType: e.resourceType ?? t.resourceType,
|
|
135
|
+
permissions: o(e.permissions) ?? t.permissions,
|
|
136
|
+
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : t.updatedAt,
|
|
137
|
+
createdAt: e.createdAt ? new Date(e.createdAt).toISOString() : t.createdAt
|
|
138
|
+
});
|
|
139
|
+
//#endregion
|
|
140
|
+
export { c as buildFromCache, d as fetchByTab, f as fetchForSearch, s as findFirstSuccessfulCopyMoveItem, o as mapCorePermissions, m as mapFileMetadataToDialFile, p as mapSearchItem, l as mergeCreatedFolderIntoCache, u as updateEntry };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../shared/string-utils.js";
|
|
2
|
+
import { PATH_SEPARATOR_REGEXP as t } from "./dial-file-manager.model.js";
|
|
3
|
+
import { DialFileManagerActionProfile as n } from "./file-manager-variant.js";
|
|
4
|
+
import { DialFileNodeType as r, DialFilePermission as i } from "@epam/ai-dial-react-file-manager";
|
|
5
|
+
//#region src/files/dial-file-manager-path.util.ts
|
|
6
|
+
var a = (e, n) => {
|
|
7
|
+
if (t.test(e)) return !0;
|
|
8
|
+
if (n == null) return !1;
|
|
9
|
+
n.lastIndex = 0;
|
|
10
|
+
let r = n.test(e);
|
|
11
|
+
return n.lastIndex = 0, r;
|
|
12
|
+
}, o = (e) => e.replace(/\/+$/, "") || "/", s = (e, t) => {
|
|
13
|
+
let n = e.split("/").filter(Boolean);
|
|
14
|
+
return n[n.length - 1] ?? t;
|
|
15
|
+
}, c = (e, t) => o(e || `/${t}`).replace(/^\/+/, "") || t, l = (e, t) => {
|
|
16
|
+
let n = o(t);
|
|
17
|
+
for (let i of e) {
|
|
18
|
+
if (i.nodeType !== r.FOLDER) continue;
|
|
19
|
+
if (o(i.path) === n) return i;
|
|
20
|
+
let e = l(i.items ?? [], t);
|
|
21
|
+
if (e) return e;
|
|
22
|
+
}
|
|
23
|
+
}, u = (e) => e?.permissions?.includes(i.WRITE) ?? !1, d = (e, t) => {
|
|
24
|
+
for (let n of e) {
|
|
25
|
+
if (n.path === t || n.id === t) return n;
|
|
26
|
+
let e = d(n.items ?? [], t);
|
|
27
|
+
if (e) return e;
|
|
28
|
+
}
|
|
29
|
+
}, f = (e) => {
|
|
30
|
+
switch (e) {
|
|
31
|
+
case n.Attach: return !1;
|
|
32
|
+
case n.Browse:
|
|
33
|
+
case n.Full: return !0;
|
|
34
|
+
default: throw Error(`Unhandled actionProfile: ${String(e)}`);
|
|
35
|
+
}
|
|
36
|
+
}, p = (e) => e === n.Full, m = (e, t) => {
|
|
37
|
+
let n = e.replace(/\/$/, ""), r = n.lastIndexOf("/");
|
|
38
|
+
if (r <= 0) {
|
|
39
|
+
let e = r === 0 ? n.slice(1) : n;
|
|
40
|
+
return {
|
|
41
|
+
parentVirtualPath: `/${t}`,
|
|
42
|
+
name: e
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
parentVirtualPath: n.slice(0, r),
|
|
47
|
+
name: n.slice(r + 1)
|
|
48
|
+
};
|
|
49
|
+
}, h = (e, t) => {
|
|
50
|
+
let n = `files/${t}/`;
|
|
51
|
+
return e.startsWith(n) ? e.slice(n.length) : e;
|
|
52
|
+
}, g = (t, n, r) => {
|
|
53
|
+
let i = t.replace(/\/+$/, "").split("/").filter(Boolean).map(e).join("/"), a = i ? `/${n}/${i}` : `/${n}`;
|
|
54
|
+
return r ? `${a}/` : a;
|
|
55
|
+
}, _ = (e, t, n) => {
|
|
56
|
+
if (!e) return {
|
|
57
|
+
bucket: n,
|
|
58
|
+
path: e
|
|
59
|
+
};
|
|
60
|
+
let r = e.indexOf("/"), i = r === -1 ? e : e.slice(0, r), a = t.get(i);
|
|
61
|
+
if (!a) return {
|
|
62
|
+
bucket: n,
|
|
63
|
+
path: e
|
|
64
|
+
};
|
|
65
|
+
let o = h(a.dialCorePath, a.bucket), s = r === -1 ? "" : e.slice(r + 1);
|
|
66
|
+
return {
|
|
67
|
+
bucket: a.bucket,
|
|
68
|
+
path: o + s
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { g as buildSharedItemVirtualPath, h as dialCorePathToRelative, d as findDialFileByPath, l as findFolderByVirtualPath, c as formatOperationFolderName, s as getVirtualPathName, u as hasDialFileWritePermission, a as hasForbiddenNameSymbols, f as isCopyMoveDuplicateAllowed, p as isShareActionsAllowed, o as normalizeVirtualPath, m as parseNewFolderVirtualPath, _ as resolveOwnerCoords };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HIDDEN_FILE as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { DialFilePermission as t, FileManagerColumnKey as n } from "@epam/ai-dial-react-file-manager";
|
|
3
|
+
//#region src/files/dial-file-manager.model.ts
|
|
4
|
+
var r = 3, i = e, a = /[/\\]/, o = {
|
|
5
|
+
year: "numeric",
|
|
6
|
+
month: "short",
|
|
7
|
+
day: "2-digit"
|
|
8
|
+
}, s = [
|
|
9
|
+
n.Name,
|
|
10
|
+
n.UpdatedAt,
|
|
11
|
+
n.Size,
|
|
12
|
+
n.Actions
|
|
13
|
+
], c = [
|
|
14
|
+
n.Name,
|
|
15
|
+
n.UpdatedAt,
|
|
16
|
+
n.Size,
|
|
17
|
+
n.Author,
|
|
18
|
+
n.Actions
|
|
19
|
+
], l = {
|
|
20
|
+
READ: t.READ,
|
|
21
|
+
WRITE: t.WRITE,
|
|
22
|
+
SHARE: t.SHARE
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { s as COLUMNS_WITHOUT_AUTHOR, c as COLUMNS_WITH_AUTHOR, l as CORE_PERMISSION_MAP, o as DATE_OPTIONS, a as PATH_SEPARATOR_REGEXP, i as RESERVED_MARKER_NAME, r as UPLOAD_CONCURRENCY };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/files/dial-file-manager.types.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.FolderLoadFailed = "folderLoadFailed", e.MetadataLoadFailed = "metadataLoadFailed", e.FolderCreateFailed = "folderCreateFailed", e.DownloadFileFailed = "downloadFileFailed", e.DownloadFilesFailed = "downloadFilesFailed", e.FilesDeleted = "filesDeleted", e.FilesDeletePartiallyFailed = "filesDeletePartiallyFailed", e.DeleteFailed = "deleteFailed", e.RenameFailed = "renameFailed", e.RenamePartiallyFailed = "renamePartiallyFailed", e.MoveFailed = "moveFailed", e.MovePartiallyFailed = "movePartiallyFailed", e.CopyFailed = "copyFailed", e.CopyPartiallyFailed = "copyPartiallyFailed", e.UnshareFailed = "unshareFailed", e.RemoveAccessFailed = "removeAccessFailed", e.UploadFailed = "uploadFailed", e.UploadCompleted = "uploadCompleted", e.UploadArchiveFailed = "uploadArchiveFailed", e.UploadArchivePartiallyFailed = "uploadArchivePartiallyFailed", e.UploadArchiveRequestFailed = "uploadArchiveRequestFailed", e;
|
|
4
|
+
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e.LeadingDot = "leadingDot", e;
|
|
6
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e;
|
|
8
|
+
}({});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as FileManagerNotificationReason, t as FileNameValidationErrorReason, n as FileOperationKind };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../shared/string-utils.js";
|
|
2
|
+
import { isDialFileId as t } from "./dial-file.js";
|
|
3
|
+
import { AttachmentType as n, RequestStatus as r } from "@epam/ai-dial-chat-shared";
|
|
4
|
+
import { DialFileNodeType as i } from "@epam/ai-dial-ui-kit";
|
|
5
|
+
//#region src/files/dial-file-to-attachment.ts
|
|
6
|
+
var a = (e, n) => {
|
|
7
|
+
let r = e.url ?? e.id;
|
|
8
|
+
if (r) return t(r) || r.startsWith("http://") || r.startsWith("https://") ? r : `files/${n}/${r.replace(/^\/+/, "")}`;
|
|
9
|
+
}, o = (e, t, o) => {
|
|
10
|
+
if (e.nodeType !== i.ITEM) return null;
|
|
11
|
+
let s = a(e, t);
|
|
12
|
+
if (!s) return null;
|
|
13
|
+
let c = e.contentType ?? "application/octet-stream", l = c.startsWith("image/"), u = l ? o?.resolvePreviewUrl?.(s) : void 0;
|
|
14
|
+
return {
|
|
15
|
+
id: s,
|
|
16
|
+
name: e.name,
|
|
17
|
+
contentType: c,
|
|
18
|
+
type: l ? n.Image : n.File,
|
|
19
|
+
status: r.Idle,
|
|
20
|
+
url: s,
|
|
21
|
+
file: new File([], e.name, { type: c }),
|
|
22
|
+
...u == null ? {} : { previewUrl: u }
|
|
23
|
+
};
|
|
24
|
+
}, s = (e, t, n) => e.map((e) => o(e, t, n)).filter((e) => e != null), c = (t) => {
|
|
25
|
+
let i = e(t.replace(/\/$/, "").split("/").filter(Boolean).pop() ?? "");
|
|
26
|
+
return {
|
|
27
|
+
id: t,
|
|
28
|
+
name: i,
|
|
29
|
+
contentType: "application/octet-stream",
|
|
30
|
+
type: n.File,
|
|
31
|
+
status: r.Idle,
|
|
32
|
+
url: t,
|
|
33
|
+
file: new File([], i)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { o as dialFileToAttachment, s as dialFilesToAttachments, c as dialFolderPathToAttachment };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../shared/string-utils.js";
|
|
2
|
+
//#region src/files/dial-file.ts
|
|
3
|
+
var t = (e) => e.startsWith("files/"), n = (n, r) => {
|
|
4
|
+
let i = `files/${r}/`;
|
|
5
|
+
if (n.startsWith(i)) return e(n.slice(i.length));
|
|
6
|
+
if (t(n)) {
|
|
7
|
+
let t = n.slice(6), i = t.indexOf("/");
|
|
8
|
+
if (i >= 0) {
|
|
9
|
+
let n = t.slice(0, i), a = t.slice(i + 1);
|
|
10
|
+
if (n === r) return e(a);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}, r = (e) => {
|
|
15
|
+
if (!t(e)) return;
|
|
16
|
+
let n = e.slice(6), r = n.indexOf("/");
|
|
17
|
+
if (r < 0) return;
|
|
18
|
+
let i = n.slice(0, r), a = n.slice(r + 1), o;
|
|
19
|
+
try {
|
|
20
|
+
o = decodeURIComponent(a);
|
|
21
|
+
} catch {
|
|
22
|
+
o = a;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
bucket: i,
|
|
26
|
+
path: o
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { t as isDialFileId, r as resolveDialFileBucketAndPath, n as resolveRelativeDialFilePath };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DialFileManagerActionProfile as e, DialFileManagerVariant as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/files/file-manager-variant.ts
|
|
3
|
+
var n = (n) => {
|
|
4
|
+
switch (n) {
|
|
5
|
+
case t.Attach: return e.Attach;
|
|
6
|
+
case t.Standalone: return e.Browse;
|
|
7
|
+
case t.FolderPicker: return e.Full;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as DialFileManagerActionProfile, t as DialFileManagerVariant, n as deriveActionProfile };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getUtf8ByteLength as e, truncateToUtf8Bytes as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { NOT_ALLOWED_SYMBOLS_REGEXP as n } from "@epam/ai-dial-ui-kit";
|
|
3
|
+
//#region src/files/file-name.ts
|
|
4
|
+
var r = (e) => {
|
|
5
|
+
let t = e.lastIndexOf("."), n = t > 0;
|
|
6
|
+
return {
|
|
7
|
+
base: n ? e.slice(0, t) : e,
|
|
8
|
+
extension: n ? e.slice(t) : ""
|
|
9
|
+
};
|
|
10
|
+
}, i = (n, i = 255) => {
|
|
11
|
+
if (e(n) <= i) return n;
|
|
12
|
+
let { base: a, extension: o } = r(n), s = i - e(o);
|
|
13
|
+
return s <= 0 ? t(n, i) : `${t(a, s)}${o}`;
|
|
14
|
+
}, a = (e) => {
|
|
15
|
+
let { base: t, extension: a } = r(e), o = t.replace(new RegExp(n.source, "g"), "_").replace(/[.\s]+$/, "");
|
|
16
|
+
return o === "" ? e : i(`${o}${a}`);
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { a as sanitizeFileName, r as splitFileNameExtension, i as trimFileNameToByteLimit };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DownloadDestinationType as e } from "./download-destination.js";
|
|
2
|
+
//#region src/files/prepare-download-destination.ts
|
|
3
|
+
var t = async (t, n = "application/octet-stream") => {
|
|
4
|
+
let r = window.showSaveFilePicker;
|
|
5
|
+
if (r == null) return { type: e.Blob };
|
|
6
|
+
try {
|
|
7
|
+
let i = t.lastIndexOf("."), a = i >= 0 ? t.slice(i) : void 0, o = await r.call(window, {
|
|
8
|
+
suggestedName: t,
|
|
9
|
+
types: [{
|
|
10
|
+
description: n,
|
|
11
|
+
accept: { [n]: a == null ? [] : [a] }
|
|
12
|
+
}]
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
type: e.Stream,
|
|
16
|
+
writable: await o.createWritable()
|
|
17
|
+
};
|
|
18
|
+
} catch (t) {
|
|
19
|
+
if (t instanceof DOMException && t.name === "AbortError") return { type: e.Cancelled };
|
|
20
|
+
throw t;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as prepareDownloadDestination };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../shared/string-utils.js";
|
|
2
|
+
import { getParentFolderPath as t } from "@epam/ai-dial-chat-shared";
|
|
3
|
+
import { DialFileNodeType as n } from "@epam/ai-dial-react-file-manager";
|
|
4
|
+
//#region src/files/resolve-dial-file-api-path.ts
|
|
5
|
+
var r = (e) => e.startsWith("files/"), i = (t, n) => {
|
|
6
|
+
let i = `files/${n}/`;
|
|
7
|
+
if (t.startsWith(i)) return e(t.slice(i.length));
|
|
8
|
+
if (r(t)) {
|
|
9
|
+
let r = t.slice(6), i = r.indexOf("/");
|
|
10
|
+
if (i >= 0) {
|
|
11
|
+
let t = r.slice(0, i), a = r.slice(i + 1);
|
|
12
|
+
if (t === n) return e(a);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}, a = (e, t) => {
|
|
17
|
+
let n = `/${t}`, r = `/${t}/`, i = `${t}/`;
|
|
18
|
+
if (e === n || e === `${t}` || e === r || e === i) return "";
|
|
19
|
+
let a;
|
|
20
|
+
if (e.startsWith(r)) a = e.slice(r.length);
|
|
21
|
+
else if (e.startsWith(i)) a = e.slice(i.length);
|
|
22
|
+
else {
|
|
23
|
+
let t = e.replace(/^\//, "");
|
|
24
|
+
a = t.startsWith(i) ? t.slice(i.length) : t;
|
|
25
|
+
}
|
|
26
|
+
let o = a.replace(/\/{2,}/g, "/");
|
|
27
|
+
return o && !o.endsWith("/") ? `${o}/` : o;
|
|
28
|
+
}, o = (e, t) => e.startsWith("/") || e === t || e.startsWith(`${t}/`), s = (e, t, r) => {
|
|
29
|
+
let s = e.nodeType === n.FOLDER, c = e.id ? i(e.id, t) : null, l = c != null && !o(c, r) ? c : a(e.path, r);
|
|
30
|
+
return s ? l.endsWith("/") ? l : `${l}/` : l.replace(/\/$/, "");
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { t as getParentFolderPath, s as resolveDialFileApiPath, a as virtualPathToApiPath };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/files/source-content.ts
|
|
2
|
+
var e = {
|
|
3
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
4
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
5
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
6
|
+
csv: "text/csv"
|
|
7
|
+
}, t = new Set(/* @__PURE__ */ "txt.md.markdown.json.jsonl.ndjson.xml.csv.tsv.yaml.yml.toml.ini.conf.cfg.css.scss.sass.less.js.jsx.ts.tsx.mjs.cjs.mts.cts.py.rb.go.rs.java.kt.swift.c.h.cpp.cs.sh.bash.zsh.fish.ps1.log.env.gitignore.dockerfile.makefile.sql".split(".")), n = new Set(["html", "htm"]), r = "pdf", i = "application/pdf", a = (e) => e.split(/[?#]/)[0], o = (e) => {
|
|
8
|
+
let t = e.lastIndexOf(".");
|
|
9
|
+
return t === -1 ? "" : e.slice(t + 1).toLowerCase();
|
|
10
|
+
}, s = (e) => {
|
|
11
|
+
let t;
|
|
12
|
+
try {
|
|
13
|
+
t = new URL(e).pathname;
|
|
14
|
+
} catch {
|
|
15
|
+
t = a(e);
|
|
16
|
+
}
|
|
17
|
+
let n = t.split("/").filter(Boolean).pop() ?? "";
|
|
18
|
+
try {
|
|
19
|
+
return decodeURIComponent(n);
|
|
20
|
+
} catch {
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
}, c = (t) => {
|
|
24
|
+
if (t.startsWith("image/") || t.startsWith("audio/")) return !0;
|
|
25
|
+
let n = t.split(";", 1)[0].trim().toLowerCase();
|
|
26
|
+
return t === i || Object.values(e).includes(n);
|
|
27
|
+
}, l = (t, n) => {
|
|
28
|
+
if (c(t)) return t;
|
|
29
|
+
let a = o(s(n));
|
|
30
|
+
return a === r ? i : Object.prototype.hasOwnProperty.call(e, a) ? e[a] : t;
|
|
31
|
+
}, u = (e, r) => {
|
|
32
|
+
if (c(l(e, r))) return !0;
|
|
33
|
+
let i = o(s(r));
|
|
34
|
+
return t.has(i) || n.has(i);
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { s as getUrlFileName, u as isExternalSourcePreviewable, l as resolveExternalSourceContentType };
|