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