@epam/ai-dial-chat-hooks 1.4.0-dev.5 → 1.4.0-dev.51
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/create-publish-api.d.ts +7 -1
- package/catalog/create-publish-api.d.ts.map +1 -1
- package/catalog/create-publish-api.js +4 -0
- package/catalog/publish-dependency-icons.d.ts +22 -0
- package/catalog/publish-dependency-icons.d.ts.map +1 -0
- package/catalog/publish-dependency-icons.js +11 -0
- package/catalog/publish.d.ts +13 -2
- package/catalog/publish.d.ts.map +1 -1
- package/catalog/publish.js +13 -2
- package/catalog/use-publish-dependencies.d.ts +19 -0
- package/catalog/use-publish-dependencies.d.ts.map +1 -0
- package/catalog/use-publish-dependencies.js +25 -0
- package/catalog/usePublishFolders/usePublishFolders.d.ts.map +1 -1
- package/catalog/usePublishFolders/usePublishFolders.js +1 -1
- package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts.map +1 -1
- package/catalog/useResourceSavePanel/useResourceSavePanel.js +83 -84
- package/catalog.js +33 -31
- package/entry-points/catalog.d.ts +2 -0
- package/entry-points/catalog.d.ts.map +1 -1
- package/entry-points/project.d.ts +5 -0
- package/entry-points/project.d.ts.map +1 -1
- package/index.d.ts +7 -0
- package/index.d.ts.map +1 -1
- package/index.js +221 -214
- package/package.json +18 -18
- package/project/project-sharing-client.d.ts +8 -0
- package/project/project-sharing-client.d.ts.map +1 -0
- package/project/project-sharing-client.js +11 -0
- package/project/project-sharing.d.ts +28 -0
- package/project/project-sharing.d.ts.map +1 -0
- package/project/project-sharing.js +22 -0
- package/project/use-pinned-project-chats.d.ts +4 -2
- package/project/use-pinned-project-chats.d.ts.map +1 -1
- package/project/use-pinned-project-chats.js +152 -96
- package/project/use-project-conversations.d.ts.map +1 -1
- package/project/use-project-conversations.js +2 -2
- package/project/use-project-remove-from-list.d.ts +30 -0
- package/project/use-project-remove-from-list.d.ts.map +1 -0
- package/project/use-project-remove-from-list.js +39 -0
- package/project/use-project-revoke-access.d.ts +15 -0
- package/project/use-project-revoke-access.d.ts.map +1 -0
- package/project/use-project-revoke-access.js +32 -0
- package/project/use-project-share-recipients.d.ts +7 -0
- package/project/use-project-share-recipients.d.ts.map +1 -0
- package/project/use-project-share-recipients.js +36 -0
- package/project/use-projects.d.ts +1 -0
- package/project/use-projects.d.ts.map +1 -1
- package/project/use-projects.js +2 -1
- package/project.js +7 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-hooks",
|
|
3
3
|
"description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
|
|
4
|
-
"version": "1.4.0-dev.
|
|
4
|
+
"version": "1.4.0-dev.51",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@epam/ai-dial-chat-api-client": "1.4.0-dev.
|
|
134
|
+
"@epam/ai-dial-chat-api-client": "1.4.0-dev.51",
|
|
135
135
|
"dompurify": "3.4.17",
|
|
136
136
|
"fflate": "^0.8.3",
|
|
137
137
|
"lru-cache": "^10.4.3",
|
|
@@ -140,25 +140,25 @@
|
|
|
140
140
|
},
|
|
141
141
|
"peerDependencies": {
|
|
142
142
|
"react": "^19.2.8",
|
|
143
|
-
"@epam/ai-dial-attachment-canvas": "1.4.0-dev.
|
|
144
|
-
"@epam/ai-dial-attachment-input": "1.4.0-dev.
|
|
145
|
-
"@epam/ai-dial-catalog": "1.4.0-dev.
|
|
146
|
-
"@epam/ai-dial-chat-overlay": "1.4.0-dev.
|
|
147
|
-
"@epam/ai-dial-chat-shared": "1.4.0-dev.
|
|
148
|
-
"@epam/ai-dial-conversation-input": "1.4.0-dev.
|
|
149
|
-
"@epam/ai-dial-mcp-apps": "1.4.0-dev.
|
|
150
|
-
"@epam/ai-dial-projects": "1.4.0-dev.
|
|
151
|
-
"@epam/ai-dial-publish-panel": "1.4.0-dev.
|
|
152
|
-
"@epam/ai-dial-quotations": "1.4.0-dev.
|
|
143
|
+
"@epam/ai-dial-attachment-canvas": "1.4.0-dev.51",
|
|
144
|
+
"@epam/ai-dial-attachment-input": "1.4.0-dev.51",
|
|
145
|
+
"@epam/ai-dial-catalog": "1.4.0-dev.51",
|
|
146
|
+
"@epam/ai-dial-chat-overlay": "1.4.0-dev.51",
|
|
147
|
+
"@epam/ai-dial-chat-shared": "1.4.0-dev.51",
|
|
148
|
+
"@epam/ai-dial-conversation-input": "1.4.0-dev.51",
|
|
149
|
+
"@epam/ai-dial-mcp-apps": "1.4.0-dev.51",
|
|
150
|
+
"@epam/ai-dial-projects": "1.4.0-dev.51",
|
|
151
|
+
"@epam/ai-dial-publish-panel": "1.4.0-dev.51",
|
|
152
|
+
"@epam/ai-dial-quotations": "1.4.0-dev.51",
|
|
153
153
|
"@epam/ai-dial-react-file-manager": "^0.4.1",
|
|
154
|
-
"@epam/ai-dial-scheduled-tasks": "1.4.0-dev.
|
|
155
|
-
"@epam/ai-dial-share": "1.4.0-dev.
|
|
156
|
-
"@epam/ai-dial-skill-editor": "1.4.0-dev.
|
|
157
|
-
"@epam/ai-dial-source-panel": "1.4.0-dev.
|
|
154
|
+
"@epam/ai-dial-scheduled-tasks": "1.4.0-dev.51",
|
|
155
|
+
"@epam/ai-dial-share": "1.4.0-dev.51",
|
|
156
|
+
"@epam/ai-dial-skill-editor": "1.4.0-dev.51",
|
|
157
|
+
"@epam/ai-dial-source-panel": "1.4.0-dev.51",
|
|
158
158
|
"@epam/ai-dial-ui-kit": "^0.16.0",
|
|
159
|
-
"@epam/ai-dial-usage-dashboard": "1.4.0-dev.
|
|
159
|
+
"@epam/ai-dial-usage-dashboard": "1.4.0-dev.51",
|
|
160
160
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
161
|
-
"@epam/pdf-highlighter-kit": "^0.0.
|
|
161
|
+
"@epam/pdf-highlighter-kit": "^0.0.22"
|
|
162
162
|
},
|
|
163
163
|
"peerDependenciesMeta": {
|
|
164
164
|
"@epam/ai-dial-attachment-canvas": {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShareApi } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
/** Already-configured sharing operations required by project sharing hooks. Keep the instance stable. */
|
|
3
|
+
export type ProjectSharingClient = Pick<ShareApi, 'getShareRecipientsCount' | 'revokeSharedAccess'>;
|
|
4
|
+
/** Subscribes a menu to successful revokes made through the same configured client. */
|
|
5
|
+
export declare const subscribeProjectAccessRevoked: (client: ProjectSharingClient, listener: (projectId: string) => void) => () => void;
|
|
6
|
+
/** Invalidates recipient counts for one project and one configured client. */
|
|
7
|
+
export declare const notifyProjectAccessRevoked: (client: ProjectSharingClient, projectId: string) => void;
|
|
8
|
+
//# sourceMappingURL=project-sharing-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-sharing-client.d.ts","sourceRoot":"","sources":["../../src/project/project-sharing-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,yGAAyG;AACzG,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,QAAQ,EACR,yBAAyB,GAAG,oBAAoB,CACjD,CAAC;AAOF,uFAAuF;AACvF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,oBAAoB,EAC5B,UAAU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,eAWtC,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,GACrC,QAAQ,oBAAoB,EAC5B,WAAW,MAAM,SAGlB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/project/project-sharing-client.ts
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap(), t = (t, n) => {
|
|
3
|
+
let r = e.get(t);
|
|
4
|
+
return r || (r = /* @__PURE__ */ new Set(), e.set(t, r)), r.add(n), () => {
|
|
5
|
+
r.delete(n);
|
|
6
|
+
};
|
|
7
|
+
}, n = (t, n) => {
|
|
8
|
+
for (let r of e.get(t) ?? []) r(n);
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as notifyProjectAccessRevoked, t as subscribeProjectAccessRevoked };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ProjectDetailsDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
/** Whether a project was shared with the caller, so they may drop it from their list but not delete it. */
|
|
3
|
+
export declare const isProjectSharedWithMe: (project: Pick<ProjectDetailsDto, "source" | "canManage"> | null | undefined) => boolean;
|
|
4
|
+
/** An action of a pinned project's sidebar menu; the values are the menu item keys. */
|
|
5
|
+
export declare enum PinnedProjectMenuAction {
|
|
6
|
+
/** Removes the project from the pins. */
|
|
7
|
+
Unpin = "unpin",
|
|
8
|
+
/** Opens the edit page. */
|
|
9
|
+
Edit = "edit",
|
|
10
|
+
/** Opens the publish panel. */
|
|
11
|
+
Publish = "publish",
|
|
12
|
+
/** Opens the share popover. */
|
|
13
|
+
Share = "share",
|
|
14
|
+
/** Opens the owner's revoke-access confirmation. */
|
|
15
|
+
RevokeAccess = "revokeAccess",
|
|
16
|
+
/** Opens the delete confirmation. */
|
|
17
|
+
Delete = "delete",
|
|
18
|
+
/** Opens the confirmation that drops a shared project from the caller's list. */
|
|
19
|
+
RemoveFromMyList = "removeFromMyList"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the actions a pinned project's menu offers the caller, in display order.
|
|
23
|
+
* The host maps each to its label, icon and handler.
|
|
24
|
+
* @param project - The loaded project, or nullish while loading.
|
|
25
|
+
* @param canRevokeAccess - Whether recipients are confirmed; defaults to false. Ownership is still required.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getPinnedProjectMenuActions: (project: Pick<ProjectDetailsDto, "source" | "canEdit" | "canManage"> | null | undefined, canRevokeAccess?: boolean) => PinnedProjectMenuAction[];
|
|
28
|
+
//# sourceMappingURL=project-sharing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-sharing.d.ts","sourceRoot":"","sources":["../../src/project/project-sharing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,+BAA+B,CAAC;AAEvC,2GAA2G;AAC3G,eAAO,MAAM,qBAAqB,GAChC,SAAS,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KAC1E,OAGiB,CAAC;AAErB,uFAAuF;AACvF,oBAAY,uBAAuB;IACjC,yCAAyC;IACzC,KAAK,UAAU;IACf,2BAA2B;IAC3B,IAAI,SAAS;IACb,+BAA+B;IAC/B,OAAO,YAAY;IACnB,+BAA+B;IAC/B,KAAK,UAAU;IACf,oDAAoD;IACpD,YAAY,iBAAiB;IAC7B,qCAAqC;IACrC,MAAM,WAAW;IACjB,iFAAiF;IACjF,gBAAgB,qBAAqB;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GACtC,SACI,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC,GAC3D,IAAI,GACJ,SAAS,EACb,yBAAuB,KACtB,uBAAuB,EAyBzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProjectSource as e } from "@epam/ai-dial-chat-api-client";
|
|
2
|
+
//#region src/project/project-sharing.ts
|
|
3
|
+
var t = (t) => t != null && t.source === e.Shared && !t.canManage, n = /* @__PURE__ */ function(e) {
|
|
4
|
+
return e.Unpin = "unpin", e.Edit = "edit", e.Publish = "publish", e.Share = "share", e.RevokeAccess = "revokeAccess", e.Delete = "delete", e.RemoveFromMyList = "removeFromMyList", e;
|
|
5
|
+
}({}), r = (e, n = !1) => {
|
|
6
|
+
if (e == null) return ["unpin"];
|
|
7
|
+
let r = t(e) ? ["removeFromMyList"] : [];
|
|
8
|
+
return e.canEdit ? e.canManage ? [
|
|
9
|
+
"unpin",
|
|
10
|
+
"edit",
|
|
11
|
+
"publish",
|
|
12
|
+
"share",
|
|
13
|
+
...n ? ["revokeAccess"] : [],
|
|
14
|
+
"delete"
|
|
15
|
+
] : [
|
|
16
|
+
"unpin",
|
|
17
|
+
"edit",
|
|
18
|
+
...r
|
|
19
|
+
] : ["unpin", ...r];
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { n as PinnedProjectMenuAction, r as getPinnedProjectMenuActions, t as isProjectSharedWithMe };
|
|
@@ -8,6 +8,8 @@ export interface PinnedProjectChatsOptions {
|
|
|
8
8
|
enabled: boolean;
|
|
9
9
|
/** The project no longer exists (a watch `DELETE`, or `404` on a read). Called at most once per id. */
|
|
10
10
|
onProjectDeleted: (projectId: string) => void;
|
|
11
|
+
/** Id of the chat the host has open. When it is not among the newest chats of its project, it takes the last slot of that project's list, so the list never exceeds `PINNED_PROJECT_CHATS_LIMIT`. */
|
|
12
|
+
activeConversationId?: string;
|
|
11
13
|
}
|
|
12
14
|
/** A chat listed under a pinned project. */
|
|
13
15
|
export interface PinnedProjectChat {
|
|
@@ -22,7 +24,7 @@ export interface PinnedProjectChat {
|
|
|
22
24
|
export interface PinnedProjectChats {
|
|
23
25
|
/** The project's details as last read; `canEdit`, `canManage`, `contentVersion` and `conversationCount` feed the host's actions. */
|
|
24
26
|
project: ProjectDetailsDto;
|
|
25
|
-
/** At most `PINNED_PROJECT_CHATS_LIMIT` chats, newest first. */
|
|
27
|
+
/** At most `PINNED_PROJECT_CHATS_LIMIT` chats, newest first; an open chat past the newest ones replaces the last of them and comes last. */
|
|
26
28
|
chats: PinnedProjectChat[];
|
|
27
29
|
/** The project has more chats than `chats` holds. */
|
|
28
30
|
hasMore: boolean;
|
|
@@ -54,5 +56,5 @@ export interface PinnedProjectChatsResult {
|
|
|
54
56
|
* @param projectIds - The pinned project ids, in display order.
|
|
55
57
|
* @param options - Whether the tree is enabled and the delete callback; the callback is read at event time, so a new identity never resubscribes.
|
|
56
58
|
*/
|
|
57
|
-
export declare const usePinnedProjectChats: (client: Pick<ProjectsApiClient, "getProject" | "listProjectConversations" | "getProjectConversationTitles" | "watchProjects">, projectIds: string[], { enabled, onProjectDeleted }: PinnedProjectChatsOptions) => PinnedProjectChatsResult;
|
|
59
|
+
export declare const usePinnedProjectChats: (client: Pick<ProjectsApiClient, "getProject" | "listProjectConversations" | "getProjectConversationTitles" | "watchProjects">, projectIds: string[], { enabled, onProjectDeleted, activeConversationId, }: PinnedProjectChatsOptions) => PinnedProjectChatsResult;
|
|
58
60
|
//# sourceMappingURL=use-pinned-project-chats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pinned-project-chats.d.ts","sourceRoot":"","sources":["../../src/project/use-pinned-project-chats.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAW7C,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,uGAAuG;IACvG,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/
|
|
1
|
+
{"version":3,"file":"use-pinned-project-chats.d.ts","sourceRoot":"","sources":["../../src/project/use-pinned-project-chats.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAW7C,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,uGAAuG;IACvG,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,qMAAqM;IACrM,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,oIAAoI;IACpI,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4IAA4I;IAC5I,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,qGAAqG;IACrG,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,oEAAoE;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,mGAAmG;IACnG,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gGAAgG;IAChG,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAiHD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,IAAI,CACV,iBAAiB,EACf,YAAY,GACZ,0BAA0B,GAC1B,8BAA8B,GAC9B,eAAe,CAClB,EACD,YAAY,MAAM,EAAE,EACpB,sDAIG,yBAAyB,KAC3B,wBAwaF,CAAC"}
|
|
@@ -14,10 +14,26 @@ var l = 10, u = 1e3, d = [
|
|
|
14
14
|
snapshots: /* @__PURE__ */ new Map(),
|
|
15
15
|
settled: /* @__PURE__ */ new Set(),
|
|
16
16
|
watchKey: ""
|
|
17
|
-
}, m = [], h = (e,
|
|
17
|
+
}, m = [], h = ({ overflow: e, chats: t, ...n }, r) => {
|
|
18
|
+
if (r == null || t.some((e) => e.id === r)) return {
|
|
19
|
+
...n,
|
|
20
|
+
chats: t
|
|
21
|
+
};
|
|
22
|
+
let i = e.find((e) => e.id === r);
|
|
23
|
+
return i == null ? {
|
|
24
|
+
...n,
|
|
25
|
+
chats: t
|
|
26
|
+
} : {
|
|
27
|
+
...n,
|
|
28
|
+
chats: [...t.slice(0, 9), {
|
|
29
|
+
id: i.id,
|
|
30
|
+
title: i.title
|
|
31
|
+
}]
|
|
32
|
+
};
|
|
33
|
+
}, g = (e, { settled: t, snapshots: n }, r) => {
|
|
18
34
|
let i = [...e].sort();
|
|
19
35
|
return i.every((e) => t.has(e)) ? i.filter((e) => n.has(e)).slice(0, u).join(f) : r;
|
|
20
|
-
},
|
|
36
|
+
}, _ = (e, t) => {
|
|
21
37
|
if (!e.snapshots.has(t) && !e.settled.has(t)) return e;
|
|
22
38
|
let n = new Map(e.snapshots);
|
|
23
39
|
n.delete(t);
|
|
@@ -27,7 +43,7 @@ var l = 10, u = 1e3, d = [
|
|
|
27
43
|
snapshots: n,
|
|
28
44
|
settled: r
|
|
29
45
|
};
|
|
30
|
-
},
|
|
46
|
+
}, v = (e, t) => {
|
|
31
47
|
if (t.length === 0) return e;
|
|
32
48
|
let n = new Map(t.map((e) => [e.id, e]));
|
|
33
49
|
return e.map((e) => {
|
|
@@ -38,73 +54,75 @@ var l = 10, u = 1e3, d = [
|
|
|
38
54
|
isTitlePending: !1
|
|
39
55
|
} : e;
|
|
40
56
|
});
|
|
41
|
-
},
|
|
42
|
-
let [
|
|
57
|
+
}, y = (l, u, { enabled: y, onProjectDeleted: b, activeConversationId: x }) => {
|
|
58
|
+
let [S, C] = c(p), w = s(S);
|
|
43
59
|
a(() => {
|
|
44
|
-
|
|
60
|
+
w.current = S;
|
|
45
61
|
});
|
|
46
|
-
let
|
|
62
|
+
let T = s(b);
|
|
47
63
|
a(() => {
|
|
48
|
-
|
|
64
|
+
T.current = b;
|
|
49
65
|
});
|
|
50
|
-
let
|
|
66
|
+
let E = s(/* @__PURE__ */ new Set()), D = s(/* @__PURE__ */ new Map()), O = s(/* @__PURE__ */ new Map()), k = s(/* @__PURE__ */ new Set()), A = s(/* @__PURE__ */ new Map()), j = s(/* @__PURE__ */ new Map()), M = s(null), N = o(() => [...new Set(u)].sort().join(f), [u]), P = i(async (e, t) => {
|
|
51
67
|
let [n, r] = await Promise.allSettled([l.getProject(e, t), l.listProjectConversations(e, t)]);
|
|
52
68
|
if (n.status === "rejected") throw n.reason;
|
|
53
69
|
let i = r.status === "fulfilled" ? r.value.items : [], a = i.slice(0, 10), o = a.filter((e) => e.isTitlePending).map((e) => e.name);
|
|
54
70
|
if (o.length > 0) try {
|
|
55
71
|
let { items: n } = await l.getProjectConversationTitles(e, o, t);
|
|
56
|
-
a =
|
|
72
|
+
a = v(a, n);
|
|
57
73
|
} catch {}
|
|
58
74
|
return {
|
|
59
75
|
project: n.value,
|
|
60
76
|
items: a,
|
|
77
|
+
overflow: i.slice(10),
|
|
61
78
|
hasMore: i.length > 10
|
|
62
79
|
};
|
|
63
|
-
}, [l]),
|
|
64
|
-
for (let { id: e, updatedAt: n } of t)
|
|
80
|
+
}, [l]), F = i(({ project: e, items: t, overflow: r, hasMore: i }) => {
|
|
81
|
+
for (let { id: e, updatedAt: n } of [...t, ...r]) j.current.set(e, n);
|
|
65
82
|
return {
|
|
66
83
|
project: e,
|
|
67
|
-
hasMore:
|
|
84
|
+
hasMore: i,
|
|
85
|
+
overflow: r,
|
|
68
86
|
chats: t.map((e) => ({
|
|
69
87
|
id: e.id,
|
|
70
88
|
title: e.title,
|
|
71
|
-
...n(
|
|
89
|
+
...n(A.current, e) ? { isUnread: !0 } : {}
|
|
72
90
|
}))
|
|
73
91
|
};
|
|
74
|
-
}, []), P = i((e) => {
|
|
75
|
-
D.current.has(e) || (D.current.add(e), C.current(e));
|
|
76
|
-
}, []), F = i((e) => {
|
|
77
|
-
E.current.get(e)?.controller?.abort(), E.current.delete(e);
|
|
78
92
|
}, []), I = i((e) => {
|
|
79
|
-
|
|
93
|
+
k.current.has(e) || (k.current.add(e), T.current(e));
|
|
94
|
+
}, []), L = i((e) => {
|
|
95
|
+
O.current.get(e)?.controller?.abort(), O.current.delete(e);
|
|
96
|
+
}, []), R = i((e) => {
|
|
97
|
+
L(e), C((t) => {
|
|
80
98
|
if (!t.snapshots.has(e)) return t;
|
|
81
99
|
let n = new Map(t.snapshots);
|
|
82
100
|
return n.delete(e), {
|
|
83
101
|
...t,
|
|
84
102
|
snapshots: n,
|
|
85
|
-
watchKey:
|
|
103
|
+
watchKey: g(E.current, {
|
|
86
104
|
settled: t.settled,
|
|
87
105
|
snapshots: n
|
|
88
106
|
}, t.watchKey)
|
|
89
107
|
};
|
|
90
108
|
});
|
|
91
|
-
}, [
|
|
92
|
-
if (!
|
|
93
|
-
let n =
|
|
109
|
+
}, [L]), z = i((t) => {
|
|
110
|
+
if (!w.current.snapshots.has(t)) return;
|
|
111
|
+
let n = O.current.get(t);
|
|
94
112
|
if (n ?? (n = {
|
|
95
113
|
isRefreshing: !1,
|
|
96
114
|
isPending: !1
|
|
97
|
-
},
|
|
115
|
+
}, O.current.set(t, n)), n.isRefreshing) {
|
|
98
116
|
n.isPending = !0;
|
|
99
117
|
return;
|
|
100
118
|
}
|
|
101
119
|
let r = n, i = new AbortController();
|
|
102
120
|
r.isRefreshing = !0, r.controller = i, (async () => {
|
|
103
121
|
try {
|
|
104
|
-
let e = await
|
|
122
|
+
let e = await P(t, i.signal);
|
|
105
123
|
if (i.signal.aborted) return;
|
|
106
|
-
let n =
|
|
107
|
-
|
|
124
|
+
let n = F(e);
|
|
125
|
+
C((e) => {
|
|
108
126
|
if (!e.snapshots.has(t)) return e;
|
|
109
127
|
let r = new Map(e.snapshots);
|
|
110
128
|
return r.set(t, n), {
|
|
@@ -114,33 +132,33 @@ var l = 10, u = 1e3, d = [
|
|
|
114
132
|
});
|
|
115
133
|
} catch (n) {
|
|
116
134
|
if (i.signal.aborted) return;
|
|
117
|
-
e(n) === 404 && (
|
|
135
|
+
e(n) === 404 && (R(t), I(t));
|
|
118
136
|
} finally {
|
|
119
|
-
r.isRefreshing = !1, r.isPending && !i.signal.aborted &&
|
|
137
|
+
r.isRefreshing = !1, r.isPending && !i.signal.aborted && O.current.get(t) === r && (r.isPending = !1, z(t));
|
|
120
138
|
}
|
|
121
139
|
})();
|
|
122
140
|
}, [
|
|
123
|
-
|
|
124
|
-
M,
|
|
141
|
+
R,
|
|
125
142
|
P,
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
I,
|
|
144
|
+
F
|
|
145
|
+
]), B = i((t, n, r = 0) => {
|
|
128
146
|
let i = () => {
|
|
129
|
-
|
|
147
|
+
D.current.get(t) === n && D.current.delete(t);
|
|
130
148
|
};
|
|
131
149
|
(async () => {
|
|
132
150
|
try {
|
|
133
|
-
let e = await
|
|
151
|
+
let e = await P(t, n.signal);
|
|
134
152
|
if (n.signal.aborted) return;
|
|
135
|
-
let r =
|
|
136
|
-
|
|
153
|
+
let r = F(e);
|
|
154
|
+
C((e) => {
|
|
137
155
|
let n = new Map(e.snapshots);
|
|
138
156
|
n.set(t, r);
|
|
139
157
|
let i = new Set(e.settled).add(t);
|
|
140
158
|
return {
|
|
141
159
|
snapshots: n,
|
|
142
160
|
settled: i,
|
|
143
|
-
watchKey:
|
|
161
|
+
watchKey: g(E.current, {
|
|
144
162
|
settled: i,
|
|
145
163
|
snapshots: n
|
|
146
164
|
}, e.watchKey)
|
|
@@ -148,13 +166,13 @@ var l = 10, u = 1e3, d = [
|
|
|
148
166
|
}), i();
|
|
149
167
|
} catch (a) {
|
|
150
168
|
if (n.signal.aborted) return;
|
|
151
|
-
|
|
169
|
+
C((e) => {
|
|
152
170
|
if (e.settled.has(t)) return e;
|
|
153
171
|
let n = new Set(e.settled).add(t);
|
|
154
172
|
return {
|
|
155
173
|
...e,
|
|
156
174
|
settled: n,
|
|
157
|
-
watchKey:
|
|
175
|
+
watchKey: g(E.current, {
|
|
158
176
|
settled: n,
|
|
159
177
|
snapshots: e.snapshots
|
|
160
178
|
}, e.watchKey)
|
|
@@ -162,74 +180,74 @@ var l = 10, u = 1e3, d = [
|
|
|
162
180
|
});
|
|
163
181
|
let o = e(a) === 404, s = o ? void 0 : d[r];
|
|
164
182
|
if (s == null) {
|
|
165
|
-
i(), o &&
|
|
183
|
+
i(), o && I(t);
|
|
166
184
|
return;
|
|
167
185
|
}
|
|
168
|
-
let c = setTimeout(() =>
|
|
186
|
+
let c = setTimeout(() => B(t, n, r + 1), s);
|
|
169
187
|
n.signal.addEventListener("abort", () => clearTimeout(c), { once: !0 });
|
|
170
188
|
}
|
|
171
189
|
})();
|
|
172
190
|
}, [
|
|
173
|
-
M,
|
|
174
191
|
P,
|
|
175
|
-
|
|
192
|
+
I,
|
|
193
|
+
F
|
|
176
194
|
]);
|
|
177
195
|
a(() => () => {
|
|
178
|
-
for (let e of
|
|
179
|
-
|
|
180
|
-
for (let e of
|
|
181
|
-
|
|
182
|
-
}, [l,
|
|
183
|
-
if (!
|
|
184
|
-
let e = new Set(
|
|
185
|
-
for (let t of [...
|
|
186
|
-
let n =
|
|
196
|
+
for (let e of D.current.values()) e.abort();
|
|
197
|
+
D.current.clear();
|
|
198
|
+
for (let e of O.current.values()) e.controller?.abort();
|
|
199
|
+
O.current.clear(), E.current.clear(), k.current.clear(), A.current.clear(), j.current.clear(), C(p);
|
|
200
|
+
}, [l, y]), a(() => {
|
|
201
|
+
if (!y) return;
|
|
202
|
+
let e = new Set(N === "" ? [] : N.split(f));
|
|
203
|
+
for (let t of [...E.current]) e.has(t) || (E.current.delete(t), k.current.delete(t), D.current.get(t)?.abort(), D.current.delete(t), L(t), C((e) => {
|
|
204
|
+
let n = _(e, t);
|
|
187
205
|
return {
|
|
188
206
|
...n,
|
|
189
|
-
watchKey:
|
|
207
|
+
watchKey: g(E.current, n, e.watchKey)
|
|
190
208
|
};
|
|
191
209
|
}));
|
|
192
210
|
for (let t of e) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
211
|
+
if (E.current.has(t)) continue;
|
|
212
|
+
E.current.add(t);
|
|
195
213
|
let e = new AbortController();
|
|
196
|
-
|
|
214
|
+
D.current.set(t, e), B(t, e);
|
|
197
215
|
}
|
|
198
216
|
}, [
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
217
|
+
y,
|
|
218
|
+
N,
|
|
219
|
+
L,
|
|
220
|
+
B
|
|
203
221
|
]);
|
|
204
|
-
let
|
|
222
|
+
let V = y && N !== "" && N.split(f).some((e) => !S.settled.has(e)), H = y ? S.watchKey : "", { watchProjects: U } = l;
|
|
205
223
|
a(() => {
|
|
206
|
-
if (
|
|
224
|
+
if (U == null || H === "" || H === M.current) return;
|
|
207
225
|
let e = new AbortController();
|
|
208
226
|
return t({
|
|
209
|
-
watchProjects:
|
|
210
|
-
ids:
|
|
227
|
+
watchProjects: U,
|
|
228
|
+
ids: H.split(f),
|
|
211
229
|
signal: e.signal,
|
|
212
230
|
onEvent: (t) => {
|
|
213
231
|
if (e.signal.aborted) return;
|
|
214
|
-
let n =
|
|
215
|
-
n != null && (t.action === r.Delete ? (
|
|
232
|
+
let n = w.current.snapshots.get(t.id);
|
|
233
|
+
n != null && (t.action === r.Delete ? (R(t.id), I(t.id)) : (t.etag == null || t.etag !== n.project.etag) && z(t.id));
|
|
216
234
|
},
|
|
217
235
|
onReconnected: () => {
|
|
218
|
-
for (let e of
|
|
236
|
+
for (let e of w.current.snapshots.keys()) z(e);
|
|
219
237
|
},
|
|
220
238
|
onUnavailable: () => {
|
|
221
|
-
|
|
239
|
+
M.current = H;
|
|
222
240
|
}
|
|
223
241
|
}), () => e.abort();
|
|
224
242
|
}, [
|
|
225
|
-
|
|
226
|
-
|
|
243
|
+
U,
|
|
244
|
+
H,
|
|
245
|
+
R,
|
|
227
246
|
I,
|
|
228
|
-
|
|
229
|
-
L
|
|
247
|
+
z
|
|
230
248
|
]);
|
|
231
|
-
let
|
|
232
|
-
|
|
249
|
+
let W = i((e) => {
|
|
250
|
+
j.current.has(e) && (A.current.set(e, j.current.get(e)), C((t) => {
|
|
233
251
|
let n;
|
|
234
252
|
for (let [r, i] of t.snapshots) i.chats.some((t) => t.id === e && t.isUnread) && (n ??= new Map(t.snapshots), n.set(r, {
|
|
235
253
|
...i,
|
|
@@ -243,27 +261,65 @@ var l = 10, u = 1e3, d = [
|
|
|
243
261
|
snapshots: n
|
|
244
262
|
} : t;
|
|
245
263
|
}));
|
|
246
|
-
}, [])
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
])
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
}, []), G = o(() => {
|
|
265
|
+
if (!y) return m;
|
|
266
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
267
|
+
for (let n of u) {
|
|
268
|
+
if (e.has(n)) continue;
|
|
269
|
+
e.add(n);
|
|
270
|
+
let r = S.snapshots.get(n);
|
|
271
|
+
r && t.push(h(r, x));
|
|
272
|
+
}
|
|
273
|
+
return t;
|
|
274
|
+
}, [
|
|
275
|
+
y,
|
|
276
|
+
u,
|
|
277
|
+
S.snapshots,
|
|
278
|
+
x
|
|
279
|
+
]), K = o(() => {
|
|
280
|
+
if (y && x != null) for (let [e, t] of S.snapshots) {
|
|
281
|
+
let n = t.overflow.find((e) => e.id === x && e.isTitlePending);
|
|
282
|
+
if (n != null) return {
|
|
283
|
+
projectId: e,
|
|
284
|
+
name: n.name
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
}, [
|
|
288
|
+
y,
|
|
289
|
+
x,
|
|
290
|
+
S.snapshots
|
|
291
|
+
]), q = K?.projectId, J = K?.name;
|
|
292
|
+
return a(() => {
|
|
293
|
+
if (q == null || J == null) return;
|
|
294
|
+
let e = new AbortController();
|
|
295
|
+
return (async () => {
|
|
296
|
+
try {
|
|
297
|
+
let { items: t } = await l.getProjectConversationTitles(q, [J], e.signal);
|
|
298
|
+
if (e.signal.aborted) return;
|
|
299
|
+
C((e) => {
|
|
300
|
+
let n = e.snapshots.get(q);
|
|
301
|
+
if (n == null) return e;
|
|
302
|
+
let r = new Map(e.snapshots);
|
|
303
|
+
return r.set(q, {
|
|
304
|
+
...n,
|
|
305
|
+
overflow: v(n.overflow, t)
|
|
306
|
+
}), {
|
|
307
|
+
...e,
|
|
308
|
+
snapshots: r
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
} catch {}
|
|
312
|
+
})(), () => e.abort();
|
|
313
|
+
}, [
|
|
314
|
+
l,
|
|
315
|
+
q,
|
|
316
|
+
J
|
|
317
|
+
]), {
|
|
318
|
+
projects: G,
|
|
319
|
+
isLoading: V,
|
|
320
|
+
markViewed: W,
|
|
321
|
+
refresh: z
|
|
266
322
|
};
|
|
267
323
|
};
|
|
268
324
|
//#endregion
|
|
269
|
-
export { l as PINNED_PROJECT_CHATS_LIMIT,
|
|
325
|
+
export { l as PINNED_PROJECT_CHATS_LIMIT, y as usePinnedProjectChats };
|
|
@@ -1 +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;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA8E/D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,IAAI,CACV,iBAAiB,EACf,0BAA0B,GAC1B,8BAA8B,GAC9B,2BAA2B,GAC3B,kCAAkC,GAClC,2BAA2B,GAC3B,+BAA+B,CAClC,EACD,WAAW,MAAM,GAAG,IAAI;;;;
|
|
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;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA8E/D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,IAAI,CACV,iBAAiB,EACf,0BAA0B,GAC1B,8BAA8B,GAC9B,2BAA2B,GAC3B,kCAAkC,GAClC,2BAA2B,GAC3B,+BAA+B,CAClC,EACD,WAAW,MAAM,GAAG,IAAI;;;;IA4OtB,8CAA8C;;IAE9C,2DAA2D;;;;iBAzDhD,MAAM,YAAY,MAAM;wBAoBxB,MAAM;iBAQN,MAAM;;qBAjDZ,MAAM;CAwFd,CAAC"}
|
|
@@ -167,8 +167,8 @@ var o = 20, s = 100, c = {
|
|
|
167
167
|
title: r,
|
|
168
168
|
isTitlePending: !1
|
|
169
169
|
} : e)
|
|
170
|
-
}));
|
|
171
|
-
}, [e]), M = t(async (t) => {
|
|
170
|
+
})), k();
|
|
171
|
+
}, [e, k]), M = t(async (t) => {
|
|
172
172
|
let { name: n } = await e.generateProjectConversationTitle(t);
|
|
173
173
|
return n;
|
|
174
174
|
}, [e]), N = t(async (t) => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProjectDetailsDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
/** Host behaviour the removal delegates to. */
|
|
3
|
+
export interface ProjectRemoveFromListHandlers {
|
|
4
|
+
/** Discards the caller's own access to the project; rejects on failure. */
|
|
5
|
+
discardShared: (projectId: string) => Promise<unknown>;
|
|
6
|
+
/** Persists the pin state; rejects on failure. */
|
|
7
|
+
setPinned: (projectId: string, isPinned: boolean) => Promise<void>;
|
|
8
|
+
/** Called when the unpin could not be saved, so the host can mirror it locally and the entry still leaves the sidebar. */
|
|
9
|
+
onUnpinFailed?: (project: ProjectDetailsDto) => void;
|
|
10
|
+
/** Called after the project left the caller's list; the host notifies and navigates away. */
|
|
11
|
+
onRemoved: (project: ProjectDetailsDto) => void;
|
|
12
|
+
/** Called when the discard failed, with the request's trace id; the host shows the message. */
|
|
13
|
+
onError: (project: ProjectDetailsDto, requestId?: string) => void;
|
|
14
|
+
/** Called once the request settles, whether it succeeded or failed, so the host can close its confirmation. */
|
|
15
|
+
onSettled?: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Drops a project shared with the caller from their own list: discards only
|
|
19
|
+
* the caller's access, then unpins it. The owner's project and the other
|
|
20
|
+
* recipients' access are untouched. Messages, notifications and navigation
|
|
21
|
+
* stay with the host through `handlers`.
|
|
22
|
+
*
|
|
23
|
+
* @param project - The project to remove, or `null` while none is chosen.
|
|
24
|
+
* @param handlers - Host behaviour the removal delegates to.
|
|
25
|
+
*/
|
|
26
|
+
export declare const useProjectRemoveFromList: (project: ProjectDetailsDto | null, { discardShared, setPinned, onUnpinFailed, onRemoved, onError, onSettled, }: ProjectRemoveFromListHandlers) => {
|
|
27
|
+
isRemoving: boolean;
|
|
28
|
+
confirmRemove: () => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=use-project-remove-from-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-project-remove-from-list.d.ts","sourceRoot":"","sources":["../../src/project/use-project-remove-from-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAIvE,+CAA+C;AAC/C,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,kDAAkD;IAClD,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,0HAA0H;IAC1H,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACrD,6FAA6F;IAC7F,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,+FAA+F;IAC/F,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,+GAA+G;IAC/G,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,iBAAiB,GAAG,IAAI,EACjC,6EAOG,6BAA6B;;;CA0CjC,CAAC"}
|