@epam/ai-dial-chat-hooks 1.3.0-dev.294 → 1.3.0-dev.304
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/application-credentials.d.ts.map +1 -1
- package/catalog/application-credentials.js +20 -25
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.d.ts.map +1 -1
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +72 -77
- package/conversation/useConversationScroll/useConversationScroll.d.ts.map +1 -1
- package/conversation/useConversationScroll/useConversationScroll.js +64 -63
- package/external-services/useExternalServiceLogin.d.ts +3 -13
- package/external-services/useExternalServiceLogin.d.ts.map +1 -1
- package/external-services/useExternalServiceLogin.js +49 -58
- package/index.js +168 -168
- package/mcp-apps/useMcpAppTools/useMcpAppTools.d.ts.map +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +42 -39
- package/oauth/authorize-url.d.ts +7 -1
- package/oauth/authorize-url.d.ts.map +1 -1
- package/oauth/authorize-url.js +13 -3
- package/oauth/models.d.ts +25 -0
- package/oauth/models.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +1 -1
- package/oauth/useToolsetLogin/useToolsetLogin.js +45 -56
- package/oauth.js +7 -7
- package/package.json +17 -17
- package/project/projects-api-client.d.ts +9 -11
- package/project/projects-api-client.d.ts.map +1 -1
- package/project/projects-api-client.js +4 -3
- package/project/use-project-conversations.d.ts +15 -13
- package/project/use-project-conversations.d.ts.map +1 -1
- package/project/use-project-conversations.js +127 -110
|
@@ -1,182 +1,199 @@
|
|
|
1
|
-
import { useCallback as e, useEffect as t,
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
2
|
//#region src/project/use-project-conversations.ts
|
|
3
|
-
var
|
|
4
|
-
|
|
3
|
+
var a = 20, o = 100, s = {
|
|
4
|
+
rows: [],
|
|
5
|
+
visibleCount: a,
|
|
5
6
|
isLoading: !0,
|
|
6
7
|
hasError: !1,
|
|
7
|
-
hasMore: !1,
|
|
8
8
|
isLoadingMore: !1
|
|
9
|
-
},
|
|
10
|
-
...
|
|
9
|
+
}, c = {
|
|
10
|
+
...s,
|
|
11
11
|
isLoading: !1
|
|
12
|
-
},
|
|
13
|
-
let
|
|
12
|
+
}, l = (e, t) => e.map(({ id: e, name: n, title: r, author: i, updatedAt: a, isUnread: o, isTitlePending: s }) => {
|
|
13
|
+
let c = o;
|
|
14
14
|
if (t.has(e)) {
|
|
15
15
|
let n = t.get(e);
|
|
16
|
-
|
|
16
|
+
a != null && n != null && a > n ? t.delete(e) : c = !1;
|
|
17
17
|
}
|
|
18
18
|
return {
|
|
19
19
|
id: e,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
name: n,
|
|
21
|
+
title: r,
|
|
22
|
+
authorName: i,
|
|
23
|
+
isTitlePending: s === !0,
|
|
24
|
+
...c ? { isUnread: !0 } : {}
|
|
23
25
|
};
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
+
}), u = (e, t) => {
|
|
27
|
+
if (t.length === 0) return e;
|
|
28
|
+
let n = new Map(t.map((e) => [e.id, e]));
|
|
29
|
+
return e.map((e) => n.get(e.id) ?? e);
|
|
30
|
+
}, d = ({ id: e, title: t, authorName: n, isUnread: r }) => ({
|
|
31
|
+
id: e,
|
|
32
|
+
title: t,
|
|
33
|
+
authorName: n,
|
|
34
|
+
...r ? { isUnread: !0 } : {}
|
|
35
|
+
}), f = (f, p) => {
|
|
36
|
+
let [m, h] = i(s), [g, _] = i(0), v = r(null), y = r(null), b = r(!1), x = r(/* @__PURE__ */ new Map()), S = r(/* @__PURE__ */ new Map()), C = r(m);
|
|
26
37
|
t(() => {
|
|
27
|
-
|
|
38
|
+
C.current = m;
|
|
28
39
|
});
|
|
29
|
-
let
|
|
30
|
-
for (let { id: t, updatedAt: n } of e)
|
|
31
|
-
}, [])
|
|
40
|
+
let w = e((e) => {
|
|
41
|
+
for (let { id: t, updatedAt: n } of e) S.current.set(t, n);
|
|
42
|
+
}, []), T = e(async (e, t) => {
|
|
43
|
+
if (p == null) return [];
|
|
44
|
+
let n = e.filter((e) => e.isTitlePending).map((e) => e.name), r = [];
|
|
45
|
+
for (let e = 0; e < n.length; e += o) {
|
|
46
|
+
let { items: i } = await f.getProjectConversationTitles(p, n.slice(e, e + o), t);
|
|
47
|
+
r.push(...i);
|
|
48
|
+
}
|
|
49
|
+
return w(r), l(r, x.current);
|
|
50
|
+
}, [
|
|
51
|
+
f,
|
|
52
|
+
p,
|
|
53
|
+
w
|
|
54
|
+
]), E = e(async (e, t, n) => {
|
|
55
|
+
try {
|
|
56
|
+
let r = await T(e.slice(0, t), n);
|
|
57
|
+
if (n.aborted) return;
|
|
58
|
+
h((e) => ({
|
|
59
|
+
...e,
|
|
60
|
+
rows: u(e.rows, r)
|
|
61
|
+
}));
|
|
62
|
+
} catch {}
|
|
63
|
+
}, [T]);
|
|
32
64
|
t(() => {
|
|
33
|
-
if (
|
|
34
|
-
|
|
65
|
+
if (x.current = /* @__PURE__ */ new Map(), S.current = /* @__PURE__ */ new Map(), p == null) {
|
|
66
|
+
h(c);
|
|
35
67
|
return;
|
|
36
68
|
}
|
|
37
69
|
let e = new AbortController();
|
|
38
|
-
return
|
|
39
|
-
|
|
70
|
+
return v.current = e, (async () => {
|
|
71
|
+
h((e) => ({
|
|
40
72
|
...e,
|
|
41
73
|
isLoading: !0,
|
|
42
74
|
hasError: !1,
|
|
43
75
|
isLoadingMore: !1
|
|
44
76
|
}));
|
|
45
77
|
try {
|
|
46
|
-
let t = await
|
|
78
|
+
let { items: t } = await f.listProjectConversations(p, e.signal);
|
|
47
79
|
if (e.signal.aborted) return;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
hasError: !1,
|
|
52
|
-
hasMore: t.hasMore,
|
|
53
|
-
isLoadingMore: !1
|
|
80
|
+
w(t), h({
|
|
81
|
+
...c,
|
|
82
|
+
rows: l(t, x.current)
|
|
54
83
|
});
|
|
55
84
|
} catch {
|
|
56
85
|
if (e.signal.aborted) return;
|
|
57
|
-
|
|
58
|
-
...
|
|
86
|
+
h({
|
|
87
|
+
...c,
|
|
59
88
|
hasError: !0
|
|
60
89
|
});
|
|
61
90
|
}
|
|
62
91
|
})(), () => {
|
|
63
|
-
e.abort(),
|
|
92
|
+
e.abort(), y.current?.abort();
|
|
64
93
|
};
|
|
65
94
|
}, [
|
|
66
|
-
|
|
67
|
-
u,
|
|
95
|
+
f,
|
|
68
96
|
p,
|
|
69
|
-
|
|
97
|
+
g,
|
|
98
|
+
w
|
|
70
99
|
]);
|
|
71
|
-
let
|
|
72
|
-
let e =
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
let D = e(() => _((e) => e + 1), []), O = e(async () => {
|
|
101
|
+
let e = v.current, t = C.current;
|
|
102
|
+
if (p == null || e == null || b.current) return;
|
|
103
|
+
b.current = !0;
|
|
104
|
+
let n = t.visibleCount + a, r = t.rows.slice(t.visibleCount, n);
|
|
105
|
+
h((e) => ({
|
|
76
106
|
...e,
|
|
77
107
|
isLoadingMore: !0
|
|
78
108
|
}));
|
|
79
109
|
try {
|
|
80
|
-
let
|
|
110
|
+
let t = await T(r, e.signal);
|
|
81
111
|
if (e.signal.aborted) return;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
x(n.items), f((e) => {
|
|
90
|
-
let t = new Set(e.items.map((e) => e.id));
|
|
91
|
-
return {
|
|
92
|
-
...e,
|
|
93
|
-
items: [...e.items, ...c(n.items, v.current).filter((e) => !t.has(e.id))],
|
|
94
|
-
hasMore: n.hasMore,
|
|
95
|
-
isLoadingMore: !1
|
|
96
|
-
};
|
|
97
|
-
});
|
|
112
|
+
h((e) => ({
|
|
113
|
+
...e,
|
|
114
|
+
rows: u(e.rows, t),
|
|
115
|
+
visibleCount: Math.max(e.visibleCount, n),
|
|
116
|
+
isLoadingMore: !1
|
|
117
|
+
}));
|
|
98
118
|
} catch (t) {
|
|
99
119
|
if (e.signal.aborted) return;
|
|
100
|
-
throw
|
|
120
|
+
throw h((e) => ({
|
|
101
121
|
...e,
|
|
102
122
|
isLoadingMore: !1
|
|
103
123
|
})), t;
|
|
124
|
+
} finally {
|
|
125
|
+
b.current = !1;
|
|
104
126
|
}
|
|
105
|
-
}, [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
d.items.length
|
|
110
|
-
]), w = e(async () => {
|
|
111
|
-
let e = b.current;
|
|
112
|
-
if (u == null || e.isLoading || e.hasError) return;
|
|
113
|
-
g.current?.abort();
|
|
127
|
+
}, [p, T]), k = e(async () => {
|
|
128
|
+
let e = C.current;
|
|
129
|
+
if (p == null || e.isLoading || e.hasError) return;
|
|
130
|
+
y.current?.abort();
|
|
114
131
|
let t = new AbortController();
|
|
115
|
-
|
|
116
|
-
let n
|
|
132
|
+
y.current = t;
|
|
133
|
+
let n;
|
|
117
134
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
limit: Math.min(s, n - r.length)
|
|
122
|
-
});
|
|
123
|
-
if (t.signal.aborted) return;
|
|
124
|
-
if (r.push(...e.items), i = e.hasMore, e.items.length === 0) break;
|
|
125
|
-
}
|
|
135
|
+
let { items: e } = await f.listProjectConversations(p, t.signal);
|
|
136
|
+
if (t.signal.aborted) return;
|
|
137
|
+
w(e), n = l(e, x.current);
|
|
126
138
|
} catch {
|
|
127
139
|
return;
|
|
128
140
|
}
|
|
129
|
-
|
|
130
|
-
x(r);
|
|
131
|
-
let a = /* @__PURE__ */ new Set(), d = c(r, v.current).filter((e) => !a.has(e.id) && (a.add(e.id), !0));
|
|
132
|
-
f((e) => ({
|
|
141
|
+
h((e) => ({
|
|
133
142
|
...e,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
isLoadingMore: !1
|
|
137
|
-
}));
|
|
143
|
+
rows: n
|
|
144
|
+
})), await E(n, C.current.visibleCount, t.signal);
|
|
138
145
|
}, [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
146
|
+
f,
|
|
147
|
+
E,
|
|
148
|
+
p,
|
|
149
|
+
w
|
|
142
150
|
]);
|
|
143
|
-
t(() => () =>
|
|
144
|
-
let
|
|
145
|
-
|
|
151
|
+
t(() => () => y.current?.abort(), []);
|
|
152
|
+
let A = e((e) => {
|
|
153
|
+
x.current.set(e, S.current.get(e)), h((t) => ({
|
|
146
154
|
...t,
|
|
147
|
-
|
|
155
|
+
rows: t.rows.map((t) => t.id === e && t.isUnread ? {
|
|
148
156
|
...t,
|
|
149
157
|
isUnread: !1
|
|
150
158
|
} : t)
|
|
151
159
|
})), (async () => {
|
|
152
160
|
try {
|
|
153
|
-
await
|
|
161
|
+
await f.markProjectConversationViewed?.(e);
|
|
154
162
|
} catch {}
|
|
155
163
|
})();
|
|
156
|
-
}, [
|
|
157
|
-
let { name: n } = await
|
|
158
|
-
|
|
164
|
+
}, [f]), j = e(async (e, t) => {
|
|
165
|
+
let { name: n } = await f.renameProjectConversation(e, t);
|
|
166
|
+
h((t) => ({
|
|
159
167
|
...t,
|
|
160
|
-
|
|
168
|
+
rows: t.rows.map((t) => t.id === e ? {
|
|
161
169
|
...t,
|
|
162
|
-
title: n
|
|
170
|
+
title: n,
|
|
171
|
+
isTitlePending: !1
|
|
163
172
|
} : t)
|
|
164
173
|
}));
|
|
165
|
-
}, [
|
|
166
|
-
await
|
|
174
|
+
}, [f]), M = e(async (e) => {
|
|
175
|
+
await f.deleteProjectConversation(e);
|
|
176
|
+
let { rows: t, visibleCount: n } = C.current, r = t.filter((t) => t.id !== e);
|
|
177
|
+
h((t) => ({
|
|
167
178
|
...t,
|
|
168
|
-
|
|
179
|
+
rows: t.rows.filter((t) => t.id !== e)
|
|
169
180
|
}));
|
|
170
|
-
|
|
181
|
+
let i = v.current;
|
|
182
|
+
i != null && E(r, n, i.signal);
|
|
183
|
+
}, [f, E]), { rows: N, visibleCount: P, isLoading: F, hasError: I, isLoadingMore: L } = m;
|
|
171
184
|
return {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
items: n(() => N.slice(0, P).map(d), [N, P]),
|
|
186
|
+
isLoading: F,
|
|
187
|
+
hasError: I,
|
|
188
|
+
hasMore: P < N.length,
|
|
189
|
+
isLoadingMore: L,
|
|
190
|
+
retry: D,
|
|
191
|
+
loadMore: O,
|
|
192
|
+
rename: j,
|
|
193
|
+
remove: M,
|
|
194
|
+
refresh: k,
|
|
195
|
+
markViewed: A
|
|
179
196
|
};
|
|
180
197
|
};
|
|
181
198
|
//#endregion
|
|
182
|
-
export {
|
|
199
|
+
export { f as useProjectConversations };
|