@xata.io/client 0.0.0-alpha.vf98a27d → 0.0.0-alpha.vf9999ff4b05d999462008ed970e92ff105361132

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) {
@@ -30,8 +31,15 @@ function compact(arr) {
30
31
  function compactObject(obj) {
31
32
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
32
33
  }
34
+ function isBlob(value) {
35
+ try {
36
+ return value instanceof Blob;
37
+ } catch (error) {
38
+ return false;
39
+ }
40
+ }
33
41
  function isObject(value) {
34
- return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
42
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
35
43
  }
36
44
  function isDefined(value) {
37
45
  return value !== null && value !== void 0;
@@ -206,7 +214,7 @@ function getAPIKey() {
206
214
  function getBranch() {
207
215
  try {
208
216
  const { branch } = getEnvironment();
209
- return branch ?? "main";
217
+ return branch;
210
218
  } catch (err) {
211
219
  return void 0;
212
220
  }
@@ -234,12 +242,6 @@ function getPreviewBranch() {
234
242
  }
235
243
  }
236
244
 
237
- var __defProp$8 = Object.defineProperty;
238
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
239
- var __publicField$8 = (obj, key, value) => {
240
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
241
- return value;
242
- };
243
245
  var __accessCheck$8 = (obj, member, msg) => {
244
246
  if (!member.has(obj))
245
247
  throw TypeError("Cannot " + msg);
@@ -263,14 +265,13 @@ var __privateMethod$4 = (obj, member, method) => {
263
265
  return method;
264
266
  };
265
267
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
266
- const REQUEST_TIMEOUT = 3e4;
268
+ const REQUEST_TIMEOUT = 5 * 60 * 1e3;
267
269
  function getFetchImplementation(userFetch) {
268
270
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
269
- const fetchImpl = userFetch ?? globalFetch;
271
+ const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
272
+ const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
270
273
  if (!fetchImpl) {
271
- throw new Error(
272
- `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
273
- );
274
+ throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
274
275
  }
275
276
  return fetchImpl;
276
277
  }
@@ -280,8 +281,6 @@ class ApiRequestPool {
280
281
  __privateAdd$8(this, _fetch, void 0);
281
282
  __privateAdd$8(this, _queue, void 0);
282
283
  __privateAdd$8(this, _concurrency, void 0);
283
- __publicField$8(this, "running");
284
- __publicField$8(this, "started");
285
284
  __privateSet$8(this, _queue, []);
286
285
  __privateSet$8(this, _concurrency, concurrency);
287
286
  this.running = 0;
@@ -301,13 +300,7 @@ class ApiRequestPool {
301
300
  const fetchImpl = this.getFetch();
302
301
  const runRequest = async (stalled = false) => {
303
302
  const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
304
- const response = await Promise.race([
305
- fetchImpl(url, options).then((result) => {
306
- cancel();
307
- return result;
308
- }),
309
- promise.then(() => null)
310
- ]);
303
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
311
304
  if (!response) {
312
305
  throw new Error("Request timed out");
313
306
  }
@@ -318,7 +311,7 @@ class ApiRequestPool {
318
311
  }
319
312
  if (stalled) {
320
313
  const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
321
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
314
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
322
315
  }
323
316
  return response;
324
317
  };
@@ -533,26 +526,16 @@ function defaultOnOpen(response) {
533
526
  }
534
527
  }
535
528
 
536
- const VERSION = "0.25.0";
529
+ const VERSION = "0.28.4";
537
530
 
538
- var __defProp$7 = Object.defineProperty;
539
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
540
- var __publicField$7 = (obj, key, value) => {
541
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
542
- return value;
543
- };
544
531
  class ErrorWithCause extends Error {
545
532
  constructor(message, options) {
546
533
  super(message, options);
547
- __publicField$7(this, "cause");
548
534
  }
549
535
  }
550
536
  class FetcherError extends ErrorWithCause {
551
537
  constructor(status, data, requestId) {
552
538
  super(getMessage(data));
553
- __publicField$7(this, "status");
554
- __publicField$7(this, "requestId");
555
- __publicField$7(this, "errors");
556
539
  this.status = status;
557
540
  this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
558
541
  this.requestId = requestId;
@@ -586,6 +569,67 @@ function getMessage(data) {
586
569
  }
587
570
  }
588
571
 
572
+ function getHostUrl(provider, type) {
573
+ if (isHostProviderAlias(provider)) {
574
+ return providers[provider][type];
575
+ } else if (isHostProviderBuilder(provider)) {
576
+ return provider[type];
577
+ }
578
+ throw new Error("Invalid API provider");
579
+ }
580
+ const providers = {
581
+ production: {
582
+ main: "https://api.xata.io",
583
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
584
+ },
585
+ staging: {
586
+ main: "https://api.staging-xata.dev",
587
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
588
+ },
589
+ dev: {
590
+ main: "https://api.dev-xata.dev",
591
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
592
+ },
593
+ local: {
594
+ main: "http://localhost:6001",
595
+ workspaces: "http://{workspaceId}.{region}.localhost:6001"
596
+ }
597
+ };
598
+ function isHostProviderAlias(alias) {
599
+ return isString(alias) && Object.keys(providers).includes(alias);
600
+ }
601
+ function isHostProviderBuilder(builder) {
602
+ return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
603
+ }
604
+ function parseProviderString(provider = "production") {
605
+ if (isHostProviderAlias(provider)) {
606
+ return provider;
607
+ }
608
+ const [main, workspaces] = provider.split(",");
609
+ if (!main || !workspaces)
610
+ return null;
611
+ return { main, workspaces };
612
+ }
613
+ function buildProviderString(provider) {
614
+ if (isHostProviderAlias(provider))
615
+ return provider;
616
+ return `${provider.main},${provider.workspaces}`;
617
+ }
618
+ function parseWorkspacesUrlParts(url) {
619
+ if (!isString(url))
620
+ return null;
621
+ const matches = {
622
+ production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/),
623
+ staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/),
624
+ dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/),
625
+ local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(\d+)/)
626
+ };
627
+ const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
628
+ if (!isHostProviderAlias(host) || !match)
629
+ return null;
630
+ return { workspace: match[1], region: match[2], host };
631
+ }
632
+
589
633
  const pool = new ApiRequestPool();
590
634
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
591
635
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
@@ -601,6 +645,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
601
645
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
602
646
  };
603
647
  function buildBaseUrl({
648
+ method,
604
649
  endpoint,
605
650
  path,
606
651
  workspacesApiUrl,
@@ -608,7 +653,24 @@ function buildBaseUrl({
608
653
  pathParams = {}
609
654
  }) {
610
655
  if (endpoint === "dataPlane") {
611
- const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
656
+ let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
657
+ if (method.toUpperCase() === "PUT" && [
658
+ "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
659
+ "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
660
+ ].includes(path)) {
661
+ const { host } = parseWorkspacesUrlParts(url) ?? {};
662
+ switch (host) {
663
+ case "production":
664
+ url = url.replace("xata.sh", "upload.xata.sh");
665
+ break;
666
+ case "staging":
667
+ url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
668
+ break;
669
+ case "dev":
670
+ url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
671
+ break;
672
+ }
673
+ }
612
674
  const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
613
675
  return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
614
676
  }
@@ -619,11 +681,14 @@ function hostHeader(url) {
619
681
  const { groups } = pattern.exec(url) ?? {};
620
682
  return groups?.host ? { Host: groups.host } : {};
621
683
  }
622
- function parseBody(body, headers) {
684
+ async function parseBody(body, headers) {
623
685
  if (!isDefined(body))
624
686
  return void 0;
687
+ if (isBlob(body) || typeof body.text === "function") {
688
+ return body;
689
+ }
625
690
  const { "Content-Type": contentType } = headers ?? {};
626
- if (String(contentType).toLowerCase() === "application/json") {
691
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
627
692
  return JSON.stringify(body);
628
693
  }
629
694
  return body;
@@ -654,9 +719,9 @@ async function fetch$1({
654
719
  return await trace(
655
720
  `${method.toUpperCase()} ${path}`,
656
721
  async ({ setAttributes }) => {
657
- const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
722
+ const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
658
723
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
659
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
724
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
660
725
  setAttributes({
661
726
  [TraceAttributes.HTTP_URL]: url,
662
727
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
@@ -680,7 +745,7 @@ async function fetch$1({
680
745
  const response = await pool.request(url, {
681
746
  ...fetchOptions,
682
747
  method: method.toUpperCase(),
683
- body: parseBody(body, headers),
748
+ body: await parseBody(body, headers),
684
749
  headers,
685
750
  signal
686
751
  });
@@ -691,7 +756,8 @@ async function fetch$1({
691
756
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
692
757
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
693
758
  [TraceAttributes.HTTP_HOST]: host,
694
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
759
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
760
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
695
761
  });
696
762
  const message = response.headers?.get("x-xata-message");
697
763
  if (message)
@@ -736,7 +802,7 @@ function fetchSSERequest({
736
802
  clientName,
737
803
  xataAgentExtra
738
804
  }) {
739
- const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
805
+ const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
740
806
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
741
807
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
742
808
  void fetchEventSource(url, {
@@ -779,6 +845,20 @@ function parseUrl(url) {
779
845
 
780
846
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
781
847
 
848
+ const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
849
+ const pgRollStatus = (variables, signal) => dataPlaneFetch({
850
+ url: "/db/{dbBranchName}/pgroll/status",
851
+ method: "get",
852
+ ...variables,
853
+ signal
854
+ });
855
+ const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
856
+ url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
857
+ method: "get",
858
+ ...variables,
859
+ signal
860
+ });
861
+ const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
782
862
  const getBranchList = (variables, signal) => dataPlaneFetch({
783
863
  url: "/dbs/{dbName}",
784
864
  method: "get",
@@ -798,6 +878,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
798
878
  ...variables,
799
879
  signal
800
880
  });
881
+ const getSchema = (variables, signal) => dataPlaneFetch({
882
+ url: "/db/{dbBranchName}/schema",
883
+ method: "get",
884
+ ...variables,
885
+ signal
886
+ });
801
887
  const copyBranch = (variables, signal) => dataPlaneFetch({
802
888
  url: "/db/{dbBranchName}/copy",
803
889
  method: "post",
@@ -963,12 +1049,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
963
1049
  ...variables,
964
1050
  signal
965
1051
  });
966
- const sqlQuery = (variables, signal) => dataPlaneFetch({
967
- url: "/db/{dbBranchName}/sql",
968
- method: "post",
969
- ...variables,
970
- signal
971
- });
972
1052
  const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
973
1053
  const askTable = (variables, signal) => dataPlaneFetch({
974
1054
  url: "/db/{dbBranchName}/tables/{tableName}/ask",
@@ -985,8 +1065,24 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
985
1065
  ...variables,
986
1066
  signal
987
1067
  });
1068
+ const fileUpload = (variables, signal) => dataPlaneFetch({
1069
+ url: "/file/{fileId}",
1070
+ method: "put",
1071
+ ...variables,
1072
+ signal
1073
+ });
1074
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
1075
+ url: "/db/{dbBranchName}/sql",
1076
+ method: "post",
1077
+ ...variables,
1078
+ signal
1079
+ });
988
1080
  const operationsByTag$2 = {
989
1081
  branch: {
1082
+ applyMigration,
1083
+ pgRollStatus,
1084
+ pgRollJobStatus,
1085
+ pgRollMigrationHistory,
990
1086
  getBranchList,
991
1087
  getBranchDetails,
992
1088
  createBranch,
@@ -1001,6 +1097,7 @@ const operationsByTag$2 = {
1001
1097
  resolveBranch
1002
1098
  },
1003
1099
  migrations: {
1100
+ getSchema,
1004
1101
  getBranchMigrationHistory,
1005
1102
  getBranchMigrationPlan,
1006
1103
  executeBranchMigrationPlan,
@@ -1044,29 +1141,24 @@ const operationsByTag$2 = {
1044
1141
  deleteRecord,
1045
1142
  bulkInsertTableRecords
1046
1143
  },
1047
- files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1144
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
1048
1145
  searchAndFilter: {
1049
1146
  queryTable,
1050
1147
  searchBranch,
1051
1148
  searchTable,
1052
- sqlQuery,
1053
1149
  vectorSearchTable,
1054
1150
  askTable,
1055
1151
  askTableSession,
1056
1152
  summarizeTable,
1057
1153
  aggregateTable
1058
- }
1154
+ },
1155
+ sql: { sqlQuery }
1059
1156
  };
1060
1157
 
1061
1158
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
1062
1159
 
1160
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1063
1161
  const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
1064
- const generateAccessToken = (variables, signal) => controlPlaneFetch({
1065
- url: "/oauth/token",
1066
- method: "post",
1067
- ...variables,
1068
- signal
1069
- });
1070
1162
  const getUser = (variables, signal) => controlPlaneFetch({
1071
1163
  url: "/user",
1072
1164
  method: "get",
@@ -1103,6 +1195,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
1103
1195
  ...variables,
1104
1196
  signal
1105
1197
  });
1198
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1199
+ url: "/user/oauth/clients",
1200
+ method: "get",
1201
+ ...variables,
1202
+ signal
1203
+ });
1204
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1205
+ url: "/user/oauth/clients/{clientId}",
1206
+ method: "delete",
1207
+ ...variables,
1208
+ signal
1209
+ });
1210
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1211
+ url: "/user/oauth/tokens",
1212
+ method: "get",
1213
+ ...variables,
1214
+ signal
1215
+ });
1216
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1217
+ url: "/user/oauth/tokens/{token}",
1218
+ method: "delete",
1219
+ ...variables,
1220
+ signal
1221
+ });
1222
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
1106
1223
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
1107
1224
  url: "/workspaces",
1108
1225
  method: "get",
@@ -1146,6 +1263,15 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
1146
1263
  const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1147
1264
  const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1148
1265
  const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1266
+ const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
1267
+ const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
1268
+ const getCluster = (variables, signal) => controlPlaneFetch({
1269
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
1270
+ method: "get",
1271
+ ...variables,
1272
+ signal
1273
+ });
1274
+ const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
1149
1275
  const getDatabaseList = (variables, signal) => controlPlaneFetch({
1150
1276
  url: "/workspaces/{workspaceId}/dbs",
1151
1277
  method: "get",
@@ -1172,7 +1298,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
1172
1298
  signal
1173
1299
  });
1174
1300
  const operationsByTag$1 = {
1175
- authOther: { grantAuthorizationCode, generateAccessToken },
1301
+ oAuth: {
1302
+ getAuthorizationCode,
1303
+ grantAuthorizationCode,
1304
+ getUserOAuthClients,
1305
+ deleteUserOAuthClient,
1306
+ getUserOAuthAccessTokens,
1307
+ deleteOAuthAccessToken,
1308
+ updateOAuthAccessToken
1309
+ },
1176
1310
  users: { getUser, updateUser, deleteUser },
1177
1311
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1178
1312
  workspaces: {
@@ -1192,6 +1326,7 @@ const operationsByTag$1 = {
1192
1326
  acceptWorkspaceMemberInvite,
1193
1327
  resendWorkspaceMemberInvite
1194
1328
  },
1329
+ xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
1195
1330
  databases: {
1196
1331
  getDatabaseList,
1197
1332
  createDatabase,
@@ -1208,61 +1343,6 @@ const operationsByTag$1 = {
1208
1343
 
1209
1344
  const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
1210
1345
 
1211
- function getHostUrl(provider, type) {
1212
- if (isHostProviderAlias(provider)) {
1213
- return providers[provider][type];
1214
- } else if (isHostProviderBuilder(provider)) {
1215
- return provider[type];
1216
- }
1217
- throw new Error("Invalid API provider");
1218
- }
1219
- const providers = {
1220
- production: {
1221
- main: "https://api.xata.io",
1222
- workspaces: "https://{workspaceId}.{region}.xata.sh"
1223
- },
1224
- staging: {
1225
- main: "https://api.staging-xata.dev",
1226
- workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1227
- },
1228
- dev: {
1229
- main: "https://api.dev-xata.dev",
1230
- workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
1231
- }
1232
- };
1233
- function isHostProviderAlias(alias) {
1234
- return isString(alias) && Object.keys(providers).includes(alias);
1235
- }
1236
- function isHostProviderBuilder(builder) {
1237
- return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
1238
- }
1239
- function parseProviderString(provider = "production") {
1240
- if (isHostProviderAlias(provider)) {
1241
- return provider;
1242
- }
1243
- const [main, workspaces] = provider.split(",");
1244
- if (!main || !workspaces)
1245
- return null;
1246
- return { main, workspaces };
1247
- }
1248
- function buildProviderString(provider) {
1249
- if (isHostProviderAlias(provider))
1250
- return provider;
1251
- return `${provider.main},${provider.workspaces}`;
1252
- }
1253
- function parseWorkspacesUrlParts(url) {
1254
- if (!isString(url))
1255
- return null;
1256
- const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1257
- const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1258
- const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1259
- const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1260
- const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
1261
- if (!match)
1262
- return null;
1263
- return { workspace: match[1], region: match[2] };
1264
- }
1265
-
1266
1346
  var __accessCheck$7 = (obj, member, msg) => {
1267
1347
  if (!member.has(obj))
1268
1348
  throw TypeError("Cannot " + msg);
@@ -2587,60 +2667,6 @@ class XataApiPlugin {
2587
2667
  class XataPlugin {
2588
2668
  }
2589
2669
 
2590
- class FilesPlugin extends XataPlugin {
2591
- build(pluginOptions) {
2592
- return {
2593
- download: async (location) => {
2594
- const { table, record, column, fileId = "" } = location ?? {};
2595
- return await getFileItem({
2596
- pathParams: {
2597
- workspace: "{workspaceId}",
2598
- dbBranchName: "{dbBranch}",
2599
- region: "{region}",
2600
- tableName: table ?? "",
2601
- recordId: record ?? "",
2602
- columnName: column ?? "",
2603
- fileId
2604
- },
2605
- ...pluginOptions,
2606
- rawResponse: true
2607
- });
2608
- },
2609
- upload: async (location, file) => {
2610
- const { table, record, column, fileId = "" } = location ?? {};
2611
- return await putFileItem({
2612
- pathParams: {
2613
- workspace: "{workspaceId}",
2614
- dbBranchName: "{dbBranch}",
2615
- region: "{region}",
2616
- tableName: table ?? "",
2617
- recordId: record ?? "",
2618
- columnName: column ?? "",
2619
- fileId
2620
- },
2621
- body: file,
2622
- ...pluginOptions
2623
- });
2624
- },
2625
- delete: async (location) => {
2626
- const { table, record, column, fileId = "" } = location ?? {};
2627
- return await deleteFileItem({
2628
- pathParams: {
2629
- workspace: "{workspaceId}",
2630
- dbBranchName: "{dbBranch}",
2631
- region: "{region}",
2632
- tableName: table ?? "",
2633
- recordId: record ?? "",
2634
- columnName: column ?? "",
2635
- fileId
2636
- },
2637
- ...pluginOptions
2638
- });
2639
- }
2640
- };
2641
- }
2642
- }
2643
-
2644
2670
  function buildTransformString(transformations) {
2645
2671
  return transformations.flatMap(
2646
2672
  (t) => Object.entries(t).map(([key, value]) => {
@@ -2656,71 +2682,33 @@ function buildTransformString(transformations) {
2656
2682
  })
2657
2683
  ).join(",");
2658
2684
  }
2659
- function transformImage(url, transformations) {
2685
+ function transformImage(url, ...transformations) {
2660
2686
  if (!isDefined(url))
2661
2687
  return void 0;
2662
- const transformationsString = buildTransformString(transformations);
2688
+ const newTransformations = buildTransformString(transformations);
2663
2689
  const { hostname, pathname, search } = new URL(url);
2664
- return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
2690
+ const pathParts = pathname.split("/");
2691
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2692
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2693
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2694
+ const path = pathParts.join("/");
2695
+ return `https://${hostname}${transform}${path}${search}`;
2665
2696
  }
2666
2697
 
2667
- var __defProp$6 = Object.defineProperty;
2668
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2669
- var __publicField$6 = (obj, key, value) => {
2670
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2671
- return value;
2672
- };
2673
2698
  class XataFile {
2674
2699
  constructor(file) {
2675
- /**
2676
- * Name of this file.
2677
- */
2678
- __publicField$6(this, "name");
2679
- /**
2680
- * Media type of this file.
2681
- */
2682
- __publicField$6(this, "mediaType");
2683
- /**
2684
- * Base64 encoded content of this file.
2685
- */
2686
- __publicField$6(this, "base64Content");
2687
- /**
2688
- * Whether to enable public url for this file.
2689
- */
2690
- __publicField$6(this, "enablePublicUrl");
2691
- /**
2692
- * Timeout for the signed url.
2693
- */
2694
- __publicField$6(this, "signedUrlTimeout");
2695
- /**
2696
- * Size of this file.
2697
- */
2698
- __publicField$6(this, "size");
2699
- /**
2700
- * Version of this file.
2701
- */
2702
- __publicField$6(this, "version");
2703
- /**
2704
- * Url of this file.
2705
- */
2706
- __publicField$6(this, "url");
2707
- /**
2708
- * Signed url of this file.
2709
- */
2710
- __publicField$6(this, "signedUrl");
2711
- /**
2712
- * Attributes of this file.
2713
- */
2714
- __publicField$6(this, "attributes");
2700
+ this.id = file.id;
2715
2701
  this.name = file.name;
2716
- this.mediaType = file.mediaType || "application/octet-stream";
2702
+ this.mediaType = file.mediaType;
2717
2703
  this.base64Content = file.base64Content;
2718
2704
  this.enablePublicUrl = file.enablePublicUrl;
2719
2705
  this.signedUrlTimeout = file.signedUrlTimeout;
2706
+ this.uploadUrlTimeout = file.uploadUrlTimeout;
2720
2707
  this.size = file.size;
2721
2708
  this.version = file.version;
2722
2709
  this.url = file.url;
2723
2710
  this.signedUrl = file.signedUrl;
2711
+ this.uploadUrl = file.uploadUrl;
2724
2712
  this.attributes = file.attributes;
2725
2713
  }
2726
2714
  static fromBuffer(buffer, options = {}) {
@@ -2773,8 +2761,12 @@ class XataFile {
2773
2761
  if (!this.base64Content) {
2774
2762
  throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2775
2763
  }
2776
- const arrayBuffer = this.toArrayBuffer();
2777
- return new Blob([arrayBuffer], { type: this.mediaType });
2764
+ const binary = atob(this.base64Content);
2765
+ const uint8Array = new Uint8Array(binary.length);
2766
+ for (let i = 0; i < binary.length; i++) {
2767
+ uint8Array[i] = binary.charCodeAt(i);
2768
+ }
2769
+ return new Blob([uint8Array], { type: this.mediaType });
2778
2770
  }
2779
2771
  static fromString(string, options = {}) {
2780
2772
  const base64Content = btoa(string);
@@ -2797,16 +2789,27 @@ class XataFile {
2797
2789
  }
2798
2790
  transform(...options) {
2799
2791
  return {
2800
- url: transformImage(this.url, options),
2801
- signedUrl: transformImage(this.signedUrl, options)
2792
+ url: transformImage(this.url, ...options),
2793
+ signedUrl: transformImage(this.signedUrl, ...options),
2794
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2795
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2802
2796
  };
2803
2797
  }
2804
2798
  }
2805
2799
  const parseInputFileEntry = async (entry) => {
2806
2800
  if (!isDefined(entry))
2807
2801
  return null;
2808
- const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2809
- return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2802
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
2803
+ return compactObject({
2804
+ id,
2805
+ // Name cannot be an empty string in our API
2806
+ name: name ? name : void 0,
2807
+ mediaType,
2808
+ base64Content,
2809
+ enablePublicUrl,
2810
+ signedUrlTimeout,
2811
+ uploadUrlTimeout
2812
+ });
2810
2813
  };
2811
2814
 
2812
2815
  function cleanFilter(filter) {
@@ -2836,12 +2839,25 @@ function cleanFilter(filter) {
2836
2839
  return Object.keys(values).length > 0 ? values : void 0;
2837
2840
  }
2838
2841
 
2839
- var __defProp$5 = Object.defineProperty;
2840
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2841
- var __publicField$5 = (obj, key, value) => {
2842
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2843
- return value;
2844
- };
2842
+ function stringifyJson(value) {
2843
+ if (!isDefined(value))
2844
+ return value;
2845
+ if (isString(value))
2846
+ return value;
2847
+ try {
2848
+ return JSON.stringify(value);
2849
+ } catch (e) {
2850
+ return value;
2851
+ }
2852
+ }
2853
+ function parseJson(value) {
2854
+ try {
2855
+ return JSON.parse(value);
2856
+ } catch (e) {
2857
+ return value;
2858
+ }
2859
+ }
2860
+
2845
2861
  var __accessCheck$6 = (obj, member, msg) => {
2846
2862
  if (!member.has(obj))
2847
2863
  throw TypeError("Cannot " + msg);
@@ -2864,14 +2880,6 @@ var _query, _page;
2864
2880
  class Page {
2865
2881
  constructor(query, meta, records = []) {
2866
2882
  __privateAdd$6(this, _query, void 0);
2867
- /**
2868
- * Page metadata, required to retrieve additional records.
2869
- */
2870
- __publicField$5(this, "meta");
2871
- /**
2872
- * The set of results for this page.
2873
- */
2874
- __publicField$5(this, "records");
2875
2883
  __privateSet$6(this, _query, query);
2876
2884
  this.meta = meta;
2877
2885
  this.records = new RecordArray(this, records);
@@ -2921,9 +2929,9 @@ class Page {
2921
2929
  }
2922
2930
  }
2923
2931
  _query = new WeakMap();
2924
- const PAGINATION_MAX_SIZE = 200;
2932
+ const PAGINATION_MAX_SIZE = 1e3;
2925
2933
  const PAGINATION_DEFAULT_SIZE = 20;
2926
- const PAGINATION_MAX_OFFSET = 800;
2934
+ const PAGINATION_MAX_OFFSET = 49e3;
2927
2935
  const PAGINATION_DEFAULT_OFFSET = 0;
2928
2936
  function isCursorPaginationOptions(options) {
2929
2937
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
@@ -3002,12 +3010,6 @@ const _RecordArray = class _RecordArray extends Array {
3002
3010
  _page = new WeakMap();
3003
3011
  let RecordArray = _RecordArray;
3004
3012
 
3005
- var __defProp$4 = Object.defineProperty;
3006
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3007
- var __publicField$4 = (obj, key, value) => {
3008
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3009
- return value;
3010
- };
3011
3013
  var __accessCheck$5 = (obj, member, msg) => {
3012
3014
  if (!member.has(obj))
3013
3015
  throw TypeError("Cannot " + msg);
@@ -3038,8 +3040,8 @@ const _Query = class _Query {
3038
3040
  __privateAdd$5(this, _repository, void 0);
3039
3041
  __privateAdd$5(this, _data, { filter: {} });
3040
3042
  // Implements pagination
3041
- __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3042
- __publicField$4(this, "records", new RecordArray(this, []));
3043
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3044
+ this.records = new RecordArray(this, []);
3043
3045
  __privateSet$5(this, _table$1, table);
3044
3046
  if (repository) {
3045
3047
  __privateSet$5(this, _repository, repository);
@@ -3294,7 +3296,8 @@ const RecordColumnTypes = [
3294
3296
  "datetime",
3295
3297
  "vector",
3296
3298
  "file[]",
3297
- "file"
3299
+ "file",
3300
+ "json"
3298
3301
  ];
3299
3302
  function isIdentifiable(x) {
3300
3303
  return isObject(x) && isString(x?.id);
@@ -3305,6 +3308,24 @@ function isXataRecord(x) {
3305
3308
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
3306
3309
  }
3307
3310
 
3311
+ function isValidExpandedColumn(column) {
3312
+ return isObject(column) && isString(column.name);
3313
+ }
3314
+ function isValidSelectableColumns(columns) {
3315
+ if (!Array.isArray(columns)) {
3316
+ return false;
3317
+ }
3318
+ return columns.every((column) => {
3319
+ if (typeof column === "string") {
3320
+ return true;
3321
+ }
3322
+ if (typeof column === "object") {
3323
+ return isValidExpandedColumn(column);
3324
+ }
3325
+ return false;
3326
+ });
3327
+ }
3328
+
3308
3329
  function isSortFilterString(value) {
3309
3330
  return isString(value);
3310
3331
  }
@@ -3405,24 +3426,24 @@ class RestRepository extends Query {
3405
3426
  if (a.length === 0)
3406
3427
  return [];
3407
3428
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3408
- const columns = isStringArray(b) ? b : ["*"];
3429
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3409
3430
  const result = await this.read(ids, columns);
3410
3431
  return result;
3411
3432
  }
3412
3433
  if (isString(a) && isObject(b)) {
3413
3434
  if (a === "")
3414
3435
  throw new Error("The id can't be empty");
3415
- const columns = isStringArray(c) ? c : void 0;
3436
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3416
3437
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
3417
3438
  }
3418
3439
  if (isObject(a) && isString(a.id)) {
3419
3440
  if (a.id === "")
3420
3441
  throw new Error("The id can't be empty");
3421
- const columns = isStringArray(b) ? b : void 0;
3442
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3422
3443
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
3423
3444
  }
3424
3445
  if (isObject(a)) {
3425
- const columns = isStringArray(b) ? b : void 0;
3446
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3426
3447
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
3427
3448
  }
3428
3449
  throw new Error("Invalid arguments for create method");
@@ -3430,7 +3451,7 @@ class RestRepository extends Query {
3430
3451
  }
3431
3452
  async read(a, b) {
3432
3453
  return __privateGet$4(this, _trace).call(this, "read", async () => {
3433
- const columns = isStringArray(b) ? b : ["*"];
3454
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3434
3455
  if (Array.isArray(a)) {
3435
3456
  if (a.length === 0)
3436
3457
  return [];
@@ -3457,7 +3478,13 @@ class RestRepository extends Query {
3457
3478
  ...__privateGet$4(this, _getFetchProps).call(this)
3458
3479
  });
3459
3480
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3460
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3481
+ return initObject(
3482
+ __privateGet$4(this, _db),
3483
+ schemaTables,
3484
+ __privateGet$4(this, _table),
3485
+ response,
3486
+ columns
3487
+ );
3461
3488
  } catch (e) {
3462
3489
  if (isObject(e) && e.status === 404) {
3463
3490
  return null;
@@ -3499,17 +3526,17 @@ class RestRepository extends Query {
3499
3526
  ifVersion,
3500
3527
  upsert: false
3501
3528
  });
3502
- const columns = isStringArray(b) ? b : ["*"];
3529
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3503
3530
  const result = await this.read(a, columns);
3504
3531
  return result;
3505
3532
  }
3506
3533
  try {
3507
3534
  if (isString(a) && isObject(b)) {
3508
- const columns = isStringArray(c) ? c : void 0;
3535
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3509
3536
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3510
3537
  }
3511
3538
  if (isObject(a) && isString(a.id)) {
3512
- const columns = isStringArray(b) ? b : void 0;
3539
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3513
3540
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3514
3541
  }
3515
3542
  } catch (error) {
@@ -3549,20 +3576,20 @@ class RestRepository extends Query {
3549
3576
  ifVersion,
3550
3577
  upsert: true
3551
3578
  });
3552
- const columns = isStringArray(b) ? b : ["*"];
3579
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3553
3580
  const result = await this.read(a, columns);
3554
3581
  return result;
3555
3582
  }
3556
3583
  if (isString(a) && isObject(b)) {
3557
3584
  if (a === "")
3558
3585
  throw new Error("The id can't be empty");
3559
- const columns = isStringArray(c) ? c : void 0;
3586
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3560
3587
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3561
3588
  }
3562
3589
  if (isObject(a) && isString(a.id)) {
3563
3590
  if (a.id === "")
3564
3591
  throw new Error("The id can't be empty");
3565
- const columns = isStringArray(c) ? c : void 0;
3592
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3566
3593
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3567
3594
  }
3568
3595
  if (!isDefined(a) && isObject(b)) {
@@ -3581,20 +3608,20 @@ class RestRepository extends Query {
3581
3608
  if (a.length === 0)
3582
3609
  return [];
3583
3610
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3584
- const columns = isStringArray(b) ? b : ["*"];
3611
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3585
3612
  const result = await this.read(ids, columns);
3586
3613
  return result;
3587
3614
  }
3588
3615
  if (isString(a) && isObject(b)) {
3589
3616
  if (a === "")
3590
3617
  throw new Error("The id can't be empty");
3591
- const columns = isStringArray(c) ? c : void 0;
3618
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3592
3619
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3593
3620
  }
3594
3621
  if (isObject(a) && isString(a.id)) {
3595
3622
  if (a.id === "")
3596
3623
  throw new Error("The id can't be empty");
3597
- const columns = isStringArray(c) ? c : void 0;
3624
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3598
3625
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3599
3626
  }
3600
3627
  if (!isDefined(a) && isObject(b)) {
@@ -3618,7 +3645,7 @@ class RestRepository extends Query {
3618
3645
  return o.id;
3619
3646
  throw new Error("Invalid arguments for delete method");
3620
3647
  });
3621
- const columns = isStringArray(b) ? b : ["*"];
3648
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3622
3649
  const result = await this.read(a, columns);
3623
3650
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3624
3651
  return result;
@@ -3652,7 +3679,7 @@ class RestRepository extends Query {
3652
3679
  }
3653
3680
  async search(query, options = {}) {
3654
3681
  return __privateGet$4(this, _trace).call(this, "search", async () => {
3655
- const { records } = await searchTable({
3682
+ const { records, totalCount } = await searchTable({
3656
3683
  pathParams: {
3657
3684
  workspace: "{workspaceId}",
3658
3685
  dbBranchName: "{dbBranch}",
@@ -3672,12 +3699,15 @@ class RestRepository extends Query {
3672
3699
  ...__privateGet$4(this, _getFetchProps).call(this)
3673
3700
  });
3674
3701
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3675
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3702
+ return {
3703
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3704
+ totalCount
3705
+ };
3676
3706
  });
3677
3707
  }
3678
3708
  async vectorSearch(column, query, options) {
3679
3709
  return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3680
- const { records } = await vectorSearchTable({
3710
+ const { records, totalCount } = await vectorSearchTable({
3681
3711
  pathParams: {
3682
3712
  workspace: "{workspaceId}",
3683
3713
  dbBranchName: "{dbBranch}",
@@ -3694,7 +3724,10 @@ class RestRepository extends Query {
3694
3724
  ...__privateGet$4(this, _getFetchProps).call(this)
3695
3725
  });
3696
3726
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3697
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3727
+ return {
3728
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3729
+ totalCount
3730
+ };
3698
3731
  });
3699
3732
  }
3700
3733
  async aggregate(aggs, filter) {
@@ -3737,7 +3770,13 @@ class RestRepository extends Query {
3737
3770
  });
3738
3771
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3739
3772
  const records = objects.map(
3740
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3773
+ (record) => initObject(
3774
+ __privateGet$4(this, _db),
3775
+ schemaTables,
3776
+ __privateGet$4(this, _table),
3777
+ record,
3778
+ data.columns ?? ["*"]
3779
+ )
3741
3780
  );
3742
3781
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
3743
3782
  return new Page(query, meta, records);
@@ -3764,7 +3803,13 @@ class RestRepository extends Query {
3764
3803
  },
3765
3804
  ...__privateGet$4(this, _getFetchProps).call(this)
3766
3805
  });
3767
- return result;
3806
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3807
+ return {
3808
+ ...result,
3809
+ summaries: result.summaries.map(
3810
+ (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3811
+ )
3812
+ };
3768
3813
  });
3769
3814
  }
3770
3815
  ask(question, options) {
@@ -4043,19 +4088,15 @@ transformObjectToApi_fn = async function(object) {
4043
4088
  case "file[]":
4044
4089
  result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4045
4090
  break;
4091
+ case "json":
4092
+ result[key] = stringifyJson(value);
4093
+ break;
4046
4094
  default:
4047
4095
  result[key] = value;
4048
4096
  }
4049
4097
  }
4050
4098
  return result;
4051
4099
  };
4052
- const removeLinksFromObject = (object) => {
4053
- return Object.entries(object).reduce((acc, [key, value]) => {
4054
- if (key === "xata")
4055
- return acc;
4056
- return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
4057
- }, {});
4058
- };
4059
4100
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
4060
4101
  const data = {};
4061
4102
  const { xata, ...rest } = object ?? {};
@@ -4086,13 +4127,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4086
4127
  if (item === column.name) {
4087
4128
  return [...acc, "*"];
4088
4129
  }
4089
- if (item.startsWith(`${column.name}.`)) {
4130
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
4090
4131
  const [, ...path] = item.split(".");
4091
4132
  return [...acc, path.join(".")];
4092
4133
  }
4093
4134
  return acc;
4094
4135
  }, []);
4095
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4136
+ data[column.name] = initObject(
4137
+ db,
4138
+ schemaTables,
4139
+ linkTable,
4140
+ value,
4141
+ selectedLinkColumns
4142
+ );
4096
4143
  } else {
4097
4144
  data[column.name] = null;
4098
4145
  }
@@ -4104,6 +4151,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4104
4151
  case "file[]":
4105
4152
  data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4106
4153
  break;
4154
+ case "json":
4155
+ data[column.name] = parseJson(value);
4156
+ break;
4107
4157
  default:
4108
4158
  data[column.name] = value ?? null;
4109
4159
  if (column.notNull === true && value === null) {
@@ -4113,33 +4163,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4113
4163
  }
4114
4164
  }
4115
4165
  const record = { ...data };
4116
- const serializable = { xata, ...removeLinksFromObject(data) };
4117
4166
  const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
4118
4167
  record.read = function(columns2) {
4119
4168
  return db[table].read(record["id"], columns2);
4120
4169
  };
4121
4170
  record.update = function(data2, b, c) {
4122
- const columns2 = isStringArray(b) ? b : ["*"];
4171
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
4123
4172
  const ifVersion = parseIfVersion(b, c);
4124
4173
  return db[table].update(record["id"], data2, columns2, { ifVersion });
4125
4174
  };
4126
4175
  record.replace = function(data2, b, c) {
4127
- const columns2 = isStringArray(b) ? b : ["*"];
4176
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
4128
4177
  const ifVersion = parseIfVersion(b, c);
4129
4178
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
4130
4179
  };
4131
4180
  record.delete = function() {
4132
4181
  return db[table].delete(record["id"]);
4133
4182
  };
4134
- record.xata = Object.freeze(metadata);
4183
+ if (metadata !== void 0) {
4184
+ record.xata = Object.freeze(metadata);
4185
+ }
4135
4186
  record.getMetadata = function() {
4136
4187
  return record.xata;
4137
4188
  };
4138
4189
  record.toSerializable = function() {
4139
- return JSON.parse(JSON.stringify(serializable));
4190
+ return JSON.parse(JSON.stringify(record));
4140
4191
  };
4141
4192
  record.toString = function() {
4142
- return JSON.stringify(serializable);
4193
+ return JSON.stringify(record);
4143
4194
  };
4144
4195
  for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
4145
4196
  Object.defineProperty(record, prop, { enumerable: false });
@@ -4157,7 +4208,7 @@ function extractId(value) {
4157
4208
  function isValidColumn(columns, column) {
4158
4209
  if (columns.includes("*"))
4159
4210
  return true;
4160
- return columns.filter((item) => item.startsWith(column.name)).length > 0;
4211
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
4161
4212
  }
4162
4213
  function parseIfVersion(...args) {
4163
4214
  for (const arg of args) {
@@ -4168,12 +4219,6 @@ function parseIfVersion(...args) {
4168
4219
  return void 0;
4169
4220
  }
4170
4221
 
4171
- var __defProp$3 = Object.defineProperty;
4172
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4173
- var __publicField$3 = (obj, key, value) => {
4174
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4175
- return value;
4176
- };
4177
4222
  var __accessCheck$3 = (obj, member, msg) => {
4178
4223
  if (!member.has(obj))
4179
4224
  throw TypeError("Cannot " + msg);
@@ -4196,8 +4241,6 @@ var _map;
4196
4241
  class SimpleCache {
4197
4242
  constructor(options = {}) {
4198
4243
  __privateAdd$3(this, _map, void 0);
4199
- __publicField$3(this, "capacity");
4200
- __publicField$3(this, "defaultQueryTTL");
4201
4244
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
4202
4245
  this.capacity = options.max ?? 500;
4203
4246
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -4242,10 +4285,12 @@ const notExists = (column) => ({ $notExists: column });
4242
4285
  const startsWith = (value) => ({ $startsWith: value });
4243
4286
  const endsWith = (value) => ({ $endsWith: value });
4244
4287
  const pattern = (value) => ({ $pattern: value });
4288
+ const iPattern = (value) => ({ $iPattern: value });
4245
4289
  const is = (value) => ({ $is: value });
4246
4290
  const equals = is;
4247
4291
  const isNot = (value) => ({ $isNot: value });
4248
4292
  const contains = (value) => ({ $contains: value });
4293
+ const iContains = (value) => ({ $iContains: value });
4249
4294
  const includes = (value) => ({ $includes: value });
4250
4295
  const includesAll = (value) => ({ $includesAll: value });
4251
4296
  const includesNone = (value) => ({ $includesNone: value });
@@ -4301,6 +4346,80 @@ class SchemaPlugin extends XataPlugin {
4301
4346
  _tables = new WeakMap();
4302
4347
  _schemaTables$1 = new WeakMap();
4303
4348
 
4349
+ class FilesPlugin extends XataPlugin {
4350
+ build(pluginOptions) {
4351
+ return {
4352
+ download: async (location) => {
4353
+ const { table, record, column, fileId = "" } = location ?? {};
4354
+ return await getFileItem({
4355
+ pathParams: {
4356
+ workspace: "{workspaceId}",
4357
+ dbBranchName: "{dbBranch}",
4358
+ region: "{region}",
4359
+ tableName: table ?? "",
4360
+ recordId: record ?? "",
4361
+ columnName: column ?? "",
4362
+ fileId
4363
+ },
4364
+ ...pluginOptions,
4365
+ rawResponse: true
4366
+ });
4367
+ },
4368
+ upload: async (location, file, options) => {
4369
+ const { table, record, column, fileId = "" } = location ?? {};
4370
+ const resolvedFile = await file;
4371
+ const contentType = options?.mediaType || getContentType(resolvedFile);
4372
+ const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
4373
+ return await putFileItem({
4374
+ ...pluginOptions,
4375
+ pathParams: {
4376
+ workspace: "{workspaceId}",
4377
+ dbBranchName: "{dbBranch}",
4378
+ region: "{region}",
4379
+ tableName: table ?? "",
4380
+ recordId: record ?? "",
4381
+ columnName: column ?? "",
4382
+ fileId
4383
+ },
4384
+ body,
4385
+ headers: { "Content-Type": contentType }
4386
+ });
4387
+ },
4388
+ delete: async (location) => {
4389
+ const { table, record, column, fileId = "" } = location ?? {};
4390
+ return await deleteFileItem({
4391
+ pathParams: {
4392
+ workspace: "{workspaceId}",
4393
+ dbBranchName: "{dbBranch}",
4394
+ region: "{region}",
4395
+ tableName: table ?? "",
4396
+ recordId: record ?? "",
4397
+ columnName: column ?? "",
4398
+ fileId
4399
+ },
4400
+ ...pluginOptions
4401
+ });
4402
+ }
4403
+ };
4404
+ }
4405
+ }
4406
+ function getContentType(file) {
4407
+ if (typeof file === "string") {
4408
+ return "text/plain";
4409
+ }
4410
+ if ("mediaType" in file && file.mediaType !== void 0) {
4411
+ return file.mediaType;
4412
+ }
4413
+ if (isBlob(file)) {
4414
+ return file.type;
4415
+ }
4416
+ try {
4417
+ return file.type;
4418
+ } catch (e) {
4419
+ }
4420
+ return "application/octet-stream";
4421
+ }
4422
+
4304
4423
  var __accessCheck$1 = (obj, member, msg) => {
4305
4424
  if (!member.has(obj))
4306
4425
  throw TypeError("Cannot " + msg);
@@ -4336,22 +4455,26 @@ class SearchPlugin extends XataPlugin {
4336
4455
  build(pluginOptions) {
4337
4456
  return {
4338
4457
  all: async (query, options = {}) => {
4339
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4458
+ const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4340
4459
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4341
- return records.map((record) => {
4342
- const { table = "orphan" } = record.xata;
4343
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4344
- });
4460
+ return {
4461
+ totalCount,
4462
+ records: records.map((record) => {
4463
+ const { table = "orphan" } = record.xata;
4464
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4465
+ })
4466
+ };
4345
4467
  },
4346
4468
  byTable: async (query, options = {}) => {
4347
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4469
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4348
4470
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4349
- return records.reduce((acc, record) => {
4471
+ const records = rawRecords.reduce((acc, record) => {
4350
4472
  const { table = "orphan" } = record.xata;
4351
4473
  const items = acc[table] ?? [];
4352
4474
  const item = initObject(this.db, schemaTables, table, record, ["*"]);
4353
4475
  return { ...acc, [table]: [...items, item] };
4354
4476
  }, {});
4477
+ return { totalCount, records };
4355
4478
  }
4356
4479
  };
4357
4480
  }
@@ -4360,13 +4483,13 @@ _schemaTables = new WeakMap();
4360
4483
  _search = new WeakSet();
4361
4484
  search_fn = async function(query, options, pluginOptions) {
4362
4485
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4363
- const { records } = await searchBranch({
4486
+ const { records, totalCount } = await searchBranch({
4364
4487
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4365
4488
  // @ts-ignore https://github.com/xataio/client-ts/issues/313
4366
4489
  body: { tables, query, fuzziness, prefix, highlight, page },
4367
4490
  ...pluginOptions
4368
4491
  });
4369
- return records;
4492
+ return { records, totalCount };
4370
4493
  };
4371
4494
  _getSchemaTables = new WeakSet();
4372
4495
  getSchemaTables_fn = async function(pluginOptions) {
@@ -4380,6 +4503,78 @@ getSchemaTables_fn = async function(pluginOptions) {
4380
4503
  return schema.tables;
4381
4504
  };
4382
4505
 
4506
+ function escapeElement(elementRepresentation) {
4507
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4508
+ return '"' + escaped + '"';
4509
+ }
4510
+ function arrayString(val) {
4511
+ let result = "{";
4512
+ for (let i = 0; i < val.length; i++) {
4513
+ if (i > 0) {
4514
+ result = result + ",";
4515
+ }
4516
+ if (val[i] === null || typeof val[i] === "undefined") {
4517
+ result = result + "NULL";
4518
+ } else if (Array.isArray(val[i])) {
4519
+ result = result + arrayString(val[i]);
4520
+ } else if (val[i] instanceof Buffer) {
4521
+ result += "\\\\x" + val[i].toString("hex");
4522
+ } else {
4523
+ result += escapeElement(prepareValue(val[i]));
4524
+ }
4525
+ }
4526
+ result = result + "}";
4527
+ return result;
4528
+ }
4529
+ function prepareValue(value) {
4530
+ if (!isDefined(value))
4531
+ return null;
4532
+ if (value instanceof Date) {
4533
+ return value.toISOString();
4534
+ }
4535
+ if (Array.isArray(value)) {
4536
+ return arrayString(value);
4537
+ }
4538
+ if (isObject(value)) {
4539
+ return JSON.stringify(value);
4540
+ }
4541
+ try {
4542
+ return value.toString();
4543
+ } catch (e) {
4544
+ return value;
4545
+ }
4546
+ }
4547
+ function prepareParams(param1, param2) {
4548
+ if (isString(param1)) {
4549
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4550
+ }
4551
+ if (isStringArray(param1)) {
4552
+ const statement = param1.reduce((acc, curr, index) => {
4553
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4554
+ }, "");
4555
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4556
+ }
4557
+ if (isObject(param1)) {
4558
+ const { statement, params, consistency } = param1;
4559
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4560
+ }
4561
+ throw new Error("Invalid query");
4562
+ }
4563
+
4564
+ class SQLPlugin extends XataPlugin {
4565
+ build(pluginOptions) {
4566
+ return async (param1, ...param2) => {
4567
+ const { statement, params, consistency } = prepareParams(param1, param2);
4568
+ const { records, warning } = await sqlQuery({
4569
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4570
+ body: { statement, params, consistency },
4571
+ ...pluginOptions
4572
+ });
4573
+ return { records, warning };
4574
+ };
4575
+ }
4576
+ }
4577
+
4383
4578
  class TransactionPlugin extends XataPlugin {
4384
4579
  build(pluginOptions) {
4385
4580
  return {
@@ -4395,12 +4590,6 @@ class TransactionPlugin extends XataPlugin {
4395
4590
  }
4396
4591
  }
4397
4592
 
4398
- var __defProp$2 = Object.defineProperty;
4399
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4400
- var __publicField$2 = (obj, key, value) => {
4401
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4402
- return value;
4403
- };
4404
4593
  var __accessCheck = (obj, member, msg) => {
4405
4594
  if (!member.has(obj))
4406
4595
  throw TypeError("Cannot " + msg);
@@ -4430,10 +4619,6 @@ const buildClient = (plugins) => {
4430
4619
  __privateAdd(this, _parseOptions);
4431
4620
  __privateAdd(this, _getFetchProps);
4432
4621
  __privateAdd(this, _options, void 0);
4433
- __publicField$2(this, "db");
4434
- __publicField$2(this, "search");
4435
- __publicField$2(this, "transactions");
4436
- __publicField$2(this, "files");
4437
4622
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
4438
4623
  __privateSet(this, _options, safeOptions);
4439
4624
  const pluginOptions = {
@@ -4444,10 +4629,12 @@ const buildClient = (plugins) => {
4444
4629
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
4445
4630
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4446
4631
  const transactions = new TransactionPlugin().build(pluginOptions);
4632
+ const sql = new SQLPlugin().build(pluginOptions);
4447
4633
  const files = new FilesPlugin().build(pluginOptions);
4448
4634
  this.db = db;
4449
4635
  this.search = search;
4450
4636
  this.transactions = transactions;
4637
+ this.sql = sql;
4451
4638
  this.files = files;
4452
4639
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
4453
4640
  if (namespace === void 0)
@@ -4545,17 +4732,11 @@ const buildClient = (plugins) => {
4545
4732
  class BaseClient extends buildClient() {
4546
4733
  }
4547
4734
 
4548
- var __defProp$1 = Object.defineProperty;
4549
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4550
- var __publicField$1 = (obj, key, value) => {
4551
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4552
- return value;
4553
- };
4554
4735
  const META = "__";
4555
4736
  const VALUE = "___";
4556
4737
  class Serializer {
4557
4738
  constructor() {
4558
- __publicField$1(this, "classes", {});
4739
+ this.classes = {};
4559
4740
  }
4560
4741
  add(clazz) {
4561
4742
  this.classes[clazz.name] = clazz;
@@ -4618,34 +4799,12 @@ const deserialize = (json) => {
4618
4799
  return defaultSerializer.fromJSON(json);
4619
4800
  };
4620
4801
 
4621
- function buildWorkerRunner(config) {
4622
- return function xataWorker(name, worker) {
4623
- return async (...args) => {
4624
- const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
4625
- const result = await fetch(url, {
4626
- method: "POST",
4627
- headers: { "Content-Type": "application/json" },
4628
- body: serialize({ args })
4629
- });
4630
- const text = await result.text();
4631
- return deserialize(text);
4632
- };
4633
- };
4634
- }
4635
-
4636
- var __defProp = Object.defineProperty;
4637
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4638
- var __publicField = (obj, key, value) => {
4639
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4640
- return value;
4641
- };
4642
4802
  class XataError extends Error {
4643
4803
  constructor(message, status) {
4644
4804
  super(message);
4645
- __publicField(this, "status");
4646
4805
  this.status = status;
4647
4806
  }
4648
4807
  }
4649
4808
 
4650
- export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, generateAccessToken, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, 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, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
4809
+ 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, fileUpload, 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, pgRollJobStatus, pgRollMigrationHistory, 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 };
4651
4810
  //# sourceMappingURL=index.mjs.map