react-semaphor 0.1.381 → 0.1.383

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 (86) hide show
  1. package/DATA_APP_SDK.md +238 -0
  2. package/README.md +7 -0
  3. package/dist/analytics-protocol/index.cjs +1 -1
  4. package/dist/analytics-protocol/index.js +45 -41
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +28 -28
  7. package/dist/chunks/analyze-result-contract-CtXfp3nv.js +1 -0
  8. package/dist/chunks/analyze-result-contract-DuhlklhI.js +102 -0
  9. package/dist/chunks/{braces-DOxxfERN.js → braces--20GzUQh.js} +1 -1
  10. package/dist/chunks/{braces-BT-ZyB-g.js → braces-C0Vh_Mft.js} +1 -1
  11. package/dist/chunks/{calendar-preferences-dialog-Dsgs8WDv.js → calendar-preferences-dialog-B-VsxhsA.js} +4 -4
  12. package/dist/chunks/calendar-preferences-dialog-DE67Z3oQ.js +1 -0
  13. package/dist/chunks/catalog-field-grounding-Bnx-3tE0.js +1 -0
  14. package/dist/chunks/catalog-field-grounding-CJKAqtiC.js +100 -0
  15. package/dist/chunks/{dashboard-briefing-launcher-Coks66cV.js → dashboard-briefing-launcher-BIj3X7b3.js} +108 -107
  16. package/dist/chunks/dashboard-briefing-launcher-Czx6BcXW.js +80 -0
  17. package/dist/chunks/dashboard-controls-BP-DcPFs.js +52 -0
  18. package/dist/chunks/{dashboard-controls-BfkcnIdy.js → dashboard-controls-BXxucM4f.js} +115 -114
  19. package/dist/chunks/dashboard-json-BNwshkK2.js +1 -0
  20. package/dist/chunks/{dashboard-json-DjXi4cI6.js → dashboard-json-C6oZuipD.js} +9 -9
  21. package/dist/chunks/edit-dashboard-visual-BAprin3J.js +178 -0
  22. package/dist/chunks/{edit-dashboard-visual-DOW1Ap1N.js → edit-dashboard-visual-CmfrI_L3.js} +1278 -1277
  23. package/dist/chunks/{index-CkoRCh3g.js → index-4W_ElSBJ.js} +219 -239
  24. package/dist/chunks/{index-DlprYjr6.js → index-icb12JV1.js} +900 -952
  25. package/dist/chunks/{layout-grid-DccceHv4.js → layout-grid-B7-klXiK.js} +1 -1
  26. package/dist/chunks/{layout-grid-DTbOIOsE.js → layout-grid-DV89AC9_.js} +1 -1
  27. package/dist/chunks/operators-C8TxpM4C.js +48 -0
  28. package/dist/chunks/operators-DrTQsJXv.js +1 -0
  29. package/dist/chunks/{palette-DCzLwqIw.js → palette-5IwhMbSF.js} +1 -1
  30. package/dist/chunks/{palette-SimHJELn.js → palette-Dj-dgPYh.js} +1 -1
  31. package/dist/chunks/{save-zNVYH02T.js → save-16C6YSW2.js} +1 -1
  32. package/dist/chunks/{save-D2O96E5A.js → save-C5fwVdTF.js} +1 -1
  33. package/dist/chunks/search-0LmWwZzW.js +57 -0
  34. package/dist/chunks/search-Dq1Mbb03.js +21 -0
  35. package/dist/chunks/{source-identity-Dj3dryN9.js → source-identity-CN4xiyKJ.js} +5 -5
  36. package/dist/chunks/{switch-DMPsMpHW.js → switch-DUdaHFZQ.js} +2328 -2414
  37. package/dist/chunks/{switch-Jhyl63RF.js → switch-bdJp0Bkw.js} +29 -54
  38. package/dist/chunks/use-create-flow-overlay-state-BIHKf_XK.js +21 -0
  39. package/dist/chunks/{use-create-flow-overlay-state-r5JKyXU8.js → use-create-flow-overlay-state-YvqCp6Zo.js} +75 -75
  40. package/dist/chunks/{validators-CtNmgsvG.js → validators-CHPH6ORs.js} +641 -498
  41. package/dist/chunks/validators-lWo8m0Q7.js +1 -0
  42. package/dist/chunks/x-B_cx7LwM.js +26 -0
  43. package/dist/chunks/x-IdR_js6f.js +139 -0
  44. package/dist/dashboard/index.cjs +1 -1
  45. package/dist/dashboard/index.js +1 -1
  46. package/dist/dashboard-authoring/index.cjs +3 -3
  47. package/dist/dashboard-authoring/index.js +105 -92
  48. package/dist/data-app-builder/index.cjs +23 -23
  49. package/dist/data-app-builder/index.js +17 -15
  50. package/dist/data-app-sdk/index.cjs +68 -1
  51. package/dist/data-app-sdk/index.js +2731 -384
  52. package/dist/data-app-sdk-adapters/index.cjs +1 -0
  53. package/dist/data-app-sdk-adapters/index.js +383 -0
  54. package/dist/data-app-sdk-validation/index.cjs +1 -1
  55. package/dist/data-app-sdk-validation/index.js +1073 -6
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.js +15 -15
  58. package/dist/surfboard/index.cjs +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/analytics-protocol.d.ts +58 -31
  61. package/dist/types/dashboard-assistant.d.ts +40 -15
  62. package/dist/types/dashboard-authoring.d.ts +36 -16
  63. package/dist/types/dashboard.d.ts +8 -8
  64. package/dist/types/data-app-builder.d.ts +35 -11
  65. package/dist/types/data-app-sdk-adapters.d.ts +733 -0
  66. package/dist/types/data-app-sdk-validation.d.ts +85 -25
  67. package/dist/types/data-app-sdk.d.ts +217 -147
  68. package/dist/types/main.d.ts +35 -11
  69. package/dist/types/shared.d.ts +8 -8
  70. package/dist/types/surfboard.d.ts +8 -8
  71. package/dist/types/types.d.ts +8 -8
  72. package/package.json +9 -2
  73. package/src/data-app-sdk/README.md +240 -0
  74. package/dist/chunks/calendar-preferences-dialog-iZs8XqyH.js +0 -1
  75. package/dist/chunks/catalog-field-grounding-8L9I0zdg.js +0 -1
  76. package/dist/chunks/catalog-field-grounding-BK4BX8sZ.js +0 -200
  77. package/dist/chunks/dashboard-briefing-launcher-B5vPTl8P.js +0 -80
  78. package/dist/chunks/dashboard-controls-Dyqye6fh.js +0 -52
  79. package/dist/chunks/dashboard-json-CV_LnO9x.js +0 -1
  80. package/dist/chunks/edit-dashboard-visual-yinO0yU-.js +0 -178
  81. package/dist/chunks/index-BxM99sFL.js +0 -1
  82. package/dist/chunks/index-CuHybtft.js +0 -51
  83. package/dist/chunks/use-create-flow-overlay-state-NsqFPwdB.js +0 -21
  84. package/dist/chunks/validation-BM3-ShHV.js +0 -1003
  85. package/dist/chunks/validation-BVpqRFar.js +0 -1
  86. package/dist/chunks/validators-jpoYhpHh.js +0 -1
