drizzle-cube 0.2.17 → 0.2.18
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 +19 -20
- package/dist/adapters/compiler-A8IN32GM.cjs +22 -0
- package/dist/adapters/{compiler-SWjBOq5Q.js → compiler-Cwmfwbls.js} +422 -421
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +55 -54
- package/package.json +1 -1
- package/dist/adapters/compiler-5xl2RLGE.cjs +0 -22
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as n, eq as g, and as B, SQL as qT, gte as
|
|
1
|
+
import { sql as n, eq as g, and as B, SQL as qT, gte as v, lte as x, arrayContained as zT, arrayOverlaps as Ee, arrayContains as Te, isNotNull as JE, ne as vE, or as k, isNull as xE, notInArray as QE, inArray as IE, lt as sE, gt as nE, StringChunk as ee, sum as V, max as q, min as z, count as VE, countDistinct as Re, desc as Ae, asc as ZE } from "drizzle-orm";
|
|
2
2
|
class yE {
|
|
3
3
|
/**
|
|
4
4
|
* Default implementation returns template unchanged
|
|
@@ -1061,8 +1061,8 @@ class ie {
|
|
|
1061
1061
|
t.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? A = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(t.getTime() / 1e3) : t.getTime() : A = t.toISOString();
|
|
1062
1062
|
}
|
|
1063
1063
|
return B(
|
|
1064
|
-
|
|
1065
|
-
|
|
1064
|
+
v(E, R),
|
|
1065
|
+
x(E, A)
|
|
1066
1066
|
);
|
|
1067
1067
|
}
|
|
1068
1068
|
if (typeof T == "string") {
|
|
@@ -1070,8 +1070,8 @@ class ie {
|
|
|
1070
1070
|
if (R) {
|
|
1071
1071
|
let s, O;
|
|
1072
1072
|
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(R.start.getTime() / 1e3), O = Math.floor(R.end.getTime() / 1e3)) : (s = R.start.getTime(), O = R.end.getTime()) : (s = R.start.toISOString(), O = R.end.toISOString()), B(
|
|
1073
|
-
|
|
1074
|
-
|
|
1073
|
+
v(E, s),
|
|
1074
|
+
x(E, O)
|
|
1075
1075
|
);
|
|
1076
1076
|
}
|
|
1077
1077
|
const A = this.normalizeDate(T);
|
|
@@ -1082,8 +1082,8 @@ class ie {
|
|
|
1082
1082
|
I.setUTCHours(23, 59, 59, 999);
|
|
1083
1083
|
let C, N;
|
|
1084
1084
|
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(t.getTime() / 1e3), N = Math.floor(I.getTime() / 1e3)) : (C = t.getTime(), N = I.getTime()) : (C = t.toISOString(), N = I.toISOString()), B(
|
|
1085
|
-
|
|
1086
|
-
|
|
1085
|
+
v(E, C),
|
|
1086
|
+
x(E, N)
|
|
1087
1087
|
);
|
|
1088
1088
|
}
|
|
1089
1089
|
return null;
|
|
@@ -1236,7 +1236,7 @@ class ae {
|
|
|
1236
1236
|
}
|
|
1237
1237
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
1238
1238
|
case "notEquals":
|
|
1239
|
-
return t.length > 1 ? QE(E, t) : t.length === 1 ?
|
|
1239
|
+
return t.length > 1 ? QE(E, t) : t.length === 1 ? vE(E, I) : null;
|
|
1240
1240
|
case "contains":
|
|
1241
1241
|
return this.databaseAdapter.buildStringCondition(E, "contains", I);
|
|
1242
1242
|
case "notContains":
|
|
@@ -1248,15 +1248,15 @@ class ae {
|
|
|
1248
1248
|
case "gt":
|
|
1249
1249
|
return nE(E, I);
|
|
1250
1250
|
case "gte":
|
|
1251
|
-
return
|
|
1251
|
+
return v(E, I);
|
|
1252
1252
|
case "lt":
|
|
1253
1253
|
return sE(E, I);
|
|
1254
1254
|
case "lte":
|
|
1255
|
-
return
|
|
1255
|
+
return x(E, I);
|
|
1256
1256
|
case "set":
|
|
1257
1257
|
return JE(E);
|
|
1258
1258
|
case "notSet":
|
|
1259
|
-
return
|
|
1259
|
+
return xE(E);
|
|
1260
1260
|
case "inDateRange":
|
|
1261
1261
|
if (t.length >= 2) {
|
|
1262
1262
|
const C = this.dateTimeBuilder.normalizeDate(t[0]);
|
|
@@ -1268,8 +1268,8 @@ class ae {
|
|
|
1268
1268
|
r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? N = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : N = r.toISOString();
|
|
1269
1269
|
}
|
|
1270
1270
|
return B(
|
|
1271
|
-
|
|
1272
|
-
|
|
1271
|
+
v(E, C),
|
|
1272
|
+
x(E, N)
|
|
1273
1273
|
);
|
|
1274
1274
|
}
|
|
1275
1275
|
}
|
|
@@ -1284,8 +1284,8 @@ class ae {
|
|
|
1284
1284
|
}
|
|
1285
1285
|
case "between":
|
|
1286
1286
|
return t.length >= 2 ? B(
|
|
1287
|
-
|
|
1288
|
-
|
|
1287
|
+
v(E, t[0]),
|
|
1288
|
+
x(E, t[1])
|
|
1289
1289
|
) : null;
|
|
1290
1290
|
case "notBetween":
|
|
1291
1291
|
return t.length >= 2 ? k(
|
|
@@ -1308,13 +1308,13 @@ class ae {
|
|
|
1308
1308
|
return this.databaseAdapter.buildStringCondition(E, "notRegex", I);
|
|
1309
1309
|
case "isEmpty":
|
|
1310
1310
|
return k(
|
|
1311
|
-
|
|
1311
|
+
xE(E),
|
|
1312
1312
|
g(E, "")
|
|
1313
1313
|
);
|
|
1314
1314
|
case "isNotEmpty":
|
|
1315
1315
|
return B(
|
|
1316
1316
|
JE(E),
|
|
1317
|
-
|
|
1317
|
+
vE(E, "")
|
|
1318
1318
|
);
|
|
1319
1319
|
// PostgreSQL array operators - silent no-op for other databases
|
|
1320
1320
|
// These use Drizzle's built-in array operator functions
|
|
@@ -3483,20 +3483,21 @@ class CE {
|
|
|
3483
3483
|
* detect cubes that may leak data across tenants.
|
|
3484
3484
|
*/
|
|
3485
3485
|
validateSecurityContext(E, T) {
|
|
3486
|
-
|
|
3486
|
+
const R = typeof process < "u" ? process.env?.NODE_ENV : void 0, A = typeof process < "u" ? process.env?.DRIZZLE_CUBE_WARN_SECURITY : void 0;
|
|
3487
|
+
if (R !== "development" && !A)
|
|
3487
3488
|
return;
|
|
3488
|
-
const
|
|
3489
|
-
for (const
|
|
3490
|
-
|
|
3491
|
-
for (const
|
|
3492
|
-
|
|
3493
|
-
const
|
|
3494
|
-
for (const
|
|
3495
|
-
if (!
|
|
3496
|
-
|
|
3489
|
+
const S = [E.primaryCube];
|
|
3490
|
+
for (const I of E.joinCubes || [])
|
|
3491
|
+
S.push(I.cube);
|
|
3492
|
+
for (const I of E.preAggregationCTEs || [])
|
|
3493
|
+
S.push(I.cube);
|
|
3494
|
+
const t = /* @__PURE__ */ new Set();
|
|
3495
|
+
for (const I of S)
|
|
3496
|
+
if (!t.has(I.name)) {
|
|
3497
|
+
t.add(I.name);
|
|
3497
3498
|
try {
|
|
3498
|
-
|
|
3499
|
-
`[drizzle-cube] WARNING: Cube '${
|
|
3499
|
+
I.sql(T).where || console.warn(
|
|
3500
|
+
`[drizzle-cube] WARNING: Cube '${I.name}' may not have proper security filtering. The sql() function returned no 'where' clause. Ensure it returns a filter like: { from: table, where: eq(table.organisationId, ctx.securityContext.organisationId) }`
|
|
3500
3501
|
);
|
|
3501
3502
|
} catch {
|
|
3502
3503
|
}
|
|
@@ -4713,11 +4714,11 @@ const VT = (e) => ({
|
|
|
4713
4714
|
"ASSERT",
|
|
4714
4715
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
4715
4716
|
"EXPORT DATA"
|
|
4716
|
-
]),
|
|
4717
|
+
]), ve = i([
|
|
4717
4718
|
"UNION {ALL | DISTINCT}",
|
|
4718
4719
|
"EXCEPT DISTINCT",
|
|
4719
4720
|
"INTERSECT DISTINCT"
|
|
4720
|
-
]),
|
|
4721
|
+
]), xe = i([
|
|
4721
4722
|
"JOIN",
|
|
4722
4723
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4723
4724
|
"{INNER | CROSS} JOIN"
|
|
@@ -4737,8 +4738,8 @@ const VT = (e) => ({
|
|
|
4737
4738
|
tokenizerOptions: {
|
|
4738
4739
|
reservedSelect: we,
|
|
4739
4740
|
reservedClauses: [...Je, ...LE, ...ET],
|
|
4740
|
-
reservedSetOperations:
|
|
4741
|
-
reservedJoins:
|
|
4741
|
+
reservedSetOperations: ve,
|
|
4742
|
+
reservedJoins: xe,
|
|
4742
4743
|
reservedKeywordPhrases: Qe,
|
|
4743
4744
|
reservedDataTypePhrases: Ze,
|
|
4744
4745
|
reservedKeywords: $e,
|
|
@@ -9055,7 +9056,7 @@ const $R = [
|
|
|
9055
9056
|
// CASE expression shorthands
|
|
9056
9057
|
"COALESCE",
|
|
9057
9058
|
"NULLIF"
|
|
9058
|
-
], JR = i(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),
|
|
9059
|
+
], JR = i(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), vR = i([
|
|
9059
9060
|
// queries
|
|
9060
9061
|
"WITH [RECURSIVE]",
|
|
9061
9062
|
"FROM",
|
|
@@ -9286,7 +9287,7 @@ const $R = [
|
|
|
9286
9287
|
"XA RECOVER",
|
|
9287
9288
|
"XA ROLLBACK",
|
|
9288
9289
|
"XA START"
|
|
9289
|
-
]),
|
|
9290
|
+
]), xR = i([
|
|
9290
9291
|
"UNION [ALL | DISTINCT]",
|
|
9291
9292
|
"EXCEPT [ALL | DISTINCT]",
|
|
9292
9293
|
"INTERSECT [ALL | DISTINCT]",
|
|
@@ -9308,8 +9309,8 @@ const $R = [
|
|
|
9308
9309
|
name: "mariadb",
|
|
9309
9310
|
tokenizerOptions: {
|
|
9310
9311
|
reservedSelect: JR,
|
|
9311
|
-
reservedClauses: [...
|
|
9312
|
-
reservedSetOperations:
|
|
9312
|
+
reservedClauses: [...vR, ...tT, ...DE],
|
|
9313
|
+
reservedSetOperations: xR,
|
|
9313
9314
|
reservedJoins: QR,
|
|
9314
9315
|
reservedKeywordPhrases: ZR,
|
|
9315
9316
|
reservedDataTypePhrases: jR,
|
|
@@ -13430,7 +13431,7 @@ const XA = [
|
|
|
13430
13431
|
"{INNER | CROSS} JOIN",
|
|
13431
13432
|
"NATURAL [INNER] JOIN",
|
|
13432
13433
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13433
|
-
]),
|
|
13434
|
+
]), vA = i([
|
|
13434
13435
|
"PRIMARY KEY",
|
|
13435
13436
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
13436
13437
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -13441,7 +13442,7 @@ const XA = [
|
|
|
13441
13442
|
"IS [NOT] DISTINCT FROM",
|
|
13442
13443
|
"NULLS {FIRST | LAST}",
|
|
13443
13444
|
"WITH ORDINALITY"
|
|
13444
|
-
]),
|
|
13445
|
+
]), xA = i([
|
|
13445
13446
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
13446
13447
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
13447
13448
|
]), QA = {
|
|
@@ -13451,8 +13452,8 @@ const XA = [
|
|
|
13451
13452
|
reservedClauses: [...KA, ...nT, ...cE],
|
|
13452
13453
|
reservedSetOperations: wA,
|
|
13453
13454
|
reservedJoins: JA,
|
|
13454
|
-
reservedKeywordPhrases:
|
|
13455
|
-
reservedDataTypePhrases:
|
|
13455
|
+
reservedKeywordPhrases: vA,
|
|
13456
|
+
reservedDataTypePhrases: xA,
|
|
13456
13457
|
reservedKeywords: gA,
|
|
13457
13458
|
reservedDataTypes: yA,
|
|
13458
13459
|
reservedFunctionNames: XA,
|
|
@@ -16687,7 +16688,7 @@ const iS = [
|
|
|
16687
16688
|
onelineClauses: [...iT, ...mE],
|
|
16688
16689
|
tabularOnelineClauses: mE
|
|
16689
16690
|
}
|
|
16690
|
-
},
|
|
16691
|
+
}, vS = [
|
|
16691
16692
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
16692
16693
|
// aggregate
|
|
16693
16694
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -16992,7 +16993,7 @@ const iS = [
|
|
|
16992
16993
|
// Shorthand functions to use in place of CASE expression
|
|
16993
16994
|
"COALESCE",
|
|
16994
16995
|
"NULLIF"
|
|
16995
|
-
],
|
|
16996
|
+
], xS = [
|
|
16996
16997
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
16997
16998
|
// standard
|
|
16998
16999
|
"ADD",
|
|
@@ -17423,9 +17424,9 @@ const iS = [
|
|
|
17423
17424
|
reservedJoins: qS,
|
|
17424
17425
|
reservedKeywordPhrases: zS,
|
|
17425
17426
|
reservedDataTypePhrases: Et,
|
|
17426
|
-
reservedKeywords:
|
|
17427
|
+
reservedKeywords: xS,
|
|
17427
17428
|
reservedDataTypes: QS,
|
|
17428
|
-
reservedFunctionNames:
|
|
17429
|
+
reservedFunctionNames: vS,
|
|
17429
17430
|
nestedBlockComments: !0,
|
|
17430
17431
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
17431
17432
|
identTypes: ['""-qq', "[]"],
|
|
@@ -20065,10 +20066,10 @@ function Kt() {
|
|
|
20065
20066
|
}
|
|
20066
20067
|
var wt = Kt();
|
|
20067
20068
|
const Jt = /* @__PURE__ */ yt(wt);
|
|
20068
|
-
function
|
|
20069
|
-
return e.map(
|
|
20069
|
+
function vt(e) {
|
|
20070
|
+
return e.map(xt).map(Qt).map(Zt).map(jt).map(kt);
|
|
20070
20071
|
}
|
|
20071
|
-
const
|
|
20072
|
+
const xt = (e, E, T) => {
|
|
20072
20073
|
if (bT(e.type)) {
|
|
20073
20074
|
const R = qt(T, E);
|
|
20074
20075
|
if (R && R.type === o.PROPERTY_ACCESS_OPERATOR)
|
|
@@ -20559,7 +20560,7 @@ const G = new JT((e) => []), W = ([[e]]) => e, F = (e) => ({
|
|
|
20559
20560
|
function AN(e) {
|
|
20560
20561
|
let E = {};
|
|
20561
20562
|
const T = new JT((A) => [
|
|
20562
|
-
...
|
|
20563
|
+
...vt(e.tokenize(A, E)),
|
|
20563
20564
|
VT(A.length)
|
|
20564
20565
|
]), R = new eN(RN.fromCompiled(TN), { lexer: T });
|
|
20565
20566
|
return {
|
|
@@ -20577,7 +20578,7 @@ var a;
|
|
|
20577
20578
|
(function(e) {
|
|
20578
20579
|
e[e.SPACE = 0] = "SPACE", e[e.NO_SPACE = 1] = "NO_SPACE", e[e.NO_NEWLINE = 2] = "NO_NEWLINE", e[e.NEWLINE = 3] = "NEWLINE", e[e.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", e[e.INDENT = 5] = "INDENT", e[e.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
20579
20580
|
})(a = a || (a = {}));
|
|
20580
|
-
class
|
|
20581
|
+
class vT {
|
|
20581
20582
|
constructor(E) {
|
|
20582
20583
|
this.indentation = E, this.items = [];
|
|
20583
20584
|
}
|
|
@@ -20675,7 +20676,7 @@ function HT(e) {
|
|
|
20675
20676
|
return ge(e) || e === o.RESERVED_CLAUSE || e === o.RESERVED_SELECT || e === o.RESERVED_SET_OPERATION || e === o.RESERVED_JOIN || e === o.LIMIT;
|
|
20676
20677
|
}
|
|
20677
20678
|
const YE = "top-level", NN = "block-level";
|
|
20678
|
-
class
|
|
20679
|
+
class xT {
|
|
20679
20680
|
/**
|
|
20680
20681
|
* @param {string} indent A string to indent with
|
|
20681
20682
|
*/
|
|
@@ -20723,9 +20724,9 @@ class vT {
|
|
|
20723
20724
|
;
|
|
20724
20725
|
}
|
|
20725
20726
|
}
|
|
20726
|
-
class ON extends
|
|
20727
|
+
class ON extends vT {
|
|
20727
20728
|
constructor(E) {
|
|
20728
|
-
super(new
|
|
20729
|
+
super(new xT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
20729
20730
|
}
|
|
20730
20731
|
add(...E) {
|
|
20731
20732
|
if (E.forEach((T) => this.addToLength(T)), this.length > this.expressionWidth)
|
|
@@ -21078,7 +21079,7 @@ class IN {
|
|
|
21078
21079
|
cfg: this.cfg,
|
|
21079
21080
|
dialectCfg: this.dialect.formatOptions,
|
|
21080
21081
|
params: this.params,
|
|
21081
|
-
layout: new
|
|
21082
|
+
layout: new vT(new xT(Xt(this.cfg)))
|
|
21082
21083
|
}).format(E.children);
|
|
21083
21084
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(a.NEWLINE, ";") : T.add(a.NO_NEWLINE, ";")), T.toString();
|
|
21084
21085
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-cube",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.",
|
|
5
5
|
"main": "./dist/server/index.js",
|
|
6
6
|
"types": "./dist/server/index.d.ts",
|