react-semaphor 0.1.417 → 0.1.418

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