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