yamchart 0.9.5 → 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.
Files changed (92) hide show
  1. package/dist/{advisor-SC64RTZO.js → advisor-5TJDNAY7.js} +24 -14
  2. package/dist/advisor-5TJDNAY7.js.map +1 -0
  3. package/dist/agent-TZZHNDPK.js +1 -0
  4. package/dist/{chunk-NXQ6ZO3V.js → chunk-5FHV22X2.js} +7 -6
  5. package/dist/chunk-5FHV22X2.js.map +1 -0
  6. package/dist/{dist-MNXSMGV6.js → chunk-64CI3HSY.js} +184 -15
  7. package/dist/chunk-64CI3HSY.js.map +1 -0
  8. package/dist/chunk-7D4SUZUM.js +1 -0
  9. package/dist/chunk-DZVT6PHW.js +1 -0
  10. package/dist/chunk-EAQXUGP6.js +1 -0
  11. package/dist/chunk-HJVVHYVN.js +1 -0
  12. package/dist/chunk-IVD4OP3K.js +1 -0
  13. package/dist/{chunk-S7YQXEKM.js → chunk-QUIDZO5G.js} +104 -275
  14. package/dist/chunk-QUIDZO5G.js.map +1 -0
  15. package/dist/{chunk-RMIDEBHD.js → chunk-S2CH4HUZ.js} +7 -6
  16. package/dist/chunk-TZKNU5TD.js +1 -0
  17. package/dist/chunk-UFDQ3C7Q.js +919 -0
  18. package/dist/chunk-UFDQ3C7Q.js.map +1 -0
  19. package/dist/chunk-VJC24RKT.js +1 -0
  20. package/dist/chunk-WYS4ULBE.js +1 -0
  21. package/dist/{chunk-H4L3FNLS.js → chunk-ZBCQNWVN.js} +3 -2
  22. package/dist/{chunk-RM6MNDVF.js → chunk-ZIY22VO7.js} +193 -11
  23. package/dist/chunk-ZIY22VO7.js.map +1 -0
  24. package/dist/chunk-ZMJPRNOA.js +1 -0
  25. package/dist/compare-RQFCEZIK.js +1 -0
  26. package/dist/connection-utils-FEUWER5I.js +20 -0
  27. package/dist/{describe-X75C2VDU.js → describe-MEP72B56.js} +7 -6
  28. package/dist/{dev-GWXHBBWB.js → dev-H6SJZ5UA.js} +1315 -73
  29. package/dist/dev-H6SJZ5UA.js.map +1 -0
  30. package/dist/dist-5DQO6L2S.js +48 -0
  31. package/dist/dist-MIKFZKSD.js +1 -0
  32. package/dist/dist-PPAD6KOM.js +99 -0
  33. package/dist/{dist-JMLAZUL7.js → dist-XNCED7JW.js} +30 -12
  34. package/dist/generate-B7FAWVIQ.js +1 -0
  35. package/dist/index.js +25 -24
  36. package/dist/init-SECXKD5G.js +1 -0
  37. package/dist/lineage-HYO4RKZT.js +1 -0
  38. package/dist/public/assets/DataView-DUCz_96y.js +9 -0
  39. package/dist/public/assets/{EventManagement-CTuAJ0eF.js → EventManagement-BnmeJDQl.js} +1 -1
  40. package/dist/public/assets/{ExplorePage-ZJ3zNjNQ.js → ExplorePage-kk4z9ldZ.js} +1 -1
  41. package/dist/public/assets/{LoginPage-wygea4BI.js → LoginPage-CzaFkkjg.js} +1 -1
  42. package/dist/public/assets/{PublicViewer-8YqGrVVB.js → PublicViewer-irjxqH6a.js} +1 -1
  43. package/dist/public/assets/{SetupWizard-DqDBwHrF.js → SetupWizard-ConWIcmy.js} +1 -1
  44. package/dist/public/assets/{ShareManagement-TAAdI_gY.js → ShareManagement-CP4wdwLR.js} +1 -1
  45. package/dist/public/assets/SourceDetailView-DZS5518E.js +1 -0
  46. package/dist/public/assets/{UserManagement-B4kZHyri.js → UserManagement-AubGd9hl.js} +1 -1
  47. package/dist/public/assets/data-3vtzSuAZ.js +1 -0
  48. package/dist/public/assets/{index-CfyF2Wf-.css → index-C1X8RW4Z.css} +1 -1
  49. package/dist/public/assets/{index-BgzSjgIu.js → index-jlfTO7f5.js} +44 -44
  50. package/dist/public/assets/{index.es-AB-GdGyc.js → index.es-CgnvEWi5.js} +1 -1
  51. package/dist/public/assets/{jspdf.es.min-ChRx2mOQ.js → jspdf.es.min-Cw5WefMt.js} +3 -3
  52. package/dist/public/index.html +2 -2
  53. package/dist/{query-QNRDS74I.js → query-2H3YOPI2.js} +6 -5
  54. package/dist/reset-password-YVCZKZPC.js +1 -0
  55. package/dist/rewrite-database-BOA4QPUR.js +1 -0
  56. package/dist/{sample-SKLHBZBU.js → sample-ODUGGSFA.js} +6 -5
  57. package/dist/{search-4KMETZVX.js → search-IPE4ISFB.js} +7 -6
  58. package/dist/{semantic-6WKELH5V.js → semantic-K3MYXXJI.js} +4 -2
  59. package/dist/{semantic-6WKELH5V.js.map → semantic-K3MYXXJI.js.map} +1 -1
  60. package/dist/source-resolver-HZQLOODU.js +19 -0
  61. package/dist/source-resolver-HZQLOODU.js.map +1 -0
  62. package/dist/sync-dbt-72GVO75P.js +1 -0
  63. package/dist/{sync-warehouse-UWRNUXE7.js → sync-warehouse-TUNULDUY.js} +6 -5
  64. package/dist/{tables-V65QUGHK.js → tables-K5NAN2WK.js} +7 -6
  65. package/dist/templates/default/docs/yamchart-reference.md +42 -0
  66. package/dist/{test-UE5OWG3E.js → test-SRHVOXZB.js} +9 -7
  67. package/dist/{test-UE5OWG3E.js.map → test-SRHVOXZB.js.map} +1 -1
  68. package/dist/update-HWCJNQRP.js +1 -0
  69. package/package.json +8 -6
  70. package/dist/advisor-SC64RTZO.js.map +0 -1
  71. package/dist/chunk-NXQ6ZO3V.js.map +0 -1
  72. package/dist/chunk-RM6MNDVF.js.map +0 -1
  73. package/dist/chunk-S7YQXEKM.js.map +0 -1
  74. package/dist/chunk-UND73EOB.js +0 -449
  75. package/dist/chunk-UND73EOB.js.map +0 -1
  76. package/dist/connection-utils-C4FQGBW6.js +0 -19
  77. package/dist/dev-GWXHBBWB.js.map +0 -1
  78. package/dist/dist-MNXSMGV6.js.map +0 -1
  79. package/dist/dist-MX5K2ABB.js +0 -56
  80. package/dist/source-resolver-R7WBIL7M.js +0 -18
  81. /package/dist/{chunk-RMIDEBHD.js.map → chunk-S2CH4HUZ.js.map} +0 -0
  82. /package/dist/{chunk-H4L3FNLS.js.map → chunk-ZBCQNWVN.js.map} +0 -0
  83. /package/dist/{connection-utils-C4FQGBW6.js.map → connection-utils-FEUWER5I.js.map} +0 -0
  84. /package/dist/{describe-X75C2VDU.js.map → describe-MEP72B56.js.map} +0 -0
  85. /package/dist/{dist-JMLAZUL7.js.map → dist-5DQO6L2S.js.map} +0 -0
  86. /package/dist/{dist-MX5K2ABB.js.map → dist-PPAD6KOM.js.map} +0 -0
  87. /package/dist/{source-resolver-R7WBIL7M.js.map → dist-XNCED7JW.js.map} +0 -0
  88. /package/dist/{query-QNRDS74I.js.map → query-2H3YOPI2.js.map} +0 -0
  89. /package/dist/{sample-SKLHBZBU.js.map → sample-ODUGGSFA.js.map} +0 -0
  90. /package/dist/{search-4KMETZVX.js.map → search-IPE4ISFB.js.map} +0 -0
  91. /package/dist/{sync-warehouse-UWRNUXE7.js.map → sync-warehouse-TUNULDUY.js.map} +0 -0
  92. /package/dist/{tables-V65QUGHK.js.map → tables-K5NAN2WK.js.map} +0 -0
