useblocks 1.1.45 → 1.1.46
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/iframe/js/amp.CVC2Iq48.js +1 -1
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.4N5s3OV-.js +1 -1
- package/npm-publish.manifest.json +7 -7
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{5e0828e3.js → 350eac23.js} +3 -3
- package/static/core/{2f2019c1.js → 35e13192.js} +253 -239
- package/static/core/{bc098620.js → 4a2af478.js} +3 -3
- package/static/core/{ed0ecf0a.js → 4eb628d3.js} +5 -5
- package/static/core/{d14cb6e2.js → 526b23c2.js} +7 -7
- package/static/core/{48b80eec.js → 6b8432a3.js} +3 -3
- package/static/core/{b7a9d262.js → 6df04323.js} +248 -248
- package/static/core/{94f2c0df.js → 6e2d88d5.js} +8959 -8844
- package/static/core/{6450546e2.js → 90ec6d2b2.js} +7 -7
- package/static/core/{632d894f.js → 9421a704.js} +3 -3
- package/static/core/{fd4fa049.js → 9c1c1b89.js} +4 -4
- package/static/core/{ff830d19.js → 9c79239d.js} +899 -882
- package/static/core/{7d884291.js → a321a57d.js} +32 -32
- package/static/core/{8c84cc76.js → b8b730b2.js} +15 -15
- package/static/core/{af153381.js → b9529b8a.js} +6405 -6131
- package/static/core/{cb72ea5e.js → cc8f145d.js} +86 -86
- package/static/core/{bb774fb9.js → cefd6620.js} +636 -603
- package/static/core/df0652cc.js +1119 -0
- package/two_step_headless_plugin.html +1 -1
- package/{useblocks-core.ecd1a3b0.js → useblocks-core.2116f1b9.js} +6 -6
- package/useblocks-esm.js +5 -4
- package/useblocks.d.ts +6 -0
- package/useblocks.js +5 -4
- package/static/core/c28bc42e.js +0 -46
- /package/iframe/{iframe-eblock.ecd1a3b0.html → iframe-eblock.2116f1b9.html} +0 -0
- /package/iframe/{iframe.ecd1a3b0.html → iframe.2116f1b9.html} +0 -0
|
@@ -0,0 +1,1119 @@
|
|
|
1
|
+
__useblocks__.define("static/core/df0652cc.js", [
|
|
2
|
+
"require",
|
|
3
|
+
"exports",
|
|
4
|
+
"module",
|
|
5
|
+
"static/core/cefd6620.js",
|
|
6
|
+
"static/core/350eac23.js",
|
|
7
|
+
"static/core/6e2d88d5.js",
|
|
8
|
+
"static/core/90ec6d2b2.js"
|
|
9
|
+
], function(j, b, z) {
|
|
10
|
+
const g = j("./cefd6620.js"), v = j("./350eac23.js"), m = j("./6e2d88d5.js");
|
|
11
|
+
j("./90ec6d2b2.js");
|
|
12
|
+
var F;
|
|
13
|
+
(function(t) {
|
|
14
|
+
function e(a, o, n = (i, d) => i === d) {
|
|
15
|
+
if (a === o) return !0;
|
|
16
|
+
if (a.length !== o.length) return !1;
|
|
17
|
+
for (let i = 0; i < a.length; i++) if (!n(a[i], o[i])) return !1;
|
|
18
|
+
return !0;
|
|
19
|
+
}
|
|
20
|
+
t.isEqual = e;
|
|
21
|
+
function r(a, o = (n) => n) {
|
|
22
|
+
const n = new Set();
|
|
23
|
+
return a.filter((i) => {
|
|
24
|
+
const d = o(i);
|
|
25
|
+
return n.has(d) ? !1 : (n.add(d), !0);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
t.unique = r;
|
|
29
|
+
function s(a = [], o = [], n = (i, d) => i === d) {
|
|
30
|
+
const i = [], d = [], h = [];
|
|
31
|
+
for (const l of a) {
|
|
32
|
+
const c = o.find((y) => n(l, y));
|
|
33
|
+
c ? h.push({
|
|
34
|
+
prev: l,
|
|
35
|
+
next: c
|
|
36
|
+
}) : d.push(l);
|
|
37
|
+
}
|
|
38
|
+
for (const l of o) a.find((c) => n(l, c)) || i.push(l);
|
|
39
|
+
return {
|
|
40
|
+
added: i,
|
|
41
|
+
removed: d,
|
|
42
|
+
exists: h
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
t.diff = s;
|
|
46
|
+
})(F || (F = {}));
|
|
47
|
+
var T = (function(t) {
|
|
48
|
+
return t.Json = "application/json", t.JsonApi = "application/vnd.api+json", t.FormData = "multipart/form-data", t.UrlEncoded = "application/x-www-form-urlencoded", t.Text = "text/plain", t;
|
|
49
|
+
})({}), O = class {
|
|
50
|
+
baseUrl = "/api/v2";
|
|
51
|
+
securityData = null;
|
|
52
|
+
securityWorker;
|
|
53
|
+
abortControllers = new Map();
|
|
54
|
+
customFetch = (...t) => fetch(...t);
|
|
55
|
+
baseApiParams = {
|
|
56
|
+
credentials: "same-origin",
|
|
57
|
+
headers: {},
|
|
58
|
+
redirect: "follow",
|
|
59
|
+
referrerPolicy: "no-referrer"
|
|
60
|
+
};
|
|
61
|
+
constructor(t = {}) {
|
|
62
|
+
Object.assign(this, t);
|
|
63
|
+
}
|
|
64
|
+
setSecurityData = (t) => {
|
|
65
|
+
this.securityData = t;
|
|
66
|
+
};
|
|
67
|
+
encodeQueryParam(t, e) {
|
|
68
|
+
return `${encodeURIComponent(t)}=${encodeURIComponent(typeof e == "number" ? e : `${e}`)}`;
|
|
69
|
+
}
|
|
70
|
+
addQueryParam(t, e) {
|
|
71
|
+
return this.encodeQueryParam(e, t[e]);
|
|
72
|
+
}
|
|
73
|
+
addArrayQueryParam(t, e) {
|
|
74
|
+
return t[e].map((r) => this.encodeQueryParam(e, r)).join("&");
|
|
75
|
+
}
|
|
76
|
+
toQueryString(t) {
|
|
77
|
+
const e = t || {};
|
|
78
|
+
return Object.keys(e).filter((r) => typeof e[r] < "u").map((r) => Array.isArray(e[r]) ? this.addArrayQueryParam(e, r) : this.addQueryParam(e, r)).join("&");
|
|
79
|
+
}
|
|
80
|
+
addQueryParams(t) {
|
|
81
|
+
const e = this.toQueryString(t);
|
|
82
|
+
return e ? `?${e}` : "";
|
|
83
|
+
}
|
|
84
|
+
contentFormatters = {
|
|
85
|
+
"application/json": (t) => t !== null && (typeof t == "object" || typeof t == "string") ? JSON.stringify(t) : t,
|
|
86
|
+
"application/vnd.api+json": (t) => t !== null && (typeof t == "object" || typeof t == "string") ? JSON.stringify(t) : t,
|
|
87
|
+
"text/plain": (t) => t !== null && typeof t != "string" ? JSON.stringify(t) : t,
|
|
88
|
+
"multipart/form-data": (t) => t instanceof FormData ? t : Object.keys(t || {}).reduce((e, r) => {
|
|
89
|
+
const s = t[r];
|
|
90
|
+
return e.append(r, s instanceof Blob ? s : typeof s == "object" && s !== null ? JSON.stringify(s) : `${s}`), e;
|
|
91
|
+
}, new FormData()),
|
|
92
|
+
"application/x-www-form-urlencoded": (t) => this.toQueryString(t)
|
|
93
|
+
};
|
|
94
|
+
mergeRequestParams(t, e) {
|
|
95
|
+
return {
|
|
96
|
+
...this.baseApiParams,
|
|
97
|
+
...t,
|
|
98
|
+
...e || {},
|
|
99
|
+
headers: {
|
|
100
|
+
...this.baseApiParams.headers || {},
|
|
101
|
+
...t.headers || {},
|
|
102
|
+
...e && e.headers || {}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
createAbortSignal = (t) => {
|
|
107
|
+
if (this.abortControllers.has(t)) {
|
|
108
|
+
const r = this.abortControllers.get(t);
|
|
109
|
+
return r ? r.signal : void 0;
|
|
110
|
+
}
|
|
111
|
+
const e = new AbortController();
|
|
112
|
+
return this.abortControllers.set(t, e), e.signal;
|
|
113
|
+
};
|
|
114
|
+
abortRequest = (t) => {
|
|
115
|
+
const e = this.abortControllers.get(t);
|
|
116
|
+
e && (e.abort(), this.abortControllers.delete(t));
|
|
117
|
+
};
|
|
118
|
+
request = async ({ body: t, secure: e, path: r, type: s, query: a, format: o, baseUrl: n, cancelToken: i, ...d }) => {
|
|
119
|
+
const h = (typeof e == "boolean" ? e : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {}, l = this.mergeRequestParams(d, h), c = a && this.toQueryString(a), y = this.contentFormatters[s || "application/json"], w = o || l.format;
|
|
120
|
+
return this.customFetch(`${n || this.baseUrl || ""}${r}${c ? `?${c}` : ""}`, {
|
|
121
|
+
...l,
|
|
122
|
+
headers: {
|
|
123
|
+
...l.headers || {},
|
|
124
|
+
...s && s !== "multipart/form-data" ? { "Content-Type": s } : {}
|
|
125
|
+
},
|
|
126
|
+
signal: (i ? this.createAbortSignal(i) : l.signal) || null,
|
|
127
|
+
body: typeof t > "u" || t === null ? null : y(t)
|
|
128
|
+
}).then(async (_) => {
|
|
129
|
+
const p = _;
|
|
130
|
+
p.data = null, p.error = null;
|
|
131
|
+
const N = w ? _.clone() : _, B = w ? await N[w]().then((I) => (p.ok ? p.data = I : p.error = I, p)).catch((I) => (p.error = I, p)) : p;
|
|
132
|
+
return i && this.abortControllers.delete(i), B;
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
}, A = class extends O {
|
|
136
|
+
admin = {
|
|
137
|
+
apiClientsList: (t = {}, e = {}) => this.request({
|
|
138
|
+
path: "/admin/api-clients",
|
|
139
|
+
method: "GET",
|
|
140
|
+
query: t,
|
|
141
|
+
secure: !0,
|
|
142
|
+
format: "json",
|
|
143
|
+
...e
|
|
144
|
+
}),
|
|
145
|
+
apiClientsCreate: (t, e = {}) => this.request({
|
|
146
|
+
path: "/admin/api-clients",
|
|
147
|
+
method: "POST",
|
|
148
|
+
body: t,
|
|
149
|
+
secure: !0,
|
|
150
|
+
type: "application/json",
|
|
151
|
+
format: "json",
|
|
152
|
+
...e
|
|
153
|
+
}),
|
|
154
|
+
apiClientsDetail: ({ clientId: t }, e = {}) => this.request({
|
|
155
|
+
path: `/admin/api-clients/${t}`,
|
|
156
|
+
method: "GET",
|
|
157
|
+
secure: !0,
|
|
158
|
+
format: "json",
|
|
159
|
+
...e
|
|
160
|
+
}),
|
|
161
|
+
apiClientsPartialUpdate: ({ clientId: t }, e, r = {}) => this.request({
|
|
162
|
+
path: `/admin/api-clients/${t}`,
|
|
163
|
+
method: "PATCH",
|
|
164
|
+
body: e,
|
|
165
|
+
secure: !0,
|
|
166
|
+
type: "application/json",
|
|
167
|
+
format: "json",
|
|
168
|
+
...r
|
|
169
|
+
}),
|
|
170
|
+
apiClientsRotateSecretCreate: ({ clientId: t }, e = {}) => this.request({
|
|
171
|
+
path: `/admin/api-clients/${t}/rotate-secret`,
|
|
172
|
+
method: "POST",
|
|
173
|
+
secure: !0,
|
|
174
|
+
format: "json",
|
|
175
|
+
...e
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
ai = {
|
|
179
|
+
converterJobsCreate: (t, e = {}) => this.request({
|
|
180
|
+
path: "/ai/converter/jobs",
|
|
181
|
+
method: "POST",
|
|
182
|
+
body: t,
|
|
183
|
+
secure: !0,
|
|
184
|
+
type: "application/json",
|
|
185
|
+
format: "json",
|
|
186
|
+
...e
|
|
187
|
+
}),
|
|
188
|
+
converterJobsDetail: ({ jobId: t }, e = {}) => this.request({
|
|
189
|
+
path: `/ai/converter/jobs/${t}`,
|
|
190
|
+
method: "GET",
|
|
191
|
+
secure: !0,
|
|
192
|
+
format: "json",
|
|
193
|
+
...e
|
|
194
|
+
})
|
|
195
|
+
};
|
|
196
|
+
auth = {
|
|
197
|
+
appTokenCreate: (t, e = {}) => this.request({
|
|
198
|
+
path: "/auth/app/token",
|
|
199
|
+
method: "POST",
|
|
200
|
+
body: t,
|
|
201
|
+
type: "application/json",
|
|
202
|
+
format: "json",
|
|
203
|
+
...e
|
|
204
|
+
}),
|
|
205
|
+
captchaConfigList: (t = {}) => this.request({
|
|
206
|
+
path: "/auth/captcha-config",
|
|
207
|
+
method: "GET",
|
|
208
|
+
format: "json",
|
|
209
|
+
...t
|
|
210
|
+
}),
|
|
211
|
+
elamaCreate: (t, e = {}) => this.request({
|
|
212
|
+
path: "/auth/elama",
|
|
213
|
+
method: "POST",
|
|
214
|
+
body: t,
|
|
215
|
+
type: "application/json",
|
|
216
|
+
format: "json",
|
|
217
|
+
...e
|
|
218
|
+
}),
|
|
219
|
+
googleCreate: (t, e = {}) => this.request({
|
|
220
|
+
path: "/auth/google",
|
|
221
|
+
method: "POST",
|
|
222
|
+
body: t,
|
|
223
|
+
type: "application/json",
|
|
224
|
+
format: "json",
|
|
225
|
+
...e
|
|
226
|
+
}),
|
|
227
|
+
passwordChangeCreate: (t, e = {}) => this.request({
|
|
228
|
+
path: "/auth/password/change",
|
|
229
|
+
method: "POST",
|
|
230
|
+
body: t,
|
|
231
|
+
secure: !0,
|
|
232
|
+
type: "application/json",
|
|
233
|
+
...e
|
|
234
|
+
}),
|
|
235
|
+
passwordResetCreate: (t, e = {}) => this.request({
|
|
236
|
+
path: "/auth/password/reset",
|
|
237
|
+
method: "POST",
|
|
238
|
+
body: t,
|
|
239
|
+
type: "application/json",
|
|
240
|
+
...e
|
|
241
|
+
}),
|
|
242
|
+
passwordResetConfirmCreate: (t, e = {}) => this.request({
|
|
243
|
+
path: "/auth/password/reset/confirm",
|
|
244
|
+
method: "POST",
|
|
245
|
+
body: t,
|
|
246
|
+
type: "application/json",
|
|
247
|
+
...e
|
|
248
|
+
}),
|
|
249
|
+
registerCreate: (t, e = {}) => this.request({
|
|
250
|
+
path: "/auth/register",
|
|
251
|
+
method: "POST",
|
|
252
|
+
body: t,
|
|
253
|
+
type: "application/json",
|
|
254
|
+
format: "json",
|
|
255
|
+
...e
|
|
256
|
+
}),
|
|
257
|
+
tokenDelete: (t = {}) => this.request({
|
|
258
|
+
path: "/auth/token",
|
|
259
|
+
method: "DELETE",
|
|
260
|
+
secure: !0,
|
|
261
|
+
...t
|
|
262
|
+
}),
|
|
263
|
+
tokenCreate: (t, e = {}) => this.request({
|
|
264
|
+
path: "/auth/token",
|
|
265
|
+
method: "POST",
|
|
266
|
+
body: t,
|
|
267
|
+
type: "application/json",
|
|
268
|
+
format: "json",
|
|
269
|
+
...e
|
|
270
|
+
}),
|
|
271
|
+
tokenRefreshCreate: (t, e = {}) => this.request({
|
|
272
|
+
path: "/auth/token/refresh",
|
|
273
|
+
method: "POST",
|
|
274
|
+
body: t,
|
|
275
|
+
type: "application/json",
|
|
276
|
+
format: "json",
|
|
277
|
+
...e
|
|
278
|
+
}),
|
|
279
|
+
userList: (t = {}) => this.request({
|
|
280
|
+
path: "/auth/user",
|
|
281
|
+
method: "GET",
|
|
282
|
+
secure: !0,
|
|
283
|
+
format: "json",
|
|
284
|
+
...t
|
|
285
|
+
}),
|
|
286
|
+
yandexCreate: (t, e = {}) => this.request({
|
|
287
|
+
path: "/auth/yandex",
|
|
288
|
+
method: "POST",
|
|
289
|
+
body: t,
|
|
290
|
+
type: "application/json",
|
|
291
|
+
format: "json",
|
|
292
|
+
...e
|
|
293
|
+
})
|
|
294
|
+
};
|
|
295
|
+
counters = { countersList: (t = {}) => this.request({
|
|
296
|
+
path: "/counters",
|
|
297
|
+
method: "GET",
|
|
298
|
+
secure: !0,
|
|
299
|
+
format: "json",
|
|
300
|
+
...t
|
|
301
|
+
}) };
|
|
302
|
+
files = {
|
|
303
|
+
filesList: (t, e = {}) => this.request({
|
|
304
|
+
path: "/files",
|
|
305
|
+
method: "GET",
|
|
306
|
+
query: t,
|
|
307
|
+
secure: !0,
|
|
308
|
+
format: "json",
|
|
309
|
+
...e
|
|
310
|
+
}),
|
|
311
|
+
filesCreate: (t = {}) => this.request({
|
|
312
|
+
path: "/files",
|
|
313
|
+
method: "POST",
|
|
314
|
+
secure: !0,
|
|
315
|
+
format: "json",
|
|
316
|
+
...t
|
|
317
|
+
}),
|
|
318
|
+
filesDelete: ({ id: t, ...e }, r = {}) => this.request({
|
|
319
|
+
path: `/files/${t}`,
|
|
320
|
+
method: "DELETE",
|
|
321
|
+
query: e,
|
|
322
|
+
secure: !0,
|
|
323
|
+
...r
|
|
324
|
+
}),
|
|
325
|
+
filesDetail: ({ id: t, ...e }, r = {}) => this.request({
|
|
326
|
+
path: `/files/${t}`,
|
|
327
|
+
method: "GET",
|
|
328
|
+
query: e,
|
|
329
|
+
secure: !0,
|
|
330
|
+
format: "json",
|
|
331
|
+
...r
|
|
332
|
+
}),
|
|
333
|
+
filesPartialUpdate: ({ id: t }, e, r = {}) => this.request({
|
|
334
|
+
path: `/files/${t}`,
|
|
335
|
+
method: "PATCH",
|
|
336
|
+
body: e,
|
|
337
|
+
secure: !0,
|
|
338
|
+
type: "application/json",
|
|
339
|
+
format: "json",
|
|
340
|
+
...r
|
|
341
|
+
}),
|
|
342
|
+
contentList: ({ id: t, ...e }, r = {}) => this.request({
|
|
343
|
+
path: `/files/${t}/content`,
|
|
344
|
+
method: "GET",
|
|
345
|
+
query: e,
|
|
346
|
+
secure: !0,
|
|
347
|
+
...r
|
|
348
|
+
}),
|
|
349
|
+
contentUpdate: ({ id: t }, e = {}) => this.request({
|
|
350
|
+
path: `/files/${t}/content`,
|
|
351
|
+
method: "PUT",
|
|
352
|
+
secure: !0,
|
|
353
|
+
format: "json",
|
|
354
|
+
...e
|
|
355
|
+
}),
|
|
356
|
+
backfillList: (t, e = {}) => this.request({
|
|
357
|
+
path: "/files/backfill",
|
|
358
|
+
method: "GET",
|
|
359
|
+
query: t,
|
|
360
|
+
secure: !0,
|
|
361
|
+
format: "json",
|
|
362
|
+
...e
|
|
363
|
+
}),
|
|
364
|
+
backfillCreate: (t, e = {}) => this.request({
|
|
365
|
+
path: "/files/backfill",
|
|
366
|
+
method: "POST",
|
|
367
|
+
body: t,
|
|
368
|
+
secure: !0,
|
|
369
|
+
type: "application/json",
|
|
370
|
+
format: "json",
|
|
371
|
+
...e
|
|
372
|
+
}),
|
|
373
|
+
backfillCancelCreate: (t, e = {}) => this.request({
|
|
374
|
+
path: "/files/backfill/cancel",
|
|
375
|
+
method: "POST",
|
|
376
|
+
body: t,
|
|
377
|
+
secure: !0,
|
|
378
|
+
type: "application/json",
|
|
379
|
+
format: "json",
|
|
380
|
+
...e
|
|
381
|
+
}),
|
|
382
|
+
uploadByUrlCreate: (t, e = {}) => this.request({
|
|
383
|
+
path: "/files/upload-by-url",
|
|
384
|
+
method: "POST",
|
|
385
|
+
body: t,
|
|
386
|
+
secure: !0,
|
|
387
|
+
type: "application/json",
|
|
388
|
+
format: "json",
|
|
389
|
+
...e
|
|
390
|
+
})
|
|
391
|
+
};
|
|
392
|
+
folders = {
|
|
393
|
+
foldersList: (t, e = {}) => this.request({
|
|
394
|
+
path: "/folders",
|
|
395
|
+
method: "GET",
|
|
396
|
+
query: t,
|
|
397
|
+
secure: !0,
|
|
398
|
+
format: "json",
|
|
399
|
+
...e
|
|
400
|
+
}),
|
|
401
|
+
foldersCreate: (t, e = {}) => this.request({
|
|
402
|
+
path: "/folders",
|
|
403
|
+
method: "POST",
|
|
404
|
+
body: t,
|
|
405
|
+
secure: !0,
|
|
406
|
+
type: "application/json",
|
|
407
|
+
format: "json",
|
|
408
|
+
...e
|
|
409
|
+
}),
|
|
410
|
+
foldersDelete: ({ id: t, ...e }, r = {}) => this.request({
|
|
411
|
+
path: `/folders/${t}`,
|
|
412
|
+
method: "DELETE",
|
|
413
|
+
query: e,
|
|
414
|
+
secure: !0,
|
|
415
|
+
...r
|
|
416
|
+
}),
|
|
417
|
+
foldersPartialUpdate: ({ id: t }, e, r = {}) => this.request({
|
|
418
|
+
path: `/folders/${t}`,
|
|
419
|
+
method: "PATCH",
|
|
420
|
+
body: e,
|
|
421
|
+
secure: !0,
|
|
422
|
+
type: "application/json",
|
|
423
|
+
format: "json",
|
|
424
|
+
...r
|
|
425
|
+
})
|
|
426
|
+
};
|
|
427
|
+
items = {
|
|
428
|
+
copyCreate: (t, e = {}) => this.request({
|
|
429
|
+
path: "/items/copy",
|
|
430
|
+
method: "POST",
|
|
431
|
+
body: t,
|
|
432
|
+
secure: !0,
|
|
433
|
+
type: "application/json",
|
|
434
|
+
format: "json",
|
|
435
|
+
...e
|
|
436
|
+
}),
|
|
437
|
+
moveCreate: (t, e = {}) => this.request({
|
|
438
|
+
path: "/items/move",
|
|
439
|
+
method: "POST",
|
|
440
|
+
body: t,
|
|
441
|
+
secure: !0,
|
|
442
|
+
type: "application/json",
|
|
443
|
+
format: "json",
|
|
444
|
+
...e
|
|
445
|
+
})
|
|
446
|
+
};
|
|
447
|
+
limits = {
|
|
448
|
+
statsList: (t = {}) => this.request({
|
|
449
|
+
path: "/limits/stats",
|
|
450
|
+
method: "GET",
|
|
451
|
+
secure: !0,
|
|
452
|
+
format: "json",
|
|
453
|
+
...t
|
|
454
|
+
}),
|
|
455
|
+
statsDetail: ({ type: t }, e = {}) => this.request({
|
|
456
|
+
path: `/limits/stats/${t}`,
|
|
457
|
+
method: "GET",
|
|
458
|
+
secure: !0,
|
|
459
|
+
format: "json",
|
|
460
|
+
...e
|
|
461
|
+
}),
|
|
462
|
+
warningsList: (t = {}) => this.request({
|
|
463
|
+
path: "/limits/warnings",
|
|
464
|
+
method: "GET",
|
|
465
|
+
secure: !0,
|
|
466
|
+
format: "json",
|
|
467
|
+
...t
|
|
468
|
+
})
|
|
469
|
+
};
|
|
470
|
+
translations = {
|
|
471
|
+
translationsDetail: ({ locale: t }, e = {}) => this.request({
|
|
472
|
+
path: `/translations/${t}`,
|
|
473
|
+
method: "GET",
|
|
474
|
+
secure: !0,
|
|
475
|
+
...e
|
|
476
|
+
}),
|
|
477
|
+
localesList: (t = {}) => this.request({
|
|
478
|
+
path: "/translations/locales",
|
|
479
|
+
method: "GET",
|
|
480
|
+
secure: !0,
|
|
481
|
+
format: "json",
|
|
482
|
+
...t
|
|
483
|
+
})
|
|
484
|
+
};
|
|
485
|
+
trash = {
|
|
486
|
+
emptyCreate: (t, e = {}) => this.request({
|
|
487
|
+
path: "/trash/empty",
|
|
488
|
+
method: "POST",
|
|
489
|
+
body: t,
|
|
490
|
+
secure: !0,
|
|
491
|
+
type: "application/json",
|
|
492
|
+
format: "json",
|
|
493
|
+
...e
|
|
494
|
+
}),
|
|
495
|
+
restoreCreate: (t, e = {}) => this.request({
|
|
496
|
+
path: "/trash/restore",
|
|
497
|
+
method: "POST",
|
|
498
|
+
body: t,
|
|
499
|
+
secure: !0,
|
|
500
|
+
type: "application/json",
|
|
501
|
+
format: "json",
|
|
502
|
+
...e
|
|
503
|
+
})
|
|
504
|
+
};
|
|
505
|
+
}, u = class q extends Error {
|
|
506
|
+
code;
|
|
507
|
+
status;
|
|
508
|
+
details;
|
|
509
|
+
get httpStatus() {
|
|
510
|
+
return this.status;
|
|
511
|
+
}
|
|
512
|
+
constructor(e, r, s, a) {
|
|
513
|
+
super(e), this.name = "FileManagerApiError", this.code = r, this.status = s, this.details = a, Error.captureStackTrace && Error.captureStackTrace(this, q);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
function P(t) {
|
|
517
|
+
return t.replace(/\/+$/, "");
|
|
518
|
+
}
|
|
519
|
+
function U(t, e) {
|
|
520
|
+
const r = P(g.buildCdnFileUrl(e ?? {}, [])), s = P(t);
|
|
521
|
+
if (!(!r || !s.startsWith(`${r}/`))) return s.slice(r.length + 1).split("/").filter(Boolean)[0];
|
|
522
|
+
}
|
|
523
|
+
function k(t, e = {}) {
|
|
524
|
+
const r = e.projectId?.trim();
|
|
525
|
+
if (!r) return !1;
|
|
526
|
+
const s = g.unwrapResourceProxyUrl(t, e.appConfig, e.isStandalone);
|
|
527
|
+
return g.isCdnUrl(s, e.appConfig) ? U(s, e.appConfig) === r : !1;
|
|
528
|
+
}
|
|
529
|
+
function x(t, e = {}) {
|
|
530
|
+
return g.unwrapResourceProxyUrl(t, e.appConfig, e.isStandalone);
|
|
531
|
+
}
|
|
532
|
+
var L = 2e3, R = 30;
|
|
533
|
+
function D(t) {
|
|
534
|
+
return typeof t?.watchThumbnail == "function";
|
|
535
|
+
}
|
|
536
|
+
var C = 200, S = {
|
|
537
|
+
validation_error: "ValidationError",
|
|
538
|
+
unauthorized: "AuthenticationFailed",
|
|
539
|
+
forbidden: "AuthorizationFailed",
|
|
540
|
+
not_found: "FileNotFound",
|
|
541
|
+
conflict: "FolderAlreadyExists",
|
|
542
|
+
payload_too_large: "PayloadTooLarge",
|
|
543
|
+
unsupported_media_type: "FileTypeNotAllowed",
|
|
544
|
+
too_many_requests: "RateLimitExceeded",
|
|
545
|
+
service_unavailable: "ServiceUnavailable",
|
|
546
|
+
internal_error: "BackendError"
|
|
547
|
+
}, M = {
|
|
548
|
+
file: {
|
|
549
|
+
not_found: "FileNotFound",
|
|
550
|
+
conflict: "FileAlreadyExists"
|
|
551
|
+
},
|
|
552
|
+
folder: {
|
|
553
|
+
not_found: "FolderNotFound",
|
|
554
|
+
conflict: "FolderAlreadyExists"
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
function E(t) {
|
|
558
|
+
switch (t) {
|
|
559
|
+
case 400: return "ValidationError";
|
|
560
|
+
case 401: return "AuthenticationFailed";
|
|
561
|
+
case 403: return "AuthorizationFailed";
|
|
562
|
+
case 404: return "FileNotFound";
|
|
563
|
+
case 409: return "FolderAlreadyExists";
|
|
564
|
+
case 413: return "PayloadTooLarge";
|
|
565
|
+
case 415: return "FileTypeNotAllowed";
|
|
566
|
+
case 429: return "RateLimitExceeded";
|
|
567
|
+
case 503: return "ServiceUnavailable";
|
|
568
|
+
case 504: return "Timeout";
|
|
569
|
+
default: return "BackendError";
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
var $ = class f {
|
|
573
|
+
pathMode = !1;
|
|
574
|
+
rootId = "";
|
|
575
|
+
trashPath = m.Ns;
|
|
576
|
+
useSoftDelete = !1;
|
|
577
|
+
api;
|
|
578
|
+
projectId;
|
|
579
|
+
i18n;
|
|
580
|
+
appConfig;
|
|
581
|
+
isStandalone;
|
|
582
|
+
onIndexingStateChange;
|
|
583
|
+
pendingThumbnails = new Map();
|
|
584
|
+
thumbWatchers = new Map();
|
|
585
|
+
resolveSystemFolderByPath;
|
|
586
|
+
constructor(e) {
|
|
587
|
+
this.api = e.restApi, this.projectId = e.projectId, this.i18n = e.i18n ?? v.defaultI18nContext, this.appConfig = e.appConfig, this.isStandalone = e.isStandalone, this.onIndexingStateChange = e.onIndexingStateChange, this.resolveSystemFolderByPath = m.Ls({ Trash: {
|
|
588
|
+
id: m.Ns,
|
|
589
|
+
folderId: this.rootId
|
|
590
|
+
} });
|
|
591
|
+
}
|
|
592
|
+
async getItems(e) {
|
|
593
|
+
const r = e.folderId === m.Ns;
|
|
594
|
+
if (e.itemType === "folder") return { items: await this.listFolders(e.folderId, r) };
|
|
595
|
+
const s = e.itemType === "all" && (e.page ?? 1) <= 1, [a, o] = await Promise.all([s ? this.listFolders(e.folderId, r, e.search) : [], this.listFiles(e, r)]);
|
|
596
|
+
return {
|
|
597
|
+
items: [...a, ...o.items],
|
|
598
|
+
pagination: o.pagination
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
async listFolders(e, r, s) {
|
|
602
|
+
const a = await this.api.folders.foldersList({
|
|
603
|
+
project_id: this.projectId,
|
|
604
|
+
parent_id: r ? void 0 : this.normalizeFolderId(e),
|
|
605
|
+
trashed: r || void 0
|
|
606
|
+
});
|
|
607
|
+
try {
|
|
608
|
+
this.assertOk(a, "folder");
|
|
609
|
+
} catch (n) {
|
|
610
|
+
if (f.isNotFound(n)) return [];
|
|
611
|
+
throw n;
|
|
612
|
+
}
|
|
613
|
+
let o = (a.data.items ?? []).map((n) => this.mapFolder(n, e));
|
|
614
|
+
if (s) {
|
|
615
|
+
const n = s.toLowerCase();
|
|
616
|
+
o = o.filter((i) => i.name.toLowerCase().includes(n));
|
|
617
|
+
}
|
|
618
|
+
return o;
|
|
619
|
+
}
|
|
620
|
+
async listFiles(e, r) {
|
|
621
|
+
const s = Math.min(e.limit ?? C, C), a = Math.max(e.page ?? 1, 1), o = await this.api.files.filesList({
|
|
622
|
+
project_id: this.projectId,
|
|
623
|
+
folder_id: r ? void 0 : this.normalizeFolderId(e.folderId),
|
|
624
|
+
search: e.search || void 0,
|
|
625
|
+
sort_by: e.sortBy,
|
|
626
|
+
sort_order: e.sortOrder,
|
|
627
|
+
limit: s,
|
|
628
|
+
offset: (a - 1) * s,
|
|
629
|
+
trashed: r || void 0
|
|
630
|
+
});
|
|
631
|
+
try {
|
|
632
|
+
this.assertOk(o, "folder");
|
|
633
|
+
} catch (i) {
|
|
634
|
+
if (f.isNotFound(i)) return {
|
|
635
|
+
items: [],
|
|
636
|
+
pagination: {
|
|
637
|
+
page: 1,
|
|
638
|
+
limit: s,
|
|
639
|
+
total: 0,
|
|
640
|
+
totalPages: 0,
|
|
641
|
+
hasNext: !1,
|
|
642
|
+
hasPrev: !1
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
throw i;
|
|
646
|
+
}
|
|
647
|
+
this.onIndexingStateChange?.(!!o.data.indexing);
|
|
648
|
+
const n = r ? m.Ns : this.normalizeFolderId(e.folderId) ?? this.rootId;
|
|
649
|
+
return {
|
|
650
|
+
items: (o.data.data ?? []).map((i) => this.mapFile(i, n)),
|
|
651
|
+
pagination: this.mapPagination(o.data.page, s)
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
async createFolder(e, r) {
|
|
655
|
+
const s = await this.api.folders.foldersCreate({
|
|
656
|
+
project_id: this.projectId,
|
|
657
|
+
name: e,
|
|
658
|
+
parent_id: this.normalizeFolderId(r)
|
|
659
|
+
});
|
|
660
|
+
return this.assertOk(s), this.mapFolder(s.data.folder ?? {}, r);
|
|
661
|
+
}
|
|
662
|
+
async uploadFileByUrl(e, r) {
|
|
663
|
+
const s = await this.api.files.uploadByUrlCreate({
|
|
664
|
+
project_id: this.projectId,
|
|
665
|
+
url: e,
|
|
666
|
+
folder_id: this.normalizeFolderId(r)
|
|
667
|
+
});
|
|
668
|
+
return this.assertOk(s), this.mapFile(s.data.file ?? {}, this.normalizeFolderId(r) ?? this.rootId);
|
|
669
|
+
}
|
|
670
|
+
async uploadFiles(e) {
|
|
671
|
+
if (e.items.length === 0) return {
|
|
672
|
+
success: !0,
|
|
673
|
+
detailed: []
|
|
674
|
+
};
|
|
675
|
+
const r = new Map();
|
|
676
|
+
e.items.forEach((o, n) => {
|
|
677
|
+
const i = this.normalizeFolderId(o.folderId ?? e.folderId ?? void 0) ?? this.rootId, d = o.requestId ?? `item-${n}`, h = r.get(i) ?? [];
|
|
678
|
+
h.push({
|
|
679
|
+
item: o,
|
|
680
|
+
requestId: d
|
|
681
|
+
}), r.set(i, h);
|
|
682
|
+
});
|
|
683
|
+
const s = [];
|
|
684
|
+
for (const [o, n] of r) {
|
|
685
|
+
const i = new FormData();
|
|
686
|
+
i.append("project_id", this.projectId), o !== this.rootId && i.append("folder_id", o);
|
|
687
|
+
for (const { item: l, requestId: c } of n) i.append("request_id", c), i.append("file", l.data, l.name);
|
|
688
|
+
let d;
|
|
689
|
+
try {
|
|
690
|
+
d = await this.api.request({
|
|
691
|
+
path: "/files",
|
|
692
|
+
method: "POST",
|
|
693
|
+
body: i,
|
|
694
|
+
type: T.FormData,
|
|
695
|
+
format: "json",
|
|
696
|
+
secure: !0
|
|
697
|
+
}), this.assertOk(d, "file");
|
|
698
|
+
} catch (l) {
|
|
699
|
+
for (const { requestId: c } of n) s.push({
|
|
700
|
+
requestId: c,
|
|
701
|
+
success: !1,
|
|
702
|
+
error: f.toErrorInfo(l)
|
|
703
|
+
});
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
const h = new Map((d.data.items ?? []).map((l) => [l.request_id, l]));
|
|
707
|
+
n.forEach(({ requestId: l }, c) => {
|
|
708
|
+
const y = h.get(l) ?? d.data.items?.[c];
|
|
709
|
+
y?.file ? s.push({
|
|
710
|
+
requestId: l,
|
|
711
|
+
success: !0,
|
|
712
|
+
data: this.mapFile(y.file, o)
|
|
713
|
+
}) : s.push({
|
|
714
|
+
requestId: l,
|
|
715
|
+
success: !1,
|
|
716
|
+
error: this.mapItemFail(y?.error)
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
const a = s.filter((o) => !o.success);
|
|
721
|
+
return {
|
|
722
|
+
success: a.length === 0,
|
|
723
|
+
error: a[0]?.error,
|
|
724
|
+
detailed: s
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
async uploadFile(e) {
|
|
728
|
+
const r = (await this.uploadFiles({ items: [{
|
|
729
|
+
name: e.name,
|
|
730
|
+
size: e.size,
|
|
731
|
+
type: e.type,
|
|
732
|
+
folderId: e.folderId,
|
|
733
|
+
data: e.data
|
|
734
|
+
}] })).detailed?.[0];
|
|
735
|
+
if (!r?.success || !r.data) {
|
|
736
|
+
const s = r?.error;
|
|
737
|
+
throw s instanceof u ? s : new u(String(s?.message ?? this.i18n.__("Unknown error")), s?.code || "FileWriteError", typeof s?.status == "number" ? s.status : void 0);
|
|
738
|
+
}
|
|
739
|
+
return r.data;
|
|
740
|
+
}
|
|
741
|
+
async updateFile(e, r) {
|
|
742
|
+
let s = { id: e.id };
|
|
743
|
+
if (r.data !== void 0) {
|
|
744
|
+
const a = typeof r.data == "string" ? f.base64ToBlob(r.data, e.type) : r.data, o = new FormData();
|
|
745
|
+
o.append("project_id", this.projectId), o.append("file", a, e.name);
|
|
746
|
+
const n = await this.api.request({
|
|
747
|
+
path: `/files/${e.id}/content`,
|
|
748
|
+
method: "PUT",
|
|
749
|
+
body: o,
|
|
750
|
+
type: T.FormData,
|
|
751
|
+
format: "json",
|
|
752
|
+
secure: !0
|
|
753
|
+
});
|
|
754
|
+
this.assertOk(n, "file");
|
|
755
|
+
const i = n.data.file ?? {};
|
|
756
|
+
s = {
|
|
757
|
+
...s,
|
|
758
|
+
size: i.size,
|
|
759
|
+
type: i.mime,
|
|
760
|
+
url: i.url,
|
|
761
|
+
thumbnail: i.thumbnail_url,
|
|
762
|
+
thumbnailUrl: i.thumbnail_url,
|
|
763
|
+
lastEdited: i.updated_at
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
if (r.name && r.name !== e.name) {
|
|
767
|
+
const a = await this.renameItem(e, r.name);
|
|
768
|
+
s = {
|
|
769
|
+
...s,
|
|
770
|
+
...a
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
return s;
|
|
774
|
+
}
|
|
775
|
+
getFileData = async (e, r) => {
|
|
776
|
+
const { __: s } = this.i18n;
|
|
777
|
+
if (!e.url) throw new u(s("Failed to get file: %s").replace("%s", e.name), "FileReadError");
|
|
778
|
+
const a = await g.fetchWithResourceProxy(e.url, {
|
|
779
|
+
config: this.appConfig,
|
|
780
|
+
standalone: this.isStandalone,
|
|
781
|
+
resourceType: g.isCdnUrl(e.url, this.appConfig) ? "cdn" : "generic",
|
|
782
|
+
intent: "downloadBlob",
|
|
783
|
+
init: r?.forceReload ? { cache: "no-store" } : void 0
|
|
784
|
+
});
|
|
785
|
+
if (a.ok) return a.blob();
|
|
786
|
+
throw new u(await a.text() || s("Failed to get file: %s").replace("%s", a.statusText), E(a.status), a.status);
|
|
787
|
+
};
|
|
788
|
+
static base64ToBlob(e, r) {
|
|
789
|
+
const s = e.includes(",") ? e.slice(e.indexOf(",") + 1) : e, a = atob(s), o = new Uint8Array(a.length);
|
|
790
|
+
for (let n = 0; n < a.length; n += 1) o[n] = a.charCodeAt(n);
|
|
791
|
+
return new Blob([o], r ? { type: r } : void 0);
|
|
792
|
+
}
|
|
793
|
+
mapItemFail(e) {
|
|
794
|
+
const { __: r } = this.i18n;
|
|
795
|
+
return {
|
|
796
|
+
message: e?.message || r("Unknown error"),
|
|
797
|
+
code: (e?.code ? S[e.code] : void 0) ?? "FileWriteError"
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
async renameItem(e, r) {
|
|
801
|
+
if (e.isFolder) {
|
|
802
|
+
const o = await this.api.folders.foldersPartialUpdate({ id: e.id }, {
|
|
803
|
+
project_id: this.projectId,
|
|
804
|
+
name: r
|
|
805
|
+
});
|
|
806
|
+
this.assertOk(o, "folder");
|
|
807
|
+
const n = o.data.folder ?? {};
|
|
808
|
+
return {
|
|
809
|
+
id: e.id,
|
|
810
|
+
name: n.name ?? r,
|
|
811
|
+
folderId: n.parent_id ?? e.folderId,
|
|
812
|
+
isFolder: !0,
|
|
813
|
+
lastEdited: n.updated_at
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
const s = await this.api.files.filesPartialUpdate({ id: e.id }, {
|
|
817
|
+
project_id: this.projectId,
|
|
818
|
+
name: r,
|
|
819
|
+
mode: "replace"
|
|
820
|
+
});
|
|
821
|
+
this.assertOk(s, "file");
|
|
822
|
+
const a = s.data.file ?? {};
|
|
823
|
+
return {
|
|
824
|
+
id: e.id,
|
|
825
|
+
name: a.name ?? r,
|
|
826
|
+
folderId: a.folder_id ?? e.folderId,
|
|
827
|
+
isFolder: !1,
|
|
828
|
+
url: a.url,
|
|
829
|
+
thumbnail: a.thumbnail_url,
|
|
830
|
+
thumbnailUrl: a.thumbnail_url,
|
|
831
|
+
extension: a.ext,
|
|
832
|
+
type: a.mime,
|
|
833
|
+
lastEdited: a.updated_at
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
async deleteItem(e, r) {
|
|
837
|
+
try {
|
|
838
|
+
if (e.isFolder) {
|
|
839
|
+
const s = await this.api.folders.foldersDelete({
|
|
840
|
+
id: e.id,
|
|
841
|
+
project_id: this.projectId,
|
|
842
|
+
permanent: r.permanent || void 0
|
|
843
|
+
});
|
|
844
|
+
this.assertOk(s, "folder");
|
|
845
|
+
} else {
|
|
846
|
+
const s = await this.api.files.filesDelete({
|
|
847
|
+
id: e.id,
|
|
848
|
+
project_id: this.projectId,
|
|
849
|
+
permanent: r.permanent || void 0
|
|
850
|
+
});
|
|
851
|
+
this.assertOk(s, "file");
|
|
852
|
+
}
|
|
853
|
+
} catch (s) {
|
|
854
|
+
if (!f.isNotFound(s)) throw s;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async deleteItems(e, r) {
|
|
858
|
+
if (e.length === 0) return { success: !0 };
|
|
859
|
+
const s = new Set(e.filter((i) => i.isFolder).map((i) => i.id)), a = new Set(e.filter((i) => s.has(i.folderId))), o = [];
|
|
860
|
+
for (const i of e) {
|
|
861
|
+
if (a.has(i)) {
|
|
862
|
+
o.push({
|
|
863
|
+
requestId: i.id,
|
|
864
|
+
success: !0
|
|
865
|
+
});
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
try {
|
|
869
|
+
await this.deleteItem(i, r), o.push({
|
|
870
|
+
requestId: i.id,
|
|
871
|
+
success: !0
|
|
872
|
+
});
|
|
873
|
+
} catch (d) {
|
|
874
|
+
o.push({
|
|
875
|
+
requestId: i.id,
|
|
876
|
+
success: !1,
|
|
877
|
+
error: f.toErrorInfo(d)
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
const n = o.filter((i) => !i.success);
|
|
882
|
+
return {
|
|
883
|
+
success: n.length === 0,
|
|
884
|
+
error: n[0]?.error,
|
|
885
|
+
detailed: o
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
async moveItems(e, r) {
|
|
889
|
+
if (e.length === 0) return {
|
|
890
|
+
success: !0,
|
|
891
|
+
detailed: []
|
|
892
|
+
};
|
|
893
|
+
const s = e.filter((i) => i.folderId === m.Ns), a = e.filter((i) => i.folderId !== m.Ns), o = [];
|
|
894
|
+
if (s.length > 0) {
|
|
895
|
+
const i = await this.api.trash.restoreCreate({
|
|
896
|
+
project_id: this.projectId,
|
|
897
|
+
ids: s.map((d) => d.id),
|
|
898
|
+
target_folder_id: this.normalizeFolderId(r),
|
|
899
|
+
on_conflict: "keep_both"
|
|
900
|
+
});
|
|
901
|
+
this.assertOk(i), o.push(...this.mapTransferResults(i.data.items, s));
|
|
902
|
+
}
|
|
903
|
+
if (a.length > 0) {
|
|
904
|
+
const i = await this.api.items.moveCreate({
|
|
905
|
+
project_id: this.projectId,
|
|
906
|
+
ids: a.map((d) => d.id),
|
|
907
|
+
target_folder_id: this.normalizeFolderId(r)
|
|
908
|
+
});
|
|
909
|
+
this.assertOk(i), o.push(...this.mapTransferResults(i.data.items, a));
|
|
910
|
+
}
|
|
911
|
+
const n = o.filter((i) => !i.success);
|
|
912
|
+
return {
|
|
913
|
+
success: n.length === 0,
|
|
914
|
+
error: n[0]?.error,
|
|
915
|
+
detailed: o
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
async moveItem(e, r) {
|
|
919
|
+
return this.unwrapSingleTransfer(await this.moveItems([e], r), e);
|
|
920
|
+
}
|
|
921
|
+
async copyItems(e, r) {
|
|
922
|
+
if (e.length === 0) return {
|
|
923
|
+
success: !0,
|
|
924
|
+
detailed: []
|
|
925
|
+
};
|
|
926
|
+
const s = await this.api.items.copyCreate({
|
|
927
|
+
project_id: this.projectId,
|
|
928
|
+
ids: e.map((n) => n.id),
|
|
929
|
+
target_folder_id: this.normalizeFolderId(r)
|
|
930
|
+
});
|
|
931
|
+
this.assertOk(s);
|
|
932
|
+
const a = this.mapTransferResults(s.data.items, e), o = a.filter((n) => !n.success);
|
|
933
|
+
return {
|
|
934
|
+
success: o.length === 0,
|
|
935
|
+
error: o[0]?.error,
|
|
936
|
+
detailed: a
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
async copyItem(e, r) {
|
|
940
|
+
return this.unwrapSingleTransfer(await this.copyItems([e], r), e);
|
|
941
|
+
}
|
|
942
|
+
async cleanTrash() {
|
|
943
|
+
const e = await this.api.trash.emptyCreate({ project_id: this.projectId });
|
|
944
|
+
return this.assertOk(e), {
|
|
945
|
+
success: !0,
|
|
946
|
+
deletedCount: (e.data.deleted_files ?? 0) + (e.data.deleted_folders ?? 0)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
async clearCache(e) {}
|
|
950
|
+
findItemByPath(e) {
|
|
951
|
+
return this.resolveSystemFolderByPath(e);
|
|
952
|
+
}
|
|
953
|
+
async findFileByUrl(e, r) {
|
|
954
|
+
const s = {
|
|
955
|
+
appConfig: this.appConfig,
|
|
956
|
+
isStandalone: this.isStandalone,
|
|
957
|
+
projectId: this.projectId
|
|
958
|
+
};
|
|
959
|
+
if (!k(e, s)) return;
|
|
960
|
+
const a = x(e, s), o = f.fileNameFromUrl(a);
|
|
961
|
+
if (!o) return;
|
|
962
|
+
const { items: n } = await this.listFiles({
|
|
963
|
+
folderId: r,
|
|
964
|
+
search: o
|
|
965
|
+
}, !1);
|
|
966
|
+
return n.find((i) => i.url === e || i.url === a);
|
|
967
|
+
}
|
|
968
|
+
static fileNameFromUrl(e) {
|
|
969
|
+
try {
|
|
970
|
+
const r = new URL(e).pathname.split("/").filter(Boolean).pop();
|
|
971
|
+
return r ? decodeURIComponent(r) : void 0;
|
|
972
|
+
} catch {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
mapTransferResults(e, r) {
|
|
977
|
+
const s = new Map(r.map((a) => [a.id, a]));
|
|
978
|
+
return (e ?? []).map((a, o) => {
|
|
979
|
+
const n = a.id ?? r[o]?.id, i = n ? s.get(n) : r[o];
|
|
980
|
+
return a.error ? {
|
|
981
|
+
requestId: n,
|
|
982
|
+
success: !1,
|
|
983
|
+
error: this.mapItemFail(a.error)
|
|
984
|
+
} : {
|
|
985
|
+
requestId: n,
|
|
986
|
+
success: !0,
|
|
987
|
+
data: a.file ? this.mapFile(a.file, a.file.folder_id ?? this.rootId) : a.folder ? this.mapFolder(a.folder) : i ? { id: i.id } : { id: n ?? "" }
|
|
988
|
+
};
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
unwrapSingleTransfer(e, r) {
|
|
992
|
+
const s = e.detailed?.[0];
|
|
993
|
+
if (!s?.success) {
|
|
994
|
+
const a = s?.error ?? e.error;
|
|
995
|
+
throw a instanceof u ? a : new u(String(a?.message ?? this.i18n.__("Unknown error")), a?.code || "BackendError", typeof a?.status == "number" ? a.status : void 0);
|
|
996
|
+
}
|
|
997
|
+
return s.data ?? { id: r.id };
|
|
998
|
+
}
|
|
999
|
+
mapFile(e, r) {
|
|
1000
|
+
return this.trackThumbnailReadiness(e), {
|
|
1001
|
+
id: e.id ?? "",
|
|
1002
|
+
name: e.name ?? "",
|
|
1003
|
+
folderId: e.folder_id ?? r,
|
|
1004
|
+
isFolder: !1,
|
|
1005
|
+
size: e.size,
|
|
1006
|
+
date: e.created_at,
|
|
1007
|
+
lastEdited: e.updated_at,
|
|
1008
|
+
type: e.mime,
|
|
1009
|
+
extension: e.ext,
|
|
1010
|
+
url: e.url,
|
|
1011
|
+
thumbnail: e.thumbnail_url,
|
|
1012
|
+
thumbnailUrl: e.thumbnail_url,
|
|
1013
|
+
dimensions: e.width && e.height ? `${e.width}x${e.height}` : void 0,
|
|
1014
|
+
aspectRatio: e.width && e.height ? String(e.width / e.height) : void 0,
|
|
1015
|
+
selected: !1
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
trackThumbnailReadiness(e) {
|
|
1019
|
+
!e.id || !e.url || !e.mime?.startsWith("image/") || (e.thumbnail_url ? this.pendingThumbnails.delete(e.url) : this.pendingThumbnails.set(e.url, e.id));
|
|
1020
|
+
}
|
|
1021
|
+
watchThumbnail(e, r) {
|
|
1022
|
+
const s = this.pendingThumbnails.get(e);
|
|
1023
|
+
if (!s) return () => {};
|
|
1024
|
+
const a = this.thumbWatchers.get(s);
|
|
1025
|
+
if (a) return a.listeners.add(r), () => a.listeners.delete(r);
|
|
1026
|
+
const o = {
|
|
1027
|
+
listeners: new Set([r]),
|
|
1028
|
+
cancelled: !1
|
|
1029
|
+
};
|
|
1030
|
+
return this.thumbWatchers.set(s, o), this.pollThumbnail(s, e, o), () => {
|
|
1031
|
+
o.listeners.delete(r), o.listeners.size === 0 && (o.cancelled = !0, this.thumbWatchers.delete(s));
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
async pollThumbnail(e, r, s) {
|
|
1035
|
+
for (let a = 0; a < R; a += 1) {
|
|
1036
|
+
if (await new Promise((n) => setTimeout(n, L)), s.cancelled) return;
|
|
1037
|
+
let o;
|
|
1038
|
+
try {
|
|
1039
|
+
const n = await this.api.files.filesDetail({
|
|
1040
|
+
id: e,
|
|
1041
|
+
project_id: this.projectId
|
|
1042
|
+
});
|
|
1043
|
+
n.ok && !n.error && (o = n.data.file?.thumbnail_url);
|
|
1044
|
+
} catch {}
|
|
1045
|
+
if (s.cancelled) return;
|
|
1046
|
+
if (o) {
|
|
1047
|
+
this.pendingThumbnails.delete(r), this.thumbWatchers.delete(e), s.listeners.forEach((n) => n(o));
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
this.thumbWatchers.delete(e);
|
|
1052
|
+
}
|
|
1053
|
+
mapFolder(e, r) {
|
|
1054
|
+
return {
|
|
1055
|
+
id: e.id ?? "",
|
|
1056
|
+
name: e.name ?? "",
|
|
1057
|
+
folderId: e.parent_id ?? this.normalizeFolderId(r) ?? this.rootId,
|
|
1058
|
+
isFolder: !0,
|
|
1059
|
+
date: e.created_at,
|
|
1060
|
+
lastEdited: e.updated_at,
|
|
1061
|
+
selected: !1
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
mapPagination(e, r) {
|
|
1065
|
+
const s = e?.limit ?? r, a = e?.offset ?? 0, o = e?.total ?? 0, n = s > 0 ? Math.floor(a / s) + 1 : 1, i = s > 0 ? Math.ceil(o / s) : 0;
|
|
1066
|
+
return {
|
|
1067
|
+
page: n,
|
|
1068
|
+
limit: s,
|
|
1069
|
+
total: o,
|
|
1070
|
+
totalPages: i,
|
|
1071
|
+
hasNext: n < i,
|
|
1072
|
+
hasPrev: n > 1
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
normalizeFolderId(e) {
|
|
1076
|
+
if (!(!e || e === this.rootId)) return e;
|
|
1077
|
+
}
|
|
1078
|
+
assertOk(e, r) {
|
|
1079
|
+
if (e.ok && !e.error) return;
|
|
1080
|
+
const { __: s } = this.i18n, a = e.error?.error, o = (a?.code && r ? M[r][a.code] : void 0) ?? (a?.code ? S[a.code] : void 0) ?? E(e.status);
|
|
1081
|
+
throw new u(a?.message || s("Unknown error"), o, e.status);
|
|
1082
|
+
}
|
|
1083
|
+
static isNotFound(e) {
|
|
1084
|
+
return e instanceof u && (e.code === "FileNotFound" || e.code === "FolderNotFound");
|
|
1085
|
+
}
|
|
1086
|
+
static toErrorInfo(e) {
|
|
1087
|
+
return e instanceof u || e instanceof Error ? e : {
|
|
1088
|
+
message: String(e),
|
|
1089
|
+
raw: e
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
Object.defineProperty(b, "FileManagerApiError", {
|
|
1094
|
+
enumerable: !0,
|
|
1095
|
+
get: function() {
|
|
1096
|
+
return u;
|
|
1097
|
+
}
|
|
1098
|
+
}), Object.defineProperty(b, "FileManagerRestApiProviderV2", {
|
|
1099
|
+
enumerable: !0,
|
|
1100
|
+
get: function() {
|
|
1101
|
+
return $;
|
|
1102
|
+
}
|
|
1103
|
+
}), Object.defineProperty(b, "RestApiV2", {
|
|
1104
|
+
enumerable: !0,
|
|
1105
|
+
get: function() {
|
|
1106
|
+
return A;
|
|
1107
|
+
}
|
|
1108
|
+
}), Object.defineProperty(b, "arrays", {
|
|
1109
|
+
enumerable: !0,
|
|
1110
|
+
get: function() {
|
|
1111
|
+
return F;
|
|
1112
|
+
}
|
|
1113
|
+
}), Object.defineProperty(b, "hasThumbnailWatcher", {
|
|
1114
|
+
enumerable: !0,
|
|
1115
|
+
get: function() {
|
|
1116
|
+
return D;
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
});
|