react-semaphor 0.1.418 → 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 (51) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +2 -2
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/chunks/{analyze-result-contract-Akysi2ML.js → analyze-result-contract-DdhEt99q.js} +46 -45
  6. package/dist/chunks/{analyze-result-contract-COjyJzYm.js → analyze-result-contract-DwRzl7yJ.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-BbuLgela.js → calendar-preferences-dialog-DIfAbE_y.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-CInkkhl_.js → calendar-preferences-dialog-f0Z7Kf-U.js} +1 -1
  9. package/dist/chunks/{dashboard-briefing-launcher-B4OWNsVD.js → dashboard-briefing-launcher-C3tNkGFG.js} +1 -1
  10. package/dist/chunks/{dashboard-briefing-launcher-D7FNuDuc.js → dashboard-briefing-launcher-anh-Jy5v.js} +4 -4
  11. package/dist/chunks/{dashboard-controls-DcX7Mid4.js → dashboard-controls-8dCQaPaq.js} +5 -5
  12. package/dist/chunks/{dashboard-controls-DTC1eCz0.js → dashboard-controls-DQxlOxzy.js} +1 -1
  13. package/dist/chunks/{dashboard-json-vu38P5pV.js → dashboard-json-B309EInF.js} +1 -1
  14. package/dist/chunks/{dashboard-json-BHWbQS6I.js → dashboard-json-i7Ae9KGD.js} +3 -3
  15. package/dist/chunks/{edit-dashboard-visual-CkBhJBhp.js → edit-dashboard-visual-4HycwBHR.js} +1 -1
  16. package/dist/chunks/{edit-dashboard-visual-DsCr90_3.js → edit-dashboard-visual-z3IqzYnj.js} +4 -4
  17. package/dist/chunks/{index-C56DuHI8.js → index-B6DLEXRX.js} +5 -5
  18. package/dist/chunks/{index-C8thRvkW.js → index-yxKWKFdr.js} +2 -2
  19. package/dist/chunks/{switch-Dsx-IwBE.js → switch-COWQU8aK.js} +1 -1
  20. package/dist/chunks/{switch-BXuyni6l.js → switch-D6Ygf3wA.js} +1 -1
  21. package/dist/chunks/{update-policy-B5S_LfEu.js → update-policy-BzT2k4n6.js} +1 -1
  22. package/dist/chunks/{update-policy-BqBKUk3Q.js → update-policy-VloD-0YM.js} +1 -1
  23. package/dist/chunks/{use-create-flow-overlay-state-CzftV84t.js → use-create-flow-overlay-state-CX0D-6HM.js} +3 -3
  24. package/dist/chunks/{use-create-flow-overlay-state-BDv_VpL6.js → use-create-flow-overlay-state-DENfd7sW.js} +1 -1
  25. package/dist/chunks/{validators-CPFcUMrV.js → validators-BMQo93Y0.js} +1 -1
  26. package/dist/chunks/{validators-CLzrE2N_.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 +1 -1
  30. package/dist/dashboard-authoring/index.js +2 -2
  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 +123 -92
  36. package/dist/data-app-codegen-node/index.js +461 -422
  37. package/dist/data-app-sdk/index.cjs +2 -2
  38. package/dist/data-app-sdk/index.js +193 -188
  39. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  40. package/dist/data-app-sdk-adapters/index.js +1 -1
  41. package/dist/data-app-sdk-validation/index.cjs +1 -1
  42. package/dist/data-app-sdk-validation/index.js +2 -2
  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 +4 -0
  48. package/dist/types/dashboard-assistant.d.ts +1 -0
  49. package/dist/types/data-app-sdk-validation.d.ts +1 -0
  50. package/dist/types/data-app-sdk.d.ts +3 -0
  51. package/package.json +1 -1
@@ -1,13 +1,13 @@
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";
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
4
  import { createHash as ye } from "node:crypto";
5
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
8
  function wn(e, n = {}) {
9
9
  ke(e);
10
- const r = Ne(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."
@@ -17,14 +17,14 @@ function wn(e, n = {}) {
17
17
  files: t,
18
18
  generatorName: n.generatorName || "react-semaphor/data-app-codegen/node",
19
19
  generatorVersion: n.generatorVersion || "unknown"
20
- }), i = {
20
+ }), a = {
21
21
  ...t,
22
22
  "contract.manifest.json": `${JSON.stringify(o, null, 2)}
23
23
  `
24
24
  };
25
25
  return {
26
26
  schemaVersion: fe,
27
- files: i,
27
+ files: a,
28
28
  manifest: o,
29
29
  contentHash: String(o.generatedContentHash || ""),
30
30
  usageExample: Ee(r),
@@ -38,94 +38,94 @@ function wn(e, n = {}) {
38
38
  }
39
39
  };
40
40
  }
