react-semaphor 0.1.368 → 0.1.370
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.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +1 -1
- package/dist/brand-studio/index.cjs +5 -5
- package/dist/brand-studio/index.js +24 -23
- package/dist/chunks/{braces-Cc86y9Ov.js → braces-C3-w6xDL.js} +1 -1
- package/dist/chunks/{braces-CXvY9MwQ.js → braces-C8QqW4wu.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-BOFlzOJg.js → calendar-preferences-dialog-6q51A6XC.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-ZzwfJv2J.js → calendar-preferences-dialog-CUGzkNcE.js} +1 -1
- package/dist/chunks/{chevrons-up-down-CUZL1zaU.js → chevrons-up-down-CnCSGY02.js} +1 -1
- package/dist/chunks/{chevrons-up-down-qQMadOWA.js → chevrons-up-down-DSvLu4Ye.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-9-PCYMjR.js → dashboard-briefing-launcher-BEZnvIla.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-D2lBFqAd.js → dashboard-briefing-launcher-ptERmNJr.js} +176 -177
- package/dist/chunks/{dashboard-controls-D4bUHAjX.js → dashboard-controls-CGt6_hMf.js} +11 -11
- package/dist/chunks/{dashboard-controls-BIk094Ah.js → dashboard-controls-CqKC5oEk.js} +77 -77
- package/dist/chunks/{dashboard-json-DImOf512.js → dashboard-json-6SgPm_QW.js} +13 -14
- package/dist/chunks/dashboard-json-CYSbOdmE.js +1 -0
- package/dist/chunks/{edit-dashboard-visual-DTxkV6Fl.js → edit-dashboard-visual-ByQx_M2i.js} +8 -9
- package/dist/chunks/{edit-dashboard-visual-BHKlcqQR.js → edit-dashboard-visual-w6hKbjlw.js} +1 -1
- package/dist/chunks/index-BtqYNH_S.js +1361 -0
- package/dist/chunks/{index-BVEIk-rB.js → index-CPyEi9gS.js} +72498 -76193
- package/dist/chunks/{palette-DPuAc82h.js → palette-D-f4-82S.js} +1 -1
- package/dist/chunks/{palette-C1k347Tb.js → palette-DUGktM-M.js} +1 -1
- package/dist/chunks/{resource-management-panel-BeHceP2D.js → resource-management-panel-Bf8-3eUf.js} +1 -1
- package/dist/chunks/{resource-management-panel-BOfbSf48.js → resource-management-panel-mJ84NxzC.js} +152 -152
- package/dist/chunks/save-D3YYinDz.js +6 -0
- package/dist/chunks/save-kkBEBeLg.js +21 -0
- package/dist/chunks/{switch-xcWLtWs0.js → switch-Dkx2qEOr.js} +758 -776
- package/dist/chunks/{switch-C0S63HAv.js → switch-fIkmwzUt.js} +27 -32
- package/dist/chunks/{use-create-flow-overlay-state-B5FygfQL.js → use-create-flow-overlay-state-BfoXDDrd.js} +190 -189
- package/dist/chunks/use-create-flow-overlay-state-c6rCm36x.js +26 -0
- package/dist/chunks/{use-visual-utils-DxDE8S8M.js → use-visual-utils-C_c-aiqi.js} +1 -1
- package/dist/chunks/{use-visual-utils-CszWnFBW.js → use-visual-utils-NN0e3fBP.js} +13 -13
- package/dist/chunks/validation-DYL3ArlL.js +1 -0
- package/dist/chunks/validation-PPSpYtVf.js +900 -0
- package/dist/chunks/validators-CgxWT8UX.js +1 -0
- package/dist/chunks/validators-DBNa-eb1.js +1799 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +51 -1
- package/dist/data-app-builder/index.js +3666 -2
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +661 -389
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +14 -14
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +472 -3
- package/dist/types/dashboard-assistant.d.ts +469 -3
- package/dist/types/dashboard-authoring.d.ts +170 -2
- package/dist/types/data-app-builder.d.ts +167 -2
- package/dist/types/data-app-sdk-validation.d.ts +576 -25
- package/dist/types/data-app-sdk.d.ts +655 -37
- package/dist/types/main.d.ts +167 -2
- package/package.json +1 -1
- package/dist/chunks/dashboard-json-Bo1kX6W1.js +0 -1
- package/dist/chunks/index-HjDeEytV.js +0 -1411
- package/dist/chunks/use-create-flow-overlay-state-DOXTbTcQ.js +0 -26
- package/dist/chunks/validation-CrUjNWby.js +0 -689
- package/dist/chunks/validation-DGl8wnTt.js +0 -1
- package/dist/chunks/validators-Dq5X4mp0.js +0 -1
- package/dist/chunks/validators-L0xEXtjf.js +0 -965
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const G=require("./source-identity-C-xaeE_I.js");function Q(e){const i=D(e);return O(i)?i:void 0}function D(e){if(typeof e!="string"||e.trim().length===0)return;const i=e.trim().toLowerCase().replace(/_/g," ");switch(i){case"eq":case"equals":case"=":return"=";case"neq":case"not equals":case"not equal":case"!=":return"!=";case"in":return"in";case"not in":return"not_in";case"contains":case"like":return"contains";case"not contains":case"not like":return"not_contains";case"between":return"between";case"not between":return"not_between";case">":case">=":case"<":case"<=":return i;case"is null":return"is_null";case"is not null":return"is_not_null";default:return X(e)?e:void 0}}function O(e){return e==="="||e==="!="||e==="in"||e==="not_in"||e==="contains"||e==="not_contains"||e==="between"||e==="not_between"||e===">"||e===">="||e==="<"||e==="<="}function X(e){return O(e)||e==="not_contains"||e==="is_null"||e==="is_not_null"}function a(e,i,t){return t?{code:e,message:i,path:t}:{code:e,message:i}}function Y(e){for(let i=0;i<e.length;i+=1){const t=e[i];if(e.some((s,n)=>n!==i&&E(s,t)))return!1}return!0}function F(e,i){return G.semaphorFieldRefsMatch(e,i)}function E(e,i){return F(e,i)&&b(e)===b(i)}function Z(e){return`Metric intent has duplicate metric "${e.name}" with the same aggregate (${b(e)}). Use different aggregates to request both, or remove one entry.`}function N(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function J(e,i,t){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e)){t.push(a("invalid_sql_default_parameters","SQL defaultParameters must be an object keyed by parameter name.",i));return}Object.entries(e).forEach(([s,n])=>{if(!s.trim()){t.push(a("invalid_sql_default_parameter_name","SQL defaultParameters names must be non-empty strings.",`${i}.${s}`));return}(Array.isArray(n)?n.every(N):N(n))||t.push(a("invalid_sql_default_parameter_value","SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",`${i}.${s}`))})}}function K(e,i){return S(e,i).length===1}function W(e,i){return S(e,i).length===1}function S(e,i){return i.filter(s=>ee(e,s))}function ee(e,i){return ie(e,i)?e.source?F(i,e):!0:!1}function ie(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||te(e,i)&&b(i)!==b(e))}function te(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function b(e){return(e.aggregate||"SUM").toUpperCase()}const ae=/^(\d{4})-(\d{2})-(\d{2})$/,ne=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})$/;function x(e){if(typeof e!="string")return null;const i=e.trim(),t=ae.exec(i);if(t){const[,v,I,P]=t;return q(v,I,P)?new Date(Date.UTC(Number(v),Number(I)-1,Number(P))):null}const s=ne.exec(i);if(!s)return null;const[,n,o,r,d,l,u="00",,p]=s;if(!q(n,o,r)||!_(d,0,23)||!_(l,0,59)||!_(u,0,59)||!se(p))return null;const h=new Date(i);return Number.isFinite(h.getTime())?h:null}function q(e,i,t){const s=Number(e),n=Number(i),o=Number(t);if(!Number.isInteger(s)||!Number.isInteger(n)||!Number.isInteger(o)||n<1||n>12)return!1;const r=new Date(Date.UTC(s,n-1,o));return r.getUTCFullYear()===s&&r.getUTCMonth()===n-1&&r.getUTCDate()===o}function _(e,i,t){const s=Number(e);return Number.isInteger(s)&&s>=i&&s<=t}function se(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 c(e){return typeof e=="string"&&e.trim().length>0}function m(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function B(e,i,t){if(e!==void 0){if(!m(e)){t.push(a("invalid_pagination","Pagination must be an object with positive integer page and pageSize.",i));return}(!Number.isInteger(e.page)||typeof e.page!="number"||e.page<1)&&t.push(a("invalid_pagination_page","Pagination page must be a positive integer.",`${i}.page`)),(!Number.isInteger(e.pageSize)||typeof e.pageSize!="number"||e.pageSize<1)&&t.push(a("invalid_pagination_page_size","Pagination pageSize must be a positive integer.",`${i}.pageSize`))}}function w(e){const i=new Set;for(const t of e){if(i.has(t))return t;i.add(t)}return null}function g(e,i,t,s){w(e.filter(o=>c(o)))&&s.push(a("duplicate_matrix_public_id",`Matrix ${t} ids must be unique so sort and expansion references are unambiguous.`,i))}const re=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function C(e,i,t){if(!e||typeof e!="object"){t.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){c(e.domainId)||t.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),c(e.datasetName)||t.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){c(e.connectionId)||t.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),c(e.tableName)||t.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){c(e.connectionId)||t.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}t.push(a("invalid_source_kind","Source kind is not supported.",i))}function f(e,i,t,s={}){if(!e||!m(e)){s.required&&t.push(a("missing_field_ref","Field reference needs a name.",i));return}c(e.name)||t.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&C(e.source,`${i}.source`,t),y(e.aggregate,`${i}.aggregate`,t)}function y(e,i,t){e!==void 0&&(typeof e!="string"||!re.has(e))&&t.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function oe(e,i,t){e!==void 0&&e!=="hour"&&e!=="day"&&e!=="week"&&e!=="month"&&e!=="quarter"&&e!=="year"&&t.push(a("invalid_time_grain","Time grain must be hour, day, week, month, quarter, or year.",i))}function L(e,i,t,s){e!=="asc"&&e!=="desc"&&t.push(a(s,"Sort direction must be asc or desc.",i))}function U(e,i,t,s){e!==void 0&&e!=="warehouseDefault"&&e!=="first"&&e!=="last"&&t.push(a(s,"Null ordering must be warehouseDefault, first, or last.",i))}function H(e,i,t,s){e!==void 0&&e!=="global"&&e!=="withinParent"&&t.push(a(s,"Sort scope must be global or withinParent.",i))}function le(e,i,t){e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal enabled must be a boolean.",`${i}.enabled`)),e.position!==void 0&&e.position!=="before"&&e.position!=="after"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal position must be before or after.",`${i}.position`)),e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal label must be a string.",`${i}.label`))}function de(e,i,t){if(L(e.direction,`${i}.direction`,t,"invalid_matrix_sort_direction"),U(e.nulls,`${i}.nulls`,t,"invalid_matrix_sort_nulls"),H(e.scope,`${i}.scope`,t,"invalid_matrix_sort_scope"),!m(e.by)){t.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${i}.by`));return}if(e.by.kind!=="label"){if(e.by.kind==="field"){f(e.by.field,`${i}.by.field`,t,{required:!0}),y(e.by.aggregate,`${i}.by.aggregate`,t);return}t.push(a("invalid_matrix_sort_by","Matrix axis sort by must be label or field.",`${i}.by.kind`))}}function T(e,i,t,s){if(!Array.isArray(e))return s.required?t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i)):e!==void 0&&t.push(a("invalid_matrix_columns","Matrix columns must be an array of axis levels.",i)),[];s.required&&e.length===0&&t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i));const n=[];return e.forEach((o,r)=>{const d=`${i}.${r}`;if(!m(o)){t.push(a("invalid_matrix_axis_level","Matrix axis levels must be structured objects.",d));return}const l=o;n.push(l),l.id!==void 0&&!c(l.id)&&t.push(a("invalid_matrix_axis_level_id","Matrix axis level id must be a non-empty string.",`${d}.id`)),f(l.field,`${d}.field`,t,{required:!0}),oe(l.grain,`${d}.grain`,t),l.label!==void 0&&typeof l.label!="string"&&t.push(a("invalid_matrix_axis_label","Matrix axis level label must be a string.",`${d}.label`)),l.subtotal!==void 0&&typeof l.subtotal!="boolean"&&(m(l.subtotal)?le(l.subtotal,`${d}.subtotal`,t):t.push(a("invalid_matrix_subtotal","Matrix subtotal must be a boolean or structured options object.",`${d}.subtotal`))),l.sortBy!==void 0&&(m(l.sortBy)?de(l.sortBy,`${d}.sortBy`,t):t.push(a("invalid_matrix_sort_by","Matrix axis sortBy must be a structured object.",`${d}.sortBy`)))}),n}function ue(e,i,t){if(!m(e)){t.push(a("invalid_matrix_total_behavior","Matrix total behavior must be a structured object.",i));return}if(e.kind!=="defaultAggregate"&&e.kind!=="blank"&&e.kind!=="labelOnly"&&e.kind!=="customAggregate"&&e.kind!=="percentOfParent"&&e.kind!=="percentOfGrandTotal"&&e.kind!=="customExpression"){t.push(a("invalid_matrix_total_behavior","Matrix total behavior kind is not supported.",`${i}.kind`));return}e.kind==="customAggregate"&&(Object.prototype.hasOwnProperty.call(e,"aggregate")?y(e.aggregate,`${i}.aggregate`,t):t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an aggregate.",`${i}.aggregate`))),e.kind==="customExpression"&&!c(e.expressionId)&&t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an expressionId.",`${i}.expressionId`)),e.kind==="labelOnly"&&e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_total_behavior","Matrix label-only total behavior label must be a string.",`${i}.label`))}function ce(e,i,t){if(!Array.isArray(e)||e.length===0)return t.push(a("missing_matrix_values","Matrix intent needs at least one value field.",i)),[];const s=[];return e.forEach((n,o)=>{const r=`${i}.${o}`;if(!m(n)){t.push(a("invalid_matrix_value","Matrix values must be structured objects.",r));return}const d=n;s.push(d),d.id!==void 0&&!c(d.id)&&t.push(a("invalid_matrix_value_id","Matrix value id must be a non-empty string.",`${r}.id`)),f(d.field,`${r}.field`,t,{required:!0}),y(d.aggregate,`${r}.aggregate`,t),d.label!==void 0&&typeof d.label!="string"&&t.push(a("invalid_matrix_value_label","Matrix value label must be a string.",`${r}.label`)),d.totalBehavior!==void 0&&ue(d.totalBehavior,`${r}.totalBehavior`,t)}),s}function me(e,i,t){if(!m(e)){t.push(a("invalid_matrix_totals","Matrix totals must be a structured object.",i));return}for(const s of["rows","columns"]){const n=e[s];n!==void 0&&n!==!0&&n!==!1&&n!=="perLevel"&&t.push(a("invalid_matrix_totals","Matrix total axis setting must be a boolean or perLevel.",`${i}.${s}`))}if(e.grandTotal!==void 0&&typeof e.grandTotal!="boolean")if(!m(e.grandTotal))t.push(a("invalid_matrix_totals","Matrix grandTotal must be a boolean or structured object.",`${i}.grandTotal`));else for(const s of["rows","columns"]){const n=e.grandTotal[s];n!==void 0&&typeof n!="boolean"&&t.push(a("invalid_matrix_totals","Matrix grandTotal rows/columns must be booleans.",`${i}.grandTotal.${s}`))}e.rowPosition!==void 0&&e.rowPosition!=="top"&&e.rowPosition!=="bottom"&&t.push(a("invalid_matrix_totals","Matrix row total position must be top or bottom.",`${i}.rowPosition`)),e.columnPosition!==void 0&&e.columnPosition!=="left"&&e.columnPosition!=="right"&&t.push(a("invalid_matrix_totals","Matrix column total position must be left or right.",`${i}.columnPosition`))}function $(e,i,t,s){if(!Array.isArray(e)){s.push(a("invalid_matrix_path","Matrix member path must be an array of path segments.",i));return}e.forEach((n,o)=>{const r=`${i}.${o}`;if(!m(n)){s.push(a("invalid_matrix_path","Matrix path segment must be a structured object.",r));return}const d=n;if(!c(d.levelId)){s.push(a("stable_id_required","Matrix path segments must reference an explicit public axis level id.",`${r}.levelId`));return}Object.prototype.hasOwnProperty.call(n,"value")||s.push(a("invalid_matrix_path","Matrix path segments must include a value property; use explicit null for null members.",`${r}.value`)),t.has(d.levelId)||s.push(a("stable_id_required","Matrix path segment levelId must match an explicit public axis level id.",`${r}.levelId`))})}function j(e,i,t,s){if(!m(e)){s.push(a("invalid_matrix_expansion","Matrix expansion axis options must be structured objects.",i));return}e.defaultDepth!==void 0&&(typeof e.defaultDepth!="number"||!Number.isInteger(e.defaultDepth)||e.defaultDepth<0)&&s.push(a("invalid_matrix_expansion","Matrix expansion defaultDepth must be a non-negative integer.",`${i}.defaultDepth`)),e.lazy!==void 0&&typeof e.lazy!="boolean"&&s.push(a("invalid_matrix_expansion","Matrix expansion lazy must be a boolean.",`${i}.lazy`)),e.expandedPaths!==void 0&&(Array.isArray(e.expandedPaths)?e.expandedPaths.forEach((n,o)=>{$(n,`${i}.expandedPaths.${o}`,t,s)}):s.push(a("invalid_matrix_expansion","Matrix expandedPaths must be an array of member paths.",`${i}.expandedPaths`)))}function fe(e,i,t,s){if(e!==void 0){if(!m(e)){s.push(a("invalid_matrix_expansion","Matrix expansion must be a structured object.","expansion"));return}e.rows!==void 0&&j(e.rows,"expansion.rows",i,s),e.columns!==void 0&&j(e.columns,"expansion.columns",t,s)}}function pe(e,i,t,s,n){if(e!==void 0){if(!Array.isArray(e)){n.push(a("invalid_matrix_sort","Matrix sort must be an array of sort rules.","sort"));return}e.forEach((o,r)=>{const d=`sort.${r}`;if(!m(o)){n.push(a("invalid_matrix_sort","Matrix sort rule must be a structured object.",d));return}const l=o;l.axis!=="row"&&l.axis!=="column"&&n.push(a("invalid_matrix_sort","Matrix sort axis must be row or column.",`${d}.axis`));const u=l.axis==="column"?t:i;if(l.targetId!==void 0&&!u.has(l.targetId)&&n.push(a("stable_id_required","Matrix sort targetId must reference an explicit public axis level id.",`${d}.targetId`)),L(l.direction,`${d}.direction`,n,"invalid_matrix_sort_direction"),U(l.nulls,`${d}.nulls`,n,"invalid_matrix_sort_nulls"),H(l.scope,`${d}.scope`,n,"invalid_matrix_sort_scope"),!m(l.by)){n.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${d}.by`));return}if(l.by.kind!=="label"){if(l.by.kind==="field"){f(l.by.field,`${d}.by.field`,n,{required:!0}),y(l.by.aggregate,`${d}.by.aggregate`,n);return}if(l.by.kind==="value"){(!c(l.by.valueId)||!s.has(l.by.valueId))&&n.push(a("stable_id_required","Matrix value sort must reference an explicit public value id.",`${d}.by.valueId`)),l.by.rowPath!==void 0&&$(l.by.rowPath,`${d}.by.rowPath`,i,n),l.by.columnPath!==void 0&&$(l.by.columnPath,`${d}.by.columnPath`,t,n);return}n.push(a("invalid_matrix_sort_by","Matrix sort by must be label, field, or value.",`${d}.by.kind`))}})}}function _e(e,i){if(e!==void 0){if(!m(e)){i.push(a("invalid_matrix_layout","Matrix layout must be a structured object.","layout"));return}e.hierarchy!==void 0&&e.hierarchy!=="compact"&&e.hierarchy!=="tabular"&&e.hierarchy!=="outline"&&i.push(a("invalid_matrix_layout","Matrix hierarchy layout must be compact, tabular, or outline.","layout.hierarchy")),e.valuesPlacement!==void 0&&e.valuesPlacement!=="columns"&&e.valuesPlacement!=="rows"&&i.push(a("invalid_matrix_layout","Matrix valuesPlacement must be columns or rows.","layout.valuesPlacement")),e.stickyRowHeaders!==void 0&&typeof e.stickyRowHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyRowHeaders must be a boolean.","layout.stickyRowHeaders")),e.stickyColumnHeaders!==void 0&&typeof e.stickyColumnHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyColumnHeaders must be a boolean.","layout.stickyColumnHeaders"))}}function R(e,i,t){if(!m(e)){t.push(a("invalid_matrix_display_limits","Matrix display limit must be a structured object.",i));return}(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1)&&t.push(a("invalid_matrix_display_limits","Matrix display limit must be a positive integer.",`${i}.limit`)),e.by!==void 0&&e.by!=="label"&&e.by!=="value"&&t.push(a("invalid_matrix_display_limits","Matrix display limit by must be label or value.",`${i}.by`)),e.direction!==void 0&&e.direction!=="top"&&e.direction!=="bottom"&&t.push(a("invalid_matrix_display_limits","Matrix display limit direction must be top or bottom.",`${i}.direction`)),e.others!==void 0&&typeof e.others!="boolean"&&(m(e.others)?e.others.label!==void 0&&typeof e.others.label!="string"&&t.push(a("invalid_matrix_display_limits","Matrix display limit others label must be a string.",`${i}.others.label`)):t.push(a("invalid_matrix_display_limits","Matrix display limit others must be a boolean or structured object.",`${i}.others`)))}function be(e,i){if(e!==void 0){if(!m(e)){i.push(a("invalid_matrix_display_limits","Matrix displayLimits must be a structured object.","displayLimits"));return}e.rows!==void 0&&R(e.rows,"displayLimits.rows",i),e.columns!==void 0&&R(e.columns,"displayLimits.columns",i)}}function ye(e,i){var l;((l=e.source)==null?void 0:l.kind)==="sql"&&i.push(a("unsupported_matrix_sql_source","Matrix analytics intent does not support raw SQL sources.","source.kind"));const t=T(e.rows,"rows",i,{required:!0}),s=T(e.columns,"columns",i,{required:!1}),n=ce(e.values,"values",i);A(e.filters,"filters",i),e.totals!==void 0&&me(e.totals,"totals",i),g(t.map(u=>u.id),"rows","row axis level",i),g(s.map(u=>u.id),"columns","column axis level",i),g(n.map(u=>u.id),"values","value",i);const o=new Set(t.map(u=>u.id).filter(u=>c(u))),r=new Set(s.map(u=>u.id).filter(u=>c(u))),d=new Set(n.map(u=>u.id).filter(u=>c(u)));pe(e.sort,o,r,d,i),fe(e.expansion,o,r,i),_e(e.layout,i),be(e.displayLimits,i)}function he(e,i){if(e.analysis===void 0)return;if(!m(e.analysis)){i.push(a("invalid_metric_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(a("invalid_metric_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(a("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(a("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(a("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&&M(t,"analysis.timeWindow",i)}function M(e,i,t){if(!m(e)){t.push(a("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(a("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(c(e.start)||t.push(a("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),c(e.end)||t.push(a("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),c(e.start)&&c(e.end)){const s=x(e.start),n=x(e.end);s||t.push(a("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),n||t.push(a("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),s&&n&&s.getTime()>n.getTime()&&t.push(a("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(a("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(a("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(a("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(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function A(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((s,n)=>{var l;const o=`${i}.${n}`;if(!m(s)){t.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",o));return}const r=s;f(r.field,`${o}.field`,t,{required:!0}),r.scope!==void 0&&r.scope!=="row"&&r.scope!=="aggregate"&&t.push(a("invalid_analytics_filter_scope","Analytics filter scope must be row or aggregate.",`${o}.scope`)),r.scope==="aggregate"&&((l=r.field)==null?void 0:l.role)!==void 0&&r.field.role!=="measure"&&t.push(a("invalid_analytics_filter_scope","Aggregate-scope analytics filters must target a measure field.",`${o}.scope`));const d=r.operator==="is_null"||r.operator==="is_not_null";if(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"&&t.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${o}.operator`)),r.values===void 0&&!d&&t.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",o)),d&&r.values!==void 0){t.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${o}.values`));return}if(r.values!==void 0&&!Array.isArray(r.values)){t.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${o}.values`));return}if(r.values!==void 0){const u=r.values.length;if(r.operator==="between"||r.operator==="not_between"){u!==2&&t.push(a("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${o}.values`));return}(r.operator==="contains"||r.operator==="not_contains"||r.operator==="="||r.operator==="!="||r.operator===">"||r.operator===">="||r.operator==="<"||r.operator==="<="||r.operator===void 0)&&u!==1&&t.push(a("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${o}.values`))}})}}function k(e){var s;const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Analytics intent version must be 1.","version")),C(e.source,"source",i),e.kind==="metric"){const n=Array.isArray(e.metrics)?e.metrics.filter(o=>m(o)&&c(o.name)):[];if(!Array.isArray(e.metrics)||e.metrics.length===0?i.push(a("missing_metric","Metric intent needs at least one metric.","metrics")):e.metrics.some(o=>!m(o)||!c(o.name))&&i.push(a("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),n.forEach((o,r)=>{f(o,`metrics.${r}`,i,{required:!0})}),n.length>0&&!Y(n)){const o=n.find((r,d)=>n.some((l,u)=>u!==d&&E(l,r)));o&&i.push(a("duplicate_metric",Z(o),"metrics"))}if(m(e.primaryMetric)&&c(e.primaryMetric.name)&&S(e.primaryMetric,n).length>1&&i.push(a("ambiguous_primary_metric","Metric intent primaryMetric must identify exactly one selected metric.","primaryMetric")),e.primaryMetric!==void 0&&(f(e.primaryMetric,"primaryMetric",i,{required:!0}),m(e.primaryMetric)&&c(e.primaryMetric.name)&&n.length>0&&!K(e.primaryMetric,n)&&i.push(a("invalid_primary_metric","Metric intent primaryMetric must match one metric field reference.","primaryMetric"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(a("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(o=>!m(o)||!c(o.name))&&i.push(a("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&f(e.dateField,"dateField",i),e.timeWindow!==void 0&&(M(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),A(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((o,r)=>{f(o,`dimensions.${r}`,i)}),e.orderBy!==void 0){if(!m(e.orderBy))i.push(a("invalid_metric_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_metric_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),m(e.orderBy.field)&&c(e.orderBy.field.name)){const o=[...n,...e.timeGrain&&e.dateField&&m(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(r=>m(r)&&c(r.name)):[]];o.length>0&&!W(e.orderBy.field,o)&&i.push(a("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}he(e,i)}else e.kind==="records"?(!Array.isArray(e.fields)||e.fields.length===0?i.push(a("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(n=>!m(n)||!c(n.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((n,o)=>{f(n,`fields.${o}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i),B(e.pagination,"pagination",i),e.timeWindow!==void 0&&(M(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Records timeWindow needs a dateField.","dateField"))),A(e.filters,"filters",i),Array.isArray(e.filters)&&e.filters.forEach((n,o)=>{m(n)&&n.scope==="aggregate"&&i.push(a("unsupported_record_filter_scope","Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",`filters.${o}.scope`))}),e.orderBy!==void 0&&(m(e.orderBy)?(f(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(a("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy")))):e.kind==="inputOptions"?((!e.field||!c(e.field.name))&&i.push(a("missing_input_options_field","Input options intent needs a field.","field")),f(e.field,"field",i,{required:!0})):e.kind==="matrix"?ye(e,i):e.kind==="sql"?(((s=e.source)==null?void 0:s.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),c(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),J(e.defaultParameters,"defaultParameters",i),Array.isArray(e.fields)&&e.fields.forEach((n,o)=>{f(n,`fields.${o}`,i)}),B(e.pagination,"pagination",i)):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:ge(i)}}function z(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(a("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((s,n)=>{c(s.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${n}.id`)),c(s.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${n}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(c(e.instruction)||i.push(a("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const s=k(e.analyticsIntent);i.push(...s.errors),t.push(...s.warnings)}}else i.push(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:V(i)}}function ve(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(a("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const s=z(e.operationIntent);return i.push(...s.errors),t.push(...s.warnings),Array.isArray(e.plannedToolCalls)||i.push(a("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:t,repairHints:V(i)}}function V(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 ge(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_matrix_rows":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Choose at least one row axis level for the matrix table."};case"missing_matrix_values":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose at least one value field for the matrix table."};case"unsupported_matrix_sql_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."};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 xe(e,i,t,s){if(!e||typeof e!="object"){t.push(a("invalid_view","Dashboard view must be an object.",i));return}if(c(e.title)||t.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){t.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){c(e.text)||s.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){t.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}e.presentation.kind==="matrixTable"&&e.analytics.kind!=="matrix"&&t.push(a("invalid_matrix_view_analytics","Matrix table views need matrix analytics intent.",`${i}.analytics.kind`));const n=k(e.analytics);for(const o of n.errors)t.push(a(o.code,o.message,`${i}.analytics${o.path?`.${o.path}`:""}`));for(const o of n.warnings)s.push(a(o.code,o.message,`${i}.analytics${o.path?`.${o.path}`:""}`))}function we(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:t};e.version!==1&&i.push(a("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(a("invalid_kind","Experience intent kind must be dashboard.")),c(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const s=Array.isArray(e.inputs)?e.inputs:[],n=w(s.filter(m).map(l=>l.id).filter(l=>typeof l=="string"));n&&i.push(a("duplicate_input_id",`Duplicate input id: ${n}.`,"inputs"));for(const[l,u]of s.entries()){const p=`inputs.${l}`;if(!m(u)){i.push(a("invalid_input","Dashboard input must be an object.",p));continue}c(u.id)||i.push(a("missing_input_id","Input needs an id.",`${p}.id`)),c(u.label)||i.push(a("missing_input_label","Input needs a label.",`${p}.label`)),!u.field||!c(u.field.name)?i.push(a("missing_input_field","Input needs a field.",`${p}.field`)):f(u.field,`${p}.field`,i)}const o=Array.isArray(e.sections)?e.sections:[];o.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const r=o.flatMap(l=>l&&typeof l=="object"&&Array.isArray(l.views)?l.views.filter(m).map(u=>u.id).filter(u=>!!u):[]),d=w(r);d&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${d}.`,"sections"));for(const[l,u]of o.entries()){const p=`sections.${l}`;if(!u||typeof u!="object"){i.push(a("invalid_section","Dashboard section must be an object.",p));continue}if(c(u.title)||i.push(a("missing_section_title","Dashboard section needs a title.",p)),!Array.isArray(u.views)||u.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${p}.views`));continue}for(const[h,v]of u.views.entries())xe(v,`${p}.views.${h}`,i,t)}return{ok:i.length===0,errors:i,warnings:t}}exports.normalizeSemaphorAnalyticsFilterOperator=D;exports.normalizeSemaphorInputOperator=Q;exports.parseSemaphorIsoTimeWindowBoundary=x;exports.validateSemaphorAnalyticsIntent=k;exports.validateSemaphorAnalyticsRecoveryPlan=ve;exports.validateSemaphorDashboardIntent=we;exports.validateSemaphorOperationIntent=z;
|