@holistics/anfra-sdk 0.19.0 → 0.21.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 (36) 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 +4 -3
  6. package/dist/{bootstrap-5xNrSbJb.d.ts → bootstrap-BxBqFhgm.d.ts} +279 -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-4TXKXLWK.js → chunk-7I2HXY72.js} +1 -1
  12. package/dist/{chunk-ZSIJLBKG.js → chunk-7NZOMBYE.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-CDZ7MBXC.js → chunk-E3Q3FRKQ.js} +1 -1
  16. package/dist/{chunk-SXKJQU7A.js → chunk-GPBYPSWK.js} +22 -36
  17. package/dist/{chunk-OS4CRPTU.js → chunk-IHRNKDMO.js} +830 -265
  18. package/dist/{chunk-EIPHDMZ7.js → chunk-UWRQXPPG.js} +69 -24
  19. package/dist/common.d.ts +3 -3
  20. package/dist/{data-ESPFZ5IM.js → data-SZDYO55C.js} +7 -5
  21. package/dist/{declaration-RYRBX7PH.js → declaration-GYV6OUR3.js} +5 -3
  22. package/dist/{errors-BlRfqyty.d.ts → errors-DR05L6-y.d.ts} +1 -1
  23. package/dist/host.d.ts +2 -2
  24. package/dist/host.js +29 -6
  25. package/dist/{menu-Dmfu51qo.d.ts → menu-CuTKq-dC.d.ts} +2 -1
  26. package/dist/{overview-S6FTM2JT.js → overview-KOQJNG2Y.js} +28 -13
  27. package/dist/{plugin-C_Cc_e9L.d.ts → plugin-BIcighnC.d.ts} +7 -2
  28. package/dist/plugins.d.ts +1 -7
  29. package/dist/plugins.js +53 -17
  30. package/dist/{queries-FWMX7H5Z.js → queries-BWKWZQMG.js} +70 -17
  31. package/dist/{structure-VFRJFC4C.js → structure-JO4YZHKZ.js} +5 -3
  32. package/dist/{tab-XL2HS5W4.js → tab-QPHE7YUQ.js} +3 -3
  33. package/dist/testing.d.ts +2 -1
  34. package/dist/testing.js +8 -7
  35. package/dist/{types-DKQjAL1O.d.ts → types-C_-1rgj2.d.ts} +783 -123
  36. 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"][];
@@ -635,18 +980,25 @@ interface components {
635
980
  type: "header";
636
981
  };
637
982
  QueryInput: {
638
- /** @description the data source a SQL query runs against */
639
- data_source?: string;
640
- /** @description the dataset an AQL query runs against */
641
- dataset?: string;
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;
642
997
  /**
643
- * @description the language the query is written in
644
- * @default aql
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.
645
999
  * @enum {string}
646
1000
  */
647
- lang?: "aql" | "sql";
648
- /** @description the query */
649
- query: string;
1001
+ weekStartDay?: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
650
1002
  };