41
- function Ne(e) {
42
- var d, s, u, c, p, S, I, F, b, K, 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
- 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);
44
+ for (const s of e.inputs) {
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
- 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);
50
+ for (const s of e.filterContracts) {
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
- 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);
55
+ for (const s of e.views) {
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
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);
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
66
  const o = dn(
67
67
  [
68
- ...e.sources.map((a) => ({
69
- raw: a,
70
- key: $e(a),
71
- aliases: Ie(a),
68
+ ...e.sources.map((s) => ({
69
+ raw: s,
70
+ key: $e(s),
71
+ aliases: Ie(s),
72
72
  name: ""
73
73
  })),
74
- ...r.map((a) => sn(a)).filter(G)
74
+ ...r.map((s) => sn(s)).filter(K)
75
75
  ]
76
76
  );
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"
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 i = pn(o), l = X(
84
- r.filter((a) => a.name).map((a) => ({
85
- raw: a,
86
- key: U(a),
83
+ const a = pn(o), l = X(
84
+ r.filter((s) => s.name).map((s) => ({
85
+ raw: s,
86
+ key: L(s),
87
87
  name: ""
88
88
  })),
89
- (a) => a.key
89
+ (s) => s.key
90
90
  );
91
91
  v(
92
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
93
+ (s) => q([
94
+ s.raw.sourceKey ? fn(s.raw.sourceKey) : "",
95
+ s.raw.aggregate ? s.raw.aggregate.toLowerCase() : "",
96
+ s.raw.name
97
97
  ].filter(Boolean).join("_"))
98
98
  );
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")
99
+ const y = new Map(l.map((s) => [s.key, s.name])), w = e.inputs.map((s) => ({
100
+ raw: s,
101
+ name: q(s.id || s.label || "input")
102
102
  }));
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
103
+ v(w, (s) => s.name);
104
+ const f = w.filter((s) => !!s.raw.optionQuery).map((s) => ({
105
+ input: s,
106
+ name: `${s.name}Options`,
107
+ raw: s.raw.optionQuery
108
108
  }));
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.`
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
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));
115
+ (s) => {
116
+ var I, T;
117
+ return !!((I = s.sdkSpec) != null && I.builder && ((T = s.sdkSpec) != null && T.spec));
118
118
  }
119
- ).map((a) => ({
120
- raw: a,
121
- name: B(a.id || a.title || "query")
119
+ ).map((s) => ({
120
+ raw: s,
121
+ name: q(s.id || s.title || "query")
122
122
  }));
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
- inputs: h,
123
+ v(m, (s) => s.name);
124
+ const N = e.views.filter((s) => ce(s) && !("sdkSpec" in s)).map((s) => on(s));
125
+ for (const s of e.views)
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
+ return Ne({
128
+ inputs: w,
129
129
  views: m,
130
130
  filterContracts: e.filterContracts
131
131
  }), {
@@ -133,49 +133,49 @@ function Ne(e) {
133
133
  title: e.title || "Semaphor Data App",
134
134
  sources: o,
135
135
  fields: l,
136
- inputs: h,
136
+ inputs: w,
137
137
  optionQueries: f,
138
138
  views: m,
139
- presentationViews: M,
139
+ presentationViews: N,
140
140
  filterContracts: e.filterContracts,
141
141
  checklist: t,
142
- sourceNameByKey: i,
142
+ sourceNameByKey: a,
143
143
  fieldNameByKey: y,
144
144
  warnings: n
145
145
  };
146
146
  }
147
- function xe({
147
+ function Ne({
148
148
  inputs: e,
149
149
  views: n,
150
150
  filterContracts: r
151
151
  }) {
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()) {
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
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 || []);
155
+ throw new Error(`filterContracts.${a}.inputId must reference a generated input.`);
156
+ const y = new Set(l.appliesToViewIds || []), w = new Set(l.notAppliedToViewIds || []);
157
157
  for (const [f, m] of (l.appliesToViewIds || []).entries())
158
158
  if (!o.has(m))
159
159
  throw new Error(
160
- `filterContracts.${i}.appliesToViewIds.${f} must reference an executable generated view.`
160
+ `filterContracts.${a}.appliesToViewIds.${f} must reference an executable generated view.`
161
161
  );
162
162
  for (const [f, m] of (l.notAppliedToViewIds || []).entries())
163
163
  if (!o.has(m))
164
164
  throw new Error(
165
- `filterContracts.${i}.notAppliedToViewIds.${f} must reference an executable generated view.`
165
+ `filterContracts.${a}.notAppliedToViewIds.${f} must reference an executable generated view.`
166
166
  );
167
167
  for (const [f, m] of (l.bindings || []).entries()) {
168
168
  if (!o.has(m.viewId))
169
169
  throw new Error(
170
- `filterContracts.${i}.bindings.${f}.viewId must reference an executable generated view.`
170
+ `filterContracts.${a}.bindings.${f}.viewId must reference an executable generated view.`
171
171
  );
172
172
  if (!y.has(m.viewId))
173
173
  throw new Error(
174
- `filterContracts.${i}.bindings.${f}.viewId must be included in appliesToViewIds.`
174
+ `filterContracts.${a}.bindings.${f}.viewId must be included in appliesToViewIds.`
175
175
  );
176
- if (h.has(m.viewId))
176
+ if (w.has(m.viewId))
177
177
  throw new Error(
178
- `filterContracts.${i}.bindings.${f}.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
  }
@@ -183,7 +183,7 @@ function xe({
183
183
  function Ce(e) {
184
184
  return {
185
185
  "sources.ts": ve(e),
186
- "fields.ts": Be(e),
186
+ "fields.ts": qe(e),
187
187
  "inputs.ts": Te(e),
188
188
  "queries.ts": _e(e),
189
189
  "bindings.ts": Le(e),
@@ -234,14 +234,14 @@ function Ee(e) {
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
  `);
@@ -250,14 +250,14 @@ function Ee(e) {
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
  `);
@@ -266,12 +266,12 @@ function Ee(e) {
266
266
  );
267
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
272
  `const query = queries.${t.name}({ page, pageSize });`,
273
273
  `const result = useSemaphorQuery(query, queryOptionsForView.${t.name}(inputHandles));`,
274
- `const rows = result.records.map((row) => rowValuesForView.${t.name}(row, result.columns));`,
274
+ `const rows = rowsForView.${t.name}(result);`,
275
275
  "const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
276
276
  ].join(`
277
277
  `);
@@ -280,26 +280,26 @@ function Ee(e) {
280
280
  );
281
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
286
  `const query = queries.${o.name}({ page, pageSize });`,
287
287
  `const result = useSemaphorQuery(query, queryOptionsForView.${o.name}(inputHandles));`,
288
- `const rows = result.records.map((row) => rowValuesForView.${o.name}(row, result.columns));`,
288
+ `const rows = rowsForView.${o.name}(result);`,
289
289
  "const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
290
290
  ].join(`
291
291
  `);
292
- const i = e.views.find((f) => {
292
+ const a = e.views.find((f) => {
293
293
  var m;
294
294
  return cn((m = f.raw.sdkSpec) == null ? void 0 : m.builder);
295
295
  });
296
- if (i)
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
- `const result = useSemaphorQuery(queries.${i.name}(), queryOptionsForView.${i.name}(inputHandles));`,
302
- `const rows = result.records.map((row) => rowValuesForView.${i.name}(row, result.columns));`,
301
+ `const result = useSemaphorQuery(queries.${a.name}(), queryOptionsForView.${a.name}(inputHandles));`,
302
+ `const rows = rowsForView.${a.name}(result);`,
303
303
  "const presentationViews = semaphorGeneratedContractMetadata.presentationViews;"
304
304
  ].join(`
305
305
  `);
@@ -326,11 +326,11 @@ function Ee(e) {
326
326
  }
327
327
  function W(e) {
328
328
  var n;
329
- return j((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "records";
329
+ return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "records";
330
330
  }
331
331
  function Ae(e) {
332
332
  var n;
333
- return j((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "metric";
333
+ return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "metric";
334
334
  }
335
335
  function E(e) {
336
336
  var n, r, t;
@@ -338,7 +338,7 @@ function E(e) {
338
338
  }
339
339
  function ue(e) {
340
340
  var n;
341
- return j((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "sql";
341
+ return B((n = e.raw.sdkSpec) == null ? void 0 : n.builder) === "sql";
342
342
  }
343
343
  function A(e) {
344
344
  var n, r, t;
@@ -349,8 +349,8 @@ function He(e) {
349
349
  }
350
350
  function ve(e) {
351
351
  const n = e.sources.map(({ name: t, raw: o }) => {
352
- const i = qe(o);
353
- return ` ${t}: ${i},`;
352
+ const a = je(o);
353
+ return ` ${t}: ${a},`;
354
354
  }).join(`
355
355
  `), r = e.sources.some((t) => t.raw.kind === "semantic") ? `import { semaphor } from "react-semaphor/data-app-sdk";
356
356
 
@@ -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(O(n))})`;
372
+ return `semaphor.source.semantic(${k(G(n))})`;
373
373
  }
374
- return `${k(O({ ...e, sourceKey: void 0 }))} as const`;
374
+ return `${k(G({ ...e, sourceKey: void 0 }))} as const`;
375
375
  }
376
- function Be(e) {
376
+ function qe(e) {
377
377
  const n = e.fields.map(({ name: t, raw: o }) => {
378
- const i = je(o, e);
379
- return ` ${t}: ${i},`;
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
 
@@ -387,7 +387,7 @@ ${n}
387
387
  } as const;
388
388
  `;
389
389
  }
390
- function je(e, n) {
390
+ function Be(e, n) {
391
391
  const r = {
392
392
  name: e.name,
393
393
  label: e.label,
@@ -399,90 +399,90 @@ function je(e, n) {
399
399
  throw new Error(
400
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 i = Object.entries(O(r)).map(([l, y]) => `${JSON.stringify(l)}: ${C(y, n)}`);
403
- return o && i.push(`"source": sources.${o}`), `{ ${i.join(", ")} }`;
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
404
  }
405
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))}`
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 (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(", ")} }),`;
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((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
- valueField: V,
423
- labelField: N,
424
- population: a,
425
- dependencies: w,
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
+ population: s,
425
+ dependencies: I,
426
426
  limit: T,
427
427
  ...ee
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 = {
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: p.id || S.id || `${c.id}-options`,
431
- inputId: c.id,
432
- source: L,
430
+ id: p.id || S.id || `${i.id}-options`,
431
+ inputId: i.id,
432
+ source: J,
433
433
  valueField: p.valueFieldRef,
434
434
  labelField: p.labelFieldRef,
435
- population: p.population || a,
435
+ population: p.population || s,
436
436
  dependencies: oe,
437
437
  limit: p.limit || T || 100
438
438
  };
439
439
  if (!ne || !re || !te)
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(", ")} }),`;
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
- `), 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)
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 ${u.raw.id || `${u.input.raw.id}-options`} references input ${I.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 b = `inputHandles[${JSON.stringify(I.raw.id)}]`;
452
- return ` if (${b}) {
453
- inputs.push(semaphor.bindInput(${b}, { field: fields.${F} }));
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 ` ${u.name}(${p}: 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
- `), l = e.optionQueries.map((u) => ` ${u.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
464
+ `), l = e.optionQueries.map((c) => ` ${c.name}(inputHandles: SemaphorGeneratedInputHandleMap): SemaphorQueryRuntimeOptions {
465
465
  return {
466
- inputs: inputsForInputOptionQuery.${u.name}(inputHandles),
466
+ inputs: inputsForInputOptionQuery.${c.name}(inputHandles),
467
467
  };
468
468
  },`).join(`
469
469
 
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 = [
470
+ `), y = e.optionQueries.map((c) => ` case ${JSON.stringify(c.raw.id || `${c.input.raw.id}-options`)}:
471
+ return queryOptionsForInputOptionQuery.${c.name}(inputHandles);`).join(`
472
+ `), w = e.inputs.length > 0, f = e.optionQueries.length > 0, m = f ? "inputOptionQueryId" : "_inputOptionQueryId", N = f ? "inputHandles" : "_inputHandles", u = [
473
473
  "SemaphorInputHandle",
474
474
  f ? "SemaphorInputReference" : void 0,
475
475
  "SemaphorQueryRuntimeOptions"
476
- ].filter(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,
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
480
  f ? 'import { sources } from "./sources";' : void 0,
481
481
  'import type { SemaphorGeneratedInputId, SemaphorGeneratedInputOptionQueryId } from "./metadata";'
482
- ].filter(G).join(`
482
+ ].filter(K).join(`
483
483
  `);
484
484
  return `${H}
485
- ${s}
485
+ ${d}
486
486
 
487
487
  export const filterSpecs = {
488
488
  ${n}
@@ -502,7 +502,7 @@ ${o}
502
502
  } as const;
503
503
 
504
504
  export const inputsForInputOptionQuery = {
505
- ${i}
505
+ ${a}
506
506
  } as const;
507
507
 
508
508
  export const queryOptionsForInputOptionQuery = {
@@ -511,7 +511,7 @@ ${l}
511
511
 
512
512
  export function queryOptionsForInputOptionQueryId(
513
513
  ${m}: SemaphorGeneratedInputOptionQueryId,
514
- ${M}: SemaphorGeneratedInputHandleMap,
514
+ ${N}: SemaphorGeneratedInputHandleMap,
515
515
  ): SemaphorQueryRuntimeOptions {
516
516
  switch (${m}) {
517
517
  ${y}
@@ -530,77 +530,77 @@ function Qe(e, n) {
530
530
  n.input.raw.id,
531
531
  ...r.excludeInputIds || []
532
532
  ]);
533
- return e.inputs.filter((i) => o.has(i.raw.id) ? !1 : t.has(i.raw.id));
533
+ return e.inputs.filter((a) => o.has(a.raw.id) ? !1 : t.has(a.raw.id));
534
534
  }
535
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
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,
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: (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},
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
+ supportsPagination: s,
552
+ supportsSort: I
553
+ }), te = I ? ` const orderBy = resolveRecordsOrderBy(
554
+ recordsSortFieldsForView.${d.name},
555
555
  params.sort,
556
- ${C(L, e)},
557
- ${C(ne, e)},
556
+ ${O(J, e)},
557
+ ${O(ne, e)},
558
558
  );
559
- ` : "", oe = w ? ` ...(orderBy ? { orderBy } : {}),
560
- ` : "", se = a ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(T)}),
559
+ ` : "", oe = I ? ` ...(orderBy ? { orderBy } : {}),
560
+ ` : "", se = s ? ` pagination: resolveServerTablePagination(params, ${JSON.stringify(T)}),
561
561
  ` : "";
562
- return ` ${s.name}(
562
+ return ` ${d.name}(
563
563
  params: ${re} = {},
564
564
  ) {
565
- ${te} return semaphor.${u}({
566
- ...${C(c, e)},
565
+ ${te} return semaphor.${c}({
566
+ ...${O(i, e)},
567
567
  ${oe}${se} });
568
568
  },`;
569
569
  }
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}(
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.${u}({
576
- ...${C(c, e)},
577
- pagination: resolveServerTablePagination(params, ${JSON.stringify(a)}),
575
+ return semaphor.${c}({
576
+ ...${O(i, e)},
577
+ pagination: resolveServerTablePagination(params, ${JSON.stringify(s)}),
578
578
  });
579
579
  },`;
580
580
  }
581
- return ` ${s.name}: () => semaphor.${u}(${C(c, e)}),`;
581
+ return ` ${d.name}: () => semaphor.${c}(${O(i, e)}),`;
582
582
  }).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(`
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 ` ${s.name}: {
587
- ${c}
586
+ return ` ${d.name}: {
587
+ ${i}
588
588
  },`;
589
589
  }).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(`
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 ` ${s.name}: [
594
- ${c}
593
+ return ` ${d.name}: [
594
+ ${i}
595
595
  ],`;
596
596
  }).join(`
597
- `), o = e.views.some((s) => E(s)), i = e.views.some((s) => A(s)), l = [n, r, t].join(`
597
+ `), o = e.views.some((d) => E(d)), a = e.views.some((d) => A(d)), l = [n, r, t].join(`
598
598
  `), y = [
599
599
  n ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
600
600
  o ? 'import type { SemaphorFieldRef } from "react-semaphor/data-app-sdk";' : void 0,
601
601
  l.includes("fields.") ? 'import { fields } from "./fields";' : void 0,
602
602
  l.includes("sources.") ? 'import { sources } from "./sources";' : void 0
603
- ].filter(G).join(`
603
+ ].filter(K).join(`
604
604
  `);
605
605
  return `${H}
606
606
  ${y}
@@ -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
- ` : ""}${i ? `export type SemaphorGeneratedServerPaginationParams = {
617
+ ` : ""}${a ? `export type SemaphorGeneratedServerPaginationParams = {
618
618
  page?: number;
619
619
  pageSize?: number;
620
620
  };
621
- ` : ""}${o && i ? `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
  ` : ""}
@@ -655,7 +655,7 @@ ${o ? `function resolveRecordsOrderBy<TSortKey extends string>(
655
655
  };
656
656
  }
657
657
  ` : ""}
658
- ${i ? `function resolveServerTablePagination(
658
+ ${a ? `function resolveServerTablePagination(
659
659
  params: SemaphorGeneratedServerPaginationParams,
660
660
  defaultPageSize: number,
661
661
  ) {
@@ -668,31 +668,31 @@ ${i ? `function resolveServerTablePagination(
668
668
  `;
669
669
  }
670
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;
671
+ var a, l;
672
+ const n = V((a = e.raw.sdkSpec) == null ? void 0 : a.spec) || {}, { kind: r, id: t, ...o } = n;
673
673
  return {
674
674
  ...o,
675
675
  id: e.raw.id,
676
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 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);
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
686
  r.map((y) => {
687
- const h = R(y, n);
688
- if (!(!y.name || !h))
687
+ const w = x(y, n);
688
+ if (!(!y.name || !w))
689
689
  return {
690
- key: h,
691
- fieldName: h,
690
+ key: w,
691
+ fieldName: w,
692
692
  rawName: y.name,
693
693
  label: y.label || y.name
694
694
  };
695
- }).filter(G),
695
+ }).filter(K),
696
696
  (y) => y.key
697
697
  );
698
698
  }
@@ -702,14 +702,14 @@ function De({
702
702
  sortFields: r,
703
703
  defaultField: t
704
704
  }) {
705
- var h, f;
705
+ var w, f;
706
706
  const o = new Set(r.map((m) => m.key));
707
707
  if (t && o.has(t))
708
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);
709
+ const a = r.filter((m) => m.rawName === t);
710
+ if (a.length === 1)
711
+ return a[0].key;
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
713
  return y && o.has(y) ? y : void 0;
714
714
  }
715
715
  function Ue({
@@ -721,32 +721,32 @@ function Ue({
721
721
  }
722
722
  function Le(e) {
723
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)
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 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 })}`);
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 S = `inputHandles[${JSON.stringify(u)}]`;
738
+ const S = `inputHandles[${JSON.stringify(c)}]`;
739
739
  return ` if (${S}) {
740
740
  inputs.push(semaphor.bindInput(${S}, { ${p.join(", ")} }));
741
741
  }`;
742
742
  }).filter(Boolean).join(`
743
743
  `);
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[] {
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
- ${M}
749
+ ${N}
750
750
  return inputs;
751
751
  },`;
752
752
  }).join(`
@@ -758,18 +758,18 @@ ${M}
758
758
  };
759
759
  },`).join(`
760
760
 
761
- `), i = e.views.map((m) => ` case ${JSON.stringify(m.raw.id)}:
761
+ `), a = e.views.map((m) => ` case ${JSON.stringify(m.raw.id)}:
762
762
  return inputsForView.${m.name}(inputHandles);`).join(`
763
763
  `), l = e.views.map((m) => ` case ${JSON.stringify(m.raw.id)}:
764
764
  return queryOptionsForView.${m.name}(inputHandles);`).join(`
765
- `), y = e.views.length > 0, h = y ? "inputHandles" : "_inputHandles", f = [
765
+ `), y = e.views.length > 0, w = y ? "inputHandles" : "_inputHandles", f = [
766
766
  r ? 'import { semaphor } from "react-semaphor/data-app-sdk";' : void 0,
767
767
  'import type { SemaphorInputReference, SemaphorQueryRuntimeOptions } from "react-semaphor/data-app-sdk";',
768
768
  r ? 'import { fields } from "./fields";' : void 0,
769
769
  'import type { SemaphorGeneratedInputHandleMap } from "./inputs";',
770
770
  y ? 'import { queryDebugForView } from "./metadata";' : void 0,
771
771
  'import type { SemaphorGeneratedQueryViewId } from "./metadata";'
772
- ].filter(G).join(`
772
+ ].filter(K).join(`
773
773
  `);
774
774
  return `${H}
775
775
  ${f}
@@ -784,17 +784,17 @@ ${o}
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
- ${i}
790
+ ${a}
791
791
  }
792
792
  throw new Error(\`Unknown generated Semaphor view id: \${viewId}\`);
793
793
  }
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
800
  ${l}
@@ -814,130 +814,161 @@ function Je(e, n) {
814
814
  );
815
815
  }
816
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},` : "";
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 ` ${s.name}: {
824
- ${c}
823
+ return ` ${i.name}: {
824
+ ${S}
825
825
  },`;
826
826
  }).join(`
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},` : "";
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 ` ${s.name}: {
834
- ${c}
833
+ return ` ${i.name}: {
834
+ ${S}
835
835
  },`;
836
836
  }).join(`
837
- `), t = e.views.map((s) => {
838
- const u = P(s, e), c = rn(u), p = nn(u), S = u.map((I) => {
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
- he(I.raw).filter((b) => p.has(b))
841
+ he(F.raw).filter((b) => g.has(b))
842
842
  )
843
843
  );
844
- return ` ${I.name}: metricKeysForField(metricFieldsForView.${s.name}.${I.name}, { allowNameFallback: ${c.has(I.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 ` ${s.name}: {
848
- ${S}
847
+ return ` ${i.name}: {
848
+ ${$}
849
849
  },`;
850
850
  }).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(`
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 ` ${s.name}: {
855
- ${c}
854
+ return ` ${i.name}: {
855
+ ${S}
856
856
  },`;
857
857
  }).join(`
858
- `), i = e.views.map((s) => {
859
- const u = P(s, e);
860
- if (u.length === 0)
861
- return ` ${s.name}(): Record<keyof typeof metricFieldsForView.${s.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 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},`;
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 ` ${s.name}(result: SemaphorGeneratedMetricResult): Record<keyof typeof metricFieldsForView.${s.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
- ${p}
874
+ ${g}
875
875
  };
876
876
  },`;
877
877
  }).join(`
878
878
 
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}> {
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
883
  return [];
884
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(`
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
886
  `);
887
- return ` ${s.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${s.name}> {
887
+ return ` ${i.name}(result: SemaphorGeneratedMetricResult): Array<keyof typeof metricFieldsForView.${i.name}> {
888
888
  const missing = new Set(result?.missingMeasures || []);
889
889
  return [
890
- ${c}
890
+ ${S}
891
891
  ];
892
892
  },`;
893
893
  }).join(`
894
894
 
895
- `), y = e.views.map((s) => {
896
- const u = Ye(s, e);
897
- return ` ${s.name}: ${k(u)},`;
895
+ `), y = e.views.map((i) => {
896
+ const p = Ye(i, e);
897
+ return ` ${i.name}: ${k(p)},`;
898
898
  }).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(`
899
+ `), w = e.views.map((i) => {
900
+ const S = D(i, e).map((g) => ` ${g.name}: resolveColumnKey(columns, fieldsForView.${i.name}.${g.name}),`).join(`
901
901
  `);
902
- return ` ${s.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, string | undefined> {
902
+ return ` ${i.name}(columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, string | undefined> {
903
903
  return {
904
- ${c}
904
+ ${S}
905
905
  };
906
906
  },`;
907
907
  }).join(`
908
908
 
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(`
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(`
911
911
  `);
912
- return ` ${s.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${s.name}, unknown> {
912
+ return ` ${i.name}(row: SemaphorGeneratedRow, columns: SemaphorGeneratedColumns): Record<keyof typeof fieldsForView.${i.name}, unknown> {
913
913
  return {
914
- ${c}
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}
915
935
  };
916
936
  },`;
917
937
  }).join(`
918
938
 
919
- `), m = n.includes("fields.") || r.includes("fields."), d = [
939
+ `), u = n.includes("fields.") || r.includes("fields."), c = [
920
940
  `import { ${[
921
941
  "type SemaphorFieldRef",
922
942
  "type SemaphorResultColumn",
923
943
  "semaphorMetricMeasureBindingKey"
924
- ].filter(G).join(", ")} } from "react-semaphor/data-app-sdk";`,
925
- m ? 'import { fields } from "./fields";' : void 0
926
- ].filter(G).join(`
944
+ ].filter(K).join(", ")} } from "react-semaphor/data-app-sdk";`,
945
+ u ? 'import { fields } from "./fields";' : void 0
946
+ ].filter(K).join(`
927
947
  `);
928
948
  return `${H}
929
- ${d}
949
+ ${c}
930
950
 
931
951
  export type SemaphorGeneratedRow = Record<string, unknown>;
932
952
  export type SemaphorGeneratedColumns = readonly SemaphorResultColumn[] | null | undefined;
953
+ export type SemaphorGeneratedRecordsResult = {
954
+ readonly records?: readonly SemaphorGeneratedRow[];
955
+ readonly columns?: SemaphorGeneratedColumns;
956
+ } | null | undefined;
933
957
  export type SemaphorGeneratedMetricMeasures = Record<string, unknown> | null | undefined;
934
958
  export type SemaphorGeneratedMetricMeasureBindings = Record<string, string> | null | undefined;
935
959
  export type SemaphorGeneratedMetricResult = {
936
960
  readonly measures?: SemaphorGeneratedMetricMeasures;
937
961
  readonly measureBindings?: SemaphorGeneratedMetricMeasureBindings;
938
962
  readonly missingMeasures?: readonly string[];
963
+ readonly primaryValue: unknown;
939
964
  readonly value?: unknown;
940
965
  } | null | undefined;
966
+ export type SemaphorGeneratedRoleValues = {
967
+ readonly primaryDimension: unknown;
968
+ readonly secondaryDimension: unknown;
969
+ readonly primaryMeasure: unknown;
970
+ readonly secondaryMeasure: unknown;
971
+ };
941
972
  export type SemaphorGeneratedTableColumn = {
942
973
  readonly key: string;
943
974
  readonly label: string;
@@ -967,15 +998,23 @@ ${y}
967
998
  } as const;
968
999
 
969
1000
  export const columnKeysForView = {
970
- ${h}
1001
+ ${w}
971
1002
  } as const;
972
1003
 
973
1004
  export const rowValuesForView = {
974
1005
  ${f}
975
1006
  } as const;
976
1007
 
1008
+ export const rowsForView = {
1009
+ ${m}
1010
+ } as const;
1011
+
1012
+ export const roleValuesForView = {
1013
+ ${N}
1014
+ } as const;
1015
+
977
1016
  export const metricValuesForView = {
978
- ${i}
1017
+ ${a}
979
1018
  } as const;
980
1019
 
981
1020
  export const missingMetricMeasuresForView = {
@@ -1279,12 +1318,12 @@ function sourcesReferToSameDataset(
1279
1318
  `;
1280
1319
  }
1281
1320
  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])
1321
+ const r = D(e, n), t = new Map(
1322
+ (E(e) ? Y(e, n) : []).map((o) => [o.fieldName, o.key])
1284
1323
  );
1285
1324
  return r.map((o) => {
1286
- const i = R(o.raw, n), l = i ? t.get(i) : void 0;
1287
- return O({
1325
+ const a = x(o.raw, n), l = a ? t.get(a) : void 0;
1326
+ return G({
1288
1327
  key: o.name,
1289
1328
  label: o.raw.label || o.raw.name,
1290
1329
  dataType: o.raw.dataType,
@@ -1294,68 +1333,68 @@ function Ye(e, n) {
1294
1333
  });
1295
1334
  }
1296
1335
  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,
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,
1299
1338
  e.filterContracts.filter(
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,
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,
1304
1343
  {
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
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
1310
1349
  }
1311
- ])), f = Object.fromEntries(e.views.map((d) => {
1312
- var s;
1350
+ ])), f = Object.fromEntries(e.views.map((u) => {
1351
+ var d;
1313
1352
  return [
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),
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),
1321
1360
  marker: {
1322
1361
  attribute: "data-semaphor-view-id",
1323
- value: d.raw.id
1362
+ value: u.raw.id
1324
1363
  }
1325
1364
  })
1326
1365
  ];
1327
- })), m = Object.fromEntries(e.inputs.map((d) => {
1328
- var s;
1366
+ })), m = Object.fromEntries(e.inputs.map((u) => {
1367
+ var d;
1329
1368
  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),
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),
1337
1376
  marker: {
1338
1377
  attribute: "data-semaphor-input-id",
1339
- value: d.raw.id
1378
+ value: u.raw.id
1340
1379
  }
1341
1380
  })
1342
1381
  ];
1343
- })), M = Object.fromEntries(e.views.map((d) => {
1344
- var s, u, c;
1382
+ })), N = Object.fromEntries(e.views.map((u) => {
1383
+ var d, c, i;
1345
1384
  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
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
1352
1391
  })
1353
1392
  ];
