@xata.io/client 0.0.0-alpha.vf9819fa → 0.0.0-alpha.vf9d4e41

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.d.ts CHANGED
@@ -1151,9 +1151,10 @@ declare type ResolveBranchVariables = {
1151
1151
  } & FetcherExtraProps;
1152
1152
  /**
1153
1153
  * In order to resolve the database branch, the following algorithm is used:
1154
- * * if the `gitBranch` is found in the [git branches mapping](), the associated Xata branch is returned
1154
+ * * if the `gitBranch` was provided and is found in the [git branches mapping](/api-reference/dbs/db_name/gitBranches), the associated Xata branch is returned
1155
1155
  * * else, if a Xata branch with the exact same name as `gitBranch` exists, return it
1156
- * * else, return the default branch of the DB (currently `main` or the first branch)
1156
+ * * else, if `fallbackBranch` is provided and a branch with that name exists, return it
1157
+ * * else, return the default branch of the DB (`main` or the first branch)
1157
1158
  *
1158
1159
  * Example call:
1159
1160
  *
package/dist/index.mjs CHANGED
@@ -1077,7 +1077,7 @@ const _Query = class {
1077
1077
  }
1078
1078
  async getFirst(options = {}) {
1079
1079
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
1080
- return records[0] || null;
1080
+ return records[0] ?? null;
1081
1081
  }
1082
1082
  cache(ttl) {
1083
1083
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
@@ -1307,7 +1307,7 @@ class RestRepository extends Query {
1307
1307
  const data = query.getQueryOptions();
1308
1308
  const body = {
1309
1309
  filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
1310
- sort: data.sort ? buildSortFilter(data.sort) : void 0,
1310
+ sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
1311
1311
  page: data.pagination,
1312
1312
  columns: data.columns
1313
1313
  };
@@ -1497,7 +1497,7 @@ const initObject = (db, schema, table, object) => {
1497
1497
  const linkTable = column.link?.table;
1498
1498
  if (!linkTable) {
1499
1499
  console.error(`Failed to parse link for field ${column.name}`);
1500
- } else if (value && isObject(value)) {
1500
+ } else if (isObject(value)) {
1501
1501
  result[column.name] = initObject(db, schema, linkTable, value);
1502
1502
  }
1503
1503
  break;
@@ -1623,7 +1623,7 @@ class SchemaPlugin extends XataPlugin {
1623
1623
  get: (_target, table) => {
1624
1624
  if (!isString(table))
1625
1625
  throw new Error("Invalid table name");
1626
- if (!__privateGet$2(this, _tables)[table]) {
1626
+ if (__privateGet$2(this, _tables)[table] === void 0) {
1627
1627
  __privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
1628
1628
  }
1629
1629
  return __privateGet$2(this, _tables)[table];
@@ -1728,7 +1728,7 @@ const envBranchNames = [
1728
1728
  ];
1729
1729
  const defaultBranch = "main";
1730
1730
  async function getCurrentBranchName(options) {
1731
- const env = await getBranchByEnvVariable();
1731
+ const env = getBranchByEnvVariable();
1732
1732
  if (env)
1733
1733
  return env;
1734
1734
  const branch = await getGitBranch();
@@ -1740,7 +1740,7 @@ async function getCurrentBranchName(options) {
1740
1740
  return defaultBranch;
1741
1741
  }
1742
1742
  async function getCurrentBranchDetails(options) {
1743
- const env = await getBranchByEnvVariable();
1743
+ const env = getBranchByEnvVariable();
1744
1744
  if (env)
1745
1745
  return getDatabaseBranch(env, options);
1746
1746
  const branch = await getGitBranch();
@@ -1838,7 +1838,7 @@ const buildClient = (plugins) => {
1838
1838
  this.db = db;
1839
1839
  this.search = search;
1840
1840
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
1841
- if (!namespace)
1841
+ if (namespace === void 0)
1842
1842
  continue;
1843
1843
  const result = namespace.build(pluginOptions);
1844
1844
  if (result instanceof Promise) {
@@ -1855,7 +1855,7 @@ const buildClient = (plugins) => {
1855
1855
  const databaseURL = options?.databaseURL || getDatabaseURL();
1856
1856
  const apiKey = options?.apiKey || getAPIKey();
1857
1857
  const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
1858
- const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1858
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
1859
1859
  if (!databaseURL || !apiKey) {
1860
1860
  throw new Error("Options databaseURL and apiKey are required");
1861
1861
  }
@@ -1882,7 +1882,7 @@ const buildClient = (plugins) => {
1882
1882
  }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
1883
1883
  if (__privateGet(this, _branch))
1884
1884
  return __privateGet(this, _branch);
1885
- if (!param)
1885
+ if (param === void 0)
1886
1886
  return void 0;
1887
1887
  const strategies = Array.isArray(param) ? [...param] : [param];
1888
1888
  const evaluateBranch = async (strategy) => {