651
1003
  QueryRecords: {
652
1004
  /** @description one array per row, its values in fields' order, written as a page's records are */
@@ -657,30 +1009,15 @@ interface components {
657
1009
  */
658
1010
  type: "rows";
659
1011
  };
660
- QueryResult: {
661
- /** @description the final AQL (with the Query Input applied). Absent for a SQL query. */
662
- aql?: string;
663
- /** @description one per field of result, in order */
664
- 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. */
666
- has_more: boolean;
667
- result: components["schemas"]["QueryRows"];
668
- sql: string;
669
- /** @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. */
670
- timings: components["schemas"]["Timings"];
671
- };
672
- QueryRows: {
673
- fields: string[];
674
- /** @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
- records: unknown[][];
676
- };
677
- QueryRunInput: {
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"];
678
1015
  /** @description the data source a SQL query runs against */
679
1016
  data_source?: string;
680
1017
  /** @description the dataset an AQL query runs against */
681
1018
  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"];
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"];
684
1021
  /**
685
1022
  * @description the language the query is written in
686
1023
  * @default aql
@@ -689,19 +1026,47 @@ interface components {
689
1026
  lang?: "aql" | "sql";
690
1027
  /**
691
1028
  * Format: int64
692
- * @description the 1-based page of rows to return, 1 by default, for AQL only. Needs page_size.
1029
+ * @deprecated
1030
+ * @description deprecated: use input.pagination.page. Ignored when input.pagination is set.
693
1031
  */
694
1032
  page?: number;
695
1033
  /**
696
1034
  * Format: int64
697
- * @description how many rows a page has, for AQL only
1035
+ * @deprecated
1036
+ * @description deprecated: use input.pagination.pageSize. Ignored when input.pagination is set.
698
1037
  */
699
1038
  page_size?: number;
700
1039
  /** @description the query */
701
1040
  query: string;
702
- /** @description the IANA time zone that relative dates and date truncation use, such as Asia/Ho_Chi_Minh, for AQL only */
1041
+ /**
1042
+ * @deprecated
1043
+ * @description deprecated: use input.timezone. Ignored when input.timezone is set.
1044
+ */
703
1045
  timezone?: string;
704
1046
  };
1047
+ QueryResult: {
1048
+ /** @description the final AQL (with the Query Input applied). Absent for a SQL query. */
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"];
1052
+ /** @description one per field of result, in order */
1053
+ columns: components["schemas"]["Column"][];
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. */
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"];
1060
+ result: components["schemas"]["QueryRows"];
1061
+ sql: string;
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. */
1063
+ timings: components["schemas"]["Timings"];
1064
+ };
1065
+ QueryRows: {
1066
+ fields: string[];
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. */
1068
+ records: unknown[][];
1069
+ };
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,10 @@ 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"];
1264
+ /** @description what to do next, if any */
1265
+ hints?: string[];
896
1266
  repo: components["schemas"]["RepoStatus"];
897
1267
  server: components["schemas"]["ServerStatus"];
898
1268
  };
@@ -935,6 +1305,19 @@ interface components {
935
1305
  */
936
1306
  type: "status";
937
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
+ };
938
1321
  TimedStep: {
939
1322
  /**
940
1323
  * Format: int64
@@ -997,6 +1380,131 @@ interface components {
997
1380
  pathItems: never;
998
1381
  }
999
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
+ };
1000
1508
  "core.ingest": {
1001
1509
  parameters: {
1002
1510
  query?: never;
@@ -1142,7 +1650,7 @@ interface operations {
1142
1650
  };
1143
1651
  requestBody: {
1144
1652
  content: {
1145
- "application/json": components["schemas"]["QueryRunInput"];
1653
+ "application/json": components["schemas"]["QueryRequestParams"];
1146
1654
  };
1147
1655
  };
1148
1656
  responses: {
@@ -1178,14 +1686,14 @@ interface operations {
1178
1686
  };
1179
1687
  };
1180
1688
  };
1181
- /** @description internal_server_error */
1689
+ /** @description internal_server_error, repo_settings_invalid, cache_miss, cache_disabled, cache_unavailable */
1182
1690
  500: {
1183
1691
  headers: {
1184
1692
  [name: string]: unknown;
1185
1693
  };
1186
1694
  content: {
1187
1695
  "application/json": {
1188
- error: components["schemas"]["ErrorBodyInternalServerError"];
1696
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"] | components["schemas"]["ErrorBodyCacheMiss"] | components["schemas"]["ErrorBodyCacheDisabled"] | components["schemas"]["ErrorBodyCacheUnavailable"];
1189
1697
  };
1190
1698
  };
1191
1699
  };
@@ -1211,7 +1719,7 @@ interface operations {
1211
1719
  };
1212
1720
  requestBody: {
1213
1721
  content: {
1214
- "application/json": components["schemas"]["QueryRunInput"];
1722
+ "application/json": components["schemas"]["QueryCompileRequestParams"];
1215
1723
  };
1216
1724
  };
1217
1725
  responses: {
@@ -1246,14 +1754,14 @@ interface operations {
1246
1754
  };
1247
1755
  };
1248
1756
  };
1249
- /** @description internal_server_error */
1757
+ /** @description internal_server_error, repo_settings_invalid */
1250
1758
  500: {
1251
1759
  headers: {
1252
1760
  [name: string]: unknown;
1253
1761
  };
1254
1762
  content: {
1255
1763
  "application/json": {
1256
- error: components["schemas"]["ErrorBodyInternalServerError"];
1764
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"];
1257
1765
  };
1258
1766
  };
1259
1767
  };