@@ -1,13 +1,13 @@
1
1
  import { jsxs as d, jsx as r, Fragment as ce } from "react/jsx-runtime";
2
2
  import m from "react";
3
- import { c as ae, a as q, P as ge, b as be, B as C, d as fe, U as De, C as Ie, R as me, f as le, X as Je, S as se, e as je, T as Le, I as $e, J as U, K as _e, M, N as Ve, O as Ue, Q as Me, V as Ge, L as E, W as K, Y as Q, Z as ee, _ as he, $ as re, a0 as oe, a1 as ke, a2 as xe, a3 as ye, a4 as ve, a5 as Ce, a6 as We } from "../chunks/switch-DMPsMpHW.js";
4
- import { r as He, v as Ye, A as Xe, a as Ze, p as qe } from "../chunks/index-CJdxSyQq.js";
5
- import "../chunks/index-CuHybtft.js";
6
- import "../chunks/catalog-field-grounding-BK4BX8sZ.js";
7
- import { P as G } from "../chunks/palette-DCzLwqIw.js";
8
- import { B as Ke } from "../chunks/braces-DOxxfERN.js";
9
- import { S as Qe } from "../chunks/save-zNVYH02T.js";
10
- import { L as er } from "../chunks/layout-grid-DTbOIOsE.js";
3
+ import { c as q, P as ge, a as be, B as C, b as fe, U as De, C as Ie, R as me, e as le, S as se, d as Je, T as je, H as Le, I as U, J as $e, K as M, M as _e, N as Ve, O as Ue, Q as Me, L as E, V as K, W as Q, X as ee, Y as he, Z as re, _ as oe, $ as ke, a0 as xe, a1 as ye, a2 as ve, a3 as Ce, a4 as Ge } from "../chunks/switch-DUdaHFZQ.js";
4
+ import { r as We, v as He, A as Xe, a as Ye, p as Ze } from "../chunks/index-CJdxSyQq.js";
5
+ import { c as ae, X as qe } from "../chunks/x-IdR_js6f.js";
6
+ import "../chunks/analyze-result-contract-DuhlklhI.js";
7
+ import { P as G } from "../chunks/palette-5IwhMbSF.js";
8
+ import { B as Ke } from "../chunks/braces--20GzUQh.js";
9
+ import { S as Qe } from "../chunks/save-16C6YSW2.js";
10
+ import { L as er } from "../chunks/layout-grid-DV89AC9_.js";
11
11
  /**
12
12
  * @license lucide-react v0.453.0 - ISC
13
13
  *
@@ -200,7 +200,7 @@ const ar = ae("Pipette", [
200
200
  }
201
201
  ];
202
202
  function j(e) {
203
- const n = He({
203
+ const n = We({
204
204
  organizationAppearance: e ?? void 0
205
205
  });
206
206
  return tr(O(n));
@@ -210,7 +210,7 @@ function L(e) {
210
210
  version: Xe,
211
211
  mode: e.mode,
212
212
  schemes: e.schemes
213
- }), t = Ye(n);
213
+ }), t = He(n);
214
214
  if (!t.success) {
215
215
  const u = t.issues[0];
216
216
  throw new Error(
@@ -434,7 +434,7 @@ const dr = [
434
434
  ["negative", "Negative"],
435
435
  ["warning", "Warning"],
436
436
  ["info", "Info"]
437
- ], ir = [0, 1, 2, 3, 4, 5], H = Ze, cr = [
437
+ ], ir = [0, 1, 2, 3, 4, 5], H = Ye, cr = [
438
438
  "#ffffff",
439
439
  "#f8fafc",
440
440
  "#f4f4f5",
@@ -729,7 +729,7 @@ function wr({
729
729
  "aria-label": "Close Brand Studio",
730
730
  className: "flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",
731
731
  onClick: S,
732
- children: /* @__PURE__ */ r(Je, { className: "h-3.5 w-3.5" })
732
+ children: /* @__PURE__ */ r(qe, { className: "h-3.5 w-3.5" })
733
733
  }
