@epam/ai-dial-chat-hooks 1.3.0-dev.282 → 1.3.0-dev.289
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/api-error.d.ts +2 -0
- package/api-error/api-error.d.ts.map +1 -1
- package/api-error/api-error.js +31 -23
- package/catalog/map-skill-to-catalog-item.js +19 -19
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts +2 -4
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts.map +1 -1
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +94 -112
- package/catalog/useCatalogItemDelete/useCatalogItemDelete.d.ts +41 -0
- package/catalog/useCatalogItemDelete/useCatalogItemDelete.d.ts.map +1 -0
- package/catalog/useCatalogItemDelete/useCatalogItemDelete.js +37 -0
- package/catalog/usePublishFolders/usePublishFolders.d.ts +8 -0
- package/catalog/usePublishFolders/usePublishFolders.d.ts.map +1 -1
- package/catalog/usePublishFolders/usePublishFolders.js +32 -29
- package/catalog.js +11 -10
- package/conversation/conversation-title-stream.d.ts +33 -0
- package/conversation/conversation-title-stream.d.ts.map +1 -0
- package/conversation/conversation-title-stream.js +103 -0
- package/conversation/useConversationExport/useConversationExport.js +46 -46
- package/conversation/useConversationHandlers/useConversationHandlers.js +39 -39
- package/conversation/useConversationStream/useConversationStream.js +93 -93
- package/conversation.js +5 -4
- package/entry-points/catalog.d.ts +1 -0
- package/entry-points/catalog.d.ts.map +1 -1
- package/entry-points/conversation.d.ts +1 -0
- package/entry-points/conversation.d.ts.map +1 -1
- package/entry-points/project.d.ts +3 -0
- package/entry-points/project.d.ts.map +1 -1
- package/files/dial-file-manager-copy-move.util.js +16 -16
- package/files/dial-file-manager-mapping.util.js +17 -17
- package/files/useDialFileListing/useDialFileListing.js +113 -113
- package/files/useDialFileMutations/useDialFileMutations.js +47 -47
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -1
- package/index.js +213 -208
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts +7 -1
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.js +40 -21
- package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.js +10 -10
- package/package.json +18 -18
- package/project/project-events.d.ts +2 -2
- package/project/project-events.d.ts.map +1 -1
- package/project/project-events.js +3 -2
- package/project/project-mapping.js +12 -12
- package/project/project-refresh.d.ts +12 -0
- package/project/project-refresh.d.ts.map +1 -0
- package/project/project-refresh.js +6 -0
- package/project/project-watch-stream.d.ts +26 -0
- package/project/project-watch-stream.d.ts.map +1 -0
- package/project/project-watch-stream.js +39 -0
- package/project/projects-api-client.d.ts +6 -0
- package/project/projects-api-client.d.ts.map +1 -1
- package/project/projects-api-client.js +1 -0
- package/project/use-project-actions.js +12 -12
- package/project/use-project-conversations.d.ts +8 -6
- package/project/use-project-conversations.d.ts.map +1 -1
- package/project/use-project-conversations.js +129 -56
- package/project/use-project-watch.d.ts +24 -0
- package/project/use-project-watch.d.ts.map +1 -0
- package/project/use-project-watch.js +41 -0
- package/project/use-project.d.ts +4 -1
- package/project/use-project.d.ts.map +1 -1
- package/project/use-project.js +47 -22
- package/project/use-projects.d.ts.map +1 -1
- package/project/use-projects.js +49 -68
- package/project.js +8 -5
- package/prompt/prompt.d.ts +11 -0
- package/prompt/prompt.d.ts.map +1 -1
- package/prompt/prompt.js +7 -3
- package/scheduled-task/use-scheduled-task-runs.js +13 -13
- package/shared/serialized-writer.d.ts +10 -0
- package/shared/serialized-writer.d.ts.map +1 -0
- package/shared/serialized-writer.js +35 -0
- package/usage/map-user-usage-to-model-limits.js +21 -21
- package/useShareLink/useShareLink.js +18 -18
- package/utils.js +21 -21
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ListFilesItemDtoNodeTypeEnum as e } from "@epam/ai-dial-chat-api-client";
|
|
2
|
+
import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
3
|
import { fromFolderPathKey as a, mergeFolderPaths as o, toFolderPathKey as s } from "@epam/ai-dial-publish-panel";
|
|
4
4
|
//#region src/catalog/usePublishFolders/usePublishFolders.ts
|
|
5
|
-
var c = "Production", l = 50, u = (e,
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
var c = "Production", l = 50, u = (e) => !e.includes(c), d = (e, t) => {
|
|
6
|
+
let n = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
7
|
+
if (t && n[0] !== t) return [t, ...n.filter((e) => e !== t)].slice(0, l);
|
|
8
|
+
}, f = (t, n, r) => {
|
|
9
|
+
let i = t.get(n);
|
|
10
|
+
return i == null ? [] : i.filter((t) => t.nodeType === e.Folder).map((e) => {
|
|
11
|
+
let i = e.name, a = [...r, i], o = `${n}${e.name}/`;
|
|
9
12
|
return {
|
|
10
13
|
path: a,
|
|
11
14
|
name: i,
|
|
12
|
-
children:
|
|
15
|
+
children: t.has(o) ? f(t, o, a) : void 0
|
|
13
16
|
};
|
|
14
17
|
});
|
|
15
|
-
},
|
|
16
|
-
let [p, m] =
|
|
18
|
+
}, p = ({ listPublicFiles: e, rememberedFolderKeys: c, onRememberedFolderKeysChange: l }) => {
|
|
19
|
+
let [p, m] = i(() => /* @__PURE__ */ new Map()), [h, g] = i(() => /* @__PURE__ */ new Set()), [_, v] = i(() => /* @__PURE__ */ new Set()), [y, b] = i([]), x = r(() => {
|
|
17
20
|
let e = /* @__PURE__ */ new Set();
|
|
18
21
|
return h.forEach((t) => {
|
|
19
22
|
let n = t ? `${t}/` : "";
|
|
20
23
|
p.has(n) && e.add(t);
|
|
21
24
|
}), e;
|
|
22
|
-
}, [h, p]), S =
|
|
23
|
-
v((
|
|
25
|
+
}, [h, p]), S = t(async (t) => {
|
|
26
|
+
v((e) => new Set(e).add(t));
|
|
24
27
|
try {
|
|
25
|
-
let { items:
|
|
26
|
-
m((
|
|
28
|
+
let { items: n } = await e({ path: t || void 0 });
|
|
29
|
+
m((e) => new Map(e).set(t, n));
|
|
27
30
|
} finally {
|
|
28
|
-
v((
|
|
29
|
-
let n = new Set(
|
|
30
|
-
return n.delete(
|
|
31
|
+
v((e) => {
|
|
32
|
+
let n = new Set(e);
|
|
33
|
+
return n.delete(t), n;
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
|
-
}, [
|
|
34
|
-
|
|
36
|
+
}, [e]);
|
|
37
|
+
n(() => {
|
|
35
38
|
S("");
|
|
36
39
|
}, []);
|
|
37
|
-
let C =
|
|
40
|
+
let C = t((e) => {
|
|
38
41
|
g(e), e.forEach((e) => {
|
|
39
42
|
let t = `${e}/`;
|
|
40
43
|
!p.has(t) && !_.has(t) && S(t);
|
|
@@ -43,20 +46,20 @@ var c = "Production", l = 50, u = (e, t, n) => {
|
|
|
43
46
|
p,
|
|
44
47
|
_,
|
|
45
48
|
S
|
|
46
|
-
]), w =
|
|
49
|
+
]), w = t((e, t) => {
|
|
47
50
|
let n = s([...e, t]);
|
|
48
51
|
return b((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
|
|
49
|
-
}, []), T =
|
|
50
|
-
let t =
|
|
51
|
-
t &&
|
|
52
|
-
}, [
|
|
52
|
+
}, []), T = t((e) => {
|
|
53
|
+
let t = d(c, s(e));
|
|
54
|
+
t && l?.(t);
|
|
55
|
+
}, [c, l]), E = u;
|
|
53
56
|
return {
|
|
54
|
-
folderItems:
|
|
55
|
-
let e = Array.isArray(
|
|
56
|
-
return o(
|
|
57
|
+
folderItems: r(() => {
|
|
58
|
+
let e = Array.isArray(c) ? c.filter((e) => typeof e == "string") : [];
|
|
59
|
+
return o(f(p, "", []), [...e.map(a), ...y.map(a)]);
|
|
57
60
|
}, [
|
|
58
61
|
p,
|
|
59
|
-
|
|
62
|
+
c,
|
|
60
63
|
y
|
|
61
64
|
]),
|
|
62
65
|
expandedPaths: h,
|
|
@@ -69,4 +72,4 @@ var c = "Production", l = 50, u = (e, t, n) => {
|
|
|
69
72
|
};
|
|
70
73
|
};
|
|
71
74
|
//#endregion
|
|
72
|
-
export { d as usePublishFolders };
|
|
75
|
+
export { u as hasPublishFolderWriteAccess, d as rememberPublishFolderKey, p as usePublishFolders };
|
package/catalog.js
CHANGED
|
@@ -18,13 +18,14 @@ import { resolveFavoriteEntityType as se } from "./catalog/favorite-entity-type.
|
|
|
18
18
|
import { parseCatalogFilterTopics as ce, resolveCatalogActiveTab as le, resolveCatalogSortKey as ue } from "./catalog/catalog-preferences.js";
|
|
19
19
|
import { findWorstCappedRow as de } from "./catalog/usage-limit-rows.js";
|
|
20
20
|
import { CatalogPrimaryActionType as fe, resolveCatalogPrimaryAction as pe } from "./catalog/catalog-primary-action.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
21
|
+
import { useCatalogItemDelete as me } from "./catalog/useCatalogItemDelete/useCatalogItemDelete.js";
|
|
22
|
+
import { useCatalogEditNavigation as he } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
|
|
23
|
+
import { useSkillItemDetails as ge } from "./catalog/useSkillItemDetails.js";
|
|
24
|
+
import { useCatalogItemDetails as _e } from "./catalog/useCatalogItemDetails.js";
|
|
25
|
+
import { useCatalogToolsetCredentials as ve } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
|
|
26
|
+
import { buildApplicationCredentialLoginParams as ye, mapApplicationCredentials as be } from "./catalog/application-credentials.js";
|
|
27
|
+
import { useApplicationCredentials as xe } from "./catalog/useApplicationCredentials/useApplicationCredentials.js";
|
|
28
|
+
import { useSkillDetailsPanelData as Se } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
|
|
29
|
+
import { hasPublishFolderWriteAccess as Ce, rememberPublishFolderKey as we, usePublishFolders as Te } from "./catalog/usePublishFolders/usePublishFolders.js";
|
|
30
|
+
import { SkillPreviewErrorKind as Ee, useSkillFilePreview as De } from "./skill/useSkillFilePreview.js";
|
|
31
|
+
export { u as AuthenticationType, ne as CatalogEntityKind, fe as CatalogPrimaryActionType, m as DEFAULT_ENTITY_DETAILS_LABELS, ae as FavoriteEntityType, B as McpResourceKind, E as PUBLIC_SKILL_BUCKET, D as SKILL_LISTING_MAX_PAGES, O as SKILL_LISTING_PAGE_SIZE, k as SKILL_MANIFEST_MAX_BYTES, Ee as SkillPreviewErrorKind, A as SkillSource, ye as buildApplicationCredentialLoginParams, V as buildApplicationMcpUrl, n as buildChatCompletionsUrl, H as buildConnectApi, r as buildDeploymentConnectApi, C as buildPromptOverview, d as buildResetFields, i as buildResponsesUrl, M as buildSkillContentTree, N as buildSkillOverview, U as buildToolsetMcpUrl, X as canEditShareAccess, a as createDeploymentLookup, e as createPublishApiClient, o as decodeDeploymentId, Z as deriveAvailableTabIds, Q as deriveFavoriteItems, s as encodeDeploymentId, $ as filterCatalogItemsBySelector, ee as filterHiddenOwnedItems, c as findDeploymentByIdOrReference, re as findSchemaDisplayName, de as findWorstCappedRow, G as getPublicCatalogEntityFolderPath, Ce as hasPublishFolderWriteAccess, w as isOrganisationPromptItem, K as isPublicCatalogEntityId, be as mapApplicationCredentials, h as mapDeploymentDetailsDtoToEntityDetails, p as mapDeploymentLimitsDtoToCatalogLimits, f as mapDeploymentLimitsToInput, v as mapDeploymentToCatalogItem, y as mapDeploymentToolsetCredentials, g as mapEntityDetailsToCatalogDetails, T as mapPromptToCatalogItem, q as mapPublishConversationResultDto, J as mapPublishHistoryEntryDto, P as mapSkillToCatalogItem, _ as mapToolsetCredentials, b as mapToolsetToCatalogItem, l as normalizeDeploymentId, ce as parseCatalogFilterTopics, j as parseSkillResourceUrl, F as readSkillFileBytes, I as readSkillFilePreviewBytes, L as readSkillManifest, te as reconcileFilterTopics, we as rememberPublishFolderKey, le as resolveCatalogActiveTab, ie as resolveCatalogEntityKind, pe as resolveCatalogPrimaryAction, ue as resolveCatalogSortKey, x as resolveDeploymentFolder, se as resolveFavoriteEntityType, W as resolveMcpResourceKind, R as resolveSkillFileDownloadPath, z as resolveSkillManifestFileId, S as supportsChatInterface, Y as toPublishEntityType, t as toPublishRuleDto, xe as useApplicationCredentials, he as useCatalogEditNavigation, me as useCatalogItemDelete, _e as useCatalogItemDetails, ve as useCatalogToolsetCredentials, oe as useFavoriteEntitiesState, Te as usePublishFolders, Se as useSkillDetailsPanelData, De as useSkillFilePreview, ge as useSkillItemDetails };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConversationTitleStreamEventDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
/** Most conversation ids one `streamConversationTitles` request may carry. */
|
|
3
|
+
export declare const CONVERSATION_TITLE_STREAM_MAX_IDS = 500;
|
|
4
|
+
/** Most bytes the serialized ids of one `streamConversationTitles` request may take. */
|
|
5
|
+
export declare const CONVERSATION_TITLE_STREAM_MAX_ID_BYTES: number;
|
|
6
|
+
/** No single event (data lines plus an unterminated line) may exceed this. */
|
|
7
|
+
export declare const CONVERSATION_TITLE_STREAM_MAX_FRAME_BYTES: number;
|
|
8
|
+
/** The stream broke its contract; the attempt must stop without retrying. */
|
|
9
|
+
export declare class ConversationTitleStreamProtocolError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
/** Validates one `data:` payload against the generated event union. */
|
|
13
|
+
export declare const parseConversationTitleStreamEvent: (data: string) => ConversationTitleStreamEventDto;
|
|
14
|
+
/**
|
|
15
|
+
* Incremental SSE framing for already-decoded text: CR, LF and CRLF line
|
|
16
|
+
* endings, comment lines, and multi-line `data:` fields joined by `\n`.
|
|
17
|
+
* Returns the `data` payload of every event completed by `text`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createSseFrameDecoder: (maxFrameBytes?: number) => {
|
|
20
|
+
push: (text: string) => string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reads a title stream body as validated events. The reader is cancelled
|
|
24
|
+
* when iteration stops early (a terminal event, an abort, a protocol error)
|
|
25
|
+
* and released on every exit.
|
|
26
|
+
*/
|
|
27
|
+
export declare const readConversationTitleStream: (body: ReadableStream<Uint8Array>) => AsyncIterable<ConversationTitleStreamEventDto>;
|
|
28
|
+
/**
|
|
29
|
+
* True when an older backend lacks the stream route — the only failure that
|
|
30
|
+
* may switch an identity session to the JSON titles endpoint.
|
|
31
|
+
*/
|
|
32
|
+
export declare const isConversationTitleStreamUnsupported: (error: unknown) => boolean;
|
|
33
|
+
//# sourceMappingURL=conversation-title-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-title-stream.d.ts","sourceRoot":"","sources":["../../src/conversation/conversation-title-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,+BAA+B,EAUrC,MAAM,+BAA+B,CAAC;AAEvC,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,wFAAwF;AACxF,eAAO,MAAM,sCAAsC,QAAa,CAAC;AACjE,8EAA8E;AAC9E,eAAO,MAAM,yCAAyC,QAAY,CAAC;AAEnE,6EAA6E;AAC7E,qBAAa,oCAAqC,SAAQ,KAAK;gBACjD,OAAO,EAAE,MAAM;CAI5B;AA4BD,uEAAuE;AACvE,eAAO,MAAM,iCAAiC,GAC5C,MAAM,MAAM,KACX,+BA4DF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,sBAAyD;iBAoC1C,MAAM,KAAG,MAAM,EAAE;CAmBjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,MAAM,cAAc,CAAC,UAAU,CAAC,KAC/B,aAAa,CAAC,+BAA+B,CA2B9C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,OAAO,YAED,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ConversationTitleStreamDoneEventDtoTypeEnum as e, ConversationTitleStreamDoneReason as t, ConversationTitleStreamErrorCode as n, ConversationTitleStreamErrorEventDtoTypeEnum as r, ConversationTitleStreamItemErrorCode as i, ConversationTitleStreamItemErrorEventDtoTypeEnum as a, ConversationTitleStreamTitleEventDtoTypeEnum as o, ConversationTitleStreamUnavailableEventDtoTypeEnum as s, ResponseError as c } from "@epam/ai-dial-chat-api-client";
|
|
2
|
+
//#region src/conversation/conversation-title-stream.ts
|
|
3
|
+
var l = 500, u = 262144, d = 65536, f = class extends Error {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(e), this.name = "ConversationTitleStreamProtocolError";
|
|
6
|
+
}
|
|
7
|
+
}, p = {
|
|
8
|
+
401: n.Unauthenticated,
|
|
9
|
+
502: n.UpstreamError,
|
|
10
|
+
503: n.Unavailable
|
|
11
|
+
}, m = (e) => {
|
|
12
|
+
let t = 0;
|
|
13
|
+
for (let n = 0; n < e.length; n++) {
|
|
14
|
+
let r = e.charCodeAt(n);
|
|
15
|
+
r < 128 ? t += 1 : r < 2048 ? t += 2 : r >= 55296 && r <= 56319 ? (t += 4, n++) : t += 3;
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}, h = (e) => typeof e == "string", g = (e) => Number.isInteger(e) && e >= 0, _ = (e, t) => Object.values(e).includes(t), v = (n) => {
|
|
19
|
+
let c;
|
|
20
|
+
try {
|
|
21
|
+
c = JSON.parse(n);
|
|
22
|
+
} catch {
|
|
23
|
+
throw new f("Malformed event JSON");
|
|
24
|
+
}
|
|
25
|
+
if (typeof c != "object" || !c) throw new f("Event is not an object");
|
|
26
|
+
switch (c.type) {
|
|
27
|
+
case o.Title:
|
|
28
|
+
if (h(c.id) && h(c.title)) return {
|
|
29
|
+
type: c.type,
|
|
30
|
+
id: c.id,
|
|
31
|
+
title: c.title
|
|
32
|
+
};
|
|
33
|
+
break;
|
|
34
|
+
case s.Unavailable:
|
|
35
|
+
if (h(c.id)) return {
|
|
36
|
+
type: c.type,
|
|
37
|
+
id: c.id
|
|
38
|
+
};
|
|
39
|
+
break;
|
|
40
|
+
case a.ItemError:
|
|
41
|
+
if (h(c.id) && _(i, c.code)) return {
|
|
42
|
+
type: c.type,
|
|
43
|
+
id: c.id,
|
|
44
|
+
code: c.code
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
case e.Done:
|
|
48
|
+
if (_(t, c.reason) && g(c.processed) && g(c.total) && c.processed <= c.total) return {
|
|
49
|
+
type: c.type,
|
|
50
|
+
reason: c.reason,
|
|
51
|
+
processed: c.processed,
|
|
52
|
+
total: c.total
|
|
53
|
+
};
|
|
54
|
+
break;
|
|
55
|
+
case r.Error: if (typeof c.status == "number" && p[c.status] === c.code) return {
|
|
56
|
+
type: c.type,
|
|
57
|
+
status: c.status,
|
|
58
|
+
code: c.code
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
throw new f("Unknown or invalid event");
|
|
62
|
+
}, y = (e = d) => {
|
|
63
|
+
let t = "", n = [], r = 0, i = !0, a = (t) => {
|
|
64
|
+
if (t > e) throw new f("Event exceeds 64 KiB");
|
|
65
|
+
}, o = (e, t) => {
|
|
66
|
+
if (i && (i = !1, e.startsWith("") && (e = e.slice(1))), e === "") {
|
|
67
|
+
n.length > 0 && t.push(n.join("\n")), n = [], r = 0;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (e.startsWith(":")) return;
|
|
71
|
+
let o = e.indexOf(":");
|
|
72
|
+
if ((o === -1 ? e : e.slice(0, o)) !== "data") return;
|
|
73
|
+
let s = o === -1 ? "" : e.slice(o + 1);
|
|
74
|
+
s.startsWith(" ") && (s = s.slice(1)), r += m(s) + 1, a(r), n.push(s);
|
|
75
|
+
};
|
|
76
|
+
return { push: (e) => {
|
|
77
|
+
let n = [];
|
|
78
|
+
for (t += e;;) {
|
|
79
|
+
let e = /\r\n|\r|\n/.exec(t);
|
|
80
|
+
if (!e || e[0] === "\r" && e.index === t.length - 1) break;
|
|
81
|
+
o(t.slice(0, e.index), n), t = t.slice(e.index + e[0].length);
|
|
82
|
+
}
|
|
83
|
+
return a(r + m(t)), n;
|
|
84
|
+
} };
|
|
85
|
+
}, b = (e) => ({ async *[Symbol.asyncIterator]() {
|
|
86
|
+
let t = e.getReader(), n = new TextDecoder(), r = y(), i = !1;
|
|
87
|
+
try {
|
|
88
|
+
for (;;) {
|
|
89
|
+
let { done: e, value: a } = await t.read();
|
|
90
|
+
if (e) {
|
|
91
|
+
i = !0;
|
|
92
|
+
for (let e of r.push(n.decode())) yield v(e);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let o = n.decode(a, { stream: !0 });
|
|
96
|
+
for (let e of r.push(o)) yield v(e);
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
i || await t.cancel().catch(() => void 0), t.releaseLock();
|
|
100
|
+
}
|
|
101
|
+
} }), x = (e) => e instanceof c && (e.response.status === 404 || e.response.status === 405);
|
|
102
|
+
//#endregion
|
|
103
|
+
export { d as CONVERSATION_TITLE_STREAM_MAX_FRAME_BYTES, l as CONVERSATION_TITLE_STREAM_MAX_IDS, u as CONVERSATION_TITLE_STREAM_MAX_ID_BYTES, f as ConversationTitleStreamProtocolError, y as createSseFrameDecoder, x as isConversationTitleStreamUnsupported, v as parseConversationTitleStreamEvent, b as readConversationTitleStream };
|
|
@@ -6,11 +6,11 @@ import { runWithConcurrency as u } from "../conversation-transfer/async.js";
|
|
|
6
6
|
import { ConversationTransferKind as d, ConversationTransferPhase as f, buildTransferProgress as p } from "../conversation-transfer/progress.js";
|
|
7
7
|
import { useConversationTransferQueue as m } from "../conversation-transfer/queue.js";
|
|
8
8
|
import { buildDialArchive as h } from "../conversation-transfer/zip-export.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { ResponseError as g } from "@epam/ai-dial-chat-api-client";
|
|
10
|
+
import { ConversationTransferErrorCode as _, ConversationTransferSubjectKind as v, ConversationTransferUnitKind as y, triggerBlobDownload as b } from "@epam/ai-dial-chat-shared";
|
|
11
|
+
import { useCallback as x } from "react";
|
|
12
12
|
//#region src/conversation/useConversationExport/useConversationExport.ts
|
|
13
|
-
var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof
|
|
13
|
+
var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof g && e.response.status === w, O = (e, t) => {
|
|
14
14
|
let n = Number(e.response.headers.get("Retry-After"));
|
|
15
15
|
return Number.isFinite(n) && n > 0 ? n * 1e3 : E * t;
|
|
16
16
|
}, k = (e, t) => new Promise((n) => {
|
|
@@ -29,8 +29,8 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
29
29
|
if (n.aborted || !D(e) || r >= T) throw e;
|
|
30
30
|
await k(O(e, r), n);
|
|
31
31
|
}
|
|
32
|
-
}, j = (e) => !e.sharedWithMe && !e.publishedWithMe, M = (e) => e instanceof RangeError, N = (e) => e === t.WithoutAttachments ? d.ExportSingle : d.ExportSingleWithAttachments, P = ({ conversationsApi:
|
|
33
|
-
let I = m(), L =
|
|
32
|
+
}, j = (e) => !e.sharedWithMe && !e.publishedWithMe, M = (e) => e instanceof RangeError, N = (e) => e === t.WithoutAttachments ? d.ExportSingle : d.ExportSingleWithAttachments, P = ({ conversationsApi: g, filesApi: w, normalizeConversationPath: T, classifyTransferError: E = () => ({}), resolveErrorTraceId: D = async () => void 0, maxArchiveBytes: O = C, onSuccess: k, onWarning: P, onError: F }) => {
|
|
33
|
+
let I = m(), L = x(async (e, t, n) => {
|
|
34
34
|
let r = !1, i = !1, a = 0, o = () => {
|
|
35
35
|
a += 1, n(a, e.length);
|
|
36
36
|
};
|
|
@@ -61,24 +61,24 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
61
61
|
anySkipped: !t.aborted && !i && r,
|
|
62
62
|
isUnauthorized: !t.aborted && i
|
|
63
63
|
};
|
|
64
|
-
}, [E, w]), R =
|
|
65
|
-
let m = N(l),
|
|
64
|
+
}, [E, w]), R = x(async (r, i, o, l, u, d) => {
|
|
65
|
+
let m = N(l), v;
|
|
66
66
|
try {
|
|
67
|
-
|
|
67
|
+
v = await A(g, T(i), d);
|
|
68
68
|
} catch (e) {
|
|
69
69
|
if (d.aborted) return;
|
|
70
70
|
if (E(e).isUnauthorized) F?.({
|
|
71
71
|
jobId: r,
|
|
72
|
-
code:
|
|
73
|
-
}), I.failJob(r,
|
|
72
|
+
code: _.Unauthorized
|
|
73
|
+
}), I.failJob(r, _.Unauthorized);
|
|
74
74
|
else {
|
|
75
75
|
let t = await D(e);
|
|
76
76
|
F?.({
|
|
77
77
|
jobId: r,
|
|
78
|
-
code:
|
|
78
|
+
code: _.Unknown,
|
|
79
79
|
titles: [o],
|
|
80
80
|
traceId: t
|
|
81
|
-
}), I.failJob(r,
|
|
81
|
+
}), I.failJob(r, _.Unknown);
|
|
82
82
|
}
|
|
83
83
|
console.error("Failed to fetch conversation for export", e);
|
|
84
84
|
return;
|
|
@@ -90,14 +90,14 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
90
90
|
}));
|
|
91
91
|
try {
|
|
92
92
|
if (l === t.WithoutAttachments) {
|
|
93
|
-
let e = a([c(
|
|
94
|
-
|
|
93
|
+
let e = a([c(v)], []), t = s(e);
|
|
94
|
+
b(t, u), k?.({
|
|
95
95
|
jobId: r,
|
|
96
96
|
titles: [o]
|
|
97
97
|
}), I.succeedJob(r);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
let i = e(
|
|
100
|
+
let i = e(v), { entries: g, anySkipped: x, isUnauthorized: S } = await L(i, d, (e, t) => {
|
|
101
101
|
I.setJobProgress(r, p({
|
|
102
102
|
kind: m,
|
|
103
103
|
phase: f.Transfer,
|
|
@@ -106,15 +106,15 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
106
106
|
}, {
|
|
107
107
|
completed: e,
|
|
108
108
|
total: t,
|
|
109
|
-
kind:
|
|
109
|
+
kind: y.Attachment
|
|
110
110
|
}));
|
|
111
111
|
});
|
|
112
112
|
if (d.aborted) return;
|
|
113
113
|
if (S) {
|
|
114
114
|
F?.({
|
|
115
115
|
jobId: r,
|
|
116
|
-
code:
|
|
117
|
-
}), I.failJob(r,
|
|
116
|
+
code: _.Unauthorized
|
|
117
|
+
}), I.failJob(r, _.Unauthorized);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
I.setJobProgress(r, p({
|
|
@@ -123,26 +123,26 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
123
123
|
completed: i.length,
|
|
124
124
|
total: i.length
|
|
125
125
|
}));
|
|
126
|
-
let C =
|
|
126
|
+
let C = g.reduce((e, t) => e + t.data.byteLength, 0);
|
|
127
127
|
if (C > O) {
|
|
128
128
|
F?.({
|
|
129
129
|
jobId: r,
|
|
130
|
-
code:
|
|
130
|
+
code: _.FileTooLarge,
|
|
131
131
|
titles: [o]
|
|
132
|
-
}), I.failJob(r,
|
|
132
|
+
}), I.failJob(r, _.FileTooLarge), console.error(`Refused to build an export archive of ${C} bytes: over the ${O}-byte limit`);
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
-
let w = a([
|
|
135
|
+
let w = a([v], []), { blob: T, skippedPaths: E } = h(w, g), D = x || E.length > 0;
|
|
136
136
|
D && P?.({
|
|
137
137
|
jobId: r,
|
|
138
138
|
code: n.AttachmentSkipped
|
|
139
|
-
}),
|
|
139
|
+
}), b(T, u), k?.({
|
|
140
140
|
jobId: r,
|
|
141
141
|
titles: [o]
|
|
142
142
|
}), D ? I.warnJob(r, n.AttachmentSkipped) : I.succeedJob(r);
|
|
143
143
|
} catch (e) {
|
|
144
144
|
if (d.aborted) return;
|
|
145
|
-
let t = M(e) ?
|
|
145
|
+
let t = M(e) ? _.FileTooLarge : _.Unknown, n = await D(e);
|
|
146
146
|
F?.({
|
|
147
147
|
jobId: r,
|
|
148
148
|
code: t,
|
|
@@ -153,7 +153,7 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
153
153
|
}
|
|
154
154
|
}, [
|
|
155
155
|
E,
|
|
156
|
-
|
|
156
|
+
g,
|
|
157
157
|
L,
|
|
158
158
|
O,
|
|
159
159
|
T,
|
|
@@ -162,32 +162,32 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
162
162
|
P,
|
|
163
163
|
I,
|
|
164
164
|
D
|
|
165
|
-
]), z =
|
|
165
|
+
]), z = x((e, n, a) => {
|
|
166
166
|
let s = o(a === t.WithoutAttachments ? r.SingleConversation : r.SingleConversationWithAttachments, i), c = I.addJob({
|
|
167
|
-
kind:
|
|
167
|
+
kind: v.Single,
|
|
168
168
|
title: n
|
|
169
169
|
}, s);
|
|
170
170
|
return I.startJob(c, (t) => R(c, e, n, a, s, t));
|
|
171
|
-
}, [I, R]), B =
|
|
171
|
+
}, [I, R]), B = x(async (e, t, n) => {
|
|
172
172
|
let r = d.ExportAll, i = [], o;
|
|
173
173
|
do {
|
|
174
174
|
if (n.aborted) return;
|
|
175
175
|
let t;
|
|
176
176
|
try {
|
|
177
|
-
t = await
|
|
177
|
+
t = await g.listConversations({ nextToken: o }, { signal: n });
|
|
178
178
|
} catch (t) {
|
|
179
179
|
if (n.aborted) return;
|
|
180
180
|
if (E(t).isUnauthorized) F?.({
|
|
181
181
|
jobId: e,
|
|
182
|
-
code:
|
|
183
|
-
}), I.failJob(e,
|
|
182
|
+
code: _.Unauthorized
|
|
183
|
+
}), I.failJob(e, _.Unauthorized);
|
|
184
184
|
else {
|
|
185
185
|
let n = await D(t);
|
|
186
186
|
F?.({
|
|
187
187
|
jobId: e,
|
|
188
|
-
code:
|
|
188
|
+
code: _.Unknown,
|
|
189
189
|
traceId: n
|
|
190
|
-
}), I.failJob(e,
|
|
190
|
+
}), I.failJob(e, _.Unknown);
|
|
191
191
|
}
|
|
192
192
|
console.error("Failed to list conversations for export", t);
|
|
193
193
|
return;
|
|
@@ -205,7 +205,7 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
205
205
|
for (let t of i) {
|
|
206
206
|
if (n.aborted) return;
|
|
207
207
|
try {
|
|
208
|
-
let e = await A(
|
|
208
|
+
let e = await A(g, T(t.id), n);
|
|
209
209
|
l.push(e);
|
|
210
210
|
} catch (r) {
|
|
211
211
|
if (n.aborted) return;
|
|
@@ -213,15 +213,15 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
213
213
|
if (i.isUnauthorized) {
|
|
214
214
|
F?.({
|
|
215
215
|
jobId: e,
|
|
216
|
-
code:
|
|
217
|
-
}), I.failJob(e,
|
|
216
|
+
code: _.Unauthorized
|
|
217
|
+
}), I.failJob(e, _.Unauthorized);
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
220
|
if (i.isNotFound) {
|
|
221
221
|
let n = await D(r);
|
|
222
222
|
F?.({
|
|
223
223
|
jobId: e,
|
|
224
|
-
code:
|
|
224
|
+
code: _.NotFound,
|
|
225
225
|
titles: [t.title],
|
|
226
226
|
traceId: n
|
|
227
227
|
}), console.error("Skipped a conversation during export-all: not found", r);
|
|
@@ -230,9 +230,9 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
230
230
|
let a = await D(r);
|
|
231
231
|
F?.({
|
|
232
232
|
jobId: e,
|
|
233
|
-
code:
|
|
233
|
+
code: _.Unknown,
|
|
234
234
|
traceId: a
|
|
235
|
-
}), I.failJob(e,
|
|
235
|
+
}), I.failJob(e, _.Unknown), console.error("Aborted export-all: failed to fetch conversation", r);
|
|
236
236
|
return;
|
|
237
237
|
} finally {
|
|
238
238
|
I.setJobProgress(e, p({
|
|
@@ -243,15 +243,15 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
243
243
|
}, {
|
|
244
244
|
completed: l.length,
|
|
245
245
|
total: i.length,
|
|
246
|
-
kind:
|
|
246
|
+
kind: y.Conversation
|
|
247
247
|
}));
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
if (!n.aborted) try {
|
|
251
251
|
let n = a(l.map(c), []), r = s(n);
|
|
252
|
-
|
|
252
|
+
b(r, t), k?.({ jobId: e }), I.succeedJob(e);
|
|
253
253
|
} catch (t) {
|
|
254
|
-
let n = M(t) ?
|
|
254
|
+
let n = M(t) ? _.FileTooLarge : _.Unknown, r = await D(t);
|
|
255
255
|
F?.({
|
|
256
256
|
jobId: e,
|
|
257
257
|
code: n,
|
|
@@ -260,14 +260,14 @@ var S = 5, C = 536870912, w = 429, T = 5, E = 2e3, D = (e) => e instanceof x &&
|
|
|
260
260
|
}
|
|
261
261
|
}, [
|
|
262
262
|
E,
|
|
263
|
-
|
|
263
|
+
g,
|
|
264
264
|
T,
|
|
265
265
|
F,
|
|
266
266
|
k,
|
|
267
267
|
I,
|
|
268
268
|
D
|
|
269
|
-
]), V =
|
|
270
|
-
let e = o(r.AllConversationsHistory, i), t = I.addJob({ kind:
|
|
269
|
+
]), V = x(() => {
|
|
270
|
+
let e = o(r.AllConversationsHistory, i), t = I.addJob({ kind: v.All }, e);
|
|
271
271
|
return I.startJob(t, (n) => B(t, e, n));
|
|
272
272
|
}, [I, B]);
|
|
273
273
|
return {
|