react-semaphor 0.1.359 → 0.1.361
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/chunks/{calendar-preferences-dialog-BeZvsJV0.js → calendar-preferences-dialog-BEKBpwMY.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-BHq3bPkF.js → calendar-preferences-dialog-GwtaSN53.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-gm3YPxOh.js → dashboard-briefing-launcher-D6gGO5wz.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-Dr6trdJw.js → dashboard-briefing-launcher-DYxd4856.js} +1 -1
- package/dist/chunks/{dashboard-controls-BZljC-GB.js → dashboard-controls-B4u5RsKl.js} +3 -3
- package/dist/chunks/{dashboard-controls-4a3fKtuD.js → dashboard-controls-C_rExqPw.js} +1 -1
- package/dist/chunks/{dashboard-json-wTRw_VIn.js → dashboard-json-BWWU6a7V.js} +1 -1
- package/dist/chunks/{dashboard-json-4uDp0D6Y.js → dashboard-json-CPGTofhm.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CqnMxF8h.js → edit-dashboard-visual-D_jZ-iix.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-BztJSdkR.js → edit-dashboard-visual-biMO829J.js} +3 -3
- package/dist/chunks/{index-DZ3lq1Pk.js → index-CJ2IEuKz.js} +31368 -31127
- package/dist/chunks/index-Db1XVmfU.js +1411 -0
- package/dist/chunks/{resource-management-panel-CEVKKwSW.js → resource-management-panel-B9-5VHYe.js} +2 -2
- package/dist/chunks/{resource-management-panel-BajPY5IU.js → resource-management-panel-Bam-yvnt.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CT1BlsPJ.js → use-create-flow-overlay-state-DAvEqaJV.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-D010FtSh.js → use-create-flow-overlay-state-dhxgdLYo.js} +1 -1
- package/dist/chunks/{use-visual-utils-CIHFvxpt.js → use-visual-utils-CAKdXsr5.js} +1 -1
- package/dist/chunks/{use-visual-utils-H2FXMsGo.js → use-visual-utils-FoHNPwpu.js} +1 -1
- package/dist/chunks/validation-3nSax_Vs.js +672 -0
- package/dist/chunks/validation-bKtG7HIt.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- 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 +308 -440
- package/dist/data-app-sdk-validation/index.cjs +1 -0
- package/dist/data-app-sdk-validation/index.js +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/data-app-builder.d.ts +68 -9
- package/dist/types/data-app-sdk-validation.d.ts +595 -0
- package/dist/types/data-app-sdk.d.ts +333 -0
- package/package.json +6 -1
- package/dist/chunks/index-YZnHD2NF.js +0 -1410
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { v as x } from "./validators-BnLhuIhd.js";
|
|
2
|
+
import { s as A, c as F, b } from "./source-identity-qAmkNtEK.js";
|
|
3
|
+
function M(e) {
|
|
4
|
+
var r;
|
|
5
|
+
const t = R(e);
|
|
6
|
+
return {
|
|
7
|
+
version: 1,
|
|
8
|
+
kind: "metric",
|
|
9
|
+
id: e.id,
|
|
10
|
+
label: e.label,
|
|
11
|
+
source: p(e),
|
|
12
|
+
metrics: t,
|
|
13
|
+
primaryMetric: P(e, t),
|
|
14
|
+
dateField: e.dateField ? a(e.dateField, "date") : void 0,
|
|
15
|
+
timeGrain: e.timeGrain,
|
|
16
|
+
dimensions: (r = e.dimensions) == null ? void 0 : r.map((i) => a(i, "dimension")),
|
|
17
|
+
comparison: W(e.comparison),
|
|
18
|
+
orderBy: e.orderBy ? {
|
|
19
|
+
field: a(e.orderBy.field),
|
|
20
|
+
direction: e.orderBy.direction
|
|
21
|
+
} : void 0,
|
|
22
|
+
inputs: g(e.inputs),
|
|
23
|
+
limit: e.limit
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function T(e) {
|
|
27
|
+
var r;
|
|
28
|
+
return {
|
|
29
|
+
...M(e),
|
|
30
|
+
...e.timeWindow ? { timeWindow: e.timeWindow } : {},
|
|
31
|
+
...(r = e.filters) != null && r.length ? { filters: e.filters } : {},
|
|
32
|
+
...e.analysis ? { analysis: e.analysis } : {}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function ce(e) {
|
|
36
|
+
return {
|
|
37
|
+
...e.chartTitle ? { chartTitle: e.chartTitle } : {},
|
|
38
|
+
...e.chartType ? { chartType: e.chartType } : {},
|
|
39
|
+
...e.driverMode ? { driverMode: e.driverMode } : {},
|
|
40
|
+
...e.includePopulation !== void 0 ? { includePopulation: e.includePopulation } : {},
|
|
41
|
+
...e.calendarContext ? { calendarContext: e.calendarContext } : {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function P(e, t) {
|
|
45
|
+
if (!e.primaryMetric)
|
|
46
|
+
return t[0] || { name: "", role: "measure" };
|
|
47
|
+
const r = a(e.primaryMetric, "measure"), i = H(r, t), o = i.length === 1 ? i[0] : void 0;
|
|
48
|
+
return o ? _(r, o) : r;
|
|
49
|
+
}
|
|
50
|
+
function R(e) {
|
|
51
|
+
const t = [];
|
|
52
|
+
for (const r of e.metrics.map((i) => a(i, "measure"))) {
|
|
53
|
+
if (!r.name)
|
|
54
|
+
continue;
|
|
55
|
+
const i = t.findIndex(
|
|
56
|
+
(o) => z(o, r)
|
|
57
|
+
);
|
|
58
|
+
if (i === -1) {
|
|
59
|
+
t.push(r);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
t[i] = _(t[i], r);
|
|
63
|
+
}
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
function z(e, t) {
|
|
67
|
+
return A(e, t) && f(e) === f(t);
|
|
68
|
+
}
|
|
69
|
+
function B(e, t) {
|
|
70
|
+
return f(t) === f(e);
|
|
71
|
+
}
|
|
72
|
+
function D(e, t) {
|
|
73
|
+
return t.name !== e.name || e.source && !A(t, e) ? !1 : B(e, t);
|
|
74
|
+
}
|
|
75
|
+
function H(e, t) {
|
|
76
|
+
const r = t.filter(
|
|
77
|
+
(i) => D(e, i)
|
|
78
|
+
);
|
|
79
|
+
return e.aggregate !== void 0, r;
|
|
80
|
+
}
|
|
81
|
+
function f(e) {
|
|
82
|
+
return (e.aggregate || "SUM").toUpperCase();
|
|
83
|
+
}
|
|
84
|
+
function _(e, t) {
|
|
85
|
+
if (e.aggregate && t.aggregate && e.aggregate !== t.aggregate)
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${t.aggregate}.`
|
|
88
|
+
);
|
|
89
|
+
return {
|
|
90
|
+
...F(e, t),
|
|
91
|
+
aggregate: e.aggregate || t.aggregate
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function N(e) {
|
|
95
|
+
if ("sort" in e)
|
|
96
|
+
throw new Error(
|
|
97
|
+
"useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
|
|
98
|
+
);
|
|
99
|
+
if (!V(e))
|
|
100
|
+
throw new Error(
|
|
101
|
+
"useSemaphorRecords needs at least one field."
|
|
102
|
+
);
|
|
103
|
+
const t = O(e.fields);
|
|
104
|
+
return {
|
|
105
|
+
version: 1,
|
|
106
|
+
kind: "records",
|
|
107
|
+
id: e.id,
|
|
108
|
+
label: e.label,
|
|
109
|
+
source: p(e),
|
|
110
|
+
fields: t,
|
|
111
|
+
dateField: e.dateField ? a(e.dateField, "date") : void 0,
|
|
112
|
+
timeGrain: e.timeGrain,
|
|
113
|
+
orderBy: e.orderBy ? {
|
|
114
|
+
field: a(e.orderBy.field),
|
|
115
|
+
direction: e.orderBy.direction
|
|
116
|
+
} : void 0,
|
|
117
|
+
inputs: g(e.inputs),
|
|
118
|
+
limit: e.limit
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function O(e) {
|
|
122
|
+
return e.map((t) => {
|
|
123
|
+
const r = a(t);
|
|
124
|
+
if (!r.role)
|
|
125
|
+
throw new Error(
|
|
126
|
+
`useSemaphorRecords field "${r.name}" needs an explicit role.`
|
|
127
|
+
);
|
|
128
|
+
return r;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function j(e) {
|
|
132
|
+
return {
|
|
133
|
+
version: 1,
|
|
134
|
+
kind: "inputOptions",
|
|
135
|
+
id: e.id,
|
|
136
|
+
label: e.label,
|
|
137
|
+
source: p(e),
|
|
138
|
+
field: a(e.field, "dimension"),
|
|
139
|
+
search: e.search,
|
|
140
|
+
limit: e.limit
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function q(e) {
|
|
144
|
+
if ("toAnalyticsInput" in e) {
|
|
145
|
+
const t = e.toAnalyticsInput();
|
|
146
|
+
return {
|
|
147
|
+
inputId: t.inputId,
|
|
148
|
+
...t.field ? { field: t.field } : {}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
inputId: e.inputId,
|
|
153
|
+
...e.field ? { field: e.field } : {}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function fe(e) {
|
|
157
|
+
const t = g(e);
|
|
158
|
+
return t.length > 0 ? t : void 0;
|
|
159
|
+
}
|
|
160
|
+
function E(e) {
|
|
161
|
+
return (e || []).map(G);
|
|
162
|
+
}
|
|
163
|
+
function ue(e) {
|
|
164
|
+
return E(e).filter((t) => t.isActive);
|
|
165
|
+
}
|
|
166
|
+
function me(e) {
|
|
167
|
+
return e.kind === "filter" ? {
|
|
168
|
+
inputId: e.id,
|
|
169
|
+
kind: e.kind,
|
|
170
|
+
label: e.label,
|
|
171
|
+
field: a(e.field, "dimension"),
|
|
172
|
+
operator: e.operator || "in"
|
|
173
|
+
} : {
|
|
174
|
+
inputId: e.id,
|
|
175
|
+
kind: e.kind,
|
|
176
|
+
label: e.label
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function he(e = []) {
|
|
180
|
+
return e.map(
|
|
181
|
+
(t) => typeof t == "object" ? t : {
|
|
182
|
+
label: String(t),
|
|
183
|
+
value: t
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function U(e) {
|
|
188
|
+
return e == null ? !1 : Array.isArray(e) ? e.length > 0 : typeof e == "string" ? e.trim().length > 0 : !0;
|
|
189
|
+
}
|
|
190
|
+
function G(e) {
|
|
191
|
+
return "toAnalyticsInput" in e ? e.toAnalyticsInput() : "kind" in e && "isActive" in e ? e : {
|
|
192
|
+
...e,
|
|
193
|
+
kind: "filter",
|
|
194
|
+
isActive: U(
|
|
195
|
+
e.value
|
|
196
|
+
),
|
|
197
|
+
value: e.value
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function p(e) {
|
|
201
|
+
return e.source;
|
|
202
|
+
}
|
|
203
|
+
function V(e) {
|
|
204
|
+
var t;
|
|
205
|
+
return !!((t = e.fields) != null && t.length);
|
|
206
|
+
}
|
|
207
|
+
function a(e, t) {
|
|
208
|
+
return {
|
|
209
|
+
...e,
|
|
210
|
+
role: e.role || t
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function g(e) {
|
|
214
|
+
return (e || []).map(q);
|
|
215
|
+
}
|
|
216
|
+
function W(e) {
|
|
217
|
+
if (e)
|
|
218
|
+
return e;
|
|
219
|
+
}
|
|
220
|
+
function K(e, t = {}) {
|
|
221
|
+
const r = t.pathPrefix || "analysisOptions";
|
|
222
|
+
if (e === void 0)
|
|
223
|
+
return { ok: !0 };
|
|
224
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
225
|
+
return s(
|
|
226
|
+
r,
|
|
227
|
+
"Data App analysis options must be an object."
|
|
228
|
+
);
|
|
229
|
+
const i = e, o = {};
|
|
230
|
+
if (i.chartTitle !== void 0) {
|
|
231
|
+
if (typeof i.chartTitle != "string")
|
|
232
|
+
return s(
|
|
233
|
+
`${r}.chartTitle`,
|
|
234
|
+
'Data App analysis option "chartTitle" must be a string.'
|
|
235
|
+
);
|
|
236
|
+
o.chartTitle = i.chartTitle;
|
|
237
|
+
}
|
|
238
|
+
if (i.chartType !== void 0) {
|
|
239
|
+
if (typeof i.chartType != "string")
|
|
240
|
+
return s(
|
|
241
|
+
`${r}.chartType`,
|
|
242
|
+
'Data App analysis option "chartType" must be a string.'
|
|
243
|
+
);
|
|
244
|
+
o.chartType = i.chartType;
|
|
245
|
+
}
|
|
246
|
+
if (i.driverMode !== void 0) {
|
|
247
|
+
if (!L(i.driverMode))
|
|
248
|
+
return s(
|
|
249
|
+
`${r}.driverMode`,
|
|
250
|
+
'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.'
|
|
251
|
+
);
|
|
252
|
+
o.driverMode = i.driverMode;
|
|
253
|
+
}
|
|
254
|
+
if (i.includePopulation !== void 0) {
|
|
255
|
+
if (typeof i.includePopulation != "boolean")
|
|
256
|
+
return s(
|
|
257
|
+
`${r}.includePopulation`,
|
|
258
|
+
'Data App analysis option "includePopulation" must be a boolean.'
|
|
259
|
+
);
|
|
260
|
+
o.includePopulation = i.includePopulation;
|
|
261
|
+
}
|
|
262
|
+
if (i.calendarContext !== void 0) {
|
|
263
|
+
const n = X(
|
|
264
|
+
i.calendarContext,
|
|
265
|
+
{
|
|
266
|
+
pathPrefix: `${r}.calendarContext`,
|
|
267
|
+
validateTimezone: t.validateTimezone
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
if (!n.ok)
|
|
271
|
+
return n;
|
|
272
|
+
o.calendarContext = n.calendarContext;
|
|
273
|
+
}
|
|
274
|
+
return { ok: !0, analysisOptions: o };
|
|
275
|
+
}
|
|
276
|
+
function pe(e) {
|
|
277
|
+
const t = e.hooks.map(
|
|
278
|
+
(o, n) => Q(o, n, {
|
|
279
|
+
fieldCatalogs: e.fieldCatalogs || [],
|
|
280
|
+
requireFieldCatalog: !!e.requireFieldCatalog,
|
|
281
|
+
validateTimezone: e.validateTimezone
|
|
282
|
+
})
|
|
283
|
+
), r = t.flatMap((o) => o.diagnostics), i = t.map((o) => o.executionResult);
|
|
284
|
+
return {
|
|
285
|
+
ok: r.every((o) => o.severity !== "error"),
|
|
286
|
+
diagnostics: r,
|
|
287
|
+
hooks: t,
|
|
288
|
+
intents: t.flatMap((o) => o.intent ? [o.intent] : []),
|
|
289
|
+
executionResults: i
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function Q(e, t, r) {
|
|
293
|
+
const i = `hooks.${t}`;
|
|
294
|
+
try {
|
|
295
|
+
const o = Y(e), n = se(e, o), d = x(o), l = [
|
|
296
|
+
...d.errors.map(
|
|
297
|
+
(m) => v(m, {
|
|
298
|
+
hook: e.hook,
|
|
299
|
+
hookId: n,
|
|
300
|
+
pathPrefix: i,
|
|
301
|
+
severity: "error",
|
|
302
|
+
intent: o
|
|
303
|
+
})
|
|
304
|
+
),
|
|
305
|
+
...d.warnings.map(
|
|
306
|
+
(m) => v(m, {
|
|
307
|
+
hook: e.hook,
|
|
308
|
+
hookId: n,
|
|
309
|
+
pathPrefix: i,
|
|
310
|
+
severity: "warning",
|
|
311
|
+
intent: o
|
|
312
|
+
})
|
|
313
|
+
),
|
|
314
|
+
...Z({
|
|
315
|
+
hookSpec: e,
|
|
316
|
+
hookId: n,
|
|
317
|
+
intent: o,
|
|
318
|
+
pathPrefix: i,
|
|
319
|
+
fieldCatalogs: r.fieldCatalogs,
|
|
320
|
+
requireFieldCatalog: r.requireFieldCatalog
|
|
321
|
+
}),
|
|
322
|
+
...re({
|
|
323
|
+
hookSpec: e,
|
|
324
|
+
hookId: n,
|
|
325
|
+
intent: o,
|
|
326
|
+
pathPrefix: i,
|
|
327
|
+
validateTimezone: r.validateTimezone
|
|
328
|
+
})
|
|
329
|
+
], c = ae(d, l);
|
|
330
|
+
return {
|
|
331
|
+
hook: e.hook,
|
|
332
|
+
hookId: n,
|
|
333
|
+
intent: o,
|
|
334
|
+
diagnostics: l,
|
|
335
|
+
executionResult: S({
|
|
336
|
+
intent: o,
|
|
337
|
+
validation: c,
|
|
338
|
+
diagnostics: l
|
|
339
|
+
})
|
|
340
|
+
};
|
|
341
|
+
} catch (o) {
|
|
342
|
+
const n = {
|
|
343
|
+
severity: "error",
|
|
344
|
+
code: "invalid_hook_spec",
|
|
345
|
+
message: o instanceof Error ? o.message : String(o),
|
|
346
|
+
path: i,
|
|
347
|
+
hook: e.hook,
|
|
348
|
+
hookId: $(e.spec)
|
|
349
|
+
}, d = C([n]);
|
|
350
|
+
return {
|
|
351
|
+
hook: e.hook,
|
|
352
|
+
hookId: n.hookId,
|
|
353
|
+
diagnostics: [n],
|
|
354
|
+
executionResult: S({
|
|
355
|
+
validation: d,
|
|
356
|
+
diagnostics: [n]
|
|
357
|
+
})
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function s(e, t) {
|
|
362
|
+
return {
|
|
363
|
+
ok: !1,
|
|
364
|
+
issues: [
|
|
365
|
+
{
|
|
366
|
+
code: "invalid_analysis_option",
|
|
367
|
+
message: t,
|
|
368
|
+
path: e
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function L(e) {
|
|
374
|
+
return e === "absolute_delta" || e === "largest_negative" || e === "largest_positive" || e === "positive_and_negative" || e === "all";
|
|
375
|
+
}
|
|
376
|
+
function J(e) {
|
|
377
|
+
return e.trim().length > 0 && !Number.isNaN(Date.parse(e));
|
|
378
|
+
}
|
|
379
|
+
function X(e, t) {
|
|
380
|
+
var c;
|
|
381
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
382
|
+
return s(
|
|
383
|
+
t.pathPrefix,
|
|
384
|
+
'Data App analysis option "calendarContext" must be an object.'
|
|
385
|
+
);
|
|
386
|
+
const r = e, i = r.tz, o = r.weekStart, n = r.anchor, d = n && typeof n == "object" && !Array.isArray(n) ? n.iso : void 0, l = typeof i == "string" ? ((c = t.validateTimezone) == null ? void 0 : c.call(t, i)) ?? i : null;
|
|
387
|
+
return l ? typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 6 ? s(
|
|
388
|
+
`${t.pathPrefix}.weekStart`,
|
|
389
|
+
'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'
|
|
390
|
+
) : n !== "now" && !(typeof d == "string" && J(d)) ? s(
|
|
391
|
+
`${t.pathPrefix}.anchor`,
|
|
392
|
+
'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'
|
|
393
|
+
) : {
|
|
394
|
+
ok: !0,
|
|
395
|
+
calendarContext: {
|
|
396
|
+
tz: l,
|
|
397
|
+
weekStart: o,
|
|
398
|
+
anchor: n
|
|
399
|
+
}
|
|
400
|
+
} : s(
|
|
401
|
+
`${t.pathPrefix}.tz`,
|
|
402
|
+
'Data App analysis option "calendarContext.tz" must be a valid timezone string.'
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function Y(e) {
|
|
406
|
+
return e.hook === "useSemaphorMetric" ? M(e.spec) : e.hook === "useSemaphorAnalysis" ? T(e.spec) : e.hook === "useSemaphorRecords" ? N(e.spec) : j(e.spec);
|
|
407
|
+
}
|
|
408
|
+
function Z(e) {
|
|
409
|
+
if (e.fieldCatalogs.length === 0 && !e.requireFieldCatalog)
|
|
410
|
+
return [];
|
|
411
|
+
const t = oe(e.fieldCatalogs, e.intent.source);
|
|
412
|
+
return t ? [
|
|
413
|
+
...ee({
|
|
414
|
+
...e,
|
|
415
|
+
catalog: t
|
|
416
|
+
}),
|
|
417
|
+
...te({
|
|
418
|
+
...e,
|
|
419
|
+
catalog: t
|
|
420
|
+
})
|
|
421
|
+
] : [
|
|
422
|
+
{
|
|
423
|
+
severity: "error",
|
|
424
|
+
code: "invalid_source_ref",
|
|
425
|
+
message: `Source ref for ${e.hookSpec.hook} does not match a visible Semaphor source.`,
|
|
426
|
+
path: `${e.pathPrefix}.spec.source`,
|
|
427
|
+
hook: e.hookSpec.hook,
|
|
428
|
+
hookId: e.hookId,
|
|
429
|
+
intentId: e.intent.id,
|
|
430
|
+
source: e.intent.source
|
|
431
|
+
}
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
function ee(e) {
|
|
435
|
+
return ie(e.intent).flatMap(({ field: t, path: r }) => w(e.catalog, t, e.intent.source) ? [] : [
|
|
436
|
+
{
|
|
437
|
+
severity: "error",
|
|
438
|
+
code: "missing_field",
|
|
439
|
+
message: `Field "${t.name}" is not visible on the selected Semaphor source.`,
|
|
440
|
+
path: `${e.pathPrefix}.${r}`,
|
|
441
|
+
hook: e.hookSpec.hook,
|
|
442
|
+
hookId: e.hookId,
|
|
443
|
+
intentId: e.intent.id,
|
|
444
|
+
source: u(t, e.intent.source),
|
|
445
|
+
field: t
|
|
446
|
+
}
|
|
447
|
+
]);
|
|
448
|
+
}
|
|
449
|
+
function te(e) {
|
|
450
|
+
return ("inputs" in e.intent ? e.intent.inputs || [] : []).flatMap((r, i) => {
|
|
451
|
+
if (!r.field)
|
|
452
|
+
return [];
|
|
453
|
+
const o = u(r.field, e.intent.source);
|
|
454
|
+
return b(o, e.intent.source) ? w(e.catalog, r.field, e.intent.source) ? [] : [
|
|
455
|
+
{
|
|
456
|
+
severity: "error",
|
|
457
|
+
code: "missing_field",
|
|
458
|
+
message: `Input "${r.inputId}" references field "${r.field.name}", which is not visible on the selected Semaphor source.`,
|
|
459
|
+
path: `${e.pathPrefix}.spec.inputs.${i}.field`,
|
|
460
|
+
hook: e.hookSpec.hook,
|
|
461
|
+
hookId: e.hookId,
|
|
462
|
+
intentId: e.intent.id,
|
|
463
|
+
source: o,
|
|
464
|
+
field: r.field
|
|
465
|
+
}
|
|
466
|
+
] : [
|
|
467
|
+
{
|
|
468
|
+
severity: "error",
|
|
469
|
+
code: "unsupported_input_filter_composition",
|
|
470
|
+
message: `Input "${r.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,
|
|
471
|
+
path: `${e.pathPrefix}.spec.inputs.${i}.field`,
|
|
472
|
+
hook: e.hookSpec.hook,
|
|
473
|
+
hookId: e.hookId,
|
|
474
|
+
intentId: e.intent.id,
|
|
475
|
+
source: o,
|
|
476
|
+
field: r.field
|
|
477
|
+
}
|
|
478
|
+
];
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function re(e) {
|
|
482
|
+
if (e.hookSpec.hook !== "useSemaphorAnalysis")
|
|
483
|
+
return [];
|
|
484
|
+
const t = K(e.hookSpec.spec, {
|
|
485
|
+
pathPrefix: `${e.pathPrefix}.spec`,
|
|
486
|
+
validateTimezone: e.validateTimezone
|
|
487
|
+
});
|
|
488
|
+
return t.ok ? [] : t.issues.map((r) => ({
|
|
489
|
+
severity: "error",
|
|
490
|
+
code: r.code,
|
|
491
|
+
message: r.message,
|
|
492
|
+
path: r.path,
|
|
493
|
+
hook: e.hookSpec.hook,
|
|
494
|
+
hookId: e.hookId,
|
|
495
|
+
intentId: e.intent.id,
|
|
496
|
+
source: e.intent.source
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
499
|
+
function ie(e) {
|
|
500
|
+
return e.kind === "metric" ? [
|
|
501
|
+
...e.metrics.map((t, r) => ({
|
|
502
|
+
field: t,
|
|
503
|
+
path: `spec.metrics.${r}`
|
|
504
|
+
})),
|
|
505
|
+
...e.primaryMetric ? [{ field: e.primaryMetric, path: "spec.primaryMetric" }] : [],
|
|
506
|
+
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
507
|
+
...(e.dimensions || []).map((t, r) => ({
|
|
508
|
+
field: t,
|
|
509
|
+
path: `spec.dimensions.${r}`
|
|
510
|
+
})),
|
|
511
|
+
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : [],
|
|
512
|
+
...(e.filters || []).map((t, r) => ({
|
|
513
|
+
field: t.field,
|
|
514
|
+
path: `spec.filters.${r}.field`
|
|
515
|
+
}))
|
|
516
|
+
] : e.kind === "records" ? [
|
|
517
|
+
...e.fields.map((t, r) => ({
|
|
518
|
+
field: t,
|
|
519
|
+
path: `spec.fields.${r}`
|
|
520
|
+
})),
|
|
521
|
+
...e.dateField ? [{ field: e.dateField, path: "spec.dateField" }] : [],
|
|
522
|
+
...e.orderBy ? [{ field: e.orderBy.field, path: "spec.orderBy.field" }] : []
|
|
523
|
+
] : e.kind === "inputOptions" ? [{ field: e.field, path: "spec.field" }] : [];
|
|
524
|
+
}
|
|
525
|
+
function oe(e, t) {
|
|
526
|
+
return e.find((r) => h(r, t));
|
|
527
|
+
}
|
|
528
|
+
function w(e, t, r) {
|
|
529
|
+
const i = u(t, r);
|
|
530
|
+
if (h(e, i))
|
|
531
|
+
return e.fields.find(
|
|
532
|
+
(o) => ne(o, t) && h(
|
|
533
|
+
e,
|
|
534
|
+
u(o, e.source)
|
|
535
|
+
)
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
function h(e, t) {
|
|
539
|
+
return [e.source, ...e.sourceAliases || []].some(
|
|
540
|
+
(r) => b(r, t)
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
function u(e, t) {
|
|
544
|
+
return e.source || t;
|
|
545
|
+
}
|
|
546
|
+
function ne(e, t) {
|
|
547
|
+
const r = y(e.name), i = y(t.name);
|
|
548
|
+
return !!(r && i && r === i);
|
|
549
|
+
}
|
|
550
|
+
function y(e) {
|
|
551
|
+
return (e || "").trim().toLowerCase();
|
|
552
|
+
}
|
|
553
|
+
function v(e, t) {
|
|
554
|
+
return {
|
|
555
|
+
severity: t.severity,
|
|
556
|
+
code: e.code || "invalid_analytics_intent",
|
|
557
|
+
message: e.message,
|
|
558
|
+
path: e.path ? `${t.pathPrefix}.spec.${e.path}` : t.pathPrefix,
|
|
559
|
+
hook: t.hook,
|
|
560
|
+
hookId: t.hookId,
|
|
561
|
+
intentId: t.intent.id,
|
|
562
|
+
source: t.intent.source
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function ae(e, t) {
|
|
566
|
+
const r = C(t);
|
|
567
|
+
return {
|
|
568
|
+
ok: r.ok && e.ok,
|
|
569
|
+
errors: I([
|
|
570
|
+
...e.errors,
|
|
571
|
+
...r.errors
|
|
572
|
+
]),
|
|
573
|
+
warnings: I([
|
|
574
|
+
...e.warnings,
|
|
575
|
+
...r.warnings
|
|
576
|
+
]),
|
|
577
|
+
repairHints: [
|
|
578
|
+
...e.repairHints,
|
|
579
|
+
...r.repairHints
|
|
580
|
+
]
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
function C(e) {
|
|
584
|
+
const t = e.filter((i) => i.severity === "error").map(k), r = e.filter((i) => i.severity === "warning").map(k);
|
|
585
|
+
return {
|
|
586
|
+
ok: t.length === 0,
|
|
587
|
+
errors: t,
|
|
588
|
+
warnings: r,
|
|
589
|
+
repairHints: t.map((i) => {
|
|
590
|
+
var o, n;
|
|
591
|
+
return {
|
|
592
|
+
code: i.code,
|
|
593
|
+
message: i.message,
|
|
594
|
+
fieldRole: i.fieldRole,
|
|
595
|
+
invalidField: (o = i.repairHint) == null ? void 0 : o.invalidField,
|
|
596
|
+
recommendedNextStep: ((n = i.repairHint) == null ? void 0 : n.recommendedNextStep) || "Update the Data App SDK hook spec to use visible Semaphor source and field refs."
|
|
597
|
+
};
|
|
598
|
+
})
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function k(e) {
|
|
602
|
+
var t;
|
|
603
|
+
return {
|
|
604
|
+
code: e.code,
|
|
605
|
+
message: e.message,
|
|
606
|
+
path: e.path,
|
|
607
|
+
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
608
|
+
repairHint: {
|
|
609
|
+
code: e.code,
|
|
610
|
+
message: e.message,
|
|
611
|
+
invalidField: (t = e.field) == null ? void 0 : t.name,
|
|
612
|
+
fieldRole: e.code === "invalid_source_ref" ? "source" : void 0,
|
|
613
|
+
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."
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function I(e) {
|
|
618
|
+
const t = /* @__PURE__ */ new Set();
|
|
619
|
+
return e.filter((r) => {
|
|
620
|
+
const i = `${r.code}:${r.path || ""}:${r.message}`;
|
|
621
|
+
return t.has(i) ? !1 : (t.add(i), !0);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
function S(e) {
|
|
625
|
+
var r, i;
|
|
626
|
+
const t = e.diagnostics.filter((o) => o.severity === "error");
|
|
627
|
+
return {
|
|
628
|
+
intentId: (r = e.intent) == null ? void 0 : r.id,
|
|
629
|
+
status: t.length ? "failed" : "answered",
|
|
630
|
+
resultShape: (i = e.intent) == null ? void 0 : i.kind,
|
|
631
|
+
intent: e.intent,
|
|
632
|
+
validation: e.validation,
|
|
633
|
+
coverage: {
|
|
634
|
+
answeredObligations: t.length ? [] : ["hook_spec_validation"],
|
|
635
|
+
missingObligations: t.length ? ["hook_spec_validation"] : [],
|
|
636
|
+
warnings: e.validation.warnings
|
|
637
|
+
},
|
|
638
|
+
missingFields: t.filter((o) => o.code === "missing_field").flatMap((o) => {
|
|
639
|
+
var n;
|
|
640
|
+
return (n = o.field) != null && n.name ? [o.field.name] : [];
|
|
641
|
+
}),
|
|
642
|
+
warnings: e.diagnostics.filter((o) => o.severity === "warning").map((o) => o.message),
|
|
643
|
+
metadata: {
|
|
644
|
+
validationKind: "data_app_sdk_hook_spec"
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function se(e, t) {
|
|
649
|
+
return t.id || $(e.spec);
|
|
650
|
+
}
|
|
651
|
+
function $(e) {
|
|
652
|
+
if (!e || typeof e != "object" || !("id" in e))
|
|
653
|
+
return;
|
|
654
|
+
const t = e.id;
|
|
655
|
+
return typeof t == "string" && t.trim() ? t : void 0;
|
|
656
|
+
}
|
|
657
|
+
export {
|
|
658
|
+
ce as a,
|
|
659
|
+
T as b,
|
|
660
|
+
M as c,
|
|
661
|
+
N as d,
|
|
662
|
+
j as e,
|
|
663
|
+
me as f,
|
|
664
|
+
q as g,
|
|
665
|
+
U as h,
|
|
666
|
+
fe as i,
|
|
667
|
+
E as j,
|
|
668
|
+
K as k,
|
|
669
|
+
he as n,
|
|
670
|
+
ue as t,
|
|
671
|
+
pe as v
|
|
672
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const B=require("./validators-Cu_w8ZEP.js"),c=require("./source-identity-C-xaeE_I.js");function g(e){var r;const t=H(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:y(e),metrics:t,primaryMetric:O(e,t),dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(r=e.dimensions)==null?void 0:r.map(i=>a(i,"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 b(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 D(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 O(e,t){if(!e.primaryMetric)return t[0]||{name:"",role:"measure"};const r=a(e.primaryMetric,"measure"),i=E(r,t),o=i.length===1?i[0]:void 0;return o?_(r,o):r}function H(e){const t=[];for(const r of e.metrics.map(i=>a(i,"measure"))){if(!r.name)continue;const i=t.findIndex(o=>N(o,r));if(i===-1){t.push(r);continue}t[i]=_(t[i],r)}return t}function N(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 E(e,t){const r=t.filter(i=>q(e,i));return e.aggregate!==void 0,r}function u(e){return(e.aggregate||"SUM").toUpperCase()}function _(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 w(e){if("sort"in e)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!L(e))throw new Error("useSemaphorRecords needs at least one field.");const t=U(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 U(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 C(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 V(e){const t=v(e);return t.length>0?t:void 0}function F(e){return(e||[]).map(K)}function G(e){return F(e).filter(t=>t.isActive)}function Q(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 W(e=[]){return e.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function T(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function K(e){return"toAnalyticsInput"in e?e.toAnalyticsInput():"kind"in e&&"isActive"in e?e:{...e,kind:"filter",isActive:T(e.value),value:e.value}}function y(e){return e.source}function L(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 x(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 i=e,o={};if(i.chartTitle!==void 0){if(typeof i.chartTitle!="string")return s(`${r}.chartTitle`,'Data App analysis option "chartTitle" must be a string.');o.chartTitle=i.chartTitle}if(i.chartType!==void 0){if(typeof i.chartType!="string")return s(`${r}.chartType`,'Data App analysis option "chartType" must be a string.');o.chartType=i.chartType}if(i.driverMode!==void 0){if(!Z(i.driverMode))return s(`${r}.driverMode`,'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.');o.driverMode=i.driverMode}if(i.includePopulation!==void 0){if(typeof i.includePopulation!="boolean")return s(`${r}.includePopulation`,'Data App analysis option "includePopulation" must be a boolean.');o.includePopulation=i.includePopulation}if(i.calendarContext!==void 0){const n=te(i.calendarContext,{pathPrefix:`${r}.calendarContext`,validateTimezone:t.validateTimezone});if(!n.ok)return n;o.calendarContext=n.calendarContext}return{ok:!0,analysisOptions:o}}function X(e){const t=e.hooks.map((o,n)=>Y(o,n,{fieldCatalogs:e.fieldCatalogs||[],requireFieldCatalog:!!e.requireFieldCatalog,validateTimezone:e.validateTimezone})),r=t.flatMap(o=>o.diagnostics),i=t.map(o=>o.executionResult);return{ok:r.every(o=>o.severity!=="error"),diagnostics:r,hooks:t,intents:t.flatMap(o=>o.intent?[o.intent]:[]),executionResults:i}}function Y(e,t,r){const i=`hooks.${t}`;try{const o=re(e),n=fe(e,o),d=B.validateSemaphorAnalyticsIntent(o),l=[...d.errors.map(m=>I(m,{hook:e.hook,hookId:n,pathPrefix:i,severity:"error",intent:o})),...d.warnings.map(m=>I(m,{hook:e.hook,hookId:n,pathPrefix:i,severity:"warning",intent:o})),...ie({hookSpec:e,hookId:n,intent:o,pathPrefix:i,fieldCatalogs:r.fieldCatalogs,requireFieldCatalog:r.requireFieldCatalog}),...ae({hookSpec:e,hookId:n,intent:o,pathPrefix:i,validateTimezone:r.validateTimezone})],f=ce(d,l);return{hook:e.hook,hookId:n,intent:o,diagnostics:l,executionResult:M({intent:o,validation:f,diagnostics:l})}}catch(o){const n={severity:"error",code:"invalid_hook_spec",message:o instanceof Error?o.message:String(o),path:i,hook:e.hook,hookId:z(e.spec)},d=P([n]);return{hook:e.hook,hookId:n.hookId,diagnostics:[n],executionResult:M({validation:d,diagnostics:[n]})}}}function s(e,t){return{ok:!1,issues:[{code:"invalid_analysis_option",message:t,path:e}]}}function Z(e){return e==="absolute_delta"||e==="largest_negative"||e==="largest_positive"||e==="positive_and_negative"||e==="all"}function ee(e){return e.trim().length>0&&!Number.isNaN(Date.parse(e))}function te(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,i=r.tz,o=r.weekStart,n=r.anchor,d=n&&typeof n=="object"&&!Array.isArray(n)?n.iso:void 0,l=typeof i=="string"?((f=t.validateTimezone)==null?void 0:f.call(t,i))??i:null;return l?typeof o!="number"||!Number.isInteger(o)||o<0||o>6?s(`${t.pathPrefix}.weekStart`,'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'):n!=="now"&&!(typeof d=="string"&&ee(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:o,anchor:n}}:s(`${t.pathPrefix}.tz`,'Data App analysis option "calendarContext.tz" must be a valid timezone string.')}function re(e){return e.hook==="useSemaphorMetric"?g(e.spec):e.hook==="useSemaphorAnalysis"?b(e.spec):e.hook==="useSemaphorRecords"?w(e.spec):C(e.spec)}function ie(e){if(e.fieldCatalogs.length===0&&!e.requireFieldCatalog)return[];const t=de(e.fieldCatalogs,e.intent.source);return t?[...oe({...e,catalog:t}),...ne({...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 oe(e){return se(e.intent).flatMap(({field:t,path:r})=>R(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 ne(e){return("inputs"in e.intent?e.intent.inputs||[]:[]).flatMap((r,i)=>{if(!r.field)return[];const o=h(r.field,e.intent.source);return c.semaphorSourcesReferToSameDataset(o,e.intent.source)?R(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.${i}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:o,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.${i}.field`,hook:e.hookSpec.hook,hookId:e.hookId,intentId:e.intent.id,source:o,field:r.field}]})}function ae(e){if(e.hookSpec.hook!=="useSemaphorAnalysis")return[];const t=x(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 se(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 de(e,t){return e.find(r=>p(r,t))}function R(e,t,r){const i=h(t,r);if(p(e,i))return e.fields.find(o=>le(o,t)&&p(e,h(o,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 le(e,t){const r=k(e.name),i=k(t.name);return!!(r&&i&&r===i)}function k(e){return(e||"").trim().toLowerCase()}function I(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 ce(e,t){const r=P(t);return{ok:r.ok&&e.ok,errors:A([...e.errors,...r.errors]),warnings:A([...e.warnings,...r.warnings]),repairHints:[...e.repairHints,...r.repairHints]}}function P(e){const t=e.filter(i=>i.severity==="error").map(S),r=e.filter(i=>i.severity==="warning").map(S);return{ok:t.length===0,errors:t,warnings:r,repairHints:t.map(i=>{var o,n;return{code:i.code,message:i.message,fieldRole:i.fieldRole,invalidField:(o=i.repairHint)==null?void 0:o.invalidField,recommendedNextStep:((n=i.repairHint)==null?void 0:n.recommendedNextStep)||"Update the Data App SDK hook spec to use visible Semaphor source and field refs."}})}}function S(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 A(e){const t=new Set;return e.filter(r=>{const i=`${r.code}:${r.path||""}:${r.message}`;return t.has(i)?!1:(t.add(i),!0)})}function M(e){var r,i;const t=e.diagnostics.filter(o=>o.severity==="error");return{intentId:(r=e.intent)==null?void 0:r.id,status:t.length?"failed":"answered",resultShape:(i=e.intent)==null?void 0:i.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(o=>o.code==="missing_field").flatMap(o=>{var n;return(n=o.field)!=null&&n.name?[o.field.name]:[]}),warnings:e.diagnostics.filter(o=>o.severity==="warning").map(o=>o.message),metadata:{validationKind:"data_app_sdk_hook_spec"}}}function fe(e,t){return t.id||z(e.spec)}function z(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=T;exports.normalizeSemaphorAnalysisQueryOptions=x;exports.normalizeSemaphorInputOptions=W;exports.toSemaphorActiveInputSnapshots=G;exports.toSemaphorAnalysisIntent=b;exports.toSemaphorAnalysisQueryOptions=D;exports.toSemaphorInputBinding=$;exports.toSemaphorInputBindings=V;exports.toSemaphorInputOptionsIntent=C;exports.toSemaphorInputSnapshots=F;exports.toSemaphorInputSpec=Q;exports.toSemaphorMetricIntent=g;exports.toSemaphorRecordsIntent=w;exports.validateSemaphorDataAppHookSpecs=X;
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-Db1XVmfU.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED