@katerai/sdk 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/client.js.map +1 -1
  3. package/client.mjs.map +1 -1
  4. package/package.json +1 -1
  5. package/resources/v1/compiler/cache.d.mts +39 -0
  6. package/resources/v1/compiler/cache.d.mts.map +1 -0
  7. package/resources/v1/compiler/cache.d.ts +39 -0
  8. package/resources/v1/compiler/cache.d.ts.map +1 -0
  9. package/resources/v1/compiler/cache.js +18 -0
  10. package/resources/v1/compiler/cache.js.map +1 -0
  11. package/resources/v1/compiler/cache.mjs +14 -0
  12. package/resources/v1/compiler/cache.mjs.map +1 -0
  13. package/resources/v1/compiler/compiler.d.mts +1893 -0
  14. package/resources/v1/compiler/compiler.d.mts.map +1 -0
  15. package/resources/v1/compiler/compiler.d.ts +1893 -0
  16. package/resources/v1/compiler/compiler.d.ts.map +1 -0
  17. package/resources/v1/compiler/compiler.js +119 -0
  18. package/resources/v1/compiler/compiler.js.map +1 -0
  19. package/resources/v1/compiler/compiler.mjs +114 -0
  20. package/resources/v1/compiler/compiler.mjs.map +1 -0
  21. package/resources/v1/compiler/index.d.mts +3 -0
  22. package/resources/v1/compiler/index.d.mts.map +1 -0
  23. package/resources/v1/compiler/index.d.ts +3 -0
  24. package/resources/v1/compiler/index.d.ts.map +1 -0
  25. package/resources/v1/compiler/index.js +9 -0
  26. package/resources/v1/compiler/index.js.map +1 -0
  27. package/resources/v1/compiler/index.mjs +4 -0
  28. package/resources/v1/compiler/index.mjs.map +1 -0
  29. package/resources/v1/compiler.d.mts +1 -1115
  30. package/resources/v1/compiler.d.mts.map +1 -1
  31. package/resources/v1/compiler.d.ts +1 -1115
  32. package/resources/v1/compiler.d.ts.map +1 -1
  33. package/resources/v1/compiler.js +2 -66
  34. package/resources/v1/compiler.js.map +1 -1
  35. package/resources/v1/compiler.mjs +1 -64
  36. package/resources/v1/compiler.mjs.map +1 -1
  37. package/resources/v1/index.d.mts +1 -1
  38. package/resources/v1/index.d.mts.map +1 -1
  39. package/resources/v1/index.d.ts +1 -1
  40. package/resources/v1/index.d.ts.map +1 -1
  41. package/resources/v1/index.js +4 -4
  42. package/resources/v1/index.js.map +1 -1
  43. package/resources/v1/index.mjs +1 -1
  44. package/resources/v1/index.mjs.map +1 -1
  45. package/resources/v1/v1.d.mts +3 -3
  46. package/resources/v1/v1.d.mts.map +1 -1
  47. package/resources/v1/v1.d.ts +3 -3
  48. package/resources/v1/v1.d.ts.map +1 -1
  49. package/resources/v1/v1.js +2 -2
  50. package/resources/v1/v1.js.map +1 -1
  51. package/resources/v1/v1.mjs +2 -2
  52. package/resources/v1/v1.mjs.map +1 -1
  53. package/src/client.ts +1 -1
  54. package/src/resources/v1/compiler/cache.ts +51 -0
  55. package/src/resources/v1/compiler/compiler.ts +2548 -0
  56. package/src/resources/v1/compiler/index.ts +23 -0
  57. package/src/resources/v1/compiler.ts +1 -1482
  58. package/src/resources/v1/index.ts +5 -1
  59. package/src/resources/v1/v1.ts +17 -9
  60. package/src/version.ts +1 -1
  61. package/version.d.mts +1 -1
  62. package/version.d.mts.map +1 -1
  63. package/version.d.ts +1 -1
  64. package/version.d.ts.map +1 -1
  65. package/version.js +1 -1
  66. package/version.js.map +1 -1
  67. package/version.mjs +1 -1
  68. package/version.mjs.map +1 -1
