@xata.io/client 0.0.0-next.v3c98c9e18d38b282eb80381e4bd7bf95da9aabdb → 0.0.0-next.v403cdd55cb26b69c074dbc07b44daa0c2a0a77b6
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-add-version.log +1 -1
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +13 -3
- package/dist/index.cjs +334 -394
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1215 -186
- package/dist/index.mjs +319 -395
- 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,29 +1901,15 @@ function promiseMap(inputValues, mapper) {
|
|
1926
1901
|
return inputValues.reduce(reducer, Promise.resolve([]));
|
1927
1902
|
}
|
1928
1903
|
|
1929
|
-
var
|
1930
|
-
|
1931
|
-
throw TypeError("Cannot " + msg);
|
1932
|
-
};
|
1933
|
-
var __privateGet$5 = (obj, member, getter) => {
|
1934
|
-
__accessCheck$6(obj, member, "read from private field");
|
1935
|
-
return getter ? getter.call(obj) : member.get(obj);
|
1936
|
-
};
|
1937
|
-
var __privateAdd$6 = (obj, member, value) => {
|
1938
|
-
if (member.has(obj))
|
1939
|
-
throw TypeError("Cannot add the same private member more than once");
|
1940
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1904
|
+
var __typeError$6 = (msg) => {
|
1905
|
+
throw TypeError(msg);
|
1941
1906
|
};
|
1942
|
-
var
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
var
|
1948
|
-
__accessCheck$6(obj, member, "access private method");
|
1949
|
-
return method;
|
1950
|
-
};
|
1951
|
-
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
1907
|
+
var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
|
1908
|
+
var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
1909
|
+
var __privateAdd$6 = (obj, member, value) => member.has(obj) ? __typeError$6("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1910
|
+
var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
|
1911
|
+
var __privateMethod$4 = (obj, member, method) => (__accessCheck$6(obj, member, "access private method"), method);
|
1912
|
+
var _fetch, _queue, _concurrency, _ApiRequestPool_instances, enqueue_fn;
|
1952
1913
|
const REQUEST_TIMEOUT = 5 * 60 * 1e3;
|
1953
1914
|
function getFetchImplementation(userFetch) {
|
1954
1915
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
@@ -1961,10 +1922,10 @@ function getFetchImplementation(userFetch) {
|
|
1961
1922
|
}
|
1962
1923
|
class ApiRequestPool {
|
1963
1924
|
constructor(concurrency = 10) {
|
1964
|
-
__privateAdd$6(this,
|
1965
|
-
__privateAdd$6(this, _fetch
|
1966
|
-
__privateAdd$6(this, _queue
|
1967
|
-
__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);
|
1968
1929
|
__privateSet$4(this, _queue, []);
|
1969
1930
|
__privateSet$4(this, _concurrency, concurrency);
|
1970
1931
|
this.running = 0;
|
@@ -1999,7 +1960,7 @@ class ApiRequestPool {
|
|
1999
1960
|
}
|
2000
1961
|
return response;
|
2001
1962
|
};
|
2002
|
-
return __privateMethod$4(this,
|
1963
|
+
return __privateMethod$4(this, _ApiRequestPool_instances, enqueue_fn).call(this, async () => {
|
2003
1964
|
return await runRequest();
|
2004
1965
|
});
|
2005
1966
|
}
|
@@ -2007,7 +1968,7 @@ class ApiRequestPool {
|
|
2007
1968
|
_fetch = new WeakMap();
|
2008
1969
|
_queue = new WeakMap();
|
2009
1970
|
_concurrency = new WeakMap();
|
2010
|
-
|
1971
|
+
_ApiRequestPool_instances = new WeakSet();
|
2011
1972
|
enqueue_fn = function(task) {
|
2012
1973
|
const promise = new Promise((resolve) => __privateGet$5(this, _queue).push(resolve)).finally(() => {
|
2013
1974
|
this.started--;
|
@@ -2210,7 +2171,7 @@ function defaultOnOpen(response) {
|
|
2210
2171
|
}
|
2211
2172
|
}
|
2212
2173
|
|
2213
|
-
const VERSION = "0.
|
2174
|
+
const VERSION = "0.30.0";
|
2214
2175
|
|
2215
2176
|
class ErrorWithCause extends Error {
|
2216
2177
|
constructor(message, options) {
|
@@ -2290,18 +2251,15 @@ function parseProviderString(provider = "production") {
|
|
2290
2251
|
return provider;
|
2291
2252
|
}
|
2292
2253
|
const [main, workspaces] = provider.split(",");
|
2293
|
-
if (!main || !workspaces)
|
2294
|
-
return null;
|
2254
|
+
if (!main || !workspaces) return null;
|
2295
2255
|
return { main, workspaces };
|
2296
2256
|
}
|
2297
2257
|
function buildProviderString(provider) {
|
2298
|
-
if (isHostProviderAlias(provider))
|
2299
|
-
return provider;
|
2258
|
+
if (isHostProviderAlias(provider)) return provider;
|
2300
2259
|
return `${provider.main},${provider.workspaces}`;
|
2301
2260
|
}
|
2302
2261
|
function parseWorkspacesUrlParts(url) {
|
2303
|
-
if (!isString(url))
|
2304
|
-
return null;
|
2262
|
+
if (!isString(url)) return null;
|
2305
2263
|
const matches = {
|
2306
2264
|
production: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.xata\.sh\/db\/([^:]+):?(.*)?/),
|
2307
2265
|
staging: url.match(/(?:https:\/\/)?([^.]+)(?:\.([^.]+))\.staging-xata\.dev\/db\/([^:]+):?(.*)?/),
|
@@ -2309,16 +2267,14 @@ function parseWorkspacesUrlParts(url) {
|
|
2309
2267
|
local: url.match(/(?:https?:\/\/)?([^.]+)(?:\.([^.]+))\.localhost:(?:\d+)\/db\/([^:]+):?(.*)?/)
|
2310
2268
|
};
|
2311
2269
|
const [host, match] = Object.entries(matches).find(([, match2]) => match2 !== null) ?? [];
|
2312
|
-
if (!isHostProviderAlias(host) || !match)
|
2313
|
-
return null;
|
2270
|
+
if (!isHostProviderAlias(host) || !match) return null;
|
2314
2271
|
return { workspace: match[1], region: match[2], database: match[3], branch: match[4], host };
|
2315
2272
|
}
|
2316
2273
|
|
2317
2274
|
const pool = new ApiRequestPool();
|
2318
2275
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
2319
2276
|
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
2320
|
-
if (value === void 0 || value === null)
|
2321
|
-
return acc;
|
2277
|
+
if (value === void 0 || value === null) return acc;
|
2322
2278
|
return { ...acc, [key]: value };
|
2323
2279
|
}, {});
|
2324
2280
|
const query = new URLSearchParams(cleanQueryParams).toString();
|
@@ -2366,8 +2322,7 @@ function hostHeader(url) {
|
|
2366
2322
|
return groups?.host ? { Host: groups.host } : {};
|
2367
2323
|
}
|
2368
2324
|
async function parseBody(body, headers) {
|
2369
|
-
if (!isDefined(body))
|
2370
|
-
return void 0;
|
2325
|
+
if (!isDefined(body)) return void 0;
|
2371
2326
|
if (isBlob(body) || typeof body.text === "function") {
|
2372
2327
|
return body;
|
2373
2328
|
}
|
@@ -2446,8 +2401,7 @@ async function fetch$1({
|
|
2446
2401
|
[TraceAttributes.CLOUDFLARE_RAY_ID]: response.headers?.get("cf-ray") ?? void 0
|
2447
2402
|
});
|
2448
2403
|
const message = response.headers?.get("x-xata-message");
|
2449
|
-
if (message)
|
2450
|
-
console.warn(message);
|
2404
|
+
if (message) console.warn(message);
|
2451
2405
|
if (response.status === 204) {
|
2452
2406
|
return {};
|
2453
2407
|
}
|
@@ -2531,12 +2485,72 @@ function parseUrl(url) {
|
|
2531
2485
|
|
2532
2486
|
const dataPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "dataPlane" });
|
2533
2487
|
|
2488
|
+
const getTasks = (variables, signal) => dataPlaneFetch({
|
2489
|
+
url: "/tasks",
|
2490
|
+
method: "get",
|
2491
|
+
...variables,
|
2492
|
+
signal
|
2493
|
+
});
|
2494
|
+
const getTaskStatus = (variables, signal) => dataPlaneFetch({
|
2495
|
+
url: "/tasks/{taskId}",
|
2496
|
+
method: "get",
|
2497
|
+
...variables,
|
2498
|
+
signal
|
2499
|
+
});
|
2500
|
+
const listClusterBranches = (variables, signal) => dataPlaneFetch({
|
2501
|
+
url: "/cluster/{clusterId}/branches",
|
2502
|
+
method: "get",
|
2503
|
+
...variables,
|
2504
|
+
signal
|
2505
|
+
});
|
2506
|
+
const listClusterExtensions = (variables, signal) => dataPlaneFetch({
|
2507
|
+
url: "/cluster/{clusterId}/extensions",
|
2508
|
+
method: "get",
|
2509
|
+
...variables,
|
2510
|
+
signal
|
2511
|
+
});
|
2512
|
+
const installClusterExtension = (variables, signal) => dataPlaneFetch({
|
2513
|
+
url: "/cluster/{clusterId}/extensions",
|
2514
|
+
method: "post",
|
2515
|
+
...variables,
|
2516
|
+
signal
|
2517
|
+
});
|
2518
|
+
const dropClusterExtension = (variables, signal) => dataPlaneFetch({
|
2519
|
+
url: "/cluster/{clusterId}/extensions",
|
2520
|
+
method: "delete",
|
2521
|
+
...variables,
|
2522
|
+
signal
|
2523
|
+
});
|
2524
|
+
const getClusterMetrics = (variables, signal) => dataPlaneFetch({
|
2525
|
+
url: "/cluster/{clusterId}/metrics",
|
2526
|
+
method: "get",
|
2527
|
+
...variables,
|
2528
|
+
signal
|
2529
|
+
});
|
2534
2530
|
const applyMigration = (variables, signal) => dataPlaneFetch({
|
2535
2531
|
url: "/db/{dbBranchName}/migrations/apply",
|
2536
2532
|
method: "post",
|
2537
2533
|
...variables,
|
2538
2534
|
signal
|
2539
2535
|
});
|
2536
|
+
const startMigration = (variables, signal) => dataPlaneFetch({
|
2537
|
+
url: "/db/{dbBranchName}/migrations/start",
|
2538
|
+
method: "post",
|
2539
|
+
...variables,
|
2540
|
+
signal
|
2541
|
+
});
|
2542
|
+
const completeMigration = (variables, signal) => dataPlaneFetch({
|
2543
|
+
url: "/db/{dbBranchName}/migrations/complete",
|
2544
|
+
method: "post",
|
2545
|
+
...variables,
|
2546
|
+
signal
|
2547
|
+
});
|
2548
|
+
const rollbackMigration = (variables, signal) => dataPlaneFetch({
|
2549
|
+
url: "/db/{dbBranchName}/migrations/rollback",
|
2550
|
+
method: "post",
|
2551
|
+
...variables,
|
2552
|
+
signal
|
2553
|
+
});
|
2540
2554
|
const adaptTable = (variables, signal) => dataPlaneFetch({
|
2541
2555
|
url: "/db/{dbBranchName}/migrations/adapt/{tableName}",
|
2542
2556
|
method: "post",
|
@@ -2555,6 +2569,12 @@ const getBranchMigrationJobStatus = (variables, signal) => dataPlaneFetch({
|
|
2555
2569
|
...variables,
|
2556
2570
|
signal
|
2557
2571
|
});
|
2572
|
+
const getMigrationJobs = (variables, signal) => dataPlaneFetch({
|
2573
|
+
url: "/db/{dbBranchName}/migrations/jobs",
|
2574
|
+
method: "get",
|
2575
|
+
...variables,
|
2576
|
+
signal
|
2577
|
+
});
|
2558
2578
|
const getMigrationJobStatus = (variables, signal) => dataPlaneFetch({
|
2559
2579
|
url: "/db/{dbBranchName}/migrations/jobs/{jobId}",
|
2560
2580
|
method: "get",
|
@@ -2580,6 +2600,7 @@ const getDatabaseSettings = (variables, signal) => dataPlaneFetch({
|
|
2580
2600
|
signal
|
2581
2601
|
});
|
2582
2602
|
const updateDatabaseSettings = (variables, signal) => dataPlaneFetch({ url: "/dbs/{dbName}/settings", method: "patch", ...variables, signal });
|
2603
|
+
const createBranchAsync = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/async", method: "put", ...variables, signal });
|
2583
2604
|
const getBranchDetails = (variables, signal) => dataPlaneFetch({
|
2584
2605
|
url: "/db/{dbBranchName}",
|
2585
2606
|
method: "get",
|
@@ -2599,12 +2620,25 @@ const getSchema = (variables, signal) => dataPlaneFetch({
|
|
2599
2620
|
...variables,
|
2600
2621
|
signal
|
2601
2622
|
});
|
2623
|
+
const getSchemas = (variables, signal) => dataPlaneFetch({
|
2624
|
+
url: "/db/{dbBranchName}/schemas",
|
2625
|
+
method: "get",
|
2626
|
+
...variables,
|
2627
|
+
signal
|
2628
|
+
});
|
2602
2629
|
const copyBranch = (variables, signal) => dataPlaneFetch({
|
2603
2630
|
url: "/db/{dbBranchName}/copy",
|
2604
2631
|
method: "post",
|
2605
2632
|
...variables,
|
2606
2633
|
signal
|
2607
2634
|
});
|
2635
|
+
const getBranchMoveStatus = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/move", method: "get", ...variables, signal });
|
2636
|
+
const moveBranch = (variables, signal) => dataPlaneFetch({
|
2637
|
+
url: "/db/{dbBranchName}/move",
|
2638
|
+
method: "put",
|
2639
|
+
...variables,
|
2640
|
+
signal
|
2641
|
+
});
|
2608
2642
|
const updateBranchMetadata = (variables, signal) => dataPlaneFetch({
|
2609
2643
|
url: "/db/{dbBranchName}/metadata",
|
2610
2644
|
method: "put",
|
@@ -2952,15 +2986,34 @@ const sqlQuery = (variables, signal) => dataPlaneFetch({
|
|
2952
2986
|
...variables,
|
2953
2987
|
signal
|
2954
2988
|
});
|
2989
|
+
const sqlBatchQuery = (variables, signal) => dataPlaneFetch({
|
2990
|
+
url: "/db/{dbBranchName}/sql/batch",
|
2991
|
+
method: "post",
|
2992
|
+
...variables,
|
2993
|
+
signal
|
2994
|
+
});
|
2955
2995
|
const operationsByTag$2 = {
|
2996
|
+
tasks: { getTasks, getTaskStatus },
|
2997
|
+
cluster: {
|
2998
|
+
listClusterBranches,
|
2999
|
+
listClusterExtensions,
|
3000
|
+
installClusterExtension,
|
3001
|
+
dropClusterExtension,
|
3002
|
+
getClusterMetrics
|
3003
|
+
},
|
2956
3004
|
migrations: {
|
2957
3005
|
applyMigration,
|
3006
|
+
startMigration,
|
3007
|
+
completeMigration,
|
3008
|
+
rollbackMigration,
|
2958
3009
|
adaptTable,
|
2959
3010
|
adaptAllTables,
|
2960
3011
|
getBranchMigrationJobStatus,
|
3012
|
+
getMigrationJobs,
|
2961
3013
|
getMigrationJobStatus,
|
2962
3014
|
getMigrationHistory,
|
2963
3015
|
getSchema,
|
3016
|
+
getSchemas,
|
2964
3017
|
getBranchMigrationHistory,
|
2965
3018
|
getBranchMigrationPlan,
|
2966
3019
|
executeBranchMigrationPlan,
|
@@ -2974,10 +3027,13 @@ const operationsByTag$2 = {
|
|
2974
3027
|
},
|
2975
3028
|
branch: {
|
2976
3029
|
getBranchList,
|
3030
|
+
createBranchAsync,
|
2977
3031
|
getBranchDetails,
|
2978
3032
|
createBranch,
|
2979
3033
|
deleteBranch,
|
2980
3034
|
copyBranch,
|
3035
|
+
getBranchMoveStatus,
|
3036
|
+
moveBranch,
|
2981
3037
|
updateBranchMetadata,
|
2982
3038
|
getBranchMetadata,
|
2983
3039
|
getBranchStats,
|
@@ -3039,7 +3095,7 @@ const operationsByTag$2 = {
|
|
3039
3095
|
summarizeTable,
|
3040
3096
|
aggregateTable
|
3041
3097
|
},
|
3042
|
-
sql: { sqlQuery }
|
3098
|
+
sql: { sqlQuery, sqlBatchQuery }
|
3043
3099
|
};
|
3044
3100
|
|
3045
3101
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
@@ -3416,8 +3472,7 @@ function buildTransformString(transformations) {
|
|
3416
3472
|
).join(",");
|
3417
3473
|
}
|
3418
3474
|
function transformImage(url, ...transformations) {
|
3419
|
-
if (!isDefined(url))
|
3420
|
-
return void 0;
|
3475
|
+
if (!isDefined(url)) return void 0;
|
3421
3476
|
const newTransformations = buildTransformString(transformations);
|
3422
3477
|
const { hostname, pathname, search } = new URL(url);
|
3423
3478
|
const pathParts = pathname.split("/");
|
@@ -3530,8 +3585,7 @@ class XataFile {
|
|
3530
3585
|
}
|
3531
3586
|
}
|
3532
3587
|
const parseInputFileEntry = async (entry) => {
|
3533
|
-
if (!isDefined(entry))
|
3534
|
-
return null;
|
3588
|
+
if (!isDefined(entry)) return null;
|
3535
3589
|
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout, uploadUrlTimeout } = await entry;
|
3536
3590
|
return compactObject({
|
3537
3591
|
id,
|
@@ -3546,24 +3600,19 @@ const parseInputFileEntry = async (entry) => {
|
|
3546
3600
|
};
|
3547
3601
|
|
3548
3602
|
function cleanFilter(filter) {
|
3549
|
-
if (!isDefined(filter))
|
3550
|
-
|
3551
|
-
if (!isObject(filter))
|
3552
|
-
return filter;
|
3603
|
+
if (!isDefined(filter)) return void 0;
|
3604
|
+
if (!isObject(filter)) return filter;
|
3553
3605
|
const values = Object.fromEntries(
|
3554
3606
|
Object.entries(filter).reduce((acc, [key, value]) => {
|
3555
|
-
if (!isDefined(value))
|
3556
|
-
return acc;
|
3607
|
+
if (!isDefined(value)) return acc;
|
3557
3608
|
if (Array.isArray(value)) {
|
3558
3609
|
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
3559
|
-
if (clean.length === 0)
|
3560
|
-
return acc;
|
3610
|
+
if (clean.length === 0) return acc;
|
3561
3611
|
return [...acc, [key, clean]];
|
3562
3612
|
}
|
3563
3613
|
if (isObject(value)) {
|
3564
3614
|
const clean = cleanFilter(value);
|
3565
|
-
if (!isDefined(clean))
|
3566
|
-
return acc;
|
3615
|
+
if (!isDefined(clean)) return acc;
|
3567
3616
|
return [...acc, [key, clean]];
|
3568
3617
|
}
|
3569
3618
|
return [...acc, [key, value]];
|
@@ -3573,10 +3622,8 @@ function cleanFilter(filter) {
|
|
3573
3622
|
}
|
3574
3623
|
|
3575
3624
|
function stringifyJson(value) {
|
3576
|
-
if (!isDefined(value))
|
3577
|
-
|
3578
|
-
if (isString(value))
|
3579
|
-
return value;
|
3625
|
+
if (!isDefined(value)) return value;
|
3626
|
+
if (isString(value)) return value;
|
3580
3627
|
try {
|
3581
3628
|
return JSON.stringify(value);
|
3582
3629
|
} catch (e) {
|
@@ -3591,28 +3638,17 @@ function parseJson(value) {
|
|
3591
3638
|
}
|
3592
3639
|
}
|
3593
3640
|
|
3594
|
-
var
|
3595
|
-
|
3596
|
-
throw TypeError("Cannot " + msg);
|
3597
|
-
};
|
3598
|
-
var __privateGet$4 = (obj, member, getter) => {
|
3599
|
-
__accessCheck$5(obj, member, "read from private field");
|
3600
|
-
return getter ? getter.call(obj) : member.get(obj);
|
3601
|
-
};
|
3602
|
-
var __privateAdd$5 = (obj, member, value) => {
|
3603
|
-
if (member.has(obj))
|
3604
|
-
throw TypeError("Cannot add the same private member more than once");
|
3605
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3606
|
-
};
|
3607
|
-
var __privateSet$3 = (obj, member, value, setter) => {
|
3608
|
-
__accessCheck$5(obj, member, "write to private field");
|
3609
|
-
member.set(obj, value);
|
3610
|
-
return value;
|
3641
|
+
var __typeError$5 = (msg) => {
|
3642
|
+
throw TypeError(msg);
|
3611
3643
|
};
|
3644
|
+
var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
|
3645
|
+
var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
3646
|
+
var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3647
|
+
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
|
3612
3648
|
var _query, _page;
|
3613
3649
|
class Page {
|
3614
3650
|
constructor(query, meta, records = []) {
|
3615
|
-
__privateAdd$5(this, _query
|
3651
|
+
__privateAdd$5(this, _query);
|
3616
3652
|
__privateSet$3(this, _query, query);
|
3617
3653
|
this.meta = meta;
|
3618
3654
|
this.records = new PageRecordArray(this, records);
|
@@ -3699,7 +3735,7 @@ class RecordArray extends Array {
|
|
3699
3735
|
const _PageRecordArray = class _PageRecordArray extends Array {
|
3700
3736
|
constructor(...args) {
|
3701
3737
|
super(..._PageRecordArray.parseConstructorParams(...args));
|
3702
|
-
__privateAdd$5(this, _page
|
3738
|
+
__privateAdd$5(this, _page);
|
3703
3739
|
__privateSet$3(this, _page, isObject(args[0]?.meta) ? args[0] : { meta: { page: { cursor: "", more: false } }, records: [] });
|
3704
3740
|
}
|
3705
3741
|
static parseConstructorParams(...args) {
|
@@ -3770,34 +3806,20 @@ const _PageRecordArray = class _PageRecordArray extends Array {
|
|
3770
3806
|
_page = new WeakMap();
|
3771
3807
|
let PageRecordArray = _PageRecordArray;
|
3772
3808
|
|
3773
|
-
var
|
3774
|
-
|
3775
|
-
throw TypeError("Cannot " + msg);
|
3776
|
-
};
|
3777
|
-
var __privateGet$3 = (obj, member, getter) => {
|
3778
|
-
__accessCheck$4(obj, member, "read from private field");
|
3779
|
-
return getter ? getter.call(obj) : member.get(obj);
|
3780
|
-
};
|
3781
|
-
var __privateAdd$4 = (obj, member, value) => {
|
3782
|
-
if (member.has(obj))
|
3783
|
-
throw TypeError("Cannot add the same private member more than once");
|
3784
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3809
|
+
var __typeError$4 = (msg) => {
|
3810
|
+
throw TypeError(msg);
|
3785
3811
|
};
|
3786
|
-
var
|
3787
|
-
|
3788
|
-
|
3789
|
-
|
3790
|
-
|
3791
|
-
var
|
3792
|
-
__accessCheck$4(obj, member, "access private method");
|
3793
|
-
return method;
|
3794
|
-
};
|
3795
|
-
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
3812
|
+
var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
|
3813
|
+
var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
3814
|
+
var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
3815
|
+
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
3816
|
+
var __privateMethod$3 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
|
3817
|
+
var _table$1, _repository, _data, _Query_instances, cleanFilterConstraint_fn;
|
3796
3818
|
const _Query = class _Query {
|
3797
3819
|
constructor(repository, table, data, rawParent) {
|
3798
|
-
__privateAdd$4(this,
|
3799
|
-
__privateAdd$4(this, _table$1
|
3800
|
-
__privateAdd$4(this, _repository
|
3820
|
+
__privateAdd$4(this, _Query_instances);
|
3821
|
+
__privateAdd$4(this, _table$1);
|
3822
|
+
__privateAdd$4(this, _repository);
|
3801
3823
|
__privateAdd$4(this, _data, { filter: {} });
|
3802
3824
|
// Implements pagination
|
3803
3825
|
this.meta = { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } };
|
@@ -3875,12 +3897,12 @@ const _Query = class _Query {
|
|
3875
3897
|
filter(a, b) {
|
3876
3898
|
if (arguments.length === 1) {
|
3877
3899
|
const constraints = Object.entries(a ?? {}).map(([column, constraint]) => ({
|
3878
|
-
[column]: __privateMethod$3(this,
|
3900
|
+
[column]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, column, constraint)
|
3879
3901
|
}));
|
3880
3902
|
const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
|
3881
3903
|
return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
|
3882
3904
|
} else {
|
3883
|
-
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this,
|
3905
|
+
const constraints = isDefined(a) && isDefined(b) ? [{ [a]: __privateMethod$3(this, _Query_instances, cleanFilterConstraint_fn).call(this, a, b) }] : void 0;
|
3884
3906
|
const $all = compact([__privateGet$3(this, _data).filter?.$all].flat().concat(constraints));
|
3885
3907
|
return new _Query(__privateGet$3(this, _repository), __privateGet$3(this, _table$1), { filter: { $all } }, __privateGet$3(this, _data));
|
3886
3908
|
}
|
@@ -3959,8 +3981,7 @@ const _Query = class _Query {
|
|
3959
3981
|
}
|
3960
3982
|
async getFirstOrThrow(options = {}) {
|
3961
3983
|
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
3962
|
-
if (records[0] === void 0)
|
3963
|
-
throw new Error("No results found.");
|
3984
|
+
if (records[0] === void 0) throw new Error("No results found.");
|
3964
3985
|
return records[0];
|
3965
3986
|
}
|
3966
3987
|
async summarize(params = {}) {
|
@@ -4015,7 +4036,7 @@ const _Query = class _Query {
|
|
4015
4036
|
_table$1 = new WeakMap();
|
4016
4037
|
_repository = new WeakMap();
|
4017
4038
|
_data = new WeakMap();
|
4018
|
-
|
4039
|
+
_Query_instances = new WeakSet();
|
4019
4040
|
cleanFilterConstraint_fn = function(column, value) {
|
4020
4041
|
const columnType = __privateGet$3(this, _table$1).schema?.columns.find(({ name }) => name === column)?.type;
|
4021
4042
|
if (columnType === "multiple" && (isString(value) || isStringArray(value))) {
|
@@ -4076,8 +4097,7 @@ function isSortFilterString(value) {
|
|
4076
4097
|
}
|
4077
4098
|
function isSortFilterBase(filter) {
|
4078
4099
|
return isObject(filter) && Object.entries(filter).every(([key, value]) => {
|
4079
|
-
if (key === "*")
|
4080
|
-
return value === "random";
|
4100
|
+
if (key === "*") return value === "random";
|
4081
4101
|
return value === "asc" || value === "desc";
|
4082
4102
|
});
|
4083
4103
|
}
|
@@ -4098,29 +4118,15 @@ function buildSortFilter(filter) {
|
|
4098
4118
|
}
|
4099
4119
|
}
|
4100
4120
|
|
4101
|
-
var
|
4102
|
-
|
4103
|
-
throw TypeError("Cannot " + msg);
|
4104
|
-
};
|
4105
|
-
var __privateGet$2 = (obj, member, getter) => {
|
4106
|
-
__accessCheck$3(obj, member, "read from private field");
|
4107
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4108
|
-
};
|
4109
|
-
var __privateAdd$3 = (obj, member, value) => {
|
4110
|
-
if (member.has(obj))
|
4111
|
-
throw TypeError("Cannot add the same private member more than once");
|
4112
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4113
|
-
};
|
4114
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
4115
|
-
__accessCheck$3(obj, member, "write to private field");
|
4116
|
-
member.set(obj, value);
|
4117
|
-
return value;
|
4121
|
+
var __typeError$3 = (msg) => {
|
4122
|
+
throw TypeError(msg);
|
4118
4123
|
};
|
4119
|
-
var
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
var
|
4124
|
+
var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
|
4125
|
+
var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
4126
|
+
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4127
|
+
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
4128
|
+
var __privateMethod$2 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
|
4129
|
+
var _table, _getFetchProps, _db, _schemaTables, _trace, _RestRepository_instances, insertRecordWithoutId_fn, insertRecordWithId_fn, insertRecords_fn, updateRecordWithID_fn, updateRecords_fn, upsertRecordWithID_fn, deleteRecord_fn, deleteRecords_fn, getSchemaTables_fn, transformObjectToApi_fn;
|
4124
4130
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
4125
4131
|
class Repository extends Query {
|
4126
4132
|
}
|
@@ -4131,21 +4137,12 @@ class RestRepository extends Query {
|
|
4131
4137
|
{ name: options.table, schema: options.schemaTables?.find((table) => table.name === options.table) },
|
4132
4138
|
{}
|
4133
4139
|
);
|
4134
|
-
__privateAdd$3(this,
|
4135
|
-
__privateAdd$3(this,
|
4136
|
-
__privateAdd$3(this,
|
4137
|
-
__privateAdd$3(this,
|
4138
|
-
__privateAdd$3(this,
|
4139
|
-
__privateAdd$3(this,
|
4140
|
-
__privateAdd$3(this, _deleteRecord);
|
4141
|
-
__privateAdd$3(this, _deleteRecords);
|
4142
|
-
__privateAdd$3(this, _getSchemaTables);
|
4143
|
-
__privateAdd$3(this, _transformObjectToApi);
|
4144
|
-
__privateAdd$3(this, _table, void 0);
|
4145
|
-
__privateAdd$3(this, _getFetchProps, void 0);
|
4146
|
-
__privateAdd$3(this, _db, void 0);
|
4147
|
-
__privateAdd$3(this, _schemaTables, void 0);
|
4148
|
-
__privateAdd$3(this, _trace, void 0);
|
4140
|
+
__privateAdd$3(this, _RestRepository_instances);
|
4141
|
+
__privateAdd$3(this, _table);
|
4142
|
+
__privateAdd$3(this, _getFetchProps);
|
4143
|
+
__privateAdd$3(this, _db);
|
4144
|
+
__privateAdd$3(this, _schemaTables);
|
4145
|
+
__privateAdd$3(this, _trace);
|
4149
4146
|
__privateSet$1(this, _table, options.table);
|
4150
4147
|
__privateSet$1(this, _db, options.db);
|
4151
4148
|
__privateSet$1(this, _schemaTables, options.schemaTables);
|
@@ -4164,31 +4161,28 @@ class RestRepository extends Query {
|
|
4164
4161
|
return __privateGet$2(this, _trace).call(this, "create", async () => {
|
4165
4162
|
const ifVersion = parseIfVersion(b, c, d);
|
4166
4163
|
if (Array.isArray(a)) {
|
4167
|
-
if (a.length === 0)
|
4168
|
-
|
4169
|
-
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
4164
|
+
if (a.length === 0) return [];
|
4165
|
+
const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: true });
|
4170
4166
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4171
4167
|
const result = await this.read(ids, columns);
|
4172
4168
|
return result;
|
4173
4169
|
}
|
4174
4170
|
if (isString(a) && isObject(b)) {
|
4175
|
-
if (a === "")
|
4176
|
-
throw new Error("The id can't be empty");
|
4171
|
+
if (a === "") throw new Error("The id can't be empty");
|
4177
4172
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4178
|
-
return await __privateMethod$2(this,
|
4173
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: true, ifVersion });
|
4179
4174
|
}
|
4180
4175
|
if (isObject(a) && isString(a.xata_id)) {
|
4181
|
-
if (a.xata_id === "")
|
4182
|
-
throw new Error("The id can't be empty");
|
4176
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4183
4177
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4184
|
-
return await __privateMethod$2(this,
|
4178
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
|
4185
4179
|
createOnly: true,
|
4186
4180
|
ifVersion
|
4187
4181
|
});
|
4188
4182
|
}
|
4189
4183
|
if (isObject(a)) {
|
4190
4184
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4191
|
-
return __privateMethod$2(this,
|
4185
|
+
return __privateMethod$2(this, _RestRepository_instances, insertRecordWithoutId_fn).call(this, a, columns);
|
4192
4186
|
}
|
4193
4187
|
throw new Error("Invalid arguments for create method");
|
4194
4188
|
});
|
@@ -4197,8 +4191,7 @@ class RestRepository extends Query {
|
|
4197
4191
|
return __privateGet$2(this, _trace).call(this, "read", async () => {
|
4198
4192
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4199
4193
|
if (Array.isArray(a)) {
|
4200
|
-
if (a.length === 0)
|
4201
|
-
return [];
|
4194
|
+
if (a.length === 0) return [];
|
4202
4195
|
const ids = a.map((item) => extractId(item));
|
4203
4196
|
const finalObjects = await this.getAll({ filter: { xata_id: { $any: compact(ids) } }, columns });
|
4204
4197
|
const dictionary = finalObjects.reduce((acc, object) => {
|
@@ -4221,7 +4214,7 @@ class RestRepository extends Query {
|
|
4221
4214
|
queryParams: { columns },
|
4222
4215
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4223
4216
|
});
|
4224
|
-
const schemaTables = await __privateMethod$2(this,
|
4217
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4225
4218
|
return initObject(
|
4226
4219
|
__privateGet$2(this, _db),
|
4227
4220
|
schemaTables,
|
@@ -4262,11 +4255,10 @@ class RestRepository extends Query {
|
|
4262
4255
|
return __privateGet$2(this, _trace).call(this, "update", async () => {
|
4263
4256
|
const ifVersion = parseIfVersion(b, c, d);
|
4264
4257
|
if (Array.isArray(a)) {
|
4265
|
-
if (a.length === 0)
|
4266
|
-
return [];
|
4258
|
+
if (a.length === 0) return [];
|
4267
4259
|
const existing = await this.read(a, ["xata_id"]);
|
4268
4260
|
const updates = a.filter((_item, index) => existing[index] !== null);
|
4269
|
-
await __privateMethod$2(this,
|
4261
|
+
await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, updates, {
|
4270
4262
|
ifVersion,
|
4271
4263
|
upsert: false
|
4272
4264
|
});
|
@@ -4277,15 +4269,14 @@ class RestRepository extends Query {
|
|
4277
4269
|
try {
|
4278
4270
|
if (isString(a) && isObject(b)) {
|
4279
4271
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4280
|
-
return await __privateMethod$2(this,
|
4272
|
+
return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
4281
4273
|
}
|
4282
4274
|
if (isObject(a) && isString(a.xata_id)) {
|
4283
4275
|
const columns = isValidSelectableColumns(b) ? b : void 0;
|
4284
|
-
return await __privateMethod$2(this,
|
4276
|
+
return await __privateMethod$2(this, _RestRepository_instances, updateRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
|
4285
4277
|
}
|
4286
4278
|
} catch (error) {
|
4287
|
-
if (error.status === 422)
|
4288
|
-
return null;
|
4279
|
+
if (error.status === 422) return null;
|
4289
4280
|
throw error;
|
4290
4281
|
}
|
4291
4282
|
throw new Error("Invalid arguments for update method");
|
@@ -4314,9 +4305,8 @@ class RestRepository extends Query {
|
|
4314
4305
|
return __privateGet$2(this, _trace).call(this, "createOrUpdate", async () => {
|
4315
4306
|
const ifVersion = parseIfVersion(b, c, d);
|
4316
4307
|
if (Array.isArray(a)) {
|
4317
|
-
if (a.length === 0)
|
4318
|
-
|
4319
|
-
await __privateMethod$2(this, _updateRecords, updateRecords_fn).call(this, a, {
|
4308
|
+
if (a.length === 0) return [];
|
4309
|
+
await __privateMethod$2(this, _RestRepository_instances, updateRecords_fn).call(this, a, {
|
4320
4310
|
ifVersion,
|
4321
4311
|
upsert: true
|
4322
4312
|
});
|
@@ -4325,16 +4315,14 @@ class RestRepository extends Query {
|
|
4325
4315
|
return result;
|
4326
4316
|
}
|
4327
4317
|
if (isString(a) && isObject(b)) {
|
4328
|
-
if (a === "")
|
4329
|
-
throw new Error("The id can't be empty");
|
4318
|
+
if (a === "") throw new Error("The id can't be empty");
|
4330
4319
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4331
|
-
return await __privateMethod$2(this,
|
4320
|
+
return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
4332
4321
|
}
|
4333
4322
|
if (isObject(a) && isString(a.xata_id)) {
|
4334
|
-
if (a.xata_id === "")
|
4335
|
-
throw new Error("The id can't be empty");
|
4323
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4336
4324
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4337
|
-
return await __privateMethod$2(this,
|
4325
|
+
return await __privateMethod$2(this, _RestRepository_instances, upsertRecordWithID_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, { ifVersion });
|
4338
4326
|
}
|
4339
4327
|
if (!isDefined(a) && isObject(b)) {
|
4340
4328
|
return await this.create(b, c);
|
@@ -4349,24 +4337,21 @@ class RestRepository extends Query {
|
|
4349
4337
|
return __privateGet$2(this, _trace).call(this, "createOrReplace", async () => {
|
4350
4338
|
const ifVersion = parseIfVersion(b, c, d);
|
4351
4339
|
if (Array.isArray(a)) {
|
4352
|
-
if (a.length === 0)
|
4353
|
-
|
4354
|
-
const ids = await __privateMethod$2(this, _insertRecords, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
4340
|
+
if (a.length === 0) return [];
|
4341
|
+
const ids = await __privateMethod$2(this, _RestRepository_instances, insertRecords_fn).call(this, a, { ifVersion, createOnly: false });
|
4355
4342
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4356
4343
|
const result = await this.read(ids, columns);
|
4357
4344
|
return result;
|
4358
4345
|
}
|
4359
4346
|
if (isString(a) && isObject(b)) {
|
4360
|
-
if (a === "")
|
4361
|
-
throw new Error("The id can't be empty");
|
4347
|
+
if (a === "") throw new Error("The id can't be empty");
|
4362
4348
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4363
|
-
return await __privateMethod$2(this,
|
4349
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
4364
4350
|
}
|
4365
4351
|
if (isObject(a) && isString(a.xata_id)) {
|
4366
|
-
if (a.xata_id === "")
|
4367
|
-
throw new Error("The id can't be empty");
|
4352
|
+
if (a.xata_id === "") throw new Error("The id can't be empty");
|
4368
4353
|
const columns = isValidSelectableColumns(c) ? c : void 0;
|
4369
|
-
return await __privateMethod$2(this,
|
4354
|
+
return await __privateMethod$2(this, _RestRepository_instances, insertRecordWithId_fn).call(this, a.xata_id, { ...a, xata_id: void 0 }, columns, {
|
4370
4355
|
createOnly: false,
|
4371
4356
|
ifVersion
|
4372
4357
|
});
|
@@ -4383,25 +4368,22 @@ class RestRepository extends Query {
|
|
4383
4368
|
async delete(a, b) {
|
4384
4369
|
return __privateGet$2(this, _trace).call(this, "delete", async () => {
|
4385
4370
|
if (Array.isArray(a)) {
|
4386
|
-
if (a.length === 0)
|
4387
|
-
return [];
|
4371
|
+
if (a.length === 0) return [];
|
4388
4372
|
const ids = a.map((o) => {
|
4389
|
-
if (isString(o))
|
4390
|
-
|
4391
|
-
if (isString(o.xata_id))
|
4392
|
-
return o.xata_id;
|
4373
|
+
if (isString(o)) return o;
|
4374
|
+
if (isString(o.xata_id)) return o.xata_id;
|
4393
4375
|
throw new Error("Invalid arguments for delete method");
|
4394
4376
|
});
|
4395
4377
|
const columns = isValidSelectableColumns(b) ? b : ["*"];
|
4396
4378
|
const result = await this.read(a, columns);
|
4397
|
-
await __privateMethod$2(this,
|
4379
|
+
await __privateMethod$2(this, _RestRepository_instances, deleteRecords_fn).call(this, ids);
|
4398
4380
|
return result;
|
4399
4381
|
}
|
4400
4382
|
if (isString(a)) {
|
4401
|
-
return __privateMethod$2(this,
|
4383
|
+
return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a, b);
|
4402
4384
|
}
|
4403
4385
|
if (isObject(a) && isString(a.xata_id)) {
|
4404
|
-
return __privateMethod$2(this,
|
4386
|
+
return __privateMethod$2(this, _RestRepository_instances, deleteRecord_fn).call(this, a.xata_id, b);
|
4405
4387
|
}
|
4406
4388
|
throw new Error("Invalid arguments for delete method");
|
4407
4389
|
});
|
@@ -4445,7 +4427,7 @@ class RestRepository extends Query {
|
|
4445
4427
|
},
|
4446
4428
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4447
4429
|
});
|
4448
|
-
const schemaTables = await __privateMethod$2(this,
|
4430
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4449
4431
|
return {
|
4450
4432
|
records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
|
4451
4433
|
totalCount
|
@@ -4470,7 +4452,7 @@ class RestRepository extends Query {
|
|
4470
4452
|
},
|
4471
4453
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4472
4454
|
});
|
4473
|
-
const schemaTables = await __privateMethod$2(this,
|
4455
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4474
4456
|
return {
|
4475
4457
|
records: records.map((item) => initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), item, ["*"])),
|
4476
4458
|
totalCount
|
@@ -4512,7 +4494,7 @@ class RestRepository extends Query {
|
|
4512
4494
|
fetchOptions: data.fetchOptions,
|
4513
4495
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4514
4496
|
});
|
4515
|
-
const schemaTables = await __privateMethod$2(this,
|
4497
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4516
4498
|
const records = objects.map(
|
4517
4499
|
(record) => initObject(
|
4518
4500
|
__privateGet$2(this, _db),
|
@@ -4546,7 +4528,7 @@ class RestRepository extends Query {
|
|
4546
4528
|
},
|
4547
4529
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4548
4530
|
});
|
4549
|
-
const schemaTables = await __privateMethod$2(this,
|
4531
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4550
4532
|
return {
|
4551
4533
|
...result,
|
4552
4534
|
summaries: result.summaries.map(
|
@@ -4594,9 +4576,9 @@ _getFetchProps = new WeakMap();
|
|
4594
4576
|
_db = new WeakMap();
|
4595
4577
|
_schemaTables = new WeakMap();
|
4596
4578
|
_trace = new WeakMap();
|
4597
|
-
|
4579
|
+
_RestRepository_instances = new WeakSet();
|
4598
4580
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
4599
|
-
const record = await __privateMethod$2(this,
|
4581
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4600
4582
|
const response = await insertRecord({
|
4601
4583
|
pathParams: {
|
4602
4584
|
workspace: "{workspaceId}",
|
@@ -4608,14 +4590,12 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
4608
4590
|
body: record,
|
4609
4591
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4610
4592
|
});
|
4611
|
-
const schemaTables = await __privateMethod$2(this,
|
4593
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4612
4594
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4613
4595
|
};
|
4614
|
-
_insertRecordWithId = new WeakSet();
|
4615
4596
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
4616
|
-
if (!recordId)
|
4617
|
-
|
4618
|
-
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
4597
|
+
if (!recordId) return null;
|
4598
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4619
4599
|
const response = await insertRecordWithID({
|
4620
4600
|
pathParams: {
|
4621
4601
|
workspace: "{workspaceId}",
|
@@ -4628,13 +4608,12 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
4628
4608
|
queryParams: { createOnly, columns, ifVersion },
|
4629
4609
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4630
4610
|
});
|
4631
|
-
const schemaTables = await __privateMethod$2(this,
|
4611
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4632
4612
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4633
4613
|
};
|
4634
|
-
_insertRecords = new WeakSet();
|
4635
4614
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
4636
4615
|
const operations = await promiseMap(objects, async (object) => {
|
4637
|
-
const record = await __privateMethod$2(this,
|
4616
|
+
const record = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4638
4617
|
return { insert: { table: __privateGet$2(this, _table), record, createOnly, ifVersion } };
|
4639
4618
|
});
|
4640
4619
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
@@ -4659,11 +4638,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
4659
4638
|
}
|
4660
4639
|
return ids;
|
4661
4640
|
};
|
4662
|
-
_updateRecordWithID = new WeakSet();
|
4663
4641
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
4664
|
-
if (!recordId)
|
4665
|
-
|
4666
|
-
const { xata_id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
4642
|
+
if (!recordId) return null;
|
4643
|
+
const { xata_id: _id, ...record } = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4667
4644
|
try {
|
4668
4645
|
const response = await updateRecordWithID({
|
4669
4646
|
pathParams: {
|
@@ -4677,7 +4654,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4677
4654
|
body: record,
|
4678
4655
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4679
4656
|
});
|
4680
|
-
const schemaTables = await __privateMethod$2(this,
|
4657
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4681
4658
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4682
4659
|
} catch (e) {
|
4683
4660
|
if (isObject(e) && e.status === 404) {
|
@@ -4686,10 +4663,9 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4686
4663
|
throw e;
|
4687
4664
|
}
|
4688
4665
|
};
|
4689
|
-
_updateRecords = new WeakSet();
|
4690
4666
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
4691
4667
|
const operations = await promiseMap(objects, async ({ xata_id, ...object }) => {
|
4692
|
-
const fields = await __privateMethod$2(this,
|
4668
|
+
const fields = await __privateMethod$2(this, _RestRepository_instances, transformObjectToApi_fn).call(this, object);
|
4693
4669
|
return { update: { table: __privateGet$2(this, _table), id: xata_id, ifVersion, upsert, fields } };
|
4694
4670
|
});
|
4695
4671
|
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
@@ -4714,10 +4690,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
4714
4690
|
}
|
4715
4691
|
return ids;
|
4716
4692
|
};
|
4717
|
-
_upsertRecordWithID = new WeakSet();
|
4718
4693
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
4719
|
-
if (!recordId)
|
4720
|
-
return null;
|
4694
|
+
if (!recordId) return null;
|
4721
4695
|
const response = await upsertRecordWithID({
|
4722
4696
|
pathParams: {
|
4723
4697
|
workspace: "{workspaceId}",
|
@@ -4730,13 +4704,11 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
4730
4704
|
body: object,
|
4731
4705
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4732
4706
|
});
|
4733
|
-
const schemaTables = await __privateMethod$2(this,
|
4707
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4734
4708
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4735
4709
|
};
|
4736
|
-
_deleteRecord = new WeakSet();
|
4737
4710
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
4738
|
-
if (!recordId)
|
4739
|
-
return null;
|
4711
|
+
if (!recordId) return null;
|
4740
4712
|
try {
|
4741
4713
|
const response = await deleteRecord({
|
4742
4714
|
pathParams: {
|
@@ -4749,7 +4721,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4749
4721
|
queryParams: { columns },
|
4750
4722
|
...__privateGet$2(this, _getFetchProps).call(this)
|
4751
4723
|
});
|
4752
|
-
const schemaTables = await __privateMethod$2(this,
|
4724
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4753
4725
|
return initObject(__privateGet$2(this, _db), schemaTables, __privateGet$2(this, _table), response, columns);
|
4754
4726
|
} catch (e) {
|
4755
4727
|
if (isObject(e) && e.status === 404) {
|
@@ -4758,7 +4730,6 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
4758
4730
|
throw e;
|
4759
4731
|
}
|
4760
4732
|
};
|
4761
|
-
_deleteRecords = new WeakSet();
|
4762
4733
|
deleteRecords_fn = async function(recordIds) {
|
4763
4734
|
const chunkedOperations = chunk(
|
4764
4735
|
compact(recordIds).map((id) => ({ delete: { table: __privateGet$2(this, _table), id } })),
|
@@ -4776,10 +4747,8 @@ deleteRecords_fn = async function(recordIds) {
|
|
4776
4747
|
});
|
4777
4748
|
}
|
4778
4749
|
};
|
4779
|
-
_getSchemaTables = new WeakSet();
|
4780
4750
|
getSchemaTables_fn = async function() {
|
4781
|
-
if (__privateGet$2(this, _schemaTables))
|
4782
|
-
return __privateGet$2(this, _schemaTables);
|
4751
|
+
if (__privateGet$2(this, _schemaTables)) return __privateGet$2(this, _schemaTables);
|
4783
4752
|
const { schema } = await getBranchDetails({
|
4784
4753
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
4785
4754
|
...__privateGet$2(this, _getFetchProps).call(this)
|
@@ -4787,16 +4756,13 @@ getSchemaTables_fn = async function() {
|
|
4787
4756
|
__privateSet$1(this, _schemaTables, schema.tables);
|
4788
4757
|
return schema.tables;
|
4789
4758
|
};
|
4790
|
-
_transformObjectToApi = new WeakSet();
|
4791
4759
|
transformObjectToApi_fn = async function(object) {
|
4792
|
-
const schemaTables = await __privateMethod$2(this,
|
4760
|
+
const schemaTables = await __privateMethod$2(this, _RestRepository_instances, getSchemaTables_fn).call(this);
|
4793
4761
|
const schema = schemaTables.find((table) => table.name === __privateGet$2(this, _table));
|
4794
|
-
if (!schema)
|
4795
|
-
throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
|
4762
|
+
if (!schema) throw new Error(`Table ${__privateGet$2(this, _table)} not found in schema`);
|
4796
4763
|
const result = {};
|
4797
4764
|
for (const [key, value] of Object.entries(object)) {
|
4798
|
-
if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key))
|
4799
|
-
continue;
|
4765
|
+
if (["xata_version", "xata_createdat", "xata_updatedat"].includes(key)) continue;
|
4800
4766
|
const type = schema.columns.find((column) => column.name === key)?.type;
|
4801
4767
|
switch (type) {
|
4802
4768
|
case "link": {
|
@@ -4826,11 +4792,9 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4826
4792
|
const data = {};
|
4827
4793
|
Object.assign(data, { ...object });
|
4828
4794
|
const { columns } = schemaTables.find(({ name }) => name === table) ?? {};
|
4829
|
-
if (!columns)
|
4830
|
-
console.error(`Table ${table} not found in schema`);
|
4795
|
+
if (!columns) console.error(`Table ${table} not found in schema`);
|
4831
4796
|
for (const column of columns ?? []) {
|
4832
|
-
if (!isValidColumn(selectedColumns, column))
|
4833
|
-
continue;
|
4797
|
+
if (!isValidColumn(selectedColumns, column)) continue;
|
4834
4798
|
const value = data[column.name];
|
4835
4799
|
switch (column.type) {
|
4836
4800
|
case "datetime": {
|
@@ -4916,15 +4880,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
4916
4880
|
return record;
|
4917
4881
|
};
|
4918
4882
|
function extractId(value) {
|
4919
|
-
if (isString(value))
|
4920
|
-
|
4921
|
-
if (isObject(value) && isString(value.xata_id))
|
4922
|
-
return value.xata_id;
|
4883
|
+
if (isString(value)) return value;
|
4884
|
+
if (isObject(value) && isString(value.xata_id)) return value.xata_id;
|
4923
4885
|
return void 0;
|
4924
4886
|
}
|
4925
4887
|
function isValidColumn(columns, column) {
|
4926
|
-
if (columns.includes("*"))
|
4927
|
-
return true;
|
4888
|
+
if (columns.includes("*")) return true;
|
4928
4889
|
return columns.filter((item) => isString(item) && item.startsWith(column.name)).length > 0;
|
4929
4890
|
}
|
4930
4891
|
function parseIfVersion(...args) {
|
@@ -4964,19 +4925,12 @@ const includesAll = (value) => ({ $includesAll: value });
|
|
4964
4925
|
const includesNone = (value) => ({ $includesNone: value });
|
4965
4926
|
const includesAny = (value) => ({ $includesAny: value });
|
4966
4927
|
|
4967
|
-
var
|
4968
|
-
|
4969
|
-
throw TypeError("Cannot " + msg);
|
4970
|
-
};
|
4971
|
-
var __privateGet$1 = (obj, member, getter) => {
|
4972
|
-
__accessCheck$2(obj, member, "read from private field");
|
4973
|
-
return getter ? getter.call(obj) : member.get(obj);
|
4974
|
-
};
|
4975
|
-
var __privateAdd$2 = (obj, member, value) => {
|
4976
|
-
if (member.has(obj))
|
4977
|
-
throw TypeError("Cannot add the same private member more than once");
|
4978
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4928
|
+
var __typeError$2 = (msg) => {
|
4929
|
+
throw TypeError(msg);
|
4979
4930
|
};
|
4931
|
+
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
4932
|
+
var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
4933
|
+
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
4980
4934
|
var _tables;
|
4981
4935
|
class SchemaPlugin extends XataPlugin {
|
4982
4936
|
constructor() {
|
@@ -4988,8 +4942,7 @@ class SchemaPlugin extends XataPlugin {
|
|
4988
4942
|
{},
|
4989
4943
|
{
|
4990
4944
|
get: (_target, table) => {
|
4991
|
-
if (!isString(table))
|
4992
|
-
throw new Error("Invalid table name");
|
4945
|
+
if (!isString(table)) throw new Error("Invalid table name");
|
4993
4946
|
if (__privateGet$1(this, _tables)[table] === void 0) {
|
4994
4947
|
__privateGet$1(this, _tables)[table] = new RestRepository({ db, pluginOptions, table, schemaTables: pluginOptions.tables });
|
4995
4948
|
}
|
@@ -5080,30 +5033,23 @@ function getContentType(file) {
|
|
5080
5033
|
return "application/octet-stream";
|
5081
5034
|
}
|
5082
5035
|
|
5083
|
-
var
|
5084
|
-
|
5085
|
-
throw TypeError("Cannot " + msg);
|
5086
|
-
};
|
5087
|
-
var __privateAdd$1 = (obj, member, value) => {
|
5088
|
-
if (member.has(obj))
|
5089
|
-
throw TypeError("Cannot add the same private member more than once");
|
5090
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
5091
|
-
};
|
5092
|
-
var __privateMethod$1 = (obj, member, method) => {
|
5093
|
-
__accessCheck$1(obj, member, "access private method");
|
5094
|
-
return method;
|
5036
|
+
var __typeError$1 = (msg) => {
|
5037
|
+
throw TypeError(msg);
|
5095
5038
|
};
|
5096
|
-
var
|
5039
|
+
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
5040
|
+
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
5041
|
+
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
5042
|
+
var _SearchPlugin_instances, search_fn;
|
5097
5043
|
class SearchPlugin extends XataPlugin {
|
5098
5044
|
constructor(db) {
|
5099
5045
|
super();
|
5100
5046
|
this.db = db;
|
5101
|
-
__privateAdd$1(this,
|
5047
|
+
__privateAdd$1(this, _SearchPlugin_instances);
|
5102
5048
|
}
|
5103
5049
|
build(pluginOptions) {
|
5104
5050
|
return {
|
5105
5051
|
all: async (query, options = {}) => {
|
5106
|
-
const { records, totalCount } = await __privateMethod$1(this,
|
5052
|
+
const { records, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
|
5107
5053
|
return {
|
5108
5054
|
totalCount,
|
5109
5055
|
records: records.map((record) => {
|
@@ -5113,7 +5059,7 @@ class SearchPlugin extends XataPlugin {
|
|
5113
5059
|
};
|
5114
5060
|
},
|
5115
5061
|
byTable: async (query, options = {}) => {
|
5116
|
-
const { records: rawRecords, totalCount } = await __privateMethod$1(this,
|
5062
|
+
const { records: rawRecords, totalCount } = await __privateMethod$1(this, _SearchPlugin_instances, search_fn).call(this, query, options, pluginOptions);
|
5117
5063
|
const records = rawRecords.reduce((acc, record) => {
|
5118
5064
|
const table = record.xata_table;
|
5119
5065
|
const items = acc[table] ?? [];
|
@@ -5125,7 +5071,7 @@ class SearchPlugin extends XataPlugin {
|
|
5125
5071
|
};
|
5126
5072
|
}
|
5127
5073
|
}
|
5128
|
-
|
5074
|
+
_SearchPlugin_instances = new WeakSet();
|
5129
5075
|
search_fn = async function(query, options, pluginOptions) {
|
5130
5076
|
const { tables, fuzziness, highlight, prefix, page } = options ?? {};
|
5131
5077
|
const { records, totalCount } = await searchBranch({
|
@@ -5161,8 +5107,7 @@ function arrayString(val) {
|
|
5161
5107
|
return result;
|
5162
5108
|
}
|
5163
5109
|
function prepareValue(value) {
|
5164
|
-
if (!isDefined(value))
|
5165
|
-
return null;
|
5110
|
+
if (!isDefined(value)) return null;
|
5166
5111
|
if (value instanceof Date) {
|
5167
5112
|
return value.toISOString();
|
5168
5113
|
}
|
@@ -5202,19 +5147,28 @@ class SQLPlugin extends XataPlugin {
|
|
5202
5147
|
throw new Error("Invalid usage of `xata.sql`. Please use it as a tagged template or with an object.");
|
5203
5148
|
}
|
5204
5149
|
const { statement, params, consistency, responseType } = prepareParams(query, parameters);
|
5205
|
-
const {
|
5206
|
-
records,
|
5207
|
-
rows,
|
5208
|
-
warning,
|
5209
|
-
columns = []
|
5210
|
-
} = await sqlQuery({
|
5150
|
+
const { warning, columns, ...response } = await sqlQuery({
|
5211
5151
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
5212
5152
|
body: { statement, params, consistency, responseType },
|
5213
5153
|
...pluginOptions
|
5214
5154
|
});
|
5155
|
+
const records = "records" in response ? response.records : void 0;
|
5156
|
+
const rows = "rows" in response ? response.rows : void 0;
|
5215
5157
|
return { records, rows, warning, columns };
|
5216
5158
|
};
|
5217
5159
|
sqlFunction.connectionString = buildConnectionString(pluginOptions);
|
5160
|
+
sqlFunction.batch = async (query) => {
|
5161
|
+
const { results } = await sqlBatchQuery({
|
5162
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", region: "{region}" },
|
5163
|
+
body: {
|
5164
|
+
statements: query.statements.map(({ statement, params }) => ({ statement, params })),
|
5165
|
+
consistency: query.consistency,
|
5166
|
+
responseType: query.responseType
|
5167
|
+
},
|
5168
|
+
...pluginOptions
|
5169
|
+
});
|
5170
|
+
return { results };
|
5171
|
+
};
|
5218
5172
|
return sqlFunction;
|
5219
5173
|
}
|
5220
5174
|
}
|
@@ -5241,8 +5195,7 @@ function buildDomain(host, region) {
|
|
5241
5195
|
function buildConnectionString({ apiKey, workspacesApiUrl, branch }) {
|
5242
5196
|
const url = isString(workspacesApiUrl) ? workspacesApiUrl : workspacesApiUrl("", {});
|
5243
5197
|
const parts = parseWorkspacesUrlParts(url);
|
5244
|
-
if (!parts)
|
5245
|
-
throw new Error("Invalid workspaces URL");
|
5198
|
+
if (!parts) throw new Error("Invalid workspaces URL");
|
5246
5199
|
const { workspace: workspaceSlug, region, database, host } = parts;
|
5247
5200
|
const domain = buildDomain(host, region);
|
5248
5201
|
const workspace = workspaceSlug.split("-").pop();
|
@@ -5267,39 +5220,24 @@ class TransactionPlugin extends XataPlugin {
|
|
5267
5220
|
}
|
5268
5221
|
}
|
5269
5222
|
|
5270
|
-
var
|
5271
|
-
|
5272
|
-
throw TypeError("Cannot " + msg);
|
5273
|
-
};
|
5274
|
-
var __privateGet = (obj, member, getter) => {
|
5275
|
-
__accessCheck(obj, member, "read from private field");
|
5276
|
-
return getter ? getter.call(obj) : member.get(obj);
|
5277
|
-
};
|
5278
|
-
var __privateAdd = (obj, member, value) => {
|
5279
|
-
if (member.has(obj))
|
5280
|
-
throw TypeError("Cannot add the same private member more than once");
|
5281
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
5282
|
-
};
|
5283
|
-
var __privateSet = (obj, member, value, setter) => {
|
5284
|
-
__accessCheck(obj, member, "write to private field");
|
5285
|
-
member.set(obj, value);
|
5286
|
-
return value;
|
5287
|
-
};
|
5288
|
-
var __privateMethod = (obj, member, method) => {
|
5289
|
-
__accessCheck(obj, member, "access private method");
|
5290
|
-
return method;
|
5223
|
+
var __typeError = (msg) => {
|
5224
|
+
throw TypeError(msg);
|
5291
5225
|
};
|
5226
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
5227
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
5228
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
5229
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
5230
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
5292
5231
|
const buildClient = (plugins) => {
|
5293
|
-
var _options,
|
5232
|
+
var _options, _instances, parseOptions_fn, getFetchProps_fn, _a;
|
5294
5233
|
return _a = class {
|
5295
5234
|
constructor(options = {}, tables) {
|
5296
|
-
__privateAdd(this,
|
5297
|
-
__privateAdd(this,
|
5298
|
-
|
5299
|
-
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
5235
|
+
__privateAdd(this, _instances);
|
5236
|
+
__privateAdd(this, _options);
|
5237
|
+
const safeOptions = __privateMethod(this, _instances, parseOptions_fn).call(this, options);
|
5300
5238
|
__privateSet(this, _options, safeOptions);
|
5301
5239
|
const pluginOptions = {
|
5302
|
-
...__privateMethod(this,
|
5240
|
+
...__privateMethod(this, _instances, getFetchProps_fn).call(this, safeOptions),
|
5303
5241
|
host: safeOptions.host,
|
5304
5242
|
tables,
|
5305
5243
|
branch: safeOptions.branch
|
@@ -5316,8 +5254,7 @@ const buildClient = (plugins) => {
|
|
5316
5254
|
this.sql = sql;
|
5317
5255
|
this.files = files;
|
5318
5256
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
5319
|
-
if (namespace === void 0)
|
5320
|
-
continue;
|
5257
|
+
if (namespace === void 0) continue;
|
5321
5258
|
this[key] = namespace.build(pluginOptions);
|
5322
5259
|
}
|
5323
5260
|
}
|
@@ -5326,7 +5263,7 @@ const buildClient = (plugins) => {
|
|
5326
5263
|
const branch = __privateGet(this, _options).branch;
|
5327
5264
|
return { databaseURL, branch };
|
5328
5265
|
}
|
5329
|
-
}, _options = new WeakMap(),
|
5266
|
+
}, _options = new WeakMap(), _instances = new WeakSet(), parseOptions_fn = function(options) {
|
5330
5267
|
const enableBrowser = options?.enableBrowser ?? false;
|
5331
5268
|
const isBrowser = typeof window !== "undefined" && typeof Deno === "undefined";
|
5332
5269
|
if (isBrowser && !enableBrowser) {
|
@@ -5363,7 +5300,7 @@ const buildClient = (plugins) => {
|
|
5363
5300
|
clientName,
|
5364
5301
|
xataAgentExtra
|
5365
5302
|
};
|
5366
|
-
},
|
5303
|
+
}, getFetchProps_fn = function({
|
5367
5304
|
fetch,
|
5368
5305
|
apiKey,
|
5369
5306
|
databaseURL,
|
@@ -5404,26 +5341,19 @@ class Serializer {
|
|
5404
5341
|
}
|
5405
5342
|
toJSON(data) {
|
5406
5343
|
function visit(obj) {
|
5407
|
-
if (Array.isArray(obj))
|
5408
|
-
return obj.map(visit);
|
5344
|
+
if (Array.isArray(obj)) return obj.map(visit);
|
5409
5345
|
const type = typeof obj;
|
5410
|
-
if (type === "undefined")
|
5411
|
-
|
5412
|
-
if (
|
5413
|
-
return { [META]: "bigint", [VALUE]: obj.toString() };
|
5414
|
-
if (obj === null || type !== "object")
|
5415
|
-
return obj;
|
5346
|
+
if (type === "undefined") return { [META]: "undefined" };
|
5347
|
+
if (type === "bigint") return { [META]: "bigint", [VALUE]: obj.toString() };
|
5348
|
+
if (obj === null || type !== "object") return obj;
|
5416
5349
|
const constructor = obj.constructor;
|
5417
5350
|
const o = { [META]: constructor.name };
|
5418
5351
|
for (const [key, value] of Object.entries(obj)) {
|
5419
5352
|
o[key] = visit(value);
|
5420
5353
|
}
|
5421
|
-
if (constructor === Date)
|
5422
|
-
|
5423
|
-
if (constructor ===
|
5424
|
-
o[VALUE] = Object.fromEntries(obj);
|
5425
|
-
if (constructor === Set)
|
5426
|
-
o[VALUE] = [...obj];
|
5354
|
+
if (constructor === Date) o[VALUE] = obj.toISOString();
|
5355
|
+
if (constructor === Map) o[VALUE] = Object.fromEntries(obj);
|
5356
|
+
if (constructor === Set) o[VALUE] = [...obj];
|
5427
5357
|
return o;
|
5428
5358
|
}
|
5429
5359
|
return JSON.stringify(visit(data));
|
@@ -5436,16 +5366,11 @@ class Serializer {
|
|
5436
5366
|
if (constructor) {
|
5437
5367
|
return Object.assign(Object.create(constructor.prototype), rest);
|
5438
5368
|
}
|
5439
|
-
if (clazz === "Date")
|
5440
|
-
|
5441
|
-
if (clazz === "
|
5442
|
-
|
5443
|
-
if (clazz === "
|
5444
|
-
return new Map(Object.entries(val));
|
5445
|
-
if (clazz === "bigint")
|
5446
|
-
return BigInt(val);
|
5447
|
-
if (clazz === "undefined")
|
5448
|
-
return void 0;
|
5369
|
+
if (clazz === "Date") return new Date(val);
|
5370
|
+
if (clazz === "Set") return new Set(val);
|
5371
|
+
if (clazz === "Map") return new Map(Object.entries(val));
|
5372
|
+
if (clazz === "bigint") return BigInt(val);
|
5373
|
+
if (clazz === "undefined") return void 0;
|
5449
5374
|
return rest;
|
5450
5375
|
}
|
5451
5376
|
return value;
|
@@ -5485,8 +5410,7 @@ function buildPreviewBranchName({ org, branch }) {
|
|
5485
5410
|
function getDeployPreviewBranch(environment) {
|
5486
5411
|
try {
|
5487
5412
|
const { deployPreview, deployPreviewBranch, vercelGitCommitRef, vercelGitRepoOwner } = parseEnvironment(environment);
|
5488
|
-
if (deployPreviewBranch)
|
5489
|
-
return deployPreviewBranch;
|
5413
|
+
if (deployPreviewBranch) return deployPreviewBranch;
|
5490
5414
|
switch (deployPreview) {
|
5491
5415
|
case "vercel": {
|
5492
5416
|
if (!vercelGitCommitRef || !vercelGitRepoOwner) {
|
@@ -5554,9 +5478,11 @@ exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
|
5554
5478
|
exports.compareBranchSchemas = compareBranchSchemas;
|
5555
5479
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
5556
5480
|
exports.compareMigrationRequest = compareMigrationRequest;
|
5481
|
+
exports.completeMigration = completeMigration;
|
5557
5482
|
exports.contains = contains;
|
5558
5483
|
exports.copyBranch = copyBranch;
|
5559
5484
|
exports.createBranch = createBranch;
|
5485
|
+
exports.createBranchAsync = createBranchAsync;
|
5560
5486
|
exports.createCluster = createCluster;
|
5561
5487
|
exports.createDatabase = createDatabase;
|
5562
5488
|
exports.createMigrationRequest = createMigrationRequest;
|
@@ -5578,6 +5504,7 @@ exports.deleteUserAPIKey = deleteUserAPIKey;
|
|
5578
5504
|
exports.deleteUserOAuthClient = deleteUserOAuthClient;
|
5579
5505
|
exports.deleteWorkspace = deleteWorkspace;
|
5580
5506
|
exports.deserialize = deserialize;
|
5507
|
+
exports.dropClusterExtension = dropClusterExtension;
|
5581
5508
|
exports.endsWith = endsWith;
|
5582
5509
|
exports.equals = equals;
|
5583
5510
|
exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
@@ -5592,9 +5519,11 @@ exports.getBranchMetadata = getBranchMetadata;
|
|
5592
5519
|
exports.getBranchMigrationHistory = getBranchMigrationHistory;
|
5593
5520
|
exports.getBranchMigrationJobStatus = getBranchMigrationJobStatus;
|
5594
5521
|
exports.getBranchMigrationPlan = getBranchMigrationPlan;
|
5522
|
+
exports.getBranchMoveStatus = getBranchMoveStatus;
|
5595
5523
|
exports.getBranchSchemaHistory = getBranchSchemaHistory;
|
5596
5524
|
exports.getBranchStats = getBranchStats;
|
5597
5525
|
exports.getCluster = getCluster;
|
5526
|
+
exports.getClusterMetrics = getClusterMetrics;
|
5598
5527
|
exports.getColumn = getColumn;
|
5599
5528
|
exports.getDatabaseGithubSettings = getDatabaseGithubSettings;
|
5600
5529
|
exports.getDatabaseList = getDatabaseList;
|
@@ -5607,12 +5536,16 @@ exports.getGitBranchesMapping = getGitBranchesMapping;
|
|
5607
5536
|
exports.getHostUrl = getHostUrl;
|
5608
5537
|
exports.getMigrationHistory = getMigrationHistory;
|
5609
5538
|
exports.getMigrationJobStatus = getMigrationJobStatus;
|
5539
|
+
exports.getMigrationJobs = getMigrationJobs;
|
5610
5540
|
exports.getMigrationRequest = getMigrationRequest;
|
5611
5541
|
exports.getMigrationRequestIsMerged = getMigrationRequestIsMerged;
|
5612
5542
|
exports.getRecord = getRecord;
|
5613
5543
|
exports.getSchema = getSchema;
|
5544
|
+
exports.getSchemas = getSchemas;
|
5614
5545
|
exports.getTableColumns = getTableColumns;
|
5615
5546
|
exports.getTableSchema = getTableSchema;
|
5547
|
+
exports.getTaskStatus = getTaskStatus;
|
5548
|
+
exports.getTasks = getTasks;
|
5616
5549
|
exports.getUser = getUser;
|
5617
5550
|
exports.getUserAPIKeys = getUserAPIKeys;
|
5618
5551
|
exports.getUserOAuthAccessTokens = getUserOAuthAccessTokens;
|
@@ -5635,6 +5568,7 @@ exports.includesAny = includesAny;
|
|
5635
5568
|
exports.includesNone = includesNone;
|
5636
5569
|
exports.insertRecord = insertRecord;
|
5637
5570
|
exports.insertRecordWithID = insertRecordWithID;
|
5571
|
+
exports.installClusterExtension = installClusterExtension;
|
5638
5572
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
5639
5573
|
exports.is = is;
|
5640
5574
|
exports.isCursorPaginationOptions = isCursorPaginationOptions;
|
@@ -5648,12 +5582,15 @@ exports.le = le;
|
|
5648
5582
|
exports.lessEquals = lessEquals;
|
5649
5583
|
exports.lessThan = lessThan;
|
5650
5584
|
exports.lessThanEquals = lessThanEquals;
|
5585
|
+
exports.listClusterBranches = listClusterBranches;
|
5586
|
+
exports.listClusterExtensions = listClusterExtensions;
|
5651
5587
|
exports.listClusters = listClusters;
|
5652
5588
|
exports.listMigrationRequestsCommits = listMigrationRequestsCommits;
|
5653
5589
|
exports.listRegions = listRegions;
|
5654
5590
|
exports.lt = lt;
|
5655
5591
|
exports.lte = lte;
|
5656
5592
|
exports.mergeMigrationRequest = mergeMigrationRequest;
|
5593
|
+
exports.moveBranch = moveBranch;
|
5657
5594
|
exports.notExists = notExists;
|
5658
5595
|
exports.operationsByTag = operationsByTag;
|
5659
5596
|
exports.parseProviderString = parseProviderString;
|
@@ -5670,11 +5607,14 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
5670
5607
|
exports.renameDatabase = renameDatabase;
|
5671
5608
|
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
5672
5609
|
exports.resolveBranch = resolveBranch;
|
5610
|
+
exports.rollbackMigration = rollbackMigration;
|
5673
5611
|
exports.searchBranch = searchBranch;
|
5674
5612
|
exports.searchTable = searchTable;
|
5675
5613
|
exports.serialize = serialize;
|
5676
5614
|
exports.setTableSchema = setTableSchema;
|
5615
|
+
exports.sqlBatchQuery = sqlBatchQuery;
|
5677
5616
|
exports.sqlQuery = sqlQuery;
|
5617
|
+
exports.startMigration = startMigration;
|
5678
5618
|
exports.startsWith = startsWith;
|
5679
5619
|
exports.summarizeTable = summarizeTable;
|
5680
5620
|
exports.transformImage = transformImage;
|