@ryuzaki13/react-foundation-api 1.1.15 → 1.1.17
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 +32 -43
- package/dist/chunks/{odataFetchFn-vnAXC-c0.js → odataFetchFn-B9wSQpUS.js} +11 -11
- package/dist/chunks/{odataFetchFn-vnAXC-c0.js.map → odataFetchFn-B9wSQpUS.js.map} +1 -1
- package/dist/odata/fetchCollectionData.d.ts +1 -1
- package/dist/odata/fetchCollectionData.d.ts.map +1 -1
- package/dist/odata/index.js +111 -112
- package/dist/odata/index.js.map +1 -1
- package/dist/odata/projectODataCollectionSort.d.ts +1 -1
- package/dist/odata/projectODataCollectionSort.d.ts.map +1 -1
- package/dist/odata/types.d.ts +1 -2
- package/dist/odata/types.d.ts.map +1 -1
- package/dist/odata/useODataCollection.d.ts +1 -1
- package/dist/odata/useODataCollection.d.ts.map +1 -1
- package/dist/odata/useODataCollectionQuery.d.ts +1 -1
- package/dist/odata/useODataCollectionQuery.d.ts.map +1 -1
- package/dist/odata/useODataEntity.d.ts +1 -1
- package/dist/odata/useODataEntity.d.ts.map +1 -1
- package/dist/persisted/index.js +1 -1
- package/package.json +8 -3
- package/src/adt/README.mdx +164 -0
- package/src/async/README.mdx +253 -0
- package/src/error-report/README.mdx +148 -0
- package/src/foundationApi.mdx +123 -0
- package/src/http/README.mdx +221 -0
- package/src/odata/README.mdx +790 -0
- package/src/persisted/README.mdx +454 -0
- package/src/resource/README.mdx +358 -0
- package/src/server-fn/README.mdx +194 -0
- package/src/transport/README.mdx +183 -0
- package/src/README.md +0 -937
- package/src/async/README.md +0 -623
- package/src/async/async.mdx +0 -6
- package/src/odata/README.md +0 -761
- package/src/odata/odataFetchFn.mdx +0 -6
- package/src/persisted/README.md +0 -598
- package/src/persisted/persisted.mdx +0 -6
package/dist/odata/index.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, w as x, x as S, y as C } from "../chunks/fetch-Cq29VQlt.js";
|
|
2
|
-
import { S as w, _ as ee, a as te, b as ne, c as re, d as ie, f as ae, g as
|
|
2
|
+
import { S as w, _ as ee, a as te, b as ne, c as re, d as ie, f as ae, g as oe, h as se, i as ce, l as le, m as ue, n as de, o as fe, p as pe, r as T, s as me, t as he, u as ge, v as E, x as D, y as _e } from "../chunks/odataFetchFn-B9wSQpUS.js";
|
|
3
3
|
import { logError as ve } from "@ryuzaki13/react-foundation-lib/utils";
|
|
4
4
|
import { parseDate as ye } from "@ryuzaki13/react-foundation-lib/formatters";
|
|
5
|
-
import { compareStrings as
|
|
6
|
-
import { useCallback as
|
|
7
|
-
import { queryOptions as
|
|
8
|
-
import { buildSeparatedArrays as Ce, useODataCollectionStore as we } from "@ryuzaki13/react-foundation-lib/odata";
|
|
9
|
-
import { persistedQueryMeta as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { notify as je } from "@ryuzaki13/react-foundation-lib/notifications";
|
|
5
|
+
import { compareStrings as O } from "@ryuzaki13/react-foundation-lib/string-comparison";
|
|
6
|
+
import { useCallback as k, useEffect as A, useMemo as j, useRef as be, useState as M } from "react";
|
|
7
|
+
import { queryOptions as xe, useQuery as N, useQueryClient as P } from "@tanstack/react-query";
|
|
8
|
+
import { buildEntityPath as Se, buildSeparatedArrays as Ce, useODataCollectionStore as we } from "@ryuzaki13/react-foundation-lib/odata-service";
|
|
9
|
+
import { persistedQueryMeta as F } from "@ryuzaki13/react-foundation-lib/query-client";
|
|
10
|
+
import { createTableColumnVisibilityFromODataMetadata as I, createTableColumnsFromODataMetadata as Te, enrichTableColumnsWithODataFormatting as Ee, resolveStableColumnId as De } from "@ryuzaki13/react-foundation-lib/table";
|
|
11
|
+
import { notify as Oe } from "@ryuzaki13/react-foundation-lib/notifications";
|
|
13
12
|
//#region src/odata/createODataCollectionQueryKey.ts
|
|
14
|
-
var
|
|
15
|
-
version:
|
|
13
|
+
var ke = 2, L = () => [...w, "collection"], R = ({ service: e, target: t, limitedKeys: n, serverFilter: r }) => [...L(), {
|
|
14
|
+
version: ke,
|
|
16
15
|
service: e,
|
|
17
16
|
target: t,
|
|
18
17
|
limitedKeys: n,
|
|
@@ -20,7 +19,7 @@ var Me = 2, P = () => [...w, "collection"], F = ({ service: e, target: t, limite
|
|
|
20
19
|
}];
|
|
21
20
|
//#endregion
|
|
22
21
|
//#region src/odata/flattenODataDependentServices.ts
|
|
23
|
-
function
|
|
22
|
+
function Ae(e) {
|
|
24
23
|
let t = [];
|
|
25
24
|
for (let [n, r] of e.entries()) {
|
|
26
25
|
let e = `${r.odata.service}.${r.odata.target}`;
|
|
@@ -42,7 +41,7 @@ function Ne(e) {
|
|
|
42
41
|
}
|
|
43
42
|
//#endregion
|
|
44
43
|
//#region src/odata/sortODataDependentSegmentItemsByChains.ts
|
|
45
|
-
function
|
|
44
|
+
function je(e, t, n) {
|
|
46
45
|
let r = /* @__PURE__ */ new Map();
|
|
47
46
|
for (let [e, n] of Object.entries(t)) r.set(e, new Map(n.map((e, t) => [e.codeKey, t])));
|
|
48
47
|
let i = [...e].map((e, t) => ({
|
|
@@ -64,7 +63,7 @@ function Pe(e, t, n) {
|
|
|
64
63
|
}
|
|
65
64
|
//#endregion
|
|
66
65
|
//#region src/odata/sortODataDependentServicesByChains.ts
|
|
67
|
-
function
|
|
66
|
+
function Me(e, t) {
|
|
68
67
|
if (!t?.length) return [...e];
|
|
69
68
|
let n = /* @__PURE__ */ new Set();
|
|
70
69
|
for (let t of e) for (let e of Object.keys(t.segments)) n.add(e);
|
|
@@ -83,13 +82,13 @@ function Fe(e, t) {
|
|
|
83
82
|
return (n ? o.get(n) ?? 2 ** 53 - 1 : 2 ** 53 - 1) - (r ? o.get(r) ?? 2 ** 53 - 1 : 2 ** 53 - 1);
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
|
-
function
|
|
87
|
-
return
|
|
85
|
+
function Ne(e, t, n) {
|
|
86
|
+
return Me(e.map((e) => {
|
|
88
87
|
let n = t[`${e.odata.service}.${e.odata.target}`];
|
|
89
88
|
if (!n?.length) return e;
|
|
90
89
|
let r = new Map(n.map((e, t) => [e.codeKey, t])), i = Object.entries(e.segments).sort(([e], [t]) => {
|
|
91
90
|
let n = r.get(e), i = r.get(t);
|
|
92
|
-
return n !== void 0 && i !== void 0 ? n - i : n === void 0 ? i === void 0 ?
|
|
91
|
+
return n !== void 0 && i !== void 0 ? n - i : n === void 0 ? i === void 0 ? O(e, t) : 1 : -1;
|
|
93
92
|
});
|
|
94
93
|
return {
|
|
95
94
|
...e,
|
|
@@ -99,7 +98,7 @@ function Ie(e, t, n) {
|
|
|
99
98
|
}
|
|
100
99
|
//#endregion
|
|
101
100
|
//#region src/odata/fetchCollectionData.ts
|
|
102
|
-
async function
|
|
101
|
+
async function Pe(e) {
|
|
103
102
|
let { url: t, query: n, signal: r } = e;
|
|
104
103
|
try {
|
|
105
104
|
let e = await D(t, n, { signal: r });
|
|
@@ -111,66 +110,66 @@ async function Le(e) {
|
|
|
111
110
|
}
|
|
112
111
|
//#endregion
|
|
113
112
|
//#region src/odata/projectODataCollectionSort.ts
|
|
114
|
-
var
|
|
115
|
-
function
|
|
116
|
-
let t =
|
|
113
|
+
var z = /* @__PURE__ */ new WeakMap();
|
|
114
|
+
function Fe(e) {
|
|
115
|
+
let t = z.get(e);
|
|
117
116
|
if (t) return t;
|
|
118
117
|
let n = !1, r = Object.fromEntries(Object.entries(e.separated).map(([t, r]) => {
|
|
119
118
|
let i = e.keyPairsMap[t];
|
|
120
|
-
return !i || r.length < 2 ? [t, r] : (n = !0, [t, [...r].sort((e, t) =>
|
|
119
|
+
return !i || r.length < 2 ? [t, r] : (n = !0, [t, [...r].sort((e, t) => O(String(e[i] ?? ""), String(t[i] ?? "")))]);
|
|
121
120
|
}));
|
|
122
121
|
if (!n) return e;
|
|
123
122
|
let i = {
|
|
124
123
|
...e,
|
|
125
124
|
separated: r
|
|
126
125
|
};
|
|
127
|
-
return
|
|
126
|
+
return z.set(e, i), i;
|
|
128
127
|
}
|
|
129
128
|
//#endregion
|
|
130
129
|
//#region src/odata/useODataCollectionUpdatesQuery.ts
|
|
131
|
-
var
|
|
130
|
+
var Ie = __APP_BUILD_ID__, Le = 144e5, B = 6048e5, V = "ttl=forever;name=ref", H = "bust=forever;name=ref", U = "ttl=4h;name=ref-updates", W = () => [
|
|
132
131
|
...w,
|
|
133
132
|
"collection-updates",
|
|
134
|
-
{ buildId:
|
|
133
|
+
{ buildId: Ie }
|
|
135
134
|
];
|
|
136
|
-
function
|
|
135
|
+
function Re(e) {
|
|
137
136
|
return {
|
|
138
137
|
...e,
|
|
139
138
|
lastChangedAt: ye(e.lastChanged)
|
|
140
139
|
};
|
|
141
140
|
}
|
|
142
|
-
function
|
|
143
|
-
let n = e.map(
|
|
141
|
+
function G(e, t) {
|
|
142
|
+
let n = e.map(Re);
|
|
144
143
|
return {
|
|
145
144
|
items: n,
|
|
146
145
|
byEntityName: n.reduce((e, t) => (t.entityName && (e[t.entityName] = t), e), {}),
|
|
147
146
|
fetchedAt: t,
|
|
148
|
-
coverageStartedAt: t -
|
|
147
|
+
coverageStartedAt: t - B
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
|
-
function
|
|
150
|
+
function K() {
|
|
152
151
|
return async ({ signal: t }) => {
|
|
153
152
|
let n = Date.now(), r = S().collectionUpdates;
|
|
154
|
-
return r ?
|
|
153
|
+
return r ? G((await D(`/${r.service}/${r.target}`, {
|
|
155
154
|
baseUrl: e(r.service, r.baseUrl),
|
|
156
|
-
swCache:
|
|
157
|
-
}, { signal: t })).data, Math.max(n, Date.now())) :
|
|
155
|
+
swCache: U
|
|
156
|
+
}, { signal: t })).data, Math.max(n, Date.now())) : G([], n);
|
|
158
157
|
};
|
|
159
158
|
}
|
|
160
|
-
var
|
|
161
|
-
queryKey:
|
|
162
|
-
queryFn:
|
|
163
|
-
meta:
|
|
164
|
-
staleTime: e.staleTime ??
|
|
159
|
+
var ze = (e = {}) => xe({
|
|
160
|
+
queryKey: W(),
|
|
161
|
+
queryFn: K(),
|
|
162
|
+
meta: F,
|
|
163
|
+
staleTime: e.staleTime ?? Le,
|
|
165
164
|
gcTime: Infinity
|
|
166
165
|
});
|
|
167
|
-
function
|
|
168
|
-
return
|
|
166
|
+
function Be(e = {}) {
|
|
167
|
+
return N(ze(e));
|
|
169
168
|
}
|
|
170
169
|
//#endregion
|
|
171
170
|
//#region src/odata/useODataMetadata.ts
|
|
172
|
-
function
|
|
173
|
-
let { data: t, dataUpdatedAt: n = 0, isLoading: r, isLoadingError: i } =
|
|
171
|
+
function q(e) {
|
|
172
|
+
let { data: t, dataUpdatedAt: n = 0, isLoading: r, isLoadingError: i } = E({ service: e.service }), a = t?.entities[e.target];
|
|
174
173
|
if (!r && !a && t?.functionImports[e.target]) throw Error(`OData target '${e.target}' является FunctionImport и не может использоваться как сущность`);
|
|
175
174
|
if (i) throw Error(`Ошибка загрузки метаданных сервиса ${e.service}`);
|
|
176
175
|
return {
|
|
@@ -181,32 +180,32 @@ function K(e) {
|
|
|
181
180
|
}
|
|
182
181
|
//#endregion
|
|
183
182
|
//#region src/odata/useODataEntity.ts
|
|
184
|
-
var
|
|
185
|
-
function
|
|
186
|
-
let { metadata: t, metadataUpdatedAt: n, isLoading: r } =
|
|
183
|
+
var J = "Использование actions недопустимо до окончания загрузки metadata";
|
|
184
|
+
function Ve(e) {
|
|
185
|
+
let { metadata: t, metadataUpdatedAt: n, isLoading: r } = q(e);
|
|
187
186
|
return {
|
|
188
187
|
config: e,
|
|
189
188
|
metadata: t,
|
|
190
189
|
metadataUpdatedAt: n,
|
|
191
190
|
isLoading: r,
|
|
192
|
-
actions:
|
|
191
|
+
actions: j(() => ({
|
|
193
192
|
getEntityPath: (n = {}) => {
|
|
194
|
-
if (!t) throw Error(
|
|
195
|
-
return
|
|
193
|
+
if (!t) throw Error(J);
|
|
194
|
+
return Se(t, e, n);
|
|
196
195
|
},
|
|
197
196
|
getKeys: () => {
|
|
198
|
-
if (!t) throw Error(
|
|
197
|
+
if (!t) throw Error(J);
|
|
199
198
|
return t.columns?.map((e) => e.id);
|
|
200
199
|
},
|
|
201
200
|
getKeyPairs: () => {
|
|
202
|
-
if (!t) throw Error(
|
|
201
|
+
if (!t) throw Error(J);
|
|
203
202
|
return t.columns?.filter((e) => e.semanticType === "code" && e.linkedColumnId).map((e) => ({
|
|
204
203
|
codeKey: e.id,
|
|
205
204
|
textKey: e.linkedColumnId
|
|
206
205
|
}));
|
|
207
206
|
},
|
|
208
207
|
getKeyPairsMap: () => {
|
|
209
|
-
if (!t) throw Error(
|
|
208
|
+
if (!t) throw Error(J);
|
|
210
209
|
let e = {};
|
|
211
210
|
for (let n of t.columns ?? []) n.semanticType === "code" && n.linkedColumnId && (e[n.id] = n.linkedColumnId);
|
|
212
211
|
return e;
|
|
@@ -216,20 +215,20 @@ function J(e) {
|
|
|
216
215
|
}
|
|
217
216
|
//#endregion
|
|
218
217
|
//#region src/odata/useODataCollectionQuery.ts
|
|
219
|
-
function
|
|
218
|
+
function He(e, t) {
|
|
220
219
|
if (!t) return e;
|
|
221
220
|
let n = e.trim().toLowerCase();
|
|
222
|
-
return n === "off" || n.startsWith("bust=") ? e : n.startsWith("ttl=") ? e.replace(/^\s*ttl=/i, "bust=") :
|
|
221
|
+
return n === "off" || n.startsWith("bust=") ? e : n.startsWith("ttl=") ? e.replace(/^\s*ttl=/i, "bust=") : H;
|
|
223
222
|
}
|
|
224
|
-
function
|
|
223
|
+
function Y(e) {
|
|
225
224
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
226
225
|
}
|
|
227
|
-
function
|
|
226
|
+
function Ue(e, t) {
|
|
228
227
|
let n = t?.cacheUpdatedAt ?? 0, r = e.update?.lastChangedAt?.getTime();
|
|
229
|
-
return !!(
|
|
228
|
+
return !!(Y(r) && (!t || !n || r > n) || Y(e.metadataUpdatedAt) && (!t || !n || e.metadataUpdatedAt > n) || Y(e.updatesCoverageStartedAt) && (!t || !n || n < e.updatesCoverageStartedAt));
|
|
230
229
|
}
|
|
231
|
-
function
|
|
232
|
-
let { service: t, target: n, limitedKeys: r, excludeEmpty: i, sortByCode: a, serverFilter: o, clientFilter: s, swCache: c =
|
|
230
|
+
function We(e) {
|
|
231
|
+
let { service: t, target: n, limitedKeys: r, excludeEmpty: i, sortByCode: a, serverFilter: o, clientFilter: s, swCache: c = V } = e, l = P(), { actions: u, metadata: d, metadataUpdatedAt: f, isLoading: p } = Ve(e), m = Be(), h = j(() => R({
|
|
233
232
|
service: t,
|
|
234
233
|
target: n,
|
|
235
234
|
limitedKeys: r,
|
|
@@ -239,19 +238,19 @@ function Ue(e) {
|
|
|
239
238
|
n,
|
|
240
239
|
r,
|
|
241
240
|
o
|
|
242
|
-
]), g = l.getQueryData(h), _ = m.data?.byEntityName[n], v =
|
|
241
|
+
]), g = l.getQueryData(h), _ = m.data?.byEntityName[n], v = Ue({
|
|
243
242
|
update: _,
|
|
244
243
|
metadataUpdatedAt: f,
|
|
245
244
|
updatesCoverageStartedAt: m.data?.coverageStartedAt
|
|
246
|
-
}, g), y =
|
|
247
|
-
return
|
|
245
|
+
}, g), y = He(c, v), b = m.isError || m.isSuccess && !m.isFetching;
|
|
246
|
+
return A(() => {
|
|
248
247
|
!g || !v || l.invalidateQueries({ queryKey: h });
|
|
249
248
|
}, [
|
|
250
249
|
g,
|
|
251
250
|
l,
|
|
252
251
|
h,
|
|
253
252
|
v
|
|
254
|
-
]),
|
|
253
|
+
]), N({
|
|
255
254
|
queryKey: h,
|
|
256
255
|
queryFn: async ({ signal: e }) => {
|
|
257
256
|
let a = Date.now(), c = r ? [...r] : u.getKeys(), l = u.getKeyPairs(), d = u.getKeyPairsMap();
|
|
@@ -259,7 +258,7 @@ function Ue(e) {
|
|
|
259
258
|
let t = d[e];
|
|
260
259
|
t && !c.includes(t) && c.push(t);
|
|
261
260
|
}
|
|
262
|
-
let { items: p } = await
|
|
261
|
+
let { items: p } = await Pe({
|
|
263
262
|
url: `/${t}/${n}`,
|
|
264
263
|
query: {
|
|
265
264
|
select: c,
|
|
@@ -284,16 +283,16 @@ function Ue(e) {
|
|
|
284
283
|
};
|
|
285
284
|
},
|
|
286
285
|
enabled: !!(!p && d && t && n && b),
|
|
287
|
-
meta:
|
|
286
|
+
meta: F,
|
|
288
287
|
staleTime: 72e5,
|
|
289
288
|
gcTime: 36e5,
|
|
290
|
-
select: a === !1 ?
|
|
289
|
+
select: a === !1 ? Fe : void 0
|
|
291
290
|
});
|
|
292
291
|
}
|
|
293
292
|
//#endregion
|
|
294
293
|
//#region src/odata/useODataCollection.ts
|
|
295
|
-
function
|
|
296
|
-
let { codeKey: r, maxVisibleItems: i } = t, { data: a, isLoading: o, isError: s, refetch: c } =
|
|
294
|
+
function Ge({ odata: e, model: t, pageSize: n = 50 }) {
|
|
295
|
+
let { codeKey: r, maxVisibleItems: i } = t, { data: a, isLoading: o, isError: s, refetch: c } = We(e), l = a?.keyPairsMap[r] ?? "", u = P(), [d, f] = M(), p = be(/* @__PURE__ */ new Map()), { itemsMap: m, separatedItems: h, orderedKeys: g } = j(() => {
|
|
297
296
|
let e = /* @__PURE__ */ new Map(), t = [], n = [];
|
|
298
297
|
if (a && a.separated[r]) {
|
|
299
298
|
n = a.separated[r];
|
|
@@ -307,7 +306,7 @@ function We({ odata: e, model: t, pageSize: n = 50 }) {
|
|
|
307
306
|
separatedItems: n,
|
|
308
307
|
orderedKeys: t
|
|
309
308
|
};
|
|
310
|
-
}, [a, r]), _ =
|
|
309
|
+
}, [a, r]), _ = k((e) => {
|
|
311
310
|
let t = a?.separated[r];
|
|
312
311
|
if (!t) return /* @__PURE__ */ new Map();
|
|
313
312
|
let n = /* @__PURE__ */ new Map();
|
|
@@ -319,11 +318,11 @@ function We({ odata: e, model: t, pageSize: n = 50 }) {
|
|
|
319
318
|
}
|
|
320
319
|
}
|
|
321
320
|
return n;
|
|
322
|
-
}, [a, r]), v =
|
|
321
|
+
}, [a, r]), v = k((e) => {
|
|
323
322
|
f(() => {
|
|
324
323
|
if (e?.length) return new Set(e.map((e) => e[r]));
|
|
325
324
|
});
|
|
326
|
-
}, [r]), y =
|
|
325
|
+
}, [r]), y = k((e, t) => {
|
|
327
326
|
if (!g.length) return [];
|
|
328
327
|
let n = i, a = /* @__PURE__ */ new Set(), o = [];
|
|
329
328
|
if (t?.length) for (let e = 0; e < t.length; e++) a.add(t[e][r]);
|
|
@@ -343,26 +342,26 @@ function We({ odata: e, model: t, pageSize: n = 50 }) {
|
|
|
343
342
|
m,
|
|
344
343
|
d,
|
|
345
344
|
l
|
|
346
|
-
]), b =
|
|
345
|
+
]), b = k((e) => {
|
|
347
346
|
let t = a?.separated[r] || [], i = e * n, o = i + n;
|
|
348
347
|
return t.slice(i, o);
|
|
349
348
|
}, [
|
|
350
349
|
a,
|
|
351
350
|
n,
|
|
352
351
|
r
|
|
353
|
-
]), x =
|
|
352
|
+
]), x = k((e, t) => {
|
|
354
353
|
if (!a) return [];
|
|
355
354
|
let n = new Set(t);
|
|
356
355
|
return a.items.filter((t) => n.has(t[e]));
|
|
357
|
-
}, [a]), S =
|
|
356
|
+
}, [a]), S = k((e, t, n = 200) => {
|
|
358
357
|
p.current.has(e) && clearTimeout(p.current.get(e));
|
|
359
358
|
let r = setTimeout(t, n);
|
|
360
359
|
p.current.set(e, r);
|
|
361
|
-
}, []), C =
|
|
360
|
+
}, []), C = k(() => {
|
|
362
361
|
for (let e of p.current.values()) clearTimeout(e);
|
|
363
362
|
p.current.clear();
|
|
364
363
|
}, []);
|
|
365
|
-
return
|
|
364
|
+
return j(() => () => {
|
|
366
365
|
C();
|
|
367
366
|
}, [C]), {
|
|
368
367
|
data: a,
|
|
@@ -380,20 +379,20 @@ function We({ odata: e, model: t, pageSize: n = 50 }) {
|
|
|
380
379
|
separatedItems: h,
|
|
381
380
|
orderedKeys: g,
|
|
382
381
|
refetch: c,
|
|
383
|
-
invalidate: () => u.invalidateQueries({ queryKey:
|
|
382
|
+
invalidate: () => u.invalidateQueries({ queryKey: R(e) }),
|
|
384
383
|
totalCount: a?.separated[r]?.length || 0,
|
|
385
384
|
pageSize: n
|
|
386
385
|
};
|
|
387
386
|
}
|
|
388
387
|
//#endregion
|
|
389
388
|
//#region src/odata/useODataCollectionChains.ts
|
|
390
|
-
function
|
|
391
|
-
let t =
|
|
392
|
-
return
|
|
389
|
+
function Ke(e) {
|
|
390
|
+
let t = P(), [n, r] = M({}), i = j(() => e.map((e) => R(e)), [e]);
|
|
391
|
+
return A(() => {
|
|
393
392
|
function n() {
|
|
394
393
|
let n = {};
|
|
395
394
|
for (let r of e) {
|
|
396
|
-
let e =
|
|
395
|
+
let e = R(r), i = t.getQueryData(e);
|
|
397
396
|
i?.chain && (n[`${r.service}.${r.target}`] = i.chain);
|
|
398
397
|
}
|
|
399
398
|
r((e) => Object.keys(e).length === Object.keys(n).length && Object.entries(n).every(([t, n]) => e[t] === n) ? e : n);
|
|
@@ -412,8 +411,8 @@ function Ge(e) {
|
|
|
412
411
|
}
|
|
413
412
|
//#endregion
|
|
414
413
|
//#region src/odata/useODataCollectionModel.ts
|
|
415
|
-
function
|
|
416
|
-
let [t] =
|
|
414
|
+
function qe(e) {
|
|
415
|
+
let [t] = M(() => {
|
|
417
416
|
let t = we.getState(), { codeKey: n, maxVisibleItems: r = t.defaultMaxVisibleItems, minSearchCodeLength: i = t.defaultMinSearchCodeLength, minSearchTextLength: a = t.defaultMinSearchTextLength, searchDebounceDelay: o = t.defaultSearchDebounceDelay } = e;
|
|
418
417
|
return {
|
|
419
418
|
codeKey: n,
|
|
@@ -427,31 +426,31 @@ function Ke(e) {
|
|
|
427
426
|
}
|
|
428
427
|
//#endregion
|
|
429
428
|
//#region src/odata/useODataTableColumns.ts
|
|
430
|
-
function
|
|
429
|
+
function Je(e, t) {
|
|
431
430
|
let n = {}, r = (e) => {
|
|
432
431
|
for (let i of e) {
|
|
433
432
|
if ("columns" in i && Array.isArray(i.columns) && i.columns.length > 0) {
|
|
434
433
|
r(i.columns);
|
|
435
434
|
continue;
|
|
436
435
|
}
|
|
437
|
-
let e =
|
|
436
|
+
let e = De(i);
|
|
438
437
|
!e || !(e in t) || (n[e] = t[e]);
|
|
439
438
|
}
|
|
440
439
|
};
|
|
441
440
|
return r(e), n;
|
|
442
441
|
}
|
|
443
|
-
function
|
|
444
|
-
let { metadata: t, isLoading: n } =
|
|
442
|
+
function Ye(e) {
|
|
443
|
+
let { metadata: t, isLoading: n } = q(e);
|
|
445
444
|
return {
|
|
446
|
-
columns:
|
|
445
|
+
columns: j(() => t ? e.mode === "build" ? Te(t.columns, {
|
|
447
446
|
resolveHeader: e.resolveHeader,
|
|
448
447
|
resolveFormatting: e.resolveFormatting
|
|
449
|
-
}) :
|
|
450
|
-
defaultColumnVisibility:
|
|
448
|
+
}) : Ee(e.columns, t.columns) : e.mode === "build" ? [] : [...e.columns], [e, t]),
|
|
449
|
+
defaultColumnVisibility: j(() => {
|
|
451
450
|
if (!t) return;
|
|
452
|
-
if (e.mode === "build") return
|
|
453
|
-
let n =
|
|
454
|
-
return
|
|
451
|
+
if (e.mode === "build") return I(t.columns, { resolveVisible: e.resolveVisible });
|
|
452
|
+
let n = I(t.columns);
|
|
453
|
+
return Je(e.columns, n);
|
|
455
454
|
}, [e, t]),
|
|
456
455
|
metadata: t,
|
|
457
456
|
isLoading: n
|
|
@@ -459,16 +458,16 @@ function Je(e) {
|
|
|
459
458
|
}
|
|
460
459
|
//#endregion
|
|
461
460
|
//#region src/odata/odataFetchFnDev.ts
|
|
462
|
-
function
|
|
461
|
+
function Xe() {
|
|
463
462
|
return globalThis.console;
|
|
464
463
|
}
|
|
465
|
-
function
|
|
464
|
+
function Ze(e) {
|
|
466
465
|
let t = {};
|
|
467
466
|
return new Headers(e).forEach((e, n) => {
|
|
468
467
|
t[n] = e;
|
|
469
468
|
}), t;
|
|
470
469
|
}
|
|
471
|
-
function
|
|
470
|
+
function Qe(e) {
|
|
472
471
|
if (e != null) {
|
|
473
472
|
if (typeof e != "string") return e;
|
|
474
473
|
try {
|
|
@@ -478,7 +477,7 @@ function Ze(e) {
|
|
|
478
477
|
}
|
|
479
478
|
}
|
|
480
479
|
}
|
|
481
|
-
function
|
|
480
|
+
function X(e) {
|
|
482
481
|
return e !== void 0 && !["GET", "HEAD"].includes(e.toUpperCase());
|
|
483
482
|
}
|
|
484
483
|
function $e(e) {
|
|
@@ -492,18 +491,18 @@ function Z(e, t, n) {
|
|
|
492
491
|
et(e, t) || (e[t] = n);
|
|
493
492
|
}
|
|
494
493
|
function tt(e) {
|
|
495
|
-
let t =
|
|
496
|
-
return Z(t, "DataServiceVersion", "2.0"), Z(t, "MaxDataServiceVersion", "2.0"), Z(t, "Accept", "application/json"), t["sap-language"] = "ru", r && (t["sap-contextid-accept"] = "header"),
|
|
494
|
+
let t = Ze(e.init.headers), n = e.init.method, r = $e(e);
|
|
495
|
+
return Z(t, "DataServiceVersion", "2.0"), Z(t, "MaxDataServiceVersion", "2.0"), Z(t, "Accept", "application/json"), t["sap-language"] = "ru", r && (t["sap-contextid-accept"] = "header"), X(n) && e.init.body && Z(t, "Content-Type", "application/json"), X(n) && r && Z(t, "x-csrf-token", "<получается отдельным GET перед реальным write-запросом>"), t;
|
|
497
496
|
}
|
|
498
497
|
function nt(e) {
|
|
499
|
-
return
|
|
498
|
+
return le(e) ? "FunctionImport" : e.result ? "Parameterized Entity" : "Entity";
|
|
500
499
|
}
|
|
501
500
|
function Q(e, t) {
|
|
502
|
-
let n =
|
|
501
|
+
let n = Xe();
|
|
503
502
|
n.groupCollapsed(e), n.info(t), n.groupEnd();
|
|
504
503
|
}
|
|
505
504
|
function rt(e) {
|
|
506
|
-
let t =
|
|
505
|
+
let t = Xe(), n = Qe(e.request.init.body), r = Ze(e.request.init.headers), i = tt(e.request), a = {
|
|
507
506
|
method: e.request.init.method,
|
|
508
507
|
headers: r,
|
|
509
508
|
body: n,
|
|
@@ -522,19 +521,19 @@ function rt(e) {
|
|
|
522
521
|
} : { data: void 0 }), Q("OData config", e.odata), Q("Target metadata", e.target), Q("Target params", e.params), Q("Query options", e.queryOptions), Q("RequestInit, переданный в transport", a), Q("Заголовки после transport defaults (без реального fetch)", i), t.groupEnd();
|
|
523
522
|
}
|
|
524
523
|
function it(e) {
|
|
525
|
-
|
|
524
|
+
Oe.warning(`${e}: DEV dry-run OData запроса. Реальный запрос не выполняется, payload выведен в console.`, { title: "OData DEV helper" });
|
|
526
525
|
}
|
|
527
526
|
function $(t, n, r) {
|
|
528
527
|
let { odata: i, options: a = {}, init: o = {}, autoParse: s, swCache: c } = n, l = n.params ?? {};
|
|
529
528
|
return async ({ client: u, signal: d }) => {
|
|
530
529
|
it(r);
|
|
531
|
-
let f = e(i.service, a.baseUrl), p = await
|
|
530
|
+
let f = e(i.service, a.baseUrl), p = await oe({
|
|
532
531
|
service: i.service,
|
|
533
532
|
baseUrl: f
|
|
534
533
|
}, u);
|
|
535
534
|
if (!p) throw Error(`Не удалось загрузить metadata OData-сервиса '${i.service}'`);
|
|
536
|
-
let m =
|
|
537
|
-
|
|
535
|
+
let m = ge(p, i.target);
|
|
536
|
+
pe(m, t, i);
|
|
538
537
|
let h = ie(n.body, t), g = ae(m, t), _ = re(m, i, l, t), v = c ? {
|
|
539
538
|
...a,
|
|
540
539
|
baseUrl: f,
|
|
@@ -568,24 +567,24 @@ function $(t, n, r) {
|
|
|
568
567
|
};
|
|
569
568
|
}
|
|
570
569
|
function at(e) {
|
|
571
|
-
return __DEV__ ? $("create", e, "odataCreateFnDev") :
|
|
570
|
+
return __DEV__ ? $("create", e, "odataCreateFnDev") : T("create", e);
|
|
572
571
|
}
|
|
573
572
|
function ot(e) {
|
|
574
|
-
return __DEV__ ? $("update", e, "odataUpdateFnDev") :
|
|
573
|
+
return __DEV__ ? $("update", e, "odataUpdateFnDev") : T("update", e);
|
|
575
574
|
}
|
|
576
575
|
function st(e) {
|
|
577
|
-
return __DEV__ ? $("delete", e, "odataDeleteFnDev") :
|
|
576
|
+
return __DEV__ ? $("delete", e, "odataDeleteFnDev") : T("delete", e);
|
|
578
577
|
}
|
|
579
578
|
function ct(e) {
|
|
580
|
-
return __DEV__ ? $("read", e, "odataReadFnDev") :
|
|
579
|
+
return __DEV__ ? $("read", e, "odataReadFnDev") : T("read", e);
|
|
581
580
|
}
|
|
582
581
|
function lt(e) {
|
|
583
|
-
return __DEV__ ? $("query", e, "odataQueryFnDev") :
|
|
582
|
+
return __DEV__ ? $("query", e, "odataQueryFnDev") : T("query", e);
|
|
584
583
|
}
|
|
585
584
|
function ut(e) {
|
|
586
|
-
return __DEV__ ? $("fi", e, "odataFunctionImportFnDev") :
|
|
585
|
+
return __DEV__ ? $("fi", e, "odataFunctionImportFnDev") : T("fi", e);
|
|
587
586
|
}
|
|
588
587
|
//#endregion
|
|
589
|
-
export { h as BaseAppConfigURL, f as BaseODataDp0URL, l as BaseODataUI2URL, c as BaseODataURL, n as BaseUrlMap,
|
|
588
|
+
export { h as BaseAppConfigURL, f as BaseODataDp0URL, l as BaseODataUI2URL, c as BaseODataURL, n as BaseUrlMap, H as ODATA_COLLECTION_BUST_SW_CACHE, V as ODATA_COLLECTION_DEFAULT_SW_CACHE, B as ODATA_COLLECTION_UPDATES_LOOKBACK_MS, U as ODATA_COLLECTION_UPDATES_SW_CACHE, d as SsoRequiredError, ue as applyODataMetadataVersion, i as configureODataProjectAdapter, L as createODataCollectionBaseQueryKey, R as createODataCollectionQueryKey, W as createODataCollectionUpdatesQueryKey, v as fetchBase, p as fetchDeleteFn, g as fetchJson, u as fetchJsonMutationFn, r as fetchJsonQueryFn, se as fetchMetadata, K as fetchODataCollectionUpdates, m as fetchODataJson, _ as fetchQueryFn, Ae as flattenODataDependentServices, b as getInputUrl, oe as getODataMetadataData, S as getODataProjectAdapter, a as isNoContentResponse, y as isSsoForm, t as normalizeODataServiceName, C as normalizeRelativePath, ze as odataCollectionUpdatesQueryOptions, he as odataCreateFn, at as odataCreateFnDev, de as odataDeleteFn, st as odataDeleteFnDev, D as odataFetch, ce as odataFunctionImportFn, ut as odataFunctionImportFnDev, ee as odataMetadataQueryOptions, te as odataQueryFn, lt as odataQueryFnDev, fe as odataReadFn, ct as odataReadFnDev, me as odataUpdateFn, ot as odataUpdateFnDev, o as recoverSsoSession, e as resolveODataBaseUrl, He as resolveODataCollectionSwCachePolicy, x as resolveODataSapClient, Ue as shouldRefreshODataCollectionCache, je as sortODataDependentSegmentItemsByChains, Ne as sortODataDependentServicesByChains, s as submitSsoForm, Ge as useODataCollection, Ke as useODataCollectionChains, qe as useODataCollectionModel, We as useODataCollectionQuery, Be as useODataCollectionUpdatesQuery, Ve as useODataEntity, q as useODataMetadata, E as useODataMetadataQuery, _e as useODataMetadataVersionQuery, Ye as useODataTableColumns };
|
|
590
589
|
|
|
591
590
|
//# sourceMappingURL=index.js.map
|