drizzle-cube 0.1.3 → 0.1.4
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 +24 -2
- package/dist/adapters/hono/index.d.ts +5 -1
- package/dist/adapters/hono/index.js +187 -93
- package/dist/client/client/CubeClient.d.ts +14 -0
- package/dist/client/components/AnalyticsDashboard.d.ts +2 -0
- package/dist/client/components/AnalyticsPage.d.ts +1 -0
- package/dist/client/components/AnalyticsPortlet.d.ts +6 -0
- package/dist/client/components/ChartConfigEditor.d.ts +8 -0
- package/dist/client/components/ChartErrorBoundary.d.ts +21 -0
- package/dist/client/components/DashboardEditModal.d.ts +14 -0
- package/dist/client/components/DashboardGrid.d.ts +11 -0
- package/dist/client/components/Modal.d.ts +15 -0
- package/dist/client/components/PortletContainer.d.ts +10 -0
- package/dist/client/components/PortletEditModal.d.ts +12 -0
- package/dist/client/components/charts/AreaChart.d.ts +2 -0
- package/dist/client/components/charts/BarChart.d.ts +2 -0
- package/dist/client/components/charts/ChartContainer.d.ts +7 -0
- package/dist/client/components/charts/ChartLegend.d.ts +7 -0
- package/dist/client/components/charts/ChartTooltip.d.ts +7 -0
- package/dist/client/components/charts/DataTable.d.ts +2 -0
- package/dist/client/components/charts/LineChart.d.ts +2 -0
- package/dist/client/components/charts/PieChart.d.ts +2 -0
- package/dist/client/components/charts/RadarChart.d.ts +2 -0
- package/dist/client/components/charts/RadialBarChart.d.ts +2 -0
- package/dist/client/components/charts/ScatterChart.d.ts +2 -0
- package/dist/client/components/charts/TreeMapChart.d.ts +2 -0
- package/dist/client/components/charts/index.d.ts +13 -0
- package/dist/client/hooks/useCubeQuery.d.ts +8 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +23813 -4
- package/dist/client/providers/CubeProvider.d.ts +15 -0
- package/dist/client/styles.css +1 -0
- package/dist/client/types.d.ts +111 -0
- package/dist/client/utils/chartConstants.d.ts +15 -0
- package/dist/client/utils/chartUtils.d.ts +9 -0
- package/dist/client/utils/index.d.ts +87 -0
- package/dist/server/index.d.ts +74 -1155
- package/dist/server/index.js +1036 -2842
- package/package.json +10 -3
package/dist/server/index.js
CHANGED
|
@@ -1,168 +1,249 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { parse as
|
|
6
|
-
function
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var k = (s, e, t) => e in s ? U(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var E = (s, e, t) => k(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { sql as f, and as p, eq as _, count as $, max as B, min as O, avg as R, sum as I, countDistinct as Y, or as J, gt as A, lt as F, gte as w, lte as C, isNull as W, isNotNull as K, notInArray as H, ne as V, inArray as Z } from "drizzle-orm";
|
|
5
|
+
import { parse as G, stringify as P } from "yaml";
|
|
6
|
+
function Ce(s, e) {
|
|
7
7
|
return {
|
|
8
8
|
...e,
|
|
9
9
|
name: e.name
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class x {
|
|
13
13
|
constructor(e, t) {
|
|
14
14
|
this.db = e, this.schema = t;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
18
|
-
async execute(e) {
|
|
17
|
+
class X extends x {
|
|
18
|
+
async execute(e, t) {
|
|
19
19
|
if (e && typeof e == "object") {
|
|
20
20
|
if (typeof e.execute == "function") {
|
|
21
|
-
const
|
|
22
|
-
return Array.isArray(
|
|
21
|
+
const n = await e.execute();
|
|
22
|
+
return Array.isArray(n) ? n.map((r) => this.convertNumericFields(r, t)) : n;
|
|
23
23
|
}
|
|
24
24
|
if (this.db && typeof this.db.execute == "function")
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
return Array.isArray(
|
|
28
|
-
} catch (
|
|
26
|
+
const n = await this.db.execute(e);
|
|
27
|
+
return Array.isArray(n) ? n.map((r) => this.convertNumericFields(r, t)) : n;
|
|
28
|
+
} catch (n) {
|
|
29
29
|
if (typeof e.getSQL == "function") {
|
|
30
|
-
const
|
|
31
|
-
return Array.isArray(
|
|
30
|
+
const r = e.getSQL(), a = await this.db.execute(r);
|
|
31
|
+
return Array.isArray(a) ? a.map((o) => this.convertNumericFields(o, t)) : a;
|
|
32
32
|
}
|
|
33
|
-
throw
|
|
33
|
+
throw n;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
if (!this.db.execute)
|
|
37
37
|
throw new Error("PostgreSQL database instance must have an execute method");
|
|
38
|
-
const
|
|
39
|
-
return Array.isArray(
|
|
38
|
+
const i = await this.db.execute(e);
|
|
39
|
+
return Array.isArray(i) ? i.map((n) => this.convertNumericFields(n, t)) : i;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Convert numeric string fields to numbers
|
|
42
|
+
* Convert numeric string fields to numbers (only for measure fields)
|
|
43
43
|
*/
|
|
44
|
-
convertNumericFields(e) {
|
|
44
|
+
convertNumericFields(e, t) {
|
|
45
45
|
if (!e || typeof e != "object") return e;
|
|
46
|
-
const
|
|
47
|
-
for (const [
|
|
48
|
-
|
|
49
|
-
return
|
|
46
|
+
const i = {};
|
|
47
|
+
for (const [n, r] of Object.entries(e))
|
|
48
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(r) : i[n] = r;
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Coerce a value to a number if it represents a numeric type
|
|
53
|
+
*/
|
|
54
|
+
coerceToNumber(e) {
|
|
55
|
+
var t, i;
|
|
56
|
+
if (e == null || typeof e == "number") return e;
|
|
57
|
+
if (typeof e == "bigint") return Number(e);
|
|
58
|
+
if (e && typeof e == "object") {
|
|
59
|
+
if (typeof e.toString == "function") {
|
|
60
|
+
const n = e.toString();
|
|
61
|
+
if (/^-?\d+(\.\d+)?$/.test(n))
|
|
62
|
+
return n.includes(".") ? parseFloat(n) : parseInt(n, 10);
|
|
63
|
+
}
|
|
64
|
+
if (((t = e.constructor) == null ? void 0 : t.name) === "Numeric" || ((i = e.constructor) == null ? void 0 : i.name) === "Decimal" || "digits" in e || "sign" in e) {
|
|
65
|
+
const n = e.toString();
|
|
66
|
+
return parseFloat(n);
|
|
67
|
+
}
|
|
68
|
+
return e;
|
|
69
|
+
}
|
|
70
|
+
if (typeof e == "string") {
|
|
71
|
+
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
72
|
+
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
73
|
+
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
74
|
+
return parseFloat(e);
|
|
75
|
+
}
|
|
76
|
+
return e;
|
|
50
77
|
}
|
|
51
78
|
getEngineType() {
|
|
52
79
|
return "postgres";
|
|
53
80
|
}
|
|
54
81
|
}
|
|
55
|
-
class
|
|
56
|
-
async execute(e) {
|
|
57
|
-
if (e && typeof e == "object" && typeof e.execute == "function")
|
|
58
|
-
|
|
82
|
+
class q extends x {
|
|
83
|
+
async execute(e, t) {
|
|
84
|
+
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
85
|
+
const i = await e.execute();
|
|
86
|
+
return Array.isArray(i) ? i.map((n) => this.convertNumericFields(n, t)) : i;
|
|
87
|
+
}
|
|
59
88
|
try {
|
|
60
|
-
if (this.db.all)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
if (this.db.all) {
|
|
90
|
+
const i = this.db.all(e);
|
|
91
|
+
return Array.isArray(i) ? i.map((n) => this.convertNumericFields(n, t)) : i;
|
|
92
|
+
} else {
|
|
93
|
+
if (this.db.run)
|
|
94
|
+
return this.db.run(e);
|
|
95
|
+
throw new Error("SQLite database instance must have an all() or run() method");
|
|
96
|
+
}
|
|
97
|
+
} catch (i) {
|
|
98
|
+
throw new Error(`SQLite execution failed: ${i instanceof Error ? i.message : "Unknown error"}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Convert numeric string fields to numbers (only for measure fields)
|
|
103
|
+
*/
|
|
104
|
+
convertNumericFields(e, t) {
|
|
105
|
+
if (!e || typeof e != "object") return e;
|
|
106
|
+
const i = {};
|
|
107
|
+
for (const [n, r] of Object.entries(e))
|
|
108
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(r) : i[n] = r;
|
|
109
|
+
return i;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Coerce a value to a number if it represents a numeric type
|
|
113
|
+
*/
|
|
114
|
+
coerceToNumber(e) {
|
|
115
|
+
if (e == null || typeof e == "number") return e;
|
|
116
|
+
if (typeof e == "string") {
|
|
117
|
+
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
118
|
+
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
119
|
+
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
120
|
+
return parseFloat(e);
|
|
67
121
|
}
|
|
122
|
+
return e;
|
|
68
123
|
}
|
|
69
124
|
getEngineType() {
|
|
70
125
|
return "sqlite";
|
|
71
126
|
}
|
|
72
127
|
}
|
|
73
|
-
class
|
|
74
|
-
async execute(e) {
|
|
75
|
-
if (e && typeof e == "object" && typeof e.execute == "function")
|
|
76
|
-
|
|
128
|
+
class ee extends x {
|
|
129
|
+
async execute(e, t) {
|
|
130
|
+
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
131
|
+
const n = await e.execute();
|
|
132
|
+
return Array.isArray(n) ? n.map((r) => this.convertNumericFields(r, t)) : n;
|
|
133
|
+
}
|
|
77
134
|
if (!this.db.execute)
|
|
78
135
|
throw new Error("MySQL database instance must have an execute method");
|
|
79
|
-
|
|
136
|
+
const i = await this.db.execute(e);
|
|
137
|
+
return Array.isArray(i) ? i.map((n) => this.convertNumericFields(n, t)) : i;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Convert numeric string fields to numbers (only for measure fields)
|
|
141
|
+
*/
|
|
142
|
+
convertNumericFields(e, t) {
|
|
143
|
+
if (!e || typeof e != "object") return e;
|
|
144
|
+
const i = {};
|
|
145
|
+
for (const [n, r] of Object.entries(e))
|
|
146
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(r) : i[n] = r;
|
|
147
|
+
return i;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Coerce a value to a number if it represents a numeric type
|
|
151
|
+
*/
|
|
152
|
+
coerceToNumber(e) {
|
|
153
|
+
if (e == null || typeof e == "number") return e;
|
|
154
|
+
if (typeof e == "string") {
|
|
155
|
+
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
156
|
+
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
157
|
+
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
158
|
+
return parseFloat(e);
|
|
159
|
+
}
|
|
160
|
+
return e;
|
|
80
161
|
}
|
|
81
162
|
getEngineType() {
|
|
82
163
|
return "mysql";
|
|
83
164
|
}
|
|
84
165
|
}
|
|
85
|
-
function
|
|
86
|
-
return new
|
|
166
|
+
function S(s, e) {
|
|
167
|
+
return new X(s, e);
|
|
87
168
|
}
|
|
88
|
-
function
|
|
89
|
-
return new
|
|
169
|
+
function M(s, e) {
|
|
170
|
+
return new q(s, e);
|
|
90
171
|
}
|
|
91
|
-
function
|
|
92
|
-
return new
|
|
172
|
+
function te(s, e) {
|
|
173
|
+
return new ee(s, e);
|
|
93
174
|
}
|
|
94
|
-
function
|
|
175
|
+
function j(s, e, t) {
|
|
95
176
|
if (t)
|
|
96
177
|
switch (t) {
|
|
97
178
|
case "postgres":
|
|
98
|
-
return
|
|
179
|
+
return S(s, e);
|
|
99
180
|
case "mysql":
|
|
100
|
-
return
|
|
181
|
+
return te(s, e);
|
|
101
182
|
case "sqlite":
|
|
102
|
-
return
|
|
183
|
+
return M(s, e);
|
|
103
184
|
}
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
106
|
-
if (
|
|
107
|
-
return
|
|
185
|
+
if (s.all && s.run)
|
|
186
|
+
return M(s, e);
|
|
187
|
+
if (s.execute)
|
|
188
|
+
return S(s, e);
|
|
108
189
|
throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
109
190
|
}
|
|
110
|
-
function
|
|
191
|
+
function Ne(s, e) {
|
|
111
192
|
return {
|
|
112
|
-
name:
|
|
193
|
+
name: s,
|
|
113
194
|
...e
|
|
114
195
|
};
|
|
115
196
|
}
|
|
116
|
-
function
|
|
117
|
-
return typeof
|
|
197
|
+
function b(s, e) {
|
|
198
|
+
return typeof s == "function" ? s(e) : s;
|
|
118
199
|
}
|
|
119
|
-
function
|
|
200
|
+
function ne(s, e, t) {
|
|
120
201
|
return {
|
|
121
|
-
...
|
|
202
|
+
...s,
|
|
122
203
|
cubes: e,
|
|
123
204
|
currentCube: t
|
|
124
205
|
};
|
|
125
206
|
}
|
|
126
|
-
class
|
|
207
|
+
class ie {
|
|
127
208
|
/**
|
|
128
209
|
* Analyze a semantic query to determine which cubes are involved
|
|
129
210
|
*/
|
|
130
211
|
analyzeCubeUsage(e) {
|
|
131
212
|
const t = /* @__PURE__ */ new Set();
|
|
132
213
|
if (e.measures)
|
|
133
|
-
for (const
|
|
134
|
-
const [
|
|
135
|
-
t.add(
|
|
214
|
+
for (const i of e.measures) {
|
|
215
|
+
const [n] = i.split(".");
|
|
216
|
+
t.add(n);
|
|
136
217
|
}
|
|
137
218
|
if (e.dimensions)
|
|
138
|
-
for (const
|
|
139
|
-
const [
|
|
140
|
-
t.add(
|
|
219
|
+
for (const i of e.dimensions) {
|
|
220
|
+
const [n] = i.split(".");
|
|
221
|
+
t.add(n);
|
|
141
222
|
}
|
|
142
223
|
if (e.timeDimensions)
|
|
143
|
-
for (const
|
|
144
|
-
const [
|
|
145
|
-
t.add(
|
|
224
|
+
for (const i of e.timeDimensions) {
|
|
225
|
+
const [n] = i.dimension.split(".");
|
|
226
|
+
t.add(n);
|
|
146
227
|
}
|
|
147
228
|
return t;
|
|
148
229
|
}
|
|
149
230
|
/**
|
|
150
231
|
* Build a multi-cube query plan
|
|
151
232
|
*/
|
|
152
|
-
buildMultiCubeQueryPlan(e, t,
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
233
|
+
buildMultiCubeQueryPlan(e, t, i) {
|
|
234
|
+
const n = this.analyzeCubeUsage(t), r = Array.from(n);
|
|
235
|
+
if (r.length === 1)
|
|
155
236
|
throw new Error("Single cube query should use QueryExecutor directly");
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
throw new Error(`Primary cube '${
|
|
159
|
-
const
|
|
237
|
+
const a = this.choosePrimaryCube(r, t), o = e.get(a);
|
|
238
|
+
if (!o)
|
|
239
|
+
throw new Error(`Primary cube '${a}' not found`);
|
|
240
|
+
const c = this.buildJoinPlan(e, o, r, i.securityContext), l = this.buildMultiCubeSelections(e, t, i.securityContext), u = this.buildMultiCubeWhereConditions(e, t, i), m = this.buildMultiCubeGroupByFields(e, t, i.securityContext);
|
|
160
241
|
return {
|
|
161
|
-
primaryCube:
|
|
162
|
-
joinCubes:
|
|
163
|
-
selections:
|
|
242
|
+
primaryCube: o,
|
|
243
|
+
joinCubes: c,
|
|
244
|
+
selections: l,
|
|
164
245
|
whereConditions: u,
|
|
165
|
-
groupByFields:
|
|
246
|
+
groupByFields: m
|
|
166
247
|
};
|
|
167
248
|
}
|
|
168
249
|
/**
|
|
@@ -170,173 +251,173 @@ class yo {
|
|
|
170
251
|
*/
|
|
171
252
|
choosePrimaryCube(e, t) {
|
|
172
253
|
if (t.measures && t.measures.length > 0) {
|
|
173
|
-
const [
|
|
174
|
-
return
|
|
254
|
+
const [i] = t.measures[0].split(".");
|
|
255
|
+
return i;
|
|
175
256
|
}
|
|
176
257
|
if (t.dimensions && t.dimensions.length > 0) {
|
|
177
|
-
const [
|
|
178
|
-
return
|
|
258
|
+
const [i] = t.dimensions[0].split(".");
|
|
259
|
+
return i;
|
|
179
260
|
}
|
|
180
261
|
return e[0];
|
|
181
262
|
}
|
|
182
263
|
/**
|
|
183
264
|
* Build join plan for multi-cube query
|
|
184
265
|
*/
|
|
185
|
-
buildJoinPlan(e, t,
|
|
186
|
-
var
|
|
187
|
-
const
|
|
188
|
-
for (const
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
191
|
-
throw new Error(`Cube '${
|
|
192
|
-
const u = (
|
|
266
|
+
buildJoinPlan(e, t, i, n) {
|
|
267
|
+
var o;
|
|
268
|
+
const r = [], a = i.filter((c) => c !== t.name);
|
|
269
|
+
for (const c of a) {
|
|
270
|
+
const l = e.get(c);
|
|
271
|
+
if (!l)
|
|
272
|
+
throw new Error(`Cube '${c}' not found`);
|
|
273
|
+
const u = (o = t.joins) == null ? void 0 : o[c];
|
|
193
274
|
if (!u)
|
|
194
|
-
throw new Error(`No join definition found from '${t.name}' to '${
|
|
195
|
-
const
|
|
275
|
+
throw new Error(`No join definition found from '${t.name}' to '${c}'`);
|
|
276
|
+
const m = ne(
|
|
196
277
|
{
|
|
197
278
|
db: {},
|
|
198
279
|
// Will be filled in during execution
|
|
199
280
|
schema: {},
|
|
200
281
|
// Will be filled in during execution
|
|
201
|
-
securityContext:
|
|
282
|
+
securityContext: n
|
|
202
283
|
},
|
|
203
284
|
e,
|
|
204
|
-
|
|
205
|
-
),
|
|
206
|
-
|
|
207
|
-
cube:
|
|
208
|
-
alias: `${
|
|
285
|
+
l
|
|
286
|
+
), d = u.condition(m);
|
|
287
|
+
r.push({
|
|
288
|
+
cube: l,
|
|
289
|
+
alias: `${c.toLowerCase()}_cube`,
|
|
209
290
|
joinType: u.type || "left",
|
|
210
|
-
joinCondition:
|
|
291
|
+
joinCondition: d
|
|
211
292
|
});
|
|
212
293
|
}
|
|
213
|
-
return
|
|
294
|
+
return r;
|
|
214
295
|
}
|
|
215
296
|
/**
|
|
216
297
|
* Build selections across multiple cubes
|
|
217
298
|
*/
|
|
218
|
-
buildMultiCubeSelections(e, t,
|
|
219
|
-
const
|
|
299
|
+
buildMultiCubeSelections(e, t, i) {
|
|
300
|
+
const n = {}, r = {
|
|
220
301
|
db: {},
|
|
221
302
|
// Filled during execution
|
|
222
303
|
schema: {},
|
|
223
304
|
// Filled during execution
|
|
224
|
-
securityContext:
|
|
305
|
+
securityContext: i
|
|
225
306
|
};
|
|
226
307
|
if (t.dimensions)
|
|
227
|
-
for (const
|
|
228
|
-
const [
|
|
229
|
-
if (
|
|
230
|
-
const u =
|
|
231
|
-
|
|
308
|
+
for (const a of t.dimensions) {
|
|
309
|
+
const [o, c] = a.split("."), l = e.get(o);
|
|
310
|
+
if (l && l.dimensions[c]) {
|
|
311
|
+
const u = l.dimensions[c], m = b(u.sql, r);
|
|
312
|
+
n[a] = f`${m}`.as(a);
|
|
232
313
|
}
|
|
233
314
|
}
|
|
234
315
|
if (t.measures)
|
|
235
|
-
for (const
|
|
236
|
-
const [
|
|
237
|
-
if (
|
|
238
|
-
const u =
|
|
239
|
-
|
|
316
|
+
for (const a of t.measures) {
|
|
317
|
+
const [o, c] = a.split("."), l = e.get(o);
|
|
318
|
+
if (l && l.measures[c]) {
|
|
319
|
+
const u = l.measures[c], m = this.buildMeasureExpression(u, r);
|
|
320
|
+
n[a] = f`${m}`.as(a);
|
|
240
321
|
}
|
|
241
322
|
}
|
|
242
323
|
if (t.timeDimensions)
|
|
243
|
-
for (const
|
|
244
|
-
const [
|
|
245
|
-
if (
|
|
246
|
-
const u =
|
|
324
|
+
for (const a of t.timeDimensions) {
|
|
325
|
+
const [o, c] = a.dimension.split("."), l = e.get(o);
|
|
326
|
+
if (l && l.dimensions[c]) {
|
|
327
|
+
const u = l.dimensions[c], m = this.buildTimeDimensionExpression(
|
|
247
328
|
u.sql,
|
|
248
|
-
|
|
249
|
-
|
|
329
|
+
a.granularity,
|
|
330
|
+
r
|
|
250
331
|
);
|
|
251
|
-
|
|
332
|
+
n[a.dimension] = f`${m}`.as(a.dimension);
|
|
252
333
|
}
|
|
253
334
|
}
|
|
254
|
-
return
|
|
335
|
+
return n;
|
|
255
336
|
}
|
|
256
337
|
/**
|
|
257
338
|
* Build measure expression with aggregation (similar to single-cube approach)
|
|
258
339
|
*/
|
|
259
340
|
buildMeasureExpression(e, t) {
|
|
260
|
-
let
|
|
341
|
+
let i = b(e.sql, t);
|
|
261
342
|
if (e.filters && e.filters.length > 0) {
|
|
262
|
-
const
|
|
263
|
-
|
|
343
|
+
const n = e.filters.map((r) => r(t));
|
|
344
|
+
i = f`CASE WHEN ${p(...n)} THEN ${i} END`;
|
|
264
345
|
}
|
|
265
346
|
switch (e.type) {
|
|
266
347
|
case "count":
|
|
267
|
-
return
|
|
348
|
+
return f`COUNT(${i})`;
|
|
268
349
|
case "countDistinct":
|
|
269
|
-
return
|
|
350
|
+
return f`COUNT(DISTINCT ${i})`;
|
|
270
351
|
case "sum":
|
|
271
|
-
return
|
|
352
|
+
return f`SUM(${i})`;
|
|
272
353
|
case "avg":
|
|
273
|
-
return
|
|
354
|
+
return f`AVG(${i})`;
|
|
274
355
|
case "min":
|
|
275
|
-
return
|
|
356
|
+
return f`MIN(${i})`;
|
|
276
357
|
case "max":
|
|
277
|
-
return
|
|
358
|
+
return f`MAX(${i})`;
|
|
278
359
|
case "number":
|
|
279
|
-
return
|
|
360
|
+
return i;
|
|
280
361
|
default:
|
|
281
|
-
return
|
|
362
|
+
return f`COUNT(${i})`;
|
|
282
363
|
}
|
|
283
364
|
}
|
|
284
365
|
/**
|
|
285
366
|
* Build time dimension expression (similar to single-cube approach)
|
|
286
367
|
*/
|
|
287
|
-
buildTimeDimensionExpression(e, t,
|
|
288
|
-
const
|
|
368
|
+
buildTimeDimensionExpression(e, t, i) {
|
|
369
|
+
const n = b(e, i);
|
|
289
370
|
if (!t)
|
|
290
|
-
return
|
|
371
|
+
return n;
|
|
291
372
|
switch (t) {
|
|
292
373
|
case "year":
|
|
293
|
-
return
|
|
374
|
+
return f`DATE_TRUNC('year', ${n}::timestamp)`;
|
|
294
375
|
case "quarter":
|
|
295
|
-
return
|
|
376
|
+
return f`DATE_TRUNC('quarter', ${n}::timestamp)`;
|
|
296
377
|
case "month":
|
|
297
|
-
return
|
|
378
|
+
return f`DATE_TRUNC('month', ${n}::timestamp)`;
|
|
298
379
|
case "week":
|
|
299
|
-
return
|
|
380
|
+
return f`DATE_TRUNC('week', ${n}::timestamp)`;
|
|
300
381
|
case "day":
|
|
301
|
-
return
|
|
382
|
+
return f`DATE_TRUNC('day', ${n}::timestamp)`;
|
|
302
383
|
case "hour":
|
|
303
|
-
return
|
|
384
|
+
return f`DATE_TRUNC('hour', ${n}::timestamp)`;
|
|
304
385
|
case "minute":
|
|
305
|
-
return
|
|
386
|
+
return f`DATE_TRUNC('minute', ${n}::timestamp)`;
|
|
306
387
|
case "second":
|
|
307
|
-
return
|
|
388
|
+
return f`DATE_TRUNC('second', ${n}::timestamp)`;
|
|
308
389
|
default:
|
|
309
|
-
return
|
|
390
|
+
return n;
|
|
310
391
|
}
|
|
311
392
|
}
|
|
312
393
|
/**
|
|
313
394
|
* Build WHERE conditions for multi-cube query
|
|
314
395
|
*/
|
|
315
|
-
buildMultiCubeWhereConditions(e, t,
|
|
316
|
-
const
|
|
396
|
+
buildMultiCubeWhereConditions(e, t, i) {
|
|
397
|
+
const n = [];
|
|
317
398
|
if (t.filters) {
|
|
318
|
-
for (const
|
|
319
|
-
if ("member" in
|
|
320
|
-
const [
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
|
|
399
|
+
for (const r of t.filters)
|
|
400
|
+
if ("member" in r) {
|
|
401
|
+
const [a] = r.member.split("."), o = e.get(a);
|
|
402
|
+
if (o) {
|
|
403
|
+
const c = this.buildFilterCondition(r, o, i);
|
|
404
|
+
c && n.push(c);
|
|
324
405
|
}
|
|
325
406
|
}
|
|
326
407
|
}
|
|
327
|
-
return
|
|
408
|
+
return n;
|
|
328
409
|
}
|
|
329
410
|
/**
|
|
330
411
|
* Filter condition builder (would reuse logic from DrizzleExecutor)
|
|
331
412
|
*/
|
|
332
|
-
buildFilterCondition(e, t,
|
|
413
|
+
buildFilterCondition(e, t, i) {
|
|
333
414
|
if (e.operator === "equals" && e.values && e.values.length > 0) {
|
|
334
|
-
const [
|
|
335
|
-
if (
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
338
|
-
const
|
|
339
|
-
return
|
|
415
|
+
const [n, r] = e.member.split(".");
|
|
416
|
+
if (n === t.name) {
|
|
417
|
+
const a = t.dimensions[r] || t.measures[r];
|
|
418
|
+
if (a) {
|
|
419
|
+
const o = typeof a.sql == "function" ? a.sql(i) : a.sql;
|
|
420
|
+
return _(o, e.values[0]);
|
|
340
421
|
}
|
|
341
422
|
}
|
|
342
423
|
}
|
|
@@ -345,540 +426,717 @@ class yo {
|
|
|
345
426
|
/**
|
|
346
427
|
* Build GROUP BY fields for multi-cube query
|
|
347
428
|
*/
|
|
348
|
-
buildMultiCubeGroupByFields(e, t,
|
|
349
|
-
const
|
|
429
|
+
buildMultiCubeGroupByFields(e, t, i) {
|
|
430
|
+
const n = [];
|
|
350
431
|
if (!(t.measures && t.measures.length > 0))
|
|
351
432
|
return [];
|
|
352
|
-
const
|
|
433
|
+
const a = {
|
|
353
434
|
db: {},
|
|
354
435
|
schema: {},
|
|
355
|
-
securityContext:
|
|
436
|
+
securityContext: i
|
|
356
437
|
};
|
|
357
438
|
if (t.dimensions)
|
|
358
|
-
for (const
|
|
359
|
-
const [
|
|
360
|
-
if (u && u.dimensions[
|
|
361
|
-
const
|
|
362
|
-
|
|
439
|
+
for (const o of t.dimensions) {
|
|
440
|
+
const [c, l] = o.split("."), u = e.get(c);
|
|
441
|
+
if (u && u.dimensions[l]) {
|
|
442
|
+
const m = u.dimensions[l], d = b(m.sql, a);
|
|
443
|
+
n.push(d);
|
|
363
444
|
}
|
|
364
445
|
}
|
|
365
446
|
if (t.timeDimensions)
|
|
366
|
-
for (const
|
|
367
|
-
const [
|
|
368
|
-
if (u && u.dimensions[
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
447
|
+
for (const o of t.timeDimensions) {
|
|
448
|
+
const [c, l] = o.dimension.split("."), u = e.get(c);
|
|
449
|
+
if (u && u.dimensions[l]) {
|
|
450
|
+
const m = u.dimensions[l], d = this.buildTimeDimensionExpression(
|
|
451
|
+
m.sql,
|
|
452
|
+
o.granularity,
|
|
453
|
+
a
|
|
373
454
|
);
|
|
374
|
-
|
|
455
|
+
n.push(d);
|
|
375
456
|
}
|
|
376
457
|
}
|
|
377
|
-
return
|
|
458
|
+
return n;
|
|
378
459
|
}
|
|
379
460
|
}
|
|
380
|
-
class
|
|
461
|
+
class y {
|
|
381
462
|
constructor(e) {
|
|
382
|
-
|
|
383
|
-
this.dbExecutor = e, this.multiCubeBuilder = new
|
|
463
|
+
E(this, "multiCubeBuilder");
|
|
464
|
+
this.dbExecutor = e, this.multiCubeBuilder = new ie();
|
|
384
465
|
}
|
|
385
466
|
/**
|
|
386
467
|
* Unified query execution method that handles both single and multi-cube queries
|
|
387
468
|
*/
|
|
388
|
-
async execute(e, t,
|
|
469
|
+
async execute(e, t, i) {
|
|
389
470
|
try {
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
471
|
+
const n = v(e, t);
|
|
472
|
+
if (!n.isValid)
|
|
473
|
+
throw new Error(`Query validation failed: ${n.errors.join(", ")}`);
|
|
474
|
+
const r = this.multiCubeBuilder.analyzeCubeUsage(t);
|
|
475
|
+
if (r.size === 0)
|
|
392
476
|
throw new Error("No cubes found for query");
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
if (!
|
|
396
|
-
throw new Error(`Cube '${
|
|
397
|
-
return this.executeSingleCube(
|
|
477
|
+
if (r.size === 1) {
|
|
478
|
+
const a = Array.from(r)[0], o = e.get(a);
|
|
479
|
+
if (!o)
|
|
480
|
+
throw new Error(`Cube '${a}' not found`);
|
|
481
|
+
return this.executeSingleCube(o, t, i);
|
|
398
482
|
} else
|
|
399
|
-
return this.executeMultiCube(e, t,
|
|
400
|
-
} catch (
|
|
401
|
-
throw new Error(`Query execution failed: ${
|
|
483
|
+
return this.executeMultiCube(e, t, i);
|
|
484
|
+
} catch (n) {
|
|
485
|
+
throw new Error(`Query execution failed: ${n instanceof Error ? n.message : "Unknown error"}`);
|
|
402
486
|
}
|
|
403
487
|
}
|
|
404
488
|
/**
|
|
405
489
|
* Legacy interface for single cube queries
|
|
406
490
|
*/
|
|
407
|
-
async executeQuery(e, t,
|
|
408
|
-
const
|
|
409
|
-
return
|
|
491
|
+
async executeQuery(e, t, i) {
|
|
492
|
+
const n = /* @__PURE__ */ new Map();
|
|
493
|
+
return n.set(e.name, e), this.execute(n, t, i);
|
|
410
494
|
}
|
|
411
495
|
/**
|
|
412
496
|
* Execute a single cube query
|
|
413
497
|
*/
|
|
414
|
-
async executeSingleCube(e, t,
|
|
415
|
-
return this.executeCube(e, t,
|
|
498
|
+
async executeSingleCube(e, t, i) {
|
|
499
|
+
return this.executeCube(e, t, i);
|
|
416
500
|
}
|
|
417
501
|
/**
|
|
418
502
|
* Execute a Cube query (dynamic query building)
|
|
419
503
|
*/
|
|
420
|
-
async executeCube(e, t,
|
|
504
|
+
async executeCube(e, t, i) {
|
|
421
505
|
try {
|
|
422
|
-
const
|
|
506
|
+
const n = {
|
|
423
507
|
db: this.dbExecutor.db,
|
|
424
508
|
schema: this.dbExecutor.schema,
|
|
425
|
-
securityContext:
|
|
426
|
-
},
|
|
427
|
-
let
|
|
428
|
-
if (
|
|
429
|
-
for (const h of
|
|
509
|
+
securityContext: i
|
|
510
|
+
}, r = e.sql(n), a = this.buildSelections(e, t, n);
|
|
511
|
+
let o = n.db.select(a).from(r.from);
|
|
512
|
+
if (r.joins)
|
|
513
|
+
for (const h of r.joins)
|
|
430
514
|
switch (h.type || "left") {
|
|
431
515
|
case "left":
|
|
432
|
-
|
|
516
|
+
o = o.leftJoin(h.table, h.on);
|
|
433
517
|
break;
|
|
434
518
|
case "inner":
|
|
435
|
-
|
|
519
|
+
o = o.innerJoin(h.table, h.on);
|
|
436
520
|
break;
|
|
437
521
|
case "right":
|
|
438
|
-
|
|
522
|
+
o = o.rightJoin(h.table, h.on);
|
|
439
523
|
break;
|
|
440
524
|
case "full":
|
|
441
|
-
|
|
525
|
+
o = o.fullJoin(h.table, h.on);
|
|
442
526
|
break;
|
|
443
527
|
}
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
const h =
|
|
448
|
-
|
|
528
|
+
r.where && (o = o.where(r.where));
|
|
529
|
+
const c = this.buildWhereConditions(e, t, n);
|
|
530
|
+
if (c.length > 0) {
|
|
531
|
+
const h = c.length === 1 ? c[0] : p(...c);
|
|
532
|
+
o = o.where(h);
|
|
449
533
|
}
|
|
450
|
-
const
|
|
451
|
-
|
|
534
|
+
const l = this.buildGroupByFields(e, t, n);
|
|
535
|
+
l.length > 0 && (o = o.groupBy(...l));
|
|
452
536
|
const u = this.buildOrderBy(t);
|
|
453
|
-
u.length > 0 && (
|
|
454
|
-
|
|
537
|
+
if (u.length > 0 && (o = o.orderBy(...u)), t.limit !== void 0) {
|
|
538
|
+
if (t.limit < 0)
|
|
539
|
+
throw new Error("Limit must be non-negative");
|
|
540
|
+
o = o.limit(t.limit);
|
|
541
|
+
}
|
|
542
|
+
if (t.offset !== void 0) {
|
|
543
|
+
if (t.offset < 0)
|
|
544
|
+
throw new Error("Offset must be non-negative");
|
|
545
|
+
o = o.offset(t.offset);
|
|
546
|
+
}
|
|
547
|
+
const m = t.measures || [], d = await this.dbExecutor.execute(o, m), Q = Array.isArray(d) ? d.map((h) => {
|
|
548
|
+
const N = { ...h };
|
|
549
|
+
if (t.timeDimensions) {
|
|
550
|
+
for (const D of t.timeDimensions)
|
|
551
|
+
if (D.dimension in N) {
|
|
552
|
+
let g = N[D.dimension];
|
|
553
|
+
typeof g == "string" && g.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/) && (g = g.replace(" ", "T"), !g.endsWith("Z") && !g.includes("+") && (g = g + "Z")), N[D.dimension] = g;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return N;
|
|
557
|
+
}) : [d], z = this.generateAnnotations(e, t);
|
|
455
558
|
return {
|
|
456
|
-
data:
|
|
457
|
-
annotation:
|
|
559
|
+
data: Q,
|
|
560
|
+
annotation: z
|
|
458
561
|
};
|
|
459
|
-
} catch (
|
|
460
|
-
throw new Error(`Cube query execution failed: ${
|
|
562
|
+
} catch (n) {
|
|
563
|
+
throw new Error(`Cube query execution failed: ${n instanceof Error ? n.message : "Unknown error"}`);
|
|
461
564
|
}
|
|
462
565
|
}
|
|
463
566
|
/**
|
|
464
567
|
* Execute multi-cube query using JOIN resolution
|
|
465
568
|
*/
|
|
466
|
-
async executeMultiCube(e, t,
|
|
467
|
-
const i = {
|
|
569
|
+
async executeMultiCube(e, t, i) {
|
|
570
|
+
const n = this.buildMultiCubeQuery(e, t, i), r = t.measures || [], a = await this.dbExecutor.execute(n, r), o = {
|
|
571
|
+
db: this.dbExecutor.db,
|
|
572
|
+
schema: this.dbExecutor.schema,
|
|
573
|
+
securityContext: i
|
|
574
|
+
}, c = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, o), l = this.generateMultiCubeAnnotations(c, t);
|
|
575
|
+
return {
|
|
576
|
+
data: Array.isArray(a) ? a : [a],
|
|
577
|
+
annotation: l
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Generate raw SQL for debugging (without execution)
|
|
582
|
+
*/
|
|
583
|
+
async generateSQL(e, t, i) {
|
|
584
|
+
return this.generateCubeSQL(e, t, i);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Generate raw SQL for multi-cube queries without execution
|
|
588
|
+
*/
|
|
589
|
+
async generateMultiCubeSQL(e, t, i) {
|
|
590
|
+
const r = this.buildMultiCubeQuery(e, t, i).toSQL();
|
|
591
|
+
return {
|
|
592
|
+
sql: r.sql,
|
|
593
|
+
params: r.params
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Build multi-cube query (extracted from executeMultiCube for reuse)
|
|
598
|
+
*/
|
|
599
|
+
buildMultiCubeQuery(e, t, i) {
|
|
600
|
+
const n = {
|
|
468
601
|
db: this.dbExecutor.db,
|
|
469
602
|
schema: this.dbExecutor.schema,
|
|
470
|
-
securityContext:
|
|
471
|
-
},
|
|
472
|
-
let
|
|
473
|
-
if (
|
|
474
|
-
for (const
|
|
475
|
-
switch (
|
|
603
|
+
securityContext: i
|
|
604
|
+
}, r = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, n), a = r.primaryCube.sql(n);
|
|
605
|
+
let o = n.db.select(r.selections).from(a.from);
|
|
606
|
+
if (a.joins)
|
|
607
|
+
for (const u of a.joins)
|
|
608
|
+
switch (u.type || "left") {
|
|
476
609
|
case "left":
|
|
477
|
-
|
|
610
|
+
o = o.leftJoin(u.table, u.on);
|
|
478
611
|
break;
|
|
479
612
|
case "inner":
|
|
480
|
-
|
|
613
|
+
o = o.innerJoin(u.table, u.on);
|
|
481
614
|
break;
|
|
482
615
|
case "right":
|
|
483
|
-
|
|
616
|
+
o = o.rightJoin(u.table, u.on);
|
|
484
617
|
break;
|
|
485
618
|
case "full":
|
|
486
|
-
|
|
619
|
+
o = o.fullJoin(u.table, u.on);
|
|
487
620
|
break;
|
|
621
|
+
default:
|
|
622
|
+
o = o.leftJoin(u.table, u.on);
|
|
488
623
|
}
|
|
489
|
-
if (
|
|
490
|
-
for (const
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
624
|
+
if (r.joinCubes && r.joinCubes.length > 0)
|
|
625
|
+
for (const u of r.joinCubes) {
|
|
626
|
+
const m = u.cube.sql(n);
|
|
627
|
+
try {
|
|
628
|
+
switch (u.joinType || "left") {
|
|
629
|
+
case "left":
|
|
630
|
+
o = o.leftJoin(m.from, u.joinCondition);
|
|
631
|
+
break;
|
|
632
|
+
case "inner":
|
|
633
|
+
o = o.innerJoin(m.from, u.joinCondition);
|
|
634
|
+
break;
|
|
635
|
+
case "right":
|
|
636
|
+
o = o.rightJoin(m.from, u.joinCondition);
|
|
637
|
+
break;
|
|
638
|
+
case "full":
|
|
639
|
+
o = o.fullJoin(m.from, u.joinCondition);
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
} catch (d) {
|
|
643
|
+
console.warn(`Multi-cube join failed for ${u.cube.name}: ${d instanceof Error ? d.message : "Unknown error"}`);
|
|
505
644
|
}
|
|
506
645
|
}
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
|
|
646
|
+
const c = [];
|
|
647
|
+
if (a.where && c.push(a.where), r.whereConditions.length > 0 && c.push(...r.whereConditions), c.length > 0) {
|
|
648
|
+
const u = c.length === 1 ? c[0] : p(...c);
|
|
649
|
+
o = o.where(u);
|
|
511
650
|
}
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return this.generateCubeSQL(e, t, s);
|
|
651
|
+
r.groupByFields.length > 0 && (o = o.groupBy(...r.groupByFields));
|
|
652
|
+
const l = this.buildOrderBy(t);
|
|
653
|
+
if (l.length > 0 && (o = o.orderBy(...l)), t.limit !== void 0) {
|
|
654
|
+
if (t.limit < 0)
|
|
655
|
+
throw new Error("Limit must be non-negative");
|
|
656
|
+
o = o.limit(t.limit);
|
|
657
|
+
}
|
|
658
|
+
if (t.offset !== void 0) {
|
|
659
|
+
if (t.offset < 0)
|
|
660
|
+
throw new Error("Offset must be non-negative");
|
|
661
|
+
o = o.offset(t.offset);
|
|
662
|
+
}
|
|
663
|
+
return o;
|
|
526
664
|
}
|
|
527
665
|
/**
|
|
528
666
|
* Generate SQL for Cube
|
|
529
667
|
*/
|
|
530
|
-
async generateCubeSQL(e, t,
|
|
531
|
-
const
|
|
668
|
+
async generateCubeSQL(e, t, i) {
|
|
669
|
+
const n = {
|
|
532
670
|
db: this.dbExecutor.db,
|
|
533
671
|
schema: this.dbExecutor.schema,
|
|
534
|
-
securityContext:
|
|
535
|
-
},
|
|
536
|
-
let
|
|
537
|
-
if (
|
|
538
|
-
for (const
|
|
539
|
-
switch (
|
|
672
|
+
securityContext: i
|
|
673
|
+
}, r = e.sql(n), a = this.buildSelections(e, t, n);
|
|
674
|
+
let o = n.db.select(a).from(r.from);
|
|
675
|
+
if (r.joins)
|
|
676
|
+
for (const d of r.joins)
|
|
677
|
+
switch (d.type || "left") {
|
|
540
678
|
case "left":
|
|
541
|
-
|
|
679
|
+
o = o.leftJoin(d.table, d.on);
|
|
542
680
|
break;
|
|
543
681
|
case "inner":
|
|
544
|
-
|
|
682
|
+
o = o.innerJoin(d.table, d.on);
|
|
545
683
|
break;
|
|
546
684
|
case "right":
|
|
547
|
-
|
|
685
|
+
o = o.rightJoin(d.table, d.on);
|
|
548
686
|
break;
|
|
549
687
|
case "full":
|
|
550
|
-
|
|
688
|
+
o = o.fullJoin(d.table, d.on);
|
|
551
689
|
break;
|
|
552
690
|
}
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
const
|
|
557
|
-
|
|
691
|
+
r.where && (o = o.where(r.where));
|
|
692
|
+
const c = this.buildWhereConditions(e, t, n);
|
|
693
|
+
if (c.length > 0) {
|
|
694
|
+
const d = c.length === 1 ? c[0] : p(...c);
|
|
695
|
+
o = o.where(d);
|
|
558
696
|
}
|
|
559
|
-
const
|
|
560
|
-
|
|
697
|
+
const l = this.buildGroupByFields(e, t, n);
|
|
698
|
+
l.length > 0 && (o = o.groupBy(...l));
|
|
561
699
|
const u = this.buildOrderBy(t);
|
|
562
|
-
u.length > 0 && (
|
|
563
|
-
|
|
700
|
+
if (u.length > 0 && (o = o.orderBy(...u)), t.limit !== void 0) {
|
|
701
|
+
if (t.limit < 0)
|
|
702
|
+
throw new Error("Limit must be non-negative");
|
|
703
|
+
o = o.limit(t.limit);
|
|
704
|
+
}
|
|
705
|
+
if (t.offset !== void 0) {
|
|
706
|
+
if (t.offset < 0)
|
|
707
|
+
throw new Error("Offset must be non-negative");
|
|
708
|
+
o = o.offset(t.offset);
|
|
709
|
+
}
|
|
710
|
+
const m = o.toSQL();
|
|
564
711
|
return {
|
|
565
|
-
sql:
|
|
566
|
-
params:
|
|
712
|
+
sql: m.sql,
|
|
713
|
+
params: m.params
|
|
567
714
|
};
|
|
568
715
|
}
|
|
569
716
|
/**
|
|
570
717
|
* Build dynamic selections for Cube measures and dimensions
|
|
571
718
|
*/
|
|
572
|
-
buildSelections(e, t,
|
|
573
|
-
const
|
|
719
|
+
buildSelections(e, t, i) {
|
|
720
|
+
const n = {};
|
|
574
721
|
if (t.dimensions)
|
|
575
|
-
for (const
|
|
576
|
-
const [
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
|
|
722
|
+
for (const r of t.dimensions) {
|
|
723
|
+
const [a, o] = r.split(".");
|
|
724
|
+
if (a === e.name && e.dimensions[o]) {
|
|
725
|
+
const c = e.dimensions[o], l = b(c.sql, i);
|
|
726
|
+
n[r] = f`${l}`.as(r);
|
|
580
727
|
}
|
|
581
728
|
}
|
|
582
729
|
if (t.measures)
|
|
583
|
-
for (const
|
|
584
|
-
const [
|
|
585
|
-
if (
|
|
586
|
-
const
|
|
587
|
-
|
|
730
|
+
for (const r of t.measures) {
|
|
731
|
+
const [a, o] = r.split(".");
|
|
732
|
+
if (a === e.name && e.measures[o]) {
|
|
733
|
+
const c = e.measures[o], l = this.buildMeasureExpression(c, i);
|
|
734
|
+
n[r] = f`${l}`.as(r);
|
|
588
735
|
}
|
|
589
736
|
}
|
|
590
737
|
if (t.timeDimensions)
|
|
591
|
-
for (const
|
|
592
|
-
const [
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
738
|
+
for (const r of t.timeDimensions) {
|
|
739
|
+
const [a, o] = r.dimension.split(".");
|
|
740
|
+
if (a === e.name && e.dimensions[o]) {
|
|
741
|
+
const c = e.dimensions[o], l = this.buildTimeDimensionExpression(
|
|
742
|
+
c.sql,
|
|
743
|
+
r.granularity,
|
|
744
|
+
i
|
|
598
745
|
);
|
|
599
|
-
|
|
746
|
+
n[r.dimension] = f`${l}`.as(r.dimension);
|
|
600
747
|
}
|
|
601
748
|
}
|
|
602
|
-
return Object.keys(
|
|
749
|
+
return Object.keys(n).length === 0 && (n.count = $()), n;
|
|
603
750
|
}
|
|
604
751
|
/**
|
|
605
752
|
* Build measure expression with aggregation and filters for Cube
|
|
606
753
|
*/
|
|
607
754
|
buildMeasureExpression(e, t) {
|
|
608
|
-
let
|
|
755
|
+
let i = b(e.sql, t);
|
|
609
756
|
if (e.filters && e.filters.length > 0) {
|
|
610
|
-
const
|
|
611
|
-
|
|
757
|
+
const n = e.filters.map((r) => r(t));
|
|
758
|
+
i = f`CASE WHEN ${p(...n)} THEN ${i} END`;
|
|
612
759
|
}
|
|
613
760
|
switch (e.type) {
|
|
614
761
|
case "count":
|
|
615
|
-
return
|
|
762
|
+
return $(i);
|
|
616
763
|
case "countDistinct":
|
|
617
|
-
return
|
|
764
|
+
return Y(i);
|
|
618
765
|
case "sum":
|
|
619
|
-
return
|
|
766
|
+
return I(i);
|
|
620
767
|
case "avg":
|
|
621
|
-
return
|
|
768
|
+
return R(i);
|
|
622
769
|
case "min":
|
|
623
|
-
return
|
|
770
|
+
return O(i);
|
|
624
771
|
case "max":
|
|
625
|
-
return
|
|
772
|
+
return B(i);
|
|
626
773
|
case "number":
|
|
627
|
-
return
|
|
774
|
+
return i;
|
|
628
775
|
default:
|
|
629
|
-
return
|
|
776
|
+
return $(i);
|
|
630
777
|
}
|
|
631
778
|
}
|
|
632
779
|
/**
|
|
633
780
|
* Build time dimension expression with granularity
|
|
634
781
|
*/
|
|
635
|
-
buildTimeDimensionExpression(e, t,
|
|
636
|
-
const
|
|
782
|
+
buildTimeDimensionExpression(e, t, i) {
|
|
783
|
+
const n = b(e, i);
|
|
637
784
|
if (!t)
|
|
638
|
-
return
|
|
785
|
+
return f`${n}`;
|
|
639
786
|
switch (t) {
|
|
640
787
|
case "year":
|
|
641
|
-
return
|
|
788
|
+
return f`DATE_TRUNC('year', ${n}::timestamp)`;
|
|
642
789
|
case "quarter":
|
|
643
|
-
return
|
|
790
|
+
return f`DATE_TRUNC('quarter', ${n}::timestamp)`;
|
|
644
791
|
case "month":
|
|
645
|
-
return
|
|
792
|
+
return f`DATE_TRUNC('month', ${n}::timestamp)`;
|
|
646
793
|
case "week":
|
|
647
|
-
return
|
|
794
|
+
return f`DATE_TRUNC('week', ${n}::timestamp)`;
|
|
648
795
|
case "day":
|
|
649
|
-
return
|
|
796
|
+
return f`DATE_TRUNC('day', ${n}::timestamp)::timestamp`;
|
|
650
797
|
case "hour":
|
|
651
|
-
return
|
|
798
|
+
return f`DATE_TRUNC('hour', ${n}::timestamp)`;
|
|
652
799
|
case "minute":
|
|
653
|
-
return
|
|
800
|
+
return f`DATE_TRUNC('minute', ${n}::timestamp)`;
|
|
654
801
|
case "second":
|
|
655
|
-
return
|
|
802
|
+
return f`DATE_TRUNC('second', ${n}::timestamp)`;
|
|
656
803
|
default:
|
|
657
|
-
return
|
|
804
|
+
return n;
|
|
658
805
|
}
|
|
659
806
|
}
|
|
660
807
|
/**
|
|
661
808
|
* Build WHERE conditions from semantic query filters (Cube)
|
|
662
809
|
*/
|
|
663
|
-
buildWhereConditions(e, t,
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
810
|
+
buildWhereConditions(e, t, i) {
|
|
811
|
+
const n = [];
|
|
812
|
+
if (t.filters && t.filters.length > 0)
|
|
813
|
+
for (const r of t.filters) {
|
|
814
|
+
const a = this.processFilter(r, e, i);
|
|
815
|
+
a && n.push(a);
|
|
816
|
+
}
|
|
817
|
+
if (t.timeDimensions)
|
|
818
|
+
for (const r of t.timeDimensions) {
|
|
819
|
+
const [a, o] = r.dimension.split(".");
|
|
820
|
+
if (a === e.name && e.dimensions[o] && r.dateRange) {
|
|
821
|
+
const c = e.dimensions[o], l = b(c.sql, i), u = this.buildDateRangeCondition(l, r.dateRange);
|
|
822
|
+
u && n.push(u);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return n;
|
|
672
826
|
}
|
|
673
827
|
/**
|
|
674
828
|
* Process a single filter for Cube (basic or logical)
|
|
675
829
|
*/
|
|
676
|
-
processFilter(e, t,
|
|
830
|
+
processFilter(e, t, i) {
|
|
677
831
|
if ("and" in e || "or" in e) {
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
const u =
|
|
681
|
-
return u.length > 0 ?
|
|
832
|
+
const l = e;
|
|
833
|
+
if (l.and) {
|
|
834
|
+
const u = l.and.map((m) => this.processFilter(m, t, i)).filter((m) => m !== null);
|
|
835
|
+
return u.length > 0 ? p(...u) : null;
|
|
682
836
|
}
|
|
683
|
-
if (
|
|
684
|
-
const u =
|
|
685
|
-
return u.length > 0 ?
|
|
837
|
+
if (l.or) {
|
|
838
|
+
const u = l.or.map((m) => this.processFilter(m, t, i)).filter((m) => m !== null);
|
|
839
|
+
return u.length > 0 ? J(...u) : null;
|
|
686
840
|
}
|
|
687
841
|
}
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
const
|
|
691
|
-
if (!
|
|
692
|
-
const
|
|
693
|
-
return this.buildFilterCondition(
|
|
842
|
+
const n = e, [r, a] = n.member.split(".");
|
|
843
|
+
if (r !== t.name) return null;
|
|
844
|
+
const o = t.dimensions[a] || t.measures[a];
|
|
845
|
+
if (!o) return null;
|
|
846
|
+
const c = b(o.sql, i);
|
|
847
|
+
return this.buildFilterCondition(c, n.operator, n.values);
|
|
694
848
|
}
|
|
695
849
|
/**
|
|
696
850
|
* Build filter condition using Drizzle operators
|
|
697
851
|
*/
|
|
698
|
-
buildFilterCondition(e, t,
|
|
699
|
-
|
|
852
|
+
buildFilterCondition(e, t, i) {
|
|
853
|
+
if (!i || i.length === 0)
|
|
854
|
+
return t === "equals" ? f`FALSE` : null;
|
|
855
|
+
const n = i.filter((a) => !(a == null || a === "" || typeof a == "string" && a.includes("\0")));
|
|
856
|
+
if (n.length === 0 && !["set", "notSet"].includes(t))
|
|
857
|
+
return t === "equals" ? f`FALSE` : null;
|
|
858
|
+
const r = n[0];
|
|
700
859
|
switch (t) {
|
|
701
860
|
case "equals":
|
|
702
|
-
return
|
|
861
|
+
return n.length > 1 ? Z(e, n) : n.length === 1 ? _(e, r) : f`FALSE`;
|
|
703
862
|
case "notEquals":
|
|
704
|
-
return
|
|
863
|
+
return n.length > 1 ? H(e, n) : n.length === 1 ? V(e, r) : null;
|
|
705
864
|
case "contains":
|
|
706
|
-
return
|
|
865
|
+
return f`${e} ILIKE ${"%" + r + "%"}`;
|
|
707
866
|
case "notContains":
|
|
708
|
-
return
|
|
867
|
+
return f`${e} NOT ILIKE ${"%" + r + "%"}`;
|
|
709
868
|
case "startsWith":
|
|
710
|
-
return
|
|
869
|
+
return f`${e} ILIKE ${r + "%"}`;
|
|
711
870
|
case "endsWith":
|
|
712
|
-
return
|
|
871
|
+
return f`${e} ILIKE ${"%" + r}`;
|
|
713
872
|
case "gt":
|
|
714
|
-
return
|
|
873
|
+
return A(e, r);
|
|
715
874
|
case "gte":
|
|
716
|
-
return
|
|
875
|
+
return w(e, r);
|
|
717
876
|
case "lt":
|
|
718
|
-
return
|
|
877
|
+
return F(e, r);
|
|
719
878
|
case "lte":
|
|
720
|
-
return
|
|
879
|
+
return C(e, r);
|
|
721
880
|
case "set":
|
|
722
|
-
return
|
|
881
|
+
return K(e);
|
|
723
882
|
case "notSet":
|
|
724
|
-
return
|
|
883
|
+
return W(e);
|
|
725
884
|
case "inDateRange":
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
885
|
+
if (n.length >= 2) {
|
|
886
|
+
const a = this.normalizeDate(n[0]), o = this.normalizeDate(n[1]);
|
|
887
|
+
if (a && o)
|
|
888
|
+
return p(
|
|
889
|
+
w(e, a),
|
|
890
|
+
C(e, o)
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
return null;
|
|
894
|
+
case "beforeDate": {
|
|
895
|
+
const a = this.normalizeDate(r);
|
|
896
|
+
return a ? F(e, a) : null;
|
|
897
|
+
}
|
|
898
|
+
case "afterDate": {
|
|
899
|
+
const a = this.normalizeDate(r);
|
|
900
|
+
return a ? A(e, a) : null;
|
|
901
|
+
}
|
|
734
902
|
default:
|
|
735
903
|
return null;
|
|
736
904
|
}
|
|
737
905
|
}
|
|
906
|
+
/**
|
|
907
|
+
* Build date range condition for time dimensions
|
|
908
|
+
*/
|
|
909
|
+
buildDateRangeCondition(e, t) {
|
|
910
|
+
if (!t) return null;
|
|
911
|
+
if (Array.isArray(t) && t.length >= 2) {
|
|
912
|
+
const i = this.normalizeDate(t[0]), n = this.normalizeDate(t[1]);
|
|
913
|
+
return !i || !n ? null : p(
|
|
914
|
+
w(e, i),
|
|
915
|
+
C(e, n)
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
if (typeof t == "string") {
|
|
919
|
+
const i = this.parseRelativeDateRange(t);
|
|
920
|
+
if (i)
|
|
921
|
+
return p(
|
|
922
|
+
w(e, i.start),
|
|
923
|
+
C(e, i.end)
|
|
924
|
+
);
|
|
925
|
+
const n = this.normalizeDate(t);
|
|
926
|
+
if (!n) return null;
|
|
927
|
+
const r = new Date(n);
|
|
928
|
+
r.setUTCHours(0, 0, 0, 0);
|
|
929
|
+
const a = new Date(n);
|
|
930
|
+
return a.setUTCHours(23, 59, 59, 999), p(
|
|
931
|
+
w(e, r),
|
|
932
|
+
C(e, a)
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
return null;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Parse relative date range expressions like "last 7 days", "this month"
|
|
939
|
+
*/
|
|
940
|
+
parseRelativeDateRange(e) {
|
|
941
|
+
const t = /* @__PURE__ */ new Date(), i = e.toLowerCase().trim(), n = i.match(/^last\s+(\d+)\s+days?$/);
|
|
942
|
+
if (n) {
|
|
943
|
+
const o = parseInt(n[1], 10), c = new Date(t);
|
|
944
|
+
c.setDate(t.getDate() - o), c.setHours(0, 0, 0, 0);
|
|
945
|
+
const l = new Date(t);
|
|
946
|
+
return l.setHours(23, 59, 59, 999), { start: c, end: l };
|
|
947
|
+
}
|
|
948
|
+
if (i === "this month") {
|
|
949
|
+
const o = new Date(t.getFullYear(), t.getMonth(), 1, 0, 0, 0, 0), c = new Date(t.getFullYear(), t.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
950
|
+
return { start: o, end: c };
|
|
951
|
+
}
|
|
952
|
+
const r = i.match(/^last\s+(\d+)\s+months?$/);
|
|
953
|
+
if (r) {
|
|
954
|
+
const o = parseInt(r[1], 10), c = new Date(t.getFullYear(), t.getMonth() - o, 1, 0, 0, 0, 0), l = new Date(t);
|
|
955
|
+
return l.setHours(23, 59, 59, 999), { start: c, end: l };
|
|
956
|
+
}
|
|
957
|
+
if (i === "this year") {
|
|
958
|
+
const o = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0), c = new Date(t.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
959
|
+
return { start: o, end: c };
|
|
960
|
+
}
|
|
961
|
+
const a = i.match(/^last\s+(\d+)\s+years?$/);
|
|
962
|
+
if (a) {
|
|
963
|
+
const o = parseInt(a[1], 10), c = new Date(t.getFullYear() - o, 0, 1, 0, 0, 0, 0), l = new Date(t);
|
|
964
|
+
return l.setHours(23, 59, 59, 999), { start: c, end: l };
|
|
965
|
+
}
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Normalize date values to handle both string and Date objects
|
|
970
|
+
* For PostgreSQL timestamp fields, Drizzle expects Date objects
|
|
971
|
+
*/
|
|
972
|
+
normalizeDate(e) {
|
|
973
|
+
if (!e) return null;
|
|
974
|
+
if (e instanceof Date)
|
|
975
|
+
return isNaN(e.getTime()) ? null : e;
|
|
976
|
+
if (typeof e == "string") {
|
|
977
|
+
const i = new Date(e);
|
|
978
|
+
return isNaN(i.getTime()) ? null : i;
|
|
979
|
+
}
|
|
980
|
+
const t = new Date(e);
|
|
981
|
+
return isNaN(t.getTime()) ? null : t;
|
|
982
|
+
}
|
|
738
983
|
/**
|
|
739
984
|
* Build GROUP BY fields from dimensions and time dimensions (Cube)
|
|
740
985
|
*/
|
|
741
|
-
buildGroupByFields(e, t,
|
|
742
|
-
const
|
|
986
|
+
buildGroupByFields(e, t, i) {
|
|
987
|
+
const n = [];
|
|
743
988
|
if (t.dimensions)
|
|
744
|
-
for (const
|
|
745
|
-
const [
|
|
746
|
-
if (
|
|
747
|
-
const
|
|
748
|
-
|
|
989
|
+
for (const r of t.dimensions) {
|
|
990
|
+
const [a, o] = r.split(".");
|
|
991
|
+
if (a === e.name && e.dimensions[o]) {
|
|
992
|
+
const c = e.dimensions[o], l = b(c.sql, i);
|
|
993
|
+
n.push(l);
|
|
749
994
|
}
|
|
750
995
|
}
|
|
751
996
|
if (t.timeDimensions)
|
|
752
|
-
for (const
|
|
753
|
-
const [
|
|
754
|
-
if (
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
997
|
+
for (const r of t.timeDimensions) {
|
|
998
|
+
const [a, o] = r.dimension.split(".");
|
|
999
|
+
if (a === e.name && e.dimensions[o]) {
|
|
1000
|
+
const c = e.dimensions[o], l = this.buildTimeDimensionExpression(
|
|
1001
|
+
c.sql,
|
|
1002
|
+
r.granularity,
|
|
1003
|
+
i
|
|
759
1004
|
);
|
|
760
|
-
|
|
1005
|
+
n.push(l);
|
|
761
1006
|
}
|
|
762
1007
|
}
|
|
763
|
-
return
|
|
1008
|
+
return n;
|
|
764
1009
|
}
|
|
765
1010
|
/**
|
|
766
|
-
* Build ORDER BY clause
|
|
1011
|
+
* Build ORDER BY clause with automatic time dimension sorting
|
|
767
1012
|
*/
|
|
768
|
-
buildOrderBy(e) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1013
|
+
buildOrderBy(e, t) {
|
|
1014
|
+
var r;
|
|
1015
|
+
const i = [], n = t || [
|
|
1016
|
+
...e.measures || [],
|
|
1017
|
+
...e.dimensions || [],
|
|
1018
|
+
...((r = e.timeDimensions) == null ? void 0 : r.map((a) => a.dimension)) || []
|
|
1019
|
+
];
|
|
1020
|
+
if (e.order && Object.keys(e.order).length > 0)
|
|
1021
|
+
for (const [a, o] of Object.entries(e.order)) {
|
|
1022
|
+
if (!n.includes(a))
|
|
1023
|
+
throw new Error(`Cannot order by '${a}': field is not selected in the query`);
|
|
1024
|
+
const c = o === "desc" ? f`DESC` : f`ASC`;
|
|
1025
|
+
i.push(f`${f.identifier(a)} ${c}`);
|
|
1026
|
+
}
|
|
1027
|
+
if (e.timeDimensions && e.timeDimensions.length > 0) {
|
|
1028
|
+
const a = new Set(Object.keys(e.order || {})), o = [...e.timeDimensions].sort(
|
|
1029
|
+
(c, l) => c.dimension.localeCompare(l.dimension)
|
|
1030
|
+
);
|
|
1031
|
+
for (const c of o)
|
|
1032
|
+
a.has(c.dimension) || i.push(f`${f.identifier(c.dimension)} ASC`);
|
|
775
1033
|
}
|
|
776
|
-
return
|
|
1034
|
+
return i;
|
|
777
1035
|
}
|
|
778
1036
|
/**
|
|
779
1037
|
* Generate annotations for UI metadata
|
|
780
1038
|
*/
|
|
781
1039
|
generateAnnotations(e, t) {
|
|
782
|
-
const
|
|
1040
|
+
const i = {}, n = {}, r = {};
|
|
783
1041
|
if (t.measures)
|
|
784
|
-
for (const
|
|
785
|
-
const [
|
|
786
|
-
if (
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
title:
|
|
790
|
-
shortTitle:
|
|
791
|
-
type:
|
|
1042
|
+
for (const a of t.measures) {
|
|
1043
|
+
const [o, c] = a.split(".");
|
|
1044
|
+
if (o === e.name && e.measures[c]) {
|
|
1045
|
+
const l = e.measures[c];
|
|
1046
|
+
i[a] = {
|
|
1047
|
+
title: l.title || c,
|
|
1048
|
+
shortTitle: l.title || c,
|
|
1049
|
+
type: l.type
|
|
792
1050
|
};
|
|
793
1051
|
}
|
|
794
1052
|
}
|
|
795
1053
|
if (t.dimensions)
|
|
796
|
-
for (const
|
|
797
|
-
const [
|
|
798
|
-
if (
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
title:
|
|
802
|
-
shortTitle:
|
|
803
|
-
type:
|
|
1054
|
+
for (const a of t.dimensions) {
|
|
1055
|
+
const [o, c] = a.split(".");
|
|
1056
|
+
if (o === e.name && e.dimensions[c]) {
|
|
1057
|
+
const l = e.dimensions[c];
|
|
1058
|
+
n[a] = {
|
|
1059
|
+
title: l.title || c,
|
|
1060
|
+
shortTitle: l.title || c,
|
|
1061
|
+
type: l.type
|
|
804
1062
|
};
|
|
805
1063
|
}
|
|
806
1064
|
}
|
|
807
1065
|
if (t.timeDimensions)
|
|
808
|
-
for (const
|
|
809
|
-
const [
|
|
810
|
-
if (
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
title:
|
|
814
|
-
shortTitle:
|
|
815
|
-
type:
|
|
816
|
-
granularity:
|
|
1066
|
+
for (const a of t.timeDimensions) {
|
|
1067
|
+
const [o, c] = a.dimension.split(".");
|
|
1068
|
+
if (o === e.name && e.dimensions[c]) {
|
|
1069
|
+
const l = e.dimensions[c];
|
|
1070
|
+
r[a.dimension] = {
|
|
1071
|
+
title: l.title || c,
|
|
1072
|
+
shortTitle: l.title || c,
|
|
1073
|
+
type: l.type,
|
|
1074
|
+
granularity: a.granularity
|
|
817
1075
|
};
|
|
818
1076
|
}
|
|
819
1077
|
}
|
|
820
1078
|
return {
|
|
821
|
-
measures:
|
|
822
|
-
dimensions:
|
|
1079
|
+
measures: i,
|
|
1080
|
+
dimensions: n,
|
|
823
1081
|
segments: {},
|
|
824
|
-
timeDimensions:
|
|
1082
|
+
timeDimensions: r
|
|
825
1083
|
};
|
|
826
1084
|
}
|
|
827
1085
|
/**
|
|
828
1086
|
* Generate annotations for multi-cube queries
|
|
829
1087
|
*/
|
|
830
1088
|
generateMultiCubeAnnotations(e, t) {
|
|
831
|
-
const
|
|
832
|
-
if (e.joinCubes &&
|
|
833
|
-
for (const
|
|
834
|
-
const [
|
|
835
|
-
if (u && u.measures[
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
title:
|
|
839
|
-
shortTitle:
|
|
840
|
-
type:
|
|
1089
|
+
const i = {}, n = {}, r = {}, a = [e.primaryCube];
|
|
1090
|
+
if (e.joinCubes && a.push(...e.joinCubes.map((o) => o.cube)), t.measures)
|
|
1091
|
+
for (const o of t.measures) {
|
|
1092
|
+
const [c, l] = o.split("."), u = a.find((m) => m.name === c);
|
|
1093
|
+
if (u && u.measures[l]) {
|
|
1094
|
+
const m = u.measures[l];
|
|
1095
|
+
i[o] = {
|
|
1096
|
+
title: m.title || l,
|
|
1097
|
+
shortTitle: m.title || l,
|
|
1098
|
+
type: m.type
|
|
841
1099
|
};
|
|
842
1100
|
}
|
|
843
1101
|
}
|
|
844
1102
|
if (t.dimensions)
|
|
845
|
-
for (const
|
|
846
|
-
const [
|
|
847
|
-
if (u && u.dimensions[
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
title:
|
|
851
|
-
shortTitle:
|
|
852
|
-
type:
|
|
1103
|
+
for (const o of t.dimensions) {
|
|
1104
|
+
const [c, l] = o.split("."), u = a.find((m) => m.name === c);
|
|
1105
|
+
if (u && u.dimensions[l]) {
|
|
1106
|
+
const m = u.dimensions[l];
|
|
1107
|
+
n[o] = {
|
|
1108
|
+
title: m.title || l,
|
|
1109
|
+
shortTitle: m.title || l,
|
|
1110
|
+
type: m.type
|
|
853
1111
|
};
|
|
854
1112
|
}
|
|
855
1113
|
}
|
|
856
1114
|
if (t.timeDimensions)
|
|
857
|
-
for (const
|
|
858
|
-
const [
|
|
859
|
-
if (u && u.dimensions && u.dimensions[
|
|
860
|
-
const
|
|
861
|
-
o
|
|
862
|
-
title:
|
|
863
|
-
shortTitle:
|
|
864
|
-
type:
|
|
865
|
-
granularity:
|
|
1115
|
+
for (const o of t.timeDimensions) {
|
|
1116
|
+
const [c, l] = o.dimension.split("."), u = a.find((m) => m.name === c);
|
|
1117
|
+
if (u && u.dimensions && u.dimensions[l]) {
|
|
1118
|
+
const m = u.dimensions[l];
|
|
1119
|
+
r[o.dimension] = {
|
|
1120
|
+
title: m.title || l,
|
|
1121
|
+
shortTitle: m.title || l,
|
|
1122
|
+
type: m.type,
|
|
1123
|
+
granularity: o.granularity
|
|
866
1124
|
};
|
|
867
1125
|
}
|
|
868
1126
|
}
|
|
869
1127
|
return {
|
|
870
|
-
measures:
|
|
871
|
-
dimensions:
|
|
1128
|
+
measures: i,
|
|
1129
|
+
dimensions: n,
|
|
872
1130
|
segments: {},
|
|
873
|
-
timeDimensions:
|
|
1131
|
+
timeDimensions: r
|
|
874
1132
|
};
|
|
875
1133
|
}
|
|
876
1134
|
}
|
|
877
|
-
class
|
|
1135
|
+
class T {
|
|
878
1136
|
constructor(e) {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
e != null && e.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e != null && e.drizzle && (this.dbExecutor =
|
|
1137
|
+
E(this, "cubes", /* @__PURE__ */ new Map());
|
|
1138
|
+
E(this, "dbExecutor");
|
|
1139
|
+
e != null && e.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e != null && e.drizzle && (this.dbExecutor = j(
|
|
882
1140
|
e.drizzle,
|
|
883
1141
|
e.schema,
|
|
884
1142
|
e.engineType
|
|
@@ -893,8 +1151,8 @@ class te {
|
|
|
893
1151
|
/**
|
|
894
1152
|
* Set Drizzle instance and schema directly
|
|
895
1153
|
*/
|
|
896
|
-
setDrizzle(e, t,
|
|
897
|
-
this.dbExecutor =
|
|
1154
|
+
setDrizzle(e, t, i) {
|
|
1155
|
+
this.dbExecutor = j(e, t, i);
|
|
898
1156
|
}
|
|
899
1157
|
/**
|
|
900
1158
|
* Check if database executor is configured
|
|
@@ -932,7 +1190,7 @@ class te {
|
|
|
932
1190
|
async execute(e, t) {
|
|
933
1191
|
if (!this.dbExecutor)
|
|
934
1192
|
throw new Error("Database executor not configured");
|
|
935
|
-
return new
|
|
1193
|
+
return new y(this.dbExecutor).execute(this.cubes, e, t);
|
|
936
1194
|
}
|
|
937
1195
|
/**
|
|
938
1196
|
* Execute a multi-cube query
|
|
@@ -943,10 +1201,10 @@ class te {
|
|
|
943
1201
|
/**
|
|
944
1202
|
* Execute a single cube query
|
|
945
1203
|
*/
|
|
946
|
-
async executeQuery(e, t,
|
|
1204
|
+
async executeQuery(e, t, i) {
|
|
947
1205
|
if (!this.cubes.get(e))
|
|
948
1206
|
throw new Error(`Cube '${e}' not found`);
|
|
949
|
-
return this.execute(t,
|
|
1207
|
+
return this.execute(t, i);
|
|
950
1208
|
}
|
|
951
1209
|
/**
|
|
952
1210
|
* Get metadata for all cubes (for API responses)
|
|
@@ -958,29 +1216,29 @@ class te {
|
|
|
958
1216
|
* Generate cube metadata for API responses from cubes
|
|
959
1217
|
*/
|
|
960
1218
|
generateCubeMetadata(e) {
|
|
961
|
-
const t = Object.entries(e.measures).map(([
|
|
962
|
-
name: `${e.name}.${
|
|
963
|
-
title:
|
|
964
|
-
shortTitle:
|
|
965
|
-
type:
|
|
1219
|
+
const t = Object.entries(e.measures).map(([n, r]) => ({
|
|
1220
|
+
name: `${e.name}.${n}`,
|
|
1221
|
+
title: r.title || n,
|
|
1222
|
+
shortTitle: r.title || n,
|
|
1223
|
+
type: r.type,
|
|
966
1224
|
format: void 0,
|
|
967
1225
|
// Measure doesn't have format field
|
|
968
|
-
description:
|
|
969
|
-
})),
|
|
970
|
-
name: `${e.name}.${
|
|
971
|
-
title:
|
|
972
|
-
shortTitle:
|
|
973
|
-
type:
|
|
1226
|
+
description: r.description
|
|
1227
|
+
})), i = Object.entries(e.dimensions).map(([n, r]) => ({
|
|
1228
|
+
name: `${e.name}.${n}`,
|
|
1229
|
+
title: r.title || n,
|
|
1230
|
+
shortTitle: r.title || n,
|
|
1231
|
+
type: r.type,
|
|
974
1232
|
format: void 0,
|
|
975
1233
|
// Dimension doesn't have format field
|
|
976
|
-
description:
|
|
1234
|
+
description: r.description
|
|
977
1235
|
}));
|
|
978
1236
|
return {
|
|
979
1237
|
name: e.name,
|
|
980
1238
|
title: e.title || e.name,
|
|
981
1239
|
description: e.description,
|
|
982
1240
|
measures: t,
|
|
983
|
-
dimensions:
|
|
1241
|
+
dimensions: i,
|
|
984
1242
|
segments: []
|
|
985
1243
|
// Add segments support later if needed
|
|
986
1244
|
};
|
|
@@ -988,13 +1246,21 @@ class te {
|
|
|
988
1246
|
/**
|
|
989
1247
|
* Get SQL for a query without executing it (debugging)
|
|
990
1248
|
*/
|
|
991
|
-
async generateSQL(e, t,
|
|
992
|
-
const
|
|
993
|
-
if (!
|
|
1249
|
+
async generateSQL(e, t, i) {
|
|
1250
|
+
const n = this.getCube(e);
|
|
1251
|
+
if (!n)
|
|
994
1252
|
throw new Error(`Cube '${e}' not found`);
|
|
995
1253
|
if (!this.dbExecutor)
|
|
996
1254
|
throw new Error("Database executor not configured");
|
|
997
|
-
return new
|
|
1255
|
+
return new y(this.dbExecutor).generateSQL(n, t, i);
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Get SQL for a multi-cube query without executing it (debugging)
|
|
1259
|
+
*/
|
|
1260
|
+
async generateMultiCubeSQL(e, t) {
|
|
1261
|
+
if (!this.dbExecutor)
|
|
1262
|
+
throw new Error("Database executor not configured");
|
|
1263
|
+
return new y(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t);
|
|
998
1264
|
}
|
|
999
1265
|
/**
|
|
1000
1266
|
* Check if a cube exists
|
|
@@ -1020,12 +1286,98 @@ class te {
|
|
|
1020
1286
|
getCubeNames() {
|
|
1021
1287
|
return Array.from(this.cubes.keys());
|
|
1022
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Validate a query against registered cubes
|
|
1291
|
+
* Ensures all referenced cubes and fields exist
|
|
1292
|
+
*/
|
|
1293
|
+
validateQuery(e) {
|
|
1294
|
+
return v(this.cubes, e);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
function v(s, e) {
|
|
1298
|
+
const t = [], i = /* @__PURE__ */ new Set();
|
|
1299
|
+
if (e.measures)
|
|
1300
|
+
for (const n of e.measures) {
|
|
1301
|
+
const [r, a] = n.split(".");
|
|
1302
|
+
if (!r || !a) {
|
|
1303
|
+
t.push(`Invalid measure format: ${n}. Expected format: 'CubeName.fieldName'`);
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
i.add(r);
|
|
1307
|
+
const o = s.get(r);
|
|
1308
|
+
if (!o) {
|
|
1309
|
+
t.push(`Cube '${r}' not found (referenced in measure '${n}')`);
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
o.measures[a] || t.push(`Measure '${a}' not found on cube '${r}'`);
|
|
1313
|
+
}
|
|
1314
|
+
if (e.dimensions)
|
|
1315
|
+
for (const n of e.dimensions) {
|
|
1316
|
+
const [r, a] = n.split(".");
|
|
1317
|
+
if (!r || !a) {
|
|
1318
|
+
t.push(`Invalid dimension format: ${n}. Expected format: 'CubeName.fieldName'`);
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
i.add(r);
|
|
1322
|
+
const o = s.get(r);
|
|
1323
|
+
if (!o) {
|
|
1324
|
+
t.push(`Cube '${r}' not found (referenced in dimension '${n}')`);
|
|
1325
|
+
continue;
|
|
1326
|
+
}
|
|
1327
|
+
o.dimensions[a] || t.push(`Dimension '${a}' not found on cube '${r}'`);
|
|
1328
|
+
}
|
|
1329
|
+
if (e.timeDimensions)
|
|
1330
|
+
for (const n of e.timeDimensions) {
|
|
1331
|
+
const [r, a] = n.dimension.split(".");
|
|
1332
|
+
if (!r || !a) {
|
|
1333
|
+
t.push(`Invalid timeDimension format: ${n.dimension}. Expected format: 'CubeName.fieldName'`);
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
i.add(r);
|
|
1337
|
+
const o = s.get(r);
|
|
1338
|
+
if (!o) {
|
|
1339
|
+
t.push(`Cube '${r}' not found (referenced in timeDimension '${n.dimension}')`);
|
|
1340
|
+
continue;
|
|
1341
|
+
}
|
|
1342
|
+
o.dimensions[a] || t.push(`TimeDimension '${a}' not found on cube '${r}' (must be a dimension with time type)`);
|
|
1343
|
+
}
|
|
1344
|
+
if (e.filters)
|
|
1345
|
+
for (const n of e.filters)
|
|
1346
|
+
L(n, s, t, i);
|
|
1347
|
+
return i.size === 0 && t.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
1348
|
+
isValid: t.length === 0,
|
|
1349
|
+
errors: t
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function L(s, e, t, i) {
|
|
1353
|
+
if ("and" in s || "or" in s) {
|
|
1354
|
+
const o = s.and || s.or || [];
|
|
1355
|
+
for (const c of o)
|
|
1356
|
+
L(c, e, t, i);
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (!("member" in s)) {
|
|
1360
|
+
t.push("Filter must have a member field");
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const [n, r] = s.member.split(".");
|
|
1364
|
+
if (!n || !r) {
|
|
1365
|
+
t.push(`Invalid filter member format: ${s.member}. Expected format: 'CubeName.fieldName'`);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
i.add(n);
|
|
1369
|
+
const a = e.get(n);
|
|
1370
|
+
if (!a) {
|
|
1371
|
+
t.push(`Cube '${n}' not found (referenced in filter '${s.member}')`);
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
!a.dimensions[r] && !a.measures[r] && t.push(`Filter field '${r}' not found on cube '${n}' (must be a dimension or measure)`);
|
|
1023
1375
|
}
|
|
1024
|
-
function
|
|
1025
|
-
return new
|
|
1376
|
+
function Ee(s) {
|
|
1377
|
+
return new T(s);
|
|
1026
1378
|
}
|
|
1027
|
-
const
|
|
1028
|
-
function
|
|
1379
|
+
const se = new T();
|
|
1380
|
+
function re(s) {
|
|
1029
1381
|
const e = {
|
|
1030
1382
|
valid: !0,
|
|
1031
1383
|
errors: [],
|
|
@@ -1033,7 +1385,7 @@ function xo(n) {
|
|
|
1033
1385
|
cubes: []
|
|
1034
1386
|
};
|
|
1035
1387
|
try {
|
|
1036
|
-
const t =
|
|
1388
|
+
const t = G(s);
|
|
1037
1389
|
if (!t)
|
|
1038
1390
|
return e.valid = !1, e.errors.push("Invalid YAML: empty or malformed content"), e;
|
|
1039
1391
|
if (t.cubes && Array.isArray(t.cubes))
|
|
@@ -1042,9 +1394,9 @@ function xo(n) {
|
|
|
1042
1394
|
e.cubes = [t];
|
|
1043
1395
|
else
|
|
1044
1396
|
return e.valid = !1, e.errors.push('YAML must contain either a "cubes" array or cube properties at root level'), e;
|
|
1045
|
-
for (const
|
|
1046
|
-
const
|
|
1047
|
-
e.errors.push(...
|
|
1397
|
+
for (const i of e.cubes) {
|
|
1398
|
+
const n = oe(i);
|
|
1399
|
+
e.errors.push(...n);
|
|
1048
1400
|
}
|
|
1049
1401
|
e.valid = e.errors.length === 0;
|
|
1050
1402
|
} catch (t) {
|
|
@@ -1052,87 +1404,87 @@ function xo(n) {
|
|
|
1052
1404
|
}
|
|
1053
1405
|
return e;
|
|
1054
1406
|
}
|
|
1055
|
-
function
|
|
1407
|
+
function oe(s) {
|
|
1056
1408
|
const e = [];
|
|
1057
|
-
return
|
|
1058
|
-
t.name || e.push(`Dimension at index ${
|
|
1059
|
-
}),
|
|
1060
|
-
t.name || e.push(`Measure at index ${
|
|
1061
|
-
}),
|
|
1062
|
-
t.name || e.push(`Join at index ${
|
|
1409
|
+
return s.name || e.push("Cube name is required"), !s.sql && !s.sql_table && !s.sqlTable && e.push('Cube must have either "sql", "sql_table", or "sqlTable" property'), s.dimensions && s.dimensions.forEach((t, i) => {
|
|
1410
|
+
t.name || e.push(`Dimension at index ${i} is missing name`), t.type || e.push(`Dimension "${t.name}" is missing type`), t.sql || e.push(`Dimension "${t.name}" is missing sql`);
|
|
1411
|
+
}), s.measures && s.measures.forEach((t, i) => {
|
|
1412
|
+
t.name || e.push(`Measure at index ${i} is missing name`), t.type || e.push(`Measure "${t.name}" is missing type`), t.sql || e.push(`Measure "${t.name}" is missing sql`);
|
|
1413
|
+
}), s.joins && s.joins.forEach((t, i) => {
|
|
1414
|
+
t.name || e.push(`Join at index ${i} is missing name`), t.relationship || e.push(`Join "${t.name}" is missing relationship`), t.sql || e.push(`Join "${t.name}" is missing sql`);
|
|
1063
1415
|
}), e;
|
|
1064
1416
|
}
|
|
1065
|
-
function
|
|
1417
|
+
function ae(s) {
|
|
1066
1418
|
const e = {};
|
|
1067
|
-
|
|
1068
|
-
e[
|
|
1419
|
+
s.dimensions && s.dimensions.forEach((o) => {
|
|
1420
|
+
e[o.name] = ce(o);
|
|
1069
1421
|
});
|
|
1070
1422
|
const t = {};
|
|
1071
|
-
|
|
1072
|
-
t[
|
|
1073
|
-
});
|
|
1074
|
-
const s = {};
|
|
1075
|
-
n.joins && n.joins.forEach((a) => {
|
|
1076
|
-
s[a.name] = vo(a);
|
|
1423
|
+
s.measures && s.measures.forEach((o) => {
|
|
1424
|
+
t[o.name] = le(o);
|
|
1077
1425
|
});
|
|
1078
1426
|
const i = {};
|
|
1079
|
-
|
|
1080
|
-
i[
|
|
1427
|
+
s.joins && s.joins.forEach((o) => {
|
|
1428
|
+
i[o.name] = fe(o);
|
|
1081
1429
|
});
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1430
|
+
const n = {};
|
|
1431
|
+
(s.pre_aggregations || s.preAggregations) && (s.pre_aggregations || s.preAggregations || []).forEach((c) => {
|
|
1432
|
+
n[c.name] = de(c);
|
|
1433
|
+
});
|
|
1434
|
+
let r = s.sql;
|
|
1435
|
+
!r && (s.sql_table || s.sqlTable) && (r = `SELECT * FROM ${s.sql_table || s.sqlTable}`);
|
|
1436
|
+
const a = s.refresh_key || s.refreshKey;
|
|
1085
1437
|
return {
|
|
1086
|
-
name:
|
|
1087
|
-
title:
|
|
1088
|
-
description:
|
|
1089
|
-
sql:
|
|
1090
|
-
sqlAlias:
|
|
1091
|
-
dataSource:
|
|
1092
|
-
refreshKey:
|
|
1093
|
-
every:
|
|
1094
|
-
sql:
|
|
1438
|
+
name: s.name,
|
|
1439
|
+
title: s.title,
|
|
1440
|
+
description: s.description,
|
|
1441
|
+
sql: r || "",
|
|
1442
|
+
sqlAlias: s.sql_alias || s.sqlAlias,
|
|
1443
|
+
dataSource: s.data_source || s.dataSource,
|
|
1444
|
+
refreshKey: a ? {
|
|
1445
|
+
every: a.every,
|
|
1446
|
+
sql: a.sql
|
|
1095
1447
|
} : void 0,
|
|
1096
1448
|
dimensions: e,
|
|
1097
1449
|
measures: t,
|
|
1098
|
-
joins: Object.keys(
|
|
1099
|
-
preAggregations: Object.keys(
|
|
1100
|
-
meta:
|
|
1450
|
+
joins: Object.keys(i).length > 0 ? i : void 0,
|
|
1451
|
+
preAggregations: Object.keys(n).length > 0 ? n : void 0,
|
|
1452
|
+
meta: s.meta
|
|
1101
1453
|
};
|
|
1102
1454
|
}
|
|
1103
|
-
function
|
|
1455
|
+
function ce(s) {
|
|
1104
1456
|
return {
|
|
1105
|
-
name:
|
|
1106
|
-
title:
|
|
1107
|
-
description:
|
|
1108
|
-
type:
|
|
1109
|
-
sql:
|
|
1110
|
-
primaryKey:
|
|
1111
|
-
shown:
|
|
1112
|
-
format:
|
|
1113
|
-
meta:
|
|
1457
|
+
name: s.name,
|
|
1458
|
+
title: s.title,
|
|
1459
|
+
description: s.description,
|
|
1460
|
+
type: s.type,
|
|
1461
|
+
sql: s.sql,
|
|
1462
|
+
primaryKey: s.primary_key || s.primaryKey,
|
|
1463
|
+
shown: s.shown,
|
|
1464
|
+
format: s.format,
|
|
1465
|
+
meta: s.meta
|
|
1114
1466
|
};
|
|
1115
1467
|
}
|
|
1116
|
-
function
|
|
1117
|
-
var
|
|
1118
|
-
const e = (
|
|
1119
|
-
sql:
|
|
1120
|
-
})), t =
|
|
1468
|
+
function le(s) {
|
|
1469
|
+
var i;
|
|
1470
|
+
const e = (i = s.filters) == null ? void 0 : i.map((n) => ({
|
|
1471
|
+
sql: n.sql
|
|
1472
|
+
})), t = s.rolling_window || s.rollingWindow;
|
|
1121
1473
|
return {
|
|
1122
|
-
name:
|
|
1123
|
-
title:
|
|
1124
|
-
description:
|
|
1125
|
-
type:
|
|
1126
|
-
sql:
|
|
1127
|
-
format:
|
|
1128
|
-
shown:
|
|
1474
|
+
name: s.name,
|
|
1475
|
+
title: s.title,
|
|
1476
|
+
description: s.description,
|
|
1477
|
+
type: s.type,
|
|
1478
|
+
sql: s.sql,
|
|
1479
|
+
format: s.format,
|
|
1480
|
+
shown: s.shown,
|
|
1129
1481
|
filters: e,
|
|
1130
1482
|
rollingWindow: t,
|
|
1131
|
-
meta:
|
|
1483
|
+
meta: s.meta
|
|
1132
1484
|
};
|
|
1133
1485
|
}
|
|
1134
|
-
function
|
|
1135
|
-
switch (
|
|
1486
|
+
function ue(s) {
|
|
1487
|
+
switch (s) {
|
|
1136
1488
|
case "one_to_one":
|
|
1137
1489
|
return "hasOne";
|
|
1138
1490
|
case "one_to_many":
|
|
@@ -1143,8 +1495,8 @@ function Po(n) {
|
|
|
1143
1495
|
return "belongsTo";
|
|
1144
1496
|
}
|
|
1145
1497
|
}
|
|
1146
|
-
function
|
|
1147
|
-
switch (
|
|
1498
|
+
function me(s) {
|
|
1499
|
+
switch (s) {
|
|
1148
1500
|
case "hasOne":
|
|
1149
1501
|
return "one_to_one";
|
|
1150
1502
|
case "hasMany":
|
|
@@ -1155,62 +1507,62 @@ function Do(n) {
|
|
|
1155
1507
|
return "many_to_one";
|
|
1156
1508
|
}
|
|
1157
1509
|
}
|
|
1158
|
-
function
|
|
1510
|
+
function fe(s) {
|
|
1159
1511
|
return {
|
|
1160
|
-
name:
|
|
1161
|
-
type:
|
|
1162
|
-
relationship:
|
|
1163
|
-
sql:
|
|
1512
|
+
name: s.name,
|
|
1513
|
+
type: s.type,
|
|
1514
|
+
relationship: ue(s.relationship),
|
|
1515
|
+
sql: s.sql
|
|
1164
1516
|
};
|
|
1165
1517
|
}
|
|
1166
|
-
function
|
|
1167
|
-
const e =
|
|
1518
|
+
function de(s) {
|
|
1519
|
+
const e = s.time_dimension || s.timeDimension, t = s.refresh_key || s.refreshKey;
|
|
1168
1520
|
return {
|
|
1169
|
-
name:
|
|
1170
|
-
measures:
|
|
1171
|
-
dimensions:
|
|
1521
|
+
name: s.name,
|
|
1522
|
+
measures: s.measures,
|
|
1523
|
+
dimensions: s.dimensions,
|
|
1172
1524
|
timeDimension: e,
|
|
1173
1525
|
refreshKey: t,
|
|
1174
|
-
indexes:
|
|
1526
|
+
indexes: s.indexes
|
|
1175
1527
|
};
|
|
1176
1528
|
}
|
|
1177
|
-
async function
|
|
1529
|
+
async function he() {
|
|
1178
1530
|
try {
|
|
1179
|
-
const { promises:
|
|
1531
|
+
const { promises: s } = await import("fs"), e = await s.readFile("non-existent-file.txt", "utf-8").catch((t) => t.message);
|
|
1180
1532
|
return !(typeof e == "string" && e.includes("not implemented"));
|
|
1181
1533
|
} catch {
|
|
1182
1534
|
return !1;
|
|
1183
1535
|
}
|
|
1184
1536
|
}
|
|
1185
|
-
function
|
|
1186
|
-
const e =
|
|
1537
|
+
function pe(s) {
|
|
1538
|
+
const e = re(s);
|
|
1187
1539
|
if (!e.valid)
|
|
1188
1540
|
throw new Error(`Invalid YAML cube definition:
|
|
1189
1541
|
${e.errors.join(`
|
|
1190
1542
|
`)}`);
|
|
1191
|
-
return e.cubes.map((t) =>
|
|
1543
|
+
return e.cubes.map((t) => ae(t));
|
|
1192
1544
|
}
|
|
1193
|
-
async function
|
|
1194
|
-
if (!await
|
|
1545
|
+
async function De(s) {
|
|
1546
|
+
if (!await he())
|
|
1195
1547
|
return console.log("ℹ️ YAML file loading not supported in this environment (Cloudflare Workers/Edge Runtime). Use inline YAML strings or build-time transformations instead."), [];
|
|
1196
1548
|
try {
|
|
1197
|
-
const { promises: t } = await import("fs"),
|
|
1198
|
-
return
|
|
1549
|
+
const { promises: t } = await import("fs"), i = await t.readFile(s, "utf-8");
|
|
1550
|
+
return pe(i);
|
|
1199
1551
|
} catch (t) {
|
|
1200
|
-
return console.log(`ℹ️ Could not load YAML file ${
|
|
1552
|
+
return console.log(`ℹ️ Could not load YAML file ${s}:`, t instanceof Error ? t.message : t), [];
|
|
1201
1553
|
}
|
|
1202
1554
|
}
|
|
1203
|
-
function
|
|
1204
|
-
let e =
|
|
1555
|
+
function $e(s) {
|
|
1556
|
+
let e = s;
|
|
1205
1557
|
return e = e.replace(/\{CUBE\}/g, "${CUBE}"), e = e.replace(/\{([A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\}/g, "${$1}"), e = e.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, "${$1}"), e = e.replace(/\$\$\{/g, "${"), e;
|
|
1206
1558
|
}
|
|
1207
|
-
function
|
|
1559
|
+
function ye(s) {
|
|
1208
1560
|
const e = {
|
|
1209
|
-
name:
|
|
1210
|
-
title:
|
|
1211
|
-
description:
|
|
1212
|
-
sql: typeof
|
|
1213
|
-
dimensions: Object.values(
|
|
1561
|
+
name: s.name,
|
|
1562
|
+
title: s.title,
|
|
1563
|
+
description: s.description,
|
|
1564
|
+
sql: typeof s.sql == "string" ? s.sql : void 0,
|
|
1565
|
+
dimensions: Object.values(s.dimensions).map((t) => ({
|
|
1214
1566
|
name: t.name,
|
|
1215
1567
|
title: t.title,
|
|
1216
1568
|
description: t.description,
|
|
@@ -1221,8 +1573,8 @@ function $a(n) {
|
|
|
1221
1573
|
format: t.format,
|
|
1222
1574
|
meta: t.meta
|
|
1223
1575
|
})),
|
|
1224
|
-
measures: Object.values(
|
|
1225
|
-
var
|
|
1576
|
+
measures: Object.values(s.measures).map((t) => {
|
|
1577
|
+
var i;
|
|
1226
1578
|
return {
|
|
1227
1579
|
name: t.name,
|
|
1228
1580
|
title: t.title,
|
|
@@ -1231,2257 +1583,108 @@ function $a(n) {
|
|
|
1231
1583
|
sql: typeof t.sql == "string" ? t.sql : "",
|
|
1232
1584
|
format: t.format,
|
|
1233
1585
|
shown: t.shown,
|
|
1234
|
-
filters: (
|
|
1235
|
-
sql: typeof
|
|
1586
|
+
filters: (i = t.filters) == null ? void 0 : i.map((n) => ({
|
|
1587
|
+
sql: typeof n.sql == "string" ? n.sql : ""
|
|
1236
1588
|
})),
|
|
1237
1589
|
rolling_window: t.rollingWindow,
|
|
1238
1590
|
meta: t.meta
|
|
1239
1591
|
};
|
|
1240
1592
|
}),
|
|
1241
|
-
joins:
|
|
1593
|
+
joins: s.joins ? Object.values(s.joins).map((t) => ({
|
|
1242
1594
|
name: t.name || "",
|
|
1243
1595
|
type: t.type,
|
|
1244
|
-
relationship:
|
|
1596
|
+
relationship: me(t.relationship),
|
|
1245
1597
|
sql: typeof t.sql == "string" ? t.sql : ""
|
|
1246
1598
|
})) : void 0,
|
|
1247
|
-
meta:
|
|
1599
|
+
meta: s.meta
|
|
1248
1600
|
};
|
|
1249
|
-
return
|
|
1601
|
+
return P(e, {
|
|
1250
1602
|
indent: 2,
|
|
1251
1603
|
lineWidth: 120,
|
|
1252
1604
|
minContentWidth: 40
|
|
1253
1605
|
});
|
|
1254
1606
|
}
|
|
1255
|
-
const
|
|
1256
|
-
function
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
return !0;
|
|
1261
|
-
if (!Object.prototype.hasOwnProperty.call(e, c))
|
|
1262
|
-
throw new Error(
|
|
1263
|
-
`Class "${e.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
|
|
1264
|
-
);
|
|
1265
|
-
let t = Object.getPrototypeOf(n).constructor;
|
|
1266
|
-
if (t)
|
|
1267
|
-
for (; t; ) {
|
|
1268
|
-
if (c in t && t[c] === e[c])
|
|
1269
|
-
return !0;
|
|
1270
|
-
t = Object.getPrototypeOf(t);
|
|
1271
|
-
}
|
|
1272
|
-
return !1;
|
|
1273
|
-
}
|
|
1274
|
-
var xe;
|
|
1275
|
-
xe = c;
|
|
1276
|
-
class K {
|
|
1277
|
-
constructor(e, t) {
|
|
1278
|
-
r(this, "name");
|
|
1279
|
-
r(this, "keyAsName");
|
|
1280
|
-
r(this, "primary");
|
|
1281
|
-
r(this, "notNull");
|
|
1282
|
-
r(this, "default");
|
|
1283
|
-
r(this, "defaultFn");
|
|
1284
|
-
r(this, "onUpdateFn");
|
|
1285
|
-
r(this, "hasDefault");
|
|
1286
|
-
r(this, "isUnique");
|
|
1287
|
-
r(this, "uniqueName");
|
|
1288
|
-
r(this, "uniqueType");
|
|
1289
|
-
r(this, "dataType");
|
|
1290
|
-
r(this, "columnType");
|
|
1291
|
-
r(this, "enumValues");
|
|
1292
|
-
r(this, "generated");
|
|
1293
|
-
r(this, "generatedIdentity");
|
|
1294
|
-
r(this, "config");
|
|
1295
|
-
this.table = e, this.config = t, this.name = t.name, this.keyAsName = t.keyAsName, this.notNull = t.notNull, this.default = t.default, this.defaultFn = t.defaultFn, this.onUpdateFn = t.onUpdateFn, this.hasDefault = t.hasDefault, this.primary = t.primaryKey, this.isUnique = t.isUnique, this.uniqueName = t.uniqueName, this.uniqueType = t.uniqueType, this.dataType = t.dataType, this.columnType = t.columnType, this.generated = t.generated, this.generatedIdentity = t.generatedIdentity;
|
|
1296
|
-
}
|
|
1297
|
-
mapFromDriverValue(e) {
|
|
1298
|
-
return e;
|
|
1299
|
-
}
|
|
1300
|
-
mapToDriverValue(e) {
|
|
1301
|
-
return e;
|
|
1302
|
-
}
|
|
1303
|
-
// ** @internal */
|
|
1304
|
-
shouldDisableInsert() {
|
|
1305
|
-
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
r(K, xe, "Column");
|
|
1309
|
-
var Ne;
|
|
1310
|
-
Ne = c;
|
|
1311
|
-
class fi {
|
|
1312
|
-
constructor(e, t, s) {
|
|
1313
|
-
r(this, "config");
|
|
1314
|
-
/**
|
|
1315
|
-
* Alias for {@link $defaultFn}.
|
|
1316
|
-
*/
|
|
1317
|
-
r(this, "$default", this.$defaultFn);
|
|
1318
|
-
/**
|
|
1319
|
-
* Alias for {@link $onUpdateFn}.
|
|
1320
|
-
*/
|
|
1321
|
-
r(this, "$onUpdate", this.$onUpdateFn);
|
|
1322
|
-
this.config = {
|
|
1323
|
-
name: e,
|
|
1324
|
-
keyAsName: e === "",
|
|
1325
|
-
notNull: !1,
|
|
1326
|
-
default: void 0,
|
|
1327
|
-
hasDefault: !1,
|
|
1328
|
-
primaryKey: !1,
|
|
1329
|
-
isUnique: !1,
|
|
1330
|
-
uniqueName: void 0,
|
|
1331
|
-
uniqueType: void 0,
|
|
1332
|
-
dataType: t,
|
|
1333
|
-
columnType: s,
|
|
1334
|
-
generated: void 0
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
/**
|
|
1338
|
-
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
|
|
1339
|
-
*
|
|
1340
|
-
* @example
|
|
1341
|
-
* ```ts
|
|
1342
|
-
* const users = pgTable('users', {
|
|
1343
|
-
* id: integer('id').$type<UserId>().primaryKey(),
|
|
1344
|
-
* details: json('details').$type<UserDetails>().notNull(),
|
|
1345
|
-
* });
|
|
1346
|
-
* ```
|
|
1347
|
-
*/
|
|
1348
|
-
$type() {
|
|
1349
|
-
return this;
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Adds a `not null` clause to the column definition.
|
|
1353
|
-
*
|
|
1354
|
-
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
1355
|
-
*/
|
|
1356
|
-
notNull() {
|
|
1357
|
-
return this.config.notNull = !0, this;
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* Adds a `default <value>` clause to the column definition.
|
|
1361
|
-
*
|
|
1362
|
-
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
1363
|
-
*
|
|
1364
|
-
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
1365
|
-
*/
|
|
1366
|
-
default(e) {
|
|
1367
|
-
return this.config.default = e, this.config.hasDefault = !0, this;
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Adds a dynamic default value to the column.
|
|
1371
|
-
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
1372
|
-
*
|
|
1373
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1374
|
-
*/
|
|
1375
|
-
$defaultFn(e) {
|
|
1376
|
-
return this.config.defaultFn = e, this.config.hasDefault = !0, this;
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Adds a dynamic update value to the column.
|
|
1380
|
-
* The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
|
|
1381
|
-
* If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
|
|
1382
|
-
*
|
|
1383
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1384
|
-
*/
|
|
1385
|
-
$onUpdateFn(e) {
|
|
1386
|
-
return this.config.onUpdateFn = e, this.config.hasDefault = !0, this;
|
|
1387
|
-
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
1390
|
-
*
|
|
1391
|
-
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
1392
|
-
*/
|
|
1393
|
-
primaryKey() {
|
|
1394
|
-
return this.config.primaryKey = !0, this.config.notNull = !0, this;
|
|
1395
|
-
}
|
|
1396
|
-
/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
|
|
1397
|
-
setName(e) {
|
|
1398
|
-
this.config.name === "" && (this.config.name = e);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
r(fi, Ne, "ColumnBuilder");
|
|
1402
|
-
const Q = Symbol.for("drizzle:Name");
|
|
1403
|
-
var Te;
|
|
1404
|
-
Te = c;
|
|
1405
|
-
class pi {
|
|
1406
|
-
constructor(e, t) {
|
|
1407
|
-
/** @internal */
|
|
1408
|
-
r(this, "reference");
|
|
1409
|
-
/** @internal */
|
|
1410
|
-
r(this, "_onUpdate", "no action");
|
|
1411
|
-
/** @internal */
|
|
1412
|
-
r(this, "_onDelete", "no action");
|
|
1413
|
-
this.reference = () => {
|
|
1414
|
-
const { name: s, columns: i, foreignColumns: o } = e();
|
|
1415
|
-
return { name: s, columns: i, foreignTable: o[0].table, foreignColumns: o };
|
|
1416
|
-
}, t && (this._onUpdate = t.onUpdate, this._onDelete = t.onDelete);
|
|
1417
|
-
}
|
|
1418
|
-
onUpdate(e) {
|
|
1419
|
-
return this._onUpdate = e === void 0 ? "no action" : e, this;
|
|
1420
|
-
}
|
|
1421
|
-
onDelete(e) {
|
|
1422
|
-
return this._onDelete = e === void 0 ? "no action" : e, this;
|
|
1423
|
-
}
|
|
1424
|
-
/** @internal */
|
|
1425
|
-
build(e) {
|
|
1426
|
-
return new hi(e, this);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
r(pi, Te, "PgForeignKeyBuilder");
|
|
1430
|
-
var Ce;
|
|
1431
|
-
Ce = c;
|
|
1432
|
-
class hi {
|
|
1433
|
-
constructor(e, t) {
|
|
1434
|
-
r(this, "reference");
|
|
1435
|
-
r(this, "onUpdate");
|
|
1436
|
-
r(this, "onDelete");
|
|
1437
|
-
this.table = e, this.reference = t.reference, this.onUpdate = t._onUpdate, this.onDelete = t._onDelete;
|
|
1438
|
-
}
|
|
1439
|
-
getName() {
|
|
1440
|
-
const { name: e, columns: t, foreignColumns: s } = this.reference(), i = t.map((a) => a.name), o = s.map((a) => a.name), l = [
|
|
1441
|
-
this.table[Q],
|
|
1442
|
-
...i,
|
|
1443
|
-
s[0].table[Q],
|
|
1444
|
-
...o
|
|
1445
|
-
];
|
|
1446
|
-
return e ?? `${l.join("_")}_fk`;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
r(hi, Ce, "PgForeignKey");
|
|
1450
|
-
function zo(n, ...e) {
|
|
1451
|
-
return n(...e);
|
|
1452
|
-
}
|
|
1453
|
-
function Fo(n, e) {
|
|
1454
|
-
return `${n[Q]}_${e.join("_")}_unique`;
|
|
1455
|
-
}
|
|
1456
|
-
function fe(n, e, t) {
|
|
1457
|
-
for (let s = e; s < n.length; s++) {
|
|
1458
|
-
const i = n[s];
|
|
1459
|
-
if (i === "\\") {
|
|
1460
|
-
s++;
|
|
1461
|
-
continue;
|
|
1462
|
-
}
|
|
1463
|
-
if (i === '"')
|
|
1464
|
-
return [n.slice(e, s).replace(/\\/g, ""), s + 1];
|
|
1465
|
-
if (!t && (i === "," || i === "}"))
|
|
1466
|
-
return [n.slice(e, s).replace(/\\/g, ""), s];
|
|
1467
|
-
}
|
|
1468
|
-
return [n.slice(e).replace(/\\/g, ""), n.length];
|
|
1469
|
-
}
|
|
1470
|
-
function gi(n, e = 0) {
|
|
1471
|
-
const t = [];
|
|
1472
|
-
let s = e, i = !1;
|
|
1473
|
-
for (; s < n.length; ) {
|
|
1474
|
-
const o = n[s];
|
|
1475
|
-
if (o === ",") {
|
|
1476
|
-
(i || s === e) && t.push(""), i = !0, s++;
|
|
1477
|
-
continue;
|
|
1478
|
-
}
|
|
1479
|
-
if (i = !1, o === "\\") {
|
|
1480
|
-
s += 2;
|
|
1481
|
-
continue;
|
|
1482
|
-
}
|
|
1483
|
-
if (o === '"') {
|
|
1484
|
-
const [m, d] = fe(n, s + 1, !0);
|
|
1485
|
-
t.push(m), s = d;
|
|
1486
|
-
continue;
|
|
1487
|
-
}
|
|
1488
|
-
if (o === "}")
|
|
1489
|
-
return [t, s + 1];
|
|
1490
|
-
if (o === "{") {
|
|
1491
|
-
const [m, d] = gi(n, s + 1);
|
|
1492
|
-
t.push(m), s = d;
|
|
1493
|
-
continue;
|
|
1494
|
-
}
|
|
1495
|
-
const [l, a] = fe(n, s, !1);
|
|
1496
|
-
t.push(l), s = a;
|
|
1497
|
-
}
|
|
1498
|
-
return [t, s];
|
|
1499
|
-
}
|
|
1500
|
-
function Lo(n) {
|
|
1501
|
-
const [e] = gi(n, 1);
|
|
1502
|
-
return e;
|
|
1503
|
-
}
|
|
1504
|
-
function bi(n) {
|
|
1505
|
-
return `{${n.map((e) => Array.isArray(e) ? bi(e) : typeof e == "string" ? `"${e.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"` : `${e}`).join(",")}}`;
|
|
1506
|
-
}
|
|
1507
|
-
var Se, Pe;
|
|
1508
|
-
class b extends (Pe = fi, Se = c, Pe) {
|
|
1509
|
-
constructor() {
|
|
1510
|
-
super(...arguments);
|
|
1511
|
-
r(this, "foreignKeyConfigs", []);
|
|
1512
|
-
}
|
|
1513
|
-
array(t) {
|
|
1514
|
-
return new wi(this.config.name, this, t);
|
|
1515
|
-
}
|
|
1516
|
-
references(t, s = {}) {
|
|
1517
|
-
return this.foreignKeyConfigs.push({ ref: t, actions: s }), this;
|
|
1518
|
-
}
|
|
1519
|
-
unique(t, s) {
|
|
1520
|
-
return this.config.isUnique = !0, this.config.uniqueName = t, this.config.uniqueType = s == null ? void 0 : s.nulls, this;
|
|
1521
|
-
}
|
|
1522
|
-
generatedAlwaysAs(t) {
|
|
1523
|
-
return this.config.generated = {
|
|
1524
|
-
as: t,
|
|
1525
|
-
type: "always",
|
|
1526
|
-
mode: "stored"
|
|
1527
|
-
}, this;
|
|
1528
|
-
}
|
|
1529
|
-
/** @internal */
|
|
1530
|
-
buildForeignKeys(t, s) {
|
|
1531
|
-
return this.foreignKeyConfigs.map(({ ref: i, actions: o }) => zo(
|
|
1532
|
-
(l, a) => {
|
|
1533
|
-
const m = new pi(() => {
|
|
1534
|
-
const d = l();
|
|
1535
|
-
return { columns: [t], foreignColumns: [d] };
|
|
1536
|
-
});
|
|
1537
|
-
return a.onUpdate && m.onUpdate(a.onUpdate), a.onDelete && m.onDelete(a.onDelete), m.build(s);
|
|
1538
|
-
},
|
|
1539
|
-
i,
|
|
1540
|
-
o
|
|
1541
|
-
));
|
|
1542
|
-
}
|
|
1543
|
-
/** @internal */
|
|
1544
|
-
buildExtraConfigColumn(t) {
|
|
1545
|
-
return new yi(t, this.config);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
r(b, Se, "PgColumnBuilder");
|
|
1549
|
-
var De, ve;
|
|
1550
|
-
class g extends (ve = K, De = c, ve) {
|
|
1551
|
-
constructor(e, t) {
|
|
1552
|
-
t.uniqueName || (t.uniqueName = Fo(e, [t.name])), super(e, t), this.table = e;
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
r(g, De, "PgColumn");
|
|
1556
|
-
var Ee, $e;
|
|
1557
|
-
class yi extends ($e = g, Ee = c, $e) {
|
|
1558
|
-
constructor() {
|
|
1559
|
-
super(...arguments);
|
|
1560
|
-
r(this, "indexConfig", {
|
|
1561
|
-
order: this.config.order ?? "asc",
|
|
1562
|
-
nulls: this.config.nulls ?? "last",
|
|
1563
|
-
opClass: this.config.opClass
|
|
1564
|
-
});
|
|
1565
|
-
r(this, "defaultConfig", {
|
|
1566
|
-
order: "asc",
|
|
1567
|
-
nulls: "last",
|
|
1568
|
-
opClass: void 0
|
|
1569
|
-
});
|
|
1570
|
-
}
|
|
1571
|
-
getSQLType() {
|
|
1572
|
-
return this.getSQLType();
|
|
1573
|
-
}
|
|
1574
|
-
asc() {
|
|
1575
|
-
return this.indexConfig.order = "asc", this;
|
|
1576
|
-
}
|
|
1577
|
-
desc() {
|
|
1578
|
-
return this.indexConfig.order = "desc", this;
|
|
1579
|
-
}
|
|
1580
|
-
nullsFirst() {
|
|
1581
|
-
return this.indexConfig.nulls = "first", this;
|
|
1582
|
-
}
|
|
1583
|
-
nullsLast() {
|
|
1584
|
-
return this.indexConfig.nulls = "last", this;
|
|
1585
|
-
}
|
|
1586
|
-
/**
|
|
1587
|
-
* ### PostgreSQL documentation quote
|
|
1588
|
-
*
|
|
1589
|
-
* > An operator class with optional parameters can be specified for each column of an index.
|
|
1590
|
-
* The operator class identifies the operators to be used by the index for that column.
|
|
1591
|
-
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
1592
|
-
* this operator class includes comparison functions for four-byte integers.
|
|
1593
|
-
* In practice the default operator class for the column's data type is usually sufficient.
|
|
1594
|
-
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
1595
|
-
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
1596
|
-
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
1597
|
-
* More information about operator classes check:
|
|
1598
|
-
*
|
|
1599
|
-
* ### Useful links
|
|
1600
|
-
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
1601
|
-
*
|
|
1602
|
-
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
1603
|
-
*
|
|
1604
|
-
* https://www.postgresql.org/docs/current/xindex.html
|
|
1605
|
-
*
|
|
1606
|
-
* ### Additional types
|
|
1607
|
-
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
1608
|
-
* `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
|
|
1609
|
-
*
|
|
1610
|
-
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
1611
|
-
*
|
|
1612
|
-
* @param opClass
|
|
1613
|
-
* @returns
|
|
1614
|
-
*/
|
|
1615
|
-
op(t) {
|
|
1616
|
-
return this.indexConfig.opClass = t, this;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
r(yi, Ee, "ExtraConfigColumn");
|
|
1620
|
-
var Be, ze;
|
|
1621
|
-
class wi extends (ze = b, Be = c, ze) {
|
|
1622
|
-
constructor(e, t, s) {
|
|
1623
|
-
super(e, "array", "PgArray"), this.config.baseBuilder = t, this.config.size = s;
|
|
1624
|
-
}
|
|
1625
|
-
/** @internal */
|
|
1626
|
-
build(e) {
|
|
1627
|
-
const t = this.config.baseBuilder.build(e);
|
|
1628
|
-
return new X(
|
|
1629
|
-
e,
|
|
1630
|
-
this.config,
|
|
1631
|
-
t
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
r(wi, Be, "PgArrayBuilder");
|
|
1636
|
-
var Fe, Le;
|
|
1637
|
-
const R = class R extends (Le = g, Fe = c, Le) {
|
|
1638
|
-
constructor(t, s, i, o) {
|
|
1639
|
-
super(t, s);
|
|
1640
|
-
r(this, "size");
|
|
1641
|
-
this.baseColumn = i, this.range = o, this.size = s.size;
|
|
1642
|
-
}
|
|
1643
|
-
getSQLType() {
|
|
1644
|
-
return `${this.baseColumn.getSQLType()}[${typeof this.size == "number" ? this.size : ""}]`;
|
|
1645
|
-
}
|
|
1646
|
-
mapFromDriverValue(t) {
|
|
1647
|
-
return typeof t == "string" && (t = Lo(t)), t.map((s) => this.baseColumn.mapFromDriverValue(s));
|
|
1648
|
-
}
|
|
1649
|
-
mapToDriverValue(t, s = !1) {
|
|
1650
|
-
const i = t.map(
|
|
1651
|
-
(o) => o === null ? null : T(this.baseColumn, R) ? this.baseColumn.mapToDriverValue(o, !0) : this.baseColumn.mapToDriverValue(o)
|
|
1652
|
-
);
|
|
1653
|
-
return s ? i : bi(i);
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
r(R, Fe, "PgArray");
|
|
1657
|
-
let X = R;
|
|
1658
|
-
const pe = Symbol.for("drizzle:isPgEnum");
|
|
1659
|
-
function Ao(n) {
|
|
1660
|
-
return !!n && typeof n == "function" && pe in n && n[pe] === !0;
|
|
1661
|
-
}
|
|
1662
|
-
var Ae;
|
|
1663
|
-
Ae = c;
|
|
1664
|
-
class ne {
|
|
1665
|
-
constructor(e, t, s, i = !1, o = []) {
|
|
1666
|
-
this._ = {
|
|
1667
|
-
brand: "Subquery",
|
|
1668
|
-
sql: e,
|
|
1669
|
-
selectedFields: t,
|
|
1670
|
-
alias: s,
|
|
1671
|
-
isWith: i,
|
|
1672
|
-
usedTables: o
|
|
1673
|
-
};
|
|
1674
|
-
}
|
|
1675
|
-
// getSQL(): SQL<unknown> {
|
|
1676
|
-
// return new SQL([this]);
|
|
1677
|
-
// }
|
|
1678
|
-
}
|
|
1679
|
-
r(ne, Ae, "Subquery");
|
|
1680
|
-
const Qo = {
|
|
1681
|
-
startActiveSpan(n, e) {
|
|
1682
|
-
return e();
|
|
1683
|
-
}
|
|
1684
|
-
}, I = Symbol.for("drizzle:ViewBaseConfig"), G = Symbol.for("drizzle:Schema"), he = Symbol.for("drizzle:Columns"), ge = Symbol.for("drizzle:ExtraConfigColumns"), H = Symbol.for("drizzle:OriginalName"), Z = Symbol.for("drizzle:BaseName"), _ = Symbol.for("drizzle:IsAlias"), be = Symbol.for("drizzle:ExtraConfigBuilder"), Vo = Symbol.for("drizzle:IsDrizzleTable");
|
|
1685
|
-
var Qe, Ve, Ie, je, _e, Ue, qe, Oe, Me, Re;
|
|
1686
|
-
Re = c, Me = Q, Oe = H, qe = G, Ue = he, _e = ge, je = Z, Ie = _, Ve = Vo, Qe = be;
|
|
1687
|
-
class w {
|
|
1688
|
-
constructor(e, t, s) {
|
|
1689
|
-
/**
|
|
1690
|
-
* @internal
|
|
1691
|
-
* Can be changed if the table is aliased.
|
|
1692
|
-
*/
|
|
1693
|
-
r(this, Me);
|
|
1694
|
-
/**
|
|
1695
|
-
* @internal
|
|
1696
|
-
* Used to store the original name of the table, before any aliasing.
|
|
1697
|
-
*/
|
|
1698
|
-
r(this, Oe);
|
|
1699
|
-
/** @internal */
|
|
1700
|
-
r(this, qe);
|
|
1701
|
-
/** @internal */
|
|
1702
|
-
r(this, Ue);
|
|
1703
|
-
/** @internal */
|
|
1704
|
-
r(this, _e);
|
|
1705
|
-
/**
|
|
1706
|
-
* @internal
|
|
1707
|
-
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
1708
|
-
*/
|
|
1709
|
-
r(this, je);
|
|
1710
|
-
/** @internal */
|
|
1711
|
-
r(this, Ie, !1);
|
|
1712
|
-
/** @internal */
|
|
1713
|
-
r(this, Ve, !0);
|
|
1714
|
-
/** @internal */
|
|
1715
|
-
r(this, Qe);
|
|
1716
|
-
this[Q] = this[H] = e, this[G] = t, this[Z] = s;
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
r(w, Re, "Table"), /** @internal */
|
|
1720
|
-
r(w, "Symbol", {
|
|
1721
|
-
Name: Q,
|
|
1722
|
-
Schema: G,
|
|
1723
|
-
OriginalName: H,
|
|
1724
|
-
Columns: he,
|
|
1725
|
-
ExtraConfigColumns: ge,
|
|
1726
|
-
BaseName: Z,
|
|
1727
|
-
IsAlias: _,
|
|
1728
|
-
ExtraConfigBuilder: be
|
|
1729
|
-
});
|
|
1730
|
-
function Io(n) {
|
|
1731
|
-
return n != null && typeof n.getSQL == "function";
|
|
1732
|
-
}
|
|
1733
|
-
function jo(n) {
|
|
1734
|
-
var t;
|
|
1735
|
-
const e = { sql: "", params: [] };
|
|
1736
|
-
for (const s of n)
|
|
1737
|
-
e.sql += s.sql, e.params.push(...s.params), (t = s.typings) != null && t.length && (e.typings || (e.typings = []), e.typings.push(...s.typings));
|
|
1738
|
-
return e;
|
|
1739
|
-
}
|
|
1740
|
-
var Je;
|
|
1741
|
-
Je = c;
|
|
1742
|
-
class C {
|
|
1743
|
-
constructor(e) {
|
|
1744
|
-
r(this, "value");
|
|
1745
|
-
this.value = Array.isArray(e) ? e : [e];
|
|
1746
|
-
}
|
|
1747
|
-
getSQL() {
|
|
1748
|
-
return new N([this]);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
r(C, Je, "StringChunk");
|
|
1752
|
-
var Ke;
|
|
1753
|
-
Ke = c;
|
|
1754
|
-
const z = class z {
|
|
1755
|
-
constructor(e) {
|
|
1756
|
-
/** @internal */
|
|
1757
|
-
r(this, "decoder", xi);
|
|
1758
|
-
r(this, "shouldInlineParams", !1);
|
|
1759
|
-
/** @internal */
|
|
1760
|
-
r(this, "usedTables", []);
|
|
1761
|
-
this.queryChunks = e;
|
|
1762
|
-
for (const t of e)
|
|
1763
|
-
if (T(t, w)) {
|
|
1764
|
-
const s = t[w.Symbol.Schema];
|
|
1765
|
-
this.usedTables.push(
|
|
1766
|
-
s === void 0 ? t[w.Symbol.Name] : s + "." + t[w.Symbol.Name]
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
append(e) {
|
|
1771
|
-
return this.queryChunks.push(...e.queryChunks), this;
|
|
1772
|
-
}
|
|
1773
|
-
toQuery(e) {
|
|
1774
|
-
return Qo.startActiveSpan("drizzle.buildSQL", (t) => {
|
|
1775
|
-
const s = this.buildQueryFromSourceParams(this.queryChunks, e);
|
|
1776
|
-
return t == null || t.setAttributes({
|
|
1777
|
-
"drizzle.query.text": s.sql,
|
|
1778
|
-
"drizzle.query.params": JSON.stringify(s.params)
|
|
1779
|
-
}), s;
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
buildQueryFromSourceParams(e, t) {
|
|
1783
|
-
const s = Object.assign({}, t, {
|
|
1784
|
-
inlineParams: t.inlineParams || this.shouldInlineParams,
|
|
1785
|
-
paramStartIndex: t.paramStartIndex || { value: 0 }
|
|
1786
|
-
}), {
|
|
1787
|
-
casing: i,
|
|
1788
|
-
escapeName: o,
|
|
1789
|
-
escapeParam: l,
|
|
1790
|
-
prepareTyping: a,
|
|
1791
|
-
inlineParams: m,
|
|
1792
|
-
paramStartIndex: d
|
|
1793
|
-
} = s;
|
|
1794
|
-
return jo(e.map((u) => {
|
|
1795
|
-
var f;
|
|
1796
|
-
if (T(u, C))
|
|
1797
|
-
return { sql: u.value.join(""), params: [] };
|
|
1798
|
-
if (T(u, U))
|
|
1799
|
-
return { sql: o(u.value), params: [] };
|
|
1800
|
-
if (u === void 0)
|
|
1801
|
-
return { sql: "", params: [] };
|
|
1802
|
-
if (Array.isArray(u)) {
|
|
1803
|
-
const p = [new C("(")];
|
|
1804
|
-
for (const [h, A] of u.entries())
|
|
1805
|
-
p.push(A), h < u.length - 1 && p.push(new C(", "));
|
|
1806
|
-
return p.push(new C(")")), this.buildQueryFromSourceParams(p, s);
|
|
1807
|
-
}
|
|
1808
|
-
if (T(u, z))
|
|
1809
|
-
return this.buildQueryFromSourceParams(u.queryChunks, {
|
|
1810
|
-
...s,
|
|
1811
|
-
inlineParams: m || u.shouldInlineParams
|
|
1812
|
-
});
|
|
1813
|
-
if (T(u, w)) {
|
|
1814
|
-
const p = u[w.Symbol.Schema], h = u[w.Symbol.Name];
|
|
1815
|
-
return {
|
|
1816
|
-
sql: p === void 0 || u[_] ? o(h) : o(p) + "." + o(h),
|
|
1817
|
-
params: []
|
|
1818
|
-
};
|
|
1819
|
-
}
|
|
1820
|
-
if (T(u, K)) {
|
|
1821
|
-
const p = i.getColumnCasing(u);
|
|
1822
|
-
if (t.invokeSource === "indexes")
|
|
1823
|
-
return { sql: o(p), params: [] };
|
|
1824
|
-
const h = u.table[w.Symbol.Schema];
|
|
1825
|
-
return {
|
|
1826
|
-
sql: u.table[_] || h === void 0 ? o(u.table[w.Symbol.Name]) + "." + o(p) : o(h) + "." + o(u.table[w.Symbol.Name]) + "." + o(p),
|
|
1827
|
-
params: []
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
if (T(u, Ti)) {
|
|
1831
|
-
const p = u[I].schema, h = u[I].name;
|
|
1832
|
-
return {
|
|
1833
|
-
sql: p === void 0 || u[I].isAlias ? o(h) : o(p) + "." + o(h),
|
|
1834
|
-
params: []
|
|
1835
|
-
};
|
|
1836
|
-
}
|
|
1837
|
-
if (T(u, se)) {
|
|
1838
|
-
if (T(u.value, O))
|
|
1839
|
-
return { sql: l(d.value++, u), params: [u], typings: ["none"] };
|
|
1840
|
-
const p = u.value === null ? null : u.encoder.mapToDriverValue(u.value);
|
|
1841
|
-
if (T(p, z))
|
|
1842
|
-
return this.buildQueryFromSourceParams([p], s);
|
|
1843
|
-
if (m)
|
|
1844
|
-
return { sql: this.mapInlineParam(p, s), params: [] };
|
|
1845
|
-
let h = ["none"];
|
|
1846
|
-
return a && (h = [a(u.encoder)]), { sql: l(d.value++, p), params: [p], typings: h };
|
|
1847
|
-
}
|
|
1848
|
-
return T(u, O) ? { sql: l(d.value++, u), params: [u], typings: ["none"] } : T(u, z.Aliased) && u.fieldAlias !== void 0 ? { sql: o(u.fieldAlias), params: [] } : T(u, ne) ? u._.isWith ? { sql: o(u._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
1849
|
-
new C("("),
|
|
1850
|
-
u._.sql,
|
|
1851
|
-
new C(") "),
|
|
1852
|
-
new U(u._.alias)
|
|
1853
|
-
], s) : Ao(u) ? u.schema ? { sql: o(u.schema) + "." + o(u.enumName), params: [] } : { sql: o(u.enumName), params: [] } : Io(u) ? (f = u.shouldOmitSQLParens) != null && f.call(u) ? this.buildQueryFromSourceParams([u.getSQL()], s) : this.buildQueryFromSourceParams([
|
|
1854
|
-
new C("("),
|
|
1855
|
-
u.getSQL(),
|
|
1856
|
-
new C(")")
|
|
1857
|
-
], s) : m ? { sql: this.mapInlineParam(u, s), params: [] } : { sql: l(d.value++, u), params: [u], typings: ["none"] };
|
|
1858
|
-
}));
|
|
1859
|
-
}
|
|
1860
|
-
mapInlineParam(e, { escapeString: t }) {
|
|
1861
|
-
if (e === null)
|
|
1862
|
-
return "null";
|
|
1863
|
-
if (typeof e == "number" || typeof e == "boolean")
|
|
1864
|
-
return e.toString();
|
|
1865
|
-
if (typeof e == "string")
|
|
1866
|
-
return t(e);
|
|
1867
|
-
if (typeof e == "object") {
|
|
1868
|
-
const s = e.toString();
|
|
1869
|
-
return t(s === "[object Object]" ? JSON.stringify(e) : s);
|
|
1870
|
-
}
|
|
1871
|
-
throw new Error("Unexpected param value: " + e);
|
|
1872
|
-
}
|
|
1873
|
-
getSQL() {
|
|
1874
|
-
return this;
|
|
1875
|
-
}
|
|
1876
|
-
as(e) {
|
|
1877
|
-
return e === void 0 ? this : new z.Aliased(this, e);
|
|
1878
|
-
}
|
|
1879
|
-
mapWith(e) {
|
|
1880
|
-
return this.decoder = typeof e == "function" ? { mapFromDriverValue: e } : e, this;
|
|
1881
|
-
}
|
|
1882
|
-
inlineParams() {
|
|
1883
|
-
return this.shouldInlineParams = !0, this;
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* This method is used to conditionally include a part of the query.
|
|
1887
|
-
*
|
|
1888
|
-
* @param condition - Condition to check
|
|
1889
|
-
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
1890
|
-
*/
|
|
1891
|
-
if(e) {
|
|
1892
|
-
return e ? this : void 0;
|
|
1893
|
-
}
|
|
1894
|
-
};
|
|
1895
|
-
r(z, Ke, "SQL");
|
|
1896
|
-
let N = z;
|
|
1897
|
-
var We;
|
|
1898
|
-
We = c;
|
|
1899
|
-
class U {
|
|
1900
|
-
constructor(e) {
|
|
1901
|
-
r(this, "brand");
|
|
1902
|
-
this.value = e;
|
|
1903
|
-
}
|
|
1904
|
-
getSQL() {
|
|
1905
|
-
return new N([this]);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
r(U, We, "Name");
|
|
1909
|
-
const xi = {
|
|
1910
|
-
mapFromDriverValue: (n) => n
|
|
1911
|
-
}, Ni = {
|
|
1912
|
-
mapToDriverValue: (n) => n
|
|
1913
|
-
};
|
|
1914
|
-
({
|
|
1915
|
-
...xi,
|
|
1916
|
-
...Ni
|
|
1917
|
-
});
|
|
1918
|
-
var Ye;
|
|
1919
|
-
Ye = c;
|
|
1920
|
-
class se {
|
|
1921
|
-
/**
|
|
1922
|
-
* @param value - Parameter value
|
|
1923
|
-
* @param encoder - Encoder to convert the value to a driver parameter
|
|
1924
|
-
*/
|
|
1925
|
-
constructor(e, t = Ni) {
|
|
1926
|
-
r(this, "brand");
|
|
1927
|
-
this.value = e, this.encoder = t;
|
|
1928
|
-
}
|
|
1929
|
-
getSQL() {
|
|
1930
|
-
return new N([this]);
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
r(se, Ye, "Param");
|
|
1934
|
-
function q(n, ...e) {
|
|
1935
|
-
const t = [];
|
|
1936
|
-
(e.length > 0 || n.length > 0 && n[0] !== "") && t.push(new C(n[0]));
|
|
1937
|
-
for (const [s, i] of e.entries())
|
|
1938
|
-
t.push(i, new C(n[s + 1]));
|
|
1939
|
-
return new N(t);
|
|
1940
|
-
}
|
|
1941
|
-
((n) => {
|
|
1942
|
-
function e() {
|
|
1943
|
-
return new N([]);
|
|
1944
|
-
}
|
|
1945
|
-
n.empty = e;
|
|
1946
|
-
function t(m) {
|
|
1947
|
-
return new N(m);
|
|
1948
|
-
}
|
|
1949
|
-
n.fromList = t;
|
|
1950
|
-
function s(m) {
|
|
1951
|
-
return new N([new C(m)]);
|
|
1952
|
-
}
|
|
1953
|
-
n.raw = s;
|
|
1954
|
-
function i(m, d) {
|
|
1955
|
-
const u = [];
|
|
1956
|
-
for (const [f, p] of m.entries())
|
|
1957
|
-
f > 0 && d !== void 0 && u.push(d), u.push(p);
|
|
1958
|
-
return new N(u);
|
|
1959
|
-
}
|
|
1960
|
-
n.join = i;
|
|
1961
|
-
function o(m) {
|
|
1962
|
-
return new U(m);
|
|
1963
|
-
}
|
|
1964
|
-
n.identifier = o;
|
|
1965
|
-
function l(m) {
|
|
1966
|
-
return new O(m);
|
|
1967
|
-
}
|
|
1968
|
-
n.placeholder = l;
|
|
1969
|
-
function a(m, d) {
|
|
1970
|
-
return new se(m, d);
|
|
1971
|
-
}
|
|
1972
|
-
n.param = a;
|
|
1973
|
-
})(q || (q = {}));
|
|
1974
|
-
((n) => {
|
|
1975
|
-
var t;
|
|
1976
|
-
t = c;
|
|
1977
|
-
const s = class s {
|
|
1978
|
-
constructor(o, l) {
|
|
1979
|
-
/** @internal */
|
|
1980
|
-
r(this, "isSelectionField", !1);
|
|
1981
|
-
this.sql = o, this.fieldAlias = l;
|
|
1982
|
-
}
|
|
1983
|
-
getSQL() {
|
|
1984
|
-
return this.sql;
|
|
1985
|
-
}
|
|
1986
|
-
/** @internal */
|
|
1987
|
-
clone() {
|
|
1988
|
-
return new s(this.sql, this.fieldAlias);
|
|
1989
|
-
}
|
|
1990
|
-
};
|
|
1991
|
-
r(s, t, "SQL.Aliased");
|
|
1992
|
-
let e = s;
|
|
1993
|
-
n.Aliased = e;
|
|
1994
|
-
})(N || (N = {}));
|
|
1995
|
-
var Ge;
|
|
1996
|
-
Ge = c;
|
|
1997
|
-
class O {
|
|
1998
|
-
constructor(e) {
|
|
1999
|
-
this.name = e;
|
|
2000
|
-
}
|
|
2001
|
-
getSQL() {
|
|
2002
|
-
return new N([this]);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
r(O, Ge, "Placeholder");
|
|
2006
|
-
const _o = Symbol.for("drizzle:IsDrizzleView");
|
|
2007
|
-
var He, Ze, Xe;
|
|
2008
|
-
Xe = c, Ze = I, He = _o;
|
|
2009
|
-
class Ti {
|
|
2010
|
-
constructor({ name: e, schema: t, selectedFields: s, query: i }) {
|
|
2011
|
-
/** @internal */
|
|
2012
|
-
r(this, Ze);
|
|
2013
|
-
/** @internal */
|
|
2014
|
-
r(this, He, !0);
|
|
2015
|
-
this[I] = {
|
|
2016
|
-
name: e,
|
|
2017
|
-
originalName: e,
|
|
2018
|
-
schema: t,
|
|
2019
|
-
selectedFields: s,
|
|
2020
|
-
query: i,
|
|
2021
|
-
isExisting: !i,
|
|
2022
|
-
isAlias: !1
|
|
2023
|
-
};
|
|
2024
|
-
}
|
|
2025
|
-
getSQL() {
|
|
2026
|
-
return new N([this]);
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
r(Ti, Xe, "View");
|
|
2030
|
-
K.prototype.getSQL = function() {
|
|
2031
|
-
return new N([this]);
|
|
2032
|
-
};
|
|
2033
|
-
w.prototype.getSQL = function() {
|
|
2034
|
-
return new N([this]);
|
|
2035
|
-
};
|
|
2036
|
-
ne.prototype.getSQL = function() {
|
|
2037
|
-
return new N([this]);
|
|
2038
|
-
};
|
|
2039
|
-
function x(n, e) {
|
|
2040
|
-
return {
|
|
2041
|
-
name: typeof n == "string" && n.length > 0 ? n : "",
|
|
2042
|
-
config: typeof n == "object" ? n : e
|
|
2043
|
-
};
|
|
2044
|
-
}
|
|
2045
|
-
var ke, et;
|
|
2046
|
-
class j extends (et = b, ke = c, et) {
|
|
2047
|
-
generatedAlwaysAsIdentity(e) {
|
|
2048
|
-
if (e) {
|
|
2049
|
-
const { name: t, ...s } = e;
|
|
2050
|
-
this.config.generatedIdentity = {
|
|
2051
|
-
type: "always",
|
|
2052
|
-
sequenceName: t,
|
|
2053
|
-
sequenceOptions: s
|
|
2054
|
-
};
|
|
2055
|
-
} else
|
|
2056
|
-
this.config.generatedIdentity = {
|
|
2057
|
-
type: "always"
|
|
2058
|
-
};
|
|
2059
|
-
return this.config.hasDefault = !0, this.config.notNull = !0, this;
|
|
2060
|
-
}
|
|
2061
|
-
generatedByDefaultAsIdentity(e) {
|
|
2062
|
-
if (e) {
|
|
2063
|
-
const { name: t, ...s } = e;
|
|
2064
|
-
this.config.generatedIdentity = {
|
|
2065
|
-
type: "byDefault",
|
|
2066
|
-
sequenceName: t,
|
|
2067
|
-
sequenceOptions: s
|
|
2068
|
-
};
|
|
2069
|
-
} else
|
|
2070
|
-
this.config.generatedIdentity = {
|
|
2071
|
-
type: "byDefault"
|
|
2072
|
-
};
|
|
2073
|
-
return this.config.hasDefault = !0, this.config.notNull = !0, this;
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
r(j, ke, "PgIntColumnBaseBuilder");
|
|
2077
|
-
var tt, nt;
|
|
2078
|
-
class Ci extends (nt = j, tt = c, nt) {
|
|
2079
|
-
constructor(e) {
|
|
2080
|
-
super(e, "number", "PgBigInt53");
|
|
2081
|
-
}
|
|
2082
|
-
/** @internal */
|
|
2083
|
-
build(e) {
|
|
2084
|
-
return new Si(e, this.config);
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
r(Ci, tt, "PgBigInt53Builder");
|
|
2088
|
-
var st, it;
|
|
2089
|
-
class Si extends (it = g, st = c, it) {
|
|
2090
|
-
getSQLType() {
|
|
2091
|
-
return "bigint";
|
|
2092
|
-
}
|
|
2093
|
-
mapFromDriverValue(e) {
|
|
2094
|
-
return typeof e == "number" ? e : Number(e);
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
r(Si, st, "PgBigInt53");
|
|
2098
|
-
var rt, ot;
|
|
2099
|
-
class Pi extends (ot = j, rt = c, ot) {
|
|
2100
|
-
constructor(e) {
|
|
2101
|
-
super(e, "bigint", "PgBigInt64");
|
|
2102
|
-
}
|
|
2103
|
-
/** @internal */
|
|
2104
|
-
build(e) {
|
|
2105
|
-
return new Di(
|
|
2106
|
-
e,
|
|
2107
|
-
this.config
|
|
2108
|
-
);
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
r(Pi, rt, "PgBigInt64Builder");
|
|
2112
|
-
var at, ut;
|
|
2113
|
-
class Di extends (ut = g, at = c, ut) {
|
|
2114
|
-
getSQLType() {
|
|
2115
|
-
return "bigint";
|
|
2116
|
-
}
|
|
2117
|
-
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
2118
|
-
mapFromDriverValue(e) {
|
|
2119
|
-
return BigInt(e);
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
r(Di, at, "PgBigInt64");
|
|
2123
|
-
function Uo(n, e) {
|
|
2124
|
-
const { name: t, config: s } = x(n, e);
|
|
2125
|
-
return s.mode === "number" ? new Ci(t) : new Pi(t);
|
|
2126
|
-
}
|
|
2127
|
-
var ct, lt;
|
|
2128
|
-
class vi extends (lt = b, ct = c, lt) {
|
|
2129
|
-
constructor(e) {
|
|
2130
|
-
super(e, "number", "PgBigSerial53"), this.config.hasDefault = !0, this.config.notNull = !0;
|
|
2131
|
-
}
|
|
2132
|
-
/** @internal */
|
|
2133
|
-
build(e) {
|
|
2134
|
-
return new Ei(
|
|
2135
|
-
e,
|
|
2136
|
-
this.config
|
|
2137
|
-
);
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
r(vi, ct, "PgBigSerial53Builder");
|
|
2141
|
-
var mt, dt;
|
|
2142
|
-
class Ei extends (dt = g, mt = c, dt) {
|
|
2143
|
-
getSQLType() {
|
|
2144
|
-
return "bigserial";
|
|
2145
|
-
}
|
|
2146
|
-
mapFromDriverValue(e) {
|
|
2147
|
-
return typeof e == "number" ? e : Number(e);
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
r(Ei, mt, "PgBigSerial53");
|
|
2151
|
-
var ft, pt;
|
|
2152
|
-
class $i extends (pt = b, ft = c, pt) {
|
|
2153
|
-
constructor(e) {
|
|
2154
|
-
super(e, "bigint", "PgBigSerial64"), this.config.hasDefault = !0;
|
|
2155
|
-
}
|
|
2156
|
-
/** @internal */
|
|
2157
|
-
build(e) {
|
|
2158
|
-
return new Bi(
|
|
2159
|
-
e,
|
|
2160
|
-
this.config
|
|
2161
|
-
);
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
r($i, ft, "PgBigSerial64Builder");
|
|
2165
|
-
var ht, gt;
|
|
2166
|
-
class Bi extends (gt = g, ht = c, gt) {
|
|
2167
|
-
getSQLType() {
|
|
2168
|
-
return "bigserial";
|
|
2169
|
-
}
|
|
2170
|
-
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
2171
|
-
mapFromDriverValue(e) {
|
|
2172
|
-
return BigInt(e);
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
r(Bi, ht, "PgBigSerial64");
|
|
2176
|
-
function qo(n, e) {
|
|
2177
|
-
const { name: t, config: s } = x(n, e);
|
|
2178
|
-
return s.mode === "number" ? new vi(t) : new $i(t);
|
|
2179
|
-
}
|
|
2180
|
-
var bt, yt;
|
|
2181
|
-
class zi extends (yt = b, bt = c, yt) {
|
|
2182
|
-
constructor(e) {
|
|
2183
|
-
super(e, "boolean", "PgBoolean");
|
|
2184
|
-
}
|
|
2185
|
-
/** @internal */
|
|
2186
|
-
build(e) {
|
|
2187
|
-
return new Fi(e, this.config);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
r(zi, bt, "PgBooleanBuilder");
|
|
2191
|
-
var wt, xt;
|
|
2192
|
-
class Fi extends (xt = g, wt = c, xt) {
|
|
2193
|
-
getSQLType() {
|
|
2194
|
-
return "boolean";
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
r(Fi, wt, "PgBoolean");
|
|
2198
|
-
function ie(n) {
|
|
2199
|
-
return new zi(n ?? "");
|
|
2200
|
-
}
|
|
2201
|
-
var Nt, Tt;
|
|
2202
|
-
class Li extends (Tt = b, Nt = c, Tt) {
|
|
2203
|
-
constructor(e, t) {
|
|
2204
|
-
super(e, "string", "PgChar"), this.config.length = t.length, this.config.enumValues = t.enum;
|
|
2205
|
-
}
|
|
2206
|
-
/** @internal */
|
|
2207
|
-
build(e) {
|
|
2208
|
-
return new Ai(
|
|
2209
|
-
e,
|
|
2210
|
-
this.config
|
|
2211
|
-
);
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
r(Li, Nt, "PgCharBuilder");
|
|
2215
|
-
var Ct, St;
|
|
2216
|
-
class Ai extends (St = g, Ct = c, St) {
|
|
2217
|
-
constructor() {
|
|
2218
|
-
super(...arguments);
|
|
2219
|
-
r(this, "length", this.config.length);
|
|
2220
|
-
r(this, "enumValues", this.config.enumValues);
|
|
2221
|
-
}
|
|
2222
|
-
getSQLType() {
|
|
2223
|
-
return this.length === void 0 ? "char" : `char(${this.length})`;
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
r(Ai, Ct, "PgChar");
|
|
2227
|
-
function Oo(n, e = {}) {
|
|
2228
|
-
const { name: t, config: s } = x(n, e);
|
|
2229
|
-
return new Li(t, s);
|
|
2230
|
-
}
|
|
2231
|
-
var Pt, Dt;
|
|
2232
|
-
class Qi extends (Dt = b, Pt = c, Dt) {
|
|
2233
|
-
constructor(e) {
|
|
2234
|
-
super(e, "string", "PgCidr");
|
|
2235
|
-
}
|
|
2236
|
-
/** @internal */
|
|
2237
|
-
build(e) {
|
|
2238
|
-
return new Vi(e, this.config);
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
r(Qi, Pt, "PgCidrBuilder");
|
|
2242
|
-
var vt, Et;
|
|
2243
|
-
class Vi extends (Et = g, vt = c, Et) {
|
|
2244
|
-
getSQLType() {
|
|
2245
|
-
return "cidr";
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
r(Vi, vt, "PgCidr");
|
|
2249
|
-
function Mo(n) {
|
|
2250
|
-
return new Qi(n ?? "");
|
|
2251
|
-
}
|
|
2252
|
-
var $t, Bt;
|
|
2253
|
-
class Ii extends (Bt = b, $t = c, Bt) {
|
|
2254
|
-
constructor(e, t, s) {
|
|
2255
|
-
super(e, "custom", "PgCustomColumn"), this.config.fieldConfig = t, this.config.customTypeParams = s;
|
|
2256
|
-
}
|
|
2257
|
-
/** @internal */
|
|
2258
|
-
build(e) {
|
|
2259
|
-
return new ji(
|
|
2260
|
-
e,
|
|
2261
|
-
this.config
|
|
2262
|
-
);
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
r(Ii, $t, "PgCustomColumnBuilder");
|
|
2266
|
-
var zt, Ft;
|
|
2267
|
-
class ji extends (Ft = g, zt = c, Ft) {
|
|
2268
|
-
constructor(t, s) {
|
|
2269
|
-
super(t, s);
|
|
2270
|
-
r(this, "sqlName");
|
|
2271
|
-
r(this, "mapTo");
|
|
2272
|
-
r(this, "mapFrom");
|
|
2273
|
-
this.sqlName = s.customTypeParams.dataType(s.fieldConfig), this.mapTo = s.customTypeParams.toDriver, this.mapFrom = s.customTypeParams.fromDriver;
|
|
2274
|
-
}
|
|
2275
|
-
getSQLType() {
|
|
2276
|
-
return this.sqlName;
|
|
2277
|
-
}
|
|
2278
|
-
mapFromDriverValue(t) {
|
|
2279
|
-
return typeof this.mapFrom == "function" ? this.mapFrom(t) : t;
|
|
2280
|
-
}
|
|
2281
|
-
mapToDriverValue(t) {
|
|
2282
|
-
return typeof this.mapTo == "function" ? this.mapTo(t) : t;
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
r(ji, zt, "PgCustomColumn");
|
|
2286
|
-
function Ro(n) {
|
|
2287
|
-
return (e, t) => {
|
|
2288
|
-
const { name: s, config: i } = x(e, t);
|
|
2289
|
-
return new Ii(s, i, n);
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
var Lt, At;
|
|
2293
|
-
class V extends (At = b, Lt = c, At) {
|
|
2294
|
-
defaultNow() {
|
|
2295
|
-
return this.default(q`now()`);
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
r(V, Lt, "PgDateColumnBaseBuilder");
|
|
2299
|
-
var Qt, Vt;
|
|
2300
|
-
class _i extends (Vt = V, Qt = c, Vt) {
|
|
2301
|
-
constructor(e) {
|
|
2302
|
-
super(e, "date", "PgDate");
|
|
2303
|
-
}
|
|
2304
|
-
/** @internal */
|
|
2305
|
-
build(e) {
|
|
2306
|
-
return new Ui(e, this.config);
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
r(_i, Qt, "PgDateBuilder");
|
|
2310
|
-
var It, jt;
|
|
2311
|
-
class Ui extends (jt = g, It = c, jt) {
|
|
2312
|
-
getSQLType() {
|
|
2313
|
-
return "date";
|
|
2314
|
-
}
|
|
2315
|
-
mapFromDriverValue(e) {
|
|
2316
|
-
return new Date(e);
|
|
2317
|
-
}
|
|
2318
|
-
mapToDriverValue(e) {
|
|
2319
|
-
return e.toISOString();
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
r(Ui, It, "PgDate");
|
|
2323
|
-
var _t, Ut;
|
|
2324
|
-
class qi extends (Ut = V, _t = c, Ut) {
|
|
2325
|
-
constructor(e) {
|
|
2326
|
-
super(e, "string", "PgDateString");
|
|
2327
|
-
}
|
|
2328
|
-
/** @internal */
|
|
2329
|
-
build(e) {
|
|
2330
|
-
return new Oi(
|
|
2331
|
-
e,
|
|
2332
|
-
this.config
|
|
2333
|
-
);
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
r(qi, _t, "PgDateStringBuilder");
|
|
2337
|
-
var qt, Ot;
|
|
2338
|
-
class Oi extends (Ot = g, qt = c, Ot) {
|
|
2339
|
-
getSQLType() {
|
|
2340
|
-
return "date";
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
r(Oi, qt, "PgDateString");
|
|
2344
|
-
function Jo(n, e) {
|
|
2345
|
-
const { name: t, config: s } = x(n, e);
|
|
2346
|
-
return (s == null ? void 0 : s.mode) === "date" ? new _i(t) : new qi(t);
|
|
2347
|
-
}
|
|
2348
|
-
var Mt, Rt;
|
|
2349
|
-
class Mi extends (Rt = b, Mt = c, Rt) {
|
|
2350
|
-
constructor(e) {
|
|
2351
|
-
super(e, "number", "PgDoublePrecision");
|
|
2352
|
-
}
|
|
2353
|
-
/** @internal */
|
|
2354
|
-
build(e) {
|
|
2355
|
-
return new Ri(
|
|
2356
|
-
e,
|
|
2357
|
-
this.config
|
|
2358
|
-
);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
r(Mi, Mt, "PgDoublePrecisionBuilder");
|
|
2362
|
-
var Jt, Kt;
|
|
2363
|
-
class Ri extends (Kt = g, Jt = c, Kt) {
|
|
2364
|
-
getSQLType() {
|
|
2365
|
-
return "double precision";
|
|
2366
|
-
}
|
|
2367
|
-
mapFromDriverValue(e) {
|
|
2368
|
-
return typeof e == "string" ? Number.parseFloat(e) : e;
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
r(Ri, Jt, "PgDoublePrecision");
|
|
2372
|
-
function Ko(n) {
|
|
2373
|
-
return new Mi(n ?? "");
|
|
2374
|
-
}
|
|
2375
|
-
var Wt, Yt;
|
|
2376
|
-
class Ji extends (Yt = b, Wt = c, Yt) {
|
|
2377
|
-
constructor(e) {
|
|
2378
|
-
super(e, "string", "PgInet");
|
|
2379
|
-
}
|
|
2380
|
-
/** @internal */
|
|
2381
|
-
build(e) {
|
|
2382
|
-
return new Ki(e, this.config);
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
r(Ji, Wt, "PgInetBuilder");
|
|
2386
|
-
var Gt, Ht;
|
|
2387
|
-
class Ki extends (Ht = g, Gt = c, Ht) {
|
|
2388
|
-
getSQLType() {
|
|
2389
|
-
return "inet";
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
r(Ki, Gt, "PgInet");
|
|
2393
|
-
function Wo(n) {
|
|
2394
|
-
return new Ji(n ?? "");
|
|
2395
|
-
}
|
|
2396
|
-
var Zt, Xt;
|
|
2397
|
-
class Wi extends (Xt = j, Zt = c, Xt) {
|
|
2398
|
-
constructor(e) {
|
|
2399
|
-
super(e, "number", "PgInteger");
|
|
2400
|
-
}
|
|
2401
|
-
/** @internal */
|
|
2402
|
-
build(e) {
|
|
2403
|
-
return new Yi(e, this.config);
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
r(Wi, Zt, "PgIntegerBuilder");
|
|
2407
|
-
var kt, en;
|
|
2408
|
-
class Yi extends (en = g, kt = c, en) {
|
|
2409
|
-
getSQLType() {
|
|
2410
|
-
return "integer";
|
|
2411
|
-
}
|
|
2412
|
-
mapFromDriverValue(e) {
|
|
2413
|
-
return typeof e == "string" ? Number.parseInt(e) : e;
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
r(Yi, kt, "PgInteger");
|
|
2417
|
-
function D(n) {
|
|
2418
|
-
return new Wi(n ?? "");
|
|
2419
|
-
}
|
|
2420
|
-
var tn, nn;
|
|
2421
|
-
class Gi extends (nn = b, tn = c, nn) {
|
|
2422
|
-
constructor(e, t) {
|
|
2423
|
-
super(e, "string", "PgInterval"), this.config.intervalConfig = t;
|
|
2424
|
-
}
|
|
2425
|
-
/** @internal */
|
|
2426
|
-
build(e) {
|
|
2427
|
-
return new Hi(e, this.config);
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
r(Gi, tn, "PgIntervalBuilder");
|
|
2431
|
-
var sn, rn;
|
|
2432
|
-
class Hi extends (rn = g, sn = c, rn) {
|
|
2433
|
-
constructor() {
|
|
2434
|
-
super(...arguments);
|
|
2435
|
-
r(this, "fields", this.config.intervalConfig.fields);
|
|
2436
|
-
r(this, "precision", this.config.intervalConfig.precision);
|
|
2437
|
-
}
|
|
2438
|
-
getSQLType() {
|
|
2439
|
-
const t = this.fields ? ` ${this.fields}` : "", s = this.precision ? `(${this.precision})` : "";
|
|
2440
|
-
return `interval${t}${s}`;
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
r(Hi, sn, "PgInterval");
|
|
2444
|
-
function Yo(n, e = {}) {
|
|
2445
|
-
const { name: t, config: s } = x(n, e);
|
|
2446
|
-
return new Gi(t, s);
|
|
2447
|
-
}
|
|
2448
|
-
var on, an;
|
|
2449
|
-
class Zi extends (an = b, on = c, an) {
|
|
2450
|
-
constructor(e) {
|
|
2451
|
-
super(e, "json", "PgJson");
|
|
2452
|
-
}
|
|
2453
|
-
/** @internal */
|
|
2454
|
-
build(e) {
|
|
2455
|
-
return new Xi(e, this.config);
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
r(Zi, on, "PgJsonBuilder");
|
|
2459
|
-
var un, cn;
|
|
2460
|
-
class Xi extends (cn = g, un = c, cn) {
|
|
2461
|
-
constructor(e, t) {
|
|
2462
|
-
super(e, t);
|
|
2463
|
-
}
|
|
2464
|
-
getSQLType() {
|
|
2465
|
-
return "json";
|
|
2466
|
-
}
|
|
2467
|
-
mapToDriverValue(e) {
|
|
2468
|
-
return JSON.stringify(e);
|
|
2469
|
-
}
|
|
2470
|
-
mapFromDriverValue(e) {
|
|
2471
|
-
if (typeof e == "string")
|
|
2472
|
-
try {
|
|
2473
|
-
return JSON.parse(e);
|
|
2474
|
-
} catch {
|
|
2475
|
-
return e;
|
|
2476
|
-
}
|
|
2477
|
-
return e;
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
r(Xi, un, "PgJson");
|
|
2481
|
-
function Go(n) {
|
|
2482
|
-
return new Zi(n ?? "");
|
|
2483
|
-
}
|
|
2484
|
-
var ln, mn;
|
|
2485
|
-
class ki extends (mn = b, ln = c, mn) {
|
|
2486
|
-
constructor(e) {
|
|
2487
|
-
super(e, "json", "PgJsonb");
|
|
2488
|
-
}
|
|
2489
|
-
/** @internal */
|
|
2490
|
-
build(e) {
|
|
2491
|
-
return new er(e, this.config);
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
|
-
r(ki, ln, "PgJsonbBuilder");
|
|
2495
|
-
var dn, fn;
|
|
2496
|
-
class er extends (fn = g, dn = c, fn) {
|
|
2497
|
-
constructor(e, t) {
|
|
2498
|
-
super(e, t);
|
|
2499
|
-
}
|
|
2500
|
-
getSQLType() {
|
|
2501
|
-
return "jsonb";
|
|
2502
|
-
}
|
|
2503
|
-
mapToDriverValue(e) {
|
|
2504
|
-
return JSON.stringify(e);
|
|
2505
|
-
}
|
|
2506
|
-
mapFromDriverValue(e) {
|
|
2507
|
-
if (typeof e == "string")
|
|
2508
|
-
try {
|
|
2509
|
-
return JSON.parse(e);
|
|
2510
|
-
} catch {
|
|
2511
|
-
return e;
|
|
2512
|
-
}
|
|
2513
|
-
return e;
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
r(er, dn, "PgJsonb");
|
|
2517
|
-
function Ho(n) {
|
|
2518
|
-
return new ki(n ?? "");
|
|
2519
|
-
}
|
|
2520
|
-
var pn, hn;
|
|
2521
|
-
class tr extends (hn = b, pn = c, hn) {
|
|
2522
|
-
constructor(e) {
|
|
2523
|
-
super(e, "array", "PgLine");
|
|
2524
|
-
}
|
|
2525
|
-
/** @internal */
|
|
2526
|
-
build(e) {
|
|
2527
|
-
return new nr(
|
|
2528
|
-
e,
|
|
2529
|
-
this.config
|
|
2530
|
-
);
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
r(tr, pn, "PgLineBuilder");
|
|
2534
|
-
var gn, bn;
|
|
2535
|
-
class nr extends (bn = g, gn = c, bn) {
|
|
2536
|
-
getSQLType() {
|
|
2537
|
-
return "line";
|
|
2538
|
-
}
|
|
2539
|
-
mapFromDriverValue(e) {
|
|
2540
|
-
const [t, s, i] = e.slice(1, -1).split(",");
|
|
2541
|
-
return [Number.parseFloat(t), Number.parseFloat(s), Number.parseFloat(i)];
|
|
2542
|
-
}
|
|
2543
|
-
mapToDriverValue(e) {
|
|
2544
|
-
return `{${e[0]},${e[1]},${e[2]}}`;
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
r(nr, gn, "PgLine");
|
|
2548
|
-
var yn, wn;
|
|
2549
|
-
class sr extends (wn = b, yn = c, wn) {
|
|
2550
|
-
constructor(e) {
|
|
2551
|
-
super(e, "json", "PgLineABC");
|
|
2552
|
-
}
|
|
2553
|
-
/** @internal */
|
|
2554
|
-
build(e) {
|
|
2555
|
-
return new ir(
|
|
2556
|
-
e,
|
|
2557
|
-
this.config
|
|
2558
|
-
);
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
r(sr, yn, "PgLineABCBuilder");
|
|
2562
|
-
var xn, Nn;
|
|
2563
|
-
class ir extends (Nn = g, xn = c, Nn) {
|
|
2564
|
-
getSQLType() {
|
|
2565
|
-
return "line";
|
|
2566
|
-
}
|
|
2567
|
-
mapFromDriverValue(e) {
|
|
2568
|
-
const [t, s, i] = e.slice(1, -1).split(",");
|
|
2569
|
-
return { a: Number.parseFloat(t), b: Number.parseFloat(s), c: Number.parseFloat(i) };
|
|
2570
|
-
}
|
|
2571
|
-
mapToDriverValue(e) {
|
|
2572
|
-
return `{${e.a},${e.b},${e.c}}`;
|
|
2573
|
-
}
|
|
2574
|
-
}
|
|
2575
|
-
r(ir, xn, "PgLineABC");
|
|
2576
|
-
function Zo(n, e) {
|
|
2577
|
-
const { name: t, config: s } = x(n, e);
|
|
2578
|
-
return !(s != null && s.mode) || s.mode === "tuple" ? new tr(t) : new sr(t);
|
|
2579
|
-
}
|
|
2580
|
-
var Tn, Cn;
|
|
2581
|
-
class rr extends (Cn = b, Tn = c, Cn) {
|
|
2582
|
-
constructor(e) {
|
|
2583
|
-
super(e, "string", "PgMacaddr");
|
|
2584
|
-
}
|
|
2585
|
-
/** @internal */
|
|
2586
|
-
build(e) {
|
|
2587
|
-
return new or(e, this.config);
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
r(rr, Tn, "PgMacaddrBuilder");
|
|
2591
|
-
var Sn, Pn;
|
|
2592
|
-
class or extends (Pn = g, Sn = c, Pn) {
|
|
2593
|
-
getSQLType() {
|
|
2594
|
-
return "macaddr";
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
r(or, Sn, "PgMacaddr");
|
|
2598
|
-
function Xo(n) {
|
|
2599
|
-
return new rr(n ?? "");
|
|
2600
|
-
}
|
|
2601
|
-
var Dn, vn;
|
|
2602
|
-
class ar extends (vn = b, Dn = c, vn) {
|
|
2603
|
-
constructor(e) {
|
|
2604
|
-
super(e, "string", "PgMacaddr8");
|
|
2605
|
-
}
|
|
2606
|
-
/** @internal */
|
|
2607
|
-
build(e) {
|
|
2608
|
-
return new ur(e, this.config);
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
r(ar, Dn, "PgMacaddr8Builder");
|
|
2612
|
-
var En, $n;
|
|
2613
|
-
class ur extends ($n = g, En = c, $n) {
|
|
2614
|
-
getSQLType() {
|
|
2615
|
-
return "macaddr8";
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
r(ur, En, "PgMacaddr8");
|
|
2619
|
-
function ko(n) {
|
|
2620
|
-
return new ar(n ?? "");
|
|
2621
|
-
}
|
|
2622
|
-
var Bn, zn;
|
|
2623
|
-
class cr extends (zn = b, Bn = c, zn) {
|
|
2624
|
-
constructor(e, t, s) {
|
|
2625
|
-
super(e, "string", "PgNumeric"), this.config.precision = t, this.config.scale = s;
|
|
2626
|
-
}
|
|
2627
|
-
/** @internal */
|
|
2628
|
-
build(e) {
|
|
2629
|
-
return new lr(e, this.config);
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
r(cr, Bn, "PgNumericBuilder");
|
|
2633
|
-
var Fn, Ln;
|
|
2634
|
-
class lr extends (Ln = g, Fn = c, Ln) {
|
|
2635
|
-
constructor(t, s) {
|
|
2636
|
-
super(t, s);
|
|
2637
|
-
r(this, "precision");
|
|
2638
|
-
r(this, "scale");
|
|
2639
|
-
this.precision = s.precision, this.scale = s.scale;
|
|
2640
|
-
}
|
|
2641
|
-
mapFromDriverValue(t) {
|
|
2642
|
-
return typeof t == "string" ? t : String(t);
|
|
2643
|
-
}
|
|
2644
|
-
getSQLType() {
|
|
2645
|
-
return this.precision !== void 0 && this.scale !== void 0 ? `numeric(${this.precision}, ${this.scale})` : this.precision === void 0 ? "numeric" : `numeric(${this.precision})`;
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
r(lr, Fn, "PgNumeric");
|
|
2649
|
-
var An, Qn;
|
|
2650
|
-
class mr extends (Qn = b, An = c, Qn) {
|
|
2651
|
-
constructor(e, t, s) {
|
|
2652
|
-
super(e, "number", "PgNumericNumber"), this.config.precision = t, this.config.scale = s;
|
|
2653
|
-
}
|
|
2654
|
-
/** @internal */
|
|
2655
|
-
build(e) {
|
|
2656
|
-
return new dr(
|
|
2657
|
-
e,
|
|
2658
|
-
this.config
|
|
2659
|
-
);
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
r(mr, An, "PgNumericNumberBuilder");
|
|
2663
|
-
var Vn, In;
|
|
2664
|
-
class dr extends (In = g, Vn = c, In) {
|
|
2665
|
-
constructor(t, s) {
|
|
2666
|
-
super(t, s);
|
|
2667
|
-
r(this, "precision");
|
|
2668
|
-
r(this, "scale");
|
|
2669
|
-
r(this, "mapToDriverValue", String);
|
|
2670
|
-
this.precision = s.precision, this.scale = s.scale;
|
|
2671
|
-
}
|
|
2672
|
-
mapFromDriverValue(t) {
|
|
2673
|
-
return typeof t == "number" ? t : Number(t);
|
|
2674
|
-
}
|
|
2675
|
-
getSQLType() {
|
|
2676
|
-
return this.precision !== void 0 && this.scale !== void 0 ? `numeric(${this.precision}, ${this.scale})` : this.precision === void 0 ? "numeric" : `numeric(${this.precision})`;
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
r(dr, Vn, "PgNumericNumber");
|
|
2680
|
-
var jn, _n;
|
|
2681
|
-
class fr extends (_n = b, jn = c, _n) {
|
|
2682
|
-
constructor(e, t, s) {
|
|
2683
|
-
super(e, "bigint", "PgNumericBigInt"), this.config.precision = t, this.config.scale = s;
|
|
2684
|
-
}
|
|
2685
|
-
/** @internal */
|
|
2686
|
-
build(e) {
|
|
2687
|
-
return new pr(
|
|
2688
|
-
e,
|
|
2689
|
-
this.config
|
|
2690
|
-
);
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
r(fr, jn, "PgNumericBigIntBuilder");
|
|
2694
|
-
var Un, qn;
|
|
2695
|
-
class pr extends (qn = g, Un = c, qn) {
|
|
2696
|
-
constructor(t, s) {
|
|
2697
|
-
super(t, s);
|
|
2698
|
-
r(this, "precision");
|
|
2699
|
-
r(this, "scale");
|
|
2700
|
-
r(this, "mapFromDriverValue", BigInt);
|
|
2701
|
-
r(this, "mapToDriverValue", String);
|
|
2702
|
-
this.precision = s.precision, this.scale = s.scale;
|
|
2703
|
-
}
|
|
2704
|
-
getSQLType() {
|
|
2705
|
-
return this.precision !== void 0 && this.scale !== void 0 ? `numeric(${this.precision}, ${this.scale})` : this.precision === void 0 ? "numeric" : `numeric(${this.precision})`;
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
r(pr, Un, "PgNumericBigInt");
|
|
2709
|
-
function hr(n, e) {
|
|
2710
|
-
const { name: t, config: s } = x(n, e), i = s == null ? void 0 : s.mode;
|
|
2711
|
-
return i === "number" ? new mr(t, s == null ? void 0 : s.precision, s == null ? void 0 : s.scale) : i === "bigint" ? new fr(t, s == null ? void 0 : s.precision, s == null ? void 0 : s.scale) : new cr(t, s == null ? void 0 : s.precision, s == null ? void 0 : s.scale);
|
|
2712
|
-
}
|
|
2713
|
-
const ea = hr;
|
|
2714
|
-
var On, Mn;
|
|
2715
|
-
class gr extends (Mn = b, On = c, Mn) {
|
|
2716
|
-
constructor(e) {
|
|
2717
|
-
super(e, "array", "PgPointTuple");
|
|
2718
|
-
}
|
|
2719
|
-
/** @internal */
|
|
2720
|
-
build(e) {
|
|
2721
|
-
return new br(
|
|
2722
|
-
e,
|
|
2723
|
-
this.config
|
|
2724
|
-
);
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
r(gr, On, "PgPointTupleBuilder");
|
|
2728
|
-
var Rn, Jn;
|
|
2729
|
-
class br extends (Jn = g, Rn = c, Jn) {
|
|
2730
|
-
getSQLType() {
|
|
2731
|
-
return "point";
|
|
2732
|
-
}
|
|
2733
|
-
mapFromDriverValue(e) {
|
|
2734
|
-
if (typeof e == "string") {
|
|
2735
|
-
const [t, s] = e.slice(1, -1).split(",");
|
|
2736
|
-
return [Number.parseFloat(t), Number.parseFloat(s)];
|
|
2737
|
-
}
|
|
2738
|
-
return [e.x, e.y];
|
|
2739
|
-
}
|
|
2740
|
-
mapToDriverValue(e) {
|
|
2741
|
-
return `(${e[0]},${e[1]})`;
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
r(br, Rn, "PgPointTuple");
|
|
2745
|
-
var Kn, Wn;
|
|
2746
|
-
class yr extends (Wn = b, Kn = c, Wn) {
|
|
2747
|
-
constructor(e) {
|
|
2748
|
-
super(e, "json", "PgPointObject");
|
|
2749
|
-
}
|
|
2750
|
-
/** @internal */
|
|
2751
|
-
build(e) {
|
|
2752
|
-
return new wr(
|
|
2753
|
-
e,
|
|
2754
|
-
this.config
|
|
2755
|
-
);
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
r(yr, Kn, "PgPointObjectBuilder");
|
|
2759
|
-
var Yn, Gn;
|
|
2760
|
-
class wr extends (Gn = g, Yn = c, Gn) {
|
|
2761
|
-
getSQLType() {
|
|
2762
|
-
return "point";
|
|
2763
|
-
}
|
|
2764
|
-
mapFromDriverValue(e) {
|
|
2765
|
-
if (typeof e == "string") {
|
|
2766
|
-
const [t, s] = e.slice(1, -1).split(",");
|
|
2767
|
-
return { x: Number.parseFloat(t), y: Number.parseFloat(s) };
|
|
2768
|
-
}
|
|
2769
|
-
return e;
|
|
2770
|
-
}
|
|
2771
|
-
mapToDriverValue(e) {
|
|
2772
|
-
return `(${e.x},${e.y})`;
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
r(wr, Yn, "PgPointObject");
|
|
2776
|
-
function ta(n, e) {
|
|
2777
|
-
const { name: t, config: s } = x(n, e);
|
|
2778
|
-
return !(s != null && s.mode) || s.mode === "tuple" ? new gr(t) : new yr(t);
|
|
2779
|
-
}
|
|
2780
|
-
function na(n) {
|
|
2781
|
-
const e = [];
|
|
2782
|
-
for (let t = 0; t < n.length; t += 2)
|
|
2783
|
-
e.push(Number.parseInt(n.slice(t, t + 2), 16));
|
|
2784
|
-
return new Uint8Array(e);
|
|
2785
|
-
}
|
|
2786
|
-
function ye(n, e) {
|
|
2787
|
-
const t = new ArrayBuffer(8), s = new DataView(t);
|
|
2788
|
-
for (let i = 0; i < 8; i++)
|
|
2789
|
-
s.setUint8(i, n[e + i]);
|
|
2790
|
-
return s.getFloat64(0, !0);
|
|
2791
|
-
}
|
|
2792
|
-
function xr(n) {
|
|
2793
|
-
const e = na(n);
|
|
2794
|
-
let t = 0;
|
|
2795
|
-
const s = e[t];
|
|
2796
|
-
t += 1;
|
|
2797
|
-
const i = new DataView(e.buffer), o = i.getUint32(t, s === 1);
|
|
2798
|
-
if (t += 4, o & 536870912 && (i.getUint32(t, s === 1), t += 4), (o & 65535) === 1) {
|
|
2799
|
-
const l = ye(e, t);
|
|
2800
|
-
t += 8;
|
|
2801
|
-
const a = ye(e, t);
|
|
2802
|
-
return t += 8, [l, a];
|
|
2803
|
-
}
|
|
2804
|
-
throw new Error("Unsupported geometry type");
|
|
2805
|
-
}
|
|
2806
|
-
var Hn, Zn;
|
|
2807
|
-
class Nr extends (Zn = b, Hn = c, Zn) {
|
|
2808
|
-
constructor(e) {
|
|
2809
|
-
super(e, "array", "PgGeometry");
|
|
2810
|
-
}
|
|
2811
|
-
/** @internal */
|
|
2812
|
-
build(e) {
|
|
2813
|
-
return new Tr(
|
|
2814
|
-
e,
|
|
2815
|
-
this.config
|
|
2816
|
-
);
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
r(Nr, Hn, "PgGeometryBuilder");
|
|
2820
|
-
var Xn, kn;
|
|
2821
|
-
class Tr extends (kn = g, Xn = c, kn) {
|
|
2822
|
-
getSQLType() {
|
|
2823
|
-
return "geometry(point)";
|
|
2824
|
-
}
|
|
2825
|
-
mapFromDriverValue(e) {
|
|
2826
|
-
return xr(e);
|
|
2827
|
-
}
|
|
2828
|
-
mapToDriverValue(e) {
|
|
2829
|
-
return `point(${e[0]} ${e[1]})`;
|
|
2830
|
-
}
|
|
2831
|
-
}
|
|
2832
|
-
r(Tr, Xn, "PgGeometry");
|
|
2833
|
-
var es, ts;
|
|
2834
|
-
class Cr extends (ts = b, es = c, ts) {
|
|
2835
|
-
constructor(e) {
|
|
2836
|
-
super(e, "json", "PgGeometryObject");
|
|
2837
|
-
}
|
|
2838
|
-
/** @internal */
|
|
2839
|
-
build(e) {
|
|
2840
|
-
return new Sr(
|
|
2841
|
-
e,
|
|
2842
|
-
this.config
|
|
2843
|
-
);
|
|
2844
|
-
}
|
|
2845
|
-
}
|
|
2846
|
-
r(Cr, es, "PgGeometryObjectBuilder");
|
|
2847
|
-
var ns, ss;
|
|
2848
|
-
class Sr extends (ss = g, ns = c, ss) {
|
|
2849
|
-
getSQLType() {
|
|
2850
|
-
return "geometry(point)";
|
|
2851
|
-
}
|
|
2852
|
-
mapFromDriverValue(e) {
|
|
2853
|
-
const t = xr(e);
|
|
2854
|
-
return { x: t[0], y: t[1] };
|
|
2855
|
-
}
|
|
2856
|
-
mapToDriverValue(e) {
|
|
2857
|
-
return `point(${e.x} ${e.y})`;
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
r(Sr, ns, "PgGeometryObject");
|
|
2861
|
-
function sa(n, e) {
|
|
2862
|
-
const { name: t, config: s } = x(n, e);
|
|
2863
|
-
return !(s != null && s.mode) || s.mode === "tuple" ? new Nr(t) : new Cr(t);
|
|
2864
|
-
}
|
|
2865
|
-
var is, rs;
|
|
2866
|
-
class Pr extends (rs = b, is = c, rs) {
|
|
2867
|
-
constructor(e, t) {
|
|
2868
|
-
super(e, "number", "PgReal"), this.config.length = t;
|
|
2869
|
-
}
|
|
2870
|
-
/** @internal */
|
|
2871
|
-
build(e) {
|
|
2872
|
-
return new Dr(e, this.config);
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
r(Pr, is, "PgRealBuilder");
|
|
2876
|
-
var os, as;
|
|
2877
|
-
class Dr extends (as = g, os = c, as) {
|
|
2878
|
-
constructor(t, s) {
|
|
2879
|
-
super(t, s);
|
|
2880
|
-
r(this, "mapFromDriverValue", (t) => typeof t == "string" ? Number.parseFloat(t) : t);
|
|
2881
|
-
}
|
|
2882
|
-
getSQLType() {
|
|
2883
|
-
return "real";
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
r(Dr, os, "PgReal");
|
|
2887
|
-
function ia(n) {
|
|
2888
|
-
return new Pr(n ?? "");
|
|
2889
|
-
}
|
|
2890
|
-
var us, cs;
|
|
2891
|
-
class vr extends (cs = b, us = c, cs) {
|
|
2892
|
-
constructor(e) {
|
|
2893
|
-
super(e, "number", "PgSerial"), this.config.hasDefault = !0, this.config.notNull = !0;
|
|
2894
|
-
}
|
|
2895
|
-
/** @internal */
|
|
2896
|
-
build(e) {
|
|
2897
|
-
return new Er(e, this.config);
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
r(vr, us, "PgSerialBuilder");
|
|
2901
|
-
var ls, ms;
|
|
2902
|
-
class Er extends (ms = g, ls = c, ms) {
|
|
2903
|
-
getSQLType() {
|
|
2904
|
-
return "serial";
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
r(Er, ls, "PgSerial");
|
|
2908
|
-
function ra(n) {
|
|
2909
|
-
return new vr(n ?? "");
|
|
2910
|
-
}
|
|
2911
|
-
var ds, fs;
|
|
2912
|
-
class $r extends (fs = j, ds = c, fs) {
|
|
2913
|
-
constructor(e) {
|
|
2914
|
-
super(e, "number", "PgSmallInt");
|
|
2915
|
-
}
|
|
2916
|
-
/** @internal */
|
|
2917
|
-
build(e) {
|
|
2918
|
-
return new Br(e, this.config);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
r($r, ds, "PgSmallIntBuilder");
|
|
2922
|
-
var ps, hs;
|
|
2923
|
-
class Br extends (hs = g, ps = c, hs) {
|
|
2924
|
-
constructor() {
|
|
2925
|
-
super(...arguments);
|
|
2926
|
-
r(this, "mapFromDriverValue", (t) => typeof t == "string" ? Number(t) : t);
|
|
2927
|
-
}
|
|
2928
|
-
getSQLType() {
|
|
2929
|
-
return "smallint";
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
r(Br, ps, "PgSmallInt");
|
|
2933
|
-
function oa(n) {
|
|
2934
|
-
return new $r(n ?? "");
|
|
2935
|
-
}
|
|
2936
|
-
var gs, bs;
|
|
2937
|
-
class zr extends (bs = b, gs = c, bs) {
|
|
2938
|
-
constructor(e) {
|
|
2939
|
-
super(e, "number", "PgSmallSerial"), this.config.hasDefault = !0, this.config.notNull = !0;
|
|
2940
|
-
}
|
|
2941
|
-
/** @internal */
|
|
2942
|
-
build(e) {
|
|
2943
|
-
return new Fr(
|
|
2944
|
-
e,
|
|
2945
|
-
this.config
|
|
2946
|
-
);
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
r(zr, gs, "PgSmallSerialBuilder");
|
|
2950
|
-
var ys, ws;
|
|
2951
|
-
class Fr extends (ws = g, ys = c, ws) {
|
|
2952
|
-
getSQLType() {
|
|
2953
|
-
return "smallserial";
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
r(Fr, ys, "PgSmallSerial");
|
|
2957
|
-
function aa(n) {
|
|
2958
|
-
return new zr(n ?? "");
|
|
2959
|
-
}
|
|
2960
|
-
var xs, Ns;
|
|
2961
|
-
class Lr extends (Ns = b, xs = c, Ns) {
|
|
2962
|
-
constructor(e, t) {
|
|
2963
|
-
super(e, "string", "PgText"), this.config.enumValues = t.enum;
|
|
2964
|
-
}
|
|
2965
|
-
/** @internal */
|
|
2966
|
-
build(e) {
|
|
2967
|
-
return new Ar(e, this.config);
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
r(Lr, xs, "PgTextBuilder");
|
|
2971
|
-
var Ts, Cs;
|
|
2972
|
-
class Ar extends (Cs = g, Ts = c, Cs) {
|
|
2973
|
-
constructor() {
|
|
2974
|
-
super(...arguments);
|
|
2975
|
-
r(this, "enumValues", this.config.enumValues);
|
|
2976
|
-
}
|
|
2977
|
-
getSQLType() {
|
|
2978
|
-
return "text";
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
r(Ar, Ts, "PgText");
|
|
2982
|
-
function E(n, e = {}) {
|
|
2983
|
-
const { name: t, config: s } = x(n, e);
|
|
2984
|
-
return new Lr(t, s);
|
|
2985
|
-
}
|
|
2986
|
-
var Ss, Ps;
|
|
2987
|
-
class Qr extends (Ps = V, Ss = c, Ps) {
|
|
2988
|
-
constructor(e, t, s) {
|
|
2989
|
-
super(e, "string", "PgTime"), this.withTimezone = t, this.precision = s, this.config.withTimezone = t, this.config.precision = s;
|
|
2990
|
-
}
|
|
2991
|
-
/** @internal */
|
|
2992
|
-
build(e) {
|
|
2993
|
-
return new Vr(e, this.config);
|
|
2994
|
-
}
|
|
2995
|
-
}
|
|
2996
|
-
r(Qr, Ss, "PgTimeBuilder");
|
|
2997
|
-
var Ds, vs;
|
|
2998
|
-
class Vr extends (vs = g, Ds = c, vs) {
|
|
2999
|
-
constructor(t, s) {
|
|
3000
|
-
super(t, s);
|
|
3001
|
-
r(this, "withTimezone");
|
|
3002
|
-
r(this, "precision");
|
|
3003
|
-
this.withTimezone = s.withTimezone, this.precision = s.precision;
|
|
3004
|
-
}
|
|
3005
|
-
getSQLType() {
|
|
3006
|
-
return `time${this.precision === void 0 ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
r(Vr, Ds, "PgTime");
|
|
3010
|
-
function ua(n, e = {}) {
|
|
3011
|
-
const { name: t, config: s } = x(n, e);
|
|
3012
|
-
return new Qr(t, s.withTimezone ?? !1, s.precision);
|
|
3013
|
-
}
|
|
3014
|
-
var Es, $s;
|
|
3015
|
-
class Ir extends ($s = V, Es = c, $s) {
|
|
3016
|
-
constructor(e, t, s) {
|
|
3017
|
-
super(e, "date", "PgTimestamp"), this.config.withTimezone = t, this.config.precision = s;
|
|
3018
|
-
}
|
|
3019
|
-
/** @internal */
|
|
3020
|
-
build(e) {
|
|
3021
|
-
return new jr(e, this.config);
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
r(Ir, Es, "PgTimestampBuilder");
|
|
3025
|
-
var Bs, zs;
|
|
3026
|
-
class jr extends (zs = g, Bs = c, zs) {
|
|
3027
|
-
constructor(t, s) {
|
|
3028
|
-
super(t, s);
|
|
3029
|
-
r(this, "withTimezone");
|
|
3030
|
-
r(this, "precision");
|
|
3031
|
-
r(this, "mapFromDriverValue", (t) => new Date(this.withTimezone ? t : t + "+0000"));
|
|
3032
|
-
r(this, "mapToDriverValue", (t) => t.toISOString());
|
|
3033
|
-
this.withTimezone = s.withTimezone, this.precision = s.precision;
|
|
3034
|
-
}
|
|
3035
|
-
getSQLType() {
|
|
3036
|
-
return `timestamp${this.precision === void 0 ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
r(jr, Bs, "PgTimestamp");
|
|
3040
|
-
var Fs, Ls;
|
|
3041
|
-
class _r extends (Ls = V, Fs = c, Ls) {
|
|
3042
|
-
constructor(e, t, s) {
|
|
3043
|
-
super(e, "string", "PgTimestampString"), this.config.withTimezone = t, this.config.precision = s;
|
|
3044
|
-
}
|
|
3045
|
-
/** @internal */
|
|
3046
|
-
build(e) {
|
|
3047
|
-
return new Ur(
|
|
3048
|
-
e,
|
|
3049
|
-
this.config
|
|
3050
|
-
);
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
r(_r, Fs, "PgTimestampStringBuilder");
|
|
3054
|
-
var As, Qs;
|
|
3055
|
-
class Ur extends (Qs = g, As = c, Qs) {
|
|
3056
|
-
constructor(t, s) {
|
|
3057
|
-
super(t, s);
|
|
3058
|
-
r(this, "withTimezone");
|
|
3059
|
-
r(this, "precision");
|
|
3060
|
-
this.withTimezone = s.withTimezone, this.precision = s.precision;
|
|
3061
|
-
}
|
|
3062
|
-
getSQLType() {
|
|
3063
|
-
return `timestamp${this.precision === void 0 ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
r(Ur, As, "PgTimestampString");
|
|
3067
|
-
function S(n, e = {}) {
|
|
3068
|
-
const { name: t, config: s } = x(n, e);
|
|
3069
|
-
return (s == null ? void 0 : s.mode) === "string" ? new _r(t, s.withTimezone ?? !1, s.precision) : new Ir(t, (s == null ? void 0 : s.withTimezone) ?? !1, s == null ? void 0 : s.precision);
|
|
3070
|
-
}
|
|
3071
|
-
var Vs, Is;
|
|
3072
|
-
class qr extends (Is = b, Vs = c, Is) {
|
|
3073
|
-
constructor(e) {
|
|
3074
|
-
super(e, "string", "PgUUID");
|
|
3075
|
-
}
|
|
3076
|
-
/**
|
|
3077
|
-
* Adds `default gen_random_uuid()` to the column definition.
|
|
3078
|
-
*/
|
|
3079
|
-
defaultRandom() {
|
|
3080
|
-
return this.default(q`gen_random_uuid()`);
|
|
3081
|
-
}
|
|
3082
|
-
/** @internal */
|
|
3083
|
-
build(e) {
|
|
3084
|
-
return new Or(e, this.config);
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
r(qr, Vs, "PgUUIDBuilder");
|
|
3088
|
-
var js, _s;
|
|
3089
|
-
class Or extends (_s = g, js = c, _s) {
|
|
3090
|
-
getSQLType() {
|
|
3091
|
-
return "uuid";
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
r(Or, js, "PgUUID");
|
|
3095
|
-
function ca(n) {
|
|
3096
|
-
return new qr(n ?? "");
|
|
3097
|
-
}
|
|
3098
|
-
var Us, qs;
|
|
3099
|
-
class Mr extends (qs = b, Us = c, qs) {
|
|
3100
|
-
constructor(e, t) {
|
|
3101
|
-
super(e, "string", "PgVarchar"), this.config.length = t.length, this.config.enumValues = t.enum;
|
|
3102
|
-
}
|
|
3103
|
-
/** @internal */
|
|
3104
|
-
build(e) {
|
|
3105
|
-
return new Rr(
|
|
3106
|
-
e,
|
|
3107
|
-
this.config
|
|
3108
|
-
);
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
r(Mr, Us, "PgVarcharBuilder");
|
|
3112
|
-
var Os, Ms;
|
|
3113
|
-
class Rr extends (Ms = g, Os = c, Ms) {
|
|
3114
|
-
constructor() {
|
|
3115
|
-
super(...arguments);
|
|
3116
|
-
r(this, "length", this.config.length);
|
|
3117
|
-
r(this, "enumValues", this.config.enumValues);
|
|
3118
|
-
}
|
|
3119
|
-
getSQLType() {
|
|
3120
|
-
return this.length === void 0 ? "varchar" : `varchar(${this.length})`;
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
r(Rr, Os, "PgVarchar");
|
|
3124
|
-
function la(n, e = {}) {
|
|
3125
|
-
const { name: t, config: s } = x(n, e);
|
|
3126
|
-
return new Mr(t, s);
|
|
3127
|
-
}
|
|
3128
|
-
var Rs, Js;
|
|
3129
|
-
class Jr extends (Js = b, Rs = c, Js) {
|
|
3130
|
-
constructor(e, t) {
|
|
3131
|
-
super(e, "string", "PgBinaryVector"), this.config.dimensions = t.dimensions;
|
|
3132
|
-
}
|
|
3133
|
-
/** @internal */
|
|
3134
|
-
build(e) {
|
|
3135
|
-
return new Kr(
|
|
3136
|
-
e,
|
|
3137
|
-
this.config
|
|
3138
|
-
);
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
r(Jr, Rs, "PgBinaryVectorBuilder");
|
|
3142
|
-
var Ks, Ws;
|
|
3143
|
-
class Kr extends (Ws = g, Ks = c, Ws) {
|
|
3144
|
-
constructor() {
|
|
3145
|
-
super(...arguments);
|
|
3146
|
-
r(this, "dimensions", this.config.dimensions);
|
|
3147
|
-
}
|
|
3148
|
-
getSQLType() {
|
|
3149
|
-
return `bit(${this.dimensions})`;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
r(Kr, Ks, "PgBinaryVector");
|
|
3153
|
-
function ma(n, e) {
|
|
3154
|
-
const { name: t, config: s } = x(n, e);
|
|
3155
|
-
return new Jr(t, s);
|
|
3156
|
-
}
|
|
3157
|
-
var Ys, Gs;
|
|
3158
|
-
class Wr extends (Gs = b, Ys = c, Gs) {
|
|
3159
|
-
constructor(e, t) {
|
|
3160
|
-
super(e, "array", "PgHalfVector"), this.config.dimensions = t.dimensions;
|
|
3161
|
-
}
|
|
3162
|
-
/** @internal */
|
|
3163
|
-
build(e) {
|
|
3164
|
-
return new Yr(
|
|
3165
|
-
e,
|
|
3166
|
-
this.config
|
|
3167
|
-
);
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
r(Wr, Ys, "PgHalfVectorBuilder");
|
|
3171
|
-
var Hs, Zs;
|
|
3172
|
-
class Yr extends (Zs = g, Hs = c, Zs) {
|
|
3173
|
-
constructor() {
|
|
3174
|
-
super(...arguments);
|
|
3175
|
-
r(this, "dimensions", this.config.dimensions);
|
|
3176
|
-
}
|
|
3177
|
-
getSQLType() {
|
|
3178
|
-
return `halfvec(${this.dimensions})`;
|
|
3179
|
-
}
|
|
3180
|
-
mapToDriverValue(t) {
|
|
3181
|
-
return JSON.stringify(t);
|
|
3182
|
-
}
|
|
3183
|
-
mapFromDriverValue(t) {
|
|
3184
|
-
return t.slice(1, -1).split(",").map((s) => Number.parseFloat(s));
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
r(Yr, Hs, "PgHalfVector");
|
|
3188
|
-
function da(n, e) {
|
|
3189
|
-
const { name: t, config: s } = x(n, e);
|
|
3190
|
-
return new Wr(t, s);
|
|
3191
|
-
}
|
|
3192
|
-
var Xs, ks;
|
|
3193
|
-
class Gr extends (ks = b, Xs = c, ks) {
|
|
3194
|
-
constructor(e, t) {
|
|
3195
|
-
super(e, "string", "PgSparseVector"), this.config.dimensions = t.dimensions;
|
|
3196
|
-
}
|
|
3197
|
-
/** @internal */
|
|
3198
|
-
build(e) {
|
|
3199
|
-
return new Hr(
|
|
3200
|
-
e,
|
|
3201
|
-
this.config
|
|
3202
|
-
);
|
|
3203
|
-
}
|
|
3204
|
-
}
|
|
3205
|
-
r(Gr, Xs, "PgSparseVectorBuilder");
|
|
3206
|
-
var ei, ti;
|
|
3207
|
-
class Hr extends (ti = g, ei = c, ti) {
|
|
3208
|
-
constructor() {
|
|
3209
|
-
super(...arguments);
|
|
3210
|
-
r(this, "dimensions", this.config.dimensions);
|
|
3211
|
-
}
|
|
3212
|
-
getSQLType() {
|
|
3213
|
-
return `sparsevec(${this.dimensions})`;
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
r(Hr, ei, "PgSparseVector");
|
|
3217
|
-
function fa(n, e) {
|
|
3218
|
-
const { name: t, config: s } = x(n, e);
|
|
3219
|
-
return new Gr(t, s);
|
|
3220
|
-
}
|
|
3221
|
-
var ni, si;
|
|
3222
|
-
class Zr extends (si = b, ni = c, si) {
|
|
3223
|
-
constructor(e, t) {
|
|
3224
|
-
super(e, "array", "PgVector"), this.config.dimensions = t.dimensions;
|
|
3225
|
-
}
|
|
3226
|
-
/** @internal */
|
|
3227
|
-
build(e) {
|
|
3228
|
-
return new Xr(
|
|
3229
|
-
e,
|
|
3230
|
-
this.config
|
|
3231
|
-
);
|
|
3232
|
-
}
|
|
3233
|
-
}
|
|
3234
|
-
r(Zr, ni, "PgVectorBuilder");
|
|
3235
|
-
var ii, ri;
|
|
3236
|
-
class Xr extends (ri = g, ii = c, ri) {
|
|
3237
|
-
constructor() {
|
|
3238
|
-
super(...arguments);
|
|
3239
|
-
r(this, "dimensions", this.config.dimensions);
|
|
3240
|
-
}
|
|
3241
|
-
getSQLType() {
|
|
3242
|
-
return `vector(${this.dimensions})`;
|
|
3243
|
-
}
|
|
3244
|
-
mapToDriverValue(t) {
|
|
3245
|
-
return JSON.stringify(t);
|
|
3246
|
-
}
|
|
3247
|
-
mapFromDriverValue(t) {
|
|
3248
|
-
return t.slice(1, -1).split(",").map((s) => Number.parseFloat(s));
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
r(Xr, ii, "PgVector");
|
|
3252
|
-
function pa(n, e) {
|
|
3253
|
-
const { name: t, config: s } = x(n, e);
|
|
3254
|
-
return new Zr(t, s);
|
|
3255
|
-
}
|
|
3256
|
-
function ha() {
|
|
3257
|
-
return {
|
|
3258
|
-
bigint: Uo,
|
|
3259
|
-
bigserial: qo,
|
|
3260
|
-
boolean: ie,
|
|
3261
|
-
char: Oo,
|
|
3262
|
-
cidr: Mo,
|
|
3263
|
-
customType: Ro,
|
|
3264
|
-
date: Jo,
|
|
3265
|
-
doublePrecision: Ko,
|
|
3266
|
-
inet: Wo,
|
|
3267
|
-
integer: D,
|
|
3268
|
-
interval: Yo,
|
|
3269
|
-
json: Go,
|
|
3270
|
-
jsonb: Ho,
|
|
3271
|
-
line: Zo,
|
|
3272
|
-
macaddr: Xo,
|
|
3273
|
-
macaddr8: ko,
|
|
3274
|
-
numeric: hr,
|
|
3275
|
-
point: ta,
|
|
3276
|
-
geometry: sa,
|
|
3277
|
-
real: ia,
|
|
3278
|
-
serial: ra,
|
|
3279
|
-
smallint: oa,
|
|
3280
|
-
smallserial: aa,
|
|
3281
|
-
text: E,
|
|
3282
|
-
time: ua,
|
|
3283
|
-
timestamp: S,
|
|
3284
|
-
uuid: ca,
|
|
3285
|
-
varchar: la,
|
|
3286
|
-
bit: ma,
|
|
3287
|
-
halfvec: da,
|
|
3288
|
-
sparsevec: fa,
|
|
3289
|
-
vector: pa
|
|
3290
|
-
};
|
|
3291
|
-
}
|
|
3292
|
-
const k = Symbol.for("drizzle:PgInlineForeignKeys"), we = Symbol.for("drizzle:EnableRLS");
|
|
3293
|
-
var oi, ai, ui, ci, li, mi;
|
|
3294
|
-
class M extends (mi = w, li = c, ci = k, ui = we, ai = w.Symbol.ExtraConfigBuilder, oi = w.Symbol.ExtraConfigColumns, mi) {
|
|
3295
|
-
constructor() {
|
|
3296
|
-
super(...arguments);
|
|
3297
|
-
/**@internal */
|
|
3298
|
-
r(this, ci, []);
|
|
3299
|
-
/** @internal */
|
|
3300
|
-
r(this, ui, !1);
|
|
3301
|
-
/** @internal */
|
|
3302
|
-
r(this, ai);
|
|
3303
|
-
/** @internal */
|
|
3304
|
-
r(this, oi, {});
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
r(M, li, "PgTable"), /** @internal */
|
|
3308
|
-
r(M, "Symbol", Object.assign({}, w.Symbol, {
|
|
3309
|
-
InlineForeignKeys: k,
|
|
3310
|
-
EnableRLS: we
|
|
3311
|
-
}));
|
|
3312
|
-
function ga(n, e, t, s, i = n) {
|
|
3313
|
-
const o = new M(n, s, i), l = typeof e == "function" ? e(ha()) : e, a = Object.fromEntries(
|
|
3314
|
-
Object.entries(l).map(([u, f]) => {
|
|
3315
|
-
const p = f;
|
|
3316
|
-
p.setName(u);
|
|
3317
|
-
const h = p.build(o);
|
|
3318
|
-
return o[k].push(...p.buildForeignKeys(h, o)), [u, h];
|
|
3319
|
-
})
|
|
3320
|
-
), m = Object.fromEntries(
|
|
3321
|
-
Object.entries(l).map(([u, f]) => {
|
|
3322
|
-
const p = f;
|
|
3323
|
-
p.setName(u);
|
|
3324
|
-
const h = p.buildExtraConfigColumn(o);
|
|
3325
|
-
return [u, h];
|
|
3326
|
-
})
|
|
3327
|
-
), d = Object.assign(o, a);
|
|
3328
|
-
return d[w.Symbol.Columns] = a, d[w.Symbol.ExtraConfigColumns] = m, Object.assign(d, {
|
|
3329
|
-
enableRLS: () => (d[M.Symbol.EnableRLS] = !0, d)
|
|
3330
|
-
});
|
|
3331
|
-
}
|
|
3332
|
-
const W = (n, e, t) => ga(n, e, t, void 0), P = W("organisations", {
|
|
3333
|
-
id: D("id").primaryKey(),
|
|
3334
|
-
name: E("name").notNull(),
|
|
3335
|
-
description: E("description"),
|
|
3336
|
-
createdAt: S("created_at").defaultNow(),
|
|
3337
|
-
updatedAt: S("updated_at").defaultNow()
|
|
3338
|
-
}), F = W("departments", {
|
|
3339
|
-
id: D("id").primaryKey(),
|
|
3340
|
-
name: E("name").notNull(),
|
|
3341
|
-
description: E("description"),
|
|
3342
|
-
organisation: D("organisation").notNull().references(() => P.id),
|
|
3343
|
-
createdAt: S("created_at").defaultNow(),
|
|
3344
|
-
updatedAt: S("updated_at").defaultNow()
|
|
3345
|
-
}), L = W("suppliers", {
|
|
3346
|
-
id: D("id").primaryKey(),
|
|
3347
|
-
name: E("name").notNull(),
|
|
3348
|
-
description: E("description"),
|
|
3349
|
-
internal: ie("internal").default(!1),
|
|
3350
|
-
organisation: D("organisation").notNull().references(() => P.id),
|
|
3351
|
-
createdAt: S("created_at").defaultNow(),
|
|
3352
|
-
updatedAt: S("updated_at").defaultNow()
|
|
3353
|
-
}), $ = W("employees", {
|
|
3354
|
-
id: D("id").primaryKey(),
|
|
3355
|
-
name: E("name").notNull(),
|
|
3356
|
-
email: E("email").notNull(),
|
|
3357
|
-
active: ie("active").default(!0),
|
|
3358
|
-
fteBasis: ea("fte_basis", { precision: 3, scale: 2 }).default("1.00"),
|
|
3359
|
-
startDate: S("start_date"),
|
|
3360
|
-
endDate: S("end_date"),
|
|
3361
|
-
department: D("department").references(() => F.id),
|
|
3362
|
-
supplier: D("supplier").references(() => L.id),
|
|
3363
|
-
organisation: D("organisation").notNull().references(() => P.id),
|
|
3364
|
-
createdAt: S("created_at").defaultNow(),
|
|
3365
|
-
updatedAt: S("updated_at").defaultNow()
|
|
3366
|
-
}), ba = J(P, ({ many: n }) => ({
|
|
3367
|
-
departments: n(F),
|
|
3368
|
-
suppliers: n(L),
|
|
3369
|
-
employees: n($)
|
|
3370
|
-
})), ya = J(F, ({ one: n, many: e }) => ({
|
|
3371
|
-
organisation: n(P, {
|
|
3372
|
-
fields: [F.organisation],
|
|
3373
|
-
references: [P.id]
|
|
3374
|
-
}),
|
|
3375
|
-
employees: e($)
|
|
3376
|
-
})), wa = J(L, ({ one: n, many: e }) => ({
|
|
3377
|
-
organisation: n(P, {
|
|
3378
|
-
fields: [L.organisation],
|
|
3379
|
-
references: [P.id]
|
|
3380
|
-
}),
|
|
3381
|
-
employees: e($)
|
|
3382
|
-
})), xa = J($, ({ one: n }) => ({
|
|
3383
|
-
organisation: n(P, {
|
|
3384
|
-
fields: [$.organisation],
|
|
3385
|
-
references: [P.id]
|
|
3386
|
-
}),
|
|
3387
|
-
department: n(F, {
|
|
3388
|
-
fields: [$.department],
|
|
3389
|
-
references: [F.id]
|
|
3390
|
-
}),
|
|
3391
|
-
supplier: n(L, {
|
|
3392
|
-
fields: [$.supplier],
|
|
3393
|
-
references: [L.id]
|
|
3394
|
-
})
|
|
3395
|
-
})), Ba = {
|
|
3396
|
-
organisations: P,
|
|
3397
|
-
departments: F,
|
|
3398
|
-
suppliers: L,
|
|
3399
|
-
employees: $,
|
|
3400
|
-
organisationsRelations: ba,
|
|
3401
|
-
departmentsRelations: ya,
|
|
3402
|
-
suppliersRelations: wa,
|
|
3403
|
-
employeesRelations: xa
|
|
3404
|
-
}, za = wo;
|
|
3405
|
-
function Fa(n) {
|
|
3406
|
-
return new te({
|
|
3407
|
-
drizzle: n.drizzle,
|
|
3408
|
-
schema: n.schema
|
|
1607
|
+
const xe = se;
|
|
1608
|
+
function Te(s) {
|
|
1609
|
+
return new T({
|
|
1610
|
+
drizzle: s.drizzle,
|
|
1611
|
+
schema: s.schema
|
|
3409
1612
|
});
|
|
3410
1613
|
}
|
|
3411
|
-
const
|
|
1614
|
+
const Ae = {
|
|
3412
1615
|
/**
|
|
3413
1616
|
* Create a simple query builder
|
|
3414
1617
|
*/
|
|
3415
1618
|
query: () => {
|
|
3416
|
-
const
|
|
1619
|
+
const s = (e, t = [], i = [], n = [], r, a) => ({
|
|
3417
1620
|
measures: e,
|
|
3418
1621
|
dimensions: t,
|
|
3419
|
-
filters:
|
|
3420
|
-
timeDimensions:
|
|
3421
|
-
limit:
|
|
3422
|
-
order:
|
|
1622
|
+
filters: i,
|
|
1623
|
+
timeDimensions: n,
|
|
1624
|
+
limit: r,
|
|
1625
|
+
order: a
|
|
3423
1626
|
});
|
|
3424
1627
|
return {
|
|
3425
1628
|
measures: (e) => ({
|
|
3426
1629
|
dimensions: (t = []) => ({
|
|
3427
|
-
filters: (
|
|
3428
|
-
timeDimensions: (
|
|
3429
|
-
limit: (
|
|
3430
|
-
order: (
|
|
1630
|
+
filters: (i = []) => ({
|
|
1631
|
+
timeDimensions: (n = []) => ({
|
|
1632
|
+
limit: (r) => ({
|
|
1633
|
+
order: (a) => s(e, t, i, n, r, a)
|
|
3431
1634
|
}),
|
|
3432
|
-
order: (
|
|
1635
|
+
order: (r) => s(e, t, i, n, void 0, r)
|
|
3433
1636
|
}),
|
|
3434
|
-
limit: (
|
|
3435
|
-
order: (
|
|
1637
|
+
limit: (n) => ({
|
|
1638
|
+
order: (r) => s(e, t, i, [], n, r)
|
|
3436
1639
|
}),
|
|
3437
|
-
order: (
|
|
1640
|
+
order: (n) => s(e, t, i, [], void 0, n)
|
|
3438
1641
|
}),
|
|
3439
|
-
timeDimensions: (
|
|
3440
|
-
filters: (
|
|
3441
|
-
limit: (
|
|
3442
|
-
order: (
|
|
1642
|
+
timeDimensions: (i = []) => ({
|
|
1643
|
+
filters: (n = []) => ({
|
|
1644
|
+
limit: (r) => ({
|
|
1645
|
+
order: (a) => s(e, t, n, i, r, a)
|
|
3443
1646
|
}),
|
|
3444
|
-
order: (
|
|
1647
|
+
order: (r) => s(e, t, n, i, void 0, r)
|
|
3445
1648
|
}),
|
|
3446
|
-
limit: (
|
|
3447
|
-
order: (
|
|
1649
|
+
limit: (n) => ({
|
|
1650
|
+
order: (r) => s(e, t, [], i, n, r)
|
|
3448
1651
|
}),
|
|
3449
|
-
order: (
|
|
1652
|
+
order: (n) => s(e, t, [], i, void 0, n)
|
|
3450
1653
|
}),
|
|
3451
|
-
limit: (
|
|
3452
|
-
order: (
|
|
1654
|
+
limit: (i) => ({
|
|
1655
|
+
order: (n) => s(e, t, [], [], i, n)
|
|
3453
1656
|
}),
|
|
3454
|
-
order: (
|
|
1657
|
+
order: (i) => s(e, t, [], [], void 0, i)
|
|
3455
1658
|
}),
|
|
3456
1659
|
filters: (t = []) => ({
|
|
3457
|
-
dimensions: (
|
|
3458
|
-
timeDimensions: (
|
|
3459
|
-
limit: (
|
|
3460
|
-
order: (
|
|
1660
|
+
dimensions: (i = []) => ({
|
|
1661
|
+
timeDimensions: (n = []) => ({
|
|
1662
|
+
limit: (r) => ({
|
|
1663
|
+
order: (a) => s(e, i, t, n, r, a)
|
|
3461
1664
|
}),
|
|
3462
|
-
order: (
|
|
1665
|
+
order: (r) => s(e, i, t, n, void 0, r)
|
|
3463
1666
|
}),
|
|
3464
|
-
limit: (
|
|
3465
|
-
order: (
|
|
1667
|
+
limit: (n) => ({
|
|
1668
|
+
order: (r) => s(e, i, t, [], n, r)
|
|
3466
1669
|
}),
|
|
3467
|
-
order: (
|
|
1670
|
+
order: (n) => s(e, i, t, [], void 0, n)
|
|
3468
1671
|
}),
|
|
3469
|
-
timeDimensions: (
|
|
3470
|
-
dimensions: (
|
|
3471
|
-
limit: (
|
|
3472
|
-
order: (
|
|
1672
|
+
timeDimensions: (i = []) => ({
|
|
1673
|
+
dimensions: (n = []) => ({
|
|
1674
|
+
limit: (r) => ({
|
|
1675
|
+
order: (a) => s(e, n, t, i, r, a)
|
|
3473
1676
|
}),
|
|
3474
|
-
order: (
|
|
1677
|
+
order: (r) => s(e, n, t, i, void 0, r)
|
|
3475
1678
|
}),
|
|
3476
|
-
limit: (
|
|
3477
|
-
order: (
|
|
1679
|
+
limit: (n) => ({
|
|
1680
|
+
order: (r) => s(e, [], t, i, n, r)
|
|
3478
1681
|
}),
|
|
3479
|
-
order: (
|
|
1682
|
+
order: (n) => s(e, [], t, i, void 0, n)
|
|
3480
1683
|
}),
|
|
3481
|
-
limit: (
|
|
3482
|
-
order: (
|
|
1684
|
+
limit: (i) => ({
|
|
1685
|
+
order: (n) => s(e, [], t, [], i, n)
|
|
3483
1686
|
}),
|
|
3484
|
-
order: (
|
|
1687
|
+
order: (i) => s(e, [], t, [], void 0, i)
|
|
3485
1688
|
})
|
|
3486
1689
|
})
|
|
3487
1690
|
};
|
|
@@ -3490,64 +1693,55 @@ const La = {
|
|
|
3490
1693
|
* Create filters
|
|
3491
1694
|
*/
|
|
3492
1695
|
filters: {
|
|
3493
|
-
equals: (
|
|
3494
|
-
notEquals: (
|
|
3495
|
-
contains: (
|
|
3496
|
-
greaterThan: (
|
|
3497
|
-
lessThan: (
|
|
3498
|
-
inDateRange: (
|
|
3499
|
-
member:
|
|
1696
|
+
equals: (s, e) => ({ member: s, operator: "equals", values: [e] }),
|
|
1697
|
+
notEquals: (s, e) => ({ member: s, operator: "notEquals", values: [e] }),
|
|
1698
|
+
contains: (s, e) => ({ member: s, operator: "contains", values: [e] }),
|
|
1699
|
+
greaterThan: (s, e) => ({ member: s, operator: "gt", values: [e] }),
|
|
1700
|
+
lessThan: (s, e) => ({ member: s, operator: "lt", values: [e] }),
|
|
1701
|
+
inDateRange: (s, e, t) => ({
|
|
1702
|
+
member: s,
|
|
3500
1703
|
operator: "inDateRange",
|
|
3501
1704
|
values: [e, t]
|
|
3502
1705
|
}),
|
|
3503
|
-
set: (
|
|
3504
|
-
notSet: (
|
|
1706
|
+
set: (s) => ({ member: s, operator: "set", values: [] }),
|
|
1707
|
+
notSet: (s) => ({ member: s, operator: "notSet", values: [] })
|
|
3505
1708
|
},
|
|
3506
1709
|
/**
|
|
3507
1710
|
* Create time dimensions
|
|
3508
1711
|
*/
|
|
3509
1712
|
timeDimensions: {
|
|
3510
|
-
create: (
|
|
3511
|
-
dimension:
|
|
1713
|
+
create: (s, e, t) => ({
|
|
1714
|
+
dimension: s,
|
|
3512
1715
|
granularity: e,
|
|
3513
1716
|
dateRange: t
|
|
3514
1717
|
})
|
|
3515
1718
|
}
|
|
3516
1719
|
};
|
|
3517
1720
|
export {
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
P as organisations,
|
|
3545
|
-
ba as organisationsRelations,
|
|
3546
|
-
xo as parseYamlCubes,
|
|
3547
|
-
v as resolveSqlExpression,
|
|
3548
|
-
$a as semanticCubeToYaml,
|
|
3549
|
-
wo as semanticLayer,
|
|
3550
|
-
L as suppliers,
|
|
3551
|
-
wa as suppliersRelations,
|
|
3552
|
-
To as yamlCubeToSemanticCube
|
|
1721
|
+
x as BaseDatabaseExecutor,
|
|
1722
|
+
ie as MultiCubeBuilder,
|
|
1723
|
+
ee as MySQLExecutor,
|
|
1724
|
+
X as PostgresExecutor,
|
|
1725
|
+
y as QueryExecutor,
|
|
1726
|
+
q as SQLiteExecutor,
|
|
1727
|
+
T as SemanticLayerCompiler,
|
|
1728
|
+
Ae as SemanticLayerUtils,
|
|
1729
|
+
$e as convertCubeReferences,
|
|
1730
|
+
j as createDatabaseExecutor,
|
|
1731
|
+
Te as createDrizzleSemanticLayer,
|
|
1732
|
+
ne as createMultiCubeContext,
|
|
1733
|
+
te as createMySQLExecutor,
|
|
1734
|
+
S as createPostgresExecutor,
|
|
1735
|
+
M as createSQLiteExecutor,
|
|
1736
|
+
Ee as createSemanticLayer,
|
|
1737
|
+
xe as defaultSemanticLayer,
|
|
1738
|
+
Ne as defineCube,
|
|
1739
|
+
Ce as defineLegacyCube,
|
|
1740
|
+
pe as loadYamlCubes,
|
|
1741
|
+
De as loadYamlCubesFromFile,
|
|
1742
|
+
re as parseYamlCubes,
|
|
1743
|
+
b as resolveSqlExpression,
|
|
1744
|
+
ye as semanticCubeToYaml,
|
|
1745
|
+
se as semanticLayer,
|
|
1746
|
+
ae as yamlCubeToSemanticCube
|
|
3553
1747
|
};
|