@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
@@ -1,1484 +1,3 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../core/resource';
4
- import * as CompilerAPI from './compiler';
5
- import { APIPromise } from '../../core/api-promise';
6
- import { buildHeaders } from '../../internal/headers';
7
- import { RequestOptions } from '../../internal/request-options';
8
-
9
- export class Compiler extends APIResource {
10
- /**
11
- * Compile a resolved query to SQL.
12
- *
13
- * Takes a previously resolved query and generates the final SQL statement for the
14
- * target dialect.
15
- *
16
- * RLS: Filtered to current client (ClientRLSDB).
17
- */
18
- compile(params: CompilerCompileParams, options?: RequestOptions): APIPromise<CompilerCompileResponse> {
19
- const { source, 'X-Kater-CLI-ID': xKaterCliID, ...body } = params;
20
- return this._client.post('/api/v1/compiler/compile', {
21
- query: { source },
22
- body,
23
- ...options,
24
- headers: buildHeaders([
25
- { ...(xKaterCliID != null ? { 'X-Kater-CLI-ID': xKaterCliID } : undefined) },
26
- options?.headers,
27
- ]),
28
- });
29
- }
30
-
31
- /**
32
- * Resolve a query template with user-selected parameters.
33
- *
34
- * Takes a query reference and variable selections, returns the fully resolved
35
- * query object ready for compilation.
36
- *
37
- * RLS: Filtered to current client (ClientRLSDB).
38
- */
39
- resolve(params: CompilerResolveParams, options?: RequestOptions): APIPromise<CompilerResolveResponse> {
40
- const { source, 'X-Kater-CLI-ID': xKaterCliID, ...body } = params;
41
- return this._client.post('/api/v1/compiler/resolve', {
42
- query: { source },
43
- body,
44
- ...options,
45
- headers: buildHeaders([
46
- { ...(xKaterCliID != null ? { 'X-Kater-CLI-ID': xKaterCliID } : undefined) },
47
- options?.headers,
48
- ]),
49
- });
50
- }
51
-
52
- /**
53
- * Validate a schema file set against a connection.
54
- *
55
- * Checks all views, queries, and related schemas for correctness and returns any
56
- * errors or warnings found.
57
- *
58
- * RLS: Filtered to current client (ClientRLSDB).
59
- */
60
- validate(params: CompilerValidateParams, options?: RequestOptions): APIPromise<CompilerValidateResponse> {
61
- const { source, 'X-Kater-CLI-ID': xKaterCliID, ...body } = params;
62
- return this._client.post('/api/v1/compiler/validate', {
63
- query: { source },
64
- body,
65
- ...options,
66
- headers: buildHeaders([
67
- { ...(xKaterCliID != null ? { 'X-Kater-CLI-ID': xKaterCliID } : undefined) },
68
- options?.headers,
69
- ]),
70
- });
71
- }
72
- }
73
-
74
- /**
75
- * Chart configuration with variable references
76
- */
77
- export interface ChartConfig {
78
- /**
79
- * Field or variable reference for color grouping
80
- */
81
- color_by?: string | null;
82
-
83
- /**
84
- * Field or variable reference for size
85
- */
86
- size?: string | null;
87
-
88
- /**
89
- * Field or variable reference for stacking
90
- */
91
- stack_by?: string | null;
92
-
93
- /**
94
- * Field or variable reference for x-axis
95
- */
96
- x_axis?: string | null;
97
-
98
- /**
99
- * Field or variable reference for y-axis
100
- */
101
- y_axis?: string | null;
102
- }
103
-
104
- /**
105
- * A single compiler validation or compilation error.
106
- */
107
- export interface CompilerErrorItem {
108
- /**
109
- * Machine-readable error code
110
- */
111
- code: string;
112
-
113
- /**
114
- * Human-readable error description
115
- */
116
- message: string;
117
-
118
- /**
119
- * Source file path where the error occurred
120
- */
121
- file?: string | null;
122
-
123
- /**
124
- * Line number in the source file
125
- */
126
- line?: number | null;
127
-
128
- /**
129
- * Reference to the source element (e.g. view or query name)
130
- */
131
- ref?: string | null;
132
-
133
- /**
134
- * Suggested fix for this error
135
- */
136
- remediation?: string | null;
137
- }
138
-
139
- /**
140
- * An inline field definition for dimensions/measures/calculations
141
- */
142
- export interface InlineField {
143
- /**
144
- * Unique identifier for this inline field
145
- */
146
- kater_id: string;
147
-
148
- /**
149
- * Name of the inline field
150
- */
151
- name: string;
152
-
153
- /**
154
- * SQL expression for the field
155
- */
156
- sql: string;
157
-
158
- /**
159
- * Human-readable label
160
- */
161
- label?: string | null;
162
- }
163
-
164
- /**
165
- * Compilation manifest with all named objects.
166
- */
167
- export interface Manifest {
168
- generated_at: string;
169
-
170
- objects: { [key: string]: ManifestEntry };
171
-
172
- schema_version?: string;
173
- }
174
-
175
- /**
176
- * A single object entry in the manifest.
177
- */
178
- export interface ManifestEntry {
179
- kater_id: string;
180
-
181
- name: string;
182
-
183
- type: string;
184
-
185
- label?: string | null;
186
-
187
- parent_id?: string | null;
188
-
189
- source_file?: string | null;
190
- }
191
-
192
- /**
193
- * A reference with optional label override
194
- */
195
- export interface RefWithLabel {
196
- /**
197
- * Reference using ref(), var(), or expr() syntax
198
- */
199
- ref: string;
200
-
201
- /**
202
- * Optional label override for this reference
203
- */
204
- label?: string | null;
205
- }
206
-
207
- /**
208
- * A subquery condition for EXISTS/NOT EXISTS filters
209
- */
210
- export interface SubqueryCondition {
211
- /**
212
- * Reference to the source view/table for the subquery
213
- */
214
- from: string;
215
-
216
- /**
217
- * WHERE conditions for the subquery
218
- */
219
- where: Array<string>;
220
- }
221
-
222
- /**
223
- * Response model for SQL compilation.
224
- */
225
- export interface CompilerCompileResponse {
226
- /**
227
- * SQL dialect used (e.g. 'snowflake')
228
- */
229
- dialect: string;
230
-
231
- /**
232
- * Whether compilation succeeded
233
- */
234
- success: boolean;
235
-
236
- /**
237
- * Compilation errors
238
- */
239
- errors?: Array<CompilerErrorItem>;
240
-
241
- /**
242
- * Compilation manifest with all named objects.
243
- */
244
- manifest?: Manifest | null;
245
-
246
- /**
247
- * Compilation metadata from the compiler.
248
- */
249
- metadata?: CompilerCompileResponse.Metadata | null;
250
-
251
- /**
252
- * Generated SQL statement
253
- */
254
- sql?: string | null;
255
- }
256
-
257
- export namespace CompilerCompileResponse {
258
- /**
259
- * Compilation metadata from the compiler.
260
- */
261
- export interface Metadata {
262
- /**
263
- * SQL dialect used (e.g. 'snowflake')
264
- */
265
- dialect: string;
266
-
267
- /**
268
- * Reference to the compiled query
269
- */
270
- query_ref: string;
271
-
272
- /**
273
- * Dimension names used in compilation
274
- */
275
- dimensions_used?: Array<string>;
276
-
277
- /**
278
- * Filter names used in compilation
279
- */
280
- filters_used?: Array<string>;
281
-
282
- /**
283
- * Measure names used in compilation
284
- */
285
- measures_used?: Array<string>;
286
-
287
- /**
288
- * View names used in compilation
289
- */
290
- views_used?: Array<string>;
291
- }
292
- }
293
-
294
- /**
295
- * Response model for a resolved query.
296
- */
297
- export interface CompilerResolveResponse {
298
- /**
299
- * The fully resolved query object
300
- */
301
- resolved_query: CompilerResolveResponse.ResolvedQuery;
302
-
303
- /**
304
- * Dependency graph between schema objects.
305
- */
306
- dependency_graph?: CompilerResolveResponse.DependencyGraph | null;
307
-
308
- /**
309
- * Compilation manifest with all named objects.
310
- */
311
- manifest?: Manifest | null;
312
- }
313
-
314
- export namespace CompilerResolveResponse {
315
- /**
316
- * The fully resolved query object
317
- */
318
- export interface ResolvedQuery {
319
- /**
320
- * Unique identifier for this resolved query instance
321
- */
322
- kater_id: string;
323
-
324
- /**
325
- * Name from the leaf query in the inheritance chain
326
- */
327
- name: string;
328
-
329
- /**
330
- * Reference to the original query template this was resolved from
331
- */
332
- source_query: string;
333
-
334
- /**
335
- * Reference to the topic this query uses (always known after inheritance
336
- * resolution)
337
- */
338
- topic: string;
339
-
340
- /**
341
- * Usage guidance for AI processing
342
- */
343
- ai_context?: string | null;
344
-
345
- /**
346
- * Merged required + selected optional calculations
347
- */
348
- calculations?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
349
-
350
- /**
351
- * Chart recommendations preserved for evaluation
352
- */
353
- chart_hints?: Array<ResolvedQuery.ChartHint1 | ResolvedQuery.ChartHint2Output> | null;
354
-
355
- /**
356
- * Custom properties
357
- */
358
- custom_properties?: { [key: string]: unknown } | null;
359
-
360
- /**
361
- * Description of the query
362
- */
363
- description?: string | null;
364
-
365
- /**
366
- * Merged required + selected optional dimensions
367
- */
368
- dimensions?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
369
-
370
- /**
371
- * Merged required + selected optional filters
372
- */
373
- filters?: Array<
374
- | ResolvedQuery.InlineFieldFilter
375
- | string
376
- | ResolvedQuery.InlineExistsFilter1
377
- | ResolvedQuery.InlineExistsFilter2
378
- > | null;
379
-
380
- /**
381
- * Ordered list of query refs that were merged during inheritance resolution
382
- */
383
- inheritance_chain?: Array<string> | null;
384
-
385
- /**
386
- * Human-readable label with var() values substituted
387
- */
388
- label?: string | null;
389
-
390
- /**
391
- * Maximum number of rows to return
392
- */
393
- limit?: number | null;
394
-
395
- /**
396
- * Merged required + selected optional measures
397
- */
398
- measures?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
399
-
400
- /**
401
- * Sort order specification for query results. Use desc for descending
402
- * (highest/newest first) and asc for ascending (lowest/oldest first).
403
- */
404
- order_by?: ResolvedQuery.OrderBy | null;
405
-
406
- /**
407
- * Access grants required to use this query
408
- */
409
- required_access_grants?: Array<string> | null;
410
-
411
- /**
412
- * The matched chart recommendation after evaluating chart hints
413
- */
414
- resolved_chart?: ResolvedQuery.ResolvedChart | null;
415
-
416
- /**
417
- * Full variable definitions with bound values
418
- */
419
- resolved_variables?: Array<ResolvedQuery.ResolvedVariable> | null;
420
-
421
- /**
422
- * Category of widget that determines data shape constraints for queries
423
- */
424
- widget_category?: 'axis' | 'pie' | 'single_value' | 'heatmap' | 'table' | 'static' | null;
425
- }
426
-
427
- export namespace ResolvedQuery {
428
- /**
429
- * A chart recommendation rule
430
- */
431
- export interface ChartHint1 {
432
- /**
433
- * Chart configuration with variable references
434
- */
435
- config: CompilerAPI.ChartConfig;
436
-
437
- /**
438
- * Type of chart visualization
439
- */
440
- recommend:
441
- | 'line'
442
- | 'bar'
443
- | 'stacked_bar'
444
- | 'area'
445
- | 'pie'
446
- | 'donut'
447
- | 'scatter'
448
- | 'table'
449
- | 'heatmap'
450
- | 'single_value';
451
-
452
- /**
453
- * Conditions based on variable values - can be single value (string) or multiple
454
- * values (array)
455
- */
456
- when: { [key: string]: string | Array<string> };
457
- }
458
-
459
- /**
460
- * A chart recommendation rule
461
- */
462
- export interface ChartHint2Output {
463
- default: ChartHint2Output.Default;
464
- }
465
-
466
- export namespace ChartHint2Output {
467
- export interface Default {
468
- /**
469
- * Chart configuration with variable references
470
- */
471
- config: CompilerAPI.ChartConfig;
472
-
473
- /**
474
- * Type of chart visualization
475
- */
476
- recommend:
477
- | 'line'
478
- | 'bar'
479
- | 'stacked_bar'
480
- | 'area'
481
- | 'pie'
482
- | 'donut'
483
- | 'scatter'
484
- | 'table'
485
- | 'heatmap'
486
- | 'single_value';
487
- }
488
- }
489
-
490
- /**
491
- * An inline filter using field + operator + values
492
- */
493
- export interface InlineFieldFilter {
494
- /**
495
- * Reference to the field to filter on
496
- */
497
- field: string;
498
-
499
- /**
500
- * Name of the inline filter
501
- */
502
- name: string;
503
-
504
- /**
505
- * Filter operator to apply
506
- */
507
- operator:
508
- | 'equals'
509
- | 'not_equals'
510
- | 'in'
511
- | 'not_in'
512
- | 'greater_than'
513
- | 'less_than'
514
- | 'greater_than_or_equals'
515
- | 'less_than_or_equals'
516
- | 'between'
517
- | 'in_the_last'
518
- | 'in_the_next'
519
- | 'contains'
520
- | 'not_contains'
521
- | 'starts_with'
522
- | 'ends_with'
523
- | 'is_null'
524
- | 'is_not_null';
525
-
526
- /**
527
- * SQL expression for the filter value
528
- */
529
- sql_value?: string | null;
530
-
531
- /**
532
- * Fixed values for the filter
533
- */
534
- static_values?: Array<string | number | boolean> | null;
535
- }
536
-
537
- /**
538
- * An inline filter using EXISTS or NOT EXISTS with a subquery
539
- */
540
- export interface InlineExistsFilter1 {
541
- /**
542
- * EXISTS subquery condition
543
- */
544
- exists: CompilerAPI.SubqueryCondition;
545
-
546
- /**
547
- * Name of the inline filter
548
- */
549
- name: string;
550
-
551
- /**
552
- * Description of the filter
553
- */
554
- description?: string | null;
555
-
556
- /**
557
- * Human-readable label
558
- */
559
- label?: string | null;
560
-
561
- /**
562
- * A subquery condition for EXISTS/NOT EXISTS filters
563
- */
564
- not_exists?: CompilerAPI.SubqueryCondition | null;
565
- }
566
-
567
- /**
568
- * An inline filter using EXISTS or NOT EXISTS with a subquery
569
- */
570
- export interface InlineExistsFilter2 {
571
- /**
572
- * Name of the inline filter
573
- */
574
- name: string;
575
-
576
- /**
577
- * NOT EXISTS subquery condition
578
- */
579
- not_exists: CompilerAPI.SubqueryCondition;
580
-
581
- /**
582
- * Description of the filter
583
- */
584
- description?: string | null;
585
-
586
- /**
587
- * A subquery condition for EXISTS/NOT EXISTS filters
588
- */
589
- exists?: CompilerAPI.SubqueryCondition | null;
590
-
591
- /**
592
- * Human-readable label
593
- */
594
- label?: string | null;
595
- }
596
-
597
- /**
598
- * Sort order specification for query results. Use desc for descending
599
- * (highest/newest first) and asc for ascending (lowest/oldest first).
600
- */
601
- export interface OrderBy {
602
- /**
603
- * Fields to sort in ascending order (lowest/oldest first)
604
- */
605
- asc?: Array<string> | null;
606
-
607
- /**
608
- * Fields to sort in descending order (highest/newest first)
609
- */
610
- desc?: Array<string> | null;
611
- }
612
-
613
- /**
614
- * The matched chart recommendation after evaluating chart hints
615
- */
616
- export interface ResolvedChart {
617
- /**
618
- * Chart configuration
619
- */
620
- config: CompilerAPI.ChartConfig;
621
-
622
- /**
623
- * Recommended chart type
624
- */
625
- recommend:
626
- | 'line'
627
- | 'bar'
628
- | 'stacked_bar'
629
- | 'area'
630
- | 'pie'
631
- | 'donut'
632
- | 'scatter'
633
- | 'table'
634
- | 'heatmap'
635
- | 'single_value';
636
- }
637
-
638
- /**
639
- * A variable definition with its bound value
640
- */
641
- export interface ResolvedVariable {
642
- /**
643
- * The concrete value bound for this resolution
644
- */
645
- bound_value: string | number | boolean;
646
-
647
- /**
648
- * Default value for this variable
649
- */
650
- default: string | number | boolean;
651
-
652
- /**
653
- * Variable name identifier
654
- */
655
- name: string;
656
-
657
- /**
658
- * Data type of the variable
659
- */
660
- type:
661
- | 'STRING'
662
- | 'INT'
663
- | 'FLOAT'
664
- | 'DATE'
665
- | 'TIMESTAMP'
666
- | 'BOOL'
667
- | 'DIMENSION'
668
- | 'MEASURE'
669
- | 'CALCULATION'
670
- | 'FILTER';
671
-
672
- /**
673
- * Allowed values configuration
674
- */
675
- allowed_values?:
676
- | ResolvedVariable.VariableAllowedValues1
677
- | ResolvedVariable.VariableAllowedValues2
678
- | null;
679
-
680
- /**
681
- * Constraints for variable types
682
- */
683
- constraints?: ResolvedVariable.Constraints | null;
684
-
685
- /**
686
- * Description of the variable's purpose
687
- */
688
- description?: string | null;
689
-
690
- /**
691
- * True if bound_value equals the default value
692
- */
693
- is_default?: boolean | null;
694
-
695
- /**
696
- * Human-readable label for the variable
697
- */
698
- label?: string | null;
699
- }
700
-
701
- export namespace ResolvedVariable {
702
- /**
703
- * Allowed values for a variable - either static list or from column
704
- */
705
- export interface VariableAllowedValues1 {
706
- /**
707
- * Static list of allowed values with optional labels
708
- */
709
- static: Array<VariableAllowedValues1.Static>;
710
- }
711
-
712
- export namespace VariableAllowedValues1 {
713
- /**
714
- * A value with optional display label
715
- */
716
- export interface Static {
717
- /**
718
- * The actual value
719
- */
720
- value: string | number | boolean;
721
-
722
- /**
723
- * Human-readable label for the value
724
- */
725
- label?: string | null;
726
- }
727
- }
728
-
729
- /**
730
- * Allowed values for a variable - either static list or from column
731
- */
732
- export interface VariableAllowedValues2 {
733
- /**
734
- * Reference to column for dynamic values
735
- */
736
- from_column: string;
737
-
738
- /**
739
- * Cache time-to-live in seconds
740
- */
741
- cache_ttl?: number;
742
-
743
- /**
744
- * Maximum number of values to retrieve
745
- */
746
- limit?: number;
747
-
748
- /**
749
- * Sort order for values
750
- */
751
- order_by?: 'asc' | 'desc';
752
- }
753
-
754
- /**
755
- * Constraints for variable types
756
- */
757
- export interface Constraints {
758
- /**
759
- * Maximum allowed value
760
- */
761
- max?: number | null;
762
-
763
- /**
764
- * Maximum length for STRING variables
765
- */
766
- max_length?: number | null;
767
-
768
- /**
769
- * Minimum allowed value
770
- */
771
- min?: number | null;
772
-
773
- /**
774
- * Step increment for numeric input
775
- */
776
- step?: number | null;
777
- }
778
- }
779
- }
780
-
781
- /**
782
- * Dependency graph between schema objects.
783
- */
784
- export interface DependencyGraph {
785
- /**
786
- * Edge relationships with UUID string keys
787
- */
788
- edges: { [key: string]: { [key: string]: Array<string> } };
789
-
790
- /**
791
- * UUID string to node mapping
792
- */
793
- nodes: { [key: string]: DependencyGraph.Nodes };
794
- }
795
-
796
- export namespace DependencyGraph {
797
- /**
798
- * A node in the dependency graph.
799
- */
800
- export interface Nodes {
801
- /**
802
- * Source file path
803
- */
804
- file: string;
805
-
806
- /**
807
- * Fully qualified name (e.g. 'dim_customer.region')
808
- */
809
- fqn: string;
810
-
811
- /**
812
- * UUID of the schema object
813
- */
814
- kater_id: string;
815
-
816
- /**
817
- * Line number in source file
818
- */
819
- line: number;
820
-
821
- /**
822
- * Node type: QUERY, VIEW, DIMENSION, MEASURE, FILTER, EXPRESSION
823
- */
824
- node_type: string;
825
- }
826
- }
827
- }
828
-
829
- /**
830
- * Response model for schema validation.
831
- */
832
- export interface CompilerValidateResponse {
833
- /**
834
- * Whether validation passed without errors
835
- */
836
- success: boolean;
837
-
838
- /**
839
- * Dependency graph between schema objects.
840
- */
841
- dependency_graph?: CompilerValidateResponse.DependencyGraph | null;
842
-
843
- /**
844
- * Validation errors
845
- */
846
- errors?: Array<CompilerErrorItem>;
847
-
848
- /**
849
- * Compilation manifest with all named objects.
850
- */
851
- manifest?: Manifest | null;
852
-
853
- /**
854
- * Validation warnings
855
- */
856
- warnings?: Array<CompilerErrorItem>;
857
- }
858
-
859
- export namespace CompilerValidateResponse {
860
- /**
861
- * Dependency graph between schema objects.
862
- */
863
- export interface DependencyGraph {
864
- /**
865
- * Edge relationships with UUID string keys
866
- */
867
- edges: { [key: string]: { [key: string]: Array<string> } };
868
-
869
- /**
870
- * UUID string to node mapping
871
- */
872
- nodes: { [key: string]: DependencyGraph.Nodes };
873
- }
874
-
875
- export namespace DependencyGraph {
876
- /**
877
- * A node in the dependency graph.
878
- */
879
- export interface Nodes {
880
- /**
881
- * Source file path
882
- */
883
- file: string;
884
-
885
- /**
886
- * Fully qualified name (e.g. 'dim_customer.region')
887
- */
888
- fqn: string;
889
-
890
- /**
891
- * UUID of the schema object
892
- */
893
- kater_id: string;
894
-
895
- /**
896
- * Line number in source file
897
- */
898
- line: number;
899
-
900
- /**
901
- * Node type: QUERY, VIEW, DIMENSION, MEASURE, FILTER, EXPRESSION
902
- */
903
- node_type: string;
904
- }
905
- }
906
- }
907
-
908
- export interface CompilerCompileParams {
909
- /**
910
- * Body param: Connection to compile against
911
- */
912
- connection_id: string;
913
-
914
- /**
915
- * Body param: Previously resolved query object from /resolve
916
- */
917
- resolved_query: CompilerCompileParams.ResolvedQuery;
918
-
919
- /**
920
- * Query param
921
- */
922
- source?: string | null;
923
-
924
- /**
925
- * Body param: Optional tenant database override
926
- */
927
- tenant_database?: string | null;
928
-
929
- /**
930
- * Header param
931
- */
932
- 'X-Kater-CLI-ID'?: string;
933
- }
934
-
935
- export namespace CompilerCompileParams {
936
- /**
937
- * Previously resolved query object from /resolve
938
- */
939
- export interface ResolvedQuery {
940
- /**
941
- * Unique identifier for this resolved query instance
942
- */
943
- kater_id: string;
944
-
945
- /**
946
- * Name from the leaf query in the inheritance chain
947
- */
948
- name: string;
949
-
950
- /**
951
- * Reference to the original query template this was resolved from
952
- */
953
- source_query: string;
954
-
955
- /**
956
- * Reference to the topic this query uses (always known after inheritance
957
- * resolution)
958
- */
959
- topic: string;
960
-
961
- /**
962
- * Usage guidance for AI processing
963
- */
964
- ai_context?: string | null;
965
-
966
- /**
967
- * Merged required + selected optional calculations
968
- */
969
- calculations?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
970
-
971
- /**
972
- * Chart recommendations preserved for evaluation
973
- */
974
- chart_hints?: Array<ResolvedQuery.ChartHint1 | ResolvedQuery.ChartHint2Input> | null;
975
-
976
- /**
977
- * Custom properties
978
- */
979
- custom_properties?: { [key: string]: unknown } | null;
980
-
981
- /**
982
- * Description of the query
983
- */
984
- description?: string | null;
985
-
986
- /**
987
- * Merged required + selected optional dimensions
988
- */
989
- dimensions?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
990
-
991
- /**
992
- * Merged required + selected optional filters
993
- */
994
- filters?: Array<
995
- | ResolvedQuery.InlineFieldFilter
996
- | string
997
- | ResolvedQuery.InlineExistsFilter1
998
- | ResolvedQuery.InlineExistsFilter2
999
- > | null;
1000
-
1001
- /**
1002
- * Ordered list of query refs that were merged during inheritance resolution
1003
- */
1004
- inheritance_chain?: Array<string> | null;
1005
-
1006
- /**
1007
- * Human-readable label with var() values substituted
1008
- */
1009
- label?: string | null;
1010
-
1011
- /**
1012
- * Maximum number of rows to return
1013
- */
1014
- limit?: number | null;
1015
-
1016
- /**
1017
- * Merged required + selected optional measures
1018
- */
1019
- measures?: Array<CompilerAPI.RefWithLabel | CompilerAPI.InlineField | string> | null;
1020
-
1021
- /**
1022
- * Sort order specification for query results. Use desc for descending
1023
- * (highest/newest first) and asc for ascending (lowest/oldest first).
1024
- */
1025
- order_by?: ResolvedQuery.OrderBy | null;
1026
-
1027
- /**
1028
- * Access grants required to use this query
1029
- */
1030
- required_access_grants?: Array<string> | null;
1031
-
1032
- /**
1033
- * The matched chart recommendation after evaluating chart hints
1034
- */
1035
- resolved_chart?: ResolvedQuery.ResolvedChart | null;
1036
-
1037
- /**
1038
- * Full variable definitions with bound values
1039
- */
1040
- resolved_variables?: Array<ResolvedQuery.ResolvedVariable> | null;
1041
-
1042
- /**
1043
- * Category of widget that determines data shape constraints for queries
1044
- */
1045
- widget_category?: 'axis' | 'pie' | 'single_value' | 'heatmap' | 'table' | 'static' | null;
1046
- }
1047
-
1048
- export namespace ResolvedQuery {
1049
- /**
1050
- * A chart recommendation rule
1051
- */
1052
- export interface ChartHint1 {
1053
- /**
1054
- * Chart configuration with variable references
1055
- */
1056
- config: CompilerAPI.ChartConfig;
1057
-
1058
- /**
1059
- * Type of chart visualization
1060
- */
1061
- recommend:
1062
- | 'line'
1063
- | 'bar'
1064
- | 'stacked_bar'
1065
- | 'area'
1066
- | 'pie'
1067
- | 'donut'
1068
- | 'scatter'
1069
- | 'table'
1070
- | 'heatmap'
1071
- | 'single_value';
1072
-
1073
- /**
1074
- * Conditions based on variable values - can be single value (string) or multiple
1075
- * values (array)
1076
- */
1077
- when: { [key: string]: string | Array<string> };
1078
- }
1079
-
1080
- /**
1081
- * A chart recommendation rule
1082
- */
1083
- export interface ChartHint2Input {
1084
- default: ChartHint2Input.Default;
1085
- }
1086
-
1087
- export namespace ChartHint2Input {
1088
- export interface Default {
1089
- /**
1090
- * Chart configuration with variable references
1091
- */
1092
- config: CompilerAPI.ChartConfig;
1093
-
1094
- /**
1095
- * Type of chart visualization
1096
- */
1097
- recommend:
1098
- | 'line'
1099
- | 'bar'
1100
- | 'stacked_bar'
1101
- | 'area'
1102
- | 'pie'
1103
- | 'donut'
1104
- | 'scatter'
1105
- | 'table'
1106
- | 'heatmap'
1107
- | 'single_value';
1108
- }
1109
- }
1110
-
1111
- /**
1112
- * An inline filter using field + operator + values
1113
- */
1114
- export interface InlineFieldFilter {
1115
- /**
1116
- * Reference to the field to filter on
1117
- */
1118
- field: string;
1119
-
1120
- /**
1121
- * Name of the inline filter
1122
- */
1123
- name: string;
1124
-
1125
- /**
1126
- * Filter operator to apply
1127
- */
1128
- operator:
1129
- | 'equals'
1130
- | 'not_equals'
1131
- | 'in'
1132
- | 'not_in'
1133
- | 'greater_than'
1134
- | 'less_than'
1135
- | 'greater_than_or_equals'
1136
- | 'less_than_or_equals'
1137
- | 'between'
1138
- | 'in_the_last'
1139
- | 'in_the_next'
1140
- | 'contains'
1141
- | 'not_contains'
1142
- | 'starts_with'
1143
- | 'ends_with'
1144
- | 'is_null'
1145
- | 'is_not_null';
1146
-
1147
- /**
1148
- * SQL expression for the filter value
1149
- */
1150
- sql_value?: string | null;
1151
-
1152
- /**
1153
- * Fixed values for the filter
1154
- */
1155
- static_values?: Array<string | number | boolean> | null;
1156
- }
1157
-
1158
- /**
1159
- * An inline filter using EXISTS or NOT EXISTS with a subquery
1160
- */
1161
- export interface InlineExistsFilter1 {
1162
- /**
1163
- * EXISTS subquery condition
1164
- */
1165
- exists: CompilerAPI.SubqueryCondition;
1166
-
1167
- /**
1168
- * Name of the inline filter
1169
- */
1170
- name: string;
1171
-
1172
- /**
1173
- * Description of the filter
1174
- */
1175
- description?: string | null;
1176
-
1177
- /**
1178
- * Human-readable label
1179
- */
1180
- label?: string | null;
1181
-
1182
- /**
1183
- * A subquery condition for EXISTS/NOT EXISTS filters
1184
- */
1185
- not_exists?: CompilerAPI.SubqueryCondition | null;
1186
- }
1187
-
1188
- /**
1189
- * An inline filter using EXISTS or NOT EXISTS with a subquery
1190
- */
1191
- export interface InlineExistsFilter2 {
1192
- /**
1193
- * Name of the inline filter
1194
- */
1195
- name: string;
1196
-
1197
- /**
1198
- * NOT EXISTS subquery condition
1199
- */
1200
- not_exists: CompilerAPI.SubqueryCondition;
1201
-
1202
- /**
1203
- * Description of the filter
1204
- */
1205
- description?: string | null;
1206
-
1207
- /**
1208
- * A subquery condition for EXISTS/NOT EXISTS filters
1209
- */
1210
- exists?: CompilerAPI.SubqueryCondition | null;
1211
-
1212
- /**
1213
- * Human-readable label
1214
- */
1215
- label?: string | null;
1216
- }
1217
-
1218
- /**
1219
- * Sort order specification for query results. Use desc for descending
1220
- * (highest/newest first) and asc for ascending (lowest/oldest first).
1221
- */
1222
- export interface OrderBy {
1223
- /**
1224
- * Fields to sort in ascending order (lowest/oldest first)
1225
- */
1226
- asc?: Array<string> | null;
1227
-
1228
- /**
1229
- * Fields to sort in descending order (highest/newest first)
1230
- */
1231
- desc?: Array<string> | null;
1232
- }
1233
-
1234
- /**
1235
- * The matched chart recommendation after evaluating chart hints
1236
- */
1237
- export interface ResolvedChart {
1238
- /**
1239
- * Chart configuration
1240
- */
1241
- config: CompilerAPI.ChartConfig;
1242
-
1243
- /**
1244
- * Recommended chart type
1245
- */
1246
- recommend:
1247
- | 'line'
1248
- | 'bar'
1249
- | 'stacked_bar'
1250
- | 'area'
1251
- | 'pie'
1252
- | 'donut'
1253
- | 'scatter'
1254
- | 'table'
1255
- | 'heatmap'
1256
- | 'single_value';
1257
- }
1258
-
1259
- /**
1260
- * A variable definition with its bound value
1261
- */
1262
- export interface ResolvedVariable {
1263
- /**
1264
- * The concrete value bound for this resolution
1265
- */
1266
- bound_value: string | number | boolean;
1267
-
1268
- /**
1269
- * Default value for this variable
1270
- */
1271
- default: string | number | boolean;
1272
-
1273
- /**
1274
- * Variable name identifier
1275
- */
1276
- name: string;
1277
-
1278
- /**
1279
- * Data type of the variable
1280
- */
1281
- type:
1282
- | 'STRING'
1283
- | 'INT'
1284
- | 'FLOAT'
1285
- | 'DATE'
1286
- | 'TIMESTAMP'
1287
- | 'BOOL'
1288
- | 'DIMENSION'
1289
- | 'MEASURE'
1290
- | 'CALCULATION'
1291
- | 'FILTER';
1292
-
1293
- /**
1294
- * Allowed values configuration
1295
- */
1296
- allowed_values?:
1297
- | ResolvedVariable.VariableAllowedValues1
1298
- | ResolvedVariable.VariableAllowedValues2
1299
- | null;
1300
-
1301
- /**
1302
- * Constraints for variable types
1303
- */
1304
- constraints?: ResolvedVariable.Constraints | null;
1305
-
1306
- /**
1307
- * Description of the variable's purpose
1308
- */
1309
- description?: string | null;
1310
-
1311
- /**
1312
- * True if bound_value equals the default value
1313
- */
1314
- is_default?: boolean | null;
1315
-
1316
- /**
1317
- * Human-readable label for the variable
1318
- */
1319
- label?: string | null;
1320
- }
1321
-
1322
- export namespace ResolvedVariable {
1323
- /**
1324
- * Allowed values for a variable - either static list or from column
1325
- */
1326
- export interface VariableAllowedValues1 {
1327
- /**
1328
- * Static list of allowed values with optional labels
1329
- */
1330
- static: Array<VariableAllowedValues1.Static>;
1331
- }
1332
-
1333
- export namespace VariableAllowedValues1 {
1334
- /**
1335
- * A value with optional display label
1336
- */
1337
- export interface Static {
1338
- /**
1339
- * The actual value
1340
- */
1341
- value: string | number | boolean;
1342
-
1343
- /**
1344
- * Human-readable label for the value
1345
- */
1346
- label?: string | null;
1347
- }
1348
- }
1349
-
1350
- /**
1351
- * Allowed values for a variable - either static list or from column
1352
- */
1353
- export interface VariableAllowedValues2 {
1354
- /**
1355
- * Reference to column for dynamic values
1356
- */
1357
- from_column: string;
1358
-
1359
- /**
1360
- * Cache time-to-live in seconds
1361
- */
1362
- cache_ttl?: number;
1363
-
1364
- /**
1365
- * Maximum number of values to retrieve
1366
- */
1367
- limit?: number;
1368
-
1369
- /**
1370
- * Sort order for values
1371
- */
1372
- order_by?: 'asc' | 'desc';
1373
- }
1374
-
1375
- /**
1376
- * Constraints for variable types
1377
- */
1378
- export interface Constraints {
1379
- /**
1380
- * Maximum allowed value
1381
- */
1382
- max?: number | null;
1383
-
1384
- /**
1385
- * Maximum length for STRING variables
1386
- */
1387
- max_length?: number | null;
1388
-
1389
- /**
1390
- * Minimum allowed value
1391
- */
1392
- min?: number | null;
1393
-
1394
- /**
1395
- * Step increment for numeric input
1396
- */
1397
- step?: number | null;
1398
- }
1399
- }
1400
- }
1401
- }
1402
-
1403
- export interface CompilerResolveParams {
1404
- /**
1405
- * Body param: Connection to resolve against
1406
- */
1407
- connection_id: string;
1408
-
1409
- /**
1410
- * Body param: Reference to the query template (e.g. 'ref(MY_QUERY)')
1411
- */
1412
- query_ref: string;
1413
-
1414
- /**
1415
- * Query param
1416
- */
1417
- source?: string | null;
1418
-
1419
- /**
1420
- * Body param: Calculation names to include
1421
- */
1422
- include_calculations?: Array<string>;
1423
-
1424
- /**
1425
- * Body param: Dimension names to include
1426
- */
1427
- include_dimensions?: Array<string>;
1428
-
1429
- /**
1430
- * Body param: Filter names to include
1431
- */
1432
- include_filters?: Array<string>;
1433
-
1434
- /**
1435
- * Body param: Measure names to include
1436
- */
1437
- include_measures?: Array<string>;
1438
-
1439
- /**
1440
- * Body param: User-selected variable values
1441
- */
1442
- variables?: { [key: string]: unknown };
1443
-
1444
- /**
1445
- * Header param
1446
- */
1447
- 'X-Kater-CLI-ID'?: string;
1448
- }
1449
-
1450
- export interface CompilerValidateParams {
1451
- /**
1452
- * Query param
1453
- */
1454
- source?: string | null;
1455
-
1456
- /**
1457
- * Body param: Optional connection IDs to validate. If omitted, validates all
1458
- * connections.
1459
- */
1460
- connection_ids?: Array<string> | null;
1461
-
1462
- /**
1463
- * Header param
1464
- */
1465
- 'X-Kater-CLI-ID'?: string;
1466
- }
1467
-
1468
- export declare namespace Compiler {
1469
- export {
1470
- type ChartConfig as ChartConfig,
1471
- type CompilerErrorItem as CompilerErrorItem,
1472
- type InlineField as InlineField,
1473
- type Manifest as Manifest,
1474
- type ManifestEntry as ManifestEntry,
1475
- type RefWithLabel as RefWithLabel,
1476
- type SubqueryCondition as SubqueryCondition,
1477
- type CompilerCompileResponse as CompilerCompileResponse,
1478
- type CompilerResolveResponse as CompilerResolveResponse,
1479
- type CompilerValidateResponse as CompilerValidateResponse,
1480
- type CompilerCompileParams as CompilerCompileParams,
1481
- type CompilerResolveParams as CompilerResolveParams,
1482
- type CompilerValidateParams as CompilerValidateParams,
1483
- };
1484
- }
3
+ export * from './compiler/index';