@epam/ai-dial-chat-hooks 1.1.0-dev.423 → 1.1.0-dev.430
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,101 @@
|
|
|
1
|
+
import { buildDeploymentConnectApi as e } from "./deployment-endpoint-url.js";
|
|
2
|
+
import { mapDeploymentLimitsDtoToCatalogLimits as t } from "./map-deployment-limits-to-catalog.js";
|
|
3
|
+
import { mapDeploymentDetailsDtoToEntityDetails as n, mapEntityDetailsToCatalogDetails as r, mapToolsetCredentials as i } from "./map-entity-details-to-catalog.js";
|
|
4
|
+
import { parsePromptResourceUrl as a } from "../prompt/prompt-resource.js";
|
|
5
|
+
import { buildPromptOverview as o, isOrganisationPromptItem as s } from "./map-prompt-to-catalog-item.js";
|
|
6
|
+
import { SKILL_MANIFEST_FILE as c } from "../skill/skill.js";
|
|
7
|
+
import { parseSkillResourceUrl as l } from "../skill/skill-types.js";
|
|
8
|
+
import { buildSkillContentTree as u, buildSkillOverview as d, readSkillFileBytes as f, readSkillManifest as p, resolveSkillFileDownloadPath as m, resolveSkillManifestFileId as h } from "./map-skill-to-catalog-item.js";
|
|
9
|
+
import { buildConnectApi as g, resolveMcpResourceKind as _ } from "./mcp-endpoint-url.js";
|
|
10
|
+
import { parseSkillManifestDocument as v } from "../skill/skill-manifest.js";
|
|
11
|
+
import { CatalogEntityType as y } from "@epam/ai-dial-chat-shared";
|
|
12
|
+
import { useCallback as b, useRef as x } from "react";
|
|
13
|
+
//#region src/catalog/useCatalogItemDetails.ts
|
|
14
|
+
var S = (e) => (t) => {
|
|
15
|
+
if (!s(t)) return e.getPrompt(t.id);
|
|
16
|
+
let n = a(t.id);
|
|
17
|
+
return e.getPublicPrompt(n?.path ?? t.id);
|
|
18
|
+
}, C = ({ api: a, skills: s, isAdmin: C, dialCoreExternalUrl: w, skillOverviewLabels: T, promptOverviewLabels: E, deploymentLimitsLabels: D }) => {
|
|
19
|
+
let O = x(null);
|
|
20
|
+
return {
|
|
21
|
+
onFetchDetails: b(async (f) => {
|
|
22
|
+
if (f.type === y.Prompt) try {
|
|
23
|
+
let e = await S(a)(f);
|
|
24
|
+
return {
|
|
25
|
+
promptContent: { content: e.content },
|
|
26
|
+
overview: o(e, E)
|
|
27
|
+
};
|
|
28
|
+
} catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (f.type === y.Skill) {
|
|
32
|
+
let e = l(f.id);
|
|
33
|
+
if (e == null) return;
|
|
34
|
+
let { bucket: t, path: n } = e;
|
|
35
|
+
O.current = e;
|
|
36
|
+
let [r, i] = await Promise.allSettled([a.downloadSkillFile(t, n, c).then(p), a.listSkillFiles({
|
|
37
|
+
bucket: t,
|
|
38
|
+
path: n,
|
|
39
|
+
filePath: "",
|
|
40
|
+
recursive: !0
|
|
41
|
+
})]), o = r.status === "fulfilled" && r.value != null ? v(r.value) : void 0, m = s.find((e) => e.url === f.id), g = i.status === "fulfilled" ? d(m, i.value.items, o?.about, T) : void 0, _ = i.status === "fulfilled" ? u(i.value.items, n) : [], y = i.status === "fulfilled" ? h(i.value.items, n) : c;
|
|
42
|
+
return o == null && g == null ? void 0 : {
|
|
43
|
+
...o == null ? {} : { promptContent: {
|
|
44
|
+
content: o.body,
|
|
45
|
+
...o.description == null ? {} : { description: o.description },
|
|
46
|
+
files: _,
|
|
47
|
+
selectedFileId: y
|
|
48
|
+
} },
|
|
49
|
+
...g == null ? {} : { overview: g }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
let o = f.type === y.Model ? a.getDeploymentLimits(f.id).catch(() => void 0) : Promise.resolve(void 0), [s, c] = await Promise.all([a.getDeploymentDetails(f.id), o]), l = n(s), u = r(l), d = _(f.type, f.supportsMcp), p = l.type === "MODEL" || l.type === "AGENT" ? e(w ?? "", f.id, {
|
|
54
|
+
hasChatCompletion: l.data.capabilities?.hasChatCompletion,
|
|
55
|
+
hasResponsesApi: l.data.capabilities?.hasResponsesApi
|
|
56
|
+
}) : void 0;
|
|
57
|
+
return {
|
|
58
|
+
...u,
|
|
59
|
+
api: d == null ? p ?? u.api : g(w ?? "", f.id, d),
|
|
60
|
+
limits: t(c, D),
|
|
61
|
+
credentials: l.type === "TOOLSET" ? i(f.id, l.data, C) : void 0
|
|
62
|
+
};
|
|
63
|
+
} catch {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
a,
|
|
68
|
+
C,
|
|
69
|
+
D,
|
|
70
|
+
w,
|
|
71
|
+
s,
|
|
72
|
+
E,
|
|
73
|
+
T
|
|
74
|
+
]),
|
|
75
|
+
onLoadContentFile: b(async (e) => {
|
|
76
|
+
let t = O.current;
|
|
77
|
+
if (t == null) return;
|
|
78
|
+
let n = m(e, t.path);
|
|
79
|
+
if (n == null) return;
|
|
80
|
+
let r = await p(await a.downloadSkillFile(t.bucket, t.path, n));
|
|
81
|
+
if (r != null) return n === "SKILL.md" ? v(r).body : r;
|
|
82
|
+
}, [a]),
|
|
83
|
+
onLoadSkillDetailsFile: b(async (e) => {
|
|
84
|
+
let t = O.current;
|
|
85
|
+
if (t == null) throw Error("No skill details are open");
|
|
86
|
+
let n = m(e, t.path);
|
|
87
|
+
if (n == null) throw Error("A folder cannot be previewed");
|
|
88
|
+
let r = await a.downloadSkillFile(t.bucket, t.path, n);
|
|
89
|
+
if (!r.ok) throw Object.assign(/* @__PURE__ */ Error(`File preview failed with status ${r.status}`), { status: r.status });
|
|
90
|
+
let i = await f(r);
|
|
91
|
+
if (i == null) throw Error("File exceeds the preview size limit");
|
|
92
|
+
let o = r.headers.get("content-type")?.split(";")[0].trim() || void 0;
|
|
93
|
+
return {
|
|
94
|
+
bytes: i,
|
|
95
|
+
mimeType: o === "application/octet-stream" ? void 0 : o
|
|
96
|
+
};
|
|
97
|
+
}, [a])
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { C as useCatalogItemDetails };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { getApiErrorDetails as e } from "../../api-error/api-error.js";
|
|
2
|
+
import { ToolsetAuthTypes as t, ToolsetCredentialsLevel as n } from "../../oauth/types.js";
|
|
3
|
+
import { ToolsetLoginOutcomeType as r, useToolsetLogin as i } from "../../oauth/useToolsetLogin/useToolsetLogin.js";
|
|
4
|
+
import { useCallback as a } from "react";
|
|
5
|
+
import { CredentialStatus as o, CredentialsLevel as s, ToolsetAuthenticationType as c } from "@epam/ai-dial-catalog";
|
|
6
|
+
import { NotificationVariant as l } from "@epam/ai-dial-ui-kit";
|
|
7
|
+
//#region src/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.ts
|
|
8
|
+
var u = (e, t, n) => e === s.User ? n.user : t ? n.org : n.global, d = (e) => {
|
|
9
|
+
switch (e) {
|
|
10
|
+
case c.ApiKey: return t.ApiKey;
|
|
11
|
+
case c.OAuth: return t.OAuth;
|
|
12
|
+
case c.None:
|
|
13
|
+
case void 0: return t.None;
|
|
14
|
+
}
|
|
15
|
+
}, f = ({ isAdmin: t, toolsets: f, refetchToolsets: p, callbackPath: m, loginToolset: h, logoutToolset: g, getToolset: _, labels: v, onNotify: y }) => {
|
|
16
|
+
let b = a((e, t) => t === s.User ? e.credentials?.userStatus : e.credentials?.globalStatus, []), x = a((e, n) => {
|
|
17
|
+
let r = t && !!e.credentials?.isPublic;
|
|
18
|
+
if (e.credentials?.authenticationType === c.ApiKey) {
|
|
19
|
+
let t = u(n, r, v.apiKeyAddedSuccess);
|
|
20
|
+
y({
|
|
21
|
+
variant: l.Success,
|
|
22
|
+
title: v.apiKeyAddedSuccessTitle,
|
|
23
|
+
message: t({
|
|
24
|
+
name: e.name,
|
|
25
|
+
version: e.version
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let i = u(n, r, v.loginSuccess);
|
|
31
|
+
y({
|
|
32
|
+
variant: l.Success,
|
|
33
|
+
title: v.loginSuccessTitle,
|
|
34
|
+
message: i({
|
|
35
|
+
name: e.name,
|
|
36
|
+
version: e.version
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}, [
|
|
40
|
+
t,
|
|
41
|
+
v,
|
|
42
|
+
y
|
|
43
|
+
]), S = a((e, n) => {
|
|
44
|
+
let r = t && !!e.credentials?.isPublic;
|
|
45
|
+
if (e.credentials?.authenticationType === c.ApiKey) {
|
|
46
|
+
let t = u(n, r, v.apiKeyDeletedSuccess);
|
|
47
|
+
y({
|
|
48
|
+
variant: l.Success,
|
|
49
|
+
title: v.apiKeyDeletedSuccessTitle,
|
|
50
|
+
message: t({
|
|
51
|
+
name: e.name,
|
|
52
|
+
version: e.version
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let i = u(n, r, v.logoutSuccess);
|
|
58
|
+
y({
|
|
59
|
+
variant: l.Success,
|
|
60
|
+
title: v.logoutSuccessTitle,
|
|
61
|
+
message: i({
|
|
62
|
+
name: e.name,
|
|
63
|
+
version: e.version
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}, [
|
|
67
|
+
t,
|
|
68
|
+
v,
|
|
69
|
+
y
|
|
70
|
+
]), { login: C } = i({
|
|
71
|
+
callbackPath: m,
|
|
72
|
+
loginToolset: h,
|
|
73
|
+
logoutToolset: g,
|
|
74
|
+
getToolset: _
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
handleLogin: a(async (e, t) => {
|
|
78
|
+
let i = e.credentials?.authenticationType, a = t.level === s.User ? n.User : n.Global, c = f.find((t) => t.id === e.id);
|
|
79
|
+
switch ((await C({
|
|
80
|
+
toolsetId: e.id,
|
|
81
|
+
credentialsLevel: a,
|
|
82
|
+
authenticationType: d(i),
|
|
83
|
+
apiKey: t.apiKey,
|
|
84
|
+
oauthSettings: {
|
|
85
|
+
clientId: c?.authSettings?.clientId,
|
|
86
|
+
authorizationEndpoint: c?.authSettings?.authorizationEndpoint,
|
|
87
|
+
scopes: c?.authSettings?.scopesSupported,
|
|
88
|
+
codeChallenge: c?.authSettings?.codeChallenge,
|
|
89
|
+
codeChallengeMethod: c?.authSettings?.codeChallengeMethod
|
|
90
|
+
},
|
|
91
|
+
isCurrentlyFailed: b(e, t.level) === o.Failed
|
|
92
|
+
})).type) {
|
|
93
|
+
case r.Success:
|
|
94
|
+
x(e, t.level), await p();
|
|
95
|
+
return;
|
|
96
|
+
case r.PopupBlocked:
|
|
97
|
+
y({
|
|
98
|
+
variant: l.Error,
|
|
99
|
+
message: v.popupBlockedError
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
case r.Failure:
|
|
103
|
+
y({
|
|
104
|
+
variant: l.Error,
|
|
105
|
+
message: v.loginFailedError
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
case r.Cancelled: return;
|
|
109
|
+
}
|
|
110
|
+
}, [
|
|
111
|
+
f,
|
|
112
|
+
v,
|
|
113
|
+
y,
|
|
114
|
+
b,
|
|
115
|
+
x,
|
|
116
|
+
p,
|
|
117
|
+
C
|
|
118
|
+
]),
|
|
119
|
+
handleLogout: a(async (t, r) => {
|
|
120
|
+
let i = r.level === s.User ? n.User : n.Global;
|
|
121
|
+
try {
|
|
122
|
+
let e = {
|
|
123
|
+
url: t.id,
|
|
124
|
+
credentialsLevel: i,
|
|
125
|
+
authenticationType: t.credentials?.authenticationType
|
|
126
|
+
};
|
|
127
|
+
await g(t.id, e), S(t, r.level), await p();
|
|
128
|
+
} catch (t) {
|
|
129
|
+
let { traceId: n } = await e(t);
|
|
130
|
+
y({
|
|
131
|
+
variant: l.Error,
|
|
132
|
+
message: v.logoutFailedError,
|
|
133
|
+
requestId: n
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, [
|
|
137
|
+
g,
|
|
138
|
+
v,
|
|
139
|
+
y,
|
|
140
|
+
S,
|
|
141
|
+
p
|
|
142
|
+
])
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
//#endregion
|
|
146
|
+
export { f as useCatalogToolsetCredentials };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useState as r } from "react";
|
|
2
|
+
//#region src/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.ts
|
|
3
|
+
var i = /* @__PURE__ */ function(e) {
|
|
4
|
+
return e.Deployment = "deployment", e.Toolset = "toolset", e.Prompt = "prompt", e.Skill = "skill", e;
|
|
5
|
+
}({}), a = ({ loadFavorites: i, updateFavorite: a }) => {
|
|
6
|
+
let [o, s] = r(/* @__PURE__ */ new Set()), [c, l] = r(!0);
|
|
7
|
+
t(() => {
|
|
8
|
+
let e = { value: !1 };
|
|
9
|
+
return (async () => {
|
|
10
|
+
try {
|
|
11
|
+
let t = await i();
|
|
12
|
+
e.value || s(new Set([
|
|
13
|
+
...t.deployments,
|
|
14
|
+
...t.toolsets,
|
|
15
|
+
...t.prompts,
|
|
16
|
+
...t.skills
|
|
17
|
+
]));
|
|
18
|
+
} catch {} finally {
|
|
19
|
+
e.value || l(!1);
|
|
20
|
+
}
|
|
21
|
+
})(), () => {
|
|
22
|
+
e.value = !0;
|
|
23
|
+
};
|
|
24
|
+
}, [i]);
|
|
25
|
+
let u = e(async (e, t, n = "deployment") => {
|
|
26
|
+
s((n) => {
|
|
27
|
+
let r = new Set(n);
|
|
28
|
+
return t ? r.add(e) : r.delete(e), r;
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
await a(e, t, n);
|
|
32
|
+
} catch (n) {
|
|
33
|
+
throw s((n) => {
|
|
34
|
+
let r = new Set(n);
|
|
35
|
+
return t ? r.delete(e) : r.add(e), r;
|
|
36
|
+
}), n;
|
|
37
|
+
}
|
|
38
|
+
}, [a]);
|
|
39
|
+
return n(() => ({
|
|
40
|
+
favoriteIds: o,
|
|
41
|
+
isLoading: c,
|
|
42
|
+
toggleFavorite: u
|
|
43
|
+
}), [
|
|
44
|
+
o,
|
|
45
|
+
c,
|
|
46
|
+
u
|
|
47
|
+
]);
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { i as FavoriteEntityType, a as useFavoriteEntitiesState };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useState as r } from "react";
|
|
2
|
+
import { ListFilesItemDtoNodeTypeEnum as i } from "@epam/ai-dial-chat-api-client";
|
|
3
|
+
import { fromFolderPathKey as a, mergeFolderPaths as o, toFolderPathKey as s } from "@epam/ai-dial-publish-panel";
|
|
4
|
+
//#region src/catalog/usePublishFolders/usePublishFolders.ts
|
|
5
|
+
var c = "Production", l = 50, u = (e, t, n) => {
|
|
6
|
+
let r = e.get(t);
|
|
7
|
+
return r == null ? [] : r.filter((e) => e.nodeType === i.Folder).map((r) => {
|
|
8
|
+
let i = r.name, a = [...n, i], o = `${t}${r.name}/`;
|
|
9
|
+
return {
|
|
10
|
+
path: a,
|
|
11
|
+
name: i,
|
|
12
|
+
children: e.has(o) ? u(e, o, a) : void 0
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}, d = ({ listPublicFiles: i, rememberedFolderKeys: d, onRememberedFolderKeysChange: f }) => {
|
|
16
|
+
let [p, m] = r(() => /* @__PURE__ */ new Map()), [h, g] = r(() => /* @__PURE__ */ new Set()), [_, v] = r(() => /* @__PURE__ */ new Set()), [y, b] = r([]), x = n(() => {
|
|
17
|
+
let e = /* @__PURE__ */ new Set();
|
|
18
|
+
return h.forEach((t) => {
|
|
19
|
+
let n = t ? `${t}/` : "";
|
|
20
|
+
p.has(n) && e.add(t);
|
|
21
|
+
}), e;
|
|
22
|
+
}, [h, p]), S = e(async (e) => {
|
|
23
|
+
v((t) => new Set(t).add(e));
|
|
24
|
+
try {
|
|
25
|
+
let { items: t } = await i({ path: e || void 0 });
|
|
26
|
+
m((n) => new Map(n).set(e, t));
|
|
27
|
+
} finally {
|
|
28
|
+
v((t) => {
|
|
29
|
+
let n = new Set(t);
|
|
30
|
+
return n.delete(e), n;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, [i]);
|
|
34
|
+
t(() => {
|
|
35
|
+
S("");
|
|
36
|
+
}, []);
|
|
37
|
+
let C = e((e) => {
|
|
38
|
+
g(e), e.forEach((e) => {
|
|
39
|
+
let t = `${e}/`;
|
|
40
|
+
!p.has(t) && !_.has(t) && S(t);
|
|
41
|
+
});
|
|
42
|
+
}, [
|
|
43
|
+
p,
|
|
44
|
+
_,
|
|
45
|
+
S
|
|
46
|
+
]), w = e((e, t) => {
|
|
47
|
+
let n = s([...e, t]);
|
|
48
|
+
return b((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
|
|
49
|
+
}, []), T = e((e) => {
|
|
50
|
+
let t = s(e), n = Array.isArray(d) ? d : [];
|
|
51
|
+
!t || n.includes(t) || f?.([t, ...n].slice(0, l));
|
|
52
|
+
}, [d, f]), E = e((e) => !e.includes(c), []);
|
|
53
|
+
return {
|
|
54
|
+
folderItems: n(() => {
|
|
55
|
+
let e = Array.isArray(d) ? d.filter((e) => typeof e == "string") : [];
|
|
56
|
+
return o(u(p, "", []), [...e.map(a), ...y.map(a)]);
|
|
57
|
+
}, [
|
|
58
|
+
p,
|
|
59
|
+
d,
|
|
60
|
+
y
|
|
61
|
+
]),
|
|
62
|
+
expandedPaths: h,
|
|
63
|
+
loadedPaths: x,
|
|
64
|
+
loadingPaths: _,
|
|
65
|
+
onExpandedPathsChange: C,
|
|
66
|
+
onCreatePublishFolder: w,
|
|
67
|
+
rememberPublishFolder: T,
|
|
68
|
+
hasPublishWriteAccess: E
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { d as usePublishFolders };
|
package/catalog.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
|
|
1
|
+
import { createPublishApiClient as e, toPublishRuleDto as t } from "./catalog/create-publish-api.js";
|
|
2
|
+
import { buildChatCompletionsUrl as n, buildDeploymentConnectApi as r, buildResponsesUrl as i } from "./catalog/deployment-endpoint-url.js";
|
|
3
|
+
import { encodeDeploymentId as a, findDeploymentByIdOrReference as o } from "./catalog/deployment-id.js";
|
|
4
|
+
import { AuthenticationType as s } from "./catalog/entity-details.js";
|
|
5
|
+
import { mapDeploymentLimitsDtoToCatalogLimits as c } from "./catalog/map-deployment-limits-to-catalog.js";
|
|
6
|
+
import { mapDeploymentLimitsToInput as l } from "./catalog/map-deployment-limits-to-input.js";
|
|
7
|
+
import { mapDeploymentDetailsDtoToEntityDetails as u, mapEntityDetailsToCatalogDetails as d, mapToolsetCredentials as f } from "./catalog/map-entity-details-to-catalog.js";
|
|
8
|
+
import { mapDeploymentToCatalogItem as p, mapDeploymentToolsetCredentials as m, mapToolsetToCatalogItem as h, resolveDeploymentFolder as g } from "./catalog/map-deployment-to-catalog-item.js";
|
|
9
|
+
import { buildPromptOverview as _, isOrganisationPromptItem as v, mapPromptToCatalogItem as y } from "./catalog/map-prompt-to-catalog-item.js";
|
|
10
|
+
import { PUBLIC_SKILL_BUCKET as b, SKILL_LISTING_MAX_PAGES as x, SKILL_LISTING_PAGE_SIZE as S, SKILL_MANIFEST_MAX_BYTES as C, SkillSource as w, parseSkillResourceUrl as T } from "./skill/skill-types.js";
|
|
11
|
+
import { buildSkillContentTree as E, buildSkillOverview as D, mapSkillToCatalogItem as O, readSkillFileBytes as k, readSkillManifest as A, resolveSkillFileDownloadPath as j, resolveSkillManifestFileId as M } from "./catalog/map-skill-to-catalog-item.js";
|
|
12
|
+
import { McpResourceKind as N, buildApplicationMcpUrl as P, buildConnectApi as F, buildToolsetMcpUrl as I, resolveMcpResourceKind as L } from "./catalog/mcp-endpoint-url.js";
|
|
13
|
+
import { mapPublishConversationResultDto as R, mapPublishHistoryEntryDto as z, toPublishEntityType as B } from "./catalog/publish.js";
|
|
14
|
+
import { deriveAvailableTabIds as V, deriveFavoriteItems as H, filterCatalogItemsBySelector as U, filterHiddenOwnedItems as W, reconcileFilterTopics as G } from "./catalog/catalog-derivations.js";
|
|
15
|
+
import { CatalogPrimaryActionType as K, resolveCatalogPrimaryAction as q } from "./catalog/catalog-primary-action.js";
|
|
16
|
+
import { useCatalogEditNavigation as J } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
|
|
17
|
+
import { useCatalogItemDetails as Y } from "./catalog/useCatalogItemDetails.js";
|
|
18
|
+
import { useCatalogToolsetCredentials as X } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
|
|
19
|
+
import { FavoriteEntityType as Z, useFavoriteEntitiesState as Q } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
|
|
20
|
+
import { usePublishFolders as $ } from "./catalog/usePublishFolders/usePublishFolders.js";
|
|
21
|
+
import { SkillPreviewErrorKind as ee, useSkillFilePreview as te } from "./skill/useSkillFilePreview.js";
|
|
22
|
+
export { s as AuthenticationType, K as CatalogPrimaryActionType, Z as FavoriteEntityType, N as McpResourceKind, b as PUBLIC_SKILL_BUCKET, x as SKILL_LISTING_MAX_PAGES, S as SKILL_LISTING_PAGE_SIZE, C as SKILL_MANIFEST_MAX_BYTES, ee as SkillPreviewErrorKind, w as SkillSource, P as buildApplicationMcpUrl, n as buildChatCompletionsUrl, F as buildConnectApi, r as buildDeploymentConnectApi, _ as buildPromptOverview, i as buildResponsesUrl, E as buildSkillContentTree, D as buildSkillOverview, I as buildToolsetMcpUrl, e as createPublishApiClient, V as deriveAvailableTabIds, H as deriveFavoriteItems, a as encodeDeploymentId, U as filterCatalogItemsBySelector, W as filterHiddenOwnedItems, o as findDeploymentByIdOrReference, v as isOrganisationPromptItem, u as mapDeploymentDetailsDtoToEntityDetails, c as mapDeploymentLimitsDtoToCatalogLimits, l as mapDeploymentLimitsToInput, p as mapDeploymentToCatalogItem, m as mapDeploymentToolsetCredentials, d as mapEntityDetailsToCatalogDetails, y as mapPromptToCatalogItem, R as mapPublishConversationResultDto, z as mapPublishHistoryEntryDto, O as mapSkillToCatalogItem, f as mapToolsetCredentials, h as mapToolsetToCatalogItem, T as parseSkillResourceUrl, k as readSkillFileBytes, A as readSkillManifest, G as reconcileFilterTopics, q as resolveCatalogPrimaryAction, g as resolveDeploymentFolder, L as resolveMcpResourceKind, j as resolveSkillFileDownloadPath, M as resolveSkillManifestFileId, B as toPublishEntityType, t as toPublishRuleDto, J as useCatalogEditNavigation, Y as useCatalogItemDetails, X as useCatalogToolsetCredentials, Q as useFavoriteEntitiesState, $ as usePublishFolders, te as useSkillFilePreview };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import e from "dompurify";
|
|
2
|
+
//#region src/conversation/announcement-message.ts
|
|
3
|
+
var t = {
|
|
4
|
+
ALLOWED_TAGS: [
|
|
5
|
+
"a",
|
|
6
|
+
"b",
|
|
7
|
+
"strong",
|
|
8
|
+
"em",
|
|
9
|
+
"br",
|
|
10
|
+
"span"
|
|
11
|
+
],
|
|
12
|
+
ALLOWED_ATTR: [
|
|
13
|
+
"href",
|
|
14
|
+
"target",
|
|
15
|
+
"rel"
|
|
16
|
+
]
|
|
17
|
+
}, n = {
|
|
18
|
+
ALLOWED_TAGS: [
|
|
19
|
+
"a",
|
|
20
|
+
"b",
|
|
21
|
+
"strong",
|
|
22
|
+
"em",
|
|
23
|
+
"u",
|
|
24
|
+
"br",
|
|
25
|
+
"span",
|
|
26
|
+
"p"
|
|
27
|
+
],
|
|
28
|
+
ALLOWED_ATTR: [
|
|
29
|
+
"href",
|
|
30
|
+
"target",
|
|
31
|
+
"rel"
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
e.addHook("afterSanitizeAttributes", (e) => {
|
|
35
|
+
e.tagName === "A" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
|
|
36
|
+
});
|
|
37
|
+
var r = (n) => e.sanitize(n, t), i = (t) => e.sanitize(t, n), a = (e) => typeof e == "string" && e.length > 0, o = ({ title: e, description: t }) => a(e) || a(t), s = (e) => o(e) || a(e.html), c = (e) => o(e) ? JSON.stringify({
|
|
38
|
+
title: e.title ?? "",
|
|
39
|
+
description: e.description ?? ""
|
|
40
|
+
}) : e.html ?? "";
|
|
41
|
+
//#endregion
|
|
42
|
+
export { c as buildAnnouncementSignature, s as hasAnnouncementContent, o as hasStructuredAnnouncement, r as sanitizeAnnouncementHtml, i as sanitizeAnnouncementMessageHtml };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/conversation/conversation-transfer/async.ts
|
|
2
|
+
var e = async (e, t, n) => {
|
|
3
|
+
let r = [], i = 0, a = async () => {
|
|
4
|
+
let t = i;
|
|
5
|
+
if (i += 1, !(t >= e.length)) {
|
|
6
|
+
try {
|
|
7
|
+
let i = await n(e[t]);
|
|
8
|
+
i !== void 0 && r.push(i);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error("runWithConcurrency: worker failed for item", e);
|
|
11
|
+
}
|
|
12
|
+
await a();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { e as runWithConcurrency };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/conversation/conversation-transfer/attachment-refs.ts
|
|
2
|
+
var e = (e) => e.startsWith("files/"), t = (t) => {
|
|
3
|
+
let n = /* @__PURE__ */ new Set();
|
|
4
|
+
for (let r of t.messages) for (let t of r.custom_content?.attachments ?? []) {
|
|
5
|
+
let r = t.url ?? t.reference_url;
|
|
6
|
+
r != null && e(r) && n.add(r);
|
|
7
|
+
}
|
|
8
|
+
return Array.from(n, (e) => ({ fileId: e }));
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as collectAttachmentRefs };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { formatDateYM as e } from "./date.js";
|
|
2
|
+
//#region src/conversation/conversation-transfer/build-upload-path.ts
|
|
3
|
+
var t = (e) => {
|
|
4
|
+
let t = e.lastIndexOf("."), n = t > 0;
|
|
5
|
+
return {
|
|
6
|
+
base: n ? e.slice(0, t) : e,
|
|
7
|
+
extension: n ? e.slice(t) : ""
|
|
8
|
+
};
|
|
9
|
+
}, n = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", r = (e, t, n) => n === 0 ? `${e}${t}` : `${e} (${n})${t}`, i = (i) => {
|
|
10
|
+
let a = i?.date ?? /* @__PURE__ */ new Date(), o = new Set(i?.existingNames);
|
|
11
|
+
return {
|
|
12
|
+
allocate: (i) => {
|
|
13
|
+
let { base: s, extension: c } = t(n(i)), l = 0, u = r(s, c, l);
|
|
14
|
+
for (; o.has(u);) l += 1, u = r(s, c, l);
|
|
15
|
+
return o.add(u), {
|
|
16
|
+
path: `uploads/${e(a)}/${encodeURIComponent(u)}`,
|
|
17
|
+
fileName: u,
|
|
18
|
+
isRenamed: l > 0
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
markTaken: (e) => {
|
|
22
|
+
o.add(e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i as createUploadPathAllocator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/conversation/conversation-transfer/date.ts
|
|
2
2
|
var e = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, t = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`;
|
|
3
3
|
//#endregion
|
|
4
|
-
export {
|
|
4
|
+
export { t as formatDateYM, e as formatDateYMD };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/conversation/conversation-transfer/dial-file-resolve.ts
|
|
2
|
+
var e = (e) => e.startsWith("files/"), t = (t) => {
|
|
3
|
+
if (!e(t)) return;
|
|
4
|
+
let n = t.slice(6), r = n.indexOf("/");
|
|
5
|
+
if (r < 0) return;
|
|
6
|
+
let i = n.slice(0, r), a = n.slice(r + 1), o;
|
|
7
|
+
try {
|
|
8
|
+
o = decodeURIComponent(a);
|
|
9
|
+
} catch {
|
|
10
|
+
o = a;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
bucket: i,
|
|
14
|
+
path: o
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { t as resolveDialFileBucketAndPath };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { formatDateYMD as e } from "./date.js";
|
|
2
|
+
import { ExportFileNameKind as t } from "./types.js";
|
|
3
|
+
//#region src/conversation/conversation-transfer/export-conversation.ts
|
|
4
|
+
var n = "ai_dial", r = (e) => e.map(({ attachments: e, ...t }) => t), i = (e) => {
|
|
5
|
+
let t = e.custom_content;
|
|
6
|
+
if (!t) return e;
|
|
7
|
+
let { attachments: n, stages: i, ...a } = t;
|
|
8
|
+
if (n == null && i == null) return e;
|
|
9
|
+
let o = {
|
|
10
|
+
...a,
|
|
11
|
+
...i ? { stages: r(i) } : {}
|
|
12
|
+
};
|
|
13
|
+
if (Object.keys(o).length > 0) return {
|
|
14
|
+
...e,
|
|
15
|
+
custom_content: o
|
|
16
|
+
};
|
|
17
|
+
let { custom_content: s, ...c } = e;
|
|
18
|
+
return c;
|
|
19
|
+
}, a = (e) => ({
|
|
20
|
+
...e,
|
|
21
|
+
messages: e.messages.map(i)
|
|
22
|
+
}), o = (e, t = []) => ({
|
|
23
|
+
version: 5,
|
|
24
|
+
history: e,
|
|
25
|
+
folders: t
|
|
26
|
+
}), s = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), c = {
|
|
27
|
+
[t.SingleConversation]: "json",
|
|
28
|
+
[t.SingleConversationWithAttachments]: "dial",
|
|
29
|
+
[t.AllConversationsHistory]: "json"
|
|
30
|
+
}, l = (t, n, r = /* @__PURE__ */ new Date()) => `${e(r)}_${n}_${t}.${c[t]}`;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { n as EXPORT_APP_NAME, o as buildExportEnvelope, l as buildExportFileName, s as serializeExportEnvelope, a as stripConversationAttachments };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { collectAttachmentRefs as e } from "./attachment-refs.js";
|
|
2
|
+
import { resolveDialFileBucketAndPath as t } from "./dial-file-resolve.js";
|
|
3
|
+
import { generateUUID as n } from "@epam/ai-dial-chat-shared";
|
|
4
|
+
//#region src/conversation/conversation-transfer/import-conversation.ts
|
|
5
|
+
var r = class extends Error {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
super(e), this.name = "UnsupportedImportFormatError";
|
|
8
|
+
}
|
|
9
|
+
}, i = (e) => typeof e == "object" && !!e, a = 5, o = (e) => {
|
|
10
|
+
let t;
|
|
11
|
+
try {
|
|
12
|
+
t = JSON.parse(e);
|
|
13
|
+
} catch {
|
|
14
|
+
throw new r("Import file is not valid JSON");
|
|
15
|
+
}
|
|
16
|
+
if (!i(t) || t.version !== a || !Array.isArray(t.history)) throw new r("Import file is not a supported export format");
|
|
17
|
+
let n = Array.isArray(t.folders) ? t.folders : [];
|
|
18
|
+
return {
|
|
19
|
+
version: a,
|
|
20
|
+
history: t.history,
|
|
21
|
+
folders: n
|
|
22
|
+
};
|
|
23
|
+
}, s = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, c = (e) => {
|
|
24
|
+
let t = e.lastIndexOf("__");
|
|
25
|
+
if (t < 0) return e;
|
|
26
|
+
let n = e.slice(t + 2);
|
|
27
|
+
return s.test(n) ? e.slice(0, t) : e;
|
|
28
|
+
}, l = "conversations/", u = (e) => e.startsWith(l) ? e.slice(14) : e, d = (e, t) => {
|
|
29
|
+
let r = u(e.id), i = r.split("/"), a = u(e.folderId), o = i[0], s = a.startsWith(`${o}/`) ? a.slice(o.length + 1).split("/").filter(Boolean) : [], l = i.slice(1).slice(s.length), d = l.slice(0, -1), f = `${c(l.at(-1) ?? i.at(-1) ?? r)}__${n()}`, p = [
|
|
30
|
+
...s,
|
|
31
|
+
...d,
|
|
32
|
+
f
|
|
33
|
+
].join("/"), m = s.length ? `${t}/${s.join("/")}` : t;
|
|
34
|
+
return {
|
|
35
|
+
conversation: {
|
|
36
|
+
...e,
|
|
37
|
+
id: `${t}/${p}`,
|
|
38
|
+
folderId: m
|
|
39
|
+
},
|
|
40
|
+
subPath: p
|
|
41
|
+
};
|
|
42
|
+
}, f = (e) => {
|
|
43
|
+
let t = u(e.folderId).split("/").filter(Boolean).slice(1);
|
|
44
|
+
return t.length ? t.join(" / ") : void 0;
|
|
45
|
+
}, p = (e) => e.map((e) => `"${e}"`).join(", "), m = (e, t) => ({
|
|
46
|
+
...e,
|
|
47
|
+
messages: e.messages.map((e) => {
|
|
48
|
+
let n = e.custom_content?.attachments;
|
|
49
|
+
return n?.length ? {
|
|
50
|
+
...e,
|
|
51
|
+
custom_content: {
|
|
52
|
+
...e.custom_content,
|
|
53
|
+
attachments: n.map((e) => {
|
|
54
|
+
let n = e.url ? t.get(e.url) : void 0, r = e.reference_url ? t.get(e.reference_url) : void 0;
|
|
55
|
+
if (n == null && r == null) return e;
|
|
56
|
+
let i = n?.title ?? r?.title;
|
|
57
|
+
return {
|
|
58
|
+
...e,
|
|
59
|
+
...n == null ? {} : { url: n.url },
|
|
60
|
+
...r == null ? {} : { reference_url: r.url },
|
|
61
|
+
...i == null ? {} : { title: i }
|
|
62
|
+
};
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
} : e;
|
|
66
|
+
})
|
|
67
|
+
}), h = (e) => e.split("/").pop() || e, g = (n, r, i) => {
|
|
68
|
+
let a = [], o = [];
|
|
69
|
+
for (let s of e(n)) {
|
|
70
|
+
let e = t(s.fileId);
|
|
71
|
+
if (!e) {
|
|
72
|
+
o.push(h(s.fileId));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let n = e.path.split("/").pop() ?? e.path, c = r.get(e.path);
|
|
76
|
+
if (!c) {
|
|
77
|
+
o.push(n);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
a.push({
|
|
81
|
+
fileId: s.fileId,
|
|
82
|
+
bytes: c,
|
|
83
|
+
originalFileName: n,
|
|
84
|
+
allocated: i.allocate(n)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
plan: a,
|
|
89
|
+
skippedNames: o
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { r as UnsupportedImportFormatError, p as formatQuotedNameList, f as getFolderBreadcrumb, o as parseImportEnvelope, g as planAttachmentUploads, d as rebaseConversationId, m as rewriteAttachmentUrls };
|