@holistics/anfra-sdk 0.20.0 → 0.22.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 (38) hide show
  1. package/README.md +5 -0
  2. package/dist/api.d.ts +11 -8
  3. package/dist/api.js +45 -22
  4. package/dist/app.d.ts +5 -5
  5. package/dist/app.js +5 -4
  6. package/dist/{bootstrap-DHU2haC5.d.ts → bootstrap-fGoj2ap1.d.ts} +324 -27
  7. package/dist/build.d.ts +2 -2
  8. package/dist/{chunk-32566ZNE.js → chunk-2TTGSNHA.js} +1 -1
  9. package/dist/{chunk-H52PO7MP.js → chunk-33HI2ODM.js} +25 -0
  10. package/dist/chunk-4UEESYHH.js +32 -0
  11. package/dist/{chunk-KKSOTHP4.js → chunk-7GQZU5FL.js} +1 -1
  12. package/dist/{chunk-4TXKXLWK.js → chunk-7I2HXY72.js} +1 -1
  13. package/dist/{chunk-DITKCHFQ.js → chunk-CLXZMA5D.js} +1 -1
  14. package/dist/{chunk-GBXK7F2V.js → chunk-D7DIJRAC.js} +14 -1
  15. package/dist/{chunk-ACKFOANJ.js → chunk-DWQUIHUX.js} +4 -1
  16. package/dist/{chunk-FTTVLHNN.js → chunk-EOFPMSND.js} +1 -1
  17. package/dist/{chunk-SXKJQU7A.js → chunk-GPBYPSWK.js} +22 -36
  18. package/dist/{chunk-EIPHDMZ7.js → chunk-UWRQXPPG.js} +69 -24
  19. package/dist/{chunk-T5T76SAR.js → chunk-YPGMBSOZ.js} +1209 -274
  20. package/dist/common.d.ts +3 -3
  21. package/dist/common.js +1 -1
  22. package/dist/{data-ESPFZ5IM.js → data-SZDYO55C.js} +7 -5
  23. package/dist/{declaration-RYRBX7PH.js → declaration-GYV6OUR3.js} +5 -3
  24. package/dist/{errors-189T_Mnc.d.ts → errors-kH5eHvNO.d.ts} +1 -1
  25. package/dist/host.d.ts +2 -2
  26. package/dist/host.js +31 -8
  27. package/dist/{overview-AWPXJACF.js → overview-CD6NY3VQ.js} +28 -13
  28. package/dist/{plugin-rRd-zHGt.d.ts → plugin-DG2NDTCT.d.ts} +7 -2
  29. package/dist/plugins.d.ts +1 -7
  30. package/dist/plugins.js +53 -17
  31. package/dist/{queries-FWMX7H5Z.js → queries-BWKWZQMG.js} +70 -17
  32. package/dist/{structure-VFRJFC4C.js → structure-JO4YZHKZ.js} +5 -3
  33. package/dist/{tab-XL2HS5W4.js → tab-QPHE7YUQ.js} +3 -3
  34. package/dist/testing.d.ts +2 -1
  35. package/dist/testing.js +8 -7
  36. package/dist/{menu-Cam-hOdJ.d.ts → theme-FQ_1b569.d.ts} +72 -55
  37. package/dist/{types-N0V9n38H.d.ts → types-BE767W6G.d.ts} +879 -129
  38. package/package.json +1 -1
@@ -4,6 +4,50 @@
4
4
  */
5
5
 
