@ryuzaki13/react-foundation-lib 2.30.1 → 2.31.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/README.md +3 -2
- package/dist/analytical-table/index.js +8 -7
- package/dist/analytical-table/index.js.map +1 -1
- package/dist/chunks/formatDate-BUvpRI7H.js +133 -0
- package/dist/chunks/formatDate-BUvpRI7H.js.map +1 -0
- package/dist/chunks/{formatters-CZnnbdud.js → formatters-rxriDRPk.js} +14 -13
- package/dist/chunks/{formatters-CZnnbdud.js.map → formatters-rxriDRPk.js.map} +1 -1
- package/dist/chunks/scalarTypeClassification-BZcFmIyR.js +764 -0
- package/dist/chunks/scalarTypeClassification-BZcFmIyR.js.map +1 -0
- package/dist/chunks/{validate-CEQHqevt.js → validate-DsUR-bFF.js} +2 -2
- package/dist/chunks/{validate-CEQHqevt.js.map → validate-DsUR-bFF.js.map} +1 -1
- package/dist/error-report/index.js +2 -2
- package/dist/excel/index.js +20 -20
- package/dist/excel/index.js.map +1 -1
- package/dist/excel/tableExport.d.ts +2 -2
- package/dist/excel/tableExport.d.ts.map +1 -1
- package/dist/formatters/index.js +5 -4
- package/dist/formatters/pipeline/types.d.ts +4 -4
- package/dist/formatters/pipeline/types.d.ts.map +1 -1
- package/dist/hooks/useFloatingListbox.d.ts +1 -1
- package/dist/metadata/baseMetaTypes.d.ts +7 -0
- package/dist/metadata/baseMetaTypes.d.ts.map +1 -0
- package/dist/metadata/metadataTypes.d.ts +16 -0
- package/dist/metadata/metadataTypes.d.ts.map +1 -0
- package/dist/metadata/scalarTypeClassification.d.ts +8 -0
- package/dist/metadata/scalarTypeClassification.d.ts.map +1 -0
- package/dist/odata-service/baseTypes.d.ts +1 -5
- package/dist/odata-service/baseTypes.d.ts.map +1 -1
- package/dist/odata-service/formatters.d.ts +1 -2
- package/dist/odata-service/formatters.d.ts.map +1 -1
- package/dist/odata-service/index.js +1311 -2
- package/dist/odata-service/index.js.map +1 -0
- package/dist/odata-service/types.d.ts +8 -11
- package/dist/odata-service/types.d.ts.map +1 -1
- package/dist/odata-service/typesValidation.d.ts +1 -5
- package/dist/odata-service/typesValidation.d.ts.map +1 -1
- package/dist/promise/createDeferredPromise.d.ts +8 -0
- package/dist/promise/createDeferredPromise.d.ts.map +1 -0
- package/dist/promise/deferredPromiseTypes.d.ts +7 -0
- package/dist/promise/deferredPromiseTypes.d.ts.map +1 -0
- package/dist/promise/index.d.ts +3 -0
- package/dist/promise/index.d.ts.map +1 -0
- package/dist/promise/index.js +16 -0
- package/dist/promise/index.js.map +1 -0
- package/package.json +5 -1
- package/src/formatters/README.mdx +5 -0
- package/src/foundationLib.mdx +8 -0
- package/src/metadata/README.md +35 -0
- package/src/odata-service/README.mdx +36 -1
- package/src/promise/README.md +44 -0
- package/dist/chunks/odata-service-tp2U5yIr.js +0 -2211
- package/dist/chunks/odata-service-tp2U5yIr.js.map +0 -1
|
@@ -1,2 +1,1311 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { n as e } from "../chunks/isRecord-DXDTW-jA.js";
|
|
2
|
+
import { O as t, b as n, n as r, x as i } from "../chunks/formatDate-BUvpRI7H.js";
|
|
3
|
+
import { A as a, a as o, i as s, n as c, o as l, r as u, t as d } from "../chunks/scalarTypeClassification-BZcFmIyR.js";
|
|
4
|
+
import { t as f } from "../chunks/string-comparison-BKT7PXmq.js";
|
|
5
|
+
import { z as p } from "zod";
|
|
6
|
+
import { create as ee } from "zustand";
|
|
7
|
+
import { immer as te } from "zustand/middleware/immer";
|
|
8
|
+
//#region src/metadata/baseMetaTypes.ts
|
|
9
|
+
var ne = Object.freeze([
|
|
10
|
+
"string",
|
|
11
|
+
"number",
|
|
12
|
+
"boolean",
|
|
13
|
+
"date"
|
|
14
|
+
]), re = new Set(ne), ie = Object.freeze({
|
|
15
|
+
string: "строка",
|
|
16
|
+
number: "число",
|
|
17
|
+
boolean: "boolean",
|
|
18
|
+
date: "дата"
|
|
19
|
+
});
|
|
20
|
+
function ae(e) {
|
|
21
|
+
return typeof e == "string" && re.has(e);
|
|
22
|
+
}
|
|
23
|
+
function oe(e) {
|
|
24
|
+
return ie[e];
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/odata-service/buildSeparatedArrays.ts
|
|
28
|
+
function se(e) {
|
|
29
|
+
let t = {};
|
|
30
|
+
return e.forEach((e) => {
|
|
31
|
+
t[e.codeKey] = [];
|
|
32
|
+
}), t;
|
|
33
|
+
}
|
|
34
|
+
function ce(e, t, n = !0, r = !0) {
|
|
35
|
+
if (!e || e.length === 0) return se(t);
|
|
36
|
+
let i = /* @__PURE__ */ new Set(), a = e[0];
|
|
37
|
+
a && Object.keys(a).forEach((e) => {
|
|
38
|
+
i.add(e);
|
|
39
|
+
});
|
|
40
|
+
let o = t.filter((e) => i.has(e.codeKey) && i.has(e.textKey));
|
|
41
|
+
if (o.length === 0) return se(t);
|
|
42
|
+
let s = {}, c = /* @__PURE__ */ new Map();
|
|
43
|
+
for (let e of o) {
|
|
44
|
+
let t = e.codeKey;
|
|
45
|
+
c.set(t, {
|
|
46
|
+
codeKey: e.codeKey,
|
|
47
|
+
textKey: e.textKey,
|
|
48
|
+
uniqueSet: /* @__PURE__ */ new Set()
|
|
49
|
+
}), s[t] = [];
|
|
50
|
+
}
|
|
51
|
+
t.forEach((e) => {
|
|
52
|
+
let t = e.codeKey;
|
|
53
|
+
c.has(t) || (s[t] = []);
|
|
54
|
+
});
|
|
55
|
+
for (let t of e) for (let [e, r] of c) {
|
|
56
|
+
let { codeKey: i, textKey: a, uniqueSet: o } = r, c = String(t[i]), l = String(t[a]);
|
|
57
|
+
if (n && !l || c == null) continue;
|
|
58
|
+
let u = `${String(c)}|${String(l)}`;
|
|
59
|
+
o.has(u) || (o.add(u), s[e].push({
|
|
60
|
+
[i]: c,
|
|
61
|
+
[a]: l
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
for (let [e, t] of c) {
|
|
65
|
+
let n = s[e];
|
|
66
|
+
if (n.length > 0) {
|
|
67
|
+
let e = r ? t.codeKey : t.textKey;
|
|
68
|
+
n.sort((t, n) => {
|
|
69
|
+
let r = t[e] || "", i = n[e] || "";
|
|
70
|
+
return f(String(r), String(i));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return s;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/odata-service/dateUtils.ts
|
|
78
|
+
var m = {
|
|
79
|
+
datetime(e) {
|
|
80
|
+
return `datetime'${n(e)}'`;
|
|
81
|
+
},
|
|
82
|
+
datetimeOffset(e) {
|
|
83
|
+
return `datetimeoffset'${e.toISOString()}'`;
|
|
84
|
+
},
|
|
85
|
+
time(e) {
|
|
86
|
+
return `time'${i(e)}'`;
|
|
87
|
+
}
|
|
88
|
+
}, h = {
|
|
89
|
+
string: p.string(),
|
|
90
|
+
guid: p.uuid().or(p.string().regex(/^[0-9a-fA-F-]+$/, "Invalid GUID")),
|
|
91
|
+
boolean: p.boolean(),
|
|
92
|
+
int: p.number().int(),
|
|
93
|
+
long: p.number().int(),
|
|
94
|
+
float: p.number(),
|
|
95
|
+
decimal: p.number(),
|
|
96
|
+
double: p.number(),
|
|
97
|
+
datetime: p.date(),
|
|
98
|
+
datetimeOffset: p.date(),
|
|
99
|
+
time: p.date(),
|
|
100
|
+
binary: p.string(),
|
|
101
|
+
byte: p.number().int().min(0).max(255)
|
|
102
|
+
};
|
|
103
|
+
function g(e, t) {
|
|
104
|
+
return t.safeParse(e).success;
|
|
105
|
+
}
|
|
106
|
+
function le(e) {
|
|
107
|
+
return g(e, h.string);
|
|
108
|
+
}
|
|
109
|
+
function ue(e) {
|
|
110
|
+
return g(e, h.float);
|
|
111
|
+
}
|
|
112
|
+
function de(e) {
|
|
113
|
+
return g(e, h.boolean);
|
|
114
|
+
}
|
|
115
|
+
function fe(e) {
|
|
116
|
+
return g(e, h.datetime);
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/odata-service/formatters.ts
|
|
120
|
+
function _(e, t) {
|
|
121
|
+
switch (e) {
|
|
122
|
+
case "string": return `'${String(t).replace(/'/g, "''")}'`;
|
|
123
|
+
case "guid": return `guid'${String(t)}'`;
|
|
124
|
+
case "boolean": return t ? "'X'" : "' '";
|
|
125
|
+
case "long": return `${String(t)}L`;
|
|
126
|
+
case "float": return `${String(t)}F`;
|
|
127
|
+
case "decimal": return `${String(t)}M`;
|
|
128
|
+
case "double": return `${String(t)}D`;
|
|
129
|
+
case "datetime":
|
|
130
|
+
case "datetimeOffset":
|
|
131
|
+
case "time":
|
|
132
|
+
if (!(t instanceof Date)) throw Error(`Неверная дата для типа '${e}': ${t}`);
|
|
133
|
+
return m[e](t);
|
|
134
|
+
case "binary": return `binary'${t}'`;
|
|
135
|
+
case "byte":
|
|
136
|
+
case "int": return `${String(t)}`;
|
|
137
|
+
default: throw Error(`Неподдерживаемый тип: ${e}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function v(e, t) {
|
|
141
|
+
let n = h[e].safeParse(t);
|
|
142
|
+
if (!n.success) throw Error(`Некорректное значение для типа '${e}': ${n.error.issues[0]?.message ?? t}`);
|
|
143
|
+
return _(e, n.data);
|
|
144
|
+
}
|
|
145
|
+
function pe(e) {
|
|
146
|
+
if (typeof e == "boolean") return e;
|
|
147
|
+
if (typeof e == "number") return e === 1 || e !== 0 && void 0;
|
|
148
|
+
if (typeof e != "string") return;
|
|
149
|
+
if (e === "X") return !0;
|
|
150
|
+
if (e === " " || e === "") return !1;
|
|
151
|
+
let t = e.trim().toLowerCase();
|
|
152
|
+
if (t === "true" || t === "1") return !0;
|
|
153
|
+
if (t === "false" || t === "0") return !1;
|
|
154
|
+
}
|
|
155
|
+
function me(e) {
|
|
156
|
+
if (e == null) return !1;
|
|
157
|
+
if (typeof e == "string" && (e === "X" || e === " " || e === "")) return t(e);
|
|
158
|
+
}
|
|
159
|
+
function he(e, t) {
|
|
160
|
+
switch (e) {
|
|
161
|
+
case "boolean": return pe(t) ?? t;
|
|
162
|
+
case "int":
|
|
163
|
+
case "long":
|
|
164
|
+
case "float":
|
|
165
|
+
case "decimal":
|
|
166
|
+
case "double":
|
|
167
|
+
case "byte": return a(t);
|
|
168
|
+
case "datetime":
|
|
169
|
+
case "datetimeOffset":
|
|
170
|
+
case "time": return l(t);
|
|
171
|
+
default: return String(t);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function ge(e, t) {
|
|
175
|
+
if (e.abapBooleanLike) {
|
|
176
|
+
let e = me(t);
|
|
177
|
+
if (e !== void 0) return e;
|
|
178
|
+
}
|
|
179
|
+
return he(e.type, t);
|
|
180
|
+
}
|
|
181
|
+
function _e(e) {
|
|
182
|
+
switch (e) {
|
|
183
|
+
case "boolean": return !1;
|
|
184
|
+
case "int":
|
|
185
|
+
case "long":
|
|
186
|
+
case "float":
|
|
187
|
+
case "decimal":
|
|
188
|
+
case "double":
|
|
189
|
+
case "byte": return 0;
|
|
190
|
+
case "datetime":
|
|
191
|
+
case "datetimeOffset":
|
|
192
|
+
case "time": return /* @__PURE__ */ new Date();
|
|
193
|
+
default: return "";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function ve(e) {
|
|
197
|
+
switch (e) {
|
|
198
|
+
case "boolean": return !1;
|
|
199
|
+
case "number": return 0;
|
|
200
|
+
case "date": return /* @__PURE__ */ new Date();
|
|
201
|
+
default: return "";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function y(e, t) {
|
|
205
|
+
return (...n) => {
|
|
206
|
+
let r = e.safeParse(n);
|
|
207
|
+
if (!r.success) throw Error(`Validation failed: ${r.error.message}`);
|
|
208
|
+
return t(...r.data);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function b(e) {
|
|
212
|
+
return y(p.array(p.boolean()), e);
|
|
213
|
+
}
|
|
214
|
+
function x(e) {
|
|
215
|
+
return y(p.array(p.string()), e);
|
|
216
|
+
}
|
|
217
|
+
function ye(e) {
|
|
218
|
+
return y(p.array(p.number()), e);
|
|
219
|
+
}
|
|
220
|
+
function S(e) {
|
|
221
|
+
return y(p.array(p.date()), e);
|
|
222
|
+
}
|
|
223
|
+
var be = S(m.datetime), xe = S(m.datetimeOffset), Se = S(m.time), Ce = S((e) => _("string", r(e))), we = b((e) => _("boolean", e)), Te = b((e) => _("string", Number(e))), Ee = b((e) => _("byte", Number(e))), De = x((e) => _("string", e)), C = {
|
|
224
|
+
date: {
|
|
225
|
+
base: {
|
|
226
|
+
label: "Базовый datetime",
|
|
227
|
+
description: "Используется для параметров OData с типом данных datetime",
|
|
228
|
+
fn: be
|
|
229
|
+
},
|
|
230
|
+
datetimeOffset: {
|
|
231
|
+
label: "Базовый datetimeoffset",
|
|
232
|
+
description: "Используется для параметров OData с типом данных datetimeoffset",
|
|
233
|
+
fn: xe
|
|
234
|
+
},
|
|
235
|
+
time: {
|
|
236
|
+
label: "Базовый time",
|
|
237
|
+
description: "Используется для параметров OData с типом данных time",
|
|
238
|
+
fn: Se
|
|
239
|
+
},
|
|
240
|
+
stringAbapDate: {
|
|
241
|
+
label: "Дата ABAP YYYYMMDD",
|
|
242
|
+
description: "Используется для параметров OData с типом данных string(8)",
|
|
243
|
+
fn: Ce
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
boolean: {
|
|
247
|
+
base: {
|
|
248
|
+
label: "Базовое ABAP булево",
|
|
249
|
+
description: "Стандартный формат abap_bool со значением 'X' для true и '' для false",
|
|
250
|
+
fn: we
|
|
251
|
+
},
|
|
252
|
+
asChar: {
|
|
253
|
+
label: "Как символ",
|
|
254
|
+
description: "Преобразование булево в символы '0' или '1'",
|
|
255
|
+
fn: Te
|
|
256
|
+
},
|
|
257
|
+
asByte: {
|
|
258
|
+
label: "Как цифра",
|
|
259
|
+
description: "Преобразование булево в цифру 0 или 1",
|
|
260
|
+
fn: Ee
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
string: { base: {
|
|
264
|
+
label: "Базовая строка",
|
|
265
|
+
description: "",
|
|
266
|
+
fn: De
|
|
267
|
+
} }
|
|
268
|
+
};
|
|
269
|
+
function Oe(e) {
|
|
270
|
+
let t = C[d(e)];
|
|
271
|
+
return t ? Object.entries(t).map(([e, t]) => ({
|
|
272
|
+
id: e,
|
|
273
|
+
...t
|
|
274
|
+
})) : [];
|
|
275
|
+
}
|
|
276
|
+
function ke(e) {
|
|
277
|
+
let t = C[e];
|
|
278
|
+
return t ? Object.entries(t).map(([e, t]) => ({
|
|
279
|
+
id: e,
|
|
280
|
+
...t
|
|
281
|
+
})) : [];
|
|
282
|
+
}
|
|
283
|
+
function Ae(e, t) {
|
|
284
|
+
return C[d(e)]?.[t];
|
|
285
|
+
}
|
|
286
|
+
function je(e, t) {
|
|
287
|
+
return C[e]?.[t];
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/odata-service/builder.ts
|
|
291
|
+
function Me(e, t) {
|
|
292
|
+
if (!t || typeof t != "number") return;
|
|
293
|
+
let n = e.match(/^'(.*)'$/s);
|
|
294
|
+
if (!n) throw Error(`Значение должно быть заключено в одинарные кавычки: ${e}`);
|
|
295
|
+
let r = n[1];
|
|
296
|
+
if (r.length > t) throw Error(`Значение слишком длинное для maxLength=${t}: '${e}' (${r.length} символов внутри кавычек)`);
|
|
297
|
+
}
|
|
298
|
+
function w(e, t) {
|
|
299
|
+
return e.parameters ? e.parameters.map((e) => {
|
|
300
|
+
let { id: n, type: r, maxLength: i, mandatory: a } = e, o = t[n] ?? {}, s = o.value, c = o.formatter;
|
|
301
|
+
if (a && s == null) throw Error(`Отсутствует обязательный параметр: ${n}`);
|
|
302
|
+
if (s == null) return null;
|
|
303
|
+
try {
|
|
304
|
+
if (Array.isArray(s) && !c) throw Error("Массив значений OData-параметра требует custom formatter");
|
|
305
|
+
let e = c ? c(s) : v(r, s);
|
|
306
|
+
return Me(e, i), [n, e];
|
|
307
|
+
} catch (e) {
|
|
308
|
+
throw Error(`Ошибка форматирования параметра ${n}: ${String(e)}`);
|
|
309
|
+
}
|
|
310
|
+
}).filter((e) => e !== null) : [];
|
|
311
|
+
}
|
|
312
|
+
function T(e, t) {
|
|
313
|
+
let n = w(e, t);
|
|
314
|
+
return n.length ? `(${n.map(([e, t]) => `${e}=${encodeURIComponent(t)}`).join(",")})` : "";
|
|
315
|
+
}
|
|
316
|
+
function Ne(e, t) {
|
|
317
|
+
let n = new URLSearchParams();
|
|
318
|
+
for (let [r, i] of w(e, t)) n.set(r, i);
|
|
319
|
+
return n;
|
|
320
|
+
}
|
|
321
|
+
function Pe(e, t, n, r) {
|
|
322
|
+
let i = `/${t.service}/${t.target}`;
|
|
323
|
+
return r === "create" ? i : r === "query" ? e.result ? Ie(e, t, n) : (__DEV__ && Object.keys(n).length > 0 && console.warn(`Параметры для query-запроса '/${t.service}/${t.target}' проигнорированы: target не поддерживает parameterized query.`), i) : `${i}${T(e, n)}`;
|
|
324
|
+
}
|
|
325
|
+
function Fe(e, t, n) {
|
|
326
|
+
let r = Ne(e, n).toString(), i = `/${t.service}/${t.target}`;
|
|
327
|
+
return r ? `${i}?${r}` : i;
|
|
328
|
+
}
|
|
329
|
+
function Ie(e, t, n) {
|
|
330
|
+
let r = T(e, n), i = e.result ? `/${e.result}` : "";
|
|
331
|
+
return `/${t.service}/${t.target}${r}${i}`;
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/odata-service/columns.ts
|
|
335
|
+
function E(e) {
|
|
336
|
+
return e.filter((e) => e.semanticType === "code" && e.filterable);
|
|
337
|
+
}
|
|
338
|
+
function Le(e) {
|
|
339
|
+
return new Set(E(e).map((e) => e.id));
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/odata-service/filters.ts
|
|
343
|
+
var Re = Object.freeze({
|
|
344
|
+
eq: "eq",
|
|
345
|
+
ne: "ne",
|
|
346
|
+
gt: "gt",
|
|
347
|
+
ge: "ge",
|
|
348
|
+
lt: "lt",
|
|
349
|
+
le: "le",
|
|
350
|
+
startswith: "startswith",
|
|
351
|
+
endswith: "endswith",
|
|
352
|
+
contains: "contains"
|
|
353
|
+
}), ze = Object.freeze(Object.values(Re)), Be = Object.freeze({
|
|
354
|
+
eq: "равно",
|
|
355
|
+
ne: "не равно",
|
|
356
|
+
gt: "больше",
|
|
357
|
+
ge: "больше или равно",
|
|
358
|
+
lt: "меньше",
|
|
359
|
+
le: "меньше или равно",
|
|
360
|
+
startswith: "начинается с",
|
|
361
|
+
endswith: "заканчивается на",
|
|
362
|
+
contains: "содержит"
|
|
363
|
+
}), Ve = new Set(ze);
|
|
364
|
+
function He(e) {
|
|
365
|
+
return typeof e == "string" && Ve.has(e);
|
|
366
|
+
}
|
|
367
|
+
function Ue(e) {
|
|
368
|
+
return Be[e];
|
|
369
|
+
}
|
|
370
|
+
function We(e) {
|
|
371
|
+
switch (typeof e) {
|
|
372
|
+
case "bigint":
|
|
373
|
+
case "number": return "int";
|
|
374
|
+
case "boolean": return "boolean";
|
|
375
|
+
case "object": if (e instanceof Date) return "datetime";
|
|
376
|
+
}
|
|
377
|
+
return "string";
|
|
378
|
+
}
|
|
379
|
+
function D(e) {
|
|
380
|
+
let { key: t, operation: n = "eq", value: r, type: i } = e, a = v(i ?? We(r), r);
|
|
381
|
+
return n === "contains" ? `substringof(${a},${String(t)})` : n === "startswith" || n === "endswith" ? `${n}(${String(t)}, ${a})` : `${String(t)} ${n} ${a}`;
|
|
382
|
+
}
|
|
383
|
+
function Ge(e) {
|
|
384
|
+
return "conditions" in e && e.conditions !== void 0;
|
|
385
|
+
}
|
|
386
|
+
function Ke(e) {
|
|
387
|
+
return "filters" in e && e.filters !== void 0;
|
|
388
|
+
}
|
|
389
|
+
function qe(e, t) {
|
|
390
|
+
let n = [];
|
|
391
|
+
for (let r of e) {
|
|
392
|
+
let e = t(r);
|
|
393
|
+
e && n.push(e);
|
|
394
|
+
}
|
|
395
|
+
return n;
|
|
396
|
+
}
|
|
397
|
+
function O(e) {
|
|
398
|
+
if (!e) return "";
|
|
399
|
+
if (Ge(e)) {
|
|
400
|
+
let { conditions: t, and: n = !1 } = e;
|
|
401
|
+
if (t.length === 0) return "";
|
|
402
|
+
if (t.length === 1) return D(t[0]);
|
|
403
|
+
let r = n ? "and" : "or";
|
|
404
|
+
return `(${t.map(D).join(` ${r} `)})`;
|
|
405
|
+
}
|
|
406
|
+
if (Ke(e)) {
|
|
407
|
+
let { filters: t, and: n = !1 } = e;
|
|
408
|
+
if (t.length === 0) return "";
|
|
409
|
+
if (t.length === 1) return O(t[0]);
|
|
410
|
+
let r = n ? "and" : "or", i = qe(t, O);
|
|
411
|
+
return i.length === 0 ? "" : i.length === 1 ? i[0] : `(${i.join(` ${r} `)})`;
|
|
412
|
+
}
|
|
413
|
+
throw Error("Некорректное выражение фильтра");
|
|
414
|
+
}
|
|
415
|
+
function Je(e) {
|
|
416
|
+
let t = (e) => {
|
|
417
|
+
if (!e) return "";
|
|
418
|
+
if (Ge(e)) {
|
|
419
|
+
let { conditions: t, and: n = !1 } = e;
|
|
420
|
+
if (t.length === 0) return "";
|
|
421
|
+
if (t.length === 1) return D(t[0]);
|
|
422
|
+
let r = n ? "and" : "or";
|
|
423
|
+
return `(${t.map(D).join(` ${r} `)})`;
|
|
424
|
+
}
|
|
425
|
+
if (Ke(e)) {
|
|
426
|
+
let { filters: n, and: r = !1 } = e;
|
|
427
|
+
if (n.length === 0) return "";
|
|
428
|
+
if (n.length === 1) return t(n[0]);
|
|
429
|
+
let i = r ? "and" : "or", a = qe(n, t).map((e) => e.includes(" ") ? `(${e})` : e);
|
|
430
|
+
return a.length === 0 ? "" : a.length === 1 ? a[0] : `(${a.join(` ${i} `)})`;
|
|
431
|
+
}
|
|
432
|
+
return "";
|
|
433
|
+
};
|
|
434
|
+
return t(e);
|
|
435
|
+
}
|
|
436
|
+
function k(e, t, n) {
|
|
437
|
+
if (t == null) return { conditions: [] };
|
|
438
|
+
if (Array.isArray(t)) {
|
|
439
|
+
let r = [];
|
|
440
|
+
for (let i of t) i != null && r.push({
|
|
441
|
+
key: e,
|
|
442
|
+
value: i,
|
|
443
|
+
operation: n
|
|
444
|
+
});
|
|
445
|
+
return { conditions: r };
|
|
446
|
+
}
|
|
447
|
+
return { conditions: [{
|
|
448
|
+
key: e,
|
|
449
|
+
value: t,
|
|
450
|
+
operation: n
|
|
451
|
+
}] };
|
|
452
|
+
}
|
|
453
|
+
function Ye(e, t) {
|
|
454
|
+
if (!t) return { conditions: [] };
|
|
455
|
+
let n = t[0], r = t[1];
|
|
456
|
+
return n == null || r == null ? n ? { conditions: [{
|
|
457
|
+
key: e,
|
|
458
|
+
value: n,
|
|
459
|
+
operation: "ge"
|
|
460
|
+
}] } : r ? { conditions: [{
|
|
461
|
+
key: e,
|
|
462
|
+
value: r,
|
|
463
|
+
operation: "le"
|
|
464
|
+
}] } : { conditions: [] } : {
|
|
465
|
+
and: !0,
|
|
466
|
+
conditions: [{
|
|
467
|
+
key: e,
|
|
468
|
+
value: n,
|
|
469
|
+
operation: "ge"
|
|
470
|
+
}, {
|
|
471
|
+
key: e,
|
|
472
|
+
value: r,
|
|
473
|
+
operation: "le"
|
|
474
|
+
}]
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function A(e, t) {
|
|
478
|
+
return k(e, t, "eq");
|
|
479
|
+
}
|
|
480
|
+
function Xe(e, t) {
|
|
481
|
+
return k(e, Array.isArray(t) ? t.map((e) => e || null) : t || null, "eq");
|
|
482
|
+
}
|
|
483
|
+
function Ze(e, t) {
|
|
484
|
+
return k(e, t, "contains");
|
|
485
|
+
}
|
|
486
|
+
function Qe(e, t) {
|
|
487
|
+
return e ? t ? {
|
|
488
|
+
and: !0,
|
|
489
|
+
filters: [e, t]
|
|
490
|
+
} : e : t;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/odata-service/filterDefinitions.ts
|
|
494
|
+
function $e(e) {
|
|
495
|
+
return e === "select" || e === "multi-select" || e === "checkbox" || e === "text-input" || e === "number-input";
|
|
496
|
+
}
|
|
497
|
+
function j(e, t) {
|
|
498
|
+
return e?.conditions.length ? e.conditions.map((e) => e.columnId?.trim() || t).filter((e) => !!e) : [];
|
|
499
|
+
}
|
|
500
|
+
function et(e, t) {
|
|
501
|
+
let n = e.kind === "list" ? e.options.flatMap((e) => j(e.filter, t)) : e.kind === "boolean" ? j(e.trueFilter, t) : j(e.valueFilter, t);
|
|
502
|
+
return [...new Set(n.length ? n : t ? [t] : [])];
|
|
503
|
+
}
|
|
504
|
+
function M(e, t) {
|
|
505
|
+
let n = j(e, t);
|
|
506
|
+
return n.length ? n : t ? [t] : [];
|
|
507
|
+
}
|
|
508
|
+
function tt(e) {
|
|
509
|
+
return e.kind === "registered" ? e.valueMode === "multiple" : e.componentId === "multi-select";
|
|
510
|
+
}
|
|
511
|
+
function nt(e) {
|
|
512
|
+
return Array.isArray(e) ? [...new Set(e.filter((e) => typeof e == "string").map((e) => e.trim()))] : [];
|
|
513
|
+
}
|
|
514
|
+
function N(e, t) {
|
|
515
|
+
if (tt(e)) return nt(t);
|
|
516
|
+
let n = P(t);
|
|
517
|
+
return typeof n == "string" ? [n] : [];
|
|
518
|
+
}
|
|
519
|
+
function rt(e) {
|
|
520
|
+
let t = B([e])[0];
|
|
521
|
+
return t ? t.kind === "registered" ? [...t.columnIds] : t.kind === "segment" || t.kind === "column" || t.kind === "advanced" ? [t.ownerColumnId] : [...t.columnIds] : [];
|
|
522
|
+
}
|
|
523
|
+
function it(e, t) {
|
|
524
|
+
let n = B([e])[0], r = V(t);
|
|
525
|
+
if (!n || r === void 0) return [];
|
|
526
|
+
switch (n.kind) {
|
|
527
|
+
case "segment":
|
|
528
|
+
case "column":
|
|
529
|
+
case "advanced": return [n.ownerColumnId];
|
|
530
|
+
case "tree": {
|
|
531
|
+
let e = L(r);
|
|
532
|
+
return e ? Object.keys(e).filter((e) => n.columnIds.includes(e)) : [];
|
|
533
|
+
}
|
|
534
|
+
case "local":
|
|
535
|
+
if (n.binding.kind === "list") {
|
|
536
|
+
let e = N(n, r);
|
|
537
|
+
return [...new Set(e.flatMap((e) => {
|
|
538
|
+
let t = n.binding.kind === "list" ? n.binding.options.find((t) => t.key === e) : void 0;
|
|
539
|
+
return t ? M(t.filter, n.ownerColumnId) : [];
|
|
540
|
+
}))];
|
|
541
|
+
}
|
|
542
|
+
return n.binding.kind === "boolean" ? r === !0 ? M(n.binding.trueFilter, n.ownerColumnId) : [] : M(n.binding.valueFilter, n.ownerColumnId);
|
|
543
|
+
case "registered": {
|
|
544
|
+
let e = n.binding;
|
|
545
|
+
if (!e) return [];
|
|
546
|
+
if (e.kind === "list") {
|
|
547
|
+
let t = N(n, r);
|
|
548
|
+
return [...new Set(t.flatMap((t) => {
|
|
549
|
+
let n = e.options.find((e) => e.key === t);
|
|
550
|
+
return n ? M(n.filter, "") : [];
|
|
551
|
+
}))];
|
|
552
|
+
}
|
|
553
|
+
return e.kind === "boolean" ? r === !0 ? M(e.trueFilter, "") : [] : M(e.valueFilter, "");
|
|
554
|
+
}
|
|
555
|
+
default: return [];
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function at(e, t) {
|
|
559
|
+
let n = e?.trim();
|
|
560
|
+
return n && n !== t ? n : void 0;
|
|
561
|
+
}
|
|
562
|
+
function P(e) {
|
|
563
|
+
if (e instanceof Date) return Number.isFinite(e.getTime()) ? e : void 0;
|
|
564
|
+
if (typeof e == "string") return e.trim();
|
|
565
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
|
|
566
|
+
if (typeof e == "boolean") return e;
|
|
567
|
+
}
|
|
568
|
+
function F(e) {
|
|
569
|
+
return e instanceof Date ? `date:${e.toISOString()}` : `${typeof e}:${String(e)}`;
|
|
570
|
+
}
|
|
571
|
+
function I(e) {
|
|
572
|
+
if (!Array.isArray(e)) return;
|
|
573
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
574
|
+
for (let r of e) {
|
|
575
|
+
let e = P(r);
|
|
576
|
+
if (e === void 0) continue;
|
|
577
|
+
let i = F(e);
|
|
578
|
+
t.has(i) || (t.add(i), n.push(e));
|
|
579
|
+
}
|
|
580
|
+
return n.sort((e, t) => f(F(e), F(t))), n.length ? n : void 0;
|
|
581
|
+
}
|
|
582
|
+
function ot(e) {
|
|
583
|
+
if (!Array.isArray(e)) return;
|
|
584
|
+
let t = [...new Set(e.filter((e) => typeof e == "string").map((e) => e.trim()).filter(Boolean))];
|
|
585
|
+
return t.length ? t : void 0;
|
|
586
|
+
}
|
|
587
|
+
function L(e) {
|
|
588
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e instanceof Date) return;
|
|
589
|
+
let t = Object.fromEntries(Object.entries(e).map(([e, t]) => [e.trim(), ot(t)]).filter((e) => !!e[0] && !!e[1]?.length));
|
|
590
|
+
return Object.keys(t).length ? t : void 0;
|
|
591
|
+
}
|
|
592
|
+
function R(e) {
|
|
593
|
+
if (!e?.conditions?.length) return;
|
|
594
|
+
let t = [];
|
|
595
|
+
for (let n of e.conditions) {
|
|
596
|
+
let e = P(n.value);
|
|
597
|
+
(n.valueSource !== "static" || e !== void 0) && t.push({
|
|
598
|
+
columnId: n.columnId?.trim() || void 0,
|
|
599
|
+
operation: n.operation,
|
|
600
|
+
valueSource: n.valueSource,
|
|
601
|
+
value: e
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
if (t.length) return {
|
|
605
|
+
and: e.and === !1 ? !1 : e.and ? !0 : void 0,
|
|
606
|
+
conditions: t
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function z(e) {
|
|
610
|
+
if (e) {
|
|
611
|
+
if (e.kind === "list") {
|
|
612
|
+
let t = [];
|
|
613
|
+
for (let n of e.options ?? []) {
|
|
614
|
+
let e = n.key.trim();
|
|
615
|
+
t.push({
|
|
616
|
+
key: e,
|
|
617
|
+
label: n.label.trim() || e,
|
|
618
|
+
filter: R(n.filter)
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
if (!t.length) return;
|
|
622
|
+
let n = e.and === !0 || e.and !== !1 && void 0;
|
|
623
|
+
return {
|
|
624
|
+
kind: "list",
|
|
625
|
+
...n === void 0 ? {} : { and: n },
|
|
626
|
+
options: t
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
return e.kind === "boolean" ? {
|
|
630
|
+
kind: "boolean",
|
|
631
|
+
trueFilter: R(e.trueFilter)
|
|
632
|
+
} : {
|
|
633
|
+
kind: "value",
|
|
634
|
+
valueFilter: R(e.valueFilter)
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
function B(e) {
|
|
639
|
+
if (!e?.length) return [];
|
|
640
|
+
let t = [];
|
|
641
|
+
for (let n of e) {
|
|
642
|
+
let e = n.id.trim();
|
|
643
|
+
if (!e) continue;
|
|
644
|
+
let r = { ...n };
|
|
645
|
+
if (r.kind === "odata-segment" && (r.kind = "segment"), r.kind === "odata-tree" && (r.kind = "tree"), r.kind === "registered") {
|
|
646
|
+
let n = r.componentId.trim(), i = r.valueMode;
|
|
647
|
+
if (!n || i !== "single" && i !== "multiple") continue;
|
|
648
|
+
let a = z(r.binding);
|
|
649
|
+
t.push({
|
|
650
|
+
...r,
|
|
651
|
+
id: e,
|
|
652
|
+
componentId: n,
|
|
653
|
+
valueMode: i,
|
|
654
|
+
columnIds: a ? et(a, "") : [],
|
|
655
|
+
binding: a
|
|
656
|
+
});
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
let i = r.ownerColumnId.trim();
|
|
660
|
+
if (i) switch (r.kind) {
|
|
661
|
+
case "segment":
|
|
662
|
+
t.push({
|
|
663
|
+
...r,
|
|
664
|
+
id: e,
|
|
665
|
+
ownerColumnId: i,
|
|
666
|
+
columnIds: [i],
|
|
667
|
+
componentId: r.componentId === "select" ? "select" : "multi-select",
|
|
668
|
+
dictionaryCodeKey: at(r.dictionaryCodeKey, i)
|
|
669
|
+
});
|
|
670
|
+
break;
|
|
671
|
+
case "tree": {
|
|
672
|
+
let n = [...new Set(r.columnIds.map((e) => e.trim()).filter(Boolean))];
|
|
673
|
+
if (!n.length) break;
|
|
674
|
+
let a = r.componentId, o = a === "treeSelect" || a === "tree-select" ? "tree-select" : "tree-multi-select";
|
|
675
|
+
t.push({
|
|
676
|
+
...r,
|
|
677
|
+
id: e,
|
|
678
|
+
ownerColumnId: n.includes(i) ? i : n[0],
|
|
679
|
+
columnIds: n,
|
|
680
|
+
componentId: o,
|
|
681
|
+
levelOperator: r.levelOperator === "or" ? "or" : void 0
|
|
682
|
+
});
|
|
683
|
+
break;
|
|
684
|
+
}
|
|
685
|
+
case "local": {
|
|
686
|
+
let n = z(r.binding);
|
|
687
|
+
if (!n) break;
|
|
688
|
+
t.push({
|
|
689
|
+
...r,
|
|
690
|
+
id: e,
|
|
691
|
+
ownerColumnId: i,
|
|
692
|
+
columnIds: et(n, i),
|
|
693
|
+
binding: n
|
|
694
|
+
});
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
case "advanced":
|
|
698
|
+
t.push({
|
|
699
|
+
...r,
|
|
700
|
+
id: e,
|
|
701
|
+
ownerColumnId: i
|
|
702
|
+
});
|
|
703
|
+
break;
|
|
704
|
+
case "column": t.push({
|
|
705
|
+
...r,
|
|
706
|
+
id: e,
|
|
707
|
+
ownerColumnId: i
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return t;
|
|
712
|
+
}
|
|
713
|
+
function V(e) {
|
|
714
|
+
if (e == null) return;
|
|
715
|
+
let t = P(e);
|
|
716
|
+
return t === void 0 ? I(e) || L(e) : t;
|
|
717
|
+
}
|
|
718
|
+
function H(e) {
|
|
719
|
+
if (!e) return {};
|
|
720
|
+
let t = {};
|
|
721
|
+
for (let [n, r] of Object.entries(e)) {
|
|
722
|
+
let e = n.trim();
|
|
723
|
+
if (!e) continue;
|
|
724
|
+
let i = V(r);
|
|
725
|
+
i !== void 0 && (t[e] = i);
|
|
726
|
+
}
|
|
727
|
+
return t;
|
|
728
|
+
}
|
|
729
|
+
function st(e, t, n) {
|
|
730
|
+
let r = { ...H(e) }, i = V(n);
|
|
731
|
+
return i === void 0 ? (delete r[t], r) : (r[t] = i, r);
|
|
732
|
+
}
|
|
733
|
+
function ct(e, t, n) {
|
|
734
|
+
if (!e || Object.keys(e).length === 0) return {};
|
|
735
|
+
let r = {}, i = {};
|
|
736
|
+
for (let [e, t] of Object.entries(n)) for (let n of t) i[n.codeKey] = e;
|
|
737
|
+
let a = {}, o = new Set(t);
|
|
738
|
+
for (let [t, n] of Object.entries(e)) {
|
|
739
|
+
let e = i[t], s = o.has(t);
|
|
740
|
+
if (e && s && (Array.isArray(n) || typeof n == "string")) {
|
|
741
|
+
a[e] = a[e] ?? [], a[e].push(t);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
r[t] = n;
|
|
745
|
+
}
|
|
746
|
+
for (let [t, i] of Object.entries(a)) {
|
|
747
|
+
let a = n[t];
|
|
748
|
+
if (!a) continue;
|
|
749
|
+
let o = null;
|
|
750
|
+
for (let { codeKey: e } of [...a].reverse()) if (i.includes(e)) {
|
|
751
|
+
o = e;
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
o && e[o] !== void 0 && (r[o] = e[o]);
|
|
755
|
+
}
|
|
756
|
+
return r;
|
|
757
|
+
}
|
|
758
|
+
function lt(e, t) {
|
|
759
|
+
return P(t);
|
|
760
|
+
}
|
|
761
|
+
function ut(e, t, n) {
|
|
762
|
+
let r = lt(t.valueSource, t.valueSource === "input" ? n : t.value);
|
|
763
|
+
if (r === void 0) return;
|
|
764
|
+
let i = t.columnId?.trim() || e;
|
|
765
|
+
if (i) return {
|
|
766
|
+
key: i,
|
|
767
|
+
operation: t.operation,
|
|
768
|
+
value: r
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
function U(e, t, n) {
|
|
772
|
+
if (!t?.conditions.length) return;
|
|
773
|
+
let r = t.conditions.map((t) => ut(e, t, n)).filter((e) => !!e);
|
|
774
|
+
if (r.length) return {
|
|
775
|
+
and: t.and !== !1 || void 0,
|
|
776
|
+
conditions: r
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function dt(e) {
|
|
780
|
+
return A(e, !0);
|
|
781
|
+
}
|
|
782
|
+
function W(e, t) {
|
|
783
|
+
return A(e, t);
|
|
784
|
+
}
|
|
785
|
+
function ft(e, t) {
|
|
786
|
+
let n = L(t);
|
|
787
|
+
if (!n) return;
|
|
788
|
+
let r = e.columnIds.map((e) => {
|
|
789
|
+
let t = n[e];
|
|
790
|
+
if (t?.length) return A(e, t);
|
|
791
|
+
}).filter((e) => !!e);
|
|
792
|
+
if (r.length) return r.length === 1 ? r[0] : {
|
|
793
|
+
and: e.levelOperator !== "or" || void 0,
|
|
794
|
+
filters: r
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function pt(e, t) {
|
|
798
|
+
if (!e.binding || e.binding.kind !== "list") return;
|
|
799
|
+
let n = e.binding, r = N(e, t);
|
|
800
|
+
if (!r.length) return;
|
|
801
|
+
let i = e.kind === "local" ? e.ownerColumnId : "", a = r.map((t) => {
|
|
802
|
+
let r = n.options.find((e) => e.key === t);
|
|
803
|
+
if (!r) return;
|
|
804
|
+
let a = U(i, r.filter);
|
|
805
|
+
return a || e.kind === "registered" ? a : W(e.ownerColumnId, r.key);
|
|
806
|
+
}).filter((e) => !!e);
|
|
807
|
+
if (a.length) return a.length === 1 ? a[0] : {
|
|
808
|
+
and: n.and === !0 || void 0,
|
|
809
|
+
filters: a
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
function mt(e, t) {
|
|
813
|
+
if (t !== void 0) switch (e.kind) {
|
|
814
|
+
case "segment": {
|
|
815
|
+
if (e.componentId === "select") {
|
|
816
|
+
let n = P(t);
|
|
817
|
+
return n === void 0 ? void 0 : W(e.ownerColumnId, n);
|
|
818
|
+
}
|
|
819
|
+
let n = I(t);
|
|
820
|
+
return n?.length ? W(e.ownerColumnId, n) : void 0;
|
|
821
|
+
}
|
|
822
|
+
case "tree": return ft(e, t);
|
|
823
|
+
case "local": return e.binding.kind === "list" ? pt(e, t) : e.binding.kind === "boolean" ? t === !0 ? U(e.ownerColumnId, e.binding.trueFilter) ?? dt(e.ownerColumnId) : void 0 : U(e.ownerColumnId, e.binding.valueFilter, t) ?? (() => {
|
|
824
|
+
let n = P(t), r = I(t), i = n ?? r;
|
|
825
|
+
return i === void 0 ? void 0 : W(e.ownerColumnId, i);
|
|
826
|
+
})();
|
|
827
|
+
case "registered": return e.binding ? e.binding.kind === "list" ? pt(e, t) : e.binding.kind === "boolean" ? t === !0 ? U("", e.binding.trueFilter) : void 0 : U("", e.binding.valueFilter, t) : void 0;
|
|
828
|
+
case "column": {
|
|
829
|
+
let n = P(t), r = I(t), i = n ?? r;
|
|
830
|
+
return i === void 0 ? void 0 : W(e.ownerColumnId, i);
|
|
831
|
+
}
|
|
832
|
+
case "advanced": {
|
|
833
|
+
let n = I(t);
|
|
834
|
+
return n?.length ? W(e.ownerColumnId, n) : void 0;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function ht(e, t) {
|
|
839
|
+
let n = B(e), r = H(t);
|
|
840
|
+
if (!n.length || !Object.keys(r).length) return;
|
|
841
|
+
let i = n.map((e) => mt(e, r[e.id])).filter((e) => !!e);
|
|
842
|
+
if (i.length) return i.length === 1 ? i[0] : {
|
|
843
|
+
and: !0,
|
|
844
|
+
filters: i
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function gt(e, t) {
|
|
848
|
+
let n = B(e), r = H(t), i = {};
|
|
849
|
+
for (let e of n) {
|
|
850
|
+
if (e.kind !== "segment" && e.kind !== "tree") continue;
|
|
851
|
+
let t = r[e.id];
|
|
852
|
+
if (t === void 0) continue;
|
|
853
|
+
if (e.kind === "segment") {
|
|
854
|
+
let n = typeof t == "string" ? t : void 0, r = ot(t), a = n ? [n] : r;
|
|
855
|
+
if (!a?.length) continue;
|
|
856
|
+
i[e.dictionaryCodeKey ?? e.ownerColumnId] = a;
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
let n = L(t);
|
|
860
|
+
if (n) for (let t of e.columnIds) {
|
|
861
|
+
let e = n[t];
|
|
862
|
+
e && e.length && (i[t] = e);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return i;
|
|
866
|
+
}
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region src/odata-service/findCollectionPairs.ts
|
|
869
|
+
function _t(e, t = {}) {
|
|
870
|
+
let { textSuffixes: n = [
|
|
871
|
+
"_txt",
|
|
872
|
+
"_text",
|
|
873
|
+
"_t",
|
|
874
|
+
"_Text",
|
|
875
|
+
"_TXT",
|
|
876
|
+
"_T"
|
|
877
|
+
], caseSensitive: r = !1, returnUnpaired: i = !1 } = t, a = Object.keys(e), o = [], s = {}, c = /* @__PURE__ */ new Set(), l = new Set(a), u = n.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), d = RegExp(`(.*)(${u})$`, r ? "" : "i"), f = a.filter((e) => d.test(e));
|
|
878
|
+
for (let e of f) {
|
|
879
|
+
if (c.has(e)) continue;
|
|
880
|
+
let t = e.match(d);
|
|
881
|
+
if (t) {
|
|
882
|
+
let n = t[1];
|
|
883
|
+
a.includes(n) && !c.has(n) && (o.push({
|
|
884
|
+
codeKey: n,
|
|
885
|
+
textKey: e
|
|
886
|
+
}), s[n] = e, c.add(n), c.add(e), l.delete(n), l.delete(e));
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
let p = {
|
|
890
|
+
pairs: o,
|
|
891
|
+
pairsMap: s
|
|
892
|
+
};
|
|
893
|
+
return i && (p.unpaired = Array.from(l)), p;
|
|
894
|
+
}
|
|
895
|
+
//#endregion
|
|
896
|
+
//#region src/odata-service/odataCollectionStore.ts
|
|
897
|
+
var G = ee()(te((e) => ({
|
|
898
|
+
defaultMaxVisibleItems: 200,
|
|
899
|
+
defaultMinSearchCodeLength: 3,
|
|
900
|
+
defaultMinSearchTextLength: 1,
|
|
901
|
+
defaultSearchDebounceDelay: 100,
|
|
902
|
+
setDefaultMaxVisibleItems: (t) => e({ defaultMaxVisibleItems: t }),
|
|
903
|
+
setDefaultMinSearchTextLength: (t) => e({ defaultMinSearchTextLength: t }),
|
|
904
|
+
setDefaultMinSearchCodeLength: (t) => e({ defaultMinSearchCodeLength: t }),
|
|
905
|
+
setDefaultSearchDebounceDelay: (t) => e({ defaultSearchDebounceDelay: t })
|
|
906
|
+
}))), vt = {
|
|
907
|
+
useMaxVisibleItems: () => G((e) => e.defaultMaxVisibleItems),
|
|
908
|
+
useMinSearchCodeLength: () => G((e) => e.defaultMinSearchCodeLength),
|
|
909
|
+
useMinSearchTextLength: () => G((e) => e.defaultMinSearchTextLength),
|
|
910
|
+
useSearchDebounce: () => G((e) => e.defaultSearchDebounceDelay)
|
|
911
|
+
}, K = /^(.+)(_txt|_text|_t)$/i, q = /* @__PURE__ */ new Set(["ZDIV", "ZCFO1"]);
|
|
912
|
+
function yt(e) {
|
|
913
|
+
return e.label || e.id;
|
|
914
|
+
}
|
|
915
|
+
function bt(e) {
|
|
916
|
+
return e ? q.has(e.toUpperCase()) : !1;
|
|
917
|
+
}
|
|
918
|
+
function xt(e) {
|
|
919
|
+
if (!e) return !1;
|
|
920
|
+
let t = e.toUpperCase();
|
|
921
|
+
if (q.has(t)) return !0;
|
|
922
|
+
let n = t.match(/^(.+)(_TXT|_TEXT|_T)$/);
|
|
923
|
+
return n ? q.has(n[1]) : !1;
|
|
924
|
+
}
|
|
925
|
+
function St(e) {
|
|
926
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
927
|
+
}
|
|
928
|
+
function J(e) {
|
|
929
|
+
return e.startsWith("Edm.");
|
|
930
|
+
}
|
|
931
|
+
function Y(e, t) {
|
|
932
|
+
if (t) return e[t.toUpperCase()];
|
|
933
|
+
}
|
|
934
|
+
function Ct(e, t, n) {
|
|
935
|
+
let r = Y(n, e);
|
|
936
|
+
if (!r) return;
|
|
937
|
+
let i = RegExp(`^${St(r)}(_txt|_text|_t)$`, "i");
|
|
938
|
+
for (let e of t) if (i.test(e.id)) return e.id;
|
|
939
|
+
}
|
|
940
|
+
function wt(e) {
|
|
941
|
+
let t = {}, n = {};
|
|
942
|
+
for (let r of e) t[r.id] = r, n[r.id.toUpperCase()] = r.id;
|
|
943
|
+
for (let t of e) {
|
|
944
|
+
if (t.role === "measure") {
|
|
945
|
+
t.semanticType = "none", t.linkedColumnId = void 0;
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
t.role = "dimension", t.sortable = !0, t.filterable = !0, t.semanticType = K.test(t.id) ? "text" : "code";
|
|
949
|
+
let e = Y(n, t.linkedColumnId);
|
|
950
|
+
t.linkedColumnId = e && e !== t.id ? e : void 0;
|
|
951
|
+
}
|
|
952
|
+
for (let r of e) {
|
|
953
|
+
if (r.role !== "dimension" || r.semanticType !== "code") continue;
|
|
954
|
+
let i = r.linkedColumnId;
|
|
955
|
+
if (i) {
|
|
956
|
+
let e = t[i];
|
|
957
|
+
!e || e.role !== "dimension" ? i = void 0 : e.semanticType = "text";
|
|
958
|
+
}
|
|
959
|
+
if (i ||= Ct(r.id, e, n), !i && bt(r.id) && (i = Ct(r.id, e, n)), r.linkedColumnId = i, i) {
|
|
960
|
+
let e = t[i];
|
|
961
|
+
e && e.role === "dimension" && (e.semanticType = "text", e.linkedColumnId = r.id);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
for (let r of e) {
|
|
965
|
+
if (r.role !== "dimension" || r.semanticType !== "text") continue;
|
|
966
|
+
let e = r.linkedColumnId;
|
|
967
|
+
if (e) {
|
|
968
|
+
let n = t[e];
|
|
969
|
+
!n || n.role !== "dimension" ? e = void 0 : n.semanticType = "code";
|
|
970
|
+
}
|
|
971
|
+
if (!e) {
|
|
972
|
+
let i = Y(n, r.id.match(K)?.[1]);
|
|
973
|
+
i && t[i]?.role === "dimension" && (e = i);
|
|
974
|
+
}
|
|
975
|
+
if (r.linkedColumnId = e, e) {
|
|
976
|
+
let n = t[e];
|
|
977
|
+
n && n.role === "dimension" && (n.semanticType = "code", n.linkedColumnId ||= r.id);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return e;
|
|
981
|
+
}
|
|
982
|
+
function Tt(e) {
|
|
983
|
+
switch (e) {
|
|
984
|
+
case "Edm.String": return "string";
|
|
985
|
+
case "Edm.Guid": return "guid";
|
|
986
|
+
case "Edm.Boolean": return "boolean";
|
|
987
|
+
case "Edm.Int16":
|
|
988
|
+
case "Edm.Int32": return "int";
|
|
989
|
+
case "Edm.Int64": return "long";
|
|
990
|
+
case "Edm.Single": return "float";
|
|
991
|
+
case "Edm.Decimal": return "decimal";
|
|
992
|
+
case "Edm.Double": return "double";
|
|
993
|
+
case "Edm.DateTime": return "datetime";
|
|
994
|
+
case "Edm.DateTimeOffset": return "datetimeOffset";
|
|
995
|
+
case "Edm.Time": return "time";
|
|
996
|
+
case "Edm.Binary": return "binary";
|
|
997
|
+
case "Edm.Byte": return "byte";
|
|
998
|
+
default: throw Error(`Неподдерживаемый тип данных ${e}`);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function X(e) {
|
|
1002
|
+
let t = e.getAttribute("Name"), n = e.getAttribute("Type") || "", r = Tt(n), i = e.hasAttribute("MaxLength") ? Number(e.getAttribute("MaxLength")) : void 0, a = e.hasAttribute("Precision") ? Number(e.getAttribute("Precision")) : void 0, o = e.hasAttribute("Scale") ? Number(e.getAttribute("Scale")) : void 0, s = e.getAttribute("sap:label") || void 0, c = e.getAttribute("sap:parameter") || void 0, l = e.getAttribute("Nullable") !== "false" || void 0;
|
|
1003
|
+
return {
|
|
1004
|
+
id: t,
|
|
1005
|
+
label: s ?? t,
|
|
1006
|
+
type: r,
|
|
1007
|
+
originalType: n,
|
|
1008
|
+
...r === "string" && i === 1 ? { abapBooleanLike: !0 } : {},
|
|
1009
|
+
...i !== void 0 && { maxLength: i },
|
|
1010
|
+
...a !== void 0 && { precision: a },
|
|
1011
|
+
...o !== void 0 && { scale: o },
|
|
1012
|
+
...c !== void 0 && { parameter: c },
|
|
1013
|
+
...l !== void 0 && { nullable: !0 },
|
|
1014
|
+
...c === "mandatory" && { mandatory: !0 }
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
function Et(e) {
|
|
1018
|
+
let t = X(e), n = e.getAttribute("sap:text") || void 0, r = e.getAttribute("sap:sortable") !== "false", i = e.getAttribute("sap:filterable") !== "false", a = e.getAttribute("sap:aggregation-role") === "measure" ? "measure" : "dimension", o = e.getAttribute("sap:label") || void 0, { nullable: s, mandatory: c, ...l } = t;
|
|
1019
|
+
return {
|
|
1020
|
+
...l,
|
|
1021
|
+
...n !== void 0 && { linkedColumnId: n },
|
|
1022
|
+
...o !== void 0 && { label: o },
|
|
1023
|
+
semanticType: "none",
|
|
1024
|
+
sortable: r,
|
|
1025
|
+
filterable: i,
|
|
1026
|
+
role: a
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
function Dt(e) {
|
|
1030
|
+
let t = e.getAttribute("Name"), n = e.getAttribute("Type") || "";
|
|
1031
|
+
return !t || !J(n) ? !1 : !(["CNT", "cnt"].includes(t) || /_F$/i.test(t));
|
|
1032
|
+
}
|
|
1033
|
+
function Ot(e) {
|
|
1034
|
+
let t = e.getAttribute("Name"), n = e.getAttribute("Type") || "";
|
|
1035
|
+
return !t || !J(n) ? !1 : !(["CNT", "cnt"].includes(t) || /_F$/i.test(t));
|
|
1036
|
+
}
|
|
1037
|
+
function Z(e) {
|
|
1038
|
+
return Array.from(e.getElementsByTagName("Property"));
|
|
1039
|
+
}
|
|
1040
|
+
function kt(e) {
|
|
1041
|
+
return Array.from(e.getElementsByTagName("PropertyRef"));
|
|
1042
|
+
}
|
|
1043
|
+
function At(e) {
|
|
1044
|
+
return Array.from(e.getElementsByTagName("NavigationProperty"));
|
|
1045
|
+
}
|
|
1046
|
+
function jt(e) {
|
|
1047
|
+
return Z(e).filter(Dt).map(X);
|
|
1048
|
+
}
|
|
1049
|
+
function Mt(e) {
|
|
1050
|
+
let t = Z(e).filter(Dt), n = kt(e);
|
|
1051
|
+
return t.map((e) => {
|
|
1052
|
+
let t = X(e);
|
|
1053
|
+
return n.find((e) => e.getAttribute("Name") === t.id) && (t.mandatory = !0), t;
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
function Nt(e) {
|
|
1057
|
+
return wt(Z(e).filter(Ot).map(Et));
|
|
1058
|
+
}
|
|
1059
|
+
function Q(e) {
|
|
1060
|
+
if (!e) return;
|
|
1061
|
+
let t = e.split(".");
|
|
1062
|
+
return t[t.length - 1] || void 0;
|
|
1063
|
+
}
|
|
1064
|
+
function Pt(e) {
|
|
1065
|
+
let t = e.getAttribute("Mode");
|
|
1066
|
+
if (t && t !== "In") {
|
|
1067
|
+
let n = e.getAttribute("Name") || "(unknown)";
|
|
1068
|
+
throw Error(`FunctionImport parameter '${n}' uses unsupported Mode='${t}'`);
|
|
1069
|
+
}
|
|
1070
|
+
let n = e.getAttribute("Type") || "";
|
|
1071
|
+
if (!J(n)) {
|
|
1072
|
+
let t = e.getAttribute("Name") || "(unknown)";
|
|
1073
|
+
throw Error(`FunctionImport parameter '${t}' uses unsupported Type='${n}'`);
|
|
1074
|
+
}
|
|
1075
|
+
let r = X(e);
|
|
1076
|
+
return e.getAttribute("Nullable") === "false" && (r.mandatory = !0), r;
|
|
1077
|
+
}
|
|
1078
|
+
function Ft(e) {
|
|
1079
|
+
return e.reduce((e, t) => {
|
|
1080
|
+
let n = t.getAttribute("Name");
|
|
1081
|
+
return n && (e[n] = t), e;
|
|
1082
|
+
}, {});
|
|
1083
|
+
}
|
|
1084
|
+
function It(e) {
|
|
1085
|
+
return Array.from(e.getElementsByTagName("EntitySet")).reduce((e, t) => {
|
|
1086
|
+
let n = t.getAttribute("Name"), r = Q(t.getAttribute("EntityType"));
|
|
1087
|
+
return !n || !r || (e[n] = r), e;
|
|
1088
|
+
}, {});
|
|
1089
|
+
}
|
|
1090
|
+
function Lt(e) {
|
|
1091
|
+
return Array.from(e.getElementsByTagName("AssociationSet")).reduce((e, t) => {
|
|
1092
|
+
let n = t.getAttribute("Association");
|
|
1093
|
+
if (!n) return e;
|
|
1094
|
+
let r = { ends: Array.from(t.getElementsByTagName("End")).map((e) => {
|
|
1095
|
+
let t = e.getAttribute("Role"), n = e.getAttribute("EntitySet");
|
|
1096
|
+
if (!(!t || !n)) return {
|
|
1097
|
+
role: t,
|
|
1098
|
+
entitySet: n
|
|
1099
|
+
};
|
|
1100
|
+
}).filter((e) => !!e) };
|
|
1101
|
+
e[n] = r;
|
|
1102
|
+
let i = Q(n);
|
|
1103
|
+
return i && (e[i] = r), e;
|
|
1104
|
+
}, {});
|
|
1105
|
+
}
|
|
1106
|
+
function Rt(e, t) {
|
|
1107
|
+
for (let n of At(e)) {
|
|
1108
|
+
let e = n.getAttribute("Name");
|
|
1109
|
+
if (e !== "Set" && e !== "Results") continue;
|
|
1110
|
+
let r = n.getAttribute("Relationship"), i = r ? t[r] : void 0, a = n.getAttribute("ToRole"), o = n.getAttribute("FromRole"), s = i?.ends.find((e) => e.role === a)?.entitySet;
|
|
1111
|
+
return !s && i && (s = i.ends.find((e) => e.role !== o)?.entitySet), {
|
|
1112
|
+
name: e,
|
|
1113
|
+
targetEntitySet: s
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function zt(e, t, n) {
|
|
1118
|
+
let r = /* @__PURE__ */ new Set();
|
|
1119
|
+
for (let [i, a] of Object.entries(e)) {
|
|
1120
|
+
let e = t[a];
|
|
1121
|
+
if (!e) continue;
|
|
1122
|
+
let o = Rt(e, n);
|
|
1123
|
+
o?.targetEntitySet && o.targetEntitySet !== i && r.add(o.targetEntitySet);
|
|
1124
|
+
}
|
|
1125
|
+
return r;
|
|
1126
|
+
}
|
|
1127
|
+
function Bt(e, t, n, r) {
|
|
1128
|
+
let i = t?.targetEntitySet ? n[t.targetEntitySet] : void 0;
|
|
1129
|
+
return i && r[i] || e;
|
|
1130
|
+
}
|
|
1131
|
+
function Vt(e, t, n) {
|
|
1132
|
+
if (n) return jt(e);
|
|
1133
|
+
if (!t.endsWith("Type")) return Mt(e);
|
|
1134
|
+
}
|
|
1135
|
+
function Ht(e, t) {
|
|
1136
|
+
if (!e) return /* @__PURE__ */ new Set();
|
|
1137
|
+
let n = Q(e);
|
|
1138
|
+
if (!n) return /* @__PURE__ */ new Set();
|
|
1139
|
+
let r = t[n];
|
|
1140
|
+
return r ? new Set(kt(r).map((e) => e.getAttribute("Name")).filter((e) => !!e)) : /* @__PURE__ */ new Set();
|
|
1141
|
+
}
|
|
1142
|
+
function Ut(e, t, n) {
|
|
1143
|
+
let r = e.getAttribute("Name") || "", i = e.getAttribute("EntitySet") || void 0, a = e.getAttribute("sap:action-for") || void 0, o = Ht(a, n), s = Array.from(e.getElementsByTagName("Parameter")).map((e) => {
|
|
1144
|
+
let t = Pt(e);
|
|
1145
|
+
return o.has(t.id) && (t.mandatory = !0), t;
|
|
1146
|
+
});
|
|
1147
|
+
return {
|
|
1148
|
+
name: r,
|
|
1149
|
+
title: e.getAttribute("sap:label") || "",
|
|
1150
|
+
httpMethod: e.getAttribute("m:HttpMethod") || void 0,
|
|
1151
|
+
parameters: s.length ? s : void 0,
|
|
1152
|
+
returnType: e.getAttribute("ReturnType") || "",
|
|
1153
|
+
...i !== void 0 && { entitySet: i },
|
|
1154
|
+
...a !== void 0 && { actionFor: a },
|
|
1155
|
+
...i && t[i] ? { resultEntity: i } : {}
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
function Wt(e) {
|
|
1159
|
+
let t = new DOMParser().parseFromString(e, "application/xml"), n = Array.from(t.getElementsByTagName("EntityType")), r = Array.from(t.getElementsByTagName("FunctionImport")), i = It(t), a = Ft(n), o = Lt(t), s = zt(i, a, o), c = {}, l = {};
|
|
1160
|
+
for (let [e, t] of Object.entries(i)) {
|
|
1161
|
+
if (s.has(e)) continue;
|
|
1162
|
+
let n = a[t];
|
|
1163
|
+
if (!n) continue;
|
|
1164
|
+
let r = Rt(n, o), l = Bt(n, r, i, a), u = n.getAttribute("sap:label") || l.getAttribute("sap:label") || "", d = Nt(l), f = Vt(n, t, r);
|
|
1165
|
+
c[e] = {
|
|
1166
|
+
title: u,
|
|
1167
|
+
columns: d,
|
|
1168
|
+
...f?.length ? { parameters: f } : {},
|
|
1169
|
+
...r ? { result: r.name } : {}
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
for (let e of r) {
|
|
1173
|
+
let t = Ut(e, i, a);
|
|
1174
|
+
l[t.name] = t;
|
|
1175
|
+
}
|
|
1176
|
+
return {
|
|
1177
|
+
entities: c,
|
|
1178
|
+
functionImports: l
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
//#endregion
|
|
1182
|
+
//#region src/odata-service/sorts.ts
|
|
1183
|
+
function Gt(e, t) {
|
|
1184
|
+
return e.findIndex((e) => e.key === t);
|
|
1185
|
+
}
|
|
1186
|
+
function Kt(e) {
|
|
1187
|
+
return e.map((e) => `${String(e.key)} ${e.desc ? "desc" : "asc"}`).join(",");
|
|
1188
|
+
}
|
|
1189
|
+
function qt(e, t, n) {
|
|
1190
|
+
let r = Gt(e, t), i = n ? [...e] : [...e.filter((e) => e.key === t)];
|
|
1191
|
+
return r === -1 ? (i.push({ key: t }), i) : e[r].desc ? i.filter((e) => e.key !== t) : i.map((e) => e.key === t ? {
|
|
1192
|
+
key: t,
|
|
1193
|
+
desc: !0
|
|
1194
|
+
} : e);
|
|
1195
|
+
}
|
|
1196
|
+
function Jt(e, t) {
|
|
1197
|
+
return t.length > 0 ? t.map((e) => ({
|
|
1198
|
+
key: e.key,
|
|
1199
|
+
desc: e.desc
|
|
1200
|
+
})) : e.map((e) => ({ key: e }));
|
|
1201
|
+
}
|
|
1202
|
+
function Yt(e, t) {
|
|
1203
|
+
let n = Jt(e, t).map((e) => `${String(e.key)} ${e.desc ? "desc" : "asc"}`);
|
|
1204
|
+
return n.length ? n.join(",") : void 0;
|
|
1205
|
+
}
|
|
1206
|
+
function Xt(e, t, n) {
|
|
1207
|
+
let r = t.length > 0, i = e.indexOf(n);
|
|
1208
|
+
if (!r && i !== -1) return {
|
|
1209
|
+
active: !0,
|
|
1210
|
+
order: i + 1,
|
|
1211
|
+
lockedByGrouping: !0
|
|
1212
|
+
};
|
|
1213
|
+
let a = t.findIndex((e) => e.key === n);
|
|
1214
|
+
return a === -1 ? { active: !1 } : {
|
|
1215
|
+
active: !0,
|
|
1216
|
+
desc: t[a]?.desc,
|
|
1217
|
+
order: a + 1
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
//#endregion
|
|
1221
|
+
//#region src/odata-service/sqlFilters.ts
|
|
1222
|
+
var Zt = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
1223
|
+
function Qt(e) {
|
|
1224
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
|
|
1225
|
+
}
|
|
1226
|
+
function $(e) {
|
|
1227
|
+
if (!Zt.test(e)) throw Error(`Некорректное имя поля SQL-фильтра: ${e}`);
|
|
1228
|
+
}
|
|
1229
|
+
function $t(e, t) {
|
|
1230
|
+
return {
|
|
1231
|
+
fieldId: e,
|
|
1232
|
+
operation: "eq",
|
|
1233
|
+
value: t
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
function en(e, t) {
|
|
1237
|
+
return {
|
|
1238
|
+
fieldId: e,
|
|
1239
|
+
operation: "in",
|
|
1240
|
+
values: t
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function tn(e, t) {
|
|
1244
|
+
return {
|
|
1245
|
+
operation: "group",
|
|
1246
|
+
conjunction: t,
|
|
1247
|
+
expressions: e
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
function nn(e) {
|
|
1251
|
+
if (e instanceof Date) throw Error("Дата должна быть отформатирована вызывающей стороной до формирования SQL-фильтра");
|
|
1252
|
+
if (!Qt(e) || typeof e == "number" && !Number.isFinite(e)) return;
|
|
1253
|
+
let t = String(e);
|
|
1254
|
+
if (!(!t || t.trim() === "")) return `'${t.replaceAll("'", "''")}'`;
|
|
1255
|
+
}
|
|
1256
|
+
function rn(e) {
|
|
1257
|
+
if (e.operation === "group") {
|
|
1258
|
+
let t = e.expressions.map((e) => rn(e)).filter((e) => !!e);
|
|
1259
|
+
if (!t.length) return;
|
|
1260
|
+
let n = e.conjunction === "or" ? " OR " : " AND ";
|
|
1261
|
+
return `(${t.join(n)})`;
|
|
1262
|
+
}
|
|
1263
|
+
if (e.operation === "eq") {
|
|
1264
|
+
let t = nn(e.value);
|
|
1265
|
+
return t ? ($(e.fieldId), `${e.fieldId}=${t}`) : void 0;
|
|
1266
|
+
}
|
|
1267
|
+
let t = (e.values ?? []).map((e) => nn(e)).filter((e) => !!e);
|
|
1268
|
+
if (t.length !== 0) return $(e.fieldId), `${e.fieldId} IN (${t.join(", ")})`;
|
|
1269
|
+
}
|
|
1270
|
+
function an(e) {
|
|
1271
|
+
return e ? e.map((e) => rn(e)).filter((e) => !!e).join(" AND ") : "";
|
|
1272
|
+
}
|
|
1273
|
+
//#endregion
|
|
1274
|
+
//#region src/odata-service/unwrapODataQueryResult.ts
|
|
1275
|
+
function on(e) {
|
|
1276
|
+
let t = e.data?.data, n = e.data?.totalCount;
|
|
1277
|
+
return {
|
|
1278
|
+
...e,
|
|
1279
|
+
data: t,
|
|
1280
|
+
totalCount: n
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
//#endregion
|
|
1284
|
+
//#region src/odata-service/utils.ts
|
|
1285
|
+
function sn(e) {
|
|
1286
|
+
return Array.isArray(e) ? [e[0] ?? null, e[1] ?? null] : [ln(e) ? e ?? null : null, null];
|
|
1287
|
+
}
|
|
1288
|
+
function cn(t) {
|
|
1289
|
+
return t instanceof Date ? t : Array.isArray(t) || e(t) ? null : t;
|
|
1290
|
+
}
|
|
1291
|
+
function ln(e) {
|
|
1292
|
+
return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
|
|
1293
|
+
}
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region src/odata-service/wrapParams.ts
|
|
1296
|
+
function un(e) {
|
|
1297
|
+
if (!e) return {};
|
|
1298
|
+
let t = {};
|
|
1299
|
+
for (let n in e) t[n] = { value: e[n] };
|
|
1300
|
+
return t;
|
|
1301
|
+
}
|
|
1302
|
+
function dn(e) {
|
|
1303
|
+
if (!e) return;
|
|
1304
|
+
let t = {};
|
|
1305
|
+
for (let n of Object.keys(e).sort()) t[n] = e[n]?.value ?? null;
|
|
1306
|
+
return t;
|
|
1307
|
+
}
|
|
1308
|
+
//#endregion
|
|
1309
|
+
export { ne as BASE_META_TYPES, ie as BASE_META_TYPE_LABELS, ze as FILTER_OPERATIONS, q as FORCED_CODE_TEXT_IDS, Re as FilterOperation, m as ODataDateFormat, $ as assertSqlFilterFieldId, Pe as buildEntityOperationPath, T as buildEntityParameters, Ie as buildEntityPath, Ne as buildFunctionImportParameters, Fe as buildFunctionImportPath, O as buildODataFilter, Je as buildODataFilterRecursive, Kt as buildODataOrder, Yt as buildODataOrderBy, w as buildParameterEntries, ce as buildSeparatedArrays, an as buildSqlFilter, ct as collapseChainedODataSegmentFilterValues, E as collectFilterableColumns, Le as collectFilterableColumnsIds, ht as compileFiltersToExpression, b as createBooleanFormatter, S as createDateFormatter, k as createFilter, Ye as createFilterBetween, Ze as createFilterContains, A as createFilterEqual, Xe as createFilterEqualFalsy, y as createFormatter, ye as createNumberFormatter, $t as createSqlFilterEqual, tn as createSqlFilterGroup, en as createSqlFilterIn, x as createStringFormatter, ve as defaultControlTypeValue, _e as defaultODataTypeValue, _t as findCollectionPairs, gt as flattenFilterValuesToODataDependencies, d as getBaseTypeFromODataType, Ae as getFormatter, je as getFormatterForBaseType, Oe as getFormattersFor, ke as getFormattersForBaseType, Gt as getSortIndex, Xt as getSortIndicator, ae as isBaseMetaType, ln as isBaseValue, de as isBooleanSafe, fe as isDateSafe, $e as isFilterLocalComponentId, He as isFilterOperation, xt as isForcedCodeTextFamilyId, bt as isForcedCodeTextId, ue as isNumberSafe, c as isODataBooleanType, u as isODataDateType, s as isODataIntegerType, o as isODataNumericType, Qt as isSqlFilterScalarValue, le as isStringSafe, Qe as mergeFilterExpressions, st as mergeFilterValuePatch, cn as normalizeBaseValue, at as normalizeDictionaryCodeKey, sn as normalizeRangeValue, vt as odataCollectionConfig, v as odataFormatValue, he as odataParseValue, ge as odataParseValueByMetadata, h as odataTypeSchemas, Wt as parseServiceMetadata, oe as resolveBaseTypeLabel, Jt as resolveEffectiveSorts, yt as resolveMetadataColumnLabel, it as resolveODataFilterDefinitionActiveColumnIds, rt as resolveODataFilterDefinitionColumnIds, Ue as resolveOperationLabel, z as sanitizeFilterBinding, R as sanitizeFilterConditionGroup, B as sanitizeFilterDefinitions, V as sanitizeFilterValue, H as sanitizeFilterValues, qt as toggleSort, dn as unwrapODataParams, on as unwrapODataQueryResult, G as useODataCollectionStore, un as wrapODataParams };
|
|
1310
|
+
|
|
1311
|
+
//# sourceMappingURL=index.js.map
|