@epam/ai-dial-chat-hooks 1.2.0-rc.0 → 1.2.0-rc.2
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/useCatalogEditNavigation/useCatalogEditNavigation.js +136 -119
- package/catalog.d.ts +3 -0
- package/conversation/create-chat-stream-api.js +14 -10
- package/conversation/useConversationStream/useConversationStream.js +98 -77
- package/conversation.d.ts +14 -1
- package/file-manager.d.ts +17 -4
- package/file-manager.js +25 -25
- package/files/dial-file-manager.model.js +7 -3
- package/files/dial-file-manager.types.js +1 -1
- package/files/useDialFileListing/useDialFileListing.js +24 -14
- package/files/useDialFileManager/useDialFileManager.js +148 -140
- package/files/useDialFileSharing/useDialFileSharing.js +45 -39
- package/index.d.ts +34 -5
- package/index.js +43 -43
- package/package.json +16 -16
|
@@ -1,28 +1,28 @@
|
|
|
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
|
|
2
|
+
import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as a, StreamUpstreamError as o } from "../create-chat-stream-api.js";
|
|
3
|
+
import { getConversationPath as s } from "./conversation-path.js";
|
|
4
|
+
import { applyChunkToMessages as c } from "./apply-chunk.js";
|
|
5
|
+
import { restoreBufferedMessage as l } from "./buffered-generation.js";
|
|
6
|
+
import { createResumeIfAwaitingGeneration as ee, fetchConversationForRecovery as te, findPendingBackgroundMessageIndex as u, hasGeneratedPayload as ne, isAwaitingGenerationResume as d } from "./generation-resume.js";
|
|
7
|
+
import { createFrameScheduler as re } from "./frame-scheduler.js";
|
|
8
|
+
import { MessageRole as ie, generateUUID as ae } from "@epam/ai-dial-chat-shared";
|
|
9
9
|
import { useCallback as f, useEffect as p, useMemo as oe, useRef as m, useState as h } from "react";
|
|
10
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 = 401, le = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof o ? e.message : "", _ = (e) => {
|
|
13
13
|
if (!e) return;
|
|
14
|
-
let t =
|
|
14
|
+
let t = u(e);
|
|
15
15
|
return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
|
|
16
|
-
}, v = ({ conversationId:
|
|
16
|
+
}, v = ({ conversationId: o, state: { setConversation: v, conversationRef: y }, transport: b, generation: { startGeneration: ue, completeGeneration: x }, channel: S, overlay: C, onStopError: w, generationConflictMessage: de = t, generationPersistenceErrorMessage: T = n, onStreamError: E, batchChunksPerFrame: D = !1 }) => {
|
|
17
17
|
let O = m(E);
|
|
18
18
|
p(() => {
|
|
19
19
|
O.current = E;
|
|
20
20
|
}, [E]);
|
|
21
|
-
let
|
|
21
|
+
let fe = m(D);
|
|
22
22
|
p(() => {
|
|
23
|
-
|
|
23
|
+
fe.current = D;
|
|
24
24
|
}, [D]);
|
|
25
|
-
let [k] = h(
|
|
25
|
+
let [k] = h(re), [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()), pe = m(/* @__PURE__ */ new Map()), R = m(!0), z = m(/* @__PURE__ */ new Map()), [B, V] = h(z.current), H = m(/* @__PURE__ */ new Set()), [me, U] = h(H.current);
|
|
26
26
|
p(() => (R.current = !0, () => {
|
|
27
27
|
R.current = !1;
|
|
28
28
|
}), []);
|
|
@@ -37,9 +37,9 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
37
37
|
retry: t,
|
|
38
38
|
isCurrent: n
|
|
39
39
|
}), z.current = r, V(r);
|
|
40
|
-
}, []),
|
|
41
|
-
if (!
|
|
42
|
-
let e = z.current.get(o
|
|
40
|
+
}, []), he = f(async () => {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
let e = z.current.get(s(o));
|
|
43
43
|
if (!(!e || !e.isCurrent() || H.current.has(e))) {
|
|
44
44
|
H.current.add(e), U(new Set(H.current));
|
|
45
45
|
try {
|
|
@@ -48,9 +48,9 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
48
48
|
H.current.delete(e), R.current && U(new Set(H.current));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}, [
|
|
52
|
-
p(() => (
|
|
53
|
-
let q = f((e) => R.current &&
|
|
51
|
+
}, [o]), K = m(o);
|
|
52
|
+
p(() => (K.current = o, () => k.cancelAll()), [o, k]);
|
|
53
|
+
let q = f((e) => R.current && s(K.current ?? "") === e, []), J = f((e) => {
|
|
54
54
|
W(e), j((t) => {
|
|
55
55
|
if (t.has(e)) return t;
|
|
56
56
|
let n = new Set(t);
|
|
@@ -68,9 +68,9 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
68
68
|
let r = new Set(n);
|
|
69
69
|
return t ? r.add(e) : r.delete(e), r;
|
|
70
70
|
});
|
|
71
|
-
}, []),
|
|
71
|
+
}, []), Z = f((e, t) => {
|
|
72
72
|
P.current.get(e) === t && (P.current.delete(e), X(e, !1));
|
|
73
|
-
}, [X]),
|
|
73
|
+
}, [X]), Q = oe(() => ee({
|
|
74
74
|
transport: b,
|
|
75
75
|
setConversation: v,
|
|
76
76
|
conversationRef: y,
|
|
@@ -94,19 +94,19 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
94
94
|
k,
|
|
95
95
|
G,
|
|
96
96
|
W
|
|
97
|
-
]), ge = f((t, n,
|
|
98
|
-
let m = f ?? ae(), h =
|
|
99
|
-
k.flush(h), F.current.delete(h), P.current.set(h, m),
|
|
97
|
+
]), ge = f((t, n, o, ee, re, f, p = g.Append, oe = {}) => {
|
|
98
|
+
let m = f ?? ae(), h = s(t);
|
|
99
|
+
k.flush(h), F.current.delete(h), P.current.set(h, m), pe.current.set(h, m), X(h, !0);
|
|
100
100
|
let _;
|
|
101
|
-
p === g.Regenerate ? _ =
|
|
102
|
-
let w = () =>
|
|
101
|
+
p === g.Regenerate ? _ = o : p === g.Edit && (_ = o - 1);
|
|
102
|
+
let w = () => pe.current.get(h) !== m, E = ue(h, m), D = y.current?.messages[o];
|
|
103
103
|
D ? I.current.set(h, {
|
|
104
104
|
generationId: m,
|
|
105
|
-
messageIndex:
|
|
105
|
+
messageIndex: o,
|
|
106
106
|
message: D
|
|
107
107
|
}) : I.current.delete(h), J(h), C?.notifyGenerationStart?.(), S?.ensureConnected();
|
|
108
108
|
let A = () => {
|
|
109
|
-
w() || Y(h),
|
|
109
|
+
w() || Y(h), Z(h, m), x(h, m), S?.notifyGenerationSettled?.();
|
|
110
110
|
}, j = () => {
|
|
111
111
|
if (w()) return;
|
|
112
112
|
let e = I.current.get(h);
|
|
@@ -115,7 +115,7 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
115
115
|
streamErrorMessage: T
|
|
116
116
|
}, O.current?.(new i()), q(h) && v((t) => {
|
|
117
117
|
if (!t || w() || !q(h)) return t;
|
|
118
|
-
let n =
|
|
118
|
+
let n = l(t, e);
|
|
119
119
|
return y.current = n, n;
|
|
120
120
|
}));
|
|
121
121
|
}, M = I.current.get(h), N = () => R.current && !w() && I.current.get(h) === M, z = async () => {
|
|
@@ -131,11 +131,11 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
131
131
|
M && I.current.delete(h);
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
if (
|
|
135
|
-
|
|
134
|
+
if (u(n) !== -1) {
|
|
135
|
+
Q(t, n, { seedMessage: M?.message });
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
if (M && M.messageIndex === n.messages.length - 1 &&
|
|
138
|
+
if (M && M.messageIndex === n.messages.length - 1 && d(n) && ne(M.message)) {
|
|
139
139
|
j();
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
@@ -150,18 +150,18 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
150
150
|
if (w()) return;
|
|
151
151
|
let t = I.current.get(h);
|
|
152
152
|
if (t?.generationId === m) {
|
|
153
|
-
let n =
|
|
153
|
+
let n = c([t.message], 0, e);
|
|
154
154
|
n && (t.message = n[0]);
|
|
155
155
|
}
|
|
156
156
|
if (q(h)) {
|
|
157
|
-
if (
|
|
157
|
+
if (fe.current && t?.generationId === m) {
|
|
158
158
|
k.schedule(h, () => {
|
|
159
159
|
let e = I.current.get(h);
|
|
160
160
|
if (w() || !q(h) || e?.generationId !== m) return;
|
|
161
161
|
let t = { ...e };
|
|
162
162
|
v((e) => {
|
|
163
163
|
if (!e) return e;
|
|
164
|
-
let n =
|
|
164
|
+
let n = l(e, t);
|
|
165
165
|
return y.current = n, n;
|
|
166
166
|
});
|
|
167
167
|
});
|
|
@@ -170,9 +170,9 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
170
170
|
v((t) => {
|
|
171
171
|
if (!t) return t;
|
|
172
172
|
let n = I.current.get(h), r;
|
|
173
|
-
if (n?.generationId === m) r =
|
|
173
|
+
if (n?.generationId === m) r = l(t, n);
|
|
174
174
|
else {
|
|
175
|
-
let n =
|
|
175
|
+
let n = c(t.messages, o, e);
|
|
176
176
|
if (!n) return t;
|
|
177
177
|
r = {
|
|
178
178
|
...t,
|
|
@@ -187,80 +187,101 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
187
187
|
k.flush(h), A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.(), await z();
|
|
188
188
|
},
|
|
189
189
|
onError: (e) => {
|
|
190
|
-
if (k.flush(h), O.current?.(e), e instanceof
|
|
191
|
-
|
|
190
|
+
if (k.flush(h), O.current?.(e), e instanceof a && !w()) {
|
|
191
|
+
he(e);
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
if (e instanceof r && oe.resumeOnConflict && !w()) {
|
|
195
|
-
|
|
195
|
+
K(e);
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
V(e);
|
|
199
199
|
}
|
|
200
200
|
}, V = (e) => {
|
|
201
201
|
let t = I.current.get(h), n = t?.generationId === m ? t : void 0;
|
|
202
|
-
if (n && (e instanceof i
|
|
203
|
-
|
|
202
|
+
if (n && !(e instanceof i) && I.current.delete(h), A(), n && b.saveConversation && e instanceof i && e.status === ce) {
|
|
203
|
+
me(e, n, b.saveConversation.bind(b));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
H(e, n);
|
|
207
|
+
}, H = (e, t) => {
|
|
208
|
+
if (t && e instanceof i && (t.message = {
|
|
209
|
+
...t.message,
|
|
204
210
|
streamErrorMessage: T
|
|
205
|
-
}
|
|
206
|
-
let
|
|
211
|
+
}), w() || !q(h)) return;
|
|
212
|
+
let n = le(e, de, T);
|
|
207
213
|
v((e) => {
|
|
208
214
|
if (!e || w() || !q(h)) return e;
|
|
209
|
-
let
|
|
210
|
-
...
|
|
211
|
-
messages:
|
|
215
|
+
let r = t?.generationId === m ? l(e, t) : e, i = {
|
|
216
|
+
...r,
|
|
217
|
+
messages: r.messages.map((e, t) => t === o ? {
|
|
212
218
|
...e,
|
|
213
|
-
streamErrorMessage:
|
|
219
|
+
streamErrorMessage: n
|
|
214
220
|
} : e)
|
|
215
221
|
};
|
|
216
222
|
return y.current = i, i;
|
|
217
223
|
});
|
|
218
|
-
},
|
|
224
|
+
}, me = async (n, r, i) => {
|
|
225
|
+
let a = () => R.current && !w() && I.current.get(h) === r;
|
|
226
|
+
try {
|
|
227
|
+
let o = await b.getConversation(e(t));
|
|
228
|
+
if (!a()) return;
|
|
229
|
+
if (r.messageIndex !== o.messages.length - 1 || !d(o)) {
|
|
230
|
+
H(n, r);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
let s = await i(h, l(o, r));
|
|
234
|
+
if (!a() || (I.current.delete(h), !q(h))) return;
|
|
235
|
+
v(s), y.current = s;
|
|
236
|
+
} catch {
|
|
237
|
+
a() && H(n, r);
|
|
238
|
+
}
|
|
239
|
+
}, U = () => {
|
|
219
240
|
A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
|
|
220
|
-
},
|
|
221
|
-
F.current.add(h),
|
|
222
|
-
},
|
|
223
|
-
P.current.get(h) === m && X(h, !1), F.current.add(h),
|
|
224
|
-
},
|
|
241
|
+
}, he = async (n) => {
|
|
242
|
+
F.current.add(h), ge(await te(() => b.getConversation(e(t)), w), n, !1);
|
|
243
|
+
}, K = async (n) => {
|
|
244
|
+
P.current.get(h) === m && X(h, !1), F.current.add(h), ge(await te(() => b.getConversation(e(t)), w, (e) => e.messages.length === o && e.messages.at(-1)?.role === ie.User), n, !0);
|
|
245
|
+
}, ge = (e, n, r) => {
|
|
225
246
|
if (w()) {
|
|
226
247
|
A();
|
|
227
248
|
return;
|
|
228
249
|
}
|
|
229
|
-
let i = e?.messages[e.messages.length - 1],
|
|
230
|
-
if (!e || !
|
|
250
|
+
let i = e?.messages[e.messages.length - 1], a = e != null && e.messages.length - 1 === o && i?.role === ie.Assistant, s = r && e != null && u(e) !== -1;
|
|
251
|
+
if (!e || !a && !s) {
|
|
231
252
|
F.current.delete(h), V(n);
|
|
232
253
|
return;
|
|
233
254
|
}
|
|
234
|
-
let
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
seedMessage:
|
|
255
|
+
let c = I.current.get(h), l = c?.generationId === m ? c : void 0;
|
|
256
|
+
if (d(e)) {
|
|
257
|
+
Q(t, e, {
|
|
258
|
+
seedMessage: a ? l?.message : void 0,
|
|
238
259
|
skipDedupe: !0,
|
|
239
|
-
onSettled:
|
|
260
|
+
onSettled: U
|
|
240
261
|
});
|
|
241
262
|
return;
|
|
242
263
|
}
|
|
243
|
-
F.current.delete(h),
|
|
264
|
+
F.current.delete(h), l && I.current.delete(h), q(h) && (v(e), y.current = e), U();
|
|
244
265
|
};
|
|
245
266
|
(async () => {
|
|
246
267
|
try {
|
|
247
268
|
let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t = L.current.has(m);
|
|
248
269
|
if (E.signal.aborted || w() || t) {
|
|
249
|
-
I.current.get(h)?.generationId === m && I.current.delete(h), w() || Y(h),
|
|
270
|
+
I.current.get(h)?.generationId === m && I.current.delete(h), w() || Y(h), Z(h, m), x(h, m), S?.notifyGenerationSettled?.(), t ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
|
|
250
271
|
return;
|
|
251
272
|
}
|
|
252
|
-
b.streamCompletion(h, n,
|
|
273
|
+
b.streamCompletion(h, n, ee, B, re, m, p, _, e);
|
|
253
274
|
} catch (e) {
|
|
254
275
|
B.onError(e instanceof Error ? e : Error(String(e)));
|
|
255
276
|
}
|
|
256
277
|
})();
|
|
257
278
|
}, [
|
|
258
|
-
|
|
279
|
+
ue,
|
|
259
280
|
x,
|
|
260
281
|
J,
|
|
261
282
|
Y,
|
|
262
283
|
X,
|
|
263
|
-
|
|
284
|
+
Z,
|
|
264
285
|
q,
|
|
265
286
|
S?.channelId,
|
|
266
287
|
S?.ensureConnected,
|
|
@@ -268,18 +289,18 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
268
289
|
S?.notifyGenerationSettled,
|
|
269
290
|
C,
|
|
270
291
|
b,
|
|
271
|
-
|
|
272
|
-
|
|
292
|
+
Q,
|
|
293
|
+
de,
|
|
273
294
|
T,
|
|
274
295
|
k,
|
|
275
296
|
G,
|
|
276
297
|
W
|
|
277
298
|
]), _e = f((e, t) => {
|
|
278
|
-
let n =
|
|
279
|
-
return z.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role ===
|
|
299
|
+
let n = s(e), r = I.current.get(n);
|
|
300
|
+
return z.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === ie.Assistant && !d(t) ? (W(n), I.current.delete(n), t) : r ? l(t, r) : t;
|
|
280
301
|
}, [W]), ve = f(() => {
|
|
281
|
-
if (!
|
|
282
|
-
let e = o
|
|
302
|
+
if (!o) return;
|
|
303
|
+
let e = s(o), t = P.current.get(e) ?? _(y.current);
|
|
283
304
|
if (!t) return;
|
|
284
305
|
L.current.add(t), k.flush(e), C?.notifyStopGenerating?.();
|
|
285
306
|
let n = I.current.get(e)?.message.content;
|
|
@@ -292,17 +313,17 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
292
313
|
w?.(t);
|
|
293
314
|
});
|
|
294
315
|
}, [
|
|
295
|
-
|
|
316
|
+
o,
|
|
296
317
|
y,
|
|
297
318
|
k,
|
|
298
319
|
w,
|
|
299
320
|
C,
|
|
300
321
|
b
|
|
301
|
-
]), ye = f((e, t) =>
|
|
322
|
+
]), ye = f((e, t) => Q(e, t), [Q]), be = o != null && A.has(s(o)), $ = o == null ? null : s(o), xe = $ != null && (M.has($) || be && _(y.current) != null), Se = $ ? B.get($) : void 0, Ce = Se?.isCurrent() ?? !1;
|
|
302
323
|
return {
|
|
303
|
-
hasConversationReloadError:
|
|
304
|
-
isReloadingConversation:
|
|
305
|
-
retryConversationReload:
|
|
324
|
+
hasConversationReloadError: Ce,
|
|
325
|
+
isReloadingConversation: !!Se && Ce && me.has(Se),
|
|
326
|
+
retryConversationReload: he,
|
|
306
327
|
startStream: ge,
|
|
307
328
|
handleStop: ve,
|
|
308
329
|
resumeIfAwaitingGeneration: ye,
|
package/conversation.d.ts
CHANGED
|
@@ -330,6 +330,13 @@ export declare interface ConversationStreamTransport {
|
|
|
330
330
|
attachToGeneration(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
331
331
|
/** Reloads the persisted conversation by its full (bucket-qualified) id. */
|
|
332
332
|
getConversation(conversationId: string, signal?: AbortSignal): Promise<Conversation>;
|
|
333
|
+
/**
|
|
334
|
+
* Saves `conversation` at the bucket-stripped `path`, resolving with the saved
|
|
335
|
+
* conversation. Used only for the single recovery save after the backend's
|
|
336
|
+
* terminal save was rejected with `401`; without it that failure shows the
|
|
337
|
+
* persistence warning immediately.
|
|
338
|
+
*/
|
|
339
|
+
saveConversation?(path: string, conversation: Conversation): Promise<Conversation>;
|
|
333
340
|
}
|
|
334
341
|
|
|
335
342
|
/**
|
|
@@ -420,7 +427,13 @@ export declare class GenerationConflictError extends Error {
|
|
|
420
427
|
/** Identifies a failed terminal save independently of the model's generation outcome. */
|
|
421
428
|
export declare class GenerationPersistenceError extends Error {
|
|
422
429
|
static readonly type = "conversation_save_failed";
|
|
423
|
-
|
|
430
|
+
/** HTTP status of the rejected terminal write, when the backend reported one. */
|
|
431
|
+
readonly status?: number;
|
|
432
|
+
/**
|
|
433
|
+
* Creates the error with the default persistence message.
|
|
434
|
+
* @param status - HTTP status of the rejected terminal write, if known
|
|
435
|
+
*/
|
|
436
|
+
constructor(status?: number);
|
|
424
437
|
}
|
|
425
438
|
|
|
426
439
|
/**
|
package/file-manager.d.ts
CHANGED
|
@@ -75,9 +75,11 @@ export declare const buildFromCache: (cache: Map<string, ListFilesItemDto[]>, li
|
|
|
75
75
|
*/
|
|
76
76
|
export declare const buildSharedItemVirtualPath: (relativePath: string, rootLabel: string, isFolder: boolean) => string;
|
|
77
77
|
|
|
78
|
-
export declare const
|
|
78
|
+
export declare const COLUMNS_MY_FILES: FileManagerColumnKey[];
|
|
79
79
|
|
|
80
|
-
export declare const
|
|
80
|
+
export declare const COLUMNS_ORGANIZATION: FileManagerColumnKey[];
|
|
81
|
+
|
|
82
|
+
export declare const COLUMNS_SHARED: FileManagerColumnKey[];
|
|
81
83
|
|
|
82
84
|
export declare interface CopyMoveResult {
|
|
83
85
|
success?: boolean;
|
|
@@ -405,7 +407,9 @@ export declare enum FileOperationKind {
|
|
|
405
407
|
FilesMoved = "filesMoved",
|
|
406
408
|
/** A copy whose every item landed in its own source folder (Duplicate). */
|
|
407
409
|
FileDuplicated = "fileDuplicated",
|
|
408
|
-
FilesDuplicated = "filesDuplicated"
|
|
410
|
+
FilesDuplicated = "filesDuplicated",
|
|
411
|
+
/** One or more shared-with-me items were removed from the Shared tab. */
|
|
412
|
+
FilesUnshared = "filesUnshared"
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
/**
|
|
@@ -773,6 +777,11 @@ export declare interface UseDialFileListingResult {
|
|
|
773
777
|
mergeCreatedFolder: (parentApiPath: string, created: CreateFolderResponseDto, inheritedPermissions?: string[]) => void;
|
|
774
778
|
/** Forces the listing effect to re-fetch the currently browsed folder. */
|
|
775
779
|
bumpRetry: () => void;
|
|
780
|
+
/**
|
|
781
|
+
* Drops the named root rows from the Shared tab's cached listing, so an
|
|
782
|
+
* unshared item disappears at once instead of waiting for the refetch.
|
|
783
|
+
*/
|
|
784
|
+
removeSharedRootItems: (names: string[]) => void;
|
|
776
785
|
}
|
|
777
786
|
|
|
778
787
|
/**
|
|
@@ -1094,7 +1103,7 @@ export declare interface UseDialFileMutationsResult {
|
|
|
1094
1103
|
* shared retry counter after each mutation settles rather than holding its
|
|
1095
1104
|
* own cache copy.
|
|
1096
1105
|
*/
|
|
1097
|
-
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
1106
|
+
export declare const useDialFileSharing: ({ filesApi, bucket, rootLabel, bumpRetry, onNotification, onOperationSuccess, removeSharedRootItems, }: UseDialFileSharingOptions) => UseDialFileSharingResult;
|
|
1098
1107
|
|
|
1099
1108
|
/** Options accepted by `useDialFileSharing`. */
|
|
1100
1109
|
export declare interface UseDialFileSharingOptions {
|
|
@@ -1108,6 +1117,10 @@ export declare interface UseDialFileSharingOptions {
|
|
|
1108
1117
|
bumpRetry: () => void;
|
|
1109
1118
|
/** Called when a sharing mutation fails and should surface a toast notification. */
|
|
1110
1119
|
onNotification?: (notification: FileManagerNotification) => void;
|
|
1120
|
+
/** Called with a structured event once an unshare succeeds, so the host can show its success toast. */
|
|
1121
|
+
onOperationSuccess?: (event: FileOperationSuccessEvent) => void;
|
|
1122
|
+
/** Removes the unshared root rows from the cached Shared listing ahead of the refetch. */
|
|
1123
|
+
removeSharedRootItems?: (names: string[]) => void;
|
|
1111
1124
|
}
|
|
1112
1125
|
|
|
1113
1126
|
/** Values returned by `useDialFileSharing`. */
|
package/file-manager.js
CHANGED
|
@@ -3,28 +3,28 @@ import { isDialFileAcceptType as r, mimeTypesToAttachmentExtensionLabels as i, m
|
|
|
3
3
|
import { sanitizeFileName as s, splitFileNameExtension as c, trimFileNameToByteLimit as l } from "./files/file-name.js";
|
|
4
4
|
import { DialFilesApiUploadMode as u } from "./files/dial-files-api.js";
|
|
5
5
|
import { FileManagerNotificationReason as d, FileNameValidationErrorReason as f, FileOperationKind as p } from "./files/dial-file-manager.types.js";
|
|
6
|
-
import {
|
|
7
|
-
import { buildSharedItemVirtualPath as
|
|
8
|
-
import { resolveDialFileApiPath as
|
|
9
|
-
import { prepareCopyItems as
|
|
10
|
-
import { buildFromCache as
|
|
11
|
-
import { createFilesApiClient as
|
|
12
|
-
import { createUploadFileWithProgress as
|
|
13
|
-
import { openAnnotationAttachment as
|
|
14
|
-
import { getUrlFileName as
|
|
15
|
-
import { annotationToDisplayAttachment as
|
|
16
|
-
import { dialFileToAttachment as
|
|
17
|
-
import { DownloadDestinationType as
|
|
18
|
-
import { prepareDownloadDestination as
|
|
19
|
-
import { deriveActionProfile as
|
|
20
|
-
import { useDialFileListing as
|
|
21
|
-
import { useDialFileMetadata as
|
|
22
|
-
import { useDialFileMutations as
|
|
23
|
-
import { useDialFileSharing as
|
|
24
|
-
import { useDialFileUploadBatch as
|
|
25
|
-
import { useDialFileManager as
|
|
26
|
-
import { useDialFileManagerSections as
|
|
27
|
-
import { useDialFileManagerTabConfig as
|
|
28
|
-
import { useFileAttachmentPicker as
|
|
29
|
-
import { useGridEditingScroll as
|
|
30
|
-
export { m as
|
|
6
|
+
import { COLUMNS_MY_FILES as m, COLUMNS_ORGANIZATION as h, COLUMNS_SHARED as g, CORE_PERMISSION_MAP as _, DATE_OPTIONS as v, DIAL_FILE_MANAGER_SECTION_TABS as y, PATH_SEPARATOR_REGEXP as b, RESERVED_MARKER_NAME as x, UPLOAD_CONCURRENCY as S } from "./files/dial-file-manager.model.js";
|
|
7
|
+
import { buildSharedItemVirtualPath as C, dialCorePathToRelative as w, findDialFileByPath as T, findFolderByVirtualPath as E, formatOperationFolderName as D, getVirtualPathName as O, hasDialFileWritePermission as k, hasForbiddenNameSymbols as A, hasSamePaths as j, isCopyMoveDuplicateAllowed as M, isShareActionsAllowed as N, normalizeVirtualPath as P, parseNewFolderVirtualPath as F, resolveOwnerCoords as I, resolveSectionByPath as L, unionPathSets as R, withRoutableRootLabels as z } from "./files/dial-file-manager-path.util.js";
|
|
8
|
+
import { resolveDialFileApiPath as B, virtualPathToApiPath as V } from "./files/resolve-dial-file-api-path.js";
|
|
9
|
+
import { prepareCopyItems as H, prepareMoveRenameItems as U } from "./files/dial-file-manager-copy-move.util.js";
|
|
10
|
+
import { buildFromCache as W, fetchByTab as G, fetchForSearch as K, findFirstSuccessfulCopyMoveItem as q, mapCorePermissions as J, mapFileMetadataToDialFile as Y, mapSearchItem as X, mergeCreatedFolderIntoCache as Z, updateEntry as Q } from "./files/dial-file-manager-mapping.util.js";
|
|
11
|
+
import { createFilesApiClient as $ } from "./files/create-files-api.js";
|
|
12
|
+
import { createUploadFileWithProgress as ee } from "./files/create-upload-file-with-progress.js";
|
|
13
|
+
import { openAnnotationAttachment as te } from "./files/annotation.js";
|
|
14
|
+
import { getUrlFileName as ne, isExternalSourcePreviewable as re, resolveExternalSourceContentType as ie } from "./files/source-content.js";
|
|
15
|
+
import { annotationToDisplayAttachment as ae, attachmentDtoToDisplayAttachment as oe, attachmentDtosToDisplayAttachments as se } from "./files/attachment-dto-to-display.js";
|
|
16
|
+
import { dialFileToAttachment as ce, dialFilesToAttachments as le, dialFolderPathToAttachment as ue } from "./files/dial-file-to-attachment.js";
|
|
17
|
+
import { DownloadDestinationType as de } from "./files/download-destination.js";
|
|
18
|
+
import { prepareDownloadDestination as fe } from "./files/prepare-download-destination.js";
|
|
19
|
+
import { deriveActionProfile as pe } from "./files/file-manager-variant.js";
|
|
20
|
+
import { useDialFileListing as me } from "./files/useDialFileListing/useDialFileListing.js";
|
|
21
|
+
import { useDialFileMetadata as he } from "./files/useDialFileMetadata/useDialFileMetadata.js";
|
|
22
|
+
import { useDialFileMutations as ge } from "./files/useDialFileMutations/useDialFileMutations.js";
|
|
23
|
+
import { useDialFileSharing as _e } from "./files/useDialFileSharing/useDialFileSharing.js";
|
|
24
|
+
import { useDialFileUploadBatch as ve } from "./files/useDialFileUploadBatch/useDialFileUploadBatch.js";
|
|
25
|
+
import { useDialFileManager as ye } from "./files/useDialFileManager/useDialFileManager.js";
|
|
26
|
+
import { useDialFileManagerSections as be } from "./files/useDialFileManagerSections/useDialFileManagerSections.js";
|
|
27
|
+
import { useDialFileManagerTabConfig as xe } from "./files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js";
|
|
28
|
+
import { useFileAttachmentPicker as Se } from "./files/useFileAttachmentPicker/useFileAttachmentPicker.js";
|
|
29
|
+
import { useGridEditingScroll as Ce } from "@epam/ai-dial-chat-shared";
|
|
30
|
+
export { m as COLUMNS_MY_FILES, h as COLUMNS_ORGANIZATION, g as COLUMNS_SHARED, _ as CORE_PERMISSION_MAP, v as DATE_OPTIONS, y as DIAL_FILE_MANAGER_SECTION_TABS, u as DialFilesApiUploadMode, de as DownloadDestinationType, d as FileManagerNotificationReason, f as FileNameValidationErrorReason, p as FileOperationKind, b as PATH_SEPARATOR_REGEXP, x as RESERVED_MARKER_NAME, S as UPLOAD_CONCURRENCY, ae as annotationToDisplayAttachment, oe as attachmentDtoToDisplayAttachment, se as attachmentDtosToDisplayAttachments, W as buildFromCache, C as buildSharedItemVirtualPath, $ as createFilesApiClient, ee as createUploadFileWithProgress, pe as deriveActionProfile, w as dialCorePathToRelative, ce as dialFileToAttachment, le as dialFilesToAttachments, ue as dialFolderPathToAttachment, G as fetchByTab, K as fetchForSearch, T as findDialFileByPath, q as findFirstSuccessfulCopyMoveItem, E as findFolderByVirtualPath, D as formatOperationFolderName, ne as getUrlFileName, O as getVirtualPathName, k as hasDialFileWritePermission, A as hasForbiddenNameSymbols, j as hasSamePaths, M as isCopyMoveDuplicateAllowed, r as isDialFileAcceptType, e as isDialFileId, re as isExternalSourcePreviewable, N as isShareActionsAllowed, J as mapCorePermissions, Y as mapFileMetadataToDialFile, X as mapSearchItem, Z as mergeCreatedFolderIntoCache, i as mimeTypesToAttachmentExtensionLabels, a as mimeTypesToDialFileAcceptTypes, o as mimeTypesToFileAccept, P as normalizeVirtualPath, te as openAnnotationAttachment, F as parseNewFolderVirtualPath, H as prepareCopyItems, fe as prepareDownloadDestination, U as prepareMoveRenameItems, B as resolveDialFileApiPath, t as resolveDialFileBucketAndPath, ie as resolveExternalSourceContentType, I as resolveOwnerCoords, n as resolveRelativeDialFilePath, L as resolveSectionByPath, s as sanitizeFileName, c as splitFileNameExtension, l as trimFileNameToByteLimit, R as unionPathSets, Q as updateEntry, me as useDialFileListing, ye as useDialFileManager, be as useDialFileManagerSections, xe as useDialFileManagerTabConfig, he as useDialFileMetadata, ge as useDialFileMutations, _e as useDialFileSharing, ve as useDialFileUploadBatch, Se as useFileAttachmentPicker, Ce as useGridEditingScroll, V as virtualPathToApiPath, z as withRoutableRootLabels };
|
|
@@ -14,19 +14,23 @@ var i = 3, a = e, o = /[/\\]/, s = {
|
|
|
14
14
|
r.Size,
|
|
15
15
|
r.Actions
|
|
16
16
|
], l = [
|
|
17
|
+
r.Name,
|
|
18
|
+
r.Author,
|
|
19
|
+
r.Actions
|
|
20
|
+
], u = [
|
|
17
21
|
r.Name,
|
|
18
22
|
r.UpdatedAt,
|
|
19
23
|
r.Size,
|
|
20
24
|
r.Author,
|
|
21
25
|
r.Actions
|
|
22
|
-
],
|
|
26
|
+
], d = {
|
|
23
27
|
READ: n.READ,
|
|
24
28
|
WRITE: n.WRITE,
|
|
25
29
|
SHARE: n.SHARE
|
|
26
|
-
},
|
|
30
|
+
}, f = [
|
|
27
31
|
t.MyFiles,
|
|
28
32
|
t.Shared,
|
|
29
33
|
t.Organization
|
|
30
34
|
];
|
|
31
35
|
//#endregion
|
|
32
|
-
export { c as
|
|
36
|
+
export { c as COLUMNS_MY_FILES, u as COLUMNS_ORGANIZATION, l as COLUMNS_SHARED, d as CORE_PERMISSION_MAP, s as DATE_OPTIONS, f as DIAL_FILE_MANAGER_SECTION_TABS, o as PATH_SEPARATOR_REGEXP, a as RESERVED_MARKER_NAME, i as UPLOAD_CONCURRENCY };
|
|
@@ -4,7 +4,7 @@ var e = /* @__PURE__ */ function(e) {
|
|
|
4
4
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
5
|
return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e;
|
|
6
6
|
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
-
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e.FileDuplicated = "fileDuplicated", e.FilesDuplicated = "filesDuplicated", e;
|
|
7
|
+
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e.FileDuplicated = "fileDuplicated", e.FilesDuplicated = "filesDuplicated", e.FilesUnshared = "filesUnshared", e;
|
|
8
8
|
}({});
|
|
9
9
|
//#endregion
|
|
10
10
|
export { e as FileManagerNotificationReason, t as FileNameValidationErrorReason, n as FileOperationKind };
|
|
@@ -27,11 +27,11 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
let t = !1;
|
|
30
|
-
return A(!0), j(null), s(_, b, v, C, L.current).then(({ items: e, permissions:
|
|
30
|
+
return A(!0), j(null), s(_, b, v, C, L.current).then(({ items: e, permissions: n }) => {
|
|
31
31
|
t || (E((t) => {
|
|
32
32
|
let n = new Map(t);
|
|
33
33
|
return n.set(C, e), n;
|
|
34
|
-
}), k((e) => new Map(e).set(C,
|
|
34
|
+
}), k((e) => new Map(e).set(C, n)), b === g.Shared && C === "" && (F(e.map((e) => e.nodeType === m.Folder ? `/${y}/${e.name}/` : `/${y}/${e.name}`)), L.current = new Map(e.map((e) => [e.name, {
|
|
35
35
|
bucket: e.bucket ?? "",
|
|
36
36
|
dialCorePath: e.path
|
|
37
37
|
}]))));
|
|
@@ -144,6 +144,15 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
144
144
|
]), ve = l((e, t, n) => {
|
|
145
145
|
E((r) => re(r, e, t, n));
|
|
146
146
|
}, []), ye = l((e) => {
|
|
147
|
+
if (e.length === 0) return;
|
|
148
|
+
let t = new Set(e);
|
|
149
|
+
E((e) => {
|
|
150
|
+
let n = e.get("");
|
|
151
|
+
if (n == null) return e;
|
|
152
|
+
let r = new Map(e);
|
|
153
|
+
return r.set("", n.filter((e) => !t.has(e.name))), r;
|
|
154
|
+
}), F((t) => t?.filter((t) => !e.some((e) => t === `/${y}/${e}`)));
|
|
155
|
+
}, [y]), be = l((e) => {
|
|
147
156
|
if (!S) return;
|
|
148
157
|
let n = e == null ? "" : o(e, y), r = e ?? `/${y}`;
|
|
149
158
|
if (J((e) => {
|
|
@@ -185,7 +194,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
185
194
|
S,
|
|
186
195
|
x,
|
|
187
196
|
y
|
|
188
|
-
]),
|
|
197
|
+
]), xe = d(() => {
|
|
189
198
|
let e = /* @__PURE__ */ new Set(), t = new Set([...W, ...q]);
|
|
190
199
|
for (let n of t) {
|
|
191
200
|
let t = o(n, y);
|
|
@@ -197,7 +206,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
197
206
|
q,
|
|
198
207
|
T,
|
|
199
208
|
y
|
|
200
|
-
]),
|
|
209
|
+
]), Se = l((e) => {
|
|
201
210
|
S && (W.forEach((t) => {
|
|
202
211
|
e.has(t) || U.current.delete(o(t, y));
|
|
203
212
|
}), G(e), [...e].filter((e) => {
|
|
@@ -230,9 +239,9 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
230
239
|
S,
|
|
231
240
|
x,
|
|
232
241
|
y
|
|
233
|
-
]),
|
|
242
|
+
]), Ce = l(() => {
|
|
234
243
|
B.current != null && (clearTimeout(B.current), B.current = null), V.current?.(), V.current = null, z(null), R(!1);
|
|
235
|
-
}, []),
|
|
244
|
+
}, []), we = l((e, t) => {
|
|
236
245
|
if (S) {
|
|
237
246
|
if (B.current != null && (clearTimeout(B.current), B.current = null), V.current?.(), V.current = null, !t.trim()) {
|
|
238
247
|
z(null), R(!1);
|
|
@@ -267,7 +276,7 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
267
276
|
C,
|
|
268
277
|
S,
|
|
269
278
|
y
|
|
270
|
-
]), $ = C ? `/${y}/${C}` : `/${y}`,
|
|
279
|
+
]), $ = C ? `/${y}/${C}` : `/${y}`, Te = d(() => {
|
|
271
280
|
let e = Z[0];
|
|
272
281
|
if (e) return a($) === a(`/${y}`) ? e : i(e.items ?? [], $);
|
|
273
282
|
}, [
|
|
@@ -283,25 +292,26 @@ var _ = ({ filesApi: _, bucket: v, rootLabel: y, activeTab: b, onNotification: x
|
|
|
283
292
|
folderPath: C,
|
|
284
293
|
onPathChange: he,
|
|
285
294
|
retry: Q,
|
|
286
|
-
onSearchFiles:
|
|
295
|
+
onSearchFiles: we,
|
|
287
296
|
isSearching: fe,
|
|
288
297
|
searchResults: pe,
|
|
289
|
-
clearSearchResults:
|
|
298
|
+
clearSearchResults: Ce,
|
|
290
299
|
expandedPaths: W,
|
|
291
|
-
loadedPaths:
|
|
292
|
-
onExpandedPathsChange:
|
|
293
|
-
onFolderPopupPathChange:
|
|
300
|
+
loadedPaths: xe,
|
|
301
|
+
onExpandedPathsChange: Se,
|
|
302
|
+
onFolderPopupPathChange: be,
|
|
294
303
|
folderPopupLoadingPaths: me,
|
|
295
304
|
sharedWithMeIds: d(() => b === g.Shared ? P : void 0, [b, P]),
|
|
296
305
|
sharedByMePaths: de,
|
|
297
|
-
currentFolder:
|
|
306
|
+
currentFolder: Te,
|
|
298
307
|
cache: T,
|
|
299
308
|
listingPermissionsCache: O,
|
|
300
309
|
sharedRootMetaRef: L,
|
|
301
310
|
setFolderPath: w,
|
|
302
311
|
invalidateFolders: _e,
|
|
303
312
|
mergeCreatedFolder: ve,
|
|
304
|
-
bumpRetry: ge
|
|
313
|
+
bumpRetry: ge,
|
|
314
|
+
removeSharedRootItems: ye
|
|
305
315
|
};
|
|
306
316
|
};
|
|
307
317
|
//#endregion
|