react-semaphor 0.1.338 → 0.1.340

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +58 -57
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +3 -3
  5. package/dist/chunks/{braces-Q86XHDaD.js → braces-Ccvdip75.js} +1 -1
  6. package/dist/chunks/{braces-BLa_lORs.js → braces-DDHkbW1c.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-Cocogo9H.js → calendar-preferences-dialog-2IbYrrP1.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-Bm7ji3k9.js → calendar-preferences-dialog-8-KE5sVX.js} +1 -1
  9. package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +100 -0
  10. package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +1 -0
  11. package/dist/chunks/{chevrons-up-down-BBTZ5pAY.js → chevrons-up-down-B9fTSds9.js} +1 -1
  12. package/dist/chunks/{chevrons-up-down-CYuWasy_.js → chevrons-up-down-pV0i9ptS.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-BtqtLx1-.js → dashboard-briefing-launcher-CcqDPVke.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-DF4CoaRn.js → dashboard-briefing-launcher-DtxDRAiu.js} +4 -4
  15. package/dist/chunks/{dashboard-controls-B5U-VUxs.js → dashboard-controls-Bi98DhYD.js} +6 -6
  16. package/dist/chunks/{dashboard-controls-0VMAeMoa.js → dashboard-controls-By7aKmDj.js} +1 -1
  17. package/dist/chunks/{dashboard-json-CqbLOfnr.js → dashboard-json-BOyLuhS6.js} +1 -1
  18. package/dist/chunks/{dashboard-json-Hmc0Ri5z.js → dashboard-json-CGxIsTEP.js} +2 -2
  19. package/dist/chunks/{edit-dashboard-visual-D4VVu-QQ.js → edit-dashboard-visual-Ba8LenNc.js} +6 -6
  20. package/dist/chunks/{edit-dashboard-visual-C0EDM0QB.js → edit-dashboard-visual-BuXlHmJH.js} +1 -1
  21. package/dist/chunks/{index-DE0vIuYG.js → index-DT9osgRT.js} +2 -2
  22. package/dist/chunks/{index-DzyUhzV3.js → index-DVPvpd8u.js} +5 -5
  23. package/dist/chunks/{palette-DalASD28.js → palette-BMXS-AcI.js} +1 -1
  24. package/dist/chunks/{palette-B9AbDw0n.js → palette-DKecBucs.js} +1 -1
  25. package/dist/chunks/{resource-management-panel-C4YydU9I.js → resource-management-panel-98Hy6SYB.js} +3 -3
  26. package/dist/chunks/{resource-management-panel-P9iNqBM1.js → resource-management-panel-ByR-FD3h.js} +1 -1
  27. package/dist/chunks/{switch-BAYfpAEb.js → switch-CP7SmEIZ.js} +1 -1
  28. package/dist/chunks/{switch-CyRoZr5T.js → switch-DYRgERrC.js} +1 -1
  29. package/dist/chunks/{use-create-flow-overlay-state-P1LMwQ89.js → use-create-flow-overlay-state-D5uvjbwY.js} +3 -3
  30. package/dist/chunks/{use-create-flow-overlay-state-CbhjxI3W.js → use-create-flow-overlay-state-uNxArZdj.js} +1 -1
  31. package/dist/chunks/{use-visual-utils-lB-3Zk0b.js → use-visual-utils-BLh9mKic.js} +2 -2
  32. package/dist/chunks/{use-visual-utils-CV6_-y4p.js → use-visual-utils-CpaqIHoc.js} +1 -1
  33. package/dist/chunks/{validators-BOqiGymD.js → validators-CPEQojnV.js} +325 -250
  34. package/dist/chunks/validators-CfP-49k9.js +1 -0
  35. package/dist/dashboard/index.cjs +1 -1
  36. package/dist/dashboard/index.js +1 -1
  37. package/dist/dashboard-authoring/index.cjs +3 -3
  38. package/dist/dashboard-authoring/index.js +424 -561
  39. package/dist/data-app-builder/index.cjs +1 -1
  40. package/dist/data-app-builder/index.js +1 -1
  41. package/dist/data-app-sdk/index.cjs +1 -1
  42. package/dist/data-app-sdk/index.js +313 -308
  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 +75 -49
  48. package/dist/types/dashboard-authoring.d.ts +26 -52
  49. package/dist/types/dashboard.d.ts +1 -2
  50. package/dist/types/data-app-builder.d.ts +23 -13
  51. package/dist/types/data-app-sdk.d.ts +33 -46
  52. package/dist/types/main.d.ts +29 -50
  53. package/dist/types/shared.d.ts +1 -2
  54. package/dist/types/surfboard.d.ts +1 -2
  55. package/dist/types/types.d.ts +1 -2
  56. package/package.json +1 -1
  57. package/dist/chunks/catalog-field-grounding-DmT7aGUA.js +0 -191
  58. package/dist/chunks/catalog-field-grounding-VgVzDd25.js +0 -1
  59. package/dist/chunks/validators-BtFXY3S_.js +0 -2