1354
1393
  }));
1355
1394
  return `${H}
1356
1395
  export const generatedViewIds = ${k(t)} as const;
1357
1396
  export const generatedQueryViewIds = ${k(o)} as const;
1358
- export const generatedInputIds = ${k(i)} as const;
1397
+ export const generatedInputIds = ${k(a)} as const;
1359
1398
  export const generatedInputOptionQueryIds = ${k(l)} as const;
1360
1399
  export const generatedViewAuthoring = ${k(f)} as const;
1361
1400
  export const generatedInputAuthoring = ${k(m)} as const;
@@ -1398,7 +1437,7 @@ export function filterContractsForView(viewId: SemaphorGeneratedQueryViewId) {
1398
1437
  );
1399
1438
  }
1400
1439
 
1401
- export const queryDebugForView = ${k(M)} as const;
1440
+ export const queryDebugForView = ${k(N)} as const;
1402
1441
 
1403
1442
  export const semaphorGeneratedContractMetadata = ${k({
1404
1443
  schemaVersion: "semaphor-generated-data-app-contract/v1",
@@ -1408,12 +1447,12 @@ export const semaphorGeneratedContractMetadata = ${k({
1408
1447
  filterScopeByInput: n,
1409
1448
  generatedViewIds: t,
1410
1449
  generatedQueryViewIds: o,
1411
- generatedInputIds: i,
1450
+ generatedInputIds: a,
1412
1451
  generatedInputOptionQueryIds: l,
1413
1452
  generatedInputIdsForView: y,
1414
1453
  generatedViewAuthoring: f,
1415
1454
  generatedInputAuthoring: m,
1416
- visualSpecs: h,
1455
+ visualSpecs: w,
1417
1456
  presentationViews: e.presentationViews
1418
1457
  })} as const;
1419
1458
  `;
