react-semaphor 0.1.407 → 0.1.409

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