react-semaphor 0.1.349 → 0.1.351

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 (43) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/chunks/{calendar-preferences-dialog-gMb9JPpz.js → calendar-preferences-dialog-BAEeX-ug.js} +1 -1
  4. package/dist/chunks/{calendar-preferences-dialog-C2vX2dga.js → calendar-preferences-dialog-C8flqOjZ.js} +1 -1
  5. package/dist/chunks/{dashboard-briefing-launcher-DjzTWk1f.js → dashboard-briefing-launcher--zBBsBWm.js} +1 -1
  6. package/dist/chunks/{dashboard-briefing-launcher-Cx4NkJil.js → dashboard-briefing-launcher-DU9x-97H.js} +3 -3
  7. package/dist/chunks/{dashboard-controls-Yo3L7krV.js → dashboard-controls-BwMjIqjP.js} +3 -3
  8. package/dist/chunks/{dashboard-controls-BTz9RgtD.js → dashboard-controls-CMShL7m9.js} +1 -1
  9. package/dist/chunks/{dashboard-json-3_OGzDQh.js → dashboard-json-CHKC0bf-.js} +1 -1
  10. package/dist/chunks/{dashboard-json-OLpSyYFR.js → dashboard-json-kD_jszqF.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-073yhfDG.js → edit-dashboard-visual-C1RUXsWi.js} +3 -3
  12. package/dist/chunks/{edit-dashboard-visual-DXzKEyXJ.js → edit-dashboard-visual-C1vIFm6H.js} +1 -1
  13. package/dist/chunks/{index-DTSZ23bE.js → index-BJLPtQeK.js} +5425 -5432
  14. package/dist/chunks/{index-Alj8oDV1.js → index-D2ai-cZQ.js} +48 -48
  15. package/dist/chunks/{resource-management-panel-BvTTEaef.js → resource-management-panel-UkMvz7Cp.js} +2 -2
  16. package/dist/chunks/{resource-management-panel-DLJ6uWYJ.js → resource-management-panel-f4Od7wCB.js} +1 -1
  17. package/dist/chunks/{use-create-flow-overlay-state-BMr_844V.js → use-create-flow-overlay-state-C49F2KdU.js} +1 -1
  18. package/dist/chunks/{use-create-flow-overlay-state-gRSXj8dj.js → use-create-flow-overlay-state-jpQ2BxKF.js} +2 -2
  19. package/dist/chunks/{use-visual-utils-7w01KGK7.js → use-visual-utils-CiN4zNkZ.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-D5zrmYt8.js → use-visual-utils-D8Pe1PSH.js} +1 -1
  21. package/dist/chunks/{validators-B-NiYgGc.js → validators-BnLhuIhd.js} +189 -176
  22. package/dist/chunks/validators-Cu_w8ZEP.js +1 -0
  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 +1 -1
  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-sdk/index.cjs +1 -1
  30. package/dist/data-app-sdk/index.js +1 -1
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.js +5 -5
  33. package/dist/style.css +1 -1
  34. package/dist/surfboard/index.cjs +1 -1
  35. package/dist/surfboard/index.js +2 -2
  36. package/dist/types/analytics-protocol.d.ts +8 -0
  37. package/dist/types/dashboard-assistant.d.ts +8 -0
  38. package/dist/types/dashboard-authoring.d.ts +8 -0
  39. package/dist/types/data-app-builder.d.ts +8 -0
  40. package/dist/types/data-app-sdk.d.ts +8 -0
  41. package/dist/types/main.d.ts +8 -0
  42. package/package.json +1 -1
  43. package/dist/chunks/validators-DlEfynH8.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-Alj8oDV1.js"),e=require("../chunks/common-types-C73-Ud1-.js"),a=require("../chunks/calendar-preferences-dialog-C2vX2dga.js");exports.Surfboard=r.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=a.CalendarPreferencesDialog;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-D2ai-cZQ.js"),e=require("../chunks/common-types-C73-Ud1-.js"),a=require("../chunks/calendar-preferences-dialog-C8flqOjZ.js");exports.Surfboard=r.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=a.CalendarPreferencesDialog;
@@ -1,6 +1,6 @@
1
- import { a as e } from "../chunks/index-DTSZ23bE.js";
1
+ import { a as e } from "../chunks/index-BJLPtQeK.js";
2
2
  import { C, E } from "../chunks/common-types-4bjoIgvm.js";
