@xata.io/client 0.0.0-alpha.vea397e5 → 0.0.0-alpha.vec0bff6

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
@@ -150,7 +150,7 @@ function getFetchImplementation(userFetch) {
150
150
  return fetchImpl;
151
151
  }
152
152
 
153
- const VERSION = "0.0.0-alpha.vea397e5";
153
+ const VERSION = "0.0.0-alpha.vec0bff6";
154
154
 
155
155
  class ErrorWithCause extends Error {
156
156
  constructor(message, options) {
@@ -1336,7 +1336,7 @@ var __privateMethod$2 = (obj, member, method) => {
1336
1336
  __accessCheck$4(obj, member, "access private method");
1337
1337
  return method;
1338
1338
  };
1339
- var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1339
+ var _table, _getFetchProps, _db, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
1340
1340
  class Repository extends Query {
1341
1341
  }
1342
1342
  class RestRepository extends Query {
@@ -1353,11 +1353,12 @@ class RestRepository extends Query {
1353
1353
  __privateAdd$4(this, _getSchemaTables$1);
1354
1354
  __privateAdd$4(this, _table, void 0);
1355
1355
  __privateAdd$4(this, _getFetchProps, void 0);
1356
+ __privateAdd$4(this, _db, void 0);
1356
1357
  __privateAdd$4(this, _cache, void 0);
1357
1358
  __privateAdd$4(this, _schemaTables$2, void 0);
1358
1359
  __privateSet$4(this, _table, options.table);
1359
1360
  __privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
1360
- this.db = options.db;
1361
+ __privateSet$4(this, _db, options.db);
1361
1362
  __privateSet$4(this, _cache, options.pluginOptions.cache);
1362
1363
  __privateSet$4(this, _schemaTables$2, options.schemaTables);
1363
1364
  }
@@ -1409,7 +1410,7 @@ class RestRepository extends Query {
1409
1410
  ...fetchProps
1410
1411
  });
1411
1412
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1412
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1413
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1413
1414
  } catch (e) {
1414
1415
  if (isObject(e) && e.status === 404) {
1415
1416
  return null;
@@ -1494,7 +1495,7 @@ class RestRepository extends Query {
1494
1495
  ...fetchProps
1495
1496
  });
1496
1497
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1497
- return records.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1498
+ return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1498
1499
  }
1499
1500
  async query(query) {
1500
1501
  const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
@@ -1514,13 +1515,14 @@ class RestRepository extends Query {
1514
1515
  ...fetchProps
1515
1516
  });
1516
1517
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1517
- const records = objects.map((record) => initObject(this.db, schemaTables, __privateGet$4(this, _table), record));
1518
+ const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
1518
1519
  await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
1519
1520
  return new Page(query, meta, records);
1520
1521
  }
1521
1522
  }
1522
1523
  _table = new WeakMap();
1523
1524
  _getFetchProps = new WeakMap();
1525
+ _db = new WeakMap();
1524
1526
  _cache = new WeakMap();
1525
1527
  _schemaTables$2 = new WeakMap();
1526
1528
  _insertRecordWithoutId = new WeakSet();
@@ -1538,7 +1540,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
1538
1540
  ...fetchProps
1539
1541
  });
1540
1542
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1541
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1543
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1542
1544
  };
1543
1545
  _insertRecordWithId = new WeakSet();
1544
1546
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
@@ -1556,7 +1558,7 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
1556
1558
  ...fetchProps
1557
1559
  });
1558
1560
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1559
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1561
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1560
1562
  };
1561
1563
  _bulkInsertTableRecords = new WeakSet();
1562
1564
  bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
@@ -1572,7 +1574,7 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
1572
1574
  throw new Error("Request included columns but server didn't include them");
1573
1575
  }
1574
1576
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1575
- return response.records?.map((item) => initObject(this.db, schemaTables, __privateGet$4(this, _table), item));
1577
+ return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
1576
1578
  };
1577
1579
  _updateRecordWithID = new WeakSet();
1578
1580
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1585,7 +1587,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1585
1587
  ...fetchProps
1586
1588
  });
1587
1589
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1588
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1590
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1589
1591
  };
1590
1592
  _upsertRecordWithID = new WeakSet();
1591
1593
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
@@ -1597,7 +1599,7 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
1597
1599
  ...fetchProps
1598
1600
  });
1599
1601
  const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
1600
- return initObject(this.db, schemaTables, __privateGet$4(this, _table), response);
1602
+ return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
1601
1603
  };
1602
1604
  _deleteRecord = new WeakSet();
1603
1605
  deleteRecord_fn = async function(recordId) {
@@ -1995,14 +1997,16 @@ var __privateMethod = (obj, member, method) => {
1995
1997
  return method;
1996
1998
  };
1997
1999
  const buildClient = (plugins) => {
1998
- var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
2000
+ var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
1999
2001
  return _a = class {
2000
2002
  constructor(options = {}, schemaTables) {
2001
2003
  __privateAdd(this, _parseOptions);
2002
2004
  __privateAdd(this, _getFetchProps);
2003
2005
  __privateAdd(this, _evaluateBranch);
2004
2006
  __privateAdd(this, _branch, void 0);
2007
+ __privateAdd(this, _options, void 0);
2005
2008
  const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
2009
+ __privateSet(this, _options, safeOptions);
2006
2010
  const pluginOptions = {
2007
2011
  getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
2008
2012
  cache: safeOptions.cache
@@ -2024,7 +2028,12 @@ const buildClient = (plugins) => {
2024
2028
  }
2025
2029
  }
2026
2030
  }
2027
- }, _branch = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2031
+ async getConfig() {
2032
+ const databaseURL = __privateGet(this, _options).databaseURL;
2033
+ const branch = await __privateGet(this, _options).branch();
2034
+ return { databaseURL, branch };
2035
+ }
2036
+ }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
2028
2037
  const fetch = getFetchImplementation(options?.fetch);
2029
2038
  const databaseURL = options?.databaseURL || getDatabaseURL();
2030
2039
  const apiKey = options?.apiKey || getAPIKey();
@@ -2034,12 +2043,7 @@ const buildClient = (plugins) => {
2034
2043
  throw new Error("Options databaseURL and apiKey are required");
2035
2044
  }
2036
2045
  return { fetch, databaseURL, apiKey, branch, cache };
2037
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
2038
- fetch,
2039
- apiKey,
2040
- databaseURL,
2041
- branch
2042
- }) {
2046
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
2043
2047
  const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
2044
2048
  if (!branchValue)
2045
2049
  throw new Error("Unable to resolve branch value");