@nice2dev/ui 1.4.5 → 1.4.7
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/CHANGELOG.md +76 -0
- package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
- package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
- package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
- package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
- package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
- package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
- package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
- package/dist/{NiceSavedQueryPanel-U1-yaw-Q.cjs → NiceSavedQueryPanel-BSZhE-_l.cjs} +6 -6
- package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
- package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/database/NiceDataSourceEditor.mjs +370 -0
- package/dist/database/NiceQueryDesigner.mjs +958 -0
- package/dist/database/moduleDataSource.mjs +151 -0
- package/dist/database/queryDesign.mjs +396 -0
- package/dist/database/queryDesignerPanels.mjs +1214 -0
- package/dist/database/querySql.mjs +481 -0
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +188 -181
- package/dist/index.d.ts +674 -0
- package/dist/index.mjs +774 -720
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
- package/dist/no-code/noCodeScript.mjs +326 -0
- package/dist/no-code-B1jzfUF5.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +177 -0
- package/dist/no-code.mjs +26 -16
- package/dist/style.css +2 -2
- package/package.json +4 -4
- package/dist/NiceForm-O3sv-DNX.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
- package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
- package/dist/no-code-B3BHeyG-.cjs +0 -331
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { outputColumns as d, queryParameterNames as q } from "./queryDesign.mjs";
|
|
2
|
+
import { generateQuerySql as l } from "./querySql.mjs";
|
|
3
|
+
const g = [
|
|
4
|
+
"query",
|
|
5
|
+
"sql",
|
|
6
|
+
"union",
|
|
7
|
+
"static"
|
|
8
|
+
], u = (e) => typeof e == "object" && e !== null && !Array.isArray(e), f = (e) => Array.isArray(e) && e.every((n) => typeof n == "string");
|
|
9
|
+
function S(e) {
|
|
10
|
+
if (!u(e) || typeof e.key != "string" || !e.key)
|
|
11
|
+
return !1;
|
|
12
|
+
switch (e.kind) {
|
|
13
|
+
case "query":
|
|
14
|
+
return u(e.query) && Array.isArray(e.query.tables) && typeof e.sql == "string";
|
|
15
|
+
case "sql":
|
|
16
|
+
return typeof e.sql == "string";
|
|
17
|
+
case "union":
|
|
18
|
+
return f(e.sources);
|
|
19
|
+
case "static":
|
|
20
|
+
return Array.isArray(e.rows) && e.rows.every(u);
|
|
21
|
+
default:
|
|
22
|
+
return !1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const m = {
|
|
26
|
+
tables: [],
|
|
27
|
+
joins: [],
|
|
28
|
+
conditions: [],
|
|
29
|
+
sorts: [],
|
|
30
|
+
groupBy: [],
|
|
31
|
+
distinct: !1
|
|
32
|
+
};
|
|
33
|
+
function w(e, n, t = {}) {
|
|
34
|
+
const r = {
|
|
35
|
+
key: n,
|
|
36
|
+
...t.label ? { label: t.label } : {},
|
|
37
|
+
...t.description ? { description: t.description } : {}
|
|
38
|
+
};
|
|
39
|
+
switch (e) {
|
|
40
|
+
case "query":
|
|
41
|
+
return { ...r, kind: e, query: { ...m }, sql: "" };
|
|
42
|
+
case "sql":
|
|
43
|
+
return { ...r, kind: e, sql: "SELECT 1", parameters: [], columns: [] };
|
|
44
|
+
case "union":
|
|
45
|
+
return { ...r, kind: e, sources: [] };
|
|
46
|
+
case "static":
|
|
47
|
+
return { ...r, kind: e, columns: [], rows: [] };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function y(e, n = {}, t = /* @__PURE__ */ new Set()) {
|
|
51
|
+
switch (e.kind) {
|
|
52
|
+
case "query":
|
|
53
|
+
return d(e.query).filter((r) => r.path.length === 0).map((r) => ({ name: r.name, dataType: r.dataType }));
|
|
54
|
+
case "sql":
|
|
55
|
+
return e.columns ?? [];
|
|
56
|
+
case "union": {
|
|
57
|
+
const r = n.sources?.find((o) => o.key === e.sources[0]);
|
|
58
|
+
return r && !t.has(r.key) ? y(r, n, /* @__PURE__ */ new Set([...t, e.key])) : [];
|
|
59
|
+
}
|
|
60
|
+
case "static":
|
|
61
|
+
return e.columns?.length ? e.columns : [...new Set(e.rows.flatMap((r) => Object.keys(r)))].map((r) => ({ name: r }));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function A(e, n = {}) {
|
|
65
|
+
return {
|
|
66
|
+
name: e.key,
|
|
67
|
+
schema: "source",
|
|
68
|
+
columns: y(e, n).map((t) => ({
|
|
69
|
+
name: t.name,
|
|
70
|
+
dataType: t.dataType ?? "string"
|
|
71
|
+
}))
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function D(e) {
|
|
75
|
+
const n = "parameters" in e && e.parameters ? e.parameters : [], t = e.kind === "sql" ? e.sql : "", r = /* @__PURE__ */ new Set();
|
|
76
|
+
for (const s of t.matchAll(/@([A-Za-z_]\w*)|\{\{\s*([A-Za-z_]\w*)\s*\}\}/g))
|
|
77
|
+
r.add(s[1] ?? s[2]);
|
|
78
|
+
e.kind === "query" && q(e.query).forEach((s) => r.add(s));
|
|
79
|
+
const o = new Set(n.map((s) => s.name));
|
|
80
|
+
return [...n, ...[...r].filter((s) => !o.has(s)).map((s) => ({ name: s }))];
|
|
81
|
+
}
|
|
82
|
+
function T(e, n = {}) {
|
|
83
|
+
return e.flatMap((t) => {
|
|
84
|
+
const r = t.entity ?? t.name, o = {
|
|
85
|
+
...m,
|
|
86
|
+
tables: [
|
|
87
|
+
{
|
|
88
|
+
id: "t1",
|
|
89
|
+
name: t.name,
|
|
90
|
+
...t.schema ? { schema: t.schema } : {},
|
|
91
|
+
position: { x: 24, y: 24 },
|
|
92
|
+
columns: t.columns.map((a) => ({
|
|
93
|
+
name: a.name,
|
|
94
|
+
dataType: a.dataType,
|
|
95
|
+
...a.isPrimaryKey ? { isPrimaryKey: !0 } : {},
|
|
96
|
+
...a.isForeignKey ? { isForeignKey: !0 } : {},
|
|
97
|
+
selected: !0
|
|
98
|
+
}))
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}, s = {
|
|
102
|
+
key: `${r}All`,
|
|
103
|
+
label: r,
|
|
104
|
+
kind: "query",
|
|
105
|
+
query: o,
|
|
106
|
+
shape: "list",
|
|
107
|
+
sql: l(o, { dialect: n.dialect, shape: "list" })
|
|
108
|
+
}, i = t.columns.find((a) => a.isPrimaryKey)?.name ?? t.columns.find((a) => a.name.toLowerCase() === "id")?.name;
|
|
109
|
+
if (!i)
|
|
110
|
+
return [s];
|
|
111
|
+
const c = {
|
|
112
|
+
...o,
|
|
113
|
+
filter: {
|
|
114
|
+
kind: "group",
|
|
115
|
+
id: "g1",
|
|
116
|
+
logic: "AND",
|
|
117
|
+
items: [
|
|
118
|
+
{
|
|
119
|
+
kind: "rule",
|
|
120
|
+
id: "r1",
|
|
121
|
+
left: { kind: "column", tableId: "t1", column: i },
|
|
122
|
+
operator: "eq",
|
|
123
|
+
right: { kind: "parameter", name: "id" }
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}, p = {
|
|
128
|
+
key: `${r}ById`,
|
|
129
|
+
label: r,
|
|
130
|
+
kind: "query",
|
|
131
|
+
query: c,
|
|
132
|
+
shape: "object",
|
|
133
|
+
parameters: [{ name: "id", required: !0 }],
|
|
134
|
+
sql: l(c, { dialect: n.dialect, shape: "object" })
|
|
135
|
+
};
|
|
136
|
+
return [s, p];
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function b(e) {
|
|
140
|
+
return e.kind === "union" ? [...e.sources] : e.kind === "query" ? e.query.tables.filter((n) => n.schema === "source").map((n) => n.name) : [];
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
g as NICE_MODULE_DATA_SOURCE_KINDS,
|
|
144
|
+
S as isModuleDataSource,
|
|
145
|
+
y as moduleDataSourceColumns,
|
|
146
|
+
b as moduleDataSourceDependencies,
|
|
147
|
+
D as moduleDataSourceParameters,
|
|
148
|
+
A as moduleDataSourceTable,
|
|
149
|
+
w as newModuleDataSource,
|
|
150
|
+
T as standardDataSources
|
|
151
|
+
};
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
const v = [
|
|
2
|
+
"postgresql",
|
|
3
|
+
"sqlserver",
|
|
4
|
+
"mysql",
|
|
5
|
+
"sqlite",
|
|
6
|
+
"oracle"
|
|
7
|
+
], h = [
|
|
8
|
+
{ id: "eq", takes: "one", fits: ["text", "number", "date", "boolean", "any"] },
|
|
9
|
+
{ id: "ne", takes: "one", fits: ["text", "number", "date", "boolean", "any"] },
|
|
10
|
+
{ id: "contains", takes: "one", fits: ["text", "any"] },
|
|
11
|
+
{ id: "notContains", takes: "one", fits: ["text", "any"] },
|
|
12
|
+
{ id: "startsWith", takes: "one", fits: ["text", "any"] },
|
|
13
|
+
{ id: "endsWith", takes: "one", fits: ["text", "any"] },
|
|
14
|
+
{ id: "gt", takes: "one", fits: ["number", "date", "any"] },
|
|
15
|
+
{ id: "ge", takes: "one", fits: ["number", "date", "any"] },
|
|
16
|
+
{ id: "lt", takes: "one", fits: ["number", "date", "any"] },
|
|
17
|
+
{ id: "le", takes: "one", fits: ["number", "date", "any"] },
|
|
18
|
+
{ id: "between", takes: "two", fits: ["number", "date", "any"] },
|
|
19
|
+
{ id: "in", takes: "list", fits: ["text", "number", "any"] },
|
|
20
|
+
{ id: "notIn", takes: "list", fits: ["text", "number", "any"] },
|
|
21
|
+
{ id: "isEmpty", takes: "none", fits: ["text", "number", "date", "boolean", "any"] },
|
|
22
|
+
{ id: "isNotEmpty", takes: "none", fits: ["text", "number", "date", "boolean", "any"] },
|
|
23
|
+
{ id: "isTrue", takes: "none", fits: ["boolean"] },
|
|
24
|
+
{ id: "isFalse", takes: "none", fits: ["boolean"] },
|
|
25
|
+
{ id: "today", takes: "none", fits: ["date"] },
|
|
26
|
+
{ id: "lastDays", takes: "days", fits: ["date"] },
|
|
27
|
+
{ id: "nextDays", takes: "days", fits: ["date"] },
|
|
28
|
+
{ id: "thisMonth", takes: "none", fits: ["date"] },
|
|
29
|
+
{ id: "thisYear", takes: "none", fits: ["date"] }
|
|
30
|
+
], I = [
|
|
31
|
+
{ id: "upper", group: "text", args: ["text"], result: "text" },
|
|
32
|
+
{ id: "lower", group: "text", args: ["text"], result: "text" },
|
|
33
|
+
{ id: "trim", group: "text", args: ["text"], result: "text" },
|
|
34
|
+
{ id: "concat", group: "text", args: ["any", "any"], variadic: !0, result: "text" },
|
|
35
|
+
{ id: "left", group: "text", args: ["text", "number"], result: "text" },
|
|
36
|
+
{ id: "length", group: "text", args: ["text"], result: "number" },
|
|
37
|
+
{ id: "replace", group: "text", args: ["text", "text", "text"], result: "text" },
|
|
38
|
+
{ id: "round", group: "number", args: ["number", "number"], result: "number" },
|
|
39
|
+
{ id: "abs", group: "number", args: ["number"], result: "number" },
|
|
40
|
+
{ id: "floor", group: "number", args: ["number"], result: "number" },
|
|
41
|
+
{ id: "ceil", group: "number", args: ["number"], result: "number" },
|
|
42
|
+
{ id: "add", group: "number", args: ["number", "number"], result: "number" },
|
|
43
|
+
{ id: "subtract", group: "number", args: ["number", "number"], result: "number" },
|
|
44
|
+
{ id: "multiply", group: "number", args: ["number", "number"], result: "number" },
|
|
45
|
+
{ id: "divide", group: "number", args: ["number", "number"], result: "number" },
|
|
46
|
+
{ id: "year", group: "date", args: ["date"], result: "number" },
|
|
47
|
+
{ id: "month", group: "date", args: ["date"], result: "number" },
|
|
48
|
+
{ id: "day", group: "date", args: ["date"], result: "number" },
|
|
49
|
+
{ id: "date", group: "date", args: ["date"], result: "date" },
|
|
50
|
+
{ id: "daysBetween", group: "date", args: ["date", "date"], result: "number" },
|
|
51
|
+
{ id: "now", group: "date", args: [], result: "date" },
|
|
52
|
+
{ id: "coalesce", group: "other", args: ["any", "any"], variadic: !0, result: "any" }
|
|
53
|
+
];
|
|
54
|
+
function T(r) {
|
|
55
|
+
const t = (r ?? "").toLowerCase();
|
|
56
|
+
return /bool|bit\b/.test(t) ? "boolean" : /date|time|timestamp/.test(t) ? "date" : /int|dec|num|money|float|double|real|serial|currency/.test(t) ? "number" : /char|text|string|guid|uuid|email|url|phone|json|enum/.test(t) ? "text" : "any";
|
|
57
|
+
}
|
|
58
|
+
function E(r) {
|
|
59
|
+
return h.filter((t) => r === "any" || t.fits.includes(r));
|
|
60
|
+
}
|
|
61
|
+
function O(r) {
|
|
62
|
+
const t = new Set(r.joins.map((o) => o.rightTableId));
|
|
63
|
+
return (r.tables.find((o) => !t.has(o.id)) ?? r.tables[0])?.id;
|
|
64
|
+
}
|
|
65
|
+
const f = (r) => r.alias || r.name, $ = (r, t) => r.as || (t ? f(t) : r.rightTableId);
|
|
66
|
+
function x(r, t) {
|
|
67
|
+
const o = new Map(r.tables.map((a) => [a.id, a])), s = [], e = /* @__PURE__ */ new Set();
|
|
68
|
+
let n = t;
|
|
69
|
+
for (; ; ) {
|
|
70
|
+
const a = r.joins.find((i) => i.rightTableId === n);
|
|
71
|
+
if (!a || e.has(a.id))
|
|
72
|
+
return s;
|
|
73
|
+
e.add(a.id), (a.nest === "object" || a.nest === "list") && s.unshift($(a, o.get(n))), n = a.leftTableId;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function L(r, t) {
|
|
77
|
+
const o = /* @__PURE__ */ new Set();
|
|
78
|
+
let s = t;
|
|
79
|
+
for (; ; ) {
|
|
80
|
+
const e = r.joins.find((n) => n.rightTableId === s);
|
|
81
|
+
if (!e || o.has(e.id))
|
|
82
|
+
return;
|
|
83
|
+
if (e.nest === "list")
|
|
84
|
+
return e;
|
|
85
|
+
o.add(e.id), s = e.leftTableId;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function S(r) {
|
|
89
|
+
const t = [];
|
|
90
|
+
let o = 0;
|
|
91
|
+
for (const n of r.tables) {
|
|
92
|
+
const a = x(r, n.id);
|
|
93
|
+
for (const i of n.columns)
|
|
94
|
+
i.selected && t.push({
|
|
95
|
+
key: `t:${n.id}:${i.name}`,
|
|
96
|
+
tableId: n.id,
|
|
97
|
+
column: i.name,
|
|
98
|
+
name: i.alias || i.name,
|
|
99
|
+
dataType: i.aggregate === "COUNT" || i.aggregate === "COUNT_DISTINCT" ? "int" : i.dataType,
|
|
100
|
+
aggregate: i.aggregate,
|
|
101
|
+
path: a,
|
|
102
|
+
order: i.order ?? o
|
|
103
|
+
}), o++;
|
|
104
|
+
}
|
|
105
|
+
for (const n of r.computed ?? []) {
|
|
106
|
+
if (n.selected) {
|
|
107
|
+
const a = I.find((i) => i.id === n.fn);
|
|
108
|
+
t.push({
|
|
109
|
+
key: `c:${n.id}`,
|
|
110
|
+
computedId: n.id,
|
|
111
|
+
name: n.alias,
|
|
112
|
+
dataType: a?.result === "number" ? "decimal" : a?.result === "date" ? "date" : "string",
|
|
113
|
+
aggregate: n.aggregate,
|
|
114
|
+
path: [],
|
|
115
|
+
order: n.order ?? o
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
o++;
|
|
119
|
+
}
|
|
120
|
+
t.sort((n, a) => n.order - a.order);
|
|
121
|
+
const s = new Map(r.tables.map((n) => [n.id, n])), e = /* @__PURE__ */ new Map();
|
|
122
|
+
for (const n of t) {
|
|
123
|
+
const a = `${n.path.join(".")}|${n.name}`;
|
|
124
|
+
e.set(a, (e.get(a) ?? 0) + 1);
|
|
125
|
+
}
|
|
126
|
+
for (const n of t) {
|
|
127
|
+
const a = `${n.path.join(".")}|${n.name}`, i = n.tableId ? s.get(n.tableId) : void 0;
|
|
128
|
+
(e.get(a) ?? 0) > 1 && i && !i.columns.find((u) => u.name === n.column)?.alias && (n.name = `${f(i)}_${n.name}`);
|
|
129
|
+
}
|
|
130
|
+
return t;
|
|
131
|
+
}
|
|
132
|
+
function j(r) {
|
|
133
|
+
const t = /* @__PURE__ */ new Set(), o = (e) => {
|
|
134
|
+
e?.kind === "parameter" && e.name && t.add(e.name);
|
|
135
|
+
}, s = (e) => {
|
|
136
|
+
for (const n of e?.items ?? [])
|
|
137
|
+
n.kind === "group" ? s(n) : (o(n.left), o(n.right), o(n.right2));
|
|
138
|
+
};
|
|
139
|
+
s(r.filter), s(r.having);
|
|
140
|
+
for (const e of r.computed ?? [])
|
|
141
|
+
e.args.forEach(o);
|
|
142
|
+
for (const e of r.conditions)
|
|
143
|
+
for (const n of [e.value, e.value2]) {
|
|
144
|
+
const a = /^[@:]([A-Za-z_]\w*)$/.exec(n ?? "");
|
|
145
|
+
a && t.add(a[1]);
|
|
146
|
+
}
|
|
147
|
+
return [...t];
|
|
148
|
+
}
|
|
149
|
+
function k(r) {
|
|
150
|
+
return (r?.items ?? []).reduce((t, o) => t + (o.kind === "group" ? k(o) : 1), 0);
|
|
151
|
+
}
|
|
152
|
+
let N = 0;
|
|
153
|
+
const p = (r) => `${r}-${Date.now().toString(36)}-${(N++).toString(36)}`;
|
|
154
|
+
function F() {
|
|
155
|
+
return { tables: [], joins: [], conditions: [], sorts: [], groupBy: [], distinct: !1 };
|
|
156
|
+
}
|
|
157
|
+
const y = (r = "AND") => ({
|
|
158
|
+
kind: "group",
|
|
159
|
+
id: p("g"),
|
|
160
|
+
logic: r,
|
|
161
|
+
items: []
|
|
162
|
+
}), b = { width: 220, header: 34, row: 24, gapX: 60, gapY: 40 };
|
|
163
|
+
function w(r, t, o = {}) {
|
|
164
|
+
const s = r.tables.filter((l) => l.name === t.name && l.schema === t.schema), e = new Set(r.tables.map(f));
|
|
165
|
+
let n;
|
|
166
|
+
if (o.alias && o.alias !== t.name) {
|
|
167
|
+
n = o.alias;
|
|
168
|
+
for (let l = 2; e.has(n); l++)
|
|
169
|
+
n = `${o.alias}${l}`;
|
|
170
|
+
} else if (s.length > 0 || e.has(t.name)) {
|
|
171
|
+
for (let l = 2; ; l++)
|
|
172
|
+
if (!e.has(`${t.name}${l}`)) {
|
|
173
|
+
n = `${t.name}${l}`;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const a = r.tables.length, i = o.position ?? {
|
|
178
|
+
x: 24 + a % 4 * (b.width + b.gapX),
|
|
179
|
+
y: 24 + Math.floor(a / 4) * 280
|
|
180
|
+
}, u = o.select ?? "none", d = p("t"), g = {
|
|
181
|
+
id: d,
|
|
182
|
+
name: t.name,
|
|
183
|
+
...t.schema ? { schema: t.schema } : {},
|
|
184
|
+
...n ? { alias: n } : {},
|
|
185
|
+
position: i,
|
|
186
|
+
columns: t.columns.map((l) => ({
|
|
187
|
+
name: l.name,
|
|
188
|
+
dataType: l.dataType,
|
|
189
|
+
...l.isPrimaryKey ? { isPrimaryKey: !0 } : {},
|
|
190
|
+
...l.isForeignKey ? { isForeignKey: !0 } : {},
|
|
191
|
+
selected: u === "all" || Array.isArray(u) && u.includes(l.name)
|
|
192
|
+
}))
|
|
193
|
+
};
|
|
194
|
+
return { model: { ...r, tables: [...r.tables, g] }, tableId: d };
|
|
195
|
+
}
|
|
196
|
+
function _(r, t) {
|
|
197
|
+
const o = (s) => s && {
|
|
198
|
+
...s,
|
|
199
|
+
items: s.items.map((e) => e.kind === "group" ? o(e) : e).filter(
|
|
200
|
+
(e) => e.kind === "group" || ![e.left, e.right, e.right2].some((n) => n?.kind === "column" && n.tableId === t)
|
|
201
|
+
)
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
...r,
|
|
205
|
+
tables: r.tables.filter((s) => s.id !== t),
|
|
206
|
+
joins: r.joins.filter((s) => s.leftTableId !== t && s.rightTableId !== t),
|
|
207
|
+
conditions: r.conditions.filter((s) => s.tableId !== t),
|
|
208
|
+
sorts: r.sorts.filter((s) => s.tableId !== t),
|
|
209
|
+
groupBy: r.groupBy.filter((s) => s.tableId !== t),
|
|
210
|
+
filter: o(r.filter),
|
|
211
|
+
having: o(r.having),
|
|
212
|
+
computed: r.computed?.filter(
|
|
213
|
+
(s) => !s.args.some((e) => e.kind === "column" && e.tableId === t)
|
|
214
|
+
)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function K(r, t, o) {
|
|
218
|
+
return {
|
|
219
|
+
...r,
|
|
220
|
+
tables: r.tables.map(
|
|
221
|
+
(s) => o && s.id !== o ? s : {
|
|
222
|
+
...s,
|
|
223
|
+
columns: s.columns.map((e) => {
|
|
224
|
+
let n = e.selected;
|
|
225
|
+
return t === "all" ? n = !0 : t === "none" ? n = !1 : t === "invert" ? n = !e.selected : t === "keys" ? n = !!(e.isPrimaryKey || e.isForeignKey) || e.selected : typeof t == "object" ? n = t.names.includes(e.name) ? t.selected : e.selected : n = T(e.dataType) === t || e.selected, n === e.selected ? e : { ...e, selected: n };
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
const m = (r) => r.toLowerCase();
|
|
232
|
+
function R(r, t) {
|
|
233
|
+
const o = [], s = new Set(
|
|
234
|
+
r.joins.flatMap((e) => [
|
|
235
|
+
`${e.leftTableId}|${e.rightTableId}`,
|
|
236
|
+
`${e.rightTableId}|${e.leftTableId}`
|
|
237
|
+
])
|
|
238
|
+
);
|
|
239
|
+
for (const e of r.tables) {
|
|
240
|
+
const n = t.find((a) => a.name === e.name && a.schema === e.schema);
|
|
241
|
+
for (const a of e.columns) {
|
|
242
|
+
const i = n?.columns.find((u) => u.name === a.name)?.references;
|
|
243
|
+
for (const u of r.tables) {
|
|
244
|
+
if (u.id === e.id || s.has(`${e.id}|${u.id}`))
|
|
245
|
+
continue;
|
|
246
|
+
const d = u.columns.find((c) => c.isPrimaryKey)?.name ?? "Id", g = i && m(i.table) === m(u.name) && u.columns.some((c) => c.name === i.column), l = !i && a.isForeignKey !== !1 && m(a.name) === m(`${u.name}${d}`) && u.columns.some((c) => c.name === d);
|
|
247
|
+
if (g || l) {
|
|
248
|
+
const c = g ? i.column : d;
|
|
249
|
+
s.add(`${e.id}|${u.id}`), s.add(`${u.id}|${e.id}`), o.push({
|
|
250
|
+
join: {
|
|
251
|
+
type: "LEFT",
|
|
252
|
+
leftTableId: e.id,
|
|
253
|
+
leftColumn: a.name,
|
|
254
|
+
rightTableId: u.id,
|
|
255
|
+
rightColumn: c,
|
|
256
|
+
nest: "flat"
|
|
257
|
+
},
|
|
258
|
+
label: `${f(e)}.${a.name} = ${f(u)}.${c}`
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return o;
|
|
265
|
+
}
|
|
266
|
+
function D(r, t, o) {
|
|
267
|
+
const s = r.tables.find((i) => i.id === t);
|
|
268
|
+
if (!s)
|
|
269
|
+
return [];
|
|
270
|
+
const e = o.find((i) => i.name === s.name && i.schema === s.schema), n = s.columns.find((i) => i.isPrimaryKey)?.name ?? "Id", a = [];
|
|
271
|
+
for (const i of e?.columns ?? []) {
|
|
272
|
+
const u = i.references && o.find((d) => m(d.name) === m(i.references.table));
|
|
273
|
+
u && a.push({
|
|
274
|
+
fromTableId: t,
|
|
275
|
+
table: u,
|
|
276
|
+
fromColumn: i.name,
|
|
277
|
+
toColumn: i.references.column,
|
|
278
|
+
direction: "out"
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
for (const i of o)
|
|
282
|
+
for (const u of i.columns)
|
|
283
|
+
u.references && m(u.references.table) === m(s.name) && a.push({
|
|
284
|
+
fromTableId: t,
|
|
285
|
+
table: i,
|
|
286
|
+
fromColumn: u.references.column || n,
|
|
287
|
+
toColumn: u.name,
|
|
288
|
+
direction: "in"
|
|
289
|
+
});
|
|
290
|
+
return a;
|
|
291
|
+
}
|
|
292
|
+
function A(r, t) {
|
|
293
|
+
const o = r.tables.find((a) => a.id === t.fromTableId), s = t.direction === "out" ? t.fromColumn.replace(/_?id$/i, "") : "", e = w(r, t.table, {
|
|
294
|
+
alias: s && s.toLowerCase() !== t.table.name.toLowerCase() ? s : void 0,
|
|
295
|
+
position: o ? { x: o.position.x + b.width + b.gapX, y: o.position.y } : void 0,
|
|
296
|
+
select: "none"
|
|
297
|
+
}), n = {
|
|
298
|
+
id: p("j"),
|
|
299
|
+
type: "LEFT",
|
|
300
|
+
leftTableId: t.fromTableId,
|
|
301
|
+
leftColumn: t.fromColumn,
|
|
302
|
+
rightTableId: e.tableId,
|
|
303
|
+
rightColumn: t.toColumn,
|
|
304
|
+
nest: t.direction === "out" ? "object" : "list"
|
|
305
|
+
};
|
|
306
|
+
return { ...e.model, joins: [...e.model.joins, n] };
|
|
307
|
+
}
|
|
308
|
+
function q(r) {
|
|
309
|
+
const t = (a) => {
|
|
310
|
+
switch (a.operator) {
|
|
311
|
+
case "=":
|
|
312
|
+
return "eq";
|
|
313
|
+
case "!=":
|
|
314
|
+
return "ne";
|
|
315
|
+
case ">":
|
|
316
|
+
return "gt";
|
|
317
|
+
case ">=":
|
|
318
|
+
return "ge";
|
|
319
|
+
case "<":
|
|
320
|
+
return "lt";
|
|
321
|
+
case "<=":
|
|
322
|
+
return "le";
|
|
323
|
+
case "LIKE":
|
|
324
|
+
return "contains";
|
|
325
|
+
case "NOT LIKE":
|
|
326
|
+
return "notContains";
|
|
327
|
+
case "IN":
|
|
328
|
+
return "in";
|
|
329
|
+
case "NOT IN":
|
|
330
|
+
return "notIn";
|
|
331
|
+
case "IS NULL":
|
|
332
|
+
return "isEmpty";
|
|
333
|
+
case "IS NOT NULL":
|
|
334
|
+
return "isNotEmpty";
|
|
335
|
+
case "BETWEEN":
|
|
336
|
+
return "between";
|
|
337
|
+
}
|
|
338
|
+
}, o = (a) => {
|
|
339
|
+
const i = /^[@:]([A-Za-z_]\w*)$/.exec(a ?? "");
|
|
340
|
+
return i ? { kind: "parameter", name: i[1] } : { kind: "value", value: (a ?? "").replace(/^'(.*)'$/, "$1").replace(/^%|%$/g, "") };
|
|
341
|
+
}, s = (a) => ({
|
|
342
|
+
kind: "rule",
|
|
343
|
+
id: a.id,
|
|
344
|
+
left: { kind: "column", tableId: a.tableId, column: a.column },
|
|
345
|
+
operator: t(a),
|
|
346
|
+
...a.operator === "IN" || a.operator === "NOT IN" ? {
|
|
347
|
+
right: {
|
|
348
|
+
kind: "values",
|
|
349
|
+
values: a.value.replace(/^\(|\)$/g, "").split(",").map((i) => i.trim().replace(/^'(.*)'$/, "$1")).filter(Boolean)
|
|
350
|
+
}
|
|
351
|
+
} : a.operator === "IS NULL" || a.operator === "IS NOT NULL" ? {} : { right: o(a.value) },
|
|
352
|
+
...a.operator === "BETWEEN" ? { right2: o(a.value2) } : {}
|
|
353
|
+
}), e = y("AND");
|
|
354
|
+
let n;
|
|
355
|
+
return r.forEach((a, i) => {
|
|
356
|
+
const u = r[i + 1];
|
|
357
|
+
u?.logicalOperator === "OR" || n && a.logicalOperator === "OR" ? (n || (n = y("OR"), e.items.push(n)), n.items.push(s(a)), u?.logicalOperator !== "OR" && (n = void 0)) : e.items.push(s(a));
|
|
358
|
+
}), e;
|
|
359
|
+
}
|
|
360
|
+
function C(r, t, o) {
|
|
361
|
+
const s = [];
|
|
362
|
+
for (const e of r.items)
|
|
363
|
+
if (e.id === t) {
|
|
364
|
+
const n = o(e);
|
|
365
|
+
n && s.push(n);
|
|
366
|
+
} else
|
|
367
|
+
s.push(e.kind === "group" ? C(e, t, o) : e);
|
|
368
|
+
return { ...r, items: s };
|
|
369
|
+
}
|
|
370
|
+
export {
|
|
371
|
+
b as DESIGN_CARD,
|
|
372
|
+
h as NICE_QUERY_OPERATORS,
|
|
373
|
+
v as NICE_SQL_DIALECTS,
|
|
374
|
+
I as NICE_SQL_FUNCTIONS,
|
|
375
|
+
A as addRelatedTable,
|
|
376
|
+
w as addTableInstance,
|
|
377
|
+
q as conditionsToFilter,
|
|
378
|
+
p as designId,
|
|
379
|
+
y as emptyFilterGroup,
|
|
380
|
+
F as emptyQueryDesign,
|
|
381
|
+
k as filterRuleCount,
|
|
382
|
+
L as listJoinOf,
|
|
383
|
+
$ as nestNameOf,
|
|
384
|
+
x as nestPathOf,
|
|
385
|
+
E as operatorsFor,
|
|
386
|
+
S as outputColumns,
|
|
387
|
+
K as pickColumns,
|
|
388
|
+
j as queryParameterNames,
|
|
389
|
+
D as relatedTables,
|
|
390
|
+
_ as removeTable,
|
|
391
|
+
O as rootTableId,
|
|
392
|
+
R as suggestJoins,
|
|
393
|
+
f as tableHandleOf,
|
|
394
|
+
C as updateFilterNode,
|
|
395
|
+
T as valueTypeOf
|
|
396
|
+
};
|