@xata.io/client 0.21.5 → 0.21.6

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- ignorePatterns: ["dist"],
2
+ ignorePatterns: ['dist'],
3
3
  parserOptions: {
4
4
  ecmaVersion: 2020,
5
5
  sourceType: 'module',
@@ -7,6 +7,6 @@ module.exports = {
7
7
  },
8
8
  rules: {
9
9
  '@typescript-eslint/no-floating-promises': 'error',
10
- "@typescript-eslint/strict-boolean-expressions": ["error", { allowNullableString: true, allowNullableObject: true }],
10
+ '@typescript-eslint/strict-boolean-expressions': ['error', { allowNullableString: true, allowNullableObject: true }]
11
11
  }
12
12
  };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.21.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#828](https://github.com/xataio/client-ts/pull/828) [`039e35bf`](https://github.com/xataio/client-ts/commit/039e35bf9f01149f39bca39e1867908ca3468bb5) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix enableBrowser with Deno
8
+
9
+ - [#828](https://github.com/xataio/client-ts/pull/828) [`039e35bf`](https://github.com/xataio/client-ts/commit/039e35bf9f01149f39bca39e1867908ca3468bb5) Thanks [@SferaDev](https://github.com/SferaDev)! - Add branded types to serializer
10
+
3
11
  ## 0.21.5
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -175,8 +175,6 @@ async function getGitBranch() {
175
175
  if (typeof require === "function") {
176
176
  return require(nodeModule).execSync(fullCmd, execOptions).trim();
177
177
  }
178
- const { execSync } = await import(nodeModule);
179
- return execSync(fullCmd, execOptions).toString().trim();
180
178
  } catch (err) {
181
179
  }
182
180
  try {
@@ -304,7 +302,7 @@ function generateUUID() {
304
302
  });
305
303
  }
306
304
 
307
- const VERSION = "0.21.5";
305
+ const VERSION = "0.21.6";
308
306
 
309
307
  class ErrorWithCause extends Error {
310
308
  constructor(message, options) {
@@ -2869,23 +2867,23 @@ const transformObjectLinks = (object) => {
2869
2867
  }, {});
2870
2868
  };
2871
2869
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2872
- const result = {};
2870
+ const data = {};
2873
2871
  const { xata, ...rest } = object ?? {};
2874
- Object.assign(result, rest);
2872
+ Object.assign(data, rest);
2875
2873
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2876
2874
  if (!columns)
2877
2875
  console.error(`Table ${table} not found in schema`);
2878
2876
  for (const column of columns ?? []) {
2879
2877
  if (!isValidColumn(selectedColumns, column))
2880
2878
  continue;
2881
- const value = result[column.name];
2879
+ const value = data[column.name];
2882
2880
  switch (column.type) {
2883
2881
  case "datetime": {
2884
2882
  const date = value !== void 0 ? new Date(value) : null;
2885
2883
  if (date !== null && isNaN(date.getTime())) {
2886
2884
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2887
2885
  } else {
2888
- result[column.name] = date;
2886
+ data[column.name] = date;
2889
2887
  }
2890
2888
  break;
2891
2889
  }
@@ -2904,44 +2902,45 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2904
2902
  }
2905
2903
  return acc;
2906
2904
  }, []);
2907
- result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2905
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2908
2906
  } else {
2909
- result[column.name] = null;
2907
+ data[column.name] = null;
2910
2908
  }
2911
2909
  break;
2912
2910
  }
2913
2911
  default:
2914
- result[column.name] = value ?? null;
2912
+ data[column.name] = value ?? null;
2915
2913
  if (column.notNull === true && value === null) {
2916
2914
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2917
2915
  }
2918
2916
  break;
2919
2917
  }
2920
2918
  }
2921
- result.read = function(columns2) {
2922
- return db[table].read(result["id"], columns2);
2919
+ const record = { ...data };
2920
+ record.read = function(columns2) {
2921
+ return db[table].read(record["id"], columns2);
2923
2922
  };
2924
- result.update = function(data, b, c) {
2923
+ record.update = function(data2, b, c) {
2925
2924
  const columns2 = isStringArray(b) ? b : ["*"];
2926
2925
  const ifVersion = parseIfVersion(b, c);
2927
- return db[table].update(result["id"], data, columns2, { ifVersion });
2926
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2928
2927
  };
2929
- result.replace = function(data, b, c) {
2928
+ record.replace = function(data2, b, c) {
2930
2929
  const columns2 = isStringArray(b) ? b : ["*"];
2931
2930
  const ifVersion = parseIfVersion(b, c);
2932
- return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2931
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2933
2932
  };
2934
- result.delete = function() {
2935
- return db[table].delete(result["id"]);
2933
+ record.delete = function() {
2934
+ return db[table].delete(record["id"]);
2936
2935
  };
2937
- result.getMetadata = function() {
2936
+ record.getMetadata = function() {
2938
2937
  return xata;
2939
2938
  };
2940
2939
  for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2941
- Object.defineProperty(result, prop, { enumerable: false });
2940
+ Object.defineProperty(record, prop, { enumerable: false });
2942
2941
  }
2943
- Object.freeze(result);
2944
- return result;
2942
+ Object.freeze(record);
2943
+ return record;
2945
2944
  };
2946
2945
  function extractId(value) {
2947
2946
  if (isString(value))
@@ -3337,7 +3336,7 @@ const buildClient = (plugins) => {
3337
3336
  }
3338
3337
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3339
3338
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3340
- const isBrowser = typeof window !== "undefined";
3339
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3341
3340
  if (isBrowser && !enableBrowser) {
3342
3341
  throw new Error(
3343
3342
  "You are trying to use Xata from the browser, which is potentially a non-secure environment. If you understand the security concerns, such as leaking your credentials, pass `enableBrowser: true` to the client options to remove this error."