react-semaphor 0.1.418 → 0.1.419
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 +2 -2
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/{analyze-result-contract-Akysi2ML.js → analyze-result-contract-DdhEt99q.js} +46 -45
- package/dist/chunks/{analyze-result-contract-COjyJzYm.js → analyze-result-contract-DwRzl7yJ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-BbuLgela.js → calendar-preferences-dialog-DIfAbE_y.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-CInkkhl_.js → calendar-preferences-dialog-f0Z7Kf-U.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-B4OWNsVD.js → dashboard-briefing-launcher-C3tNkGFG.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-D7FNuDuc.js → dashboard-briefing-launcher-anh-Jy5v.js} +4 -4
- package/dist/chunks/{dashboard-controls-DcX7Mid4.js → dashboard-controls-8dCQaPaq.js} +5 -5
- package/dist/chunks/{dashboard-controls-DTC1eCz0.js → dashboard-controls-DQxlOxzy.js} +1 -1
- package/dist/chunks/{dashboard-json-vu38P5pV.js → dashboard-json-B309EInF.js} +1 -1
- package/dist/chunks/{dashboard-json-BHWbQS6I.js → dashboard-json-i7Ae9KGD.js} +3 -3
- package/dist/chunks/{edit-dashboard-visual-CkBhJBhp.js → edit-dashboard-visual-4HycwBHR.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DsCr90_3.js → edit-dashboard-visual-z3IqzYnj.js} +4 -4
- package/dist/chunks/{index-C56DuHI8.js → index-B6DLEXRX.js} +5 -5
- package/dist/chunks/{index-C8thRvkW.js → index-yxKWKFdr.js} +2 -2
- package/dist/chunks/{switch-Dsx-IwBE.js → switch-COWQU8aK.js} +1 -1
- package/dist/chunks/{switch-BXuyni6l.js → switch-D6Ygf3wA.js} +1 -1
- package/dist/chunks/{update-policy-B5S_LfEu.js → update-policy-BzT2k4n6.js} +1 -1
- package/dist/chunks/{update-policy-BqBKUk3Q.js → update-policy-VloD-0YM.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-CzftV84t.js → use-create-flow-overlay-state-CX0D-6HM.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-BDv_VpL6.js → use-create-flow-overlay-state-DENfd7sW.js} +1 -1
- package/dist/chunks/{validators-CPFcUMrV.js → validators-BMQo93Y0.js} +1 -1
- package/dist/chunks/{validators-CLzrE2N_.js → validators-Cxr9qbrR.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +2 -2
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +123 -92
- package/dist/data-app-codegen-node/index.js +461 -422
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +193 -188
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +4 -0
- package/dist/types/dashboard-assistant.d.ts +1 -0
- package/dist/types/data-app-sdk-validation.d.ts +1 -0
- package/dist/types/data-app-sdk.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { S as In, a as Fn, i as bn, v as Vn } from "../chunks/analyze-result-contract-
|
|
2
|
-
import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-
|
|
3
|
-
import { C as Rn, e as Mn, R as
|
|
1
|
+
import { S as In, a as Fn, i as bn, v as Vn } from "../chunks/analyze-result-contract-DdhEt99q.js";
|
|
2
|
+
import { c as ke, G as fe, a as Re, b as Me } from "../chunks/update-policy-BzT2k4n6.js";
|
|
3
|
+
import { C as Rn, e as Mn, R as xn, f as Nn, g as Cn, h as On, i as Gn, j as Kn, v as En, d as An } from "../chunks/update-policy-BzT2k4n6.js";
|
|
4
4
|
import { createHash as ye } from "node:crypto";
|
|
5
5
|
const hn = "src/semaphor/generated", H = `// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
6
6
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
7
7
|
`;
|
|
8
8
|
function wn(e, n = {}) {
|
|
9
9
|
ke(e);
|
|
10
|
-
const r =
|
|
10
|
+
const r = xe(e);
|
|
11
11
|
if (r.views.length === 0 && !n.allowEmpty)
|
|
12
12
|
throw new Error(
|
|
13
13
|
"Contract generation produced zero executable views. Stop and ask for a different domain/goal or semantic model improvement; pass --allow-empty only for an explicit model-gap report."
|
|
@@ -17,14 +17,14 @@ function wn(e, n = {}) {
|
|
|
17
17
|
files: t,
|
|
18
18
|
generatorName: n.generatorName || "react-semaphor/data-app-codegen/node",
|
|
19
19
|
generatorVersion: n.generatorVersion || "unknown"
|
|
20
|
-
}),
|
|
20
|
+
}), a = {
|
|
21
21
|
...t,
|
|
22
22
|
"contract.manifest.json": `${JSON.stringify(o, null, 2)}
|
|
23
23
|
`
|
|
24
24
|
};
|
|
25
25
|
return {
|
|
26
26
|
schemaVersion: fe,
|
|
27
|
-
files:
|
|
27
|
+
files: a,
|
|
28
28
|
manifest: o,
|
|
29
29
|
contentHash: String(o.generatedContentHash || ""),
|
|
30
30
|
usageExample: Ee(r),
|
|
@@ -38,94 +38,94 @@ function wn(e, n = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
var
|
|
41
|
+
function xe(e) {
|
|
42
|
+
var u, d, c, i, p, S, g, $, F, R, b, M;
|
|
43
43
|
const n = [], r = [];
|
|
44
|
-
for (const
|
|
45
|
-
|
|
46
|
-
for (const
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
for (const s of e.inputs) {
|
|
45
|
+
h(r, s.fieldRef);
|
|
46
|
+
for (const I of s.bindings || [])
|
|
47
|
+
h(r, I.fieldRef);
|
|
48
|
+
h(r, (u = s.optionQuery) == null ? void 0 : u.valueFieldRef), h(r, (d = s.optionQuery) == null ? void 0 : d.labelFieldRef), h(r, (c = s.optionQuery) == null ? void 0 : c.filterFieldRef), Q(r, (i = s.optionQuery) == null ? void 0 : i.spec);
|
|
49
49
|
}
|
|
50
|
-
for (const
|
|
51
|
-
|
|
52
|
-
for (const
|
|
53
|
-
|
|
50
|
+
for (const s of e.filterContracts) {
|
|
51
|
+
h(r, s.fieldRef), h(r, (p = s.optionQuery) == null ? void 0 : p.valueFieldRef), h(r, (S = s.optionQuery) == null ? void 0 : S.labelFieldRef), h(r, (g = s.optionQuery) == null ? void 0 : g.filterFieldRef), Q(r, ($ = s.optionQuery) == null ? void 0 : $.spec);
|
|
52
|
+
for (const I of s.bindings || [])
|
|
53
|
+
h(r, I.fieldRef);
|
|
54
54
|
}
|
|
55
|
-
for (const
|
|
56
|
-
for (const
|
|
57
|
-
|
|
58
|
-
Q(r, (
|
|
55
|
+
for (const s of e.views) {
|
|
56
|
+
for (const I of s.fields || [])
|
|
57
|
+
h(r, I);
|
|
58
|
+
Q(r, (F = s.sdkSpec) == null ? void 0 : F.spec), Q(r, s.visualSpec);
|
|
59
59
|
}
|
|
60
60
|
const t = e.implementationChecklist || {};
|
|
61
|
-
for (const
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
-
for (const
|
|
65
|
-
|
|
61
|
+
for (const s of Object.values(t.bindingsByView || {}))
|
|
62
|
+
for (const I of Array.isArray(s) ? s : [])
|
|
63
|
+
h(r, I.fieldRef), h(r, I.optionValueField), h(r, I.optionLabelField);
|
|
64
|
+
for (const s of t.requiredInputOptions || [])
|
|
65
|
+
h(r, s.visibleLabelField), h(r, s.optionValueField), h(r, s.runtimeFilterField);
|
|
66
66
|
const o = dn(
|
|
67
67
|
[
|
|
68
|
-
...e.sources.map((
|
|
69
|
-
raw:
|
|
70
|
-
key: $e(
|
|
71
|
-
aliases: Ie(
|
|
68
|
+
...e.sources.map((s) => ({
|
|
69
|
+
raw: s,
|
|
70
|
+
key: $e(s),
|
|
71
|
+
aliases: Ie(s),
|
|
72
72
|
name: ""
|
|
73
73
|
})),
|
|
74
|
-
...r.map((
|
|
74
|
+
...r.map((s) => sn(s)).filter(K)
|
|
75
75
|
]
|
|
76
76
|
);
|
|
77
|
-
v(o, (
|
|
78
|
-
const
|
|
79
|
-
return
|
|
80
|
-
|
|
77
|
+
v(o, (s) => {
|
|
78
|
+
const I = V(s.raw);
|
|
79
|
+
return q(
|
|
80
|
+
s.raw.label || (I == null ? void 0 : I.datasetName) || (I == null ? void 0 : I.datasetId) || (I == null ? void 0 : I.name) || s.raw.kind || "source"
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
|
-
const
|
|
84
|
-
r.filter((
|
|
85
|
-
raw:
|
|
86
|
-
key:
|
|
83
|
+
const a = pn(o), l = X(
|
|
84
|
+
r.filter((s) => s.name).map((s) => ({
|
|
85
|
+
raw: s,
|
|
86
|
+
key: L(s),
|
|
87
87
|
name: ""
|
|
88
88
|
})),
|
|
89
|
-
(
|
|
89
|
+
(s) => s.key
|
|
90
90
|
);
|
|
91
91
|
v(
|
|
92
92
|
l,
|
|
93
|
-
(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
(s) => q([
|
|
94
|
+
s.raw.sourceKey ? fn(s.raw.sourceKey) : "",
|
|
95
|
+
s.raw.aggregate ? s.raw.aggregate.toLowerCase() : "",
|
|
96
|
+
s.raw.name
|
|
97
97
|
].filter(Boolean).join("_"))
|
|
98
98
|
);
|
|
99
|
-
const y = new Map(l.map((
|
|
100
|
-
raw:
|
|
101
|
-
name:
|
|
99
|
+
const y = new Map(l.map((s) => [s.key, s.name])), w = e.inputs.map((s) => ({
|
|
100
|
+
raw: s,
|
|
101
|
+
name: q(s.id || s.label || "input")
|
|
102
102
|
}));
|
|
103
|
-
v(
|
|
104
|
-
const f =
|
|
105
|
-
input:
|
|
106
|
-
name: `${
|
|
107
|
-
raw:
|
|
103
|
+
v(w, (s) => s.name);
|
|
104
|
+
const f = w.filter((s) => !!s.raw.optionQuery).map((s) => ({
|
|
105
|
+
input: s,
|
|
106
|
+
name: `${s.name}Options`,
|
|
107
|
+
raw: s.raw.optionQuery
|
|
108
108
|
}));
|
|
109
|
-
v(f, (
|
|
110
|
-
for (const
|
|
111
|
-
an(
|
|
112
|
-
`Input option query ${((
|
|
109
|
+
v(f, (s) => s.name);
|
|
110
|
+
for (const s of f)
|
|
111
|
+
an(s.raw.labelFieldRef, s.raw.valueFieldRef) && un(s.raw.valueFieldRef) && n.push(
|
|
112
|
+
`Input option query ${((R = s.raw.spec) == null ? void 0 : R.inputId) || s.input.raw.id || s.name} uses identifier field ${s.raw.valueFieldRef.name} as both label and value. It can execute, but the UI will show key values unless the semantic model exposes a human-readable label through a modeled relationship.`
|
|
113
113
|
);
|
|
114
114
|
const m = e.views.filter(
|
|
115
|
-
(
|
|
116
|
-
var
|
|
117
|
-
return !!((
|
|
115
|
+
(s) => {
|
|
116
|
+
var I, T;
|
|
117
|
+
return !!((I = s.sdkSpec) != null && I.builder && ((T = s.sdkSpec) != null && T.spec));
|
|
118
118
|
}
|
|
119
|
-
).map((
|
|
120
|
-
raw:
|
|
121
|
-
name:
|
|
119
|
+
).map((s) => ({
|
|
120
|
+
raw: s,
|
|
121
|
+
name: q(s.id || s.title || "query")
|
|
122
122
|
}));
|
|
123
|
-
v(m, (
|
|
124
|
-
const
|
|
125
|
-
for (const
|
|
126
|
-
(!("sdkSpec" in
|
|
127
|
-
return
|
|
128
|
-
inputs:
|
|
123
|
+
v(m, (s) => s.name);
|
|
124
|
+
const N = e.views.filter((s) => ce(s) && !("sdkSpec" in s)).map((s) => on(s));
|
|
125
|
+
for (const s of e.views)
|
|
126
|
+
(!("sdkSpec" in s) || !((b = s.sdkSpec) != null && b.builder) || !((M = s.sdkSpec) != null && M.spec)) && !ce(s) && n.push(`Skipped view ${s.id || s.title || "unknown"} because it has no sdkSpec.`);
|
|
127
|
+
return Ne({
|
|
128
|
+
inputs: w,
|
|
129
129
|
views: m,
|
|
130
130
|
filterContracts: e.filterContracts
|
|
131
131
|
}), {
|
|
@@ -133,49 +133,49 @@ function Ne(e) {
|
|
|
133
133
|
title: e.title || "Semaphor Data App",
|
|
134
134
|
sources: o,
|
|
135
135
|
fields: l,
|
|
136
|
-
inputs:
|
|
136
|
+
inputs: w,
|
|
137
137
|
optionQueries: f,
|
|
138
138
|
views: m,
|
|
139
|
-
presentationViews:
|
|
139
|
+
presentationViews: N,
|
|
140
140
|
filterContracts: e.filterContracts,
|
|
141
141
|
checklist: t,
|
|
142
|
-
sourceNameByKey:
|
|
142
|
+
sourceNameByKey: a,
|
|
143
143
|
fieldNameByKey: y,
|
|
144
144
|
warnings: n
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Ne({
|
|
148
148
|
inputs: e,
|
|
149
149
|
views: n,
|
|
150
150
|
filterContracts: r
|
|
151
151
|
}) {
|
|
152
|
-
const t = new Set(e.map((
|
|
153
|
-
for (const [
|
|
152
|
+
const t = new Set(e.map((a) => a.raw.id).filter(Boolean)), o = new Set(n.map((a) => a.raw.id).filter(Boolean));
|
|
153
|
+
for (const [a, l] of r.entries()) {
|
|
154
154
|
if (!t.has(l.inputId))
|
|
155
|
-
throw new Error(`filterContracts.${
|
|
156
|
-
const y = new Set(l.appliesToViewIds || []),
|
|
155
|
+
throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);
|
|
156
|
+
const y = new Set(l.appliesToViewIds || []), w = new Set(l.notAppliedToViewIds || []);
|
|
157
157
|
for (const [f, m] of (l.appliesToViewIds || []).entries())
|
|
158
158
|
if (!o.has(m))
|
|
159
159
|
throw new Error(
|
|
160
|
-
`filterContracts.${
|
|
160
|
+
`filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`
|
|
161
161
|
);
|
|
162
162
|
for (const [f, m] of (l.notAppliedToViewIds || []).entries())
|
|
163
163
|
if (!o.has(m))
|
|
164
164
|
throw new Error(
|
|
165
|
-
`filterContracts.${
|
|
165
|
+
`filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`
|
|
166
166
|
);
|
|
167
167
|
for (const [f, m] of (l.bindings || []).entries()) {
|
|
168
168
|
if (!o.has(m.viewId))
|
|
169
169
|
throw new Error(
|
|
170
|
-
`filterContracts.${
|
|
170
|
+
`filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`
|
|
171
171
|
);
|
|
172
172
|
if (!y.has(m.viewId))
|
|
173
173
|
throw new Error(
|
|
174
|
-
`filterContracts.${
|
|
174
|
+
`filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`
|
|
175
175
|
);
|
|
176
|
-
if (
|
|
176
|
+
if (w.has(m.viewId))
|
|
177
177
|
throw new Error(
|
|
178
|
-
`filterContracts.${
|
|
178
|
+
`filterContracts.${a}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -183,7 +183,7 @@ function xe({
|
|
|
183
183
|
function Ce(e) {
|
|
184
184
|
return {
|
|
185
185
|
"sources.ts": ve(e),
|
|
186
|
-
"fields.ts":
|
|
186
|
+
"fields.ts": qe(e),
|
|
187
187
|
"inputs.ts": Te(e),
|
|
188
188
|
"queries.ts": _e(e),
|
|
189
189
|
"bindings.ts": Le(e),
|
|
@@ -234,14 +234,14 @@ function Ee(e) {
|
|
|
234
234
|
);
|
|
235
235
|
if (n)
|
|
236
236
|
return [
|
|
237
|
-
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView,
|
|
237
|
+
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
238
238
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
239
239
|
"const inputHandles = createInputHandleMap(handles);",
|
|
240
240
|
`const sortOption = recordsSortOptionsForView.${n.name}[0];`,
|
|
241
241
|
'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',
|
|
242
242
|
`const query = queries.${n.name}({ page, pageSize, sort });`,
|
|
243
243
|
`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,
|
|
244
|
-
`const rows =
|
|
244
|
+
`const rows = rowsForView.${n.name}(result);`,
|
|
245
245
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
246
246
|
].join(`
|
|
247
247
|
`);
|
|
@@ -250,14 +250,14 @@ function Ee(e) {
|
|
|
250
250
|
);
|
|
251
251
|
if (r)
|
|
252
252
|
return [
|
|
253
|
-
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView,
|
|
253
|
+
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
254
254
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
255
255
|
"const inputHandles = createInputHandleMap(handles);",
|
|
256
256
|
`const sortOption = recordsSortOptionsForView.${r.name}[0];`,
|
|
257
257
|
'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',
|
|
258
258
|
`const query = queries.${r.name}({ sort });`,
|
|
259
259
|
`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,
|
|
260
|
-
`const rows =
|
|
260
|
+
`const rows = rowsForView.${r.name}(result);`,
|
|
261
261
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
262
262
|
].join(`
|
|
263
263
|
`);
|
|
@@ -266,12 +266,12 @@ function Ee(e) {
|
|
|
266
266
|
);
|
|
267
267
|
if (t)
|
|
268
268
|
return [
|
|
269
|
-
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView,
|
|
269
|
+
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
270
270
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
271
271
|
"const inputHandles = createInputHandleMap(handles);",
|
|
272
272
|
`const query = queries.${t.name}({ page, pageSize });`,
|
|
273
273
|
`const result = useSemaphorQuery(query, queryOptionsForView.${t.name}(inputHandles));`,
|
|
274
|
-
`const rows =
|
|
274
|
+
`const rows = rowsForView.${t.name}(result);`,
|
|
275
275
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
276
276
|
].join(`
|
|
277
277
|
`);
|
|
@@ -280,26 +280,26 @@ function Ee(e) {
|
|
|
280
280
|
);
|
|
281
281
|
if (o)
|
|
282
282
|
return [
|
|
283
|
-
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView,
|
|
283
|
+
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
284
284
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
285
285
|
"const inputHandles = createInputHandleMap(handles);",
|
|
286
286
|
`const query = queries.${o.name}({ page, pageSize });`,
|
|
287
287
|
`const result = useSemaphorQuery(query, queryOptionsForView.${o.name}(inputHandles));`,
|
|
288
|
-
`const rows =
|
|
288
|
+
`const rows = rowsForView.${o.name}(result);`,
|
|
289
289
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
290
290
|
].join(`
|
|
291
291
|
`);
|
|
292
|
-
const
|
|
292
|
+
const a = e.views.find((f) => {
|
|
293
293
|
var m;
|
|
294
294
|
return cn((m = f.raw.sdkSpec) == null ? void 0 : m.builder);
|
|
295
295
|
});
|
|
296
|
-
if (
|
|
296
|
+
if (a)
|
|
297
297
|
return [
|
|
298
|
-
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView,
|
|
298
|
+
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
299
299
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
300
300
|
"const inputHandles = createInputHandleMap(handles);",
|
|
301
|
-
`const result = useSemaphorQuery(queries.${
|
|
302
|
-
`const rows =
|
|
301
|
+
`const result = useSemaphorQuery(queries.${a.name}(), queryOptionsForView.${a.name}(inputHandles));`,
|
|
302
|
+
`const rows = rowsForView.${a.name}(result);`,
|
|
303
303
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
304
304
|
].join(`
|
|
305
305
|
`);
|
|
@@ -326,11 +326,11 @@ function Ee(e) {
|
|
|
326
326
|
}
|
|
327
327
|
function W(e) {
|
|
328
328
|
var n;
|
|
329
|
-
return
|
|
329
|
+
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "records";
|
|
330
330
|
}
|
|
331
331
|
function Ae(e) {
|
|
332
332
|
var n;
|
|
333
|
-
return
|
|
333
|
+
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "metric";
|
|
334
334
|
}
|
|
335
335
|
function E(e) {
|
|
336
336
|
var n, r, t;
|
|
@@ -338,7 +338,7 @@ function E(e) {
|
|
|
338
338
|
}
|
|
339
339
|
function ue(e) {
|
|
340
340
|
var n;
|
|
341
|
-
return
|
|
341
|
+
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "sql";
|
|
342
342
|
}
|
|
343
343
|
function A(e) {
|
|
344
344
|
var n, r, t;
|
|
@@ -349,8 +349,8 @@ function He(e) {
|
|
|
349
349
|
}
|
|
350
350
|
function ve(e) {
|
|
351
351
|
const n = e.sources.map(({ name: t, raw: o }) => {
|
|
352
|
-
const
|
|
353
|
-
return ` ${t}: ${
|
|
352
|
+
const a = je(o);
|
|
353
|
+
return ` ${t}: ${a},`;
|
|
354
354
|
}).join(`
|
|
355
355
|
`), r = e.sources.some((t) => t.raw.kind === "semantic") ? `import { semaphor } from "react-semaphor/data-app-sdk";
|
|
356
356
|
|
|
@@ -361,7 +361,7 @@ ${n}
|
|
|
361
361
|
} as const;
|
|
362
362
|
`;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function je(e) {
|
|
365
365
|
if (e.kind === "semantic") {
|
|
366
366
|
const n = {
|
|
367
367
|
domainId: e.domainId,
|
|
@@ -369,14 +369,14 @@ function qe(e) {
|
|
|
369
369
|
datasetName: e.datasetName,
|
|
370
370
|
label: e.label
|
|
371
371
|
};
|
|
372
|
-
return `semaphor.source.semantic(${k(
|
|
372
|
+
return `semaphor.source.semantic(${k(G(n))})`;
|
|
373
373
|
}
|
|
374
|
-
return `${k(
|
|
374
|
+
return `${k(G({ ...e, sourceKey: void 0 }))} as const`;
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function qe(e) {
|
|
377
377
|
const n = e.fields.map(({ name: t, raw: o }) => {
|
|
378
|
-
const
|
|
379
|
-
return ` ${t}: ${
|
|
378
|
+
const a = Be(o, e);
|
|
379
|
+
return ` ${t}: ${a},`;
|
|
380
380
|
}).join(`
|
|
381
381
|
`), r = n.includes("sources.") ? `import { sources } from "./sources";
|
|
382
382
|
|
|
@@ -387,7 +387,7 @@ ${n}
|
|
|
387
387
|
} as const;
|
|
388
388
|
`;
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Be(e, n) {
|
|
391
391
|
const r = {
|
|
392
392
|
name: e.name,
|
|
393
393
|
label: e.label,
|
|
@@ -399,90 +399,90 @@ function je(e, n) {
|
|
|
399
399
|
throw new Error(
|
|
400
400
|
`Field ${e.name} references source ${t}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`
|
|
401
401
|
);
|
|
402
|
-
const
|
|
403
|
-
return o &&
|
|
402
|
+
const a = Object.entries(G(r)).map(([l, y]) => `${JSON.stringify(l)}: ${O(y, n)}`);
|
|
403
|
+
return o && a.push(`"source": sources.${o}`), `{ ${a.join(", ")} }`;
|
|
404
404
|
}
|
|
405
405
|
function Te(e) {
|
|
406
|
-
const n = e.inputs.map((
|
|
407
|
-
const
|
|
408
|
-
`id: ${JSON.stringify(
|
|
409
|
-
`label: ${JSON.stringify(
|
|
410
|
-
`operator: ${JSON.stringify(mn(
|
|
406
|
+
const n = e.inputs.map((c) => {
|
|
407
|
+
const i = x(c.raw.fieldRef, e), p = [
|
|
408
|
+
`id: ${JSON.stringify(c.raw.id)}`,
|
|
409
|
+
`label: ${JSON.stringify(c.raw.label || c.raw.id)}`,
|
|
410
|
+
`operator: ${JSON.stringify(mn(c.raw))}`
|
|
411
411
|
];
|
|
412
|
-
if (
|
|
413
|
-
throw new Error(`Input ${
|
|
414
|
-
return ` ${
|
|
412
|
+
if (i && p.push(`field: fields.${i}`), c.raw.relationshipHint && p.push(`relationshipHint: ${k(c.raw.relationshipHint)}`), !i)
|
|
413
|
+
throw new Error(`Input ${c.raw.id || c.name} is missing a generated field reference.`);
|
|
414
|
+
return ` ${c.name}: semaphor.filter({ ${p.join(", ")} }),`;
|
|
415
415
|
}).join(`
|
|
416
|
-
`), r = e.inputs.map((
|
|
417
|
-
const
|
|
418
|
-
id:
|
|
419
|
-
inputId:
|
|
420
|
-
source:
|
|
421
|
-
sourceKey:
|
|
422
|
-
valueField:
|
|
423
|
-
labelField:
|
|
424
|
-
population:
|
|
425
|
-
dependencies:
|
|
416
|
+
`), r = e.inputs.map((c) => `filterSpecs.${c.name}`).join(", "), t = e.inputs.map((c) => JSON.stringify(c.raw.id)).join(", "), o = e.optionQueries.map((c) => {
|
|
417
|
+
const i = c.input.raw, p = c.raw, S = V(p.spec) || {}, {
|
|
418
|
+
id: g,
|
|
419
|
+
inputId: $,
|
|
420
|
+
source: F,
|
|
421
|
+
sourceKey: R,
|
|
422
|
+
valueField: b,
|
|
423
|
+
labelField: M,
|
|
424
|
+
population: s,
|
|
425
|
+
dependencies: I,
|
|
426
426
|
limit: T,
|
|
427
427
|
...ee
|
|
428
|
-
} = S,
|
|
428
|
+
} = S, J = p.sourceKey ? { sourceKey: p.sourceKey } : p.source || F || (typeof R == "string" ? { sourceKey: R } : void 0), ne = Se(J, e), re = x(p.valueFieldRef, e), te = x(p.labelFieldRef, e), oe = ge(c), se = {
|
|
429
429
|
...ee,
|
|
430
|
-
id: p.id || S.id || `${
|
|
431
|
-
inputId:
|
|
432
|
-
source:
|
|
430
|
+
id: p.id || S.id || `${i.id}-options`,
|
|
431
|
+
inputId: i.id,
|
|
432
|
+
source: J,
|
|
433
433
|
valueField: p.valueFieldRef,
|
|
434
434
|
labelField: p.labelFieldRef,
|
|
435
|
-
population: p.population ||
|
|
435
|
+
population: p.population || s,
|
|
436
436
|
dependencies: oe,
|
|
437
437
|
limit: p.limit || T || 100
|
|
438
438
|
};
|
|
439
439
|
if (!ne || !re || !te)
|
|
440
|
-
throw new Error(`Input option query ${p.id || `${
|
|
441
|
-
const Fe = Object.entries(
|
|
442
|
-
return ` ${
|
|
440
|
+
throw new Error(`Input option query ${p.id || `${i.id}-options`} is missing source, valueField, or labelField.`);
|
|
441
|
+
const Fe = Object.entries(G(se)).map(([be, Ve]) => `${JSON.stringify(be)}: ${O(Ve, e)}`);
|
|
442
|
+
return ` ${c.name}: semaphor.inputOptions({ ${Fe.join(", ")} }),`;
|
|
443
443
|
}).join(`
|
|
444
|
-
`),
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
444
|
+
`), a = e.optionQueries.map((c) => {
|
|
445
|
+
const i = Qe(e, c), p = i.length > 0 ? "inputHandles" : "_inputHandles", S = i.map((g) => {
|
|
446
|
+
const $ = x(g.raw.fieldRef, e);
|
|
447
|
+
if (!$)
|
|
448
448
|
throw new Error(
|
|
449
|
-
`Input option query ${
|
|
449
|
+
`Input option query ${c.raw.id || `${c.input.raw.id}-options`} references input ${g.raw.id} without a generated field reference.`
|
|
450
450
|
);
|
|
451
|
-
const
|
|
452
|
-
return ` if (${
|
|
453
|
-
inputs.push(semaphor.bindInput(${
|
|
451
|
+
const F = `inputHandles[${JSON.stringify(g.raw.id)}]`;
|
|
452
|
+
return ` if (${F}) {
|
|
453
|
+
inputs.push(semaphor.bindInput(${F}, { field: fields.${$} }));
|
|
454
454
|
}`;
|
|
455
455
|
}).join(`
|
|
456
456
|
`);
|
|
457
|
-
return ` ${
|
|
457
|
+
return ` ${c.name}(${p}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
458
458
|
const inputs: SemaphorInputReference[] = [];
|
|
459
459
|
${S}
|
|
460
460
|
return inputs;
|
|
461
461
|
},`;
|
|
462
462
|
}).join(`
|
|
463
463
|
|
|
464
|
-
`), l = e.optionQueries.map((
|
|
464
|
+
`), l = e.optionQueries.map((c) => ` ${c.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
465
465
|
return {
|
|
466
|
-
inputs: inputsForInputOptionQuery.${
|
|
466
|
+
inputs: inputsForInputOptionQuery.${c.name}(inputHandles),
|
|
467
467
|
};
|
|
468
468
|
},`).join(`
|
|
469
469
|
|
|
470
|
-
`), y = e.optionQueries.map((
|
|
471
|
-
return queryOptionsForInputOptionQuery.${
|
|
472
|
-
`),
|
|
470
|
+
`), y = e.optionQueries.map((c) => ` case ${JSON.stringify(c.raw.id || `${c.input.raw.id}-options`)}:
|
|
471
|
+
return queryOptionsForInputOptionQuery.${c.name}(inputHandles);`).join(`
|
|
472
|
+
`), w = e.inputs.length > 0, f = e.optionQueries.length > 0, m = f ? "inputOptionQueryId" : "_inputOptionQueryId", N = f ? "inputHandles" : "_inputHandles", u = [
|
|
473
473
|
"SemaphorInputHandle",
|
|
474
474
|
f ? "SemaphorInputReference" : void 0,
|
|
475
475
|
"SemaphorQueryRuntimeOptions"
|
|
476
|
-
].filter(
|
|
477
|
-
|
|
478
|
-
`import type { ${
|
|
479
|
-
|
|
476
|
+
].filter(K).join(", "), d = [
|
|
477
|
+
w || f ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
478
|
+
`import type { ${u} } from "react-semaphor/data-app-sdk";`,
|
|
479
|
+
w || f ? 'import { fields } from "./fields";' : void 0,
|
|
480
480
|
f ? 'import { sources } from "./sources";' : void 0,
|
|
481
481
|
'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'
|
|
482
|
-
].filter(
|
|
482
|
+
].filter(K).join(`
|
|
483
483
|
`);
|
|
484
484
|
return `${H}
|
|
485
|
-
${
|
|
485
|
+
${d}
|
|
486
486
|
|
|
487
487
|
export const filterSpecs = {
|
|
488
488
|
${n}
|
|
@@ -502,7 +502,7 @@ ${o}
|
|
|
502
502
|
} as const;
|
|
503
503
|
|
|
504
504
|
export const inputsForInputOptionQuery = {
|
|
505
|
-
${
|
|
505
|
+
${a}
|
|
506
506
|
} as const;
|
|
507
507
|
|
|
508
508
|
export const queryOptionsForInputOptionQuery = {
|
|
@@ -511,7 +511,7 @@ ${l}
|
|
|
511
511
|
|
|
512
512
|
export function queryOptionsForInputOptionQueryId(
|
|
513
513
|
${m}: SemaphorGeneratedInputOptionQueryId,
|
|
514
|
-
${
|
|
514
|
+
${N}: SemaphorGeneratedInputHandleMap,
|
|
515
515
|
): SemaphorQueryRuntimeOptions {
|
|
516
516
|
switch (${m}) {
|
|
517
517
|
${y}
|
|
@@ -530,77 +530,77 @@ function Qe(e, n) {
|
|
|
530
530
|
n.input.raw.id,
|
|
531
531
|
...r.excludeInputIds || []
|
|
532
532
|
]);
|
|
533
|
-
return e.inputs.filter((
|
|
533
|
+
return e.inputs.filter((a) => o.has(a.raw.id) ? !1 : t.has(a.raw.id));
|
|
534
534
|
}
|
|
535
535
|
function ge(e) {
|
|
536
536
|
var n;
|
|
537
537
|
return e.raw.dependencies || ((n = e.raw.spec) == null ? void 0 : n.dependencies);
|
|
538
538
|
}
|
|
539
539
|
function _e(e) {
|
|
540
|
-
const n = e.views.map((
|
|
541
|
-
var p, S,
|
|
542
|
-
const
|
|
543
|
-
if (W(
|
|
544
|
-
const
|
|
545
|
-
view:
|
|
540
|
+
const n = e.views.map((d) => {
|
|
541
|
+
var p, S, g, $, F, R;
|
|
542
|
+
const c = B(d.raw.sdkSpec.builder), i = Pe(d);
|
|
543
|
+
if (W(d) && He(d)) {
|
|
544
|
+
const b = (p = d.raw.visualSpec) == null ? void 0 : p.tableBehavior, M = V(i.pagination), s = A(d), I = E(d), T = ((S = b == null ? void 0 : b.pagination) == null ? void 0 : S.pageSize) || z(M == null ? void 0 : M.pageSize) || z(i.limit) || 100, ee = I ? Y(d, e) : [], J = I ? De({
|
|
545
|
+
view: d,
|
|
546
546
|
contract: e,
|
|
547
547
|
sortFields: ee,
|
|
548
|
-
defaultField: (
|
|
549
|
-
}) : void 0, ne =
|
|
550
|
-
viewName:
|
|
551
|
-
supportsPagination:
|
|
552
|
-
supportsSort:
|
|
553
|
-
}), te =
|
|
554
|
-
recordsSortFieldsForView.${
|
|
548
|
+
defaultField: (g = b == null ? void 0 : b.sorting) == null ? void 0 : g.defaultField
|
|
549
|
+
}) : void 0, ne = I ? ($ = b == null ? void 0 : b.sorting) == null ? void 0 : $.defaultDirection : void 0, re = Ue({
|
|
550
|
+
viewName: d.name,
|
|
551
|
+
supportsPagination: s,
|
|
552
|
+
supportsSort: I
|
|
553
|
+
}), te = I ? ` const orderBy = resolveRecordsOrderBy(
|
|
554
|
+
recordsSortFieldsForView.${d.name},
|
|
555
555
|
params.sort,
|
|
556
|
-
${
|
|
557
|
-
${
|
|
556
|
+
${O(J, e)},
|
|
557
|
+
${O(ne, e)},
|
|
558
558
|
);
|
|
559
|
-
` : "", oe =
|
|
560
|
-
` : "", se =
|
|
559
|
+
` : "", oe = I ? ` ...(orderBy ? { orderBy } : {}),
|
|
560
|
+
` : "", se = s ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(T)}),
|
|
561
561
|
` : "";
|
|
562
|
-
return ` ${
|
|
562
|
+
return ` ${d.name}(
|
|
563
563
|
params: ${re} = {},
|
|
564
564
|
) {
|
|
565
|
-
${te} return semaphor.${
|
|
566
|
-
...${
|
|
565
|
+
${te} return semaphor.${c}({
|
|
566
|
+
...${O(i, e)},
|
|
567
567
|
${oe}${se} });
|
|
568
568
|
},`;
|
|
569
569
|
}
|
|
570
|
-
if (ue(
|
|
571
|
-
const
|
|
572
|
-
return ` ${
|
|
570
|
+
if (ue(d) && A(d)) {
|
|
571
|
+
const b = (F = d.raw.visualSpec) == null ? void 0 : F.tableBehavior, M = V(i.pagination), s = ((R = b == null ? void 0 : b.pagination) == null ? void 0 : R.pageSize) || z(M == null ? void 0 : M.pageSize) || z(i.limit) || 100;
|
|
572
|
+
return ` ${d.name}(
|
|
573
573
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
574
574
|
) {
|
|
575
|
-
return semaphor.${
|
|
576
|
-
...${
|
|
577
|
-
pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
575
|
+
return semaphor.${c}({
|
|
576
|
+
...${O(i, e)},
|
|
577
|
+
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
578
578
|
});
|
|
579
579
|
},`;
|
|
580
580
|
}
|
|
581
|
-
return ` ${
|
|
581
|
+
return ` ${d.name}: () => semaphor.${c}(${O(i, e)}),`;
|
|
582
582
|
}).join(`
|
|
583
|
-
`), r = e.views.filter((
|
|
584
|
-
const
|
|
583
|
+
`), r = e.views.filter((d) => E(d)).map((d) => {
|
|
584
|
+
const i = Y(d, e).map((p) => ` ${JSON.stringify(p.key)}: fields.${p.fieldName},`).join(`
|
|
585
585
|
`);
|
|
586
|
-
return ` ${
|
|
587
|
-
${
|
|
586
|
+
return ` ${d.name}: {
|
|
587
|
+
${i}
|
|
588
588
|
},`;
|
|
589
589
|
}).join(`
|
|
590
|
-
`), t = e.views.filter((
|
|
591
|
-
const
|
|
590
|
+
`), t = e.views.filter((d) => E(d)).map((d) => {
|
|
591
|
+
const i = Y(d, e).map((p) => ` { key: ${JSON.stringify(p.key)}, label: ${JSON.stringify(p.label)}, field: fields.${p.fieldName} },`).join(`
|
|
592
592
|
`);
|
|
593
|
-
return ` ${
|
|
594
|
-
${
|
|
593
|
+
return ` ${d.name}: [
|
|
594
|
+
${i}
|
|
595
595
|
],`;
|
|
596
596
|
}).join(`
|
|
597
|
-
`), o = e.views.some((
|
|
597
|
+
`), o = e.views.some((d) => E(d)), a = e.views.some((d) => A(d)), l = [n, r, t].join(`
|
|
598
598
|
`), y = [
|
|
599
599
|
n ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
600
600
|
o ? 'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";' : void 0,
|
|
601
601
|
l.includes("fields.") ? 'import { fields } from "./fields";' : void 0,
|
|
602
602
|
l.includes("sources.") ? 'import { sources } from "./sources";' : void 0
|
|
603
|
-
].filter(
|
|
603
|
+
].filter(K).join(`
|
|
604
604
|
`);
|
|
605
605
|
return `${H}
|
|
606
606
|
${y}
|
|
@@ -614,11 +614,11 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
614
614
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
615
615
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
616
616
|
};
|
|
617
|
-
` : ""}${
|
|
617
|
+
` : ""}${a ? `export type SemaphorGeneratedServerPaginationParams = {
|
|
618
618
|
page?: number;
|
|
619
619
|
pageSize?: number;
|
|
620
620
|
};
|
|
621
|
-
` : ""}${o &&
|
|
621
|
+
` : ""}${o && a ? `export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
622
622
|
SemaphorGeneratedServerPaginationParams &
|
|
623
623
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
624
624
|
` : ""}
|
|
@@ -655,7 +655,7 @@ ${o ? `function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
655
655
|
};
|
|
656
656
|
}
|
|
657
657
|
` : ""}
|
|
658
|
-
${
|
|
658
|
+
${a ? `function resolveServerTablePagination(
|
|
659
659
|
params: SemaphorGeneratedServerPaginationParams,
|
|
660
660
|
defaultPageSize: number,
|
|
661
661
|
) {
|
|
@@ -668,31 +668,31 @@ ${i ? `function resolveServerTablePagination(
|
|
|
668
668
|
`;
|
|
669
669
|
}
|
|
670
670
|
function Pe(e) {
|
|
671
|
-
var
|
|
672
|
-
const n =
|
|
671
|
+
var a, l;
|
|
672
|
+
const n = V((a = e.raw.sdkSpec) == null ? void 0 : a.spec) || {}, { kind: r, id: t, ...o } = n;
|
|
673
673
|
return {
|
|
674
674
|
...o,
|
|
675
675
|
id: e.raw.id,
|
|
676
676
|
label: ((l = e.raw.visualSpec) == null ? void 0 : l.title) || e.raw.title || o.label
|
|
677
677
|
};
|
|
678
678
|
}
|
|
679
|
-
function
|
|
680
|
-
var
|
|
681
|
-
const r = [], t =
|
|
682
|
-
for (const y of
|
|
683
|
-
|
|
684
|
-
for (const y of e.raw.fields || [])
|
|
679
|
+
function Y(e, n) {
|
|
680
|
+
var a, l;
|
|
681
|
+
const r = [], t = V((a = e.raw.sdkSpec) == null ? void 0 : a.spec) || {};
|
|
682
|
+
for (const y of j(t.fields)) h(r, y);
|
|
683
|
+
h(r, t.dateField), h(r, (l = V(t.orderBy)) == null ? void 0 : l.field);
|
|
684
|
+
for (const y of e.raw.fields || []) h(r, y);
|
|
685
685
|
return X(
|
|
686
686
|
r.map((y) => {
|
|
687
|
-
const
|
|
688
|
-
if (!(!y.name || !
|
|
687
|
+
const w = x(y, n);
|
|
688
|
+
if (!(!y.name || !w))
|
|
689
689
|
return {
|
|
690
|
-
key:
|
|
691
|
-
fieldName:
|
|
690
|
+
key: w,
|
|
691
|
+
fieldName: w,
|
|
692
692
|
rawName: y.name,
|
|
693
693
|
label: y.label || y.name
|
|
694
694
|
};
|
|
695
|
-
}).filter(
|
|
695
|
+
}).filter(K),
|
|
696
696
|
(y) => y.key
|
|
697
697
|
);
|
|
698
698
|
}
|
|
@@ -702,14 +702,14 @@ function De({
|
|
|
702
702
|
sortFields: r,
|
|
703
703
|
defaultField: t
|
|
704
704
|
}) {
|
|
705
|
-
var
|
|
705
|
+
var w, f;
|
|
706
706
|
const o = new Set(r.map((m) => m.key));
|
|
707
707
|
if (t && o.has(t))
|
|
708
708
|
return t;
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
711
|
-
return
|
|
712
|
-
const l =
|
|
709
|
+
const a = r.filter((m) => m.rawName === t);
|
|
710
|
+
if (a.length === 1)
|
|
711
|
+
return a[0].key;
|
|
712
|
+
const l = V((w = e.raw.sdkSpec) == null ? void 0 : w.spec), y = x((f = V(l == null ? void 0 : l.orderBy)) == null ? void 0 : f.field, n);
|
|
713
713
|
return y && o.has(y) ? y : void 0;
|
|
714
714
|
}
|
|
715
715
|
function Ue({
|
|
@@ -721,32 +721,32 @@ function Ue({
|
|
|
721
721
|
}
|
|
722
722
|
function Le(e) {
|
|
723
723
|
const n = e.views.map((m) => {
|
|
724
|
-
const
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
724
|
+
const u = Je(e, m.raw.id).map((d) => {
|
|
725
|
+
const c = d.inputId, i = x(d.fieldRef, e);
|
|
726
|
+
if (!c || !i)
|
|
727
727
|
return "";
|
|
728
|
-
const p = [`field: fields.${
|
|
729
|
-
if (
|
|
730
|
-
p.push(`relationshipHint: ${k(
|
|
731
|
-
else if (Array.isArray(
|
|
732
|
-
const
|
|
733
|
-
var
|
|
734
|
-
return (
|
|
735
|
-
}).filter((
|
|
736
|
-
|
|
728
|
+
const p = [`field: fields.${i}`];
|
|
729
|
+
if (d.relationshipHint)
|
|
730
|
+
p.push(`relationshipHint: ${k(d.relationshipHint)}`);
|
|
731
|
+
else if (Array.isArray(d.relationshipsUsed) && d.relationshipsUsed.length > 0) {
|
|
732
|
+
const g = d.relationshipsUsed.map(($) => {
|
|
733
|
+
var F;
|
|
734
|
+
return (F = V($)) == null ? void 0 : F.id;
|
|
735
|
+
}).filter(($) => typeof $ == "string" && $.length > 0);
|
|
736
|
+
g.length > 0 && p.push(`relationshipHint: ${k({ relationshipIds: g })}`);
|
|
737
737
|
}
|
|
738
|
-
const S = `inputHandles[${JSON.stringify(
|
|
738
|
+
const S = `inputHandles[${JSON.stringify(c)}]`;
|
|
739
739
|
return ` if (${S}) {
|
|
740
740
|
inputs.push(semaphor.bindInput(${S}, { ${p.join(", ")} }));
|
|
741
741
|
}`;
|
|
742
742
|
}).filter(Boolean).join(`
|
|
743
743
|
`);
|
|
744
|
-
return { view: m, renderedBindings:
|
|
745
|
-
}), r = n.some((m) => m.renderedBindings.length > 0), t = n.map(({ view: m, renderedBindings:
|
|
746
|
-
const
|
|
747
|
-
return ` ${m.name}(${
|
|
744
|
+
return { view: m, renderedBindings: u };
|
|
745
|
+
}), r = n.some((m) => m.renderedBindings.length > 0), t = n.map(({ view: m, renderedBindings: N }) => {
|
|
746
|
+
const u = N ? "inputHandles" : "_inputHandles";
|
|
747
|
+
return ` ${m.name}(${u}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
748
748
|
const inputs: SemaphorInputReference[] = [];
|
|
749
|
-
${
|
|
749
|
+
${N}
|
|
750
750
|
return inputs;
|
|
751
751
|
},`;
|
|
752
752
|
}).join(`
|
|
@@ -758,18 +758,18 @@ ${M}
|
|
|
758
758
|
};
|
|
759
759
|
},`).join(`
|
|
760
760
|
|
|
761
|
-
`),
|
|
761
|
+
`), a = e.views.map((m) => ` case ${JSON.stringify(m.raw.id)}:
|
|
762
762
|
return inputsForView.${m.name}(inputHandles);`).join(`
|
|
763
763
|
`), l = e.views.map((m) => ` case ${JSON.stringify(m.raw.id)}:
|
|
764
764
|
return queryOptionsForView.${m.name}(inputHandles);`).join(`
|
|
765
|
-
`), y = e.views.length > 0,
|
|
765
|
+
`), y = e.views.length > 0, w = y ? "inputHandles" : "_inputHandles", f = [
|
|
766
766
|
r ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
767
767
|
'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',
|
|
768
768
|
r ? 'import { fields } from "./fields";' : void 0,
|
|
769
769
|
'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',
|
|
770
770
|
y ? 'import { queryDebugForView } from "./metadata";' : void 0,
|
|
771
771
|
'import type { SemaphorGeneratedQueryViewId } from "./metadata";'
|
|
772
|
-
].filter(
|
|
772
|
+
].filter(K).join(`
|
|
773
773
|
`);
|
|
774
774
|
return `${H}
|
|
775
775
|
${f}
|
|
@@ -784,17 +784,17 @@ ${o}
|
|
|
784
784
|
|
|
785
785
|
export function inputsForViewId(
|
|
786
786
|
viewId: SemaphorGeneratedQueryViewId,
|
|
787
|
-
${
|
|
787
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
788
788
|
): SemaphorInputReference[] {
|
|
789
789
|
switch (viewId) {
|
|
790
|
-
${
|
|
790
|
+
${a}
|
|
791
791
|
}
|
|
792
792
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
export function queryOptionsForViewId(
|
|
796
796
|
viewId: SemaphorGeneratedQueryViewId,
|
|
797
|
-
${
|
|
797
|
+
${w}: SemaphorGeneratedInputHandleMap,
|
|
798
798
|
): SemaphorQueryRuntimeOptions {
|
|
799
799
|
switch (viewId) {
|
|
800
800
|
${l}
|
|
@@ -814,130 +814,161 @@ function Je(e, n) {
|
|
|
814
814
|
);
|
|
815
815
|
}
|
|
816
816
|
function ze(e) {
|
|
817
|
-
const n = e.views.map((
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
return
|
|
817
|
+
const n = e.views.map((i) => {
|
|
818
|
+
const S = D(i, e).map((g) => {
|
|
819
|
+
const $ = x(g.raw, e);
|
|
820
|
+
return $ ? ` ${g.name}: fields.${$},` : "";
|
|
821
821
|
}).filter(Boolean).join(`
|
|
822
822
|
`);
|
|
823
|
-
return ` ${
|
|
824
|
-
${
|
|
823
|
+
return ` ${i.name}: {
|
|
824
|
+
${S}
|
|
825
825
|
},`;
|
|
826
826
|
}).join(`
|
|
827
|
-
`), r = e.views.map((
|
|
828
|
-
const
|
|
829
|
-
const
|
|
830
|
-
return
|
|
827
|
+
`), r = e.views.map((i) => {
|
|
828
|
+
const S = P(i, e).map((g) => {
|
|
829
|
+
const $ = x(g.raw, e);
|
|
830
|
+
return $ ? ` ${g.name}: fields.${$},` : "";
|
|
831
831
|
}).filter(Boolean).join(`
|
|
832
832
|
`);
|
|
833
|
-
return ` ${
|
|
834
|
-
${
|
|
833
|
+
return ` ${i.name}: {
|
|
834
|
+
${S}
|
|
835
835
|
},`;
|
|
836
836
|
}).join(`
|
|
837
|
-
`), t = e.views.map((
|
|
838
|
-
const
|
|
839
|
-
const
|
|
837
|
+
`), t = e.views.map((i) => {
|
|
838
|
+
const p = P(i, e), S = rn(p), g = nn(p), $ = p.map((F) => {
|
|
839
|
+
const R = Array.from(
|
|
840
840
|
new Set(
|
|
841
|
-
he(
|
|
841
|
+
he(F.raw).filter((b) => g.has(b))
|
|
842
842
|
)
|
|
843
843
|
);
|
|
844
|
-
return ` ${
|
|
844
|
+
return ` ${F.name}: metricKeysForField(metricFieldsForView.${i.name}.${F.name}, { allowNameFallback: ${S.has(F.raw.name) ? "false" : "true"}, excludedKeys: ${k(R)} }),`;
|
|
845
845
|
}).join(`
|
|
846
846
|
`);
|
|
847
|
-
return ` ${
|
|
848
|
-
${
|
|
847
|
+
return ` ${i.name}: {
|
|
848
|
+
${$}
|
|
849
849
|
},`;
|
|
850
850
|
}).join(`
|
|
851
|
-
`), o = e.views.map((
|
|
852
|
-
const
|
|
851
|
+
`), o = e.views.map((i) => {
|
|
852
|
+
const S = P(i, e).map((g, $) => ` ${g.name}: ${JSON.stringify(Xe(i, g, $))},`).join(`
|
|
853
853
|
`);
|
|
854
|
-
return ` ${
|
|
855
|
-
${
|
|
854
|
+
return ` ${i.name}: {
|
|
855
|
+
${S}
|
|
856
856
|
},`;
|
|
857
857
|
}).join(`
|
|
858
|
-
`),
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
return ` ${
|
|
858
|
+
`), a = e.views.map((i) => {
|
|
859
|
+
const p = P(i, e);
|
|
860
|
+
if (p.length === 0)
|
|
861
|
+
return ` ${i.name}(): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
862
862
|
return {};
|
|
863
863
|
},`;
|
|
864
|
-
const
|
|
865
|
-
const
|
|
866
|
-
return ` ${
|
|
864
|
+
const S = en(i, p), g = p.map(($) => {
|
|
865
|
+
const F = `metricMeasureKeysForView.${i.name}.${$.name}`, R = `metricMeasureBindingKeysForView.${i.name}.${$.name}`, b = S.has($.name) ? `readMetricValueByBindingWithFallback(measures, measureBindings, ${R}, ${F}, primaryValue)` : `readMetricValueByBinding(measures, measureBindings, ${R}, ${F})`;
|
|
866
|
+
return ` ${$.name}: ${b},`;
|
|
867
867
|
}).join(`
|
|
868
868
|
`);
|
|
869
|
-
return ` ${
|
|
869
|
+
return ` ${i.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${i.name}, unknown> {
|
|
870
870
|
const measures = result?.measures;
|
|
871
871
|
const measureBindings = result?.measureBindings;
|
|
872
|
-
const
|
|
872
|
+
const primaryValue = result?.primaryValue;
|
|
873
873
|
return {
|
|
874
|
-
${
|
|
874
|
+
${g}
|
|
875
875
|
};
|
|
876
876
|
},`;
|
|
877
877
|
}).join(`
|
|
878
878
|
|
|
879
|
-
`), l = e.views.map((
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
return ` ${
|
|
879
|
+
`), l = e.views.map((i) => {
|
|
880
|
+
const p = P(i, e);
|
|
881
|
+
if (p.length === 0)
|
|
882
|
+
return ` ${i.name}(): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
883
883
|
return [];
|
|
884
884
|
},`;
|
|
885
|
-
const
|
|
885
|
+
const S = p.map((g) => ` ...(missing.has(metricMeasureBindingKeysForView.${i.name}.${g.name}) ? [${JSON.stringify(g.name)} as keyof typeof metricFieldsForView.${i.name}] : []),`).join(`
|
|
886
886
|
`);
|
|
887
|
-
return ` ${
|
|
887
|
+
return ` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
|
|
888
888
|
const missing = new Set(result?.missingMeasures || []);
|
|
889
889
|
return [
|
|
890
|
-
${
|
|
890
|
+
${S}
|
|
891
891
|
];
|
|
892
892
|
},`;
|
|
893
893
|
}).join(`
|
|
894
894
|
|
|
895
|
-
`), y = e.views.map((
|
|
896
|
-
const
|
|
897
|
-
return ` ${
|
|
895
|
+
`), y = e.views.map((i) => {
|
|
896
|
+
const p = Ye(i, e);
|
|
897
|
+
return ` ${i.name}: ${k(p)},`;
|
|
898
898
|
}).join(`
|
|
899
|
-
`),
|
|
900
|
-
const
|
|
899
|
+
`), w = e.views.map((i) => {
|
|
900
|
+
const S = D(i, e).map((g) => ` ${g.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${g.name}),`).join(`
|
|
901
901
|
`);
|
|
902
|
-
return ` ${
|
|
902
|
+
return ` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
|
|
903
903
|
return {
|
|
904
|
-
${
|
|
904
|
+
${S}
|
|
905
905
|
};
|
|
906
906
|
},`;
|
|
907
907
|
}).join(`
|
|
908
908
|
|
|
909
|
-
`), f = e.views.map((
|
|
910
|
-
const
|
|
909
|
+
`), f = e.views.map((i) => {
|
|
910
|
+
const S = D(i, e).map((g) => ` ${g.name}: readCell(row, columns, fieldsForView.${i.name}.${g.name}),`).join(`
|
|
911
911
|
`);
|
|
912
|
-
return ` ${
|
|
912
|
+
return ` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
|
|
913
913
|
return {
|
|
914
|
-
${
|
|
914
|
+
${S}
|
|
915
|
+
};
|
|
916
|
+
},`;
|
|
917
|
+
}).join(`
|
|
918
|
+
|
|
919
|
+
`), m = e.views.map((i) => ` ${i.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${i.name}, unknown>> {
|
|
920
|
+
return (result?.records || []).map((row) => rowValuesForView.${i.name}(row, result?.columns));
|
|
921
|
+
},`).join(`
|
|
922
|
+
|
|
923
|
+
`), N = e.views.map((i) => {
|
|
924
|
+
const p = D(i, e), S = p.filter((s) => s.raw.role === "dimension"), g = p.filter((s) => s.raw.role === "measure"), $ = S[0], F = S[1], R = g[0], b = g[1], M = [
|
|
925
|
+
$ ? ` primaryDimension: values.${$.name},` : " primaryDimension: undefined,",
|
|
926
|
+
F ? ` secondaryDimension: values.${F.name},` : " secondaryDimension: undefined,",
|
|
927
|
+
R ? ` primaryMeasure: values.${R.name},` : " primaryMeasure: undefined,",
|
|
928
|
+
b ? ` secondaryMeasure: values.${b.name},` : " secondaryMeasure: undefined,"
|
|
929
|
+
].join(`
|
|
930
|
+
`);
|
|
931
|
+
return ` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
932
|
+
const values = rowValuesForView.${i.name}(row, columns);
|
|
933
|
+
return {
|
|
934
|
+
${M}
|
|
915
935
|
};
|
|
916
936
|
},`;
|
|
917
937
|
}).join(`
|
|
918
938
|
|
|
919
|
-
`),
|
|
939
|
+
`), u = n.includes("fields.") || r.includes("fields."), c = [
|
|
920
940
|
`import { ${[
|
|
921
941
|
"type SemaphorFieldRef",
|
|
922
942
|
"type SemaphorResultColumn",
|
|
923
943
|
"semaphorMetricMeasureBindingKey"
|
|
924
|
-
].filter(
|
|
925
|
-
|
|
926
|
-
].filter(
|
|
944
|
+
].filter(K).join(", ")} } from "react-semaphor/data-app-sdk";`,
|
|
945
|
+
u ? 'import { fields } from "./fields";' : void 0
|
|
946
|
+
].filter(K).join(`
|
|
927
947
|
`);
|
|
928
948
|
return `${H}
|
|
929
|
-
${
|
|
949
|
+
${c}
|
|
930
950
|
|
|
931
951
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
932
952
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
953
|
+
export type SemaphorGeneratedRecordsResult = {
|
|
954
|
+
readonly records?: readonly SemaphorGeneratedRow[];
|
|
955
|
+
readonly columns?: SemaphorGeneratedColumns;
|
|
956
|
+
} | null | undefined;
|
|
933
957
|
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
934
958
|
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
935
959
|
export type SemaphorGeneratedMetricResult = {
|
|
936
960
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
937
961
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
938
962
|
readonly missingMeasures?: readonly string[];
|
|
963
|
+
readonly primaryValue: unknown;
|
|
939
964
|
readonly value?: unknown;
|
|
940
965
|
} | null | undefined;
|
|
966
|
+
export type SemaphorGeneratedRoleValues = {
|
|
967
|
+
readonly primaryDimension: unknown;
|
|
968
|
+
readonly secondaryDimension: unknown;
|
|
969
|
+
readonly primaryMeasure: unknown;
|
|
970
|
+
readonly secondaryMeasure: unknown;
|
|
971
|
+
};
|
|
941
972
|
export type SemaphorGeneratedTableColumn = {
|
|
942
973
|
readonly key: string;
|
|
943
974
|
readonly label: string;
|
|
@@ -967,15 +998,23 @@ ${y}
|
|
|
967
998
|
} as const;
|
|
968
999
|
|
|
969
1000
|
export const columnKeysForView = {
|
|
970
|
-
${
|
|
1001
|
+
${w}
|
|
971
1002
|
} as const;
|
|
972
1003
|
|
|
973
1004
|
export const rowValuesForView = {
|
|
974
1005
|
${f}
|
|
975
1006
|
} as const;
|
|
976
1007
|
|
|
1008
|
+
export const rowsForView = {
|
|
1009
|
+
${m}
|
|
1010
|
+
} as const;
|
|
1011
|
+
|
|
1012
|
+
export const roleValuesForView = {
|
|
1013
|
+
${N}
|
|
1014
|
+
} as const;
|
|
1015
|
+
|
|
977
1016
|
export const metricValuesForView = {
|
|
978
|
-
${
|
|
1017
|
+
${a}
|
|
979
1018
|
} as const;
|
|
980
1019
|
|
|
981
1020
|
export const missingMetricMeasuresForView = {
|
|
@@ -1279,12 +1318,12 @@ function sourcesReferToSameDataset(
|
|
|
1279
1318
|
`;
|
|
1280
1319
|
}
|
|
1281
1320
|
function Ye(e, n) {
|
|
1282
|
-
const r =
|
|
1283
|
-
(E(e) ?
|
|
1321
|
+
const r = D(e, n), t = new Map(
|
|
1322
|
+
(E(e) ? Y(e, n) : []).map((o) => [o.fieldName, o.key])
|
|
1284
1323
|
);
|
|
1285
1324
|
return r.map((o) => {
|
|
1286
|
-
const
|
|
1287
|
-
return
|
|
1325
|
+
const a = x(o.raw, n), l = a ? t.get(a) : void 0;
|
|
1326
|
+
return G({
|
|
1288
1327
|
key: o.name,
|
|
1289
1328
|
label: o.raw.label || o.raw.name,
|
|
1290
1329
|
dataType: o.raw.dataType,
|
|
@@ -1294,68 +1333,68 @@ function Ye(e, n) {
|
|
|
1294
1333
|
});
|
|
1295
1334
|
}
|
|
1296
1335
|
function We(e) {
|
|
1297
|
-
const n = e.checklist.filterScopeByInput || [], r = e.checklist.requiredDevtools || {}, t = e.summary.views.map((
|
|
1298
|
-
|
|
1336
|
+
const n = e.checklist.filterScopeByInput || [], r = e.checklist.requiredDevtools || {}, t = e.summary.views.map((u) => u.id).filter(Boolean), o = e.views.map((u) => u.raw.id).filter(Boolean), a = e.inputs.map((u) => u.raw.id).filter(Boolean), l = e.optionQueries.map((u) => u.raw.id || `${u.input.raw.id}-options`).filter(Boolean), y = Object.fromEntries(o.map((u) => [
|
|
1337
|
+
u,
|
|
1299
1338
|
e.filterContracts.filter(
|
|
1300
|
-
(
|
|
1301
|
-
).map((
|
|
1302
|
-
])),
|
|
1303
|
-
|
|
1339
|
+
(d) => Array.isArray(d.appliesToViewIds) && d.appliesToViewIds.includes(u)
|
|
1340
|
+
).map((d) => d.inputId)
|
|
1341
|
+
])), w = Object.fromEntries(e.views.map((u) => [
|
|
1342
|
+
u.raw.id,
|
|
1304
1343
|
{
|
|
1305
|
-
title:
|
|
1306
|
-
visual:
|
|
1307
|
-
visualSpec:
|
|
1308
|
-
queryKind:
|
|
1309
|
-
sdkBuilder:
|
|
1344
|
+
title: u.raw.title,
|
|
1345
|
+
visual: u.raw.visual,
|
|
1346
|
+
visualSpec: u.raw.visualSpec,
|
|
1347
|
+
queryKind: u.raw.queryKind,
|
|
1348
|
+
sdkBuilder: u.raw.sdkBuilder
|
|
1310
1349
|
}
|
|
1311
|
-
])), f = Object.fromEntries(e.views.map((
|
|
1312
|
-
var
|
|
1350
|
+
])), f = Object.fromEntries(e.views.map((u) => {
|
|
1351
|
+
var d;
|
|
1313
1352
|
return [
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
viewId:
|
|
1317
|
-
queryId:
|
|
1318
|
-
title:
|
|
1319
|
-
visualType: ((
|
|
1320
|
-
suggestedComponentName: me(
|
|
1353
|
+
u.raw.id,
|
|
1354
|
+
G({
|
|
1355
|
+
viewId: u.raw.id,
|
|
1356
|
+
queryId: u.name,
|
|
1357
|
+
title: u.raw.title,
|
|
1358
|
+
visualType: ((d = u.raw.visualSpec) == null ? void 0 : d.visualType) || u.raw.visual,
|
|
1359
|
+
suggestedComponentName: me(u.raw.title || u.raw.id || u.name),
|
|
1321
1360
|
marker: {
|
|
1322
1361
|
attribute: "data-semaphor-view-id",
|
|
1323
|
-
value:
|
|
1362
|
+
value: u.raw.id
|
|
1324
1363
|
}
|
|
1325
1364
|
})
|
|
1326
1365
|
];
|
|
1327
|
-
})), m = Object.fromEntries(e.inputs.map((
|
|
1328
|
-
var
|
|
1366
|
+
})), m = Object.fromEntries(e.inputs.map((u) => {
|
|
1367
|
+
var d;
|
|
1329
1368
|
return [
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
inputId:
|
|
1333
|
-
label:
|
|
1334
|
-
type:
|
|
1335
|
-
optionQueryId: ((
|
|
1336
|
-
suggestedComponentName: me(
|
|
1369
|
+
u.raw.id,
|
|
1370
|
+
G({
|
|
1371
|
+
inputId: u.raw.id,
|
|
1372
|
+
label: u.raw.label,
|
|
1373
|
+
type: u.raw.type,
|
|
1374
|
+
optionQueryId: ((d = u.raw.optionQuery) == null ? void 0 : d.id) || (u.raw.optionQuery ? `${u.raw.id}-options` : void 0),
|
|
1375
|
+
suggestedComponentName: me(u.raw.label || u.raw.id || u.name),
|
|
1337
1376
|
marker: {
|
|
1338
1377
|
attribute: "data-semaphor-input-id",
|
|
1339
|
-
value:
|
|
1378
|
+
value: u.raw.id
|
|
1340
1379
|
}
|
|
1341
1380
|
})
|
|
1342
1381
|
];
|
|
1343
|
-
})),
|
|
1344
|
-
var
|
|
1382
|
+
})), N = Object.fromEntries(e.views.map((u) => {
|
|
1383
|
+
var d, c, i;
|
|
1345
1384
|
return [
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
viewId:
|
|
1349
|
-
viewTitle: ((
|
|
1350
|
-
visualType: (
|
|
1351
|
-
title: ((
|
|
1385
|
+
u.name,
|
|
1386
|
+
G({
|
|
1387
|
+
viewId: u.raw.id,
|
|
1388
|
+
viewTitle: ((d = u.raw.visualSpec) == null ? void 0 : d.title) || u.raw.title,
|
|
1389
|
+
visualType: (c = u.raw.visualSpec) == null ? void 0 : c.visualType,
|
|
1390
|
+
title: ((i = u.raw.visualSpec) == null ? void 0 : i.title) || u.raw.title
|
|
1352
1391
|
})
|
|
1353
1392
|
];
|
|
1354
1393
|
}));
|
|
1355
1394
|
return `${H}
|
|
1356
1395
|
export const generatedViewIds = ${k(t)} as const;
|
|
1357
1396
|
export const generatedQueryViewIds = ${k(o)} as const;
|
|
1358
|
-
export const generatedInputIds = ${k(
|
|
1397
|
+
export const generatedInputIds = ${k(a)} as const;
|
|
1359
1398
|
export const generatedInputOptionQueryIds = ${k(l)} as const;
|
|
1360
1399
|
export const generatedViewAuthoring = ${k(f)} as const;
|
|
1361
1400
|
export const generatedInputAuthoring = ${k(m)} as const;
|
|
@@ -1398,7 +1437,7 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
1398
1437
|
);
|
|
1399
1438
|
}
|
|
1400
1439
|
|
|
1401
|
-
export const queryDebugForView = ${k(
|
|
1440
|
+
export const queryDebugForView = ${k(N)} as const;
|
|
1402
1441
|
|
|
1403
1442
|
export const semaphorGeneratedContractMetadata = ${k({
|
|
1404
1443
|
schemaVersion: "semaphor-generated-data-app-contract/v1",
|
|
@@ -1408,12 +1447,12 @@ export const semaphorGeneratedContractMetadata = ${k({
|
|
|
1408
1447
|
filterScopeByInput: n,
|
|
1409
1448
|
generatedViewIds: t,
|
|
1410
1449
|
generatedQueryViewIds: o,
|
|
1411
|
-
generatedInputIds:
|
|
1450
|
+
generatedInputIds: a,
|
|
1412
1451
|
generatedInputOptionQueryIds: l,
|
|
1413
1452
|
generatedInputIdsForView: y,
|
|
1414
1453
|
generatedViewAuthoring: f,
|
|
1415
1454
|
generatedInputAuthoring: m,
|
|
1416
|
-
visualSpecs:
|
|
1455
|
+
visualSpecs: w,
|
|
1417
1456
|
presentationViews: e.presentationViews
|
|
1418
1457
|
})} as const;
|
|
1419
1458
|
`;
|
|
@@ -1435,39 +1474,39 @@ function Q(e, n) {
|
|
|
1435
1474
|
for (const r of n) Q(e, r);
|
|
1436
1475
|
return;
|
|
1437
1476
|
}
|
|
1438
|
-
|
|
1477
|
+
C(n) && h(e, U(n));
|
|
1439
1478
|
for (const r of Object.values(n))
|
|
1440
1479
|
Q(e, r);
|
|
1441
1480
|
}
|
|
1442
1481
|
}
|
|
1443
|
-
function
|
|
1482
|
+
function D(e, n) {
|
|
1444
1483
|
const r = [];
|
|
1445
1484
|
if (tn(r, e.raw.sdkSpec), r.length === 0)
|
|
1446
1485
|
for (const o of e.raw.fields || [])
|
|
1447
|
-
|
|
1486
|
+
h(r, o);
|
|
1448
1487
|
const t = X(
|
|
1449
|
-
r.filter((o) => o.name &&
|
|
1488
|
+
r.filter((o) => o.name && x(o, n)).map((o) => ({ raw: o, key: L(o), name: "" })),
|
|
1450
1489
|
(o) => o.key
|
|
1451
1490
|
);
|
|
1452
1491
|
return v(
|
|
1453
1492
|
t,
|
|
1454
|
-
(o) =>
|
|
1493
|
+
(o) => q(o.raw.label || o.raw.name || "field")
|
|
1455
1494
|
), t;
|
|
1456
1495
|
}
|
|
1457
1496
|
function P(e, n) {
|
|
1458
|
-
if (
|
|
1497
|
+
if (B(e.raw.sdkSpec.builder) !== "metric")
|
|
1459
1498
|
return [];
|
|
1460
|
-
const r =
|
|
1461
|
-
|
|
1462
|
-
for (const
|
|
1463
|
-
|
|
1499
|
+
const r = V(e.raw.sdkSpec.spec), t = [];
|
|
1500
|
+
h(t, r == null ? void 0 : r.primaryMeasure);
|
|
1501
|
+
for (const a of j(r == null ? void 0 : r.measures))
|
|
1502
|
+
h(t, a);
|
|
1464
1503
|
const o = X(
|
|
1465
|
-
t.filter((
|
|
1466
|
-
(
|
|
1504
|
+
t.filter((a) => a.name && x(a, n)).map((a) => ({ raw: a, key: L(a), name: "" })),
|
|
1505
|
+
(a) => a.key
|
|
1467
1506
|
);
|
|
1468
1507
|
return v(
|
|
1469
1508
|
o,
|
|
1470
|
-
(
|
|
1509
|
+
(a) => q(a.raw.label || a.raw.name || "metric")
|
|
1471
1510
|
), o;
|
|
1472
1511
|
}
|
|
1473
1512
|
function Xe(e, n, r) {
|
|
@@ -1482,10 +1521,10 @@ function Xe(e, n, r) {
|
|
|
1482
1521
|
function en(e, n) {
|
|
1483
1522
|
if (n.length === 1)
|
|
1484
1523
|
return /* @__PURE__ */ new Set([n[0].name]);
|
|
1485
|
-
const r =
|
|
1486
|
-
if (!
|
|
1524
|
+
const r = V(e.raw.sdkSpec.spec);
|
|
1525
|
+
if (!C(r == null ? void 0 : r.primaryMeasure))
|
|
1487
1526
|
return /* @__PURE__ */ new Set();
|
|
1488
|
-
const t = U(
|
|
1527
|
+
const t = L(U(r.primaryMeasure)), o = n.find((a) => a.key === t);
|
|
1489
1528
|
return o ? /* @__PURE__ */ new Set([o.name]) : /* @__PURE__ */ new Set();
|
|
1490
1529
|
}
|
|
1491
1530
|
function nn(e) {
|
|
@@ -1516,56 +1555,56 @@ function rn(e) {
|
|
|
1516
1555
|
);
|
|
1517
1556
|
}
|
|
1518
1557
|
function tn(e, n) {
|
|
1519
|
-
const r =
|
|
1558
|
+
const r = V(n.spec);
|
|
1520
1559
|
if (!r)
|
|
1521
1560
|
return;
|
|
1522
|
-
const t =
|
|
1561
|
+
const t = B(n.builder);
|
|
1523
1562
|
if (t === "records") {
|
|
1524
|
-
for (const o of
|
|
1563
|
+
for (const o of j(r.fields)) h(e, o);
|
|
1525
1564
|
return;
|
|
1526
1565
|
}
|
|
1527
1566
|
if (t === "sql") {
|
|
1528
|
-
for (const o of
|
|
1567
|
+
for (const o of j(r.fields)) h(e, o);
|
|
1529
1568
|
return;
|
|
1530
1569
|
}
|
|
1531
1570
|
if (t === "analysis" || t === "metric") {
|
|
1532
|
-
|
|
1533
|
-
for (const o of
|
|
1534
|
-
for (const o of
|
|
1535
|
-
|
|
1571
|
+
h(e, r.primaryMeasure);
|
|
1572
|
+
for (const o of j(r.measures)) h(e, o);
|
|
1573
|
+
for (const o of j(r.dimensions)) h(e, o);
|
|
1574
|
+
h(e, r.dateField);
|
|
1536
1575
|
return;
|
|
1537
1576
|
}
|
|
1538
1577
|
if (t === "matrix") {
|
|
1539
|
-
const o = pe(r.rows),
|
|
1578
|
+
const o = pe(r.rows), a = pe(r.columns), l = j(r.values);
|
|
1540
1579
|
for (const y of o) le(e, y);
|
|
1541
|
-
for (const y of
|
|
1580
|
+
for (const y of a) le(e, y);
|
|
1542
1581
|
for (const y of l) {
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1582
|
+
const w = V(y);
|
|
1583
|
+
h(e, w == null ? void 0 : w.field), h(e, w == null ? void 0 : w.measure);
|
|
1545
1584
|
}
|
|
1546
1585
|
}
|
|
1547
1586
|
}
|
|
1548
1587
|
function pe(e) {
|
|
1549
1588
|
if (Array.isArray(e))
|
|
1550
1589
|
return e;
|
|
1551
|
-
const n =
|
|
1590
|
+
const n = V(e);
|
|
1552
1591
|
return Array.isArray(n == null ? void 0 : n.levels) ? n.levels : [];
|
|
1553
1592
|
}
|
|
1554
1593
|
function le(e, n) {
|
|
1555
1594
|
var r;
|
|
1556
|
-
if (
|
|
1557
|
-
|
|
1595
|
+
if (C(n)) {
|
|
1596
|
+
h(e, n);
|
|
1558
1597
|
return;
|
|
1559
1598
|
}
|
|
1560
|
-
|
|
1599
|
+
h(e, (r = V(n)) == null ? void 0 : r.field);
|
|
1561
1600
|
}
|
|
1562
1601
|
function ce(e) {
|
|
1563
1602
|
var n, r, t, o;
|
|
1564
1603
|
return ((n = e == null ? void 0 : e.computation) == null ? void 0 : n.kind) === "presentation_only" || ((r = e == null ? void 0 : e.computation) == null ? void 0 : r.kind) === "derived" || ((t = e == null ? void 0 : e.computation) == null ? void 0 : t.kind) === "unsupported" || (e == null ? void 0 : e.visual) === "text_block" || ((o = e == null ? void 0 : e.visualSpec) == null ? void 0 : o.visualType) === "text_block";
|
|
1565
1604
|
}
|
|
1566
1605
|
function on(e) {
|
|
1567
|
-
const n =
|
|
1568
|
-
return
|
|
1606
|
+
const n = V(e) || {};
|
|
1607
|
+
return G({
|
|
1569
1608
|
id: e.id,
|
|
1570
1609
|
title: e.title,
|
|
1571
1610
|
purpose: e.purpose,
|
|
@@ -1579,10 +1618,10 @@ function on(e) {
|
|
|
1579
1618
|
description: n.description
|
|
1580
1619
|
});
|
|
1581
1620
|
}
|
|
1582
|
-
function
|
|
1583
|
-
|
|
1621
|
+
function h(e, n) {
|
|
1622
|
+
C(n) && e.push(U(n));
|
|
1584
1623
|
}
|
|
1585
|
-
function
|
|
1624
|
+
function U(e) {
|
|
1586
1625
|
return {
|
|
1587
1626
|
name: e.name,
|
|
1588
1627
|
label: e.label,
|
|
@@ -1608,38 +1647,38 @@ function sn(e) {
|
|
|
1608
1647
|
name: ""
|
|
1609
1648
|
};
|
|
1610
1649
|
}
|
|
1611
|
-
function
|
|
1612
|
-
const n =
|
|
1650
|
+
function C(e) {
|
|
1651
|
+
const n = V(e);
|
|
1613
1652
|
return !!(n && typeof n.name == "string" && (typeof n.role == "string" || typeof n.dataType == "string" || typeof n.aggregate == "string" || n.source || n.sourceKey));
|
|
1614
1653
|
}
|
|
1615
1654
|
function we(e) {
|
|
1616
|
-
const n =
|
|
1655
|
+
const n = V(e);
|
|
1617
1656
|
return !!(n && (typeof n.sourceKey == "string" || n.kind === "semantic" || typeof n.datasetName == "string" && typeof n.domainId == "string"));
|
|
1618
1657
|
}
|
|
1619
|
-
function
|
|
1658
|
+
function O(e, n) {
|
|
1620
1659
|
if (e === void 0)
|
|
1621
1660
|
return "undefined";
|
|
1622
1661
|
if (e === null || typeof e == "number" || typeof e == "boolean" || typeof e == "string")
|
|
1623
1662
|
return JSON.stringify(e);
|
|
1624
1663
|
if (Array.isArray(e))
|
|
1625
|
-
return `[${e.map((o) =>
|
|
1626
|
-
if (
|
|
1627
|
-
const o =
|
|
1664
|
+
return `[${e.map((o) => O(o, n)).join(", ")}]`;
|
|
1665
|
+
if (C(e)) {
|
|
1666
|
+
const o = x(U(e), n);
|
|
1628
1667
|
if (o) return `fields.${o}`;
|
|
1629
1668
|
}
|
|
1630
1669
|
if (we(e)) {
|
|
1631
1670
|
const o = Se(e, n);
|
|
1632
1671
|
if (o) return `sources.${o}`;
|
|
1633
1672
|
}
|
|
1634
|
-
const r =
|
|
1635
|
-
return r ? `{ ${Object.entries(r).filter(([, o]) => o !== void 0).map(([o,
|
|
1673
|
+
const r = V(e);
|
|
1674
|
+
return r ? `{ ${Object.entries(r).filter(([, o]) => o !== void 0).map(([o, a]) => `${JSON.stringify(o)}: ${O(a, n)}`).join(", ")} }` : JSON.stringify(e);
|
|
1636
1675
|
}
|
|
1637
1676
|
function k(e) {
|
|
1638
1677
|
return JSON.stringify(e, null, 2);
|
|
1639
1678
|
}
|
|
1640
|
-
function
|
|
1641
|
-
if (
|
|
1642
|
-
return n.fieldNameByKey.get(U(
|
|
1679
|
+
function x(e, n) {
|
|
1680
|
+
if (C(e))
|
|
1681
|
+
return n.fieldNameByKey.get(L(U(e)));
|
|
1643
1682
|
}
|
|
1644
1683
|
function Se(e, n) {
|
|
1645
1684
|
if (we(e))
|
|
@@ -1649,7 +1688,7 @@ function Se(e, n) {
|
|
|
1649
1688
|
return t;
|
|
1650
1689
|
}
|
|
1651
1690
|
}
|
|
1652
|
-
function
|
|
1691
|
+
function L(e) {
|
|
1653
1692
|
return [
|
|
1654
1693
|
e.sourceKey || "",
|
|
1655
1694
|
e.name || "",
|
|
@@ -1658,19 +1697,19 @@ function U(e) {
|
|
|
1658
1697
|
].join("|");
|
|
1659
1698
|
}
|
|
1660
1699
|
function an(e, n) {
|
|
1661
|
-
return !
|
|
1700
|
+
return !C(e) || !C(n) || e.name !== n.name ? !1 : ie(e).some(
|
|
1662
1701
|
(r) => ie(n).includes(r)
|
|
1663
1702
|
);
|
|
1664
1703
|
}
|
|
1665
1704
|
function un(e) {
|
|
1666
|
-
return
|
|
1705
|
+
return C(e) && e.role === "id";
|
|
1667
1706
|
}
|
|
1668
1707
|
function dn(e) {
|
|
1669
1708
|
const n = [], r = /* @__PURE__ */ new Map();
|
|
1670
1709
|
for (const t of e) {
|
|
1671
|
-
const o = _(t.aliases.length ? t.aliases : [t.key]),
|
|
1672
|
-
if (
|
|
1673
|
-
|
|
1710
|
+
const o = _(t.aliases.length ? t.aliases : [t.key]), a = o.map((l) => r.get(l)).find(K);
|
|
1711
|
+
if (a) {
|
|
1712
|
+
a.aliases = _([...a.aliases, ...o]);
|
|
1674
1713
|
continue;
|
|
1675
1714
|
}
|
|
1676
1715
|
t.aliases = o, n.push(t);
|
|
@@ -1697,7 +1736,7 @@ function $e(e) {
|
|
|
1697
1736
|
return Z(e)[0] || de(e);
|
|
1698
1737
|
}
|
|
1699
1738
|
function Z(e) {
|
|
1700
|
-
const n =
|
|
1739
|
+
const n = V(e);
|
|
1701
1740
|
if (!n)
|
|
1702
1741
|
return [];
|
|
1703
1742
|
const r = [];
|
|
@@ -1711,78 +1750,78 @@ function Ie(e) {
|
|
|
1711
1750
|
return Z(e);
|
|
1712
1751
|
}
|
|
1713
1752
|
function de(e) {
|
|
1714
|
-
const n =
|
|
1753
|
+
const n = V(e);
|
|
1715
1754
|
return n ? typeof n.sourceKey == "string" ? n.sourceKey : JSON.stringify(n) : "";
|
|
1716
1755
|
}
|
|
1717
1756
|
function ln(e) {
|
|
1718
|
-
return
|
|
1757
|
+
return C(e) && ie(e)[0] || "";
|
|
1719
1758
|
}
|
|
1720
1759
|
function ie(e) {
|
|
1721
|
-
return
|
|
1760
|
+
return C(e) ? _([
|
|
1722
1761
|
...typeof e.sourceKey == "string" ? [e.sourceKey] : [],
|
|
1723
1762
|
...e.source ? Z(e.source) : []
|
|
1724
1763
|
]) : [];
|
|
1725
1764
|
}
|
|
1726
|
-
function
|
|
1765
|
+
function B(e) {
|
|
1727
1766
|
const n = String(e || "").replace(/^semaphor\./, "");
|
|
1728
1767
|
if (!["metric", "records", "analysis", "matrix", "sql"].includes(n))
|
|
1729
1768
|
throw new Error(`Unsupported sdkSpec builder: ${e}`);
|
|
1730
1769
|
return n;
|
|
1731
1770
|
}
|
|
1732
1771
|
function cn(e) {
|
|
1733
|
-
const n =
|
|
1772
|
+
const n = B(e);
|
|
1734
1773
|
return n === "records" || n === "sql";
|
|
1735
1774
|
}
|
|
1736
1775
|
function mn(e) {
|
|
1737
|
-
const n =
|
|
1776
|
+
const n = V(e);
|
|
1738
1777
|
return typeof (n == null ? void 0 : n.operator) == "string" ? n.operator : e.type === "date_range" ? "between" : e.type === "multi_select" || e.type === "select" ? "in" : "=";
|
|
1739
1778
|
}
|
|
1740
1779
|
function v(e, n) {
|
|
1741
1780
|
const r = /* @__PURE__ */ new Map();
|
|
1742
1781
|
for (const t of e) {
|
|
1743
|
-
const o = n(t) || "item",
|
|
1744
|
-
r.set(o,
|
|
1782
|
+
const o = n(t) || "item", a = r.get(o) || 0;
|
|
1783
|
+
r.set(o, a + 1), t.name = a === 0 ? o : `${o}${a + 1}`;
|
|
1745
1784
|
}
|
|
1746
1785
|
}
|
|
1747
1786
|
function X(e, n) {
|
|
1748
1787
|
const r = /* @__PURE__ */ new Set(), t = [];
|
|
1749
1788
|
for (const o of e) {
|
|
1750
|
-
const
|
|
1751
|
-
!
|
|
1789
|
+
const a = n(o);
|
|
1790
|
+
!a || r.has(a) || (r.add(a), t.push(o));
|
|
1752
1791
|
}
|
|
1753
1792
|
return t;
|
|
1754
1793
|
}
|
|
1755
|
-
function
|
|
1794
|
+
function q(e) {
|
|
1756
1795
|
const n = String(e || "").replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
|
|
1757
1796
|
if (n.length === 0)
|
|
1758
1797
|
return "item";
|
|
1759
1798
|
const [r, ...t] = n, o = [
|
|
1760
1799
|
r.toLowerCase(),
|
|
1761
|
-
...t.map((
|
|
1800
|
+
...t.map((a) => a.charAt(0).toUpperCase() + a.slice(1).toLowerCase())
|
|
1762
1801
|
].join("");
|
|
1763
1802
|
return /^[A-Za-z_$]/.test(o) ? o : `item${o}`;
|
|
1764
1803
|
}
|
|
1765
1804
|
function me(e) {
|
|
1766
|
-
const n =
|
|
1805
|
+
const n = q(e);
|
|
1767
1806
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
1768
1807
|
}
|
|
1769
1808
|
function fn(e) {
|
|
1770
1809
|
const n = String(e).split(":");
|
|
1771
1810
|
return n[n.length - 1] || String(e);
|
|
1772
1811
|
}
|
|
1773
|
-
function
|
|
1812
|
+
function G(e) {
|
|
1774
1813
|
return Object.fromEntries(Object.entries(e).filter(([, n]) => n !== void 0));
|
|
1775
1814
|
}
|
|
1776
|
-
function
|
|
1815
|
+
function V(e) {
|
|
1777
1816
|
return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
|
|
1778
1817
|
}
|
|
1779
|
-
function
|
|
1818
|
+
function j(e) {
|
|
1780
1819
|
return Array.isArray(e) ? e : [];
|
|
1781
1820
|
}
|
|
1782
|
-
function
|
|
1821
|
+
function z(e) {
|
|
1783
1822
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1784
1823
|
}
|
|
1785
|
-
function
|
|
1824
|
+
function K(e) {
|
|
1786
1825
|
return e !== void 0;
|
|
1787
1826
|
}
|
|
1788
1827
|
export {
|
|
@@ -1792,11 +1831,11 @@ export {
|
|
|
1792
1831
|
hn as DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR,
|
|
1793
1832
|
fe as GENERATED_CONTRACT_SCHEMA_VERSION,
|
|
1794
1833
|
Mn as GENERATED_CONTRACT_TYPESCRIPT_FILES,
|
|
1795
|
-
|
|
1834
|
+
xn as REQUIRED_GENERATED_CONTRACT_FILES,
|
|
1796
1835
|
In as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
1797
1836
|
Fn as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
1798
1837
|
ke as assertValidCodegenSummary,
|
|
1799
|
-
|
|
1838
|
+
Nn as buildSemaphorGeneratedActiveInput,
|
|
1800
1839
|
Cn as buildSemaphorGeneratedInputOptionIntent,
|
|
1801
1840
|
On as buildSemaphorGeneratedViewExecutionRequest,
|
|
1802
1841
|
Gn as buildSemaphorGeneratedViewExecutionRequests,
|