@xata.io/client 0.0.0-next.v96c0efcf2b6fc9674a4a1e547d0b9c665f255e80 → 0.0.0-next.v9a81c4765c87e96d23c4e8ae0cbee78e78451dd5

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
@@ -37,8 +37,7 @@ function getLens(b64) {
37
37
  throw new Error("Invalid string. Length must be a multiple of 4");
38
38
  }
39
39
  let validLen = b64.indexOf("=");
40
- if (validLen === -1)
41
- validLen = len;
40
+ if (validLen === -1) validLen = len;
42
41
  const placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
43
42
  return [validLen, placeHoldersLen];
44
43
  }
@@ -373,10 +372,8 @@ class Buffer extends Uint8Array {
373
372
  break;
374
373
  }
375
374
  }
376
- if (x < y)
377
- return -1;
378
- if (y < x)
379
- return 1;
375
+ if (x < y) return -1;
376
+ if (y < x) return 1;
380
377
  return 0;
381
378
  }
382
379
  /**
@@ -389,33 +386,21 @@ class Buffer extends Uint8Array {
389
386
  * @param sourceEnd The offset within this buffer at which to end copying (exclusive).
390
387
  */
391
388
  copy(targetBuffer, targetStart, sourceStart, sourceEnd) {
392
- if (!Buffer.isBuffer(targetBuffer))
393
- throw new TypeError("argument should be a Buffer");
394
- if (!sourceStart)
395
- sourceStart = 0;
396
- if (!targetStart)
397
- targetStart = 0;
398
- if (!sourceEnd && sourceEnd !== 0)
399
- sourceEnd = this.length;
400
- if (targetStart >= targetBuffer.length)
401
- targetStart = targetBuffer.length;
402
- if (!targetStart)
403
- targetStart = 0;
404
- if (sourceEnd > 0 && sourceEnd < sourceStart)
405
- sourceEnd = sourceStart;
406
- if (sourceEnd === sourceStart)
407
- return 0;
408
- if (targetBuffer.length === 0 || this.length === 0)
409
- return 0;
389
+ if (!Buffer.isBuffer(targetBuffer)) throw new TypeError("argument should be a Buffer");
390
+ if (!sourceStart) sourceStart = 0;
391
+ if (!targetStart) targetStart = 0;
392
+ if (!sourceEnd && sourceEnd !== 0) sourceEnd = this.length;
393
+ if (targetStart >= targetBuffer.length) targetStart = targetBuffer.length;
394
+ if (!targetStart) targetStart = 0;
395
+ if (sourceEnd > 0 && sourceEnd < sourceStart) sourceEnd = sourceStart;
396
+ if (sourceEnd === sourceStart) return 0;
397
+ if (targetBuffer.length === 0 || this.length === 0) return 0;
410
398
  if (targetStart < 0) {
411
399
  throw new RangeError("targetStart out of bounds");
412
400
  }
413
- if (sourceStart < 0 || sourceStart >= this.length)
414
- throw new RangeError("Index out of range");
415
- if (sourceEnd < 0)
416
- throw new RangeError("sourceEnd out of bounds");
417
- if (sourceEnd > this.length)
418
- sourceEnd = this.length;
401
+ if (sourceStart < 0 || sourceStart >= this.length) throw new RangeError("Index out of range");
402
+ if (sourceEnd < 0) throw new RangeError("sourceEnd out of bounds");
403
+ if (sourceEnd > this.length) sourceEnd = this.length;
419
404
  if (targetBuffer.length - targetStart < sourceEnd - sourceStart) {
420
405
  sourceEnd = targetBuffer.length - targetStart + sourceStart;
421
406
  }
@@ -1576,8 +1561,7 @@ class Buffer extends Uint8Array {
1576
1561
  let c, hi, lo;
1577
1562
  const byteArray = [];
1578
1563
  for (let i = 0; i < str.length; ++i) {
1579
- if ((units -= 2) < 0)
1580
- break;
1564
+ if ((units -= 2) < 0) break;
1581
1565
  c = str.charCodeAt(i);
1582
1566
  hi = c >> 8;
1583
1567
  lo = c % 256;
@@ -1731,13 +1715,10 @@ class Buffer extends Uint8Array {
1731
1715
  let foundIndex = -1;
1732
1716
  for (i = byteOffset; i < arrLength; i++) {
1733
1717
  if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1734
- if (foundIndex === -1)
1735
- foundIndex = i;
1736
- if (i - foundIndex + 1 === valLength)
1737
- return foundIndex * indexSize;
1718
+ if (foundIndex === -1) foundIndex = i;
1719
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
1738
1720
  } else {
1739
- if (foundIndex !== -1)
1740
- i -= i - foundIndex;
1721
+ if (foundIndex !== -1) i -= i - foundIndex;
1741
1722
  foundIndex = -1;
1742
1723
  }
1743
1724
  }
@@ -1761,18 +1742,13 @@ class Buffer extends Uint8Array {
1761
1742
  return -1;
1762
1743
  }
1763
1744
  static _checkOffset(offset, ext, length) {
1764
- if (offset % 1 !== 0 || offset < 0)
1765
- throw new RangeError("offset is not uint");
1766
- if (offset + ext > length)
1767
- throw new RangeError("Trying to access beyond buffer length");
1745
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1746
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1768
1747
  }
1769
1748
  static _checkInt(buf, value, offset, ext, max, min) {
1770
- if (!Buffer.isBuffer(buf))
1771
- throw new TypeError('"buffer" argument must be a Buffer instance');
1772
- if (value > max || value < min)
1773
- throw new RangeError('"value" argument is out of bounds');
1774
- if (offset + ext > buf.length)
1775
- throw new RangeError("Index out of range");
1749
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1750
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
1751
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1776
1752
  }
1777
1753
  static _getEncoding(encoding) {
1778
1754
  let toLowerCase = false;
@@ -1822,8 +1798,7 @@ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1822
1798
  function base64clean(str) {
1823
1799
  str = str.split("=")[0];
1824
1800
  str = str.trim().replace(INVALID_BASE64_RE, "");
1825
- if (str.length < 2)
1826
- return "";
1801
+ if (str.length < 2) return "";
1827
1802
  while (str.length % 4 !== 0) {
1828
1803
  str = str + "=";
1829
1804
  }
@@ -1924,155 +1899,15 @@ function promiseMap(inputValues, mapper) {
1924
1899
  return inputValues.reduce(reducer, Promise.resolve([]));
1925
1900
  }
1926
1901
 
1927
- function getEnvironment() {
1928
- try {
1929
- if (isDefined(process) && isDefined(process.env)) {
1930
- return {
1931
- apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
1932
- databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
1933
- branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
1934
- deployPreview: process.env.XATA_PREVIEW,
1935
- deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
1936
- vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
1937
- vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
1938
- };
1939
- }
1940
- } catch (err) {
1941
- }
1942
- try {
1943
- if (isObject(Deno) && isObject(Deno.env)) {
1944
- return {
1945
- apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
1946
- databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
1947
- branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
1948
- deployPreview: Deno.env.get("XATA_PREVIEW"),
1949
- deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
1950
- vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
1951
- vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
1952
- };
1953
- }
1954
- } catch (err) {
1955
- }
1956
- return {
1957
- apiKey: getGlobalApiKey(),
1958
- databaseURL: getGlobalDatabaseURL(),
1959
- branch: getGlobalBranch(),
1960
- deployPreview: void 0,
1961
- deployPreviewBranch: void 0,
1962
- vercelGitCommitRef: void 0,
1963
- vercelGitRepoOwner: void 0
1964
- };
1965
- }
1966
- function getEnableBrowserVariable() {
1967
- try {
1968
- if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
1969
- return process.env.XATA_ENABLE_BROWSER === "true";
1970
- }
1971
- } catch (err) {
1972
- }
1973
- try {
1974
- if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
1975
- return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
1976
- }
1977
- } catch (err) {
1978
- }
1979
- try {
1980
- return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
1981
- } catch (err) {
1982
- return void 0;
1983
- }
1984
- }
1985
- function getGlobalApiKey() {
1986
- try {
1987
- return XATA_API_KEY;
1988
- } catch (err) {
1989
- return void 0;
1990
- }
1991
- }
1992
- function getGlobalDatabaseURL() {
1993
- try {
1994
- return XATA_DATABASE_URL;
1995
- } catch (err) {
1996
- return void 0;
1997
- }
1998
- }
1999
- function getGlobalBranch() {
2000
- try {
2001
- return XATA_BRANCH;
2002
- } catch (err) {
2003
- return void 0;
2004
- }
2005
- }
2006
- function getDatabaseURL() {
2007
- try {
2008
- const { databaseURL } = getEnvironment();
2009
- return databaseURL;
2010
- } catch (err) {
2011
- return void 0;
2012
- }
2013
- }
2014
- function getAPIKey() {
2015
- try {
2016
- const { apiKey } = getEnvironment();
2017
- return apiKey;
2018
- } catch (err) {
2019
- return void 0;
2020
- }
2021
- }
2022
- function getBranch() {
2023
- try {
2024
- const { branch } = getEnvironment();
2025
- return branch;
2026
- } catch (err) {
2027
- return void 0;
2028
- }
2029
- }
2030
- function buildPreviewBranchName({ org, branch }) {
2031
- return `preview-${org}-${branch}`;
2032
- }
2033
- function getPreviewBranch() {
2034
- try {
2035
- const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
2036
- if (deployPreviewBranch)
2037
- return deployPreviewBranch;
2038
- switch (deployPreview) {
2039
- case "vercel": {
2040
- if (!vercelGitCommitRef || !vercelGitRepoOwner) {
2041
- console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
2042
- return void 0;
2043
- }
2044
- return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
2045
- }
2046
- }
2047
- return void 0;
2048
- } catch (err) {
2049
- return void 0;
2050
- }
2051
- }
2052
-
2053
- var __accessCheck$6 = (obj, member, msg) => {
2054
- if (!member.has(obj))
2055
- throw TypeError("Cannot " + msg);
2056
- };
2057
- var __privateGet$5 = (obj, member, getter) => {
2058
- __accessCheck$6(obj, member, "read from private field");
2059
- return getter ? getter.call(obj) : member.get(obj);
2060
- };
2061
- var __privateAdd$6 = (obj, member, value) => {
2062
- if (member.has(obj))
2063
- throw TypeError("Cannot add the same private member more than once");
2064
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2065
- };
2066
- var __privateSet$4 = (obj, member, value, setter) => {
2067
- __accessCheck$6(obj, member, "write to private field");
2068
- setter ? setter.call(obj, value) : member.set(obj, value);
2069
- return value;
2070
- };
2071
- var __privateMethod$4 = (obj, member, method) => {
2072
- __accessCheck$6(obj, member, "access private method");
2073
- return method;
1902
+ var __typeError$6 = (msg) => {
1903
+ throw TypeError(msg);
2074
1904
  };
2075
- var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
1905
+ var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
1906
+ var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1907
+ var __privateAdd$6 = (obj, member, value) => member.has(obj) ? __typeError$6("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1908
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
1909
+ var __privateMethod$4 = (obj, member, method) => (__accessCheck$6(obj, member, "access private method"), method);
1910
+ var _fetch, _queue, _concurrency, _ApiRequestPool_instances, enqueue_fn;
2076
1911
  const REQUEST_TIMEOUT = 5 * 60 * 1e3;
2077
1912
  function getFetchImplementation(userFetch) {
2078
1913
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
@@ -2085,10 +1920,10 @@ function getFetchImplementation(userFetch) {
2085
1920
  }
2086
1921
  class ApiRequestPool {
2087
1922
  constructor(concurrency = 10) {
2088
- __privateAdd$6(this, _enqueue);
2089
- __privateAdd$6(this, _fetch, void 0);
2090
- __privateAdd$6(this, _queue, void 0);
2091
- __privateAdd$6(this, _concurrency, void 0);
1923
+ __privateAdd$6(this, _ApiRequestPool_instances);
1924
+ __privateAdd$6(this, _fetch);
1925
+ __privateAdd$6(this, _queue);
1926
+ __privateAdd$6(this, _concurrency);
2092
1927
  __privateSet$4(this, _queue, []);
2093
1928
  __privateSet$4(this, _concurrency, concurrency);
2094
1929
  this.running = 0;
@@ -2123,7 +1958,7 @@ class ApiRequestPool {
2123
1958
  }
2124
1959
  return response;
2125
1960
  };
2126
- return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
1961
+ return __privateMethod$4(this, _ApiRequestPool_instances, enqueue_fn).call(this, async () => {
2127
1962
  return await runRequest();
2128
1963
  });
2129
1964
  }
@@ -2131,7 +1966,7 @@ class ApiRequestPool {
2131
1966
  _fetch = new WeakMap();
2132
1967
  _queue = new WeakMap();
2133
1968
  _concurrency = new WeakMap();
2134
- _enqueue = new WeakSet();
1969
+ _ApiRequestPool_instances = new WeakSet();
2135
1970
  enqueue_fn = function(task) {
2136
1971
  const promise = new Promise((resolve) => __privateGet$5(this, _queue).push(resolve)).finally(() => {
2137
1972
  this.started--;
@@ -2414,18 +2249,15 @@ function parseProviderString(provider = "production") {
2414
2249
  return provider;
2415
2250
  }
2416
2251
  const [main, workspaces] = provider.split(",");
2417
- if (!main || !workspaces)
2418
- return null;
2252
+ if (!main || !workspaces) return null;
2419
2253
  return { main, workspaces };
2420
2254
  }
2421
2255
  function buildProviderString(provider) {
2422
- if (isHostProviderAlias(provider))
2423
- return provider;
2256
+ if (isHostProviderAlias(provider)) return provider;
2424
2257
  return `${provider.main},${provider.workspaces}`;
2425
2258
  }
2426
2259
  function parseWorkspacesUrlParts(url) {
2427
- if (!isString(url))
2428
- return null;
2260
+ if (!isString(url)) return null;
2429
2261
  const matches = {
2430
2262
  production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh\/db\/([^:]+):?(.*)?/),
2431
2263
  staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev\/db\/([^:]+):?(.*)?/),
@@ -2433,16 +2265,14 @@ function parseWorkspacesUrlParts(url) {
2433
2265
  local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(?:\d+)\/db\/([^:]+):?(.*)?/)
2434
2266
  };
2435
2267
  const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
2436
- if (!isHostProviderAlias(host) || !match)
2437
- return null;
2268
+ if (!isHostProviderAlias(host) || !match) return null;
2438
2269
  return { workspace: match[1], region: match[2], database: match[3], branch: match[4], host };
2439
2270
  }
2440
2271
 
2441
2272
  const pool = new ApiRequestPool();
2442
2273
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
2443
2274
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
2444
- if (value === void 0 || value === null)
2445
- return acc;
2275
+ if (value === void 0 || value === null) return acc;
2446
2276
  return { ...acc, [key]: value };
2447
2277
  }, {});
2448
2278
  const query = new URLSearchParams(cleanQueryParams).toString();
@@ -2490,8 +2320,7 @@ function hostHeader(url) {
2490
2320
  return groups?.host ? { Host: groups.host } : {};
2491
2321
  }
2492
2322
  async function parseBody(body, headers) {
2493
- if (!isDefined(body))
2494
- return void 0;
2323
+ if (!isDefined(body)) return void 0;
2495
2324
  if (isBlob(body) || typeof body.text === "function") {
2496
2325
  return body;
2497
2326
  }
@@ -2570,8 +2399,7 @@ async function fetch$1({
2570
2399
  [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
2571
2400
  });
2572
2401
  const message = response.headers?.get("x-xata-message");
2573
- if (message)
2574
- console.warn(message);
2402
+ if (message) console.warn(message);
2575
2403
  if (response.status === 204) {
2576
2404
  return {};
2577
2405
  }
@@ -2655,7 +2483,18 @@ function parseUrl(url) {
2655
2483
 
2656
2484
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
2657
2485
 
2658
- const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/apply", method: "post", ...variables, signal });
2486
+ const applyMigration = (variables, signal) => dataPlaneFetch({
2487
+ url: "/db/{dbBranchName}/migrations/apply",
2488
+ method: "post",
2489
+ ...variables,
2490
+ signal
2491
+ });
2492
+ const startMigration = (variables, signal) => dataPlaneFetch({
2493
+ url: "/db/{dbBranchName}/migrations/start",
2494
+ method: "post",
2495
+ ...variables,
2496
+ signal
2497
+ });
2659
2498
  const adaptTable = (variables, signal) => dataPlaneFetch({
2660
2499
  url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
2661
2500
  method: "post",
@@ -2668,9 +2507,24 @@ const adaptAllTables = (variables, signal) => dataPlaneFetch({
2668
2507
  ...variables,
2669
2508
  signal
2670
2509
  });
2671
- const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/status", method: "get", ...variables, signal });
2672
- const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/jobs/{jobId}", method: "get", ...variables, signal });
2673
- const getMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/history", method: "get", ...variables, signal });
2510
+ const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({
2511
+ url: "/db/{dbBranchName}/migrations/status",
2512
+ method: "get",
2513
+ ...variables,
2514
+ signal
2515
+ });
2516
+ const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({
2517
+ url: "/db/{dbBranchName}/migrations/jobs/{jobId}",
2518
+ method: "get",
2519
+ ...variables,
2520
+ signal
2521
+ });
2522
+ const getMigrationHistory = (variables, signal) => dataPlaneFetch({
2523
+ url: "/db/{dbBranchName}/migrations/history",
2524
+ method: "get",
2525
+ ...variables,
2526
+ signal
2527
+ });
2674
2528
  const getBranchList = (variables, signal) => dataPlaneFetch({
2675
2529
  url: "/dbs/{dbName}",
2676
2530
  method: "get",
@@ -2729,12 +2583,42 @@ const getBranchStats = (variables, signal) => dataPlaneFetch({
2729
2583
  });
2730
2584
  const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
2731
2585
  const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
2732
- const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "delete", ...variables, signal });
2733
- const resolveBranch = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/resolveBranch", method: "get", ...variables, signal });
2734
- const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations", method: "get", ...variables, signal });
2735
- const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/plan", method: "post", ...variables, signal });
2736
- const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/execute", method: "post", ...variables, signal });
2737
- const queryMigrationRequests = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/query", method: "post", ...variables, signal });
2586
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({
2587
+ url: "/dbs/{dbName}/gitBranches",
2588
+ method: "delete",
2589
+ ...variables,
2590
+ signal
2591
+ });
2592
+ const resolveBranch = (variables, signal) => dataPlaneFetch({
2593
+ url: "/dbs/{dbName}/resolveBranch",
2594
+ method: "get",
2595
+ ...variables,
2596
+ signal
2597
+ });
2598
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({
2599
+ url: "/db/{dbBranchName}/migrations",
2600
+ method: "get",
2601
+ ...variables,
2602
+ signal
2603
+ });
2604
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
2605
+ url: "/db/{dbBranchName}/migrations/plan",
2606
+ method: "post",
2607
+ ...variables,
2608
+ signal
2609
+ });
2610
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
2611
+ url: "/db/{dbBranchName}/migrations/execute",
2612
+ method: "post",
2613
+ ...variables,
2614
+ signal
2615
+ });
2616
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({
2617
+ url: "/dbs/{dbName}/migrations/query",
2618
+ method: "post",
2619
+ ...variables,
2620
+ signal
2621
+ });
2738
2622
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
2739
2623
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
2740
2624
  url: "/dbs/{dbName}/migrations/{mrNumber}",
@@ -2742,23 +2626,78 @@ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
2742
2626
  ...variables,
2743
2627
  signal
2744
2628
  });
2745
- const updateMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}", method: "patch", ...variables, signal });
2746
- const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/commits", method: "post", ...variables, signal });
2747
- const compareMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/compare", method: "post", ...variables, signal });
2748
- const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations/{mrNumber}/merge", method: "get", ...variables, signal });
2629
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({
2630
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
2631
+ method: "patch",
2632
+ ...variables,
2633
+ signal
2634
+ });
2635
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({
2636
+ url: "/dbs/{dbName}/migrations/{mrNumber}/commits",
2637
+ method: "post",
2638
+ ...variables,
2639
+ signal
2640
+ });
2641
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({
2642
+ url: "/dbs/{dbName}/migrations/{mrNumber}/compare",
2643
+ method: "post",
2644
+ ...variables,
2645
+ signal
2646
+ });
2647
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({
2648
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
2649
+ method: "get",
2650
+ ...variables,
2651
+ signal
2652
+ });
2749
2653
  const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
2750
2654
  url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
2751
2655
  method: "post",
2752
2656
  ...variables,
2753
2657
  signal
2754
2658
  });
2755
- const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/history", method: "post", ...variables, signal });
2756
- const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare", method: "post", ...variables, signal });
2757
- const compareBranchSchemas = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/compare/{branchName}", method: "post", ...variables, signal });
2758
- const updateBranchSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/update", method: "post", ...variables, signal });
2759
- const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/preview", method: "post", ...variables, signal });
2760
- const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/apply", method: "post", ...variables, signal });
2761
- const pushBranchMigrations = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/schema/push", method: "post", ...variables, signal });
2659
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({
2660
+ url: "/db/{dbBranchName}/schema/history",
2661
+ method: "post",
2662
+ ...variables,
2663
+ signal
2664
+ });
2665
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({
2666
+ url: "/db/{dbBranchName}/schema/compare",
2667
+ method: "post",
2668
+ ...variables,
2669
+ signal
2670
+ });
2671
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({
2672
+ url: "/db/{dbBranchName}/schema/compare/{branchName}",
2673
+ method: "post",
2674
+ ...variables,
2675
+ signal
2676
+ });
2677
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({
2678
+ url: "/db/{dbBranchName}/schema/update",
2679
+ method: "post",
2680
+ ...variables,
2681
+ signal
2682
+ });
2683
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
2684
+ url: "/db/{dbBranchName}/schema/preview",
2685
+ method: "post",
2686
+ ...variables,
2687
+ signal
2688
+ });
2689
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
2690
+ url: "/db/{dbBranchName}/schema/apply",
2691
+ method: "post",
2692
+ ...variables,
2693
+ signal
2694
+ });
2695
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({
2696
+ url: "/db/{dbBranchName}/schema/push",
2697
+ method: "post",
2698
+ ...variables,
2699
+ signal
2700
+ });
2762
2701
  const createTable = (variables, signal) => dataPlaneFetch({
2763
2702
  url: "/db/{dbBranchName}/tables/{tableName}",
2764
2703
  method: "put",
@@ -2771,14 +2710,24 @@ const deleteTable = (variables, signal) => dataPlaneFetch({
2771
2710
  ...variables,
2772
2711
  signal
2773
2712
  });
2774
- const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
2713
+ const updateTable = (variables, signal) => dataPlaneFetch({
2714
+ url: "/db/{dbBranchName}/tables/{tableName}",
2715
+ method: "patch",
2716
+ ...variables,
2717
+ signal
2718
+ });
2775
2719
  const getTableSchema = (variables, signal) => dataPlaneFetch({
2776
2720
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
2777
2721
  method: "get",
2778
2722
  ...variables,
2779
2723
  signal
2780
2724
  });
2781
- const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
2725
+ const setTableSchema = (variables, signal) => dataPlaneFetch({
2726
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
2727
+ method: "put",
2728
+ ...variables,
2729
+ signal
2730
+ });
2782
2731
  const getTableColumns = (variables, signal) => dataPlaneFetch({
2783
2732
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
2784
2733
  method: "get",
@@ -2786,7 +2735,12 @@ const getTableColumns = (variables, signal) => dataPlaneFetch({
2786
2735
  signal
2787
2736
  });
2788
2737
  const addTableColumn = (variables, signal) => dataPlaneFetch(
2789
- { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
2738
+ {
2739
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
2740
+ method: "post",
2741
+ ...variables,
2742
+ signal
2743
+ }
2790
2744
  );
2791
2745
  const getColumn = (variables, signal) => dataPlaneFetch({
2792
2746
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
@@ -2794,15 +2748,30 @@ const getColumn = (variables, signal) => dataPlaneFetch({
2794
2748
  ...variables,
2795
2749
  signal
2796
2750
  });
2797
- const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
2751
+ const updateColumn = (variables, signal) => dataPlaneFetch({
2752
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
2753
+ method: "patch",
2754
+ ...variables,
2755
+ signal
2756
+ });
2798
2757
  const deleteColumn = (variables, signal) => dataPlaneFetch({
2799
2758
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
2800
2759
  method: "delete",
2801
2760
  ...variables,
2802
2761
  signal
2803
2762
  });
2804
- const branchTransaction = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/transaction", method: "post", ...variables, signal });
2805
- const insertRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data", method: "post", ...variables, signal });
2763
+ const branchTransaction = (variables, signal) => dataPlaneFetch({
2764
+ url: "/db/{dbBranchName}/transaction",
2765
+ method: "post",
2766
+ ...variables,
2767
+ signal
2768
+ });
2769
+ const insertRecord = (variables, signal) => dataPlaneFetch({
2770
+ url: "/db/{dbBranchName}/tables/{tableName}/data",
2771
+ method: "post",
2772
+ ...variables,
2773
+ signal
2774
+ });
2806
2775
  const getFileItem = (variables, signal) => dataPlaneFetch({
2807
2776
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
2808
2777
  method: "get",
@@ -2845,11 +2814,36 @@ const getRecord = (variables, signal) => dataPlaneFetch({
2845
2814
  ...variables,
2846
2815
  signal
2847
2816
  });
2848
- const insertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "put", ...variables, signal });
2849
- const updateRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "patch", ...variables, signal });
2850
- const upsertRecordWithID = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "post", ...variables, signal });
2851
- const deleteRecord = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}", method: "delete", ...variables, signal });
2852
- const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/bulk", method: "post", ...variables, signal });
2817
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({
2818
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2819
+ method: "put",
2820
+ ...variables,
2821
+ signal
2822
+ });
2823
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({
2824
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2825
+ method: "patch",
2826
+ ...variables,
2827
+ signal
2828
+ });
2829
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({
2830
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2831
+ method: "post",
2832
+ ...variables,
2833
+ signal
2834
+ });
2835
+ const deleteRecord = (variables, signal) => dataPlaneFetch({
2836
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2837
+ method: "delete",
2838
+ ...variables,
2839
+ signal
2840
+ });
2841
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({
2842
+ url: "/db/{dbBranchName}/tables/{tableName}/bulk",
2843
+ method: "post",
2844
+ ...variables,
2845
+ signal
2846
+ });
2853
2847
  const queryTable = (variables, signal) => dataPlaneFetch({
2854
2848
  url: "/db/{dbBranchName}/tables/{tableName}/query",
2855
2849
  method: "post",
@@ -2868,16 +2862,36 @@ const searchTable = (variables, signal) => dataPlaneFetch({
2868
2862
  ...variables,
2869
2863
  signal
2870
2864
  });
2871
- const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
2865
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({
2866
+ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch",
2867
+ method: "post",
2868
+ ...variables,
2869
+ signal
2870
+ });
2872
2871
  const askTable = (variables, signal) => dataPlaneFetch({
2873
2872
  url: "/db/{dbBranchName}/tables/{tableName}/ask",
2874
2873
  method: "post",
2875
2874
  ...variables,
2876
2875
  signal
2877
2876
  });
2878
- const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
2879
- const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
2880
- const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
2877
+ const askTableSession = (variables, signal) => dataPlaneFetch({
2878
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
2879
+ method: "post",
2880
+ ...variables,
2881
+ signal
2882
+ });
2883
+ const summarizeTable = (variables, signal) => dataPlaneFetch({
2884
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
2885
+ method: "post",
2886
+ ...variables,
2887
+ signal
2888
+ });
2889
+ const aggregateTable = (variables, signal) => dataPlaneFetch({
2890
+ url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
2891
+ method: "post",
2892
+ ...variables,
2893
+ signal
2894
+ });
2881
2895
  const fileAccess = (variables, signal) => dataPlaneFetch({
2882
2896
  url: "/file/{fileId}",
2883
2897
  method: "get",
@@ -2899,6 +2913,7 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
2899
2913
  const operationsByTag$2 = {
2900
2914
  migrations: {
2901
2915
  applyMigration,
2916
+ startMigration,
2902
2917
  adaptTable,
2903
2918
  adaptAllTables,
2904
2919
  getBranchMigrationJobStatus,
@@ -2963,7 +2978,16 @@ const operationsByTag$2 = {
2963
2978
  deleteRecord,
2964
2979
  bulkInsertTableRecords
2965
2980
  },
2966
- files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
2981
+ files: {
2982
+ getFileItem,
2983
+ putFileItem,
2984
+ deleteFileItem,
2985
+ getFile,
2986
+ putFile,
2987
+ deleteFile,
2988
+ fileAccess,
2989
+ fileUpload
2990
+ },
2967
2991
  searchAndFilter: {
2968
2992
  queryTable,
2969
2993
  searchBranch,
@@ -3041,7 +3065,12 @@ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
3041
3065
  ...variables,
3042
3066
  signal
3043
3067
  });
3044
- const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
3068
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({
3069
+ url: "/user/oauth/tokens/{token}",
3070
+ method: "patch",
3071
+ ...variables,
3072
+ signal
3073
+ });
3045
3074
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
3046
3075
  url: "/workspaces",
3047
3076
  method: "get",
@@ -3072,49 +3101,150 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
3072
3101
  ...variables,
3073
3102
  signal
3074
3103
  });
3075
- const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "get", ...variables, signal });
3076
- const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/settings", method: "patch", ...variables, signal });
3077
- const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members", method: "get", ...variables, signal });
3078
- const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/members/{userId}", method: "put", ...variables, signal });
3104
+ const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({
3105
+ url: "/workspaces/{workspaceId}/settings",
3106
+ method: "get",
3107
+ ...variables,
3108
+ signal
3109
+ });
3110
+ const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({
3111
+ url: "/workspaces/{workspaceId}/settings",
3112
+ method: "patch",
3113
+ ...variables,
3114
+ signal
3115
+ });
3116
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({
3117
+ url: "/workspaces/{workspaceId}/members",
3118
+ method: "get",
3119
+ ...variables,
3120
+ signal
3121
+ });
3122
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({
3123
+ url: "/workspaces/{workspaceId}/members/{userId}",
3124
+ method: "put",
3125
+ ...variables,
3126
+ signal
3127
+ });
3079
3128
  const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
3080
3129
  url: "/workspaces/{workspaceId}/members/{userId}",
3081
3130
  method: "delete",
3082
3131
  ...variables,
3083
3132
  signal
3084
3133
  });
3085
- const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites", method: "post", ...variables, signal });
3086
- const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "patch", ...variables, signal });
3087
- const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}", method: "delete", ...variables, signal });
3088
- const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept", method: "post", ...variables, signal });
3089
- const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend", method: "post", ...variables, signal });
3090
- const listClusters = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "get", ...variables, signal });
3091
- const createCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters", method: "post", ...variables, signal });
3134
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({
3135
+ url: "/workspaces/{workspaceId}/invites",
3136
+ method: "post",
3137
+ ...variables,
3138
+ signal
3139
+ });
3140
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3141
+ url: "/workspaces/{workspaceId}/invites/{inviteId}",
3142
+ method: "patch",
3143
+ ...variables,
3144
+ signal
3145
+ });
3146
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3147
+ url: "/workspaces/{workspaceId}/invites/{inviteId}",
3148
+ method: "delete",
3149
+ ...variables,
3150
+ signal
3151
+ });
3152
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3153
+ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
3154
+ method: "post",
3155
+ ...variables,
3156
+ signal
3157
+ });
3158
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3159
+ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
3160
+ method: "post",
3161
+ ...variables,
3162
+ signal
3163
+ });
3164
+ const listClusters = (variables, signal) => controlPlaneFetch({
3165
+ url: "/workspaces/{workspaceId}/clusters",
3166
+ method: "get",
3167
+ ...variables,
3168
+ signal
3169
+ });
3170
+ const createCluster = (variables, signal) => controlPlaneFetch({
3171
+ url: "/workspaces/{workspaceId}/clusters",
3172
+ method: "post",
3173
+ ...variables,
3174
+ signal
3175
+ });
3092
3176
  const getCluster = (variables, signal) => controlPlaneFetch({
3093
3177
  url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3094
3178
  method: "get",
3095
3179
  ...variables,
3096
3180
  signal
3097
3181
  });