@@ -1,191 +0,0 @@
1
- function c(t) {
2
- return typeof t == "string" ? t.trim().toLowerCase() : "";
3
- }
4
- function y(t) {
5
- return String(t.column_name || t.name || t.qualifiedFieldName || "");
6
- }
7
- function D(t) {
8
- return Array.from(
9
- new Set(
10
- [
11
- t.column_name,
12
- t.name,
13
- t.qualifiedFieldName,
14
- t.alias
15
- ].filter(
16
- (e) => typeof e == "string" && e.trim().length > 0
17
- ).map((e) => e.trim())
18
- )
19
- );
20
- }
21
- function l(t) {
22
- const e = h(t);
23
- return e ? e.includes("int") || e.includes("uint") || e.includes("bigint") || e.includes("smallint") || e.includes("tinyint") || e.includes("numeric") || e.includes("decimal") || e.includes("double") || e.includes("float") || e.includes("number") || e.includes("real") || e.includes("money") || e.includes("currency") || e.includes("percent") ? "number" : e.includes("timestamp") || e.includes("datetime") || e.startsWith("time") ? "datetime" : e.includes("date") ? "date" : e.includes("bool") ? "boolean" : "string" : "unknown";
24
- }
25
- function h(t) {
26
- let e = c(t), n = "";
27
- for (; e && e !== n; )
28
- n = e, e = u(e, "nullable"), e = u(e, "lowcardinality");
29
- return e;
30
- }
31
- function u(t, e) {
32
- const n = `${e}(`;
33
- return !t.startsWith(n) || !t.endsWith(")") ? t : t.slice(n.length, -1).trim();
34
- }
35
- function F(t) {
36
- const e = l(t);
37
- return e === "date" || e === "datetime";
38
- }
39
- function d(t) {
40
- return F(t.dataType || t.data_type);
41
- }
42
- function p(t) {
43
- const e = g(t);
44
- return e === "id" || e === "row_id";
45
- }
46
- function m(t) {
47
- const e = g(t);
48
- return p(t) || e.endsWith("_id") || e.endsWith("_key") || e.endsWith("_number");
49
- }
50
- function g(t) {
51
- return c(
52
- y(t) || t.name || t.alias
53
- ).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
54
- }
55
- function f(t, e = {}) {
56
- const n = c(t.role);
57
- return n === "metric" || n === "measure" ? !e.excludeIdentifiers || !m(t) : n === "groupby" || n === "dimension" || n === "date" || n === "id" ? !1 : l(
58
- t.dataType || t.data_type
59
- ) === "number" && (!e.excludeIdentifiers || !m(t));
60
- }
61
- function A(t) {
62
- return !f(t) && !d(t);
63
- }
64
- function b(t) {
65
- return [
66
- t.column_name,
67
- t.name,
68
- t.label,
69
- t.alias,
70
- t.qualifiedFieldName
71
- ].filter(
72
- (e) => typeof e == "string" && e.trim().length > 0
73
- ).map(
74
- (e) => c(e).replace(/[^a-z0-9]+/g, " ")
75
- ).join(" ");
76
- }
77
- function o(t, e) {
78
- return e.some((n) => {
79
- const i = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
80
- return new RegExp(`(^|\\s)${i}(\\s|$)`, "i").test(t);
81
- });
82
- }
83
- function C(t) {
84
- const e = b(t);
85
- if (e)
86
- return o(e, [
87
- "pct",
88
- "percent",
89
- "percentage",
90
- "rate",
91
- "ratio",
92
- "share",
93
- "conversion",
94
- "retention",
95
- "churn",
96
- "growth",
97
- "margin rate",
98
- "margin pct",
99
- "margin percent",
100
- "margin percentage"
101
- ]) ? {
102
- type: "percent",
103
- minimumFractionDigits: 0,
104
- maximumFractionDigits: 1,
105
- percentValueMode: "fraction"
106
- } : o(e, [
107
- "revenue",
108
- "sales",
109
- "profit",
110
- "arr",
111
- "mrr",
112
- "gmv",
113
- "amount",
114
- "price",
115
- "cost",
116
- "spend",
117
- "expense",
118
- "budget",
119
- "income",
120
- "value",
121
- "booking",
122
- "bookings"
123
- ]) ? {
124
- type: "currency",
125
- currency: "USD",
126
- minimumFractionDigits: 0,
127
- maximumFractionDigits: 1,
128
- compact: !0
129
- } : o(e, [
130
- "count",
131
- "quantity",
132
- "orders",
133
- "order",
134
- "users",
135
- "customers",
136
- "tickets",
137
- "units",
138
- "sessions",
139
- "visits",
140
- "items",
141
- "rows"
142
- ]) ? {
143
- type: "number",
144
- minimumFractionDigits: 0,
145
- maximumFractionDigits: 0,
146
- compact: !0
147
- } : {
148
- type: "number",
149
- minimumFractionDigits: 0,
150
- maximumFractionDigits: 1,
151
- compact: !0
152
- };
153
- }
154
- function x(t) {
155
- const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
156
- for (const r of t) {
157
- if (p(r))
158
- continue;
159
- const s = D(r);
160
- if (s.length !== 0) {
161
- if (d(r)) {
162
- s.forEach((a) => n.add(a));
163
- continue;
164
- }
165
- if (f(r, { excludeIdentifiers: !0 })) {
166
- s.forEach((a) => e.add(a));
167
- continue;
168
- }
169
- s.forEach((a) => i.add(a));
170
- }
171
- }
172
- return {
173
- validMetricCandidates: Array.from(e).sort(),
174
- validDateCandidates: Array.from(n).sort(),
175
- validDimensionCandidates: Array.from(i).sort()
176
- };
177
- }
178
- export {
179
- D as a,
180
- l as b,
181
- d as c,
182
- p as d,
183
- m as e,
184
- f,
185
- y as g,
186
- A as h,
187
- F as i,
188
- C as j,
189
- x as k,
190
- c as n
191
- };
@@ -1 +0,0 @@
1
- "use strict";function r(t){return typeof t=="string"?t.trim().toLowerCase():""}function p(t){return String(t.column_name||t.name||t.qualifiedFieldName||"")}function f(t){return Array.from(new Set([t.column_name,t.name,t.qualifiedFieldName,t.alias].filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>e.trim())))}function u(t){const e=C(t);return e?e.includes("int")||e.includes("uint")||e.includes("bigint")||e.includes("smallint")||e.includes("tinyint")||e.includes("numeric")||e.includes("decimal")||e.includes("double")||e.includes("float")||e.includes("number")||e.includes("real")||e.includes("money")||e.includes("currency")||e.includes("percent")?"number":e.includes("timestamp")||e.includes("datetime")||e.startsWith("time")?"datetime":e.includes("date")?"date":e.includes("bool")?"boolean":"string":"unknown"}function C(t){let e=r(t),i="";for(;e&&e!==i;)i=e,e=g(e,"nullable"),e=g(e,"lowcardinality");return e}function g(t,e){const i=`${e}(`;return!t.startsWith(i)||!t.endsWith(")")?t:t.slice(i.length,-1).trim()}function A(t){const e=u(t);return e==="date"||e==="datetime"}function m(t){return A(t.dataType||t.data_type)}function d(t){const e=F(t);return e==="id"||e==="row_id"}function l(t){const e=F(t);return d(t)||e.endsWith("_id")||e.endsWith("_key")||e.endsWith("_number")}function F(t){return r(p(t)||t.name||t.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function y(t,e={}){const i=r(t.role);return i==="metric"||i==="measure"?!e.excludeIdentifiers||!l(t):i==="groupby"||i==="dimension"||i==="date"||i==="id"?!1:u(t.dataType||t.data_type)==="number"&&(!e.excludeIdentifiers||!l(t))}function D(t){return!y(t)&&!m(t)}function h(t){return[t.column_name,t.name,t.label,t.alias,t.qualifiedFieldName].filter(e=>typeof e=="string"&&e.trim().length>0).map(e=>r(e).replace(/[^a-z0-9]+/g," ")).join(" ")}function o(t,e){return e.some(i=>{const n=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(^|\\s)${n}(\\s|$)`,"i").test(t)})}function b(t){const e=h(t);if(e)return o(e,["pct","percent","percentage","rate","ratio","share","conversion","retention","churn","growth","margin rate","margin pct","margin percent","margin percentage"])?{type:"percent",minimumFractionDigits:0,maximumFractionDigits:1,percentValueMode:"fraction"}:o(e,["revenue","sales","profit","arr","mrr","gmv","amount","price","cost","spend","expense","budget","income","value","booking","bookings"])?{type:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:1,compact:!0}:o(e,["count","quantity","orders","order","users","customers","tickets","units","sessions","visits","items","rows"])?{type:"number",minimumFractionDigits:0,maximumFractionDigits:0,compact:!0}:{type:"number",minimumFractionDigits:0,maximumFractionDigits:1,compact:!0}}function T(t){const e=new Set,i=new Set,n=new Set;for(const c of t){if(d(c))continue;const s=f(c);if(s.length!==0){if(m(c)){s.forEach(a=>i.add(a));continue}if(y(c,{excludeIdentifiers:!0})){s.forEach(a=>e.add(a));continue}s.forEach(a=>n.add(a))}}return{validMetricCandidates:Array.from(e).sort(),validDateCandidates:Array.from(i).sort(),validDimensionCandidates:Array.from(n).sort()}}exports.buildAnalyticsCatalogFieldSummary=T;exports.getAnalyticsCatalogFieldCandidates=f;exports.getAnalyticsCatalogFieldName=p;exports.inferAnalyticsMetricFormat=b;exports.isAnalyticsCatalogDateField=m;exports.isAnalyticsCatalogDimensionField=D;exports.isAnalyticsCatalogMetricField=y;exports.isAnalyticsDateLikeDataType=A;exports.isAnalyticsMetricIdentifierField=l;exports.isAnalyticsTechnicalIdentifierField=d;exports.normalizeAnalyticsCatalogDataType=u;exports.normalizeAnalyticsCatalogName=r;
@@ -1,2 +0,0 @@
1
- "use strict";function s(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function h(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}function a(e){return typeof e=="string"&&e.trim().length>0}function p(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function y(e,i,n,o={}){if(!e||typeof e!="object"){n.push(s("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){a(e.domainId)||n.push(s("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),a(e.datasetName)||n.push(s("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){a(e.connectionId)||n.push(s("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),a(e.tableName)||n.push(s("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){a(e.connectionId)||n.push(s("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`)),o.requireSqlText!==!1&&!a(e.sql)&&n.push(s("missing_sql","SQL source needs SQL text.",`${i}.sql`));return}n.push(s("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,n,o={}){if(!e||!p(e)){o.required&&n.push(s("missing_field_ref","Field reference needs a name.",i));return}a(e.name)||n.push(s("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&y(e.source,`${i}.source`,n,{requireSqlText:!1})}function q(e,i){if(e.analysis===void 0)return;if(!p(e.analysis)){i.push(s("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(s("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(s("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(s("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain"));const{timeWindow:n}=e.analysis;n!==void 0&&g(n,"analysis.timeWindow",i)}function g(e,i,n){if(!p(e)){n.push(s("invalid_time_window","Time window must be a structured object.",i));return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&n.push(s("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&n.push(s("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&n.push(s("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`))}function $(e,i,n){if(e!==void 0){if(!Array.isArray(e)){n.push(s("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((o,f)=>{const d=`${i}.${f}`;if(!p(o)){n.push(s("invalid_analytics_filter","Analytics filter must be a structured object.",d));return}const r=o;m(r.field,`${d}.field`,n,{required:!0}),r.operator!==void 0&&r.operator!=="="&&r.operator!=="!="&&r.operator!=="in"&&r.operator!=="not_in"&&r.operator!=="contains"&&r.operator!=="not_contains"&&r.operator!=="between"&&r.operator!=="not_between"&&r.operator!==">"&&r.operator!==">="&&r.operator!=="<"&&r.operator!=="<="&&r.operator!=="is_null"&&r.operator!=="is_not_null"&&n.push(s("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${d}.operator`)),r.value===void 0&&r.values===void 0&&r.operator!=="is_null"&&r.operator!=="is_not_null"&&n.push(s("missing_analytics_filter_value","Analytics filter needs value or values unless it is a null check.",d)),r.values!==void 0&&!Array.isArray(r.values)&&n.push(s("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${d}.values`))})}}function v(e){var o,f,d,r;const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.version!==void 0&&e.version!==1&&i.push(s("invalid_version","Analytics intent version must be 1.","version")),y(e.source,"source",i,{requireSqlText:e.kind!=="sql"||!a(e.sql)}),e.kind==="metric"){const u=Array.isArray(e.metrics)?e.metrics.filter(a):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(s("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(t=>!a(t))&&i.push(s("invalid_metric_list","Metric intent metrics must be an array of non-empty metric names.","metrics")),u.length>0){const t=h(u);t&&i.push(s("duplicate_metric",`Metric intent has duplicate metric "${t}".`,"metrics"))}if(e.primaryMetric!==void 0&&(!a(e.primaryMetric)||u.length>0&&!u.includes(e.primaryMetric))&&i.push(s("invalid_primary_metric","Metric intent primaryMetric must be one of metrics.","primaryMetric")),e.metricRefs!==void 0&&!Array.isArray(e.metricRefs))i.push(s("invalid_metric_refs","Metric intent metricRefs must be an array of field references.","metricRefs"));else if(Array.isArray(e.metricRefs)){e.metricRefs.forEach((c,_)=>{m(c,`metricRefs.${_}`,i,{required:!0})});const t=e.metricRefs.filter(c=>p(c)&&a(c.name)).map(c=>c.name);(u.length>0?t.filter(c=>!u.includes(c)):[]).length>0&&i.push(s("invalid_metric_refs","Metric intent metricRefs must reference names included in metrics.","metricRefs"))}e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(t=>!p(t)||!a(t.name))&&i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.timeWindow!==void 0&&(g(e.timeWindow,"timeWindow",i),e.dateField||i.push(s("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),$(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((t,l)=>{m(t,`dimensions.${l}`,i)}),q(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(s("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(u=>!p(u)||!a(u.name))&&i.push(s("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((u,t)=>{m(u,`fields.${t}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i)):e.kind==="inputOptions"?((!e.field||!a(e.field.name))&&i.push(s("missing_input_options_field","Input options intent needs a field.","field")),m(e.field,"field",i,{required:!0})):e.kind==="sql"?(((o=e.source)==null?void 0:o.kind)!=="sql"&&((f=e.source)==null?void 0:f.kind)!=="physical"&&i.push(s("invalid_sql_source","SQL analytics intent must use a SQL or physical source.","source")),a(e.sql)&&((d=e.source)==null?void 0:d.kind)==="sql"&&a(e.source.sql)&&b(e.sql)!==b(e.source.sql)&&i.push(s("conflicting_sql","SQL analytics intent cannot define different SQL text in source.sql and sql.","sql")),!a(e.sql)&&!(((r=e.source)==null?void 0:r.kind)==="sql"&&a(e.source.sql))&&i.push(s("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((u,t)=>{m(u,`fields.${t}`,i)})):i.push(s("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:x(i)}}function b(e){return e.replace(/\r\n/g,`
2
- `).trim()}function A(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_operation_intent","Operation intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(s("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(s("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((o,f)=>{a(o.id)||i.push(s("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${f}.id`)),a(o.prompt)||i.push(s("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${f}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(a(e.instruction)||i.push(s("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const o=v(e.analyticsIntent);i.push(...o.errors),n.push(...o.warnings)}}else i.push(s("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:w(i)}}function S(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:n,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(s("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(s("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const o=A(e.operationIntent);return i.push(...o.errors),n.push(...o.warnings),Array.isArray(e.plannedToolCalls)||i.push(s("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:n,repairHints:w(i)}}function w(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function x(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_metric":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose one exact metric from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_input_options_field":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the exact field whose option values should be listed."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function R(e,i,n,o){if(!e||typeof e!="object"){n.push(s("invalid_view","Dashboard view must be an object.",i));return}if(a(e.title)||n.push(s("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(s("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){a(e.text)||o.push(s("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(s("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const f=v(e.analytics);for(const d of f.errors)n.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`));for(const d of f.warnings)o.push(s(d.code,d.message,`${i}.analytics${d.path?`.${d.path}`:""}`))}function I(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(s("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(s("invalid_kind","Experience intent kind must be dashboard.")),a(e.title)||i.push(s("missing_title","Dashboard intent needs a title.","title"));const o=Array.isArray(e.inputs)?e.inputs:[],f=h(o.filter(p).map(t=>t.id).filter(t=>typeof t=="string"));f&&i.push(s("duplicate_input_id",`Duplicate input id: ${f}.`,"inputs"));for(const[t,l]of o.entries()){const c=`inputs.${t}`;if(!p(l)){i.push(s("invalid_input","Dashboard input must be an object.",c));continue}a(l.id)||i.push(s("missing_input_id","Input needs an id.",`${c}.id`)),a(l.label)||i.push(s("missing_input_label","Input needs a label.",`${c}.label`)),!l.field||!a(l.field.name)?i.push(s("missing_input_field","Input needs a field.",`${c}.field`)):m(l.field,`${c}.field`,i),l.source&&y(l.source,`${c}.source`,i)}const d=Array.isArray(e.sections)?e.sections:[];d.length===0&&i.push(s("missing_sections","Dashboard intent needs at least one section.","sections"));const r=d.flatMap(t=>t&&typeof t=="object"&&Array.isArray(t.views)?t.views.filter(p).map(l=>l.id).filter(l=>!!l):[]),u=h(r);u&&i.push(s("duplicate_view_id",`Duplicate dashboard view id: ${u}.`,"sections"));for(const[t,l]of d.entries()){const c=`sections.${t}`;if(!l||typeof l!="object"){i.push(s("invalid_section","Dashboard section must be an object.",c));continue}if(a(l.title)||i.push(s("missing_section_title","Dashboard section needs a title.",c)),!Array.isArray(l.views)||l.views.length===0){i.push(s("missing_section_views","Dashboard section needs at least one view.",`${c}.views`));continue}for(const[_,k]of l.views.entries())R(k,`${c}.views.${_}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.validateSemaphorAnalyticsIntent=v;exports.validateSemaphorAnalyticsRecoveryPlan=S;exports.validateSemaphorDashboardIntent=I;exports.validateSemaphorOperationIntent=A;