@ryuzaki13/react-foundation-api 1.0.0 → 1.1.1
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/adt/index.js +1 -1
- package/dist/chunks/{fetch-BW2OtCu7.js → fetch-3O2E2pQ9.js} +3 -3
- package/dist/chunks/{fetch-BW2OtCu7.js.map → fetch-3O2E2pQ9.js.map} +1 -1
- package/dist/chunks/{odataFetchFn-BXVJxOou.js → odataFetchFn-BS26nUg7.js} +3 -3
- package/dist/chunks/{odataFetchFn-BXVJxOou.js.map → odataFetchFn-BS26nUg7.js.map} +1 -1
- package/dist/odata/index.js +473 -4
- package/dist/odata/index.js.map +1 -0
- package/dist/persisted/index.js +1 -1
- package/dist/transport/index.js +1 -1
- package/package.json +1 -8
- package/dist/chunks/odata-ZgZGme_K.js +0 -473
- package/dist/chunks/odata-ZgZGme_K.js.map +0 -1
- package/dist/s3/constants.d.ts +0 -12
- package/dist/s3/constants.d.ts.map +0 -1
- package/dist/s3/fetchFileFromS3.d.ts +0 -13
- package/dist/s3/fetchFileFromS3.d.ts.map +0 -1
- package/dist/s3/index.d.ts +0 -3
- package/dist/s3/index.d.ts.map +0 -1
- package/dist/s3/index.js +0 -41
- package/dist/s3/index.js.map +0 -1
- package/dist/s3/uploadToS3.d.ts +0 -18
- package/dist/s3/uploadToS3.d.ts.map +0 -1
package/dist/transport/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as e } from "../chunks/fetch-
|
|
1
|
+
import { r as e } from "../chunks/fetch-3O2E2pQ9.js";
|
|
2
2
|
import { normalizeTextWithFallback as t } from "@ryuzaki13/react-foundation-lib/formatters";
|
|
3
3
|
//#region src/transport/normalizeTransportRequests.ts
|
|
4
4
|
function n(e, n) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuzaki13/react-foundation-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Reusable React and TypeScript foundation API helpers and transport adapters.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ryuzaki13",
|
|
@@ -60,10 +60,6 @@
|
|
|
60
60
|
"types": "./dist/resource/index.d.ts",
|
|
61
61
|
"import": "./dist/resource/index.js"
|
|
62
62
|
},
|
|
63
|
-
"./s3": {
|
|
64
|
-
"types": "./dist/s3/index.d.ts",
|
|
65
|
-
"import": "./dist/s3/index.js"
|
|
66
|
-
},
|
|
67
63
|
"./server-fn": {
|
|
68
64
|
"types": "./dist/server-fn/index.d.ts",
|
|
69
65
|
"import": "./dist/server-fn/index.js"
|
|
@@ -97,9 +93,6 @@
|
|
|
97
93
|
"resource": [
|
|
98
94
|
"dist/resource/index.d.ts"
|
|
99
95
|
],
|
|
100
|
-
"s3": [
|
|
101
|
-
"dist/s3/index.d.ts"
|
|
102
|
-
],
|
|
103
96
|
"server-fn": [
|
|
104
97
|
"dist/server-fn/index.d.ts"
|
|
105
98
|
],
|
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
import { C as e, c as t, x as n } from "./fetch-BW2OtCu7.js";
|
|
2
|
-
import { f as r, h as i, m as a, r as o } from "./odataFetchFn-BXVJxOou.js";
|
|
3
|
-
import { logError as s } from "@ryuzaki13/react-foundation-lib/utils";
|
|
4
|
-
import { parseDate as c } from "@ryuzaki13/react-foundation-lib/formatters";
|
|
5
|
-
import { compareStrings as l } from "@ryuzaki13/react-foundation-lib/string-comparison";
|
|
6
|
-
import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
7
|
-
import { queryOptions as h, useQuery as g, useQueryClient as _ } from "@tanstack/react-query";
|
|
8
|
-
import { buildSeparatedArrays as v, useODataCollectionStore as y } from "@ryuzaki13/react-foundation-lib/odata";
|
|
9
|
-
import { persistedQueryMeta as b } from "@ryuzaki13/react-foundation-lib/query-client";
|
|
10
|
-
import { buildEntityPath as x } from "@ryuzaki13/react-foundation-lib/odata-service";
|
|
11
|
-
import { createTableColumnVisibilityFromODataMetadata as S, createTableColumnsFromODataMetadata as C, enrichTableColumnsWithODataFormatting as w, resolveStableColumnId as T } from "@ryuzaki13/react-foundation-lib/table";
|
|
12
|
-
import "@ryuzaki13/react-foundation-lib/notifications";
|
|
13
|
-
//#region src/odata/createODataCollectionQueryKey.ts
|
|
14
|
-
var E = () => [...i, "collection"], D = ({ service: e, target: t, limitedKeys: n, serverFilter: r }) => [...E(), {
|
|
15
|
-
service: e,
|
|
16
|
-
target: t,
|
|
17
|
-
limitedKeys: n,
|
|
18
|
-
serverFilter: r
|
|
19
|
-
}];
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/odata/flattenODataDependentServices.ts
|
|
22
|
-
function O(e) {
|
|
23
|
-
let t = [];
|
|
24
|
-
for (let [n, r] of e.entries()) {
|
|
25
|
-
let e = `${r.odata.service}.${r.odata.target}`;
|
|
26
|
-
for (let [i, [a, o]] of Object.entries(r.segments).entries()) t.push({
|
|
27
|
-
id: a,
|
|
28
|
-
serviceKey: e,
|
|
29
|
-
serviceIndex: n,
|
|
30
|
-
segmentIndex: i,
|
|
31
|
-
odata: r.odata,
|
|
32
|
-
segment: o,
|
|
33
|
-
model: {
|
|
34
|
-
...r.model,
|
|
35
|
-
codeKey: a
|
|
36
|
-
},
|
|
37
|
-
panelVisibility: o.panelVisibility ?? "user"
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return t;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/odata/sortODataDependentSegmentItemsByChains.ts
|
|
44
|
-
function k(e, t, n) {
|
|
45
|
-
let r = /* @__PURE__ */ new Map();
|
|
46
|
-
for (let [e, n] of Object.entries(t)) r.set(e, new Map(n.map((e, t) => [e.codeKey, t])));
|
|
47
|
-
let i = [...e].map((e, t) => ({
|
|
48
|
-
item: e,
|
|
49
|
-
index: t
|
|
50
|
-
})).sort((e, t) => {
|
|
51
|
-
if (e.item.serviceIndex !== t.item.serviceIndex) return e.item.serviceIndex - t.item.serviceIndex;
|
|
52
|
-
let n = r.get(e.item.serviceKey), i = n?.get(e.item.id), a = n?.get(t.item.id);
|
|
53
|
-
return i !== void 0 && a !== void 0 ? i - a : i === void 0 ? a === void 0 ? e.item.segmentIndex === t.item.segmentIndex ? e.index - t.index : e.item.segmentIndex - t.item.segmentIndex : 1 : -1;
|
|
54
|
-
});
|
|
55
|
-
if (!n?.length) return i.map(({ item: e }) => e);
|
|
56
|
-
let a = new Set(i.map(({ item: e }) => e.id)), o = [...new Set(n)].filter((e) => a.has(e));
|
|
57
|
-
if (o.length === 0) return i.map(({ item: e }) => e);
|
|
58
|
-
let s = new Map(o.map((e, t) => [e, t]));
|
|
59
|
-
return [...i].sort((e, t) => {
|
|
60
|
-
let n = s.get(e.item.id), r = s.get(t.item.id);
|
|
61
|
-
return n !== void 0 && r !== void 0 ? n - r : n === void 0 ? r === void 0 ? e.index - t.index : 1 : -1;
|
|
62
|
-
}).map(({ item: e }) => e);
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/odata/sortODataDependentServicesByChains.ts
|
|
66
|
-
function A(e, t) {
|
|
67
|
-
if (!t?.length) return [...e];
|
|
68
|
-
let n = /* @__PURE__ */ new Set();
|
|
69
|
-
for (let t of e) for (let e of Object.keys(t.segments)) n.add(e);
|
|
70
|
-
let r = [...new Set(t)].filter((e) => n.has(e));
|
|
71
|
-
if (r.length === 0) return [...e];
|
|
72
|
-
let i = new Map(r.map((e, t) => [e, t])), a = r.length, o = /* @__PURE__ */ new Map(), s = a;
|
|
73
|
-
for (let t of e) for (let e of Object.keys(t.segments)) o.has(e) || o.set(e, i.get(e) ?? s++);
|
|
74
|
-
return [...e.map((e) => {
|
|
75
|
-
let t = Object.entries(e.segments).sort(([e], [t]) => (o.get(e) ?? 2 ** 53 - 1) - (o.get(t) ?? 2 ** 53 - 1));
|
|
76
|
-
return {
|
|
77
|
-
...e,
|
|
78
|
-
segments: Object.fromEntries(t)
|
|
79
|
-
};
|
|
80
|
-
})].sort((e, t) => {
|
|
81
|
-
let n = Object.keys(e.segments)[0], r = Object.keys(t.segments)[0];
|
|
82
|
-
return (n ? o.get(n) ?? 2 ** 53 - 1 : 2 ** 53 - 1) - (r ? o.get(r) ?? 2 ** 53 - 1 : 2 ** 53 - 1);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function j(e, t, n) {
|
|
86
|
-
return A(e.map((e) => {
|
|
87
|
-
let n = t[`${e.odata.service}.${e.odata.target}`];
|
|
88
|
-
if (!n?.length) return e;
|
|
89
|
-
let r = new Map(n.map((e, t) => [e.codeKey, t])), i = Object.entries(e.segments).sort(([e], [t]) => {
|
|
90
|
-
let n = r.get(e), i = r.get(t);
|
|
91
|
-
return n !== void 0 && i !== void 0 ? n - i : n === void 0 ? i === void 0 ? l(e, t) : 1 : -1;
|
|
92
|
-
});
|
|
93
|
-
return {
|
|
94
|
-
...e,
|
|
95
|
-
segments: Object.fromEntries(i)
|
|
96
|
-
};
|
|
97
|
-
}), n);
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/odata/fetchCollectionData.ts
|
|
101
|
-
async function M(e) {
|
|
102
|
-
let { url: n, query: r, signal: i } = e;
|
|
103
|
-
try {
|
|
104
|
-
let e = await a(n, r, { signal: i });
|
|
105
|
-
if (t(e)) throw Error("отсутствует тело ответа");
|
|
106
|
-
return { items: e.data.map(({ ID: e, CNT: t, __metadata: n, __Parameters: r, ...i }) => i) };
|
|
107
|
-
} catch (e) {
|
|
108
|
-
return s("Ошибка загрузки справочника:", e), { items: [] };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/odata/useODataCollectionUpdatesQuery.ts
|
|
113
|
-
var N = "@ryuzaki13/react-foundation-api@1.0.0", P = 1e3 * 60 * 60 * 4, F = 1e3 * 60 * 60 * 24 * 7, I = "ttl=forever;name=ref", L = "bust=forever;name=ref", R = "ttl=4h;name=ref-updates", z = () => [
|
|
114
|
-
...i,
|
|
115
|
-
"collection-updates",
|
|
116
|
-
{ buildId: N }
|
|
117
|
-
];
|
|
118
|
-
function B(e) {
|
|
119
|
-
return {
|
|
120
|
-
...e,
|
|
121
|
-
lastChangedAt: c(e.lastChanged)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function V(e, t) {
|
|
125
|
-
let n = e.map(B);
|
|
126
|
-
return {
|
|
127
|
-
items: n,
|
|
128
|
-
byEntityName: n.reduce((e, t) => (t.entityName && (e[t.entityName] = t), e), {}),
|
|
129
|
-
fetchedAt: t,
|
|
130
|
-
coverageStartedAt: t - F
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function H() {
|
|
134
|
-
return async ({ signal: t }) => {
|
|
135
|
-
let r = Date.now(), i = n().collectionUpdates;
|
|
136
|
-
return i ? V((await a(`/${i.service}/${i.target}`, {
|
|
137
|
-
baseUrl: e(i.service, i.baseUrl),
|
|
138
|
-
swCache: R
|
|
139
|
-
}, { signal: t })).data, Math.max(r, Date.now())) : V([], r);
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
var U = (e = {}) => h({
|
|
143
|
-
queryKey: z(),
|
|
144
|
-
queryFn: H(),
|
|
145
|
-
meta: b,
|
|
146
|
-
enabled: !!n().collectionUpdates,
|
|
147
|
-
staleTime: e.staleTime ?? P,
|
|
148
|
-
gcTime: Infinity
|
|
149
|
-
});
|
|
150
|
-
function W(e = {}) {
|
|
151
|
-
return g(U(e));
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/odata/useODataMetadata.ts
|
|
155
|
-
function G(e) {
|
|
156
|
-
let { data: t, dataUpdatedAt: n = 0, isLoading: i, isError: a } = r({ service: e.service }), o = t?.entities[e.target];
|
|
157
|
-
if (!i && !o && t?.functionImports[e.target]) throw Error(`OData target '${e.target}' является FunctionImport и не может использоваться как сущность`);
|
|
158
|
-
if (a) throw Error(`Ошибка загрузки метаданных сервиса ${e.service}`);
|
|
159
|
-
return {
|
|
160
|
-
metadata: o,
|
|
161
|
-
metadataUpdatedAt: n,
|
|
162
|
-
isLoading: i
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
//#endregion
|
|
166
|
-
//#region src/odata/useODataEntity.ts
|
|
167
|
-
var K = "Использование actions недопустимо до окончания загрузки metadata";
|
|
168
|
-
function q(e) {
|
|
169
|
-
let { metadata: t, metadataUpdatedAt: n, isLoading: r } = G(e);
|
|
170
|
-
return {
|
|
171
|
-
config: e,
|
|
172
|
-
metadata: t,
|
|
173
|
-
metadataUpdatedAt: n,
|
|
174
|
-
isLoading: r,
|
|
175
|
-
actions: f(() => ({
|
|
176
|
-
getEntityPath: (n = {}) => {
|
|
177
|
-
if (!t) throw Error(K);
|
|
178
|
-
return x(t, e, n);
|
|
179
|
-
},
|
|
180
|
-
getKeys: () => {
|
|
181
|
-
if (!t) throw Error(K);
|
|
182
|
-
return t.columns?.map((e) => e.id);
|
|
183
|
-
},
|
|
184
|
-
getKeyPairs: () => {
|
|
185
|
-
if (!t) throw Error(K);
|
|
186
|
-
return t.columns?.filter((e) => e.semanticType === "code" && e.linkedColumnId).map((e) => ({
|
|
187
|
-
codeKey: e.id,
|
|
188
|
-
textKey: e.linkedColumnId
|
|
189
|
-
}));
|
|
190
|
-
},
|
|
191
|
-
getKeyPairsMap: () => {
|
|
192
|
-
if (!t) throw Error(K);
|
|
193
|
-
let e = {};
|
|
194
|
-
for (let n of t.columns ?? []) n.semanticType === "code" && n.linkedColumnId && (e[n.id] = n.linkedColumnId);
|
|
195
|
-
return e;
|
|
196
|
-
}
|
|
197
|
-
}), [e, t])
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
//#endregion
|
|
201
|
-
//#region src/odata/useODataCollectionQuery.ts
|
|
202
|
-
function J(e, t) {
|
|
203
|
-
if (!t) return e;
|
|
204
|
-
let n = e.trim().toLowerCase();
|
|
205
|
-
return n === "off" || n.startsWith("bust=") ? e : n.startsWith("ttl=") ? e.replace(/^\s*ttl=/i, "bust=") : L;
|
|
206
|
-
}
|
|
207
|
-
function Y(e) {
|
|
208
|
-
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
209
|
-
}
|
|
210
|
-
function X(e, t) {
|
|
211
|
-
let n = t?.cacheUpdatedAt ?? 0, r = e.update?.lastChangedAt?.getTime();
|
|
212
|
-
return !!(Y(r) && (!t || !n || r > n) || Y(e.metadataUpdatedAt) && (!t || !n || e.metadataUpdatedAt > n) || Y(e.updatesCoverageStartedAt) && (!t || !n || n < e.updatesCoverageStartedAt));
|
|
213
|
-
}
|
|
214
|
-
function Z(e) {
|
|
215
|
-
let { service: t, target: n, limitedKeys: r, excludeEmpty: i, sortByCode: a, serverFilter: o, clientFilter: s, swCache: c = I } = e, l = _(), { actions: u, metadata: p, metadataUpdatedAt: m, isLoading: h } = q(e), y = W(), x = f(() => D({
|
|
216
|
-
service: t,
|
|
217
|
-
target: n,
|
|
218
|
-
limitedKeys: r,
|
|
219
|
-
serverFilter: o
|
|
220
|
-
}), [
|
|
221
|
-
t,
|
|
222
|
-
n,
|
|
223
|
-
r,
|
|
224
|
-
o
|
|
225
|
-
]), S = l.getQueryData(x), C = y.data?.byEntityName[n], w = X({
|
|
226
|
-
update: C,
|
|
227
|
-
metadataUpdatedAt: m,
|
|
228
|
-
updatesCoverageStartedAt: y.data?.coverageStartedAt
|
|
229
|
-
}, S), T = J(c, w), E = y.isError || y.isSuccess && !y.isFetching;
|
|
230
|
-
return d(() => {
|
|
231
|
-
!S || !w || l.invalidateQueries({ queryKey: x });
|
|
232
|
-
}, [
|
|
233
|
-
S,
|
|
234
|
-
l,
|
|
235
|
-
x,
|
|
236
|
-
w
|
|
237
|
-
]), g({
|
|
238
|
-
queryKey: x,
|
|
239
|
-
queryFn: async ({ signal: e }) => {
|
|
240
|
-
let c = Date.now(), l = r ? [...r] : u.getKeys(), d = u.getKeyPairs(), f = u.getKeyPairsMap();
|
|
241
|
-
if (r) for (let e of r) {
|
|
242
|
-
let t = f[e];
|
|
243
|
-
t && !l.includes(t) && l.push(t);
|
|
244
|
-
}
|
|
245
|
-
let { items: p } = await M({
|
|
246
|
-
url: `/${t}/${n}`,
|
|
247
|
-
query: {
|
|
248
|
-
select: l,
|
|
249
|
-
expression: o,
|
|
250
|
-
swCache: T
|
|
251
|
-
},
|
|
252
|
-
signal: e
|
|
253
|
-
}), h = p;
|
|
254
|
-
s && (h = p.filter(s));
|
|
255
|
-
let g = v(h, d, i, a), _ = d.map((e) => ({
|
|
256
|
-
codeKey: e.codeKey,
|
|
257
|
-
count: g[e.codeKey].length
|
|
258
|
-
})).sort((e, t) => e.count - t.count);
|
|
259
|
-
return {
|
|
260
|
-
items: h,
|
|
261
|
-
keyPairs: d,
|
|
262
|
-
keyPairsMap: f,
|
|
263
|
-
separated: g,
|
|
264
|
-
chain: _,
|
|
265
|
-
count: h.length,
|
|
266
|
-
cacheUpdatedAt: Math.max(c, Date.now(), C?.lastChangedAt?.getTime() ?? 0, m)
|
|
267
|
-
};
|
|
268
|
-
},
|
|
269
|
-
enabled: !!(!h && p && t && n && E),
|
|
270
|
-
meta: b,
|
|
271
|
-
staleTime: 1e3 * 60 * 60 * 2,
|
|
272
|
-
gcTime: 1e3 * 60 * 60 * 1
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/odata/useODataCollection.ts
|
|
277
|
-
function Q({ odata: e, model: t, pageSize: n = 50 }) {
|
|
278
|
-
let { codeKey: r, maxVisibleItems: i } = t, { data: a, isLoading: o, isError: s, refetch: c } = Z(e), l = a?.keyPairsMap[r] ?? "", d = _(), [h, g] = m(), v = p(/* @__PURE__ */ new Map()), { itemsMap: y, separatedItems: b, orderedKeys: x } = f(() => {
|
|
279
|
-
let e = /* @__PURE__ */ new Map(), t = [], n = [];
|
|
280
|
-
if (a && a.separated[r]) {
|
|
281
|
-
n = a.separated[r];
|
|
282
|
-
for (let i of n) {
|
|
283
|
-
let n = i[r];
|
|
284
|
-
n && (e.set(n, i), t.push(n));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return {
|
|
288
|
-
itemsMap: e,
|
|
289
|
-
separatedItems: n,
|
|
290
|
-
orderedKeys: t
|
|
291
|
-
};
|
|
292
|
-
}, [a, r]), S = u((e) => {
|
|
293
|
-
let t = a?.separated[r];
|
|
294
|
-
if (!t) return /* @__PURE__ */ new Map();
|
|
295
|
-
let n = /* @__PURE__ */ new Map();
|
|
296
|
-
for (let i of t) {
|
|
297
|
-
let t = i[e]?.toLowerCase();
|
|
298
|
-
if (t) for (let e = 1; e <= Math.min(5, t.length); e++) {
|
|
299
|
-
let a = t.substring(0, e);
|
|
300
|
-
n.has(a) || n.set(a, /* @__PURE__ */ new Set()), n.get(a).add(i[r]);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return n;
|
|
304
|
-
}, [a, r]), C = u((e) => {
|
|
305
|
-
g(() => {
|
|
306
|
-
if (e?.length) return new Set(e.map((e) => e[r]));
|
|
307
|
-
});
|
|
308
|
-
}, [r]), w = u((e, t) => {
|
|
309
|
-
if (!x.length) return [];
|
|
310
|
-
let n = i, a = /* @__PURE__ */ new Set(), o = [];
|
|
311
|
-
if (t?.length) for (let e = 0; e < t.length; e++) a.add(t[e][r]);
|
|
312
|
-
let s = 0, c = h && h.size > 0;
|
|
313
|
-
for (let t of x) {
|
|
314
|
-
if (s >= n) break;
|
|
315
|
-
let i = y.get(t);
|
|
316
|
-
if (!i || a.size > 0 && a.has(t)) continue;
|
|
317
|
-
let u = i[r];
|
|
318
|
-
c && !h.has(u) || e && !e(u, i[l]) || (o.push(i), s++);
|
|
319
|
-
}
|
|
320
|
-
return o;
|
|
321
|
-
}, [
|
|
322
|
-
x,
|
|
323
|
-
i,
|
|
324
|
-
r,
|
|
325
|
-
y,
|
|
326
|
-
h,
|
|
327
|
-
l
|
|
328
|
-
]), T = u((e) => {
|
|
329
|
-
let t = a?.separated[r] || [], i = e * n, o = i + n;
|
|
330
|
-
return t.slice(i, o);
|
|
331
|
-
}, [
|
|
332
|
-
a,
|
|
333
|
-
n,
|
|
334
|
-
r
|
|
335
|
-
]), E = u((e, t) => {
|
|
336
|
-
if (!a) return [];
|
|
337
|
-
let n = new Set(t);
|
|
338
|
-
return a.items.filter((t) => n.has(t[e]));
|
|
339
|
-
}, [a]), O = u((e, t, n = 200) => {
|
|
340
|
-
v.current.has(e) && clearTimeout(v.current.get(e));
|
|
341
|
-
let r = setTimeout(t, n);
|
|
342
|
-
v.current.set(e, r);
|
|
343
|
-
}, []), k = u(() => {
|
|
344
|
-
for (let e of v.current.values()) clearTimeout(e);
|
|
345
|
-
v.current.clear();
|
|
346
|
-
}, []);
|
|
347
|
-
return f(() => () => {
|
|
348
|
-
k();
|
|
349
|
-
}, [k]), {
|
|
350
|
-
data: a,
|
|
351
|
-
isLoading: o,
|
|
352
|
-
isError: s,
|
|
353
|
-
codeKey: r,
|
|
354
|
-
textKey: l,
|
|
355
|
-
getItems: w,
|
|
356
|
-
findSourceItemsByKeys: E,
|
|
357
|
-
setFilteredItems: C,
|
|
358
|
-
getPage: T,
|
|
359
|
-
buildSearchIndex: S,
|
|
360
|
-
debounce: O,
|
|
361
|
-
itemsMap: y,
|
|
362
|
-
separatedItems: b,
|
|
363
|
-
orderedKeys: x,
|
|
364
|
-
refetch: c,
|
|
365
|
-
invalidate: () => d.invalidateQueries({ queryKey: D(e) }),
|
|
366
|
-
totalCount: a?.separated[r]?.length || 0,
|
|
367
|
-
pageSize: n
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
//#endregion
|
|
371
|
-
//#region src/odata/useODataCollectionChains.ts
|
|
372
|
-
function $(e) {
|
|
373
|
-
let t = _(), [n, r] = m({}), i = f(() => e.map((e) => D(e)), [e]);
|
|
374
|
-
return d(() => {
|
|
375
|
-
function n() {
|
|
376
|
-
let n = {};
|
|
377
|
-
for (let r of e) {
|
|
378
|
-
let e = D(r), i = t.getQueryData(e);
|
|
379
|
-
i?.chain && (n[`${r.service}.${r.target}`] = i.chain);
|
|
380
|
-
}
|
|
381
|
-
r((e) => Object.keys(e).length === Object.keys(n).length && Object.entries(n).every(([t, n]) => e[t] === n) ? e : n);
|
|
382
|
-
}
|
|
383
|
-
return n(), t.getQueryCache().subscribe((e) => {
|
|
384
|
-
if (e?.query) {
|
|
385
|
-
let t = e.query;
|
|
386
|
-
i.some((e) => JSON.stringify(e) === JSON.stringify(t.queryKey)) && n();
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
}, [
|
|
390
|
-
e,
|
|
391
|
-
t,
|
|
392
|
-
i
|
|
393
|
-
]), n;
|
|
394
|
-
}
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/odata/useODataCollectionModel.ts
|
|
397
|
-
function ee(e) {
|
|
398
|
-
let [t] = m(() => {
|
|
399
|
-
let t = y.getState(), { codeKey: n, maxVisibleItems: r = t.defaultMaxVisibleItems, minSearchCodeLength: i = t.defaultMinSearchCodeLength, minSearchTextLength: a = t.defaultMinSearchTextLength, searchDebounceDelay: o = t.defaultSearchDebounceDelay } = e;
|
|
400
|
-
return {
|
|
401
|
-
codeKey: n,
|
|
402
|
-
maxVisibleItems: r,
|
|
403
|
-
minSearchCodeLength: i,
|
|
404
|
-
minSearchTextLength: a,
|
|
405
|
-
searchDebounceDelay: o
|
|
406
|
-
};
|
|
407
|
-
});
|
|
408
|
-
return t;
|
|
409
|
-
}
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region src/odata/useODataTableColumns.ts
|
|
412
|
-
function te(e, t) {
|
|
413
|
-
let n = {}, r = (e) => {
|
|
414
|
-
for (let i of e) {
|
|
415
|
-
if ("columns" in i && Array.isArray(i.columns) && i.columns.length > 0) {
|
|
416
|
-
r(i.columns);
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
let e = T(i);
|
|
420
|
-
!e || !(e in t) || (n[e] = t[e]);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
return r(e), n;
|
|
424
|
-
}
|
|
425
|
-
function ne(e) {
|
|
426
|
-
let { metadata: t, isLoading: n } = G(e);
|
|
427
|
-
return {
|
|
428
|
-
columns: f(() => t ? e.mode === "build" ? C(t.columns, {
|
|
429
|
-
resolveHeader: e.resolveHeader,
|
|
430
|
-
resolveFormatting: e.resolveFormatting
|
|
431
|
-
}) : w(e.columns, t.columns) : e.mode === "build" ? [] : [...e.columns], [e, t]),
|
|
432
|
-
defaultColumnVisibility: f(() => {
|
|
433
|
-
if (!t) return;
|
|
434
|
-
if (e.mode === "build") return S(t.columns, { resolveVisible: e.resolveVisible });
|
|
435
|
-
let n = S(t.columns);
|
|
436
|
-
return te(e.columns, n);
|
|
437
|
-
}, [e, t]),
|
|
438
|
-
metadata: t,
|
|
439
|
-
isLoading: n
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
//#endregion
|
|
443
|
-
//#region src/odata/useTextServiceQuery.ts
|
|
444
|
-
function re(e) {
|
|
445
|
-
return Z({
|
|
446
|
-
service: "TEXT_DICTIONARY_SRV",
|
|
447
|
-
target: e
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/odata/odataFetchFnDev.ts
|
|
452
|
-
function ie(e) {
|
|
453
|
-
return o("create", e);
|
|
454
|
-
}
|
|
455
|
-
function ae(e) {
|
|
456
|
-
return o("update", e);
|
|
457
|
-
}
|
|
458
|
-
function oe(e) {
|
|
459
|
-
return o("delete", e);
|
|
460
|
-
}
|
|
461
|
-
function se(e) {
|
|
462
|
-
return o("read", e);
|
|
463
|
-
}
|
|
464
|
-
function ce(e) {
|
|
465
|
-
return o("query", e);
|
|
466
|
-
}
|
|
467
|
-
function le(e) {
|
|
468
|
-
return o("fi", e);
|
|
469
|
-
}
|
|
470
|
-
//#endregion
|
|
471
|
-
export { U as C, O as D, k as E, E as O, H as S, j as T, L as _, se as a, R as b, ne as c, Q as d, J as f, G as g, q as h, ce as i, D as k, ee as l, Z as m, oe as n, ae as o, X as p, le as r, re as s, ie as t, $ as u, I as v, W as w, z as x, F as y };
|
|
472
|
-
|
|
473
|
-
//# sourceMappingURL=odata-ZgZGme_K.js.map
|