@xata.io/client 0.0.0-alpha.vf55585d9b3ddcdd6254b3a79c108fa99863f7685 → 0.0.0-alpha.vf58a3c229cee57bd4c4c22a72c3826618cdc9b94

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.4";
529
+ const VERSION = "0.29.0";
530
530
 
531
531
  class ErrorWithCause extends Error {
532
532
  constructor(message, options) {
@@ -1347,7 +1347,7 @@ var __accessCheck$7 = (obj, member, msg) => {
1347
1347
  if (!member.has(obj))
1348
1348
  throw TypeError("Cannot " + msg);
1349
1349
  };
1350
- var __privateGet$7 = (obj, member, getter) => {
1350
+ var __privateGet$6 = (obj, member, getter) => {
1351
1351
  __accessCheck$7(obj, member, "read from private field");
1352
1352
  return getter ? getter.call(obj) : member.get(obj);
1353
1353
  };
@@ -1356,7 +1356,7 @@ var __privateAdd$7 = (obj, member, value) => {
1356
1356
  throw TypeError("Cannot add the same private member more than once");
1357
1357
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1358
1358
  };
1359
- var __privateSet$7 = (obj, member, value, setter) => {
1359
+ var __privateSet$5 = (obj, member, value, setter) => {
1360
1360
  __accessCheck$7(obj, member, "write to private field");
1361
1361
  setter ? setter.call(obj, value) : member.set(obj, value);
1362
1362
  return value;
@@ -1373,7 +1373,7 @@ class XataApiClient {
1373
1373
  if (!apiKey) {
1374
1374
  throw new Error("Could not resolve a valid apiKey");
1375
1375
  }
1376
- __privateSet$7(this, _extraProps, {
1376
+ __privateSet$5(this, _extraProps, {
1377
1377
  apiUrl: getHostUrl(provider, "main"),
1378
1378
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
1379
1379
  fetch: getFetchImplementation(options.fetch),
@@ -1385,64 +1385,64 @@ class XataApiClient {
1385
1385
  });
1386
1386
  }
1387
1387
  get user() {
1388
- if (!__privateGet$7(this, _namespaces).user)
1389
- __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
1390
- return __privateGet$7(this, _namespaces).user;
1388
+ if (!__privateGet$6(this, _namespaces).user)
1389
+ __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
1390
+ return __privateGet$6(this, _namespaces).user;
1391
1391
  }
1392
1392
  get authentication() {
1393
- if (!__privateGet$7(this, _namespaces).authentication)
1394
- __privateGet$7(this, _namespaces).authentication = new AuthenticationApi(__privateGet$7(this, _extraProps));
1395
- return __privateGet$7(this, _namespaces).authentication;
1393
+ if (!__privateGet$6(this, _namespaces).authentication)
1394
+ __privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
1395
+ return __privateGet$6(this, _namespaces).authentication;
1396
1396
  }
1397
1397
  get workspaces() {
1398
- if (!__privateGet$7(this, _namespaces).workspaces)
1399
- __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
1400
- return __privateGet$7(this, _namespaces).workspaces;
1398
+ if (!__privateGet$6(this, _namespaces).workspaces)
1399
+ __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
1400
+ return __privateGet$6(this, _namespaces).workspaces;
1401
1401
  }
1402
1402
  get invites() {
1403
- if (!__privateGet$7(this, _namespaces).invites)
1404
- __privateGet$7(this, _namespaces).invites = new InvitesApi(__privateGet$7(this, _extraProps));
1405
- return __privateGet$7(this, _namespaces).invites;
1403
+ if (!__privateGet$6(this, _namespaces).invites)
1404
+ __privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
1405
+ return __privateGet$6(this, _namespaces).invites;
1406
1406
  }
1407
1407
  get database() {
1408
- if (!__privateGet$7(this, _namespaces).database)
1409
- __privateGet$7(this, _namespaces).database = new DatabaseApi(__privateGet$7(this, _extraProps));
1410
- return __privateGet$7(this, _namespaces).database;
1408
+ if (!__privateGet$6(this, _namespaces).database)
1409
+ __privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
1410
+ return __privateGet$6(this, _namespaces).database;
1411
1411
  }
1412
1412
  get branches() {
1413
- if (!__privateGet$7(this, _namespaces).branches)
1414
- __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
1415
- return __privateGet$7(this, _namespaces).branches;
1413
+ if (!__privateGet$6(this, _namespaces).branches)
1414
+ __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
1415
+ return __privateGet$6(this, _namespaces).branches;
1416
1416
  }
1417
1417
  get migrations() {
1418
- if (!__privateGet$7(this, _namespaces).migrations)
1419
- __privateGet$7(this, _namespaces).migrations = new MigrationsApi(__privateGet$7(this, _extraProps));
1420
- return __privateGet$7(this, _namespaces).migrations;
1418
+ if (!__privateGet$6(this, _namespaces).migrations)
1419
+ __privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
1420
+ return __privateGet$6(this, _namespaces).migrations;
1421
1421
  }
1422
1422
  get migrationRequests() {
1423
- if (!__privateGet$7(this, _namespaces).migrationRequests)
1424
- __privateGet$7(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$7(this, _extraProps));
1425
- return __privateGet$7(this, _namespaces).migrationRequests;
1423
+ if (!__privateGet$6(this, _namespaces).migrationRequests)
1424
+ __privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
1425
+ return __privateGet$6(this, _namespaces).migrationRequests;
1426
1426
  }
1427
1427
  get tables() {
1428
- if (!__privateGet$7(this, _namespaces).tables)
1429
- __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
1430
- return __privateGet$7(this, _namespaces).tables;
1428
+ if (!__privateGet$6(this, _namespaces).tables)
1429
+ __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
1430
+ return __privateGet$6(this, _namespaces).tables;
1431
1431
  }
1432
1432
  get records() {
1433
- if (!__privateGet$7(this, _namespaces).records)
1434
- __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
1435
- return __privateGet$7(this, _namespaces).records;
1433
+ if (!__privateGet$6(this, _namespaces).records)
1434
+ __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
1435
+ return __privateGet$6(this, _namespaces).records;
1436
1436
  }
1437
1437
  get files() {
1438
- if (!__privateGet$7(this, _namespaces).files)
1439
- __privateGet$7(this, _namespaces).files = new FilesApi(__privateGet$7(this, _extraProps));
1440
- return __privateGet$7(this, _namespaces).files;
1438
+ if (!__privateGet$6(this, _namespaces).files)
1439
+ __privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
1440
+ return __privateGet$6(this, _namespaces).files;
1441
1441
  }
1442
1442
  get searchAndFilter() {
1443
- if (!__privateGet$7(this, _namespaces).searchAndFilter)
1444
- __privateGet$7(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$7(this, _extraProps));
1445
- return __privateGet$7(this, _namespaces).searchAndFilter;
1443
+ if (!__privateGet$6(this, _namespaces).searchAndFilter)
1444
+ __privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
1445
+ return __privateGet$6(this, _namespaces).searchAndFilter;
1446
1446
  }
1447
1447
  }
1448
1448
  _extraProps = new WeakMap();
@@ -1744,6 +1744,53 @@ class BranchApi {
1744
1744
  ...this.extraProps
1745
1745
  });
1746
1746
  }
1747
+ pgRollMigrationHistory({
1748
+ workspace,
1749
+ region,
1750
+ database,
1751
+ branch
1752
+ }) {
1753
+ return operationsByTag.branch.pgRollMigrationHistory({
1754
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1755
+ ...this.extraProps
1756
+ });
1757
+ }
1758
+ applyMigration({
1759
+ workspace,
1760
+ region,
1761
+ database,
1762
+ branch,
1763
+ migration
1764
+ }) {
1765
+ return operationsByTag.branch.applyMigration({
1766
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1767
+ body: migration,
1768
+ ...this.extraProps
1769
+ });
1770
+ }
1771
+ pgRollStatus({
1772
+ workspace,
1773
+ region,
1774
+ database,
1775
+ branch
1776
+ }) {
1777
+ return operationsByTag.branch.pgRollStatus({
1778
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
1779
+ ...this.extraProps
1780
+ });
1781
+ }
1782
+ pgRollJobStatus({
1783
+ workspace,
1784
+ region,
1785
+ database,
1786
+ branch,
1787
+ jobId
1788
+ }) {
1789
+ return operationsByTag.branch.pgRollJobStatus({
1790
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, jobId },
1791
+ ...this.extraProps
1792
+ });
1793
+ }
1747
1794
  }
1748
1795
  class TableApi {
1749
1796
  constructor(extraProps) {
@@ -2557,6 +2604,17 @@ class MigrationsApi {
2557
2604
  ...this.extraProps
2558
2605
  });
2559
2606
  }
2607
+ getSchema({
2608
+ workspace,
2609
+ region,
2610
+ database,
2611
+ branch
2612
+ }) {
2613
+ return operationsByTag.migrations.getSchema({
2614
+ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
2615
+ ...this.extraProps
2616
+ });
2617
+ }
2560
2618
  }
2561
2619
  class DatabaseApi {
2562
2620
  constructor(extraProps) {
@@ -2862,7 +2920,7 @@ var __accessCheck$6 = (obj, member, msg) => {
2862
2920
  if (!member.has(obj))
2863
2921
  throw TypeError("Cannot " + msg);
2864
2922
  };
2865
- var __privateGet$6 = (obj, member, getter) => {
2923
+ var __privateGet$5 = (obj, member, getter) => {
2866
2924
  __accessCheck$6(obj, member, "read from private field");
2867
2925
  return getter ? getter.call(obj) : member.get(obj);
2868
2926
  };
@@ -2871,7 +2929,7 @@ var __privateAdd$6 = (obj, member, value) => {
2871
2929
  throw TypeError("Cannot add the same private member more than once");
2872
2930
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2873
2931
  };
2874
- var __privateSet$6 = (obj, member, value, setter) => {
2932
+ var __privateSet$4 = (obj, member, value, setter) => {
2875
2933
  __accessCheck$6(obj, member, "write to private field");
2876
2934
  setter ? setter.call(obj, value) : member.set(obj, value);
2877
2935
  return value;
@@ -2880,9 +2938,9 @@ var _query, _page;
2880
2938
  class Page {
2881
2939
  constructor(query, meta, records = []) {
2882
2940
  __privateAdd$6(this, _query, void 0);
2883
- __privateSet$6(this, _query, query);
2941
+ __privateSet$4(this, _query, query);
2884
2942
  this.meta = meta;
2885
- this.records = new RecordArray(this, records);
2943
+ this.records = new PageRecordArray(this, records);
2886
2944
  }
2887
2945
  /**
2888
2946
  * Retrieves the next page of results.
@@ -2891,7 +2949,7 @@ class Page {
2891
2949
  * @returns The next page or results.
2892
2950
  */
2893
2951
  async nextPage(size, offset) {
2894
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2952
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
2895
2953
  }
2896
2954
  /**
2897
2955
  * Retrieves the previous page of results.
@@ -2900,7 +2958,7 @@ class Page {
2900
2958
  * @returns The previous page or results.
2901
2959
  */
2902
2960
  async previousPage(size, offset) {
2903
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2961
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
2904
2962
  }
2905
2963
  /**
2906
2964
  * Retrieves the start page of results.
@@ -2909,7 +2967,7 @@ class Page {
2909
2967
  * @returns The start page or results.
2910
2968
  */
2911
2969
  async startPage(size, offset) {
2912
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2970
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
2913
2971
  }
2914
2972
  /**
2915
2973
  * Retrieves the end page of results.
@@ -2918,7 +2976,7 @@ class Page {
2918
2976
  * @returns The end page or results.
2919
2977
  */
2920
2978
  async endPage(size, offset) {
2921
- return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2979
+ return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
2922
2980
  }
2923
2981
  /**
2924
2982
  * Shortcut method to check if there will be additional results if the next page of results is retrieved.
@@ -2936,11 +2994,38 @@ const PAGINATION_DEFAULT_OFFSET = 0;
2936
2994
  function isCursorPaginationOptions(options) {
2937
2995
  return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
2938
2996
  }
2939
- const _RecordArray = class _RecordArray extends Array {
2997
+ class RecordArray extends Array {
2940
2998
  constructor(...args) {
2941
- super(..._RecordArray.parseConstructorParams(...args));
2999
+ super(...RecordArray.parseConstructorParams(...args));
3000
+ }
3001
+ static parseConstructorParams(...args) {
3002
+ if (args.length === 1 && typeof args[0] === "number") {
3003
+ return new Array(args[0]);
3004
+ }
3005
+ if (args.length <= 1 && Array.isArray(args[0] ?? [])) {
3006
+ const result = args[0] ?? [];
3007
+ return new Array(...result);
3008
+ }
3009
+ return new Array(...args);
3010
+ }
3011
+ toArray() {
3012
+ return new Array(...this);
3013
+ }
3014
+ toSerializable() {
3015
+ return JSON.parse(this.toString());
3016
+ }
3017
+ toString() {
3018
+ return JSON.stringify(this.toArray());
3019
+ }
3020
+ map(callbackfn, thisArg) {
3021
+ return this.toArray().map(callbackfn, thisArg);
3022
+ }
3023
+ }
3024
+ const _PageRecordArray = class _PageRecordArray extends Array {
3025
+ constructor(...args) {
3026
+ super(..._PageRecordArray.parseConstructorParams(...args));
2942
3027
  __privateAdd$6(this, _page, void 0);
2943
- __privateSet$6(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
3028
+ __privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
2944
3029
  }
2945
3030
  static parseConstructorParams(...args) {
2946
3031
  if (args.length === 1 && typeof args[0] === "number") {
@@ -2970,8 +3055,8 @@ const _RecordArray = class _RecordArray extends Array {
2970
3055
  * @returns A new array of objects
2971
3056
  */
2972
3057
  async nextPage(size, offset) {
2973
- const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
2974
- return new _RecordArray(newPage);
3058
+ const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
3059
+ return new _PageRecordArray(newPage);
2975
3060
  }
2976
3061
  /**
2977
3062
  * Retrieve previous page of records
@@ -2979,8 +3064,8 @@ const _RecordArray = class _RecordArray extends Array {
2979
3064
  * @returns A new array of objects
2980
3065
  */
2981
3066
  async previousPage(size, offset) {
2982
- const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
2983
- return new _RecordArray(newPage);
3067
+ const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
3068
+ return new _PageRecordArray(newPage);
2984
3069
  }
2985
3070
  /**
2986
3071
  * Retrieve start page of records
@@ -2988,8 +3073,8 @@ const _RecordArray = class _RecordArray extends Array {
2988
3073
  * @returns A new array of objects
2989
3074
  */
2990
3075
  async startPage(size, offset) {
2991
- const newPage = await __privateGet$6(this, _page).startPage(size, offset);
2992
- return new _RecordArray(newPage);
3076
+ const newPage = await __privateGet$5(this, _page).startPage(size, offset);
3077
+ return new _PageRecordArray(newPage);
2993
3078
  }
2994
3079
  /**
2995
3080
  * Retrieve end page of records
@@ -2997,24 +3082,24 @@ const _RecordArray = class _RecordArray extends Array {
2997
3082
  * @returns A new array of objects
2998
3083
  */
2999
3084
  async endPage(size, offset) {
3000
- const newPage = await __privateGet$6(this, _page).endPage(size, offset);
3001
- return new _RecordArray(newPage);
3085
+ const newPage = await __privateGet$5(this, _page).endPage(size, offset);
3086
+ return new _PageRecordArray(newPage);
3002
3087
  }
3003
3088
  /**
3004
3089
  * @returns Boolean indicating if there is a next page
3005
3090
  */
3006
3091
  hasNextPage() {
3007
- return __privateGet$6(this, _page).meta.page.more;
3092
+ return __privateGet$5(this, _page).meta.page.more;
3008
3093
  }
3009
3094
  };
3010
3095
  _page = new WeakMap();
3011
- let RecordArray = _RecordArray;
3096
+ let PageRecordArray = _PageRecordArray;
3012
3097
 
3013
3098
  var __accessCheck$5 = (obj, member, msg) => {
3014
3099
  if (!member.has(obj))
3015
3100
  throw TypeError("Cannot " + msg);
3016
3101
  };
3017
- var __privateGet$5 = (obj, member, getter) => {
3102
+ var __privateGet$4 = (obj, member, getter) => {
3018
3103
  __accessCheck$5(obj, member, "read from private field");
3019
3104
  return getter ? getter.call(obj) : member.get(obj);
3020
3105
  };
@@ -3023,7 +3108,7 @@ var __privateAdd$5 = (obj, member, value) => {
3023
3108
  throw TypeError("Cannot add the same private member more than once");
3024
3109
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3025
3110
  };
3026
- var __privateSet$5 = (obj, member, value, setter) => {
3111
+ var __privateSet$3 = (obj, member, value, setter) => {
3027
3112
  __accessCheck$5(obj, member, "write to private field");
3028
3113
  setter ? setter.call(obj, value) : member.set(obj, value);
3029
3114
  return value;
@@ -3041,25 +3126,25 @@ const _Query = class _Query {
3041
3126
  __privateAdd$5(this, _data, { filter: {} });
3042
3127
  // Implements pagination
3043
3128
  this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
3044
- this.records = new RecordArray(this, []);
3045
- __privateSet$5(this, _table$1, table);
3129
+ this.records = new PageRecordArray(this, []);
3130
+ __privateSet$3(this, _table$1, table);
3046
3131
  if (repository) {
3047
- __privateSet$5(this, _repository, repository);
3132
+ __privateSet$3(this, _repository, repository);
3048
3133
  } else {
3049
- __privateSet$5(this, _repository, this);
3134
+ __privateSet$3(this, _repository, this);
3050
3135
  }
3051
3136
  const parent = cleanParent(data, rawParent);
3052
- __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
3053
- __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3054
- __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3055
- __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3056
- __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3057
- __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
3058
- __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
3059
- __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
3060
- __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
3061
- __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
3062
- __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3137
+ __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
3138
+ __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3139
+ __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3140
+ __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3141
+ __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3142
+ __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
3143
+ __privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
3144
+ __privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
3145
+ __privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
3146
+ __privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
3147
+ __privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3063
3148
  this.any = this.any.bind(this);
3064
3149
  this.all = this.all.bind(this);
3065
3150
  this.not = this.not.bind(this);
@@ -3070,10 +3155,10 @@ const _Query = class _Query {
3070
3155
  Object.defineProperty(this, "repository", { enumerable: false });
3071
3156
  }
3072
3157
  getQueryOptions() {
3073
- return __privateGet$5(this, _data);
3158
+ return __privateGet$4(this, _data);
3074
3159
  }
3075
3160
  key() {
3076
- const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
3161
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
3077
3162
  const key = JSON.stringify({ columns, filter, sort, pagination });
3078
3163
  return toBase64(key);
3079
3164
  }
@@ -3084,7 +3169,7 @@ const _Query = class _Query {
3084
3169
  */
3085
3170
  any(...queries) {
3086
3171
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
3087
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
3172
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
3088
3173
  }
3089
3174
  /**
3090
3175
  * Builds a new query object representing a logical AND between the given subqueries.
@@ -3093,7 +3178,7 @@ const _Query = class _Query {
3093
3178
  */
3094
3179
  all(...queries) {
3095
3180
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
3096
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3181
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3097
3182
  }
3098
3183
  /**
3099
3184
  * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
@@ -3102,7 +3187,7 @@ const _Query = class _Query {
3102
3187
  */
3103
3188
  not(...queries) {
3104
3189
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
3105
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
3190
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
3106
3191
  }
3107
3192
  /**
3108
3193
  * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
@@ -3111,25 +3196,25 @@ const _Query = class _Query {
3111
3196
  */
3112
3197
  none(...queries) {
3113
3198
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
3114
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
3199
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
3115
3200
  }
3116
3201
  filter(a, b) {
3117
3202
  if (arguments.length === 1) {
3118
3203
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
3119
3204
  [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
3120
3205
  }));
3121
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3122
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3206
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3207
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3123
3208
  } else {
3124
3209
  const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3125
- const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
3126
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
3210
+ const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
3211
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3127
3212
  }
3128
3213
  }
3129
3214
  sort(column, direction = "asc") {
3130
- const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
3215
+ const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
3131
3216
  const sort = [...originalSort, { column, direction }];
3132
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
3217
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
3133
3218
  }
3134
3219
  /**
3135
3220
  * Builds a new query specifying the set of columns to be returned in the query response.
@@ -3138,15 +3223,15 @@ const _Query = class _Query {
3138
3223
  */
3139
3224
  select(columns) {
3140
3225
  return new _Query(
3141
- __privateGet$5(this, _repository),
3142
- __privateGet$5(this, _table$1),
3226
+ __privateGet$4(this, _repository),
3227
+ __privateGet$4(this, _table$1),
3143
3228
  { columns },
3144
- __privateGet$5(this, _data)
3229
+ __privateGet$4(this, _data)
3145
3230
  );
3146
3231
  }
3147
3232
  getPaginated(options = {}) {
3148
- const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
3149
- return __privateGet$5(this, _repository).query(query);
3233
+ const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
3234
+ return __privateGet$4(this, _repository).query(query);
3150
3235
  }
3151
3236
  /**
3152
3237
  * Get results in an iterator
@@ -3183,7 +3268,7 @@ const _Query = class _Query {
3183
3268
  if (page.hasNextPage() && options.pagination?.size === void 0) {
3184
3269
  console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
3185
3270
  }
3186
- const array = new RecordArray(page, results.slice(0, size));
3271
+ const array = new PageRecordArray(page, results.slice(0, size));
3187
3272
  return array;
3188
3273
  }
3189
3274
  async getAll(options = {}) {
@@ -3192,7 +3277,7 @@ const _Query = class _Query {
3192
3277
  for await (const page of this.getIterator({ ...rest, batchSize })) {
3193
3278
  results.push(...page);
3194
3279
  }
3195
- return results;
3280
+ return new RecordArray(results);
3196
3281
  }
3197
3282
  async getFirst(options = {}) {
3198
3283
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
@@ -3207,12 +3292,12 @@ const _Query = class _Query {
3207
3292
  async summarize(params = {}) {
3208
3293
  const { summaries, summariesFilter, ...options } = params;
3209
3294
  const query = new _Query(
3210
- __privateGet$5(this, _repository),
3211
- __privateGet$5(this, _table$1),
3295
+ __privateGet$4(this, _repository),
3296
+ __privateGet$4(this, _table$1),
3212
3297
  options,
3213
- __privateGet$5(this, _data)
3298
+ __privateGet$4(this, _data)
3214
3299
  );
3215
- return __privateGet$5(this, _repository).summarizeTable(query, summaries, summariesFilter);
3300
+ return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
3216
3301
  }
3217
3302
  /**
3218
3303
  * Builds a new query object adding a cache TTL in milliseconds.
@@ -3220,7 +3305,7 @@ const _Query = class _Query {
3220
3305
  * @returns A new Query object.
3221
3306
  */
3222
3307
  cache(ttl) {
3223
- return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
3308
+ return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
3224
3309
  }
3225
3310
  /**
3226
3311
  * Retrieve next page of records
@@ -3266,7 +3351,7 @@ _repository = new WeakMap();
3266
3351
  _data = new WeakMap();
3267
3352
  _cleanFilterConstraint = new WeakSet();
3268
3353
  cleanFilterConstraint_fn = function(column, value) {
3269
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3354
+ const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3270
3355
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
3271
3356
  return { $includes: value };
3272
3357
  }
@@ -3356,7 +3441,7 @@ var __accessCheck$4 = (obj, member, msg) => {
3356
3441
  if (!member.has(obj))
3357
3442
  throw TypeError("Cannot " + msg);
3358
3443
  };
3359
- var __privateGet$4 = (obj, member, getter) => {
3444
+ var __privateGet$3 = (obj, member, getter) => {
3360
3445
  __accessCheck$4(obj, member, "read from private field");
3361
3446
  return getter ? getter.call(obj) : member.get(obj);
3362
3447
  };
@@ -3365,7 +3450,7 @@ var __privateAdd$4 = (obj, member, value) => {
3365
3450
  throw TypeError("Cannot add the same private member more than once");
3366
3451
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3367
3452
  };
3368
- var __privateSet$4 = (obj, member, value, setter) => {
3453
+ var __privateSet$2 = (obj, member, value, setter) => {
3369
3454
  __accessCheck$4(obj, member, "write to private field");
3370
3455
  setter ? setter.call(obj, value) : member.set(obj, value);
3371
3456
  return value;
@@ -3374,7 +3459,7 @@ var __privateMethod$2 = (obj, member, method) => {
3374
3459
  __accessCheck$4(obj, member, "access private method");
3375
3460
  return method;
3376
3461
  };
3377
- 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;
3462
+ 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;
3378
3463
  const BULK_OPERATION_MAX_SIZE = 1e3;
3379
3464
  class Repository extends Query {
3380
3465
  }
@@ -3395,31 +3480,31 @@ class RestRepository extends Query {
3395
3480
  __privateAdd$4(this, _deleteRecords);
3396
3481
  __privateAdd$4(this, _setCacheQuery);
3397
3482
  __privateAdd$4(this, _getCacheQuery);
3398
- __privateAdd$4(this, _getSchemaTables$1);
3483
+ __privateAdd$4(this, _getSchemaTables);
3399
3484
  __privateAdd$4(this, _transformObjectToApi);
3400
3485
  __privateAdd$4(this, _table, void 0);
3401
3486
  __privateAdd$4(this, _getFetchProps, void 0);
3402
3487
  __privateAdd$4(this, _db, void 0);
3403
3488
  __privateAdd$4(this, _cache, void 0);
3404
- __privateAdd$4(this, _schemaTables$2, void 0);
3489
+ __privateAdd$4(this, _schemaTables, void 0);
3405
3490
  __privateAdd$4(this, _trace, void 0);
3406
- __privateSet$4(this, _table, options.table);
3407
- __privateSet$4(this, _db, options.db);
3408
- __privateSet$4(this, _cache, options.pluginOptions.cache);
3409
- __privateSet$4(this, _schemaTables$2, options.schemaTables);
3410
- __privateSet$4(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3491
+ __privateSet$2(this, _table, options.table);
3492
+ __privateSet$2(this, _db, options.db);
3493
+ __privateSet$2(this, _cache, options.pluginOptions.cache);
3494
+ __privateSet$2(this, _schemaTables, options.schemaTables);
3495
+ __privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
3411
3496
  const trace = options.pluginOptions.trace ?? defaultTrace;
3412
- __privateSet$4(this, _trace, async (name, fn, options2 = {}) => {
3497
+ __privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
3413
3498
  return trace(name, fn, {
3414
3499
  ...options2,
3415
- [TraceAttributes.TABLE]: __privateGet$4(this, _table),
3500
+ [TraceAttributes.TABLE]: __privateGet$3(this, _table),
3416
3501
  [TraceAttributes.KIND]: "sdk-operation",
3417
3502
  [TraceAttributes.VERSION]: VERSION
3418
3503
  });
3419
3504
  });
3420
3505
  }
3421
3506
  async create(a, b, c, d) {
3422
- return __privateGet$4(this, _trace).call(this, "create", async () => {
3507
+ return __privateGet$3(this, _trace).call(this, "create", async () => {
3423
3508
  const ifVersion = parseIfVersion(b, c, d);
3424
3509
  if (Array.isArray(a)) {
3425
3510
  if (a.length === 0)
@@ -3449,7 +3534,7 @@ class RestRepository extends Query {
3449
3534
  });
3450
3535
  }
3451
3536
  async read(a, b) {
3452
- return __privateGet$4(this, _trace).call(this, "read", async () => {
3537
+ return __privateGet$3(this, _trace).call(this, "read", async () => {
3453
3538
  const columns = isValidSelectableColumns(b) ? b : ["*"];
3454
3539
  if (Array.isArray(a)) {
3455
3540
  if (a.length === 0)
@@ -3470,17 +3555,17 @@ class RestRepository extends Query {
3470
3555
  workspace: "{workspaceId}",
3471
3556
  dbBranchName: "{dbBranch}",
3472
3557
  region: "{region}",
3473
- tableName: __privateGet$4(this, _table),
3558
+ tableName: __privateGet$3(this, _table),
3474
3559
  recordId: id
3475
3560
  },
3476
3561
  queryParams: { columns },
3477
- ...__privateGet$4(this, _getFetchProps).call(this)
3562
+ ...__privateGet$3(this, _getFetchProps).call(this)
3478
3563
  });
3479
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3564
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3480
3565
  return initObject(
3481
- __privateGet$4(this, _db),
3566
+ __privateGet$3(this, _db),
3482
3567
  schemaTables,
3483
- __privateGet$4(this, _table),
3568
+ __privateGet$3(this, _table),
3484
3569
  response,
3485
3570
  columns
3486
3571
  );
@@ -3495,7 +3580,7 @@ class RestRepository extends Query {
3495
3580
  });
3496
3581
  }
3497
3582
  async readOrThrow(a, b) {
3498
- return __privateGet$4(this, _trace).call(this, "readOrThrow", async () => {
3583
+ return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
3499
3584
  const result = await this.read(a, b);
3500
3585
  if (Array.isArray(result)) {
3501
3586
  const missingIds = compact(
@@ -3514,7 +3599,7 @@ class RestRepository extends Query {
3514
3599
  });
3515
3600
  }
3516
3601
  async update(a, b, c, d) {
3517
- return __privateGet$4(this, _trace).call(this, "update", async () => {
3602
+ return __privateGet$3(this, _trace).call(this, "update", async () => {
3518
3603
  const ifVersion = parseIfVersion(b, c, d);
3519
3604
  if (Array.isArray(a)) {
3520
3605
  if (a.length === 0)
@@ -3547,7 +3632,7 @@ class RestRepository extends Query {
3547
3632
  });
3548
3633
  }
3549
3634
  async updateOrThrow(a, b, c, d) {
3550
- return __privateGet$4(this, _trace).call(this, "updateOrThrow", async () => {
3635
+ return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
3551
3636
  const result = await this.update(a, b, c, d);
3552
3637
  if (Array.isArray(result)) {
3553
3638
  const missingIds = compact(
@@ -3566,7 +3651,7 @@ class RestRepository extends Query {
3566
3651
  });
3567
3652
  }
3568
3653
  async createOrUpdate(a, b, c, d) {
3569
- return __privateGet$4(this, _trace).call(this, "createOrUpdate", async () => {
3654
+ return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
3570
3655
  const ifVersion = parseIfVersion(b, c, d);
3571
3656
  if (Array.isArray(a)) {
3572
3657
  if (a.length === 0)
@@ -3601,7 +3686,7 @@ class RestRepository extends Query {
3601
3686
  });
3602
3687
  }
3603
3688
  async createOrReplace(a, b, c, d) {
3604
- return __privateGet$4(this, _trace).call(this, "createOrReplace", async () => {
3689
+ return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
3605
3690
  const ifVersion = parseIfVersion(b, c, d);
3606
3691
  if (Array.isArray(a)) {
3607
3692
  if (a.length === 0)
@@ -3633,7 +3718,7 @@ class RestRepository extends Query {
3633
3718
  });
3634
3719
  }
3635
3720
  async delete(a, b) {
3636
- return __privateGet$4(this, _trace).call(this, "delete", async () => {
3721
+ return __privateGet$3(this, _trace).call(this, "delete", async () => {
3637
3722
  if (Array.isArray(a)) {
3638
3723
  if (a.length === 0)
3639
3724
  return [];
@@ -3659,7 +3744,7 @@ class RestRepository extends Query {
3659
3744
  });
3660
3745
  }
3661
3746
  async deleteOrThrow(a, b) {
3662
- return __privateGet$4(this, _trace).call(this, "deleteOrThrow", async () => {
3747
+ return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
3663
3748
  const result = await this.delete(a, b);
3664
3749
  if (Array.isArray(result)) {
3665
3750
  const missingIds = compact(
@@ -3677,13 +3762,13 @@ class RestRepository extends Query {
3677
3762
  });
3678
3763
  }
3679
3764
  async search(query, options = {}) {
3680
- return __privateGet$4(this, _trace).call(this, "search", async () => {
3765
+ return __privateGet$3(this, _trace).call(this, "search", async () => {
3681
3766
  const { records, totalCount } = await searchTable({
3682
3767
  pathParams: {
3683
3768
  workspace: "{workspaceId}",
3684
3769
  dbBranchName: "{dbBranch}",
3685
3770
  region: "{region}",
3686
- tableName: __privateGet$4(this, _table)
3771
+ tableName: __privateGet$3(this, _table)
3687
3772
  },
3688
3773
  body: {
3689
3774
  query,
@@ -3695,23 +3780,23 @@ class RestRepository extends Query {
3695
3780
  page: options.page,
3696
3781
  target: options.target
3697
3782
  },
3698
- ...__privateGet$4(this, _getFetchProps).call(this)
3783
+ ...__privateGet$3(this, _getFetchProps).call(this)
3699
3784
  });
3700
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3785
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3701
3786
  return {
3702
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3787
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3703
3788
  totalCount
3704
3789
  };
3705
3790
  });
3706
3791
  }
3707
3792
  async vectorSearch(column, query, options) {
3708
- return __privateGet$4(this, _trace).call(this, "vectorSearch", async () => {
3793
+ return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
3709
3794
  const { records, totalCount } = await vectorSearchTable({
3710
3795
  pathParams: {
3711
3796
  workspace: "{workspaceId}",
3712
3797
  dbBranchName: "{dbBranch}",
3713
3798
  region: "{region}",
3714
- tableName: __privateGet$4(this, _table)
3799
+ tableName: __privateGet$3(this, _table)
3715
3800
  },
3716
3801
  body: {
3717
3802
  column,
@@ -3720,32 +3805,32 @@ class RestRepository extends Query {
3720
3805
  size: options?.size,
3721
3806
  filter: options?.filter
3722
3807
  },
3723
- ...__privateGet$4(this, _getFetchProps).call(this)
3808
+ ...__privateGet$3(this, _getFetchProps).call(this)
3724
3809
  });
3725
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3810
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3726
3811
  return {
3727
- records: records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item, ["*"])),
3812
+ records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
3728
3813
  totalCount
3729
3814
  };
3730
3815
  });
3731
3816
  }
3732
3817
  async aggregate(aggs, filter) {
3733
- return __privateGet$4(this, _trace).call(this, "aggregate", async () => {
3818
+ return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
3734
3819
  const result = await aggregateTable({
3735
3820
  pathParams: {
3736
3821
  workspace: "{workspaceId}",
3737
3822
  dbBranchName: "{dbBranch}",
3738
3823
  region: "{region}",
3739
- tableName: __privateGet$4(this, _table)
3824
+ tableName: __privateGet$3(this, _table)
3740
3825
  },
3741
3826
  body: { aggs, filter },
3742
- ...__privateGet$4(this, _getFetchProps).call(this)
3827
+ ...__privateGet$3(this, _getFetchProps).call(this)
3743
3828
  });
3744
3829
  return result;
3745
3830
  });
3746
3831
  }
3747
3832
  async query(query) {
3748
- return __privateGet$4(this, _trace).call(this, "query", async () => {
3833
+ return __privateGet$3(this, _trace).call(this, "query", async () => {
3749
3834
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
3750
3835
  if (cacheQuery)
3751
3836
  return new Page(query, cacheQuery.meta, cacheQuery.records);
@@ -3755,7 +3840,7 @@ class RestRepository extends Query {
3755
3840
  workspace: "{workspaceId}",
3756
3841
  dbBranchName: "{dbBranch}",
3757
3842
  region: "{region}",
3758
- tableName: __privateGet$4(this, _table)
3843
+ tableName: __privateGet$3(this, _table)
3759
3844
  },
3760
3845
  body: {
3761
3846
  filter: cleanFilter(data.filter),
@@ -3765,14 +3850,14 @@ class RestRepository extends Query {
3765
3850
  consistency: data.consistency
3766
3851
  },
3767
3852
  fetchOptions: data.fetchOptions,
3768
- ...__privateGet$4(this, _getFetchProps).call(this)
3853
+ ...__privateGet$3(this, _getFetchProps).call(this)
3769
3854
  });
3770
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3855
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3771
3856
  const records = objects.map(
3772
3857
  (record) => initObject(
3773
- __privateGet$4(this, _db),
3858
+ __privateGet$3(this, _db),
3774
3859
  schemaTables,
3775
- __privateGet$4(this, _table),
3860
+ __privateGet$3(this, _table),
3776
3861
  record,
3777
3862
  data.columns ?? ["*"]
3778
3863
  )
@@ -3782,14 +3867,14 @@ class RestRepository extends Query {
3782
3867
  });
3783
3868
  }
3784
3869
  async summarizeTable(query, summaries, summariesFilter) {
3785
- return __privateGet$4(this, _trace).call(this, "summarize", async () => {
3870
+ return __privateGet$3(this, _trace).call(this, "summarize", async () => {
3786
3871
  const data = query.getQueryOptions();
3787
3872
  const result = await summarizeTable({
3788
3873
  pathParams: {
3789
3874
  workspace: "{workspaceId}",
3790
3875
  dbBranchName: "{dbBranch}",
3791
3876
  region: "{region}",
3792
- tableName: __privateGet$4(this, _table)
3877
+ tableName: __privateGet$3(this, _table)
3793
3878
  },
3794
3879
  body: {
3795
3880
  filter: cleanFilter(data.filter),
@@ -3800,13 +3885,13 @@ class RestRepository extends Query {
3800
3885
  summaries,
3801
3886
  summariesFilter
3802
3887
  },
3803
- ...__privateGet$4(this, _getFetchProps).call(this)
3888
+ ...__privateGet$3(this, _getFetchProps).call(this)
3804
3889
  });
3805
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3890
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3806
3891
  return {
3807
3892
  ...result,
3808
3893
  summaries: result.summaries.map(
3809
- (summary) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), summary, data.columns ?? [])
3894
+ (summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
3810
3895
  )
3811
3896
  };
3812
3897
  });
@@ -3818,7 +3903,7 @@ class RestRepository extends Query {
3818
3903
  workspace: "{workspaceId}",
3819
3904
  dbBranchName: "{dbBranch}",
3820
3905
  region: "{region}",
3821
- tableName: __privateGet$4(this, _table),
3906
+ tableName: __privateGet$3(this, _table),
3822
3907
  sessionId: options?.sessionId
3823
3908
  },
3824
3909
  body: {
@@ -3828,7 +3913,7 @@ class RestRepository extends Query {
3828
3913
  search: options?.searchType === "keyword" ? options?.search : void 0,
3829
3914
  vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
3830
3915
  },
3831
- ...__privateGet$4(this, _getFetchProps).call(this)
3916
+ ...__privateGet$3(this, _getFetchProps).call(this)
3832
3917
  };
3833
3918
  if (options?.onMessage) {
3834
3919
  fetchSSERequest({
@@ -3849,7 +3934,7 @@ _table = new WeakMap();
3849
3934
  _getFetchProps = new WeakMap();
3850
3935
  _db = new WeakMap();
3851
3936
  _cache = new WeakMap();
3852
- _schemaTables$2 = new WeakMap();
3937
+ _schemaTables = new WeakMap();
3853
3938
  _trace = new WeakMap();
3854
3939
  _insertRecordWithoutId = new WeakSet();
3855
3940
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
@@ -3859,14 +3944,14 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
3859
3944
  workspace: "{workspaceId}",
3860
3945
  dbBranchName: "{dbBranch}",
3861
3946
  region: "{region}",
3862
- tableName: __privateGet$4(this, _table)
3947
+ tableName: __privateGet$3(this, _table)
3863
3948
  },
3864
3949
  queryParams: { columns },
3865
3950
  body: record,
3866
- ...__privateGet$4(this, _getFetchProps).call(this)
3951
+ ...__privateGet$3(this, _getFetchProps).call(this)
3867
3952
  });
3868
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3869
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3953
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3954
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3870
3955
  };
3871
3956
  _insertRecordWithId = new WeakSet();
3872
3957
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
@@ -3878,21 +3963,21 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
3878
3963
  workspace: "{workspaceId}",
3879
3964
  dbBranchName: "{dbBranch}",
3880
3965
  region: "{region}",
3881
- tableName: __privateGet$4(this, _table),
3966
+ tableName: __privateGet$3(this, _table),
3882
3967
  recordId
3883
3968
  },
3884
3969
  body: record,
3885
3970
  queryParams: { createOnly, columns, ifVersion },
3886
- ...__privateGet$4(this, _getFetchProps).call(this)
3971
+ ...__privateGet$3(this, _getFetchProps).call(this)
3887
3972
  });
3888
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3889
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
3973
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
3974
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3890
3975
  };
3891
3976
  _insertRecords = new WeakSet();
3892
3977
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3893
3978
  const operations = await promiseMap(objects, async (object) => {
3894
3979
  const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3895
- return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
3980
+ return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
3896
3981
  });
3897
3982
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3898
3983
  const ids = [];
@@ -3904,7 +3989,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
3904
3989
  region: "{region}"
3905
3990
  },
3906
3991
  body: { operations: operations2 },
3907
- ...__privateGet$4(this, _getFetchProps).call(this)
3992
+ ...__privateGet$3(this, _getFetchProps).call(this)
3908
3993
  });
3909
3994
  for (const result of results) {
3910
3995
  if (result.operation === "insert") {
@@ -3927,15 +4012,15 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3927
4012
  workspace: "{workspaceId}",
3928
4013
  dbBranchName: "{dbBranch}",
3929
4014
  region: "{region}",
3930
- tableName: __privateGet$4(this, _table),
4015
+ tableName: __privateGet$3(this, _table),
3931
4016
  recordId
3932
4017
  },
3933
4018
  queryParams: { columns, ifVersion },
3934
4019
  body: record,
3935
- ...__privateGet$4(this, _getFetchProps).call(this)
4020
+ ...__privateGet$3(this, _getFetchProps).call(this)
3936
4021
  });
3937
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3938
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4022
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4023
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3939
4024
  } catch (e) {
3940
4025
  if (isObject(e) && e.status === 404) {
3941
4026
  return null;
@@ -3947,7 +4032,7 @@ _updateRecords = new WeakSet();
3947
4032
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3948
4033
  const operations = await promiseMap(objects, async ({ id, ...object }) => {
3949
4034
  const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
3950
- return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
4035
+ return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
3951
4036
  });
3952
4037
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
3953
4038
  const ids = [];
@@ -3959,7 +4044,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
3959
4044
  region: "{region}"
3960
4045
  },
3961
4046
  body: { operations: operations2 },
3962
- ...__privateGet$4(this, _getFetchProps).call(this)
4047
+ ...__privateGet$3(this, _getFetchProps).call(this)
3963
4048
  });
3964
4049
  for (const result of results) {
3965
4050
  if (result.operation === "update") {
@@ -3980,15 +4065,15 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
3980
4065
  workspace: "{workspaceId}",
3981
4066
  dbBranchName: "{dbBranch}",
3982
4067
  region: "{region}",
3983
- tableName: __privateGet$4(this, _table),
4068
+ tableName: __privateGet$3(this, _table),
3984
4069
  recordId
3985
4070
  },
3986
4071
  queryParams: { columns, ifVersion },
3987
4072
  body: object,
3988
- ...__privateGet$4(this, _getFetchProps).call(this)
4073
+ ...__privateGet$3(this, _getFetchProps).call(this)
3989
4074
  });
3990
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
3991
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4075
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4076
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
3992
4077
  };
3993
4078
  _deleteRecord = new WeakSet();
3994
4079
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
@@ -4000,14 +4085,14 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4000
4085
  workspace: "{workspaceId}",
4001
4086
  dbBranchName: "{dbBranch}",
4002
4087
  region: "{region}",
4003
- tableName: __privateGet$4(this, _table),
4088
+ tableName: __privateGet$3(this, _table),
4004
4089
  recordId
4005
4090
  },
4006
4091
  queryParams: { columns },
4007
- ...__privateGet$4(this, _getFetchProps).call(this)
4092
+ ...__privateGet$3(this, _getFetchProps).call(this)
4008
4093
  });
4009
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4010
- return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response, columns);
4094
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4095
+ return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4011
4096
  } catch (e) {
4012
4097
  if (isObject(e) && e.status === 404) {
4013
4098
  return null;
@@ -4018,7 +4103,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4018
4103
  _deleteRecords = new WeakSet();
4019
4104
  deleteRecords_fn = async function(recordIds) {
4020
4105
  const chunkedOperations = chunk(
4021
- compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
4106
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
4022
4107
  BULK_OPERATION_MAX_SIZE
4023
4108
  );
4024
4109
  for (const operations of chunkedOperations) {
@@ -4029,44 +4114,44 @@ deleteRecords_fn = async function(recordIds) {
4029
4114
  region: "{region}"
4030
4115
  },
4031
4116
  body: { operations },
4032
- ...__privateGet$4(this, _getFetchProps).call(this)
4117
+ ...__privateGet$3(this, _getFetchProps).call(this)
4033
4118
  });
4034
4119
  }
4035
4120
  };
4036
4121
  _setCacheQuery = new WeakSet();
4037
4122
  setCacheQuery_fn = async function(query, meta, records) {
4038
- await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4123
+ await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
4039
4124
  };
4040
4125
  _getCacheQuery = new WeakSet();
4041
4126
  getCacheQuery_fn = async function(query) {
4042
- const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
4043
- const result = await __privateGet$4(this, _cache)?.get(key);
4127
+ const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
4128
+ const result = await __privateGet$3(this, _cache)?.get(key);
4044
4129
  if (!result)
4045
4130
  return null;
4046
- const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
4131
+ const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
4047
4132
  const { cache: ttl = defaultTTL } = query.getQueryOptions();
4048
4133
  if (ttl < 0)
4049
4134
  return null;
4050
4135
  const hasExpired = result.date.getTime() + ttl < Date.now();
4051
4136
  return hasExpired ? null : result;
4052
4137
  };
4053
- _getSchemaTables$1 = new WeakSet();
4054
- getSchemaTables_fn$1 = async function() {
4055
- if (__privateGet$4(this, _schemaTables$2))
4056
- return __privateGet$4(this, _schemaTables$2);
4138
+ _getSchemaTables = new WeakSet();
4139
+ getSchemaTables_fn = async function() {
4140
+ if (__privateGet$3(this, _schemaTables))
4141
+ return __privateGet$3(this, _schemaTables);
4057
4142
  const { schema } = await getBranchDetails({
4058
4143
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4059
- ...__privateGet$4(this, _getFetchProps).call(this)
4144
+ ...__privateGet$3(this, _getFetchProps).call(this)
4060
4145
  });
4061
- __privateSet$4(this, _schemaTables$2, schema.tables);
4146
+ __privateSet$2(this, _schemaTables, schema.tables);
4062
4147
  return schema.tables;
4063
4148
  };
4064
4149
  _transformObjectToApi = new WeakSet();
4065
4150
  transformObjectToApi_fn = async function(object) {
4066
- const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
4067
- const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
4151
+ const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4152
+ const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
4068
4153
  if (!schema)
4069
- throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
4154
+ throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
4070
4155
  const result = {};
4071
4156
  for (const [key, value] of Object.entries(object)) {
4072
4157
  if (key === "xata")
@@ -4222,7 +4307,7 @@ var __accessCheck$3 = (obj, member, msg) => {
4222
4307
  if (!member.has(obj))
4223
4308
  throw TypeError("Cannot " + msg);
4224
4309
  };
4225
- var __privateGet$3 = (obj, member, getter) => {
4310
+ var __privateGet$2 = (obj, member, getter) => {
4226
4311
  __accessCheck$3(obj, member, "read from private field");
4227
4312
  return getter ? getter.call(obj) : member.get(obj);
4228
4313
  };
@@ -4231,7 +4316,7 @@ var __privateAdd$3 = (obj, member, value) => {
4231
4316
  throw TypeError("Cannot add the same private member more than once");
4232
4317
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4233
4318
  };
4234
- var __privateSet$3 = (obj, member, value, setter) => {
4319
+ var __privateSet$1 = (obj, member, value, setter) => {
4235
4320
  __accessCheck$3(obj, member, "write to private field");
4236
4321
  setter ? setter.call(obj, value) : member.set(obj, value);
4237
4322
  return value;
@@ -4240,29 +4325,29 @@ var _map;
4240
4325
  class SimpleCache {
4241
4326
  constructor(options = {}) {
4242
4327
  __privateAdd$3(this, _map, void 0);
4243
- __privateSet$3(this, _map, /* @__PURE__ */ new Map());
4328
+ __privateSet$1(this, _map, /* @__PURE__ */ new Map());
4244
4329
  this.capacity = options.max ?? 500;
4245
4330
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
4246
4331
  }
4247
4332
  async getAll() {
4248
- return Object.fromEntries(__privateGet$3(this, _map));
4333
+ return Object.fromEntries(__privateGet$2(this, _map));
4249
4334
  }
4250
4335
  async get(key) {
4251
- return __privateGet$3(this, _map).get(key) ?? null;
4336
+ return __privateGet$2(this, _map).get(key) ?? null;
4252
4337
  }
4253
4338
  async set(key, value) {
4254
4339
  await this.delete(key);
4255
- __privateGet$3(this, _map).set(key, value);
4256
- if (__privateGet$3(this, _map).size > this.capacity) {
4257
- const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
4340
+ __privateGet$2(this, _map).set(key, value);
4341
+ if (__privateGet$2(this, _map).size > this.capacity) {
4342
+ const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
4258
4343
  await this.delete(leastRecentlyUsed);
4259
4344
  }
4260
4345
  }
4261
4346
  async delete(key) {
4262
- __privateGet$3(this, _map).delete(key);
4347
+ __privateGet$2(this, _map).delete(key);
4263
4348
  }
4264
4349
  async clear() {
4265
- return __privateGet$3(this, _map).clear();
4350
+ return __privateGet$2(this, _map).clear();
4266
4351
  }
4267
4352
  }
4268
4353
  _map = new WeakMap();
@@ -4299,7 +4384,7 @@ var __accessCheck$2 = (obj, member, msg) => {
4299
4384
  if (!member.has(obj))
4300
4385
  throw TypeError("Cannot " + msg);
4301
4386
  };
4302
- var __privateGet$2 = (obj, member, getter) => {
4387
+ var __privateGet$1 = (obj, member, getter) => {
4303
4388
  __accessCheck$2(obj, member, "read from private field");
4304
4389
  return getter ? getter.call(obj) : member.get(obj);
4305
4390
  };
@@ -4308,18 +4393,11 @@ var __privateAdd$2 = (obj, member, value) => {
4308
4393
  throw TypeError("Cannot add the same private member more than once");
4309
4394
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4310
4395
  };
4311
- var __privateSet$2 = (obj, member, value, setter) => {
4312
- __accessCheck$2(obj, member, "write to private field");
4313
- setter ? setter.call(obj, value) : member.set(obj, value);
4314
- return value;
4315
- };
4316
- var _tables, _schemaTables$1;
4396
+ var _tables;
4317
4397
  class SchemaPlugin extends XataPlugin {
4318
- constructor(schemaTables) {
4398
+ constructor() {
4319
4399
  super();
4320
4400
  __privateAdd$2(this, _tables, {});
4321
- __privateAdd$2(this, _schemaTables$1, void 0);
4322
- __privateSet$2(this, _schemaTables$1, schemaTables);
4323
4401
  }
4324
4402
  build(pluginOptions) {
4325
4403
  const db = new Proxy(
@@ -4328,22 +4406,21 @@ class SchemaPlugin extends XataPlugin {
4328
4406
  get: (_target, table) => {
4329
4407
  if (!isString(table))
4330
4408
  throw new Error("Invalid table name");
4331
- if (__privateGet$2(this, _tables)[table] === void 0) {
4332
- __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4409
+ if (__privateGet$1(this, _tables)[table] === void 0) {
4410
+ __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4333
4411
  }
4334
- return __privateGet$2(this, _tables)[table];
4412
+ return __privateGet$1(this, _tables)[table];
4335
4413
  }
4336
4414
  }
4337
4415
  );
4338
- const tableNames = __privateGet$2(this, _schemaTables$1)?.map(({ name }) => name) ?? [];
4416
+ const tableNames = pluginOptions.tables?.map(({ name }) => name) ?? [];
4339
4417
  for (const table of tableNames) {
4340
- db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: __privateGet$2(this, _schemaTables$1) });
4418
+ db[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4341
4419
  }
4342
4420
  return db;
4343
4421
  }
4344
4422
  }
4345
4423
  _tables = new WeakMap();
4346
- _schemaTables$1 = new WeakMap();
4347
4424
 
4348
4425
  class FilesPlugin extends XataPlugin {
4349
4426
  build(pluginOptions) {
@@ -4423,54 +4500,40 @@ var __accessCheck$1 = (obj, member, msg) => {
4423
4500
  if (!member.has(obj))
4424
4501
  throw TypeError("Cannot " + msg);
4425
4502
  };
4426
- var __privateGet$1 = (obj, member, getter) => {
4427
- __accessCheck$1(obj, member, "read from private field");
4428
- return getter ? getter.call(obj) : member.get(obj);
4429
- };
4430
4503
  var __privateAdd$1 = (obj, member, value) => {
4431
4504
  if (member.has(obj))
4432
4505
  throw TypeError("Cannot add the same private member more than once");
4433
4506
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4434
4507
  };
4435
- var __privateSet$1 = (obj, member, value, setter) => {
4436
- __accessCheck$1(obj, member, "write to private field");
4437
- setter ? setter.call(obj, value) : member.set(obj, value);
4438
- return value;
4439
- };
4440
4508
  var __privateMethod$1 = (obj, member, method) => {
4441
4509
  __accessCheck$1(obj, member, "access private method");
4442
4510
  return method;
4443
4511
  };
4444
- var _schemaTables, _search, search_fn, _getSchemaTables, getSchemaTables_fn;
4512
+ var _search, search_fn;
4445
4513
  class SearchPlugin extends XataPlugin {
4446
- constructor(db, schemaTables) {
4514
+ constructor(db) {
4447
4515
  super();
4448
4516
  this.db = db;
4449
4517
  __privateAdd$1(this, _search);
4450
- __privateAdd$1(this, _getSchemaTables);
4451
- __privateAdd$1(this, _schemaTables, void 0);
4452
- __privateSet$1(this, _schemaTables, schemaTables);
4453
4518
  }
4454
4519
  build(pluginOptions) {
4455
4520
  return {
4456
4521
  all: async (query, options = {}) => {
4457
4522
  const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4458
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4459
4523
  return {
4460
4524
  totalCount,
4461
4525
  records: records.map((record) => {
4462
4526
  const { table = "orphan" } = record.xata;
4463
- return { table, record: initObject(this.db, schemaTables, table, record, ["*"]) };
4527
+ return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
4464
4528
  })
4465
4529
  };
4466
4530
  },
4467
4531
  byTable: async (query, options = {}) => {
4468
4532
  const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4469
- const schemaTables = await __privateMethod$1(this, _getSchemaTables, getSchemaTables_fn).call(this, pluginOptions);
4470
4533
  const records = rawRecords.reduce((acc, record) => {
4471
4534
  const { table = "orphan" } = record.xata;
4472
4535
  const items = acc[table] ?? [];
4473
- const item = initObject(this.db, schemaTables, table, record, ["*"]);
4536
+ const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
4474
4537
  return { ...acc, [table]: [...items, item] };
4475
4538
  }, {});
4476
4539
  return { totalCount, records };
@@ -4478,29 +4541,17 @@ class SearchPlugin extends XataPlugin {
4478
4541
  };
4479
4542
  }
4480
4543
  }
4481
- _schemaTables = new WeakMap();
4482
4544
  _search = new WeakSet();
4483
4545
  search_fn = async function(query, options, pluginOptions) {
4484
4546
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4485
4547
  const { records, totalCount } = await searchBranch({
4486
4548
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4487
- // @ts-ignore https://github.com/xataio/client-ts/issues/313
4549
+ // @ts-expect-error Filter properties do not match inferred type
4488
4550
  body: { tables, query, fuzziness, prefix, highlight, page },
4489
4551
  ...pluginOptions
4490
4552
  });
4491
4553
  return { records, totalCount };
4492
4554
  };
4493
- _getSchemaTables = new WeakSet();
4494
- getSchemaTables_fn = async function(pluginOptions) {
4495
- if (__privateGet$1(this, _schemaTables))
4496
- return __privateGet$1(this, _schemaTables);
4497
- const { schema } = await getBranchDetails({
4498
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4499
- ...pluginOptions
4500
- });
4501
- __privateSet$1(this, _schemaTables, schema.tables);
4502
- return schema.tables;
4503
- };
4504
4555
 
4505
4556
  function escapeElement(elementRepresentation) {
4506
4557
  const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -4562,19 +4613,17 @@ function prepareParams(param1, param2) {
4562
4613
 
4563
4614
  class SQLPlugin extends XataPlugin {
4564
4615
  build(pluginOptions) {
4565
- return async (param1, ...param2) => {
4566
- if (!isParamsObject(param1) && (!isTemplateStringsArray(param1) || !Array.isArray(param2))) {
4567
- throw new Error(
4568
- "Calling `xata.sql` as a function is not safe. Make sure to use it as a tagged template or with an object."
4569
- );
4616
+ return async (query, ...parameters) => {
4617
+ if (!isParamsObject(query) && (!isTemplateStringsArray(query) || !Array.isArray(parameters))) {
4618
+ throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
4570
4619
  }
4571
- const { statement, params, consistency } = prepareParams(param1, param2);
4572
- const { records, warning } = await sqlQuery({
4620
+ const { statement, params, consistency } = prepareParams(query, parameters);
4621
+ const { records, warning, columns } = await sqlQuery({
4573
4622
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4574
4623
  body: { statement, params, consistency },
4575
4624
  ...pluginOptions
4576
4625
  });
4577
- return { records, warning };
4626
+ return { records, warning, columns };
4578
4627
  };
4579
4628
  }
4580
4629
  }
@@ -4625,7 +4674,7 @@ var __privateMethod = (obj, member, method) => {
4625
4674
  const buildClient = (plugins) => {
4626
4675
  var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
4627
4676
  return _a = class {
4628
- constructor(options = {}, schemaTables) {
4677
+ constructor(options = {}, tables) {
4629
4678
  __privateAdd(this, _parseOptions);
4630
4679
  __privateAdd(this, _getFetchProps);
4631
4680
  __privateAdd(this, _options, void 0);
@@ -4634,13 +4683,15 @@ const buildClient = (plugins) => {
4634
4683
  const pluginOptions = {
4635
4684
  ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
4636
4685
  cache: safeOptions.cache,
4637
- host: safeOptions.host
4686
+ host: safeOptions.host,
4687
+ tables
4638
4688
  };
4639
- const db = new SchemaPlugin(schemaTables).build(pluginOptions);
4640
- const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
4689
+ const db = new SchemaPlugin().build(pluginOptions);
4690
+ const search = new SearchPlugin(db).build(pluginOptions);
4641
4691
  const transactions = new TransactionPlugin().build(pluginOptions);
4642
4692
  const sql = new SQLPlugin().build(pluginOptions);
4643
4693
  const files = new FilesPlugin().build(pluginOptions);
4694
+ this.schema = { tables };
4644
4695
  this.db = db;
4645
4696
  this.search = search;
4646
4697
  this.transactions = transactions;
@@ -4816,5 +4867,5 @@ class XataError extends Error {
4816
4867
  }
4817
4868
  }
4818
4869
 
4819
- 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, fileUpload, 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, pgRollJobStatus, pgRollMigrationHistory, 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 };
4870
+ 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, 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, 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, pgRollJobStatus, pgRollMigrationHistory, 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 };
4820
4871
  //# sourceMappingURL=index.mjs.map