react-semaphor 0.1.365 → 0.1.367
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-B4_hBuYu.js → validation-CrUjNWby.js} +115 -94
- package/dist/chunks/validation-DGl8wnTt.js +1 -0
- package/dist/chunks/validators-Dq5X4mp0.js +1 -0
- package/dist/chunks/{validators-BnLhuIhd.js → validators-L0xEXtjf.js} +279 -212
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +288 -280
- 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 +400 -271
- 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 +12 -2
- package/dist/types/dashboard-assistant.d.ts +3 -1
- package/dist/types/dashboard-authoring.d.ts +8 -2
- package/dist/types/data-app-builder.d.ts +3 -1
- package/dist/types/data-app-sdk-validation.d.ts +5 -1
- package/dist/types/data-app-sdk.d.ts +25 -6
- package/dist/types/main.d.ts +3 -1
- 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"});require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../chunks/validators-Dq5X4mp0.js");require("../chunks/source-identity-C-xaeE_I.js");const e=require("../chunks/validation-DGl8wnTt.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-L0xEXtjf.js";
|
|
2
|
+
import "../chunks/source-identity-Dj3dryN9.js";
|
|
3
|
+
import { k as e, v as i } from "../chunks/validation-CrUjNWby.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;
|
|
@@ -527,7 +531,11 @@ export declare type SemaphorInputBinding = {
|
|
|
527
531
|
field?: SemaphorFieldRef;
|
|
528
532
|
};
|
|
529
533
|
|
|
530
|
-
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
534
|
+
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
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;
|
|
531
539
|
|
|
532
540
|
export declare type SemaphorInputOptionsIntent = {
|
|
533
541
|
kind: 'inputOptions';
|
|
@@ -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;
|
|
@@ -755,7 +755,7 @@ declare type SemaphorInputBinding = {
|
|
|
755
755
|
field?: SemaphorFieldRef;
|
|
756
756
|
};
|
|
757
757
|
|
|
758
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
758
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
759
759
|
|
|
760
760
|
declare type SemaphorInputOptionsIntent = {
|
|
761
761
|
kind: 'inputOptions';
|
|
@@ -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;
|
|
@@ -1885,7 +1885,11 @@ declare type SemaphorInputBinding = {
|
|
|
1885
1885
|
field?: SemaphorFieldRef;
|
|
1886
1886
|
};
|
|
1887
1887
|
|
|
1888
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
1888
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
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;
|
|
1889
1893
|
|
|
1890
1894
|
declare type SemaphorInputOptionsIntent = {
|
|
1891
1895
|
kind: 'inputOptions';
|
|
@@ -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;
|
|
@@ -596,7 +596,7 @@ declare type SemaphorInputBinding = {
|
|
|
596
596
|
field?: SemaphorFieldRef;
|
|
597
597
|
};
|
|
598
598
|
|
|
599
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
599
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
600
600
|
|
|
601
601
|
declare type SemaphorInputOptionsIntent = {
|
|
602
602
|
kind: 'inputOptions';
|
|
@@ -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;
|
|
@@ -296,7 +296,7 @@ declare type SemaphorInputHandle<TValue extends SemaphorInputValue = SemaphorInp
|
|
|
296
296
|
toAnalyticsInput(): SemaphorActiveInput<TValue>;
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
299
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
300
300
|
|
|
301
301
|
declare type SemaphorInputOption = {
|
|
302
302
|
label: string;
|
|
@@ -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;
|
|
@@ -35,6 +35,8 @@ export declare function createSemaphorQueryExecutor(): SemaphorQueryExecutor;
|
|
|
35
35
|
|
|
36
36
|
export declare function hasSemaphorInputValue(value: unknown): boolean;
|
|
37
37
|
|
|
38
|
+
export declare function normalizeSemaphorAnalysisPayload(payload: SemaphorAnalysisPayload | undefined | null): SemaphorAnalysisPayload;
|
|
39
|
+
|
|
38
40
|
export declare function normalizeSemaphorAnalysisQueryOptions(value: unknown, options?: {
|
|
39
41
|
pathPrefix?: string;
|
|
40
42
|
validateTimezone?: SemaphorAnalysisTimezoneValidator;
|
|
@@ -73,7 +75,10 @@ export declare type SemaphorAnalysisPayload = {
|
|
|
73
75
|
answerSummary?: string;
|
|
74
76
|
mode?: string;
|
|
75
77
|
data?: Record<string, unknown>;
|
|
78
|
+
resultSets?: Record<string, SemaphorAnalysisResultSet>;
|
|
79
|
+
columns?: SemaphorResultColumn[];
|
|
76
80
|
records?: Array<Record<string, unknown>>;
|
|
81
|
+
rowCount?: number;
|
|
77
82
|
changes?: Array<Record<string, unknown>>;
|
|
78
83
|
drivers?: Array<Record<string, unknown>>;
|
|
79
84
|
largestNegativeChanges?: Array<Record<string, unknown>>;
|
|
@@ -122,6 +127,12 @@ export declare type SemaphorAnalysisQuerySpec = SemaphorMetricQuerySpec & Semaph
|
|
|
122
127
|
filters?: SemaphorAnalyticsFilter[];
|
|
123
128
|
};
|
|
124
129
|
|
|
130
|
+
export declare type SemaphorAnalysisResultSet = {
|
|
131
|
+
records: Array<Record<string, unknown>>;
|
|
132
|
+
columns: SemaphorResultColumn[];
|
|
133
|
+
rowCount?: number;
|
|
134
|
+
};
|
|
135
|
+
|
|
125
136
|
export declare type SemaphorAnalysisTimezoneValidator = (tz: string) => string | null;
|
|
126
137
|
|
|
127
138
|
declare type SemaphorAnalyticsExecutionResult = {
|
|
@@ -150,7 +161,7 @@ declare type SemaphorAnalyticsExecutionStatus = 'answered' | 'partial' | 'failed
|
|
|
150
161
|
|
|
151
162
|
declare type SemaphorAnalyticsFieldRole = 'metric' | 'dateField' | 'dimension' | 'input' | 'source' | 'sql';
|
|
152
163
|
|
|
153
|
-
declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
|
|
164
|
+
export declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
|
|
154
165
|
|
|
155
166
|
declare type SemaphorAnalyticsFilterBase = {
|
|
156
167
|
id?: string;
|
|
@@ -336,7 +347,7 @@ declare type SemaphorExecutionFieldRef = SemaphorFieldRef & {
|
|
|
336
347
|
aggregateSource?: SemaphorMetricAggregateSource;
|
|
337
348
|
};
|
|
338
349
|
|
|
339
|
-
declare type SemaphorFieldRef = {
|
|
350
|
+
export declare type SemaphorFieldRef = {
|
|
340
351
|
name: string;
|
|
341
352
|
label?: string;
|
|
342
353
|
role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
|
|
@@ -348,7 +359,7 @@ declare type SemaphorFieldRef = {
|
|
|
348
359
|
export declare type SemaphorFilterInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
|
|
349
360
|
kind: 'filter';
|
|
350
361
|
field: SemaphorQueryField;
|
|
351
|
-
operator?:
|
|
362
|
+
operator?: SemaphorInputOperatorInput;
|
|
352
363
|
multi?: boolean;
|
|
353
364
|
};
|
|
354
365
|
|
|
@@ -381,7 +392,11 @@ export declare type SemaphorInputHandle<TValue extends SemaphorInputValue = Sema
|
|
|
381
392
|
toAnalyticsInput(): SemaphorActiveInput<TValue>;
|
|
382
393
|
};
|
|
383
394
|
|
|
384
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
395
|
+
export declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
396
|
+
|
|
397
|
+
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';
|
|
398
|
+
|
|
399
|
+
export declare type SemaphorInputOperatorInput = SemaphorInputOperator | SemaphorInputOperatorAlias;
|
|
385
400
|
|
|
386
401
|
export declare type SemaphorInputOption = {
|
|
387
402
|
label: string;
|
|
@@ -568,6 +583,8 @@ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
|
|
|
568
583
|
label?: string;
|
|
569
584
|
dateField?: SemaphorQueryField;
|
|
570
585
|
timeGrain?: SemaphorTimeGrain;
|
|
586
|
+
timeWindow?: SemaphorTimeWindow;
|
|
587
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
571
588
|
orderBy?: SemaphorRecordsOrderBy;
|
|
572
589
|
inputs?: SemaphorInputReference[];
|
|
573
590
|
limit?: number;
|
|
@@ -586,6 +603,8 @@ declare type SemaphorRecordsIntent = {
|
|
|
586
603
|
fields: SemaphorFieldRef[];
|
|
587
604
|
dateField?: SemaphorFieldRef;
|
|
588
605
|
timeGrain?: SemaphorTimeGrain;
|
|
606
|
+
timeWindow?: SemaphorTimeWindow;
|
|
607
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
589
608
|
limit?: number;
|
|
590
609
|
orderBy?: {
|
|
591
610
|
field: SemaphorFieldRef;
|
|
@@ -671,7 +690,7 @@ export declare type SemaphorResultColumn = {
|
|
|
671
690
|
|
|
672
691
|
export declare type SemaphorScalar = string | number | boolean | null;
|
|
673
692
|
|
|
674
|
-
declare type SemaphorSourceRef = {
|
|
693
|
+
export declare type SemaphorSourceRef = {
|
|
675
694
|
kind: 'semantic';
|
|
676
695
|
domainId: string;
|
|
677
696
|
datasetName: string;
|
|
@@ -724,7 +743,7 @@ declare type SemaphorSqlResult = SemaphorAnalyticsResultBase & {
|
|
|
724
743
|
|
|
725
744
|
declare type SemaphorTimeGrain = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
726
745
|
|
|
727
|
-
declare type SemaphorTimeWindow = SemaphorRelativeTimeWindow | SemaphorAbsoluteTimeWindow;
|
|
746
|
+
export declare type SemaphorTimeWindow = SemaphorRelativeTimeWindow | SemaphorAbsoluteTimeWindow;
|
|
728
747
|
|
|
729
748
|
export declare function toSemaphorActiveInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
|
|
730
749
|
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4457,7 +4457,7 @@ declare type SemaphorInputBinding = {
|
|
|
4457
4457
|
field?: SemaphorFieldRef;
|
|
4458
4458
|
};
|
|
4459
4459
|
|
|
4460
|
-
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
4460
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
4461
4461
|
|
|
4462
4462
|
declare type SemaphorInputOptionsIntent = {
|
|
4463
4463
|
kind: 'inputOptions';
|
|
@@ -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;
|