@xata.io/client 0.0.0-alpha.vf27674a → 0.0.0-alpha.vf28813b

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
@@ -2,6 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n["default"] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
5
23
  function notEmpty(value) {
6
24
  return value !== null && value !== void 0;
7
25
  }
@@ -11,46 +29,101 @@ function compact(arr) {
11
29
  function isObject(value) {
12
30
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13
31
  }
32
+ function isDefined(value) {
33
+ return value !== null && value !== void 0;
34
+ }
14
35
  function isString(value) {
15
- return value !== void 0 && value !== null && typeof value === "string";
36
+ return isDefined(value) && typeof value === "string";
37
+ }
38
+ function isStringArray(value) {
39
+ return isDefined(value) && Array.isArray(value) && value.every(isString);
16
40
  }
17
41
  function toBase64(value) {
18
42
  try {
19
43
  return btoa(value);
20
44
  } catch (err) {
21
- return Buffer.from(value).toString("base64");
45
+ const buf = Buffer;
46
+ return buf.from(value).toString("base64");
22
47
  }
23
48
  }
24
49
 
25
- function getEnvVariable(name) {
50
+ function getEnvironment() {
26
51
  try {
27
- if (isObject(process) && isString(process?.env?.[name])) {
28
- return process.env[name];
52
+ if (isObject(process) && isObject(process.env)) {
53
+ return {
54
+ apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
55
+ databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
56
+ branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
57
+ envBranch: process.env.VERCEL_GIT_COMMIT_REF ?? process.env.CF_PAGES_BRANCH ?? process.env.BRANCH,
58
+ fallbackBranch: process.env.XATA_FALLBACK_BRANCH ?? getGlobalFallbackBranch()
59
+ };
29
60
  }
30
61
  } catch (err) {
31
62
  }
32
63
  try {
33
- if (isObject(Deno) && isString(Deno?.env?.get(name))) {
34
- return Deno.env.get(name);
64
+ if (isObject(Deno) && isObject(Deno.env)) {
65
+ return {
66
+ apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
67
+ databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
68
+ branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
69
+ envBranch: Deno.env.get("VERCEL_GIT_COMMIT_REF") ?? Deno.env.get("CF_PAGES_BRANCH") ?? Deno.env.get("BRANCH"),
70
+ fallbackBranch: Deno.env.get("XATA_FALLBACK_BRANCH") ?? getGlobalFallbackBranch()
71
+ };
35
72
  }
36
73
  } catch (err) {
37
74
  }
75
+ return {
76
+ apiKey: getGlobalApiKey(),
77
+ databaseURL: getGlobalDatabaseURL(),
78
+ branch: getGlobalBranch(),
79
+ envBranch: void 0,
80
+ fallbackBranch: getGlobalFallbackBranch()
81
+ };
82
+ }
83
+ function getGlobalApiKey() {
84
+ try {
85
+ return XATA_API_KEY;
86
+ } catch (err) {
87
+ return void 0;
88
+ }
89
+ }
90
+ function getGlobalDatabaseURL() {
91
+ try {
92
+ return XATA_DATABASE_URL;
93
+ } catch (err) {
94
+ return void 0;
95
+ }
96
+ }
97
+ function getGlobalBranch() {
98
+ try {
99
+ return XATA_BRANCH;
100
+ } catch (err) {
101
+ return void 0;
102
+ }
103
+ }
104
+ function getGlobalFallbackBranch() {
105
+ try {
106
+ return XATA_FALLBACK_BRANCH;
107
+ } catch (err) {
108
+ return void 0;
109
+ }
38
110
  }
39
111
  async function getGitBranch() {
112
+ const cmd = ["git", "branch", "--show-current"];
113
+ const fullCmd = cmd.join(" ");
114
+ const nodeModule = ["child", "process"].join("_");
115
+ const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
40
116
  try {
41
117
  if (typeof require === "function") {
42
- const req = require;
43
- return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
118
+ return require(nodeModule).execSync(fullCmd, execOptions).trim();
44
119
  }
120
+ const { execSync } = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(nodeModule);
121
+ return execSync(fullCmd, execOptions).toString().trim();
45
122
  } catch (err) {
46
123
  }
47
124
  try {
48
125
  if (isObject(Deno)) {
49
- const process2 = Deno.run({
50
- cmd: ["git", "branch", "--show-current"],
51
- stdout: "piped",
52
- stderr: "piped"
53
- });
126
+ const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
54
127
  return new TextDecoder().decode(await process2.output()).trim();
55
128
  }
56
129
  } catch (err) {
@@ -59,7 +132,8 @@ async function getGitBranch() {
59
132
 
60
133
  function getAPIKey() {
61
134
  try {
62
- return getEnvVariable("XATA_API_KEY") ?? XATA_API_KEY;
135
+ const { apiKey } = getEnvironment();
136
+ return apiKey;
63
137
  } catch (err) {
64
138
  return void 0;
65
139
  }
@@ -69,21 +143,35 @@ function getFetchImplementation(userFetch) {
69
143
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
70
144
  const fetchImpl = userFetch ?? globalFetch;
71
145
  if (!fetchImpl) {
72
- throw new Error(`The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`);
146
+ throw new Error(
147
+ `The \`fetch\` option passed to the Xata client is resolving to a falsy value and may not be correctly imported.`
148
+ );
73
149
  }
74
150
  return fetchImpl;
75
151
  }
76
152
 
77
- class FetcherError extends Error {
78
- constructor(status, data) {
153
+ const VERSION = "0.0.0-alpha.vf28813b";
154
+
155
+ class ErrorWithCause extends Error {
156
+ constructor(message, options) {
157
+ super(message, options);
158
+ }
159
+ }
160
+ class FetcherError extends ErrorWithCause {
161
+ constructor(status, data, requestId) {
79
162
  super(getMessage(data));
80
163
  this.status = status;
81
164
  this.errors = isBulkError(data) ? data.errors : void 0;
165
+ this.requestId = requestId;
82
166
  if (data instanceof Error) {
83
167
  this.stack = data.stack;
84
168
  this.cause = data.cause;
85
169
  }
86
170
  }
171
+ toString() {
172
+ const error = super.toString();
173
+ return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
174
+ }
87
175
  }
88
176
  function isBulkError(error) {
89
177
  return isObject(error) && Array.isArray(error.errors);
@@ -106,7 +194,12 @@ function getMessage(data) {
106
194
  }
107
195
 
108
196
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
109
- const query = new URLSearchParams(queryParams).toString();
197
+ const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
198
+ if (value === void 0 || value === null)
199
+ return acc;
200
+ return { ...acc, [key]: value };
201
+ }, {});
202
+ const query = new URLSearchParams(cleanQueryParams).toString();
110
203
  const queryString = query.length > 0 ? `?${query}` : "";
111
204
  return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
112
205
  };
@@ -146,6 +239,7 @@ async function fetch$1({
146
239
  body: body ? JSON.stringify(body) : void 0,
147
240
  headers: {
148
241
  "Content-Type": "application/json",
242
+ "User-Agent": `Xata client-ts/${VERSION}`,
149
243
  ...headers,
150
244
  ...hostHeader(fullUrl),
151
245
  Authorization: `Bearer ${apiKey}`
@@ -154,14 +248,15 @@ async function fetch$1({
154
248
  if (response.status === 204) {
155
249
  return {};
156
250
  }
251
+ const requestId = response.headers?.get("x-request-id") ?? void 0;
157
252
  try {
158
253
  const jsonResponse = await response.json();
159
254
  if (response.ok) {
160
255
  return jsonResponse;
161
256
  }
162
- throw new FetcherError(response.status, jsonResponse);
257
+ throw new FetcherError(response.status, jsonResponse, requestId);
163
258
  } catch (error) {
164
- throw new FetcherError(response.status, error);
259
+ throw new FetcherError(response.status, error, requestId);
165
260
  }
166
261
  }
167
262
 
@@ -220,6 +315,7 @@ const removeWorkspaceMember = (variables) => fetch$1({
220
315
  ...variables
221
316
  });
222
317
  const inviteWorkspaceMember = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables });
318
+ const updateWorkspaceMemberInvite = (variables) => fetch$1({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables });
223
319
  const cancelWorkspaceMemberInvite = (variables) => fetch$1({
224
320
  url: "/workspaces/{workspaceId}/invites/{inviteId}",
225
321
  method: "delete",
@@ -255,6 +351,11 @@ const deleteDatabase = (variables) => fetch$1({
255
351
  method: "delete",
256
352
  ...variables
257
353
  });
354
+ const getDatabaseMetadata = (variables) => fetch$1({
355
+ url: "/dbs/{dbName}/metadata",
356
+ method: "get",
357
+ ...variables
358
+ });
258
359
  const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
259
360
  const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
260
361
  const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
@@ -268,11 +369,7 @@ const getBranchDetails = (variables) => fetch$1({
268
369
  method: "get",
269
370
  ...variables
270
371
  });
271
- const createBranch = (variables) => fetch$1({
272
- url: "/db/{dbBranchName}",
273
- method: "put",
274
- ...variables
275
- });
372
+ const createBranch = (variables) => fetch$1({ url: "/db/{dbBranchName}", method: "put", ...variables });
276
373
  const deleteBranch = (variables) => fetch$1({
277
374
  url: "/db/{dbBranchName}",
278
375
  method: "delete",
@@ -346,11 +443,7 @@ const updateColumn = (variables) => fetch$1({
346
443
  method: "patch",
347
444
  ...variables
348
445
  });
349
- const insertRecord = (variables) => fetch$1({
350
- url: "/db/{dbBranchName}/tables/{tableName}/data",
351
- method: "post",
352
- ...variables
353
- });
446
+ const insertRecord = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables });
354
447
  const insertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables });
355
448
  const updateRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables });
356
449
  const upsertRecordWithID = (variables) => fetch$1({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables });
@@ -370,6 +463,11 @@ const queryTable = (variables) => fetch$1({
370
463
  method: "post",
371
464
  ...variables
372
465
  });
466
+ const searchTable = (variables) => fetch$1({
467
+ url: "/db/{dbBranchName}/tables/{tableName}/search",
468
+ method: "post",
469
+ ...variables
470
+ });
373
471
  const searchBranch = (variables) => fetch$1({
374
472
  url: "/db/{dbBranchName}/search",
375
473
  method: "post",
@@ -387,6 +485,7 @@ const operationsByTag = {
387
485
  updateWorkspaceMemberRole,
388
486
  removeWorkspaceMember,
389
487
  inviteWorkspaceMember,
488
+ updateWorkspaceMemberInvite,
390
489
  cancelWorkspaceMemberInvite,
391
490
  resendWorkspaceMemberInvite,
392
491
  acceptWorkspaceMemberInvite
@@ -402,6 +501,7 @@ const operationsByTag = {
402
501
  },
403
502
  branch: {
404
503
  getBranchList,
504
+ getDatabaseMetadata,
405
505
  getBranchDetails,
406
506
  createBranch,
407
507
  deleteBranch,
@@ -433,6 +533,7 @@ const operationsByTag = {
433
533
  getRecord,
434
534
  bulkInsertTableRecords,
435
535
  queryTable,
536
+ searchTable,
436
537
  searchBranch
437
538
  }
438
539
  };
@@ -475,7 +576,7 @@ var __privateAdd$7 = (obj, member, value) => {
475
576
  throw TypeError("Cannot add the same private member more than once");
476
577
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
477
578
  };
478
- var __privateSet$6 = (obj, member, value, setter) => {
579
+ var __privateSet$7 = (obj, member, value, setter) => {
479
580
  __accessCheck$7(obj, member, "write to private field");
480
581
  setter ? setter.call(obj, value) : member.set(obj, value);
481
582
  return value;
@@ -490,7 +591,7 @@ class XataApiClient {
490
591
  if (!apiKey) {
491
592
  throw new Error("Could not resolve a valid apiKey");
492
593
  }
493
- __privateSet$6(this, _extraProps, {
594
+ __privateSet$7(this, _extraProps, {
494
595
  apiUrl: getHostUrl(provider, "main"),
495
596
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
496
597
  fetchImpl: getFetchImplementation(options.fetch),
@@ -617,6 +718,13 @@ class WorkspaceApi {
617
718
  ...this.extraProps
618
719
  });
619
720
  }
721
+ updateWorkspaceMemberInvite(workspaceId, inviteId, role) {
722
+ return operationsByTag.workspaces.updateWorkspaceMemberInvite({
723
+ pathParams: { workspaceId, inviteId },
724
+ body: { role },
725
+ ...this.extraProps
726
+ });
727
+ }
620
728
  cancelWorkspaceMemberInvite(workspaceId, inviteId) {
621
729
  return operationsByTag.workspaces.cancelWorkspaceMemberInvite({
622
730
  pathParams: { workspaceId, inviteId },
@@ -679,10 +787,10 @@ class DatabaseApi {
679
787
  ...this.extraProps
680
788
  });
681
789
  }
682
- resolveBranch(workspace, dbName, gitBranch) {
790
+ resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
683
791
  return operationsByTag.database.resolveBranch({
684
792
  pathParams: { workspace, dbName },
685
- queryParams: { gitBranch },
793
+ queryParams: { gitBranch, fallbackBranch },
686
794
  ...this.extraProps
687
795
  });
688
796
  }
@@ -831,9 +939,10 @@ class RecordsApi {
831
939
  constructor(extraProps) {
832
940
  this.extraProps = extraProps;
833
941
  }
834
- insertRecord(workspace, database, branch, tableName, record) {
942
+ insertRecord(workspace, database, branch, tableName, record, options = {}) {
835
943
  return operationsByTag.records.insertRecord({
836
944
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
945
+ queryParams: options,
837
946
  body: record,
838
947
  ...this.extraProps
839
948
  });
@@ -862,21 +971,24 @@ class RecordsApi {
862
971
  ...this.extraProps
863
972
  });
864
973
  }
865
- deleteRecord(workspace, database, branch, tableName, recordId) {
974
+ deleteRecord(workspace, database, branch, tableName, recordId, options = {}) {
866
975
  return operationsByTag.records.deleteRecord({
867
976
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
977
+ queryParams: options,
868
978
  ...this.extraProps
869
979
  });
870
980
  }
871
981
  getRecord(workspace, database, branch, tableName, recordId, options = {}) {
872
982
  return operationsByTag.records.getRecord({
873
983
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName, recordId },
984
+ queryParams: options,
874
985
  ...this.extraProps
875
986
  });
876
987
  }
877
- bulkInsertTableRecords(workspace, database, branch, tableName, records) {
988
+ bulkInsertTableRecords(workspace, database, branch, tableName, records, options = {}) {
878
989
  return operationsByTag.records.bulkInsertTableRecords({
879
990
  pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
991
+ queryParams: options,
880
992
  body: { records },
881
993
  ...this.extraProps
882
994
  });
@@ -888,6 +1000,13 @@ class RecordsApi {
888
1000
  ...this.extraProps
889
1001
  });
890
1002
  }
1003
+ searchTable(workspace, database, branch, tableName, query) {
1004
+ return operationsByTag.records.searchTable({
1005
+ pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
1006
+ body: query,
1007
+ ...this.extraProps
1008
+ });
1009
+ }
891
1010
  searchBranch(workspace, database, branch, query) {
892
1011
  return operationsByTag.records.searchBranch({
893
1012
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
@@ -920,18 +1039,18 @@ var __privateAdd$6 = (obj, member, value) => {
920
1039
  throw TypeError("Cannot add the same private member more than once");
921
1040
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
922
1041
  };
923
- var __privateSet$5 = (obj, member, value, setter) => {
1042
+ var __privateSet$6 = (obj, member, value, setter) => {
924
1043
  __accessCheck$6(obj, member, "write to private field");
925
1044
  setter ? setter.call(obj, value) : member.set(obj, value);
926
1045
  return value;
927
1046
  };
928
- var _query;
1047
+ var _query, _page;
929
1048
  class Page {
930
1049
  constructor(query, meta, records = []) {
931
1050
  __privateAdd$6(this, _query, void 0);
932
- __privateSet$5(this, _query, query);
1051
+ __privateSet$6(this, _query, query);
933
1052
  this.meta = meta;
934
- this.records = records;
1053
+ this.records = new RecordArray(this, records);
935
1054
  }
936
1055
  async nextPage(size, offset) {
937
1056
  return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
@@ -951,9 +1070,56 @@ class Page {
951
1070
  }
952
1071
  _query = new WeakMap();
953
1072
  const PAGINATION_MAX_SIZE = 200;
954
- const PAGINATION_DEFAULT_SIZE = 200;
1073
+ const PAGINATION_DEFAULT_SIZE = 20;
955
1074
  const PAGINATION_MAX_OFFSET = 800;
956
1075
  const PAGINATION_DEFAULT_OFFSET = 0;
1076
+ function isCursorPaginationOptions(options) {
1077
+ return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
1078
+ }
1079
+ const _RecordArray = class extends Array {
1080
+ constructor(...args) {
1081
+ super(..._RecordArray.parseConstructorParams(...args));
1082
+ __privateAdd$6(this, _page, void 0);
1083
+ __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
1084
+ }
1085
+ static parseConstructorParams(...args) {
1086
+ if (args.length === 1 && typeof args[0] === "number") {
1087
+ return new Array(args[0]);
1088
+ }
1089
+ if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
1090
+ const result = args[1] ?? args[0].records ?? [];
1091
+ return new Array(...result);
1092
+ }
1093
+ return new Array(...args);
1094
+ }
1095
+ toArray() {
1096
+ return new Array(...this);
1097
+ }
1098
+ map(callbackfn, thisArg) {
1099
+ return this.toArray().map(callbackfn, thisArg);
1100
+ }
1101
+ async nextPage(size, offset) {
1102
+ const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
1103
+ return new _RecordArray(newPage);
1104
+ }
1105
+ async previousPage(size, offset) {
1106
+ const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
1107
+ return new _RecordArray(newPage);
1108
+ }
1109
+ async firstPage(size, offset) {
1110
+ const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
1111
+ return new _RecordArray(newPage);
1112
+ }
1113
+ async lastPage(size, offset) {
1114
+ const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
1115
+ return new _RecordArray(newPage);
1116
+ }
1117
+ hasNextPage() {
1118
+ return __privateGet$6(this, _page).meta.page.more;
1119
+ }
1120
+ };
1121
+ let RecordArray = _RecordArray;
1122
+ _page = new WeakMap();
957
1123
 
958
1124
  var __accessCheck$5 = (obj, member, msg) => {
959
1125
  if (!member.has(obj))
@@ -968,25 +1134,26 @@ var __privateAdd$5 = (obj, member, value) => {
968
1134
  throw TypeError("Cannot add the same private member more than once");
969
1135
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
970
1136
  };
971
- var __privateSet$4 = (obj, member, value, setter) => {
1137
+ var __privateSet$5 = (obj, member, value, setter) => {
972
1138
  __accessCheck$5(obj, member, "write to private field");
973
1139
  setter ? setter.call(obj, value) : member.set(obj, value);
974
1140
  return value;
975
1141
  };
976
1142
  var _table$1, _repository, _data;
977
1143
  const _Query = class {
978
- constructor(repository, table, data, parent) {
1144
+ constructor(repository, table, data, rawParent) {
979
1145
  __privateAdd$5(this, _table$1, void 0);
980
1146
  __privateAdd$5(this, _repository, void 0);
981
1147
  __privateAdd$5(this, _data, { filter: {} });
982
1148
  this.meta = { page: { cursor: "start", more: true } };
983
- this.records = [];
984
- __privateSet$4(this, _table$1, table);
1149
+ this.records = new RecordArray(this, []);
1150
+ __privateSet$5(this, _table$1, table);
985
1151
  if (repository) {
986
- __privateSet$4(this, _repository, repository);
1152
+ __privateSet$5(this, _repository, repository);
987
1153
  } else {
988
- __privateSet$4(this, _repository, this);
1154
+ __privateSet$5(this, _repository, this);
989
1155
  }
1156
+ const parent = cleanParent(data, rawParent);
990
1157
  __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
991
1158
  __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
992
1159
  __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
@@ -1045,7 +1212,12 @@ const _Query = class {
1045
1212
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
1046
1213
  }
1047
1214
  select(columns) {
1048
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
1215
+ return new _Query(
1216
+ __privateGet$5(this, _repository),
1217
+ __privateGet$5(this, _table$1),
1218
+ { columns },
1219
+ __privateGet$5(this, _data)
1220
+ );
1049
1221
  }
1050
1222
  getPaginated(options = {}) {
1051
1223
  const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
@@ -1058,18 +1230,21 @@ const _Query = class {
1058
1230
  }
1059
1231
  async *getIterator(options = {}) {
1060
1232
  const { batchSize = 1 } = options;
1061
- let offset = 0;
1062
- let end = false;
1063
- while (!end) {
1064
- const { records, meta } = await this.getPaginated({ ...options, pagination: { size: batchSize, offset } });
1065
- yield records;
1066
- offset += batchSize;
1067
- end = !meta.page.more;
1233
+ let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
1234
+ let more = page.hasNextPage();
1235
+ yield page.records;
1236
+ while (more) {
1237
+ page = await page.nextPage();
1238
+ more = page.hasNextPage();
1239
+ yield page.records;
1068
1240
  }
1069
1241
  }
1070
1242
  async getMany(options = {}) {
1071
- const { records } = await this.getPaginated(options);
1072
- return records;
1243
+ const page = await this.getPaginated(options);
1244
+ if (page.hasNextPage() && options.pagination?.size === void 0) {
1245
+ console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
1246
+ }
1247
+ return page.records;
1073
1248
  }
1074
1249
  async getAll(options = {}) {
1075
1250
  const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
@@ -1081,7 +1256,7 @@ const _Query = class {
1081
1256
  }
1082
1257
  async getFirst(options = {}) {
1083
1258
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1084
- return records[0] || null;
1259
+ return records[0] ?? null;
1085
1260
  }
1086
1261
  cache(ttl) {
1087
1262
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
@@ -1106,12 +1281,20 @@ let Query = _Query;
1106
1281
  _table$1 = new WeakMap();
1107
1282
  _repository = new WeakMap();
1108
1283
  _data = new WeakMap();
1284
+ function cleanParent(data, parent) {
1285
+ if (isCursorPaginationOptions(data.pagination)) {
1286
+ return { ...parent, sorting: void 0, filter: void 0 };
1287
+ }
1288
+ return parent;
1289
+ }
1109
1290
 
1110
1291
  function isIdentifiable(x) {
1111
1292
  return isObject(x) && isString(x?.id);
1112
1293
  }
1113
1294
  function isXataRecord(x) {
1114
- return isIdentifiable(x) && typeof x?.xata === "object" && typeof x?.xata?.version === "number";
1295
+ const record = x;
1296
+ const metadata = record?.getMetadata();
1297
+ return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
1115
1298
  }
1116
1299
 
1117
1300
  function isSortFilterString(value) {
@@ -1150,7 +1333,7 @@ var __privateAdd$4 = (obj, member, value) => {
1150
1333
  throw TypeError("Cannot add the same private member more than once");
1151
1334
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1152
1335
  };
1153
- var __privateSet$3 = (obj, member, value, setter) => {
1336
+ var __privateSet$4 = (obj, member, value, setter) => {
1154
1337
  __accessCheck$4(obj, member, "write to private field");
1155
1338
  setter ? setter.call(obj, value) : member.set(obj, value);
1156
1339
  return value;
@@ -1159,7 +1342,7 @@ var __privateMethod$2 = (obj, member, method) => {
1159
1342
  __accessCheck$4(obj, member, "access private method");
1160
1343
  return method;
1161
1344
  };
1162
- var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
1345
+ var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1163
1346
  class Repository extends Query {
1164
1347
  }
1165
1348
  class RestRepository extends Query {
@@ -1171,111 +1354,121 @@ class RestRepository extends Query {
1171
1354
  __privateAdd$4(this, _updateRecordWithID);
1172
1355
  __privateAdd$4(this, _upsertRecordWithID);
1173
1356
  __privateAdd$4(this, _deleteRecord);
1174
- __privateAdd$4(this, _invalidateCache);
1175
- __privateAdd$4(this, _setCacheRecord);
1176
- __privateAdd$4(this, _getCacheRecord);
1177
1357
  __privateAdd$4(this, _setCacheQuery);
1178
1358
  __privateAdd$4(this, _getCacheQuery);
1179
- __privateAdd$4(this, _getSchema$1);
1359
+ __privateAdd$4(this, _getSchemaTables$1);
1180
1360
  __privateAdd$4(this, _table, void 0);
1181
1361
  __privateAdd$4(this, _getFetchProps, void 0);
1182
1362
  __privateAdd$4(this, _cache, void 0);
1183
- __privateAdd$4(this, _schema$1, void 0);
1184
- __privateSet$3(this, _table, options.table);
1185
- __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1363
+ __privateAdd$4(this, _schemaTables$2, void 0);
1364
+ __privateSet$4(this, _table, options.table);
1365
+ __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1186
1366
  this.db = options.db;
1187
- __privateSet$3(this, _cache, options.pluginOptions.cache);
1367
+ __privateSet$4(this, _cache, options.pluginOptions.cache);
1368
+ __privateSet$4(this, _schemaTables$2, options.schemaTables);
1188
1369
  }
1189
- async create(a, b) {
1370
+ async create(a, b, c) {
1190
1371
  if (Array.isArray(a)) {
1191
- const records = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a);
1192
- await Promise.all(records.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
1193
- return records;
1372
+ if (a.length === 0)
1373
+ return [];
1374
+ const columns = isStringArray(b) ? b : void 0;
1375
+ return __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, a, columns);
1194
1376
  }
1195
1377
  if (isString(a) && isObject(b)) {
1196
1378
  if (a === "")
1197
1379
  throw new Error("The id can't be empty");
1198
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b);
1199
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1200
- return record;
1380
+ const columns = isStringArray(c) ? c : void 0;
1381
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns);
1201
1382
  }
1202
1383
  if (isObject(a) && isString(a.id)) {
1203
1384
  if (a.id === "")
1204
1385
  throw new Error("The id can't be empty");
1205
- const record = await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 });
1206
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1207
- return record;
1386
+ const columns = isStringArray(b) ? b : void 0;
1387
+ return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1208
1388
  }
1209
1389
  if (isObject(a)) {
1210
- const record = await __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a);
1211
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1212
- return record;
1390
+ const columns = isStringArray(b) ? b : void 0;
1391
+ return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
1213
1392
  }
1214
1393
  throw new Error("Invalid arguments for create method");
1215
1394
  }
1216
- async read(recordId) {
1217
- const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
1218
- if (cacheRecord)
1219
- return cacheRecord;
1220
- const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1221
- try {
1222
- const response = await getRecord({
1223
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1224
- ...fetchProps
1225
- });
1226
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1227
- return initObject(this.db, schema, __privateGet$4(this, _table), response);
1228
- } catch (e) {
1229
- if (isObject(e) && e.status === 404) {
1230
- return null;
1395
+ async read(a, b) {
1396
+ const columns = isStringArray(b) ? b : ["*"];
1397
+ if (Array.isArray(a)) {
1398
+ if (a.length === 0)
1399
+ return [];
1400
+ const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
1401
+ const finalObjects = await this.getAll({ filter: { id: { $any: ids } }, columns });
1402
+ const dictionary = finalObjects.reduce((acc, object) => {
1403
+ acc[object.id] = object;
1404
+ return acc;
1405
+ }, {});
1406
+ return ids.map((id2) => dictionary[id2] ?? null);
1407
+ }
1408
+ const id = isString(a) ? a : a.id;
1409
+ if (isString(id)) {
1410
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1411
+ try {
1412
+ const response = await getRecord({
1413
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
1414
+ queryParams: { columns },
1415
+ ...fetchProps
1416
+ });
1417
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1418
+ return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1419
+ } catch (e) {
1420
+ if (isObject(e) && e.status === 404) {
1421
+ return null;
1422
+ }
1423
+ throw e;
1231
1424
  }
1232
- throw e;
1233
1425
  }
1426
+ return null;
1234
1427
  }
1235
- async update(a, b) {
1428
+ async update(a, b, c) {
1236
1429
  if (Array.isArray(a)) {
1430
+ if (a.length === 0)
1431
+ return [];
1237
1432
  if (a.length > 100) {
1238
1433
  console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1239
1434
  }
1240
- return Promise.all(a.map((object) => this.update(object)));
1435
+ const columns = isStringArray(b) ? b : ["*"];
1436
+ return Promise.all(a.map((object) => this.update(object, columns)));
1241
1437
  }
1242
1438
  if (isString(a) && isObject(b)) {
1243
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1244
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b);
1245
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1246
- return record;
1439
+ const columns = isStringArray(c) ? c : void 0;
1440
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns);
1247
1441
  }
1248
1442
  if (isObject(a) && isString(a.id)) {
1249
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1250
- const record = await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1251
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1252
- return record;
1443
+ const columns = isStringArray(b) ? b : void 0;
1444
+ return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1253
1445
  }
1254
1446
  throw new Error("Invalid arguments for update method");
1255
1447
  }
1256
- async createOrUpdate(a, b) {
1448
+ async createOrUpdate(a, b, c) {
1257
1449
  if (Array.isArray(a)) {
1450
+ if (a.length === 0)
1451
+ return [];
1258
1452
  if (a.length > 100) {
1259
1453
  console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
1260
1454
  }
1261
- return Promise.all(a.map((object) => this.createOrUpdate(object)));
1455
+ const columns = isStringArray(b) ? b : ["*"];
1456
+ return Promise.all(a.map((object) => this.createOrUpdate(object, columns)));
1262
1457
  }
1263
1458
  if (isString(a) && isObject(b)) {
1264
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1265
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b);
1266
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1267
- return record;
1459
+ const columns = isStringArray(c) ? c : void 0;
1460
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns);
1268
1461
  }
1269
1462
  if (isObject(a) && isString(a.id)) {
1270
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1271
- const record = await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 });
1272
- await __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record);
1273
- return record;
1463
+ const columns = isStringArray(c) ? c : void 0;
1464
+ return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns);
1274
1465
  }
1275
1466
  throw new Error("Invalid arguments for createOrUpdate method");
1276
1467
  }
1277
1468
  async delete(a) {
1278
1469
  if (Array.isArray(a)) {
1470
+ if (a.length === 0)
1471
+ return;
1279
1472
  if (a.length > 100) {
1280
1473
  console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
1281
1474
  }
@@ -1284,25 +1477,30 @@ class RestRepository extends Query {
1284
1477
  }
1285
1478
  if (isString(a)) {
1286
1479
  await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a);
1287
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a);
1288
1480
  return;
1289
1481
  }
1290
1482
  if (isObject(a) && isString(a.id)) {
1291
1483
  await __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id);
1292
- await __privateMethod$2(this, _invalidateCache, invalidateCache_fn).call(this, a.id);
1293
1484
  return;
1294
1485
  }
1295
1486
  throw new Error("Invalid arguments for delete method");
1296
1487
  }
1297
1488
  async search(query, options = {}) {
1298
1489
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1299
- const { records } = await searchBranch({
1300
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1301
- body: { tables: [__privateGet$4(this, _table)], query, fuzziness: options.fuzziness },
1490
+ const { records } = await searchTable({
1491
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1492
+ body: {
1493
+ query,
1494
+ fuzziness: options.fuzziness,
1495
+ prefix: options.prefix,
1496
+ highlight: options.highlight,
1497
+ filter: options.filter,
1498
+ boosters: options.boosters
1499
+ },
1302
1500
  ...fetchProps
1303
1501
  });
1304
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1305
- return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1502
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1503
+ return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1306
1504
  }
1307
1505
  async query(query) {
1308
1506
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
@@ -1311,7 +1509,7 @@ class RestRepository extends Query {
1311
1509
  const data = query.getQueryOptions();
1312
1510
  const body = {
1313
1511
  filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1314
- sort: data.sort ? buildSortFilter(data.sort) : void 0,
1512
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1315
1513
  page: data.pagination,
1316
1514
  columns: data.columns
1317
1515
  };
@@ -1321,8 +1519,8 @@ class RestRepository extends Query {
1321
1519
  body,
1322
1520
  ...fetchProps
1323
1521
  });
1324
- const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1325
- const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1522
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1523
+ const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1326
1524
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1327
1525
  return new Page(query, meta, records);
1328
1526
  }
@@ -1330,9 +1528,9 @@ class RestRepository extends Query {
1330
1528
  _table = new WeakMap();
1331
1529
  _getFetchProps = new WeakMap();
1332
1530
  _cache = new WeakMap();
1333
- _schema$1 = new WeakMap();
1531
+ _schemaTables$2 = new WeakMap();
1334
1532
  _insertRecordWithoutId = new WeakSet();
1335
- insertRecordWithoutId_fn = async function(object) {
1533
+ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1336
1534
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1337
1535
  const record = transformObjectLinks(object);
1338
1536
  const response = await insertRecord({
@@ -1341,17 +1539,15 @@ insertRecordWithoutId_fn = async function(object) {
1341
1539
  dbBranchName: "{dbBranch}",
1342
1540
  tableName: __privateGet$4(this, _table)
1343
1541
  },
1542
+ queryParams: { columns },
1344
1543
  body: record,
1345
1544
  ...fetchProps
1346
1545
  });
1347
- const finalObject = await this.read(response.id);
1348
- if (!finalObject) {
1349
- throw new Error("The server failed to save the record");
1350
- }
1351
- return finalObject;
1546
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1547
+ return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1352
1548
  };
1353
1549
  _insertRecordWithId = new WeakSet();
1354
- insertRecordWithId_fn = async function(recordId, object) {
1550
+ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1355
1551
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1356
1552
  const record = transformObjectLinks(object);
1357
1553
  const response = await insertRecordWithID({
@@ -1362,56 +1558,52 @@ insertRecordWithId_fn = async function(recordId, object) {
1362
1558
  recordId
1363
1559
  },
1364
1560
  body: record,
1365
- queryParams: { createOnly: true },
1561
+ queryParams: { createOnly: true, columns },
1366
1562
  ...fetchProps
1367
1563
  });
1368
- const finalObject = await this.read(response.id);
1369
- if (!finalObject) {
1370
- throw new Error("The server failed to save the record");
1371
- }
1372
- return finalObject;
1564
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1565
+ return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1373
1566
  };
1374
1567
  _bulkInsertTableRecords = new WeakSet();
1375
- bulkInsertTableRecords_fn = async function(objects) {
1568
+ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1376
1569
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1377
1570
  const records = objects.map((object) => transformObjectLinks(object));
1378
1571
  const response = await bulkInsertTableRecords({
1379
1572
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1573
+ queryParams: { columns },
1380
1574
  body: { records },
1381
1575
  ...fetchProps
1382
1576
  });
1383
- const finalObjects = await this.any(...response.recordIDs.map((id) => this.filter("id", id))).getAll();
1384
- if (finalObjects.length !== objects.length) {
1385
- throw new Error("The server failed to save some records");
1577
+ if (!isResponseWithRecords(response)) {
1578
+ throw new Error("Request included columns but server didn't include them");
1386
1579
  }
1387
- return finalObjects;
1580
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1581
+ return response.records?.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1388
1582
  };
1389
1583
  _updateRecordWithID = new WeakSet();
1390
- updateRecordWithID_fn = async function(recordId, object) {
1584
+ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1391
1585
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1392
1586
  const record = transformObjectLinks(object);
1393
1587
  const response = await updateRecordWithID({
1394
1588
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1589
+ queryParams: { columns },
1395
1590
  body: record,
1396
1591
  ...fetchProps
1397
1592
  });
1398
- const item = await this.read(response.id);
1399
- if (!item)
1400
- throw new Error("The server failed to save the record");
1401
- return item;
1593
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1594
+ return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1402
1595
  };
1403
1596
  _upsertRecordWithID = new WeakSet();
1404
- upsertRecordWithID_fn = async function(recordId, object) {
1597
+ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1405
1598
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1406
1599
  const response = await upsertRecordWithID({
1407
1600
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1601
+ queryParams: { columns },
1408
1602
  body: object,
1409
1603
  ...fetchProps
1410
1604
  });
1411
- const item = await this.read(response.id);
1412
- if (!item)
1413
- throw new Error("The server failed to save the record");
1414
- return item;
1605
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1606
+ return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1415
1607
  };
1416
1608
  _deleteRecord = new WeakSet();
1417
1609
  deleteRecord_fn = async function(recordId) {
@@ -1421,29 +1613,6 @@ deleteRecord_fn = async function(recordId) {
1421
1613
  ...fetchProps
1422
1614
  });
1423
1615
  };
1424
- _invalidateCache = new WeakSet();
1425
- invalidateCache_fn = async function(recordId) {
1426
- await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1427
- const cacheItems = await __privateGet$4(this, _cache).getAll();
1428
- const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1429
- for (const [key, value] of queries) {
1430
- const ids = getIds(value);
1431
- if (ids.includes(recordId))
1432
- await __privateGet$4(this, _cache).delete(key);
1433
- }
1434
- };
1435
- _setCacheRecord = new WeakSet();
1436
- setCacheRecord_fn = async function(record) {
1437
- if (!__privateGet$4(this, _cache).cacheRecords)
1438
- return;
1439
- await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1440
- };
1441
- _getCacheRecord = new WeakSet();
1442
- getCacheRecord_fn = async function(recordId) {
1443
- if (!__privateGet$4(this, _cache).cacheRecords)
1444
- return null;
1445
- return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1446
- };
1447
1616
  _setCacheQuery = new WeakSet();
1448
1617
  setCacheQuery_fn = async function(query, meta, records) {
1449
1618
  await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
@@ -1460,17 +1629,17 @@ getCacheQuery_fn = async function(query) {
1460
1629
  const hasExpired = result.date.getTime() + ttl < Date.now();
1461
1630
  return hasExpired ? null : result;
1462
1631
  };
1463
- _getSchema$1 = new WeakSet();
1464
- getSchema_fn$1 = async function() {
1465
- if (__privateGet$4(this, _schema$1))
1466
- return __privateGet$4(this, _schema$1);
1632
+ _getSchemaTables$1 = new WeakSet();
1633
+ getSchemaTables_fn$1 = async function() {
1634
+ if (__privateGet$4(this, _schemaTables$2))
1635
+ return __privateGet$4(this, _schemaTables$2);
1467
1636
  const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1468
1637
  const { schema } = await getBranchDetails({
1469
1638
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1470
1639
  ...fetchProps
1471
1640
  });
1472
- __privateSet$3(this, _schema$1, schema);
1473
- return schema;
1641
+ __privateSet$4(this, _schemaTables$2, schema.tables);
1642
+ return schema.tables;
1474
1643
  };
1475
1644
  const transformObjectLinks = (object) => {
1476
1645
  return Object.entries(object).reduce((acc, [key, value]) => {
@@ -1479,20 +1648,21 @@ const transformObjectLinks = (object) => {
1479
1648
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1480
1649
  }, {});
1481
1650
  };
1482
- const initObject = (db, schema, table, object) => {
1651
+ const initObject = (db, schemaTables, table, object) => {
1483
1652
  const result = {};
1484
- Object.assign(result, object);
1485
- const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
1653
+ const { xata, ...rest } = object ?? {};
1654
+ Object.assign(result, rest);
1655
+ const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
1486
1656
  if (!columns)
1487
1657
  console.error(`Table ${table} not found in schema`);
1488
1658
  for (const column of columns ?? []) {
1489
1659
  const value = result[column.name];
1490
1660
  switch (column.type) {
1491
1661
  case "datetime": {
1492
- const date = new Date(value);
1493
- if (isNaN(date.getTime())) {
1662
+ const date = value !== void 0 ? new Date(value) : void 0;
1663
+ if (date && isNaN(date.getTime())) {
1494
1664
  console.error(`Failed to parse date ${value} for field ${column.name}`);
1495
- } else {
1665
+ } else if (date) {
1496
1666
  result[column.name] = date;
1497
1667
  }
1498
1668
  break;
@@ -1501,36 +1671,33 @@ const initObject = (db, schema, table, object) => {
1501
1671
  const linkTable = column.link?.table;
1502
1672
  if (!linkTable) {
1503
1673
  console.error(`Failed to parse link for field ${column.name}`);
1504
- } else if (value && isObject(value)) {
1505
- result[column.name] = initObject(db, schema, linkTable, value);
1674
+ } else if (isObject(value)) {
1675
+ result[column.name] = initObject(db, schemaTables, linkTable, value);
1506
1676
  }
1507
1677
  break;
1508
1678
  }
1509
1679
  }
1510
1680
  }
1511
- result.read = function() {
1512
- return db[table].read(result["id"]);
1681
+ result.read = function(columns2) {
1682
+ return db[table].read(result["id"], columns2);
1513
1683
  };
1514
- result.update = function(data) {
1515
- return db[table].update(result["id"], data);
1684
+ result.update = function(data, columns2) {
1685
+ return db[table].update(result["id"], data, columns2);
1516
1686
  };
1517
1687
  result.delete = function() {
1518
1688
  return db[table].delete(result["id"]);
1519
1689
  };
1520
- for (const prop of ["read", "update", "delete"]) {
1690
+ result.getMetadata = function() {
1691
+ return xata;
1692
+ };
1693
+ for (const prop of ["read", "update", "delete", "getMetadata"]) {
1521
1694
  Object.defineProperty(result, prop, { enumerable: false });
1522
1695
  }
1523
1696
  Object.freeze(result);
1524
1697
  return result;
1525
1698
  };
1526
- function getIds(value) {
1527
- if (Array.isArray(value)) {
1528
- return value.map((item) => getIds(item)).flat();
1529
- }
1530
- if (!isObject(value))
1531
- return [];
1532
- const nestedIds = Object.values(value).map((item) => getIds(item)).flat();
1533
- return isString(value.id) ? [value.id, ...nestedIds] : nestedIds;
1699
+ function isResponseWithRecords(value) {
1700
+ return isObject(value) && Array.isArray(value.records);
1534
1701
  }
1535
1702
 
1536
1703
  var __accessCheck$3 = (obj, member, msg) => {
@@ -1546,7 +1713,7 @@ var __privateAdd$3 = (obj, member, value) => {
1546
1713
  throw TypeError("Cannot add the same private member more than once");
1547
1714
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1548
1715
  };
1549
- var __privateSet$2 = (obj, member, value, setter) => {
1716
+ var __privateSet$3 = (obj, member, value, setter) => {
1550
1717
  __accessCheck$3(obj, member, "write to private field");
1551
1718
  setter ? setter.call(obj, value) : member.set(obj, value);
1552
1719
  return value;
@@ -1555,9 +1722,8 @@ var _map;
1555
1722
  class SimpleCache {
1556
1723
  constructor(options = {}) {
1557
1724
  __privateAdd$3(this, _map, void 0);
1558
- __privateSet$2(this, _map, /* @__PURE__ */ new Map());
1725
+ __privateSet$3(this, _map, /* @__PURE__ */ new Map());
1559
1726
  this.capacity = options.max ?? 500;
1560
- this.cacheRecords = options.cacheRecords ?? true;
1561
1727
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1562
1728
  }
1563
1729
  async getAll() {
@@ -1615,31 +1781,42 @@ var __privateAdd$2 = (obj, member, value) => {
1615
1781
  throw TypeError("Cannot add the same private member more than once");
1616
1782
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1617
1783
  };
1618
- var _tables;
1784
+ var __privateSet$2 = (obj, member, value, setter) => {
1785
+ __accessCheck$2(obj, member, "write to private field");
1786
+ setter ? setter.call(obj, value) : member.set(obj, value);
1787
+ return value;
1788
+ };
1789
+ var _tables, _schemaTables$1;
1619
1790
  class SchemaPlugin extends XataPlugin {
1620
- constructor(tableNames) {
1791
+ constructor(schemaTables) {
1621
1792
  super();
1622
- this.tableNames = tableNames;
1623
1793
  __privateAdd$2(this, _tables, {});
1794
+ __privateAdd$2(this, _schemaTables$1, void 0);
1795
+ __privateSet$2(this, _schemaTables$1, schemaTables);
1624
1796
  }
1625
1797
  build(pluginOptions) {
1626
- const db = new Proxy({}, {
1627
- get: (_target, table) => {
1628
- if (!isString(table))
1629
- throw new Error("Invalid table name");
1630
- if (!__privateGet$2(this, _tables)[table]) {
1631
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
1798
+ const db = new Proxy(
1799
+ {},
1800
+ {
1801
+ get: (_target, table) => {
1802
+ if (!isString(table))
1803
+ throw new Error("Invalid table name");
1804
+ if (__privateGet$2(this, _tables)[table] === void 0) {
1805
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1806
+ }
1807
+ return __privateGet$2(this, _tables)[table];
1632
1808
  }
1633
- return __privateGet$2(this, _tables)[table];
1634
1809
  }
1635
- });
1636
- for (const table of this.tableNames ?? []) {
1637
- db[table] = new RestRepository({ db, pluginOptions, table });
1810
+ );
1811
+ const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
1812
+ for (const table of tableNames) {
1813
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
1638
1814
  }
1639
1815
  return db;
1640
1816
  }
1641
1817
  }
1642
1818
  _tables = new WeakMap();
1819
+ _schemaTables$1 = new WeakMap();
1643
1820
 
1644
1821
  var __accessCheck$1 = (obj, member, msg) => {
1645
1822
  if (!member.has(obj))
@@ -1663,105 +1840,118 @@ var __privateMethod$1 = (obj, member, method) => {
1663
1840
  __accessCheck$1(obj, member, "access private method");
1664
1841
  return method;
1665
1842
  };
1666
- var _schema, _search, search_fn, _getSchema, getSchema_fn;
1843
+ var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
1667
1844
  class SearchPlugin extends XataPlugin {
1668
- constructor(db) {
1845
+ constructor(db, schemaTables) {
1669
1846
  super();
1670
1847
  this.db = db;
1671
1848
  __privateAdd$1(this, _search);
1672
- __privateAdd$1(this, _getSchema);
1673
- __privateAdd$1(this, _schema, void 0);
1849
+ __privateAdd$1(this, _getSchemaTables);
1850
+ __privateAdd$1(this, _schemaTables, void 0);
1851
+ __privateSet$1(this, _schemaTables, schemaTables);
1674
1852
  }
1675
1853
  build({ getFetchProps }) {
1676
1854
  return {
1677
1855
  all: async (query, options = {}) => {
1678
1856
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1679
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1857
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1680
1858
  return records.map((record) => {
1681
1859
  const { table = "orphan" } = record.xata;
1682
- return { table, record: initObject(this.db, schema, table, record) };
1860
+ return { table, record: initObject(this.db, schemaTables, table, record) };
1683
1861
  });
1684
1862
  },
1685
1863
  byTable: async (query, options = {}) => {
1686
1864
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1687
- const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1865
+ const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, getFetchProps);
1688
1866
  return records.reduce((acc, record) => {
1689
1867
  const { table = "orphan" } = record.xata;
1690
1868
  const items = acc[table] ?? [];
1691
- const item = initObject(this.db, schema, table, record);
1869
+ const item = initObject(this.db, schemaTables, table, record);
1692
1870
  return { ...acc, [table]: [...items, item] };
1693
1871
  }, {});
1694
1872
  }
1695
1873
  };
1696
1874
  }
1697
1875
  }
1698
- _schema = new WeakMap();
1876
+ _schemaTables = new WeakMap();
1699
1877
  _search = new WeakSet();
1700
1878
  search_fn = async function(query, options, getFetchProps) {
1701
1879
  const fetchProps = await getFetchProps();
1702
- const { tables, fuzziness } = options ?? {};
1880
+ const { tables, fuzziness, highlight, prefix } = options ?? {};
1703
1881
  const { records } = await searchBranch({
1704
1882
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1705
- body: { tables, query, fuzziness },
1883
+ body: { tables, query, fuzziness, prefix, highlight },
1706
1884
  ...fetchProps
1707
1885
  });
1708
1886
  return records;
1709
1887
  };
1710
- _getSchema = new WeakSet();
1711
- getSchema_fn = async function(getFetchProps) {
1712
- if (__privateGet$1(this, _schema))
1713
- return __privateGet$1(this, _schema);
1888
+ _getSchemaTables = new WeakSet();
1889
+ getSchemaTables_fn = async function(getFetchProps) {
1890
+ if (__privateGet$1(this, _schemaTables))
1891
+ return __privateGet$1(this, _schemaTables);
1714
1892
  const fetchProps = await getFetchProps();
1715
1893
  const { schema } = await getBranchDetails({
1716
1894
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1717
1895
  ...fetchProps
1718
1896
  });
1719
- __privateSet$1(this, _schema, schema);
1720
- return schema;
1897
+ __privateSet$1(this, _schemaTables, schema.tables);
1898
+ return schema.tables;
1721
1899
  };
1722
1900
 
1723
1901
  const isBranchStrategyBuilder = (strategy) => {
1724
1902
  return typeof strategy === "function";
1725
1903
  };
1726
1904
 
1727
- const envBranchNames = [
1728
- "XATA_BRANCH",
1729
- "VERCEL_GIT_COMMIT_REF",
1730
- "CF_PAGES_BRANCH",
1731
- "BRANCH"
1732
- ];
1733
- const defaultBranch = "main";
1734
1905
  async function getCurrentBranchName(options) {
1735
- const env = getBranchByEnvVariable();
1736
- if (env)
1737
- return env;
1738
- const branch = await getGitBranch();
1739
- if (!branch)
1740
- return void 0;
1741
- const details = await getDatabaseBranch(branch, options);
1742
- if (details)
1743
- return branch;
1744
- return void 0;
1906
+ const { branch, envBranch } = getEnvironment();
1907
+ if (branch) {
1908
+ const details = await getDatabaseBranch(branch, options);
1909
+ if (details)
1910
+ return branch;
1911
+ console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
1912
+ }
1913
+ const gitBranch = envBranch || await getGitBranch();
1914
+ return resolveXataBranch(gitBranch, options);
1745
1915
  }
1746
1916
  async function getCurrentBranchDetails(options) {
1747
- const env = getBranchByEnvVariable();
1748
- if (env)
1749
- return getDatabaseBranch(env, options);
1750
- const branch = await getGitBranch();
1751
- if (!branch)
1752
- return getDatabaseBranch(defaultBranch, options);
1753
- const details = await getDatabaseBranch(branch, options);
1754
- if (details)
1755
- return details;
1756
- return getDatabaseBranch(defaultBranch, options);
1917
+ const branch = await getCurrentBranchName(options);
1918
+ return getDatabaseBranch(branch, options);
1919
+ }
1920
+ async function resolveXataBranch(gitBranch, options) {
1921
+ const databaseURL = options?.databaseURL || getDatabaseURL();
1922
+ const apiKey = options?.apiKey || getAPIKey();
1923
+ if (!databaseURL)
1924
+ throw new Error(
1925
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
1926
+ );
1927
+ if (!apiKey)
1928
+ throw new Error(
1929
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1930
+ );
1931
+ const [protocol, , host, , dbName] = databaseURL.split("/");
1932
+ const [workspace] = host.split(".");
1933
+ const { fallbackBranch } = getEnvironment();
1934
+ const { branch } = await resolveBranch({
1935
+ apiKey,
1936
+ apiUrl: databaseURL,
1937
+ fetchImpl: getFetchImplementation(options?.fetchImpl),
1938
+ workspacesApiUrl: `${protocol}//${host}`,
1939
+ pathParams: { dbName, workspace },
1940
+ queryParams: { gitBranch, fallbackBranch }
1941
+ });
1942
+ return branch;
1757
1943
  }
1758
1944
  async function getDatabaseBranch(branch, options) {
1759
1945
  const databaseURL = options?.databaseURL || getDatabaseURL();
1760
1946
  const apiKey = options?.apiKey || getAPIKey();
1761
1947
  if (!databaseURL)
1762
- throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
1948
+ throw new Error(
1949
+ "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
1950
+ );
1763
1951
  if (!apiKey)
1764
- throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
1952
+ throw new Error(
1953
+ "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
1954
+ );
1765
1955
  const [protocol, , host, , database] = databaseURL.split("/");
1766
1956
  const [workspace] = host.split(".");
1767
1957
  const dbBranchName = `${database}:${branch}`;
@@ -1771,10 +1961,7 @@ async function getDatabaseBranch(branch, options) {
1771
1961
  apiUrl: databaseURL,
1772
1962
  fetchImpl: getFetchImplementation(options?.fetchImpl),
1773
1963
  workspacesApiUrl: `${protocol}//${host}`,
1774
- pathParams: {
1775
- dbBranchName,
1776
- workspace
1777
- }
1964
+ pathParams: { dbBranchName, workspace }
1778
1965
  });
1779
1966
  } catch (err) {
1780
1967
  if (isObject(err) && err.status === 404)
@@ -1782,21 +1969,10 @@ async function getDatabaseBranch(branch, options) {
1782
1969
  throw err;
1783
1970
  }
1784
1971
  }
1785
- function getBranchByEnvVariable() {
1786
- for (const name of envBranchNames) {
1787
- const value = getEnvVariable(name);
1788
- if (value) {
1789
- return value;
1790
- }
1791
- }
1792
- try {
1793
- return XATA_BRANCH;
1794
- } catch (err) {
1795
- }
1796
- }
1797
1972
  function getDatabaseURL() {
1798
1973
  try {
1799
- return getEnvVariable("XATA_DATABASE_URL") ?? XATA_DATABASE_URL;
1974
+ const { databaseURL } = getEnvironment();
1975
+ return databaseURL;
1800
1976
  } catch (err) {
1801
1977
  return void 0;
1802
1978
  }
@@ -1827,7 +2003,7 @@ var __privateMethod = (obj, member, method) => {
1827
2003
  const buildClient = (plugins) => {
1828
2004
  var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1829
2005
  return _a = class {
1830
- constructor(options = {}, tables) {
2006
+ constructor(options = {}, schemaTables) {
1831
2007
  __privateAdd(this, _parseOptions);
1832
2008
  __privateAdd(this, _getFetchProps);
1833
2009
  __privateAdd(this, _evaluateBranch);
@@ -1837,12 +2013,12 @@ const buildClient = (plugins) => {
1837
2013
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1838
2014
  cache: safeOptions.cache
1839
2015
  };
1840
- const db = new SchemaPlugin(tables).build(pluginOptions);
1841
- const search = new SearchPlugin(db).build(pluginOptions);
2016
+ const db = new SchemaPlugin(schemaTables).build(pluginOptions);
2017
+ const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
1842
2018
  this.db = db;
1843
2019
  this.search = search;
1844
2020
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
1845
- if (!namespace)
2021
+ if (namespace === void 0)
1846
2022
  continue;
1847
2023
  const result = namespace.build(pluginOptions);
1848
2024
  if (result instanceof Promise) {
@@ -1858,8 +2034,8 @@ const buildClient = (plugins) => {
1858
2034
  const fetch = getFetchImplementation(options?.fetch);
1859
2035
  const databaseURL = options?.databaseURL || getDatabaseURL();
1860
2036
  const apiKey = options?.apiKey || getAPIKey();
1861
- const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
1862
- const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch }) ?? defaultBranch;
2037
+ const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
2038
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1863
2039
  if (!databaseURL || !apiKey) {
1864
2040
  throw new Error("Options databaseURL and apiKey are required");
1865
2041
  }
@@ -1886,7 +2062,7 @@ const buildClient = (plugins) => {
1886
2062
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
1887
2063
  if (__privateGet(this, _branch))
1888
2064
  return __privateGet(this, _branch);
1889
- if (!param)
2065
+ if (param === void 0)
1890
2066
  return void 0;
1891
2067
  const strategies = Array.isArray(param) ? [...param] : [param];
1892
2068
  const evaluateBranch = async (strategy) => {
@@ -1919,6 +2095,7 @@ exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
1919
2095
  exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
1920
2096
  exports.Page = Page;
1921
2097
  exports.Query = Query;
2098
+ exports.RecordArray = RecordArray;
1922
2099
  exports.Repository = Repository;
1923
2100
  exports.RestRepository = RestRepository;
1924
2101
  exports.SchemaPlugin = SchemaPlugin;
@@ -1940,7 +2117,6 @@ exports.createDatabase = createDatabase;
1940
2117
  exports.createTable = createTable;
1941
2118
  exports.createUserAPIKey = createUserAPIKey;
1942
2119
  exports.createWorkspace = createWorkspace;
1943
- exports.defaultBranch = defaultBranch;
1944
2120
  exports.deleteBranch = deleteBranch;
1945
2121
  exports.deleteColumn = deleteColumn;
1946
2122
  exports.deleteDatabase = deleteDatabase;
@@ -1964,6 +2140,7 @@ exports.getColumn = getColumn;
1964
2140
  exports.getCurrentBranchDetails = getCurrentBranchDetails;
1965
2141
  exports.getCurrentBranchName = getCurrentBranchName;
1966
2142
  exports.getDatabaseList = getDatabaseList;
2143
+ exports.getDatabaseMetadata = getDatabaseMetadata;
1967
2144
  exports.getDatabaseURL = getDatabaseURL;
1968
2145
  exports.getGitBranchesMapping = getGitBranchesMapping;
1969
2146
  exports.getRecord = getRecord;
@@ -1984,6 +2161,7 @@ exports.insertRecord = insertRecord;
1984
2161
  exports.insertRecordWithID = insertRecordWithID;
1985
2162
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
1986
2163
  exports.is = is;
2164
+ exports.isCursorPaginationOptions = isCursorPaginationOptions;
1987
2165
  exports.isIdentifiable = isIdentifiable;
1988
2166
  exports.isNot = isNot;
1989
2167
  exports.isXataRecord = isXataRecord;
@@ -1999,6 +2177,7 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
1999
2177
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
2000
2178
  exports.resolveBranch = resolveBranch;
2001
2179
  exports.searchBranch = searchBranch;
2180
+ exports.searchTable = searchTable;
2002
2181
  exports.setTableSchema = setTableSchema;
2003
2182
  exports.startsWith = startsWith;
2004
2183
  exports.updateBranchMetadata = updateBranchMetadata;
@@ -2007,6 +2186,7 @@ exports.updateRecordWithID = updateRecordWithID;
2007
2186
  exports.updateTable = updateTable;
2008
2187
  exports.updateUser = updateUser;
2009
2188
  exports.updateWorkspace = updateWorkspace;
2189
+ exports.updateWorkspaceMemberInvite = updateWorkspaceMemberInvite;
2010
2190
  exports.updateWorkspaceMemberRole = updateWorkspaceMemberRole;
2011
2191
  exports.upsertRecordWithID = upsertRecordWithID;
2012
2192
  //# sourceMappingURL=index.cjs.map