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