@recats/cdeebee 2.3.7 → 3.0.0-beta.3
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/LICENSE +1 -1
- package/README.md +309 -150
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +93 -6
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -24
- package/dist/actions.d.ts +0 -24
- package/dist/cdeebee.js +0 -1160
- package/dist/cdeebee.umd.cjs +0 -3
- package/dist/definition.d.ts +0 -210
- package/dist/helpers.d.ts +0 -22
- package/dist/reducer.d.ts +0 -8
- package/dist/request.d.ts +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { AsyncThunk } from '@reduxjs/toolkit';
|
|
2
|
+
import { AsyncThunkConfig } from '@reduxjs/toolkit';
|
|
3
|
+
import { Slice } from '@reduxjs/toolkit';
|
|
4
|
+
import { SliceSelectors } from '@reduxjs/toolkit';
|
|
5
|
+
import { WritableDraft } from '@reduxjs/toolkit';
|
|
6
|
+
|
|
7
|
+
declare type Append<P extends readonly (string | number)[], K extends string | number> = [...P, K];
|
|
8
|
+
|
|
9
|
+
declare type ArrayElement<T> = T extends readonly (infer U)[] ? U : T extends (infer U)[] ? U : never;
|
|
10
|
+
|
|
11
|
+
export declare function batchingUpdate<T extends Record<string, unknown>>(state: T, valueList: CdeebeeValueList<T>): void;
|
|
12
|
+
|
|
13
|
+
declare interface CdeebeeActiveRequest {
|
|
14
|
+
api: string;
|
|
15
|
+
requestId: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare interface CdeebeeHistoryState {
|
|
19
|
+
requestId: string;
|
|
20
|
+
api: string;
|
|
21
|
+
request: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare type CdeebeeListStrategy<T> = Record<keyof T, CdeebeeStrategy>;
|
|
25
|
+
|
|
26
|
+
declare type CdeebeeModule = 'history' | 'listener' | 'storage' | 'cancelation';
|
|
27
|
+
|
|
28
|
+
export declare interface CdeebeeRequestOptions<T> extends Partial<Pick<CdeebeeSettings<T>, 'fileKey' | 'bodyKey' | 'normalize' | 'listStrategy'>> {
|
|
29
|
+
api: string;
|
|
30
|
+
files?: File[];
|
|
31
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
32
|
+
body?: unknown;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
onResult?: (response: T) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare interface CdeebeeRequestState {
|
|
38
|
+
active: CdeebeeActiveRequest[];
|
|
39
|
+
errors: Record<string, CdeebeeHistoryState[]>;
|
|
40
|
+
done: Record<string, CdeebeeHistoryState[]>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare interface CdeebeeSettings<T> {
|
|
44
|
+
modules: CdeebeeModule[];
|
|
45
|
+
fileKey: string;
|
|
46
|
+
bodyKey: string;
|
|
47
|
+
primaryKey: string;
|
|
48
|
+
mergeWithData: unknown;
|
|
49
|
+
mergeWithHeaders: unknown;
|
|
50
|
+
listStrategy?: CdeebeeListStrategy<T>;
|
|
51
|
+
normalize?: <T>(storage: CdeebeeState<T>, result: T, strategyList: CdeebeeListStrategy<T>) => T;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare interface CdeebeeState<T> {
|
|
55
|
+
settings: CdeebeeSettings<T>;
|
|
56
|
+
storage: T;
|
|
57
|
+
request: CdeebeeRequestState;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare type CdeebeeStrategy = 'merge' | 'replace';
|
|
61
|
+
|
|
62
|
+
declare type CdeebeeValueItem<T> = NonEmptyPaths<T> extends infer P ? P extends readonly (string | number)[] ? {
|
|
63
|
+
key: P;
|
|
64
|
+
value: ValueAtPath<T, P>;
|
|
65
|
+
} : never : never;
|
|
66
|
+
|
|
67
|
+
export declare type CdeebeeValueList<T> = ReadonlyArray<CdeebeeValueItem<T>>;
|
|
68
|
+
|
|
69
|
+
export declare const factory: <T>(settings: CdeebeeSettings<T>, storage?: T) => Slice<CdeebeeState<T>, {
|
|
70
|
+
set(state: WritableDraft<CdeebeeState<T>>, action: {
|
|
71
|
+
payload: CdeebeeValueList<T>;
|
|
72
|
+
}): void;
|
|
73
|
+
}, "cdeebee", "cdeebee", SliceSelectors<CdeebeeState<T>>>;
|
|
74
|
+
|
|
75
|
+
declare type IsArray<T> = T extends readonly unknown[] ? true : T extends unknown[] ? true : false;
|
|
76
|
+
|
|
77
|
+
declare type KeyOf<T> = Extract<keyof T, string | number>;
|
|
78
|
+
|
|
79
|
+
declare type NonEmptyPaths<T> = Exclude<Paths<T>, []>;
|
|
80
|
+
|
|
81
|
+
declare type Paths<T, P extends readonly (string | number)[] = []> = IsArray<T> extends true ? P | Paths<ArrayElement<T>, Append<P, number>> : T extends object ? {
|
|
82
|
+
[K in KeyOf<T>]: Paths<T[K], Append<P, K>>;
|
|
83
|
+
}[KeyOf<T>] : P;
|
|
84
|
+
|
|
85
|
+
export declare const request: AsyncThunk< {
|
|
86
|
+
result: any;
|
|
87
|
+
startedAt: string;
|
|
88
|
+
endedAt: string;
|
|
89
|
+
}, CdeebeeRequestOptions<unknown>, AsyncThunkConfig>;
|
|
90
|
+
|
|
91
|
+
declare type ValueAtPath<T, P extends readonly (string | number)[]> = P extends [] ? T : P extends readonly [infer K, ...infer R] ? K extends keyof T ? ValueAtPath<T[K], Extract<R, readonly (string | number)[]>> : T extends readonly (infer U)[] | (infer U)[] ? K extends number | `${number}` ? ValueAtPath<U, Extract<R, readonly (string | number)[]>> : never : never : never;
|
|
92
|
+
|
|
93
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { createAsyncThunk as R, createSlice as D, current as C } from "@reduxjs/toolkit";
|
|
2
|
+
function d(r, n, i) {
|
|
3
|
+
r.modules.includes(n) && i();
|
|
4
|
+
}
|
|
5
|
+
function f(r) {
|
|
6
|
+
return r !== null && typeof r == "object" && !Array.isArray(r);
|
|
7
|
+
}
|
|
8
|
+
function z(r) {
|
|
9
|
+
return f(r) && Array.isArray(r.data);
|
|
10
|
+
}
|
|
11
|
+
function I(r, n) {
|
|
12
|
+
return f(r) && Object.prototype.hasOwnProperty.call(r, n);
|
|
13
|
+
}
|
|
14
|
+
function q(r, n) {
|
|
15
|
+
if (!f(r) || !f(n))
|
|
16
|
+
return n;
|
|
17
|
+
const i = { ...r }, a = n;
|
|
18
|
+
for (const e in a)
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(a, e)) {
|
|
20
|
+
const c = i[e], t = a[e];
|
|
21
|
+
f(c) && f(t) && !Array.isArray(c) && !Array.isArray(t) ? i[e] = q(c, t) : i[e] = t;
|
|
22
|
+
}
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
25
|
+
function N(r, n) {
|
|
26
|
+
const i = { ...n };
|
|
27
|
+
for (const a of r)
|
|
28
|
+
delete i[a];
|
|
29
|
+
return i;
|
|
30
|
+
}
|
|
31
|
+
function O(r, n) {
|
|
32
|
+
for (let i = 0; i < n.length; i++) {
|
|
33
|
+
const a = n[i], e = a.key, c = a.value;
|
|
34
|
+
if (e.length === 0)
|
|
35
|
+
continue;
|
|
36
|
+
let t = r;
|
|
37
|
+
for (let o = 0; o < e.length - 1; o++) {
|
|
38
|
+
const s = e[o];
|
|
39
|
+
if (Array.isArray(t)) {
|
|
40
|
+
const l = typeof s == "number" ? s : Number(s);
|
|
41
|
+
(!(l in t) || !f(t[l])) && (t[l] = {}), t = t[l];
|
|
42
|
+
} else {
|
|
43
|
+
const l = String(s);
|
|
44
|
+
if (!(l in t)) {
|
|
45
|
+
const u = typeof e[o + 1] == "number" || !isNaN(Number(e[o + 1])) && String(Number(e[o + 1])) === String(e[o + 1]);
|
|
46
|
+
t[l] = u ? [] : {};
|
|
47
|
+
}
|
|
48
|
+
const y = t[l];
|
|
49
|
+
t = Array.isArray(y) || f(y) ? y : {};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
Array.isArray(t) || (t[String(e[e.length - 1])] = c);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class x {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.byRequestId = /* @__PURE__ */ new Map(), this.byApi = /* @__PURE__ */ new Map();
|
|
58
|
+
}
|
|
59
|
+
add(n, i, a) {
|
|
60
|
+
const e = { requestId: i, controller: a, api: n };
|
|
61
|
+
this.byRequestId.set(i, e), this.byApi.has(n) || this.byApi.set(n, /* @__PURE__ */ new Set()), this.byApi.get(n).add(i);
|
|
62
|
+
}
|
|
63
|
+
delete(n) {
|
|
64
|
+
const i = this.byRequestId.get(n);
|
|
65
|
+
if (!i) return;
|
|
66
|
+
this.byRequestId.delete(n);
|
|
67
|
+
const a = this.byApi.get(i.api);
|
|
68
|
+
a && (a.delete(n), a.size === 0 && this.byApi.delete(i.api));
|
|
69
|
+
}
|
|
70
|
+
abortAllForApi(n, i) {
|
|
71
|
+
const a = this.byApi.get(n);
|
|
72
|
+
a && a.forEach((e) => {
|
|
73
|
+
if (e !== i) {
|
|
74
|
+
const c = this.byRequestId.get(e);
|
|
75
|
+
c && (c.controller.abort(), this.delete(e));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const K = new x();
|
|
81
|
+
function P(r, n) {
|
|
82
|
+
K.abortAllForApi(r, n);
|
|
83
|
+
}
|
|
84
|
+
function j(r, n, i) {
|
|
85
|
+
const a = new AbortController(), e = () => {
|
|
86
|
+
K.delete(i);
|
|
87
|
+
};
|
|
88
|
+
return r.addEventListener("abort", () => {
|
|
89
|
+
a.abort(), e();
|
|
90
|
+
}), {
|
|
91
|
+
controller: a,
|
|
92
|
+
init: () => K.add(n, i, a),
|
|
93
|
+
drop: e
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const k = R(
|
|
97
|
+
"cdeebee/request",
|
|
98
|
+
async (r, { rejectWithValue: n, getState: i, requestId: a, signal: e }) => {
|
|
99
|
+
const c = (/* @__PURE__ */ new Date()).toUTCString(), { cdeebee: { settings: t } } = i(), o = j(e, r.api, a);
|
|
100
|
+
d(t, "cancelation", o.init);
|
|
101
|
+
try {
|
|
102
|
+
const { method: s = "POST", body: l, headers: y = {} } = r, u = { ...t.mergeWithHeaders ?? {}, ...y }, A = { ...t.mergeWithData ?? {}, ...l ?? {} };
|
|
103
|
+
let h = JSON.stringify(A);
|
|
104
|
+
if (r.files) {
|
|
105
|
+
const p = new FormData(), m = r.fileKey || t.fileKey, S = r.bodyKey || t.bodyKey;
|
|
106
|
+
for (let w = 0; w < r.files.length; w += 1)
|
|
107
|
+
m && p.append(m, r.files[w]);
|
|
108
|
+
S && p.append(S, h), h = p;
|
|
109
|
+
}
|
|
110
|
+
const g = await fetch(r.api, {
|
|
111
|
+
method: s,
|
|
112
|
+
headers: {
|
|
113
|
+
"ui-request-id": a,
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
...u
|
|
116
|
+
},
|
|
117
|
+
signal: o.controller.signal,
|
|
118
|
+
body: h
|
|
119
|
+
});
|
|
120
|
+
if (d(t, "cancelation", o.drop), !g.ok)
|
|
121
|
+
return n(g);
|
|
122
|
+
const b = await g.json();
|
|
123
|
+
return r.onResult && typeof r.onResult == "function" && r.onResult(b), { result: b, startedAt: c, endedAt: (/* @__PURE__ */ new Date()).toUTCString() };
|
|
124
|
+
} catch (s) {
|
|
125
|
+
return d(t, "cancelation", o.drop), s instanceof Error && s.name === "AbortError" ? n({
|
|
126
|
+
message: "Request was cancelled",
|
|
127
|
+
cancelled: !0
|
|
128
|
+
}) : n({
|
|
129
|
+
message: s instanceof Error ? s.message : "Unknown error occurred"
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
function v(r, n, i) {
|
|
135
|
+
const a = Object.keys(n), e = r.settings.primaryKey, c = f(r.storage) ? r.storage : {}, t = { ...c }, o = /* @__PURE__ */ new Set();
|
|
136
|
+
for (const s of a) {
|
|
137
|
+
const l = n[s];
|
|
138
|
+
if (l == null || typeof l == "string") {
|
|
139
|
+
o.add(s);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (z(l) && I(l, e)) {
|
|
143
|
+
const y = l[e];
|
|
144
|
+
if (typeof y != "string") {
|
|
145
|
+
console.warn(`Cdeebee: Primary key "${e}" is not a string for API "${s}". Skipping normalization.`), t[s] = l;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const u = {}, A = l.data, h = A.length;
|
|
149
|
+
for (let p = 0; p < h; p++) {
|
|
150
|
+
const m = A[p];
|
|
151
|
+
if (f(m) && m[y]) {
|
|
152
|
+
const S = m[y];
|
|
153
|
+
u[S] = m;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const g = i[s] ?? "merge", b = s in c ? c[s] : {};
|
|
157
|
+
g === "replace" ? t[s] = u : (g === "merge" || console.warn(`Cdeebee: Unknown strategy "${g}" for key "${s}". Skipping normalization.`), t[s] = q(b, u));
|
|
158
|
+
} else
|
|
159
|
+
t[s] = l;
|
|
160
|
+
}
|
|
161
|
+
return o.size > 0 ? N(Array.from(o), t) : t;
|
|
162
|
+
}
|
|
163
|
+
const T = {
|
|
164
|
+
settings: {
|
|
165
|
+
modules: ["history", "listener", "storage", "cancelation"],
|
|
166
|
+
fileKey: "file",
|
|
167
|
+
bodyKey: "value",
|
|
168
|
+
primaryKey: "primaryKey",
|
|
169
|
+
listStrategy: {},
|
|
170
|
+
mergeWithData: {},
|
|
171
|
+
mergeWithHeaders: {}
|
|
172
|
+
},
|
|
173
|
+
storage: {},
|
|
174
|
+
request: {
|
|
175
|
+
active: [],
|
|
176
|
+
errors: {},
|
|
177
|
+
done: {}
|
|
178
|
+
}
|
|
179
|
+
}, U = (r, n) => D({
|
|
180
|
+
name: "cdeebee",
|
|
181
|
+
initialState: q(T, { settings: r, storage: n ?? {} }),
|
|
182
|
+
reducers: {
|
|
183
|
+
set(a, e) {
|
|
184
|
+
O(a.storage, e.payload);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
extraReducers: (a) => {
|
|
188
|
+
a.addCase(k.pending, (e, c) => {
|
|
189
|
+
const t = c.meta.arg.api, o = c.meta.requestId;
|
|
190
|
+
d(e.settings, "cancelation", () => {
|
|
191
|
+
P(t, o);
|
|
192
|
+
}), d(e.settings, "listener", () => {
|
|
193
|
+
e.request.active.push({ api: t, requestId: o });
|
|
194
|
+
});
|
|
195
|
+
}).addCase(k.fulfilled, (e, c) => {
|
|
196
|
+
const t = c.meta.requestId, o = c.meta.arg.api;
|
|
197
|
+
d(e.settings, "listener", () => {
|
|
198
|
+
e.request.active = e.request.active.filter((s) => !(s.api === o && s.requestId === t));
|
|
199
|
+
}), d(e.settings, "history", () => {
|
|
200
|
+
e.request.done[o] || (e.request.done[o] = []), e.request.done[o].push({ api: o, request: c.payload, requestId: t });
|
|
201
|
+
}), d(e.settings, "storage", () => {
|
|
202
|
+
const s = c.meta.arg.listStrategy ?? e.settings.listStrategy ?? {}, l = c.meta.arg.normalize ?? e.settings.normalize ?? v, y = C(e), u = l(y, c.payload.result, s);
|
|
203
|
+
e.storage = u;
|
|
204
|
+
});
|
|
205
|
+
}).addCase(k.rejected, (e, c) => {
|
|
206
|
+
const t = c.meta.requestId, o = c.meta.arg.api;
|
|
207
|
+
d(e.settings, "listener", () => {
|
|
208
|
+
e.request.active = e.request.active.filter((s) => !(s.api === o && s.requestId === t));
|
|
209
|
+
}), d(e.settings, "history", () => {
|
|
210
|
+
e.request.errors[o] || (e.request.errors[o] = []), e.request.errors[o].push({ requestId: t, api: o, request: c.error });
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
export {
|
|
216
|
+
O as batchingUpdate,
|
|
217
|
+
U as factory,
|
|
218
|
+
k as request
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../lib/reducer/helpers.ts","../lib/reducer/abortController.ts","../lib/reducer/request.ts","../lib/reducer/storage.ts","../lib/reducer/index.ts"],"sourcesContent":["import { type CdeebeeSettings, type CdeebeeModule, CdeebeeValueList } from './types';\n\nexport function checkModule(settings: CdeebeeSettings<unknown>, module: CdeebeeModule, result: () => void) {\n if (settings.modules.includes(module)) {\n result();\n }\n}\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nexport function hasDataProperty(value: unknown): value is Record<string, unknown> & { data: unknown[] } {\n return isRecord(value) && Array.isArray(value.data);\n}\n\nexport function hasProperty(value: unknown, prop: string): boolean {\n return isRecord(value) && Object.prototype.hasOwnProperty.call(value, prop);\n}\n\nexport function mergeDeepRight<T>(\n left: T,\n right: Partial<T> | Record<string, unknown>\n): T {\n if (!isRecord(left) || !isRecord(right)) {\n return right as T;\n }\n\n const result = { ...left } as Record<string, unknown>;\n const rightRecord = right as Record<string, unknown>;\n\n for (const key in rightRecord) {\n if (Object.prototype.hasOwnProperty.call(rightRecord, key)) {\n const leftValue = result[key];\n const rightValue = rightRecord[key];\n\n if (\n isRecord(leftValue) &&\n isRecord(rightValue) &&\n !Array.isArray(leftValue) &&\n !Array.isArray(rightValue)\n ) {\n result[key] = mergeDeepRight(leftValue, rightValue);\n } else {\n result[key] = rightValue;\n }\n }\n }\n\n return result as T;\n}\n\nexport function omit<T extends Record<string, unknown>>(keys: string[], obj: T): Omit<T, keyof T> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, keyof T>;\n}\n\nexport function assocPath<T>(path: (string | number)[], value: unknown, obj: T): T {\n if (path.length === 0) {\n return value as T;\n }\n\n const [first, ...rest] = path;\n const firstKey = String(first);\n const result = Array.isArray(obj) ? [...obj] : { ...obj } as Record<string, unknown>;\n\n if (rest.length === 0) {\n (result as Record<string, unknown>)[firstKey] = value;\n } else {\n const currentValue = (result as Record<string, unknown>)[firstKey];\n (result as Record<string, unknown>)[firstKey] = assocPath(rest, value, currentValue ?? {});\n }\n\n return result as T;\n}\n\nexport function batchingUpdate<T extends Record<string, unknown>>(\n state: T,\n valueList: CdeebeeValueList<T>\n): void {\n for (let i = 0; i < valueList.length; i++) {\n const item = valueList[i] as { key: readonly (string | number)[]; value: unknown };\n const path = item.key;\n const value = item.value;\n \n if (path.length === 0) {\n continue;\n }\n\n let current: Record<string, unknown> | unknown[] = state as Record<string, unknown>;\n \n for (let j = 0; j < path.length - 1; j++) {\n const pathKey = path[j];\n \n if (Array.isArray(current)) {\n const index = typeof pathKey === 'number' ? pathKey : Number(pathKey);\n if (!(index in current) || !isRecord(current[index])) {\n current[index] = {};\n }\n current = current[index] as Record<string, unknown>;\n } else {\n const key = String(pathKey);\n if (!(key in current)) {\n const nextIsNumeric = typeof path[j + 1] === 'number' || (!isNaN(Number(path[j + 1])) && String(Number(path[j + 1])) === String(path[j + 1]));\n current[key] = nextIsNumeric ? [] : {};\n }\n const next = current[key];\n current = (Array.isArray(next) ? next : (isRecord(next) ? next : {})) as Record<string, unknown> | unknown[];\n }\n }\n \n if (Array.isArray(current)) {\n continue; // Can't update array element directly\n }\n current[String(path[path.length - 1])] = value;\n }\n}\n","interface RequestController {\n requestId: string;\n controller: AbortController;\n api: string;\n}\n\nclass AbortControllerStore {\n private byRequestId = new Map<string, RequestController>();\n private byApi = new Map<string, Set<string>>();\n\n add(api: string, requestId: string, controller: AbortController): void {\n const item: RequestController = { requestId, controller, api };\n this.byRequestId.set(requestId, item);\n\n if (!this.byApi.has(api)) {\n this.byApi.set(api, new Set());\n }\n this.byApi.get(api)!.add(requestId);\n }\n\n delete(requestId: string): void {\n const item = this.byRequestId.get(requestId);\n if (!item) return;\n\n this.byRequestId.delete(requestId);\n const apiSet = this.byApi.get(item.api);\n if (apiSet) {\n apiSet.delete(requestId);\n if (apiSet.size === 0) {\n this.byApi.delete(item.api);\n }\n }\n }\n\n abortAllForApi(api: string, excludeRequestId: string): void {\n const requestIds = this.byApi.get(api);\n if (!requestIds) return;\n\n requestIds.forEach(requestId => {\n if (requestId !== excludeRequestId) {\n const item = this.byRequestId.get(requestId);\n if (item) {\n item.controller.abort();\n this.delete(requestId);\n }\n }\n });\n }\n}\n\nconst abortStore = new AbortControllerStore();\n\nexport function abortQuery(api: string, currentRequestId: string): void {\n abortStore.abortAllForApi(api, currentRequestId);\n}\n\nexport function abortManager(signal: AbortSignal, api: string, requestId: string) {\n const controller = new AbortController();\n\n const cleanup = () => {\n abortStore.delete(requestId);\n };\n\n signal.addEventListener('abort', () => {\n controller.abort();\n cleanup();\n });\n\n return {\n controller,\n init: () => abortStore.add(api, requestId, controller),\n drop: cleanup,\n };\n}\n","import { createAsyncThunk } from '@reduxjs/toolkit';\nimport { checkModule } from './helpers';\nimport { abortManager } from './abortController';\nimport { type CdeebeeState, type CdeebeeRequestOptions } from './types';\n\nexport const request = createAsyncThunk(\n 'cdeebee/request',\n async (options: CdeebeeRequestOptions<unknown>, { rejectWithValue, getState, requestId, signal }) => {\n const startedAt = new Date().toUTCString();\n const { cdeebee: { settings } } = getState() as { cdeebee: CdeebeeState<unknown> };\n\n const abort = abortManager(signal, options.api, requestId);\n\n checkModule(settings, 'cancelation', abort.init);\n\n try {\n const { method = 'POST', body, headers = {} } = options;\n const extraHeaders: Record<string, string> = { ...(settings.mergeWithHeaders ?? {}), ...headers };\n\n const b = { ...(settings.mergeWithData ?? {}), ...(body ?? {}) };\n let requestData: FormData | string = JSON.stringify(b);\n\n // handling files\n if (options.files) {\n const formData = new FormData();\n const fileKey = options.fileKey || settings.fileKey;\n const bodyKey = options.bodyKey || settings.bodyKey;\n\n for (let i = 0; i < options.files.length; i += 1) {\n if (fileKey) {\n formData.append(fileKey, options.files[i]);\n }\n }\n\n if (bodyKey) {\n formData.append(bodyKey, requestData);\n }\n requestData = formData;\n }\n // [end] handling files\n \n const response = await fetch(options.api, {\n method,\n headers: {\n 'ui-request-id': requestId,\n 'Content-Type': 'application/json',\n ...extraHeaders,\n },\n signal: abort.controller.signal,\n body: requestData,\n });\n\n checkModule(settings, 'cancelation', abort.drop);\n\n if (!response.ok) {\n return rejectWithValue(response);\n }\n const result = await response.json();\n if (options.onResult && typeof options.onResult === 'function') {\n options.onResult(result);\n }\n return { result, startedAt, endedAt: new Date().toUTCString() };\n } catch (error) {\n checkModule(settings, 'cancelation', abort.drop);\n if (error instanceof Error && error.name === 'AbortError') {\n return rejectWithValue({\n message: 'Request was cancelled',\n cancelled: true,\n });\n }\n return rejectWithValue({\n message: error instanceof Error ? error.message : 'Unknown error occurred',\n });\n }\n },\n);\n\n","import { type CdeebeeListStrategy, type CdeebeeState } from './types';\nimport { hasDataProperty, hasProperty, isRecord, mergeDeepRight, omit } from './helpers';\n\ntype ResponseValue = Record<string, unknown> & {\n data?: unknown[];\n [key: string]: unknown;\n};\n\ntype IResponse = Record<string, ResponseValue>;\n\ntype StorageData = Record<string, unknown>;\n\nexport function defaultNormalize<T>(\n cdeebee: CdeebeeState<T>,\n response: IResponse,\n strategyList: CdeebeeListStrategy<T> \n): Record<string, ResponseValue> {\n const keyList = Object.keys(response);\n const primaryKey = cdeebee.settings.primaryKey;\n const currentStorage = isRecord(cdeebee.storage) ? (cdeebee.storage as Record<string, unknown>) : {};\n \n // Start with existing storage to preserve keys not in response\n const result = { ...currentStorage } as Record<string, ResponseValue>;\n const keyListToOmit = new Set<string>();\n\n for (const key of keyList) {\n const responseValue = response[key];\n\n if (responseValue === null || responseValue === undefined || typeof responseValue === 'string') {\n keyListToOmit.add(key);\n continue;\n }\n\n if (hasDataProperty(responseValue) && hasProperty(responseValue, primaryKey)) {\n const primaryKeyValue = responseValue[primaryKey];\n \n if (typeof primaryKeyValue !== 'string') {\n console.warn(`Cdeebee: Primary key \"${primaryKey}\" is not a string for API \"${key}\". Skipping normalization.`);\n result[key] = responseValue;\n continue;\n }\n\n // Pre-allocate storage data object\n const newStorageData: StorageData = {};\n const dataArray = responseValue.data;\n const dataLength = dataArray.length;\n\n for (let i = 0; i < dataLength; i++) {\n const element = dataArray[i];\n if (isRecord(element) && element[primaryKeyValue]) {\n const elementKey = element[primaryKeyValue] as string;\n newStorageData[elementKey] = element;\n }\n }\n\n const strategy = strategyList[key as keyof T] ?? 'merge';\n const existingValue = key in currentStorage ? (currentStorage[key] as StorageData) : {};\n\n if (strategy === 'replace') {\n // Replace: completely replace the value\n result[key] = newStorageData as ResponseValue;\n } else if (strategy === 'merge') {\n // Merge: merge with existing value\n result[key] = mergeDeepRight(existingValue, newStorageData) as ResponseValue;\n } else {\n // Unknown strategy: warn and fall back to merge\n console.warn(`Cdeebee: Unknown strategy \"${strategy}\" for key \"${key}\". Skipping normalization.`);\n result[key] = mergeDeepRight(existingValue, newStorageData) as ResponseValue;\n }\n } else {\n result[key] = responseValue;\n }\n }\n\n return keyListToOmit.size > 0 ? omit(Array.from(keyListToOmit), result) : result;\n}\n","import { createSlice, current } from '@reduxjs/toolkit';\n\nimport { type CdeebeeSettings, type CdeebeeState, type CdeebeeValueList } from './types';\nimport { checkModule, mergeDeepRight, batchingUpdate } from './helpers';\nimport { abortQuery } from './abortController';\nimport { request } from './request';\nimport { defaultNormalize } from './storage';\n\nconst initialState: CdeebeeState<unknown> = {\n settings: {\n modules: ['history', 'listener', 'storage', 'cancelation'],\n fileKey: 'file',\n bodyKey: 'value',\n primaryKey: 'primaryKey',\n listStrategy: {},\n mergeWithData: {},\n mergeWithHeaders: {},\n },\n storage: {},\n request: {\n active: [],\n errors: {},\n done: {}\n },\n};\n\nexport const factory = <T>(settings: CdeebeeSettings<T>, storage?: T) => {\n const slice = createSlice({\n name: 'cdeebee',\n initialState: mergeDeepRight(initialState, { settings, storage: storage ?? {} }) as CdeebeeState<T>,\n reducers: {\n set(state, action: { payload: CdeebeeValueList<T> }) {\n // Directly mutate state.storage using Immer Draft\n // This is more performant than creating a new object\n // Immer will track changes and create minimal updates\n batchingUpdate(state.storage as Record<string, unknown>, action.payload);\n }\n },\n extraReducers: builder => {\n builder\n .addCase(request.pending, (state, action) => {\n const api = action.meta.arg.api;\n const requestId = action.meta.requestId;\n\n checkModule(state.settings, 'cancelation', () => {\n abortQuery(api, requestId);\n });\n checkModule(state.settings, 'listener', () => {\n state.request.active.push({ api, requestId });\n });\n })\n .addCase(request.fulfilled, (state, action) => {\n const requestId = action.meta.requestId;\n const api = action.meta.arg.api;\n\n checkModule(state.settings, 'listener', () => {\n state.request.active = state.request.active.filter(q => !(q.api === api && q.requestId === requestId));\n });\n checkModule(state.settings, 'history', () => {\n if (!state.request.done[api]) state.request.done[api] = [];\n state.request.done[api].push({ api, request: action.payload, requestId });\n });\n checkModule(state.settings, 'storage', () => {\n const strategyList = action.meta.arg.listStrategy ?? state.settings.listStrategy ?? {};\n const normalize = action.meta.arg.normalize ?? state.settings.normalize ?? defaultNormalize;\n\n const currentState = current(state) as CdeebeeState<T>;\n const normalizedData = normalize(currentState, action.payload.result, strategyList);\n\n // Normalize already handles merge/replace and preserves keys not in response\n // Simply apply the result\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (state.storage as any) = normalizedData;\n });\n })\n .addCase(request.rejected, (state, action) => {\n const requestId = action.meta.requestId;\n const api = action.meta.arg.api;\n \n checkModule(state.settings, 'listener', () => {\n state.request.active = state.request.active.filter(q => !(q.api === api && q.requestId === requestId));\n });\n checkModule(state.settings, 'history', () => {\n if (!state.request.errors[api]) state.request.errors[api] = [];\n state.request.errors[api].push({ requestId: requestId, api, request: action.error });\n });\n });\n },\n });\n\n return slice;\n};\n"],"names":["checkModule","settings","module","result","isRecord","value","hasDataProperty","hasProperty","prop","mergeDeepRight","left","right","rightRecord","key","leftValue","rightValue","omit","keys","obj","batchingUpdate","state","valueList","item","path","current","j","pathKey","index","nextIsNumeric","next","AbortControllerStore","api","requestId","controller","apiSet","excludeRequestId","requestIds","abortStore","abortQuery","currentRequestId","abortManager","signal","cleanup","request","createAsyncThunk","options","rejectWithValue","getState","startedAt","abort","method","body","headers","extraHeaders","b","requestData","formData","fileKey","bodyKey","i","response","error","defaultNormalize","cdeebee","strategyList","keyList","primaryKey","currentStorage","keyListToOmit","responseValue","primaryKeyValue","newStorageData","dataArray","dataLength","element","elementKey","strategy","existingValue","initialState","factory","storage","createSlice","action","builder","q","normalize","currentState","normalizedData"],"mappings":";AAEO,SAASA,EAAYC,GAAoCC,GAAuBC,GAAoB;AACzG,EAAIF,EAAS,QAAQ,SAASC,CAAM,KAClCC,EAAA;AAEJ;AACO,SAASC,EAASC,GAAkD;AACzE,SAAOA,MAAU,QAAQ,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAC5E;AAEQ,SAASC,EAAgBD,GAAwE;AACvG,SAAOD,EAASC,CAAK,KAAK,MAAM,QAAQA,EAAM,IAAI;AACpD;AAEQ,SAASE,EAAYF,GAAgBG,GAAuB;AAClE,SAAOJ,EAASC,CAAK,KAAK,OAAO,UAAU,eAAe,KAAKA,GAAOG,CAAI;AAC5E;AAEO,SAASC,EACdC,GACAC,GACG;AACH,MAAI,CAACP,EAASM,CAAI,KAAK,CAACN,EAASO,CAAK;AACpC,WAAOA;AAGT,QAAMR,IAAS,EAAE,GAAGO,EAAA,GACdE,IAAcD;AAEpB,aAAWE,KAAOD;AAChB,QAAI,OAAO,UAAU,eAAe,KAAKA,GAAaC,CAAG,GAAG;AAC1D,YAAMC,IAAYX,EAAOU,CAAG,GACtBE,IAAaH,EAAYC,CAAG;AAElC,MACET,EAASU,CAAS,KAClBV,EAASW,CAAU,KACnB,CAAC,MAAM,QAAQD,CAAS,KACxB,CAAC,MAAM,QAAQC,CAAU,IAEzBZ,EAAOU,CAAG,IAAIJ,EAAeK,GAAWC,CAAU,IAElDZ,EAAOU,CAAG,IAAIE;AAAA,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EAAO,SAAS,WAAAlD,EAAA,CAAW;AAAA,MAC1E,CAAC,GACDhC,EAAYoB,EAAM,UAAU,WAAW,MAAM;AAC3C,cAAM4C,IAAekB,EAAO,KAAK,IAAI,gBAAgB9D,EAAM,SAAS,gBAAgB,CAAA,GAC9EiE,IAAYH,EAAO,KAAK,IAAI,aAAa9D,EAAM,SAAS,aAAa0C,GAErEwB,IAAe9D,EAAQJ,CAAK,GAC5BmE,IAAiBF,EAAUC,GAAcJ,EAAO,QAAQ,QAAQlB,CAAY;AAKjF,QAAA5C,EAAM,UAAkBmE;AAAA,MAC3B,CAAC;AAAA,IACH,CAAC,EACA,QAAQ5C,EAAQ,UAAU,CAACvB,GAAO8D,MAAW;AAC5C,YAAMlD,IAAYkD,EAAO,KAAK,WACxBnD,IAAMmD,EAAO,KAAK,IAAI;AAE5B,MAAAlF,EAAYoB,EAAM,UAAU,YAAY,MAAM;AAC5C,QAAAA,EAAM,QAAQ,SAASA,EAAM,QAAQ,OAAO,OAAO,CAAAgE,MAAK,EAAEA,EAAE,QAAQrD,KAAOqD,EAAE,cAAcpD,EAAU;AAAA,MACvG,CAAC,GACDhC,EAAYoB,EAAM,UAAU,WAAW,MAAM;AAC3C,QAAKA,EAAM,QAAQ,OAAOW,CAAG,MAAIX,EAAM,QAAQ,OAAOW,CAAG,IAAI,CAAA,IAC7DX,EAAM,QAAQ,OAAOW,CAAG,EAAE,KAAK,EAAE,WAAAC,GAAsB,KAAAD,GAAK,SAASmD,EAAO,MAAA,CAAO;AAAA,MACrF,CAAC;AAAA,IACH,CAAC;AAAA,EACL;AAAA,CACD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recats/cdeebee",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.3",
|
|
4
4
|
"description": "React Redux data-logic library",
|
|
5
5
|
"repository": "git@github.com:recats/cdeebee.git",
|
|
6
6
|
"author": "recats",
|
|
@@ -13,39 +13,50 @@
|
|
|
13
13
|
"server"
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
],
|
|
16
|
+
"main": "./dist/index.cjs",
|
|
17
|
+
"module": "./dist/index.js",
|
|
19
18
|
"types": "./dist/index.d.ts",
|
|
20
|
-
"module": "./dist/cdeebee.js",
|
|
21
19
|
"exports": {
|
|
22
20
|
".": {
|
|
23
21
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"import":
|
|
25
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
28
37
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@types/
|
|
31
|
-
"@types/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"typescript
|
|
36
|
-
"
|
|
37
|
-
"vite
|
|
38
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
39
|
+
"@types/lodash": "^4.17.21",
|
|
40
|
+
"@types/node": "^22.19.3",
|
|
41
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
42
|
+
"eslint": "^9.39.2",
|
|
43
|
+
"jsdom": "^27.3.0",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"typescript-eslint": "^8.50.1",
|
|
46
|
+
"vite": "^6.4.1",
|
|
47
|
+
"vite-plugin-dts": "^4.5.4",
|
|
48
|
+
"vitest": "^2.1.9"
|
|
38
49
|
},
|
|
39
50
|
"peerDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"redux": ">=5.0.0"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"abortcontroller-polyfill": "^1.7.8",
|
|
45
|
-
"whatwg-fetch": "^3.6.20"
|
|
51
|
+
"@reduxjs/toolkit": ">=2"
|
|
46
52
|
},
|
|
47
53
|
"scripts": {
|
|
48
|
-
"lint": "eslint
|
|
49
|
-
"
|
|
54
|
+
"lint": "eslint lib/**/*.ts",
|
|
55
|
+
"lint:ts": "tsc --noEmit --project tsconfig.lint.json",
|
|
56
|
+
"lint:all": "pnpm lint && pnpm lint:ts",
|
|
57
|
+
"build": "vite build",
|
|
58
|
+
"test": "vitest",
|
|
59
|
+
"test:run": "vitest run",
|
|
60
|
+
"test:coverage": "vitest run --coverage"
|
|
50
61
|
}
|
|
51
62
|
}
|
package/dist/actions.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Dispatch } from 'redux';
|
|
2
|
-
import { cdeebeeTypes, cdeebeeValueList, EntityID } from './definition';
|
|
3
|
-
export declare function unsafe_updateStore(entityList: string, entityID: EntityID, value: unknown): (dispatch: Dispatch) => void;
|
|
4
|
-
export declare function setKeyValue(entityList: string, entityID: EntityID, valueList: cdeebeeValueList[]): (dispatch: Dispatch) => void;
|
|
5
|
-
export declare function commitEntity(entityList: string, entityID: EntityID, entity: object): (dispatch: Dispatch) => void;
|
|
6
|
-
export declare function resetEntity(entityList: string, entityID: string | number): (dispatch: Dispatch) => void;
|
|
7
|
-
export declare function dropCdeebeePath(path: (string | number)[]): (dispatch: Dispatch) => {
|
|
8
|
-
type: cdeebeeTypes;
|
|
9
|
-
payload: {
|
|
10
|
-
path: (string | number)[];
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare function dropRequestByApiUrl(api: string): (dispatch: Dispatch) => {
|
|
14
|
-
type: cdeebeeTypes;
|
|
15
|
-
payload: {
|
|
16
|
-
api: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare function dropErrorsByApiUrl(api: string): (dispatch: Dispatch) => {
|
|
20
|
-
type: cdeebeeTypes;
|
|
21
|
-
payload: {
|
|
22
|
-
api: string;
|
|
23
|
-
};
|
|
24
|
-
};
|