@xata.io/client 0.0.0-alpha.vf229a69778d4166c9021b4cec87cfce2b38e6bbf → 0.0.0-alpha.vf22cd1268cc516ac7867c22d558b9480f18e2df1

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.cjs CHANGED
@@ -39,8 +39,7 @@ function getLens(b64) {
39
39
  throw new Error("Invalid string. Length must be a multiple of 4");
40
40
  }
41
41
  let validLen = b64.indexOf("=");
42
- if (validLen === -1)
43
- validLen = len;
42
+ if (validLen === -1) validLen = len;
44
43
  const placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
45
44
  return [validLen, placeHoldersLen];
46
45
  }
@@ -375,10 +374,8 @@ class Buffer extends Uint8Array {
375
374
  break;
376
375
  }
377
376
  }
378
- if (x < y)
379
- return -1;
380
- if (y < x)
381
- return 1;
377
+ if (x < y) return -1;
378
+ if (y < x) return 1;
382
379
  return 0;
383
380
  }
384
381
  /**
@@ -391,33 +388,21 @@ class Buffer extends Uint8Array {
391
388
  * @param sourceEnd The offset within this buffer at which to end copying (exclusive).
392
389
  */
393
390
  copy(targetBuffer, targetStart, sourceStart, sourceEnd) {
394
- if (!Buffer.isBuffer(targetBuffer))
395
- throw new TypeError("argument should be a Buffer");
396
- if (!sourceStart)
397
- sourceStart = 0;
398
- if (!targetStart)
399
- targetStart = 0;
400
- if (!sourceEnd && sourceEnd !== 0)
401
- sourceEnd = this.length;
402
- if (targetStart >= targetBuffer.length)
403
- targetStart = targetBuffer.length;
404
- if (!targetStart)
405
- targetStart = 0;
406
- if (sourceEnd > 0 && sourceEnd < sourceStart)
407
- sourceEnd = sourceStart;
408
- if (sourceEnd === sourceStart)
409
- return 0;
410
- if (targetBuffer.length === 0 || this.length === 0)
411
- return 0;
391
+ if (!Buffer.isBuffer(targetBuffer)) throw new TypeError("argument should be a Buffer");
392
+ if (!sourceStart) sourceStart = 0;
393
+ if (!targetStart) targetStart = 0;
394
+ if (!sourceEnd && sourceEnd !== 0) sourceEnd = this.length;
395
+ if (targetStart >= targetBuffer.length) targetStart = targetBuffer.length;
396
+ if (!targetStart) targetStart = 0;
397
+ if (sourceEnd > 0 && sourceEnd < sourceStart) sourceEnd = sourceStart;
398
+ if (sourceEnd === sourceStart) return 0;
399
+ if (targetBuffer.length === 0 || this.length === 0) return 0;
412
400
  if (targetStart < 0) {
413
401
  throw new RangeError("targetStart out of bounds");
414
402
  }
415
- if (sourceStart < 0 || sourceStart >= this.length)
416
- throw new RangeError("Index out of range");
417
- if (sourceEnd < 0)
418
- throw new RangeError("sourceEnd out of bounds");
419
- if (sourceEnd > this.length)
420
- sourceEnd = this.length;
403
+ if (sourceStart < 0 || sourceStart >= this.length) throw new RangeError("Index out of range");
404
+ if (sourceEnd < 0) throw new RangeError("sourceEnd out of bounds");
405
+ if (sourceEnd > this.length) sourceEnd = this.length;
421
406
  if (targetBuffer.length - targetStart < sourceEnd - sourceStart) {
422
407
  sourceEnd = targetBuffer.length - targetStart + sourceStart;
423
408
  }
@@ -1578,8 +1563,7 @@ class Buffer extends Uint8Array {
1578
1563
  let c, hi, lo;
1579
1564
  const byteArray = [];
1580
1565
  for (let i = 0; i < str.length; ++i) {
1581
- if ((units -= 2) < 0)
1582
- break;
1566
+ if ((units -= 2) < 0) break;
1583
1567
  c = str.charCodeAt(i);
1584
1568
  hi = c >> 8;
1585
1569
  lo = c % 256;
@@ -1733,13 +1717,10 @@ class Buffer extends Uint8Array {
1733
1717
  let foundIndex = -1;
1734
1718
  for (i = byteOffset; i < arrLength; i++) {
1735
1719
  if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1736
- if (foundIndex === -1)
1737
- foundIndex = i;
1738
- if (i - foundIndex + 1 === valLength)
1739
- return foundIndex * indexSize;
1720
+ if (foundIndex === -1) foundIndex = i;
1721
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
1740
1722
  } else {
1741
- if (foundIndex !== -1)
1742
- i -= i - foundIndex;
1723
+ if (foundIndex !== -1) i -= i - foundIndex;
1743
1724
  foundIndex = -1;
1744
1725
  }
1745
1726
  }
@@ -1763,18 +1744,13 @@ class Buffer extends Uint8Array {
1763
1744
  return -1;
1764
1745
  }
1765
1746
  static _checkOffset(offset, ext, length) {
1766
- if (offset % 1 !== 0 || offset < 0)
1767
- throw new RangeError("offset is not uint");
1768
- if (offset + ext > length)
1769
- throw new RangeError("Trying to access beyond buffer length");
1747
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1748
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1770
1749
  }
1771
1750
  static _checkInt(buf, value, offset, ext, max, min) {
1772
- if (!Buffer.isBuffer(buf))
1773
- throw new TypeError('"buffer" argument must be a Buffer instance');
1774
- if (value > max || value < min)
1775
- throw new RangeError('"value" argument is out of bounds');
1776
- if (offset + ext > buf.length)
1777
- throw new RangeError("Index out of range");
1751
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1752
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
1753
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1778
1754
  }
1779
1755
  static _getEncoding(encoding) {
1780
1756
  let toLowerCase = false;
@@ -1824,8 +1800,7 @@ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1824
1800
  function base64clean(str) {
1825
1801
  str = str.split("=")[0];
1826
1802
  str = str.trim().replace(INVALID_BASE64_RE, "");
1827
- if (str.length < 2)
1828
- return "";
1803
+ if (str.length < 2) return "";
1829
1804
  while (str.length % 4 !== 0) {
1830
1805
  str = str + "=";
1831
1806
  }
@@ -1926,155 +1901,15 @@ function promiseMap(inputValues, mapper) {
1926
1901
  return inputValues.reduce(reducer, Promise.resolve([]));
1927
1902
  }
1928
1903
 
1929
- function getEnvironment() {
1930
- try {
1931
- if (isDefined(process) && isDefined(process.env)) {
1932
- return {
1933
- apiKey: process.env.XATA_API_KEY ?? getGlobalApiKey(),
1934
- databaseURL: process.env.XATA_DATABASE_URL ?? getGlobalDatabaseURL(),
1935
- branch: process.env.XATA_BRANCH ?? getGlobalBranch(),
1936
- deployPreview: process.env.XATA_PREVIEW,
1937
- deployPreviewBranch: process.env.XATA_PREVIEW_BRANCH,
1938
- vercelGitCommitRef: process.env.VERCEL_GIT_COMMIT_REF,
1939
- vercelGitRepoOwner: process.env.VERCEL_GIT_REPO_OWNER
1940
- };
1941
- }
1942
- } catch (err) {
1943
- }
1944
- try {
1945
- if (isObject(Deno) && isObject(Deno.env)) {
1946
- return {
1947
- apiKey: Deno.env.get("XATA_API_KEY") ?? getGlobalApiKey(),
1948
- databaseURL: Deno.env.get("XATA_DATABASE_URL") ?? getGlobalDatabaseURL(),
1949
- branch: Deno.env.get("XATA_BRANCH") ?? getGlobalBranch(),
1950
- deployPreview: Deno.env.get("XATA_PREVIEW"),
1951
- deployPreviewBranch: Deno.env.get("XATA_PREVIEW_BRANCH"),
1952
- vercelGitCommitRef: Deno.env.get("VERCEL_GIT_COMMIT_REF"),
1953
- vercelGitRepoOwner: Deno.env.get("VERCEL_GIT_REPO_OWNER")
1954
- };
1955
- }
1956
- } catch (err) {
1957
- }
1958
- return {
1959
- apiKey: getGlobalApiKey(),
1960
- databaseURL: getGlobalDatabaseURL(),
1961
- branch: getGlobalBranch(),
1962
- deployPreview: void 0,
1963
- deployPreviewBranch: void 0,
1964
- vercelGitCommitRef: void 0,
1965
- vercelGitRepoOwner: void 0
1966
- };
1967
- }
1968
- function getEnableBrowserVariable() {
1969
- try {
1970
- if (isObject(process) && isObject(process.env) && process.env.XATA_ENABLE_BROWSER !== void 0) {
1971
- return process.env.XATA_ENABLE_BROWSER === "true";
1972
- }
1973
- } catch (err) {
1974
- }
1975
- try {
1976
- if (isObject(Deno) && isObject(Deno.env) && Deno.env.get("XATA_ENABLE_BROWSER") !== void 0) {
1977
- return Deno.env.get("XATA_ENABLE_BROWSER") === "true";
1978
- }
1979
- } catch (err) {
1980
- }
1981
- try {
1982
- return XATA_ENABLE_BROWSER === true || XATA_ENABLE_BROWSER === "true";
1983
- } catch (err) {
1984
- return void 0;
1985
- }
1986
- }
1987
- function getGlobalApiKey() {
1988
- try {
1989
- return XATA_API_KEY;
1990
- } catch (err) {
1991
- return void 0;
1992
- }
1993
- }
1994
- function getGlobalDatabaseURL() {
1995
- try {
1996
- return XATA_DATABASE_URL;
1997
- } catch (err) {
1998
- return void 0;
1999
- }
2000
- }
2001
- function getGlobalBranch() {
2002
- try {
2003
- return XATA_BRANCH;
2004
- } catch (err) {
2005
- return void 0;
2006
- }
2007
- }
2008
- function getDatabaseURL() {
2009
- try {
2010
- const { databaseURL } = getEnvironment();
2011
- return databaseURL;
2012
- } catch (err) {
2013
- return void 0;
2014
- }
2015
- }
2016
- function getAPIKey() {
2017
- try {
2018
- const { apiKey } = getEnvironment();
2019
- return apiKey;
2020
- } catch (err) {
2021
- return void 0;
2022
- }
2023
- }
2024
- function getBranch() {
2025
- try {
2026
- const { branch } = getEnvironment();
2027
- return branch;
2028
- } catch (err) {
2029
- return void 0;
2030
- }
2031
- }
2032
- function buildPreviewBranchName({ org, branch }) {
2033
- return `preview-${org}-${branch}`;
2034
- }
2035
- function getPreviewBranch() {
2036
- try {
2037
- const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = getEnvironment();
2038
- if (deployPreviewBranch)
2039
- return deployPreviewBranch;
2040
- switch (deployPreview) {
2041
- case "vercel": {
2042
- if (!vercelGitCommitRef || !vercelGitRepoOwner) {
2043
- console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
2044
- return void 0;
2045
- }
2046
- return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
2047
- }
2048
- }
2049
- return void 0;
2050
- } catch (err) {
2051
- return void 0;
2052
- }
2053
- }
2054
-
2055
- var __accessCheck$8 = (obj, member, msg) => {
2056
- if (!member.has(obj))
2057
- throw TypeError("Cannot " + msg);
2058
- };
2059
- var __privateGet$7 = (obj, member, getter) => {
2060
- __accessCheck$8(obj, member, "read from private field");
2061
- return getter ? getter.call(obj) : member.get(obj);
2062
- };
2063
- var __privateAdd$8 = (obj, member, value) => {
2064
- if (member.has(obj))
2065
- throw TypeError("Cannot add the same private member more than once");
2066
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1904
+ var __typeError$6 = (msg) => {
1905
+ throw TypeError(msg);
2067
1906
  };
2068
- var __privateSet$6 = (obj, member, value, setter) => {
2069
- __accessCheck$8(obj, member, "write to private field");
2070
- setter ? setter.call(obj, value) : member.set(obj, value);
2071
- return value;
2072
- };
2073
- var __privateMethod$4 = (obj, member, method) => {
2074
- __accessCheck$8(obj, member, "access private method");
2075
- return method;
2076
- };
2077
- var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
1907
+ var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
1908
+ var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1909
+ 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);
1910
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
1911
+ var __privateMethod$4 = (obj, member, method) => (__accessCheck$6(obj, member, "access private method"), method);
1912
+ var _fetch, _queue, _concurrency, _ApiRequestPool_instances, enqueue_fn;
2078
1913
  const REQUEST_TIMEOUT = 5 * 60 * 1e3;
2079
1914
  function getFetchImplementation(userFetch) {
2080
1915
  const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
@@ -2087,23 +1922,23 @@ function getFetchImplementation(userFetch) {
2087
1922
  }
2088
1923
  class ApiRequestPool {
2089
1924
  constructor(concurrency = 10) {
2090
- __privateAdd$8(this, _enqueue);
2091
- __privateAdd$8(this, _fetch, void 0);
2092
- __privateAdd$8(this, _queue, void 0);
2093
- __privateAdd$8(this, _concurrency, void 0);
2094
- __privateSet$6(this, _queue, []);
2095
- __privateSet$6(this, _concurrency, concurrency);
1925
+ __privateAdd$6(this, _ApiRequestPool_instances);
1926
+ __privateAdd$6(this, _fetch);
1927
+ __privateAdd$6(this, _queue);
1928
+ __privateAdd$6(this, _concurrency);
1929
+ __privateSet$4(this, _queue, []);
1930
+ __privateSet$4(this, _concurrency, concurrency);
2096
1931
  this.running = 0;
2097
1932
  this.started = 0;
2098
1933
  }
2099
1934
  setFetch(fetch2) {
2100
- __privateSet$6(this, _fetch, fetch2);
1935
+ __privateSet$4(this, _fetch, fetch2);
2101
1936
  }
2102
1937
  getFetch() {
2103
- if (!__privateGet$7(this, _fetch)) {
1938
+ if (!__privateGet$5(this, _fetch)) {
2104
1939
  throw new Error("Fetch not set");
2105
1940
  }
2106
- return __privateGet$7(this, _fetch);
1941
+ return __privateGet$5(this, _fetch);
2107
1942
  }
2108
1943
  request(url, options) {
2109
1944
  const start = /* @__PURE__ */ new Date();
@@ -2125,7 +1960,7 @@ class ApiRequestPool {
2125
1960
  }
2126
1961
  return response;
2127
1962
  };
2128
- return __privateMethod$4(this, _enqueue, enqueue_fn).call(this, async () => {
1963
+ return __privateMethod$4(this, _ApiRequestPool_instances, enqueue_fn).call(this, async () => {
2129
1964
  return await runRequest();
2130
1965
  });
2131
1966
  }
@@ -2133,21 +1968,21 @@ class ApiRequestPool {
2133
1968
  _fetch = new WeakMap();
2134
1969
  _queue = new WeakMap();
2135
1970
  _concurrency = new WeakMap();
2136
- _enqueue = new WeakSet();
1971
+ _ApiRequestPool_instances = new WeakSet();
2137
1972
  enqueue_fn = function(task) {
2138
- const promise = new Promise((resolve) => __privateGet$7(this, _queue).push(resolve)).finally(() => {
1973
+ const promise = new Promise((resolve) => __privateGet$5(this, _queue).push(resolve)).finally(() => {
2139
1974
  this.started--;
2140
1975
  this.running++;
2141
1976
  }).then(() => task()).finally(() => {
2142
1977
  this.running--;
2143
- const next = __privateGet$7(this, _queue).shift();
1978
+ const next = __privateGet$5(this, _queue).shift();
2144
1979
  if (next !== void 0) {
2145
1980
  this.started++;
2146
1981
  next();
2147
1982
  }
2148
1983
  });
2149
- if (this.running + this.started < __privateGet$7(this, _concurrency)) {
2150
- const next = __privateGet$7(this, _queue).shift();
1984
+ if (this.running + this.started < __privateGet$5(this, _concurrency)) {
1985
+ const next = __privateGet$5(this, _queue).shift();
2151
1986
  if (next !== void 0) {
2152
1987
  this.started++;
2153
1988
  next();
@@ -2336,7 +2171,7 @@ function defaultOnOpen(response) {
2336
2171
  }
2337
2172
  }
2338
2173
 
2339
- const VERSION = "0.29.3";
2174
+ const VERSION = "0.30.0";
2340
2175
 
2341
2176
  class ErrorWithCause extends Error {
2342
2177
  constructor(message, options) {
@@ -2416,18 +2251,15 @@ function parseProviderString(provider = "production") {
2416
2251
  return provider;
2417
2252
  }
2418
2253
  const [main, workspaces] = provider.split(",");
2419
- if (!main || !workspaces)
2420
- return null;
2254
+ if (!main || !workspaces) return null;
2421
2255
  return { main, workspaces };
2422
2256
  }
2423
2257
  function buildProviderString(provider) {
2424
- if (isHostProviderAlias(provider))
2425
- return provider;
2258
+ if (isHostProviderAlias(provider)) return provider;
2426
2259
  return `${provider.main},${provider.workspaces}`;
2427
2260
  }
2428
2261
  function parseWorkspacesUrlParts(url) {
2429
- if (!isString(url))
2430
- return null;
2262
+ if (!isString(url)) return null;
2431
2263
  const matches = {
2432
2264
  production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh\/db\/([^:]+):?(.*)?/),
2433
2265
  staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev\/db\/([^:]+):?(.*)?/),
@@ -2435,16 +2267,14 @@ function parseWorkspacesUrlParts(url) {
2435
2267
  local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(?:\d+)\/db\/([^:]+):?(.*)?/)
2436
2268
  };
2437
2269
  const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
2438
- if (!isHostProviderAlias(host) || !match)
2439
- return null;
2270
+ if (!isHostProviderAlias(host) || !match) return null;
2440
2271
  return { workspace: match[1], region: match[2], database: match[3], branch: match[4], host };
2441
2272
  }
2442
2273
 
2443
2274
  const pool = new ApiRequestPool();
2444
2275
  const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
2445
2276
  const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
2446
- if (value === void 0 || value === null)
2447
- return acc;
2277
+ if (value === void 0 || value === null) return acc;
2448
2278
  return { ...acc, [key]: value };
2449
2279
  }, {});
2450
2280
  const query = new URLSearchParams(cleanQueryParams).toString();
@@ -2492,8 +2322,7 @@ function hostHeader(url) {
2492
2322
  return groups?.host ? { Host: groups.host } : {};
2493
2323
  }
2494
2324
  async function parseBody(body, headers) {
2495
- if (!isDefined(body))
2496
- return void 0;
2325
+ if (!isDefined(body)) return void 0;
2497
2326
  if (isBlob(body) || typeof body.text === "function") {
2498
2327
  return body;
2499
2328
  }
@@ -2548,6 +2377,8 @@ async function fetch$1({
2548
2377
  "X-Xata-Client-ID": clientID ?? defaultClientID,
2549
2378
  "X-Xata-Session-ID": sessionID ?? generateUUID(),
2550
2379
  "X-Xata-Agent": xataAgent,
2380
+ // Force field rename to xata_ internal properties
2381
+ "X-Features": compact(["feat-internal-field-rename-api=1", customHeaders?.["X-Features"]]).join(" "),
2551
2382
  ...customHeaders,
2552
2383
  ...hostHeader(fullUrl),
2553
2384
  Authorization: `Bearer ${apiKey}`
@@ -2570,8 +2401,7 @@ async function fetch$1({
2570
2401
  [TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
2571
2402
  });
2572
2403
  const message = response.headers?.get("x-xata-message");
2573
- if (message)
2574
- console.warn(message);
2404
+ if (message) console.warn(message);
2575
2405
  if (response.status === 204) {
2576
2406
  return {};
2577
2407
  }
@@ -2655,7 +2485,72 @@ function parseUrl(url) {
2655
2485
 
2656
2486
  const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
2657
2487
 
2658
- const applyMigration = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/migrations/apply", method: "post", ...variables, signal });
2488
+ const getTasks = (variables, signal) => dataPlaneFetch({
2489
+ url: "/tasks",
2490
+ method: "get",
2491
+ ...variables,
2492
+ signal
2493
+ });
2494
+ const getTaskStatus = (variables, signal) => dataPlaneFetch({
2495
+ url: "/tasks/{taskId}",
2496
+ method: "get",
2497
+ ...variables,
2498
+ signal
2499
+ });
2500
+ const listClusterBranches = (variables, signal) => dataPlaneFetch({
2501
+ url: "/cluster/{clusterId}/branches",
2502
+ method: "get",
2503
+ ...variables,
2504
+ signal
2505
+ });
2506
+ const listClusterExtensions = (variables, signal) => dataPlaneFetch({
2507
+ url: "/cluster/{clusterId}/extensions",
2508
+ method: "get",
2509
+ ...variables,
2510
+ signal
2511
+ });
2512
+ const installClusterExtension = (variables, signal) => dataPlaneFetch({
2513
+ url: "/cluster/{clusterId}/extensions",
2514
+ method: "post",
2515
+ ...variables,
2516
+ signal
2517
+ });
2518
+ const dropClusterExtension = (variables, signal) => dataPlaneFetch({
2519
+ url: "/cluster/{clusterId}/extensions",
2520
+ method: "delete",
2521
+ ...variables,
2522
+ signal
2523
+ });
2524
+ const getClusterMetrics = (variables, signal) => dataPlaneFetch({
2525
+ url: "/cluster/{clusterId}/metrics",
2526
+ method: "get",
2527
+ ...variables,
2528
+ signal
2529
+ });
2530
+ const applyMigration = (variables, signal) => dataPlaneFetch({
2531
+ url: "/db/{dbBranchName}/migrations/apply",
2532
+ method: "post",
2533
+ ...variables,
2534
+ signal
2535
+ });
2536
+ const startMigration = (variables, signal) => dataPlaneFetch({
2537
+ url: "/db/{dbBranchName}/migrations/start",
2538
+ method: "post",
2539
+ ...variables,
2540
+ signal
2541
+ });
2542
+ const completeMigration = (variables, signal) => dataPlaneFetch({
2543
+ url: "/db/{dbBranchName}/migrations/complete",
2544
+ method: "post",
2545
+ ...variables,
2546
+ signal
2547
+ });
2548
+ const rollbackMigration = (variables, signal) => dataPlaneFetch({
2549
+ url: "/db/{dbBranchName}/migrations/rollback",
2550
+ method: "post",
2551
+ ...variables,
2552
+ signal
2553
+ });
2659
2554
  const adaptTable = (variables, signal) => dataPlaneFetch({
2660
2555
  url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
2661
2556
  method: "post",
@@ -2668,9 +2563,30 @@ const adaptAllTables = (variables, signal) => dataPlaneFetch({
2668
2563
  ...variables,
2669
2564
  signal
2670
2565
  });
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 });
2566
+ const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({
2567
+ url: "/db/{dbBranchName}/migrations/status",
2568
+ method: "get",
2569
+ ...variables,
2570
+ signal
2571
+ });
2572
+ const getMigrationJobs = (variables, signal) => dataPlaneFetch({
2573
+ url: "/db/{dbBranchName}/migrations/jobs",
2574
+ method: "get",
2575
+ ...variables,
2576
+ signal
2577
+ });
2578
+ const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({
2579
+ url: "/db/{dbBranchName}/migrations/jobs/{jobId}",
2580
+ method: "get",
2581
+ ...variables,
2582
+ signal
2583
+ });
2584
+ const getMigrationHistory = (variables, signal) => dataPlaneFetch({
2585
+ url: "/db/{dbBranchName}/migrations/history",
2586
+ method: "get",
2587
+ ...variables,
2588
+ signal
2589
+ });
2674
2590
  const getBranchList = (variables, signal) => dataPlaneFetch({
2675
2591
  url: "/dbs/{dbName}",
2676
2592
  method: "get",
@@ -2684,6 +2600,7 @@ const getDatabaseSettings = (variables, signal) => dataPlaneFetch({
2684
2600
  signal
2685
2601
  });
2686
2602
  const updateDatabaseSettings = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/settings", method: "patch", ...variables, signal });
2603
+ const createBranchAsync = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/async", method: "put", ...variables, signal });
2687
2604
  const getBranchDetails = (variables, signal) => dataPlaneFetch({
2688
2605
  url: "/db/{dbBranchName}",
2689
2606
  method: "get",
@@ -2703,12 +2620,25 @@ const getSchema = (variables, signal) => dataPlaneFetch({
2703
2620
  ...variables,
2704
2621
  signal
2705
2622
  });
2623
+ const getSchemas = (variables, signal) => dataPlaneFetch({
2624
+ url: "/db/{dbBranchName}/schemas",
2625
+ method: "get",
2626
+ ...variables,
2627
+ signal
2628
+ });
2706
2629
  const copyBranch = (variables, signal) => dataPlaneFetch({
2707
2630
  url: "/db/{dbBranchName}/copy",
2708
2631
  method: "post",
2709
2632
  ...variables,
2710
2633
  signal
2711
2634
  });
2635
+ const getBranchMoveStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/move", method: "get", ...variables, signal });
2636
+ const moveBranch = (variables, signal) => dataPlaneFetch({
2637
+ url: "/db/{dbBranchName}/move",
2638
+ method: "put",
2639
+ ...variables,
2640
+ signal
2641
+ });
2712
2642
  const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
2713
2643
  url: "/db/{dbBranchName}/metadata",
2714
2644
  method: "put",
@@ -2729,12 +2659,42 @@ const getBranchStats = (variables, signal) => dataPlaneFetch({
2729
2659
  });
2730
2660
  const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
2731
2661
  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 });
2662
+ const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({
2663
+ url: "/dbs/{dbName}/gitBranches",
2664
+ method: "delete",
2665
+ ...variables,
2666
+ signal
2667
+ });
2668
+ const resolveBranch = (variables, signal) => dataPlaneFetch({
2669
+ url: "/dbs/{dbName}/resolveBranch",
2670
+ method: "get",
2671
+ ...variables,
2672
+ signal
2673
+ });
2674
+ const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({
2675
+ url: "/db/{dbBranchName}/migrations",
2676
+ method: "get",
2677
+ ...variables,
2678
+ signal
2679
+ });
2680
+ const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
2681
+ url: "/db/{dbBranchName}/migrations/plan",
2682
+ method: "post",
2683
+ ...variables,
2684
+ signal
2685
+ });
2686
+ const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
2687
+ url: "/db/{dbBranchName}/migrations/execute",
2688
+ method: "post",
2689
+ ...variables,
2690
+ signal
2691
+ });
2692
+ const queryMigrationRequests = (variables, signal) => dataPlaneFetch({
2693
+ url: "/dbs/{dbName}/migrations/query",
2694
+ method: "post",
2695
+ ...variables,
2696
+ signal
2697
+ });
2738
2698
  const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
2739
2699
  const getMigrationRequest = (variables, signal) => dataPlaneFetch({
2740
2700
  url: "/dbs/{dbName}/migrations/{mrNumber}",
@@ -2742,23 +2702,78 @@ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
2742
2702
  ...variables,
2743
2703
  signal
2744
2704
  });
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 });
2705
+ const updateMigrationRequest = (variables, signal) => dataPlaneFetch({
2706
+ url: "/dbs/{dbName}/migrations/{mrNumber}",
2707
+ method: "patch",
2708
+ ...variables,
2709
+ signal
2710
+ });
2711
+ const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({
2712
+ url: "/dbs/{dbName}/migrations/{mrNumber}/commits",
2713
+ method: "post",
2714
+ ...variables,
2715
+ signal
2716
+ });
2717
+ const compareMigrationRequest = (variables, signal) => dataPlaneFetch({
2718
+ url: "/dbs/{dbName}/migrations/{mrNumber}/compare",
2719
+ method: "post",
2720
+ ...variables,
2721
+ signal
2722
+ });
2723
+ const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({
2724
+ url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
2725
+ method: "get",
2726
+ ...variables,
2727
+ signal
2728
+ });
2749
2729
  const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
2750
2730
  url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
2751
2731
  method: "post",
2752
2732
  ...variables,
2753
2733
  signal
2754
2734
  });
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 });
2735
+ const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({
2736
+ url: "/db/{dbBranchName}/schema/history",
2737
+ method: "post",
2738
+ ...variables,
2739
+ signal
2740
+ });
2741
+ const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({
2742
+ url: "/db/{dbBranchName}/schema/compare",
2743
+ method: "post",
2744
+ ...variables,
2745
+ signal
2746
+ });
2747
+ const compareBranchSchemas = (variables, signal) => dataPlaneFetch({
2748
+ url: "/db/{dbBranchName}/schema/compare/{branchName}",
2749
+ method: "post",
2750
+ ...variables,
2751
+ signal
2752
+ });
2753
+ const updateBranchSchema = (variables, signal) => dataPlaneFetch({
2754
+ url: "/db/{dbBranchName}/schema/update",
2755
+ method: "post",
2756
+ ...variables,
2757
+ signal
2758
+ });
2759
+ const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
2760
+ url: "/db/{dbBranchName}/schema/preview",
2761
+ method: "post",
2762
+ ...variables,
2763
+ signal
2764
+ });
2765
+ const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
2766
+ url: "/db/{dbBranchName}/schema/apply",
2767
+ method: "post",
2768
+ ...variables,
2769
+ signal
2770
+ });
2771
+ const pushBranchMigrations = (variables, signal) => dataPlaneFetch({
2772
+ url: "/db/{dbBranchName}/schema/push",
2773
+ method: "post",
2774
+ ...variables,
2775
+ signal
2776
+ });
2762
2777
  const createTable = (variables, signal) => dataPlaneFetch({
2763
2778
  url: "/db/{dbBranchName}/tables/{tableName}",
2764
2779
  method: "put",
@@ -2771,14 +2786,24 @@ const deleteTable = (variables, signal) => dataPlaneFetch({
2771
2786
  ...variables,
2772
2787
  signal
2773
2788
  });
2774
- const updateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}", method: "patch", ...variables, signal });
2789
+ const updateTable = (variables, signal) => dataPlaneFetch({
2790
+ url: "/db/{dbBranchName}/tables/{tableName}",
2791
+ method: "patch",
2792
+ ...variables,
2793
+ signal
2794
+ });
2775
2795
  const getTableSchema = (variables, signal) => dataPlaneFetch({
2776
2796
  url: "/db/{dbBranchName}/tables/{tableName}/schema",
2777
2797
  method: "get",
2778
2798
  ...variables,
2779
2799
  signal
2780
2800
  });
2781
- const setTableSchema = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/schema", method: "put", ...variables, signal });
2801
+ const setTableSchema = (variables, signal) => dataPlaneFetch({
2802
+ url: "/db/{dbBranchName}/tables/{tableName}/schema",
2803
+ method: "put",
2804
+ ...variables,
2805
+ signal
2806
+ });
2782
2807
  const getTableColumns = (variables, signal) => dataPlaneFetch({
2783
2808
  url: "/db/{dbBranchName}/tables/{tableName}/columns",
2784
2809
  method: "get",
@@ -2786,7 +2811,12 @@ const getTableColumns = (variables, signal) => dataPlaneFetch({
2786
2811
  signal
2787
2812
  });
2788
2813
  const addTableColumn = (variables, signal) => dataPlaneFetch(
2789
- { url: "/db/{dbBranchName}/tables/{tableName}/columns", method: "post", ...variables, signal }
2814
+ {
2815
+ url: "/db/{dbBranchName}/tables/{tableName}/columns",
2816
+ method: "post",
2817
+ ...variables,
2818
+ signal
2819
+ }
2790
2820
  );
2791
2821
  const getColumn = (variables, signal) => dataPlaneFetch({
2792
2822
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
@@ -2794,15 +2824,30 @@ const getColumn = (variables, signal) => dataPlaneFetch({
2794
2824
  ...variables,
2795
2825
  signal
2796
2826
  });
2797
- const updateColumn = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}", method: "patch", ...variables, signal });
2827
+ const updateColumn = (variables, signal) => dataPlaneFetch({
2828
+ url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
2829
+ method: "patch",
2830
+ ...variables,
2831
+ signal
2832
+ });
2798
2833
  const deleteColumn = (variables, signal) => dataPlaneFetch({
2799
2834
  url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
2800
2835
  method: "delete",
2801
2836
  ...variables,
2802
2837
  signal
2803
2838
  });
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 });
2839
+ const branchTransaction = (variables, signal) => dataPlaneFetch({
2840
+ url: "/db/{dbBranchName}/transaction",
2841
+ method: "post",
2842
+ ...variables,
2843
+ signal
2844
+ });
2845
+ const insertRecord = (variables, signal) => dataPlaneFetch({
2846
+ url: "/db/{dbBranchName}/tables/{tableName}/data",
2847
+ method: "post",
2848
+ ...variables,
2849
+ signal
2850
+ });
2806
2851
  const getFileItem = (variables, signal) => dataPlaneFetch({
2807
2852
  url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
2808
2853
  method: "get",
@@ -2845,19 +2890,44 @@ const getRecord = (variables, signal) => dataPlaneFetch({
2845
2890
  ...variables,
2846
2891
  signal
2847
2892
  });
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 });
2853
- const queryTable = (variables, signal) => dataPlaneFetch({
2854
- url: "/db/{dbBranchName}/tables/{tableName}/query",
2855
- method: "post",
2893
+ const insertRecordWithID = (variables, signal) => dataPlaneFetch({
2894
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2895
+ method: "put",
2856
2896
  ...variables,
2857
2897
  signal
2858
2898
  });
2859
- const searchBranch = (variables, signal) => dataPlaneFetch({
2860
- url: "/db/{dbBranchName}/search",
2899
+ const updateRecordWithID = (variables, signal) => dataPlaneFetch({
2900
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2901
+ method: "patch",
2902
+ ...variables,
2903
+ signal
2904
+ });
2905
+ const upsertRecordWithID = (variables, signal) => dataPlaneFetch({
2906
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2907
+ method: "post",
2908
+ ...variables,
2909
+ signal
2910
+ });
2911
+ const deleteRecord = (variables, signal) => dataPlaneFetch({
2912
+ url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
2913
+ method: "delete",
2914
+ ...variables,
2915
+ signal
2916
+ });
2917
+ const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({
2918
+ url: "/db/{dbBranchName}/tables/{tableName}/bulk",
2919
+ method: "post",
2920
+ ...variables,
2921
+ signal
2922
+ });
2923
+ const queryTable = (variables, signal) => dataPlaneFetch({
2924
+ url: "/db/{dbBranchName}/tables/{tableName}/query",
2925
+ method: "post",
2926
+ ...variables,
2927
+ signal
2928
+ });
2929
+ const searchBranch = (variables, signal) => dataPlaneFetch({
2930
+ url: "/db/{dbBranchName}/search",
2861
2931
  method: "post",
2862
2932
  ...variables,
2863
2933
  signal
@@ -2868,16 +2938,36 @@ const searchTable = (variables, signal) => dataPlaneFetch({
2868
2938
  ...variables,
2869
2939
  signal
2870
2940
  });
2871
- const vectorSearchTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch", method: "post", ...variables, signal });
2941
+ const vectorSearchTable = (variables, signal) => dataPlaneFetch({
2942
+ url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch",
2943
+ method: "post",
2944
+ ...variables,
2945
+ signal
2946
+ });
2872
2947
  const askTable = (variables, signal) => dataPlaneFetch({
2873
2948
  url: "/db/{dbBranchName}/tables/{tableName}/ask",
2874
2949
  method: "post",
2875
2950
  ...variables,
2876
2951
  signal
2877
2952
  });
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 });
2953
+ const askTableSession = (variables, signal) => dataPlaneFetch({
2954
+ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
2955
+ method: "post",
2956
+ ...variables,
2957
+ signal
2958
+ });
2959
+ const summarizeTable = (variables, signal) => dataPlaneFetch({
2960
+ url: "/db/{dbBranchName}/tables/{tableName}/summarize",
2961
+ method: "post",
2962
+ ...variables,
2963
+ signal
2964
+ });
2965
+ const aggregateTable = (variables, signal) => dataPlaneFetch({
2966
+ url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
2967
+ method: "post",
2968
+ ...variables,
2969
+ signal
2970
+ });
2881
2971
  const fileAccess = (variables, signal) => dataPlaneFetch({
2882
2972
  url: "/file/{fileId}",
2883
2973
  method: "get",
@@ -2896,15 +2986,34 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
2896
2986
  ...variables,
2897
2987
  signal
2898
2988
  });
2989
+ const sqlBatchQuery = (variables, signal) => dataPlaneFetch({
2990
+ url: "/db/{dbBranchName}/sql/batch",
2991
+ method: "post",
2992
+ ...variables,
2993
+ signal
2994
+ });
2899
2995
  const operationsByTag$2 = {
2996
+ tasks: { getTasks, getTaskStatus },
2997
+ cluster: {
2998
+ listClusterBranches,
2999
+ listClusterExtensions,
3000
+ installClusterExtension,
3001
+ dropClusterExtension,
3002
+ getClusterMetrics
3003
+ },
2900
3004
  migrations: {
2901
3005
  applyMigration,
3006
+ startMigration,
3007
+ completeMigration,
3008
+ rollbackMigration,
2902
3009
  adaptTable,
2903
3010
  adaptAllTables,
2904
3011
  getBranchMigrationJobStatus,
3012
+ getMigrationJobs,
2905
3013
  getMigrationJobStatus,
2906
3014
  getMigrationHistory,
2907
3015
  getSchema,
3016
+ getSchemas,
2908
3017
  getBranchMigrationHistory,
2909
3018
  getBranchMigrationPlan,
2910
3019
  executeBranchMigrationPlan,
@@ -2918,10 +3027,13 @@ const operationsByTag$2 = {
2918
3027
  },
2919
3028
  branch: {
2920
3029
  getBranchList,
3030
+ createBranchAsync,
2921
3031
  getBranchDetails,
2922
3032
  createBranch,
2923
3033
  deleteBranch,
2924
3034
  copyBranch,
3035
+ getBranchMoveStatus,
3036
+ moveBranch,
2925
3037
  updateBranchMetadata,
2926
3038
  getBranchMetadata,
2927
3039
  getBranchStats,
@@ -2963,7 +3075,16 @@ const operationsByTag$2 = {
2963
3075
  deleteRecord,
2964
3076
  bulkInsertTableRecords
2965
3077
  },
2966
- files: { getFileItem, putFileItem, deleteFileItem, getFile, putFile, deleteFile, fileAccess, fileUpload },
3078
+ files: {
3079
+ getFileItem,
3080
+ putFileItem,
3081
+ deleteFileItem,
3082
+ getFile,
3083
+ putFile,
3084
+ deleteFile,
3085
+ fileAccess,
3086
+ fileUpload
3087
+ },
2967
3088
  searchAndFilter: {
2968
3089
  queryTable,
2969
3090
  searchBranch,
@@ -2974,7 +3095,7 @@ const operationsByTag$2 = {
2974
3095
  summarizeTable,
2975
3096
  aggregateTable
2976
3097
  },
2977
- sql: { sqlQuery }
3098
+ sql: { sqlQuery, sqlBatchQuery }
2978
3099
  };
2979
3100
 
2980
3101
  const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
@@ -3041,7 +3162,12 @@ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
3041
3162
  ...variables,
3042
3163
  signal
3043
3164
  });
3044
- const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({ url: "/user/oauth/tokens/{token}", method: "patch", ...variables, signal });
3165
+ const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({
3166
+ url: "/user/oauth/tokens/{token}",
3167
+ method: "patch",
3168
+ ...variables,
3169
+ signal
3170
+ });
3045
3171
  const getWorkspacesList = (variables, signal) => controlPlaneFetch({
3046
3172
  url: "/workspaces",
3047
3173
  method: "get",
@@ -3072,1451 +3198,253 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
3072
3198
  ...variables,
3073
3199
  signal
3074
3200
  });
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 });
3079
- const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
3080
- url: "/workspaces/{workspaceId}/members/{userId}",
3081
- method: "delete",
3201
+ const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({
3202
+ url: "/workspaces/{workspaceId}/settings",
3203
+ method: "get",
3082
3204
  ...variables,
3083
3205
  signal
3084
3206
  });
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 });
3092
- const getCluster = (variables, signal) => controlPlaneFetch({
3093
- url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3094
- method: "get",
3207
+ const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({
3208
+ url: "/workspaces/{workspaceId}/settings",
3209
+ method: "patch",
3095
3210
  ...variables,
3096
3211
  signal
3097
3212
  });
3098
- const updateCluster = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/clusters/{clusterId}", method: "patch", ...variables, signal });
3099
- const getDatabaseList = (variables, signal) => controlPlaneFetch({
3100
- url: "/workspaces/{workspaceId}/dbs",
3213
+ const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({
3214
+ url: "/workspaces/{workspaceId}/members",
3101
3215
  method: "get",
3102
3216
  ...variables,
3103
3217
  signal
3104
3218
  });
3105
- const createDatabase = (variables, signal) => controlPlaneFetch({ url: "/workspaces/{workspaceId}/dbs/{dbName}", method: "put", ...variables, signal });
3106
- const deleteDatabase = (variables, signal) => controlPlaneFetch({
3107
- url: "/workspaces/{workspaceId}/dbs/{dbName}",
3108
- method: "delete",
3219
+ const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({
3220
+ url: "/workspaces/{workspaceId}/members/{userId}",
3221
+ method: "put",
3109
3222
  ...variables,
3110
3223
  signal
3111
3224
  });
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 });
3118
- const listRegions = (variables, signal) => controlPlaneFetch({
3119
- url: "/workspaces/{workspaceId}/regions",
3120
- method: "get",
3225
+ const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
3226
+ url: "/workspaces/{workspaceId}/members/{userId}",
3227
+ method: "delete",
3121
3228
  ...variables,
3122
3229
  signal
3123
3230
  });
3124
- const operationsByTag$1 = {
3125
- oAuth: {
3126
- getAuthorizationCode,
3127
- grantAuthorizationCode,
3128
- getUserOAuthClients,
3129
- deleteUserOAuthClient,
3130
- getUserOAuthAccessTokens,
3131
- deleteOAuthAccessToken,
3132
- updateOAuthAccessToken
3133
- },
3134
- users: { getUser, updateUser, deleteUser },
3135
- authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
3136
- workspaces: {
3137
- getWorkspacesList,
3138
- createWorkspace,
3139
- getWorkspace,
3140
- updateWorkspace,
3141
- deleteWorkspace,
3142
- getWorkspaceSettings,
3143
- updateWorkspaceSettings,
3144
- getWorkspaceMembersList,
3145
- updateWorkspaceMemberRole,
3146
- removeWorkspaceMember
3147
- },
3148
- invites: {
3149
- inviteWorkspaceMember,
3150
- updateWorkspaceMemberInvite,
3151
- cancelWorkspaceMemberInvite,
3152
- acceptWorkspaceMemberInvite,
3153
- resendWorkspaceMemberInvite
3154
- },
3155
- xbcontrolOther: { listClusters, createCluster, getCluster, updateCluster },
3156
- databases: {
3157
- getDatabaseList,
3158
- createDatabase,
3159
- deleteDatabase,
3160
- getDatabaseMetadata,
3161
- updateDatabaseMetadata,
3162
- renameDatabase,
3163
- getDatabaseGithubSettings,
3164
- updateDatabaseGithubSettings,
3165
- deleteDatabaseGithubSettings,
3166
- listRegions
3167
- }
3168
- };
3169
-
3170
- const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
3171
-
3172
- var __accessCheck$7 = (obj, member, msg) => {
3173
- if (!member.has(obj))
3174
- throw TypeError("Cannot " + msg);
3175
- };
3176
- var __privateGet$6 = (obj, member, getter) => {
3177
- __accessCheck$7(obj, member, "read from private field");
3178
- return getter ? getter.call(obj) : member.get(obj);
3179
- };
3180
- var __privateAdd$7 = (obj, member, value) => {
3181
- if (member.has(obj))
3182
- throw TypeError("Cannot add the same private member more than once");
3183
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3184
- };
3185
- var __privateSet$5 = (obj, member, value, setter) => {
3186
- __accessCheck$7(obj, member, "write to private field");
3187
- setter ? setter.call(obj, value) : member.set(obj, value);
3188
- return value;
3189
- };
3190
- var _extraProps, _namespaces;
3191
- class XataApiClient {
3192
- constructor(options = {}) {
3193
- __privateAdd$7(this, _extraProps, void 0);
3194
- __privateAdd$7(this, _namespaces, {});
3195
- const provider = options.host ?? "production";
3196
- const apiKey = options.apiKey ?? getAPIKey();
3197
- const trace = options.trace ?? defaultTrace;
3198
- const clientID = generateUUID();
3199
- if (!apiKey) {
3200
- throw new Error("Could not resolve a valid apiKey");
3201
- }
3202
- __privateSet$5(this, _extraProps, {
3203
- apiUrl: getHostUrl(provider, "main"),
3204
- workspacesApiUrl: getHostUrl(provider, "workspaces"),
3205
- fetch: getFetchImplementation(options.fetch),
3206
- apiKey,
3207
- trace,
3208
- clientName: options.clientName,
3209
- xataAgentExtra: options.xataAgentExtra,
3210
- clientID
3211
- });
3212
- }
3213
- get user() {
3214
- if (!__privateGet$6(this, _namespaces).user)
3215
- __privateGet$6(this, _namespaces).user = new UserApi(__privateGet$6(this, _extraProps));
3216
- return __privateGet$6(this, _namespaces).user;
3217
- }
3218
- get authentication() {
3219
- if (!__privateGet$6(this, _namespaces).authentication)
3220
- __privateGet$6(this, _namespaces).authentication = new AuthenticationApi(__privateGet$6(this, _extraProps));
3221
- return __privateGet$6(this, _namespaces).authentication;
3222
- }
3223
- get workspaces() {
3224
- if (!__privateGet$6(this, _namespaces).workspaces)
3225
- __privateGet$6(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$6(this, _extraProps));
3226
- return __privateGet$6(this, _namespaces).workspaces;
3227
- }
3228
- get invites() {
3229
- if (!__privateGet$6(this, _namespaces).invites)
3230
- __privateGet$6(this, _namespaces).invites = new InvitesApi(__privateGet$6(this, _extraProps));
3231
- return __privateGet$6(this, _namespaces).invites;
3232
- }
3233
- get database() {
3234
- if (!__privateGet$6(this, _namespaces).database)
3235
- __privateGet$6(this, _namespaces).database = new DatabaseApi(__privateGet$6(this, _extraProps));
3236
- return __privateGet$6(this, _namespaces).database;
3237
- }
3238
- get branches() {
3239
- if (!__privateGet$6(this, _namespaces).branches)
3240
- __privateGet$6(this, _namespaces).branches = new BranchApi(__privateGet$6(this, _extraProps));
3241
- return __privateGet$6(this, _namespaces).branches;
3242
- }
3243
- get migrations() {
3244
- if (!__privateGet$6(this, _namespaces).migrations)
3245
- __privateGet$6(this, _namespaces).migrations = new MigrationsApi(__privateGet$6(this, _extraProps));
3246
- return __privateGet$6(this, _namespaces).migrations;
3247
- }
3248
- get migrationRequests() {
3249
- if (!__privateGet$6(this, _namespaces).migrationRequests)
3250
- __privateGet$6(this, _namespaces).migrationRequests = new MigrationRequestsApi(__privateGet$6(this, _extraProps));
3251
- return __privateGet$6(this, _namespaces).migrationRequests;
3252
- }
3253
- get tables() {
3254
- if (!__privateGet$6(this, _namespaces).tables)
3255
- __privateGet$6(this, _namespaces).tables = new TableApi(__privateGet$6(this, _extraProps));
3256
- return __privateGet$6(this, _namespaces).tables;
3257
- }
3258
- get records() {
3259
- if (!__privateGet$6(this, _namespaces).records)
3260
- __privateGet$6(this, _namespaces).records = new RecordsApi(__privateGet$6(this, _extraProps));
3261
- return __privateGet$6(this, _namespaces).records;
3262
- }
3263
- get files() {
3264
- if (!__privateGet$6(this, _namespaces).files)
3265
- __privateGet$6(this, _namespaces).files = new FilesApi(__privateGet$6(this, _extraProps));
3266
- return __privateGet$6(this, _namespaces).files;
3267
- }
3268
- get searchAndFilter() {
3269
- if (!__privateGet$6(this, _namespaces).searchAndFilter)
3270
- __privateGet$6(this, _namespaces).searchAndFilter = new SearchAndFilterApi(__privateGet$6(this, _extraProps));
3271
- return __privateGet$6(this, _namespaces).searchAndFilter;
3272
- }
3273
- }
3274
- _extraProps = new WeakMap();
3275
- _namespaces = new WeakMap();
3276
- class UserApi {
3277
- constructor(extraProps) {
3278
- this.extraProps = extraProps;
3279
- }
3280
- getUser() {
3281
- return operationsByTag.users.getUser({ ...this.extraProps });
3282
- }
3283
- updateUser({ user }) {
3284
- return operationsByTag.users.updateUser({ body: user, ...this.extraProps });
3285
- }
3286
- deleteUser() {
3287
- return operationsByTag.users.deleteUser({ ...this.extraProps });
3288
- }
3289
- }
3290
- class AuthenticationApi {
3291
- constructor(extraProps) {
3292
- this.extraProps = extraProps;
3293
- }
3294
- getUserAPIKeys() {
3295
- return operationsByTag.authentication.getUserAPIKeys({ ...this.extraProps });
3296
- }
3297
- createUserAPIKey({ name }) {
3298
- return operationsByTag.authentication.createUserAPIKey({
3299
- pathParams: { keyName: name },
3300
- ...this.extraProps
3301
- });
3302
- }
3303
- deleteUserAPIKey({ name }) {
3304
- return operationsByTag.authentication.deleteUserAPIKey({
3305
- pathParams: { keyName: name },
3306
- ...this.extraProps
3307
- });
3308
- }
3309
- }
3310
- class WorkspaceApi {
3311
- constructor(extraProps) {
3312
- this.extraProps = extraProps;
3313
- }
3314
- getWorkspacesList() {
3315
- return operationsByTag.workspaces.getWorkspacesList({ ...this.extraProps });
3316
- }
3317
- createWorkspace({ data }) {
3318
- return operationsByTag.workspaces.createWorkspace({
3319
- body: data,
3320
- ...this.extraProps
3321
- });
3322
- }
3323
- getWorkspace({ workspace }) {
3324
- return operationsByTag.workspaces.getWorkspace({
3325
- pathParams: { workspaceId: workspace },
3326
- ...this.extraProps
3327
- });
3328
- }
3329
- updateWorkspace({
3330
- workspace,
3331
- update
3332
- }) {
3333
- return operationsByTag.workspaces.updateWorkspace({
3334
- pathParams: { workspaceId: workspace },
3335
- body: update,
3336
- ...this.extraProps
3337
- });
3338
- }
3339
- deleteWorkspace({ workspace }) {
3340
- return operationsByTag.workspaces.deleteWorkspace({
3341
- pathParams: { workspaceId: workspace },
3342
- ...this.extraProps
3343
- });
3344
- }
3345
- getWorkspaceMembersList({ workspace }) {
3346
- return operationsByTag.workspaces.getWorkspaceMembersList({
3347
- pathParams: { workspaceId: workspace },
3348
- ...this.extraProps
3349
- });
3350
- }
3351
- updateWorkspaceMemberRole({
3352
- workspace,
3353
- user,
3354
- role
3355
- }) {
3356
- return operationsByTag.workspaces.updateWorkspaceMemberRole({
3357
- pathParams: { workspaceId: workspace, userId: user },
3358
- body: { role },
3359
- ...this.extraProps
3360
- });
3361
- }
3362
- removeWorkspaceMember({
3363
- workspace,
3364
- user
3365
- }) {
3366
- return operationsByTag.workspaces.removeWorkspaceMember({
3367
- pathParams: { workspaceId: workspace, userId: user },
3368
- ...this.extraProps
3369
- });
3370
- }
3371
- }
3372
- class InvitesApi {
3373
- constructor(extraProps) {
3374
- this.extraProps = extraProps;
3375
- }
3376
- inviteWorkspaceMember({
3377
- workspace,
3378
- email,
3379
- role
3380
- }) {
3381
- return operationsByTag.invites.inviteWorkspaceMember({
3382
- pathParams: { workspaceId: workspace },
3383
- body: { email, role },
3384
- ...this.extraProps
3385
- });
3386
- }
3387
- updateWorkspaceMemberInvite({
3388
- workspace,
3389
- invite,
3390
- role
3391
- }) {
3392
- return operationsByTag.invites.updateWorkspaceMemberInvite({
3393
- pathParams: { workspaceId: workspace, inviteId: invite },
3394
- body: { role },
3395
- ...this.extraProps
3396
- });
3397
- }
3398
- cancelWorkspaceMemberInvite({
3399
- workspace,
3400
- invite
3401
- }) {
3402
- return operationsByTag.invites.cancelWorkspaceMemberInvite({
3403
- pathParams: { workspaceId: workspace, inviteId: invite },
3404
- ...this.extraProps
3405
- });
3406
- }
3407
- acceptWorkspaceMemberInvite({
3408
- workspace,
3409
- key
3410
- }) {
3411
- return operationsByTag.invites.acceptWorkspaceMemberInvite({
3412
- pathParams: { workspaceId: workspace, inviteKey: key },
3413
- ...this.extraProps
3414
- });
3415
- }
3416
- resendWorkspaceMemberInvite({
3417
- workspace,
3418
- invite
3419
- }) {
3420
- return operationsByTag.invites.resendWorkspaceMemberInvite({
3421
- pathParams: { workspaceId: workspace, inviteId: invite },
3422
- ...this.extraProps
3423
- });
3424
- }
3425
- }
3426
- class BranchApi {
3427
- constructor(extraProps) {
3428
- this.extraProps = extraProps;
3429
- }
3430
- getBranchList({
3431
- workspace,
3432
- region,
3433
- database
3434
- }) {
3435
- return operationsByTag.branch.getBranchList({
3436
- pathParams: { workspace, region, dbName: database },
3437
- ...this.extraProps
3438
- });
3439
- }
3440
- getBranchDetails({
3441
- workspace,
3442
- region,
3443
- database,
3444
- branch
3445
- }) {
3446
- return operationsByTag.branch.getBranchDetails({
3447
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3448
- ...this.extraProps
3449
- });
3450
- }
3451
- createBranch({
3452
- workspace,
3453
- region,
3454
- database,
3455
- branch,
3456
- from,
3457
- metadata
3458
- }) {
3459
- return operationsByTag.branch.createBranch({
3460
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3461
- body: { from, metadata },
3462
- ...this.extraProps
3463
- });
3464
- }
3465
- deleteBranch({
3466
- workspace,
3467
- region,
3468
- database,
3469
- branch
3470
- }) {
3471
- return operationsByTag.branch.deleteBranch({
3472
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3473
- ...this.extraProps
3474
- });
3475
- }
3476
- copyBranch({
3477
- workspace,
3478
- region,
3479
- database,
3480
- branch,
3481
- destinationBranch,
3482
- limit
3483
- }) {
3484
- return operationsByTag.branch.copyBranch({
3485
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3486
- body: { destinationBranch, limit },
3487
- ...this.extraProps
3488
- });
3489
- }
3490
- updateBranchMetadata({
3491
- workspace,
3492
- region,
3493
- database,
3494
- branch,
3495
- metadata
3496
- }) {
3497
- return operationsByTag.branch.updateBranchMetadata({
3498
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3499
- body: metadata,
3500
- ...this.extraProps
3501
- });
3502
- }
3503
- getBranchMetadata({
3504
- workspace,
3505
- region,
3506
- database,
3507
- branch
3508
- }) {
3509
- return operationsByTag.branch.getBranchMetadata({
3510
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3511
- ...this.extraProps
3512
- });
3513
- }
3514
- getBranchStats({
3515
- workspace,
3516
- region,
3517
- database,
3518
- branch
3519
- }) {
3520
- return operationsByTag.branch.getBranchStats({
3521
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3522
- ...this.extraProps
3523
- });
3524
- }
3525
- getGitBranchesMapping({
3526
- workspace,
3527
- region,
3528
- database
3529
- }) {
3530
- return operationsByTag.branch.getGitBranchesMapping({
3531
- pathParams: { workspace, region, dbName: database },
3532
- ...this.extraProps
3533
- });
3534
- }
3535
- addGitBranchesEntry({
3536
- workspace,
3537
- region,
3538
- database,
3539
- gitBranch,
3540
- xataBranch
3541
- }) {
3542
- return operationsByTag.branch.addGitBranchesEntry({
3543
- pathParams: { workspace, region, dbName: database },
3544
- body: { gitBranch, xataBranch },
3545
- ...this.extraProps
3546
- });
3547
- }
3548
- removeGitBranchesEntry({
3549
- workspace,
3550
- region,
3551
- database,
3552
- gitBranch
3553
- }) {
3554
- return operationsByTag.branch.removeGitBranchesEntry({
3555
- pathParams: { workspace, region, dbName: database },
3556
- queryParams: { gitBranch },
3557
- ...this.extraProps
3558
- });
3559
- }
3560
- resolveBranch({
3561
- workspace,
3562
- region,
3563
- database,
3564
- gitBranch,
3565
- fallbackBranch
3566
- }) {
3567
- return operationsByTag.branch.resolveBranch({
3568
- pathParams: { workspace, region, dbName: database },
3569
- queryParams: { gitBranch, fallbackBranch },
3570
- ...this.extraProps
3571
- });
3572
- }
3573
- pgRollMigrationHistory({
3574
- workspace,
3575
- region,
3576
- database,
3577
- branch
3578
- }) {
3579
- return operationsByTag.migrations.getMigrationHistory({
3580
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3581
- ...this.extraProps
3582
- });
3583
- }
3584
- applyMigration({
3585
- workspace,
3586
- region,
3587
- database,
3588
- branch,
3589
- migration
3590
- }) {
3591
- return operationsByTag.migrations.applyMigration({
3592
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3593
- body: migration,
3594
- ...this.extraProps
3595
- });
3596
- }
3597
- }
3598
- class TableApi {
3599
- constructor(extraProps) {
3600
- this.extraProps = extraProps;
3601
- }
3602
- createTable({
3603
- workspace,
3604
- region,
3605
- database,
3606
- branch,
3607
- table
3608
- }) {
3609
- return operationsByTag.table.createTable({
3610
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3611
- ...this.extraProps
3612
- });
3613
- }
3614
- deleteTable({
3615
- workspace,
3616
- region,
3617
- database,
3618
- branch,
3619
- table
3620
- }) {
3621
- return operationsByTag.table.deleteTable({
3622
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3623
- ...this.extraProps
3624
- });
3625
- }
3626
- updateTable({
3627
- workspace,
3628
- region,
3629
- database,
3630
- branch,
3631
- table,
3632
- update
3633
- }) {
3634
- return operationsByTag.table.updateTable({
3635
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3636
- body: update,
3637
- ...this.extraProps
3638
- });
3639
- }
3640
- getTableSchema({
3641
- workspace,
3642
- region,
3643
- database,
3644
- branch,
3645
- table
3646
- }) {
3647
- return operationsByTag.table.getTableSchema({
3648
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3649
- ...this.extraProps
3650
- });
3651
- }
3652
- setTableSchema({
3653
- workspace,
3654
- region,
3655
- database,
3656
- branch,
3657
- table,
3658
- schema
3659
- }) {
3660
- return operationsByTag.table.setTableSchema({
3661
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3662
- body: schema,
3663
- ...this.extraProps
3664
- });
3665
- }
3666
- getTableColumns({
3667
- workspace,
3668
- region,
3669
- database,
3670
- branch,
3671
- table
3672
- }) {
3673
- return operationsByTag.table.getTableColumns({
3674
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3675
- ...this.extraProps
3676
- });
3677
- }
3678
- addTableColumn({
3679
- workspace,
3680
- region,
3681
- database,
3682
- branch,
3683
- table,
3684
- column
3685
- }) {
3686
- return operationsByTag.table.addTableColumn({
3687
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3688
- body: column,
3689
- ...this.extraProps
3690
- });
3691
- }
3692
- getColumn({
3693
- workspace,
3694
- region,
3695
- database,
3696
- branch,
3697
- table,
3698
- column
3699
- }) {
3700
- return operationsByTag.table.getColumn({
3701
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
3702
- ...this.extraProps
3703
- });
3704
- }
3705
- updateColumn({
3706
- workspace,
3707
- region,
3708
- database,
3709
- branch,
3710
- table,
3711
- column,
3712
- update
3713
- }) {
3714
- return operationsByTag.table.updateColumn({
3715
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
3716
- body: update,
3717
- ...this.extraProps
3718
- });
3719
- }
3720
- deleteColumn({
3721
- workspace,
3722
- region,
3723
- database,
3724
- branch,
3725
- table,
3726
- column
3727
- }) {
3728
- return operationsByTag.table.deleteColumn({
3729
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, columnName: column },
3730
- ...this.extraProps
3731
- });
3732
- }
3733
- }
3734
- class RecordsApi {
3735
- constructor(extraProps) {
3736
- this.extraProps = extraProps;
3737
- }
3738
- insertRecord({
3739
- workspace,
3740
- region,
3741
- database,
3742
- branch,
3743
- table,
3744
- record,
3745
- columns
3746
- }) {
3747
- return operationsByTag.records.insertRecord({
3748
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3749
- queryParams: { columns },
3750
- body: record,
3751
- ...this.extraProps
3752
- });
3753
- }
3754
- getRecord({
3755
- workspace,
3756
- region,
3757
- database,
3758
- branch,
3759
- table,
3760
- id,
3761
- columns
3762
- }) {
3763
- return operationsByTag.records.getRecord({
3764
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
3765
- queryParams: { columns },
3766
- ...this.extraProps
3767
- });
3768
- }
3769
- insertRecordWithID({
3770
- workspace,
3771
- region,
3772
- database,
3773
- branch,
3774
- table,
3775
- id,
3776
- record,
3777
- columns,
3778
- createOnly,
3779
- ifVersion
3780
- }) {
3781
- return operationsByTag.records.insertRecordWithID({
3782
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
3783
- queryParams: { columns, createOnly, ifVersion },
3784
- body: record,
3785
- ...this.extraProps
3786
- });
3787
- }
3788
- updateRecordWithID({
3789
- workspace,
3790
- region,
3791
- database,
3792
- branch,
3793
- table,
3794
- id,
3795
- record,
3796
- columns,
3797
- ifVersion
3798
- }) {
3799
- return operationsByTag.records.updateRecordWithID({
3800
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
3801
- queryParams: { columns, ifVersion },
3802
- body: record,
3803
- ...this.extraProps
3804
- });
3805
- }
3806
- upsertRecordWithID({
3807
- workspace,
3808
- region,
3809
- database,
3810
- branch,
3811
- table,
3812
- id,
3813
- record,
3814
- columns,
3815
- ifVersion
3816
- }) {
3817
- return operationsByTag.records.upsertRecordWithID({
3818
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
3819
- queryParams: { columns, ifVersion },
3820
- body: record,
3821
- ...this.extraProps
3822
- });
3823
- }
3824
- deleteRecord({
3825
- workspace,
3826
- region,
3827
- database,
3828
- branch,
3829
- table,
3830
- id,
3831
- columns
3832
- }) {
3833
- return operationsByTag.records.deleteRecord({
3834
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, recordId: id },
3835
- queryParams: { columns },
3836
- ...this.extraProps
3837
- });
3838
- }
3839
- bulkInsertTableRecords({
3840
- workspace,
3841
- region,
3842
- database,
3843
- branch,
3844
- table,
3845
- records,
3846
- columns
3847
- }) {
3848
- return operationsByTag.records.bulkInsertTableRecords({
3849
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
3850
- queryParams: { columns },
3851
- body: { records },
3852
- ...this.extraProps
3853
- });
3854
- }
3855
- branchTransaction({
3856
- workspace,
3857
- region,
3858
- database,
3859
- branch,
3860
- operations
3861
- }) {
3862
- return operationsByTag.records.branchTransaction({
3863
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
3864
- body: { operations },
3865
- ...this.extraProps
3866
- });
3867
- }
3868
- }
3869
- class FilesApi {
3870
- constructor(extraProps) {
3871
- this.extraProps = extraProps;
3872
- }
3873
- getFileItem({
3874
- workspace,
3875
- region,
3876
- database,
3877
- branch,
3878
- table,
3879
- record,
3880
- column,
3881
- fileId
3882
- }) {
3883
- return operationsByTag.files.getFileItem({
3884
- pathParams: {
3885
- workspace,
3886
- region,
3887
- dbBranchName: `${database}:${branch}`,
3888
- tableName: table,
3889
- recordId: record,
3890
- columnName: column,
3891
- fileId
3892
- },
3893
- ...this.extraProps
3894
- });
3895
- }
3896
- putFileItem({
3897
- workspace,
3898
- region,
3899
- database,
3900
- branch,
3901
- table,
3902
- record,
3903
- column,
3904
- fileId,
3905
- file
3906
- }) {
3907
- return operationsByTag.files.putFileItem({
3908
- pathParams: {
3909
- workspace,
3910
- region,
3911
- dbBranchName: `${database}:${branch}`,
3912
- tableName: table,
3913
- recordId: record,
3914
- columnName: column,
3915
- fileId
3916
- },
3917
- // @ts-ignore
3918
- body: file,
3919
- ...this.extraProps
3920
- });
3921
- }
3922
- deleteFileItem({
3923
- workspace,
3924
- region,
3925
- database,
3926
- branch,
3927
- table,
3928
- record,
3929
- column,
3930
- fileId
3931
- }) {
3932
- return operationsByTag.files.deleteFileItem({
3933
- pathParams: {
3934
- workspace,
3935
- region,
3936
- dbBranchName: `${database}:${branch}`,
3937
- tableName: table,
3938
- recordId: record,
3939
- columnName: column,
3940
- fileId
3941
- },
3942
- ...this.extraProps
3943
- });
3944
- }
3945
- getFile({
3946
- workspace,
3947
- region,
3948
- database,
3949
- branch,
3950
- table,
3951
- record,
3952
- column
3953
- }) {
3954
- return operationsByTag.files.getFile({
3955
- pathParams: {
3956
- workspace,
3957
- region,
3958
- dbBranchName: `${database}:${branch}`,
3959
- tableName: table,
3960
- recordId: record,
3961
- columnName: column
3962
- },
3963
- ...this.extraProps
3964
- });
3965
- }
3966
- putFile({
3967
- workspace,
3968
- region,
3969
- database,
3970
- branch,
3971
- table,
3972
- record,
3973
- column,
3974
- file
3975
- }) {
3976
- return operationsByTag.files.putFile({
3977
- pathParams: {
3978
- workspace,
3979
- region,
3980
- dbBranchName: `${database}:${branch}`,
3981
- tableName: table,
3982
- recordId: record,
3983
- columnName: column
3984
- },
3985
- body: file,
3986
- ...this.extraProps
3987
- });
3988
- }
3989
- deleteFile({
3990
- workspace,
3991
- region,
3992
- database,
3993
- branch,
3994
- table,
3995
- record,
3996
- column
3997
- }) {
3998
- return operationsByTag.files.deleteFile({
3999
- pathParams: {
4000
- workspace,
4001
- region,
4002
- dbBranchName: `${database}:${branch}`,
4003
- tableName: table,
4004
- recordId: record,
4005
- columnName: column
4006
- },
4007
- ...this.extraProps
4008
- });
4009
- }
4010
- fileAccess({
4011
- workspace,
4012
- region,
4013
- fileId,
4014
- verify
4015
- }) {
4016
- return operationsByTag.files.fileAccess({
4017
- pathParams: {
4018
- workspace,
4019
- region,
4020
- fileId
4021
- },
4022
- queryParams: { verify },
4023
- ...this.extraProps
4024
- });
4025
- }
4026
- }
4027
- class SearchAndFilterApi {
4028
- constructor(extraProps) {
4029
- this.extraProps = extraProps;
4030
- }
4031
- queryTable({
4032
- workspace,
4033
- region,
4034
- database,
4035
- branch,
4036
- table,
4037
- filter,
4038
- sort,
4039
- page,
4040
- columns,
4041
- consistency
4042
- }) {
4043
- return operationsByTag.searchAndFilter.queryTable({
4044
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4045
- body: { filter, sort, page, columns, consistency },
4046
- ...this.extraProps
4047
- });
4048
- }
4049
- searchTable({
4050
- workspace,
4051
- region,
4052
- database,
4053
- branch,
4054
- table,
4055
- query,
4056
- fuzziness,
4057
- target,
4058
- prefix,
4059
- filter,
4060
- highlight,
4061
- boosters
4062
- }) {
4063
- return operationsByTag.searchAndFilter.searchTable({
4064
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4065
- body: { query, fuzziness, target, prefix, filter, highlight, boosters },
4066
- ...this.extraProps
4067
- });
4068
- }
4069
- searchBranch({
4070
- workspace,
4071
- region,
4072
- database,
4073
- branch,
4074
- tables,
4075
- query,
4076
- fuzziness,
4077
- prefix,
4078
- highlight
4079
- }) {
4080
- return operationsByTag.searchAndFilter.searchBranch({
4081
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4082
- body: { tables, query, fuzziness, prefix, highlight },
4083
- ...this.extraProps
4084
- });
4085
- }
4086
- vectorSearchTable({
4087
- workspace,
4088
- region,
4089
- database,
4090
- branch,
4091
- table,
4092
- queryVector,
4093
- column,
4094
- similarityFunction,
4095
- size,
4096
- filter
4097
- }) {
4098
- return operationsByTag.searchAndFilter.vectorSearchTable({
4099
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4100
- body: { queryVector, column, similarityFunction, size, filter },
4101
- ...this.extraProps
4102
- });
4103
- }
4104
- askTable({
4105
- workspace,
4106
- region,
4107
- database,
4108
- branch,
4109
- table,
4110
- options
4111
- }) {
4112
- return operationsByTag.searchAndFilter.askTable({
4113
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4114
- body: { ...options },
4115
- ...this.extraProps
4116
- });
4117
- }
4118
- askTableSession({
4119
- workspace,
4120
- region,
4121
- database,
4122
- branch,
4123
- table,
4124
- sessionId,
4125
- message
4126
- }) {
4127
- return operationsByTag.searchAndFilter.askTableSession({
4128
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
4129
- body: { message },
4130
- ...this.extraProps
4131
- });
4132
- }
4133
- summarizeTable({
4134
- workspace,
4135
- region,
4136
- database,
4137
- branch,
4138
- table,
4139
- filter,
4140
- columns,
4141
- summaries,
4142
- sort,
4143
- summariesFilter,
4144
- page,
4145
- consistency
4146
- }) {
4147
- return operationsByTag.searchAndFilter.summarizeTable({
4148
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4149
- body: { filter, columns, summaries, sort, summariesFilter, page, consistency },
4150
- ...this.extraProps
4151
- });
4152
- }
4153
- aggregateTable({
4154
- workspace,
4155
- region,
4156
- database,
4157
- branch,
4158
- table,
4159
- filter,
4160
- aggs
4161
- }) {
4162
- return operationsByTag.searchAndFilter.aggregateTable({
4163
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table },
4164
- body: { filter, aggs },
4165
- ...this.extraProps
4166
- });
4167
- }
4168
- }
4169
- class MigrationRequestsApi {
4170
- constructor(extraProps) {
4171
- this.extraProps = extraProps;
4172
- }
4173
- queryMigrationRequests({
4174
- workspace,
4175
- region,
4176
- database,
4177
- filter,
4178
- sort,
4179
- page,
4180
- columns
4181
- }) {
4182
- return operationsByTag.migrationRequests.queryMigrationRequests({
4183
- pathParams: { workspace, region, dbName: database },
4184
- body: { filter, sort, page, columns },
4185
- ...this.extraProps
4186
- });
4187
- }
4188
- createMigrationRequest({
4189
- workspace,
4190
- region,
4191
- database,
4192
- migration
4193
- }) {
4194
- return operationsByTag.migrationRequests.createMigrationRequest({
4195
- pathParams: { workspace, region, dbName: database },
4196
- body: migration,
4197
- ...this.extraProps
4198
- });
4199
- }
4200
- getMigrationRequest({
4201
- workspace,
4202
- region,
4203
- database,
4204
- migrationRequest
4205
- }) {
4206
- return operationsByTag.migrationRequests.getMigrationRequest({
4207
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4208
- ...this.extraProps
4209
- });
4210
- }
4211
- updateMigrationRequest({
4212
- workspace,
4213
- region,
4214
- database,
4215
- migrationRequest,
4216
- update
4217
- }) {
4218
- return operationsByTag.migrationRequests.updateMigrationRequest({
4219
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4220
- body: update,
4221
- ...this.extraProps
4222
- });
4223
- }
4224
- listMigrationRequestsCommits({
4225
- workspace,
4226
- region,
4227
- database,
4228
- migrationRequest,
4229
- page
4230
- }) {
4231
- return operationsByTag.migrationRequests.listMigrationRequestsCommits({
4232
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4233
- body: { page },
4234
- ...this.extraProps
4235
- });
4236
- }
4237
- compareMigrationRequest({
4238
- workspace,
4239
- region,
4240
- database,
4241
- migrationRequest
4242
- }) {
4243
- return operationsByTag.migrationRequests.compareMigrationRequest({
4244
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4245
- ...this.extraProps
4246
- });
4247
- }
4248
- getMigrationRequestIsMerged({
4249
- workspace,
4250
- region,
4251
- database,
4252
- migrationRequest
4253
- }) {
4254
- return operationsByTag.migrationRequests.getMigrationRequestIsMerged({
4255
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4256
- ...this.extraProps
4257
- });
4258
- }
4259
- mergeMigrationRequest({
4260
- workspace,
4261
- region,
4262
- database,
4263
- migrationRequest
4264
- }) {
4265
- return operationsByTag.migrationRequests.mergeMigrationRequest({
4266
- pathParams: { workspace, region, dbName: database, mrNumber: migrationRequest },
4267
- ...this.extraProps
4268
- });
4269
- }
4270
- }
4271
- class MigrationsApi {
4272
- constructor(extraProps) {
4273
- this.extraProps = extraProps;
4274
- }
4275
- getBranchMigrationHistory({
4276
- workspace,
4277
- region,
4278
- database,
4279
- branch,
4280
- limit,
4281
- startFrom
4282
- }) {
4283
- return operationsByTag.migrations.getBranchMigrationHistory({
4284
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4285
- body: { limit, startFrom },
4286
- ...this.extraProps
4287
- });
4288
- }
4289
- getBranchMigrationPlan({
4290
- workspace,
4291
- region,
4292
- database,
4293
- branch,
4294
- schema
4295
- }) {
4296
- return operationsByTag.migrations.getBranchMigrationPlan({
4297
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4298
- body: schema,
4299
- ...this.extraProps
4300
- });
4301
- }
4302
- executeBranchMigrationPlan({
4303
- workspace,
4304
- region,
4305
- database,
4306
- branch,
4307
- plan
4308
- }) {
4309
- return operationsByTag.migrations.executeBranchMigrationPlan({
4310
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4311
- body: plan,
4312
- ...this.extraProps
4313
- });
4314
- }
4315
- getBranchSchemaHistory({
4316
- workspace,
4317
- region,
4318
- database,
4319
- branch,
4320
- page
4321
- }) {
4322
- return operationsByTag.migrations.getBranchSchemaHistory({
4323
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4324
- body: { page },
4325
- ...this.extraProps
4326
- });
4327
- }
4328
- compareBranchWithUserSchema({
4329
- workspace,
4330
- region,
4331
- database,
4332
- branch,
4333
- schema,
4334
- schemaOperations,
4335
- branchOperations
4336
- }) {
4337
- return operationsByTag.migrations.compareBranchWithUserSchema({
4338
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4339
- body: { schema, schemaOperations, branchOperations },
4340
- ...this.extraProps
4341
- });
4342
- }
4343
- compareBranchSchemas({
4344
- workspace,
4345
- region,
4346
- database,
4347
- branch,
4348
- compare,
4349
- sourceBranchOperations,
4350
- targetBranchOperations
4351
- }) {
4352
- return operationsByTag.migrations.compareBranchSchemas({
4353
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, branchName: compare },
4354
- body: { sourceBranchOperations, targetBranchOperations },
4355
- ...this.extraProps
4356
- });
4357
- }
4358
- updateBranchSchema({
4359
- workspace,
4360
- region,
4361
- database,
4362
- branch,
4363
- migration
4364
- }) {
4365
- return operationsByTag.migrations.updateBranchSchema({
4366
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4367
- body: migration,
4368
- ...this.extraProps
4369
- });
4370
- }
4371
- previewBranchSchemaEdit({
4372
- workspace,
4373
- region,
4374
- database,
4375
- branch,
4376
- data
4377
- }) {
4378
- return operationsByTag.migrations.previewBranchSchemaEdit({
4379
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4380
- body: data,
4381
- ...this.extraProps
4382
- });
4383
- }
4384
- applyBranchSchemaEdit({
4385
- workspace,
4386
- region,
4387
- database,
4388
- branch,
4389
- edits
4390
- }) {
4391
- return operationsByTag.migrations.applyBranchSchemaEdit({
4392
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4393
- body: { edits },
4394
- ...this.extraProps
4395
- });
4396
- }
4397
- pushBranchMigrations({
4398
- workspace,
4399
- region,
4400
- database,
4401
- branch,
4402
- migrations
4403
- }) {
4404
- return operationsByTag.migrations.pushBranchMigrations({
4405
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4406
- body: { migrations },
4407
- ...this.extraProps
4408
- });
4409
- }
4410
- getSchema({
4411
- workspace,
4412
- region,
4413
- database,
4414
- branch
4415
- }) {
4416
- return operationsByTag.migrations.getSchema({
4417
- pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
4418
- ...this.extraProps
4419
- });
4420
- }
4421
- }
4422
- class DatabaseApi {
4423
- constructor(extraProps) {
4424
- this.extraProps = extraProps;
4425
- }
4426
- getDatabaseList({ workspace }) {
4427
- return operationsByTag.databases.getDatabaseList({
4428
- pathParams: { workspaceId: workspace },
4429
- ...this.extraProps
4430
- });
4431
- }
4432
- createDatabase({
4433
- workspace,
4434
- database,
4435
- data,
4436
- headers
4437
- }) {
4438
- return operationsByTag.databases.createDatabase({
4439
- pathParams: { workspaceId: workspace, dbName: database },
4440
- body: data,
4441
- headers,
4442
- ...this.extraProps
4443
- });
4444
- }
4445
- deleteDatabase({
4446
- workspace,
4447
- database
4448
- }) {
4449
- return operationsByTag.databases.deleteDatabase({
4450
- pathParams: { workspaceId: workspace, dbName: database },
4451
- ...this.extraProps
4452
- });
4453
- }
4454
- getDatabaseMetadata({
4455
- workspace,
4456
- database
4457
- }) {
4458
- return operationsByTag.databases.getDatabaseMetadata({
4459
- pathParams: { workspaceId: workspace, dbName: database },
4460
- ...this.extraProps
4461
- });
4462
- }
4463
- updateDatabaseMetadata({
4464
- workspace,
4465
- database,
4466
- metadata
4467
- }) {
4468
- return operationsByTag.databases.updateDatabaseMetadata({
4469
- pathParams: { workspaceId: workspace, dbName: database },
4470
- body: metadata,
4471
- ...this.extraProps
4472
- });
4473
- }
4474
- renameDatabase({
4475
- workspace,
4476
- database,
4477
- newName
4478
- }) {
4479
- return operationsByTag.databases.renameDatabase({
4480
- pathParams: { workspaceId: workspace, dbName: database },
4481
- body: { newName },
4482
- ...this.extraProps
4483
- });
4484
- }
4485
- getDatabaseGithubSettings({
4486
- workspace,
4487
- database
4488
- }) {
4489
- return operationsByTag.databases.getDatabaseGithubSettings({
4490
- pathParams: { workspaceId: workspace, dbName: database },
4491
- ...this.extraProps
4492
- });
4493
- }
4494
- updateDatabaseGithubSettings({
4495
- workspace,
4496
- database,
4497
- settings
4498
- }) {
4499
- return operationsByTag.databases.updateDatabaseGithubSettings({
4500
- pathParams: { workspaceId: workspace, dbName: database },
4501
- body: settings,
4502
- ...this.extraProps
4503
- });
4504
- }
4505
- deleteDatabaseGithubSettings({
4506
- workspace,
4507
- database
4508
- }) {
4509
- return operationsByTag.databases.deleteDatabaseGithubSettings({
4510
- pathParams: { workspaceId: workspace, dbName: database },
4511
- ...this.extraProps
4512
- });
3231
+ const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({
3232
+ url: "/workspaces/{workspaceId}/invites",
3233
+ method: "post",
3234
+ ...variables,
3235
+ signal
3236
+ });
3237
+ const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3238
+ url: "/workspaces/{workspaceId}/invites/{inviteId}",
3239
+ method: "patch",
3240
+ ...variables,
3241
+ signal
3242
+ });
3243
+ const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3244
+ url: "/workspaces/{workspaceId}/invites/{inviteId}",
3245
+ method: "delete",
3246
+ ...variables,
3247
+ signal
3248
+ });
3249
+ const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3250
+ url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
3251
+ method: "post",
3252
+ ...variables,
3253
+ signal
3254
+ });
3255
+ const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
3256
+ url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
3257
+ method: "post",
3258
+ ...variables,
3259
+ signal
3260
+ });
3261
+ const listClusters = (variables, signal) => controlPlaneFetch({
3262
+ url: "/workspaces/{workspaceId}/clusters",
3263
+ method: "get",
3264
+ ...variables,
3265
+ signal
3266
+ });
3267
+ const createCluster = (variables, signal) => controlPlaneFetch({
3268
+ url: "/workspaces/{workspaceId}/clusters",
3269
+ method: "post",
3270
+ ...variables,
3271
+ signal
3272
+ });
3273
+ const getCluster = (variables, signal) => controlPlaneFetch({
3274
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3275
+ method: "get",
3276
+ ...variables,
3277
+ signal
3278
+ });
3279
+ const updateCluster = (variables, signal) => controlPlaneFetch({
3280
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3281
+ method: "patch",
3282
+ ...variables,
3283
+ signal
3284
+ });
3285
+ const deleteCluster = (variables, signal) => controlPlaneFetch({
3286
+ url: "/workspaces/{workspaceId}/clusters/{clusterId}",
3287
+ method: "delete",
3288
+ ...variables,
3289
+ signal
3290
+ });
3291
+ const getDatabaseList = (variables, signal) => controlPlaneFetch({
3292
+ url: "/workspaces/{workspaceId}/dbs",
3293
+ method: "get",
3294
+ ...variables,
3295
+ signal
3296
+ });
3297
+ const createDatabase = (variables, signal) => controlPlaneFetch({
3298
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3299
+ method: "put",
3300
+ ...variables,
3301
+ signal
3302
+ });
3303
+ const deleteDatabase = (variables, signal) => controlPlaneFetch({
3304
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3305
+ method: "delete",
3306
+ ...variables,
3307
+ signal
3308
+ });
3309
+ const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({
3310
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3311
+ method: "get",
3312
+ ...variables,
3313
+ signal
3314
+ });
3315
+ const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({
3316
+ url: "/workspaces/{workspaceId}/dbs/{dbName}",
3317
+ method: "patch",
3318
+ ...variables,
3319
+ signal
3320
+ });
3321
+ const renameDatabase = (variables, signal) => controlPlaneFetch({
3322
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/rename",
3323
+ method: "post",
3324
+ ...variables,
3325
+ signal
3326
+ });
3327
+ const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3328
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3329
+ method: "get",
3330
+ ...variables,
3331
+ signal
3332
+ });
3333
+ const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3334
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3335
+ method: "put",
3336
+ ...variables,
3337
+ signal
3338
+ });
3339
+ const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
3340
+ url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
3341
+ method: "delete",
3342
+ ...variables,
3343
+ signal
3344
+ });
3345
+ const listRegions = (variables, signal) => controlPlaneFetch({
3346
+ url: "/workspaces/{workspaceId}/regions",
3347
+ method: "get",
3348
+ ...variables,
3349
+ signal
3350
+ });
3351
+ const operationsByTag$1 = {
3352
+ oAuth: {
3353
+ getAuthorizationCode,
3354
+ grantAuthorizationCode,
3355
+ getUserOAuthClients,
3356
+ deleteUserOAuthClient,
3357
+ getUserOAuthAccessTokens,
3358
+ deleteOAuthAccessToken,
3359
+ updateOAuthAccessToken
3360
+ },
3361
+ users: { getUser, updateUser, deleteUser },
3362
+ authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
3363
+ workspaces: {
3364
+ getWorkspacesList,
3365
+ createWorkspace,
3366
+ getWorkspace,
3367
+ updateWorkspace,
3368
+ deleteWorkspace,
3369
+ getWorkspaceSettings,
3370
+ updateWorkspaceSettings,
3371
+ getWorkspaceMembersList,
3372
+ updateWorkspaceMemberRole,
3373
+ removeWorkspaceMember
3374
+ },
3375
+ invites: {
3376
+ inviteWorkspaceMember,
3377
+ updateWorkspaceMemberInvite,
3378
+ cancelWorkspaceMemberInvite,
3379
+ acceptWorkspaceMemberInvite,
3380
+ resendWorkspaceMemberInvite
3381
+ },
3382
+ xbcontrolOther: {
3383
+ listClusters,
3384
+ createCluster,
3385
+ getCluster,
3386
+ updateCluster,
3387
+ deleteCluster
3388
+ },
3389
+ databases: {
3390
+ getDatabaseList,
3391
+ createDatabase,
3392
+ deleteDatabase,
3393
+ getDatabaseMetadata,
3394
+ updateDatabaseMetadata,
3395
+ renameDatabase,
3396
+ getDatabaseGithubSettings,
3397
+ updateDatabaseGithubSettings,
3398
+ deleteDatabaseGithubSettings,
3399
+ listRegions
4513
3400
  }
4514
- listRegions({ workspace }) {
4515
- return operationsByTag.databases.listRegions({
4516
- pathParams: { workspaceId: workspace },
4517
- ...this.extraProps
3401
+ };
3402
+
3403
+ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
3404
+
3405
+ const buildApiClient = () => class {
3406
+ constructor(options = {}) {
3407
+ const provider = options.host ?? "production";
3408
+ const apiKey = options.apiKey;
3409
+ const trace = options.trace ?? defaultTrace;
3410
+ const clientID = generateUUID();
3411
+ if (!apiKey) {
3412
+ throw new Error("Could not resolve a valid apiKey");
3413
+ }
3414
+ const extraProps = {
3415
+ apiUrl: getHostUrl(provider, "main"),
3416
+ workspacesApiUrl: getHostUrl(provider, "workspaces"),
3417
+ fetch: getFetchImplementation(options.fetch),
3418
+ apiKey,
3419
+ trace,
3420
+ clientName: options.clientName,
3421
+ xataAgentExtra: options.xataAgentExtra,
3422
+ clientID
3423
+ };
3424
+ return new Proxy(this, {
3425
+ get: (_target, namespace) => {
3426
+ if (operationsByTag[namespace] === void 0) {
3427
+ return void 0;
3428
+ }
3429
+ return new Proxy(
3430
+ {},
3431
+ {
3432
+ get: (_target2, operation) => {
3433
+ if (operationsByTag[namespace][operation] === void 0) {
3434
+ return void 0;
3435
+ }
3436
+ const method = operationsByTag[namespace][operation];
3437
+ return async (params) => {
3438
+ return await method({ ...params, ...extraProps });
3439
+ };
3440
+ }
3441
+ }
3442
+ );
3443
+ }
4518
3444
  });
4519
3445
  }
3446
+ };
3447
+ class XataApiClient extends buildApiClient() {
4520
3448
  }
4521
3449
 
4522
3450
  class XataApiPlugin {
@@ -4544,8 +3472,7 @@ function buildTransformString(transformations) {
4544
3472
  ).join(",");
4545
3473
  }
4546
3474
  function transformImage(url, ...transformations) {
4547
- if (!isDefined(url))
4548
- return void 0;
3475
+ if (!isDefined(url)) return void 0;
4549
3476
  const newTransformations = buildTransformString(transformations);
4550
3477
  const { hostname, pathname, search } = new URL(url);
4551
3478
  const pathParts = pathname.split("/");
@@ -4658,8 +3585,7 @@ class XataFile {
4658
3585
  }
4659
3586
  }
4660
3587
  const parseInputFileEntry = async (entry) => {
4661
- if (!isDefined(entry))
4662
- return null;
3588
+ if (!isDefined(entry)) return null;
4663
3589
  const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
4664
3590
  return compactObject({
4665
3591
  id,
@@ -4674,24 +3600,19 @@ const parseInputFileEntry = async (entry) => {
4674
3600
  };
4675
3601
 
4676
3602
  function cleanFilter(filter) {
4677
- if (!isDefined(filter))
4678
- return void 0;
4679
- if (!isObject(filter))
4680
- return filter;
3603
+ if (!isDefined(filter)) return void 0;
3604
+ if (!isObject(filter)) return filter;
4681
3605
  const values = Object.fromEntries(
4682
3606
  Object.entries(filter).reduce((acc, [key, value]) => {
4683
- if (!isDefined(value))
4684
- return acc;
3607
+ if (!isDefined(value)) return acc;
4685
3608
  if (Array.isArray(value)) {
4686
3609
  const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
4687
- if (clean.length === 0)
4688
- return acc;
3610
+ if (clean.length === 0) return acc;
4689
3611
  return [...acc, [key, clean]];
4690
3612
  }
4691
3613
  if (isObject(value)) {
4692
3614
  const clean = cleanFilter(value);
4693
- if (!isDefined(clean))
4694
- return acc;
3615
+ if (!isDefined(clean)) return acc;
4695
3616
  return [...acc, [key, clean]];
4696
3617
  }
4697
3618
  return [...acc, [key, value]];
@@ -4701,10 +3622,8 @@ function cleanFilter(filter) {
4701
3622
  }
4702
3623
 
4703
3624
  function stringifyJson(value) {
4704
- if (!isDefined(value))
4705
- return value;
4706
- if (isString(value))
4707
- return value;
3625
+ if (!isDefined(value)) return value;
3626
+ if (isString(value)) return value;
4708
3627
  try {
4709
3628
  return JSON.stringify(value);
4710
3629
  } catch (e) {
@@ -4719,29 +3638,18 @@ function parseJson(value) {
4719
3638
  }
4720
3639
  }
4721
3640
 
4722
- var __accessCheck$6 = (obj, member, msg) => {
4723
- if (!member.has(obj))
4724
- throw TypeError("Cannot " + msg);
4725
- };
4726
- var __privateGet$5 = (obj, member, getter) => {
4727
- __accessCheck$6(obj, member, "read from private field");
4728
- return getter ? getter.call(obj) : member.get(obj);
4729
- };
4730
- var __privateAdd$6 = (obj, member, value) => {
4731
- if (member.has(obj))
4732
- throw TypeError("Cannot add the same private member more than once");
4733
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4734
- };
4735
- var __privateSet$4 = (obj, member, value, setter) => {
4736
- __accessCheck$6(obj, member, "write to private field");
4737
- setter ? setter.call(obj, value) : member.set(obj, value);
4738
- return value;
3641
+ var __typeError$5 = (msg) => {
3642
+ throw TypeError(msg);
4739
3643
  };
3644
+ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
3645
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
3646
+ 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);
3647
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
4740
3648
  var _query, _page;
4741
3649
  class Page {
4742
3650
  constructor(query, meta, records = []) {
4743
- __privateAdd$6(this, _query, void 0);
4744
- __privateSet$4(this, _query, query);
3651
+ __privateAdd$5(this, _query);
3652
+ __privateSet$3(this, _query, query);
4745
3653
  this.meta = meta;
4746
3654
  this.records = new PageRecordArray(this, records);
4747
3655
  }
@@ -4752,7 +3660,7 @@ class Page {
4752
3660
  * @returns The next page or results.
4753
3661
  */
4754
3662
  async nextPage(size, offset) {
4755
- return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
3663
+ return __privateGet$4(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
4756
3664
  }
4757
3665
  /**
4758
3666
  * Retrieves the previous page of results.
@@ -4761,7 +3669,7 @@ class Page {
4761
3669
  * @returns The previous page or results.
4762
3670
  */
4763
3671
  async previousPage(size, offset) {
4764
- return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
3672
+ return __privateGet$4(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
4765
3673
  }
4766
3674
  /**
4767
3675
  * Retrieves the start page of results.
@@ -4770,7 +3678,7 @@ class Page {
4770
3678
  * @returns The start page or results.
4771
3679
  */
4772
3680
  async startPage(size, offset) {
4773
- return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
3681
+ return __privateGet$4(this, _query).getPaginated({ pagination: { size, offset, start: this.meta.page.cursor } });
4774
3682
  }
4775
3683
  /**
4776
3684
  * Retrieves the end page of results.
@@ -4779,7 +3687,7 @@ class Page {
4779
3687
  * @returns The end page or results.
4780
3688
  */
4781
3689
  async endPage(size, offset) {
4782
- return __privateGet$5(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
3690
+ return __privateGet$4(this, _query).getPaginated({ pagination: { size, offset, end: this.meta.page.cursor } });
4783
3691
  }
4784
3692
  /**
4785
3693
  * Shortcut method to check if there will be additional results if the next page of results is retrieved.
@@ -4827,8 +3735,8 @@ class RecordArray extends Array {
4827
3735
  const _PageRecordArray = class _PageRecordArray extends Array {
4828
3736
  constructor(...args) {
4829
3737
  super(..._PageRecordArray.parseConstructorParams(...args));
4830
- __privateAdd$6(this, _page, void 0);
4831
- __privateSet$4(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
3738
+ __privateAdd$5(this, _page);
3739
+ __privateSet$3(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
4832
3740
  }
4833
3741
  static parseConstructorParams(...args) {
4834
3742
  if (args.length === 1 && typeof args[0] === "number") {
@@ -4858,7 +3766,7 @@ const _PageRecordArray = class _PageRecordArray extends Array {
4858
3766
  * @returns A new array of objects
4859
3767
  */
4860
3768
  async nextPage(size, offset) {
4861
- const newPage = await __privateGet$5(this, _page).nextPage(size, offset);
3769
+ const newPage = await __privateGet$4(this, _page).nextPage(size, offset);
4862
3770
  return new _PageRecordArray(newPage);
4863
3771
  }
4864
3772
  /**
@@ -4867,7 +3775,7 @@ const _PageRecordArray = class _PageRecordArray extends Array {
4867
3775
  * @returns A new array of objects
4868
3776
  */
4869
3777
  async previousPage(size, offset) {
4870
- const newPage = await __privateGet$5(this, _page).previousPage(size, offset);
3778
+ const newPage = await __privateGet$4(this, _page).previousPage(size, offset);
4871
3779
  return new _PageRecordArray(newPage);
4872
3780
  }
4873
3781
  /**
@@ -4876,7 +3784,7 @@ const _PageRecordArray = class _PageRecordArray extends Array {
4876
3784
  * @returns A new array of objects
4877
3785
  */
4878
3786
  async startPage(size, offset) {
4879
- const newPage = await __privateGet$5(this, _page).startPage(size, offset);
3787
+ const newPage = await __privateGet$4(this, _page).startPage(size, offset);
4880
3788
  return new _PageRecordArray(newPage);
4881
3789
  }
4882
3790
  /**
@@ -4885,69 +3793,54 @@ const _PageRecordArray = class _PageRecordArray extends Array {
4885
3793
  * @returns A new array of objects
4886
3794
  */
4887
3795
  async endPage(size, offset) {
4888
- const newPage = await __privateGet$5(this, _page).endPage(size, offset);
3796
+ const newPage = await __privateGet$4(this, _page).endPage(size, offset);
4889
3797
  return new _PageRecordArray(newPage);
4890
3798
  }
4891
3799
  /**
4892
3800
  * @returns Boolean indicating if there is a next page
4893
3801
  */
4894
3802
  hasNextPage() {
4895
- return __privateGet$5(this, _page).meta.page.more;
3803
+ return __privateGet$4(this, _page).meta.page.more;
4896
3804
  }
4897
3805
  };
4898
3806
  _page = new WeakMap();
4899
3807
  let PageRecordArray = _PageRecordArray;
4900
3808
 
4901
- var __accessCheck$5 = (obj, member, msg) => {
4902
- if (!member.has(obj))
4903
- throw TypeError("Cannot " + msg);
4904
- };
4905
- var __privateGet$4 = (obj, member, getter) => {
4906
- __accessCheck$5(obj, member, "read from private field");
4907
- return getter ? getter.call(obj) : member.get(obj);
4908
- };
4909
- var __privateAdd$5 = (obj, member, value) => {
4910
- if (member.has(obj))
4911
- throw TypeError("Cannot add the same private member more than once");
4912
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3809
+ var __typeError$4 = (msg) => {
3810
+ throw TypeError(msg);
4913
3811
  };
4914
- var __privateSet$3 = (obj, member, value, setter) => {
4915
- __accessCheck$5(obj, member, "write to private field");
4916
- setter ? setter.call(obj, value) : member.set(obj, value);
4917
- return value;
4918
- };
4919
- var __privateMethod$3 = (obj, member, method) => {
4920
- __accessCheck$5(obj, member, "access private method");
4921
- return method;
4922
- };
4923
- var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
3812
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
3813
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
3814
+ 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);
3815
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
3816
+ var __privateMethod$3 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
3817
+ var _table$1, _repository, _data, _Query_instances, cleanFilterConstraint_fn;
4924
3818
  const _Query = class _Query {
4925
3819
  constructor(repository, table, data, rawParent) {
4926
- __privateAdd$5(this, _cleanFilterConstraint);
4927
- __privateAdd$5(this, _table$1, void 0);
4928
- __privateAdd$5(this, _repository, void 0);
4929
- __privateAdd$5(this, _data, { filter: {} });
3820
+ __privateAdd$4(this, _Query_instances);
3821
+ __privateAdd$4(this, _table$1);
3822
+ __privateAdd$4(this, _repository);
3823
+ __privateAdd$4(this, _data, { filter: {} });
4930
3824
  // Implements pagination
4931
3825
  this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
4932
3826
  this.records = new PageRecordArray(this, []);
4933
- __privateSet$3(this, _table$1, table);
3827
+ __privateSet$2(this, _table$1, table);
4934
3828
  if (repository) {
4935
- __privateSet$3(this, _repository, repository);
3829
+ __privateSet$2(this, _repository, repository);
4936
3830
  } else {
4937
- __privateSet$3(this, _repository, this);
3831
+ __privateSet$2(this, _repository, this);
4938
3832
  }
4939
3833
  const parent = cleanParent(data, rawParent);
4940
- __privateGet$4(this, _data).filter = data.filter ?? parent?.filter ?? {};
4941
- __privateGet$4(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
4942
- __privateGet$4(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
4943
- __privateGet$4(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
4944
- __privateGet$4(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
4945
- __privateGet$4(this, _data).sort = data.sort ?? parent?.sort;
4946
- __privateGet$4(this, _data).columns = data.columns ?? parent?.columns;
4947
- __privateGet$4(this, _data).consistency = data.consistency ?? parent?.consistency;
4948
- __privateGet$4(this, _data).pagination = data.pagination ?? parent?.pagination;
4949
- __privateGet$4(this, _data).cache = data.cache ?? parent?.cache;
4950
- __privateGet$4(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
3834
+ __privateGet$3(this, _data).filter = data.filter ?? parent?.filter ?? {};
3835
+ __privateGet$3(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
3836
+ __privateGet$3(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
3837
+ __privateGet$3(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
3838
+ __privateGet$3(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
3839
+ __privateGet$3(this, _data).sort = data.sort ?? parent?.sort;
3840
+ __privateGet$3(this, _data).columns = data.columns ?? parent?.columns;
3841
+ __privateGet$3(this, _data).consistency = data.consistency ?? parent?.consistency;
3842
+ __privateGet$3(this, _data).pagination = data.pagination ?? parent?.pagination;
3843
+ __privateGet$3(this, _data).fetchOptions = data.fetchOptions ?? parent?.fetchOptions;
4951
3844
  this.any = this.any.bind(this);
4952
3845
  this.all = this.all.bind(this);
4953
3846
  this.not = this.not.bind(this);
@@ -4958,10 +3851,10 @@ const _Query = class _Query {
4958
3851
  Object.defineProperty(this, "repository", { enumerable: false });
4959
3852
  }
4960
3853
  getQueryOptions() {
4961
- return __privateGet$4(this, _data);
3854
+ return __privateGet$3(this, _data);
4962
3855
  }
4963
3856
  key() {
4964
- const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$4(this, _data);
3857
+ const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$3(this, _data);
4965
3858
  const key = JSON.stringify({ columns, filter, sort, pagination });
4966
3859
  return toBase64(key);
4967
3860
  }
@@ -4972,7 +3865,7 @@ const _Query = class _Query {
4972
3865
  */
4973
3866
  any(...queries) {
4974
3867
  const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
4975
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $any } }, __privateGet$4(this, _data));
3868
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $any } }, __privateGet$3(this, _data));
4976
3869
  }
4977
3870
  /**
4978
3871
  * Builds a new query object representing a logical AND between the given subqueries.
@@ -4981,7 +3874,7 @@ const _Query = class _Query {
4981
3874
  */
4982
3875
  all(...queries) {
4983
3876
  const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
4984
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3877
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
4985
3878
  }
4986
3879
  /**
4987
3880
  * Builds a new query object representing a logical OR negating each subquery. In pseudo-code: !q1 OR !q2
@@ -4990,7 +3883,7 @@ const _Query = class _Query {
4990
3883
  */
4991
3884
  not(...queries) {
4992
3885
  const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
4993
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $not } }, __privateGet$4(this, _data));
3886
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $not } }, __privateGet$3(this, _data));
4994
3887
  }
4995
3888
  /**
4996
3889
  * Builds a new query object representing a logical AND negating each subquery. In pseudo-code: !q1 AND !q2
@@ -4999,25 +3892,25 @@ const _Query = class _Query {
4999
3892
  */
5000
3893
  none(...queries) {
5001
3894
  const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
5002
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $none } }, __privateGet$4(this, _data));
3895
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $none } }, __privateGet$3(this, _data));
5003
3896
  }
5004
3897
  filter(a, b) {
5005
3898
  if (arguments.length === 1) {
5006
3899
  const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
5007
- [column]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, column, constraint)
3900
+ [column]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, column, constraint)
5008
3901
  }));
5009
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
5010
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3902
+ const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
3903
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
5011
3904
  } else {
5012
- const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _cleanFilterConstraint, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
5013
- const $all = compact([__privateGet$4(this, _data).filter?.$all].flat().concat(constraints));
5014
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { filter: { $all } }, __privateGet$4(this, _data));
3905
+ const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
3906
+ const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
3907
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
5015
3908
  }
5016
3909
  }
5017
3910
  sort(column, direction = "asc") {
5018
- const originalSort = [__privateGet$4(this, _data).sort ?? []].flat();
3911
+ const originalSort = [__privateGet$3(this, _data).sort ?? []].flat();
5019
3912
  const sort = [...originalSort, { column, direction }];
5020
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { sort }, __privateGet$4(this, _data));
3913
+ return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { sort }, __privateGet$3(this, _data));
5021
3914
  }
5022
3915
  /**
5023
3916
  * Builds a new query specifying the set of columns to be returned in the query response.
@@ -5026,15 +3919,15 @@ const _Query = class _Query {
5026
3919
  */
5027
3920
  select(columns) {
5028
3921
  return new _Query(
5029
- __privateGet$4(this, _repository),
5030
- __privateGet$4(this, _table$1),
3922
+ __privateGet$3(this, _repository),
3923
+ __privateGet$3(this, _table$1),
5031
3924
  { columns },
5032
- __privateGet$4(this, _data)
3925
+ __privateGet$3(this, _data)
5033
3926
  );
5034
3927
  }
5035
3928
  getPaginated(options = {}) {
5036
- const query = new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), options, __privateGet$4(this, _data));
5037
- return __privateGet$4(this, _repository).query(query);
3929
+ const query = new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), options, __privateGet$3(this, _data));
3930
+ return __privateGet$3(this, _repository).query(query);
5038
3931
  }
