@epam/ai-dial-chat-hooks 1.2.0-dev.158 → 1.2.0-dev.162
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/catalog/map-deployment-to-catalog-item.js +34 -34
- package/catalog/publish.js +4 -4
- package/catalog.d.ts +5 -1
- package/conversation/conversation-transfer/export-conversation.js +24 -16
- package/conversation/conversation-transfer/import-conversation.js +80 -31
- package/conversation/useConversationExport/useConversationExport.js +9 -9
- package/conversation/useConversationImport/useConversationImport.js +123 -121
- package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
- package/conversation-transfer.d.ts +2 -1
- package/conversation.d.ts +43 -0
- package/conversation.js +16 -15
- package/index.d.ts +50 -2
- package/index.js +63 -62
- package/oauth/toolset-id.js +3 -2
- package/package.json +18 -18
- package/skill/skill-types.js +8 -7
- package/usePageFileDrag/usePageFileDrag.js +3 -3
|
@@ -2,52 +2,52 @@ import { safeDecodeURIComponent as e } from "../shared/string-utils.js";
|
|
|
2
2
|
import { isPublicToolsetId as t } from "../oauth/toolset-id.js";
|
|
3
3
|
import { resolveLocalizedText as n } from "../shared/locale.js";
|
|
4
4
|
import { mapEntityDetailsToCatalogDetails as r } from "./map-entity-details-to-catalog.js";
|
|
5
|
-
import { CatalogEntityType as i,
|
|
6
|
-
import { CredentialStatus as
|
|
5
|
+
import { CatalogEntityType as i, PUBLIC_BUCKET as a, formatLastUsed as o } from "@epam/ai-dial-chat-shared";
|
|
6
|
+
import { CredentialStatus as s, ToolsetAuthenticationType as c } from "@epam/ai-dial-catalog";
|
|
7
7
|
//#region src/catalog/map-deployment-to-catalog-item.ts
|
|
8
|
-
var
|
|
9
|
-
NONE:
|
|
10
|
-
API_KEY:
|
|
11
|
-
OAUTH:
|
|
12
|
-
},
|
|
13
|
-
SIGNED_IN:
|
|
14
|
-
SIGNED_OUT:
|
|
15
|
-
FAILED:
|
|
16
|
-
},
|
|
8
|
+
var l = {
|
|
9
|
+
NONE: c.None,
|
|
10
|
+
API_KEY: c.ApiKey,
|
|
11
|
+
OAUTH: c.OAuth
|
|
12
|
+
}, u = {
|
|
13
|
+
SIGNED_IN: s.SignedIn,
|
|
14
|
+
SIGNED_OUT: s.SignedOut,
|
|
15
|
+
FAILED: s.Failed
|
|
16
|
+
}, d = (e, n, r) => {
|
|
17
17
|
if (n == null) return;
|
|
18
|
-
let i = t(e), a = n.userLevelAuthStatus ?
|
|
18
|
+
let i = t(e), a = n.userLevelAuthStatus ? u[n.userLevelAuthStatus] : void 0, o = n.globalAuthStatus ? u[n.globalAuthStatus] : void 0;
|
|
19
19
|
return {
|
|
20
|
-
authenticationType: !r && i && a !==
|
|
20
|
+
authenticationType: !r && i && a !== s.SignedIn && o === s.SignedIn ? c.None : l[n.authenticationType],
|
|
21
21
|
userStatus: a,
|
|
22
|
-
globalStatus:
|
|
22
|
+
globalStatus: o,
|
|
23
23
|
isPublic: i,
|
|
24
24
|
isManageableByAdmin: r && i,
|
|
25
25
|
apiKeyHeader: n.apiKeyHeader
|
|
26
26
|
};
|
|
27
|
-
},
|
|
27
|
+
}, f = {
|
|
28
28
|
model: i.Model,
|
|
29
29
|
toolset: i.Toolset,
|
|
30
30
|
application: i.Agent
|
|
31
|
-
},
|
|
31
|
+
}, p = "applications/", m = "toolsets/", h = (t, n) => (t.startsWith(n) ? t.slice(n.length) : t).split("/").filter(Boolean).map(e), g = (e, t) => {
|
|
32
32
|
if (e.isMy) return [t.personal];
|
|
33
|
-
let n = h(e.applicationFolder ?? "",
|
|
34
|
-
return e.sharedWithMe ? [t.shared, ...n.slice(1)] : n.length === 0 && e.type?.toLowerCase() === "application" ? [t.public] : n[0]?.toLowerCase() ===
|
|
33
|
+
let n = h(e.applicationFolder ?? "", p);
|
|
34
|
+
return e.sharedWithMe ? [t.shared, ...n.slice(1)] : n.length === 0 && e.type?.toLowerCase() === "application" ? [t.public] : n[0]?.toLowerCase() === a ? [t.public, ...n.slice(1)] : n;
|
|
35
35
|
}, _ = (e, t) => {
|
|
36
36
|
if (e.isMy && t != null) return [t.personal];
|
|
37
37
|
let n = e.toolset || e.id;
|
|
38
|
-
if (!n.startsWith(
|
|
39
|
-
let r = h(n,
|
|
40
|
-
return e.sharedWithMe && t != null ? [t.shared, ...r.slice(1)] : r[0]?.toLowerCase() ===
|
|
41
|
-
}, v = (e, { favoriteIds: t = /* @__PURE__ */ new Set(), entityDetails:
|
|
42
|
-
let m = n(e.displayName, u,
|
|
38
|
+
if (!n.startsWith(m)) return t == null ? [] : e.sharedWithMe ? [t.shared] : n.length > 0 && !n.includes("/") ? [t.public] : [];
|
|
39
|
+
let r = h(n, m).slice(0, -1);
|
|
40
|
+
return e.sharedWithMe && t != null ? [t.shared, ...r.slice(1)] : r[0]?.toLowerCase() === a && t != null ? [t.public, ...r.slice(1)] : r.slice(1);
|
|
41
|
+
}, v = (e, { favoriteIds: t = /* @__PURE__ */ new Set(), entityDetails: a, folderLabels: s, editableSchemaIds: c = [], isCustomAppsEditable: l = !1, activeLocale: u, primaryLocale: d, resolveIconUrl: p }) => {
|
|
42
|
+
let m = n(e.displayName, u, d) || e.id, h = (e.type ?? "").toLowerCase();
|
|
43
43
|
return {
|
|
44
44
|
id: e.id,
|
|
45
|
-
type:
|
|
45
|
+
type: f[h] ?? i.Model,
|
|
46
46
|
name: m,
|
|
47
|
-
description: n(e.description, u,
|
|
47
|
+
description: n(e.description, u, d),
|
|
48
48
|
iconUrl: p(e.iconUrl),
|
|
49
49
|
version: e.displayVersion ?? "",
|
|
50
|
-
lastUsed:
|
|
50
|
+
lastUsed: o(e.updatedAt),
|
|
51
51
|
updatedAt: e.updatedAt,
|
|
52
52
|
createdAt: e.createdAt,
|
|
53
53
|
isFeatured: e.isFeatured ?? !1,
|
|
@@ -59,20 +59,20 @@ var c = {
|
|
|
59
59
|
sharedWithMe: e.sharedWithMe ?? !1,
|
|
60
60
|
isEditable: (!!e.isMy || !!e.canEdit) && (c.length > 0 && c.includes(e.applicationTypeSchemaId ?? "") || l && !e.applicationTypeSchemaId && h === "application"),
|
|
61
61
|
folder: g(e, s),
|
|
62
|
-
details:
|
|
62
|
+
details: a == null ? void 0 : r(a),
|
|
63
63
|
supportsMcp: e.features?.mcp === !0,
|
|
64
64
|
supportsChat: e.interfaces == null || e.interfaces.includes("chat")
|
|
65
65
|
};
|
|
66
|
-
}, y = (e, { favoriteIds: t = /* @__PURE__ */ new Set(), isAdmin: r = !1, folderLabels:
|
|
67
|
-
let
|
|
66
|
+
}, y = (e, { favoriteIds: t = /* @__PURE__ */ new Set(), isAdmin: r = !1, folderLabels: a, activeLocale: s, primaryLocale: c, resolveIconUrl: l }) => {
|
|
67
|
+
let u = n(e.displayName, s, c) || e.toolset || e.reference || e.id, f = e.allowedTools ?? [];
|
|
68
68
|
return {
|
|
69
69
|
id: e.id,
|
|
70
70
|
type: i.Toolset,
|
|
71
|
-
name:
|
|
71
|
+
name: u,
|
|
72
72
|
description: n(e.description, s, c),
|
|
73
73
|
iconUrl: l(e.iconUrl),
|
|
74
74
|
version: e.displayVersion ?? "",
|
|
75
|
-
lastUsed:
|
|
75
|
+
lastUsed: o(e.updatedAt),
|
|
76
76
|
updatedAt: e.updatedAt,
|
|
77
77
|
createdAt: e.createdAt,
|
|
78
78
|
isFeatured: !1,
|
|
@@ -83,10 +83,10 @@ var c = {
|
|
|
83
83
|
isMyApp: e.isMy ?? !1,
|
|
84
84
|
sharedWithMe: e.sharedWithMe ?? !1,
|
|
85
85
|
isEditable: !!(e.isMy || e.canEdit),
|
|
86
|
-
folder: _(e,
|
|
87
|
-
credentials:
|
|
86
|
+
folder: _(e, a),
|
|
87
|
+
credentials: d(e.id, e.authSettings, r),
|
|
88
88
|
details: f.length > 0 ? { tools: { tools: f.map((e) => ({ name: e })) } } : void 0
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
//#endregion
|
|
92
|
-
export { v as mapDeploymentToCatalogItem,
|
|
92
|
+
export { v as mapDeploymentToCatalogItem, d as mapDeploymentToolsetCredentials, y as mapToolsetToCatalogItem, g as resolveDeploymentFolder };
|
package/catalog/publish.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { safeDecodeURIComponent as e } from "../shared/string-utils.js";
|
|
2
|
-
import { CatalogEntityType as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { CatalogEntityType as t, PUBLIC_BUCKET as n } from "@epam/ai-dial-chat-shared";
|
|
3
3
|
//#region src/catalog/publish.ts
|
|
4
|
-
var
|
|
4
|
+
var r = {
|
|
5
5
|
[t.Model]: "model",
|
|
6
6
|
[t.Toolset]: "toolset",
|
|
7
7
|
[t.Agent]: "application",
|
|
8
8
|
[t.Prompt]: "prompt",
|
|
9
9
|
[t.Skill]: "skill"
|
|
10
|
-
},
|
|
10
|
+
}, i = (e) => r[e], a = (e) => e.split("/")[1] === n, o = (t) => a(t) ? t.split("/").slice(2, -1).map(e) : [], s = (e) => ({
|
|
11
11
|
version: e.version,
|
|
12
12
|
publishedAt: Date.parse(e.publishedAt),
|
|
13
13
|
folderPath: e.folderPath.split("/").filter(Boolean),
|
|
@@ -17,4 +17,4 @@ var n = {
|
|
|
17
17
|
folderPath: e.folderPath.split("/").filter(Boolean)
|
|
18
18
|
});
|
|
19
19
|
//#endregion
|
|
20
|
-
export { o as getPublicCatalogEntityFolderPath, a as isPublicCatalogEntityId, c as mapPublishConversationResultDto, s as mapPublishHistoryEntryDto,
|
|
20
|
+
export { o as getPublicCatalogEntityFolderPath, a as isPublicCatalogEntityId, c as mapPublishConversationResultDto, s as mapPublishHistoryEntryDto, i as toPublishEntityType };
|
package/catalog.d.ts
CHANGED
|
@@ -646,7 +646,11 @@ declare enum PromptSource {
|
|
|
646
646
|
Public = "public"
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
-
/**
|
|
649
|
+
/**
|
|
650
|
+
* DIAL Core bucket holding organisation-wide skills.
|
|
651
|
+
*
|
|
652
|
+
* @deprecated Use `PUBLIC_BUCKET` from `@epam/ai-dial-chat-shared`.
|
|
653
|
+
*/
|
|
650
654
|
export declare const PUBLIC_SKILL_BUCKET = "public";
|
|
651
655
|
|
|
652
656
|
/** The DIAL publish API surface produced by {@link createPublishApiClient}. */
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import { formatDateYMD as e } from "./date.js";
|
|
2
2
|
import { ExportFileNameKind as t } from "./types.js";
|
|
3
3
|
//#region src/conversation/conversation-transfer/export-conversation.ts
|
|
4
|
-
var n = "ai_dial", r = (e) => e.map(({ attachments: e, ...t }) => t), i = (e) => {
|
|
4
|
+
var n = "ai_dial", r = (e) => e.map(({ attachments: e, ...t }) => t), i = (e) => e.map((e) => {
|
|
5
|
+
if (e.body?.source == null) return e;
|
|
6
|
+
let { source: t, ...n } = e.body;
|
|
7
|
+
return {
|
|
8
|
+
...e,
|
|
9
|
+
body: n
|
|
10
|
+
};
|
|
11
|
+
}), a = (e) => {
|
|
5
12
|
let t = e.custom_content;
|
|
6
13
|
if (!t) return e;
|
|
7
|
-
let { attachments: n, stages:
|
|
8
|
-
if (n == null &&
|
|
9
|
-
let
|
|
10
|
-
...
|
|
11
|
-
...
|
|
14
|
+
let { attachments: n, stages: a, annotations: o, ...s } = t;
|
|
15
|
+
if (n == null && a == null && o == null) return e;
|
|
16
|
+
let c = {
|
|
17
|
+
...s,
|
|
18
|
+
...a ? { stages: r(a) } : {},
|
|
19
|
+
...o ? { annotations: i(o) } : {}
|
|
12
20
|
};
|
|
13
|
-
if (Object.keys(
|
|
21
|
+
if (Object.keys(c).length > 0) return {
|
|
14
22
|
...e,
|
|
15
|
-
custom_content:
|
|
23
|
+
custom_content: c
|
|
16
24
|
};
|
|
17
|
-
let { custom_content:
|
|
18
|
-
return
|
|
19
|
-
},
|
|
25
|
+
let { custom_content: l, ...u } = e;
|
|
26
|
+
return u;
|
|
27
|
+
}, o = (e) => ({
|
|
20
28
|
...e,
|
|
21
|
-
messages: e.messages.map(
|
|
22
|
-
}),
|
|
29
|
+
messages: e.messages.map(a)
|
|
30
|
+
}), s = (e, t = []) => ({
|
|
23
31
|
version: 5,
|
|
24
32
|
history: e,
|
|
25
33
|
folders: t
|
|
26
|
-
}),
|
|
34
|
+
}), c = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), l = {
|
|
27
35
|
[t.SingleConversation]: "json",
|
|
28
36
|
[t.SingleConversationWithAttachments]: "dial",
|
|
29
37
|
[t.AllConversationsHistory]: "json"
|
|
30
|
-
},
|
|
38
|
+
}, u = (t, n, r = /* @__PURE__ */ new Date()) => `${e(r)}_${n}_${t}.${l[t]}`;
|
|
31
39
|
//#endregion
|
|
32
|
-
export { n as EXPORT_APP_NAME,
|
|
40
|
+
export { n as EXPORT_APP_NAME, s as buildExportEnvelope, u as buildExportFileName, c as serializeExportEnvelope, o as stripConversationAttachments };
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { collectAttachmentRefs as e, splitFileIdAnchor as t } from "./attachment-refs.js";
|
|
2
2
|
import { resolveDialFileBucketAndPath as n } from "./dial-file-resolve.js";
|
|
3
|
-
import {
|
|
3
|
+
import { PUBLIC_BUCKET as r, generateUUID as i, sanitizeConversationName as a, stripTrailingDots as o, truncateToUtf8Bytes as s } from "@epam/ai-dial-chat-shared";
|
|
4
4
|
//#region src/conversation/conversation-transfer/import-conversation.ts
|
|
5
|
-
var
|
|
5
|
+
var c = class extends Error {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
super(e), this.name = "UnsupportedImportFormatError";
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, l = (e) => typeof e == "object" && !!e, u = 5, d = (e) => {
|
|
10
10
|
let t;
|
|
11
11
|
try {
|
|
12
12
|
t = JSON.parse(e);
|
|
13
13
|
} catch {
|
|
14
|
-
throw new
|
|
14
|
+
throw new c("Import file is not valid JSON");
|
|
15
15
|
}
|
|
16
|
-
if (!
|
|
16
|
+
if (!l(t) || t.version !== u || !Array.isArray(t.history)) throw new c("Import file is not a supported export format");
|
|
17
17
|
let n = Array.isArray(t.folders) ? t.folders : [];
|
|
18
18
|
return {
|
|
19
|
-
version:
|
|
19
|
+
version: u,
|
|
20
20
|
history: t.history,
|
|
21
21
|
folders: n
|
|
22
22
|
};
|
|
23
|
-
},
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
let a = n &&
|
|
23
|
+
}, f = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, p = "__", m = 255, h = "applications", g = /[-+]/, _ = /^\d+$/, v = (e) => e ? e.split(g)[0].split(".").every((e) => _.test(e)) : !1, y = (e) => o(s(e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => a(e).trim()).filter(Boolean)[0] ?? "", m)).trimEnd(), b = (e, t, n) => {
|
|
24
|
+
let r = e.split(p);
|
|
25
|
+
if (r.length < 2) return [e, i()].join(p);
|
|
26
|
+
let a = n && v(r[1]) ? r.slice(0, 2) : r.slice(0, 1), o = a.length > 1 ? f.test(r[r.length - 1]) : r.length >= 3, s = r.slice(a.length, o ? -1 : void 0).join(p);
|
|
27
27
|
return [
|
|
28
28
|
...a,
|
|
29
29
|
t || s,
|
|
30
|
-
|
|
31
|
-
].join(
|
|
32
|
-
},
|
|
33
|
-
let n =
|
|
30
|
+
i()
|
|
31
|
+
].join(p);
|
|
32
|
+
}, x = "conversations/", S = (e) => e.startsWith(x) ? e.slice(14) : e, C = (e, t) => {
|
|
33
|
+
let n = S(e.id), r = n.split("/"), i = S(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = s.at(-1) ?? r.at(-1) ?? n, u = [...o, ...c], d = y(e.name), f = b(l, d, u[0] === h), p = [...u, f].join("/"), m = o.length ? `${t}/${o.join("/")}` : t;
|
|
34
34
|
return {
|
|
35
35
|
conversation: {
|
|
36
36
|
...e,
|
|
37
37
|
...d ? { name: d } : {},
|
|
38
38
|
id: `${t}/${p}`,
|
|
39
|
-
folderId:
|
|
39
|
+
folderId: m
|
|
40
40
|
},
|
|
41
41
|
subPath: p
|
|
42
42
|
};
|
|
43
|
-
},
|
|
44
|
-
let t =
|
|
43
|
+
}, w = (e) => {
|
|
44
|
+
let t = S(e.folderId).split("/").filter(Boolean).slice(1);
|
|
45
45
|
return t.length ? t.join(" / ") : void 0;
|
|
46
|
-
},
|
|
46
|
+
}, T = (e) => e.map((e) => `"${e}"`).join(", "), E = (e, n) => {
|
|
47
47
|
if (!e) return;
|
|
48
48
|
let { fileId: r, anchor: i } = t(e), a = n.get(r);
|
|
49
49
|
if (a != null) return {
|
|
50
50
|
...a,
|
|
51
51
|
url: `${a.url}${i}`
|
|
52
52
|
};
|
|
53
|
-
},
|
|
54
|
-
let n =
|
|
53
|
+
}, D = (e, t) => {
|
|
54
|
+
let n = E(e.url, t), r = E(e.reference_url, t);
|
|
55
55
|
if (n == null && r == null) return;
|
|
56
56
|
let i = n?.title ?? r?.title;
|
|
57
57
|
return {
|
|
@@ -59,19 +59,19 @@ var s = class extends Error {
|
|
|
59
59
|
...r == null ? {} : { reference_url: r.url },
|
|
60
60
|
...i == null ? {} : { title: i }
|
|
61
61
|
};
|
|
62
|
-
},
|
|
62
|
+
}, O = (e, t) => e.map((e) => e.attachments?.length ? {
|
|
63
63
|
...e,
|
|
64
64
|
attachments: e.attachments.map((e) => {
|
|
65
|
-
let n =
|
|
65
|
+
let n = D(e, t);
|
|
66
66
|
return n ? {
|
|
67
67
|
...e,
|
|
68
68
|
...n
|
|
69
69
|
} : e;
|
|
70
70
|
})
|
|
71
|
-
} : e),
|
|
71
|
+
} : e), k = (e, t) => e.map((e) => {
|
|
72
72
|
let n = e.body?.source;
|
|
73
73
|
if (n?.attachment == null) return e;
|
|
74
|
-
let r =
|
|
74
|
+
let r = D(n.attachment, t);
|
|
75
75
|
return r == null ? e : {
|
|
76
76
|
...e,
|
|
77
77
|
body: {
|
|
@@ -85,7 +85,7 @@ var s = class extends Error {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
}),
|
|
88
|
+
}), A = (e, t) => ({
|
|
89
89
|
...e,
|
|
90
90
|
messages: e.messages.map((e) => {
|
|
91
91
|
let n = e.custom_content;
|
|
@@ -96,23 +96,72 @@ var s = class extends Error {
|
|
|
96
96
|
custom_content: {
|
|
97
97
|
...n,
|
|
98
98
|
...r?.length ? { attachments: r.map((e) => {
|
|
99
|
-
let n =
|
|
99
|
+
let n = D(e, t);
|
|
100
100
|
return n ? {
|
|
101
101
|
...e,
|
|
102
102
|
...n
|
|
103
103
|
} : e;
|
|
104
104
|
}) } : {},
|
|
105
|
-
...i?.length ? { stages:
|
|
106
|
-
...a?.length ? { annotations:
|
|
105
|
+
...i?.length ? { stages: O(i, t) } : {},
|
|
106
|
+
...a?.length ? { annotations: k(a, t) } : {}
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
})
|
|
110
|
-
}),
|
|
110
|
+
}), j = (e, i) => {
|
|
111
|
+
if (!e) return;
|
|
112
|
+
let a = n(t(e).fileId);
|
|
113
|
+
if (!(!a || a.bucket === i || a.bucket === r)) return a.path.split("/").pop() || a.path;
|
|
114
|
+
}, M = (e, t, n) => e.flatMap((e) => {
|
|
115
|
+
let r = j(e.url, t);
|
|
116
|
+
if (r != null) return n.push(r), [];
|
|
117
|
+
let i = j(e.reference_url, t);
|
|
118
|
+
if (i == null) return [e];
|
|
119
|
+
n.push(i);
|
|
120
|
+
let { reference_url: a, reference_type: o, ...s } = e;
|
|
121
|
+
return s.url == null && s.data == null ? [] : [s];
|
|
122
|
+
}), N = (e, t, n) => e.map((e) => {
|
|
123
|
+
let r = e.body, i = j(r?.source?.attachment?.url, t);
|
|
124
|
+
if (r == null || i == null) return e;
|
|
125
|
+
n.push(i);
|
|
126
|
+
let { source: a, ...o } = r;
|
|
127
|
+
return {
|
|
128
|
+
...e,
|
|
129
|
+
body: o
|
|
130
|
+
};
|
|
131
|
+
}), P = (e, t) => {
|
|
132
|
+
let n = [], r = e.messages.map((e) => {
|
|
133
|
+
let r = e.custom_content;
|
|
134
|
+
if (!r) return e;
|
|
135
|
+
let { attachments: i, stages: a, annotations: o } = r;
|
|
136
|
+
return !i?.length && !a?.length && !o?.length ? e : {
|
|
137
|
+
...e,
|
|
138
|
+
custom_content: {
|
|
139
|
+
...r,
|
|
140
|
+
...i?.length ? { attachments: M(i, t, n) } : {},
|
|
141
|
+
...a?.length ? { stages: a.map((e) => e.attachments?.length ? {
|
|
142
|
+
...e,
|
|
143
|
+
attachments: M(e.attachments, t, n)
|
|
144
|
+
} : e) } : {},
|
|
145
|
+
...o?.length ? { annotations: N(o, t, n) } : {}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
return n.length ? {
|
|
150
|
+
conversation: {
|
|
151
|
+
...e,
|
|
152
|
+
messages: r
|
|
153
|
+
},
|
|
154
|
+
droppedNames: n
|
|
155
|
+
} : {
|
|
156
|
+
conversation: e,
|
|
157
|
+
droppedNames: n
|
|
158
|
+
};
|
|
159
|
+
}, F = (e) => e.split("/").pop() || e, I = (t, r, i) => {
|
|
111
160
|
let a = [], o = [];
|
|
112
161
|
for (let s of e(t)) {
|
|
113
162
|
let e = n(s.fileId);
|
|
114
163
|
if (!e) {
|
|
115
|
-
o.push(
|
|
164
|
+
o.push(F(s.fileId));
|
|
116
165
|
continue;
|
|
117
166
|
}
|
|
118
167
|
let t = e.path.split("/").pop() ?? e.path, c = r.get(e.path);
|
|
@@ -133,4 +182,4 @@ var s = class extends Error {
|
|
|
133
182
|
};
|
|
134
183
|
};
|
|
135
184
|
//#endregion
|
|
136
|
-
export {
|
|
185
|
+
export { c as UnsupportedImportFormatError, P as dropForeignAttachmentRefs, T as formatQuotedNameList, w as getFolderBreadcrumb, d as parseImportEnvelope, I as planAttachmentUploads, C as rebaseConversationId, A as rewriteAttachmentUrls };
|
|
@@ -171,12 +171,12 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
171
171
|
}, s);
|
|
172
172
|
return I.startJob(c, (e) => R(c, t, i, o, s, e));
|
|
173
173
|
}, [I, R]), B = b(async (e, t, n) => {
|
|
174
|
-
let r = d.ExportAll, a = [],
|
|
174
|
+
let r = d.ExportAll, a = [], c;
|
|
175
175
|
do {
|
|
176
176
|
if (n.aborted) return;
|
|
177
177
|
let t;
|
|
178
178
|
try {
|
|
179
|
-
t = await x.listConversations({ nextToken:
|
|
179
|
+
t = await x.listConversations({ nextToken: c }, { signal: n });
|
|
180
180
|
} catch (t) {
|
|
181
181
|
if (n.aborted) return;
|
|
182
182
|
if (E(t).isUnauthorized) F?.({
|
|
@@ -197,18 +197,18 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
197
197
|
a.push(...t.items.filter(j).map((e) => ({
|
|
198
198
|
id: e.id,
|
|
199
199
|
title: e.title
|
|
200
|
-
}))),
|
|
201
|
-
} while (
|
|
200
|
+
}))), c = t.nextToken;
|
|
201
|
+
} while (c);
|
|
202
202
|
I.setJobProgress(e, p({
|
|
203
203
|
kind: r,
|
|
204
204
|
phase: f.Prepare
|
|
205
205
|
}));
|
|
206
|
-
let
|
|
206
|
+
let l = [];
|
|
207
207
|
for (let t of a) {
|
|
208
208
|
if (n.aborted) return;
|
|
209
209
|
try {
|
|
210
210
|
let e = await A(x, T(t.id), n);
|
|
211
|
-
|
|
211
|
+
l.push(e);
|
|
212
212
|
} catch (r) {
|
|
213
213
|
if (n.aborted) return;
|
|
214
214
|
let i = E(r);
|
|
@@ -240,17 +240,17 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
240
240
|
I.setJobProgress(e, p({
|
|
241
241
|
kind: r,
|
|
242
242
|
phase: f.Transfer,
|
|
243
|
-
completed:
|
|
243
|
+
completed: l.length,
|
|
244
244
|
total: a.length
|
|
245
245
|
}, {
|
|
246
|
-
completed:
|
|
246
|
+
completed: l.length,
|
|
247
247
|
total: a.length,
|
|
248
248
|
kind: v.Conversation
|
|
249
249
|
}));
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
if (!n.aborted) try {
|
|
253
|
-
y(o(i(
|
|
253
|
+
y(o(i(l.map(s), [])), t), k?.({ jobId: e }), I.succeedJob(e);
|
|
254
254
|
} catch (t) {
|
|
255
255
|
let n = M(t) ? g.FileTooLarge : g.Unknown, r = await D(t);
|
|
256
256
|
F?.({
|