@xata.io/client 0.24.3 → 0.25.1
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 +9 -4
- package/CHANGELOG.md +22 -0
- package/dist/index.cjs +493 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +491 -29
- package/dist/index.mjs +489 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -27,8 +27,11 @@ function notEmpty(value) {
|
|
27
27
|
function compact(arr) {
|
28
28
|
return arr.filter(notEmpty);
|
29
29
|
}
|
30
|
+
function compactObject(obj) {
|
31
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
32
|
+
}
|
30
33
|
function isObject(value) {
|
31
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
34
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
32
35
|
}
|
33
36
|
function isDefined(value) {
|
34
37
|
return value !== null && value !== void 0;
|
@@ -83,6 +86,27 @@ function chunk(array, chunkSize) {
|
|
83
86
|
async function timeout(ms) {
|
84
87
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
85
88
|
}
|
89
|
+
function timeoutWithCancel(ms) {
|
90
|
+
let timeoutId;
|
91
|
+
const promise = new Promise((resolve) => {
|
92
|
+
timeoutId = setTimeout(() => {
|
93
|
+
resolve();
|
94
|
+
}, ms);
|
95
|
+
});
|
96
|
+
return {
|
97
|
+
cancel: () => clearTimeout(timeoutId),
|
98
|
+
promise
|
99
|
+
};
|
100
|
+
}
|
101
|
+
function promiseMap(inputValues, mapper) {
|
102
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
103
|
+
(acc) => mapper(inputValue).then((result) => {
|
104
|
+
acc.push(result);
|
105
|
+
return acc;
|
106
|
+
})
|
107
|
+
);
|
108
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
109
|
+
}
|
86
110
|
|
87
111
|
function getEnvironment() {
|
88
112
|
try {
|
@@ -210,6 +234,12 @@ function getPreviewBranch() {
|
|
210
234
|
}
|
211
235
|
}
|
212
236
|
|
237
|
+
var __defProp$8 = Object.defineProperty;
|
238
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
239
|
+
var __publicField$8 = (obj, key, value) => {
|
240
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
241
|
+
return value;
|
242
|
+
};
|
213
243
|
var __accessCheck$8 = (obj, member, msg) => {
|
214
244
|
if (!member.has(obj))
|
215
245
|
throw TypeError("Cannot " + msg);
|
@@ -233,6 +263,7 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
233
263
|
return method;
|
234
264
|
};
|
235
265
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
266
|
+
const REQUEST_TIMEOUT = 3e4;
|
236
267
|
function getFetchImplementation(userFetch) {
|
237
268
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
238
269
|
const fetchImpl = userFetch ?? globalFetch;
|
@@ -249,6 +280,8 @@ class ApiRequestPool {
|
|
249
280
|
__privateAdd$8(this, _fetch, void 0);
|
250
281
|
__privateAdd$8(this, _queue, void 0);
|
251
282
|
__privateAdd$8(this, _concurrency, void 0);
|
283
|
+
__publicField$8(this, "running");
|
284
|
+
__publicField$8(this, "started");
|
252
285
|
__privateSet$8(this, _queue, []);
|
253
286
|
__privateSet$8(this, _concurrency, concurrency);
|
254
287
|
this.running = 0;
|
@@ -265,9 +298,13 @@ class ApiRequestPool {
|
|
265
298
|
}
|
266
299
|
request(url, options) {
|
267
300
|
const start = /* @__PURE__ */ new Date();
|
268
|
-
const
|
301
|
+
const fetchImpl = this.getFetch();
|
269
302
|
const runRequest = async (stalled = false) => {
|
270
|
-
const
|
303
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
304
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
305
|
+
if (!response) {
|
306
|
+
throw new Error("Request timed out");
|
307
|
+
}
|
271
308
|
if (response.status === 429) {
|
272
309
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
273
310
|
await timeout(rateLimitReset * 1e3);
|
@@ -490,16 +527,26 @@ function defaultOnOpen(response) {
|
|
490
527
|
}
|
491
528
|
}
|
492
529
|
|
493
|
-
const VERSION = "0.
|
530
|
+
const VERSION = "0.25.1";
|
494
531
|
|
532
|
+
var __defProp$7 = Object.defineProperty;
|
533
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
534
|
+
var __publicField$7 = (obj, key, value) => {
|
535
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
536
|
+
return value;
|
537
|
+
};
|
495
538
|
class ErrorWithCause extends Error {
|
496
539
|
constructor(message, options) {
|
497
540
|
super(message, options);
|
541
|
+
__publicField$7(this, "cause");
|
498
542
|
}
|
499
543
|
}
|
500
544
|
class FetcherError extends ErrorWithCause {
|
501
545
|
constructor(status, data, requestId) {
|
502
546
|
super(getMessage(data));
|
547
|
+
__publicField$7(this, "status");
|
548
|
+
__publicField$7(this, "requestId");
|
549
|
+
__publicField$7(this, "errors");
|
503
550
|
this.status = status;
|
504
551
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
505
552
|
this.requestId = requestId;
|
@@ -566,6 +613,15 @@ function hostHeader(url) {
|
|
566
613
|
const { groups } = pattern.exec(url) ?? {};
|
567
614
|
return groups?.host ? { Host: groups.host } : {};
|
568
615
|
}
|
616
|
+
function parseBody(body, headers) {
|
617
|
+
if (!isDefined(body))
|
618
|
+
return void 0;
|
619
|
+
const { "Content-Type": contentType } = headers ?? {};
|
620
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
621
|
+
return JSON.stringify(body);
|
622
|
+
}
|
623
|
+
return body;
|
624
|
+
}
|
569
625
|
const defaultClientID = generateUUID();
|
570
626
|
async function fetch$1({
|
571
627
|
url: path,
|
@@ -585,7 +641,8 @@ async function fetch$1({
|
|
585
641
|
sessionID,
|
586
642
|
clientName,
|
587
643
|
xataAgentExtra,
|
588
|
-
fetchOptions = {}
|
644
|
+
fetchOptions = {},
|
645
|
+
rawResponse = false
|
589
646
|
}) {
|
590
647
|
pool.setFetch(fetch2);
|
591
648
|
return await trace(
|
@@ -604,7 +661,7 @@ async function fetch$1({
|
|
604
661
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
605
662
|
...Object.entries(xataAgentExtra ?? {})
|
606
663
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
607
|
-
const headers = {
|
664
|
+
const headers = compactObject({
|
608
665
|
"Accept-Encoding": "identity",
|
609
666
|
"Content-Type": "application/json",
|
610
667
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -613,11 +670,11 @@ async function fetch$1({
|
|
613
670
|
...customHeaders,
|
614
671
|
...hostHeader(fullUrl),
|
615
672
|
Authorization: `Bearer ${apiKey}`
|
616
|
-
};
|
673
|
+
});
|
617
674
|
const response = await pool.request(url, {
|
618
675
|
...fetchOptions,
|
619
676
|
method: method.toUpperCase(),
|
620
|
-
body: body
|
677
|
+
body: parseBody(body, headers),
|
621
678
|
headers,
|
622
679
|
signal
|
623
680
|
});
|
@@ -630,6 +687,9 @@ async function fetch$1({
|
|
630
687
|
[TraceAttributes.HTTP_HOST]: host,
|
631
688
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
632
689
|
});
|
690
|
+
const message = response.headers?.get("x-xata-message");
|
691
|
+
if (message)
|
692
|
+
console.warn(message);
|
633
693
|
if (response.status === 204) {
|
634
694
|
return {};
|
635
695
|
}
|
@@ -637,7 +697,7 @@ async function fetch$1({
|
|
637
697
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
638
698
|
}
|
639
699
|
try {
|
640
|
-
const jsonResponse = await response.json();
|
700
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
641
701
|
if (response.ok) {
|
642
702
|
return jsonResponse;
|
643
703
|
}
|
@@ -910,6 +970,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
910
970
|
...variables,
|
911
971
|
signal
|
912
972
|
});
|
973
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
913
974
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
914
975
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
915
976
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -985,6 +1046,7 @@ const operationsByTag$2 = {
|
|
985
1046
|
sqlQuery,
|
986
1047
|
vectorSearchTable,
|
987
1048
|
askTable,
|
1049
|
+
askTableSession,
|
988
1050
|
summarizeTable,
|
989
1051
|
aggregateTable
|
990
1052
|
}
|
@@ -992,6 +1054,13 @@ const operationsByTag$2 = {
|
|
992
1054
|
|
993
1055
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
994
1056
|
|
1057
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
1058
|
+
const generateAccessToken = (variables, signal) => controlPlaneFetch({
|
1059
|
+
url: "/oauth/token",
|
1060
|
+
method: "post",
|
1061
|
+
...variables,
|
1062
|
+
signal
|
1063
|
+
});
|
995
1064
|
const getUser = (variables, signal) => controlPlaneFetch({
|
996
1065
|
url: "/user",
|
997
1066
|
method: "get",
|
@@ -1097,6 +1166,7 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1097
1166
|
signal
|
1098
1167
|
});
|
1099
1168
|
const operationsByTag$1 = {
|
1169
|
+
authOther: { grantAuthorizationCode, generateAccessToken },
|
1100
1170
|
users: { getUser, updateUser, deleteUser },
|
1101
1171
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1102
1172
|
workspaces: {
|
@@ -2109,6 +2179,21 @@ class SearchAndFilterApi {
|
|
2109
2179
|
...this.extraProps
|
2110
2180
|
});
|
2111
2181
|
}
|
2182
|
+
askTableSession({
|
2183
|
+
workspace,
|
2184
|
+
region,
|
2185
|
+
database,
|
2186
|
+
branch,
|
2187
|
+
table,
|
2188
|
+
sessionId,
|
2189
|
+
message
|
2190
|
+
}) {
|
2191
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2192
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2193
|
+
body: { message },
|
2194
|
+
...this.extraProps
|
2195
|
+
});
|
2196
|
+
}
|
2112
2197
|
summarizeTable({
|
2113
2198
|
workspace,
|
2114
2199
|
region,
|
@@ -2400,11 +2485,13 @@ class DatabaseApi {
|
|
2400
2485
|
createDatabase({
|
2401
2486
|
workspace,
|
2402
2487
|
database,
|
2403
|
-
data
|
2488
|
+
data,
|
2489
|
+
headers
|
2404
2490
|
}) {
|
2405
2491
|
return operationsByTag.databases.createDatabase({
|
2406
2492
|
pathParams: { workspaceId: workspace, dbName: database },
|
2407
2493
|
body: data,
|
2494
|
+
headers,
|
2408
2495
|
...this.extraProps
|
2409
2496
|
});
|
2410
2497
|
}
|
@@ -2494,13 +2581,261 @@ class XataApiPlugin {
|
|
2494
2581
|
class XataPlugin {
|
2495
2582
|
}
|
2496
2583
|
|
2584
|
+
class FilesPlugin extends XataPlugin {
|
2585
|
+
build(pluginOptions) {
|
2586
|
+
return {
|
2587
|
+
download: async (location) => {
|
2588
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2589
|
+
return await getFileItem({
|
2590
|
+
pathParams: {
|
2591
|
+
workspace: "{workspaceId}",
|
2592
|
+
dbBranchName: "{dbBranch}",
|
2593
|
+
region: "{region}",
|
2594
|
+
tableName: table ?? "",
|
2595
|
+
recordId: record ?? "",
|
2596
|
+
columnName: column ?? "",
|
2597
|
+
fileId
|
2598
|
+
},
|
2599
|
+
...pluginOptions,
|
2600
|
+
rawResponse: true
|
2601
|
+
});
|
2602
|
+
},
|
2603
|
+
upload: async (location, file) => {
|
2604
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2605
|
+
return await putFileItem({
|
2606
|
+
pathParams: {
|
2607
|
+
workspace: "{workspaceId}",
|
2608
|
+
dbBranchName: "{dbBranch}",
|
2609
|
+
region: "{region}",
|
2610
|
+
tableName: table ?? "",
|
2611
|
+
recordId: record ?? "",
|
2612
|
+
columnName: column ?? "",
|
2613
|
+
fileId
|
2614
|
+
},
|
2615
|
+
body: file,
|
2616
|
+
...pluginOptions
|
2617
|
+
});
|
2618
|
+
},
|
2619
|
+
delete: async (location) => {
|
2620
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2621
|
+
return await deleteFileItem({
|
2622
|
+
pathParams: {
|
2623
|
+
workspace: "{workspaceId}",
|
2624
|
+
dbBranchName: "{dbBranch}",
|
2625
|
+
region: "{region}",
|
2626
|
+
tableName: table ?? "",
|
2627
|
+
recordId: record ?? "",
|
2628
|
+
columnName: column ?? "",
|
2629
|
+
fileId
|
2630
|
+
},
|
2631
|
+
...pluginOptions
|
2632
|
+
});
|
2633
|
+
}
|
2634
|
+
};
|
2635
|
+
}
|
2636
|
+
}
|
2637
|
+
|
2638
|
+
function buildTransformString(transformations) {
|
2639
|
+
return transformations.flatMap(
|
2640
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2641
|
+
if (key === "trim") {
|
2642
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2643
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2644
|
+
}
|
2645
|
+
if (key === "gravity" && typeof value === "object") {
|
2646
|
+
const { x = 0.5, y = 0.5 } = value;
|
2647
|
+
return `${key}=${[x, y].join("x")}`;
|
2648
|
+
}
|
2649
|
+
return `${key}=${value}`;
|
2650
|
+
})
|
2651
|
+
).join(",");
|
2652
|
+
}
|
2653
|
+
function transformImage(url, transformations) {
|
2654
|
+
if (!isDefined(url))
|
2655
|
+
return void 0;
|
2656
|
+
const transformationsString = buildTransformString(transformations);
|
2657
|
+
const { hostname, pathname, search } = new URL(url);
|
2658
|
+
return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
|
2659
|
+
}
|
2660
|
+
|
2661
|
+
var __defProp$6 = Object.defineProperty;
|
2662
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2663
|
+
var __publicField$6 = (obj, key, value) => {
|
2664
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2665
|
+
return value;
|
2666
|
+
};
|
2667
|
+
class XataFile {
|
2668
|
+
constructor(file) {
|
2669
|
+
/**
|
2670
|
+
* Name of this file.
|
2671
|
+
*/
|
2672
|
+
__publicField$6(this, "name");
|
2673
|
+
/**
|
2674
|
+
* Media type of this file.
|
2675
|
+
*/
|
2676
|
+
__publicField$6(this, "mediaType");
|
2677
|
+
/**
|
2678
|
+
* Base64 encoded content of this file.
|
2679
|
+
*/
|
2680
|
+
__publicField$6(this, "base64Content");
|
2681
|
+
/**
|
2682
|
+
* Whether to enable public url for this file.
|
2683
|
+
*/
|
2684
|
+
__publicField$6(this, "enablePublicUrl");
|
2685
|
+
/**
|
2686
|
+
* Timeout for the signed url.
|
2687
|
+
*/
|
2688
|
+
__publicField$6(this, "signedUrlTimeout");
|
2689
|
+
/**
|
2690
|
+
* Size of this file.
|
2691
|
+
*/
|
2692
|
+
__publicField$6(this, "size");
|
2693
|
+
/**
|
2694
|
+
* Version of this file.
|
2695
|
+
*/
|
2696
|
+
__publicField$6(this, "version");
|
2697
|
+
/**
|
2698
|
+
* Url of this file.
|
2699
|
+
*/
|
2700
|
+
__publicField$6(this, "url");
|
2701
|
+
/**
|
2702
|
+
* Signed url of this file.
|
2703
|
+
*/
|
2704
|
+
__publicField$6(this, "signedUrl");
|
2705
|
+
/**
|
2706
|
+
* Attributes of this file.
|
2707
|
+
*/
|
2708
|
+
__publicField$6(this, "attributes");
|
2709
|
+
this.name = file.name;
|
2710
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
2711
|
+
this.base64Content = file.base64Content;
|
2712
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2713
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2714
|
+
this.size = file.size;
|
2715
|
+
this.version = file.version;
|
2716
|
+
this.url = file.url;
|
2717
|
+
this.signedUrl = file.signedUrl;
|
2718
|
+
this.attributes = file.attributes;
|
2719
|
+
}
|
2720
|
+
static fromBuffer(buffer, options = {}) {
|
2721
|
+
const base64Content = buffer.toString("base64");
|
2722
|
+
return new XataFile({ ...options, base64Content });
|
2723
|
+
}
|
2724
|
+
toBuffer() {
|
2725
|
+
if (!this.base64Content) {
|
2726
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2727
|
+
}
|
2728
|
+
return Buffer.from(this.base64Content, "base64");
|
2729
|
+
}
|
2730
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2731
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2732
|
+
return this.fromUint8Array(uint8Array, options);
|
2733
|
+
}
|
2734
|
+
toArrayBuffer() {
|
2735
|
+
if (!this.base64Content) {
|
2736
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2737
|
+
}
|
2738
|
+
const binary = atob(this.base64Content);
|
2739
|
+
return new ArrayBuffer(binary.length);
|
2740
|
+
}
|
2741
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2742
|
+
let binary = "";
|
2743
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2744
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2745
|
+
}
|
2746
|
+
const base64Content = btoa(binary);
|
2747
|
+
return new XataFile({ ...options, base64Content });
|
2748
|
+
}
|
2749
|
+
toUint8Array() {
|
2750
|
+
if (!this.base64Content) {
|
2751
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2752
|
+
}
|
2753
|
+
const binary = atob(this.base64Content);
|
2754
|
+
const uint8Array = new Uint8Array(binary.length);
|
2755
|
+
for (let i = 0; i < binary.length; i++) {
|
2756
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2757
|
+
}
|
2758
|
+
return uint8Array;
|
2759
|
+
}
|
2760
|
+
static async fromBlob(file, options = {}) {
|
2761
|
+
const name = options.name ?? file.name;
|
2762
|
+
const mediaType = file.type;
|
2763
|
+
const arrayBuffer = await file.arrayBuffer();
|
2764
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2765
|
+
}
|
2766
|
+
toBlob() {
|
2767
|
+
if (!this.base64Content) {
|
2768
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2769
|
+
}
|
2770
|
+
const arrayBuffer = this.toArrayBuffer();
|
2771
|
+
return new Blob([arrayBuffer], { type: this.mediaType });
|
2772
|
+
}
|
2773
|
+
static fromString(string, options = {}) {
|
2774
|
+
const base64Content = btoa(string);
|
2775
|
+
return new XataFile({ ...options, base64Content });
|
2776
|
+
}
|
2777
|
+
toString() {
|
2778
|
+
if (!this.base64Content) {
|
2779
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2780
|
+
}
|
2781
|
+
return atob(this.base64Content);
|
2782
|
+
}
|
2783
|
+
static fromBase64(base64Content, options = {}) {
|
2784
|
+
return new XataFile({ ...options, base64Content });
|
2785
|
+
}
|
2786
|
+
toBase64() {
|
2787
|
+
if (!this.base64Content) {
|
2788
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2789
|
+
}
|
2790
|
+
return this.base64Content;
|
2791
|
+
}
|
2792
|
+
transform(...options) {
|
2793
|
+
return {
|
2794
|
+
url: transformImage(this.url, options),
|
2795
|
+
signedUrl: transformImage(this.signedUrl, options)
|
2796
|
+
};
|
2797
|
+
}
|
2798
|
+
}
|
2799
|
+
const parseInputFileEntry = async (entry) => {
|
2800
|
+
if (!isDefined(entry))
|
2801
|
+
return null;
|
2802
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2803
|
+
return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
|
2804
|
+
};
|
2805
|
+
|
2497
2806
|
function cleanFilter(filter) {
|
2498
|
-
if (!filter)
|
2807
|
+
if (!isDefined(filter))
|
2499
2808
|
return void 0;
|
2500
|
-
|
2501
|
-
|
2809
|
+
if (!isObject(filter))
|
2810
|
+
return filter;
|
2811
|
+
const values = Object.fromEntries(
|
2812
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2813
|
+
if (!isDefined(value))
|
2814
|
+
return acc;
|
2815
|
+
if (Array.isArray(value)) {
|
2816
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2817
|
+
if (clean.length === 0)
|
2818
|
+
return acc;
|
2819
|
+
return [...acc, [key, clean]];
|
2820
|
+
}
|
2821
|
+
if (isObject(value)) {
|
2822
|
+
const clean = cleanFilter(value);
|
2823
|
+
if (!isDefined(clean))
|
2824
|
+
return acc;
|
2825
|
+
return [...acc, [key, clean]];
|
2826
|
+
}
|
2827
|
+
return [...acc, [key, value]];
|
2828
|
+
}, [])
|
2829
|
+
);
|
2830
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2502
2831
|
}
|
2503
2832
|
|
2833
|
+
var __defProp$5 = Object.defineProperty;
|
2834
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2835
|
+
var __publicField$5 = (obj, key, value) => {
|
2836
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2837
|
+
return value;
|
2838
|
+
};
|
2504
2839
|
var __accessCheck$6 = (obj, member, msg) => {
|
2505
2840
|
if (!member.has(obj))
|
2506
2841
|
throw TypeError("Cannot " + msg);
|
@@ -2523,6 +2858,14 @@ var _query, _page;
|
|
2523
2858
|
class Page {
|
2524
2859
|
constructor(query, meta, records = []) {
|
2525
2860
|
__privateAdd$6(this, _query, void 0);
|
2861
|
+
/**
|
2862
|
+
* Page metadata, required to retrieve additional records.
|
2863
|
+
*/
|
2864
|
+
__publicField$5(this, "meta");
|
2865
|
+
/**
|
2866
|
+
* The set of results for this page.
|
2867
|
+
*/
|
2868
|
+
__publicField$5(this, "records");
|
2526
2869
|
__privateSet$6(this, _query, query);
|
2527
2870
|
this.meta = meta;
|
2528
2871
|
this.records = new RecordArray(this, records);
|
@@ -2579,7 +2922,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2579
2922
|
function isCursorPaginationOptions(options) {
|
2580
2923
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2581
2924
|
}
|
2582
|
-
const _RecordArray = class extends Array {
|
2925
|
+
const _RecordArray = class _RecordArray extends Array {
|
2583
2926
|
constructor(...args) {
|
2584
2927
|
super(..._RecordArray.parseConstructorParams(...args));
|
2585
2928
|
__privateAdd$6(this, _page, void 0);
|
@@ -2650,9 +2993,15 @@ const _RecordArray = class extends Array {
|
|
2650
2993
|
return __privateGet$6(this, _page).meta.page.more;
|
2651
2994
|
}
|
2652
2995
|
};
|
2653
|
-
let RecordArray = _RecordArray;
|
2654
2996
|
_page = new WeakMap();
|
2997
|
+
let RecordArray = _RecordArray;
|
2655
2998
|
|
2999
|
+
var __defProp$4 = Object.defineProperty;
|
3000
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3001
|
+
var __publicField$4 = (obj, key, value) => {
|
3002
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3003
|
+
return value;
|
3004
|
+
};
|
2656
3005
|
var __accessCheck$5 = (obj, member, msg) => {
|
2657
3006
|
if (!member.has(obj))
|
2658
3007
|
throw TypeError("Cannot " + msg);
|
@@ -2676,15 +3025,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2676
3025
|
return method;
|
2677
3026
|
};
|
2678
3027
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2679
|
-
const _Query = class {
|
3028
|
+
const _Query = class _Query {
|
2680
3029
|
constructor(repository, table, data, rawParent) {
|
2681
3030
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2682
3031
|
__privateAdd$5(this, _table$1, void 0);
|
2683
3032
|
__privateAdd$5(this, _repository, void 0);
|
2684
3033
|
__privateAdd$5(this, _data, { filter: {} });
|
2685
3034
|
// Implements pagination
|
2686
|
-
this
|
2687
|
-
this
|
3035
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
3036
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2688
3037
|
__privateSet$5(this, _table$1, table);
|
2689
3038
|
if (repository) {
|
2690
3039
|
__privateSet$5(this, _repository, repository);
|
@@ -2904,7 +3253,6 @@ const _Query = class {
|
|
2904
3253
|
return this.meta.page.more;
|
2905
3254
|
}
|
2906
3255
|
};
|
2907
|
-
let Query = _Query;
|
2908
3256
|
_table$1 = new WeakMap();
|
2909
3257
|
_repository = new WeakMap();
|
2910
3258
|
_data = new WeakMap();
|
@@ -2919,6 +3267,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2919
3267
|
}
|
2920
3268
|
return value;
|
2921
3269
|
};
|
3270
|
+
let Query = _Query;
|
2922
3271
|
function cleanParent(data, parent) {
|
2923
3272
|
if (isCursorPaginationOptions(data.pagination)) {
|
2924
3273
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2926,6 +3275,21 @@ function cleanParent(data, parent) {
|
|
2926
3275
|
return parent;
|
2927
3276
|
}
|
2928
3277
|
|
3278
|
+
const RecordColumnTypes = [
|
3279
|
+
"bool",
|
3280
|
+
"int",
|
3281
|
+
"float",
|
3282
|
+
"string",
|
3283
|
+
"text",
|
3284
|
+
"email",
|
3285
|
+
"multiple",
|
3286
|
+
"link",
|
3287
|
+
"object",
|
3288
|
+
"datetime",
|
3289
|
+
"vector",
|
3290
|
+
"file[]",
|
3291
|
+
"file"
|
3292
|
+
];
|
2929
3293
|
function isIdentifiable(x) {
|
2930
3294
|
return isObject(x) && isString(x?.id);
|
2931
3295
|
}
|
@@ -2984,7 +3348,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2984
3348
|
__accessCheck$4(obj, member, "access private method");
|
2985
3349
|
return method;
|
2986
3350
|
};
|
2987
|
-
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
3351
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _trace, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _insertRecords, insertRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _updateRecords, updateRecords_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _deleteRecords, deleteRecords_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1, _transformObjectToApi, transformObjectToApi_fn;
|
2988
3352
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2989
3353
|
class Repository extends Query {
|
2990
3354
|
}
|
@@ -3006,6 +3370,7 @@ class RestRepository extends Query {
|
|
3006
3370
|
__privateAdd$4(this, _setCacheQuery);
|
3007
3371
|
__privateAdd$4(this, _getCacheQuery);
|
3008
3372
|
__privateAdd$4(this, _getSchemaTables$1);
|
3373
|
+
__privateAdd$4(this, _transformObjectToApi);
|
3009
3374
|
__privateAdd$4(this, _table, void 0);
|
3010
3375
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3011
3376
|
__privateAdd$4(this, _db, void 0);
|
@@ -3397,23 +3762,28 @@ class RestRepository extends Query {
|
|
3397
3762
|
});
|
3398
3763
|
}
|
3399
3764
|
ask(question, options) {
|
3765
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3400
3766
|
const params = {
|
3401
3767
|
pathParams: {
|
3402
3768
|
workspace: "{workspaceId}",
|
3403
3769
|
dbBranchName: "{dbBranch}",
|
3404
3770
|
region: "{region}",
|
3405
|
-
tableName: __privateGet$4(this, _table)
|
3771
|
+
tableName: __privateGet$4(this, _table),
|
3772
|
+
sessionId: options?.sessionId
|
3406
3773
|
},
|
3407
3774
|
body: {
|
3408
|
-
|
3409
|
-
|
3775
|
+
...questionParam,
|
3776
|
+
rules: options?.rules,
|
3777
|
+
searchType: options?.searchType,
|
3778
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3779
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3410
3780
|
},
|
3411
3781
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3412
3782
|
};
|
3413
3783
|
if (options?.onMessage) {
|
3414
3784
|
fetchSSERequest({
|
3415
3785
|
endpoint: "dataPlane",
|
3416
|
-
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3786
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3417
3787
|
method: "POST",
|
3418
3788
|
onMessage: (message) => {
|
3419
3789
|
options.onMessage?.({ answer: message.text, records: message.records });
|
@@ -3421,7 +3791,7 @@ class RestRepository extends Query {
|
|
3421
3791
|
...params
|
3422
3792
|
});
|
3423
3793
|
} else {
|
3424
|
-
return
|
3794
|
+
return askTableSession(params);
|
3425
3795
|
}
|
3426
3796
|
}
|
3427
3797
|
}
|
@@ -3433,7 +3803,7 @@ _schemaTables$2 = new WeakMap();
|
|
3433
3803
|
_trace = new WeakMap();
|
3434
3804
|
_insertRecordWithoutId = new WeakSet();
|
3435
3805
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
3436
|
-
const record =
|
3806
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3437
3807
|
const response = await insertRecord({
|
3438
3808
|
pathParams: {
|
3439
3809
|
workspace: "{workspaceId}",
|
@@ -3452,7 +3822,7 @@ _insertRecordWithId = new WeakSet();
|
|
3452
3822
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
3453
3823
|
if (!recordId)
|
3454
3824
|
return null;
|
3455
|
-
const record =
|
3825
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3456
3826
|
const response = await insertRecordWithID({
|
3457
3827
|
pathParams: {
|
3458
3828
|
workspace: "{workspaceId}",
|
@@ -3470,21 +3840,20 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3470
3840
|
};
|
3471
3841
|
_insertRecords = new WeakSet();
|
3472
3842
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3473
|
-
const
|
3474
|
-
|
3475
|
-
|
3476
|
-
|
3477
|
-
|
3478
|
-
);
|
3843
|
+
const operations = await promiseMap(objects, async (object) => {
|
3844
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3845
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3846
|
+
});
|
3847
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3479
3848
|
const ids = [];
|
3480
|
-
for (const
|
3849
|
+
for (const operations2 of chunkedOperations) {
|
3481
3850
|
const { results } = await branchTransaction({
|
3482
3851
|
pathParams: {
|
3483
3852
|
workspace: "{workspaceId}",
|
3484
3853
|
dbBranchName: "{dbBranch}",
|
3485
3854
|
region: "{region}"
|
3486
3855
|
},
|
3487
|
-
body: { operations },
|
3856
|
+
body: { operations: operations2 },
|
3488
3857
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3489
3858
|
});
|
3490
3859
|
for (const result of results) {
|
@@ -3501,7 +3870,7 @@ _updateRecordWithID = new WeakSet();
|
|
3501
3870
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3502
3871
|
if (!recordId)
|
3503
3872
|
return null;
|
3504
|
-
const { id: _id, ...record } =
|
3873
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3505
3874
|
try {
|
3506
3875
|
const response = await updateRecordWithID({
|
3507
3876
|
pathParams: {
|
@@ -3526,21 +3895,20 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3526
3895
|
};
|
3527
3896
|
_updateRecords = new WeakSet();
|
3528
3897
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3529
|
-
const
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3533
|
-
|
3534
|
-
);
|
3898
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3899
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3900
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3901
|
+
});
|
3902
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3535
3903
|
const ids = [];
|
3536
|
-
for (const
|
3904
|
+
for (const operations2 of chunkedOperations) {
|
3537
3905
|
const { results } = await branchTransaction({
|
3538
3906
|
pathParams: {
|
3539
3907
|
workspace: "{workspaceId}",
|
3540
3908
|
dbBranchName: "{dbBranch}",
|
3541
3909
|
region: "{region}"
|
3542
3910
|
},
|
3543
|
-
body: { operations },
|
3911
|
+
body: { operations: operations2 },
|
3544
3912
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3545
3913
|
});
|
3546
3914
|
for (const result of results) {
|
@@ -3643,7 +4011,39 @@ getSchemaTables_fn$1 = async function() {
|
|
3643
4011
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
3644
4012
|
return schema.tables;
|
3645
4013
|
};
|
3646
|
-
|
4014
|
+
_transformObjectToApi = new WeakSet();
|
4015
|
+
transformObjectToApi_fn = async function(object) {
|
4016
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4017
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4018
|
+
if (!schema)
|
4019
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4020
|
+
const result = {};
|
4021
|
+
for (const [key, value] of Object.entries(object)) {
|
4022
|
+
if (key === "xata")
|
4023
|
+
continue;
|
4024
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4025
|
+
switch (type) {
|
4026
|
+
case "link": {
|
4027
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4028
|
+
break;
|
4029
|
+
}
|
4030
|
+
case "datetime": {
|
4031
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4032
|
+
break;
|
4033
|
+
}
|
4034
|
+
case `file`:
|
4035
|
+
result[key] = await parseInputFileEntry(value);
|
4036
|
+
break;
|
4037
|
+
case "file[]":
|
4038
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4039
|
+
break;
|
4040
|
+
default:
|
4041
|
+
result[key] = value;
|
4042
|
+
}
|
4043
|
+
}
|
4044
|
+
return result;
|
4045
|
+
};
|
4046
|
+
const removeLinksFromObject = (object) => {
|
3647
4047
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
3648
4048
|
if (key === "xata")
|
3649
4049
|
return acc;
|
@@ -3692,6 +4092,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3692
4092
|
}
|
3693
4093
|
break;
|
3694
4094
|
}
|
4095
|
+
case "file":
|
4096
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4097
|
+
break;
|
4098
|
+
case "file[]":
|
4099
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4100
|
+
break;
|
3695
4101
|
default:
|
3696
4102
|
data[column.name] = value ?? null;
|
3697
4103
|
if (column.notNull === true && value === null) {
|
@@ -3701,7 +4107,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3701
4107
|
}
|
3702
4108
|
}
|
3703
4109
|
const record = { ...data };
|
3704
|
-
const serializable = { xata, ...
|
4110
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
3705
4111
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3706
4112
|
record.read = function(columns2) {
|
3707
4113
|
return db[table].read(record["id"], columns2);
|
@@ -3727,7 +4133,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3727
4133
|
return JSON.parse(JSON.stringify(serializable));
|
3728
4134
|
};
|
3729
4135
|
record.toString = function() {
|
3730
|
-
return JSON.stringify(
|
4136
|
+
return JSON.stringify(serializable);
|
3731
4137
|
};
|
3732
4138
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3733
4139
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -3745,11 +4151,7 @@ function extractId(value) {
|
|
3745
4151
|
function isValidColumn(columns, column) {
|
3746
4152
|
if (columns.includes("*"))
|
3747
4153
|
return true;
|
3748
|
-
|
3749
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3750
|
-
return linkColumns.length > 0;
|
3751
|
-
}
|
3752
|
-
return columns.includes(column.name);
|
4154
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
3753
4155
|
}
|
3754
4156
|
function parseIfVersion(...args) {
|
3755
4157
|
for (const arg of args) {
|
@@ -3760,6 +4162,12 @@ function parseIfVersion(...args) {
|
|
3760
4162
|
return void 0;
|
3761
4163
|
}
|
3762
4164
|
|
4165
|
+
var __defProp$3 = Object.defineProperty;
|
4166
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4167
|
+
var __publicField$3 = (obj, key, value) => {
|
4168
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4169
|
+
return value;
|
4170
|
+
};
|
3763
4171
|
var __accessCheck$3 = (obj, member, msg) => {
|
3764
4172
|
if (!member.has(obj))
|
3765
4173
|
throw TypeError("Cannot " + msg);
|
@@ -3782,6 +4190,8 @@ var _map;
|
|
3782
4190
|
class SimpleCache {
|
3783
4191
|
constructor(options = {}) {
|
3784
4192
|
__privateAdd$3(this, _map, void 0);
|
4193
|
+
__publicField$3(this, "capacity");
|
4194
|
+
__publicField$3(this, "defaultQueryTTL");
|
3785
4195
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
3786
4196
|
this.capacity = options.max ?? 500;
|
3787
4197
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3979,6 +4389,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3979
4389
|
}
|
3980
4390
|
}
|
3981
4391
|
|
4392
|
+
var __defProp$2 = Object.defineProperty;
|
4393
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4394
|
+
var __publicField$2 = (obj, key, value) => {
|
4395
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4396
|
+
return value;
|
4397
|
+
};
|
3982
4398
|
var __accessCheck = (obj, member, msg) => {
|
3983
4399
|
if (!member.has(obj))
|
3984
4400
|
throw TypeError("Cannot " + msg);
|
@@ -4008,6 +4424,10 @@ const buildClient = (plugins) => {
|
|
4008
4424
|
__privateAdd(this, _parseOptions);
|
4009
4425
|
__privateAdd(this, _getFetchProps);
|
4010
4426
|
__privateAdd(this, _options, void 0);
|
4427
|
+
__publicField$2(this, "db");
|
4428
|
+
__publicField$2(this, "search");
|
4429
|
+
__publicField$2(this, "transactions");
|
4430
|
+
__publicField$2(this, "files");
|
4011
4431
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4012
4432
|
__privateSet(this, _options, safeOptions);
|
4013
4433
|
const pluginOptions = {
|
@@ -4018,9 +4438,11 @@ const buildClient = (plugins) => {
|
|
4018
4438
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4019
4439
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4020
4440
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4441
|
+
const files = new FilesPlugin().build(pluginOptions);
|
4021
4442
|
this.db = db;
|
4022
4443
|
this.search = search;
|
4023
4444
|
this.transactions = transactions;
|
4445
|
+
this.files = files;
|
4024
4446
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4025
4447
|
if (namespace === void 0)
|
4026
4448
|
continue;
|
@@ -4117,11 +4539,17 @@ const buildClient = (plugins) => {
|
|
4117
4539
|
class BaseClient extends buildClient() {
|
4118
4540
|
}
|
4119
4541
|
|
4542
|
+
var __defProp$1 = Object.defineProperty;
|
4543
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4544
|
+
var __publicField$1 = (obj, key, value) => {
|
4545
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4546
|
+
return value;
|
4547
|
+
};
|
4120
4548
|
const META = "__";
|
4121
4549
|
const VALUE = "___";
|
4122
4550
|
class Serializer {
|
4123
4551
|
constructor() {
|
4124
|
-
this
|
4552
|
+
__publicField$1(this, "classes", {});
|
4125
4553
|
}
|
4126
4554
|
add(clazz) {
|
4127
4555
|
this.classes[clazz.name] = clazz;
|
@@ -4199,12 +4627,19 @@ function buildWorkerRunner(config) {
|
|
4199
4627
|
};
|
4200
4628
|
}
|
4201
4629
|
|
4630
|
+
var __defProp = Object.defineProperty;
|
4631
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4632
|
+
var __publicField = (obj, key, value) => {
|
4633
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4634
|
+
return value;
|
4635
|
+
};
|
4202
4636
|
class XataError extends Error {
|
4203
4637
|
constructor(message, status) {
|
4204
4638
|
super(message);
|
4639
|
+
__publicField(this, "status");
|
4205
4640
|
this.status = status;
|
4206
4641
|
}
|
4207
4642
|
}
|
4208
4643
|
|
4209
|
-
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4644
|
+
export { BaseClient, FetcherError, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, RecordColumnTypes, Repository, RestRepository, SchemaPlugin, SearchPlugin, Serializer, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataFile, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, askTableSession, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, compareBranchSchemas, compareBranchWithUserSchema, compareMigrationRequest, contains, copyBranch, createBranch, createDatabase, createMigrationRequest, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteDatabaseGithubSettings, deleteFile, deleteFileItem, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, deserialize, endsWith, equals, executeBranchMigrationPlan, exists, fileAccess, ge, generateAccessToken, getAPIKey, getBranch, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchSchemaHistory, getBranchStats, getColumn, getDatabaseGithubSettings, getDatabaseList, getDatabaseMetadata, getDatabaseURL, getFile, getFileItem, getGitBranchesMapping, getHostUrl, getMigrationRequest, getMigrationRequestIsMerged, getPreviewBranch, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, grantAuthorizationCode, greaterEquals, greaterThan, greaterThanEquals, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isHostProviderAlias, isHostProviderBuilder, isIdentifiable, isNot, isXataRecord, le, lessEquals, lessThan, lessThanEquals, listMigrationRequestsCommits, listRegions, lt, lte, mergeMigrationRequest, notExists, operationsByTag, parseProviderString, parseWorkspacesUrlParts, pattern, previewBranchSchemaEdit, pushBranchMigrations, putFile, putFileItem, queryMigrationRequests, queryTable, removeGitBranchesEntry, removeWorkspaceMember, renameDatabase, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, serialize, setTableSchema, sqlQuery, startsWith, summarizeTable, updateBranchMetadata, updateBranchSchema, updateColumn, updateDatabaseGithubSettings, updateDatabaseMetadata, updateMigrationRequest, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberInvite, updateWorkspaceMemberRole, upsertRecordWithID, vectorSearchTable };
|
4210
4645
|
//# sourceMappingURL=index.mjs.map
|