@xata.io/client 0.24.3 → 0.25.0
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 +8 -3
- package/CHANGELOG.md +16 -0
- package/dist/index.cjs +480 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +491 -29
- package/dist/index.mjs +476 -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,15 @@ function chunk(array, chunkSize) {
|
|
85
88
|
async function timeout(ms) {
|
86
89
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
87
90
|
}
|
91
|
+
function promiseMap(inputValues, mapper) {
|
92
|
+
const reducer = (acc$, inputValue) => acc$.then(
|
93
|
+
(acc) => mapper(inputValue).then((result) => {
|
94
|
+
acc.push(result);
|
95
|
+
return acc;
|
96
|
+
})
|
97
|
+
);
|
98
|
+
return inputValues.reduce(reducer, Promise.resolve([]));
|
99
|
+
}
|
88
100
|
|
89
101
|
function getEnvironment() {
|
90
102
|
try {
|
@@ -212,6 +224,12 @@ function getPreviewBranch() {
|
|
212
224
|
}
|
213
225
|
}
|
214
226
|
|
227
|
+
var __defProp$8 = Object.defineProperty;
|
228
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
229
|
+
var __publicField$8 = (obj, key, value) => {
|
230
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
231
|
+
return value;
|
232
|
+
};
|
215
233
|
var __accessCheck$8 = (obj, member, msg) => {
|
216
234
|
if (!member.has(obj))
|
217
235
|
throw TypeError("Cannot " + msg);
|
@@ -235,6 +253,7 @@ var __privateMethod$4 = (obj, member, method) => {
|
|
235
253
|
return method;
|
236
254
|
};
|
237
255
|
var _fetch, _queue, _concurrency, _enqueue, enqueue_fn;
|
256
|
+
const REQUEST_TIMEOUT = 3e4;
|
238
257
|
function getFetchImplementation(userFetch) {
|
239
258
|
const globalFetch = typeof fetch !== "undefined" ? fetch : void 0;
|
240
259
|
const fetchImpl = userFetch ?? globalFetch;
|
@@ -251,6 +270,8 @@ class ApiRequestPool {
|
|
251
270
|
__privateAdd$8(this, _fetch, void 0);
|
252
271
|
__privateAdd$8(this, _queue, void 0);
|
253
272
|
__privateAdd$8(this, _concurrency, void 0);
|
273
|
+
__publicField$8(this, "running");
|
274
|
+
__publicField$8(this, "started");
|
254
275
|
__privateSet$8(this, _queue, []);
|
255
276
|
__privateSet$8(this, _concurrency, concurrency);
|
256
277
|
this.running = 0;
|
@@ -267,9 +288,12 @@ class ApiRequestPool {
|
|
267
288
|
}
|
268
289
|
request(url, options) {
|
269
290
|
const start = /* @__PURE__ */ new Date();
|
270
|
-
const
|
291
|
+
const fetchImpl = this.getFetch();
|
271
292
|
const runRequest = async (stalled = false) => {
|
272
|
-
const response = await
|
293
|
+
const response = await Promise.race([fetchImpl(url, options), timeout(REQUEST_TIMEOUT).then(() => null)]);
|
294
|
+
if (!response) {
|
295
|
+
throw new Error("Request timed out");
|
296
|
+
}
|
273
297
|
if (response.status === 429) {
|
274
298
|
const rateLimitReset = parseNumber(response.headers?.get("x-ratelimit-reset")) ?? 1;
|
275
299
|
await timeout(rateLimitReset * 1e3);
|
@@ -492,16 +516,26 @@ function defaultOnOpen(response) {
|
|
492
516
|
}
|
493
517
|
}
|
494
518
|
|
495
|
-
const VERSION = "0.
|
519
|
+
const VERSION = "0.25.0";
|
496
520
|
|
521
|
+
var __defProp$7 = Object.defineProperty;
|
522
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
523
|
+
var __publicField$7 = (obj, key, value) => {
|
524
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
525
|
+
return value;
|
526
|
+
};
|
497
527
|
class ErrorWithCause extends Error {
|
498
528
|
constructor(message, options) {
|
499
529
|
super(message, options);
|
530
|
+
__publicField$7(this, "cause");
|
500
531
|
}
|
501
532
|
}
|
502
533
|
class FetcherError extends ErrorWithCause {
|
503
534
|
constructor(status, data, requestId) {
|
504
535
|
super(getMessage(data));
|
536
|
+
__publicField$7(this, "status");
|
537
|
+
__publicField$7(this, "requestId");
|
538
|
+
__publicField$7(this, "errors");
|
505
539
|
this.status = status;
|
506
540
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
507
541
|
this.requestId = requestId;
|
@@ -568,6 +602,15 @@ function hostHeader(url) {
|
|
568
602
|
const { groups } = pattern.exec(url) ?? {};
|
569
603
|
return groups?.host ? { Host: groups.host } : {};
|
570
604
|
}
|
605
|
+
function parseBody(body, headers) {
|
606
|
+
if (!isDefined(body))
|
607
|
+
return void 0;
|
608
|
+
const { "Content-Type": contentType } = headers ?? {};
|
609
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
610
|
+
return JSON.stringify(body);
|
611
|
+
}
|
612
|
+
return body;
|
613
|
+
}
|
571
614
|
const defaultClientID = generateUUID();
|
572
615
|
async function fetch$1({
|
573
616
|
url: path,
|
@@ -587,7 +630,8 @@ async function fetch$1({
|
|
587
630
|
sessionID,
|
588
631
|
clientName,
|
589
632
|
xataAgentExtra,
|
590
|
-
fetchOptions = {}
|
633
|
+
fetchOptions = {},
|
634
|
+
rawResponse = false
|
591
635
|
}) {
|
592
636
|
pool.setFetch(fetch2);
|
593
637
|
return await trace(
|
@@ -606,7 +650,7 @@ async function fetch$1({
|
|
606
650
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
607
651
|
...Object.entries(xataAgentExtra ?? {})
|
608
652
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
609
|
-
const headers = {
|
653
|
+
const headers = compactObject({
|
610
654
|
"Accept-Encoding": "identity",
|
611
655
|
"Content-Type": "application/json",
|
612
656
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -615,11 +659,11 @@ async function fetch$1({
|
|
615
659
|
...customHeaders,
|
616
660
|
...hostHeader(fullUrl),
|
617
661
|
Authorization: `Bearer ${apiKey}`
|
618
|
-
};
|
662
|
+
});
|
619
663
|
const response = await pool.request(url, {
|
620
664
|
...fetchOptions,
|
621
665
|
method: method.toUpperCase(),
|
622
|
-
body: body
|
666
|
+
body: parseBody(body, headers),
|
623
667
|
headers,
|
624
668
|
signal
|
625
669
|
});
|
@@ -632,6 +676,9 @@ async function fetch$1({
|
|
632
676
|
[TraceAttributes.HTTP_HOST]: host,
|
633
677
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
634
678
|
});
|
679
|
+
const message = response.headers?.get("x-xata-message");
|
680
|
+
if (message)
|
681
|
+
console.warn(message);
|
635
682
|
if (response.status === 204) {
|
636
683
|
return {};
|
637
684
|
}
|
@@ -639,7 +686,7 @@ async function fetch$1({
|
|
639
686
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
640
687
|
}
|
641
688
|
try {
|
642
|
-
const jsonResponse = await response.json();
|
689
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
643
690
|
if (response.ok) {
|
644
691
|
return jsonResponse;
|
645
692
|
}
|
@@ -912,6 +959,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
912
959
|
...variables,
|
913
960
|
signal
|
914
961
|
});
|
962
|
+
const askTableSession = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
915
963
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
916
964
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
917
965
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -987,6 +1035,7 @@ const operationsByTag$2 = {
|
|
987
1035
|
sqlQuery,
|
988
1036
|
vectorSearchTable,
|
989
1037
|
askTable,
|
1038
|
+
askTableSession,
|
990
1039
|
summarizeTable,
|
991
1040
|
aggregateTable
|
992
1041
|
}
|
@@ -994,6 +1043,13 @@ const operationsByTag$2 = {
|
|
994
1043
|
|
995
1044
|
const controlPlaneFetch = async (options) => fetch$1({ ...options, endpoint: "controlPlane" });
|
996
1045
|
|
1046
|
+
const grantAuthorizationCode = (variables, signal) => controlPlaneFetch({ url: "/oauth/authorize", method: "post", ...variables, signal });
|
1047
|
+
const generateAccessToken = (variables, signal) => controlPlaneFetch({
|
1048
|
+
url: "/oauth/token",
|
1049
|
+
method: "post",
|
1050
|
+
...variables,
|
1051
|
+
signal
|
1052
|
+
});
|
997
1053
|
const getUser = (variables, signal) => controlPlaneFetch({
|
998
1054
|
url: "/user",
|
999
1055
|
method: "get",
|
@@ -1099,6 +1155,7 @@ const listRegions = (variables, signal) => controlPlaneFetch({
|
|
1099
1155
|
signal
|
1100
1156
|
});
|
1101
1157
|
const operationsByTag$1 = {
|
1158
|
+
authOther: { grantAuthorizationCode, generateAccessToken },
|
1102
1159
|
users: { getUser, updateUser, deleteUser },
|
1103
1160
|
authentication: { getUserAPIKeys, createUserAPIKey, deleteUserAPIKey },
|
1104
1161
|
workspaces: {
|
@@ -2111,6 +2168,21 @@ class SearchAndFilterApi {
|
|
2111
2168
|
...this.extraProps
|
2112
2169
|
});
|
2113
2170
|
}
|
2171
|
+
askTableSession({
|
2172
|
+
workspace,
|
2173
|
+
region,
|
2174
|
+
database,
|
2175
|
+
branch,
|
2176
|
+
table,
|
2177
|
+
sessionId,
|
2178
|
+
message
|
2179
|
+
}) {
|
2180
|
+
return operationsByTag.searchAndFilter.askTableSession({
|
2181
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2182
|
+
body: { message },
|
2183
|
+
...this.extraProps
|
2184
|
+
});
|
2185
|
+
}
|
2114
2186
|
summarizeTable({
|
2115
2187
|
workspace,
|
2116
2188
|
region,
|
@@ -2402,11 +2474,13 @@ class DatabaseApi {
|
|
2402
2474
|
createDatabase({
|
2403
2475
|
workspace,
|
2404
2476
|
database,
|
2405
|
-
data
|
2477
|
+
data,
|
2478
|
+
headers
|
2406
2479
|
}) {
|
2407
2480
|
return operationsByTag.databases.createDatabase({
|
2408
2481
|
pathParams: { workspaceId: workspace, dbName: database },
|
2409
2482
|
body: data,
|
2483
|
+
headers,
|
2410
2484
|
...this.extraProps
|
2411
2485
|
});
|
2412
2486
|
}
|
@@ -2496,13 +2570,261 @@ class XataApiPlugin {
|
|
2496
2570
|
class XataPlugin {
|
2497
2571
|
}
|
2498
2572
|
|
2573
|
+
class FilesPlugin extends XataPlugin {
|
2574
|
+
build(pluginOptions) {
|
2575
|
+
return {
|
2576
|
+
download: async (location) => {
|
2577
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2578
|
+
return await getFileItem({
|
2579
|
+
pathParams: {
|
2580
|
+
workspace: "{workspaceId}",
|
2581
|
+
dbBranchName: "{dbBranch}",
|
2582
|
+
region: "{region}",
|
2583
|
+
tableName: table ?? "",
|
2584
|
+
recordId: record ?? "",
|
2585
|
+
columnName: column ?? "",
|
2586
|
+
fileId
|
2587
|
+
},
|
2588
|
+
...pluginOptions,
|
2589
|
+
rawResponse: true
|
2590
|
+
});
|
2591
|
+
},
|
2592
|
+
upload: async (location, file) => {
|
2593
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2594
|
+
return await putFileItem({
|
2595
|
+
pathParams: {
|
2596
|
+
workspace: "{workspaceId}",
|
2597
|
+
dbBranchName: "{dbBranch}",
|
2598
|
+
region: "{region}",
|
2599
|
+
tableName: table ?? "",
|
2600
|
+
recordId: record ?? "",
|
2601
|
+
columnName: column ?? "",
|
2602
|
+
fileId
|
2603
|
+
},
|
2604
|
+
body: file,
|
2605
|
+
...pluginOptions
|
2606
|
+
});
|
2607
|
+
},
|
2608
|
+
delete: async (location) => {
|
2609
|
+
const { table, record, column, fileId = "" } = location ?? {};
|
2610
|
+
return await deleteFileItem({
|
2611
|
+
pathParams: {
|
2612
|
+
workspace: "{workspaceId}",
|
2613
|
+
dbBranchName: "{dbBranch}",
|
2614
|
+
region: "{region}",
|
2615
|
+
tableName: table ?? "",
|
2616
|
+
recordId: record ?? "",
|
2617
|
+
columnName: column ?? "",
|
2618
|
+
fileId
|
2619
|
+
},
|
2620
|
+
...pluginOptions
|
2621
|
+
});
|
2622
|
+
}
|
2623
|
+
};
|
2624
|
+
}
|
2625
|
+
}
|
2626
|
+
|
2627
|
+
function buildTransformString(transformations) {
|
2628
|
+
return transformations.flatMap(
|
2629
|
+
(t) => Object.entries(t).map(([key, value]) => {
|
2630
|
+
if (key === "trim") {
|
2631
|
+
const { left = 0, top = 0, right = 0, bottom = 0 } = value;
|
2632
|
+
return `${key}=${[top, right, bottom, left].join(";")}`;
|
2633
|
+
}
|
2634
|
+
if (key === "gravity" && typeof value === "object") {
|
2635
|
+
const { x = 0.5, y = 0.5 } = value;
|
2636
|
+
return `${key}=${[x, y].join("x")}`;
|
2637
|
+
}
|
2638
|
+
return `${key}=${value}`;
|
2639
|
+
})
|
2640
|
+
).join(",");
|
2641
|
+
}
|
2642
|
+
function transformImage(url, transformations) {
|
2643
|
+
if (!isDefined(url))
|
2644
|
+
return void 0;
|
2645
|
+
const transformationsString = buildTransformString(transformations);
|
2646
|
+
const { hostname, pathname, search } = new URL(url);
|
2647
|
+
return `https://${hostname}/transform/${transformationsString}${pathname}${search}`;
|
2648
|
+
}
|
2649
|
+
|
2650
|
+
var __defProp$6 = Object.defineProperty;
|
2651
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2652
|
+
var __publicField$6 = (obj, key, value) => {
|
2653
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2654
|
+
return value;
|
2655
|
+
};
|
2656
|
+
class XataFile {
|
2657
|
+
constructor(file) {
|
2658
|
+
/**
|
2659
|
+
* Name of this file.
|
2660
|
+
*/
|
2661
|
+
__publicField$6(this, "name");
|
2662
|
+
/**
|
2663
|
+
* Media type of this file.
|
2664
|
+
*/
|
2665
|
+
__publicField$6(this, "mediaType");
|
2666
|
+
/**
|
2667
|
+
* Base64 encoded content of this file.
|
2668
|
+
*/
|
2669
|
+
__publicField$6(this, "base64Content");
|
2670
|
+
/**
|
2671
|
+
* Whether to enable public url for this file.
|
2672
|
+
*/
|
2673
|
+
__publicField$6(this, "enablePublicUrl");
|
2674
|
+
/**
|
2675
|
+
* Timeout for the signed url.
|
2676
|
+
*/
|
2677
|
+
__publicField$6(this, "signedUrlTimeout");
|
2678
|
+
/**
|
2679
|
+
* Size of this file.
|
2680
|
+
*/
|
2681
|
+
__publicField$6(this, "size");
|
2682
|
+
/**
|
2683
|
+
* Version of this file.
|
2684
|
+
*/
|
2685
|
+
__publicField$6(this, "version");
|
2686
|
+
/**
|
2687
|
+
* Url of this file.
|
2688
|
+
*/
|
2689
|
+
__publicField$6(this, "url");
|
2690
|
+
/**
|
2691
|
+
* Signed url of this file.
|
2692
|
+
*/
|
2693
|
+
__publicField$6(this, "signedUrl");
|
2694
|
+
/**
|
2695
|
+
* Attributes of this file.
|
2696
|
+
*/
|
2697
|
+
__publicField$6(this, "attributes");
|
2698
|
+
this.name = file.name;
|
2699
|
+
this.mediaType = file.mediaType || "application/octet-stream";
|
2700
|
+
this.base64Content = file.base64Content;
|
2701
|
+
this.enablePublicUrl = file.enablePublicUrl;
|
2702
|
+
this.signedUrlTimeout = file.signedUrlTimeout;
|
2703
|
+
this.size = file.size;
|
2704
|
+
this.version = file.version;
|
2705
|
+
this.url = file.url;
|
2706
|
+
this.signedUrl = file.signedUrl;
|
2707
|
+
this.attributes = file.attributes;
|
2708
|
+
}
|
2709
|
+
static fromBuffer(buffer, options = {}) {
|
2710
|
+
const base64Content = buffer.toString("base64");
|
2711
|
+
return new XataFile({ ...options, base64Content });
|
2712
|
+
}
|
2713
|
+
toBuffer() {
|
2714
|
+
if (!this.base64Content) {
|
2715
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2716
|
+
}
|
2717
|
+
return Buffer.from(this.base64Content, "base64");
|
2718
|
+
}
|
2719
|
+
static fromArrayBuffer(arrayBuffer, options = {}) {
|
2720
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
2721
|
+
return this.fromUint8Array(uint8Array, options);
|
2722
|
+
}
|
2723
|
+
toArrayBuffer() {
|
2724
|
+
if (!this.base64Content) {
|
2725
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2726
|
+
}
|
2727
|
+
const binary = atob(this.base64Content);
|
2728
|
+
return new ArrayBuffer(binary.length);
|
2729
|
+
}
|
2730
|
+
static fromUint8Array(uint8Array, options = {}) {
|
2731
|
+
let binary = "";
|
2732
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
2733
|
+
binary += String.fromCharCode(uint8Array[i]);
|
2734
|
+
}
|
2735
|
+
const base64Content = btoa(binary);
|
2736
|
+
return new XataFile({ ...options, base64Content });
|
2737
|
+
}
|
2738
|
+
toUint8Array() {
|
2739
|
+
if (!this.base64Content) {
|
2740
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2741
|
+
}
|
2742
|
+
const binary = atob(this.base64Content);
|
2743
|
+
const uint8Array = new Uint8Array(binary.length);
|
2744
|
+
for (let i = 0; i < binary.length; i++) {
|
2745
|
+
uint8Array[i] = binary.charCodeAt(i);
|
2746
|
+
}
|
2747
|
+
return uint8Array;
|
2748
|
+
}
|
2749
|
+
static async fromBlob(file, options = {}) {
|
2750
|
+
const name = options.name ?? file.name;
|
2751
|
+
const mediaType = file.type;
|
2752
|
+
const arrayBuffer = await file.arrayBuffer();
|
2753
|
+
return this.fromArrayBuffer(arrayBuffer, { ...options, name, mediaType });
|
2754
|
+
}
|
2755
|
+
toBlob() {
|
2756
|
+
if (!this.base64Content) {
|
2757
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2758
|
+
}
|
2759
|
+
const arrayBuffer = this.toArrayBuffer();
|
2760
|
+
return new Blob([arrayBuffer], { type: this.mediaType });
|
2761
|
+
}
|
2762
|
+
static fromString(string, options = {}) {
|
2763
|
+
const base64Content = btoa(string);
|
2764
|
+
return new XataFile({ ...options, base64Content });
|
2765
|
+
}
|
2766
|
+
toString() {
|
2767
|
+
if (!this.base64Content) {
|
2768
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2769
|
+
}
|
2770
|
+
return atob(this.base64Content);
|
2771
|
+
}
|
2772
|
+
static fromBase64(base64Content, options = {}) {
|
2773
|
+
return new XataFile({ ...options, base64Content });
|
2774
|
+
}
|
2775
|
+
toBase64() {
|
2776
|
+
if (!this.base64Content) {
|
2777
|
+
throw new Error(`File content is not available, please select property "base64Content" when querying the file`);
|
2778
|
+
}
|
2779
|
+
return this.base64Content;
|
2780
|
+
}
|
2781
|
+
transform(...options) {
|
2782
|
+
return {
|
2783
|
+
url: transformImage(this.url, options),
|
2784
|
+
signedUrl: transformImage(this.signedUrl, options)
|
2785
|
+
};
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
const parseInputFileEntry = async (entry) => {
|
2789
|
+
if (!isDefined(entry))
|
2790
|
+
return null;
|
2791
|
+
const { id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout } = await entry;
|
2792
|
+
return compactObject({ id, name, mediaType, base64Content, enablePublicUrl, signedUrlTimeout });
|
2793
|
+
};
|
2794
|
+
|
2499
2795
|
function cleanFilter(filter) {
|
2500
|
-
if (!filter)
|
2796
|
+
if (!isDefined(filter))
|
2501
2797
|
return void 0;
|
2502
|
-
|
2503
|
-
|
2798
|
+
if (!isObject(filter))
|
2799
|
+
return filter;
|
2800
|
+
const values = Object.fromEntries(
|
2801
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2802
|
+
if (!isDefined(value))
|
2803
|
+
return acc;
|
2804
|
+
if (Array.isArray(value)) {
|
2805
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2806
|
+
if (clean.length === 0)
|
2807
|
+
return acc;
|
2808
|
+
return [...acc, [key, clean]];
|
2809
|
+
}
|
2810
|
+
if (isObject(value)) {
|
2811
|
+
const clean = cleanFilter(value);
|
2812
|
+
if (!isDefined(clean))
|
2813
|
+
return acc;
|
2814
|
+
return [...acc, [key, clean]];
|
2815
|
+
}
|
2816
|
+
return [...acc, [key, value]];
|
2817
|
+
}, [])
|
2818
|
+
);
|
2819
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2504
2820
|
}
|
2505
2821
|
|
2822
|
+
var __defProp$5 = Object.defineProperty;
|
2823
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2824
|
+
var __publicField$5 = (obj, key, value) => {
|
2825
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2826
|
+
return value;
|
2827
|
+
};
|
2506
2828
|
var __accessCheck$6 = (obj, member, msg) => {
|
2507
2829
|
if (!member.has(obj))
|
2508
2830
|
throw TypeError("Cannot " + msg);
|
@@ -2525,6 +2847,14 @@ var _query, _page;
|
|
2525
2847
|
class Page {
|
2526
2848
|
constructor(query, meta, records = []) {
|
2527
2849
|
__privateAdd$6(this, _query, void 0);
|
2850
|
+
/**
|
2851
|
+
* Page metadata, required to retrieve additional records.
|
2852
|
+
*/
|
2853
|
+
__publicField$5(this, "meta");
|
2854
|
+
/**
|
2855
|
+
* The set of results for this page.
|
2856
|
+
*/
|
2857
|
+
__publicField$5(this, "records");
|
2528
2858
|
__privateSet$6(this, _query, query);
|
2529
2859
|
this.meta = meta;
|
2530
2860
|
this.records = new RecordArray(this, records);
|
@@ -2581,7 +2911,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2581
2911
|
function isCursorPaginationOptions(options) {
|
2582
2912
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2583
2913
|
}
|
2584
|
-
const _RecordArray = class extends Array {
|
2914
|
+
const _RecordArray = class _RecordArray extends Array {
|
2585
2915
|
constructor(...args) {
|
2586
2916
|
super(..._RecordArray.parseConstructorParams(...args));
|
2587
2917
|
__privateAdd$6(this, _page, void 0);
|
@@ -2652,9 +2982,15 @@ const _RecordArray = class extends Array {
|
|
2652
2982
|
return __privateGet$6(this, _page).meta.page.more;
|
2653
2983
|
}
|
2654
2984
|
};
|
2655
|
-
let RecordArray = _RecordArray;
|
2656
2985
|
_page = new WeakMap();
|
2986
|
+
let RecordArray = _RecordArray;
|
2657
2987
|
|
2988
|
+
var __defProp$4 = Object.defineProperty;
|
2989
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2990
|
+
var __publicField$4 = (obj, key, value) => {
|
2991
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2992
|
+
return value;
|
2993
|
+
};
|
2658
2994
|
var __accessCheck$5 = (obj, member, msg) => {
|
2659
2995
|
if (!member.has(obj))
|
2660
2996
|
throw TypeError("Cannot " + msg);
|
@@ -2678,15 +3014,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2678
3014
|
return method;
|
2679
3015
|
};
|
2680
3016
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2681
|
-
const _Query = class {
|
3017
|
+
const _Query = class _Query {
|
2682
3018
|
constructor(repository, table, data, rawParent) {
|
2683
3019
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2684
3020
|
__privateAdd$5(this, _table$1, void 0);
|
2685
3021
|
__privateAdd$5(this, _repository, void 0);
|
2686
3022
|
__privateAdd$5(this, _data, { filter: {} });
|
2687
3023
|
// Implements pagination
|
2688
|
-
this
|
2689
|
-
this
|
3024
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
3025
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2690
3026
|
__privateSet$5(this, _table$1, table);
|
2691
3027
|
if (repository) {
|
2692
3028
|
__privateSet$5(this, _repository, repository);
|
@@ -2906,7 +3242,6 @@ const _Query = class {
|
|
2906
3242
|
return this.meta.page.more;
|
2907
3243
|
}
|
2908
3244
|
};
|
2909
|
-
let Query = _Query;
|
2910
3245
|
_table$1 = new WeakMap();
|
2911
3246
|
_repository = new WeakMap();
|
2912
3247
|
_data = new WeakMap();
|
@@ -2921,6 +3256,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2921
3256
|
}
|
2922
3257
|
return value;
|
2923
3258
|
};
|
3259
|
+
let Query = _Query;
|
2924
3260
|
function cleanParent(data, parent) {
|
2925
3261
|
if (isCursorPaginationOptions(data.pagination)) {
|
2926
3262
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2928,6 +3264,21 @@ function cleanParent(data, parent) {
|
|
2928
3264
|
return parent;
|
2929
3265
|
}
|
2930
3266
|
|
3267
|
+
const RecordColumnTypes = [
|
3268
|
+
"bool",
|
3269
|
+
"int",
|
3270
|
+
"float",
|
3271
|
+
"string",
|
3272
|
+
"text",
|
3273
|
+
"email",
|
3274
|
+
"multiple",
|
3275
|
+
"link",
|
3276
|
+
"object",
|
3277
|
+
"datetime",
|
3278
|
+
"vector",
|
3279
|
+
"file[]",
|
3280
|
+
"file"
|
3281
|
+
];
|
2931
3282
|
function isIdentifiable(x) {
|
2932
3283
|
return isObject(x) && isString(x?.id);
|
2933
3284
|
}
|
@@ -2986,7 +3337,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
2986
3337
|
__accessCheck$4(obj, member, "access private method");
|
2987
3338
|
return method;
|
2988
3339
|
};
|
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;
|
3340
|
+
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
3341
|
const BULK_OPERATION_MAX_SIZE = 1e3;
|
2991
3342
|
class Repository extends Query {
|
2992
3343
|
}
|
@@ -3008,6 +3359,7 @@ class RestRepository extends Query {
|
|
3008
3359
|
__privateAdd$4(this, _setCacheQuery);
|
3009
3360
|
__privateAdd$4(this, _getCacheQuery);
|
3010
3361
|
__privateAdd$4(this, _getSchemaTables$1);
|
3362
|
+
__privateAdd$4(this, _transformObjectToApi);
|
3011
3363
|
__privateAdd$4(this, _table, void 0);
|
3012
3364
|
__privateAdd$4(this, _getFetchProps, void 0);
|
3013
3365
|
__privateAdd$4(this, _db, void 0);
|
@@ -3399,23 +3751,28 @@ class RestRepository extends Query {
|
|
3399
3751
|
});
|
3400
3752
|
}
|
3401
3753
|
ask(question, options) {
|
3754
|
+
const questionParam = options?.sessionId ? { message: question } : { question };
|
3402
3755
|
const params = {
|
3403
3756
|
pathParams: {
|
3404
3757
|
workspace: "{workspaceId}",
|
3405
3758
|
dbBranchName: "{dbBranch}",
|
3406
3759
|
region: "{region}",
|
3407
|
-
tableName: __privateGet$4(this, _table)
|
3760
|
+
tableName: __privateGet$4(this, _table),
|
3761
|
+
sessionId: options?.sessionId
|
3408
3762
|
},
|
3409
3763
|
body: {
|
3410
|
-
|
3411
|
-
|
3764
|
+
...questionParam,
|
3765
|
+
rules: options?.rules,
|
3766
|
+
searchType: options?.searchType,
|
3767
|
+
search: options?.searchType === "keyword" ? options?.search : void 0,
|
3768
|
+
vectorSearch: options?.searchType === "vector" ? options?.vectorSearch : void 0
|
3412
3769
|
},
|
3413
3770
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3414
3771
|
};
|
3415
3772
|
if (options?.onMessage) {
|
3416
3773
|
fetchSSERequest({
|
3417
3774
|
endpoint: "dataPlane",
|
3418
|
-
url: "/db/{dbBranchName}/tables/{tableName}/ask",
|
3775
|
+
url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}",
|
3419
3776
|
method: "POST",
|
3420
3777
|
onMessage: (message) => {
|
3421
3778
|
options.onMessage?.({ answer: message.text, records: message.records });
|
@@ -3423,7 +3780,7 @@ class RestRepository extends Query {
|
|
3423
3780
|
...params
|
3424
3781
|
});
|
3425
3782
|
} else {
|
3426
|
-
return
|
3783
|
+
return askTableSession(params);
|
3427
3784
|
}
|
3428
3785
|
}
|
3429
3786
|
}
|
@@ -3435,7 +3792,7 @@ _schemaTables$2 = new WeakMap();
|
|
3435
3792
|
_trace = new WeakMap();
|
3436
3793
|
_insertRecordWithoutId = new WeakSet();
|
3437
3794
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
3438
|
-
const record =
|
3795
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3439
3796
|
const response = await insertRecord({
|
3440
3797
|
pathParams: {
|
3441
3798
|
workspace: "{workspaceId}",
|
@@ -3454,7 +3811,7 @@ _insertRecordWithId = new WeakSet();
|
|
3454
3811
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
3455
3812
|
if (!recordId)
|
3456
3813
|
return null;
|
3457
|
-
const record =
|
3814
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3458
3815
|
const response = await insertRecordWithID({
|
3459
3816
|
pathParams: {
|
3460
3817
|
workspace: "{workspaceId}",
|
@@ -3472,21 +3829,20 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { crea
|
|
3472
3829
|
};
|
3473
3830
|
_insertRecords = new WeakSet();
|
3474
3831
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3475
|
-
const
|
3476
|
-
|
3477
|
-
|
3478
|
-
|
3479
|
-
|
3480
|
-
);
|
3832
|
+
const operations = await promiseMap(objects, async (object) => {
|
3833
|
+
const record = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3834
|
+
return { insert: { table: __privateGet$4(this, _table), record, createOnly, ifVersion } };
|
3835
|
+
});
|
3836
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3481
3837
|
const ids = [];
|
3482
|
-
for (const
|
3838
|
+
for (const operations2 of chunkedOperations) {
|
3483
3839
|
const { results } = await branchTransaction({
|
3484
3840
|
pathParams: {
|
3485
3841
|
workspace: "{workspaceId}",
|
3486
3842
|
dbBranchName: "{dbBranch}",
|
3487
3843
|
region: "{region}"
|
3488
3844
|
},
|
3489
|
-
body: { operations },
|
3845
|
+
body: { operations: operations2 },
|
3490
3846
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3491
3847
|
});
|
3492
3848
|
for (const result of results) {
|
@@ -3503,7 +3859,7 @@ _updateRecordWithID = new WeakSet();
|
|
3503
3859
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3504
3860
|
if (!recordId)
|
3505
3861
|
return null;
|
3506
|
-
const { id: _id, ...record } =
|
3862
|
+
const { id: _id, ...record } = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3507
3863
|
try {
|
3508
3864
|
const response = await updateRecordWithID({
|
3509
3865
|
pathParams: {
|
@@ -3528,21 +3884,20 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3528
3884
|
};
|
3529
3885
|
_updateRecords = new WeakSet();
|
3530
3886
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3531
|
-
const
|
3532
|
-
|
3533
|
-
|
3534
|
-
|
3535
|
-
|
3536
|
-
);
|
3887
|
+
const operations = await promiseMap(objects, async ({ id, ...object }) => {
|
3888
|
+
const fields = await __privateMethod$2(this, _transformObjectToApi, transformObjectToApi_fn).call(this, object);
|
3889
|
+
return { update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields } };
|
3890
|
+
});
|
3891
|
+
const chunkedOperations = chunk(operations, BULK_OPERATION_MAX_SIZE);
|
3537
3892
|
const ids = [];
|
3538
|
-
for (const
|
3893
|
+
for (const operations2 of chunkedOperations) {
|
3539
3894
|
const { results } = await branchTransaction({
|
3540
3895
|
pathParams: {
|
3541
3896
|
workspace: "{workspaceId}",
|
3542
3897
|
dbBranchName: "{dbBranch}",
|
3543
3898
|
region: "{region}"
|
3544
3899
|
},
|
3545
|
-
body: { operations },
|
3900
|
+
body: { operations: operations2 },
|
3546
3901
|
...__privateGet$4(this, _getFetchProps).call(this)
|
3547
3902
|
});
|
3548
3903
|
for (const result of results) {
|
@@ -3645,7 +4000,39 @@ getSchemaTables_fn$1 = async function() {
|
|
3645
4000
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
3646
4001
|
return schema.tables;
|
3647
4002
|
};
|
3648
|
-
|
4003
|
+
_transformObjectToApi = new WeakSet();
|
4004
|
+
transformObjectToApi_fn = async function(object) {
|
4005
|
+
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
4006
|
+
const schema = schemaTables.find((table) => table.name === __privateGet$4(this, _table));
|
4007
|
+
if (!schema)
|
4008
|
+
throw new Error(`Table ${__privateGet$4(this, _table)} not found in schema`);
|
4009
|
+
const result = {};
|
4010
|
+
for (const [key, value] of Object.entries(object)) {
|
4011
|
+
if (key === "xata")
|
4012
|
+
continue;
|
4013
|
+
const type = schema.columns.find((column) => column.name === key)?.type;
|
4014
|
+
switch (type) {
|
4015
|
+
case "link": {
|
4016
|
+
result[key] = isIdentifiable(value) ? value.id : value;
|
4017
|
+
break;
|
4018
|
+
}
|
4019
|
+
case "datetime": {
|
4020
|
+
result[key] = value instanceof Date ? value.toISOString() : value;
|
4021
|
+
break;
|
4022
|
+
}
|
4023
|
+
case `file`:
|
4024
|
+
result[key] = await parseInputFileEntry(value);
|
4025
|
+
break;
|
4026
|
+
case "file[]":
|
4027
|
+
result[key] = await promiseMap(value, (item) => parseInputFileEntry(item));
|
4028
|
+
break;
|
4029
|
+
default:
|
4030
|
+
result[key] = value;
|
4031
|
+
}
|
4032
|
+
}
|
4033
|
+
return result;
|
4034
|
+
};
|
4035
|
+
const removeLinksFromObject = (object) => {
|
3649
4036
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
3650
4037
|
if (key === "xata")
|
3651
4038
|
return acc;
|
@@ -3694,6 +4081,12 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3694
4081
|
}
|
3695
4082
|
break;
|
3696
4083
|
}
|
4084
|
+
case "file":
|
4085
|
+
data[column.name] = isDefined(value) ? new XataFile(value) : null;
|
4086
|
+
break;
|
4087
|
+
case "file[]":
|
4088
|
+
data[column.name] = value?.map((item) => new XataFile(item)) ?? null;
|
4089
|
+
break;
|
3697
4090
|
default:
|
3698
4091
|
data[column.name] = value ?? null;
|
3699
4092
|
if (column.notNull === true && value === null) {
|
@@ -3703,7 +4096,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3703
4096
|
}
|
3704
4097
|
}
|
3705
4098
|
const record = { ...data };
|
3706
|
-
const serializable = { xata, ...
|
4099
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
3707
4100
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3708
4101
|
record.read = function(columns2) {
|
3709
4102
|
return db[table].read(record["id"], columns2);
|
@@ -3729,7 +4122,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3729
4122
|
return JSON.parse(JSON.stringify(serializable));
|
3730
4123
|
};
|
3731
4124
|
record.toString = function() {
|
3732
|
-
return JSON.stringify(
|
4125
|
+
return JSON.stringify(serializable);
|
3733
4126
|
};
|
3734
4127
|
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3735
4128
|
Object.defineProperty(record, prop, { enumerable: false });
|
@@ -3747,11 +4140,7 @@ function extractId(value) {
|
|
3747
4140
|
function isValidColumn(columns, column) {
|
3748
4141
|
if (columns.includes("*"))
|
3749
4142
|
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);
|
4143
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
3755
4144
|
}
|
3756
4145
|
function parseIfVersion(...args) {
|
3757
4146
|
for (const arg of args) {
|
@@ -3762,6 +4151,12 @@ function parseIfVersion(...args) {
|
|
3762
4151
|
return void 0;
|
3763
4152
|
}
|
3764
4153
|
|
4154
|
+
var __defProp$3 = Object.defineProperty;
|
4155
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4156
|
+
var __publicField$3 = (obj, key, value) => {
|
4157
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4158
|
+
return value;
|
4159
|
+
};
|
3765
4160
|
var __accessCheck$3 = (obj, member, msg) => {
|
3766
4161
|
if (!member.has(obj))
|
3767
4162
|
throw TypeError("Cannot " + msg);
|
@@ -3784,6 +4179,8 @@ var _map;
|
|
3784
4179
|
class SimpleCache {
|
3785
4180
|
constructor(options = {}) {
|
3786
4181
|
__privateAdd$3(this, _map, void 0);
|
4182
|
+
__publicField$3(this, "capacity");
|
4183
|
+
__publicField$3(this, "defaultQueryTTL");
|
3787
4184
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
3788
4185
|
this.capacity = options.max ?? 500;
|
3789
4186
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3981,6 +4378,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3981
4378
|
}
|
3982
4379
|
}
|
3983
4380
|
|
4381
|
+
var __defProp$2 = Object.defineProperty;
|
4382
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4383
|
+
var __publicField$2 = (obj, key, value) => {
|
4384
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4385
|
+
return value;
|
4386
|
+
};
|
3984
4387
|
var __accessCheck = (obj, member, msg) => {
|
3985
4388
|
if (!member.has(obj))
|
3986
4389
|
throw TypeError("Cannot " + msg);
|
@@ -4010,6 +4413,10 @@ const buildClient = (plugins) => {
|
|
4010
4413
|
__privateAdd(this, _parseOptions);
|
4011
4414
|
__privateAdd(this, _getFetchProps);
|
4012
4415
|
__privateAdd(this, _options, void 0);
|
4416
|
+
__publicField$2(this, "db");
|
4417
|
+
__publicField$2(this, "search");
|
4418
|
+
__publicField$2(this, "transactions");
|
4419
|
+
__publicField$2(this, "files");
|
4013
4420
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
4014
4421
|
__privateSet(this, _options, safeOptions);
|
4015
4422
|
const pluginOptions = {
|
@@ -4020,9 +4427,11 @@ const buildClient = (plugins) => {
|
|
4020
4427
|
const db = new SchemaPlugin(schemaTables).build(pluginOptions);
|
4021
4428
|
const search = new SearchPlugin(db, schemaTables).build(pluginOptions);
|
4022
4429
|
const transactions = new TransactionPlugin().build(pluginOptions);
|
4430
|
+
const files = new FilesPlugin().build(pluginOptions);
|
4023
4431
|
this.db = db;
|
4024
4432
|
this.search = search;
|
4025
4433
|
this.transactions = transactions;
|
4434
|
+
this.files = files;
|
4026
4435
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
4027
4436
|
if (namespace === void 0)
|
4028
4437
|
continue;
|
@@ -4119,11 +4528,17 @@ const buildClient = (plugins) => {
|
|
4119
4528
|
class BaseClient extends buildClient() {
|
4120
4529
|
}
|
4121
4530
|
|
4531
|
+
var __defProp$1 = Object.defineProperty;
|
4532
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4533
|
+
var __publicField$1 = (obj, key, value) => {
|
4534
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4535
|
+
return value;
|
4536
|
+
};
|
4122
4537
|
const META = "__";
|
4123
4538
|
const VALUE = "___";
|
4124
4539
|
class Serializer {
|
4125
4540
|
constructor() {
|
4126
|
-
this
|
4541
|
+
__publicField$1(this, "classes", {});
|
4127
4542
|
}
|
4128
4543
|
add(clazz) {
|
4129
4544
|
this.classes[clazz.name] = clazz;
|
@@ -4201,9 +4616,16 @@ function buildWorkerRunner(config) {
|
|
4201
4616
|
};
|
4202
4617
|
}
|
4203
4618
|
|
4619
|
+
var __defProp = Object.defineProperty;
|
4620
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4621
|
+
var __publicField = (obj, key, value) => {
|
4622
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4623
|
+
return value;
|
4624
|
+
};
|
4204
4625
|
class XataError extends Error {
|
4205
4626
|
constructor(message, status) {
|
4206
4627
|
super(message);
|
4628
|
+
__publicField(this, "status");
|
4207
4629
|
this.status = status;
|
4208
4630
|
}
|
4209
4631
|
}
|
@@ -4218,6 +4640,7 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
4218
4640
|
exports.Page = Page;
|
4219
4641
|
exports.Query = Query;
|
4220
4642
|
exports.RecordArray = RecordArray;
|
4643
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
4221
4644
|
exports.Repository = Repository;
|
4222
4645
|
exports.RestRepository = RestRepository;
|
4223
4646
|
exports.SchemaPlugin = SchemaPlugin;
|
@@ -4227,6 +4650,7 @@ exports.SimpleCache = SimpleCache;
|
|
4227
4650
|
exports.XataApiClient = XataApiClient;
|
4228
4651
|
exports.XataApiPlugin = XataApiPlugin;
|
4229
4652
|
exports.XataError = XataError;
|
4653
|
+
exports.XataFile = XataFile;
|
4230
4654
|
exports.XataPlugin = XataPlugin;
|
4231
4655
|
exports.acceptWorkspaceMemberInvite = acceptWorkspaceMemberInvite;
|
4232
4656
|
exports.addGitBranchesEntry = addGitBranchesEntry;
|
@@ -4234,6 +4658,7 @@ exports.addTableColumn = addTableColumn;
|
|
4234
4658
|
exports.aggregateTable = aggregateTable;
|
4235
4659
|
exports.applyBranchSchemaEdit = applyBranchSchemaEdit;
|
4236
4660
|
exports.askTable = askTable;
|
4661
|
+
exports.askTableSession = askTableSession;
|
4237
4662
|
exports.branchTransaction = branchTransaction;
|
4238
4663
|
exports.buildClient = buildClient;
|
4239
4664
|
exports.buildPreviewBranchName = buildPreviewBranchName;
|
@@ -4270,6 +4695,7 @@ exports.executeBranchMigrationPlan = executeBranchMigrationPlan;
|
|
4270
4695
|
exports.exists = exists;
|
4271
4696
|
exports.fileAccess = fileAccess;
|
4272
4697
|
exports.ge = ge;
|
4698
|
+
exports.generateAccessToken = generateAccessToken;
|
4273
4699
|
exports.getAPIKey = getAPIKey;
|
4274
4700
|
exports.getBranch = getBranch;
|
4275
4701
|
exports.getBranchDetails = getBranchDetails;
|
@@ -4299,6 +4725,7 @@ exports.getUserAPIKeys = getUserAPIKeys;
|
|
4299
4725
|
exports.getWorkspace = getWorkspace;
|
4300
4726
|
exports.getWorkspaceMembersList = getWorkspaceMembersList;
|
4301
4727
|
exports.getWorkspacesList = getWorkspacesList;
|
4728
|
+
exports.grantAuthorizationCode = grantAuthorizationCode;
|
4302
4729
|
exports.greaterEquals = greaterEquals;
|
4303
4730
|
exports.greaterThan = greaterThan;
|
4304
4731
|
exports.greaterThanEquals = greaterThanEquals;
|