@@ -1435,39 +1474,39 @@ function Q(e, n) {
1435
1474
  for (const r of n) Q(e, r);
1436
1475
  return;
1437
1476
  }
1438
- x(n) && g(e, D(n));
1477
+ C(n) && h(e, U(n));
1439
1478
  for (const r of Object.values(n))
1440
1479
  Q(e, r);
1441
1480
  }
1442
1481
  }
1443
- function Y(e, n) {
1482
+ function D(e, n) {
1444
1483
  const r = [];
1445
1484
  if (tn(r, e.raw.sdkSpec), r.length === 0)
1446
1485
  for (const o of e.raw.fields || [])
1447
- g(r, o);
1486
+ h(r, o);
1448
1487
  const t = X(
1449
- r.filter((o) => o.name && R(o, n)).map((o) => ({ raw: o, key: U(o), name: "" })),
1488
+ r.filter((o) => o.name && x(o, n)).map((o) => ({ raw: o, key: L(o), name: "" })),
1450
1489
  (o) => o.key
1451
1490
  );
1452
1491
  return v(
1453
1492
  t,
1454
- (o) => B(o.raw.label || o.raw.name || "field")
1493
+ (o) => q(o.raw.label || o.raw.name || "field")
1455
1494
  ), t;
1456
1495
  }
1457
1496
  function P(e, n) {
1458
- if (j(e.raw.sdkSpec.builder) !== "metric")
1497
+ if (B(e.raw.sdkSpec.builder) !== "metric")
1459
1498
  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);
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);
1464
1503
  const o = X(
1465
- t.filter((i) => i.name && R(i, n)).map((i) => ({ raw: i, key: U(i), name: "" })),
1466
- (i) => i.key
1504
+ t.filter((a) => a.name && x(a, n)).map((a) => ({ raw: a, key: L(a), name: "" })),
1505
+ (a) => a.key
1467
1506
  );
