@epam/ai-dial-chat-hooks 1.3.0-dev.252 → 1.3.0-dev.256
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/deployment-id.d.ts +6 -0
- package/catalog/deployment-id.d.ts.map +1 -1
- package/catalog/deployment-id.js +12 -2
- package/catalog/map-deployment-to-catalog-item.d.ts +4 -1
- package/catalog/map-deployment-to-catalog-item.d.ts.map +1 -1
- package/catalog/map-deployment-to-catalog-item.js +10 -10
- package/catalog.js +23 -23
- package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -1
- package/conversation/useConversationStream/useConversationStream.js +3 -1
- package/entry-points/project.d.ts +10 -0
- package/entry-points/project.d.ts.map +1 -0
- package/index.d.ts +9 -0
- package/index.d.ts.map +1 -1
- package/index.js +177 -168
- package/package.json +25 -16
- package/project/project-form-errors.d.ts +23 -0
- package/project/project-form-errors.d.ts.map +1 -0
- package/project/project-form-errors.js +46 -0
- package/project/project-limits.d.ts +17 -0
- package/project/project-limits.d.ts.map +1 -0
- package/project/project-limits.js +11 -0
- package/project/project-mapping.d.ts +11 -0
- package/project/project-mapping.d.ts.map +1 -0
- package/project/project-mapping.js +36 -0
- package/project/projects-api-client.d.ts +157 -0
- package/project/projects-api-client.d.ts.map +1 -0
- package/project/projects-api-client.js +81 -0
- package/project/use-project-actions.d.ts +49 -0
- package/project/use-project-actions.d.ts.map +1 -0
- package/project/use-project-actions.js +102 -0
- package/project/use-project-conversations.d.ts +27 -0
- package/project/use-project-conversations.d.ts.map +1 -0
- package/project/use-project-conversations.js +109 -0
- package/project/use-project-submit.d.ts +49 -0
- package/project/use-project-submit.d.ts.map +1 -0
- package/project/use-project-submit.js +73 -0
- package/project/use-project.d.ts +20 -0
- package/project/use-project.d.ts.map +1 -0
- package/project/use-project.js +48 -0
- package/project/use-projects.d.ts +19 -0
- package/project/use-projects.d.ts.map +1 -0
- package/project/use-projects.js +46 -0
- package/project.d.ts +2 -0
- package/project.js +10 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Why the BFF rejected a project create or edit, as the form explains it. */
|
|
2
|
+
export declare enum ProjectFormErrorReason {
|
|
3
|
+
NameTaken = "name-taken",
|
|
4
|
+
NameInvalid = "name-invalid",
|
|
5
|
+
TooManyFiles = "too-many-files",
|
|
6
|
+
FilesRejected = "files-rejected",
|
|
7
|
+
UnknownFile = "unknown-file"
|
|
8
|
+
}
|
|
9
|
+
/** The project form field a rejection belongs to. */
|
|
10
|
+
export declare enum ProjectFormErrorField {
|
|
11
|
+
Name = "name",
|
|
12
|
+
Context = "context"
|
|
13
|
+
}
|
|
14
|
+
/** Where a rejected create or edit request's message goes on the project form. */
|
|
15
|
+
export interface ProjectFormError {
|
|
16
|
+
/** Field the message is shown under. */
|
|
17
|
+
field: ProjectFormErrorField;
|
|
18
|
+
/** Why the request was rejected; the host resolves the message. */
|
|
19
|
+
reason: ProjectFormErrorReason;
|
|
20
|
+
}
|
|
21
|
+
/** Returns the form field and reason a `ProjectCreateErrorCode` maps to, or `null` when the rejection belongs in a toast. */
|
|
22
|
+
export declare const getProjectFormError: (code: string | undefined) => ProjectFormError | null;
|
|
23
|
+
//# sourceMappingURL=project-form-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-form-errors.d.ts","sourceRoot":"","sources":["../../src/project/project-form-errors.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,oBAAY,sBAAsB;IAChC,SAAS,eAAe;IACxB,WAAW,iBAAiB;IAC5B,YAAY,mBAAmB;IAC/B,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,qDAAqD;AACrD,oBAAY,qBAAqB;IAC/B,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,mEAAmE;IACnE,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAyCD,6HAA6H;AAC7H,eAAO,MAAM,mBAAmB,GAC9B,MAAM,MAAM,GAAG,SAAS,KACvB,gBAAgB,GAAG,IACmC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ProjectCreateErrorCode as e } from "@epam/ai-dial-chat-api-client";
|
|
2
|
+
//#region src/project/project-form-errors.ts
|
|
3
|
+
var t = /* @__PURE__ */ function(e) {
|
|
4
|
+
return e.NameTaken = "name-taken", e.NameInvalid = "name-invalid", e.TooManyFiles = "too-many-files", e.FilesRejected = "files-rejected", e.UnknownFile = "unknown-file", e;
|
|
5
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
6
|
+
return e.Name = "name", e.Context = "context", e;
|
|
7
|
+
}({}), r = {
|
|
8
|
+
[e.NameTaken]: {
|
|
9
|
+
field: "name",
|
|
10
|
+
reason: "name-taken"
|
|
11
|
+
},
|
|
12
|
+
[e.InvalidName]: {
|
|
13
|
+
field: "name",
|
|
14
|
+
reason: "name-invalid"
|
|
15
|
+
},
|
|
16
|
+
[e.TooManyFiles]: {
|
|
17
|
+
field: "context",
|
|
18
|
+
reason: "too-many-files"
|
|
19
|
+
},
|
|
20
|
+
[e.UnsupportedFileType]: {
|
|
21
|
+
field: "context",
|
|
22
|
+
reason: "files-rejected"
|
|
23
|
+
},
|
|
24
|
+
[e.FileTooLarge]: {
|
|
25
|
+
field: "context",
|
|
26
|
+
reason: "files-rejected"
|
|
27
|
+
},
|
|
28
|
+
[e.CapacityExceeded]: {
|
|
29
|
+
field: "context",
|
|
30
|
+
reason: "files-rejected"
|
|
31
|
+
},
|
|
32
|
+
[e.InvalidFileName]: {
|
|
33
|
+
field: "context",
|
|
34
|
+
reason: "files-rejected"
|
|
35
|
+
},
|
|
36
|
+
[e.DuplicateFileName]: {
|
|
37
|
+
field: "context",
|
|
38
|
+
reason: "files-rejected"
|
|
39
|
+
},
|
|
40
|
+
[e.UnknownFile]: {
|
|
41
|
+
field: "context",
|
|
42
|
+
reason: "unknown-file"
|
|
43
|
+
}
|
|
44
|
+
}, i = (e) => (e == null ? void 0 : r[e]) ?? null;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { n as ProjectFormErrorField, t as ProjectFormErrorReason, i as getProjectFormError };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Defaults matching the BFF's `PROJECT_CONTEXT_*` defaults, used before the client config loads. */
|
|
2
|
+
export declare const DEFAULT_PROJECT_CONTEXT_FILE_MAX_BYTES = 1048576;
|
|
3
|
+
export declare const DEFAULT_PROJECT_CONTEXT_TOTAL_MAX_BYTES = 10485760;
|
|
4
|
+
export declare const DEFAULT_PROJECT_CONTEXT_ALLOWED_EXTENSIONS: string[];
|
|
5
|
+
/** Returns `value` when it is a positive finite number, otherwise `fallback`. */
|
|
6
|
+
export declare const resolveByteLimit: (value: unknown, fallback: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* Returns `value` lower-cased when it is a non-empty array of non-empty
|
|
9
|
+
* strings, otherwise `fallback`. An older BFF omits the field entirely.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolveExtensionList: (value: unknown, fallback: string[]) => string[];
|
|
12
|
+
/**
|
|
13
|
+
* Returns every MIME type `MIME_TYPE_EXT_MAP` maps to one of `extensions`,
|
|
14
|
+
* for the file manager's MIME-based `allowedTypes` filter.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getMimeTypesForExtensions: (extensions: string[], mimeTypeExtensions: Record<string, string>) => string[];
|
|
17
|
+
//# sourceMappingURL=project-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-limits.d.ts","sourceRoot":"","sources":["../../src/project/project-limits.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,eAAO,MAAM,sCAAsC,UAAY,CAAC;AAChE,eAAO,MAAM,uCAAuC,WAAa,CAAC;AAClE,eAAO,MAAM,0CAA0C,UAItD,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,UAAU,MAAM,KAAG,MAGtD,CAAC;AAEf;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,OAAO,EACd,UAAU,MAAM,EAAE,KACjB,MAAM,EAKK,CAAC;AAEf;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GACpC,YAAY,MAAM,EAAE,EACpB,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACzC,MAAM,EAOR,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/project/project-limits.ts
|
|
2
|
+
var e = 1048576, t = 10485760, n = [
|
|
3
|
+
"csv",
|
|
4
|
+
"pdf",
|
|
5
|
+
"xlsx"
|
|
6
|
+
], r = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, i = (e, t) => Array.isArray(e) && e.length > 0 && e.every((e) => typeof e == "string" && e.length > 0) ? e.map((e) => e.toLowerCase()) : t, a = (e, t) => {
|
|
7
|
+
let n = new Set(e.map((e) => e.toLowerCase()));
|
|
8
|
+
return Object.entries(t).filter(([, e]) => n.has(e)).map(([e]) => e);
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as DEFAULT_PROJECT_CONTEXT_ALLOWED_EXTENSIONS, e as DEFAULT_PROJECT_CONTEXT_FILE_MAX_BYTES, t as DEFAULT_PROJECT_CONTEXT_TOTAL_MAX_BYTES, a as getMimeTypesForExtensions, r as resolveByteLimit, i as resolveExtensionList };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProjectSource as ProjectSourceDto, ProjectDetailsDto, ProjectDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { ProjectItem, ProjectSource, ProjectViewModel, StoredProjectContextFile } from '@epam/ai-dial-projects';
|
|
3
|
+
/** Maps a BFF project source onto the Projects lib's source. */
|
|
4
|
+
export declare const mapProjectSource: (source: ProjectSourceDto) => ProjectSource;
|
|
5
|
+
/** Maps a BFF project to the card item the Projects lib renders; the sort date falls back to the creation time. */
|
|
6
|
+
export declare const mapProjectDtoToItem: (project: ProjectDto) => ProjectItem;
|
|
7
|
+
/** Maps a project's BFF details to the content the project view renders; content types come from the file names. */
|
|
8
|
+
export declare const mapProjectDetailsToViewModel: (project: ProjectDetailsDto) => ProjectViewModel;
|
|
9
|
+
/** Maps a project's stored context files to the cards the project form renders; ids are `stored:{name}`. */
|
|
10
|
+
export declare const mapStoredContextFiles: (project: ProjectDetailsDto) => StoredProjectContextFile[];
|
|
11
|
+
//# sourceMappingURL=project-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-mapping.d.ts","sourceRoot":"","sources":["../../src/project/project-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EACL,KAAK,WAAW,EAChB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAchC,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,GAAI,QAAQ,gBAAgB,KAAG,aACnC,CAAC;AAE1B,mHAAmH;AACnH,eAAO,MAAM,mBAAmB,GAAI,SAAS,UAAU,KAAG,WAMxD,CAAC;AAEH,oHAAoH;AACpH,eAAO,MAAM,4BAA4B,GACvC,SAAS,iBAAiB,KACzB,gBAQD,CAAC;AAEH,4GAA4G;AAC5G,eAAO,MAAM,qBAAqB,GAChC,SAAS,iBAAiB,KACzB,wBAAwB,EAYvB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RequestStatus as e, getAttachmentTypeFromMime as t, inferMimeTypeFromPath as n } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { ProjectSource as r } from "@epam/ai-dial-chat-api-client";
|
|
3
|
+
import { ProjectSource as i } from "@epam/ai-dial-projects";
|
|
4
|
+
//#region src/project/project-mapping.ts
|
|
5
|
+
var a = "", o = {
|
|
6
|
+
[r.Personal]: i.Personal,
|
|
7
|
+
[r.Shared]: i.Shared,
|
|
8
|
+
[r.Organization]: i.Organization
|
|
9
|
+
}, s = (e) => o[e], c = (e) => ({
|
|
10
|
+
id: e.id,
|
|
11
|
+
name: e.name,
|
|
12
|
+
source: s(e.source),
|
|
13
|
+
parentPath: e.parentPath,
|
|
14
|
+
updatedAt: e.updatedAt ?? e.createdAt
|
|
15
|
+
}), l = (e) => ({
|
|
16
|
+
name: e.name,
|
|
17
|
+
description: e.description,
|
|
18
|
+
instructions: e.instructions,
|
|
19
|
+
contextFiles: e.contextFiles.map(({ name: e }) => ({
|
|
20
|
+
name: e,
|
|
21
|
+
contentType: n(e) ?? a
|
|
22
|
+
}))
|
|
23
|
+
}), u = (r) => r.contextFiles.map(({ name: r, size: i }) => {
|
|
24
|
+
let o = n(r) ?? a;
|
|
25
|
+
return {
|
|
26
|
+
id: `stored:${r}`,
|
|
27
|
+
name: r,
|
|
28
|
+
size: i,
|
|
29
|
+
contentType: o,
|
|
30
|
+
type: t(o),
|
|
31
|
+
status: e.Idle,
|
|
32
|
+
isStored: !0
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
export { l as mapProjectDetailsToViewModel, c as mapProjectDtoToItem, s as mapProjectSource, u as mapStoredContextFiles };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { AttachmentDto, ConversationResponseDto, CreateConversationDto, CreateProjectResponseDto, ListProjectsResponseDto, ProjectConversationListResponseDto, ProjectDetailsDto, RenameConversationResponseDto, UpdateProjectResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
3
|
+
/** A generated-client `Raw` answer, of which only the native response is read. */
|
|
4
|
+
interface RawApiResponse {
|
|
5
|
+
raw: Response;
|
|
6
|
+
}
|
|
7
|
+
/** Narrow configured generated-client (`ProjectsApi`) surface the project hooks require. */
|
|
8
|
+
export interface ProjectsConfiguredClient {
|
|
9
|
+
listProjects: (options?: RequestInit) => Promise<ListProjectsResponseDto>;
|
|
10
|
+
getProject: (request: {
|
|
11
|
+
id: string;
|
|
12
|
+
}, options?: RequestInit) => Promise<ProjectDetailsDto>;
|
|
13
|
+
createProject: (request: {
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
instructions?: string;
|
|
17
|
+
fileNames?: string;
|
|
18
|
+
files?: Blob[];
|
|
19
|
+
}, options?: RequestInit) => Promise<CreateProjectResponseDto>;
|
|
20
|
+
updateProject: (request: {
|
|
21
|
+
id: string;
|
|
22
|
+
ifMatch: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
instructions?: string;
|
|
26
|
+
fileNames?: string;
|
|
27
|
+
removedFileNames?: string;
|
|
28
|
+
files?: Blob[];
|
|
29
|
+
}, options?: RequestInit) => Promise<UpdateProjectResponseDto>;
|
|
30
|
+
deleteProject: (request: {
|
|
31
|
+
id: string;
|
|
32
|
+
ifMatch: string;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
downloadProjectRaw: (request: {
|
|
35
|
+
id: string;
|
|
36
|
+
}, options?: RequestInit) => Promise<RawApiResponse>;
|
|
37
|
+
downloadProjectFileRaw: (request: {
|
|
38
|
+
id: string;
|
|
39
|
+
fileName: string;
|
|
40
|
+
}, options?: RequestInit) => Promise<RawApiResponse>;
|
|
41
|
+
listProjectConversations: (request: {
|
|
42
|
+
id: string;
|
|
43
|
+
limit?: number;
|
|
44
|
+
offset?: number;
|
|
45
|
+
}, options?: RequestInit) => Promise<ProjectConversationListResponseDto>;
|
|
46
|
+
createProjectConversation: (request: {
|
|
47
|
+
id: string;
|
|
48
|
+
createConversationDto: CreateConversationDto;
|
|
49
|
+
}) => Promise<ConversationResponseDto>;
|
|
50
|
+
getProjectConversation: (request: {
|
|
51
|
+
id: string;
|
|
52
|
+
conversationName: string;
|
|
53
|
+
}, options?: RequestInit) => Promise<ConversationResponseDto>;
|
|
54
|
+
saveProjectConversation: (request: {
|
|
55
|
+
id: string;
|
|
56
|
+
conversationName: string;
|
|
57
|
+
saveConversationBodyDto: {
|
|
58
|
+
conversation: ConversationResponseDto;
|
|
59
|
+
};
|
|
60
|
+
}) => Promise<ConversationResponseDto>;
|
|
61
|
+
renameProjectConversation: (request: {
|
|
62
|
+
id: string;
|
|
63
|
+
conversationName: string;
|
|
64
|
+
renameConversationBodyDto: {
|
|
65
|
+
newTitle: string;
|
|
66
|
+
};
|
|
67
|
+
}) => Promise<RenameConversationResponseDto>;
|
|
68
|
+
deleteProjectConversation: (request: {
|
|
69
|
+
id: string;
|
|
70
|
+
conversationName: string;
|
|
71
|
+
}) => Promise<void>;
|
|
72
|
+
attachToProjectGenerationRaw: (request: {
|
|
73
|
+
id: string;
|
|
74
|
+
attachGenerationDto: {
|
|
75
|
+
path: string;
|
|
76
|
+
};
|
|
77
|
+
}, options?: RequestInit) => Promise<RawApiResponse>;
|
|
78
|
+
}
|
|
79
|
+
/** Text fields of a project create or edit request. */
|
|
80
|
+
export interface ProjectFields {
|
|
81
|
+
/** Project name; also the last path segment of its id. */
|
|
82
|
+
name: string;
|
|
83
|
+
/** Plain-text description. */
|
|
84
|
+
description: string;
|
|
85
|
+
/** Markdown instructions, stored as the `PROJECT.md` body. */
|
|
86
|
+
instructions: string;
|
|
87
|
+
}
|
|
88
|
+
/** One project edit: the fields, the added files only, the stored files to drop and the loaded version. */
|
|
89
|
+
export interface ProjectUpdateRequest {
|
|
90
|
+
/** The project's DIAL id. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** The edited text fields. */
|
|
93
|
+
fields: ProjectFields;
|
|
94
|
+
/** Files added in this edit. */
|
|
95
|
+
newFiles: File[];
|
|
96
|
+
/** Names of the stored context files to remove. */
|
|
97
|
+
removedFileNames: string[];
|
|
98
|
+
/** The loaded project's `contentVersion`; a conversation written meanwhile does not change it. */
|
|
99
|
+
contentVersion: string;
|
|
100
|
+
}
|
|
101
|
+
/** One page of a project's conversations, newest first. */
|
|
102
|
+
export interface ProjectConversationListPage {
|
|
103
|
+
/** Page size, `1..100`; the BFF defaults to 50. */
|
|
104
|
+
limit?: number;
|
|
105
|
+
/** Conversations to skip; the next page starts at the count already loaded. */
|
|
106
|
+
offset?: number;
|
|
107
|
+
}
|
|
108
|
+
/** The first message of a new top-level or project conversation. */
|
|
109
|
+
export interface ConversationCreateRequest {
|
|
110
|
+
/** The first user message. */
|
|
111
|
+
firstMessage: string;
|
|
112
|
+
/** Model or application the conversation starts with. */
|
|
113
|
+
deploymentId: string;
|
|
114
|
+
/** Attachments of the first message. */
|
|
115
|
+
attachments?: AttachmentDto[];
|
|
116
|
+
/** Tool configuration of the first message. */
|
|
117
|
+
configurationValue?: Record<string, unknown>;
|
|
118
|
+
/** Form values of the first message. */
|
|
119
|
+
formValue?: Record<string, unknown>;
|
|
120
|
+
/** Skills requested with the first message. */
|
|
121
|
+
skills?: RequestSkill[];
|
|
122
|
+
}
|
|
123
|
+
/** App-agnostic project requests over a configured generated client. */
|
|
124
|
+
export interface ProjectsApiClient {
|
|
125
|
+
listProjects: (signal?: AbortSignal) => Promise<ListProjectsResponseDto>;
|
|
126
|
+
getProject: (id: string, signal?: AbortSignal) => Promise<ProjectDetailsDto>;
|
|
127
|
+
createProject: (fields: ProjectFields, files: File[], signal?: AbortSignal) => Promise<CreateProjectResponseDto>;
|
|
128
|
+
updateProject: (request: ProjectUpdateRequest, signal?: AbortSignal) => Promise<UpdateProjectResponseDto>;
|
|
129
|
+
deleteProject: (id: string, contentVersion: string) => Promise<void>;
|
|
130
|
+
downloadProjectArchive: (id: string, signal?: AbortSignal) => Promise<Response>;
|
|
131
|
+
downloadProjectContextFile: (id: string, fileName: string, signal?: AbortSignal) => Promise<Response>;
|
|
132
|
+
listProjectConversations: (projectId: string, signal?: AbortSignal, page?: ProjectConversationListPage) => Promise<ProjectConversationListResponseDto>;
|
|
133
|
+
createProjectConversation: (projectId: string, request: ConversationCreateRequest) => Promise<ConversationResponseDto>;
|
|
134
|
+
getProjectConversation: (conversationId: string, signal?: AbortSignal) => Promise<ConversationResponseDto>;
|
|
135
|
+
saveProjectConversation: (conversationId: string, conversation: ConversationResponseDto) => Promise<ConversationResponseDto>;
|
|
136
|
+
renameProjectConversation: (conversationId: string, newTitle: string) => Promise<RenameConversationResponseDto>;
|
|
137
|
+
deleteProjectConversation: (conversationId: string) => Promise<void>;
|
|
138
|
+
attachToProjectGeneration: (projectId: string, path: string, signal?: AbortSignal) => Promise<ReadableStream<Uint8Array>>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Splits a project conversation id `projects/{bucket}/{projectPath…}/conversations/{name}`
|
|
142
|
+
* into the project id and the conversation file name; `null` for any other id.
|
|
143
|
+
*/
|
|
144
|
+
export declare const splitProjectConversationId: (conversationId: string) => {
|
|
145
|
+
projectId: string;
|
|
146
|
+
conversationName: string;
|
|
147
|
+
} | null;
|
|
148
|
+
/** The create-conversation body of a first message, the same for a top-level and a project conversation. */
|
|
149
|
+
export declare const buildCreateConversationDto: ({ firstMessage, deploymentId, attachments, configurationValue, formValue, skills, }: ConversationCreateRequest) => CreateConversationDto;
|
|
150
|
+
/**
|
|
151
|
+
* Composes the project requests over a configured generated `ProjectsApi`.
|
|
152
|
+
* File names travel as JSON fields, positionally paired with `files`,
|
|
153
|
+
* because the BFF never trusts a multipart part's own filename.
|
|
154
|
+
*/
|
|
155
|
+
export declare const createProjectsApiClient: (client: ProjectsConfiguredClient) => ProjectsApiClient;
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=projects-api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-api-client.d.ts","sourceRoot":"","sources":["../../src/project/projects-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,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,CAAC,kCAAkC,CAAC,CAAC;IACjD,yBAAyB,EAAE,CACzB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,sBAAsB,EAAE,CACtB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,uBAAuB,EAAE,CACvB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,uBAAuB,KAClC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,yBAAyB,EAAE,CACzB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,yBAAyB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,yBAAyB,EAAE,CACzB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;CAC1C;AAKD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GACrC,gBAAgB,MAAM,KACrB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAAG,IAapD,CAAC;AAYF,4GAA4G;AAC5G,eAAO,MAAM,0BAA0B,GAAI,qFAOxC,yBAAyB,KAAG,qBAe7B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,wBAAwB,KAC/B,iBA6ED,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region src/project/projects-api-client.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e.split("/");
|
|
4
|
+
return t.length < 5 || t[0] !== "projects" || t[t.length - 2] !== "conversations" ? null : {
|
|
5
|
+
projectId: t.slice(0, -2).join("/"),
|
|
6
|
+
conversationName: t[t.length - 1]
|
|
7
|
+
};
|
|
8
|
+
}, t = (t) => {
|
|
9
|
+
let n = e(t);
|
|
10
|
+
if (!n) throw Error("Not a project conversation id");
|
|
11
|
+
return {
|
|
12
|
+
id: n.projectId,
|
|
13
|
+
conversationName: n.conversationName
|
|
14
|
+
};
|
|
15
|
+
}, n = (e) => e ? [{ signal: e }] : [], r = ({ firstMessage: e, deploymentId: t, attachments: n, configurationValue: r, formValue: i, skills: a }) => ({
|
|
16
|
+
firstMessage: e,
|
|
17
|
+
deploymentId: t,
|
|
18
|
+
...n?.length || r || i || a?.length ? { custom_content: {
|
|
19
|
+
...n?.length ? { attachments: n } : {},
|
|
20
|
+
...r ? { configuration_value: r } : {},
|
|
21
|
+
...i ? { form_value: i } : {},
|
|
22
|
+
...a?.length ? { skills: a } : {}
|
|
23
|
+
} } : {}
|
|
24
|
+
}), i = (e) => ({
|
|
25
|
+
listProjects: (t) => e.listProjects(...n(t)),
|
|
26
|
+
getProject: (t, r) => e.getProject({ id: t }, ...n(r)),
|
|
27
|
+
createProject: ({ name: t, description: r, instructions: i }, a, o) => e.createProject({
|
|
28
|
+
name: t,
|
|
29
|
+
description: r,
|
|
30
|
+
instructions: i,
|
|
31
|
+
fileNames: JSON.stringify(a.map((e) => e.name)),
|
|
32
|
+
files: a
|
|
33
|
+
}, ...n(o)),
|
|
34
|
+
updateProject: ({ id: t, fields: r, newFiles: i, removedFileNames: a, contentVersion: o }, s) => e.updateProject({
|
|
35
|
+
id: t,
|
|
36
|
+
ifMatch: o,
|
|
37
|
+
name: r.name,
|
|
38
|
+
description: r.description,
|
|
39
|
+
instructions: r.instructions,
|
|
40
|
+
fileNames: JSON.stringify(i.map((e) => e.name)),
|
|
41
|
+
removedFileNames: JSON.stringify(a),
|
|
42
|
+
files: i
|
|
43
|
+
}, ...n(s)),
|
|
44
|
+
deleteProject: (t, n) => e.deleteProject({
|
|
45
|
+
id: t,
|
|
46
|
+
ifMatch: n
|
|
47
|
+
}),
|
|
48
|
+
downloadProjectArchive: async (t, r) => (await e.downloadProjectRaw({ id: t }, ...n(r))).raw,
|
|
49
|
+
downloadProjectContextFile: async (t, r, i) => (await e.downloadProjectFileRaw({
|
|
50
|
+
id: t,
|
|
51
|
+
fileName: r
|
|
52
|
+
}, ...n(i))).raw,
|
|
53
|
+
listProjectConversations: (t, r, i) => e.listProjectConversations({
|
|
54
|
+
id: t,
|
|
55
|
+
...i
|
|
56
|
+
}, ...n(r)),
|
|
57
|
+
createProjectConversation: (t, n) => e.createProjectConversation({
|
|
58
|
+
id: t,
|
|
59
|
+
createConversationDto: r(n)
|
|
60
|
+
}),
|
|
61
|
+
getProjectConversation: (r, i) => e.getProjectConversation(t(r), ...n(i)),
|
|
62
|
+
saveProjectConversation: (n, r) => e.saveProjectConversation({
|
|
63
|
+
...t(n),
|
|
64
|
+
saveConversationBodyDto: { conversation: r }
|
|
65
|
+
}),
|
|
66
|
+
renameProjectConversation: (n, r) => e.renameProjectConversation({
|
|
67
|
+
...t(n),
|
|
68
|
+
renameConversationBodyDto: { newTitle: r }
|
|
69
|
+
}),
|
|
70
|
+
deleteProjectConversation: (n) => e.deleteProjectConversation(t(n)),
|
|
71
|
+
attachToProjectGeneration: async (t, r, i) => {
|
|
72
|
+
let { raw: a } = await e.attachToProjectGenerationRaw({
|
|
73
|
+
id: t,
|
|
74
|
+
attachGenerationDto: { path: r }
|
|
75
|
+
}, ...n(i));
|
|
76
|
+
if (!a.body) throw Error("Attach endpoint returned no response body");
|
|
77
|
+
return a.body;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
//#endregion
|
|
81
|
+
export { r as buildCreateConversationDto, i as createProjectsApiClient, e as splitProjectConversationId };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ProjectDetailsDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
import { ProjectsApiClient } from './projects-api-client';
|
|
3
|
+
/** Which project action failed, for the host's error message. */
|
|
4
|
+
export declare enum ProjectActionError {
|
|
5
|
+
Pin = "pin",
|
|
6
|
+
Download = "download",
|
|
7
|
+
Delete = "delete",
|
|
8
|
+
/** The delete lost to a concurrent change; the project should be reloaded. */
|
|
9
|
+
ChangedElsewhere = "changed-elsewhere"
|
|
10
|
+
}
|
|
11
|
+
/** Host behaviour the project actions delegate to. */
|
|
12
|
+
export interface ProjectActionsHandlers {
|
|
13
|
+
/** Whether the project is in the caller's pins. */
|
|
14
|
+
isPinned: boolean;
|
|
15
|
+
/** Persists the pin state; rejects on failure. */
|
|
16
|
+
setPinned: (projectId: string, isPinned: boolean) => Promise<void>;
|
|
17
|
+
/** Saves a downloaded response as a file and resolves the saved name. */
|
|
18
|
+
saveFile: (response: Response, fileName: string) => Promise<string>;
|
|
19
|
+
/** Called after the archive was saved, with the saved file name. */
|
|
20
|
+
onArchiveDownloaded?: (savedName: string) => void;
|
|
21
|
+
/** Called after the project was deleted; the host updates pins and navigates away. */
|
|
22
|
+
onDeleted: (project: ProjectDetailsDto) => void;
|
|
23
|
+
/** Called with a failed action and its trace id; the host shows the message. */
|
|
24
|
+
onError: (error: ProjectActionError, requestId?: string) => void;
|
|
25
|
+
/** Re-reads the project, e.g. after a delete lost to a concurrent change. */
|
|
26
|
+
onReload: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pin, archive and context-file downloads, and the confirmed delete of one
|
|
30
|
+
* loaded project, with their in-flight state. Messages, notifications, pins
|
|
31
|
+
* and navigation stay with the host through `handlers`.
|
|
32
|
+
*
|
|
33
|
+
* @param client - Configured project requests, from `createProjectsApiClient`.
|
|
34
|
+
* @param project - The loaded project, or `null` while none is loaded.
|
|
35
|
+
* @param handlers - Host behaviour the actions delegate to.
|
|
36
|
+
*/
|
|
37
|
+
export declare const useProjectActions: (client: Pick<ProjectsApiClient, "deleteProject" | "downloadProjectArchive" | "downloadProjectContextFile">, project: ProjectDetailsDto | null, { isPinned, setPinned, saveFile, onArchiveDownloaded, onDeleted, onError, onReload, }: ProjectActionsHandlers) => {
|
|
38
|
+
isPinned: boolean;
|
|
39
|
+
isPinPending: boolean;
|
|
40
|
+
togglePin: () => Promise<void>;
|
|
41
|
+
downloadArchive: () => Promise<void>;
|
|
42
|
+
openFile: (fileName: string) => Promise<void>;
|
|
43
|
+
isDeleteOpen: boolean;
|
|
44
|
+
isDeleting: boolean;
|
|
45
|
+
requestDelete: () => void;
|
|
46
|
+
cancelDelete: () => void;
|
|
47
|
+
confirmDelete: () => Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=use-project-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-project-actions.d.ts","sourceRoot":"","sources":["../../src/project/use-project-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,iEAAiE;AACjE,oBAAY,kBAAkB;IAC5B,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,8EAA8E;IAC9E,gBAAgB,sBAAsB;CACvC;AAED,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,kDAAkD;IAClD,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,yEAAyE;IACzE,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpE,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,sFAAsF;IACtF,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,gFAAgF;IAChF,OAAO,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,IAAI,CACV,iBAAiB,EACjB,eAAe,GAAG,wBAAwB,GAAG,4BAA4B,CAC1E,EACD,SAAS,iBAAiB,GAAG,IAAI,EACjC,uFAQG,sBAAsB;;;;;yBAyCN,MAAM;;;;;;CAmE1B,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getApiErrorDetails as e } from "../api-error/api-error.js";
|
|
2
|
+
import { sanitizeFileName as t } from "../files/file-name.js";
|
|
3
|
+
import { useCallback as n, useMemo as r, useState as i } from "react";
|
|
4
|
+
import { ProjectCreateErrorCode as a } from "@epam/ai-dial-chat-api-client";
|
|
5
|
+
//#region src/project/use-project-actions.ts
|
|
6
|
+
var o = /* @__PURE__ */ function(e) {
|
|
7
|
+
return e.Pin = "pin", e.Download = "download", e.Delete = "delete", e.ChangedElsewhere = "changed-elsewhere", e;
|
|
8
|
+
}({}), s = (o, s, { isPinned: c, setPinned: l, saveFile: u, onArchiveDownloaded: d, onDeleted: f, onError: p, onReload: m }) => {
|
|
9
|
+
let [h, g] = i(!1), [_, v] = i(!1), [y, b] = i(!1), x = n(async (t, n) => {
|
|
10
|
+
let { traceId: r } = await e(t);
|
|
11
|
+
p(n, r);
|
|
12
|
+
}, [p]), S = n(async () => {
|
|
13
|
+
if (s != null) {
|
|
14
|
+
g(!0);
|
|
15
|
+
try {
|
|
16
|
+
await l(s.id, !c);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
await x(e, "pin");
|
|
19
|
+
} finally {
|
|
20
|
+
g(!1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, [
|
|
24
|
+
s,
|
|
25
|
+
c,
|
|
26
|
+
l,
|
|
27
|
+
x
|
|
28
|
+
]), C = n(async () => {
|
|
29
|
+
if (s != null) try {
|
|
30
|
+
let e = await u(await o.downloadProjectArchive(s.id), `${t(s.name)}.zip`);
|
|
31
|
+
d?.(e);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
await x(e, "download");
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
o,
|
|
37
|
+
s,
|
|
38
|
+
u,
|
|
39
|
+
d,
|
|
40
|
+
x
|
|
41
|
+
]), w = n(async (e) => {
|
|
42
|
+
if (s != null) try {
|
|
43
|
+
await u(await o.downloadProjectContextFile(s.id, e), e);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
await x(e, "download");
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
o,
|
|
49
|
+
s,
|
|
50
|
+
u,
|
|
51
|
+
x
|
|
52
|
+
]), T = n(() => v(!0), []), E = n(() => {
|
|
53
|
+
y || v(!1);
|
|
54
|
+
}, [y]), D = n(async () => {
|
|
55
|
+
if (s != null) {
|
|
56
|
+
b(!0);
|
|
57
|
+
try {
|
|
58
|
+
await o.deleteProject(s.id, s.contentVersion), v(!1), f(s);
|
|
59
|
+
} catch (t) {
|
|
60
|
+
let { code: n, traceId: r } = await e(t);
|
|
61
|
+
if (n === a.ProjectChanged) {
|
|
62
|
+
v(!1), p("changed-elsewhere", r), m();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
p("delete", r);
|
|
66
|
+
} finally {
|
|
67
|
+
b(!1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
71
|
+
o,
|
|
72
|
+
s,
|
|
73
|
+
f,
|
|
74
|
+
p,
|
|
75
|
+
m
|
|
76
|
+
]);
|
|
77
|
+
return r(() => ({
|
|
78
|
+
isPinned: c,
|
|
79
|
+
isPinPending: h,
|
|
80
|
+
togglePin: S,
|
|
81
|
+
downloadArchive: C,
|
|
82
|
+
openFile: w,
|
|
83
|
+
isDeleteOpen: _,
|
|
84
|
+
isDeleting: y,
|
|
85
|
+
requestDelete: T,
|
|
86
|
+
cancelDelete: E,
|
|
87
|
+
confirmDelete: D
|
|
88
|
+
}), [
|
|
89
|
+
c,
|
|
90
|
+
h,
|
|
91
|
+
S,
|
|
92
|
+
C,
|
|
93
|
+
w,
|
|
94
|
+
_,
|
|
95
|
+
y,
|
|
96
|
+
T,
|
|
97
|
+
E,
|
|
98
|
+
D
|
|
99
|
+
]);
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
export { o as ProjectActionError, s as useProjectActions };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ProjectConversationListItem } from '@epam/ai-dial-projects';
|
|
2
|
+
import { ProjectsApiClient } from './projects-api-client';
|
|
3
|
+
/**
|
|
4
|
+
* Loads a project's conversations for its Chats list and keeps them in local
|
|
5
|
+
* state: there is no live subscription, so the first page is read once per
|
|
6
|
+
* project (and on retry), `loadMore` appends the next one, and rename and
|
|
7
|
+
* delete update the list in place. Requests are aborted when the project
|
|
8
|
+
* changes or the view unmounts. Rename, delete and `loadMore` reject on
|
|
9
|
+
* failure for the caller's toast.
|
|
10
|
+
*
|
|
11
|
+
* @param client - Configured project requests, from `createProjectsApiClient`; it must be referentially stable, because a new object reloads the list.
|
|
12
|
+
* @param projectId - The project's DIAL id, or `null` while none is known.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useProjectConversations: (client: Pick<ProjectsApiClient, "listProjectConversations" | "renameProjectConversation" | "deleteProjectConversation">, projectId: string | null) => {
|
|
15
|
+
retry: () => void;
|
|
16
|
+
loadMore: () => Promise<void>;
|
|
17
|
+
rename: (id: string, newTitle: string) => Promise<void>;
|
|
18
|
+
remove: (id: string) => Promise<void>;
|
|
19
|
+
items: ProjectConversationListItem[];
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
hasError: boolean;
|
|
22
|
+
/** More conversations exist after `items`. */
|
|
23
|
+
hasMore: boolean;
|
|
24
|
+
/** The next page is being read. */
|
|
25
|
+
isLoadingMore: boolean;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=use-project-conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-project-conversations.d.ts","sourceRoot":"","sources":["../../src/project/use-project-conversations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA8B/D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,IAAI,CACV,iBAAiB,EACf,0BAA0B,GAC1B,2BAA2B,GAC3B,2BAA2B,CAC9B,EACD,WAAW,MAAM,GAAG,IAAI;;;iBA6EX,MAAM,YAAY,MAAM;iBAaxB,MAAM;WAvIZ,2BAA2B,EAAE;eACzB,OAAO;cACR,OAAO;IACjB,8CAA8C;aACrC,OAAO;IAChB,mCAAmC;mBACpB,OAAO;CA4IvB,CAAC"}
|