@epam/ai-dial-chat-hooks 1.2.0-dev.287 → 1.2.0-dev.288
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.
|
@@ -1,159 +1,167 @@
|
|
|
1
1
|
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
-
import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as
|
|
3
|
-
import { getConversationPath as
|
|
4
|
-
import { applyChunkToMessages as
|
|
5
|
-
import { restoreBufferedMessage as
|
|
6
|
-
import { createResumeIfAwaitingGeneration as
|
|
7
|
-
import { createFrameScheduler as
|
|
8
|
-
import { MessageRole as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { SendCompletionDtoModeEnum as
|
|
2
|
+
import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as ee, StreamUpstreamError as a } from "../create-chat-stream-api.js";
|
|
3
|
+
import { getConversationPath as o } from "./conversation-path.js";
|
|
4
|
+
import { applyChunkToMessages as s } from "./apply-chunk.js";
|
|
5
|
+
import { restoreBufferedMessage as c } from "./buffered-generation.js";
|
|
6
|
+
import { createResumeIfAwaitingGeneration as te, fetchConversationForRecovery as ne, findPendingBackgroundMessageIndex as l, hasGeneratedPayload as re, isAwaitingGenerationResume as u } from "./generation-resume.js";
|
|
7
|
+
import { createFrameScheduler as ie } from "./frame-scheduler.js";
|
|
8
|
+
import { MessageRole as d, generateUUID as ae } from "@epam/ai-dial-chat-shared";
|
|
9
|
+
import { useCallback as f, useEffect as p, useMemo as oe, useRef as m, useState as h } from "react";
|
|
10
|
+
import { SendCompletionDtoModeEnum as g } from "@epam/ai-dial-chat-api-client";
|
|
11
11
|
//#region src/conversation/useConversationStream/useConversationStream.ts
|
|
12
|
-
var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof
|
|
12
|
+
var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof a ? e.message : "", _ = (e) => {
|
|
13
13
|
if (!e) return;
|
|
14
|
-
let t =
|
|
14
|
+
let t = l(e);
|
|
15
15
|
return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
|
|
16
|
-
}, v = ({ conversationId:
|
|
17
|
-
let O =
|
|
18
|
-
|
|
16
|
+
}, v = ({ conversationId: a, state: { setConversation: v, conversationRef: y }, transport: b, generation: { startGeneration: le, completeGeneration: x }, channel: S, overlay: C, onStopError: w, generationConflictMessage: ue = t, generationPersistenceErrorMessage: T = n, onStreamError: E, batchChunksPerFrame: D = !1 }) => {
|
|
17
|
+
let O = m(E);
|
|
18
|
+
p(() => {
|
|
19
19
|
O.current = E;
|
|
20
20
|
}, [E]);
|
|
21
|
-
let de =
|
|
22
|
-
|
|
21
|
+
let de = m(D);
|
|
22
|
+
p(() => {
|
|
23
23
|
de.current = D;
|
|
24
24
|
}, [D]);
|
|
25
|
-
let [k] =
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
let [k] = h(ie), [A, j] = h(() => /* @__PURE__ */ new Set()), [M, N] = h(() => /* @__PURE__ */ new Set()), P = m(/* @__PURE__ */ new Map()), F = m(/* @__PURE__ */ new Set()), I = m(/* @__PURE__ */ new Map()), L = m(/* @__PURE__ */ new Set()), fe = m(/* @__PURE__ */ new Map()), R = m(!0), z = m(/* @__PURE__ */ new Map()), [B, V] = h(z.current), H = m(/* @__PURE__ */ new Set()), [pe, U] = h(H.current);
|
|
26
|
+
p(() => (R.current = !0, () => {
|
|
27
|
+
R.current = !1;
|
|
28
28
|
}), []);
|
|
29
|
-
let
|
|
30
|
-
if (!
|
|
31
|
-
let t = new Map(
|
|
32
|
-
t.delete(e),
|
|
33
|
-
}, []),
|
|
34
|
-
if (!
|
|
35
|
-
let r = new Map(
|
|
29
|
+
let W = f((e) => {
|
|
30
|
+
if (!z.current.has(e)) return;
|
|
31
|
+
let t = new Map(z.current);
|
|
32
|
+
t.delete(e), z.current = t, R.current && V(t);
|
|
33
|
+
}, []), G = f((e, t, n) => {
|
|
34
|
+
if (!R.current || !n()) return;
|
|
35
|
+
let r = new Map(z.current);
|
|
36
36
|
r.set(e, {
|
|
37
37
|
retry: t,
|
|
38
38
|
isCurrent: n
|
|
39
|
-
}),
|
|
40
|
-
}, []),
|
|
41
|
-
if (!
|
|
42
|
-
let e =
|
|
43
|
-
if (!(!e || !e.isCurrent() ||
|
|
44
|
-
|
|
39
|
+
}), z.current = r, V(r);
|
|
40
|
+
}, []), K = f(async () => {
|
|
41
|
+
if (!a) return;
|
|
42
|
+
let e = z.current.get(o(a));
|
|
43
|
+
if (!(!e || !e.isCurrent() || H.current.has(e))) {
|
|
44
|
+
H.current.add(e), U(new Set(H.current));
|
|
45
45
|
try {
|
|
46
46
|
await e.retry();
|
|
47
47
|
} finally {
|
|
48
|
-
|
|
48
|
+
H.current.delete(e), R.current && U(new Set(H.current));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
|
|
51
|
+
}, [a]), me = m(a);
|
|
52
|
+
p(() => (me.current = a, () => k.cancelAll()), [a, k]);
|
|
53
|
+
let q = f((e) => R.current && o(me.current ?? "") === e, []), J = f((e) => {
|
|
54
|
+
W(e), j((t) => {
|
|
55
55
|
if (t.has(e)) return t;
|
|
56
56
|
let n = new Set(t);
|
|
57
57
|
return n.add(e), n;
|
|
58
58
|
});
|
|
59
|
-
}, [
|
|
59
|
+
}, [W]), Y = f((e) => {
|
|
60
60
|
j((t) => {
|
|
61
61
|
if (!t.has(e)) return t;
|
|
62
62
|
let n = new Set(t);
|
|
63
63
|
return n.delete(e), n;
|
|
64
64
|
});
|
|
65
|
-
}, []),
|
|
65
|
+
}, []), X = f((e, t) => {
|
|
66
|
+
N((n) => {
|
|
67
|
+
if (n.has(e) === t) return n;
|
|
68
|
+
let r = new Set(n);
|
|
69
|
+
return t ? r.add(e) : r.delete(e), r;
|
|
70
|
+
});
|
|
71
|
+
}, []), he = f((e, t) => {
|
|
72
|
+
P.current.get(e) === t && (P.current.delete(e), X(e, !1));
|
|
73
|
+
}, [X]), Z = oe(() => te({
|
|
66
74
|
transport: b,
|
|
67
75
|
setConversation: v,
|
|
68
76
|
conversationRef: y,
|
|
69
|
-
resumingPathsRef:
|
|
70
|
-
bufferedGenerationsRef:
|
|
71
|
-
addStreamingPath:
|
|
72
|
-
removeStreamingPath:
|
|
73
|
-
isPathDisplayed:
|
|
77
|
+
resumingPathsRef: F,
|
|
78
|
+
bufferedGenerationsRef: I,
|
|
79
|
+
addStreamingPath: J,
|
|
80
|
+
removeStreamingPath: Y,
|
|
81
|
+
isPathDisplayed: q,
|
|
74
82
|
generationPersistenceErrorMessage: T,
|
|
75
83
|
frameScheduler: D ? k : void 0,
|
|
76
|
-
stoppedGenerationIdsRef:
|
|
77
|
-
onReloadError:
|
|
78
|
-
onReloadSuccess:
|
|
84
|
+
stoppedGenerationIdsRef: L,
|
|
85
|
+
onReloadError: G,
|
|
86
|
+
onReloadSuccess: W
|
|
79
87
|
}), [
|
|
80
|
-
|
|
81
|
-
Z,
|
|
88
|
+
J,
|
|
82
89
|
Y,
|
|
90
|
+
q,
|
|
83
91
|
b,
|
|
84
92
|
T,
|
|
85
93
|
D,
|
|
86
94
|
k,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
]),
|
|
90
|
-
let
|
|
91
|
-
k.flush(
|
|
95
|
+
G,
|
|
96
|
+
W
|
|
97
|
+
]), ge = f((t, n, a, te, ie, f, p = g.Append, oe = {}) => {
|
|
98
|
+
let m = f ?? ae(), h = o(t);
|
|
99
|
+
k.flush(h), F.current.delete(h), P.current.set(h, m), fe.current.set(h, m), X(h, !0);
|
|
92
100
|
let _;
|
|
93
|
-
|
|
94
|
-
let w = () => fe.current.get(
|
|
95
|
-
D ?
|
|
96
|
-
generationId:
|
|
97
|
-
messageIndex:
|
|
101
|
+
p === g.Regenerate ? _ = a : p === g.Edit && (_ = a - 1);
|
|
102
|
+
let w = () => fe.current.get(h) !== m, E = le(h, m), D = y.current?.messages[a];
|
|
103
|
+
D ? I.current.set(h, {
|
|
104
|
+
generationId: m,
|
|
105
|
+
messageIndex: a,
|
|
98
106
|
message: D
|
|
99
|
-
}) :
|
|
107
|
+
}) : I.current.delete(h), J(h), C?.notifyGenerationStart?.(), S?.ensureConnected();
|
|
100
108
|
let A = () => {
|
|
101
|
-
w() ||
|
|
109
|
+
w() || Y(h), he(h, m), x(h, m), S?.notifyGenerationSettled?.();
|
|
102
110
|
}, j = () => {
|
|
103
111
|
if (w()) return;
|
|
104
|
-
let e =
|
|
105
|
-
!e || e.generationId !==
|
|
112
|
+
let e = I.current.get(h);
|
|
113
|
+
!e || e.generationId !== m || (e.message = {
|
|
106
114
|
...e.message,
|
|
107
115
|
streamErrorMessage: T
|
|
108
|
-
}, O.current?.(new i()),
|
|
109
|
-
if (!t || w() || !
|
|
110
|
-
let n =
|
|
116
|
+
}, O.current?.(new i()), q(h) && v((t) => {
|
|
117
|
+
if (!t || w() || !q(h)) return t;
|
|
118
|
+
let n = c(t, e);
|
|
111
119
|
return y.current = n, n;
|
|
112
120
|
}));
|
|
113
|
-
}, M =
|
|
114
|
-
if (
|
|
115
|
-
if (!
|
|
116
|
-
M &&
|
|
121
|
+
}, M = I.current.get(h), N = () => R.current && !w() && I.current.get(h) === M, z = async () => {
|
|
122
|
+
if (N()) {
|
|
123
|
+
if (!q(h)) {
|
|
124
|
+
M && I.current.delete(h);
|
|
117
125
|
return;
|
|
118
126
|
}
|
|
119
127
|
try {
|
|
120
128
|
let n = await b.getConversation(e(t));
|
|
121
|
-
if (!
|
|
122
|
-
if (
|
|
123
|
-
M &&
|
|
129
|
+
if (!N()) return;
|
|
130
|
+
if (W(h), !q(h)) {
|
|
131
|
+
M && I.current.delete(h);
|
|
124
132
|
return;
|
|
125
133
|
}
|
|
126
|
-
if (
|
|
127
|
-
|
|
134
|
+
if (l(n) !== -1) {
|
|
135
|
+
Z(t, n, { seedMessage: M?.message });
|
|
128
136
|
return;
|
|
129
137
|
}
|
|
130
|
-
if (M && M.messageIndex === n.messages.length - 1 &&
|
|
138
|
+
if (M && M.messageIndex === n.messages.length - 1 && u(n) && re(M.message)) {
|
|
131
139
|
j();
|
|
132
140
|
return;
|
|
133
141
|
}
|
|
134
|
-
M &&
|
|
142
|
+
M && I.current.delete(h), v(n), y.current = n;
|
|
135
143
|
} catch {
|
|
136
|
-
|
|
144
|
+
N() && G(h, z, N);
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
|
-
},
|
|
147
|
+
}, B = {
|
|
140
148
|
signal: E.signal,
|
|
141
149
|
onChunk: (e) => {
|
|
142
|
-
if (
|
|
143
|
-
let t =
|
|
144
|
-
if (t?.generationId ===
|
|
145
|
-
let n =
|
|
150
|
+
if (w()) return;
|
|
151
|
+
let t = I.current.get(h);
|
|
152
|
+
if (t?.generationId === m) {
|
|
153
|
+
let n = s([t.message], 0, e);
|
|
146
154
|
n && (t.message = n[0]);
|
|
147
155
|
}
|
|
148
|
-
if (
|
|
149
|
-
if (de.current && t?.generationId ===
|
|
150
|
-
k.schedule(
|
|
151
|
-
let e =
|
|
152
|
-
if (
|
|
156
|
+
if (q(h)) {
|
|
157
|
+
if (de.current && t?.generationId === m) {
|
|
158
|
+
k.schedule(h, () => {
|
|
159
|
+
let e = I.current.get(h);
|
|
160
|
+
if (w() || !q(h) || e?.generationId !== m) return;
|
|
153
161
|
let t = { ...e };
|
|
154
162
|
v((e) => {
|
|
155
163
|
if (!e) return e;
|
|
156
|
-
let n =
|
|
164
|
+
let n = c(e, t);
|
|
157
165
|
return y.current = n, n;
|
|
158
166
|
});
|
|
159
167
|
});
|
|
@@ -161,10 +169,10 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
161
169
|
}
|
|
162
170
|
v((t) => {
|
|
163
171
|
if (!t) return t;
|
|
164
|
-
let n =
|
|
165
|
-
if (n?.generationId ===
|
|
172
|
+
let n = I.current.get(h), r;
|
|
173
|
+
if (n?.generationId === m) r = c(t, n);
|
|
166
174
|
else {
|
|
167
|
-
let n =
|
|
175
|
+
let n = s(t.messages, a, e);
|
|
168
176
|
if (!n) return t;
|
|
169
177
|
r = {
|
|
170
178
|
...t,
|
|
@@ -176,103 +184,105 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
176
184
|
}
|
|
177
185
|
},
|
|
178
186
|
onComplete: async () => {
|
|
179
|
-
k.flush(
|
|
187
|
+
k.flush(h), A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.(), await z();
|
|
180
188
|
},
|
|
181
189
|
onError: (e) => {
|
|
182
|
-
if (k.flush(
|
|
183
|
-
|
|
190
|
+
if (k.flush(h), O.current?.(e), e instanceof ee && !w()) {
|
|
191
|
+
pe(e);
|
|
184
192
|
return;
|
|
185
193
|
}
|
|
186
|
-
if (e instanceof r &&
|
|
187
|
-
|
|
194
|
+
if (e instanceof r && oe.resumeOnConflict && !w()) {
|
|
195
|
+
U(e);
|
|
188
196
|
return;
|
|
189
197
|
}
|
|
190
|
-
|
|
198
|
+
V(e);
|
|
191
199
|
}
|
|
192
|
-
},
|
|
193
|
-
let t =
|
|
200
|
+
}, V = (e) => {
|
|
201
|
+
let t = I.current.get(h), n = t?.generationId === m ? t : void 0;
|
|
194
202
|
if (n && (e instanceof i ? n.message = {
|
|
195
203
|
...n.message,
|
|
196
204
|
streamErrorMessage: T
|
|
197
|
-
} :
|
|
205
|
+
} : I.current.delete(h)), A(), w() || !q(h)) return;
|
|
198
206
|
let r = ce(e, ue, T);
|
|
199
207
|
v((e) => {
|
|
200
|
-
if (!e || w() || !
|
|
201
|
-
let t = n?.generationId ===
|
|
208
|
+
if (!e || w() || !q(h)) return e;
|
|
209
|
+
let t = n?.generationId === m ? c(e, n) : e, i = {
|
|
202
210
|
...t,
|
|
203
|
-
messages: t.messages.map((e, t) => t ===
|
|
211
|
+
messages: t.messages.map((e, t) => t === a ? {
|
|
204
212
|
...e,
|
|
205
213
|
streamErrorMessage: r
|
|
206
214
|
} : e)
|
|
207
215
|
};
|
|
208
216
|
return y.current = i, i;
|
|
209
217
|
});
|
|
210
|
-
},
|
|
211
|
-
A(),
|
|
212
|
-
}, G = async (n) => {
|
|
213
|
-
I.current.add(g), J(await te(() => b.getConversation(e(t)), w), n, !1);
|
|
218
|
+
}, H = () => {
|
|
219
|
+
A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
|
|
214
220
|
}, pe = async (n) => {
|
|
215
|
-
|
|
216
|
-
},
|
|
221
|
+
F.current.add(h), K(await ne(() => b.getConversation(e(t)), w), n, !1);
|
|
222
|
+
}, U = async (n) => {
|
|
223
|
+
P.current.get(h) === m && X(h, !1), F.current.add(h), K(await ne(() => b.getConversation(e(t)), w, (e) => e.messages.length === a && e.messages.at(-1)?.role === d.User), n, !0);
|
|
224
|
+
}, K = (e, n, r) => {
|
|
217
225
|
if (w()) {
|
|
218
226
|
A();
|
|
219
227
|
return;
|
|
220
228
|
}
|
|
221
|
-
let i = e?.messages[e.messages.length - 1],
|
|
222
|
-
if (!e || !
|
|
223
|
-
|
|
229
|
+
let i = e?.messages[e.messages.length - 1], ee = e != null && e.messages.length - 1 === a && i?.role === d.Assistant, o = r && e != null && l(e) !== -1;
|
|
230
|
+
if (!e || !ee && !o) {
|
|
231
|
+
F.current.delete(h), V(n);
|
|
224
232
|
return;
|
|
225
233
|
}
|
|
226
|
-
let
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
seedMessage:
|
|
234
|
+
let s = I.current.get(h), c = s?.generationId === m ? s : void 0;
|
|
235
|
+
if (u(e)) {
|
|
236
|
+
Z(t, e, {
|
|
237
|
+
seedMessage: ee ? c?.message : void 0,
|
|
230
238
|
skipDedupe: !0,
|
|
231
|
-
onSettled:
|
|
239
|
+
onSettled: H
|
|
232
240
|
});
|
|
233
241
|
return;
|
|
234
242
|
}
|
|
235
|
-
|
|
243
|
+
F.current.delete(h), c && I.current.delete(h), q(h) && (v(e), y.current = e), H();
|
|
236
244
|
};
|
|
237
245
|
(async () => {
|
|
238
246
|
try {
|
|
239
|
-
let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t =
|
|
247
|
+
let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t = L.current.has(m);
|
|
240
248
|
if (E.signal.aborted || w() || t) {
|
|
241
|
-
|
|
249
|
+
I.current.get(h)?.generationId === m && I.current.delete(h), w() || Y(h), he(h, m), x(h, m), S?.notifyGenerationSettled?.(), t ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
|
|
242
250
|
return;
|
|
243
251
|
}
|
|
244
|
-
b.streamCompletion(
|
|
252
|
+
b.streamCompletion(h, n, te, B, ie, m, p, _, e);
|
|
245
253
|
} catch (e) {
|
|
246
|
-
|
|
254
|
+
B.onError(e instanceof Error ? e : Error(String(e)));
|
|
247
255
|
}
|
|
248
256
|
})();
|
|
249
257
|
}, [
|
|
250
258
|
le,
|
|
251
259
|
x,
|
|
252
|
-
|
|
253
|
-
Z,
|
|
260
|
+
J,
|
|
254
261
|
Y,
|
|
262
|
+
X,
|
|
263
|
+
he,
|
|
264
|
+
q,
|
|
255
265
|
S?.channelId,
|
|
256
266
|
S?.ensureConnected,
|
|
257
267
|
S?.waitForChannel,
|
|
258
268
|
S?.notifyGenerationSettled,
|
|
259
269
|
C,
|
|
260
270
|
b,
|
|
261
|
-
|
|
271
|
+
Z,
|
|
262
272
|
ue,
|
|
263
273
|
T,
|
|
264
274
|
k,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
]),
|
|
268
|
-
let n =
|
|
269
|
-
return
|
|
270
|
-
}, [
|
|
271
|
-
if (!
|
|
272
|
-
let e =
|
|
275
|
+
G,
|
|
276
|
+
W
|
|
277
|
+
]), _e = f((e, t) => {
|
|
278
|
+
let n = o(e), r = I.current.get(n);
|
|
279
|
+
return z.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === d.Assistant && !u(t) ? (W(n), I.current.delete(n), t) : r ? c(t, r) : t;
|
|
280
|
+
}, [W]), ve = f(() => {
|
|
281
|
+
if (!a) return;
|
|
282
|
+
let e = o(a), t = P.current.get(e) ?? _(y.current);
|
|
273
283
|
if (!t) return;
|
|
274
|
-
|
|
275
|
-
let n =
|
|
284
|
+
L.current.add(t), k.flush(e), C?.notifyStopGenerating?.();
|
|
285
|
+
let n = I.current.get(e)?.message.content;
|
|
276
286
|
b.stopCompletion({
|
|
277
287
|
generationId: t,
|
|
278
288
|
path: e,
|
|
@@ -282,23 +292,23 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
282
292
|
w?.(t);
|
|
283
293
|
});
|
|
284
294
|
}, [
|
|
285
|
-
|
|
295
|
+
a,
|
|
286
296
|
y,
|
|
287
297
|
k,
|
|
288
298
|
w,
|
|
289
299
|
C,
|
|
290
300
|
b
|
|
291
|
-
]),
|
|
301
|
+
]), ye = f((e, t) => Z(e, t), [Z]), be = a != null && A.has(o(a)), Q = a == null ? null : o(a), xe = Q != null && (M.has(Q) || be && _(y.current) != null), $ = Q ? B.get(Q) : void 0, Se = $?.isCurrent() ?? !1;
|
|
292
302
|
return {
|
|
293
|
-
hasConversationReloadError:
|
|
294
|
-
isReloadingConversation:
|
|
295
|
-
retryConversationReload:
|
|
296
|
-
startStream:
|
|
297
|
-
handleStop:
|
|
298
|
-
resumeIfAwaitingGeneration:
|
|
299
|
-
restoreBufferedGeneration:
|
|
300
|
-
isStreaming:
|
|
301
|
-
canStopStreaming:
|
|
303
|
+
hasConversationReloadError: Se,
|
|
304
|
+
isReloadingConversation: !!$ && Se && pe.has($),
|
|
305
|
+
retryConversationReload: K,
|
|
306
|
+
startStream: ge,
|
|
307
|
+
handleStop: ve,
|
|
308
|
+
resumeIfAwaitingGeneration: ye,
|
|
309
|
+
restoreBufferedGeneration: _e,
|
|
310
|
+
isStreaming: be,
|
|
311
|
+
canStopStreaming: xe
|
|
302
312
|
};
|
|
303
313
|
};
|
|
304
314
|
//#endregion
|
package/file-manager-canvas.d.ts
CHANGED
|
@@ -200,7 +200,7 @@ declare interface OoxmlDocxHighlightLocation {
|
|
|
200
200
|
path: number[];
|
|
201
201
|
/** Inclusive start character offset within the story's matched text. */
|
|
202
202
|
start: number;
|
|
203
|
-
/** Exclusive end character offset
|
|
203
|
+
/** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
|
|
204
204
|
endExclusive: number;
|
|
205
205
|
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
206
206
|
text: string;
|
|
@@ -264,7 +264,7 @@ declare interface OoxmlPptxHighlightLocation {
|
|
|
264
264
|
shapeId: string;
|
|
265
265
|
/** Inclusive start character offset within the shape's matched text. */
|
|
266
266
|
start: number;
|
|
267
|
-
/** Exclusive end character offset
|
|
267
|
+
/** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
|
|
268
268
|
endExclusive: number;
|
|
269
269
|
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
270
270
|
text: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDialFileId as e } from "./dial-file.js";
|
|
2
2
|
import { AttachmentContentType as t, AttachmentErrorType as n, OoxmlFileType as r, OoxmlHighlightKind as i, getOoxmlFileType as a } from "@epam/ai-dial-attachment-canvas";
|
|
3
3
|
import { MIMEType as o, base64ToBlob as s, tryBase64ToBytes as c } from "@epam/ai-dial-chat-shared";
|
|
4
|
-
import {
|
|
4
|
+
import { annotationHighlightIds as l, annotationToOfficeHighlightLocations as u, annotationsToPdfHighlights as d, gatherSameSourceAnnotations as f, getAnnotationPdfPage as p, parsePdfPageReference as m } from "@epam/ai-dial-quotations";
|
|
5
5
|
import { LRUCache as h } from "lru-cache";
|
|
6
6
|
//#region src/files/attachment-canvas.ts
|
|
7
7
|
var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
|
|
@@ -166,7 +166,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
|
|
|
166
166
|
if (a?.type !== o.PDF) return null;
|
|
167
167
|
let s = e(a.url) ? i.resolveDialFileDownloadUrl(a.url) : a.url;
|
|
168
168
|
if (s == null) return null;
|
|
169
|
-
let c = (r.find((e) => e.annotations.includes(n))?.annotations ?? [n]).filter((e) => e.body?.source?.attachment?.url === a.url), u = c.indexOf(n), f = d(c), m = l(
|
|
169
|
+
let c = (r.find((e) => e.annotations.includes(n))?.annotations ?? [n]).filter((e) => e.body?.source?.attachment?.url === a.url), u = c.indexOf(n), f = d(c), m = l(c)[u], h = p(n), g = f.some((e) => e.id === m);
|
|
170
170
|
if (!g && h != null) {
|
|
171
171
|
let e = `page-anchor-${m}`;
|
|
172
172
|
return {
|
|
@@ -227,15 +227,15 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
|
|
|
227
227
|
if (c !== r.Docx && c !== r.Xlsx && c !== r.Pptx) return null;
|
|
228
228
|
let d = e(s.url) ? o.resolveDialFileDownloadUrl(s.url) : s.url;
|
|
229
229
|
if (d == null) return null;
|
|
230
|
-
let p = f(n, i), m = [], h;
|
|
230
|
+
let p = f(n, i), m = [], h, g = l(p);
|
|
231
231
|
return p.forEach((e, t) => {
|
|
232
232
|
let r = u(e);
|
|
233
233
|
if (r.length === 0) return;
|
|
234
|
-
let i =
|
|
234
|
+
let i = g[t];
|
|
235
235
|
m.push({
|
|
236
236
|
id: i,
|
|
237
237
|
locations: r.map(B)
|
|
238
|
-
}), e === n && (h = i);
|
|
238
|
+
}), e === n && h == null && (h = i);
|
|
239
239
|
}), {
|
|
240
240
|
type: t.Ooxml,
|
|
241
241
|
url: d,
|
|
@@ -7,17 +7,17 @@ import { findFirstSuccessfulCopyMoveItem as p } from "../dial-file-manager-mappi
|
|
|
7
7
|
import { DownloadDestinationType as m } from "../download-destination.js";
|
|
8
8
|
import { getParentFolderPath as h } from "@epam/ai-dial-chat-shared";
|
|
9
9
|
import { useCallback as g, useRef as _, useState as v } from "react";
|
|
10
|
-
import { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as
|
|
11
|
-
import { NOT_ALLOWED_SYMBOLS as
|
|
12
|
-
import { DialFileManagerTabs as
|
|
10
|
+
import { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as te } from "@epam/ai-dial-chat-api-client";
|
|
11
|
+
import { NOT_ALLOWED_SYMBOLS as S, NotificationVariant as C } from "@epam/ai-dial-ui-kit";
|
|
12
|
+
import { DialFileManagerTabs as w, DialFileNodeType as T } from "@epam/ai-dial-react-file-manager";
|
|
13
13
|
//#region src/files/useDialFileMutations/useDialFileMutations.ts
|
|
14
|
-
var
|
|
15
|
-
let [
|
|
14
|
+
var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, currentFolder: j, sharedRootMetaRef: M, listingPermissionsCache: N, invalidateFolders: P, bumpRetry: F, mergeCreatedFolder: I, setFolderPath: L, onNotification: R, onOperationSuccess: z, downloadDestination: B, forbiddenSymbolsRegExp: V }) => {
|
|
15
|
+
let [ne, H] = v(!1), [re, U] = v(!1), [ie, W] = v(!1), [G, K] = v(!1), [q, J] = v(!1), [Y, X] = v(!1), Z = _(null), Q = _(null), $ = g((e, n) => {
|
|
16
16
|
let i = null;
|
|
17
17
|
if (!e || e.trim() === "") i = { reason: t.Empty };
|
|
18
|
-
else if (o(e,
|
|
18
|
+
else if (o(e, V)) i = {
|
|
19
19
|
reason: t.ForbiddenSymbols,
|
|
20
|
-
symbols:
|
|
20
|
+
symbols: S
|
|
21
21
|
};
|
|
22
22
|
else if (e === r) i = { reason: t.ReservedName };
|
|
23
23
|
else if (e.length > 255) i = {
|
|
@@ -32,246 +32,249 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
return Q.current = i, i;
|
|
35
|
-
}, [
|
|
36
|
-
let { parentVirtualPath: a, name: o } = s(r,
|
|
35
|
+
}, [V]), ae = g(async (t, r, i) => {
|
|
36
|
+
let { parentVirtualPath: a, name: o } = s(r, O), l = u(a, O), d = j && A === l ? j : {
|
|
37
37
|
id: l,
|
|
38
38
|
path: l,
|
|
39
39
|
name: a.split("/").filter(Boolean).pop() ?? "",
|
|
40
40
|
folderId: l,
|
|
41
|
-
nodeType:
|
|
41
|
+
nodeType: T.FOLDER,
|
|
42
42
|
items: []
|
|
43
43
|
}, f = Q.current;
|
|
44
44
|
if (Q.current = null, $(o, d) || f) return;
|
|
45
|
-
|
|
46
|
-
let { bucket: p, path: m } =
|
|
47
|
-
bucket:
|
|
45
|
+
H(!0);
|
|
46
|
+
let { bucket: p, path: m } = k === w.Shared ? c(l, M.current, D) : {
|
|
47
|
+
bucket: D,
|
|
48
48
|
path: l
|
|
49
49
|
};
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
I(l, await E.createFolder({
|
|
52
52
|
bucket: p,
|
|
53
53
|
parentPath: m,
|
|
54
54
|
name: o
|
|
55
|
-
}),
|
|
55
|
+
}), N.get(l)), F(), z?.({
|
|
56
56
|
kind: n.FolderCreated,
|
|
57
57
|
name: o
|
|
58
58
|
});
|
|
59
59
|
} catch {
|
|
60
|
-
|
|
61
|
-
variant:
|
|
60
|
+
R?.({
|
|
61
|
+
variant: C.Error,
|
|
62
62
|
reason: e.FolderCreateFailed
|
|
63
63
|
});
|
|
64
64
|
} finally {
|
|
65
|
-
|
|
65
|
+
H(!1);
|
|
66
66
|
}
|
|
67
67
|
}, [
|
|
68
|
-
|
|
69
|
-
O,
|
|
70
|
-
M,
|
|
68
|
+
k,
|
|
71
69
|
D,
|
|
72
70
|
j,
|
|
71
|
+
E,
|
|
72
|
+
A,
|
|
73
73
|
$,
|
|
74
|
-
|
|
75
|
-
P,
|
|
76
|
-
L,
|
|
77
|
-
I,
|
|
78
|
-
B,
|
|
74
|
+
O,
|
|
79
75
|
N,
|
|
80
|
-
|
|
76
|
+
I,
|
|
77
|
+
F,
|
|
78
|
+
z,
|
|
79
|
+
M,
|
|
80
|
+
R
|
|
81
81
|
]), oe = g((t) => {
|
|
82
82
|
(async () => {
|
|
83
|
-
|
|
83
|
+
U(!0);
|
|
84
84
|
try {
|
|
85
|
-
let e = t.length === 1 ? t[0].nodeType ===
|
|
85
|
+
let e = t.length === 1 ? t[0].nodeType === T.ITEM ? t[0].name : `${t[0].name}.zip` : "files.zip", r = await B.resolveDestination(e, t.length === 1 && t[0].nodeType === T.ITEM ? t[0].contentType ?? "application/octet-stream" : "application/zip");
|
|
86
86
|
if (r.type === m.Cancelled) return;
|
|
87
|
-
if (t.length === 1 && t[0].nodeType ===
|
|
87
|
+
if (t.length === 1 && t[0].nodeType === T.ITEM) {
|
|
88
88
|
let e = t[0];
|
|
89
89
|
if (!e.bucket) throw Error("File is missing bucket");
|
|
90
|
-
let i = l(e, e.bucket,
|
|
90
|
+
let i = l(e, e.bucket, O), a = await E.downloadFile(e.bucket, i);
|
|
91
91
|
if (!a.ok) throw Error(`Download failed with status ${a.status}`);
|
|
92
|
-
let o = await
|
|
93
|
-
|
|
92
|
+
let o = await B.triggerDownload(a, e.name, r);
|
|
93
|
+
z?.({
|
|
94
94
|
kind: n.FileDownloaded,
|
|
95
95
|
name: o,
|
|
96
96
|
count: 1
|
|
97
97
|
});
|
|
98
98
|
} else {
|
|
99
99
|
let i = t.map((e) => ({
|
|
100
|
-
bucket: e.bucket ??
|
|
101
|
-
path: l(e, e.bucket ??
|
|
100
|
+
bucket: e.bucket ?? D,
|
|
101
|
+
path: l(e, e.bucket ?? D, O),
|
|
102
102
|
name: e.name,
|
|
103
|
-
nodeType: e.nodeType ===
|
|
104
|
-
})), a = await
|
|
103
|
+
nodeType: e.nodeType === T.FOLDER ? y.Folder : y.Item
|
|
104
|
+
})), a = await E.downloadArchive(i);
|
|
105
105
|
if (!a.ok) throw Error(`Download failed with status ${a.status}`);
|
|
106
|
-
let o = await
|
|
107
|
-
t.length === 1 ?
|
|
106
|
+
let o = await B.triggerDownload(a, e, r);
|
|
107
|
+
t.length === 1 ? z?.({
|
|
108
108
|
kind: n.FileDownloaded,
|
|
109
109
|
name: o
|
|
110
|
-
}) :
|
|
110
|
+
}) : z?.({
|
|
111
111
|
kind: n.FilesDownloaded,
|
|
112
112
|
count: t.length
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
} catch {
|
|
116
|
-
|
|
117
|
-
variant:
|
|
116
|
+
R?.({
|
|
117
|
+
variant: C.Error,
|
|
118
118
|
reason: t.length === 1 ? e.DownloadFileFailed : e.DownloadFilesFailed
|
|
119
119
|
});
|
|
120
120
|
} finally {
|
|
121
|
-
|
|
121
|
+
U(!1);
|
|
122
122
|
}
|
|
123
123
|
})();
|
|
124
124
|
}, [
|
|
125
|
+
D,
|
|
125
126
|
O,
|
|
126
|
-
k,
|
|
127
|
-
B,
|
|
128
127
|
z,
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
R,
|
|
129
|
+
E,
|
|
130
|
+
B
|
|
131
131
|
]), se = g((t, n) => {
|
|
132
132
|
t.length !== 0 && (async () => {
|
|
133
|
-
|
|
134
|
-
let r = t.map((e) => {
|
|
135
|
-
let t = e.nodeType ===
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
W(!0);
|
|
134
|
+
let r = [], i = t.map((e) => {
|
|
135
|
+
let t = e.nodeType === T.FOLDER, n = u(e.sourceUrl, O), i = t ? n : n.replace(/\/$/, "");
|
|
136
|
+
t && i !== "" && r.push(i.endsWith("/") ? i : `${i}/`);
|
|
137
|
+
let o = a(e.sourceUrl, i), { bucket: s, path: l } = k === w.Shared ? c(i, M.current, D) : {
|
|
138
|
+
bucket: D,
|
|
139
|
+
path: i
|
|
138
140
|
};
|
|
139
141
|
return {
|
|
140
|
-
bucket:
|
|
141
|
-
path:
|
|
142
|
-
name:
|
|
142
|
+
bucket: s,
|
|
143
|
+
path: l,
|
|
144
|
+
name: o,
|
|
143
145
|
nodeType: t ? x.Folder : x.Item
|
|
144
146
|
};
|
|
145
147
|
});
|
|
146
148
|
try {
|
|
147
|
-
let { results: t } = await
|
|
148
|
-
if (o > 0 &&
|
|
149
|
-
variant:
|
|
149
|
+
let { results: t } = await E.deleteFiles(i), r = t.filter((e) => !e.success), a = r.length, o = t.length - a, s = t.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
|
|
150
|
+
if (o > 0 && R?.({
|
|
151
|
+
variant: C.Success,
|
|
150
152
|
reason: e.FilesDeleted,
|
|
151
153
|
count: o,
|
|
152
154
|
name: c?.name,
|
|
153
|
-
folder: n ||
|
|
155
|
+
folder: n || O
|
|
154
156
|
}), a > 0) {
|
|
155
|
-
let t =
|
|
156
|
-
|
|
157
|
-
variant:
|
|
157
|
+
let t = r.slice(0, 3).map((e) => i.find((t) => t.path === e.path)?.name ?? e.path), n = a - t.length;
|
|
158
|
+
R?.({
|
|
159
|
+
variant: C.Error,
|
|
158
160
|
reason: e.FilesDeletePartiallyFailed,
|
|
159
161
|
names: t,
|
|
160
162
|
restCount: n
|
|
161
163
|
});
|
|
162
164
|
}
|
|
163
165
|
} catch {
|
|
164
|
-
|
|
165
|
-
variant:
|
|
166
|
+
R?.({
|
|
167
|
+
variant: C.Error,
|
|
166
168
|
reason: e.DeleteFailed
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
|
-
|
|
170
|
-
F([...new Set(r.map((e) => {
|
|
171
|
+
P([...new Set(i.map((e) => {
|
|
171
172
|
if (e.nodeType === x.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
|
|
172
173
|
let t = e.path.lastIndexOf("/");
|
|
173
174
|
return t > 0 ? e.path.slice(0, t + 1) : "";
|
|
174
|
-
}))])
|
|
175
|
+
}))]);
|
|
176
|
+
let o = r.filter((e) => A.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
|
|
177
|
+
o != null && L(h(o)), F(), W(!1);
|
|
175
178
|
})();
|
|
176
179
|
}, [
|
|
177
|
-
A,
|
|
178
|
-
O,
|
|
179
180
|
k,
|
|
180
|
-
j,
|
|
181
|
-
z,
|
|
182
181
|
D,
|
|
183
|
-
|
|
182
|
+
O,
|
|
183
|
+
A,
|
|
184
|
+
R,
|
|
185
|
+
E,
|
|
186
|
+
M,
|
|
187
|
+
P,
|
|
184
188
|
F,
|
|
185
|
-
|
|
186
|
-
R
|
|
189
|
+
L
|
|
187
190
|
]), ce = g((e, n) => {
|
|
188
191
|
if (!e || e.trim() === "") return { reason: t.Empty };
|
|
189
192
|
if (e === r) return { reason: t.ReservedName };
|
|
190
|
-
if (o(e,
|
|
193
|
+
if (o(e, V)) return {
|
|
191
194
|
reason: t.ForbiddenSymbols,
|
|
192
|
-
symbols:
|
|
195
|
+
symbols: S
|
|
193
196
|
};
|
|
194
197
|
if (e.length > 255) return {
|
|
195
198
|
reason: t.TooLong,
|
|
196
199
|
maxLength: 255
|
|
197
200
|
};
|
|
198
|
-
let i =
|
|
201
|
+
let i = j?.items ?? [], a = e.toLowerCase(), s = i.find((e) => e.path !== n.path && e.name.toLowerCase() === a);
|
|
199
202
|
return s ? {
|
|
200
203
|
reason: t.DuplicateName,
|
|
201
204
|
existingName: s.name
|
|
202
205
|
} : null;
|
|
203
|
-
}, [
|
|
204
|
-
if (t.length === 0 ||
|
|
206
|
+
}, [V, j]), le = g((t, r) => {
|
|
207
|
+
if (t.length === 0 || q || Y) return;
|
|
205
208
|
let a = new AbortController();
|
|
206
209
|
Z.current = a, (async () => {
|
|
207
|
-
|
|
208
|
-
let o = d(t,
|
|
210
|
+
J(!0);
|
|
211
|
+
let o = d(t, D, O), s = o.map(({ dto: e }) => e);
|
|
209
212
|
try {
|
|
210
|
-
let { results: t } = await
|
|
213
|
+
let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
|
|
211
214
|
if (l > 0) {
|
|
212
215
|
let e = p(o, t), a = s.every((e) => h(e.sourcePath) === h(e.destinationPath)), c;
|
|
213
|
-
c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied,
|
|
216
|
+
c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied, z?.({
|
|
214
217
|
kind: c,
|
|
215
218
|
name: e?.destinationName,
|
|
216
219
|
count: l,
|
|
217
220
|
isFolder: e?.dto.nodeType === b.Folder,
|
|
218
|
-
destinationFolderName: i(r,
|
|
221
|
+
destinationFolderName: i(r, O)
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
|
-
c > 0 && c < t.length ?
|
|
222
|
-
variant:
|
|
224
|
+
c > 0 && c < t.length ? R?.({
|
|
225
|
+
variant: C.Error,
|
|
223
226
|
reason: e.CopyPartiallyFailed,
|
|
224
227
|
count: c
|
|
225
|
-
}) : c === t.length &&
|
|
226
|
-
variant:
|
|
228
|
+
}) : c === t.length && R?.({
|
|
229
|
+
variant: C.Error,
|
|
227
230
|
reason: e.CopyFailed
|
|
228
231
|
});
|
|
229
232
|
} catch {
|
|
230
|
-
a.signal.aborted ||
|
|
231
|
-
variant:
|
|
233
|
+
a.signal.aborted || R?.({
|
|
234
|
+
variant: C.Error,
|
|
232
235
|
reason: e.CopyFailed
|
|
233
236
|
});
|
|
234
237
|
} finally {
|
|
235
|
-
|
|
238
|
+
P([...new Set(s.flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), J(!1), Z.current = null;
|
|
236
239
|
}
|
|
237
240
|
})();
|
|
238
241
|
}, [
|
|
242
|
+
D,
|
|
239
243
|
O,
|
|
240
|
-
|
|
244
|
+
R,
|
|
241
245
|
z,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
F
|
|
247
|
-
I
|
|
246
|
+
E,
|
|
247
|
+
q,
|
|
248
|
+
Y,
|
|
249
|
+
P,
|
|
250
|
+
F
|
|
248
251
|
]), ue = g(() => {
|
|
249
252
|
Z.current?.abort();
|
|
250
253
|
}, []);
|
|
251
254
|
return {
|
|
252
|
-
isCreatingFolder:
|
|
253
|
-
isDownloading:
|
|
254
|
-
isDeleting:
|
|
255
|
-
isRenaming:
|
|
256
|
-
isCopying:
|
|
257
|
-
isMoving:
|
|
255
|
+
isCreatingFolder: ne,
|
|
256
|
+
isDownloading: re,
|
|
257
|
+
isDeleting: ie,
|
|
258
|
+
isRenaming: G,
|
|
259
|
+
isCopying: q,
|
|
260
|
+
isMoving: Y,
|
|
258
261
|
onCreateFolder: ae,
|
|
259
262
|
onCreateFolderValidate: $,
|
|
260
263
|
onDownloadFiles: oe,
|
|
261
264
|
onDeleteFiles: se,
|
|
262
265
|
onRenameValidate: ce,
|
|
263
266
|
onMoveToFiles: g((t, r, o) => {
|
|
264
|
-
if (t.length === 0 ||
|
|
265
|
-
let { renameDtos: s, preparedMoveItems: c } = f(t,
|
|
267
|
+
if (t.length === 0 || q || Y || G) return;
|
|
268
|
+
let { renameDtos: s, preparedMoveItems: c } = f(t, D, O), l = c.map(({ dto: e }) => e), u = new AbortController();
|
|
266
269
|
l.length > 0 && (Z.current = u), (async () => {
|
|
267
|
-
s.length > 0 &&
|
|
270
|
+
s.length > 0 && K(!0), l.length > 0 && X(!0);
|
|
268
271
|
let [t, r] = await Promise.all([(async () => {
|
|
269
272
|
if (s.length === 0) return {
|
|
270
273
|
results: [],
|
|
271
274
|
threw: !1
|
|
272
275
|
};
|
|
273
276
|
try {
|
|
274
|
-
let { results: e } = await
|
|
277
|
+
let { results: e } = await E.renameFiles(s);
|
|
275
278
|
return {
|
|
276
279
|
results: e,
|
|
277
280
|
threw: !1
|
|
@@ -289,7 +292,7 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
|
|
|
289
292
|
aborted: !1
|
|
290
293
|
};
|
|
291
294
|
try {
|
|
292
|
-
let { results: e } = await
|
|
295
|
+
let { results: e } = await E.moveFiles(l, u.signal);
|
|
293
296
|
return {
|
|
294
297
|
results: e,
|
|
295
298
|
threw: !1,
|
|
@@ -305,57 +308,57 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
|
|
|
305
308
|
})()]), d = t.threw ? s.length : t.results.filter((e) => !e.success).length, f = r.threw && r.aborted, m = f ? 0 : l.length, g = f ? 0 : r.threw ? l.length : r.results.filter((e) => !e.success).length, _ = r.threw ? 0 : r.results.filter((e) => e.success).length, v = s.length + m, y = d + g, b = g > 0;
|
|
306
309
|
if (_ > 0) {
|
|
307
310
|
let e = p(c, r.results);
|
|
308
|
-
|
|
311
|
+
z?.({
|
|
309
312
|
kind: _ === 1 ? n.FileMoved : n.FilesMoved,
|
|
310
313
|
name: e?.destinationName,
|
|
311
314
|
count: _,
|
|
312
315
|
isFolder: e?.dto.nodeType === ee.Folder,
|
|
313
|
-
destinationFolderName: i(o,
|
|
316
|
+
destinationFolderName: i(o, O)
|
|
314
317
|
});
|
|
315
318
|
}
|
|
316
319
|
if (s.length === 1 && d === 0) {
|
|
317
320
|
let [e] = s;
|
|
318
|
-
|
|
321
|
+
z?.({
|
|
319
322
|
kind: n.FileRenamed,
|
|
320
323
|
name: a(e.destinationPath, e.destinationPath),
|
|
321
|
-
isFolder: e.nodeType ===
|
|
324
|
+
isFolder: e.nodeType === te.Folder
|
|
322
325
|
});
|
|
323
326
|
}
|
|
324
|
-
y > 0 && (y === v ?
|
|
325
|
-
variant:
|
|
327
|
+
y > 0 && (y === v ? R?.({
|
|
328
|
+
variant: C.Error,
|
|
326
329
|
reason: b ? e.MoveFailed : e.RenameFailed
|
|
327
|
-
}) :
|
|
328
|
-
variant:
|
|
330
|
+
}) : R?.({
|
|
331
|
+
variant: C.Error,
|
|
329
332
|
reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
|
|
330
333
|
count: y
|
|
331
334
|
}));
|
|
332
|
-
let x = s.find((e) => e.nodeType ===
|
|
335
|
+
let x = s.find((e) => e.nodeType === te.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
|
|
333
336
|
if (x != null) {
|
|
334
337
|
let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
|
|
335
|
-
if (
|
|
338
|
+
if (A === e || A.startsWith(e)) {
|
|
336
339
|
let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
|
|
337
|
-
|
|
340
|
+
L(A.replace(e, t));
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
|
-
|
|
343
|
+
P([...new Set([...s, ...l].flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), K(!1), X(!1), l.length > 0 && (Z.current = null);
|
|
341
344
|
})();
|
|
342
345
|
}, [
|
|
346
|
+
D,
|
|
343
347
|
O,
|
|
344
|
-
|
|
345
|
-
j,
|
|
346
|
-
B,
|
|
348
|
+
A,
|
|
347
349
|
z,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
R,
|
|
351
|
+
E,
|
|
352
|
+
q,
|
|
353
|
+
Y,
|
|
354
|
+
G,
|
|
355
|
+
P,
|
|
352
356
|
F,
|
|
353
|
-
|
|
354
|
-
R
|
|
357
|
+
L
|
|
355
358
|
]),
|
|
356
359
|
onCopyFiles: le,
|
|
357
360
|
cancelCopyMove: ue
|
|
358
361
|
};
|
|
359
362
|
};
|
|
360
363
|
//#endregion
|
|
361
|
-
export {
|
|
364
|
+
export { E as useDialFileMutations };
|
package/index.d.ts
CHANGED
|
@@ -2881,7 +2881,7 @@ declare interface OoxmlDocxHighlightLocation {
|
|
|
2881
2881
|
path: number[];
|
|
2882
2882
|
/** Inclusive start character offset within the story's matched text. */
|
|
2883
2883
|
start: number;
|
|
2884
|
-
/** Exclusive end character offset
|
|
2884
|
+
/** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
|
|
2885
2885
|
endExclusive: number;
|
|
2886
2886
|
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
2887
2887
|
text: string;
|
|
@@ -2945,7 +2945,7 @@ declare interface OoxmlPptxHighlightLocation {
|
|
|
2945
2945
|
shapeId: string;
|
|
2946
2946
|
/** Inclusive start character offset within the shape's matched text. */
|
|
2947
2947
|
start: number;
|
|
2948
|
-
/** Exclusive end character offset
|
|
2948
|
+
/** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
|
|
2949
2949
|
endExclusive: number;
|
|
2950
2950
|
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
2951
2951
|
text: string;
|
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.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.288",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@epam/ai-dial-chat-api-client": "1.2.0-dev.
|
|
114
|
+
"@epam/ai-dial-chat-api-client": "1.2.0-dev.288",
|
|
115
115
|
"dompurify": "3.4.16",
|
|
116
116
|
"fflate": "^0.8.3",
|
|
117
117
|
"lru-cache": "^10.4.3",
|
|
@@ -120,21 +120,21 @@
|
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"react": "^19.2.8",
|
|
123
|
-
"@epam/ai-dial-attachment-canvas": "1.2.0-dev.
|
|
124
|
-
"@epam/ai-dial-attachment-input": "1.2.0-dev.
|
|
125
|
-
"@epam/ai-dial-catalog": "1.2.0-dev.
|
|
126
|
-
"@epam/ai-dial-chat-overlay": "1.2.0-dev.
|
|
127
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
128
|
-
"@epam/ai-dial-mcp-apps": "1.2.0-dev.
|
|
129
|
-
"@epam/ai-dial-publish-panel": "1.2.0-dev.
|
|
130
|
-
"@epam/ai-dial-quotations": "1.2.0-dev.
|
|
123
|
+
"@epam/ai-dial-attachment-canvas": "1.2.0-dev.288",
|
|
124
|
+
"@epam/ai-dial-attachment-input": "1.2.0-dev.288",
|
|
125
|
+
"@epam/ai-dial-catalog": "1.2.0-dev.288",
|
|
126
|
+
"@epam/ai-dial-chat-overlay": "1.2.0-dev.288",
|
|
127
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.288",
|
|
128
|
+
"@epam/ai-dial-mcp-apps": "1.2.0-dev.288",
|
|
129
|
+
"@epam/ai-dial-publish-panel": "1.2.0-dev.288",
|
|
130
|
+
"@epam/ai-dial-quotations": "1.2.0-dev.288",
|
|
131
131
|
"@epam/ai-dial-react-file-manager": "^0.3.0-dev.25",
|
|
132
|
-
"@epam/ai-dial-scheduled-tasks": "1.2.0-dev.
|
|
133
|
-
"@epam/ai-dial-share": "1.2.0-dev.
|
|
134
|
-
"@epam/ai-dial-skill-editor": "1.2.0-dev.
|
|
135
|
-
"@epam/ai-dial-source-panel": "1.2.0-dev.
|
|
132
|
+
"@epam/ai-dial-scheduled-tasks": "1.2.0-dev.288",
|
|
133
|
+
"@epam/ai-dial-share": "1.2.0-dev.288",
|
|
134
|
+
"@epam/ai-dial-skill-editor": "1.2.0-dev.288",
|
|
135
|
+
"@epam/ai-dial-source-panel": "1.2.0-dev.288",
|
|
136
136
|
"@epam/ai-dial-ui-kit": "^0.15.0-dev.36",
|
|
137
|
-
"@epam/ai-dial-usage-dashboard": "1.2.0-dev.
|
|
137
|
+
"@epam/ai-dial-usage-dashboard": "1.2.0-dev.288",
|
|
138
138
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
139
139
|
"@epam/pdf-highlighter-kit": "^0.0.19",
|
|
140
140
|
"@mcp-ui/client": "^7.1.1"
|