react-semaphor 0.1.375 → 0.1.377
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +47 -43
- package/dist/brand-studio/index.cjs +4 -9
- package/dist/brand-studio/index.js +98 -108
- package/dist/chunks/{braces-C3-w6xDL.js → braces-C2uBgj3t.js} +1 -1
- package/dist/chunks/{braces-C8QqW4wu.js → braces-CkXyWzRh.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DXgi7q5u.js → calendar-preferences-dialog-C55VOTIy.js} +6 -5
- package/dist/chunks/calendar-preferences-dialog-DAukJOaP.js +1 -0
- package/dist/chunks/catalog-field-grounding-BGW0hnB9.js +1 -0
- package/dist/chunks/catalog-field-grounding-DHXEI7cW.js +199 -0
- package/dist/chunks/{chevrons-up-down-DSvLu4Ye.js → chevrons-up-down-BnzChFLU.js} +1 -1
- package/dist/chunks/{chevrons-up-down-CnCSGY02.js → chevrons-up-down-W0nzHzx0.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Jwbmrcl_.js → dashboard-briefing-launcher-CUyeiL_T.js} +3141 -2372
- package/dist/chunks/dashboard-briefing-launcher-DMKfG_z3.js +111 -0
- package/dist/chunks/dashboard-controls-B4hxFc3Q.js +2279 -0
- package/dist/chunks/dashboard-controls-D4vI0wvU.js +52 -0
- package/dist/chunks/dashboard-json-DQnm6daE.js +1 -0
- package/dist/chunks/{dashboard-json-Cl1O3uh0.js → dashboard-json-pl1_mFqJ.js} +14 -13
- package/dist/chunks/{edit-dashboard-visual-B_0sbc43.js → edit-dashboard-visual-CF4aSsav.js} +4729 -4645
- package/dist/chunks/edit-dashboard-visual-CjTXY51a.js +178 -0
- package/dist/chunks/{index-BIks0ktd.js → index-B2kPleRS.js} +186 -181
- package/dist/chunks/{index-BSkBy5cH.js → index-Bn866BBY.js} +22824 -22664
- package/dist/chunks/layout-grid-BFmJ7vmH.js +16 -0
- package/dist/chunks/layout-grid-CTOW9oTg.js +6 -0
- package/dist/chunks/{palette-DUGktM-M.js → palette-DrhPeer-.js} +1 -1
- package/dist/chunks/{palette-D-f4-82S.js → palette-OFaniMPn.js} +1 -1
- package/dist/chunks/{save-D3YYinDz.js → save-BxWBiQv1.js} +1 -1
- package/dist/chunks/{save-kkBEBeLg.js → save-Dh6gSC4x.js} +1 -1
- package/dist/chunks/{switch-Dkx2qEOr.js → switch-C-fGjxjY.js} +2002 -1983
- package/dist/chunks/switch-D5xopzFD.js +168 -0
- package/dist/chunks/use-create-flow-overlay-state-Dg2ffpCE.js +21 -0
- package/dist/chunks/use-create-flow-overlay-state-DrKP0jWE.js +1968 -0
- package/dist/chunks/{validation-1V7bWmYw.js → validation-BHFaWDU-.js} +1 -1
- package/dist/chunks/{validation-DlrTIf1N.js → validation-bMedDBOo.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +18 -13
- package/dist/data-app-builder/index.js +141 -131
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +22 -21
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +151 -151
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +84 -0
- package/dist/types/main.d.ts +8 -12
- package/package.json +1 -1
- package/dist/chunks/calendar-preferences-dialog-CsRzDpDs.js +0 -1
- package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +0 -100
- package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +0 -1
- package/dist/chunks/dashboard-briefing-launcher-C-G6vQTL.js +0 -106
- package/dist/chunks/dashboard-controls-DzGGNQxv.js +0 -2269
- package/dist/chunks/dashboard-controls-p7VKzWSb.js +0 -57
- package/dist/chunks/dashboard-json-CvPhMpbM.js +0 -1
- package/dist/chunks/edit-dashboard-visual-CSrdS10O.js +0 -178
- package/dist/chunks/resource-management-panel-IHbUOh2g.js +0 -6
- package/dist/chunks/resource-management-panel-tFjbtgPw.js +0 -1018
- package/dist/chunks/switch-fIkmwzUt.js +0 -168
- package/dist/chunks/use-create-flow-overlay-state-D-yGZTR3.js +0 -1647
- package/dist/chunks/use-create-flow-overlay-state-DbaUD5xc.js +0 -26
- package/dist/chunks/use-visual-utils-B5hwU_av.js +0 -1
- package/dist/chunks/use-visual-utils-Dj82r7DA.js +0 -340
|
@@ -1,9 +1,10 @@
|
|
|
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 _, l as R, m as me, n as fe, o as N } from "./index-
|
|
4
|
-
import { a as S, L as G, P as he, b as pe, B as j, d as ge, e as V, f as ve } from "./switch-
|
|
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 _, l as R, m as me, n as fe, o as N } from "./index-Bn866BBY.js";
|
|
4
|
+
import { a as S, L as G, P as he, b as pe, B as j, d as ge, e as V, f as ve } from "./switch-C-fGjxjY.js";
|
|
5
5
|
import "./index-CuHybtft.js";
|
|
6
|
-
import
|
|
6
|
+
import "./catalog-field-grounding-DHXEI7cW.js";
|
|
7
|
+
import { C as be } from "./chevrons-up-down-BnzChFLU.js";
|
|
7
8
|
function we(n = {}) {
|
|
8
9
|
var C, A, E, L;
|
|
9
10
|
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 || {
|
|
@@ -167,7 +168,7 @@ function xe(n) {
|
|
|
167
168
|
const c = K.find((e) => e.value === n);
|
|
168
169
|
return c ? c.label : String(n);
|
|
169
170
|
}
|
|
170
|
-
function
|
|
171
|
+
function Ee({
|
|
171
172
|
open: n,
|
|
172
173
|
onOpenChange: c
|
|
173
174
|
}) {
|
|
@@ -453,5 +454,5 @@ function Ae({
|
|
|
453
454
|
] }) });
|
|
454
455
|
}
|
|
455
456
|
export {
|
|
456
|
-
|
|
457
|
+
Ee as C
|
|
457
458
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("react"),t=require("./index-B2kPleRS.js"),i=require("./switch-D5xopzFD.js");require("./index-BxM99sFL.js");require("./catalog-field-grounding-BGW0hnB9.js");const G=require("./chevrons-up-down-W0nzHzx0.js");function W(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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to fetch preferences")}const r=await o.json();S({tz:r.tz,weekStart:r.weekStart,source:r.source,isInherited:r.isInherited,userHasPrefs:r.userHasPrefs,inherited:r.inherited})}catch(o){const r=o instanceof Error?o.message:"Unknown error";c(r)}finally{C(!1)}}},[m,f,x]);l.useEffect(()=>{x&&p()},[x,p]);const T=l.useCallback(async o=>{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(o)});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 o=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${m}`}});if(!o.ok){const u=await o.json().catch(()=>({}));throw new Error(u.error||"Failed to clear preferences")}const r=await o.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(o){const r=o instanceof Error?o.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 q(){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 V(n){const d=M.find(a=>a.value===n);return d?d.label:String(n)}function Z({open:n,onOpenChange:d}){var D,U,F;const{preferences:a,isLoading:x,isSaving:m,isClearing:f,updatePreferences:L,clearPreferences:C}=W({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(()=>q(),[]),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",o=a.inherited?V(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:i.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 ",o]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:i.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:i.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(i.Label,{className:H,children:"Timezone"}),e.jsxs(i.Popover,{open:T,onOpenChange:w,modal:!0,children:[e.jsx(i.PopoverTrigger,{asChild:!0,children:e.jsxs(i.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(G.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(i.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(i.Check,{className:i.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(i.Check,{className:i.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(i.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:i.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(i.Button,{variant:"outline",size:"xs",onClick:$,disabled:I,children:"Cancel"}),e.jsx(i.Button,{size:"xs",onClick:u,disabled:B,children:I?e.jsxs(e.Fragment,{children:[e.jsx(i.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}exports.CalendarPreferencesDialog=Z;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o={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",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"},S=new Set(Object.keys(o)),b=new Set(["compact","standard","debug"]);function D(){return Object.keys(o)}function g(e){return S.has(e)}function F(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Semaphor analyze result must be an object.");const n=e,r=Object.keys(n).filter(t=>!g(t));if(r.length)throw new Error(`Semaphor analyze result contains unsupported top-level field(s): ${r.join(", ")}.`);for(const[t,i]of Object.entries(n)){if(i===void 0)continue;const a=o[t];if(!k(i,a))throw new Error(`Semaphor analyze result field "${t}" does not match contract kind "${a}".`)}return n}function k(e,n){switch(n){case"boolean":return typeof e=="boolean";case"number":return typeof e=="number"&&Number.isFinite(e);case"record":return A(e);case"recordArray":return Array.isArray(e)&&e.every(A);case"responseDetail":return typeof e=="string"&&b.has(e);case"string":return typeof e=="string";case"stringArray":return Array.isArray(e)&&e.every(r=>typeof r=="string");case"unknown":return!0;case"unknownArray":return Array.isArray(e)}}function A(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function c(e){return typeof e=="string"?e.trim().toLowerCase():""}function p(e){return String(e.column_name||e.name||e.qualifiedFieldName||"")}function w(e){return Array.from(new Set([e.column_name,e.name,e.qualifiedFieldName,e.alias].filter(n=>typeof n=="string"&&n.trim().length>0).map(n=>n.trim())))}function d(e){const n=T(e);return n?n.includes("int")||n.includes("uint")||n.includes("bigint")||n.includes("smallint")||n.includes("tinyint")||n.includes("numeric")||n.includes("decimal")||n.includes("double")||n.includes("float")||n.includes("number")||n.includes("real")||n.includes("money")||n.includes("currency")||n.includes("percent")?"number":n.includes("timestamp")||n.includes("datetime")||n.startsWith("time")?"datetime":n.includes("date")?"date":n.includes("bool")?"boolean":"string":"unknown"}function T(e){let n=c(e),r="";for(;n&&n!==r;)r=n,n=f(n,"nullable"),n=f(n,"lowcardinality");return n}function f(e,n){const r=`${n}(`;return!e.startsWith(r)||!e.endsWith(")")?e:e.slice(r.length,-1).trim()}function h(e){const n=d(e);return n==="date"||n==="datetime"}function u(e){return h(e.dataType||e.data_type)}function y(e){const n=C(e);return n==="id"||n==="row_id"}function l(e){const n=C(e);return y(e)||n.endsWith("_id")||n.endsWith("_key")||n.endsWith("_number")}function C(e){return c(p(e)||e.name||e.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function m(e,n={}){const r=c(e.role);return r==="metric"||r==="measure"?!n.excludeIdentifiers||!l(e):r==="groupby"||r==="dimension"||r==="date"||r==="id"?!1:d(e.dataType||e.data_type)==="number"&&(!n.excludeIdentifiers||!l(e))}function _(e){return!m(e)&&!u(e)}function E(e){const n=new Set,r=new Set,t=new Set;for(const i of e){if(y(i))continue;const a=w(i);if(a.length!==0){if(u(i)){a.forEach(s=>r.add(s));continue}if(m(i,{excludeIdentifiers:!0})){a.forEach(s=>n.add(s));continue}a.forEach(s=>t.add(s))}}return{validMetricCandidates:Array.from(n).sort(),validDateCandidates:Array.from(r).sort(),validDimensionCandidates:Array.from(t).sort()}}exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=o;exports.buildAnalyticsCatalogFieldSummary=E;exports.getAnalyticsCatalogFieldCandidates=w;exports.getAnalyticsCatalogFieldName=p;exports.getSemaphorAnalyzeResultFieldNames=D;exports.isAnalyticsCatalogDateField=u;exports.isAnalyticsCatalogDimensionField=_;exports.isAnalyticsCatalogMetricField=m;exports.isAnalyticsDateLikeDataType=h;exports.isAnalyticsMetricIdentifierField=l;exports.isAnalyticsTechnicalIdentifierField=y;exports.isSemaphorAnalyzeResultFieldName=g;exports.normalizeAnalyticsCatalogDataType=d;exports.normalizeAnalyticsCatalogName=c;exports.parseSemaphorAnalyzeResult=F;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
const o = {
|
|
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
|
+
missingFields: "stringArray",
|
|
20
|
+
warnings: "unknownArray",
|
|
21
|
+
comparison: "unknown",
|
|
22
|
+
population: "unknown",
|
|
23
|
+
comparisons: "recordArray",
|
|
24
|
+
fieldsUsed: "unknown",
|
|
25
|
+
changes: "recordArray",
|
|
26
|
+
largestNegativeChanges: "recordArray",
|
|
27
|
+
largestPositiveChanges: "recordArray",
|
|
28
|
+
drivers: "recordArray",
|
|
29
|
+
absoluteDeltaDrivers: "recordArray",
|
|
30
|
+
largestNegativeDrivers: "recordArray",
|
|
31
|
+
largestPositiveDrivers: "recordArray",
|
|
32
|
+
periodRows: "recordArray",
|
|
33
|
+
sql: "unknown",
|
|
34
|
+
omitted: "stringArray"
|
|
35
|
+
}, g = new Set(
|
|
36
|
+
Object.keys(o)
|
|
37
|
+
), w = /* @__PURE__ */ new Set([
|
|
38
|
+
"compact",
|
|
39
|
+
"standard",
|
|
40
|
+
"debug"
|
|
41
|
+
]);
|
|
42
|
+
function _() {
|
|
43
|
+
return Object.keys(
|
|
44
|
+
o
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function h(e) {
|
|
48
|
+
return g.has(e);
|
|
49
|
+
}
|
|
50
|
+
function E(e) {
|
|
51
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
52
|
+
throw new Error("Semaphor analyze result must be an object.");
|
|
53
|
+
const n = e, r = Object.keys(n).filter(
|
|
54
|
+
(t) => !h(t)
|
|
55
|
+
);
|
|
56
|
+
if (r.length)
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Semaphor analyze result contains unsupported top-level field(s): ${r.join(", ")}.`
|
|
59
|
+
);
|
|
60
|
+
for (const [t, a] of Object.entries(n)) {
|
|
61
|
+
if (a === void 0)
|
|
62
|
+
continue;
|
|
63
|
+
const i = o[t];
|
|
64
|
+
if (!b(a, i))
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Semaphor analyze result field "${t}" does not match contract kind "${i}".`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
function b(e, n) {
|
|
72
|
+
switch (n) {
|
|
73
|
+
case "boolean":
|
|
74
|
+
return typeof e == "boolean";
|
|
75
|
+
case "number":
|
|
76
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
77
|
+
case "record":
|
|
78
|
+
return d(e);
|
|
79
|
+
case "recordArray":
|
|
80
|
+
return Array.isArray(e) && e.every(d);
|
|
81
|
+
case "responseDetail":
|
|
82
|
+
return typeof e == "string" && w.has(e);
|
|
83
|
+
case "string":
|
|
84
|
+
return typeof e == "string";
|
|
85
|
+
case "stringArray":
|
|
86
|
+
return Array.isArray(e) && e.every((r) => typeof r == "string");
|
|
87
|
+
case "unknown":
|
|
88
|
+
return !0;
|
|
89
|
+
case "unknownArray":
|
|
90
|
+
return Array.isArray(e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function d(e) {
|
|
94
|
+
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
95
|
+
}
|
|
96
|
+
function c(e) {
|
|
97
|
+
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
98
|
+
}
|
|
99
|
+
function S(e) {
|
|
100
|
+
return String(e.column_name || e.name || e.qualifiedFieldName || "");
|
|
101
|
+
}
|
|
102
|
+
function k(e) {
|
|
103
|
+
return Array.from(
|
|
104
|
+
new Set(
|
|
105
|
+
[
|
|
106
|
+
e.column_name,
|
|
107
|
+
e.name,
|
|
108
|
+
e.qualifiedFieldName,
|
|
109
|
+
e.alias
|
|
110
|
+
].filter(
|
|
111
|
+
(n) => typeof n == "string" && n.trim().length > 0
|
|
112
|
+
).map((n) => n.trim())
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function y(e) {
|
|
117
|
+
const n = C(e);
|
|
118
|
+
return n ? n.includes("int") || n.includes("uint") || n.includes("bigint") || n.includes("smallint") || n.includes("tinyint") || n.includes("numeric") || n.includes("decimal") || n.includes("double") || n.includes("float") || n.includes("number") || n.includes("real") || n.includes("money") || n.includes("currency") || n.includes("percent") ? "number" : n.includes("timestamp") || n.includes("datetime") || n.startsWith("time") ? "datetime" : n.includes("date") ? "date" : n.includes("bool") ? "boolean" : "string" : "unknown";
|
|
119
|
+
}
|
|
120
|
+
function C(e) {
|
|
121
|
+
let n = c(e), r = "";
|
|
122
|
+
for (; n && n !== r; )
|
|
123
|
+
r = n, n = u(n, "nullable"), n = u(n, "lowcardinality");
|
|
124
|
+
return n;
|
|
125
|
+
}
|
|
126
|
+
function u(e, n) {
|
|
127
|
+
const r = `${n}(`;
|
|
128
|
+
return !e.startsWith(r) || !e.endsWith(")") ? e : e.slice(r.length, -1).trim();
|
|
129
|
+
}
|
|
130
|
+
function D(e) {
|
|
131
|
+
const n = y(e);
|
|
132
|
+
return n === "date" || n === "datetime";
|
|
133
|
+
}
|
|
134
|
+
function m(e) {
|
|
135
|
+
return D(e.dataType || e.data_type);
|
|
136
|
+
}
|
|
137
|
+
function f(e) {
|
|
138
|
+
const n = p(e);
|
|
139
|
+
return n === "id" || n === "row_id";
|
|
140
|
+
}
|
|
141
|
+
function l(e) {
|
|
142
|
+
const n = p(e);
|
|
143
|
+
return f(e) || n.endsWith("_id") || n.endsWith("_key") || n.endsWith("_number");
|
|
144
|
+
}
|
|
145
|
+
function p(e) {
|
|
146
|
+
return c(
|
|
147
|
+
S(e) || e.name || e.alias
|
|
148
|
+
).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
149
|
+
}
|
|
150
|
+
function A(e, n = {}) {
|
|
151
|
+
const r = c(e.role);
|
|
152
|
+
return r === "metric" || r === "measure" ? !n.excludeIdentifiers || !l(e) : r === "groupby" || r === "dimension" || r === "date" || r === "id" ? !1 : y(
|
|
153
|
+
e.dataType || e.data_type
|
|
154
|
+
) === "number" && (!n.excludeIdentifiers || !l(e));
|
|
155
|
+
}
|
|
156
|
+
function F(e) {
|
|
157
|
+
return !A(e) && !m(e);
|
|
158
|
+
}
|
|
159
|
+
function T(e) {
|
|
160
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
161
|
+
for (const a of e) {
|
|
162
|
+
if (f(a))
|
|
163
|
+
continue;
|
|
164
|
+
const i = k(a);
|
|
165
|
+
if (i.length !== 0) {
|
|
166
|
+
if (m(a)) {
|
|
167
|
+
i.forEach((s) => r.add(s));
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (A(a, { excludeIdentifiers: !0 })) {
|
|
171
|
+
i.forEach((s) => n.add(s));
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
i.forEach((s) => t.add(s));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
validMetricCandidates: Array.from(n).sort(),
|
|
179
|
+
validDateCandidates: Array.from(r).sort(),
|
|
180
|
+
validDimensionCandidates: Array.from(t).sort()
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
o as S,
|
|
185
|
+
S as a,
|
|
186
|
+
k as b,
|
|
187
|
+
y as c,
|
|
188
|
+
D as d,
|
|
189
|
+
m as e,
|
|
190
|
+
f,
|
|
191
|
+
_ as g,
|
|
192
|
+
l as h,
|
|
193
|
+
h as i,
|
|
194
|
+
A as j,
|
|
195
|
+
F as k,
|
|
196
|
+
T as l,
|
|
197
|
+
c as n,
|
|
198
|
+
E as p
|
|
199
|
+
};
|