5039
3932
  /**
5040
3933
  * Get results in an iterator
@@ -5088,27 +3981,18 @@ const _Query = class _Query {
5088
3981
  }
5089
3982
  async getFirstOrThrow(options = {}) {
5090
3983
  const records = await this.getMany({ ...options, pagination: { size: 1 } });
5091
- if (records[0] === void 0)
5092
- throw new Error("No results found.");
3984
+ if (records[0] === void 0) throw new Error("No results found.");
5093
3985
  return records[0];
5094
3986
  }
5095
3987
  async summarize(params = {}) {
5096
3988
  const { summaries, summariesFilter, ...options } = params;
5097
3989
  const query = new _Query(
5098
- __privateGet$4(this, _repository),
5099
- __privateGet$4(this, _table$1),
3990
+ __privateGet$3(this, _repository),
3991
+ __privateGet$3(this, _table$1),
5100
3992
  options,
5101
- __privateGet$4(this, _data)
3993
+ __privateGet$3(this, _data)
5102
3994
  );
5103
- return __privateGet$4(this, _repository).summarizeTable(query, summaries, summariesFilter);
5104
- }
5105
- /**
5106
- * Builds a new query object adding a cache TTL in milliseconds.
5107
- * @param ttl The cache TTL in milliseconds.
5108
- * @returns A new Query object.
5109
- */
5110
- cache(ttl) {
5111
- return new _Query(__privateGet$4(this, _repository), __privateGet$4(this, _table$1), { cache: ttl }, __privateGet$4(this, _data));
3995
+ return __privateGet$3(this, _repository).summarizeTable(query, summaries, summariesFilter);
5112
3996
  }
