react-semaphor 0.1.335 → 0.1.337
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 +67 -45
- package/dist/chunks/{validators-BuaRUBQI.js → validators-BOqiGymD.js} +247 -148
- package/dist/chunks/validators-BtFXY3S_.js +2 -0
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +567 -545
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +89 -80
- package/dist/types/analytics-protocol.d.ts +100 -6
- package/dist/types/dashboard-authoring.d.ts +20 -5
- package/dist/types/data-app-builder.d.ts +17 -4
- package/dist/types/data-app-sdk.d.ts +19 -6
- package/dist/types/main.d.ts +21 -4
- package/package.json +1 -1
- package/dist/chunks/validators-x74uYpnG.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../chunks/index-BxM99sFL.js"),u=require("react"),P=require("react/jsx-runtime"),K=require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../chunks/index-BxM99sFL.js"),u=require("react"),P=require("react/jsx-runtime"),K=require("../chunks/validators-BtFXY3S_.js");function x(t){var e;return{version:1,kind:"metric",id:t.id,label:t.label,source:k(t),metrics:U(t),primaryMetric:t.primaryMetric||t.metrics[0],dateField:t.dateField?m(t.dateField,"date"):void 0,timeGrain:t.timeGrain,dimensions:(e=t.dimensions)==null?void 0:e.map(o=>m(o,"dimension")),comparison:L(t.comparison),inputs:g(t.inputs),limit:t.limit}}function U(t){return Array.from(new Set(t.metrics.filter(e=>typeof e=="string"&&e.trim().length>0)))}function R(t){if("sort"in t)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!j(t))throw new Error("useSemaphorRecords needs at least one field, dimension, or measure.");const e=z(t.fields,t.dimensions,t.measures);return{version:1,kind:"records",id:t.id,label:t.label,source:k(t),fields:e,measures:t.measures,dateField:t.dateField?m(t.dateField,"date"):void 0,timeGrain:t.timeGrain,orderBy:t.orderBy,inputs:g(t.inputs),limit:t.limit}}function q(t){return{version:1,kind:"inputOptions",id:t.id,label:t.label,source:k(t),field:m(t.field,"dimension"),search:t.search,limit:t.limit}}function M(t){if("toAnalyticsInput"in t){const e=t.toAnalyticsInput();return{inputId:e.inputId,field:e.field}}return{inputId:t.inputId,field:t.field}}function N(t){const e=g(t);return e.length>0?e:void 0}function O(t){return(t||[]).map(V)}function A(t){return O(t).filter(e=>e.isActive)}function w(t){return t.kind==="filter"?{inputId:t.id,kind:t.kind,label:t.label,field:m(t.field,"dimension"),operator:t.operator||"in",source:t.source}:{inputId:t.id,kind:t.kind,label:t.label}}function $(t=[]){return t.map(e=>typeof e=="object"?e:{label:String(e),value:e})}function S(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="string"?t.trim().length>0:!0}function V(t){return"toAnalyticsInput"in t?t.toAnalyticsInput():"kind"in t&&"isActive"in t?t:{...t,kind:"filter",isActive:S(t.value),value:t.value}}function k(t){if("source"in t&&t.source)return t.source;const e=t.datasetName||t.dataset;if(!e)throw new Error("Semaphor data app source needs datasetName or dataset.");return{kind:"semantic",domainId:t.domainId,datasetName:e,datasetId:t.datasetId,connectionId:t.connectionId,label:t.sourceLabel}}function j(t){var e,o,n;return!!((e=t.fields)!=null&&e.length||(o=t.dimensions)!=null&&o.length||(n=t.measures)!=null&&n.length)}function F(t){return!!(t!=null&&t.length)}function z(t,e,o){const n=[],r=new Set,a=i=>{const l=`${i.role||""}:${i.name}`;r.has(l)||(r.add(l),n.push(i))};return F(t)&&t.map(i=>m(i)).forEach(a),e==null||e.map(i=>m(i,"dimension")).forEach(a),o==null||o.map(i=>m(i,"measure")).forEach(a),n}function m(t,e){return typeof t=="string"?e?{name:t,role:e}:{name:t}:{...t,role:t.role||e}}function g(t){return(t||[]).map(M)}function L(t){if(!(!t||t==="none"))return typeof t=="object"?t:t==="same_period_last_year"?{kind:"previous_year"}:{kind:t}}function B(){return{executeMetric:(t,e)=>y(t,e),executeRecords:(t,e)=>y(t,e),executeInputOptions:(t,e)=>y(t,e)}}async function y(t,e){if(!e.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const o=await fetch(J(e),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:JSON.stringify({intent:t,activeInputs:e.activeInputs,resultShape:t.kind})}),n=await Q(o);if(!o.ok||n.error)throw new Error(n.error||`Semaphor Data App execution failed with status ${o.status}.`);return n}async function Q(t){const e=await t.text().catch(()=>"");if(!e.trim())return t.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(e)}catch{return t.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:e}:{error:G(t,e),details:e}}}function G(t,e){const o=t.statusText?` ${t.statusText}`:"",n=e.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${t.status}${o}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${t.status}${o}.`}function J(t){const e=W(t).replace(/\/+$/,"");return e?e.endsWith("/api")?`${e}/v1/data-app/execute`:`${e}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function W(t){if(t.apiBaseUrl)return t.apiBaseUrl;if(!t.token)return"";try{return T.jwtDecode(t.token).apiServiceUrl||""}catch{return""}}const D=u.createContext({});function _(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function C(){return u.useContext(D)}function H({token:t,apiBaseUrl:e,executor:o,children:n}){var d;const r=_(),a=((d=r==null?void 0:r.authToken)==null?void 0:d.accessToken)||t,i=(r==null?void 0:r.dataApiBaseUrl)||(r==null?void 0:r.apiBaseUrl)||e,l=u.useMemo(()=>B(),[]),s=o||l,p=u.useMemo(()=>({token:a,apiBaseUrl:i,executor:s}),[i,s,a]);return P.jsx(D.Provider,{value:p,children:n})}const I={value:null},X={records:[]},v={options:[]};function Y(t){const e=A(t.inputs);try{const o=x(t),n=b(o);return n?{error:n,activeInputs:e,queryKey:c(void 0,e,n),idleData:I}:{intent:o,error:null,activeInputs:e,queryKey:c(o,e),idleData:I}}catch(o){const n=h(o);return{error:n,activeInputs:e,queryKey:c(void 0,e,n),idleData:I}}}function Z(t){const e=A(t.inputs),o=X;try{const n=R(t),r=b(n);return r?{error:r,activeInputs:e,queryKey:c(void 0,e,r),idleData:o}:{intent:n,error:null,activeInputs:e,queryKey:c(n,e),idleData:o}}catch(n){const r=h(n);return{error:r,activeInputs:e,queryKey:c(void 0,e,r),idleData:o}}}function tt(t){try{const e=q(t),o=b(e);return o?{error:o,queryKey:c(void 0,void 0,o),idleData:v}:{intent:e,error:null,queryKey:c(e),idleData:v}}catch(e){const o=h(e);return{error:o,queryKey:c(void 0,void 0,o),idleData:v}}}function h(t){return t instanceof Error?t:new Error(String(t))}function b(t){const e=K.validateSemaphorAnalyticsIntent(t);if(e.ok)return null;const o=e.errors.map(n=>n.path?`${n.code} at ${n.path}: ${n.message}`:`${n.code}: ${n.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${o}`)}function c(t,e,o){return JSON.stringify({intent:t,activeInputs:e,error:o==null?void 0:o.message})}function et(t){const[e,o]=u.useState(t.defaultValue),n=Object.prototype.hasOwnProperty.call(t,"value"),r=n?t.value:e,a=u.useMemo(()=>$(t.options),[t.options]),i=u.useCallback(s=>{var d;const p=s;(d=t.onValueChange)==null||d.call(t,p),n||o(p)},[n,t]),l=u.useCallback(()=>i(void 0),[i]);return u.useMemo(()=>{const s=w(t);return{id:t.id,kind:t.kind,label:t.label,field:s.field,operator:s.operator,source:s.source,controlRole:t.kind==="control"?t.role:void 0,value:r,options:a,isActive:S(r),setValue:i,clear:l,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:t.kind,label:t.label,value:r,isActive:S(r),operator:s.operator,source:s.source,controlRole:t.kind==="control"?t.role:void 0})}},[l,a,i,t,r])}function rt(t){const e=u.useMemo(()=>Y(t),[t]),o=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeMetric(e.intent,a):void 0},[e.intent]),n=E(e.queryKey,o,e.idleData,e.activeInputs),r=e.error?e.idleData:n.data;return{id:t.id,intent:e.intent,value:(r==null?void 0:r.value)??null,metrics:r==null?void 0:r.metrics,comparisonValue:r==null?void 0:r.comparisonValue,delta:r==null?void 0:r.delta,deltaPercent:r==null?void 0:r.deltaPercent,records:r==null?void 0:r.records,status:e.error?"error":n.status,isLoading:!e.error&&n.status==="loading",error:e.error||n.error}}function nt(t){const e=u.useMemo(()=>Z(t),[t]),o=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeRecords(e.intent,a):void 0},[e.intent]),n=E(e.queryKey,o,e.idleData,e.activeInputs),r=e.error?e.idleData:n.data;return{id:t.id,intent:e.intent,records:(r==null?void 0:r.records)||[],columns:r==null?void 0:r.columns,rowCount:r==null?void 0:r.rowCount,status:e.error?"error":n.status,isLoading:!e.error&&n.status==="loading",error:e.error||n.error}}function ot(t){const e=u.useMemo(()=>tt(t),[t]),o=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeInputOptions(e.intent,a):void 0},[e.intent]),n=E(e.queryKey,o,e.idleData),r=e.error?e.idleData:n.data;return{id:t.id,intent:e.intent,options:(r==null?void 0:r.options)||[],status:e.error?"error":n.status,isLoading:!e.error&&n.status==="loading",error:e.error||n.error}}function E(t,e,o,n){const r=C(),a=u.useRef(e),i=u.useRef(n),[l,s]=u.useState({status:"idle",data:o,error:null});return a.current=e,i.current=n,u.useEffect(()=>{let p;try{p=a.current({...r,activeInputs:i.current})}catch(f){s({status:"error",data:o,error:h(f)});return}if(!p){s({status:"idle",data:o,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:o,error:h(f)})}),()=>{d=!0}},[o,t,r]),l}exports.SemaphorDataAppContext=D;exports.SemaphorDataAppProvider=H;exports.createSemaphorDataAppExecutor=B;exports.hasSemaphorInputValue=S;exports.normalizeSemaphorInputOptions=$;exports.readWindowRuntime=_;exports.toSemaphorActiveInputSnapshots=A;exports.toSemaphorInputBinding=M;exports.toSemaphorInputBindings=N;exports.toSemaphorInputOptionsIntent=q;exports.toSemaphorInputSnapshots=O;exports.toSemaphorInputSpec=w;exports.toSemaphorMetricIntent=x;exports.toSemaphorRecordsIntent=R;exports.useSemaphorDataAppRuntime=C;exports.useSemaphorInput=et;exports.useSemaphorInputOptions=ot;exports.useSemaphorMetric=rt;exports.useSemaphorRecords=nt;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { j as w } from "../chunks/index-CuHybtft.js";
|
|
2
|
+
import { createContext as $, useContext as O, useMemo as p, useState as x, useCallback as h, useRef as b, useEffect as _ } from "react";
|
|
3
3
|
import { jsx as B } from "react/jsx-runtime";
|
|
4
|
-
import { v as T } from "../chunks/validators-
|
|
5
|
-
function
|
|
4
|
+
import { v as T } from "../chunks/validators-BOqiGymD.js";
|
|
5
|
+
function M(t) {
|
|
6
6
|
var r;
|
|
7
7
|
return {
|
|
8
8
|
version: 1,
|
|
@@ -10,26 +10,35 @@ function K(t) {
|
|
|
10
10
|
id: t.id,
|
|
11
11
|
label: t.label,
|
|
12
12
|
source: k(t),
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
metrics: K(t),
|
|
14
|
+
primaryMetric: t.primaryMetric || t.metrics[0],
|
|
15
15
|
dateField: t.dateField ? f(t.dateField, "date") : void 0,
|
|
16
16
|
timeGrain: t.timeGrain,
|
|
17
17
|
dimensions: (r = t.dimensions) == null ? void 0 : r.map((o) => f(o, "dimension")),
|
|
18
|
-
comparison:
|
|
18
|
+
comparison: G(t.comparison),
|
|
19
19
|
inputs: g(t.inputs),
|
|
20
20
|
limit: t.limit
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
function K(t) {
|
|
24
|
+
return Array.from(
|
|
25
|
+
new Set(
|
|
26
|
+
t.metrics.filter(
|
|
27
|
+
(r) => typeof r == "string" && r.trim().length > 0
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
23
32
|
function C(t) {
|
|
24
33
|
if ("sort" in t)
|
|
25
34
|
throw new Error(
|
|
26
35
|
"useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
|
|
27
36
|
);
|
|
28
|
-
if (!
|
|
37
|
+
if (!L(t))
|
|
29
38
|
throw new Error(
|
|
30
39
|
"useSemaphorRecords needs at least one field, dimension, or measure."
|
|
31
40
|
);
|
|
32
|
-
const r =
|
|
41
|
+
const r = Q(
|
|
33
42
|
t.fields,
|
|
34
43
|
t.dimensions,
|
|
35
44
|
t.measures
|
|
@@ -74,17 +83,17 @@ function U(t) {
|
|
|
74
83
|
field: t.field
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
|
-
function
|
|
86
|
+
function lt(t) {
|
|
78
87
|
const r = g(t);
|
|
79
88
|
return r.length > 0 ? r : void 0;
|
|
80
89
|
}
|
|
81
|
-
function
|
|
82
|
-
return (t || []).map(
|
|
90
|
+
function N(t) {
|
|
91
|
+
return (t || []).map(j);
|
|
83
92
|
}
|
|
84
93
|
function R(t) {
|
|
85
|
-
return
|
|
94
|
+
return N(t).filter((r) => r.isActive);
|
|
86
95
|
}
|
|
87
|
-
function
|
|
96
|
+
function V(t) {
|
|
88
97
|
return t.kind === "filter" ? {
|
|
89
98
|
inputId: t.id,
|
|
90
99
|
kind: t.kind,
|
|
@@ -98,7 +107,7 @@ function N(t) {
|
|
|
98
107
|
label: t.label
|
|
99
108
|
};
|
|
100
109
|
}
|
|
101
|
-
function
|
|
110
|
+
function F(t = []) {
|
|
102
111
|
return t.map(
|
|
103
112
|
(r) => typeof r == "object" ? r : {
|
|
104
113
|
label: String(r),
|
|
@@ -109,7 +118,7 @@ function V(t = []) {
|
|
|
109
118
|
function A(t) {
|
|
110
119
|
return t == null ? !1 : Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.trim().length > 0 : !0;
|
|
111
120
|
}
|
|
112
|
-
function
|
|
121
|
+
function j(t) {
|
|
113
122
|
return "toAnalyticsInput" in t ? t.toAnalyticsInput() : "kind" in t && "isActive" in t ? t : {
|
|
114
123
|
...t,
|
|
115
124
|
kind: "filter",
|
|
@@ -134,19 +143,19 @@ function k(t) {
|
|
|
134
143
|
label: t.sourceLabel
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
|
-
function
|
|
146
|
+
function L(t) {
|
|
138
147
|
var r, o, n;
|
|
139
148
|
return !!((r = t.fields) != null && r.length || (o = t.dimensions) != null && o.length || (n = t.measures) != null && n.length);
|
|
140
149
|
}
|
|
141
|
-
function
|
|
150
|
+
function z(t) {
|
|
142
151
|
return !!(t != null && t.length);
|
|
143
152
|
}
|
|
144
|
-
function
|
|
153
|
+
function Q(t, r, o) {
|
|
145
154
|
const n = [], e = /* @__PURE__ */ new Set(), a = (i) => {
|
|
146
155
|
const s = `${i.role || ""}:${i.name}`;
|
|
147
156
|
e.has(s) || (e.add(s), n.push(i));
|
|
148
157
|
};
|
|
149
|
-
return
|
|
158
|
+
return z(t) && t.map((i) => f(i)).forEach(a), r == null || r.map((i) => f(i, "dimension")).forEach(a), o == null || o.map((i) => f(i, "measure")).forEach(a), n;
|
|
150
159
|
}
|
|
151
160
|
function f(t, r) {
|
|
152
161
|
return typeof t == "string" ? r ? { name: t, role: r } : { name: t } : {
|
|
@@ -157,11 +166,11 @@ function f(t, r) {
|
|
|
157
166
|
function g(t) {
|
|
158
167
|
return (t || []).map(U);
|
|
159
168
|
}
|
|
160
|
-
function
|
|
169
|
+
function G(t) {
|
|
161
170
|
if (!(!t || t === "none"))
|
|
162
171
|
return typeof t == "object" ? t : t === "same_period_last_year" ? { kind: "previous_year" } : { kind: t };
|
|
163
172
|
}
|
|
164
|
-
function
|
|
173
|
+
function J() {
|
|
165
174
|
return {
|
|
166
175
|
executeMetric: (t, r) => v(t, r),
|
|
167
176
|
executeRecords: (t, r) => v(t, r),
|
|
@@ -171,7 +180,7 @@ function G() {
|
|
|
171
180
|
async function v(t, r) {
|
|
172
181
|
if (!r.token)
|
|
173
182
|
throw new Error("SemaphorDataAppProvider needs a token to execute queries.");
|
|
174
|
-
const o = await fetch(
|
|
183
|
+
const o = await fetch(X(r), {
|
|
175
184
|
method: "POST",
|
|
176
185
|
headers: {
|
|
177
186
|
"Content-Type": "application/json",
|
|
@@ -182,14 +191,14 @@ async function v(t, r) {
|
|
|
182
191
|
activeInputs: r.activeInputs,
|
|
183
192
|
resultShape: t.kind
|
|
184
193
|
})
|
|
185
|
-
}), n = await
|
|
194
|
+
}), n = await H(o);
|
|
186
195
|
if (!o.ok || n.error)
|
|
187
196
|
throw new Error(
|
|
188
197
|
n.error || `Semaphor Data App execution failed with status ${o.status}.`
|
|
189
198
|
);
|
|
190
199
|
return n;
|
|
191
200
|
}
|
|
192
|
-
async function
|
|
201
|
+
async function H(t) {
|
|
193
202
|
const r = await t.text().catch(() => "");
|
|
194
203
|
if (!r.trim())
|
|
195
204
|
return t.ok ? {
|
|
@@ -202,36 +211,36 @@ async function J(t) {
|
|
|
202
211
|
error: "Semaphor Data App execution returned invalid JSON.",
|
|
203
212
|
details: r
|
|
204
213
|
} : {
|
|
205
|
-
error:
|
|
214
|
+
error: W(t, r),
|
|
206
215
|
details: r
|
|
207
216
|
};
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
|
-
function
|
|
219
|
+
function W(t, r) {
|
|
211
220
|
const o = t.statusText ? ` ${t.statusText}` : "", n = r.replace(/\s+/g, " ").trim();
|
|
212
221
|
return n ? `Semaphor Data App execution failed with status ${t.status}${o}: ${n.slice(0, 240)}` : `Semaphor Data App execution failed with status ${t.status}${o}.`;
|
|
213
222
|
}
|
|
214
|
-
function
|
|
215
|
-
const r =
|
|
223
|
+
function X(t) {
|
|
224
|
+
const r = Y(t).replace(/\/+$/, "");
|
|
216
225
|
return r ? r.endsWith("/api") ? `${r}/v1/data-app/execute` : `${r}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
|
|
217
226
|
}
|
|
218
|
-
function
|
|
227
|
+
function Y(t) {
|
|
219
228
|
if (t.apiBaseUrl)
|
|
220
229
|
return t.apiBaseUrl;
|
|
221
230
|
if (!t.token)
|
|
222
231
|
return "";
|
|
223
232
|
try {
|
|
224
|
-
return
|
|
233
|
+
return w(t.token).apiServiceUrl || "";
|
|
225
234
|
} catch {
|
|
226
235
|
return "";
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
|
-
const q =
|
|
230
|
-
function
|
|
238
|
+
const q = $({});
|
|
239
|
+
function Z() {
|
|
231
240
|
if (!(typeof window > "u"))
|
|
232
241
|
return window.__SEMAPHOR_DATA_APP_RUNTIME__;
|
|
233
242
|
}
|
|
234
|
-
function
|
|
243
|
+
function tt() {
|
|
235
244
|
return O(q);
|
|
236
245
|
}
|
|
237
246
|
function dt({
|
|
@@ -240,8 +249,8 @@ function dt({
|
|
|
240
249
|
executor: o,
|
|
241
250
|
children: n
|
|
242
251
|
}) {
|
|
243
|
-
var
|
|
244
|
-
const e =
|
|
252
|
+
var l;
|
|
253
|
+
const e = Z(), a = ((l = e == null ? void 0 : e.authToken) == null ? void 0 : l.accessToken) || t, i = (e == null ? void 0 : e.dataApiBaseUrl) || (e == null ? void 0 : e.apiBaseUrl) || r, s = p(() => J(), []), u = o || s, c = p(
|
|
245
254
|
() => ({
|
|
246
255
|
token: a,
|
|
247
256
|
apiBaseUrl: i,
|
|
@@ -251,21 +260,21 @@ function dt({
|
|
|
251
260
|
);
|
|
252
261
|
return /* @__PURE__ */ B(q.Provider, { value: c, children: n });
|
|
253
262
|
}
|
|
254
|
-
const I = { value: null },
|
|
255
|
-
function
|
|
263
|
+
const I = { value: null }, rt = { records: [] }, S = { options: [] };
|
|
264
|
+
function et(t) {
|
|
256
265
|
const r = R(t.inputs);
|
|
257
266
|
try {
|
|
258
|
-
const o =
|
|
267
|
+
const o = M(t), n = D(o);
|
|
259
268
|
return n ? {
|
|
260
269
|
error: n,
|
|
261
270
|
activeInputs: r,
|
|
262
|
-
queryKey:
|
|
271
|
+
queryKey: d(void 0, r, n),
|
|
263
272
|
idleData: I
|
|
264
273
|
} : {
|
|
265
274
|
intent: o,
|
|
266
275
|
error: null,
|
|
267
276
|
activeInputs: r,
|
|
268
|
-
queryKey:
|
|
277
|
+
queryKey: d(o, r),
|
|
269
278
|
idleData: I
|
|
270
279
|
};
|
|
271
280
|
} catch (o) {
|
|
@@ -273,25 +282,25 @@ function rt(t) {
|
|
|
273
282
|
return {
|
|
274
283
|
error: n,
|
|
275
284
|
activeInputs: r,
|
|
276
|
-
queryKey:
|
|
285
|
+
queryKey: d(void 0, r, n),
|
|
277
286
|
idleData: I
|
|
278
287
|
};
|
|
279
288
|
}
|
|
280
289
|
}
|
|
281
|
-
function
|
|
282
|
-
const r = R(t.inputs), o =
|
|
290
|
+
function nt(t) {
|
|
291
|
+
const r = R(t.inputs), o = rt;
|
|
283
292
|
try {
|
|
284
293
|
const n = C(t), e = D(n);
|
|
285
294
|
return e ? {
|
|
286
295
|
error: e,
|
|
287
296
|
activeInputs: r,
|
|
288
|
-
queryKey:
|
|
297
|
+
queryKey: d(void 0, r, e),
|
|
289
298
|
idleData: o
|
|
290
299
|
} : {
|
|
291
300
|
intent: n,
|
|
292
301
|
error: null,
|
|
293
302
|
activeInputs: r,
|
|
294
|
-
queryKey:
|
|
303
|
+
queryKey: d(n, r),
|
|
295
304
|
idleData: o
|
|
296
305
|
};
|
|
297
306
|
} catch (n) {
|
|
@@ -299,29 +308,29 @@ function et(t) {
|
|
|
299
308
|
return {
|
|
300
309
|
error: e,
|
|
301
310
|
activeInputs: r,
|
|
302
|
-
queryKey:
|
|
311
|
+
queryKey: d(void 0, r, e),
|
|
303
312
|
idleData: o
|
|
304
313
|
};
|
|
305
314
|
}
|
|
306
315
|
}
|
|
307
|
-
function
|
|
316
|
+
function ot(t) {
|
|
308
317
|
try {
|
|
309
318
|
const r = P(t), o = D(r);
|
|
310
319
|
return o ? {
|
|
311
320
|
error: o,
|
|
312
|
-
queryKey:
|
|
321
|
+
queryKey: d(void 0, void 0, o),
|
|
313
322
|
idleData: S
|
|
314
323
|
} : {
|
|
315
324
|
intent: r,
|
|
316
325
|
error: null,
|
|
317
|
-
queryKey:
|
|
326
|
+
queryKey: d(r),
|
|
318
327
|
idleData: S
|
|
319
328
|
};
|
|
320
329
|
} catch (r) {
|
|
321
330
|
const o = y(r);
|
|
322
331
|
return {
|
|
323
332
|
error: o,
|
|
324
|
-
queryKey:
|
|
333
|
+
queryKey: d(void 0, void 0, o),
|
|
325
334
|
idleData: S
|
|
326
335
|
};
|
|
327
336
|
}
|
|
@@ -338,27 +347,27 @@ function D(t) {
|
|
|
338
347
|
).join("; ");
|
|
339
348
|
return new Error(`Invalid Semaphor analytics intent. ${o}`);
|
|
340
349
|
}
|
|
341
|
-
function
|
|
350
|
+
function d(t, r, o) {
|
|
342
351
|
return JSON.stringify({
|
|
343
352
|
intent: t,
|
|
344
353
|
activeInputs: r,
|
|
345
354
|
error: o == null ? void 0 : o.message
|
|
346
355
|
});
|
|
347
356
|
}
|
|
348
|
-
function
|
|
357
|
+
function ct(t) {
|
|
349
358
|
const [r, o] = x(t.defaultValue), n = Object.prototype.hasOwnProperty.call(t, "value"), e = n ? t.value : r, a = p(
|
|
350
|
-
() =>
|
|
359
|
+
() => F(t.options),
|
|
351
360
|
[t.options]
|
|
352
361
|
), i = h(
|
|
353
362
|
(u) => {
|
|
354
|
-
var
|
|
363
|
+
var l;
|
|
355
364
|
const c = u;
|
|
356
|
-
(
|
|
365
|
+
(l = t.onValueChange) == null || l.call(t, c), n || o(c);
|
|
357
366
|
},
|
|
358
367
|
[n, t]
|
|
359
368
|
), s = h(() => i(void 0), [i]);
|
|
360
369
|
return p(() => {
|
|
361
|
-
const u =
|
|
370
|
+
const u = V(t);
|
|
362
371
|
return {
|
|
363
372
|
id: t.id,
|
|
364
373
|
kind: t.kind,
|
|
@@ -386,8 +395,8 @@ function lt(t) {
|
|
|
386
395
|
};
|
|
387
396
|
}, [s, a, i, t, e]);
|
|
388
397
|
}
|
|
389
|
-
function
|
|
390
|
-
const r = p(() =>
|
|
398
|
+
function ft(t) {
|
|
399
|
+
const r = p(() => et(t), [t]), o = h(
|
|
391
400
|
(a) => {
|
|
392
401
|
var i;
|
|
393
402
|
return r.intent ? (i = a.executor) == null ? void 0 : i.executeMetric(r.intent, a) : void 0;
|
|
@@ -413,8 +422,8 @@ function ct(t) {
|
|
|
413
422
|
error: r.error || n.error
|
|
414
423
|
};
|
|
415
424
|
}
|
|
416
|
-
function
|
|
417
|
-
const r = p(() =>
|
|
425
|
+
function mt(t) {
|
|
426
|
+
const r = p(() => nt(t), [t]), o = h(
|
|
418
427
|
(a) => {
|
|
419
428
|
var i;
|
|
420
429
|
return r.intent ? (i = a.executor) == null ? void 0 : i.executeRecords(r.intent, a) : void 0;
|
|
@@ -437,8 +446,8 @@ function ft(t) {
|
|
|
437
446
|
error: r.error || n.error
|
|
438
447
|
};
|
|
439
448
|
}
|
|
440
|
-
function
|
|
441
|
-
const r = p(() =>
|
|
449
|
+
function pt(t) {
|
|
450
|
+
const r = p(() => ot(t), [t]), o = h(
|
|
442
451
|
(a) => {
|
|
443
452
|
var i;
|
|
444
453
|
return r.intent ? (i = a.executor) == null ? void 0 : i.executeInputOptions(r.intent, a) : void 0;
|
|
@@ -459,7 +468,7 @@ function mt(t) {
|
|
|
459
468
|
};
|
|
460
469
|
}
|
|
461
470
|
function E(t, r, o, n) {
|
|
462
|
-
const e =
|
|
471
|
+
const e = tt(), a = b(r), i = b(n), [s, u] = x({
|
|
463
472
|
status: "idle",
|
|
464
473
|
data: o,
|
|
465
474
|
error: null
|
|
@@ -483,42 +492,42 @@ function E(t, r, o, n) {
|
|
|
483
492
|
u({ status: "idle", data: o, error: null });
|
|
484
493
|
return;
|
|
485
494
|
}
|
|
486
|
-
let
|
|
495
|
+
let l = !1;
|
|
487
496
|
return u((m) => ({
|
|
488
497
|
status: "loading",
|
|
489
498
|
data: m.data,
|
|
490
499
|
error: null
|
|
491
500
|
})), c.then((m) => {
|
|
492
|
-
|
|
501
|
+
l || u({ status: "success", data: m, error: null });
|
|
493
502
|
}).catch((m) => {
|
|
494
|
-
|
|
503
|
+
l || u({
|
|
495
504
|
status: "error",
|
|
496
505
|
data: o,
|
|
497
506
|
error: y(m)
|
|
498
507
|
});
|
|
499
508
|
}), () => {
|
|
500
|
-
|
|
509
|
+
l = !0;
|
|
501
510
|
};
|
|
502
511
|
}, [o, t, e]), s;
|
|
503
512
|
}
|
|
504
513
|
export {
|
|
505
514
|
q as SemaphorDataAppContext,
|
|
506
515
|
dt as SemaphorDataAppProvider,
|
|
507
|
-
|
|
516
|
+
J as createSemaphorDataAppExecutor,
|
|
508
517
|
A as hasSemaphorInputValue,
|
|
509
|
-
|
|
510
|
-
|
|
518
|
+
F as normalizeSemaphorInputOptions,
|
|
519
|
+
Z as readWindowRuntime,
|
|
511
520
|
R as toSemaphorActiveInputSnapshots,
|
|
512
521
|
U as toSemaphorInputBinding,
|
|
513
|
-
|
|
522
|
+
lt as toSemaphorInputBindings,
|
|
514
523
|
P as toSemaphorInputOptionsIntent,
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
524
|
+
N as toSemaphorInputSnapshots,
|
|
525
|
+
V as toSemaphorInputSpec,
|
|
526
|
+
M as toSemaphorMetricIntent,
|
|
518
527
|
C as toSemaphorRecordsIntent,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
528
|
+
tt as useSemaphorDataAppRuntime,
|
|
529
|
+
ct as useSemaphorInput,
|
|
530
|
+
pt as useSemaphorInputOptions,
|
|
531
|
+
ft as useSemaphorMetric,
|
|
532
|
+
mt as useSemaphorRecords
|
|
524
533
|
};
|
|
@@ -97,7 +97,8 @@ export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
|
97
97
|
readonly connectionId: "conn_sales";
|
|
98
98
|
readonly label: "Orders";
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
metrics: string[];
|
|
101
|
+
primaryMetric: string;
|
|
101
102
|
comparison: {
|
|
102
103
|
kind: "previous_period";
|
|
103
104
|
};
|
|
@@ -189,7 +190,8 @@ export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
|
189
190
|
readonly connectionId: "conn_sales";
|
|
190
191
|
readonly label: "Orders";
|
|
191
192
|
};
|
|
192
|
-
|
|
193
|
+
metrics: string[];
|
|
194
|
+
primaryMetric: string;
|
|
193
195
|
dateField: {
|
|
194
196
|
name: string;
|
|
195
197
|
role: "date";
|
|
@@ -201,6 +203,46 @@ export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
|
201
203
|
};
|
|
202
204
|
limit: number;
|
|
203
205
|
};
|
|
206
|
+
inboundSupplierConcentration: {
|
|
207
|
+
version: 1;
|
|
208
|
+
kind: "metric";
|
|
209
|
+
id: string;
|
|
210
|
+
label: string;
|
|
211
|
+
source: {
|
|
212
|
+
readonly kind: "semantic";
|
|
213
|
+
readonly domainId: "domain_sales";
|
|
214
|
+
readonly datasetName: "orders";
|
|
215
|
+
readonly connectionId: "conn_sales";
|
|
216
|
+
readonly label: "Orders";
|
|
217
|
+
};
|
|
218
|
+
metrics: string[];
|
|
219
|
+
primaryMetric: string;
|
|
220
|
+
dateField: {
|
|
221
|
+
name: string;
|
|
222
|
+
role: "date";
|
|
223
|
+
dataType: "date";
|
|
224
|
+
};
|
|
225
|
+
timeWindow: {
|
|
226
|
+
unit: "month";
|
|
227
|
+
value: number;
|
|
228
|
+
anchor: "latest_available";
|
|
229
|
+
};
|
|
230
|
+
dimensions: {
|
|
231
|
+
name: string;
|
|
232
|
+
role: "dimension";
|
|
233
|
+
dataType: "number";
|
|
234
|
+
}[];
|
|
235
|
+
filters: {
|
|
236
|
+
field: {
|
|
237
|
+
name: string;
|
|
238
|
+
role: "dimension";
|
|
239
|
+
dataType: "string";
|
|
240
|
+
};
|
|
241
|
+
operator: "=";
|
|
242
|
+
value: string;
|
|
243
|
+
}[];
|
|
244
|
+
limit: number;
|
|
245
|
+
};
|
|
204
246
|
boundedSqlRanking: {
|
|
205
247
|
version: 1;
|
|
206
248
|
kind: "sql";
|
|
@@ -229,6 +271,17 @@ export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
|
229
271
|
};
|
|
230
272
|
};
|
|
231
273
|
|
|
274
|
+
export declare type SemaphorAgentFilterInput = {
|
|
275
|
+
id?: string;
|
|
276
|
+
field: string | SemaphorFieldRef;
|
|
277
|
+
operator?: SemaphorAgentFilterInputOperator;
|
|
278
|
+
operation?: SemaphorAgentFilterInputOperator | string;
|
|
279
|
+
value?: unknown;
|
|
280
|
+
values?: unknown[];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export declare type SemaphorAgentFilterInputOperator = SemaphorAnalyticsFilterOperator | 'equals' | 'eq' | 'not_equals' | 'neq' | 'like' | 'not_like' | 'not in' | 'not contains' | 'not between' | 'is_null' | 'is_not_null' | 'is null' | 'is not null';
|
|
284
|
+
|
|
232
285
|
export declare type SemaphorAnalyticsExecutionResult = {
|
|
233
286
|
intentId?: string;
|
|
234
287
|
queryId?: string;
|
|
@@ -246,6 +299,8 @@ export declare type SemaphorAnalyticsExecutionResult = {
|
|
|
246
299
|
};
|
|
247
300
|
missingFields?: string[];
|
|
248
301
|
warnings?: string[];
|
|
302
|
+
relationshipDiagnostics?: SemaphorRelationshipDiagnostics;
|
|
303
|
+
population?: SemaphorAnalyticsPopulation;
|
|
249
304
|
metadata?: Record<string, unknown>;
|
|
250
305
|
};
|
|
251
306
|
|
|
@@ -253,6 +308,16 @@ export declare type SemaphorAnalyticsExecutionStatus = 'answered' | 'partial' |
|
|
|
253
308
|
|
|
254
309
|
export declare type SemaphorAnalyticsFieldRole = 'metric' | 'dateField' | 'dimension' | 'input' | 'source' | 'sql';
|
|
255
310
|
|
|
311
|
+
export declare type SemaphorAnalyticsFilter = {
|
|
312
|
+
id?: string;
|
|
313
|
+
field: SemaphorFieldRef;
|
|
314
|
+
operator?: SemaphorAnalyticsFilterOperator;
|
|
315
|
+
value?: unknown;
|
|
316
|
+
values?: unknown[];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
|
|
320
|
+
|
|
256
321
|
export declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent;
|
|
257
322
|
|
|
258
323
|
export declare type SemaphorAnalyticsIntentFixtureName = keyof typeof SEMAPHOR_ANALYTICS_INTENT_FIXTURES;
|
|
@@ -277,6 +342,11 @@ export declare type SemaphorAnalyticsObligation = {
|
|
|
277
342
|
|
|
278
343
|
export declare type SemaphorAnalyticsObligationType = 'record_list' | 'count' | 'trend' | 'comparison' | 'driver_analysis' | 'metric_summary' | 'analysis_table' | 'lookup' | 'unknown';
|
|
279
344
|
|
|
345
|
+
export declare type SemaphorAnalyticsPopulation = {
|
|
346
|
+
scope: 'filtered_query';
|
|
347
|
+
metrics: Record<string, number | string | null>;
|
|
348
|
+
};
|
|
349
|
+
|
|
280
350
|
export declare type SemaphorAnalyticsRecoveryPlan = {
|
|
281
351
|
version: SemaphorProtocolVersion;
|
|
282
352
|
kind: 'analytics_recovery_plan';
|
|
@@ -406,7 +476,7 @@ export declare type SemaphorInputBinding = {
|
|
|
406
476
|
field?: SemaphorFieldRef;
|
|
407
477
|
};
|
|
408
478
|
|
|
409
|
-
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | '>' | '>=' | '<' | '<=';
|
|
479
|
+
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
410
480
|
|
|
411
481
|
export declare type SemaphorInputOptionsIntent = {
|
|
412
482
|
kind: 'inputOptions';
|
|
@@ -464,12 +534,15 @@ export declare type SemaphorMetricIntent = {
|
|
|
464
534
|
version?: SemaphorProtocolVersion;
|
|
465
535
|
id?: string;
|
|
466
536
|
source: SemaphorSourceRef;
|
|
467
|
-
|
|
468
|
-
|
|
537
|
+
metrics: string[];
|
|
538
|
+
primaryMetric?: string;
|
|
539
|
+
metricRefs?: SemaphorFieldRef[];
|
|
469
540
|
label?: string;
|
|
470
541
|
dateField?: SemaphorFieldRef;
|
|
471
542
|
timeGrain?: SemaphorTimeGrain;
|
|
543
|
+
timeWindow?: SemaphorTimeWindow;
|
|
472
544
|
dimensions?: SemaphorFieldRef[];
|
|
545
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
473
546
|
comparison?: {
|
|
474
547
|
kind: 'previous_period' | 'previous_year' | 'target';
|
|
475
548
|
targetValue?: number;
|
|
@@ -557,6 +630,27 @@ export declare type SemaphorRecoveryToolCall = {
|
|
|
557
630
|
recoveryKind?: 'schema_discovery' | 'query_spec' | 'sql' | 'unsupported';
|
|
558
631
|
};
|
|
559
632
|
|
|
633
|
+
export declare type SemaphorRelationshipDiagnostics = {
|
|
634
|
+
status: SemaphorRelationshipDiagnosticStatus;
|
|
635
|
+
requiredSources?: SemaphorSourceRef[];
|
|
636
|
+
relationshipsUsed?: string[];
|
|
637
|
+
missingSources?: string[];
|
|
638
|
+
warnings?: string[];
|
|
639
|
+
message?: string;
|
|
640
|
+
recommendedNextStep?: string;
|
|
641
|
+
joinPlanSummary?: {
|
|
642
|
+
baseSource?: SemaphorSourceRef;
|
|
643
|
+
joinedSources?: SemaphorSourceRef[];
|
|
644
|
+
joinCount?: number;
|
|
645
|
+
};
|
|
646
|
+
fanoutRisk?: {
|
|
647
|
+
status: 'none' | 'warning' | 'error' | 'unknown';
|
|
648
|
+
message?: string;
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
export declare type SemaphorRelationshipDiagnosticStatus = 'not_required' | 'resolved' | 'missing' | 'ambiguous' | 'fanout_risk' | 'unknown';
|
|
653
|
+
|
|
560
654
|
export declare type SemaphorSourceCoordinateInput = {
|
|
561
655
|
databaseName?: string;
|
|
562
656
|
schemaName?: string;
|
|
@@ -625,7 +719,7 @@ export declare type SemaphorSqlResult = SemaphorAnalyticsResultBase & {
|
|
|
625
719
|
export declare type SemaphorTimeGrain = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
626
720
|
|
|
627
721
|
export declare type SemaphorTimeWindow = {
|
|
628
|
-
unit: 'day' | 'month';
|
|
722
|
+
unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
629
723
|
value: number;
|
|
630
724
|
anchor?: 'now' | 'latest_available';
|
|
631
725
|
};
|