drizzle-cube 0.1.3 → 0.1.5
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 +259 -96
- package/dist/client/client/CubeClient.d.ts +15 -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 +16 -0
- package/dist/client/components/PortletContainer.d.ts +10 -0
- package/dist/client/components/PortletEditModal.d.ts +12 -0
- package/dist/client/components/QueryBuilder/CubeMetaExplorer.d.ts +4 -0
- package/dist/client/components/QueryBuilder/QueryPanel.d.ts +4 -0
- package/dist/client/components/QueryBuilder/ResultsPanel.d.ts +4 -0
- package/dist/client/components/QueryBuilder/SetupPanel.d.ts +11 -0
- package/dist/client/components/QueryBuilder/index.d.ts +3 -0
- package/dist/client/components/QueryBuilder/types.d.ts +132 -0
- package/dist/client/components/QueryBuilder/utils.d.ts +42 -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 +15 -0
- package/dist/client/index.js +25439 -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 +84 -1155
- package/dist/server/index.js +1046 -2826
- package/package.json +14 -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 z = Object.defineProperty;
|
|
2
|
+
var U = (s, e, t) => e in s ? z(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var C = (s, e, t) => U(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { sql as f, and as p, eq as v, count as y, 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 N, 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 we(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((o) => this.convertNumericFields(o, 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((o) => this.convertNumericFields(o, t)) : n;
|
|
28
|
+
} catch (n) {
|
|
29
29
|
if (typeof e.getSQL == "function") {
|
|
30
|
-
const
|
|
31
|
-
return Array.isArray(
|
|
30
|
+
const o = e.getSQL(), a = await this.db.execute(o);
|
|
31
|
+
return Array.isArray(a) ? a.map((r) => this.convertNumericFields(r, 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, o] of Object.entries(e))
|
|
48
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(o) : i[n] = o;
|
|
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, o] of Object.entries(e))
|
|
108
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(o) : i[n] = o;
|
|
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((o) => this.convertNumericFields(o, 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, o] of Object.entries(e))
|
|
146
|
+
t && t.includes(n) ? i[n] = this.coerceToNumber(o) : i[n] = o;
|
|
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 _(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
|
|
233
|
+
buildMultiCubeQueryPlan(e, t, i) {
|
|
234
|
+
const n = this.analyzeCubeUsage(t), o = Array.from(n);
|
|
154
235
|
if (o.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(o, t), r = e.get(a);
|
|
238
|
+
if (!r)
|
|
239
|
+
throw new Error(`Primary cube '${a}' not found`);
|
|
240
|
+
const c = this.buildJoinPlan(e, r, o, 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: r,
|
|
243
|
+
joinCubes: c,
|
|
244
|
+
selections: l,
|
|
164
245
|
whereConditions: u,
|
|
165
|
-
groupByFields:
|
|
246
|
+
groupByFields: m
|
|
166
247
|
};
|
|
167
248
|
}
|
|
168
249
|
/**
|
|
@@ -170,44 +251,44 @@ 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 o = [],
|
|
188
|
-
for (const
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
191
|
-
throw new Error(`Cube '${
|
|
192
|
-
const u = (
|
|
266
|
+
buildJoinPlan(e, t, i, n) {
|
|
267
|
+
var r;
|
|
268
|
+
const o = [], 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 = (r = t.joins) == null ? void 0 : r[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
|
-
),
|
|
285
|
+
l
|
|
286
|
+
), d = u.condition(m);
|
|
206
287
|
o.push({
|
|
207
|
-
cube:
|
|
208
|
-
alias: `${
|
|
288
|
+
cube: l,
|
|
289
|
+
alias: `${c.toLowerCase()}_cube`,
|
|
209
290
|
joinType: u.type || "left",
|
|
210
|
-
joinCondition:
|
|
291
|
+
joinCondition: d
|
|
211
292
|
});
|
|
212
293
|
}
|
|
213
294
|
return o;
|
|
@@ -215,128 +296,128 @@ class yo {
|
|
|
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 = {}, o = {
|
|
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 [r, c] = a.split("."), l = e.get(r);
|
|
310
|
+
if (l && l.dimensions[c]) {
|
|
311
|
+
const u = l.dimensions[c], m = b(u.sql, o);
|
|
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 [r, c] = a.split("."), l = e.get(r);
|
|
318
|
+
if (l && l.measures[c]) {
|
|
319
|
+
const u = l.measures[c], m = this.buildMeasureExpression(u, o);
|
|
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 [r, c] = a.dimension.split("."), l = e.get(r);
|
|
326
|
+
if (l && l.dimensions[c]) {
|
|
327
|
+
const u = l.dimensions[c], m = this.buildTimeDimensionExpression(
|
|
247
328
|
u.sql,
|
|
248
|
-
|
|
329
|
+
a.granularity,
|
|
249
330
|
o
|
|
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((o) => o(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
399
|
for (const o of t.filters)
|
|
319
400
|
if ("member" in o) {
|
|
320
|
-
const [
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
|
|
401
|
+
const [a] = o.member.split("."), r = e.get(a);
|
|
402
|
+
if (r) {
|
|
403
|
+
const c = this.buildFilterCondition(o, r, 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, o] = e.member.split(".");
|
|
416
|
+
if (n === t.name) {
|
|
417
|
+
const a = t.dimensions[o] || t.measures[o];
|
|
418
|
+
if (a) {
|
|
419
|
+
const r = typeof a.sql == "function" ? a.sql(i) : a.sql;
|
|
420
|
+
return v(r, e.values[0]);
|
|
340
421
|
}
|
|
341
422
|
}
|
|
342
423
|
}
|
|
@@ -345,481 +426,658 @@ 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 r of t.dimensions) {
|
|
440
|
+
const [c, l] = r.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 r of t.timeDimensions) {
|
|
448
|
+
const [c, l] = r.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
|
+
r.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 $ {
|
|
381
462
|
constructor(e) {
|
|
382
|
-
|
|
383
|
-
this.dbExecutor = e, this.multiCubeBuilder = new
|
|
463
|
+
C(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 = j(e, t);
|
|
472
|
+
if (!n.isValid)
|
|
473
|
+
throw new Error(`Query validation failed: ${n.errors.join(", ")}`);
|
|
474
|
+
const o = this.multiCubeBuilder.analyzeCubeUsage(t);
|
|
475
|
+
if (o.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 (o.size === 1) {
|
|
478
|
+
const a = Array.from(o)[0], r = e.get(a);
|
|
479
|
+
if (!r)
|
|
480
|
+
throw new Error(`Cube '${a}' not found`);
|
|
481
|
+
return this.executeSingleCube(r, 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
|
-
}, o = e.sql(
|
|
427
|
-
let
|
|
509
|
+
securityContext: i
|
|
510
|
+
}, o = e.sql(n), a = this.buildSelections(e, t, n);
|
|
511
|
+
let r = n.db.select(a).from(o.from);
|
|
428
512
|
if (o.joins)
|
|
429
513
|
for (const h of o.joins)
|
|
430
514
|
switch (h.type || "left") {
|
|
431
515
|
case "left":
|
|
432
|
-
|
|
516
|
+
r = r.leftJoin(h.table, h.on);
|
|
433
517
|
break;
|
|
434
518
|
case "inner":
|
|
435
|
-
|
|
519
|
+
r = r.innerJoin(h.table, h.on);
|
|
436
520
|
break;
|
|
437
521
|
case "right":
|
|
438
|
-
|
|
522
|
+
r = r.rightJoin(h.table, h.on);
|
|
439
523
|
break;
|
|
440
524
|
case "full":
|
|
441
|
-
|
|
525
|
+
r = r.fullJoin(h.table, h.on);
|
|
442
526
|
break;
|
|
443
527
|
}
|
|
444
|
-
o.where && (
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
const h =
|
|
448
|
-
|
|
528
|
+
o.where && (r = r.where(o.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
|
+
r = r.where(h);
|
|
449
533
|
}
|
|
450
|
-
const
|
|
451
|
-
|
|
534
|
+
const l = this.buildGroupByFields(e, t, n);
|
|
535
|
+
l.length > 0 && (r = r.groupBy(...l));
|
|
452
536
|
const u = this.buildOrderBy(t);
|
|
453
|
-
u.length > 0 && (
|
|
454
|
-
|
|
537
|
+
if (u.length > 0 && (r = r.orderBy(...u)), t.limit !== void 0) {
|
|
538
|
+
if (t.limit < 0)
|
|
539
|
+
throw new Error("Limit must be non-negative");
|
|
540
|
+
r = r.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
|
+
r = r.offset(t.offset);
|
|
546
|
+
}
|
|
547
|
+
const m = t.measures || [], d = await this.dbExecutor.execute(r, m), Q = Array.isArray(d) ? d.map((h) => {
|
|
548
|
+
const E = { ...h };
|
|
549
|
+
if (t.timeDimensions) {
|
|
550
|
+
for (const D of t.timeDimensions)
|
|
551
|
+
if (D.dimension in E) {
|
|
552
|
+
let g = E[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")), E[D.dimension] = g;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return E;
|
|
557
|
+
}) : [d], k = this.generateAnnotations(e, t);
|
|
455
558
|
return {
|
|
456
|
-
data:
|
|
457
|
-
annotation:
|
|
559
|
+
data: Q,
|
|
560
|
+
annotation: k
|
|
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), o = t.measures || [], a = await this.dbExecutor.execute(n, o), r = {
|
|
571
|
+
db: this.dbExecutor.db,
|
|
572
|
+
schema: this.dbExecutor.schema,
|
|
573
|
+
securityContext: i
|
|
574
|
+
}, c = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, r), 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 o = this.buildMultiCubeQuery(e, t, i).toSQL();
|
|
591
|
+
return {
|
|
592
|
+
sql: o.sql,
|
|
593
|
+
params: o.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
|
-
}, o = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t,
|
|
472
|
-
let
|
|
473
|
-
if (
|
|
474
|
-
for (const
|
|
475
|
-
switch (
|
|
603
|
+
securityContext: i
|
|
604
|
+
}, o = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, n), a = o.primaryCube.sql(n);
|
|
605
|
+
let r = n.db.select(o.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
|
+
r = r.leftJoin(u.table, u.on);
|
|
478
611
|
break;
|
|
479
612
|
case "inner":
|
|
480
|
-
|
|
613
|
+
r = r.innerJoin(u.table, u.on);
|
|
481
614
|
break;
|
|
482
615
|
case "right":
|
|
483
|
-
|
|
616
|
+
r = r.rightJoin(u.table, u.on);
|
|
484
617
|
break;
|
|
485
618
|
case "full":
|
|
486
|
-
|
|
619
|
+
r = r.fullJoin(u.table, u.on);
|
|
487
620
|
break;
|
|
621
|
+
default:
|
|
622
|
+
r = r.leftJoin(u.table, u.on);
|
|
488
623
|
}
|
|
489
624
|
if (o.joinCubes && o.joinCubes.length > 0)
|
|
490
|
-
for (const
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
625
|
+
for (const u of o.joinCubes) {
|
|
626
|
+
const m = u.cube.sql(n);
|
|
627
|
+
try {
|
|
628
|
+
switch (u.joinType || "left") {
|
|
629
|
+
case "left":
|
|
630
|
+
r = r.leftJoin(m.from, u.joinCondition);
|
|
631
|
+
break;
|
|
632
|
+
case "inner":
|
|
633
|
+
r = r.innerJoin(m.from, u.joinCondition);
|
|
634
|
+
break;
|
|
635
|
+
case "right":
|
|
636
|
+
r = r.rightJoin(m.from, u.joinCondition);
|
|
637
|
+
break;
|
|
638
|
+
case "full":
|
|
639
|
+
r = r.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), o.whereConditions.length > 0 && c.push(...o.whereConditions), c.length > 0) {
|
|
648
|
+
const u = c.length === 1 ? c[0] : p(...c);
|
|
649
|
+
r = r.where(u);
|
|
511
650
|
}
|
|
512
|
-
o.groupByFields.length > 0 && (
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return this.generateCubeSQL(e, t, s);
|
|
651
|
+
o.groupByFields.length > 0 && (r = r.groupBy(...o.groupByFields));
|
|
652
|
+
const l = this.buildOrderBy(t);
|
|
653
|
+
if (l.length > 0 && (r = r.orderBy(...l)), t.limit !== void 0) {
|
|
654
|
+
if (t.limit < 0)
|
|
655
|
+
throw new Error("Limit must be non-negative");
|
|
656
|
+
r = r.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
|
+
r = r.offset(t.offset);
|
|
662
|
+
}
|
|
663
|
+
return r;
|
|
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
|
-
}, o = e.sql(
|
|
536
|
-
let
|
|
672
|
+
securityContext: i
|
|
673
|
+
}, o = e.sql(n), a = this.buildSelections(e, t, n);
|
|
674
|
+
let r = n.db.select(a).from(o.from);
|
|
537
675
|
if (o.joins)
|
|
538
|
-
for (const
|
|
539
|
-
switch (
|
|
676
|
+
for (const d of o.joins)
|
|
677
|
+
switch (d.type || "left") {
|
|
540
678
|
case "left":
|
|
541
|
-
|
|
679
|
+
r = r.leftJoin(d.table, d.on);
|
|
542
680
|
break;
|
|
543
681
|
case "inner":
|
|
544
|
-
|
|
682
|
+
r = r.innerJoin(d.table, d.on);
|
|
545
683
|
break;
|
|
546
684
|
case "right":
|
|
547
|
-
|
|
685
|
+
r = r.rightJoin(d.table, d.on);
|
|
548
686
|
break;
|
|
549
687
|
case "full":
|
|
550
|
-
|
|
688
|
+
r = r.fullJoin(d.table, d.on);
|
|
551
689
|
break;
|
|
552
690
|
}
|
|
553
|
-
o.where && (
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
const
|
|
557
|
-
|
|
691
|
+
o.where && (r = r.where(o.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
|
+
r = r.where(d);
|
|
558
696
|
}
|
|
559
|
-
const
|
|
560
|
-
|
|
697
|
+
const l = this.buildGroupByFields(e, t, n);
|
|
698
|
+
l.length > 0 && (r = r.groupBy(...l));
|
|
561
699
|
const u = this.buildOrderBy(t);
|
|
562
|
-
u.length > 0 && (
|
|
563
|
-
|
|
700
|
+
if (u.length > 0 && (r = r.orderBy(...u)), t.limit !== void 0) {
|
|
701
|
+
if (t.limit < 0)
|
|
702
|
+
throw new Error("Limit must be non-negative");
|
|
703
|
+
r = r.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
|
+
r = r.offset(t.offset);
|
|
709
|
+
}
|
|
710
|
+
const m = r.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
722
|
for (const o of t.dimensions) {
|
|
576
|
-
const [
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
|
|
723
|
+
const [a, r] = o.split(".");
|
|
724
|
+
if (a === e.name && e.dimensions[r]) {
|
|
725
|
+
const c = e.dimensions[r], l = b(c.sql, i);
|
|
726
|
+
n[o] = f`${l}`.as(o);
|
|
580
727
|
}
|
|
581
728
|
}
|
|
582
729
|
if (t.measures)
|
|
583
730
|
for (const o of t.measures) {
|
|
584
|
-
const [
|
|
585
|
-
if (
|
|
586
|
-
const
|
|
587
|
-
|
|
731
|
+
const [a, r] = o.split(".");
|
|
732
|
+
if (a === e.name && e.measures[r]) {
|
|
733
|
+
const c = e.measures[r], l = this.buildMeasureExpression(c, i);
|
|
734
|
+
n[o] = f`${l}`.as(o);
|
|
588
735
|
}
|
|
589
736
|
}
|
|
590
737
|
if (t.timeDimensions)
|
|
591
738
|
for (const o of t.timeDimensions) {
|
|
592
|
-
const [
|
|
593
|
-
if (
|
|
594
|
-
const
|
|
595
|
-
|
|
739
|
+
const [a, r] = o.dimension.split(".");
|
|
740
|
+
if (a === e.name && e.dimensions[r]) {
|
|
741
|
+
const c = e.dimensions[r], l = this.buildTimeDimensionExpression(
|
|
742
|
+
c.sql,
|
|
596
743
|
o.granularity,
|
|
597
|
-
|
|
744
|
+
i
|
|
598
745
|
);
|
|
599
|
-
|
|
746
|
+
n[o.dimension] = f`${l}`.as(o.dimension);
|
|
600
747
|
}
|
|
601
748
|
}
|
|
602
|
-
return Object.keys(
|
|
749
|
+
return Object.keys(n).length === 0 && (n.count = y()), 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((o) => o(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 y(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 y(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 o of t.filters) {
|
|
814
|
+
const a = this.processFilter(o, e, i);
|
|
815
|
+
a && n.push(a);
|
|
816
|
+
}
|
|
817
|
+
if (t.timeDimensions)
|
|
818
|
+
for (const o of t.timeDimensions) {
|
|
819
|
+
const [a, r] = o.dimension.split(".");
|
|
820
|
+
if (a === e.name && e.dimensions[r] && o.dateRange) {
|
|
821
|
+
const c = e.dimensions[r], l = b(c.sql, i), u = this.buildDateRangeCondition(l, o.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
|
|
842
|
+
const n = e, [o, a] = n.member.split(".");
|
|
689
843
|
if (o !== t.name) return null;
|
|
690
|
-
const
|
|
691
|
-
if (!
|
|
692
|
-
const
|
|
693
|
-
return this.buildFilterCondition(
|
|
844
|
+
const r = t.dimensions[a] || t.measures[a];
|
|
845
|
+
if (!r) return null;
|
|
846
|
+
const c = b(r.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 o = n[0];
|
|
700
859
|
switch (t) {
|
|
701
860
|
case "equals":
|
|
702
|
-
return
|
|
861
|
+
return n.length > 1 ? Z(e, n) : n.length === 1 ? v(e, o) : f`FALSE`;
|
|
703
862
|
case "notEquals":
|
|
704
|
-
return
|
|
863
|
+
return n.length > 1 ? H(e, n) : n.length === 1 ? V(e, o) : null;
|
|
705
864
|
case "contains":
|
|
706
|
-
return
|
|
865
|
+
return f`${e} ILIKE ${"%" + o + "%"}`;
|
|
707
866
|
case "notContains":
|
|
708
|
-
return
|
|
867
|
+
return f`${e} NOT ILIKE ${"%" + o + "%"}`;
|
|
709
868
|
case "startsWith":
|
|
710
|
-
return
|
|
869
|
+
return f`${e} ILIKE ${o + "%"}`;
|
|
711
870
|
case "endsWith":
|
|
712
|
-
return
|
|
871
|
+
return f`${e} ILIKE ${"%" + o}`;
|
|
713
872
|
case "gt":
|
|
714
|
-
return
|
|
873
|
+
return A(e, o);
|
|
715
874
|
case "gte":
|
|
716
|
-
return
|
|
875
|
+
return w(e, o);
|
|
717
876
|
case "lt":
|
|
718
|
-
return
|
|
877
|
+
return F(e, o);
|
|
719
878
|
case "lte":
|
|
720
|
-
return
|
|
879
|
+
return N(e, o);
|
|
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]), r = this.normalizeDate(n[1]);
|
|
887
|
+
if (a && r)
|
|
888
|
+
return p(
|
|
889
|
+
w(e, a),
|
|
890
|
+
N(e, r)
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
return null;
|
|
894
|
+
case "beforeDate": {
|
|
895
|
+
const a = this.normalizeDate(o);
|
|
896
|
+
return a ? F(e, a) : null;
|
|
897
|
+
}
|
|
898
|
+
case "afterDate": {
|
|
899
|
+
const a = this.normalizeDate(o);
|
|
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
|
+
N(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
|
+
N(e, i.end)
|
|
924
|
+
);
|
|
925
|
+
const n = this.normalizeDate(t);
|
|
926
|
+
if (!n) return null;
|
|
927
|
+
const o = new Date(n);
|
|
928
|
+
o.setUTCHours(0, 0, 0, 0);
|
|
929
|
+
const a = new Date(n);
|
|
930
|
+
return a.setUTCHours(23, 59, 59, 999), p(
|
|
931
|
+
w(e, o),
|
|
932
|
+
N(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 r = parseInt(n[1], 10), c = new Date(t);
|
|
944
|
+
c.setDate(t.getDate() - r), 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 r = 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: r, end: c };
|
|
951
|
+
}
|
|
952
|
+
const o = i.match(/^last\s+(\d+)\s+months?$/);
|
|
953
|
+
if (o) {
|
|
954
|
+
const r = parseInt(o[1], 10), c = new Date(t.getFullYear(), t.getMonth() - r, 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 r = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0), c = new Date(t.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
959
|
+
return { start: r, end: c };
|
|
960
|
+
}
|
|
961
|
+
const a = i.match(/^last\s+(\d+)\s+years?$/);
|
|
962
|
+
if (a) {
|
|
963
|
+
const r = parseInt(a[1], 10), c = new Date(t.getFullYear() - r, 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
989
|
for (const o of t.dimensions) {
|
|
745
|
-
const [
|
|
746
|
-
if (
|
|
747
|
-
const
|
|
748
|
-
|
|
990
|
+
const [a, r] = o.split(".");
|
|
991
|
+
if (a === e.name && e.dimensions[r]) {
|
|
992
|
+
const c = e.dimensions[r], l = b(c.sql, i);
|
|
993
|
+
n.push(l);
|
|
749
994
|
}
|
|
750
995
|
}
|
|
751
996
|
if (t.timeDimensions)
|
|
752
997
|
for (const o of t.timeDimensions) {
|
|
753
|
-
const [
|
|
754
|
-
if (
|
|
755
|
-
const
|
|
756
|
-
|
|
998
|
+
const [a, r] = o.dimension.split(".");
|
|
999
|
+
if (a === e.name && e.dimensions[r]) {
|
|
1000
|
+
const c = e.dimensions[r], l = this.buildTimeDimensionExpression(
|
|
1001
|
+
c.sql,
|
|
757
1002
|
o.granularity,
|
|
758
|
-
|
|
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 o;
|
|
1015
|
+
const i = [], n = t || [
|
|
1016
|
+
...e.measures || [],
|
|
1017
|
+
...e.dimensions || [],
|
|
1018
|
+
...((o = e.timeDimensions) == null ? void 0 : o.map((a) => a.dimension)) || []
|
|
1019
|
+
];
|
|
1020
|
+
if (e.order && Object.keys(e.order).length > 0)
|
|
1021
|
+
for (const [a, r] 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 = r === "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 || {})), r = [...e.timeDimensions].sort(
|
|
1029
|
+
(c, l) => c.dimension.localeCompare(l.dimension)
|
|
1030
|
+
);
|
|
1031
|
+
for (const c of r)
|
|
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 = {}, o = {};
|
|
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 [r, c] = a.split(".");
|
|
1044
|
+
if (r === 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 [r, c] = a.split(".");
|
|
1056
|
+
if (r === 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
|
-
o[
|
|
813
|
-
title:
|
|
814
|
-
shortTitle:
|
|
815
|
-
type:
|
|
816
|
-
granularity:
|
|
1066
|
+
for (const a of t.timeDimensions) {
|
|
1067
|
+
const [r, c] = a.dimension.split(".");
|
|
1068
|
+
if (r === e.name && e.dimensions[c]) {
|
|
1069
|
+
const l = e.dimensions[c];
|
|
1070
|
+
o[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
1082
|
timeDimensions: o
|
|
825
1083
|
};
|
|
@@ -828,57 +1086,61 @@ class de {
|
|
|
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 = {}, o = {}, a = [e.primaryCube];
|
|
1090
|
+
if (e.joinCubes && a.push(...e.joinCubes.map((r) => r.cube)), t.measures)
|
|
1091
|
+
for (const r of t.measures) {
|
|
1092
|
+
const [c, l] = r.split("."), u = a.find((m) => m.name === c);
|
|
1093
|
+
if (u && u.measures[l]) {
|
|
1094
|
+
const m = u.measures[l];
|
|
1095
|
+
i[r] = {
|
|
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 r of t.dimensions) {
|
|
1104
|
+
const [c, l] = r.split("."), u = a.find((m) => m.name === c);
|
|
1105
|
+
if (u && u.dimensions[l]) {
|
|
1106
|
+
const m = u.dimensions[l];
|
|
1107
|
+
n[r] = {
|
|
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 r of t.timeDimensions) {
|
|
1116
|
+
const [c, l] = r.dimension.split("."), u = a.find((m) => m.name === c);
|
|
1117
|
+
if (u && u.dimensions && u.dimensions[l]) {
|
|
1118
|
+
const m = u.dimensions[l];
|
|
1119
|
+
o[r.dimension] = {
|
|
1120
|
+
title: m.title || l,
|
|
1121
|
+
shortTitle: m.title || l,
|
|
1122
|
+
type: m.type,
|
|
1123
|
+
granularity: r.granularity
|
|
866
1124
|
};
|
|
867
1125
|
}
|
|
868
1126
|
}
|
|
869
1127
|
return {
|
|
870
|
-
measures:
|
|
871
|
-
dimensions:
|
|
1128
|
+
measures: i,
|
|
1129
|
+
dimensions: n,
|
|
872
1130
|
segments: {},
|
|
873
1131
|
timeDimensions: o
|
|
874
1132
|
};
|
|
875
1133
|
}
|
|
876
1134
|
}
|
|
877
|
-
class
|
|
1135
|
+
class T {
|
|
1136
|
+
// 5 minutes in milliseconds
|
|
878
1137
|
constructor(e) {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1138
|
+
C(this, "cubes", /* @__PURE__ */ new Map());
|
|
1139
|
+
C(this, "dbExecutor");
|
|
1140
|
+
C(this, "metadataCache");
|
|
1141
|
+
C(this, "metadataCacheTimestamp");
|
|
1142
|
+
C(this, "METADATA_CACHE_TTL", 5 * 60 * 1e3);
|
|
1143
|
+
e != null && e.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e != null && e.drizzle && (this.dbExecutor = _(
|
|
882
1144
|
e.drizzle,
|
|
883
1145
|
e.schema,
|
|
884
1146
|
e.engineType
|
|
@@ -893,8 +1155,8 @@ class te {
|
|
|
893
1155
|
/**
|
|
894
1156
|
* Set Drizzle instance and schema directly
|
|
895
1157
|
*/
|
|
896
|
-
setDrizzle(e, t,
|
|
897
|
-
this.dbExecutor =
|
|
1158
|
+
setDrizzle(e, t, i) {
|
|
1159
|
+
this.dbExecutor = _(e, t, i);
|
|
898
1160
|
}
|
|
899
1161
|
/**
|
|
900
1162
|
* Check if database executor is configured
|
|
@@ -906,7 +1168,7 @@ class te {
|
|
|
906
1168
|
* Register a simplified cube with dynamic query building
|
|
907
1169
|
*/
|
|
908
1170
|
registerCube(e) {
|
|
909
|
-
this.cubes.set(e.name, e);
|
|
1171
|
+
this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
910
1172
|
}
|
|
911
1173
|
/**
|
|
912
1174
|
* Get a cube by name
|
|
@@ -932,7 +1194,7 @@ class te {
|
|
|
932
1194
|
async execute(e, t) {
|
|
933
1195
|
if (!this.dbExecutor)
|
|
934
1196
|
throw new Error("Database executor not configured");
|
|
935
|
-
return new
|
|
1197
|
+
return new $(this.dbExecutor).execute(this.cubes, e, t);
|
|
936
1198
|
}
|
|
937
1199
|
/**
|
|
938
1200
|
* Execute a multi-cube query
|
|
@@ -943,44 +1205,58 @@ class te {
|
|
|
943
1205
|
/**
|
|
944
1206
|
* Execute a single cube query
|
|
945
1207
|
*/
|
|
946
|
-
async executeQuery(e, t,
|
|
1208
|
+
async executeQuery(e, t, i) {
|
|
947
1209
|
if (!this.cubes.get(e))
|
|
948
1210
|
throw new Error(`Cube '${e}' not found`);
|
|
949
|
-
return this.execute(t,
|
|
1211
|
+
return this.execute(t, i);
|
|
950
1212
|
}
|
|
951
1213
|
/**
|
|
952
1214
|
* Get metadata for all cubes (for API responses)
|
|
1215
|
+
* Uses caching to improve performance for repeated requests
|
|
953
1216
|
*/
|
|
954
1217
|
getMetadata() {
|
|
955
|
-
|
|
1218
|
+
const e = Date.now();
|
|
1219
|
+
if (this.metadataCache && this.metadataCacheTimestamp && e - this.metadataCacheTimestamp < this.METADATA_CACHE_TTL)
|
|
1220
|
+
return this.metadataCache;
|
|
1221
|
+
const t = Array.from(this.cubes.values()).map((i) => this.generateCubeMetadata(i));
|
|
1222
|
+
return this.metadataCache = t, this.metadataCacheTimestamp = e, t;
|
|
956
1223
|
}
|
|
957
1224
|
/**
|
|
958
1225
|
* Generate cube metadata for API responses from cubes
|
|
1226
|
+
* Optimized version that minimizes object iterations
|
|
959
1227
|
*/
|
|
960
1228
|
generateCubeMetadata(e) {
|
|
961
|
-
const t = Object.
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1229
|
+
const t = Object.keys(e.measures), i = Object.keys(e.dimensions), n = new Array(t.length), o = new Array(i.length);
|
|
1230
|
+
for (let a = 0; a < t.length; a++) {
|
|
1231
|
+
const r = t[a], c = e.measures[r];
|
|
1232
|
+
n[a] = {
|
|
1233
|
+
name: `${e.name}.${r}`,
|
|
1234
|
+
title: c.title || r,
|
|
1235
|
+
shortTitle: c.title || r,
|
|
1236
|
+
type: c.type,
|
|
1237
|
+
format: void 0,
|
|
1238
|
+
// Measure doesn't have format field
|
|
1239
|
+
description: c.description
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
for (let a = 0; a < i.length; a++) {
|
|
1243
|
+
const r = i[a], c = e.dimensions[r];
|
|
1244
|
+
o[a] = {
|
|
1245
|
+
name: `${e.name}.${r}`,
|
|
1246
|
+
title: c.title || r,
|
|
1247
|
+
shortTitle: c.title || r,
|
|
1248
|
+
type: c.type,
|
|
1249
|
+
format: void 0,
|
|
1250
|
+
// Dimension doesn't have format field
|
|
1251
|
+
description: c.description
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
978
1254
|
return {
|
|
979
1255
|
name: e.name,
|
|
980
1256
|
title: e.title || e.name,
|
|
981
1257
|
description: e.description,
|
|
982
|
-
measures:
|
|
983
|
-
dimensions:
|
|
1258
|
+
measures: n,
|
|
1259
|
+
dimensions: o,
|
|
984
1260
|
segments: []
|
|
985
1261
|
// Add segments support later if needed
|
|
986
1262
|
};
|
|
@@ -988,13 +1264,21 @@ class te {
|
|
|
988
1264
|
/**
|
|
989
1265
|
* Get SQL for a query without executing it (debugging)
|
|
990
1266
|
*/
|
|
991
|
-
async generateSQL(e, t,
|
|
992
|
-
const
|
|
993
|
-
if (!
|
|
1267
|
+
async generateSQL(e, t, i) {
|
|
1268
|
+
const n = this.getCube(e);
|
|
1269
|
+
if (!n)
|
|
994
1270
|
throw new Error(`Cube '${e}' not found`);
|
|
995
1271
|
if (!this.dbExecutor)
|
|
996
1272
|
throw new Error("Database executor not configured");
|
|
997
|
-
return new
|
|
1273
|
+
return new $(this.dbExecutor).generateSQL(n, t, i);
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Get SQL for a multi-cube query without executing it (debugging)
|
|
1277
|
+
*/
|
|
1278
|
+
async generateMultiCubeSQL(e, t) {
|
|
1279
|
+
if (!this.dbExecutor)
|
|
1280
|
+
throw new Error("Database executor not configured");
|
|
1281
|
+
return new $(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t);
|
|
998
1282
|
}
|
|
999
1283
|
/**
|
|
1000
1284
|
* Check if a cube exists
|
|
@@ -1006,13 +1290,21 @@ class te {
|
|
|
1006
1290
|
* Remove a cube
|
|
1007
1291
|
*/
|
|
1008
1292
|
removeCube(e) {
|
|
1009
|
-
|
|
1293
|
+
const t = this.cubes.delete(e);
|
|
1294
|
+
return t && this.invalidateMetadataCache(), t;
|
|
1010
1295
|
}
|
|
1011
1296
|
/**
|
|
1012
1297
|
* Clear all cubes
|
|
1013
1298
|
*/
|
|
1014
1299
|
clearCubes() {
|
|
1015
|
-
this.cubes.clear();
|
|
1300
|
+
this.cubes.clear(), this.invalidateMetadataCache();
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Invalidate the metadata cache
|
|
1304
|
+
* Called whenever cubes are modified
|
|
1305
|
+
*/
|
|
1306
|
+
invalidateMetadataCache() {
|
|
1307
|
+
this.metadataCache = void 0, this.metadataCacheTimestamp = void 0;
|
|
1016
1308
|
}
|
|
1017
1309
|
/**
|
|
1018
1310
|
* Get cube names
|
|
@@ -1020,12 +1312,98 @@ class te {
|
|
|
1020
1312
|
getCubeNames() {
|
|
1021
1313
|
return Array.from(this.cubes.keys());
|
|
1022
1314
|
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Validate a query against registered cubes
|
|
1317
|
+
* Ensures all referenced cubes and fields exist
|
|
1318
|
+
*/
|
|
1319
|
+
validateQuery(e) {
|
|
1320
|
+
return j(this.cubes, e);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
function j(s, e) {
|
|
1324
|
+
const t = [], i = /* @__PURE__ */ new Set();
|
|
1325
|
+
if (e.measures)
|
|
1326
|
+
for (const n of e.measures) {
|
|
1327
|
+
const [o, a] = n.split(".");
|
|
1328
|
+
if (!o || !a) {
|
|
1329
|
+
t.push(`Invalid measure format: ${n}. Expected format: 'CubeName.fieldName'`);
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
i.add(o);
|
|
1333
|
+
const r = s.get(o);
|
|
1334
|
+
if (!r) {
|
|
1335
|
+
t.push(`Cube '${o}' not found (referenced in measure '${n}')`);
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1338
|
+
r.measures[a] || t.push(`Measure '${a}' not found on cube '${o}'`);
|
|
1339
|
+
}
|
|
1340
|
+
if (e.dimensions)
|
|
1341
|
+
for (const n of e.dimensions) {
|
|
1342
|
+
const [o, a] = n.split(".");
|
|
1343
|
+
if (!o || !a) {
|
|
1344
|
+
t.push(`Invalid dimension format: ${n}. Expected format: 'CubeName.fieldName'`);
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
i.add(o);
|
|
1348
|
+
const r = s.get(o);
|
|
1349
|
+
if (!r) {
|
|
1350
|
+
t.push(`Cube '${o}' not found (referenced in dimension '${n}')`);
|
|
1351
|
+
continue;
|
|
1352
|
+
}
|
|
1353
|
+
r.dimensions[a] || t.push(`Dimension '${a}' not found on cube '${o}'`);
|
|
1354
|
+
}
|
|
1355
|
+
if (e.timeDimensions)
|
|
1356
|
+
for (const n of e.timeDimensions) {
|
|
1357
|
+
const [o, a] = n.dimension.split(".");
|
|
1358
|
+
if (!o || !a) {
|
|
1359
|
+
t.push(`Invalid timeDimension format: ${n.dimension}. Expected format: 'CubeName.fieldName'`);
|
|
1360
|
+
continue;
|
|
1361
|
+
}
|
|
1362
|
+
i.add(o);
|
|
1363
|
+
const r = s.get(o);
|
|
1364
|
+
if (!r) {
|
|
1365
|
+
t.push(`Cube '${o}' not found (referenced in timeDimension '${n.dimension}')`);
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
r.dimensions[a] || t.push(`TimeDimension '${a}' not found on cube '${o}' (must be a dimension with time type)`);
|
|
1369
|
+
}
|
|
1370
|
+
if (e.filters)
|
|
1371
|
+
for (const n of e.filters)
|
|
1372
|
+
L(n, s, t, i);
|
|
1373
|
+
return i.size === 0 && t.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
1374
|
+
isValid: t.length === 0,
|
|
1375
|
+
errors: t
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function L(s, e, t, i) {
|
|
1379
|
+
if ("and" in s || "or" in s) {
|
|
1380
|
+
const r = s.and || s.or || [];
|
|
1381
|
+
for (const c of r)
|
|
1382
|
+
L(c, e, t, i);
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
if (!("member" in s)) {
|
|
1386
|
+
t.push("Filter must have a member field");
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
const [n, o] = s.member.split(".");
|
|
1390
|
+
if (!n || !o) {
|
|
1391
|
+
t.push(`Invalid filter member format: ${s.member}. Expected format: 'CubeName.fieldName'`);
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
i.add(n);
|
|
1395
|
+
const a = e.get(n);
|
|
1396
|
+
if (!a) {
|
|
1397
|
+
t.push(`Cube '${n}' not found (referenced in filter '${s.member}')`);
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
!a.dimensions[o] && !a.measures[o] && t.push(`Filter field '${o}' not found on cube '${n}' (must be a dimension or measure)`);
|
|
1023
1401
|
}
|
|
1024
|
-
function
|
|
1025
|
-
return new
|
|
1402
|
+
function Ee(s) {
|
|
1403
|
+
return new T(s);
|
|
1026
1404
|
}
|
|
1027
|
-
const
|
|
1028
|
-
function
|
|
1405
|
+
const se = new T();
|
|
1406
|
+
function re(s) {
|
|
1029
1407
|
const e = {
|
|
1030
1408
|
valid: !0,
|
|
1031
1409
|
errors: [],
|
|
@@ -1033,7 +1411,7 @@ function xo(n) {
|
|
|
1033
1411
|
cubes: []
|
|
1034
1412
|
};
|
|
1035
1413
|
try {
|
|
1036
|
-
const t =
|
|
1414
|
+
const t = G(s);
|
|
1037
1415
|
if (!t)
|
|
1038
1416
|
return e.valid = !1, e.errors.push("Invalid YAML: empty or malformed content"), e;
|
|
1039
1417
|
if (t.cubes && Array.isArray(t.cubes))
|
|
@@ -1042,9 +1420,9 @@ function xo(n) {
|
|
|
1042
1420
|
e.cubes = [t];
|
|
1043
1421
|
else
|
|
1044
1422
|
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(...
|
|
1423
|
+
for (const i of e.cubes) {
|
|
1424
|
+
const n = oe(i);
|
|
1425
|
+
e.errors.push(...n);
|
|
1048
1426
|
}
|
|
1049
1427
|
e.valid = e.errors.length === 0;
|
|
1050
1428
|
} catch (t) {
|
|
@@ -1052,87 +1430,87 @@ function xo(n) {
|
|
|
1052
1430
|
}
|
|
1053
1431
|
return e;
|
|
1054
1432
|
}
|
|
1055
|
-
function
|
|
1433
|
+
function oe(s) {
|
|
1056
1434
|
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 ${
|
|
1435
|
+
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) => {
|
|
1436
|
+
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`);
|
|
1437
|
+
}), s.measures && s.measures.forEach((t, i) => {
|
|
1438
|
+
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`);
|
|
1439
|
+
}), s.joins && s.joins.forEach((t, i) => {
|
|
1440
|
+
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
1441
|
}), e;
|
|
1064
1442
|
}
|
|
1065
|
-
function
|
|
1443
|
+
function ae(s) {
|
|
1066
1444
|
const e = {};
|
|
1067
|
-
|
|
1068
|
-
e[
|
|
1445
|
+
s.dimensions && s.dimensions.forEach((r) => {
|
|
1446
|
+
e[r.name] = ce(r);
|
|
1069
1447
|
});
|
|
1070
1448
|
const t = {};
|
|
1071
|
-
|
|
1072
|
-
t[
|
|
1073
|
-
});
|
|
1074
|
-
const s = {};
|
|
1075
|
-
n.joins && n.joins.forEach((a) => {
|
|
1076
|
-
s[a.name] = vo(a);
|
|
1449
|
+
s.measures && s.measures.forEach((r) => {
|
|
1450
|
+
t[r.name] = le(r);
|
|
1077
1451
|
});
|
|
1078
1452
|
const i = {};
|
|
1079
|
-
|
|
1080
|
-
i[
|
|
1453
|
+
s.joins && s.joins.forEach((r) => {
|
|
1454
|
+
i[r.name] = fe(r);
|
|
1081
1455
|
});
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1456
|
+
const n = {};
|
|
1457
|
+
(s.pre_aggregations || s.preAggregations) && (s.pre_aggregations || s.preAggregations || []).forEach((c) => {
|
|
1458
|
+
n[c.name] = de(c);
|
|
1459
|
+
});
|
|
1460
|
+
let o = s.sql;
|
|
1461
|
+
!o && (s.sql_table || s.sqlTable) && (o = `SELECT * FROM ${s.sql_table || s.sqlTable}`);
|
|
1462
|
+
const a = s.refresh_key || s.refreshKey;
|
|
1085
1463
|
return {
|
|
1086
|
-
name:
|
|
1087
|
-
title:
|
|
1088
|
-
description:
|
|
1464
|
+
name: s.name,
|
|
1465
|
+
title: s.title,
|
|
1466
|
+
description: s.description,
|
|
1089
1467
|
sql: o || "",
|
|
1090
|
-
sqlAlias:
|
|
1091
|
-
dataSource:
|
|
1092
|
-
refreshKey:
|
|
1093
|
-
every:
|
|
1094
|
-
sql:
|
|
1468
|
+
sqlAlias: s.sql_alias || s.sqlAlias,
|
|
1469
|
+
dataSource: s.data_source || s.dataSource,
|
|
1470
|
+
refreshKey: a ? {
|
|
1471
|
+
every: a.every,
|
|
1472
|
+
sql: a.sql
|
|
1095
1473
|
} : void 0,
|
|
1096
1474
|
dimensions: e,
|
|
1097
1475
|
measures: t,
|
|
1098
|
-
joins: Object.keys(
|
|
1099
|
-
preAggregations: Object.keys(
|
|
1100
|
-
meta:
|
|
1476
|
+
joins: Object.keys(i).length > 0 ? i : void 0,
|
|
1477
|
+
preAggregations: Object.keys(n).length > 0 ? n : void 0,
|
|
1478
|
+
meta: s.meta
|
|
1101
1479
|
};
|
|
1102
1480
|
}
|
|
1103
|
-
function
|
|
1481
|
+
function ce(s) {
|
|
1104
1482
|
return {
|
|
1105
|
-
name:
|
|
1106
|
-
title:
|
|
1107
|
-
description:
|
|
1108
|
-
type:
|
|
1109
|
-
sql:
|
|
1110
|
-
primaryKey:
|
|
1111
|
-
shown:
|
|
1112
|
-
format:
|
|
1113
|
-
meta:
|
|
1483
|
+
name: s.name,
|
|
1484
|
+
title: s.title,
|
|
1485
|
+
description: s.description,
|
|
1486
|
+
type: s.type,
|
|
1487
|
+
sql: s.sql,
|
|
1488
|
+
primaryKey: s.primary_key || s.primaryKey,
|
|
1489
|
+
shown: s.shown,
|
|
1490
|
+
format: s.format,
|
|
1491
|
+
meta: s.meta
|
|
1114
1492
|
};
|
|
1115
1493
|
}
|
|
1116
|
-
function
|
|
1117
|
-
var
|
|
1118
|
-
const e = (
|
|
1119
|
-
sql:
|
|
1120
|
-
})), t =
|
|
1494
|
+
function le(s) {
|
|
1495
|
+
var i;
|
|
1496
|
+
const e = (i = s.filters) == null ? void 0 : i.map((n) => ({
|
|
1497
|
+
sql: n.sql
|
|
1498
|
+
})), t = s.rolling_window || s.rollingWindow;
|
|
1121
1499
|
return {
|
|
1122
|
-
name:
|
|
1123
|
-
title:
|
|
1124
|
-
description:
|
|
1125
|
-
type:
|
|
1126
|
-
sql:
|
|
1127
|
-
format:
|
|
1128
|
-
shown:
|
|
1500
|
+
name: s.name,
|
|
1501
|
+
title: s.title,
|
|
1502
|
+
description: s.description,
|
|
1503
|
+
type: s.type,
|
|
1504
|
+
sql: s.sql,
|
|
1505
|
+
format: s.format,
|
|
1506
|
+
shown: s.shown,
|
|
1129
1507
|
filters: e,
|
|
1130
1508
|
rollingWindow: t,
|
|
1131
|
-
meta:
|
|
1509
|
+
meta: s.meta
|
|
1132
1510
|
};
|
|
1133
1511
|
}
|
|
1134
|
-
function
|
|
1135
|
-
switch (
|
|
1512
|
+
function ue(s) {
|
|
1513
|
+
switch (s) {
|
|
1136
1514
|
case "one_to_one":
|
|
1137
1515
|
return "hasOne";
|
|
1138
1516
|
case "one_to_many":
|
|
@@ -1143,8 +1521,8 @@ function Po(n) {
|
|
|
1143
1521
|
return "belongsTo";
|
|
1144
1522
|
}
|
|
1145
1523
|
}
|
|
1146
|
-
function
|
|
1147
|
-
switch (
|
|
1524
|
+
function me(s) {
|
|
1525
|
+
switch (s) {
|
|
1148
1526
|
case "hasOne":
|
|
1149
1527
|
return "one_to_one";
|
|
1150
1528
|
case "hasMany":
|
|
@@ -1155,62 +1533,62 @@ function Do(n) {
|
|
|
1155
1533
|
return "many_to_one";
|
|
1156
1534
|
}
|
|
1157
1535
|
}
|
|
1158
|
-
function
|
|
1536
|
+
function fe(s) {
|
|
1159
1537
|
return {
|
|
1160
|
-
name:
|
|
1161
|
-
type:
|
|
1162
|
-
relationship:
|
|
1163
|
-
sql:
|
|
1538
|
+
name: s.name,
|
|
1539
|
+
type: s.type,
|
|
1540
|
+
relationship: ue(s.relationship),
|
|
1541
|
+
sql: s.sql
|
|
1164
1542
|
};
|
|
1165
1543
|
}
|
|
1166
|
-
function
|
|
1167
|
-
const e =
|
|
1544
|
+
function de(s) {
|
|
1545
|
+
const e = s.time_dimension || s.timeDimension, t = s.refresh_key || s.refreshKey;
|
|
1168
1546
|
return {
|
|
1169
|
-
name:
|
|
1170
|
-
measures:
|
|
1171
|
-
dimensions:
|
|
1547
|
+
name: s.name,
|
|
1548
|
+
measures: s.measures,
|
|
1549
|
+
dimensions: s.dimensions,
|
|
1172
1550
|
timeDimension: e,
|
|
1173
1551
|
refreshKey: t,
|
|
1174
|
-
indexes:
|
|
1552
|
+
indexes: s.indexes
|
|
1175
1553
|
};
|
|
1176
1554
|
}
|
|
1177
|
-
async function
|
|
1555
|
+
async function he() {
|
|
1178
1556
|
try {
|
|
1179
|
-
const { promises:
|
|
1557
|
+
const { promises: s } = await import("fs"), e = await s.readFile("non-existent-file.txt", "utf-8").catch((t) => t.message);
|
|
1180
1558
|
return !(typeof e == "string" && e.includes("not implemented"));
|
|
1181
1559
|
} catch {
|
|
1182
1560
|
return !1;
|
|
1183
1561
|
}
|
|
1184
1562
|
}
|
|
1185
|
-
function
|
|
1186
|
-
const e =
|
|
1563
|
+
function pe(s) {
|
|
1564
|
+
const e = re(s);
|
|
1187
1565
|
if (!e.valid)
|
|
1188
1566
|
throw new Error(`Invalid YAML cube definition:
|
|
1189
1567
|
${e.errors.join(`
|
|
1190
1568
|
`)}`);
|
|
1191
|
-
return e.cubes.map((t) =>
|
|
1569
|
+
return e.cubes.map((t) => ae(t));
|
|
1192
1570
|
}
|
|
1193
|
-
async function
|
|
1194
|
-
if (!await
|
|
1571
|
+
async function De(s) {
|
|
1572
|
+
if (!await he())
|
|
1195
1573
|
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
1574
|
try {
|
|
1197
|
-
const { promises: t } = await import("fs"),
|
|
1198
|
-
return
|
|
1575
|
+
const { promises: t } = await import("fs"), i = await t.readFile(s, "utf-8");
|
|
1576
|
+
return pe(i);
|
|
1199
1577
|
} catch (t) {
|
|
1200
|
-
return console.log(`ℹ️ Could not load YAML file ${
|
|
1578
|
+
return console.log(`ℹ️ Could not load YAML file ${s}:`, t instanceof Error ? t.message : t), [];
|
|
1201
1579
|
}
|
|
1202
1580
|
}
|
|
1203
|
-
function
|
|
1204
|
-
let e =
|
|
1581
|
+
function ye(s) {
|
|
1582
|
+
let e = s;
|
|
1205
1583
|
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
1584
|
}
|
|
1207
|
-
function $
|
|
1585
|
+
function $e(s) {
|
|
1208
1586
|
const e = {
|
|
1209
|
-
name:
|
|
1210
|
-
title:
|
|
1211
|
-
description:
|
|
1212
|
-
sql: typeof
|
|
1213
|
-
dimensions: Object.values(
|
|
1587
|
+
name: s.name,
|
|
1588
|
+
title: s.title,
|
|
1589
|
+
description: s.description,
|
|
1590
|
+
sql: typeof s.sql == "string" ? s.sql : void 0,
|
|
1591
|
+
dimensions: Object.values(s.dimensions).map((t) => ({
|
|
1214
1592
|
name: t.name,
|
|
1215
1593
|
title: t.title,
|
|
1216
1594
|
description: t.description,
|
|
@@ -1221,8 +1599,8 @@ function $a(n) {
|
|
|
1221
1599
|
format: t.format,
|
|
1222
1600
|
meta: t.meta
|
|
1223
1601
|
})),
|
|
1224
|
-
measures: Object.values(
|
|
1225
|
-
var
|
|
1602
|
+
measures: Object.values(s.measures).map((t) => {
|
|
1603
|
+
var i;
|
|
1226
1604
|
return {
|
|
1227
1605
|
name: t.name,
|
|
1228
1606
|
title: t.title,
|
|
@@ -1231,2257 +1609,108 @@ function $a(n) {
|
|
|
1231
1609
|
sql: typeof t.sql == "string" ? t.sql : "",
|
|
1232
1610
|
format: t.format,
|
|
1233
1611
|
shown: t.shown,
|
|
1234
|
-
filters: (
|
|
1235
|
-
sql: typeof
|
|
1612
|
+
filters: (i = t.filters) == null ? void 0 : i.map((n) => ({
|
|
1613
|
+
sql: typeof n.sql == "string" ? n.sql : ""
|
|
1236
1614
|
})),
|
|
1237
1615
|
rolling_window: t.rollingWindow,
|
|
1238
1616
|
meta: t.meta
|
|
1239
1617
|
};
|
|
1240
1618
|
}),
|
|
1241
|
-
joins:
|
|
1619
|
+
joins: s.joins ? Object.values(s.joins).map((t) => ({
|
|
1242
1620
|
name: t.name || "",
|
|
1243
1621
|
type: t.type,
|
|
1244
|
-
relationship:
|
|
1622
|
+
relationship: me(t.relationship),
|
|
1245
1623
|
sql: typeof t.sql == "string" ? t.sql : ""
|
|
1246
1624
|
})) : void 0,
|
|
1247
|
-
meta:
|
|
1625
|
+
meta: s.meta
|
|
1248
1626
|
};
|
|
1249
|
-
return
|
|
1627
|
+
return P(e, {
|
|
1250
1628
|
indent: 2,
|
|
1251
1629
|
lineWidth: 120,
|
|
1252
1630
|
minContentWidth: 40
|
|
1253
1631
|
});
|
|
1254
1632
|
}
|
|
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
|
|
1633
|
+
const xe = se;
|
|
1634
|
+
function Te(s) {
|
|
1635
|
+
return new T({
|
|
1636
|
+
drizzle: s.drizzle,
|
|
1637
|
+
schema: s.schema
|
|
3409
1638
|
});
|
|
3410
1639
|
}
|
|
3411
|
-
const
|
|
1640
|
+
const Ae = {
|
|
3412
1641
|
/**
|
|
3413
1642
|
* Create a simple query builder
|
|
3414
1643
|
*/
|
|
3415
1644
|
query: () => {
|
|
3416
|
-
const
|
|
1645
|
+
const s = (e, t = [], i = [], n = [], o, a) => ({
|
|
3417
1646
|
measures: e,
|
|
3418
1647
|
dimensions: t,
|
|
3419
|
-
filters:
|
|
3420
|
-
timeDimensions:
|
|
1648
|
+
filters: i,
|
|
1649
|
+
timeDimensions: n,
|
|
3421
1650
|
limit: o,
|
|
3422
|
-
order:
|
|
1651
|
+
order: a
|
|
3423
1652
|
});
|
|
3424
1653
|
return {
|
|
3425
1654
|
measures: (e) => ({
|
|
3426
1655
|
dimensions: (t = []) => ({
|
|
3427
|
-
filters: (
|
|
3428
|
-
timeDimensions: (
|
|
1656
|
+
filters: (i = []) => ({
|
|
1657
|
+
timeDimensions: (n = []) => ({
|
|
3429
1658
|
limit: (o) => ({
|
|
3430
|
-
order: (
|
|
1659
|
+
order: (a) => s(e, t, i, n, o, a)
|
|
3431
1660
|
}),
|
|
3432
|
-
order: (o) =>
|
|
1661
|
+
order: (o) => s(e, t, i, n, void 0, o)
|
|
3433
1662
|
}),
|
|
3434
|
-
limit: (
|
|
3435
|
-
order: (o) =>
|
|
1663
|
+
limit: (n) => ({
|
|
1664
|
+
order: (o) => s(e, t, i, [], n, o)
|
|
3436
1665
|
}),
|
|
3437
|
-
order: (
|
|
1666
|
+
order: (n) => s(e, t, i, [], void 0, n)
|
|
3438
1667
|
}),
|
|
3439
|
-
timeDimensions: (
|
|
3440
|
-
filters: (
|
|
1668
|
+
timeDimensions: (i = []) => ({
|
|
1669
|
+
filters: (n = []) => ({
|
|
3441
1670
|
limit: (o) => ({
|
|
3442
|
-
order: (
|
|
1671
|
+
order: (a) => s(e, t, n, i, o, a)
|
|
3443
1672
|
}),
|
|
3444
|
-
order: (o) =>
|
|
1673
|
+
order: (o) => s(e, t, n, i, void 0, o)
|
|
3445
1674
|
}),
|
|
3446
|
-
limit: (
|
|
3447
|
-
order: (o) =>
|
|
1675
|
+
limit: (n) => ({
|
|
1676
|
+
order: (o) => s(e, t, [], i, n, o)
|
|
3448
1677
|
}),
|
|
3449
|
-
order: (
|
|
1678
|
+
order: (n) => s(e, t, [], i, void 0, n)
|
|
3450
1679
|
}),
|
|
3451
|
-
limit: (
|
|
3452
|
-
order: (
|
|
1680
|
+
limit: (i) => ({
|
|
1681
|
+
order: (n) => s(e, t, [], [], i, n)
|
|
3453
1682
|
}),
|
|
3454
|
-
order: (
|
|
1683
|
+
order: (i) => s(e, t, [], [], void 0, i)
|
|
3455
1684
|
}),
|
|
3456
1685
|
filters: (t = []) => ({
|
|
3457
|
-
dimensions: (
|
|
3458
|
-
timeDimensions: (
|
|
1686
|
+
dimensions: (i = []) => ({
|
|
1687
|
+
timeDimensions: (n = []) => ({
|
|
3459
1688
|
limit: (o) => ({
|
|
3460
|
-
order: (
|
|
1689
|
+
order: (a) => s(e, i, t, n, o, a)
|
|
3461
1690
|
}),
|
|
3462
|
-
order: (o) =>
|
|
1691
|
+
order: (o) => s(e, i, t, n, void 0, o)
|
|
3463
1692
|
}),
|
|
3464
|
-
limit: (
|
|
3465
|
-
order: (o) =>
|
|
1693
|
+
limit: (n) => ({
|
|
1694
|
+
order: (o) => s(e, i, t, [], n, o)
|
|
3466
1695
|
}),
|
|
3467
|
-
order: (
|
|
1696
|
+
order: (n) => s(e, i, t, [], void 0, n)
|
|
3468
1697
|
}),
|
|
3469
|
-
timeDimensions: (
|
|
3470
|
-
dimensions: (
|
|
1698
|
+
timeDimensions: (i = []) => ({
|
|
1699
|
+
dimensions: (n = []) => ({
|
|
3471
1700
|
limit: (o) => ({
|
|
3472
|
-
order: (
|
|
1701
|
+
order: (a) => s(e, n, t, i, o, a)
|
|
3473
1702
|
}),
|
|
3474
|
-
order: (o) =>
|
|
1703
|
+
order: (o) => s(e, n, t, i, void 0, o)
|
|
3475
1704
|
}),
|
|
3476
|
-
limit: (
|
|
3477
|
-
order: (o) =>
|
|
1705
|
+
limit: (n) => ({
|
|
1706
|
+
order: (o) => s(e, [], t, i, n, o)
|
|
3478
1707
|
}),
|
|
3479
|
-
order: (
|
|
1708
|
+
order: (n) => s(e, [], t, i, void 0, n)
|
|
3480
1709
|
}),
|
|
3481
|
-
limit: (
|
|
3482
|
-
order: (
|
|
1710
|
+
limit: (i) => ({
|
|
1711
|
+
order: (n) => s(e, [], t, [], i, n)
|
|
3483
1712
|
}),
|
|
3484
|
-
order: (
|
|
1713
|
+
order: (i) => s(e, [], t, [], void 0, i)
|
|
3485
1714
|
})
|
|
3486
1715
|
})
|
|
3487
1716
|
};
|
|
@@ -3490,64 +1719,55 @@ const La = {
|
|
|
3490
1719
|
* Create filters
|
|
3491
1720
|
*/
|
|
3492
1721
|
filters: {
|
|
3493
|
-
equals: (
|
|
3494
|
-
notEquals: (
|
|
3495
|
-
contains: (
|
|
3496
|
-
greaterThan: (
|
|
3497
|
-
lessThan: (
|
|
3498
|
-
inDateRange: (
|
|
3499
|
-
member:
|
|
1722
|
+
equals: (s, e) => ({ member: s, operator: "equals", values: [e] }),
|
|
1723
|
+
notEquals: (s, e) => ({ member: s, operator: "notEquals", values: [e] }),
|
|
1724
|
+
contains: (s, e) => ({ member: s, operator: "contains", values: [e] }),
|
|
1725
|
+
greaterThan: (s, e) => ({ member: s, operator: "gt", values: [e] }),
|
|
1726
|
+
lessThan: (s, e) => ({ member: s, operator: "lt", values: [e] }),
|
|
1727
|
+
inDateRange: (s, e, t) => ({
|
|
1728
|
+
member: s,
|
|
3500
1729
|
operator: "inDateRange",
|
|
3501
1730
|
values: [e, t]
|
|
3502
1731
|
}),
|
|
3503
|
-
set: (
|
|
3504
|
-
notSet: (
|
|
1732
|
+
set: (s) => ({ member: s, operator: "set", values: [] }),
|
|
1733
|
+
notSet: (s) => ({ member: s, operator: "notSet", values: [] })
|
|
3505
1734
|
},
|
|
3506
1735
|
/**
|
|
3507
1736
|
* Create time dimensions
|
|
3508
1737
|
*/
|
|
3509
1738
|
timeDimensions: {
|
|
3510
|
-
create: (
|
|
3511
|
-
dimension:
|
|
1739
|
+
create: (s, e, t) => ({
|
|
1740
|
+
dimension: s,
|
|
3512
1741
|
granularity: e,
|
|
3513
1742
|
dateRange: t
|
|
3514
1743
|
})
|
|
3515
1744
|
}
|
|
3516
1745
|
};
|
|
3517
1746
|
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
|
|
1747
|
+
x as BaseDatabaseExecutor,
|
|
1748
|
+
ie as MultiCubeBuilder,
|
|
1749
|
+
ee as MySQLExecutor,
|
|
1750
|
+
X as PostgresExecutor,
|
|
1751
|
+
$ as QueryExecutor,
|
|
1752
|
+
q as SQLiteExecutor,
|
|
1753
|
+
T as SemanticLayerCompiler,
|
|
1754
|
+
Ae as SemanticLayerUtils,
|
|
1755
|
+
ye as convertCubeReferences,
|
|
1756
|
+
_ as createDatabaseExecutor,
|
|
1757
|
+
Te as createDrizzleSemanticLayer,
|
|
1758
|
+
ne as createMultiCubeContext,
|
|
1759
|
+
te as createMySQLExecutor,
|
|
1760
|
+
S as createPostgresExecutor,
|
|
1761
|
+
M as createSQLiteExecutor,
|
|
1762
|
+
Ee as createSemanticLayer,
|
|
1763
|
+
xe as defaultSemanticLayer,
|
|
1764
|
+
Ne as defineCube,
|
|
1765
|
+
we as defineLegacyCube,
|
|
1766
|
+
pe as loadYamlCubes,
|
|
1767
|
+
De as loadYamlCubesFromFile,
|
|
1768
|
+
re as parseYamlCubes,
|
|
1769
|
+
b as resolveSqlExpression,
|
|
1770
|
+
$e as semanticCubeToYaml,
|
|
1771
|
+
se as semanticLayer,
|
|
1772
|
+
ae as yamlCubeToSemanticCube
|
|
3553
1773
|
};
|