react-semaphor 0.1.345 → 0.1.347
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 +1 -1
- package/dist/chunks/validators-Bu5tOTYW.js +1 -0
- package/dist/chunks/{validators-yMB7Tm4j.js → validators-ZeP5TVCl.js} +150 -127
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +23 -23
- package/dist/types/analytics-protocol.d.ts +22 -6
- package/dist/types/data-app-sdk.d.ts +205 -190
- package/package.json +1 -1
- package/dist/chunks/validators-8R9pr2K9.js +0 -1
|
@@ -2,20 +2,29 @@ import { Context } from 'react';
|
|
|
2
2
|
import { JSX } from 'react/jsx-runtime';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createSemaphorQueryExecutor(): SemaphorQueryExecutor;
|
|
6
6
|
|
|
7
7
|
export declare function hasSemaphorInputValue(value: unknown): boolean;
|
|
8
8
|
|
|
9
9
|
export declare function normalizeSemaphorInputOptions(options?: Array<{
|
|
10
10
|
label: string;
|
|
11
|
-
value:
|
|
12
|
-
} |
|
|
11
|
+
value: SemaphorOptionValue;
|
|
12
|
+
} | SemaphorOptionValue>): {
|
|
13
13
|
label: string;
|
|
14
|
-
value:
|
|
14
|
+
value: SemaphorOptionValue;
|
|
15
15
|
}[];
|
|
16
16
|
|
|
17
17
|
export declare function readWindowRuntime(): SemaphorDataAppWindowRuntime | undefined;
|
|
18
18
|
|
|
19
|
+
export declare type SemaphorActiveInput<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBinding & {
|
|
20
|
+
kind: 'filter' | 'control';
|
|
21
|
+
label?: string;
|
|
22
|
+
value?: TValue;
|
|
23
|
+
isActive: boolean;
|
|
24
|
+
operator?: SemaphorInputOperator;
|
|
25
|
+
controlRole?: SemaphorControlRole;
|
|
26
|
+
};
|
|
27
|
+
|
|
19
28
|
declare type SemaphorAggregateFunction = 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'MEDIAN' | 'DISTINCT';
|
|
20
29
|
|
|
21
30
|
declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAnalyticsNullFilter;
|
|
@@ -43,108 +52,164 @@ declare type SemaphorAnalyticsValueFilter = SemaphorAnalyticsFilterBase & {
|
|
|
43
52
|
|
|
44
53
|
declare type SemaphorAnalyticsValueFilterOperator = Exclude<SemaphorAnalyticsFilterOperator, 'is_null' | 'is_not_null'>;
|
|
45
54
|
|
|
46
|
-
export declare
|
|
47
|
-
|
|
48
|
-
export declare type SemaphorDataAppControlInputSpec<TValue extends SemaphorDataAppInputValue = SemaphorDataAppInputValue> = SemaphorDataAppInputBase<TValue> & {
|
|
55
|
+
export declare type SemaphorControlInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
|
|
49
56
|
kind: 'control';
|
|
50
|
-
role:
|
|
57
|
+
role: SemaphorControlRole;
|
|
51
58
|
};
|
|
52
59
|
|
|
53
|
-
export declare type
|
|
60
|
+
export declare type SemaphorControlRole = 'grain' | 'metric' | 'dimension' | 'aggregation' | 'sqlParam';
|
|
54
61
|
|
|
55
|
-
export declare
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
export declare const SemaphorDataAppContext: Context<SemaphorDataAppRuntime>;
|
|
63
|
+
|
|
64
|
+
export declare function SemaphorDataAppProvider({ token, apiBaseUrl, executor, children, }: SemaphorDataAppProviderProps): JSX.Element;
|
|
65
|
+
|
|
66
|
+
export declare type SemaphorDataAppProviderProps = SemaphorQueryExecutorContext & {
|
|
67
|
+
executor?: SemaphorQueryExecutor;
|
|
68
|
+
children: ReactNode;
|
|
61
69
|
};
|
|
62
70
|
|
|
63
|
-
export declare type
|
|
64
|
-
|
|
71
|
+
export declare type SemaphorDataAppRuntime = SemaphorQueryExecutorContext & {
|
|
72
|
+
executor?: SemaphorQueryExecutor;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
declare type SemaphorDataAppWindowRuntime = {
|
|
65
76
|
apiBaseUrl?: string;
|
|
66
|
-
|
|
77
|
+
dataApiBaseUrl?: string;
|
|
78
|
+
authToken?: null | {
|
|
79
|
+
accessToken?: string;
|
|
80
|
+
};
|
|
67
81
|
};
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
70
84
|
|
|
71
|
-
|
|
85
|
+
declare type SemaphorFieldRef = {
|
|
86
|
+
name: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
|
|
89
|
+
dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'unknown';
|
|
90
|
+
source?: SemaphorSourceRef;
|
|
91
|
+
aggregate?: SemaphorAggregateFunction;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export declare type SemaphorFilterInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorInputBase<TValue> & {
|
|
72
95
|
kind: 'filter';
|
|
73
|
-
field:
|
|
96
|
+
field: SemaphorQueryField;
|
|
74
97
|
operator?: SemaphorInputOperator;
|
|
75
98
|
multi?: boolean;
|
|
76
99
|
};
|
|
77
100
|
|
|
78
|
-
declare type
|
|
101
|
+
declare type SemaphorInputBase<TValue extends SemaphorInputValue> = {
|
|
79
102
|
id: string;
|
|
80
103
|
label?: string;
|
|
81
104
|
value?: TValue;
|
|
82
105
|
defaultValue?: TValue;
|
|
83
106
|
onValueChange?: (value: TValue | undefined) => void;
|
|
84
|
-
options?: Array<
|
|
107
|
+
options?: Array<SemaphorInputOption | SemaphorOptionValue>;
|
|
85
108
|
};
|
|
86
109
|
|
|
87
|
-
|
|
110
|
+
declare type SemaphorInputBinding = {
|
|
111
|
+
inputId: string;
|
|
112
|
+
field?: SemaphorFieldRef;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export declare type SemaphorInputHandle<TValue extends SemaphorInputValue = SemaphorInputValue> = {
|
|
88
116
|
id: string;
|
|
89
117
|
kind: 'filter' | 'control';
|
|
90
118
|
label?: string;
|
|
91
119
|
field?: SemaphorFieldRef;
|
|
92
120
|
operator?: SemaphorInputOperator;
|
|
93
|
-
controlRole?:
|
|
121
|
+
controlRole?: SemaphorControlRole;
|
|
94
122
|
value: TValue | undefined;
|
|
95
|
-
options:
|
|
123
|
+
options: SemaphorInputOption[];
|
|
96
124
|
isActive: boolean;
|
|
97
125
|
setValue(value: TValue | undefined): void;
|
|
98
126
|
clear(): void;
|
|
99
|
-
toAnalyticsInput():
|
|
127
|
+
toAnalyticsInput(): SemaphorActiveInput<TValue>;
|
|
100
128
|
};
|
|
101
129
|
|
|
102
|
-
|
|
130
|
+
declare type SemaphorInputOperator = '=' | '!=' | 'in' | 'not_in' | 'contains' | 'between' | 'not_between' | '>' | '>=' | '<' | '<=';
|
|
131
|
+
|
|
132
|
+
export declare type SemaphorInputOption = {
|
|
103
133
|
label: string;
|
|
104
|
-
value:
|
|
134
|
+
value: SemaphorOptionValue;
|
|
105
135
|
count?: number;
|
|
106
136
|
};
|
|
107
137
|
|
|
108
|
-
|
|
109
|
-
|
|
138
|
+
declare type SemaphorInputOptionsIntent = {
|
|
139
|
+
kind: 'inputOptions';
|
|
140
|
+
version?: SemaphorProtocolVersion;
|
|
141
|
+
id?: string;
|
|
142
|
+
label?: string;
|
|
143
|
+
source: SemaphorSourceRef;
|
|
144
|
+
field: SemaphorFieldRef;
|
|
145
|
+
search?: string;
|
|
146
|
+
limit?: number;
|
|
110
147
|
};
|
|
111
148
|
|
|
112
|
-
export declare type
|
|
149
|
+
export declare type SemaphorInputOptionsPayload = {
|
|
150
|
+
options: SemaphorInputOption[];
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export declare type SemaphorInputOptionsQueryResult = SemaphorQueryState & SemaphorInputOptionsPayload & {
|
|
113
154
|
id?: string;
|
|
114
155
|
intent?: Extract<SemaphorAnalyticsIntent, {
|
|
115
156
|
kind: 'inputOptions';
|
|
116
157
|
}>;
|
|
117
158
|
};
|
|
118
159
|
|
|
119
|
-
export declare type
|
|
160
|
+
export declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & {
|
|
120
161
|
id?: string;
|
|
121
162
|
label?: string;
|
|
122
|
-
field:
|
|
163
|
+
field: SemaphorQueryField;
|
|
123
164
|
search?: string;
|
|
124
165
|
limit?: number;
|
|
125
166
|
};
|
|
126
167
|
|
|
127
|
-
export declare type
|
|
168
|
+
export declare type SemaphorInputReference = SemaphorInputBinding | SemaphorActiveInput | SemaphorInputHandle;
|
|
128
169
|
|
|
129
|
-
export declare type
|
|
130
|
-
kind: 'filter' | 'control';
|
|
131
|
-
label?: string;
|
|
132
|
-
value?: TValue;
|
|
133
|
-
isActive: boolean;
|
|
134
|
-
operator?: SemaphorInputOperator;
|
|
135
|
-
controlRole?: SemaphorDataAppControlRole;
|
|
136
|
-
};
|
|
170
|
+
export declare type SemaphorInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue> = SemaphorFilterInputSpec<TValue> | SemaphorControlInputSpec<TValue>;
|
|
137
171
|
|
|
138
|
-
export declare type
|
|
172
|
+
export declare type SemaphorInputValue = SemaphorScalar | SemaphorScalar[];
|
|
139
173
|
|
|
140
|
-
|
|
174
|
+
declare type SemaphorMetricAnalysis = {
|
|
175
|
+
kind: 'period_change';
|
|
176
|
+
orderBy?: 'absolute_change' | 'positive_change' | 'negative_change' | 'period';
|
|
177
|
+
direction?: 'increase' | 'decrease' | 'both';
|
|
178
|
+
timeWindow?: SemaphorTimeWindow;
|
|
179
|
+
};
|
|
141
180
|
|
|
142
|
-
export declare type
|
|
181
|
+
export declare type SemaphorMetricComparison = {
|
|
143
182
|
kind: 'previous_period' | 'previous_year' | 'target';
|
|
144
183
|
targetValue?: number;
|
|
145
184
|
};
|
|
146
185
|
|
|
147
|
-
|
|
186
|
+
declare type SemaphorMetricIntent = {
|
|
187
|
+
kind: 'metric';
|
|
188
|
+
version?: SemaphorProtocolVersion;
|
|
189
|
+
id?: string;
|
|
190
|
+
source: SemaphorSourceRef;
|
|
191
|
+
metrics: SemaphorFieldRef[];
|
|
192
|
+
primaryMetric?: SemaphorFieldRef;
|
|
193
|
+
label?: string;
|
|
194
|
+
dateField?: SemaphorFieldRef;
|
|
195
|
+
timeGrain?: SemaphorTimeGrain;
|
|
196
|
+
timeWindow?: SemaphorTimeWindow;
|
|
197
|
+
dimensions?: SemaphorFieldRef[];
|
|
198
|
+
filters?: SemaphorAnalyticsFilter[];
|
|
199
|
+
comparison?: {
|
|
200
|
+
kind: 'previous_period' | 'previous_year' | 'target';
|
|
201
|
+
targetValue?: number;
|
|
202
|
+
};
|
|
203
|
+
analysis?: SemaphorMetricAnalysis;
|
|
204
|
+
orderBy?: {
|
|
205
|
+
field: SemaphorFieldRef;
|
|
206
|
+
direction: 'asc' | 'desc';
|
|
207
|
+
};
|
|
208
|
+
inputs?: SemaphorInputBinding[];
|
|
209
|
+
limit?: number;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export declare type SemaphorMetricPayload = {
|
|
148
213
|
value: number | string | null;
|
|
149
214
|
metrics?: Record<string, number | string | null>;
|
|
150
215
|
comparisonValue?: number | string | null;
|
|
@@ -153,168 +218,77 @@ export declare type SemaphorDataAppMetricData = {
|
|
|
153
218
|
records?: Array<Record<string, unknown>>;
|
|
154
219
|
};
|
|
155
220
|
|
|
156
|
-
export declare type
|
|
221
|
+
export declare type SemaphorMetricQueryResult = SemaphorQueryState & SemaphorMetricPayload & {
|
|
157
222
|
id?: string;
|
|
158
223
|
intent?: SemaphorMetricIntent;
|
|
159
224
|
};
|
|
160
225
|
|
|
161
|
-
export declare type
|
|
226
|
+
export declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & {
|
|
162
227
|
id?: string;
|
|
163
228
|
label?: string;
|
|
164
|
-
metrics:
|
|
165
|
-
primaryMetric?:
|
|
166
|
-
dateField?:
|
|
229
|
+
metrics: SemaphorNonEmptyArray<SemaphorQueryField>;
|
|
230
|
+
primaryMetric?: SemaphorQueryField;
|
|
231
|
+
dateField?: SemaphorQueryField;
|
|
167
232
|
timeGrain?: SemaphorTimeGrain;
|
|
168
|
-
dimensions?:
|
|
169
|
-
comparison?:
|
|
170
|
-
orderBy?:
|
|
171
|
-
inputs?:
|
|
233
|
+
dimensions?: SemaphorQueryField[];
|
|
234
|
+
comparison?: SemaphorMetricComparison;
|
|
235
|
+
orderBy?: SemaphorQueryOrderBy;
|
|
236
|
+
inputs?: SemaphorInputReference[];
|
|
172
237
|
limit?: number;
|
|
173
238
|
};
|
|
174
239
|
|
|
175
|
-
export declare type
|
|
176
|
-
|
|
177
|
-
export declare type SemaphorDataAppOptionValue = string | number | boolean;
|
|
178
|
-
|
|
179
|
-
export declare type SemaphorDataAppOrderBy = {
|
|
180
|
-
field: SemaphorDataAppFieldSpec;
|
|
181
|
-
direction: 'asc' | 'desc';
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export declare function SemaphorDataAppProvider({ token, apiBaseUrl, executor, children, }: SemaphorDataAppProviderProps): JSX.Element;
|
|
240
|
+
export declare type SemaphorNonEmptyArray<T> = [T, ...T[]];
|
|
185
241
|
|
|
186
|
-
export declare type
|
|
187
|
-
executor?: SemaphorDataAppExecutor;
|
|
188
|
-
children: ReactNode;
|
|
189
|
-
};
|
|
242
|
+
export declare type SemaphorOptionValue = string | number | boolean;
|
|
190
243
|
|
|
191
|
-
|
|
192
|
-
status: SemaphorDataAppQueryStatus;
|
|
193
|
-
isLoading: boolean;
|
|
194
|
-
error: Error | null;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export declare type SemaphorDataAppQueryStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
198
|
-
|
|
199
|
-
declare type SemaphorDataAppRecordsBaseSpec = SemaphorDataAppSourceSpec & {
|
|
200
|
-
id?: string;
|
|
201
|
-
label?: string;
|
|
202
|
-
dateField?: SemaphorDataAppFieldSpec;
|
|
203
|
-
timeGrain?: SemaphorTimeGrain;
|
|
204
|
-
orderBy?: SemaphorDataAppRecordsOrderBy;
|
|
205
|
-
inputs?: SemaphorDataAppInputReference[];
|
|
206
|
-
limit?: number;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
export declare type SemaphorDataAppRecordsData<TRecord extends Record<string, unknown> = Record<string, unknown>> = {
|
|
210
|
-
records: TRecord[];
|
|
211
|
-
columns?: Array<{
|
|
212
|
-
name: string;
|
|
213
|
-
label?: string;
|
|
214
|
-
dataType?: SemaphorFieldRef['dataType'];
|
|
215
|
-
role?: SemaphorFieldRef['role'];
|
|
216
|
-
}>;
|
|
217
|
-
rowCount?: number;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
export declare type SemaphorDataAppRecordsFieldSpec = SemaphorFieldRef & {
|
|
221
|
-
role: NonNullable<SemaphorFieldRef['role']>;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export declare type SemaphorDataAppRecordsOrderBy = SemaphorDataAppOrderBy;
|
|
225
|
-
|
|
226
|
-
export declare type SemaphorDataAppRecordsResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorDataAppQueryState & SemaphorDataAppRecordsData<TRecord> & {
|
|
227
|
-
id?: string;
|
|
228
|
-
intent?: SemaphorRecordsIntent;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
declare type SemaphorDataAppRecordsSelectorSpec = {
|
|
232
|
-
fields: SemaphorDataAppNonEmptyArray<SemaphorDataAppRecordsFieldSpec>;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export declare type SemaphorDataAppRecordsSpec = SemaphorDataAppRecordsBaseSpec & SemaphorDataAppRecordsSelectorSpec;
|
|
236
|
-
|
|
237
|
-
export declare type SemaphorDataAppRuntime = SemaphorDataAppExecutorContext & {
|
|
238
|
-
executor?: SemaphorDataAppExecutor;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
export declare type SemaphorDataAppScalar = string | number | boolean | null;
|
|
244
|
+
declare type SemaphorProtocolVersion = 1;
|
|
242
245
|
|
|
243
|
-
export declare type
|
|
244
|
-
|
|
246
|
+
export declare type SemaphorQueryExecutor = {
|
|
247
|
+
executeMetric(intent: SemaphorMetricIntent, context: SemaphorQueryExecutorContext): Promise<SemaphorMetricPayload>;
|
|
248
|
+
executeRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(intent: SemaphorRecordsIntent, context: SemaphorQueryExecutorContext): Promise<SemaphorRecordsPayload<TRecord>>;
|
|
249
|
+
executeInputOptions(intent: Extract<SemaphorAnalyticsIntent, {
|
|
250
|
+
kind: 'inputOptions';
|
|
251
|
+
}>, context: SemaphorQueryExecutorContext): Promise<SemaphorInputOptionsPayload>;
|
|
245
252
|
};
|
|
246
253
|
|
|
247
|
-
declare type
|
|
254
|
+
export declare type SemaphorQueryExecutorContext = {
|
|
255
|
+
token?: string;
|
|
248
256
|
apiBaseUrl?: string;
|
|
249
|
-
|
|
250
|
-
authToken?: null | {
|
|
251
|
-
accessToken?: string;
|
|
252
|
-
};
|
|
257
|
+
activeInputs?: SemaphorActiveInput[];
|
|
253
258
|
};
|
|
254
259
|
|
|
255
|
-
declare type
|
|
256
|
-
|
|
257
|
-
declare type SemaphorFieldRef = {
|
|
258
|
-
name: string;
|
|
259
|
-
label?: string;
|
|
260
|
-
role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
|
|
261
|
-
dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'unknown';
|
|
262
|
-
source?: SemaphorSourceRef;
|
|
263
|
-
aggregate?: SemaphorAggregateFunction;
|
|
264
|
-
};
|
|
260
|
+
export declare type SemaphorQueryField = SemaphorFieldRef;
|
|
265
261
|
|
|
266
|
-
declare type
|
|
267
|
-
|
|
268
|
-
|
|
262
|
+
export declare type SemaphorQueryOrderBy = {
|
|
263
|
+
field: SemaphorQueryField;
|
|
264
|
+
direction: 'asc' | 'desc';
|
|
269
265
|
};
|
|
270
266
|
|
|
271
|
-
declare type
|
|
272
|
-
|
|
273
|
-
declare type SemaphorInputOptionsIntent = {
|
|
274
|
-
kind: 'inputOptions';
|
|
275
|
-
version?: SemaphorProtocolVersion;
|
|
276
|
-
id?: string;
|
|
277
|
-
label?: string;
|
|
267
|
+
export declare type SemaphorQuerySourceSpec = {
|
|
278
268
|
source: SemaphorSourceRef;
|
|
279
|
-
field: SemaphorFieldRef;
|
|
280
|
-
search?: string;
|
|
281
|
-
limit?: number;
|
|
282
269
|
};
|
|
283
270
|
|
|
284
|
-
declare type
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
timeWindow?: SemaphorTimeWindow;
|
|
271
|
+
export declare type SemaphorQueryState = {
|
|
272
|
+
status: SemaphorQueryStatus;
|
|
273
|
+
isLoading: boolean;
|
|
274
|
+
error: Error | null;
|
|
289
275
|
};
|
|
290
276
|
|
|
291
|
-
declare type
|
|
292
|
-
|
|
293
|
-
|
|
277
|
+
export declare type SemaphorQueryStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
278
|
+
|
|
279
|
+
declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
|
|
294
280
|
id?: string;
|
|
295
|
-
source: SemaphorSourceRef;
|
|
296
|
-
metrics: SemaphorFieldRef[];
|
|
297
|
-
primaryMetric?: SemaphorFieldRef;
|
|
298
281
|
label?: string;
|
|
299
|
-
dateField?:
|
|
282
|
+
dateField?: SemaphorQueryField;
|
|
300
283
|
timeGrain?: SemaphorTimeGrain;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
filters?: SemaphorAnalyticsFilter[];
|
|
304
|
-
comparison?: {
|
|
305
|
-
kind: 'previous_period' | 'previous_year' | 'target';
|
|
306
|
-
targetValue?: number;
|
|
307
|
-
};
|
|
308
|
-
analysis?: SemaphorMetricAnalysis;
|
|
309
|
-
orderBy?: {
|
|
310
|
-
field: SemaphorFieldRef;
|
|
311
|
-
direction: 'asc' | 'desc';
|
|
312
|
-
};
|
|
313
|
-
inputs?: SemaphorInputBinding[];
|
|
284
|
+
orderBy?: SemaphorRecordsOrderBy;
|
|
285
|
+
inputs?: SemaphorInputReference[];
|
|
314
286
|
limit?: number;
|
|
315
287
|
};
|
|
316
288
|
|
|
317
|
-
declare type
|
|
289
|
+
export declare type SemaphorRecordsField = SemaphorFieldRef & {
|
|
290
|
+
role: NonNullable<SemaphorFieldRef['role']>;
|
|
291
|
+
};
|
|
318
292
|
|
|
319
293
|
declare type SemaphorRecordsIntent = {
|
|
320
294
|
kind: 'records';
|
|
@@ -333,6 +307,47 @@ declare type SemaphorRecordsIntent = {
|
|
|
333
307
|
inputs?: SemaphorInputBinding[];
|
|
334
308
|
};
|
|
335
309
|
|
|
310
|
+
export declare type SemaphorRecordsOrderBy = SemaphorQueryOrderBy;
|
|
311
|
+
|
|
312
|
+
export declare type SemaphorRecordsPayload<TRecord extends Record<string, unknown> = Record<string, unknown>> = {
|
|
313
|
+
records: TRecord[];
|
|
314
|
+
columns?: SemaphorResultColumn[];
|
|
315
|
+
rowCount?: number;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export declare type SemaphorRecordsQueryResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorQueryState & SemaphorRecordsPayload<TRecord> & {
|
|
319
|
+
id?: string;
|
|
320
|
+
intent?: SemaphorRecordsIntent;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export declare type SemaphorRecordsQuerySpec = SemaphorRecordsBaseQuerySpec & SemaphorRecordsSelectorSpec;
|
|
324
|
+
|
|
325
|
+
declare type SemaphorRecordsSelectorSpec = {
|
|
326
|
+
fields: SemaphorNonEmptyArray<SemaphorRecordsField>;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export declare type SemaphorResultColumn = {
|
|
330
|
+
/**
|
|
331
|
+
* Stable row accessor for this result. Consumers should read values with
|
|
332
|
+
* `row[column.key]`; labels are display-only and may change.
|
|
333
|
+
*/
|
|
334
|
+
key: string;
|
|
335
|
+
/**
|
|
336
|
+
* Semantic/source field name before result-key disambiguation.
|
|
337
|
+
*/
|
|
338
|
+
name: string;
|
|
339
|
+
/**
|
|
340
|
+
* Human-facing display label.
|
|
341
|
+
*/
|
|
342
|
+
label: string;
|
|
343
|
+
role?: SemaphorFieldRef['role'];
|
|
344
|
+
dataType?: SemaphorFieldRef['dataType'];
|
|
345
|
+
aggregate?: SemaphorFieldRef['aggregate'];
|
|
346
|
+
source?: SemaphorFieldRef['source'];
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export declare type SemaphorScalar = string | number | boolean | null;
|
|
350
|
+
|
|
336
351
|
declare type SemaphorSourceRef = {
|
|
337
352
|
kind: 'semantic';
|
|
338
353
|
domainId: string;
|
|
@@ -382,37 +397,37 @@ declare type SemaphorTimeWindow = {
|
|
|
382
397
|
completeness?: 'include_partial' | 'complete_periods';
|
|
383
398
|
};
|
|
384
399
|
|
|
385
|
-
export declare function toSemaphorActiveInputSnapshots(inputs:
|
|
400
|
+
export declare function toSemaphorActiveInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
|
|
386
401
|
|
|
387
|
-
export declare function toSemaphorInputBinding(input:
|
|
402
|
+
export declare function toSemaphorInputBinding(input: SemaphorInputReference): SemaphorInputBinding;
|
|
388
403
|
|
|
389
|
-
export declare function toSemaphorInputBindings(inputs:
|
|
404
|
+
export declare function toSemaphorInputBindings(inputs: SemaphorInputReference[] | undefined): SemaphorInputBinding[] | undefined;
|
|
390
405
|
|
|
391
|
-
export declare function toSemaphorInputOptionsIntent(spec:
|
|
406
|
+
export declare function toSemaphorInputOptionsIntent(spec: SemaphorInputOptionsQuerySpec): Extract<SemaphorAnalyticsIntent, {
|
|
392
407
|
kind: 'inputOptions';
|
|
393
408
|
}>;
|
|
394
409
|
|
|
395
|
-
export declare function toSemaphorInputSnapshots(inputs:
|
|
410
|
+
export declare function toSemaphorInputSnapshots(inputs: SemaphorInputReference[] | undefined): SemaphorActiveInput[];
|
|
396
411
|
|
|
397
|
-
export declare function toSemaphorInputSpec<TValue extends
|
|
398
|
-
kind:
|
|
412
|
+
export declare function toSemaphorInputSpec<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: SemaphorInputSpec<TValue>): SemaphorInputBinding & {
|
|
413
|
+
kind: SemaphorInputSpec['kind'];
|
|
399
414
|
label?: string;
|
|
400
415
|
field?: SemaphorFieldRef;
|
|
401
416
|
operator?: SemaphorInputOperator;
|
|
402
417
|
};
|
|
403
418
|
|
|
404
|
-
export declare function toSemaphorMetricIntent(spec:
|
|
419
|
+
export declare function toSemaphorMetricIntent(spec: SemaphorMetricQuerySpec): SemaphorMetricIntent;
|
|
405
420
|
|
|
406
|
-
export declare function toSemaphorRecordsIntent(spec:
|
|
421
|
+
export declare function toSemaphorRecordsIntent(spec: SemaphorRecordsQuerySpec): SemaphorRecordsIntent;
|
|
407
422
|
|
|
408
423
|
export declare function useSemaphorDataAppRuntime(): SemaphorDataAppRuntime;
|
|
409
424
|
|
|
410
|
-
export declare function useSemaphorInput<TValue extends
|
|
425
|
+
export declare function useSemaphorInput<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: SemaphorInputSpec<TValue>): SemaphorInputHandle;
|
|
411
426
|
|
|
412
|
-
export declare function useSemaphorInputOptions(spec:
|
|
427
|
+
export declare function useSemaphorInputOptions(spec: SemaphorInputOptionsQuerySpec): SemaphorInputOptionsQueryResult;
|
|
413
428
|
|
|
414
|
-
export declare function useSemaphorMetric(spec:
|
|
429
|
+
export declare function useSemaphorMetric(spec: SemaphorMetricQuerySpec): SemaphorMetricQueryResult;
|
|
415
430
|
|
|
416
|
-
export declare function useSemaphorRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(spec:
|
|
431
|
+
export declare function useSemaphorRecords<TRecord extends Record<string, unknown> = Record<string, unknown>>(spec: SemaphorRecordsQuerySpec): SemaphorRecordsQueryResult<TRecord>;
|
|
417
432
|
|
|
418
433
|
export { }
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function _(e){return e?e.kind==="semantic"?[e.kind,e.domainId,e.datasetId||"",e.datasetName].join(":"):e.kind==="physical"?[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":"):[e.kind,e.connectionId,e.dialect||"",e.label||""].join(":"):""}function b(e,i){return!e||!i?e===i:e.kind!==i.kind?!1:e.kind==="semantic"&&i.kind==="semantic"?e.domainId!==i.domainId?!1:e.datasetId&&i.datasetId?e.datasetId===i.datasetId:e.datasetName===i.datasetName:_(e)===_(i)}function A(e,i){return e.kind!=="semantic"||i.kind!=="semantic"?e:{...e,datasetId:e.datasetId||i.datasetId,label:e.label||i.label,connectionId:e.connectionId||i.connectionId}}function I(e,i){return e.name===i.name&&b(e.source,i.source)}function F(e,i){return{...e,label:e.label||i.label,role:e.role||i.role,dataType:e.dataType||i.dataType,source:e.source&&i.source?A(e.source,i.source):e.source||i.source}}function a(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function j(e){for(let i=0;i<e.length;i+=1){const n=e[i];if(e.some((o,r)=>r!==i&&M(o,n)))return!1}return!0}function S(e,i){return I(e,i)}function M(e,i){return S(e,i)&&y(e)===y(i)}function T(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 D(e,i){return h(e,i).length===1}function x(e,i){return h(e,i).length===1}function h(e,i){return i.filter(o=>q(e,o))}function q(e,i){return C(e,i)?e.source?S(i,e):!0:!1}function C(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||E(e,i)&&y(i)!==y(e))}function E(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()}function d(e){return typeof e=="string"&&e.trim().length>0}function c(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function g(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}const P=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function k(e,i,n){if(!e||typeof e!="object"){n.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||n.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||n.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||n.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||n.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||n.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}n.push(a("invalid_source_kind","Source kind is not supported.",i))}function f(e,i,n,o={}){if(!e||!c(e)){o.required&&n.push(a("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||n.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&k(e.source,`${i}.source`,n),O(e.aggregate,`${i}.aggregate`,n)}function O(e,i,n){e!==void 0&&(typeof e!="string"||!P.has(e))&&n.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function H(e,i){if(e.analysis===void 0)return;if(!c(e.analysis)){i.push(a("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(a("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(a("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(a("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(a("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&&w(n,"analysis.timeWindow",i)}function w(e,i,n){if(!c(e)){n.push(a("invalid_time_window","Time window must be a structured object.",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(a("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(a("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(a("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(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function U(e,i,n){if(e!==void 0){if(!Array.isArray(e)){n.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((o,r)=>{const s=`${i}.${r}`;if(!c(o)){n.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",s));return}const t=o;f(t.field,`${s}.field`,n,{required:!0});const p=t.operator==="is_null"||t.operator==="is_not_null";if(t.operator!==void 0&&t.operator!=="="&&t.operator!=="!="&&t.operator!=="in"&&t.operator!=="not_in"&&t.operator!=="contains"&&t.operator!=="not_contains"&&t.operator!=="between"&&t.operator!=="not_between"&&t.operator!==">"&&t.operator!==">="&&t.operator!=="<"&&t.operator!=="<="&&t.operator!=="is_null"&&t.operator!=="is_not_null"&&n.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${s}.operator`)),t.values===void 0&&!p&&n.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",s)),p&&t.values!==void 0){n.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${s}.values`));return}t.values!==void 0&&!Array.isArray(t.values)&&n.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${s}.values`))})}}function v(e){var o;const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Analytics intent version must be 1.","version")),k(e.source,"source",i),e.kind==="metric"){const r=Array.isArray(e.metrics)?e.metrics.filter(s=>c(s)&&d(s.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(a("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(s=>!c(s)||!d(s.name))&&i.push(a("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),r.forEach((s,t)=>{f(s,`metrics.${t}`,i,{required:!0})}),r.length>0&&!j(r)){const s=r.find((t,p)=>r.some((u,l)=>l!==p&&M(u,t)));s&&i.push(a("duplicate_metric",T(s),"metrics"))}if(c(e.primaryMetric)&&d(e.primaryMetric.name)&&h(e.primaryMetric,r).length>1&&i.push(a("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(f(e.primaryMetric,"primaryMetric",i,{required:!0}),c(e.primaryMetric)&&d(e.primaryMetric.name)&&r.length>0&&!D(e.primaryMetric,r)&&i.push(a("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(a("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(s=>!c(s)||!d(s.name))&&i.push(a("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&f(e.dateField,"dateField",i),e.timeWindow!==void 0&&(w(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),U(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((s,t)=>{f(s,`dimensions.${t}`,i)}),e.orderBy!==void 0){if(!c(e.orderBy))i.push(a("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),c(e.orderBy.field)&&d(e.orderBy.field.name)){const s=[...r,...e.timeGrain&&e.dateField&&c(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(t=>c(t)&&d(t.name)):[]];s.length>0&&!x(e.orderBy.field,s)&&i.push(a("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}H(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(a("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(r=>!c(r)||!d(r.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i),e.orderBy!==void 0&&(c(e.orderBy)?(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(a("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!d(e.field.name))&&i.push(a("missing_input_options_field","Input options intent needs a field.","field")),f(e.field,"field",i,{required:!0})):e.kind==="sql"?(((o=e.source)==null?void 0:o.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)})):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:L(i)}}function $(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(a("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((o,r)=>{d(o.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${r}.id`)),d(o.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${r}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(a("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const o=v(e.analyticsIntent);i.push(...o.errors),n.push(...o.warnings)}}else i.push(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:N(i)}}function G(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(a("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const o=$(e.operationIntent);return i.push(...o.errors),n.push(...o.warnings),Array.isArray(e.plannedToolCalls)||i.push(a("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:n,repairHints:N(i)}}function N(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 L(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 Q(e,i,n,o){if(!e||typeof e!="object"){n.push(a("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||n.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||o.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const r=v(e.analytics);for(const s of r.errors)n.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`));for(const s of r.warnings)o.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`))}function V(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(a("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(a("invalid_kind","Experience intent kind must be dashboard.")),d(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const o=Array.isArray(e.inputs)?e.inputs:[],r=g(o.filter(c).map(u=>u.id).filter(u=>typeof u=="string"));r&&i.push(a("duplicate_input_id",`Duplicate input id: ${r}.`,"inputs"));for(const[u,l]of o.entries()){const m=`inputs.${u}`;if(!c(l)){i.push(a("invalid_input","Dashboard input must be an object.",m));continue}d(l.id)||i.push(a("missing_input_id","Input needs an id.",`${m}.id`)),d(l.label)||i.push(a("missing_input_label","Input needs a label.",`${m}.label`)),!l.field||!d(l.field.name)?i.push(a("missing_input_field","Input needs a field.",`${m}.field`)):f(l.field,`${m}.field`,i)}const s=Array.isArray(e.sections)?e.sections:[];s.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const t=s.flatMap(u=>u&&typeof u=="object"&&Array.isArray(u.views)?u.views.filter(c).map(l=>l.id).filter(l=>!!l):[]),p=g(t);p&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[u,l]of s.entries()){const m=`sections.${u}`;if(!l||typeof l!="object"){i.push(a("invalid_section","Dashboard section must be an object.",m));continue}if(d(l.title)||i.push(a("missing_section_title","Dashboard section needs a title.",m)),!Array.isArray(l.views)||l.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${m}.views`));continue}for(const[R,B]of l.views.entries())Q(B,`${m}.views.${R}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.preferSemaphorFieldRefMetadata=F;exports.preferSemaphorSourceMetadata=A;exports.semaphorFieldRefsMatch=I;exports.semaphorSourceIdentityKey=_;exports.semaphorSourcesReferToSameDataset=b;exports.validateSemaphorAnalyticsIntent=v;exports.validateSemaphorAnalyticsRecoveryPlan=G;exports.validateSemaphorDashboardIntent=V;exports.validateSemaphorOperationIntent=$;
|