react-semaphor 0.1.344 → 0.1.346
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/chunks/validators-8R9pr2K9.js +1 -0
- package/dist/chunks/{validators-BqEnmlC6.js → validators-yMB7Tm4j.js} +120 -109
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +233 -220
- package/dist/types/analytics-protocol.d.ts +22 -6
- package/dist/types/dashboard-authoring.d.ts +1 -0
- package/dist/types/dashboard.d.ts +1 -0
- package/dist/types/data-app-sdk.d.ts +205 -190
- package/dist/types/main.d.ts +1 -0
- package/dist/types/shared.d.ts +1 -0
- package/dist/types/surfboard.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunks/validators-v8WAqhaN.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/validators-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/validators-8R9pr2K9.js"),t=require("../chunks/catalog-field-grounding-Du6mKDcF.js");function d(e,a={}){const i=o(e),s={connectionId:a.connectionId,connectionType:e,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return i.includes("postgres")?{...s,prefixLevels:["schema","table"],dialect:"postgres"}:i.includes("mysql")?{...s,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:i.includes("mssql")||i.includes("sqlserver")?{...s,dialect:"mssql",supportsFilterClause:!1}:i.includes("redshift")?{...s,prefixLevels:["schema","table"],dialect:"redshift"}:i.includes("snowflake")?{...s,dialect:"snowflake"}:i.includes("clickhouse")?{connectionId:a.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:i==="s3"||i==="api"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:i==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:i==="googlesheets"||i==="fileupload"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:i==="s3tables"?{...s,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:i==="bigquery"?{...s,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:s}function c(e){const a=o(e);switch(a){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return a;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";default:return"unknown"}}function u(e){return e.capabilities.prefixLevels.every(a=>!!l(e.source,a))}function m(e){const a=e.quoteIdentifier??p;return e.capabilities.prefixLevels.map(i=>l(e.source,i)).filter(i=>!!i).map(i=>a(i,e.capabilities.dialect)).join(".")}function l(e,a){return a==="database"?e.databaseName:a==="schema"?e.schemaName:e.tableName}function p(e,a){return a==="mysql"||a==="bigquery"||a==="clickhouse"||a==="duckdb"?`\`${e.replace(/`/g,"``")}\``:a==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function o(e){if(typeof e!="string")return"";const a=[];for(const i of e.trim().toLowerCase())b(i)&&a.push(i);return a.join("")}function b(e){const a=e.charCodeAt(0);return a>=48&&a<=57||a>=97&&a<=122}const n={kind:"semantic",domainId:"domain_sales",datasetName:"orders",connectionId:"conn_sales",label:"Orders"},f={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:n,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},comparison:{kind:"previous_period"},limit:1},revenueTrend:{version:1,kind:"records",id:"revenue-trend",label:"Revenue trend",source:n,fields:[{name:"order_date",role:"date",dataType:"date",label:"Order Date"},{name:"revenue",role:"measure",dataType:"number"}],dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"month",limit:100},topCustomersRecords:{version:1,kind:"records",id:"top-customers",label:"Top customers",source:n,fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"segment",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}],orderBy:{field:{name:"revenue",role:"measure"},direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",source:n,field:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:n,metrics:[{name:"revenue",role:"measure"}],primaryMetric:{name:"revenue",role:"measure"},dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},inboundSupplierConcentration:{version:1,kind:"metric",id:"inbound-supplier-concentration",label:"Inbound supplier concentration",source:n,metrics:[{name:"net_tons",role:"measure"},{name:"ticket_value",role:"measure"}],primaryMetric:{name:"net_tons",role:"measure"},dateField:{name:"ticket_date",role:"date",dataType:"date"},timeWindow:{unit:"month",value:6,anchor:"latest_available"},dimensions:[{name:"supplier_id",role:"dimension",dataType:"number"}],filters:[{field:{name:"direction",role:"dimension",dataType:"string"},operator:"=",values:["Inbound"]}],limit:15},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"sql",connectionId:"conn_sales",dialect:"postgres"},sql:"SELECT customer_name, SUM(revenue) AS revenue FROM public.orders GROUP BY customer_name ORDER BY revenue DESC LIMIT 20",limit:20,rationale:"Ranking is SQL-natural because it requires ordering grouped aggregate rows.",fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}]}};exports.preferSemaphorFieldRefMetadata=r.preferSemaphorFieldRefMetadata;exports.preferSemaphorSourceMetadata=r.preferSemaphorSourceMetadata;exports.semaphorFieldRefsMatch=r.semaphorFieldRefsMatch;exports.semaphorSourceIdentityKey=r.semaphorSourceIdentityKey;exports.semaphorSourcesReferToSameDataset=r.semaphorSourcesReferToSameDataset;exports.validateSemaphorAnalyticsIntent=r.validateSemaphorAnalyticsIntent;exports.validateSemaphorAnalyticsRecoveryPlan=r.validateSemaphorAnalyticsRecoveryPlan;exports.validateSemaphorDashboardIntent=r.validateSemaphorDashboardIntent;exports.validateSemaphorOperationIntent=r.validateSemaphorOperationIntent;exports.buildAnalyticsCatalogFieldSummary=t.buildAnalyticsCatalogFieldSummary;exports.getAnalyticsCatalogFieldCandidates=t.getAnalyticsCatalogFieldCandidates;exports.getAnalyticsCatalogFieldName=t.getAnalyticsCatalogFieldName;exports.isAnalyticsCatalogDateField=t.isAnalyticsCatalogDateField;exports.isAnalyticsCatalogDimensionField=t.isAnalyticsCatalogDimensionField;exports.isAnalyticsCatalogMetricField=t.isAnalyticsCatalogMetricField;exports.isAnalyticsDateLikeDataType=t.isAnalyticsDateLikeDataType;exports.isAnalyticsMetricIdentifierField=t.isAnalyticsMetricIdentifierField;exports.isAnalyticsTechnicalIdentifierField=t.isAnalyticsTechnicalIdentifierField;exports.normalizeAnalyticsCatalogDataType=t.normalizeAnalyticsCatalogDataType;exports.normalizeAnalyticsCatalogName=t.normalizeAnalyticsCatalogName;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=f;exports.buildSemaphorQualifiedSourcePath=m;exports.getSemaphorConnectionCapabilities=d;exports.normalizeSemaphorDialect=c;exports.semaphorSourceHasRequiredCoordinates=u;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as v, p as h, e as g, s as y, d as k, v as C, b as I, c as S, a as T } from "../chunks/validators-
|
|
1
|
+
import { f as v, p as h, e as g, s as y, d as k, v as C, b as I, c as S, a as T } from "../chunks/validators-yMB7Tm4j.js";
|
|
2
2
|
import { j as F, a as _, g as A, c as R, h as L, f as D, i as x, e as M, d as N, b as w, n as O } from "../chunks/catalog-field-grounding-DoEBOXQd.js";
|
|
3
3
|
function d(e, a = {}) {
|
|
4
4
|
const r = n(e), t = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function _(e){return e?e.kind==="semantic"?[e.kind,e.domainId,e.datasetId||"",e.datasetName].join(":"):e.kind==="physical"?[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":"):[e.kind,e.connectionId,e.dialect||"",e.label||""].join(":"):""}function b(e,i){return!e||!i?e===i:e.kind!==i.kind?!1:e.kind==="semantic"&&i.kind==="semantic"?e.domainId!==i.domainId?!1:e.datasetId&&i.datasetId?e.datasetId===i.datasetId:e.datasetName===i.datasetName:_(e)===_(i)}function A(e,i){return e.kind!=="semantic"||i.kind!=="semantic"?e:{...e,datasetId:e.datasetId||i.datasetId,label:e.label||i.label,connectionId:e.connectionId||i.connectionId}}function I(e,i){return e.name===i.name&&b(e.source,i.source)}function F(e,i){return{...e,label:e.label||i.label,role:e.role||i.role,dataType:e.dataType||i.dataType,source:e.source&&i.source?A(e.source,i.source):e.source||i.source}}function a(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function j(e){for(let i=0;i<e.length;i+=1){const n=e[i];if(e.some((o,r)=>r!==i&&M(o,n)))return!1}return!0}function S(e,i){return I(e,i)}function M(e,i){return S(e,i)&&y(e)===y(i)}function T(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 D(e,i){return h(e,i).length===1}function x(e,i){return h(e,i).length===1}function h(e,i){return i.filter(o=>q(e,o))}function q(e,i){return C(e,i)?e.source?S(i,e):!0:!1}function C(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||E(e,i)&&y(i)!==y(e))}function E(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()}function d(e){return typeof e=="string"&&e.trim().length>0}function c(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function g(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}const P=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function k(e,i,n){if(!e||typeof e!="object"){n.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){d(e.domainId)||n.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),d(e.datasetName)||n.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){d(e.connectionId)||n.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),d(e.tableName)||n.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){d(e.connectionId)||n.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}n.push(a("invalid_source_kind","Source kind is not supported.",i))}function f(e,i,n,o={}){if(!e||!c(e)){o.required&&n.push(a("missing_field_ref","Field reference needs a name.",i));return}d(e.name)||n.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&k(e.source,`${i}.source`,n),O(e.aggregate,`${i}.aggregate`,n)}function O(e,i,n){e!==void 0&&(typeof e!="string"||!P.has(e))&&n.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}function H(e,i){if(e.analysis===void 0)return;if(!c(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:n}=e.analysis;n!==void 0&&w(n,"analysis.timeWindow",i)}function w(e,i,n){if(!c(e)){n.push(a("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(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)&&n.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"&&n.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"&&n.push(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function U(e,i,n){if(e!==void 0){if(!Array.isArray(e)){n.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((o,r)=>{const s=`${i}.${r}`;if(!c(o)){n.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",s));return}const t=o;f(t.field,`${s}.field`,n,{required:!0});const p=t.operator==="is_null"||t.operator==="is_not_null";if(t.operator!==void 0&&t.operator!=="="&&t.operator!=="!="&&t.operator!=="in"&&t.operator!=="not_in"&&t.operator!=="contains"&&t.operator!=="not_contains"&&t.operator!=="between"&&t.operator!=="not_between"&&t.operator!==">"&&t.operator!==">="&&t.operator!=="<"&&t.operator!=="<="&&t.operator!=="is_null"&&t.operator!=="is_not_null"&&n.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${s}.operator`)),t.values===void 0&&!p&&n.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",s)),p&&t.values!==void 0){n.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${s}.values`));return}t.values!==void 0&&!Array.isArray(t.values)&&n.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${s}.values`))})}}function v(e){var o;const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(a("invalid_version","Analytics intent version must be 1.","version")),k(e.source,"source",i),e.kind==="metric"){const r=Array.isArray(e.metrics)?e.metrics.filter(s=>c(s)&&d(s.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(s=>!c(s)||!d(s.name))&&i.push(a("invalid_metric_list","Metric intent metrics must be an array of field references with names.","metrics")),r.forEach((s,t)=>{f(s,`metrics.${t}`,i,{required:!0})}),r.length>0&&!j(r)){const s=r.find((t,p)=>r.some((u,l)=>l!==p&&M(u,t)));s&&i.push(a("duplicate_metric",T(s),"metrics"))}if(c(e.primaryMetric)&&d(e.primaryMetric.name)&&h(e.primaryMetric,r).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}),c(e.primaryMetric)&&d(e.primaryMetric.name)&&r.length>0&&!D(e.primaryMetric,r)&&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(s=>!c(s)||!d(s.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&&(w(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),U(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((s,t)=>{f(s,`dimensions.${t}`,i)}),e.orderBy!==void 0){if(!c(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")),c(e.orderBy.field)&&d(e.orderBy.field.name)){const s=[...r,...e.timeGrain&&e.dateField&&c(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(t=>c(t)&&d(t.name)):[]];s.length>0&&!x(e.orderBy.field,s)&&i.push(a("invalid_metric_order_by","Metric intent orderBy.field must match one selected metric, grouped dateField, or dimension.","orderBy.field"))}}H(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(r=>!c(r)||!d(r.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)}),e.dateField!==void 0&&f(e.dateField,"dateField",i),e.orderBy!==void 0&&(c(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||!d(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==="sql"?(((o=e.source)==null?void 0:o.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),d(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),Array.isArray(e.fields)&&e.fields.forEach((r,s)=>{f(r,`fields.${s}`,i)})):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:L(i)}}function $(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(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((o,r)=>{d(o.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${r}.id`)),d(o.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${r}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(d(e.instruction)||i.push(a("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(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:n,repairHints:N(i)}}function G(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("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(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 o=$(e.operationIntent);return i.push(...o.errors),n.push(...o.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:n,repairHints:N(i)}}function N(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 L(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 Q(e,i,n,o){if(!e||typeof e!="object"){n.push(a("invalid_view","Dashboard view must be an object.",i));return}if(d(e.title)||n.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){d(e.text)||o.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const r=v(e.analytics);for(const s of r.errors)n.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`));for(const s of r.warnings)o.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`))}function V(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};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.")),d(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const o=Array.isArray(e.inputs)?e.inputs:[],r=g(o.filter(c).map(u=>u.id).filter(u=>typeof u=="string"));r&&i.push(a("duplicate_input_id",`Duplicate input id: ${r}.`,"inputs"));for(const[u,l]of o.entries()){const m=`inputs.${u}`;if(!c(l)){i.push(a("invalid_input","Dashboard input must be an object.",m));continue}d(l.id)||i.push(a("missing_input_id","Input needs an id.",`${m}.id`)),d(l.label)||i.push(a("missing_input_label","Input needs a label.",`${m}.label`)),!l.field||!d(l.field.name)?i.push(a("missing_input_field","Input needs a field.",`${m}.field`)):f(l.field,`${m}.field`,i)}const s=Array.isArray(e.sections)?e.sections:[];s.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const t=s.flatMap(u=>u&&typeof u=="object"&&Array.isArray(u.views)?u.views.filter(c).map(l=>l.id).filter(l=>!!l):[]),p=g(t);p&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${p}.`,"sections"));for(const[u,l]of s.entries()){const m=`sections.${u}`;if(!l||typeof l!="object"){i.push(a("invalid_section","Dashboard section must be an object.",m));continue}if(d(l.title)||i.push(a("missing_section_title","Dashboard section needs a title.",m)),!Array.isArray(l.views)||l.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${m}.views`));continue}for(const[R,B]of l.views.entries())Q(B,`${m}.views.${R}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.preferSemaphorFieldRefMetadata=F;exports.preferSemaphorSourceMetadata=A;exports.semaphorFieldRefsMatch=I;exports.semaphorSourceIdentityKey=_;exports.semaphorSourcesReferToSameDataset=b;exports.validateSemaphorAnalyticsIntent=v;exports.validateSemaphorAnalyticsRecoveryPlan=G;exports.validateSemaphorDashboardIntent=V;exports.validateSemaphorOperationIntent=$;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function h(e) {
|
|
2
2
|
return e ? e.kind === "semantic" ? [
|
|
3
3
|
e.kind,
|
|
4
4
|
e.domainId,
|
|
@@ -17,10 +17,10 @@ function y(e) {
|
|
|
17
17
|
e.label || ""
|
|
18
18
|
].join(":") : "";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return !e || !i ? e === i : e.kind !== i.kind ? !1 : e.kind === "semantic" && i.kind === "semantic" ? e.domainId !== i.domainId ? !1 : e.datasetId && i.datasetId ? e.datasetId === i.datasetId : e.datasetName === i.datasetName :
|
|
20
|
+
function $(e, i) {
|
|
21
|
+
return !e || !i ? e === i : e.kind !== i.kind ? !1 : e.kind === "semantic" && i.kind === "semantic" ? e.domainId !== i.domainId ? !1 : e.datasetId && i.datasetId ? e.datasetId === i.datasetId : e.datasetName === i.datasetName : h(e) === h(i);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function N(e, i) {
|
|
24
24
|
return e.kind !== "semantic" || i.kind !== "semantic" ? e : {
|
|
25
25
|
...e,
|
|
26
26
|
datasetId: e.datasetId || i.datasetId,
|
|
@@ -28,51 +28,62 @@ function S(e, i) {
|
|
|
28
28
|
connectionId: e.connectionId || i.connectionId
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return e.name === i.name &&
|
|
31
|
+
function B(e, i) {
|
|
32
|
+
return e.name === i.name && $(e.source, i.source);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function L(e, i) {
|
|
35
35
|
return {
|
|
36
36
|
...e,
|
|
37
37
|
label: e.label || i.label,
|
|
38
38
|
role: e.role || i.role,
|
|
39
39
|
dataType: e.dataType || i.dataType,
|
|
40
|
-
source: e.source && i.source ?
|
|
40
|
+
source: e.source && i.source ? N(e.source, i.source) : e.source || i.source
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function a(e, i, s) {
|
|
44
44
|
return s ? { code: e, message: i, path: s } : { code: e, message: i };
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function R(e) {
|
|
47
47
|
for (let i = 0; i < e.length; i += 1) {
|
|
48
48
|
const s = e[i];
|
|
49
49
|
if (e.some(
|
|
50
|
-
(
|
|
50
|
+
(o, r) => r !== i && b(o, s)
|
|
51
51
|
))
|
|
52
52
|
return !1;
|
|
53
53
|
}
|
|
54
54
|
return !0;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function g(e, i) {
|
|
57
|
+
return B(e, i);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
function b(e, i) {
|
|
60
|
+
return g(e, i) && y(e) === y(i);
|
|
61
|
+
}
|
|
62
|
+
function F(e) {
|
|
63
|
+
return `Metric intent has duplicate metric "${e.name}" with the same aggregate (${y(e)}). Use different aggregates to request both, or remove one entry.`;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function j(e, i) {
|
|
66
|
+
return _(e, i).length === 1;
|
|
67
|
+
}
|
|
68
|
+
function x(e, i) {
|
|
69
|
+
return _(e, i).length === 1;
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
(
|
|
71
|
+
function _(e, i) {
|
|
72
|
+
return i.filter(
|
|
73
|
+
(o) => T(e, o)
|
|
71
74
|
);
|
|
72
|
-
return e.source ? s.some((r) => _(r, e)) : s.length === 1;
|
|
73
75
|
}
|
|
74
|
-
function
|
|
75
|
-
return
|
|
76
|
+
function T(e, i) {
|
|
77
|
+
return D(e, i) ? e.source ? g(i, e) : !0 : !1;
|
|
78
|
+
}
|
|
79
|
+
function D(e, i) {
|
|
80
|
+
return !(i.name !== e.name || e.role !== void 0 && i.role !== void 0 && i.role !== e.role || q(e, i) && y(i) !== y(e));
|
|
81
|
+
}
|
|
82
|
+
function q(e, i) {
|
|
83
|
+
return e.role === "measure" || i.role === "measure" || e.aggregate !== void 0 || i.aggregate !== void 0;
|
|
84
|
+
}
|
|
85
|
+
function y(e) {
|
|
86
|
+
return (e.aggregate || "SUM").toUpperCase();
|
|
76
87
|
}
|
|
77
88
|
function d(e) {
|
|
78
89
|
return typeof e == "string" && e.trim().length > 0;
|
|
@@ -89,7 +100,7 @@ function v(e) {
|
|
|
89
100
|
}
|
|
90
101
|
return null;
|
|
91
102
|
}
|
|
92
|
-
const
|
|
103
|
+
const C = /* @__PURE__ */ new Set([
|
|
93
104
|
"SUM",
|
|
94
105
|
"COUNT",
|
|
95
106
|
"AVG",
|
|
@@ -98,7 +109,7 @@ const j = /* @__PURE__ */ new Set([
|
|
|
98
109
|
"MEDIAN",
|
|
99
110
|
"DISTINCT"
|
|
100
111
|
]);
|
|
101
|
-
function
|
|
112
|
+
function A(e, i, s) {
|
|
102
113
|
if (!e || typeof e != "object") {
|
|
103
114
|
s.push(a("missing_source", "Analytics intent needs a source.", i));
|
|
104
115
|
return;
|
|
@@ -147,19 +158,19 @@ function g(e, i, s) {
|
|
|
147
158
|
}
|
|
148
159
|
s.push(a("invalid_source_kind", "Source kind is not supported.", i));
|
|
149
160
|
}
|
|
150
|
-
function f(e, i, s,
|
|
161
|
+
function f(e, i, s, o = {}) {
|
|
151
162
|
if (!e || !c(e)) {
|
|
152
|
-
|
|
163
|
+
o.required && s.push(
|
|
153
164
|
a("missing_field_ref", "Field reference needs a name.", i)
|
|
154
165
|
);
|
|
155
166
|
return;
|
|
156
167
|
}
|
|
157
168
|
d(e.name) || s.push(
|
|
158
169
|
a("missing_field_ref", "Field reference needs a name.", `${i}.name`)
|
|
159
|
-
), e.source !== void 0 &&
|
|
170
|
+
), e.source !== void 0 && A(e.source, `${i}.source`, s), E(e.aggregate, `${i}.aggregate`, s);
|
|
160
171
|
}
|
|
161
|
-
function
|
|
162
|
-
e !== void 0 && (typeof e != "string" || !
|
|
172
|
+
function E(e, i, s) {
|
|
173
|
+
e !== void 0 && (typeof e != "string" || !C.has(e)) && s.push(
|
|
163
174
|
a(
|
|
164
175
|
"invalid_aggregate",
|
|
165
176
|
"Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",
|
|
@@ -167,7 +178,7 @@ function T(e, i, s) {
|
|
|
167
178
|
)
|
|
168
179
|
);
|
|
169
180
|
}
|
|
170
|
-
function
|
|
181
|
+
function P(e, i) {
|
|
171
182
|
if (e.analysis === void 0)
|
|
172
183
|
return;
|
|
173
184
|
if (!c(e.analysis)) {
|
|
@@ -210,9 +221,9 @@ function x(e, i) {
|
|
|
210
221
|
)
|
|
211
222
|
);
|
|
212
223
|
const { timeWindow: s } = e.analysis;
|
|
213
|
-
s !== void 0 &&
|
|
224
|
+
s !== void 0 && k(s, "analysis.timeWindow", i);
|
|
214
225
|
}
|
|
215
|
-
function
|
|
226
|
+
function k(e, i, s) {
|
|
216
227
|
if (!c(e)) {
|
|
217
228
|
s.push(
|
|
218
229
|
a(
|
|
@@ -249,7 +260,7 @@ function b(e, i, s) {
|
|
|
249
260
|
)
|
|
250
261
|
);
|
|
251
262
|
}
|
|
252
|
-
function
|
|
263
|
+
function O(e, i, s) {
|
|
253
264
|
if (e !== void 0) {
|
|
254
265
|
if (!Array.isArray(e)) {
|
|
255
266
|
s.push(
|
|
@@ -261,9 +272,9 @@ function D(e, i, s) {
|
|
|
261
272
|
);
|
|
262
273
|
return;
|
|
263
274
|
}
|
|
264
|
-
e.forEach((
|
|
265
|
-
const n = `${i}.${
|
|
266
|
-
if (!c(
|
|
275
|
+
e.forEach((o, r) => {
|
|
276
|
+
const n = `${i}.${r}`;
|
|
277
|
+
if (!c(o)) {
|
|
267
278
|
s.push(
|
|
268
279
|
a(
|
|
269
280
|
"invalid_analytics_filter",
|
|
@@ -273,7 +284,7 @@ function D(e, i, s) {
|
|
|
273
284
|
);
|
|
274
285
|
return;
|
|
275
286
|
}
|
|
276
|
-
const t =
|
|
287
|
+
const t = o;
|
|
277
288
|
f(t.field, `${n}.field`, s, {
|
|
278
289
|
required: !0
|
|
279
290
|
});
|
|
@@ -310,8 +321,8 @@ function D(e, i, s) {
|
|
|
310
321
|
});
|
|
311
322
|
}
|
|
312
323
|
}
|
|
313
|
-
function
|
|
314
|
-
var
|
|
324
|
+
function w(e) {
|
|
325
|
+
var o;
|
|
315
326
|
const i = [], s = [];
|
|
316
327
|
if (!e || typeof e != "object")
|
|
317
328
|
return {
|
|
@@ -332,8 +343,8 @@ function A(e) {
|
|
|
332
343
|
};
|
|
333
344
|
if (e.version !== void 0 && e.version !== 1 && i.push(
|
|
334
345
|
a("invalid_version", "Analytics intent version must be 1.", "version")
|
|
335
|
-
),
|
|
336
|
-
const
|
|
346
|
+
), A(e.source, "source", i), e.kind === "metric") {
|
|
347
|
+
const r = Array.isArray(e.metrics) ? e.metrics.filter(
|
|
337
348
|
(n) => c(n) && d(n.name)
|
|
338
349
|
) : [];
|
|
339
350
|
if (!Array.isArray(e.metrics) || e.metrics.length === 0 ? i.push(
|
|
@@ -346,38 +357,38 @@ function A(e) {
|
|
|
346
357
|
"Metric intent metrics must be an array of field references with names.",
|
|
347
358
|
"metrics"
|
|
348
359
|
)
|
|
349
|
-
),
|
|
360
|
+
), r.forEach((n, t) => {
|
|
350
361
|
f(n, `metrics.${t}`, i, {
|
|
351
362
|
required: !0
|
|
352
363
|
});
|
|
353
|
-
}),
|
|
354
|
-
const n =
|
|
355
|
-
(t, p) =>
|
|
356
|
-
(u, l) => l !== p &&
|
|
364
|
+
}), r.length > 0 && !R(r)) {
|
|
365
|
+
const n = r.find(
|
|
366
|
+
(t, p) => r.some(
|
|
367
|
+
(u, l) => l !== p && b(u, t)
|
|
357
368
|
)
|
|
358
369
|
);
|
|
359
370
|
n && i.push(
|
|
360
371
|
a(
|
|
361
372
|
"duplicate_metric",
|
|
362
|
-
|
|
373
|
+
F(n),
|
|
363
374
|
"metrics"
|
|
364
375
|
)
|
|
365
376
|
);
|
|
366
377
|
}
|
|
367
|
-
if (c(e.primaryMetric) && d(e.primaryMetric.name) &&
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
378
|
+
if (c(e.primaryMetric) && d(e.primaryMetric.name) && _(
|
|
379
|
+
e.primaryMetric,
|
|
380
|
+
r
|
|
381
|
+
).length > 1 && i.push(
|
|
371
382
|
a(
|
|
372
383
|
"ambiguous_primary_metric",
|
|
373
|
-
"Metric intent primaryMetric
|
|
384
|
+
"Metric intent primaryMetric must identify exactly one selected metric.",
|
|
374
385
|
"primaryMetric"
|
|
375
386
|
)
|
|
376
387
|
), e.primaryMetric !== void 0 && (f(e.primaryMetric, "primaryMetric", i, {
|
|
377
388
|
required: !0
|
|
378
|
-
}), c(e.primaryMetric) && d(e.primaryMetric.name) &&
|
|
389
|
+
}), c(e.primaryMetric) && d(e.primaryMetric.name) && r.length > 0 && !j(
|
|
379
390
|
e.primaryMetric,
|
|
380
|
-
|
|
391
|
+
r
|
|
381
392
|
) && i.push(
|
|
382
393
|
a(
|
|
383
394
|
"invalid_primary_metric",
|
|
@@ -398,13 +409,13 @@ function A(e) {
|
|
|
398
409
|
"Metric intent dimensions must be an array of field references with names.",
|
|
399
410
|
"dimensions"
|
|
400
411
|
)
|
|
401
|
-
), e.dateField !== void 0 && f(e.dateField, "dateField", i), e.timeWindow !== void 0 && (
|
|
412
|
+
), e.dateField !== void 0 && f(e.dateField, "dateField", i), e.timeWindow !== void 0 && (k(e.timeWindow, "timeWindow", i), e.dateField || i.push(
|
|
402
413
|
a(
|
|
403
414
|
"missing_time_window_date_field",
|
|
404
415
|
"Metric timeWindow needs a dateField.",
|
|
405
416
|
"dateField"
|
|
406
417
|
)
|
|
407
|
-
)),
|
|
418
|
+
)), O(e.filters, "filters", i), Array.isArray(e.dimensions) && e.dimensions.forEach((n, t) => {
|
|
408
419
|
f(n, `dimensions.${t}`, i);
|
|
409
420
|
}), e.orderBy !== void 0) {
|
|
410
421
|
if (!c(e.orderBy))
|
|
@@ -425,13 +436,13 @@ function A(e) {
|
|
|
425
436
|
)
|
|
426
437
|
), c(e.orderBy.field) && d(e.orderBy.field.name)) {
|
|
427
438
|
const n = [
|
|
428
|
-
...
|
|
439
|
+
...r,
|
|
429
440
|
...e.timeGrain && e.dateField && c(e.dateField) ? [e.dateField] : [],
|
|
430
441
|
...Array.isArray(e.dimensions) ? e.dimensions.filter(
|
|
431
442
|
(t) => c(t) && d(t.name)
|
|
432
443
|
) : []
|
|
433
444
|
];
|
|
434
|
-
n.length > 0 && !
|
|
445
|
+
n.length > 0 && !x(
|
|
435
446
|
e.orderBy.field,
|
|
436
447
|
n
|
|
437
448
|
) && i.push(
|
|
@@ -443,7 +454,7 @@ function A(e) {
|
|
|
443
454
|
);
|
|
444
455
|
}
|
|
445
456
|
}
|
|
446
|
-
|
|
457
|
+
P(e, i);
|
|
447
458
|
} else e.kind === "records" ? (!Array.isArray(e.fields) || e.fields.length === 0 ? i.push(
|
|
448
459
|
a(
|
|
449
460
|
"missing_record_fields",
|
|
@@ -451,15 +462,15 @@ function A(e) {
|
|
|
451
462
|
"fields"
|
|
452
463
|
)
|
|
453
464
|
) : e.fields.some(
|
|
454
|
-
(
|
|
465
|
+
(r) => !c(r) || !d(r.name)
|
|
455
466
|
) && i.push(
|
|
456
467
|
a(
|
|
457
468
|
"invalid_record_fields",
|
|
458
469
|
"Records intent fields must be field references with names.",
|
|
459
470
|
"fields"
|
|
460
471
|
)
|
|
461
|
-
), Array.isArray(e.fields) && e.fields.forEach((
|
|
462
|
-
f(
|
|
472
|
+
), Array.isArray(e.fields) && e.fields.forEach((r, n) => {
|
|
473
|
+
f(r, `fields.${n}`, i);
|
|
463
474
|
}), e.dateField !== void 0 && f(e.dateField, "dateField", i), e.orderBy !== void 0 && (c(e.orderBy) ? (f(e.orderBy.field, "orderBy.field", i, {
|
|
464
475
|
required: !0
|
|
465
476
|
}), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && i.push(
|
|
@@ -480,14 +491,14 @@ function A(e) {
|
|
|
480
491
|
"Input options intent needs a field.",
|
|
481
492
|
"field"
|
|
482
493
|
)
|
|
483
|
-
), f(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((
|
|
494
|
+
), f(e.field, "field", i, { required: !0 })) : e.kind === "sql" ? (((o = e.source) == null ? void 0 : o.kind) !== "sql" && i.push(
|
|
484
495
|
a(
|
|
485
496
|
"invalid_sql_source",
|
|
486
497
|
"SQL analytics intent must use a SQL execution source.",
|
|
487
498
|
"source"
|
|
488
499
|
)
|
|
489
|
-
), d(e.sql) || i.push(a("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((
|
|
490
|
-
f(
|
|
500
|
+
), d(e.sql) || i.push(a("missing_sql", "SQL analytics intent needs SQL text.", "sql")), Array.isArray(e.fields) && e.fields.forEach((r, n) => {
|
|
501
|
+
f(r, `fields.${n}`, i);
|
|
491
502
|
})) : i.push(
|
|
492
503
|
a("invalid_analytics_kind", "Analytics kind is not supported.", "kind")
|
|
493
504
|
);
|
|
@@ -495,10 +506,10 @@ function A(e) {
|
|
|
495
506
|
ok: i.length === 0,
|
|
496
507
|
errors: i,
|
|
497
508
|
warnings: s,
|
|
498
|
-
repairHints:
|
|
509
|
+
repairHints: U(i)
|
|
499
510
|
};
|
|
500
511
|
}
|
|
501
|
-
function
|
|
512
|
+
function H(e) {
|
|
502
513
|
const i = [], s = [];
|
|
503
514
|
if (!e || typeof e != "object")
|
|
504
515
|
return {
|
|
@@ -526,18 +537,18 @@ function q(e) {
|
|
|
526
537
|
"Answer-obligations operation intent needs at least one obligation.",
|
|
527
538
|
"obligations"
|
|
528
539
|
)
|
|
529
|
-
) : e.obligations.forEach((
|
|
530
|
-
d(
|
|
540
|
+
) : e.obligations.forEach((o, r) => {
|
|
541
|
+
d(o.id) || i.push(
|
|
531
542
|
a(
|
|
532
543
|
"missing_obligation_id",
|
|
533
544
|
"Each analytics obligation needs an id.",
|
|
534
|
-
`obligations.${
|
|
545
|
+
`obligations.${r}.id`
|
|
535
546
|
)
|
|
536
|
-
), d(
|
|
547
|
+
), d(o.prompt) || i.push(
|
|
537
548
|
a(
|
|
538
549
|
"missing_obligation_prompt",
|
|
539
550
|
"Each analytics obligation needs a prompt.",
|
|
540
|
-
`obligations.${
|
|
551
|
+
`obligations.${r}.prompt`
|
|
541
552
|
)
|
|
542
553
|
);
|
|
543
554
|
});
|
|
@@ -549,10 +560,10 @@ function q(e) {
|
|
|
549
560
|
"instruction"
|
|
550
561
|
)
|
|
551
562
|
), e.analyticsIntent) {
|
|
552
|
-
const
|
|
563
|
+
const o = w(
|
|
553
564
|
e.analyticsIntent
|
|
554
565
|
);
|
|
555
|
-
i.push(...
|
|
566
|
+
i.push(...o.errors), s.push(...o.warnings);
|
|
556
567
|
}
|
|
557
568
|
} else
|
|
558
569
|
i.push(
|
|
@@ -566,10 +577,10 @@ function q(e) {
|
|
|
566
577
|
ok: i.length === 0,
|
|
567
578
|
errors: i,
|
|
568
579
|
warnings: s,
|
|
569
|
-
repairHints:
|
|
580
|
+
repairHints: I(i)
|
|
570
581
|
};
|
|
571
582
|
}
|
|
572
|
-
function
|
|
583
|
+
function Q(e) {
|
|
573
584
|
const i = [], s = [];
|
|
574
585
|
if (!e || typeof e != "object")
|
|
575
586
|
return {
|
|
@@ -597,8 +608,8 @@ function O(e) {
|
|
|
597
608
|
"kind"
|
|
598
609
|
)
|
|
599
610
|
);
|
|
600
|
-
const
|
|
601
|
-
return i.push(...
|
|
611
|
+
const o = H(e.operationIntent);
|
|
612
|
+
return i.push(...o.errors), s.push(...o.warnings), Array.isArray(e.plannedToolCalls) || i.push(
|
|
602
613
|
a(
|
|
603
614
|
"invalid_planned_tool_calls",
|
|
604
615
|
"Recovery plan plannedToolCalls must be an array.",
|
|
@@ -608,16 +619,16 @@ function O(e) {
|
|
|
608
619
|
ok: i.length === 0,
|
|
609
620
|
errors: i,
|
|
610
621
|
warnings: s,
|
|
611
|
-
repairHints:
|
|
622
|
+
repairHints: I(i)
|
|
612
623
|
};
|
|
613
624
|
}
|
|
614
|
-
function
|
|
625
|
+
function I(e) {
|
|
615
626
|
return e.map((i) => ({
|
|
616
627
|
code: i.code,
|
|
617
628
|
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."
|
|
618
629
|
}));
|
|
619
630
|
}
|
|
620
|
-
function
|
|
631
|
+
function U(e) {
|
|
621
632
|
return e.map((i) => {
|
|
622
633
|
switch (i.code) {
|
|
623
634
|
case "missing_source":
|
|
@@ -670,7 +681,7 @@ function E(e) {
|
|
|
670
681
|
}
|
|
671
682
|
}).filter((i) => !!i);
|
|
672
683
|
}
|
|
673
|
-
function
|
|
684
|
+
function G(e, i, s, o) {
|
|
674
685
|
if (!e || typeof e != "object") {
|
|
675
686
|
s.push(a("invalid_view", "Dashboard view must be an object.", i));
|
|
676
687
|
return;
|
|
@@ -686,7 +697,7 @@ function C(e, i, s, r) {
|
|
|
686
697
|
return;
|
|
687
698
|
}
|
|
688
699
|
if (e.presentation.kind === "text") {
|
|
689
|
-
d(e.text) ||
|
|
700
|
+
d(e.text) || o.push(
|
|
690
701
|
a(
|
|
691
702
|
"missing_text_content",
|
|
692
703
|
"Text views should include text content.",
|
|
@@ -705,13 +716,13 @@ function C(e, i, s, r) {
|
|
|
705
716
|
);
|
|
706
717
|
return;
|
|
707
718
|
}
|
|
708
|
-
const
|
|
709
|
-
for (const n of
|
|
719
|
+
const r = w(e.analytics);
|
|
720
|
+
for (const n of r.errors)
|
|
710
721
|
s.push(
|
|
711
722
|
a(n.code, n.message, `${i}.analytics${n.path ? `.${n.path}` : ""}`)
|
|
712
723
|
);
|
|
713
|
-
for (const n of
|
|
714
|
-
|
|
724
|
+
for (const n of r.warnings)
|
|
725
|
+
o.push(
|
|
715
726
|
a(
|
|
716
727
|
n.code,
|
|
717
728
|
n.message,
|
|
@@ -719,7 +730,7 @@ function C(e, i, s, r) {
|
|
|
719
730
|
)
|
|
720
731
|
);
|
|
721
732
|
}
|
|
722
|
-
function
|
|
733
|
+
function V(e) {
|
|
723
734
|
const i = [], s = [];
|
|
724
735
|
if (!e || typeof e != "object")
|
|
725
736
|
return {
|
|
@@ -733,17 +744,17 @@ function H(e) {
|
|
|
733
744
|
warnings: s
|
|
734
745
|
};
|
|
735
746
|
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.")), d(e.title) || i.push(a("missing_title", "Dashboard intent needs a title.", "title"));
|
|
736
|
-
const
|
|
737
|
-
|
|
747
|
+
const o = Array.isArray(e.inputs) ? e.inputs : [], r = v(
|
|
748
|
+
o.filter(c).map((u) => u.id).filter((u) => typeof u == "string")
|
|
738
749
|
);
|
|
739
|
-
|
|
750
|
+
r && i.push(
|
|
740
751
|
a(
|
|
741
752
|
"duplicate_input_id",
|
|
742
|
-
`Duplicate input id: ${
|
|
753
|
+
`Duplicate input id: ${r}.`,
|
|
743
754
|
"inputs"
|
|
744
755
|
)
|
|
745
756
|
);
|
|
746
|
-
for (const [u, l] of
|
|
757
|
+
for (const [u, l] of o.entries()) {
|
|
747
758
|
const m = `inputs.${u}`;
|
|
748
759
|
if (!c(l)) {
|
|
749
760
|
i.push(a("invalid_input", "Dashboard input must be an object.", m));
|
|
@@ -793,10 +804,10 @@ function H(e) {
|
|
|
793
804
|
);
|
|
794
805
|
continue;
|
|
795
806
|
}
|
|
796
|
-
for (const [
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
`${m}.views.${
|
|
807
|
+
for (const [M, S] of l.views.entries())
|
|
808
|
+
G(
|
|
809
|
+
S,
|
|
810
|
+
`${m}.views.${M}`,
|
|
800
811
|
i,
|
|
801
812
|
s
|
|
802
813
|
);
|
|
@@ -804,13 +815,13 @@ function H(e) {
|
|
|
804
815
|
return { ok: i.length === 0, errors: i, warnings: s };
|
|
805
816
|
}
|
|
806
817
|
export {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
818
|
+
H as a,
|
|
819
|
+
Q as b,
|
|
820
|
+
V as c,
|
|
821
|
+
$ as d,
|
|
822
|
+
B as e,
|
|
823
|
+
L as f,
|
|
824
|
+
N as p,
|
|
825
|
+
h as s,
|
|
826
|
+
w as v
|
|
816
827
|
};
|