1468
1507
  return v(
1469
1508
  o,
1470
- (i) => B(i.raw.label || i.raw.name || "metric")
1509
+ (a) => q(a.raw.label || a.raw.name || "metric")
1471
1510
  ), o;
1472
1511
  }
1473
1512
  function Xe(e, n, r) {
@@ -1482,10 +1521,10 @@ function Xe(e, n, r) {
1482
1521
  function en(e, n) {
1483
1522
  if (n.length === 1)
1484
1523
  return /* @__PURE__ */ new Set([n[0].name]);
1485
- const r = $(e.raw.sdkSpec.spec);
1486
- 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))
1487
1526
  return /* @__PURE__ */ new Set();
1488
- const t = U(D(r.primaryMeasure)), o = n.find((i) => i.key === t);
1527
+ const t = L(U(r.primaryMeasure)), o = n.find((a) => a.key === t);
1489
1528
  return o ? /* @__PURE__ */ new Set([o.name]) : /* @__PURE__ */ new Set();
1490
1529
  }
1491
1530
  function nn(e) {
@@ -1516,56 +1555,56 @@ function rn(e) {
1516
1555
  );
1517
1556
  }
1518
1557
  function tn(e, n) {
1519
- const r = $(n.spec);
1558
+ const r = V(n.spec);
1520
1559
  if (!r)
1521
1560
  return;
1522
- const t = j(n.builder);
1561
+ const t = B(n.builder);
1523
1562
  if (t === "records") {
1524
- for (const o of q(r.fields)) g(e, o);
1563
+ for (const o of j(r.fields)) h(e, o);
1525
1564
  return;
1526
1565
  }
1527
1566
  if (t === "sql") {
1528
- for (const o of q(r.fields)) g(e, o);
1567
+ for (const o of j(r.fields)) h(e, o);
1529
1568
  return;
1530
1569
  }
1531
1570
  if (t === "analysis" || t === "metric") {
1532
- g(e, r.primaryMeasure);
1533
- for (const o of q(r.measures)) g(e, o);
1534
- for (const o of q(r.dimensions)) g(e, o);
1535
- g(e, r.dateField);
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);
1536
1575
  return;
1537
1576
  }
