react-semaphor 0.1.420 → 0.1.421
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 +28 -27
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/analyze-result-contract-B5Eeu7vD.js +1 -0
- package/dist/chunks/analyze-result-contract-sWcmvBOA.js +2070 -0
- package/dist/chunks/{calendar-preferences-dialog-f0Z7Kf-U.js → calendar-preferences-dialog-CscmhyuZ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DIfAbE_y.js → calendar-preferences-dialog-cN3_2C-u.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-anh-Jy5v.js → dashboard-briefing-launcher-BYTBNetR.js} +4 -4
- package/dist/chunks/{dashboard-briefing-launcher-C3tNkGFG.js → dashboard-briefing-launcher-DmZkzIC3.js} +1 -1
- package/dist/chunks/{dashboard-controls-DQxlOxzy.js → dashboard-controls-9DFeKIP4.js} +1 -1
- package/dist/chunks/{dashboard-controls-8dCQaPaq.js → dashboard-controls-PhzuaTBj.js} +5 -5
- package/dist/chunks/{dashboard-json-i7Ae9KGD.js → dashboard-json-Cxhw2TZc.js} +3 -3
- package/dist/chunks/{dashboard-json-B309EInF.js → dashboard-json-DyRHI3mL.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-4HycwBHR.js → edit-dashboard-visual-3_jiBXsu.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-z3IqzYnj.js → edit-dashboard-visual-BigSJ3-x.js} +4 -4
- package/dist/chunks/{index-yxKWKFdr.js → index-BKDQw0aK.js} +2 -2
- package/dist/chunks/{index-B6DLEXRX.js → index-CH2ZzQo4.js} +5 -5
- package/dist/chunks/{switch-D6Ygf3wA.js → switch-CiOjVyVI.js} +1 -1
- package/dist/chunks/{switch-COWQU8aK.js → switch-TbCsyhv9.js} +1 -1
- package/dist/chunks/{update-policy-BzT2k4n6.js → update-policy-2MZ-Vf7v.js} +211 -187
- package/dist/chunks/update-policy-qpyAkOyO.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-CX0D-6HM.js → use-create-flow-overlay-state-BzcJWNzh.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-DENfd7sW.js → use-create-flow-overlay-state-DUQmgb9H.js} +1 -1
- package/dist/chunks/{validators-Cxr9qbrR.js → validators-D0pfj3jJ.js} +93 -93
- package/dist/chunks/validators-Dj1Y-46V.js +1 -0
- 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 +14 -14
- 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 +251 -139
- package/dist/data-app-codegen-node/index.js +806 -657
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +730 -686
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +51 -51
- 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 +12 -5
- package/dist/types/dashboard-assistant.d.ts +0 -5
- package/dist/types/data-app-codegen-node.d.ts +12 -2
- package/dist/types/data-app-codegen.d.ts +12 -2
- package/dist/types/data-app-sdk-validation.d.ts +0 -5
- package/dist/types/data-app-sdk.d.ts +17 -5
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-DdhEt99q.js +0 -2004
- package/dist/chunks/analyze-result-contract-DwRzl7yJ.js +0 -1
- package/dist/chunks/update-policy-VloD-0YM.js +0 -3
- package/dist/chunks/validators-BMQo93Y0.js +0 -1
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { b as ke } from "../chunks/analyze-result-contract-sWcmvBOA.js";
|
|
2
|
+
import { S as Vr, a as br, i as kr, v as Mr } from "../chunks/analyze-result-contract-sWcmvBOA.js";
|
|
3
|
+
import { c as Me, G as fe, a as Re, b as xe } from "../chunks/update-policy-2MZ-Vf7v.js";
|
|
4
|
+
import { C as xr, e as Nr, R as Cr, f as Gr, g as Or, h as vr, i as Kr, j as Er, v as Ar, d as jr } from "../chunks/update-policy-2MZ-Vf7v.js";
|
|
4
5
|
import { createHash as ye } from "node:crypto";
|
|
5
|
-
const
|
|
6
|
+
const Sr = "src/semaphor/generated", A = `// Generated by Semaphor Agent Plugin. Do not hand-edit analytics wiring here.
|
|
6
7
|
// Regenerate from the accepted semaphor_plan_data_app codegenSummary when the plan changes.
|
|
7
8
|
`;
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
9
|
+
function $r(e, r = {}) {
|
|
10
|
+
Me(e);
|
|
11
|
+
const n = Ne(e);
|
|
12
|
+
if (n.views.length === 0 && !r.allowEmpty)
|
|
12
13
|
throw new Error(
|
|
13
14
|
"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."
|
|
14
15
|
);
|
|
15
|
-
const t =
|
|
16
|
-
contract:
|
|
16
|
+
const t = Ge(n), o = Oe({
|
|
17
|
+
contract: n,
|
|
17
18
|
files: t,
|
|
18
|
-
generatorName:
|
|
19
|
-
generatorVersion:
|
|
20
|
-
}),
|
|
19
|
+
generatorName: r.generatorName || "react-semaphor/data-app-codegen/node",
|
|
20
|
+
generatorVersion: r.generatorVersion || "unknown"
|
|
21
|
+
}), i = {
|
|
21
22
|
...t,
|
|
22
23
|
"contract.manifest.json": `${JSON.stringify(o, null, 2)}
|
|
23
24
|
`
|
|
24
25
|
};
|
|
25
26
|
return {
|
|
26
27
|
schemaVersion: fe,
|
|
27
|
-
files:
|
|
28
|
+
files: i,
|
|
28
29
|
manifest: o,
|
|
29
30
|
contentHash: String(o.generatedContentHash || ""),
|
|
30
|
-
usageExample:
|
|
31
|
-
warnings:
|
|
31
|
+
usageExample: Ae(n),
|
|
32
|
+
warnings: n.warnings,
|
|
32
33
|
stats: {
|
|
33
|
-
inputCount:
|
|
34
|
-
executableViewCount:
|
|
35
|
-
presentationViewCount:
|
|
36
|
-
queryCount:
|
|
37
|
-
optionQueryCount:
|
|
34
|
+
inputCount: n.inputs.length,
|
|
35
|
+
executableViewCount: n.views.length,
|
|
36
|
+
presentationViewCount: n.presentationViews.length,
|
|
37
|
+
queryCount: n.views.length,
|
|
38
|
+
optionQueryCount: n.optionQueries.length
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
var u, d,
|
|
43
|
-
const
|
|
42
|
+
function Ne(e) {
|
|
43
|
+
var u, d, p, $, a, g, h, y, I, V, b, M;
|
|
44
|
+
const r = [], n = [];
|
|
44
45
|
for (const s of e.inputs) {
|
|
45
|
-
|
|
46
|
-
for (const
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
w(n, s.fieldRef);
|
|
47
|
+
for (const S of s.bindings || [])
|
|
48
|
+
w(n, S.fieldRef);
|
|
49
|
+
w(n, (u = s.optionQuery) == null ? void 0 : u.valueFieldRef), w(n, (d = s.optionQuery) == null ? void 0 : d.labelFieldRef), w(n, (p = s.optionQuery) == null ? void 0 : p.filterFieldRef), Q(n, ($ = s.optionQuery) == null ? void 0 : $.spec);
|
|
49
50
|
}
|
|
50
51
|
for (const s of e.filterContracts) {
|
|
51
|
-
|
|
52
|
-
for (const
|
|
53
|
-
|
|
52
|
+
w(n, s.fieldRef), w(n, (a = s.optionQuery) == null ? void 0 : a.valueFieldRef), w(n, (g = s.optionQuery) == null ? void 0 : g.labelFieldRef), w(n, (h = s.optionQuery) == null ? void 0 : h.filterFieldRef), Q(n, (y = s.optionQuery) == null ? void 0 : y.spec);
|
|
53
|
+
for (const S of s.bindings || [])
|
|
54
|
+
w(n, S.fieldRef);
|
|
54
55
|
}
|
|
55
56
|
for (const s of e.views) {
|
|
56
|
-
for (const
|
|
57
|
-
|
|
58
|
-
Q(
|
|
57
|
+
for (const S of s.fields || [])
|
|
58
|
+
w(n, S);
|
|
59
|
+
Q(n, (I = s.sdkSpec) == null ? void 0 : I.spec), Q(n, s.visualSpec);
|
|
59
60
|
}
|
|
60
61
|
const t = e.implementationChecklist || {};
|
|
61
62
|
for (const s of Object.values(t.bindingsByView || {}))
|
|
62
|
-
for (const
|
|
63
|
-
|
|
63
|
+
for (const S of Array.isArray(s) ? s : [])
|
|
64
|
+
w(n, S.fieldRef), w(n, S.optionValueField), w(n, S.optionLabelField);
|
|
64
65
|
for (const s of t.requiredInputOptions || [])
|
|
65
|
-
|
|
66
|
-
const o =
|
|
66
|
+
w(n, s.visibleLabelField), w(n, s.optionValueField), w(n, s.runtimeFilterField);
|
|
67
|
+
const o = lr(
|
|
67
68
|
[
|
|
68
69
|
...e.sources.map((s) => ({
|
|
69
70
|
raw: s,
|
|
@@ -71,153 +72,186 @@ function xe(e) {
|
|
|
71
72
|
aliases: Ie(s),
|
|
72
73
|
name: ""
|
|
73
74
|
})),
|
|
74
|
-
...
|
|
75
|
+
...n.map((s) => ir(s)).filter(v)
|
|
75
76
|
]
|
|
76
77
|
);
|
|
77
|
-
|
|
78
|
-
const
|
|
78
|
+
j(o, (s) => {
|
|
79
|
+
const S = k(s.raw);
|
|
79
80
|
return q(
|
|
80
|
-
s.raw.label || (
|
|
81
|
+
s.raw.label || (S == null ? void 0 : S.datasetName) || (S == null ? void 0 : S.datasetId) || (S == null ? void 0 : S.name) || s.raw.kind || "source"
|
|
81
82
|
);
|
|
82
83
|
});
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
const i = pr(o), l = X(
|
|
85
|
+
n.filter((s) => s.name).map((s) => ({
|
|
85
86
|
raw: s,
|
|
86
|
-
key:
|
|
87
|
+
key: J(s),
|
|
87
88
|
name: ""
|
|
88
89
|
})),
|
|
89
90
|
(s) => s.key
|
|
90
91
|
);
|
|
91
|
-
|
|
92
|
+
j(
|
|
92
93
|
l,
|
|
93
94
|
(s) => q([
|
|
94
|
-
s.raw.sourceKey ?
|
|
95
|
+
s.raw.sourceKey ? yr(s.raw.sourceKey) : "",
|
|
95
96
|
s.raw.aggregate ? s.raw.aggregate.toLowerCase() : "",
|
|
96
97
|
s.raw.name
|
|
97
98
|
].filter(Boolean).join("_"))
|
|
98
99
|
);
|
|
99
|
-
const
|
|
100
|
+
const f = new Map(l.map((s) => [s.key, s.name])), F = e.inputs.map((s) => ({
|
|
100
101
|
raw: s,
|
|
101
102
|
name: q(s.id || s.label || "input")
|
|
102
103
|
}));
|
|
103
|
-
|
|
104
|
-
const
|
|
104
|
+
j(F, (s) => s.name);
|
|
105
|
+
const m = F.filter((s) => !!s.raw.optionQuery).map((s) => ({
|
|
105
106
|
input: s,
|
|
106
107
|
name: `${s.name}Options`,
|
|
107
108
|
raw: s.raw.optionQuery
|
|
108
109
|
}));
|
|
109
|
-
|
|
110
|
-
for (const s of
|
|
111
|
-
|
|
112
|
-
`Input option query ${((
|
|
110
|
+
j(m, (s) => s.name);
|
|
111
|
+
for (const s of m)
|
|
112
|
+
ur(s.raw.labelFieldRef, s.raw.valueFieldRef) && dr(s.raw.valueFieldRef) && r.push(
|
|
113
|
+
`Input option query ${((V = s.raw.spec) == null ? void 0 : V.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
114
|
);
|
|
114
|
-
const
|
|
115
|
+
const c = e.views.filter(
|
|
115
116
|
(s) => {
|
|
116
|
-
var
|
|
117
|
-
return !!((
|
|
117
|
+
var S, P;
|
|
118
|
+
return !!((S = s.sdkSpec) != null && S.builder && ((P = s.sdkSpec) != null && P.spec));
|
|
118
119
|
}
|
|
119
120
|
).map((s) => ({
|
|
120
121
|
raw: s,
|
|
121
122
|
name: q(s.id || s.title || "query")
|
|
122
123
|
}));
|
|
123
|
-
|
|
124
|
-
const N = e.views.filter((s) => ce(s) && !("sdkSpec" in s)).map((s) =>
|
|
124
|
+
j(c, (s) => s.name);
|
|
125
|
+
const N = e.views.filter((s) => ce(s) && !("sdkSpec" in s)).map((s) => ar(s));
|
|
125
126
|
for (const s of e.views)
|
|
126
|
-
(!("sdkSpec" in s) || !((b = s.sdkSpec) != null && b.builder) || !((M = s.sdkSpec) != null && M.spec)) && !ce(s) &&
|
|
127
|
-
return
|
|
128
|
-
inputs:
|
|
129
|
-
views:
|
|
127
|
+
(!("sdkSpec" in s) || !((b = s.sdkSpec) != null && b.builder) || !((M = s.sdkSpec) != null && M.spec)) && !ce(s) && r.push(`Skipped view ${s.id || s.title || "unknown"} because it has no sdkSpec.`);
|
|
128
|
+
return Ce({
|
|
129
|
+
inputs: F,
|
|
130
|
+
views: c,
|
|
130
131
|
filterContracts: e.filterContracts
|
|
131
132
|
}), {
|
|
132
133
|
summary: e,
|
|
133
134
|
title: e.title || "Semaphor Data App",
|
|
134
135
|
sources: o,
|
|
135
136
|
fields: l,
|
|
136
|
-
inputs:
|
|
137
|
-
optionQueries:
|
|
138
|
-
views:
|
|
137
|
+
inputs: F,
|
|
138
|
+
optionQueries: m,
|
|
139
|
+
views: c,
|
|
139
140
|
presentationViews: N,
|
|
140
141
|
filterContracts: e.filterContracts,
|
|
141
142
|
checklist: t,
|
|
142
|
-
sourceNameByKey:
|
|
143
|
-
fieldNameByKey:
|
|
144
|
-
warnings:
|
|
143
|
+
sourceNameByKey: i,
|
|
144
|
+
fieldNameByKey: f,
|
|
145
|
+
warnings: r
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
+
function Ce({
|
|
148
149
|
inputs: e,
|
|
149
|
-
views:
|
|
150
|
-
filterContracts:
|
|
150
|
+
views: r,
|
|
151
|
+
filterContracts: n
|
|
151
152
|
}) {
|
|
152
|
-
const t = new Set(e.map((
|
|
153
|
-
for (const [
|
|
153
|
+
const t = new Set(e.map((i) => i.raw.id).filter(Boolean)), o = new Set(r.map((i) => i.raw.id).filter(Boolean));
|
|
154
|
+
for (const [i, l] of n.entries()) {
|
|
154
155
|
if (!t.has(l.inputId))
|
|
155
|
-
throw new Error(`filterContracts.${
|
|
156
|
-
const
|
|
157
|
-
for (const [
|
|
158
|
-
if (!o.has(
|
|
156
|
+
throw new Error(`filterContracts.${i}.inputId must reference a generated input.`);
|
|
157
|
+
const f = new Set(l.appliesToViewIds || []), F = new Set(l.notAppliedToViewIds || []);
|
|
158
|
+
for (const [m, c] of (l.appliesToViewIds || []).entries())
|
|
159
|
+
if (!o.has(c))
|
|
159
160
|
throw new Error(
|
|
160
|
-
`filterContracts.${
|
|
161
|
+
`filterContracts.${i}.appliesToViewIds.${m} must reference an executable generated view.`
|
|
161
162
|
);
|
|
162
|
-
for (const [
|
|
163
|
-
if (!o.has(
|
|
163
|
+
for (const [m, c] of (l.notAppliedToViewIds || []).entries())
|
|
164
|
+
if (!o.has(c))
|
|
164
165
|
throw new Error(
|
|
165
|
-
`filterContracts.${
|
|
166
|
+
`filterContracts.${i}.notAppliedToViewIds.${m} must reference an executable generated view.`
|
|
166
167
|
);
|
|
167
|
-
for (const [
|
|
168
|
-
if (!o.has(
|
|
168
|
+
for (const [m, c] of (l.bindings || []).entries()) {
|
|
169
|
+
if (!o.has(c.viewId))
|
|
169
170
|
throw new Error(
|
|
170
|
-
`filterContracts.${
|
|
171
|
+
`filterContracts.${i}.bindings.${m}.viewId must reference an executable generated view.`
|
|
171
172
|
);
|
|
172
|
-
if (!
|
|
173
|
+
if (!f.has(c.viewId))
|
|
173
174
|
throw new Error(
|
|
174
|
-
`filterContracts.${
|
|
175
|
+
`filterContracts.${i}.bindings.${m}.viewId must be included in appliesToViewIds.`
|
|
175
176
|
);
|
|
176
|
-
if (
|
|
177
|
+
if (F.has(c.viewId))
|
|
177
178
|
throw new Error(
|
|
178
|
-
`filterContracts.${
|
|
179
|
+
`filterContracts.${i}.bindings.${m}.viewId must not be listed in notAppliedToViewIds.`
|
|
179
180
|
);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
|
-
function
|
|
184
|
+
function Ge(e) {
|
|
184
185
|
return {
|
|
185
|
-
"sources.ts":
|
|
186
|
-
"fields.ts":
|
|
187
|
-
"inputs.ts":
|
|
188
|
-
"queries.ts":
|
|
189
|
-
"bindings.ts":
|
|
190
|
-
"accessors.ts":
|
|
191
|
-
"metadata.ts":
|
|
192
|
-
"index.ts":
|
|
186
|
+
"sources.ts": qe(e),
|
|
187
|
+
"fields.ts": Pe(e),
|
|
188
|
+
"inputs.ts": Qe(e),
|
|
189
|
+
"queries.ts": De(e),
|
|
190
|
+
"bindings.ts": ze(e),
|
|
191
|
+
"accessors.ts": We(e),
|
|
192
|
+
"metadata.ts": Xe(e),
|
|
193
|
+
"index.ts": er(),
|
|
194
|
+
"USAGE.md": Ke(e)
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
function Oe({
|
|
196
198
|
contract: e,
|
|
197
|
-
files:
|
|
198
|
-
generatorName:
|
|
199
|
+
files: r,
|
|
200
|
+
generatorName: n,
|
|
199
201
|
generatorVersion: t
|
|
200
202
|
}) {
|
|
201
203
|
return {
|
|
202
|
-
schemaVersion:
|
|
204
|
+
schemaVersion: xe,
|
|
203
205
|
generatedContractSchemaVersion: fe,
|
|
204
206
|
generator: {
|
|
205
|
-
name:
|
|
207
|
+
name: n,
|
|
206
208
|
version: t
|
|
207
209
|
},
|
|
208
|
-
generatedContentHash:
|
|
210
|
+
generatedContentHash: ve(r),
|
|
209
211
|
codegenSummaryValidatorVersion: Re,
|
|
210
|
-
codegenSummaryHash:
|
|
212
|
+
codegenSummaryHash: Ee(e.summary),
|
|
211
213
|
codegenSummary: e.summary
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
|
-
function
|
|
215
|
-
const
|
|
216
|
-
for (const
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
function ve(e) {
|
|
217
|
+
const r = ye("sha256");
|
|
218
|
+
for (const n of Object.keys(e).filter(
|
|
219
|
+
(t) => t.endsWith(".ts")
|
|
220
|
+
).sort())
|
|
221
|
+
r.update(n), r.update("\0"), r.update(e[n]), r.update("\0");
|
|
222
|
+
return `sha256:${r.digest("hex")}`;
|
|
219
223
|
}
|
|
220
224
|
function Ke(e) {
|
|
225
|
+
const r = [
|
|
226
|
+
"# Semaphor Generated Data App Contract",
|
|
227
|
+
"",
|
|
228
|
+
"Generated files in this directory are governed Semaphor analytics wiring. Do not hand-edit them.",
|
|
229
|
+
"",
|
|
230
|
+
"Use the app-facing exports from `index.ts`:",
|
|
231
|
+
"",
|
|
232
|
+
"- `queries`: generated governed query factories.",
|
|
233
|
+
"- `queryOptionsForView`: active-input wiring for each generated view.",
|
|
234
|
+
"- `rowsForView`: table/records row readers.",
|
|
235
|
+
"- `rowValuesForView`: friendly row object readers for chart/table views.",
|
|
236
|
+
"- `metricValuesForView`: friendly metric-value readers.",
|
|
237
|
+
"- `kpiPropsForView`: KPI component props derived from runtime metric results.",
|
|
238
|
+
"- `roleValuesForView`: canonical dimension/measure/date/id role readers.",
|
|
239
|
+
"- `appInputSpecs`: generated input/filter specs.",
|
|
240
|
+
"- `inputOptionQueries`: option-list query factories for generated inputs.",
|
|
241
|
+
"- `semaphorGeneratedContractMetadata`: generated view/input metadata and presentation-only views.",
|
|
242
|
+
"",
|
|
243
|
+
"Start with these exports before opening large generated internals such as `metadata.ts`.",
|
|
244
|
+
""
|
|
245
|
+
];
|
|
246
|
+
return e.views.length > 0 && (r.push("Generated executable views:"), e.views.forEach((n) => {
|
|
247
|
+
r.push(`- \`${n.raw.id}\`: ${n.raw.title || n.name}`);
|
|
248
|
+
}), r.push("")), e.inputs.length > 0 && (r.push("Generated inputs:"), e.inputs.forEach((n) => {
|
|
249
|
+
r.push(`- \`${n.raw.id}\`: ${n.raw.label || n.name}`);
|
|
250
|
+
}), r.push("")), `${r.join(`
|
|
251
|
+
`)}
|
|
252
|
+
`;
|
|
253
|
+
}
|
|
254
|
+
function Ee(e) {
|
|
221
255
|
return `sha256:${ye("sha256").update(ae(e)).digest("hex")}`;
|
|
222
256
|
}
|
|
223
257
|
function ae(e) {
|
|
@@ -225,44 +259,44 @@ function ae(e) {
|
|
|
225
259
|
return JSON.stringify(e);
|
|
226
260
|
if (Array.isArray(e))
|
|
227
261
|
return `[${e.map((t) => ae(t)).join(",")}]`;
|
|
228
|
-
const
|
|
229
|
-
return `{${Object.keys(
|
|
262
|
+
const r = e;
|
|
263
|
+
return `{${Object.keys(r).sort().filter((t) => r[t] !== void 0).map((t) => `${JSON.stringify(t)}:${ae(r[t])}`).join(",")}}`;
|
|
230
264
|
}
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
(
|
|
265
|
+
function Ae(e) {
|
|
266
|
+
const r = e.views.find(
|
|
267
|
+
(m) => K(m) && E(m)
|
|
234
268
|
);
|
|
235
|
-
if (
|
|
269
|
+
if (r)
|
|
236
270
|
return [
|
|
237
271
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
238
272
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
239
273
|
"const inputHandles = createInputHandleMap(handles);",
|
|
240
|
-
`const sortOption = recordsSortOptionsForView.${
|
|
274
|
+
`const sortOption = recordsSortOptionsForView.${r.name}[0];`,
|
|
241
275
|
'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',
|
|
242
|
-
`const query = queries.${
|
|
243
|
-
`const result = useSemaphorQuery(query, queryOptionsForView.${
|
|
244
|
-
`const rows = rowsForView.${
|
|
276
|
+
`const query = queries.${r.name}({ page, pageSize, sort });`,
|
|
277
|
+
`const result = useSemaphorQuery(query, queryOptionsForView.${r.name}(inputHandles));`,
|
|
278
|
+
`const rows = rowsForView.${r.name}(result);`,
|
|
245
279
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
246
280
|
].join(`
|
|
247
281
|
`);
|
|
248
|
-
const
|
|
249
|
-
(
|
|
282
|
+
const n = e.views.find(
|
|
283
|
+
(m) => K(m)
|
|
250
284
|
);
|
|
251
|
-
if (
|
|
285
|
+
if (n)
|
|
252
286
|
return [
|
|
253
287
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, recordsSortOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
254
288
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
255
289
|
"const inputHandles = createInputHandleMap(handles);",
|
|
256
|
-
`const sortOption = recordsSortOptionsForView.${
|
|
290
|
+
`const sortOption = recordsSortOptionsForView.${n.name}[0];`,
|
|
257
291
|
'const sort = sortOption ? { key: sortOption.key, direction: "asc" as const } : undefined;',
|
|
258
|
-
`const query = queries.${
|
|
259
|
-
`const result = useSemaphorQuery(query, queryOptionsForView.${
|
|
260
|
-
`const rows = rowsForView.${
|
|
292
|
+
`const query = queries.${n.name}({ sort });`,
|
|
293
|
+
`const result = useSemaphorQuery(query, queryOptionsForView.${n.name}(inputHandles));`,
|
|
294
|
+
`const rows = rowsForView.${n.name}(result);`,
|
|
261
295
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
262
296
|
].join(`
|
|
263
297
|
`);
|
|
264
298
|
const t = e.views.find(
|
|
265
|
-
(
|
|
299
|
+
(m) => W(m) && E(m)
|
|
266
300
|
);
|
|
267
301
|
if (t)
|
|
268
302
|
return [
|
|
@@ -276,7 +310,7 @@ function Ee(e) {
|
|
|
276
310
|
].join(`
|
|
277
311
|
`);
|
|
278
312
|
const o = e.views.find(
|
|
279
|
-
(
|
|
313
|
+
(m) => ue(m) && E(m)
|
|
280
314
|
);
|
|
281
315
|
if (o)
|
|
282
316
|
return [
|
|
@@ -289,206 +323,206 @@ function Ee(e) {
|
|
|
289
323
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
290
324
|
].join(`
|
|
291
325
|
`);
|
|
292
|
-
const
|
|
293
|
-
var
|
|
294
|
-
return
|
|
326
|
+
const i = e.views.find((m) => {
|
|
327
|
+
var c;
|
|
328
|
+
return mr((c = m.raw.sdkSpec) == null ? void 0 : c.builder);
|
|
295
329
|
});
|
|
296
|
-
if (
|
|
330
|
+
if (i)
|
|
297
331
|
return [
|
|
298
332
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
299
333
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
300
334
|
"const inputHandles = createInputHandleMap(handles);",
|
|
301
|
-
`const result = useSemaphorQuery(queries.${
|
|
302
|
-
`const rows = rowsForView.${
|
|
335
|
+
`const result = useSemaphorQuery(queries.${i.name}(), queryOptionsForView.${i.name}(inputHandles));`,
|
|
336
|
+
`const rows = rowsForView.${i.name}(result);`,
|
|
303
337
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
304
338
|
].join(`
|
|
305
339
|
`);
|
|
306
|
-
const l = e.views.find((
|
|
340
|
+
const l = e.views.find((m) => je(m));
|
|
307
341
|
if (l)
|
|
308
342
|
return [
|
|
309
|
-
'import { appInputSpecs, createInputHandleMap,
|
|
343
|
+
'import { appInputSpecs, createInputHandleMap, kpiPropsForView, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
310
344
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
311
345
|
"const inputHandles = createInputHandleMap(handles);",
|
|
312
346
|
`const result = useSemaphorQuery(queries.${l.name}(), queryOptionsForView.${l.name}(inputHandles));`,
|
|
313
|
-
`const
|
|
347
|
+
`const kpiProps = kpiPropsForView.${l.name}(result);`,
|
|
314
348
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
315
349
|
].join(`
|
|
316
350
|
`);
|
|
317
|
-
const
|
|
351
|
+
const f = e.views[0];
|
|
318
352
|
return [
|
|
319
353
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
320
354
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
321
355
|
"const inputHandles = createInputHandleMap(handles);",
|
|
322
|
-
|
|
356
|
+
f ? `const result = useSemaphorQuery(queries.${f.name}(), queryOptionsForView.${f.name}(inputHandles));` : "const result = undefined;",
|
|
323
357
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
324
358
|
].join(`
|
|
325
359
|
`);
|
|
326
360
|
}
|
|
327
361
|
function W(e) {
|
|
328
|
-
var
|
|
329
|
-
return B((
|
|
362
|
+
var r;
|
|
363
|
+
return B((r = e.raw.sdkSpec) == null ? void 0 : r.builder) === "records";
|
|
330
364
|
}
|
|
331
|
-
function
|
|
332
|
-
var
|
|
333
|
-
return B((
|
|
365
|
+
function je(e) {
|
|
366
|
+
var r;
|
|
367
|
+
return B((r = e.raw.sdkSpec) == null ? void 0 : r.builder) === "metric";
|
|
334
368
|
}
|
|
335
|
-
function
|
|
336
|
-
var
|
|
337
|
-
return W(e) && ((t = (
|
|
369
|
+
function K(e) {
|
|
370
|
+
var r, n, t;
|
|
371
|
+
return W(e) && ((t = (n = (r = e.raw.visualSpec) == null ? void 0 : r.tableBehavior) == null ? void 0 : n.sorting) == null ? void 0 : t.mode) === "server";
|
|
338
372
|
}
|
|
339
373
|
function ue(e) {
|
|
340
|
-
var
|
|
341
|
-
return B((
|
|
374
|
+
var r;
|
|
375
|
+
return B((r = e.raw.sdkSpec) == null ? void 0 : r.builder) === "sql";
|
|
342
376
|
}
|
|
343
|
-
function
|
|
344
|
-
var
|
|
345
|
-
return ((t = (
|
|
377
|
+
function E(e) {
|
|
378
|
+
var r, n, t;
|
|
379
|
+
return ((t = (n = (r = e.raw.visualSpec) == null ? void 0 : r.tableBehavior) == null ? void 0 : n.pagination) == null ? void 0 : t.mode) === "server";
|
|
346
380
|
}
|
|
347
381
|
function He(e) {
|
|
348
|
-
return W(e) && (
|
|
382
|
+
return W(e) && (E(e) || K(e)) || ue(e) && E(e);
|
|
349
383
|
}
|
|
350
|
-
function
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
return ` ${t}: ${
|
|
384
|
+
function qe(e) {
|
|
385
|
+
const r = e.sources.map(({ name: t, raw: o }) => {
|
|
386
|
+
const i = Be(o);
|
|
387
|
+
return ` ${t}: ${i},`;
|
|
354
388
|
}).join(`
|
|
355
|
-
`),
|
|
389
|
+
`), n = e.sources.some((t) => t.raw.kind === "semantic") ? `import { semaphor } from "react-semaphor/data-app-sdk";
|
|
356
390
|
|
|
357
391
|
` : "";
|
|
358
|
-
return `${
|
|
359
|
-
${
|
|
360
|
-
${
|
|
392
|
+
return `${A}
|
|
393
|
+
${n}export const sources = {
|
|
394
|
+
${r}
|
|
361
395
|
} as const;
|
|
362
396
|
`;
|
|
363
397
|
}
|
|
364
|
-
function
|
|
398
|
+
function Be(e) {
|
|
365
399
|
if (e.kind === "semantic") {
|
|
366
|
-
const
|
|
400
|
+
const r = {
|
|
367
401
|
domainId: e.domainId,
|
|
368
402
|
datasetId: e.datasetId,
|
|
369
403
|
datasetName: e.datasetName,
|
|
370
404
|
label: e.label
|
|
371
405
|
};
|
|
372
|
-
return `semaphor.source.semantic(${
|
|
406
|
+
return `semaphor.source.semantic(${R(O(r))})`;
|
|
373
407
|
}
|
|
374
|
-
return `${
|
|
408
|
+
return `${R(O({ ...e, sourceKey: void 0 }))} as const`;
|
|
375
409
|
}
|
|
376
|
-
function
|
|
377
|
-
const
|
|
378
|
-
const
|
|
379
|
-
return ` ${t}: ${
|
|
410
|
+
function Pe(e) {
|
|
411
|
+
const r = e.fields.map(({ name: t, raw: o }) => {
|
|
412
|
+
const i = Te(o, e);
|
|
413
|
+
return ` ${t}: ${i},`;
|
|
380
414
|
}).join(`
|
|
381
|
-
`),
|
|
415
|
+
`), n = r.includes("sources.") ? `import { sources } from "./sources";
|
|
382
416
|
|
|
383
417
|
` : "";
|
|
384
|
-
return `${
|
|
385
|
-
${
|
|
386
|
-
${
|
|
418
|
+
return `${A}
|
|
419
|
+
${n}export const fields = {
|
|
420
|
+
${r}
|
|
387
421
|
} as const;
|
|
388
422
|
`;
|
|
389
423
|
}
|
|
390
|
-
function
|
|
391
|
-
const
|
|
424
|
+
function Te(e, r) {
|
|
425
|
+
const n = {
|
|
392
426
|
name: e.name,
|
|
393
427
|
label: e.label,
|
|
394
428
|
role: e.role,
|
|
395
429
|
dataType: e.dataType,
|
|
396
430
|
aggregate: e.aggregate
|
|
397
|
-
}, t =
|
|
431
|
+
}, t = cr(e), o = t ? r.sourceNameByKey.get(t) : void 0;
|
|
398
432
|
if (t && !o)
|
|
399
433
|
throw new Error(
|
|
400
434
|
`Field ${e.name} references source ${t}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`
|
|
401
435
|
);
|
|
402
|
-
const
|
|
403
|
-
return o &&
|
|
404
|
-
}
|
|
405
|
-
function
|
|
406
|
-
const
|
|
407
|
-
const
|
|
408
|
-
`id: ${JSON.stringify(
|
|
409
|
-
`label: ${JSON.stringify(
|
|
410
|
-
`operator: ${JSON.stringify(
|
|
436
|
+
const i = Object.entries(O(n)).map(([l, f]) => `${JSON.stringify(l)}: ${G(f, r)}`);
|
|
437
|
+
return o && i.push(`"source": sources.${o}`), `{ ${i.join(", ")} }`;
|
|
438
|
+
}
|
|
439
|
+
function Qe(e) {
|
|
440
|
+
const r = e.inputs.map((p) => {
|
|
441
|
+
const $ = x(p.raw.fieldRef, e), a = [
|
|
442
|
+
`id: ${JSON.stringify(p.raw.id)}`,
|
|
443
|
+
`label: ${JSON.stringify(p.raw.label || p.raw.id)}`,
|
|
444
|
+
`operator: ${JSON.stringify(fr(p.raw))}`
|
|
411
445
|
];
|
|
412
|
-
if (
|
|
413
|
-
throw new Error(`Input ${
|
|
414
|
-
return ` ${
|
|
446
|
+
if ($ && a.push(`field: fields.${$}`), p.raw.relationshipHint && a.push(`relationshipHint: ${R(p.raw.relationshipHint)}`), !$)
|
|
447
|
+
throw new Error(`Input ${p.raw.id || p.name} is missing a generated field reference.`);
|
|
448
|
+
return ` ${p.name}: semaphor.filter({ ${a.join(", ")} }),`;
|
|
415
449
|
}).join(`
|
|
416
|
-
`),
|
|
417
|
-
const
|
|
418
|
-
id:
|
|
419
|
-
inputId:
|
|
420
|
-
source:
|
|
421
|
-
sourceKey:
|
|
450
|
+
`), n = e.inputs.map((p) => `filterSpecs.${p.name}`).join(", "), t = e.inputs.map((p) => JSON.stringify(p.raw.id)).join(", "), o = e.optionQueries.map((p) => {
|
|
451
|
+
const $ = p.input.raw, a = p.raw, g = k(a.spec) || {}, {
|
|
452
|
+
id: h,
|
|
453
|
+
inputId: y,
|
|
454
|
+
source: I,
|
|
455
|
+
sourceKey: V,
|
|
422
456
|
valueField: b,
|
|
423
457
|
labelField: M,
|
|
424
458
|
population: s,
|
|
425
|
-
dependencies:
|
|
426
|
-
limit:
|
|
459
|
+
dependencies: S,
|
|
460
|
+
limit: P,
|
|
427
461
|
...ee
|
|
428
|
-
} =
|
|
462
|
+
} = g, L = a.sourceKey ? { sourceKey: a.sourceKey } : a.source || I || (typeof V == "string" ? { sourceKey: V } : void 0), re = Se(L, e), ne = x(a.valueFieldRef, e), te = x(a.labelFieldRef, e), oe = ge(p), se = {
|
|
429
463
|
...ee,
|
|
430
|
-
id:
|
|
431
|
-
inputId:
|
|
432
|
-
source:
|
|
433
|
-
valueField:
|
|
434
|
-
labelField:
|
|
435
|
-
population:
|
|
464
|
+
id: a.id || g.id || `${$.id}-options`,
|
|
465
|
+
inputId: $.id,
|
|
466
|
+
source: L,
|
|
467
|
+
valueField: a.valueFieldRef,
|
|
468
|
+
labelField: a.labelFieldRef,
|
|
469
|
+
population: a.population || s,
|
|
436
470
|
dependencies: oe,
|
|
437
|
-
limit:
|
|
471
|
+
limit: a.limit || P || 100
|
|
438
472
|
};
|
|
439
|
-
if (!
|
|
440
|
-
throw new Error(`Input option query ${
|
|
441
|
-
const Fe = Object.entries(
|
|
442
|
-
return ` ${
|
|
473
|
+
if (!re || !ne || !te)
|
|
474
|
+
throw new Error(`Input option query ${a.id || `${$.id}-options`} is missing source, valueField, or labelField.`);
|
|
475
|
+
const Fe = Object.entries(O(se)).map(([Ve, be]) => `${JSON.stringify(Ve)}: ${G(be, e)}`);
|
|
476
|
+
return ` ${p.name}: semaphor.inputOptions({ ${Fe.join(", ")} }),`;
|
|
443
477
|
}).join(`
|
|
444
|
-
`),
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
478
|
+
`), i = e.optionQueries.map((p) => {
|
|
479
|
+
const $ = _e(e, p), a = $.length > 0 ? "inputHandles" : "_inputHandles", g = $.map((h) => {
|
|
480
|
+
const y = x(h.raw.fieldRef, e);
|
|
481
|
+
if (!y)
|
|
448
482
|
throw new Error(
|
|
449
|
-
`Input option query ${
|
|
483
|
+
`Input option query ${p.raw.id || `${p.input.raw.id}-options`} references input ${h.raw.id} without a generated field reference.`
|
|
450
484
|
);
|
|
451
|
-
const
|
|
452
|
-
return ` if (${
|
|
453
|
-
inputs.push(semaphor.bindInput(${
|
|
485
|
+
const I = `inputHandles[${JSON.stringify(h.raw.id)}]`;
|
|
486
|
+
return ` if (${I}) {
|
|
487
|
+
inputs.push(semaphor.bindInput(${I}, { field: fields.${y} }));
|
|
454
488
|
}`;
|
|
455
489
|
}).join(`
|
|
456
490
|
`);
|
|
457
|
-
return ` ${
|
|
491
|
+
return ` ${p.name}(${a}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
458
492
|
const inputs: SemaphorInputReference[] = [];
|
|
459
|
-
${
|
|
493
|
+
${g}
|
|
460
494
|
return inputs;
|
|
461
495
|
},`;
|
|
462
496
|
}).join(`
|
|
463
497
|
|
|
464
|
-
`), l = e.optionQueries.map((
|
|
498
|
+
`), l = e.optionQueries.map((p) => ` ${p.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
465
499
|
return {
|
|
466
|
-
inputs: inputsForInputOptionQuery.${
|
|
500
|
+
inputs: inputsForInputOptionQuery.${p.name}(inputHandles),
|
|
467
501
|
};
|
|
468
502
|
},`).join(`
|
|
469
503
|
|
|
470
|
-
`),
|
|
471
|
-
return queryOptionsForInputOptionQuery.${
|
|
472
|
-
`),
|
|
504
|
+
`), f = e.optionQueries.map((p) => ` case ${JSON.stringify(p.raw.id || `${p.input.raw.id}-options`)}:
|
|
505
|
+
return queryOptionsForInputOptionQuery.${p.name}(inputHandles);`).join(`
|
|
506
|
+
`), F = e.inputs.length > 0, m = e.optionQueries.length > 0, c = m ? "inputOptionQueryId" : "_inputOptionQueryId", N = m ? "inputHandles" : "_inputHandles", u = [
|
|
473
507
|
"SemaphorInputHandle",
|
|
474
|
-
|
|
508
|
+
m ? "SemaphorInputReference" : void 0,
|
|
475
509
|
"SemaphorQueryRuntimeOptions"
|
|
476
|
-
].filter(
|
|
477
|
-
|
|
510
|
+
].filter(v).join(", "), d = [
|
|
511
|
+
F || m ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
478
512
|
`import type { ${u} } from "react-semaphor/data-app-sdk";`,
|
|
479
|
-
|
|
480
|
-
|
|
513
|
+
F || m ? 'import { fields } from "./fields";' : void 0,
|
|
514
|
+
m ? 'import { sources } from "./sources";' : void 0,
|
|
481
515
|
'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'
|
|
482
|
-
].filter(
|
|
516
|
+
].filter(v).join(`
|
|
483
517
|
`);
|
|
484
|
-
return `${
|
|
518
|
+
return `${A}
|
|
485
519
|
${d}
|
|
486
520
|
|
|
487
521
|
export const filterSpecs = {
|
|
488
|
-
${
|
|
522
|
+
${r}
|
|
489
523
|
} as const;
|
|
490
524
|
|
|
491
|
-
export const appInputSpecs = [${
|
|
525
|
+
export const appInputSpecs = [${n}] as const;
|
|
492
526
|
export const appInputIds = [${t}] as const;
|
|
493
527
|
|
|
494
528
|
export type SemaphorGeneratedInputHandleMap = Partial<Record<SemaphorGeneratedInputId, SemaphorInputHandle>>;
|
|
@@ -502,7 +536,7 @@ ${o}
|
|
|
502
536
|
} as const;
|
|
503
537
|
|
|
504
538
|
export const inputsForInputOptionQuery = {
|
|
505
|
-
${
|
|
539
|
+
${i}
|
|
506
540
|
} as const;
|
|
507
541
|
|
|
508
542
|
export const queryOptionsForInputOptionQuery = {
|
|
@@ -510,100 +544,100 @@ ${l}
|
|
|
510
544
|
} as const;
|
|
511
545
|
|
|
512
546
|
export function queryOptionsForInputOptionQueryId(
|
|
513
|
-
${
|
|
547
|
+
${c}: SemaphorGeneratedInputOptionQueryId,
|
|
514
548
|
${N}: SemaphorGeneratedInputHandleMap,
|
|
515
549
|
): SemaphorQueryRuntimeOptions {
|
|
516
|
-
switch (${
|
|
517
|
-
${
|
|
550
|
+
switch (${c}) {
|
|
551
|
+
${f}
|
|
518
552
|
}
|
|
519
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
553
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${c}}\`);
|
|
520
554
|
}
|
|
521
555
|
`;
|
|
522
556
|
}
|
|
523
|
-
function
|
|
524
|
-
const
|
|
525
|
-
if (!
|
|
557
|
+
function _e(e, r) {
|
|
558
|
+
const n = ge(r);
|
|
559
|
+
if (!n || n.mode === "independent")
|
|
526
560
|
return [];
|
|
527
|
-
if (
|
|
561
|
+
if (n.mode !== "explicit")
|
|
528
562
|
return [];
|
|
529
|
-
const t = new Set(
|
|
530
|
-
|
|
531
|
-
...
|
|
563
|
+
const t = new Set(n.includeInputIds || []), o = /* @__PURE__ */ new Set([
|
|
564
|
+
r.input.raw.id,
|
|
565
|
+
...n.excludeInputIds || []
|
|
532
566
|
]);
|
|
533
|
-
return e.inputs.filter((
|
|
567
|
+
return e.inputs.filter((i) => o.has(i.raw.id) ? !1 : t.has(i.raw.id));
|
|
534
568
|
}
|
|
535
569
|
function ge(e) {
|
|
536
|
-
var
|
|
537
|
-
return e.raw.dependencies || ((
|
|
570
|
+
var r;
|
|
571
|
+
return e.raw.dependencies || ((r = e.raw.spec) == null ? void 0 : r.dependencies);
|
|
538
572
|
}
|
|
539
|
-
function
|
|
540
|
-
const
|
|
541
|
-
var
|
|
542
|
-
const
|
|
573
|
+
function De(e) {
|
|
574
|
+
const r = e.views.map((d) => {
|
|
575
|
+
var a, g, h, y, I, V;
|
|
576
|
+
const p = B(d.raw.sdkSpec.builder), $ = Ue(d);
|
|
543
577
|
if (W(d) && He(d)) {
|
|
544
|
-
const b = (
|
|
578
|
+
const b = (a = d.raw.visualSpec) == null ? void 0 : a.tableBehavior, M = k($.pagination), s = E(d), S = K(d), P = ((g = b == null ? void 0 : b.pagination) == null ? void 0 : g.pageSize) || z(M == null ? void 0 : M.pageSize) || z($.limit) || 100, ee = S ? Y(d, e) : [], L = S ? Je({
|
|
545
579
|
view: d,
|
|
546
580
|
contract: e,
|
|
547
581
|
sortFields: ee,
|
|
548
|
-
defaultField: (
|
|
549
|
-
}) : void 0,
|
|
582
|
+
defaultField: (h = b == null ? void 0 : b.sorting) == null ? void 0 : h.defaultField
|
|
583
|
+
}) : void 0, re = S ? (y = b == null ? void 0 : b.sorting) == null ? void 0 : y.defaultDirection : void 0, ne = Le({
|
|
550
584
|
viewName: d.name,
|
|
551
585
|
supportsPagination: s,
|
|
552
|
-
supportsSort:
|
|
553
|
-
}), te =
|
|
586
|
+
supportsSort: S
|
|
587
|
+
}), te = S ? ` const orderBy = resolveRecordsOrderBy(
|
|
554
588
|
recordsSortFieldsForView.${d.name},
|
|
555
589
|
params.sort,
|
|
556
|
-
${
|
|
557
|
-
${
|
|
590
|
+
${G(L, e)},
|
|
591
|
+
${G(re, e)},
|
|
558
592
|
);
|
|
559
|
-
` : "", oe =
|
|
560
|
-
` : "", se = s ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(
|
|
593
|
+
` : "", oe = S ? ` ...(orderBy ? { orderBy } : {}),
|
|
594
|
+
` : "", se = s ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(P)}),
|
|
561
595
|
` : "";
|
|
562
596
|
return ` ${d.name}(
|
|
563
|
-
params: ${
|
|
597
|
+
params: ${ne} = {},
|
|
564
598
|
) {
|
|
565
|
-
${te} return semaphor.${
|
|
566
|
-
...${
|
|
599
|
+
${te} return semaphor.${p}({
|
|
600
|
+
...${G($, e)},
|
|
567
601
|
${oe}${se} });
|
|
568
602
|
},`;
|
|
569
603
|
}
|
|
570
|
-
if (ue(d) &&
|
|
571
|
-
const b = (
|
|
604
|
+
if (ue(d) && E(d)) {
|
|
605
|
+
const b = (I = d.raw.visualSpec) == null ? void 0 : I.tableBehavior, M = k($.pagination), s = ((V = b == null ? void 0 : b.pagination) == null ? void 0 : V.pageSize) || z(M == null ? void 0 : M.pageSize) || z($.limit) || 100;
|
|
572
606
|
return ` ${d.name}(
|
|
573
607
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
574
608
|
) {
|
|
575
|
-
return semaphor.${
|
|
576
|
-
...${
|
|
609
|
+
return semaphor.${p}({
|
|
610
|
+
...${G($, e)},
|
|
577
611
|
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
578
612
|
});
|
|
579
613
|
},`;
|
|
580
614
|
}
|
|
581
|
-
return ` ${d.name}: () => semaphor.${
|
|
615
|
+
return ` ${d.name}: () => semaphor.${p}(${G($, e)}),`;
|
|
582
616
|
}).join(`
|
|
583
|
-
`),
|
|
584
|
-
const
|
|
617
|
+
`), n = e.views.filter((d) => K(d)).map((d) => {
|
|
618
|
+
const $ = Y(d, e).map((a) => ` ${JSON.stringify(a.key)}: fields.${a.fieldName},`).join(`
|
|
585
619
|
`);
|
|
586
620
|
return ` ${d.name}: {
|
|
587
|
-
${
|
|
621
|
+
${$}
|
|
588
622
|
},`;
|
|
589
623
|
}).join(`
|
|
590
|
-
`), t = e.views.filter((d) =>
|
|
591
|
-
const
|
|
624
|
+
`), t = e.views.filter((d) => K(d)).map((d) => {
|
|
625
|
+
const $ = Y(d, e).map((a) => ` { key: ${JSON.stringify(a.key)}, label: ${JSON.stringify(a.label)}, field: fields.${a.fieldName} },`).join(`
|
|
592
626
|
`);
|
|
593
627
|
return ` ${d.name}: [
|
|
594
|
-
${
|
|
628
|
+
${$}
|
|
595
629
|
],`;
|
|
596
630
|
}).join(`
|
|
597
|
-
`), o = e.views.some((d) =>
|
|
598
|
-
`),
|
|
599
|
-
|
|
631
|
+
`), o = e.views.some((d) => K(d)), i = e.views.some((d) => E(d)), l = [r, n, t].join(`
|
|
632
|
+
`), f = [
|
|
633
|
+
r ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
600
634
|
o ? 'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";' : void 0,
|
|
601
635
|
l.includes("fields.") ? 'import { fields } from "./fields";' : void 0,
|
|
602
636
|
l.includes("sources.") ? 'import { sources } from "./sources";' : void 0
|
|
603
|
-
].filter(
|
|
637
|
+
].filter(v).join(`
|
|
604
638
|
`);
|
|
605
|
-
return `${
|
|
606
|
-
${
|
|
639
|
+
return `${A}
|
|
640
|
+
${f}
|
|
607
641
|
${o ? `export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
608
642
|
|
|
609
643
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
@@ -614,17 +648,17 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
614
648
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
615
649
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
616
650
|
};
|
|
617
|
-
` : ""}${
|
|
651
|
+
` : ""}${i ? `export type SemaphorGeneratedServerPaginationParams = {
|
|
618
652
|
page?: number;
|
|
619
653
|
pageSize?: number;
|
|
620
654
|
};
|
|
621
|
-
` : ""}${o &&
|
|
655
|
+
` : ""}${o && i ? `export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
622
656
|
SemaphorGeneratedServerPaginationParams &
|
|
623
657
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
624
658
|
` : ""}
|
|
625
659
|
|
|
626
660
|
export const recordsSortFieldsForView = {
|
|
627
|
-
${
|
|
661
|
+
${n}
|
|
628
662
|
} as const;
|
|
629
663
|
|
|
630
664
|
export const recordsSortOptionsForView = {
|
|
@@ -632,7 +666,7 @@ ${t}
|
|
|
632
666
|
} as const;
|
|
633
667
|
|
|
634
668
|
export const queries = {
|
|
635
|
-
${
|
|
669
|
+
${r}
|
|
636
670
|
} as const;
|
|
637
671
|
|
|
638
672
|
${o ? `function resolveRecordsOrderBy<TSortKey extends string>(
|
|
@@ -655,7 +689,7 @@ ${o ? `function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
655
689
|
};
|
|
656
690
|
}
|
|
657
691
|
` : ""}
|
|
658
|
-
${
|
|
692
|
+
${i ? `function resolveServerTablePagination(
|
|
659
693
|
params: SemaphorGeneratedServerPaginationParams,
|
|
660
694
|
defaultPageSize: number,
|
|
661
695
|
) {
|
|
@@ -667,112 +701,112 @@ ${a ? `function resolveServerTablePagination(
|
|
|
667
701
|
` : ""}
|
|
668
702
|
`;
|
|
669
703
|
}
|
|
670
|
-
function
|
|
671
|
-
var
|
|
672
|
-
const
|
|
704
|
+
function Ue(e) {
|
|
705
|
+
var i, l;
|
|
706
|
+
const r = k((i = e.raw.sdkSpec) == null ? void 0 : i.spec) || {}, { kind: n, id: t, ...o } = r;
|
|
673
707
|
return {
|
|
674
708
|
...o,
|
|
675
709
|
id: e.raw.id,
|
|
676
710
|
label: ((l = e.raw.visualSpec) == null ? void 0 : l.title) || e.raw.title || o.label
|
|
677
711
|
};
|
|
678
712
|
}
|
|
679
|
-
function Y(e,
|
|
680
|
-
var
|
|
681
|
-
const
|
|
682
|
-
for (const
|
|
683
|
-
|
|
684
|
-
for (const
|
|
713
|
+
function Y(e, r) {
|
|
714
|
+
var i, l;
|
|
715
|
+
const n = [], t = k((i = e.raw.sdkSpec) == null ? void 0 : i.spec) || {};
|
|
716
|
+
for (const f of H(t.fields)) w(n, f);
|
|
717
|
+
w(n, t.dateField), w(n, (l = k(t.orderBy)) == null ? void 0 : l.field);
|
|
718
|
+
for (const f of e.raw.fields || []) w(n, f);
|
|
685
719
|
return X(
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
if (!(!
|
|
720
|
+
n.map((f) => {
|
|
721
|
+
const F = x(f, r);
|
|
722
|
+
if (!(!f.name || !F))
|
|
689
723
|
return {
|
|
690
|
-
key:
|
|
691
|
-
fieldName:
|
|
692
|
-
rawName:
|
|
693
|
-
label:
|
|
724
|
+
key: F,
|
|
725
|
+
fieldName: F,
|
|
726
|
+
rawName: f.name,
|
|
727
|
+
label: f.label || f.name
|
|
694
728
|
};
|
|
695
|
-
}).filter(
|
|
696
|
-
(
|
|
729
|
+
}).filter(v),
|
|
730
|
+
(f) => f.key
|
|
697
731
|
);
|
|
698
732
|
}
|
|
699
|
-
function
|
|
733
|
+
function Je({
|
|
700
734
|
view: e,
|
|
701
|
-
contract:
|
|
702
|
-
sortFields:
|
|
735
|
+
contract: r,
|
|
736
|
+
sortFields: n,
|
|
703
737
|
defaultField: t
|
|
704
738
|
}) {
|
|
705
|
-
var
|
|
706
|
-
const o = new Set(
|
|
739
|
+
var F, m;
|
|
740
|
+
const o = new Set(n.map((c) => c.key));
|
|
707
741
|
if (t && o.has(t))
|
|
708
742
|
return t;
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
711
|
-
return
|
|
712
|
-
const l =
|
|
713
|
-
return
|
|
743
|
+
const i = n.filter((c) => c.rawName === t);
|
|
744
|
+
if (i.length === 1)
|
|
745
|
+
return i[0].key;
|
|
746
|
+
const l = k((F = e.raw.sdkSpec) == null ? void 0 : F.spec), f = x((m = k(l == null ? void 0 : l.orderBy)) == null ? void 0 : m.field, r);
|
|
747
|
+
return f && o.has(f) ? f : void 0;
|
|
714
748
|
}
|
|
715
|
-
function
|
|
749
|
+
function Le({
|
|
716
750
|
viewName: e,
|
|
717
|
-
supportsPagination:
|
|
718
|
-
supportsSort:
|
|
751
|
+
supportsPagination: r,
|
|
752
|
+
supportsSort: n
|
|
719
753
|
}) {
|
|
720
|
-
return
|
|
754
|
+
return r && n ? `SemaphorGeneratedRecordsQueryParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>` : n ? `SemaphorGeneratedRecordsSortParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>` : "SemaphorGeneratedServerPaginationParams";
|
|
721
755
|
}
|
|
722
|
-
function
|
|
723
|
-
const
|
|
724
|
-
const u =
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
756
|
+
function ze(e) {
|
|
757
|
+
const r = e.views.map((c) => {
|
|
758
|
+
const u = Ye(e, c.raw.id).map((d) => {
|
|
759
|
+
const p = d.inputId, $ = x(d.fieldRef, e);
|
|
760
|
+
if (!p || !$)
|
|
727
761
|
return "";
|
|
728
|
-
const
|
|
762
|
+
const a = [`field: fields.${$}`];
|
|
729
763
|
if (d.relationshipHint)
|
|
730
|
-
|
|
764
|
+
a.push(`relationshipHint: ${R(d.relationshipHint)}`);
|
|
731
765
|
else if (Array.isArray(d.relationshipsUsed) && d.relationshipsUsed.length > 0) {
|
|
732
|
-
const
|
|
733
|
-
var
|
|
734
|
-
return (
|
|
735
|
-
}).filter((
|
|
736
|
-
|
|
766
|
+
const h = d.relationshipsUsed.map((y) => {
|
|
767
|
+
var I;
|
|
768
|
+
return (I = k(y)) == null ? void 0 : I.id;
|
|
769
|
+
}).filter((y) => typeof y == "string" && y.length > 0);
|
|
770
|
+
h.length > 0 && a.push(`relationshipHint: ${R({ relationshipIds: h })}`);
|
|
737
771
|
}
|
|
738
|
-
const
|
|
739
|
-
return ` if (${
|
|
740
|
-
inputs.push(semaphor.bindInput(${
|
|
772
|
+
const g = `inputHandles[${JSON.stringify(p)}]`;
|
|
773
|
+
return ` if (${g}) {
|
|
774
|
+
inputs.push(semaphor.bindInput(${g}, { ${a.join(", ")} }));
|
|
741
775
|
}`;
|
|
742
776
|
}).filter(Boolean).join(`
|
|
743
777
|
`);
|
|
744
|
-
return { view:
|
|
745
|
-
}),
|
|
778
|
+
return { view: c, renderedBindings: u };
|
|
779
|
+
}), n = r.some((c) => c.renderedBindings.length > 0), t = r.map(({ view: c, renderedBindings: N }) => {
|
|
746
780
|
const u = N ? "inputHandles" : "_inputHandles";
|
|
747
|
-
return ` ${
|
|
781
|
+
return ` ${c.name}(${u}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
748
782
|
const inputs: SemaphorInputReference[] = [];
|
|
749
783
|
${N}
|
|
750
784
|
return inputs;
|
|
751
785
|
},`;
|
|
752
786
|
}).join(`
|
|
753
787
|
|
|
754
|
-
`), o = e.views.map((
|
|
788
|
+
`), o = e.views.map((c) => ` ${c.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
755
789
|
return {
|
|
756
|
-
inputs: inputsForView.${
|
|
757
|
-
debug: queryDebugForView.${
|
|
790
|
+
inputs: inputsForView.${c.name}(inputHandles),
|
|
791
|
+
debug: queryDebugForView.${c.name},
|
|
758
792
|
};
|
|
759
793
|
},`).join(`
|
|
760
794
|
|
|
761
|
-
`),
|
|
762
|
-
return inputsForView.${
|
|
763
|
-
`), l = e.views.map((
|
|
764
|
-
return queryOptionsForView.${
|
|
765
|
-
`),
|
|
766
|
-
|
|
795
|
+
`), i = e.views.map((c) => ` case ${JSON.stringify(c.raw.id)}:
|
|
796
|
+
return inputsForView.${c.name}(inputHandles);`).join(`
|
|
797
|
+
`), l = e.views.map((c) => ` case ${JSON.stringify(c.raw.id)}:
|
|
798
|
+
return queryOptionsForView.${c.name}(inputHandles);`).join(`
|
|
799
|
+
`), f = e.views.length > 0, F = f ? "inputHandles" : "_inputHandles", m = [
|
|
800
|
+
n ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
767
801
|
'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',
|
|
768
|
-
|
|
802
|
+
n ? 'import { fields } from "./fields";' : void 0,
|
|
769
803
|
'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',
|
|
770
|
-
|
|
804
|
+
f ? 'import { queryDebugForView } from "./metadata";' : void 0,
|
|
771
805
|
'import type { SemaphorGeneratedQueryViewId } from "./metadata";'
|
|
772
|
-
].filter(
|
|
806
|
+
].filter(v).join(`
|
|
773
807
|
`);
|
|
774
|
-
return `${
|
|
775
|
-
${
|
|
808
|
+
return `${A}
|
|
809
|
+
${m}
|
|
776
810
|
|
|
777
811
|
export const inputsForView = {
|
|
778
812
|
${t}
|
|
@@ -784,17 +818,17 @@ ${o}
|
|
|
784
818
|
|
|
785
819
|
export function inputsForViewId(
|
|
786
820
|
viewId: SemaphorGeneratedQueryViewId,
|
|
787
|
-
${
|
|
821
|
+
${F}: SemaphorGeneratedInputHandleMap,
|
|
788
822
|
): SemaphorInputReference[] {
|
|
789
823
|
switch (viewId) {
|
|
790
|
-
${
|
|
824
|
+
${i}
|
|
791
825
|
}
|
|
792
826
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
793
827
|
}
|
|
794
828
|
|
|
795
829
|
export function queryOptionsForViewId(
|
|
796
830
|
viewId: SemaphorGeneratedQueryViewId,
|
|
797
|
-
${
|
|
831
|
+
${F}: SemaphorGeneratedInputHandleMap,
|
|
798
832
|
): SemaphorQueryRuntimeOptions {
|
|
799
833
|
switch (viewId) {
|
|
800
834
|
${l}
|
|
@@ -803,150 +837,180 @@ ${l}
|
|
|
803
837
|
}
|
|
804
838
|
`;
|
|
805
839
|
}
|
|
806
|
-
function
|
|
840
|
+
function Ye(e, r) {
|
|
807
841
|
return e.filterContracts.flatMap(
|
|
808
|
-
(
|
|
809
|
-
inputId:
|
|
842
|
+
(n) => (n.bindings || []).filter((t) => t.viewId === r).map((t) => ({
|
|
843
|
+
inputId: n.inputId,
|
|
810
844
|
fieldRef: t.fieldRef,
|
|
811
845
|
relationshipHint: t.relationshipHint,
|
|
812
846
|
relationshipsUsed: t.relationshipsUsed
|
|
813
847
|
}))
|
|
814
848
|
);
|
|
815
849
|
}
|
|
816
|
-
function
|
|
817
|
-
const
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
return
|
|
850
|
+
function We(e) {
|
|
851
|
+
const r = e.views.map((a) => {
|
|
852
|
+
const h = D(a, e).map((y) => {
|
|
853
|
+
const I = x(y.raw, e);
|
|
854
|
+
return I ? ` ${y.name}: fields.${I},` : "";
|
|
821
855
|
}).filter(Boolean).join(`
|
|
822
856
|
`);
|
|
823
|
-
return ` ${
|
|
824
|
-
${
|
|
857
|
+
return ` ${a.name}: {
|
|
858
|
+
${h}
|
|
825
859
|
},`;
|
|
826
860
|
}).join(`
|
|
827
|
-
`),
|
|
828
|
-
const
|
|
829
|
-
const
|
|
830
|
-
return
|
|
861
|
+
`), n = e.views.map((a) => {
|
|
862
|
+
const h = T(a, e).map((y) => {
|
|
863
|
+
const I = x(y.raw, e);
|
|
864
|
+
return I ? ` ${y.name}: fields.${I},` : "";
|
|
831
865
|
}).filter(Boolean).join(`
|
|
832
866
|
`);
|
|
833
|
-
return ` ${
|
|
834
|
-
${
|
|
867
|
+
return ` ${a.name}: {
|
|
868
|
+
${h}
|
|
835
869
|
},`;
|
|
836
870
|
}).join(`
|
|
837
|
-
`), t = e.views.map((
|
|
838
|
-
const
|
|
839
|
-
const
|
|
871
|
+
`), t = e.views.map((a) => {
|
|
872
|
+
const g = T(a, e), h = or(g), y = tr(g), I = g.map((V) => {
|
|
873
|
+
const b = Array.from(
|
|
840
874
|
new Set(
|
|
841
|
-
he(
|
|
875
|
+
he(V.raw).filter((M) => y.has(M))
|
|
842
876
|
)
|
|
843
877
|
);
|
|
844
|
-
return ` ${
|
|
878
|
+
return ` ${V.name}: metricKeysForField(metricFieldsForView.${a.name}.${V.name}, { allowNameFallback: ${h.has(V.raw.name) ? "false" : "true"}, excludedKeys: ${R(b)} }),`;
|
|
845
879
|
}).join(`
|
|
846
880
|
`);
|
|
847
|
-
return ` ${
|
|
848
|
-
${
|
|
881
|
+
return ` ${a.name}: {
|
|
882
|
+
${I}
|
|
849
883
|
},`;
|
|
850
884
|
}).join(`
|
|
851
|
-
`), o = e.views.map((
|
|
852
|
-
const
|
|
885
|
+
`), o = e.views.map((a) => {
|
|
886
|
+
const h = T(a, e).map((y, I) => ` ${y.name}: ${JSON.stringify(rr(a, y, I))},`).join(`
|
|
853
887
|
`);
|
|
854
|
-
return ` ${
|
|
855
|
-
${
|
|
888
|
+
return ` ${a.name}: {
|
|
889
|
+
${h}
|
|
856
890
|
},`;
|
|
857
891
|
}).join(`
|
|
858
|
-
`),
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
return ` ${
|
|
892
|
+
`), i = e.views.map((a) => {
|
|
893
|
+
const g = T(a, e);
|
|
894
|
+
if (g.length === 0)
|
|
895
|
+
return ` ${a.name}(): Record<keyof typeof metricFieldsForView.${a.name}, unknown> {
|
|
862
896
|
return {};
|
|
863
897
|
},`;
|
|
864
|
-
const
|
|
865
|
-
const
|
|
866
|
-
return ` ${
|
|
898
|
+
const h = nr(a, g), y = g.map((I) => {
|
|
899
|
+
const V = `metricMeasureKeysForView.${a.name}.${I.name}`, b = `metricMeasureBindingKeysForView.${a.name}.${I.name}`, M = h.has(I.name) ? `readMetricValueByBindingWithFallback(measures, measureBindings, ${b}, ${V}, primaryValue)` : `readMetricValueByBinding(measures, measureBindings, ${b}, ${V})`;
|
|
900
|
+
return ` ${I.name}: ${M},`;
|
|
867
901
|
}).join(`
|
|
868
902
|
`);
|
|
869
|
-
return ` ${
|
|
903
|
+
return ` ${a.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${a.name}, unknown> {
|
|
870
904
|
const measures = result?.measures;
|
|
871
905
|
const measureBindings = result?.measureBindings;
|
|
872
906
|
const primaryValue = result?.primaryValue;
|
|
873
907
|
return {
|
|
874
|
-
${
|
|
908
|
+
${y}
|
|
875
909
|
};
|
|
876
910
|
},`;
|
|
877
911
|
}).join(`
|
|
878
912
|
|
|
879
|
-
`), l = e.views.map((
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
return ` ${
|
|
913
|
+
`), l = e.views.map((a) => {
|
|
914
|
+
const g = T(a, e);
|
|
915
|
+
if (g.length === 0)
|
|
916
|
+
return ` ${a.name}(): Array<keyof typeof metricFieldsForView.${a.name}> {
|
|
883
917
|
return [];
|
|
884
918
|
},`;
|
|
885
|
-
const
|
|
919
|
+
const h = g.map((y) => ` ...(missing.has(metricMeasureBindingKeysForView.${a.name}.${y.name}) ? [${JSON.stringify(y.name)} as keyof typeof metricFieldsForView.${a.name}] : []),`).join(`
|
|
886
920
|
`);
|
|
887
|
-
return ` ${
|
|
921
|
+
return ` ${a.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${a.name}> {
|
|
888
922
|
const missing = new Set(result?.missingMeasures || []);
|
|
889
923
|
return [
|
|
890
|
-
${
|
|
924
|
+
${h}
|
|
891
925
|
];
|
|
892
926
|
},`;
|
|
893
927
|
}).join(`
|
|
894
928
|
|
|
895
|
-
`),
|
|
896
|
-
const
|
|
897
|
-
|
|
929
|
+
`), f = e.views.map((a) => {
|
|
930
|
+
const g = T(a, e);
|
|
931
|
+
if (g.length === 0)
|
|
932
|
+
return "";
|
|
933
|
+
const h = g[0], y = g.map((V) => `{ key: ${JSON.stringify(V.name)}, label: ${JSON.stringify(V.raw.label || V.raw.name)} }`).join(", "), I = g.filter((V) => V.name !== h.name).map((V) => ` if (missing.includes(${JSON.stringify(V.name)})) delete values.${V.name};`).join(`
|
|
934
|
+
`);
|
|
935
|
+
return ` ${a.name}(result: SemaphorGeneratedMetricResult): SemaphorGeneratedKpiProps {
|
|
936
|
+
const values = mapMetricDisplayValues(metricValuesForView.${a.name}(result));
|
|
937
|
+
const missing = missingMetricMeasuresForView.${a.name}(result).map((key) => String(key));
|
|
938
|
+
const primaryMissing = missing.includes(${JSON.stringify(h.name)});
|
|
939
|
+
const primaryValue = primaryMissing ? result?.primaryValue : values.${h.name};
|
|
940
|
+
if (primaryMissing) values.${h.name} = metricDisplayValue(result?.primaryValue);
|
|
941
|
+
${I}
|
|
942
|
+
return {
|
|
943
|
+
result: {
|
|
944
|
+
...(result || {}),
|
|
945
|
+
value: metricDisplayValue(result?.value),
|
|
946
|
+
primaryValue: metricDisplayValue(result?.primaryValue),
|
|
947
|
+
comparisonValue: metricDisplayValue(result?.comparisonValue),
|
|
948
|
+
measures: values,
|
|
949
|
+
},
|
|
950
|
+
title: ${JSON.stringify(a.raw.title || a.raw.id)},
|
|
951
|
+
label: ${JSON.stringify(h.raw.label || h.raw.name)},
|
|
952
|
+
value: metricDisplayValue(primaryValue),
|
|
953
|
+
measures: [${y}],
|
|
954
|
+
missingMeasures: missing,
|
|
955
|
+
showComparison: Boolean(result?.comparisonKind),
|
|
956
|
+
};
|
|
957
|
+
},`;
|
|
958
|
+
}).filter(Boolean).join(`
|
|
959
|
+
|
|
960
|
+
`), F = e.views.map((a) => {
|
|
961
|
+
const g = Ze(a, e);
|
|
962
|
+
return ` ${a.name}: ${R(g)},`;
|
|
898
963
|
}).join(`
|
|
899
|
-
`),
|
|
900
|
-
const
|
|
964
|
+
`), m = e.views.map((a) => {
|
|
965
|
+
const h = D(a, e).map((y) => ` ${y.name}: resolveColumnKey(columns, fieldsForView.${a.name}.${y.name}),`).join(`
|
|
901
966
|
`);
|
|
902
|
-
return ` ${
|
|
967
|
+
return ` ${a.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${a.name}, string | undefined> {
|
|
903
968
|
return {
|
|
904
|
-
${
|
|
969
|
+
${h}
|
|
905
970
|
};
|
|
906
971
|
},`;
|
|
907
972
|
}).join(`
|
|
908
973
|
|
|
909
|
-
`),
|
|
910
|
-
const
|
|
974
|
+
`), c = e.views.map((a) => {
|
|
975
|
+
const h = D(a, e).map((y) => ` ${y.name}: readCell(row, columns, fieldsForView.${a.name}.${y.name}),`).join(`
|
|
911
976
|
`);
|
|
912
|
-
return ` ${
|
|
977
|
+
return ` ${a.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${a.name}, unknown> {
|
|
913
978
|
return {
|
|
914
|
-
${
|
|
979
|
+
${h}
|
|
915
980
|
};
|
|
916
981
|
},`;
|
|
917
982
|
}).join(`
|
|
918
983
|
|
|
919
|
-
`),
|
|
920
|
-
return (result?.records || []).map((row) => rowValuesForView.${
|
|
984
|
+
`), N = e.views.map((a) => ` ${a.name}(result: SemaphorGeneratedRecordsResult): Array<Record<keyof typeof fieldsForView.${a.name}, unknown>> {
|
|
985
|
+
return (result?.records || []).map((row) => rowValuesForView.${a.name}(row, result?.columns));
|
|
921
986
|
},`).join(`
|
|
922
987
|
|
|
923
|
-
`),
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
988
|
+
`), u = e.views.map((a) => {
|
|
989
|
+
const g = D(a, e), h = g.filter((S) => S.raw.role === "dimension"), y = g.filter((S) => S.raw.role === "measure"), I = h[0], V = h[1], b = y[0], M = y[1], s = [
|
|
990
|
+
I ? ` primaryDimension: values.${I.name},` : " primaryDimension: undefined,",
|
|
991
|
+
V ? ` secondaryDimension: values.${V.name},` : " secondaryDimension: undefined,",
|
|
992
|
+
b ? ` primaryMeasure: values.${b.name},` : " primaryMeasure: undefined,",
|
|
993
|
+
M ? ` secondaryMeasure: values.${M.name},` : " secondaryMeasure: undefined,"
|
|
929
994
|
].join(`
|
|
930
995
|
`);
|
|
931
|
-
return ` ${
|
|
932
|
-
const values = rowValuesForView.${
|
|
996
|
+
return ` ${a.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): SemaphorGeneratedRoleValues {
|
|
997
|
+
const values = rowValuesForView.${a.name}(row, columns);
|
|
933
998
|
return {
|
|
934
|
-
${
|
|
999
|
+
${s}
|
|
935
1000
|
};
|
|
936
1001
|
},`;
|
|
937
1002
|
}).join(`
|
|
938
1003
|
|
|
939
|
-
`),
|
|
1004
|
+
`), d = r.includes("fields.") || n.includes("fields."), $ = [
|
|
940
1005
|
`import { ${[
|
|
941
1006
|
"type SemaphorFieldRef",
|
|
942
|
-
"type SemaphorResultColumn"
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
].filter(K).join(`
|
|
1007
|
+
"type SemaphorResultColumn"
|
|
1008
|
+
].filter(v).join(", ")} } from "react-semaphor/data-app-sdk";`,
|
|
1009
|
+
d ? 'import { fields } from "./fields";' : void 0
|
|
1010
|
+
].filter(v).join(`
|
|
947
1011
|
`);
|
|
948
|
-
return `${
|
|
949
|
-
${
|
|
1012
|
+
return `${A}
|
|
1013
|
+
${$}
|
|
950
1014
|
|
|
951
1015
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
952
1016
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
@@ -956,12 +1020,17 @@ export type SemaphorGeneratedRecordsResult = {
|
|
|
956
1020
|
} | null | undefined;
|
|
957
1021
|
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
958
1022
|
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
1023
|
+
export type SemaphorGeneratedMetricValue = number | string | null;
|
|
959
1024
|
export type SemaphorGeneratedMetricResult = {
|
|
960
1025
|
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
961
1026
|
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
962
1027
|
readonly missingMeasures?: readonly string[];
|
|
963
1028
|
readonly primaryValue: unknown;
|
|
964
1029
|
readonly value?: unknown;
|
|
1030
|
+
readonly comparisonKind?: string;
|
|
1031
|
+
readonly comparisonValue?: unknown;
|
|
1032
|
+
readonly delta?: number | null;
|
|
1033
|
+
readonly deltaPercent?: number | null;
|
|
965
1034
|
} | null | undefined;
|
|
966
1035
|
export type SemaphorGeneratedRoleValues = {
|
|
967
1036
|
readonly primaryDimension: unknown;
|
|
@@ -976,13 +1045,36 @@ export type SemaphorGeneratedTableColumn = {
|
|
|
976
1045
|
readonly sortable?: boolean;
|
|
977
1046
|
readonly sortKey?: string;
|
|
978
1047
|
};
|
|
1048
|
+
export type SemaphorGeneratedKpiResult<TValues extends Record<string, SemaphorGeneratedMetricValue> = Record<string, SemaphorGeneratedMetricValue>> =
|
|
1049
|
+
Record<string, unknown> & {
|
|
1050
|
+
readonly value?: SemaphorGeneratedMetricValue;
|
|
1051
|
+
readonly primaryValue?: SemaphorGeneratedMetricValue;
|
|
1052
|
+
readonly comparisonValue?: SemaphorGeneratedMetricValue;
|
|
1053
|
+
readonly comparisonKind?: string;
|
|
1054
|
+
readonly delta?: number | null;
|
|
1055
|
+
readonly deltaPercent?: number | null;
|
|
1056
|
+
readonly measures: TValues;
|
|
1057
|
+
};
|
|
1058
|
+
export type SemaphorGeneratedKpiMeasureConfig = {
|
|
1059
|
+
key: string;
|
|
1060
|
+
label: string;
|
|
1061
|
+
};
|
|
1062
|
+
export type SemaphorGeneratedKpiProps = {
|
|
1063
|
+
readonly result: SemaphorGeneratedKpiResult;
|
|
1064
|
+
readonly title: string;
|
|
1065
|
+
readonly label: string;
|
|
1066
|
+
readonly value: SemaphorGeneratedMetricValue;
|
|
1067
|
+
readonly measures: SemaphorGeneratedKpiMeasureConfig[];
|
|
1068
|
+
readonly missingMeasures: readonly string[];
|
|
1069
|
+
readonly showComparison: boolean;
|
|
1070
|
+
};
|
|
979
1071
|
|
|
980
1072
|
export const fieldsForView = {
|
|
981
|
-
${
|
|
1073
|
+
${r}
|
|
982
1074
|
} as const;
|
|
983
1075
|
|
|
984
1076
|
export const metricFieldsForView = {
|
|
985
|
-
${
|
|
1077
|
+
${n}
|
|
986
1078
|
} as const;
|
|
987
1079
|
|
|
988
1080
|
export const metricMeasureKeysForView = {
|
|
@@ -994,33 +1086,37 @@ ${o}
|
|
|
994
1086
|
} as const;
|
|
995
1087
|
|
|
996
1088
|
export const tableColumnsForView = {
|
|
997
|
-
${
|
|
1089
|
+
${F}
|
|
998
1090
|
} as const;
|
|
999
1091
|
|
|
1000
1092
|
export const columnKeysForView = {
|
|
1001
|
-
${
|
|
1093
|
+
${m}
|
|
1002
1094
|
} as const;
|
|
1003
1095
|
|
|
1004
1096
|
export const rowValuesForView = {
|
|
1005
|
-
${
|
|
1097
|
+
${c}
|
|
1006
1098
|
} as const;
|
|
1007
1099
|
|
|
1008
1100
|
export const rowsForView = {
|
|
1009
|
-
${
|
|
1101
|
+
${N}
|
|
1010
1102
|
} as const;
|
|
1011
1103
|
|
|
1012
1104
|
export const roleValuesForView = {
|
|
1013
|
-
${
|
|
1105
|
+
${u}
|
|
1014
1106
|
} as const;
|
|
1015
1107
|
|
|
1016
1108
|
export const metricValuesForView = {
|
|
1017
|
-
${
|
|
1109
|
+
${i}
|
|
1018
1110
|
} as const;
|
|
1019
1111
|
|
|
1020
1112
|
export const missingMetricMeasuresForView = {
|
|
1021
1113
|
${l}
|
|
1022
1114
|
} as const;
|
|
1023
1115
|
|
|
1116
|
+
export const kpiPropsForView = {
|
|
1117
|
+
${f}
|
|
1118
|
+
} as const;
|
|
1119
|
+
|
|
1024
1120
|
export function resolveColumnKey(
|
|
1025
1121
|
columns: SemaphorGeneratedColumns,
|
|
1026
1122
|
field: SemaphorFieldRef,
|
|
@@ -1140,6 +1236,26 @@ export function readStringMetricValue(
|
|
|
1140
1236
|
return value === null || value === undefined ? "" : String(value);
|
|
1141
1237
|
}
|
|
1142
1238
|
|
|
1239
|
+
export function mapMetricDisplayValues(
|
|
1240
|
+
values: Record<string, unknown>,
|
|
1241
|
+
): Record<string, SemaphorGeneratedMetricValue> {
|
|
1242
|
+
return Object.fromEntries(
|
|
1243
|
+
Object.entries(values)
|
|
1244
|
+
.map(([key, value]) => [key, metricDisplayValue(value)] as const)
|
|
1245
|
+
.filter(([key]) => values[key] !== undefined),
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
export function metricDisplayValue(value: unknown): SemaphorGeneratedMetricValue {
|
|
1250
|
+
if (value === null || value === undefined) {
|
|
1251
|
+
return null;
|
|
1252
|
+
}
|
|
1253
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
1254
|
+
return value;
|
|
1255
|
+
}
|
|
1256
|
+
return String(value);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1143
1259
|
export function metricKeysForField(
|
|
1144
1260
|
field: SemaphorFieldRef,
|
|
1145
1261
|
options: { allowNameFallback?: boolean; excludedKeys?: readonly string[] } = {},
|
|
@@ -1159,11 +1275,15 @@ export function metricKeysForField(
|
|
|
1159
1275
|
}
|
|
1160
1276
|
|
|
1161
1277
|
function metricQualifiedKeyForField(field: SemaphorFieldRef): string {
|
|
1162
|
-
return
|
|
1278
|
+
return [
|
|
1279
|
+
field.source ? sourceIdentityKey(field.source as Record<string, unknown>) : "unknown",
|
|
1280
|
+
metricAggregateForField(field),
|
|
1281
|
+
field.name,
|
|
1282
|
+
].filter(Boolean).join(":");
|
|
1163
1283
|
}
|
|
1164
1284
|
|
|
1165
1285
|
function metricAggregateForField(field: SemaphorFieldRef): string {
|
|
1166
|
-
return
|
|
1286
|
+
return (field.aggregate || "SUM").toUpperCase();
|
|
1167
1287
|
}
|
|
1168
1288
|
|
|
1169
1289
|
function metricKeyPrefixesForSource(
|
|
@@ -1204,6 +1324,35 @@ function metricKeyPrefixesForSource(
|
|
|
1204
1324
|
return [];
|
|
1205
1325
|
}
|
|
1206
1326
|
|
|
1327
|
+
function sourceIdentityKey(source: Record<string, unknown>): string {
|
|
1328
|
+
const kind = stringProperty(source, "kind");
|
|
1329
|
+
if (kind === "semantic") {
|
|
1330
|
+
const datasetId = stringProperty(source, "datasetId");
|
|
1331
|
+
return [
|
|
1332
|
+
kind,
|
|
1333
|
+
stringProperty(source, "domainId") || "",
|
|
1334
|
+
datasetId
|
|
1335
|
+
? \`datasetId:\${datasetId}\`
|
|
1336
|
+
: \`datasetName:\${stringProperty(source, "datasetName") || ""}\`,
|
|
1337
|
+
].join(":");
|
|
1338
|
+
}
|
|
1339
|
+
if (kind === "physical") {
|
|
1340
|
+
return [
|
|
1341
|
+
kind,
|
|
1342
|
+
stringProperty(source, "connectionId") || "",
|
|
1343
|
+
stringProperty(source, "databaseName") || "",
|
|
1344
|
+
stringProperty(source, "schemaName") || "",
|
|
1345
|
+
stringProperty(source, "tableName") || "",
|
|
1346
|
+
].join(":");
|
|
1347
|
+
}
|
|
1348
|
+
return [
|
|
1349
|
+
kind || "unknown",
|
|
1350
|
+
stringProperty(source, "connectionId") || "",
|
|
1351
|
+
stringProperty(source, "dialect") || "",
|
|
1352
|
+
stringProperty(source, "label") || "",
|
|
1353
|
+
].join(":");
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1207
1356
|
function stringProperty(record: Record<string, unknown>, key: string): string | undefined {
|
|
1208
1357
|
const value = record[key];
|
|
1209
1358
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -1317,13 +1466,13 @@ function sourcesReferToSameDataset(
|
|
|
1317
1466
|
}
|
|
1318
1467
|
`;
|
|
1319
1468
|
}
|
|
1320
|
-
function
|
|
1321
|
-
const
|
|
1322
|
-
(
|
|
1469
|
+
function Ze(e, r) {
|
|
1470
|
+
const n = D(e, r), t = new Map(
|
|
1471
|
+
(K(e) ? Y(e, r) : []).map((o) => [o.fieldName, o.key])
|
|
1323
1472
|
);
|
|
1324
|
-
return
|
|
1325
|
-
const
|
|
1326
|
-
return
|
|
1473
|
+
return n.map((o) => {
|
|
1474
|
+
const i = x(o.raw, r), l = i ? t.get(i) : void 0;
|
|
1475
|
+
return O({
|
|
1327
1476
|
key: o.name,
|
|
1328
1477
|
label: o.raw.label || o.raw.name,
|
|
1329
1478
|
dataType: o.raw.dataType,
|
|
@@ -1332,13 +1481,13 @@ function Ye(e, n) {
|
|
|
1332
1481
|
});
|
|
1333
1482
|
});
|
|
1334
1483
|
}
|
|
1335
|
-
function
|
|
1336
|
-
const
|
|
1484
|
+
function Xe(e) {
|
|
1485
|
+
const r = e.checklist.filterScopeByInput || [], n = e.checklist.requiredDevtools || {}, t = e.summary.views.map((u) => u.id).filter(Boolean), o = e.views.map((u) => u.raw.id).filter(Boolean), i = e.inputs.map((u) => u.raw.id).filter(Boolean), l = e.optionQueries.map((u) => u.raw.id || `${u.input.raw.id}-options`).filter(Boolean), f = Object.fromEntries(o.map((u) => [
|
|
1337
1486
|
u,
|
|
1338
1487
|
e.filterContracts.filter(
|
|
1339
1488
|
(d) => Array.isArray(d.appliesToViewIds) && d.appliesToViewIds.includes(u)
|
|
1340
1489
|
).map((d) => d.inputId)
|
|
1341
|
-
])),
|
|
1490
|
+
])), F = Object.fromEntries(e.views.map((u) => [
|
|
1342
1491
|
u.raw.id,
|
|
1343
1492
|
{
|
|
1344
1493
|
title: u.raw.title,
|
|
@@ -1347,11 +1496,11 @@ function We(e) {
|
|
|
1347
1496
|
queryKind: u.raw.queryKind,
|
|
1348
1497
|
sdkBuilder: u.raw.sdkBuilder
|
|
1349
1498
|
}
|
|
1350
|
-
])),
|
|
1499
|
+
])), m = Object.fromEntries(e.views.map((u) => {
|
|
1351
1500
|
var d;
|
|
1352
1501
|
return [
|
|
1353
1502
|
u.raw.id,
|
|
1354
|
-
|
|
1503
|
+
O({
|
|
1355
1504
|
viewId: u.raw.id,
|
|
1356
1505
|
queryId: u.name,
|
|
1357
1506
|
title: u.raw.title,
|
|
@@ -1363,11 +1512,11 @@ function We(e) {
|
|
|
1363
1512
|
}
|
|
1364
1513
|
})
|
|
1365
1514
|
];
|
|
1366
|
-
})),
|
|
1515
|
+
})), c = Object.fromEntries(e.inputs.map((u) => {
|
|
1367
1516
|
var d;
|
|
1368
1517
|
return [
|
|
1369
1518
|
u.raw.id,
|
|
1370
|
-
|
|
1519
|
+
O({
|
|
1371
1520
|
inputId: u.raw.id,
|
|
1372
1521
|
label: u.raw.label,
|
|
1373
1522
|
type: u.raw.type,
|
|
@@ -1380,24 +1529,24 @@ function We(e) {
|
|
|
1380
1529
|
})
|
|
1381
1530
|
];
|
|
1382
1531
|
})), N = Object.fromEntries(e.views.map((u) => {
|
|
1383
|
-
var d,
|
|
1532
|
+
var d, p, $;
|
|
1384
1533
|
return [
|
|
1385
1534
|
u.name,
|
|
1386
|
-
|
|
1535
|
+
O({
|
|
1387
1536
|
viewId: u.raw.id,
|
|
1388
1537
|
viewTitle: ((d = u.raw.visualSpec) == null ? void 0 : d.title) || u.raw.title,
|
|
1389
|
-
visualType: (
|
|
1390
|
-
title: ((
|
|
1538
|
+
visualType: (p = u.raw.visualSpec) == null ? void 0 : p.visualType,
|
|
1539
|
+
title: (($ = u.raw.visualSpec) == null ? void 0 : $.title) || u.raw.title
|
|
1391
1540
|
})
|
|
1392
1541
|
];
|
|
1393
1542
|
}));
|
|
1394
|
-
return `${
|
|
1395
|
-
export const generatedViewIds = ${
|
|
1396
|
-
export const generatedQueryViewIds = ${
|
|
1397
|
-
export const generatedInputIds = ${
|
|
1398
|
-
export const generatedInputOptionQueryIds = ${
|
|
1399
|
-
export const generatedViewAuthoring = ${
|
|
1400
|
-
export const generatedInputAuthoring = ${
|
|
1543
|
+
return `${A}
|
|
1544
|
+
export const generatedViewIds = ${R(t)} as const;
|
|
1545
|
+
export const generatedQueryViewIds = ${R(o)} as const;
|
|
1546
|
+
export const generatedInputIds = ${R(i)} as const;
|
|
1547
|
+
export const generatedInputOptionQueryIds = ${R(l)} as const;
|
|
1548
|
+
export const generatedViewAuthoring = ${R(m)} as const;
|
|
1549
|
+
export const generatedInputAuthoring = ${R(c)} as const;
|
|
1401
1550
|
|
|
1402
1551
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
1403
1552
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -1416,8 +1565,8 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
1416
1565
|
readonly [key: string]: unknown;
|
|
1417
1566
|
};
|
|
1418
1567
|
|
|
1419
|
-
export const generatedInputIdsForView = ${
|
|
1420
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${
|
|
1568
|
+
export const generatedInputIdsForView = ${R(f)} as const;
|
|
1569
|
+
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${R(e.filterContracts)} as const;
|
|
1421
1570
|
|
|
1422
1571
|
export function semaphorViewMarkerProps(viewId: SemaphorGeneratedViewId) {
|
|
1423
1572
|
return {
|
|
@@ -1437,28 +1586,28 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
1437
1586
|
);
|
|
1438
1587
|
}
|
|
1439
1588
|
|
|
1440
|
-
export const queryDebugForView = ${
|
|
1589
|
+
export const queryDebugForView = ${R(N)} as const;
|
|
1441
1590
|
|
|
1442
|
-
export const semaphorGeneratedContractMetadata = ${
|
|
1591
|
+
export const semaphorGeneratedContractMetadata = ${R({
|
|
1443
1592
|
schemaVersion: "semaphor-generated-data-app-contract/v1",
|
|
1444
1593
|
title: e.title,
|
|
1445
|
-
requiredDevtools:
|
|
1594
|
+
requiredDevtools: n,
|
|
1446
1595
|
filterContracts: e.filterContracts,
|
|
1447
|
-
filterScopeByInput:
|
|
1596
|
+
filterScopeByInput: r,
|
|
1448
1597
|
generatedViewIds: t,
|
|
1449
1598
|
generatedQueryViewIds: o,
|
|
1450
|
-
generatedInputIds:
|
|
1599
|
+
generatedInputIds: i,
|
|
1451
1600
|
generatedInputOptionQueryIds: l,
|
|
1452
|
-
generatedInputIdsForView:
|
|
1453
|
-
generatedViewAuthoring:
|
|
1454
|
-
generatedInputAuthoring:
|
|
1455
|
-
visualSpecs:
|
|
1601
|
+
generatedInputIdsForView: f,
|
|
1602
|
+
generatedViewAuthoring: m,
|
|
1603
|
+
generatedInputAuthoring: c,
|
|
1604
|
+
visualSpecs: F,
|
|
1456
1605
|
presentationViews: e.presentationViews
|
|
1457
1606
|
})} as const;
|
|
1458
1607
|
`;
|
|
1459
1608
|
}
|
|
1460
|
-
function
|
|
1461
|
-
return `${
|
|
1609
|
+
function er() {
|
|
1610
|
+
return `${A}
|
|
1462
1611
|
export * from "./sources";
|
|
1463
1612
|
export * from "./fields";
|
|
1464
1613
|
export * from "./inputs";
|
|
@@ -1468,143 +1617,143 @@ export * from "./accessors";
|
|
|
1468
1617
|
export * from "./metadata";
|
|
1469
1618
|
`;
|
|
1470
1619
|
}
|
|
1471
|
-
function Q(e,
|
|
1472
|
-
if (!(!
|
|
1473
|
-
if (Array.isArray(
|
|
1474
|
-
for (const
|
|
1620
|
+
function Q(e, r) {
|
|
1621
|
+
if (!(!r || typeof r != "object")) {
|
|
1622
|
+
if (Array.isArray(r)) {
|
|
1623
|
+
for (const n of r) Q(e, n);
|
|
1475
1624
|
return;
|
|
1476
1625
|
}
|
|
1477
|
-
C(
|
|
1478
|
-
for (const
|
|
1479
|
-
Q(e,
|
|
1626
|
+
C(r) && w(e, U(r));
|
|
1627
|
+
for (const n of Object.values(r))
|
|
1628
|
+
Q(e, n);
|
|
1480
1629
|
}
|
|
1481
1630
|
}
|
|
1482
|
-
function D(e,
|
|
1483
|
-
const
|
|
1484
|
-
if (
|
|
1631
|
+
function D(e, r) {
|
|
1632
|
+
const n = [];
|
|
1633
|
+
if (sr(n, e.raw.sdkSpec), n.length === 0)
|
|
1485
1634
|
for (const o of e.raw.fields || [])
|
|
1486
|
-
|
|
1635
|
+
w(n, o);
|
|
1487
1636
|
const t = X(
|
|
1488
|
-
|
|
1637
|
+
n.filter((o) => o.name && x(o, r)).map((o) => ({ raw: o, key: J(o), name: "" })),
|
|
1489
1638
|
(o) => o.key
|
|
1490
1639
|
);
|
|
1491
|
-
return
|
|
1640
|
+
return j(
|
|
1492
1641
|
t,
|
|
1493
1642
|
(o) => q(o.raw.label || o.raw.name || "field")
|
|
1494
1643
|
), t;
|
|
1495
1644
|
}
|
|
1496
|
-
function
|
|
1645
|
+
function T(e, r) {
|
|
1497
1646
|
if (B(e.raw.sdkSpec.builder) !== "metric")
|
|
1498
1647
|
return [];
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1501
|
-
for (const
|
|
1502
|
-
|
|
1648
|
+
const n = k(e.raw.sdkSpec.spec), t = [];
|
|
1649
|
+
w(t, n == null ? void 0 : n.primaryMeasure);
|
|
1650
|
+
for (const i of H(n == null ? void 0 : n.measures))
|
|
1651
|
+
w(t, i);
|
|
1503
1652
|
const o = X(
|
|
1504
|
-
t.filter((
|
|
1505
|
-
(
|
|
1653
|
+
t.filter((i) => i.name && x(i, r)).map((i) => ({ raw: i, key: J(i), name: "" })),
|
|
1654
|
+
(i) => i.key
|
|
1506
1655
|
);
|
|
1507
|
-
return
|
|
1656
|
+
return j(
|
|
1508
1657
|
o,
|
|
1509
|
-
(
|
|
1658
|
+
(i) => q(i.raw.label || i.raw.name || "metric")
|
|
1510
1659
|
), o;
|
|
1511
1660
|
}
|
|
1512
|
-
function
|
|
1661
|
+
function rr(e, r, n) {
|
|
1513
1662
|
var o;
|
|
1514
|
-
const t = (o = e.raw.metricBindingKeys) == null ? void 0 : o[
|
|
1663
|
+
const t = (o = e.raw.metricBindingKeys) == null ? void 0 : o[n];
|
|
1515
1664
|
if (typeof t == "string" && t.trim())
|
|
1516
1665
|
return t;
|
|
1517
1666
|
throw new Error(
|
|
1518
|
-
`views.${e.raw.id}.metricBindingKeys must include a binding key for metric field ${
|
|
1667
|
+
`views.${e.raw.id}.metricBindingKeys must include a binding key for metric field ${r.raw.name}.`
|
|
1519
1668
|
);
|
|
1520
1669
|
}
|
|
1521
|
-
function
|
|
1522
|
-
if (
|
|
1523
|
-
return /* @__PURE__ */ new Set([
|
|
1524
|
-
const
|
|
1525
|
-
if (!C(
|
|
1670
|
+
function nr(e, r) {
|
|
1671
|
+
if (r.length === 1)
|
|
1672
|
+
return /* @__PURE__ */ new Set([r[0].name]);
|
|
1673
|
+
const n = k(e.raw.sdkSpec.spec);
|
|
1674
|
+
if (!C(n == null ? void 0 : n.primaryMeasure))
|
|
1526
1675
|
return /* @__PURE__ */ new Set();
|
|
1527
|
-
const t =
|
|
1676
|
+
const t = J(U(n.primaryMeasure)), o = r.find((i) => i.key === t);
|
|
1528
1677
|
return o ? /* @__PURE__ */ new Set([o.name]) : /* @__PURE__ */ new Set();
|
|
1529
1678
|
}
|
|
1530
|
-
function
|
|
1531
|
-
const
|
|
1532
|
-
for (const
|
|
1533
|
-
for (const t of new Set(he(
|
|
1534
|
-
|
|
1679
|
+
function tr(e) {
|
|
1680
|
+
const r = /* @__PURE__ */ new Map();
|
|
1681
|
+
for (const n of e)
|
|
1682
|
+
for (const t of new Set(he(n.raw)))
|
|
1683
|
+
r.set(t, (r.get(t) || 0) + 1);
|
|
1535
1684
|
return new Set(
|
|
1536
|
-
Array.from(
|
|
1685
|
+
Array.from(r.entries()).filter(([, n]) => n > 1).map(([n]) => n)
|
|
1537
1686
|
);
|
|
1538
1687
|
}
|
|
1539
1688
|
function he(e) {
|
|
1540
|
-
const
|
|
1689
|
+
const r = ke(e);
|
|
1541
1690
|
return _([
|
|
1542
|
-
`${
|
|
1543
|
-
`${
|
|
1544
|
-
`${e.name}_${
|
|
1545
|
-
`${e.name}_${
|
|
1691
|
+
`${r.toLowerCase()}_${e.name}`,
|
|
1692
|
+
`${r}_${e.name}`,
|
|
1693
|
+
`${e.name}_${r.toLowerCase()}`,
|
|
1694
|
+
`${e.name}_${r}`,
|
|
1546
1695
|
e.name
|
|
1547
1696
|
]);
|
|
1548
1697
|
}
|
|
1549
|
-
function
|
|
1550
|
-
const
|
|
1551
|
-
for (const
|
|
1552
|
-
|
|
1698
|
+
function or(e) {
|
|
1699
|
+
const r = /* @__PURE__ */ new Map();
|
|
1700
|
+
for (const n of e)
|
|
1701
|
+
r.set(n.raw.name, (r.get(n.raw.name) || 0) + 1);
|
|
1553
1702
|
return new Set(
|
|
1554
|
-
Array.from(
|
|
1703
|
+
Array.from(r.entries()).filter(([, n]) => n > 1).map(([n]) => n)
|
|
1555
1704
|
);
|
|
1556
1705
|
}
|
|
1557
|
-
function
|
|
1558
|
-
const
|
|
1559
|
-
if (!
|
|
1706
|
+
function sr(e, r) {
|
|
1707
|
+
const n = k(r.spec);
|
|
1708
|
+
if (!n)
|
|
1560
1709
|
return;
|
|
1561
|
-
const t = B(
|
|
1710
|
+
const t = B(r.builder);
|
|
1562
1711
|
if (t === "records") {
|
|
1563
|
-
for (const o of
|
|
1712
|
+
for (const o of H(n.fields)) w(e, o);
|
|
1564
1713
|
return;
|
|
1565
1714
|
}
|
|
1566
1715
|
if (t === "sql") {
|
|
1567
|
-
for (const o of
|
|
1716
|
+
for (const o of H(n.fields)) w(e, o);
|
|
1568
1717
|
return;
|
|
1569
1718
|
}
|
|
1570
1719
|
if (t === "analysis" || t === "metric") {
|
|
1571
|
-
|
|
1572
|
-
for (const o of
|
|
1573
|
-
for (const o of
|
|
1574
|
-
|
|
1720
|
+
w(e, n.primaryMeasure);
|
|
1721
|
+
for (const o of H(n.measures)) w(e, o);
|
|
1722
|
+
for (const o of H(n.dimensions)) w(e, o);
|
|
1723
|
+
w(e, n.dateField);
|
|
1575
1724
|
return;
|
|
1576
1725
|
}
|
|
1577
1726
|
if (t === "matrix") {
|
|
1578
|
-
const o =
|
|
1579
|
-
for (const
|
|
1580
|
-
for (const
|
|
1581
|
-
for (const
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1727
|
+
const o = le(n.rows), i = le(n.columns), l = H(n.values);
|
|
1728
|
+
for (const f of o) pe(e, f);
|
|
1729
|
+
for (const f of i) pe(e, f);
|
|
1730
|
+
for (const f of l) {
|
|
1731
|
+
const F = k(f);
|
|
1732
|
+
w(e, F == null ? void 0 : F.field), w(e, F == null ? void 0 : F.measure);
|
|
1584
1733
|
}
|
|
1585
1734
|
}
|
|
1586
1735
|
}
|
|
1587
|
-
function
|
|
1736
|
+
function le(e) {
|
|
1588
1737
|
if (Array.isArray(e))
|
|
1589
1738
|
return e;
|
|
1590
|
-
const
|
|
1591
|
-
return Array.isArray(
|
|
1739
|
+
const r = k(e);
|
|
1740
|
+
return Array.isArray(r == null ? void 0 : r.levels) ? r.levels : [];
|
|
1592
1741
|
}
|
|
1593
|
-
function
|
|
1594
|
-
var
|
|
1595
|
-
if (C(
|
|
1596
|
-
|
|
1742
|
+
function pe(e, r) {
|
|
1743
|
+
var n;
|
|
1744
|
+
if (C(r)) {
|
|
1745
|
+
w(e, r);
|
|
1597
1746
|
return;
|
|
1598
1747
|
}
|
|
1599
|
-
|
|
1748
|
+
w(e, (n = k(r)) == null ? void 0 : n.field);
|
|
1600
1749
|
}
|
|
1601
1750
|
function ce(e) {
|
|
1602
|
-
var
|
|
1603
|
-
return ((
|
|
1751
|
+
var r, n, t, o;
|
|
1752
|
+
return ((r = e == null ? void 0 : e.computation) == null ? void 0 : r.kind) === "presentation_only" || ((n = e == null ? void 0 : e.computation) == null ? void 0 : n.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";
|
|
1604
1753
|
}
|
|
1605
|
-
function
|
|
1606
|
-
const
|
|
1607
|
-
return
|
|
1754
|
+
function ar(e) {
|
|
1755
|
+
const r = k(e) || {};
|
|
1756
|
+
return O({
|
|
1608
1757
|
id: e.id,
|
|
1609
1758
|
title: e.title,
|
|
1610
1759
|
purpose: e.purpose,
|
|
@@ -1613,13 +1762,13 @@ function on(e) {
|
|
|
1613
1762
|
computation: e.computation,
|
|
1614
1763
|
uxExpectations: e.uxExpectations,
|
|
1615
1764
|
validation: e.validation,
|
|
1616
|
-
sourceViewIds:
|
|
1617
|
-
content:
|
|
1618
|
-
description:
|
|
1765
|
+
sourceViewIds: r.sourceViewIds,
|
|
1766
|
+
content: r.content,
|
|
1767
|
+
description: r.description
|
|
1619
1768
|
});
|
|
1620
1769
|
}
|
|
1621
|
-
function
|
|
1622
|
-
C(
|
|
1770
|
+
function w(e, r) {
|
|
1771
|
+
C(r) && e.push(U(r));
|
|
1623
1772
|
}
|
|
1624
1773
|
function U(e) {
|
|
1625
1774
|
return {
|
|
@@ -1632,63 +1781,63 @@ function U(e) {
|
|
|
1632
1781
|
...e.source ? { source: e.source } : {}
|
|
1633
1782
|
};
|
|
1634
1783
|
}
|
|
1635
|
-
function
|
|
1784
|
+
function ir(e) {
|
|
1636
1785
|
if (!e.source)
|
|
1637
1786
|
return;
|
|
1638
|
-
const
|
|
1787
|
+
const r = {
|
|
1639
1788
|
...e.source,
|
|
1640
1789
|
...e.sourceKey ? { sourceKey: e.sourceKey } : {}
|
|
1641
|
-
},
|
|
1642
|
-
if (
|
|
1790
|
+
}, n = $e(r);
|
|
1791
|
+
if (n)
|
|
1643
1792
|
return {
|
|
1644
|
-
raw:
|
|
1645
|
-
key:
|
|
1646
|
-
aliases: Ie(
|
|
1793
|
+
raw: r,
|
|
1794
|
+
key: n,
|
|
1795
|
+
aliases: Ie(r),
|
|
1647
1796
|
name: ""
|
|
1648
1797
|
};
|
|
1649
1798
|
}
|
|
1650
1799
|
function C(e) {
|
|
1651
|
-
const
|
|
1652
|
-
return !!(
|
|
1800
|
+
const r = k(e);
|
|
1801
|
+
return !!(r && typeof r.name == "string" && (typeof r.role == "string" || typeof r.dataType == "string" || typeof r.aggregate == "string" || r.source || r.sourceKey));
|
|
1653
1802
|
}
|
|
1654
1803
|
function we(e) {
|
|
1655
|
-
const
|
|
1656
|
-
return !!(
|
|
1804
|
+
const r = k(e);
|
|
1805
|
+
return !!(r && (typeof r.sourceKey == "string" || r.kind === "semantic" || typeof r.datasetName == "string" && typeof r.domainId == "string"));
|
|
1657
1806
|
}
|
|
1658
|
-
function
|
|
1807
|
+
function G(e, r) {
|
|
1659
1808
|
if (e === void 0)
|
|
1660
1809
|
return "undefined";
|
|
1661
1810
|
if (e === null || typeof e == "number" || typeof e == "boolean" || typeof e == "string")
|
|
1662
1811
|
return JSON.stringify(e);
|
|
1663
1812
|
if (Array.isArray(e))
|
|
1664
|
-
return `[${e.map((o) =>
|
|
1813
|
+
return `[${e.map((o) => G(o, r)).join(", ")}]`;
|
|
1665
1814
|
if (C(e)) {
|
|
1666
|
-
const o = x(U(e),
|
|
1815
|
+
const o = x(U(e), r);
|
|
1667
1816
|
if (o) return `fields.${o}`;
|
|
1668
1817
|
}
|
|
1669
1818
|
if (we(e)) {
|
|
1670
|
-
const o = Se(e,
|
|
1819
|
+
const o = Se(e, r);
|
|
1671
1820
|
if (o) return `sources.${o}`;
|
|
1672
1821
|
}
|
|
1673
|
-
const
|
|
1674
|
-
return
|
|
1822
|
+
const n = k(e);
|
|
1823
|
+
return n ? `{ ${Object.entries(n).filter(([, o]) => o !== void 0).map(([o, i]) => `${JSON.stringify(o)}: ${G(i, r)}`).join(", ")} }` : JSON.stringify(e);
|
|
1675
1824
|
}
|
|
1676
|
-
function
|
|
1825
|
+
function R(e) {
|
|
1677
1826
|
return JSON.stringify(e, null, 2);
|
|
1678
1827
|
}
|
|
1679
|
-
function x(e,
|
|
1828
|
+
function x(e, r) {
|
|
1680
1829
|
if (C(e))
|
|
1681
|
-
return
|
|
1830
|
+
return r.fieldNameByKey.get(J(U(e)));
|
|
1682
1831
|
}
|
|
1683
|
-
function Se(e,
|
|
1832
|
+
function Se(e, r) {
|
|
1684
1833
|
if (we(e))
|
|
1685
|
-
for (const
|
|
1686
|
-
const t =
|
|
1834
|
+
for (const n of Z(e)) {
|
|
1835
|
+
const t = r.sourceNameByKey.get(n);
|
|
1687
1836
|
if (t)
|
|
1688
1837
|
return t;
|
|
1689
1838
|
}
|
|
1690
1839
|
}
|
|
1691
|
-
function
|
|
1840
|
+
function J(e) {
|
|
1692
1841
|
return [
|
|
1693
1842
|
e.sourceKey || "",
|
|
1694
1843
|
e.name || "",
|
|
@@ -1696,38 +1845,38 @@ function L(e) {
|
|
|
1696
1845
|
e.aggregate || ""
|
|
1697
1846
|
].join("|");
|
|
1698
1847
|
}
|
|
1699
|
-
function
|
|
1700
|
-
return !C(e) || !C(
|
|
1701
|
-
(
|
|
1848
|
+
function ur(e, r) {
|
|
1849
|
+
return !C(e) || !C(r) || e.name !== r.name ? !1 : ie(e).some(
|
|
1850
|
+
(n) => ie(r).includes(n)
|
|
1702
1851
|
);
|
|
1703
1852
|
}
|
|
1704
|
-
function
|
|
1853
|
+
function dr(e) {
|
|
1705
1854
|
return C(e) && e.role === "id";
|
|
1706
1855
|
}
|
|
1707
|
-
function
|
|
1708
|
-
const
|
|
1856
|
+
function lr(e) {
|
|
1857
|
+
const r = [], n = /* @__PURE__ */ new Map();
|
|
1709
1858
|
for (const t of e) {
|
|
1710
|
-
const o = _(t.aliases.length ? t.aliases : [t.key]),
|
|
1711
|
-
if (
|
|
1712
|
-
|
|
1859
|
+
const o = _(t.aliases.length ? t.aliases : [t.key]), i = o.map((l) => n.get(l)).find(v);
|
|
1860
|
+
if (i) {
|
|
1861
|
+
i.aliases = _([...i.aliases, ...o]);
|
|
1713
1862
|
continue;
|
|
1714
1863
|
}
|
|
1715
|
-
t.aliases = o,
|
|
1864
|
+
t.aliases = o, r.push(t);
|
|
1716
1865
|
for (const l of o)
|
|
1717
|
-
|
|
1866
|
+
n.set(l, t);
|
|
1718
1867
|
}
|
|
1719
|
-
return
|
|
1868
|
+
return r;
|
|
1720
1869
|
}
|
|
1721
|
-
function
|
|
1722
|
-
const
|
|
1723
|
-
for (const
|
|
1724
|
-
for (const t of _([
|
|
1725
|
-
const o =
|
|
1726
|
-
if (o && o !==
|
|
1870
|
+
function pr(e) {
|
|
1871
|
+
const r = /* @__PURE__ */ new Map();
|
|
1872
|
+
for (const n of e)
|
|
1873
|
+
for (const t of _([n.key, ...n.aliases])) {
|
|
1874
|
+
const o = r.get(t);
|
|
1875
|
+
if (o && o !== n.name)
|
|
1727
1876
|
throw new Error(`Source identity ${t} resolves to multiple generated sources.`);
|
|
1728
|
-
|
|
1877
|
+
r.set(t, n.name);
|
|
1729
1878
|
}
|
|
1730
|
-
return
|
|
1879
|
+
return r;
|
|
1731
1880
|
}
|
|
1732
1881
|
function _(e) {
|
|
1733
1882
|
return Array.from(new Set(e.filter(Boolean)));
|
|
@@ -1736,24 +1885,24 @@ function $e(e) {
|
|
|
1736
1885
|
return Z(e)[0] || de(e);
|
|
1737
1886
|
}
|
|
1738
1887
|
function Z(e) {
|
|
1739
|
-
const
|
|
1740
|
-
if (!
|
|
1888
|
+
const r = k(e);
|
|
1889
|
+
if (!r)
|
|
1741
1890
|
return [];
|
|
1742
|
-
const
|
|
1743
|
-
if (typeof
|
|
1744
|
-
const t = typeof
|
|
1745
|
-
t && typeof
|
|
1891
|
+
const n = [];
|
|
1892
|
+
if (typeof r.sourceKey == "string" && n.push(r.sourceKey), r.kind === "semantic" || r.datasetName) {
|
|
1893
|
+
const t = typeof r.domainId == "string" ? r.domainId : "";
|
|
1894
|
+
t && typeof r.datasetId == "string" && n.push(`semantic:${t}:datasetId:${r.datasetId}`), t && typeof r.datasetName == "string" && n.push(`semantic:${t}:datasetName:${r.datasetName}`);
|
|
1746
1895
|
}
|
|
1747
|
-
return
|
|
1896
|
+
return n.length === 0 && n.push(de(e)), _(n);
|
|
1748
1897
|
}
|
|
1749
1898
|
function Ie(e) {
|
|
1750
1899
|
return Z(e);
|
|
1751
1900
|
}
|
|
1752
1901
|
function de(e) {
|
|
1753
|
-
const
|
|
1754
|
-
return
|
|
1902
|
+
const r = k(e);
|
|
1903
|
+
return r ? typeof r.sourceKey == "string" ? r.sourceKey : JSON.stringify(r) : "";
|
|
1755
1904
|
}
|
|
1756
|
-
function
|
|
1905
|
+
function cr(e) {
|
|
1757
1906
|
return C(e) && ie(e)[0] || "";
|
|
1758
1907
|
}
|
|
1759
1908
|
function ie(e) {
|
|
@@ -1763,86 +1912,86 @@ function ie(e) {
|
|
|
1763
1912
|
]) : [];
|
|
1764
1913
|
}
|
|
1765
1914
|
function B(e) {
|
|
1766
|
-
const
|
|
1767
|
-
if (!["metric", "records", "analysis", "matrix", "sql"].includes(
|
|
1915
|
+
const r = String(e || "").replace(/^semaphor\./, "");
|
|
1916
|
+
if (!["metric", "records", "analysis", "matrix", "sql"].includes(r))
|
|
1768
1917
|
throw new Error(`Unsupported sdkSpec builder: ${e}`);
|
|
1769
|
-
return
|
|
1918
|
+
return r;
|
|
1770
1919
|
}
|
|
1771
|
-
function
|
|
1772
|
-
const
|
|
1773
|
-
return
|
|
1920
|
+
function mr(e) {
|
|
1921
|
+
const r = B(e);
|
|
1922
|
+
return r === "records" || r === "sql";
|
|
1774
1923
|
}
|
|
1775
|
-
function
|
|
1776
|
-
const
|
|
1777
|
-
return typeof (
|
|
1924
|
+
function fr(e) {
|
|
1925
|
+
const r = k(e);
|
|
1926
|
+
return typeof (r == null ? void 0 : r.operator) == "string" ? r.operator : e.type === "date_range" ? "between" : e.type === "multi_select" || e.type === "select" ? "in" : "=";
|
|
1778
1927
|
}
|
|
1779
|
-
function
|
|
1780
|
-
const
|
|
1928
|
+
function j(e, r) {
|
|
1929
|
+
const n = /* @__PURE__ */ new Map();
|
|
1781
1930
|
for (const t of e) {
|
|
1782
|
-
const o =
|
|
1783
|
-
|
|
1931
|
+
const o = r(t) || "item", i = n.get(o) || 0;
|
|
1932
|
+
n.set(o, i + 1), t.name = i === 0 ? o : `${o}${i + 1}`;
|
|
1784
1933
|
}
|
|
1785
1934
|
}
|
|
1786
|
-
function X(e,
|
|
1787
|
-
const
|
|
1935
|
+
function X(e, r) {
|
|
1936
|
+
const n = /* @__PURE__ */ new Set(), t = [];
|
|
1788
1937
|
for (const o of e) {
|
|
1789
|
-
const
|
|
1790
|
-
!
|
|
1938
|
+
const i = r(o);
|
|
1939
|
+
!i || n.has(i) || (n.add(i), t.push(o));
|
|
1791
1940
|
}
|
|
1792
1941
|
return t;
|
|
1793
1942
|
}
|
|
1794
1943
|
function q(e) {
|
|
1795
|
-
const
|
|
1796
|
-
if (
|
|
1944
|
+
const r = String(e || "").replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
|
|
1945
|
+
if (r.length === 0)
|
|
1797
1946
|
return "item";
|
|
1798
|
-
const [
|
|
1799
|
-
|
|
1800
|
-
...t.map((
|
|
1947
|
+
const [n, ...t] = r, o = [
|
|
1948
|
+
n.toLowerCase(),
|
|
1949
|
+
...t.map((i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase())
|
|
1801
1950
|
].join("");
|
|
1802
1951
|
return /^[A-Za-z_$]/.test(o) ? o : `item${o}`;
|
|
1803
1952
|
}
|
|
1804
1953
|
function me(e) {
|
|
1805
|
-
const
|
|
1806
|
-
return
|
|
1954
|
+
const r = q(e);
|
|
1955
|
+
return r.charAt(0).toUpperCase() + r.slice(1);
|
|
1807
1956
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const
|
|
1810
|
-
return
|
|
1957
|
+
function yr(e) {
|
|
1958
|
+
const r = String(e).split(":");
|
|
1959
|
+
return r[r.length - 1] || String(e);
|
|
1811
1960
|
}
|
|
1812
|
-
function
|
|
1813
|
-
return Object.fromEntries(Object.entries(e).filter(([,
|
|
1961
|
+
function O(e) {
|
|
1962
|
+
return Object.fromEntries(Object.entries(e).filter(([, r]) => r !== void 0));
|
|
1814
1963
|
}
|
|
1815
|
-
function
|
|
1964
|
+
function k(e) {
|
|
1816
1965
|
return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
|
|
1817
1966
|
}
|
|
1818
|
-
function
|
|
1967
|
+
function H(e) {
|
|
1819
1968
|
return Array.isArray(e) ? e : [];
|
|
1820
1969
|
}
|
|
1821
1970
|
function z(e) {
|
|
1822
1971
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1823
1972
|
}
|
|
1824
|
-
function
|
|
1973
|
+
function v(e) {
|
|
1825
1974
|
return e !== void 0;
|
|
1826
1975
|
}
|
|
1827
1976
|
export {
|
|
1828
|
-
|
|
1977
|
+
xr as CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
1829
1978
|
Re as CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
1830
|
-
|
|
1831
|
-
|
|
1979
|
+
xe as CONTRACT_MANIFEST_SCHEMA_VERSION,
|
|
1980
|
+
Sr as DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR,
|
|
1832
1981
|
fe as GENERATED_CONTRACT_SCHEMA_VERSION,
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1982
|
+
Nr as GENERATED_CONTRACT_TYPESCRIPT_FILES,
|
|
1983
|
+
Cr as REQUIRED_GENERATED_CONTRACT_FILES,
|
|
1984
|
+
Vr as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
1985
|
+
br as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
1986
|
+
Me as assertValidCodegenSummary,
|
|
1987
|
+
Gr as buildSemaphorGeneratedActiveInput,
|
|
1988
|
+
Or as buildSemaphorGeneratedInputOptionIntent,
|
|
1989
|
+
vr as buildSemaphorGeneratedViewExecutionRequest,
|
|
1990
|
+
Kr as buildSemaphorGeneratedViewExecutionRequests,
|
|
1991
|
+
Er as evaluateSemaphorDataAppContractUpdatePolicy,
|
|
1992
|
+
$r as generateSemaphorDataAppContract,
|
|
1993
|
+
kr as isSemaphorDataAppCodegenSummary,
|
|
1994
|
+
Ar as validateCodegenSummary,
|
|
1995
|
+
Mr as validateSemaphorDataAppCodegenSummary,
|
|
1996
|
+
jr as validateSemaphorGeneratedContract
|
|
1848
1997
|
};
|