@xata.io/client 0.18.0 → 0.18.1

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
@@ -150,7 +150,7 @@ function getFetchImplementation(userFetch) {
150
150
  return fetchImpl;
151
151
  }
152
152
 
153
- const VERSION = "0.18.0";
153
+ const VERSION = "0.18.1";
154
154
 
155
155
  class ErrorWithCause extends Error {
156
156
  constructor(message, options) {
@@ -1357,9 +1357,14 @@ var __privateSet$5 = (obj, member, value, setter) => {
1357
1357
  setter ? setter.call(obj, value) : member.set(obj, value);
1358
1358
  return value;
1359
1359
  };
1360
- var _table$1, _repository, _data;
1360
+ var __privateMethod$3 = (obj, member, method) => {
1361
+ __accessCheck$5(obj, member, "access private method");
1362
+ return method;
1363
+ };
1364
+ var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
1361
1365
  const _Query = class {
1362
1366
  constructor(repository, table, data, rawParent) {
1367
+ __privateAdd$5(this, _cleanFilterConstraint);
1363
1368
  __privateAdd$5(this, _table$1, void 0);
1364
1369
  __privateAdd$5(this, _repository, void 0);
1365
1370
  __privateAdd$5(this, _data, { filter: {} });
@@ -1416,22 +1421,17 @@ const _Query = class {
1416
1421
  }
1417
1422
  filter(a, b) {
1418
1423
  if (arguments.length === 1) {
1419
- const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({ [column]: constraint }));
1424
+ const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
1425
+ [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
1426
+ }));
1420
1427
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1421
1428
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1422
1429
  } else {
1423
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: this.defaultFilter(a, b) }] : void 0;
1430
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
1424
1431
  const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
1425
1432
  return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
1426
1433
  }
1427
1434
  }
1428
- defaultFilter(column, value) {
1429
- const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1430
- if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1431
- return { $includes: value };
1432
- }
1433
- return value;
1434
- }
1435
1435
  sort(column, direction = "asc") {
1436
1436
  const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
1437
1437
  const sort = [...originalSort, { column, direction }];
@@ -1522,6 +1522,17 @@ let Query = _Query;
1522
1522
  _table$1 = new WeakMap();
1523
1523
  _repository = new WeakMap();
1524
1524
  _data = new WeakMap();
1525
+ _cleanFilterConstraint = new WeakSet();
1526
+ cleanFilterConstraint_fn = function(column, value) {
1527
+ const columnType = __privateGet$5(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
1528
+ if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
1529
+ return { $includes: value };
1530
+ }
1531
+ if (columnType === "link" && isObject(value) && isString(value.id)) {
1532
+ return value.id;
1533
+ }
1534
+ return value;
1535
+ };
1525
1536
  function cleanParent(data, parent) {
1526
1537
  if (isCursorPaginationOptions(data.pagination)) {
1527
1538
  return { ...parent, sorting: void 0, filter: void 0 };