react-semaphor 0.1.408 → 0.1.410
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 +22 -21
- package/dist/chunks/{calendar-preferences-dialog-BEJunQM-.js → calendar-preferences-dialog-B8FmFRHX.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-BDovl96B.js → calendar-preferences-dialog-ck4AU-to.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-D-G1kXb8.js → dashboard-briefing-launcher-Br_1IK1z.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DmybDHiR.js → dashboard-briefing-launcher-Tr2SqDMK.js} +2 -2
- package/dist/chunks/{dashboard-controls-DgjlAGWu.js → dashboard-controls-B2bEv8uG.js} +3 -3
- package/dist/chunks/{dashboard-controls-DIPQW6Vj.js → dashboard-controls-B7OObDNl.js} +1 -1
- package/dist/chunks/{dashboard-json-DUmEB8x3.js → dashboard-json-DAB8WVyb.js} +1 -1
- package/dist/chunks/{dashboard-json-DvW8_MWp.js → dashboard-json-DNixjalS.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-BZnVLA4S.js → edit-dashboard-visual-DWygSAp3.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-BuwFsoeW.js → edit-dashboard-visual-Dh8Ge3-B.js} +2 -2
- package/dist/chunks/{index-DhkNgPPm.js → index-BkTLAfKy.js} +4 -4
- package/dist/chunks/{index-D7JKnhyA.js → index-CQIMj-FF.js} +2 -2
- package/dist/chunks/source-identity-BM2FvJDP.js +1 -0
- package/dist/chunks/{source-identity-y0VSSreA.js → source-identity-Cv4Nm3TM.js} +23 -15
- package/dist/chunks/{update-policy-Bv3_5LFK.js → update-policy-BnEbPhHW.js} +305 -282
- package/dist/chunks/update-policy-CWg9c08k.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-C9QPAd9_.js → use-create-flow-overlay-state-CZA-dSns.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-B8clS9IG.js → use-create-flow-overlay-state-uujasvbD.js} +1 -1
- package/dist/chunks/{validators-DaBsAUsR.js → validators-C-_9Ew5G.js} +1 -1
- package/dist/chunks/{validators-BCQB11_y.js → validators-CB9BFarT.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 +1 -1
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +1 -1
- package/dist/data-app-codegen-node/index.cjs +304 -105
- package/dist/data-app-codegen-node/index.js +800 -503
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +158 -155
- 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 +4 -4
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +2 -0
- package/dist/types/data-app-sdk.d.ts +3 -0
- package/package.json +1 -1
- package/dist/chunks/source-identity-uMaUe036.js +0 -1
- package/dist/chunks/update-policy-2M0canB_.js +0 -3
|
@@ -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 hn, a as Sn, i as wn, v as $n } from "../chunks/analyze-result-contract-DPjm6btg.js";
|
|
2
|
+
import { c as Fe, G as me, a as be, b as Ve } from "../chunks/update-policy-BnEbPhHW.js";
|
|
3
|
+
import { C as Fn, e as bn, R as Vn, f as kn, g as Rn, h as Mn, i as Nn, j as xn, v as Cn, d as On } from "../chunks/update-policy-BnEbPhHW.js";
|
|
4
|
+
import { createHash as fe } from "node:crypto";
|
|
5
|
+
const mn = "src/semaphor/generated", v = `// 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 fn(e, n = {}) {
|
|
9
|
+
Fe(e);
|
|
10
|
+
const r = ke(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 o =
|
|
15
|
+
const o = Me(r), t = Ne({
|
|
16
16
|
contract: r,
|
|
17
17
|
files: o,
|
|
18
18
|
generatorName: n.generatorName || "react-semaphor/data-app-codegen/node",
|
|
19
19
|
generatorVersion: n.generatorVersion || "unknown"
|
|
20
|
-
}),
|
|
20
|
+
}), a = {
|
|
21
21
|
...o,
|
|
22
22
|
"contract.manifest.json": `${JSON.stringify(t, null, 2)}
|
|
23
23
|
`
|
|
24
24
|
};
|
|
25
25
|
return {
|
|
26
|
-
schemaVersion:
|
|
27
|
-
files:
|
|
26
|
+
schemaVersion: me,
|
|
27
|
+
files: a,
|
|
28
28
|
manifest: t,
|
|
29
29
|
contentHash: String(t.generatedContentHash || ""),
|
|
30
|
-
usageExample:
|
|
30
|
+
usageExample: Oe(r),
|
|
31
31
|
warnings: r.warnings,
|
|
32
32
|
stats: {
|
|
33
33
|
inputCount: r.inputs.length,
|
|
@@ -38,199 +38,199 @@ function un(e, n = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
var
|
|
41
|
+
function ke(e) {
|
|
42
|
+
var c, u, d, m, l, w, b, F, x, G, V, M;
|
|
43
43
|
const n = [], r = [];
|
|
44
44
|
for (const s of e.inputs) {
|
|
45
|
-
|
|
46
|
-
for (const
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
g(r, s.fieldRef);
|
|
46
|
+
for (const S of s.bindings || [])
|
|
47
|
+
g(r, S.fieldRef);
|
|
48
|
+
g(r, (c = s.optionQuery) == null ? void 0 : c.valueFieldRef), g(r, (u = s.optionQuery) == null ? void 0 : u.labelFieldRef), g(r, (d = s.optionQuery) == null ? void 0 : d.filterFieldRef), T(r, (m = s.optionQuery) == null ? void 0 : m.spec);
|
|
49
49
|
}
|
|
50
50
|
for (const s of e.filterContracts) {
|
|
51
|
-
|
|
52
|
-
for (const
|
|
53
|
-
|
|
51
|
+
g(r, s.fieldRef), g(r, (l = s.optionQuery) == null ? void 0 : l.valueFieldRef), g(r, (w = s.optionQuery) == null ? void 0 : w.labelFieldRef), g(r, (b = s.optionQuery) == null ? void 0 : b.filterFieldRef), T(r, (F = s.optionQuery) == null ? void 0 : F.spec);
|
|
52
|
+
for (const S of s.bindings || [])
|
|
53
|
+
g(r, S.fieldRef);
|
|
54
54
|
}
|
|
55
55
|
for (const s of e.views) {
|
|
56
|
-
for (const
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
for (const S of s.fields || [])
|
|
57
|
+
g(r, S);
|
|
58
|
+
T(r, (x = s.sdkSpec) == null ? void 0 : x.spec), T(r, s.visualSpec);
|
|
59
59
|
}
|
|
60
60
|
const o = e.implementationChecklist || {};
|
|
61
61
|
for (const s of Object.values(o.bindingsByView || {}))
|
|
62
|
-
for (const
|
|
63
|
-
|
|
62
|
+
for (const S of Array.isArray(s) ? s : [])
|
|
63
|
+
g(r, S.fieldRef), g(r, S.optionValueField), g(r, S.optionLabelField);
|
|
64
64
|
for (const s of o.requiredInputOptions || [])
|
|
65
|
-
|
|
66
|
-
const t =
|
|
65
|
+
g(r, s.visibleLabelField), g(r, s.optionValueField), g(r, s.runtimeFilterField);
|
|
66
|
+
const t = on(
|
|
67
67
|
[
|
|
68
68
|
...e.sources.map((s) => ({
|
|
69
69
|
raw: s,
|
|
70
|
-
key:
|
|
71
|
-
aliases:
|
|
70
|
+
key: Se(s),
|
|
71
|
+
aliases: we(s),
|
|
72
72
|
name: ""
|
|
73
73
|
})),
|
|
74
|
-
...r.map((s) =>
|
|
74
|
+
...r.map((s) => nn(s)).filter(O)
|
|
75
75
|
]
|
|
76
76
|
);
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
return
|
|
80
|
-
s.raw.label || (
|
|
77
|
+
H(t, (s) => {
|
|
78
|
+
const S = $(s.raw);
|
|
79
|
+
return Q(
|
|
80
|
+
s.raw.label || (S == null ? void 0 : S.datasetName) || (S == null ? void 0 : S.datasetId) || (S == null ? void 0 : S.name) || s.raw.kind || "source"
|
|
81
81
|
);
|
|
82
82
|
});
|
|
83
|
-
const
|
|
83
|
+
const a = sn(t), p = X(
|
|
84
84
|
r.filter((s) => s.name).map((s) => ({
|
|
85
85
|
raw: s,
|
|
86
|
-
key:
|
|
86
|
+
key: D(s),
|
|
87
87
|
name: ""
|
|
88
88
|
})),
|
|
89
89
|
(s) => s.key
|
|
90
90
|
);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(s) =>
|
|
94
|
-
s.raw.sourceKey ?
|
|
91
|
+
H(
|
|
92
|
+
p,
|
|
93
|
+
(s) => Q([
|
|
94
|
+
s.raw.sourceKey ? ln(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 f = new Map(p.map((s) => [s.key, s.name])), h = e.inputs.map((s) => ({
|
|
100
100
|
raw: s,
|
|
101
|
-
name:
|
|
101
|
+
name: Q(s.id || s.label || "input")
|
|
102
102
|
}));
|
|
103
|
-
|
|
104
|
-
const
|
|
103
|
+
H(h, (s) => s.name);
|
|
104
|
+
const y = h.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
|
-
|
|
110
|
-
for (const s of
|
|
111
|
-
|
|
109
|
+
H(y, (s) => s.name);
|
|
110
|
+
for (const s of y)
|
|
111
|
+
rn(s.raw.labelFieldRef, s.raw.valueFieldRef) && tn(s.raw.valueFieldRef) && n.push(
|
|
112
112
|
`Input option query ${((G = s.raw.spec) == null ? void 0 : G.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 i = e.views.filter(
|
|
115
115
|
(s) => {
|
|
116
|
-
var
|
|
117
|
-
return !!((
|
|
116
|
+
var S, j;
|
|
117
|
+
return !!((S = s.sdkSpec) != null && S.builder && ((j = s.sdkSpec) != null && j.spec));
|
|
118
118
|
}
|
|
119
119
|
).map((s) => ({
|
|
120
120
|
raw: s,
|
|
121
|
-
name:
|
|
121
|
+
name: Q(s.id || s.title || "query")
|
|
122
122
|
}));
|
|
123
|
-
|
|
124
|
-
const I = e.views.filter((s) =>
|
|
123
|
+
H(i, (s) => s.name);
|
|
124
|
+
const I = e.views.filter((s) => ce(s) && !("sdkSpec" in s)).map((s) => en(s));
|
|
125
125
|
for (const s of e.views)
|
|
126
|
-
(!("sdkSpec" in s) || !((
|
|
127
|
-
return
|
|
128
|
-
inputs:
|
|
129
|
-
views:
|
|
126
|
+
(!("sdkSpec" in s) || !((V = s.sdkSpec) != null && V.builder) || !((M = s.sdkSpec) != null && M.spec)) && !ce(s) && n.push(`Skipped view ${s.id || s.title || "unknown"} because it has no sdkSpec.`);
|
|
127
|
+
return Re({
|
|
128
|
+
inputs: h,
|
|
129
|
+
views: i,
|
|
130
130
|
filterContracts: e.filterContracts
|
|
131
131
|
}), {
|
|
132
132
|
summary: e,
|
|
133
133
|
title: e.title || "Semaphor Data App",
|
|
134
134
|
sources: t,
|
|
135
|
-
fields:
|
|
136
|
-
inputs:
|
|
137
|
-
optionQueries:
|
|
138
|
-
views:
|
|
135
|
+
fields: p,
|
|
136
|
+
inputs: h,
|
|
137
|
+
optionQueries: y,
|
|
138
|
+
views: i,
|
|
139
139
|
presentationViews: I,
|
|
140
140
|
filterContracts: e.filterContracts,
|
|
141
141
|
checklist: o,
|
|
142
|
-
sourceNameByKey:
|
|
143
|
-
fieldNameByKey:
|
|
142
|
+
sourceNameByKey: a,
|
|
143
|
+
fieldNameByKey: f,
|
|
144
144
|
warnings: n
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Re({
|
|
148
148
|
inputs: e,
|
|
149
149
|
views: n,
|
|
150
150
|
filterContracts: r
|
|
151
151
|
}) {
|
|
152
|
-
const o = new Set(e.map((
|
|
153
|
-
for (const [
|
|
154
|
-
if (!o.has(
|
|
155
|
-
throw new Error(`filterContracts.${
|
|
156
|
-
const
|
|
157
|
-
for (const [
|
|
158
|
-
if (!t.has(
|
|
152
|
+
const o = new Set(e.map((a) => a.raw.id).filter(Boolean)), t = new Set(n.map((a) => a.raw.id).filter(Boolean));
|
|
153
|
+
for (const [a, p] of r.entries()) {
|
|
154
|
+
if (!o.has(p.inputId))
|
|
155
|
+
throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);
|
|
156
|
+
const f = new Set(p.appliesToViewIds || []), h = new Set(p.notAppliedToViewIds || []);
|
|
157
|
+
for (const [y, i] of (p.appliesToViewIds || []).entries())
|
|
158
|
+
if (!t.has(i))
|
|
159
159
|
throw new Error(
|
|
160
|
-
`filterContracts.${
|
|
160
|
+
`filterContracts.${a}.appliesToViewIds.${y} must reference an executable generated view.`
|
|
161
161
|
);
|
|
162
|
-
for (const [
|
|
163
|
-
if (!t.has(
|
|
162
|
+
for (const [y, i] of (p.notAppliedToViewIds || []).entries())
|
|
163
|
+
if (!t.has(i))
|
|
164
164
|
throw new Error(
|
|
165
|
-
`filterContracts.${
|
|
165
|
+
`filterContracts.${a}.notAppliedToViewIds.${y} must reference an executable generated view.`
|
|
166
166
|
);
|
|
167
|
-
for (const [
|
|
168
|
-
if (!t.has(
|
|
167
|
+
for (const [y, i] of (p.bindings || []).entries()) {
|
|
168
|
+
if (!t.has(i.viewId))
|
|
169
169
|
throw new Error(
|
|
170
|
-
`filterContracts.${
|
|
170
|
+
`filterContracts.${a}.bindings.${y}.viewId must reference an executable generated view.`
|
|
171
171
|
);
|
|
172
|
-
if (!
|
|
172
|
+
if (!f.has(i.viewId))
|
|
173
173
|
throw new Error(
|
|
174
|
-
`filterContracts.${
|
|
174
|
+
`filterContracts.${a}.bindings.${y}.viewId must be included in appliesToViewIds.`
|
|
175
175
|
);
|
|
176
|
-
if (
|
|
176
|
+
if (h.has(i.viewId))
|
|
177
177
|
throw new Error(
|
|
178
|
-
`filterContracts.${
|
|
178
|
+
`filterContracts.${a}.bindings.${y}.viewId must not be listed in notAppliedToViewIds.`
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function Me(e) {
|
|
184
184
|
return {
|
|
185
|
-
"sources.ts":
|
|
185
|
+
"sources.ts": Ee(e),
|
|
186
186
|
"fields.ts": He(e),
|
|
187
|
-
"inputs.ts":
|
|
188
|
-
"queries.ts":
|
|
189
|
-
"bindings.ts":
|
|
190
|
-
"accessors.ts":
|
|
191
|
-
"metadata.ts":
|
|
192
|
-
"index.ts":
|
|
187
|
+
"inputs.ts": Ae(e),
|
|
188
|
+
"queries.ts": je(e),
|
|
189
|
+
"bindings.ts": Pe(e),
|
|
190
|
+
"accessors.ts": Ue(e),
|
|
191
|
+
"metadata.ts": Je(e),
|
|
192
|
+
"index.ts": ze()
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Ne({
|
|
196
196
|
contract: e,
|
|
197
197
|
files: n,
|
|
198
198
|
generatorName: r,
|
|
199
199
|
generatorVersion: o
|
|
200
200
|
}) {
|
|
201
201
|
return {
|
|
202
|
-
schemaVersion:
|
|
203
|
-
generatedContractSchemaVersion:
|
|
202
|
+
schemaVersion: Ve,
|
|
203
|
+
generatedContractSchemaVersion: me,
|
|
204
204
|
generator: {
|
|
205
205
|
name: r,
|
|
206
206
|
version: o
|
|
207
207
|
},
|
|
208
|
-
generatedContentHash:
|
|
209
|
-
codegenSummaryValidatorVersion:
|
|
210
|
-
codegenSummaryHash:
|
|
208
|
+
generatedContentHash: xe(n),
|
|
209
|
+
codegenSummaryValidatorVersion: be,
|
|
210
|
+
codegenSummaryHash: Ce(e.summary),
|
|
211
211
|
codegenSummary: e.summary
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
const n =
|
|
214
|
+
function xe(e) {
|
|
215
|
+
const n = fe("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 Ce(e) {
|
|
221
|
+
return `sha256:${fe("sha256").update(ae(e)).digest("hex")}`;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
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((o) =>
|
|
227
|
+
return `[${e.map((o) => ae(o)).join(",")}]`;
|
|
228
228
|
const n = e;
|
|
229
|
-
return `{${Object.keys(n).sort().filter((o) => n[o] !== void 0).map((o) => `${JSON.stringify(o)}:${
|
|
229
|
+
return `{${Object.keys(n).sort().filter((o) => n[o] !== void 0).map((o) => `${JSON.stringify(o)}:${ae(n[o])}`).join(",")}}`;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Oe(e) {
|
|
232
232
|
const n = e.views.find(
|
|
233
|
-
(
|
|
233
|
+
(y) => K(y) && E(y)
|
|
234
234
|
);
|
|
235
235
|
if (n)
|
|
236
236
|
return [
|
|
@@ -246,7 +246,7 @@ function Ne(e) {
|
|
|
246
246
|
].join(`
|
|
247
247
|
`);
|
|
248
248
|
const r = e.views.find(
|
|
249
|
-
(
|
|
249
|
+
(y) => K(y)
|
|
250
250
|
);
|
|
251
251
|
if (r)
|
|
252
252
|
return [
|
|
@@ -262,7 +262,7 @@ function Ne(e) {
|
|
|
262
262
|
].join(`
|
|
263
263
|
`);
|
|
264
264
|
const o = e.views.find(
|
|
265
|
-
(
|
|
265
|
+
(y) => W(y) && E(y)
|
|
266
266
|
);
|
|
267
267
|
if (o)
|
|
268
268
|
return [
|
|
@@ -276,7 +276,7 @@ function Ne(e) {
|
|
|
276
276
|
].join(`
|
|
277
277
|
`);
|
|
278
278
|
const t = e.views.find(
|
|
279
|
-
(
|
|
279
|
+
(y) => ue(y) && E(y)
|
|
280
280
|
);
|
|
281
281
|
if (t)
|
|
282
282
|
return [
|
|
@@ -289,64 +289,79 @@ function Ne(e) {
|
|
|
289
289
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
290
290
|
].join(`
|
|
291
291
|
`);
|
|
292
|
-
const
|
|
293
|
-
var
|
|
294
|
-
return
|
|
292
|
+
const a = e.views.find((y) => {
|
|
293
|
+
var i;
|
|
294
|
+
return un((i = y.raw.sdkSpec) == null ? void 0 : i.builder);
|
|
295
295
|
});
|
|
296
|
-
if (
|
|
296
|
+
if (a)
|
|
297
297
|
return [
|
|
298
298
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, rowValuesForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
299
299
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
300
300
|
"const inputHandles = createInputHandleMap(handles);",
|
|
301
|
-
`const result = useSemaphorQuery(queries.${
|
|
302
|
-
`const rows = result.records.map((row) => rowValuesForView.${
|
|
301
|
+
`const result = useSemaphorQuery(queries.${a.name}(), queryOptionsForView.${a.name}(inputHandles));`,
|
|
302
|
+
`const rows = result.records.map((row) => rowValuesForView.${a.name}(row, result.columns));`,
|
|
303
|
+
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
304
|
+
].join(`
|
|
305
|
+
`);
|
|
306
|
+
const p = e.views.find((y) => Ge(y));
|
|
307
|
+
if (p)
|
|
308
|
+
return [
|
|
309
|
+
'import { appInputSpecs, createInputHandleMap, metricValuesForView, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
310
|
+
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
311
|
+
"const inputHandles = createInputHandleMap(handles);",
|
|
312
|
+
`const result = useSemaphorQuery(queries.${p.name}(), queryOptionsForView.${p.name}(inputHandles));`,
|
|
313
|
+
`const metrics = metricValuesForView.${p.name}(result);`,
|
|
303
314
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
304
315
|
].join(`
|
|
305
316
|
`);
|
|
306
|
-
const
|
|
317
|
+
const f = e.views[0];
|
|
307
318
|
return [
|
|
308
319
|
'import { appInputSpecs, createInputHandleMap, queries, queryOptionsForView, semaphorGeneratedContractMetadata } from "./semaphor/generated";',
|
|
309
320
|
"const handles = useSemaphorInputs(appInputSpecs);",
|
|
310
321
|
"const inputHandles = createInputHandleMap(handles);",
|
|
311
|
-
|
|
322
|
+
f ? `const result = useSemaphorQuery(queries.${f.name}(), queryOptionsForView.${f.name}(inputHandles));` : "const result = undefined;",
|
|
312
323
|
"const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
|
|
313
324
|
].join(`
|
|
314
325
|
`);
|
|
315
326
|
}
|
|
316
|
-
function
|
|
327
|
+
function W(e) {
|
|
317
328
|
var n;
|
|
318
329
|
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "records";
|
|
319
330
|
}
|
|
320
|
-
function
|
|
331
|
+
function Ge(e) {
|
|
332
|
+
var n;
|
|
333
|
+
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "metric";
|
|
334
|
+
}
|
|
335
|
+
function K(e) {
|
|
321
336
|
var n, r, o;
|
|
322
|
-
return
|
|
337
|
+
return W(e) && ((o = (r = (n = e.raw.visualSpec) == null ? void 0 : n.tableBehavior) == null ? void 0 : r.sorting) == null ? void 0 : o.mode) === "server";
|
|
323
338
|
}
|
|
324
|
-
function
|
|
339
|
+
function ue(e) {
|
|
325
340
|
var n;
|
|
326
341
|
return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "sql";
|
|
327
342
|
}
|
|
328
|
-
function
|
|
343
|
+
function E(e) {
|
|
329
344
|
var n, r, o;
|
|
330
345
|
return ((o = (r = (n = e.raw.visualSpec) == null ? void 0 : n.tableBehavior) == null ? void 0 : r.pagination) == null ? void 0 : o.mode) === "server";
|
|
331
346
|
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
347
|
+
function Ke(e) {
|
|
348
|
+
return W(e) && (E(e) || K(e)) || ue(e) && E(e);
|
|
334
349
|
}
|
|
335
|
-
function
|
|
350
|
+
function Ee(e) {
|
|
336
351
|
const n = e.sources.map(({ name: o, raw: t }) => {
|
|
337
|
-
const
|
|
338
|
-
return ` ${o}: ${
|
|
352
|
+
const a = ve(t);
|
|
353
|
+
return ` ${o}: ${a},`;
|
|
339
354
|
}).join(`
|
|
340
355
|
`), r = e.sources.some((o) => o.raw.kind === "semantic") ? `import { semaphor } from "react-semaphor/data-app-sdk";
|
|
341
356
|
|
|
342
357
|
` : "";
|
|
343
|
-
return `${
|
|
358
|
+
return `${v}
|
|
344
359
|
${r}export const sources = {
|
|
345
360
|
${n}
|
|
346
361
|
} as const;
|
|
347
362
|
`;
|
|
348
363
|
}
|
|
349
|
-
function
|
|
364
|
+
function ve(e) {
|
|
350
365
|
if (e.kind === "semantic") {
|
|
351
366
|
const n = {
|
|
352
367
|
domainId: e.domainId,
|
|
@@ -354,120 +369,120 @@ function Ee(e) {
|
|
|
354
369
|
datasetName: e.datasetName,
|
|
355
370
|
label: e.label
|
|
356
371
|
};
|
|
357
|
-
return `semaphor.source.semantic(${
|
|
372
|
+
return `semaphor.source.semantic(${k(A(n))})`;
|
|
358
373
|
}
|
|
359
|
-
return `${
|
|
374
|
+
return `${k(A({ ...e, sourceKey: void 0 }))} as const`;
|
|
360
375
|
}
|
|
361
376
|
function He(e) {
|
|
362
377
|
const n = e.fields.map(({ name: o, raw: t }) => {
|
|
363
|
-
const
|
|
364
|
-
return ` ${o}: ${
|
|
378
|
+
const a = qe(t, e);
|
|
379
|
+
return ` ${o}: ${a},`;
|
|
365
380
|
}).join(`
|
|
366
381
|
`), r = n.includes("sources.") ? `import { sources } from "./sources";
|
|
367
382
|
|
|
368
383
|
` : "";
|
|
369
|
-
return `${
|
|
384
|
+
return `${v}
|
|
370
385
|
${r}export const fields = {
|
|
371
386
|
${n}
|
|
372
387
|
} as const;
|
|
373
388
|
`;
|
|
374
389
|
}
|
|
375
|
-
function
|
|
390
|
+
function qe(e, n) {
|
|
376
391
|
const r = {
|
|
377
392
|
name: e.name,
|
|
378
393
|
label: e.label,
|
|
379
394
|
role: e.role,
|
|
380
395
|
dataType: e.dataType,
|
|
381
396
|
aggregate: e.aggregate
|
|
382
|
-
}, o =
|
|
397
|
+
}, o = an(e), t = o ? n.sourceNameByKey.get(o) : void 0;
|
|
383
398
|
if (o && !t)
|
|
384
399
|
throw new Error(
|
|
385
400
|
`Field ${e.name} references source ${o}, but that source is not renderable. Include the source in codegenSummary.sources or provide field.source.`
|
|
386
401
|
);
|
|
387
|
-
const
|
|
388
|
-
return t &&
|
|
389
|
-
}
|
|
390
|
-
function
|
|
391
|
-
const n = e.inputs.map((
|
|
392
|
-
const
|
|
393
|
-
`id: ${JSON.stringify(
|
|
394
|
-
`label: ${JSON.stringify(
|
|
395
|
-
`operator: ${JSON.stringify(
|
|
402
|
+
const a = Object.entries(A(r)).map(([p, f]) => `${JSON.stringify(p)}: ${C(f, n)}`);
|
|
403
|
+
return t && a.push(`"source": sources.${t}`), `{ ${a.join(", ")} }`;
|
|
404
|
+
}
|
|
405
|
+
function Ae(e) {
|
|
406
|
+
const n = e.inputs.map((d) => {
|
|
407
|
+
const m = R(d.raw.fieldRef, e), l = [
|
|
408
|
+
`id: ${JSON.stringify(d.raw.id)}`,
|
|
409
|
+
`label: ${JSON.stringify(d.raw.label || d.raw.id)}`,
|
|
410
|
+
`operator: ${JSON.stringify(dn(d.raw))}`
|
|
396
411
|
];
|
|
397
|
-
if (
|
|
398
|
-
throw new Error(`Input ${
|
|
399
|
-
return ` ${
|
|
412
|
+
if (m && l.push(`field: fields.${m}`), d.raw.relationshipHint && l.push(`relationshipHint: ${k(d.raw.relationshipHint)}`), !m)
|
|
413
|
+
throw new Error(`Input ${d.raw.id || d.name} is missing a generated field reference.`);
|
|
414
|
+
return ` ${d.name}: semaphor.filter({ ${l.join(", ")} }),`;
|
|
400
415
|
}).join(`
|
|
401
|
-
`), r = e.inputs.map((
|
|
402
|
-
const
|
|
403
|
-
id:
|
|
416
|
+
`), r = e.inputs.map((d) => `filterSpecs.${d.name}`).join(", "), o = e.inputs.map((d) => JSON.stringify(d.raw.id)).join(", "), t = e.optionQueries.map((d) => {
|
|
417
|
+
const m = d.input.raw, l = d.raw, w = $(l.spec) || {}, {
|
|
418
|
+
id: b,
|
|
404
419
|
inputId: F,
|
|
405
|
-
source:
|
|
420
|
+
source: x,
|
|
406
421
|
sourceKey: G,
|
|
407
|
-
valueField:
|
|
408
|
-
labelField:
|
|
422
|
+
valueField: V,
|
|
423
|
+
labelField: M,
|
|
409
424
|
population: s,
|
|
410
|
-
dependencies:
|
|
411
|
-
limit:
|
|
412
|
-
...
|
|
413
|
-
} =
|
|
414
|
-
...
|
|
415
|
-
id:
|
|
416
|
-
inputId:
|
|
417
|
-
source:
|
|
418
|
-
valueField:
|
|
419
|
-
labelField:
|
|
420
|
-
population:
|
|
421
|
-
dependencies:
|
|
422
|
-
limit:
|
|
425
|
+
dependencies: S,
|
|
426
|
+
limit: j,
|
|
427
|
+
...ee
|
|
428
|
+
} = w, U = l.sourceKey ? { sourceKey: l.sourceKey } : l.source || x || (typeof G == "string" ? { sourceKey: G } : void 0), ne = he(U, e), re = R(l.valueFieldRef, e), te = R(l.labelFieldRef, e), oe = {
|
|
429
|
+
...ee,
|
|
430
|
+
id: l.id || w.id || `${m.id}-options`,
|
|
431
|
+
inputId: m.id,
|
|
432
|
+
source: U,
|
|
433
|
+
valueField: l.valueFieldRef,
|
|
434
|
+
labelField: l.labelFieldRef,
|
|
435
|
+
population: l.population || s,
|
|
436
|
+
dependencies: l.dependencies || S,
|
|
437
|
+
limit: l.limit || j || 100
|
|
423
438
|
};
|
|
424
|
-
if (!
|
|
425
|
-
throw new Error(`Input option query ${
|
|
426
|
-
const
|
|
427
|
-
return ` ${
|
|
439
|
+
if (!ne || !re || !te)
|
|
440
|
+
throw new Error(`Input option query ${l.id || `${m.id}-options`} is missing source, valueField, or labelField.`);
|
|
441
|
+
const se = Object.entries(A(oe)).map(([$e, Ie]) => `${JSON.stringify($e)}: ${C(Ie, e)}`);
|
|
442
|
+
return ` ${d.name}: semaphor.inputOptions({ ${se.join(", ")} }),`;
|
|
428
443
|
}).join(`
|
|
429
|
-
`),
|
|
430
|
-
const
|
|
431
|
-
const
|
|
432
|
-
if (!
|
|
444
|
+
`), a = e.optionQueries.map((d) => {
|
|
445
|
+
const l = Be(e, d).map((w) => {
|
|
446
|
+
const b = R(w.raw.fieldRef, e);
|
|
447
|
+
if (!b)
|
|
433
448
|
throw new Error(
|
|
434
|
-
`Input option query ${
|
|
449
|
+
`Input option query ${d.raw.id || `${d.input.raw.id}-options`} references input ${w.raw.id} without a generated field reference.`
|
|
435
450
|
);
|
|
436
|
-
const F = `inputHandles[${JSON.stringify(
|
|
451
|
+
const F = `inputHandles[${JSON.stringify(w.raw.id)}]`;
|
|
437
452
|
return ` if (${F}) {
|
|
438
|
-
inputs.push(semaphor.bindInput(${F}, { field: fields.${
|
|
453
|
+
inputs.push(semaphor.bindInput(${F}, { field: fields.${b} }));
|
|
439
454
|
}`;
|
|
440
455
|
}).join(`
|
|
441
456
|
`);
|
|
442
|
-
return ` ${
|
|
457
|
+
return ` ${d.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
443
458
|
const inputs: SemaphorInputReference[] = [];
|
|
444
|
-
${
|
|
459
|
+
${l}
|
|
445
460
|
return inputs;
|
|
446
461
|
},`;
|
|
447
462
|
}).join(`
|
|
448
463
|
|
|
449
|
-
`),
|
|
464
|
+
`), p = e.optionQueries.map((d) => ` ${d.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
450
465
|
return {
|
|
451
|
-
inputs: inputsForInputOptionQuery.${
|
|
466
|
+
inputs: inputsForInputOptionQuery.${d.name}(inputHandles),
|
|
452
467
|
};
|
|
453
468
|
},`).join(`
|
|
454
469
|
|
|
455
|
-
`),
|
|
456
|
-
return queryOptionsForInputOptionQuery.${
|
|
457
|
-
`),
|
|
470
|
+
`), f = e.optionQueries.map((d) => ` case ${JSON.stringify(d.raw.id || `${d.input.raw.id}-options`)}:
|
|
471
|
+
return queryOptionsForInputOptionQuery.${d.name}(inputHandles);`).join(`
|
|
472
|
+
`), h = e.inputs.length > 0, y = e.optionQueries.length > 0, i = y ? "inputOptionQueryId" : "_inputOptionQueryId", I = y ? "inputHandles" : "_inputHandles", c = [
|
|
458
473
|
"SemaphorInputHandle",
|
|
459
|
-
|
|
474
|
+
y ? "SemaphorInputReference" : void 0,
|
|
460
475
|
"SemaphorQueryRuntimeOptions"
|
|
461
|
-
].filter(
|
|
462
|
-
|
|
463
|
-
`import type { ${
|
|
464
|
-
|
|
465
|
-
|
|
476
|
+
].filter(O).join(", "), u = [
|
|
477
|
+
h || y ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
478
|
+
`import type { ${c} } from "react-semaphor/data-app-sdk";`,
|
|
479
|
+
h || y ? 'import { fields } from "./fields";' : void 0,
|
|
480
|
+
y ? 'import { sources } from "./sources";' : void 0,
|
|
466
481
|
'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'
|
|
467
|
-
].filter(
|
|
482
|
+
].filter(O).join(`
|
|
468
483
|
`);
|
|
469
|
-
return `${
|
|
470
|
-
${
|
|
484
|
+
return `${v}
|
|
485
|
+
${u}
|
|
471
486
|
|
|
472
487
|
export const filterSpecs = {
|
|
473
488
|
${n}
|
|
@@ -487,25 +502,25 @@ ${t}
|
|
|
487
502
|
} as const;
|
|
488
503
|
|
|
489
504
|
export const inputsForInputOptionQuery = {
|
|
490
|
-
${
|
|
505
|
+
${a}
|
|
491
506
|
} as const;
|
|
492
507
|
|
|
493
508
|
export const queryOptionsForInputOptionQuery = {
|
|
494
|
-
${
|
|
509
|
+
${p}
|
|
495
510
|
} as const;
|
|
496
511
|
|
|
497
512
|
export function queryOptionsForInputOptionQueryId(
|
|
498
|
-
${
|
|
513
|
+
${i}: SemaphorGeneratedInputOptionQueryId,
|
|
499
514
|
${I}: SemaphorGeneratedInputHandleMap,
|
|
500
515
|
): SemaphorQueryRuntimeOptions {
|
|
501
|
-
switch (${
|
|
502
|
-
${
|
|
516
|
+
switch (${i}) {
|
|
517
|
+
${f}
|
|
503
518
|
}
|
|
504
|
-
throw new Error(\`Unknown generated Semaphor input option query id: \${${
|
|
519
|
+
throw new Error(\`Unknown generated Semaphor input option query id: \${${i}}\`);
|
|
505
520
|
}
|
|
506
521
|
`;
|
|
507
522
|
}
|
|
508
|
-
function
|
|
523
|
+
function Be(e, n) {
|
|
509
524
|
const r = n.raw.dependencies;
|
|
510
525
|
if ((r == null ? void 0 : r.mode) === "independent")
|
|
511
526
|
return [];
|
|
@@ -513,76 +528,76 @@ function Me(e, n) {
|
|
|
513
528
|
n.input.raw.id,
|
|
514
529
|
...(r == null ? void 0 : r.excludeInputIds) || []
|
|
515
530
|
]), t = (r == null ? void 0 : r.mode) === "explicit" ? new Set(r.includeInputIds || []) : void 0;
|
|
516
|
-
return e.inputs.filter((
|
|
531
|
+
return e.inputs.filter((a) => o.has(a.raw.id) ? !1 : t ? t.has(a.raw.id) : !!a.raw.fieldRef);
|
|
517
532
|
}
|
|
518
|
-
function
|
|
519
|
-
const n = e.views.map((
|
|
520
|
-
var
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const
|
|
524
|
-
view:
|
|
533
|
+
function je(e) {
|
|
534
|
+
const n = e.views.map((u) => {
|
|
535
|
+
var l, w, b, F, x, G;
|
|
536
|
+
const d = B(u.raw.sdkSpec.builder), m = Te(u);
|
|
537
|
+
if (W(u) && Ke(u)) {
|
|
538
|
+
const V = (l = u.raw.visualSpec) == null ? void 0 : l.tableBehavior, M = $(m.pagination), s = E(u), S = K(u), j = ((w = V == null ? void 0 : V.pagination) == null ? void 0 : w.pageSize) || J(M == null ? void 0 : M.pageSize) || J(m.limit) || 100, ee = S ? z(u, e) : [], U = S ? Qe({
|
|
539
|
+
view: u,
|
|
525
540
|
contract: e,
|
|
526
|
-
sortFields:
|
|
527
|
-
defaultField: (
|
|
528
|
-
}) : void 0,
|
|
529
|
-
viewName:
|
|
541
|
+
sortFields: ee,
|
|
542
|
+
defaultField: (b = V == null ? void 0 : V.sorting) == null ? void 0 : b.defaultField
|
|
543
|
+
}) : void 0, ne = S ? (F = V == null ? void 0 : V.sorting) == null ? void 0 : F.defaultDirection : void 0, re = _e({
|
|
544
|
+
viewName: u.name,
|
|
530
545
|
supportsPagination: s,
|
|
531
|
-
supportsSort:
|
|
532
|
-
}),
|
|
533
|
-
recordsSortFieldsForView.${
|
|
546
|
+
supportsSort: S
|
|
547
|
+
}), te = S ? ` const orderBy = resolveRecordsOrderBy(
|
|
548
|
+
recordsSortFieldsForView.${u.name},
|
|
534
549
|
params.sort,
|
|
535
|
-
${
|
|
536
|
-
${
|
|
550
|
+
${C(U, e)},
|
|
551
|
+
${C(ne, e)},
|
|
537
552
|
);
|
|
538
|
-
` : "",
|
|
539
|
-
` : "",
|
|
553
|
+
` : "", oe = S ? ` ...(orderBy ? { orderBy } : {}),
|
|
554
|
+
` : "", se = s ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(j)}),
|
|
540
555
|
` : "";
|
|
541
|
-
return ` ${
|
|
542
|
-
params: ${
|
|
556
|
+
return ` ${u.name}(
|
|
557
|
+
params: ${re} = {},
|
|
543
558
|
) {
|
|
544
|
-
${
|
|
545
|
-
...${
|
|
546
|
-
${
|
|
559
|
+
${te} return semaphor.${d}({
|
|
560
|
+
...${C(m, e)},
|
|
561
|
+
${oe}${se} });
|
|
547
562
|
},`;
|
|
548
563
|
}
|
|
549
|
-
if (
|
|
550
|
-
const
|
|
551
|
-
return ` ${
|
|
564
|
+
if (ue(u) && E(u)) {
|
|
565
|
+
const V = (x = u.raw.visualSpec) == null ? void 0 : x.tableBehavior, M = $(m.pagination), s = ((G = V == null ? void 0 : V.pagination) == null ? void 0 : G.pageSize) || J(M == null ? void 0 : M.pageSize) || J(m.limit) || 100;
|
|
566
|
+
return ` ${u.name}(
|
|
552
567
|
params: SemaphorGeneratedServerPaginationParams = {},
|
|
553
568
|
) {
|
|
554
|
-
return semaphor.${
|
|
555
|
-
...${
|
|
569
|
+
return semaphor.${d}({
|
|
570
|
+
...${C(m, e)},
|
|
556
571
|
pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
|
|
557
572
|
});
|
|
558
573
|
},`;
|
|
559
574
|
}
|
|
560
|
-
return ` ${
|
|
575
|
+
return ` ${u.name}: () => semaphor.${d}(${C(m, e)}),`;
|
|
561
576
|
}).join(`
|
|
562
|
-
`), r = e.views.filter((
|
|
563
|
-
const
|
|
577
|
+
`), r = e.views.filter((u) => K(u)).map((u) => {
|
|
578
|
+
const m = z(u, e).map((l) => ` ${JSON.stringify(l.key)}: fields.${l.fieldName},`).join(`
|
|
564
579
|
`);
|
|
565
|
-
return ` ${
|
|
566
|
-
${
|
|
580
|
+
return ` ${u.name}: {
|
|
581
|
+
${m}
|
|
567
582
|
},`;
|
|
568
583
|
}).join(`
|
|
569
|
-
`), o = e.views.filter((
|
|
570
|
-
const
|
|
584
|
+
`), o = e.views.filter((u) => K(u)).map((u) => {
|
|
585
|
+
const m = z(u, e).map((l) => ` { key: ${JSON.stringify(l.key)}, label: ${JSON.stringify(l.label)}, field: fields.${l.fieldName} },`).join(`
|
|
571
586
|
`);
|
|
572
|
-
return ` ${
|
|
573
|
-
${
|
|
587
|
+
return ` ${u.name}: [
|
|
588
|
+
${m}
|
|
574
589
|
],`;
|
|
575
590
|
}).join(`
|
|
576
|
-
`), t = e.views.some((
|
|
577
|
-
`),
|
|
591
|
+
`), t = e.views.some((u) => K(u)), a = e.views.some((u) => E(u)), p = [n, r, o].join(`
|
|
592
|
+
`), f = [
|
|
578
593
|
n ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
579
594
|
t ? 'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";' : void 0,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
].filter(
|
|
595
|
+
p.includes("fields.") ? 'import { fields } from "./fields";' : void 0,
|
|
596
|
+
p.includes("sources.") ? 'import { sources } from "./sources";' : void 0
|
|
597
|
+
].filter(O).join(`
|
|
583
598
|
`);
|
|
584
|
-
return `${
|
|
585
|
-
${
|
|
599
|
+
return `${v}
|
|
600
|
+
${f}
|
|
586
601
|
${t ? `export type SemaphorGeneratedRecordsSortDirection = "asc" | "desc";
|
|
587
602
|
|
|
588
603
|
export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
@@ -593,11 +608,11 @@ export type SemaphorGeneratedRecordsSort<TSortKey extends string = string> = {
|
|
|
593
608
|
export type SemaphorGeneratedRecordsSortParams<TSortKey extends string = string> = {
|
|
594
609
|
sort?: SemaphorGeneratedRecordsSort<TSortKey> | null;
|
|
595
610
|
};
|
|
596
|
-
` : ""}${
|
|
611
|
+
` : ""}${a ? `export type SemaphorGeneratedServerPaginationParams = {
|
|
597
612
|
page?: number;
|
|
598
613
|
pageSize?: number;
|
|
599
614
|
};
|
|
600
|
-
` : ""}${t &&
|
|
615
|
+
` : ""}${t && a ? `export type SemaphorGeneratedRecordsQueryParams<TSortKey extends string = string> =
|
|
601
616
|
SemaphorGeneratedServerPaginationParams &
|
|
602
617
|
SemaphorGeneratedRecordsSortParams<TSortKey>;
|
|
603
618
|
` : ""}
|
|
@@ -634,7 +649,7 @@ ${t ? `function resolveRecordsOrderBy<TSortKey extends string>(
|
|
|
634
649
|
};
|
|
635
650
|
}
|
|
636
651
|
` : ""}
|
|
637
|
-
${
|
|
652
|
+
${a ? `function resolveServerTablePagination(
|
|
638
653
|
params: SemaphorGeneratedServerPaginationParams,
|
|
639
654
|
defaultPageSize: number,
|
|
640
655
|
) {
|
|
@@ -646,112 +661,112 @@ ${i ? `function resolveServerTablePagination(
|
|
|
646
661
|
` : ""}
|
|
647
662
|
`;
|
|
648
663
|
}
|
|
649
|
-
function
|
|
650
|
-
var
|
|
651
|
-
const n =
|
|
664
|
+
function Te(e) {
|
|
665
|
+
var a, p;
|
|
666
|
+
const n = $((a = e.raw.sdkSpec) == null ? void 0 : a.spec) || {}, { kind: r, id: o, ...t } = n;
|
|
652
667
|
return {
|
|
653
668
|
...t,
|
|
654
669
|
id: e.raw.id,
|
|
655
|
-
label: ((
|
|
670
|
+
label: ((p = e.raw.visualSpec) == null ? void 0 : p.title) || e.raw.title || t.label
|
|
656
671
|
};
|
|
657
672
|
}
|
|
658
|
-
function
|
|
659
|
-
var
|
|
660
|
-
const r = [], o =
|
|
661
|
-
for (const
|
|
662
|
-
|
|
663
|
-
for (const
|
|
664
|
-
return
|
|
665
|
-
r.map((
|
|
666
|
-
const
|
|
667
|
-
if (!(!
|
|
673
|
+
function z(e, n) {
|
|
674
|
+
var a, p;
|
|
675
|
+
const r = [], o = $((a = e.raw.sdkSpec) == null ? void 0 : a.spec) || {};
|
|
676
|
+
for (const f of q(o.fields)) g(r, f);
|
|
677
|
+
g(r, o.dateField), g(r, (p = $(o.orderBy)) == null ? void 0 : p.field);
|
|
678
|
+
for (const f of e.raw.fields || []) g(r, f);
|
|
679
|
+
return X(
|
|
680
|
+
r.map((f) => {
|
|
681
|
+
const h = R(f, n);
|
|
682
|
+
if (!(!f.name || !h))
|
|
668
683
|
return {
|
|
669
|
-
key:
|
|
670
|
-
fieldName:
|
|
671
|
-
rawName:
|
|
672
|
-
label:
|
|
684
|
+
key: h,
|
|
685
|
+
fieldName: h,
|
|
686
|
+
rawName: f.name,
|
|
687
|
+
label: f.label || f.name
|
|
673
688
|
};
|
|
674
|
-
}).filter(
|
|
675
|
-
(
|
|
689
|
+
}).filter(O),
|
|
690
|
+
(f) => f.key
|
|
676
691
|
);
|
|
677
692
|
}
|
|
678
|
-
function
|
|
693
|
+
function Qe({
|
|
679
694
|
view: e,
|
|
680
695
|
contract: n,
|
|
681
696
|
sortFields: r,
|
|
682
697
|
defaultField: o
|
|
683
698
|
}) {
|
|
684
|
-
var
|
|
685
|
-
const t = new Set(r.map((
|
|
699
|
+
var h, y;
|
|
700
|
+
const t = new Set(r.map((i) => i.key));
|
|
686
701
|
if (o && t.has(o))
|
|
687
702
|
return o;
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
return
|
|
691
|
-
const
|
|
692
|
-
return
|
|
703
|
+
const a = r.filter((i) => i.rawName === o);
|
|
704
|
+
if (a.length === 1)
|
|
705
|
+
return a[0].key;
|
|
706
|
+
const p = $((h = e.raw.sdkSpec) == null ? void 0 : h.spec), f = R((y = $(p == null ? void 0 : p.orderBy)) == null ? void 0 : y.field, n);
|
|
707
|
+
return f && t.has(f) ? f : void 0;
|
|
693
708
|
}
|
|
694
|
-
function
|
|
709
|
+
function _e({
|
|
695
710
|
viewName: e,
|
|
696
711
|
supportsPagination: n,
|
|
697
712
|
supportsSort: r
|
|
698
713
|
}) {
|
|
699
714
|
return n && r ? `SemaphorGeneratedRecordsQueryParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>` : r ? `SemaphorGeneratedRecordsSortParams<Extract<keyof typeof recordsSortFieldsForView.${e}, string>>` : "SemaphorGeneratedServerPaginationParams";
|
|
700
715
|
}
|
|
701
|
-
function
|
|
702
|
-
const n = e.views.map((
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
if (!
|
|
716
|
+
function Pe(e) {
|
|
717
|
+
const n = e.views.map((i) => {
|
|
718
|
+
const c = De(e, i.raw.id).map((u) => {
|
|
719
|
+
const d = u.inputId, m = R(u.fieldRef, e);
|
|
720
|
+
if (!d || !m)
|
|
706
721
|
return "";
|
|
707
|
-
const
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
else if (Array.isArray(
|
|
711
|
-
const
|
|
712
|
-
var
|
|
713
|
-
return (
|
|
722
|
+
const l = [`field: fields.${m}`];
|
|
723
|
+
if (u.relationshipHint)
|
|
724
|
+
l.push(`relationshipHint: ${k(u.relationshipHint)}`);
|
|
725
|
+
else if (Array.isArray(u.relationshipsUsed) && u.relationshipsUsed.length > 0) {
|
|
726
|
+
const b = u.relationshipsUsed.map((F) => {
|
|
727
|
+
var x;
|
|
728
|
+
return (x = $(F)) == null ? void 0 : x.id;
|
|
714
729
|
}).filter((F) => typeof F == "string" && F.length > 0);
|
|
715
|
-
|
|
730
|
+
b.length > 0 && l.push(`relationshipHint: ${k({ relationshipIds: b })}`);
|
|
716
731
|
}
|
|
717
|
-
const
|
|
718
|
-
return ` if (${
|
|
719
|
-
inputs.push(semaphor.bindInput(${
|
|
732
|
+
const w = `inputHandles[${JSON.stringify(d)}]`;
|
|
733
|
+
return ` if (${w}) {
|
|
734
|
+
inputs.push(semaphor.bindInput(${w}, { ${l.join(", ")} }));
|
|
720
735
|
}`;
|
|
721
736
|
}).filter(Boolean).join(`
|
|
722
737
|
`);
|
|
723
|
-
return { view:
|
|
724
|
-
}), r = n.some((
|
|
725
|
-
const
|
|
726
|
-
return ` ${
|
|
738
|
+
return { view: i, renderedBindings: c };
|
|
739
|
+
}), r = n.some((i) => i.renderedBindings.length > 0), o = n.map(({ view: i, renderedBindings: I }) => {
|
|
740
|
+
const c = I ? "inputHandles" : "_inputHandles";
|
|
741
|
+
return ` ${i.name}(${c}: SemaphorGeneratedInputHandleMap): SemaphorInputReference[] {
|
|
727
742
|
const inputs: SemaphorInputReference[] = [];
|
|
728
743
|
${I}
|
|
729
744
|
return inputs;
|
|
730
745
|
},`;
|
|
731
746
|
}).join(`
|
|
732
747
|
|
|
733
|
-
`), t = e.views.map((
|
|
748
|
+
`), t = e.views.map((i) => ` ${i.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
|
|
734
749
|
return {
|
|
735
|
-
inputs: inputsForView.${
|
|
736
|
-
debug: queryDebugForView.${
|
|
750
|
+
inputs: inputsForView.${i.name}(inputHandles),
|
|
751
|
+
debug: queryDebugForView.${i.name},
|
|
737
752
|
};
|
|
738
753
|
},`).join(`
|
|
739
754
|
|
|
740
|
-
`),
|
|
741
|
-
return inputsForView.${
|
|
742
|
-
`),
|
|
743
|
-
return queryOptionsForView.${
|
|
744
|
-
`),
|
|
755
|
+
`), a = e.views.map((i) => ` case ${JSON.stringify(i.raw.id)}:
|
|
756
|
+
return inputsForView.${i.name}(inputHandles);`).join(`
|
|
757
|
+
`), p = e.views.map((i) => ` case ${JSON.stringify(i.raw.id)}:
|
|
758
|
+
return queryOptionsForView.${i.name}(inputHandles);`).join(`
|
|
759
|
+
`), f = e.views.length > 0, h = f ? "inputHandles" : "_inputHandles", y = [
|
|
745
760
|
r ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
|
|
746
761
|
'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',
|
|
747
762
|
r ? 'import { fields } from "./fields";' : void 0,
|
|
748
763
|
'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',
|
|
749
|
-
|
|
764
|
+
f ? 'import { queryDebugForView } from "./metadata";' : void 0,
|
|
750
765
|
'import type { SemaphorGeneratedQueryViewId } from "./metadata";'
|
|
751
|
-
].filter(
|
|
766
|
+
].filter(O).join(`
|
|
752
767
|
`);
|
|
753
|
-
return `${
|
|
754
|
-
${
|
|
768
|
+
return `${v}
|
|
769
|
+
${y}
|
|
755
770
|
|
|
756
771
|
export const inputsForView = {
|
|
757
772
|
${o}
|
|
@@ -763,26 +778,26 @@ ${t}
|
|
|
763
778
|
|
|
764
779
|
export function inputsForViewId(
|
|
765
780
|
viewId: SemaphorGeneratedQueryViewId,
|
|
766
|
-
${
|
|
781
|
+
${h}: SemaphorGeneratedInputHandleMap,
|
|
767
782
|
): SemaphorInputReference[] {
|
|
768
783
|
switch (viewId) {
|
|
769
|
-
${
|
|
784
|
+
${a}
|
|
770
785
|
}
|
|
771
786
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
772
787
|
}
|
|
773
788
|
|
|
774
789
|
export function queryOptionsForViewId(
|
|
775
790
|
viewId: SemaphorGeneratedQueryViewId,
|
|
776
|
-
${
|
|
791
|
+
${h}: SemaphorGeneratedInputHandleMap,
|
|
777
792
|
): SemaphorQueryRuntimeOptions {
|
|
778
793
|
switch (viewId) {
|
|
779
|
-
${
|
|
794
|
+
${p}
|
|
780
795
|
}
|
|
781
796
|
throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
|
|
782
797
|
}
|
|
783
798
|
`;
|
|
784
799
|
}
|
|
785
|
-
function
|
|
800
|
+
function De(e, n) {
|
|
786
801
|
return e.filterContracts.flatMap(
|
|
787
802
|
(r) => (r.bindings || []).filter((o) => o.viewId === n).map((o) => ({
|
|
788
803
|
inputId: r.inputId,
|
|
@@ -792,51 +807,114 @@ function _e(e, n) {
|
|
|
792
807
|
}))
|
|
793
808
|
);
|
|
794
809
|
}
|
|
795
|
-
function
|
|
796
|
-
const n = e.views.map((
|
|
797
|
-
const
|
|
798
|
-
const
|
|
799
|
-
return
|
|
810
|
+
function Ue(e) {
|
|
811
|
+
const n = e.views.map((c) => {
|
|
812
|
+
const d = Y(c, e).map((m) => {
|
|
813
|
+
const l = R(m.raw, e);
|
|
814
|
+
return l ? ` ${m.name}: fields.${l},` : "";
|
|
800
815
|
}).filter(Boolean).join(`
|
|
801
816
|
`);
|
|
802
|
-
return ` ${
|
|
803
|
-
${
|
|
817
|
+
return ` ${c.name}: {
|
|
818
|
+
${d}
|
|
819
|
+
},`;
|
|
820
|
+
}).join(`
|
|
821
|
+
`), r = e.views.map((c) => {
|
|
822
|
+
const d = L(c, e).map((m) => {
|
|
823
|
+
const l = R(m.raw, e);
|
|
824
|
+
return l ? ` ${m.name}: fields.${l},` : "";
|
|
825
|
+
}).filter(Boolean).join(`
|
|
826
|
+
`);
|
|
827
|
+
return ` ${c.name}: {
|
|
828
|
+
${d}
|
|
829
|
+
},`;
|
|
830
|
+
}).join(`
|
|
831
|
+
`), o = e.views.map((c) => {
|
|
832
|
+
const u = L(c, e), d = Ze(u), m = We(u), l = u.map((w) => {
|
|
833
|
+
const b = Array.from(
|
|
834
|
+
new Set(
|
|
835
|
+
ye(w.raw).filter((F) => m.has(F))
|
|
836
|
+
)
|
|
837
|
+
);
|
|
838
|
+
return ` ${w.name}: metricKeysForField(metricFieldsForView.${c.name}.${w.name}, { allowNameFallback: ${d.has(w.raw.name) ? "false" : "true"}, excludedKeys: ${k(b)} }),`;
|
|
839
|
+
}).join(`
|
|
840
|
+
`);
|
|
841
|
+
return ` ${c.name}: {
|
|
842
|
+
${l}
|
|
804
843
|
},`;
|
|
805
844
|
}).join(`
|
|
806
|
-
`),
|
|
807
|
-
const
|
|
808
|
-
|
|
845
|
+
`), t = e.views.map((c) => {
|
|
846
|
+
const d = L(c, e).map((m) => ` ${m.name}: semaphorMetricMeasureBindingKey(metricFieldsForView.${c.name}.${m.name}),`).join(`
|
|
847
|
+
`);
|
|
848
|
+
return ` ${c.name}: {
|
|
849
|
+
${d}
|
|
850
|
+
},`;
|
|
809
851
|
}).join(`
|
|
810
|
-
`),
|
|
811
|
-
const
|
|
852
|
+
`), a = e.views.map((c) => {
|
|
853
|
+
const u = L(c, e);
|
|
854
|
+
if (u.length === 0)
|
|
855
|
+
return ` ${c.name}(): Record<keyof typeof metricFieldsForView.${c.name}, unknown> {
|
|
856
|
+
return {};
|
|
857
|
+
},`;
|
|
858
|
+
const d = Ye(c, u), m = u.map((l) => {
|
|
859
|
+
const w = `metricMeasureKeysForView.${c.name}.${l.name}`, b = `metricMeasureBindingKeysForView.${c.name}.${l.name}`, F = d.has(l.name) ? `readMetricValueByBindingWithFallback(measures, measureBindings, ${b}, ${w}, scalarValue)` : `readMetricValueByBinding(measures, measureBindings, ${b}, ${w})`;
|
|
860
|
+
return ` ${l.name}: ${F},`;
|
|
861
|
+
}).join(`
|
|
812
862
|
`);
|
|
813
|
-
return ` ${
|
|
863
|
+
return ` ${c.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${c.name}, unknown> {
|
|
864
|
+
const measures = result?.measures;
|
|
865
|
+
const measureBindings = result?.measureBindings;
|
|
866
|
+
const scalarValue = result?.value;
|
|
814
867
|
return {
|
|
815
|
-
${
|
|
868
|
+
${m}
|
|
816
869
|
};
|
|
817
870
|
},`;
|
|
818
871
|
}).join(`
|
|
819
872
|
|
|
820
|
-
`),
|
|
821
|
-
const
|
|
873
|
+
`), p = e.views.map((c) => {
|
|
874
|
+
const u = Le(c, e);
|
|
875
|
+
return ` ${c.name}: ${k(u)},`;
|
|
876
|
+
}).join(`
|
|
877
|
+
`), f = e.views.map((c) => {
|
|
878
|
+
const d = Y(c, e).map((m) => ` ${m.name}: resolveColumnKey(columns, fieldsForView.${c.name}.${m.name}),`).join(`
|
|
822
879
|
`);
|
|
823
|
-
return ` ${
|
|
880
|
+
return ` ${c.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${c.name}, string | undefined> {
|
|
824
881
|
return {
|
|
825
|
-
${
|
|
882
|
+
${d}
|
|
883
|
+
};
|
|
884
|
+
},`;
|
|
885
|
+
}).join(`
|
|
886
|
+
|
|
887
|
+
`), h = e.views.map((c) => {
|
|
888
|
+
const d = Y(c, e).map((m) => ` ${m.name}: readCell(row, columns, fieldsForView.${c.name}.${m.name}),`).join(`
|
|
889
|
+
`);
|
|
890
|
+
return ` ${c.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${c.name}, unknown> {
|
|
891
|
+
return {
|
|
892
|
+
${d}
|
|
826
893
|
};
|
|
827
894
|
},`;
|
|
828
895
|
}).join(`
|
|
829
896
|
|
|
830
|
-
`),
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
897
|
+
`), y = n.includes("fields.") || r.includes("fields."), I = [
|
|
898
|
+
`import { ${[
|
|
899
|
+
"type SemaphorFieldRef",
|
|
900
|
+
"type SemaphorResultColumn",
|
|
901
|
+
"semaphorMetricMeasureBindingKey"
|
|
902
|
+
].filter(O).join(", ")} } from "react-semaphor/data-app-sdk";`,
|
|
903
|
+
y ? 'import { fields } from "./fields";' : void 0
|
|
904
|
+
].filter(O).join(`
|
|
834
905
|
`);
|
|
835
|
-
return `${
|
|
836
|
-
${
|
|
906
|
+
return `${v}
|
|
907
|
+
${I}
|
|
837
908
|
|
|
838
909
|
export type SemaphorGeneratedRow = Record<string, unknown>;
|
|
839
910
|
export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
|
|
911
|
+
export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
|
|
912
|
+
export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
|
|
913
|
+
export type SemaphorGeneratedMetricResult = {
|
|
914
|
+
readonly measures?: SemaphorGeneratedMetricMeasures;
|
|
915
|
+
readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
|
|
916
|
+
readonly value?: unknown;
|
|
917
|
+
} | null | undefined;
|
|
840
918
|
export type SemaphorGeneratedTableColumn = {
|
|
841
919
|
readonly key: string;
|
|
842
920
|
readonly label: string;
|
|
@@ -849,18 +927,34 @@ export const fieldsForView = {
|
|
|
849
927
|
${n}
|
|
850
928
|
} as const;
|
|
851
929
|
|
|
852
|
-
export const
|
|
930
|
+
export const metricFieldsForView = {
|
|
853
931
|
${r}
|
|
854
932
|
} as const;
|
|
855
933
|
|
|
856
|
-
export const
|
|
934
|
+
export const metricMeasureKeysForView = {
|
|
857
935
|
${o}
|
|
858
936
|
} as const;
|
|
859
937
|
|
|
860
|
-
export const
|
|
938
|
+
export const metricMeasureBindingKeysForView = {
|
|
861
939
|
${t}
|
|
862
940
|
} as const;
|
|
863
941
|
|
|
942
|
+
export const tableColumnsForView = {
|
|
943
|
+
${p}
|
|
944
|
+
} as const;
|
|
945
|
+
|
|
946
|
+
export const columnKeysForView = {
|
|
947
|
+
${f}
|
|
948
|
+
} as const;
|
|
949
|
+
|
|
950
|
+
export const rowValuesForView = {
|
|
951
|
+
${h}
|
|
952
|
+
} as const;
|
|
953
|
+
|
|
954
|
+
export const metricValuesForView = {
|
|
955
|
+
${a}
|
|
956
|
+
} as const;
|
|
957
|
+
|
|
864
958
|
export function resolveColumnKey(
|
|
865
959
|
columns: SemaphorGeneratedColumns,
|
|
866
960
|
field: SemaphorFieldRef,
|
|
@@ -902,6 +996,157 @@ export function readStringCell(
|
|
|
902
996
|
return value === null || value === undefined ? "" : String(value);
|
|
903
997
|
}
|
|
904
998
|
|
|
999
|
+
export function readMetricValue(
|
|
1000
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1001
|
+
field: SemaphorFieldRef,
|
|
1002
|
+
): unknown {
|
|
1003
|
+
return readMetricValueByKeys(measures, metricKeysForField(field));
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export function readMetricValueByKeys(
|
|
1007
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1008
|
+
keys: readonly string[],
|
|
1009
|
+
): unknown {
|
|
1010
|
+
if (!measures) {
|
|
1011
|
+
return undefined;
|
|
1012
|
+
}
|
|
1013
|
+
for (const key of keys) {
|
|
1014
|
+
if (Object.prototype.hasOwnProperty.call(measures, key)) {
|
|
1015
|
+
return measures[key];
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return undefined;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
export function readMetricValueByBinding(
|
|
1022
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1023
|
+
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
1024
|
+
bindingKey: string,
|
|
1025
|
+
fallbackKeys: readonly string[],
|
|
1026
|
+
): unknown {
|
|
1027
|
+
const resultKey = measureBindings?.[bindingKey];
|
|
1028
|
+
if (resultKey && measures && Object.prototype.hasOwnProperty.call(measures, resultKey)) {
|
|
1029
|
+
return measures[resultKey];
|
|
1030
|
+
}
|
|
1031
|
+
return readMetricValueByKeys(measures, fallbackKeys);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
export function readMetricValueByKeysWithFallback(
|
|
1035
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1036
|
+
keys: readonly string[],
|
|
1037
|
+
fallbackValue: unknown,
|
|
1038
|
+
): unknown {
|
|
1039
|
+
const value = readMetricValueByKeys(measures, keys);
|
|
1040
|
+
return value === undefined ? fallbackValue : value;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
export function readMetricValueByBindingWithFallback(
|
|
1044
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1045
|
+
measureBindings: SemaphorGeneratedMetricMeasureBindings,
|
|
1046
|
+
bindingKey: string,
|
|
1047
|
+
fallbackKeys: readonly string[],
|
|
1048
|
+
fallbackValue: unknown,
|
|
1049
|
+
): unknown {
|
|
1050
|
+
const value = readMetricValueByBinding(measures, measureBindings, bindingKey, fallbackKeys);
|
|
1051
|
+
return value === undefined ? fallbackValue : value;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
export function readNumberMetricValue(
|
|
1055
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1056
|
+
field: SemaphorFieldRef,
|
|
1057
|
+
): number | null {
|
|
1058
|
+
const value = readMetricValue(measures, field);
|
|
1059
|
+
if (typeof value === "number") {
|
|
1060
|
+
return Number.isFinite(value) ? value : null;
|
|
1061
|
+
}
|
|
1062
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1063
|
+
const parsed = Number(value);
|
|
1064
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1065
|
+
}
|
|
1066
|
+
return null;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
export function readStringMetricValue(
|
|
1070
|
+
measures: SemaphorGeneratedMetricMeasures,
|
|
1071
|
+
field: SemaphorFieldRef,
|
|
1072
|
+
): string {
|
|
1073
|
+
const value = readMetricValue(measures, field);
|
|
1074
|
+
return value === null || value === undefined ? "" : String(value);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
export function metricKeysForField(
|
|
1078
|
+
field: SemaphorFieldRef,
|
|
1079
|
+
options: { allowNameFallback?: boolean; excludedKeys?: readonly string[] } = {},
|
|
1080
|
+
): string[] {
|
|
1081
|
+
const prefixes = metricKeyPrefixesForSource(field.source);
|
|
1082
|
+
const aggregate = metricAggregateForField(field);
|
|
1083
|
+
const excludedKeys = new Set(options.excludedKeys || []);
|
|
1084
|
+
return uniqueStrings([
|
|
1085
|
+
metricQualifiedKeyForField(field),
|
|
1086
|
+
...prefixes.map((prefix) => \`\${prefix}.\${field.name}\`),
|
|
1087
|
+
\`\${aggregate.toLowerCase()}_\${field.name}\`,
|
|
1088
|
+
\`\${aggregate}_\${field.name}\`,
|
|
1089
|
+
\`\${field.name}_\${aggregate.toLowerCase()}\`,
|
|
1090
|
+
\`\${field.name}_\${aggregate}\`,
|
|
1091
|
+
...(options.allowNameFallback === false ? [] : [field.name]),
|
|
1092
|
+
]).filter((key) => !excludedKeys.has(key));
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function metricQualifiedKeyForField(field: SemaphorFieldRef): string {
|
|
1096
|
+
return semaphorMetricMeasureBindingKey(field);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function metricAggregateForField(field: SemaphorFieldRef): string {
|
|
1100
|
+
return stringProperty(field as Record<string, unknown>, "aggregate")?.toUpperCase() || "SUM";
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
function metricKeyPrefixesForSource(
|
|
1104
|
+
source: SemaphorFieldRef["source"] | undefined,
|
|
1105
|
+
): string[] {
|
|
1106
|
+
if (!source) {
|
|
1107
|
+
return [];
|
|
1108
|
+
}
|
|
1109
|
+
const sourceRecord = source as Record<string, unknown>;
|
|
1110
|
+
if (source.kind === "semantic") {
|
|
1111
|
+
const prefixes: string[] = [];
|
|
1112
|
+
const datasetName = stringProperty(sourceRecord, "datasetName");
|
|
1113
|
+
const datasetId = stringProperty(sourceRecord, "datasetId");
|
|
1114
|
+
if (datasetName) {
|
|
1115
|
+
prefixes.push(datasetName);
|
|
1116
|
+
}
|
|
1117
|
+
if (datasetId) {
|
|
1118
|
+
prefixes.push(datasetId);
|
|
1119
|
+
}
|
|
1120
|
+
return uniqueStrings(prefixes);
|
|
1121
|
+
}
|
|
1122
|
+
if (source.kind === "physical") {
|
|
1123
|
+
const prefixes: string[] = [];
|
|
1124
|
+
const databaseName = stringProperty(sourceRecord, "databaseName");
|
|
1125
|
+
const schemaName = stringProperty(sourceRecord, "schemaName");
|
|
1126
|
+
const tableName = stringProperty(sourceRecord, "tableName");
|
|
1127
|
+
if (tableName) {
|
|
1128
|
+
prefixes.push(tableName);
|
|
1129
|
+
}
|
|
1130
|
+
if (schemaName && tableName) {
|
|
1131
|
+
prefixes.push(\`\${schemaName}.\${tableName}\`);
|
|
1132
|
+
}
|
|
1133
|
+
if (databaseName && schemaName && tableName) {
|
|
1134
|
+
prefixes.push(\`\${databaseName}.\${schemaName}.\${tableName}\`);
|
|
1135
|
+
}
|
|
1136
|
+
return uniqueStrings(prefixes);
|
|
1137
|
+
}
|
|
1138
|
+
return [];
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function stringProperty(record: Record<string, unknown>, key: string): string | undefined {
|
|
1142
|
+
const value = record[key];
|
|
1143
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function uniqueStrings(values: string[]): string[] {
|
|
1147
|
+
return Array.from(new Set(values.filter((value) => value.length > 0)));
|
|
1148
|
+
}
|
|
1149
|
+
|
|
905
1150
|
function resolveColumn(
|
|
906
1151
|
columns: SemaphorGeneratedColumns,
|
|
907
1152
|
field: SemaphorFieldRef,
|
|
@@ -1006,53 +1251,53 @@ function sourcesReferToSameDataset(
|
|
|
1006
1251
|
}
|
|
1007
1252
|
`;
|
|
1008
1253
|
}
|
|
1009
|
-
function
|
|
1010
|
-
const r =
|
|
1011
|
-
(
|
|
1254
|
+
function Le(e, n) {
|
|
1255
|
+
const r = Y(e, n), o = new Map(
|
|
1256
|
+
(K(e) ? z(e, n) : []).map((t) => [t.fieldName, t.key])
|
|
1012
1257
|
);
|
|
1013
1258
|
return r.map((t) => {
|
|
1014
|
-
const
|
|
1015
|
-
return
|
|
1259
|
+
const a = R(t.raw, n), p = a ? o.get(a) : void 0;
|
|
1260
|
+
return A({
|
|
1016
1261
|
key: t.name,
|
|
1017
1262
|
label: t.raw.label || t.raw.name,
|
|
1018
1263
|
dataType: t.raw.dataType,
|
|
1019
|
-
sortable: !!
|
|
1020
|
-
sortKey:
|
|
1264
|
+
sortable: !!p,
|
|
1265
|
+
sortKey: p
|
|
1021
1266
|
});
|
|
1022
1267
|
});
|
|
1023
1268
|
}
|
|
1024
|
-
function
|
|
1025
|
-
const n = e.checklist.filterScopeByInput || [], r = e.checklist.requiredDevtools || {}, o = e.summary.views.map((
|
|
1026
|
-
|
|
1269
|
+
function Je(e) {
|
|
1270
|
+
const n = e.checklist.filterScopeByInput || [], r = e.checklist.requiredDevtools || {}, o = e.summary.views.map((i) => i.id).filter(Boolean), t = e.views.map((i) => i.raw.id).filter(Boolean), a = e.inputs.map((i) => i.raw.id).filter(Boolean), p = e.optionQueries.map((i) => i.raw.id || `${i.input.raw.id}-options`).filter(Boolean), f = Object.fromEntries(t.map((i) => [
|
|
1271
|
+
i,
|
|
1027
1272
|
e.filterContracts.filter(
|
|
1028
|
-
(I) => Array.isArray(I.appliesToViewIds) && I.appliesToViewIds.includes(
|
|
1273
|
+
(I) => Array.isArray(I.appliesToViewIds) && I.appliesToViewIds.includes(i)
|
|
1029
1274
|
).map((I) => I.inputId)
|
|
1030
|
-
])),
|
|
1031
|
-
|
|
1275
|
+
])), h = Object.fromEntries(e.views.map((i) => [
|
|
1276
|
+
i.raw.id,
|
|
1032
1277
|
{
|
|
1033
|
-
title:
|
|
1034
|
-
visual:
|
|
1035
|
-
visualSpec:
|
|
1036
|
-
queryKind:
|
|
1037
|
-
sdkBuilder:
|
|
1278
|
+
title: i.raw.title,
|
|
1279
|
+
visual: i.raw.visual,
|
|
1280
|
+
visualSpec: i.raw.visualSpec,
|
|
1281
|
+
queryKind: i.raw.queryKind,
|
|
1282
|
+
sdkBuilder: i.raw.sdkBuilder
|
|
1038
1283
|
}
|
|
1039
|
-
])),
|
|
1040
|
-
var I,
|
|
1284
|
+
])), y = Object.fromEntries(e.views.map((i) => {
|
|
1285
|
+
var I, c, u;
|
|
1041
1286
|
return [
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
viewId:
|
|
1045
|
-
viewTitle: ((I =
|
|
1046
|
-
visualType: (
|
|
1047
|
-
title: ((
|
|
1287
|
+
i.name,
|
|
1288
|
+
A({
|
|
1289
|
+
viewId: i.raw.id,
|
|
1290
|
+
viewTitle: ((I = i.raw.visualSpec) == null ? void 0 : I.title) || i.raw.title,
|
|
1291
|
+
visualType: (c = i.raw.visualSpec) == null ? void 0 : c.visualType,
|
|
1292
|
+
title: ((u = i.raw.visualSpec) == null ? void 0 : u.title) || i.raw.title
|
|
1048
1293
|
})
|
|
1049
1294
|
];
|
|
1050
1295
|
}));
|
|
1051
|
-
return `${
|
|
1052
|
-
export const generatedViewIds = ${
|
|
1053
|
-
export const generatedQueryViewIds = ${
|
|
1054
|
-
export const generatedInputIds = ${
|
|
1055
|
-
export const generatedInputOptionQueryIds = ${
|
|
1296
|
+
return `${v}
|
|
1297
|
+
export const generatedViewIds = ${k(o)} as const;
|
|
1298
|
+
export const generatedQueryViewIds = ${k(t)} as const;
|
|
1299
|
+
export const generatedInputIds = ${k(a)} as const;
|
|
1300
|
+
export const generatedInputOptionQueryIds = ${k(p)} as const;
|
|
1056
1301
|
|
|
1057
1302
|
export type SemaphorGeneratedViewId = typeof generatedViewIds[number];
|
|
1058
1303
|
export type SemaphorGeneratedQueryViewId = typeof generatedQueryViewIds[number];
|
|
@@ -1071,8 +1316,8 @@ export type SemaphorGeneratedFilterContract = {
|
|
|
1071
1316
|
readonly [key: string]: unknown;
|
|
1072
1317
|
};
|
|
1073
1318
|
|
|
1074
|
-
export const generatedInputIdsForView = ${
|
|
1075
|
-
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${
|
|
1319
|
+
export const generatedInputIdsForView = ${k(f)} as const;
|
|
1320
|
+
export const generatedFilterContracts: readonly SemaphorGeneratedFilterContract[] = ${k(e.filterContracts)} as const;
|
|
1076
1321
|
|
|
1077
1322
|
export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
1078
1323
|
return generatedFilterContracts.filter((filterContract) =>
|
|
@@ -1080,9 +1325,9 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
|
|
|
1080
1325
|
);
|
|
1081
1326
|
}
|
|
1082
1327
|
|
|
1083
|
-
export const queryDebugForView = ${
|
|
1328
|
+
export const queryDebugForView = ${k(y)} as const;
|
|
1084
1329
|
|
|
1085
|
-
export const semaphorGeneratedContractMetadata = ${
|
|
1330
|
+
export const semaphorGeneratedContractMetadata = ${k({
|
|
1086
1331
|
schemaVersion: "semaphor-generated-data-app-contract/v1",
|
|
1087
1332
|
title: e.title,
|
|
1088
1333
|
requiredDevtools: r,
|
|
@@ -1090,16 +1335,16 @@ export const semaphorGeneratedContractMetadata = ${b({
|
|
|
1090
1335
|
filterScopeByInput: n,
|
|
1091
1336
|
generatedViewIds: o,
|
|
1092
1337
|
generatedQueryViewIds: t,
|
|
1093
|
-
generatedInputIds:
|
|
1094
|
-
generatedInputOptionQueryIds:
|
|
1095
|
-
generatedInputIdsForView:
|
|
1096
|
-
visualSpecs:
|
|
1338
|
+
generatedInputIds: a,
|
|
1339
|
+
generatedInputOptionQueryIds: p,
|
|
1340
|
+
generatedInputIdsForView: f,
|
|
1341
|
+
visualSpecs: h,
|
|
1097
1342
|
presentationViews: e.presentationViews
|
|
1098
1343
|
})} as const;
|
|
1099
1344
|
`;
|
|
1100
1345
|
}
|
|
1101
|
-
function
|
|
1102
|
-
return `${
|
|
1346
|
+
function ze() {
|
|
1347
|
+
return `${v}
|
|
1103
1348
|
export * from "./sources";
|
|
1104
1349
|
export * from "./fields";
|
|
1105
1350
|
export * from "./inputs";
|
|
@@ -1109,82 +1354,134 @@ export * from "./accessors";
|
|
|
1109
1354
|
export * from "./metadata";
|
|
1110
1355
|
`;
|
|
1111
1356
|
}
|
|
1112
|
-
function
|
|
1357
|
+
function T(e, n) {
|
|
1113
1358
|
if (!(!n || typeof n != "object")) {
|
|
1114
1359
|
if (Array.isArray(n)) {
|
|
1115
|
-
for (const r of n)
|
|
1360
|
+
for (const r of n) T(e, r);
|
|
1116
1361
|
return;
|
|
1117
1362
|
}
|
|
1118
|
-
N(n) &&
|
|
1363
|
+
N(n) && g(e, P(n));
|
|
1119
1364
|
for (const r of Object.values(n))
|
|
1120
|
-
|
|
1365
|
+
T(e, r);
|
|
1121
1366
|
}
|
|
1122
1367
|
}
|
|
1123
|
-
function
|
|
1368
|
+
function Y(e, n) {
|
|
1124
1369
|
const r = [];
|
|
1125
|
-
if (
|
|
1370
|
+
if (Xe(r, e.raw.sdkSpec), r.length === 0)
|
|
1126
1371
|
for (const t of e.raw.fields || [])
|
|
1127
|
-
|
|
1128
|
-
const o =
|
|
1129
|
-
r.filter((t) => t.name &&
|
|
1372
|
+
g(r, t);
|
|
1373
|
+
const o = X(
|
|
1374
|
+
r.filter((t) => t.name && R(t, n)).map((t) => ({ raw: t, key: D(t), name: "" })),
|
|
1130
1375
|
(t) => t.key
|
|
1131
1376
|
);
|
|
1132
|
-
return
|
|
1377
|
+
return H(
|
|
1133
1378
|
o,
|
|
1134
|
-
(t) =>
|
|
1379
|
+
(t) => Q(t.raw.label || t.raw.name || "field")
|
|
1135
1380
|
), o;
|
|
1136
1381
|
}
|
|
1137
|
-
function
|
|
1138
|
-
|
|
1382
|
+
function L(e, n) {
|
|
1383
|
+
if (B(e.raw.sdkSpec.builder) !== "metric")
|
|
1384
|
+
return [];
|
|
1385
|
+
const r = $(e.raw.sdkSpec.spec), o = [];
|
|
1386
|
+
g(o, r == null ? void 0 : r.primaryMeasure);
|
|
1387
|
+
for (const a of q(r == null ? void 0 : r.measures))
|
|
1388
|
+
g(o, a);
|
|
1389
|
+
const t = X(
|
|
1390
|
+
o.filter((a) => a.name && R(a, n)).map((a) => ({ raw: a, key: D(a), name: "" })),
|
|
1391
|
+
(a) => a.key
|
|
1392
|
+
);
|
|
1393
|
+
return H(
|
|
1394
|
+
t,
|
|
1395
|
+
(a) => Q(a.raw.label || a.raw.name || "metric")
|
|
1396
|
+
), t;
|
|
1397
|
+
}
|
|
1398
|
+
function Ye(e, n) {
|
|
1399
|
+
if (n.length === 1)
|
|
1400
|
+
return /* @__PURE__ */ new Set([n[0].name]);
|
|
1401
|
+
const r = $(e.raw.sdkSpec.spec);
|
|
1402
|
+
if (!N(r == null ? void 0 : r.primaryMeasure))
|
|
1403
|
+
return /* @__PURE__ */ new Set();
|
|
1404
|
+
const o = D(P(r.primaryMeasure)), t = n.find((a) => a.key === o);
|
|
1405
|
+
return t ? /* @__PURE__ */ new Set([t.name]) : /* @__PURE__ */ new Set();
|
|
1406
|
+
}
|
|
1407
|
+
function We(e) {
|
|
1408
|
+
const n = /* @__PURE__ */ new Map();
|
|
1409
|
+
for (const r of e)
|
|
1410
|
+
for (const o of new Set(ye(r.raw)))
|
|
1411
|
+
n.set(o, (n.get(o) || 0) + 1);
|
|
1412
|
+
return new Set(
|
|
1413
|
+
Array.from(n.entries()).filter(([, r]) => r > 1).map(([r]) => r)
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
function ye(e) {
|
|
1417
|
+
const n = (e.aggregate || "SUM").toUpperCase();
|
|
1418
|
+
return _([
|
|
1419
|
+
`${n.toLowerCase()}_${e.name}`,
|
|
1420
|
+
`${n}_${e.name}`,
|
|
1421
|
+
`${e.name}_${n.toLowerCase()}`,
|
|
1422
|
+
`${e.name}_${n}`,
|
|
1423
|
+
e.name
|
|
1424
|
+
]);
|
|
1425
|
+
}
|
|
1426
|
+
function Ze(e) {
|
|
1427
|
+
const n = /* @__PURE__ */ new Map();
|
|
1428
|
+
for (const r of e)
|
|
1429
|
+
n.set(r.raw.name, (n.get(r.raw.name) || 0) + 1);
|
|
1430
|
+
return new Set(
|
|
1431
|
+
Array.from(n.entries()).filter(([, r]) => r > 1).map(([r]) => r)
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1434
|
+
function Xe(e, n) {
|
|
1435
|
+
const r = $(n.spec);
|
|
1139
1436
|
if (!r)
|
|
1140
1437
|
return;
|
|
1141
1438
|
const o = B(n.builder);
|
|
1142
1439
|
if (o === "records") {
|
|
1143
|
-
for (const t of
|
|
1440
|
+
for (const t of q(r.fields)) g(e, t);
|
|
1144
1441
|
return;
|
|
1145
1442
|
}
|
|
1146
1443
|
if (o === "sql") {
|
|
1147
|
-
for (const t of
|
|
1444
|
+
for (const t of q(r.fields)) g(e, t);
|
|
1148
1445
|
return;
|
|
1149
1446
|
}
|
|
1150
1447
|
if (o === "analysis" || o === "metric") {
|
|
1151
|
-
|
|
1152
|
-
for (const t of
|
|
1153
|
-
for (const t of
|
|
1154
|
-
|
|
1448
|
+
g(e, r.primaryMeasure);
|
|
1449
|
+
for (const t of q(r.measures)) g(e, t);
|
|
1450
|
+
for (const t of q(r.dimensions)) g(e, t);
|
|
1451
|
+
g(e, r.dateField);
|
|
1155
1452
|
return;
|
|
1156
1453
|
}
|
|
1157
1454
|
if (o === "matrix") {
|
|
1158
|
-
const t =
|
|
1159
|
-
for (const
|
|
1160
|
-
for (const
|
|
1161
|
-
for (const
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1455
|
+
const t = le(r.rows), a = le(r.columns), p = q(r.values);
|
|
1456
|
+
for (const f of t) pe(e, f);
|
|
1457
|
+
for (const f of a) pe(e, f);
|
|
1458
|
+
for (const f of p) {
|
|
1459
|
+
const h = $(f);
|
|
1460
|
+
g(e, h == null ? void 0 : h.field), g(e, h == null ? void 0 : h.measure);
|
|
1164
1461
|
}
|
|
1165
1462
|
}
|
|
1166
1463
|
}
|
|
1167
|
-
function
|
|
1464
|
+
function le(e) {
|
|
1168
1465
|
if (Array.isArray(e))
|
|
1169
1466
|
return e;
|
|
1170
|
-
const n =
|
|
1467
|
+
const n = $(e);
|
|
1171
1468
|
return Array.isArray(n == null ? void 0 : n.levels) ? n.levels : [];
|
|
1172
1469
|
}
|
|
1173
|
-
function
|
|
1470
|
+
function pe(e, n) {
|
|
1174
1471
|
var r;
|
|
1175
1472
|
if (N(n)) {
|
|
1176
|
-
|
|
1473
|
+
g(e, n);
|
|
1177
1474
|
return;
|
|
1178
1475
|
}
|
|
1179
|
-
|
|
1476
|
+
g(e, (r = $(n)) == null ? void 0 : r.field);
|
|
1180
1477
|
}
|
|
1181
|
-
function
|
|
1478
|
+
function ce(e) {
|
|
1182
1479
|
var n, r, o, t;
|
|
1183
1480
|
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" || ((o = e == null ? void 0 : e.computation) == null ? void 0 : o.kind) === "unsupported" || (e == null ? void 0 : e.visual) === "text_block" || ((t = e == null ? void 0 : e.visualSpec) == null ? void 0 : t.visualType) === "text_block";
|
|
1184
1481
|
}
|
|
1185
|
-
function
|
|
1186
|
-
const n =
|
|
1187
|
-
return
|
|
1482
|
+
function en(e) {
|
|
1483
|
+
const n = $(e) || {};
|
|
1484
|
+
return A({
|
|
1188
1485
|
id: e.id,
|
|
1189
1486
|
title: e.title,
|
|
1190
1487
|
purpose: e.purpose,
|
|
@@ -1198,77 +1495,77 @@ function Le(e) {
|
|
|
1198
1495
|
description: n.description
|
|
1199
1496
|
});
|
|
1200
1497
|
}
|
|
1201
|
-
function
|
|
1202
|
-
N(n) && e.push(
|
|
1498
|
+
function g(e, n) {
|
|
1499
|
+
N(n) && e.push(P(n));
|
|
1203
1500
|
}
|
|
1204
|
-
function
|
|
1501
|
+
function P(e) {
|
|
1205
1502
|
return {
|
|
1206
1503
|
name: e.name,
|
|
1207
1504
|
label: e.label,
|
|
1208
1505
|
role: e.role,
|
|
1209
1506
|
dataType: e.dataType,
|
|
1210
1507
|
aggregate: e.aggregate,
|
|
1211
|
-
sourceKey: e.sourceKey || (e.source ?
|
|
1508
|
+
sourceKey: e.sourceKey || (e.source ? de(e.source) : void 0),
|
|
1212
1509
|
...e.source ? { source: e.source } : {}
|
|
1213
1510
|
};
|
|
1214
1511
|
}
|
|
1215
|
-
function
|
|
1512
|
+
function nn(e) {
|
|
1216
1513
|
if (!e.source)
|
|
1217
1514
|
return;
|
|
1218
1515
|
const n = {
|
|
1219
1516
|
...e.source,
|
|
1220
1517
|
...e.sourceKey ? { sourceKey: e.sourceKey } : {}
|
|
1221
|
-
}, r =
|
|
1518
|
+
}, r = Se(n);
|
|
1222
1519
|
if (r)
|
|
1223
1520
|
return {
|
|
1224
1521
|
raw: n,
|
|
1225
1522
|
key: r,
|
|
1226
|
-
aliases:
|
|
1523
|
+
aliases: we(n),
|
|
1227
1524
|
name: ""
|
|
1228
1525
|
};
|
|
1229
1526
|
}
|
|
1230
1527
|
function N(e) {
|
|
1231
|
-
const n =
|
|
1528
|
+
const n = $(e);
|
|
1232
1529
|
return !!(n && typeof n.name == "string" && (typeof n.role == "string" || typeof n.dataType == "string" || typeof n.aggregate == "string" || n.source || n.sourceKey));
|
|
1233
1530
|
}
|
|
1234
|
-
function
|
|
1235
|
-
const n =
|
|
1531
|
+
function ge(e) {
|
|
1532
|
+
const n = $(e);
|
|
1236
1533
|
return !!(n && (typeof n.sourceKey == "string" || n.kind === "semantic" || typeof n.datasetName == "string" && typeof n.domainId == "string"));
|
|
1237
1534
|
}
|
|
1238
|
-
function
|
|
1535
|
+
function C(e, n) {
|
|
1239
1536
|
if (e === void 0)
|
|
1240
1537
|
return "undefined";
|
|
1241
1538
|
if (e === null || typeof e == "number" || typeof e == "boolean" || typeof e == "string")
|
|
1242
1539
|
return JSON.stringify(e);
|
|
1243
1540
|
if (Array.isArray(e))
|
|
1244
|
-
return `[${e.map((t) =>
|
|
1541
|
+
return `[${e.map((t) => C(t, n)).join(", ")}]`;
|
|
1245
1542
|
if (N(e)) {
|
|
1246
|
-
const t =
|
|
1543
|
+
const t = R(P(e), n);
|
|
1247
1544
|
if (t) return `fields.${t}`;
|
|
1248
1545
|
}
|
|
1249
|
-
if (
|
|
1250
|
-
const t =
|
|
1546
|
+
if (ge(e)) {
|
|
1547
|
+
const t = he(e, n);
|
|
1251
1548
|
if (t) return `sources.${t}`;
|
|
1252
1549
|
}
|
|
1253
|
-
const r =
|
|
1254
|
-
return r ? `{ ${Object.entries(r).filter(([, t]) => t !== void 0).map(([t,
|
|
1550
|
+
const r = $(e);
|
|
1551
|
+
return r ? `{ ${Object.entries(r).filter(([, t]) => t !== void 0).map(([t, a]) => `${JSON.stringify(t)}: ${C(a, n)}`).join(", ")} }` : JSON.stringify(e);
|
|
1255
1552
|
}
|
|
1256
|
-
function
|
|
1553
|
+
function k(e) {
|
|
1257
1554
|
return JSON.stringify(e, null, 2);
|
|
1258
1555
|
}
|
|
1259
|
-
function
|
|
1556
|
+
function R(e, n) {
|
|
1260
1557
|
if (N(e))
|
|
1261
|
-
return n.fieldNameByKey.get(
|
|
1558
|
+
return n.fieldNameByKey.get(D(P(e)));
|
|
1262
1559
|
}
|
|
1263
|
-
function
|
|
1264
|
-
if (
|
|
1265
|
-
for (const r of
|
|
1560
|
+
function he(e, n) {
|
|
1561
|
+
if (ge(e))
|
|
1562
|
+
for (const r of Z(e)) {
|
|
1266
1563
|
const o = n.sourceNameByKey.get(r);
|
|
1267
1564
|
if (o)
|
|
1268
1565
|
return o;
|
|
1269
1566
|
}
|
|
1270
1567
|
}
|
|
1271
|
-
function
|
|
1568
|
+
function D(e) {
|
|
1272
1569
|
return [
|
|
1273
1570
|
e.sourceKey || "",
|
|
1274
1571
|
e.name || "",
|
|
@@ -1276,29 +1573,29 @@ function ie(e) {
|
|
|
1276
1573
|
e.aggregate || ""
|
|
1277
1574
|
].join("|");
|
|
1278
1575
|
}
|
|
1279
|
-
function
|
|
1280
|
-
return !N(e) || !N(n) || e.name !== n.name ? !1 :
|
|
1281
|
-
(r) =>
|
|
1576
|
+
function rn(e, n) {
|
|
1577
|
+
return !N(e) || !N(n) || e.name !== n.name ? !1 : ie(e).some(
|
|
1578
|
+
(r) => ie(n).includes(r)
|
|
1282
1579
|
);
|
|
1283
1580
|
}
|
|
1284
|
-
function
|
|
1581
|
+
function tn(e) {
|
|
1285
1582
|
return N(e) && e.role === "id";
|
|
1286
1583
|
}
|
|
1287
|
-
function
|
|
1584
|
+
function on(e) {
|
|
1288
1585
|
const n = [], r = /* @__PURE__ */ new Map();
|
|
1289
1586
|
for (const o of e) {
|
|
1290
|
-
const t = _(o.aliases.length ? o.aliases : [o.key]),
|
|
1291
|
-
if (
|
|
1292
|
-
|
|
1587
|
+
const t = _(o.aliases.length ? o.aliases : [o.key]), a = t.map((p) => r.get(p)).find(O);
|
|
1588
|
+
if (a) {
|
|
1589
|
+
a.aliases = _([...a.aliases, ...t]);
|
|
1293
1590
|
continue;
|
|
1294
1591
|
}
|
|
1295
1592
|
o.aliases = t, n.push(o);
|
|
1296
|
-
for (const
|
|
1297
|
-
r.set(
|
|
1593
|
+
for (const p of t)
|
|
1594
|
+
r.set(p, o);
|
|
1298
1595
|
}
|
|
1299
1596
|
return n;
|
|
1300
1597
|
}
|
|
1301
|
-
function
|
|
1598
|
+
function sn(e) {
|
|
1302
1599
|
const n = /* @__PURE__ */ new Map();
|
|
1303
1600
|
for (const r of e)
|
|
1304
1601
|
for (const o of _([r.key, ...r.aliases])) {
|
|
@@ -1312,11 +1609,11 @@ function Xe(e) {
|
|
|
1312
1609
|
function _(e) {
|
|
1313
1610
|
return Array.from(new Set(e.filter(Boolean)));
|
|
1314
1611
|
}
|
|
1315
|
-
function
|
|
1316
|
-
return
|
|
1612
|
+
function Se(e) {
|
|
1613
|
+
return Z(e)[0] || de(e);
|
|
1317
1614
|
}
|
|
1318
|
-
function
|
|
1319
|
-
const n =
|
|
1615
|
+
function Z(e) {
|
|
1616
|
+
const n = $(e);
|
|
1320
1617
|
if (!n)
|
|
1321
1618
|
return [];
|
|
1322
1619
|
const r = [];
|
|
@@ -1324,22 +1621,22 @@ function Y(e) {
|
|
|
1324
1621
|
const o = typeof n.domainId == "string" ? n.domainId : "";
|
|
1325
1622
|
o && typeof n.datasetId == "string" && r.push(`semantic:${o}:datasetId:${n.datasetId}`), o && typeof n.datasetName == "string" && r.push(`semantic:${o}:datasetName:${n.datasetName}`);
|
|
1326
1623
|
}
|
|
1327
|
-
return r.length === 0 && r.push(
|
|
1624
|
+
return r.length === 0 && r.push(de(e)), _(r);
|
|
1328
1625
|
}
|
|
1329
|
-
function
|
|
1330
|
-
return
|
|
1626
|
+
function we(e) {
|
|
1627
|
+
return Z(e);
|
|
1331
1628
|
}
|
|
1332
|
-
function
|
|
1333
|
-
const n =
|
|
1629
|
+
function de(e) {
|
|
1630
|
+
const n = $(e);
|
|
1334
1631
|
return n ? typeof n.sourceKey == "string" ? n.sourceKey : JSON.stringify(n) : "";
|
|
1335
1632
|
}
|
|
1336
|
-
function
|
|
1337
|
-
return N(e) &&
|
|
1633
|
+
function an(e) {
|
|
1634
|
+
return N(e) && ie(e)[0] || "";
|
|
1338
1635
|
}
|
|
1339
|
-
function
|
|
1636
|
+
function ie(e) {
|
|
1340
1637
|
return N(e) ? _([
|
|
1341
1638
|
...typeof e.sourceKey == "string" ? [e.sourceKey] : [],
|
|
1342
|
-
...e.source ?
|
|
1639
|
+
...e.source ? Z(e.source) : []
|
|
1343
1640
|
]) : [];
|
|
1344
1641
|
}
|
|
1345
1642
|
function B(e) {
|
|
@@ -1348,77 +1645,77 @@ function B(e) {
|
|
|
1348
1645
|
throw new Error(`Unsupported sdkSpec builder: ${e}`);
|
|
1349
1646
|
return n;
|
|
1350
1647
|
}
|
|
1351
|
-
function
|
|
1648
|
+
function un(e) {
|
|
1352
1649
|
const n = B(e);
|
|
1353
1650
|
return n === "records" || n === "sql";
|
|
1354
1651
|
}
|
|
1355
|
-
function
|
|
1356
|
-
const n =
|
|
1652
|
+
function dn(e) {
|
|
1653
|
+
const n = $(e);
|
|
1357
1654
|
return typeof (n == null ? void 0 : n.operator) == "string" ? n.operator : e.type === "date_range" ? "between" : e.type === "multi_select" || e.type === "select" ? "in" : "=";
|
|
1358
1655
|
}
|
|
1359
|
-
function
|
|
1656
|
+
function H(e, n) {
|
|
1360
1657
|
const r = /* @__PURE__ */ new Map();
|
|
1361
1658
|
for (const o of e) {
|
|
1362
|
-
const t = n(o) || "item",
|
|
1363
|
-
r.set(t,
|
|
1659
|
+
const t = n(o) || "item", a = r.get(t) || 0;
|
|
1660
|
+
r.set(t, a + 1), o.name = a === 0 ? t : `${t}${a + 1}`;
|
|
1364
1661
|
}
|
|
1365
1662
|
}
|
|
1366
|
-
function
|
|
1663
|
+
function X(e, n) {
|
|
1367
1664
|
const r = /* @__PURE__ */ new Set(), o = [];
|
|
1368
1665
|
for (const t of e) {
|
|
1369
|
-
const
|
|
1370
|
-
!
|
|
1666
|
+
const a = n(t);
|
|
1667
|
+
!a || r.has(a) || (r.add(a), o.push(t));
|
|
1371
1668
|
}
|
|
1372
1669
|
return o;
|
|
1373
1670
|
}
|
|
1374
|
-
function
|
|
1671
|
+
function Q(e) {
|
|
1375
1672
|
const n = String(e || "").replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
|
|
1376
1673
|
if (n.length === 0)
|
|
1377
1674
|
return "item";
|
|
1378
1675
|
const [r, ...o] = n, t = [
|
|
1379
1676
|
r.toLowerCase(),
|
|
1380
|
-
...o.map((
|
|
1677
|
+
...o.map((a) => a.charAt(0).toUpperCase() + a.slice(1).toLowerCase())
|
|
1381
1678
|
].join("");
|
|
1382
1679
|
return /^[A-Za-z_$]/.test(t) ? t : `item${t}`;
|
|
1383
1680
|
}
|
|
1384
|
-
function
|
|
1681
|
+
function ln(e) {
|
|
1385
1682
|
const n = String(e).split(":");
|
|
1386
1683
|
return n[n.length - 1] || String(e);
|
|
1387
1684
|
}
|
|
1388
|
-
function
|
|
1685
|
+
function A(e) {
|
|
1389
1686
|
return Object.fromEntries(Object.entries(e).filter(([, n]) => n !== void 0));
|
|
1390
1687
|
}
|
|
1391
|
-
function
|
|
1688
|
+
function $(e) {
|
|
1392
1689
|
return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
|
|
1393
1690
|
}
|
|
1394
|
-
function
|
|
1691
|
+
function q(e) {
|
|
1395
1692
|
return Array.isArray(e) ? e : [];
|
|
1396
1693
|
}
|
|
1397
|
-
function
|
|
1694
|
+
function J(e) {
|
|
1398
1695
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1399
1696
|
}
|
|
1400
|
-
function
|
|
1697
|
+
function O(e) {
|
|
1401
1698
|
return e !== void 0;
|
|
1402
1699
|
}
|
|
1403
1700
|
export {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1701
|
+
Fn as CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
1702
|
+
be as CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
1703
|
+
Ve as CONTRACT_MANIFEST_SCHEMA_VERSION,
|
|
1704
|
+
mn as DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR,
|
|
1705
|
+
me as GENERATED_CONTRACT_SCHEMA_VERSION,
|
|
1706
|
+
bn as GENERATED_CONTRACT_TYPESCRIPT_FILES,
|
|
1707
|
+
Vn as REQUIRED_GENERATED_CONTRACT_FILES,
|
|
1708
|
+
hn as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
1709
|
+
Sn as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,
|
|
1710
|
+
Fe as assertValidCodegenSummary,
|
|
1711
|
+
kn as buildSemaphorGeneratedActiveInput,
|
|
1712
|
+
Rn as buildSemaphorGeneratedInputOptionIntent,
|
|
1713
|
+
Mn as buildSemaphorGeneratedViewExecutionRequest,
|
|
1714
|
+
Nn as buildSemaphorGeneratedViewExecutionRequests,
|
|
1715
|
+
xn as evaluateSemaphorDataAppContractUpdatePolicy,
|
|
1716
|
+
fn as generateSemaphorDataAppContract,
|
|
1717
|
+
wn as isSemaphorDataAppCodegenSummary,
|
|
1718
|
+
Cn as validateCodegenSummary,
|
|
1719
|
+
$n as validateSemaphorDataAppCodegenSummary,
|
|
1720
|
+
On as validateSemaphorGeneratedContract
|
|
1424
1721
|
};
|