react-semaphor 0.1.345 → 0.1.346

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../chunks/validators-8R9pr2K9.js"),K=require("../chunks/index-BxM99sFL.js"),a=require("react"),F=require("react/jsx-runtime");function E(e){var r;const t=V(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:D(e),metrics:t,primaryMetric:z(e,t),dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(n=>l(n,"dimension")),comparison:X(e.comparison),orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:k(e.inputs),limit:e.limit}}function z(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=l(e.primaryMetric,"measure"),n=Q(r,t),o=n.length===1?n[0]:void 0;return o?B(r,o):r}function V(e){const t=[];for(const r of e.metrics.map(n=>l(n,"measure"))){if(!r.name)continue;const n=t.findIndex(o=>j(o,r));if(n===-1){t.push(r);continue}t[n]=B(t[n],r)}return t}function j(e,t){return S.semaphorFieldRefsMatch(e,t)&&g(e)===g(t)}function N(e,t){return g(t)===g(e)}function L(e,t){return t.name!==e.name||e.source&&!S.semaphorFieldRefsMatch(t,e)?!1:N(e,t)}function Q(e,t){const r=t.filter(n=>L(e,n));return e.aggregate!==void 0,r}function g(e){return(e.aggregate||"SUM").toUpperCase()}function B(e,t){if(e.aggregate&&t.aggregate&&e.aggregate!==t.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`);return{...S.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function w(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!W(e))throw new Error("useSemaphorRecords needs at least one field.");const t=G(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:D(e),fields:t,dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:k(e.inputs),limit:e.limit}}function G(e){return e.map(t=>{const r=l(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function O(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:D(e),field:l(e.field,"dimension"),search:e.search,limit:e.limit}}function $(e){if("toAnalyticsInput"in e){const t=e.toAnalyticsInput();return{inputId:t.inputId,...t.field?{field:t.field}:{}}}return{inputId:e.inputId,...e.field?{field:e.field}:{}}}function J(e){const t=k(e);return t.length>0?t:void 0}function q(e){return(e||[]).map(H)}function M(e){return q(e).filter(t=>t.isActive)}function C(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:l(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function T(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function y(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function H(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:y(e.value),value:e.value}}function D(e){return e.source}function W(e){var t;return!!((t=e.fields)!=null&&t.length)}function l(e,t){return{...e,role:e.role||t}}function k(e){return(e||[]).map($)}function X(e){if(e)return e}function P(){return{executeMetric:(e,t)=>v(e,t),executeRecords:(e,t)=>v(e,t),executeInputOptions:(e,t)=>v(e,t)}}async function v(e,t){if(!t.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const r=await fetch(ee(t),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`},body:JSON.stringify({intent:e,activeInputs:t.activeInputs,resultShape:e.kind})}),n=await Y(r);if(!r.ok||n.error)throw new Error(n.error||`Semaphor Data App execution failed with status ${r.status}.`);return n}async function Y(e){const t=await e.text().catch(()=>"");if(!t.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(t)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:t}:{error:Z(e,t),details:t}}}function Z(e,t){const r=e.statusText?` ${e.statusText}`:"",n=t.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${r}.`}function ee(e){const t=te(e).replace(/\/+$/,"");return t?t.endsWith("/api")?`${t}/v1/data-app/execute`:`${t}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function te(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return K.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const R=a.createContext({});function U(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function _(){return a.useContext(R)}function re({token:e,apiBaseUrl:t,executor:r,children:n}){var d;const o=U(),u=((d=o==null?void 0:o.authToken)==null?void 0:d.accessToken)||e,i=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||t,m=a.useMemo(()=>P(),[]),s=r||m,p=a.useMemo(()=>({token:u,apiBaseUrl:i,executor:s}),[i,s,u]);return F.jsx(R.Provider,{value:p,children:n})}const I={value:null},ne={records:[]},A={options:[]};function oe(e){const t=M(e.inputs);try{const r=E(e),n=b(r);return n?{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}:{intent:r,error:null,activeInputs:t,queryKey:c(r,t),idleData:I}}catch(r){const n=h(r);return{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}}}function ie(e){const t=M(e.inputs),r=ne;try{const n=w(e),o=b(n);return o?{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}:{intent:n,error:null,activeInputs:t,queryKey:c(n,t),idleData:r}}catch(n){const o=h(n);return{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}}}function ae(e){try{const t=O(e),r=b(t);return r?{error:r,queryKey:c(void 0,void 0,r),idleData:A}:{intent:t,error:null,queryKey:c(t),idleData:A}}catch(t){const r=h(t);return{error:r,queryKey:c(void 0,void 0,r),idleData:A}}}function h(e){return e instanceof Error?e:new Error(String(e))}function b(e){const t=S.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const r=t.errors.map(n=>n.path?`${n.code} at ${n.path}: ${n.message}`:`${n.code}: ${n.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${r}`)}function c(e,t,r){return JSON.stringify({intent:e,activeInputs:t,error:r==null?void 0:r.message})}function ue(e){const[t,r]=a.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),o=n?e.value:t,u=a.useMemo(()=>T(e.options),[e.options]),i=a.useCallback(s=>{var d;const p=s;(d=e.onValueChange)==null||d.call(e,p),n||r(p)},[n,e]),m=a.useCallback(()=>i(void 0),[i]);return a.useMemo(()=>{const s=C(e);return{id:e.id,kind:e.kind,label:e.label,field:s.field,operator:s.operator,controlRole:e.kind==="control"?e.role:void 0,value:o,options:u,isActive:y(o),setValue:i,clear:m,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:e.kind,label:e.label,value:o,isActive:y(o),operator:s.operator,controlRole:e.kind==="control"?e.role:void 0})}},[m,u,i,e,o])}function se(e){const t=a.useMemo(()=>oe(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeMetric(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,value:(o==null?void 0:o.value)??null,metrics:o==null?void 0:o.metrics,comparisonValue:o==null?void 0:o.comparisonValue,delta:o==null?void 0:o.delta,deltaPercent:o==null?void 0:o.deltaPercent,records:o==null?void 0:o.records,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function le(e){const t=a.useMemo(()=>ie(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeRecords(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,records:(o==null?void 0:o.records)||[],columns:o==null?void 0:o.columns,rowCount:o==null?void 0:o.rowCount,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function de(e){const t=a.useMemo(()=>ae(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeInputOptions(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,options:(o==null?void 0:o.options)||[],status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function x(e,t,r,n){const o=_(),u=a.useRef(t),i=a.useRef(n),[m,s]=a.useState({status:"idle",data:r,error:null});return u.current=t,i.current=n,a.useEffect(()=>{let p;try{p=u.current({...o,activeInputs:i.current})}catch(f){s({status:"error",data:r,error:h(f)});return}if(!p){s({status:"idle",data:r,error:null});return}let d=!1;return s(f=>({status:"loading",data:f.data,error:null})),p.then(f=>{d||s({status:"success",data:f,error:null})}).catch(f=>{d||s({status:"error",data:r,error:h(f)})}),()=>{d=!0}},[r,e,o]),m}exports.SemaphorDataAppContext=R;exports.SemaphorDataAppProvider=re;exports.createSemaphorDataAppExecutor=P;exports.hasSemaphorInputValue=y;exports.normalizeSemaphorInputOptions=T;exports.readWindowRuntime=U;exports.toSemaphorActiveInputSnapshots=M;exports.toSemaphorInputBinding=$;exports.toSemaphorInputBindings=J;exports.toSemaphorInputOptionsIntent=O;exports.toSemaphorInputSnapshots=q;exports.toSemaphorInputSpec=C;exports.toSemaphorMetricIntent=E;exports.toSemaphorRecordsIntent=w;exports.useSemaphorDataAppRuntime=_;exports.useSemaphorInput=ue;exports.useSemaphorInputOptions=de;exports.useSemaphorMetric=se;exports.useSemaphorRecords=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../chunks/validators-8R9pr2K9.js"),K=require("../chunks/index-BxM99sFL.js"),a=require("react"),F=require("react/jsx-runtime");function E(e){var r;const t=V(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:k(e),metrics:t,primaryMetric:z(e,t),dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(n=>l(n,"dimension")),comparison:X(e.comparison),orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function z(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=l(e.primaryMetric,"measure"),n=L(r,t),o=n.length===1?n[0]:void 0;return o?B(r,o):r}function V(e){const t=[];for(const r of e.metrics.map(n=>l(n,"measure"))){if(!r.name)continue;const n=t.findIndex(o=>j(o,r));if(n===-1){t.push(r);continue}t[n]=B(t[n],r)}return t}function j(e,t){return S.semaphorFieldRefsMatch(e,t)&&g(e)===g(t)}function N(e,t){return g(t)===g(e)}function Q(e,t){return t.name!==e.name||e.source&&!S.semaphorFieldRefsMatch(t,e)?!1:N(e,t)}function L(e,t){const r=t.filter(n=>Q(e,n));return e.aggregate!==void 0,r}function g(e){return(e.aggregate||"SUM").toUpperCase()}function B(e,t){if(e.aggregate&&t.aggregate&&e.aggregate!==t.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`);return{...S.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function w(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!W(e))throw new Error("useSemaphorRecords needs at least one field.");const t=G(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:k(e),fields:t,dateField:e.dateField?l(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:l(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:R(e.inputs),limit:e.limit}}function G(e){return e.map(t=>{const r=l(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function O(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:k(e),field:l(e.field,"dimension"),search:e.search,limit:e.limit}}function $(e){if("toAnalyticsInput"in e){const t=e.toAnalyticsInput();return{inputId:t.inputId,...t.field?{field:t.field}:{}}}return{inputId:e.inputId,...e.field?{field:e.field}:{}}}function J(e){const t=R(e);return t.length>0?t:void 0}function q(e){return(e||[]).map(H)}function M(e){return q(e).filter(t=>t.isActive)}function C(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:l(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function T(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function y(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function H(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:y(e.value),value:e.value}}function k(e){return e.source}function W(e){var t;return!!((t=e.fields)!=null&&t.length)}function l(e,t){return{...e,role:e.role||t}}function R(e){return(e||[]).map($)}function X(e){if(e)return e}function P(){return{executeMetric:(e,t)=>v(e,t),executeRecords:(e,t)=>v(e,t),executeInputOptions:(e,t)=>v(e,t)}}async function v(e,t){if(!t.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const r=await fetch(ee(t),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`},body:JSON.stringify({intent:e,activeInputs:t.activeInputs,resultShape:e.kind})}),n=await Y(r);if(!r.ok||n.error)throw new Error(n.error||`Semaphor Data App execution failed with status ${r.status}.`);return n}async function Y(e){const t=await e.text().catch(()=>"");if(!t.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(t)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:t}:{error:Z(e,t),details:t}}}function Z(e,t){const r=e.statusText?` ${e.statusText}`:"",n=t.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${r}.`}function ee(e){const t=te(e).replace(/\/+$/,"");return t?t.endsWith("/api")?`${t}/v1/data-app/execute`:`${t}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function te(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return K.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const D=a.createContext({});function U(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function _(){return a.useContext(D)}function re({token:e,apiBaseUrl:t,executor:r,children:n}){var d;const o=U(),u=((d=o==null?void 0:o.authToken)==null?void 0:d.accessToken)||e,i=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||t,m=a.useMemo(()=>P(),[]),s=r||m,f=a.useMemo(()=>({token:u,apiBaseUrl:i,executor:s}),[i,s,u]);return F.jsx(D.Provider,{value:f,children:n})}const I={value:null},ne={records:[]},A={options:[]};function oe(e){const t=M(e.inputs);try{const r=E(e),n=b(r);return n?{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}:{intent:r,error:null,activeInputs:t,queryKey:c(r,t),idleData:I}}catch(r){const n=h(r);return{error:n,activeInputs:t,queryKey:c(void 0,t,n),idleData:I}}}function ie(e){const t=M(e.inputs),r=ne;try{const n=w(e),o=b(n);return o?{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}:{intent:n,error:null,activeInputs:t,queryKey:c(n,t),idleData:r}}catch(n){const o=h(n);return{error:o,activeInputs:t,queryKey:c(void 0,t,o),idleData:r}}}function ae(e){try{const t=O(e),r=b(t);return r?{error:r,queryKey:c(void 0,void 0,r),idleData:A}:{intent:t,error:null,queryKey:c(t),idleData:A}}catch(t){const r=h(t);return{error:r,queryKey:c(void 0,void 0,r),idleData:A}}}function h(e){return e instanceof Error?e:new Error(String(e))}function b(e){const t=S.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const r=t.errors.map(n=>n.path?`${n.code} at ${n.path}: ${n.message}`:`${n.code}: ${n.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${r}`)}function c(e,t,r){return JSON.stringify({intent:e,activeInputs:t,error:r==null?void 0:r.message})}function ue(e){const[t,r]=a.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),o=n?e.value:t,u=a.useMemo(()=>T(e.options),[e.options]),i=a.useCallback(s=>{var d;const f=s;(d=e.onValueChange)==null||d.call(e,f),n||r(f)},[n,e]),m=a.useCallback(()=>i(void 0),[i]);return a.useMemo(()=>{const s=C(e);return{id:e.id,kind:e.kind,label:e.label,field:s.field,operator:s.operator,controlRole:e.kind==="control"?e.role:void 0,value:o,options:u,isActive:y(o),setValue:i,clear:m,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:e.kind,label:e.label,value:o,isActive:y(o),operator:s.operator,controlRole:e.kind==="control"?e.role:void 0})}},[m,u,i,e,o])}function se(e){const t=a.useMemo(()=>oe(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeMetric(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,value:(o==null?void 0:o.value)??null,metrics:o==null?void 0:o.metrics,comparisonValue:o==null?void 0:o.comparisonValue,delta:o==null?void 0:o.delta,deltaPercent:o==null?void 0:o.deltaPercent,records:o==null?void 0:o.records,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function le(e){const t=a.useMemo(()=>ie(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeRecords(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData,t.activeInputs),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,records:(o==null?void 0:o.records)||[],columns:o==null?void 0:o.columns,rowCount:o==null?void 0:o.rowCount,status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function de(e){const t=a.useMemo(()=>ae(e),[e]),r=a.useCallback(u=>{var i;return t.intent?(i=u.executor)==null?void 0:i.executeInputOptions(t.intent,u):void 0},[t.intent]),n=x(t.queryKey,r,t.idleData),o=t.error?t.idleData:n.data;return{id:e.id,intent:t.intent,options:(o==null?void 0:o.options)||[],status:t.error?"error":n.status,isLoading:!t.error&&n.status==="loading",error:t.error||n.error}}function x(e,t,r,n){const o=_(),u=a.useRef(t),i=a.useRef(n),[m,s]=a.useState({status:"idle",data:r,error:null});return u.current=t,i.current=n,a.useEffect(()=>{let f;try{f=u.current({...o,activeInputs:i.current})}catch(p){s({status:"error",data:r,error:h(p)});return}if(!f){s({status:"idle",data:r,error:null});return}let d=!1;return s(p=>({status:"loading",data:p.data,error:null})),f.then(p=>{d||s({status:"success",data:p,error:null})}).catch(p=>{d||s({status:"error",data:r,error:h(p)})}),()=>{d=!0}},[r,e,o]),m}exports.SemaphorDataAppContext=D;exports.SemaphorDataAppProvider=re;exports.createSemaphorQueryExecutor=P;exports.hasSemaphorInputValue=y;exports.normalizeSemaphorInputOptions=T;exports.readWindowRuntime=U;exports.toSemaphorActiveInputSnapshots=M;exports.toSemaphorInputBinding=$;exports.toSemaphorInputBindings=J;exports.toSemaphorInputOptionsIntent=O;exports.toSemaphorInputSnapshots=q;exports.toSemaphorInputSpec=C;exports.toSemaphorMetricIntent=E;exports.toSemaphorRecordsIntent=w;exports.useSemaphorDataAppRuntime=_;exports.useSemaphorInput=ue;exports.useSemaphorInputOptions=de;exports.useSemaphorMetric=se;exports.useSemaphorRecords=le;
@@ -10,7 +10,7 @@ function P(t) {
10
10
  kind: "metric",
11
11
  id: t.id,
12
12
  label: t.label,
13
- source: D(t),
13
+ source: k(t),
14
14
  metrics: e,
15
15
  primaryMetric: F(t, e),
16
16
  dateField: t.dateField ? s(t.dateField, "date") : void 0,
@@ -21,7 +21,7 @@ function P(t) {
21
21
  field: s(t.orderBy.field),
22
22
  direction: t.orderBy.direction
23
23
  } : void 0,
24
- inputs: k(t.inputs),
24
+ inputs: D(t.inputs),
25
25
  limit: t.limit
26
26
  };
27
27
  }
@@ -48,10 +48,10 @@ function z(t) {
48
48
  return e;
49
49
  }
50
50
  function V(t, e) {
51
- return x(t, e) && y(t) === y(e);
51
+ return x(t, e) && g(t) === g(e);
52
52
  }
53
53
  function j(t, e) {
54
- return y(e) === y(t);
54
+ return g(e) === g(t);
55
55
  }
56
56
  function N(t, e) {
57
57
  return e.name !== t.name || t.source && !x(e, t) ? !1 : j(t, e);
@@ -62,7 +62,7 @@ function L(t, e) {
62
62
  );
63
63
  return t.aggregate !== void 0, r;
64
64
  }
65
- function y(t) {
65
+ function g(t) {
66
66
  return (t.aggregate || "SUM").toUpperCase();
67
67
  }
68
68
  function w(t, e) {
@@ -90,7 +90,7 @@ function Q(t) {
90
90
  kind: "records",
91
91
  id: t.id,
92
92
  label: t.label,
93
- source: D(t),
93
+ source: k(t),
94
94
  fields: e,
95
95
  dateField: t.dateField ? s(t.dateField, "date") : void 0,
96
96
  timeGrain: t.timeGrain,
@@ -98,7 +98,7 @@ function Q(t) {
98
98
  field: s(t.orderBy.field),
99
99
  direction: t.orderBy.direction
100
100
  } : void 0,
101
- inputs: k(t.inputs),
101
+ inputs: D(t.inputs),
102
102
  limit: t.limit
103
103
  };
104
104
  }
@@ -118,7 +118,7 @@ function J(t) {
118
118
  kind: "inputOptions",
119
119
  id: t.id,
120
120
  label: t.label,
121
- source: D(t),
121
+ source: k(t),
122
122
  field: s(t.field, "dimension"),
123
123
  search: t.search,
124
124
  limit: t.limit
@@ -137,8 +137,8 @@ function H(t) {
137
137
  ...t.field ? { field: t.field } : {}
138
138
  };
139
139
  }
140
- function yt(t) {
141
- const e = k(t);
140
+ function gt(t) {
141
+ const e = D(t);
142
142
  return e.length > 0 ? e : void 0;
143
143
  }
144
144
  function W(t) {
@@ -181,7 +181,7 @@ function Z(t) {
181
181
  value: t.value
182
182
  };
183
183
  }
184
- function D(t) {
184
+ function k(t) {
185
185
  return t.source;
186
186
  }
187
187
  function tt(t) {
@@ -194,7 +194,7 @@ function s(t, e) {
194
194
  role: t.role || e
195
195
  };
196
196
  }
197
- function k(t) {
197
+ function D(t) {
198
198
  return (t || []).map(H);
199
199
  }
200
200
  function et(t) {
@@ -309,7 +309,7 @@ function dt(t) {
309
309
  idleData: S
310
310
  };
311
311
  } catch (r) {
312
- const n = g(r);
312
+ const n = y(r);
313
313
  return {
314
314
  error: n,
315
315
  activeInputs: e,
@@ -335,7 +335,7 @@ function ct(t) {
335
335
  idleData: r
336
336
  };
337
337
  } catch (n) {
338
- const o = g(n);
338
+ const o = y(n);
339
339
  return {
340
340
  error: o,
341
341
  activeInputs: e,
@@ -358,7 +358,7 @@ function ft(t) {
358
358
  idleData: I
359
359
  };
360
360
  } catch (e) {
361
- const r = g(e);
361
+ const r = y(e);
362
362
  return {
363
363
  error: r,
364
364
  queryKey: d(void 0, void 0, r),
@@ -366,7 +366,7 @@ function ft(t) {
366
366
  };
367
367
  }
368
368
  }
369
- function g(t) {
369
+ function y(t) {
370
370
  return t instanceof Error ? t : new Error(String(t));
371
371
  }
372
372
  function E(t) {
@@ -475,7 +475,7 @@ function At(t) {
475
475
  error: e.error || n.error
476
476
  };
477
477
  }
478
- function Dt(t) {
478
+ function kt(t) {
479
479
  const e = m(() => ft(t), [t]), r = h(
480
480
  (a) => {
481
481
  var i;
@@ -513,7 +513,7 @@ function M(t, e, r, n) {
513
513
  u({
514
514
  status: "error",
515
515
  data: r,
516
- error: g(f)
516
+ error: y(f)
517
517
  });
518
518
  return;
519
519
  }
@@ -532,7 +532,7 @@ function M(t, e, r, n) {
532
532
  l || u({
533
533
  status: "error",
534
534
  data: r,
535
- error: g(f)
535
+ error: y(f)
536
536
  });
537
537
  }), () => {
538
538
  l = !0;
@@ -542,13 +542,13 @@ function M(t, e, r, n) {
542
542
  export {
543
543
  $ as SemaphorDataAppContext,
544
544
  vt as SemaphorDataAppProvider,
545
- rt as createSemaphorDataAppExecutor,
545
+ rt as createSemaphorQueryExecutor,
546
546
  A as hasSemaphorInputValue,
547
547
  Y as normalizeSemaphorInputOptions,
548
548
  ut as readWindowRuntime,
549
549
  B as toSemaphorActiveInputSnapshots,
550
550
  H as toSemaphorInputBinding,
551
- yt as toSemaphorInputBindings,
551
+ gt as toSemaphorInputBindings,
552
552
  J as toSemaphorInputOptionsIntent,
553
553
  W as toSemaphorInputSnapshots,
554
554
  X as toSemaphorInputSpec,
@@ -556,7 +556,7 @@ export {
556
556
  Q as toSemaphorRecordsIntent,
557
557
  st as useSemaphorDataAppRuntime,
558
558
  St as useSemaphorInput,
559
- Dt as useSemaphorInputOptions,
559
+ kt as useSemaphorInputOptions,
560
560
  It as useSemaphorMetric,
561
561
  At as useSemaphorRecords
562
562
  };
@@ -309,7 +309,7 @@ export declare type SemaphorAnalyticsExecutionResult = {
309
309
  coverage?: {
310
310
  answeredObligations: string[];
311
311
  missingObligations: string[];
312
- warnings: SemaphorAnalyticsValidationIssue[];
312
+ warnings?: SemaphorAnalyticsValidationIssue[];
313
313
  };
314
314
  missingFields?: string[];
315
315
  warnings?: string[];
@@ -652,11 +652,7 @@ export declare type SemaphorRecordsIntent = {
652
652
 
653
653
  export declare type SemaphorRecordsResult = SemaphorAnalyticsResultBase & {
654
654
  kind: 'records';
655
- columns: Array<{
656
- name: string;
657
- label?: string;
658
- dataType?: SemaphorFieldRef['dataType'];
659
- }>;
655
+ columns: SemaphorResultColumn[];
660
656
  records: Array<Record<string, unknown>>;
661
657
  };
662
658
 
@@ -689,6 +685,26 @@ export declare type SemaphorRelationshipDiagnostics = {
689
685
 
690
686
  export declare type SemaphorRelationshipDiagnosticStatus = 'not_required' | 'resolved' | 'missing' | 'ambiguous' | 'fanout_risk' | 'unknown';
691
687
 
688
+ export declare type SemaphorResultColumn = {
689
+ /**
690
+ * Stable row accessor for this result. Consumers should read values with
691
+ * `row[column.key]`; labels are display-only and may change.
692
+ */
693
+ key: string;
694
+ /**
695
+ * Semantic/source field name before result-key disambiguation.
696
+ */
697
+ name: string;
698
+ /**
699
+ * Human-facing display label.
700
+ */
701
+ label: string;
702
+ role?: SemaphorFieldRef['role'];
703
+ dataType?: SemaphorFieldRef['dataType'];
704
+ aggregate?: SemaphorFieldRef['aggregate'];
705
+ source?: SemaphorFieldRef['source'];
706
+ };
707
+
692
708
  export declare type SemaphorSourceCoordinateInput = {
693
709
  databaseName?: string;
694
710
  schemaName?: string;
@@ -2,20 +2,29 @@ import { Context } from 'react';
2
2
  import { JSX } from 'react/jsx-runtime';
3
3
  import { ReactNode } from 'react';
4
4
 
5
- export declare function createSemaphorDataAppExecutor(): SemaphorDataAppExecutor;
5
+ export declare function createSemaphorQueryExecutor(): SemaphorQueryExecutor;
6
6
 
7
7
  export declare function hasSemaphorInputValue(value: unknown): boolean;
8
8
 
9
9
  export declare function normalizeSemaphorInputOptions(options?: Array<{
10
10
  label: string;
11
- value: SemaphorDataAppOptionValue;
12
- } | SemaphorDataAppOptionValue>): {
11
+ value: SemaphorOptionValue;
12
+ } | SemaphorOptionValue>): {
13
13
  label: string;
14
- value: SemaphorDataAppOptionValue;
14
+ value: SemaphorOptionValue;
15
15
  }[];
16
16
 
17
17
  export declare function readWindowRuntime(): SemaphorDataAppWindowRuntime | undefined;
18
18
 
19
+ export declare type SemaphorActiveInput<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBinding & {
20
+ kind: 'filter' | 'control';
21
+ label?: string;
22
+ value?: TValue;
23
+ isActive: boolean;
24
+ operator?: SemaphorInputOperator;
25
+ controlRole?: SemaphorControlRole;
26
+ };
27
+
19
28
  declare type SemaphorAggregateFunction = 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'MEDIAN' | 'DISTINCT';
20
29
 
21
30
  declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
@@ -43,108 +52,164 @@ declare type SemaphorAnalyticsValueFilter = SemaphorAnalyticsFilterBase & {
43
52
 
44
53
  declare type SemaphorAnalyticsValueFilterOperator = Exclude<SemaphorAnalyticsFilterOperator, 'is_null' | 'is_not_null'>;
45
54
 
46
- export declare const SemaphorDataAppContext: Context<SemaphorDataAppRuntime>;
47
-
48
- export declare type SemaphorDataAppControlInputSpec<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = SemaphorDataAppInputBase<TValue> & {
55
+ export declare type SemaphorControlInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
49
56
  kind: 'control';
50
- role: SemaphorDataAppControlRole;
57
+ role: SemaphorControlRole;
51
58
  };
52
59
 
53
- export declare type SemaphorDataAppControlRole = 'grain' | 'metric' | 'dimension' | 'aggregation' | 'sqlParam';
60
+ export declare type SemaphorControlRole = 'grain' | 'metric' | 'dimension' | 'aggregation' | 'sqlParam';
54
61
 
55
- export declare type SemaphorDataAppExecutor = {
56
- executeMetric(intent: SemaphorMetricIntent, context: SemaphorDataAppExecutorContext): Promise<SemaphorDataAppMetricData>;
57
- executeRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(intent: SemaphorRecordsIntent, context: SemaphorDataAppExecutorContext): Promise<SemaphorDataAppRecordsData<TRecord>>;
58
- executeInputOptions(intent: Extract<SemaphorAnalyticsIntent, {
59
- kind: 'inputOptions';
60
- }>, context: SemaphorDataAppExecutorContext): Promise<SemaphorDataAppInputOptionsData>;
62
+ export declare const SemaphorDataAppContext: Context<SemaphorDataAppRuntime>;
63
+
64
+ export declare function SemaphorDataAppProvider({ token, apiBaseUrl, executor, children, }: SemaphorDataAppProviderProps): JSX.Element;
65
+
66
+ export declare type SemaphorDataAppProviderProps = SemaphorQueryExecutorContext & {
67
+ executor?: SemaphorQueryExecutor;
68
+ children: ReactNode;
61
69
  };
62
70
 
63
- export declare type SemaphorDataAppExecutorContext = {
64
- token?: string;
71
+ export declare type SemaphorDataAppRuntime = SemaphorQueryExecutorContext & {
72
+ executor?: SemaphorQueryExecutor;
73
+ };
74
+
75
+ declare type SemaphorDataAppWindowRuntime = {
65
76
  apiBaseUrl?: string;
66
- activeInputs?: SemaphorDataAppInputSnapshot[];
77
+ dataApiBaseUrl?: string;
78
+ authToken?: null | {
79
+ accessToken?: string;
80
+ };
67
81
  };
68
82
 
69
- export declare type SemaphorDataAppFieldSpec = SemaphorFieldRef;
83
+ declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
70
84
 
71
- export declare type SemaphorDataAppFilterInputSpec<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = SemaphorDataAppInputBase<TValue> & {
85
+ declare type SemaphorFieldRef = {
86
+ name: string;
87
+ label?: string;
88
+ role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
89
+ dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'unknown';
90
+ source?: SemaphorSourceRef;
91
+ aggregate?: SemaphorAggregateFunction;
92
+ };
93
+
94
+ export declare type SemaphorFilterInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
72
95
  kind: 'filter';
73
- field: SemaphorDataAppFieldSpec;
96
+ field: SemaphorQueryField;
74
97
  operator?: SemaphorInputOperator;
75
98
  multi?: boolean;
76
99
  };
77
100
 
78
- declare type SemaphorDataAppInputBase<TValue extends SemaphorDataAppInputValue> = {
101
+ declare type SemaphorInputBase<TValue extends SemaphorInputValue> = {
79
102
  id: string;
80
103
  label?: string;
81
104
  value?: TValue;
82
105
  defaultValue?: TValue;
83
106
  onValueChange?: (value: TValue | undefined) => void;
84
- options?: Array<SemaphorDataAppInputOption | SemaphorDataAppOptionValue>;
107
+ options?: Array<SemaphorInputOption | SemaphorOptionValue>;
85
108
  };
86
109
 
87
- export declare type SemaphorDataAppInputHandle<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = {
110
+ declare type SemaphorInputBinding = {
111
+ inputId: string;
112
+ field?: SemaphorFieldRef;
113
+ };
114
+
115
+ export declare type SemaphorInputHandle<TValue extends SemaphorInputValue = SemaphorInputValue> = {
88
116
  id: string;
89
117
  kind: 'filter' | 'control';
90
118
  label?: string;
91
119
  field?: SemaphorFieldRef;
92
120
  operator?: SemaphorInputOperator;
93
- controlRole?: SemaphorDataAppControlRole;
121
+ controlRole?: SemaphorControlRole;
94
122
  value: TValue | undefined;
95
- options: SemaphorDataAppInputOption[];
123
+ options: SemaphorInputOption[];
96
124
  isActive: boolean;
97
125
  setValue(value: TValue | undefined): void;
98
126
  clear(): void;
99
- toAnalyticsInput(): SemaphorDataAppInputSnapshot<TValue>;
127
+ toAnalyticsInput(): SemaphorActiveInput<TValue>;
100
128
  };
101
129
 
102
- export declare type SemaphorDataAppInputOption = {
130
+ declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
131
+
132
+ export declare type SemaphorInputOption = {
103
133
  label: string;
104
- value: SemaphorDataAppOptionValue;
134
+ value: SemaphorOptionValue;
105
135
  count?: number;
106
136
  };
107
137
 
108
- export declare type SemaphorDataAppInputOptionsData = {
109
- options: SemaphorDataAppInputOption[];
138
+ declare type SemaphorInputOptionsIntent = {
139
+ kind: 'inputOptions';
140
+ version?: SemaphorProtocolVersion;
141
+ id?: string;
142
+ label?: string;
143
+ source: SemaphorSourceRef;
144
+ field: SemaphorFieldRef;
145
+ search?: string;
146
+ limit?: number;
110
147
  };
111
148
 
112
- export declare type SemaphorDataAppInputOptionsResult = SemaphorDataAppQueryState & SemaphorDataAppInputOptionsData & {
149
+ export declare type SemaphorInputOptionsPayload = {
150
+ options: SemaphorInputOption[];
151
+ };
152
+
153
+ export declare type SemaphorInputOptionsQueryResult = SemaphorQueryState & SemaphorInputOptionsPayload & {
113
154
  id?: string;
114
155
  intent?: Extract<SemaphorAnalyticsIntent, {
115
156
  kind: 'inputOptions';
116
157
  }>;
117
158
  };
118
159
 
119
- export declare type SemaphorDataAppInputOptionsSpec = SemaphorDataAppSourceSpec & {
160
+ export declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & {
120
161
  id?: string;
121
162
  label?: string;
122
- field: SemaphorDataAppFieldSpec;
163
+ field: SemaphorQueryField;
123
164
  search?: string;
124
165
  limit?: number;
125
166
  };
126
167
 
127
- export declare type SemaphorDataAppInputReference = SemaphorInputBinding | SemaphorDataAppInputSnapshot | SemaphorDataAppInputHandle;
168
+ export declare type SemaphorInputReference = SemaphorInputBinding | SemaphorActiveInput | SemaphorInputHandle;
128
169
 
129
- export declare type SemaphorDataAppInputSnapshot<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = SemaphorInputBinding & {
130
- kind: 'filter' | 'control';
131
- label?: string;
132
- value?: TValue;
133
- isActive: boolean;
134
- operator?: SemaphorInputOperator;
135
- controlRole?: SemaphorDataAppControlRole;
136
- };
170
+ export declare type SemaphorInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorFilterInputSpec<TValue> | SemaphorControlInputSpec<TValue>;
137
171
 
138
- export declare type SemaphorDataAppInputSpec<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = SemaphorDataAppFilterInputSpec<TValue> | SemaphorDataAppControlInputSpec<TValue>;
172
+ export declare type SemaphorInputValue = SemaphorScalar | SemaphorScalar[];
139
173
 
140
- export declare type SemaphorDataAppInputValue = SemaphorDataAppScalar | SemaphorDataAppScalar[];
174
+ declare type SemaphorMetricAnalysis = {
175
+ kind: 'period_change';
176
+ orderBy?: 'absolute_change' | 'positive_change' | 'negative_change' | 'period';
177
+ direction?: 'increase' | 'decrease' | 'both';
178
+ timeWindow?: SemaphorTimeWindow;
179
+ };
141
180
 
142
- export declare type SemaphorDataAppMetricComparison = {
181
+ export declare type SemaphorMetricComparison = {
143
182
  kind: 'previous_period' | 'previous_year' | 'target';
144
183
  targetValue?: number;
145
184
  };
146
185
 
147
- export declare type SemaphorDataAppMetricData = {
186
+ declare type SemaphorMetricIntent = {
187
+ kind: 'metric';
188
+ version?: SemaphorProtocolVersion;
189
+ id?: string;
190
+ source: SemaphorSourceRef;
191
+ metrics: SemaphorFieldRef[];
192
+ primaryMetric?: SemaphorFieldRef;
193
+ label?: string;
194
+ dateField?: SemaphorFieldRef;
195
+ timeGrain?: SemaphorTimeGrain;
196
+ timeWindow?: SemaphorTimeWindow;
197
+ dimensions?: SemaphorFieldRef[];
198
+ filters?: SemaphorAnalyticsFilter[];
199
+ comparison?: {
200
+ kind: 'previous_period' | 'previous_year' | 'target';
201
+ targetValue?: number;
202
+ };
203
+ analysis?: SemaphorMetricAnalysis;
204
+ orderBy?: {
205
+ field: SemaphorFieldRef;
206
+ direction: 'asc' | 'desc';
207
+ };
208
+ inputs?: SemaphorInputBinding[];
209
+ limit?: number;
210
+ };
211
+
212
+ export declare type SemaphorMetricPayload = {
148
213
  value: number | string | null;
149
214
  metrics?: Record<string, number | string | null>;
150
215
  comparisonValue?: number | string | null;
@@ -153,168 +218,77 @@ export declare type SemaphorDataAppMetricData = {
153
218
  records?: Array<Record<string, unknown>>;
154
219
  };
155
220
 
156
- export declare type SemaphorDataAppMetricResult = SemaphorDataAppQueryState & SemaphorDataAppMetricData & {
221
+ export declare type SemaphorMetricQueryResult = SemaphorQueryState & SemaphorMetricPayload & {
157
222
  id?: string;
158
223
  intent?: SemaphorMetricIntent;
159
224
  };
160
225
 
161
- export declare type SemaphorDataAppMetricSpec = SemaphorDataAppSourceSpec & {
226
+ export declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & {
162
227
  id?: string;
163
228
  label?: string;
164
- metrics: SemaphorDataAppNonEmptyArray<SemaphorDataAppFieldSpec>;
165
- primaryMetric?: SemaphorDataAppFieldSpec;
166
- dateField?: SemaphorDataAppFieldSpec;
229
+ metrics: SemaphorNonEmptyArray<SemaphorQueryField>;
230
+ primaryMetric?: SemaphorQueryField;
231
+ dateField?: SemaphorQueryField;
167
232
  timeGrain?: SemaphorTimeGrain;
168
- dimensions?: SemaphorDataAppFieldSpec[];
169
- comparison?: SemaphorDataAppMetricComparison;
170
- orderBy?: SemaphorDataAppOrderBy;
171
- inputs?: SemaphorDataAppInputReference[];
233
+ dimensions?: SemaphorQueryField[];
234
+ comparison?: SemaphorMetricComparison;
235
+ orderBy?: SemaphorQueryOrderBy;
236
+ inputs?: SemaphorInputReference[];
172
237
  limit?: number;
173
238
  };
174
239
 
175
- export declare type SemaphorDataAppNonEmptyArray<T> = [T, ...T[]];
176
-
177
- export declare type SemaphorDataAppOptionValue = string | number | boolean;
178
-
179
- export declare type SemaphorDataAppOrderBy = {
180
- field: SemaphorDataAppFieldSpec;
181
- direction: 'asc' | 'desc';
182
- };
183
-
184
- export declare function SemaphorDataAppProvider({ token, apiBaseUrl, executor, children, }: SemaphorDataAppProviderProps): JSX.Element;
240
+ export declare type SemaphorNonEmptyArray<T> = [T, ...T[]];
185
241
 
186
- export declare type SemaphorDataAppProviderProps = SemaphorDataAppExecutorContext & {
187
- executor?: SemaphorDataAppExecutor;
188
- children: ReactNode;
189
- };
242
+ export declare type SemaphorOptionValue = string | number | boolean;
190
243
 
191
- export declare type SemaphorDataAppQueryState = {
192
- status: SemaphorDataAppQueryStatus;
193
- isLoading: boolean;
194
- error: Error | null;
195
- };
196
-
197
- export declare type SemaphorDataAppQueryStatus = 'idle' | 'loading' | 'success' | 'error';
198
-
199
- declare type SemaphorDataAppRecordsBaseSpec = SemaphorDataAppSourceSpec & {
200
- id?: string;
201
- label?: string;
202
- dateField?: SemaphorDataAppFieldSpec;
203
- timeGrain?: SemaphorTimeGrain;
204
- orderBy?: SemaphorDataAppRecordsOrderBy;
205
- inputs?: SemaphorDataAppInputReference[];
206
- limit?: number;
207
- };
208
-
209
- export declare type SemaphorDataAppRecordsData<TRecord extends Record<string, unknown> = Record<string, unknown>> = {
210
- records: TRecord[];
211
- columns?: Array<{
212
- name: string;
213
- label?: string;
214
- dataType?: SemaphorFieldRef['dataType'];
215
- role?: SemaphorFieldRef['role'];
216
- }>;
217
- rowCount?: number;
218
- };
219
-
220
- export declare type SemaphorDataAppRecordsFieldSpec = SemaphorFieldRef & {
221
- role: NonNullable<SemaphorFieldRef['role']>;
222
- };
223
-
224
- export declare type SemaphorDataAppRecordsOrderBy = SemaphorDataAppOrderBy;
225
-
226
- export declare type SemaphorDataAppRecordsResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorDataAppQueryState & SemaphorDataAppRecordsData<TRecord> & {
227
- id?: string;
228
- intent?: SemaphorRecordsIntent;
229
- };
230
-
231
- declare type SemaphorDataAppRecordsSelectorSpec = {
232
- fields: SemaphorDataAppNonEmptyArray<SemaphorDataAppRecordsFieldSpec>;
233
- };
234
-
235
- export declare type SemaphorDataAppRecordsSpec = SemaphorDataAppRecordsBaseSpec & SemaphorDataAppRecordsSelectorSpec;
236
-
237
- export declare type SemaphorDataAppRuntime = SemaphorDataAppExecutorContext & {
238
- executor?: SemaphorDataAppExecutor;
239
- };
240
-
241
- export declare type SemaphorDataAppScalar = string | number | boolean | null;
244
+ declare type SemaphorProtocolVersion = 1;
242
245
 
243
- export declare type SemaphorDataAppSourceSpec = {
244
- source: SemaphorSourceRef;
246
+ export declare type SemaphorQueryExecutor = {
247
+ executeMetric(intent: SemaphorMetricIntent, context: SemaphorQueryExecutorContext): Promise<SemaphorMetricPayload>;
248
+ executeRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(intent: SemaphorRecordsIntent, context: SemaphorQueryExecutorContext): Promise<SemaphorRecordsPayload<TRecord>>;
249
+ executeInputOptions(intent: Extract<SemaphorAnalyticsIntent, {
250
+ kind: 'inputOptions';
251
+ }>, context: SemaphorQueryExecutorContext): Promise<SemaphorInputOptionsPayload>;
245
252
  };
246
253
 
247
- declare type SemaphorDataAppWindowRuntime = {
254
+ export declare type SemaphorQueryExecutorContext = {
255
+ token?: string;
248
256
  apiBaseUrl?: string;
249
- dataApiBaseUrl?: string;
250
- authToken?: null | {
251
- accessToken?: string;
252
- };
257
+ activeInputs?: SemaphorActiveInput[];
253
258
  };
254
259
 
255
- declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
256
-
257
- declare type SemaphorFieldRef = {
258
- name: string;
259
- label?: string;
260
- role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
261
- dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'unknown';
262
- source?: SemaphorSourceRef;
263
- aggregate?: SemaphorAggregateFunction;
264
- };
260
+ export declare type SemaphorQueryField = SemaphorFieldRef;
265
261
 
266
- declare type SemaphorInputBinding = {
267
- inputId: string;
268
- field?: SemaphorFieldRef;
262
+ export declare type SemaphorQueryOrderBy = {
263
+ field: SemaphorQueryField;
264
+ direction: 'asc' | 'desc';
269
265
  };
270
266
 
271
- declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
272
-
273
- declare type SemaphorInputOptionsIntent = {
274
- kind: 'inputOptions';
275
- version?: SemaphorProtocolVersion;
276
- id?: string;
277
- label?: string;
267
+ export declare type SemaphorQuerySourceSpec = {
278
268
  source: SemaphorSourceRef;
279
- field: SemaphorFieldRef;
280
- search?: string;
281
- limit?: number;
282
269
  };
283
270
 
284
- declare type SemaphorMetricAnalysis = {
285
- kind: 'period_change';
286
- orderBy?: 'absolute_change' | 'positive_change' | 'negative_change' | 'period';
287
- direction?: 'increase' | 'decrease' | 'both';
288
- timeWindow?: SemaphorTimeWindow;
271
+ export declare type SemaphorQueryState = {
272
+ status: SemaphorQueryStatus;
273
+ isLoading: boolean;
274
+ error: Error | null;
289
275
  };
290
276
 
291
- declare type SemaphorMetricIntent = {
292
- kind: 'metric';
293
- version?: SemaphorProtocolVersion;
277
+ export declare type SemaphorQueryStatus = 'idle' | 'loading' | 'success' | 'error';
278
+
279
+ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
294
280
  id?: string;
295
- source: SemaphorSourceRef;
296
- metrics: SemaphorFieldRef[];
297
- primaryMetric?: SemaphorFieldRef;
298
281
  label?: string;
299
- dateField?: SemaphorFieldRef;
282
+ dateField?: SemaphorQueryField;
300
283
  timeGrain?: SemaphorTimeGrain;
301
- timeWindow?: SemaphorTimeWindow;
302
- dimensions?: SemaphorFieldRef[];
303
- filters?: SemaphorAnalyticsFilter[];
304
- comparison?: {
305
- kind: 'previous_period' | 'previous_year' | 'target';
306
- targetValue?: number;
307
- };
308
- analysis?: SemaphorMetricAnalysis;
309
- orderBy?: {
310
- field: SemaphorFieldRef;
311
- direction: 'asc' | 'desc';
312
- };
313
- inputs?: SemaphorInputBinding[];
284
+ orderBy?: SemaphorRecordsOrderBy;
285
+ inputs?: SemaphorInputReference[];
314
286
  limit?: number;
315
287
  };
316
288
 
317
- declare type SemaphorProtocolVersion = 1;
289
+ export declare type SemaphorRecordsField = SemaphorFieldRef & {
290
+ role: NonNullable<SemaphorFieldRef['role']>;
291
+ };
318
292
 
319
293
  declare type SemaphorRecordsIntent = {
320
294
  kind: 'records';
@@ -333,6 +307,47 @@ declare type SemaphorRecordsIntent = {
333
307
  inputs?: SemaphorInputBinding[];
334
308
  };
335
309
 
310
+ export declare type SemaphorRecordsOrderBy = SemaphorQueryOrderBy;
311
+
312
+ export declare type SemaphorRecordsPayload<TRecord extends Record<string, unknown> = Record<string, unknown>> = {
313
+ records: TRecord[];
314
+ columns?: SemaphorResultColumn[];
315
+ rowCount?: number;
316
+ };
317
+
318
+ export declare type SemaphorRecordsQueryResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorQueryState & SemaphorRecordsPayload<TRecord> & {
319
+ id?: string;
320
+ intent?: SemaphorRecordsIntent;
321
+ };
322
+
323
+ export declare type SemaphorRecordsQuerySpec = SemaphorRecordsBaseQuerySpec & SemaphorRecordsSelectorSpec;
324
+
325
+ declare type SemaphorRecordsSelectorSpec = {
326
+ fields: SemaphorNonEmptyArray<SemaphorRecordsField>;
327
+ };
328
+
329
+ export declare type SemaphorResultColumn = {
330
+ /**
331
+ * Stable row accessor for this result. Consumers should read values with
332
+ * `row[column.key]`; labels are display-only and may change.
333
+ */
334
+ key: string;
335
+ /**
336
+ * Semantic/source field name before result-key disambiguation.
337
+ */
338
+ name: string;
339
+ /**
340
+ * Human-facing display label.
341
+ */
342
+ label: string;
343
+ role?: SemaphorFieldRef['role'];
344
+ dataType?: SemaphorFieldRef['dataType'];
345
+ aggregate?: SemaphorFieldRef['aggregate'];
346
+ source?: SemaphorFieldRef['source'];
347
+ };
348
+
349
+ export declare type SemaphorScalar = string | number | boolean | null;
350
+
336
351
  declare type SemaphorSourceRef = {
337
352
  kind: 'semantic';
338
353
  domainId: string;
@@ -382,37 +397,37 @@ declare type SemaphorTimeWindow = {
382
397
  completeness?: 'include_partial' | 'complete_periods';
383
398
  };
384
399
 
385
- export declare function toSemaphorActiveInputSnapshots(inputs: SemaphorDataAppInputReference[] | undefined): SemaphorDataAppInputSnapshot[];
400
+ export declare function toSemaphorActiveInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
386
401
 
387
- export declare function toSemaphorInputBinding(input: SemaphorDataAppInputReference): SemaphorInputBinding;
402
+ export declare function toSemaphorInputBinding(input: SemaphorInputReference): SemaphorInputBinding;
388
403
 
389
- export declare function toSemaphorInputBindings(inputs: SemaphorDataAppInputReference[] | undefined): SemaphorInputBinding[] | undefined;
404
+ export declare function toSemaphorInputBindings(inputs: SemaphorInputReference[] | undefined): SemaphorInputBinding[] | undefined;
390
405
 
391
- export declare function toSemaphorInputOptionsIntent(spec: SemaphorDataAppInputOptionsSpec): Extract<SemaphorAnalyticsIntent, {
406
+ export declare function toSemaphorInputOptionsIntent(spec: SemaphorInputOptionsQuerySpec): Extract<SemaphorAnalyticsIntent, {
392
407
  kind: 'inputOptions';
393
408
  }>;
394
409
 
395
- export declare function toSemaphorInputSnapshots(inputs: SemaphorDataAppInputReference[] | undefined): SemaphorDataAppInputSnapshot[];
410
+ export declare function toSemaphorInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
396
411
 
397
- export declare function toSemaphorInputSpec<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue>(spec: SemaphorDataAppInputSpec<TValue>): SemaphorInputBinding & {
398
- kind: SemaphorDataAppInputSpec['kind'];
412
+ export declare function toSemaphorInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: SemaphorInputSpec<TValue>): SemaphorInputBinding & {
413
+ kind: SemaphorInputSpec['kind'];
399
414
  label?: string;
400
415
  field?: SemaphorFieldRef;
401
416
  operator?: SemaphorInputOperator;
402
417
  };
403
418
 
404
- export declare function toSemaphorMetricIntent(spec: SemaphorDataAppMetricSpec): SemaphorMetricIntent;
419
+ export declare function toSemaphorMetricIntent(spec: SemaphorMetricQuerySpec): SemaphorMetricIntent;
405
420
 
406
- export declare function toSemaphorRecordsIntent(spec: SemaphorDataAppRecordsSpec): SemaphorRecordsIntent;
421
+ export declare function toSemaphorRecordsIntent(spec: SemaphorRecordsQuerySpec): SemaphorRecordsIntent;
407
422
 
408
423
  export declare function useSemaphorDataAppRuntime(): SemaphorDataAppRuntime;
409
424
 
410
- export declare function useSemaphorInput<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue>(spec: SemaphorDataAppInputSpec<TValue>): SemaphorDataAppInputHandle;
425
+ export declare function useSemaphorInput<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: SemaphorInputSpec<TValue>): SemaphorInputHandle;
411
426
 
412
- export declare function useSemaphorInputOptions(spec: SemaphorDataAppInputOptionsSpec): SemaphorDataAppInputOptionsResult;
427
+ export declare function useSemaphorInputOptions(spec: SemaphorInputOptionsQuerySpec): SemaphorInputOptionsQueryResult;
413
428
 
414
- export declare function useSemaphorMetric(spec: SemaphorDataAppMetricSpec): SemaphorDataAppMetricResult;
429
+ export declare function useSemaphorMetric(spec: SemaphorMetricQuerySpec): SemaphorMetricQueryResult;
415
430
 
416
- export declare function useSemaphorRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(spec: SemaphorDataAppRecordsSpec): SemaphorDataAppRecordsResult<TRecord>;
431
+ export declare function useSemaphorRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(spec: SemaphorRecordsQuerySpec): SemaphorRecordsQueryResult<TRecord>;
417
432
 
418
433
  export { }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.345",
8
+ "version": "0.1.346",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",