@@ -1279,7 +1787,7 @@ interface operations {
1279
1787
  };
1280
1788
  requestBody: {
1281
1789
  content: {
1282
- "application/json": components["schemas"]["ExportInput"];
1790
+ "application/json": components["schemas"]["QueryExportRequestParams"];
1283
1791
  };
1284
1792
  };
1285
1793
  responses: {
@@ -1289,7 +1797,7 @@ interface operations {
1289
1797
  [name: string]: unknown;
1290
1798
  };
1291
1799
  content: {
1292
- "application/json": components["schemas"]["ExportLink"];
1800
+ "application/json": components["schemas"]["QueryExportResult"];
1293
1801
  };
1294
1802
  };
1295
1803
  /** @description invalid_request */
@@ -1314,14 +1822,14 @@ interface operations {
1314
1822
  };
1315
1823
  };
1316
1824
  };
1317
- /** @description internal_server_error */
1825
+ /** @description internal_server_error, repo_settings_invalid */
1318
1826
  500: {
1319
1827
  headers: {
1320
1828
  [name: string]: unknown;
1321
1829
  };
1322
1830
  content: {
1323
1831
  "application/json": {
1324
- error: components["schemas"]["ErrorBodyInternalServerError"];
1832
+ error: components["schemas"]["ErrorBodyInternalServerError"] | components["schemas"]["ErrorBodyRepoSettingsInvalid"];
1325
1833
  };
1326
1834
  };
1327
1835
  };
@@ -1358,7 +1866,7 @@ interface operations {
1358
1866
  };
1359
1867
  requestBody: {
1360
1868
  content: {
1361
- "application/json": components["schemas"]["QueryInput"];
1869
+ "application/json": components["schemas"]["QueryDefinition"];
1362
1870
  };
1363
1871
  };
1364
1872
  responses: {
@@ -1925,10 +2433,33 @@ interface QueryDeclaration {
1925
2433
  aql: string;
1926
2434
  /**
1927
2435
  * Rows per page, a whole number of at least 1. Past the first page, use `fetchMore()`. Leave it
1928
- * out to get every row in one result. anfra can't page a pivot query (`rows { }` / `columns { }`),
1929
- * 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.
1930
2440
  */
1931
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;
1932
2463
  }
1933
2464
  /**
1934
2465
  * A sort applied to a query's result, independent of the query itself — the same mechanism a
@@ -1958,10 +2489,34 @@ interface DateDrillDeclaration {
1958
2489
  interface AppDeclaration {
1959
2490
  title?: string;
1960
2491
  /**
1961
- * Omitted means the server applies the tenant reporting timezone — the SDK does not guess the
1962
- * 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.
1963
2496
  */
1964
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
+ };
1965
2520
  }
1966
2521
  /**
1967
2522
  * Describes one result column. Classified server-side, since the SDK never parses the AQL that
@@ -2026,11 +2581,33 @@ type Row = Record<string, unknown>;
2026
2581
  interface QueryDebug {
2027
2582
  executedAql?: string;
2028
2583
  executedSql?: string;
2584
+ /** Whether the rows came from the backend's result cache. The same as `cache.hit`, where the backend says. */
2029
2585
  fromCache: boolean;
2030
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;
2031
2589
  /** How the run's time went, where the server reports it. */
2032
2590
  timings?: QueryTimings;
2033
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
+ }
2034
2611
  /**
2035
2612
  * When each step of a query's run started, in order, in milliseconds since the run started; and
2036
2613
  * when it ended. A step ends where the next step at its level or above starts — a child step,
@@ -2060,9 +2637,20 @@ interface QueryResult {
2060
2637
  * mean more may follow.
2061
2638
  */
2062
2639
  hasMore?: boolean;
2640
+ /** For a paged pivot query: how big its grid is, across every page. */
2641
+ pivot?: QueryPivot;
2063
2642
  };
2064
2643
  debug?: QueryDebug;
2065
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
+ }
2066
2654
  type QueryState = 'idle' | 'executing' | 'success' | 'error';
