react-semaphor 0.1.421 → 0.1.423

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