@xata.io/client 0.23.4 → 0.24.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @xata.io/client@0.23.4 add-version /home/runner/work/client-ts/client-ts/packages/client
2
+ > @xata.io/client@0.24.0 add-version /home/runner/work/client-ts/client-ts/packages/client
3
3
  > node ../../scripts/add-version-file.mjs
4
4
 
@@ -1,13 +1,13 @@
1
1
 
2
- > @xata.io/client@0.23.4 build /home/runner/work/client-ts/client-ts/packages/client
2
+ > @xata.io/client@0.24.0 build /home/runner/work/client-ts/client-ts/packages/client
3
3
  > rimraf dist && rollup -c
4
4
 
5
5
  
6
6
  src/index.ts → dist/index.cjs...
7
- created dist/index.cjs in 1.1s
7
+ created dist/index.cjs in 1.5s
8
8
  
9
9
  src/index.ts → dist/index.mjs...
10
- created dist/index.mjs in 829ms
10
+ created dist/index.mjs in 1.2s
11
11
  
12
12
  src/index.ts → dist/index.d.ts...
13
- created dist/index.d.ts in 5.4s
13
+ created dist/index.d.ts in 7.8s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1009](https://github.com/xataio/client-ts/pull/1009) [`45aa2207`](https://github.com/xataio/client-ts/commit/45aa220728e98dd716a55a9a307474732a9b2bc1) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `createdAt` and `updatedAt` properties
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1008](https://github.com/xataio/client-ts/pull/1008) [`f28080f0`](https://github.com/xataio/client-ts/commit/f28080f034f02704fe00d64b8f42e1127bde30c7) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `failIfMissing` to delete transactions
12
+
13
+ - [#994](https://github.com/xataio/client-ts/pull/994) [`ac9c0604`](https://github.com/xataio/client-ts/commit/ac9c06042bb85105d9a38624676ce6ea5a27d488) Thanks [@xata-bot](https://github.com/xata-bot)! - Update internal endpoints
14
+
15
+ - [#1015](https://github.com/xataio/client-ts/pull/1015) [`c163b365`](https://github.com/xataio/client-ts/commit/c163b3658f23fb2eaad6243ebebc92624754099a) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `factor` to date boosters
16
+
17
+ ## 0.23.5
18
+
19
+ ### Patch Changes
20
+
21
+ - [#970](https://github.com/xataio/client-ts/pull/970) [`20cc8c43`](https://github.com/xataio/client-ts/commit/20cc8c43e1659bf112ae2642948c84bfcf46a6ba) Thanks [@xata-bot](https://github.com/xata-bot)! - Add delete file endpoint
22
+
23
+ - [#976](https://github.com/xataio/client-ts/pull/976) [`5099cbbd`](https://github.com/xataio/client-ts/commit/5099cbbd3065a60dcee2f1699afa1ee8ed5edb1c) Thanks [@SferaDev](https://github.com/SferaDev)! - Re-export JSONData helper type
24
+
25
+ - [#972](https://github.com/xataio/client-ts/pull/972) [`89375e76`](https://github.com/xataio/client-ts/commit/89375e76b790fed7e6a26bf3ac4ea9eaed1aecae) Thanks [@SferaDev](https://github.com/SferaDev)! - Add types to exports
26
+
27
+ - [#979](https://github.com/xataio/client-ts/pull/979) [`5eaee932`](https://github.com/xataio/client-ts/commit/5eaee932b828907ae352d7c0d0584e860845434b) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `size` to pagination meta
28
+
29
+ - [#974](https://github.com/xataio/client-ts/pull/974) [`109b8790`](https://github.com/xataio/client-ts/commit/109b8790849532d9c442e7c03c67792aeafebd88) Thanks [@xata-bot](https://github.com/xata-bot)! - Make checksum mandatory
30
+
3
31
  ## 0.23.4
4
32
 
5
33
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -266,7 +266,7 @@ class ApiRequestPool {
266
266
  return __privateGet$8(this, _fetch);
267
267
  }
268
268
  request(url, options) {
269
- const start = new Date();
269
+ const start = /* @__PURE__ */ new Date();
270
270
  const fetch2 = this.getFetch();
271
271
  const runRequest = async (stalled = false) => {
272
272
  const response = await fetch2(url, options);
@@ -276,7 +276,7 @@ class ApiRequestPool {
276
276
  return await runRequest(true);
277
277
  }
278
278
  if (stalled) {
279
- const stalledTime = new Date().getTime() - start.getTime();
279
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
280
280
  console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
281
281
  }
282
282
  return response;
@@ -492,7 +492,7 @@ function defaultOnOpen(response) {
492
492
  }
493
493
  }
494
494
 
495
- const VERSION = "0.23.4";
495
+ const VERSION = "0.24.0";
496
496
 
497
497
  class ErrorWithCause extends Error {
498
498
  constructor(message, options) {
@@ -834,6 +834,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
834
834
  });
835
835
  const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
836
836
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
837
+ const getFileItem = (variables, signal) => dataPlaneFetch({
838
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
839
+ method: "get",
840
+ ...variables,
841
+ signal
842
+ });
843
+ const putFileItem = (variables, signal) => dataPlaneFetch({
844
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
845
+ method: "put",
846
+ ...variables,
847
+ signal
848
+ });
849
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
850
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
851
+ method: "delete",
852
+ ...variables,
853
+ signal
854
+ });
855
+ const getFile = (variables, signal) => dataPlaneFetch({
856
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
857
+ method: "get",
858
+ ...variables,
859
+ signal
860
+ });
861
+ const putFile = (variables, signal) => dataPlaneFetch({
862
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
863
+ method: "put",
864
+ ...variables,
865
+ signal
866
+ });
867
+ const deleteFile = (variables, signal) => dataPlaneFetch({
868
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
869
+ method: "delete",
870
+ ...variables,
871
+ signal
872
+ });
837
873
  const getRecord = (variables, signal) => dataPlaneFetch({
838
874
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
839
875
  method: "get",
@@ -878,6 +914,12 @@ const askTable = (variables, signal) => dataPlaneFetch({
878
914
  });
879
915
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
880
916
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
917
+ const fileAccess = (variables, signal) => dataPlaneFetch({
918
+ url: "/file/{fileId}",
919
+ method: "get",
920
+ ...variables,
921
+ signal
922
+ });
881
923
  const operationsByTag$2 = {
882
924
  branch: {
883
925
  getBranchList,
@@ -937,6 +979,7 @@ const operationsByTag$2 = {
937
979
  deleteRecord,
938
980
  bulkInsertTableRecords
939
981
  },
982
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
940
983
  searchAndFilter: {
941
984
  queryTable,
942
985
  searchBranch,
@@ -1045,6 +1088,7 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
1045
1088
  });
1046
1089
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
1047
1090
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1091
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1048
1092
  const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1049
1093
  const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1050
1094
  const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
@@ -1080,6 +1124,7 @@ const operationsByTag$1 = {
1080
1124
  deleteDatabase,
1081
1125
  getDatabaseMetadata,
1082
1126
  updateDatabaseMetadata,
1127
+ renameDatabase,
1083
1128
  getDatabaseGithubSettings,
1084
1129
  updateDatabaseGithubSettings,
1085
1130
  deleteDatabaseGithubSettings,
@@ -1235,6 +1280,11 @@ class XataApiClient {
1235
1280
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
1236
1281
  return __privateGet$7(this, _namespaces).records;
1237
1282
  }
1283
+ get files() {
1284
+ if (!__privateGet$7(this, _namespaces).files)
1285
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1286
+ return __privateGet$7(this, _namespaces).files;
1287
+ }
1238
1288
  get searchAndFilter() {
1239
1289
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
1240
1290
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
@@ -1812,6 +1862,164 @@ class RecordsApi {
1812
1862
  });
1813
1863
  }
1814
1864
  }
1865
+ class FilesApi {
1866
+ constructor(extraProps) {
1867
+ this.extraProps = extraProps;
1868
+ }
1869
+ getFileItem({
1870
+ workspace,
1871
+ region,
1872
+ database,
1873
+ branch,
1874
+ table,
1875
+ record,
1876
+ column,
1877
+ fileId
1878
+ }) {
1879
+ return operationsByTag.files.getFileItem({
1880
+ pathParams: {
1881
+ workspace,
1882
+ region,
1883
+ dbBranchName: `${database}:${branch}`,
1884
+ tableName: table,
1885
+ recordId: record,
1886
+ columnName: column,
1887
+ fileId
1888
+ },
1889
+ ...this.extraProps
1890
+ });
1891
+ }
1892
+ putFileItem({
1893
+ workspace,
1894
+ region,
1895
+ database,
1896
+ branch,
1897
+ table,
1898
+ record,
1899
+ column,
1900
+ fileId,
1901
+ file
1902
+ }) {
1903
+ return operationsByTag.files.putFileItem({
1904
+ pathParams: {
1905
+ workspace,
1906
+ region,
1907
+ dbBranchName: `${database}:${branch}`,
1908
+ tableName: table,
1909
+ recordId: record,
1910
+ columnName: column,
1911
+ fileId
1912
+ },
1913
+ // @ts-ignore
1914
+ body: file,
1915
+ ...this.extraProps
1916
+ });
1917
+ }
1918
+ deleteFileItem({
1919
+ workspace,
1920
+ region,
1921
+ database,
1922
+ branch,
1923
+ table,
1924
+ record,
1925
+ column,
1926
+ fileId
1927
+ }) {
1928
+ return operationsByTag.files.deleteFileItem({
1929
+ pathParams: {
1930
+ workspace,
1931
+ region,
1932
+ dbBranchName: `${database}:${branch}`,
1933
+ tableName: table,
1934
+ recordId: record,
1935
+ columnName: column,
1936
+ fileId
1937
+ },
1938
+ ...this.extraProps
1939
+ });
1940
+ }
1941
+ getFile({
1942
+ workspace,
1943
+ region,
1944
+ database,
1945
+ branch,
1946
+ table,
1947
+ record,
1948
+ column
1949
+ }) {
1950
+ return operationsByTag.files.getFile({
1951
+ pathParams: {
1952
+ workspace,
1953
+ region,
1954
+ dbBranchName: `${database}:${branch}`,
1955
+ tableName: table,
1956
+ recordId: record,
1957
+ columnName: column
1958
+ },
1959
+ ...this.extraProps
1960
+ });
1961
+ }
1962
+ putFile({
1963
+ workspace,
1964
+ region,
1965
+ database,
1966
+ branch,
1967
+ table,
1968
+ record,
1969
+ column,
1970
+ file
1971
+ }) {
1972
+ return operationsByTag.files.putFile({
1973
+ pathParams: {
1974
+ workspace,
1975
+ region,
1976
+ dbBranchName: `${database}:${branch}`,
1977
+ tableName: table,
1978
+ recordId: record,
1979
+ columnName: column
1980
+ },
1981
+ body: file,
1982
+ ...this.extraProps
1983
+ });
1984
+ }
1985
+ deleteFile({
1986
+ workspace,
1987
+ region,
1988
+ database,
1989
+ branch,
1990
+ table,
1991
+ record,
1992
+ column
1993
+ }) {
1994
+ return operationsByTag.files.deleteFile({
1995
+ pathParams: {
1996
+ workspace,
1997
+ region,
1998
+ dbBranchName: `${database}:${branch}`,
1999
+ tableName: table,
2000
+ recordId: record,
2001
+ columnName: column
2002
+ },
2003
+ ...this.extraProps
2004
+ });
2005
+ }
2006
+ fileAccess({
2007
+ workspace,
2008
+ region,
2009
+ fileId,
2010
+ verify
2011
+ }) {
2012
+ return operationsByTag.files.fileAccess({
2013
+ pathParams: {
2014
+ workspace,
2015
+ region,
2016
+ fileId
2017
+ },
2018
+ queryParams: { verify },
2019
+ ...this.extraProps
2020
+ });
2021
+ }
2022
+ }
1815
2023
  class SearchAndFilterApi {
1816
2024
  constructor(extraProps) {
1817
2025
  this.extraProps = extraProps;
@@ -2231,6 +2439,17 @@ class DatabaseApi {
2231
2439
  ...this.extraProps
2232
2440
  });
2233
2441
  }
2442
+ renameDatabase({
2443
+ workspace,
2444
+ database,
2445
+ newName
2446
+ }) {
2447
+ return operationsByTag.databases.renameDatabase({
2448
+ pathParams: { workspaceId: workspace, dbName: database },
2449
+ body: { newName },
2450
+ ...this.extraProps
2451
+ });
2452
+ }
2234
2453
  getDatabaseGithubSettings({
2235
2454
  workspace,
2236
2455
  database
@@ -2310,18 +2529,46 @@ class Page {
2310
2529
  this.meta = meta;
2311
2530
  this.records = new RecordArray(this, records);
2312
2531
  }
2532
+ /**
2533
+ * Retrieves the next page of results.
2534
+ * @param size Maximum number of results to be retrieved.
2535
+ * @param offset Number of results to skip when retrieving the results.
2536
+ * @returns The next page or results.
2537
+ */
2313
2538
  async nextPage(size, offset) {
2314
2539
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2315
2540
  }
2541
+ /**
2542
+ * Retrieves the previous page of results.
2543
+ * @param size Maximum number of results to be retrieved.
2544
+ * @param offset Number of results to skip when retrieving the results.
2545
+ * @returns The previous page or results.
2546
+ */
2316
2547
  async previousPage(size, offset) {
2317
2548
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2318
2549
  }
2550
+ /**
2551
+ * Retrieves the start page of results.
2552
+ * @param size Maximum number of results to be retrieved.
2553
+ * @param offset Number of results to skip when retrieving the results.
2554
+ * @returns The start page or results.
2555
+ */
2319
2556
  async startPage(size, offset) {
2320
2557
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2321
2558
  }
2559
+ /**
2560
+ * Retrieves the end page of results.
2561
+ * @param size Maximum number of results to be retrieved.
2562
+ * @param offset Number of results to skip when retrieving the results.
2563
+ * @returns The end page or results.
2564
+ */
2322
2565
  async endPage(size, offset) {
2323
2566
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2324
2567
  }
2568
+ /**
2569
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2570
+ * @returns Whether or not there will be additional results in the next page of results.
2571
+ */
2325
2572
  hasNextPage() {
2326
2573
  return this.meta.page.more;
2327
2574
  }
@@ -2362,22 +2609,45 @@ const _RecordArray = class extends Array {
2362
2609
  map(callbackfn, thisArg) {
2363
2610
  return this.toArray().map(callbackfn, thisArg);
2364
2611
  }
2612
+ /**
2613
+ * Retrieve next page of records
2614
+ *
2615
+ * @returns A new array of objects
2616
+ */
2365
2617
  async nextPage(size, offset) {
2366
2618
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
2367
2619
  return new _RecordArray(newPage);
2368
2620
  }
2621
+ /**
2622
+ * Retrieve previous page of records
2623
+ *
2624
+ * @returns A new array of objects
2625
+ */
2369
2626
  async previousPage(size, offset) {
2370
2627
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
2371
2628
  return new _RecordArray(newPage);
2372
2629
  }
2630
+ /**
2631
+ * Retrieve start page of records
2632
+ *
2633
+ * @returns A new array of objects
2634
+ */
2373
2635
  async startPage(size, offset) {
2374
2636
  const newPage = await __privateGet$6(this, _page).startPage(size, offset);
2375
2637
  return new _RecordArray(newPage);
2376
2638
  }
2639
+ /**
2640
+ * Retrieve end page of records
2641
+ *
2642
+ * @returns A new array of objects
2643
+ */
2377
2644
  async endPage(size, offset) {
2378
2645
  const newPage = await __privateGet$6(this, _page).endPage(size, offset);
2379
2646
  return new _RecordArray(newPage);
2380
2647
  }
2648
+ /**
2649
+ * @returns Boolean indicating if there is a next page
2650
+ */
2381
2651
  hasNextPage() {
2382
2652
  return __privateGet$6(this, _page).meta.page.more;
2383
2653
  }
@@ -2414,7 +2684,8 @@ const _Query = class {
2414
2684
  __privateAdd$5(this, _table$1, void 0);
2415
2685
  __privateAdd$5(this, _repository, void 0);
2416
2686
  __privateAdd$5(this, _data, { filter: {} });
2417
- this.meta = { page: { cursor: "start", more: true } };
2687
+ // Implements pagination
2688
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
2418
2689
  this.records = new RecordArray(this, []);
2419
2690
  __privateSet$5(this, _table$1, table);
2420
2691
  if (repository) {
@@ -2451,18 +2722,38 @@ const _Query = class {
2451
2722
  const key = JSON.stringify({ columns, filter, sort, pagination });
2452
2723
  return toBase64(key);
2453
2724
  }
2725
+ /**
2726
+ * Builds a new query object representing a logical OR between the given subqueries.
2727
+ * @param queries An array of subqueries.
2728
+ * @returns A new Query object.
2729
+ */
2454
2730
  any(...queries) {
2455
2731
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
2456
2732
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
2457
2733
  }
2734
+ /**
2735
+ * Builds a new query object representing a logical AND between the given subqueries.
2736
+ * @param queries An array of subqueries.
2737
+ * @returns A new Query object.
2738
+ */
2458
2739
  all(...queries) {
2459
2740
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
2460
2741
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
2461
2742
  }
2743
+ /**
2744
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
2745
+ * @param queries An array of subqueries.
2746
+ * @returns A new Query object.
2747
+ */
2462
2748
  not(...queries) {
2463
2749
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
2464
2750
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
2465
2751
  }
2752
+ /**
2753
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
2754
+ * @param queries An array of subqueries.
2755
+ * @returns A new Query object.
2756
+ */
2466
2757
  none(...queries) {
2467
2758
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
2468
2759
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -2485,6 +2776,11 @@ const _Query = class {
2485
2776
  const sort = [...originalSort, { column, direction }];
2486
2777
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
2487
2778
  }
2779
+ /**
2780
+ * Builds a new query specifying the set of columns to be returned in the query response.
2781
+ * @param columns Array of column names to be returned by the query.
2782
+ * @returns A new Query object.
2783
+ */
2488
2784
  select(columns) {
2489
2785
  return new _Query(
2490
2786
  __privateGet$5(this, _repository),
@@ -2497,6 +2793,12 @@ const _Query = class {
2497
2793
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
2498
2794
  return __privateGet$5(this, _repository).query(query);
2499
2795
  }
2796
+ /**
2797
+ * Get results in an iterator
2798
+ *
2799
+ * @async
2800
+ * @returns Async interable of results
2801
+ */
2500
2802
  async *[Symbol.asyncIterator]() {
2501
2803
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
2502
2804
  yield record;
@@ -2557,21 +2859,49 @@ const _Query = class {
2557
2859
  );
2558
2860
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2559
2861
  }
2862
+ /**
2863
+ * Builds a new query object adding a cache TTL in milliseconds.
2864
+ * @param ttl The cache TTL in milliseconds.
2865
+ * @returns A new Query object.
2866
+ */
2560
2867
  cache(ttl) {
2561
2868
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
2562
2869
  }
2870
+ /**
2871
+ * Retrieve next page of records
2872
+ *
2873
+ * @returns A new page object.
2874
+ */
2563
2875
  nextPage(size, offset) {
2564
2876
  return this.startPage(size, offset);
2565
2877
  }
2878
+ /**
2879
+ * Retrieve previous page of records
2880
+ *
2881
+ * @returns A new page object
2882
+ */
2566
2883
  previousPage(size, offset) {
2567
2884
  return this.startPage(size, offset);
2568
2885
  }
2886
+ /**
2887
+ * Retrieve start page of records
2888
+ *
2889
+ * @returns A new page object
2890
+ */
2569
2891
  startPage(size, offset) {
2570
2892
  return this.getPaginated({ pagination: { size, offset } });
2571
2893
  }
2894
+ /**
2895
+ * Retrieve last page of records
2896
+ *
2897
+ * @returns A new page object
2898
+ */
2572
2899
  endPage(size, offset) {
2573
2900
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
2574
2901
  }
2902
+ /**
2903
+ * @returns Boolean indicating if there is a next page
2904
+ */
2575
2905
  hasNextPage() {
2576
2906
  return this.meta.page.more;
2577
2907
  }
@@ -3261,7 +3591,7 @@ deleteRecords_fn = async function(recordIds) {
3261
3591
  };
3262
3592
  _setCacheQuery = new WeakSet();
3263
3593
  setCacheQuery_fn = async function(query, meta, records) {
3264
- await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
3594
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
3265
3595
  };
3266
3596
  _getCacheQuery = new WeakSet();
3267
3597
  getCacheQuery_fn = async function(query) {
@@ -3345,6 +3675,8 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3345
3675
  }
3346
3676
  }
3347
3677
  const record = { ...data };
3678
+ const serializable = { xata, ...transformObjectLinks(data) };
3679
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
3348
3680
  record.read = function(columns2) {
3349
3681
  return db[table].read(record["id"], columns2);
3350
3682
  };
@@ -3361,16 +3693,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3361
3693
  record.delete = function() {
3362
3694
  return db[table].delete(record["id"]);
3363
3695
  };
3696
+ record.xata = metadata;
3364
3697
  record.getMetadata = function() {
3365
- return xata;
3698
+ return metadata;
3366
3699
  };
3367
3700
  record.toSerializable = function() {
3368
- return JSON.parse(JSON.stringify(transformObjectLinks(data)));
3701
+ return JSON.parse(JSON.stringify(serializable));
3369
3702
  };
3370
3703
  record.toString = function() {
3371
- return JSON.stringify(transformObjectLinks(data));
3704
+ return JSON.stringify(transformObjectLinks(serializable));
3372
3705
  };
3373
- for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3706
+ for (const prop of ["read", "update", "replace", "delete", "xata", "getMetadata", "toSerializable", "toString"]) {
3374
3707
  Object.defineProperty(record, prop, { enumerable: false });
3375
3708
  }
3376
3709
  Object.freeze(record);
@@ -3587,6 +3920,7 @@ search_fn = async function(query, options, pluginOptions) {
3587
3920
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3588
3921
  const { records } = await searchBranch({
3589
3922
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
3923
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
3590
3924
  body: { tables, query, fuzziness, prefix, highlight, page },
3591
3925
  ...pluginOptions
3592
3926
  });
@@ -3741,6 +4075,7 @@ const buildClient = (plugins) => {
3741
4075
  fetch,
3742
4076
  apiKey,
3743
4077
  apiUrl: "",
4078
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
3744
4079
  workspacesApiUrl: (path, params) => {
3745
4080
  const hasBranch = params.dbBranchName ?? params.branch;
3746
4081
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
@@ -3893,6 +4228,8 @@ exports.deleteBranch = deleteBranch;
3893
4228
  exports.deleteColumn = deleteColumn;
3894
4229
  exports.deleteDatabase = deleteDatabase;
3895
4230
  exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
4231
+ exports.deleteFile = deleteFile;
4232
+ exports.deleteFileItem = deleteFileItem;
3896
4233
  exports.deleteRecord = deleteRecord;
3897
4234
  exports.deleteTable = deleteTable;
3898
4235
  exports.deleteUser = deleteUser;
@@ -3903,6 +4240,7 @@ exports.endsWith = endsWith;
3903
4240
  exports.equals = equals;
3904
4241
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
3905
4242
  exports.exists = exists;
4243
+ exports.fileAccess = fileAccess;
3906
4244
  exports.ge = ge;
3907
4245
  exports.getAPIKey = getAPIKey;
3908
4246
  exports.getBranch = getBranch;
@@ -3918,6 +4256,8 @@ exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
3918
4256
  exports.getDatabaseList = getDatabaseList;
3919
4257
  exports.getDatabaseMetadata = getDatabaseMetadata;
3920
4258
  exports.getDatabaseURL = getDatabaseURL;
4259
+ exports.getFile = getFile;
4260
+ exports.getFileItem = getFileItem;
3921
4261
  exports.getGitBranchesMapping = getGitBranchesMapping;
3922
4262
  exports.getHostUrl = getHostUrl;
3923
4263
  exports.getMigrationRequest = getMigrationRequest;
@@ -3966,10 +4306,13 @@ exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
3966
4306
  exports.pattern = pattern;
3967
4307
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
3968
4308
  exports.pushBranchMigrations = pushBranchMigrations;
4309
+ exports.putFile = putFile;
4310
+ exports.putFileItem = putFileItem;
3969
4311
  exports.queryMigrationRequests = queryMigrationRequests;
3970
4312
  exports.queryTable = queryTable;
3971
4313
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
3972
4314
  exports.removeWorkspaceMember = removeWorkspaceMember;
4315
+ exports.renameDatabase = renameDatabase;
3973
4316
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
3974
4317
  exports.resolveBranch = resolveBranch;
3975
4318
  exports.searchBranch = searchBranch;