@xata.io/client 0.0.0-alpha.vf3ab3ad → 0.0.0-alpha.vf455e66cda21d00ed37168f3b02730a799f48650

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
@@ -246,7 +246,7 @@ var __accessCheck$8 = (obj, member, msg) => {
246
246
  if (!member.has(obj))
247
247
  throw TypeError("Cannot " + msg);
248
248
  };
249
- var __privateGet$8 = (obj, member, getter) => {
249
+ var __privateGet$7 = (obj, member, getter) => {
250
250
  __accessCheck$8(obj, member, "read from private field");
251
251
  return getter ? getter.call(obj) : member.get(obj);
252
252
  };
@@ -255,7 +255,7 @@ var __privateAdd$8 = (obj, member, value) => {
255
255
  throw TypeError("Cannot add the same private member more than once");
256
256
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
257
257
  };
258
- var __privateSet$8 = (obj, member, value, setter) => {
258
+ var __privateSet$6 = (obj, member, value, setter) => {
259
259
  __accessCheck$8(obj, member, "write to private field");
260
260
  setter ? setter.call(obj, value) : member.set(obj, value);
261
261
  return value;
@@ -281,19 +281,19 @@ class ApiRequestPool {
281
281
  __privateAdd$8(this, _fetch, void 0);
282
282
  __privateAdd$8(this, _queue, void 0);
283
283
  __privateAdd$8(this, _concurrency, void 0);
284
- __privateSet$8(this, _queue, []);
285
- __privateSet$8(this, _concurrency, concurrency);
284
+ __privateSet$6(this, _queue, []);
285
+ __privateSet$6(this, _concurrency, concurrency);
286
286
  this.running = 0;
287
287
  this.started = 0;
288
288
  }
289
289
  setFetch(fetch2) {
290
- __privateSet$8(this, _fetch, fetch2);
290
+ __privateSet$6(this, _fetch, fetch2);
291
291
  }
292
292
  getFetch() {
293
- if (!__privateGet$8(this, _fetch)) {
293
+ if (!__privateGet$7(this, _fetch)) {
294
294
  throw new Error("Fetch not set");
295
295
  }
296
- return __privateGet$8(this, _fetch);
296
+ return __privateGet$7(this, _fetch);
297
297
  }
298
298
  request(url, options) {
299
299
  const start = /* @__PURE__ */ new Date();
@@ -325,19 +325,19 @@ _queue = new WeakMap();
325
325
  _concurrency = new WeakMap();
326
326
  _enqueue = new WeakSet();
327
327
  enqueue_fn = function(task) {
328
- const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
328
+ const promise = new Promise((resolve) => __privateGet$7(this, _queue).push(resolve)).finally(() => {
329
329
  this.started--;
330
330
  this.running++;
331
331
  }).then(() => task()).finally(() => {
332
332
  this.running--;
333
- const next = __privateGet$8(this, _queue).shift();
333
+ const next = __privateGet$7(this, _queue).shift();
334
334
  if (next !== void 0) {
335
335
  this.started++;
336
336
  next();
337
337
  }
338
338
  });
339
- if (this.running + this.started < __privateGet$8(this, _concurrency)) {
340
- const next = __privateGet$8(this, _queue).shift();
339
+ if (this.running + this.started < __privateGet$7(this, _concurrency)) {
340
+ const next = __privateGet$7(this, _queue).shift();
341
341
  if (next !== void 0) {
342
342
  this.started++;
343
343
  next();
@@ -526,7 +526,7 @@ function defaultOnOpen(response) {
526
526
  }
527
527
  }
528
528
 
529
- const VERSION = "0.28.0";
529
+ const VERSION = "0.29.3";
530
530
 
531
531
  class ErrorWithCause extends Error {
532
532
  constructor(message, options) {
@@ -569,6 +569,67 @@ function getMessage(data) {
569
569
  }
570
570
  }
571
571
 
572
+ function getHostUrl(provider, type) {
573
+ if (isHostProviderAlias(provider)) {
574
+ return providers[provider][type];
575
+ } else if (isHostProviderBuilder(provider)) {
576
+ return provider[type];
577
+ }
578
+ throw new Error("Invalid API provider");
579
+ }
580
+ const providers = {
581
+ production: {
582
+ main: "https://api.xata.io",
583
+ workspaces: "https://{workspaceId}.{region}.xata.sh"
584
+ },
585
+ staging: {
586
+ main: "https://api.staging-xata.dev",
587
+ workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
588
+ },
589
+ dev: {
590
+ main: "https://api.dev-xata.dev",
591
+ workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
592
+ },
593
+ local: {
594
+ main: "http://localhost:6001",
595
+ workspaces: "http://{workspaceId}.{region}.localhost:6001"
596
+ }
597
+ };
598
+ function isHostProviderAlias(alias) {
599
+ return isString(alias) && Object.keys(providers).includes(alias);
600
+ }
601
+ function isHostProviderBuilder(builder) {
602
+ return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
603
+ }
604
+ function parseProviderString(provider = "production") {
605
+ if (isHostProviderAlias(provider)) {
606
+ return provider;
607
+ }
608
+ const [main, workspaces] = provider.split(",");
609
+ if (!main || !workspaces)
610
+ return null;
611
+ return { main, workspaces };
612
+ }
613
+ function buildProviderString(provider) {
614
+ if (isHostProviderAlias(provider))
615
+ return provider;
616
+ return `${provider.main},${provider.workspaces}`;
617
+ }
618
+ function parseWorkspacesUrlParts(url) {
619
+ if (!isString(url))
620
+ return null;
621
+ const matches = {
622
+ production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh\/db\/([^:]+):?(.*)?/),
623
+ staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev\/db\/([^:]+):?(.*)?/),
624
+ dev: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev\/db\/([^:]+):?(.*)?/),
625
+ local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:([^:]+):?(.*)?/)
626
+ };
627
+ const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
628
+ if (!isHostProviderAlias(host) || !match)
629
+ return null;
630
+ return { workspace: match[1], region: match[2], database: match[3], branch: match[4], host };
631
+ }
632
+
572
633
  const pool = new ApiRequestPool();
573
634
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
574
635
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
@@ -584,6 +645,7 @@ const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
584
645
  return url.replace(/\{\w*\}/g, (key) => cleanPathParams[key.slice(1, -1)]) + queryString;
585
646
  };
586
647
  function buildBaseUrl({
648
+ method,
587
649
  endpoint,
588
650
  path,
589
651
  workspacesApiUrl,
@@ -591,7 +653,24 @@ function buildBaseUrl({
591
653
  pathParams = {}
592
654
  }) {
593
655
  if (endpoint === "dataPlane") {
594
- const url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
656
+ let url = isString(workspacesApiUrl) ? `${workspacesApiUrl}${path}` : workspacesApiUrl(path, pathParams);
657
+ if (method.toUpperCase() === "PUT" && [
658
+ "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file",
659
+ "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}"
660
+ ].includes(path)) {
661
+ const { host } = parseWorkspacesUrlParts(url) ?? {};
662
+ switch (host) {
663
+ case "production":
664
+ url = url.replace("xata.sh", "upload.xata.sh");
665
+ break;
666
+ case "staging":
667
+ url = url.replace("staging-xata.dev", "upload.staging-xata.dev");
668
+ break;
669
+ case "dev":
670
+ url = url.replace("dev-xata.dev", "upload.dev-xata.dev");
671
+ break;
672
+ }
673
+ }
595
674
  const urlWithWorkspace = isString(pathParams.workspace) ? url.replace("{workspaceId}", String(pathParams.workspace)) : url;
596
675
  return isString(pathParams.region) ? urlWithWorkspace.replace("{region}", String(pathParams.region)) : urlWithWorkspace;
597
676
  }
@@ -640,9 +719,9 @@ async function fetch$1({
640
719
  return await trace(
641
720
  `${method.toUpperCase()} ${path}`,
642
721
  async ({ setAttributes }) => {
643
- const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
722
+ const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
644
723
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
645
- const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
724
+ const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\.[^.]+\./, "http://") : fullUrl;
646
725
  setAttributes({
647
726
  [TraceAttributes.HTTP_URL]: url,
648
727
  [TraceAttributes.HTTP_TARGET]: resolveUrl(path, queryParams, pathParams)
@@ -723,7 +802,7 @@ function fetchSSERequest({
723
802
  clientName,
724
803
  xataAgentExtra
725
804
  }) {
726
- const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
805
+ const baseUrl = buildBaseUrl({ method, endpoint, path, workspacesApiUrl, pathParams, apiUrl });
727
806
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
728
807
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
729
808
  void fetchEventSource(url, {
@@ -766,19 +845,35 @@ function parseUrl(url) {
766
845
 
767
846
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
768
847
 
769
- const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
770
- const pgRollStatus = (variables, signal) => dataPlaneFetch({
771
- url: "/db/{dbBranchName}/pgroll/status",
772
- method: "get",
848
+ const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/apply", method: "post", ...variables, signal });
849
+ const adaptTable = (variables, signal) => dataPlaneFetch({
850
+ url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
851
+ method: "post",
852
+ ...variables,
853
+ signal
854
+ });
855
+ const adaptAllTables = (variables, signal) => dataPlaneFetch({
856
+ url: "/db/{dbBranchName}/migrations/adapt",
857
+ method: "post",
773
858
  ...variables,
774
859
  signal
775
860
  });
861
+ const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/status", method: "get", ...variables, signal });
862
+ const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/jobs/{jobId}", method: "get", ...variables, signal });
863
+ const getMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/history", method: "get", ...variables, signal });
776
864
  const getBranchList = (variables, signal) => dataPlaneFetch({
777
865
  url: "/dbs/{dbName}",
778
866
  method: "get",
779
867
  ...variables,
780
868
  signal
781
869
  });
870
+ const getDatabaseSettings = (variables, signal) => dataPlaneFetch({
871
+ url: "/dbs/{dbName}/settings",
872
+ method: "get",
873
+ ...variables,
874
+ signal
875
+ });
876
+ const updateDatabaseSettings = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/settings", method: "patch", ...variables, signal });
782
877
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
783
878
  url: "/db/{dbBranchName}",
784
879
  method: "get",
@@ -979,6 +1074,12 @@ const fileAccess = (variables, signal) => dataPlaneFetch({
979
1074
  ...variables,
980
1075
  signal
981
1076
  });
1077
+ const fileUpload = (variables, signal) => dataPlaneFetch({
1078
+ url: "/file/{fileId}",
1079
+ method: "put",
1080
+ ...variables,
1081
+ signal
1082
+ });
982
1083
  const sqlQuery = (variables, signal) => dataPlaneFetch({
983
1084
  url: "/db/{dbBranchName}/sql",
984
1085
  method: "post",
@@ -986,9 +1087,26 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
986
1087
  signal
987
1088
  });
988
1089
  const operationsByTag$2 = {
989
- branch: {
1090
+ migrations: {
990
1091
  applyMigration,
991
- pgRollStatus,
1092
+ adaptTable,
1093
+ adaptAllTables,
1094
+ getBranchMigrationJobStatus,
1095
+ getMigrationJobStatus,
1096
+ getMigrationHistory,
1097
+ getSchema,
1098
+ getBranchMigrationHistory,
1099
+ getBranchMigrationPlan,
1100
+ executeBranchMigrationPlan,
1101
+ getBranchSchemaHistory,
1102
+ compareBranchWithUserSchema,
1103
+ compareBranchSchemas,
1104
+ updateBranchSchema,
1105
+ previewBranchSchemaEdit,
1106
+ applyBranchSchemaEdit,
1107
+ pushBranchMigrations
1108
+ },
1109
+ branch: {
992
1110
  getBranchList,
993
1111
  getBranchDetails,
994
1112
  createBranch,
@@ -1002,19 +1120,7 @@ const operationsByTag$2 = {
1002
1120
  removeGitBranchesEntry,
1003
1121
  resolveBranch
1004
1122
  },
1005
- migrations: {
1006
- getSchema,
1007
- getBranchMigrationHistory,
1008
- getBranchMigrationPlan,
1009
- executeBranchMigrationPlan,
1010
- getBranchSchemaHistory,
1011
- compareBranchWithUserSchema,
1012
- compareBranchSchemas,
1013
- updateBranchSchema,
1014
- previewBranchSchemaEdit,
1015
- applyBranchSchemaEdit,
1016
- pushBranchMigrations
1017
- },
1123
+ database: { getDatabaseSettings, updateDatabaseSettings },
1018
1124
  migrationRequests: {
1019
1125
  queryMigrationRequests,
1020
1126
  createMigrationRequest,
@@ -1047,7 +1153,7 @@ const operationsByTag$2 = {
1047
1153
  deleteRecord,
1048
1154
  bulkInsertTableRecords
1049
1155
  },
1050
- files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess },
1156
+ files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
1051
1157
  searchAndFilter: {
1052
1158
  queryTable,
1053
1159
  searchBranch,
@@ -1156,6 +1262,8 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
1156
1262
  ...variables,
1157
1263
  signal
1158
1264
  });
1265
+ const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "get", ...variables, signal });
1266
+ const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "patch", ...variables, signal });
1159
1267
  const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
1160
1268
  const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
1161
1269
  const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
@@ -1169,12 +1277,7 @@ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ u
1169
1277
  const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
1170
1278
  const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
1171
1279
  const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
1172
- const listClusters = (variables, signal) => controlPlaneFetch({
1173
- url: "/workspaces/{workspaceId}/clusters",
1174
- method: "get",
1175
- ...variables,
1176
- signal
1177
- });
1280
+ const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
1178
1281
  const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
1179
1282
  const getCluster = (variables, signal) => controlPlaneFetch({
1180
1283
  url: "/workspaces/{workspaceId}/clusters/{clusterId}",
@@ -1226,6 +1329,8 @@ const operationsByTag$1 = {
1226
1329
  getWorkspace,
1227
1330
  updateWorkspace,
1228
1331
  deleteWorkspace,
1332
+ getWorkspaceSettings,
1333
+ updateWorkspaceSettings,
1229
1334
  getWorkspaceMembersList,
1230
1335
  updateWorkspaceMemberRole,
1231
1336
  removeWorkspaceMember
@@ -1254,66 +1359,11 @@ const operationsByTag$1 = {
1254
1359
 
1255
1360
  const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
1256
1361
 
1257
- function getHostUrl(provider, type) {
1258
- if (isHostProviderAlias(provider)) {
1259
- return providers[provider][type];
1260
- } else if (isHostProviderBuilder(provider)) {
1261
- return provider[type];
1262
- }
1263
- throw new Error("Invalid API provider");
1264
- }
1265
- const providers = {
1266
- production: {
1267
- main: "https://api.xata.io",
1268
- workspaces: "https://{workspaceId}.{region}.xata.sh"
1269
- },
1270
- staging: {
1271
- main: "https://api.staging-xata.dev",
1272
- workspaces: "https://{workspaceId}.{region}.staging-xata.dev"
1273
- },
1274
- dev: {
1275
- main: "https://api.dev-xata.dev",
1276
- workspaces: "https://{workspaceId}.{region}.dev-xata.dev"
1277
- }
1278
- };
1279
- function isHostProviderAlias(alias) {
1280
- return isString(alias) && Object.keys(providers).includes(alias);
1281
- }
1282
- function isHostProviderBuilder(builder) {
1283
- return isObject(builder) && isString(builder.main) && isString(builder.workspaces);
1284
- }
1285
- function parseProviderString(provider = "production") {
1286
- if (isHostProviderAlias(provider)) {
1287
- return provider;
1288
- }
1289
- const [main, workspaces] = provider.split(",");
1290
- if (!main || !workspaces)
1291
- return null;
1292
- return { main, workspaces };
1293
- }
1294
- function buildProviderString(provider) {
1295
- if (isHostProviderAlias(provider))
1296
- return provider;
1297
- return `${provider.main},${provider.workspaces}`;
1298
- }
1299
- function parseWorkspacesUrlParts(url) {
1300
- if (!isString(url))
1301
- return null;
1302
- const regex = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh.*/;
1303
- const regexDev = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.dev-xata\.dev.*/;
1304
- const regexStaging = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev.*/;
1305
- const regexProdTesting = /(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.tech.*/;
1306
- const match = url.match(regex) || url.match(regexDev) || url.match(regexStaging) || url.match(regexProdTesting);
1307
- if (!match)
1308
- return null;
1309
- return { workspace: match[1], region: match[2] };
1310
- }
1311
-
1312
1362
  var __accessCheck$7 = (obj, member, msg) => {
1313
1363
  if (!member.has(obj))
1314
1364
  throw TypeError("Cannot " + msg);
1315
1365
  };
1316
- var __privateGet$7 = (obj, member, getter) => {
1366
+ var __privateGet$6 = (obj, member, getter) => {
1317
1367
  __accessCheck$7(obj, member, "read from private field");
1318
1368
  return getter ? getter.call(obj) : member.get(obj);
1319
1369
  };
@@ -1322,7 +1372,7 @@ var __privateAdd$7 = (obj, member, value) => {
1322
1372
  throw TypeError("Cannot add the same private member more than once");
1323
1373
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1324
1374
  };
1325
- var __privateSet$7 = (obj, member, value, setter) => {
1375
+ var __privateSet$5 = (obj, member, value, setter) => {
1326
1376
  __accessCheck$7(obj, member, "write to private field");
1327
1377
  setter ? setter.call(obj, value) : member.set(obj, value);
1328
1378
  return value;
@@ -1339,7 +1389,7 @@ class XataApiClient {
1339
1389
  if (!apiKey) {
1340
1390
  throw new Error("Could not resolve a valid apiKey");
1341
1391
  }
1342
- __privateSet$7(this, _extraProps, {
1392
+ __privateSet$5(this, _extraProps, {
1343
1393
  apiUrl: getHostUrl(provider, "main"),
1344
1394
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
1345
1395
  fetch: getFetchImplementation(options.fetch),
@@ -1351,64 +1401,64 @@ class XataApiClient {
1351
1401
  });
1352
1402
  }
1353
1403
  get user() {
1354
- if (!__privateGet$7(this, _namespaces).user)
1355
- __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
1356
- return __privateGet$7(this, _namespaces).user;
1404
+ if (!__privateGet$6(this, _namespaces).user)
1405
+ __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
1406
+ return __privateGet$6(this, _namespaces).user;
1357
1407
  }
1358
1408
  get authentication() {
1359
- if (!__privateGet$7(this, _namespaces).authentication)
1360
- __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
1361
- return __privateGet$7(this, _namespaces).authentication;
1409
+ if (!__privateGet$6(this, _namespaces).authentication)
1410
+ __privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
1411
+ return __privateGet$6(this, _namespaces).authentication;
1362
1412
  }
1363
1413
  get workspaces() {
1364
- if (!__privateGet$7(this, _namespaces).workspaces)
1365
- __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
1366
- return __privateGet$7(this, _namespaces).workspaces;
1414
+ if (!__privateGet$6(this, _namespaces).workspaces)
1415
+ __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
1416
+ return __privateGet$6(this, _namespaces).workspaces;
1367
1417
  }
1368
1418
  get invites() {
1369
- if (!__privateGet$7(this, _namespaces).invites)
1370
- __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
1371
- return __privateGet$7(this, _namespaces).invites;
1419
+ if (!__privateGet$6(this, _namespaces).invites)
1420
+ __privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
1421
+ return __privateGet$6(this, _namespaces).invites;
1372
1422
  }
1373
1423
  get database() {
1374
- if (!__privateGet$7(this, _namespaces).database)
1375
- __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
1376
- return __privateGet$7(this, _namespaces).database;
1424
+ if (!__privateGet$6(this, _namespaces).database)
1425
+ __privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
1426
+ return __privateGet$6(this, _namespaces).database;
1377
1427
  }
1378
1428
  get branches() {
1379
- if (!__privateGet$7(this, _namespaces).branches)
1380
- __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
1381
- return __privateGet$7(this, _namespaces).branches;
1429
+ if (!__privateGet$6(this, _namespaces).branches)
1430
+ __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
1431
+ return __privateGet$6(this, _namespaces).branches;
1382
1432
  }
1383
1433
  get migrations() {
1384
- if (!__privateGet$7(this, _namespaces).migrations)
1385
- __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
1386
- return __privateGet$7(this, _namespaces).migrations;
1434
+ if (!__privateGet$6(this, _namespaces).migrations)
1435
+ __privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
1436
+ return __privateGet$6(this, _namespaces).migrations;
1387
1437
  }
1388
1438
  get migrationRequests() {
1389
- if (!__privateGet$7(this, _namespaces).migrationRequests)
1390
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
1391
- return __privateGet$7(this, _namespaces).migrationRequests;
1439
+ if (!__privateGet$6(this, _namespaces).migrationRequests)
1440
+ __privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
1441
+ return __privateGet$6(this, _namespaces).migrationRequests;
1392
1442
  }
1393
1443
  get tables() {
1394
- if (!__privateGet$7(this, _namespaces).tables)
1395
- __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
1396
- return __privateGet$7(this, _namespaces).tables;
1444
+ if (!__privateGet$6(this, _namespaces).tables)
1445
+ __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
1446
+ return __privateGet$6(this, _namespaces).tables;
1397
1447
  }
1398
1448
  get records() {
1399
- if (!__privateGet$7(this, _namespaces).records)
1400
- __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
1401
- return __privateGet$7(this, _namespaces).records;
1449
+ if (!__privateGet$6(this, _namespaces).records)
1450
+ __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
1451
+ return __privateGet$6(this, _namespaces).records;
1402
1452
  }
1403
1453
  get files() {
1404
- if (!__privateGet$7(this, _namespaces).files)
1405
- __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1406
- return __privateGet$7(this, _namespaces).files;
1454
+ if (!__privateGet$6(this, _namespaces).files)
1455
+ __privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
1456
+ return __privateGet$6(this, _namespaces).files;
1407
1457
  }
1408
1458
  get searchAndFilter() {
1409
- if (!__privateGet$7(this, _namespaces).searchAndFilter)
1410
- __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
1411
- return __privateGet$7(this, _namespaces).searchAndFilter;
1459
+ if (!__privateGet$6(this, _namespaces).searchAndFilter)
1460
+ __privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
1461
+ return __privateGet$6(this, _namespaces).searchAndFilter;
1412
1462
  }
1413
1463
  }
1414
1464
  _extraProps = new WeakMap();
@@ -1710,6 +1760,30 @@ class BranchApi {
1710
1760
  ...this.extraProps
1711
1761
  });
1712
1762
  }
1763
+ pgRollMigrationHistory({
1764
+ workspace,
1765
+ region,
1766
+ database,
1767
+ branch
1768
+ }) {
1769
+ return operationsByTag.migrations.getMigrationHistory({
1770
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1771
+ ...this.extraProps
1772
+ });
1773
+ }
1774
+ applyMigration({
1775
+ workspace,
1776
+ region,
1777
+ database,
1778
+ branch,
1779
+ migration
1780
+ }) {
1781
+ return operationsByTag.migrations.applyMigration({
1782
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1783
+ body: migration,
1784
+ ...this.extraProps
1785
+ });
1786
+ }
1713
1787
  }
1714
1788
  class TableApi {
1715
1789
  constructor(extraProps) {
@@ -2523,6 +2597,17 @@ class MigrationsApi {
2523
2597
  ...this.extraProps
2524
2598
  });
2525
2599
  }
2600
+ getSchema({
2601
+ workspace,
2602
+ region,
2603
+ database,
2604
+ branch
2605
+ }) {
2606
+ return operationsByTag.migrations.getSchema({
2607
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2608
+ ...this.extraProps
2609
+ });
2610
+ }
2526
2611
  }
2527
2612
  class DatabaseApi {
2528
2613
  constructor(extraProps) {
@@ -2664,16 +2749,18 @@ function transformImage(url, ...transformations) {
2664
2749
  class XataFile {
2665
2750
  constructor(file) {
2666
2751
  this.id = file.id;
2667
- this.name = file.name || "";
2668
- this.mediaType = file.mediaType || "application/octet-stream";
2752
+ this.name = file.name;
2753
+ this.mediaType = file.mediaType;
2669
2754
  this.base64Content = file.base64Content;
2670
- this.enablePublicUrl = file.enablePublicUrl ?? false;
2671
- this.signedUrlTimeout = file.signedUrlTimeout ?? 300;
2672
- this.size = file.size ?? 0;
2673
- this.version = file.version ?? 1;
2674
- this.url = file.url || "";
2755
+ this.enablePublicUrl = file.enablePublicUrl;
2756
+ this.signedUrlTimeout = file.signedUrlTimeout;
2757
+ this.uploadUrlTimeout = file.uploadUrlTimeout;
2758
+ this.size = file.size;
2759
+ this.version = file.version;
2760
+ this.url = file.url;
2675
2761
  this.signedUrl = file.signedUrl;
2676
- this.attributes = file.attributes || {};
2762
+ this.uploadUrl = file.uploadUrl;
2763
+ this.attributes = file.attributes;
2677
2764
  }
2678
2765
  static fromBuffer(buffer, options = {}) {
2679
2766
  const base64Content = buffer.toString("base64");
@@ -2763,7 +2850,7 @@ class XataFile {
2763
2850
  const parseInputFileEntry = async (entry) => {
2764
2851
  if (!isDefined(entry))
2765
2852
  return null;
2766
- const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
2853
+ const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
2767
2854
  return compactObject({
2768
2855
  id,
2769
2856
  // Name cannot be an empty string in our API
@@ -2771,7 +2858,8 @@ const parseInputFileEntry = async (entry) => {
2771
2858
  mediaType,
2772
2859
  base64Content,
2773
2860
  enablePublicUrl,
2774
- signedUrlTimeout
2861
+ signedUrlTimeout,
2862
+ uploadUrlTimeout
2775
2863
  });
2776
2864
  };
2777
2865
 
@@ -2825,7 +2913,7 @@ var __accessCheck$6 = (obj, member, msg) => {
2825
2913
  if (!member.has(obj))
2826
2914
  throw TypeError("Cannot " + msg);
2827
2915
  };
2828
- var __privateGet$6 = (obj, member, getter) => {
2916
+ var __privateGet$5 = (obj, member, getter) => {
2829
2917
  __accessCheck$6(obj, member, "read from private field");
2830
2918
  return getter ? getter.call(obj) : member.get(obj);
2831
2919
  };
@@ -2834,7 +2922,7 @@ var __privateAdd$6 = (obj, member, value) => {
2834
2922
  throw TypeError("Cannot add the same private member more than once");
2835
2923
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2836
2924
  };
2837
- var __privateSet$6 = (obj, member, value, setter) => {
2925
+ var __privateSet$4 = (obj, member, value, setter) => {
2838
2926
  __accessCheck$6(obj, member, "write to private field");
2839
2927
  setter ? setter.call(obj, value) : member.set(obj, value);
2840
2928
  return value;
@@ -2843,9 +2931,9 @@ var _query, _page;
2843
2931
  class Page {
2844
2932
  constructor(query, meta, records = []) {
2845
2933
  __privateAdd$6(this, _query, void 0);
2846
- __privateSet$6(this, _query, query);
2934
+ __privateSet$4(this, _query, query);
2847
2935
  this.meta = meta;
2848
- this.records = new RecordArray(this, records);
2936
+ this.records = new PageRecordArray(this, records);
2849
2937
  }
2850
2938
  /**
2851
2939
  * Retrieves the next page of results.
@@ -2854,7 +2942,7 @@ class Page {
2854
2942
  * @returns The next page or results.
2855
2943
  */
2856
2944
  async nextPage(size, offset) {
2857
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2945
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2858
2946
  }
2859
2947
  /**
2860
2948
  * Retrieves the previous page of results.
@@ -2863,7 +2951,7 @@ class Page {
2863
2951
  * @returns The previous page or results.
2864
2952
  */
2865
2953
  async previousPage(size, offset) {
2866
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2954
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2867
2955
  }
2868
2956
  /**
2869
2957
  * Retrieves the start page of results.
@@ -2872,7 +2960,7 @@ class Page {
2872
2960
  * @returns The start page or results.
2873
2961
  */
2874
2962
  async startPage(size, offset) {
2875
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2963
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2876
2964
  }
2877
2965
  /**
2878
2966
  * Retrieves the end page of results.
@@ -2881,7 +2969,7 @@ class Page {
2881
2969
  * @returns The end page or results.
2882
2970
  */
2883
2971
  async endPage(size, offset) {
2884
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2972
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2885
2973
  }
2886
2974
  /**
2887
2975
  * Shortcut method to check if there will be additional results if the next page of results is retrieved.
@@ -2899,11 +2987,38 @@ const PAGINATION_DEFAULT_OFFSET = 0;
2899
2987
  function isCursorPaginationOptions(options) {
2900
2988
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
2901
2989
  }
2902
- const _RecordArray = class _RecordArray extends Array {
2990
+ class RecordArray extends Array {
2903
2991
  constructor(...args) {
2904
- super(..._RecordArray.parseConstructorParams(...args));
2992
+ super(...RecordArray.parseConstructorParams(...args));
2993
+ }
2994
+ static parseConstructorParams(...args) {
2995
+ if (args.length === 1 && typeof args[0] === "number") {
2996
+ return new Array(args[0]);
2997
+ }
2998
+ if (args.length <= 1 && Array.isArray(args[0] ?? [])) {
2999
+ const result = args[0] ?? [];
3000
+ return new Array(...result);
3001
+ }
3002
+ return new Array(...args);
3003
+ }
3004
+ toArray() {
3005
+ return new Array(...this);
3006
+ }
3007
+ toSerializable() {
3008
+ return JSON.parse(this.toString());
3009
+ }
3010
+ toString() {
3011
+ return JSON.stringify(this.toArray());
3012
+ }
3013
+ map(callbackfn, thisArg) {
3014
+ return this.toArray().map(callbackfn, thisArg);
3015
+ }
3016
+ }
3017
+ const _PageRecordArray = class _PageRecordArray extends Array {
3018
+ constructor(...args) {
3019
+ super(..._PageRecordArray.parseConstructorParams(...args));
2905
3020
  __privateAdd$6(this, _page, void 0);
2906
- __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
3021
+ __privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
2907
3022
  }
2908
3023
  static parseConstructorParams(...args) {
2909
3024
  if (args.length === 1 && typeof args[0] === "number") {
@@ -2933,8 +3048,8 @@ const _RecordArray = class _RecordArray extends Array {
2933
3048
  * @returns A new array of objects
2934
3049
  */
2935
3050
  async nextPage(size, offset) {
2936
- const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
2937
- return new _RecordArray(newPage);
3051
+ const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
3052
+ return new _PageRecordArray(newPage);
2938
3053
  }
2939
3054
  /**
2940
3055
  * Retrieve previous page of records
@@ -2942,8 +3057,8 @@ const _RecordArray = class _RecordArray extends Array {
2942
3057
  * @returns A new array of objects
2943
3058
  */
2944
3059
  async previousPage(size, offset) {
2945
- const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
2946
- return new _RecordArray(newPage);
3060
+ const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
3061
+ return new _PageRecordArray(newPage);
2947
3062
  }
2948
3063
  /**
2949
3064
  * Retrieve start page of records
@@ -2951,8 +3066,8 @@ const _RecordArray = class _RecordArray extends Array {
2951
3066
  * @returns A new array of objects
2952
3067
  */
2953
3068
  async startPage(size, offset) {
2954
- const newPage = await __privateGet$6(this, _page).startPage(size, offset);
2955
- return new _RecordArray(newPage);
3069
+ const newPage = await __privateGet$5(this, _page).startPage(size, offset);
3070
+ return new _PageRecordArray(newPage);
2956
3071
  }
2957
3072
  /**
2958
3073
  * Retrieve end page of records
@@ -2960,24 +3075,24 @@ const _RecordArray = class _RecordArray extends Array {
2960
3075
  * @returns A new array of objects
2961
3076
  */
2962
3077
  async endPage(size, offset) {
2963
- const newPage = await __privateGet$6(this, _page).endPage(size, offset);
2964
- return new _RecordArray(newPage);
3078
+ const newPage = await __privateGet$5(this, _page).endPage(size, offset);
3079
+ return new _PageRecordArray(newPage);
2965
3080
  }
2966
3081
  /**
2967
3082
  * @returns Boolean indicating if there is a next page
2968
3083
  */
2969
3084
  hasNextPage() {
2970
- return __privateGet$6(this, _page).meta.page.more;
3085
+ return __privateGet$5(this, _page).meta.page.more;
2971
3086
  }
2972
3087
  };
2973
3088
  _page = new WeakMap();
2974
- let RecordArray = _RecordArray;
3089
+ let PageRecordArray = _PageRecordArray;
2975
3090
 
2976
3091
  var __accessCheck$5 = (obj, member, msg) => {
2977
3092
  if (!member.has(obj))
2978
3093
  throw TypeError("Cannot " + msg);
2979
3094
  };
2980
- var __privateGet$5 = (obj, member, getter) => {
3095
+ var __privateGet$4 = (obj, member, getter) => {
2981
3096
  __accessCheck$5(obj, member, "read from private field");
2982
3097
  return getter ? getter.call(obj) : member.get(obj);
2983
3098
  };
@@ -2986,7 +3101,7 @@ var __privateAdd$5 = (obj, member, value) => {
2986
3101
  throw TypeError("Cannot add the same private member more than once");
2987
3102
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2988
3103
  };
2989
- var __privateSet$5 = (obj, member, value, setter) => {
3104
+ var __privateSet$3 = (obj, member, value, setter) => {
2990
3105
  __accessCheck$5(obj, member, "write to private field");
2991
3106
  setter ? setter.call(obj, value) : member.set(obj, value);
2992
3107
  return value;
@@ -3004,25 +3119,25 @@ const _Query = class _Query {
3004
3119
  __privateAdd$5(this, _data, { filter: {} });
3005
3120
  // Implements pagination
3006
3121
  this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3007
- this.records = new RecordArray(this, []);
3008
- __privateSet$5(this, _table$1, table);
3122
+ this.records = new PageRecordArray(this, []);
3123
+ __privateSet$3(this, _table$1, table);
3009
3124
  if (repository) {
3010
- __privateSet$5(this, _repository, repository);
3125
+ __privateSet$3(this, _repository, repository);
3011
3126
  } else {
3012
- __privateSet$5(this, _repository, this);
3127
+ __privateSet$3(this, _repository, this);
3013
3128
  }
3014
3129
  const parent = cleanParent(data, rawParent);
3015
- __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
3016
- __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3017
- __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3018
- __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3019
- __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3020
- __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
3021
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
3022
- __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
3023
- __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
3024
- __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
3025
- __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3130
+ __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
3131
+ __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3132
+ __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3133
+ __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3134
+ __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3135
+ __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
3136
+ __privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
3137
+ __privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
3138
+ __privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
3139
+ __privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
3140
+ __privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3026
3141
  this.any = this.any.bind(this);
3027
3142
  this.all = this.all.bind(this);
3028
3143
  this.not = this.not.bind(this);
@@ -3033,10 +3148,10 @@ const _Query = class _Query {
3033
3148
  Object.defineProperty(this, "repository", { enumerable: false });
3034
3149
  }
3035
3150
  getQueryOptions() {
3036
- return __privateGet$5(this, _data);
3151
+ return __privateGet$4(this, _data);
3037
3152
  }
3038
3153
  key() {
3039
- const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
3154
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
3040
3155
  const key = JSON.stringify({ columns, filter, sort, pagination });
3041
3156
  return toBase64(key);
3042
3157
  }
@@ -3047,7 +3162,7 @@ const _Query = class _Query {
3047
3162
  */
3048
3163
  any(...queries) {
3049
3164
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
3050
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
3165
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
3051
3166
  }
3052
3167
  /**
3053
3168
  * Builds a new query object representing a logical AND between the given subqueries.
@@ -3056,7 +3171,7 @@ const _Query = class _Query {
3056
3171
  */
3057
3172
  all(...queries) {
3058
3173
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
3059
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3174
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3060
3175
  }
3061
3176
  /**
3062
3177
  * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
@@ -3065,7 +3180,7 @@ const _Query = class _Query {
3065
3180
  */
3066
3181
  not(...queries) {
3067
3182
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
3068
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
3183
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
3069
3184
  }
3070
3185
  /**
3071
3186
  * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
@@ -3074,25 +3189,25 @@ const _Query = class _Query {
3074
3189
  */
3075
3190
  none(...queries) {
3076
3191
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
3077
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
3192
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
3078
3193
  }
3079
3194
  filter(a, b) {
3080
3195
  if (arguments.length === 1) {
3081
3196
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
3082
3197
  [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
3083
3198
  }));
3084
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3085
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3199
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3200
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3086
3201
  } else {
3087
3202
  const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3088
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3089
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3203
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3204
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3090
3205
  }
3091
3206
  }
3092
3207
  sort(column, direction = "asc") {
3093
- const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
3208
+ const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
3094
3209
  const sort = [...originalSort, { column, direction }];
3095
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
3210
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
3096
3211
  }
3097
3212
  /**
3098
3213
  * Builds a new query specifying the set of columns to be returned in the query response.
@@ -3101,15 +3216,15 @@ const _Query = class _Query {
3101
3216
  */
3102
3217
  select(columns) {
3103
3218
  return new _Query(
3104
- __privateGet$5(this, _repository),
3105
- __privateGet$5(this, _table$1),
3219
+ __privateGet$4(this, _repository),
3220
+ __privateGet$4(this, _table$1),
3106
3221
  { columns },
3107
- __privateGet$5(this, _data)
3222
+ __privateGet$4(this, _data)
3108
3223
  );
3109
3224
  }
3110
3225
  getPaginated(options = {}) {
3111
- const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
3112
- return __privateGet$5(this, _repository).query(query);
3226
+ const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
3227
+ return __privateGet$4(this, _repository).query(query);
3113
3228
  }
3114
3229
  /**
3115
3230
  * Get results in an iterator
@@ -3146,7 +3261,7 @@ const _Query = class _Query {
3146
3261
  if (page.hasNextPage() && options.pagination?.size === void 0) {
3147
3262
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
3148
3263
  }
3149
- const array = new RecordArray(page, results.slice(0, size));
3264
+ const array = new PageRecordArray(page, results.slice(0, size));
3150
3265
  return array;
3151
3266
  }
3152
3267
  async getAll(options = {}) {
@@ -3155,7 +3270,7 @@ const _Query = class _Query {
3155
3270
  for await (const page of this.getIterator({ ...rest, batchSize })) {
3156
3271
  results.push(...page);
3157
3272
  }
3158
- return results;
3273
+ return new RecordArray(results);
3159
3274
  }
3160
3275
  async getFirst(options = {}) {
3161
3276
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
@@ -3170,12 +3285,12 @@ const _Query = class _Query {
3170
3285
  async summarize(params = {}) {
3171
3286
  const { summaries, summariesFilter, ...options } = params;
3172
3287
  const query = new _Query(
3173
- __privateGet$5(this, _repository),
3174
- __privateGet$5(this, _table$1),
3288
+ __privateGet$4(this, _repository),
3289
+ __privateGet$4(this, _table$1),
3175
3290
  options,
3176
- __privateGet$5(this, _data)
3291
+ __privateGet$4(this, _data)
3177
3292
  );
3178
- return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
3293
+ return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
3179
3294
  }
3180
3295
  /**
3181
3296
  * Builds a new query object adding a cache TTL in milliseconds.
@@ -3183,7 +3298,7 @@ const _Query = class _Query {
3183
3298
  * @returns A new Query object.
3184
3299
  */
3185
3300
  cache(ttl) {
3186
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
3301
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
3187
3302
  }
3188
3303
  /**
3189
3304
  * Retrieve next page of records
@@ -3229,7 +3344,7 @@ _repository = new WeakMap();
3229
3344
  _data = new WeakMap();
3230
3345
  _cleanFilterConstraint = new WeakSet();
3231
3346
  cleanFilterConstraint_fn = function(column, value) {
3232
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3347
+ const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3233
3348
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
3234
3349
  return { $includes: value };
3235
3350
  }
@@ -3255,7 +3370,6 @@ const RecordColumnTypes = [
3255
3370
  "email",
3256
3371
  "multiple",
3257
3372
  "link",
3258
- "object",
3259
3373
  "datetime",
3260
3374
  "vector",
3261
3375
  "file[]",
@@ -3320,7 +3434,7 @@ var __accessCheck$4 = (obj, member, msg) => {
3320
3434
  if (!member.has(obj))
3321
3435
  throw TypeError("Cannot " + msg);
3322
3436
  };
3323
- var __privateGet$4 = (obj, member, getter) => {
3437
+ var __privateGet$3 = (obj, member, getter) => {
3324
3438
  __accessCheck$4(obj, member, "read from private field");
3325
3439
  return getter ? getter.call(obj) : member.get(obj);
3326
3440
  };
@@ -3329,7 +3443,7 @@ var __privateAdd$4 = (obj, member, value) => {
3329
3443
  throw TypeError("Cannot add the same private member more than once");
3330
3444
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3331
3445
  };
3332
- var __privateSet$4 = (obj, member, value, setter) => {
3446
+ var __privateSet$2 = (obj, member, value, setter) => {
3333
3447
  __accessCheck$4(obj, member, "write to private field");
3334
3448
  setter ? setter.call(obj, value) : member.set(obj, value);
3335
3449
  return value;
@@ -3338,7 +3452,7 @@ var __privateMethod$2 = (obj, member, method) => {
3338
3452
  __accessCheck$4(obj, member, "access private method");
3339
3453
  return method;
3340
3454
  };
3341
- var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1, _transformObjectToApi, transformObjectToApi_fn;
3455
+ var _table, _getFetchProps, _db, _cache, _schemaTables, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
3342
3456
  const BULK_OPERATION_MAX_SIZE = 1e3;
3343
3457
  class Repository extends Query {
3344
3458
  }
@@ -3359,31 +3473,31 @@ class RestRepository extends Query {
3359
3473
  __privateAdd$4(this, _deleteRecords);
3360
3474
  __privateAdd$4(this, _setCacheQuery);
3361
3475
  __privateAdd$4(this, _getCacheQuery);
3362
- __privateAdd$4(this, _getSchemaTables$1);
3476
+ __privateAdd$4(this, _getSchemaTables);
3363
3477
  __privateAdd$4(this, _transformObjectToApi);
3364
3478
  __privateAdd$4(this, _table, void 0);
3365
3479
  __privateAdd$4(this, _getFetchProps, void 0);
3366
3480
  __privateAdd$4(this, _db, void 0);
3367
3481
  __privateAdd$4(this, _cache, void 0);
3368
- __privateAdd$4(this, _schemaTables$2, void 0);
3482
+ __privateAdd$4(this, _schemaTables, void 0);
3369
3483
  __privateAdd$4(this, _trace, void 0);
3370
- __privateSet$4(this, _table, options.table);
3371
- __privateSet$4(this, _db, options.db);
3372
- __privateSet$4(this, _cache, options.pluginOptions.cache);
3373
- __privateSet$4(this, _schemaTables$2, options.schemaTables);
3374
- __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3484
+ __privateSet$2(this, _table, options.table);
3485
+ __privateSet$2(this, _db, options.db);
3486
+ __privateSet$2(this, _cache, options.pluginOptions.cache);
3487
+ __privateSet$2(this, _schemaTables, options.schemaTables);
3488
+ __privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3375
3489
  const trace = options.pluginOptions.trace ?? defaultTrace;
3376
- __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
3490
+ __privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
3377
3491
  return trace(name, fn, {
3378
3492
  ...options2,
3379
- [TraceAttributes.TABLE]: __privateGet$4(this, _table),
3493
+ [TraceAttributes.TABLE]: __privateGet$3(this, _table),
3380
3494
  [TraceAttributes.KIND]: "sdk-operation",
3381
3495
  [TraceAttributes.VERSION]: VERSION
3382
3496
  });
3383
3497
  });
3384
3498
  }
3385
3499
  async create(a, b, c, d) {
3386
- return __privateGet$4(this, _trace).call(this, "create", async () => {
3500
+ return __privateGet$3(this, _trace).call(this, "create", async () => {
3387
3501
  const ifVersion = parseIfVersion(b, c, d);
3388
3502
  if (Array.isArray(a)) {
3389
3503
  if (a.length === 0)
@@ -3413,7 +3527,7 @@ class RestRepository extends Query {
3413
3527
  });
3414
3528
  }
3415
3529
  async read(a, b) {
3416
- return __privateGet$4(this, _trace).call(this, "read", async () => {
3530
+ return __privateGet$3(this, _trace).call(this, "read", async () => {
3417
3531
  const columns = isValidSelectableColumns(b) ? b : ["*"];
3418
3532
  if (Array.isArray(a)) {
3419
3533
  if (a.length === 0)
@@ -3434,17 +3548,17 @@ class RestRepository extends Query {
3434
3548
  workspace: "{workspaceId}",
3435
3549
  dbBranchName: "{dbBranch}",
3436
3550
  region: "{region}",
3437
- tableName: __privateGet$4(this, _table),
3551
+ tableName: __privateGet$3(this, _table),
3438
3552
  recordId: id
3439
3553
  },
3440
3554
  queryParams: { columns },
3441
- ...__privateGet$4(this, _getFetchProps).call(this)
3555
+ ...__privateGet$3(this, _getFetchProps).call(this)
3442
3556
  });
3443
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3557
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3444
3558
  return initObject(
3445
- __privateGet$4(this, _db),
3559
+ __privateGet$3(this, _db),
3446
3560
  schemaTables,
3447
- __privateGet$4(this, _table),
3561
+ __privateGet$3(this, _table),
3448
3562
  response,
3449
3563
  columns
3450
3564
  );
@@ -3459,7 +3573,7 @@ class RestRepository extends Query {
3459
3573
  });
3460
3574
  }
3461
3575
  async readOrThrow(a, b) {
3462
- return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
3576
+ return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
3463
3577
  const result = await this.read(a, b);
3464
3578
  if (Array.isArray(result)) {
3465
3579
  const missingIds = compact(
@@ -3478,7 +3592,7 @@ class RestRepository extends Query {
3478
3592
  });
3479
3593
  }
3480
3594
  async update(a, b, c, d) {
3481
- return __privateGet$4(this, _trace).call(this, "update", async () => {
3595
+ return __privateGet$3(this, _trace).call(this, "update", async () => {
3482
3596
  const ifVersion = parseIfVersion(b, c, d);
3483
3597
  if (Array.isArray(a)) {
3484
3598
  if (a.length === 0)
@@ -3511,7 +3625,7 @@ class RestRepository extends Query {
3511
3625
  });
3512
3626
  }
3513
3627
  async updateOrThrow(a, b, c, d) {
3514
- return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
3628
+ return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
3515
3629
  const result = await this.update(a, b, c, d);
3516
3630
  if (Array.isArray(result)) {
3517
3631
  const missingIds = compact(
@@ -3530,7 +3644,7 @@ class RestRepository extends Query {
3530
3644
  });
3531
3645
  }
3532
3646
  async createOrUpdate(a, b, c, d) {
3533
- return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3647
+ return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
3534
3648
  const ifVersion = parseIfVersion(b, c, d);
3535
3649
  if (Array.isArray(a)) {
3536
3650
  if (a.length === 0)
@@ -3565,7 +3679,7 @@ class RestRepository extends Query {
3565
3679
  });
3566
3680
  }
3567
3681
  async createOrReplace(a, b, c, d) {
3568
- return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3682
+ return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
3569
3683
  const ifVersion = parseIfVersion(b, c, d);
3570
3684
  if (Array.isArray(a)) {
3571
3685
  if (a.length === 0)
@@ -3597,7 +3711,7 @@ class RestRepository extends Query {
3597
3711
  });
3598
3712
  }
3599
3713
  async delete(a, b) {
3600
- return __privateGet$4(this, _trace).call(this, "delete", async () => {
3714
+ return __privateGet$3(this, _trace).call(this, "delete", async () => {
3601
3715
  if (Array.isArray(a)) {
3602
3716
  if (a.length === 0)
3603
3717
  return [];
@@ -3623,7 +3737,7 @@ class RestRepository extends Query {
3623
3737
  });
3624
3738
  }
3625
3739
  async deleteOrThrow(a, b) {
3626
- return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
3740
+ return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
3627
3741
  const result = await this.delete(a, b);
3628
3742
  if (Array.isArray(result)) {
3629
3743
  const missingIds = compact(
@@ -3641,13 +3755,13 @@ class RestRepository extends Query {
3641
3755
  });
3642
3756
  }
3643
3757
  async search(query, options = {}) {
3644
- return __privateGet$4(this, _trace).call(this, "search", async () => {
3758
+ return __privateGet$3(this, _trace).call(this, "search", async () => {
3645
3759
  const { records, totalCount } = await searchTable({
3646
3760
  pathParams: {
3647
3761
  workspace: "{workspaceId}",
3648
3762
  dbBranchName: "{dbBranch}",
3649
3763
  region: "{region}",
3650
- tableName: __privateGet$4(this, _table)
3764
+ tableName: __privateGet$3(this, _table)
3651
3765
  },
3652
3766
  body: {
3653
3767
  query,
@@ -3659,23 +3773,23 @@ class RestRepository extends Query {
3659
3773
  page: options.page,
3660
3774
  target: options.target
3661
3775
  },
3662
- ...__privateGet$4(this, _getFetchProps).call(this)
3776
+ ...__privateGet$3(this, _getFetchProps).call(this)
3663
3777
  });
3664
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3778
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3665
3779
  return {
3666
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3780
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3667
3781
  totalCount
3668
3782
  };
3669
3783
  });
3670
3784
  }
3671
3785
  async vectorSearch(column, query, options) {
3672
- return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3786
+ return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
3673
3787
  const { records, totalCount } = await vectorSearchTable({
3674
3788
  pathParams: {
3675
3789
  workspace: "{workspaceId}",
3676
3790
  dbBranchName: "{dbBranch}",
3677
3791
  region: "{region}",
3678
- tableName: __privateGet$4(this, _table)
3792
+ tableName: __privateGet$3(this, _table)
3679
3793
  },
3680
3794
  body: {
3681
3795
  column,
@@ -3684,32 +3798,32 @@ class RestRepository extends Query {
3684
3798
  size: options?.size,
3685
3799
  filter: options?.filter
3686
3800
  },
3687
- ...__privateGet$4(this, _getFetchProps).call(this)
3801
+ ...__privateGet$3(this, _getFetchProps).call(this)
3688
3802
  });
3689
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3803
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3690
3804
  return {
3691
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3805
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3692
3806
  totalCount
3693
3807
  };
3694
3808
  });
3695
3809
  }
3696
3810
  async aggregate(aggs, filter) {
3697
- return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
3811
+ return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
3698
3812
  const result = await aggregateTable({
3699
3813
  pathParams: {
3700
3814
  workspace: "{workspaceId}",
3701
3815
  dbBranchName: "{dbBranch}",
3702
3816
  region: "{region}",
3703
- tableName: __privateGet$4(this, _table)
3817
+ tableName: __privateGet$3(this, _table)
3704
3818
  },
3705
3819
  body: { aggs, filter },
3706
- ...__privateGet$4(this, _getFetchProps).call(this)
3820
+ ...__privateGet$3(this, _getFetchProps).call(this)
3707
3821
  });
3708
3822
  return result;
3709
3823
  });
3710
3824
  }
3711
3825
  async query(query) {
3712
- return __privateGet$4(this, _trace).call(this, "query", async () => {
3826
+ return __privateGet$3(this, _trace).call(this, "query", async () => {
3713
3827
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
3714
3828
  if (cacheQuery)
3715
3829
  return new Page(query, cacheQuery.meta, cacheQuery.records);
@@ -3719,7 +3833,7 @@ class RestRepository extends Query {
3719
3833
  workspace: "{workspaceId}",
3720
3834
  dbBranchName: "{dbBranch}",
3721
3835
  region: "{region}",
3722
- tableName: __privateGet$4(this, _table)
3836
+ tableName: __privateGet$3(this, _table)
3723
3837
  },
3724
3838
  body: {
3725
3839
  filter: cleanFilter(data.filter),
@@ -3729,14 +3843,14 @@ class RestRepository extends Query {
3729
3843
  consistency: data.consistency
3730
3844
  },
3731
3845
  fetchOptions: data.fetchOptions,
3732
- ...__privateGet$4(this, _getFetchProps).call(this)
3846
+ ...__privateGet$3(this, _getFetchProps).call(this)
3733
3847
  });
3734
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3848
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3735
3849
  const records = objects.map(
3736
3850
  (record) => initObject(
3737
- __privateGet$4(this, _db),
3851
+ __privateGet$3(this, _db),
3738
3852
  schemaTables,
3739
- __privateGet$4(this, _table),
3853
+ __privateGet$3(this, _table),
3740
3854
  record,
3741
3855
  data.columns ?? ["*"]
3742
3856
  )
@@ -3746,14 +3860,14 @@ class RestRepository extends Query {
3746
3860
  });
3747
3861
  }
3748
3862
  async summarizeTable(query, summaries, summariesFilter) {
3749
- return __privateGet$4(this, _trace).call(this, "summarize", async () => {
3863
+ return __privateGet$3(this, _trace).call(this, "summarize", async () => {
3750
3864
  const data = query.getQueryOptions();
3751
3865
  const result = await summarizeTable({
3752
3866
  pathParams: {
3753
3867
  workspace: "{workspaceId}",
3754
3868
  dbBranchName: "{dbBranch}",
3755
3869
  region: "{region}",
3756
- tableName: __privateGet$4(this, _table)
3870
+ tableName: __privateGet$3(this, _table)
3757
3871
  },
3758
3872
  body: {
3759
3873
  filter: cleanFilter(data.filter),
@@ -3764,13 +3878,13 @@ class RestRepository extends Query {
3764
3878
  summaries,
3765
3879
  summariesFilter
3766
3880
  },
3767
- ...__privateGet$4(this, _getFetchProps).call(this)
3881
+ ...__privateGet$3(this, _getFetchProps).call(this)
3768
3882
  });
3769
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3883
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3770
3884
  return {
3771
3885
  ...result,
3772
3886
  summaries: result.summaries.map(
3773
- (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3887
+ (summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
3774
3888
  )
3775
3889
  };
3776
3890
  });
@@ -3782,7 +3896,7 @@ class RestRepository extends Query {
3782
3896
  workspace: "{workspaceId}",
3783
3897
  dbBranchName: "{dbBranch}",
3784
3898
  region: "{region}",
3785
- tableName: __privateGet$4(this, _table),
3899
+ tableName: __privateGet$3(this, _table),
3786
3900
  sessionId: options?.sessionId
3787
3901
  },
3788
3902
  body: {
@@ -3792,7 +3906,7 @@ class RestRepository extends Query {
3792
3906
  search: options?.searchType === "keyword" ? options?.search : void 0,
3793
3907
  vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3794
3908
  },
3795
- ...__privateGet$4(this, _getFetchProps).call(this)
3909
+ ...__privateGet$3(this, _getFetchProps).call(this)
3796
3910
  };
3797
3911
  if (options?.onMessage) {
3798
3912
  fetchSSERequest({
@@ -3813,7 +3927,7 @@ _table = new WeakMap();
3813
3927
  _getFetchProps = new WeakMap();
3814
3928
  _db = new WeakMap();
3815
3929
  _cache = new WeakMap();
3816
- _schemaTables$2 = new WeakMap();
3930
+ _schemaTables = new WeakMap();
3817
3931
  _trace = new WeakMap();
3818
3932
  _insertRecordWithoutId = new WeakSet();
3819
3933
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
@@ -3823,14 +3937,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3823
3937
  workspace: "{workspaceId}",
3824
3938
  dbBranchName: "{dbBranch}",
3825
3939
  region: "{region}",
3826
- tableName: __privateGet$4(this, _table)
3940
+ tableName: __privateGet$3(this, _table)
3827
3941
  },
3828
3942
  queryParams: { columns },
3829
3943
  body: record,
3830
- ...__privateGet$4(this, _getFetchProps).call(this)
3944
+ ...__privateGet$3(this, _getFetchProps).call(this)
3831
3945
  });
3832
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3833
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3946
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3947
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3834
3948
  };
3835
3949
  _insertRecordWithId = new WeakSet();
3836
3950
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
@@ -3842,21 +3956,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
3842
3956
  workspace: "{workspaceId}",
3843
3957
  dbBranchName: "{dbBranch}",
3844
3958
  region: "{region}",
3845
- tableName: __privateGet$4(this, _table),
3959
+ tableName: __privateGet$3(this, _table),
3846
3960
  recordId
3847
3961
  },
3848
3962
  body: record,
3849
3963
  queryParams: { createOnly, columns, ifVersion },
3850
- ...__privateGet$4(this, _getFetchProps).call(this)
3964
+ ...__privateGet$3(this, _getFetchProps).call(this)
3851
3965
  });
3852
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3853
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3966
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3967
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3854
3968
  };
3855
3969
  _insertRecords = new WeakSet();
3856
3970
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3857
3971
  const operations = await promiseMap(objects, async (object) => {
3858
3972
  const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3859
- return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3973
+ return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
3860
3974
  });
3861
3975
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3862
3976
  const ids = [];
@@ -3868,7 +3982,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3868
3982
  region: "{region}"
3869
3983
  },
3870
3984
  body: { operations: operations2 },
3871
- ...__privateGet$4(this, _getFetchProps).call(this)
3985
+ ...__privateGet$3(this, _getFetchProps).call(this)
3872
3986
  });
3873
3987
  for (const result of results) {
3874
3988
  if (result.operation === "insert") {
@@ -3891,15 +4005,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3891
4005
  workspace: "{workspaceId}",
3892
4006
  dbBranchName: "{dbBranch}",
3893
4007
  region: "{region}",
3894
- tableName: __privateGet$4(this, _table),
4008
+ tableName: __privateGet$3(this, _table),
3895
4009
  recordId
3896
4010
  },
3897
4011
  queryParams: { columns, ifVersion },
3898
4012
  body: record,
3899
- ...__privateGet$4(this, _getFetchProps).call(this)
4013
+ ...__privateGet$3(this, _getFetchProps).call(this)
3900
4014
  });
3901
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3902
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4015
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4016
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3903
4017
  } catch (e) {
3904
4018
  if (isObject(e) && e.status === 404) {
3905
4019
  return null;
@@ -3911,7 +4025,7 @@ _updateRecords = new WeakSet();
3911
4025
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3912
4026
  const operations = await promiseMap(objects, async ({ id, ...object }) => {
3913
4027
  const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3914
- return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
4028
+ return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
3915
4029
  });
3916
4030
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3917
4031
  const ids = [];
@@ -3923,7 +4037,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3923
4037
  region: "{region}"
3924
4038
  },
3925
4039
  body: { operations: operations2 },
3926
- ...__privateGet$4(this, _getFetchProps).call(this)
4040
+ ...__privateGet$3(this, _getFetchProps).call(this)
3927
4041
  });
3928
4042
  for (const result of results) {
3929
4043
  if (result.operation === "update") {
@@ -3944,15 +4058,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3944
4058
  workspace: "{workspaceId}",
3945
4059
  dbBranchName: "{dbBranch}",
3946
4060
  region: "{region}",
3947
- tableName: __privateGet$4(this, _table),
4061
+ tableName: __privateGet$3(this, _table),
3948
4062
  recordId
3949
4063
  },
3950
4064
  queryParams: { columns, ifVersion },
3951
4065
  body: object,
3952
- ...__privateGet$4(this, _getFetchProps).call(this)
4066
+ ...__privateGet$3(this, _getFetchProps).call(this)
3953
4067
  });
3954
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3955
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4068
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4069
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3956
4070
  };
3957
4071
  _deleteRecord = new WeakSet();
3958
4072
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
@@ -3964,14 +4078,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
3964
4078
  workspace: "{workspaceId}",
3965
4079
  dbBranchName: "{dbBranch}",
3966
4080
  region: "{region}",
3967
- tableName: __privateGet$4(this, _table),
4081
+ tableName: __privateGet$3(this, _table),
3968
4082
  recordId
3969
4083
  },
3970
4084
  queryParams: { columns },
3971
- ...__privateGet$4(this, _getFetchProps).call(this)
4085
+ ...__privateGet$3(this, _getFetchProps).call(this)
3972
4086
  });
3973
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3974
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4087
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4088
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3975
4089
  } catch (e) {
3976
4090
  if (isObject(e) && e.status === 404) {
3977
4091
  return null;
@@ -3982,7 +4096,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
3982
4096
  _deleteRecords = new WeakSet();
3983
4097
  deleteRecords_fn = async function(recordIds) {
3984
4098
  const chunkedOperations = chunk(
3985
- compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4099
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
3986
4100
  BULK_OPERATION_MAX_SIZE
3987
4101
  );
3988
4102
  for (const operations of chunkedOperations) {
@@ -3993,44 +4107,44 @@ deleteRecords_fn = async function(recordIds) {
3993
4107
  region: "{region}"
3994
4108
  },
3995
4109
  body: { operations },
3996
- ...__privateGet$4(this, _getFetchProps).call(this)
4110
+ ...__privateGet$3(this, _getFetchProps).call(this)
3997
4111
  });
3998
4112
  }
3999
4113
  };
4000
4114
  _setCacheQuery = new WeakSet();
4001
4115
  setCacheQuery_fn = async function(query, meta, records) {
4002
- await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4116
+ await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4003
4117
  };
4004
4118
  _getCacheQuery = new WeakSet();
4005
4119
  getCacheQuery_fn = async function(query) {
4006
- const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
4007
- const result = await __privateGet$4(this, _cache)?.get(key);
4120
+ const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
4121
+ const result = await __privateGet$3(this, _cache)?.get(key);
4008
4122
  if (!result)
4009
4123
  return null;
4010
- const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4124
+ const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
4011
4125
  const { cache: ttl = defaultTTL } = query.getQueryOptions();
4012
4126
  if (ttl < 0)
4013
4127
  return null;
4014
4128
  const hasExpired = result.date.getTime() + ttl < Date.now();
4015
4129
  return hasExpired ? null : result;
4016
4130
  };
4017
- _getSchemaTables$1 = new WeakSet();
4018
- getSchemaTables_fn$1 = async function() {
4019
- if (__privateGet$4(this, _schemaTables$2))
4020
- return __privateGet$4(this, _schemaTables$2);
4131
+ _getSchemaTables = new WeakSet();
4132
+ getSchemaTables_fn = async function() {
4133
+ if (__privateGet$3(this, _schemaTables))
4134
+ return __privateGet$3(this, _schemaTables);
4021
4135
  const { schema } = await getBranchDetails({
4022
4136
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4023
- ...__privateGet$4(this, _getFetchProps).call(this)
4137
+ ...__privateGet$3(this, _getFetchProps).call(this)
4024
4138
  });
4025
- __privateSet$4(this, _schemaTables$2, schema.tables);
4139
+ __privateSet$2(this, _schemaTables, schema.tables);
4026
4140
  return schema.tables;
4027
4141
  };
4028
4142
  _transformObjectToApi = new WeakSet();
4029
4143
  transformObjectToApi_fn = async function(object) {
4030
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4031
- const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4144
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4145
+ const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
4032
4146
  if (!schema)
4033
- throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4147
+ throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
4034
4148
  const result = {};
4035
4149
  for (const [key, value] of Object.entries(object)) {
4036
4150
  if (key === "xata")
@@ -4186,7 +4300,7 @@ var __accessCheck$3 = (obj, member, msg) => {
4186
4300
  if (!member.has(obj))
4187
4301
  throw TypeError("Cannot " + msg);
4188
4302
  };
4189
- var __privateGet$3 = (obj, member, getter) => {
4303
+ var __privateGet$2 = (obj, member, getter) => {
4190
4304
  __accessCheck$3(obj, member, "read from private field");
4191
4305
  return getter ? getter.call(obj) : member.get(obj);
4192
4306
  };
@@ -4195,7 +4309,7 @@ var __privateAdd$3 = (obj, member, value) => {
4195
4309
  throw TypeError("Cannot add the same private member more than once");
4196
4310
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4197
4311
  };
4198
- var __privateSet$3 = (obj, member, value, setter) => {
4312
+ var __privateSet$1 = (obj, member, value, setter) => {
4199
4313
  __accessCheck$3(obj, member, "write to private field");
4200
4314
  setter ? setter.call(obj, value) : member.set(obj, value);
4201
4315
  return value;
@@ -4204,29 +4318,29 @@ var _map;
4204
4318
  class SimpleCache {
4205
4319
  constructor(options = {}) {
4206
4320
  __privateAdd$3(this, _map, void 0);
4207
- __privateSet$3(this, _map, /* @__PURE__ */ new Map());
4321
+ __privateSet$1(this, _map, /* @__PURE__ */ new Map());
4208
4322
  this.capacity = options.max ?? 500;
4209
4323
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
4210
4324
  }
4211
4325
  async getAll() {
4212
- return Object.fromEntries(__privateGet$3(this, _map));
4326
+ return Object.fromEntries(__privateGet$2(this, _map));
4213
4327
  }
4214
4328
  async get(key) {
4215
- return __privateGet$3(this, _map).get(key) ?? null;
4329
+ return __privateGet$2(this, _map).get(key) ?? null;
4216
4330
  }
4217
4331
  async set(key, value) {
4218
4332
  await this.delete(key);
4219
- __privateGet$3(this, _map).set(key, value);
4220
- if (__privateGet$3(this, _map).size > this.capacity) {
4221
- const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
4333
+ __privateGet$2(this, _map).set(key, value);
4334
+ if (__privateGet$2(this, _map).size > this.capacity) {
4335
+ const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
4222
4336
  await this.delete(leastRecentlyUsed);
4223
4337
  }
4224
4338
  }
4225
4339
  async delete(key) {
4226
- __privateGet$3(this, _map).delete(key);
4340
+ __privateGet$2(this, _map).delete(key);
4227
4341
  }
4228
4342
  async clear() {
4229
- return __privateGet$3(this, _map).clear();
4343
+ return __privateGet$2(this, _map).clear();
4230
4344
  }
4231
4345
  }
4232
4346
  _map = new WeakMap();
@@ -4263,7 +4377,7 @@ var __accessCheck$2 = (obj, member, msg) => {
4263
4377
  if (!member.has(obj))
4264
4378
  throw TypeError("Cannot " + msg);
4265
4379
  };
4266
- var __privateGet$2 = (obj, member, getter) => {
4380
+ var __privateGet$1 = (obj, member, getter) => {
4267
4381
  __accessCheck$2(obj, member, "read from private field");
4268
4382
  return getter ? getter.call(obj) : member.get(obj);
4269
4383
  };
@@ -4272,18 +4386,11 @@ var __privateAdd$2 = (obj, member, value) => {
4272
4386
  throw TypeError("Cannot add the same private member more than once");
4273
4387
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4274
4388
  };
4275
- var __privateSet$2 = (obj, member, value, setter) => {
4276
- __accessCheck$2(obj, member, "write to private field");
4277
- setter ? setter.call(obj, value) : member.set(obj, value);
4278
- return value;
4279
- };
4280
- var _tables, _schemaTables$1;
4389
+ var _tables;
4281
4390
  class SchemaPlugin extends XataPlugin {
4282
- constructor(schemaTables) {
4391
+ constructor() {
4283
4392
  super();
4284
4393
  __privateAdd$2(this, _tables, {});
4285
- __privateAdd$2(this, _schemaTables$1, void 0);
4286
- __privateSet$2(this, _schemaTables$1, schemaTables);
4287
4394
  }
4288
4395
  build(pluginOptions) {
4289
4396
  const db = new Proxy(
@@ -4292,22 +4399,21 @@ class SchemaPlugin extends XataPlugin {
4292
4399
  get: (_target, table) => {
4293
4400
  if (!isString(table))
4294
4401
  throw new Error("Invalid table name");
4295
- if (__privateGet$2(this, _tables)[table] === void 0) {
4296
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4402
+ if (__privateGet$1(this, _tables)[table] === void 0) {
4403
+ __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4297
4404
  }
4298
- return __privateGet$2(this, _tables)[table];
4405
+ return __privateGet$1(this, _tables)[table];
4299
4406
  }
4300
4407
  }
4301
4408
  );
4302
- const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
4409
+ const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
4303
4410
  for (const table of tableNames) {
4304
- db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4411
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4305
4412
  }
4306
4413
  return db;
4307
4414
  }
4308
4415
  }
4309
4416
  _tables = new WeakMap();
4310
- _schemaTables$1 = new WeakMap();
4311
4417
 
4312
4418
  class FilesPlugin extends XataPlugin {
4313
4419
  build(pluginOptions) {
@@ -4370,7 +4476,7 @@ function getContentType(file) {
4370
4476
  if (typeof file === "string") {
4371
4477
  return "text/plain";
4372
4478
  }
4373
- if ("mediaType" in file) {
4479
+ if ("mediaType" in file && file.mediaType !== void 0) {
4374
4480
  return file.mediaType;
4375
4481
  }
4376
4482
  if (isBlob(file)) {
@@ -4387,54 +4493,40 @@ var __accessCheck$1 = (obj, member, msg) => {
4387
4493
  if (!member.has(obj))
4388
4494
  throw TypeError("Cannot " + msg);
4389
4495
  };
4390
- var __privateGet$1 = (obj, member, getter) => {
4391
- __accessCheck$1(obj, member, "read from private field");
4392
- return getter ? getter.call(obj) : member.get(obj);
4393
- };
4394
4496
  var __privateAdd$1 = (obj, member, value) => {
4395
4497
  if (member.has(obj))
4396
4498
  throw TypeError("Cannot add the same private member more than once");
4397
4499
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4398
4500
  };
4399
- var __privateSet$1 = (obj, member, value, setter) => {
4400
- __accessCheck$1(obj, member, "write to private field");
4401
- setter ? setter.call(obj, value) : member.set(obj, value);
4402
- return value;
4403
- };
4404
4501
  var __privateMethod$1 = (obj, member, method) => {
4405
4502
  __accessCheck$1(obj, member, "access private method");
4406
4503
  return method;
4407
4504
  };
4408
- var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
4505
+ var _search, search_fn;
4409
4506
  class SearchPlugin extends XataPlugin {
4410
- constructor(db, schemaTables) {
4507
+ constructor(db) {
4411
4508
  super();
4412
4509
  this.db = db;
4413
4510
  __privateAdd$1(this, _search);
4414
- __privateAdd$1(this, _getSchemaTables);
4415
- __privateAdd$1(this, _schemaTables, void 0);
4416
- __privateSet$1(this, _schemaTables, schemaTables);
4417
4511
  }
4418
4512
  build(pluginOptions) {
4419
4513
  return {
4420
4514
  all: async (query, options = {}) => {
4421
4515
  const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4422
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4423
4516
  return {
4424
4517
  totalCount,
4425
4518
  records: records.map((record) => {
4426
4519
  const { table = "orphan" } = record.xata;
4427
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4520
+ return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
4428
4521
  })
4429
4522
  };
4430
4523
  },
4431
4524
  byTable: async (query, options = {}) => {
4432
4525
  const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4433
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4434
4526
  const records = rawRecords.reduce((acc, record) => {
4435
4527
  const { table = "orphan" } = record.xata;
4436
4528
  const items = acc[table] ?? [];
4437
- const item = initObject(this.db, schemaTables, table, record, ["*"]);
4529
+ const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
4438
4530
  return { ...acc, [table]: [...items, item] };
4439
4531
  }, {});
4440
4532
  return { totalCount, records };
@@ -4442,29 +4534,17 @@ class SearchPlugin extends XataPlugin {
4442
4534
  };
4443
4535
  }
4444
4536
  }
4445
- _schemaTables = new WeakMap();
4446
4537
  _search = new WeakSet();
4447
4538
  search_fn = async function(query, options, pluginOptions) {
4448
4539
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4449
4540
  const { records, totalCount } = await searchBranch({
4450
4541
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4451
- // @ts-ignore https://github.com/xataio/client-ts/issues/313
4542
+ // @ts-expect-error Filter properties do not match inferred type
4452
4543
  body: { tables, query, fuzziness, prefix, highlight, page },
4453
4544
  ...pluginOptions
4454
4545
  });
4455
4546
  return { records, totalCount };
4456
4547
  };
4457
- _getSchemaTables = new WeakSet();
4458
- getSchemaTables_fn = async function(pluginOptions) {
4459
- if (__privateGet$1(this, _schemaTables))
4460
- return __privateGet$1(this, _schemaTables);
4461
- const { schema } = await getBranchDetails({
4462
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4463
- ...pluginOptions
4464
- });
4465
- __privateSet$1(this, _schemaTables, schema.tables);
4466
- return schema.tables;
4467
- };
4468
4548
 
4469
4549
  function escapeElement(elementRepresentation) {
4470
4550
  const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -4518,25 +4598,68 @@ function prepareParams(param1, param2) {
4518
4598
  return { statement, params: param2?.map((value) => prepareValue(value)) };
4519
4599
  }
4520
4600
  if (isObject(param1)) {
4521
- const { statement, params, consistency } = param1;
4522
- return { statement, params: params?.map((value) => prepareValue(value)), consistency };
4601
+ const { statement, params, consistency, responseType } = param1;
4602
+ return { statement, params: params?.map((value) => prepareValue(value)), consistency, responseType };
4523
4603
  }
4524
4604
  throw new Error("Invalid query");
4525
4605
  }
4526
4606
 
4527
4607
  class SQLPlugin extends XataPlugin {
4528
4608
  build(pluginOptions) {
4529
- return async (param1, ...param2) => {
4530
- const { statement, params, consistency } = prepareParams(param1, param2);
4531
- const { records, warning } = await sqlQuery({
4609
+ const sqlFunction = async (query, ...parameters) => {
4610
+ if (!isParamsObject(query) && (!isTemplateStringsArray(query) || !Array.isArray(parameters))) {
4611
+ throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
4612
+ }
4613
+ const { statement, params, consistency, responseType } = prepareParams(query, parameters);
4614
+ const {
4615
+ records,
4616
+ rows,
4617
+ warning,
4618
+ columns = []
4619
+ } = await sqlQuery({
4532
4620
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4533
- body: { statement, params, consistency },
4621
+ body: { statement, params, consistency, responseType },
4534
4622
  ...pluginOptions
4535
4623
  });
4536
- return { records, warning };
4624
+ return { records, rows, warning, columns };
4537
4625
  };
4626
+ sqlFunction.connectionString = buildConnectionString(pluginOptions);
4627
+ return sqlFunction;
4538
4628
  }
4539
4629
  }
4630
+ function isTemplateStringsArray(strings) {
4631
+ return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
4632
+ }
4633
+ function isParamsObject(params) {
4634
+ return isObject(params) && "statement" in params;
4635
+ }
4636
+ function buildDomain(host, region) {
4637
+ switch (host) {
4638
+ case "production":
4639
+ return `${region}.sql.xata.sh`;
4640
+ case "staging":
4641
+ return `${region}.sql.staging-xata.dev`;
4642
+ case "dev":
4643
+ return `${region}.sql.dev-xata.dev`;
4644
+ case "local":
4645
+ return "localhost:7654";
4646
+ default:
4647
+ throw new Error("Invalid host provider");
4648
+ }
4649
+ }
4650
+ function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
4651
+ const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
4652
+ const parts = parseWorkspacesUrlParts(url);
4653
+ if (!parts)
4654
+ throw new Error("Invalid workspaces URL");
4655
+ const { workspace: workspaceSlug, region, database, host } = parts;
4656
+ const domain = buildDomain(host, region);
4657
+ const workspace = workspaceSlug.split("-").pop();
4658
+ if (!workspace || !region || !database || !apiKey || !branch) {
4659
+ throw new Error("Unable to build xata connection string");
4660
+ }
4661
+ return `postgresql://${workspace}:${apiKey}@${domain}/${database}:${branch}?sslmode=require`;
4662
+ }
4540
4663
 
4541
4664
  class TransactionPlugin extends XataPlugin {
4542
4665
  build(pluginOptions) {
@@ -4578,7 +4701,7 @@ var __privateMethod = (obj, member, method) => {
4578
4701
  const buildClient = (plugins) => {
4579
4702
  var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
4580
4703
  return _a = class {
4581
- constructor(options = {}, schemaTables) {
4704
+ constructor(options = {}, tables) {
4582
4705
  __privateAdd(this, _parseOptions);
4583
4706
  __privateAdd(this, _getFetchProps);
4584
4707
  __privateAdd(this, _options, void 0);
@@ -4587,13 +4710,16 @@ const buildClient = (plugins) => {
4587
4710
  const pluginOptions = {
4588
4711
  ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4589
4712
  cache: safeOptions.cache,
4590
- host: safeOptions.host
4713
+ host: safeOptions.host,
4714
+ tables,
4715
+ branch: safeOptions.branch
4591
4716
  };
4592
- const db = new SchemaPlugin(schemaTables).build(pluginOptions);
4593
- const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4717
+ const db = new SchemaPlugin().build(pluginOptions);
4718
+ const search = new SearchPlugin(db).build(pluginOptions);
4594
4719
  const transactions = new TransactionPlugin().build(pluginOptions);
4595
4720
  const sql = new SQLPlugin().build(pluginOptions);
4596
4721
  const files = new FilesPlugin().build(pluginOptions);
4722
+ this.schema = { tables };
4597
4723
  this.db = db;
4598
4724
  this.search = search;
4599
4725
  this.transactions = transactions;
@@ -4615,7 +4741,7 @@ const buildClient = (plugins) => {
4615
4741
  const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
4616
4742
  if (isBrowser && !enableBrowser) {
4617
4743
  throw new Error(
4618
- "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."
4744
+ "You are trying to use Xata from the browser, which is potentially a non-secure environment. How to fix: https://xata.io/docs/messages/api-key-browser-error"
4619
4745
  );
4620
4746
  }
4621
4747
  const fetch = getFetchImplementation(options?.fetch);
@@ -4769,5 +4895,5 @@ class XataError extends Error {
4769
4895
  }
4770
4896
  }
4771
4897
 
4772
- export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, pgRollStatus, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
4898
+ export { BaseClient, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, PageRecordArray, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, adaptAllTables, adaptTable, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationJobStatus, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseSettings, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationHistory, getMigrationJobStatus, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspaceSettings, 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, 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, updateDatabaseSettings, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, updateWorkspaceSettings, upsertRecordWithID, vectorSearchTable };
4773
4899
  //# sourceMappingURL=index.mjs.map