5113
3997
  /**
5114
3998
  * Retrieve next page of records
@@ -5152,14 +4036,14 @@ const _Query = class _Query {
5152
4036
  _table$1 = new WeakMap();
5153
4037
  _repository = new WeakMap();
5154
4038
  _data = new WeakMap();
5155
- _cleanFilterConstraint = new WeakSet();
4039
+ _Query_instances = new WeakSet();
5156
4040
  cleanFilterConstraint_fn = function(column, value) {
5157
- const columnType = __privateGet$4(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
4041
+ const columnType = __privateGet$3(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
5158
4042
  if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
5159
4043
  return { $includes: value };
5160
4044
  }
5161
- if (columnType === "link" && isObject(value) && isString(value.id)) {
5162
- return value.id;
4045
+ if (columnType === "link" && isObject(value) && isString(value.xata_id)) {
4046
+ return value.xata_id;
5163
4047
  }
5164
4048
  return value;
5165
4049
  };
@@ -5187,12 +4071,7 @@ const RecordColumnTypes = [
5187
4071
  "json"
5188
4072
  ];
5189
4073
  function isIdentifiable(x) {
5190
- return isObject(x) && isString(x?.id);
5191
- }
5192
- function isXataRecord(x) {
5193
- const record = x;
5194
- const metadata = record?.getMetadata();
5195
- return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
4074
+ return isObject(x) && isString(x?.xata_id);
5196
4075
  }
5197
4076
 
5198
4077
  function isValidExpandedColumn(column) {
@@ -5218,8 +4097,7 @@ function isSortFilterString(value) {
5218
4097
  }
5219
4098
  function isSortFilterBase(filter) {
5220
4099
  return isObject(filter) && Object.entries(filter).every(([key, value]) => {
5221
- if (key === "*")
5222
- return value === "random";
4100
+ if (key === "*") return value === "random";
5223
4101
  return value === "asc" || value === "desc";
5224
4102
  });
5225
4103
  }
@@ -5240,29 +4118,15 @@ function buildSortFilter(filter) {
5240
4118
  }
5241
4119
  }
5242
4120
 
5243
- var __accessCheck$4 = (obj, member, msg) => {
5244
- if (!member.has(obj))
5245
- throw TypeError("Cannot " + msg);
5246
- };
5247
- var __privateGet$3 = (obj, member, getter) => {
5248
- __accessCheck$4(obj, member, "read from private field");
5249
- return getter ? getter.call(obj) : member.get(obj);
5250
- };
5251
- var __privateAdd$4 = (obj, member, value) => {
5252
- if (member.has(obj))
5253
- throw TypeError("Cannot add the same private member more than once");
5254
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5255
- };
5256
- var __privateSet$2 = (obj, member, value, setter) => {
5257
- __accessCheck$4(obj, member, "write to private field");
5258
- setter ? setter.call(obj, value) : member.set(obj, value);
5259
- return value;
4121
+ var __typeError$3 = (msg) => {
4122
+ throw TypeError(msg);
5260
4123
  };
5261
- var __privateMethod$2 = (obj, member, method) => {
5262
- __accessCheck$4(obj, member, "access private method");
5263
- return method;
5264
- };
5265
- var _table, _getFetchProps, _db, _cache, _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, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
4124
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
4125
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
4126
+ 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);
4127
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
4128
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
4129
+ 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;
5266
4130
  const BULK_OPERATION_MAX_SIZE = 1e3;
5267
4131
  class Repository extends Query {
5268
4132
  }
@@ -5273,79 +4137,65 @@ class RestRepository extends Query {
5273
4137
  { name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
5274
4138
  {}
5275
4139
  );
5276
- __privateAdd$4(this, _insertRecordWithoutId);
5277
- __privateAdd$4(this, _insertRecordWithId);
5278
- __privateAdd$4(this, _insertRecords);
5279
- __privateAdd$4(this, _updateRecordWithID);
5280
- __privateAdd$4(this, _updateRecords);
5281
- __privateAdd$4(this, _upsertRecordWithID);
5282
- __privateAdd$4(this, _deleteRecord);
5283
- __privateAdd$4(this, _deleteRecords);
5284
- __privateAdd$4(this, _setCacheQuery);
5285
- __privateAdd$4(this, _getCacheQuery);
5286
- __privateAdd$4(this, _getSchemaTables);
5287
- __privateAdd$4(this, _transformObjectToApi);
5288
- __privateAdd$4(this, _table, void 0);
5289
- __privateAdd$4(this, _getFetchProps, void 0);
5290
- __privateAdd$4(this, _db, void 0);
5291
- __privateAdd$4(this, _cache, void 0);
5292
- __privateAdd$4(this, _schemaTables, void 0);
5293
- __privateAdd$4(this, _trace, void 0);
5294
- __privateSet$2(this, _table, options.table);
5295
- __privateSet$2(this, _db, options.db);
5296
- __privateSet$2(this, _cache, options.pluginOptions.cache);
5297
- __privateSet$2(this, _schemaTables, options.schemaTables);
5298
- __privateSet$2(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
4140
+ __privateAdd$3(this, _RestRepository_instances);
4141
+ __privateAdd$3(this, _table);
4142
+ __privateAdd$3(this, _getFetchProps);
4143
+ __privateAdd$3(this, _db);
4144
+ __privateAdd$3(this, _schemaTables);
4145
+ __privateAdd$3(this, _trace);
4146
+ __privateSet$1(this, _table, options.table);
4147
+ __privateSet$1(this, _db, options.db);
4148
+ __privateSet$1(this, _schemaTables, options.schemaTables);
4149
+ __privateSet$1(this, _getFetchProps, () => ({ ...options.pluginOptions, sessionID: generateUUID() }));
5299
4150
  const trace = options.pluginOptions.trace ?? defaultTrace;
5300
- __privateSet$2(this, _trace, async (name, fn, options2 = {}) => {
4151
+ __privateSet$1(this, _trace, async (name, fn, options2 = {}) => {
5301
4152
  return trace(name, fn, {
5302
4153
  ...options2,
5303
- [TraceAttributes.TABLE]: __privateGet$3(this, _table),
4154
+ [TraceAttributes.TABLE]: __privateGet$2(this, _table),
5304
4155
  [TraceAttributes.KIND]: "sdk-operation",
5305
4156
  [TraceAttributes.VERSION]: VERSION
5306
4157
  });
5307
4158
  });
5308
4159
  }
5309
4160
  async create(a, b, c, d) {
5310
- return __privateGet$3(this, _trace).call(this, "create", async () => {
4161
+ return __privateGet$2(this, _trace).call(this, "create", async () => {
5311
4162
  const ifVersion = parseIfVersion(b, c, d);
5312
4163
  if (Array.isArray(a)) {
5313
- if (a.length === 0)
5314
- return [];
5315
- const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
4164
+ if (a.length === 0) return [];
4165
+ const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
5316
4166
  const columns = isValidSelectableColumns(b) ? b : ["*"];
5317
4167
  const result = await this.read(ids, columns);
5318
4168
  return result;
5319
4169
  }
5320
4170
  if (isString(a) && isObject(b)) {
5321
- if (a === "")
5322
- throw new Error("The id can't be empty");
4171
+ if (a === "") throw new Error("The id can't be empty");
5323
4172
  const columns = isValidSelectableColumns(c) ? c : void 0;
5324
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
4173
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
5325
4174
  }
5326
- if (isObject(a) && isString(a.id)) {
5327
- if (a.id === "")
5328
- throw new Error("The id can't be empty");
4175
+ if (isObject(a) && isString(a.xata_id)) {
4176
+ if (a.xata_id === "") throw new Error("The id can't be empty");
5329
4177
  const columns = isValidSelectableColumns(b) ? b : void 0;
5330
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: true, ifVersion });
4178
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4179
+ createOnly: true,
4180
+ ifVersion
4181
+ });
5331
4182
  }
5332
4183
  if (isObject(a)) {
5333
4184
  const columns = isValidSelectableColumns(b) ? b : void 0;
5334
- return __privateMethod$2(this, _insertRecordWithoutId, insertRecordWithoutId_fn).call(this, a, columns);
4185
+ return __privateMethod$2(this, _RestRepository_instances, insertRecordWithoutId_fn).call(this, a, columns);
5335
4186
  }
5336
4187
  throw new Error("Invalid arguments for create method");
5337
4188
  });
5338
4189
  }
5339
4190
  async read(a, b) {
5340
- return __privateGet$3(this, _trace).call(this, "read", async () => {
4191
+ return __privateGet$2(this, _trace).call(this, "read", async () => {
5341
4192
  const columns = isValidSelectableColumns(b) ? b : ["*"];
5342
4193
  if (Array.isArray(a)) {
5343
- if (a.length === 0)
5344
- return [];
4194
+ if (a.length === 0) return [];
5345
4195
  const ids = a.map((item) => extractId(item));
5346
- const finalObjects = await this.getAll({ filter: { id: { $any: compact(ids) } }, columns });
4196
+ const finalObjects = await this.getAll({ filter: { xata_id: { $any: compact(ids) } }, columns });
5347
4197
  const dictionary = finalObjects.reduce((acc, object) => {
5348
- acc[object.id] = object;
4198
+ acc[object.xata_id] = object;
5349
4199
  return acc;
5350
4200
  }, {});
5351
4201
  return ids.map((id2) => dictionary[id2 ?? ""] ?? null);
@@ -5358,17 +4208,17 @@ class RestRepository extends Query {
5358
4208
  workspace: "{workspaceId}",
5359
4209
  dbBranchName: "{dbBranch}",
5360
4210
  region: "{region}",
5361
- tableName: __privateGet$3(this, _table),
4211
+ tableName: __privateGet$2(this, _table),
5362
4212
  recordId: id
5363
4213
  },
5364
4214
  queryParams: { columns },
5365
- ...__privateGet$3(this, _getFetchProps).call(this)
4215
+ ...__privateGet$2(this, _getFetchProps).call(this)
5366
4216
  });
5367
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4217
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
5368
4218
  return initObject(
5369
- __privateGet$3(this, _db),
4219
+ __privateGet$2(this, _db),
5370
4220
  schemaTables,
5371
- __privateGet$3(this, _table),
4221
+ __privateGet$2(this, _table),
5372
4222
  response,
5373
4223
  columns
5374
4224
  );
@@ -5383,7 +4233,7 @@ class RestRepository extends Query {
5383
4233
  });
5384
4234
  }
5385
4235
  async readOrThrow(a, b) {
5386
- return __privateGet$3(this, _trace).call(this, "readOrThrow", async () => {
4236
+ return __privateGet$2(this, _trace).call(this, "readOrThrow", async () => {
5387
4237
  const result = await this.read(a, b);
5388
4238
  if (Array.isArray(result)) {
5389
4239
  const missingIds = compact(
@@ -5402,14 +4252,13 @@ class RestRepository extends Query {
5402
4252
  });
5403
4253
  }
5404
4254
  async update(a, b, c, d) {
5405
- return __privateGet$3(this, _trace).call(this, "update", async () => {
4255
+ return __privateGet$2(this, _trace).call(this, "update", async () => {
5406
4256
  const ifVersion = parseIfVersion(b, c, d);
5407
4257
  if (Array.isArray(a)) {
5408
- if (a.length === 0)
5409
- return [];
5410
- const existing = await this.read(a, ["id"]);
4258
+ if (a.length === 0) return [];
4259
+ const existing = await this.read(a, ["xata_id"]);
5411
4260
  const updates = a.filter((_item, index) => existing[index] !== null);
5412
- await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, updates, {
4261
+ await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, updates, {
5413
4262
  ifVersion,
5414
4263
  upsert: false
5415
4264
  });
@@ -5420,22 +4269,21 @@ class RestRepository extends Query {
5420
4269
  try {
5421
4270
  if (isString(a) && isObject(b)) {
5422
4271
  const columns = isValidSelectableColumns(c) ? c : void 0;
5423
- return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4272
+ return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
5424
4273
  }
5425
- if (isObject(a) && isString(a.id)) {
4274
+ if (isObject(a) && isString(a.xata_id)) {
5426
4275
  const columns = isValidSelectableColumns(b) ? b : void 0;
5427
- return await __privateMethod$2(this, _updateRecordWithID, updateRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
4276
+ return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
5428
4277
  }
5429
4278
  } catch (error) {
5430
- if (error.status === 422)
5431
- return null;
4279
+ if (error.status === 422) return null;
5432
4280
  throw error;
5433
4281
  }
5434
4282
  throw new Error("Invalid arguments for update method");
5435
4283
  });
5436
4284
  }
5437
4285
  async updateOrThrow(a, b, c, d) {
5438
- return __privateGet$3(this, _trace).call(this, "updateOrThrow", async () => {
4286
+ return __privateGet$2(this, _trace).call(this, "updateOrThrow", async () => {
5439
4287
  const result = await this.update(a, b, c, d);
5440
4288
  if (Array.isArray(result)) {
5441
4289
  const missingIds = compact(
@@ -5454,12 +4302,11 @@ class RestRepository extends Query {
5454
4302
  });
5455
4303
  }
5456
4304
  async createOrUpdate(a, b, c, d) {
5457
- return __privateGet$3(this, _trace).call(this, "createOrUpdate", async () => {
4305
+ return __privateGet$2(this, _trace).call(this, "createOrUpdate", async () => {
5458
4306
  const ifVersion = parseIfVersion(b, c, d);
5459
4307
  if (Array.isArray(a)) {
5460
- if (a.length === 0)
5461
- return [];
5462
- await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
4308
+ if (a.length === 0) return [];
4309
+ await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, a, {
5463
4310
  ifVersion,
5464
4311
  upsert: true
5465
4312
  });
@@ -5468,86 +4315,81 @@ class RestRepository extends Query {
5468
4315
  return result;
5469
4316
  }
5470
4317
  if (isString(a) && isObject(b)) {
5471
- if (a === "")
5472
- throw new Error("The id can't be empty");
4318
+ if (a === "") throw new Error("The id can't be empty");
5473
4319
  const columns = isValidSelectableColumns(c) ? c : void 0;
5474
- return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
4320
+ return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
5475
4321
  }
5476
- if (isObject(a) && isString(a.id)) {
5477
- if (a.id === "")
5478
- throw new Error("The id can't be empty");
4322
+ if (isObject(a) && isString(a.xata_id)) {
4323
+ if (a.xata_id === "") throw new Error("The id can't be empty");
5479
4324
  const columns = isValidSelectableColumns(c) ? c : void 0;
5480
- return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
4325
+ return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
5481
4326
  }
5482
4327
  if (!isDefined(a) && isObject(b)) {
5483
4328
  return await this.create(b, c);
5484
4329
  }
5485
- if (isObject(a) && !isDefined(a.id)) {
4330
+ if (isObject(a) && !isDefined(a.xata_id)) {
5486
4331
  return await this.create(a, b);
5487
4332
  }
5488
4333
  throw new Error("Invalid arguments for createOrUpdate method");
5489
4334
  });
5490
4335
  }
5491
4336
  async createOrReplace(a, b, c, d) {
5492
- return __privateGet$3(this, _trace).call(this, "createOrReplace", async () => {
4337
+ return __privateGet$2(this, _trace).call(this, "createOrReplace", async () => {
5493
4338
  const ifVersion = parseIfVersion(b, c, d);
5494
4339
  if (Array.isArray(a)) {
5495
- if (a.length === 0)
5496
- return [];
5497
- const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
4340
+ if (a.length === 0) return [];
4341
+ const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
5498
4342
  const columns = isValidSelectableColumns(b) ? b : ["*"];
5499
4343
  const result = await this.read(ids, columns);
5500
4344
  return result;
5501
4345
  }
5502
4346
  if (isString(a) && isObject(b)) {
5503
- if (a === "")
5504
- throw new Error("The id can't be empty");
4347
+ if (a === "") throw new Error("The id can't be empty");
5505
4348
  const columns = isValidSelectableColumns(c) ? c : void 0;
5506
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
4349
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
5507
4350
  }
5508
- if (isObject(a) && isString(a.id)) {
5509
- if (a.id === "")
5510
- throw new Error("The id can't be empty");
4351
+ if (isObject(a) && isString(a.xata_id)) {
4352
+ if (a.xata_id === "") throw new Error("The id can't be empty");
5511
4353
  const columns = isValidSelectableColumns(c) ? c : void 0;
5512
- return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
4354
+ return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
4355
+ createOnly: false,
4356
+ ifVersion
4357
+ });
5513
4358
  }
5514
4359
  if (!isDefined(a) && isObject(b)) {
5515
4360
  return await this.create(b, c);
5516
4361
  }
5517
- if (isObject(a) && !isDefined(a.id)) {
4362
+ if (isObject(a) && !isDefined(a.xata_id)) {
5518
4363
  return await this.create(a, b);
5519
4364
  }
5520
4365
  throw new Error("Invalid arguments for createOrReplace method");
5521
4366
  });
5522
4367
  }
5523
4368
  async delete(a, b) {
5524
- return __privateGet$3(this, _trace).call(this, "delete", async () => {
4369
+ return __privateGet$2(this, _trace).call(this, "delete", async () => {
5525
4370
  if (Array.isArray(a)) {
5526
- if (a.length === 0)
5527
- return [];
4371
+ if (a.length === 0) return [];
5528
4372
  const ids = a.map((o) => {
5529
- if (isString(o))
5530
- return o;
5531
- if (isString(o.id))
5532
- return o.id;
4373
+ if (isString(o)) return o;
4374
+ if (isString(o.xata_id)) return o.xata_id;
5533
4375
  throw new Error("Invalid arguments for delete method");
5534
4376
  });
5535
4377
  const columns = isValidSelectableColumns(b) ? b : ["*"];
5536
4378
  const result = await this.read(a, columns);
5537
- await __privateMethod$2(this, _deleteRecords, deleteRecords_fn).call(this, ids);
4379
+ await __privateMethod$2(this, _RestRepository_instances, deleteRecords_fn).call(this, ids);
5538
4380
  return result;
5539
4381
  }
5540
4382
  if (isString(a)) {
5541
- return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a, b);
4383
+ return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a, b);
5542
4384
  }
5543
- if (isObject(a) && isString(a.id)) {
5544
- return __privateMethod$2(this, _deleteRecord, deleteRecord_fn).call(this, a.id, b);
4385
+ if (isObject(a) && isString(a.xata_id)) {
4386
+ return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a.xata_id, b);
5545
4387
  }
5546
4388
  throw new Error("Invalid arguments for delete method");
5547
4389
  });
5548
4390
  }
5549
4391
  async deleteOrThrow(a, b) {
5550
- return __privateGet$3(this, _trace).call(this, "deleteOrThrow", async () => {
4392
+ return __privateGet$2(this, _trace).call(this, "deleteOrThrow", async () => {
5551
4393
  const result = await this.delete(a, b);
5552
4394
  if (Array.isArray(result)) {
5553
4395
  const missingIds = compact(
@@ -5565,13 +4407,13 @@ class RestRepository extends Query {
5565
4407
  });
5566
4408
  }
5567
4409
  async search(query, options = {}) {
5568
- return __privateGet$3(this, _trace).call(this, "search", async () => {
4410
+ return __privateGet$2(this, _trace).call(this, "search", async () => {
5569
4411
  const { records, totalCount } = await searchTable({
5570
4412
  pathParams: {
5571
4413
  workspace: "{workspaceId}",
5572
4414
  dbBranchName: "{dbBranch}",
5573
4415
  region: "{region}",
5574
- tableName: __privateGet$3(this, _table)
4416
+ tableName: __privateGet$2(this, _table)
5575
4417
  },
5576
4418
  body: {
5577
4419
  query,
@@ -5583,23 +4425,23 @@ class RestRepository extends Query {
5583
4425
  page: options.page,
5584
4426
  target: options.target
5585
4427
  },
5586
- ...__privateGet$3(this, _getFetchProps).call(this)
4428
+ ...__privateGet$2(this, _getFetchProps).call(this)
5587
4429
  });
5588
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4430
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
5589
4431
  return {
5590
- records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
4432
+ records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
5591
4433
  totalCount
5592
4434
  };
5593
4435
  });
5594
4436
  }
5595
4437
  async vectorSearch(column, query, options) {
5596
- return __privateGet$3(this, _trace).call(this, "vectorSearch", async () => {
4438
+ return __privateGet$2(this, _trace).call(this, "vectorSearch", async () => {
5597
4439
  const { records, totalCount } = await vectorSearchTable({
5598
4440
  pathParams: {
5599
4441
  workspace: "{workspaceId}",
5600
4442
  dbBranchName: "{dbBranch}",
5601
4443
  region: "{region}",
5602
- tableName: __privateGet$3(this, _table)
4444
+ tableName: __privateGet$2(this, _table)
5603
4445
  },
5604
4446
  body: {
5605
4447
  column,
@@ -5608,42 +4450,39 @@ class RestRepository extends Query {
5608
4450
  size: options?.size,
5609
4451
  filter: options?.filter
5610
4452
  },
5611
- ...__privateGet$3(this, _getFetchProps).call(this)
4453
+ ...__privateGet$2(this, _getFetchProps).call(this)
5612
4454
  });
5613
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4455
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
5614
4456
  return {
5615
- records: records.map((item) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), item, ["*"])),
4457
+ records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
5616
4458
  totalCount
5617
4459
  };
5618
4460
  });
5619
4461
  }
5620
4462
  async aggregate(aggs, filter) {
5621
- return __privateGet$3(this, _trace).call(this, "aggregate", async () => {
4463
+ return __privateGet$2(this, _trace).call(this, "aggregate", async () => {
5622
4464
  const result = await aggregateTable({
5623
4465
  pathParams: {
5624
4466
  workspace: "{workspaceId}",
5625
4467
  dbBranchName: "{dbBranch}",
5626
4468
  region: "{region}",
5627
- tableName: __privateGet$3(this, _table)
4469
+ tableName: __privateGet$2(this, _table)
5628
4470
  },
5629
4471
  body: { aggs, filter },
5630
- ...__privateGet$3(this, _getFetchProps).call(this)
4472
+ ...__privateGet$2(this, _getFetchProps).call(this)
5631
4473
  });
5632
4474
  return result;
5633
4475
  });
5634
4476
  }
5635
4477
  async query(query) {
5636
- return __privateGet$3(this, _trace).call(this, "query", async () => {
5637
- const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
5638
- if (cacheQuery)
5639
- return new Page(query, cacheQuery.meta, cacheQuery.records);
4478
+ return __privateGet$2(this, _trace).call(this, "query", async () => {
5640
4479
  const data = query.getQueryOptions();
5641
4480
  const { meta, records: objects } = await queryTable({
5642
4481
  pathParams: {
5643
4482
  workspace: "{workspaceId}",
5644
4483
  dbBranchName: "{dbBranch}",
5645
4484
  region: "{region}",
5646
- tableName: __privateGet$3(this, _table)
4485
+ tableName: __privateGet$2(this, _table)
5647
4486
  },
5648
4487
  body: {
5649
4488
  filter: cleanFilter(data.filter),
@@ -5653,31 +4492,30 @@ class RestRepository extends Query {
5653
4492
  consistency: data.consistency
5654
4493
  },
5655
4494
  fetchOptions: data.fetchOptions,
5656
- ...__privateGet$3(this, _getFetchProps).call(this)
4495
+ ...__privateGet$2(this, _getFetchProps).call(this)
5657
4496
  });
5658
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4497
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
5659
4498
  const records = objects.map(
5660
4499
  (record) => initObject(
5661
- __privateGet$3(this, _db),
4500
+ __privateGet$2(this, _db),
5662
4501
  schemaTables,
5663
- __privateGet$3(this, _table),
4502
+ __privateGet$2(this, _table),
5664
4503
  record,
5665
4504
  data.columns ?? ["*"]
5666
4505
  )
5667
4506
  );
5668
- await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
5669
4507
  return new Page(query, meta, records);
5670
4508
  });
5671
4509
  }
5672
4510
  async summarizeTable(query, summaries, summariesFilter) {
5673
- return __privateGet$3(this, _trace).call(this, "summarize", async () => {
4511
+ return __privateGet$2(this, _trace).call(this, "summarize", async () => {
5674
4512
  const data = query.getQueryOptions();
5675
4513
  const result = await summarizeTable({
5676
4514
  pathParams: {
5677
4515
  workspace: "{workspaceId}",
5678
4516
  dbBranchName: "{dbBranch}",
5679
4517
  region: "{region}",
5680
- tableName: __privateGet$3(this, _table)
4518
+ tableName: __privateGet$2(this, _table)
5681
4519
  },
5682
4520
  body: {
5683
4521
  filter: cleanFilter(data.filter),
@@ -5688,13 +4526,13 @@ class RestRepository extends Query {
5688
4526
  summaries,
5689
4527
  summariesFilter
5690
4528
  },
5691
- ...__privateGet$3(this, _getFetchProps).call(this)
4529
+ ...__privateGet$2(this, _getFetchProps).call(this)
5692
4530
  });
5693
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
4531
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
5694
4532
  return {
5695
4533
  ...result,
5696
4534
  summaries: result.summaries.map(
5697
- (summary) => initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), summary, data.columns ?? [])
4535
+ (summary) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), summary, data.columns ?? [])
5698
4536
  )
5699
4537
  };
5700
4538
  });
@@ -5706,7 +4544,7 @@ class RestRepository extends Query {
5706
4544
  workspace: "{workspaceId}",
5707
4545
  dbBranchName: "{dbBranch}",
5708
4546
  region: "{region}",
5709
- tableName: __privateGet$3(this, _table),
4547
+ tableName: __privateGet$2(this, _table),
5710
4548
  sessionId: options?.sessionId
5711
4549
  },
5712
4550
  body: {
@@ -5716,7 +4554,7 @@ class RestRepository extends Query {
5716
4554
  search: options?.searchType === "keyword" ? options?.search : void 0,
5717
4555
  vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
5718
4556
  },
5719
- ...__privateGet$3(this, _getFetchProps).call(this)
4557
+ ...__privateGet$2(this, _getFetchProps).call(this)
5720
4558
  };
5721
4559
  if (options?.onMessage) {
5722
4560
  fetchSSERequest({
@@ -5736,51 +4574,47 @@ class RestRepository extends Query {
5736
4574
  _table = new WeakMap();
5737
4575
  _getFetchProps = new WeakMap();
5738
4576
  _db = new WeakMap();
5739
- _cache = new WeakMap();
5740
4577
  _schemaTables = new WeakMap();
5741
4578
  _trace = new WeakMap();
5742
- _insertRecordWithoutId = new WeakSet();
4579
+ _RestRepository_instances = new WeakSet();
5743
4580
  insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
5744
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4581
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
5745
4582
  const response = await insertRecord({
5746
4583
  pathParams: {
5747
4584
  workspace: "{workspaceId}",
5748
4585
  dbBranchName: "{dbBranch}",
5749
4586
  region: "{region}",
5750
- tableName: __privateGet$3(this, _table)
4587
+ tableName: __privateGet$2(this, _table)
5751
4588
  },
5752
4589
  queryParams: { columns },
5753
4590
  body: record,
5754
- ...__privateGet$3(this, _getFetchProps).call(this)
4591
+ ...__privateGet$2(this, _getFetchProps).call(this)
5755
4592
  });
5756
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5757
- return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4593
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4594
+ return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
5758
4595
  };
5759
- _insertRecordWithId = new WeakSet();
5760
4596
  insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
5761
- if (!recordId)
5762
- return null;
5763
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4597
+ if (!recordId) return null;
4598
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
5764
4599
  const response = await insertRecordWithID({
5765
4600
  pathParams: {
5766
4601
  workspace: "{workspaceId}",
5767
4602
  dbBranchName: "{dbBranch}",
5768
4603
  region: "{region}",
5769
- tableName: __privateGet$3(this, _table),
4604
+ tableName: __privateGet$2(this, _table),
5770
4605
  recordId
5771
4606
  },
5772
4607
  body: record,
5773
4608
  queryParams: { createOnly, columns, ifVersion },
5774
- ...__privateGet$3(this, _getFetchProps).call(this)
4609
+ ...__privateGet$2(this, _getFetchProps).call(this)
5775
4610
  });
5776
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5777
- return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4611
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4612
+ return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
5778
4613
  };
5779
- _insertRecords = new WeakSet();
5780
4614
  insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
5781
4615
  const operations = await promiseMap(objects, async (object) => {
5782
- const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
5783
- return { insert: { table: __privateGet$3(this, _table), record, createOnly, ifVersion } };
4616
+ const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4617
+ return { insert: { table: __privateGet$2(this, _table), record, createOnly, ifVersion } };
5784
4618
  });
5785
4619
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
5786
4620
  const ids = [];
@@ -5792,7 +4626,7 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
5792
4626
  region: "{region}"
5793
4627
  },
5794
4628
  body: { operations: operations2 },
5795
- ...__privateGet$3(this, _getFetchProps).call(this)
4629
+ ...__privateGet$2(this, _getFetchProps).call(this)
5796
4630
  });
5797
4631
  for (const result of results) {
5798
4632
  if (result.operation === "insert") {
@@ -5804,26 +4638,24 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
5804
4638
  }
5805
4639
  return ids;
5806
4640
  };
5807
- _updateRecordWithID = new WeakSet();
5808
4641
  updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
5809
- if (!recordId)
5810
- return null;
5811
- const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
4642
+ if (!recordId) return null;
4643
+ const { xata_id: _id, ...record } = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
5812
4644
  try {
5813
4645
  const response = await updateRecordWithID({
5814
4646
  pathParams: {
5815
4647
  workspace: "{workspaceId}",
5816
4648
  dbBranchName: "{dbBranch}",
5817
4649
  region: "{region}",
5818
- tableName: __privateGet$3(this, _table),
4650
+ tableName: __privateGet$2(this, _table),
5819
4651
  recordId
5820
4652
  },
5821
4653
  queryParams: { columns, ifVersion },
5822
4654
  body: record,
5823
- ...__privateGet$3(this, _getFetchProps).call(this)
4655
+ ...__privateGet$2(this, _getFetchProps).call(this)
5824
4656
  });
5825
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5826
- return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4657
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4658
+ return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
5827
4659
  } catch (e) {
5828
4660
  if (isObject(e) && e.status === 404) {
5829
4661
  return null;
@@ -5831,11 +4663,10 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
5831
4663
  throw e;
5832
4664
  }
5833
4665
  };
5834
- _updateRecords = new WeakSet();
5835
4666
  updateRecords_fn = async function(objects, { ifVersion, upsert }) {
5836
- const operations = await promiseMap(objects, async ({ id, ...object }) => {
5837
- const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
5838
- return { update: { table: __privateGet$3(this, _table), id, ifVersion, upsert, fields } };
4667
+ const operations = await promiseMap(objects, async ({ xata_id, ...object }) => {
4668
+ const fields = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
4669
+ return { update: { table: __privateGet$2(this, _table), id: xata_id, ifVersion, upsert, fields } };
5839
4670
  });
5840
4671
  const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
5841
4672
  const ids = [];
@@ -5847,7 +4678,7 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
5847
4678
  region: "{region}"
5848
4679
  },
5849
4680
  body: { operations: operations2 },
5850
- ...__privateGet$3(this, _getFetchProps).call(this)
4681
+ ...__privateGet$2(this, _getFetchProps).call(this)
5851
4682
  });
5852
4683
  for (const result of results) {
5853
4684
  if (result.operation === "update") {
@@ -5859,43 +4690,39 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
5859
4690
  }
5860
4691
  return ids;
5861
4692
  };
5862
- _upsertRecordWithID = new WeakSet();
5863
4693
  upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
5864
- if (!recordId)
5865
- return null;
4694
+ if (!recordId) return null;
5866
4695
  const response = await upsertRecordWithID({
5867
4696
  pathParams: {
5868
4697
  workspace: "{workspaceId}",
5869
4698
  dbBranchName: "{dbBranch}",
5870
4699
  region: "{region}",
5871
- tableName: __privateGet$3(this, _table),
4700
+ tableName: __privateGet$2(this, _table),
5872
4701
  recordId
5873
4702
  },
5874
4703
  queryParams: { columns, ifVersion },
5875
4704
  body: object,
5876
- ...__privateGet$3(this, _getFetchProps).call(this)
4705
+ ...__privateGet$2(this, _getFetchProps).call(this)
5877
4706
  });
5878
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5879
- return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4707
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4708
+ return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
5880
4709
  };
5881
- _deleteRecord = new WeakSet();
5882
4710
  deleteRecord_fn = async function(recordId, columns = ["*"]) {
5883
- if (!recordId)
5884
- return null;
4711
+ if (!recordId) return null;
5885
4712
  try {
5886
4713
  const response = await deleteRecord({
5887
4714
  pathParams: {
5888
4715
  workspace: "{workspaceId}",
5889
4716
  dbBranchName: "{dbBranch}",
5890
4717
  region: "{region}",
5891
- tableName: __privateGet$3(this, _table),
4718
+ tableName: __privateGet$2(this, _table),
5892
4719
  recordId
5893
4720
  },
5894
4721
  queryParams: { columns },
5895
- ...__privateGet$3(this, _getFetchProps).call(this)
4722
+ ...__privateGet$2(this, _getFetchProps).call(this)
5896
4723
  });
5897
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5898
- return initObject(__privateGet$3(this, _db), schemaTables, __privateGet$3(this, _table), response, columns);
4724
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4725
+ return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
5899
4726
  } catch (e) {
5900
4727
  if (isObject(e) && e.status === 404) {
5901
4728
  return null;
@@ -5903,10 +4730,9 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
5903
4730
  throw e;
5904
4731
  }
5905
4732
  };
5906
- _deleteRecords = new WeakSet();
5907
4733
  deleteRecords_fn = async function(recordIds) {
5908
4734
  const chunkedOperations = chunk(
5909
- compact(recordIds).map((id) => ({ delete: { table: __privateGet$3(this, _table), id } })),
4735
+ compact(recordIds).map((id) => ({ delete: { table: __privateGet$2(this, _table), id } })),
5910
4736
  BULK_OPERATION_MAX_SIZE
5911
4737
  );
5912
4738
  for (const operations of chunkedOperations) {
@@ -5917,52 +4743,30 @@ deleteRecords_fn = async function(recordIds) {
5917
4743
  region: "{region}"
5918
4744
  },
5919
4745
  body: { operations },
5920
- ...__privateGet$3(this, _getFetchProps).call(this)
4746
+ ...__privateGet$2(this, _getFetchProps).call(this)
5921
4747
  });
5922
4748
  }
5923
4749
  };
5924
- _setCacheQuery = new WeakSet();
5925
- setCacheQuery_fn = async function(query, meta, records) {
5926
- await __privateGet$3(this, _cache)?.set(`query_${__privateGet$3(this, _table)}:${query.key()}`, { date: /* @__PURE__ */ new Date(), meta, records });
5927
- };
5928
- _getCacheQuery = new WeakSet();
5929
- getCacheQuery_fn = async function(query) {
5930
- const key = `query_${__privateGet$3(this, _table)}:${query.key()}`;
5931
- const result = await __privateGet$3(this, _cache)?.get(key);
5932
- if (!result)
5933
- return null;
5934
- const defaultTTL = __privateGet$3(this, _cache)?.defaultQueryTTL ?? -1;
5935
- const { cache: ttl = defaultTTL } = query.getQueryOptions();
5936
- if (ttl < 0)
5937
- return null;
5938
- const hasExpired = result.date.getTime() + ttl < Date.now();
5939
- return hasExpired ? null : result;
5940
- };
5941
- _getSchemaTables = new WeakSet();
5942
4750
  getSchemaTables_fn = async function() {
5943
- if (__privateGet$3(this, _schemaTables))
5944
- return __privateGet$3(this, _schemaTables);
4751
+ if (__privateGet$2(this, _schemaTables)) return __privateGet$2(this, _schemaTables);
5945
4752
  const { schema } = await getBranchDetails({
5946
4753
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
5947
- ...__privateGet$3(this, _getFetchProps).call(this)
4754
+ ...__privateGet$2(this, _getFetchProps).call(this)
5948
4755
  });
5949
- __privateSet$2(this, _schemaTables, schema.tables);
4756
+ __privateSet$1(this, _schemaTables, schema.tables);
5950
4757
  return schema.tables;
5951
4758
  };
