@scaleflex/dam-core 0.3.1 → 0.3.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -29
- package/dist/index.js.map +1 -1
- package/dist/store/browse-store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,10 +11,10 @@ async function W(s, e, t, i = {}) {
|
|
|
11
11
|
let a = new Error("SASS key exchange failed");
|
|
12
12
|
for (let c = 0; c <= o; c++) {
|
|
13
13
|
c > 0 && await G(l * c);
|
|
14
|
-
const
|
|
14
|
+
const f = new AbortController(), h = setTimeout(() => f.abort(), 3e4);
|
|
15
15
|
try {
|
|
16
|
-
const d = await fetch(r, { signal:
|
|
17
|
-
if (clearTimeout(
|
|
16
|
+
const d = await fetch(r, { signal: f.signal, cache: "no-store" });
|
|
17
|
+
if (clearTimeout(h), !d.ok) {
|
|
18
18
|
if (a = new Error(`SASS key exchange failed (HTTP ${d.status})`), B(d.status) && c < o) continue;
|
|
19
19
|
throw a;
|
|
20
20
|
}
|
|
@@ -23,7 +23,7 @@ async function W(s, e, t, i = {}) {
|
|
|
23
23
|
throw new Error(`SASS key exchange failed: ${u.msg || "Unknown error"}`);
|
|
24
24
|
return u.key;
|
|
25
25
|
} catch (d) {
|
|
26
|
-
if (clearTimeout(
|
|
26
|
+
if (clearTimeout(h), d instanceof DOMException && d.name === "AbortError")
|
|
27
27
|
throw new Error("SASS key exchange timed out");
|
|
28
28
|
if (d instanceof TypeError && c < o) {
|
|
29
29
|
a = d;
|
|
@@ -128,25 +128,25 @@ class O {
|
|
|
128
128
|
signal: r.signal
|
|
129
129
|
});
|
|
130
130
|
if (clearTimeout(o), a.status === 401 && !i && ((l = this.auth) == null ? void 0 : l.mode) === "security-template") {
|
|
131
|
-
const
|
|
132
|
-
return this.headers =
|
|
131
|
+
const h = await I(this.auth, this.apiDomain);
|
|
132
|
+
return this.headers = h.headers, this.send(e, t, !0);
|
|
133
133
|
}
|
|
134
134
|
if (!a.ok) {
|
|
135
|
-
let
|
|
135
|
+
let h = `API error: ${a.status} ${a.statusText}`;
|
|
136
136
|
try {
|
|
137
137
|
const d = await a.json();
|
|
138
|
-
d != null && d.msg && (
|
|
138
|
+
d != null && d.msg && (h = `API error: ${a.status} - ${d.msg}`);
|
|
139
139
|
} catch {
|
|
140
140
|
}
|
|
141
|
-
throw new Error(
|
|
141
|
+
throw new Error(h);
|
|
142
142
|
}
|
|
143
143
|
if (a.status === 204) return;
|
|
144
144
|
const c = await a.text();
|
|
145
145
|
if (!c) return;
|
|
146
|
-
const
|
|
147
|
-
if ((
|
|
148
|
-
throw new Error(`API error: ${
|
|
149
|
-
return
|
|
146
|
+
const f = JSON.parse(c);
|
|
147
|
+
if ((f == null ? void 0 : f.status) === "error")
|
|
148
|
+
throw new Error(`API error: ${f.msg || "Unknown error"}`);
|
|
149
|
+
return f;
|
|
150
150
|
} catch (a) {
|
|
151
151
|
throw clearTimeout(o), a instanceof DOMException && a.name === "AbortError" ? new Error("API request timed out") : a;
|
|
152
152
|
}
|
|
@@ -320,12 +320,12 @@ async function oe(s, e, t = {}) {
|
|
|
320
320
|
for (; o < e.length; ) {
|
|
321
321
|
const c = o++;
|
|
322
322
|
try {
|
|
323
|
-
const
|
|
323
|
+
const f = await s.get(`/file/${encodeURIComponent(e[c])}`, {
|
|
324
324
|
format: "json,regvar:api,select:internal",
|
|
325
325
|
preview: 2301,
|
|
326
326
|
fields: i.length ? i : void 0
|
|
327
327
|
});
|
|
328
|
-
|
|
328
|
+
f != null && f.file && (r[c] = z(f.file));
|
|
329
329
|
} catch {
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -466,17 +466,17 @@ function be(s) {
|
|
|
466
466
|
throw new Error(`Archive job failed: ${(s == null ? void 0 : s.task_status) ?? "unknown status"}`);
|
|
467
467
|
}
|
|
468
468
|
async function _e(s, e, t = {}) {
|
|
469
|
-
var
|
|
469
|
+
var h, d;
|
|
470
470
|
const i = t.intervalMs ?? 1500, r = t.timeoutMs ?? 12e4, o = t.maxRetries ?? 5, l = t.sleep ?? ((u) => new Promise((g) => setTimeout(g, u))), a = t.now ?? Date.now, c = a() + r;
|
|
471
|
-
let
|
|
471
|
+
let f = 0;
|
|
472
472
|
for (; ; ) {
|
|
473
|
-
if ((
|
|
473
|
+
if ((h = t.signal) != null && h.aborted) throw new Error("Archive polling aborted");
|
|
474
474
|
if (a() > c) throw new Error("Archive polling timed out");
|
|
475
475
|
let u;
|
|
476
476
|
try {
|
|
477
477
|
u = await ye(s, e);
|
|
478
478
|
} catch (S) {
|
|
479
|
-
if (
|
|
479
|
+
if (f++ < o) {
|
|
480
480
|
await l(i);
|
|
481
481
|
continue;
|
|
482
482
|
}
|
|
@@ -810,30 +810,31 @@ class E {
|
|
|
810
810
|
async fetchAssetsPage(e) {
|
|
811
811
|
const { scope: t, sortBy: i, sortDirection: r } = this.state, o = this.state.searchQuery || void 0, l = this.facetParams();
|
|
812
812
|
if (t.type === "favourites") {
|
|
813
|
-
const
|
|
813
|
+
const h = [...this.state.favourites], d = await oe(this.client, h.slice(0, U)), u = Date.now(), g = d.filter((S) => re(S, l, u)), p = ne(g, i, r);
|
|
814
814
|
return {
|
|
815
815
|
assets: p,
|
|
816
816
|
total: p.length,
|
|
817
|
-
truncated:
|
|
817
|
+
truncated: h.length > U,
|
|
818
818
|
hasMore: !1,
|
|
819
819
|
fetched: 0
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
822
|
const a = { sortBy: i, sortDirection: r, search: o, ...l, offset: e, limit: C };
|
|
823
823
|
let c;
|
|
824
|
-
if (t.type === "folder")
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
824
|
+
if (t.type === "folder") {
|
|
825
|
+
const h = this.state.searchQuery.trim() ? 1 : 0;
|
|
826
|
+
c = await w(this.client, { ...a, folder: t.value ?? "/", recursive: h });
|
|
827
|
+
} else if (t.type === "label") {
|
|
828
|
+
const h = this.state.labels.find((u) => u.uuid === t.value), d = h ? he(h) : void 0;
|
|
828
829
|
c = await w(this.client, { ...a, recursive: 1, q: d });
|
|
829
830
|
} else
|
|
830
831
|
c = await w(this.client, { ...a, recursive: 1 });
|
|
831
|
-
const
|
|
832
|
+
const f = c.assets.length === C;
|
|
832
833
|
return {
|
|
833
834
|
assets: c.assets,
|
|
834
835
|
total: c.total,
|
|
835
836
|
truncated: !1,
|
|
836
|
-
hasMore:
|
|
837
|
+
hasMore: f,
|
|
837
838
|
fetched: c.assets.length
|
|
838
839
|
};
|
|
839
840
|
}
|
|
@@ -1109,8 +1110,8 @@ function We(s) {
|
|
|
1109
1110
|
for (; t >= 1024 && i < e.length - 1; )
|
|
1110
1111
|
t /= 1024, i++;
|
|
1111
1112
|
const r = (a, c) => {
|
|
1112
|
-
const
|
|
1113
|
-
return { str:
|
|
1113
|
+
const f = c > 0 && Math.round(a * 10) / 10 < 10 ? 1 : 0, h = a.toFixed(f);
|
|
1114
|
+
return { str: h, rounded: Number(h) };
|
|
1114
1115
|
}, o = r(t, i);
|
|
1115
1116
|
let l = o.str;
|
|
1116
1117
|
return o.rounded >= 1024 && i < e.length - 1 && (t /= 1024, i++, l = r(t, i).str), `${l} ${e[i]}`;
|