734
734
  )
735
735
  ] }),
@@ -738,7 +738,7 @@ function wr({
738
738
  /* @__PURE__ */ r(se, { className: "h-3.5 w-3.5 text-destructive" }),
739
739
  "Preview keeps the last valid draft"
740
740
  ] }) : /* @__PURE__ */ d(ce, { children: [
741
- /* @__PURE__ */ r(je, { className: "h-3.5 w-3.5 text-emerald-500" }),
741
+ /* @__PURE__ */ r(Je, { className: "h-3.5 w-3.5 text-emerald-500" }),
742
742
  "Draft is applied to the live dashboard preview"
743
743
  ] }) }),
744
744
  /* @__PURE__ */ r("div", { className: "inline-flex h-7 items-center overflow-hidden rounded-control border border-border/70", children: ["light", "dark"].map((o) => /* @__PURE__ */ r(
@@ -756,13 +756,13 @@ function wr({
756
756
  )) })
757
757
  ] }),
758
758
  I && /* @__PURE__ */ r("div", { className: "border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive", children: I }),
759
- t ? /* @__PURE__ */ r("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ r(le, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : c ? /* @__PURE__ */ r("div", { className: "p-4 text-[13px] text-muted-foreground", children: c }) : f && p ? /* @__PURE__ */ d(Le, { defaultValue: "style", className: "flex min-h-0 flex-1 flex-col", children: [
760
- /* @__PURE__ */ r("div", { className: "shrink-0 px-4 pt-3", children: /* @__PURE__ */ d($e, { variant: "underline", className: "w-full gap-5", children: [
759
+ t ? /* @__PURE__ */ r("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ r(le, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : c ? /* @__PURE__ */ r("div", { className: "p-4 text-[13px] text-muted-foreground", children: c }) : f && p ? /* @__PURE__ */ d(je, { defaultValue: "style", className: "flex min-h-0 flex-1 flex-col", children: [
760
+ /* @__PURE__ */ r("div", { className: "shrink-0 px-4 pt-3", children: /* @__PURE__ */ d(Le, { variant: "underline", className: "w-full gap-5", children: [
761
761
  /* @__PURE__ */ r(U, { value: "style", children: "Style" }),
762
762
  /* @__PURE__ */ r(U, { value: "surfaces", children: "Surfaces" }),
763
763
  /* @__PURE__ */ r(U, { value: "data", children: "Data" })
764
764
  ] }) }),
765
- /* @__PURE__ */ d(_e, { className: "min-h-0 flex-1", children: [
765
+ /* @__PURE__ */ d($e, { className: "min-h-0 flex-1", children: [
766
766
  /* @__PURE__ */ d(M, { value: "style", className: "m-0 p-4", children: [
767
767
  /* @__PURE__ */ r(
768
768
  N,
@@ -828,7 +828,7 @@ function wr({
828
828
  /* @__PURE__ */ d(
829
829
  N,
830
830
  {
831
- icon: Ve,
831
+ icon: _e,
832
832
  title: "Typography",
833
833
  description: "Fonts and density used by dashboard and workflow chrome.",
834
834
  children: [
@@ -855,7 +855,7 @@ function wr({
855
855
  }
856
856
  ),
857
857
  /* @__PURE__ */ r(
858
- X,
858
+ Y,
859
859
  {
860
860
  label: "Density",
861
861
  value: p.tokens.typography.density,
@@ -1026,7 +1026,7 @@ function wr({
1026
1026
  /* @__PURE__ */ d(
1027
1027
  N,
1028
1028
  {
1029
- icon: Ue,
1029
+ icon: Ve,
1030
1030
  title: "Charts",
1031
1031
  description: "Palette and semantic chart text/grid colors.",
1032
1032
  children: [
@@ -1069,13 +1069,13 @@ function wr({
1069
1069
  /* @__PURE__ */ d(
1070
1070
  N,
1071
1071
  {
1072
- icon: Me,
1072
+ icon: Ue,
1073
1073
  title: "Tables",
1074
1074
  description: "Flat, aggregate, and pivot tables share this V1 table appearance.",
1075
1075
  children: [
1076
1076
  /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1077
1077
  /* @__PURE__ */ r(
1078
- X,
1078
+ Y,
1079
1079
  {
1080
1080
  label: "Density",
1081
1081
  value: p.components.table.density,
@@ -1090,7 +1090,7 @@ function wr({
1090
1090
  }
1091
1091
  ),
1092
1092
  /* @__PURE__ */ r(
1093
- X,
1093
+ Y,
1094
1094
  {
1095
1095
  label: "Cell wrap",
1096
1096
  value: p.components.table.cell.wrap,
@@ -1181,7 +1181,7 @@ function N({
1181
1181
  ] })
1182
1182
  ] }),
1183
1183
  /* @__PURE__ */ r("div", { className: "space-y-2", children: u }),
1184
- /* @__PURE__ */ r(Ge, { className: "mt-5 bg-border/60" })
1184
+ /* @__PURE__ */ r(Me, { className: "mt-5 bg-border/60" })
1185
1185
  ] });
1186
1186
  }
1187
1187
  function lr({
@@ -1347,10 +1347,10 @@ function v({
1347
1347
  ] });
1348
1348
  }
1349
1349
  function sr(e) {
1350
- const n = qe(e);
1351
- return n ? `#${Y(n.r)}${Y(n.g)}${Y(n.b)}` : "#000000";
1350
+ const n = Ze(e);
1351
+ return n ? `#${X(n.r)}${X(n.g)}${X(n.b)}` : "#000000";
1352
1352
  }
1353
- function Y(e) {
1353
+ function X(e) {
1354
1354
  return Math.round(e).toString(16).padStart(2, "0");
1355
1355
  }
1356
1356
  function w({
@@ -1402,7 +1402,7 @@ function w({
1402
1402
  )
1403
1403
  ] });
1404
1404
  }
1405
- function X({
1405
+ function Y({
1406
1406
  label: e,
1407
1407
  value: n,
1408
1408
  options: t,
@@ -1423,7 +1423,7 @@ function Z({
1423
1423
  }) {
1424
1424
  return /* @__PURE__ */ d("div", { className: "flex h-8 items-center justify-between rounded-control border border-border/60 px-2", children: [
1425
1425
  /* @__PURE__ */ r("span", { className: "text-[12px]", children: e }),
1426
- /* @__PURE__ */ r(We, { size: "xs", checked: n, onCheckedChange: t })
1426
+ /* @__PURE__ */ r(Ge, { size: "xs", checked: n, onCheckedChange: t })
1427
1427
  ] });
1428
1428
  }
1429
1429
  function ur(e) {
@@ -0,0 +1 @@
1
+ "use strict";const t={answerSummary:"string",responseDetail:"responseDetail",mode:"string",comparisonType:"string",executionResult:"unknown",compiledQuery:"unknown",data:"unknown",resultSets:"record",columns:"unknownArray",records:"recordArray",rowCount:"number",rowLimitExceeded:"boolean",output:"string",querySpec:"unknown",metadata:"record",validation:"unknown",coverage:"unknown",diagnosticFeedback:"unknown",missingFields:"stringArray",warnings:"unknownArray",comparison:"unknown",population:"unknown",comparisons:"recordArray",fieldsUsed:"unknown",changes:"recordArray",largestNegativeChanges:"recordArray",largestPositiveChanges:"recordArray",drivers:"recordArray",absoluteDeltaDrivers:"recordArray",largestNegativeDrivers:"recordArray",largestPositiveDrivers:"recordArray",periodRows:"recordArray",sql:"unknown",omitted:"stringArray"},u=new Set(Object.keys(t)),y=new Set(["compact","standard","debug"]);function d(){return Object.keys(t)}function c(r){return u.has(r)}function A(r){if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Semaphor analyze result must be an object.");const e=r,n=Object.keys(e).filter(o=>!c(o));if(n.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${n.join(", ")}.`);for(const[o,s]of Object.entries(e)){if(s===void 0)continue;const a=t[o];if(!l(s,a))throw new Error(`Semaphor analyze result field "${o}" does not match contract kind "${a}".`)}return e}function l(r,e){switch(e){case"boolean":return typeof r=="boolean";case"number":return typeof r=="number"&&Number.isFinite(r);case"record":return i(r);case"recordArray":return Array.isArray(r)&&r.every(i);case"responseDetail":return typeof r=="string"&&y.has(r);case"string":return typeof r=="string";case"stringArray":return Array.isArray(r)&&r.every(n=>typeof n=="string");case"unknown":return!0;case"unknownArray":return Array.isArray(r)}}function i(r){return!!(r&&typeof r=="object"&&!Array.isArray(r))}exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=t;exports.getSemaphorAnalyzeResultFieldNames=d;exports.isSemaphorAnalyzeResultFieldName=c;exports.parseSemaphorAnalyzeResult=A;
@@ -0,0 +1,102 @@
1
+ const t = {
2
+ answerSummary: "string",
3
+ responseDetail: "responseDetail",
4
+ mode: "string",
5
+ comparisonType: "string",
6
+ executionResult: "unknown",
7
+ compiledQuery: "unknown",
8
+ data: "unknown",
9
+ resultSets: "record",
10
+ columns: "unknownArray",
11
+ records: "recordArray",
12
+ rowCount: "number",
13
+ rowLimitExceeded: "boolean",
14
+ output: "string",
15
+ querySpec: "unknown",
16
+ metadata: "record",
17
+ validation: "unknown",
18
+ coverage: "unknown",
19
+ diagnosticFeedback: "unknown",
20
+ missingFields: "stringArray",
21
+ warnings: "unknownArray",
22
+ comparison: "unknown",
23
+ population: "unknown",
24
+ comparisons: "recordArray",
25
+ fieldsUsed: "unknown",
26
+ changes: "recordArray",
27
+ largestNegativeChanges: "recordArray",
28
+ largestPositiveChanges: "recordArray",
29
+ drivers: "recordArray",
30
+ absoluteDeltaDrivers: "recordArray",
31
+ largestNegativeDrivers: "recordArray",
32
+ largestPositiveDrivers: "recordArray",
33
+ periodRows: "recordArray",
34
+ sql: "unknown",
35
+ omitted: "stringArray"
36
+ }, c = new Set(
37
+ Object.keys(t)
38
+ ), u = /* @__PURE__ */ new Set([
39
+ "compact",
40
+ "standard",
41
+ "debug"
42
+ ]);
43
+ function A() {
44
+ return Object.keys(
45
+ t
46
+ );
47
+ }
48
+ function y(r) {
49
+ return c.has(r);
50
+ }
51
+ function l(r) {
52
+ if (!r || typeof r != "object" || Array.isArray(r))
53
+ throw new Error("Semaphor analyze result must be an object.");
54
+ const e = r, n = Object.keys(e).filter(
55
+ (o) => !y(o)
56
+ );
57
+ if (n.length)
58
+ throw new Error(
59
+ `Semaphor analyze result contains unsupported top-level field(s): ${n.join(", ")}.`
60
+ );
61
+ for (const [o, s] of Object.entries(e)) {
62
+ if (s === void 0)
63
+ continue;
64
+ const a = t[o];
65
+ if (!d(s, a))
66
+ throw new Error(
67
+ `Semaphor analyze result field "${o}" does not match contract kind "${a}".`
68
+ );
69
+ }
70
+ return e;
71
+ }
72
+ function d(r, e) {
73
+ switch (e) {
74
+ case "boolean":
75
+ return typeof r == "boolean";
76
+ case "number":
77
+ return typeof r == "number" && Number.isFinite(r);
78
+ case "record":
79
+ return i(r);
80
+ case "recordArray":
81
+ return Array.isArray(r) && r.every(i);
82
+ case "responseDetail":
83
+ return typeof r == "string" && u.has(r);
84
+ case "string":
85
+ return typeof r == "string";
86
+ case "stringArray":
87
+ return Array.isArray(r) && r.every((n) => typeof n == "string");
88
+ case "unknown":
89
+ return !0;
90
+ case "unknownArray":
91
+ return Array.isArray(r);
92
+ }
93
+ }
94
+ function i(r) {
95
+ return !!(r && typeof r == "object" && !Array.isArray(r));
96
+ }
97
+ export {
98
+ t as S,
99
+ A as g,
100
+ y as i,
101
+ l as p
102
+ };
@@ -1,4 +1,4 @@
1
- import { c as a } from "./switch-DMPsMpHW.js";
1
+ import { c as a } from "./x-IdR_js6f.js";
2
2
  /**
3
3
  * @license lucide-react v0.453.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./switch-Jhyl63RF.js");/**
1
+ "use strict";const e=require("./x-B_cx7LwM.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,9 +1,9 @@
1
1
  import { jsx as r, jsxs as s, Fragment as X } from "react/jsx-runtime";
2
2
  import ee, { useState as h, useCallback as F, useEffect as ae, useMemo as H } from "react";
3
- import { u as re, b as te, c as se, d as ne, e as le, f as oe, R as W, g as O, C as ie, h as ce, i as de, j as ue, k as me, l as _, m as R, n as fe, o as he, p as N } from "./index-DlprYjr6.js";
4
- import { a as S, L as G, P as pe, b as ge, B as j, d as ve, e as V, f as be } from "./switch-DMPsMpHW.js";
5
- import "./index-CuHybtft.js";
6
- import "./catalog-field-grounding-BK4BX8sZ.js";
3
+ import { u as re, b as te, c as se, d as ne, e as le, f as oe, R as W, g as O, C as ie, h as ce, i as de, j as ue, k as me, l as _, m as R, n as fe, o as he, p as N } from "./index-icb12JV1.js";
4
+ import { c as S, L as G, P as pe, a as ge, B as j, b as ve, d as V, e as be } from "./switch-DUdaHFZQ.js";
5
+ import "./x-IdR_js6f.js";
6
+ import "./analyze-result-contract-DuhlklhI.js";
7
7
  function we(n = {}) {
8
8
  var C, A, E, L;
9
9
  const { authToken: c, tokenProps: e } = re(), p = n.enabled ?? !0, d = (c == null ? void 0 : c.accessToken) ?? null, u = (e == null ? void 0 : e.apiServiceUrl) ?? null, [I, k] = h(!1), [y, b] = h(!1), [m, g] = h(!1), [T, o] = h(null), [v, w] = h(null), P = v || {
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),t=require("./index-4W_ElSBJ.js"),o=require("./switch-bdJp0Bkw.js");require("./x-B_cx7LwM.js");require("./analyze-result-contract-CtXfp3nv.js");function G(n={}){var y,P,z,A;const{authToken:d,tokenProps:a}=t.useSemaphorContext(),x=n.enabled??!0,m=(d==null?void 0:d.accessToken)??null,f=(a==null?void 0:a.apiServiceUrl)??null,[L,C]=l.useState(!1),[j,b]=l.useState(!1),[h,g]=l.useState(!1),[N,c]=l.useState(null),[v,S]=l.useState(null),k=v||{tz:((P=(y=a==null?void 0:a.params)==null?void 0:y.calendarContext)==null?void 0:P.tz)||null,weekStart:((A=(z=a==null?void 0:a.params)==null?void 0:z.calendarContext)==null?void 0:A.weekStart)??null},p=l.useCallback(async()=>{if(!(!x||!m||!f)){C(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${m}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const r=await i.json();S({tz:r.tz,weekStart:r.weekStart,source:r.source,isInherited:r.isInherited,userHasPrefs:r.userHasPrefs,inherited:r.inherited})}catch(i){const r=i instanceof Error?i.message:"Unknown error";c(r)}finally{C(!1)}}},[m,f,x]);l.useEffect(()=>{x&&p()},[x,p]);const T=l.useCallback(async i=>{if(!m||!f)return c("Not authenticated"),!1;b(!0),c(null);try{const r=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify(i)});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.error||"Failed to update preferences")}return await p(),!0}catch(r){const u=r instanceof Error?r.message:"Unknown error";return c(u),!1}finally{b(!1)}},[m,f,p]),w=l.useCallback(async()=>{if(!m||!f)return c("Not authenticated"),!1;g(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${m}`}});if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const r=await i.text();if(r)try{const u=JSON.parse(r);return S({tz:u.tz,weekStart:u.weekStart,source:u.source,isInherited:u.isInherited??!0,userHasPrefs:!1,inherited:u.inherited}),!0}catch{}return await p(),!0}catch(i){const r=i instanceof Error?i.message:"Unknown error";return c(r),!1}finally{g(!1)}},[m,f,p]);return{preferences:k,isLoading:L,isSaving:j,isClearing:h,error:N,updatePreferences:T,clearPreferences:w,refetch:p}}const E=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],M=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return E.map(n=>n.value)}function _(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function O(n){const d=E.find(a=>a.value===n);return d?d.label:n}function q(n){const d=M.find(a=>a.value===n);return d?d.label:String(n)}function V({open:n,onOpenChange:d}){var D,U,F;const{preferences:a,isLoading:x,isSaving:m,isClearing:f,updatePreferences:L,clearPreferences:C}=G({enabled:n}),j=a.tz||((D=a.inherited)==null?void 0:D.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=a.weekStart??((U=a.inherited)==null?void 0:U.weekStart)??1,[h,g]=l.useState(!a.userHasPrefs),[N,c]=l.useState(!1),[v,S]=l.useState(j),[k,p]=l.useState(b),[T,w]=l.useState(!1),y=l.useMemo(()=>W(),[]),P=l.useMemo(()=>y.filter(s=>!E.some(R=>R.value===s)),[y]),z=l.useMemo(()=>O(v),[v]),A=a.inherited?O(a.inherited.tz):"UTC",i=a.inherited?q(a.inherited.weekStart):"Monday",r=_((F=a.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!n){c(!1);return}N||(a.userHasPrefs!==void 0&&g(!a.userHasPrefs),S(j),p(b))},[n,N,a.userHasPrefs,j,b]);const u=async()=>{if(x){t.ue.error("Preferences are still loading. Please try again.");return}h?await C()?(t.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),d(!1)):t.ue.error("Failed to save preferences. Please try again."):await L({tz:v,weekStart:k})?(t.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),d(!1)):t.ue.error("Failed to save preferences. Please try again.")},$=()=>{d(!1)},I=m||f,B=I||x;return e.jsx(t.Dialog,{open:n,onOpenChange:d,children:e.jsxs(t.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(t.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(t.RadioGroup,{value:h?"defaults":"custom",onValueChange:s=>{c(!0),g(s==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:o.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{c(!0),g(!0)},children:[e.jsx(t.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",r," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[A,", week starts ",i]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:o.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{c(!0),g(!1)},children:[e.jsx(t.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:o.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{className:H,children:"Timezone"}),e.jsxs(o.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":T,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:z}),e.jsx(t.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(o.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(t.Command,{className:"overflow-visible",children:[e.jsx(t.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No timezone found."}),e.jsx(t.CommandGroup,{heading:"Common",children:E.map(s=>e.jsxs(t.CommandItem,{value:`${s.value} ${s.label}`,onSelect:()=>{c(!0),S(s.value),w(!1)},children:[e.jsx(o.Check,{className:o.cn("h-3.5 w-3.5",v===s.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:s.value})]},s.value))}),e.jsx(t.CommandSeparator,{}),e.jsx(t.CommandGroup,{heading:"All timezones",children:P.map(s=>e.jsxs(t.CommandItem,{value:s,onSelect:()=>{c(!0),S(s),w(!1)},children:[e.jsx(o.Check,{className:o.cn("h-3.5 w-3.5",v===s?"opacity-100":"opacity-0")}),s]},s))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o.Label,{className:H,children:"Week starts on"}),e.jsx(t.RadioGroup,{value:String(k),onValueChange:s=>{c(!0),p(Number(s))},className:"flex gap-4",disabled:h,children:M.map(s=>e.jsxs("label",{htmlFor:`week-start-${s.value}`,className:o.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(t.RadioGroupItem,{value:String(s.value),id:`week-start-${s.value}`,disabled:h}),s.label]},s.value))})]})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",size:"xs",onClick:$,disabled:I,children:"Cancel"}),e.jsx(o.Button,{size:"xs",onClick:u,disabled:B,children:I?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=V;
@@ -0,0 +1 @@
1
+ "use strict";function l(t){return typeof t=="string"?t.trim().toLowerCase():""}function f(t){return String(t.column_name||t.name||t.qualifiedFieldName||"")}function g(t){return Array.from(new Set([t.column_name,t.name,t.qualifiedFieldName,t.alias].filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim())))}function d(t){const e=p(t);return e?e.includes("int")||e.includes("uint")||e.includes("bigint")||e.includes("smallint")||e.includes("tinyint")||e.includes("numeric")||e.includes("decimal")||e.includes("double")||e.includes("float")||e.includes("number")||e.includes("real")||e.includes("money")||e.includes("currency")||e.includes("percent")?"number":e.includes("timestamp")||e.includes("datetime")||e.startsWith("time")?"datetime":e.includes("date")?"date":e.includes("bool")?"boolean":"string":"unknown"}function p(t){let e=l(t),i="";for(;e&&e!==i;)i=e,e=y(e,"nullable"),e=y(e,"lowcardinality");return e}function y(t,e){const i=`${e}(`;return!t.startsWith(i)||!t.endsWith(")")?t:t.slice(i.length,-1).trim()}function A(t){const e=d(t);return e==="date"||e==="datetime"}function o(t){return A(t.dataType||t.data_type)}function u(t){const e=C(t);return e==="id"||e==="row_id"}function c(t){const e=C(t);return u(t)||e.endsWith("_id")||e.endsWith("_key")||e.endsWith("_number")}function C(t){return l(f(t)||t.name||t.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function m(t,e={}){const i=l(t.role);return i==="metric"||i==="measure"?!e.excludeIdentifiers||!c(t):i==="groupby"||i==="dimension"||i==="date"||i==="id"?!1:d(t.dataType||t.data_type)==="number"&&(!e.excludeIdentifiers||!c(t))}function D(t){return!m(t)&&!o(t)}function F(t){const e=new Set,i=new Set,s=new Set;for(const a of t){if(u(a))continue;const r=g(a);if(r.length!==0){if(o(a)){r.forEach(n=>i.add(n));continue}if(m(a,{excludeIdentifiers:!0})){r.forEach(n=>e.add(n));continue}r.forEach(n=>s.add(n))}}return{validMeasureCandidates:Array.from(e).sort(),validDateCandidates:Array.from(i).sort(),validDimensionCandidates:Array.from(s).sort()}}exports.buildAnalyticsCatalogFieldSummary=F;exports.getAnalyticsCatalogFieldCandidates=g;exports.getAnalyticsCatalogFieldName=f;exports.isAnalyticsCatalogDateField=o;exports.isAnalyticsCatalogDimensionField=D;exports.isAnalyticsCatalogMetricField=m;exports.isAnalyticsDateLikeDataType=A;exports.isAnalyticsMetricIdentifierField=c;exports.isAnalyticsTechnicalIdentifierField=u;exports.normalizeAnalyticsCatalogDataType=d;exports.normalizeAnalyticsCatalogName=l;
@@ -0,0 +1,100 @@
1
+ function c(n) {
2
+ return typeof n == "string" ? n.trim().toLowerCase() : "";
3
+ }
4
+ function g(n) {
5
+ return String(n.column_name || n.name || n.qualifiedFieldName || "");
6
+ }
7
+ function p(n) {
8
+ return Array.from(
9
+ new Set(
10
+ [
11
+ n.column_name,
12
+ n.name,
13
+ n.qualifiedFieldName,
14
+ n.alias
15
+ ].filter(
16
+ (e) => typeof e == "string" && e.trim().length > 0
17
+ ).map((e) => e.trim())
18
+ )
19
+ );
20
+ }
21
+ function o(n) {
22
+ const e = C(n);
23
+ return e ? e.includes("int") || e.includes("uint") || e.includes("bigint") || e.includes("smallint") || e.includes("tinyint") || e.includes("numeric") || e.includes("decimal") || e.includes("double") || e.includes("float") || e.includes("number") || e.includes("real") || e.includes("money") || e.includes("currency") || e.includes("percent") ? "number" : e.includes("timestamp") || e.includes("datetime") || e.startsWith("time") ? "datetime" : e.includes("date") ? "date" : e.includes("bool") ? "boolean" : "string" : "unknown";
24
+ }
25
+ function C(n) {
26
+ let e = c(n), t = "";
27
+ for (; e && e !== t; )
28
+ t = e, e = d(e, "nullable"), e = d(e, "lowcardinality");
29
+ return e;
30
+ }
31
+ function d(n, e) {
32
+ const t = `${e}(`;
33
+ return !n.startsWith(t) || !n.endsWith(")") ? n : n.slice(t.length, -1).trim();
34
+ }
35
+ function A(n) {
36
+ const e = o(n);
37
+ return e === "date" || e === "datetime";
38
+ }
39
+ function u(n) {
40
+ return A(n.dataType || n.data_type);
41
+ }
42
+ function m(n) {
43
+ const e = f(n);
44
+ return e === "id" || e === "row_id";
45
+ }
46
+ function l(n) {
47
+ const e = f(n);
48
+ return m(n) || e.endsWith("_id") || e.endsWith("_key") || e.endsWith("_number");
49
+ }
50
+ function f(n) {
51
+ return c(
52
+ g(n) || n.name || n.alias
53
+ ).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
54
+ }
55
+ function y(n, e = {}) {
56
+ const t = c(n.role);
57
+ return t === "metric" || t === "measure" ? !e.excludeIdentifiers || !l(n) : t === "groupby" || t === "dimension" || t === "date" || t === "id" ? !1 : o(
58
+ n.dataType || n.data_type
59
+ ) === "number" && (!e.excludeIdentifiers || !l(n));
60
+ }
61
+ function h(n) {
62
+ return !y(n) && !u(n);
63
+ }
64
+ function D(n) {
65
+ const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
66
+ for (const a of n) {
67
+ if (m(a))
68
+ continue;
69
+ const r = p(a);
70
+ if (r.length !== 0) {
71
+ if (u(a)) {
72
+ r.forEach((i) => t.add(i));
73
+ continue;
74
+ }
75
+ if (y(a, { excludeIdentifiers: !0 })) {
76
+ r.forEach((i) => e.add(i));
77
+ continue;
78
+ }
79
+ r.forEach((i) => s.add(i));
80
+ }
81
+ }
82
+ return {
83
+ validMeasureCandidates: Array.from(e).sort(),
84
+ validDateCandidates: Array.from(t).sort(),
85
+ validDimensionCandidates: Array.from(s).sort()
86
+ };
87
+ }
88
+ export {
89
+ p as a,
90
+ o as b,
91
+ u as c,
92
+ m as d,
93
+ l as e,
94
+ y as f,
95
+ g,
96
+ h,
97
+ A as i,
98
+ D as j,
99
+ c as n
100
+ };