drizzle-cube 0.4.21 → 0.4.23
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/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +2 -2
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/{handler-B-tEntiU.cjs → handler-C3hT7g2W.cjs} +1 -1
- package/dist/adapters/{handler-9Rdn7zM2.js → handler-t7Qd1IYi.js} +1 -1
- package/dist/adapters/hono/index.cjs +6 -6
- package/dist/adapters/hono/index.d.ts +13 -6
- package/dist/adapters/hono/index.js +65 -65
- package/dist/adapters/{mcp-transport-m1X1GtwG.js → mcp-transport-B6ZudTSk.js} +7 -0
- package/dist/adapters/{mcp-transport-8u9G5oNa.cjs → mcp-transport-DCiSGtp1.cjs} +1 -1
- package/dist/adapters/nextjs/index.cjs +2 -2
- package/dist/adapters/nextjs/index.js +2 -2
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js → RetentionCombinedChart-BK3NPsHP.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js.map → RetentionCombinedChart-BK3NPsHP.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-3z9fHE2F.js → analysis-builder-DVrv9Q4n.js} +9 -9
- package/dist/client/chunks/{analysis-builder-3z9fHE2F.js.map → analysis-builder-DVrv9Q4n.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js → analysis-builder-shared-CrENEvEk.js} +6 -6
- package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js.map → analysis-builder-shared-CrENEvEk.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js → chart-activity-grid-OG6he4YS.js} +2 -2
- package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js.map → chart-activity-grid-OG6he4YS.js.map} +1 -1
- package/dist/client/chunks/{chart-area-ByJQ7NZd.js → chart-area-TawAd2k9.js} +3 -3
- package/dist/client/chunks/{chart-area-ByJQ7NZd.js.map → chart-area-TawAd2k9.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-dj14frMt.js → chart-bar-D3vtCNQG.js} +2 -2
- package/dist/client/chunks/{chart-bar-dj14frMt.js.map → chart-bar-D3vtCNQG.js.map} +1 -1
- package/dist/client/chunks/{chart-box-plot-ZatBpatq.js → chart-box-plot-BXwN2rO5.js} +2 -2
- package/dist/client/chunks/{chart-box-plot-ZatBpatq.js.map → chart-box-plot-BXwN2rO5.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-CemotLx-.js → chart-bubble-ZfNe8t5k.js} +2 -2
- package/dist/client/chunks/{chart-bubble-CemotLx-.js.map → chart-bubble-ZfNe8t5k.js.map} +1 -1
- package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js → chart-candlestick-DmF3haFu.js} +2 -2
- package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js.map → chart-candlestick-DmF3haFu.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-BsAjHe7o.js → chart-data-table-DJZPkArt.js} +4 -4
- package/dist/client/chunks/{chart-data-table-BsAjHe7o.js.map → chart-data-table-DJZPkArt.js.map} +1 -1
- package/dist/client/chunks/{chart-funnel-dofnhD24.js → chart-funnel-CE9x0Io9.js} +2 -2
- package/dist/client/chunks/{chart-funnel-dofnhD24.js.map → chart-funnel-CE9x0Io9.js.map} +1 -1
- package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js → chart-gauge-Djs5FWxB.js} +2 -2
- package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js.map → chart-gauge-Djs5FWxB.js.map} +1 -1
- package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js → chart-heat-map-CqtMkdxd.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js.map → chart-heat-map-CqtMkdxd.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js → chart-kpi-delta-DEzA74cL.js} +4 -4
- package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js.map → chart-kpi-delta-DEzA74cL.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js → chart-kpi-number-Bab-BZtX.js} +3 -3
- package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js.map → chart-kpi-number-Bab-BZtX.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js → chart-kpi-text-BkTgckDJ.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js.map → chart-kpi-text-BkTgckDJ.js.map} +1 -1
- package/dist/client/chunks/{chart-line-DzyZkugh.js → chart-line-DhM-Hvu0.js} +3 -3
- package/dist/client/chunks/{chart-line-DzyZkugh.js.map → chart-line-DhM-Hvu0.js.map} +1 -1
- package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js → chart-measure-profile-4vQxFm69.js} +3 -3
- package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js.map → chart-measure-profile-4vQxFm69.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-akbfRfb9.js → chart-pie-B86KRcHI.js} +2 -2
- package/dist/client/chunks/{chart-pie-akbfRfb9.js.map → chart-pie-B86KRcHI.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-BaN-Kjww.js → chart-radar-BhDBmJRh.js} +2 -2
- package/dist/client/chunks/{chart-radar-BaN-Kjww.js.map → chart-radar-BhDBmJRh.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js → chart-radial-bar-Brugya8X.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js.map → chart-radial-bar-Brugya8X.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-CG-3hHmX.js → chart-sankey-D2L8ympI.js} +2 -2
- package/dist/client/chunks/{chart-sankey-CG-3hHmX.js.map → chart-sankey-D2L8ympI.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-l_yTVxF3.js → chart-scatter-CAkbBDkK.js} +2 -2
- package/dist/client/chunks/{chart-scatter-l_yTVxF3.js.map → chart-scatter-CAkbBDkK.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js → chart-sunburst-DaxJ-cob.js} +2 -2
- package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js.map → chart-sunburst-DaxJ-cob.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js → chart-tree-map-CrDJAvZU.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js.map → chart-tree-map-CrDJAvZU.js.map} +1 -1
- package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js → chart-waterfall-BBwSfEKT.js} +3 -3
- package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js.map → chart-waterfall-BBwSfEKT.js.map} +1 -1
- package/dist/client/chunks/{charts-core-CU9u_HtL.js → charts-core-B4Rbfdcn.js} +2 -2
- package/dist/client/chunks/{charts-core-CU9u_HtL.js.map → charts-core-B4Rbfdcn.js.map} +1 -1
- package/dist/client/chunks/{charts-loader-B3tt5oKG.js → charts-loader-DbrwgvCK.js} +25 -25
- package/dist/client/chunks/{charts-loader-B3tt5oKG.js.map → charts-loader-DbrwgvCK.js.map} +1 -1
- package/dist/client/chunks/{components-CMGGxqOB.js → components-GzooQM5J.js} +9 -9
- package/dist/client/chunks/{components-CMGGxqOB.js.map → components-GzooQM5J.js.map} +1 -1
- package/dist/client/chunks/{core-D_8mkGpQ.js → core-Y9e-sNfb.js} +2 -2
- package/dist/client/chunks/{core-D_8mkGpQ.js.map → core-Y9e-sNfb.js.map} +1 -1
- package/dist/client/chunks/{icons-M7shurcH.js → icons-DFJw-2HU.js} +6 -6
- package/dist/client/chunks/{icons-M7shurcH.js.map → icons-DFJw-2HU.js.map} +1 -1
- package/dist/client/chunks/{providers-CgxXm6Ll.js → providers-CCw8Kjlc.js} +2 -2
- package/dist/client/chunks/{providers-CgxXm6Ll.js.map → providers-CCw8Kjlc.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js → syntaxHighlighting-DAMSW_A6.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js.map → syntaxHighlighting-DAMSW_A6.js.map} +1 -1
- package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js → useDirtyStateTracking-CjhwBXRw.js} +20 -20
- package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js.map → useDirtyStateTracking-CjhwBXRw.js.map} +1 -1
- package/dist/client/chunks/useExplainAI-IiW55BaQ.js +182 -0
- package/dist/client/chunks/useExplainAI-IiW55BaQ.js.map +1 -0
- package/dist/client/chunks/{vendor-AVsJ2ni0.js → vendor-B2EH3V58.js} +7 -7
- package/dist/client/chunks/{vendor-AVsJ2ni0.js.map → vendor-B2EH3V58.js.map} +1 -1
- package/dist/client/components.js +1 -1
- package/dist/client/hooks/useNotebookLayout.d.ts +8 -0
- package/dist/client/hooks.d.ts +2 -0
- package/dist/client/hooks.js +51 -190
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +871 -742
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.js +7 -7
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +7 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -211,7 +211,7 @@ ${JSON.stringify(E,void 0,2)}`)}}}var L;(function(i){i[i.SPACE=0]="SPACE",i[i.NO
|
|
|
211
211
|
`;case L.SINGLE_INDENT:return this.indentation.getSingleIndent();default:return e}}}const Do=i=>i===L.SPACE||i===L.SINGLE_INDENT,fo=i=>i===L.SPACE||i===L.SINGLE_INDENT||i===L.NEWLINE;function ns(i,e){if(e==="standard")return i;let t=[];return i.length>=10&&i.includes(" ")&&([i,...t]=i.split(" ")),e==="tabularLeft"?i=i.padEnd(9," "):i=i.padStart(9," "),i+["",...t].join(" ")}function is(i){return Qn(i)||i===_.RESERVED_CLAUSE||i===_.RESERVED_SELECT||i===_.RESERVED_SET_OPERATION||i===_.RESERVED_JOIN||i===_.LIMIT}const it="top-level",ho="block-level";class $s{constructor(e){this.indent=e,this.indentTypes=[]}getSingleIndent(){return this.indent}getLevel(){return this.indentTypes.length}increaseTopLevel(){this.indentTypes.push(it)}increaseBlockLevel(){this.indentTypes.push(ho)}decreaseTopLevel(){this.indentTypes.length>0&&Ne(this.indentTypes)===it&&this.indentTypes.pop()}decreaseBlockLevel(){for(;this.indentTypes.length>0&&this.indentTypes.pop()===it;);}}class Po extends vs{constructor(e){super(new $s("")),this.expressionWidth=e,this.length=0,this.trailingSpace=!1}add(...e){if(e.forEach(t=>this.addToLength(t)),this.length>this.expressionWidth)throw new St;super.add(...e)}addToLength(e){if(typeof e=="string")this.length+=e.length,this.trailingSpace=!1;else{if(e===L.MANDATORY_NEWLINE||e===L.NEWLINE)throw new St;e===L.INDENT||e===L.SINGLE_INDENT||e===L.SPACE?this.trailingSpace||(this.length++,this.trailingSpace=!0):(e===L.NO_NEWLINE||e===L.NO_SPACE)&&this.trailingSpace&&(this.trailingSpace=!1,this.length--)}}}class St extends Error{}class fe{constructor({cfg:e,dialectCfg:t,params:s,layout:n,inline:r=!1}){this.inline=!1,this.nodes=[],this.index=-1,this.cfg=e,this.dialectCfg=t,this.inline=r,this.params=s,this.layout=n}format(e){for(this.nodes=e,this.index=0;this.index<this.nodes.length;this.index++)this.formatNode(this.nodes[this.index]);return this.layout}formatNode(e){this.formatComments(e.leadingComments),this.formatNodeWithoutComments(e),this.formatComments(e.trailingComments)}formatNodeWithoutComments(e){switch(e.type){case M.function_call:return this.formatFunctionCall(e);case M.parameterized_data_type:return this.formatParameterizedDataType(e);case M.array_subscript:return this.formatArraySubscript(e);case M.property_access:return this.formatPropertyAccess(e);case M.parenthesis:return this.formatParenthesis(e);case M.between_predicate:return this.formatBetweenPredicate(e);case M.case_expression:return this.formatCaseExpression(e);case M.case_when:return this.formatCaseWhen(e);case M.case_else:return this.formatCaseElse(e);case M.clause:return this.formatClause(e);case M.set_operation:return this.formatSetOperation(e);case M.limit_clause:return this.formatLimitClause(e);case M.all_columns_asterisk:return this.formatAllColumnsAsterisk(e);case M.literal:return this.formatLiteral(e);case M.identifier:return this.formatIdentifier(e);case M.parameter:return this.formatParameter(e);case M.operator:return this.formatOperator(e);case M.comma:return this.formatComma(e);case M.line_comment:return this.formatLineComment(e);case M.block_comment:return this.formatBlockComment(e);case M.disable_comment:return this.formatBlockComment(e);case M.data_type:return this.formatDataType(e);case M.keyword:return this.formatKeywordNode(e)}}formatFunctionCall(e){this.withComments(e.nameKw,()=>{this.layout.add(this.showFunctionKw(e.nameKw))}),this.formatNode(e.parenthesis)}formatParameterizedDataType(e){this.withComments(e.dataType,()=>{this.layout.add(this.showDataType(e.dataType))}),this.formatNode(e.parenthesis)}formatArraySubscript(e){let t;switch(e.array.type){case M.data_type:t=this.showDataType(e.array);break;case M.keyword:t=this.showKw(e.array);break;default:t=this.showIdentifier(e.array);break}this.withComments(e.array,()=>{this.layout.add(t)}),this.formatNode(e.parenthesis)}formatPropertyAccess(e){this.formatNode(e.object),this.layout.add(L.NO_SPACE,e.operator),this.formatNode(e.property)}formatParenthesis(e){const t=this.formatInlineExpression(e.children);t?(this.layout.add(e.openParen),this.layout.add(...t.getLayoutItems()),this.layout.add(L.NO_SPACE,e.closeParen,L.SPACE)):(this.layout.add(e.openParen,L.NEWLINE),Te(this.cfg)?(this.layout.add(L.INDENT),this.layout=this.formatSubExpression(e.children)):(this.layout.indentation.increaseBlockLevel(),this.layout.add(L.INDENT),this.layout=this.formatSubExpression(e.children),this.layout.indentation.decreaseBlockLevel()),this.layout.add(L.NEWLINE,L.INDENT,e.closeParen,L.SPACE))}formatBetweenPredicate(e){this.layout.add(this.showKw(e.betweenKw),L.SPACE),this.layout=this.formatSubExpression(e.expr1),this.layout.add(L.NO_SPACE,L.SPACE,this.showNonTabularKw(e.andKw),L.SPACE),this.layout=this.formatSubExpression(e.expr2),this.layout.add(L.SPACE)}formatCaseExpression(e){this.formatNode(e.caseKw),this.layout.indentation.increaseBlockLevel(),this.layout=this.formatSubExpression(e.expr),this.layout=this.formatSubExpression(e.clauses),this.layout.indentation.decreaseBlockLevel(),this.layout.add(L.NEWLINE,L.INDENT),this.formatNode(e.endKw)}formatCaseWhen(e){this.layout.add(L.NEWLINE,L.INDENT),this.formatNode(e.whenKw),this.layout=this.formatSubExpression(e.condition),this.formatNode(e.thenKw),this.layout=this.formatSubExpression(e.result)}formatCaseElse(e){this.layout.add(L.NEWLINE,L.INDENT),this.formatNode(e.elseKw),this.layout=this.formatSubExpression(e.result)}formatClause(e){this.isOnelineClause(e)?this.formatClauseInOnelineStyle(e):Te(this.cfg)?this.formatClauseInTabularStyle(e):this.formatClauseInIndentedStyle(e)}isOnelineClause(e){return Te(this.cfg)?this.dialectCfg.tabularOnelineClauses[e.nameKw.text]:this.dialectCfg.onelineClauses[e.nameKw.text]}formatClauseInIndentedStyle(e){this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e.nameKw),L.NEWLINE),this.layout.indentation.increaseTopLevel(),this.layout.add(L.INDENT),this.layout=this.formatSubExpression(e.children),this.layout.indentation.decreaseTopLevel()}formatClauseInOnelineStyle(e){this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e.nameKw),L.SPACE),this.layout=this.formatSubExpression(e.children)}formatClauseInTabularStyle(e){this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e.nameKw),L.SPACE),this.layout.indentation.increaseTopLevel(),this.layout=this.formatSubExpression(e.children),this.layout.indentation.decreaseTopLevel()}formatSetOperation(e){this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e.nameKw),L.NEWLINE),this.layout.add(L.INDENT),this.layout=this.formatSubExpression(e.children)}formatLimitClause(e){this.withComments(e.limitKw,()=>{this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e.limitKw))}),this.layout.indentation.increaseTopLevel(),Te(this.cfg)?this.layout.add(L.SPACE):this.layout.add(L.NEWLINE,L.INDENT),e.offset?(this.layout=this.formatSubExpression(e.offset),this.layout.add(L.NO_SPACE,",",L.SPACE),this.layout=this.formatSubExpression(e.count)):this.layout=this.formatSubExpression(e.count),this.layout.indentation.decreaseTopLevel()}formatAllColumnsAsterisk(e){this.layout.add("*",L.SPACE)}formatLiteral(e){this.layout.add(e.text,L.SPACE)}formatIdentifier(e){this.layout.add(this.showIdentifier(e),L.SPACE)}formatParameter(e){this.layout.add(this.params.get(e),L.SPACE)}formatOperator({text:e}){this.cfg.denseOperators||this.dialectCfg.alwaysDenseOperators.includes(e)?this.layout.add(L.NO_SPACE,e):e===":"?this.layout.add(L.NO_SPACE,e,L.SPACE):this.layout.add(e,L.SPACE)}formatComma(e){this.inline?this.layout.add(L.NO_SPACE,",",L.SPACE):this.layout.add(L.NO_SPACE,",",L.NEWLINE,L.INDENT)}withComments(e,t){this.formatComments(e.leadingComments),t(),this.formatComments(e.trailingComments)}formatComments(e){e&&e.forEach(t=>{t.type===M.line_comment?this.formatLineComment(t):this.formatBlockComment(t)})}formatLineComment(e){tt(e.precedingWhitespace||"")?this.layout.add(L.NEWLINE,L.INDENT,e.text,L.MANDATORY_NEWLINE,L.INDENT):this.layout.getLayoutItems().length>0?this.layout.add(L.NO_NEWLINE,L.SPACE,e.text,L.MANDATORY_NEWLINE,L.INDENT):this.layout.add(e.text,L.MANDATORY_NEWLINE,L.INDENT)}formatBlockComment(e){e.type===M.block_comment&&this.isMultilineBlockComment(e)?(this.splitBlockComment(e.text).forEach(t=>{this.layout.add(L.NEWLINE,L.INDENT,t)}),this.layout.add(L.NEWLINE,L.INDENT)):this.layout.add(e.text,L.SPACE)}isMultilineBlockComment(e){return tt(e.text)||tt(e.precedingWhitespace||"")}isDocComment(e){const t=e.split(/\n/);return/^\/\*\*?$/.test(t[0])&&t.slice(1,t.length-1).every(s=>/^\s*\*/.test(s))&&/^\s*\*\/$/.test(Ne(t))}splitBlockComment(e){return this.isDocComment(e)?e.split(/\n/).map(t=>/^\s*\*/.test(t)?" "+t.replace(/^\s*/,""):t):e.split(/\n/).map(t=>t.replace(/^\s*/,""))}formatSubExpression(e){return new fe({cfg:this.cfg,dialectCfg:this.dialectCfg,params:this.params,layout:this.layout,inline:this.inline}).format(e)}formatInlineExpression(e){const t=this.params.getPositionalParameterIndex();try{return new fe({cfg:this.cfg,dialectCfg:this.dialectCfg,params:this.params,layout:new Po(this.cfg.expressionWidth),inline:!0}).format(e)}catch(s){if(s instanceof St){this.params.setPositionalParameterIndex(t);return}else throw s}}formatKeywordNode(e){switch(e.tokenType){case _.RESERVED_JOIN:return this.formatJoin(e);case _.AND:case _.OR:case _.XOR:return this.formatLogicalOperator(e);default:return this.formatKeyword(e)}}formatJoin(e){Te(this.cfg)?(this.layout.indentation.decreaseTopLevel(),this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e),L.SPACE),this.layout.indentation.increaseTopLevel()):this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e),L.SPACE)}formatKeyword(e){this.layout.add(this.showKw(e),L.SPACE)}formatLogicalOperator(e){this.cfg.logicalOperatorNewline==="before"?Te(this.cfg)?(this.layout.indentation.decreaseTopLevel(),this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e),L.SPACE),this.layout.indentation.increaseTopLevel()):this.layout.add(L.NEWLINE,L.INDENT,this.showKw(e),L.SPACE):this.layout.add(this.showKw(e),L.NEWLINE,L.INDENT)}formatDataType(e){this.layout.add(this.showDataType(e),L.SPACE)}showKw(e){return is(e.tokenType)?ns(this.showNonTabularKw(e),this.cfg.indentStyle):this.showNonTabularKw(e)}showNonTabularKw(e){switch(this.cfg.keywordCase){case"preserve":return Ce(e.raw);case"upper":return e.text;case"lower":return e.text.toLowerCase()}}showFunctionKw(e){return is(e.tokenType)?ns(this.showNonTabularFunctionKw(e),this.cfg.indentStyle):this.showNonTabularFunctionKw(e)}showNonTabularFunctionKw(e){switch(this.cfg.functionCase){case"preserve":return Ce(e.raw);case"upper":return e.text;case"lower":return e.text.toLowerCase()}}showIdentifier(e){if(e.quoted)return e.text;switch(this.cfg.identifierCase){case"preserve":return e.text;case"upper":return e.text.toUpperCase();case"lower":return e.text.toLowerCase()}}showDataType(e){switch(this.cfg.dataTypeCase){case"preserve":return Ce(e.raw);case"upper":return e.text;case"lower":return e.text.toLowerCase()}}}class Mo{constructor(e,t){this.dialect=e,this.cfg=t,this.params=new ro(this.cfg.params)}format(e){const t=this.parse(e);return this.formatAst(t).trimEnd()}parse(e){return po(this.dialect.tokenizer).parse(e,this.cfg.paramTypes||{})}formatAst(e){return e.map(t=>this.formatStatement(t)).join(`
|
|
212
212
|
`.repeat(this.cfg.linesBetweenQueries+1))}formatStatement(e){const t=new fe({cfg:this.cfg,dialectCfg:this.dialect.formatOptions,params:this.params,layout:new vs(new $s(io(this.cfg)))}).format(e.children);return e.hasSemicolon&&(this.cfg.newlineBeforeSemicolon?t.add(L.NEWLINE,";"):t.add(L.NO_NEWLINE,";")),t.toString()}}class Le extends Error{}function Uo(i){const e=["multilineLists","newlineBeforeOpenParen","newlineBeforeCloseParen","aliasAs","commaPosition","tabulateAlias"];for(const t of e)if(t in i)throw new Le(`${t} config is no more supported.`);if(i.expressionWidth<=0)throw new Le(`expressionWidth config must be positive number. Received ${i.expressionWidth} instead.`);if(i.params&&!yo(i.params)&&console.warn('WARNING: All "params" option values should be strings.'),i.paramTypes&&!go(i.paramTypes))throw new Le("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");return i}function yo(i){return(i instanceof Array?i:Object.values(i)).every(t=>typeof t=="string")}function go(i){return i.custom&&Array.isArray(i.custom)?i.custom.every(e=>e.regex!==""):!0}var bo=function(i,e){var t={};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&e.indexOf(s)<0&&(t[s]=i[s]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(i);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(i,s[n])&&(t[s[n]]=i[s[n]]);return t};const Vs={bigquery:"bigquery",clickhouse:"clickhouse",db2:"db2",db2i:"db2i",duckdb:"duckdb",hive:"hive",mariadb:"mariadb",mysql:"mysql",n1ql:"n1ql",plsql:"plsql",postgresql:"postgresql",redshift:"redshift",spark:"spark",sqlite:"sqlite",sql:"sql",tidb:"tidb",trino:"trino",transactsql:"transactsql",tsql:"transactsql",singlestoredb:"singlestoredb",snowflake:"snowflake"},Go=Object.keys(Vs),Fo={tabWidth:2,useTabs:!1,keywordCase:"preserve",identifierCase:"preserve",dataTypeCase:"preserve",functionCase:"preserve",indentStyle:"standard",logicalOperatorNewline:"before",expressionWidth:50,linesBetweenQueries:1,denseOperators:!1,newlineBeforeSemicolon:!1},Bo=(i,e={})=>{if(typeof e.language=="string"&&!Go.includes(e.language))throw new Le(`Unsupported SQL dialect: ${e.language}`);const t=Vs[e.language||"sql"];return Ho(i,Object.assign(Object.assign({},e),{dialect:$a[t]}))},Ho=(i,e)=>{var{dialect:t}=e,s=bo(e,["dialect"]);if(typeof i!="string")throw new Error("Invalid query argument. Expected string, instead got "+typeof i);const n=Uo(Object.assign(Object.assign({},Fo),s));return new Mo(to(t),n).format(i)};function Yo(i,e){try{return Bo(i,{language:{postgres:"postgresql",mysql:"mysql",sqlite:"sqlite",singlestore:"mysql",duckdb:"postgresql"}[e],tabWidth:2,keywordCase:"upper",indentStyle:"standard"})}catch(t){return console.warn("SQL formatting failed:",t),i}}async function wo(i,e){const t=i.getMetadata();return{cubes:dt(t,{topic:e.topic,intent:e.intent,limit:e.limit,minScore:e.minScore})}}async function vo(i,e,t){const s=t.query,n=i.validateQuery(s);if(!n.isValid)throw new Error(`Query validation failed: ${n.errors.join(", ")}`);const r=await i.executeMultiCubeQuery(s,e);return{data:r.data,annotation:r.annotation,query:s}}class ge{cubes=new Map;dbExecutor;metadataCache;cacheConfig;constructor(e){e?.databaseExecutor?this.dbExecutor=e.databaseExecutor:e?.drizzle&&(this.dbExecutor=Tt(e.drizzle,e.schema,e.engineType)),this.cacheConfig=e?.cache}setDatabaseExecutor(e){this.dbExecutor=e}getEngineType(){return this.dbExecutor?.getEngineType()}setDrizzle(e,t,s){this.dbExecutor=Tt(e,t,s)}hasExecutor(){return!!this.dbExecutor}requireExecutor(){if(!this.dbExecutor)throw new Error("Database executor not configured");return this.dbExecutor}createQueryExecutor(e=!1){const t=this.requireExecutor();return new Ms(t,e?this.cacheConfig:void 0)}formatSqlResult(e){const t=this.requireExecutor().getEngineType();return{sql:Yo(e.sql,t),params:e.params}}registerCube(e){this.validateCalculatedMeasures(e),new te(this.cubes).populateDependencies(e),this.cubes.set(e.name,e),this.invalidateMetadataCache()}validateCalculatedMeasures(e){const t=[];for(const[s,n]of Object.entries(e.measures))if(n.type==="calculated"){if(!n.calculatedSql){t.push(`Calculated measure '${e.name}.${s}' must have calculatedSql property`);continue}const r=Dn(n.calculatedSql);if(!r.isValid){t.push(`Invalid calculatedSql syntax in '${e.name}.${s}': ${r.errors.join(", ")}`);continue}const E=new Map(this.cubes);E.set(e.name,e);const a=new te(E);try{a.validateDependencies(e)}catch(A){t.push(A instanceof Error?A.message:String(A))}}if(t.length===0){const s=new Map(this.cubes);s.set(e.name,e);const n=new te(s);n.buildGraph(e);const r=n.detectCycle();r&&t.push(`Circular dependency detected in calculated measures: ${r.join(" -> ")}`)}if(t.length>0)throw new Error(`Calculated measure validation failed for cube '${e.name}':
|
|
213
213
|
${t.join(`
|
|
214
|
-
`)}`)}getCube(e){return this.cubes.get(e)}getAllCubes(){return Array.from(this.cubes.values())}getAllCubesMap(){return this.cubes}async execute(e,t,s){return this.createQueryExecutor(!0).execute(this.cubes,e,t,s)}async executeMultiCubeQuery(e,t,s){return this.execute(e,t,s)}async executeQuery(e,t,s){if(!this.cubes.get(e))throw new Error(`Cube '${e}' not found`);return this.execute(t,s)}getMetadata(){return this.metadataCache?this.metadataCache:(this.metadataCache=Array.from(this.cubes.values()).map(e=>this.generateCubeMetadata(e)),this.metadataCache)}getColumnName(e){if(e&&e.name||e&&e.columnType&&e.name)return e.name;if(typeof e=="string")return e;if(e&&typeof e=="object"){if(e._.name)return e._.name;if(e.name)return e.name;if(e.columnName)return e.columnName}return"unknown_column"}static DEFAULT_TIME_GRANULARITIES=["year","quarter","month","week","day","hour"];generateCubeMetadata(e){const t=Object.keys(e.measures),s=Object.keys(e.dimensions),n=new Array(t.length),r=new Array(s.length);for(let T=0;T<t.length;T++){const R=t[T],l=e.measures[R];let S;l.drillMembers&&l.drillMembers.length>0&&(S=l.drillMembers.map(N=>N.includes(".")?N:`${e.name}.${N}`)),n[T]={name:`${e.name}.${R}`,title:l.title||R,shortTitle:l.title||R,type:l.type,format:void 0,description:l.description,synonyms:l.synonyms,drillMembers:S}}for(let T=0;T<s.length;T++){const R=s[T],l=e.dimensions[R];let S;l.type==="time"&&(S=l.granularities||ge.DEFAULT_TIME_GRANULARITIES),r[T]={name:`${e.name}.${R}`,title:l.title||R,shortTitle:l.title||R,type:l.type,format:void 0,description:l.description,synonyms:l.synonyms,granularities:S}}const E=[];if(e.joins)for(const[,T]of Object.entries(e.joins)){const R=typeof T.targetCube=="function"?T.targetCube():T.targetCube;E.push({targetCube:R.name,relationship:T.relationship,joinFields:T.on.map(l=>({sourceField:this.getColumnName(l.source),targetField:this.getColumnName(l.target)}))})}const a=[];if(e.hierarchies)for(const[,T]of Object.entries(e.hierarchies))a.push({name:T.name,title:T.title||T.name,cubeName:e.name,levels:T.levels.map(R=>R.includes(".")?R:`${e.name}.${R}`)});return{name:e.name,title:e.title||e.name,description:e.description,exampleQuestions:e.exampleQuestions,measures:n,dimensions:r,segments:[],relationships:E.length>0?E:void 0,hierarchies:a.length>0?a:void 0,meta:e.meta}}async generateSQL(e,t,s){const n=this.getCube(e);if(!n)throw new Error(`Cube '${e}' not found`);const E=await this.createQueryExecutor().generateSQL(n,t,s);return this.formatSqlResult(E)}async generateMultiCubeSQL(e,t){const n=await this.createQueryExecutor().generateMultiCubeSQL(this.cubes,e,t);return this.formatSqlResult(n)}async dryRun(e,t){const n=await this.createQueryExecutor().dryRunSQL(this.cubes,e,t);return this.formatSqlResult(n)}async dryRunFunnel(e,t){return this.dryRun(e,t)}async dryRunFlow(e,t){return this.dryRun(e,t)}async dryRunRetention(e,t){return this.dryRun(e,t)}async explainQuery(e,t,s){return this.createQueryExecutor().explainQuery(this.cubes,e,t,s)}hasCube(e){return this.cubes.has(e)}removeCube(e){const t=this.cubes.delete(e);return t&&this.invalidateMetadataCache(),t}clearCubes(){this.cubes.clear(),this.invalidateMetadataCache()}invalidateMetadataCache(){this.metadataCache=void 0}getCubeNames(){return Array.from(this.cubes.keys())}validateQuery(e){return Ws(this.cubes,e)}analyzeQuery(e,t){return this.createQueryExecutor(!0).analyzeQuery(this.cubes,e,t)}}function $o(i){const e=[];return i.timeDimensions?.some(t=>t.compareDateRange&&t.compareDateRange.length>=2)&&e.push("comparison"),i.funnel!==void 0&&i.funnel.steps?.length>=2&&e.push("funnel"),i.flow!==void 0&&i.flow.startingStep!==void 0&&i.flow.eventDimension!==void 0&&e.push("flow"),i.retention!==void 0&&i.retention.timeDimension!=null&&i.retention.bindingKey!=null&&e.push("retention"),e.length===0?[]:e}function Ws(i,e){const t=[],s=$o(e);if(s.length>1)return t.push(`Query contains multiple query modes: ${s.join(", ")}`),{isValid:!1,errors:t};const n={funnel:()=>{const E=e.funnel.bindingKey;if(typeof E=="string"){const[a]=E.split(".");a&&!i.has(a)&&t.push(`Funnel binding key cube not found: ${a}`)}else if(Array.isArray(E))for(const a of E)i.has(a.cube)||t.push(`Funnel binding key cube not found: ${a.cube}`)},flow:()=>{const E=e.flow.bindingKey;if(typeof E=="string"){const[a]=E.split(".");a&&!i.has(a)&&t.push(`Flow binding key cube not found: ${a}`)}},retention:()=>{const E=e.retention,a=Vo(E.timeDimension);a&&!i.has(a)&&t.push(`Retention cube not found: ${a}`);const A=E.bindingKey;if(typeof A=="string"){const[T]=A.split(".");T&&!i.has(T)&&t.push(`Retention binding key cube not found: ${T}`)}else if(Array.isArray(A))for(const T of A)i.has(T.cube)||t.push(`Retention binding key cube not found: ${T.cube}`);if(E.breakdownDimensions&&Array.isArray(E.breakdownDimensions))for(const T of E.breakdownDimensions){const[R]=T.split(".");R&&!i.has(R)&&t.push(`Retention breakdown cube not found: ${R}`)}}};if(s.length===1&&s[0]!=="comparison"){const E=s[0];return n[E](),{isValid:t.length===0,errors:t}}const r=new Set;if(e.measures)for(const E of e.measures){const[a,A]=E.split(".");if(!a||!A){t.push(`Invalid measure format: ${E}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in measure '${E}')`);continue}if(!T.measures[A]){const R=A===a?`. Did you mean one of: ${Object.keys(T.measures).slice(0,5).map(l=>`'${a}.${l}'`).join(", ")}?`:"";t.push(`Measure '${A}' not found on cube '${a}'${R}`)}}if(e.dimensions)for(const E of e.dimensions){const[a,A]=E.split(".");if(!a||!A){t.push(`Invalid dimension format: ${E}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in dimension '${E}')`);continue}if(!T.dimensions[A]){const R=A===a?`. Did you mean one of: ${Object.keys(T.dimensions).slice(0,5).map(l=>`'${a}.${l}'`).join(", ")}?`:"";t.push(`Dimension '${A}' not found on cube '${a}'${R}`)}}if(e.timeDimensions)for(const E of e.timeDimensions){const[a,A]=E.dimension.split(".");if(!a||!A){t.push(`Invalid timeDimension format: ${E.dimension}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in timeDimension '${E.dimension}')`);continue}T.dimensions[A]||t.push(`TimeDimension '${A}' not found on cube '${a}' (must be a dimension with time type)`)}if(e.filters)for(const E of e.filters)xs(E,i,t,r);return r.size===0&&t.push("Query must reference at least one cube through measures, dimensions, or filters"),{isValid:t.length===0,errors:t}}function xs(i,e,t,s){if("and"in i||"or"in i){const a=i.and||i.or||[];for(const A of a)xs(A,e,t,s);return}if(!("member"in i)){t.push("Filter must have a member field");return}const[n,r]=i.member.split(".");if(!n||!r){t.push(`Invalid filter member format: ${i.member}. Expected format: 'CubeName.fieldName'`);return}s.add(n);const E=e.get(n);if(!E){t.push(`Cube '${n}' not found (referenced in filter '${i.member}')`);return}if(!E.dimensions[r]&&!E.measures[r]){const a=r===n?`. Did you mean one of: ${[...Object.keys(E.dimensions),...Object.keys(E.measures)].slice(0,5).map(A=>`'${n}.${A}'`).join(", ")}?`:"";t.push(`Filter field '${r}' not found on cube '${n}' (must be a dimension or measure)${a}`)}}function Vo(i){if(typeof i=="string"){const[e]=i.split(".");return e||null}return i.cube}class Wo{cache=new Map;defaultTtlMs;maxEntries;cleanupIntervalId;accessOrder=[];constructor(e={}){this.defaultTtlMs=e.defaultTtlMs??3e5,this.maxEntries=e.maxEntries;const t=e.cleanupIntervalMs??6e4;t>0&&(this.cleanupIntervalId=setInterval(()=>{this.cleanup()},t),typeof this.cleanupIntervalId=="object"&&"unref"in this.cleanupIntervalId&&this.cleanupIntervalId.unref())}async get(e){const t=this.cache.get(e);if(!t)return null;const s=Date.now();return s>t.expiresAt?(this.cache.delete(e),this.removeFromAccessOrder(e),null):(this.touchAccessOrder(e),{value:t.value,metadata:{cachedAt:t.cachedAt,ttlMs:t.ttlMs,ttlRemainingMs:t.expiresAt-s}})}async set(e,t,s){const n=s??this.defaultTtlMs,r=Date.now();this.maxEntries&&this.cache.size>=this.maxEntries&&!this.cache.has(e)&&this.evictOldest(),this.cache.set(e,{value:t,cachedAt:r,ttlMs:n,expiresAt:r+n}),this.touchAccessOrder(e)}async delete(e){const t=this.cache.delete(e);return t&&this.removeFromAccessOrder(e),t}async deletePattern(e){let t=0;if(e.endsWith("*")){const s=e.slice(0,-1);for(const n of this.cache.keys())n.startsWith(s)&&(this.cache.delete(n),this.removeFromAccessOrder(n),t++)}else if(e.startsWith("*")){const s=e.slice(1);for(const n of this.cache.keys())n.endsWith(s)&&(this.cache.delete(n),this.removeFromAccessOrder(n),t++)}else if(e.includes("*")){const[s,n]=e.split("*");for(const r of this.cache.keys())r.startsWith(s)&&r.endsWith(n)&&(this.cache.delete(r),this.removeFromAccessOrder(r),t++)}else this.cache.delete(e)&&(this.removeFromAccessOrder(e),t++);return t}async has(e){const t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),this.removeFromAccessOrder(e),!1):!0:!1}async close(){this.cleanupIntervalId&&(clearInterval(this.cleanupIntervalId),this.cleanupIntervalId=void 0),this.cache.clear(),this.accessOrder=[]}cleanup(){const e=Date.now();let t=0;for(const[s,n]of this.cache.entries())e>n.expiresAt&&(this.cache.delete(s),this.removeFromAccessOrder(s),t++);return t}size(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}stats(){return{size:this.cache.size,maxEntries:this.maxEntries,defaultTtlMs:this.defaultTtlMs}}touchAccessOrder(e){this.removeFromAccessOrder(e),this.accessOrder.push(e)}removeFromAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1)}evictOldest(){for(;this.accessOrder.length>0&&this.maxEntries&&this.cache.size>=this.maxEntries;){const e=this.accessOrder.shift();e&&this.cache.delete(e)}}}const qs=`You are a security validator for a data analytics system. Your ONLY job is to determine if a user's input is a valid data analysis request.
|
|
214
|
+
`)}`)}getCube(e){return this.cubes.get(e)}getAllCubes(){return Array.from(this.cubes.values())}getAllCubesMap(){return this.cubes}async execute(e,t,s){return this.createQueryExecutor(!0).execute(this.cubes,e,t,s)}async executeMultiCubeQuery(e,t,s){return this.execute(e,t,s)}async executeQuery(e,t,s){if(!this.cubes.get(e))throw new Error(`Cube '${e}' not found`);return this.execute(t,s)}getMetadata(){return this.metadataCache?this.metadataCache:(this.metadataCache=Array.from(this.cubes.values()).map(e=>this.generateCubeMetadata(e)),this.metadataCache)}getColumnName(e){if(e&&e.name||e&&e.columnType&&e.name)return e.name;if(typeof e=="string")return e;if(e&&typeof e=="object"){if(e._.name)return e._.name;if(e.name)return e.name;if(e.columnName)return e.columnName}return"unknown_column"}static DEFAULT_TIME_GRANULARITIES=["year","quarter","month","week","day","hour"];generateCubeMetadata(e){const t=Object.keys(e.measures),s=Object.keys(e.dimensions),n=new Array(t.length),r=new Array(s.length);for(let T=0;T<t.length;T++){const R=t[T],l=e.measures[R];let S;l.drillMembers&&l.drillMembers.length>0&&(S=l.drillMembers.map(N=>N.includes(".")?N:`${e.name}.${N}`)),n[T]={name:`${e.name}.${R}`,title:l.title||R,shortTitle:l.title||R,type:l.type,format:void 0,description:l.description,synonyms:l.synonyms,drillMembers:S}}for(let T=0;T<s.length;T++){const R=s[T],l=e.dimensions[R];let S;l.type==="time"&&(S=l.granularities||ge.DEFAULT_TIME_GRANULARITIES),r[T]={name:`${e.name}.${R}`,title:l.title||R,shortTitle:l.title||R,type:l.type,format:void 0,description:l.description,synonyms:l.synonyms,granularities:S}}const E=[];if(e.joins)for(const[,T]of Object.entries(e.joins)){const R=typeof T.targetCube=="function"?T.targetCube():T.targetCube;E.push({targetCube:R.name,relationship:T.relationship,joinFields:T.on.map(l=>({sourceField:this.getColumnName(l.source),targetField:this.getColumnName(l.target)}))})}const a=[];if(e.hierarchies)for(const[,T]of Object.entries(e.hierarchies))a.push({name:T.name,title:T.title||T.name,cubeName:e.name,levels:T.levels.map(R=>R.includes(".")?R:`${e.name}.${R}`)});return{name:e.name,title:e.title||e.name,description:e.description,exampleQuestions:e.exampleQuestions,measures:n,dimensions:r,segments:[],relationships:E.length>0?E:void 0,hierarchies:a.length>0?a:void 0,meta:e.meta}}async generateSQL(e,t,s){const n=this.getCube(e);if(!n)throw new Error(`Cube '${e}' not found`);const E=await this.createQueryExecutor().generateSQL(n,t,s);return this.formatSqlResult(E)}async generateMultiCubeSQL(e,t){const n=await this.createQueryExecutor().generateMultiCubeSQL(this.cubes,e,t);return this.formatSqlResult(n)}async dryRun(e,t){const n=await this.createQueryExecutor().dryRunSQL(this.cubes,e,t);return this.formatSqlResult(n)}async dryRunFunnel(e,t){return this.dryRun(e,t)}async dryRunFlow(e,t){return this.dryRun(e,t)}async dryRunRetention(e,t){return this.dryRun(e,t)}async explainQuery(e,t,s){return this.createQueryExecutor().explainQuery(this.cubes,e,t,s)}hasCube(e){return this.cubes.has(e)}unregisterCube(e){return this.removeCube(e)}removeCube(e){const t=this.cubes.delete(e);return t&&this.invalidateMetadataCache(),t}clearCubes(){this.cubes.clear(),this.invalidateMetadataCache()}invalidateMetadataCache(){this.metadataCache=void 0}getCubeNames(){return Array.from(this.cubes.keys())}validateQuery(e){return Ws(this.cubes,e)}analyzeQuery(e,t){return this.createQueryExecutor(!0).analyzeQuery(this.cubes,e,t)}}function $o(i){const e=[];return i.timeDimensions?.some(t=>t.compareDateRange&&t.compareDateRange.length>=2)&&e.push("comparison"),i.funnel!==void 0&&i.funnel.steps?.length>=2&&e.push("funnel"),i.flow!==void 0&&i.flow.startingStep!==void 0&&i.flow.eventDimension!==void 0&&e.push("flow"),i.retention!==void 0&&i.retention.timeDimension!=null&&i.retention.bindingKey!=null&&e.push("retention"),e.length===0?[]:e}function Ws(i,e){const t=[],s=$o(e);if(s.length>1)return t.push(`Query contains multiple query modes: ${s.join(", ")}`),{isValid:!1,errors:t};const n={funnel:()=>{const E=e.funnel.bindingKey;if(typeof E=="string"){const[a]=E.split(".");a&&!i.has(a)&&t.push(`Funnel binding key cube not found: ${a}`)}else if(Array.isArray(E))for(const a of E)i.has(a.cube)||t.push(`Funnel binding key cube not found: ${a.cube}`)},flow:()=>{const E=e.flow.bindingKey;if(typeof E=="string"){const[a]=E.split(".");a&&!i.has(a)&&t.push(`Flow binding key cube not found: ${a}`)}},retention:()=>{const E=e.retention,a=Vo(E.timeDimension);a&&!i.has(a)&&t.push(`Retention cube not found: ${a}`);const A=E.bindingKey;if(typeof A=="string"){const[T]=A.split(".");T&&!i.has(T)&&t.push(`Retention binding key cube not found: ${T}`)}else if(Array.isArray(A))for(const T of A)i.has(T.cube)||t.push(`Retention binding key cube not found: ${T.cube}`);if(E.breakdownDimensions&&Array.isArray(E.breakdownDimensions))for(const T of E.breakdownDimensions){const[R]=T.split(".");R&&!i.has(R)&&t.push(`Retention breakdown cube not found: ${R}`)}}};if(s.length===1&&s[0]!=="comparison"){const E=s[0];return n[E](),{isValid:t.length===0,errors:t}}const r=new Set;if(e.measures)for(const E of e.measures){const[a,A]=E.split(".");if(!a||!A){t.push(`Invalid measure format: ${E}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in measure '${E}')`);continue}if(!T.measures[A]){const R=A===a?`. Did you mean one of: ${Object.keys(T.measures).slice(0,5).map(l=>`'${a}.${l}'`).join(", ")}?`:"";t.push(`Measure '${A}' not found on cube '${a}'${R}`)}}if(e.dimensions)for(const E of e.dimensions){const[a,A]=E.split(".");if(!a||!A){t.push(`Invalid dimension format: ${E}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in dimension '${E}')`);continue}if(!T.dimensions[A]){const R=A===a?`. Did you mean one of: ${Object.keys(T.dimensions).slice(0,5).map(l=>`'${a}.${l}'`).join(", ")}?`:"";t.push(`Dimension '${A}' not found on cube '${a}'${R}`)}}if(e.timeDimensions)for(const E of e.timeDimensions){const[a,A]=E.dimension.split(".");if(!a||!A){t.push(`Invalid timeDimension format: ${E.dimension}. Expected format: 'CubeName.fieldName'`);continue}r.add(a);const T=i.get(a);if(!T){t.push(`Cube '${a}' not found (referenced in timeDimension '${E.dimension}')`);continue}T.dimensions[A]||t.push(`TimeDimension '${A}' not found on cube '${a}' (must be a dimension with time type)`)}if(e.filters)for(const E of e.filters)xs(E,i,t,r);return r.size===0&&t.push("Query must reference at least one cube through measures, dimensions, or filters"),{isValid:t.length===0,errors:t}}function xs(i,e,t,s){if("and"in i||"or"in i){const a=i.and||i.or||[];for(const A of a)xs(A,e,t,s);return}if(!("member"in i)){t.push("Filter must have a member field");return}const[n,r]=i.member.split(".");if(!n||!r){t.push(`Invalid filter member format: ${i.member}. Expected format: 'CubeName.fieldName'`);return}s.add(n);const E=e.get(n);if(!E){t.push(`Cube '${n}' not found (referenced in filter '${i.member}')`);return}if(!E.dimensions[r]&&!E.measures[r]){const a=r===n?`. Did you mean one of: ${[...Object.keys(E.dimensions),...Object.keys(E.measures)].slice(0,5).map(A=>`'${n}.${A}'`).join(", ")}?`:"";t.push(`Filter field '${r}' not found on cube '${n}' (must be a dimension or measure)${a}`)}}function Vo(i){if(typeof i=="string"){const[e]=i.split(".");return e||null}return i.cube}class Wo{cache=new Map;defaultTtlMs;maxEntries;cleanupIntervalId;accessOrder=[];constructor(e={}){this.defaultTtlMs=e.defaultTtlMs??3e5,this.maxEntries=e.maxEntries;const t=e.cleanupIntervalMs??6e4;t>0&&(this.cleanupIntervalId=setInterval(()=>{this.cleanup()},t),typeof this.cleanupIntervalId=="object"&&"unref"in this.cleanupIntervalId&&this.cleanupIntervalId.unref())}async get(e){const t=this.cache.get(e);if(!t)return null;const s=Date.now();return s>t.expiresAt?(this.cache.delete(e),this.removeFromAccessOrder(e),null):(this.touchAccessOrder(e),{value:t.value,metadata:{cachedAt:t.cachedAt,ttlMs:t.ttlMs,ttlRemainingMs:t.expiresAt-s}})}async set(e,t,s){const n=s??this.defaultTtlMs,r=Date.now();this.maxEntries&&this.cache.size>=this.maxEntries&&!this.cache.has(e)&&this.evictOldest(),this.cache.set(e,{value:t,cachedAt:r,ttlMs:n,expiresAt:r+n}),this.touchAccessOrder(e)}async delete(e){const t=this.cache.delete(e);return t&&this.removeFromAccessOrder(e),t}async deletePattern(e){let t=0;if(e.endsWith("*")){const s=e.slice(0,-1);for(const n of this.cache.keys())n.startsWith(s)&&(this.cache.delete(n),this.removeFromAccessOrder(n),t++)}else if(e.startsWith("*")){const s=e.slice(1);for(const n of this.cache.keys())n.endsWith(s)&&(this.cache.delete(n),this.removeFromAccessOrder(n),t++)}else if(e.includes("*")){const[s,n]=e.split("*");for(const r of this.cache.keys())r.startsWith(s)&&r.endsWith(n)&&(this.cache.delete(r),this.removeFromAccessOrder(r),t++)}else this.cache.delete(e)&&(this.removeFromAccessOrder(e),t++);return t}async has(e){const t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),this.removeFromAccessOrder(e),!1):!0:!1}async close(){this.cleanupIntervalId&&(clearInterval(this.cleanupIntervalId),this.cleanupIntervalId=void 0),this.cache.clear(),this.accessOrder=[]}cleanup(){const e=Date.now();let t=0;for(const[s,n]of this.cache.entries())e>n.expiresAt&&(this.cache.delete(s),this.removeFromAccessOrder(s),t++);return t}size(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}stats(){return{size:this.cache.size,maxEntries:this.maxEntries,defaultTtlMs:this.defaultTtlMs}}touchAccessOrder(e){this.removeFromAccessOrder(e),this.accessOrder.push(e)}removeFromAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1)}evictOldest(){for(;this.accessOrder.length>0&&this.maxEntries&&this.cache.size>=this.maxEntries;){const e=this.accessOrder.shift();e&&this.cache.delete(e)}}}const qs=`You are a security validator for a data analytics system. Your ONLY job is to determine if a user's input is a valid data analysis request.
|
|
215
215
|
|
|
216
216
|
USER INPUT TO VALIDATE:
|
|
217
217
|
{USER_PROMPT}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4522,6 +4522,11 @@ export declare class SemanticLayerCompiler {
|
|
|
4522
4522
|
* Check if a cube exists
|
|
4523
4523
|
*/
|
|
4524
4524
|
hasCube(name: string): boolean;
|
|
4525
|
+
/**
|
|
4526
|
+
* Unregister a cube by name.
|
|
4527
|
+
* Returns true if the cube existed and was removed, false if not found.
|
|
4528
|
+
*/
|
|
4529
|
+
unregisterCube(name: string): boolean;
|
|
4525
4530
|
/**
|
|
4526
4531
|
* Remove a cube
|
|
4527
4532
|
*/
|
package/dist/server/index.js
CHANGED
|
@@ -29492,6 +29492,13 @@ ${t.join(`
|
|
|
29492
29492
|
hasCube(e) {
|
|
29493
29493
|
return this.cubes.has(e);
|
|
29494
29494
|
}
|
|
29495
|
+
/**
|
|
29496
|
+
* Unregister a cube by name.
|
|
29497
|
+
* Returns true if the cube existed and was removed, false if not found.
|
|
29498
|
+
*/
|
|
29499
|
+
unregisterCube(e) {
|
|
29500
|
+
return this.removeCube(e);
|
|
29501
|
+
}
|
|
29495
29502
|
/**
|
|
29496
29503
|
* Remove a cube
|
|
29497
29504
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-cube",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.23",
|
|
4
4
|
"description": "Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.",
|
|
5
5
|
"main": "./dist/server/index.js",
|
|
6
6
|
"types": "./dist/server/index.d.ts",
|