3
- import { C as s } from "../chunks/calendar-preferences-dialog-gMb9JPpz.js";
3
+ import { C as s } from "../chunks/calendar-preferences-dialog-BAEeX-ug.js";
4
4
  export {
5
5
  C as CONTROL_CARD_DEFAULT_VALUE,
6
6
  s as CalendarPreferencesDialog,
@@ -335,6 +335,14 @@ export declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | Sem
335
335
  export declare type SemaphorAnalyticsFilterBase = {
336
336
  id?: string;
337
337
  field: SemaphorFieldRef;
338
+ /**
339
+ * Controls where the filter is applied in an aggregate query.
340
+ *
341
+ * `row` means pre-aggregation filtering (`WHERE`).
342
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
343
+ * for measure fields the execution engine can aggregate safely.
344
+ */
345
+ scope?: 'row' | 'aggregate';
338
346
  };
339
347
 
340
348
  export declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
@@ -636,6 +636,14 @@ declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAn
636
636
  declare type SemaphorAnalyticsFilterBase = {
637
637
  id?: string;
638
638
  field: SemaphorFieldRef;
639
+ /**
640
+ * Controls where the filter is applied in an aggregate query.
641
+ *
642
+ * `row` means pre-aggregation filtering (`WHERE`).
643
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
644
+ * for measure fields the execution engine can aggregate safely.
645
+ */
646
+ scope?: 'row' | 'aggregate';
639
647
  };
640
648
 
641
649
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
@@ -1816,6 +1816,14 @@ declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAn
1816
1816
  declare type SemaphorAnalyticsFilterBase = {
1817
1817
  id?: string;
1818
1818
  field: SemaphorFieldRef;
1819
+ /**
1820
+ * Controls where the filter is applied in an aggregate query.
1821
+ *
1822
+ * `row` means pre-aggregation filtering (`WHERE`).
1823
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
1824
+ * for measure fields the execution engine can aggregate safely.
1825
+ */
1826
+ scope?: 'row' | 'aggregate';
1819
1827
  };
1820
1828
 
1821
1829
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
@@ -493,6 +493,14 @@ declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAn
493
493
  declare type SemaphorAnalyticsFilterBase = {
494
494
  id?: string;
495
495
  field: SemaphorFieldRef;
496
+ /**
497
+ * Controls where the filter is applied in an aggregate query.
498
+ *
499
+ * `row` means pre-aggregation filtering (`WHERE`).
500
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
501
+ * for measure fields the execution engine can aggregate safely.
502
+ */
503
+ scope?: 'row' | 'aggregate';
496
504
  };
497
505
 
498
506
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
@@ -38,6 +38,14 @@ declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAn
38
38
  declare type SemaphorAnalyticsFilterBase = {
39
39
  id?: string;
40
40
  field: SemaphorFieldRef;
41
+ /**
42
+ * Controls where the filter is applied in an aggregate query.
43
+ *
44
+ * `row` means pre-aggregation filtering (`WHERE`).
45
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
46
+ * for measure fields the execution engine can aggregate safely.
47
+ */
48
+ scope?: 'row' | 'aggregate';
41
49
  };
42
50
 
43
51
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
@@ -4408,6 +4408,14 @@ declare type SemaphorAnalyticsFilter = SemaphorAnalyticsValueFilter | SemaphorAn
4408
4408
  declare type SemaphorAnalyticsFilterBase = {
4409
4409
  id?: string;
4410
4410
  field: SemaphorFieldRef;
4411
+ /**
4412
+ * Controls where the filter is applied in an aggregate query.
4413
+ *
4414
+ * `row` means pre-aggregation filtering (`WHERE`).
4415
+ * `aggregate` means post-aggregation filtering (`HAVING`) and is valid only
4416
+ * for measure fields the execution engine can aggregate safely.
4417
+ */
4418
+ scope?: 'row' | 'aggregate';
4411
4419
  };
4412
4420
 
4413
4421
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.349",
8
+ "version": "0.1.351",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1 +0,0 @@
1
- "use strict";const T=require("./source-identity-C-xaeE_I.js");function n(e,i,t){return t?{code:e,message:i,path:t}:{code:e,message:i}}function D(e){for(let i=0;i<e.length;i+=1){const t=e[i];if(e.some((r,o)=>o!==i&&k(r,t)))return!1}return!0}function $(e,i){return T.semaphorFieldRefsMatch(e,i)}function k(e,i){return $(e,i)&&y(e)===y(i)}function F(e){return`Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`}function j(e,i){return b(e,i).length===1}function O(e,i){return b(e,i).length===1}function b(e,i){return i.filter(r=>C(e,r))}function C(e,i){return E(e,i)?e.source?$(i,e):!0:!1}function E(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||q(e,i)&&y(i)!==y(e))}function q(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function y(e){return(e.aggregate||"SUM").toUpperCase()}const U=/^(\d{4})-(\d{2})-(\d{2})$/,P=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;function g(e){if(typeof e!="string")return null;const i=e.trim(),t=U.exec(i);if(t){const[,v,A,I]=t;return M(v,A,I)?new Date(Date.UTC(Number(v),Number(A)-1,Number(I))):null}const r=P.exec(i);if(!r)return null;const[,o,a,s,p,c,l="00",,f]=r;if(!M(o,a,s)||!_(p,0,23)||!_(c,0,59)||!_(l,0,59)||!G(f))return null;const h=new Date(i);return Number.isFinite(h.getTime())?h:null}function M(e,i,t){const r=Number(e),o=Number(i),a=Number(t);if(!Number.isInteger(r)||!Number.isInteger(o)||!Number.isInteger(a)||o<1||o>12)return!1;const s=new Date(Date.UTC(r,o-1,a));return s.getUTCFullYear()===r&&s.getUTCMonth()===o-1&&s.getUTCDate()===a}function _(e,i,t){const r=Number(e);return Number.isInteger(r)&&r>=i&&r<=t}function G(e){if(e==="Z")return!0;const i=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(i&&_(i[2],0,23)&&_(i[3],0,59))}function d(e){return typeof e=="string"&&e.trim().length>0}function u(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function S(e){const i=new Set;for(const t of e){if(i.has(t))return t;i.add(t)}return null}const H=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function N(e,i,t){if(!e||typeof e!="object"){t.push(n("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||t.push(n("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||t.push(n("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||t.push(n("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||t.push(n("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||t.push(n("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}t.push(n("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,t,r={}){if(!e||!u(e)){r.required&&t.push(n("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||t.push(n("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&N(e.source,`${i}.source`,t),L(e.aggregate,`${i}.aggregate`,t)}function L(e,i,t){e!==void 0&&(typeof e!="string"||!H.has(e))&&t.push(n("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function V(e,i){if(e.analysis===void 0)return;if(!u(e.analysis)){i.push(n("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(n("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(n("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(n("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(n("invalid_metric_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:t}=e.analysis;t!==void 0&&B(t,"analysis.timeWindow",i)}function B(e,i,t){if(!u(e)){t.push(n("invalid_time_window","Time window must be a structured object.",i));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&t.push(n("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(d(e.start)||t.push(n("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),d(e.end)||t.push(n("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),d(e.start)&&d(e.end)){const r=g(e.start),o=g(e.end);r||t.push(n("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),o||t.push(n("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),r&&o&&r.getTime()>o.getTime()&&t.push(n("invalid_time_window","Absolute time window start must be before or equal to end.",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"&&t.push(n("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)&&t.push(n("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&t.push(n("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&t.push(n("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function Q(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push(n("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((r,o)=>{const a=`${i}.${o}`;if(!u(r)){t.push(n("invalid_analytics_filter","Analytics filter must be a structured object.",a));return}const s=r;m(s.field,`${a}.field`,t,{required:!0});const p=s.operator==="is_null"||s.operator==="is_not_null";if(s.operator!==void 0&&s.operator!=="="&&s.operator!=="!="&&s.operator!=="in"&&s.operator!=="not_in"&&s.operator!=="contains"&&s.operator!=="not_contains"&&s.operator!=="between"&&s.operator!=="not_between"&&s.operator!==">"&&s.operator!==">="&&s.operator!=="<"&&s.operator!=="<="&&s.operator!=="is_null"&&s.operator!=="is_not_null"&&t.push(n("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${a}.operator`)),s.values===void 0&&!p&&t.push(n("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",a)),p&&s.values!==void 0){t.push(n("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${a}.values`));return}if(s.values!==void 0&&!Array.isArray(s.values)){t.push(n("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${a}.values`));return}if(s.values!==void 0){const c=s.values.length;if(s.operator==="between"||s.operator==="not_between"){c!==2&&t.push(n("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${a}.values`));return}(s.operator==="contains"||s.operator==="not_contains"||s.operator==="="||s.operator==="!="||s.operator===">"||s.operator===">="||s.operator==="<"||s.operator==="<="||s.operator===void 0)&&c!==1&&t.push(n("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${a}.values`))}})}}function w(e){var r;const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:t,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(n("invalid_version","Analytics intent version must be 1.","version")),N(e.source,"source",i),e.kind==="metric"){const o=Array.isArray(e.metrics)?e.metrics.filter(a=>u(a)&&d(a.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(n("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(a=>!u(a)||!d(a.name))&&i.push(n("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),o.forEach((a,s)=>{m(a,`metrics.${s}`,i,{required:!0})}),o.length>0&&!D(o)){const a=o.find((s,p)=>o.some((c,l)=>l!==p&&k(c,s)));a&&i.push(n("duplicate_metric",F(a),"metrics"))}if(u(e.primaryMetric)&&d(e.primaryMetric.name)&&b(e.primaryMetric,o).length>1&&i.push(n("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(m(e.primaryMetric,"primaryMetric",i,{required:!0}),u(e.primaryMetric)&&d(e.primaryMetric.name)&&o.length>0&&!j(e.primaryMetric,o)&&i.push(n("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(n("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(a=>!u(a)||!d(a.name))&&i.push(n("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&&(B(e.timeWindow,"timeWindow",i),e.dateField||i.push(n("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),Q(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((a,s)=>{m(a,`dimensions.${s}`,i)}),e.orderBy!==void 0){if(!u(e.orderBy))i.push(n("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(n("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),u(e.orderBy.field)&&d(e.orderBy.field.name)){const a=[...o,...e.timeGrain&&e.dateField&&u(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(s=>u(s)&&d(s.name)):[]];a.length>0&&!O(e.orderBy.field,a)&&i.push(n("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}V(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(n("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(o=>!u(o)||!d(o.name))&&i.push(n("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.orderBy!==void 0&&(u(e.orderBy)?(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(n("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(n("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!d(e.field.name))&&i.push(n("missing_input_options_field","Input options intent needs a field.","field")),m(e.field,"field",i,{required:!0})):e.kind==="sql"?(((r=e.source)==null?void 0:r.kind)!=="sql"&&i.push(n("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(n("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((o,a)=>{m(o,`fields.${a}`,i)})):i.push(n("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:Y(i)}}function x(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_operation_intent","Operation intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(n("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(n("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((r,o)=>{d(r.id)||i.push(n("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${o}.id`)),d(r.prompt)||i.push(n("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${o}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(n("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const r=w(e.analyticsIntent);i.push(...r.errors),t.push(...r.warnings)}}else i.push(n("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:R(i)}}function X(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:t,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(n("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(n("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const r=x(e.operationIntent);return i.push(...r.errors),t.push(...r.warnings),Array.isArray(e.plannedToolCalls)||i.push(n("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:t,repairHints:R(i)}}function R(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 Y(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 Z(e,i,t,r){if(!e||typeof e!="object"){t.push(n("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||t.push(n("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){t.push(n("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||r.push(n("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){t.push(n("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const o=w(e.analytics);for(const a of o.errors)t.push(n(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`));for(const a of o.warnings)r.push(n(a.code,a.message,`${i}.analytics${a.path?`.${a.path}`:""}`))}function z(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[n("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:t};e.version!==1&&i.push(n("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(n("invalid_kind","Experience intent kind must be dashboard.")),d(e.title)||i.push(n("missing_title","Dashboard intent needs a title.","title"));const r=Array.isArray(e.inputs)?e.inputs:[],o=S(r.filter(u).map(c=>c.id).filter(c=>typeof c=="string"));o&&i.push(n("duplicate_input_id",`Duplicate input id: ${o}.`,"inputs"));for(const[c,l]of r.entries()){const f=`inputs.${c}`;if(!u(l)){i.push(n("invalid_input","Dashboard input must be an object.",f));continue}d(l.id)||i.push(n("missing_input_id","Input needs an id.",`${f}.id`)),d(l.label)||i.push(n("missing_input_label","Input needs a label.",`${f}.label`)),!l.field||!d(l.field.name)?i.push(n("missing_input_field","Input needs a field.",`${f}.field`)):m(l.field,`${f}.field`,i)}const a=Array.isArray(e.sections)?e.sections:[];a.length===0&&i.push(n("missing_sections","Dashboard intent needs at least one section.","sections"));const s=a.flatMap(c=>c&&typeof c=="object"&&Array.isArray(c.views)?c.views.filter(u).map(l=>l.id).filter(l=>!!l):[]),p=S(s);p&&i.push(n("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[c,l]of a.entries()){const f=`sections.${c}`;if(!l||typeof l!="object"){i.push(n("invalid_section","Dashboard section must be an object.",f));continue}if(d(l.title)||i.push(n("missing_section_title","Dashboard section needs a title.",f)),!Array.isArray(l.views)||l.views.length===0){i.push(n("missing_section_views","Dashboard section needs at least one view.",`${f}.views`));continue}for(const[h,v]of l.views.entries())Z(v,`${f}.views.${h}`,i,t)}return{ok:i.length===0,errors:i,warnings:t}}exports.parseSemaphorIsoTimeWindowBoundary=g;exports.validateSemaphorAnalyticsIntent=w;exports.validateSemaphorAnalyticsRecoveryPlan=X;exports.validateSemaphorDashboardIntent=z;exports.validateSemaphorOperationIntent=x;