@xata.io/client 0.9.1 → 0.10.0

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
@@ -462,7 +462,7 @@ var __accessCheck$7 = (obj, member, msg) => {
462
462
  if (!member.has(obj))
463
463
  throw TypeError("Cannot " + msg);
464
464
  };
465
- var __privateGet$6 = (obj, member, getter) => {
465
+ var __privateGet$7 = (obj, member, getter) => {
466
466
  __accessCheck$7(obj, member, "read from private field");
467
467
  return getter ? getter.call(obj) : member.get(obj);
468
468
  };
@@ -471,7 +471,7 @@ var __privateAdd$7 = (obj, member, value) => {
471
471
  throw TypeError("Cannot add the same private member more than once");
472
472
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
473
473
  };
474
- var __privateSet$5 = (obj, member, value, setter) => {
474
+ var __privateSet$6 = (obj, member, value, setter) => {
475
475
  __accessCheck$7(obj, member, "write to private field");
476
476
  setter ? setter.call(obj, value) : member.set(obj, value);
477
477
  return value;
@@ -486,7 +486,7 @@ class XataApiClient {
486
486
  if (!apiKey) {
487
487
  throw new Error("Could not resolve a valid apiKey");
488
488
  }
489
- __privateSet$5(this, _extraProps, {
489
+ __privateSet$6(this, _extraProps, {
490
490
  apiUrl: getHostUrl(provider, "main"),
491
491
  workspacesApiUrl: getHostUrl(provider, "workspaces"),
492
492
  fetchImpl: getFetchImplementation(options.fetch),
@@ -494,34 +494,34 @@ class XataApiClient {
494
494
  });
495
495
  }
496
496
  get user() {
497
- if (!__privateGet$6(this, _namespaces).user)
498
- __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
499
- 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;
500
500
  }
501
501
  get workspaces() {
502
- if (!__privateGet$6(this, _namespaces).workspaces)
503
- __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
504
- 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;
505
505
  }
506
506
  get databases() {
507
- if (!__privateGet$6(this, _namespaces).databases)
508
- __privateGet$6(this, _namespaces).databases = new DatabaseApi(__privateGet$6(this, _extraProps));
509
- 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;
510
510
  }
511
511
  get branches() {
512
- if (!__privateGet$6(this, _namespaces).branches)
513
- __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
514
- 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;
515
515
  }
516
516
  get tables() {
517
- if (!__privateGet$6(this, _namespaces).tables)
518
- __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
519
- 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;
520
520
  }
521
521
  get records() {
522
- if (!__privateGet$6(this, _namespaces).records)
523
- __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
524
- 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;
525
525
  }
526
526
  }
527
527
  _extraProps = new WeakMap();
@@ -699,10 +699,10 @@ class BranchApi {
699
699
  ...this.extraProps
700
700
  });
701
701
  }
702
- createBranch(workspace, database, branch, from = "", options = {}) {
702
+ createBranch(workspace, database, branch, from, options = {}) {
703
703
  return operationsByTag.branch.createBranch({
704
704
  pathParams: { workspace, dbBranchName: `${database}:${branch}` },
705
- queryParams: { from },
705
+ queryParams: isString(from) ? { from } : void 0,
706
706
  body: options,
707
707
  ...this.extraProps
708
708
  });
@@ -907,7 +907,7 @@ var __accessCheck$6 = (obj, member, msg) => {
907
907
  if (!member.has(obj))
908
908
  throw TypeError("Cannot " + msg);
909
909
  };
910
- var __privateGet$5 = (obj, member, getter) => {
910
+ var __privateGet$6 = (obj, member, getter) => {
911
911
  __accessCheck$6(obj, member, "read from private field");
912
912
  return getter ? getter.call(obj) : member.get(obj);
913
913
  };
@@ -916,7 +916,7 @@ var __privateAdd$6 = (obj, member, value) => {
916
916
  throw TypeError("Cannot add the same private member more than once");
917
917
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
918
918
  };
919
- var __privateSet$4 = (obj, member, value, setter) => {
919
+ var __privateSet$5 = (obj, member, value, setter) => {
920
920
  __accessCheck$6(obj, member, "write to private field");
921
921
  setter ? setter.call(obj, value) : member.set(obj, value);
922
922
  return value;
@@ -925,21 +925,21 @@ var _query;
925
925
  class Page {
926
926
  constructor(query, meta, records = []) {
927
927
  __privateAdd$6(this, _query, void 0);
928
- __privateSet$4(this, _query, query);
928
+ __privateSet$5(this, _query, query);
929
929
  this.meta = meta;
930
930
  this.records = records;
931
931
  }
932
932
  async nextPage(size, offset) {
933
- 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 } });
934
934
  }
935
935
  async previousPage(size, offset) {
936
- 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 } });
937
937
  }
938
938
  async firstPage(size, offset) {
939
- 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 } });
940
940
  }