1538
1577
  if (t === "matrix") {
1539
- const o = pe(r.rows), i = pe(r.columns), l = q(r.values);
1578
+ const o = pe(r.rows), a = pe(r.columns), l = j(r.values);
1540
1579
  for (const y of o) le(e, y);
1541
- for (const y of i) le(e, y);
1580
+ for (const y of a) le(e, y);
1542
1581
  for (const y of l) {
1543
- const h = $(y);
1544
- g(e, h == null ? void 0 : h.field), g(e, h == null ? void 0 : h.measure);
1582
+ const w = V(y);
1583
+ h(e, w == null ? void 0 : w.field), h(e, w == null ? void 0 : w.measure);
1545
1584
  }
1546
1585
  }
1547
1586
  }
1548
1587
  function pe(e) {
1549
1588
  if (Array.isArray(e))
1550
1589
  return e;
1551
- const n = $(e);
1590
+ const n = V(e);
1552
1591
  return Array.isArray(n == null ? void 0 : n.levels) ? n.levels : [];
1553
1592
  }
1554
1593
  function le(e, n) {
1555
1594
  var r;
1556
- if (x(n)) {
1557
- g(e, n);
1595
+ if (C(n)) {
1596
+ h(e, n);
1558
1597
  return;
1559
1598
  }
1560
- g(e, (r = $(n)) == null ? void 0 : r.field);
1599
+ h(e, (r = V(n)) == null ? void 0 : r.field);
1561
1600
  }
1562
1601
  function ce(e) {
1563
1602
  var n, r, t, o;
1564
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";
1565
1604
  }
1566
1605
  function on(e) {
1567
- const n = $(e) || {};
1568
- return O({
1606
+ const n = V(e) || {};
1607
+ return G({
1569
1608
  id: e.id,
1570
1609
  title: e.title,
1571
1610
  purpose: e.purpose,
@@ -1579,10 +1618,10 @@ function on(e) {
1579
1618
  description: n.description
1580
1619
  });
1581
1620
  }
1582
- function g(e, n) {
1583
- x(n) && e.push(D(n));
1621
+ function h(e, n) {
1622
+ C(n) && e.push(U(n));
1584
1623
  }
1585
- function D(e) {
1624
+ function U(e) {
1586
1625
  return {
1587
1626
  name: e.name,
1588
1627
  label: e.label,
@@ -1608,38 +1647,38 @@ function sn(e) {
1608
1647
  name: ""
1609
1648
  };
1610
1649
  }
1611
- function x(e) {
1612
- const n = $(e);
1650
+ function C(e) {
1651
+ const n = V(e);
1613
1652
  return !!(n && typeof n.name == "string" && (typeof n.role == "string" || typeof n.dataType == "string" || typeof n.aggregate == "string" || n.source || n.sourceKey));
1614
1653
  }
1615
1654
  function we(e) {
1616
- const n = $(e);
1655
+ const n = V(e);
1617
1656
  return !!(n && (typeof n.sourceKey == "string" || n.kind === "semantic" || typeof n.datasetName == "string" && typeof n.domainId == "string"));
1618
1657
  }
1619
- function C(e, n) {
1658
+ function O(e, n) {
1620
1659
  if (e === void 0)
1621
1660
  return "undefined";
1622
1661
  if (e === null || typeof e == "number" || typeof e == "boolean" || typeof e == "string")
1623
1662
  return JSON.stringify(e);
1624
1663
  if (Array.isArray(e))
1625
- return `[${e.map((o) => C(o, n)).join(", ")}]`;
1626
- if (x(e)) {
1627
- const o = R(D(e), n);
1664
+ return `[${e.map((o) => O(o, n)).join(", ")}]`;
1665
+ if (C(e)) {
1666
+ const o = x(U(e), n);
1628
1667
  if (o) return `fields.${o}`;
1629
1668
  }
1630
1669
  if (we(e)) {
1631
1670
  const o = Se(e, n);
1632
1671
  if (o) return `sources.${o}`;
1633
1672
  }
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);
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);
1636
1675
  }
1637
1676
  function k(e) {
1638
1677
  return JSON.stringify(e, null, 2);
1639
1678
  }
1640
- function R(e, n) {
1641
- if (x(e))
1642
- return n.fieldNameByKey.get(U(D(e)));
1679
+ function x(e, n) {
1680
+ if (C(e))
1681
+ return n.fieldNameByKey.get(L(U(e)));
1643
1682
  }
1644
1683
  function Se(e, n) {
1645
1684
  if (we(e))
@@ -1649,7 +1688,7 @@ function Se(e, n) {
1649
1688
  return t;
1650
1689
  }
1651
1690
  }
1652
- function U(e) {
1691
+ function L(e) {
1653
1692
  return [
1654
1693
  e.sourceKey || "",
1655
1694
  e.name || "",
@@ -1658,19 +1697,19 @@ function U(e) {
1658
1697
  ].join("|");
1659
1698
  }
1660
1699
  function an(e, n) {
1661
- return !x(e) || !x(n) || e.name !== n.name ? !1 : ie(e).some(
1700
+ return !C(e) || !C(n) || e.name !== n.name ? !1 : ie(e).some(
1662
1701
  (r) => ie(n).includes(r)
1663
1702
  );
1664
1703
  }
1665
1704
  function un(e) {
1666
- return x(e) && e.role === "id";
1705
+ return C(e) && e.role === "id";
1667
1706
  }
1668
1707
  function dn(e) {
1669
1708
  const n = [], r = /* @__PURE__ */ new Map();
1670
1709
  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]);
1710
+ const o = _(t.aliases.length ? t.aliases : [t.key]), a = o.map((l) => r.get(l)).find(K);
1711
+ if (a) {
1712
+ a.aliases = _([...a.aliases, ...o]);
1674
1713
  continue;
1675
1714
  }
1676
1715
  t.aliases = o, n.push(t);
@@ -1697,7 +1736,7 @@ function $e(e) {
1697
1736
  return Z(e)[0] || de(e);
1698
1737
  }
1699
1738
  function Z(e) {
1700
- const n = $(e);
1739
+ const n = V(e);
1701
1740
  if (!n)
1702
1741
  return [];
1703
1742
  const r = [];
@@ -1711,78 +1750,78 @@ function Ie(e) {
1711
1750
  return Z(e);
1712
1751
  }
1713
1752
  function de(e) {
1714
- const n = $(e);
1753
+ const n = V(e);
1715
1754
  return n ? typeof n.sourceKey == "string" ? n.sourceKey : JSON.stringify(n) : "";
1716
1755
  }
1717
1756
  function ln(e) {
1718
- return x(e) && ie(e)[0] || "";
1757
+ return C(e) && ie(e)[0] || "";
1719
1758
  }
1720
1759
  function ie(e) {
1721
- return x(e) ? _([
1760
+ return C(e) ? _([
1722
1761
  ...typeof e.sourceKey == "string" ? [e.sourceKey] : [],
1723
1762
  ...e.source ? Z(e.source) : []
1724
1763
  ]) : [];
1725
1764
  }
1726
- function j(e) {
1765
+ function B(e) {
1727
1766
  const n = String(e || "").replace(/^semaphor\./, "");
1728
1767
  if (!["metric", "records", "analysis", "matrix", "sql"].includes(n))
1729
1768
  throw new Error(`Unsupported sdkSpec builder: ${e}`);
1730
1769
  return n;
1731
1770
  }
1732
1771
  function cn(e) {
1733
- const n = j(e);
1772
+ const n = B(e);
1734
1773
  return n === "records" || n === "sql";
1735
1774
  }
1736
1775
  function mn(e) {
1737
- const n = $(e);
1776
+ const n = V(e);
1738
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" : "=";
1739
1778
  }
1740
1779
  function v(e, n) {
1741
1780
  const r = /* @__PURE__ */ new Map();
1742
1781
  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}`;
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}`;
1745
1784
  }
1746
1785
  }
1747
1786
  function X(e, n) {
1748
1787
  const r = /* @__PURE__ */ new Set(), t = [];
1749
1788
  for (const o of e) {
1750
- const i = n(o);
1751
- !i || r.has(i) || (r.add(i), t.push(o));
1789
+ const a = n(o);
1790
+ !a || r.has(a) || (r.add(a), t.push(o));
1752
1791
  }
1753
1792
  return t;
1754
1793
  }
1755
- function B(e) {
1794
+ function q(e) {
1756
1795
  const n = String(e || "").replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
1757
1796
  if (n.length === 0)
1758
1797
  return "item";
1759
1798
  const [r, ...t] = n, o = [
1760
1799
  r.toLowerCase(),
1761
- ...t.map((i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase())
1800
+ ...t.map((a) => a.charAt(0).toUpperCase() + a.slice(1).toLowerCase())
1762
1801
  ].join("");
1763
1802
  return /^[A-Za-z_$]/.test(o) ? o : `item${o}`;
1764
1803
  }
1765
1804
  function me(e) {
1766
- const n = B(e);
1805
+ const n = q(e);
1767
1806
  return n.charAt(0).toUpperCase() + n.slice(1);
1768
1807
  }
1769
1808
  function fn(e) {
1770
1809
  const n = String(e).split(":");
1771
1810
  return n[n.length - 1] || String(e);
1772
1811
  }
1773
- function O(e) {
1812
+ function G(e) {
1774
1813
  return Object.fromEntries(Object.entries(e).filter(([, n]) => n !== void 0));
1775
1814
  }
1776
- function $(e) {
1815
+ function V(e) {
1777
1816
  return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
1778
1817
  }
1779
- function q(e) {
1818
+ function j(e) {
1780
1819
  return Array.isArray(e) ? e : [];
1781
1820
  }
1782
- function J(e) {
1821
+ function z(e) {
1783
1822
  return typeof e == "number" && Number.isFinite(e) ? e : void 0;
1784
1823
  }
1785
- function G(e) {
1824
+ function K(e) {
1786
1825
  return e !== void 0;
1787
1826
  }
1788
1827
  export {
@@ -1792,11 +1831,11 @@ export {
1792
1831
  hn as DEFAULT_GENERATED_CONTRACT_OUTPUT_DIR,
1793
1832
  fe as GENERATED_CONTRACT_SCHEMA_VERSION,
1794
1833
  Mn as GENERATED_CONTRACT_TYPESCRIPT_FILES,
1795
- Nn as REQUIRED_GENERATED_CONTRACT_FILES,
1834
+ xn as REQUIRED_GENERATED_CONTRACT_FILES,
1796
1835
  In as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
1797
1836
  Fn as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,
1798
1837
  ke as assertValidCodegenSummary,
1799
- xn as buildSemaphorGeneratedActiveInput,
1838
+ Nn as buildSemaphorGeneratedActiveInput,
1800
1839
  Cn as buildSemaphorGeneratedInputOptionIntent,
1801
1840
  On as buildSemaphorGeneratedViewExecutionRequest,
1802
1841
  Gn as buildSemaphorGeneratedViewExecutionRequests,