3098
- const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
3182
+ const updateCluster = (variables, signal) => controlPlaneFetch({
3183
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3184
+ method: "patch",
3185
+ ...variables,
3186
+ signal
3187
+ });
3188
+ const deleteCluster = (variables, signal) => controlPlaneFetch({
3189
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3190
+ method: "delete",
3191
+ ...variables,
3192
+ signal
3193
+ });
3099
3194
  const getDatabaseList = (variables, signal) => controlPlaneFetch({
3100
3195
  url: "/workspaces/{workspaceId}/dbs",
3101
3196
  method: "get",
3102
3197
  ...variables,
3103
3198
  signal
3104
3199
  });
3105
- const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
3200
+ const createDatabase = (variables, signal) => controlPlaneFetch({
3201
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3202
+ method: "put",
3203
+ ...variables,
3204
+ signal
3205
+ });
3106
3206
  const deleteDatabase = (variables, signal) => controlPlaneFetch({
3107
3207
  url: "/workspaces/{workspaceId}/dbs/{dbName}",
3108
3208
  method: "delete",
3109
3209
  ...variables,
3110
3210
  signal
3111
3211
  });
3112
- const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "get", ...variables, signal });
3113
- const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "patch", ...variables, signal });
3114
- const renameDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename", method: "post", ...variables, signal });
3115
- const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "get", ...variables, signal });
3116
- const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "put", ...variables, signal });
3117
- const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}/github", method: "delete", ...variables, signal });
3212
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({
3213
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3214
+ method: "get",
3215
+ ...variables,
3216
+ signal
3217
+ });
3218
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({
3219
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3220
+ method: "patch",
3221
+ ...variables,
3222
+ signal
3223
+ });
3224
+ const renameDatabase = (variables, signal) => controlPlaneFetch({
3225
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename",
3226
+ method: "post",
3227
+ ...variables,
3228
+ signal
3229
+ });
3230
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3231
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3232
+ method: "get",
3233
+ ...variables,
3234
+ signal
3235
+ });
3236
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3237
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3238
+ method: "put",
3239
+ ...variables,
3240
+ signal
3241
+ });
3242
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3243
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3244
+ method: "delete",
3245
+ ...variables,
3246
+ signal
3247
+ });
3118
3248
  const listRegions = (variables, signal) => controlPlaneFetch({
3119
3249
  url: "/workspaces/{workspaceId}/regions",
3120
3250
  method: "get",
@@ -3152,7 +3282,13 @@ const operationsByTag$1 = {
3152
3282
  acceptWorkspaceMemberInvite,
3153
3283
  resendWorkspaceMemberInvite
3154
3284
  },
3155
- xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
3285
+ xbcontrolOther: {
3286
+ listClusters,
3287
+ createCluster,
3288
+ getCluster,
3289
+ updateCluster,
3290
+ deleteCluster
3291
+ },
3156
3292
  databases: {
3157
3293
  getDatabaseList,
3158
3294
  createDatabase,
@@ -3172,7 +3308,7 @@ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
3172
3308
  const buildApiClient = () => class {
3173
3309
  constructor(options = {}) {
3174
3310
  const provider = options.host ?? "production";
3175
- const apiKey = options.apiKey ?? getAPIKey();
3311
+ const apiKey = options.apiKey;
3176
3312
  const trace = options.trace ?? defaultTrace;
3177
3313
  const clientID = generateUUID();
3178
3314
  if (!apiKey) {
@@ -3239,8 +3375,7 @@ function buildTransformString(transformations) {
3239
3375
  ).join(",");
3240
3376
  }
3241
3377
  function transformImage(url, ...transformations) {
3242
- if (!isDefined(url))
3243
- return void 0;
3378
+ if (!isDefined(url)) return void 0;
3244
3379
  const newTransformations = buildTransformString(transformations);
3245
3380
  const { hostname, pathname, search } = new URL(url);
3246
3381
  const pathParts = pathname.split("/");
@@ -3353,8 +3488,7 @@ class XataFile {
3353
3488
  }
3354
3489
  }
3355
3490
  const parseInputFileEntry = async (entry) => {
3356
- if (!isDefined(entry))
3357
- return null;
3491
+ if (!isDefined(entry)) return null;
3358
3492
  const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
3359
3493
  return compactObject({
3360
3494
  id,
@@ -3369,24 +3503,19 @@ const parseInputFileEntry = async (entry) => {
3369
3503
  };
3370
3504
 
3371
3505
  function cleanFilter(filter) {
3372
- if (!isDefined(filter))
3373
- return void 0;
3374
- if (!isObject(filter))
3375
- return filter;
3506
+ if (!isDefined(filter)) return void 0;
3507
+ if (!isObject(filter)) return filter;
3376
3508
  const values = Object.fromEntries(
3377
3509
  Object.entries(filter).reduce((acc, [key, value]) => {
3378
- if (!isDefined(value))
3379
- return acc;
3510
+ if (!isDefined(value)) return acc;
3380
3511
  if (Array.isArray(value)) {
3381
3512
  const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
3382
- if (clean.length === 0)
3383
- return acc;
3513
+ if (clean.length === 0) return acc;
3384
3514
  return [...acc, [key, clean]];
3385
3515
  }
3386
3516
  if (isObject(value)) {
3387
3517
  const clean = cleanFilter(value);
3388
- if (!isDefined(clean))
3389
- return acc;
3518
+ if (!isDefined(clean)) return acc;
3390
3519
  return [...acc, [key, clean]];
3391
3520
  }
3392
3521
  return [...acc, [key, value]];
@@ -3396,10 +3525,8 @@ function cleanFilter(filter) {
3396
3525
  }
3397
3526
 
3398
3527
  function stringifyJson(value) {
3399
- if (!isDefined(value))
3400
- return value;
3401
- if (isString(value))
3402
- return value;
3528
+ if (!isDefined(value)) return value;
3529
+ if (isString(value)) return value;
3403
3530
  try {
3404
3531
  return JSON.stringify(value);
3405
3532
  } catch (e) {
@@ -3414,28 +3541,17 @@ function parseJson(value) {
3414
3541
  }
3415
3542
  }
3416
3543
 
3417
- var __accessCheck$5 = (obj, member, msg) => {
3418
- if (!member.has(obj))
3419
- throw TypeError("Cannot " + msg);
3420
- };
3421
- var __privateGet$4 = (obj, member, getter) => {
3422
- __accessCheck$5(obj, member, "read from private field");
3423
- return getter ? getter.call(obj) : member.get(obj);
3424
- };
3425
- var __privateAdd$5 = (obj, member, value) => {
3426
- if (member.has(obj))
3427
- throw TypeError("Cannot add the same private member more than once");
3428
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3429
- };
3430
- var __privateSet$3 = (obj, member, value, setter) => {
3431
- __accessCheck$5(obj, member, "write to private field");
3432
- setter ? setter.call(obj, value) : member.set(obj, value);
3433
- return value;
3544
+ var __typeError$5 = (msg) => {
3545
+ throw TypeError(msg);
3434
3546
  };
3547
+ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
3548
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
3549
+ var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3550
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
3435
3551
  var _query, _page;
3436
3552
  class Page {
3437
3553
  constructor(query, meta, records = []) {
3438
- __privateAdd$5(this, _query, void 0);
3554
+ __privateAdd$5(this, _query);
3439
3555
  __privateSet$3(this, _query, query);
3440
3556
  this.meta = meta;
3441
3557
  this.records = new PageRecordArray(this, records);
@@ -3522,7 +3638,7 @@ class RecordArray extends Array {
3522
3638
  const _PageRecordArray = class _PageRecordArray extends Array {
3523
3639
  constructor(...args) {
3524
3640
  super(..._PageRecordArray.parseConstructorParams(...args));
3525
- __privateAdd$5(this, _page, void 0);
3641
+ __privateAdd$5(this, _page);
3526
3642
  __privateSet$3(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
3527
3643
  }
3528
3644
  static parseConstructorParams(...args) {
@@ -3593,34 +3709,20 @@ const _PageRecordArray = class _PageRecordArray extends Array {
3593
3709
  _page = new WeakMap();
3594
3710
  let PageRecordArray = _PageRecordArray;
3595
3711
 
3596
- var __accessCheck$4 = (obj, member, msg) => {
3597
- if (!member.has(obj))
3598
- throw TypeError("Cannot " + msg);
3712
+ var __typeError$4 = (msg) => {
3713
+ throw TypeError(msg);
3599
3714
  };
3600
- var __privateGet$3 = (obj, member, getter) => {
3601
- __accessCheck$4(obj, member, "read from private field");
3602
- return getter ? getter.call(obj) : member.get(obj);
3603
- };
3604
- var __privateAdd$4 = (obj, member, value) => {
3605
- if (member.has(obj))
3606
- throw TypeError("Cannot add the same private member more than once");
3607
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3608
- };
3609
- var __privateSet$2 = (obj, member, value, setter) => {
3610
- __accessCheck$4(obj, member, "write to private field");
3611
- setter ? setter.call(obj, value) : member.set(obj, value);
3612
- return value;
3613
- };
3614
- var __privateMethod$3 = (obj, member, method) => {
3615
- __accessCheck$4(obj, member, "access private method");
3616
- return method;
3617
- };
3618
- var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
3715
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
3716
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
3717
+ var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3718
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
3719
+ var __privateMethod$3 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
3720
+ var _table$1, _repository, _data, _Query_instances, cleanFilterConstraint_fn;
3619
3721
  const _Query = class _Query {
3620
3722
  constructor(repository, table, data, rawParent) {
3621
- __privateAdd$4(this, _cleanFilterConstraint);
3622
- __privateAdd$4(this, _table$1, void 0);
3623
- __privateAdd$4(this, _repository, void 0);
3723
+ __privateAdd$4(this, _Query_instances);
3724
+ __privateAdd$4(this, _table$1);
3725
+ __privateAdd$4(this, _repository);
3624
3726
  __privateAdd$4(this, _data, { filter: {} });
3625
3727
  // Implements pagination
3626
3728
  this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
@@ -3698,12 +3800,12 @@ const _Query = class _Query {
3698
3800
  filter(a, b) {
3699
3801
  if (arguments.length === 1) {
3700
3802
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
3701
- [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
3803
+ [column]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, column, constraint)
3702
3804
  }));
3703
3805
  const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
3704
3806
  return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
3705
3807
  } else {
3706
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3808
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3707
3809
  const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
3708
3810
  return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
3709
3811
  }
@@ -3782,8 +3884,7 @@ const _Query = class _Query {
3782
3884
  }
3783
3885
  async getFirstOrThrow(options = {}) {
3784
3886
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
3785
- if (records[0] === void 0)
3786
- throw new Error("No results found.");
3887
+ if (records[0] === void 0) throw new Error("No results found.");
3787
3888
  return records[0];
3788
3889
  }
3789
3890
  async summarize(params = {}) {
@@ -3838,7 +3939,7 @@ const _Query = class _Query {
3838
3939
  _table$1 = new WeakMap();
3839
3940
  _repository = new WeakMap();
3840
3941
  _data = new WeakMap();
3841
- _cleanFilterConstraint = new WeakSet();
3942
+ _Query_instances = new WeakSet();
3842
3943
  cleanFilterConstraint_fn = function(column, value) {
3843
3944
  const columnType = __privateGet$3(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
3844
3945
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
@@ -3899,8 +4000,7 @@ function isSortFilterString(value) {
3899
4000
  }
3900
4001
  function isSortFilterBase(filter) {
3901
4002
  return isObject(filter) && Object.entries(filter).every(([key, value]) => {
3902
- if (key === "*")
3903
- return value === "random";
4003
+ if (key === "*") return value === "random";
3904
4004
  return value === "asc" || value === "desc";
3905
4005
  });
3906
4006
  }
@@ -3921,29 +4021,15 @@ function buildSortFilter(filter) {
3921
4021
  }
3922
4022
  }
3923
4023
 
3924
- var __accessCheck$3 = (obj, member, msg) => {
3925
- if (!member.has(obj))
3926
- throw TypeError("Cannot " + msg);
3927
- };
3928
- var __privateGet$2 = (obj, member, getter) => {
3929
- __accessCheck$3(obj, member, "read from private field");
3930
- return getter ? getter.call(obj) : member.get(obj);
4024
+ var __typeError$3 = (msg) => {
4025
+ throw TypeError(msg);
3931
4026
  };
3932
- var __privateAdd$3 = (obj, member, value) => {
3933
- if (member.has(obj))
3934
- throw TypeError("Cannot add the same private member more than once");
3935
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3936
- };
3937
- var __privateSet$1 = (obj, member, value, setter) => {
3938
- __accessCheck$3(obj, member, "write to private field");
3939
- setter ? setter.call(obj, value) : member.set(obj, value);
3940
- return value;
3941
- };
3942
- var __privateMethod$2 = (obj, member, method) => {
3943
- __accessCheck$3(obj, member, "access private method");
3944
- return method;
3945
- };
3946
- var _table, _getFetchProps, _db, _schemaTables, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
4027
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
4028
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
4029
+ var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4030
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
4031
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
4032
+ var _table, _getFetchProps, _db, _schemaTables, _trace, _RestRepository_instances, insertRecordWithoutId_fn, insertRecordWithId_fn, insertRecords_fn, updateRecordWithID_fn, updateRecords_fn, upsertRecordWithID_fn, deleteRecord_fn, deleteRecords_fn, getSchemaTables_fn, transformObjectToApi_fn;
3947
4033
  const BULK_OPERATION_MAX_SIZE = 1e3;
3948
4034
  class Repository extends Query {
3949
4035
  }
@@ -3954,21 +4040,12 @@ class RestRepository extends Query {
3954
4040
  { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
3955
4041
  {}
3956
4042
  );
3957
- __privateAdd$3(this, _insertRecordWithoutId);
3958
- __privateAdd$3(this, _insertRecordWithId);
3959
- __privateAdd$3(this, _insertRecords);
3960
- __privateAdd$3(this, _updateRecordWithID);
3961
- __privateAdd$3(this, _updateRecords);
3962
- __privateAdd$3(this, _upsertRecordWithID);
3963
- __privateAdd$3(this, _deleteRecord);
3964
- __privateAdd$3(this, _deleteRecords);
3965
- __privateAdd$3(this, _getSchemaTables);
3966
- __privateAdd$3(this, _transformObjectToApi);
3967
- __privateAdd$3(this, _table, void 0);
3968
- __privateAdd$3(this, _getFetchProps, void 0);
3969
- __privateAdd$3(this, _db, void 0);
3970
- __privateAdd$3(this, _schemaTables, void 0);
3971
- __privateAdd$3(this, _trace, void 0);
4043
+ __privateAdd$3(this, _RestRepository_instances);
4044
+ __privateAdd$3(this, _table);
4045
+ __privateAdd$3(this, _getFetchProps);
4046
+ __privateAdd$3(this, _db);
4047
+ __privateAdd$3(this, _schemaTables);
4048
+ __privateAdd$3(this, _trace);
3972
4049
  __privateSet$1(this, _table, options.table);
3973
4050
  __privateSet$1(this, _db, options.db);
3974
4051
  __privateSet$1(this, _schemaTables, options.schemaTables);
@@ -3987,31 +4064,28 @@ class RestRepository extends Query {
3987
4064
  return __privateGet$2(this, _trace).call(this, "create", async () => {
3988
4065
  const ifVersion = parseIfVersion(b, c, d);
3989
4066
  if (Array.isArray(a)) {
3990
- if (a.length === 0)
3991
- return [];
3992
- const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
4067
+ if (a.length === 0) return [];
4068
+ const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
3993
4069
  const columns = isValidSelectableColumns(b) ? b : ["*"];
3994
4070
  const result = await this.read(ids, columns);
3995
4071
  return result;
3996
4072
  }
3997
4073
  if (isString(a) && isObject(b)) {
3998
- if (a === "")
3999
- throw new Error("The id can't be empty");
4074
+ if (a === "") throw new Error("The id can't be empty");
4000
4075
  const columns = isValidSelectableColumns(c) ? c : void 0;
4001
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
4076
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
4002
4077
  }
4003
4078
  if (isObject(a) && isString(a.xata_id)) {
4004
- if (a.xata_id === "")
4005
- throw new Error("The id can't be empty");
4079
+ if (a.xata_id === "") throw new Error("The id can't be empty");
4006
4080
  const columns = isValidSelectableColumns(b) ? b : void 0;
4007
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4081
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4008
4082
  createOnly: true,
4009
4083
  ifVersion
4010
4084
  });
4011
4085
  }
4012
4086
  if (isObject(a)) {
4013
4087
  const columns = isValidSelectableColumns(b) ? b : void 0;
4014
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
4088
+ return __privateMethod$2(this, _RestRepository_instances, insertRecordWithoutId_fn).call(this, a, columns);
4015
4089
  }
4016
4090
  throw new Error("Invalid arguments for create method");
4017
4091
  });
@@ -4020,8 +4094,7 @@ class RestRepository extends Query {
4020
4094
  return __privateGet$2(this, _trace).call(this, "read", async () => {
4021
4095
  const columns = isValidSelectableColumns(b) ? b : ["*"];
4022
4096
  if (Array.isArray(a)) {
4023
- if (a.length === 0)
4024
- return [];
4097
+ if (a.length === 0) return [];
4025
4098
  const ids = a.map((item) => extractId(item));
4026
4099
  const finalObjects = await this.getAll({ filter: { xata_id: { $any: compact(ids) } }, columns });
4027
4100
  const dictionary = finalObjects.reduce((acc, object) => {
@@ -4044,7 +4117,7 @@ class RestRepository extends Query {
4044
4117
  queryParams: { columns },
4045
4118
  ...__privateGet$2(this, _getFetchProps).call(this)
4046
4119
  });
4047
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4120
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4048
4121
  return initObject(
4049
4122
  __privateGet$2(this, _db),
4050
4123
  schemaTables,
@@ -4085,11 +4158,10 @@ class RestRepository extends Query {
4085
4158
  return __privateGet$2(this, _trace).call(this, "update", async () => {
4086
4159
  const ifVersion = parseIfVersion(b, c, d);
4087
4160
  if (Array.isArray(a)) {
4088
- if (a.length === 0)
4089
- return [];
4161
+ if (a.length === 0) return [];
4090
4162
  const existing = await this.read(a, ["xata_id"]);
4091
4163
  const updates = a.filter((_item, index) => existing[index] !== null);
4092
- await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
4164
+ await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, updates, {
4093
4165
  ifVersion,
4094
4166
  upsert: false
4095
4167
  });
@@ -4100,15 +4172,14 @@ class RestRepository extends Query {
4100
4172
  try {
4101
4173
  if (isString(a) && isObject(b)) {
4102
4174
  const columns = isValidSelectableColumns(c) ? c : void 0;
4103
- return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4175
+ return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4104
4176
  }
4105
4177
  if (isObject(a) && isString(a.xata_id)) {
4106
4178
  const columns = isValidSelectableColumns(b) ? b : void 0;
4107
- return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
4179
+ return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
4108
4180
  }
4109
4181
  } catch (error) {
4110
- if (error.status === 422)
4111
- return null;
4182
+ if (error.status === 422) return null;
4112
4183
  throw error;
4113
4184
  }
4114
4185
  throw new Error("Invalid arguments for update method");
@@ -4137,9 +4208,8 @@ class RestRepository extends Query {
4137
4208
  return __privateGet$2(this, _trace).call(this, "createOrUpdate", async () => {
4138
4209
  const ifVersion = parseIfVersion(b, c, d);
4139
4210
  if (Array.isArray(a)) {
4140
- if (a.length === 0)
4141
- return [];
4142
- await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
4211
+ if (a.length === 0) return [];
4212
+ await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, a, {
4143
4213
  ifVersion,
4144
4214
  upsert: true
4145
4215
  });
@@ -4148,16 +4218,14 @@ class RestRepository extends Query {
4148
4218
  return result;
4149
4219
  }
4150
4220
  if (isString(a) && isObject(b)) {
4151
- if (a === "")
4152
- throw new Error("The id can't be empty");
4221
+ if (a === "") throw new Error("The id can't be empty");
4153
4222
  const columns = isValidSelectableColumns(c) ? c : void 0;
4154
- return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4223
+ return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4155
4224
  }
4156
4225
  if (isObject(a) && isString(a.xata_id)) {
4157
- if (a.xata_id === "")
4158
- throw new Error("The id can't be empty");
4226
+ if (a.xata_id === "") throw new Error("The id can't be empty");
4159
4227
  const columns = isValidSelectableColumns(c) ? c : void 0;
4160
- return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
4228
+ return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
4161
4229
  }
4162
4230
  if (!isDefined(a) && isObject(b)) {
4163
4231
  return await this.create(b, c);
@@ -4172,24 +4240,21 @@ class RestRepository extends Query {
4172
4240
  return __privateGet$2(this, _trace).call(this, "createOrReplace", async () => {
4173
4241
  const ifVersion = parseIfVersion(b, c, d);
4174
4242
  if (Array.isArray(a)) {
4175
- if (a.length === 0)
4176
- return [];
4177
- const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
4243
+ if (a.length === 0) return [];
4244
+ const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
4178
4245
  const columns = isValidSelectableColumns(b) ? b : ["*"];
4179
4246
  const result = await this.read(ids, columns);
4180
4247
  return result;
4181
4248
  }
4182
4249
  if (isString(a) && isObject(b)) {
4183
- if (a === "")
4184
- throw new Error("The id can't be empty");
4250
+ if (a === "") throw new Error("The id can't be empty");
4185
4251
  const columns = isValidSelectableColumns(c) ? c : void 0;
4186
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
4252
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
4187
4253
  }
4188
4254
  if (isObject(a) && isString(a.xata_id)) {
4189
- if (a.xata_id === "")
4190
- throw new Error("The id can't be empty");
4255
+ if (a.xata_id === "") throw new Error("The id can't be empty");
4191
4256
  const columns = isValidSelectableColumns(c) ? c : void 0;
4192
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4257
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4193
4258
  createOnly: false,
4194
4259
  ifVersion
4195
4260
  });
@@ -4206,25 +4271,22 @@ class RestRepository extends Query {
4206
4271
  async delete(a, b) {
4207
4272
  return __privateGet$2(this, _trace).call(this, "delete", async () => {
4208
4273
  if (Array.isArray(a)) {
4209
- if (a.length === 0)
4210
- return [];
4274
+ if (a.length === 0) return [];
4211
4275
  const ids = a.map((o) => {
4212
- if (isString(o))
4213
- return o;
4214
- if (isString(o.xata_id))
4215
- return o.xata_id;
4276
+ if (isString(o)) return o;
4277
+ if (isString(o.xata_id)) return o.xata_id;
4216
4278
  throw new Error("Invalid arguments for delete method");
4217
4279
  });
4218
4280
  const columns = isValidSelectableColumns(b) ? b : ["*"];
4219
4281
  const result = await this.read(a, columns);
4220
- await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
4282
+ await __privateMethod$2(this, _RestRepository_instances, deleteRecords_fn).call(this, ids);
4221
4283
  return result;
4222
4284
  }
4223
4285
  if (isString(a)) {
4224
- return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
4286
+ return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a, b);
4225
4287
  }
4226
4288
  if (isObject(a) && isString(a.xata_id)) {
4227
- return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.xata_id, b);
4289
+ return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a.xata_id, b);
4228
4290
  }
4229
4291
  throw new Error("Invalid arguments for delete method");
4230
4292
  });
@@ -4268,7 +4330,7 @@ class RestRepository extends Query {
4268
4330
  },
4269
4331
  ...__privateGet$2(this, _getFetchProps).call(this)
4270
4332
  });
4271
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4333
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4272
4334
  return {
4273
4335
  records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
4274
4336
  totalCount
@@ -4293,7 +4355,7 @@ class RestRepository extends Query {
4293
4355
  },
4294
4356
  ...__privateGet$2(this, _getFetchProps).call(this)
4295
4357
  });
4296
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4358
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4297
4359
  return {
4298
4360
  records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
4299
4361
  totalCount
@@ -4335,7 +4397,7 @@ class RestRepository extends Query {
4335
4397
  fetchOptions: data.fetchOptions,
4336
4398
  ...__privateGet$2(this, _getFetchProps).call(this)
4337
4399
  });
4338
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4400
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4339
4401
  const records = objects.map(
4340
4402
  (record) => initObject(
4341
4403
  __privateGet$2(this, _db),
@@ -4369,7 +4431,7 @@ class RestRepository extends Query {
4369
4431
  },
4370
4432
  ...__privateGet$2(this, _getFetchProps).call(this)
4371
4433
  });
4372
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4434
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4373
4435
  return {
4374
4436
  ...result,
4375
4437
  summaries: result.summaries.map(
@@ -4417,9 +4479,9 @@ _getFetchProps = new WeakMap();
4417
4479
  _db = new WeakMap();
4418
4480
  _schemaTables = new WeakMap();
4419
4481
  _trace = new WeakMap();
4420
- _insertRecordWithoutId = new WeakSet();
4482
+ _RestRepository_instances = new WeakSet();
4421
4483
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
4422
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4484
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4423
4485
  const response = await insertRecord({
4424
4486
  pathParams: {
4425
4487
  workspace: "{workspaceId}",
@@ -4431,14 +4493,12 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
4431
4493
  body: record,
4432
4494
  ...__privateGet$2(this, _getFetchProps).call(this)
4433
4495
  });
4434
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4496
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4435
4497
  return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
4436
4498
  };
4437
- _insertRecordWithId = new WeakSet();
4438
4499
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
4439
- if (!recordId)
4440
- return null;
4441
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4500
+ if (!recordId) return null;
4501
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4442
4502
  const response = await insertRecordWithID({
4443
4503
  pathParams: {
4444
4504
  workspace: "{workspaceId}",
@@ -4451,13 +4511,12 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
4451
4511
  queryParams: { createOnly, columns, ifVersion },
4452
4512
  ...__privateGet$2(this, _getFetchProps).call(this)
4453
4513
  });
4454
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4514
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4455
4515
  return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
4456
4516
  };
4457
- _insertRecords = new WeakSet();
4458
4517
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
4459
4518
  const operations = await promiseMap(objects, async (object) => {
4460
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4519
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4461
4520
  return { insert: { table: __privateGet$2(this, _table), record, createOnly, ifVersion } };
4462
4521
  });
4463
4522
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
@@ -4482,11 +4541,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
4482
4541
  }
4483
4542
  return ids;
4484
4543
  };
4485
- _updateRecordWithID = new WeakSet();
4486
4544
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
4487
- if (!recordId)
4488
- return null;
4489
- const { xata_id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4545
+ if (!recordId) return null;
4546
+ const { xata_id: _id, ...record } = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4490
4547
  try {
4491
4548
  const response = await updateRecordWithID({
4492
4549
  pathParams: {
@@ -4500,7 +4557,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
4500
4557
  body: record,
4501
4558
  ...__privateGet$2(this, _getFetchProps).call(this)
4502
4559
  });
4503
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4560
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4504
4561
  return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
4505
4562
  } catch (e) {
4506
4563
  if (isObject(e) && e.status === 404) {
@@ -4509,10 +4566,9 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
4509
4566
  throw e;
4510
4567
  }
4511
4568
  };
4512
- _updateRecords = new WeakSet();
4513
4569
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
4514
4570
  const operations = await promiseMap(objects, async ({ xata_id, ...object }) => {
4515
- const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4571
+ const fields = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4516
4572
  return { update: { table: __privateGet$2(this, _table), id: xata_id, ifVersion, upsert, fields } };
4517
4573
  });
4518
4574
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
@@ -4537,10 +4593,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
4537
4593
  }
4538
4594
  return ids;
4539
4595
  };
4540
- _upsertRecordWithID = new WeakSet();
4541
4596
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
4542
- if (!recordId)
4543
- return null;
4597
+ if (!recordId) return null;
4544
4598
  const response = await upsertRecordWithID({
4545
4599
  pathParams: {
4546
4600
  workspace: "{workspaceId}",
@@ -4553,13 +4607,11 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
4553
4607
  body: object,
4554
4608
  ...__privateGet$2(this, _getFetchProps).call(this)
4555
4609
  });
4556
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4610
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4557
4611
  return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
4558
4612
  };
4559
- _deleteRecord = new WeakSet();
4560
4613
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
4561
- if (!recordId)
4562
- return null;
4614
+ if (!recordId) return null;
4563
4615
  try {
4564
4616
  const response = await deleteRecord({
4565
4617
  pathParams: {
@@ -4572,7 +4624,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4572
4624
  queryParams: { columns },
4573
4625
  ...__privateGet$2(this, _getFetchProps).call(this)
4574
4626
  });
4575
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4627
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4576
4628
  return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
4577
4629
  } catch (e) {
4578
4630
  if (isObject(e) && e.status === 404) {
@@ -4581,7 +4633,6 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
4581
4633
  throw e;
4582
4634
  }
4583
4635
  };
4584
- _deleteRecords = new WeakSet();
4585
4636
  deleteRecords_fn = async function(recordIds) {
4586
4637
  const chunkedOperations = chunk(
4587
4638
  compact(recordIds).map((id) => ({ delete: { table: __privateGet$2(this, _table), id } })),
@@ -4599,10 +4650,8 @@ deleteRecords_fn = async function(recordIds) {
4599
4650
  });
4600
4651
  }
4601
4652
  };
4602
- _getSchemaTables = new WeakSet();
4603
4653
  getSchemaTables_fn = async function() {
4604
- if (__privateGet$2(this, _schemaTables))
4605
- return __privateGet$2(this, _schemaTables);
4654
+ if (__privateGet$2(this, _schemaTables)) return __privateGet$2(this, _schemaTables);
4606
4655
  const { schema } = await getBranchDetails({
4607
4656
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
4608
4657
  ...__privateGet$2(this, _getFetchProps).call(this)
@@ -4610,16 +4659,13 @@ getSchemaTables_fn = async function() {
4610
4659
  __privateSet$1(this, _schemaTables, schema.tables);
4611
4660
  return schema.tables;
4612
4661
  };
4613
- _transformObjectToApi = new WeakSet();
4614
4662
  transformObjectToApi_fn = async function(object) {
4615
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4663
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4616
4664
  const schema = schemaTables.find((table) => table.name === __privateGet$2(this, _table));
4617
- if (!schema)
4618
- throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
4665
+ if (!schema) throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
4619
4666
  const result = {};
4620
4667
  for (const [key, value] of Object.entries(object)) {
4621
- if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key))
4622
- continue;
4668
+ if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key)) continue;
4623
4669
  const type = schema.columns.find((column) => column.name === key)?.type;
4624
4670
  switch (type) {
4625
4671
  case "link": {
@@ -4649,11 +4695,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4649
4695
  const data = {};
4650
4696
  Object.assign(data, { ...object });
4651
4697
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
4652
- if (!columns)
4653
- console.error(`Table ${table} not found in schema`);
4698
+ if (!columns) console.error(`Table ${table} not found in schema`);
4654
4699
  for (const column of columns ?? []) {
4655
- if (!isValidColumn(selectedColumns, column))
4656
- continue;
4700
+ if (!isValidColumn(selectedColumns, column)) continue;
4657
4701
  const value = data[column.name];
4658
4702
  switch (column.type) {
4659
4703
  case "datetime": {
@@ -4739,15 +4783,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
4739
4783
  return record;
4740
4784
  };
4741
4785
  function extractId(value) {
4742
- if (isString(value))
4743
- return value;
4744
- if (isObject(value) && isString(value.xata_id))
4745
- return value.xata_id;
4786
+ if (isString(value)) return value;
4787
+ if (isObject(value) && isString(value.xata_id)) return value.xata_id;
4746
4788
  return void 0;
4747
4789
  }
4748
4790
  function isValidColumn(columns, column) {
4749
- if (columns.includes("*"))
4750
- return true;
4791
+ if (columns.includes("*")) return true;
4751
4792
  return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
4752
4793
  }
4753
4794
  function parseIfVersion(...args) {
@@ -4787,19 +4828,12 @@ const includesAll = (value) => ({ $includesAll: value });
4787
4828
  const includesNone = (value) => ({ $includesNone: value });
4788
4829
  const includesAny = (value) => ({ $includesAny: value });
4789
4830
 
4790
- var __accessCheck$2 = (obj, member, msg) => {
4791
- if (!member.has(obj))
4792
- throw TypeError("Cannot " + msg);
4793
- };
4794
- var __privateGet$1 = (obj, member, getter) => {
4795
- __accessCheck$2(obj, member, "read from private field");
4796
- return getter ? getter.call(obj) : member.get(obj);
4797
- };
4798
- var __privateAdd$2 = (obj, member, value) => {
4799
- if (member.has(obj))
4800
- throw TypeError("Cannot add the same private member more than once");
4801
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4831
+ var __typeError$2 = (msg) => {
4832
+ throw TypeError(msg);
4802
4833
  };
4834
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
4835
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
4836
+ var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4803
4837
  var _tables;
4804
4838
  class SchemaPlugin extends XataPlugin {
4805
4839
  constructor() {
@@ -4811,8 +4845,7 @@ class SchemaPlugin extends XataPlugin {
4811
4845
  {},
4812
4846
  {
4813
4847
  get: (_target, table) => {
4814
- if (!isString(table))
4815
- throw new Error("Invalid table name");
4848
+ if (!isString(table)) throw new Error("Invalid table name");
4816
4849
  if (__privateGet$1(this, _tables)[table] === void 0) {
4817
4850
  __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
4818
4851
  }
@@ -4903,30 +4936,23 @@ function getContentType(file) {
4903
4936
  return "application/octet-stream";
4904
4937
  }
4905
4938
 
4906
- var __accessCheck$1 = (obj, member, msg) => {
4907
- if (!member.has(obj))
4908
- throw TypeError("Cannot " + msg);
4909
- };
4910
- var __privateAdd$1 = (obj, member, value) => {
4911
- if (member.has(obj))
4912
- throw TypeError("Cannot add the same private member more than once");
4913
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4914
- };
4915
- var __privateMethod$1 = (obj, member, method) => {
4916
- __accessCheck$1(obj, member, "access private method");
4917
- return method;
4939
+ var __typeError$1 = (msg) => {
4940
+ throw TypeError(msg);
4918
4941
  };
4919
- var _search, search_fn;
4942
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
4943
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4944
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
4945
+ var _SearchPlugin_instances, search_fn;
4920
4946
  class SearchPlugin extends XataPlugin {
4921
4947
  constructor(db) {
4922
4948
  super();
4923
4949
  this.db = db;
4924
- __privateAdd$1(this, _search);
4950
+ __privateAdd$1(this, _SearchPlugin_instances);
4925
4951
  }
4926
4952
  build(pluginOptions) {
4927
4953
  return {
4928
4954
  all: async (query, options = {}) => {
4929
- const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4955
+ const { records, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
4930
4956
  return {
4931
4957
  totalCount,
4932
4958
  records: records.map((record) => {
@@ -4936,7 +4962,7 @@ class SearchPlugin extends XataPlugin {
4936
4962
  };
4937
4963
  },
4938
4964
  byTable: async (query, options = {}) => {
4939
- const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
4965
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
4940
4966
  const records = rawRecords.reduce((acc, record) => {
4941
4967
  const table = record.xata_table;
4942
4968
  const items = acc[table] ?? [];
@@ -4948,7 +4974,7 @@ class SearchPlugin extends XataPlugin {
4948
4974
  };
4949
4975
  }
4950
4976
  }
4951
- _search = new WeakSet();
4977
+ _SearchPlugin_instances = new WeakSet();
4952
4978
  search_fn = async function(query, options, pluginOptions) {
4953
4979
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
4954
4980
  const { records, totalCount } = await searchBranch({
@@ -4984,8 +5010,7 @@ function arrayString(val) {
4984
5010
  return result;
4985
5011
  }
4986
5012
  function prepareValue(value) {
4987
- if (!isDefined(value))
4988
- return null;
5013
+ if (!isDefined(value)) return null;
4989
5014
  if (value instanceof Date) {
4990
5015
  return value.toISOString();
4991
5016
  }
@@ -5064,8 +5089,7 @@ function buildDomain(host, region) {
5064
5089
  function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
5065
5090
  const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
5066
5091
  const parts = parseWorkspacesUrlParts(url);
5067
- if (!parts)
5068
- throw new Error("Invalid workspaces URL");
5092
+ if (!parts) throw new Error("Invalid workspaces URL");
5069
5093
  const { workspace: workspaceSlug, region, database, host } = parts;
5070
5094
  const domain = buildDomain(host, region);
5071
5095
  const workspace = workspaceSlug.split("-").pop();
@@ -5090,39 +5114,24 @@ class TransactionPlugin extends XataPlugin {
5090
5114
  }
5091
5115
  }
5092
5116
 
5093
- var __accessCheck = (obj, member, msg) => {
5094
- if (!member.has(obj))
5095
- throw TypeError("Cannot " + msg);
5096
- };
5097
- var __privateGet = (obj, member, getter) => {
5098
- __accessCheck(obj, member, "read from private field");
5099
- return getter ? getter.call(obj) : member.get(obj);
5100
- };
5101
- var __privateAdd = (obj, member, value) => {
5102
- if (member.has(obj))
5103
- throw TypeError("Cannot add the same private member more than once");
5104
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5105
- };
5106
- var __privateSet = (obj, member, value, setter) => {
5107
- __accessCheck(obj, member, "write to private field");
5108
- setter ? setter.call(obj, value) : member.set(obj, value);
5109
- return value;
5110
- };
5111
- var __privateMethod = (obj, member, method) => {
5112
- __accessCheck(obj, member, "access private method");
5113
- return method;
5117
+ var __typeError = (msg) => {
5118
+ throw TypeError(msg);
5114
5119
  };
5120
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5121
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
5122
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5123
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
5124
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
5115
5125
  const buildClient = (plugins) => {
5116
- var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
5126
+ var _options, _instances, parseOptions_fn, getFetchProps_fn, _a;
5117
5127
  return _a = class {
5118
5128
  constructor(options = {}, tables) {
5119
- __privateAdd(this, _parseOptions);
5120
- __privateAdd(this, _getFetchProps);
5121
- __privateAdd(this, _options, void 0);
5122
- const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
5129
+ __privateAdd(this, _instances);
5130
+ __privateAdd(this, _options);
5131
+ const safeOptions = __privateMethod(this, _instances, parseOptions_fn).call(this, options);
5123
5132
  __privateSet(this, _options, safeOptions);
5124
5133
  const pluginOptions = {
5125
- ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
5134
+ ...__privateMethod(this, _instances, getFetchProps_fn).call(this, safeOptions),
5126
5135
  host: safeOptions.host,
5127
5136
  tables,
5128
5137
  branch: safeOptions.branch
@@ -5139,8 +5148,7 @@ const buildClient = (plugins) => {
5139
5148
  this.sql = sql;
5140
5149
  this.files = files;
5141
5150
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
5142
- if (namespace === void 0)
5143
- continue;
5151
+ if (namespace === void 0) continue;
5144
5152
  this[key] = namespace.build(pluginOptions);
5145
5153
  }
5146
5154
  }
@@ -5149,8 +5157,8 @@ const buildClient = (plugins) => {
5149
5157
  const branch = __privateGet(this, _options).branch;
5150
5158
  return { databaseURL, branch };
5151
5159
  }
5152
- }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
5153
- const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
5160
+ }, _options = new WeakMap(), _instances = new WeakSet(), parseOptions_fn = function(options) {
5161
+ const enableBrowser = options?.enableBrowser ?? false;
5154
5162
  const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
5155
5163
  if (isBrowser && !enableBrowser) {
5156
5164
  throw new Error(
@@ -5158,8 +5166,9 @@ const buildClient = (plugins) => {
5158
5166
  );
5159
5167
  }
5160
5168
  const fetch = getFetchImplementation(options?.fetch);
5161
- const databaseURL = options?.databaseURL || getDatabaseURL();
5162
- const apiKey = options?.apiKey || getAPIKey();
5169
+ const databaseURL = options?.databaseURL;
5170
+ const apiKey = options?.apiKey;
5171
+ const branch = options?.branch;
5163
5172
  const trace = options?.trace ?? defaultTrace;
5164
5173
  const clientName = options?.clientName;
5165
5174
  const host = options?.host ?? "production";
@@ -5170,25 +5179,8 @@ const buildClient = (plugins) => {
5170
5179
  if (!databaseURL) {
5171
5180
  throw new Error("Option databaseURL is required");
5172
5181
  }
5173
- const envBranch = getBranch();
5174
- const previewBranch = getPreviewBranch();
5175
- const branch = options?.branch || previewBranch || envBranch || "main";
5176
- if (!!previewBranch && branch !== previewBranch) {
5177
- console.warn(
5178
- `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
5179
- );
5180
- } else if (!!envBranch && branch !== envBranch) {
5181
- console.warn(
5182
- `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
5183
- );
5184
- } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
5185
- console.warn(
5186
- `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
5187
- );
5188
- } else if (!previewBranch && !envBranch && options?.branch === void 0) {
5189
- console.warn(
5190
- `No branch was passed to the client constructor. Using default branch ${branch}. You can set the branch with the environment variable XATA_BRANCH or by passing the branch option to the client constructor.`
5191
- );
5182
+ if (!branch) {
5183
+ throw new Error("Option branch is required");
5192
5184
  }
5193
5185
  return {
5194
5186
  fetch,
@@ -5202,7 +5194,7 @@ const buildClient = (plugins) => {
5202
5194
  clientName,
5203
5195
  xataAgentExtra
5204
5196
  };
5205
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
5197
+ }, getFetchProps_fn = function({
5206
5198
  fetch,
5207
5199
  apiKey,
5208
5200
  databaseURL,
@@ -5243,26 +5235,19 @@ class Serializer {
5243
5235
  }
5244
5236
  toJSON(data) {
5245
5237
  function visit(obj) {
5246
- if (Array.isArray(obj))
5247
- return obj.map(visit);
5238
+ if (Array.isArray(obj)) return obj.map(visit);
5248
5239
  const type = typeof obj;
5249
- if (type === "undefined")
5250
- return { [META]: "undefined" };
5251
- if (type === "bigint")
5252
- return { [META]: "bigint", [VALUE]: obj.toString() };
5253
- if (obj === null || type !== "object")
5254
- return obj;
5240
+ if (type === "undefined") return { [META]: "undefined" };
5241
+ if (type === "bigint") return { [META]: "bigint", [VALUE]: obj.toString() };
5242
+ if (obj === null || type !== "object") return obj;
5255
5243
  const constructor = obj.constructor;
5256
5244
  const o = { [META]: constructor.name };
5257
5245
  for (const [key, value] of Object.entries(obj)) {
5258
5246
  o[key] = visit(value);
5259
5247
  }
5260
- if (constructor === Date)
5261
- o[VALUE] = obj.toISOString();
5262
- if (constructor === Map)
5263
- o[VALUE] = Object.fromEntries(obj);
5264
- if (constructor === Set)
5265
- o[VALUE] = [...obj];
5248
+ if (constructor === Date) o[VALUE] = obj.toISOString();
5249
+ if (constructor === Map) o[VALUE] = Object.fromEntries(obj);
5250
+ if (constructor === Set) o[VALUE] = [...obj];
5266
5251
  return o;
5267
5252
  }
5268
5253
  return JSON.stringify(visit(data));
@@ -5275,16 +5260,11 @@ class Serializer {
5275
5260
  if (constructor) {
5276
5261
  return Object.assign(Object.create(constructor.prototype), rest);
5277
5262
  }
5278
- if (clazz === "Date")
5279
- return new Date(val);
5280
- if (clazz === "Set")
5281
- return new Set(val);
5282
- if (clazz === "Map")
5283
- return new Map(Object.entries(val));
5284
- if (clazz === "bigint")
5285
- return BigInt(val);
5286
- if (clazz === "undefined")
5287
- return void 0;
5263
+ if (clazz === "Date") return new Date(val);
5264
+ if (clazz === "Set") return new Set(val);
5265
+ if (clazz === "Map") return new Map(Object.entries(val));
5266
+ if (clazz === "bigint") return BigInt(val);
5267
+ if (clazz === "undefined") return void 0;
5288
5268
  return rest;
5289
5269
  }
5290
5270
  return value;
@@ -5299,6 +5279,47 @@ const deserialize = (json) => {
5299
5279
  return defaultSerializer.fromJSON(json);
5300
5280
  };
5301
5281
 
5282
+ function parseEnvironment(environment) {
5283
+ try {
5284
+ if (typeof environment === "function") {
5285
+ return new Proxy(
5286
+ {},
5287
+ {
5288
+ get(target) {
5289
+ return environment(target);
5290
+ }
5291
+ }
5292
+ );
5293
+ }
5294
+ if (isObject(environment)) {
5295
+ return environment;
5296
+ }
5297
+ } catch (error) {
5298
+ }
5299
+ return {};
5300
+ }
5301
+ function buildPreviewBranchName({ org, branch }) {
5302
+ return `preview-${org}-${branch}`;
5303
+ }
5304
+ function getDeployPreviewBranch(environment) {
5305
+ try {
5306
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = parseEnvironment(environment);
5307
+ if (deployPreviewBranch) return deployPreviewBranch;
5308
+ switch (deployPreview) {
5309
+ case "vercel": {
5310
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
5311
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
5312
+ return void 0;
5313
+ }
5314
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
5315
+ }
5316
+ }
5317
+ return void 0;
5318
+ } catch (err) {
5319
+ return void 0;
5320
+ }
5321
+ }
5322
+
5302
5323
  class XataError extends Error {
5303
5324
  constructor(message, status) {
5304
5325
  super(message);
@@ -5306,5 +5327,5 @@ class XataError extends Error {
5306
5327
  }
5307
5328
  }
5308
5329
 
5309
- export { BaseClient, Buffer, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, PageRecordArray, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, adaptAllTables, adaptTable, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAPIKey, getAuthorizationCode, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationJobStatus, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseSettings, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationHistory, getMigrationJobStatus, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspaceSettings, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateDatabaseSettings, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, updateWorkspaceSettings, upsertRecordWithID, vectorSearchTable };
5330
+ export { BaseClient, Buffer, FetcherError, FilesPlugin, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, PageRecordArray, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SQLPlugin, SchemaPlugin, SearchPlugin, Serializer, TransactionPlugin, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, adaptAllTables, adaptTable, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, applyMigration, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createCluster, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteCluster, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteOAuthAccessToken, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteUserOAuthClient, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, fileUpload, ge, getAuthorizationCode, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationJobStatus, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getCluster, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseSettings, getDeployPreviewBranch, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationHistory, getMigrationJobStatus, getMigrationRequest, getMigrationRequestIsMerged, getRecord, getSchema, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getUserOAuthAccessTokens, getUserOAuthClients, getWorkspace, getWorkspaceMembersList, getWorkspaceSettings, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, iContains, iPattern, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isValidExpandedColumn, isValidSelectableColumns, le, lessEquals, lessThan, lessThanEquals, listClusters, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startMigration, startsWith, summarizeTable, transformImage, updateBranchMetadata, updateBranchSchema, updateCluster, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateDatabaseSettings, updateMigrationRequest, updateOAuthAccessToken, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, updateWorkspaceSettings, upsertRecordWithID, vectorSearchTable };
5310
5331
  //# sourceMappingURL=index.mjs.map