2067
2655
  interface ExecuteSummary {
2068
2656
  succeeded: string[];
@@ -2165,6 +2753,7 @@ type MappingJson = ControlMappingJson | CrossFilterJson;
2165
2753
  interface AppJson {
2166
2754
  title?: string;
2167
2755
  timezone?: string;
2756
+ weekStartDay?: WeekStartDay;
2168
2757
  queries: Record<string, QueryDeclaration>;
2169
2758
  filters: Record<string, FilterDeclaration>;
2170
2759
  dateDrills: Record<string, DateDrillDeclaration>;
@@ -2228,6 +2817,8 @@ type LocateTarget = {
2228
2817
  name: string;
2229
2818
  };
2230
2819
  interface InspectedQuery {
2820
+ /** Which query of its name, as its calls are stamped; absent from an older frame. */
2821
+ id?: number;
2231
2822
  state: QueryState;
2232
2823
  /** True when re-running would produce something new. */
2233
2824
  isDirty: boolean;
@@ -2264,6 +2855,9 @@ interface InspectedSelection {
2264
2855
  interface InspectedApp {
2265
2856
  title?: string;
2266
2857
  timezone?: string;
2858
+ weekStartDay?: WeekStartDay;
2859
+ /** The app's `query.default.input`, which its queries use over its own timezone and week start day. */
2860
+ queryInput?: QueryInputDefaults;
2267
2861
  hasChanges: boolean;
2268
2862
  declaration: AppJson;
2269
2863
  queries: Record<string, InspectedQuery>;
@@ -2294,12 +2888,41 @@ interface BackendDateDrill {
2294
2888
  field: string;
2295
2889
  grain: DateGrain;
2296
2890
  }
2297
- /** The structured additions a query carries on this run, applied on top of its AQL. */
2891
+ /**
2892
+ * A query's input: everything a run chooses about the query other than its AQL, in one object, as
2893
+ * the core API takes it (`input`). A query's next page and its export send the input its run came
2894
+ * back with, so they continue the result on screen.
2895
+ */
2298
2896
  interface QueryInput {
2897
+ /** What reaches the query: mapped controls and the selection, ANDed on top of its AQL. */
2299
2898
  filters: BackendFilter[];
2300
2899
  conditions: BackendCondition[];
2900
+ /** The reader's sort, replacing the AQL's own. */
2301
2901
  sorts: BackendSort[];
2302
2902
  dateDrills: BackendDateDrill[];
2903
+ /** One page of rows. Absent for an unpaged query: the backend returns every row. */
2904
+ pagination?: QueryPagination;
2905
+ /** Absent when the app declares none, leaving the backend's default. */
2906
+ timezone?: string;
2907
+ /** Absent when the app declares none, leaving the backend's default. */
2908
+ weekStartDay?: WeekStartDay;
2909
+ /** Absent for a fresh run, which runs as of now. */
2910
+ seeds?: QuerySeeds;
2911
+ }
2912
+ /** One page of a query's rows. */
2913
+ interface QueryPagination {
2914
+ /** 1-based. */
2915
+ page: number;
2916
+ pageSize: number;
2917
+ }
2918
+ /**
2919
+ * A query's seeds: values a backend generates for each run when they're unset, so a run sent
2920
+ * again with them compiles the same way: a page fetched after midnight continues the same last 7
2921
+ * days.
2922
+ */
2923
+ interface QuerySeeds {
2924
+ /** The time the query runs as of: relative dates, such as last 7 days, are counted from it. */
2925
+ referenceTime?: string;
2303
2926
  }
2304
2927
  interface BackendQueryRequest {
2305
2928
  /** The dataset's `name`, as in `DatasetDescriptor.name`. */
@@ -2307,21 +2930,23 @@ interface BackendQueryRequest {
2307
2930
  /** The query's AQL, verbatim. */
2308
2931
  aql: string;
2309
2932
  input: QueryInput;
2310
- /** 1-based. Sent together with `pageSize`, and only for a query that declares one. */
2311
- page?: number;
2312
- /** Absent for an unpaged query: the backend returns every row. */
2313
- pageSize?: number;
2314
- /** Absent when the app declares none, leaving the backend's default. */
2315
- timezone?: string;
2316
2933
  /** Present on `refresh()`: skip any result cache. */
2317
2934
  bustCache?: boolean;
2935
+ /** The query's cache duration, its own or its app's default. Absent: the backend's default. */
2936
+ cacheDuration?: string;
2937
+ /**
2938
+ * Present on a run's later page: the time its first page's rows were read (its
2939
+ * `debug.cache.cachedAt`), as an ISO 8601 time. A result cached before it isn't used, so no page
2940
+ * is older than the first.
2941
+ */
2942
+ minCachedAt?: string;
2318
2943
  }
2319
2944
  /**
2320
- * What a query runs with now, apart from its page: its dataset, its AQL, what reaches it (mapped
2321
- * controls, the selection, the reader's sort, date drills) and the timezone. A run and an export
2322
- * are both built on it.
2945
+ * What a query runs with now, apart from its page and seeds: its dataset, its AQL, its input
2946
+ * (what reaches it: mapped controls, the selection, the reader's sort, date drills; and the
2947
+ * timezone), and its cache duration. A run and an export are both built on it.
2323
2948
  */
2324
- type QueryRequest = Pick<BackendQueryRequest, 'dataset' | 'aql' | 'input' | 'timezone'>;
2949
+ type QueryRequest = Pick<BackendQueryRequest, 'dataset' | 'aql' | 'input' | 'cacheDuration'>;
2325
2950
  /** One page of a query's rows. `values` is positional: each row lines up with `columns`. */
2326
2951
  interface BackendQueryResult {
2327
2952
  columns: ColumnMeta[];
@@ -2332,8 +2957,12 @@ interface BackendQueryResult {
2332
2957
  numRows?: number;
2333
2958
  /** For a paged query: whether rows may follow this page. Omit it when not known. */
2334
2959
  hasMore?: boolean;
2960
+ /** For a paged pivot query: how big its grid is. Omit it for any other query. */
2961
+ pivot?: QueryPivot;
2335
2962
  };
2336
2963
  debug?: QueryDebug;
2964
+ /** The input as the query ran, its seeds filled in: for its next page and its export. Omit it when not known. */
2965
+ input?: QueryInput;
2337
2966
  }
2338
2967
  /** A file format an export can be written in. CSV is the only one yet; a server may add more. */
2339
2968
  type ExportFormat = 'csv' | (string & {});
@@ -2364,19 +2993,25 @@ interface ExportResult {
2364
2993
  /** The rows the file holds. */
2365
2994
  rowCount: number;
2366
2995
  expiresAt: Date;
2996
+ /** What the backend's result cache did for the export's query. Absent when it didn't use one. */
2997
+ cache?: QueryCacheResult;
2367
2998
  }
2368
2999
  /**
2369
3000
  * An export: the same query a run sends, built by the same code so the two cannot drift, but with
2370
3001
  * no page (an export is every row) and no cache to bust; plus the file's format and name.
3002
+ * `minCachedAt` keeps it no older than the result on screen, as a later page's does.
2371
3003
  */
2372
3004
  interface BackendExportRequest {
2373
3005
  /** The dataset's `name`, as in `DatasetDescriptor.name`. */
2374
3006
  dataset: string;
2375
3007
  /** The query's AQL, verbatim. */
2376
3008
  aql: string;
3009
+ /** With `pagination`, the file holds that page; without, every row. */
2377
3010
  input: QueryInput;
2378
- /** Absent when the app declares none, leaving the backend's default. */
2379
- timezone?: string;
3011
+ /** As a run's. */
3012
+ cacheDuration?: string;
3013
+ /** As a later page's: a result cached before the run's first page isn't used. */
3014
+ minCachedAt?: string;
2380
3015
  format?: ExportFormat;
2381
3016
  formatOptions?: ExportFormatOptions;
2382
3017
  filename?: string;
@@ -2418,6 +3053,30 @@ type LineageDiagram = Schemas['Diagram'];
2418
3053
  type LineageNode = Schemas['DiagramNode'];
2419
3054
  /** A node drawn at the top level, in its layer. */
2420
3055
  type LineageCard = Schemas['DiagramCard'];
3056
+ /**
3057
+ * The query a call is for, as the frame stamps it: a query's run or page (`core.submitQuery`), or its
3058
+ * export (`export.query`). The app's index among the frame's apps and the query's name. The frame's
3059
+ * word: for showing a call under its query, never for deciding what the call may do.
3060
+ */
3061
+ interface QueryStamp {
3062
+ app: number;
3063
+ query: string;
3064
+ /**
3065
+ * Which query of that name: a query removed and created again under its name has a new id. Absent
3066
+ * from an older frame's stamp, which is then the name's alone.
3067
+ */
3068
+ id?: number;
3069
+ /**
3070
+ * A short name for a variant of the query a plugin sends, such as `underlying` for the rows behind
3071
+ * a point: shown under the query, never taken for the query's own result or run.
3072
+ */
3073
+ variant?: string;
3074
+ }
3075
+ /**
3076
+ * The stamp a plugin's frame half passes to `kernel.call`: the query's `id` is left out, and the
3077
+ * kernel adds the current one of the query by that name when it sends the call.
3078
+ */
3079
+ type CallStamp = Omit<QueryStamp, 'id'>;
2421
3080
  /**
2422
3081
  * What the SDK sends queries to, supplied by the provisioner. Each call either resolves or
2423
3082
  * rejects; how the backend gets there (synchronously, as polled jobs, over a bridge) is its own
@@ -2427,7 +3086,8 @@ type LineageCard = Schemas['DiagramCard'];
2427
3086
  * error an author sees; anything else surfaces as `call_failed`.
2428
3087
  */
2429
3088
  interface Backend {
2430
- submitQuery(request: BackendQueryRequest, signal: AbortSignal): Promise<BackendQueryResult>;
3089
+ /** `stamp`: the query the request is for, when a Data App's query sends it. */
3090
+ submitQuery(request: BackendQueryRequest, signal: AbortSignal, stamp?: QueryStamp): Promise<BackendQueryResult>;
2431
3091
  fieldSuggestions(request: FieldSuggestionsRequest, signal: AbortSignal): Promise<ConditionValue[]>;
2432
3092
  /**
2433
3093
  * Export a query's whole result as a file, and answer its link once the file is ready. Optional:
@@ -2441,5 +3101,5 @@ interface Backend {
2441
3101
  lineage?(request: BackendLineageRequest, signal: AbortSignal): Promise<LineageResult>;
2442
3102
  }
2443
3103
 
2444
- export { FILTER_AGGREGATIONS as F };
2445
- 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 };
3104
+ export { FILTER_AGGREGATIONS as G };
3105
+ export type { MappingJson as $, Aggregation as A, Backend as B, CallStamp as C, DatasetDescriptor as D, EntityKind as E, ExportResult as F, FieldLineage as H, FieldSuggestionsRequest as I, FilterAggregation as J, FilterDeclaration as K, FilterValueType as L, InspectedApp as M, InspectedControl as N, InspectedError as O, InspectedQuery as P, InspectedSelection as Q, InspectedStructure as R, LineageCard as S, LineageDiagram as T, LineageNode as U, LineageOptions as V, LineageResult as W, LineageTarget as X, Listener as Y, LocateKind as Z, LocateTarget as _, AppDeclaration as a, Operator as a0, QueryCacheResult as a1, QueryCacheSettings as a2, QueryDebug as a3, QueryDeclaration as a4, QueryInput as a5, QueryInputDefaults as a6, QueryPagination as a7, QueryPivot as a8, QueryRequest as a9, QueryResult as aa, QuerySeeds as ab, QuerySort as ac, QueryStamp as ad, QueryState as ae, QueryTimings as af, RenderFormat as ag, RenderRequest as ah, Rendering as ai, Row as aj, SdkEnvironment as ak, SdkFeatures as al, Selection as am, SelectionCondition as an, SemanticType as ao, StructureKind as ap, StructureNode as aq, Unsubscribe as ar, User as as, WeekStartDay as at, components as au, paths as av, 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, ColumnMeta as l, Condition as m, ConditionValue as n, ControlMappingJson as o, CrossFilterJson as p, DateDrillDeclaration as q, DateGrain as r, DateTransformation as s, EntityRef as t, EntityUsage as u, ExecuteOptions as v, ExecuteSummary as w, ExportFormat as x, ExportFormatOptions as y, ExportOptions as z };