@epam/ai-dial-chat-hooks 1.2.0-rc.0 → 1.3.0-dev.10

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,280 +1,282 @@
1
- import { FileManagerNotificationReason as e, FileNameValidationErrorReason as t, FileOperationKind as n } from "../dial-file-manager.types.js";
2
- import { RESERVED_MARKER_NAME as r } from "../dial-file-manager.model.js";
3
- import { formatOperationFolderName as i, getVirtualPathName as a, hasForbiddenNameSymbols as o, parseNewFolderVirtualPath as s, resolveOwnerCoords as c } from "../dial-file-manager-path.util.js";
4
- import { resolveDialFileApiPath as l, virtualPathToApiPath as u } from "../resolve-dial-file-api-path.js";
5
- import { prepareCopyItems as d, prepareMoveRenameItems as f } from "../dial-file-manager-copy-move.util.js";
6
- import { findFirstSuccessfulCopyMoveItem as p } from "../dial-file-manager-mapping.util.js";
7
- import { DownloadDestinationType as m } from "../download-destination.js";
8
- import { getParentFolderPath as h } from "@epam/ai-dial-chat-shared";
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 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";
1
+ import { splitFileNameExtension as e } from "../file-name.js";
2
+ import { FileManagerNotificationReason as t, FileNameValidationErrorReason as n, FileOperationKind as r } from "../dial-file-manager.types.js";
3
+ import { RESERVED_MARKER_NAME as i } from "../dial-file-manager.model.js";
4
+ import { formatOperationFolderName as a, getVirtualPathName as o, hasForbiddenNameSymbols as s, parseNewFolderVirtualPath as c, resolveOwnerCoords as l } from "../dial-file-manager-path.util.js";
5
+ import { resolveDialFileApiPath as u, virtualPathToApiPath as d } from "../resolve-dial-file-api-path.js";
6
+ import { prepareCopyItems as f, prepareMoveRenameItems as p } from "../dial-file-manager-copy-move.util.js";
7
+ import { findFirstSuccessfulCopyMoveItem as m } from "../dial-file-manager-mapping.util.js";
8
+ import { DownloadDestinationType as h } from "../download-destination.js";
9
+ import { getParentFolderPath as g } from "@epam/ai-dial-chat-shared";
10
+ import { useCallback as _, useRef as v, useState as y } from "react";
11
+ import { ArchiveItemDtoNodeTypeEnum as b, CopyItemDtoNodeTypeEnum as x, DeleteItemDtoNodeTypeEnum as S, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as C } from "@epam/ai-dial-chat-api-client";
12
+ import { NOT_ALLOWED_SYMBOLS as te, NotificationVariant as w } from "@epam/ai-dial-ui-kit";
13
+ import { DialFileManagerTabs as T, DialFileNodeType as E } from "@epam/ai-dial-react-file-manager";
13
14
  //#region src/files/useDialFileMutations/useDialFileMutations.ts
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
- let i = null;
17
- if (!e || e.trim() === "") i = { reason: t.Empty };
18
- else if (o(e, V)) i = {
19
- reason: t.ForbiddenSymbols,
20
- symbols: S
15
+ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, currentFolder: M, sharedRootMetaRef: N, listingPermissionsCache: P, invalidateFolders: F, bumpRetry: I, mergeCreatedFolder: L, setFolderPath: R, onNotification: z, onOperationSuccess: B, downloadDestination: V, forbiddenSymbolsRegExp: H }) => {
16
+ let [ne, U] = y(!1), [re, W] = y(!1), [ie, G] = y(!1), [K, q] = y(!1), [J, Y] = y(!1), [X, ae] = y(!1), Z = v(null), Q = v(null), $ = _((e, t) => {
17
+ let r = null;
18
+ if (!e || e.trim() === "") r = { reason: n.Empty };
19
+ else if (s(e, H)) r = {
20
+ reason: n.ForbiddenSymbols,
21
+ symbols: te
21
22
  };
22
- else if (e === r) i = { reason: t.ReservedName };
23
- else if (e.length > 255) i = {
24
- reason: t.TooLong,
23
+ else if (e === i) r = { reason: n.ReservedName };
24
+ else if (e.length > 255) r = {
25
+ reason: n.TooLong,
25
26
  maxLength: 255
26
27
  };
27
28
  else {
28
- let r = n.items ?? [], a = e.toLowerCase(), o = r.find((e) => e.name.toLowerCase() === a);
29
- o && (i = {
30
- reason: t.DuplicateName,
29
+ let i = t.items ?? [], a = e.toLowerCase(), o = i.find((e) => e.name.toLowerCase() === a);
30
+ o && (r = {
31
+ reason: n.DuplicateName,
31
32
  existingName: o.name
32
33
  });
33
34
  }
34
- return Q.current = i, i;
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
- id: l,
38
- path: l,
35
+ return Q.current = r, r;
36
+ }, [H]), oe = _(async (e, n, i) => {
37
+ let { parentVirtualPath: a, name: o } = c(n, k), s = d(a, k), u = M && j === s ? M : {
38
+ id: s,
39
+ path: s,
39
40
  name: a.split("/").filter(Boolean).pop() ?? "",
40
- folderId: l,
41
- nodeType: T.FOLDER,
41
+ folderId: s,
42
+ nodeType: E.FOLDER,
42
43
  items: []
43
44
  }, f = Q.current;
44
- if (Q.current = null, $(o, d) || f) return;
45
- H(!0);
46
- let { bucket: p, path: m } = k === w.Shared ? c(l, M.current, D) : {
47
- bucket: D,
48
- path: l
45
+ if (Q.current = null, $(o, u) || f) return;
46
+ U(!0);
47
+ let { bucket: p, path: m } = A === T.Shared ? l(s, N.current, O) : {
48
+ bucket: O,
49
+ path: s
49
50
  };
50
51
  try {
51
- I(l, await E.createFolder({
52
+ L(s, await D.createFolder({
52
53
  bucket: p,
53
54
  parentPath: m,
54
55
  name: o
55
- }), N.get(l)), F(), z?.({
56
- kind: n.FolderCreated,
56
+ }), P.get(s)), I(), B?.({
57
+ kind: r.FolderCreated,
57
58
  name: o
58
59
  });
59
60
  } catch {
60
- R?.({
61
- variant: C.Error,
62
- reason: e.FolderCreateFailed
61
+ z?.({
62
+ variant: w.Error,
63
+ reason: t.FolderCreateFailed
63
64
  });
64
65
  } finally {
65
- H(!1);
66
+ U(!1);
66
67
  }
67
68
  }, [
68
- k,
69
+ A,
70
+ O,
71
+ M,
69
72
  D,
70
73
  j,
71
- E,
72
- A,
73
74
  $,
74
- O,
75
- N,
75
+ k,
76
+ P,
77
+ L,
76
78
  I,
77
- F,
78
- z,
79
- M,
80
- R
81
- ]), oe = g((t) => {
79
+ B,
80
+ N,
81
+ z
82
+ ]), se = _((e) => {
82
83
  (async () => {
83
- U(!0);
84
+ W(!0);
84
85
  try {
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
- if (r.type === m.Cancelled) return;
87
- if (t.length === 1 && t[0].nodeType === T.ITEM) {
88
- let e = t[0];
89
- if (!e.bucket) throw Error("File is missing bucket");
90
- let i = l(e, e.bucket, O), a = await E.downloadFile(e.bucket, i);
86
+ let t = e.length === 1 ? e[0].nodeType === E.ITEM ? e[0].name : `${e[0].name}.zip` : "files.zip", n = await V.resolveDestination(t, e.length === 1 && e[0].nodeType === E.ITEM ? e[0].contentType ?? "application/octet-stream" : "application/zip");
87
+ if (n.type === h.Cancelled) return;
88
+ if (e.length === 1 && e[0].nodeType === E.ITEM) {
89
+ let t = e[0];
90
+ if (!t.bucket) throw Error("File is missing bucket");
91
+ let i = u(t, t.bucket, k), a = await D.downloadFile(t.bucket, i);
91
92
  if (!a.ok) throw Error(`Download failed with status ${a.status}`);
92
- let o = await B.triggerDownload(a, e.name, r);
93
- z?.({
94
- kind: n.FileDownloaded,
93
+ let o = await V.triggerDownload(a, t.name, n);
94
+ B?.({
95
+ kind: r.FileDownloaded,
95
96
  name: o,
96
97
  count: 1
97
98
  });
98
99
  } else {
99
- let i = t.map((e) => ({
100
- bucket: e.bucket ?? D,
101
- path: l(e, e.bucket ?? D, O),
100
+ let i = e.map((e) => ({
101
+ bucket: e.bucket ?? O,
102
+ path: u(e, e.bucket ?? O, k),
102
103
  name: e.name,
103
- nodeType: e.nodeType === T.FOLDER ? y.Folder : y.Item
104
- })), a = await E.downloadArchive(i);
104
+ nodeType: e.nodeType === E.FOLDER ? b.Folder : b.Item
105
+ })), a = await D.downloadArchive(i);
105
106
  if (!a.ok) throw Error(`Download failed with status ${a.status}`);
106
- let o = await B.triggerDownload(a, e, r);
107
- t.length === 1 ? z?.({
108
- kind: n.FileDownloaded,
107
+ let o = await V.triggerDownload(a, t, n);
108
+ e.length === 1 ? B?.({
109
+ kind: r.FileDownloaded,
109
110
  name: o
110
- }) : z?.({
111
- kind: n.FilesDownloaded,
112
- count: t.length
111
+ }) : B?.({
112
+ kind: r.FilesDownloaded,
113
+ count: e.length
113
114
  });
114
115
  }
115
116
  } catch {
116
- R?.({
117
- variant: C.Error,
118
- reason: t.length === 1 ? e.DownloadFileFailed : e.DownloadFilesFailed
117
+ z?.({
118
+ variant: w.Error,
119
+ reason: e.length === 1 ? t.DownloadFileFailed : t.DownloadFilesFailed
119
120
  });
120
121
  } finally {
121
- U(!1);
122
+ W(!1);
122
123
  }
123
124
  })();
124
125
  }, [
125
- D,
126
126
  O,
127
+ k,
128
+ B,
127
129
  z,
128
- R,
129
- E,
130
- B
131
- ]), se = g((t, n) => {
132
- t.length !== 0 && (async () => {
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(/\/$/, "");
130
+ D,
131
+ V
132
+ ]), ce = _((e, n) => {
133
+ e.length !== 0 && (async () => {
134
+ G(!0);
135
+ let r = [], i = e.map((e) => {
136
+ let t = e.nodeType === E.FOLDER, n = d(e.sourceUrl, k), i = t ? n : n.replace(/\/$/, "");
136
137
  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,
138
+ let a = o(e.sourceUrl, i), { bucket: s, path: c } = A === T.Shared ? l(i, N.current, O) : {
139
+ bucket: O,
139
140
  path: i
140
141
  };
141
142
  return {
142
143
  bucket: s,
143
- path: l,
144
- name: o,
145
- nodeType: t ? x.Folder : x.Item
144
+ path: c,
145
+ name: a,
146
+ nodeType: t ? S.Folder : S.Item
146
147
  };
147
148
  });
148
149
  try {
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,
152
- reason: e.FilesDeleted,
150
+ let { results: e } = await D.deleteFiles(i), r = e.filter((e) => !e.success), a = r.length, o = e.length - a, s = e.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
151
+ if (o > 0 && z?.({
152
+ variant: w.Success,
153
+ reason: t.FilesDeleted,
153
154
  count: o,
154
155
  name: c?.name,
155
- folder: n || O
156
+ folder: n || k
156
157
  }), a > 0) {
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,
160
- reason: e.FilesDeletePartiallyFailed,
161
- names: t,
158
+ let e = r.slice(0, 3).map((e) => i.find((t) => t.path === e.path)?.name ?? e.path), n = a - e.length;
159
+ z?.({
160
+ variant: w.Error,
161
+ reason: t.FilesDeletePartiallyFailed,
162
+ names: e,
162
163
  restCount: n
163
164
  });
164
165
  }
165
166
  } catch {
166
- R?.({
167
- variant: C.Error,
168
- reason: e.DeleteFailed
167
+ z?.({
168
+ variant: w.Error,
169
+ reason: t.DeleteFailed
169
170
  });
170
171
  }
171
- P([...new Set(i.map((e) => {
172
- if (e.nodeType === x.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
172
+ F([...new Set(i.map((e) => {
173
+ if (e.nodeType === S.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
173
174
  let t = e.path.lastIndexOf("/");
174
175
  return t > 0 ? e.path.slice(0, t + 1) : "";
175
176
  }))]);
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);
177
+ let a = r.filter((e) => j.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
178
+ a != null && R(g(a)), I(), G(!1);
178
179
  })();
179
180
  }, [
181
+ A,
182
+ O,
180
183
  k,
184
+ j,
185
+ z,
181
186
  D,
182
- O,
183
- A,
184
- R,
185
- E,
186
- M,
187
- P,
187
+ N,
188
188
  F,
189
- L
190
- ]), ce = g((e, n) => {
191
- if (!e || e.trim() === "") return { reason: t.Empty };
192
- if (e === r) return { reason: t.ReservedName };
193
- if (o(e, V)) return {
194
- reason: t.ForbiddenSymbols,
195
- symbols: S
189
+ I,
190
+ R
191
+ ]), le = _((t, r) => {
192
+ if (!t || t.trim() === "") return { reason: n.Empty };
193
+ let a = r.nodeType === E.ITEM ? e(r.name).extension : "";
194
+ if (t === i || a !== "" && t === `${i}${a}`) return { reason: n.ReservedName };
195
+ if (s(t, H)) return {
196
+ reason: n.ForbiddenSymbols,
197
+ symbols: te
196
198
  };
197
- if (e.length > 255) return {
198
- reason: t.TooLong,
199
+ if (t.length > 255) return {
200
+ reason: n.TooLong,
199
201
  maxLength: 255
200
202
  };
201
- let i = j?.items ?? [], a = e.toLowerCase(), s = i.find((e) => e.path !== n.path && e.name.toLowerCase() === a);
202
- return s ? {
203
- reason: t.DuplicateName,
204
- existingName: s.name
203
+ let o = M?.items ?? [], c = t.toLowerCase(), l = o.find((e) => e.path !== r.path && e.name.toLowerCase() === c);
204
+ return l ? {
205
+ reason: n.DuplicateName,
206
+ existingName: l.name
205
207
  } : null;
206
- }, [V, j]), le = g((t, r) => {
207
- if (t.length === 0 || q || Y) return;
208
- let a = new AbortController();
209
- Z.current = a, (async () => {
210
- J(!0);
211
- let o = d(t, D, O), s = o.map(({ dto: e }) => e);
208
+ }, [H, M]), ue = _((e, n) => {
209
+ if (e.length === 0 || J || X) return;
210
+ let i = new AbortController();
211
+ Z.current = i, (async () => {
212
+ Y(!0);
213
+ let o = f(e, O, k), s = o.map(({ dto: e }) => e);
212
214
  try {
213
- let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
215
+ let { results: e } = await D.copyFiles(s, i.signal), c = e.filter((e) => !e.success).length, l = e.length - c;
214
216
  if (l > 0) {
215
- let e = p(o, t), a = s.every((e) => h(e.sourcePath) === h(e.destinationPath)), c;
216
- c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied, z?.({
217
+ let t = m(o, e), i = s.every((e) => g(e.sourcePath) === g(e.destinationPath)), c;
218
+ c = i ? l === 1 ? r.FileDuplicated : r.FilesDuplicated : l === 1 ? r.FileCopied : r.FilesCopied, B?.({
217
219
  kind: c,
218
- name: e?.destinationName,
220
+ name: t?.destinationName,
219
221
  count: l,
220
- isFolder: e?.dto.nodeType === b.Folder,
221
- destinationFolderName: i(r, O)
222
+ isFolder: t?.dto.nodeType === x.Folder,
223
+ destinationFolderName: a(n, k)
222
224
  });
223
225
  }
224
- c > 0 && c < t.length ? R?.({
225
- variant: C.Error,
226
- reason: e.CopyPartiallyFailed,
226
+ c > 0 && c < e.length ? z?.({
227
+ variant: w.Error,
228
+ reason: t.CopyPartiallyFailed,
227
229
  count: c
228
- }) : c === t.length && R?.({
229
- variant: C.Error,
230
- reason: e.CopyFailed
230
+ }) : c === e.length && z?.({
231
+ variant: w.Error,
232
+ reason: t.CopyFailed
231
233
  });
232
234
  } catch {
233
- a.signal.aborted || R?.({
234
- variant: C.Error,
235
- reason: e.CopyFailed
235
+ i.signal.aborted || z?.({
236
+ variant: w.Error,
237
+ reason: t.CopyFailed
236
238
  });
237
239
  } finally {
238
- P([...new Set(s.flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), J(!1), Z.current = null;
240
+ F([...new Set(s.flatMap((e) => [g(e.sourcePath), g(e.destinationPath)]))]), I(), Y(!1), Z.current = null;
239
241
  }
240
242
  })();
241
243
  }, [
242
- D,
243
244
  O,
244
- R,
245
+ k,
245
246
  z,
246
- E,
247
- q,
248
- Y,
249
- P,
250
- F
251
- ]), ue = g(() => {
247
+ B,
248
+ D,
249
+ J,
250
+ X,
251
+ F,
252
+ I
253
+ ]), de = _(() => {
252
254
  Z.current?.abort();
253
255
  }, []);
254
256
  return {
255
257
  isCreatingFolder: ne,
256
258
  isDownloading: re,
257
259
  isDeleting: ie,
258
- isRenaming: G,
259
- isCopying: q,
260
- isMoving: Y,
261
- onCreateFolder: ae,
260
+ isRenaming: K,
261
+ isCopying: J,
262
+ isMoving: X,
263
+ onCreateFolder: oe,
262
264
  onCreateFolderValidate: $,
263
- onDownloadFiles: oe,
264
- onDeleteFiles: se,
265
- onRenameValidate: ce,
266
- onMoveToFiles: g((t, r, o) => {
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();
265
+ onDownloadFiles: se,
266
+ onDeleteFiles: ce,
267
+ onRenameValidate: le,
268
+ onMoveToFiles: _((e, n, i) => {
269
+ if (e.length === 0 || J || X || K) return;
270
+ let { renameDtos: s, preparedMoveItems: c } = p(e, O, k), l = c.map(({ dto: e }) => e), u = new AbortController();
269
271
  l.length > 0 && (Z.current = u), (async () => {
270
- s.length > 0 && K(!0), l.length > 0 && X(!0);
271
- let [t, r] = await Promise.all([(async () => {
272
+ s.length > 0 && q(!0), l.length > 0 && ae(!0);
273
+ let [e, n] = await Promise.all([(async () => {
272
274
  if (s.length === 0) return {
273
275
  results: [],
274
276
  threw: !1
275
277
  };
276
278
  try {
277
- let { results: e } = await E.renameFiles(s);
279
+ let { results: e } = await D.renameFiles(s);
278
280
  return {
279
281
  results: e,
280
282
  threw: !1
@@ -292,7 +294,7 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
292
294
  aborted: !1
293
295
  };
294
296
  try {
295
- let { results: e } = await E.moveFiles(l, u.signal);
297
+ let { results: e } = await D.moveFiles(l, u.signal);
296
298
  return {
297
299
  results: e,
298
300
  threw: !1,
@@ -305,60 +307,60 @@ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, cu
305
307
  aborted: u.signal.aborted
306
308
  };
307
309
  }
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;
310
+ })()]), d = e.threw ? s.length : e.results.filter((e) => !e.success).length, f = n.threw && n.aborted, p = f ? 0 : l.length, h = f ? 0 : n.threw ? l.length : n.results.filter((e) => !e.success).length, _ = n.threw ? 0 : n.results.filter((e) => e.success).length, v = s.length + p, y = d + h, b = h > 0;
309
311
  if (_ > 0) {
310
- let e = p(c, r.results);
311
- z?.({
312
- kind: _ === 1 ? n.FileMoved : n.FilesMoved,
312
+ let e = m(c, n.results);
313
+ B?.({
314
+ kind: _ === 1 ? r.FileMoved : r.FilesMoved,
313
315
  name: e?.destinationName,
314
316
  count: _,
315
317
  isFolder: e?.dto.nodeType === ee.Folder,
316
- destinationFolderName: i(o, O)
318
+ destinationFolderName: a(i, k)
317
319
  });
318
320
  }
319
321
  if (s.length === 1 && d === 0) {
320
322
  let [e] = s;
321
- z?.({
322
- kind: n.FileRenamed,
323
- name: a(e.destinationPath, e.destinationPath),
324
- isFolder: e.nodeType === te.Folder
323
+ B?.({
324
+ kind: r.FileRenamed,
325
+ name: o(e.destinationPath, e.destinationPath),
326
+ isFolder: e.nodeType === C.Folder
325
327
  });
326
328
  }
327
- y > 0 && (y === v ? R?.({
328
- variant: C.Error,
329
- reason: b ? e.MoveFailed : e.RenameFailed
330
- }) : R?.({
331
- variant: C.Error,
332
- reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
329
+ y > 0 && (y === v ? z?.({
330
+ variant: w.Error,
331
+ reason: b ? t.MoveFailed : t.RenameFailed
332
+ }) : z?.({
333
+ variant: w.Error,
334
+ reason: b ? t.MovePartiallyFailed : t.RenamePartiallyFailed,
333
335
  count: y
334
336
  }));
335
- let x = s.find((e) => e.nodeType === te.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
337
+ let x = s.find((t) => t.nodeType === C.Folder && e.results.some((e) => e.success && e.sourcePath === t.sourcePath));
336
338
  if (x != null) {
337
339
  let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
338
- if (A === e || A.startsWith(e)) {
340
+ if (j === e || j.startsWith(e)) {
339
341
  let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
340
- L(A.replace(e, t));
342
+ R(j.replace(e, t));
341
343
  }
342
344
  }
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);
345
+ F([...new Set([...s, ...l].flatMap((e) => [g(e.sourcePath), g(e.destinationPath)]))]), I(), q(!1), ae(!1), l.length > 0 && (Z.current = null);
344
346
  })();
345
347
  }, [
346
- D,
347
348
  O,
348
- A,
349
+ k,
350
+ j,
351
+ B,
349
352
  z,
350
- R,
351
- E,
352
- q,
353
- Y,
354
- G,
355
- P,
353
+ D,
354
+ J,
355
+ X,
356
+ K,
356
357
  F,
357
- L
358
+ I,
359
+ R
358
360
  ]),
359
- onCopyFiles: le,
360
- cancelCopyMove: ue
361
+ onCopyFiles: ue,
362
+ cancelCopyMove: de
361
363
  };
362
364
  };
363
365
  //#endregion
364
- export { E as useDialFileMutations };
366
+ export { D as useDialFileMutations };
package/index.d.ts CHANGED
@@ -817,9 +817,11 @@ declare interface CodeCanvasContent {
817
817
  language?: string;
818
818
  }
819
819
 
820
- export declare const COLUMNS_WITH_AUTHOR: FileManagerColumnKey[];
820
+ export declare const COLUMNS_MY_FILES: FileManagerColumnKey[];
821
821
 
822
- export declare const COLUMNS_WITHOUT_AUTHOR: FileManagerColumnKey[];
822
+ export declare const COLUMNS_ORGANIZATION: FileManagerColumnKey[];
823
+
824
+ export declare const COLUMNS_SHARED: FileManagerColumnKey[];
823
825
 
824
826
  /**
825
827
  * Composes the "Add locale" popup's entries into the write-payload shape:
@@ -963,6 +965,13 @@ export declare interface ConversationStreamTransport {
963
965
  attachToGeneration(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
964
966
  /** Reloads the persisted conversation by its full (bucket-qualified) id. */
965
967
  getConversation(conversationId: string, signal?: AbortSignal): Promise<Conversation>;
968
+ /**
969
+ * Saves `conversation` at the bucket-stripped `path`, resolving with the saved
970
+ * conversation. Used only for the single recovery save after the backend's
971
+ * terminal save was rejected with `401`; without it that failure shows the
972
+ * persistence warning immediately.
973
+ */
974
+ saveConversation?(path: string, conversation: Conversation): Promise<Conversation>;
966
975
  }
967
976
 
968
977
  export { ConversationTransferErrorCode }
@@ -1875,7 +1884,13 @@ export declare class GenerationConflictError extends Error {
1875
1884
  /** Identifies a failed terminal save independently of the model's generation outcome. */
1876
1885
  export declare class GenerationPersistenceError extends Error {
1877
1886
  static readonly type = "conversation_save_failed";
1878
- constructor();
1887
+ /** HTTP status of the rejected terminal write, when the backend reported one. */
1888
+ readonly status?: number;
1889
+ /**
1890
+ * Creates the error with the default persistence message.
1891
+ * @param status - HTTP status of the rejected terminal write, if known
1892
+ */
1893
+ constructor(status?: number);
1879
1894
  }
1880
1895
 
1881
1896
  /** Normalizes any API error into a `{ status?, message, traceId?, code?, upstreamCode?, upstreamMessage? }` shape. */