@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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.21.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#787](https://github.com/xataio/client-ts/pull/787) [`93f5beed`](https://github.com/xataio/client-ts/commit/93f5beed77785b03409c614f5e2c3eca4c69c574) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose consistency options
8
+
9
+ - [#784](https://github.com/xataio/client-ts/pull/784) [`cbe0609e`](https://github.com/xataio/client-ts/commit/cbe0609ec9d6650030efbda712a1eb243287525d) Thanks [@SferaDev](https://github.com/SferaDev)! - Update resolveBranch behaviour
10
+
11
+ ## 0.21.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#781](https://github.com/xataio/client-ts/pull/781) [`fdfa47de`](https://github.com/xataio/client-ts/commit/fdfa47de93ec772170ff00a4341fc14434347df5) Thanks [@SferaDev](https://github.com/SferaDev)! - Send header to disable encoding
16
+
3
17
  ## 0.21.0
4
18
 
5
19
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -297,7 +297,7 @@ enqueue_fn = function(task) {
297
297
  return promise;
298
298
  };
299
299
 
300
- const VERSION = "0.21.0";
300
+ const VERSION = "0.21.2";
301
301
 
302
302
  class ErrorWithCause extends Error {
303
303
  constructor(message, options) {
@@ -413,6 +413,7 @@ async function fetch$1({
413
413
  method: method.toUpperCase(),
414
414
  body: body ? JSON.stringify(body) : void 0,
415
415
  headers: {
416
+ "Accept-Encoding": "identity",
416
417
  "Content-Type": "application/json",
417
418
  "X-Xata-Client-ID": clientID ?? "",
418
419
  "X-Xata-Session-ID": sessionID ?? "",
@@ -2049,6 +2050,7 @@ const _Query = class {
2049
2050
  __privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
2050
2051
  __privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
2051
2052
  __privateGet$5(this, _data).columns = data.columns ?? parent?.columns;
2053
+ __privateGet$5(this, _data).consistency = data.consistency ?? parent?.consistency;
2052
2054
  __privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
2053
2055
  __privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
2054
2056
  __privateGet$5(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
@@ -2422,13 +2424,19 @@ class RestRepository extends Query {
2422
2424
  const result = await this.read(a, columns);
2423
2425
  return result;
2424
2426
  }
2425
- if (isString(a) && isObject(b)) {
2426
- const columns = isStringArray(c) ? c : void 0;
2427
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2428
- }
2429
- if (isObject(a) && isString(a.id)) {
2430
- const columns = isStringArray(b) ? b : void 0;
2431
- return __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2427
+ try {
2428
+ if (isString(a) && isObject(b)) {
2429
+ const columns = isStringArray(c) ? c : void 0;
2430
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
2431
+ }
2432
+ if (isObject(a) && isString(a.id)) {
2433
+ const columns = isStringArray(b) ? b : void 0;
2434
+ return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
2435
+ }
2436
+ } catch (error) {
2437
+ if (error.status === 422)
2438
+ return null;
2439
+ throw error;
2432
2440
  }
2433
2441
  throw new Error("Invalid arguments for update method");
2434
2442
  });
@@ -2603,7 +2611,8 @@ class RestRepository extends Query {
2603
2611
  filter: cleanFilter(data.filter),
2604
2612
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2605
2613
  page: data.pagination,
2606
- columns: data.columns ?? ["*"]
2614
+ columns: data.columns ?? ["*"],
2615
+ consistency: data.consistency
2607
2616
  },
2608
2617
  fetchOptions: data.fetchOptions,
2609
2618
  ...fetchProps
@@ -2631,6 +2640,7 @@ class RestRepository extends Query {
2631
2640
  filter: cleanFilter(data.filter),
2632
2641
  sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
2633
2642
  columns: data.columns,
2643
+ consistency: data.consistency,
2634
2644
  page: data.pagination?.size !== void 0 ? { size: data.pagination?.size } : void 0,
2635
2645
  summaries,
2636
2646
  summariesFilter
@@ -3193,12 +3203,8 @@ const isBranchStrategyBuilder = (strategy) => {
3193
3203
 
3194
3204
  async function getCurrentBranchName(options) {
3195
3205
  const { branch, envBranch } = getEnvironment();
3196
- if (branch) {
3197
- const details = await getDatabaseBranch(branch, options);
3198
- if (details)
3199
- return branch;
3200
- console.warn(`Branch ${branch} not found in Xata. Ignoring...`);
3201
- }
3206
+ if (branch)
3207
+ return branch;
3202
3208
  const gitBranch = envBranch || await getGitBranch();
3203
3209
  return resolveXataBranch(gitBranch, options);
3204
3210
  }
@@ -3230,7 +3236,8 @@ async function resolveXataBranch(gitBranch, options) {
3230
3236
  workspacesApiUrl: `${protocol}//${host}`,
3231
3237
  pathParams: { dbName, workspace, region },
3232
3238
  queryParams: { gitBranch, fallbackBranch },
3233
- trace: defaultTrace
3239
+ trace: defaultTrace,
3240
+ clientName: options?.clientName
3234
3241
  });
3235
3242
  return branch;
3236
3243
  }
@@ -3350,7 +3357,12 @@ const buildClient = (plugins) => {
3350
3357
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3351
3358
  const trace = options?.trace ?? defaultTrace;
3352
3359
  const clientName = options?.clientName;
3353
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
3360
+ const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3361
+ apiKey,
3362
+ databaseURL,
3363
+ fetchImpl: options?.fetch,
3364
+ clientName: options?.clientName
3365
+ });
3354
3366
  if (!apiKey) {
3355
3367
  throw new Error("Option apiKey is required");
3356
3368
  }