@epam/ai-dial-chat-hooks 1.1.0-dev.252 → 1.1.0-dev.253
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/attachment/useAttachmentValidation/useAttachmentValidation.d.ts +44 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.d.ts.map +1 -0
- package/conversation/conversation-transfer/async.d.ts +10 -0
- package/conversation/conversation-transfer/async.d.ts.map +1 -0
- package/conversation/conversation-transfer/attachment-refs.d.ts +12 -0
- package/conversation/conversation-transfer/attachment-refs.d.ts.map +1 -0
- package/conversation/conversation-transfer/build-upload-path.d.ts +40 -0
- package/conversation/conversation-transfer/build-upload-path.d.ts.map +1 -0
- package/conversation/conversation-transfer/date.d.ts +5 -0
- package/conversation/conversation-transfer/date.d.ts.map +1 -0
- package/conversation/conversation-transfer/dial-file-resolve.d.ts +10 -0
- package/conversation/conversation-transfer/dial-file-resolve.d.ts.map +1 -0
- package/conversation/conversation-transfer/export-conversation.d.ts +8 -0
- package/conversation/conversation-transfer/export-conversation.d.ts.map +1 -0
- package/conversation/conversation-transfer/import-conversation.d.ts +82 -0
- package/conversation/conversation-transfer/import-conversation.d.ts.map +1 -0
- package/conversation/conversation-transfer/queue.d.ts +31 -0
- package/conversation/conversation-transfer/queue.d.ts.map +1 -0
- package/conversation/conversation-transfer/types.d.ts +73 -0
- package/conversation/conversation-transfer/types.d.ts.map +1 -0
- package/conversation/conversation-transfer/zip-export.d.ts +31 -0
- package/conversation/conversation-transfer/zip-export.d.ts.map +1 -0
- package/conversation/conversation-transfer/zip-import.d.ts +17 -0
- package/conversation/conversation-transfer/zip-import.d.ts.map +1 -0
- package/conversation/useConversationExport/useConversationExport.d.ts +50 -0
- package/conversation/useConversationExport/useConversationExport.d.ts.map +1 -0
- package/conversation/useConversationHandlers/attachment-to-dto.d.ts +7 -0
- package/conversation/useConversationHandlers/attachment-to-dto.d.ts.map +1 -0
- package/conversation/useConversationHandlers/message-factory.d.ts +9 -0
- package/conversation/useConversationHandlers/message-factory.d.ts.map +1 -0
- package/conversation/useConversationHandlers/message-utils.d.ts +14 -0
- package/conversation/useConversationHandlers/message-utils.d.ts.map +1 -0
- package/conversation/useConversationHandlers/starter-option.d.ts +14 -0
- package/conversation/useConversationHandlers/starter-option.d.ts.map +1 -0
- package/conversation/useConversationHandlers/useConversationHandlers.d.ts +66 -0
- package/conversation/useConversationHandlers/useConversationHandlers.d.ts.map +1 -0
- package/conversation/useConversationImport/useConversationImport.d.ts +50 -0
- package/conversation/useConversationImport/useConversationImport.d.ts.map +1 -0
- package/conversation/useConversationStream/apply-chunk.d.ts +20 -0
- package/conversation/useConversationStream/apply-chunk.d.ts.map +1 -0
- package/conversation/useConversationStream/conversation-path.d.ts +9 -0
- package/conversation/useConversationStream/conversation-path.d.ts.map +1 -0
- package/conversation/useConversationStream/generation-resume.d.ts +10 -0
- package/conversation/useConversationStream/generation-resume.d.ts.map +1 -0
- package/conversation/useConversationStream/useConversationStream.d.ts +78 -0
- package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -0
- package/index.d.ts +15 -0
- package/index.d.ts.map +1 -1
- package/index.js +1272 -92
- package/package.json +10 -7
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AttachmentErrorReason, Attachment } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** Reason a rejected attachment failed validation. */
|
|
3
|
+
export declare enum AttachmentValidationErrorReason {
|
|
4
|
+
/** No MIME types are allowed at all — attachments are disabled entirely. */
|
|
5
|
+
NoTypesAllowed = "noTypesAllowed",
|
|
6
|
+
/** The attachment's content type is not among the allowed MIME types. */
|
|
7
|
+
UnsupportedType = "unsupportedType"
|
|
8
|
+
}
|
|
9
|
+
/** Structured, translation-free report of a rejected attachment, emitted at most once per debounce window. */
|
|
10
|
+
export interface AttachmentValidationErrorEvent {
|
|
11
|
+
/** Why the attachment(s) were rejected. */
|
|
12
|
+
reason: AttachmentValidationErrorReason;
|
|
13
|
+
/** The resolved MIME types the caller currently allows (possibly empty). */
|
|
14
|
+
allowedMimeTypes: string[];
|
|
15
|
+
/** Already-formatted, non-translated extension list (e.g. ".png, .jpg"), present only when `reason` is `UnsupportedType`. */
|
|
16
|
+
formats?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Parameters for {@link useAttachmentValidation}. */
|
|
19
|
+
export interface UseAttachmentValidationParams {
|
|
20
|
+
/** Resolved MIME types currently allowed for attachments. */
|
|
21
|
+
allowedMimeTypes: string[];
|
|
22
|
+
/** Called with a structured event when a rejected attachment is reported, at most once per debounce window. */
|
|
23
|
+
onValidationError?: (event: AttachmentValidationErrorEvent) => void;
|
|
24
|
+
/** Debounce window, in ms, before firing `onValidationError` for a rejected file. Defaults to `100`. */
|
|
25
|
+
debounceMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Return value of {@link useAttachmentValidation}. */
|
|
28
|
+
export interface UseAttachmentValidationResult {
|
|
29
|
+
/** The resolved MIME types currently allowed for attachments (echoes the `allowedMimeTypes` param). */
|
|
30
|
+
inputAttachmentTypes: string[];
|
|
31
|
+
/** Whether at least one MIME type is currently allowed. */
|
|
32
|
+
isAttachmentsAllowed: boolean;
|
|
33
|
+
/** Classifies an attachment as allowed (`undefined`) or rejected (`AttachmentErrorReason`). */
|
|
34
|
+
validateAttachment: (attachment: Attachment) => AttachmentErrorReason | undefined;
|
|
35
|
+
/** `<input accept>` string derived from `allowedMimeTypes`, or `undefined` when any type accepts everything. */
|
|
36
|
+
fileAccept: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Validates an attachment's content type against a resolved list of allowed
|
|
40
|
+
* MIME types, debouncing a burst of rejected files into a single
|
|
41
|
+
* `onValidationError` call rather than firing one per file.
|
|
42
|
+
*/
|
|
43
|
+
export declare const useAttachmentValidation: ({ allowedMimeTypes, onValidationError, debounceMs, }: UseAttachmentValidationParams) => UseAttachmentValidationResult;
|
|
44
|
+
//# sourceMappingURL=useAttachmentValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachmentValidation.d.ts","sourceRoot":"","sources":["../../../src/attachment/useAttachmentValidation/useAttachmentValidation.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AAmCnC,sDAAsD;AACtD,oBAAY,+BAA+B;IACzC,4EAA4E;IAC5E,cAAc,mBAAmB;IACjC,yEAAyE;IACzE,eAAe,oBAAoB;CACpC;AAED,8GAA8G;AAC9G,MAAM,WAAW,8BAA8B;IAC7C,2CAA2C;IAC3C,MAAM,EAAE,+BAA+B,CAAC;IACxC,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,6HAA6H;IAC7H,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC5C,6DAA6D;IAC7D,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,+GAA+G;IAC/G,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,CAAC;IACpE,wGAAwG;IACxG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,uDAAuD;AACvD,MAAM,WAAW,6BAA6B;IAC5C,uGAAuG;IACvG,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,2DAA2D;IAC3D,oBAAoB,EAAE,OAAO,CAAC;IAC9B,+FAA+F;IAC/F,kBAAkB,EAAE,CAClB,UAAU,EAAE,UAAU,KACnB,qBAAqB,GAAG,SAAS,CAAC;IACvC,gHAAgH;IAChH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,sDAIrC,6BAA6B,KAAG,6BAqDlC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `worker` over `items` with at most `limit` concurrent invocations.
|
|
3
|
+
* Preserves no particular result order beyond "worker completed"; a worker
|
|
4
|
+
* that returns `undefined`, or throws, contributes nothing to the result
|
|
5
|
+
* array (used to skip failed/invalid items without aborting the whole
|
|
6
|
+
* batch) — a throwing worker is caught here so the other concurrent items
|
|
7
|
+
* keep being tracked instead of continuing unobserved in the background.
|
|
8
|
+
*/
|
|
9
|
+
export declare const runWithConcurrency: <T, R>(items: T[], limit: number, worker: (item: T) => Promise<R | undefined>) => Promise<R[]>;
|
|
10
|
+
//# sourceMappingURL=async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/async.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,CAAC,EAC3C,OAAO,CAAC,EAAE,EACV,OAAO,MAAM,EACb,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,KAC1C,OAAO,CAAC,CAAC,EAAE,CAqBb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Conversation } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** A unique DIAL file reference found in a conversation's messages. */
|
|
3
|
+
export interface AttachmentRef {
|
|
4
|
+
fileId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Collects unique attachment references across all messages. The same file
|
|
8
|
+
* can be attached to more than one message (e.g. re-shared in a later
|
|
9
|
+
* turn) — dedupe by `fileId` so it is only processed once.
|
|
10
|
+
*/
|
|
11
|
+
export declare const collectAttachmentRefs: (conversation: Conversation) => AttachmentRef[];
|
|
12
|
+
//# sourceMappingURL=attachment-refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-refs.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/attachment-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,KACzB,aAAa,EAWf,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `uploads/<YYYY-MM>/<safe-name>` upload path for a file.
|
|
3
|
+
* `date` defaults to now (regular attachment upload); conversation import
|
|
4
|
+
* passes a date fixed for the whole job so all its attachments land in the
|
|
5
|
+
* same month folder. Does not de-duplicate: a name collision is left for the
|
|
6
|
+
* upload call to reject (`create-only` mode) — use `createUploadPathAllocator`
|
|
7
|
+
* when collisions must be resolved with a ` (n)` suffix instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildUploadPath: (fileName: string, date?: Date) => string;
|
|
10
|
+
/** A file name the allocator has handed out, in the forms the caller needs. */
|
|
11
|
+
export interface AllocatedUploadPath {
|
|
12
|
+
/** Bucket-relative, percent-encoded upload path, e.g. `uploads/2026-08/report%20(1).pdf`. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Decoded name actually reserved, e.g. `report (1).pdf` — pass this as the uploaded `File`'s name. */
|
|
15
|
+
fileName: string;
|
|
16
|
+
/** Whether a ` (n)` suffix had to be appended because the requested name was taken. */
|
|
17
|
+
isRenamed: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Stateful allocator that hands out collision-free upload paths inside one month folder. */
|
|
20
|
+
export interface UploadPathAllocator {
|
|
21
|
+
/** Reserves the next free name derived from `fileName` and returns its upload path. */
|
|
22
|
+
allocate: (fileName: string) => AllocatedUploadPath;
|
|
23
|
+
/** Records `fileName` as taken — used when the server rejects a name the registry believed free. */
|
|
24
|
+
markTaken: (fileName: string) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates an allocator that assigns ` (1)`, ` (2)`, … suffixes to repeated or
|
|
28
|
+
* pre-existing file names so every allocation lands on a distinct path inside
|
|
29
|
+
* one `uploads/<YYYY-MM>/` folder. Mutation is deliberately confined to the
|
|
30
|
+
* private `Set` closed over here — an explicit, contained exception to the
|
|
31
|
+
* immutable-by-default rule, needed because collision-free naming is
|
|
32
|
+
* inherently a sequential, stateful decision.
|
|
33
|
+
*/
|
|
34
|
+
export declare const createUploadPathAllocator: (params?: {
|
|
35
|
+
/** Month folder to allocate into. Defaults to now. */
|
|
36
|
+
date?: Date;
|
|
37
|
+
/** Decoded names already present in the destination folder, e.g. from `listFiles`. */
|
|
38
|
+
existingNames?: Iterable<string>;
|
|
39
|
+
}) => UploadPathAllocator;
|
|
40
|
+
//# sourceMappingURL=build-upload-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-upload-path.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/build-upload-path.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,OAAM,IAAiB,KACtB,MAIF,CAAC;AAUF,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,uGAAuG;IACvG,QAAQ,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,6FAA6F;AAC7F,MAAM,WAAW,mBAAmB;IAClC,uFAAuF;IACvF,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,mBAAmB,CAAC;IACpD,oGAAoG;IACpG,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS;IACjD,sDAAsD;IACtD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,sFAAsF;IACtF,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAClC,KAAG,mBA4BH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Formats a `Date` as `YYYY-MM-DD` using its local-time components. */
|
|
2
|
+
export declare const formatDateYMD: (date: Date) => string;
|
|
3
|
+
/** Formats a `Date` as `YYYY-MM` using its local-time components. */
|
|
4
|
+
export declare const formatDateYM: (date: Date) => string;
|
|
5
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/date.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,KAAG,MAK1C,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,KAAG,MAIzC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the bucket and decoded relative path from a DIAL file ID
|
|
3
|
+
* (`files/{bucket}/{path}`). Returns `undefined` if the input does not start
|
|
4
|
+
* with `files/` or has no path segment after the bucket.
|
|
5
|
+
*/
|
|
6
|
+
export declare const resolveDialFileBucketAndPath: (fileId: string) => {
|
|
7
|
+
bucket: string;
|
|
8
|
+
path: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
//# sourceMappingURL=dial-file-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dial-file-resolve.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/dial-file-resolve.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,MAAM,KACb;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAcrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Conversation, ExportFolder, ExportFormat } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { ExportFileNameKind } from './types';
|
|
3
|
+
/** Placeholder app name used in every export file name — this branch has no app display-name config yet. */
|
|
4
|
+
export declare const EXPORT_APP_NAME = "ai_dial";
|
|
5
|
+
export declare const buildExportEnvelope: (conversations: Conversation[], folders?: ExportFolder[]) => ExportFormat;
|
|
6
|
+
export declare const serializeExportEnvelope: (envelope: ExportFormat) => Blob;
|
|
7
|
+
export declare const buildExportFileName: (kind: ExportFileNameKind, appName: string, date?: Date) => string;
|
|
8
|
+
//# sourceMappingURL=export-conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/export-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,4GAA4G;AAC5G,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC,eAAO,MAAM,mBAAmB,GAC9B,eAAe,YAAY,EAAE,EAC7B,UAAS,YAAY,EAAO,KAC3B,YAID,CAAC;AAEH,eAAO,MAAM,uBAAuB,GAAI,UAAU,YAAY,KAAG,IACY,CAAC;AAQ9E,eAAO,MAAM,mBAAmB,GAC9B,MAAM,kBAAkB,EACxB,SAAS,MAAM,EACf,OAAM,IAAiB,KACtB,MACyE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Conversation, ExportFormat } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { AllocatedUploadPath, UploadPathAllocator } from './build-upload-path';
|
|
3
|
+
/** Thrown when an imported file cannot be parsed as a supported export envelope. */
|
|
4
|
+
export declare class UnsupportedImportFormatError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses raw file text into a supported export envelope (`version: 5`) with
|
|
9
|
+
* an array `history` — conversations are returned unmodified.
|
|
10
|
+
* Throws `UnsupportedImportFormatError` for malformed JSON or any other shape.
|
|
11
|
+
*/
|
|
12
|
+
export declare const parseImportEnvelope: (text: string) => ExportFormat;
|
|
13
|
+
export interface RebasedConversationId {
|
|
14
|
+
/** The conversation with `id`/`folderId` rebased to `bucket` and a fresh UUID. */
|
|
15
|
+
conversation: Conversation;
|
|
16
|
+
/** Bucket-relative path to pass to `saveConversation`. */
|
|
17
|
+
subPath: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Rebases a conversation's id/folderId to the current user's bucket and
|
|
21
|
+
* regenerates its trailing UUID segment, so importing it can never collide
|
|
22
|
+
* with an existing conversation and needs no replace/skip dialog. Folder
|
|
23
|
+
* path segments between the bucket and the filename are preserved (not
|
|
24
|
+
* flattened) — the new chat currently displays everything at the root, but
|
|
25
|
+
* the conversation keeps its original folder location for when the folder
|
|
26
|
+
* feature ships.
|
|
27
|
+
*/
|
|
28
|
+
export declare const rebaseConversationId: (conversation: Conversation, bucket: string) => RebasedConversationId;
|
|
29
|
+
/**
|
|
30
|
+
* Derives the queue row's secondary breadcrumb line from a conversation's
|
|
31
|
+
* source `folderId` (`{bucket}[/<folder>/...]`) — the segments after the
|
|
32
|
+
* leading bucket, joined with " / ". Returns `undefined` for a root
|
|
33
|
+
* conversation (no folder segments).
|
|
34
|
+
*/
|
|
35
|
+
export declare const getFolderBreadcrumb: (conversation: Conversation) => string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Formats a list of names for the aggregate success/failure notifications,
|
|
38
|
+
* each individually quoted and comma-separated (e.g. `"A", "B", "C"`) so the
|
|
39
|
+
* i18n template only needs to append the trailing verb phrase.
|
|
40
|
+
*/
|
|
41
|
+
export declare const formatQuotedNameList: (names: string[]) => string;
|
|
42
|
+
/** New location — and, when the import renamed it, new display name — for an imported attachment. */
|
|
43
|
+
export interface RewrittenAttachmentTarget {
|
|
44
|
+
/** New `files/{bucket}/{path}` id to write into `url`/`reference_url`. */
|
|
45
|
+
url: string;
|
|
46
|
+
/** New display name — present only when a ` (n)` disambiguation suffix was applied. */
|
|
47
|
+
title?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Rewrites every message's attachment `url`/`reference_url` referencing an
|
|
51
|
+
* old file id to its new uploaded location, and its `title` when the target
|
|
52
|
+
* carries a renamed one. Attachments not present in `targetMap` are left
|
|
53
|
+
* untouched (immutable — returns a new conversation).
|
|
54
|
+
*/
|
|
55
|
+
export declare const rewriteAttachmentUrls: (conversation: Conversation, targetMap: Map<string, RewrittenAttachmentTarget>) => Conversation;
|
|
56
|
+
/** Best-effort display name for a fileId that failed to resolve to a `{bucket, path}` pair. */
|
|
57
|
+
export declare const fileIdDisplayName: (fileId: string) => string;
|
|
58
|
+
/** One attachment reference planned for upload, with its collision-free destination already allocated. */
|
|
59
|
+
export interface PlannedAttachmentUpload {
|
|
60
|
+
/** Original DIAL file id this attachment is uploaded from — the key `rewriteAttachmentUrls` rewrites. */
|
|
61
|
+
fileId: string;
|
|
62
|
+
/** Raw bytes read from the archive. */
|
|
63
|
+
bytes: Uint8Array;
|
|
64
|
+
/** Basename a 409 retry re-derives its next attempt from (never the already-suffixed name). */
|
|
65
|
+
originalFileName: string;
|
|
66
|
+
/** Destination allocated for the first upload attempt. */
|
|
67
|
+
allocated: AllocatedUploadPath;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolves a conversation's unique attachment references to archive bytes
|
|
71
|
+
* and allocates each a collision-free upload destination, in
|
|
72
|
+
* `collectAttachmentRefs` order — a synchronous pre-pass so suffix
|
|
73
|
+
* assignment stays deterministic regardless of later upload concurrency.
|
|
74
|
+
* A reference that cannot be resolved to a `{bucket, path}` pair, or has no
|
|
75
|
+
* matching bytes in the archive, is reported in `skippedNames` and does not
|
|
76
|
+
* consume an allocator slot.
|
|
77
|
+
*/
|
|
78
|
+
export declare const planAttachmentUploads: (conversation: Conversation, attachmentBytes: Map<string, Uint8Array>, allocator: UploadPathAllocator) => {
|
|
79
|
+
plan: PlannedAttachmentUpload[];
|
|
80
|
+
skippedNames: string[];
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=import-conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-conversation.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/import-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,oFAAoF;AACpF,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAOD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,YA2BlD,CAAC;AAeF,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,YAAY,EAAE,YAAY,CAAC;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;CACjB;AAgBD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,YAAY,EAC1B,QAAQ,MAAM,KACb,qBA6CF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,cAAc,YAAY,KACzB,MAAM,GAAG,SAMX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,EAAE,KAAG,MACV,CAAC;AAE9C,qGAAqG;AACrG,MAAM,WAAW,yBAAyB;IACxC,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,EAC1B,WAAW,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,KAChD,YAgCD,CAAC;AAEH,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAChB,CAAC;AAEpC,0GAA0G;AAC1G,MAAM,WAAW,uBAAuB;IACtC,yGAAyG;IACzG,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,EAAE,UAAU,CAAC;IAClB,+FAA+F;IAC/F,gBAAgB,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,SAAS,EAAE,mBAAmB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,EAC1B,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACxC,WAAW,mBAAmB,KAC7B;IAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CA2B3D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConversationTransferJob, ConversationTransferSubject } from './types';
|
|
2
|
+
/** Shared job-queue primitive underlying both `useConversationExport` and `useConversationImport`. */
|
|
3
|
+
export interface ConversationTransferQueue {
|
|
4
|
+
/** Queued jobs, most recently added last. */
|
|
5
|
+
jobs: ConversationTransferJob[];
|
|
6
|
+
/** Adds a new `InProgress` job for `subject` and returns its id. */
|
|
7
|
+
addJob: (subject: ConversationTransferSubject) => string;
|
|
8
|
+
/** Merges `patch` into the job identified by `jobId`. */
|
|
9
|
+
updateJob: (jobId: string, patch: Partial<ConversationTransferJob>) => void;
|
|
10
|
+
/** Aborts the job's in-flight request (if any) and removes it from `jobs`. */
|
|
11
|
+
dismissJob: (jobId: string) => void;
|
|
12
|
+
/** Re-invokes the job's registered run function under a fresh `AbortController`. */
|
|
13
|
+
retryJob: (jobId: string) => void;
|
|
14
|
+
/** Aborts every in-flight job and clears the queue. */
|
|
15
|
+
dismissAll: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Runs `run` under a fresh `AbortController` registered for `jobId`, and
|
|
18
|
+
* registers the same `run` function to be re-invoked (under a new
|
|
19
|
+
* controller) on `retryJob`.
|
|
20
|
+
*/
|
|
21
|
+
startJob: (jobId: string, run: (signal: AbortSignal) => Promise<void>) => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Owns the export/import job queue: job list state, per-job
|
|
25
|
+
* `AbortController` tracking, retry-function registration, and
|
|
26
|
+
* unmount cleanup. Shared by `useConversationExport` and
|
|
27
|
+
* `useConversationImport` so both hooks have identical cancellation,
|
|
28
|
+
* retry, and dismissal semantics.
|
|
29
|
+
*/
|
|
30
|
+
export declare const useConversationTransferQueue: () => ConversationTransferQueue;
|
|
31
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/queue.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EACjC,MAAM,SAAS,CAAC;AAEjB,sGAAsG;AACtG,MAAM,WAAW,yBAAyB;IACxC,6CAA6C;IAC7C,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAChC,oEAAoE;IACpE,MAAM,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,MAAM,CAAC;IACzD,yDAAyD;IACzD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;IAC5E,8EAA8E;IAC9E,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,oFAAoF;IACpF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uDAAuD;IACvD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;;;OAIG;IACH,QAAQ,EAAE,CACR,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,KACxC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,QAAO,yBAgF/C,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Whether an export includes the conversation's attachments. */
|
|
2
|
+
export declare enum ConversationExportMode {
|
|
3
|
+
WithAttachments = "withAttachments",
|
|
4
|
+
WithoutAttachments = "withoutAttachments"
|
|
5
|
+
}
|
|
6
|
+
/** Which export file was produced, used to derive its file name/extension. */
|
|
7
|
+
export declare enum ExportFileNameKind {
|
|
8
|
+
SingleConversation = "chat_conversation",
|
|
9
|
+
SingleConversationWithAttachments = "chat_with_attachments",
|
|
10
|
+
AllConversationsHistory = "chat_conversations_history"
|
|
11
|
+
}
|
|
12
|
+
/** Lifecycle status of a queued export/import job. */
|
|
13
|
+
export declare enum ConversationTransferJobStatus {
|
|
14
|
+
InProgress = "inProgress",
|
|
15
|
+
Success = "success",
|
|
16
|
+
Failed = "failed"
|
|
17
|
+
}
|
|
18
|
+
/** Whether a transfer job's subject is a single named conversation or the whole history. */
|
|
19
|
+
export declare enum ConversationTransferSubjectKind {
|
|
20
|
+
Single = "single",
|
|
21
|
+
All = "all"
|
|
22
|
+
}
|
|
23
|
+
/** What a transfer job operates on — structured data, never pre-rendered translated text. */
|
|
24
|
+
export type ConversationTransferSubject = {
|
|
25
|
+
kind: ConversationTransferSubjectKind.Single;
|
|
26
|
+
/** The conversation's own name. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** Folder breadcrumb the conversation originated from, if nested. */
|
|
29
|
+
sourceBreadcrumb?: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: ConversationTransferSubjectKind.All;
|
|
32
|
+
};
|
|
33
|
+
/** A queued export or import job. */
|
|
34
|
+
export interface ConversationTransferJob {
|
|
35
|
+
id: string;
|
|
36
|
+
subject: ConversationTransferSubject;
|
|
37
|
+
status: ConversationTransferJobStatus;
|
|
38
|
+
}
|
|
39
|
+
/** Library-owned reason a transfer job failed. */
|
|
40
|
+
export declare enum ConversationTransferErrorCode {
|
|
41
|
+
Unauthorized = "unauthorized",
|
|
42
|
+
NotFound = "notFound",
|
|
43
|
+
UnsupportedFormat = "unsupportedFormat",
|
|
44
|
+
MissingBucket = "missingBucket",
|
|
45
|
+
Unknown = "unknown"
|
|
46
|
+
}
|
|
47
|
+
/** Structured, translation-free error report for a transfer job. */
|
|
48
|
+
export interface ConversationTransferErrorEvent {
|
|
49
|
+
jobId: string;
|
|
50
|
+
code: ConversationTransferErrorCode;
|
|
51
|
+
/** Conversation title(s) relevant to the error, when applicable. */
|
|
52
|
+
titles?: string[];
|
|
53
|
+
/** Resolved trace id for the failing request, when the host's `resolveErrorTraceId` supplies one. */
|
|
54
|
+
traceId?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Library-owned reason a transfer job reports a non-fatal warning. */
|
|
57
|
+
export declare enum ConversationTransferWarningCode {
|
|
58
|
+
AttachmentSkipped = "attachmentSkipped"
|
|
59
|
+
}
|
|
60
|
+
/** Structured, translation-free warning report for a transfer job. */
|
|
61
|
+
export interface ConversationTransferWarningEvent {
|
|
62
|
+
jobId: string;
|
|
63
|
+
code: ConversationTransferWarningCode;
|
|
64
|
+
/** Names relevant to the warning (e.g. skipped attachment file names). */
|
|
65
|
+
names?: string[];
|
|
66
|
+
}
|
|
67
|
+
/** Structured, translation-free success report for a transfer job. */
|
|
68
|
+
export interface ConversationTransferSuccessEvent {
|
|
69
|
+
jobId: string;
|
|
70
|
+
/** Conversation title(s) affected, when applicable. */
|
|
71
|
+
titles?: string[];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/types.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,oBAAY,sBAAsB;IAChC,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;CAC1C;AAED,8EAA8E;AAC9E,oBAAY,kBAAkB;IAC5B,kBAAkB,sBAAsB;IACxC,iCAAiC,0BAA0B;IAC3D,uBAAuB,+BAA+B;CACvD;AAED,sDAAsD;AACtD,oBAAY,6BAA6B;IACvC,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,4FAA4F;AAC5F,oBAAY,+BAA+B;IACzC,MAAM,WAAW;IACjB,GAAG,QAAQ;CACZ;AAED,6FAA6F;AAC7F,MAAM,MAAM,2BAA2B,GACnC;IACE,IAAI,EAAE,+BAA+B,CAAC,MAAM,CAAC;IAC7C,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACD;IAAE,IAAI,EAAE,+BAA+B,CAAC,GAAG,CAAA;CAAE,CAAC;AAElD,qCAAqC;AACrC,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,2BAA2B,CAAC;IACrC,MAAM,EAAE,6BAA6B,CAAC;CACvC;AAED,kDAAkD;AAClD,oBAAY,6BAA6B;IACvC,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,OAAO,YAAY;CACpB;AAED,oEAAoE;AACpE,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,6BAA6B,CAAC;IACpC,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,uEAAuE;AACvE,oBAAY,+BAA+B;IACzC,iBAAiB,sBAAsB;CACxC;AAED,sEAAsE;AACtE,MAAM,WAAW,gCAAgC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,+BAA+B,CAAC;IACtC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,gCAAgC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ExportFormat } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Validates an attachment path before it is written into (or read from) a
|
|
4
|
+
* `.dial` archive. Blocks path traversal and absolute paths by rejecting
|
|
5
|
+
* empty, `.`, or `..` path segments (so `../../etc/passwd` and `/etc/passwd`
|
|
6
|
+
* are both rejected). No character allowlist — real-world filenames
|
|
7
|
+
* routinely contain spaces, parentheses, and non-ASCII characters, and any
|
|
8
|
+
* character that would be unsafe in the eventual upload URL is already
|
|
9
|
+
* percent-encoded downstream by `buildUploadPath`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isValidArchivePath: (path: string) => boolean;
|
|
12
|
+
/** A single attachment already fetched into memory, ready to be written into the archive. */
|
|
13
|
+
export interface ZipAttachmentEntry {
|
|
14
|
+
/** Relative path under which the attachment is stored, e.g. `reports/q1.pdf`. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Attachment content. */
|
|
17
|
+
data: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export interface BuildDialArchiveResult {
|
|
20
|
+
/** The built `.dial` archive. */
|
|
21
|
+
blob: Blob;
|
|
22
|
+
/** Attachment paths that failed validation and were not written to the archive. */
|
|
23
|
+
skippedPaths: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Builds a `.dial` ZIP archive containing the conversation export envelope
|
|
27
|
+
* plus every valid attachment, laid out under `res/<path>`. Attachments
|
|
28
|
+
* failing the path allowlist are skipped and reported in `skippedPaths`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const buildDialArchive: (envelope: ExportFormat, attachments: ZipAttachmentEntry[]) => BuildDialArchiveResult;
|
|
31
|
+
//# sourceMappingURL=zip-export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-export.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/zip-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAY9D;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,OAI4B,CAAC;AAE/E,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,iCAAiC;IACjC,IAAI,EAAE,IAAI,CAAC;IACX,mFAAmF;IACnF,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,YAAY,EACtB,aAAa,kBAAkB,EAAE,KAChC,sBAqBF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExportFormat } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
export interface ParsedDialArchive {
|
|
3
|
+
/** The parsed and validated export envelope. */
|
|
4
|
+
envelope: ExportFormat;
|
|
5
|
+
/** Attachment bytes keyed by their bucket-relative path (the `res/<path>` suffix). */
|
|
6
|
+
attachments: Map<string, Uint8Array>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parses a `.dial`/`.zip` archive produced by either the new-chat export
|
|
10
|
+
* (`conversation.json` at the archive root) or the old (`development`
|
|
11
|
+
* branch) export (`conversations/<name>.json`) — the JSON entry name is
|
|
12
|
+
* detected tolerantly by its archive path, since both old-chat and new-chat
|
|
13
|
+
* archives write the same `version: 5` envelope. Attachment bytes are
|
|
14
|
+
* collected from `res/<path>` entries, keyed by their validated relative path.
|
|
15
|
+
*/
|
|
16
|
+
export declare const parseDialArchive: (file: File) => Promise<ParsedDialArchive>;
|
|
17
|
+
//# sourceMappingURL=zip-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-import.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-transfer/zip-import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAe9D,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,QAAQ,EAAE,YAAY,CAAC;IACvB,sFAAsF;IACtF,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAqBD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,IAAI,KACT,OAAO,CAAC,iBAAiB,CAiC3B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ConversationsApi, FilesApi } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { ConversationExportMode, ConversationTransferErrorEvent, ConversationTransferJob, ConversationTransferSuccessEvent, ConversationTransferWarningEvent } from '../conversation-transfer/types';
|
|
3
|
+
interface ExportErrorClassification {
|
|
4
|
+
isUnauthorized?: boolean;
|
|
5
|
+
isNotFound?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Parameters for {@link useConversationExport}. */
|
|
8
|
+
export interface UseConversationExportParams {
|
|
9
|
+
/** Already-configured generated-client instance used to read conversations. */
|
|
10
|
+
conversationsApi: Pick<ConversationsApi, 'getConversation' | 'listConversations'>;
|
|
11
|
+
/** Already-configured generated-client instance used to download attachments. */
|
|
12
|
+
filesApi: Pick<FilesApi, 'downloadFileRaw'>;
|
|
13
|
+
/** Resolves a conversation id to the bucket-qualified path `getConversation` expects. */
|
|
14
|
+
normalizeConversationPath: (conversationId: string) => string;
|
|
15
|
+
/** Classifies a thrown error as unauthorized/not-found. Host-owned error taxonomy; defaults to neither. */
|
|
16
|
+
classifyTransferError?: (error: unknown) => ExportErrorClassification;
|
|
17
|
+
/** Resolves a trace id for a failing request, for display in an error notification. */
|
|
18
|
+
resolveErrorTraceId?: (error: unknown) => Promise<string | undefined>;
|
|
19
|
+
/** Called when a job completes successfully. */
|
|
20
|
+
onSuccess?: (event: ConversationTransferSuccessEvent) => void;
|
|
21
|
+
/** Called when a job succeeds but had to skip something (e.g. an unreachable attachment). */
|
|
22
|
+
onWarning?: (event: ConversationTransferWarningEvent) => void;
|
|
23
|
+
/** Called when a job fails. */
|
|
24
|
+
onError?: (event: ConversationTransferErrorEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
/** Return value of {@link useConversationExport}. */
|
|
27
|
+
export interface UseConversationExportResult {
|
|
28
|
+
/** Export jobs, most recently added last. Multiple jobs can be in progress concurrently. */
|
|
29
|
+
jobs: ConversationTransferJob[];
|
|
30
|
+
/** Enqueues a single-conversation export job and starts it immediately. */
|
|
31
|
+
exportSingle: (conversationId: string, title: string, mode: ConversationExportMode) => Promise<void>;
|
|
32
|
+
/** Enqueues an export-all job and starts it immediately. */
|
|
33
|
+
exportAll: () => Promise<void>;
|
|
34
|
+
/** Removes a job from the queue. If still in progress, aborts its underlying requests. */
|
|
35
|
+
dismissJob: (jobId: string) => void;
|
|
36
|
+
/** Re-attempts a failed job in place (same job id, same parameters). */
|
|
37
|
+
retryJob: (jobId: string) => void;
|
|
38
|
+
/** Aborts all in-progress jobs and clears the entire queue. */
|
|
39
|
+
dismissAll: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Owns the export job queue: fetches conversation data through the injected
|
|
43
|
+
* generated-client operations, builds the JSON v5 / ZIP output via the pure
|
|
44
|
+
* export utils, reports structured success/warning/error events, and tracks
|
|
45
|
+
* each job's lifecycle (in progress / success / failed) independently so
|
|
46
|
+
* multiple exports can run concurrently.
|
|
47
|
+
*/
|
|
48
|
+
export declare const useConversationExport: ({ conversationsApi, filesApi, normalizeConversationPath, classifyTransferError, resolveErrorTraceId, onSuccess, onWarning, onError, }: UseConversationExportParams) => UseConversationExportResult;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=useConversationExport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConversationExport.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationExport/useConversationExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,QAAQ,EACT,MAAM,+BAA+B,CAAC;AAmBvC,OAAO,EACL,sBAAsB,EAMtB,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EACtC,MAAM,gCAAgC,CAAC;AASxC,UAAU,yBAAyB;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAUD,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,gBAAgB,EAAE,IAAI,CACpB,gBAAgB,EAChB,iBAAiB,GAAG,mBAAmB,CACxC,CAAC;IACF,iFAAiF;IACjF,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC5C,yFAAyF;IACzF,yBAAyB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9D,2GAA2G;IAC3G,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,yBAAyB,CAAC;IACtE,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACtE,gDAAgD;IAChD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC9D,6FAA6F;IAC7F,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC9D,+BAA+B;IAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,CAAC;CAC3D;AAED,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC1C,4FAA4F;IAC5F,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAChC,2EAA2E;IAC3E,YAAY,EAAE,CACZ,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,sBAAsB,KACzB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,0FAA0F;IAC1F,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,wEAAwE;IACxE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,+DAA+D;IAC/D,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,uIASnC,2BAA2B,KAAG,2BAkVhC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AttachmentDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { Attachment } from '@epam/ai-dial-chat-shared';
|
|
3
|
+
/** Maps an already-uploaded attachment to its DTO shape. Throws if the attachment has no `url` yet. */
|
|
4
|
+
export declare const attachmentToDto: (attachment: Attachment) => AttachmentDto;
|
|
5
|
+
/** Maps a list of already-uploaded attachments to DTOs, or `undefined` when the list is empty. */
|
|
6
|
+
export declare const attachmentsToDtos: (attachments: Attachment[]) => AttachmentDto[] | undefined;
|
|
7
|
+
//# sourceMappingURL=attachment-to-dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-to-dto.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationHandlers/attachment-to-dto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAAI,YAAY,UAAU,KAAG,aAUxD,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,GAC5B,aAAa,UAAU,EAAE,KACxB,aAAa,EAAE,GAAG,SAGpB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Message, MessageCustomContent } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** A newly-created user message paired with its empty assistant placeholder. */
|
|
3
|
+
export interface MessagePair {
|
|
4
|
+
userMessage: Message;
|
|
5
|
+
assistantMessage: Message;
|
|
6
|
+
}
|
|
7
|
+
/** Builds a user message and its empty assistant placeholder, both timestamped `now`. */
|
|
8
|
+
export declare const createMessagePair: (content: string, customContent?: MessageCustomContent, deploymentId?: string | null) => MessagePair;
|
|
9
|
+
//# sourceMappingURL=message-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-factory.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationHandlers/message-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,oBAAoB,EAE1B,MAAM,2BAA2B,CAAC;AAEnC,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,yFAAyF;AACzF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,gBAAgB,oBAAoB,EACpC,eAAe,MAAM,GAAG,IAAI,KAC3B,WAoBF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Attachment, DisplayAttachment, Message } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** Whether at least one tool toggle in `value` is active. */
|
|
3
|
+
export declare const hasActiveToolConfig: (value: Record<string, boolean> | undefined) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Returns `true` when the edited text or attachment list differs from the
|
|
6
|
+
* original message, meaning a regeneration is needed.
|
|
7
|
+
*
|
|
8
|
+
* @param originalMessage - The unmodified message stored in the conversation.
|
|
9
|
+
* @param newText - The text the user submitted from the edit area.
|
|
10
|
+
* @param keptDisplayAttachments - Attachments the user kept (not removed).
|
|
11
|
+
* @param newAttachments - Brand-new attachments the user added during editing.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isMessageChanged: (originalMessage: Message, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => boolean;
|
|
14
|
+
//# sourceMappingURL=message-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-utils.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationHandlers/message-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,OAAO,EACR,MAAM,2BAA2B,CAAC;AAEnC,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,KACzC,OAAyD,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,OAAO,EACxB,SAAS,MAAM,EACf,wBAAwB,iBAAiB,EAAE,EAC3C,gBAAgB,UAAU,EAAE,KAC3B,OAMF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StarterOption } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the text to start/populate a conversation from a selected starter button.
|
|
4
|
+
* `description` (the schema property's shared intro/question text) is used only
|
|
5
|
+
* as a fallback when the starter's own `populateText` is explicitly `null` — it
|
|
6
|
+
* must never override a starter's own configured prompt.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getStarterConversationText: (starter: StarterOption, description?: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Returns submitted text for DIAL starter/form buttons.
|
|
11
|
+
* For submit buttons, `populateText: null` explicitly means "submit no text".
|
|
12
|
+
*/
|
|
13
|
+
export declare const getStarterSubmitText: (starter: StarterOption, description?: string) => string;
|
|
14
|
+
//# sourceMappingURL=starter-option.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starter-option.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationHandlers/starter-option.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAe/D;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,SAAS,aAAa,EACtB,cAAc,MAAM,KACnB,MAQF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,aAAa,EACtB,cAAc,MAAM,KACnB,MAQF,CAAC"}
|