@recats/cdeebee 3.0.0-beta.9 → 3.0.0
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/README.md +293 -25
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +194 -8
- package/dist/index.js +347 -237
- package/dist/index.js.map +1 -1
- package/package.json +17 -10
package/dist/index.js
CHANGED
|
@@ -1,238 +1,348 @@
|
|
|
1
|
-
import { createAsyncThunk as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
continue;
|
|
170
|
-
const l = i in e ? e[i] : {};
|
|
171
|
-
if (E(c)) {
|
|
172
|
-
const d = U(c.data, c.primaryKey);
|
|
173
|
-
a[i] = K(l, d, u, i);
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
f(c) ? a[i] = K(l, c, u, i) : a[i] = c;
|
|
177
|
-
}
|
|
178
|
-
return s.size > 0 ? x(Array.from(s), a) : a;
|
|
179
|
-
}
|
|
180
|
-
const W = {
|
|
181
|
-
settings: {
|
|
182
|
-
modules: ["history", "listener", "storage", "cancelation"],
|
|
183
|
-
fileKey: "file",
|
|
184
|
-
bodyKey: "value",
|
|
185
|
-
listStrategy: {},
|
|
186
|
-
mergeWithData: {},
|
|
187
|
-
mergeWithHeaders: {}
|
|
188
|
-
},
|
|
189
|
-
storage: {},
|
|
190
|
-
request: {
|
|
191
|
-
active: [],
|
|
192
|
-
errors: {},
|
|
193
|
-
done: {}
|
|
194
|
-
}
|
|
195
|
-
}, H = (t, r) => L({
|
|
196
|
-
name: "cdeebee",
|
|
197
|
-
initialState: h(W, { settings: t, storage: r ?? {} }),
|
|
198
|
-
reducers: {
|
|
199
|
-
set(o, e) {
|
|
200
|
-
N(o.storage, e.payload);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
extraReducers: (o) => {
|
|
204
|
-
o.addCase(A.pending, (e, a) => {
|
|
205
|
-
const s = a.meta.arg.api, i = a.meta.requestId;
|
|
206
|
-
y(e.settings, "cancelation", () => {
|
|
207
|
-
I(s, i);
|
|
208
|
-
}), y(e.settings, "listener", () => {
|
|
209
|
-
e.request.active.push({ api: s, requestId: i });
|
|
210
|
-
});
|
|
211
|
-
}).addCase(A.fulfilled, (e, a) => {
|
|
212
|
-
const s = a.meta.requestId, i = a.meta.arg.api;
|
|
213
|
-
y(e.settings, "listener", () => {
|
|
214
|
-
e.request.active = e.request.active.filter((c) => !(c.api === i && c.requestId === s));
|
|
215
|
-
}), y(e.settings, "history", () => {
|
|
216
|
-
e.request.done[i] || (e.request.done[i] = []), e.request.done[i].push({ api: i, request: a.payload, requestId: s });
|
|
217
|
-
}), y(e.settings, "storage", () => {
|
|
218
|
-
if (a.meta.arg.ignore)
|
|
219
|
-
return;
|
|
220
|
-
const c = a.meta.arg.listStrategy ?? e.settings.listStrategy ?? {}, u = a.meta.arg.normalize ?? e.settings.normalize ?? M, l = v(e), d = u(l, a.payload.result, c);
|
|
221
|
-
e.storage = d;
|
|
222
|
-
});
|
|
223
|
-
}).addCase(A.rejected, (e, a) => {
|
|
224
|
-
const s = a.meta.requestId, i = a.meta.arg.api;
|
|
225
|
-
y(e.settings, "listener", () => {
|
|
226
|
-
e.request.active = e.request.active.filter((c) => !(c.api === i && c.requestId === s));
|
|
227
|
-
}), y(e.settings, "history", () => {
|
|
228
|
-
e.request.errors[i] || (e.request.errors[i] = []), e.request.errors[i].push({ requestId: s, api: i, request: a.error });
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
1
|
+
import { createAsyncThunk as e, createSlice as t, current as n } from "@reduxjs/toolkit";
|
|
2
|
+
import { useSelector as r } from "react-redux";
|
|
3
|
+
//#region lib/reducer/helpers.ts
|
|
4
|
+
function i(e, t, n) {
|
|
5
|
+
e.modules.includes(t) && n();
|
|
6
|
+
}
|
|
7
|
+
function a(e) {
|
|
8
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
9
|
+
}
|
|
10
|
+
function o(e, t) {
|
|
11
|
+
if (!a(e) || !a(t)) return t;
|
|
12
|
+
let n = { ...e }, r = t;
|
|
13
|
+
for (let e in r) if (Object.prototype.hasOwnProperty.call(r, e)) {
|
|
14
|
+
let t = n[e], i = r[e];
|
|
15
|
+
a(t) && a(i) && !Array.isArray(t) && !Array.isArray(i) ? n[e] = o(t, i) : n[e] = i;
|
|
16
|
+
}
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
function s(e, t) {
|
|
20
|
+
let n = { ...t };
|
|
21
|
+
for (let t of e) delete n[t];
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
function c(e) {
|
|
25
|
+
if (!a(e)) return {};
|
|
26
|
+
let t = {};
|
|
27
|
+
for (let n of Object.keys(e)) {
|
|
28
|
+
let r = e[n];
|
|
29
|
+
if (a(r) && Array.isArray(r.data) && typeof r.primaryKey == "string") {
|
|
30
|
+
let e = r.primaryKey, i = [];
|
|
31
|
+
for (let t of r.data) a(t) && e in t && i.push(String(t[e]));
|
|
32
|
+
t[n] = i;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
function l(e, t) {
|
|
38
|
+
for (let n = 0; n < t.length; n++) {
|
|
39
|
+
let r = t[n], i = r.key, o = r.value;
|
|
40
|
+
if (i.length === 0) continue;
|
|
41
|
+
let s = e;
|
|
42
|
+
for (let e = 0; e < i.length - 1; e++) {
|
|
43
|
+
let t = i[e];
|
|
44
|
+
if (Array.isArray(s)) {
|
|
45
|
+
let e = typeof t == "number" ? t : Number(t);
|
|
46
|
+
(!(e in s) || !a(s[e])) && (s[e] = {}), s = s[e];
|
|
47
|
+
} else {
|
|
48
|
+
let n = String(t);
|
|
49
|
+
if (!(n in s)) {
|
|
50
|
+
let t = typeof i[e + 1] == "number" || !isNaN(Number(i[e + 1])) && String(Number(i[e + 1])) === String(i[e + 1]);
|
|
51
|
+
s[n] = t ? [] : {};
|
|
52
|
+
}
|
|
53
|
+
let r = s[n];
|
|
54
|
+
s = Array.isArray(r) || a(r) ? r : {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let c = i[i.length - 1];
|
|
58
|
+
if (Array.isArray(s)) {
|
|
59
|
+
let e = typeof c == "number" ? c : Number(c);
|
|
60
|
+
s[e] = o;
|
|
61
|
+
} else s[String(c)] = o;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var u = new class {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.byRequestId = /* @__PURE__ */ new Map(), this.byApi = /* @__PURE__ */ new Map();
|
|
67
|
+
}
|
|
68
|
+
add(e, t, n) {
|
|
69
|
+
let r = {
|
|
70
|
+
requestId: t,
|
|
71
|
+
controller: n,
|
|
72
|
+
api: e
|
|
73
|
+
};
|
|
74
|
+
this.byRequestId.set(t, r), this.byApi.has(e) || this.byApi.set(e, /* @__PURE__ */ new Set()), this.byApi.get(e).add(t);
|
|
75
|
+
}
|
|
76
|
+
delete(e) {
|
|
77
|
+
let t = this.byRequestId.get(e);
|
|
78
|
+
if (!t) return;
|
|
79
|
+
this.byRequestId.delete(e);
|
|
80
|
+
let n = this.byApi.get(t.api);
|
|
81
|
+
n && (n.delete(e), n.size === 0 && this.byApi.delete(t.api));
|
|
82
|
+
}
|
|
83
|
+
abortAllForApi(e, t) {
|
|
84
|
+
let n = this.byApi.get(e);
|
|
85
|
+
if (!n) return;
|
|
86
|
+
let r = Array.from(n).filter((e) => e !== t);
|
|
87
|
+
for (let e of r) {
|
|
88
|
+
let t = this.byRequestId.get(e);
|
|
89
|
+
t && (t.controller.abort(), this.delete(e));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}();
|
|
93
|
+
function d(e, t) {
|
|
94
|
+
u.abortAllForApi(e, t);
|
|
95
|
+
}
|
|
96
|
+
function f(e, t, n) {
|
|
97
|
+
let r = new AbortController(), i = () => {
|
|
98
|
+
u.delete(n);
|
|
99
|
+
};
|
|
100
|
+
return e.addEventListener("abort", () => {
|
|
101
|
+
r.abort(), i();
|
|
102
|
+
}), {
|
|
103
|
+
controller: r,
|
|
104
|
+
init: () => u.add(t, n, r),
|
|
105
|
+
drop: i
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
var p = new class {
|
|
109
|
+
constructor() {
|
|
110
|
+
this.currentPromise = Promise.resolve(), this.queueLength = 0;
|
|
111
|
+
}
|
|
112
|
+
async enqueue(e) {
|
|
113
|
+
return this.queueLength++, this.currentPromise = this.currentPromise.then(() => e(), () => e()).finally(() => {
|
|
114
|
+
this.queueLength--;
|
|
115
|
+
}), this.currentPromise;
|
|
116
|
+
}
|
|
117
|
+
getQueueLength() {
|
|
118
|
+
return this.queueLength;
|
|
119
|
+
}
|
|
120
|
+
clear() {
|
|
121
|
+
this.queueLength = 0, this.currentPromise = Promise.resolve();
|
|
122
|
+
}
|
|
123
|
+
}(), m = e("cdeebee/request", async (e, { rejectWithValue: t, getState: n, requestId: r, signal: a }) => {
|
|
124
|
+
let o = (/* @__PURE__ */ new Date()).toUTCString(), { cdeebee: { settings: s } } = n(), c = f(a, e.api, r), l = e.onResult && typeof e.onResult == "function";
|
|
125
|
+
i(s, "cancelation", c.init);
|
|
126
|
+
let u = async () => {
|
|
127
|
+
try {
|
|
128
|
+
let { method: n = "POST", body: a, headers: u = {} } = e, d = {
|
|
129
|
+
...typeof s.mergeWithHeaders == "function" ? s.mergeWithHeaders() : s.mergeWithHeaders ?? {},
|
|
130
|
+
...u
|
|
131
|
+
}, f = {
|
|
132
|
+
...typeof s.mergeWithData == "function" ? s.mergeWithData() : s.mergeWithData ?? {},
|
|
133
|
+
...a ?? {}
|
|
134
|
+
}, p = JSON.stringify(f), m = !!e.files;
|
|
135
|
+
if (e.files) {
|
|
136
|
+
let t = new FormData(), n = e.fileKey || s.fileKey, r = e.bodyKey || s.bodyKey;
|
|
137
|
+
for (let r = 0; r < e.files.length; r += 1) n && t.append(n, e.files[r]);
|
|
138
|
+
r && t.append(r, p), p = t;
|
|
139
|
+
}
|
|
140
|
+
let h = {
|
|
141
|
+
"ui-request-id": r,
|
|
142
|
+
...m ? {} : { "Content-Type": "application/json" },
|
|
143
|
+
...d
|
|
144
|
+
}, g = n === "GET", _ = await fetch(e.api, {
|
|
145
|
+
method: n,
|
|
146
|
+
headers: h,
|
|
147
|
+
signal: c.controller.signal,
|
|
148
|
+
...g ? {} : { body: p }
|
|
149
|
+
});
|
|
150
|
+
i(s, "cancelation", c.drop);
|
|
151
|
+
let v, y = e.responseType || "json";
|
|
152
|
+
return v = y === "text" ? await _.text() : y === "blob" ? await _.blob() : await _.json(), _.ok ? (l && e.onResult(v), {
|
|
153
|
+
result: v,
|
|
154
|
+
startedAt: o,
|
|
155
|
+
endedAt: (/* @__PURE__ */ new Date()).toUTCString()
|
|
156
|
+
}) : (l && e.onResult(v), t({
|
|
157
|
+
status: _.status,
|
|
158
|
+
statusText: _.statusText,
|
|
159
|
+
data: v
|
|
160
|
+
}));
|
|
161
|
+
} catch (n) {
|
|
162
|
+
return i(s, "cancelation", c.drop), l && e.onResult(n), n instanceof Error && n.name === "AbortError" ? t({
|
|
163
|
+
message: "Request was cancelled",
|
|
164
|
+
cancelled: !0
|
|
165
|
+
}) : t({ message: n instanceof Error ? n.message : "Unknown error occurred" });
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return s.modules.includes("queryQueue") ? p.enqueue(u) : u();
|
|
232
169
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region lib/reducer/storage.ts
|
|
172
|
+
function h(e) {
|
|
173
|
+
return a(e) && Array.isArray(e.data) && typeof e.primaryKey == "string";
|
|
174
|
+
}
|
|
175
|
+
function g(e, t) {
|
|
176
|
+
let n = {};
|
|
177
|
+
for (let r of e) if (a(r) && t in r) {
|
|
178
|
+
let e = String(r[t]);
|
|
179
|
+
n[e] = r;
|
|
180
|
+
}
|
|
181
|
+
return n;
|
|
182
|
+
}
|
|
183
|
+
function _(e, t, n, r) {
|
|
184
|
+
return n === "replace" ? t : n === "merge" ? o(e, t) : n === "skip" ? e : (console.warn(`Cdeebee: Unknown strategy "${n}" for key "${r}". Skipping normalization.`), o(e, t));
|
|
185
|
+
}
|
|
186
|
+
function v(e, t, n) {
|
|
187
|
+
let r = Object.keys(t), i = a(e.storage) ? e.storage : {}, o = { ...i }, c = /* @__PURE__ */ new Set();
|
|
188
|
+
for (let e of r) {
|
|
189
|
+
let r = t[e];
|
|
190
|
+
if (r == null || typeof r == "string") {
|
|
191
|
+
c.add(e);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
let s = n[e] ?? "merge";
|
|
195
|
+
if (s === "skip" && !(e in i)) continue;
|
|
196
|
+
let l = e in i ? i[e] : {};
|
|
197
|
+
if (h(r)) {
|
|
198
|
+
o[e] = _(l, g(r.data, r.primaryKey), s, e);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
a(r) ? o[e] = _(l, r, s, e) : o[e] = r;
|
|
202
|
+
}
|
|
203
|
+
return c.size > 0 ? s(Array.from(c), o) : o;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region lib/reducer/index.ts
|
|
207
|
+
var y = {
|
|
208
|
+
settings: {
|
|
209
|
+
modules: [
|
|
210
|
+
"history",
|
|
211
|
+
"listener",
|
|
212
|
+
"storage",
|
|
213
|
+
"cancelation"
|
|
214
|
+
],
|
|
215
|
+
fileKey: "file",
|
|
216
|
+
bodyKey: "value",
|
|
217
|
+
listStrategy: {},
|
|
218
|
+
mergeWithData: {},
|
|
219
|
+
mergeWithHeaders: {}
|
|
220
|
+
},
|
|
221
|
+
storage: {},
|
|
222
|
+
request: {
|
|
223
|
+
active: [],
|
|
224
|
+
errors: {},
|
|
225
|
+
done: {},
|
|
226
|
+
lastResultIdList: {}
|
|
227
|
+
}
|
|
228
|
+
}, b = (e, r) => t({
|
|
229
|
+
name: "cdeebee",
|
|
230
|
+
initialState: o(y, {
|
|
231
|
+
settings: e,
|
|
232
|
+
storage: r ?? {}
|
|
233
|
+
}),
|
|
234
|
+
reducers: {
|
|
235
|
+
set(e, t) {
|
|
236
|
+
l(e.storage, t.payload);
|
|
237
|
+
},
|
|
238
|
+
historyClear(e, t) {
|
|
239
|
+
let n = t.payload;
|
|
240
|
+
n ? (delete e.request.done[n], delete e.request.errors[n]) : (e.request.done = {}, e.request.errors = {});
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
extraReducers: (e) => {
|
|
244
|
+
e.addCase(m.pending, (e, t) => {
|
|
245
|
+
let n = t.meta.arg.api, r = t.meta.requestId;
|
|
246
|
+
t.meta.arg.historyClear && i(e.settings, "history", () => {
|
|
247
|
+
delete e.request.done[n], delete e.request.errors[n];
|
|
248
|
+
}), i(e.settings, "cancelation", () => {
|
|
249
|
+
d(n, r);
|
|
250
|
+
}), i(e.settings, "listener", () => {
|
|
251
|
+
e.request.active.push({
|
|
252
|
+
api: n,
|
|
253
|
+
requestId: r
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}).addCase(m.fulfilled, (e, t) => {
|
|
257
|
+
let r = t.meta.requestId, a = t.meta.arg.api;
|
|
258
|
+
i(e.settings, "listener", () => {
|
|
259
|
+
e.request.active = e.request.active.filter((e) => !(e.api === a && e.requestId === r));
|
|
260
|
+
}), i(e.settings, "history", () => {
|
|
261
|
+
e.request.done[a] || (e.request.done[a] = []), e.request.done[a].push({
|
|
262
|
+
api: a,
|
|
263
|
+
request: t.payload,
|
|
264
|
+
requestId: r
|
|
265
|
+
});
|
|
266
|
+
let n = e.settings.maxHistorySize;
|
|
267
|
+
n && e.request.done[a].length > n && (e.request.done[a] = e.request.done[a].slice(-n));
|
|
268
|
+
}), i(e.settings, "storage", () => {
|
|
269
|
+
if (t.meta.arg.ignore) return;
|
|
270
|
+
let r = t.meta.arg.listStrategy ?? e.settings.listStrategy ?? {};
|
|
271
|
+
e.storage = (t.meta.arg.normalize ?? e.settings.normalize ?? v)(n(e), t.payload.result, r), e.request.lastResultIdList[a] = c(t.payload.result);
|
|
272
|
+
});
|
|
273
|
+
}).addCase(m.rejected, (e, t) => {
|
|
274
|
+
let n = t.meta.requestId, r = t.meta.arg.api;
|
|
275
|
+
i(e.settings, "listener", () => {
|
|
276
|
+
e.request.active = e.request.active.filter((e) => !(e.api === r && e.requestId === n));
|
|
277
|
+
}), i(e.settings, "history", () => {
|
|
278
|
+
e.request.errors[r] || (e.request.errors[r] = []), e.request.errors[r].push({
|
|
279
|
+
requestId: n,
|
|
280
|
+
api: r,
|
|
281
|
+
request: t.error
|
|
282
|
+
});
|
|
283
|
+
let i = e.settings.maxHistorySize;
|
|
284
|
+
i && e.request.errors[r].length > i && (e.request.errors[r] = e.request.errors[r].slice(-i));
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}), x = [], S = x, C = x;
|
|
289
|
+
function w(e) {
|
|
290
|
+
function t(t) {
|
|
291
|
+
return r((n) => e(n).request.active.some((e) => t.includes(e.api)));
|
|
292
|
+
}
|
|
293
|
+
function n(t) {
|
|
294
|
+
return r((n) => e(n).request.done[t] ?? S);
|
|
295
|
+
}
|
|
296
|
+
function i(t) {
|
|
297
|
+
return r((n) => e(n).request.errors[t] ?? S);
|
|
298
|
+
}
|
|
299
|
+
function a(t) {
|
|
300
|
+
return r((n) => e(n).storage[t]);
|
|
301
|
+
}
|
|
302
|
+
function o() {
|
|
303
|
+
return r((t) => e(t).storage);
|
|
304
|
+
}
|
|
305
|
+
function s() {
|
|
306
|
+
return r((t) => e(t).request.active.length > 0);
|
|
307
|
+
}
|
|
308
|
+
function c(t, n) {
|
|
309
|
+
return r((r) => e(r).request.lastResultIdList[t]?.[n] ?? C);
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
useLoading: t,
|
|
313
|
+
useRequestHistory: n,
|
|
314
|
+
useRequestErrors: i,
|
|
315
|
+
useStorageList: a,
|
|
316
|
+
useStorage: o,
|
|
317
|
+
useIsLoading: s,
|
|
318
|
+
useLastResultIdList: c
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region lib/hooks/selectors.ts
|
|
323
|
+
var T = [], E = T, D = T;
|
|
324
|
+
function O(e) {
|
|
325
|
+
return r((t) => t.cdeebee.request.active.some((t) => e.includes(t.api)));
|
|
326
|
+
}
|
|
327
|
+
function k(e) {
|
|
328
|
+
return r((t) => t.cdeebee.request.done[e] ?? E);
|
|
329
|
+
}
|
|
330
|
+
function A(e) {
|
|
331
|
+
return r((t) => t.cdeebee.request.errors[e] ?? E);
|
|
332
|
+
}
|
|
333
|
+
function j(e) {
|
|
334
|
+
return r((t) => t.cdeebee.storage[e]);
|
|
335
|
+
}
|
|
336
|
+
function M() {
|
|
337
|
+
return r((e) => e.cdeebee.storage);
|
|
338
|
+
}
|
|
339
|
+
function N() {
|
|
340
|
+
return r((e) => e.cdeebee.request.active.length > 0);
|
|
341
|
+
}
|
|
342
|
+
function P(e, t) {
|
|
343
|
+
return r((n) => n.cdeebee.request.lastResultIdList[e]?.[t] ?? D);
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { l as batchingUpdate, w as createCdeebeeHooks, v as defaultNormalize, b as factory, m as request, N as useIsLoading, P as useLastResultIdList, O as useLoading, A as useRequestErrors, k as useRequestHistory, M as useStorage, j as useStorageList };
|
|
347
|
+
|
|
348
|
+
//# sourceMappingURL=index.js.map
|