5952
- _transformObjectToApi = new WeakSet();
5953
4759
  transformObjectToApi_fn = async function(object) {
5954
- const schemaTables = await __privateMethod$2(this, _getSchemaTables, getSchemaTables_fn).call(this);
5955
- const schema = schemaTables.find((table) => table.name === __privateGet$3(this, _table));
5956
- if (!schema)
5957
- throw new Error(`Table ${__privateGet$3(this, _table)} not found in schema`);
4760
+ const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
4761
+ const schema = schemaTables.find((table) => table.name === __privateGet$2(this, _table));
4762
+ if (!schema) throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
5958
4763
  const result = {};
5959
4764
  for (const [key, value] of Object.entries(object)) {
5960
- if (key === "xata")
5961
- continue;
4765
+ if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key)) continue;
5962
4766
  const type = schema.columns.find((column) => column.name === key)?.type;
5963
4767
  switch (type) {
5964
4768
  case "link": {
5965
- result[key] = isIdentifiable(value) ? value.id : value;
4769
+ result[key] = isIdentifiable(value) ? value.xata_id : value;
5966
4770
  break;
5967
4771
  }
5968
4772
  case "datetime": {
@@ -5986,14 +4790,11 @@ transformObjectToApi_fn = async function(object) {
5986
4790
  };
5987
4791
  const initObject = (db, schemaTables, table, object, selectedColumns) => {
5988
4792
  const data = {};
5989
- const { xata, ...rest } = object ?? {};
5990
- Object.assign(data, rest);
4793
+ Object.assign(data, { ...object });
5991
4794
  const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
5992
- if (!columns)
5993
- console.error(`Table ${table} not found in schema`);
4795
+ if (!columns) console.error(`Table ${table} not found in schema`);
5994
4796
  for (const column of columns ?? []) {
5995
- if (!isValidColumn(selectedColumns, column))
5996
- continue;
4797
+ if (!isValidColumn(selectedColumns, column)) continue;
5997
4798
  const value = data[column.name];
5998
4799
  switch (column.type) {
5999
4800
  case "datetime": {
@@ -6028,7 +4829,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
6028
4829
  selectedLinkColumns
6029
4830
  );
6030
4831
  } else {
6031
- data[column.name] = null;
4832
+ data[column.name] = value ?? null;
6032
4833
  }
6033
4834
  break;
6034
4835
  }
@@ -6050,28 +4851,21 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
6050
4851
  }
6051
4852
  }
6052
4853
  const record = { ...data };
6053
- const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
6054
4854
  record.read = function(columns2) {
6055
- return db[table].read(record["id"], columns2);
4855
+ return db[table].read(record["xata_id"], columns2);
6056
4856
  };
6057
4857
  record.update = function(data2, b, c) {
6058
4858
  const columns2 = isValidSelectableColumns(b) ? b : ["*"];
6059
4859
  const ifVersion = parseIfVersion(b, c);
6060
- return db[table].update(record["id"], data2, columns2, { ifVersion });
4860
+ return db[table].update(record["xata_id"], data2, columns2, { ifVersion });
6061
4861
  };
6062
4862
  record.replace = function(data2, b, c) {
6063
4863
  const columns2 = isValidSelectableColumns(b) ? b : ["*"];
6064
4864
  const ifVersion = parseIfVersion(b, c);
6065
- return db[table].createOrReplace(record["id"], data2, columns2, { ifVersion });
4865
+ return db[table].createOrReplace(record["xata_id"], data2, columns2, { ifVersion });
6066
4866
  };
6067
4867
  record.delete = function() {
6068
- return db[table].delete(record["id"]);
6069
- };
6070
- if (metadata !== void 0) {
6071
- record.xata = Object.freeze(metadata);
6072
- }
6073
- record.getMetadata = function() {
6074
- return record.xata;
4868
+ return db[table].delete(record["xata_id"]);
6075
4869
  };
6076
4870
  record.toSerializable = function() {
6077
4871
  return JSON.parse(JSON.stringify(record));
@@ -6079,22 +4873,19 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
6079
4873
  record.toString = function() {
6080
4874
  return JSON.stringify(record);
6081
4875
  };
6082
- for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
4876
+ for (const prop of ["read", "update", "replace", "delete", "toSerializable", "toString"]) {
6083
4877
  Object.defineProperty(record, prop, { enumerable: false });
6084
4878
  }
6085
4879
  Object.freeze(record);
6086
4880
  return record;
6087
4881
  };
6088
4882
  function extractId(value) {
6089
- if (isString(value))
6090
- return value;
6091
- if (isObject(value) && isString(value.id))
6092
- return value.id;
4883
+ if (isString(value)) return value;
4884
+ if (isObject(value) && isString(value.xata_id)) return value.xata_id;
6093
4885
  return void 0;
6094
4886
  }
6095
4887
  function isValidColumn(columns, column) {
6096
- if (columns.includes("*"))
6097
- return true;
4888
+ if (columns.includes("*")) return true;
6098
4889
  return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
6099
4890
  }
6100
4891
  function parseIfVersion(...args) {
@@ -6106,55 +4897,6 @@ function parseIfVersion(...args) {
6106
4897
  return void 0;
6107
4898
  }
6108
4899
 
6109
- var __accessCheck$3 = (obj, member, msg) => {
6110
- if (!member.has(obj))
6111
- throw TypeError("Cannot " + msg);
6112
- };
6113
- var __privateGet$2 = (obj, member, getter) => {
6114
- __accessCheck$3(obj, member, "read from private field");
6115
- return getter ? getter.call(obj) : member.get(obj);
6116
- };
6117
- var __privateAdd$3 = (obj, member, value) => {
6118
- if (member.has(obj))
6119
- throw TypeError("Cannot add the same private member more than once");
6120
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
6121
- };
6122
- var __privateSet$1 = (obj, member, value, setter) => {
6123
- __accessCheck$3(obj, member, "write to private field");
6124
- setter ? setter.call(obj, value) : member.set(obj, value);
6125
- return value;
6126
- };
6127
- var _map;
6128
- class SimpleCache {
6129
- constructor(options = {}) {
6130
- __privateAdd$3(this, _map, void 0);
6131
- __privateSet$1(this, _map, /* @__PURE__ */ new Map());
6132
- this.capacity = options.max ?? 500;
6133
- this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
6134
- }
6135
- async getAll() {
6136
- return Object.fromEntries(__privateGet$2(this, _map));
6137
- }
6138
- async get(key) {
6139
- return __privateGet$2(this, _map).get(key) ?? null;
6140
- }
6141
- async set(key, value) {
6142
- await this.delete(key);
6143
- __privateGet$2(this, _map).set(key, value);
6144
- if (__privateGet$2(this, _map).size > this.capacity) {
6145
- const leastRecentlyUsed = __privateGet$2(this, _map).keys().next().value;
6146
- await this.delete(leastRecentlyUsed);
6147
- }
6148
- }
6149
- async delete(key) {
6150
- __privateGet$2(this, _map).delete(key);
6151
- }
6152
- async clear() {
6153
- return __privateGet$2(this, _map).clear();
6154
- }
6155
- }
6156
- _map = new WeakMap();
6157
-
6158
4900
  const greaterThan = (value) => ({ $gt: value });
6159
4901
  const gt = greaterThan;
6160
4902
  const greaterThanEquals = (value) => ({ $ge: value });
@@ -6183,19 +4925,12 @@ const includesAll = (value) => ({ $includesAll: value });
6183
4925
  const includesNone = (value) => ({ $includesNone: value });
6184
4926
  const includesAny = (value) => ({ $includesAny: value });
6185
4927
 
6186
- var __accessCheck$2 = (obj, member, msg) => {
6187
- if (!member.has(obj))
6188
- throw TypeError("Cannot " + msg);
6189
- };
6190
- var __privateGet$1 = (obj, member, getter) => {
6191
- __accessCheck$2(obj, member, "read from private field");
6192
- return getter ? getter.call(obj) : member.get(obj);
6193
- };
6194
- var __privateAdd$2 = (obj, member, value) => {
6195
- if (member.has(obj))
6196
- throw TypeError("Cannot add the same private member more than once");
6197
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4928
+ var __typeError$2 = (msg) => {
4929
+ throw TypeError(msg);
6198
4930
  };
4931
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
4932
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
4933
+ 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);
6199
4934
  var _tables;
6200
4935
  class SchemaPlugin extends XataPlugin {
6201
4936
  constructor() {
@@ -6207,8 +4942,7 @@ class SchemaPlugin extends XataPlugin {
6207
4942
  {},
6208
4943
  {
6209
4944
  get: (_target, table) => {
6210
- if (!isString(table))
6211
- throw new Error("Invalid table name");
4945
+ if (!isString(table)) throw new Error("Invalid table name");
6212
4946
  if (__privateGet$1(this, _tables)[table] === void 0) {
6213
4947
  __privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
6214
4948
  }
@@ -6299,42 +5033,35 @@ function getContentType(file) {
6299
5033
  return "application/octet-stream";
6300
5034
  }
6301
5035
 
6302
- var __accessCheck$1 = (obj, member, msg) => {
6303
- if (!member.has(obj))
6304
- throw TypeError("Cannot " + msg);
6305
- };
6306
- var __privateAdd$1 = (obj, member, value) => {
6307
- if (member.has(obj))
6308
- throw TypeError("Cannot add the same private member more than once");
6309
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5036
+ var __typeError$1 = (msg) => {
5037
+ throw TypeError(msg);
6310
5038
  };
6311
- var __privateMethod$1 = (obj, member, method) => {
6312
- __accessCheck$1(obj, member, "access private method");
6313
- return method;
6314
- };
6315
- var _search, search_fn;
5039
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
5040
+ 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);
5041
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
5042
+ var _SearchPlugin_instances, search_fn;
6316
5043
  class SearchPlugin extends XataPlugin {
6317
5044
  constructor(db) {
6318
5045
  super();
6319
5046
  this.db = db;
6320
- __privateAdd$1(this, _search);
5047
+ __privateAdd$1(this, _SearchPlugin_instances);
6321
5048
  }
6322
5049
  build(pluginOptions) {
6323
5050
  return {
6324
5051
  all: async (query, options = {}) => {
6325
- const { records, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
5052
+ const { records, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
6326
5053
  return {
6327
5054
  totalCount,
6328
5055
  records: records.map((record) => {
6329
- const { table = "orphan" } = record.xata;
5056
+ const table = record.xata_table;
6330
5057
  return { table, record: initObject(this.db, pluginOptions.tables, table, record, ["*"]) };
6331
5058
  })
6332
5059
  };
6333
5060
  },
6334
5061
  byTable: async (query, options = {}) => {
6335
- const { records: rawRecords, totalCount } = await __privateMethod$1(this, _search, search_fn).call(this, query, options, pluginOptions);
5062
+ const { records: rawRecords, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
6336
5063
  const records = rawRecords.reduce((acc, record) => {
6337
- const { table = "orphan" } = record.xata;
5064
+ const table = record.xata_table;
6338
5065
  const items = acc[table] ?? [];
6339
5066
  const item = initObject(this.db, pluginOptions.tables, table, record, ["*"]);
6340
5067
  return { ...acc, [table]: [...items, item] };
@@ -6344,7 +5071,7 @@ class SearchPlugin extends XataPlugin {
6344
5071
  };
6345
5072
  }
6346
5073
  }
6347
- _search = new WeakSet();
5074
+ _SearchPlugin_instances = new WeakSet();
6348
5075
  search_fn = async function(query, options, pluginOptions) {
6349
5076
  const { tables, fuzziness, highlight, prefix, page } = options ?? {};
6350
5077
  const { records, totalCount } = await searchBranch({
@@ -6380,8 +5107,7 @@ function arrayString(val) {
6380
5107
  return result;
6381
5108
  }
6382
5109
  function prepareValue(value) {
6383
- if (!isDefined(value))
6384
- return null;
5110
+ if (!isDefined(value)) return null;
6385
5111
  if (value instanceof Date) {
6386
5112
  return value.toISOString();
6387
5113
  }
@@ -6421,19 +5147,28 @@ class SQLPlugin extends XataPlugin {
6421
5147
  throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
6422
5148
  }
6423
5149
  const { statement, params, consistency, responseType } = prepareParams(query, parameters);
6424
- const {
6425
- records,
6426
- rows,
6427
- warning,
6428
- columns = []
6429
- } = await sqlQuery({
5150
+ const { warning, columns, ...response } = await sqlQuery({
6430
5151
  pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
6431
5152
  body: { statement, params, consistency, responseType },
6432
5153
  ...pluginOptions
6433
5154
  });
5155
+ const records = "records" in response ? response.records : void 0;
5156
+ const rows = "rows" in response ? response.rows : void 0;
6434
5157
  return { records, rows, warning, columns };
6435
5158
  };
6436
5159
  sqlFunction.connectionString = buildConnectionString(pluginOptions);
5160
+ sqlFunction.batch = async (query) => {
5161
+ const { results } = await sqlBatchQuery({
5162
+ pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
5163
+ body: {
5164
+ statements: query.statements.map(({ statement, params }) => ({ statement, params })),
5165
+ consistency: query.consistency,
5166
+ responseType: query.responseType
5167
+ },
5168
+ ...pluginOptions
5169
+ });
5170
+ return { results };
5171
+ };
6437
5172
  return sqlFunction;
6438
5173
  }
6439
5174
  }
@@ -6460,8 +5195,7 @@ function buildDomain(host, region) {
6460
5195
  function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
6461
5196
  const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
6462
5197
  const parts = parseWorkspacesUrlParts(url);
6463
- if (!parts)
6464
- throw new Error("Invalid workspaces URL");
5198
+ if (!parts) throw new Error("Invalid workspaces URL");
6465
5199
  const { workspace: workspaceSlug, region, database, host } = parts;
6466
5200
  const domain = buildDomain(host, region);
6467
5201
  const workspace = workspaceSlug.split("-").pop();
@@ -6486,40 +5220,24 @@ class TransactionPlugin extends XataPlugin {
6486
5220
  }
6487
5221
  }
6488
5222
 
6489
- var __accessCheck = (obj, member, msg) => {
6490
- if (!member.has(obj))
6491
- throw TypeError("Cannot " + msg);
6492
- };
6493
- var __privateGet = (obj, member, getter) => {
6494
- __accessCheck(obj, member, "read from private field");
6495
- return getter ? getter.call(obj) : member.get(obj);
6496
- };
6497
- var __privateAdd = (obj, member, value) => {
6498
- if (member.has(obj))
6499
- throw TypeError("Cannot add the same private member more than once");
6500
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
6501
- };
6502
- var __privateSet = (obj, member, value, setter) => {
6503
- __accessCheck(obj, member, "write to private field");
6504
- setter ? setter.call(obj, value) : member.set(obj, value);
6505
- return value;
6506
- };
6507
- var __privateMethod = (obj, member, method) => {
6508
- __accessCheck(obj, member, "access private method");
6509
- return method;
5223
+ var __typeError = (msg) => {
5224
+ throw TypeError(msg);
6510
5225
  };
5226
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5227
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
5228
+ 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);
5229
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
5230
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
6511
5231
  const buildClient = (plugins) => {
6512
- var _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _a;
5232
+ var _options, _instances, parseOptions_fn, getFetchProps_fn, _a;
6513
5233
  return _a = class {
6514
5234
  constructor(options = {}, tables) {
6515
- __privateAdd(this, _parseOptions);
6516
- __privateAdd(this, _getFetchProps);
6517
- __privateAdd(this, _options, void 0);
6518
- const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
5235
+ __privateAdd(this, _instances);
5236
+ __privateAdd(this, _options);
5237
+ const safeOptions = __privateMethod(this, _instances, parseOptions_fn).call(this, options);
6519
5238
  __privateSet(this, _options, safeOptions);
6520
5239
  const pluginOptions = {
6521
- ...__privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
6522
- cache: safeOptions.cache,
5240
+ ...__privateMethod(this, _instances, getFetchProps_fn).call(this, safeOptions),
6523
5241
  host: safeOptions.host,
6524
5242
  tables,
6525
5243
  branch: safeOptions.branch
@@ -6536,8 +5254,7 @@ const buildClient = (plugins) => {
6536
5254
  this.sql = sql;
6537
5255
  this.files = files;
6538
5256
  for (const [key, namespace] of Object.entries(plugins ?? {})) {
6539
- if (namespace === void 0)
6540
- continue;
5257
+ if (namespace === void 0) continue;
6541
5258
  this[key] = namespace.build(pluginOptions);
6542
5259
  }
6543
5260
  }
@@ -6546,8 +5263,8 @@ const buildClient = (plugins) => {
6546
5263
  const branch = __privateGet(this, _options).branch;
6547
5264
  return { databaseURL, branch };
6548
5265
  }
6549
- }, _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
6550
- const enableBrowser = options?.enableBrowser ?? getEnableBrowserVariable() ?? false;
5266
+ }, _options = new WeakMap(), _instances = new WeakSet(), parseOptions_fn = function(options) {
5267
+ const enableBrowser = options?.enableBrowser ?? false;
6551
5268
  const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
6552
5269
  if (isBrowser && !enableBrowser) {
6553
5270
  throw new Error(
@@ -6555,9 +5272,9 @@ const buildClient = (plugins) => {
6555
5272
  );
6556
5273
  }
6557
5274
  const fetch = getFetchImplementation(options?.fetch);
6558
- const databaseURL = options?.databaseURL || getDatabaseURL();
6559
- const apiKey = options?.apiKey || getAPIKey();
6560
- const cache = options?.cache ?? new SimpleCache({ defaultQueryTTL: 0 });
5275
+ const databaseURL = options?.databaseURL;
5276
+ const apiKey = options?.apiKey;
5277
+ const branch = options?.branch;
6561
5278
  const trace = options?.trace ?? defaultTrace;
6562
5279
  const clientName = options?.clientName;
6563
5280
  const host = options?.host ?? "production";
@@ -6568,32 +5285,14 @@ const buildClient = (plugins) => {
6568
5285
  if (!databaseURL) {
6569
5286
  throw new Error("Option databaseURL is required");
6570
5287
  }
6571
- const envBranch = getBranch();
6572
- const previewBranch = getPreviewBranch();
6573
- const branch = options?.branch || previewBranch || envBranch || "main";
6574
- if (!!previewBranch && branch !== previewBranch) {
6575
- console.warn(
6576
- `Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
6577
- );
6578
- } else if (!!envBranch && branch !== envBranch) {
6579
- console.warn(
6580
- `Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
6581
- );
6582
- } else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
6583
- console.warn(
6584
- `Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
6585
- );
6586
- } else if (!previewBranch && !envBranch && options?.branch === void 0) {
6587
- console.warn(
6588
- `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.`
6589
- );
5288
+ if (!branch) {
5289
+ throw new Error("Option branch is required");
6590
5290
  }
6591
5291
  return {
6592
5292
  fetch,
6593
5293
  databaseURL,
6594
5294
  apiKey,
6595
5295
  branch,
6596
- cache,
6597
5296
  trace,
6598
5297
  host,
6599
5298
  clientID: generateUUID(),
@@ -6601,7 +5300,7 @@ const buildClient = (plugins) => {
6601
5300
  clientName,
6602
5301
  xataAgentExtra
6603
5302
  };
6604
- }, _getFetchProps = new WeakSet(), getFetchProps_fn = function({
5303
+ }, getFetchProps_fn = function({
6605
5304
  fetch,
6606
5305
  apiKey,
6607
5306
  databaseURL,
@@ -6642,26 +5341,19 @@ class Serializer {
6642
5341
  }
6643
5342
  toJSON(data) {
6644
5343
  function visit(obj) {
6645
- if (Array.isArray(obj))
6646
- return obj.map(visit);
5344
+ if (Array.isArray(obj)) return obj.map(visit);
6647
5345
  const type = typeof obj;
6648
- if (type === "undefined")
6649
- return { [META]: "undefined" };
6650
- if (type === "bigint")
6651
- return { [META]: "bigint", [VALUE]: obj.toString() };
6652
- if (obj === null || type !== "object")
6653
- return obj;
5346
+ if (type === "undefined") return { [META]: "undefined" };
5347
+ if (type === "bigint") return { [META]: "bigint", [VALUE]: obj.toString() };
5348
+ if (obj === null || type !== "object") return obj;
6654
5349
  const constructor = obj.constructor;
6655
5350
  const o = { [META]: constructor.name };
6656
5351
  for (const [key, value] of Object.entries(obj)) {
6657
5352
  o[key] = visit(value);
6658
5353
  }
6659
- if (constructor === Date)
6660
- o[VALUE] = obj.toISOString();
6661
- if (constructor === Map)
6662
- o[VALUE] = Object.fromEntries(obj);
6663
- if (constructor === Set)
6664
- o[VALUE] = [...obj];
5354
+ if (constructor === Date) o[VALUE] = obj.toISOString();
5355
+ if (constructor === Map) o[VALUE] = Object.fromEntries(obj);
5356
+ if (constructor === Set) o[VALUE] = [...obj];
6665
5357
  return o;
6666
5358
  }
6667
5359
  return JSON.stringify(visit(data));
@@ -6674,16 +5366,11 @@ class Serializer {
6674
5366
  if (constructor) {
6675
5367
  return Object.assign(Object.create(constructor.prototype), rest);
6676
5368
  }
6677
- if (clazz === "Date")
6678
- return new Date(val);
6679
- if (clazz === "Set")
6680
- return new Set(val);
6681
- if (clazz === "Map")
6682
- return new Map(Object.entries(val));
6683
- if (clazz === "bigint")
6684
- return BigInt(val);
6685
- if (clazz === "undefined")
6686
- return void 0;
5369
+ if (clazz === "Date") return new Date(val);
5370
+ if (clazz === "Set") return new Set(val);
5371
+ if (clazz === "Map") return new Map(Object.entries(val));
5372
+ if (clazz === "bigint") return BigInt(val);
5373
+ if (clazz === "undefined") return void 0;
6687
5374
  return rest;
6688
5375
  }
6689
5376
  return value;
@@ -6698,6 +5385,47 @@ const deserialize = (json) => {
6698
5385
  return defaultSerializer.fromJSON(json);
6699
5386
  };
6700
5387
 
5388
+ function parseEnvironment(environment) {
5389
+ try {
5390
+ if (typeof environment === "function") {
5391
+ return new Proxy(
5392
+ {},
5393
+ {
5394
+ get(target) {
5395
+ return environment(target);
5396
+ }
5397
+ }
5398
+ );
5399
+ }
5400
+ if (isObject(environment)) {
5401
+ return environment;
5402
+ }
5403
+ } catch (error) {
5404
+ }
5405
+ return {};
5406
+ }
5407
+ function buildPreviewBranchName({ org, branch }) {
5408
+ return `preview-${org}-${branch}`;
5409
+ }
5410
+ function getDeployPreviewBranch(environment) {
5411
+ try {
5412
+ const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = parseEnvironment(environment);
5413
+ if (deployPreviewBranch) return deployPreviewBranch;
5414
+ switch (deployPreview) {
5415
+ case "vercel": {
5416
+ if (!vercelGitCommitRef || !vercelGitRepoOwner) {
5417
+ console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
5418
+ return void 0;
5419
+ }
5420
+ return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
5421
+ }
5422
+ }
5423
+ return void 0;
5424
+ } catch (err) {
5425
+ return void 0;
5426
+ }
5427
+ }
5428
+
6701
5429
  class XataError extends Error {
6702
5430
  constructor(message, status) {
6703
5431
  super(message);
@@ -6725,7 +5453,6 @@ exports.SQLPlugin = SQLPlugin;
6725
5453
  exports.SchemaPlugin = SchemaPlugin;
6726
5454
  exports.SearchPlugin = SearchPlugin;
6727
5455
  exports.Serializer = Serializer;
6728
- exports.SimpleCache = SimpleCache;
6729
5456
  exports.TransactionPlugin = TransactionPlugin;
6730
5457
  exports.XataApiClient = XataApiClient;
6731
5458
  exports.XataApiPlugin = XataApiPlugin;
@@ -6751,9 +5478,11 @@ exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
6751
5478
  exports.compareBranchSchemas = compareBranchSchemas;
6752
5479
  exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
6753
5480
  exports.compareMigrationRequest = compareMigrationRequest;
5481
+ exports.completeMigration = completeMigration;
6754
5482
  exports.contains = contains;
6755
5483
  exports.copyBranch = copyBranch;
6756
5484
  exports.createBranch = createBranch;
5485
+ exports.createBranchAsync = createBranchAsync;
6757
5486
  exports.createCluster = createCluster;
6758
5487
  exports.createDatabase = createDatabase;
6759
5488
  exports.createMigrationRequest = createMigrationRequest;
@@ -6761,6 +5490,7 @@ exports.createTable = createTable;
6761
5490
  exports.createUserAPIKey = createUserAPIKey;
6762
5491
  exports.createWorkspace = createWorkspace;
6763
5492
  exports.deleteBranch = deleteBranch;
5493
+ exports.deleteCluster = deleteCluster;
6764
5494
  exports.deleteColumn = deleteColumn;
6765
5495
  exports.deleteDatabase = deleteDatabase;
6766
5496
  exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
@@ -6774,6 +5504,7 @@ exports.deleteUserAPIKey = deleteUserAPIKey;
6774
5504
  exports.deleteUserOAuthClient = deleteUserOAuthClient;
6775
5505
  exports.deleteWorkspace = deleteWorkspace;
6776
5506
  exports.deserialize = deserialize;
5507
+ exports.dropClusterExtension = dropClusterExtension;
6777
5508
  exports.endsWith = endsWith;
6778
5509
  exports.equals = equals;
6779
5510
  exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
@@ -6781,37 +5512,40 @@ exports.exists = exists;
6781
5512
  exports.fileAccess = fileAccess;
6782
5513
  exports.fileUpload = fileUpload;
6783
5514
  exports.ge = ge;
6784
- exports.getAPIKey = getAPIKey;
6785
5515
  exports.getAuthorizationCode = getAuthorizationCode;
6786
- exports.getBranch = getBranch;
6787
5516
  exports.getBranchDetails = getBranchDetails;
6788
5517
  exports.getBranchList = getBranchList;
6789
5518
  exports.getBranchMetadata = getBranchMetadata;
6790
5519
  exports.getBranchMigrationHistory = getBranchMigrationHistory;
6791
5520
  exports.getBranchMigrationJobStatus = getBranchMigrationJobStatus;
6792
5521
  exports.getBranchMigrationPlan = getBranchMigrationPlan;
5522
+ exports.getBranchMoveStatus = getBranchMoveStatus;
6793
5523
  exports.getBranchSchemaHistory = getBranchSchemaHistory;
6794
5524
  exports.getBranchStats = getBranchStats;
6795
5525
  exports.getCluster = getCluster;
5526
+ exports.getClusterMetrics = getClusterMetrics;
6796
5527
  exports.getColumn = getColumn;
6797
5528
  exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
6798
5529
  exports.getDatabaseList = getDatabaseList;
6799
5530
  exports.getDatabaseMetadata = getDatabaseMetadata;
6800
5531
  exports.getDatabaseSettings = getDatabaseSettings;
6801
- exports.getDatabaseURL = getDatabaseURL;
5532
+ exports.getDeployPreviewBranch = getDeployPreviewBranch;
6802
5533
  exports.getFile = getFile;
6803
5534
  exports.getFileItem = getFileItem;
6804
5535
  exports.getGitBranchesMapping = getGitBranchesMapping;
6805
5536
  exports.getHostUrl = getHostUrl;
6806
5537
  exports.getMigrationHistory = getMigrationHistory;
6807
5538
  exports.getMigrationJobStatus = getMigrationJobStatus;
5539
+ exports.getMigrationJobs = getMigrationJobs;
6808
5540
  exports.getMigrationRequest = getMigrationRequest;
6809
5541
  exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
6810
- exports.getPreviewBranch = getPreviewBranch;
6811
5542
  exports.getRecord = getRecord;
6812
5543
  exports.getSchema = getSchema;
5544
+ exports.getSchemas = getSchemas;
6813
5545
  exports.getTableColumns = getTableColumns;
6814
5546
  exports.getTableSchema = getTableSchema;
5547
+ exports.getTaskStatus = getTaskStatus;
5548
+ exports.getTasks = getTasks;
6815
5549
  exports.getUser = getUser;
6816
5550
  exports.getUserAPIKeys = getUserAPIKeys;
6817
5551
  exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
@@ -6834,6 +5568,7 @@ exports.includesAny = includesAny;
6834
5568
  exports.includesNone = includesNone;
6835
5569
  exports.insertRecord = insertRecord;
6836
5570
  exports.insertRecordWithID = insertRecordWithID;
5571
+ exports.installClusterExtension = installClusterExtension;
6837
5572
  exports.inviteWorkspaceMember = inviteWorkspaceMember;
6838
5573
  exports.is = is;
6839
5574
  exports.isCursorPaginationOptions = isCursorPaginationOptions;
@@ -6843,17 +5578,19 @@ exports.isIdentifiable = isIdentifiable;
6843
5578
  exports.isNot = isNot;
6844
5579
  exports.isValidExpandedColumn = isValidExpandedColumn;
6845
5580
  exports.isValidSelectableColumns = isValidSelectableColumns;
6846
- exports.isXataRecord = isXataRecord;
6847
5581
  exports.le = le;
6848
5582
  exports.lessEquals = lessEquals;
6849
5583
  exports.lessThan = lessThan;
6850
5584
  exports.lessThanEquals = lessThanEquals;
5585
+ exports.listClusterBranches = listClusterBranches;
5586
+ exports.listClusterExtensions = listClusterExtensions;
6851
5587
  exports.listClusters = listClusters;
6852
5588
  exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
6853
5589
  exports.listRegions = listRegions;
6854
5590
  exports.lt = lt;
6855
5591
  exports.lte = lte;
6856
5592
  exports.mergeMigrationRequest = mergeMigrationRequest;
5593
+ exports.moveBranch = moveBranch;
6857
5594
  exports.notExists = notExists;
6858
5595
  exports.operationsByTag = operationsByTag;
6859
5596
  exports.parseProviderString = parseProviderString;
@@ -6870,11 +5607,14 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
6870
5607
  exports.renameDatabase = renameDatabase;
6871
5608
  exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
6872
5609
  exports.resolveBranch = resolveBranch;
5610
+ exports.rollbackMigration = rollbackMigration;
6873
5611
  exports.searchBranch = searchBranch;
6874
5612
  exports.searchTable = searchTable;
6875
5613
  exports.serialize = serialize;
6876
5614
  exports.setTableSchema = setTableSchema;
5615
+ exports.sqlBatchQuery = sqlBatchQuery;
6877
5616
  exports.sqlQuery = sqlQuery;
5617
+ exports.startMigration = startMigration;
6878
5618
  exports.startsWith = startsWith;
6879
5619
  exports.summarizeTable = summarizeTable;
6880
5620
  exports.transformImage = transformImage;