@nongt/visql-core 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,14 +1,14 @@
1
1
  var N = Object.defineProperty;
2
2
  var I = (e, t, r) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var g = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { n as v, q as A, t as B, h as O } from "./schema-dP_ISylQ.js";
5
- import { D as le, E as pe, M as ce, b as ye, f as de, c as fe, i as me, v as he } from "./schema-dP_ISylQ.js";
6
- import { au as D, v as L, av as Q, F as M, $ as U, t as y, al as _, aw as i, ah as j } from "./params-MMOdKWnW.js";
7
- import { M as Se, a as we, b as Ee, d as ge, e as ve, f as Te, g as Ne, c as Ie, h as Ae, k as Be, m as Oe, q as De, i as Le, j as Qe, s as Me, l as Ue, p as _e, n as je, o as qe, u as xe } from "./params-MMOdKWnW.js";
8
- import { c as Re, f as $e, i as ke } from "./calendarDate-CYlr9TvX.js";
9
- import { Q as Fe, l as Je, S as Pe, a as He, n as Xe, f as Ye, j as We, m as Ke, b as Ve, k as ze, r as Ze, c as et, g as tt, h as rt, i as at, s as nt, d as st, e as it, v as ot } from "./issueLocation-BOSdd1JX.js";
10
- import { D as lt, c as pt, S as ct, a as yt, b as dt, s as ft, u as mt } from "./sqlGen-B7-2-i9V.js";
11
- const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T = {
3
+ var E = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { l as T, q as A, t as B, h as O } from "./schema-CgL10bid.js";
5
+ import { D as le, E as pe, M as ce, b as de, f as ye, a as fe, c as me, i as he, r as be, s as Se, v as we } from "./schema-CgL10bid.js";
6
+ import { au as D, t as L, av as Q, F as M, $ as U, p as d, al as _, aw as i, ah as j } from "./params-DkVFbMQn.js";
7
+ import { M as Ee, a as Te, b as ve, d as Ne, e as Ie, f as Ae, g as Be, c as Oe, h as De, k as Le, m as Qe, q as Me, r as Ue, i as _e, s as je, j as qe, o as xe, l as Ce, n as Re, u as $e } from "./params-DkVFbMQn.js";
8
+ import { c as Ge, f as Je, i as Fe } from "./calendarDate-CYlr9TvX.js";
9
+ import { Q as He, l as Xe, S as Ye, a as We, n as Ke, f as Ve, j as ze, m as Ze, b as et, k as tt, r as rt, c as at, g as nt, h as st, i as it, s as ot, d as ut, e as lt, v as pt } from "./issueLocation-BlQ280IE.js";
10
+ import { D as dt, c as yt, S as ft, a as mt, b as ht, s as bt, u as St } from "./sqlGen-C1kZwvWI.js";
11
+ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), v = {
12
12
  /** A column: `expr.field('orders', 'status')`. */
13
13
  field: (e, t) => ({ type: "field", table: e, column: t }),
14
14
  /** A literal value, written into the SQL (as a bound parameter by
@@ -75,7 +75,7 @@ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T =
75
75
  type: "binary",
76
76
  operator: "IN",
77
77
  left: e,
78
- right: Array.isArray(t) ? T.list(...t) : t
78
+ right: Array.isArray(t) ? v.list(...t) : t
79
79
  }),
80
80
  /** `left BETWEEN low AND high` (issue 169), both bounds included: each a
81
81
  * value or an expression (a param, a relative date). NOT BETWEEN:
@@ -84,7 +84,7 @@ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T =
84
84
  type: "binary",
85
85
  operator: "BETWEEN",
86
86
  left: e,
87
- right: T.list(t, r)
87
+ right: v.list(t, r)
88
88
  }),
89
89
  /** IN's values: each a value (`expr.list(1, 2)`) or an expression
90
90
  * (`expr.list(expr.param('a'), expr.param('b'))`). */
@@ -99,8 +99,8 @@ const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), T =
99
99
  * 'customer_id') }))`. */
100
100
  subquery: ({ select: e, ...t }) => ({
101
101
  type: "subquery",
102
- id: v(),
103
- query: { joins: [], ...t, select: [{ id: v(), expression: e }] }
102
+ id: T(),
103
+ query: { joins: [], ...t, select: [{ id: T(), expression: e }] }
104
104
  })
105
105
  };
106
106
  function W(e, t, r) {
@@ -119,7 +119,7 @@ function x(e, t, r, a = {}) {
119
119
  if (s.includes(n.alias))
120
120
  throw new Error("addCondition: a condition names both the union and tables of its branches: add it in two parts");
121
121
  return n.query.union.forEach((l) => {
122
- const m = l.from.table, h = new Set(A(l).map(B)), b = Q(e, m), w = s.find((E) => !h.has(E) && !b.has(E));
122
+ const m = l.from.table, h = new Set(A(l).map(B)), b = Q(e, m), w = s.find((g) => !h.has(g) && !b.has(g));
123
123
  if (w)
124
124
  throw new Error(`addCondition: "${w}" can't be reached from "${m}", one of the union's tables: a condition must reach every branch`);
125
125
  }), n.query.union.reduce((l, m, h) => M(
@@ -129,8 +129,8 @@ function x(e, t, r, a = {}) {
129
129
  ), t);
130
130
  }
131
131
  const u = a.operator ?? "AND", { where: o } = t;
132
- let d;
133
- return o ? o.type === "logical" && o.operator === u ? d = { ...o, operands: [...o.operands, r] } : d = { type: "logical", operator: u, operands: [o, r] } : d = r, y(e, t, _(e, t, d));
132
+ let y;
133
+ return o ? o.type === "logical" && o.operator === u ? y = { ...o, operands: [...o.operands, r] } : y = { type: "logical", operator: u, operands: [o, r] } : y = r, d(e, t, _(e, t, y));
134
134
  }
135
135
  function z(e, t, r, a) {
136
136
  const n = i(e, t, { type: "addSelectItem" }), s = n.select[n.select.length - 1].id, u = i(e, n, {
@@ -138,7 +138,7 @@ function z(e, t, r, a) {
138
138
  selectId: s,
139
139
  expression: r
140
140
  }), o = a === void 0 ? u : i(e, u, { type: "setSelectAlias", selectId: s, alias: a });
141
- return y(e, t, o);
141
+ return d(e, t, o);
142
142
  }
143
143
  function Z(e, t, r) {
144
144
  const a = i(e, t, { type: "addGroupByItem" }), { id: n } = a.groupBy[a.groupBy.length - 1], s = i(e, a, {
@@ -146,10 +146,10 @@ function Z(e, t, r) {
146
146
  groupById: n,
147
147
  expression: r
148
148
  });
149
- return y(e, t, s);
149
+ return d(e, t, s);
150
150
  }
151
151
  function ee(e, t, r) {
152
- return y(e, t, j(e, t, r));
152
+ return d(e, t, j(e, t, r));
153
153
  }
154
154
  function te(e, t, r, a = "asc") {
155
155
  const n = i(e, t, { type: "addOrderByItem" }), { id: s } = n.orderBy[n.orderBy.length - 1], u = i(e, n, {
@@ -161,7 +161,7 @@ function te(e, t, r, a = "asc") {
161
161
  orderById: s,
162
162
  direction: a
163
163
  });
164
- return y(e, t, o);
164
+ return d(e, t, o);
165
165
  }
166
166
  function re(e, t, r) {
167
167
  let a = t;
@@ -178,7 +178,7 @@ const S = 4;
178
178
  class p extends Error {
179
179
  constructor(r, a) {
180
180
  super(a);
181
- g(this, "kind");
181
+ E(this, "kind");
182
182
  this.name = "QueryFormatError", this.kind = r;
183
183
  }
184
184
  }
@@ -214,13 +214,13 @@ function R(e) {
214
214
  return t(e);
215
215
  }
216
216
  const $ = (e) => e, k = (e) => e, G = [R, $, k];
217
- function F(e, t, r) {
217
+ function J(e, t, r) {
218
218
  return r.slice(t - 1).reduce((a, n) => n(a), e);
219
219
  }
220
220
  function f(e, t) {
221
221
  return Array.isArray(e) ? e.map((r) => f(r, t)) : c(e) ? e.type === "literal" ? t(e) : Object.fromEntries(Object.entries(e).map(([r, a]) => [r, f(a, t)])) : e;
222
222
  }
223
- function J(e) {
223
+ function F(e) {
224
224
  return e.value instanceof Date ? { ...e, value: e.value.toISOString(), valueType: "date" } : typeof e.value == "bigint" ? { ...e, value: String(e.value), valueType: "bigint" } : e;
225
225
  }
226
226
  function P(e) {
@@ -241,7 +241,7 @@ function P(e) {
241
241
  function se(e) {
242
242
  return {
243
243
  version: S,
244
- query: f(e, J)
244
+ query: f(e, F)
245
245
  };
246
246
  }
247
247
  function ie(e) {
@@ -255,84 +255,87 @@ function ie(e) {
255
255
  "newerVersion",
256
256
  `stored in format ${t}; this version reads up to ${S}`
257
257
  );
258
- const r = F(e.query, t, G);
258
+ const r = J(e.query, t, G);
259
259
  if (!c(r) || typeof r.id != "string")
260
260
  throw new p("invalid", "a stored query has a query with a string id");
261
261
  return f(r, P);
262
262
  }
263
263
  export {
264
264
  le as DEFAULT_FUNCTIONS,
265
- lt as DIALECTS,
266
- pt as DIALECT_LABELS,
265
+ dt as DIALECTS,
266
+ yt as DIALECT_LABELS,
267
267
  pe as EMPTY_SCHEMA,
268
268
  ce as MAX_NAME_LENGTH,
269
- Se as MAX_NUMBER_DIGITS,
270
- we as MAX_TEXT_LENGTH,
271
- Ee as MAX_TYPE_NAME_LENGTH,
269
+ Ee as MAX_NUMBER_DIGITS,
270
+ Te as MAX_TEXT_LENGTH,
271
+ ve as MAX_TYPE_NAME_LENGTH,
272
272
  S as QUERY_FORMAT_VERSION,
273
- Fe as QUERY_ISSUE_KINDS,
274
- Je as QUERY_WARNING_KINDS,
273
+ He as QUERY_ISSUE_KINDS,
274
+ Xe as QUERY_WARNING_KINDS,
275
275
  p as QueryFormatError,
276
- ct as ScopeError,
277
- Pe as SharedBaseError,
276
+ ft as ScopeError,
277
+ Ye as SharedBaseError,
278
278
  x as addCondition,
279
279
  Z as addGroupBy,
280
280
  K as addJoin,
281
- ge as addMeasure,
281
+ Ne as addMeasure,
282
282
  te as addOrderBy,
283
283
  z as addSelectItem,
284
- He as addSharedQuery,
285
- ve as addUnionBranch,
286
- Te as addUnionJoin,
287
- Ne as addUnionTable,
288
- yt as astToParameterizedSql,
289
- dt as astToSql,
290
- ye as branchesOf,
291
- Re as calendarDay,
292
- Ie as createEmptyQuery,
293
- Ae as createUnion,
294
- T as expr,
295
- de as filterSchema,
296
- $e as fromIsoDay,
297
- fe as functionsForDialect,
284
+ We as addSharedQuery,
285
+ Ie as addUnionBranch,
286
+ Ae as addUnionJoin,
287
+ Be as addUnionTable,
288
+ mt as astToParameterizedSql,
289
+ ht as astToSql,
290
+ de as branchesOf,
291
+ Ge as calendarDay,
292
+ Oe as createEmptyQuery,
293
+ De as createUnion,
294
+ v as expr,
295
+ ye as filterSchema,
296
+ fe as findJoinPath,
297
+ Je as fromIsoDay,
298
+ me as functionsForDialect,
298
299
  O as hasBaseTable,
299
- me as isUnion,
300
- ke as isoDay,
301
- Xe as issueLocation,
302
- Ye as joinMultiplicity,
303
- We as joinSharedQuery,
304
- Be as keepMeasuresInStep,
300
+ he as isUnion,
301
+ Fe as isoDay,
302
+ Ke as issueLocation,
303
+ Ve as joinMultiplicity,
304
+ ze as joinSharedQuery,
305
+ Le as keepMeasuresInStep,
305
306
  ie as loadQuery,
306
- Ke as makeShared,
307
- Ve as makeSubQuery,
308
- Oe as measureFacts,
309
- De as queryParams,
310
- ze as relativeDateLabel,
307
+ Ze as makeShared,
308
+ et as makeSubQuery,
309
+ Qe as measureFacts,
310
+ Me as queryParams,
311
+ be as reachableTables,
312
+ tt as relativeDateLabel,
311
313
  V as removeJoin,
312
- Ze as removeSharedQuery,
313
- Le as removeUnionTable,
314
- et as renameSharedQuery,
315
- Qe as renameUnionColumn,
316
- tt as repeatedReads,
317
- rt as repeatedTables,
314
+ rt as removeSharedQuery,
315
+ Ue as removeUnionTable,
316
+ at as renameSharedQuery,
317
+ _e as renameUnionColumn,
318
+ nt as repeatedReads,
319
+ st as repeatedTables,
318
320
  ne as requireBaseTable,
319
- at as rowsPerBase,
321
+ it as rowsPerBase,
320
322
  se as saveQuery,
321
- ft as scopeQuery,
323
+ bt as scopeQuery,
322
324
  W as setBaseTable,
323
325
  ae as setDistinct,
324
326
  ee as setHaving,
325
327
  re as setPaging,
326
- nt as setSharedBase,
327
- Me as setUnionAll,
328
- st as sharedQueryName,
329
- it as sharedUses,
330
- Ue as unionName,
331
- _e as unionTableColumns,
332
- je as unionWithQuery,
333
- qe as unionableTables,
334
- mt as unscopedBodies,
335
- xe as unwrapUnion,
336
- ot as validateQuery,
337
- he as validateSchema
328
+ ot as setSharedBase,
329
+ je as setUnionAll,
330
+ ut as sharedQueryName,
331
+ lt as sharedUses,
332
+ Se as suggestJoin,
333
+ qe as unionName,
334
+ xe as unionTableColumns,
335
+ Ce as unionWithQuery,
336
+ Re as unionableTables,
337
+ St as unscopedBodies,
338
+ $e as unwrapUnion,
339
+ pt as validateQuery,
340
+ we as validateSchema
338
341
  };