@@ -1,3 +1,4 @@
1
+ import { createRequire as __yamchartCreateRequire } from 'module'; if (!globalThis.require) globalThis.require = __yamchartCreateRequire(import.meta.url);
1
2
  // src/dbt/rewrite-database.ts
2
3
  function extractDatabase(tablePath) {
3
4
  if (!tablePath) return null;
@@ -1,3 +1,13 @@
1
+ import { createRequire as __yamchartCreateRequire } from 'module'; if (!globalThis.require) globalThis.require = __yamchartCreateRequire(import.meta.url);
2
+ import {
3
+ expandCustomDateRange,
4
+ expandDatePreset,
5
+ expandRelativeDateRange,
6
+ getDialect,
7
+ isCustomDateRange,
8
+ isDatePreset,
9
+ isRelativeDateRange
10
+ } from "./chunk-UFDQ3C7Q.js";
1
11
  import {
2
12
  __require
3
13
  } from "./chunk-7D4SUZUM.js";
@@ -123,261 +133,6 @@ function parseReturnColumn(input) {
123
133
  return col;
124
134
  }
125
135
 
126
- // ../../packages/query/dist/presets.js
127
- import { subDays, subWeeks, subMonths, subYears, subQuarters, addDays, addWeeks, addMonths, addYears, addQuarters, startOfDay, startOfWeek, startOfYear, startOfMonth, startOfQuarter, endOfWeek, endOfMonth, endOfQuarter, endOfYear, differenceInDays, parseISO, format } from "date-fns";
128
- function isCustomDateRange(value) {
129
- return typeof value === "object" && value !== null && "type" in value && value.type === "custom" && "start" in value && "end" in value;
130
- }
131
- function expandCustomDateRange(range) {
132
- return {
133
- start_date: range.start,
134
- end_date: range.end
135
- };
136
- }
137
- var DATE_PRESETS = [
138
- "today",
139
- "yesterday",
140
- "last_7_days",
141
- "last_30_days",
142
- "last_90_days",
143
- "last_12_months",
144
- "year_to_date",
145
- "month_to_date",
146
- "quarter_to_date",
147
- "previous_month",
148
- "previous_quarter",
149
- "previous_year"
150
- ];
151
- var DATE_FORMAT = "yyyy-MM-dd";
152
- function formatDate(date) {
153
- return format(date, DATE_FORMAT);
154
- }
155
- function expandDatePreset(preset) {
156
- const now = /* @__PURE__ */ new Date();
157
- const today = formatDate(now);
158
- switch (preset) {
159
- case "today":
160
- return {
161
- start_date: today,
162
- end_date: today
163
- };
164
- case "yesterday": {
165
- const yesterday = formatDate(subDays(now, 1));
166
- return {
167
- start_date: yesterday,
168
- end_date: yesterday
169
- };
170
- }
171
- case "last_7_days": {
172
- const yesterday = formatDate(subDays(now, 1));
173
- return {
174
- start_date: formatDate(subDays(now, 7)),
175
- end_date: yesterday
176
- };
177
- }
178
- case "last_30_days": {
179
- const yesterday = formatDate(subDays(now, 1));
180
- return {
181
- start_date: formatDate(subDays(now, 30)),
182
- end_date: yesterday
183
- };
184
- }
185
- case "last_90_days": {
186
- const yesterday = formatDate(subDays(now, 1));
187
- return {
188
- start_date: formatDate(subDays(now, 90)),
189
- end_date: yesterday
190
- };
191
- }
192
- case "last_12_months": {
193
- const yesterday = formatDate(subDays(now, 1));
194
- return {
195
- start_date: formatDate(subMonths(now, 12)),
196
- end_date: yesterday
197
- };
198
- }
199
- case "year_to_date":
200
- return {
201
- start_date: formatDate(startOfYear(now)),
202
- end_date: today
203
- };
204
- case "month_to_date":
205
- return {
206
- start_date: formatDate(startOfMonth(now)),
207
- end_date: today
208
- };
209
- case "quarter_to_date":
210
- return {
211
- start_date: formatDate(startOfQuarter(now)),
212
- end_date: today
213
- };
214
- case "previous_month": {
215
- const lastMonth = subMonths(now, 1);
216
- return {
217
- start_date: formatDate(startOfMonth(lastMonth)),
218
- end_date: formatDate(endOfMonth(lastMonth))
219
- };
220
- }
221
- case "previous_quarter": {
222
- const lastQuarter = subMonths(now, 3);
223
- return {
224
- start_date: formatDate(startOfQuarter(lastQuarter)),
225
- end_date: formatDate(endOfQuarter(lastQuarter))
226
- };
227
- }
228
- case "previous_year": {
229
- const lastYear = subYears(now, 1);
230
- return {
231
- start_date: formatDate(startOfYear(lastYear)),
232
- end_date: formatDate(endOfYear(lastYear))
233
- };
234
- }
235
- default:
236
- return null;
237
- }
238
- }
239
- function computePreviousPeriod(startDate, endDate, presetName) {
240
- const start = parseISO(startDate);
241
- const end = parseISO(endDate);
242
- switch (presetName) {
243
- case "today":
244
- case "yesterday": {
245
- return {
246
- start_date: formatDate(subDays(start, 1)),
247
- end_date: formatDate(subDays(end, 1))
248
- };
249
- }
250
- case "last_7_days": {
251
- return {
252
- start_date: formatDate(subDays(start, 7)),
253
- end_date: formatDate(subDays(end, 7))
254
- };
255
- }
256
- case "last_30_days": {
257
- return {
258
- start_date: formatDate(subDays(start, 30)),
259
- end_date: formatDate(subDays(end, 30))
260
- };
261
- }
262
- case "last_90_days": {
263
- return {
264
- start_date: formatDate(subDays(start, 90)),
265
- end_date: formatDate(subDays(end, 90))
266
- };
267
- }
268
- case "last_12_months":
269
- case "last_365_days": {
270
- return {
271
- start_date: formatDate(subMonths(start, 12)),
272
- end_date: formatDate(subMonths(end, 12))
273
- };
274
- }
275
- case "year_to_date": {
276
- return {
277
- start_date: formatDate(subYears(start, 1)),
278
- end_date: formatDate(subYears(end, 1))
279
- };
280
- }
281
- case "month_to_date": {
282
- return {
283
- start_date: formatDate(subMonths(start, 1)),
284
- end_date: formatDate(subMonths(end, 1))
285
- };
286
- }
287
- case "quarter_to_date": {
288
- return {
289
- start_date: formatDate(subQuarters(start, 1)),
290
- end_date: formatDate(subQuarters(end, 1))
291
- };
292
- }
293
- case "previous_month": {
294
- const shifted = subMonths(start, 1);
295
- return {
296
- start_date: formatDate(startOfMonth(shifted)),
297
- end_date: formatDate(endOfMonth(shifted))
298
- };
299
- }
300
- case "previous_quarter": {
301
- const shifted = subQuarters(start, 1);
302
- return {
303
- start_date: formatDate(startOfQuarter(shifted)),
304
- end_date: formatDate(endOfQuarter(shifted))
305
- };
306
- }
307
- case "previous_year": {
308
- const shifted = subYears(start, 1);
309
- return {
310
- start_date: formatDate(startOfYear(shifted)),
311
- end_date: formatDate(endOfYear(shifted))
312
- };
313
- }
314
- default: {
315
- const days = differenceInDays(end, start);
316
- return {
317
- start_date: formatDate(subDays(start, days)),
318
- end_date: formatDate(subDays(end, days))
319
- };
320
- }
321
- }
322
- }
323
- function formatPeriodLabel(startDate, endDate) {
324
- const start = parseISO(startDate);
325
- const end = parseISO(endDate);
326
- if (startDate === endDate) {
327
- return format(start, "MMM d");
328
- }
329
- const startYear = start.getFullYear();
330
- const endYear = end.getFullYear();
331
- if (startYear === endYear) {
332
- return `${format(start, "MMM d")} \u2013 ${format(end, "MMM d")}`;
333
- }
334
- return `${format(start, "MMM d, yyyy")} \u2013 ${format(end, "MMM d, yyyy")}`;
335
- }
336
- function isDatePreset(value) {
337
- return DATE_PRESETS.includes(value);
338
- }
339
- function isRelativeDateRange(value) {
340
- return typeof value === "object" && value !== null && "type" in value && value.type === "relative";
341
- }
342
- function expandRelativeDateRange(rel) {
343
- const now = /* @__PURE__ */ new Date();
344
- const today = startOfDay(now);
345
- if (rel.direction === "current") {
346
- switch (rel.unit) {
347
- case "day":
348
- return { start_date: formatDate(today), end_date: formatDate(today) };
349
- case "week":
350
- return {
351
- start_date: formatDate(startOfWeek(today, { weekStartsOn: 1 })),
352
- end_date: formatDate(endOfWeek(today, { weekStartsOn: 1 }))
353
- };
354
- case "month":
355
- return { start_date: formatDate(startOfMonth(today)), end_date: formatDate(endOfMonth(today)) };
356
- case "quarter":
357
- return { start_date: formatDate(startOfQuarter(today)), end_date: formatDate(endOfQuarter(today)) };
358
- case "year":
359
- return { start_date: formatDate(startOfYear(today)), end_date: formatDate(endOfYear(today)) };
360
- }
361
- }
362
- const n = rel.value ?? 1;
363
- if (rel.direction === "previous") {
364
- const end2 = rel.includeToday ? today : subDays(today, 1);
365
- const shiftFns2 = { day: subDays, week: subWeeks, month: subMonths, quarter: subQuarters, year: subYears };
366
- const start2 = shiftFns2[rel.unit](rel.includeToday ? today : today, n);
367
- return {
368
- start_date: formatDate(start2 < end2 ? start2 : end2),
369
- end_date: formatDate(start2 < end2 ? end2 : start2)
370
- };
371
- }
372
- const start = rel.includeToday ? today : addDays(today, 1);
373
- const shiftFns = { day: addDays, week: addWeeks, month: addMonths, quarter: addQuarters, year: addYears };
374
- const end = shiftFns[rel.unit](start, n);
375
- return {
376
- start_date: formatDate(start < end ? start : end),
377
- end_date: formatDate(start < end ? end : start)
378
- };
379
- }
380
-
381
136
  // ../../packages/query/dist/template.js
382
137
  import nunjucks from "nunjucks";
383
138
  var env = new nunjucks.Environment(null, {
@@ -440,35 +195,35 @@ function extractTemplateVariables(template) {
440
195
 
441
196
  // ../../packages/query/dist/compiler.js
442
197
  import { createHash } from "crypto";
443
- import { format as format2, subDays as subDays2, addDays as addDays2, startOfYear as startOfYear2, startOfMonth as startOfMonth2, startOfQuarter as startOfQuarter2, endOfYear as endOfYear2, endOfMonth as endOfMonth2, endOfQuarter as endOfQuarter2 } from "date-fns";
198
+ import { format, subDays, addDays, startOfYear, startOfMonth, startOfQuarter, endOfYear, endOfMonth, endOfQuarter } from "date-fns";
444
199
  function resolveDynamicDefault(value) {
445
200
  if (typeof value !== "string")
446
201
  return value;
447
202
  const trimmed = value.trim().toLowerCase();
448
203
  if (trimmed === "current_date()" || trimmed === "current_date" || trimmed === "now()" || trimmed === "today") {
449
- return format2(/* @__PURE__ */ new Date(), "yyyy-MM-dd");
204
+ return format(/* @__PURE__ */ new Date(), "yyyy-MM-dd");
450
205
  }
451
206
  const now = /* @__PURE__ */ new Date();
452
207
  switch (trimmed) {
453
208
  case "start_of_year":
454
- return format2(startOfYear2(now), "yyyy-MM-dd");
209
+ return format(startOfYear(now), "yyyy-MM-dd");
455
210
  case "start_of_month":
456
- return format2(startOfMonth2(now), "yyyy-MM-dd");
211
+ return format(startOfMonth(now), "yyyy-MM-dd");
457
212
  case "start_of_quarter":
458
- return format2(startOfQuarter2(now), "yyyy-MM-dd");
213
+ return format(startOfQuarter(now), "yyyy-MM-dd");
459
214
  case "end_of_year":
460
- return format2(endOfYear2(now), "yyyy-MM-dd");
215
+ return format(endOfYear(now), "yyyy-MM-dd");
461
216
  case "end_of_month":
462
- return format2(endOfMonth2(now), "yyyy-MM-dd");
217
+ return format(endOfMonth(now), "yyyy-MM-dd");
463
218
  case "end_of_quarter":
464
- return format2(endOfQuarter2(now), "yyyy-MM-dd");
219
+ return format(endOfQuarter(now), "yyyy-MM-dd");
465
220
  }
466
221
  const arithMatch = trimmed.match(/^(?:today|current_date(?:\(\))?)\s*([+-])\s*(\d+)\s*d?$/);
467
222
  if (arithMatch) {
468
223
  const [, op, numStr] = arithMatch;
469
224
  const days = parseInt(numStr, 10);
470
- const result = op === "-" ? subDays2(now, days) : addDays2(now, days);
471
- return format2(result, "yyyy-MM-dd");
225
+ const result = op === "-" ? subDays(now, days) : addDays(now, days);
226
+ return format(result, "yyyy-MM-dd");
472
227
  }
473
228
  return value;
474
229
  }
@@ -1738,20 +1493,90 @@ async function checkSchema(compiledSql, connector, expectedReturns) {
1738
1493
  };
1739
1494
  }
1740
1495
 
1496
+ // ../../packages/query/dist/profiling/profiler.js
1497
+ var NUMERIC = /(INT|DEC|NUM|DOUBLE|FLOAT|REAL|BIGINT)/i;
1498
+ var STRINGY = /(CHAR|TEXT|STRING|VARCHAR)/i;
1499
+ var TOP_N = 10;
1500
+ function buildTableStatsSql(table, columns, dialect) {
1501
+ const d = getDialect(dialect);
1502
+ const tbl = d.quoteIdent(table);
1503
+ const parts = ["COUNT(*) AS total"];
1504
+ for (const c of columns) {
1505
+ const col = d.quoteIdent(c.name);
1506
+ parts.push(`COUNT(*) - COUNT(${col}) AS ${c.name}_nulls`);
1507
+ parts.push(`COUNT(DISTINCT ${col}) AS ${c.name}_distinct`);
1508
+ if (NUMERIC.test(c.type)) {
1509
+ parts.push(`MIN(${col}) AS ${c.name}_min`);
1510
+ parts.push(`MAX(${col}) AS ${c.name}_max`);
1511
+ }
1512
+ }
1513
+ return `SELECT ${parts.join(", ")} FROM ${tbl}`;
1514
+ }
1515
+ function buildTopValuesSql(table, column, dialect) {
1516
+ const d = getDialect(dialect);
1517
+ const tbl = d.quoteIdent(table);
1518
+ const col = d.quoteIdent(column);
1519
+ return `SELECT ${col} AS v, COUNT(*) AS c FROM ${tbl} GROUP BY ${col} ORDER BY c DESC LIMIT ${TOP_N}`;
1520
+ }
1521
+ async function buildSourceProfile(input) {
1522
+ const { connection, dialect, tables, execute } = input;
1523
+ const d = getDialect(dialect);
1524
+ const maxTopValueDistinct = input.maxTopValueDistinct ?? 50;
1525
+ const tableProfiles = [];
1526
+ for (const t of tables) {
1527
+ try {
1528
+ const statsRes = await execute(buildTableStatsSql(t.table, t.columns, dialect));
1529
+ const stats = statsRes.rows[0] ?? {};
1530
+ const total = Number(stats.total ?? 0);
1531
+ const columns = [];
1532
+ for (const c of t.columns) {
1533
+ const nulls = Number(stats[`${c.name}_nulls`] ?? 0);
1534
+ const distinct = stats[`${c.name}_distinct`] != null ? Number(stats[`${c.name}_distinct`]) : void 0;
1535
+ const col = {
1536
+ name: c.name,
1537
+ type: c.type,
1538
+ nullRate: total > 0 ? nulls / total : void 0,
1539
+ distinctCount: distinct,
1540
+ min: stats[`${c.name}_min`],
1541
+ max: stats[`${c.name}_max`]
1542
+ };
1543
+ if (STRINGY.test(c.type) && distinct != null && distinct <= maxTopValueDistinct) {
1544
+ const tv = await execute(buildTopValuesSql(t.table, c.name, dialect));
1545
+ col.topValues = tv.rows.map((r) => ({ value: r.v, count: Number(r.c) }));
1546
+ }
1547
+ columns.push(col);
1548
+ }
1549
+ const sampleLimit = input.sampleLimit ?? 5;
1550
+ const sampleRows = sampleLimit > 0 ? (await execute(`SELECT * FROM ${d.quoteIdent(t.table)} LIMIT ${sampleLimit}`)).rows : [];
1551
+ tableProfiles.push({ table: t.table, rowCount: total, columns, sampleRows });
1552
+ } catch {
1553
+ tableProfiles.push({ table: t.table, columns: t.columns.map((c) => ({ name: c.name, type: c.type })), sampleRows: [] });
1554
+ }
1555
+ }
1556
+ return { connection, profiledAt: (/* @__PURE__ */ new Date()).toISOString(), tables: tableProfiles };
1557
+ }
1558
+
1559
+ // ../../packages/query/dist/sql-safety.js
1560
+ var DESTRUCTIVE_START = /^\s*(INSERT|UPDATE|DELETE|DROP|ALTER|TRUNCATE|CREATE|MERGE|GRANT|REVOKE|COPY|ATTACH|DETACH|EXPORT|IMPORT|INSTALL|LOAD)\b/i;
1561
+ var WRITABLE_CTE = /\b(INSERT|UPDATE|DELETE|MERGE)\b/i;
1562
+ var READ_ONLY_START = /^\s*(SELECT|WITH)\b/i;
1563
+ function isReadOnlySql(sql) {
1564
+ let s = sql.trim();
1565
+ s = s.replace(/;\s*$/, "");
1566
+ if (s.includes(";"))
1567
+ return false;
1568
+ if (DESTRUCTIVE_START.test(s))
1569
+ return false;
1570
+ if (/^\s*WITH\b/i.test(s) && WRITABLE_CTE.test(s))
1571
+ return false;
1572
+ return READ_ONLY_START.test(s);
1573
+ }
1574
+
1741
1575
  // ../../packages/query/dist/index.js
1742
1576
  var VERSION = "0.1.0";
1743
1577
 
1744
1578
  export {
1745
1579
  parseModelMetadata,
1746
- isCustomDateRange,
1747
- expandCustomDateRange,
1748
- DATE_PRESETS,
1749
- expandDatePreset,
1750
- computePreviousPeriod,
1751
- formatPeriodLabel,
1752
- isDatePreset,
1753
- isRelativeDateRange,
1754
- expandRelativeDateRange,
1755
1580
  SqlList,
1756
1581
  createTemplateContext,
1757
1582
  renderTemplate,
@@ -1777,6 +1602,10 @@ export {
1777
1602
  runModel,
1778
1603
  runAll,
1779
1604
  checkSchema,
1605
+ buildTableStatsSql,
1606
+ buildTopValuesSql,
1607
+ buildSourceProfile,
1608
+ isReadOnlySql,
1780
1609
  VERSION
1781
1610
  };
1782
- //# sourceMappingURL=chunk-S7YQXEKM.js.map
1611
+ //# sourceMappingURL=chunk-QUIDZO5G.js.map