@xata.io/client 0.0.0-alpha.vfc446ea → 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.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;
@@ -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;
@@ -527,26 +526,16 @@ function defaultOnOpen(response) {
527
526
  }
528
527
  }
529
528
 
530
- const VERSION = "0.25.2";
529
+ const VERSION = "0.27.0";
531
530
 
532
- var __defProp$7 = Object.defineProperty;
533
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
534
- var __publicField$7 = (obj, key, value) => {
535
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
536
- return value;
537
- };
538
531
  class ErrorWithCause extends Error {
539
532
  constructor(message, options) {
540
533
  super(message, options);
541
- __publicField$7(this, "cause");
542
534
  }
543
535
  }
544
536
  class FetcherError extends ErrorWithCause {
545
537
  constructor(status, data, requestId) {
546
538
  super(getMessage(data));
547
- __publicField$7(this, "status");
548
- __publicField$7(this, "requestId");
549
- __publicField$7(this, "errors");
550
539
  this.status = status;
551
540
  this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
552
541
  this.requestId = requestId;
@@ -613,11 +602,14 @@ function hostHeader(url) {
613
602
  const { groups } = pattern.exec(url) ?? {};
614
603
  return groups?.host ? { Host: groups.host } : {};
615
604
  }
616
- function parseBody(body, headers) {
605
+ async function parseBody(body, headers) {
617
606
  if (!isDefined(body))
618
607
  return void 0;
608
+ if (isBlob(body) || typeof body.text === "function") {
609
+ return body;
610
+ }
619
611
  const { "Content-Type": contentType } = headers ?? {};
620
- if (String(contentType).toLowerCase() === "application/json") {
612
+ if (String(contentType).toLowerCase() === "application/json" && isObject(body)) {
621
613
  return JSON.stringify(body);
622
614
  }
623
615
  return body;
@@ -674,7 +666,7 @@ async function fetch$1({
674
666
  const response = await pool.request(url, {
675
667
  ...fetchOptions,
676
668
  method: method.toUpperCase(),
677
- body: parseBody(body, headers),
669
+ body: await parseBody(body, headers),
678
670
  headers,
679
671
  signal
680
672
  });
@@ -685,7 +677,8 @@ async function fetch$1({
685
677
  [TraceAttributes.HTTP_REQUEST_ID]: requestId,
686
678
  [TraceAttributes.HTTP_STATUS_CODE]: response.status,
687
679
  [TraceAttributes.HTTP_HOST]: host,
688
- [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
680
+ [TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", ""),
681
+ [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
689
682
  });
690
683
  const message = response.headers?.get("x-xata-message");
691
684
  if (message)
@@ -773,6 +766,18 @@ function parseUrl(url) {
773
766
 
774
767
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
775
768
 
769
+ const applyMigration = (variables, signal) => dataPlaneFetch({
770
+ url: "/db/{dbBranchName}/pgroll/apply",
771
+ method: "post",
772
+ ...variables,
773
+ signal
774
+ });
775
+ const pgRollStatus = (variables, signal) => dataPlaneFetch({
776
+ url: "/db/{dbBranchName}/pgroll/status",
777
+ method: "get",
778
+ ...variables,
779
+ signal
780
+ });
776
781
  const getBranchList = (variables, signal) => dataPlaneFetch({
777
782
  url: "/dbs/{dbName}",
778
783
  method: "get",
@@ -792,6 +797,12 @@ const deleteBranch = (variables, signal) => dataPlaneFetch({
792
797
  ...variables,
793
798
  signal
794
799
  });
800
+ const getSchema = (variables, signal) => dataPlaneFetch({
801
+ url: "/db/{dbBranchName}/schema",
802
+ method: "get",
803
+ ...variables,
804
+ signal
805
+ });
795
806
  const copyBranch = (variables, signal) => dataPlaneFetch({
796
807
  url: "/db/{dbBranchName}/copy",
797
808
  method: "post",
@@ -981,6 +992,8 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
981
992
  });
982
993
  const operationsByTag$2 = {
983
994
  branch: {
995
+ applyMigration,
996
+ pgRollStatus,
984
997
  getBranchList,
985
998
  getBranchDetails,
986
999
  createBranch,
@@ -995,6 +1008,7 @@ const operationsByTag$2 = {
995
1008
  resolveBranch
996
1009
  },
997
1010
  migrations: {
1011
+ getSchema,
998
1012
  getBranchMigrationHistory,
999
1013
  getBranchMigrationPlan,
1000
1014
  executeBranchMigrationPlan,
@@ -1098,6 +1112,12 @@ const getUserOAuthClients = (variables, signal) => controlPlaneFetch({
1098
1112
  ...variables,
1099
1113
  signal
1100
1114
  });
1115
+ const deleteUserOAuthClient = (variables, signal) => controlPlaneFetch({
1116
+ url: "/user/oauth/clients/{clientId}",
1117
+ method: "delete",
1118
+ ...variables,
1119
+ signal
1120
+ });
1101
1121
  const getUserOAuthAccessTokens = (variables, signal) => controlPlaneFetch({
1102
1122
  url: "/user/oauth/tokens",
1103
1123
  method: "get",
@@ -1154,6 +1174,20 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
1154
1174
  const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1155
1175
  const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1156
1176
  const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1177
+ const listClusters = (variables, signal) => controlPlaneFetch({
1178
+ url: "/workspaces/{workspaceId}/clusters",
1179
+ method: "get",
1180
+ ...variables,
1181
+ signal
1182
+ });
1183
+ const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
1184
+ const getCluster = (variables, signal) => controlPlaneFetch({
1185
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
1186
+ method: "get",
1187
+ ...variables,
1188
+ signal
1189
+ });
1190
+ const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
1157
1191
  const getDatabaseList = (variables, signal) => controlPlaneFetch({
1158
1192
  url: "/workspaces/{workspaceId}/dbs",
1159
1193
  method: "get",
@@ -1180,9 +1214,17 @@ const listRegions = (variables, signal) => controlPlaneFetch({
1180
1214
  signal
1181
1215
  });
1182
1216
  const operationsByTag$1 = {
1183
- authOther: { getAuthorizationCode, grantAuthorizationCode, deleteOAuthAccessToken, updateOAuthAccessToken },
1217
+ oAuth: {
1218
+ getAuthorizationCode,
1219
+ grantAuthorizationCode,
1220
+ getUserOAuthClients,
1221
+ deleteUserOAuthClient,
1222
+ getUserOAuthAccessTokens,
1223
+ deleteOAuthAccessToken,
1224
+ updateOAuthAccessToken
1225
+ },
1184
1226
  users: { getUser, updateUser, deleteUser },
1185
- authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey, getUserOAuthClients, getUserOAuthAccessTokens },
1227
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
1186
1228
  workspaces: {
1187
1229
  getWorkspacesList,
1188
1230
  createWorkspace,
@@ -1200,6 +1242,7 @@ const operationsByTag$1 = {
1200
1242
  acceptWorkspaceMemberInvite,
1201
1243
  resendWorkspaceMemberInvite
1202
1244
  },
1245
+ xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
1203
1246
  databases: {
1204
1247
  getDatabaseList,
1205
1248
  createDatabase,
@@ -2595,60 +2638,6 @@ class XataApiPlugin {
2595
2638
  class XataPlugin {
2596
2639
  }
2597
2640
 
2598
- class FilesPlugin extends XataPlugin {
2599
- build(pluginOptions) {
2600
- return {
2601
- download: async (location) => {
2602
- const { table, record, column, fileId = "" } = location ?? {};
2603
- return await getFileItem({
2604
- pathParams: {
2605
- workspace: "{workspaceId}",
2606
- dbBranchName: "{dbBranch}",
2607
- region: "{region}",
2608
- tableName: table ?? "",
2609
- recordId: record ?? "",
2610
- columnName: column ?? "",
2611
- fileId
2612
- },
2613
- ...pluginOptions,
2614
- rawResponse: true
2615
- });
2616
- },
2617
- upload: async (location, file) => {
2618
- const { table, record, column, fileId = "" } = location ?? {};
2619
- return await putFileItem({
2620
- pathParams: {
2621
- workspace: "{workspaceId}",
2622
- dbBranchName: "{dbBranch}",
2623
- region: "{region}",
2624
- tableName: table ?? "",
2625
- recordId: record ?? "",
2626
- columnName: column ?? "",
2627
- fileId
2628
- },
2629
- body: file,
2630
- ...pluginOptions
2631
- });
2632
- },
2633
- delete: async (location) => {
2634
- const { table, record, column, fileId = "" } = location ?? {};
2635
- return await deleteFileItem({
2636
- pathParams: {
2637
- workspace: "{workspaceId}",
2638
- dbBranchName: "{dbBranch}",
2639
- region: "{region}",
2640
- tableName: table ?? "",
2641
- recordId: record ?? "",
2642
- columnName: column ?? "",
2643
- fileId
2644
- },
2645
- ...pluginOptions
2646
- });
2647
- }
2648
- };
2649
- }
2650
- }
2651
-
2652
2641
  function buildTransformString(transformations) {
2653
2642
  return transformations.flatMap(
2654
2643
  (t) => Object.entries(t).map(([key, value]) => {
@@ -2664,72 +2653,32 @@ function buildTransformString(transformations) {
2664
2653
  })
2665
2654
  ).join(",");
2666
2655
  }
2667
- function transformImage(url, transformations) {
2656
+ function transformImage(url, ...transformations) {
2668
2657
  if (!isDefined(url))
2669
2658
  return void 0;
2670
- const transformationsString = buildTransformString(transformations);
2659
+ const newTransformations = buildTransformString(transformations);
2671
2660
  const { hostname, pathname, search } = new URL(url);
2672
- return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
2661
+ const pathParts = pathname.split("/");
2662
+ const transformIndex = pathParts.findIndex((part) => part === "transform");
2663
+ const removedItems = transformIndex >= 0 ? pathParts.splice(transformIndex, 2) : [];
2664
+ const transform = `/transform/${[removedItems[1], newTransformations].filter(isDefined).join(",")}`;
2665
+ const path = pathParts.join("/");
2666
+ return `https://${hostname}${transform}${path}${search}`;
2673
2667
  }
2674
2668
 
2675
- var __defProp$6 = Object.defineProperty;
2676
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2677
- var __publicField$6 = (obj, key, value) => {
2678
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2679
- return value;
2680
- };
2681
2669
  class XataFile {
2682
2670
  constructor(file) {
2683
- /**
2684
- * Name of this file.
2685
- */
2686
- __publicField$6(this, "name");
2687
- /**
2688
- * Media type of this file.
2689
- */
2690
- __publicField$6(this, "mediaType");
2691
- /**
2692
- * Base64 encoded content of this file.
2693
- */
2694
- __publicField$6(this, "base64Content");
2695
- /**
2696
- * Whether to enable public url for this file.
2697
- */
2698
- __publicField$6(this, "enablePublicUrl");
2699
- /**
2700
- * Timeout for the signed url.
2701
- */
2702
- __publicField$6(this, "signedUrlTimeout");
2703
- /**
2704
- * Size of this file.
2705
- */
2706
- __publicField$6(this, "size");
2707
- /**
2708
- * Version of this file.
2709
- */
2710
- __publicField$6(this, "version");
2711
- /**
2712
- * Url of this file.
2713
- */
2714
- __publicField$6(this, "url");
2715
- /**
2716
- * Signed url of this file.
2717
- */
2718
- __publicField$6(this, "signedUrl");
2719
- /**
2720
- * Attributes of this file.
2721
- */
2722
- __publicField$6(this, "attributes");
2723
- this.name = file.name;
2671
+ this.id = file.id;
2672
+ this.name = file.name || "";
2724
2673
  this.mediaType = file.mediaType || "application/octet-stream";
2725
2674
  this.base64Content = file.base64Content;
2726
- this.enablePublicUrl = file.enablePublicUrl;
2727
- this.signedUrlTimeout = file.signedUrlTimeout;
2728
- this.size = file.size;
2729
- this.version = file.version;
2730
- this.url = file.url;
2675
+ this.enablePublicUrl = file.enablePublicUrl ?? false;
2676
+ this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2677
+ this.size = file.size ?? 0;
2678
+ this.version = file.version ?? 1;
2679
+ this.url = file.url || "";
2731
2680
  this.signedUrl = file.signedUrl;
2732
- this.attributes = file.attributes;
2681
+ this.attributes = file.attributes || {};
2733
2682
  }
2734
2683
  static fromBuffer(buffer, options = {}) {
2735
2684
  const base64Content = buffer.toString("base64");
@@ -2781,8 +2730,12 @@ class XataFile {
2781
2730
  if (!this.base64Content) {
2782
2731
  throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
2783
2732
  }
2784
- const arrayBuffer = this.toArrayBuffer();
2785
- return new Blob([arrayBuffer], { type: this.mediaType });
2733
+ const binary = atob(this.base64Content);
2734
+ const uint8Array = new Uint8Array(binary.length);
2735
+ for (let i = 0; i < binary.length; i++) {
2736
+ uint8Array[i] = binary.charCodeAt(i);
2737
+ }
2738
+ return new Blob([uint8Array], { type: this.mediaType });
2786
2739
  }
2787
2740
  static fromString(string, options = {}) {
2788
2741
  const base64Content = btoa(string);
@@ -2805,8 +2758,10 @@ class XataFile {
2805
2758
  }
2806
2759
  transform(...options) {
2807
2760
  return {
2808
- url: transformImage(this.url, options),
2809
- signedUrl: transformImage(this.signedUrl, options)
2761
+ url: transformImage(this.url, ...options),
2762
+ signedUrl: transformImage(this.signedUrl, ...options),
2763
+ metadataUrl: transformImage(this.url, ...options, { format: "json" }),
2764
+ metadataSignedUrl: transformImage(this.signedUrl, ...options, { format: "json" })
2810
2765
  };
2811
2766
  }
2812
2767
  }
@@ -2814,7 +2769,15 @@ const parseInputFileEntry = async (entry) => {
2814
2769
  if (!isDefined(entry))
2815
2770
  return null;
2816
2771
  const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2817
- return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
2772
+ return compactObject({
2773
+ id,
2774
+ // Name cannot be an empty string in our API
2775
+ name: name ? name : void 0,
2776
+ mediaType,
2777
+ base64Content,
2778
+ enablePublicUrl,
2779
+ signedUrlTimeout
2780
+ });
2818
2781
  };
2819
2782
 
2820
2783
  function cleanFilter(filter) {
@@ -2844,12 +2807,25 @@ function cleanFilter(filter) {
2844
2807
  return Object.keys(values).length > 0 ? values : void 0;
2845
2808
  }
2846
2809
 
2847
- var __defProp$5 = Object.defineProperty;
2848
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2849
- var __publicField$5 = (obj, key, value) => {
2850
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2851
- return value;
2852
- };
2810
+ function stringifyJson(value) {
2811
+ if (!isDefined(value))
2812
+ return value;
2813
+ if (isString(value))
2814
+ return value;
2815
+ try {
2816
+ return JSON.stringify(value);
2817
+ } catch (e) {
2818
+ return value;
2819
+ }
2820
+ }
2821
+ function parseJson(value) {
2822
+ try {
2823
+ return JSON.parse(value);
2824
+ } catch (e) {
2825
+ return value;
2826
+ }
2827
+ }
2828
+
2853
2829
  var __accessCheck$6 = (obj, member, msg) => {
2854
2830
  if (!member.has(obj))
2855
2831
  throw TypeError("Cannot " + msg);
@@ -2872,14 +2848,6 @@ var _query, _page;
2872
2848
  class Page {
2873
2849
  constructor(query, meta, records = []) {
2874
2850
  __privateAdd$6(this, _query, void 0);
2875
- /**
2876
- * Page metadata, required to retrieve additional records.
2877
- */
2878
- __publicField$5(this, "meta");
2879
- /**
2880
- * The set of results for this page.
2881
- */
2882
- __publicField$5(this, "records");
2883
2851
  __privateSet$6(this, _query, query);
2884
2852
  this.meta = meta;
2885
2853
  this.records = new RecordArray(this, records);
@@ -2929,9 +2897,9 @@ class Page {
2929
2897
  }
2930
2898
  }
2931
2899
  _query = new WeakMap();
2932
- const PAGINATION_MAX_SIZE = 200;
2900
+ const PAGINATION_MAX_SIZE = 1e3;
2933
2901
  const PAGINATION_DEFAULT_SIZE = 20;
2934
- const PAGINATION_MAX_OFFSET = 800;
2902
+ const PAGINATION_MAX_OFFSET = 49e3;
2935
2903
  const PAGINATION_DEFAULT_OFFSET = 0;
2936
2904
  function isCursorPaginationOptions(options) {
2937
2905
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
@@ -3010,12 +2978,6 @@ const _RecordArray = class _RecordArray extends Array {
3010
2978
  _page = new WeakMap();
3011
2979
  let RecordArray = _RecordArray;
3012
2980
 
3013
- var __defProp$4 = Object.defineProperty;
3014
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3015
- var __publicField$4 = (obj, key, value) => {
3016
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
3017
- return value;
3018
- };
3019
2981
  var __accessCheck$5 = (obj, member, msg) => {
3020
2982
  if (!member.has(obj))
3021
2983
  throw TypeError("Cannot " + msg);
@@ -3046,8 +3008,8 @@ const _Query = class _Query {
3046
3008
  __privateAdd$5(this, _repository, void 0);
3047
3009
  __privateAdd$5(this, _data, { filter: {} });
3048
3010
  // Implements pagination
3049
- __publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
3050
- __publicField$4(this, "records", new RecordArray(this, []));
3011
+ this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3012
+ this.records = new RecordArray(this, []);
3051
3013
  __privateSet$5(this, _table$1, table);
3052
3014
  if (repository) {
3053
3015
  __privateSet$5(this, _repository, repository);
@@ -3302,7 +3264,8 @@ const RecordColumnTypes = [
3302
3264
  "datetime",
3303
3265
  "vector",
3304
3266
  "file[]",
3305
- "file"
3267
+ "file",
3268
+ "json"
3306
3269
  ];
3307
3270
  function isIdentifiable(x) {
3308
3271
  return isObject(x) && isString(x?.id);
@@ -3313,6 +3276,24 @@ function isXataRecord(x) {
3313
3276
  return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
3314
3277
  }
3315
3278
 
3279
+ function isValidExpandedColumn(column) {
3280
+ return isObject(column) && isString(column.name);
3281
+ }
3282
+ function isValidSelectableColumns(columns) {
3283
+ if (!Array.isArray(columns)) {
3284
+ return false;
3285
+ }
3286
+ return columns.every((column) => {
3287
+ if (typeof column === "string") {
3288
+ return true;
3289
+ }
3290
+ if (typeof column === "object") {
3291
+ return isValidExpandedColumn(column);
3292
+ }
3293
+ return false;
3294
+ });
3295
+ }
3296
+
3316
3297
  function isSortFilterString(value) {
3317
3298
  return isString(value);
3318
3299
  }
@@ -3413,24 +3394,24 @@ class RestRepository extends Query {
3413
3394
  if (a.length === 0)
3414
3395
  return [];
3415
3396
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3416
- const columns = isStringArray(b) ? b : ["*"];
3397
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3417
3398
  const result = await this.read(ids, columns);
3418
3399
  return result;
3419
3400
  }
3420
3401
  if (isString(a) && isObject(b)) {
3421
3402
  if (a === "")
3422
3403
  throw new Error("The id can't be empty");
3423
- const columns = isStringArray(c) ? c : void 0;
3404
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3424
3405
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
3425
3406
  }
3426
3407
  if (isObject(a) && isString(a.id)) {
3427
3408
  if (a.id === "")
3428
3409
  throw new Error("The id can't be empty");
3429
- const columns = isStringArray(b) ? b : void 0;
3410
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3430
3411
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
3431
3412
  }
3432
3413
  if (isObject(a)) {
3433
- const columns = isStringArray(b) ? b : void 0;
3414
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3434
3415
  return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
3435
3416
  }
3436
3417
  throw new Error("Invalid arguments for create method");
@@ -3438,7 +3419,7 @@ class RestRepository extends Query {
3438
3419
  }
3439
3420
  async read(a, b) {
3440
3421
  return __privateGet$4(this, _trace).call(this, "read", async () => {
3441
- const columns = isStringArray(b) ? b : ["*"];
3422
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3442
3423
  if (Array.isArray(a)) {
3443
3424
  if (a.length === 0)
3444
3425
  return [];
@@ -3465,7 +3446,13 @@ class RestRepository extends Query {
3465
3446
  ...__privateGet$4(this, _getFetchProps).call(this)
3466
3447
  });
3467
3448
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3468
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3449
+ return initObject(
3450
+ __privateGet$4(this, _db),
3451
+ schemaTables,
3452
+ __privateGet$4(this, _table),
3453
+ response,
3454
+ columns
3455
+ );
3469
3456
  } catch (e) {
3470
3457
  if (isObject(e) && e.status === 404) {
3471
3458
  return null;
@@ -3507,17 +3494,17 @@ class RestRepository extends Query {
3507
3494
  ifVersion,
3508
3495
  upsert: false
3509
3496
  });
3510
- const columns = isStringArray(b) ? b : ["*"];
3497
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3511
3498
  const result = await this.read(a, columns);
3512
3499
  return result;
3513
3500
  }
3514
3501
  try {
3515
3502
  if (isString(a) && isObject(b)) {
3516
- const columns = isStringArray(c) ? c : void 0;
3503
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3517
3504
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3518
3505
  }
3519
3506
  if (isObject(a) && isString(a.id)) {
3520
- const columns = isStringArray(b) ? b : void 0;
3507
+ const columns = isValidSelectableColumns(b) ? b : void 0;
3521
3508
  return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3522
3509
  }
3523
3510
  } catch (error) {
@@ -3557,20 +3544,20 @@ class RestRepository extends Query {
3557
3544
  ifVersion,
3558
3545
  upsert: true
3559
3546
  });
3560
- const columns = isStringArray(b) ? b : ["*"];
3547
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3561
3548
  const result = await this.read(a, columns);
3562
3549
  return result;
3563
3550
  }
3564
3551
  if (isString(a) && isObject(b)) {
3565
3552
  if (a === "")
3566
3553
  throw new Error("The id can't be empty");
3567
- const columns = isStringArray(c) ? c : void 0;
3554
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3568
3555
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
3569
3556
  }
3570
3557
  if (isObject(a) && isString(a.id)) {
3571
3558
  if (a.id === "")
3572
3559
  throw new Error("The id can't be empty");
3573
- const columns = isStringArray(c) ? c : void 0;
3560
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3574
3561
  return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
3575
3562
  }
3576
3563
  if (!isDefined(a) && isObject(b)) {
@@ -3589,20 +3576,20 @@ class RestRepository extends Query {
3589
3576
  if (a.length === 0)
3590
3577
  return [];
3591
3578
  const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
3592
- const columns = isStringArray(b) ? b : ["*"];
3579
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3593
3580
  const result = await this.read(ids, columns);
3594
3581
  return result;
3595
3582
  }
3596
3583
  if (isString(a) && isObject(b)) {
3597
3584
  if (a === "")
3598
3585
  throw new Error("The id can't be empty");
3599
- const columns = isStringArray(c) ? c : void 0;
3586
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3600
3587
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
3601
3588
  }
3602
3589
  if (isObject(a) && isString(a.id)) {
3603
3590
  if (a.id === "")
3604
3591
  throw new Error("The id can't be empty");
3605
- const columns = isStringArray(c) ? c : void 0;
3592
+ const columns = isValidSelectableColumns(c) ? c : void 0;
3606
3593
  return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
3607
3594
  }
3608
3595
  if (!isDefined(a) && isObject(b)) {
@@ -3626,7 +3613,7 @@ class RestRepository extends Query {
3626
3613
  return o.id;
3627
3614
  throw new Error("Invalid arguments for delete method");
3628
3615
  });
3629
- const columns = isStringArray(b) ? b : ["*"];
3616
+ const columns = isValidSelectableColumns(b) ? b : ["*"];
3630
3617
  const result = await this.read(a, columns);
3631
3618
  await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
3632
3619
  return result;
@@ -3660,7 +3647,7 @@ class RestRepository extends Query {
3660
3647
  }
3661
3648
  async search(query, options = {}) {
3662
3649
  return __privateGet$4(this, _trace).call(this, "search", async () => {
3663
- const { records } = await searchTable({
3650
+ const { records, totalCount } = await searchTable({
3664
3651
  pathParams: {
3665
3652
  workspace: "{workspaceId}",
3666
3653
  dbBranchName: "{dbBranch}",
@@ -3680,12 +3667,15 @@ class RestRepository extends Query {
3680
3667
  ...__privateGet$4(this, _getFetchProps).call(this)
3681
3668
  });
3682
3669
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3683
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3670
+ return {
3671
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3672
+ totalCount
3673
+ };
3684
3674
  });
3685
3675
  }
3686
3676
  async vectorSearch(column, query, options) {
3687
3677
  return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3688
- const { records } = await vectorSearchTable({
3678
+ const { records, totalCount } = await vectorSearchTable({
3689
3679
  pathParams: {
3690
3680
  workspace: "{workspaceId}",
3691
3681
  dbBranchName: "{dbBranch}",
@@ -3702,7 +3692,10 @@ class RestRepository extends Query {
3702
3692
  ...__privateGet$4(this, _getFetchProps).call(this)
3703
3693
  });
3704
3694
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3705
- return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"]));
3695
+ return {
3696
+ records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3697
+ totalCount
3698
+ };
3706
3699
  });
3707
3700
  }
3708
3701
  async aggregate(aggs, filter) {
@@ -3745,7 +3738,13 @@ class RestRepository extends Query {
3745
3738
  });
3746
3739
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3747
3740
  const records = objects.map(
3748
- (record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record, data.columns ?? ["*"])
3741
+ (record) => initObject(
3742
+ __privateGet$4(this, _db),
3743
+ schemaTables,
3744
+ __privateGet$4(this, _table),
3745
+ record,
3746
+ data.columns ?? ["*"]
3747
+ )
3749
3748
  );
3750
3749
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
3751
3750
  return new Page(query, meta, records);
@@ -3772,7 +3771,13 @@ class RestRepository extends Query {
3772
3771
  },
3773
3772
  ...__privateGet$4(this, _getFetchProps).call(this)
3774
3773
  });
3775
- return result;
3774
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3775
+ return {
3776
+ ...result,
3777
+ summaries: result.summaries.map(
3778
+ (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3779
+ )
3780
+ };
3776
3781
  });
3777
3782
  }
3778
3783
  ask(question, options) {
@@ -4051,19 +4056,15 @@ transformObjectToApi_fn = async function(object) {
4051
4056
  case "file[]":
4052
4057
  result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
4053
4058
  break;
4059
+ case "json":
4060
+ result[key] = stringifyJson(value);
4061
+ break;
4054
4062
  default:
4055
4063
  result[key] = value;
4056
4064
  }
4057
4065
  }
4058
4066
  return result;
4059
4067
  };
4060
- const removeLinksFromObject = (object) => {
4061
- return Object.entries(object).reduce((acc, [key, value]) => {
4062
- if (key === "xata")
4063
- return acc;
4064
- return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
4065
- }, {});
4066
- };
4067
4068
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
4068
4069
  const data = {};
4069
4070
  const { xata, ...rest } = object ?? {};
@@ -4094,13 +4095,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4094
4095
  if (item === column.name) {
4095
4096
  return [...acc, "*"];
4096
4097
  }
4097
- if (item.startsWith(`${column.name}.`)) {
4098
+ if (isString(item) && item.startsWith(`${column.name}.`)) {
4098
4099
  const [, ...path] = item.split(".");
4099
4100
  return [...acc, path.join(".")];
4100
4101
  }
4101
4102
  return acc;
4102
4103
  }, []);
4103
- data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
4104
+ data[column.name] = initObject(
4105
+ db,
4106
+ schemaTables,
4107
+ linkTable,
4108
+ value,
4109
+ selectedLinkColumns
4110
+ );
4104
4111
  } else {
4105
4112
  data[column.name] = null;
4106
4113
  }
@@ -4112,6 +4119,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4112
4119
  case "file[]":
4113
4120
  data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
4114
4121
  break;
4122
+ case "json":
4123
+ data[column.name] = parseJson(value);
4124
+ break;
4115
4125
  default:
4116
4126
  data[column.name] = value ?? null;
4117
4127
  if (column.notNull === true && value === null) {
@@ -4121,33 +4131,34 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4121
4131
  }
4122
4132
  }
4123
4133
  const record = { ...data };
4124
- const serializable = { xata, ...removeLinksFromObject(data) };
4125
4134
  const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
4126
4135
  record.read = function(columns2) {
4127
4136
  return db[table].read(record["id"], columns2);
4128
4137
  };
4129
4138
  record.update = function(data2, b, c) {
4130
- const columns2 = isStringArray(b) ? b : ["*"];
4139
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
4131
4140
  const ifVersion = parseIfVersion(b, c);
4132
4141
  return db[table].update(record["id"], data2, columns2, { ifVersion });
4133
4142
  };
4134
4143
  record.replace = function(data2, b, c) {
4135
- const columns2 = isStringArray(b) ? b : ["*"];
4144
+ const columns2 = isValidSelectableColumns(b) ? b : ["*"];
4136
4145
  const ifVersion = parseIfVersion(b, c);
4137
4146
  return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
4138
4147
  };
4139
4148
  record.delete = function() {
4140
4149
  return db[table].delete(record["id"]);
4141
4150
  };
4142
- record.xata = Object.freeze(metadata);
4151
+ if (metadata !== void 0) {
4152
+ record.xata = Object.freeze(metadata);
4153
+ }
4143
4154
  record.getMetadata = function() {
4144
4155
  return record.xata;
4145
4156
  };
4146
4157
  record.toSerializable = function() {
4147
- return JSON.parse(JSON.stringify(serializable));
4158
+ return JSON.parse(JSON.stringify(record));
4148
4159
  };
4149
4160
  record.toString = function() {
4150
- return JSON.stringify(serializable);
4161
+ return JSON.stringify(record);
4151
4162
  };
4152
4163
  for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
4153
4164
  Object.defineProperty(record, prop, { enumerable: false });
@@ -4165,7 +4176,7 @@ function extractId(value) {
4165
4176
  function isValidColumn(columns, column) {
4166
4177
  if (columns.includes("*"))
4167
4178
  return true;
4168
- return columns.filter((item) => item.startsWith(column.name)).length > 0;
4179
+ return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
4169
4180
  }
4170
4181
  function parseIfVersion(...args) {
4171
4182
  for (const arg of args) {
@@ -4176,12 +4187,6 @@ function parseIfVersion(...args) {
4176
4187
  return void 0;
4177
4188
  }
4178
4189
 
4179
- var __defProp$3 = Object.defineProperty;
4180
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4181
- var __publicField$3 = (obj, key, value) => {
4182
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4183
- return value;
4184
- };
4185
4190
  var __accessCheck$3 = (obj, member, msg) => {
4186
4191
  if (!member.has(obj))
4187
4192
  throw TypeError("Cannot " + msg);
@@ -4204,8 +4209,6 @@ var _map;
4204
4209
  class SimpleCache {
4205
4210
  constructor(options = {}) {
4206
4211
  __privateAdd$3(this, _map, void 0);
4207
- __publicField$3(this, "capacity");
4208
- __publicField$3(this, "defaultQueryTTL");
4209
4212
  __privateSet$3(this, _map, /* @__PURE__ */ new Map());
4210
4213
  this.capacity = options.max ?? 500;
4211
4214
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
@@ -4250,10 +4253,12 @@ const notExists = (column) => ({ $notExists: column });
4250
4253
  const startsWith = (value) => ({ $startsWith: value });
4251
4254
  const endsWith = (value) => ({ $endsWith: value });
4252
4255
  const pattern = (value) => ({ $pattern: value });
4256
+ const iPattern = (value) => ({ $iPattern: value });
4253
4257
  const is = (value) => ({ $is: value });
4254
4258
  const equals = is;
4255
4259
  const isNot = (value) => ({ $isNot: value });
4256
4260
  const contains = (value) => ({ $contains: value });
4261
+ const iContains = (value) => ({ $iContains: value });
4257
4262
  const includes = (value) => ({ $includes: value });
4258
4263
  const includesAll = (value) => ({ $includesAll: value });
4259
4264
  const includesNone = (value) => ({ $includesNone: value });
@@ -4309,6 +4314,80 @@ class SchemaPlugin extends XataPlugin {
4309
4314
  _tables = new WeakMap();
4310
4315
  _schemaTables$1 = new WeakMap();
4311
4316
 
4317
+ class FilesPlugin extends XataPlugin {
4318
+ build(pluginOptions) {
4319
+ return {
4320
+ download: async (location) => {
4321
+ const { table, record, column, fileId = "" } = location ?? {};
4322
+ return await getFileItem({
4323
+ pathParams: {
4324
+ workspace: "{workspaceId}",
4325
+ dbBranchName: "{dbBranch}",
4326
+ region: "{region}",
4327
+ tableName: table ?? "",
4328
+ recordId: record ?? "",
4329
+ columnName: column ?? "",
4330
+ fileId
4331
+ },
4332
+ ...pluginOptions,
4333
+ rawResponse: true
4334
+ });
4335
+ },
4336
+ upload: async (location, file, options) => {
4337
+ const { table, record, column, fileId = "" } = location ?? {};
4338
+ const resolvedFile = await file;
4339
+ const contentType = options?.mediaType || getContentType(resolvedFile);
4340
+ const body = resolvedFile instanceof XataFile ? resolvedFile.toBlob() : resolvedFile;
4341
+ return await putFileItem({
4342
+ ...pluginOptions,
4343
+ pathParams: {
4344
+ workspace: "{workspaceId}",
4345
+ dbBranchName: "{dbBranch}",
4346
+ region: "{region}",
4347
+ tableName: table ?? "",
4348
+ recordId: record ?? "",
4349
+ columnName: column ?? "",
4350
+ fileId
4351
+ },
4352
+ body,
4353
+ headers: { "Content-Type": contentType }
4354
+ });
4355
+ },
4356
+ delete: async (location) => {
4357
+ const { table, record, column, fileId = "" } = location ?? {};
4358
+ return await deleteFileItem({
4359
+ pathParams: {
4360
+ workspace: "{workspaceId}",
4361
+ dbBranchName: "{dbBranch}",
4362
+ region: "{region}",
4363
+ tableName: table ?? "",
4364
+ recordId: record ?? "",
4365
+ columnName: column ?? "",
4366
+ fileId
4367
+ },
4368
+ ...pluginOptions
4369
+ });
4370
+ }
4371
+ };
4372
+ }
4373
+ }
4374
+ function getContentType(file) {
4375
+ if (typeof file === "string") {
4376
+ return "text/plain";
4377
+ }
4378
+ if ("mediaType" in file) {
4379
+ return file.mediaType;
4380
+ }
4381
+ if (isBlob(file)) {
4382
+ return file.type;
4383
+ }
4384
+ try {
4385
+ return file.type;
4386
+ } catch (e) {
4387
+ }
4388
+ return "application/octet-stream";
4389
+ }
4390
+
4312
4391
  var __accessCheck$1 = (obj, member, msg) => {
4313
4392
  if (!member.has(obj))
4314
4393
  throw TypeError("Cannot " + msg);
@@ -4344,22 +4423,26 @@ class SearchPlugin extends XataPlugin {
4344
4423
  build(pluginOptions) {
4345
4424
  return {
4346
4425
  all: async (query, options = {}) => {
4347
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4426
+ const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4348
4427
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4349
- return records.map((record) => {
4350
- const { table = "orphan" } = record.xata;
4351
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4352
- });
4428
+ return {
4429
+ totalCount,
4430
+ records: records.map((record) => {
4431
+ const { table = "orphan" } = record.xata;
4432
+ return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4433
+ })
4434
+ };
4353
4435
  },
4354
4436
  byTable: async (query, options = {}) => {
4355
- const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4437
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4356
4438
  const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4357
- return records.reduce((acc, record) => {
4439
+ const records = rawRecords.reduce((acc, record) => {
4358
4440
  const { table = "orphan" } = record.xata;
4359
4441
  const items = acc[table] ?? [];
4360
4442
  const item = initObject(this.db, schemaTables, table, record, ["*"]);
4361
4443
  return { ...acc, [table]: [...items, item] };
4362
4444
  }, {});
4445
+ return { totalCount, records };
4363
4446
  }
4364
4447
  };
4365
4448
  }
@@ -4368,13 +4451,13 @@ _schemaTables = new WeakMap();
4368
4451
  _search = new WeakSet();
4369
4452
  search_fn = async function(query, options, pluginOptions) {
4370
4453
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4371
- const { records } = await searchBranch({
4454
+ const { records, totalCount } = await searchBranch({
4372
4455
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4373
4456
  // @ts-ignore https://github.com/xataio/client-ts/issues/313
4374
4457
  body: { tables, query, fuzziness, prefix, highlight, page },
4375
4458
  ...pluginOptions
4376
4459
  });
4377
- return records;
4460
+ return { records, totalCount };
4378
4461
  };
4379
4462
  _getSchemaTables = new WeakSet();
4380
4463
  getSchemaTables_fn = async function(pluginOptions) {
@@ -4475,12 +4558,6 @@ class TransactionPlugin extends XataPlugin {
4475
4558
  }
4476
4559
  }
4477
4560
 
4478
- var __defProp$2 = Object.defineProperty;
4479
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4480
- var __publicField$2 = (obj, key, value) => {
4481
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
4482
- return value;
4483
- };
4484
4561
  var __accessCheck = (obj, member, msg) => {
4485
4562
  if (!member.has(obj))
4486
4563
  throw TypeError("Cannot " + msg);
@@ -4510,11 +4587,6 @@ const buildClient = (plugins) => {
4510
4587
  __privateAdd(this, _parseOptions);
4511
4588
  __privateAdd(this, _getFetchProps);
4512
4589
  __privateAdd(this, _options, void 0);
4513
- __publicField$2(this, "db");
4514
- __publicField$2(this, "search");
4515
- __publicField$2(this, "transactions");
4516
- __publicField$2(this, "sql");
4517
- __publicField$2(this, "files");
4518
4590
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
4519
4591
  __privateSet(this, _options, safeOptions);
4520
4592
  const pluginOptions = {
@@ -4628,17 +4700,11 @@ const buildClient = (plugins) => {
4628
4700
  class BaseClient extends buildClient() {
4629
4701
  }
4630
4702
 
4631
- var __defProp$1 = Object.defineProperty;
4632
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4633
- var __publicField$1 = (obj, key, value) => {
4634
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
4635
- return value;
4636
- };
4637
4703
  const META = "__";
4638
4704
  const VALUE = "___";
4639
4705
  class Serializer {
4640
4706
  constructor() {
4641
- __publicField$1(this, "classes", {});
4707
+ this.classes = {};
4642
4708
  }
4643
4709
  add(clazz) {
4644
4710
  this.classes[clazz.name] = clazz;
@@ -4701,34 +4767,12 @@ const deserialize = (json) => {
4701
4767
  return defaultSerializer.fromJSON(json);
4702
4768
  };
4703
4769
 
4704
- function buildWorkerRunner(config) {
4705
- return function xataWorker(name, worker) {
4706
- return async (...args) => {
4707
- const url = process.env.NODE_ENV === "development" ? `http://localhost:64749/${name}` : `https://dispatcher.xata.workers.dev/${config.workspace}/${config.worker}/${name}`;
4708
- const result = await fetch(url, {
4709
- method: "POST",
4710
- headers: { "Content-Type": "application/json" },
4711
- body: serialize({ args })
4712
- });
4713
- const text = await result.text();
4714
- return deserialize(text);
4715
- };
4716
- };
4717
- }
4718
-
4719
- var __defProp = Object.defineProperty;
4720
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4721
- var __publicField = (obj, key, value) => {
4722
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4723
- return value;
4724
- };
4725
4770
  class XataError extends Error {
4726
4771
  constructor(message, status) {
4727
4772
  super(message);
4728
- __publicField(this, "status");
4729
4773
  this.status = status;
4730
4774
  }
4731
4775
  }
4732
4776
 
4733
- 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, 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, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, 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, getUserOAuthAccessTokens, getUserOAuthClients, 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, transformImage, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
4777
+ export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, pgRollStatus, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
4734
4778
  //# sourceMappingURL=index.mjs.map