@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.cjs
CHANGED
@@ -29,8 +29,11 @@ function notEmpty(value) {
|
|
29
29
|
function compact(arr) {
|
30
30
|
return arr.filter(notEmpty);
|
31
31
|
}
|
32
|
+
function compactObject(obj) {
|
33
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
34
|
+
}
|
32
35
|
function isObject(value) {
|
33
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
36
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
34
37
|
}
|
35
38
|
function isDefined(value) {
|
36
39
|
return value !== null && value !== void 0;
|
@@ -85,6 +88,27 @@ function chunk(array, chunkSize) {
|
|
85
88
|
async function timeout(ms) {
|
86
89
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
87
90
|
}
|
91
|
+
function timeoutWithCancel(ms) {
|
92
|
+
let timeoutId;
|
93
|
+
const promise = new Promise((resolve) => {
|
94
|
+
timeoutId = setTimeout(() => {
|
95
|
+
resolve();
|
96
|
+
}, ms);
|
97
|
+
});
|
98
|
+
return {
|
99
|
+
cancel: () => clearTimeout(timeoutId),
|
100
|
+
promise
|
101
|
+
};
|
102
|
+
}
|
103
|
+
function promiseMap(inputValues, mapper) {
|
104
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
105
|
+
(acc) => mapper(inputValue).then((result) => {
|
106
|
+
acc.push(result);
|
107
|
+
return acc;
|
108
|
+
})
|
109
|
+
);
|
110
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
111
|
+
}
|
88
112
|
|
89
113
|
function getEnvironment() {
|
90
114
|
try {
|
@@ -212,6 +236,12 @@ function getPreviewBranch() {
|
|
212
236
|
}
|
213
237
|
}
|
214
238
|
|
239
|
+
var __defProp$8 = Object.defineProperty;
|
240
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
241
|
+
var __publicField$8 = (obj, key, value) => {
|
242
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
243
|
+
return value;
|
244
|
+
};
|
215
245
|
var __accessCheck$8 = (obj, member, msg) => {
|
216
246
|
if (!member.has(obj))
|
217
247
|
throw TypeError("Cannot " + msg);
|
@@ -235,6 +265,7 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
235
265
|
return method;
|
236
266
|
};
|
237
267
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
268
|
+
const REQUEST_TIMEOUT = 3e4;
|
238
269
|
function getFetchImplementation(userFetch) {
|
239
270
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
240
271
|
const fetchImpl = userFetch ?? globalFetch;
|
@@ -251,6 +282,8 @@ class ApiRequestPool {
|
|
251
282
|
__privateAdd$8(this, _fetch, void 0);
|
252
283
|
__privateAdd$8(this, _queue, void 0);
|
253
284
|
__privateAdd$8(this, _concurrency, void 0);
|
285
|
+
__publicField$8(this, "running");
|
286
|
+
__publicField$8(this, "started");
|
254
287
|
__privateSet$8(this, _queue, []);
|
255
288
|
__privateSet$8(this, _concurrency, concurrency);
|
256
289
|
this.running = 0;
|
@@ -267,9 +300,13 @@ class ApiRequestPool {
|
|
267
300
|
}
|
268
301
|
request(url, options) {
|
269
302
|
const start = /* @__PURE__ */ new Date();
|
270
|
-
const
|
303
|
+
const fetchImpl = this.getFetch();
|
271
304
|
const runRequest = async (stalled = false) => {
|
272
|
-
const
|
305
|
+
const { promise, cancel } = timeoutWithCancel(REQUEST_TIMEOUT);
|
306
|
+
const response = await Promise.race([fetchImpl(url, options), promise.then(() => null)]).finally(cancel);
|
307
|
+
if (!response) {
|
308
|
+
throw new Error("Request timed out");
|
309
|
+
}
|
273
310
|
if (response.status === 429) {
|
274
311
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
275
312
|
await timeout(rateLimitReset * 1e3);
|
@@ -492,16 +529,26 @@ function defaultOnOpen(response) {
|
|
492
529
|
}
|
493
530
|
}
|
494
531
|
|
495
|
-
const VERSION = "0.
|
532
|
+
const VERSION = "0.25.1";
|
496
533
|
|
534
|
+
var __defProp$7 = Object.defineProperty;
|
535
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
536
|
+
var __publicField$7 = (obj, key, value) => {
|
537
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
538
|
+
return value;
|
539
|
+
};
|
497
540
|
class ErrorWithCause extends Error {
|
498
541
|
constructor(message, options) {
|
499
542
|
super(message, options);
|
543
|
+
__publicField$7(this, "cause");
|
500
544
|
}
|
501
545
|
}
|
502
546
|
class FetcherError extends ErrorWithCause {
|
503
547
|
constructor(status, data, requestId) {
|
504
548
|
super(getMessage(data));
|
549
|
+
__publicField$7(this, "status");
|
550
|
+
__publicField$7(this, "requestId");
|
551
|
+
__publicField$7(this, "errors");
|
505
552
|
this.status = status;
|
506
553
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
507
554
|
this.requestId = requestId;
|
@@ -568,6 +615,15 @@ function hostHeader(url) {
|
|
568
615
|
const { groups } = pattern.exec(url) ?? {};
|
569
616
|
return groups?.host ? { Host: groups.host } : {};
|
570
617
|
}
|
618
|
+
function parseBody(body, headers) {
|
619
|
+
if (!isDefined(body))
|
620
|
+
return void 0;
|
621
|
+
const { "Content-Type": contentType } = headers ?? {};
|
622
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
623
|
+
return JSON.stringify(body);
|
624
|
+
}
|
625
|
+
return body;
|
626
|
+
}
|
571
627
|
const defaultClientID = generateUUID();
|
572
628
|
async function fetch$1({
|
573
629
|
url: path,
|
@@ -587,7 +643,8 @@ async function fetch$1({
|
|
587
643
|
sessionID,
|
588
644
|
clientName,
|
589
645
|
xataAgentExtra,
|
590
|
-
fetchOptions = {}
|
646
|
+
fetchOptions = {},
|
647
|
+
rawResponse = false
|
591
648
|
}) {
|
592
649
|
pool.setFetch(fetch2);
|
593
650
|
return await trace(
|
@@ -606,7 +663,7 @@ async function fetch$1({
|
|
606
663
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
607
664
|
...Object.entries(xataAgentExtra ?? {})
|
608
665
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
609
|
-
const headers = {
|
666
|
+
const headers = compactObject({
|
610
667
|
"Accept-Encoding": "identity",
|
611
668
|
"Content-Type": "application/json",
|
612
669
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -615,11 +672,11 @@ async function fetch$1({
|
|
615
672
|
...customHeaders,
|
616
673
|
...hostHeader(fullUrl),
|
617
674
|
Authorization: `Bearer ${apiKey}`
|
618
|
-
};
|
675
|
+
});
|
619
676
|
const response = await pool.request(url, {
|
620
677
|
...fetchOptions,
|
621
678
|
method: method.toUpperCase(),
|
622
|
-
body: body
|
679
|
+
body: parseBody(body, headers),
|
623
680
|
headers,
|
624
681
|
signal
|
625
682
|
});
|
@@ -632,6 +689,9 @@ async function fetch$1({
|
|
632
689
|
[TraceAttributes.HTTP_HOST]: host,
|
633
690
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
634
691
|
});
|
692
|
+
const message = response.headers?.get("x-xata-message");
|
693
|
+
if (message)
|
694
|
+
console.warn(message);
|
635
695
|
if (response.status === 204) {
|
636
696
|
return {};
|
637
697
|
}
|
@@ -639,7 +699,7 @@ async function fetch$1({
|
|
639
699
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
640
700
|
}
|
641
701
|
try {
|
642
|
-
const jsonResponse = await response.json();
|
702
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
643
703
|
if (response.ok) {
|
644
704
|
return jsonResponse;
|
645
705
|
}
|
@@ -912,6 +972,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
912
972
|
...variables,
|
913
973
|
signal
|
914
974
|
});
|
975
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
915
976
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
916
977
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
917
978
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -987,6 +1048,7 @@ const operationsByTag$2 = {
|
|
987
1048
|
sqlQuery,
|
988
1049
|
vectorSearchTable,
|
989
1050
|
askTable,
|
1051
|
+
askTableSession,
|
990
1052
|
summarizeTable,
|
991
1053
|
aggregateTable
|
992
1054
|
}
|
@@ -994,6 +1056,13 @@ const operationsByTag$2 = {
|
|
994
1056
|
|
995
1057
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
996
1058
|
|
1059
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
1060
|
+
const generateAccessToken = (variables, signal) => controlPlaneFetch({
|
1061
|
+
url: "/oauth/token",
|
1062
|
+
method: "post",
|
1063
|
+
...variables,
|
1064
|
+
signal
|
1065
|
+
});
|
997
1066
|
const getUser = (variables, signal) => controlPlaneFetch({
|
998
1067
|
url: "/user",
|
999
1068
|
method: "get",
|
@@ -1099,6 +1168,7 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1099
1168
|
signal
|
1100
1169
|
});
|
1101
1170
|
const operationsByTag$1 = {
|
1171
|
+
authOther: { grantAuthorizationCode, generateAccessToken },
|
1102
1172
|
users: { getUser, updateUser, deleteUser },
|
1103
1173
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1104
1174
|
workspaces: {
|
@@ -2111,6 +2181,21 @@ class SearchAndFilterApi {
|
|
2111
2181
|
...this.extraProps
|
2112
2182
|
});
|
2113
2183
|
}
|
2184
|
+
askTableSession({
|
2185
|
+
workspace,
|
2186
|
+
region,
|
2187
|
+
database,
|
2188
|
+
branch,
|
2189
|
+
table,
|
2190
|
+
sessionId,
|
2191
|
+
message
|
2192
|
+
}) {
|
2193
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2194
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2195
|
+
body: { message },
|
2196
|
+
...this.extraProps
|
2197
|
+
});
|
2198
|
+
}
|
2114
2199
|
summarizeTable({
|
2115
2200
|
workspace,
|
2116
2201
|
region,
|
@@ -2402,11 +2487,13 @@ class DatabaseApi {
|
|
2402
2487
|
createDatabase({
|
2403
2488
|
workspace,
|
2404
2489
|
database,
|
2405
|
-
data
|
2490
|
+
data,
|
2491
|
+
headers
|
2406
2492
|
}) {
|
2407
2493
|
return operationsByTag.databases.createDatabase({
|
2408
2494
|
pathParams: { workspaceId: workspace, dbName: database },
|
2409
2495
|
body: data,
|
2496
|
+
headers,
|
2410
2497
|
...this.extraProps
|
2411
2498
|
});
|
2412
2499
|
}
|
@@ -2496,13 +2583,261 @@ class XataApiPlugin {
|
|
2496
2583
|
class XataPlugin {
|
2497
2584
|
}
|
2498
2585
|
|
2586
|
+
class FilesPlugin extends XataPlugin {
|
2587
|
+
build(pluginOptions) {
|
2588
|
+
return {
|
2589
|
+
download: async (location) => {
|
2590
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2591
|
+
return await getFileItem({
|
2592
|
+
pathParams: {
|
2593
|
+
workspace: "{workspaceId}",
|
2594
|
+
dbBranchName: "{dbBranch}",
|
2595
|
+
region: "{region}",
|
2596
|
+
tableName: table ?? "",
|
2597
|
+
recordId: record ?? "",
|
2598
|
+
columnName: column ?? "",
|
2599
|
+
fileId
|
2600
|
+
},
|
2601
|
+
...pluginOptions,
|
2602
|
+
rawResponse: true
|
2603
|
+
});
|
2604
|
+
},
|
2605
|
+
upload: async (location, file) => {
|
2606
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2607
|
+
return await putFileItem({
|
2608
|
+
pathParams: {
|
2609
|
+
workspace: "{workspaceId}",
|
2610
|
+
dbBranchName: "{dbBranch}",
|
2611
|
+
region: "{region}",
|
2612
|
+
tableName: table ?? "",
|
2613
|
+
recordId: record ?? "",
|
2614
|
+
columnName: column ?? "",
|
2615
|
+
fileId
|
2616
|
+
},
|
2617
|
+
body: file,
|
2618
|
+
...pluginOptions
|
2619
|
+
});
|
2620
|
+
},
|
2621
|
+
delete: async (location) => {
|
2622
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2623
|
+
return await deleteFileItem({
|
2624
|
+
pathParams: {
|
2625
|
+
workspace: "{workspaceId}",
|
2626
|
+
dbBranchName: "{dbBranch}",
|
2627
|
+
region: "{region}",
|
2628
|
+
tableName: table ?? "",
|
2629
|
+
recordId: record ?? "",
|
2630
|
+
columnName: column ?? "",
|
2631
|
+
fileId
|
2632
|
+
},
|
2633
|
+
...pluginOptions
|
2634
|
+
});
|
2635
|
+
}
|
2636
|
+
};
|
2637
|
+
}
|
2638
|
+
}
|
2639
|
+
|
2640
|
+
function buildTransformString(transformations) {
|
2641
|
+
return transformations.flatMap(
|
2642
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2643
|
+
if (key === "trim") {
|
2644
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2645
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2646
|
+
}
|
2647
|
+
if (key === "gravity" && typeof value === "object") {
|
2648
|
+
const { x = 0.5, y = 0.5 } = value;
|
2649
|
+
return `${key}=${[x, y].join("x")}`;
|
2650
|
+
}
|
2651
|
+
return `${key}=${value}`;
|
2652
|
+
})
|
2653
|
+
).join(",");
|
2654
|
+
}
|
2655
|
+
function transformImage(url, transformations) {
|
2656
|
+
if (!isDefined(url))
|
2657
|
+
return void 0;
|
2658
|
+
const transformationsString = buildTransformString(transformations);
|
2659
|
+
const { hostname, pathname, search } = new URL(url);
|
2660
|
+
return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
|
2661
|
+
}
|
2662
|
+
|
2663
|
+
var __defProp$6 = Object.defineProperty;
|
2664
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2665
|
+
var __publicField$6 = (obj, key, value) => {
|
2666
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2667
|
+
return value;
|
2668
|
+
};
|
2669
|
+
class XataFile {
|
2670
|
+
constructor(file) {
|
2671
|
+
/**
|
2672
|
+
* Name of this file.
|
2673
|
+
*/
|
2674
|
+
__publicField$6(this, "name");
|
2675
|
+
/**
|
2676
|
+
* Media type of this file.
|
2677
|
+
*/
|
2678
|
+
__publicField$6(this, "mediaType");
|
2679
|
+
/**
|
2680
|
+
* Base64 encoded content of this file.
|
2681
|
+
*/
|
2682
|
+
__publicField$6(this, "base64Content");
|
2683
|
+
/**
|
2684
|
+
* Whether to enable public url for this file.
|
2685
|
+
*/
|
2686
|
+
__publicField$6(this, "enablePublicUrl");
|
2687
|
+
/**
|
2688
|
+
* Timeout for the signed url.
|
2689
|
+
*/
|
2690
|
+
__publicField$6(this, "signedUrlTimeout");
|
2691
|
+
/**
|
2692
|
+
* Size of this file.
|
2693
|
+
*/
|
2694
|
+
__publicField$6(this, "size");
|
2695
|
+
/**
|
2696
|
+
* Version of this file.
|
2697
|
+
*/
|
2698
|
+
__publicField$6(this, "version");
|
2699
|
+
/**
|
2700
|
+
* Url of this file.
|
2701
|
+
*/
|
2702
|
+
__publicField$6(this, "url");
|
2703
|
+
/**
|
2704
|
+
* Signed url of this file.
|
2705
|
+
*/
|
2706
|
+
__publicField$6(this, "signedUrl");
|
2707
|
+
/**
|
2708
|
+
* Attributes of this file.
|
2709
|
+
*/
|
2710
|
+
__publicField$6(this, "attributes");
|
2711
|
+
this.name = file.name;
|
2712
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
2713
|
+
this.base64Content = file.base64Content;
|
2714
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2715
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2716
|
+
this.size = file.size;
|
2717
|
+
this.version = file.version;
|
2718
|
+
this.url = file.url;
|
2719
|
+
this.signedUrl = file.signedUrl;
|
2720
|
+
this.attributes = file.attributes;
|
2721
|
+
}
|
2722
|
+
static fromBuffer(buffer, options = {}) {
|
2723
|
+
const base64Content = buffer.toString("base64");
|
2724
|
+
return new XataFile({ ...options, base64Content });
|
2725
|
+
}
|
2726
|
+
toBuffer() {
|
2727
|
+
if (!this.base64Content) {
|
2728
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2729
|
+
}
|
2730
|
+
return Buffer.from(this.base64Content, "base64");
|
2731
|
+
}
|
2732
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2733
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2734
|
+
return this.fromUint8Array(uint8Array, options);
|
2735
|
+
}
|
2736
|
+
toArrayBuffer() {
|
2737
|
+
if (!this.base64Content) {
|
2738
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2739
|
+
}
|
2740
|
+
const binary = atob(this.base64Content);
|
2741
|
+
return new ArrayBuffer(binary.length);
|
2742
|
+
}
|
2743
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2744
|
+
let binary = "";
|
2745
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2746
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2747
|
+
}
|
2748
|
+
const base64Content = btoa(binary);
|
2749
|
+
return new XataFile({ ...options, base64Content });
|
2750
|
+
}
|
2751
|
+
toUint8Array() {
|
2752
|
+
if (!this.base64Content) {
|
2753
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2754
|
+
}
|
2755
|
+
const binary = atob(this.base64Content);
|
2756
|
+
const uint8Array = new Uint8Array(binary.length);
|
2757
|
+
for (let i = 0; i < binary.length; i++) {
|
2758
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2759
|
+
}
|
2760
|
+
return uint8Array;
|
2761
|
+
}
|
2762
|
+
static async fromBlob(file, options = {}) {
|
2763
|
+
const name = options.name ?? file.name;
|
2764
|
+
const mediaType = file.type;
|
2765
|
+
const arrayBuffer = await file.arrayBuffer();
|
2766
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2767
|
+
}
|
2768
|
+
toBlob() {
|
2769
|
+
if (!this.base64Content) {
|
2770
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2771
|
+
}
|
2772
|
+
const arrayBuffer = this.toArrayBuffer();
|
2773
|
+
return new Blob([arrayBuffer], { type: this.mediaType });
|
2774
|
+
}
|
2775
|
+
static fromString(string, options = {}) {
|
2776
|
+
const base64Content = btoa(string);
|
2777
|
+
return new XataFile({ ...options, base64Content });
|
2778
|
+
}
|
2779
|
+
toString() {
|
2780
|
+
if (!this.base64Content) {
|
2781
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2782
|
+
}
|
2783
|
+
return atob(this.base64Content);
|
2784
|
+
}
|
2785
|
+
static fromBase64(base64Content, options = {}) {
|
2786
|
+
return new XataFile({ ...options, base64Content });
|
2787
|
+
}
|
2788
|
+
toBase64() {
|
2789
|
+
if (!this.base64Content) {
|
2790
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2791
|
+
}
|
2792
|
+
return this.base64Content;
|
2793
|
+
}
|
2794
|
+
transform(...options) {
|
2795
|
+
return {
|
2796
|
+
url: transformImage(this.url, options),
|
2797
|
+
signedUrl: transformImage(this.signedUrl, options)
|
2798
|
+
};
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
const parseInputFileEntry = async (entry) => {
|
2802
|
+
if (!isDefined(entry))
|
2803
|
+
return null;
|
2804
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2805
|
+
return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
|
2806
|
+
};
|
2807
|
+
|
2499
2808
|
function cleanFilter(filter) {
|
2500
|
-
if (!filter)
|
2809
|
+
if (!isDefined(filter))
|
2501
2810
|
return void 0;
|
2502
|
-
|
2503
|
-
|
2811
|
+
if (!isObject(filter))
|
2812
|
+
return filter;
|
2813
|
+
const values = Object.fromEntries(
|
2814
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2815
|
+
if (!isDefined(value))
|
2816
|
+
return acc;
|
2817
|
+
if (Array.isArray(value)) {
|
2818
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2819
|
+
if (clean.length === 0)
|
2820
|
+
return acc;
|
2821
|
+
return [...acc, [key, clean]];
|
2822
|
+
}
|
2823
|
+
if (isObject(value)) {
|
2824
|
+
const clean = cleanFilter(value);
|
2825
|
+
if (!isDefined(clean))
|
2826
|
+
return acc;
|
2827
|
+
return [...acc, [key, clean]];
|
2828
|
+
}
|
2829
|
+
return [...acc, [key, value]];
|
2830
|
+
}, [])
|
2831
|
+
);
|
2832
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2504
2833
|
}
|
2505
2834
|
|
2835
|
+
var __defProp$5 = Object.defineProperty;
|
2836
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2837
|
+
var __publicField$5 = (obj, key, value) => {
|
2838
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2839
|
+
return value;
|
2840
|
+
};
|
2506
2841
|
var __accessCheck$6 = (obj, member, msg) => {
|
2507
2842
|
if (!member.has(obj))
|
2508
2843
|
throw TypeError("Cannot " + msg);
|
@@ -2525,6 +2860,14 @@ var _query, _page;
|
|
2525
2860
|
class Page {
|
2526
2861
|
constructor(query, meta, records = []) {
|
2527
2862
|
__privateAdd$6(this, _query, void 0);
|
2863
|
+
/**
|
2864
|
+
* Page metadata, required to retrieve additional records.
|
2865
|
+
*/
|
2866
|
+
__publicField$5(this, "meta");
|
2867
|
+
/**
|
2868
|
+
* The set of results for this page.
|
2869
|
+
*/
|
2870
|
+
__publicField$5(this, "records");
|
2528
2871
|
__privateSet$6(this, _query, query);
|
2529
2872
|
this.meta = meta;
|
2530
2873
|
this.records = new RecordArray(this, records);
|
@@ -2581,7 +2924,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2581
2924
|
function isCursorPaginationOptions(options) {
|
2582
2925
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2583
2926
|
}
|
2584
|
-
const _RecordArray = class extends Array {
|
2927
|
+
const _RecordArray = class _RecordArray extends Array {
|
2585
2928
|
constructor(...args) {
|
2586
2929
|
super(..._RecordArray.parseConstructorParams(...args));
|
2587
2930
|
__privateAdd$6(this, _page, void 0);
|
@@ -2652,9 +2995,15 @@ const _RecordArray = class extends Array {
|
|
2652
2995
|
return __privateGet$6(this, _page).meta.page.more;
|
2653
2996
|
}
|
2654
2997
|
};
|
2655
|
-
let RecordArray = _RecordArray;
|
2656
2998
|
_page = new WeakMap();
|
2999
|
+
let RecordArray = _RecordArray;
|
2657
3000
|
|
3001
|
+
var __defProp$4 = Object.defineProperty;
|
3002
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3003
|
+
var __publicField$4 = (obj, key, value) => {
|
3004
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3005
|
+
return value;
|
3006
|
+
};
|
2658
3007
|
var __accessCheck$5 = (obj, member, msg) => {
|
2659
3008
|
if (!member.has(obj))
|
2660
3009
|
throw TypeError("Cannot " + msg);
|
@@ -2678,15 +3027,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2678
3027
|
return method;
|
2679
3028
|
};
|
2680
3029
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2681
|
-
const _Query = class {
|
3030
|
+
const _Query = class _Query {
|
2682
3031
|
constructor(repository, table, data, rawParent) {
|
2683
3032
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2684
3033
|
__privateAdd$5(this, _table$1, void 0);
|
2685
3034
|
__privateAdd$5(this, _repository, void 0);
|
2686
3035
|
__privateAdd$5(this, _data, { filter: {} });
|
2687
3036
|
// Implements pagination
|
2688
|
-
this
|
2689
|
-
this
|
3037
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
3038
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2690
3039
|
__privateSet$5(this, _table$1, table);
|
2691
3040
|
if (repository) {
|
2692
3041
|
__privateSet$5(this, _repository, repository);
|
@@ -2906,7 +3255,6 @@ const _Query = class {
|
|
2906
3255
|
return this.meta.page.more;
|
2907
3256
|
}
|
2908
3257
|
};
|
2909
|
-
let Query = _Query;
|
2910
3258
|
_table$1 = new WeakMap();
|
2911
3259
|
_repository = new WeakMap();
|
2912
3260
|
_data = new WeakMap();
|
@@ -2921,6 +3269,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2921
3269
|
}
|
2922
3270
|
return value;
|
2923
3271
|
};
|
3272
|
+
let Query = _Query;
|
2924
3273
|
function cleanParent(data, parent) {
|
2925
3274
|
if (isCursorPaginationOptions(data.pagination)) {
|
2926
3275
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2928,6 +3277,21 @@ function cleanParent(data, parent) {
|
|
2928
3277
|
return parent;
|
2929
3278
|
}
|
2930
3279
|
|
3280
|
+
const RecordColumnTypes = [
|
3281
|
+
"bool",
|
3282
|
+
"int",
|
3283
|
+
"float",
|
3284
|
+
"string",
|
3285
|
+
"text",
|
3286
|
+
"email",
|
3287
|
+
"multiple",
|
3288
|
+
"link",
|
3289
|
+
"object",
|
3290
|
+
"datetime",
|
3291
|
+
"vector",
|
3292
|
+
"file[]",
|
3293
|
+
"file"
|
3294
|
+
];
|
2931
3295
|
function isIdentifiable(x) {
|
2932
3296
|
return isObject(x) && isString(x?.id);
|
2933
3297
|
}
|
@@ -2986,7 +3350,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2986
3350
|
__accessCheck$4(obj, member, "access private method");
|
2987
3351
|
return method;
|
2988
3352
|
};
|
2989
|
-
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;
|
3353
|
+
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;
|
2990
3354
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2991
3355
|
class Repository extends Query {
|
2992
3356
|
}
|
@@ -3008,6 +3372,7 @@ class RestRepository extends Query {
|
|
3008
3372
|
__privateAdd$4(this, _setCacheQuery);
|
3009
3373
|
__privateAdd$4(this, _getCacheQuery);
|
3010
3374
|
__privateAdd$4(this, _getSchemaTables$1);
|
3375
|
+
__privateAdd$4(this, _transformObjectToApi);
|
3011
3376
|
__privateAdd$4(this, _table, void 0);
|
3012
3377
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3013
3378
|
__privateAdd$4(this, _db, void 0);
|
@@ -3399,23 +3764,28 @@ class RestRepository extends Query {
|
|
3399
3764
|
});
|
3400
3765
|
}
|
3401
3766
|
ask(question, options) {
|
3767
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3402
3768
|
const params = {
|
3403
3769
|
pathParams: {
|
3404
3770
|
workspace: "{workspaceId}",
|
3405
3771
|
dbBranchName: "{dbBranch}",
|
3406
3772
|
region: "{region}",
|
3407
|
-
tableName: __privateGet$4(this, _table)
|
3773
|
+
tableName: __privateGet$4(this, _table),
|
3774
|
+
sessionId: options?.sessionId
|
3408
3775
|
},
|
3409
3776
|
body: {
|
3410
|
-
|
3411
|
-
|
3777
|
+
...questionParam,
|
3778
|
+
rules: options?.rules,
|
3779
|
+
searchType: options?.searchType,
|
3780
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3781
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3412
3782
|
},
|
3413
3783
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3414
3784
|
};
|
3415
3785
|
if (options?.onMessage) {
|
3416
3786
|
fetchSSERequest({
|
3417
3787
|
endpoint: "dataPlane",
|
3418
|
-
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3788
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3419
3789
|
method: "POST",
|
3420
3790
|
onMessage: (message) => {
|
3421
3791
|
options.onMessage?.({ answer: message.text, records: message.records });
|
@@ -3423,7 +3793,7 @@ class RestRepository extends Query {
|
|
3423
3793
|
...params
|
3424
3794
|
});
|
3425
3795
|
} else {
|
3426
|
-
return
|
3796
|
+
return askTableSession(params);
|
3427
3797
|
}
|
3428
3798
|
}
|
3429
3799
|
}
|
@@ -3435,7 +3805,7 @@ _schemaTables$2 = new WeakMap();
|
|
3435
3805
|
_trace = new WeakMap();
|
3436
3806
|
_insertRecordWithoutId = new WeakSet();
|
3437
3807
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
3438
|
-
const record =
|
3808
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3439
3809
|
const response = await insertRecord({
|
3440
3810
|
pathParams: {
|
3441
3811
|
workspace: "{workspaceId}",
|
@@ -3454,7 +3824,7 @@ _insertRecordWithId = new WeakSet();
|
|
3454
3824
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
3455
3825
|
if (!recordId)
|
3456
3826
|
return null;
|
3457
|
-
const record =
|
3827
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3458
3828
|
const response = await insertRecordWithID({
|
3459
3829
|
pathParams: {
|
3460
3830
|
workspace: "{workspaceId}",
|
@@ -3472,21 +3842,20 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3472
3842
|
};
|
3473
3843
|
_insertRecords = new WeakSet();
|
3474
3844
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3475
|
-
const
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
);
|
3845
|
+
const operations = await promiseMap(objects, async (object) => {
|
3846
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3847
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3848
|
+
});
|
3849
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3481
3850
|
const ids = [];
|
3482
|
-
for (const
|
3851
|
+
for (const operations2 of chunkedOperations) {
|
3483
3852
|
const { results } = await branchTransaction({
|
3484
3853
|
pathParams: {
|
3485
3854
|
workspace: "{workspaceId}",
|
3486
3855
|
dbBranchName: "{dbBranch}",
|
3487
3856
|
region: "{region}"
|
3488
3857
|
},
|
3489
|
-
body: { operations },
|
3858
|
+
body: { operations: operations2 },
|
3490
3859
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3491
3860
|
});
|
3492
3861
|
for (const result of results) {
|
@@ -3503,7 +3872,7 @@ _updateRecordWithID = new WeakSet();
|
|
3503
3872
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3504
3873
|
if (!recordId)
|
3505
3874
|
return null;
|
3506
|
-
const { id: _id, ...record } =
|
3875
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3507
3876
|
try {
|
3508
3877
|
const response = await updateRecordWithID({
|
3509
3878
|
pathParams: {
|
@@ -3528,21 +3897,20 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3528
3897
|
};
|
3529
3898
|
_updateRecords = new WeakSet();
|
3530
3899
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3531
|
-
const
|
3532
|
-
|
3533
|
-
|
3534
|
-
|
3535
|
-
|
3536
|
-
);
|
3900
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3901
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3902
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3903
|
+
});
|
3904
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3537
3905
|
const ids = [];
|
3538
|
-
for (const
|
3906
|
+
for (const operations2 of chunkedOperations) {
|
3539
3907
|
const { results } = await branchTransaction({
|
3540
3908
|
pathParams: {
|
3541
3909
|
workspace: "{workspaceId}",
|
3542
3910
|
dbBranchName: "{dbBranch}",
|
3543
3911
|
region: "{region}"
|
3544
3912
|
},
|
3545
|
-
body: { operations },
|
3913
|
+
body: { operations: operations2 },
|
3546
3914
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3547
3915
|
});
|
3548
3916
|
for (const result of results) {
|
@@ -3645,7 +4013,39 @@ getSchemaTables_fn$1 = async function() {
|
|
3645
4013
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
3646
4014
|
return schema.tables;
|
3647
4015
|
};
|
3648
|
-
|
4016
|
+
_transformObjectToApi = new WeakSet();
|
4017
|
+
transformObjectToApi_fn = async function(object) {
|
4018
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4019
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4020
|
+
if (!schema)
|
4021
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4022
|
+
const result = {};
|
4023
|
+
for (const [key, value] of Object.entries(object)) {
|
4024
|
+
if (key === "xata")
|
4025
|
+
continue;
|
4026
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4027
|
+
switch (type) {
|
4028
|
+
case "link": {
|
4029
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4030
|
+
break;
|
4031
|
+
}
|
4032
|
+
case "datetime": {
|
4033
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4034
|
+
break;
|
4035
|
+
}
|
4036
|
+
case `file`:
|
4037
|
+
result[key] = await parseInputFileEntry(value);
|
4038
|
+
break;
|
4039
|
+
case "file[]":
|
4040
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4041
|
+
break;
|
4042
|
+
default:
|
4043
|
+
result[key] = value;
|
4044
|
+
}
|
4045
|
+
}
|
4046
|
+
return result;
|
4047
|
+
};
|
4048
|
+
const removeLinksFromObject = (object) => {
|
3649
4049
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
3650
4050
|
if (key === "xata")
|
3651
4051
|
return acc;
|
@@ -3694,6 +4094,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3694
4094
|
}
|
3695
4095
|
break;
|
3696
4096
|
}
|
4097
|
+
case "file":
|
4098
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4099
|
+
break;
|
4100
|
+
case "file[]":
|
4101
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4102
|
+
break;
|
3697
4103
|
default:
|
3698
4104
|
data[column.name] = value ?? null;
|
3699
4105
|
if (column.notNull === true && value === null) {
|
@@ -3703,7 +4109,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3703
4109
|
}
|
3704
4110
|
}
|
3705
4111
|
const record = { ...data };
|
3706
|
-
const serializable = { xata, ...
|
4112
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
3707
4113
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3708
4114
|
record.read = function(columns2) {
|
3709
4115
|
return db[table].read(record["id"], columns2);
|
@@ -3729,7 +4135,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3729
4135
|
return JSON.parse(JSON.stringify(serializable));
|
3730
4136
|
};
|
3731
4137
|
record.toString = function() {
|
3732
|
-
return JSON.stringify(
|
4138
|
+
return JSON.stringify(serializable);
|
3733
4139
|
};
|
3734
4140
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3735
4141
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -3747,11 +4153,7 @@ function extractId(value) {
|
|
3747
4153
|
function isValidColumn(columns, column) {
|
3748
4154
|
if (columns.includes("*"))
|
3749
4155
|
return true;
|
3750
|
-
|
3751
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3752
|
-
return linkColumns.length > 0;
|
3753
|
-
}
|
3754
|
-
return columns.includes(column.name);
|
4156
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
3755
4157
|
}
|
3756
4158
|
function parseIfVersion(...args) {
|
3757
4159
|
for (const arg of args) {
|
@@ -3762,6 +4164,12 @@ function parseIfVersion(...args) {
|
|
3762
4164
|
return void 0;
|
3763
4165
|
}
|
3764
4166
|
|
4167
|
+
var __defProp$3 = Object.defineProperty;
|
4168
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4169
|
+
var __publicField$3 = (obj, key, value) => {
|
4170
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4171
|
+
return value;
|
4172
|
+
};
|
3765
4173
|
var __accessCheck$3 = (obj, member, msg) => {
|
3766
4174
|
if (!member.has(obj))
|
3767
4175
|
throw TypeError("Cannot " + msg);
|
@@ -3784,6 +4192,8 @@ var _map;
|
|
3784
4192
|
class SimpleCache {
|
3785
4193
|
constructor(options = {}) {
|
3786
4194
|
__privateAdd$3(this, _map, void 0);
|
4195
|
+
__publicField$3(this, "capacity");
|
4196
|
+
__publicField$3(this, "defaultQueryTTL");
|
3787
4197
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
3788
4198
|
this.capacity = options.max ?? 500;
|
3789
4199
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3981,6 +4391,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3981
4391
|
}
|
3982
4392
|
}
|
3983
4393
|
|
4394
|
+
var __defProp$2 = Object.defineProperty;
|
4395
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4396
|
+
var __publicField$2 = (obj, key, value) => {
|
4397
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4398
|
+
return value;
|
4399
|
+
};
|
3984
4400
|
var __accessCheck = (obj, member, msg) => {
|
3985
4401
|
if (!member.has(obj))
|
3986
4402
|
throw TypeError("Cannot " + msg);
|
@@ -4010,6 +4426,10 @@ const buildClient = (plugins) => {
|
|
4010
4426
|
__privateAdd(this, _parseOptions);
|
4011
4427
|
__privateAdd(this, _getFetchProps);
|
4012
4428
|
__privateAdd(this, _options, void 0);
|
4429
|
+
__publicField$2(this, "db");
|
4430
|
+
__publicField$2(this, "search");
|
4431
|
+
__publicField$2(this, "transactions");
|
4432
|
+
__publicField$2(this, "files");
|
4013
4433
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4014
4434
|
__privateSet(this, _options, safeOptions);
|
4015
4435
|
const pluginOptions = {
|
@@ -4020,9 +4440,11 @@ const buildClient = (plugins) => {
|
|
4020
4440
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4021
4441
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4022
4442
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4443
|
+
const files = new FilesPlugin().build(pluginOptions);
|
4023
4444
|
this.db = db;
|
4024
4445
|
this.search = search;
|
4025
4446
|
this.transactions = transactions;
|
4447
|
+
this.files = files;
|
4026
4448
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4027
4449
|
if (namespace === void 0)
|
4028
4450
|
continue;
|
@@ -4119,11 +4541,17 @@ const buildClient = (plugins) => {
|
|
4119
4541
|
class BaseClient extends buildClient() {
|
4120
4542
|
}
|
4121
4543
|
|
4544
|
+
var __defProp$1 = Object.defineProperty;
|
4545
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4546
|
+
var __publicField$1 = (obj, key, value) => {
|
4547
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4548
|
+
return value;
|
4549
|
+
};
|
4122
4550
|
const META = "__";
|
4123
4551
|
const VALUE = "___";
|
4124
4552
|
class Serializer {
|
4125
4553
|
constructor() {
|
4126
|
-
this
|
4554
|
+
__publicField$1(this, "classes", {});
|
4127
4555
|
}
|
4128
4556
|
add(clazz) {
|
4129
4557
|
this.classes[clazz.name] = clazz;
|
@@ -4201,9 +4629,16 @@ function buildWorkerRunner(config) {
|
|
4201
4629
|
};
|
4202
4630
|
}
|
4203
4631
|
|
4632
|
+
var __defProp = Object.defineProperty;
|
4633
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4634
|
+
var __publicField = (obj, key, value) => {
|
4635
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4636
|
+
return value;
|
4637
|
+
};
|
4204
4638
|
class XataError extends Error {
|
4205
4639
|
constructor(message, status) {
|
4206
4640
|
super(message);
|
4641
|
+
__publicField(this, "status");
|
4207
4642
|
this.status = status;
|
4208
4643
|
}
|
4209
4644
|
}
|
@@ -4218,6 +4653,7 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
4218
4653
|
exports.Page = Page;
|
4219
4654
|
exports.Query = Query;
|
4220
4655
|
exports.RecordArray = RecordArray;
|
4656
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
4221
4657
|
exports.Repository = Repository;
|
4222
4658
|
exports.RestRepository = RestRepository;
|
4223
4659
|
exports.SchemaPlugin = SchemaPlugin;
|
@@ -4227,6 +4663,7 @@ exports.SimpleCache = SimpleCache;
|
|
4227
4663
|
exports.XataApiClient = XataApiClient;
|
4228
4664
|
exports.XataApiPlugin = XataApiPlugin;
|
4229
4665
|
exports.XataError = XataError;
|
4666
|
+
exports.XataFile = XataFile;
|
4230
4667
|
exports.XataPlugin = XataPlugin;
|
4231
4668
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
4232
4669
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
@@ -4234,6 +4671,7 @@ exports.addTableColumn = addTableColumn;
|
|
4234
4671
|
exports.aggregateTable = aggregateTable;
|
4235
4672
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4236
4673
|
exports.askTable = askTable;
|
4674
|
+
exports.askTableSession = askTableSession;
|
4237
4675
|
exports.branchTransaction = branchTransaction;
|
4238
4676
|
exports.buildClient = buildClient;
|
4239
4677
|
exports.buildPreviewBranchName = buildPreviewBranchName;
|
@@ -4270,6 +4708,7 @@ exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
|
4270
4708
|
exports.exists = exists;
|
4271
4709
|
exports.fileAccess = fileAccess;
|
4272
4710
|
exports.ge = ge;
|
4711
|
+
exports.generateAccessToken = generateAccessToken;
|
4273
4712
|
exports.getAPIKey = getAPIKey;
|
4274
4713
|
exports.getBranch = getBranch;
|
4275
4714
|
exports.getBranchDetails = getBranchDetails;
|
@@ -4299,6 +4738,7 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
4299
4738
|
exports.getWorkspace = getWorkspace;
|
4300
4739
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
4301
4740
|
exports.getWorkspacesList = getWorkspacesList;
|
4741
|
+
exports.grantAuthorizationCode = grantAuthorizationCode;
|
4302
4742
|
exports.greaterEquals = greaterEquals;
|
4303
4743
|
exports.greaterThan = greaterThan;
|
4304
4744
|
exports.greaterThanEquals = greaterThanEquals;
|