@@ -0,0 +1,1893 @@
1
+ import { APIResource } from "../../../core/resource.mjs";
2
+ import * as CompilerAPI from "./compiler.mjs";
3
+ import * as CacheAPI from "./cache.mjs";
4
+ import { Cache, CacheInvalidateParams, CacheInvalidateResponse } from "./cache.mjs";
5
+ import { APIPromise } from "../../../core/api-promise.mjs";
6
+ import { RequestOptions } from "../../../internal/request-options.mjs";
7
+ export declare class Compiler extends APIResource {
8
+ cache: CacheAPI.Cache;
9
+ /**
10
+ * Compile a resolved query to SQL.
11
+ *
12
+ * Takes a previously resolved query and generates the final SQL statement for the
13
+ * target dialect.
14
+ *
15
+ * RLS: Filtered to current client (ClientRLSDB).
16
+ */
17
+ compile(params: CompilerCompileParams, options?: RequestOptions): APIPromise<CompilerCompileResponse>;
18
+ /**
19
+ * Enumerate every valid query configuration for a connection.
20
+ *
21
+ * Generates all valid combinations of optional dimensions, measures, calculations,
22
+ * filters, and variable values, constrained by widget category rules.
23
+ *
24
+ * RLS: Filtered to current client (ClientRLSDB).
25
+ */
26
+ enumerate(params: CompilerEnumerateParams, options?: RequestOptions): APIPromise<CompilerEnumerateResponse>;
27
+ /**
28
+ * Execute a query with transparent caching.
29
+ *
30
+ * Compiles the resolved query to SQL, checks the cache for existing results,
31
+ * executes against the warehouse on cache miss, and stores the result for future
32
+ * requests. Cache failures are invisible to the caller.
33
+ *
34
+ * RLS: Filtered to current client (ClientRLSDB).
35
+ */
36
+ execute(params: CompilerExecuteParams, options?: RequestOptions): APIPromise<CompilerExecuteResponse>;
37
+ /**
38
+ * Resolve a query template with user-selected parameters.
39
+ *
40
+ * Takes a query reference and variable selections, returns the fully resolved
41
+ * query object ready for compilation.
42
+ *
43
+ * RLS: Filtered to current client (ClientRLSDB).
44
+ */
45
+ resolve(params: CompilerResolveParams, options?: RequestOptions): APIPromise<CompilerResolveResponse>;
46
+ /**
47
+ * Validate a schema file set against a connection.
48
+ *
49
+ * Checks all views, queries, and related schemas for correctness and returns any
50
+ * errors or warnings found.
51
+ *
52
+ * RLS: Filtered to current client (ClientRLSDB).
53
+ */
54
+ validate(params: CompilerValidateParams, options?: RequestOptions): APIPromise<CompilerValidateResponse>;
55
+ }
56
+ /**
57
+ * Chart configuration with variable references
58
+ */
59
+ export interface ChartConfig {
60
+ /**
61
+ * Field or variable reference for color grouping
62
+ */
63
+ color_by?: string | null;
64
+ /**
65
+ * Comparison mode for single_value widgets (e.g., previous_period, target)
66
+ */
67
+ comparison?: 'previous_period' | 'target' | null;
68
+ /**
69
+ * Field or variable reference for size
70
+ */
71
+ size?: string | null;
72
+ /**
73
+ * Field or variable reference for stacking
74
+ */
75
+ stack_by?: string | null;
76
+ /**
77
+ * Target value for comparison: target mode
78
+ */
79
+ target_value?: string | null;
80
+ /**
81
+ * Field or variable reference for x-axis
82
+ */
83
+ x_axis?: string | null;
84
+ /**
85
+ * Field or variable reference for y-axis
86
+ */
87
+ y_axis?: string | null;
88
+ }
89
+ /**
90
+ * A single compiler validation or compilation error.
91
+ */
92
+ export interface CompilerErrorItem {
93
+ /**
94
+ * Machine-readable error code
95
+ */
96
+ code: string;
97
+ /**
98
+ * Human-readable error description
99
+ */
100
+ message: string;
101
+ /**
102
+ * Column number in the source file
103
+ */
104
+ column?: number | null;
105
+ /**
106
+ * Source file path where the error occurred
107
+ */
108
+ file?: string | null;
109
+ /**
110
+ * Line number in the source file
111
+ */
112
+ line?: number | null;
113
+ /**
114
+ * Reference to the source element (e.g. view or query name)
115
+ */
116
+ ref?: string | null;
117
+ /**
118
+ * Suggested fix for this error
119
+ */
120
+ remediation?: string | null;
121
+ }
122
+ /**
123
+ * An inline field definition for dimensions/measures/calculations
124
+ */
125
+ export interface InlineField {
126
+ /**
127
+ * Unique identifier for this inline field
128
+ */
129
+ kater_id: string;
130
+ /**
131
+ * Name of the inline field
132
+ */
133
+ name: string;
134
+ /**
135
+ * SQL expression for the field
136
+ */
137
+ sql: string;
138
+ /**
139
+ * Human-readable label
140
+ */
141
+ label?: string | null;
142
+ }
143
+ /**
144
+ * Compilation manifest with all named objects.
145
+ */
146
+ export interface Manifest {
147
+ generated_at: string;
148
+ objects: {
149
+ [key: string]: ManifestEntry;
150
+ };
151
+ schema_version?: string;
152
+ }
153
+ /**
154
+ * A single object entry in the manifest.
155
+ */
156
+ export interface ManifestEntry {
157
+ kater_id: string;
158
+ name: string;
159
+ type: string;
160
+ label?: string | null;
161
+ parent_id?: string | null;
162
+ source_file?: string | null;
163
+ }
164
+ /**
165
+ * A reference with optional label override
166
+ */
167
+ export interface RefWithLabel {
168
+ /**
169
+ * Reference using ref(), var(), or expr() syntax
170
+ */
171
+ ref: string;
172
+ /**
173
+ * Optional label override for this reference
174
+ */
175
+ label?: string | null;
176
+ }
177
+ /**
178
+ * A subquery condition for EXISTS/NOT EXISTS filters
179
+ */
180
+ export interface SubqueryCondition {
181
+ /**
182
+ * Reference to the source view/table for the subquery
183
+ */
184
+ from: string;
185
+ /**
186
+ * WHERE conditions for the subquery
187
+ */
188
+ where: Array<string>;
189
+ }
190
+ /**
191
+ * Response model for SQL compilation.
192
+ */
193
+ export interface CompilerCompileResponse {
194
+ /**
195
+ * SQL dialect used (e.g. 'snowflake')
196
+ */
197
+ dialect: string;
198
+ /**
199
+ * Whether compilation succeeded
200
+ */
201
+ success: boolean;
202
+ /**
203
+ * Maps UUID column aliases to human-readable names and types
204
+ */
205
+ column_map?: Array<CompilerCompileResponse.ColumnMap>;
206
+ /**
207
+ * Compilation errors
208
+ */
209
+ errors?: Array<CompilerErrorItem>;
210
+ /**
211
+ * Compilation manifest with all named objects.
212
+ */
213
+ manifest?: Manifest | null;
214
+ /**
215
+ * Compilation metadata from the compiler.
216
+ */
217
+ metadata?: CompilerCompileResponse.Metadata | null;
218
+ /**
219
+ * Generated SQL statement
220
+ */
221
+ sql?: string | null;
222
+ }
223
+ export declare namespace CompilerCompileResponse {
224
+ /**
225
+ * Maps a UUID column alias to its human-readable name and type.
226
+ */
227
+ interface ColumnMap {
228
+ /**
229
+ * Field type: dimension, measure, or calculation
230
+ */
231
+ field_type: string;
232
+ /**
233
+ * UUID string used as SQL column alias
234
+ */
235
+ kater_id: string;
236
+ /**
237
+ * Human-readable column name
238
+ */
239
+ name: string;
240
+ /**
241
+ * Aggregation type for measures: sum, count, min, max, avg, unknown. None for
242
+ * non-measures.
243
+ */
244
+ aggregation?: string | null;
245
+ /**
246
+ * Display label
247
+ */
248
+ label?: string | null;
249
+ }
250
+ /**
251
+ * Compilation metadata from the compiler.
252
+ */
253
+ interface Metadata {
254
+ /**
255
+ * SQL dialect used (e.g. 'snowflake')
256
+ */
257
+ dialect: string;
258
+ /**
259
+ * Reference to the compiled query
260
+ */
261
+ query_ref: string;
262
+ /**
263
+ * Dimension names used in compilation
264
+ */
265
+ dimensions_used?: Array<string>;
266
+ /**
267
+ * Filter names used in compilation
268
+ */
269
+ filters_used?: Array<string>;
270
+ /**
271
+ * Measure names used in compilation
272
+ */
273
+ measures_used?: Array<string>;
274
+ /**
275
+ * View names used in compilation
276
+ */
277
+ views_used?: Array<string>;
278
+ }
279
+ }
280
+ /**
281
+ * Response model for query combination enumeration.
282
+ */
283
+ export interface CompilerEnumerateResponse {
284
+ /**
285
+ * All valid query configurations
286
+ */
287
+ combinations: Array<CompilerEnumerateResponse.Combination>;
288
+ /**
289
+ * Total number of combinations
290
+ */
291
+ total_count: number;
292
+ }
293
+ export declare namespace CompilerEnumerateResponse {
294
+ /**
295
+ * A single valid query configuration.
296
+ */
297
+ interface Combination {
298
+ /**
299
+ * Query template reference (e.g. 'q:COMPLIANCE_OVERVIEW')
300
+ */
301
+ query_ref: string;
302
+ /**
303
+ * Widget category (e.g. 'axis', 'table')
304
+ */
305
+ widget_category: string;
306
+ /**
307
+ * Human-readable label for the query
308
+ */
309
+ query_label?: string | null;
310
+ /**
311
+ * Selected optional calculation names
312
+ */
313
+ selected_calculations?: Array<string>;
314
+ /**
315
+ * Selected optional dimension names
316
+ */
317
+ selected_dimensions?: Array<string>;
318
+ /**
319
+ * Selected optional filter names
320
+ */
321
+ selected_filters?: Array<string>;
322
+ /**
323
+ * Selected optional measure names
324
+ */
325
+ selected_measures?: Array<string>;
326
+ /**
327
+ * Variable name to value assignments
328
+ */
329
+ variable_assignments?: {
330
+ [key: string]: unknown;
331
+ };
332
+ }
333
+ }
334
+ /**
335
+ * Response model for query execution.
336
+ */
337
+ export interface CompilerExecuteResponse {
338
+ /**
339
+ * SQL dialect used
340
+ */
341
+ dialect: string;
342
+ /**
343
+ * Whether execution succeeded
344
+ */
345
+ success: boolean;
346
+ /**
347
+ * Whether the result was served from cache
348
+ */
349
+ cache_hit?: boolean;
350
+ /**
351
+ * Maps UUID column aliases to human-readable names
352
+ */
353
+ column_map?: Array<CompilerExecuteResponse.ColumnMap>;
354
+ /**
355
+ * Query result rows as list of column-value dicts
356
+ */
357
+ data?: Array<{
358
+ [key: string]: unknown;
359
+ }>;
360
+ /**
361
+ * Compilation errors (if any)
362
+ */
363
+ errors?: Array<CompilerErrorItem>;
364
+ /**
365
+ * Total execution time in milliseconds
366
+ */
367
+ execution_time_ms?: number;
368
+ /**
369
+ * Compilation metadata from the compiler.
370
+ */
371
+ metadata?: CompilerExecuteResponse.Metadata | null;
372
+ /**
373
+ * Number of rows returned
374
+ */
375
+ row_count?: number;
376
+ /**
377
+ * Generated SQL statement
378
+ */
379
+ sql?: string | null;
380
+ }
381
+ export declare namespace CompilerExecuteResponse {
382
+ /**
383
+ * Maps a UUID column alias to its human-readable name and type.
384
+ */
385
+ interface ColumnMap {
386
+ /**
387
+ * Field type: dimension, measure, or calculation
388
+ */
389
+ field_type: string;
390
+ /**
391
+ * UUID string used as SQL column alias
392
+ */
393
+ kater_id: string;
394
+ /**
395
+ * Human-readable column name
396
+ */
397
+ name: string;
398
+ /**
399
+ * Aggregation type for measures: sum, count, min, max, avg, unknown. None for
400
+ * non-measures.
401
+ */
402
+ aggregation?: string | null;
403
+ /**
404
+ * Display label
405
+ */
406
+ label?: string | null;
407
+ }
408
+ /**
409
+ * Compilation metadata from the compiler.
410
+ */
411
+ interface Metadata {
412
+ /**
413
+ * SQL dialect used (e.g. 'snowflake')
414
+ */
415
+ dialect: string;
416
+ /**
417
+ * Reference to the compiled query
418
+ */
419
+ query_ref: string;
420
+ /**
421
+ * Dimension names used in compilation
422
+ */
423
+ dimensions_used?: Array<string>;
424
+ /**
425
+ * Filter names used in compilation
426
+ */
427
+ filters_used?: Array<string>;
428
+ /**
429
+ * Measure names used in compilation
430
+ */
431
+ measures_used?: Array<string>;
432
+ /**
433
+ * View names used in compilation
434
+ */
435
+ views_used?: Array<string>;
436
+ }
437
+ }
438
+ /**
439
+ * Response model for a resolved query.
440
+ */
441
+ export interface CompilerResolveResponse {
442
+ /**
443
+ * The fully resolved query object
444
+ */
445
+ resolved_query: CompilerResolveResponse.ResolvedQuery;
446
+ /**
447
+ * Dependency graph between schema objects.
448
+ */
449
+ dependency_graph?: CompilerResolveResponse.DependencyGraph | null;
450
+ /**
451
+ * Compilation manifest with all named objects.
452
+ */
453
+ manifest?: Manifest | null;
454
+ }
455
+ export declare namespace CompilerResolveResponse {
456
+ /**
457
+ * The fully resolved query object
458
+ */
459
+ interface ResolvedQuery {
460
+ /**
461
+ * Unique identifier for this resolved query instance
462
+ */
463
+ kater_id: string;
464
+ /**
465
+ * Name from the leaf query in the inheritance chain
466
+ */
467
+ name: string;
468
+ /**
469
+ * Reference to the original query template this was resolved from
470
+ */
471
+ source_query: string;
472
+ /**
473
+ * Reference to the topic this query uses (always known after inheritance
474
+ * resolution)
475
+ */
476
+ topic: string;
477
+ /**
478
+ * Widget category that determines data shape constraints
479
+ */
480
+ widget_category: 'axis' | 'pie' | 'single_value' | 'heatmap' | 'table' | 'static';
481
+ /**
482
+ * Usage guidance for AI processing
483
+ */
484
+ ai_context?: string | null;
485
+ /**
486
+ * Merged required + selected optional calculations
487
+ */
488
+ calculations?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
489
+ /**
490
+ * Chart recommendations preserved for evaluation
491
+ */
492
+ chart_hints?: Array<ResolvedQuery.ChartHint1Output | ResolvedQuery.ChartHint2Output> | null;
493
+ /**
494
+ * Custom properties
495
+ */
496
+ custom_properties?: {
497
+ [key: string]: unknown;
498
+ } | null;
499
+ /**
500
+ * Description of the query
501
+ */
502
+ description?: string | null;
503
+ /**
504
+ * Merged required + selected optional dimensions
505
+ */
506
+ dimensions?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
507
+ /**
508
+ * Widget types within the declared widget_category that must NOT render this query
509
+ */
510
+ disallowed_widget_types?: Array<'kpi_card' | 'line_chart' | 'bar_chart' | 'pie_chart' | 'donut_chart' | 'area_chart' | 'scatter_chart' | 'data_table' | 'card_grid' | 'heatmap' | 'gauge' | 'text' | 'image' | 'styled_table' | 'stat_cards' | 'key_value_list'> | null;
511
+ /**
512
+ * Merged required + selected optional filters
513
+ */
514
+ filters?: Array<ResolvedQuery.InlineFieldFilter | string | ResolvedQuery.InlineExistsFilter1 | ResolvedQuery.InlineExistsFilter2> | null;
515
+ /**
516
+ * Ordered list of query refs that were merged during inheritance resolution
517
+ */
518
+ inheritance_chain?: Array<string> | null;
519
+ /**
520
+ * Human-readable label with var() values substituted
521
+ */
522
+ label?: string | null;
523
+ /**
524
+ * Maximum number of rows to return
525
+ */
526
+ limit?: number | null;
527
+ /**
528
+ * Merged required + selected optional measures
529
+ */
530
+ measures?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
531
+ /**
532
+ * Sort order specification for query results. Use desc for descending
533
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
534
+ */
535
+ order_by?: ResolvedQuery.OrderBy | null;
536
+ /**
537
+ * Access grants required to use this query
538
+ */
539
+ required_access_grants?: Array<string> | null;
540
+ /**
541
+ * The matched chart recommendation after evaluating chart hints
542
+ */
543
+ resolved_chart?: ResolvedQuery.ResolvedChart | null;
544
+ /**
545
+ * Full variable definitions with bound values
546
+ */
547
+ resolved_variables?: Array<ResolvedQuery.ResolvedVariable> | null;
548
+ /**
549
+ * Resolved select_from entries with CTE metadata
550
+ */
551
+ select_from?: Array<ResolvedQuery.SelectFrom> | null;
552
+ }
553
+ namespace ResolvedQuery {
554
+ /**
555
+ * A chart recommendation rule
556
+ */
557
+ interface ChartHint1Output {
558
+ /**
559
+ * Chart configuration with variable references
560
+ */
561
+ config: CompilerAPI.ChartConfig;
562
+ /**
563
+ * Type of chart visualization
564
+ */
565
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
566
+ /**
567
+ * Conditions based on variable values - can be single value (string) or multiple
568
+ * values (array)
569
+ */
570
+ when: {
571
+ [key: string]: string | Array<string>;
572
+ };
573
+ }
574
+ /**
575
+ * A chart recommendation rule
576
+ */
577
+ interface ChartHint2Output {
578
+ default: ChartHint2Output.Default;
579
+ }
580
+ namespace ChartHint2Output {
581
+ interface Default {
582
+ /**
583
+ * Chart configuration with variable references
584
+ */
585
+ config: CompilerAPI.ChartConfig;
586
+ /**
587
+ * Type of chart visualization
588
+ */
589
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
590
+ }
591
+ }
592
+ /**
593
+ * An inline filter using field + operator + values
594
+ */
595
+ interface InlineFieldFilter {
596
+ /**
597
+ * Reference to the field to filter on
598
+ */
599
+ field: string;
600
+ /**
601
+ * Name of the inline filter
602
+ */
603
+ name: string;
604
+ /**
605
+ * Filter operator to apply
606
+ */
607
+ operator: 'equals' | 'not_equals' | 'in' | 'not_in' | 'greater_than' | 'less_than' | 'greater_than_or_equals' | 'less_than_or_equals' | 'between' | 'in_the_last' | 'in_the_next' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'is_null' | 'is_not_null';
608
+ /**
609
+ * SQL expression for the filter value
610
+ */
611
+ sql_value?: string | null;
612
+ /**
613
+ * Fixed values for the filter
614
+ */
615
+ static_values?: Array<string | number | boolean> | null;
616
+ }
617
+ /**
618
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
619
+ */
620
+ interface InlineExistsFilter1 {
621
+ /**
622
+ * EXISTS subquery condition
623
+ */
624
+ exists: CompilerAPI.SubqueryCondition;
625
+ /**
626
+ * Name of the inline filter
627
+ */
628
+ name: string;
629
+ /**
630
+ * Description of the filter
631
+ */
632
+ description?: string | null;
633
+ /**
634
+ * Human-readable label
635
+ */
636
+ label?: string | null;
637
+ /**
638
+ * A subquery condition for EXISTS/NOT EXISTS filters
639
+ */
640
+ not_exists?: CompilerAPI.SubqueryCondition | null;
641
+ }
642
+ /**
643
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
644
+ */
645
+ interface InlineExistsFilter2 {
646
+ /**
647
+ * Name of the inline filter
648
+ */
649
+ name: string;
650
+ /**
651
+ * NOT EXISTS subquery condition
652
+ */
653
+ not_exists: CompilerAPI.SubqueryCondition;
654
+ /**
655
+ * Description of the filter
656
+ */
657
+ description?: string | null;
658
+ /**
659
+ * A subquery condition for EXISTS/NOT EXISTS filters
660
+ */
661
+ exists?: CompilerAPI.SubqueryCondition | null;
662
+ /**
663
+ * Human-readable label
664
+ */
665
+ label?: string | null;
666
+ }
667
+ /**
668
+ * Sort order specification for query results. Use desc for descending
669
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
670
+ */
671
+ interface OrderBy {
672
+ /**
673
+ * Fields to sort in ascending order (lowest/oldest first)
674
+ */
675
+ asc?: Array<string> | null;
676
+ /**
677
+ * Fields to sort in descending order (highest/newest first)
678
+ */
679
+ desc?: Array<string> | null;
680
+ }
681
+ /**
682
+ * The matched chart recommendation after evaluating chart hints
683
+ */
684
+ interface ResolvedChart {
685
+ /**
686
+ * Chart configuration
687
+ */
688
+ config: CompilerAPI.ChartConfig;
689
+ /**
690
+ * Recommended chart type
691
+ */
692
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
693
+ }
694
+ /**
695
+ * A variable definition with its bound value
696
+ */
697
+ interface ResolvedVariable {
698
+ /**
699
+ * The concrete value bound for this resolution
700
+ */
701
+ bound_value: string | number | boolean;
702
+ /**
703
+ * Default value for this variable
704
+ */
705
+ default: string | number | boolean;
706
+ /**
707
+ * Variable name identifier
708
+ */
709
+ name: string;
710
+ /**
711
+ * Data type of the variable
712
+ */
713
+ type: 'STRING' | 'INT' | 'FLOAT' | 'DATE' | 'TIMESTAMP' | 'BOOL' | 'DIMENSION' | 'MEASURE' | 'CALCULATION' | 'FILTER';
714
+ /**
715
+ * Allowed values configuration
716
+ */
717
+ allowed_values?: ResolvedVariable.VariableAllowedValues1 | ResolvedVariable.VariableAllowedValues2 | null;
718
+ /**
719
+ * Constraints for variable types
720
+ */
721
+ constraints?: ResolvedVariable.Constraints | null;
722
+ /**
723
+ * Description of the variable's purpose
724
+ */
725
+ description?: string | null;
726
+ /**
727
+ * True if bound_value equals the default value
728
+ */
729
+ is_default?: boolean | null;
730
+ /**
731
+ * Human-readable label for the variable
732
+ */
733
+ label?: string | null;
734
+ }
735
+ namespace ResolvedVariable {
736
+ /**
737
+ * Allowed values for a variable - either static list or from column
738
+ */
739
+ interface VariableAllowedValues1 {
740
+ /**
741
+ * Static list of allowed values with optional labels
742
+ */
743
+ static: Array<VariableAllowedValues1.Static>;
744
+ }
745
+ namespace VariableAllowedValues1 {
746
+ /**
747
+ * A value with optional display label
748
+ */
749
+ interface Static {
750
+ /**
751
+ * The actual value
752
+ */
753
+ value: string | number | boolean;
754
+ /**
755
+ * Human-readable label for the value
756
+ */
757
+ label?: string | null;
758
+ }
759
+ }
760
+ /**
761
+ * Allowed values for a variable - either static list or from column
762
+ */
763
+ interface VariableAllowedValues2 {
764
+ /**
765
+ * Reference to column for dynamic values
766
+ */
767
+ from_column: string;
768
+ /**
769
+ * Cache time-to-live in seconds
770
+ */
771
+ cache_ttl?: number;
772
+ /**
773
+ * Maximum number of values to retrieve
774
+ */
775
+ limit?: number;
776
+ /**
777
+ * Sort order for values
778
+ */
779
+ order_by?: 'asc' | 'desc';
780
+ }
781
+ /**
782
+ * Constraints for variable types
783
+ */
784
+ interface Constraints {
785
+ /**
786
+ * Maximum allowed value
787
+ */
788
+ max?: number | null;
789
+ /**
790
+ * Maximum length for STRING variables
791
+ */
792
+ max_length?: number | null;
793
+ /**
794
+ * Minimum allowed value
795
+ */
796
+ min?: number | null;
797
+ /**
798
+ * Step increment for numeric input
799
+ */
800
+ step?: number | null;
801
+ }
802
+ }
803
+ /**
804
+ * A resolved select_from entry with CTE metadata
805
+ */
806
+ interface SelectFrom {
807
+ /**
808
+ * CTE alias used in the WITH clause (e.g., **sf_compliance_rate**base)
809
+ */
810
+ cte_alias: string;
811
+ /**
812
+ * Columns produced by the CTE, available as q:query_name.field_name in the parent
813
+ */
814
+ output_columns: Array<SelectFrom.OutputColumn>;
815
+ /**
816
+ * Reference to the source query
817
+ */
818
+ ref: string;
819
+ /**
820
+ * Variable overrides passed to the referenced query
821
+ */
822
+ variables?: {
823
+ [key: string]: string | number | boolean;
824
+ } | null;
825
+ }
826
+ namespace SelectFrom {
827
+ /**
828
+ * A column produced by a select_from CTE
829
+ */
830
+ interface OutputColumn {
831
+ /**
832
+ * The SQL column alias in the CTE output
833
+ */
834
+ column_alias: string;
835
+ /**
836
+ * The field name used in q:query_name.field_name references
837
+ */
838
+ field_name: string;
839
+ /**
840
+ * Original type of the field in the source query
841
+ */
842
+ source_type: 'dimension' | 'measure' | 'calculation';
843
+ }
844
+ }
845
+ }
846
+ /**
847
+ * Dependency graph between schema objects.
848
+ */
849
+ interface DependencyGraph {
850
+ /**
851
+ * Edge relationships with UUID string keys
852
+ */
853
+ edges: {
854
+ [key: string]: {
855
+ [key: string]: Array<string>;
856
+ };
857
+ };
858
+ /**
859
+ * UUID string to node mapping
860
+ */
861
+ nodes: {
862
+ [key: string]: DependencyGraph.Nodes;
863
+ };
864
+ }
865
+ namespace DependencyGraph {
866
+ /**
867
+ * A node in the dependency graph.
868
+ */
869
+ interface Nodes {
870
+ /**
871
+ * Source file path
872
+ */
873
+ file: string;
874
+ /**
875
+ * Fully qualified name (e.g. 'dim_customer.region')
876
+ */
877
+ fqn: string;
878
+ /**
879
+ * UUID of the schema object
880
+ */
881
+ kater_id: string;
882
+ /**
883
+ * Line number in source file
884
+ */
885
+ line: number;
886
+ /**
887
+ * Node type: QUERY, VIEW, DIMENSION, MEASURE, FILTER, EXPRESSION
888
+ */
889
+ node_type: string;
890
+ /**
891
+ * Column number in source file
892
+ */
893
+ column?: number;
894
+ }
895
+ }
896
+ }
897
+ /**
898
+ * Response model for schema validation.
899
+ */
900
+ export interface CompilerValidateResponse {
901
+ /**
902
+ * Whether validation passed without errors
903
+ */
904
+ success: boolean;
905
+ /**
906
+ * Per-connection validation results with dependency graphs
907
+ */
908
+ connection_results?: Array<CompilerValidateResponse.ConnectionResult>;
909
+ /**
910
+ * Validation errors
911
+ */
912
+ errors?: Array<CompilerErrorItem>;
913
+ /**
914
+ * Validation warnings
915
+ */
916
+ warnings?: Array<CompilerErrorItem>;
917
+ }
918
+ export declare namespace CompilerValidateResponse {
919
+ /**
920
+ * Validation result for a single connection.
921
+ */
922
+ interface ConnectionResult {
923
+ /**
924
+ * Connection UUID
925
+ */
926
+ connection_id: string;
927
+ /**
928
+ * Connection name
929
+ */
930
+ connection_name: string;
931
+ /**
932
+ * Whether this connection validated without errors
933
+ */
934
+ success: boolean;
935
+ /**
936
+ * Dependency graph between schema objects.
937
+ */
938
+ dependency_graph?: ConnectionResult.DependencyGraph | null;
939
+ /**
940
+ * Validation errors for this connection
941
+ */
942
+ errors?: Array<CompilerAPI.CompilerErrorItem>;
943
+ /**
944
+ * Validation warnings for this connection
945
+ */
946
+ warnings?: Array<CompilerAPI.CompilerErrorItem>;
947
+ }
948
+ namespace ConnectionResult {
949
+ /**
950
+ * Dependency graph between schema objects.
951
+ */
952
+ interface DependencyGraph {
953
+ /**
954
+ * Edge relationships with UUID string keys
955
+ */
956
+ edges: {
957
+ [key: string]: {
958
+ [key: string]: Array<string>;
959
+ };
960
+ };
961
+ /**
962
+ * UUID string to node mapping
963
+ */
964
+ nodes: {
965
+ [key: string]: DependencyGraph.Nodes;
966
+ };
967
+ }
968
+ namespace DependencyGraph {
969
+ /**
970
+ * A node in the dependency graph.
971
+ */
972
+ interface Nodes {
973
+ /**
974
+ * Source file path
975
+ */
976
+ file: string;
977
+ /**
978
+ * Fully qualified name (e.g. 'dim_customer.region')
979
+ */
980
+ fqn: string;
981
+ /**
982
+ * UUID of the schema object
983
+ */
984
+ kater_id: string;
985
+ /**
986
+ * Line number in source file
987
+ */
988
+ line: number;
989
+ /**
990
+ * Node type: QUERY, VIEW, DIMENSION, MEASURE, FILTER, EXPRESSION
991
+ */
992
+ node_type: string;
993
+ /**
994
+ * Column number in source file
995
+ */
996
+ column?: number;
997
+ }
998
+ }
999
+ }
1000
+ }
1001
+ export interface CompilerCompileParams {
1002
+ /**
1003
+ * Body param: Connection to compile against
1004
+ */
1005
+ connection_id: string;
1006
+ /**
1007
+ * Body param: Previously resolved query object from /resolve
1008
+ */
1009
+ resolved_query: CompilerCompileParams.ResolvedQuery;
1010
+ /**
1011
+ * Query param
1012
+ */
1013
+ source?: string | null;
1014
+ /**
1015
+ * Body param: Tenant key for multi-tenant compilation. For database tenancy, maps
1016
+ * to the tenant's database. For row tenancy, used as the row-level filter value.
1017
+ */
1018
+ tenant_key?: string | null;
1019
+ /**
1020
+ * Header param
1021
+ */
1022
+ 'X-Kater-CLI-ID'?: string;
1023
+ }
1024
+ export declare namespace CompilerCompileParams {
1025
+ /**
1026
+ * Previously resolved query object from /resolve
1027
+ */
1028
+ interface ResolvedQuery {
1029
+ /**
1030
+ * Unique identifier for this resolved query instance
1031
+ */
1032
+ kater_id: string;
1033
+ /**
1034
+ * Name from the leaf query in the inheritance chain
1035
+ */
1036
+ name: string;
1037
+ /**
1038
+ * Reference to the original query template this was resolved from
1039
+ */
1040
+ source_query: string;
1041
+ /**
1042
+ * Reference to the topic this query uses (always known after inheritance
1043
+ * resolution)
1044
+ */
1045
+ topic: string;
1046
+ /**
1047
+ * Widget category that determines data shape constraints
1048
+ */
1049
+ widget_category: 'axis' | 'pie' | 'single_value' | 'heatmap' | 'table' | 'static';
1050
+ /**
1051
+ * Usage guidance for AI processing
1052
+ */
1053
+ ai_context?: string | null;
1054
+ /**
1055
+ * Merged required + selected optional calculations
1056
+ */
1057
+ calculations?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1058
+ /**
1059
+ * Chart recommendations preserved for evaluation
1060
+ */
1061
+ chart_hints?: Array<ResolvedQuery.ChartHint1Input | ResolvedQuery.ChartHint2Input> | null;
1062
+ /**
1063
+ * Custom properties
1064
+ */
1065
+ custom_properties?: {
1066
+ [key: string]: unknown;
1067
+ } | null;
1068
+ /**
1069
+ * Description of the query
1070
+ */
1071
+ description?: string | null;
1072
+ /**
1073
+ * Merged required + selected optional dimensions
1074
+ */
1075
+ dimensions?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1076
+ /**
1077
+ * Widget types within the declared widget_category that must NOT render this query
1078
+ */
1079
+ disallowed_widget_types?: Array<'kpi_card' | 'line_chart' | 'bar_chart' | 'pie_chart' | 'donut_chart' | 'area_chart' | 'scatter_chart' | 'data_table' | 'card_grid' | 'heatmap' | 'gauge' | 'text' | 'image' | 'styled_table' | 'stat_cards' | 'key_value_list'> | null;
1080
+ /**
1081
+ * Merged required + selected optional filters
1082
+ */
1083
+ filters?: Array<ResolvedQuery.InlineFieldFilter | string | ResolvedQuery.InlineExistsFilter1 | ResolvedQuery.InlineExistsFilter2> | null;
1084
+ /**
1085
+ * Ordered list of query refs that were merged during inheritance resolution
1086
+ */
1087
+ inheritance_chain?: Array<string> | null;
1088
+ /**
1089
+ * Human-readable label with var() values substituted
1090
+ */
1091
+ label?: string | null;
1092
+ /**
1093
+ * Maximum number of rows to return
1094
+ */
1095
+ limit?: number | null;
1096
+ /**
1097
+ * Merged required + selected optional measures
1098
+ */
1099
+ measures?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1100
+ /**
1101
+ * Sort order specification for query results. Use desc for descending
1102
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
1103
+ */
1104
+ order_by?: ResolvedQuery.OrderBy | null;
1105
+ /**
1106
+ * Access grants required to use this query
1107
+ */
1108
+ required_access_grants?: Array<string> | null;
1109
+ /**
1110
+ * The matched chart recommendation after evaluating chart hints
1111
+ */
1112
+ resolved_chart?: ResolvedQuery.ResolvedChart | null;
1113
+ /**
1114
+ * Full variable definitions with bound values
1115
+ */
1116
+ resolved_variables?: Array<ResolvedQuery.ResolvedVariable> | null;
1117
+ /**
1118
+ * Resolved select_from entries with CTE metadata
1119
+ */
1120
+ select_from?: Array<ResolvedQuery.SelectFrom> | null;
1121
+ }
1122
+ namespace ResolvedQuery {
1123
+ /**
1124
+ * A chart recommendation rule
1125
+ */
1126
+ interface ChartHint1Input {
1127
+ /**
1128
+ * Chart configuration with variable references
1129
+ */
1130
+ config: CompilerAPI.ChartConfig;
1131
+ /**
1132
+ * Type of chart visualization
1133
+ */
1134
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1135
+ /**
1136
+ * Conditions based on variable values - can be single value (string) or multiple
1137
+ * values (array)
1138
+ */
1139
+ when: {
1140
+ [key: string]: string | Array<string>;
1141
+ };
1142
+ }
1143
+ /**
1144
+ * A chart recommendation rule
1145
+ */
1146
+ interface ChartHint2Input {
1147
+ default: ChartHint2Input.Default;
1148
+ }
1149
+ namespace ChartHint2Input {
1150
+ interface Default {
1151
+ /**
1152
+ * Chart configuration with variable references
1153
+ */
1154
+ config: CompilerAPI.ChartConfig;
1155
+ /**
1156
+ * Type of chart visualization
1157
+ */
1158
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1159
+ }
1160
+ }
1161
+ /**
1162
+ * An inline filter using field + operator + values
1163
+ */
1164
+ interface InlineFieldFilter {
1165
+ /**
1166
+ * Reference to the field to filter on
1167
+ */
1168
+ field: string;
1169
+ /**
1170
+ * Name of the inline filter
1171
+ */
1172
+ name: string;
1173
+ /**
1174
+ * Filter operator to apply
1175
+ */
1176
+ operator: 'equals' | 'not_equals' | 'in' | 'not_in' | 'greater_than' | 'less_than' | 'greater_than_or_equals' | 'less_than_or_equals' | 'between' | 'in_the_last' | 'in_the_next' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'is_null' | 'is_not_null';
1177
+ /**
1178
+ * SQL expression for the filter value
1179
+ */
1180
+ sql_value?: string | null;
1181
+ /**
1182
+ * Fixed values for the filter
1183
+ */
1184
+ static_values?: Array<string | number | boolean> | null;
1185
+ }
1186
+ /**
1187
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
1188
+ */
1189
+ interface InlineExistsFilter1 {
1190
+ /**
1191
+ * EXISTS subquery condition
1192
+ */
1193
+ exists: CompilerAPI.SubqueryCondition;
1194
+ /**
1195
+ * Name of the inline filter
1196
+ */
1197
+ name: string;
1198
+ /**
1199
+ * Description of the filter
1200
+ */
1201
+ description?: string | null;
1202
+ /**
1203
+ * Human-readable label
1204
+ */
1205
+ label?: string | null;
1206
+ /**
1207
+ * A subquery condition for EXISTS/NOT EXISTS filters
1208
+ */
1209
+ not_exists?: CompilerAPI.SubqueryCondition | null;
1210
+ }
1211
+ /**
1212
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
1213
+ */
1214
+ interface InlineExistsFilter2 {
1215
+ /**
1216
+ * Name of the inline filter
1217
+ */
1218
+ name: string;
1219
+ /**
1220
+ * NOT EXISTS subquery condition
1221
+ */
1222
+ not_exists: CompilerAPI.SubqueryCondition;
1223
+ /**
1224
+ * Description of the filter
1225
+ */
1226
+ description?: string | null;
1227
+ /**
1228
+ * A subquery condition for EXISTS/NOT EXISTS filters
1229
+ */
1230
+ exists?: CompilerAPI.SubqueryCondition | null;
1231
+ /**
1232
+ * Human-readable label
1233
+ */
1234
+ label?: string | null;
1235
+ }
1236
+ /**
1237
+ * Sort order specification for query results. Use desc for descending
1238
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
1239
+ */
1240
+ interface OrderBy {
1241
+ /**
1242
+ * Fields to sort in ascending order (lowest/oldest first)
1243
+ */
1244
+ asc?: Array<string> | null;
1245
+ /**
1246
+ * Fields to sort in descending order (highest/newest first)
1247
+ */
1248
+ desc?: Array<string> | null;
1249
+ }
1250
+ /**
1251
+ * The matched chart recommendation after evaluating chart hints
1252
+ */
1253
+ interface ResolvedChart {
1254
+ /**
1255
+ * Chart configuration
1256
+ */
1257
+ config: CompilerAPI.ChartConfig;
1258
+ /**
1259
+ * Recommended chart type
1260
+ */
1261
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1262
+ }
1263
+ /**
1264
+ * A variable definition with its bound value
1265
+ */
1266
+ interface ResolvedVariable {
1267
+ /**
1268
+ * The concrete value bound for this resolution
1269
+ */
1270
+ bound_value: string | number | boolean;
1271
+ /**
1272
+ * Default value for this variable
1273
+ */
1274
+ default: string | number | boolean;
1275
+ /**
1276
+ * Variable name identifier
1277
+ */
1278
+ name: string;
1279
+ /**
1280
+ * Data type of the variable
1281
+ */
1282
+ type: 'STRING' | 'INT' | 'FLOAT' | 'DATE' | 'TIMESTAMP' | 'BOOL' | 'DIMENSION' | 'MEASURE' | 'CALCULATION' | 'FILTER';
1283
+ /**
1284
+ * Allowed values configuration
1285
+ */
1286
+ allowed_values?: ResolvedVariable.VariableAllowedValues1 | ResolvedVariable.VariableAllowedValues2 | null;
1287
+ /**
1288
+ * Constraints for variable types
1289
+ */
1290
+ constraints?: ResolvedVariable.Constraints | null;
1291
+ /**
1292
+ * Description of the variable's purpose
1293
+ */
1294
+ description?: string | null;
1295
+ /**
1296
+ * True if bound_value equals the default value
1297
+ */
1298
+ is_default?: boolean | null;
1299
+ /**
1300
+ * Human-readable label for the variable
1301
+ */
1302
+ label?: string | null;
1303
+ }
1304
+ namespace ResolvedVariable {
1305
+ /**
1306
+ * Allowed values for a variable - either static list or from column
1307
+ */
1308
+ interface VariableAllowedValues1 {
1309
+ /**
1310
+ * Static list of allowed values with optional labels
1311
+ */
1312
+ static: Array<VariableAllowedValues1.Static>;
1313
+ }
1314
+ namespace VariableAllowedValues1 {
1315
+ /**
1316
+ * A value with optional display label
1317
+ */
1318
+ interface Static {
1319
+ /**
1320
+ * The actual value
1321
+ */
1322
+ value: string | number | boolean;
1323
+ /**
1324
+ * Human-readable label for the value
1325
+ */
1326
+ label?: string | null;
1327
+ }
1328
+ }
1329
+ /**
1330
+ * Allowed values for a variable - either static list or from column
1331
+ */
1332
+ interface VariableAllowedValues2 {
1333
+ /**
1334
+ * Reference to column for dynamic values
1335
+ */
1336
+ from_column: string;
1337
+ /**
1338
+ * Cache time-to-live in seconds
1339
+ */
1340
+ cache_ttl?: number;
1341
+ /**
1342
+ * Maximum number of values to retrieve
1343
+ */
1344
+ limit?: number;
1345
+ /**
1346
+ * Sort order for values
1347
+ */
1348
+ order_by?: 'asc' | 'desc';
1349
+ }
1350
+ /**
1351
+ * Constraints for variable types
1352
+ */
1353
+ interface Constraints {
1354
+ /**
1355
+ * Maximum allowed value
1356
+ */
1357
+ max?: number | null;
1358
+ /**
1359
+ * Maximum length for STRING variables
1360
+ */
1361
+ max_length?: number | null;
1362
+ /**
1363
+ * Minimum allowed value
1364
+ */
1365
+ min?: number | null;
1366
+ /**
1367
+ * Step increment for numeric input
1368
+ */
1369
+ step?: number | null;
1370
+ }
1371
+ }
1372
+ /**
1373
+ * A resolved select_from entry with CTE metadata
1374
+ */
1375
+ interface SelectFrom {
1376
+ /**
1377
+ * CTE alias used in the WITH clause (e.g., **sf_compliance_rate**base)
1378
+ */
1379
+ cte_alias: string;
1380
+ /**
1381
+ * Columns produced by the CTE, available as q:query_name.field_name in the parent
1382
+ */
1383
+ output_columns: Array<SelectFrom.OutputColumn>;
1384
+ /**
1385
+ * Reference to the source query
1386
+ */
1387
+ ref: string;
1388
+ /**
1389
+ * Variable overrides passed to the referenced query
1390
+ */
1391
+ variables?: {
1392
+ [key: string]: string | number | boolean;
1393
+ } | null;
1394
+ }
1395
+ namespace SelectFrom {
1396
+ /**
1397
+ * A column produced by a select_from CTE
1398
+ */
1399
+ interface OutputColumn {
1400
+ /**
1401
+ * The SQL column alias in the CTE output
1402
+ */
1403
+ column_alias: string;
1404
+ /**
1405
+ * The field name used in q:query_name.field_name references
1406
+ */
1407
+ field_name: string;
1408
+ /**
1409
+ * Original type of the field in the source query
1410
+ */
1411
+ source_type: 'dimension' | 'measure' | 'calculation';
1412
+ }
1413
+ }
1414
+ }
1415
+ }
1416
+ export interface CompilerEnumerateParams {
1417
+ /**
1418
+ * Body param: Connection to enumerate against
1419
+ */
1420
+ connection_id: string;
1421
+ /**
1422
+ * Query param
1423
+ */
1424
+ source?: string | null;
1425
+ /**
1426
+ * Body param: Optional query refs to limit enumeration. If omitted, enumerates all
1427
+ * queries.
1428
+ */
1429
+ query_refs?: Array<string> | null;
1430
+ /**
1431
+ * Header param
1432
+ */
1433
+ 'X-Kater-CLI-ID'?: string;
1434
+ }
1435
+ export interface CompilerExecuteParams {
1436
+ /**
1437
+ * Body param: Connection to execute against
1438
+ */
1439
+ connection_id: string;
1440
+ /**
1441
+ * Body param: Previously resolved query object from /resolve
1442
+ */
1443
+ resolved_query: CompilerExecuteParams.ResolvedQuery;
1444
+ /**
1445
+ * Query param
1446
+ */
1447
+ source?: string | null;
1448
+ /**
1449
+ * Body param: Tenant key for multi-tenant execution
1450
+ */
1451
+ tenant_key?: string | null;
1452
+ /**
1453
+ * Header param
1454
+ */
1455
+ 'X-Kater-CLI-ID'?: string;
1456
+ }
1457
+ export declare namespace CompilerExecuteParams {
1458
+ /**
1459
+ * Previously resolved query object from /resolve
1460
+ */
1461
+ interface ResolvedQuery {
1462
+ /**
1463
+ * Unique identifier for this resolved query instance
1464
+ */
1465
+ kater_id: string;
1466
+ /**
1467
+ * Name from the leaf query in the inheritance chain
1468
+ */
1469
+ name: string;
1470
+ /**
1471
+ * Reference to the original query template this was resolved from
1472
+ */
1473
+ source_query: string;
1474
+ /**
1475
+ * Reference to the topic this query uses (always known after inheritance
1476
+ * resolution)
1477
+ */
1478
+ topic: string;
1479
+ /**
1480
+ * Widget category that determines data shape constraints
1481
+ */
1482
+ widget_category: 'axis' | 'pie' | 'single_value' | 'heatmap' | 'table' | 'static';
1483
+ /**
1484
+ * Usage guidance for AI processing
1485
+ */
1486
+ ai_context?: string | null;
1487
+ /**
1488
+ * Merged required + selected optional calculations
1489
+ */
1490
+ calculations?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1491
+ /**
1492
+ * Chart recommendations preserved for evaluation
1493
+ */
1494
+ chart_hints?: Array<ResolvedQuery.ChartHint1Input | ResolvedQuery.ChartHint2Input> | null;
1495
+ /**
1496
+ * Custom properties
1497
+ */
1498
+ custom_properties?: {
1499
+ [key: string]: unknown;
1500
+ } | null;
1501
+ /**
1502
+ * Description of the query
1503
+ */
1504
+ description?: string | null;
1505
+ /**
1506
+ * Merged required + selected optional dimensions
1507
+ */
1508
+ dimensions?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1509
+ /**
1510
+ * Widget types within the declared widget_category that must NOT render this query
1511
+ */
1512
+ disallowed_widget_types?: Array<'kpi_card' | 'line_chart' | 'bar_chart' | 'pie_chart' | 'donut_chart' | 'area_chart' | 'scatter_chart' | 'data_table' | 'card_grid' | 'heatmap' | 'gauge' | 'text' | 'image' | 'styled_table' | 'stat_cards' | 'key_value_list'> | null;
1513
+ /**
1514
+ * Merged required + selected optional filters
1515
+ */
1516
+ filters?: Array<ResolvedQuery.InlineFieldFilter | string | ResolvedQuery.InlineExistsFilter1 | ResolvedQuery.InlineExistsFilter2> | null;
1517
+ /**
1518
+ * Ordered list of query refs that were merged during inheritance resolution
1519
+ */
1520
+ inheritance_chain?: Array<string> | null;
1521
+ /**
1522
+ * Human-readable label with var() values substituted
1523
+ */
1524
+ label?: string | null;
1525
+ /**
1526
+ * Maximum number of rows to return
1527
+ */
1528
+ limit?: number | null;
1529
+ /**
1530
+ * Merged required + selected optional measures
1531
+ */
1532
+ measures?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1533
+ /**
1534
+ * Sort order specification for query results. Use desc for descending
1535
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
1536
+ */
1537
+ order_by?: ResolvedQuery.OrderBy | null;
1538
+ /**
1539
+ * Access grants required to use this query
1540
+ */
1541
+ required_access_grants?: Array<string> | null;
1542
+ /**
1543
+ * The matched chart recommendation after evaluating chart hints
1544
+ */
1545
+ resolved_chart?: ResolvedQuery.ResolvedChart | null;
1546
+ /**
1547
+ * Full variable definitions with bound values
1548
+ */
1549
+ resolved_variables?: Array<ResolvedQuery.ResolvedVariable> | null;
1550
+ /**
1551
+ * Resolved select_from entries with CTE metadata
1552
+ */
1553
+ select_from?: Array<ResolvedQuery.SelectFrom> | null;
1554
+ }
1555
+ namespace ResolvedQuery {
1556
+ /**
1557
+ * A chart recommendation rule
1558
+ */
1559
+ interface ChartHint1Input {
1560
+ /**
1561
+ * Chart configuration with variable references
1562
+ */
1563
+ config: CompilerAPI.ChartConfig;
1564
+ /**
1565
+ * Type of chart visualization
1566
+ */
1567
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1568
+ /**
1569
+ * Conditions based on variable values - can be single value (string) or multiple
1570
+ * values (array)
1571
+ */
1572
+ when: {
1573
+ [key: string]: string | Array<string>;
1574
+ };
1575
+ }
1576
+ /**
1577
+ * A chart recommendation rule
1578
+ */
1579
+ interface ChartHint2Input {
1580
+ default: ChartHint2Input.Default;
1581
+ }
1582
+ namespace ChartHint2Input {
1583
+ interface Default {
1584
+ /**
1585
+ * Chart configuration with variable references
1586
+ */
1587
+ config: CompilerAPI.ChartConfig;
1588
+ /**
1589
+ * Type of chart visualization
1590
+ */
1591
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1592
+ }
1593
+ }
1594
+ /**
1595
+ * An inline filter using field + operator + values
1596
+ */
1597
+ interface InlineFieldFilter {
1598
+ /**
1599
+ * Reference to the field to filter on
1600
+ */
1601
+ field: string;
1602
+ /**
1603
+ * Name of the inline filter
1604
+ */
1605
+ name: string;
1606
+ /**
1607
+ * Filter operator to apply
1608
+ */
1609
+ operator: 'equals' | 'not_equals' | 'in' | 'not_in' | 'greater_than' | 'less_than' | 'greater_than_or_equals' | 'less_than_or_equals' | 'between' | 'in_the_last' | 'in_the_next' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with' | 'is_null' | 'is_not_null';
1610
+ /**
1611
+ * SQL expression for the filter value
1612
+ */
1613
+ sql_value?: string | null;
1614
+ /**
1615
+ * Fixed values for the filter
1616
+ */
1617
+ static_values?: Array<string | number | boolean> | null;
1618
+ }
1619
+ /**
1620
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
1621
+ */
1622
+ interface InlineExistsFilter1 {
1623
+ /**
1624
+ * EXISTS subquery condition
1625
+ */
1626
+ exists: CompilerAPI.SubqueryCondition;
1627
+ /**
1628
+ * Name of the inline filter
1629
+ */
1630
+ name: string;
1631
+ /**
1632
+ * Description of the filter
1633
+ */
1634
+ description?: string | null;
1635
+ /**
1636
+ * Human-readable label
1637
+ */
1638
+ label?: string | null;
1639
+ /**
1640
+ * A subquery condition for EXISTS/NOT EXISTS filters
1641
+ */
1642
+ not_exists?: CompilerAPI.SubqueryCondition | null;
1643
+ }
1644
+ /**
1645
+ * An inline filter using EXISTS or NOT EXISTS with a subquery
1646
+ */
1647
+ interface InlineExistsFilter2 {
1648
+ /**
1649
+ * Name of the inline filter
1650
+ */
1651
+ name: string;
1652
+ /**
1653
+ * NOT EXISTS subquery condition
1654
+ */
1655
+ not_exists: CompilerAPI.SubqueryCondition;
1656
+ /**
1657
+ * Description of the filter
1658
+ */
1659
+ description?: string | null;
1660
+ /**
1661
+ * A subquery condition for EXISTS/NOT EXISTS filters
1662
+ */
1663
+ exists?: CompilerAPI.SubqueryCondition | null;
1664
+ /**
1665
+ * Human-readable label
1666
+ */
1667
+ label?: string | null;
1668
+ }
1669
+ /**
1670
+ * Sort order specification for query results. Use desc for descending
1671
+ * (highest/newest first) and asc for ascending (lowest/oldest first).
1672
+ */
1673
+ interface OrderBy {
1674
+ /**
1675
+ * Fields to sort in ascending order (lowest/oldest first)
1676
+ */
1677
+ asc?: Array<string> | null;
1678
+ /**
1679
+ * Fields to sort in descending order (highest/newest first)
1680
+ */
1681
+ desc?: Array<string> | null;
1682
+ }
1683
+ /**
1684
+ * The matched chart recommendation after evaluating chart hints
1685
+ */
1686
+ interface ResolvedChart {
1687
+ /**
1688
+ * Chart configuration
1689
+ */
1690
+ config: CompilerAPI.ChartConfig;
1691
+ /**
1692
+ * Recommended chart type
1693
+ */
1694
+ recommend: 'line' | 'bar' | 'stacked_bar' | 'area' | 'pie' | 'donut' | 'scatter' | 'table' | 'heatmap' | 'single_value';
1695
+ }
1696
+ /**
1697
+ * A variable definition with its bound value
1698
+ */
1699
+ interface ResolvedVariable {
1700
+ /**
1701
+ * The concrete value bound for this resolution
1702
+ */
1703
+ bound_value: string | number | boolean;
1704
+ /**
1705
+ * Default value for this variable
1706
+ */
1707
+ default: string | number | boolean;
1708
+ /**
1709
+ * Variable name identifier
1710
+ */
1711
+ name: string;
1712
+ /**
1713
+ * Data type of the variable
1714
+ */
1715
+ type: 'STRING' | 'INT' | 'FLOAT' | 'DATE' | 'TIMESTAMP' | 'BOOL' | 'DIMENSION' | 'MEASURE' | 'CALCULATION' | 'FILTER';
1716
+ /**
1717
+ * Allowed values configuration
1718
+ */
1719
+ allowed_values?: ResolvedVariable.VariableAllowedValues1 | ResolvedVariable.VariableAllowedValues2 | null;
1720
+ /**
1721
+ * Constraints for variable types
1722
+ */
1723
+ constraints?: ResolvedVariable.Constraints | null;
1724
+ /**
1725
+ * Description of the variable's purpose
1726
+ */
1727
+ description?: string | null;
1728
+ /**
1729
+ * True if bound_value equals the default value
1730
+ */
1731
+ is_default?: boolean | null;
1732
+ /**
1733
+ * Human-readable label for the variable
1734
+ */
1735
+ label?: string | null;
1736
+ }
1737
+ namespace ResolvedVariable {
1738
+ /**
1739
+ * Allowed values for a variable - either static list or from column
1740
+ */
1741
+ interface VariableAllowedValues1 {
1742
+ /**
1743
+ * Static list of allowed values with optional labels
1744
+ */
1745
+ static: Array<VariableAllowedValues1.Static>;
1746
+ }
1747
+ namespace VariableAllowedValues1 {
1748
+ /**
1749
+ * A value with optional display label
1750
+ */
1751
+ interface Static {
1752
+ /**
1753
+ * The actual value
1754
+ */
1755
+ value: string | number | boolean;
1756
+ /**
1757
+ * Human-readable label for the value
1758
+ */
1759
+ label?: string | null;
1760
+ }
1761
+ }
1762
+ /**
1763
+ * Allowed values for a variable - either static list or from column
1764
+ */
1765
+ interface VariableAllowedValues2 {
1766
+ /**
1767
+ * Reference to column for dynamic values
1768
+ */
1769
+ from_column: string;
1770
+ /**
1771
+ * Cache time-to-live in seconds
1772
+ */
1773
+ cache_ttl?: number;
1774
+ /**
1775
+ * Maximum number of values to retrieve
1776
+ */
1777
+ limit?: number;
1778
+ /**
1779
+ * Sort order for values
1780
+ */
1781
+ order_by?: 'asc' | 'desc';
1782
+ }
1783
+ /**
1784
+ * Constraints for variable types
1785
+ */
1786
+ interface Constraints {
1787
+ /**
1788
+ * Maximum allowed value
1789
+ */
1790
+ max?: number | null;
1791
+ /**
1792
+ * Maximum length for STRING variables
1793
+ */
1794
+ max_length?: number | null;
1795
+ /**
1796
+ * Minimum allowed value
1797
+ */
1798
+ min?: number | null;
1799
+ /**
1800
+ * Step increment for numeric input
1801
+ */
1802
+ step?: number | null;
1803
+ }
1804
+ }
1805
+ /**
1806
+ * A resolved select_from entry with CTE metadata
1807
+ */
1808
+ interface SelectFrom {
1809
+ /**
1810
+ * CTE alias used in the WITH clause (e.g., **sf_compliance_rate**base)
1811
+ */
1812
+ cte_alias: string;
1813
+ /**
1814
+ * Columns produced by the CTE, available as q:query_name.field_name in the parent
1815
+ */
1816
+ output_columns: Array<SelectFrom.OutputColumn>;
1817
+ /**
1818
+ * Reference to the source query
1819
+ */
1820
+ ref: string;
1821
+ /**
1822
+ * Variable overrides passed to the referenced query
1823
+ */
1824
+ variables?: {
1825
+ [key: string]: string | number | boolean;
1826
+ } | null;
1827
+ }
1828
+ namespace SelectFrom {
1829
+ /**
1830
+ * A column produced by a select_from CTE
1831
+ */
1832
+ interface OutputColumn {
1833
+ /**
1834
+ * The SQL column alias in the CTE output
1835
+ */
1836
+ column_alias: string;
1837
+ /**
1838
+ * The field name used in q:query_name.field_name references
1839
+ */
1840
+ field_name: string;
1841
+ /**
1842
+ * Original type of the field in the source query
1843
+ */
1844
+ source_type: 'dimension' | 'measure' | 'calculation';
1845
+ }
1846
+ }
1847
+ }
1848
+ }
1849
+ export interface CompilerResolveParams {
1850
+ /**
1851
+ * Body param: Connection to resolve against
1852
+ */
1853
+ connection_id: string;
1854
+ /**
1855
+ * Body param: Reference to the query template (e.g. 'ref(MY_QUERY)')
1856
+ */
1857
+ query_ref: string;
1858
+ /**
1859
+ * Query param
1860
+ */
1861
+ source?: string | null;
1862
+ /**
1863
+ * Body param: Comma-separated slot selections and variable assignments. Reserved
1864
+ * keys: measure, dimension, filter, calculation. All other keys are variable
1865
+ * assignments. Example: 'measure=Compliance
1866
+ * Rate,dimension=Department,breakdown=region'
1867
+ */
1868
+ combination?: string;
1869
+ /**
1870
+ * Header param
1871
+ */
1872
+ 'X-Kater-CLI-ID'?: string;
1873
+ }
1874
+ export interface CompilerValidateParams {
1875
+ /**
1876
+ * Query param
1877
+ */
1878
+ source?: string | null;
1879
+ /**
1880
+ * Body param: Optional connection IDs to validate. If omitted, validates all
1881
+ * connections.
1882
+ */
1883
+ connection_ids?: Array<string> | null;
1884
+ /**
1885
+ * Header param
1886
+ */
1887
+ 'X-Kater-CLI-ID'?: string;
1888
+ }
1889
+ export declare namespace Compiler {
1890
+ export { type ChartConfig as ChartConfig, type CompilerErrorItem as CompilerErrorItem, type InlineField as InlineField, type Manifest as Manifest, type ManifestEntry as ManifestEntry, type RefWithLabel as RefWithLabel, type SubqueryCondition as SubqueryCondition, type CompilerCompileResponse as CompilerCompileResponse, type CompilerEnumerateResponse as CompilerEnumerateResponse, type CompilerExecuteResponse as CompilerExecuteResponse, type CompilerResolveResponse as CompilerResolveResponse, type CompilerValidateResponse as CompilerValidateResponse, type CompilerCompileParams as CompilerCompileParams, type CompilerEnumerateParams as CompilerEnumerateParams, type CompilerExecuteParams as CompilerExecuteParams, type CompilerResolveParams as CompilerResolveParams, type CompilerValidateParams as CompilerValidateParams, };
1891
+ export { Cache as Cache, type CacheInvalidateResponse as CacheInvalidateResponse, type CacheInvalidateParams as CacheInvalidateParams, };
1892
+ }
1893
+ //# sourceMappingURL=compiler.d.mts.map