@xata.io/client 0.0.0-alpha.veecda7c → 0.0.0-alpha.vefa01e6

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.
package/dist/index.cjs CHANGED
@@ -20,7 +20,8 @@ const TraceAttributes = {
20
20
  HTTP_METHOD: "http.method",
21
21
  HTTP_URL: "http.url",
22
22
  HTTP_ROUTE: "http.route",
23
- HTTP_TARGET: "http.target"
23
+ HTTP_TARGET: "http.target",
24
+ CLOUDFLARE_RAY_ID: "cf.ray"
24
25
  };
25
26
 
26
27
  function notEmpty(value) {
@@ -29,8 +30,18 @@ function notEmpty(value) {
29
30
  function compact(arr) {
30
31
  return arr.filter(notEmpty);
31
32
  }
33
+ function compactObject(obj) {
34
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
35
+ }
36
+ function isBlob(value) {
37
+ try {
38
+ return value instanceof Blob;
39
+ } catch (error) {
40
+ return false;
41
+ }
42
+ }
32
43
  function isObject(value) {
33
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
44
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
34
45
  }
35
46
  function isDefined(value) {
36
47
  return value !== null && value !== void 0;
@@ -85,6 +96,27 @@ function chunk(array, chunkSize) {
85
96
  async function timeout(ms) {
86
97
  return new Promise((resolve) => setTimeout(resolve, ms));
87
98
  }
99
+ function timeoutWithCancel(ms) {
100
+ let timeoutId;
101
+ const promise = new Promise((resolve) => {
102
+ timeoutId = setTimeout(() => {
103
+ resolve();
104
+ }, ms);
105
+ });
106
+ return {
107
+ cancel: () => clearTimeout(timeoutId),
108
+ promise
109
+ };
110
+ }
111
+ function promiseMap(inputValues, mapper) {
112
+ const reducer = (acc$, inputValue) => acc$.then(
113
+ (acc) => mapper(inputValue).then((result) => {
114
+ acc.push(result);
115
+ return acc;
116
+ })
117
+ );
118
+ return inputValues.reduce(reducer, Promise.resolve([]));
119
+ }
88
120
 
89
121
  function getEnvironment() {
90
122
  try {
@@ -184,7 +216,7 @@ function getAPIKey() {
184
216
  function getBranch() {
185
217
  try {
186
218
  const { branch } = getEnvironment();
187
- return branch ?? "main";
219
+ return branch;
188
220
  } catch (err) {
189
221
  return void 0;
190
222
  }
@@ -235,13 +267,13 @@ var __privateMethod$4 = (obj, member, method) => {
235
267
  return method;
236
268
  };
237
269
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
270
+ const REQUEST_TIMEOUT = 5 * 60 * 1e3;
238
271
  function getFetchImplementation(userFetch) {
239
272
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
240
- const fetchImpl = userFetch ?? globalFetch;
273
+ const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
274
+ const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
241
275
  if (!fetchImpl) {
242
- throw new Error(
243
- `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
244
- );
276
+ throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
245
277
  }
246
278
  return fetchImpl;
247
279
  }
@@ -266,18 +298,22 @@ class ApiRequestPool {
266
298
  return __privateGet$8(this, _fetch);
267
299
  }
268
300
  request(url, options) {
269
- const start = new Date();
270
- const fetch2 = this.getFetch();
301
+ const start = /* @__PURE__ */ new Date();
302
+ const fetchImpl = this.getFetch();
271
303
  const runRequest = async (stalled = false) => {
272
- const response = await fetch2(url, options);
304
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
305
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
306
+ if (!response) {
307
+ throw new Error("Request timed out");
308
+ }
273
309
  if (response.status === 429) {
274
310
  const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
275
311
  await timeout(rateLimitReset * 1e3);
276
312
  return await runRequest(true);
277
313
  }
278
314
  if (stalled) {
279
- const stalledTime = new Date().getTime() - start.getTime();
280
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
315
+ const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
316
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
281
317
  }
282
318
  return response;
283
319
  };
@@ -492,7 +528,7 @@ function defaultOnOpen(response) {
492
528
  }
493
529
  }
494
530
 
495
- const VERSION = "0.23.3";
531
+ const VERSION = "0.28.0";
496
532
 
497
533
  class ErrorWithCause extends Error {
498
534
  constructor(message, options) {
@@ -568,6 +604,18 @@ function hostHeader(url) {
568
604
  const { groups } = pattern.exec(url) ?? {};
569
605
  return groups?.host ? { Host: groups.host } : {};
570
606
  }
607
+ async function parseBody(body, headers) {
608
+ if (!isDefined(body))
609
+ return void 0;
610
+ if (isBlob(body) || typeof body.text === "function") {
611
+ return body;
612
+ }
613
+ const { "Content-Type": contentType } = headers ?? {};
614
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
615
+ return JSON.stringify(body);
616
+ }
617
+ return body;
618
+ }
571
619
  const defaultClientID = generateUUID();
572
620
  async function fetch$1({
573
621
  url: path,
@@ -587,7 +635,8 @@ async function fetch$1({
587
635
  sessionID,
588
636
  clientName,
589
637
  xataAgentExtra,
590
- fetchOptions = {}
638
+ fetchOptions = {},
639
+ rawResponse = false
591
640
  }) {
592
641
  pool.setFetch(fetch2);
593
642
  return await trace(
@@ -606,7 +655,7 @@ async function fetch$1({
606
655
  isDefined(clientName) ? ["service", clientName] : void 0,
607
656
  ...Object.entries(xataAgentExtra ?? {})
608
657
  ]).map(([key, value]) => `${key}=${value}`).join("; ");
609
- const headers = {
658
+ const headers = compactObject({
610
659
  "Accept-Encoding": "identity",
611
660
  "Content-Type": "application/json",
612
661
  "X-Xata-Client-ID": clientID ?? defaultClientID,
@@ -615,11 +664,11 @@ async function fetch$1({
615
664
  ...customHeaders,
616
665
  ...hostHeader(fullUrl),
617
666
  Authorization: `Bearer ${apiKey}`
618
- };
667
+ });
619
668
  const response = await pool.request(url, {
620
669
  ...fetchOptions,
621
670
  method: method.toUpperCase(),
622
- body: body ? JSON.stringify(body) : void 0,
671
+ body: await parseBody(body, headers),
623
672
  headers,
624
673
  signal
625
674
  });
@@ -630,8 +679,12 @@ async function fetch$1({
630
679
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
631
680
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
632
681
  [TraceAttributes.HTTP_HOST]: host,
633
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
682
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
683
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
634
684
  });
685
+ const message = response.headers?.get("x-xata-message");
686
+ if (message)
687
+ console.warn(message);
635
688
  if (response.status === 204) {
636
689
  return {};
637
690
  }
@@ -639,7 +692,7 @@ async function fetch$1({
639
692
  throw new FetcherError(response.status, "Rate limit exceeded", requestId);
640
693
  }
641
694
  try {
642
- const jsonResponse = await response.json();
695
+ const jsonResponse = rawResponse ? await response.blob() : await response.json();
643
696
  if (response.ok) {
644
697
  return jsonResponse;
645
698
  }
@@ -715,6 +768,13 @@ function parseUrl(url) {
715
768
 
716
769
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
717
770
 
771
+ const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
772
+ const pgRollStatus = (variables, signal) => dataPlaneFetch({
773
+ url: "/db/{dbBranchName}/pgroll/status",
774
+ method: "get",
775
+ ...variables,
776
+ signal
777
+ });
718
778
  const getBranchList = (variables, signal) => dataPlaneFetch({
719
779
  url: "/dbs/{dbName}",
720
780
  method: "get",
@@ -734,6 +794,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
734
794
  ...variables,
735
795
  signal
736
796
  });
797
+ const getSchema = (variables, signal) => dataPlaneFetch({
798
+ url: "/db/{dbBranchName}/schema",
799
+ method: "get",
800
+ ...variables,
801
+ signal
802
+ });
737
803
  const copyBranch = (variables, signal) => dataPlaneFetch({
738
804
  url: "/db/{dbBranchName}/copy",
739
805
  method: "post",
@@ -834,6 +900,42 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
834
900
  });
835
901
  const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
836
902
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
903
+ const getFileItem = (variables, signal) => dataPlaneFetch({
904
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
905
+ method: "get",
906
+ ...variables,
907
+ signal
908
+ });
909
+ const putFileItem = (variables, signal) => dataPlaneFetch({
910
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
911
+ method: "put",
912
+ ...variables,
913
+ signal
914
+ });
915
+ const deleteFileItem = (variables, signal) => dataPlaneFetch({
916
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
917
+ method: "delete",
918
+ ...variables,
919
+ signal
920
+ });
921
+ const getFile = (variables, signal) => dataPlaneFetch({
922
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
923
+ method: "get",
924
+ ...variables,
925
+ signal
926
+ });
927
+ const putFile = (variables, signal) => dataPlaneFetch({
928
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
929
+ method: "put",
930
+ ...variables,
931
+ signal
932
+ });
933
+ const deleteFile = (variables, signal) => dataPlaneFetch({
934
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
935
+ method: "delete",
936
+ ...variables,
937
+ signal
938
+ });
837
939
  const getRecord = (variables, signal) => dataPlaneFetch({
838
940
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
839
941
  method: "get",
@@ -863,12 +965,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
863
965
  ...variables,
864
966
  signal
865
967
  });
866
- const sqlQuery = (variables, signal) => dataPlaneFetch({
867
- url: "/db/{dbBranchName}/sql",
868
- method: "post",
869
- ...variables,
870
- signal
871
- });
872
968
  const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
873
969
  const askTable = (variables, signal) => dataPlaneFetch({
874
970
  url: "/db/{dbBranchName}/tables/{tableName}/ask",
@@ -876,10 +972,25 @@ const askTable = (variables, signal) => dataPlaneFetch({
876
972
  ...variables,
877
973
  signal
878
974
  });
975
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
879
976
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
880
977
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
978
+ const fileAccess = (variables, signal) => dataPlaneFetch({
979
+ url: "/file/{fileId}",
980
+ method: "get",
981
+ ...variables,
982
+ signal
983
+ });
984
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
985
+ url: "/db/{dbBranchName}/sql",
986
+ method: "post",
987
+ ...variables,
988
+ signal
989
+ });
881
990
  const operationsByTag$2 = {
882
991
  branch: {
992
+ applyMigration,
993
+ pgRollStatus,
883
994
  getBranchList,
884
995
  getBranchDetails,
885
996
  createBranch,
@@ -894,6 +1005,7 @@ const operationsByTag$2 = {
894
1005
  resolveBranch
895
1006
  },
896
1007
  migrations: {
1008
+ getSchema,
897
1009
  getBranchMigrationHistory,
898
1010
  getBranchMigrationPlan,
899
1011
  executeBranchMigrationPlan,
@@ -937,20 +1049,24 @@ const operationsByTag$2 = {
937
1049
  deleteRecord,
938
1050
  bulkInsertTableRecords
939
1051
  },
1052
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
940
1053
  searchAndFilter: {
941
1054
  queryTable,
942
1055
  searchBranch,
943
1056
  searchTable,
944
- sqlQuery,
945
1057
  vectorSearchTable,
946
1058
  askTable,
1059
+ askTableSession,
947
1060
  summarizeTable,
948
1061
  aggregateTable
949
- }
1062
+ },
1063
+ sql: { sqlQuery }
950
1064
  };
951
1065
 
952
1066
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
953
1067
 
1068
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1069
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
954
1070
  const getUser = (variables, signal) => controlPlaneFetch({
955
1071
  url: "/user",
956
1072
  method: "get",
@@ -987,6 +1103,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
987
1103
  ...variables,
988
1104
  signal
989
1105
  });
1106
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1107
+ url: "/user/oauth/clients",
1108
+ method: "get",
1109
+ ...variables,
1110
+ signal
1111
+ });
1112
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1113
+ url: "/user/oauth/clients/{clientId}",
1114
+ method: "delete",
1115
+ ...variables,
1116
+ signal
1117
+ });
1118
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1119
+ url: "/user/oauth/tokens",
1120
+ method: "get",
1121
+ ...variables,
1122
+ signal
1123
+ });
1124
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1125
+ url: "/user/oauth/tokens/{token}",
1126
+ method: "delete",
1127
+ ...variables,
1128
+ signal
1129
+ });
1130
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
990
1131
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
991
1132
  url: "/workspaces",
992
1133
  method: "get",
@@ -1030,6 +1171,20 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
1030
1171
  const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1031
1172
  const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1032
1173
  const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1174
+ const listClusters = (variables, signal) => controlPlaneFetch({
1175
+ url: "/workspaces/{workspaceId}/clusters",
1176
+ method: "get",
1177
+ ...variables,
1178
+ signal
1179
+ });
1180
+ const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
1181
+ const getCluster = (variables, signal) => controlPlaneFetch({
1182
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
1183
+ method: "get",
1184
+ ...variables,
1185
+ signal
1186
+ });
1187
+ const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
1033
1188
  const getDatabaseList = (variables, signal) => controlPlaneFetch({
1034
1189
  url: "/workspaces/{workspaceId}/dbs",
1035
1190
  method: "get",
@@ -1045,6 +1200,7 @@ const deleteDatabase = (variables, signal) => controlPlaneFetch({
1045
1200
  });
1046
1201
  const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
1047
1202
  const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
1203
+ const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
1048
1204
  const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
1049
1205
  const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
1050
1206
  const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
@@ -1055,6 +1211,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
1055
1211
  signal
1056
1212
  });
1057
1213
  const operationsByTag$1 = {
1214
+ oAuth: {
1215
+ getAuthorizationCode,
1216
+ grantAuthorizationCode,
1217
+ getUserOAuthClients,
1218
+ deleteUserOAuthClient,
1219
+ getUserOAuthAccessTokens,
1220
+ deleteOAuthAccessToken,
1221
+ updateOAuthAccessToken
1222
+ },
1058
1223
  users: { getUser, updateUser, deleteUser },
1059
1224
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1060
1225
  workspaces: {
@@ -1074,12 +1239,14 @@ const operationsByTag$1 = {
1074
1239
  acceptWorkspaceMemberInvite,
1075
1240
  resendWorkspaceMemberInvite
1076
1241
  },
1242
+ xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
1077
1243
  databases: {
1078
1244
  getDatabaseList,
1079
1245
  createDatabase,
1080
1246
  deleteDatabase,
1081
1247
  getDatabaseMetadata,
1082
1248
  updateDatabaseMetadata,
1249
+ renameDatabase,
1083
1250
  getDatabaseGithubSettings,
1084
1251
  updateDatabaseGithubSettings,
1085
1252
  deleteDatabaseGithubSettings,
@@ -1235,6 +1402,11 @@ class XataApiClient {
1235
1402
  __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
1236
1403
  return __privateGet$7(this, _namespaces).records;
1237
1404
  }
1405
+ get files() {
1406
+ if (!__privateGet$7(this, _namespaces).files)
1407
+ __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1408
+ return __privateGet$7(this, _namespaces).files;
1409
+ }
1238
1410
  get searchAndFilter() {
1239
1411
  if (!__privateGet$7(this, _namespaces).searchAndFilter)
1240
1412
  __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
@@ -1812,6 +1984,164 @@ class RecordsApi {
1812
1984
  });
1813
1985
  }
1814
1986
  }
1987
+ class FilesApi {
1988
+ constructor(extraProps) {
1989
+ this.extraProps = extraProps;
1990
+ }
1991
+ getFileItem({
1992
+ workspace,
1993
+ region,
1994
+ database,
1995
+ branch,
1996
+ table,
1997
+ record,
1998
+ column,
1999
+ fileId
2000
+ }) {
2001
+ return operationsByTag.files.getFileItem({
2002
+ pathParams: {
2003
+ workspace,
2004
+ region,
2005
+ dbBranchName: `${database}:${branch}`,
2006
+ tableName: table,
2007
+ recordId: record,
2008
+ columnName: column,
2009
+ fileId
2010
+ },
2011
+ ...this.extraProps
2012
+ });
2013
+ }
2014
+ putFileItem({
2015
+ workspace,
2016
+ region,
2017
+ database,
2018
+ branch,
2019
+ table,
2020
+ record,
2021
+ column,
2022
+ fileId,
2023
+ file
2024
+ }) {
2025
+ return operationsByTag.files.putFileItem({
2026
+ pathParams: {
2027
+ workspace,
2028
+ region,
2029
+ dbBranchName: `${database}:${branch}`,
2030
+ tableName: table,
2031
+ recordId: record,
2032
+ columnName: column,
2033
+ fileId
2034
+ },
2035
+ // @ts-ignore
2036
+ body: file,
2037
+ ...this.extraProps
2038
+ });
2039
+ }
2040
+ deleteFileItem({
2041
+ workspace,
2042
+ region,
2043
+ database,
2044
+ branch,
2045
+ table,
2046
+ record,
2047
+ column,
2048
+ fileId
2049
+ }) {
2050
+ return operationsByTag.files.deleteFileItem({
2051
+ pathParams: {
2052
+ workspace,
2053
+ region,
2054
+ dbBranchName: `${database}:${branch}`,
2055
+ tableName: table,
2056
+ recordId: record,
2057
+ columnName: column,
2058
+ fileId
2059
+ },
2060
+ ...this.extraProps
2061
+ });
2062
+ }
2063
+ getFile({
2064
+ workspace,
2065
+ region,
2066
+ database,
2067
+ branch,
2068
+ table,
2069
+ record,
2070
+ column
2071
+ }) {
2072
+ return operationsByTag.files.getFile({
2073
+ pathParams: {
2074
+ workspace,
2075
+ region,
2076
+ dbBranchName: `${database}:${branch}`,
2077
+ tableName: table,
2078
+ recordId: record,
2079
+ columnName: column
2080
+ },
2081
+ ...this.extraProps
2082
+ });
2083
+ }
2084
+ putFile({
2085
+ workspace,
2086
+ region,
2087
+ database,
2088
+ branch,
2089
+ table,
2090
+ record,
2091
+ column,
2092
+ file
2093
+ }) {
2094
+ return operationsByTag.files.putFile({
2095
+ pathParams: {
2096
+ workspace,
2097
+ region,
2098
+ dbBranchName: `${database}:${branch}`,
2099
+ tableName: table,
2100
+ recordId: record,
2101
+ columnName: column
2102
+ },
2103
+ body: file,
2104
+ ...this.extraProps
2105
+ });
2106
+ }
2107
+ deleteFile({
2108
+ workspace,
2109
+ region,
2110
+ database,
2111
+ branch,
2112
+ table,
2113
+ record,
2114
+ column
2115
+ }) {
2116
+ return operationsByTag.files.deleteFile({
2117
+ pathParams: {
2118
+ workspace,
2119
+ region,
2120
+ dbBranchName: `${database}:${branch}`,
2121
+ tableName: table,
2122
+ recordId: record,
2123
+ columnName: column
2124
+ },
2125
+ ...this.extraProps
2126
+ });
2127
+ }
2128
+ fileAccess({
2129
+ workspace,
2130
+ region,
2131
+ fileId,
2132
+ verify
2133
+ }) {
2134
+ return operationsByTag.files.fileAccess({
2135
+ pathParams: {
2136
+ workspace,
2137
+ region,
2138
+ fileId
2139
+ },
2140
+ queryParams: { verify },
2141
+ ...this.extraProps
2142
+ });
2143
+ }
2144
+ }
1815
2145
  class SearchAndFilterApi {
1816
2146
  constructor(extraProps) {
1817
2147
  this.extraProps = extraProps;
@@ -1903,6 +2233,21 @@ class SearchAndFilterApi {
1903
2233
  ...this.extraProps
1904
2234
  });
1905
2235
  }
2236
+ askTableSession({
2237
+ workspace,
2238
+ region,
2239
+ database,
2240
+ branch,
2241
+ table,
2242
+ sessionId,
2243
+ message
2244
+ }) {
2245
+ return operationsByTag.searchAndFilter.askTableSession({
2246
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2247
+ body: { message },
2248
+ ...this.extraProps
2249
+ });
2250
+ }
1906
2251
  summarizeTable({
1907
2252
  workspace,
1908
2253
  region,
@@ -2194,11 +2539,13 @@ class DatabaseApi {
2194
2539
  createDatabase({
2195
2540
  workspace,
2196
2541
  database,
2197
- data
2542
+ data,
2543
+ headers
2198
2544
  }) {
2199
2545
  return operationsByTag.databases.createDatabase({
2200
2546
  pathParams: { workspaceId: workspace, dbName: database },
2201
2547
  body: data,
2548
+ headers,
2202
2549
  ...this.extraProps
2203
2550
  });
2204
2551
  }
@@ -2231,6 +2578,17 @@ class DatabaseApi {
2231
2578
  ...this.extraProps
2232
2579
  });
2233
2580
  }
2581
+ renameDatabase({
2582
+ workspace,
2583
+ database,
2584
+ newName
2585
+ }) {
2586
+ return operationsByTag.databases.renameDatabase({
2587
+ pathParams: { workspaceId: workspace, dbName: database },
2588
+ body: { newName },
2589
+ ...this.extraProps
2590
+ });
2591
+ }
2234
2592
  getDatabaseGithubSettings({
2235
2593
  workspace,
2236
2594
  database
@@ -2277,11 +2635,192 @@ class XataApiPlugin {
2277
2635
  class XataPlugin {
2278
2636
  }
2279
2637
 
2638
+ function buildTransformString(transformations) {
2639
+ return transformations.flatMap(
2640
+ (t) => Object.entries(t).map(([key, value]) => {
2641
+ if (key === "trim") {
2642
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2643
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2644
+ }
2645
+ if (key === "gravity" && typeof value === "object") {
2646
+ const { x = 0.5, y = 0.5 } = value;
2647
+ return `${key}=${[x, y].join("x")}`;
2648
+ }
2649
+ return `${key}=${value}`;
2650
+ })
2651
+ ).join(",");
2652
+ }
2653
+ function transformImage(url, ...transformations) {
2654
+ if (!isDefined(url))
2655
+ return void 0;
2656
+ const newTransformations = buildTransformString(transformations);
2657
+ const { hostname, pathname, search } = new URL(url);
2658
+ const pathParts = pathname.split("/");
2659
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2660
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2661
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2662
+ const path = pathParts.join("/");
2663
+ return `https://${hostname}${transform}${path}${search}`;
2664
+ }
2665
+
2666
+ class XataFile {
2667
+ constructor(file) {
2668
+ this.id = file.id;
2669
+ this.name = file.name || "";
2670
+ this.mediaType = file.mediaType || "application/octet-stream";
2671
+ this.base64Content = file.base64Content;
2672
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2673
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2674
+ this.size = file.size ?? 0;
2675
+ this.version = file.version ?? 1;
2676
+ this.url = file.url || "";
2677
+ this.signedUrl = file.signedUrl;
2678
+ this.attributes = file.attributes || {};
2679
+ }
2680
+ static fromBuffer(buffer, options = {}) {
2681
+ const base64Content = buffer.toString("base64");
2682
+ return new XataFile({ ...options, base64Content });
2683
+ }
2684
+ toBuffer() {
2685
+ if (!this.base64Content) {
2686
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2687
+ }
2688
+ return Buffer.from(this.base64Content, "base64");
2689
+ }
2690
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2691
+ const uint8Array = new Uint8Array(arrayBuffer);
2692
+ return this.fromUint8Array(uint8Array, options);
2693
+ }
2694
+ toArrayBuffer() {
2695
+ if (!this.base64Content) {
2696
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2697
+ }
2698
+ const binary = atob(this.base64Content);
2699
+ return new ArrayBuffer(binary.length);
2700
+ }
2701
+ static fromUint8Array(uint8Array, options = {}) {
2702
+ let binary = "";
2703
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2704
+ binary += String.fromCharCode(uint8Array[i]);
2705
+ }
2706
+ const base64Content = btoa(binary);
2707
+ return new XataFile({ ...options, base64Content });
2708
+ }
2709
+ toUint8Array() {
2710
+ if (!this.base64Content) {
2711
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2712
+ }
2713
+ const binary = atob(this.base64Content);
2714
+ const uint8Array = new Uint8Array(binary.length);
2715
+ for (let i = 0; i < binary.length; i++) {
2716
+ uint8Array[i] = binary.charCodeAt(i);
2717
+ }
2718
+ return uint8Array;
2719
+ }
2720
+ static async fromBlob(file, options = {}) {
2721
+ const name = options.name ?? file.name;
2722
+ const mediaType = file.type;
2723
+ const arrayBuffer = await file.arrayBuffer();
2724
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2725
+ }
2726
+ toBlob() {
2727
+ if (!this.base64Content) {
2728
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2729
+ }
2730
+ const binary = atob(this.base64Content);
2731
+ const uint8Array = new Uint8Array(binary.length);
2732
+ for (let i = 0; i < binary.length; i++) {
2733
+ uint8Array[i] = binary.charCodeAt(i);
2734
+ }
2735
+ return new Blob([uint8Array], { type: this.mediaType });
2736
+ }
2737
+ static fromString(string, options = {}) {
2738
+ const base64Content = btoa(string);
2739
+ return new XataFile({ ...options, base64Content });
2740
+ }
2741
+ toString() {
2742
+ if (!this.base64Content) {
2743
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2744
+ }
2745
+ return atob(this.base64Content);
2746
+ }
2747
+ static fromBase64(base64Content, options = {}) {
2748
+ return new XataFile({ ...options, base64Content });
2749
+ }
2750
+ toBase64() {
2751
+ if (!this.base64Content) {
2752
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2753
+ }
2754
+ return this.base64Content;
2755
+ }
2756
+ transform(...options) {
2757
+ return {
2758
+ url: transformImage(this.url, ...options),
2759
+ signedUrl: transformImage(this.signedUrl, ...options),
2760
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2761
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2762
+ };
2763
+ }
2764
+ }
2765
+ const parseInputFileEntry = async (entry) => {
2766
+ if (!isDefined(entry))
2767
+ return null;
2768
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2769
+ return compactObject({
2770
+ id,
2771
+ // Name cannot be an empty string in our API
2772
+ name: name ? name : void 0,
2773
+ mediaType,
2774
+ base64Content,
2775
+ enablePublicUrl,
2776
+ signedUrlTimeout
2777
+ });
2778
+ };
2779
+
2280
2780
  function cleanFilter(filter) {
2281
- if (!filter)
2781
+ if (!isDefined(filter))
2282
2782
  return void 0;
2283
- const values = Object.values(filter).filter(Boolean).filter((value) => Array.isArray(value) ? value.length > 0 : true);
2284
- return values.length > 0 ? filter : void 0;
2783
+ if (!isObject(filter))
2784
+ return filter;
2785
+ const values = Object.fromEntries(
2786
+ Object.entries(filter).reduce((acc, [key, value]) => {
2787
+ if (!isDefined(value))
2788
+ return acc;
2789
+ if (Array.isArray(value)) {
2790
+ const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
2791
+ if (clean.length === 0)
2792
+ return acc;
2793
+ return [...acc, [key, clean]];
2794
+ }
2795
+ if (isObject(value)) {
2796
+ const clean = cleanFilter(value);
2797
+ if (!isDefined(clean))
2798
+ return acc;
2799
+ return [...acc, [key, clean]];
2800
+ }
2801
+ return [...acc, [key, value]];
2802
+ }, [])
2803
+ );
2804
+ return Object.keys(values).length > 0 ? values : void 0;
2805
+ }
2806
+
2807
+ function stringifyJson(value) {
2808
+ if (!isDefined(value))
2809
+ return value;
2810
+ if (isString(value))
2811
+ return value;
2812
+ try {
2813
+ return JSON.stringify(value);
2814
+ } catch (e) {
2815
+ return value;
2816
+ }
2817
+ }
2818
+ function parseJson(value) {
2819
+ try {
2820
+ return JSON.parse(value);
2821
+ } catch (e) {
2822
+ return value;
2823
+ }
2285
2824
  }
2286
2825
 
2287
2826
  var __accessCheck$6 = (obj, member, msg) => {
@@ -2310,31 +2849,59 @@ class Page {
2310
2849
  this.meta = meta;
2311
2850
  this.records = new RecordArray(this, records);
2312
2851
  }
2852
+ /**
2853
+ * Retrieves the next page of results.
2854
+ * @param size Maximum number of results to be retrieved.
2855
+ * @param offset Number of results to skip when retrieving the results.
2856
+ * @returns The next page or results.
2857
+ */
2313
2858
  async nextPage(size, offset) {
2314
2859
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2315
2860
  }
2861
+ /**
2862
+ * Retrieves the previous page of results.
2863
+ * @param size Maximum number of results to be retrieved.
2864
+ * @param offset Number of results to skip when retrieving the results.
2865
+ * @returns The previous page or results.
2866
+ */
2316
2867
  async previousPage(size, offset) {
2317
2868
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2318
2869
  }
2870
+ /**
2871
+ * Retrieves the start page of results.
2872
+ * @param size Maximum number of results to be retrieved.
2873
+ * @param offset Number of results to skip when retrieving the results.
2874
+ * @returns The start page or results.
2875
+ */
2319
2876
  async startPage(size, offset) {
2320
2877
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2321
2878
  }
2879
+ /**
2880
+ * Retrieves the end page of results.
2881
+ * @param size Maximum number of results to be retrieved.
2882
+ * @param offset Number of results to skip when retrieving the results.
2883
+ * @returns The end page or results.
2884
+ */
2322
2885
  async endPage(size, offset) {
2323
2886
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2324
2887
  }
2888
+ /**
2889
+ * Shortcut method to check if there will be additional results if the next page of results is retrieved.
2890
+ * @returns Whether or not there will be additional results in the next page of results.
2891
+ */
2325
2892
  hasNextPage() {
2326
2893
  return this.meta.page.more;
2327
2894
  }
2328
2895
  }
2329
2896
  _query = new WeakMap();
2330
- const PAGINATION_MAX_SIZE = 200;
2897
+ const PAGINATION_MAX_SIZE = 1e3;
2331
2898
  const PAGINATION_DEFAULT_SIZE = 20;
2332
- const PAGINATION_MAX_OFFSET = 800;
2899
+ const PAGINATION_MAX_OFFSET = 49e3;
2333
2900
  const PAGINATION_DEFAULT_OFFSET = 0;
2334
2901
  function isCursorPaginationOptions(options) {
2335
2902
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
2336
2903
  }
2337
- const _RecordArray = class extends Array {
2904
+ const _RecordArray = class _RecordArray extends Array {
2338
2905
  constructor(...args) {
2339
2906
  super(..._RecordArray.parseConstructorParams(...args));
2340
2907
  __privateAdd$6(this, _page, void 0);
@@ -2362,28 +2929,51 @@ const _RecordArray = class extends Array {
2362
2929
  map(callbackfn, thisArg) {
2363
2930
  return this.toArray().map(callbackfn, thisArg);
2364
2931
  }
2932
+ /**
2933
+ * Retrieve next page of records
2934
+ *
2935
+ * @returns A new array of objects
2936
+ */
2365
2937
  async nextPage(size, offset) {
2366
2938
  const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
2367
2939
  return new _RecordArray(newPage);
2368
2940
  }
2941
+ /**
2942
+ * Retrieve previous page of records
2943
+ *
2944
+ * @returns A new array of objects
2945
+ */
2369
2946
  async previousPage(size, offset) {
2370
2947
  const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
2371
2948
  return new _RecordArray(newPage);
2372
2949
  }
2950
+ /**
2951
+ * Retrieve start page of records
2952
+ *
2953
+ * @returns A new array of objects
2954
+ */
2373
2955
  async startPage(size, offset) {
2374
2956
  const newPage = await __privateGet$6(this, _page).startPage(size, offset);
2375
2957
  return new _RecordArray(newPage);
2376
2958
  }
2959
+ /**
2960
+ * Retrieve end page of records
2961
+ *
2962
+ * @returns A new array of objects
2963
+ */
2377
2964
  async endPage(size, offset) {
2378
2965
  const newPage = await __privateGet$6(this, _page).endPage(size, offset);
2379
2966
  return new _RecordArray(newPage);
2380
2967
  }
2968
+ /**
2969
+ * @returns Boolean indicating if there is a next page
2970
+ */
2381
2971
  hasNextPage() {
2382
2972
  return __privateGet$6(this, _page).meta.page.more;
2383
2973
  }
2384
2974
  };
2385
- let RecordArray = _RecordArray;
2386
2975
  _page = new WeakMap();
2976
+ let RecordArray = _RecordArray;
2387
2977
 
2388
2978
  var __accessCheck$5 = (obj, member, msg) => {
2389
2979
  if (!member.has(obj))
@@ -2408,13 +2998,14 @@ var __privateMethod$3 = (obj, member, method) => {
2408
2998
  return method;
2409
2999
  };
2410
3000
  var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
2411
- const _Query = class {
3001
+ const _Query = class _Query {
2412
3002
  constructor(repository, table, data, rawParent) {
2413
3003
  __privateAdd$5(this, _cleanFilterConstraint);
2414
3004
  __privateAdd$5(this, _table$1, void 0);
2415
3005
  __privateAdd$5(this, _repository, void 0);
2416
3006
  __privateAdd$5(this, _data, { filter: {} });
2417
- this.meta = { page: { cursor: "start", more: true } };
3007
+ // Implements pagination
3008
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
2418
3009
  this.records = new RecordArray(this, []);
2419
3010
  __privateSet$5(this, _table$1, table);
2420
3011
  if (repository) {
@@ -2451,18 +3042,38 @@ const _Query = class {
2451
3042
  const key = JSON.stringify({ columns, filter, sort, pagination });
2452
3043
  return toBase64(key);
2453
3044
  }
3045
+ /**
3046
+ * Builds a new query object representing a logical OR between the given subqueries.
3047
+ * @param queries An array of subqueries.
3048
+ * @returns A new Query object.
3049
+ */
2454
3050
  any(...queries) {
2455
3051
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
2456
3052
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
2457
3053
  }
3054
+ /**
3055
+ * Builds a new query object representing a logical AND between the given subqueries.
3056
+ * @param queries An array of subqueries.
3057
+ * @returns A new Query object.
3058
+ */
2458
3059
  all(...queries) {
2459
3060
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
2460
3061
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
2461
3062
  }
3063
+ /**
3064
+ * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
3065
+ * @param queries An array of subqueries.
3066
+ * @returns A new Query object.
3067
+ */
2462
3068
  not(...queries) {
2463
3069
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
2464
3070
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
2465
3071
  }
3072
+ /**
3073
+ * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
3074
+ * @param queries An array of subqueries.
3075
+ * @returns A new Query object.
3076
+ */
2466
3077
  none(...queries) {
2467
3078
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
2468
3079
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
@@ -2485,6 +3096,11 @@ const _Query = class {
2485
3096
  const sort = [...originalSort, { column, direction }];
2486
3097
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
2487
3098
  }
3099
+ /**
3100
+ * Builds a new query specifying the set of columns to be returned in the query response.
3101
+ * @param columns Array of column names to be returned by the query.
3102
+ * @returns A new Query object.
3103
+ */
2488
3104
  select(columns) {
2489
3105
  return new _Query(
2490
3106
  __privateGet$5(this, _repository),
@@ -2497,6 +3113,12 @@ const _Query = class {
2497
3113
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
2498
3114
  return __privateGet$5(this, _repository).query(query);
2499
3115
  }
3116
+ /**
3117
+ * Get results in an iterator
3118
+ *
3119
+ * @async
3120
+ * @returns Async interable of results
3121
+ */
2500
3122
  async *[Symbol.asyncIterator]() {
2501
3123
  for await (const [record] of this.getIterator({ batchSize: 1 })) {
2502
3124
  yield record;
@@ -2557,26 +3179,53 @@ const _Query = class {
2557
3179
  );
2558
3180
  return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
2559
3181
  }
3182
+ /**
3183
+ * Builds a new query object adding a cache TTL in milliseconds.
3184
+ * @param ttl The cache TTL in milliseconds.
3185
+ * @returns A new Query object.
3186
+ */
2560
3187
  cache(ttl) {
2561
3188
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
2562
3189
  }
3190
+ /**
3191
+ * Retrieve next page of records
3192
+ *
3193
+ * @returns A new page object.
3194
+ */
2563
3195
  nextPage(size, offset) {
2564
3196
  return this.startPage(size, offset);
2565
3197
  }
3198
+ /**
3199
+ * Retrieve previous page of records
3200
+ *
3201
+ * @returns A new page object
3202
+ */
2566
3203
  previousPage(size, offset) {
2567
3204
  return this.startPage(size, offset);
2568
3205
  }
3206
+ /**
3207
+ * Retrieve start page of records
3208
+ *
3209
+ * @returns A new page object
3210
+ */
2569
3211
  startPage(size, offset) {
2570
3212
  return this.getPaginated({ pagination: { size, offset } });
2571
3213
  }
3214
+ /**
3215
+ * Retrieve last page of records
3216
+ *
3217
+ * @returns A new page object
3218
+ */
2572
3219
  endPage(size, offset) {
2573
3220
  return this.getPaginated({ pagination: { size, offset, before: "end" } });
2574
3221
  }
3222
+ /**
3223
+ * @returns Boolean indicating if there is a next page
3224
+ */
2575
3225
  hasNextPage() {
2576
3226
  return this.meta.page.more;
2577
3227
  }
2578
3228
  };
2579
- let Query = _Query;
2580
3229
  _table$1 = new WeakMap();
2581
3230
  _repository = new WeakMap();
2582
3231
  _data = new WeakMap();
@@ -2591,6 +3240,7 @@ cleanFilterConstraint_fn = function(column, value) {
2591
3240
  }
2592
3241
  return value;
2593
3242
  };
3243
+ let Query = _Query;
2594
3244
  function cleanParent(data, parent) {
2595
3245
  if (isCursorPaginationOptions(data.pagination)) {
2596
3246
  return { ...parent, sort: void 0, filter: void 0 };
@@ -2598,6 +3248,22 @@ function cleanParent(data, parent) {
2598
3248
  return parent;
2599
3249
  }
2600
3250
 
3251
+ const RecordColumnTypes = [
3252
+ "bool",
3253
+ "int",
3254
+ "float",
3255
+ "string",
3256
+ "text",
3257
+ "email",
3258
+ "multiple",
3259
+ "link",
3260
+ "object",
3261
+ "datetime",
3262
+ "vector",
3263
+ "file[]",
3264
+ "file",
3265
+ "json"
3266
+ ];
2601
3267
  function isIdentifiable(x) {
2602
3268
  return isObject(x) && isString(x?.id);
2603
3269
  }
@@ -2607,11 +3273,33 @@ function isXataRecord(x) {
2607
3273
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
2608
3274
  }
2609
3275
 
3276
+ function isValidExpandedColumn(column) {
3277
+ return isObject(column) && isString(column.name);
3278
+ }
3279
+ function isValidSelectableColumns(columns) {
3280
+ if (!Array.isArray(columns)) {
3281
+ return false;
3282
+ }
3283
+ return columns.every((column) => {
3284
+ if (typeof column === "string") {
3285
+ return true;
3286
+ }
3287
+ if (typeof column === "object") {
3288
+ return isValidExpandedColumn(column);
3289
+ }
3290
+ return false;
3291
+ });
3292
+ }
3293
+
2610
3294
  function isSortFilterString(value) {
2611
3295
  return isString(value);
2612
3296
  }
2613
3297
  function isSortFilterBase(filter) {
2614
- return isObject(filter) && Object.values(filter).every((value) => value === "asc" || value === "desc");
3298
+ return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3299
+ if (key === "*")
3300
+ return value === "random";
3301
+ return value === "asc" || value === "desc";
3302
+ });
2615
3303
  }
2616
3304
  function isSortFilterObject(filter) {
2617
3305
  return isObject(filter) && !isSortFilterBase(filter) && filter.column !== void 0;
@@ -2652,7 +3340,7 @@ var __privateMethod$2 = (obj, member, method) => {
2652
3340
  __accessCheck$4(obj, member, "access private method");
2653
3341
  return method;
2654
3342
  };
2655
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
3343
+ var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1, _transformObjectToApi, transformObjectToApi_fn;
2656
3344
  const BULK_OPERATION_MAX_SIZE = 1e3;
2657
3345
  class Repository extends Query {
2658
3346
  }
@@ -2674,6 +3362,7 @@ class RestRepository extends Query {
2674
3362
  __privateAdd$4(this, _setCacheQuery);
2675
3363
  __privateAdd$4(this, _getCacheQuery);
2676
3364
  __privateAdd$4(this, _getSchemaTables$1);
3365
+ __privateAdd$4(this, _transformObjectToApi);
2677
3366
  __privateAdd$4(this, _table, void 0);
2678
3367
  __privateAdd$4(this, _getFetchProps, void 0);
2679
3368
  __privateAdd$4(this, _db, void 0);
@@ -2702,24 +3391,24 @@ class RestRepository extends Query {
2702
3391
  if (a.length === 0)
2703
3392
  return [];
2704
3393
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
2705
- const columns = isStringArray(b) ? b : ["*"];
3394
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2706
3395
  const result = await this.read(ids, columns);
2707
3396
  return result;
2708
3397
  }
2709
3398
  if (isString(a) && isObject(b)) {
2710
3399
  if (a === "")
2711
3400
  throw new Error("The id can't be empty");
2712
- const columns = isStringArray(c) ? c : void 0;
3401
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2713
3402
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
2714
3403
  }
2715
3404
  if (isObject(a) && isString(a.id)) {
2716
3405
  if (a.id === "")
2717
3406
  throw new Error("The id can't be empty");
2718
- const columns = isStringArray(b) ? b : void 0;
3407
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2719
3408
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
2720
3409
  }
2721
3410
  if (isObject(a)) {
2722
- const columns = isStringArray(b) ? b : void 0;
3411
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2723
3412
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
2724
3413
  }
2725
3414
  throw new Error("Invalid arguments for create method");
@@ -2727,7 +3416,7 @@ class RestRepository extends Query {
2727
3416
  }
2728
3417
  async read(a, b) {
2729
3418
  return __privateGet$4(this, _trace).call(this, "read", async () => {
2730
- const columns = isStringArray(b) ? b : ["*"];
3419
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2731
3420
  if (Array.isArray(a)) {
2732
3421
  if (a.length === 0)
2733
3422
  return [];
@@ -2754,7 +3443,13 @@ class RestRepository extends Query {
2754
3443
  ...__privateGet$4(this, _getFetchProps).call(this)
2755
3444
  });
2756
3445
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2757
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3446
+ return initObject(
3447
+ __privateGet$4(this, _db),
3448
+ schemaTables,
3449
+ __privateGet$4(this, _table),
3450
+ response,
3451
+ columns
3452
+ );
2758
3453
  } catch (e) {
2759
3454
  if (isObject(e) && e.status === 404) {
2760
3455
  return null;
@@ -2796,17 +3491,17 @@ class RestRepository extends Query {
2796
3491
  ifVersion,
2797
3492
  upsert: false
2798
3493
  });
2799
- const columns = isStringArray(b) ? b : ["*"];
3494
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2800
3495
  const result = await this.read(a, columns);
2801
3496
  return result;
2802
3497
  }
2803
3498
  try {
2804
3499
  if (isString(a) && isObject(b)) {
2805
- const columns = isStringArray(c) ? c : void 0;
3500
+ const columns = isValidSelectableColumns(c) ? c : void 0;
2806
3501
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2807
3502
  }
2808
3503
  if (isObject(a) && isString(a.id)) {
2809
- const columns = isStringArray(b) ? b : void 0;
3504
+ const columns = isValidSelectableColumns(b) ? b : void 0;
2810
3505
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2811
3506
  }
2812
3507
  } catch (error) {
@@ -2846,17 +3541,27 @@ class RestRepository extends Query {
2846
3541
  ifVersion,
2847
3542
  upsert: true
2848
3543
  });
2849
- const columns = isStringArray(b) ? b : ["*"];
3544
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2850
3545
  const result = await this.read(a, columns);
2851
3546
  return result;
2852
3547
  }
2853
3548
  if (isString(a) && isObject(b)) {
2854
- const columns = isStringArray(c) ? c : void 0;
2855
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3549
+ if (a === "")
3550
+ throw new Error("The id can't be empty");
3551
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3552
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2856
3553
  }
2857
3554
  if (isObject(a) && isString(a.id)) {
2858
- const columns = isStringArray(c) ? c : void 0;
2859
- return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3555
+ if (a.id === "")
3556
+ throw new Error("The id can't be empty");
3557
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3558
+ return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3559
+ }
3560
+ if (!isDefined(a) && isObject(b)) {
3561
+ return await this.create(b, c);
3562
+ }
3563
+ if (isObject(a) && !isDefined(a.id)) {
3564
+ return await this.create(a, b);
2860
3565
  }
2861
3566
  throw new Error("Invalid arguments for createOrUpdate method");
2862
3567
  });
@@ -2868,17 +3573,27 @@ class RestRepository extends Query {
2868
3573
  if (a.length === 0)
2869
3574
  return [];
2870
3575
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
2871
- const columns = isStringArray(b) ? b : ["*"];
3576
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2872
3577
  const result = await this.read(ids, columns);
2873
3578
  return result;
2874
3579
  }
2875
3580
  if (isString(a) && isObject(b)) {
2876
- const columns = isStringArray(c) ? c : void 0;
2877
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3581
+ if (a === "")
3582
+ throw new Error("The id can't be empty");
3583
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3584
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
2878
3585
  }
2879
3586
  if (isObject(a) && isString(a.id)) {
2880
- const columns = isStringArray(c) ? c : void 0;
2881
- return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3587
+ if (a.id === "")
3588
+ throw new Error("The id can't be empty");
3589
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3590
+ return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3591
+ }
3592
+ if (!isDefined(a) && isObject(b)) {
3593
+ return await this.create(b, c);
3594
+ }
3595
+ if (isObject(a) && !isDefined(a.id)) {
3596
+ return await this.create(a, b);
2882
3597
  }
2883
3598
  throw new Error("Invalid arguments for createOrReplace method");
2884
3599
  });
@@ -2895,7 +3610,7 @@ class RestRepository extends Query {
2895
3610
  return o.id;
2896
3611
  throw new Error("Invalid arguments for delete method");
2897
3612
  });
2898
- const columns = isStringArray(b) ? b : ["*"];
3613
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
2899
3614
  const result = await this.read(a, columns);
2900
3615
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
2901
3616
  return result;
@@ -2929,7 +3644,7 @@ class RestRepository extends Query {
2929
3644
  }
2930
3645
  async search(query, options = {}) {
2931
3646
  return __privateGet$4(this, _trace).call(this, "search", async () => {
2932
- const { records } = await searchTable({
3647
+ const { records, totalCount } = await searchTable({
2933
3648
  pathParams: {
2934
3649
  workspace: "{workspaceId}",
2935
3650
  dbBranchName: "{dbBranch}",
@@ -2949,12 +3664,15 @@ class RestRepository extends Query {
2949
3664
  ...__privateGet$4(this, _getFetchProps).call(this)
2950
3665
  });
2951
3666
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2952
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3667
+ return {
3668
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3669
+ totalCount
3670
+ };
2953
3671
  });
2954
3672
  }
2955
3673
  async vectorSearch(column, query, options) {
2956
3674
  return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
2957
- const { records } = await vectorSearchTable({
3675
+ const { records, totalCount } = await vectorSearchTable({
2958
3676
  pathParams: {
2959
3677
  workspace: "{workspaceId}",
2960
3678
  dbBranchName: "{dbBranch}",
@@ -2971,7 +3689,10 @@ class RestRepository extends Query {
2971
3689
  ...__privateGet$4(this, _getFetchProps).call(this)
2972
3690
  });
2973
3691
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
2974
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3692
+ return {
3693
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3694
+ totalCount
3695
+ };
2975
3696
  });
2976
3697
  }
2977
3698
  async aggregate(aggs, filter) {
@@ -3014,7 +3735,13 @@ class RestRepository extends Query {
3014
3735
  });
3015
3736
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3016
3737
  const records = objects.map(
3017
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3738
+ (record) => initObject(
3739
+ __privateGet$4(this, _db),
3740
+ schemaTables,
3741
+ __privateGet$4(this, _table),
3742
+ record,
3743
+ data.columns ?? ["*"]
3744
+ )
3018
3745
  );
3019
3746
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
3020
3747
  return new Page(query, meta, records);
@@ -3041,27 +3768,38 @@ class RestRepository extends Query {
3041
3768
  },
3042
3769
  ...__privateGet$4(this, _getFetchProps).call(this)
3043
3770
  });
3044
- return result;
3771
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3772
+ return {
3773
+ ...result,
3774
+ summaries: result.summaries.map(
3775
+ (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3776
+ )
3777
+ };
3045
3778
  });
3046
3779
  }
3047
3780
  ask(question, options) {
3781
+ const questionParam = options?.sessionId ? { message: question } : { question };
3048
3782
  const params = {
3049
3783
  pathParams: {
3050
3784
  workspace: "{workspaceId}",
3051
3785
  dbBranchName: "{dbBranch}",
3052
3786
  region: "{region}",
3053
- tableName: __privateGet$4(this, _table)
3787
+ tableName: __privateGet$4(this, _table),
3788
+ sessionId: options?.sessionId
3054
3789
  },
3055
3790
  body: {
3056
- question,
3057
- ...options
3791
+ ...questionParam,
3792
+ rules: options?.rules,
3793
+ searchType: options?.searchType,
3794
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3795
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3058
3796
  },
3059
3797
  ...__privateGet$4(this, _getFetchProps).call(this)
3060
3798
  };
3061
3799
  if (options?.onMessage) {
3062
3800
  fetchSSERequest({
3063
3801
  endpoint: "dataPlane",
3064
- url: "/db/{dbBranchName}/tables/{tableName}/ask",
3802
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3065
3803
  method: "POST",
3066
3804
  onMessage: (message) => {
3067
3805
  options.onMessage?.({ answer: message.text, records: message.records });
@@ -3069,7 +3807,7 @@ class RestRepository extends Query {
3069
3807
  ...params
3070
3808
  });
3071
3809
  } else {
3072
- return askTable(params);
3810
+ return askTableSession(params);
3073
3811
  }
3074
3812
  }
3075
3813
  }
@@ -3081,7 +3819,7 @@ _schemaTables$2 = new WeakMap();
3081
3819
  _trace = new WeakMap();
3082
3820
  _insertRecordWithoutId = new WeakSet();
3083
3821
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3084
- const record = transformObjectLinks(object);
3822
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3085
3823
  const response = await insertRecord({
3086
3824
  pathParams: {
3087
3825
  workspace: "{workspaceId}",
@@ -3098,7 +3836,9 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3098
3836
  };
3099
3837
  _insertRecordWithId = new WeakSet();
3100
3838
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
3101
- const record = transformObjectLinks(object);
3839
+ if (!recordId)
3840
+ return null;
3841
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3102
3842
  const response = await insertRecordWithID({
3103
3843
  pathParams: {
3104
3844
  workspace: "{workspaceId}",
@@ -3116,21 +3856,20 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
3116
3856
  };
3117
3857
  _insertRecords = new WeakSet();
3118
3858
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3119
- const chunkedOperations = chunk(
3120
- objects.map((object) => ({
3121
- insert: { table: __privateGet$4(this, _table), record: transformObjectLinks(object), createOnly, ifVersion }
3122
- })),
3123
- BULK_OPERATION_MAX_SIZE
3124
- );
3859
+ const operations = await promiseMap(objects, async (object) => {
3860
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3861
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3862
+ });
3863
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3125
3864
  const ids = [];
3126
- for (const operations of chunkedOperations) {
3865
+ for (const operations2 of chunkedOperations) {
3127
3866
  const { results } = await branchTransaction({
3128
3867
  pathParams: {
3129
3868
  workspace: "{workspaceId}",
3130
3869
  dbBranchName: "{dbBranch}",
3131
3870
  region: "{region}"
3132
3871
  },
3133
- body: { operations },
3872
+ body: { operations: operations2 },
3134
3873
  ...__privateGet$4(this, _getFetchProps).call(this)
3135
3874
  });
3136
3875
  for (const result of results) {
@@ -3145,7 +3884,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3145
3884
  };
3146
3885
  _updateRecordWithID = new WeakSet();
3147
3886
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3148
- const { id: _id, ...record } = transformObjectLinks(object);
3887
+ if (!recordId)
3888
+ return null;
3889
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3149
3890
  try {
3150
3891
  const response = await updateRecordWithID({
3151
3892
  pathParams: {
@@ -3170,21 +3911,20 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3170
3911
  };
3171
3912
  _updateRecords = new WeakSet();
3172
3913
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3173
- const chunkedOperations = chunk(
3174
- objects.map(({ id, ...object }) => ({
3175
- update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: transformObjectLinks(object) }
3176
- })),
3177
- BULK_OPERATION_MAX_SIZE
3178
- );
3914
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
3915
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3916
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
3917
+ });
3918
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3179
3919
  const ids = [];
3180
- for (const operations of chunkedOperations) {
3920
+ for (const operations2 of chunkedOperations) {
3181
3921
  const { results } = await branchTransaction({
3182
3922
  pathParams: {
3183
3923
  workspace: "{workspaceId}",
3184
3924
  dbBranchName: "{dbBranch}",
3185
3925
  region: "{region}"
3186
3926
  },
3187
- body: { operations },
3927
+ body: { operations: operations2 },
3188
3928
  ...__privateGet$4(this, _getFetchProps).call(this)
3189
3929
  });
3190
3930
  for (const result of results) {
@@ -3199,6 +3939,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3199
3939
  };
3200
3940
  _upsertRecordWithID = new WeakSet();
3201
3941
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3942
+ if (!recordId)
3943
+ return null;
3202
3944
  const response = await upsertRecordWithID({
3203
3945
  pathParams: {
3204
3946
  workspace: "{workspaceId}",
@@ -3216,6 +3958,8 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3216
3958
  };
3217
3959
  _deleteRecord = new WeakSet();
3218
3960
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
3961
+ if (!recordId)
3962
+ return null;
3219
3963
  try {
3220
3964
  const response = await deleteRecord({
3221
3965
  pathParams: {
@@ -3240,7 +3984,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
3240
3984
  _deleteRecords = new WeakSet();
3241
3985
  deleteRecords_fn = async function(recordIds) {
3242
3986
  const chunkedOperations = chunk(
3243
- recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
3987
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
3244
3988
  BULK_OPERATION_MAX_SIZE
3245
3989
  );
3246
3990
  for (const operations of chunkedOperations) {
@@ -3257,7 +4001,7 @@ deleteRecords_fn = async function(recordIds) {
3257
4001
  };
3258
4002
  _setCacheQuery = new WeakSet();
3259
4003
  setCacheQuery_fn = async function(query, meta, records) {
3260
- await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
4004
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
3261
4005
  };
3262
4006
  _getCacheQuery = new WeakSet();
3263
4007
  getCacheQuery_fn = async function(query) {
@@ -3283,12 +4027,40 @@ getSchemaTables_fn$1 = async function() {
3283
4027
  __privateSet$4(this, _schemaTables$2, schema.tables);
3284
4028
  return schema.tables;
3285
4029
  };
3286
- const transformObjectLinks = (object) => {
3287
- return Object.entries(object).reduce((acc, [key, value]) => {
4030
+ _transformObjectToApi = new WeakSet();
4031
+ transformObjectToApi_fn = async function(object) {
4032
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4033
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4034
+ if (!schema)
4035
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4036
+ const result = {};
4037
+ for (const [key, value] of Object.entries(object)) {
3288
4038
  if (key === "xata")
3289
- return acc;
3290
- return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
3291
- }, {});
4039
+ continue;
4040
+ const type = schema.columns.find((column) => column.name === key)?.type;
4041
+ switch (type) {
4042
+ case "link": {
4043
+ result[key] = isIdentifiable(value) ? value.id : value;
4044
+ break;
4045
+ }
4046
+ case "datetime": {
4047
+ result[key] = value instanceof Date ? value.toISOString() : value;
4048
+ break;
4049
+ }
4050
+ case `file`:
4051
+ result[key] = await parseInputFileEntry(value);
4052
+ break;
4053
+ case "file[]":
4054
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4055
+ break;
4056
+ case "json":
4057
+ result[key] = stringifyJson(value);
4058
+ break;
4059
+ default:
4060
+ result[key] = value;
4061
+ }
4062
+ }
4063
+ return result;
3292
4064
  };
3293
4065
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
3294
4066
  const data = {};
@@ -3320,18 +4092,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3320
4092
  if (item === column.name) {
3321
4093
  return [...acc, "*"];
3322
4094
  }
3323
- if (item.startsWith(`${column.name}.`)) {
4095
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
3324
4096
  const [, ...path] = item.split(".");
3325
4097
  return [...acc, path.join(".")];
3326
4098
  }
3327
4099
  return acc;
3328
4100
  }, []);
3329
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4101
+ data[column.name] = initObject(
4102
+ db,
4103
+ schemaTables,
4104
+ linkTable,
4105
+ value,
4106
+ selectedLinkColumns
4107
+ );
3330
4108
  } else {
3331
4109
  data[column.name] = null;
3332
4110
  }
3333
4111
  break;
3334
4112
  }
4113
+ case "file":
4114
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4115
+ break;
4116
+ case "file[]":
4117
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4118
+ break;
4119
+ case "json":
4120
+ data[column.name] = parseJson(value);
4121
+ break;
3335
4122
  default:
3336
4123
  data[column.name] = value ?? null;
3337
4124
  if (column.notNull === true && value === null) {
@@ -3341,30 +4128,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3341
4128
  }
3342
4129
  }
3343
4130
  const record = { ...data };
4131
+ const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
3344
4132
  record.read = function(columns2) {
3345
4133
  return db[table].read(record["id"], columns2);
3346
4134
  };
3347
4135
  record.update = function(data2, b, c) {
3348
- const columns2 = isStringArray(b) ? b : ["*"];
4136
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
3349
4137
  const ifVersion = parseIfVersion(b, c);
3350
4138
  return db[table].update(record["id"], data2, columns2, { ifVersion });
3351
4139
  };
3352
4140
  record.replace = function(data2, b, c) {
3353
- const columns2 = isStringArray(b) ? b : ["*"];
4141
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
3354
4142
  const ifVersion = parseIfVersion(b, c);
3355
4143
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
3356
4144
  };
3357
4145
  record.delete = function() {
3358
4146
  return db[table].delete(record["id"]);
3359
4147
  };
4148
+ if (metadata !== void 0) {
4149
+ record.xata = Object.freeze(metadata);
4150
+ }
3360
4151
  record.getMetadata = function() {
3361
- return xata;
4152
+ return record.xata;
3362
4153
  };
3363
4154
  record.toSerializable = function() {
3364
- return JSON.parse(JSON.stringify(transformObjectLinks(data)));
4155
+ return JSON.parse(JSON.stringify(record));
3365
4156
  };
3366
4157
  record.toString = function() {
3367
- return JSON.stringify(transformObjectLinks(data));
4158
+ return JSON.stringify(record);
3368
4159
  };
3369
4160
  for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3370
4161
  Object.defineProperty(record, prop, { enumerable: false });
@@ -3382,11 +4173,7 @@ function extractId(value) {
3382
4173
  function isValidColumn(columns, column) {
3383
4174
  if (columns.includes("*"))
3384
4175
  return true;
3385
- if (column.type === "link") {
3386
- const linkColumns = columns.filter((item) => item.startsWith(column.name));
3387
- return linkColumns.length > 0;
3388
- }
3389
- return columns.includes(column.name);
4176
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
3390
4177
  }
3391
4178
  function parseIfVersion(...args) {
3392
4179
  for (const arg of args) {
@@ -3463,10 +4250,12 @@ const notExists = (column) => ({ $notExists: column });
3463
4250
  const startsWith = (value) => ({ $startsWith: value });
3464
4251
  const endsWith = (value) => ({ $endsWith: value });
3465
4252
  const pattern = (value) => ({ $pattern: value });
4253
+ const iPattern = (value) => ({ $iPattern: value });
3466
4254
  const is = (value) => ({ $is: value });
3467
4255
  const equals = is;
3468
4256
  const isNot = (value) => ({ $isNot: value });
3469
4257
  const contains = (value) => ({ $contains: value });
4258
+ const iContains = (value) => ({ $iContains: value });
3470
4259
  const includes = (value) => ({ $includes: value });
3471
4260
  const includesAll = (value) => ({ $includesAll: value });
3472
4261
  const includesNone = (value) => ({ $includesNone: value });
@@ -3522,6 +4311,80 @@ class SchemaPlugin extends XataPlugin {
3522
4311
  _tables = new WeakMap();
3523
4312
  _schemaTables$1 = new WeakMap();
3524
4313
 
4314
+ class FilesPlugin extends XataPlugin {
4315
+ build(pluginOptions) {
4316
+ return {
4317
+ download: async (location) => {
4318
+ const { table, record, column, fileId = "" } = location ?? {};
4319
+ return await getFileItem({
4320
+ pathParams: {
4321
+ workspace: "{workspaceId}",
4322
+ dbBranchName: "{dbBranch}",
4323
+ region: "{region}",
4324
+ tableName: table ?? "",
4325
+ recordId: record ?? "",
4326
+ columnName: column ?? "",
4327
+ fileId
4328
+ },
4329
+ ...pluginOptions,
4330
+ rawResponse: true
4331
+ });
4332
+ },
4333
+ upload: async (location, file, options) => {
4334
+ const { table, record, column, fileId = "" } = location ?? {};
4335
+ const resolvedFile = await file;
4336
+ const contentType = options?.mediaType || getContentType(resolvedFile);
4337
+ const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
4338
+ return await putFileItem({
4339
+ ...pluginOptions,
4340
+ pathParams: {
4341
+ workspace: "{workspaceId}",
4342
+ dbBranchName: "{dbBranch}",
4343
+ region: "{region}",
4344
+ tableName: table ?? "",
4345
+ recordId: record ?? "",
4346
+ columnName: column ?? "",
4347
+ fileId
4348
+ },
4349
+ body,
4350
+ headers: { "Content-Type": contentType }
4351
+ });
4352
+ },
4353
+ delete: async (location) => {
4354
+ const { table, record, column, fileId = "" } = location ?? {};
4355
+ return await deleteFileItem({
4356
+ pathParams: {
4357
+ workspace: "{workspaceId}",
4358
+ dbBranchName: "{dbBranch}",
4359
+ region: "{region}",
4360
+ tableName: table ?? "",
4361
+ recordId: record ?? "",
4362
+ columnName: column ?? "",
4363
+ fileId
4364
+ },
4365
+ ...pluginOptions
4366
+ });
4367
+ }
4368
+ };
4369
+ }
4370
+ }
4371
+ function getContentType(file) {
4372
+ if (typeof file === "string") {
4373
+ return "text/plain";
4374
+ }
4375
+ if ("mediaType" in file) {
4376
+ return file.mediaType;
4377
+ }
4378
+ if (isBlob(file)) {
4379
+ return file.type;
4380
+ }
4381
+ try {
4382
+ return file.type;
4383
+ } catch (e) {
4384
+ }
4385
+ return "application/octet-stream";
4386
+ }
4387
+
3525
4388
  var __accessCheck$1 = (obj, member, msg) => {
3526
4389
  if (!member.has(obj))
3527
4390
  throw TypeError("Cannot " + msg);
@@ -3557,22 +4420,26 @@ class SearchPlugin extends XataPlugin {
3557
4420
  build(pluginOptions) {
3558
4421
  return {
3559
4422
  all: async (query, options = {}) => {
3560
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4423
+ const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3561
4424
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3562
- return records.map((record) => {
3563
- const { table = "orphan" } = record.xata;
3564
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
3565
- });
4425
+ return {
4426
+ totalCount,
4427
+ records: records.map((record) => {
4428
+ const { table = "orphan" } = record.xata;
4429
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4430
+ })
4431
+ };
3566
4432
  },
3567
4433
  byTable: async (query, options = {}) => {
3568
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4434
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
3569
4435
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
3570
- return records.reduce((acc, record) => {
4436
+ const records = rawRecords.reduce((acc, record) => {
3571
4437
  const { table = "orphan" } = record.xata;
3572
4438
  const items = acc[table] ?? [];
3573
4439
  const item = initObject(this.db, schemaTables, table, record, ["*"]);
3574
4440
  return { ...acc, [table]: [...items, item] };
3575
4441
  }, {});
4442
+ return { totalCount, records };
3576
4443
  }
3577
4444
  };
3578
4445
  }
@@ -3581,12 +4448,13 @@ _schemaTables = new WeakMap();
3581
4448
  _search = new WeakSet();
3582
4449
  search_fn = async function(query, options, pluginOptions) {
3583
4450
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
3584
- const { records } = await searchBranch({
4451
+ const { records, totalCount } = await searchBranch({
3585
4452
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4453
+ // @ts-ignore https://github.com/xataio/client-ts/issues/313
3586
4454
  body: { tables, query, fuzziness, prefix, highlight, page },
3587
4455
  ...pluginOptions
3588
4456
  });
3589
- return records;
4457
+ return { records, totalCount };
3590
4458
  };
3591
4459
  _getSchemaTables = new WeakSet();
3592
4460
  getSchemaTables_fn = async function(pluginOptions) {
@@ -3600,6 +4468,78 @@ getSchemaTables_fn = async function(pluginOptions) {
3600
4468
  return schema.tables;
3601
4469
  };
3602
4470
 
4471
+ function escapeElement(elementRepresentation) {
4472
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4473
+ return '"' + escaped + '"';
4474
+ }
4475
+ function arrayString(val) {
4476
+ let result = "{";
4477
+ for (let i = 0; i < val.length; i++) {
4478
+ if (i > 0) {
4479
+ result = result + ",";
4480
+ }
4481
+ if (val[i] === null || typeof val[i] === "undefined") {
4482
+ result = result + "NULL";
4483
+ } else if (Array.isArray(val[i])) {
4484
+ result = result + arrayString(val[i]);
4485
+ } else if (val[i] instanceof Buffer) {
4486
+ result += "\\\\x" + val[i].toString("hex");
4487
+ } else {
4488
+ result += escapeElement(prepareValue(val[i]));
4489
+ }
4490
+ }
4491
+ result = result + "}";
4492
+ return result;
4493
+ }
4494
+ function prepareValue(value) {
4495
+ if (!isDefined(value))
4496
+ return null;
4497
+ if (value instanceof Date) {
4498
+ return value.toISOString();
4499
+ }
4500
+ if (Array.isArray(value)) {
4501
+ return arrayString(value);
4502
+ }
4503
+ if (isObject(value)) {
4504
+ return JSON.stringify(value);
4505
+ }
4506
+ try {
4507
+ return value.toString();
4508
+ } catch (e) {
4509
+ return value;
4510
+ }
4511
+ }
4512
+ function prepareParams(param1, param2) {
4513
+ if (isString(param1)) {
4514
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4515
+ }
4516
+ if (isStringArray(param1)) {
4517
+ const statement = param1.reduce((acc, curr, index) => {
4518
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4519
+ }, "");
4520
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4521
+ }
4522
+ if (isObject(param1)) {
4523
+ const { statement, params, consistency } = param1;
4524
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4525
+ }
4526
+ throw new Error("Invalid query");
4527
+ }
4528
+
4529
+ class SQLPlugin extends XataPlugin {
4530
+ build(pluginOptions) {
4531
+ return async (param1, ...param2) => {
4532
+ const { statement, params, consistency } = prepareParams(param1, param2);
4533
+ const { records, warning } = await sqlQuery({
4534
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4535
+ body: { statement, params, consistency },
4536
+ ...pluginOptions
4537
+ });
4538
+ return { records, warning };
4539
+ };
4540
+ }
4541
+ }
4542
+
3603
4543
  class TransactionPlugin extends XataPlugin {
3604
4544
  build(pluginOptions) {
3605
4545
  return {
@@ -3654,9 +4594,13 @@ const buildClient = (plugins) => {
3654
4594
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
3655
4595
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
3656
4596
  const transactions = new TransactionPlugin().build(pluginOptions);
4597
+ const sql = new SQLPlugin().build(pluginOptions);
4598
+ const files = new FilesPlugin().build(pluginOptions);
3657
4599
  this.db = db;
3658
4600
  this.search = search;
3659
4601
  this.transactions = transactions;
4602
+ this.sql = sql;
4603
+ this.files = files;
3660
4604
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
3661
4605
  if (namespace === void 0)
3662
4606
  continue;
@@ -3737,6 +4681,7 @@ const buildClient = (plugins) => {
3737
4681
  fetch,
3738
4682
  apiKey,
3739
4683
  apiUrl: "",
4684
+ // Instead of using workspace and dbBranch, we inject a probably CNAME'd URL
3740
4685
  workspacesApiUrl: (path, params) => {
3741
4686
  const hasBranch = params.dbBranchName ?? params.branch;
3742
4687
  const newPath = path.replace(/^\/db\/[^/]+/, hasBranch !== void 0 ? `:${branch}` : "");
@@ -3819,21 +4764,6 @@ const deserialize = (json) => {
3819
4764
  return defaultSerializer.fromJSON(json);
3820
4765
  };
3821
4766
 
3822
- function buildWorkerRunner(config) {
3823
- return function xataWorker(name, worker) {
3824
- return async (...args) => {
3825
- const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
3826
- const result = await fetch(url, {
3827
- method: "POST",
3828
- headers: { "Content-Type": "application/json" },
3829
- body: serialize({ args })
3830
- });
3831
- const text = await result.text();
3832
- return deserialize(text);
3833
- };
3834
- };
3835
- }
3836
-
3837
4767
  class XataError extends Error {
3838
4768
  constructor(message, status) {
3839
4769
  super(message);
@@ -3843,6 +4773,7 @@ class XataError extends Error {
3843
4773
 
3844
4774
  exports.BaseClient = BaseClient;
3845
4775
  exports.FetcherError = FetcherError;
4776
+ exports.FilesPlugin = FilesPlugin;
3846
4777
  exports.Operations = operationsByTag;
3847
4778
  exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
3848
4779
  exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
@@ -3851,27 +4782,32 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
3851
4782
  exports.Page = Page;
3852
4783
  exports.Query = Query;
3853
4784
  exports.RecordArray = RecordArray;
4785
+ exports.RecordColumnTypes = RecordColumnTypes;
3854
4786
  exports.Repository = Repository;
3855
4787
  exports.RestRepository = RestRepository;
4788
+ exports.SQLPlugin = SQLPlugin;
3856
4789
  exports.SchemaPlugin = SchemaPlugin;
3857
4790
  exports.SearchPlugin = SearchPlugin;
3858
4791
  exports.Serializer = Serializer;
3859
4792
  exports.SimpleCache = SimpleCache;
4793
+ exports.TransactionPlugin = TransactionPlugin;
3860
4794
  exports.XataApiClient = XataApiClient;
3861
4795
  exports.XataApiPlugin = XataApiPlugin;
3862
4796
  exports.XataError = XataError;
4797
+ exports.XataFile = XataFile;
3863
4798
  exports.XataPlugin = XataPlugin;
3864
4799
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
3865
4800
  exports.addGitBranchesEntry = addGitBranchesEntry;
3866
4801
  exports.addTableColumn = addTableColumn;
3867
4802
  exports.aggregateTable = aggregateTable;
3868
4803
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
4804
+ exports.applyMigration = applyMigration;
3869
4805
  exports.askTable = askTable;
4806
+ exports.askTableSession = askTableSession;
3870
4807
  exports.branchTransaction = branchTransaction;
3871
4808
  exports.buildClient = buildClient;
3872
4809
  exports.buildPreviewBranchName = buildPreviewBranchName;
3873
4810
  exports.buildProviderString = buildProviderString;
3874
- exports.buildWorkerRunner = buildWorkerRunner;
3875
4811
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
3876
4812
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
3877
4813
  exports.compareBranchSchemas = compareBranchSchemas;
@@ -3880,6 +4816,7 @@ exports.compareMigrationRequest = compareMigrationRequest;
3880
4816
  exports.contains = contains;
3881
4817
  exports.copyBranch = copyBranch;
3882
4818
  exports.createBranch = createBranch;
4819
+ exports.createCluster = createCluster;
3883
4820
  exports.createDatabase = createDatabase;
3884
4821
  exports.createMigrationRequest = createMigrationRequest;
3885
4822
  exports.createTable = createTable;
@@ -3889,18 +4826,24 @@ exports.deleteBranch = deleteBranch;
3889
4826
  exports.deleteColumn = deleteColumn;
3890
4827
  exports.deleteDatabase = deleteDatabase;
3891
4828
  exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
4829
+ exports.deleteFile = deleteFile;
4830
+ exports.deleteFileItem = deleteFileItem;
4831
+ exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
3892
4832
  exports.deleteRecord = deleteRecord;
3893
4833
  exports.deleteTable = deleteTable;
3894
4834
  exports.deleteUser = deleteUser;
3895
4835
  exports.deleteUserAPIKey = deleteUserAPIKey;
4836
+ exports.deleteUserOAuthClient = deleteUserOAuthClient;
3896
4837
  exports.deleteWorkspace = deleteWorkspace;
3897
4838
  exports.deserialize = deserialize;
3898
4839
  exports.endsWith = endsWith;
3899
4840
  exports.equals = equals;
3900
4841
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
3901
4842
  exports.exists = exists;
4843
+ exports.fileAccess = fileAccess;
3902
4844
  exports.ge = ge;
3903
4845
  exports.getAPIKey = getAPIKey;
4846
+ exports.getAuthorizationCode = getAuthorizationCode;
3904
4847
  exports.getBranch = getBranch;
3905
4848
  exports.getBranchDetails = getBranchDetails;
3906
4849
  exports.getBranchList = getBranchList;
@@ -3909,29 +4852,38 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
3909
4852
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
3910
4853
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
3911
4854
  exports.getBranchStats = getBranchStats;
4855
+ exports.getCluster = getCluster;
3912
4856
  exports.getColumn = getColumn;
3913
4857
  exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
3914
4858
  exports.getDatabaseList = getDatabaseList;
3915
4859
  exports.getDatabaseMetadata = getDatabaseMetadata;
3916
4860
  exports.getDatabaseURL = getDatabaseURL;
4861
+ exports.getFile = getFile;
4862
+ exports.getFileItem = getFileItem;
3917
4863
  exports.getGitBranchesMapping = getGitBranchesMapping;
3918
4864
  exports.getHostUrl = getHostUrl;
3919
4865
  exports.getMigrationRequest = getMigrationRequest;
3920
4866
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
3921
4867
  exports.getPreviewBranch = getPreviewBranch;
3922
4868
  exports.getRecord = getRecord;
4869
+ exports.getSchema = getSchema;
3923
4870
  exports.getTableColumns = getTableColumns;
3924
4871
  exports.getTableSchema = getTableSchema;
3925
4872
  exports.getUser = getUser;
3926
4873
  exports.getUserAPIKeys = getUserAPIKeys;
4874
+ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
4875
+ exports.getUserOAuthClients = getUserOAuthClients;
3927
4876
  exports.getWorkspace = getWorkspace;
3928
4877
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
3929
4878
  exports.getWorkspacesList = getWorkspacesList;
4879
+ exports.grantAuthorizationCode = grantAuthorizationCode;
3930
4880
  exports.greaterEquals = greaterEquals;
3931
4881
  exports.greaterThan = greaterThan;
3932
4882
  exports.greaterThanEquals = greaterThanEquals;
3933
4883
  exports.gt = gt;
3934
4884
  exports.gte = gte;
4885
+ exports.iContains = iContains;
4886
+ exports.iPattern = iPattern;
3935
4887
  exports.includes = includes;
3936
4888
  exports.includesAll = includesAll;
3937
4889
  exports.includesAny = includesAny;
@@ -3945,11 +4897,14 @@ exports.isHostProviderAlias = isHostProviderAlias;
3945
4897
  exports.isHostProviderBuilder = isHostProviderBuilder;
3946
4898
  exports.isIdentifiable = isIdentifiable;
3947
4899
  exports.isNot = isNot;
4900
+ exports.isValidExpandedColumn = isValidExpandedColumn;
4901
+ exports.isValidSelectableColumns = isValidSelectableColumns;
3948
4902
  exports.isXataRecord = isXataRecord;
3949
4903
  exports.le = le;
3950
4904
  exports.lessEquals = lessEquals;
3951
4905
  exports.lessThan = lessThan;
3952
4906
  exports.lessThanEquals = lessThanEquals;
4907
+ exports.listClusters = listClusters;
3953
4908
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
3954
4909
  exports.listRegions = listRegions;
3955
4910
  exports.lt = lt;
@@ -3960,12 +4915,16 @@ exports.operationsByTag = operationsByTag;
3960
4915
  exports.parseProviderString = parseProviderString;
3961
4916
  exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
3962
4917
  exports.pattern = pattern;
4918
+ exports.pgRollStatus = pgRollStatus;
3963
4919
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
3964
4920
  exports.pushBranchMigrations = pushBranchMigrations;
4921
+ exports.putFile = putFile;
4922
+ exports.putFileItem = putFileItem;
3965
4923
  exports.queryMigrationRequests = queryMigrationRequests;
3966
4924
  exports.queryTable = queryTable;
3967
4925
  exports.removeGitBranchesEntry = removeGitBranchesEntry;
3968
4926
  exports.removeWorkspaceMember = removeWorkspaceMember;
4927
+ exports.renameDatabase = renameDatabase;
3969
4928
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
3970
4929
  exports.resolveBranch = resolveBranch;
3971
4930
  exports.searchBranch = searchBranch;
@@ -3975,12 +4934,15 @@ exports.setTableSchema = setTableSchema;
3975
4934
  exports.sqlQuery = sqlQuery;
3976
4935
  exports.startsWith = startsWith;
3977
4936
  exports.summarizeTable = summarizeTable;
4937
+ exports.transformImage = transformImage;
3978
4938
  exports.updateBranchMetadata = updateBranchMetadata;
3979
4939
  exports.updateBranchSchema = updateBranchSchema;
4940
+ exports.updateCluster = updateCluster;
3980
4941
  exports.updateColumn = updateColumn;
3981
4942
  exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
3982
4943
  exports.updateDatabaseMetadata = updateDatabaseMetadata;
3983
4944
  exports.updateMigrationRequest = updateMigrationRequest;
4945
+ exports.updateOAuthAccessToken = updateOAuthAccessToken;
3984
4946
  exports.updateRecordWithID = updateRecordWithID;
3985
4947
  exports.updateTable = updateTable;
3986
4948
  exports.updateUser = updateUser;