6
6
  interface paths {
7
+ "/core.cache.clean": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ get?: never;
15
+ put?: never;
16
+ /**
17
+ * Remove results from the repo's query cache, so that queries run on the warehouse again
18
+ * @description Remove results from the repo's query cache, so that queries run on the warehouse again.
19
+ *
20
+ * Clean after fixing data in the warehouse: from then on, no query is answered from a result read before the clean, including one still being written when it ran. Select what to remove by what the queries read, such as --query.data-source or --query.dataset. Without any, every cache of the repo is cleaned: today, every result of its query cache.
21
+ */
22
+ post: operations["core.cache.clean"];
23
+ delete?: never;
24
+ options?: never;
25
+ head?: never;
26
+ patch?: never;
27
+ trace?: never;
28
+ };
29
+ "/core.cache.status": {
30
+ parameters: {
31
+ query?: never;
32
+ header?: never;
33
+ path?: never;
34
+ cookie?: never;
35
+ };
36
+ get?: never;
37
+ put?: never;
38
+ /**
39
+ * Show what the repo's caches hold, and where
40
+ * @description Show what the repo's caches hold, and where: for the query cache, its state, its folder, its settings, and how many results it holds and their size.
41
+ *
42
+ * It reads the caches without changing them. anfra status shows the same state, without the counts.
43
+ */
44
+ post: operations["core.cache.status"];
45
+ delete?: never;
46
+ options?: never;
47
+ head?: never;
48
+ patch?: never;
49
+ trace?: never;
50
+ };
7
51
  "/core.ingest": {
8
52
  parameters: {
9
53
  query?: never;
@@ -54,9 +98,9 @@ interface paths {
54
98
  * Run a query, and return its rows and the SQL that produced them
55
99
  * @description Run a query, and return a page of its rows and the SQL that produced them.
56
100
  *
57
- * A page is page_size rows, or the first 10000 without it, and has_more says whether there may be more. Rather than paging through many rows, ask the query for what you need: an aggregate, a filter, or a limit: directive. To get every row of a large result, export it.
101
+ * A page is input.pagination.pageSize rows, or the first 10000 without it, and has_more says whether there may be more. Rather than paging through many rows, ask the query for what you need: an aggregate, a filter, or a limit: directive. To get every row of a large result, export it.
58
102
  *
59
- * Over HTTP, a request that accepts application/x-ndjson gets the result as the query runs: its phase, its SQL, its columns, then its rows in batches. Without page_size, that's every row, up to the server's maximum.
103
+ * Over HTTP, a request that accepts application/x-ndjson gets the result as the query runs: its phase, its SQL, its columns, then its rows in batches. Without input.pagination, that's every row, up to the server's maximum.
60
104
  */
61
105
  post: operations["core.query"];
62
106
  delete?: never;
@@ -230,6 +274,63 @@ interface components {
230
274
  message: string;
231
275
  severity: string;
232
276
  };
277
+ CacheCleanRequestParams: {
278
+ /** @description the query cache's entries to remove, by what their queries read. Every field given must match, and with none, every entry of the query cache is removed. Without query, every cache of the repo is cleaned, which today is the query cache alone. */
279
+ query?: components["schemas"]["QueryCacheSelector"];
280
+ };
281
+ CacheCleanResult: {
282
+ /** @description what was removed from the query cache */
283
+ query?: components["schemas"]["QueryCacheCleaned"];
284
+ };
285
+ CacheOptions: {
286
+ /** @description true answers from a cached result, or fails with cache_miss without running the query. */
287
+ cached_only?: boolean;
288
+ /** @description how old a cached result the query accepts, and how long the result it caches is kept, such as 10m or 1h, at most 168h (7 days). 0s turns the cache off for this query. The repo's query.default.cache.duration by default. */
289
+ duration?: string;
290
+ /** @description the earliest time a cached result may have been read from the warehouse, as an RFC 3339 time, such as 2026-11-16T09:30:00.123Z. A result cached before it is treated as not cached. Send the cache.cached_at of a run's first page with the run's later pages and its export, so that none of them is older than that page. */
291
+ min_cached_at?: string;
292
+ /** @description true answers from a cached result if there is one, and otherwise runs the query without caching its result. */
293
+ read_only?: boolean;
294
+ /** @description true runs the query on the warehouse whatever is cached, and caches its result. */
295
+ refresh?: boolean;
296
+ };
297
+ CacheResult: {
298
+ /**
299
+ * Format: date-time
300
+ * @description when the cached rows were read from the warehouse. Absent when the result wasn't cached.
301
+ */
302
+ cached_at?: string;
303
+ /**
304
+ * Format: date-time
305
+ * @description when the cached result stops being used. Absent when the result wasn't cached.
306
+ */
307
+ expires_at?: string;
308
+ /** @description whether the rows came from the cache. false: they came from the warehouse. */
309
+ hit: boolean;
310
+ /** @description the query's key in the cache. Absent when the cache couldn't make one. */
311
+ key?: string;
312
+ /** @description why the query ran without the cache, though it asked for it */
313
+ warning?: components["schemas"]["CacheWarning"];
314
+ };
315
+ CacheStatus: {
316
+ /** @description the query cache, which keeps queries' results */
317
+ query: components["schemas"]["Summary"];
318
+ };
319
+ CacheStatusRequestParams: Record<string, never>;
320
+ CacheStatusResult: {
321
+ /** @description what to do about a problem the caches have, if any */
322
+ hints?: string[];
323
+ /** @description the query cache. Absent when the server keeps none. */
324
+ query?: components["schemas"]["QueryCacheStatus"];
325
+ };
326
+ CacheWarning: {
327
+ /**
328
+ * @description cache_unavailable: the cache isn't working. cache_disabled: the repo, or whoever runs anfra, turned it off.
329
+ * @enum {string}
330
+ */
331
+ code: "cache_unavailable" | "cache_disabled";
332
+ message: string;
333
+ };
233
334
  Column: {
234
335
  /** @description a query-local expression, not a field the dataset defines */
235
336
  adhoc: boolean;
@@ -260,6 +361,18 @@ interface components {
260
361
  */
261
362
  semantic_type?: "bit" | "date" | "datetime" | "json" | "number" | "text" | "truefalse" | "unknown";
262
363
  };
364
+ ColumnPage: {
365
+ /**
366
+ * Format: int64
367
+ * @description the 1-based page of columns to return, 1 by default
368
+ */
369
+ page?: number;
370
+ /**
371
+ * Format: int64
372
+ * @description how many of the grid's columns a page has
373
+ */
374
+ pageSize: number;
375
+ };
263
376
  CompileError: {
264
377
  /** Format: int64 */
265
378
  col?: number;
@@ -273,6 +386,8 @@ interface components {
273
386
  aql?: string;
274
387
  /** @description what each column of an explore query's result will be, with its semantic type. Absent for other queries. */
275
388
  columns?: components["schemas"]["Column"][];
389
+ /** @description the query's input as it compiled, every default filled in, its seeds included. Send it back with the same query to compile it the same way again. Absent for a SQL query. */
390
+ input?: components["schemas"]["QueryInput"];
276
391
  sql: string;
277
392
  };
278
393
  ContextEntry: {
@@ -382,6 +497,42 @@ interface components {
382
497
  nodes: components["schemas"]["DiagramNode"][];
383
498
  type: string;
384
499
  };
500
+ /** @description The query cache is turned off. */
501
+ ErrorBodyCacheDisabled: {
502
+ /** @constant */
503
+ code: "cache_disabled";
504
+ context?: components["schemas"]["ContextEntry"][];
505
+ message: string;
506
+ request_id: string;
507
+ /** @constant */
508
+ scope: "user";
509
+ /** @constant */
510
+ status: 500;
511
+ };
512
+ /** @description The query's result isn't cached. */
513
+ ErrorBodyCacheMiss: {
514
+ /** @constant */
515
+ code: "cache_miss";
516
+ context?: components["schemas"]["ContextEntry"][];
517
+ message: string;
518
+ request_id: string;
519
+ /** @constant */
520
+ scope: "client";
521
+ /** @constant */
522
+ status: 500;
523
+ };
524
+ /** @description The query cache isn't working. */
525
+ ErrorBodyCacheUnavailable: {
526
+ /** @constant */
527
+ code: "cache_unavailable";
528
+ context?: components["schemas"]["ContextEntry"][];
529
+ message: string;
530
+ request_id: string;
531
+ /** @constant */
532
+ scope: "server";
533
+ /** @constant */
534
+ status: 500;
535
+ };
385
536
  /** @description This server cannot make exports. */
386
537
  ErrorBodyExportsUnavailable: {
387
538
  /** @constant */
@@ -457,6 +608,18 @@ interface components {
457
608
  /** @constant */
458
609
  status: 422;
459
610
  };
611
+ /** @description The repo's settings can't be used. */
612
+ ErrorBodyRepoSettingsInvalid: {
613
+ /** @constant */
614
+ code: "repo_settings_invalid";
615
+ context?: components["schemas"]["ContextEntry"][];
616
+ message: string;
617
+ request_id: string;
618
+ /** @constant */
619
+ scope: "user";
620
+ /** @constant */
621
+ status: 500;
622
+ };
460
623
  /** @description The query's result is larger than this server allows. */
461
624
  ErrorBodyResultTooLarge: {
462
625
  /** @constant */
@@ -495,6 +658,18 @@ interface components {
495
658
  /** @constant */
496
659
  status: 422;
497
660
  };
661
+ Expired: {
662
+ /**
663
+ * Format: int64
664
+ * @description their size
665
+ */
666
+ bytes: number;
667
+ /**
668
+ * Format: int64
669
+ * @description how many
670
+ */
671
+ entries: number;
672
+ };
498
673
  ExportFormatOptions: {
499
674
  /** @description csv: start the file with a UTF-8 byte-order mark, which Excel needs to read non-ASCII text; set it for a file a person will open */
500
675
  bom?: boolean;
@@ -504,52 +679,6 @@ interface components {
504
679
  */
505
680
  header?: "labels" | "names" | "none";
506
681
  };
507
- ExportInput: {
508
- /** @description the data source a SQL query runs against */
509
- data_source?: string;
510
- /** @description the dataset an AQL query runs against */
511
- dataset?: string;
512
- /** @description the file's name, as a download saves it, with the format's extension added when it has none; when unset or blank, the dataset's or data source's name */
513
- filename?: string;
514
- /**
515
- * @description the file's format
516
- * @default csv
517
- * @enum {string}
518
- */
519
- format?: "csv";
520
- /** @description the format's options */
521
- format_options?: components["schemas"]["ExportFormatOptions"];
522
- /** @description the Query Input: filters, conditions, sorts and date drills applied to the AQL before it compiles */
523
- input?: components["schemas"]["QueryTransforms"];
524
- /**
525
- * @description the language the query is written in
526
- * @default aql
527
- * @enum {string}
528
- */
529
- lang?: "aql" | "sql";
530
- /** @description the query */
531
- query: string;
532
- /** @description the IANA time zone that relative dates and date truncation use, such as Asia/Ho_Chi_Minh, for AQL only */
533
- timezone?: string;
534
- };
535
- ExportLink: {
536
- /**
537
- * Format: date-time
538
- * @description when the link stops working
539
- */
540
- expires_at: string;
541
- /** @description the file's name, as a download saves it */
542
- filename: string;
543
- /** @description the file's format */
544
- format: string;
545
- /**
546
- * Format: int64
547
- * @description how many rows the file holds
548
- */
549
- row_count: number;
550
- /** @description where to download the file: a plain GET, with no credentials, until expires_at */
551
- url: string;
552
- };
553
682
  FieldLineage: {
554
683
  /** @description the field's lineage. Absent when error is set. */
555
684
  diagram?: components["schemas"]["Diagram"];
@@ -592,9 +721,146 @@ interface components {
592
721
  /** Format: int64 */
593
722
  max_bytes: number;
594
723
  };
724
+ Pagination: {
725
+ /** @description for a pivot, one page of its grid's columns. Without it, every column. Refused for a query that isn't a pivot. */
726
+ columns?: components["schemas"]["ColumnPage"];
727
+ /**
728
+ * Format: int64
729
+ * @description the 1-based page of rows to return, 1 by default
730
+ */
731
+ page?: number;
732
+ /**
733
+ * Format: int64
734
+ * @description how many rows a page has: of the result, or for a pivot, of its grid, each with every row of its cells, the header rows and the totals
735
+ */
736
+ pageSize: number;
737
+ };
738
+ PivotPage: {
739
+ /**
740
+ * Format: int64
741
+ * @description how many columns the pivot's grid has, the total column not counted
742
+ */
743
+ columns: number;
744
+ /** @description with input.pagination.columns: whether there are columns after this page's */
745
+ has_more_columns?: boolean;
746
+ /**
747
+ * Format: int64
748
+ * @description how many rows the pivot's grid has, in all of its pages, the grand total not counted
749
+ */
750
+ rows: number;
751
+ };
752
+ QueryCacheCleaned: {
753
+ /**
754
+ * Format: int64
755
+ * @description their size, in bytes. Their files are deleted by a sweep once they've been expired for 35 minutes, so that a read that began before the clean can finish. anfra serve sweeps every few minutes, and so does the next clean.
756
+ */
757
+ bytes: number;
758
+ /**
759
+ * Format: int64
760
+ * @description how many cached results were removed. From now on, no query is answered from a result read before the clean, including one still being written when it ran.
761
+ */
762
+ entries: number;
763
+ /** @description the files deleted by this clean: those of results expired for more than 35 minutes, by this clean or before it. Absent when they couldn't be deleted, in which case the next sweep tries again. */
764
+ freed?: components["schemas"]["QueryFreed"];
765
+ };
766
+ QueryCacheContents: {
767
+ /**
768
+ * Format: int64
769
+ * @description their size, as the rows were streamed
770
+ */
771
+ bytes: number;
772
+ /**
773
+ * Format: int64
774
+ * @description how many cached results queries can be answered from: committed, and not expired
775
+ */
776
+ entries: number;
777
+ /** @description results no query uses any more, expired, cleaned or abandoned, whose files are deleted by the next sweep */
778
+ expired: components["schemas"]["Expired"];
779
+ /**
780
+ * Format: date-time
781
+ * @description when the newest of those results was read from the warehouse. Absent without any.
782
+ */
783
+ newest_cached_at?: string;
784
+ /**
785
+ * Format: date-time
786
+ * @description when the oldest of those results was read from the warehouse. Absent without any.
787
+ */
788
+ oldest_cached_at?: string;
789
+ /**
790
+ * Format: int64
791
+ * @description results being written now, by queries still running
792
+ */
793
+ writing: number;
794
+ };
795
+ QueryCacheSelector: {
796
+ /** @description entries of queries run on this data source */
797
+ data_source?: string;
798
+ /** @description entries of queries run against this dataset */
799
+ dataset?: string;
800
+ };
801
+ QueryCacheSettings: {
802
+ /** @description the cache.duration of a query that sets none (query.default.cache.duration in .anfra/config.yml) */
803
+ default_duration?: string;
804
+ /** @description the longest a query's result may be cached, when the repo sets less than 168h (query.cache.max_duration in .anfra/config.yml) */
805
+ max_duration?: string;
806
+ /** @description the subfolder of canal-lake's storage the cache's files go in (ANFRA_CACHE_QUERY_NAMESPACE) */
807
+ namespace?: string;
808
+ };
809
+ QueryCacheStatus: {
810
+ /** @description what the cache holds, when it is ready */
811
+ contents?: components["schemas"]["QueryCacheContents"];
812
+ /** @description the cache's folder on this machine: its store, and the results of the canal-lake anfra starts. Absent when the cache is disabled, or the server keeps it elsewhere. */
813
+ folder?: string;
814
+ /** @description what's wrong with the cache, when it is incompatible or unavailable */
815
+ problem?: string;
816
+ /** @description what turns the cache off, when it is disabled */
817
+ reason?: string;
818
+ /** @description the settings the cache runs with, those that are set */
819
+ settings?: components["schemas"]["QueryCacheSettings"];
820
+ /**
821
+ * @description "ready": the cache can be used. "incompatible": a newer anfra changed the cache's store in a way this anfra can't read. "unavailable": the cache's store can't be used, as "problem" says. "disabled": the query cache is turned off, as "reason" says.
822
+ * @enum {string}
823
+ */
824
+ state: "ready" | "incompatible" | "unavailable" | "disabled";
825
+ };
826
+ QueryCompileRequestParams: {
827
+ /** @description the data source a SQL query runs against */
828
+ data_source?: string;
829
+ /** @description the dataset an AQL query runs against */
830
+ dataset?: string;
831
+ /** @description the query's input, for AQL only: the Query Input (filters, conditions, sorts and date drills applied to the AQL before it compiles), a page of rows, the time zone, and the seeds. The answer returns it as the query compiled: send it back with the same query to get the same SQL again. */
832
+ input?: components["schemas"]["QueryInput"];
833
+ /**
834
+ * @description the language the query is written in
835
+ * @default aql
836
+ * @enum {string}
837
+ */
838
+ lang?: "aql" | "sql";
839
+ /**
840
+ * Format: int64
841
+ * @deprecated
842
+ * @description deprecated: use input.pagination.page. Ignored when input.pagination is set.
843
+ */
844
+ page?: number;
845
+ /**
846
+ * Format: int64
847
+ * @deprecated
848
+ * @description deprecated: use input.pagination.pageSize. Ignored when input.pagination is set.
849
+ */
850
+ page_size?: number;
851
+ /** @description the query */
852
+ query: string;
853
+ /**
854
+ * @deprecated
855
+ * @description deprecated: use input.timezone. Ignored when input.timezone is set.
856
+ */
857
+ timezone?: string;
858
+ };
595
859
  QueryCompiled: {
596
860
  /** @description the final AQL (with the Query Input applied). Absent for a SQL query. */
597
861
  aql?: string;
862
+ /** @description the query's input as it runs, every default filled in, its seeds included. Send it back with the same query to get the same answer again. Absent for a SQL query. */
863
+ input?: components["schemas"]["QueryInput"];
598
864
  sql: string;
599
865
  /**
600
866
  * @description discriminator enum property added by openapi-typescript
@@ -612,6 +878,73 @@ interface components {
612
878
  /** @description the grain, such as month */
613
879
  grain: string;
614
880
  };
881
+ QueryDefinition: {
882
+ /** @description the data source a SQL query runs against */
883
+ data_source?: string;
884
+ /** @description the dataset an AQL query runs against */
885
+ dataset?: string;
886
+ /**
887
+ * @description the language the query is written in
888
+ * @default aql
889
+ * @enum {string}
890
+ */
891
+ lang?: "aql" | "sql";
892
+ /** @description the query */
893
+ query: string;
894
+ };
895
+ QueryExportRequestParams: {
896
+ /** @description how to use the query cache for this export, as query does: the file is written from a cached result of the same query, or the query runs and its whole result is cached. An export uses it when it sets cache.duration, or when the repo sets a default (query.default.cache.duration). Otherwise it runs on the warehouse, uncached. */
897
+ cache?: components["schemas"]["CacheOptions"];
898
+ /** @description the data source a SQL query runs against */
899
+ data_source?: string;
900
+ /** @description the dataset an AQL query runs against */
901
+ dataset?: string;
902
+ /** @description the file's name, as a download saves it, with the format's extension added when it has none; when unset or blank, the dataset's or data source's name */
903
+ filename?: string;
904
+ /**
905
+ * @description the file's format
906
+ * @default csv
907
+ * @enum {string}
908
+ */
909
+ format?: "csv";
910
+ /** @description the format's options */
911
+ format_options?: components["schemas"]["ExportFormatOptions"];
912
+ /** @description the query's input, for AQL only: the Query Input (filters, conditions, sorts and date drills applied to the AQL before it compiles), a page of rows, the time zone, and the seeds. With input.pagination, the file holds that page; without, every row. */
913
+ input?: components["schemas"]["QueryInput"];
914
+ /**
915
+ * @description the language the query is written in
916
+ * @default aql
917
+ * @enum {string}
918
+ */
919
+ lang?: "aql" | "sql";
920
+ /** @description the query */
921
+ query: string;
922
+ /**
923
+ * @deprecated
924
+ * @description deprecated: use input.timezone. Ignored when input.timezone is set.
925
+ */
926
+ timezone?: string;
927
+ };
928
+ QueryExportResult: {
929
+ /** @description what the query cache did for the export's query: whether the file was written from a cached result, and when its rows were read from the warehouse. Absent when the export doesn't use the cache: it sets no cache.duration and the repo no default, or 0s. */
930
+ cache?: components["schemas"]["CacheResult"];
931
+ /**
932
+ * Format: date-time
933
+ * @description when the link stops working
934
+ */
935
+ expires_at: string;
936
+ /** @description the file's name, as a download saves it */
937
+ filename: string;
938
+ /** @description the file's format */
939
+ format: string;
940
+ /**
941
+ * Format: int64
942
+ * @description how many rows the file holds
943
+ */
944
+ row_count: number;
945
+ /** @description where to download the file: a plain GET, with no credentials, until expires_at */
946
+ url: string;
947
+ };
615
948
  QueryFilter: {
616
949
  /** @description the aggregation to apply to the field before filtering, such as sum */
617
950
  aggregation?: string;
@@ -624,6 +957,18 @@ interface components {
624
957
  /** @description the operator's values, empty for an operator that takes none. Write a number as a string, such as "9007199254740993", because a JSON number may have lost digits and is refused. Write a date or text as a string too, and a truefalse value as true or false. */
625
958
  values: unknown[];
626
959
  };
960
+ QueryFreed: {
961
+ /**
962
+ * Format: int64
963
+ * @description their size, in bytes
964
+ */
965
+ bytes: number;
966
+ /**
967
+ * Format: int64
968
+ * @description how many results' files were deleted
969
+ */
970
+ entries: number;
971
+ };
627
972
  QueryHeader: {
628
973
  /** @description one per field, in order */
629
974
  columns: components["schemas"]["Column"][];
@@ -632,38 +977,86 @@ interface components {
632
977
  * @description discriminator enum property added by openapi-typescript
633
978
  * @enum {string}
634
979
  */
635
- type: "header";
980
+ type: "header";
981
+ };
982
+ QueryInput: {
983
+ /** @description AQL conditions ANDed with the query's own filters */
984
+ conditions?: components["schemas"]["QueryCondition"][];
985
+ /** @description grain changes on date fields. The fields keep their column names. */
986
+ dateDrills?: components["schemas"]["QueryDateDrill"][];
987
+ /** @description conditions on fields, ANDed with the query's own filters */
988
+ filters?: components["schemas"]["QueryFilter"][];
989
+ /** @description which rows to return: pageSize rows, from the 1-based page; for a pivot, pageSize rows of its grid. Without it, every row. */
990
+ pagination?: components["schemas"]["Pagination"];
991
+ /** @description values the server generates for each request when they're unset. Generated seeds typically change with every request, and the response returns them. Set seeds to generate the same SQL again, for example to replay a query as of a given time. */
992
+ seeds?: components["schemas"]["Seeds"];
993
+ /** @description sorts by result column, replacing the query's own */
994
+ sorts?: components["schemas"]["QuerySort"][];
995
+ /** @description the IANA time zone that relative dates and date truncation use, such as Asia/Ho_Chi_Minh. The repo's query.default.input.timezone by default, or else UTC. */
996
+ timezone?: string;
997
+ /**
998
+ * @description the day weeks start on, for grouping by week, relative dates such as this week, and the day of the week's number. The repo's query.default.input.weekStartDay by default, or else monday.
999
+ * @enum {string}
1000
+ */
1001
+ weekStartDay?: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
1002
+ };
1003
+ QueryRecords: {
1004
+ /** @description one array per row, its values in fields' order, written as a page's records are */
1005
+ records: unknown[][];
1006
+ /**
1007
+ * @description discriminator enum property added by openapi-typescript
1008
+ * @enum {string}
1009
+ */
1010
+ type: "rows";
636
1011
  };
637
- QueryInput: {
1012
+ QueryRequestParams: {
1013
+ /** @description how to use the query cache for this request. A query uses it when it sets cache.duration, or when the repo sets a default (query.default.cache.duration). Otherwise it runs on the warehouse, uncached. */
1014
+ cache?: components["schemas"]["CacheOptions"];
638
1015
  /** @description the data source a SQL query runs against */
639
1016
  data_source?: string;
640
1017
  /** @description the dataset an AQL query runs against */
641
1018
  dataset?: string;
1019
+ /** @description the query's input, for AQL only: the Query Input (filters, conditions, sorts and date drills applied to the AQL before it compiles), a page of rows, the time zone, and the seeds. The answer returns it as the query ran: send it back with the same query to get the same answer again. */
1020
+ input?: components["schemas"]["QueryInput"];
642
1021
  /**
643
1022
  * @description the language the query is written in
644
1023
  * @default aql
645
1024
  * @enum {string}
646
1025
  */
647
1026
  lang?: "aql" | "sql";
1027
+ /**
1028
+ * Format: int64
1029
+ * @deprecated
1030
+ * @description deprecated: use input.pagination.page. Ignored when input.pagination is set.
1031
+ */
1032
+ page?: number;
1033
+ /**
1034
+ * Format: int64
1035
+ * @deprecated
1036
+ * @description deprecated: use input.pagination.pageSize. Ignored when input.pagination is set.
1037
+ */
1038
+ page_size?: number;
648
1039
  /** @description the query */
649
1040
  query: string;
650
- };
651
- QueryRecords: {
652
- /** @description one array per row, its values in fields' order, written as a page's records are */
653
- records: unknown[][];
654
1041
  /**
655
- * @description discriminator enum property added by openapi-typescript
656
- * @enum {string}
1042
+ * @deprecated
1043
+ * @description deprecated: use input.timezone. Ignored when input.timezone is set.
657
1044
  */
658
- type: "rows";
1045
+ timezone?: string;
659
1046
  };
660
1047
  QueryResult: {
661
1048
  /** @description the final AQL (with the Query Input applied). Absent for a SQL query. */
662
1049
  aql?: string;
1050
+ /** @description what the query cache did for this query. Absent when the query doesn't use the cache: it sets no cache.duration and the repo no default, or 0s. */
1051
+ cache?: components["schemas"]["CacheResult"];
663
1052
  /** @description one per field of result, in order */
664
1053
  columns: components["schemas"]["Column"][];
665
- /** @description whether there may be rows after this page. To get them, ask for the next page, or export the query. */
1054
+ /** @description whether there are rows after this page; for a pivot, rows of its grid. To get them, ask for the next page, or export the query. */
666
1055
  has_more: boolean;
1056
+ /** @description the query's input as it ran, every default filled in, its seeds included. Send it back with the same query to get the same answer again. Absent for a SQL query. */
1057
+ input?: components["schemas"]["QueryInput"];
1058
+ /** @description for a page of a pivot: its grid's size, and whether there are columns after this page's. Absent for any other query. */
1059
+ pivot?: components["schemas"]["PivotPage"];
667
1060
  result: components["schemas"]["QueryRows"];
668
1061
  sql: string;
669
1062
  /** @description the query's steps, and when each started. The steps are compiling_query (for AQL only), connecting_to_dw, executing_query, fetching_query_result, and retrying_query, which is a wait before the query is tried again. connecting_to_dw, executing_query, and fetching_query_result may have child steps. */
@@ -674,34 +1067,6 @@ interface components {
674
1067
  /** @description one array per row, its values in fields' order. Read each value by its column's types. Every number is a string with all its digits, because a JSON number loses some in JavaScript. A float's NaN and infinities are "NaN", "Infinity", and "-Infinity". The same holds at any depth of a list, map, or struct. A database NULL is null. */
675
1068
  records: unknown[][];
676
1069
  };
677
- QueryRunInput: {
678
- /** @description the data source a SQL query runs against */
679
- data_source?: string;
680
- /** @description the dataset an AQL query runs against */
681
- dataset?: string;
682
- /** @description the Query Input: filters, conditions, sorts and date drills applied to the AQL before it compiles */
683
- input?: components["schemas"]["QueryTransforms"];
684
- /**
685
- * @description the language the query is written in
686
- * @default aql
687
- * @enum {string}
688
- */
689
- lang?: "aql" | "sql";
690
- /**
691
- * Format: int64
692
- * @description the 1-based page of rows to return, 1 by default, for AQL only. Needs page_size.
693
- */
694
- page?: number;
695
- /**
696
- * Format: int64
697
- * @description how many rows a page has, for AQL only
698
- */
699
- page_size?: number;
700
- /** @description the query */
701
- query: string;
702
- /** @description the IANA time zone that relative dates and date truncation use, such as Asia/Ho_Chi_Minh, for AQL only */
703
- timezone?: string;
704
- };
705
1070
  QuerySort: {
706
1071
  /**
707
1072
  * @description the direction
@@ -717,8 +1082,12 @@ interface components {
717
1082
  * @description the bytes the warehouse read to run the query, where it reports them (BigQuery, Athena)
718
1083
  */
719
1084
  bytes_scanned?: number;
720
- /** @description whether there may be rows after this page. Without page_size, every row was sent, and this is false. */
1085
+ /** @description what the query cache did for this query. Absent when the query doesn't use the cache: it sets no cache.duration and the repo no default, or 0s. */
1086
+ cache?: components["schemas"]["CacheResult"];
1087
+ /** @description whether there are rows after this page; for a pivot, rows of its grid. Without input.pagination, every row was sent, and this is false. */
721
1088
  has_more: boolean;
1089
+ /** @description for a page of a pivot: its grid's size, and whether there are columns after this page's. Absent for any other query. */
1090
+ pivot?: components["schemas"]["PivotPage"];
722
1091
  /** Format: int64 */
723
1092
  row_count: number;
724
1093
  /** @description the query's steps, and when each started. The steps are compiling_query (for AQL only), connecting_to_dw, executing_query, fetching_query_result, and retrying_query, which is a wait before the query is tried again. connecting_to_dw, executing_query, and fetching_query_result may have child steps. */
@@ -729,16 +1098,6 @@ interface components {
729
1098
  */
730
1099
  type: "summary";
731
1100
  };
732
- QueryTransforms: {
733
- /** @description AQL conditions ANDed with the query's own filters */
734
- conditions?: components["schemas"]["QueryCondition"][];
735
- /** @description grain changes on date fields. The fields keep their column names. */
736
- dateDrills?: components["schemas"]["QueryDateDrill"][];
737
- /** @description conditions on fields, ANDed with the query's own filters */
738
- filters?: components["schemas"]["QueryFilter"][];
739
- /** @description sorts by result column, replacing the query's own */
740
- sorts?: components["schemas"]["QuerySort"][];
741
- };
742
1101
  QueryValidation: {
743
1102
  diagnostics: components["schemas"]["AQLDiagnostic"][];
744
1103
  valid: boolean;
@@ -755,7 +1114,7 @@ interface components {
755
1114
  RepoStatus: {
756
1115
  /** @description the repo's id, which names its state folder: <ANFRA_HOME>/repos/<id> */
757
1116
  id: string;
758
- /** @description the repo's log file, which holds anfra's and its sidecars' logs. Absent for a managed repo. */
1117
+ /** @description the repo's log file, which holds anfra's and its sidecars' logs, and which anfra logs shows. Absent for a managed repo. */
759
1118
  logs?: string;
760
1119
  };
761
1120
  RepoValidation: {
@@ -805,6 +1164,13 @@ interface components {
805
1164
  /** @description search query */
806
1165
  query?: string[];
807
1166
  };
1167
+ Seeds: {
1168
+ /**
1169
+ * Format: date-time
1170
+ * @description the time the query runs as of. Relative dates, such as last 7 days, are counted from this time's day.
1171
+ */
1172
+ referenceTime?: string;
1173
+ };
808
1174
  ServerStatus: {
809
1175
  instance_id?: string;
810
1176
  sidecars?: components["schemas"]["SidecarHealth"];
@@ -893,6 +1259,8 @@ interface components {
893
1259
  version?: string;
894
1260
  };
895
1261
  StatusResult: {
1262
+ /** @description the repo's caches, read without changing them. Absent when the server keeps none. */
1263
+ cache?: components["schemas"]["CacheStatus"];
896
1264
  /** @description what to do next, if any */
897
1265
  hints?: string[];
898
1266
  repo: components["schemas"]["RepoStatus"];
@@ -937,6 +1305,19 @@ interface components {
937
1305
  */
938
1306
  type: "status";
939
1307
  };
1308
+ Summary: {
1309
+ /** @description what's wrong with the cache, when it is incompatible or unavailable */
1310
+ problem?: string;
1311
+ /** @description what turns the cache off, when it is disabled */
1312
+ reason?: string;
1313
+ /**
1314
+ * @description "ready": the cache can be used, and needs nothing. "incompatible": a newer anfra changed the cache's store in a way this anfra can't read. "unavailable": the cache's store can't be used, as "problem" says. "disabled": the query cache is turned off, as "reason" says. Queries run without the cache unless it's "ready".
1315
+ * @enum {string}
1316
+ */
1317
+ state: "ready" | "incompatible" | "unavailable" | "disabled";
1318
+ /** @description the query cache's store, a file. Absent when the cache is disabled, or the server keeps its store elsewhere. */
1319
+ store?: string;
1320
+ };
940
1321
  TimedStep: {
941
1322
  /**
942
1323
  * Format: int64
@@ -999,6 +1380,131 @@ interface components {
999
1380
  pathItems: never;
1000
1381
  }
1001
1382
  interface operations {
1383
+ "core.cache.clean": {
1384
+ parameters: {
1385
+ query?: never;
1386
+ header?: never;
1387
+ path?: never;
1388
+ cookie?: never;
1389
+ };
1390
+ requestBody: {
1391
+ content: {
1392
+ "application/json": components["schemas"]["CacheCleanRequestParams"];
1393
+ };
1394
+ };
1395
+ responses: {
1396
+ /** @description OK */
1397
+ 200: {
1398
+ headers: {
1399
+ [name: string]: unknown;
1400
+ };
1401
+ content: {
1402
+ "application/json": components["schemas"]["CacheCleanResult"];
1403
+ };
1404
+ };
1405
+ /** @description invalid_request */
1406
+ 400: {
1407
+ headers: {
1408
+ [name: string]: unknown;
1409
+ };
1410
+ content: {
1411
+ "application/json": {
1412
+ error: components["schemas"]["ErrorBodyInvalidRequest"];
1413
+ };
1414
+ };
1415
+ };
1416
+ /** @description validation_failed */
1417
+ 422: {
1418
+ headers: {
1419
+ [name: string]: unknown;
1420
+ };
1421
+ content: {
1422
+ "application/json": {
1423
+ error: components["schemas"]["ErrorBodyValidationFailed"];
1424
+ };
1425
+ };
1426
+ };
1427
+ /** @description internal_server_error, cache_disabled, cache_unavailable */
1428
+ 500: {
1429
+ headers: {
1430
+ [name: string]: unknown;
1431
+ };
1432
+ content: {
1433
+ "application/json": {
1434
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyCacheDisabled"] | components["schemas"]["ErrorBodyCacheUnavailable"];
1435
+ };
1436
+ };
1437
+ };
1438
+ /** @description sidecar_unavailable */
1439
+ 503: {
1440
+ headers: {
1441
+ [name: string]: unknown;
1442
+ };
1443
+ content: {
1444
+ "application/json": {
1445
+ error: components["schemas"]["ErrorBodySidecarUnavailable"];
1446
+ };
1447
+ };
1448
+ };
1449
+ };
1450
+ };
1451
+ "core.cache.status": {
1452
+ parameters: {
1453
+ query?: never;
1454
+ header?: never;
1455
+ path?: never;
1456
+ cookie?: never;
1457
+ };
1458
+ requestBody: {
1459
+ content: {
1460
+ "application/json": components["schemas"]["CacheStatusRequestParams"];
1461
+ };
1462
+ };
1463
+ responses: {
1464
+ /** @description OK */
1465
+ 200: {
1466
+ headers: {
1467
+ [name: string]: unknown;
1468
+ };
1469
+ content: {
1470
+ "application/json": components["schemas"]["CacheStatusResult"];
1471
+ };
1472
+ };
1473
+ /** @description invalid_request */
1474
+ 400: {
1475
+ headers: {
1476
+ [name: string]: unknown;
1477
+ };
1478
+ content: {
1479
+ "application/json": {
1480
+ error: components["schemas"]["ErrorBodyInvalidRequest"];
1481
+ };
1482
+ };
1483
+ };
1484
+ /** @description validation_failed */
1485
+ 422: {
1486
+ headers: {
1487
+ [name: string]: unknown;
1488
+ };
1489
+ content: {
1490
+ "application/json": {
1491
+ error: components["schemas"]["ErrorBodyValidationFailed"];
1492
+ };
1493
+ };
1494
+ };
1495
+ /** @description internal_server_error */
1496
+ 500: {
1497
+ headers: {
1498
+ [name: string]: unknown;
1499
+ };
1500
+ content: {
1501
+ "application/json": {
1502
+ error: components["schemas"]["ErrorBodyInternalServerError"];
1503
+ };
1504
+ };
1505
+ };
1506
+ };
1507
+ };
1002
1508
  "core.ingest": {
1003
1509
  parameters: {
1004
1510
  query?: never;
@@ -1144,7 +1650,7 @@ interface operations {
1144
1650
  };
1145
1651
  requestBody: {
1146
1652
  content: {
1147
- "application/json": components["schemas"]["QueryRunInput"];
1653
+ "application/json": components["schemas"]["QueryRequestParams"];
1148
1654
  };
1149
1655
  };
1150
1656
  responses: {
@@ -1180,14 +1686,14 @@ interface operations {
1180
1686
  };
1181
1687
  };
1182
1688
  };
1183
- /** @description internal_server_error */
1689
+ /** @description internal_server_error, repo_settings_invalid, cache_miss, cache_disabled, cache_unavailable */
1184
1690
  500: {
1185
1691
  headers: {
1186
1692
  [name: string]: unknown;
1187
1693
  };
1188
1694
  content: {
1189
1695
  "application/json": {
1190
- error: components["schemas"]["ErrorBodyInternalServerError"];
1696
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"] | components["schemas"]["ErrorBodyCacheMiss"] | components["schemas"]["ErrorBodyCacheDisabled"] | components["schemas"]["ErrorBodyCacheUnavailable"];
1191
1697
  };
1192
1698
  };
1193
1699
  };
@@ -1213,7 +1719,7 @@ interface operations {
1213
1719
  };
1214
1720
  requestBody: {
1215
1721
  content: {
1216
- "application/json": components["schemas"]["QueryRunInput"];
1722
+ "application/json": components["schemas"]["QueryCompileRequestParams"];
1217
1723
  };
1218
1724
  };
1219
1725
  responses: {
@@ -1248,14 +1754,14 @@ interface operations {
1248
1754
  };
1249
1755
  };
1250
1756
  };
1251
- /** @description internal_server_error */
1757
+ /** @description internal_server_error, repo_settings_invalid */
1252
1758
  500: {
1253
1759
  headers: {
1254
1760
  [name: string]: unknown;
1255
1761
  };
1256
1762
  content: {
1257
1763
  "application/json": {
1258
- error: components["schemas"]["ErrorBodyInternalServerError"];
1764
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"];
1259
1765
  };
1260
1766
  };
1261
1767
  };
@@ -1281,7 +1787,7 @@ interface operations {
1281
1787
  };
1282
1788
  requestBody: {
1283
1789
  content: {
1284
- "application/json": components["schemas"]["ExportInput"];
1790
+ "application/json": components["schemas"]["QueryExportRequestParams"];
1285
1791
  };
1286
1792
  };
1287
1793
  responses: {
@@ -1291,7 +1797,7 @@ interface operations {
1291
1797
  [name: string]: unknown;
1292
1798
  };
1293
1799
  content: {
1294
- "application/json": components["schemas"]["ExportLink"];
1800
+ "application/json": components["schemas"]["QueryExportResult"];
1295
1801
  };
1296
1802
  };
1297
1803
  /** @description invalid_request */
@@ -1316,14 +1822,14 @@ interface operations {
1316
1822
  };
1317
1823
  };
1318
1824
  };
1319
- /** @description internal_server_error */
1825
+ /** @description internal_server_error, repo_settings_invalid */
1320
1826
  500: {
1321
1827
  headers: {
1322
1828
  [name: string]: unknown;
1323
1829
  };
1324
1830
  content: {
1325
1831
  "application/json": {
1326
- error: components["schemas"]["ErrorBodyInternalServerError"];
1832
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"];
1327
1833
  };
1328
1834
  };
1329
1835
  };
@@ -1360,7 +1866,7 @@ interface operations {
1360
1866
  };
1361
1867
  requestBody: {
1362
1868
  content: {
1363
- "application/json": components["schemas"]["QueryInput"];
1869
+ "application/json": components["schemas"]["QueryDefinition"];
1364
1870
  };
1365
1871
  };
1366
1872
  responses: {
@@ -1927,10 +2433,33 @@ interface QueryDeclaration {
1927
2433
  aql: string;
1928
2434
  /**
1929
2435
  * Rows per page, a whole number of at least 1. Past the first page, use `fetchMore()`. Leave it
1930
- * out to get every row in one result. anfra can't page a pivot query (`rows { }` / `columns { }`),
1931
- * so a pivot query must not declare one.
2436
+ * out to get every row in one result. A pivot query's (`rows { }` / `columns { }`) page is
2437
+ * `pageSize` rows of its grid, each with every cell it has, and the grid's header rows:
2438
+ * `fetchMore()` adds the next grid rows, without repeating the header rows or a grand total, and
2439
+ * `result.meta.pivot` says how big the grid is.
1932
2440
  */
1933
2441
  pageSize?: number;
2442
+ /** How this query uses the backend's result cache. Without it, the app's default. */
2443
+ cache?: QueryCacheSettings;
2444
+ }
2445
+ /** The day a week starts on, as the core API's `input.weekStartDay` takes it. */
2446
+ type WeekStartDay = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
2447
+ /**
2448
+ * What an app's queries get in their input when they set none, overriding the app's own
2449
+ * `timezone` and `weekStartDay` for its queries only.
2450
+ */
2451
+ interface QueryInputDefaults {
2452
+ timezone?: string;
2453
+ weekStartDay?: WeekStartDay;
2454
+ }
2455
+ /** How a query uses the backend's result cache, as the core API's `cache` takes it. */
2456
+ interface QueryCacheSettings {
2457
+ /**
2458
+ * How old a cached result the query accepts, and how long the result it caches is kept: a
2459
+ * duration such as `30s`, `10m` or `2h`, at most `168h` (7 days). `0s` runs it on the warehouse,
2460
+ * uncached.
2461
+ */
2462
+ duration?: string;
1934
2463
  }
1935
2464
  /**
1936
2465
  * A sort applied to a query's result, independent of the query itself — the same mechanism a
@@ -1960,10 +2489,34 @@ interface DateDrillDeclaration {
1960
2489
  interface AppDeclaration {
1961
2490
  title?: string;
1962
2491
  /**
1963
- * Omitted means the server applies the tenant reporting timezone — the SDK does not guess the
1964
- * browser's. Part of the declaration, not the environment: two apps in one host may differ.
2492
+ * The app's timezone: for its own UI (`app.timezone`), and for its queries unless
2493
+ * `query.default.input.timezone` says otherwise. Omitted means the server's default, such as the
2494
+ * tenant's reporting timezone — the SDK does not guess the browser's. Part of the declaration, not
2495
+ * the environment: two apps in one host may differ.
1965
2496
  */
1966
2497
  timezone?: string;
2498
+ /**
2499
+ * The day the app's weeks start on: for its own UI (`app.weekStartDay`), such as a date picker,
2500
+ * and for its queries unless `query.default.input.weekStartDay` says otherwise. Omitted means the
2501
+ * server's default (monday on anfra, unless the repo sets another).
2502
+ */
2503
+ weekStartDay?: WeekStartDay;
2504
+ /**
2505
+ * What the app's queries get when they set none, in the shape `.anfra/config.yml`'s `query` has
2506
+ * for a repo. `default.input` overrides the app's own `timezone` and `weekStartDay`, for its
2507
+ * queries only. `default.cache.duration`: the cache duration of each query that declares none,
2508
+ * such as `5m`. Without either, the repo's defaults, if any.
2509
+ *
2510
+ * ```ts
2511
+ * Anfra.createApp({ title: 'Sales', query: { default: { cache: { duration: '5m' } } } });
2512
+ * ```
2513
+ */
2514
+ query?: {
2515
+ default?: {
2516
+ input?: QueryInputDefaults;
2517
+ cache?: QueryCacheSettings;
2518
+ };
2519
+ };
1967
2520
  }
1968
2521
  /**
1969
2522
  * Describes one result column. Classified server-side, since the SDK never parses the AQL that
@@ -2028,11 +2581,33 @@ type Row = Record<string, unknown>;
2028
2581
  interface QueryDebug {
2029
2582
  executedAql?: string;
2030
2583
  executedSql?: string;
2584
+ /** Whether the rows came from the backend's result cache. The same as `cache.hit`, where the backend says. */
2031
2585
  fromCache: boolean;
2032
2586
  executedAt?: Date;
2587
+ /** What the backend's result cache did for this result. Absent when the query didn't use one. */
2588
+ cache?: QueryCacheResult;
2033
2589
  /** How the run's time went, where the server reports it. */
2034
2590
  timings?: QueryTimings;
2035
2591
  }
2592
+ /**
2593
+ * What the backend's result cache did for a result: whether its rows came from the cache, and when
2594
+ * they were read from the warehouse.
2595
+ */
2596
+ interface QueryCacheResult {
2597
+ /** Whether the rows came from the cache. `false`: they came from the warehouse. */
2598
+ hit: boolean;
2599
+ /** When the rows were read from the warehouse, on a hit or a miss. Absent when the result wasn't cached. */
2600
+ cachedAt?: Date;
2601
+ /** When the cached result stops being used. Absent when the result wasn't cached. */
2602
+ expiresAt?: Date;
2603
+ /** The query's key in the cache. Absent when the backend couldn't make one. */
2604
+ key?: string;
2605
+ /** Why the query ran without the cache, though it asked for it. */
2606
+ warning?: {
2607
+ code: string;
2608
+ message: string;
2609
+ };
2610
+ }
2036
2611
  /**
2037
2612
  * When each step of a query's run started, in order, in milliseconds since the run started; and
2038
2613
  * when it ended. A step ends where the next step at its level or above starts — a child step,
@@ -2062,9 +2637,112 @@ interface QueryResult {
2062
2637
  * mean more may follow.
2063
2638
  */
2064
2639
  hasMore?: boolean;
2640
+ /** For a paged pivot query: how big its grid is, across every page. */
2641
+ pivot?: QueryPivot;
2065
2642
  };
2066
2643
  debug?: QueryDebug;
2067
2644
  }
2645
+ /**
2646
+ * How big a paged pivot's grid is, across every page: its rows (`__pivot_row__` 1 and up), the
2647
+ * grand total not counted, and its columns, the total column not counted. Divide `rows` by the
2648
+ * page size to number its pages.
2649
+ */
2650
+ interface QueryPivot {
2651
+ rows: number;
2652
+ columns: number;
2653
+ }
2654
+ /** How much an annotation matters: the theme's colour for it, and the badge's dot. */
2655
+ type AnnotationSeverity = 'info' | 'warning' | 'critical';
2656
+ /** The kinds the SDK defines; a plugin can't add one. */
2657
+ type AnnotationKind = 'mark' | 'focus' | 'line' | 'band' | 'series';
2658
+ /**
2659
+ * Rows of the query's result, each named by its dimension values (`{ month: '2026-03-01' }`), as
2660
+ * `query.selectedRows` matches them; `measure`, the measure column meant when a chart draws several.
2661
+ */
2662
+ interface RowsAnchor {
2663
+ rows: readonly Row[];
2664
+ measure?: string;
2665
+ }
2666
+ /** A value on one column, a dimension's or a measure's, whether or not a row has it. */
2667
+ interface ValueAnchor {
2668
+ column: string;
2669
+ value: string;
2670
+ }
2671
+ /** A range on one column, from one value to another. */
2672
+ interface RangeAnchor {
2673
+ column: string;
2674
+ from: string;
2675
+ to: string;
2676
+ }
2677
+ /**
2678
+ * One point of a series, at dimension values the result may lack (a future month): a `value`, or
2679
+ * both bounds (`lower`, `upper`), or both.
2680
+ */
2681
+ interface SeriesPoint {
2682
+ at: Row;
2683
+ value?: string;
2684
+ lower?: string;
2685
+ upper?: string;
2686
+ }
2687
+ /** New points through one measure, shaped like the query's rows. */
2688
+ interface SeriesAnchor {
2689
+ measure: string;
2690
+ points: readonly SeriesPoint[];
2691
+ }
2692
+ interface AnnotationText {
2693
+ /** The plugin's own name for it, unique in its set: its `key` is made from it. */
2694
+ id?: string;
2695
+ /** Short, for a chart's label. */
2696
+ label?: string;
2697
+ /** Longer, for a tooltip or a list. */
2698
+ detail?: string;
2699
+ severity?: AnnotationSeverity;
2700
+ }
2701
+ /**
2702
+ * Something a plugin says about a query's data, as its frame half sets it with `kernel.annotate`:
2703
+ * a kind, an anchor in the query's own column aliases, and optionally a label, a detail and a
2704
+ * severity. Values are strings, as rows carry them. See docs/designs/sdk-plugins.md.
2705
+ */
2706
+ type AnnotationInput = AnnotationText & ({
2707
+ kind: 'mark' | 'focus';
2708
+ anchor: RowsAnchor;
2709
+ } | {
2710
+ kind: 'line';
2711
+ anchor: ValueAnchor;
2712
+ } | {
2713
+ kind: 'band';
2714
+ anchor: RangeAnchor;
2715
+ } | {
2716
+ kind: 'series';
2717
+ anchor: SeriesAnchor;
2718
+ });
2719
+ /** A rows anchor as `query.annotations` has it: with `index`, the rows' positions in `query.result.rows`. */
2720
+ interface ResolvedRowsAnchor extends RowsAnchor {
2721
+ index: number[];
2722
+ }
2723
+ interface AnnotationMeta {
2724
+ /** The plugin that set it. */
2725
+ plugin: string;
2726
+ /** Stable across reads: the plugin and its `id`, or its position in the plugin's set. */
2727
+ key: string;
2728
+ }
2729
+ /**
2730
+ * An annotation as the definition reads it, from `query.annotations`: what a plugin set, with its
2731
+ * plugin, its key, and a rows anchor's positions in the current result.
2732
+ */
2733
+ type Annotation = AnnotationText & AnnotationMeta & ({
2734
+ kind: 'mark' | 'focus';
2735
+ anchor: ResolvedRowsAnchor;
2736
+ } | {
2737
+ kind: 'line';
2738
+ anchor: ValueAnchor;
2739
+ } | {
2740
+ kind: 'band';
2741
+ anchor: RangeAnchor;
2742
+ } | {
2743
+ kind: 'series';
2744
+ anchor: SeriesAnchor;
2745
+ });
2068
2746
  type QueryState = 'idle' | 'executing' | 'success' | 'error';
2069
2747
  interface ExecuteSummary {
2070
2748
  succeeded: string[];
@@ -2167,6 +2845,7 @@ type MappingJson = ControlMappingJson | CrossFilterJson;
2167
2845
  interface AppJson {
2168
2846
  title?: string;
2169
2847
  timezone?: string;
2848
+ weekStartDay?: WeekStartDay;
2170
2849
  queries: Record<string, QueryDeclaration>;
2171
2850
  filters: Record<string, FilterDeclaration>;
2172
2851
  dateDrills: Record<string, DateDrillDeclaration>;
@@ -2230,6 +2909,8 @@ type LocateTarget = {
2230
2909
  name: string;
2231
2910
  };
2232
2911
  interface InspectedQuery {
2912
+ /** Which query of its name, as its calls are stamped; absent from an older frame. */
2913
+ id?: number;
2233
2914
  state: QueryState;
2234
2915
  /** True when re-running would produce something new. */
2235
2916
  isDirty: boolean;
@@ -2266,6 +2947,9 @@ interface InspectedSelection {
2266
2947
  interface InspectedApp {
2267
2948
  title?: string;
2268
2949
  timezone?: string;
2950
+ weekStartDay?: WeekStartDay;
2951
+ /** The app's `query.default.input`, which its queries use over its own timezone and week start day. */
2952
+ queryInput?: QueryInputDefaults;
2269
2953
  hasChanges: boolean;
2270
2954
  declaration: AppJson;
2271
2955
  queries: Record<string, InspectedQuery>;
@@ -2296,12 +2980,41 @@ interface BackendDateDrill {
2296
2980
  field: string;
2297
2981
  grain: DateGrain;
2298
2982
  }
2299
- /** The structured additions a query carries on this run, applied on top of its AQL. */
2983
+ /**
2984
+ * A query's input: everything a run chooses about the query other than its AQL, in one object, as
2985
+ * the core API takes it (`input`). A query's next page and its export send the input its run came
2986
+ * back with, so they continue the result on screen.
2987
+ */
2300
2988
  interface QueryInput {
2989
+ /** What reaches the query: mapped controls and the selection, ANDed on top of its AQL. */
2301
2990
  filters: BackendFilter[];
2302
2991
  conditions: BackendCondition[];
2992
+ /** The reader's sort, replacing the AQL's own. */
2303
2993
  sorts: BackendSort[];
2304
2994
  dateDrills: BackendDateDrill[];
2995
+ /** One page of rows. Absent for an unpaged query: the backend returns every row. */
2996
+ pagination?: QueryPagination;
2997
+ /** Absent when the app declares none, leaving the backend's default. */
2998
+ timezone?: string;
2999
+ /** Absent when the app declares none, leaving the backend's default. */
3000
+ weekStartDay?: WeekStartDay;
3001
+ /** Absent for a fresh run, which runs as of now. */
3002
+ seeds?: QuerySeeds;
3003
+ }
3004
+ /** One page of a query's rows. */
3005
+ interface QueryPagination {
3006
+ /** 1-based. */
3007
+ page: number;
3008
+ pageSize: number;
3009
+ }
3010
+ /**
3011
+ * A query's seeds: values a backend generates for each run when they're unset, so a run sent
3012
+ * again with them compiles the same way: a page fetched after midnight continues the same last 7
3013
+ * days.
3014
+ */
3015
+ interface QuerySeeds {
3016
+ /** The time the query runs as of: relative dates, such as last 7 days, are counted from it. */
3017
+ referenceTime?: string;
2305
3018
  }
2306
3019
  interface BackendQueryRequest {
2307
3020
  /** The dataset's `name`, as in `DatasetDescriptor.name`. */
@@ -2309,21 +3022,23 @@ interface BackendQueryRequest {
2309
3022
  /** The query's AQL, verbatim. */
2310
3023
  aql: string;
2311
3024
  input: QueryInput;
2312
- /** 1-based. Sent together with `pageSize`, and only for a query that declares one. */
2313
- page?: number;
2314
- /** Absent for an unpaged query: the backend returns every row. */
2315
- pageSize?: number;
2316
- /** Absent when the app declares none, leaving the backend's default. */
2317
- timezone?: string;
2318
3025
  /** Present on `refresh()`: skip any result cache. */
2319
3026
  bustCache?: boolean;
3027
+ /** The query's cache duration, its own or its app's default. Absent: the backend's default. */
3028
+ cacheDuration?: string;
3029
+ /**
3030
+ * Present on a run's later page: the time its first page's rows were read (its
3031
+ * `debug.cache.cachedAt`), as an ISO 8601 time. A result cached before it isn't used, so no page
3032
+ * is older than the first.
3033
+ */
3034
+ minCachedAt?: string;
2320
3035
  }
2321
3036
  /**
2322
- * What a query runs with now, apart from its page: its dataset, its AQL, what reaches it (mapped
2323
- * controls, the selection, the reader's sort, date drills) and the timezone. A run and an export
2324
- * are both built on it.
3037
+ * What a query runs with now, apart from its page and seeds: its dataset, its AQL, its input
3038
+ * (what reaches it: mapped controls, the selection, the reader's sort, date drills; and the
3039
+ * timezone), and its cache duration. A run and an export are both built on it.
2325
3040
  */
2326
- type QueryRequest = Pick<BackendQueryRequest, 'dataset' | 'aql' | 'input' | 'timezone'>;
3041
+ type QueryRequest = Pick<BackendQueryRequest, 'dataset' | 'aql' | 'input' | 'cacheDuration'>;
2327
3042
  /** One page of a query's rows. `values` is positional: each row lines up with `columns`. */
2328
3043
  interface BackendQueryResult {
2329
3044
  columns: ColumnMeta[];
@@ -2334,8 +3049,12 @@ interface BackendQueryResult {
2334
3049
  numRows?: number;
2335
3050
  /** For a paged query: whether rows may follow this page. Omit it when not known. */
2336
3051
  hasMore?: boolean;
3052
+ /** For a paged pivot query: how big its grid is. Omit it for any other query. */
3053
+ pivot?: QueryPivot;
2337
3054
  };
2338
3055
  debug?: QueryDebug;
3056
+ /** The input as the query ran, its seeds filled in: for its next page and its export. Omit it when not known. */
3057
+ input?: QueryInput;
2339
3058
  }
2340
3059
  /** A file format an export can be written in. CSV is the only one yet; a server may add more. */
2341
3060
  type ExportFormat = 'csv' | (string & {});
@@ -2366,19 +3085,25 @@ interface ExportResult {
2366
3085
  /** The rows the file holds. */
2367
3086
  rowCount: number;
2368
3087
  expiresAt: Date;
3088
+ /** What the backend's result cache did for the export's query. Absent when it didn't use one. */
3089
+ cache?: QueryCacheResult;
2369
3090
  }
2370
3091
  /**
2371
3092
  * An export: the same query a run sends, built by the same code so the two cannot drift, but with
2372
3093
  * no page (an export is every row) and no cache to bust; plus the file's format and name.
3094
+ * `minCachedAt` keeps it no older than the result on screen, as a later page's does.
2373
3095
  */
2374
3096
  interface BackendExportRequest {
2375
3097
  /** The dataset's `name`, as in `DatasetDescriptor.name`. */
2376
3098
  dataset: string;
2377
3099
  /** The query's AQL, verbatim. */
2378
3100
  aql: string;
3101
+ /** With `pagination`, the file holds that page; without, every row. */
2379
3102
  input: QueryInput;
2380
- /** Absent when the app declares none, leaving the backend's default. */
2381
- timezone?: string;
3103
+ /** As a run's. */
3104
+ cacheDuration?: string;
3105
+ /** As a later page's: a result cached before the run's first page isn't used. */
3106
+ minCachedAt?: string;
2382
3107
  format?: ExportFormat;
2383
3108
  formatOptions?: ExportFormatOptions;
2384
3109
  filename?: string;
@@ -2420,6 +3145,30 @@ type LineageDiagram = Schemas['Diagram'];
2420
3145
  type LineageNode = Schemas['DiagramNode'];
2421
3146
  /** A node drawn at the top level, in its layer. */
2422
3147
  type LineageCard = Schemas['DiagramCard'];
3148
+ /**
3149
+ * The query a call is for, as the frame stamps it: a query's run or page (`core.submitQuery`), or its
3150
+ * export (`export.query`). The app's index among the frame's apps and the query's name. The frame's
3151
+ * word: for showing a call under its query, never for deciding what the call may do.
3152
+ */
3153
+ interface QueryStamp {
3154
+ app: number;
3155
+ query: string;
3156
+ /**
3157
+ * Which query of that name: a query removed and created again under its name has a new id. Absent
3158
+ * from an older frame's stamp, which is then the name's alone.
3159
+ */
3160
+ id?: number;
3161
+ /**
3162
+ * A short name for a variant of the query a plugin sends, such as `underlying` for the rows behind
3163
+ * a point: shown under the query, never taken for the query's own result or run.
3164
+ */
3165
+ variant?: string;
3166
+ }
3167
+ /**
3168
+ * The stamp a plugin's frame half passes to `kernel.call`: the query's `id` is left out, and the
3169
+ * kernel adds the current one of the query by that name when it sends the call.
3170
+ */
3171
+ type CallStamp = Omit<QueryStamp, 'id'>;
2423
3172
  /**
2424
3173
  * What the SDK sends queries to, supplied by the provisioner. Each call either resolves or
2425
3174
  * rejects; how the backend gets there (synchronously, as polled jobs, over a bridge) is its own
@@ -2429,7 +3178,8 @@ type LineageCard = Schemas['DiagramCard'];
2429
3178
  * error an author sees; anything else surfaces as `call_failed`.
2430
3179
  */
2431
3180
  interface Backend {
2432
- submitQuery(request: BackendQueryRequest, signal: AbortSignal): Promise<BackendQueryResult>;
3181
+ /** `stamp`: the query the request is for, when a Data App's query sends it. */
3182
+ submitQuery(request: BackendQueryRequest, signal: AbortSignal, stamp?: QueryStamp): Promise<BackendQueryResult>;
2433
3183
  fieldSuggestions(request: FieldSuggestionsRequest, signal: AbortSignal): Promise<ConditionValue[]>;
2434
3184
  /**
2435
3185
  * Export a query's whole result as a file, and answer its link once the file is ready. Optional:
@@ -2443,5 +3193,5 @@ interface Backend {
2443
3193
  lineage?(request: BackendLineageRequest, signal: AbortSignal): Promise<LineageResult>;
2444
3194
  }
2445
3195
 
2446
- export { FILTER_AGGREGATIONS as F };
2447
- export type { Operator as $, Aggregation as A, Backend as B, ColumnMeta as C, DatasetDescriptor as D, EntityKind as E, FieldLineage as G, FieldSuggestionsRequest as H, FilterAggregation as I, FilterDeclaration as J, FilterValueType as K, InspectedApp as L, InspectedControl as M, InspectedError as N, InspectedQuery as O, InspectedSelection as P, InspectedStructure as Q, LineageCard as R, LineageDiagram as S, LineageNode as T, LineageOptions as U, LineageResult as V, LineageTarget as W, Listener as X, LocateKind as Y, LocateTarget as Z, MappingJson as _, AppDeclaration as a, QueryDebug as a0, QueryDeclaration as a1, QueryInput as a2, QueryRequest as a3, QueryResult as a4, QuerySort as a5, QueryState as a6, QueryTimings as a7, RenderFormat as a8, RenderRequest as a9, Rendering as aa, Row as ab, SdkEnvironment as ac, SdkFeatures as ad, Selection as ae, SelectionCondition as af, SemanticType as ag, StructureKind as ah, StructureNode as ai, Unsubscribe as aj, User as ak, components as al, paths as am, AppJson as b, ArrowType as c, BackendCondition as d, BackendDateDrill as e, BackendExportRequest as f, BackendFilter as g, BackendLineageRequest as h, BackendQueryRequest as i, BackendQueryResult as j, BackendSort as k, Condition as l, ConditionValue as m, ControlMappingJson as n, CrossFilterJson as o, DateDrillDeclaration as p, DateGrain as q, DateTransformation as r, EntityRef as s, EntityUsage as t, ExecuteOptions as u, ExecuteSummary as v, ExportFormat as w, ExportFormatOptions as x, ExportOptions as y, ExportResult as z };
3196
+ export { FILTER_AGGREGATIONS as K };
3197
+ export type { LineageTarget as $, Aggregation as A, Backend as B, CallStamp as C, DatasetDescriptor as D, EntityKind as E, ExecuteSummary as F, ExportFormat as G, ExportFormatOptions as H, ExportOptions as I, ExportResult as J, FieldLineage as L, FieldSuggestionsRequest as M, FilterAggregation as N, FilterDeclaration as O, FilterValueType as P, InspectedApp as Q, InspectedControl as R, InspectedError as S, InspectedQuery as T, InspectedSelection as U, InspectedStructure as V, LineageCard as W, LineageDiagram as X, LineageNode as Y, LineageOptions as Z, LineageResult as _, Annotation as a, Listener as a0, LocateKind as a1, LocateTarget as a2, MappingJson as a3, Operator as a4, QueryCacheResult as a5, QueryCacheSettings as a6, QueryDebug as a7, QueryDeclaration as a8, QueryInput as a9, Unsubscribe as aA, User as aB, ValueAnchor as aC, WeekStartDay as aD, components as aE, paths as aF, QueryInputDefaults as aa, QueryPagination as ab, QueryPivot as ac, QueryRequest as ad, QueryResult as ae, QuerySeeds as af, QuerySort as ag, QueryStamp as ah, QueryState as ai, QueryTimings as aj, RangeAnchor as ak, RenderFormat as al, RenderRequest as am, Rendering as an, ResolvedRowsAnchor as ao, Row as ap, RowsAnchor as aq, SdkEnvironment as ar, SdkFeatures as as, Selection as at, SelectionCondition as au, SemanticType as av, SeriesAnchor as aw, SeriesPoint as ax, StructureKind as ay, StructureNode as az, AnnotationInput as b, AnnotationKind as c, AnnotationSeverity as d, AppDeclaration as e, AppJson as f, ArrowType as g, BackendCondition as h, BackendDateDrill as i, BackendExportRequest as j, BackendFilter as k, BackendLineageRequest as l, BackendQueryRequest as m, BackendQueryResult as n, BackendSort as o, ColumnMeta as p, Condition as q, ConditionValue as r, ControlMappingJson as s, CrossFilterJson as t, DateDrillDeclaration as u, DateGrain as v, DateTransformation as w, EntityRef as x, EntityUsage as y, ExecuteOptions as z };