@xata.io/client 0.0.0-alpha.vfc4a5e4 → 0.0.0-alpha.vfc4cc60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -20,7 +20,8 @@ const TraceAttributes = {
20
20
  HTTP_METHOD: "http.method",
21
21
  HTTP_URL: "http.url",
22
22
  HTTP_ROUTE: "http.route",
23
- HTTP_TARGET: "http.target"
23
+ HTTP_TARGET: "http.target",
24
+ CLOUDFLARE_RAY_ID: "cf.ray"
24
25
  };
25
26
 
26
27
  function notEmpty(value) {
@@ -32,8 +33,15 @@ function compact(arr) {
32
33
  function compactObject(obj) {
33
34
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
34
35
  }
36
+ function isBlob(value) {
37
+ try {
38
+ return value instanceof Blob;
39
+ } catch (error) {
40
+ return false;
41
+ }
42
+ }
35
43
  function isObject(value) {
36
- return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
44
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !isBlob(value);
37
45
  }
38
46
  function isDefined(value) {
39
47
  return value !== null && value !== void 0;
@@ -88,6 +96,27 @@ function chunk(array, chunkSize) {
88
96
  async function timeout(ms) {
89
97
  return new Promise((resolve) => setTimeout(resolve, ms));
90
98
  }
99
+ function timeoutWithCancel(ms) {
100
+ let timeoutId;
101
+ const promise = new Promise((resolve) => {
102
+ timeoutId = setTimeout(() => {
103
+ resolve();
104
+ }, ms);
105
+ });
106
+ return {
107
+ cancel: () => clearTimeout(timeoutId),
108
+ promise
109
+ };
110
+ }
111
+ function promiseMap(inputValues, mapper) {
112
+ const reducer = (acc$, inputValue) => acc$.then(
113
+ (acc) => mapper(inputValue).then((result) => {
114
+ acc.push(result);
115
+ return acc;
116
+ })
117
+ );
118
+ return inputValues.reduce(reducer, Promise.resolve([]));
119
+ }
91
120
 
92
121
  function getEnvironment() {
93
122
  try {
@@ -187,7 +216,7 @@ function getAPIKey() {
187
216
  function getBranch() {
188
217
  try {
189
218
  const { branch } = getEnvironment();
190
- return branch ?? "main";
219
+ return branch;
191
220
  } catch (err) {
192
221
  return void 0;
193
222
  }
@@ -215,12 +244,6 @@ function getPreviewBranch() {
215
244
  }
216
245
  }
217
246
 
218
- var __defProp$7 = Object.defineProperty;
219
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
220
- var __publicField$7 = (obj, key, value) => {
221
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
222
- return value;
223
- };
224
247
  var __accessCheck$8 = (obj, member, msg) => {
225
248
  if (!member.has(obj))
226
249
  throw TypeError("Cannot " + msg);
@@ -244,14 +267,13 @@ var __privateMethod$4 = (obj, member, method) => {
244
267
  return method;
245
268
  };
246
269
  var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
247
- const REQUEST_TIMEOUT = 3e4;
270
+ const REQUEST_TIMEOUT = 5 * 60 * 1e3;
248
271
  function getFetchImplementation(userFetch) {
249
272
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
250
- const fetchImpl = userFetch ?? globalFetch;
273
+ const globalThisFetch = typeof globalThis !== "undefined" ? globalThis.fetch : void 0;
274
+ const fetchImpl = userFetch ?? globalFetch ?? globalThisFetch;
251
275
  if (!fetchImpl) {
252
- throw new Error(
253
- `Couldn't find \`fetch\`. Install a fetch implementation such as \`node-fetch\` and pass it explicitly.`
254
- );
276
+ throw new Error(`Couldn't find a global \`fetch\`. Pass a fetch implementation explicitly.`);
255
277
  }
256
278
  return fetchImpl;
257
279
  }
@@ -261,8 +283,6 @@ class ApiRequestPool {
261
283
  __privateAdd$8(this, _fetch, void 0);
262
284
  __privateAdd$8(this, _queue, void 0);
263
285
  __privateAdd$8(this, _concurrency, void 0);
264
- __publicField$7(this, "running");
265
- __publicField$7(this, "started");
266
286
  __privateSet$8(this, _queue, []);
267
287
  __privateSet$8(this, _concurrency, concurrency);
268
288
  this.running = 0;
@@ -279,9 +299,10 @@ class ApiRequestPool {
279
299
  }
280
300
  request(url, options) {
281
301
  const start = /* @__PURE__ */ new Date();
282
- const fetch2 = this.getFetch();
302
+ const fetchImpl = this.getFetch();
283
303
  const runRequest = async (stalled = false) => {
284
- const response = await Promise.race([fetch2(url, options), timeout(REQUEST_TIMEOUT).then(() => null)]);
304
+ const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
305
+ const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
285
306
  if (!response) {
286
307
  throw new Error("Request timed out");
287
308
  }
@@ -292,7 +313,7 @@ class ApiRequestPool {
292
313
  }
293
314
  if (stalled) {
294
315
  const stalledTime = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
295
- console.warn(`A request to Xata hit your workspace limits, was retried and stalled for ${stalledTime}ms`);
316
+ console.warn(`A request to Xata hit branch rate limits, was retried and stalled for ${stalledTime}ms`);
296
317
  }
297
318
  return response;
298
319
  };
@@ -507,26 +528,16 @@ function defaultOnOpen(response) {
507
528
  }
508
529
  }
509
530
 
510
- const VERSION = "0.24.3";
531
+ const VERSION = "0.27.0";
511
532
 
512
- var __defProp$6 = Object.defineProperty;
513
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
514
- var __publicField$6 = (obj, key, value) => {
515
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
516
- return value;
517
- };
518
533
  class ErrorWithCause extends Error {
519
534
  constructor(message, options) {
520
535
  super(message, options);
521
- __publicField$6(this, "cause");
522
536
  }
523
537
  }
524
538
  class FetcherError extends ErrorWithCause {
525
539
  constructor(status, data, requestId) {
526
540
  super(getMessage(data));
527
- __publicField$6(this, "status");
528
- __publicField$6(this, "requestId");
529
- __publicField$6(this, "errors");
530
541
  this.status = status;
531
542
  this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
532
543
  this.requestId = requestId;
@@ -593,11 +604,14 @@ function hostHeader(url) {
593
604
  const { groups } = pattern.exec(url) ?? {};
594
605
  return groups?.host ? { Host: groups.host } : {};
595
606
  }
596
- function parseBody(body, headers) {
607
+ async function parseBody(body, headers) {
597
608
  if (!isDefined(body))
598
609
  return void 0;
610
+ if (isBlob(body) || typeof body.text === "function") {
611
+ return body;
612
+ }
599
613
  const { "Content-Type": contentType } = headers ?? {};
600
- if (String(contentType).toLowerCase() === "application/json") {
614
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
601
615
  return JSON.stringify(body);
602
616
  }
603
617
  return body;
@@ -654,7 +668,7 @@ async function fetch$1({
654
668
  const response = await pool.request(url, {
655
669
  ...fetchOptions,
656
670
  method: method.toUpperCase(),
657
- body: parseBody(body, headers),
671
+ body: await parseBody(body, headers),
658
672
  headers,
659
673
  signal
660
674
  });
@@ -665,7 +679,8 @@ async function fetch$1({
665
679
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
666
680
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
667
681
  [TraceAttributes.HTTP_HOST]: host,
668
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
682
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
683
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
669
684
  });
670
685
  const message = response.headers?.get("x-xata-message");
671
686
  if (message)
@@ -753,6 +768,18 @@ function parseUrl(url) {
753
768
 
754
769
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
755
770
 
771
+ const applyMigration = (variables, signal) => dataPlaneFetch({
772
+ url: "/db/{dbBranchName}/pgroll/apply",
773
+ method: "post",
774
+ ...variables,
775
+ signal
776
+ });
777
+ const pgRollStatus = (variables, signal) => dataPlaneFetch({
778
+ url: "/db/{dbBranchName}/pgroll/status",
779
+ method: "get",
780
+ ...variables,
781
+ signal
782
+ });
756
783
  const getBranchList = (variables, signal) => dataPlaneFetch({
757
784
  url: "/dbs/{dbName}",
758
785
  method: "get",
@@ -772,6 +799,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
772
799
  ...variables,
773
800
  signal
774
801
  });
802
+ const getSchema = (variables, signal) => dataPlaneFetch({
803
+ url: "/db/{dbBranchName}/schema",
804
+ method: "get",
805
+ ...variables,
806
+ signal
807
+ });
775
808
  const copyBranch = (variables, signal) => dataPlaneFetch({
776
809
  url: "/db/{dbBranchName}/copy",
777
810
  method: "post",
@@ -937,12 +970,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
937
970
  ...variables,
938
971
  signal
939
972
  });
940
- const sqlQuery = (variables, signal) => dataPlaneFetch({
941
- url: "/db/{dbBranchName}/sql",
942
- method: "post",
943
- ...variables,
944
- signal
945
- });
946
973
  const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
947
974
  const askTable = (variables, signal) => dataPlaneFetch({
948
975
  url: "/db/{dbBranchName}/tables/{tableName}/ask",
@@ -950,7 +977,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
950
977
  ...variables,
951
978
  signal
952
979
  });
953
- const chatSessionMessage = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
980
+ const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
954
981
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
955
982
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
956
983
  const fileAccess = (variables, signal) => dataPlaneFetch({
@@ -959,8 +986,16 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
959
986
  ...variables,
960
987
  signal
961
988
  });
989
+ const sqlQuery = (variables, signal) => dataPlaneFetch({
990
+ url: "/db/{dbBranchName}/sql",
991
+ method: "post",
992
+ ...variables,
993
+ signal
994
+ });
962
995
  const operationsByTag$2 = {
963
996
  branch: {
997
+ applyMigration,
998
+ pgRollStatus,
964
999
  getBranchList,
965
1000
  getBranchDetails,
966
1001
  createBranch,
@@ -975,6 +1010,7 @@ const operationsByTag$2 = {
975
1010
  resolveBranch
976
1011
  },
977
1012
  migrations: {
1013
+ getSchema,
978
1014
  getBranchMigrationHistory,
979
1015
  getBranchMigrationPlan,
980
1016
  executeBranchMigrationPlan,
@@ -1023,17 +1059,19 @@ const operationsByTag$2 = {
1023
1059
  queryTable,
1024
1060
  searchBranch,
1025
1061
  searchTable,
1026
- sqlQuery,
1027
1062
  vectorSearchTable,
1028
1063
  askTable,
1029
- chatSessionMessage,
1064
+ askTableSession,
1030
1065
  summarizeTable,
1031
1066
  aggregateTable
1032
- }
1067
+ },
1068
+ sql: { sqlQuery }
1033
1069
  };
1034
1070
 
1035
1071
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
1036
1072
 
1073
+ const getAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "get", ...variables, signal });
1074
+ const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
1037
1075
  const getUser = (variables, signal) => controlPlaneFetch({
1038
1076
  url: "/user",
1039
1077
  method: "get",
@@ -1070,6 +1108,31 @@ const deleteUserAPIKey = (variables, signal) => controlPlaneFetch({
1070
1108
  ...variables,
1071
1109
  signal
1072
1110
  });
1111
+ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1112
+ url: "/user/oauth/clients",
1113
+ method: "get",
1114
+ ...variables,
1115
+ signal
1116
+ });
1117
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1118
+ url: "/user/oauth/clients/{clientId}",
1119
+ method: "delete",
1120
+ ...variables,
1121
+ signal
1122
+ });
1123
+ const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1124
+ url: "/user/oauth/tokens",
1125
+ method: "get",
1126
+ ...variables,
1127
+ signal
1128
+ });
1129
+ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
1130
+ url: "/user/oauth/tokens/{token}",
1131
+ method: "delete",
1132
+ ...variables,
1133
+ signal
1134
+ });
1135
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
1073
1136
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
1074
1137
  url: "/workspaces",
1075
1138
  method: "get",
@@ -1113,6 +1176,20 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
1113
1176
  const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1114
1177
  const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1115
1178
  const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1179
+ const listClusters = (variables, signal) => controlPlaneFetch({
1180
+ url: "/workspaces/{workspaceId}/clusters",
1181
+ method: "get",
1182
+ ...variables,
1183
+ signal
1184
+ });
1185
+ const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
1186
+ const getCluster = (variables, signal) => controlPlaneFetch({
1187
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
1188
+ method: "get",
1189
+ ...variables,
1190
+ signal
1191
+ });
1192
+ const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
1116
1193
  const getDatabaseList = (variables, signal) => controlPlaneFetch({
1117
1194
  url: "/workspaces/{workspaceId}/dbs",
1118
1195
  method: "get",
@@ -1139,6 +1216,15 @@ const listRegions = (variables, signal) => controlPlaneFetch({
1139
1216
  signal
1140
1217
  });
1141
1218
  const operationsByTag$1 = {
1219
+ oAuth: {
1220
+ getAuthorizationCode,
1221
+ grantAuthorizationCode,
1222
+ getUserOAuthClients,
1223
+ deleteUserOAuthClient,
1224
+ getUserOAuthAccessTokens,
1225
+ deleteOAuthAccessToken,
1226
+ updateOAuthAccessToken
1227
+ },
1142
1228
  users: { getUser, updateUser, deleteUser },
1143
1229
  authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1144
1230
  workspaces: {
@@ -1158,6 +1244,7 @@ const operationsByTag$1 = {
1158
1244
  acceptWorkspaceMemberInvite,
1159
1245
  resendWorkspaceMemberInvite
1160
1246
  },
1247
+ xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
1161
1248
  databases: {
1162
1249
  getDatabaseList,
1163
1250
  createDatabase,
@@ -2151,7 +2238,7 @@ class SearchAndFilterApi {
2151
2238
  ...this.extraProps
2152
2239
  });
2153
2240
  }
2154
- chatSessionMessage({
2241
+ askTableSession({
2155
2242
  workspace,
2156
2243
  region,
2157
2244
  database,
@@ -2160,7 +2247,7 @@ class SearchAndFilterApi {
2160
2247
  sessionId,
2161
2248
  message
2162
2249
  }) {
2163
- return operationsByTag.searchAndFilter.chatSessionMessage({
2250
+ return operationsByTag.searchAndFilter.askTableSession({
2164
2251
  pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
2165
2252
  body: { message },
2166
2253
  ...this.extraProps
@@ -2457,11 +2544,13 @@ class DatabaseApi {
2457
2544
  createDatabase({
2458
2545
  workspace,
2459
2546
  database,
2460
- data
2547
+ data,
2548
+ headers
2461
2549
  }) {
2462
2550
  return operationsByTag.databases.createDatabase({
2463
2551
  pathParams: { workspaceId: workspace, dbName: database },
2464
2552
  body: data,
2553
+ headers,
2465
2554
  ...this.extraProps
2466
2555
  });
2467
2556
  }
@@ -2551,6 +2640,148 @@ class XataApiPlugin {
2551
2640
  class XataPlugin {
2552
2641
  }
2553
2642
 
2643
+ function buildTransformString(transformations) {
2644
+ return transformations.flatMap(
2645
+ (t) => Object.entries(t).map(([key, value]) => {
2646
+ if (key === "trim") {
2647
+ const { left = 0, top = 0, right = 0, bottom = 0 } = value;
2648
+ return `${key}=${[top, right, bottom, left].join(";")}`;
2649
+ }
2650
+ if (key === "gravity" && typeof value === "object") {
2651
+ const { x = 0.5, y = 0.5 } = value;
2652
+ return `${key}=${[x, y].join("x")}`;
2653
+ }
2654
+ return `${key}=${value}`;
2655
+ })
2656
+ ).join(",");
2657
+ }
2658
+ function transformImage(url, ...transformations) {
2659
+ if (!isDefined(url))
2660
+ return void 0;
2661
+ const newTransformations = buildTransformString(transformations);
2662
+ const { hostname, pathname, search } = new URL(url);
2663
+ const pathParts = pathname.split("/");
2664
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2665
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2666
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2667
+ const path = pathParts.join("/");
2668
+ return `https://${hostname}${transform}${path}${search}`;
2669
+ }
2670
+
2671
+ class XataFile {
2672
+ constructor(file) {
2673
+ this.id = file.id;
2674
+ this.name = file.name || "";
2675
+ this.mediaType = file.mediaType || "application/octet-stream";
2676
+ this.base64Content = file.base64Content;
2677
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2678
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2679
+ this.size = file.size ?? 0;
2680
+ this.version = file.version ?? 1;
2681
+ this.url = file.url || "";
2682
+ this.signedUrl = file.signedUrl;
2683
+ this.attributes = file.attributes || {};
2684
+ }
2685
+ static fromBuffer(buffer, options = {}) {
2686
+ const base64Content = buffer.toString("base64");
2687
+ return new XataFile({ ...options, base64Content });
2688
+ }
2689
+ toBuffer() {
2690
+ if (!this.base64Content) {
2691
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2692
+ }
2693
+ return Buffer.from(this.base64Content, "base64");
2694
+ }
2695
+ static fromArrayBuffer(arrayBuffer, options = {}) {
2696
+ const uint8Array = new Uint8Array(arrayBuffer);
2697
+ return this.fromUint8Array(uint8Array, options);
2698
+ }
2699
+ toArrayBuffer() {
2700
+ if (!this.base64Content) {
2701
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2702
+ }
2703
+ const binary = atob(this.base64Content);
2704
+ return new ArrayBuffer(binary.length);
2705
+ }
2706
+ static fromUint8Array(uint8Array, options = {}) {
2707
+ let binary = "";
2708
+ for (let i = 0; i < uint8Array.byteLength; i++) {
2709
+ binary += String.fromCharCode(uint8Array[i]);
2710
+ }
2711
+ const base64Content = btoa(binary);
2712
+ return new XataFile({ ...options, base64Content });
2713
+ }
2714
+ toUint8Array() {
2715
+ if (!this.base64Content) {
2716
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2717
+ }
2718
+ const binary = atob(this.base64Content);
2719
+ const uint8Array = new Uint8Array(binary.length);
2720
+ for (let i = 0; i < binary.length; i++) {
2721
+ uint8Array[i] = binary.charCodeAt(i);
2722
+ }
2723
+ return uint8Array;
2724
+ }
2725
+ static async fromBlob(file, options = {}) {
2726
+ const name = options.name ?? file.name;
2727
+ const mediaType = file.type;
2728
+ const arrayBuffer = await file.arrayBuffer();
2729
+ return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
2730
+ }
2731
+ toBlob() {
2732
+ if (!this.base64Content) {
2733
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2734
+ }
2735
+ const binary = atob(this.base64Content);
2736
+ const uint8Array = new Uint8Array(binary.length);
2737
+ for (let i = 0; i < binary.length; i++) {
2738
+ uint8Array[i] = binary.charCodeAt(i);
2739
+ }
2740
+ return new Blob([uint8Array], { type: this.mediaType });
2741
+ }
2742
+ static fromString(string, options = {}) {
2743
+ const base64Content = btoa(string);
2744
+ return new XataFile({ ...options, base64Content });
2745
+ }
2746
+ toString() {
2747
+ if (!this.base64Content) {
2748
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2749
+ }
2750
+ return atob(this.base64Content);
2751
+ }
2752
+ static fromBase64(base64Content, options = {}) {
2753
+ return new XataFile({ ...options, base64Content });
2754
+ }
2755
+ toBase64() {
2756
+ if (!this.base64Content) {
2757
+ throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2758
+ }
2759
+ return this.base64Content;
2760
+ }
2761
+ transform(...options) {
2762
+ return {
2763
+ url: transformImage(this.url, ...options),
2764
+ signedUrl: transformImage(this.signedUrl, ...options),
2765
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2766
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2767
+ };
2768
+ }
2769
+ }
2770
+ const parseInputFileEntry = async (entry) => {
2771
+ if (!isDefined(entry))
2772
+ return null;
2773
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2774
+ return compactObject({
2775
+ id,
2776
+ // Name cannot be an empty string in our API
2777
+ name: name ? name : void 0,
2778
+ mediaType,
2779
+ base64Content,
2780
+ enablePublicUrl,
2781
+ signedUrlTimeout
2782
+ });
2783
+ };
2784
+
2554
2785
  function cleanFilter(filter) {
2555
2786
  if (!isDefined(filter))
2556
2787
  return void 0;
@@ -2578,12 +2809,25 @@ function cleanFilter(filter) {
2578
2809
  return Object.keys(values).length > 0 ? values : void 0;
2579
2810
  }
2580
2811
 
2581
- var __defProp$5 = Object.defineProperty;
2582
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2583
- var __publicField$5 = (obj, key, value) => {
2584
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2585
- return value;
2586
- };
2812
+ function stringifyJson(value) {
2813
+ if (!isDefined(value))
2814
+ return value;
2815
+ if (isString(value))
2816
+ return value;
2817
+ try {
2818
+ return JSON.stringify(value);
2819
+ } catch (e) {
2820
+ return value;
2821
+ }
2822
+ }
2823
+ function parseJson(value) {
2824
+ try {
2825
+ return JSON.parse(value);
2826
+ } catch (e) {
2827
+ return value;
2828
+ }
2829
+ }
2830
+
2587
2831
  var __accessCheck$6 = (obj, member, msg) => {
2588
2832
  if (!member.has(obj))
2589
2833
  throw TypeError("Cannot " + msg);
@@ -2606,14 +2850,6 @@ var _query, _page;
2606
2850
  class Page {
2607
2851
  constructor(query, meta, records = []) {
2608
2852
  __privateAdd$6(this, _query, void 0);
2609
- /**
2610
- * Page metadata, required to retrieve additional records.
2611
- */
2612
- __publicField$5(this, "meta");
2613
- /**
2614
- * The set of results for this page.
2615
- */
2616
- __publicField$5(this, "records");
2617
2853
  __privateSet$6(this, _query, query);
2618
2854
  this.meta = meta;
2619
2855
  this.records = new RecordArray(this, records);
@@ -2663,9 +2899,9 @@ class Page {
2663
2899
  }
2664
2900
  }
2665
2901
  _query = new WeakMap();
2666
- const PAGINATION_MAX_SIZE = 200;
2902
+ const PAGINATION_MAX_SIZE = 1e3;
2667
2903
  const PAGINATION_DEFAULT_SIZE = 20;
2668
- const PAGINATION_MAX_OFFSET = 800;
2904
+ const PAGINATION_MAX_OFFSET = 49e3;
2669
2905
  const PAGINATION_DEFAULT_OFFSET = 0;
2670
2906
  function isCursorPaginationOptions(options) {
2671
2907
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
@@ -2744,12 +2980,6 @@ const _RecordArray = class _RecordArray extends Array {
2744
2980
  _page = new WeakMap();
2745
2981
  let RecordArray = _RecordArray;
2746
2982
 
2747
- var __defProp$4 = Object.defineProperty;
2748
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2749
- var __publicField$4 = (obj, key, value) => {
2750
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2751
- return value;
2752
- };
2753
2983
  var __accessCheck$5 = (obj, member, msg) => {
2754
2984
  if (!member.has(obj))
2755
2985
  throw TypeError("Cannot " + msg);
@@ -2780,8 +3010,8 @@ const _Query = class _Query {
2780
3010
  __privateAdd$5(this, _repository, void 0);
2781
3011
  __privateAdd$5(this, _data, { filter: {} });
2782
3012
  // Implements pagination
2783
- __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
2784
- __publicField$4(this, "records", new RecordArray(this, []));
3013
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3014
+ this.records = new RecordArray(this, []);
2785
3015
  __privateSet$5(this, _table$1, table);
2786
3016
  if (repository) {
2787
3017
  __privateSet$5(this, _repository, repository);
@@ -3036,7 +3266,8 @@ const RecordColumnTypes = [
3036
3266
  "datetime",
3037
3267
  "vector",
3038
3268
  "file[]",
3039
- "file"
3269
+ "file",
3270
+ "json"
3040
3271
  ];
3041
3272
  function isIdentifiable(x) {
3042
3273
  return isObject(x) && isString(x?.id);
@@ -3047,6 +3278,24 @@ function isXataRecord(x) {
3047
3278
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
3048
3279
  }
3049
3280
 
3281
+ function isValidExpandedColumn(column) {
3282
+ return isObject(column) && isString(column.name);
3283
+ }
3284
+ function isValidSelectableColumns(columns) {
3285
+ if (!Array.isArray(columns)) {
3286
+ return false;
3287
+ }
3288
+ return columns.every((column) => {
3289
+ if (typeof column === "string") {
3290
+ return true;
3291
+ }
3292
+ if (typeof column === "object") {
3293
+ return isValidExpandedColumn(column);
3294
+ }
3295
+ return false;
3296
+ });
3297
+ }
3298
+
3050
3299
  function isSortFilterString(value) {
3051
3300
  return isString(value);
3052
3301
  }
@@ -3096,7 +3345,7 @@ var __privateMethod$2 = (obj, member, method) => {
3096
3345
  __accessCheck$4(obj, member, "access private method");
3097
3346
  return method;
3098
3347
  };
3099
- 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;
3348
+ 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;
3100
3349
  const BULK_OPERATION_MAX_SIZE = 1e3;
3101
3350
  class Repository extends Query {
3102
3351
  }
@@ -3118,6 +3367,7 @@ class RestRepository extends Query {
3118
3367
  __privateAdd$4(this, _setCacheQuery);
3119
3368
  __privateAdd$4(this, _getCacheQuery);
3120
3369
  __privateAdd$4(this, _getSchemaTables$1);
3370
+ __privateAdd$4(this, _transformObjectToApi);
3121
3371
  __privateAdd$4(this, _table, void 0);
3122
3372
  __privateAdd$4(this, _getFetchProps, void 0);
3123
3373
  __privateAdd$4(this, _db, void 0);
@@ -3146,24 +3396,24 @@ class RestRepository extends Query {
3146
3396
  if (a.length === 0)
3147
3397
  return [];
3148
3398
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3149
- const columns = isStringArray(b) ? b : ["*"];
3399
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3150
3400
  const result = await this.read(ids, columns);
3151
3401
  return result;
3152
3402
  }
3153
3403
  if (isString(a) && isObject(b)) {
3154
3404
  if (a === "")
3155
3405
  throw new Error("The id can't be empty");
3156
- const columns = isStringArray(c) ? c : void 0;
3406
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3157
3407
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
3158
3408
  }
3159
3409
  if (isObject(a) && isString(a.id)) {
3160
3410
  if (a.id === "")
3161
3411
  throw new Error("The id can't be empty");
3162
- const columns = isStringArray(b) ? b : void 0;
3412
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3163
3413
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
3164
3414
  }
3165
3415
  if (isObject(a)) {
3166
- const columns = isStringArray(b) ? b : void 0;
3416
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3167
3417
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
3168
3418
  }
3169
3419
  throw new Error("Invalid arguments for create method");
@@ -3171,7 +3421,7 @@ class RestRepository extends Query {
3171
3421
  }
3172
3422
  async read(a, b) {
3173
3423
  return __privateGet$4(this, _trace).call(this, "read", async () => {
3174
- const columns = isStringArray(b) ? b : ["*"];
3424
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3175
3425
  if (Array.isArray(a)) {
3176
3426
  if (a.length === 0)
3177
3427
  return [];
@@ -3198,7 +3448,13 @@ class RestRepository extends Query {
3198
3448
  ...__privateGet$4(this, _getFetchProps).call(this)
3199
3449
  });
3200
3450
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3201
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3451
+ return initObject(
3452
+ __privateGet$4(this, _db),
3453
+ schemaTables,
3454
+ __privateGet$4(this, _table),
3455
+ response,
3456
+ columns
3457
+ );
3202
3458
  } catch (e) {
3203
3459
  if (isObject(e) && e.status === 404) {
3204
3460
  return null;
@@ -3240,17 +3496,17 @@ class RestRepository extends Query {
3240
3496
  ifVersion,
3241
3497
  upsert: false
3242
3498
  });
3243
- const columns = isStringArray(b) ? b : ["*"];
3499
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3244
3500
  const result = await this.read(a, columns);
3245
3501
  return result;
3246
3502
  }
3247
3503
  try {
3248
3504
  if (isString(a) && isObject(b)) {
3249
- const columns = isStringArray(c) ? c : void 0;
3505
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3250
3506
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3251
3507
  }
3252
3508
  if (isObject(a) && isString(a.id)) {
3253
- const columns = isStringArray(b) ? b : void 0;
3509
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3254
3510
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3255
3511
  }
3256
3512
  } catch (error) {
@@ -3290,20 +3546,20 @@ class RestRepository extends Query {
3290
3546
  ifVersion,
3291
3547
  upsert: true
3292
3548
  });
3293
- const columns = isStringArray(b) ? b : ["*"];
3549
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3294
3550
  const result = await this.read(a, columns);
3295
3551
  return result;
3296
3552
  }
3297
3553
  if (isString(a) && isObject(b)) {
3298
3554
  if (a === "")
3299
3555
  throw new Error("The id can't be empty");
3300
- const columns = isStringArray(c) ? c : void 0;
3556
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3301
3557
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3302
3558
  }
3303
3559
  if (isObject(a) && isString(a.id)) {
3304
3560
  if (a.id === "")
3305
3561
  throw new Error("The id can't be empty");
3306
- const columns = isStringArray(c) ? c : void 0;
3562
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3307
3563
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3308
3564
  }
3309
3565
  if (!isDefined(a) && isObject(b)) {
@@ -3322,20 +3578,20 @@ class RestRepository extends Query {
3322
3578
  if (a.length === 0)
3323
3579
  return [];
3324
3580
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3325
- const columns = isStringArray(b) ? b : ["*"];
3581
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3326
3582
  const result = await this.read(ids, columns);
3327
3583
  return result;
3328
3584
  }
3329
3585
  if (isString(a) && isObject(b)) {
3330
3586
  if (a === "")
3331
3587
  throw new Error("The id can't be empty");
3332
- const columns = isStringArray(c) ? c : void 0;
3588
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3333
3589
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3334
3590
  }
3335
3591
  if (isObject(a) && isString(a.id)) {
3336
3592
  if (a.id === "")
3337
3593
  throw new Error("The id can't be empty");
3338
- const columns = isStringArray(c) ? c : void 0;
3594
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3339
3595
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3340
3596
  }
3341
3597
  if (!isDefined(a) && isObject(b)) {
@@ -3359,7 +3615,7 @@ class RestRepository extends Query {
3359
3615
  return o.id;
3360
3616
  throw new Error("Invalid arguments for delete method");
3361
3617
  });
3362
- const columns = isStringArray(b) ? b : ["*"];
3618
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3363
3619
  const result = await this.read(a, columns);
3364
3620
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3365
3621
  return result;
@@ -3393,7 +3649,7 @@ class RestRepository extends Query {
3393
3649
  }
3394
3650
  async search(query, options = {}) {
3395
3651
  return __privateGet$4(this, _trace).call(this, "search", async () => {
3396
- const { records } = await searchTable({
3652
+ const { records, totalCount } = await searchTable({
3397
3653
  pathParams: {
3398
3654
  workspace: "{workspaceId}",
3399
3655
  dbBranchName: "{dbBranch}",
@@ -3413,12 +3669,15 @@ class RestRepository extends Query {
3413
3669
  ...__privateGet$4(this, _getFetchProps).call(this)
3414
3670
  });
3415
3671
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3416
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3672
+ return {
3673
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3674
+ totalCount
3675
+ };
3417
3676
  });
3418
3677
  }
3419
3678
  async vectorSearch(column, query, options) {
3420
3679
  return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3421
- const { records } = await vectorSearchTable({
3680
+ const { records, totalCount } = await vectorSearchTable({
3422
3681
  pathParams: {
3423
3682
  workspace: "{workspaceId}",
3424
3683
  dbBranchName: "{dbBranch}",
@@ -3435,7 +3694,10 @@ class RestRepository extends Query {
3435
3694
  ...__privateGet$4(this, _getFetchProps).call(this)
3436
3695
  });
3437
3696
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3438
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3697
+ return {
3698
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3699
+ totalCount
3700
+ };
3439
3701
  });
3440
3702
  }
3441
3703
  async aggregate(aggs, filter) {
@@ -3478,7 +3740,13 @@ class RestRepository extends Query {
3478
3740
  });
3479
3741
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3480
3742
  const records = objects.map(
3481
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3743
+ (record) => initObject(
3744
+ __privateGet$4(this, _db),
3745
+ schemaTables,
3746
+ __privateGet$4(this, _table),
3747
+ record,
3748
+ data.columns ?? ["*"]
3749
+ )
3482
3750
  );
3483
3751
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
3484
3752
  return new Page(query, meta, records);
@@ -3505,27 +3773,38 @@ class RestRepository extends Query {
3505
3773
  },
3506
3774
  ...__privateGet$4(this, _getFetchProps).call(this)
3507
3775
  });
3508
- return result;
3776
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3777
+ return {
3778
+ ...result,
3779
+ summaries: result.summaries.map(
3780
+ (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3781
+ )
3782
+ };
3509
3783
  });
3510
3784
  }
3511
3785
  ask(question, options) {
3786
+ const questionParam = options?.sessionId ? { message: question } : { question };
3512
3787
  const params = {
3513
3788
  pathParams: {
3514
3789
  workspace: "{workspaceId}",
3515
3790
  dbBranchName: "{dbBranch}",
3516
3791
  region: "{region}",
3517
- tableName: __privateGet$4(this, _table)
3792
+ tableName: __privateGet$4(this, _table),
3793
+ sessionId: options?.sessionId
3518
3794
  },
3519
3795
  body: {
3520
- question,
3521
- ...options
3796
+ ...questionParam,
3797
+ rules: options?.rules,
3798
+ searchType: options?.searchType,
3799
+ search: options?.searchType === "keyword" ? options?.search : void 0,
3800
+ vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3522
3801
  },
3523
3802
  ...__privateGet$4(this, _getFetchProps).call(this)
3524
3803
  };
3525
3804
  if (options?.onMessage) {
3526
3805
  fetchSSERequest({
3527
3806
  endpoint: "dataPlane",
3528
- url: "/db/{dbBranchName}/tables/{tableName}/ask",
3807
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
3529
3808
  method: "POST",
3530
3809
  onMessage: (message) => {
3531
3810
  options.onMessage?.({ answer: message.text, records: message.records });
@@ -3533,7 +3812,7 @@ class RestRepository extends Query {
3533
3812
  ...params
3534
3813
  });
3535
3814
  } else {
3536
- return askTable(params);
3815
+ return askTableSession(params);
3537
3816
  }
3538
3817
  }
3539
3818
  }
@@ -3545,7 +3824,7 @@ _schemaTables$2 = new WeakMap();
3545
3824
  _trace = new WeakMap();
3546
3825
  _insertRecordWithoutId = new WeakSet();
3547
3826
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3548
- const record = removeLinksFromObject(object);
3827
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3549
3828
  const response = await insertRecord({
3550
3829
  pathParams: {
3551
3830
  workspace: "{workspaceId}",
@@ -3564,7 +3843,7 @@ _insertRecordWithId = new WeakSet();
3564
3843
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
3565
3844
  if (!recordId)
3566
3845
  return null;
3567
- const record = removeLinksFromObject(object);
3846
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3568
3847
  const response = await insertRecordWithID({
3569
3848
  pathParams: {
3570
3849
  workspace: "{workspaceId}",
@@ -3582,21 +3861,20 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
3582
3861
  };
3583
3862
  _insertRecords = new WeakSet();
3584
3863
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3585
- const chunkedOperations = chunk(
3586
- objects.map((object) => ({
3587
- insert: { table: __privateGet$4(this, _table), record: removeLinksFromObject(object), createOnly, ifVersion }
3588
- })),
3589
- BULK_OPERATION_MAX_SIZE
3590
- );
3864
+ const operations = await promiseMap(objects, async (object) => {
3865
+ const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3866
+ return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3867
+ });
3868
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3591
3869
  const ids = [];
3592
- for (const operations of chunkedOperations) {
3870
+ for (const operations2 of chunkedOperations) {
3593
3871
  const { results } = await branchTransaction({
3594
3872
  pathParams: {
3595
3873
  workspace: "{workspaceId}",
3596
3874
  dbBranchName: "{dbBranch}",
3597
3875
  region: "{region}"
3598
3876
  },
3599
- body: { operations },
3877
+ body: { operations: operations2 },
3600
3878
  ...__privateGet$4(this, _getFetchProps).call(this)
3601
3879
  });
3602
3880
  for (const result of results) {
@@ -3613,7 +3891,7 @@ _updateRecordWithID = new WeakSet();
3613
3891
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
3614
3892
  if (!recordId)
3615
3893
  return null;
3616
- const { id: _id, ...record } = removeLinksFromObject(object);
3894
+ const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3617
3895
  try {
3618
3896
  const response = await updateRecordWithID({
3619
3897
  pathParams: {
@@ -3638,21 +3916,20 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3638
3916
  };
3639
3917
  _updateRecords = new WeakSet();
3640
3918
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3641
- const chunkedOperations = chunk(
3642
- objects.map(({ id, ...object }) => ({
3643
- update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: removeLinksFromObject(object) }
3644
- })),
3645
- BULK_OPERATION_MAX_SIZE
3646
- );
3919
+ const operations = await promiseMap(objects, async ({ id, ...object }) => {
3920
+ const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3921
+ return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
3922
+ });
3923
+ const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3647
3924
  const ids = [];
3648
- for (const operations of chunkedOperations) {
3925
+ for (const operations2 of chunkedOperations) {
3649
3926
  const { results } = await branchTransaction({
3650
3927
  pathParams: {
3651
3928
  workspace: "{workspaceId}",
3652
3929
  dbBranchName: "{dbBranch}",
3653
3930
  region: "{region}"
3654
3931
  },
3655
- body: { operations },
3932
+ body: { operations: operations2 },
3656
3933
  ...__privateGet$4(this, _getFetchProps).call(this)
3657
3934
  });
3658
3935
  for (const result of results) {
@@ -3755,12 +4032,40 @@ getSchemaTables_fn$1 = async function() {
3755
4032
  __privateSet$4(this, _schemaTables$2, schema.tables);
3756
4033
  return schema.tables;
3757
4034
  };
3758
- const removeLinksFromObject = (object) => {
3759
- return Object.entries(object).reduce((acc, [key, value]) => {
4035
+ _transformObjectToApi = new WeakSet();
4036
+ transformObjectToApi_fn = async function(object) {
4037
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4038
+ const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4039
+ if (!schema)
4040
+ throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4041
+ const result = {};
4042
+ for (const [key, value] of Object.entries(object)) {
3760
4043
  if (key === "xata")
3761
- return acc;
3762
- return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
3763
- }, {});
4044
+ continue;
4045
+ const type = schema.columns.find((column) => column.name === key)?.type;
4046
+ switch (type) {
4047
+ case "link": {
4048
+ result[key] = isIdentifiable(value) ? value.id : value;
4049
+ break;
4050
+ }
4051
+ case "datetime": {
4052
+ result[key] = value instanceof Date ? value.toISOString() : value;
4053
+ break;
4054
+ }
4055
+ case `file`:
4056
+ result[key] = await parseInputFileEntry(value);
4057
+ break;
4058
+ case "file[]":
4059
+ result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4060
+ break;
4061
+ case "json":
4062
+ result[key] = stringifyJson(value);
4063
+ break;
4064
+ default:
4065
+ result[key] = value;
4066
+ }
4067
+ }
4068
+ return result;
3764
4069
  };
3765
4070
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
3766
4071
  const data = {};
@@ -3792,18 +4097,33 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3792
4097
  if (item === column.name) {
3793
4098
  return [...acc, "*"];
3794
4099
  }
3795
- if (item.startsWith(`${column.name}.`)) {
4100
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
3796
4101
  const [, ...path] = item.split(".");
3797
4102
  return [...acc, path.join(".")];
3798
4103
  }
3799
4104
  return acc;
3800
4105
  }, []);
3801
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4106
+ data[column.name] = initObject(
4107
+ db,
4108
+ schemaTables,
4109
+ linkTable,
4110
+ value,
4111
+ selectedLinkColumns
4112
+ );
3802
4113
  } else {
3803
4114
  data[column.name] = null;
3804
4115
  }
3805
4116
  break;
3806
4117
  }
4118
+ case "file":
4119
+ data[column.name] = isDefined(value) ? new XataFile(value) : null;
4120
+ break;
4121
+ case "file[]":
4122
+ data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4123
+ break;
4124
+ case "json":
4125
+ data[column.name] = parseJson(value);
4126
+ break;
3807
4127
  default:
3808
4128
  data[column.name] = value ?? null;
3809
4129
  if (column.notNull === true && value === null) {
@@ -3813,33 +4133,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
3813
4133
  }
3814
4134
  }
3815
4135
  const record = { ...data };
3816
- const serializable = { xata, ...removeLinksFromObject(data) };
3817
4136
  const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
3818
4137
  record.read = function(columns2) {
3819
4138
  return db[table].read(record["id"], columns2);
3820
4139
  };
3821
4140
  record.update = function(data2, b, c) {
3822
- const columns2 = isStringArray(b) ? b : ["*"];
4141
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
3823
4142
  const ifVersion = parseIfVersion(b, c);
3824
4143
  return db[table].update(record["id"], data2, columns2, { ifVersion });
3825
4144
  };
3826
4145
  record.replace = function(data2, b, c) {
3827
- const columns2 = isStringArray(b) ? b : ["*"];
4146
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
3828
4147
  const ifVersion = parseIfVersion(b, c);
3829
4148
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
3830
4149
  };
3831
4150
  record.delete = function() {
3832
4151
  return db[table].delete(record["id"]);
3833
4152
  };
3834
- record.xata = Object.freeze(metadata);
4153
+ if (metadata !== void 0) {
4154
+ record.xata = Object.freeze(metadata);
4155
+ }
3835
4156
  record.getMetadata = function() {
3836
4157
  return record.xata;
3837
4158
  };
3838
4159
  record.toSerializable = function() {
3839
- return JSON.parse(JSON.stringify(serializable));
4160
+ return JSON.parse(JSON.stringify(record));
3840
4161
  };
3841
4162
  record.toString = function() {
3842
- return JSON.stringify(serializable);
4163
+ return JSON.stringify(record);
3843
4164
  };
3844
4165
  for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
3845
4166
  Object.defineProperty(record, prop, { enumerable: false });
@@ -3857,7 +4178,7 @@ function extractId(value) {
3857
4178
  function isValidColumn(columns, column) {
3858
4179
  if (columns.includes("*"))
3859
4180
  return true;
3860
- return columns.filter((item) => item.startsWith(column.name)).length > 0;
4181
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
3861
4182
  }
3862
4183
  function parseIfVersion(...args) {
3863
4184
  for (const arg of args) {
@@ -3868,12 +4189,6 @@ function parseIfVersion(...args) {
3868
4189
  return void 0;
3869
4190
  }
3870
4191
 
3871
- var __defProp$3 = Object.defineProperty;
3872
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3873
- var __publicField$3 = (obj, key, value) => {
3874
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
3875
- return value;
3876
- };
3877
4192
  var __accessCheck$3 = (obj, member, msg) => {
3878
4193
  if (!member.has(obj))
3879
4194
  throw TypeError("Cannot " + msg);
@@ -3896,8 +4211,6 @@ var _map;
3896
4211
  class SimpleCache {
3897
4212
  constructor(options = {}) {
3898
4213
  __privateAdd$3(this, _map, void 0);
3899
- __publicField$3(this, "capacity");
3900
- __publicField$3(this, "defaultQueryTTL");
3901
4214
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
3902
4215
  this.capacity = options.max ?? 500;
3903
4216
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -3942,10 +4255,12 @@ const notExists = (column) => ({ $notExists: column });
3942
4255
  const startsWith = (value) => ({ $startsWith: value });
3943
4256
  const endsWith = (value) => ({ $endsWith: value });
3944
4257
  const pattern = (value) => ({ $pattern: value });
4258
+ const iPattern = (value) => ({ $iPattern: value });
3945
4259
  const is = (value) => ({ $is: value });
3946
4260
  const equals = is;
3947
4261
  const isNot = (value) => ({ $isNot: value });
3948
4262
  const contains = (value) => ({ $contains: value });
4263
+ const iContains = (value) => ({ $iContains: value });
3949
4264
  const includes = (value) => ({ $includes: value });
3950
4265
  const includesAll = (value) => ({ $includesAll: value });
3951
4266
  const includesNone = (value) => ({ $includesNone: value });
@@ -4001,6 +4316,80 @@ class SchemaPlugin extends XataPlugin {
4001
4316
  _tables = new WeakMap();
4002
4317
  _schemaTables$1 = new WeakMap();
4003
4318
 
4319
+ class FilesPlugin extends XataPlugin {
4320
+ build(pluginOptions) {
4321
+ return {
4322
+ download: async (location) => {
4323
+ const { table, record, column, fileId = "" } = location ?? {};
4324
+ return await getFileItem({
4325
+ pathParams: {
4326
+ workspace: "{workspaceId}",
4327
+ dbBranchName: "{dbBranch}",
4328
+ region: "{region}",
4329
+ tableName: table ?? "",
4330
+ recordId: record ?? "",
4331
+ columnName: column ?? "",
4332
+ fileId
4333
+ },
4334
+ ...pluginOptions,
4335
+ rawResponse: true
4336
+ });
4337
+ },
4338
+ upload: async (location, file, options) => {
4339
+ const { table, record, column, fileId = "" } = location ?? {};
4340
+ const resolvedFile = await file;
4341
+ const contentType = options?.mediaType || getContentType(resolvedFile);
4342
+ const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
4343
+ return await putFileItem({
4344
+ ...pluginOptions,
4345
+ pathParams: {
4346
+ workspace: "{workspaceId}",
4347
+ dbBranchName: "{dbBranch}",
4348
+ region: "{region}",
4349
+ tableName: table ?? "",
4350
+ recordId: record ?? "",
4351
+ columnName: column ?? "",
4352
+ fileId
4353
+ },
4354
+ body,
4355
+ headers: { "Content-Type": contentType }
4356
+ });
4357
+ },
4358
+ delete: async (location) => {
4359
+ const { table, record, column, fileId = "" } = location ?? {};
4360
+ return await deleteFileItem({
4361
+ pathParams: {
4362
+ workspace: "{workspaceId}",
4363
+ dbBranchName: "{dbBranch}",
4364
+ region: "{region}",
4365
+ tableName: table ?? "",
4366
+ recordId: record ?? "",
4367
+ columnName: column ?? "",
4368
+ fileId
4369
+ },
4370
+ ...pluginOptions
4371
+ });
4372
+ }
4373
+ };
4374
+ }
4375
+ }
4376
+ function getContentType(file) {
4377
+ if (typeof file === "string") {
4378
+ return "text/plain";
4379
+ }
4380
+ if ("mediaType" in file) {
4381
+ return file.mediaType;
4382
+ }
4383
+ if (isBlob(file)) {
4384
+ return file.type;
4385
+ }
4386
+ try {
4387
+ return file.type;
4388
+ } catch (e) {
4389
+ }
4390
+ return "application/octet-stream";
4391
+ }
4392
+
4004
4393
  var __accessCheck$1 = (obj, member, msg) => {
4005
4394
  if (!member.has(obj))
4006
4395
  throw TypeError("Cannot " + msg);
@@ -4036,22 +4425,26 @@ class SearchPlugin extends XataPlugin {
4036
4425
  build(pluginOptions) {
4037
4426
  return {
4038
4427
  all: async (query, options = {}) => {
4039
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4428
+ const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4040
4429
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4041
- return records.map((record) => {
4042
- const { table = "orphan" } = record.xata;
4043
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4044
- });
4430
+ return {
4431
+ totalCount,
4432
+ records: records.map((record) => {
4433
+ const { table = "orphan" } = record.xata;
4434
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4435
+ })
4436
+ };
4045
4437
  },
4046
4438
  byTable: async (query, options = {}) => {
4047
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4439
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4048
4440
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4049
- return records.reduce((acc, record) => {
4441
+ const records = rawRecords.reduce((acc, record) => {
4050
4442
  const { table = "orphan" } = record.xata;
4051
4443
  const items = acc[table] ?? [];
4052
4444
  const item = initObject(this.db, schemaTables, table, record, ["*"]);
4053
4445
  return { ...acc, [table]: [...items, item] };
4054
4446
  }, {});
4447
+ return { totalCount, records };
4055
4448
  }
4056
4449
  };
4057
4450
  }
@@ -4060,13 +4453,13 @@ _schemaTables = new WeakMap();
4060
4453
  _search = new WeakSet();
4061
4454
  search_fn = async function(query, options, pluginOptions) {
4062
4455
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4063
- const { records } = await searchBranch({
4456
+ const { records, totalCount } = await searchBranch({
4064
4457
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4065
4458
  // @ts-ignore https://github.com/xataio/client-ts/issues/313
4066
4459
  body: { tables, query, fuzziness, prefix, highlight, page },
4067
4460
  ...pluginOptions
4068
4461
  });
4069
- return records;
4462
+ return { records, totalCount };
4070
4463
  };
4071
4464
  _getSchemaTables = new WeakSet();
4072
4465
  getSchemaTables_fn = async function(pluginOptions) {
@@ -4080,6 +4473,78 @@ getSchemaTables_fn = async function(pluginOptions) {
4080
4473
  return schema.tables;
4081
4474
  };
4082
4475
 
4476
+ function escapeElement(elementRepresentation) {
4477
+ const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
4478
+ return '"' + escaped + '"';
4479
+ }
4480
+ function arrayString(val) {
4481
+ let result = "{";
4482
+ for (let i = 0; i < val.length; i++) {
4483
+ if (i > 0) {
4484
+ result = result + ",";
4485
+ }
4486
+ if (val[i] === null || typeof val[i] === "undefined") {
4487
+ result = result + "NULL";
4488
+ } else if (Array.isArray(val[i])) {
4489
+ result = result + arrayString(val[i]);
4490
+ } else if (val[i] instanceof Buffer) {
4491
+ result += "\\\\x" + val[i].toString("hex");
4492
+ } else {
4493
+ result += escapeElement(prepareValue(val[i]));
4494
+ }
4495
+ }
4496
+ result = result + "}";
4497
+ return result;
4498
+ }
4499
+ function prepareValue(value) {
4500
+ if (!isDefined(value))
4501
+ return null;
4502
+ if (value instanceof Date) {
4503
+ return value.toISOString();
4504
+ }
4505
+ if (Array.isArray(value)) {
4506
+ return arrayString(value);
4507
+ }
4508
+ if (isObject(value)) {
4509
+ return JSON.stringify(value);
4510
+ }
4511
+ try {
4512
+ return value.toString();
4513
+ } catch (e) {
4514
+ return value;
4515
+ }
4516
+ }
4517
+ function prepareParams(param1, param2) {
4518
+ if (isString(param1)) {
4519
+ return { statement: param1, params: param2?.map((value) => prepareValue(value)) };
4520
+ }
4521
+ if (isStringArray(param1)) {
4522
+ const statement = param1.reduce((acc, curr, index) => {
4523
+ return acc + curr + (index < (param2?.length ?? 0) ? "$" + (index + 1) : "");
4524
+ }, "");
4525
+ return { statement, params: param2?.map((value) => prepareValue(value)) };
4526
+ }
4527
+ if (isObject(param1)) {
4528
+ const { statement, params, consistency } = param1;
4529
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4530
+ }
4531
+ throw new Error("Invalid query");
4532
+ }
4533
+
4534
+ class SQLPlugin extends XataPlugin {
4535
+ build(pluginOptions) {
4536
+ return async (param1, ...param2) => {
4537
+ const { statement, params, consistency } = prepareParams(param1, param2);
4538
+ const { records, warning } = await sqlQuery({
4539
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4540
+ body: { statement, params, consistency },
4541
+ ...pluginOptions
4542
+ });
4543
+ return { records, warning };
4544
+ };
4545
+ }
4546
+ }
4547
+
4083
4548
  class TransactionPlugin extends XataPlugin {
4084
4549
  build(pluginOptions) {
4085
4550
  return {
@@ -4095,12 +4560,6 @@ class TransactionPlugin extends XataPlugin {
4095
4560
  }
4096
4561
  }
4097
4562
 
4098
- var __defProp$2 = Object.defineProperty;
4099
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4100
- var __publicField$2 = (obj, key, value) => {
4101
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4102
- return value;
4103
- };
4104
4563
  var __accessCheck = (obj, member, msg) => {
4105
4564
  if (!member.has(obj))
4106
4565
  throw TypeError("Cannot " + msg);
@@ -4130,9 +4589,6 @@ const buildClient = (plugins) => {
4130
4589
  __privateAdd(this, _parseOptions);
4131
4590
  __privateAdd(this, _getFetchProps);
4132
4591
  __privateAdd(this, _options, void 0);
4133
- __publicField$2(this, "db");
4134
- __publicField$2(this, "search");
4135
- __publicField$2(this, "transactions");
4136
4592
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
4137
4593
  __privateSet(this, _options, safeOptions);
4138
4594
  const pluginOptions = {
@@ -4143,9 +4599,13 @@ const buildClient = (plugins) => {
4143
4599
  const db = new SchemaPlugin(schemaTables).build(pluginOptions);
4144
4600
  const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4145
4601
  const transactions = new TransactionPlugin().build(pluginOptions);
4602
+ const sql = new SQLPlugin().build(pluginOptions);
4603
+ const files = new FilesPlugin().build(pluginOptions);
4146
4604
  this.db = db;
4147
4605
  this.search = search;
4148
4606
  this.transactions = transactions;
4607
+ this.sql = sql;
4608
+ this.files = files;
4149
4609
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
4150
4610
  if (namespace === void 0)
4151
4611
  continue;
@@ -4242,17 +4702,11 @@ const buildClient = (plugins) => {
4242
4702
  class BaseClient extends buildClient() {
4243
4703
  }
4244
4704
 
4245
- var __defProp$1 = Object.defineProperty;
4246
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4247
- var __publicField$1 = (obj, key, value) => {
4248
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4249
- return value;
4250
- };
4251
4705
  const META = "__";
4252
4706
  const VALUE = "___";
4253
4707
  class Serializer {
4254
4708
  constructor() {
4255
- __publicField$1(this, "classes", {});
4709
+ this.classes = {};
4256
4710
  }
4257
4711
  add(clazz) {
4258
4712
  this.classes[clazz.name] = clazz;
@@ -4315,37 +4769,16 @@ const deserialize = (json) => {
4315
4769
  return defaultSerializer.fromJSON(json);
4316
4770
  };
4317
4771
 
4318
- function buildWorkerRunner(config) {
4319
- return function xataWorker(name, worker) {
4320
- return async (...args) => {
4321
- const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
4322
- const result = await fetch(url, {
4323
- method: "POST",
4324
- headers: { "Content-Type": "application/json" },
4325
- body: serialize({ args })
4326
- });
4327
- const text = await result.text();
4328
- return deserialize(text);
4329
- };
4330
- };
4331
- }
4332
-
4333
- var __defProp = Object.defineProperty;
4334
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4335
- var __publicField = (obj, key, value) => {
4336
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4337
- return value;
4338
- };
4339
4772
  class XataError extends Error {
4340
4773
  constructor(message, status) {
4341
4774
  super(message);
4342
- __publicField(this, "status");
4343
4775
  this.status = status;
4344
4776
  }
4345
4777
  }
4346
4778
 
4347
4779
  exports.BaseClient = BaseClient;
4348
4780
  exports.FetcherError = FetcherError;
4781
+ exports.FilesPlugin = FilesPlugin;
4349
4782
  exports.Operations = operationsByTag;
4350
4783
  exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
4351
4784
  exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
@@ -4357,34 +4790,38 @@ exports.RecordArray = RecordArray;
4357
4790
  exports.RecordColumnTypes = RecordColumnTypes;
4358
4791
  exports.Repository = Repository;
4359
4792
  exports.RestRepository = RestRepository;
4793
+ exports.SQLPlugin = SQLPlugin;
4360
4794
  exports.SchemaPlugin = SchemaPlugin;
4361
4795
  exports.SearchPlugin = SearchPlugin;
4362
4796
  exports.Serializer = Serializer;
4363
4797
  exports.SimpleCache = SimpleCache;
4798
+ exports.TransactionPlugin = TransactionPlugin;
4364
4799
  exports.XataApiClient = XataApiClient;
4365
4800
  exports.XataApiPlugin = XataApiPlugin;
4366
4801
  exports.XataError = XataError;
4802
+ exports.XataFile = XataFile;
4367
4803
  exports.XataPlugin = XataPlugin;
4368
4804
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
4369
4805
  exports.addGitBranchesEntry = addGitBranchesEntry;
4370
4806
  exports.addTableColumn = addTableColumn;
4371
4807
  exports.aggregateTable = aggregateTable;
4372
4808
  exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
4809
+ exports.applyMigration = applyMigration;
4373
4810
  exports.askTable = askTable;
4811
+ exports.askTableSession = askTableSession;
4374
4812
  exports.branchTransaction = branchTransaction;
4375
4813
  exports.buildClient = buildClient;
4376
4814
  exports.buildPreviewBranchName = buildPreviewBranchName;
4377
4815
  exports.buildProviderString = buildProviderString;
4378
- exports.buildWorkerRunner = buildWorkerRunner;
4379
4816
  exports.bulkInsertTableRecords = bulkInsertTableRecords;
4380
4817
  exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
4381
- exports.chatSessionMessage = chatSessionMessage;
4382
4818
  exports.compareBranchSchemas = compareBranchSchemas;
4383
4819
  exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
4384
4820
  exports.compareMigrationRequest = compareMigrationRequest;
4385
4821
  exports.contains = contains;
4386
4822
  exports.copyBranch = copyBranch;
4387
4823
  exports.createBranch = createBranch;
4824
+ exports.createCluster = createCluster;
4388
4825
  exports.createDatabase = createDatabase;
4389
4826
  exports.createMigrationRequest = createMigrationRequest;
4390
4827
  exports.createTable = createTable;
@@ -4396,10 +4833,12 @@ exports.deleteDatabase = deleteDatabase;
4396
4833
  exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
4397
4834
  exports.deleteFile = deleteFile;
4398
4835
  exports.deleteFileItem = deleteFileItem;
4836
+ exports.deleteOAuthAccessToken = deleteOAuthAccessToken;
4399
4837
  exports.deleteRecord = deleteRecord;
4400
4838
  exports.deleteTable = deleteTable;
4401
4839
  exports.deleteUser = deleteUser;
4402
4840
  exports.deleteUserAPIKey = deleteUserAPIKey;
4841
+ exports.deleteUserOAuthClient = deleteUserOAuthClient;
4403
4842
  exports.deleteWorkspace = deleteWorkspace;
4404
4843
  exports.deserialize = deserialize;
4405
4844
  exports.endsWith = endsWith;
@@ -4409,6 +4848,7 @@ exports.exists = exists;
4409
4848
  exports.fileAccess = fileAccess;
4410
4849
  exports.ge = ge;
4411
4850
  exports.getAPIKey = getAPIKey;
4851
+ exports.getAuthorizationCode = getAuthorizationCode;
4412
4852
  exports.getBranch = getBranch;
4413
4853
  exports.getBranchDetails = getBranchDetails;
4414
4854
  exports.getBranchList = getBranchList;
@@ -4417,6 +4857,7 @@ exports.getBranchMigrationHistory = getBranchMigrationHistory;
4417
4857
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
4418
4858
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
4419
4859
  exports.getBranchStats = getBranchStats;
4860
+ exports.getCluster = getCluster;
4420
4861
  exports.getColumn = getColumn;
4421
4862
  exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
4422
4863
  exports.getDatabaseList = getDatabaseList;
@@ -4430,18 +4871,24 @@ exports.getMigrationRequest = getMigrationRequest;
4430
4871
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
4431
4872
  exports.getPreviewBranch = getPreviewBranch;
4432
4873
  exports.getRecord = getRecord;
4874
+ exports.getSchema = getSchema;
4433
4875
  exports.getTableColumns = getTableColumns;
4434
4876
  exports.getTableSchema = getTableSchema;
4435
4877
  exports.getUser = getUser;
4436
4878
  exports.getUserAPIKeys = getUserAPIKeys;
4879
+ exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
4880
+ exports.getUserOAuthClients = getUserOAuthClients;
4437
4881
  exports.getWorkspace = getWorkspace;
4438
4882
  exports.getWorkspaceMembersList = getWorkspaceMembersList;
4439
4883
  exports.getWorkspacesList = getWorkspacesList;
4884
+ exports.grantAuthorizationCode = grantAuthorizationCode;
4440
4885
  exports.greaterEquals = greaterEquals;
4441
4886
  exports.greaterThan = greaterThan;
4442
4887
  exports.greaterThanEquals = greaterThanEquals;
4443
4888
  exports.gt = gt;
4444
4889
  exports.gte = gte;
4890
+ exports.iContains = iContains;
4891
+ exports.iPattern = iPattern;
4445
4892
  exports.includes = includes;
4446
4893
  exports.includesAll = includesAll;
4447
4894
  exports.includesAny = includesAny;
@@ -4455,11 +4902,14 @@ exports.isHostProviderAlias = isHostProviderAlias;
4455
4902
  exports.isHostProviderBuilder = isHostProviderBuilder;
4456
4903
  exports.isIdentifiable = isIdentifiable;
4457
4904
  exports.isNot = isNot;
4905
+ exports.isValidExpandedColumn = isValidExpandedColumn;
4906
+ exports.isValidSelectableColumns = isValidSelectableColumns;
4458
4907
  exports.isXataRecord = isXataRecord;
4459
4908
  exports.le = le;
4460
4909
  exports.lessEquals = lessEquals;
4461
4910
  exports.lessThan = lessThan;
4462
4911
  exports.lessThanEquals = lessThanEquals;
4912
+ exports.listClusters = listClusters;
4463
4913
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
4464
4914
  exports.listRegions = listRegions;
4465
4915
  exports.lt = lt;
@@ -4470,6 +4920,7 @@ exports.operationsByTag = operationsByTag;
4470
4920
  exports.parseProviderString = parseProviderString;
4471
4921
  exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
4472
4922
  exports.pattern = pattern;
4923
+ exports.pgRollStatus = pgRollStatus;
4473
4924
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
4474
4925
  exports.pushBranchMigrations = pushBranchMigrations;
4475
4926
  exports.putFile = putFile;
@@ -4488,12 +4939,15 @@ exports.setTableSchema = setTableSchema;
4488
4939
  exports.sqlQuery = sqlQuery;
4489
4940
  exports.startsWith = startsWith;
4490
4941
  exports.summarizeTable = summarizeTable;
4942
+ exports.transformImage = transformImage;
4491
4943
  exports.updateBranchMetadata = updateBranchMetadata;
4492
4944
  exports.updateBranchSchema = updateBranchSchema;
4945
+ exports.updateCluster = updateCluster;
4493
4946
  exports.updateColumn = updateColumn;
4494
4947
  exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
4495
4948
  exports.updateDatabaseMetadata = updateDatabaseMetadata;
4496
4949
  exports.updateMigrationRequest = updateMigrationRequest;
4950
+ exports.updateOAuthAccessToken = updateOAuthAccessToken;
4497
4951
  exports.updateRecordWithID = updateRecordWithID;
4498
4952
  exports.updateTable = updateTable;
4499
4953
  exports.updateUser = updateUser;