@xata.io/client 0.0.0-alpha.vf95371f → 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/.eslintrc.cjs +1 -2
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/tsconfig.json +1 -0
package/.eslintrc.cjs
CHANGED
@@ -6,8 +6,7 @@ module.exports = {
|
|
6
6
|
project: 'packages/client/tsconfig.json'
|
7
7
|
},
|
8
8
|
rules: {
|
9
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
10
|
-
'@typescript-eslint/ban-types': 'off',
|
11
9
|
'@typescript-eslint/no-floating-promises': 'error',
|
10
|
+
"@typescript-eslint/strict-boolean-expressions": ["error", { allowNullableString: true, allowNullableObject: true }],
|
12
11
|
}
|
13
12
|
};
|
package/dist/index.cjs
CHANGED
@@ -1081,7 +1081,7 @@ const _Query = class {
|
|
1081
1081
|
}
|
1082
1082
|
async getFirst(options = {}) {
|
1083
1083
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1084
|
-
return records[0]
|
1084
|
+
return records[0] ?? null;
|
1085
1085
|
}
|
1086
1086
|
cache(ttl) {
|
1087
1087
|
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
@@ -1311,7 +1311,7 @@ class RestRepository extends Query {
|
|
1311
1311
|
const data = query.getQueryOptions();
|
1312
1312
|
const body = {
|
1313
1313
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1314
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1314
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1315
1315
|
page: data.pagination,
|
1316
1316
|
columns: data.columns
|
1317
1317
|
};
|
@@ -1501,7 +1501,7 @@ const initObject = (db, schema, table, object) => {
|
|
1501
1501
|
const linkTable = column.link?.table;
|
1502
1502
|
if (!linkTable) {
|
1503
1503
|
console.error(`Failed to parse link for field ${column.name}`);
|
1504
|
-
} else if (
|
1504
|
+
} else if (isObject(value)) {
|
1505
1505
|
result[column.name] = initObject(db, schema, linkTable, value);
|
1506
1506
|
}
|
1507
1507
|
break;
|
@@ -1627,7 +1627,7 @@ class SchemaPlugin extends XataPlugin {
|
|
1627
1627
|
get: (_target, table) => {
|
1628
1628
|
if (!isString(table))
|
1629
1629
|
throw new Error("Invalid table name");
|
1630
|
-
if (
|
1630
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1631
1631
|
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1632
1632
|
}
|
1633
1633
|
return __privateGet$2(this, _tables)[table];
|
@@ -1842,7 +1842,7 @@ const buildClient = (plugins) => {
|
|
1842
1842
|
this.db = db;
|
1843
1843
|
this.search = search;
|
1844
1844
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1845
|
-
if (
|
1845
|
+
if (namespace === void 0)
|
1846
1846
|
continue;
|
1847
1847
|
const result = namespace.build(pluginOptions);
|
1848
1848
|
if (result instanceof Promise) {
|
@@ -1859,7 +1859,7 @@ const buildClient = (plugins) => {
|
|
1859
1859
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1860
1860
|
const apiKey = options?.apiKey || getAPIKey();
|
1861
1861
|
const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
|
1862
|
-
const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1862
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1863
1863
|
if (!databaseURL || !apiKey) {
|
1864
1864
|
throw new Error("Options databaseURL and apiKey are required");
|
1865
1865
|
}
|
@@ -1886,7 +1886,7 @@ const buildClient = (plugins) => {
|
|
1886
1886
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1887
1887
|
if (__privateGet(this, _branch))
|
1888
1888
|
return __privateGet(this, _branch);
|
1889
|
-
if (
|
1889
|
+
if (param === void 0)
|
1890
1890
|
return void 0;
|
1891
1891
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1892
1892
|
const evaluateBranch = async (strategy) => {
|