@xata.io/client 0.0.0-alpha.vf6d8daa → 0.0.0-alpha.vf7b5320

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
@@ -34,7 +34,10 @@ function getEnvVariable(name) {
34
34
  }
35
35
  async function getGitBranch() {
36
36
  try {
37
- return require("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
37
+ if (typeof require === "function") {
38
+ const req = require;
39
+ return req("child_process").execSync("git branch --show-current", { encoding: "utf-8" }).trim();
40
+ }
38
41
  } catch (err) {
39
42
  }
40
43
  try {
@@ -248,6 +251,14 @@ const deleteDatabase = (variables) => fetch$1({
248
251
  method: "delete",
249
252
  ...variables
250
253
  });
254
+ const getGitBranchesMapping = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables });
255
+ const addGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables });
256
+ const removeGitBranchesEntry = (variables) => fetch$1({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables });
257
+ const resolveBranch = (variables) => fetch$1({
258
+ url: "/dbs/{dbName}/resolveBranch",
259
+ method: "get",
260
+ ...variables
261
+ });
251
262
  const getBranchDetails = (variables) => fetch$1({
252
263
  url: "/db/{dbBranchName}",
253
264
  method: "get",
@@ -376,7 +387,15 @@ const operationsByTag = {
376
387
  resendWorkspaceMemberInvite,
377
388
  acceptWorkspaceMemberInvite
378
389
  },
379
- database: { getDatabaseList, createDatabase, deleteDatabase },
390
+ database: {
391
+ getDatabaseList,
392
+ createDatabase,
393
+ deleteDatabase,
394
+ getGitBranchesMapping,
395
+ addGitBranchesEntry,
396
+ removeGitBranchesEntry,
397
+ resolveBranch
398
+ },
380
399
  branch: {
381
400
  getBranchList,
382
401
  getBranchDetails,
@@ -443,7 +462,7 @@ var __accessCheck$7 = (obj, member, msg) => {
443
462
  if (!member.has(obj))
444
463
  throw TypeError("Cannot " + msg);
445
464
  };
446
- var __privateGet$6 = (obj, member, getter) => {
465
+ var __privateGet$7 = (obj, member, getter) => {
447
466
  __accessCheck$7(obj, member, "read from private field");
448
467
  return getter ? getter.call(obj) : member.get(obj);
449
468
  };
@@ -452,7 +471,7 @@ var __privateAdd$7 = (obj, member, value) => {
452
471
  throw TypeError("Cannot add the same private member more than once");
453
472
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
454
473
  };
455
- var __privateSet$5 = (obj, member, value, setter) => {
474
+ var __privateSet$6 = (obj, member, value, setter) => {
456
475
  __accessCheck$7(obj, member, "write to private field");
457
476
  setter ? setter.call(obj, value) : member.set(obj, value);
458
477
  return value;
@@ -467,7 +486,7 @@ class XataApiClient {
467
486
  if (!apiKey) {
468
487
  throw new Error("Could not resolve a valid apiKey");
469
488
  }
470
- __privateSet$5(this, _extraProps, {
489
+ __privateSet$6(this, _extraProps, {
471
490
  apiUrl: getHostUrl(provider, "main"),
472
491
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
473
492
  fetchImpl: getFetchImplementation(options.fetch),
@@ -475,34 +494,34 @@ class XataApiClient {
475
494
  });
476
495
  }
477
496
  get user() {
478
- if (!__privateGet$6(this, _namespaces).user)
479
- __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
480
- return __privateGet$6(this, _namespaces).user;
497
+ if (!__privateGet$7(this, _namespaces).user)
498
+ __privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
499
+ return __privateGet$7(this, _namespaces).user;
481
500
  }
482
501
  get workspaces() {
483
- if (!__privateGet$6(this, _namespaces).workspaces)
484
- __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
485
- return __privateGet$6(this, _namespaces).workspaces;
502
+ if (!__privateGet$7(this, _namespaces).workspaces)
503
+ __privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
504
+ return __privateGet$7(this, _namespaces).workspaces;
486
505
  }
487
506
  get databases() {
488
- if (!__privateGet$6(this, _namespaces).databases)
489
- __privateGet$6(this, _namespaces).databases = new DatabaseApi(__privateGet$6(this, _extraProps));
490
- return __privateGet$6(this, _namespaces).databases;
507
+ if (!__privateGet$7(this, _namespaces).databases)
508
+ __privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
509
+ return __privateGet$7(this, _namespaces).databases;
491
510
  }
492
511
  get branches() {
493
- if (!__privateGet$6(this, _namespaces).branches)
494
- __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
495
- return __privateGet$6(this, _namespaces).branches;
512
+ if (!__privateGet$7(this, _namespaces).branches)
513
+ __privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
514
+ return __privateGet$7(this, _namespaces).branches;
496
515
  }
497
516
  get tables() {
498
- if (!__privateGet$6(this, _namespaces).tables)
499
- __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
500
- return __privateGet$6(this, _namespaces).tables;
517
+ if (!__privateGet$7(this, _namespaces).tables)
518
+ __privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
519
+ return __privateGet$7(this, _namespaces).tables;
501
520
  }
502
521
  get records() {
503
- if (!__privateGet$6(this, _namespaces).records)
504
- __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
505
- return __privateGet$6(this, _namespaces).records;
522
+ if (!__privateGet$7(this, _namespaces).records)
523
+ __privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
524
+ return __privateGet$7(this, _namespaces).records;
506
525
  }
507
526
  }
508
527
  _extraProps = new WeakMap();
@@ -636,6 +655,33 @@ class DatabaseApi {
636
655
  ...this.extraProps
637
656
  });
638
657
  }
658
+ getGitBranchesMapping(workspace, dbName) {
659
+ return operationsByTag.database.getGitBranchesMapping({
660
+ pathParams: { workspace, dbName },
661
+ ...this.extraProps
662
+ });
663
+ }
664
+ addGitBranchesEntry(workspace, dbName, body) {
665
+ return operationsByTag.database.addGitBranchesEntry({
666
+ pathParams: { workspace, dbName },
667
+ body,
668
+ ...this.extraProps
669
+ });
670
+ }
671
+ removeGitBranchesEntry(workspace, dbName, gitBranch) {
672
+ return operationsByTag.database.removeGitBranchesEntry({
673
+ pathParams: { workspace, dbName },
674
+ queryParams: { gitBranch },
675
+ ...this.extraProps
676
+ });
677
+ }
678
+ resolveBranch(workspace, dbName, gitBranch) {
679
+ return operationsByTag.database.resolveBranch({
680
+ pathParams: { workspace, dbName },
681
+ queryParams: { gitBranch },
682
+ ...this.extraProps
683
+ });
684
+ }
639
685
  }
640
686
  class BranchApi {
641
687
  constructor(extraProps) {
@@ -861,7 +907,7 @@ var __accessCheck$6 = (obj, member, msg) => {
861
907
  if (!member.has(obj))
862
908
  throw TypeError("Cannot " + msg);
863
909
  };
864
- var __privateGet$5 = (obj, member, getter) => {
910
+ var __privateGet$6 = (obj, member, getter) => {
865
911
  __accessCheck$6(obj, member, "read from private field");
866
912
  return getter ? getter.call(obj) : member.get(obj);
867
913
  };
@@ -870,7 +916,7 @@ var __privateAdd$6 = (obj, member, value) => {
870
916
  throw TypeError("Cannot add the same private member more than once");
871
917
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
872
918
  };
873
- var __privateSet$4 = (obj, member, value, setter) => {
919
+ var __privateSet$5 = (obj, member, value, setter) => {
874
920
  __accessCheck$6(obj, member, "write to private field");
875
921
  setter ? setter.call(obj, value) : member.set(obj, value);
876
922
  return value;
@@ -879,21 +925,21 @@ var _query;
879
925
  class Page {
880
926
  constructor(query, meta, records = []) {
881
927
  __privateAdd$6(this, _query, void 0);
882
- __privateSet$4(this, _query, query);
928
+ __privateSet$5(this, _query, query);
883
929
  this.meta = meta;
884
930
  this.records = records;
885
931
  }
886
932
  async nextPage(size, offset) {
887
- return __privateGet$5(this, _query).getPaginated({ page: { size, offset, after: this.meta.page.cursor } });
933
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
888
934
  }
889
935
  async previousPage(size, offset) {
890
- return __privateGet$5(this, _query).getPaginated({ page: { size, offset, before: this.meta.page.cursor } });
936
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
891
937
  }
892
938
  async firstPage(size, offset) {
893
- return __privateGet$5(this, _query).getPaginated({ page: { size, offset, first: this.meta.page.cursor } });
939
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
894
940
  }
895
941
  async lastPage(size, offset) {
896
- return __privateGet$5(this, _query).getPaginated({ page: { size, offset, last: this.meta.page.cursor } });
942
+ return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
897
943
  }
898
944
  hasNextPage() {
899
945
  return this.meta.page.more;
@@ -909,7 +955,7 @@ var __accessCheck$5 = (obj, member, msg) => {
909
955
  if (!member.has(obj))
910
956
  throw TypeError("Cannot " + msg);
911
957
  };
912
- var __privateGet$4 = (obj, member, getter) => {
958
+ var __privateGet$5 = (obj, member, getter) => {
913
959
  __accessCheck$5(obj, member, "read from private field");
914
960
  return getter ? getter.call(obj) : member.get(obj);
915
961
  };
@@ -918,7 +964,7 @@ var __privateAdd$5 = (obj, member, value) => {
918
964
  throw TypeError("Cannot add the same private member more than once");
919
965
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
920
966
  };
921
- var __privateSet$3 = (obj, member, value, setter) => {
967
+ var __privateSet$4 = (obj, member, value, setter) => {
922
968
  __accessCheck$5(obj, member, "write to private field");
923
969
  setter ? setter.call(obj, value) : member.set(obj, value);
924
970
  return value;
@@ -931,21 +977,21 @@ const _Query = class {
931
977
  __privateAdd$5(this, _data, { filter: {} });
932
978
  this.meta = { page: { cursor: "start", more: true } };
933
979
  this.records = [];
934
- __privateSet$3(this, _table$1, table);
980
+ __privateSet$4(this, _table$1, table);
935
981
  if (repository) {
936
- __privateSet$3(this, _repository, repository);
982
+ __privateSet$4(this, _repository, repository);
937
983
  } else {
938
- __privateSet$3(this, _repository, this);
984
+ __privateSet$4(this, _repository, this);
939
985
  }
940
- __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
941
- __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
942
- __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
943
- __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
944
- __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
945
- __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
946
- __privateGet$4(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
947
- __privateGet$4(this, _data).page = data.page ?? parent?.page;
948
- __privateGet$4(this, _data).ttl = data.ttl ?? parent?.ttl;
986
+ __privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
987
+ __privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
988
+ __privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
989
+ __privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
990
+ __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
991
+ __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
992
+ __privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
993
+ __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
994
+ __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
949
995
  this.any = this.any.bind(this);
950
996
  this.all = this.all.bind(this);
951
997
  this.not = this.not.bind(this);
@@ -956,50 +1002,50 @@ const _Query = class {
956
1002
  Object.defineProperty(this, "repository", { enumerable: false });
957
1003
  }
958
1004
  getQueryOptions() {
959
- return __privateGet$4(this, _data);
1005
+ return __privateGet$5(this, _data);
960
1006
  }
961
1007
  key() {
962
- const { columns = [], filter = {}, sort = [], page = {} } = __privateGet$4(this, _data);
963
- const key = JSON.stringify({ columns, filter, sort, page });
1008
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
1009
+ const key = JSON.stringify({ columns, filter, sort, pagination });
964
1010
  return toBase64(key);
965
1011
  }
966
1012
  any(...queries) {
967
1013
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
968
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
1014
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
969
1015
  }
970
1016
  all(...queries) {
971
1017
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
972
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
1018
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
973
1019
  }
974
1020
  not(...queries) {
975
1021
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
976
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
1022
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
977
1023
  }
978
1024
  none(...queries) {
979
1025
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
980
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
1026
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
981
1027
  }
982
1028
  filter(a, b) {
983
1029
  if (arguments.length === 1) {
984
1030
  const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
985
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
986
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
1031
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1032
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
987
1033
  } else {
988
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
989
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
1034
+ const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1035
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
990
1036
  }
991
1037
  }
992
1038
  sort(column, direction) {
993
- const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
1039
+ const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
994
1040
  const sort = [...originalSort, { column, direction }];
995
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
1041
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
996
1042
  }
997
1043
  select(columns) {
998
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { columns }, __privateGet$4(this, _data));
1044
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
999
1045
  }
1000
1046
  getPaginated(options = {}) {
1001
- const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
1002
- return __privateGet$4(this, _repository).query(query);
1047
+ const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
1048
+ return __privateGet$5(this, _repository).query(query);
1003
1049
  }
1004
1050
  async *[Symbol.asyncIterator]() {
1005
1051
  for await (const [record] of this.getIterator(1)) {
@@ -1010,7 +1056,7 @@ const _Query = class {
1010
1056
  let offset = 0;
1011
1057
  let end = false;
1012
1058
  while (!end) {
1013
- const { records, meta } = await this.getPaginated({ ...options, page: { size: chunk, offset } });
1059
+ const { records, meta } = await this.getPaginated({ ...options, pagination: { size: chunk, offset } });
1014
1060
  yield records;
1015
1061
  offset += chunk;
1016
1062
  end = !meta.page.more;
@@ -1028,9 +1074,12 @@ const _Query = class {
1028
1074
  return results;
1029
1075
  }
1030
1076
  async getFirst(options = {}) {
1031
- const records = await this.getMany({ ...options, page: { size: 1 } });
1077
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1032
1078
  return records[0] || null;
1033
1079
  }
1080
+ cache(ttl) {
1081
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1082
+ }
1034
1083
  nextPage(size, offset) {
1035
1084
  return this.firstPage(size, offset);
1036
1085
  }
@@ -1038,10 +1087,10 @@ const _Query = class {
1038
1087
  return this.firstPage(size, offset);
1039
1088
  }
1040
1089
  firstPage(size, offset) {
1041
- return this.getPaginated({ page: { size, offset } });
1090
+ return this.getPaginated({ pagination: { size, offset } });
1042
1091
  }
1043
1092
  lastPage(size, offset) {
1044
- return this.getPaginated({ page: { size, offset, before: "end" } });
1093
+ return this.getPaginated({ pagination: { size, offset, before: "end" } });
1045
1094
  }
1046
1095
  hasNextPage() {
1047
1096
  return this.meta.page.more;
@@ -1086,7 +1135,7 @@ var __accessCheck$4 = (obj, member, msg) => {
1086
1135
  if (!member.has(obj))
1087
1136
  throw TypeError("Cannot " + msg);
1088
1137
  };
1089
- var __privateGet$3 = (obj, member, getter) => {
1138
+ var __privateGet$4 = (obj, member, getter) => {
1090
1139
  __accessCheck$4(obj, member, "read from private field");
1091
1140
  return getter ? getter.call(obj) : member.get(obj);
1092
1141
  };
@@ -1095,7 +1144,7 @@ var __privateAdd$4 = (obj, member, value) => {
1095
1144
  throw TypeError("Cannot add the same private member more than once");
1096
1145
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1097
1146
  };
1098
- var __privateSet$2 = (obj, member, value, setter) => {
1147
+ var __privateSet$3 = (obj, member, value, setter) => {
1099
1148
  __accessCheck$4(obj, member, "write to private field");
1100
1149
  setter ? setter.call(obj, value) : member.set(obj, value);
1101
1150
  return value;
@@ -1104,7 +1153,7 @@ var __privateMethod$2 = (obj, member, method) => {
1104
1153
  __accessCheck$4(obj, member, "access private method");
1105
1154
  return method;
1106
1155
  };
1107
- var _table, _links, _getFetchProps, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn;
1156
+ var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
1108
1157
  class Repository extends Query {
1109
1158
  }
1110
1159
  class RestRepository extends Query {
@@ -1121,14 +1170,15 @@ class RestRepository extends Query {
1121
1170
  __privateAdd$4(this, _getCacheRecord);
1122
1171
  __privateAdd$4(this, _setCacheQuery);
1123
1172
  __privateAdd$4(this, _getCacheQuery);
1173
+ __privateAdd$4(this, _getSchema$1);
1124
1174
  __privateAdd$4(this, _table, void 0);
1125
- __privateAdd$4(this, _links, void 0);
1126
1175
  __privateAdd$4(this, _getFetchProps, void 0);
1127
- __privateSet$2(this, _table, options.table);
1128
- __privateSet$2(this, _links, options.links ?? {});
1129
- __privateSet$2(this, _getFetchProps, options.pluginOptions.getFetchProps);
1176
+ __privateAdd$4(this, _cache, void 0);
1177
+ __privateAdd$4(this, _schema$1, void 0);
1178
+ __privateSet$3(this, _table, options.table);
1179
+ __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1130
1180
  this.db = options.db;
1131
- this.cache = options.pluginOptions.cache;
1181
+ __privateSet$3(this, _cache, options.pluginOptions.cache);
1132
1182
  }
1133
1183
  async create(a, b) {
1134
1184
  if (Array.isArray(a)) {
@@ -1161,13 +1211,14 @@ class RestRepository extends Query {
1161
1211
  const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
1162
1212
  if (cacheRecord)
1163
1213
  return cacheRecord;
1164
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1214
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1165
1215
  try {
1166
1216
  const response = await getRecord({
1167
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1217
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1168
1218
  ...fetchProps
1169
1219
  });
1170
- return initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), response);
1220
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1221
+ return initObject(this.db, schema, __privateGet$4(this, _table), response);
1171
1222
  } catch (e) {
1172
1223
  if (isObject(e) && e.status === 404) {
1173
1224
  return null;
@@ -1238,13 +1289,14 @@ class RestRepository extends Query {
1238
1289
  throw new Error("Invalid arguments for delete method");
1239
1290
  }
1240
1291
  async search(query, options = {}) {
1241
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1292
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1242
1293
  const { records } = await searchBranch({
1243
1294
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1244
- body: { tables: [__privateGet$3(this, _table)], query, fuzziness: options.fuzziness },
1295
+ body: { tables: [__privateGet$4(this, _table)], query, fuzziness: options.fuzziness },
1245
1296
  ...fetchProps
1246
1297
  });
1247
- return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
1298
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1299
+ return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1248
1300
  }
1249
1301
  async query(query) {
1250
1302
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
@@ -1254,32 +1306,34 @@ class RestRepository extends Query {
1254
1306
  const body = {
1255
1307
  filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1256
1308
  sort: data.sort ? buildSortFilter(data.sort) : void 0,
1257
- page: data.page,
1309
+ page: data.pagination,
1258
1310
  columns: data.columns
1259
1311
  };
1260
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1312
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1261
1313
  const { meta, records: objects } = await queryTable({
1262
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table) },
1314
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1263
1315
  body,
1264
1316
  ...fetchProps
1265
1317
  });
1266
- const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
1318
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1319
+ const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1267
1320
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1268
1321
  return new Page(query, meta, records);
1269
1322
  }
1270
1323
  }
1271
1324
  _table = new WeakMap();
1272
- _links = new WeakMap();
1273
1325
  _getFetchProps = new WeakMap();
1326
+ _cache = new WeakMap();
1327
+ _schema$1 = new WeakMap();
1274
1328
  _insertRecordWithoutId = new WeakSet();
1275
1329
  insertRecordWithoutId_fn = async function(object) {
1276
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1330
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1277
1331
  const record = transformObjectLinks(object);
1278
1332
  const response = await insertRecord({
1279
1333
  pathParams: {
1280
1334
  workspace: "{workspaceId}",
1281
1335
  dbBranchName: "{dbBranch}",
1282
- tableName: __privateGet$3(this, _table)
1336
+ tableName: __privateGet$4(this, _table)
1283
1337
  },
1284
1338
  body: record,
1285
1339
  ...fetchProps
@@ -1292,13 +1346,13 @@ insertRecordWithoutId_fn = async function(object) {
1292
1346
  };
1293
1347
  _insertRecordWithId = new WeakSet();
1294
1348
  insertRecordWithId_fn = async function(recordId, object) {
1295
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1349
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1296
1350
  const record = transformObjectLinks(object);
1297
1351
  const response = await insertRecordWithID({
1298
1352
  pathParams: {
1299
1353
  workspace: "{workspaceId}",
1300
1354
  dbBranchName: "{dbBranch}",
1301
- tableName: __privateGet$3(this, _table),
1355
+ tableName: __privateGet$4(this, _table),
1302
1356
  recordId
1303
1357
  },
1304
1358
  body: record,
@@ -1313,10 +1367,10 @@ insertRecordWithId_fn = async function(recordId, object) {
1313
1367
  };
1314
1368
  _bulkInsertTableRecords = new WeakSet();
1315
1369
  bulkInsertTableRecords_fn = async function(objects) {
1316
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1370
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1317
1371
  const records = objects.map((object) => transformObjectLinks(object));
1318
1372
  const response = await bulkInsertTableRecords({
1319
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table) },
1373
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1320
1374
  body: { records },
1321
1375
  ...fetchProps
1322
1376
  });
@@ -1328,10 +1382,10 @@ bulkInsertTableRecords_fn = async function(objects) {
1328
1382
  };
1329
1383
  _updateRecordWithID = new WeakSet();
1330
1384
  updateRecordWithID_fn = async function(recordId, object) {
1331
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1385
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1332
1386
  const record = transformObjectLinks(object);
1333
1387
  const response = await updateRecordWithID({
1334
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1388
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1335
1389
  body: record,
1336
1390
  ...fetchProps
1337
1391
  });
@@ -1342,9 +1396,9 @@ updateRecordWithID_fn = async function(recordId, object) {
1342
1396
  };
1343
1397
  _upsertRecordWithID = new WeakSet();
1344
1398
  upsertRecordWithID_fn = async function(recordId, object) {
1345
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1399
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1346
1400
  const response = await upsertRecordWithID({
1347
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1401
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1348
1402
  body: object,
1349
1403
  ...fetchProps
1350
1404
  });
@@ -1355,47 +1409,63 @@ upsertRecordWithID_fn = async function(recordId, object) {
1355
1409
  };
1356
1410
  _deleteRecord = new WeakSet();
1357
1411
  deleteRecord_fn = async function(recordId) {
1358
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1412
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1359
1413
  await deleteRecord({
1360
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1414
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1361
1415
  ...fetchProps
1362
1416
  });
1363
1417
  };
1364
1418
  _invalidateCache = new WeakSet();
1365
1419
  invalidateCache_fn = async function(recordId) {
1366
- await this.cache.delete(`rec_${__privateGet$3(this, _table)}:${recordId}`);
1367
- const cacheItems = await this.cache.getAll();
1420
+ await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1421
+ const cacheItems = await __privateGet$4(this, _cache).getAll();
1368
1422
  const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1369
1423
  for (const [key, value] of queries) {
1370
1424
  const ids = getIds(value);
1371
1425
  if (ids.includes(recordId))
1372
- await this.cache.delete(key);
1426
+ await __privateGet$4(this, _cache).delete(key);
1373
1427
  }
1374
1428
  };
1375
1429
  _setCacheRecord = new WeakSet();
1376
1430
  setCacheRecord_fn = async function(record) {
1377
- await this.cache.set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
1431
+ if (!__privateGet$4(this, _cache).cacheRecords)
1432
+ return;
1433
+ await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1378
1434
  };
1379
1435
  _getCacheRecord = new WeakSet();
1380
1436
  getCacheRecord_fn = async function(recordId) {
1381
- return this.cache.get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
1437
+ if (!__privateGet$4(this, _cache).cacheRecords)
1438
+ return null;
1439
+ return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1382
1440
  };
1383
1441
  _setCacheQuery = new WeakSet();
1384
1442
  setCacheQuery_fn = async function(query, meta, records) {
1385
- await this.cache.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1443
+ await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1386
1444
  };
1387
1445
  _getCacheQuery = new WeakSet();
1388
1446
  getCacheQuery_fn = async function(query) {
1389
- const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
1390
- const result = await this.cache.get(key);
1447
+ const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
1448
+ const result = await __privateGet$4(this, _cache).get(key);
1391
1449
  if (!result)
1392
1450
  return null;
1393
- const { ttl = 0 } = query.getQueryOptions();
1451
+ const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
1394
1452
  if (!ttl || ttl < 0)
1395
1453
  return result;
1396
1454
  const hasExpired = result.date.getTime() + ttl < Date.now();
1397
1455
  return hasExpired ? null : result;
1398
1456
  };
1457
+ _getSchema$1 = new WeakSet();
1458
+ getSchema_fn$1 = async function() {
1459
+ if (__privateGet$4(this, _schema$1))
1460
+ return __privateGet$4(this, _schema$1);
1461
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1462
+ const { schema } = await getBranchDetails({
1463
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1464
+ ...fetchProps
1465
+ });
1466
+ __privateSet$3(this, _schema$1, schema);
1467
+ return schema;
1468
+ };
1399
1469
  const transformObjectLinks = (object) => {
1400
1470
  return Object.entries(object).reduce((acc, [key, value]) => {
1401
1471
  if (key === "xata")
@@ -1403,15 +1473,33 @@ const transformObjectLinks = (object) => {
1403
1473
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1404
1474
  }, {});
1405
1475
  };
1406
- const initObject = (db, links, table, object) => {
1476
+ const initObject = (db, schema, table, object) => {
1407
1477
  const result = {};
1408
1478
  Object.assign(result, object);
1409
- const tableLinks = links[table] || [];
1410
- for (const link of tableLinks) {
1411
- const [field, linkTable] = link;
1412
- const value = result[field];
1413
- if (value && isObject(value)) {
1414
- result[field] = initObject(db, links, linkTable, value);
1479
+ const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
1480
+ if (!columns)
1481
+ console.error(`Table ${table} not found in schema`);
1482
+ for (const column of columns ?? []) {
1483
+ const value = result[column.name];
1484
+ switch (column.type) {
1485
+ case "datetime": {
1486
+ const date = new Date(value);
1487
+ if (isNaN(date.getTime())) {
1488
+ console.error(`Failed to parse date ${value} for field ${column.name}`);
1489
+ } else {
1490
+ result[column.name] = date;
1491
+ }
1492
+ break;
1493
+ }
1494
+ case "link": {
1495
+ const linkTable = column.link?.table;
1496
+ if (!linkTable) {
1497
+ console.error(`Failed to parse link for field ${column.name}`);
1498
+ } else if (value && isObject(value)) {
1499
+ result[column.name] = initObject(db, schema, linkTable, value);
1500
+ }
1501
+ break;
1502
+ }
1415
1503
  }
1416
1504
  }
1417
1505
  result.read = function() {
@@ -1443,7 +1531,7 @@ var __accessCheck$3 = (obj, member, msg) => {
1443
1531
  if (!member.has(obj))
1444
1532
  throw TypeError("Cannot " + msg);
1445
1533
  };
1446
- var __privateGet$2 = (obj, member, getter) => {
1534
+ var __privateGet$3 = (obj, member, getter) => {
1447
1535
  __accessCheck$3(obj, member, "read from private field");
1448
1536
  return getter ? getter.call(obj) : member.get(obj);
1449
1537
  };
@@ -1452,31 +1540,39 @@ var __privateAdd$3 = (obj, member, value) => {
1452
1540
  throw TypeError("Cannot add the same private member more than once");
1453
1541
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1454
1542
  };
1455
- var __privateSet$1 = (obj, member, value, setter) => {
1543
+ var __privateSet$2 = (obj, member, value, setter) => {
1456
1544
  __accessCheck$3(obj, member, "write to private field");
1457
1545
  setter ? setter.call(obj, value) : member.set(obj, value);
1458
1546
  return value;
1459
1547
  };
1460
1548
  var _map;
1461
1549
  class SimpleCache {
1462
- constructor() {
1550
+ constructor(options = {}) {
1463
1551
  __privateAdd$3(this, _map, void 0);
1464
- __privateSet$1(this, _map, /* @__PURE__ */ new Map());
1552
+ __privateSet$2(this, _map, /* @__PURE__ */ new Map());
1553
+ this.capacity = options.max ?? 500;
1554
+ this.cacheRecords = options.cacheRecords ?? true;
1555
+ this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1465
1556
  }
1466
1557
  async getAll() {
1467
- return Object.fromEntries(__privateGet$2(this, _map));
1558
+ return Object.fromEntries(__privateGet$3(this, _map));
1468
1559
  }
1469
1560
  async get(key) {
1470
- return __privateGet$2(this, _map).get(key) ?? null;
1561
+ return __privateGet$3(this, _map).get(key) ?? null;
1471
1562
  }
1472
1563
  async set(key, value) {
1473
- __privateGet$2(this, _map).set(key, value);
1564
+ await this.delete(key);
1565
+ __privateGet$3(this, _map).set(key, value);
1566
+ if (__privateGet$3(this, _map).size > this.capacity) {
1567
+ const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
1568
+ await this.delete(leastRecentlyUsed);
1569
+ }
1474
1570
  }
1475
1571
  async delete(key) {
1476
- __privateGet$2(this, _map).delete(key);
1572
+ __privateGet$3(this, _map).delete(key);
1477
1573
  }
1478
1574
  async clear() {
1479
- return __privateGet$2(this, _map).clear();
1575
+ return __privateGet$3(this, _map).clear();
1480
1576
  }
1481
1577
  }
1482
1578
  _map = new WeakMap();
@@ -1504,7 +1600,7 @@ var __accessCheck$2 = (obj, member, msg) => {
1504
1600
  if (!member.has(obj))
1505
1601
  throw TypeError("Cannot " + msg);
1506
1602
  };
1507
- var __privateGet$1 = (obj, member, getter) => {
1603
+ var __privateGet$2 = (obj, member, getter) => {
1508
1604
  __accessCheck$2(obj, member, "read from private field");
1509
1605
  return getter ? getter.call(obj) : member.get(obj);
1510
1606
  };
@@ -1515,26 +1611,24 @@ var __privateAdd$2 = (obj, member, value) => {
1515
1611
  };
1516
1612
  var _tables;
1517
1613
  class SchemaPlugin extends XataPlugin {
1518
- constructor(links, tableNames) {
1614
+ constructor(tableNames) {
1519
1615
  super();
1520
- this.links = links;
1521
1616
  this.tableNames = tableNames;
1522
1617
  __privateAdd$2(this, _tables, {});
1523
1618
  }
1524
1619
  build(pluginOptions) {
1525
- const links = this.links;
1526
1620
  const db = new Proxy({}, {
1527
1621
  get: (_target, table) => {
1528
1622
  if (!isString(table))
1529
1623
  throw new Error("Invalid table name");
1530
- if (!__privateGet$1(this, _tables)[table]) {
1531
- __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, links });
1624
+ if (!__privateGet$2(this, _tables)[table]) {
1625
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
1532
1626
  }
1533
- return __privateGet$1(this, _tables)[table];
1627
+ return __privateGet$2(this, _tables)[table];
1534
1628
  }
1535
1629
  });
1536
1630
  for (const table of this.tableNames ?? []) {
1537
- db[table] = new RestRepository({ db, pluginOptions, table, links });
1631
+ db[table] = new RestRepository({ db, pluginOptions, table });
1538
1632
  }
1539
1633
  return db;
1540
1634
  }
@@ -1545,44 +1639,57 @@ var __accessCheck$1 = (obj, member, msg) => {
1545
1639
  if (!member.has(obj))
1546
1640
  throw TypeError("Cannot " + msg);
1547
1641
  };
1642
+ var __privateGet$1 = (obj, member, getter) => {
1643
+ __accessCheck$1(obj, member, "read from private field");
1644
+ return getter ? getter.call(obj) : member.get(obj);
1645
+ };
1548
1646
  var __privateAdd$1 = (obj, member, value) => {
1549
1647
  if (member.has(obj))
1550
1648
  throw TypeError("Cannot add the same private member more than once");
1551
1649
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1552
1650
  };
1651
+ var __privateSet$1 = (obj, member, value, setter) => {
1652
+ __accessCheck$1(obj, member, "write to private field");
1653
+ setter ? setter.call(obj, value) : member.set(obj, value);
1654
+ return value;
1655
+ };
1553
1656
  var __privateMethod$1 = (obj, member, method) => {
1554
1657
  __accessCheck$1(obj, member, "access private method");
1555
1658
  return method;
1556
1659
  };
1557
- var _search, search_fn;
1660
+ var _schema, _search, search_fn, _getSchema, getSchema_fn;
1558
1661
  class SearchPlugin extends XataPlugin {
1559
- constructor(db, links) {
1662
+ constructor(db) {
1560
1663
  super();
1561
1664
  this.db = db;
1562
- this.links = links;
1563
1665
  __privateAdd$1(this, _search);
1666
+ __privateAdd$1(this, _getSchema);
1667
+ __privateAdd$1(this, _schema, void 0);
1564
1668
  }
1565
1669
  build({ getFetchProps }) {
1566
1670
  return {
1567
1671
  all: async (query, options = {}) => {
1568
1672
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1673
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1569
1674
  return records.map((record) => {
1570
1675
  const { table = "orphan" } = record.xata;
1571
- return { table, record: initObject(this.db, this.links, table, record) };
1676
+ return { table, record: initObject(this.db, schema, table, record) };
1572
1677
  });
1573
1678
  },
1574
1679
  byTable: async (query, options = {}) => {
1575
1680
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1681
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1576
1682
  return records.reduce((acc, record) => {
1577
1683
  const { table = "orphan" } = record.xata;
1578
1684
  const items = acc[table] ?? [];
1579
- const item = initObject(this.db, this.links, table, record);
1685
+ const item = initObject(this.db, schema, table, record);
1580
1686
  return { ...acc, [table]: [...items, item] };
1581
1687
  }, {});
1582
1688
  }
1583
1689
  };
1584
1690
  }
1585
1691
  }
1692
+ _schema = new WeakMap();
1586
1693
  _search = new WeakSet();
1587
1694
  search_fn = async function(query, options, getFetchProps) {
1588
1695
  const fetchProps = await getFetchProps();
@@ -1594,6 +1701,18 @@ search_fn = async function(query, options, getFetchProps) {
1594
1701
  });
1595
1702
  return records;
1596
1703
  };
1704
+ _getSchema = new WeakSet();
1705
+ getSchema_fn = async function(getFetchProps) {
1706
+ if (__privateGet$1(this, _schema))
1707
+ return __privateGet$1(this, _schema);
1708
+ const fetchProps = await getFetchProps();
1709
+ const { schema } = await getBranchDetails({
1710
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1711
+ ...fetchProps
1712
+ });
1713
+ __privateSet$1(this, _schema, schema);
1714
+ return schema;
1715
+ };
1597
1716
 
1598
1717
  const isBranchStrategyBuilder = (strategy) => {
1599
1718
  return typeof strategy === "function";
@@ -1702,7 +1821,7 @@ var __privateMethod = (obj, member, method) => {
1702
1821
  const buildClient = (plugins) => {
1703
1822
  var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1704
1823
  return _a = class {
1705
- constructor(options = {}, links, tables) {
1824
+ constructor(options = {}, tables) {
1706
1825
  __privateAdd(this, _parseOptions);
1707
1826
  __privateAdd(this, _getFetchProps);
1708
1827
  __privateAdd(this, _evaluateBranch);
@@ -1712,8 +1831,8 @@ const buildClient = (plugins) => {
1712
1831
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1713
1832
  cache: safeOptions.cache
1714
1833
  };
1715
- const db = new SchemaPlugin(links, tables).build(pluginOptions);
1716
- const search = new SearchPlugin(db, links ?? {}).build(pluginOptions);
1834
+ const db = new SchemaPlugin(tables).build(pluginOptions);
1835
+ const search = new SearchPlugin(db).build(pluginOptions);
1717
1836
  this.db = db;
1718
1837
  this.search = search;
1719
1838
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
@@ -1733,7 +1852,7 @@ const buildClient = (plugins) => {
1733
1852
  const fetch = getFetchImplementation(options?.fetch);
1734
1853
  const databaseURL = options?.databaseURL || getDatabaseURL();
1735
1854
  const apiKey = options?.apiKey || getAPIKey();
1736
- const cache = options?.cache ?? new SimpleCache();
1855
+ const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
1737
1856
  const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1738
1857
  if (!databaseURL || !apiKey) {
1739
1858
  throw new Error("Options databaseURL and apiKey are required");
@@ -1786,5 +1905,5 @@ class XataError extends Error {
1786
1905
  }
1787
1906
  }
1788
1907
 
1789
- export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeWorkspaceMember, resendWorkspaceMemberInvite, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
1908
+ export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
1790
1909
  //# sourceMappingURL=index.mjs.map