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