@xata.io/client 0.21.0 → 0.21.2

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
@@ -295,7 +295,7 @@ enqueue_fn = function(task) {
295
295
  return promise;
296
296
  };
297
297
 
298
- const VERSION = "0.21.0";
298
+ const VERSION = "0.21.2";
299
299
 
300
300
  class ErrorWithCause extends Error {
301
301
  constructor(message, options) {
@@ -411,6 +411,7 @@ async function fetch$1({
411
411
  method: method.toUpperCase(),
412
412
  body: body ? JSON.stringify(body) : void 0,
413
413
  headers: {
414
+ "Accept-Encoding": "identity",
414
415
  "Content-Type": "application/json",
415
416
  "X-Xata-Client-ID": clientID ?? "",
416
417
  "X-Xata-Session-ID": sessionID ?? "",
@@ -2047,6 +2048,7 @@ const _Query = class {
2047
2048
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
2048
2049
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
2049
2050
  __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2051
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
2050
2052
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
2051
2053
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2052
2054
  __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
@@ -2420,13 +2422,19 @@ class RestRepository extends Query {
2420
2422
  const result = await this.read(a, columns);
2421
2423
  return result;
2422
2424
  }
2423
- if (isString(a) && isObject(b)) {
2424
- const columns = isStringArray(c) ? c : void 0;
2425
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2426
- }
2427
- if (isObject(a) && isString(a.id)) {
2428
- const columns = isStringArray(b) ? b : void 0;
2429
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2425
+ try {
2426
+ if (isString(a) && isObject(b)) {
2427
+ const columns = isStringArray(c) ? c : void 0;
2428
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2429
+ }
2430
+ if (isObject(a) && isString(a.id)) {
2431
+ const columns = isStringArray(b) ? b : void 0;
2432
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2433
+ }
2434
+ } catch (error) {
2435
+ if (error.status === 422)
2436
+ return null;
2437
+ throw error;
2430
2438
  }
2431
2439
  throw new Error("Invalid arguments for update method");
2432
2440
  });
@@ -2601,7 +2609,8 @@ class RestRepository extends Query {
2601
2609
  filter: cleanFilter(data.filter),
2602
2610
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2603
2611
  page: data.pagination,
2604
- columns: data.columns ?? ["*"]
2612
+ columns: data.columns ?? ["*"],
2613
+ consistency: data.consistency
2605
2614
  },
2606
2615
  fetchOptions: data.fetchOptions,
2607
2616
  ...fetchProps
@@ -2629,6 +2638,7 @@ class RestRepository extends Query {
2629
2638
  filter: cleanFilter(data.filter),
2630
2639
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2631
2640
  columns: data.columns,
2641
+ consistency: data.consistency,
2632
2642
  page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2633
2643
  summaries,
2634
2644
  summariesFilter
@@ -3191,12 +3201,8 @@ const isBranchStrategyBuilder = (strategy) => {
3191
3201
 
3192
3202
  async function getCurrentBranchName(options) {
3193
3203
  const { branch, envBranch } = getEnvironment();
3194
- if (branch) {
3195
- const details = await getDatabaseBranch(branch, options);
3196
- if (details)
3197
- return branch;
3198
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
3199
- }
3204
+ if (branch)
3205
+ return branch;
3200
3206
  const gitBranch = envBranch || await getGitBranch();
3201
3207
  return resolveXataBranch(gitBranch, options);
3202
3208
  }
@@ -3228,7 +3234,8 @@ async function resolveXataBranch(gitBranch, options) {
3228
3234
  workspacesApiUrl: `${protocol}//${host}`,
3229
3235
  pathParams: { dbName, workspace, region },
3230
3236
  queryParams: { gitBranch, fallbackBranch },
3231
- trace: defaultTrace
3237
+ trace: defaultTrace,
3238
+ clientName: options?.clientName
3232
3239
  });
3233
3240
  return branch;
3234
3241
  }
@@ -3348,7 +3355,12 @@ const buildClient = (plugins) => {
3348
3355
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3349
3356
  const trace = options?.trace ?? defaultTrace;
3350
3357
  const clientName = options?.clientName;
3351
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
3358
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3359
+ apiKey,
3360
+ databaseURL,
3361
+ fetchImpl: options?.fetch,
3362
+ clientName: options?.clientName
3363
+ });
3352
3364
  if (!apiKey) {
3353
3365
  throw new Error("Option apiKey is required");
3354
3366
  }