941
941
  async lastPage(size, offset) {
942
- 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 } });
943
943
  }
944
944
  hasNextPage() {
945
945
  return this.meta.page.more;
@@ -955,7 +955,7 @@ var __accessCheck$5 = (obj, member, msg) => {
955
955
  if (!member.has(obj))
956
956
  throw TypeError("Cannot " + msg);
957
957
  };
958
- var __privateGet$4 = (obj, member, getter) => {
958
+ var __privateGet$5 = (obj, member, getter) => {
959
959
  __accessCheck$5(obj, member, "read from private field");
960
960
  return getter ? getter.call(obj) : member.get(obj);
961
961
  };
@@ -964,7 +964,7 @@ var __privateAdd$5 = (obj, member, value) => {
964
964
  throw TypeError("Cannot add the same private member more than once");
965
965
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
966
966
  };
967
- var __privateSet$3 = (obj, member, value, setter) => {
967
+ var __privateSet$4 = (obj, member, value, setter) => {
968
968
  __accessCheck$5(obj, member, "write to private field");
969
969
  setter ? setter.call(obj, value) : member.set(obj, value);
970
970
  return value;
@@ -977,21 +977,21 @@ const _Query = class {
977
977
  __privateAdd$5(this, _data, { filter: {} });
978
978
  this.meta = { page: { cursor: "start", more: true } };
979
979
  this.records = [];
980
- __privateSet$3(this, _table$1, table);
980
+ __privateSet$4(this, _table$1, table);
981
981
  if (repository) {
982
- __privateSet$3(this, _repository, repository);
982
+ __privateSet$4(this, _repository, repository);
983
983
  } else {
984
- __privateSet$3(this, _repository, this);
984
+ __privateSet$4(this, _repository, this);
985
985
  }
986
- __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
987
- __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
988
- __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
989
- __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
990
- __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
991
- __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
992
- __privateGet$4(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
993
- __privateGet$4(this, _data).page = data.page ?? parent?.page;
994
- __privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
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;
995
995
  this.any = this.any.bind(this);
996
996
  this.all = this.all.bind(this);
997
997
  this.not = this.not.bind(this);
@@ -1002,63 +1002,64 @@ const _Query = class {
1002
1002
  Object.defineProperty(this, "repository", { enumerable: false });
1003
1003
  }
1004
1004
  getQueryOptions() {
1005
- return __privateGet$4(this, _data);
1005
+ return __privateGet$5(this, _data);
1006
1006
  }
1007
1007
  key() {
1008
- const { columns = [], filter = {}, sort = [], page = {} } = __privateGet$4(this, _data);
1009
- 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 });
1010
1010
  return toBase64(key);
1011
1011
  }
1012
1012
  any(...queries) {
1013
1013
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
1014
- 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));
1015
1015
  }
1016
1016
  all(...queries) {
1017
1017
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
1018
- 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));
1019
1019
  }
1020
1020
  not(...queries) {
1021
1021
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
1022
- 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));
1023
1023
  }
1024
1024
  none(...queries) {
1025
1025
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
1026
- 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));
1027
1027
  }
1028
1028
  filter(a, b) {
1029
1029
  if (arguments.length === 1) {
1030
1030
  const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
1031
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
1032
- 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));
1033
1033
  } else {
1034
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
1035
- 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));
1036
1036
  }
1037
1037
  }
1038
1038
  sort(column, direction) {
1039
- const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
1039
+ const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1040
1040
  const sort = [...originalSort, { column, direction }];
1041
- 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));
1042
1042
  }
1043
1043
  select(columns) {
1044
- 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));
1045
1045
  }
1046
1046
  getPaginated(options = {}) {
1047
- const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
1048
- 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);
1049
1049
  }
