react-semaphor 0.1.417 → 0.1.419

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