react-semaphor 0.1.365 → 0.1.366
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 +26 -24
- package/dist/chunks/{calendar-preferences-dialog-CgBwWqfY.js → calendar-preferences-dialog-BOFlzOJg.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CK_6KGFV.js → dashboard-briefing-launcher-D2lBFqAd.js} +3 -3
- package/dist/chunks/{dashboard-controls-CsIEj0Vm.js → dashboard-controls-BIk094Ah.js} +3 -3
- package/dist/chunks/{dashboard-json-OhYs9GOx.js → dashboard-json-DImOf512.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-q_XG4oWg.js → edit-dashboard-visual-DTxkV6Fl.js} +3 -3
- package/dist/chunks/{index-Ds3_EAla.js → index-BVEIk-rB.js} +5 -5
- package/dist/chunks/{resource-management-panel-CYXyE2js.js → resource-management-panel-BOfbSf48.js} +2 -2
- package/dist/chunks/{source-identity-qAmkNtEK.js → source-identity-Dj3dryN9.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-CRQcqLs3.js → use-create-flow-overlay-state-B5FygfQL.js} +2 -2
- package/dist/chunks/{use-visual-utils-CpZplRpR.js → use-visual-utils-CszWnFBW.js} +1 -1
- package/dist/chunks/validation-DiCE3_4O.js +1 -0
- package/dist/chunks/{validation-B4_hBuYu.js → validation-WGWJOQsV.js} +115 -94
- package/dist/chunks/{validators-BnLhuIhd.js → validators-Bxc1OmZK.js} +296 -237
- package/dist/chunks/validators-BxhJ_NtM.js +1 -0
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +135 -134
- package/dist/data-app-builder/index.js +1 -1
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +3 -3
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +3 -3
- package/dist/index.js +5 -5
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +11 -1
- package/dist/types/dashboard-assistant.d.ts +2 -0
- package/dist/types/dashboard-authoring.d.ts +7 -1
- package/dist/types/data-app-builder.d.ts +2 -0
- package/dist/types/data-app-sdk-validation.d.ts +4 -0
- package/dist/types/data-app-sdk.d.ts +21 -6
- package/dist/types/main.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunks/validation-CsK42Vbq.js +0 -1
- package/dist/chunks/validators-Cu_w8ZEP.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/validation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/validation-DiCE3_4O.js"),O=require("../chunks/index-BxM99sFL.js"),u=require("react"),E=require("react/jsx-runtime"),g=require("../chunks/validators-BxhJ_NtM.js");function R(){return{executeAnalysis:(t,e,n)=>y(t,e,n??{}),executeMetric:(t,e)=>y(t,e),executeRecords:(t,e)=>y(t,e),executeInputOptions:(t,e)=>y(t,e)}}async function y(t,e,n){if(!e.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const o=await fetch(T(e),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:JSON.stringify({intent:t,activeInputs:e.activeInputs,...n?{analysisOptions:n}:{},resultShape:t.kind})}),r=await b(o);if(!o.ok||r.error)throw new Error(r.error||`Semaphor Data App execution failed with status ${o.status}.`);return r}async function b(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:M(t,e),details:e}}}function M(t,e){const n=t.statusText?` ${t.statusText}`:"",o=e.replace(/\s+/g," ").trim();return o?`Semaphor Data App execution failed with status ${t.status}${n}: ${o.slice(0,240)}`:`Semaphor Data App execution failed with status ${t.status}${n}.`}function T(t){const e=C(t).replace(/\/+$/,"");return e?e.endsWith("/api")?`${e}/v1/data-app/execute`:`${e}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function C(t){if(t.apiBaseUrl)return t.apiBaseUrl;if(!t.token)return"";try{return O.jwtDecode(t.token).apiServiceUrl||""}catch{return""}}const x=u.createContext({});function k(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function q(){return u.useContext(x)}function K({token:t,apiBaseUrl:e,executor:n,children:o}){var d;const r=k(),s=((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(()=>R(),[]),c=n||l,h=u.useMemo(()=>({token:s,apiBaseUrl:i,executor:c}),[i,c,s]);return E.jsx(x.Provider,{value:h,children:o})}const f={value:null},A={},$={records:[]},D={options:[]};function _(t){const e=a.toSemaphorActiveInputSnapshots(t.inputs),n=a.toSemaphorAnalysisQueryOptions(t);try{const o=a.toSemaphorAnalysisIntent(t),r=v(o);return r?{error:r,activeInputs:e,analysisOptions:n,queryKey:p(void 0,e,r,n),idleData:A}:{intent:o,error:null,activeInputs:e,analysisOptions:n,queryKey:p(o,e,void 0,n),idleData:A}}catch(o){const r=S(o);return{error:r,activeInputs:e,analysisOptions:n,queryKey:p(void 0,e,r,n),idleData:A}}}function P(t){const e=a.toSemaphorActiveInputSnapshots(t.inputs);try{const n=a.toSemaphorMetricIntent(t),o=v(n);return o?{error:o,activeInputs:e,queryKey:p(void 0,e,o),idleData:f}:{intent:n,error:null,activeInputs:e,queryKey:p(n,e),idleData:f}}catch(n){const o=S(n);return{error:o,activeInputs:e,queryKey:p(void 0,e,o),idleData:f}}}function V(t){const e=a.toSemaphorActiveInputSnapshots(t.inputs),n=$;try{const o=a.toSemaphorRecordsIntent(t),r=v(o);return r?{error:r,activeInputs:e,queryKey:p(void 0,e,r),idleData:n}:{intent:o,error:null,activeInputs:e,queryKey:p(o,e),idleData:n}}catch(o){const r=S(o);return{error:r,activeInputs:e,queryKey:p(void 0,e,r),idleData:n}}}function w(t){try{const e=a.toSemaphorInputOptionsIntent(t),n=v(e);return n?{error:n,queryKey:p(void 0,void 0,n),idleData:D}:{intent:e,error:null,queryKey:p(e),idleData:D}}catch(e){const n=S(e);return{error:n,queryKey:p(void 0,void 0,n),idleData:D}}}function S(t){return t instanceof Error?t:new Error(String(t))}function v(t){const e=g.validateSemaphorAnalyticsIntent(t);if(e.ok)return null;const n=e.errors.map(o=>o.path?`${o.code} at ${o.path}: ${o.message}`:`${o.code}: ${o.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${n}`)}function p(t,e,n,o){return JSON.stringify({intent:t,activeInputs:e,analysisOptions:o,error:n==null?void 0:n.message})}function B(t){const[e,n]=u.useState(t.defaultValue),o=Object.prototype.hasOwnProperty.call(t,"value"),r=o?t.value:e,s=u.useMemo(()=>a.normalizeSemaphorInputOptions(t.options),[t.options]),i=u.useCallback(c=>{var d;const h=c;(d=t.onValueChange)==null||d.call(t,h),o||n(h)},[o,t]),l=u.useCallback(()=>i(void 0),[i]);return u.useMemo(()=>{const c=a.toSemaphorInputSpec(t);return{id:t.id,kind:t.kind,label:t.label,field:c.field,operator:c.operator,controlRole:t.kind==="control"?t.role:void 0,value:r,options:s,isActive:a.hasSemaphorInputValue(r),setValue:i,clear:l,toAnalyticsInput:()=>({inputId:c.inputId,field:c.field,kind:t.kind,label:t.label,value:r,isActive:a.hasSemaphorInputValue(r),operator:c.operator,controlRole:t.kind==="control"?t.role:void 0})}},[l,s,i,t,r])}function Q(t){const e=u.useMemo(()=>_(t),[t]),n=u.useCallback(s=>{var i,l;return e.intent?(l=(i=s.executor)==null?void 0:i.executeAnalysis)==null?void 0:l.call(i,e.intent,s,e.analysisOptions):void 0},[e.analysisOptions,e.intent]),o=I(e.queryKey,n,e.idleData,e.activeInputs),r=e.error?e.idleData:o.data;return{id:t.id,intent:e.intent,...r||{},status:e.error?"error":o.status,isLoading:!e.error&&o.status==="loading",error:e.error||o.error}}function U(t){const e=u.useMemo(()=>P(t),[t]),n=u.useCallback(s=>{var i;return e.intent?(i=s.executor)==null?void 0:i.executeMetric(e.intent,s):void 0},[e.intent]),o=I(e.queryKey,n,e.idleData,e.activeInputs),r=e.error?e.idleData:o.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,executionResult:r==null?void 0:r.executionResult,status:e.error?"error":o.status,isLoading:!e.error&&o.status==="loading",error:e.error||o.error}}function z(t){const e=u.useMemo(()=>V(t),[t]),n=u.useCallback(s=>{var i;return e.intent?(i=s.executor)==null?void 0:i.executeRecords(e.intent,s):void 0},[e.intent]),o=I(e.queryKey,n,e.idleData,e.activeInputs),r=e.error?e.idleData:o.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,executionResult:r==null?void 0:r.executionResult,status:e.error?"error":o.status,isLoading:!e.error&&o.status==="loading",error:e.error||o.error}}function L(t){const e=u.useMemo(()=>w(t),[t]),n=u.useCallback(s=>{var i;return e.intent?(i=s.executor)==null?void 0:i.executeInputOptions(e.intent,s):void 0},[e.intent]),o=I(e.queryKey,n,e.idleData),r=e.error?e.idleData:o.data;return{id:t.id,intent:e.intent,options:(r==null?void 0:r.options)||[],executionResult:r==null?void 0:r.executionResult,status:e.error?"error":o.status,isLoading:!e.error&&o.status==="loading",error:e.error||o.error}}function I(t,e,n,o){const r=q(),s=u.useRef(e),i=u.useRef(o),[l,c]=u.useState({status:"idle",data:n,error:null});return s.current=e,i.current=o,u.useEffect(()=>{let h;try{h=s.current({...r,activeInputs:i.current})}catch(m){c({status:"error",data:n,error:S(m)});return}if(!h){c({status:"idle",data:n,error:null});return}let d=!1;return c(m=>({status:"loading",data:m.data,error:null})),h.then(m=>{d||c({status:"success",data:m,error:null})}).catch(m=>{d||c({status:"error",data:n,error:S(m)})}),()=>{d=!0}},[n,t,r]),l}exports.hasSemaphorInputValue=a.hasSemaphorInputValue;exports.normalizeSemaphorAnalysisQueryOptions=a.normalizeSemaphorAnalysisQueryOptions;exports.normalizeSemaphorInputOptions=a.normalizeSemaphorInputOptions;exports.toSemaphorActiveInputSnapshots=a.toSemaphorActiveInputSnapshots;exports.toSemaphorAnalysisIntent=a.toSemaphorAnalysisIntent;exports.toSemaphorAnalysisQueryOptions=a.toSemaphorAnalysisQueryOptions;exports.toSemaphorInputBinding=a.toSemaphorInputBinding;exports.toSemaphorInputBindings=a.toSemaphorInputBindings;exports.toSemaphorInputOptionsIntent=a.toSemaphorInputOptionsIntent;exports.toSemaphorInputSnapshots=a.toSemaphorInputSnapshots;exports.toSemaphorInputSpec=a.toSemaphorInputSpec;exports.toSemaphorMetricIntent=a.toSemaphorMetricIntent;exports.toSemaphorRecordsIntent=a.toSemaphorRecordsIntent;exports.validateSemaphorDataAppHookSpecs=a.validateSemaphorDataAppHookSpecs;exports.SemaphorDataAppContext=x;exports.SemaphorDataAppProvider=K;exports.createSemaphorQueryExecutor=R;exports.readWindowRuntime=k;exports.useSemaphorAnalysis=Q;exports.useSemaphorDataAppRuntime=q;exports.useSemaphorInput=B;exports.useSemaphorInputOptions=L;exports.useSemaphorMetric=U;exports.useSemaphorRecords=z;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as x, a as g, b as O, c as K, d as T, e as $, n as _, f as b, h as E } from "../chunks/validation-
|
|
2
|
-
import { k as dt, g as pt, i as yt, j as ft, v as mt } from "../chunks/validation-
|
|
1
|
+
import { t as x, a as g, b as O, c as K, d as T, e as $, n as _, f as b, h as E } from "../chunks/validation-WGWJOQsV.js";
|
|
2
|
+
import { k as dt, g as pt, i as yt, j as ft, v as mt } from "../chunks/validation-WGWJOQsV.js";
|
|
3
3
|
import { j as P } from "../chunks/index-CuHybtft.js";
|
|
4
4
|
import { createContext as U, useContext as w, useMemo as p, useState as k, useCallback as f, useRef as q, useEffect as C } from "react";
|
|
5
5
|
import { jsx as B } from "react/jsx-runtime";
|
|
6
|
-
import { v as L } from "../chunks/validators-
|
|
6
|
+
import { v as L } from "../chunks/validators-Bxc1OmZK.js";
|
|
7
7
|
function M() {
|
|
8
8
|
return {
|
|
9
9
|
executeAnalysis: (e, t, o) => h(e, t, o ?? {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../chunks/validators-BxhJ_NtM.js");require("../chunks/source-identity-C-xaeE_I.js");const e=require("../chunks/validation-DiCE3_4O.js");exports.normalizeSemaphorAnalysisQueryOptions=e.normalizeSemaphorAnalysisQueryOptions;exports.validateSemaphorDataAppHookSpecs=e.validateSemaphorDataAppHookSpecs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../chunks/validators-
|
|
2
|
-
import "../chunks/source-identity-
|
|
3
|
-
import { k as e, v as i } from "../chunks/validation-
|
|
1
|
+
import "../chunks/validators-Bxc1OmZK.js";
|
|
2
|
+
import "../chunks/source-identity-Dj3dryN9.js";
|
|
3
|
+
import { k as e, v as i } from "../chunks/validation-WGWJOQsV.js";
|
|
4
4
|
export {
|
|
5
5
|
e as normalizeSemaphorAnalysisQueryOptions,
|
|
6
6
|
i as validateSemaphorDataAppHookSpecs
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { E as T, F as N, S, q as P, U as _, r as w, s as F, t as x, v as R, w as I, C as M, i as L, I as k, x as U, j as O, k as z, l as V, m as H } from "./chunks/index-
|
|
2
|
-
import { W as ca, D as fa, T as ma, Q as pa, N as ha, a9 as ga, A as Ca, H as Da, H as Ea, J as xa, V as Ta, a as ba, a8 as ya, a4 as va, P as Aa, O as Ba, ac as Na, a7 as Sa, a6 as Pa, a5 as _a, ab as wa, aa as Fa, a1 as Ra, _ as Ia, M as Ma, Y as La, L as ka, z as Ua, X as Oa, Z as za, B as Va, a3 as Ha, a0 as qa, $ as Wa, a2 as ja, y as Ga, K as Qa, G as Ka } from "./chunks/index-
|
|
1
|
+
import { E as T, F as N, S, q as P, U as _, r as w, s as F, t as x, v as R, w as I, C as M, i as L, I as k, x as U, j as O, k as z, l as V, m as H } from "./chunks/index-BVEIk-rB.js";
|
|
2
|
+
import { W as ca, D as fa, T as ma, Q as pa, N as ha, a9 as ga, A as Ca, H as Da, H as Ea, J as xa, V as Ta, a as ba, a8 as ya, a4 as va, P as Aa, O as Ba, ac as Na, a7 as Sa, a6 as Pa, a5 as _a, ab as wa, aa as Fa, a1 as Ra, _ as Ia, M as Ma, Y as La, L as ka, z as Ua, X as Oa, Z as za, B as Va, a3 as Ha, a0 as qa, $ as Wa, a2 as ja, y as Ga, K as Qa, G as Ka } from "./chunks/index-BVEIk-rB.js";
|
|
3
3
|
import { a as Ya, C as $a, D as Ja, E as Za, P as ae, g as ee, d as se, h as re, b as oe, c as te, i as ne } from "./chunks/common-types-4bjoIgvm.js";
|
|
4
|
-
import { C as le } from "./chunks/calendar-preferences-dialog-
|
|
4
|
+
import { C as le } from "./chunks/calendar-preferences-dialog-BOFlzOJg.js";
|
|
5
5
|
import { jsx as a, jsxs as d } from "react/jsx-runtime";
|
|
6
6
|
import { u as q, P as W, b as j, B as G, a as C, g as Q, d as K, e as X } from "./chunks/switch-xcWLtWs0.js";
|
|
7
7
|
import { F as ue, q as ce, h as fe, i as me, k as pe, s as he, r as ge, w as Ce, x as De, p as Ee, j as xe, o as Te, t as be, n as ye, m as ve, l as Ae, y as Be, v as Ne, z as Se, D as Pe, A as _e, E as we, H as Fe, G as Re } from "./chunks/switch-xcWLtWs0.js";
|
|
8
8
|
import * as m from "react";
|
|
9
9
|
import { useMemo as Y, useEffect as b } from "react";
|
|
10
|
-
import { ResourceManagementPanel as Me } from "./chunks/resource-management-panel-
|
|
10
|
+
import { ResourceManagementPanel as Me } from "./chunks/resource-management-panel-BOfbSf48.js";
|
|
11
11
|
import { DEFAULT_CALENDAR_CONTEXT as ke, DEFAULT_SEMANTIC_DOMAIN_ACCESS as Ue } from "./types/index.js";
|
|
12
12
|
import { u as ze } from "./chunks/use-debounced-dirty-check-BwAbnX_5.js";
|
|
13
13
|
import "react-dom";
|
|
14
14
|
import "./chunks/index-CJdxSyQq.js";
|
|
15
|
-
import { A as He, J as qe, B as We, K as je, D as Ge, d as Qe, e as Ke, c as Xe, a as Ye, E as $e, N as Je, U as Ze, V as as, W as es, C as ss, G as rs, H as os, F as ts, t as ns, h as is, z as ls, j as ds, v as us, g as cs, w as fs, x as ms, o as ps, s as hs, q as gs, f as Cs, l as Ds, p as Es, y as xs, m as Ts, r as bs, k as ys, n as vs, i as As, u as Bs, b as Ns, I as Ss } from "./chunks/dashboard-briefing-launcher-
|
|
15
|
+
import { A as He, J as qe, B as We, K as je, D as Ge, d as Qe, e as Ke, c as Xe, a as Ye, E as $e, N as Je, U as Ze, V as as, W as es, C as ss, G as rs, H as os, F as ts, t as ns, h as is, z as ls, j as ds, v as us, g as cs, w as fs, x as ms, o as ps, s as hs, q as gs, f as Cs, l as Ds, p as Es, y as xs, m as Ts, r as bs, k as ys, n as vs, i as As, u as Bs, b as Ns, I as Ss } from "./chunks/dashboard-briefing-launcher-D2lBFqAd.js";
|
|
16
16
|
import { n as _s, s as ws } from "./chunks/normalize-dashboard-for-dirty-check-5KpZN8xr.js";
|
|
17
17
|
import "./chunks/index-CuHybtft.js";
|
|
18
18
|
function ta(e) {
|
package/dist/surfboard/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as e } from "../chunks/index-
|
|
1
|
+
import { a as e } from "../chunks/index-BVEIk-rB.js";
|
|
2
2
|
import { C, E } from "../chunks/common-types-4bjoIgvm.js";
|
|
3
|
-
import { C as s } from "../chunks/calendar-preferences-dialog-
|
|
3
|
+
import { C as s } from "../chunks/calendar-preferences-dialog-BOFlzOJg.js";
|
|
4
4
|
export {
|
|
5
5
|
C as CONTROL_CARD_DEFAULT_VALUE,
|
|
6
6
|
s as CalendarPreferencesDialog,
|
|
@@ -80,8 +80,12 @@ export declare function normalizeAnalyticsCatalogDataType(value: unknown): Analy
|
|
|
80
80
|
|
|
81
81
|
export declare function normalizeAnalyticsCatalogName(value: unknown): string;
|
|
82
82
|
|
|
83
|
+
export declare function normalizeSemaphorAnalyticsFilterOperator(value: SemaphorAnalyticsFilterOperator | string | null | undefined): SemaphorAnalyticsFilterOperator | undefined;
|
|
84
|
+
|
|
83
85
|
export declare function normalizeSemaphorDialect(input: string | undefined): SemaphorDialect;
|
|
84
86
|
|
|
87
|
+
export declare function normalizeSemaphorInputOperator(value: SemaphorInputOperatorInput | string | null | undefined): SemaphorInputOperator | undefined;
|
|
88
|
+
|
|
85
89
|
export declare function parseSemaphorIsoTimeWindowBoundary(value: unknown): Date | null;
|
|
86
90
|
|
|
87
91
|
export declare function preferSemaphorFieldRefMetadata(current: SemaphorFieldRef, next: SemaphorFieldRef): SemaphorFieldRef;
|
|
@@ -529,6 +533,10 @@ export declare type SemaphorInputBinding = {
|
|
|
529
533
|
|
|
530
534
|
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
531
535
|
|
|
536
|
+
export declare type SemaphorInputOperatorAlias = 'eq' | 'equals' | 'not_equals' | 'neq' | 'not equal' | 'not equals' | 'not in' | 'like' | 'not_contains' | 'not contains' | 'not_like' | 'not like' | 'not_between' | 'not between';
|
|
537
|
+
|
|
538
|
+
export declare type SemaphorInputOperatorInput = SemaphorInputOperator | SemaphorInputOperatorAlias;
|
|
539
|
+
|
|
532
540
|
export declare type SemaphorInputOptionsIntent = {
|
|
533
541
|
kind: 'inputOptions';
|
|
534
542
|
version?: SemaphorProtocolVersion;
|
|
@@ -566,7 +574,7 @@ export declare type SemaphorInputSpec = {
|
|
|
566
574
|
kind: 'filter' | 'control';
|
|
567
575
|
label: string;
|
|
568
576
|
field: SemaphorFieldRef;
|
|
569
|
-
operator?:
|
|
577
|
+
operator?: SemaphorInputOperatorInput;
|
|
570
578
|
multi?: boolean;
|
|
571
579
|
defaultValue?: unknown;
|
|
572
580
|
scope?: SemaphorInputScope;
|
|
@@ -658,6 +666,8 @@ export declare type SemaphorRecordsIntent = {
|
|
|
658
666
|
fields: SemaphorFieldRef[];
|
|
659
667
|
dateField?: SemaphorFieldRef;
|
|
660
668
|
timeGrain?: SemaphorTimeGrain;
|
|
669
|
+
timeWindow?: SemaphorTimeWindow;
|
|
670
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
661
671
|
limit?: number;
|
|
662
672
|
orderBy?: {
|
|
663
673
|
field: SemaphorFieldRef;
|
|
@@ -842,6 +842,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
842
842
|
fields: SemaphorFieldRef[];
|
|
843
843
|
dateField?: SemaphorFieldRef;
|
|
844
844
|
timeGrain?: SemaphorTimeGrain;
|
|
845
|
+
timeWindow?: SemaphorTimeWindow;
|
|
846
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
845
847
|
limit?: number;
|
|
846
848
|
orderBy?: {
|
|
847
849
|
field: SemaphorFieldRef;
|
|
@@ -1887,6 +1887,10 @@ declare type SemaphorInputBinding = {
|
|
|
1887
1887
|
|
|
1888
1888
|
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
1889
1889
|
|
|
1890
|
+
declare type SemaphorInputOperatorAlias = 'eq' | 'equals' | 'not_equals' | 'neq' | 'not equal' | 'not equals' | 'not in' | 'like' | 'not_contains' | 'not contains' | 'not_like' | 'not like' | 'not_between' | 'not between';
|
|
1891
|
+
|
|
1892
|
+
declare type SemaphorInputOperatorInput = SemaphorInputOperator | SemaphorInputOperatorAlias;
|
|
1893
|
+
|
|
1890
1894
|
declare type SemaphorInputOptionsIntent = {
|
|
1891
1895
|
kind: 'inputOptions';
|
|
1892
1896
|
version?: SemaphorProtocolVersion;
|
|
@@ -1915,7 +1919,7 @@ declare type SemaphorInputSpec = {
|
|
|
1915
1919
|
kind: 'filter' | 'control';
|
|
1916
1920
|
label: string;
|
|
1917
1921
|
field: SemaphorFieldRef;
|
|
1918
|
-
operator?:
|
|
1922
|
+
operator?: SemaphorInputOperatorInput;
|
|
1919
1923
|
multi?: boolean;
|
|
1920
1924
|
defaultValue?: unknown;
|
|
1921
1925
|
scope?: SemaphorInputScope;
|
|
@@ -1965,6 +1969,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
1965
1969
|
fields: SemaphorFieldRef[];
|
|
1966
1970
|
dateField?: SemaphorFieldRef;
|
|
1967
1971
|
timeGrain?: SemaphorTimeGrain;
|
|
1972
|
+
timeWindow?: SemaphorTimeWindow;
|
|
1973
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
1968
1974
|
limit?: number;
|
|
1969
1975
|
orderBy?: {
|
|
1970
1976
|
field: SemaphorFieldRef;
|
|
@@ -653,6 +653,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
653
653
|
fields: SemaphorFieldRef[];
|
|
654
654
|
dateField?: SemaphorFieldRef;
|
|
655
655
|
timeGrain?: SemaphorTimeGrain;
|
|
656
|
+
timeWindow?: SemaphorTimeWindow;
|
|
657
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
656
658
|
limit?: number;
|
|
657
659
|
orderBy?: {
|
|
658
660
|
field: SemaphorFieldRef;
|
|
@@ -431,6 +431,8 @@ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
|
|
|
431
431
|
label?: string;
|
|
432
432
|
dateField?: SemaphorQueryField;
|
|
433
433
|
timeGrain?: SemaphorTimeGrain;
|
|
434
|
+
timeWindow?: SemaphorTimeWindow;
|
|
435
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
434
436
|
orderBy?: SemaphorRecordsOrderBy;
|
|
435
437
|
inputs?: SemaphorInputReference[];
|
|
436
438
|
limit?: number;
|
|
@@ -449,6 +451,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
449
451
|
fields: SemaphorFieldRef[];
|
|
450
452
|
dateField?: SemaphorFieldRef;
|
|
451
453
|
timeGrain?: SemaphorTimeGrain;
|
|
454
|
+
timeWindow?: SemaphorTimeWindow;
|
|
455
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
452
456
|
limit?: number;
|
|
453
457
|
orderBy?: {
|
|
454
458
|
field: SemaphorFieldRef;
|
|
@@ -73,6 +73,7 @@ export declare type SemaphorAnalysisPayload = {
|
|
|
73
73
|
answerSummary?: string;
|
|
74
74
|
mode?: string;
|
|
75
75
|
data?: Record<string, unknown>;
|
|
76
|
+
resultSets?: Record<string, SemaphorAnalysisResultSet>;
|
|
76
77
|
records?: Array<Record<string, unknown>>;
|
|
77
78
|
changes?: Array<Record<string, unknown>>;
|
|
78
79
|
drivers?: Array<Record<string, unknown>>;
|
|
@@ -122,6 +123,12 @@ export declare type SemaphorAnalysisQuerySpec = SemaphorMetricQuerySpec & Semaph
|
|
|
122
123
|
filters?: SemaphorAnalyticsFilter[];
|
|
123
124
|
};
|
|
124
125
|
|
|
126
|
+
export declare type SemaphorAnalysisResultSet = {
|
|
127
|
+
records: Array<Record<string, unknown>>;
|
|
128
|
+
columns: SemaphorResultColumn[];
|
|
129
|
+
rowCount?: number;
|
|
130
|
+
};
|
|
131
|
+
|
|
125
132
|
export declare type SemaphorAnalysisTimezoneValidator = (tz: string) => string | null;
|
|
126
133
|
|
|
127
134
|
declare type SemaphorAnalyticsExecutionResult = {
|
|
@@ -150,7 +157,7 @@ declare type SemaphorAnalyticsExecutionStatus = 'answered' | 'partial' | 'failed
|
|
|
150
157
|
|
|
151
158
|
declare type SemaphorAnalyticsFieldRole = 'metric' | 'dateField' | 'dimension' | 'input' | 'source' | 'sql';
|
|
152
159
|
|
|
153
|
-
declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
|
|
160
|
+
export declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
|
|
154
161
|
|
|
155
162
|
declare type SemaphorAnalyticsFilterBase = {
|
|
156
163
|
id?: string;
|
|
@@ -336,7 +343,7 @@ declare type SemaphorExecutionFieldRef = SemaphorFieldRef & {
|
|
|
336
343
|
aggregateSource?: SemaphorMetricAggregateSource;
|
|
337
344
|
};
|
|
338
345
|
|
|
339
|
-
declare type SemaphorFieldRef = {
|
|
346
|
+
export declare type SemaphorFieldRef = {
|
|
340
347
|
name: string;
|
|
341
348
|
label?: string;
|
|
342
349
|
role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
|
|
@@ -348,7 +355,7 @@ declare type SemaphorFieldRef = {
|
|
|
348
355
|
export declare type SemaphorFilterInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
|
|
349
356
|
kind: 'filter';
|
|
350
357
|
field: SemaphorQueryField;
|
|
351
|
-
operator?:
|
|
358
|
+
operator?: SemaphorInputOperatorInput;
|
|
352
359
|
multi?: boolean;
|
|
353
360
|
};
|
|
354
361
|
|
|
@@ -381,7 +388,11 @@ export declare type SemaphorInputHandle<TValue extends SemaphorInputValue = Sema
|
|
|
381
388
|
toAnalyticsInput(): SemaphorActiveInput<TValue>;
|
|
382
389
|
};
|
|
383
390
|
|
|
384
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
391
|
+
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
392
|
+
|
|
393
|
+
declare type SemaphorInputOperatorAlias = 'eq' | 'equals' | 'not_equals' | 'neq' | 'not equal' | 'not equals' | 'not in' | 'like' | 'not_contains' | 'not contains' | 'not_like' | 'not like' | 'not_between' | 'not between';
|
|
394
|
+
|
|
395
|
+
export declare type SemaphorInputOperatorInput = SemaphorInputOperator | SemaphorInputOperatorAlias;
|
|
385
396
|
|
|
386
397
|
export declare type SemaphorInputOption = {
|
|
387
398
|
label: string;
|
|
@@ -568,6 +579,8 @@ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
|
|
|
568
579
|
label?: string;
|
|
569
580
|
dateField?: SemaphorQueryField;
|
|
570
581
|
timeGrain?: SemaphorTimeGrain;
|
|
582
|
+
timeWindow?: SemaphorTimeWindow;
|
|
583
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
571
584
|
orderBy?: SemaphorRecordsOrderBy;
|
|
572
585
|
inputs?: SemaphorInputReference[];
|
|
573
586
|
limit?: number;
|
|
@@ -586,6 +599,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
586
599
|
fields: SemaphorFieldRef[];
|
|
587
600
|
dateField?: SemaphorFieldRef;
|
|
588
601
|
timeGrain?: SemaphorTimeGrain;
|
|
602
|
+
timeWindow?: SemaphorTimeWindow;
|
|
603
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
589
604
|
limit?: number;
|
|
590
605
|
orderBy?: {
|
|
591
606
|
field: SemaphorFieldRef;
|
|
@@ -671,7 +686,7 @@ export declare type SemaphorResultColumn = {
|
|
|
671
686
|
|
|
672
687
|
export declare type SemaphorScalar = string | number | boolean | null;
|
|
673
688
|
|
|
674
|
-
declare type SemaphorSourceRef = {
|
|
689
|
+
export declare type SemaphorSourceRef = {
|
|
675
690
|
kind: 'semantic';
|
|
676
691
|
domainId: string;
|
|
677
692
|
datasetName: string;
|
|
@@ -724,7 +739,7 @@ declare type SemaphorSqlResult = SemaphorAnalyticsResultBase & {
|
|
|
724
739
|
|
|
725
740
|
declare type SemaphorTimeGrain = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
726
741
|
|
|
727
|
-
declare type SemaphorTimeWindow = SemaphorRelativeTimeWindow | SemaphorAbsoluteTimeWindow;
|
|
742
|
+
export declare type SemaphorTimeWindow = SemaphorRelativeTimeWindow | SemaphorAbsoluteTimeWindow;
|
|
728
743
|
|
|
729
744
|
export declare function toSemaphorActiveInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
|
|
730
745
|
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4520,6 +4520,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
4520
4520
|
fields: SemaphorFieldRef[];
|
|
4521
4521
|
dateField?: SemaphorFieldRef;
|
|
4522
4522
|
timeGrain?: SemaphorTimeGrain;
|
|
4523
|
+
timeWindow?: SemaphorTimeWindow;
|
|
4524
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
4523
4525
|
limit?: number;
|
|
4524
4526
|
orderBy?: {
|
|
4525
4527
|
field: SemaphorFieldRef;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const z=require("./validators-Cu_w8ZEP.js"),c=require("./source-identity-C-xaeE_I.js");function g(e){var r;const t=O(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:y(e),metrics:t,primaryMetric:D(e,t),dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(o=>a(o,"dimension")),comparison:J(e.comparison),orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:v(e.inputs),limit:e.limit}}function M(e){var r;return{...g(e),...e.timeWindow?{timeWindow:e.timeWindow}:{},...(r=e.filters)!=null&&r.length?{filters:e.filters}:{},...e.analysis?{analysis:e.analysis}:{}}}function B(e){return{...e.chartTitle?{chartTitle:e.chartTitle}:{},...e.chartType?{chartType:e.chartType}:{},...e.driverMode?{driverMode:e.driverMode}:{},...e.includePopulation!==void 0?{includePopulation:e.includePopulation}:{},...e.calendarContext?{calendarContext:e.calendarContext}:{}}}function D(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=a(e.primaryMetric,"measure"),o=N(r,t),i=o.length===1?o[0]:void 0;return i?b(r,i):r}function O(e){const t=[];for(const r of e.metrics.map(o=>a(o,"measure"))){if(!r.name)continue;const o=t.findIndex(i=>H(i,r));if(o===-1){t.push(r);continue}t[o]=b(t[o],r)}return t}function H(e,t){return c.semaphorFieldRefsMatch(e,t)&&u(e)===u(t)}function j(e,t){return u(t)===u(e)}function q(e,t){return t.name!==e.name||e.source&&!c.semaphorFieldRefsMatch(t,e)?!1:j(e,t)}function N(e,t){const r=t.filter(o=>q(e,o));return e.aggregate!==void 0,r}function u(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{...c.preferSemaphorFieldRefMetadata(e,t),aggregate:e.aggregate||t.aggregate}}function _(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(!K(e))throw new Error("useSemaphorRecords needs at least one field.");const t=E(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:y(e),fields:t,dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:v(e.inputs),limit:e.limit}}function E(e){return e.map(t=>{const r=a(t);if(!r.role)throw new Error(`useSemaphorRecords field "${r.name}" needs an explicit role.`);return r})}function w(e){return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:y(e),field:a(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 U(e){const t=v(e);return t.length>0?t:void 0}function C(e){return(e||[]).map(W)}function V(e){return C(e).filter(t=>t.isActive)}function G(e){return e.kind==="filter"?{inputId:e.id,kind:e.kind,label:e.label,field:a(e.field,"dimension"),operator:e.operator||"in"}:{inputId:e.id,kind:e.kind,label:e.label}}function Q(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function F(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function W(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:F(e.value),value:e.value}}function y(e){return e.source}function K(e){var t;return!!((t=e.fields)!=null&&t.length)}function a(e,t){return{...e,role:e.role||t}}function v(e){return(e||[]).map($)}function J(e){if(e)return e}function T(e,t={}){const r=t.pathPrefix||"analysisOptions";if(e===void 0)return{ok:!0};if(!e||typeof e!="object"||Array.isArray(e))return s(r,"Data App analysis options must be an object.");const o=e,i={};if(o.chartTitle!==void 0){if(typeof o.chartTitle!="string")return s(`${r}.chartTitle`,'Data App analysis option "chartTitle" must be a string.');i.chartTitle=o.chartTitle}if(o.chartType!==void 0){if(typeof o.chartType!="string")return s(`${r}.chartType`,'Data App analysis option "chartType" must be a string.');i.chartType=o.chartType}if(o.driverMode!==void 0){if(!Y(o.driverMode))return s(`${r}.driverMode`,'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.');i.driverMode=o.driverMode}if(o.includePopulation!==void 0){if(typeof o.includePopulation!="boolean")return s(`${r}.includePopulation`,'Data App analysis option "includePopulation" must be a boolean.');i.includePopulation=o.includePopulation}if(o.calendarContext!==void 0){const n=ee(o.calendarContext,{pathPrefix:`${r}.calendarContext`,validateTimezone:t.validateTimezone});if(!n.ok)return n;i.calendarContext=n.calendarContext}return{ok:!0,analysisOptions:i}}function L(e){const t=e.hooks.map((i,n)=>X(i,n,{fieldCatalogs:e.fieldCatalogs||[],requireFieldCatalog:!!e.requireFieldCatalog,validateTimezone:e.validateTimezone})),r=t.flatMap(i=>i.diagnostics),o=t.map(i=>i.executionResult);return{ok:r.every(i=>i.severity!=="error"),diagnostics:r,hooks:t,intents:t.flatMap(i=>i.intent?[i.intent]:[]),executionResults:o}}function X(e,t,r){const o=`hooks.${t}`;try{const i=te(e),n=ce(e,i),d=z.validateSemaphorAnalyticsIntent(i),l=[...d.errors.map(m=>k(m,{hook:e.hook,hookId:n,pathPrefix:o,severity:"error",intent:i})),...d.warnings.map(m=>k(m,{hook:e.hook,hookId:n,pathPrefix:o,severity:"warning",intent:i})),...re({hookSpec:e,hookId:n,intent:i,pathPrefix:o,fieldCatalogs:r.fieldCatalogs,requireFieldCatalog:r.requireFieldCatalog}),...ne({hookSpec:e,hookId:n,intent:i,pathPrefix:o,validateTimezone:r.validateTimezone})],f=le(d,l);return{hook:e.hook,hookId:n,intent:i,diagnostics:l,executionResult:A({intent:i,validation:f,diagnostics:l})}}catch(i){const n={severity:"error",code:"invalid_hook_spec",message:i instanceof Error?i.message:String(i),path:o,hook:e.hook,hookId:P(e.spec)},d=R([n]);return{hook:e.hook,hookId:n.hookId,diagnostics:[n],executionResult:A({validation:d,diagnostics:[n]})}}}function s(e,t){return{ok:!1,issues:[{code:"invalid_analysis_option",message:t,path:e}]}}function Y(e){return e==="absolute_delta"||e==="largest_negative"||e==="largest_positive"||e==="positive_and_negative"||e==="all"}function Z(e){return e.trim().length>0&&!Number.isNaN(Date.parse(e))}function ee(e,t){var f;if(!e||typeof e!="object"||Array.isArray(e))return s(t.pathPrefix,'Data App analysis option "calendarContext" must be an object.');const r=e,o=r.tz,i=r.weekStart,n=r.anchor,d=n&&typeof n=="object"&&!Array.isArray(n)?n.iso:void 0,l=typeof o=="string"?((f=t.validateTimezone)==null?void 0:f.call(t,o))??o:null;return l?typeof i!="number"||!Number.isInteger(i)||i<0||i>6?s(`${t.pathPrefix}.weekStart`,'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'):n!=="now"&&!(typeof d=="string"&&Z(d))?s(`${t.pathPrefix}.anchor`,'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'):{ok:!0,calendarContext:{tz:l,weekStart:i,anchor:n}}:s(`${t.pathPrefix}.tz`,'Data App analysis option "calendarContext.tz" must be a valid timezone string.')}function te(e){return e.hook==="useSemaphorMetric"?g(e.spec):e.hook==="useSemaphorAnalysis"?M(e.spec):e.hook==="useSemaphorRecords"?_(e.spec):w(e.spec)}function re(e){if(e.fieldCatalogs.length===0&&!e.requireFieldCatalog)return[];const t=se(e.fieldCatalogs,e.intent.source);return t?[...ie({...e,catalog:t}),...oe({...e,catalog:t})]:[{severity:"error",code:"invalid_source_ref",message:`Source ref for ${e.hookSpec.hook} does not match a visible Semaphor source.`,path:`${e.pathPrefix}.spec.source`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:e.intent.source}]}function ie(e){return ae(e.intent).flatMap(({field:t,path:r})=>x(e.catalog,t,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Field "${t.name}" is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.${r}`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:h(t,e.intent.source),field:t}])}function oe(e){return("inputs"in e.intent?e.intent.inputs||[]:[]).flatMap((r,o)=>{if(!r.field)return[];const i=h(r.field,e.intent.source);return c.semaphorSourcesReferToSameDataset(i,e.intent.source)?x(e.catalog,r.field,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Input "${r.inputId}" references field "${r.field.name}", which is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.spec.inputs.${o}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:i,field:r.field}]:[{severity:"error",code:"unsupported_input_filter_composition",message:`Input "${r.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,path:`${e.pathPrefix}.spec.inputs.${o}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:i,field:r.field}]})}function ne(e){if(e.hookSpec.hook!=="useSemaphorAnalysis")return[];const t=T(e.hookSpec.spec,{pathPrefix:`${e.pathPrefix}.spec`,validateTimezone:e.validateTimezone});return t.ok?[]:t.issues.map(r=>({severity:"error",code:r.code,message:r.message,path:r.path,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:e.intent.source}))}function ae(e){return e.kind==="metric"?[...e.metrics.map((t,r)=>({field:t,path:`spec.metrics.${r}`})),...e.primaryMetric?[{field:e.primaryMetric,path:"spec.primaryMetric"}]:[],...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...(e.dimensions||[]).map((t,r)=>({field:t,path:`spec.dimensions.${r}`})),...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((t,r)=>({field:t.field,path:`spec.filters.${r}.field`}))]:e.kind==="records"?[...e.fields.map((t,r)=>({field:t,path:`spec.fields.${r}`})),...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[]]:e.kind==="inputOptions"?[{field:e.field,path:"spec.field"}]:[]}function se(e,t){return e.find(r=>p(r,t))}function x(e,t,r){const o=h(t,r);if(p(e,o))return e.fields.find(i=>de(i,t)&&p(e,h(i,e.source)))}function p(e,t){return[e.source,...e.sourceAliases||[]].some(r=>c.semaphorSourcesReferToSameDataset(r,t))}function h(e,t){return e.source||t}function de(e,t){return!!(e.name&&t.name&&e.name===t.name)}function k(e,t){return{severity:t.severity,code:e.code||"invalid_analytics_intent",message:e.message,path:e.path?`${t.pathPrefix}.spec.${e.path}`:t.pathPrefix,hook:t.hook,hookId:t.hookId,intentId:t.intent.id,source:t.intent.source}}function le(e,t){const r=R(t);return{ok:r.ok&&e.ok,errors:S([...e.errors,...r.errors]),warnings:S([...e.warnings,...r.warnings]),repairHints:[...e.repairHints,...r.repairHints]}}function R(e){const t=e.filter(o=>o.severity==="error").map(I),r=e.filter(o=>o.severity==="warning").map(I);return{ok:t.length===0,errors:t,warnings:r,repairHints:t.map(o=>{var i,n;return{code:o.code,message:o.message,fieldRole:o.fieldRole,invalidField:(i=o.repairHint)==null?void 0:i.invalidField,recommendedNextStep:((n=o.repairHint)==null?void 0:n.recommendedNextStep)||"Update the Data App SDK hook spec to use visible Semaphor source and field refs."}})}}function I(e){var t;return{code:e.code,message:e.message,path:e.path,fieldRole:e.code==="invalid_source_ref"?"source":void 0,repairHint:{code:e.code,message:e.message,invalidField:(t=e.field)==null?void 0:t.name,fieldRole:e.code==="invalid_source_ref"?"source":void 0,recommendedNextStep:e.code==="unsupported_input_filter_composition"?"Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped hooks.":"Update the hook spec to use a visible Semaphor source and field ref."}}}function S(e){const t=new Set;return e.filter(r=>{const o=`${r.code}:${r.path||""}:${r.message}`;return t.has(o)?!1:(t.add(o),!0)})}function A(e){var r,o;const t=e.diagnostics.filter(i=>i.severity==="error");return{intentId:(r=e.intent)==null?void 0:r.id,status:t.length?"failed":"answered",resultShape:(o=e.intent)==null?void 0:o.kind,intent:e.intent,validation:e.validation,coverage:{answeredObligations:t.length?[]:["hook_spec_validation"],missingObligations:t.length?["hook_spec_validation"]:[],warnings:e.validation.warnings},missingFields:t.filter(i=>i.code==="missing_field").flatMap(i=>{var n;return(n=i.field)!=null&&n.name?[i.field.name]:[]}),warnings:e.diagnostics.filter(i=>i.severity==="warning").map(i=>i.message),metadata:{validationKind:"data_app_sdk_hook_spec"}}}function ce(e,t){return t.id||P(e.spec)}function P(e){if(!e||typeof e!="object"||!("id"in e))return;const t=e.id;return typeof t=="string"&&t.trim()?t:void 0}exports.hasSemaphorInputValue=F;exports.normalizeSemaphorAnalysisQueryOptions=T;exports.normalizeSemaphorInputOptions=Q;exports.toSemaphorActiveInputSnapshots=V;exports.toSemaphorAnalysisIntent=M;exports.toSemaphorAnalysisQueryOptions=B;exports.toSemaphorInputBinding=$;exports.toSemaphorInputBindings=U;exports.toSemaphorInputOptionsIntent=w;exports.toSemaphorInputSnapshots=C;exports.toSemaphorInputSpec=G;exports.toSemaphorMetricIntent=g;exports.toSemaphorRecordsIntent=_;exports.validateSemaphorDataAppHookSpecs=L;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const T=require("./source-identity-C-xaeE_I.js");function t(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function D(e){for(let i=0;i<e.length;i+=1){const n=e[i];if(e.some((r,o)=>o!==i&&k(r,n)))return!1}return!0}function S(e,i){return T.semaphorFieldRefsMatch(e,i)}function k(e,i){return S(e,i)&&y(e)===y(i)}function F(e){return`Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`}function j(e,i){return b(e,i).length===1}function O(e,i){return b(e,i).length===1}function b(e,i){return i.filter(r=>C(e,r))}function C(e,i){return E(e,i)?e.source?S(i,e):!0:!1}function E(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||q(e,i)&&y(i)!==y(e))}function q(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function y(e){return(e.aggregate||"SUM").toUpperCase()}const U=/^(\d{4})-(\d{2})-(\d{2})$/,P=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;function g(e){if(typeof e!="string")return null;const i=e.trim(),n=U.exec(i);if(n){const[,v,A,I]=n;return M(v,A,I)?new Date(Date.UTC(Number(v),Number(A)-1,Number(I))):null}const r=P.exec(i);if(!r)return null;const[,o,a,s,p,c,l="00",,f]=r;if(!M(o,a,s)||!_(p,0,23)||!_(c,0,59)||!_(l,0,59)||!G(f))return null;const h=new Date(i);return Number.isFinite(h.getTime())?h:null}function M(e,i,n){const r=Number(e),o=Number(i),a=Number(n);if(!Number.isInteger(r)||!Number.isInteger(o)||!Number.isInteger(a)||o<1||o>12)return!1;const s=new Date(Date.UTC(r,o-1,a));return s.getUTCFullYear()===r&&s.getUTCMonth()===o-1&&s.getUTCDate()===a}function _(e,i,n){const r=Number(e);return Number.isInteger(r)&&r>=i&&r<=n}function G(e){if(e==="Z")return!0;const i=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(i&&_(i[2],0,23)&&_(i[3],0,59))}function d(e){return typeof e=="string"&&e.trim().length>0}function u(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function $(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}const H=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function N(e,i,n){if(!e||typeof e!="object"){n.push(t("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||n.push(t("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||n.push(t("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||n.push(t("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||n.push(t("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||n.push(t("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}n.push(t("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,n,r={}){if(!e||!u(e)){r.required&&n.push(t("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||n.push(t("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&N(e.source,`${i}.source`,n),L(e.aggregate,`${i}.aggregate`,n)}function L(e,i,n){e!==void 0&&(typeof e!="string"||!H.has(e))&&n.push(t("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function V(e,i){if(e.analysis===void 0)return;if(!u(e.analysis)){i.push(t("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(t("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(t("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(t("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(t("invalid_metric_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:n}=e.analysis;n!==void 0&&B(n,"analysis.timeWindow",i)}function B(e,i,n){if(!u(e)){n.push(t("invalid_time_window","Time window must be a structured object.",i));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&n.push(t("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(d(e.start)||n.push(t("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),d(e.end)||n.push(t("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),d(e.start)&&d(e.end)){const r=g(e.start),o=g(e.end);r||n.push(t("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),o||n.push(t("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),r&&o&&r.getTime()>o.getTime()&&n.push(t("invalid_time_window","Absolute time window start must be before or equal to end.",i))}return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&n.push(t("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&n.push(t("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&n.push(t("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&n.push(t("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function Q(e,i,n){if(e!==void 0){if(!Array.isArray(e)){n.push(t("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((r,o)=>{var c;const a=`${i}.${o}`;if(!u(r)){n.push(t("invalid_analytics_filter","Analytics filter must be a structured object.",a));return}const s=r;m(s.field,`${a}.field`,n,{required:!0}),s.scope!==void 0&&s.scope!=="row"&&s.scope!=="aggregate"&&n.push(t("invalid_analytics_filter_scope","Analytics filter scope must be row or aggregate.",`${a}.scope`)),s.scope==="aggregate"&&((c=s.field)==null?void 0:c.role)!==void 0&&s.field.role!=="measure"&&n.push(t("invalid_analytics_filter_scope","Aggregate-scope analytics filters must target a measure field.",`${a}.scope`));const p=s.operator==="is_null"||s.operator==="is_not_null";if(s.operator!==void 0&&s.operator!=="="&&s.operator!=="!="&&s.operator!=="in"&&s.operator!=="not_in"&&s.operator!=="contains"&&s.operator!=="not_contains"&&s.operator!=="between"&&s.operator!=="not_between"&&s.operator!==">"&&s.operator!==">="&&s.operator!=="<"&&s.operator!=="<="&&s.operator!=="is_null"&&s.operator!=="is_not_null"&&n.push(t("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${a}.operator`)),s.values===void 0&&!p&&n.push(t("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",a)),p&&s.values!==void 0){n.push(t("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${a}.values`));return}if(s.values!==void 0&&!Array.isArray(s.values)){n.push(t("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${a}.values`));return}if(s.values!==void 0){const l=s.values.length;if(s.operator==="between"||s.operator==="not_between"){l!==2&&n.push(t("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${a}.values`));return}(s.operator==="contains"||s.operator==="not_contains"||s.operator==="="||s.operator==="!="||s.operator===">"||s.operator===">="||s.operator==="<"||s.operator==="<="||s.operator===void 0)&&l!==1&&n.push(t("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${a}.values`))}})}}function w(e){var r;const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[t("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.version!==void 0&&e.version!==1&&i.push(t("invalid_version","Analytics intent version must be 1.","version")),N(e.source,"source",i),e.kind==="metric"){const o=Array.isArray(e.metrics)?e.metrics.filter(a=>u(a)&&d(a.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(t("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(a=>!u(a)||!d(a.name))&&i.push(t("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),o.forEach((a,s)=>{m(a,`metrics.${s}`,i,{required:!0})}),o.length>0&&!D(o)){const a=o.find((s,p)=>o.some((c,l)=>l!==p&&k(c,s)));a&&i.push(t("duplicate_metric",F(a),"metrics"))}if(u(e.primaryMetric)&&d(e.primaryMetric.name)&&b(e.primaryMetric,o).length>1&&i.push(t("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(m(e.primaryMetric,"primaryMetric",i,{required:!0}),u(e.primaryMetric)&&d(e.primaryMetric.name)&&o.length>0&&!j(e.primaryMetric,o)&&i.push(t("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(t("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(a=>!u(a)||!d(a.name))&&i.push(t("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.timeWindow!==void 0&&(B(e.timeWindow,"timeWindow",i),e.dateField||i.push(t("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),Q(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((a,s)=>{m(a,`dimensions.${s}`,i)}),e.orderBy!==void 0){if(!u(e.orderBy))i.push(t("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(t("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),u(e.orderBy.field)&&d(e.orderBy.field.name)){const a=[...o,...e.timeGrain&&e.dateField&&u(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(s=>u(s)&&d(s.name)):[]];a.length>0&&!O(e.orderBy.field,a)&&i.push(t("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}V(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(t("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(o=>!u(o)||!d(o.name))&&i.push(t("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.orderBy!==void 0&&(u(e.orderBy)?(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(t("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(t("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!d(e.field.name))&&i.push(t("missing_input_options_field","Input options intent needs a field.","field")),m(e.field,"field",i,{required:!0})):e.kind==="sql"?(((r=e.source)==null?void 0:r.kind)!=="sql"&&i.push(t("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(t("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)})):i.push(t("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:Y(i)}}function x(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[t("invalid_operation_intent","Operation intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(t("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(t("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((r,o)=>{d(r.id)||i.push(t("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${o}.id`)),d(r.prompt)||i.push(t("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${o}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(t("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const r=w(e.analyticsIntent);i.push(...r.errors),n.push(...r.warnings)}}else i.push(t("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:R(i)}}function X(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[t("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:n,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(t("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(t("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const r=x(e.operationIntent);return i.push(...r.errors),n.push(...r.warnings),Array.isArray(e.plannedToolCalls)||i.push(t("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:n,repairHints:R(i)}}function R(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function Y(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_metric":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose one exact metric from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_input_options_field":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the exact field whose option values should be listed."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function Z(e,i,n,r){if(!e||typeof e!="object"){n.push(t("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||n.push(t("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(t("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||r.push(t("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(t("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const o=w(e.analytics);for(const a of o.errors)n.push(t(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`));for(const a of o.warnings)r.push(t(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`))}function z(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[t("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(t("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(t("invalid_kind","Experience intent kind must be dashboard.")),d(e.title)||i.push(t("missing_title","Dashboard intent needs a title.","title"));const r=Array.isArray(e.inputs)?e.inputs:[],o=$(r.filter(u).map(c=>c.id).filter(c=>typeof c=="string"));o&&i.push(t("duplicate_input_id",`Duplicate input id: ${o}.`,"inputs"));for(const[c,l]of r.entries()){const f=`inputs.${c}`;if(!u(l)){i.push(t("invalid_input","Dashboard input must be an object.",f));continue}d(l.id)||i.push(t("missing_input_id","Input needs an id.",`${f}.id`)),d(l.label)||i.push(t("missing_input_label","Input needs a label.",`${f}.label`)),!l.field||!d(l.field.name)?i.push(t("missing_input_field","Input needs a field.",`${f}.field`)):m(l.field,`${f}.field`,i)}const a=Array.isArray(e.sections)?e.sections:[];a.length===0&&i.push(t("missing_sections","Dashboard intent needs at least one section.","sections"));const s=a.flatMap(c=>c&&typeof c=="object"&&Array.isArray(c.views)?c.views.filter(u).map(l=>l.id).filter(l=>!!l):[]),p=$(s);p&&i.push(t("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[c,l]of a.entries()){const f=`sections.${c}`;if(!l||typeof l!="object"){i.push(t("invalid_section","Dashboard section must be an object.",f));continue}if(d(l.title)||i.push(t("missing_section_title","Dashboard section needs a title.",f)),!Array.isArray(l.views)||l.views.length===0){i.push(t("missing_section_views","Dashboard section needs at least one view.",`${f}.views`));continue}for(const[h,v]of l.views.entries())Z(v,`${f}.views.${h}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.parseSemaphorIsoTimeWindowBoundary=g;exports.validateSemaphorAnalyticsIntent=w;exports.validateSemaphorAnalyticsRecoveryPlan=X;exports.validateSemaphorDashboardIntent=z;exports.validateSemaphorOperationIntent=x;
|