@xata.io/client 0.29.0 → 0.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -248,7 +248,7 @@ var __accessCheck$8 = (obj, member, msg) => {
248
248
  if (!member.has(obj))
249
249
  throw TypeError("Cannot " + msg);
250
250
  };
251
- var __privateGet$8 = (obj, member, getter) => {
251
+ var __privateGet$7 = (obj, member, getter) => {
252
252
  __accessCheck$8(obj, member, "read from private field");
253
253
  return getter ? getter.call(obj) : member.get(obj);
254
254
  };
@@ -257,7 +257,7 @@ var __privateAdd$8 = (obj, member, value) => {
257
257
  throw TypeError("Cannot add the same private member more than once");
258
258
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
259
259
  };
260
- var __privateSet$8 = (obj, member, value, setter) => {
260
+ var __privateSet$6 = (obj, member, value, setter) => {
261
261
  __accessCheck$8(obj, member, "write to private field");
262
262
  setter ? setter.call(obj, value) : member.set(obj, value);
263
263
  return value;
@@ -283,19 +283,19 @@ class ApiRequestPool {
283
283
  __privateAdd$8(this, _fetch, void 0);
284
284
  __privateAdd$8(this, _queue, void 0);
285
285
  __privateAdd$8(this, _concurrency, void 0);
286
- __privateSet$8(this, _queue, []);
287
- __privateSet$8(this, _concurrency, concurrency);
286
+ __privateSet$6(this, _queue, []);
287
+ __privateSet$6(this, _concurrency, concurrency);
288
288
  this.running = 0;
289
289
  this.started = 0;
290
290
  }
291
291
  setFetch(fetch2) {
292
- __privateSet$8(this, _fetch, fetch2);
292
+ __privateSet$6(this, _fetch, fetch2);
293
293
  }
294
294
  getFetch() {
295
- if (!__privateGet$8(this, _fetch)) {
295
+ if (!__privateGet$7(this, _fetch)) {
296
296
  throw new Error("Fetch not set");
297
297
  }
298
- return __privateGet$8(this, _fetch);
298
+ return __privateGet$7(this, _fetch);
299
299
  }
300
300
  request(url, options) {
301
301
  const start = /* @__PURE__ */ new Date();
@@ -327,19 +327,19 @@ _queue = new WeakMap();
327
327
  _concurrency = new WeakMap();
328
328
  _enqueue = new WeakSet();
329
329
  enqueue_fn = function(task) {
330
- const promise = new Promise((resolve) => __privateGet$8(this, _queue).push(resolve)).finally(() => {
330
+ const promise = new Promise((resolve) => __privateGet$7(this, _queue).push(resolve)).finally(() => {
331
331
  this.started--;
332
332
  this.running++;
333
333
  }).then(() => task()).finally(() => {
334
334
  this.running--;
335
- const next = __privateGet$8(this, _queue).shift();
335
+ const next = __privateGet$7(this, _queue).shift();
336
336
  if (next !== void 0) {
337
337
  this.started++;
338
338
  next();
339
339
  }
340
340
  });
341
- if (this.running + this.started < __privateGet$8(this, _concurrency)) {
342
- const next = __privateGet$8(this, _queue).shift();
341
+ if (this.running + this.started < __privateGet$7(this, _concurrency)) {
342
+ const next = __privateGet$7(this, _queue).shift();
343
343
  if (next !== void 0) {
344
344
  this.started++;
345
345
  next();
@@ -528,7 +528,7 @@ function defaultOnOpen(response) {
528
528
  }
529
529
  }
530
530
 
531
- const VERSION = "0.29.0";
531
+ const VERSION = "0.29.2";
532
532
 
533
533
  class ErrorWithCause extends Error {
534
534
  constructor(message, options) {
@@ -847,26 +847,29 @@ function parseUrl(url) {
847
847
 
848
848
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
849
849
 
850
- const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/apply", method: "post", ...variables, signal });
851
- const pgRollStatus = (variables, signal) => dataPlaneFetch({
852
- url: "/db/{dbBranchName}/pgroll/status",
853
- method: "get",
850
+ const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/apply", method: "post", ...variables, signal });
851
+ const adaptTable = (variables, signal) => dataPlaneFetch({
852
+ url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
853
+ method: "post",
854
854
  ...variables,
855
855
  signal
856
856
  });
857
- const pgRollJobStatus = (variables, signal) => dataPlaneFetch({
858
- url: "/db/{dbBranchName}/pgroll/jobs/{jobId}",
857
+ const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/status", method: "get", ...variables, signal });
858
+ const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/jobs/{jobId}", method: "get", ...variables, signal });
859
+ const getMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/history", method: "get", ...variables, signal });
860
+ const getBranchList = (variables, signal) => dataPlaneFetch({
861
+ url: "/dbs/{dbName}",
859
862
  method: "get",
860
863
  ...variables,
861
864
  signal
862
865
  });
863
- const pgRollMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/pgroll/migrations", method: "get", ...variables, signal });
864
- const getBranchList = (variables, signal) => dataPlaneFetch({
865
- url: "/dbs/{dbName}",
866
+ const getDatabaseSettings = (variables, signal) => dataPlaneFetch({
867
+ url: "/dbs/{dbName}/settings",
866
868
  method: "get",
867
869
  ...variables,
868
870
  signal
869
871
  });
872
+ const updateDatabaseSettings = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/settings", method: "patch", ...variables, signal });
870
873
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
871
874
  url: "/db/{dbBranchName}",
872
875
  method: "get",
@@ -1080,11 +1083,25 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
1080
1083
  signal
1081
1084
  });
1082
1085
  const operationsByTag$2 = {
1083
- branch: {
1086
+ migrations: {
1084
1087
  applyMigration,
1085
- pgRollStatus,
1086
- pgRollJobStatus,
1087
- pgRollMigrationHistory,
1088
+ adaptTable,
1089
+ getBranchMigrationJobStatus,
1090
+ getMigrationJobStatus,
1091
+ getMigrationHistory,
1092
+ getSchema,
1093
+ getBranchMigrationHistory,
1094
+ getBranchMigrationPlan,
1095
+ executeBranchMigrationPlan,
1096
+ getBranchSchemaHistory,
1097
+ compareBranchWithUserSchema,
1098
+ compareBranchSchemas,
1099
+ updateBranchSchema,
1100
+ previewBranchSchemaEdit,
1101
+ applyBranchSchemaEdit,
1102
+ pushBranchMigrations
1103
+ },
1104
+ branch: {
1088
1105
  getBranchList,
1089
1106
  getBranchDetails,
1090
1107
  createBranch,
@@ -1098,19 +1115,7 @@ const operationsByTag$2 = {
1098
1115
  removeGitBranchesEntry,
1099
1116
  resolveBranch
1100
1117
  },
1101
- migrations: {
1102
- getSchema,
1103
- getBranchMigrationHistory,
1104
- getBranchMigrationPlan,
1105
- executeBranchMigrationPlan,
1106
- getBranchSchemaHistory,
1107
- compareBranchWithUserSchema,
1108
- compareBranchSchemas,
1109
- updateBranchSchema,
1110
- previewBranchSchemaEdit,
1111
- applyBranchSchemaEdit,
1112
- pushBranchMigrations
1113
- },
1118
+ database: { getDatabaseSettings, updateDatabaseSettings },
1114
1119
  migrationRequests: {
1115
1120
  queryMigrationRequests,
1116
1121
  createMigrationRequest,
@@ -1349,7 +1354,7 @@ var __accessCheck$7 = (obj, member, msg) => {
1349
1354
  if (!member.has(obj))
1350
1355
  throw TypeError("Cannot " + msg);
1351
1356
  };
1352
- var __privateGet$7 = (obj, member, getter) => {
1357
+ var __privateGet$6 = (obj, member, getter) => {
1353
1358
  __accessCheck$7(obj, member, "read from private field");
1354
1359
  return getter ? getter.call(obj) : member.get(obj);
1355
1360
  };
@@ -1358,7 +1363,7 @@ var __privateAdd$7 = (obj, member, value) => {
1358
1363
  throw TypeError("Cannot add the same private member more than once");
1359
1364
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1360
1365
  };
1361
- var __privateSet$7 = (obj, member, value, setter) => {
1366
+ var __privateSet$5 = (obj, member, value, setter) => {
1362
1367
  __accessCheck$7(obj, member, "write to private field");
1363
1368
  setter ? setter.call(obj, value) : member.set(obj, value);
1364
1369
  return value;
@@ -1375,7 +1380,7 @@ class XataApiClient {
1375
1380
  if (!apiKey) {
1376
1381
  throw new Error("Could not resolve a valid apiKey");
1377
1382
  }
1378
- __privateSet$7(this, _extraProps, {
1383
+ __privateSet$5(this, _extraProps, {
1379
1384
  apiUrl: getHostUrl(provider, "main"),
1380
1385
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
1381
1386
  fetch: getFetchImplementation(options.fetch),
@@ -1387,64 +1392,64 @@ class XataApiClient {
1387
1392
  });
1388
1393
  }
1389
1394
  get user() {
1390
- if (!__privateGet$7(this, _namespaces).user)
1391
- __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
1392
- return __privateGet$7(this, _namespaces).user;
1395
+ if (!__privateGet$6(this, _namespaces).user)
1396
+ __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
1397
+ return __privateGet$6(this, _namespaces).user;
1393
1398
  }
1394
1399
  get authentication() {
1395
- if (!__privateGet$7(this, _namespaces).authentication)
1396
- __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
1397
- return __privateGet$7(this, _namespaces).authentication;
1400
+ if (!__privateGet$6(this, _namespaces).authentication)
1401
+ __privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
1402
+ return __privateGet$6(this, _namespaces).authentication;
1398
1403
  }
1399
1404
  get workspaces() {
1400
- if (!__privateGet$7(this, _namespaces).workspaces)
1401
- __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
1402
- return __privateGet$7(this, _namespaces).workspaces;
1405
+ if (!__privateGet$6(this, _namespaces).workspaces)
1406
+ __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
1407
+ return __privateGet$6(this, _namespaces).workspaces;
1403
1408
  }
1404
1409
  get invites() {
1405
- if (!__privateGet$7(this, _namespaces).invites)
1406
- __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
1407
- return __privateGet$7(this, _namespaces).invites;
1410
+ if (!__privateGet$6(this, _namespaces).invites)
1411
+ __privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
1412
+ return __privateGet$6(this, _namespaces).invites;
1408
1413
  }
1409
1414
  get database() {
1410
- if (!__privateGet$7(this, _namespaces).database)
1411
- __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
1412
- return __privateGet$7(this, _namespaces).database;
1415
+ if (!__privateGet$6(this, _namespaces).database)
1416
+ __privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
1417
+ return __privateGet$6(this, _namespaces).database;
1413
1418
  }
1414
1419
  get branches() {
1415
- if (!__privateGet$7(this, _namespaces).branches)
1416
- __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
1417
- return __privateGet$7(this, _namespaces).branches;
1420
+ if (!__privateGet$6(this, _namespaces).branches)
1421
+ __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
1422
+ return __privateGet$6(this, _namespaces).branches;
1418
1423
  }
1419
1424
  get migrations() {
1420
- if (!__privateGet$7(this, _namespaces).migrations)
1421
- __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
1422
- return __privateGet$7(this, _namespaces).migrations;
1425
+ if (!__privateGet$6(this, _namespaces).migrations)
1426
+ __privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
1427
+ return __privateGet$6(this, _namespaces).migrations;
1423
1428
  }
1424
1429
  get migrationRequests() {
1425
- if (!__privateGet$7(this, _namespaces).migrationRequests)
1426
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
1427
- return __privateGet$7(this, _namespaces).migrationRequests;
1430
+ if (!__privateGet$6(this, _namespaces).migrationRequests)
1431
+ __privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
1432
+ return __privateGet$6(this, _namespaces).migrationRequests;
1428
1433
  }
1429
1434
  get tables() {
1430
- if (!__privateGet$7(this, _namespaces).tables)
1431
- __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
1432
- return __privateGet$7(this, _namespaces).tables;
1435
+ if (!__privateGet$6(this, _namespaces).tables)
1436
+ __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
1437
+ return __privateGet$6(this, _namespaces).tables;
1433
1438
  }
1434
1439
  get records() {
1435
- if (!__privateGet$7(this, _namespaces).records)
1436
- __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
1437
- return __privateGet$7(this, _namespaces).records;
1440
+ if (!__privateGet$6(this, _namespaces).records)
1441
+ __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
1442
+ return __privateGet$6(this, _namespaces).records;
1438
1443
  }
1439
1444
  get files() {
1440
- if (!__privateGet$7(this, _namespaces).files)
1441
- __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1442
- return __privateGet$7(this, _namespaces).files;
1445
+ if (!__privateGet$6(this, _namespaces).files)
1446
+ __privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
1447
+ return __privateGet$6(this, _namespaces).files;
1443
1448
  }
1444
1449
  get searchAndFilter() {
1445
- if (!__privateGet$7(this, _namespaces).searchAndFilter)
1446
- __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
1447
- return __privateGet$7(this, _namespaces).searchAndFilter;
1450
+ if (!__privateGet$6(this, _namespaces).searchAndFilter)
1451
+ __privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
1452
+ return __privateGet$6(this, _namespaces).searchAndFilter;
1448
1453
  }
1449
1454
  }
1450
1455
  _extraProps = new WeakMap();
@@ -1746,6 +1751,30 @@ class BranchApi {
1746
1751
  ...this.extraProps
1747
1752
  });
1748
1753
  }
1754
+ pgRollMigrationHistory({
1755
+ workspace,
1756
+ region,
1757
+ database,
1758
+ branch
1759
+ }) {
1760
+ return operationsByTag.migrations.getMigrationHistory({
1761
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1762
+ ...this.extraProps
1763
+ });
1764
+ }
1765
+ applyMigration({
1766
+ workspace,
1767
+ region,
1768
+ database,
1769
+ branch,
1770
+ migration
1771
+ }) {
1772
+ return operationsByTag.migrations.applyMigration({
1773
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1774
+ body: migration,
1775
+ ...this.extraProps
1776
+ });
1777
+ }
1749
1778
  }
1750
1779
  class TableApi {
1751
1780
  constructor(extraProps) {
@@ -2559,6 +2588,17 @@ class MigrationsApi {
2559
2588
  ...this.extraProps
2560
2589
  });
2561
2590
  }
2591
+ getSchema({
2592
+ workspace,
2593
+ region,
2594
+ database,
2595
+ branch
2596
+ }) {
2597
+ return operationsByTag.migrations.getSchema({
2598
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2599
+ ...this.extraProps
2600
+ });
2601
+ }
2562
2602
  }
2563
2603
  class DatabaseApi {
2564
2604
  constructor(extraProps) {
@@ -2864,7 +2904,7 @@ var __accessCheck$6 = (obj, member, msg) => {
2864
2904
  if (!member.has(obj))
2865
2905
  throw TypeError("Cannot " + msg);
2866
2906
  };
2867
- var __privateGet$6 = (obj, member, getter) => {
2907
+ var __privateGet$5 = (obj, member, getter) => {
2868
2908
  __accessCheck$6(obj, member, "read from private field");
2869
2909
  return getter ? getter.call(obj) : member.get(obj);
2870
2910
  };
@@ -2873,7 +2913,7 @@ var __privateAdd$6 = (obj, member, value) => {
2873
2913
  throw TypeError("Cannot add the same private member more than once");
2874
2914
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2875
2915
  };
2876
- var __privateSet$6 = (obj, member, value, setter) => {
2916
+ var __privateSet$4 = (obj, member, value, setter) => {
2877
2917
  __accessCheck$6(obj, member, "write to private field");
2878
2918
  setter ? setter.call(obj, value) : member.set(obj, value);
2879
2919
  return value;
@@ -2882,9 +2922,9 @@ var _query, _page;
2882
2922
  class Page {
2883
2923
  constructor(query, meta, records = []) {
2884
2924
  __privateAdd$6(this, _query, void 0);
2885
- __privateSet$6(this, _query, query);
2925
+ __privateSet$4(this, _query, query);
2886
2926
  this.meta = meta;
2887
- this.records = new RecordArray(this, records);
2927
+ this.records = new PageRecordArray(this, records);
2888
2928
  }
2889
2929
  /**
2890
2930
  * Retrieves the next page of results.
@@ -2893,7 +2933,7 @@ class Page {
2893
2933
  * @returns The next page or results.
2894
2934
  */
2895
2935
  async nextPage(size, offset) {
2896
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2936
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2897
2937
  }
2898
2938
  /**
2899
2939
  * Retrieves the previous page of results.
@@ -2902,7 +2942,7 @@ class Page {
2902
2942
  * @returns The previous page or results.
2903
2943
  */
2904
2944
  async previousPage(size, offset) {
2905
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2945
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2906
2946
  }
2907
2947
  /**
2908
2948
  * Retrieves the start page of results.
@@ -2911,7 +2951,7 @@ class Page {
2911
2951
  * @returns The start page or results.
2912
2952
  */
2913
2953
  async startPage(size, offset) {
2914
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2954
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2915
2955
  }
2916
2956
  /**
2917
2957
  * Retrieves the end page of results.
@@ -2920,7 +2960,7 @@ class Page {
2920
2960
  * @returns The end page or results.
2921
2961
  */
2922
2962
  async endPage(size, offset) {
2923
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2963
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2924
2964
  }
2925
2965
  /**
2926
2966
  * Shortcut method to check if there will be additional results if the next page of results is retrieved.
@@ -2938,11 +2978,38 @@ const PAGINATION_DEFAULT_OFFSET = 0;
2938
2978
  function isCursorPaginationOptions(options) {
2939
2979
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
2940
2980
  }
2941
- const _RecordArray = class _RecordArray extends Array {
2981
+ class RecordArray extends Array {
2942
2982
  constructor(...args) {
2943
- super(..._RecordArray.parseConstructorParams(...args));
2983
+ super(...RecordArray.parseConstructorParams(...args));
2984
+ }
2985
+ static parseConstructorParams(...args) {
2986
+ if (args.length === 1 && typeof args[0] === "number") {
2987
+ return new Array(args[0]);
2988
+ }
2989
+ if (args.length <= 1 && Array.isArray(args[0] ?? [])) {
2990
+ const result = args[0] ?? [];
2991
+ return new Array(...result);
2992
+ }
2993
+ return new Array(...args);
2994
+ }
2995
+ toArray() {
2996
+ return new Array(...this);
2997
+ }
2998
+ toSerializable() {
2999
+ return JSON.parse(this.toString());
3000
+ }
3001
+ toString() {
3002
+ return JSON.stringify(this.toArray());
3003
+ }
3004
+ map(callbackfn, thisArg) {
3005
+ return this.toArray().map(callbackfn, thisArg);
3006
+ }
3007
+ }
3008
+ const _PageRecordArray = class _PageRecordArray extends Array {
3009
+ constructor(...args) {
3010
+ super(..._PageRecordArray.parseConstructorParams(...args));
2944
3011
  __privateAdd$6(this, _page, void 0);
2945
- __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
3012
+ __privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
2946
3013
  }
2947
3014
  static parseConstructorParams(...args) {
2948
3015
  if (args.length === 1 && typeof args[0] === "number") {
@@ -2972,8 +3039,8 @@ const _RecordArray = class _RecordArray extends Array {
2972
3039
  * @returns A new array of objects
2973
3040
  */
2974
3041
  async nextPage(size, offset) {
2975
- const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
2976
- return new _RecordArray(newPage);
3042
+ const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
3043
+ return new _PageRecordArray(newPage);
2977
3044
  }
2978
3045
  /**
2979
3046
  * Retrieve previous page of records
@@ -2981,8 +3048,8 @@ const _RecordArray = class _RecordArray extends Array {
2981
3048
  * @returns A new array of objects
2982
3049
  */
2983
3050
  async previousPage(size, offset) {
2984
- const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
2985
- return new _RecordArray(newPage);
3051
+ const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
3052
+ return new _PageRecordArray(newPage);
2986
3053
  }
2987
3054
  /**
2988
3055
  * Retrieve start page of records
@@ -2990,8 +3057,8 @@ const _RecordArray = class _RecordArray extends Array {
2990
3057
  * @returns A new array of objects
2991
3058
  */
2992
3059
  async startPage(size, offset) {
2993
- const newPage = await __privateGet$6(this, _page).startPage(size, offset);
2994
- return new _RecordArray(newPage);
3060
+ const newPage = await __privateGet$5(this, _page).startPage(size, offset);
3061
+ return new _PageRecordArray(newPage);
2995
3062
  }
2996
3063
  /**
2997
3064
  * Retrieve end page of records
@@ -2999,24 +3066,24 @@ const _RecordArray = class _RecordArray extends Array {
2999
3066
  * @returns A new array of objects
3000
3067
  */
3001
3068
  async endPage(size, offset) {
3002
- const newPage = await __privateGet$6(this, _page).endPage(size, offset);
3003
- return new _RecordArray(newPage);
3069
+ const newPage = await __privateGet$5(this, _page).endPage(size, offset);
3070
+ return new _PageRecordArray(newPage);
3004
3071
  }
3005
3072
  /**
3006
3073
  * @returns Boolean indicating if there is a next page
3007
3074
  */
3008
3075
  hasNextPage() {
3009
- return __privateGet$6(this, _page).meta.page.more;
3076
+ return __privateGet$5(this, _page).meta.page.more;
3010
3077
  }
3011
3078
  };
3012
3079
  _page = new WeakMap();
3013
- let RecordArray = _RecordArray;
3080
+ let PageRecordArray = _PageRecordArray;
3014
3081
 
3015
3082
  var __accessCheck$5 = (obj, member, msg) => {
3016
3083
  if (!member.has(obj))
3017
3084
  throw TypeError("Cannot " + msg);
3018
3085
  };
3019
- var __privateGet$5 = (obj, member, getter) => {
3086
+ var __privateGet$4 = (obj, member, getter) => {
3020
3087
  __accessCheck$5(obj, member, "read from private field");
3021
3088
  return getter ? getter.call(obj) : member.get(obj);
3022
3089
  };
@@ -3025,7 +3092,7 @@ var __privateAdd$5 = (obj, member, value) => {
3025
3092
  throw TypeError("Cannot add the same private member more than once");
3026
3093
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3027
3094
  };
3028
- var __privateSet$5 = (obj, member, value, setter) => {
3095
+ var __privateSet$3 = (obj, member, value, setter) => {
3029
3096
  __accessCheck$5(obj, member, "write to private field");
3030
3097
  setter ? setter.call(obj, value) : member.set(obj, value);
3031
3098
  return value;
@@ -3043,25 +3110,25 @@ const _Query = class _Query {
3043
3110
  __privateAdd$5(this, _data, { filter: {} });
3044
3111
  // Implements pagination
3045
3112
  this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3046
- this.records = new RecordArray(this, []);
3047
- __privateSet$5(this, _table$1, table);
3113
+ this.records = new PageRecordArray(this, []);
3114
+ __privateSet$3(this, _table$1, table);
3048
3115
  if (repository) {
3049
- __privateSet$5(this, _repository, repository);
3116
+ __privateSet$3(this, _repository, repository);
3050
3117
  } else {
3051
- __privateSet$5(this, _repository, this);
3118
+ __privateSet$3(this, _repository, this);
3052
3119
  }
3053
3120
  const parent = cleanParent(data, rawParent);
3054
- __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
3055
- __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3056
- __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3057
- __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3058
- __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3059
- __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
3060
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
3061
- __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
3062
- __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
3063
- __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
3064
- __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3121
+ __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
3122
+ __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3123
+ __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3124
+ __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3125
+ __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3126
+ __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
3127
+ __privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
3128
+ __privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
3129
+ __privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
3130
+ __privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
3131
+ __privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3065
3132
  this.any = this.any.bind(this);
3066
3133
  this.all = this.all.bind(this);
3067
3134
  this.not = this.not.bind(this);
@@ -3072,10 +3139,10 @@ const _Query = class _Query {
3072
3139
  Object.defineProperty(this, "repository", { enumerable: false });
3073
3140
  }
3074
3141
  getQueryOptions() {
3075
- return __privateGet$5(this, _data);
3142
+ return __privateGet$4(this, _data);
3076
3143
  }
3077
3144
  key() {
3078
- const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
3145
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
3079
3146
  const key = JSON.stringify({ columns, filter, sort, pagination });
3080
3147
  return toBase64(key);
3081
3148
  }
@@ -3086,7 +3153,7 @@ const _Query = class _Query {
3086
3153
  */
3087
3154
  any(...queries) {
3088
3155
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
3089
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
3156
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
3090
3157
  }
3091
3158
  /**
3092
3159
  * Builds a new query object representing a logical AND between the given subqueries.
@@ -3095,7 +3162,7 @@ const _Query = class _Query {
3095
3162
  */
3096
3163
  all(...queries) {
3097
3164
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
3098
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3165
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3099
3166
  }
3100
3167
  /**
3101
3168
  * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
@@ -3104,7 +3171,7 @@ const _Query = class _Query {
3104
3171
  */
3105
3172
  not(...queries) {
3106
3173
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
3107
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
3174
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
3108
3175
  }
3109
3176
  /**
3110
3177
  * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
@@ -3113,25 +3180,25 @@ const _Query = class _Query {
3113
3180
  */
3114
3181
  none(...queries) {
3115
3182
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
3116
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
3183
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
3117
3184
  }
3118
3185
  filter(a, b) {
3119
3186
  if (arguments.length === 1) {
3120
3187
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
3121
3188
  [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
3122
3189
  }));
3123
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3124
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3190
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3191
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3125
3192
  } else {
3126
3193
  const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3127
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3128
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3194
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3195
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3129
3196
  }
3130
3197
  }
3131
3198
  sort(column, direction = "asc") {
3132
- const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
3199
+ const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
3133
3200
  const sort = [...originalSort, { column, direction }];
3134
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
3201
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
3135
3202
  }
3136
3203
  /**
3137
3204
  * Builds a new query specifying the set of columns to be returned in the query response.
@@ -3140,15 +3207,15 @@ const _Query = class _Query {
3140
3207
  */
3141
3208
  select(columns) {
3142
3209
  return new _Query(
3143
- __privateGet$5(this, _repository),
3144
- __privateGet$5(this, _table$1),
3210
+ __privateGet$4(this, _repository),
3211
+ __privateGet$4(this, _table$1),
3145
3212
  { columns },
3146
- __privateGet$5(this, _data)
3213
+ __privateGet$4(this, _data)
3147
3214
  );
3148
3215
  }
3149
3216
  getPaginated(options = {}) {
3150
- const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
3151
- return __privateGet$5(this, _repository).query(query);
3217
+ const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
3218
+ return __privateGet$4(this, _repository).query(query);
3152
3219
  }
3153
3220
  /**
3154
3221
  * Get results in an iterator
@@ -3185,7 +3252,7 @@ const _Query = class _Query {
3185
3252
  if (page.hasNextPage() && options.pagination?.size === void 0) {
3186
3253
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
3187
3254
  }
3188
- const array = new RecordArray(page, results.slice(0, size));
3255
+ const array = new PageRecordArray(page, results.slice(0, size));
3189
3256
  return array;
3190
3257
  }
3191
3258
  async getAll(options = {}) {
@@ -3194,7 +3261,7 @@ const _Query = class _Query {
3194
3261
  for await (const page of this.getIterator({ ...rest, batchSize })) {
3195
3262
  results.push(...page);
3196
3263
  }
3197
- return results;
3264
+ return new RecordArray(results);
3198
3265
  }
3199
3266
  async getFirst(options = {}) {
3200
3267
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
@@ -3209,12 +3276,12 @@ const _Query = class _Query {
3209
3276
  async summarize(params = {}) {
3210
3277
  const { summaries, summariesFilter, ...options } = params;
3211
3278
  const query = new _Query(
3212
- __privateGet$5(this, _repository),
3213
- __privateGet$5(this, _table$1),
3279
+ __privateGet$4(this, _repository),
3280
+ __privateGet$4(this, _table$1),
3214
3281
  options,
3215
- __privateGet$5(this, _data)
3282
+ __privateGet$4(this, _data)
3216
3283
  );
3217
- return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
3284
+ return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
3218
3285
  }
3219
3286
  /**
3220
3287
  * Builds a new query object adding a cache TTL in milliseconds.
@@ -3222,7 +3289,7 @@ const _Query = class _Query {
3222
3289
  * @returns A new Query object.
3223
3290
  */
3224
3291
  cache(ttl) {
3225
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
3292
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
3226
3293
  }
3227
3294
  /**
3228
3295
  * Retrieve next page of records
@@ -3268,7 +3335,7 @@ _repository = new WeakMap();
3268
3335
  _data = new WeakMap();
3269
3336
  _cleanFilterConstraint = new WeakSet();
3270
3337
  cleanFilterConstraint_fn = function(column, value) {
3271
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3338
+ const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3272
3339
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
3273
3340
  return { $includes: value };
3274
3341
  }
@@ -3358,7 +3425,7 @@ var __accessCheck$4 = (obj, member, msg) => {
3358
3425
  if (!member.has(obj))
3359
3426
  throw TypeError("Cannot " + msg);
3360
3427
  };
3361
- var __privateGet$4 = (obj, member, getter) => {
3428
+ var __privateGet$3 = (obj, member, getter) => {
3362
3429
  __accessCheck$4(obj, member, "read from private field");
3363
3430
  return getter ? getter.call(obj) : member.get(obj);
3364
3431
  };
@@ -3367,7 +3434,7 @@ var __privateAdd$4 = (obj, member, value) => {
3367
3434
  throw TypeError("Cannot add the same private member more than once");
3368
3435
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3369
3436
  };
3370
- var __privateSet$4 = (obj, member, value, setter) => {
3437
+ var __privateSet$2 = (obj, member, value, setter) => {
3371
3438
  __accessCheck$4(obj, member, "write to private field");
3372
3439
  setter ? setter.call(obj, value) : member.set(obj, value);
3373
3440
  return value;
@@ -3376,7 +3443,7 @@ var __privateMethod$2 = (obj, member, method) => {
3376
3443
  __accessCheck$4(obj, member, "access private method");
3377
3444
  return method;
3378
3445
  };
3379
- 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;
3446
+ 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;
3380
3447
  const BULK_OPERATION_MAX_SIZE = 1e3;
3381
3448
  class Repository extends Query {
3382
3449
  }
@@ -3397,31 +3464,31 @@ class RestRepository extends Query {
3397
3464
  __privateAdd$4(this, _deleteRecords);
3398
3465
  __privateAdd$4(this, _setCacheQuery);
3399
3466
  __privateAdd$4(this, _getCacheQuery);
3400
- __privateAdd$4(this, _getSchemaTables$1);
3467
+ __privateAdd$4(this, _getSchemaTables);
3401
3468
  __privateAdd$4(this, _transformObjectToApi);
3402
3469
  __privateAdd$4(this, _table, void 0);
3403
3470
  __privateAdd$4(this, _getFetchProps, void 0);
3404
3471
  __privateAdd$4(this, _db, void 0);
3405
3472
  __privateAdd$4(this, _cache, void 0);
3406
- __privateAdd$4(this, _schemaTables$2, void 0);
3473
+ __privateAdd$4(this, _schemaTables, void 0);
3407
3474
  __privateAdd$4(this, _trace, void 0);
3408
- __privateSet$4(this, _table, options.table);
3409
- __privateSet$4(this, _db, options.db);
3410
- __privateSet$4(this, _cache, options.pluginOptions.cache);
3411
- __privateSet$4(this, _schemaTables$2, options.schemaTables);
3412
- __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3475
+ __privateSet$2(this, _table, options.table);
3476
+ __privateSet$2(this, _db, options.db);
3477
+ __privateSet$2(this, _cache, options.pluginOptions.cache);
3478
+ __privateSet$2(this, _schemaTables, options.schemaTables);
3479
+ __privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3413
3480
  const trace = options.pluginOptions.trace ?? defaultTrace;
3414
- __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
3481
+ __privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
3415
3482
  return trace(name, fn, {
3416
3483
  ...options2,
3417
- [TraceAttributes.TABLE]: __privateGet$4(this, _table),
3484
+ [TraceAttributes.TABLE]: __privateGet$3(this, _table),
3418
3485
  [TraceAttributes.KIND]: "sdk-operation",
3419
3486
  [TraceAttributes.VERSION]: VERSION
3420
3487
  });
3421
3488
  });
3422
3489
  }
3423
3490
  async create(a, b, c, d) {
3424
- return __privateGet$4(this, _trace).call(this, "create", async () => {
3491
+ return __privateGet$3(this, _trace).call(this, "create", async () => {
3425
3492
  const ifVersion = parseIfVersion(b, c, d);
3426
3493
  if (Array.isArray(a)) {
3427
3494
  if (a.length === 0)
@@ -3451,7 +3518,7 @@ class RestRepository extends Query {
3451
3518
  });
3452
3519
  }
3453
3520
  async read(a, b) {
3454
- return __privateGet$4(this, _trace).call(this, "read", async () => {
3521
+ return __privateGet$3(this, _trace).call(this, "read", async () => {
3455
3522
  const columns = isValidSelectableColumns(b) ? b : ["*"];
3456
3523
  if (Array.isArray(a)) {
3457
3524
  if (a.length === 0)
@@ -3472,17 +3539,17 @@ class RestRepository extends Query {
3472
3539
  workspace: "{workspaceId}",
3473
3540
  dbBranchName: "{dbBranch}",
3474
3541
  region: "{region}",
3475
- tableName: __privateGet$4(this, _table),
3542
+ tableName: __privateGet$3(this, _table),
3476
3543
  recordId: id
3477
3544
  },
3478
3545
  queryParams: { columns },
3479
- ...__privateGet$4(this, _getFetchProps).call(this)
3546
+ ...__privateGet$3(this, _getFetchProps).call(this)
3480
3547
  });
3481
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3548
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3482
3549
  return initObject(
3483
- __privateGet$4(this, _db),
3550
+ __privateGet$3(this, _db),
3484
3551
  schemaTables,
3485
- __privateGet$4(this, _table),
3552
+ __privateGet$3(this, _table),
3486
3553
  response,
3487
3554
  columns
3488
3555
  );
@@ -3497,7 +3564,7 @@ class RestRepository extends Query {
3497
3564
  });
3498
3565
  }
3499
3566
  async readOrThrow(a, b) {
3500
- return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
3567
+ return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
3501
3568
  const result = await this.read(a, b);
3502
3569
  if (Array.isArray(result)) {
3503
3570
  const missingIds = compact(
@@ -3516,7 +3583,7 @@ class RestRepository extends Query {
3516
3583
  });
3517
3584
  }
3518
3585
  async update(a, b, c, d) {
3519
- return __privateGet$4(this, _trace).call(this, "update", async () => {
3586
+ return __privateGet$3(this, _trace).call(this, "update", async () => {
3520
3587
  const ifVersion = parseIfVersion(b, c, d);
3521
3588
  if (Array.isArray(a)) {
3522
3589
  if (a.length === 0)
@@ -3549,7 +3616,7 @@ class RestRepository extends Query {
3549
3616
  });
3550
3617
  }
3551
3618
  async updateOrThrow(a, b, c, d) {
3552
- return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
3619
+ return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
3553
3620
  const result = await this.update(a, b, c, d);
3554
3621
  if (Array.isArray(result)) {
3555
3622
  const missingIds = compact(
@@ -3568,7 +3635,7 @@ class RestRepository extends Query {
3568
3635
  });
3569
3636
  }
3570
3637
  async createOrUpdate(a, b, c, d) {
3571
- return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3638
+ return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
3572
3639
  const ifVersion = parseIfVersion(b, c, d);
3573
3640
  if (Array.isArray(a)) {
3574
3641
  if (a.length === 0)
@@ -3603,7 +3670,7 @@ class RestRepository extends Query {
3603
3670
  });
3604
3671
  }
3605
3672
  async createOrReplace(a, b, c, d) {
3606
- return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3673
+ return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
3607
3674
  const ifVersion = parseIfVersion(b, c, d);
3608
3675
  if (Array.isArray(a)) {
3609
3676
  if (a.length === 0)
@@ -3635,7 +3702,7 @@ class RestRepository extends Query {
3635
3702
  });
3636
3703
  }
3637
3704
  async delete(a, b) {
3638
- return __privateGet$4(this, _trace).call(this, "delete", async () => {
3705
+ return __privateGet$3(this, _trace).call(this, "delete", async () => {
3639
3706
  if (Array.isArray(a)) {
3640
3707
  if (a.length === 0)
3641
3708
  return [];
@@ -3661,7 +3728,7 @@ class RestRepository extends Query {
3661
3728
  });
3662
3729
  }
3663
3730
  async deleteOrThrow(a, b) {
3664
- return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
3731
+ return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
3665
3732
  const result = await this.delete(a, b);
3666
3733
  if (Array.isArray(result)) {
3667
3734
  const missingIds = compact(
@@ -3679,13 +3746,13 @@ class RestRepository extends Query {
3679
3746
  });
3680
3747
  }
3681
3748
  async search(query, options = {}) {
3682
- return __privateGet$4(this, _trace).call(this, "search", async () => {
3749
+ return __privateGet$3(this, _trace).call(this, "search", async () => {
3683
3750
  const { records, totalCount } = await searchTable({
3684
3751
  pathParams: {
3685
3752
  workspace: "{workspaceId}",
3686
3753
  dbBranchName: "{dbBranch}",
3687
3754
  region: "{region}",
3688
- tableName: __privateGet$4(this, _table)
3755
+ tableName: __privateGet$3(this, _table)
3689
3756
  },
3690
3757
  body: {
3691
3758
  query,
@@ -3697,23 +3764,23 @@ class RestRepository extends Query {
3697
3764
  page: options.page,
3698
3765
  target: options.target
3699
3766
  },
3700
- ...__privateGet$4(this, _getFetchProps).call(this)
3767
+ ...__privateGet$3(this, _getFetchProps).call(this)
3701
3768
  });
3702
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3769
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3703
3770
  return {
3704
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3771
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3705
3772
  totalCount
3706
3773
  };
3707
3774
  });
3708
3775
  }
3709
3776
  async vectorSearch(column, query, options) {
3710
- return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3777
+ return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
3711
3778
  const { records, totalCount } = await vectorSearchTable({
3712
3779
  pathParams: {
3713
3780
  workspace: "{workspaceId}",
3714
3781
  dbBranchName: "{dbBranch}",
3715
3782
  region: "{region}",
3716
- tableName: __privateGet$4(this, _table)
3783
+ tableName: __privateGet$3(this, _table)
3717
3784
  },
3718
3785
  body: {
3719
3786
  column,
@@ -3722,32 +3789,32 @@ class RestRepository extends Query {
3722
3789
  size: options?.size,
3723
3790
  filter: options?.filter
3724
3791
  },
3725
- ...__privateGet$4(this, _getFetchProps).call(this)
3792
+ ...__privateGet$3(this, _getFetchProps).call(this)
3726
3793
  });
3727
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3794
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3728
3795
  return {
3729
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3796
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3730
3797
  totalCount
3731
3798
  };
3732
3799
  });
3733
3800
  }
3734
3801
  async aggregate(aggs, filter) {
3735
- return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
3802
+ return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
3736
3803
  const result = await aggregateTable({
3737
3804
  pathParams: {
3738
3805
  workspace: "{workspaceId}",
3739
3806
  dbBranchName: "{dbBranch}",
3740
3807
  region: "{region}",
3741
- tableName: __privateGet$4(this, _table)
3808
+ tableName: __privateGet$3(this, _table)
3742
3809
  },
3743
3810
  body: { aggs, filter },
3744
- ...__privateGet$4(this, _getFetchProps).call(this)
3811
+ ...__privateGet$3(this, _getFetchProps).call(this)
3745
3812
  });
3746
3813
  return result;
3747
3814
  });
3748
3815
  }
3749
3816
  async query(query) {
3750
- return __privateGet$4(this, _trace).call(this, "query", async () => {
3817
+ return __privateGet$3(this, _trace).call(this, "query", async () => {
3751
3818
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
3752
3819
  if (cacheQuery)
3753
3820
  return new Page(query, cacheQuery.meta, cacheQuery.records);
@@ -3757,7 +3824,7 @@ class RestRepository extends Query {
3757
3824
  workspace: "{workspaceId}",
3758
3825
  dbBranchName: "{dbBranch}",
3759
3826
  region: "{region}",
3760
- tableName: __privateGet$4(this, _table)
3827
+ tableName: __privateGet$3(this, _table)
3761
3828
  },
3762
3829
  body: {
3763
3830
  filter: cleanFilter(data.filter),
@@ -3767,14 +3834,14 @@ class RestRepository extends Query {
3767
3834
  consistency: data.consistency
3768
3835
  },
3769
3836
  fetchOptions: data.fetchOptions,
3770
- ...__privateGet$4(this, _getFetchProps).call(this)
3837
+ ...__privateGet$3(this, _getFetchProps).call(this)
3771
3838
  });
3772
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3839
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3773
3840
  const records = objects.map(
3774
3841
  (record) => initObject(
3775
- __privateGet$4(this, _db),
3842
+ __privateGet$3(this, _db),
3776
3843
  schemaTables,
3777
- __privateGet$4(this, _table),
3844
+ __privateGet$3(this, _table),
3778
3845
  record,
3779
3846
  data.columns ?? ["*"]
3780
3847
  )
@@ -3784,14 +3851,14 @@ class RestRepository extends Query {
3784
3851
  });
3785
3852
  }
3786
3853
  async summarizeTable(query, summaries, summariesFilter) {
3787
- return __privateGet$4(this, _trace).call(this, "summarize", async () => {
3854
+ return __privateGet$3(this, _trace).call(this, "summarize", async () => {
3788
3855
  const data = query.getQueryOptions();
3789
3856
  const result = await summarizeTable({
3790
3857
  pathParams: {
3791
3858
  workspace: "{workspaceId}",
3792
3859
  dbBranchName: "{dbBranch}",
3793
3860
  region: "{region}",
3794
- tableName: __privateGet$4(this, _table)
3861
+ tableName: __privateGet$3(this, _table)
3795
3862
  },
3796
3863
  body: {
3797
3864
  filter: cleanFilter(data.filter),
@@ -3802,13 +3869,13 @@ class RestRepository extends Query {
3802
3869
  summaries,
3803
3870
  summariesFilter
3804
3871
  },
3805
- ...__privateGet$4(this, _getFetchProps).call(this)
3872
+ ...__privateGet$3(this, _getFetchProps).call(this)
3806
3873
  });
3807
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3874
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3808
3875
  return {
3809
3876
  ...result,
3810
3877
  summaries: result.summaries.map(
3811
- (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3878
+ (summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
3812
3879
  )
3813
3880
  };
3814
3881
  });
@@ -3820,7 +3887,7 @@ class RestRepository extends Query {
3820
3887
  workspace: "{workspaceId}",
3821
3888
  dbBranchName: "{dbBranch}",
3822
3889
  region: "{region}",
3823
- tableName: __privateGet$4(this, _table),
3890
+ tableName: __privateGet$3(this, _table),
3824
3891
  sessionId: options?.sessionId
3825
3892
  },
3826
3893
  body: {
@@ -3830,7 +3897,7 @@ class RestRepository extends Query {
3830
3897
  search: options?.searchType === "keyword" ? options?.search : void 0,
3831
3898
  vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3832
3899
  },
3833
- ...__privateGet$4(this, _getFetchProps).call(this)
3900
+ ...__privateGet$3(this, _getFetchProps).call(this)
3834
3901
  };
3835
3902
  if (options?.onMessage) {
3836
3903
  fetchSSERequest({
@@ -3851,7 +3918,7 @@ _table = new WeakMap();
3851
3918
  _getFetchProps = new WeakMap();
3852
3919
  _db = new WeakMap();
3853
3920
  _cache = new WeakMap();
3854
- _schemaTables$2 = new WeakMap();
3921
+ _schemaTables = new WeakMap();
3855
3922
  _trace = new WeakMap();
3856
3923
  _insertRecordWithoutId = new WeakSet();
3857
3924
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
@@ -3861,14 +3928,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3861
3928
  workspace: "{workspaceId}",
3862
3929
  dbBranchName: "{dbBranch}",
3863
3930
  region: "{region}",
3864
- tableName: __privateGet$4(this, _table)
3931
+ tableName: __privateGet$3(this, _table)
3865
3932
  },
3866
3933
  queryParams: { columns },
3867
3934
  body: record,
3868
- ...__privateGet$4(this, _getFetchProps).call(this)
3935
+ ...__privateGet$3(this, _getFetchProps).call(this)
3869
3936
  });
3870
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3871
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3937
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3938
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3872
3939
  };
3873
3940
  _insertRecordWithId = new WeakSet();
3874
3941
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
@@ -3880,21 +3947,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
3880
3947
  workspace: "{workspaceId}",
3881
3948
  dbBranchName: "{dbBranch}",
3882
3949
  region: "{region}",
3883
- tableName: __privateGet$4(this, _table),
3950
+ tableName: __privateGet$3(this, _table),
3884
3951
  recordId
3885
3952
  },
3886
3953
  body: record,
3887
3954
  queryParams: { createOnly, columns, ifVersion },
3888
- ...__privateGet$4(this, _getFetchProps).call(this)
3955
+ ...__privateGet$3(this, _getFetchProps).call(this)
3889
3956
  });
3890
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3891
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3957
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3958
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3892
3959
  };
3893
3960
  _insertRecords = new WeakSet();
3894
3961
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3895
3962
  const operations = await promiseMap(objects, async (object) => {
3896
3963
  const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3897
- return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3964
+ return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
3898
3965
  });
3899
3966
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3900
3967
  const ids = [];
@@ -3906,7 +3973,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3906
3973
  region: "{region}"
3907
3974
  },
3908
3975
  body: { operations: operations2 },
3909
- ...__privateGet$4(this, _getFetchProps).call(this)
3976
+ ...__privateGet$3(this, _getFetchProps).call(this)
3910
3977
  });
3911
3978
  for (const result of results) {
3912
3979
  if (result.operation === "insert") {
@@ -3929,15 +3996,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3929
3996
  workspace: "{workspaceId}",
3930
3997
  dbBranchName: "{dbBranch}",
3931
3998
  region: "{region}",
3932
- tableName: __privateGet$4(this, _table),
3999
+ tableName: __privateGet$3(this, _table),
3933
4000
  recordId
3934
4001
  },
3935
4002
  queryParams: { columns, ifVersion },
3936
4003
  body: record,
3937
- ...__privateGet$4(this, _getFetchProps).call(this)
4004
+ ...__privateGet$3(this, _getFetchProps).call(this)
3938
4005
  });
3939
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3940
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4006
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4007
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3941
4008
  } catch (e) {
3942
4009
  if (isObject(e) && e.status === 404) {
3943
4010
  return null;
@@ -3949,7 +4016,7 @@ _updateRecords = new WeakSet();
3949
4016
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3950
4017
  const operations = await promiseMap(objects, async ({ id, ...object }) => {
3951
4018
  const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3952
- return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
4019
+ return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
3953
4020
  });
3954
4021
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3955
4022
  const ids = [];
@@ -3961,7 +4028,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3961
4028
  region: "{region}"
3962
4029
  },
3963
4030
  body: { operations: operations2 },
3964
- ...__privateGet$4(this, _getFetchProps).call(this)
4031
+ ...__privateGet$3(this, _getFetchProps).call(this)
3965
4032
  });
3966
4033
  for (const result of results) {
3967
4034
  if (result.operation === "update") {
@@ -3982,15 +4049,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3982
4049
  workspace: "{workspaceId}",
3983
4050
  dbBranchName: "{dbBranch}",
3984
4051
  region: "{region}",
3985
- tableName: __privateGet$4(this, _table),
4052
+ tableName: __privateGet$3(this, _table),
3986
4053
  recordId
3987
4054
  },
3988
4055
  queryParams: { columns, ifVersion },
3989
4056
  body: object,
3990
- ...__privateGet$4(this, _getFetchProps).call(this)
4057
+ ...__privateGet$3(this, _getFetchProps).call(this)
3991
4058
  });
3992
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3993
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4059
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4060
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3994
4061
  };
3995
4062
  _deleteRecord = new WeakSet();
3996
4063
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
@@ -4002,14 +4069,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4002
4069
  workspace: "{workspaceId}",
4003
4070
  dbBranchName: "{dbBranch}",
4004
4071
  region: "{region}",
4005
- tableName: __privateGet$4(this, _table),
4072
+ tableName: __privateGet$3(this, _table),
4006
4073
  recordId
4007
4074
  },
4008
4075
  queryParams: { columns },
4009
- ...__privateGet$4(this, _getFetchProps).call(this)
4076
+ ...__privateGet$3(this, _getFetchProps).call(this)
4010
4077
  });
4011
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4012
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4078
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4079
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4013
4080
  } catch (e) {
4014
4081
  if (isObject(e) && e.status === 404) {
4015
4082
  return null;
@@ -4020,7 +4087,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4020
4087
  _deleteRecords = new WeakSet();
4021
4088
  deleteRecords_fn = async function(recordIds) {
4022
4089
  const chunkedOperations = chunk(
4023
- compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4090
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
4024
4091
  BULK_OPERATION_MAX_SIZE
4025
4092
  );
4026
4093
  for (const operations of chunkedOperations) {
@@ -4031,44 +4098,44 @@ deleteRecords_fn = async function(recordIds) {
4031
4098
  region: "{region}"
4032
4099
  },
4033
4100
  body: { operations },
4034
- ...__privateGet$4(this, _getFetchProps).call(this)
4101
+ ...__privateGet$3(this, _getFetchProps).call(this)
4035
4102
  });
4036
4103
  }
4037
4104
  };
4038
4105
  _setCacheQuery = new WeakSet();
4039
4106
  setCacheQuery_fn = async function(query, meta, records) {
4040
- await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4107
+ await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4041
4108
  };
4042
4109
  _getCacheQuery = new WeakSet();
4043
4110
  getCacheQuery_fn = async function(query) {
4044
- const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
4045
- const result = await __privateGet$4(this, _cache)?.get(key);
4111
+ const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
4112
+ const result = await __privateGet$3(this, _cache)?.get(key);
4046
4113
  if (!result)
4047
4114
  return null;
4048
- const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4115
+ const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
4049
4116
  const { cache: ttl = defaultTTL } = query.getQueryOptions();
4050
4117
  if (ttl < 0)
4051
4118
  return null;
4052
4119
  const hasExpired = result.date.getTime() + ttl < Date.now();
4053
4120
  return hasExpired ? null : result;
4054
4121
  };
4055
- _getSchemaTables$1 = new WeakSet();
4056
- getSchemaTables_fn$1 = async function() {
4057
- if (__privateGet$4(this, _schemaTables$2))
4058
- return __privateGet$4(this, _schemaTables$2);
4122
+ _getSchemaTables = new WeakSet();
4123
+ getSchemaTables_fn = async function() {
4124
+ if (__privateGet$3(this, _schemaTables))
4125
+ return __privateGet$3(this, _schemaTables);
4059
4126
  const { schema } = await getBranchDetails({
4060
4127
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4061
- ...__privateGet$4(this, _getFetchProps).call(this)
4128
+ ...__privateGet$3(this, _getFetchProps).call(this)
4062
4129
  });
4063
- __privateSet$4(this, _schemaTables$2, schema.tables);
4130
+ __privateSet$2(this, _schemaTables, schema.tables);
4064
4131
  return schema.tables;
4065
4132
  };
4066
4133
  _transformObjectToApi = new WeakSet();
4067
4134
  transformObjectToApi_fn = async function(object) {
4068
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4069
- const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4135
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4136
+ const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
4070
4137
  if (!schema)
4071
- throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4138
+ throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
4072
4139
  const result = {};
4073
4140
  for (const [key, value] of Object.entries(object)) {
4074
4141
  if (key === "xata")
@@ -4224,7 +4291,7 @@ var __accessCheck$3 = (obj, member, msg) => {
4224
4291
  if (!member.has(obj))
4225
4292
  throw TypeError("Cannot " + msg);
4226
4293
  };
4227
- var __privateGet$3 = (obj, member, getter) => {
4294
+ var __privateGet$2 = (obj, member, getter) => {
4228
4295
  __accessCheck$3(obj, member, "read from private field");
4229
4296
  return getter ? getter.call(obj) : member.get(obj);
4230
4297
  };
@@ -4233,7 +4300,7 @@ var __privateAdd$3 = (obj, member, value) => {
4233
4300
  throw TypeError("Cannot add the same private member more than once");
4234
4301
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4235
4302
  };
4236
- var __privateSet$3 = (obj, member, value, setter) => {
4303
+ var __privateSet$1 = (obj, member, value, setter) => {
4237
4304
  __accessCheck$3(obj, member, "write to private field");
4238
4305
  setter ? setter.call(obj, value) : member.set(obj, value);
4239
4306
  return value;
@@ -4242,29 +4309,29 @@ var _map;
4242
4309
  class SimpleCache {
4243
4310
  constructor(options = {}) {
4244
4311
  __privateAdd$3(this, _map, void 0);
4245
- __privateSet$3(this, _map, /* @__PURE__ */ new Map());
4312
+ __privateSet$1(this, _map, /* @__PURE__ */ new Map());
4246
4313
  this.capacity = options.max ?? 500;
4247
4314
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
4248
4315
  }
4249
4316
  async getAll() {
4250
- return Object.fromEntries(__privateGet$3(this, _map));
4317
+ return Object.fromEntries(__privateGet$2(this, _map));
4251
4318
  }
4252
4319
  async get(key) {
4253
- return __privateGet$3(this, _map).get(key) ?? null;
4320
+ return __privateGet$2(this, _map).get(key) ?? null;
4254
4321
  }
4255
4322
  async set(key, value) {
4256
4323
  await this.delete(key);
4257
- __privateGet$3(this, _map).set(key, value);
4258
- if (__privateGet$3(this, _map).size > this.capacity) {
4259
- const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
4324
+ __privateGet$2(this, _map).set(key, value);
4325
+ if (__privateGet$2(this, _map).size > this.capacity) {
4326
+ const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
4260
4327
  await this.delete(leastRecentlyUsed);
4261
4328
  }
4262
4329
  }
4263
4330
  async delete(key) {
4264
- __privateGet$3(this, _map).delete(key);
4331
+ __privateGet$2(this, _map).delete(key);
4265
4332
  }
4266
4333
  async clear() {
4267
- return __privateGet$3(this, _map).clear();
4334
+ return __privateGet$2(this, _map).clear();
4268
4335
  }
4269
4336
  }
4270
4337
  _map = new WeakMap();
@@ -4301,7 +4368,7 @@ var __accessCheck$2 = (obj, member, msg) => {
4301
4368
  if (!member.has(obj))
4302
4369
  throw TypeError("Cannot " + msg);
4303
4370
  };
4304
- var __privateGet$2 = (obj, member, getter) => {
4371
+ var __privateGet$1 = (obj, member, getter) => {
4305
4372
  __accessCheck$2(obj, member, "read from private field");
4306
4373
  return getter ? getter.call(obj) : member.get(obj);
4307
4374
  };
@@ -4310,18 +4377,11 @@ var __privateAdd$2 = (obj, member, value) => {
4310
4377
  throw TypeError("Cannot add the same private member more than once");
4311
4378
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4312
4379
  };
4313
- var __privateSet$2 = (obj, member, value, setter) => {
4314
- __accessCheck$2(obj, member, "write to private field");
4315
- setter ? setter.call(obj, value) : member.set(obj, value);
4316
- return value;
4317
- };
4318
- var _tables, _schemaTables$1;
4380
+ var _tables;
4319
4381
  class SchemaPlugin extends XataPlugin {
4320
- constructor(schemaTables) {
4382
+ constructor() {
4321
4383
  super();
4322
4384
  __privateAdd$2(this, _tables, {});
4323
- __privateAdd$2(this, _schemaTables$1, void 0);
4324
- __privateSet$2(this, _schemaTables$1, schemaTables);
4325
4385
  }
4326
4386
  build(pluginOptions) {
4327
4387
  const db = new Proxy(
@@ -4330,22 +4390,21 @@ class SchemaPlugin extends XataPlugin {
4330
4390
  get: (_target, table) => {
4331
4391
  if (!isString(table))
4332
4392
  throw new Error("Invalid table name");
4333
- if (__privateGet$2(this, _tables)[table] === void 0) {
4334
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4393
+ if (__privateGet$1(this, _tables)[table] === void 0) {
4394
+ __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4335
4395
  }
4336
- return __privateGet$2(this, _tables)[table];
4396
+ return __privateGet$1(this, _tables)[table];
4337
4397
  }
4338
4398
  }
4339
4399
  );
4340
- const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
4400
+ const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
4341
4401
  for (const table of tableNames) {
4342
- db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4402
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4343
4403
  }
4344
4404
  return db;
4345
4405
  }
4346
4406
  }
4347
4407
  _tables = new WeakMap();
4348
- _schemaTables$1 = new WeakMap();
4349
4408
 
4350
4409
  class FilesPlugin extends XataPlugin {
4351
4410
  build(pluginOptions) {
@@ -4425,54 +4484,40 @@ var __accessCheck$1 = (obj, member, msg) => {
4425
4484
  if (!member.has(obj))
4426
4485
  throw TypeError("Cannot " + msg);
4427
4486
  };
4428
- var __privateGet$1 = (obj, member, getter) => {
4429
- __accessCheck$1(obj, member, "read from private field");
4430
- return getter ? getter.call(obj) : member.get(obj);
4431
- };
4432
4487
  var __privateAdd$1 = (obj, member, value) => {
4433
4488
  if (member.has(obj))
4434
4489
  throw TypeError("Cannot add the same private member more than once");
4435
4490
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4436
4491
  };
4437
- var __privateSet$1 = (obj, member, value, setter) => {
4438
- __accessCheck$1(obj, member, "write to private field");
4439
- setter ? setter.call(obj, value) : member.set(obj, value);
4440
- return value;
4441
- };
4442
4492
  var __privateMethod$1 = (obj, member, method) => {
4443
4493
  __accessCheck$1(obj, member, "access private method");
4444
4494
  return method;
4445
4495
  };
4446
- var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
4496
+ var _search, search_fn;
4447
4497
  class SearchPlugin extends XataPlugin {
4448
- constructor(db, schemaTables) {
4498
+ constructor(db) {
4449
4499
  super();
4450
4500
  this.db = db;
4451
4501
  __privateAdd$1(this, _search);
4452
- __privateAdd$1(this, _getSchemaTables);
4453
- __privateAdd$1(this, _schemaTables, void 0);
4454
- __privateSet$1(this, _schemaTables, schemaTables);
4455
4502
  }
4456
4503
  build(pluginOptions) {
4457
4504
  return {
4458
4505
  all: async (query, options = {}) => {
4459
4506
  const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4460
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4461
4507
  return {
4462
4508
  totalCount,
4463
4509
  records: records.map((record) => {
4464
4510
  const { table = "orphan" } = record.xata;
4465
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4511
+ return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
4466
4512
  })
4467
4513
  };
4468
4514
  },
4469
4515
  byTable: async (query, options = {}) => {
4470
4516
  const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4471
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4472
4517
  const records = rawRecords.reduce((acc, record) => {
4473
4518
  const { table = "orphan" } = record.xata;
4474
4519
  const items = acc[table] ?? [];
4475
- const item = initObject(this.db, schemaTables, table, record, ["*"]);
4520
+ const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
4476
4521
  return { ...acc, [table]: [...items, item] };
4477
4522
  }, {});
4478
4523
  return { totalCount, records };
@@ -4480,29 +4525,17 @@ class SearchPlugin extends XataPlugin {
4480
4525
  };
4481
4526
  }
4482
4527
  }
4483
- _schemaTables = new WeakMap();
4484
4528
  _search = new WeakSet();
4485
4529
  search_fn = async function(query, options, pluginOptions) {
4486
4530
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4487
4531
  const { records, totalCount } = await searchBranch({
4488
4532
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4489
- // @ts-ignore https://github.com/xataio/client-ts/issues/313
4533
+ // @ts-expect-error Filter properties do not match inferred type
4490
4534
  body: { tables, query, fuzziness, prefix, highlight, page },
4491
4535
  ...pluginOptions
4492
4536
  });
4493
4537
  return { records, totalCount };
4494
4538
  };
4495
- _getSchemaTables = new WeakSet();
4496
- getSchemaTables_fn = async function(pluginOptions) {
4497
- if (__privateGet$1(this, _schemaTables))
4498
- return __privateGet$1(this, _schemaTables);
4499
- const { schema } = await getBranchDetails({
4500
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4501
- ...pluginOptions
4502
- });
4503
- __privateSet$1(this, _schemaTables, schema.tables);
4504
- return schema.tables;
4505
- };
4506
4539
 
4507
4540
  function escapeElement(elementRepresentation) {
4508
4541
  const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -4569,12 +4602,17 @@ class SQLPlugin extends XataPlugin {
4569
4602
  throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
4570
4603
  }
4571
4604
  const { statement, params, consistency } = prepareParams(query, parameters);
4572
- const { records, warning, columns } = await sqlQuery({
4605
+ const {
4606
+ records,
4607
+ rows,
4608
+ warning,
4609
+ columns = []
4610
+ } = await sqlQuery({
4573
4611
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4574
4612
  body: { statement, params, consistency },
4575
4613
  ...pluginOptions
4576
4614
  });
4577
- return { records, warning, columns };
4615
+ return { records, rows, warning, columns };
4578
4616
  };
4579
4617
  }
4580
4618
  }
@@ -4625,7 +4663,7 @@ var __privateMethod = (obj, member, method) => {
4625
4663
  const buildClient = (plugins) => {
4626
4664
  var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
4627
4665
  return _a = class {
4628
- constructor(options = {}, schemaTables) {
4666
+ constructor(options = {}, tables) {
4629
4667
  __privateAdd(this, _parseOptions);
4630
4668
  __privateAdd(this, _getFetchProps);
4631
4669
  __privateAdd(this, _options, void 0);
@@ -4634,13 +4672,15 @@ const buildClient = (plugins) => {
4634
4672
  const pluginOptions = {
4635
4673
  ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4636
4674
  cache: safeOptions.cache,
4637
- host: safeOptions.host
4675
+ host: safeOptions.host,
4676
+ tables
4638
4677
  };
4639
- const db = new SchemaPlugin(schemaTables).build(pluginOptions);
4640
- const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4678
+ const db = new SchemaPlugin().build(pluginOptions);
4679
+ const search = new SearchPlugin(db).build(pluginOptions);
4641
4680
  const transactions = new TransactionPlugin().build(pluginOptions);
4642
4681
  const sql = new SQLPlugin().build(pluginOptions);
4643
4682
  const files = new FilesPlugin().build(pluginOptions);
4683
+ this.schema = { tables };
4644
4684
  this.db = db;
4645
4685
  this.search = search;
4646
4686
  this.transactions = transactions;
@@ -4662,7 +4702,7 @@ const buildClient = (plugins) => {
4662
4702
  const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
4663
4703
  if (isBrowser && !enableBrowser) {
4664
4704
  throw new Error(
4665
- "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."
4705
+ "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"
4666
4706
  );
4667
4707
  }
4668
4708
  const fetch = getFetchImplementation(options?.fetch);
@@ -4825,6 +4865,7 @@ exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
4825
4865
  exports.PAGINATION_MAX_OFFSET = PAGINATION_MAX_OFFSET;
4826
4866
  exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
4827
4867
  exports.Page = Page;
4868
+ exports.PageRecordArray = PageRecordArray;
4828
4869
  exports.Query = Query;
4829
4870
  exports.RecordArray = RecordArray;
4830
4871
  exports.RecordColumnTypes = RecordColumnTypes;
@@ -4842,6 +4883,7 @@ exports.XataError = XataError;
4842
4883
  exports.XataFile = XataFile;
4843
4884
  exports.XataPlugin = XataPlugin;
4844
4885
  exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
4886
+ exports.adaptTable = adaptTable;
4845
4887
  exports.addGitBranchesEntry = addGitBranchesEntry;
4846
4888
  exports.addTableColumn = addTableColumn;
4847
4889
  exports.aggregateTable = aggregateTable;
@@ -4895,6 +4937,7 @@ exports.getBranchDetails = getBranchDetails;
4895
4937
  exports.getBranchList = getBranchList;
4896
4938
  exports.getBranchMetadata = getBranchMetadata;
4897
4939
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
4940
+ exports.getBranchMigrationJobStatus = getBranchMigrationJobStatus;
4898
4941
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
4899
4942
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
4900
4943
  exports.getBranchStats = getBranchStats;
@@ -4903,11 +4946,14 @@ exports.getColumn = getColumn;
4903
4946
  exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
4904
4947
  exports.getDatabaseList = getDatabaseList;
4905
4948
  exports.getDatabaseMetadata = getDatabaseMetadata;
4949
+ exports.getDatabaseSettings = getDatabaseSettings;
4906
4950
  exports.getDatabaseURL = getDatabaseURL;
4907
4951
  exports.getFile = getFile;
4908
4952
  exports.getFileItem = getFileItem;
4909
4953
  exports.getGitBranchesMapping = getGitBranchesMapping;
4910
4954
  exports.getHostUrl = getHostUrl;
4955
+ exports.getMigrationHistory = getMigrationHistory;
4956
+ exports.getMigrationJobStatus = getMigrationJobStatus;
4911
4957
  exports.getMigrationRequest = getMigrationRequest;
4912
4958
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
4913
4959
  exports.getPreviewBranch = getPreviewBranch;
@@ -4961,9 +5007,6 @@ exports.operationsByTag = operationsByTag;
4961
5007
  exports.parseProviderString = parseProviderString;
4962
5008
  exports.parseWorkspacesUrlParts = parseWorkspacesUrlParts;
4963
5009
  exports.pattern = pattern;
4964
- exports.pgRollJobStatus = pgRollJobStatus;
4965
- exports.pgRollMigrationHistory = pgRollMigrationHistory;
4966
- exports.pgRollStatus = pgRollStatus;
4967
5010
  exports.previewBranchSchemaEdit = previewBranchSchemaEdit;
4968
5011
  exports.pushBranchMigrations = pushBranchMigrations;
4969
5012
  exports.putFile = putFile;
@@ -4989,6 +5032,7 @@ exports.updateCluster = updateCluster;
4989
5032
  exports.updateColumn = updateColumn;
4990
5033
  exports.updateDatabaseGithubSettings = updateDatabaseGithubSettings;
4991
5034
  exports.updateDatabaseMetadata = updateDatabaseMetadata;
5035
+ exports.updateDatabaseSettings = updateDatabaseSettings;
4992
5036
  exports.updateMigrationRequest = updateMigrationRequest;
4993
5037
  exports.updateOAuthAccessToken = updateOAuthAccessToken;
4994
5038
  exports.updateRecordWithID = updateRecordWithID;