@xata.io/client 0.0.0-next.v96c0efcf2b6fc9674a4a1e547d0b9c665f255e80 → 0.0.0-next.v9a81c4765c87e96d23c4e8ae0cbee78e78451dd5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +3 -3
- package/dist/index.cjs +615 -595
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4020 -3954
- package/dist/index.mjs +613 -592
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
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
|
-
|
396
|
-
if (!
|
397
|
-
|
398
|
-
if (
|
399
|
-
|
400
|
-
if (
|
401
|
-
|
402
|
-
if (
|
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
|
-
|
417
|
-
if (sourceEnd
|
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
|
-
|
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
|
-
|
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
|
-
|
1774
|
-
if (
|
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
|
-
|
1930
|
-
|
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$6 = (obj, member, msg) => {
|
2056
|
-
if (!member.has(obj))
|
2057
|
-
throw TypeError("Cannot " + msg);
|
2058
|
-
};
|
2059
|
-
var __privateGet$5 = (obj, member, getter) => {
|
2060
|
-
__accessCheck$6(obj, member, "read from private field");
|
2061
|
-
return getter ? getter.call(obj) : member.get(obj);
|
2062
|
-
};
|
2063
|
-
var __privateAdd$6 = (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);
|
2067
|
-
};
|
2068
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
2069
|
-
__accessCheck$6(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$6(obj, member, "access private method");
|
2075
|
-
return method;
|
1904
|
+
var __typeError$6 = (msg) => {
|
1905
|
+
throw TypeError(msg);
|
2076
1906
|
};
|
2077
|
-
var
|
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,10 +1922,10 @@ function getFetchImplementation(userFetch) {
|
|
2087
1922
|
}
|
2088
1923
|
class ApiRequestPool {
|
2089
1924
|
constructor(concurrency = 10) {
|
2090
|
-
__privateAdd$6(this,
|
2091
|
-
__privateAdd$6(this, _fetch
|
2092
|
-
__privateAdd$6(this, _queue
|
2093
|
-
__privateAdd$6(this, _concurrency
|
1925
|
+
__privateAdd$6(this, _ApiRequestPool_instances);
|
1926
|
+
__privateAdd$6(this, _fetch);
|
1927
|
+
__privateAdd$6(this, _queue);
|
1928
|
+
__privateAdd$6(this, _concurrency);
|
2094
1929
|
__privateSet$4(this, _queue, []);
|
2095
1930
|
__privateSet$4(this, _concurrency, concurrency);
|
2096
1931
|
this.running = 0;
|
@@ -2125,7 +1960,7 @@ class ApiRequestPool {
|
|
2125
1960
|
}
|
2126
1961
|
return response;
|
2127
1962
|
};
|
2128
|
-
return __privateMethod$4(this,
|
1963
|
+
return __privateMethod$4(this, _ApiRequestPool_instances, enqueue_fn).call(this, async () => {
|
2129
1964
|
return await runRequest();
|
2130
1965
|
});
|
2131
1966
|
}
|
@@ -2133,7 +1968,7 @@ class ApiRequestPool {
|
|
2133
1968
|
_fetch = new WeakMap();
|
2134
1969
|
_queue = new WeakMap();
|
2135
1970
|
_concurrency = new WeakMap();
|
2136
|
-
|
1971
|
+
_ApiRequestPool_instances = new WeakSet();
|
2137
1972
|
enqueue_fn = function(task) {
|
2138
1973
|
const promise = new Promise((resolve) => __privateGet$5(this, _queue).push(resolve)).finally(() => {
|
2139
1974
|
this.started--;
|
@@ -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
|
}
|
@@ -2572,8 +2401,7 @@ async function fetch$1({
|
|
2572
2401
|
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
2573
2402
|
});
|
2574
2403
|
const message = response.headers?.get("x-xata-message");
|
2575
|
-
if (message)
|
2576
|
-
console.warn(message);
|
2404
|
+
if (message) console.warn(message);
|
2577
2405
|
if (response.status === 204) {
|
2578
2406
|
return {};
|
2579
2407
|
}
|
@@ -2657,7 +2485,18 @@ function parseUrl(url) {
|
|
2657
2485
|
|
2658
2486
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
2659
2487
|
|
2660
|
-
const applyMigration = (variables, signal) => dataPlaneFetch({
|
2488
|
+
const applyMigration = (variables, signal) => dataPlaneFetch({
|
2489
|
+
url: "/db/{dbBranchName}/migrations/apply",
|
2490
|
+
method: "post",
|
2491
|
+
...variables,
|
2492
|
+
signal
|
2493
|
+
});
|
2494
|
+
const startMigration = (variables, signal) => dataPlaneFetch({
|
2495
|
+
url: "/db/{dbBranchName}/migrations/start",
|
2496
|
+
method: "post",
|
2497
|
+
...variables,
|
2498
|
+
signal
|
2499
|
+
});
|
2661
2500
|
const adaptTable = (variables, signal) => dataPlaneFetch({
|
2662
2501
|
url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
|
2663
2502
|
method: "post",
|
@@ -2670,9 +2509,24 @@ const adaptAllTables = (variables, signal) => dataPlaneFetch({
|
|
2670
2509
|
...variables,
|
2671
2510
|
signal
|
2672
2511
|
});
|
2673
|
-
const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({
|
2674
|
-
|
2675
|
-
|
2512
|
+
const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({
|
2513
|
+
url: "/db/{dbBranchName}/migrations/status",
|
2514
|
+
method: "get",
|
2515
|
+
...variables,
|
2516
|
+
signal
|
2517
|
+
});
|
2518
|
+
const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({
|
2519
|
+
url: "/db/{dbBranchName}/migrations/jobs/{jobId}",
|
2520
|
+
method: "get",
|
2521
|
+
...variables,
|
2522
|
+
signal
|
2523
|
+
});
|
2524
|
+
const getMigrationHistory = (variables, signal) => dataPlaneFetch({
|
2525
|
+
url: "/db/{dbBranchName}/migrations/history",
|
2526
|
+
method: "get",
|
2527
|
+
...variables,
|
2528
|
+
signal
|
2529
|
+
});
|
2676
2530
|
const getBranchList = (variables, signal) => dataPlaneFetch({
|
2677
2531
|
url: "/dbs/{dbName}",
|
2678
2532
|
method: "get",
|
@@ -2731,12 +2585,42 @@ const getBranchStats = (variables, signal) => dataPlaneFetch({
|
|
2731
2585
|
});
|
2732
2586
|
const getGitBranchesMapping = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "get", ...variables, signal });
|
2733
2587
|
const addGitBranchesEntry = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/gitBranches", method: "post", ...variables, signal });
|
2734
|
-
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2588
|
+
const removeGitBranchesEntry = (variables, signal) => dataPlaneFetch({
|
2589
|
+
url: "/dbs/{dbName}/gitBranches",
|
2590
|
+
method: "delete",
|
2591
|
+
...variables,
|
2592
|
+
signal
|
2593
|
+
});
|
2594
|
+
const resolveBranch = (variables, signal) => dataPlaneFetch({
|
2595
|
+
url: "/dbs/{dbName}/resolveBranch",
|
2596
|
+
method: "get",
|
2597
|
+
...variables,
|
2598
|
+
signal
|
2599
|
+
});
|
2600
|
+
const getBranchMigrationHistory = (variables, signal) => dataPlaneFetch({
|
2601
|
+
url: "/db/{dbBranchName}/migrations",
|
2602
|
+
method: "get",
|
2603
|
+
...variables,
|
2604
|
+
signal
|
2605
|
+
});
|
2606
|
+
const getBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
|
2607
|
+
url: "/db/{dbBranchName}/migrations/plan",
|
2608
|
+
method: "post",
|
2609
|
+
...variables,
|
2610
|
+
signal
|
2611
|
+
});
|
2612
|
+
const executeBranchMigrationPlan = (variables, signal) => dataPlaneFetch({
|
2613
|
+
url: "/db/{dbBranchName}/migrations/execute",
|
2614
|
+
method: "post",
|
2615
|
+
...variables,
|
2616
|
+
signal
|
2617
|
+
});
|
2618
|
+
const queryMigrationRequests = (variables, signal) => dataPlaneFetch({
|
2619
|
+
url: "/dbs/{dbName}/migrations/query",
|
2620
|
+
method: "post",
|
2621
|
+
...variables,
|
2622
|
+
signal
|
2623
|
+
});
|
2740
2624
|
const createMigrationRequest = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/migrations", method: "post", ...variables, signal });
|
2741
2625
|
const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
2742
2626
|
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
@@ -2744,23 +2628,78 @@ const getMigrationRequest = (variables, signal) => dataPlaneFetch({
|
|
2744
2628
|
...variables,
|
2745
2629
|
signal
|
2746
2630
|
});
|
2747
|
-
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2631
|
+
const updateMigrationRequest = (variables, signal) => dataPlaneFetch({
|
2632
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}",
|
2633
|
+
method: "patch",
|
2634
|
+
...variables,
|
2635
|
+
signal
|
2636
|
+
});
|
2637
|
+
const listMigrationRequestsCommits = (variables, signal) => dataPlaneFetch({
|
2638
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/commits",
|
2639
|
+
method: "post",
|
2640
|
+
...variables,
|
2641
|
+
signal
|
2642
|
+
});
|
2643
|
+
const compareMigrationRequest = (variables, signal) => dataPlaneFetch({
|
2644
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/compare",
|
2645
|
+
method: "post",
|
2646
|
+
...variables,
|
2647
|
+
signal
|
2648
|
+
});
|
2649
|
+
const getMigrationRequestIsMerged = (variables, signal) => dataPlaneFetch({
|
2650
|
+
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
2651
|
+
method: "get",
|
2652
|
+
...variables,
|
2653
|
+
signal
|
2654
|
+
});
|
2751
2655
|
const mergeMigrationRequest = (variables, signal) => dataPlaneFetch({
|
2752
2656
|
url: "/dbs/{dbName}/migrations/{mrNumber}/merge",
|
2753
2657
|
method: "post",
|
2754
2658
|
...variables,
|
2755
2659
|
signal
|
2756
2660
|
});
|
2757
|
-
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
const
|
2661
|
+
const getBranchSchemaHistory = (variables, signal) => dataPlaneFetch({
|
2662
|
+
url: "/db/{dbBranchName}/schema/history",
|
2663
|
+
method: "post",
|
2664
|
+
...variables,
|
2665
|
+
signal
|
2666
|
+
});
|
2667
|
+
const compareBranchWithUserSchema = (variables, signal) => dataPlaneFetch({
|
2668
|
+
url: "/db/{dbBranchName}/schema/compare",
|
2669
|
+
method: "post",
|
2670
|
+
...variables,
|
2671
|
+
signal
|
2672
|
+
});
|
2673
|
+
const compareBranchSchemas = (variables, signal) => dataPlaneFetch({
|
2674
|
+
url: "/db/{dbBranchName}/schema/compare/{branchName}",
|
2675
|
+
method: "post",
|
2676
|
+
...variables,
|
2677
|
+
signal
|
2678
|
+
});
|
2679
|
+
const updateBranchSchema = (variables, signal) => dataPlaneFetch({
|
2680
|
+
url: "/db/{dbBranchName}/schema/update",
|
2681
|
+
method: "post",
|
2682
|
+
...variables,
|
2683
|
+
signal
|
2684
|
+
});
|
2685
|
+
const previewBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
|
2686
|
+
url: "/db/{dbBranchName}/schema/preview",
|
2687
|
+
method: "post",
|
2688
|
+
...variables,
|
2689
|
+
signal
|
2690
|
+
});
|
2691
|
+
const applyBranchSchemaEdit = (variables, signal) => dataPlaneFetch({
|
2692
|
+
url: "/db/{dbBranchName}/schema/apply",
|
2693
|
+
method: "post",
|
2694
|
+
...variables,
|
2695
|
+
signal
|
2696
|
+
});
|
2697
|
+
const pushBranchMigrations = (variables, signal) => dataPlaneFetch({
|
2698
|
+
url: "/db/{dbBranchName}/schema/push",
|
2699
|
+
method: "post",
|
2700
|
+
...variables,
|
2701
|
+
signal
|
2702
|
+
});
|
2764
2703
|
const createTable = (variables, signal) => dataPlaneFetch({
|
2765
2704
|
url: "/db/{dbBranchName}/tables/{tableName}",
|
2766
2705
|
method: "put",
|
@@ -2773,14 +2712,24 @@ const deleteTable = (variables, signal) => dataPlaneFetch({
|
|
2773
2712
|
...variables,
|
2774
2713
|
signal
|
2775
2714
|
});
|
2776
|
-
const updateTable = (variables, signal) => dataPlaneFetch({
|
2715
|
+
const updateTable = (variables, signal) => dataPlaneFetch({
|
2716
|
+
url: "/db/{dbBranchName}/tables/{tableName}",
|
2717
|
+
method: "patch",
|
2718
|
+
...variables,
|
2719
|
+
signal
|
2720
|
+
});
|
2777
2721
|
const getTableSchema = (variables, signal) => dataPlaneFetch({
|
2778
2722
|
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
2779
2723
|
method: "get",
|
2780
2724
|
...variables,
|
2781
2725
|
signal
|
2782
2726
|
});
|
2783
|
-
const setTableSchema = (variables, signal) => dataPlaneFetch({
|
2727
|
+
const setTableSchema = (variables, signal) => dataPlaneFetch({
|
2728
|
+
url: "/db/{dbBranchName}/tables/{tableName}/schema",
|
2729
|
+
method: "put",
|
2730
|
+
...variables,
|
2731
|
+
signal
|
2732
|
+
});
|
2784
2733
|
const getTableColumns = (variables, signal) => dataPlaneFetch({
|
2785
2734
|
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
2786
2735
|
method: "get",
|
@@ -2788,7 +2737,12 @@ const getTableColumns = (variables, signal) => dataPlaneFetch({
|
|
2788
2737
|
signal
|
2789
2738
|
});
|
2790
2739
|
const addTableColumn = (variables, signal) => dataPlaneFetch(
|
2791
|
-
{
|
2740
|
+
{
|
2741
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns",
|
2742
|
+
method: "post",
|
2743
|
+
...variables,
|
2744
|
+
signal
|
2745
|
+
}
|
2792
2746
|
);
|
2793
2747
|
const getColumn = (variables, signal) => dataPlaneFetch({
|
2794
2748
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
@@ -2796,15 +2750,30 @@ const getColumn = (variables, signal) => dataPlaneFetch({
|
|
2796
2750
|
...variables,
|
2797
2751
|
signal
|
2798
2752
|
});
|
2799
|
-
const updateColumn = (variables, signal) => dataPlaneFetch({
|
2753
|
+
const updateColumn = (variables, signal) => dataPlaneFetch({
|
2754
|
+
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
2755
|
+
method: "patch",
|
2756
|
+
...variables,
|
2757
|
+
signal
|
2758
|
+
});
|
2800
2759
|
const deleteColumn = (variables, signal) => dataPlaneFetch({
|
2801
2760
|
url: "/db/{dbBranchName}/tables/{tableName}/columns/{columnName}",
|
2802
2761
|
method: "delete",
|
2803
2762
|
...variables,
|
2804
2763
|
signal
|
2805
2764
|
});
|
2806
|
-
const branchTransaction = (variables, signal) => dataPlaneFetch({
|
2807
|
-
|
2765
|
+
const branchTransaction = (variables, signal) => dataPlaneFetch({
|
2766
|
+
url: "/db/{dbBranchName}/transaction",
|
2767
|
+
method: "post",
|
2768
|
+
...variables,
|
2769
|
+
signal
|
2770
|
+
});
|
2771
|
+
const insertRecord = (variables, signal) => dataPlaneFetch({
|
2772
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data",
|
2773
|
+
method: "post",
|
2774
|
+
...variables,
|
2775
|
+
signal
|
2776
|
+
});
|
2808
2777
|
const getFileItem = (variables, signal) => dataPlaneFetch({
|
2809
2778
|
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}/column/{columnName}/file/{fileId}",
|
2810
2779
|
method: "get",
|
@@ -2847,11 +2816,36 @@ const getRecord = (variables, signal) => dataPlaneFetch({
|
|
2847
2816
|
...variables,
|
2848
2817
|
signal
|
2849
2818
|
});
|
2850
|
-
const insertRecordWithID = (variables, signal) => dataPlaneFetch({
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2819
|
+
const insertRecordWithID = (variables, signal) => dataPlaneFetch({
|
2820
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
2821
|
+
method: "put",
|
2822
|
+
...variables,
|
2823
|
+
signal
|
2824
|
+
});
|
2825
|
+
const updateRecordWithID = (variables, signal) => dataPlaneFetch({
|
2826
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
2827
|
+
method: "patch",
|
2828
|
+
...variables,
|
2829
|
+
signal
|
2830
|
+
});
|
2831
|
+
const upsertRecordWithID = (variables, signal) => dataPlaneFetch({
|
2832
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
2833
|
+
method: "post",
|
2834
|
+
...variables,
|
2835
|
+
signal
|
2836
|
+
});
|
2837
|
+
const deleteRecord = (variables, signal) => dataPlaneFetch({
|
2838
|
+
url: "/db/{dbBranchName}/tables/{tableName}/data/{recordId}",
|
2839
|
+
method: "delete",
|
2840
|
+
...variables,
|
2841
|
+
signal
|
2842
|
+
});
|
2843
|
+
const bulkInsertTableRecords = (variables, signal) => dataPlaneFetch({
|
2844
|
+
url: "/db/{dbBranchName}/tables/{tableName}/bulk",
|
2845
|
+
method: "post",
|
2846
|
+
...variables,
|
2847
|
+
signal
|
2848
|
+
});
|
2855
2849
|
const queryTable = (variables, signal) => dataPlaneFetch({
|
2856
2850
|
url: "/db/{dbBranchName}/tables/{tableName}/query",
|
2857
2851
|
method: "post",
|
@@ -2870,16 +2864,36 @@ const searchTable = (variables, signal) => dataPlaneFetch({
|
|
2870
2864
|
...variables,
|
2871
2865
|
signal
|
2872
2866
|
});
|
2873
|
-
const vectorSearchTable = (variables, signal) => dataPlaneFetch({
|
2867
|
+
const vectorSearchTable = (variables, signal) => dataPlaneFetch({
|
2868
|
+
url: "/db/{dbBranchName}/tables/{tableName}/vectorSearch",
|
2869
|
+
method: "post",
|
2870
|
+
...variables,
|
2871
|
+
signal
|
2872
|
+
});
|
2874
2873
|
const askTable = (variables, signal) => dataPlaneFetch({
|
2875
2874
|
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
2876
2875
|
method: "post",
|
2877
2876
|
...variables,
|
2878
2877
|
signal
|
2879
2878
|
});
|
2880
|
-
const askTableSession = (variables, signal) => dataPlaneFetch({
|
2881
|
-
|
2882
|
-
|
2879
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({
|
2880
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
2881
|
+
method: "post",
|
2882
|
+
...variables,
|
2883
|
+
signal
|
2884
|
+
});
|
2885
|
+
const summarizeTable = (variables, signal) => dataPlaneFetch({
|
2886
|
+
url: "/db/{dbBranchName}/tables/{tableName}/summarize",
|
2887
|
+
method: "post",
|
2888
|
+
...variables,
|
2889
|
+
signal
|
2890
|
+
});
|
2891
|
+
const aggregateTable = (variables, signal) => dataPlaneFetch({
|
2892
|
+
url: "/db/{dbBranchName}/tables/{tableName}/aggregate",
|
2893
|
+
method: "post",
|
2894
|
+
...variables,
|
2895
|
+
signal
|
2896
|
+
});
|
2883
2897
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
2884
2898
|
url: "/file/{fileId}",
|
2885
2899
|
method: "get",
|
@@ -2901,6 +2915,7 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
2901
2915
|
const operationsByTag$2 = {
|
2902
2916
|
migrations: {
|
2903
2917
|
applyMigration,
|
2918
|
+
startMigration,
|
2904
2919
|
adaptTable,
|
2905
2920
|
adaptAllTables,
|
2906
2921
|
getBranchMigrationJobStatus,
|
@@ -2965,7 +2980,16 @@ const operationsByTag$2 = {
|
|
2965
2980
|
deleteRecord,
|
2966
2981
|
bulkInsertTableRecords
|
2967
2982
|
},
|
2968
|
-
files: {
|
2983
|
+
files: {
|
2984
|
+
getFileItem,
|
2985
|
+
putFileItem,
|
2986
|
+
deleteFileItem,
|
2987
|
+
getFile,
|
2988
|
+
putFile,
|
2989
|
+
deleteFile,
|
2990
|
+
fileAccess,
|
2991
|
+
fileUpload
|
2992
|
+
},
|
2969
2993
|
searchAndFilter: {
|
2970
2994
|
queryTable,
|
2971
2995
|
searchBranch,
|
@@ -3043,7 +3067,12 @@ const deleteOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
|
3043
3067
|
...variables,
|
3044
3068
|
signal
|
3045
3069
|
});
|
3046
|
-
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
3070
|
+
const updateOAuthAccessToken = (variables, signal) => controlPlaneFetch({
|
3071
|
+
url: "/user/oauth/tokens/{token}",
|
3072
|
+
method: "patch",
|
3073
|
+
...variables,
|
3074
|
+
signal
|
3075
|
+
});
|
3047
3076
|
const getWorkspacesList = (variables, signal) => controlPlaneFetch({
|
3048
3077
|
url: "/workspaces",
|
3049
3078
|
method: "get",
|
@@ -3074,49 +3103,150 @@ const deleteWorkspace = (variables, signal) => controlPlaneFetch({
|
|
3074
3103
|
...variables,
|
3075
3104
|
signal
|
3076
3105
|
});
|
3077
|
-
const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3106
|
+
const getWorkspaceSettings = (variables, signal) => controlPlaneFetch({
|
3107
|
+
url: "/workspaces/{workspaceId}/settings",
|
3108
|
+
method: "get",
|
3109
|
+
...variables,
|
3110
|
+
signal
|
3111
|
+
});
|
3112
|
+
const updateWorkspaceSettings = (variables, signal) => controlPlaneFetch({
|
3113
|
+
url: "/workspaces/{workspaceId}/settings",
|
3114
|
+
method: "patch",
|
3115
|
+
...variables,
|
3116
|
+
signal
|
3117
|
+
});
|
3118
|
+
const getWorkspaceMembersList = (variables, signal) => controlPlaneFetch({
|
3119
|
+
url: "/workspaces/{workspaceId}/members",
|
3120
|
+
method: "get",
|
3121
|
+
...variables,
|
3122
|
+
signal
|
3123
|
+
});
|
3124
|
+
const updateWorkspaceMemberRole = (variables, signal) => controlPlaneFetch({
|
3125
|
+
url: "/workspaces/{workspaceId}/members/{userId}",
|
3126
|
+
method: "put",
|
3127
|
+
...variables,
|
3128
|
+
signal
|
3129
|
+
});
|
3081
3130
|
const removeWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
3082
3131
|
url: "/workspaces/{workspaceId}/members/{userId}",
|
3083
3132
|
method: "delete",
|
3084
3133
|
...variables,
|
3085
3134
|
signal
|
3086
3135
|
});
|
3087
|
-
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
const
|
3136
|
+
const inviteWorkspaceMember = (variables, signal) => controlPlaneFetch({
|
3137
|
+
url: "/workspaces/{workspaceId}/invites",
|
3138
|
+
method: "post",
|
3139
|
+
...variables,
|
3140
|
+
signal
|
3141
|
+
});
|
3142
|
+
const updateWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
|
3143
|
+
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
3144
|
+
method: "patch",
|
3145
|
+
...variables,
|
3146
|
+
signal
|
3147
|
+
});
|
3148
|
+
const cancelWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
|
3149
|
+
url: "/workspaces/{workspaceId}/invites/{inviteId}",
|
3150
|
+
method: "delete",
|
3151
|
+
...variables,
|
3152
|
+
signal
|
3153
|
+
});
|
3154
|
+
const acceptWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
|
3155
|
+
url: "/workspaces/{workspaceId}/invites/{inviteKey}/accept",
|
3156
|
+
method: "post",
|
3157
|
+
...variables,
|
3158
|
+
signal
|
3159
|
+
});
|
3160
|
+
const resendWorkspaceMemberInvite = (variables, signal) => controlPlaneFetch({
|
3161
|
+
url: "/workspaces/{workspaceId}/invites/{inviteId}/resend",
|
3162
|
+
method: "post",
|
3163
|
+
...variables,
|
3164
|
+
signal
|
3165
|
+
});
|
3166
|
+
const listClusters = (variables, signal) => controlPlaneFetch({
|
3167
|
+
url: "/workspaces/{workspaceId}/clusters",
|
3168
|
+
method: "get",
|
3169
|
+
...variables,
|
3170
|
+
signal
|
3171
|
+
});
|
3172
|
+
const createCluster = (variables, signal) => controlPlaneFetch({
|
3173
|
+
url: "/workspaces/{workspaceId}/clusters",
|
3174
|
+
method: "post",
|
3175
|
+
...variables,
|
3176
|
+
signal
|
3177
|
+
});
|
3094
3178
|
const getCluster = (variables, signal) => controlPlaneFetch({
|
3095
3179
|
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
3096
3180
|
method: "get",
|
3097
3181
|
...variables,
|
3098
3182
|
signal
|
3099
3183
|
});
|
3100
|
-
const updateCluster = (variables, signal) => controlPlaneFetch({
|
3184
|
+
const updateCluster = (variables, signal) => controlPlaneFetch({
|
3185
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
3186
|
+
method: "patch",
|
3187
|
+
...variables,
|
3188
|
+
signal
|
3189
|
+
});
|
3190
|
+
const deleteCluster = (variables, signal) => controlPlaneFetch({
|
3191
|
+
url: "/workspaces/{workspaceId}/clusters/{clusterId}",
|
3192
|
+
method: "delete",
|
3193
|
+
...variables,
|
3194
|
+
signal
|
3195
|
+
});
|
3101
3196
|
const getDatabaseList = (variables, signal) => controlPlaneFetch({
|
3102
3197
|
url: "/workspaces/{workspaceId}/dbs",
|
3103
3198
|
method: "get",
|
3104
3199
|
...variables,
|
3105
3200
|
signal
|
3106
3201
|
});
|
3107
|
-
const createDatabase = (variables, signal) => controlPlaneFetch({
|
3202
|
+
const createDatabase = (variables, signal) => controlPlaneFetch({
|
3203
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
3204
|
+
method: "put",
|
3205
|
+
...variables,
|
3206
|
+
signal
|
3207
|
+
});
|
3108
3208
|
const deleteDatabase = (variables, signal) => controlPlaneFetch({
|
3109
3209
|
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
3110
3210
|
method: "delete",
|
3111
3211
|
...variables,
|
3112
3212
|
signal
|
3113
3213
|
});
|
3114
|
-
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3214
|
+
const getDatabaseMetadata = (variables, signal) => controlPlaneFetch({
|
3215
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
3216
|
+
method: "get",
|
3217
|
+
...variables,
|
3218
|
+
signal
|
3219
|
+
});
|
3220
|
+
const updateDatabaseMetadata = (variables, signal) => controlPlaneFetch({
|
3221
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}",
|
3222
|
+
method: "patch",
|
3223
|
+
...variables,
|
3224
|
+
signal
|
3225
|
+
});
|
3226
|
+
const renameDatabase = (variables, signal) => controlPlaneFetch({
|
3227
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}/rename",
|
3228
|
+
method: "post",
|
3229
|
+
...variables,
|
3230
|
+
signal
|
3231
|
+
});
|
3232
|
+
const getDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
|
3233
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
|
3234
|
+
method: "get",
|
3235
|
+
...variables,
|
3236
|
+
signal
|
3237
|
+
});
|
3238
|
+
const updateDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
|
3239
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
|
3240
|
+
method: "put",
|
3241
|
+
...variables,
|
3242
|
+
signal
|
3243
|
+
});
|
3244
|
+
const deleteDatabaseGithubSettings = (variables, signal) => controlPlaneFetch({
|
3245
|
+
url: "/workspaces/{workspaceId}/dbs/{dbName}/github",
|
3246
|
+
method: "delete",
|
3247
|
+
...variables,
|
3248
|
+
signal
|
3249
|
+
});
|
3120
3250
|
const listRegions = (variables, signal) => controlPlaneFetch({
|
3121
3251
|
url: "/workspaces/{workspaceId}/regions",
|
3122
3252
|
method: "get",
|
@@ -3154,7 +3284,13 @@ const operationsByTag$1 = {
|
|
3154
3284
|
acceptWorkspaceMemberInvite,
|
3155
3285
|
resendWorkspaceMemberInvite
|
3156
3286
|
},
|
3157
|
-
xbcontrolOther: {
|
3287
|
+
xbcontrolOther: {
|
3288
|
+
listClusters,
|
3289
|
+
createCluster,
|
3290
|
+
getCluster,
|
3291
|
+
updateCluster,
|
3292
|
+
deleteCluster
|
3293
|
+
},
|
3158
3294
|
databases: {
|
3159
3295
|
getDatabaseList,
|
3160
3296
|
createDatabase,
|
@@ -3174,7 +3310,7 @@ const operationsByTag = deepMerge(operationsByTag$2, operationsByTag$1);
|
|
3174
3310
|
const buildApiClient = () => class {
|
3175
3311
|
constructor(options = {}) {
|
3176
3312
|
const provider = options.host ?? "production";
|
3177
|
-
const apiKey = options.apiKey
|
3313
|
+
const apiKey = options.apiKey;
|
3178
3314
|
const trace = options.trace ?? defaultTrace;
|
3179
3315
|
const clientID = generateUUID();
|
3180
3316
|
if (!apiKey) {
|
@@ -3241,8 +3377,7 @@ function buildTransformString(transformations) {
|
|
3241
3377
|
).join(",");
|
3242
3378
|
}
|
3243
3379
|
function transformImage(url, ...transformations) {
|
3244
|
-
if (!isDefined(url))
|
3245
|
-
return void 0;
|
3380
|
+
if (!isDefined(url)) return void 0;
|
3246
3381
|
const newTransformations = buildTransformString(transformations);
|
3247
3382
|
const { hostname, pathname, search } = new URL(url);
|
3248
3383
|
const pathParts = pathname.split("/");
|
@@ -3355,8 +3490,7 @@ class XataFile {
|
|
3355
3490
|
}
|
3356
3491
|
}
|
3357
3492
|
const parseInputFileEntry = async (entry) => {
|
3358
|
-
if (!isDefined(entry))
|
3359
|
-
return null;
|
3493
|
+
if (!isDefined(entry)) return null;
|
3360
3494
|
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
3361
3495
|
return compactObject({
|
3362
3496
|
id,
|
@@ -3371,24 +3505,19 @@ const parseInputFileEntry = async (entry) => {
|
|
3371
3505
|
};
|
3372
3506
|
|
3373
3507
|
function cleanFilter(filter) {
|
3374
|
-
if (!isDefined(filter))
|
3375
|
-
|
3376
|
-
if (!isObject(filter))
|
3377
|
-
return filter;
|
3508
|
+
if (!isDefined(filter)) return void 0;
|
3509
|
+
if (!isObject(filter)) return filter;
|
3378
3510
|
const values = Object.fromEntries(
|
3379
3511
|
Object.entries(filter).reduce((acc, [key, value]) => {
|
3380
|
-
if (!isDefined(value))
|
3381
|
-
return acc;
|
3512
|
+
if (!isDefined(value)) return acc;
|
3382
3513
|
if (Array.isArray(value)) {
|
3383
3514
|
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
3384
|
-
if (clean.length === 0)
|
3385
|
-
return acc;
|
3515
|
+
if (clean.length === 0) return acc;
|
3386
3516
|
return [...acc, [key, clean]];
|
3387
3517
|
}
|
3388
3518
|
if (isObject(value)) {
|
3389
3519
|
const clean = cleanFilter(value);
|
3390
|
-
if (!isDefined(clean))
|
3391
|
-
return acc;
|
3520
|
+
if (!isDefined(clean)) return acc;
|
3392
3521
|
return [...acc, [key, clean]];
|
3393
3522
|
}
|
3394
3523
|
return [...acc, [key, value]];
|
@@ -3398,10 +3527,8 @@ function cleanFilter(filter) {
|
|
3398
3527
|
}
|
3399
3528
|
|
3400
3529
|
function stringifyJson(value) {
|
3401
|
-
if (!isDefined(value))
|
3402
|
-
|
3403
|
-
if (isString(value))
|
3404
|
-
return value;
|
3530
|
+
if (!isDefined(value)) return value;
|
3531
|
+
if (isString(value)) return value;
|
3405
3532
|
try {
|
3406
3533
|
return JSON.stringify(value);
|
3407
3534
|
} catch (e) {
|
@@ -3416,28 +3543,17 @@ function parseJson(value) {
|
|
3416
3543
|
}
|
3417
3544
|
}
|
3418
3545
|
|
3419
|
-
var
|
3420
|
-
|
3421
|
-
throw TypeError("Cannot " + msg);
|
3422
|
-
};
|
3423
|
-
var __privateGet$4 = (obj, member, getter) => {
|
3424
|
-
__accessCheck$5(obj, member, "read from private field");
|
3425
|
-
return getter ? getter.call(obj) : member.get(obj);
|
3426
|
-
};
|
3427
|
-
var __privateAdd$5 = (obj, member, value) => {
|
3428
|
-
if (member.has(obj))
|
3429
|
-
throw TypeError("Cannot add the same private member more than once");
|
3430
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3431
|
-
};
|
3432
|
-
var __privateSet$3 = (obj, member, value, setter) => {
|
3433
|
-
__accessCheck$5(obj, member, "write to private field");
|
3434
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
3435
|
-
return value;
|
3546
|
+
var __typeError$5 = (msg) => {
|
3547
|
+
throw TypeError(msg);
|
3436
3548
|
};
|
3549
|
+
var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
|
3550
|
+
var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
3551
|
+
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);
|
3552
|
+
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
|
3437
3553
|
var _query, _page;
|
3438
3554
|
class Page {
|
3439
3555
|
constructor(query, meta, records = []) {
|
3440
|
-
__privateAdd$5(this, _query
|
3556
|
+
__privateAdd$5(this, _query);
|
3441
3557
|
__privateSet$3(this, _query, query);
|
3442
3558
|
this.meta = meta;
|
3443
3559
|
this.records = new PageRecordArray(this, records);
|
@@ -3524,7 +3640,7 @@ class RecordArray extends Array {
|
|
3524
3640
|
const _PageRecordArray = class _PageRecordArray extends Array {
|
3525
3641
|
constructor(...args) {
|
3526
3642
|
super(..._PageRecordArray.parseConstructorParams(...args));
|
3527
|
-
__privateAdd$5(this, _page
|
3643
|
+
__privateAdd$5(this, _page);
|
3528
3644
|
__privateSet$3(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
3529
3645
|
}
|
3530
3646
|
static parseConstructorParams(...args) {
|
@@ -3595,34 +3711,20 @@ const _PageRecordArray = class _PageRecordArray extends Array {
|
|
3595
3711
|
_page = new WeakMap();
|
3596
3712
|
let PageRecordArray = _PageRecordArray;
|
3597
3713
|
|
3598
|
-
var
|
3599
|
-
|
3600
|
-
throw TypeError("Cannot " + msg);
|
3714
|
+
var __typeError$4 = (msg) => {
|
3715
|
+
throw TypeError(msg);
|
3601
3716
|
};
|
3602
|
-
var
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
var
|
3607
|
-
|
3608
|
-
throw TypeError("Cannot add the same private member more than once");
|
3609
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3610
|
-
};
|
3611
|
-
var __privateSet$2 = (obj, member, value, setter) => {
|
3612
|
-
__accessCheck$4(obj, member, "write to private field");
|
3613
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
3614
|
-
return value;
|
3615
|
-
};
|
3616
|
-
var __privateMethod$3 = (obj, member, method) => {
|
3617
|
-
__accessCheck$4(obj, member, "access private method");
|
3618
|
-
return method;
|
3619
|
-
};
|
3620
|
-
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
3717
|
+
var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
|
3718
|
+
var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
3719
|
+
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);
|
3720
|
+
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
3721
|
+
var __privateMethod$3 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
|
3722
|
+
var _table$1, _repository, _data, _Query_instances, cleanFilterConstraint_fn;
|
3621
3723
|
const _Query = class _Query {
|
3622
3724
|
constructor(repository, table, data, rawParent) {
|
3623
|
-
__privateAdd$4(this,
|
3624
|
-
__privateAdd$4(this, _table$1
|
3625
|
-
__privateAdd$4(this, _repository
|
3725
|
+
__privateAdd$4(this, _Query_instances);
|
3726
|
+
__privateAdd$4(this, _table$1);
|
3727
|
+
__privateAdd$4(this, _repository);
|
3626
3728
|
__privateAdd$4(this, _data, { filter: {} });
|
3627
3729
|
// Implements pagination
|
3628
3730
|
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
@@ -3700,12 +3802,12 @@ const _Query = class _Query {
|
|
3700
3802
|
filter(a, b) {
|
3701
3803
|
if (arguments.length === 1) {
|
3702
3804
|
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
3703
|
-
[column]: __privateMethod$3(this,
|
3805
|
+
[column]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, column, constraint)
|
3704
3806
|
}));
|
3705
3807
|
const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
|
3706
3808
|
return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
|
3707
3809
|
} else {
|
3708
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this,
|
3810
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
3709
3811
|
const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
|
3710
3812
|
return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
|
3711
3813
|
}
|
@@ -3784,8 +3886,7 @@ const _Query = class _Query {
|
|
3784
3886
|
}
|
3785
3887
|
async getFirstOrThrow(options = {}) {
|
3786
3888
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
3787
|
-
if (records[0] === void 0)
|
3788
|
-
throw new Error("No results found.");
|
3889
|
+
if (records[0] === void 0) throw new Error("No results found.");
|
3789
3890
|
return records[0];
|
3790
3891
|
}
|
3791
3892
|
async summarize(params = {}) {
|
@@ -3840,7 +3941,7 @@ const _Query = class _Query {
|
|
3840
3941
|
_table$1 = new WeakMap();
|
3841
3942
|
_repository = new WeakMap();
|
3842
3943
|
_data = new WeakMap();
|
3843
|
-
|
3944
|
+
_Query_instances = new WeakSet();
|
3844
3945
|
cleanFilterConstraint_fn = function(column, value) {
|
3845
3946
|
const columnType = __privateGet$3(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
3846
3947
|
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
@@ -3901,8 +4002,7 @@ function isSortFilterString(value) {
|
|
3901
4002
|
}
|
3902
4003
|
function isSortFilterBase(filter) {
|
3903
4004
|
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
3904
|
-
if (key === "*")
|
3905
|
-
return value === "random";
|
4005
|
+
if (key === "*") return value === "random";
|
3906
4006
|
return value === "asc" || value === "desc";
|
3907
4007
|
});
|
3908
4008
|
}
|
@@ -3923,29 +4023,15 @@ function buildSortFilter(filter) {
|
|
3923
4023
|
}
|
3924
4024
|
}
|
3925
4025
|
|
3926
|
-
var
|
3927
|
-
|
3928
|
-
throw TypeError("Cannot " + msg);
|
3929
|
-
};
|
3930
|
-
var __privateGet$2 = (obj, member, getter) => {
|
3931
|
-
__accessCheck$3(obj, member, "read from private field");
|
3932
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4026
|
+
var __typeError$3 = (msg) => {
|
4027
|
+
throw TypeError(msg);
|
3933
4028
|
};
|
3934
|
-
var
|
3935
|
-
|
3936
|
-
|
3937
|
-
|
3938
|
-
|
3939
|
-
var
|
3940
|
-
__accessCheck$3(obj, member, "write to private field");
|
3941
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
3942
|
-
return value;
|
3943
|
-
};
|
3944
|
-
var __privateMethod$2 = (obj, member, method) => {
|
3945
|
-
__accessCheck$3(obj, member, "access private method");
|
3946
|
-
return method;
|
3947
|
-
};
|
3948
|
-
var _table, _getFetchProps, _db, _schemaTables, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _getSchemaTables, getSchemaTables_fn, _transformObjectToApi, transformObjectToApi_fn;
|
4029
|
+
var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
|
4030
|
+
var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
4031
|
+
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);
|
4032
|
+
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
4033
|
+
var __privateMethod$2 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
|
4034
|
+
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;
|
3949
4035
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
3950
4036
|
class Repository extends Query {
|
3951
4037
|
}
|
@@ -3956,21 +4042,12 @@ class RestRepository extends Query {
|
|
3956
4042
|
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
3957
4043
|
{}
|
3958
4044
|
);
|
3959
|
-
__privateAdd$3(this,
|
3960
|
-
__privateAdd$3(this,
|
3961
|
-
__privateAdd$3(this,
|
3962
|
-
__privateAdd$3(this,
|
3963
|
-
__privateAdd$3(this,
|
3964
|
-
__privateAdd$3(this,
|
3965
|
-
__privateAdd$3(this, _deleteRecord);
|
3966
|
-
__privateAdd$3(this, _deleteRecords);
|
3967
|
-
__privateAdd$3(this, _getSchemaTables);
|
3968
|
-
__privateAdd$3(this, _transformObjectToApi);
|
3969
|
-
__privateAdd$3(this, _table, void 0);
|
3970
|
-
__privateAdd$3(this, _getFetchProps, void 0);
|
3971
|
-
__privateAdd$3(this, _db, void 0);
|
3972
|
-
__privateAdd$3(this, _schemaTables, void 0);
|
3973
|
-
__privateAdd$3(this, _trace, void 0);
|
4045
|
+
__privateAdd$3(this, _RestRepository_instances);
|
4046
|
+
__privateAdd$3(this, _table);
|
4047
|
+
__privateAdd$3(this, _getFetchProps);
|
4048
|
+
__privateAdd$3(this, _db);
|
4049
|
+
__privateAdd$3(this, _schemaTables);
|
4050
|
+
__privateAdd$3(this, _trace);
|
3974
4051
|
__privateSet$1(this, _table, options.table);
|
3975
4052
|
__privateSet$1(this, _db, options.db);
|
3976
4053
|
__privateSet$1(this, _schemaTables, options.schemaTables);
|
@@ -3989,31 +4066,28 @@ class RestRepository extends Query {
|
|
3989
4066
|
return __privateGet$2(this, _trace).call(this, "create", async () => {
|
3990
4067
|
const ifVersion = parseIfVersion(b, c, d);
|
3991
4068
|
if (Array.isArray(a)) {
|
3992
|
-
if (a.length === 0)
|
3993
|
-
|
3994
|
-
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
4069
|
+
if (a.length === 0) return [];
|
4070
|
+
const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
3995
4071
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
3996
4072
|
const result = await this.read(ids, columns);
|
3997
4073
|
return result;
|
3998
4074
|
}
|
3999
4075
|
if (isString(a) && isObject(b)) {
|
4000
|
-
if (a === "")
|
4001
|
-
throw new Error("The id can't be empty");
|
4076
|
+
if (a === "") throw new Error("The id can't be empty");
|
4002
4077
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4003
|
-
return await __privateMethod$2(this,
|
4078
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
4004
4079
|
}
|
4005
4080
|
if (isObject(a) && isString(a.xata_id)) {
|
4006
|
-
if (a.xata_id === "")
|
4007
|
-
throw new Error("The id can't be empty");
|
4081
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4008
4082
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4009
|
-
return await __privateMethod$2(this,
|
4083
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
|
4010
4084
|
createOnly: true,
|
4011
4085
|
ifVersion
|
4012
4086
|
});
|
4013
4087
|
}
|
4014
4088
|
if (isObject(a)) {
|
4015
4089
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4016
|
-
return __privateMethod$2(this,
|
4090
|
+
return __privateMethod$2(this, _RestRepository_instances, insertRecordWithoutId_fn).call(this, a, columns);
|
4017
4091
|
}
|
4018
4092
|
throw new Error("Invalid arguments for create method");
|
4019
4093
|
});
|
@@ -4022,8 +4096,7 @@ class RestRepository extends Query {
|
|
4022
4096
|
return __privateGet$2(this, _trace).call(this, "read", async () => {
|
4023
4097
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4024
4098
|
if (Array.isArray(a)) {
|
4025
|
-
if (a.length === 0)
|
4026
|
-
return [];
|
4099
|
+
if (a.length === 0) return [];
|
4027
4100
|
const ids = a.map((item) => extractId(item));
|
4028
4101
|
const finalObjects = await this.getAll({ filter: { xata_id: { $any: compact(ids) } }, columns });
|
4029
4102
|
const dictionary = finalObjects.reduce((acc, object) => {
|
@@ -4046,7 +4119,7 @@ class RestRepository extends Query {
|
|
4046
4119
|
queryParams: { columns },
|
4047
4120
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4048
4121
|
});
|
4049
|
-
const schemaTables = await __privateMethod$2(this,
|
4122
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4050
4123
|
return initObject(
|
4051
4124
|
__privateGet$2(this, _db),
|
4052
4125
|
schemaTables,
|
@@ -4087,11 +4160,10 @@ class RestRepository extends Query {
|
|
4087
4160
|
return __privateGet$2(this, _trace).call(this, "update", async () => {
|
4088
4161
|
const ifVersion = parseIfVersion(b, c, d);
|
4089
4162
|
if (Array.isArray(a)) {
|
4090
|
-
if (a.length === 0)
|
4091
|
-
return [];
|
4163
|
+
if (a.length === 0) return [];
|
4092
4164
|
const existing = await this.read(a, ["xata_id"]);
|
4093
4165
|
const updates = a.filter((_item, index) => existing[index] !== null);
|
4094
|
-
await __privateMethod$2(this,
|
4166
|
+
await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, updates, {
|
4095
4167
|
ifVersion,
|
4096
4168
|
upsert: false
|
4097
4169
|
});
|
@@ -4102,15 +4174,14 @@ class RestRepository extends Query {
|
|
4102
4174
|
try {
|
4103
4175
|
if (isString(a) && isObject(b)) {
|
4104
4176
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4105
|
-
return await __privateMethod$2(this,
|
4177
|
+
return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
4106
4178
|
}
|
4107
4179
|
if (isObject(a) && isString(a.xata_id)) {
|
4108
4180
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4109
|
-
return await __privateMethod$2(this,
|
4181
|
+
return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
|
4110
4182
|
}
|
4111
4183
|
} catch (error) {
|
4112
|
-
if (error.status === 422)
|
4113
|
-
return null;
|
4184
|
+
if (error.status === 422) return null;
|
4114
4185
|
throw error;
|
4115
4186
|
}
|
4116
4187
|
throw new Error("Invalid arguments for update method");
|
@@ -4139,9 +4210,8 @@ class RestRepository extends Query {
|
|
4139
4210
|
return __privateGet$2(this, _trace).call(this, "createOrUpdate", async () => {
|
4140
4211
|
const ifVersion = parseIfVersion(b, c, d);
|
4141
4212
|
if (Array.isArray(a)) {
|
4142
|
-
if (a.length === 0)
|
4143
|
-
|
4144
|
-
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
4213
|
+
if (a.length === 0) return [];
|
4214
|
+
await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, a, {
|
4145
4215
|
ifVersion,
|
4146
4216
|
upsert: true
|
4147
4217
|
});
|
@@ -4150,16 +4220,14 @@ class RestRepository extends Query {
|
|
4150
4220
|
return result;
|
4151
4221
|
}
|
4152
4222
|
if (isString(a) && isObject(b)) {
|
4153
|
-
if (a === "")
|
4154
|
-
throw new Error("The id can't be empty");
|
4223
|
+
if (a === "") throw new Error("The id can't be empty");
|
4155
4224
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4156
|
-
return await __privateMethod$2(this,
|
4225
|
+
return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
4157
4226
|
}
|
4158
4227
|
if (isObject(a) && isString(a.xata_id)) {
|
4159
|
-
if (a.xata_id === "")
|
4160
|
-
throw new Error("The id can't be empty");
|
4228
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4161
4229
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4162
|
-
return await __privateMethod$2(this,
|
4230
|
+
return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
|
4163
4231
|
}
|
4164
4232
|
if (!isDefined(a) && isObject(b)) {
|
4165
4233
|
return await this.create(b, c);
|
@@ -4174,24 +4242,21 @@ class RestRepository extends Query {
|
|
4174
4242
|
return __privateGet$2(this, _trace).call(this, "createOrReplace", async () => {
|
4175
4243
|
const ifVersion = parseIfVersion(b, c, d);
|
4176
4244
|
if (Array.isArray(a)) {
|
4177
|
-
if (a.length === 0)
|
4178
|
-
|
4179
|
-
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
4245
|
+
if (a.length === 0) return [];
|
4246
|
+
const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
4180
4247
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4181
4248
|
const result = await this.read(ids, columns);
|
4182
4249
|
return result;
|
4183
4250
|
}
|
4184
4251
|
if (isString(a) && isObject(b)) {
|
4185
|
-
if (a === "")
|
4186
|
-
throw new Error("The id can't be empty");
|
4252
|
+
if (a === "") throw new Error("The id can't be empty");
|
4187
4253
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4188
|
-
return await __privateMethod$2(this,
|
4254
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
4189
4255
|
}
|
4190
4256
|
if (isObject(a) && isString(a.xata_id)) {
|
4191
|
-
if (a.xata_id === "")
|
4192
|
-
throw new Error("The id can't be empty");
|
4257
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4193
4258
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4194
|
-
return await __privateMethod$2(this,
|
4259
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
|
4195
4260
|
createOnly: false,
|
4196
4261
|
ifVersion
|
4197
4262
|
});
|
@@ -4208,25 +4273,22 @@ class RestRepository extends Query {
|
|
4208
4273
|
async delete(a, b) {
|
4209
4274
|
return __privateGet$2(this, _trace).call(this, "delete", async () => {
|
4210
4275
|
if (Array.isArray(a)) {
|
4211
|
-
if (a.length === 0)
|
4212
|
-
return [];
|
4276
|
+
if (a.length === 0) return [];
|
4213
4277
|
const ids = a.map((o) => {
|
4214
|
-
if (isString(o))
|
4215
|
-
|
4216
|
-
if (isString(o.xata_id))
|
4217
|
-
return o.xata_id;
|
4278
|
+
if (isString(o)) return o;
|
4279
|
+
if (isString(o.xata_id)) return o.xata_id;
|
4218
4280
|
throw new Error("Invalid arguments for delete method");
|
4219
4281
|
});
|
4220
4282
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4221
4283
|
const result = await this.read(a, columns);
|
4222
|
-
await __privateMethod$2(this,
|
4284
|
+
await __privateMethod$2(this, _RestRepository_instances, deleteRecords_fn).call(this, ids);
|
4223
4285
|
return result;
|
4224
4286
|
}
|
4225
4287
|
if (isString(a)) {
|
4226
|
-
return __privateMethod$2(this,
|
4288
|
+
return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a, b);
|
4227
4289
|
}
|
4228
4290
|
if (isObject(a) && isString(a.xata_id)) {
|
4229
|
-
return __privateMethod$2(this,
|
4291
|
+
return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a.xata_id, b);
|
4230
4292
|
}
|
4231
4293
|
throw new Error("Invalid arguments for delete method");
|
4232
4294
|
});
|
@@ -4270,7 +4332,7 @@ class RestRepository extends Query {
|
|
4270
4332
|
},
|
4271
4333
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4272
4334
|
});
|
4273
|
-
const schemaTables = await __privateMethod$2(this,
|
4335
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4274
4336
|
return {
|
4275
4337
|
records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
|
4276
4338
|
totalCount
|
@@ -4295,7 +4357,7 @@ class RestRepository extends Query {
|
|
4295
4357
|
},
|
4296
4358
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4297
4359
|
});
|
4298
|
-
const schemaTables = await __privateMethod$2(this,
|
4360
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4299
4361
|
return {
|
4300
4362
|
records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
|
4301
4363
|
totalCount
|
@@ -4337,7 +4399,7 @@ class RestRepository extends Query {
|
|
4337
4399
|
fetchOptions: data.fetchOptions,
|
4338
4400
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4339
4401
|
});
|
4340
|
-
const schemaTables = await __privateMethod$2(this,
|
4402
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4341
4403
|
const records = objects.map(
|
4342
4404
|
(record) => initObject(
|
4343
4405
|
__privateGet$2(this, _db),
|
@@ -4371,7 +4433,7 @@ class RestRepository extends Query {
|
|
4371
4433
|
},
|
4372
4434
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4373
4435
|
});
|
4374
|
-
const schemaTables = await __privateMethod$2(this,
|
4436
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4375
4437
|
return {
|
4376
4438
|
...result,
|
4377
4439
|
summaries: result.summaries.map(
|
@@ -4419,9 +4481,9 @@ _getFetchProps = new WeakMap();
|
|
4419
4481
|
_db = new WeakMap();
|
4420
4482
|
_schemaTables = new WeakMap();
|
4421
4483
|
_trace = new WeakMap();
|
4422
|
-
|
4484
|
+
_RestRepository_instances = new WeakSet();
|
4423
4485
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
4424
|
-
const record = await __privateMethod$2(this,
|
4486
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4425
4487
|
const response = await insertRecord({
|
4426
4488
|
pathParams: {
|
4427
4489
|
workspace: "{workspaceId}",
|
@@ -4433,14 +4495,12 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
4433
4495
|
body: record,
|
4434
4496
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4435
4497
|
});
|
4436
|
-
const schemaTables = await __privateMethod$2(this,
|
4498
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4437
4499
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4438
4500
|
};
|
4439
|
-
_insertRecordWithId = new WeakSet();
|
4440
4501
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
4441
|
-
if (!recordId)
|
4442
|
-
|
4443
|
-
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
4502
|
+
if (!recordId) return null;
|
4503
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4444
4504
|
const response = await insertRecordWithID({
|
4445
4505
|
pathParams: {
|
4446
4506
|
workspace: "{workspaceId}",
|
@@ -4453,13 +4513,12 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
4453
4513
|
queryParams: { createOnly, columns, ifVersion },
|
4454
4514
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4455
4515
|
});
|
4456
|
-
const schemaTables = await __privateMethod$2(this,
|
4516
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4457
4517
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4458
4518
|
};
|
4459
|
-
_insertRecords = new WeakSet();
|
4460
4519
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
4461
4520
|
const operations = await promiseMap(objects, async (object) => {
|
4462
|
-
const record = await __privateMethod$2(this,
|
4521
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4463
4522
|
return { insert: { table: __privateGet$2(this, _table), record, createOnly, ifVersion } };
|
4464
4523
|
});
|
4465
4524
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
@@ -4484,11 +4543,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
4484
4543
|
}
|
4485
4544
|
return ids;
|
4486
4545
|
};
|
4487
|
-
_updateRecordWithID = new WeakSet();
|
4488
4546
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
4489
|
-
if (!recordId)
|
4490
|
-
|
4491
|
-
const { xata_id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
4547
|
+
if (!recordId) return null;
|
4548
|
+
const { xata_id: _id, ...record } = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4492
4549
|
try {
|
4493
4550
|
const response = await updateRecordWithID({
|
4494
4551
|
pathParams: {
|
@@ -4502,7 +4559,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4502
4559
|
body: record,
|
4503
4560
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4504
4561
|
});
|
4505
|
-
const schemaTables = await __privateMethod$2(this,
|
4562
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4506
4563
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4507
4564
|
} catch (e) {
|
4508
4565
|
if (isObject(e) && e.status === 404) {
|
@@ -4511,10 +4568,9 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4511
4568
|
throw e;
|
4512
4569
|
}
|
4513
4570
|
};
|
4514
|
-
_updateRecords = new WeakSet();
|
4515
4571
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
4516
4572
|
const operations = await promiseMap(objects, async ({ xata_id, ...object }) => {
|
4517
|
-
const fields = await __privateMethod$2(this,
|
4573
|
+
const fields = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4518
4574
|
return { update: { table: __privateGet$2(this, _table), id: xata_id, ifVersion, upsert, fields } };
|
4519
4575
|
});
|
4520
4576
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
@@ -4539,10 +4595,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
4539
4595
|
}
|
4540
4596
|
return ids;
|
4541
4597
|
};
|
4542
|
-
_upsertRecordWithID = new WeakSet();
|
4543
4598
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
4544
|
-
if (!recordId)
|
4545
|
-
return null;
|
4599
|
+
if (!recordId) return null;
|
4546
4600
|
const response = await upsertRecordWithID({
|
4547
4601
|
pathParams: {
|
4548
4602
|
workspace: "{workspaceId}",
|
@@ -4555,13 +4609,11 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4555
4609
|
body: object,
|
4556
4610
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4557
4611
|
});
|
4558
|
-
const schemaTables = await __privateMethod$2(this,
|
4612
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4559
4613
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4560
4614
|
};
|
4561
|
-
_deleteRecord = new WeakSet();
|
4562
4615
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
4563
|
-
if (!recordId)
|
4564
|
-
return null;
|
4616
|
+
if (!recordId) return null;
|
4565
4617
|
try {
|
4566
4618
|
const response = await deleteRecord({
|
4567
4619
|
pathParams: {
|
@@ -4574,7 +4626,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4574
4626
|
queryParams: { columns },
|
4575
4627
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4576
4628
|
});
|
4577
|
-
const schemaTables = await __privateMethod$2(this,
|
4629
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4578
4630
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4579
4631
|
} catch (e) {
|
4580
4632
|
if (isObject(e) && e.status === 404) {
|
@@ -4583,7 +4635,6 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4583
4635
|
throw e;
|
4584
4636
|
}
|
4585
4637
|
};
|
4586
|
-
_deleteRecords = new WeakSet();
|
4587
4638
|
deleteRecords_fn = async function(recordIds) {
|
4588
4639
|
const chunkedOperations = chunk(
|
4589
4640
|
compact(recordIds).map((id) => ({ delete: { table: __privateGet$2(this, _table), id } })),
|
@@ -4601,10 +4652,8 @@ deleteRecords_fn = async function(recordIds) {
|
|
4601
4652
|
});
|
4602
4653
|
}
|
4603
4654
|
};
|
4604
|
-
_getSchemaTables = new WeakSet();
|
4605
4655
|
getSchemaTables_fn = async function() {
|
4606
|
-
if (__privateGet$2(this, _schemaTables))
|
4607
|
-
return __privateGet$2(this, _schemaTables);
|
4656
|
+
if (__privateGet$2(this, _schemaTables)) return __privateGet$2(this, _schemaTables);
|
4608
4657
|
const { schema } = await getBranchDetails({
|
4609
4658
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4610
4659
|
...__privateGet$2(this, _getFetchProps).call(this)
|
@@ -4612,16 +4661,13 @@ getSchemaTables_fn = async function() {
|
|
4612
4661
|
__privateSet$1(this, _schemaTables, schema.tables);
|
4613
4662
|
return schema.tables;
|
4614
4663
|
};
|
4615
|
-
_transformObjectToApi = new WeakSet();
|
4616
4664
|
transformObjectToApi_fn = async function(object) {
|
4617
|
-
const schemaTables = await __privateMethod$2(this,
|
4665
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4618
4666
|
const schema = schemaTables.find((table) => table.name === __privateGet$2(this, _table));
|
4619
|
-
if (!schema)
|
4620
|
-
throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
|
4667
|
+
if (!schema) throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
|
4621
4668
|
const result = {};
|
4622
4669
|
for (const [key, value] of Object.entries(object)) {
|
4623
|
-
if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key))
|
4624
|
-
continue;
|
4670
|
+
if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key)) continue;
|
4625
4671
|
const type = schema.columns.find((column) => column.name === key)?.type;
|
4626
4672
|
switch (type) {
|
4627
4673
|
case "link": {
|
@@ -4651,11 +4697,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4651
4697
|
const data = {};
|
4652
4698
|
Object.assign(data, { ...object });
|
4653
4699
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
4654
|
-
if (!columns)
|
4655
|
-
console.error(`Table ${table} not found in schema`);
|
4700
|
+
if (!columns) console.error(`Table ${table} not found in schema`);
|
4656
4701
|
for (const column of columns ?? []) {
|
4657
|
-
if (!isValidColumn(selectedColumns, column))
|
4658
|
-
continue;
|
4702
|
+
if (!isValidColumn(selectedColumns, column)) continue;
|
4659
4703
|
const value = data[column.name];
|
4660
4704
|
switch (column.type) {
|
4661
4705
|
case "datetime": {
|
@@ -4741,15 +4785,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4741
4785
|
return record;
|
4742
4786
|
};
|
4743
4787
|
function extractId(value) {
|
4744
|
-
if (isString(value))
|
4745
|
-
|
4746
|
-
if (isObject(value) && isString(value.xata_id))
|
4747
|
-
return value.xata_id;
|
4788
|
+
if (isString(value)) return value;
|
4789
|
+
if (isObject(value) && isString(value.xata_id)) return value.xata_id;
|
4748
4790
|
return void 0;
|
4749
4791
|
}
|
4750
4792
|
function isValidColumn(columns, column) {
|
4751
|
-
if (columns.includes("*"))
|
4752
|
-
return true;
|
4793
|
+
if (columns.includes("*")) return true;
|
4753
4794
|
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
4754
4795
|
}
|
4755
4796
|
function parseIfVersion(...args) {
|
@@ -4789,19 +4830,12 @@ const includesAll = (value) => ({ $includesAll: value });
|
|
4789
4830
|
const includesNone = (value) => ({ $includesNone: value });
|
4790
4831
|
const includesAny = (value) => ({ $includesAny: value });
|
4791
4832
|
|
4792
|
-
var
|
4793
|
-
|
4794
|
-
throw TypeError("Cannot " + msg);
|
4795
|
-
};
|
4796
|
-
var __privateGet$1 = (obj, member, getter) => {
|
4797
|
-
__accessCheck$2(obj, member, "read from private field");
|
4798
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4799
|
-
};
|
4800
|
-
var __privateAdd$2 = (obj, member, value) => {
|
4801
|
-
if (member.has(obj))
|
4802
|
-
throw TypeError("Cannot add the same private member more than once");
|
4803
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4833
|
+
var __typeError$2 = (msg) => {
|
4834
|
+
throw TypeError(msg);
|
4804
4835
|
};
|
4836
|
+
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
4837
|
+
var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
4838
|
+
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);
|
4805
4839
|
var _tables;
|
4806
4840
|
class SchemaPlugin extends XataPlugin {
|
4807
4841
|
constructor() {
|
@@ -4813,8 +4847,7 @@ class SchemaPlugin extends XataPlugin {
|
|
4813
4847
|
{},
|
4814
4848
|
{
|
4815
4849
|
get: (_target, table) => {
|
4816
|
-
if (!isString(table))
|
4817
|
-
throw new Error("Invalid table name");
|
4850
|
+
if (!isString(table)) throw new Error("Invalid table name");
|
4818
4851
|
if (__privateGet$1(this, _tables)[table] === void 0) {
|
4819
4852
|
__privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4820
4853
|
}
|
@@ -4905,30 +4938,23 @@ function getContentType(file) {
|
|
4905
4938
|
return "application/octet-stream";
|
4906
4939
|
}
|
4907
4940
|
|
4908
|
-
var
|
4909
|
-
|
4910
|
-
throw TypeError("Cannot " + msg);
|
4911
|
-
};
|
4912
|
-
var __privateAdd$1 = (obj, member, value) => {
|
4913
|
-
if (member.has(obj))
|
4914
|
-
throw TypeError("Cannot add the same private member more than once");
|
4915
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4916
|
-
};
|
4917
|
-
var __privateMethod$1 = (obj, member, method) => {
|
4918
|
-
__accessCheck$1(obj, member, "access private method");
|
4919
|
-
return method;
|
4941
|
+
var __typeError$1 = (msg) => {
|
4942
|
+
throw TypeError(msg);
|
4920
4943
|
};
|
4921
|
-
var
|
4944
|
+
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
4945
|
+
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);
|
4946
|
+
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
4947
|
+
var _SearchPlugin_instances, search_fn;
|
4922
4948
|
class SearchPlugin extends XataPlugin {
|
4923
4949
|
constructor(db) {
|
4924
4950
|
super();
|
4925
4951
|
this.db = db;
|
4926
|
-
__privateAdd$1(this,
|
4952
|
+
__privateAdd$1(this, _SearchPlugin_instances);
|
4927
4953
|
}
|
4928
4954
|
build(pluginOptions) {
|
4929
4955
|
return {
|
4930
4956
|
all: async (query, options = {}) => {
|
4931
|
-
const { records, totalCount } = await __privateMethod$1(this,
|
4957
|
+
const { records, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
|
4932
4958
|
return {
|
4933
4959
|
totalCount,
|
4934
4960
|
records: records.map((record) => {
|
@@ -4938,7 +4964,7 @@ class SearchPlugin extends XataPlugin {
|
|
4938
4964
|
};
|
4939
4965
|
},
|
4940
4966
|
byTable: async (query, options = {}) => {
|
4941
|
-
const { records: rawRecords, totalCount } = await __privateMethod$1(this,
|
4967
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
|
4942
4968
|
const records = rawRecords.reduce((acc, record) => {
|
4943
4969
|
const table = record.xata_table;
|
4944
4970
|
const items = acc[table] ?? [];
|
@@ -4950,7 +4976,7 @@ class SearchPlugin extends XataPlugin {
|
|
4950
4976
|
};
|
4951
4977
|
}
|
4952
4978
|
}
|
4953
|
-
|
4979
|
+
_SearchPlugin_instances = new WeakSet();
|
4954
4980
|
search_fn = async function(query, options, pluginOptions) {
|
4955
4981
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
4956
4982
|
const { records, totalCount } = await searchBranch({
|
@@ -4986,8 +5012,7 @@ function arrayString(val) {
|
|
4986
5012
|
return result;
|
4987
5013
|
}
|
4988
5014
|
function prepareValue(value) {
|
4989
|
-
if (!isDefined(value))
|
4990
|
-
return null;
|
5015
|
+
if (!isDefined(value)) return null;
|
4991
5016
|
if (value instanceof Date) {
|
4992
5017
|
return value.toISOString();
|
4993
5018
|
}
|
@@ -5066,8 +5091,7 @@ function buildDomain(host, region) {
|
|
5066
5091
|
function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
|
5067
5092
|
const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
|
5068
5093
|
const parts = parseWorkspacesUrlParts(url);
|
5069
|
-
if (!parts)
|
5070
|
-
throw new Error("Invalid workspaces URL");
|
5094
|
+
if (!parts) throw new Error("Invalid workspaces URL");
|
5071
5095
|
const { workspace: workspaceSlug, region, database, host } = parts;
|
5072
5096
|
const domain = buildDomain(host, region);
|
5073
5097
|
const workspace = workspaceSlug.split("-").pop();
|
@@ -5092,39 +5116,24 @@ class TransactionPlugin extends XataPlugin {
|
|
5092
5116
|
}
|
5093
5117
|
}
|
5094
5118
|
|
5095
|
-
var
|
5096
|
-
|
5097
|
-
throw TypeError("Cannot " + msg);
|
5098
|
-
};
|
5099
|
-
var __privateGet = (obj, member, getter) => {
|
5100
|
-
__accessCheck(obj, member, "read from private field");
|
5101
|
-
return getter ? getter.call(obj) : member.get(obj);
|
5102
|
-
};
|
5103
|
-
var __privateAdd = (obj, member, value) => {
|
5104
|
-
if (member.has(obj))
|
5105
|
-
throw TypeError("Cannot add the same private member more than once");
|
5106
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
5107
|
-
};
|
5108
|
-
var __privateSet = (obj, member, value, setter) => {
|
5109
|
-
__accessCheck(obj, member, "write to private field");
|
5110
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
5111
|
-
return value;
|
5112
|
-
};
|
5113
|
-
var __privateMethod = (obj, member, method) => {
|
5114
|
-
__accessCheck(obj, member, "access private method");
|
5115
|
-
return method;
|
5119
|
+
var __typeError = (msg) => {
|
5120
|
+
throw TypeError(msg);
|
5116
5121
|
};
|
5122
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
5123
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
5124
|
+
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);
|
5125
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
5126
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
5117
5127
|
const buildClient = (plugins) => {
|
5118
|
-
var _options,
|
5128
|
+
var _options, _instances, parseOptions_fn, getFetchProps_fn, _a;
|
5119
5129
|
return _a = class {
|
5120
5130
|
constructor(options = {}, tables) {
|
5121
|
-
__privateAdd(this,
|
5122
|
-
__privateAdd(this,
|
5123
|
-
|
5124
|
-
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
5131
|
+
__privateAdd(this, _instances);
|
5132
|
+
__privateAdd(this, _options);
|
5133
|
+
const safeOptions = __privateMethod(this, _instances, parseOptions_fn).call(this, options);
|
5125
5134
|
__privateSet(this, _options, safeOptions);
|
5126
5135
|
const pluginOptions = {
|
5127
|
-
...__privateMethod(this,
|
5136
|
+
...__privateMethod(this, _instances, getFetchProps_fn).call(this, safeOptions),
|
5128
5137
|
host: safeOptions.host,
|
5129
5138
|
tables,
|
5130
5139
|
branch: safeOptions.branch
|
@@ -5141,8 +5150,7 @@ const buildClient = (plugins) => {
|
|
5141
5150
|
this.sql = sql;
|
5142
5151
|
this.files = files;
|
5143
5152
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
5144
|
-
if (namespace === void 0)
|
5145
|
-
continue;
|
5153
|
+
if (namespace === void 0) continue;
|
5146
5154
|
this[key] = namespace.build(pluginOptions);
|
5147
5155
|
}
|
5148
5156
|
}
|
@@ -5151,8 +5159,8 @@ const buildClient = (plugins) => {
|
|
5151
5159
|
const branch = __privateGet(this, _options).branch;
|
5152
5160
|
return { databaseURL, branch };
|
5153
5161
|
}
|
5154
|
-
}, _options = new WeakMap(),
|
5155
|
-
const enableBrowser = options?.enableBrowser ??
|
5162
|
+
}, _options = new WeakMap(), _instances = new WeakSet(), parseOptions_fn = function(options) {
|
5163
|
+
const enableBrowser = options?.enableBrowser ?? false;
|
5156
5164
|
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
5157
5165
|
if (isBrowser && !enableBrowser) {
|
5158
5166
|
throw new Error(
|
@@ -5160,8 +5168,9 @@ const buildClient = (plugins) => {
|
|
5160
5168
|
);
|
5161
5169
|
}
|
5162
5170
|
const fetch = getFetchImplementation(options?.fetch);
|
5163
|
-
const databaseURL = options?.databaseURL
|
5164
|
-
const apiKey = options?.apiKey
|
5171
|
+
const databaseURL = options?.databaseURL;
|
5172
|
+
const apiKey = options?.apiKey;
|
5173
|
+
const branch = options?.branch;
|
5165
5174
|
const trace = options?.trace ?? defaultTrace;
|
5166
5175
|
const clientName = options?.clientName;
|
5167
5176
|
const host = options?.host ?? "production";
|
@@ -5172,25 +5181,8 @@ const buildClient = (plugins) => {
|
|
5172
5181
|
if (!databaseURL) {
|
5173
5182
|
throw new Error("Option databaseURL is required");
|
5174
5183
|
}
|
5175
|
-
|
5176
|
-
|
5177
|
-
const branch = options?.branch || previewBranch || envBranch || "main";
|
5178
|
-
if (!!previewBranch && branch !== previewBranch) {
|
5179
|
-
console.warn(
|
5180
|
-
`Ignoring preview branch ${previewBranch} because branch option was passed to the client constructor with value ${branch}`
|
5181
|
-
);
|
5182
|
-
} else if (!!envBranch && branch !== envBranch) {
|
5183
|
-
console.warn(
|
5184
|
-
`Ignoring branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
5185
|
-
);
|
5186
|
-
} else if (!!previewBranch && !!envBranch && previewBranch !== envBranch) {
|
5187
|
-
console.warn(
|
5188
|
-
`Ignoring preview branch ${previewBranch} and branch ${envBranch} because branch option was passed to the client constructor with value ${branch}`
|
5189
|
-
);
|
5190
|
-
} else if (!previewBranch && !envBranch && options?.branch === void 0) {
|
5191
|
-
console.warn(
|
5192
|
-
`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.`
|
5193
|
-
);
|
5184
|
+
if (!branch) {
|
5185
|
+
throw new Error("Option branch is required");
|
5194
5186
|
}
|
5195
5187
|
return {
|
5196
5188
|
fetch,
|
@@ -5204,7 +5196,7 @@ const buildClient = (plugins) => {
|
|
5204
5196
|
clientName,
|
5205
5197
|
xataAgentExtra
|
5206
5198
|
};
|
5207
|
-
},
|
5199
|
+
}, getFetchProps_fn = function({
|
5208
5200
|
fetch,
|
5209
5201
|
apiKey,
|
5210
5202
|
databaseURL,
|
@@ -5245,26 +5237,19 @@ class Serializer {
|
|
5245
5237
|
}
|
5246
5238
|
toJSON(data) {
|
5247
5239
|
function visit(obj) {
|
5248
|
-
if (Array.isArray(obj))
|
5249
|
-
return obj.map(visit);
|
5240
|
+
if (Array.isArray(obj)) return obj.map(visit);
|
5250
5241
|
const type = typeof obj;
|
5251
|
-
if (type === "undefined")
|
5252
|
-
|
5253
|
-
if (
|
5254
|
-
return { [META]: "bigint", [VALUE]: obj.toString() };
|
5255
|
-
if (obj === null || type !== "object")
|
5256
|
-
return obj;
|
5242
|
+
if (type === "undefined") return { [META]: "undefined" };
|
5243
|
+
if (type === "bigint") return { [META]: "bigint", [VALUE]: obj.toString() };
|
5244
|
+
if (obj === null || type !== "object") return obj;
|
5257
5245
|
const constructor = obj.constructor;
|
5258
5246
|
const o = { [META]: constructor.name };
|
5259
5247
|
for (const [key, value] of Object.entries(obj)) {
|
5260
5248
|
o[key] = visit(value);
|
5261
5249
|
}
|
5262
|
-
if (constructor === Date)
|
5263
|
-
|
5264
|
-
if (constructor ===
|
5265
|
-
o[VALUE] = Object.fromEntries(obj);
|
5266
|
-
if (constructor === Set)
|
5267
|
-
o[VALUE] = [...obj];
|
5250
|
+
if (constructor === Date) o[VALUE] = obj.toISOString();
|
5251
|
+
if (constructor === Map) o[VALUE] = Object.fromEntries(obj);
|
5252
|
+
if (constructor === Set) o[VALUE] = [...obj];
|
5268
5253
|
return o;
|
5269
5254
|
}
|
5270
5255
|
return JSON.stringify(visit(data));
|
@@ -5277,16 +5262,11 @@ class Serializer {
|
|
5277
5262
|
if (constructor) {
|
5278
5263
|
return Object.assign(Object.create(constructor.prototype), rest);
|
5279
5264
|
}
|
5280
|
-
if (clazz === "Date")
|
5281
|
-
|
5282
|
-
if (clazz === "
|
5283
|
-
|
5284
|
-
if (clazz === "
|
5285
|
-
return new Map(Object.entries(val));
|
5286
|
-
if (clazz === "bigint")
|
5287
|
-
return BigInt(val);
|
5288
|
-
if (clazz === "undefined")
|
5289
|
-
return void 0;
|
5265
|
+
if (clazz === "Date") return new Date(val);
|
5266
|
+
if (clazz === "Set") return new Set(val);
|
5267
|
+
if (clazz === "Map") return new Map(Object.entries(val));
|
5268
|
+
if (clazz === "bigint") return BigInt(val);
|
5269
|
+
if (clazz === "undefined") return void 0;
|
5290
5270
|
return rest;
|
5291
5271
|
}
|
5292
5272
|
return value;
|
@@ -5301,6 +5281,47 @@ const deserialize = (json) => {
|
|
5301
5281
|
return defaultSerializer.fromJSON(json);
|
5302
5282
|
};
|
5303
5283
|
|
5284
|
+
function parseEnvironment(environment) {
|
5285
|
+
try {
|
5286
|
+
if (typeof environment === "function") {
|
5287
|
+
return new Proxy(
|
5288
|
+
{},
|
5289
|
+
{
|
5290
|
+
get(target) {
|
5291
|
+
return environment(target);
|
5292
|
+
}
|
5293
|
+
}
|
5294
|
+
);
|
5295
|
+
}
|
5296
|
+
if (isObject(environment)) {
|
5297
|
+
return environment;
|
5298
|
+
}
|
5299
|
+
} catch (error) {
|
5300
|
+
}
|
5301
|
+
return {};
|
5302
|
+
}
|
5303
|
+
function buildPreviewBranchName({ org, branch }) {
|
5304
|
+
return `preview-${org}-${branch}`;
|
5305
|
+
}
|
5306
|
+
function getDeployPreviewBranch(environment) {
|
5307
|
+
try {
|
5308
|
+
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = parseEnvironment(environment);
|
5309
|
+
if (deployPreviewBranch) return deployPreviewBranch;
|
5310
|
+
switch (deployPreview) {
|
5311
|
+
case "vercel": {
|
5312
|
+
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
5313
|
+
console.warn("XATA_PREVIEW=vercel but VERCEL_GIT_COMMIT_REF or VERCEL_GIT_REPO_OWNER is not valid");
|
5314
|
+
return void 0;
|
5315
|
+
}
|
5316
|
+
return buildPreviewBranchName({ org: vercelGitRepoOwner, branch: vercelGitCommitRef });
|
5317
|
+
}
|
5318
|
+
}
|
5319
|
+
return void 0;
|
5320
|
+
} catch (err) {
|
5321
|
+
return void 0;
|
5322
|
+
}
|
5323
|
+
}
|
5324
|
+
|
5304
5325
|
class XataError extends Error {
|
5305
5326
|
constructor(message, status) {
|
5306
5327
|
super(message);
|
@@ -5363,6 +5384,7 @@ exports.createTable = createTable;
|
|
5363
5384
|
exports.createUserAPIKey = createUserAPIKey;
|
5364
5385
|
exports.createWorkspace = createWorkspace;
|
5365
5386
|
exports.deleteBranch = deleteBranch;
|
5387
|
+
exports.deleteCluster = deleteCluster;
|
5366
5388
|
exports.deleteColumn = deleteColumn;
|
5367
5389
|
exports.deleteDatabase = deleteDatabase;
|
5368
5390
|
exports.deleteDatabaseGithubSettings = deleteDatabaseGithubSettings;
|
@@ -5383,9 +5405,7 @@ exports.exists = exists;
|
|
5383
5405
|
exports.fileAccess = fileAccess;
|
5384
5406
|
exports.fileUpload = fileUpload;
|
5385
5407
|
exports.ge = ge;
|
5386
|
-
exports.getAPIKey = getAPIKey;
|
5387
5408
|
exports.getAuthorizationCode = getAuthorizationCode;
|
5388
|
-
exports.getBranch = getBranch;
|
5389
5409
|
exports.getBranchDetails = getBranchDetails;
|
5390
5410
|
exports.getBranchList = getBranchList;
|
5391
5411
|
exports.getBranchMetadata = getBranchMetadata;
|
@@ -5400,7 +5420,7 @@ exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
|
5400
5420
|
exports.getDatabaseList = getDatabaseList;
|
5401
5421
|
exports.getDatabaseMetadata = getDatabaseMetadata;
|
5402
5422
|
exports.getDatabaseSettings = getDatabaseSettings;
|
5403
|
-
exports.
|
5423
|
+
exports.getDeployPreviewBranch = getDeployPreviewBranch;
|
5404
5424
|
exports.getFile = getFile;
|
5405
5425
|
exports.getFileItem = getFileItem;
|
5406
5426
|
exports.getGitBranchesMapping = getGitBranchesMapping;
|
@@ -5409,7 +5429,6 @@ exports.getMigrationHistory = getMigrationHistory;
|
|
5409
5429
|
exports.getMigrationJobStatus = getMigrationJobStatus;
|
5410
5430
|
exports.getMigrationRequest = getMigrationRequest;
|
5411
5431
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
5412
|
-
exports.getPreviewBranch = getPreviewBranch;
|
5413
5432
|
exports.getRecord = getRecord;
|
5414
5433
|
exports.getSchema = getSchema;
|
5415
5434
|
exports.getTableColumns = getTableColumns;
|
@@ -5476,6 +5495,7 @@ exports.searchTable = searchTable;
|
|
5476
5495
|
exports.serialize = serialize;
|
5477
5496
|
exports.setTableSchema = setTableSchema;
|
5478
5497
|
exports.sqlQuery = sqlQuery;
|
5498
|
+
exports.startMigration = startMigration;
|
5479
5499
|
exports.startsWith = startsWith;
|
5480
5500
|
exports.summarizeTable = summarizeTable;
|
5481
5501
|
exports.transformImage = transformImage;
|