@xata.io/client 0.0.0-alpha.vf882519 → 0.0.0-alpha.vf88f0fd

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,7 @@ 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
+ "@typescript-eslint/ban-types": "off",
11
12
  }
12
13
  };
@@ -0,0 +1,4 @@
1
+
2
+ > @xata.io/client@0.21.6 add-version /home/runner/work/client-ts/client-ts/packages/client
3
+ > node ../../scripts/add-version-file.mjs
4
+
@@ -0,0 +1,13 @@
1
+
2
+ > @xata.io/client@0.21.6 build /home/runner/work/client-ts/client-ts/packages/client
3
+ > rimraf dist && rollup -c
4
+
5
+ 
6
+ src/index.ts → dist/index.cjs...
7
+ created dist/index.cjs in 1s
8
+ 
9
+ src/index.ts → dist/index.mjs...
10
+ created dist/index.mjs in 889ms
11
+ 
12
+ src/index.ts → dist/index.d.ts...
13
+ created dist/index.d.ts in 6.5s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.0.0-alpha.vf88f0fd
4
+
5
+ ### Minor Changes
6
+
7
+ - [#852](https://github.com/xataio/client-ts/pull/852) [`b2a4def4`](https://github.com/xataio/client-ts/commit/b2a4def4baf3eb18cd323895635e0bccb7f876f4) Thanks [@SferaDev](https://github.com/SferaDev)! - [BREAKING CHANGE] Reduce column selection depth
8
+
9
+ ### Patch Changes
10
+
11
+ - Force canary build
12
+
13
+ - [#835](https://github.com/xataio/client-ts/pull/835) [`379e6144`](https://github.com/xataio/client-ts/commit/379e61446b21e7cbadd7fc59267736c6845ec566) Thanks [@SferaDev](https://github.com/SferaDev)! - Add helper methods `toSerializable` and `toString`
14
+
15
+ ## 0.21.6
16
+
17
+ ### Patch Changes
18
+
19
+ - [#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
20
+
21
+ - [#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
22
+
23
+ ## 0.21.5
24
+
25
+ ### Patch Changes
26
+
27
+ - [#825](https://github.com/xataio/client-ts/pull/825) [`41c4d29f`](https://github.com/xataio/client-ts/commit/41c4d29f9f9fc7ce87b755e447a2030fe8c10d70) Thanks [@SferaDev](https://github.com/SferaDev)! - Export fetcher error
28
+
29
+ ## 0.21.4
30
+
31
+ ### Patch Changes
32
+
33
+ - [#816](https://github.com/xataio/client-ts/pull/816) [`a0149435`](https://github.com/xataio/client-ts/commit/a01494358ae3a8dd9d7eba3a276fe6f8b7827a33) Thanks [@SferaDev](https://github.com/SferaDev)! - Improve types for datetime fields accepting strings
34
+
3
35
  ## 0.21.3
4
36
 
5
37
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Xata SDK for TypeScript and JavaScript
2
2
 
3
- This SDK has zero dependencies, so it can be used in many JavaScript runtimes including Node.js, Cloudflare workers, Deno, Electron, etc. It also works in browsers for the same reason. But this is strongly discouraged because you can easily leak your API keys from browsers.
3
+ The Xata SDK supports typescript definitions for your Xata database schema. It also works with JavaScript.
4
+
5
+ It has zero dependencies and runs in Node.js, V8, Deno and Bun.
6
+
7
+ ## Installation
8
+
9
+ See our [docs](https://xata.io/docs/sdk/typescript#installation) to get started using the Xata SDK.
10
+
4
11
 
5
12
  ## Table of Contents
6
13
 
@@ -22,7 +29,7 @@ This SDK has zero dependencies, so it can be used in many JavaScript runtimes in
22
29
 
23
30
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
24
31
 
25
- ## Installation
32
+ ## Manual Installation
26
33
 
27
34
  ```bash
28
35
  npm install @xata.io/client
package/dist/index.cjs CHANGED
@@ -166,28 +166,14 @@ function getGlobalFallbackBranch() {
166
166
  return void 0;
167
167
  }
168
168
  }
169
- async function getGitBranch() {
170
- const cmd = ["git", "branch", "--show-current"];
171
- const fullCmd = cmd.join(" ");
172
- const nodeModule = ["child", "process"].join("_");
173
- const execOptions = { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] };
174
- try {
175
- if (typeof require === "function") {
176
- return require(nodeModule).execSync(fullCmd, execOptions).trim();
177
- }
178
- const { execSync } = await import(nodeModule);
179
- return execSync(fullCmd, execOptions).toString().trim();
180
- } catch (err) {
181
- }
169
+ function getDatabaseURL() {
182
170
  try {
183
- if (isObject(Deno)) {
184
- const process2 = Deno.run({ cmd, stdout: "piped", stderr: "null" });
185
- return new TextDecoder().decode(await process2.output()).trim();
186
- }
171
+ const { databaseURL } = getEnvironment();
172
+ return databaseURL;
187
173
  } catch (err) {
174
+ return void 0;
188
175
  }
189
176
  }
190
-
191
177
  function getAPIKey() {
192
178
  try {
193
179
  const { apiKey } = getEnvironment();
@@ -304,7 +290,7 @@ function generateUUID() {
304
290
  });
305
291
  }
306
292
 
307
- const VERSION = "0.0.0-alpha.vf882519";
293
+ const VERSION = "0.21.6";
308
294
 
309
295
  class ErrorWithCause extends Error {
310
296
  constructor(message, options) {
@@ -403,7 +389,7 @@ async function fetch$1({
403
389
  pool.setFetch(fetchImpl);
404
390
  return await trace(
405
391
  `${method.toUpperCase()} ${path}`,
406
- async ({ name, setAttributes }) => {
392
+ async ({ setAttributes }) => {
407
393
  const baseUrl = buildBaseUrl({ endpoint, path, workspacesApiUrl, pathParams, apiUrl });
408
394
  const fullUrl = resolveUrl(baseUrl, queryParams, pathParams);
409
395
  const url = fullUrl.includes("localhost") ? fullUrl.replace(/^[^.]+\./, "http://") : fullUrl;
@@ -472,17 +458,12 @@ function parseUrl(url) {
472
458
 
473
459
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
474
460
 
475
- const dEPRECATEDgetDatabaseList = (variables, signal) => dataPlaneFetch({ url: "/dbs", method: "get", ...variables, signal });
476
461
  const getBranchList = (variables, signal) => dataPlaneFetch({
477
462
  url: "/dbs/{dbName}",
478
463
  method: "get",
479
464
  ...variables,
480
465
  signal
481
466
  });
482
- const dEPRECATEDcreateDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "put", ...variables, signal });
483
- const dEPRECATEDdeleteDatabase = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}", method: "delete", ...variables, signal });
484
- const dEPRECATEDgetDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "get", ...variables, signal });
485
- const dEPRECATEDupdateDatabaseMetadata = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/metadata", method: "patch", ...variables, signal });
486
467
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
487
468
  url: "/db/{dbBranchName}",
488
469
  method: "get",
@@ -521,7 +502,6 @@ const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName
521
502
  const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
522
503
  const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
523
504
  const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
524
- const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
525
505
  const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
526
506
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
527
507
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
@@ -588,6 +568,7 @@ const deleteColumn = (variables, signal) => dataPlaneFetch({
588
568
  ...variables,
589
569
  signal
590
570
  });
571
+ const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
591
572
  const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
592
573
  const getRecord = (variables, signal) => dataPlaneFetch({
593
574
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
@@ -621,13 +602,6 @@ const searchTable = (variables, signal) => dataPlaneFetch({
621
602
  const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
622
603
  const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
623
604
  const operationsByTag$2 = {
624
- database: {
625
- dEPRECATEDgetDatabaseList,
626
- dEPRECATEDcreateDatabase,
627
- dEPRECATEDdeleteDatabase,
628
- dEPRECATEDgetDatabaseMetadata,
629
- dEPRECATEDupdateDatabaseMetadata
630
- },
631
605
  branch: {
632
606
  getBranchList,
633
607
  getBranchDetails,
@@ -652,16 +626,6 @@ const operationsByTag$2 = {
652
626
  previewBranchSchemaEdit,
653
627
  applyBranchSchemaEdit
654
628
  },
655
- records: {
656
- branchTransaction,
657
- insertRecord,
658
- getRecord,
659
- insertRecordWithID,
660
- updateRecordWithID,
661
- upsertRecordWithID,
662
- deleteRecord,
663
- bulkInsertTableRecords
664
- },
665
629
  migrationRequests: {
666
630
  queryMigrationRequests,
667
631
  createMigrationRequest,
@@ -684,6 +648,16 @@ const operationsByTag$2 = {
684
648
  updateColumn,
685
649
  deleteColumn
686
650
  },
651
+ records: {
652
+ branchTransaction,
653
+ insertRecord,
654
+ getRecord,
655
+ insertRecordWithID,
656
+ updateRecordWithID,
657
+ upsertRecordWithID,
658
+ deleteRecord,
659
+ bulkInsertTableRecords
660
+ },
687
661
  searchAndFilter: { queryTable, searchBranch, searchTable, summarizeTable, aggregateTable }
688
662
  };
689
663
 
@@ -1898,8 +1872,8 @@ class DatabaseApi {
1898
1872
  }
1899
1873
 
1900
1874
  class XataApiPlugin {
1901
- async build(options) {
1902
- const { fetchImpl, apiKey } = await options.getFetchProps();
1875
+ build(options) {
1876
+ const { fetchImpl, apiKey } = options.getFetchProps();
1903
1877
  return new XataApiClient({ fetch: fetchImpl, apiKey });
1904
1878
  }
1905
1879
  }
@@ -1983,6 +1957,12 @@ const _RecordArray = class extends Array {
1983
1957
  toArray() {
1984
1958
  return new Array(...this);
1985
1959
  }
1960
+ toSerializable() {
1961
+ return JSON.parse(this.toString());
1962
+ }
1963
+ toString() {
1964
+ return JSON.stringify(this.toArray());
1965
+ }
1986
1966
  map(callbackfn, thisArg) {
1987
1967
  return this.toArray().map(callbackfn, thisArg);
1988
1968
  }
@@ -2847,15 +2827,16 @@ deleteRecords_fn = async function(recordIds) {
2847
2827
  };
2848
2828
  _setCacheQuery = new WeakSet();
2849
2829
  setCacheQuery_fn = async function(query, meta, records) {
2850
- await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
2830
+ await __privateGet$4(this, _cache)?.set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
2851
2831
  };
2852
2832
  _getCacheQuery = new WeakSet();
2853
2833
  getCacheQuery_fn = async function(query) {
2854
2834
  const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
2855
- const result = await __privateGet$4(this, _cache).get(key);
2835
+ const result = await __privateGet$4(this, _cache)?.get(key);
2856
2836
  if (!result)
2857
2837
  return null;
2858
- const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
2838
+ const defaultTTL = __privateGet$4(this, _cache)?.defaultQueryTTL ?? -1;
2839
+ const { cache: ttl = defaultTTL } = query.getQueryOptions();
2859
2840
  if (ttl < 0)
2860
2841
  return null;
2861
2842
  const hasExpired = result.date.getTime() + ttl < Date.now();
@@ -2881,23 +2862,23 @@ const transformObjectLinks = (object) => {
2881
2862
  }, {});
2882
2863
  };
2883
2864
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
2884
- const result = {};
2865
+ const data = {};
2885
2866
  const { xata, ...rest } = object ?? {};
2886
- Object.assign(result, rest);
2867
+ Object.assign(data, rest);
2887
2868
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
2888
2869
  if (!columns)
2889
2870
  console.error(`Table ${table} not found in schema`);
2890
2871
  for (const column of columns ?? []) {
2891
2872
  if (!isValidColumn(selectedColumns, column))
2892
2873
  continue;
2893
- const value = result[column.name];
2874
+ const value = data[column.name];
2894
2875
  switch (column.type) {
2895
2876
  case "datetime": {
2896
2877
  const date = value !== void 0 ? new Date(value) : null;
2897
2878
  if (date !== null && isNaN(date.getTime())) {
2898
2879
  console.error(`Failed to parse date ${value} for field ${column.name}`);
2899
2880
  } else {
2900
- result[column.name] = date;
2881
+ data[column.name] = date;
2901
2882
  }
2902
2883
  break;
2903
2884
  }
@@ -2916,44 +2897,51 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
2916
2897
  }
2917
2898
  return acc;
2918
2899
  }, []);
2919
- result[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2900
+ data[column.name] = initObject(db, schemaTables, linkTable, value, selectedLinkColumns);
2920
2901
  } else {
2921
- result[column.name] = null;
2902
+ data[column.name] = null;
2922
2903
  }
2923
2904
  break;
2924
2905
  }
2925
2906
  default:
2926
- result[column.name] = value ?? null;
2907
+ data[column.name] = value ?? null;
2927
2908
  if (column.notNull === true && value === null) {
2928
2909
  console.error(`Parse error, column ${column.name} is non nullable and value resolves null`);
2929
2910
  }
2930
2911
  break;
2931
2912
  }
2932
2913
  }
2933
- result.read = function(columns2) {
2934
- return db[table].read(result["id"], columns2);
2914
+ const record = { ...data };
2915
+ record.read = function(columns2) {
2916
+ return db[table].read(record["id"], columns2);
2935
2917
  };
2936
- result.update = function(data, b, c) {
2918
+ record.update = function(data2, b, c) {
2937
2919
  const columns2 = isStringArray(b) ? b : ["*"];
2938
2920
  const ifVersion = parseIfVersion(b, c);
2939
- return db[table].update(result["id"], data, columns2, { ifVersion });
2921
+ return db[table].update(record["id"], data2, columns2, { ifVersion });
2940
2922
  };
2941
- result.replace = function(data, b, c) {
2923
+ record.replace = function(data2, b, c) {
2942
2924
  const columns2 = isStringArray(b) ? b : ["*"];
2943
2925
  const ifVersion = parseIfVersion(b, c);
2944
- return db[table].createOrReplace(result["id"], data, columns2, { ifVersion });
2926
+ return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
2945
2927
  };
2946
- result.delete = function() {
2947
- return db[table].delete(result["id"]);
2928
+ record.delete = function() {
2929
+ return db[table].delete(record["id"]);
2948
2930
  };
2949
- result.getMetadata = function() {
2931
+ record.getMetadata = function() {
2950
2932
  return xata;
2951
2933
  };
2952
- for (const prop of ["read", "update", "replace", "delete", "getMetadata"]) {
2953
- Object.defineProperty(result, prop, { enumerable: false });
2934
+ record.toSerializable = function() {
2935
+ return JSON.parse(JSON.stringify(transformObjectLinks(data)));
2936
+ };
2937
+ record.toString = function() {
2938
+ return JSON.stringify(transformObjectLinks(data));
2939
+ };
2940
+ for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
2941
+ Object.defineProperty(record, prop, { enumerable: false });
2954
2942
  }
2955
- Object.freeze(result);
2956
- return result;
2943
+ Object.freeze(record);
2944
+ return record;
2957
2945
  };
2958
2946
  function extractId(value) {
2959
2947
  if (isString(value))
@@ -3205,86 +3193,6 @@ const isBranchStrategyBuilder = (strategy) => {
3205
3193
  return typeof strategy === "function";
3206
3194
  };
3207
3195
 
3208
- async function getCurrentBranchName(options) {
3209
- const { branch, envBranch } = getEnvironment();
3210
- if (branch)
3211
- return branch;
3212
- const gitBranch = envBranch || await getGitBranch();
3213
- return resolveXataBranch(gitBranch, options);
3214
- }
3215
- async function getCurrentBranchDetails(options) {
3216
- const branch = await getCurrentBranchName(options);
3217
- return getDatabaseBranch(branch, options);
3218
- }
3219
- async function resolveXataBranch(gitBranch, options) {
3220
- const databaseURL = options?.databaseURL || getDatabaseURL();
3221
- const apiKey = options?.apiKey || getAPIKey();
3222
- if (!databaseURL)
3223
- throw new Error(
3224
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3225
- );
3226
- if (!apiKey)
3227
- throw new Error(
3228
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3229
- );
3230
- const [protocol, , host, , dbName] = databaseURL.split("/");
3231
- const urlParts = parseWorkspacesUrlParts(host);
3232
- if (!urlParts)
3233
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3234
- const { workspace, region } = urlParts;
3235
- const { fallbackBranch } = getEnvironment();
3236
- const { branch } = await resolveBranch({
3237
- apiKey,
3238
- apiUrl: databaseURL,
3239
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3240
- workspacesApiUrl: `${protocol}//${host}`,
3241
- pathParams: { dbName, workspace, region },
3242
- queryParams: { gitBranch, fallbackBranch },
3243
- trace: defaultTrace,
3244
- clientName: options?.clientName
3245
- });
3246
- return branch;
3247
- }
3248
- async function getDatabaseBranch(branch, options) {
3249
- const databaseURL = options?.databaseURL || getDatabaseURL();
3250
- const apiKey = options?.apiKey || getAPIKey();
3251
- if (!databaseURL)
3252
- throw new Error(
3253
- "A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely"
3254
- );
3255
- if (!apiKey)
3256
- throw new Error(
3257
- "An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely"
3258
- );
3259
- const [protocol, , host, , database] = databaseURL.split("/");
3260
- const urlParts = parseWorkspacesUrlParts(host);
3261
- if (!urlParts)
3262
- throw new Error(`Unable to parse workspace and region: ${databaseURL}`);
3263
- const { workspace, region } = urlParts;
3264
- try {
3265
- return await getBranchDetails({
3266
- apiKey,
3267
- apiUrl: databaseURL,
3268
- fetchImpl: getFetchImplementation(options?.fetchImpl),
3269
- workspacesApiUrl: `${protocol}//${host}`,
3270
- pathParams: { dbBranchName: `${database}:${branch}`, workspace, region },
3271
- trace: defaultTrace
3272
- });
3273
- } catch (err) {
3274
- if (isObject(err) && err.status === 404)
3275
- return null;
3276
- throw err;
3277
- }
3278
- }
3279
- function getDatabaseURL() {
3280
- try {
3281
- const { databaseURL } = getEnvironment();
3282
- return databaseURL;
3283
- } catch (err) {
3284
- return void 0;
3285
- }
3286
- }
3287
-
3288
3196
  var __accessCheck = (obj, member, msg) => {
3289
3197
  if (!member.has(obj))
3290
3198
  throw TypeError("Cannot " + msg);
@@ -3332,24 +3240,17 @@ const buildClient = (plugins) => {
3332
3240
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
3333
3241
  if (namespace === void 0)
3334
3242
  continue;
3335
- const result = namespace.build(pluginOptions);
3336
- if (result instanceof Promise) {
3337
- void result.then((namespace2) => {
3338
- this[key] = namespace2;
3339
- });
3340
- } else {
3341
- this[key] = result;
3342
- }
3243
+ this[key] = namespace.build(pluginOptions);
3343
3244
  }
3344
3245
  }
3345
3246
  async getConfig() {
3346
3247
  const databaseURL = __privateGet(this, _options).databaseURL;
3347
- const branch = await __privateGet(this, _options).branch();
3248
+ const branch = __privateGet(this, _options).branch;
3348
3249
  return { databaseURL, branch };
3349
3250
  }
3350
3251
  }, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
3351
3252
  const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
3352
- const isBrowser = typeof window !== "undefined";
3253
+ const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
3353
3254
  if (isBrowser && !enableBrowser) {
3354
3255
  throw new Error(
3355
3256
  "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."
@@ -3361,29 +3262,28 @@ const buildClient = (plugins) => {
3361
3262
  const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
3362
3263
  const trace = options?.trace ?? defaultTrace;
3363
3264
  const clientName = options?.clientName;
3364
- const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({
3365
- apiKey,
3366
- databaseURL,
3367
- fetchImpl: options?.fetch,
3368
- clientName: options?.clientName
3369
- });
3265
+ const host = options?.host ?? "production";
3266
+ const branch = options?.branch !== void 0 ? __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : "main";
3370
3267
  if (!apiKey) {
3371
3268
  throw new Error("Option apiKey is required");
3372
3269
  }
3373
3270
  if (!databaseURL) {
3374
3271
  throw new Error("Option databaseURL is required");
3375
3272
  }
3376
- return { fetch, databaseURL, apiKey, branch, cache, trace, clientID: generateUUID(), enableBrowser, clientName };
3377
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
3378
- fetch,
3379
- apiKey,
3380
- databaseURL,
3381
- branch,
3382
- trace,
3383
- clientID,
3384
- clientName
3385
- }) {
3386
- const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3273
+ return {
3274
+ fetch,
3275
+ databaseURL,
3276
+ apiKey,
3277
+ branch,
3278
+ cache,
3279
+ trace,
3280
+ host,
3281
+ clientID: generateUUID(),
3282
+ enableBrowser,
3283
+ clientName
3284
+ };
3285
+ }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({ fetch, apiKey, databaseURL, branch, trace, clientID, clientName }) {
3286
+ const branchValue = __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
3387
3287
  if (!branchValue)
3388
3288
  throw new Error("Unable to resolve branch value");
3389
3289
  return {
@@ -3399,17 +3299,17 @@ const buildClient = (plugins) => {
3399
3299
  clientID,
3400
3300
  clientName
3401
3301
  };
3402
- }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
3302
+ }, _evaluateBranch = new WeakSet(), evaluateBranch_fn = function(param) {
3403
3303
  if (__privateGet(this, _branch))
3404
3304
  return __privateGet(this, _branch);
3405
3305
  if (param === void 0)
3406
3306
  return void 0;
3407
3307
  const strategies = Array.isArray(param) ? [...param] : [param];
3408
- const evaluateBranch = async (strategy) => {
3409
- return isBranchStrategyBuilder(strategy) ? await strategy() : strategy;
3308
+ const evaluateBranch = (strategy) => {
3309
+ return isBranchStrategyBuilder(strategy) ? strategy() : strategy;
3410
3310
  };
3411
- for await (const strategy of strategies) {
3412
- const branch = await evaluateBranch(strategy);
3311
+ for (const strategy of strategies) {
3312
+ const branch = evaluateBranch(strategy);
3413
3313
  if (branch) {
3414
3314
  __privateSet(this, _branch, branch);
3415
3315
  return branch;
@@ -3510,6 +3410,7 @@ class XataError extends Error {
3510
3410
  }
3511
3411
 
3512
3412
  exports.BaseClient = BaseClient;
3413
+ exports.FetcherError = FetcherError;
3513
3414
  exports.Operations = operationsByTag;
3514
3415
  exports.PAGINATION_DEFAULT_OFFSET = PAGINATION_DEFAULT_OFFSET;
3515
3416
  exports.PAGINATION_DEFAULT_SIZE = PAGINATION_DEFAULT_SIZE;
@@ -3548,11 +3449,6 @@ exports.createMigrationRequest = createMigrationRequest;
3548
3449
  exports.createTable = createTable;
3549
3450
  exports.createUserAPIKey = createUserAPIKey;
3550
3451
  exports.createWorkspace = createWorkspace;
3551
- exports.dEPRECATEDcreateDatabase = dEPRECATEDcreateDatabase;
3552
- exports.dEPRECATEDdeleteDatabase = dEPRECATEDdeleteDatabase;
3553
- exports.dEPRECATEDgetDatabaseList = dEPRECATEDgetDatabaseList;
3554
- exports.dEPRECATEDgetDatabaseMetadata = dEPRECATEDgetDatabaseMetadata;
3555
- exports.dEPRECATEDupdateDatabaseMetadata = dEPRECATEDupdateDatabaseMetadata;
3556
3452
  exports.deleteBranch = deleteBranch;
3557
3453
  exports.deleteColumn = deleteColumn;
3558
3454
  exports.deleteDatabase = deleteDatabase;
@@ -3576,8 +3472,6 @@ exports.getBranchMigrationPlan = getBranchMigrationPlan;
3576
3472
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
3577
3473
  exports.getBranchStats = getBranchStats;
3578
3474
  exports.getColumn = getColumn;
3579
- exports.getCurrentBranchDetails = getCurrentBranchDetails;
3580
- exports.getCurrentBranchName = getCurrentBranchName;
3581
3475
  exports.getDatabaseList = getDatabaseList;
3582
3476
  exports.getDatabaseMetadata = getDatabaseMetadata;
3583
3477
  exports.getDatabaseURL = getDatabaseURL;