drizzle-cube 0.3.13 → 0.3.16
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.d.ts +8 -1
- package/dist/adapters/express/index.js +162 -99
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.d.ts +8 -1
- package/dist/adapters/fastify/index.js +183 -96
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.d.ts +8 -1
- package/dist/adapters/hono/index.js +198 -142
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.d.ts +29 -1
- package/dist/adapters/nextjs/index.js +251 -132
- package/dist/adapters/utils.d.ts +100 -1
- package/dist/adapters/validation-Bgauxvm6.cjs +214 -0
- package/dist/adapters/{compiler-DTOU8IsK.js → validation-_UkKJ2pC.js} +9582 -5295
- package/dist/client/adapters/index.d.ts +2 -0
- package/dist/client/adapters/retentionModeAdapter.d.ts +3 -0
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/RetentionCombinedChart-DirfDaZH.js +256 -0
- package/dist/client/chunks/RetentionCombinedChart-DirfDaZH.js.map +1 -0
- package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js +47 -0
- package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js.map +1 -0
- package/dist/client/chunks/RetentionHeatmap-Bofadstm.js +178 -0
- package/dist/client/chunks/RetentionHeatmap-Bofadstm.js.map +1 -0
- package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js +28 -0
- package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js.map +1 -0
- package/dist/client/chunks/analysis-builder-APeCxkEH.js +6939 -0
- package/dist/client/chunks/analysis-builder-APeCxkEH.js.map +1 -0
- package/dist/client/chunks/analysis-builder-shared-DEovRjrp.js +2779 -0
- package/dist/client/chunks/analysis-builder-shared-DEovRjrp.js.map +1 -0
- package/dist/client/chunks/{chart-activity-grid-CuPARsr1.js → chart-activity-grid-BnweuBvr.js} +11 -11
- package/dist/client/chunks/{chart-activity-grid-CuPARsr1.js.map → chart-activity-grid-BnweuBvr.js.map} +1 -1
- package/dist/client/chunks/{chart-area-cPrJnhLj.js → chart-area-DLmXFWWy.js} +2 -2
- package/dist/client/chunks/{chart-area-cPrJnhLj.js.map → chart-area-DLmXFWWy.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-D68HFPpa.js → chart-bar-7y0-F27Q.js} +2 -2
- package/dist/client/chunks/{chart-bar-D68HFPpa.js.map → chart-bar-7y0-F27Q.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-CquyYfNO.js → chart-bubble-3jYKCA2B.js} +2 -2
- package/dist/client/chunks/{chart-bubble-CquyYfNO.js.map → chart-bubble-3jYKCA2B.js.map} +1 -1
- package/dist/client/chunks/{chart-config-activity-grid-Bkvx0F-G.js → chart-config-activity-grid-BBSNCbkb.js} +2 -2
- package/dist/client/chunks/{chart-config-activity-grid-Bkvx0F-G.js.map → chart-config-activity-grid-BBSNCbkb.js.map} +1 -1
- package/dist/client/chunks/{chart-config-area-OApsRaYC.js → chart-config-area-CyyJOO2T.js} +2 -2
- package/dist/client/chunks/{chart-config-area-OApsRaYC.js.map → chart-config-area-CyyJOO2T.js.map} +1 -1
- package/dist/client/chunks/{chart-config-bar-Dy21oaIA.js → chart-config-bar-BJKGnfLt.js} +2 -2
- package/dist/client/chunks/{chart-config-bar-Dy21oaIA.js.map → chart-config-bar-BJKGnfLt.js.map} +1 -1
- package/dist/client/chunks/{chart-config-bubble-Chv0SoFm.js → chart-config-bubble-CuSsCHZ4.js} +2 -2
- package/dist/client/chunks/{chart-config-bubble-Chv0SoFm.js.map → chart-config-bubble-CuSsCHZ4.js.map} +1 -1
- package/dist/client/chunks/{chart-config-data-table-DTIdC35a.js → chart-config-data-table-BhgqwoqT.js} +2 -2
- package/dist/client/chunks/{chart-config-data-table-DTIdC35a.js.map → chart-config-data-table-BhgqwoqT.js.map} +1 -1
- package/dist/client/chunks/{chart-config-funnel-f17Livgr.js → chart-config-funnel-BlSQYng0.js} +4 -4
- package/dist/client/chunks/{chart-config-funnel-f17Livgr.js.map → chart-config-funnel-BlSQYng0.js.map} +1 -1
- package/dist/client/chunks/{chart-config-heat-map-DPhNICha.js → chart-config-heat-map-DHQGFZhX.js} +2 -2
- package/dist/client/chunks/{chart-config-heat-map-DPhNICha.js.map → chart-config-heat-map-DHQGFZhX.js.map} +1 -1
- package/dist/client/chunks/{chart-config-kpi-delta-CCl1d-St.js → chart-config-kpi-delta-yTA5ug_l.js} +2 -2
- package/dist/client/chunks/{chart-config-kpi-delta-CCl1d-St.js.map → chart-config-kpi-delta-yTA5ug_l.js.map} +1 -1
- package/dist/client/chunks/{chart-config-kpi-number-DkE3eSwH.js → chart-config-kpi-number-nVAwDXzq.js} +2 -2
- package/dist/client/chunks/{chart-config-kpi-number-DkE3eSwH.js.map → chart-config-kpi-number-nVAwDXzq.js.map} +1 -1
- package/dist/client/chunks/{chart-config-kpi-text-BMbgdxZm.js → chart-config-kpi-text-DZjqsx-b.js} +2 -2
- package/dist/client/chunks/{chart-config-kpi-text-BMbgdxZm.js.map → chart-config-kpi-text-DZjqsx-b.js.map} +1 -1
- package/dist/client/chunks/{chart-config-line-BnLlRUQE.js → chart-config-line-DR0ThxZy.js} +2 -2
- package/dist/client/chunks/{chart-config-line-BnLlRUQE.js.map → chart-config-line-DR0ThxZy.js.map} +1 -1
- package/dist/client/chunks/{chart-config-markdown-DIaMFC0Z.js → chart-config-markdown-DZxdGNVQ.js} +2 -2
- package/dist/client/chunks/{chart-config-markdown-DIaMFC0Z.js.map → chart-config-markdown-DZxdGNVQ.js.map} +1 -1
- package/dist/client/chunks/{chart-config-pie-O9y_T0BQ.js → chart-config-pie-BM5lgH-w.js} +2 -2
- package/dist/client/chunks/{chart-config-pie-O9y_T0BQ.js.map → chart-config-pie-BM5lgH-w.js.map} +1 -1
- package/dist/client/chunks/{chart-config-radar-CXa0354h.js → chart-config-radar-BBAVIF0S.js} +2 -2
- package/dist/client/chunks/{chart-config-radar-CXa0354h.js.map → chart-config-radar-BBAVIF0S.js.map} +1 -1
- package/dist/client/chunks/{chart-config-radial-bar-BppJU8-Q.js → chart-config-radial-bar-CTwjDRnB.js} +2 -2
- package/dist/client/chunks/{chart-config-radial-bar-BppJU8-Q.js.map → chart-config-radial-bar-CTwjDRnB.js.map} +1 -1
- package/dist/client/chunks/{chart-config-sankey-BfBHgL4x.js → chart-config-sankey-CNAgsMQ4.js} +2 -2
- package/dist/client/chunks/{chart-config-sankey-BfBHgL4x.js.map → chart-config-sankey-CNAgsMQ4.js.map} +1 -1
- package/dist/client/chunks/{chart-config-scatter-BTt8a10R.js → chart-config-scatter-CWvN2E-X.js} +2 -2
- package/dist/client/chunks/{chart-config-scatter-BTt8a10R.js.map → chart-config-scatter-CWvN2E-X.js.map} +1 -1
- package/dist/client/chunks/{chart-config-sunburst-DNmQpIIx.js → chart-config-sunburst-W_SKwaj0.js} +4 -4
- package/dist/client/chunks/{chart-config-sunburst-DNmQpIIx.js.map → chart-config-sunburst-W_SKwaj0.js.map} +1 -1
- package/dist/client/chunks/{chart-config-tree-map-HVgG4oa0.js → chart-config-tree-map-CLmRvvMR.js} +2 -2
- package/dist/client/chunks/{chart-config-tree-map-HVgG4oa0.js.map → chart-config-tree-map-CLmRvvMR.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-D4WDqbM0.js → chart-data-table-rUFLqysu.js} +4 -4
- package/dist/client/chunks/{chart-data-table-D4WDqbM0.js.map → chart-data-table-rUFLqysu.js.map} +1 -1
- package/dist/client/chunks/{chart-funnel-Csdn4FbN.js → chart-funnel-C7zGBfSw.js} +2 -2
- package/dist/client/chunks/{chart-funnel-Csdn4FbN.js.map → chart-funnel-C7zGBfSw.js.map} +1 -1
- package/dist/client/chunks/{chart-heat-map-v1afxnjq.js → chart-heat-map-B-l8hK8b.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-v1afxnjq.js.map → chart-heat-map-B-l8hK8b.js.map} +1 -1
- package/dist/client/chunks/chart-kpi-delta-sfZEvQZm.js +351 -0
- package/dist/client/chunks/chart-kpi-delta-sfZEvQZm.js.map +1 -0
- package/dist/client/chunks/chart-kpi-number-BxGNOtzI.js +473 -0
- package/dist/client/chunks/chart-kpi-number-BxGNOtzI.js.map +1 -0
- package/dist/client/chunks/{chart-kpi-text-CRp8QWYG.js → chart-kpi-text-BLQ_CWQP.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-CRp8QWYG.js.map → chart-kpi-text-BLQ_CWQP.js.map} +1 -1
- package/dist/client/chunks/{chart-line-DqqE7ky9.js → chart-line-FSEpBk6Y.js} +5 -5
- package/dist/client/chunks/{chart-line-DqqE7ky9.js.map → chart-line-FSEpBk6Y.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-B5WBzIRH.js → chart-pie-BRQEH9e-.js} +2 -2
- package/dist/client/chunks/{chart-pie-B5WBzIRH.js.map → chart-pie-BRQEH9e-.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-DL_dvhA-.js → chart-radar-DgsFyiIP.js} +2 -2
- package/dist/client/chunks/{chart-radar-DL_dvhA-.js.map → chart-radar-DgsFyiIP.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-DDRo6nz-.js → chart-radial-bar-CUMoXyl9.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-DDRo6nz-.js.map → chart-radial-bar-CUMoXyl9.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-C_bgIfg-.js → chart-sankey-IAKDEe7A.js} +2 -2
- package/dist/client/chunks/{chart-sankey-C_bgIfg-.js.map → chart-sankey-IAKDEe7A.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-DjmJRlK0.js → chart-scatter-D6XwOD2W.js} +15 -15
- package/dist/client/chunks/{chart-scatter-DjmJRlK0.js.map → chart-scatter-D6XwOD2W.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-CbMEnaes.js → chart-sunburst-CP_pnj0S.js} +2 -2
- package/dist/client/chunks/{chart-sunburst-CbMEnaes.js.map → chart-sunburst-CP_pnj0S.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-DEfJtJVC.js → chart-tree-map-DQMsn47a.js} +30 -30
- package/dist/client/chunks/{chart-tree-map-DEfJtJVC.js.map → chart-tree-map-DQMsn47a.js.map} +1 -1
- package/dist/client/chunks/chartConfigRegistry-BumUIPw4.js +44 -0
- package/dist/client/chunks/{chartConfigRegistry-CiOq-PqX.js.map → chartConfigRegistry-BumUIPw4.js.map} +1 -1
- package/dist/client/chunks/charts-Dk_9XrA7.js +230 -0
- package/dist/client/chunks/charts-Dk_9XrA7.js.map +1 -0
- package/dist/client/chunks/{charts-core-CXrhEEVF.js → charts-core-CjQZBxmv.js} +10 -10
- package/dist/client/chunks/{charts-core-CXrhEEVF.js.map → charts-core-CjQZBxmv.js.map} +1 -1
- package/dist/client/chunks/{charts-loader-BtsnUO4Q.js → charts-loader-ChTUa_-G.js} +30 -28
- package/dist/client/chunks/charts-loader-ChTUa_-G.js.map +1 -0
- package/dist/client/chunks/{components-BDrlf9Er.js → components-BKZ7EAg0.js} +3575 -3208
- package/dist/client/chunks/components-BKZ7EAg0.js.map +1 -0
- package/dist/client/chunks/{core-B8zw0qRf.js → core-BRC075EG.js} +2 -2
- package/dist/client/chunks/{core-B8zw0qRf.js.map → core-BRC075EG.js.map} +1 -1
- package/dist/client/chunks/hooks-D7APQ8uS.js +150 -0
- package/dist/client/chunks/{hooks-B8Zw5PfL.js.map → hooks-D7APQ8uS.js.map} +1 -1
- package/dist/client/chunks/{icons-NzFHtqeM.js → icons-DRreo6m8.js} +128 -112
- package/dist/client/chunks/{icons-NzFHtqeM.js.map → icons-DRreo6m8.js.map} +1 -1
- package/dist/client/chunks/{providers-CqCiJTEj.js → providers-Cj7PQfXn.js} +2 -2
- package/dist/client/chunks/{providers-CqCiJTEj.js.map → providers-Cj7PQfXn.js.map} +1 -1
- package/dist/client/chunks/retention-CzCo8262.js +120 -0
- package/dist/client/chunks/retention-CzCo8262.js.map +1 -0
- package/dist/client/chunks/{useDirtyStateTracking-C_mitVwh.js → useDirtyStateTracking-ZSi3voVl.js} +101 -99
- package/dist/client/chunks/useDirtyStateTracking-ZSi3voVl.js.map +1 -0
- package/dist/client/chunks/{vendor-DzzxS7Ay.js → vendor-cTQhZ_G3.js} +549 -541
- package/dist/client/chunks/vendor-cTQhZ_G3.js.map +1 -0
- package/dist/client/components/AnalysisBuilder/AnalysisTypeSelector.d.ts +3 -1
- package/dist/client/components/AnalysisBuilder/RetentionConfigPanel.d.ts +36 -0
- package/dist/client/components/AnalysisBuilder/RetentionModeContent.d.ts +71 -0
- package/dist/client/components/AnalysisBuilder/types.d.ts +99 -0
- package/dist/client/components/DebugModal.d.ts +2 -1
- package/dist/client/components/charts/RetentionCombinedChart.config.d.ts +2 -0
- package/dist/client/components/charts/RetentionCombinedChart.d.ts +14 -0
- package/dist/client/components/charts/RetentionHeatmap.config.d.ts +2 -0
- package/dist/client/components/charts/RetentionHeatmap.d.ts +7 -0
- package/dist/client/components.js +2 -2
- package/dist/client/hooks/queries/index.d.ts +2 -1
- package/dist/client/hooks/queries/useDryRunQuery.d.ts +26 -0
- package/dist/client/hooks/queries/useExplainQuery.d.ts +3 -1
- package/dist/client/hooks/queries/useFlowQuery.d.ts +5 -0
- package/dist/client/hooks/queries/useRetentionQuery.d.ts +67 -0
- package/dist/client/hooks/useAnalysisBuilderHook.d.ts +61 -0
- package/dist/client/hooks/useAnalysisQueryExecution.d.ts +42 -1
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons/customIcons.d.ts +7 -0
- package/dist/client/icons/types.d.ts +1 -0
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +11 -11
- package/dist/client/providers.js +1 -1
- package/dist/client/stores/analysisBuilderStore.d.ts +86 -1
- package/dist/client/stores/dashboardStore.d.ts +2 -1
- package/dist/client/stores/slices/index.d.ts +2 -0
- package/dist/client/stores/slices/retentionSlice.d.ts +66 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/types/analysisConfig.d.ts +29 -4
- package/dist/client/types/funnel.d.ts +5 -0
- package/dist/client/types/retention.d.ts +301 -0
- package/dist/client/types.d.ts +6 -3
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +101 -79
- package/dist/server/index.d.ts +427 -0
- package/dist/server/index.js +9140 -4934
- package/package.json +5 -2
- package/dist/adapters/compiler-CO13DaEb.cjs +0 -192
- package/dist/client/chunks/analysis-builder-Dc9NrG_N.js +0 -6013
- package/dist/client/chunks/analysis-builder-Dc9NrG_N.js.map +0 -1
- package/dist/client/chunks/analysis-builder-shared-B3-UWqQ2.js +0 -2540
- package/dist/client/chunks/analysis-builder-shared-B3-UWqQ2.js.map +0 -1
- package/dist/client/chunks/chart-kpi-delta-Bs5R5xr4.js +0 -435
- package/dist/client/chunks/chart-kpi-delta-Bs5R5xr4.js.map +0 -1
- package/dist/client/chunks/chart-kpi-number-Cf4Pgkm9.js +0 -392
- package/dist/client/chunks/chart-kpi-number-Cf4Pgkm9.js.map +0 -1
- package/dist/client/chunks/chartConfigRegistry-CiOq-PqX.js +0 -44
- package/dist/client/chunks/charts-loader-BtsnUO4Q.js.map +0 -1
- package/dist/client/chunks/charts-xNubY0vm.js +0 -226
- package/dist/client/chunks/charts-xNubY0vm.js.map +0 -1
- package/dist/client/chunks/components-BDrlf9Er.js.map +0 -1
- package/dist/client/chunks/hooks-B8Zw5PfL.js +0 -123
- package/dist/client/chunks/useDirtyStateTracking-C_mitVwh.js.map +0 -1
- package/dist/client/chunks/vendor-DzzxS7Ay.js.map +0 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -25,6 +25,42 @@ export declare interface AIExplainAnalysis {
|
|
|
25
25
|
recommendations: ExplainRecommendation[];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Validate a query with helpful corrections
|
|
30
|
+
*/
|
|
31
|
+
export declare function aiValidateQuery(query: SemanticQuery, metadata: CubeMetadata[]): AIValidationResult;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validation error with optional correction
|
|
35
|
+
*/
|
|
36
|
+
export declare interface AIValidationError {
|
|
37
|
+
type: 'cube_not_found' | 'measure_not_found' | 'dimension_not_found' | 'invalid_filter' | 'invalid_time_dimension' | 'syntax_error';
|
|
38
|
+
message: string;
|
|
39
|
+
field?: string;
|
|
40
|
+
suggestion?: string;
|
|
41
|
+
correctedValue?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Validation result with corrections
|
|
46
|
+
*/
|
|
47
|
+
export declare interface AIValidationResult {
|
|
48
|
+
isValid: boolean;
|
|
49
|
+
errors: AIValidationError[];
|
|
50
|
+
warnings: AIValidationWarning[];
|
|
51
|
+
correctedQuery?: SemanticQuery;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Validation warning (query will work but may have issues)
|
|
56
|
+
*/
|
|
57
|
+
export declare interface AIValidationWarning {
|
|
58
|
+
type: 'ambiguous_field' | 'performance' | 'best_practice';
|
|
59
|
+
message: string;
|
|
60
|
+
field?: string;
|
|
61
|
+
suggestion?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
28
64
|
/**
|
|
29
65
|
* Abstract base class for database executors
|
|
30
66
|
*/
|
|
@@ -299,6 +335,12 @@ declare interface Cube {
|
|
|
299
335
|
name: string;
|
|
300
336
|
title?: string;
|
|
301
337
|
description?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Example questions that can be answered using this cube
|
|
340
|
+
* Used by AI agents to understand cube capabilities
|
|
341
|
+
* @example ['What was total revenue last month?', 'Show me sales by category']
|
|
342
|
+
*/
|
|
343
|
+
exampleQuestions?: string[];
|
|
302
344
|
/**
|
|
303
345
|
* Base query setup - returns the foundation that can be extended
|
|
304
346
|
* Should return FROM/JOIN/WHERE setup, NOT a complete SELECT
|
|
@@ -338,6 +380,41 @@ export declare type CubeDefinition = Omit<Cube, 'name'> & {
|
|
|
338
380
|
name?: string;
|
|
339
381
|
};
|
|
340
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Discovery result for a cube
|
|
385
|
+
*/
|
|
386
|
+
export declare interface CubeDiscoveryResult {
|
|
387
|
+
cube: string;
|
|
388
|
+
title: string;
|
|
389
|
+
description?: string;
|
|
390
|
+
relevanceScore: number;
|
|
391
|
+
matchedOn: ('name' | 'title' | 'description' | 'exampleQuestions' | 'measures' | 'dimensions')[];
|
|
392
|
+
suggestedMeasures: string[];
|
|
393
|
+
suggestedDimensions: string[];
|
|
394
|
+
capabilities: {
|
|
395
|
+
query: true;
|
|
396
|
+
funnel: boolean;
|
|
397
|
+
flow: boolean;
|
|
398
|
+
retention: boolean;
|
|
399
|
+
};
|
|
400
|
+
analysisConfig?: {
|
|
401
|
+
candidateBindingKeys: Array<{
|
|
402
|
+
dimension: string;
|
|
403
|
+
description?: string;
|
|
404
|
+
}>;
|
|
405
|
+
candidateTimeDimensions: Array<{
|
|
406
|
+
dimension: string;
|
|
407
|
+
description?: string;
|
|
408
|
+
}>;
|
|
409
|
+
candidateEventDimensions: Array<{
|
|
410
|
+
dimension: string;
|
|
411
|
+
description?: string;
|
|
412
|
+
}>;
|
|
413
|
+
};
|
|
414
|
+
hints?: string[];
|
|
415
|
+
querySchemas?: typeof QUERY_SCHEMAS;
|
|
416
|
+
}
|
|
417
|
+
|
|
341
418
|
/**
|
|
342
419
|
* Type-safe cube join definition with lazy loading support
|
|
343
420
|
*/
|
|
@@ -398,6 +475,11 @@ export declare interface CubeMetadata {
|
|
|
398
475
|
name: string;
|
|
399
476
|
title: string;
|
|
400
477
|
description?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Example questions that can be answered using this cube
|
|
480
|
+
* Used by AI agents to understand cube capabilities
|
|
481
|
+
*/
|
|
482
|
+
exampleQuestions?: string[];
|
|
401
483
|
measures: MeasureMetadata[];
|
|
402
484
|
dimensions: DimensionMetadata[];
|
|
403
485
|
segments: any[];
|
|
@@ -467,6 +549,22 @@ declare interface DatabaseAdapter {
|
|
|
467
549
|
* @returns SQL for conditional aggregation
|
|
468
550
|
*/
|
|
469
551
|
buildConditionalAggregation(aggFn: 'count' | 'avg' | 'min' | 'max' | 'sum', expr: SQL | null, condition: SQL): SQL;
|
|
552
|
+
/**
|
|
553
|
+
* Build date difference expression in specified periods
|
|
554
|
+
* Used for retention analysis to calculate period numbers
|
|
555
|
+
* @param startDate - Start date expression
|
|
556
|
+
* @param endDate - End date expression
|
|
557
|
+
* @param unit - Unit for difference ('day' | 'week' | 'month')
|
|
558
|
+
* @returns SQL expression for date difference in periods
|
|
559
|
+
*/
|
|
560
|
+
buildDateDiffPeriods(startDate: SQL, endDate: SQL, unit: 'day' | 'week' | 'month'): SQL;
|
|
561
|
+
/**
|
|
562
|
+
* Build a subquery that generates a series of period numbers (0 to maxPeriod)
|
|
563
|
+
* Used for retention analysis to cross-join with user data
|
|
564
|
+
* @param maxPeriod - Maximum period number to generate
|
|
565
|
+
* @returns SQL expression for period series subquery with alias 'p' containing 'period_number' column
|
|
566
|
+
*/
|
|
567
|
+
buildPeriodSeriesSubquery(maxPeriod: number): SQL;
|
|
470
568
|
/**
|
|
471
569
|
* Build time dimension expression with granularity truncation
|
|
472
570
|
* @param granularity - Time granularity (day, month, year, etc.)
|
|
@@ -636,6 +734,12 @@ declare interface Dimension {
|
|
|
636
734
|
name: string;
|
|
637
735
|
title?: string;
|
|
638
736
|
description?: string;
|
|
737
|
+
/**
|
|
738
|
+
* Alternative names for this dimension
|
|
739
|
+
* Used by AI agents for natural language matching
|
|
740
|
+
* @example ['date', 'day', 'timestamp'] for a createdAt dimension
|
|
741
|
+
*/
|
|
742
|
+
synonyms?: string[];
|
|
639
743
|
type: DimensionType;
|
|
640
744
|
/** Direct column reference or SQL expression */
|
|
641
745
|
sql: AnyColumn | SQL | ((ctx: QueryContext) => AnyColumn | SQL);
|
|
@@ -670,6 +774,11 @@ export declare interface DimensionMetadata {
|
|
|
670
774
|
type: string;
|
|
671
775
|
format?: DimensionFormat;
|
|
672
776
|
description?: string;
|
|
777
|
+
/**
|
|
778
|
+
* Alternative names for this dimension
|
|
779
|
+
* Used by AI agents for natural language matching
|
|
780
|
+
*/
|
|
781
|
+
synonyms?: string[];
|
|
673
782
|
}
|
|
674
783
|
|
|
675
784
|
export declare type DimensionType = 'string' | 'number' | 'time' | 'boolean';
|
|
@@ -683,6 +792,25 @@ export declare interface DimensionValues {
|
|
|
683
792
|
[dimensionName: string]: string[];
|
|
684
793
|
}
|
|
685
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Discover relevant cubes based on topic or intent
|
|
797
|
+
*/
|
|
798
|
+
export declare function discoverCubes(metadata: CubeMetadata[], options?: DiscoveryOptions): CubeDiscoveryResult[];
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Discovery request options
|
|
802
|
+
*/
|
|
803
|
+
export declare interface DiscoveryOptions {
|
|
804
|
+
/** Topic or intent to search for */
|
|
805
|
+
topic?: string;
|
|
806
|
+
/** Natural language intent */
|
|
807
|
+
intent?: string;
|
|
808
|
+
/** Maximum number of results */
|
|
809
|
+
limit?: number;
|
|
810
|
+
/** Minimum relevance score (0-1) */
|
|
811
|
+
minScore?: number;
|
|
812
|
+
}
|
|
813
|
+
|
|
686
814
|
/**
|
|
687
815
|
* Information about downstream join keys for CTE building.
|
|
688
816
|
* Used when a cube (e.g., Teams) needs to be joined through a CTE cube (e.g., EmployeeTeams)
|
|
@@ -875,6 +1003,16 @@ export declare interface ExplainSummary {
|
|
|
875
1003
|
usedIndexes: string[];
|
|
876
1004
|
}
|
|
877
1005
|
|
|
1006
|
+
/**
|
|
1007
|
+
* Extract cube name from a time dimension specification
|
|
1008
|
+
*/
|
|
1009
|
+
export declare function extractCubeFromTimeDimension(timeDimension: string | RetentionTimeDimensionMapping): string;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Extract dimension name from a time dimension specification
|
|
1013
|
+
*/
|
|
1014
|
+
export declare function extractDimensionFromTimeDimension(timeDimension: string | RetentionTimeDimensionMapping): string;
|
|
1015
|
+
|
|
878
1016
|
/**
|
|
879
1017
|
* Type-level utility to extract the schema type from a cube reference
|
|
880
1018
|
* Since we removed generics, this now returns 'any'
|
|
@@ -957,6 +1095,16 @@ export declare interface FilterCondition {
|
|
|
957
1095
|
*/
|
|
958
1096
|
export declare type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'notStartsWith' | 'endsWith' | 'notEndsWith' | 'gt' | 'gte' | 'lt' | 'lte' | 'set' | 'notSet' | 'inDateRange' | 'beforeDate' | 'afterDate' | 'between' | 'notBetween' | 'in' | 'notIn' | 'like' | 'notLike' | 'ilike' | 'regex' | 'notRegex' | 'isEmpty' | 'isNotEmpty' | 'arrayContains' | 'arrayOverlaps' | 'arrayContained';
|
|
959
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Find the best matching field across all cubes
|
|
1100
|
+
*/
|
|
1101
|
+
export declare function findBestFieldMatch(metadata: CubeMetadata[], fieldName: string, fieldType?: 'measure' | 'dimension'): {
|
|
1102
|
+
field: string;
|
|
1103
|
+
cube: string;
|
|
1104
|
+
score: number;
|
|
1105
|
+
type: 'measure' | 'dimension';
|
|
1106
|
+
} | null;
|
|
1107
|
+
|
|
960
1108
|
/**
|
|
961
1109
|
* Flow query configuration for server-side execution
|
|
962
1110
|
* This is the configuration extracted from SemanticQuery.flow
|
|
@@ -1231,6 +1379,23 @@ export declare function isMultiCubeStep(step: FunnelStep): step is FunnelStepMul
|
|
|
1231
1379
|
*/
|
|
1232
1380
|
export declare function isMultiCubeTimeDimension(timeDimension: string | FunnelTimeDimensionMapping[]): timeDimension is FunnelTimeDimensionMapping[];
|
|
1233
1381
|
|
|
1382
|
+
/**
|
|
1383
|
+
* Type guard for multi-cube binding key
|
|
1384
|
+
*/
|
|
1385
|
+
export declare function isRetentionMultiCubeBindingKey(bindingKey: string | RetentionBindingKeyMapping[]): bindingKey is RetentionBindingKeyMapping[];
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Type guard for multi-cube time dimension (object form)
|
|
1389
|
+
*/
|
|
1390
|
+
export declare function isRetentionMultiCubeTimeDimension(timeDimension: string | RetentionTimeDimensionMapping): timeDimension is RetentionTimeDimensionMapping;
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Type guard for retention query
|
|
1394
|
+
*/
|
|
1395
|
+
export declare function isRetentionQuery(query: unknown): query is {
|
|
1396
|
+
retention: RetentionQueryConfig;
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1234
1399
|
/**
|
|
1235
1400
|
* Join key information for CTE joins
|
|
1236
1401
|
* Describes how a CTE should be joined to the main query
|
|
@@ -1313,6 +1478,12 @@ declare interface Measure {
|
|
|
1313
1478
|
name: string;
|
|
1314
1479
|
title?: string;
|
|
1315
1480
|
description?: string;
|
|
1481
|
+
/**
|
|
1482
|
+
* Alternative names for this measure
|
|
1483
|
+
* Used by AI agents for natural language matching
|
|
1484
|
+
* @example ['revenue', 'sales', 'income'] for a totalRevenue measure
|
|
1485
|
+
*/
|
|
1486
|
+
synonyms?: string[];
|
|
1316
1487
|
type: MeasureType;
|
|
1317
1488
|
/**
|
|
1318
1489
|
* Column to aggregate or SQL expression
|
|
@@ -1439,6 +1610,11 @@ export declare interface MeasureMetadata {
|
|
|
1439
1610
|
type: MeasureType;
|
|
1440
1611
|
format?: MeasureFormat;
|
|
1441
1612
|
description?: string;
|
|
1613
|
+
/**
|
|
1614
|
+
* Alternative names for this measure
|
|
1615
|
+
* Used by AI agents for natural language matching
|
|
1616
|
+
*/
|
|
1617
|
+
synonyms?: string[];
|
|
1442
1618
|
}
|
|
1443
1619
|
|
|
1444
1620
|
/**
|
|
@@ -1768,6 +1944,64 @@ export declare interface PropagatingFilter {
|
|
|
1768
1944
|
preBuiltFilterSQL?: SQL;
|
|
1769
1945
|
}
|
|
1770
1946
|
|
|
1947
|
+
/**
|
|
1948
|
+
* Generic query schemas for AI agents
|
|
1949
|
+
* Teaches AI how to construct analysis queries
|
|
1950
|
+
*/
|
|
1951
|
+
declare const QUERY_SCHEMAS: {
|
|
1952
|
+
readonly funnel: {
|
|
1953
|
+
readonly description: "Track conversion through sequential steps. Entities (identified by bindingKey) move through ordered steps.";
|
|
1954
|
+
readonly structure: {
|
|
1955
|
+
readonly funnel: {
|
|
1956
|
+
readonly bindingKey: "Cube.dimension - identifies entities moving through funnel";
|
|
1957
|
+
readonly timeDimension: "Cube.dimension - time field for ordering events";
|
|
1958
|
+
readonly steps: readonly [{
|
|
1959
|
+
readonly name: "string - human readable step name";
|
|
1960
|
+
readonly filter: {
|
|
1961
|
+
readonly member: "Cube.dimension";
|
|
1962
|
+
readonly operator: "equals | notEquals | contains | ...";
|
|
1963
|
+
readonly values: readonly ["array of filter values"];
|
|
1964
|
+
};
|
|
1965
|
+
readonly timeToConvert: "optional - max time window e.g. \"7 days\"";
|
|
1966
|
+
}];
|
|
1967
|
+
readonly dateRange: "[start, end] array OR string like \"last 7 days\", \"last 3 months\", \"this quarter\"";
|
|
1968
|
+
};
|
|
1969
|
+
};
|
|
1970
|
+
};
|
|
1971
|
+
readonly flow: {
|
|
1972
|
+
readonly description: "Analyze paths users take before/after a specific event. Shows event sequences.";
|
|
1973
|
+
readonly structure: {
|
|
1974
|
+
readonly flow: {
|
|
1975
|
+
readonly bindingKey: "Cube.dimension - identifies entities";
|
|
1976
|
+
readonly timeDimension: "Cube.dimension - time field for ordering";
|
|
1977
|
+
readonly eventDimension: "Cube.dimension - the event type field";
|
|
1978
|
+
readonly startingStep: {
|
|
1979
|
+
readonly filter: {
|
|
1980
|
+
readonly member: "Cube.dimension";
|
|
1981
|
+
readonly operator: "equals";
|
|
1982
|
+
readonly values: readonly ["event value"];
|
|
1983
|
+
};
|
|
1984
|
+
};
|
|
1985
|
+
readonly stepsBefore: "number - how many steps to show before starting step";
|
|
1986
|
+
readonly stepsAfter: "number - how many steps to show after starting step";
|
|
1987
|
+
readonly dateRange: "[start, end] array OR string like \"last 7 days\", \"last 3 months\", \"this quarter\"";
|
|
1988
|
+
};
|
|
1989
|
+
};
|
|
1990
|
+
};
|
|
1991
|
+
readonly retention: {
|
|
1992
|
+
readonly description: "Measure how many users return over time periods after initial activity.";
|
|
1993
|
+
readonly structure: {
|
|
1994
|
+
readonly retention: {
|
|
1995
|
+
readonly bindingKey: "Cube.dimension - identifies entities";
|
|
1996
|
+
readonly timeDimension: "Cube.dimension - time field for cohort assignment";
|
|
1997
|
+
readonly granularity: "day | week | month - period size";
|
|
1998
|
+
readonly periods: "number - how many periods to analyze";
|
|
1999
|
+
readonly dateRange: "[start, end] array OR string like \"last 7 days\", \"last 3 months\", \"this quarter\"";
|
|
2000
|
+
};
|
|
2001
|
+
};
|
|
2002
|
+
};
|
|
2003
|
+
};
|
|
2004
|
+
|
|
1771
2005
|
/**
|
|
1772
2006
|
* Any queryable relation that can be used in FROM/JOIN clauses
|
|
1773
2007
|
* Supports tables, views, subqueries, and raw SQL expressions
|
|
@@ -1947,6 +2181,7 @@ export declare class QueryExecutor {
|
|
|
1947
2181
|
private comparisonQueryBuilder;
|
|
1948
2182
|
private funnelQueryBuilder;
|
|
1949
2183
|
private flowQueryBuilder;
|
|
2184
|
+
private retentionQueryBuilder;
|
|
1950
2185
|
private cacheConfig?;
|
|
1951
2186
|
constructor(dbExecutor: DatabaseExecutor, cacheConfig?: CacheConfig);
|
|
1952
2187
|
/**
|
|
@@ -1985,6 +2220,15 @@ export declare class QueryExecutor {
|
|
|
1985
2220
|
* Produces Sankey diagram data (nodes and links)
|
|
1986
2221
|
*/
|
|
1987
2222
|
private executeFlowQuery;
|
|
2223
|
+
/**
|
|
2224
|
+
* Execute a retention query with caching support
|
|
2225
|
+
*/
|
|
2226
|
+
private executeRetentionQueryWithCache;
|
|
2227
|
+
/**
|
|
2228
|
+
* Execute a retention analysis query
|
|
2229
|
+
* Calculates cohort-based retention rates
|
|
2230
|
+
*/
|
|
2231
|
+
private executeRetentionQuery;
|
|
1988
2232
|
/**
|
|
1989
2233
|
* Standard query execution (non-comparison)
|
|
1990
2234
|
* This is the core execution logic extracted for use by comparison queries
|
|
@@ -2036,6 +2280,14 @@ export declare class QueryExecutor {
|
|
|
2036
2280
|
sql: string;
|
|
2037
2281
|
params?: any[];
|
|
2038
2282
|
}>;
|
|
2283
|
+
/**
|
|
2284
|
+
* Generate SQL for a retention query without execution (dry-run)
|
|
2285
|
+
* Returns the actual CTE-based SQL that would be executed
|
|
2286
|
+
*/
|
|
2287
|
+
dryRunRetention(cubes: Map<string, Cube>, query: SemanticQuery, securityContext: SecurityContext): Promise<{
|
|
2288
|
+
sql: string;
|
|
2289
|
+
params?: any[];
|
|
2290
|
+
}>;
|
|
2039
2291
|
/**
|
|
2040
2292
|
* Execute EXPLAIN on a query to get the execution plan
|
|
2041
2293
|
* Generates the SQL using the same secure path as execute/generateSQL,
|
|
@@ -2270,6 +2522,20 @@ export declare interface QueryResult {
|
|
|
2270
2522
|
};
|
|
2271
2523
|
}
|
|
2272
2524
|
|
|
2525
|
+
/**
|
|
2526
|
+
* Suggested query result
|
|
2527
|
+
*/
|
|
2528
|
+
export declare interface QuerySuggestion {
|
|
2529
|
+
query: Partial<SemanticQuery>;
|
|
2530
|
+
confidence: number;
|
|
2531
|
+
reasoning: string[];
|
|
2532
|
+
warnings?: string[];
|
|
2533
|
+
/** Detected analysis mode */
|
|
2534
|
+
analysisMode: 'query' | 'funnel' | 'flow' | 'retention';
|
|
2535
|
+
/** Next steps when mode != 'query' */
|
|
2536
|
+
nextSteps?: string[];
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2273
2539
|
/**
|
|
2274
2540
|
* Query structure summary
|
|
2275
2541
|
*/
|
|
@@ -2314,6 +2580,130 @@ declare type ResolvedMeasures = Map<string, () => SQL>;
|
|
|
2314
2580
|
*/
|
|
2315
2581
|
export declare function resolveSqlExpression(expr: AnyColumn | SQL | ((ctx: QueryContext) => AnyColumn | SQL), ctx: QueryContext): AnyColumn | SQL;
|
|
2316
2582
|
|
|
2583
|
+
/**
|
|
2584
|
+
* Binding key mapping for multi-cube retention
|
|
2585
|
+
* Maps the user/entity identifier across cohort and activity cubes
|
|
2586
|
+
*/
|
|
2587
|
+
export declare interface RetentionBindingKeyMapping {
|
|
2588
|
+
cube: string;
|
|
2589
|
+
dimension: string;
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
/**
|
|
2593
|
+
* Retention capabilities per database engine
|
|
2594
|
+
*/
|
|
2595
|
+
export declare interface RetentionCapabilities {
|
|
2596
|
+
/** Whether database supports DATE_TRUNC natively */
|
|
2597
|
+
supportsDateTrunc: boolean;
|
|
2598
|
+
/** Whether database supports DATE_DIFF with unit specification */
|
|
2599
|
+
supportsDateDiff: boolean;
|
|
2600
|
+
/** Whether database supports generate_series for period generation */
|
|
2601
|
+
supportsGenerateSeries: boolean;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
/**
|
|
2605
|
+
* Date range for cohort analysis
|
|
2606
|
+
*/
|
|
2607
|
+
export declare interface RetentionDateRange {
|
|
2608
|
+
/** Start date (inclusive), ISO 8601 format (YYYY-MM-DD) */
|
|
2609
|
+
start: string;
|
|
2610
|
+
/** End date (inclusive), ISO 8601 format (YYYY-MM-DD) */
|
|
2611
|
+
end: string;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
/**
|
|
2615
|
+
* Retention query configuration (Simplified Mixpanel-style format)
|
|
2616
|
+
*
|
|
2617
|
+
* Key simplifications from previous version:
|
|
2618
|
+
* - Single timeDimension for both cohort entry and activity
|
|
2619
|
+
* - Single granularity for viewing periods (no separate cohort/period granularity)
|
|
2620
|
+
* - Single cohort (date range defines the cohort) with optional breakdown
|
|
2621
|
+
*/
|
|
2622
|
+
export declare interface RetentionQueryConfig {
|
|
2623
|
+
/**
|
|
2624
|
+
* Single timestamp dimension for the analysis.
|
|
2625
|
+
* String for single-cube (e.g., 'Events.timestamp'),
|
|
2626
|
+
* Object for multi-cube with explicit cube reference.
|
|
2627
|
+
*/
|
|
2628
|
+
timeDimension: string | RetentionTimeDimensionMapping;
|
|
2629
|
+
/**
|
|
2630
|
+
* Binding key - dimension that links users across events.
|
|
2631
|
+
* This is typically a user ID or other entity identifier.
|
|
2632
|
+
* String for single-cube (e.g., 'Events.userId'),
|
|
2633
|
+
* Array for multi-cube with different column names per cube.
|
|
2634
|
+
*/
|
|
2635
|
+
bindingKey: string | RetentionBindingKeyMapping[];
|
|
2636
|
+
/**
|
|
2637
|
+
* Date range for cohort analysis (REQUIRED).
|
|
2638
|
+
* Users who first performed the cohort action within this range are included.
|
|
2639
|
+
*/
|
|
2640
|
+
dateRange: RetentionDateRange;
|
|
2641
|
+
/**
|
|
2642
|
+
* Granularity for viewing retention periods.
|
|
2643
|
+
* Determines how period_number is calculated (day/week/month).
|
|
2644
|
+
*/
|
|
2645
|
+
granularity: 'day' | 'week' | 'month';
|
|
2646
|
+
/**
|
|
2647
|
+
* Number of periods to calculate (e.g., 12 for 12 weeks).
|
|
2648
|
+
* Period 0 is always the cohort entry period.
|
|
2649
|
+
*/
|
|
2650
|
+
periods: number;
|
|
2651
|
+
/**
|
|
2652
|
+
* Retention type:
|
|
2653
|
+
* - 'classic': User returned exactly in period N (bounded)
|
|
2654
|
+
* - 'rolling': User returned in period N or any later period (unbounded)
|
|
2655
|
+
*/
|
|
2656
|
+
retentionType: 'classic' | 'rolling';
|
|
2657
|
+
/**
|
|
2658
|
+
* Optional filters on cohort entry events.
|
|
2659
|
+
* Applied when identifying which users enter the cohort.
|
|
2660
|
+
*/
|
|
2661
|
+
cohortFilters?: Filter | Filter[];
|
|
2662
|
+
/**
|
|
2663
|
+
* Optional filters on return activity events.
|
|
2664
|
+
* Applied when checking for user activity in each period.
|
|
2665
|
+
*/
|
|
2666
|
+
activityFilters?: Filter | Filter[];
|
|
2667
|
+
/**
|
|
2668
|
+
* Optional breakdown dimensions for segmenting the cohort.
|
|
2669
|
+
* When provided, retention is calculated per unique combination of breakdown values.
|
|
2670
|
+
* e.g., ["Events.country", "Events.plan"] to see retention by country and plan.
|
|
2671
|
+
*/
|
|
2672
|
+
breakdownDimensions?: string[];
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
/**
|
|
2676
|
+
* Single retention data point in the flat result format.
|
|
2677
|
+
* Results are returned as a flat array; client transforms to matrix if needed.
|
|
2678
|
+
*
|
|
2679
|
+
* Simplified format: no cohortPeriod since we use a single cohort model.
|
|
2680
|
+
* When breakdownDimensions are specified, results include breakdownValues.
|
|
2681
|
+
*/
|
|
2682
|
+
export declare interface RetentionResultRow {
|
|
2683
|
+
/** Period number (0 = cohort entry, 1 = first retention period, etc.) */
|
|
2684
|
+
period: number;
|
|
2685
|
+
/** Number of users in the cohort (or segment when breakdown is used) */
|
|
2686
|
+
cohortSize: number;
|
|
2687
|
+
/** Number of users retained in this period */
|
|
2688
|
+
retainedUsers: number;
|
|
2689
|
+
/** Retention rate as decimal (0-1), e.g., 0.45 for 45% */
|
|
2690
|
+
retentionRate: number;
|
|
2691
|
+
/**
|
|
2692
|
+
* Breakdown values when breakdownDimensions are specified.
|
|
2693
|
+
* Keyed by dimension name (e.g., { "Events.country": "US", "Events.plan": "pro" })
|
|
2694
|
+
*/
|
|
2695
|
+
breakdownValues?: Record<string, string | null>;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
/**
|
|
2699
|
+
* Time dimension mapping for multi-cube retention
|
|
2700
|
+
* Maps the timestamp field across different cubes
|
|
2701
|
+
*/
|
|
2702
|
+
export declare interface RetentionTimeDimensionMapping {
|
|
2703
|
+
cube: string;
|
|
2704
|
+
dimension: string;
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2317
2707
|
/**
|
|
2318
2708
|
* Security context passed to cube SQL functions
|
|
2319
2709
|
* Contains user/tenant-specific data for filtering
|
|
@@ -2433,6 +2823,14 @@ export declare class SemanticLayerCompiler {
|
|
|
2433
2823
|
sql: string;
|
|
2434
2824
|
params?: any[];
|
|
2435
2825
|
}>;
|
|
2826
|
+
/**
|
|
2827
|
+
* Generate SQL for a retention query without execution (dry-run)
|
|
2828
|
+
* Returns the CTE-based SQL that would be executed for retention analysis
|
|
2829
|
+
*/
|
|
2830
|
+
dryRunRetention(query: SemanticQuery, securityContext: SecurityContext): Promise<{
|
|
2831
|
+
sql: string;
|
|
2832
|
+
params?: any[];
|
|
2833
|
+
}>;
|
|
2436
2834
|
/**
|
|
2437
2835
|
* Execute EXPLAIN on a query to get the execution plan
|
|
2438
2836
|
* Uses the same secure path as execute/dryRun to generate SQL,
|
|
@@ -2557,6 +2955,30 @@ export declare interface SemanticQuery {
|
|
|
2557
2955
|
* ```
|
|
2558
2956
|
*/
|
|
2559
2957
|
flow?: FlowQueryConfig;
|
|
2958
|
+
/**
|
|
2959
|
+
* Retention analysis configuration for cohort-based retention tracking.
|
|
2960
|
+
* When specified, the query executes as a retention analysis instead of
|
|
2961
|
+
* standard measures/dimensions aggregation.
|
|
2962
|
+
*
|
|
2963
|
+
* Retention analysis tracks what percentage of users from each cohort
|
|
2964
|
+
* return in subsequent time periods.
|
|
2965
|
+
*
|
|
2966
|
+
* @example
|
|
2967
|
+
* ```typescript
|
|
2968
|
+
* {
|
|
2969
|
+
* retention: {
|
|
2970
|
+
* timeDimension: 'Events.timestamp',
|
|
2971
|
+
* bindingKey: 'Events.userId',
|
|
2972
|
+
* dateRange: { start: '2024-01-01', end: '2024-12-31' },
|
|
2973
|
+
* granularity: 'week',
|
|
2974
|
+
* periods: 12,
|
|
2975
|
+
* retentionType: 'classic',
|
|
2976
|
+
* breakdownDimensions: ['Events.country', 'Events.plan']
|
|
2977
|
+
* }
|
|
2978
|
+
* }
|
|
2979
|
+
* ```
|
|
2980
|
+
*/
|
|
2981
|
+
retention?: RetentionQueryConfig;
|
|
2560
2982
|
}
|
|
2561
2983
|
|
|
2562
2984
|
export { SQL }
|
|
@@ -2664,6 +3086,11 @@ export declare interface Step1Result {
|
|
|
2664
3086
|
*/
|
|
2665
3087
|
export declare const STEP2_SYSTEM_PROMPT = "Complete the data query using actual dimension values from the database.\n\nORIGINAL USER REQUEST: {USER_PROMPT}\n\nCUBE SCHEMA:\n{CUBE_SCHEMA}\n\nAVAILABLE DIMENSION VALUES (from the actual database):\n{DIMENSION_VALUES}\n\nComplete the query using ONLY the values listed above for any dimension filters.\nDo NOT invent or guess filter values - use exactly what's available.\nMatch user intent to the closest available values (e.g., if user says \"opened\" but only \"created\" exists, use \"created\").\n\nRESPONSE FORMAT (same as single-step):\n{\n \"query\": { /* Cube.js query OR funnel query with actual filter values */ },\n \"chartType\": \"line\"|\"bar\"|\"area\"|\"pie\"|\"scatter\"|\"bubble\"|\"table\"|\"funnel\",\n \"chartConfig\": {\n \"xAxis\": string[],\n \"yAxis\": string[],\n \"series\": string[],\n \"sizeField\": string,\n \"colorField\": string\n }\n}\n\nFUNNEL QUERY STRUCTURE (if queryType was \"funnel\"):\n{\n \"funnel\": {\n \"bindingKey\": \"PREvents.prNumber\",\n \"timeDimension\": \"PREvents.timestamp\",\n \"steps\": [\n {\n \"name\": \"Created\",\n \"filter\": [\n { \"member\": \"PREvents.eventType\", \"operator\": \"equals\", \"values\": [\"created\"] },\n { \"member\": \"PREvents.timestamp\", \"operator\": \"inDateRange\", \"values\": [\"last 6 months\"] }\n ]\n },\n {\n \"name\": \"Merged\",\n \"filter\": { \"member\": \"PREvents.eventType\", \"operator\": \"equals\", \"values\": [\"merged\"] }\n }\n ],\n \"includeTimeMetrics\": true\n }\n}\n\nCRITICAL FILTER FORMAT RULES:\n- filter MUST be a flat array of filter objects: [{ member, operator, values }, ...]\n- filter MUST NOT be nested arrays: NOT [[{ member, operator, values }]]\n- For a single filter, use object format: { \"member\": \"...\", \"operator\": \"...\", \"values\": [...] }\n- For multiple filters on step 0, use flat array: [{ filter1 }, { filter2 }] (NOT [[filter1, filter2]])\n- The time filter (inDateRange) goes ONLY on step 0's filter, not on other steps.\n\nReturn ONLY valid JSON - no explanations or markdown:";
|
|
2666
3088
|
|
|
3089
|
+
/**
|
|
3090
|
+
* Suggest a query based on natural language input
|
|
3091
|
+
*/
|
|
3092
|
+
export declare function suggestQuery(metadata: CubeMetadata[], naturalLanguage: string, targetCube?: string): QuerySuggestion;
|
|
3093
|
+
|
|
2667
3094
|
/**
|
|
2668
3095
|
* Complete system prompt template for single-step query generation.
|
|
2669
3096
|
*
|