1050
1050
  async *[Symbol.asyncIterator]() {
1051
- for await (const [record] of this.getIterator(1)) {
1051
+ for await (const [record] of this.getIterator({ batchSize: 1 })) {
1052
1052
  yield record;
1053
1053
  }
1054
1054
  }
1055
- async *getIterator(chunk, options = {}) {
1055
+ async *getIterator(options = {}) {
1056
+ const { batchSize = 1 } = options;
1056
1057
  let offset = 0;
1057
1058
  let end = false;
1058
1059
  while (!end) {
1059
- const { records, meta } = await this.getPaginated({ ...options, page: { size: chunk, offset } });
1060
+ const { records, meta } = await this.getPaginated({ ...options, pagination: { size: batchSize, offset } });
1060
1061
  yield records;
1061
- offset += chunk;
1062
+ offset += batchSize;
1062
1063
  end = !meta.page.more;
1063
1064
  }
1064
1065
  }
@@ -1066,19 +1067,20 @@ const _Query = class {
1066
1067
  const { records } = await this.getPaginated(options);
1067
1068
  return records;
1068
1069
  }
1069
- async getAll(chunk = PAGINATION_MAX_SIZE, options = {}) {
1070
+ async getAll(options = {}) {
1071
+ const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
1070
1072
  const results = [];
1071
- for await (const page of this.getIterator(chunk, options)) {
1073
+ for await (const page of this.getIterator({ ...rest, batchSize })) {
1072
1074
  results.push(...page);
1073
1075
  }
1074
1076
  return results;
1075
1077
  }
1076
1078
  async getFirst(options = {}) {
1077
- const records = await this.getMany({ ...options, page: { size: 1 } });
1079
+ const records = await this.getMany({ ...options, pagination: { size: 1 } });
1078
1080
  return records[0] || null;
1079
1081
  }
1080
1082
  cache(ttl) {
1081
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
1083
+ return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
1082
1084
  }
1083
1085
  nextPage(size, offset) {
1084
1086
  return this.firstPage(size, offset);
@@ -1087,10 +1089,10 @@ const _Query = class {
1087
1089
  return this.firstPage(size, offset);
1088
1090
  }
1089
1091
  firstPage(size, offset) {
1090
- return this.getPaginated({ page: { size, offset } });
1092
+ return this.getPaginated({ pagination: { size, offset } });
1091
1093
  }
1092
1094
  lastPage(size, offset) {
1093
- return this.getPaginated({ page: { size, offset, before: "end" } });
1095
+ return this.getPaginated({ pagination: { size, offset, before: "end" } });
1094
1096
  }
1095
1097
  hasNextPage() {
1096
1098
  return this.meta.page.more;
@@ -1135,7 +1137,7 @@ var __accessCheck$4 = (obj, member, msg) => {
1135
1137
  if (!member.has(obj))
1136
1138
  throw TypeError("Cannot " + msg);
1137
1139
  };
1138
- var __privateGet$3 = (obj, member, getter) => {
1140
+ var __privateGet$4 = (obj, member, getter) => {
1139
1141
  __accessCheck$4(obj, member, "read from private field");
1140
1142
  return getter ? getter.call(obj) : member.get(obj);
1141
1143
  };
@@ -1144,7 +1146,7 @@ var __privateAdd$4 = (obj, member, value) => {
1144
1146
  throw TypeError("Cannot add the same private member more than once");
1145
1147
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1146
1148
  };
1147
- var __privateSet$2 = (obj, member, value, setter) => {
1149
+ var __privateSet$3 = (obj, member, value, setter) => {
1148
1150
  __accessCheck$4(obj, member, "write to private field");
1149
1151
  setter ? setter.call(obj, value) : member.set(obj, value);
1150
1152
  return value;
@@ -1153,7 +1155,7 @@ var __privateMethod$2 = (obj, member, method) => {
1153
1155
  __accessCheck$4(obj, member, "access private method");
1154
1156
  return method;
1155
1157
  };
1156
- var _table, _links, _getFetchProps, _cache, _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;
1158
+ 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;
1157
1159
  class Repository extends Query {
1158
1160
  }
1159
1161
  class RestRepository extends Query {
@@ -1170,15 +1172,15 @@ class RestRepository extends Query {
1170
1172
  __privateAdd$4(this, _getCacheRecord);
1171
1173
  __privateAdd$4(this, _setCacheQuery);
1172
1174
  __privateAdd$4(this, _getCacheQuery);
1175
+ __privateAdd$4(this, _getSchema$1);
1173
1176
  __privateAdd$4(this, _table, void 0);
1174
- __privateAdd$4(this, _links, void 0);
1175
1177
  __privateAdd$4(this, _getFetchProps, void 0);
1176
1178
  __privateAdd$4(this, _cache, void 0);
1177
- __privateSet$2(this, _table, options.table);
1178
- __privateSet$2(this, _links, options.links ?? {});
1179
- __privateSet$2(this, _getFetchProps, options.pluginOptions.getFetchProps);
1179
+ __privateAdd$4(this, _schema$1, void 0);
1180
+ __privateSet$3(this, _table, options.table);
1181
+ __privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
1180
1182
  this.db = options.db;
1181
- __privateSet$2(this, _cache, options.pluginOptions.cache);
1183
+ __privateSet$3(this, _cache, options.pluginOptions.cache);
1182
1184
  }
1183
1185
  async create(a, b) {
1184
1186
  if (Array.isArray(a)) {
@@ -1211,13 +1213,14 @@ class RestRepository extends Query {
1211
1213
  const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, recordId);
1212
1214
  if (cacheRecord)
1213
1215
  return cacheRecord;
1214
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1216
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1215
1217
  try {
1216
1218
  const response = await getRecord({
1217
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1219
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1218
1220
  ...fetchProps
1219
1221
  });
1220
- return initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), response);
1222
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1223
+ return initObject(this.db, schema, __privateGet$4(this, _table), response);
1221
1224
  } catch (e) {
1222
1225
  if (isObject(e) && e.status === 404) {
1223
1226
  return null;
@@ -1288,13 +1291,14 @@ class RestRepository extends Query {
1288
1291
  throw new Error("Invalid arguments for delete method");
1289
1292
  }
1290
1293
  async search(query, options = {}) {
1291
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1294
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1292
1295
  const { records } = await searchBranch({
1293
1296
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1294
- body: { tables: [__privateGet$3(this, _table)], query, fuzziness: options.fuzziness },
1297
+ body: { tables: [__privateGet$4(this, _table)], query, fuzziness: options.fuzziness },
1295
1298
  ...fetchProps
1296
1299
  });
1297
- return records.map((item) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), item));
1300
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1301
+ return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
1298
1302
  }
1299
1303
  async query(query) {
1300
1304
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
@@ -1304,33 +1308,34 @@ class RestRepository extends Query {
1304
1308
  const body = {
1305
1309
  filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1306
1310
  sort: data.sort ? buildSortFilter(data.sort) : void 0,
1307
- page: data.page,
1311
+ page: data.pagination,
1308
1312
  columns: data.columns
1309
1313
  };
1310
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1314
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1311
1315
  const { meta, records: objects } = await queryTable({
1312
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table) },
1316
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1313
1317
  body,
1314
1318
  ...fetchProps
1315
1319
  });
1316
- const records = objects.map((record) => initObject(this.db, __privateGet$3(this, _links), __privateGet$3(this, _table), record));
1320
+ const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
1321
+ const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
1317
1322
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1318
1323
  return new Page(query, meta, records);
1319
1324
  }
1320
1325
  }
1321
1326
  _table = new WeakMap();
1322
- _links = new WeakMap();
1323
1327
  _getFetchProps = new WeakMap();
1324
1328
  _cache = new WeakMap();
1329
+ _schema$1 = new WeakMap();
1325
1330
  _insertRecordWithoutId = new WeakSet();
1326
1331
  insertRecordWithoutId_fn = async function(object) {
1327
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1332
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1328
1333
  const record = transformObjectLinks(object);
1329
1334
  const response = await insertRecord({
1330
1335
  pathParams: {
1331
1336
  workspace: "{workspaceId}",
1332
1337
  dbBranchName: "{dbBranch}",
1333
- tableName: __privateGet$3(this, _table)
1338
+ tableName: __privateGet$4(this, _table)
1334
1339
  },
1335
1340
  body: record,
1336
1341
  ...fetchProps
@@ -1343,13 +1348,13 @@ insertRecordWithoutId_fn = async function(object) {
1343
1348
  };
1344
1349
  _insertRecordWithId = new WeakSet();
1345
1350
  insertRecordWithId_fn = async function(recordId, object) {
1346
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1351
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1347
1352
  const record = transformObjectLinks(object);
1348
1353
  const response = await insertRecordWithID({
1349
1354
  pathParams: {
1350
1355
  workspace: "{workspaceId}",
1351
1356
  dbBranchName: "{dbBranch}",
1352
- tableName: __privateGet$3(this, _table),
1357
+ tableName: __privateGet$4(this, _table),
1353
1358
  recordId
1354
1359
  },
1355
1360
  body: record,
@@ -1364,10 +1369,10 @@ insertRecordWithId_fn = async function(recordId, object) {
1364
1369
  };
1365
1370
  _bulkInsertTableRecords = new WeakSet();
1366
1371
  bulkInsertTableRecords_fn = async function(objects) {
1367
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1372
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1368
1373
  const records = objects.map((object) => transformObjectLinks(object));
1369
1374
  const response = await bulkInsertTableRecords({
1370
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table) },
1375
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
1371
1376
  body: { records },
1372
1377
  ...fetchProps
1373
1378
  });
@@ -1379,10 +1384,10 @@ bulkInsertTableRecords_fn = async function(objects) {
1379
1384
  };
1380
1385
  _updateRecordWithID = new WeakSet();
1381
1386
  updateRecordWithID_fn = async function(recordId, object) {
1382
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1387
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1383
1388
  const record = transformObjectLinks(object);
1384
1389
  const response = await updateRecordWithID({
1385
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1390
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1386
1391
  body: record,
1387
1392
  ...fetchProps
1388
1393
  });
@@ -1393,9 +1398,9 @@ updateRecordWithID_fn = async function(recordId, object) {
1393
1398
  };
1394
1399
  _upsertRecordWithID = new WeakSet();
1395
1400
  upsertRecordWithID_fn = async function(recordId, object) {
1396
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1401
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1397
1402
  const response = await upsertRecordWithID({
1398
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1403
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1399
1404
  body: object,
1400
1405
  ...fetchProps
1401
1406
  });
@@ -1406,51 +1411,63 @@ upsertRecordWithID_fn = async function(recordId, object) {
1406
1411
  };
1407
1412
  _deleteRecord = new WeakSet();
1408
1413
  deleteRecord_fn = async function(recordId) {
1409
- const fetchProps = await __privateGet$3(this, _getFetchProps).call(this);
1414
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1410
1415
  await deleteRecord({
1411
- pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$3(this, _table), recordId },
1416
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
1412
1417
  ...fetchProps
1413
1418
  });
1414
1419
  };
1415
1420
  _invalidateCache = new WeakSet();
1416
1421
  invalidateCache_fn = async function(recordId) {
1417
- await __privateGet$3(this, _cache).delete(`rec_${__privateGet$3(this, _table)}:${recordId}`);
1418
- const cacheItems = await __privateGet$3(this, _cache).getAll();
1422
+ await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1423
+ const cacheItems = await __privateGet$4(this, _cache).getAll();
1419
1424
  const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
1420
1425
  for (const [key, value] of queries) {
1421
1426
  const ids = getIds(value);
1422
1427
  if (ids.includes(recordId))
1423
- await __privateGet$3(this, _cache).delete(key);
1428
+ await __privateGet$4(this, _cache).delete(key);
1424
1429
  }
1425
1430
  };
1426
1431
  _setCacheRecord = new WeakSet();
1427
1432
  setCacheRecord_fn = async function(record) {
1428
- if (!__privateGet$3(this, _cache).cacheRecords)
1433
+ if (!__privateGet$4(this, _cache).cacheRecords)
1429
1434
  return;
1430
- await __privateGet$3(this, _cache).set(`rec_${__privateGet$3(this, _table)}:${record.id}`, record);
1435
+ await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
1431
1436
  };
1432
1437
  _getCacheRecord = new WeakSet();
1433
1438
  getCacheRecord_fn = async function(recordId) {
1434
- if (!__privateGet$3(this, _cache).cacheRecords)
1439
+ if (!__privateGet$4(this, _cache).cacheRecords)
1435
1440
  return null;
1436
- return __privateGet$3(this, _cache).get(`rec_${__privateGet$3(this, _table)}:${recordId}`);
1441
+ return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
1437
1442
  };
1438
1443
  _setCacheQuery = new WeakSet();
1439
1444
  setCacheQuery_fn = async function(query, meta, records) {
1440
- await __privateGet$3(this, _cache).set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1445
+ await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
1441
1446
  };
1442
1447
  _getCacheQuery = new WeakSet();
1443
1448
  getCacheQuery_fn = async function(query) {
1444
- const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
1445
- const result = await __privateGet$3(this, _cache).get(key);
1449
+ const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
1450
+ const result = await __privateGet$4(this, _cache).get(key);
1446
1451
  if (!result)
1447
1452
  return null;
1448
- const { cache: ttl = __privateGet$3(this, _cache).defaultQueryTTL } = query.getQueryOptions();
1449
- if (!ttl || ttl < 0)
1450
- return result;
1453
+ const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
1454
+ if (ttl < 0)
1455
+ return null;
1451
1456
  const hasExpired = result.date.getTime() + ttl < Date.now();
1452
1457
  return hasExpired ? null : result;
1453
1458
  };
1459
+ _getSchema$1 = new WeakSet();
1460
+ getSchema_fn$1 = async function() {
1461
+ if (__privateGet$4(this, _schema$1))
1462
+ return __privateGet$4(this, _schema$1);
1463
+ const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
1464
+ const { schema } = await getBranchDetails({
1465
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1466
+ ...fetchProps
1467
+ });
1468
+ __privateSet$3(this, _schema$1, schema);
1469
+ return schema;
1470
+ };
1454
1471
  const transformObjectLinks = (object) => {
1455
1472
  return Object.entries(object).reduce((acc, [key, value]) => {
1456
1473
  if (key === "xata")
@@ -1458,15 +1475,33 @@ const transformObjectLinks = (object) => {
1458
1475
  return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
1459
1476
  }, {});
1460
1477
  };
1461
- const initObject = (db, links, table, object) => {
1478
+ const initObject = (db, schema, table, object) => {
1462
1479
  const result = {};
1463
1480
  Object.assign(result, object);
1464
- const tableLinks = links[table] || [];
1465
- for (const link of tableLinks) {
1466
- const [field, linkTable] = link;
1467
- const value = result[field];
1468
- if (value && isObject(value)) {
1469
- result[field] = initObject(db, links, linkTable, value);
1481
+ const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
1482
+ if (!columns)
1483
+ console.error(`Table ${table} not found in schema`);
1484
+ for (const column of columns ?? []) {
1485
+ const value = result[column.name];
1486
+ switch (column.type) {
1487
+ case "datetime": {
1488
+ const date = new Date(value);
1489
+ if (isNaN(date.getTime())) {
1490
+ console.error(`Failed to parse date ${value} for field ${column.name}`);
1491
+ } else {
1492
+ result[column.name] = date;
1493
+ }
1494
+ break;
1495
+ }
1496
+ case "link": {
1497
+ const linkTable = column.link?.table;
1498
+ if (!linkTable) {
1499
+ console.error(`Failed to parse link for field ${column.name}`);
1500
+ } else if (value && isObject(value)) {
1501
+ result[column.name] = initObject(db, schema, linkTable, value);
1502
+ }
1503
+ break;
1504
+ }
1470
1505
  }
1471
1506
  }
1472
1507
  result.read = function() {
@@ -1498,7 +1533,7 @@ var __accessCheck$3 = (obj, member, msg) => {
1498
1533
  if (!member.has(obj))
1499
1534
  throw TypeError("Cannot " + msg);
1500
1535
  };
1501
- var __privateGet$2 = (obj, member, getter) => {
1536
+ var __privateGet$3 = (obj, member, getter) => {
1502
1537
  __accessCheck$3(obj, member, "read from private field");
1503
1538
  return getter ? getter.call(obj) : member.get(obj);
1504
1539
  };
@@ -1507,7 +1542,7 @@ var __privateAdd$3 = (obj, member, value) => {
1507
1542
  throw TypeError("Cannot add the same private member more than once");
1508
1543
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1509
1544
  };
1510
- var __privateSet$1 = (obj, member, value, setter) => {
1545
+ var __privateSet$2 = (obj, member, value, setter) => {
1511
1546
  __accessCheck$3(obj, member, "write to private field");
1512
1547
  setter ? setter.call(obj, value) : member.set(obj, value);
1513
1548
  return value;
@@ -1516,30 +1551,30 @@ var _map;
1516
1551
  class SimpleCache {
1517
1552
  constructor(options = {}) {
1518
1553
  __privateAdd$3(this, _map, void 0);
1519
- __privateSet$1(this, _map, /* @__PURE__ */ new Map());
1554
+ __privateSet$2(this, _map, /* @__PURE__ */ new Map());
1520
1555
  this.capacity = options.max ?? 500;
1521
1556
  this.cacheRecords = options.cacheRecords ?? true;
1522
1557
  this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
1523
1558
  }
1524
1559
  async getAll() {
1525
- return Object.fromEntries(__privateGet$2(this, _map));
1560
+ return Object.fromEntries(__privateGet$3(this, _map));
1526
1561
  }
1527
1562
  async get(key) {
1528
- return __privateGet$2(this, _map).get(key) ?? null;
1563
+ return __privateGet$3(this, _map).get(key) ?? null;
1529
1564
  }
1530
1565
  async set(key, value) {
1531
1566
  await this.delete(key);
1532
- __privateGet$2(this, _map).set(key, value);
1533
- if (__privateGet$2(this, _map).size > this.capacity) {
1534
- const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
1567
+ __privateGet$3(this, _map).set(key, value);
1568
+ if (__privateGet$3(this, _map).size > this.capacity) {
1569
+ const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
1535
1570
  await this.delete(leastRecentlyUsed);
1536
1571
  }
1537
1572
  }
1538
1573
  async delete(key) {
1539
- __privateGet$2(this, _map).delete(key);
1574
+ __privateGet$3(this, _map).delete(key);
1540
1575
  }
1541
1576
  async clear() {
1542
- return __privateGet$2(this, _map).clear();
1577
+ return __privateGet$3(this, _map).clear();
1543
1578
  }
1544
1579
  }
1545
1580
  _map = new WeakMap();
@@ -1567,7 +1602,7 @@ var __accessCheck$2 = (obj, member, msg) => {
1567
1602
  if (!member.has(obj))
1568
1603
  throw TypeError("Cannot " + msg);
1569
1604
  };
1570
- var __privateGet$1 = (obj, member, getter) => {
1605
+ var __privateGet$2 = (obj, member, getter) => {
1571
1606
  __accessCheck$2(obj, member, "read from private field");
1572
1607
  return getter ? getter.call(obj) : member.get(obj);
1573
1608
  };
@@ -1578,26 +1613,24 @@ var __privateAdd$2 = (obj, member, value) => {
1578
1613
  };
1579
1614
  var _tables;
1580
1615
  class SchemaPlugin extends XataPlugin {
1581
- constructor(links, tableNames) {
1616
+ constructor(tableNames) {
1582
1617
  super();
1583
- this.links = links;
1584
1618
  this.tableNames = tableNames;
1585
1619
  __privateAdd$2(this, _tables, {});
1586
1620
  }
1587
1621
  build(pluginOptions) {
1588
- const links = this.links;
1589
1622
  const db = new Proxy({}, {
1590
1623
  get: (_target, table) => {
1591
1624
  if (!isString(table))
1592
1625
  throw new Error("Invalid table name");
1593
- if (!__privateGet$1(this, _tables)[table]) {
1594
- __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, links });
1626
+ if (!__privateGet$2(this, _tables)[table]) {
1627
+ __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
1595
1628
  }
1596
- return __privateGet$1(this, _tables)[table];
1629
+ return __privateGet$2(this, _tables)[table];
1597
1630
  }
1598
1631
  });
1599
1632
  for (const table of this.tableNames ?? []) {
1600
- db[table] = new RestRepository({ db, pluginOptions, table, links });
1633
+ db[table] = new RestRepository({ db, pluginOptions, table });
1601
1634
  }
1602
1635
  return db;
1603
1636
  }
@@ -1608,44 +1641,57 @@ var __accessCheck$1 = (obj, member, msg) => {
1608
1641
  if (!member.has(obj))
1609
1642
  throw TypeError("Cannot " + msg);
1610
1643
  };
1644
+ var __privateGet$1 = (obj, member, getter) => {
1645
+ __accessCheck$1(obj, member, "read from private field");
1646
+ return getter ? getter.call(obj) : member.get(obj);
1647
+ };
1611
1648
  var __privateAdd$1 = (obj, member, value) => {
1612
1649
  if (member.has(obj))
1613
1650
  throw TypeError("Cannot add the same private member more than once");
1614
1651
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1615
1652
  };
1653
+ var __privateSet$1 = (obj, member, value, setter) => {
1654
+ __accessCheck$1(obj, member, "write to private field");
1655
+ setter ? setter.call(obj, value) : member.set(obj, value);
1656
+ return value;
1657
+ };
1616
1658
  var __privateMethod$1 = (obj, member, method) => {
1617
1659
  __accessCheck$1(obj, member, "access private method");
1618
1660
  return method;
1619
1661
  };
1620
- var _search, search_fn;
1662
+ var _schema, _search, search_fn, _getSchema, getSchema_fn;
1621
1663
  class SearchPlugin extends XataPlugin {
1622
- constructor(db, links) {
1664
+ constructor(db) {
1623
1665
  super();
1624
1666
  this.db = db;
1625
- this.links = links;
1626
1667
  __privateAdd$1(this, _search);
1668
+ __privateAdd$1(this, _getSchema);
1669
+ __privateAdd$1(this, _schema, void 0);
1627
1670
  }
1628
1671
  build({ getFetchProps }) {
1629
1672
  return {
1630
1673
  all: async (query, options = {}) => {
1631
1674
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1675
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1632
1676
  return records.map((record) => {
1633
1677
  const { table = "orphan" } = record.xata;
1634
- return { table, record: initObject(this.db, this.links, table, record) };
1678
+ return { table, record: initObject(this.db, schema, table, record) };
1635
1679
  });
1636
1680
  },
1637
1681
  byTable: async (query, options = {}) => {
1638
1682
  const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
1683
+ const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
1639
1684
  return records.reduce((acc, record) => {
1640
1685
  const { table = "orphan" } = record.xata;
1641
1686
  const items = acc[table] ?? [];
1642
- const item = initObject(this.db, this.links, table, record);
1687
+ const item = initObject(this.db, schema, table, record);
1643
1688
  return { ...acc, [table]: [...items, item] };
1644
1689
  }, {});
1645
1690
  }
1646
1691
  };
1647
1692
  }
1648
1693
  }
1694
+ _schema = new WeakMap();
1649
1695
  _search = new WeakSet();
1650
1696
  search_fn = async function(query, options, getFetchProps) {
1651
1697
  const fetchProps = await getFetchProps();
@@ -1657,6 +1703,18 @@ search_fn = async function(query, options, getFetchProps) {
1657
1703
  });
1658
1704
  return records;
1659
1705
  };
1706
+ _getSchema = new WeakSet();
1707
+ getSchema_fn = async function(getFetchProps) {
1708
+ if (__privateGet$1(this, _schema))
1709
+ return __privateGet$1(this, _schema);
1710
+ const fetchProps = await getFetchProps();
1711
+ const { schema } = await getBranchDetails({
1712
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
1713
+ ...fetchProps
1714
+ });
1715
+ __privateSet$1(this, _schema, schema);
1716
+ return schema;
1717
+ };
1660
1718
 
1661
1719
  const isBranchStrategyBuilder = (strategy) => {
1662
1720
  return typeof strategy === "function";
@@ -1765,7 +1823,7 @@ var __privateMethod = (obj, member, method) => {
1765
1823
  const buildClient = (plugins) => {
1766
1824
  var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1767
1825
  return _a = class {
1768
- constructor(options = {}, links, tables) {
1826
+ constructor(options = {}, tables) {
1769
1827
  __privateAdd(this, _parseOptions);
1770
1828
  __privateAdd(this, _getFetchProps);
1771
1829
  __privateAdd(this, _evaluateBranch);
@@ -1775,8 +1833,8 @@ const buildClient = (plugins) => {
1775
1833
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
1776
1834
  cache: safeOptions.cache
1777
1835
  };
1778
- const db = new SchemaPlugin(links, tables).build(pluginOptions);
1779
- const search = new SearchPlugin(db, links ?? {}).build(pluginOptions);
1836
+ const db = new SchemaPlugin(tables).build(pluginOptions);
1837
+ const search = new SearchPlugin(db).build(pluginOptions);
1780
1838
  this.db = db;
1781
1839
  this.search = search;
1782
1840
  for (const [key, namespace] of Object.entries(plugins ?? {})) {