@xata.io/client 0.0.0-alpha.vfa37ea7 → 0.0.0-alpha.vfaba5d6
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 +23 -1
- package/dist/index.cjs +200 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +229 -91
- package/dist/index.mjs +199 -39
- 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;
|
@@ -210,6 +213,12 @@ function getPreviewBranch() {
|
|
210
213
|
}
|
211
214
|
}
|
212
215
|
|
216
|
+
var __defProp$7 = Object.defineProperty;
|
217
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
218
|
+
var __publicField$7 = (obj, key, value) => {
|
219
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
220
|
+
return value;
|
221
|
+
};
|
213
222
|
var __accessCheck$8 = (obj, member, msg) => {
|
214
223
|
if (!member.has(obj))
|
215
224
|
throw TypeError("Cannot " + msg);
|
@@ -249,6 +258,8 @@ class ApiRequestPool {
|
|
249
258
|
__privateAdd$8(this, _fetch, void 0);
|
250
259
|
__privateAdd$8(this, _queue, void 0);
|
251
260
|
__privateAdd$8(this, _concurrency, void 0);
|
261
|
+
__publicField$7(this, "running");
|
262
|
+
__publicField$7(this, "started");
|
252
263
|
__privateSet$8(this, _queue, []);
|
253
264
|
__privateSet$8(this, _concurrency, concurrency);
|
254
265
|
this.running = 0;
|
@@ -490,16 +501,26 @@ function defaultOnOpen(response) {
|
|
490
501
|
}
|
491
502
|
}
|
492
503
|
|
493
|
-
const VERSION = "0.24.
|
504
|
+
const VERSION = "0.24.3";
|
494
505
|
|
506
|
+
var __defProp$6 = Object.defineProperty;
|
507
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
508
|
+
var __publicField$6 = (obj, key, value) => {
|
509
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
510
|
+
return value;
|
511
|
+
};
|
495
512
|
class ErrorWithCause extends Error {
|
496
513
|
constructor(message, options) {
|
497
514
|
super(message, options);
|
515
|
+
__publicField$6(this, "cause");
|
498
516
|
}
|
499
517
|
}
|
500
518
|
class FetcherError extends ErrorWithCause {
|
501
519
|
constructor(status, data, requestId) {
|
502
520
|
super(getMessage(data));
|
521
|
+
__publicField$6(this, "status");
|
522
|
+
__publicField$6(this, "requestId");
|
523
|
+
__publicField$6(this, "errors");
|
503
524
|
this.status = status;
|
504
525
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
505
526
|
this.requestId = requestId;
|
@@ -566,6 +587,15 @@ function hostHeader(url) {
|
|
566
587
|
const { groups } = pattern.exec(url) ?? {};
|
567
588
|
return groups?.host ? { Host: groups.host } : {};
|
568
589
|
}
|
590
|
+
function parseBody(body, headers) {
|
591
|
+
if (!isDefined(body))
|
592
|
+
return void 0;
|
593
|
+
const { "Content-Type": contentType } = headers ?? {};
|
594
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
595
|
+
return JSON.stringify(body);
|
596
|
+
}
|
597
|
+
return body;
|
598
|
+
}
|
569
599
|
const defaultClientID = generateUUID();
|
570
600
|
async function fetch$1({
|
571
601
|
url: path,
|
@@ -585,7 +615,8 @@ async function fetch$1({
|
|
585
615
|
sessionID,
|
586
616
|
clientName,
|
587
617
|
xataAgentExtra,
|
588
|
-
fetchOptions = {}
|
618
|
+
fetchOptions = {},
|
619
|
+
rawResponse = false
|
589
620
|
}) {
|
590
621
|
pool.setFetch(fetch2);
|
591
622
|
return await trace(
|
@@ -604,7 +635,7 @@ async function fetch$1({
|
|
604
635
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
605
636
|
...Object.entries(xataAgentExtra ?? {})
|
606
637
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
607
|
-
const headers = {
|
638
|
+
const headers = compactObject({
|
608
639
|
"Accept-Encoding": "identity",
|
609
640
|
"Content-Type": "application/json",
|
610
641
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -613,11 +644,11 @@ async function fetch$1({
|
|
613
644
|
...customHeaders,
|
614
645
|
...hostHeader(fullUrl),
|
615
646
|
Authorization: `Bearer ${apiKey}`
|
616
|
-
};
|
647
|
+
});
|
617
648
|
const response = await pool.request(url, {
|
618
649
|
...fetchOptions,
|
619
650
|
method: method.toUpperCase(),
|
620
|
-
body: body
|
651
|
+
body: parseBody(body, headers),
|
621
652
|
headers,
|
622
653
|
signal
|
623
654
|
});
|
@@ -630,6 +661,9 @@ async function fetch$1({
|
|
630
661
|
[TraceAttributes.HTTP_HOST]: host,
|
631
662
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
632
663
|
});
|
664
|
+
const message = response.headers?.get("x-xata-message");
|
665
|
+
if (message)
|
666
|
+
console.warn(message);
|
633
667
|
if (response.status === 204) {
|
634
668
|
return {};
|
635
669
|
}
|
@@ -637,7 +671,7 @@ async function fetch$1({
|
|
637
671
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
638
672
|
}
|
639
673
|
try {
|
640
|
-
const jsonResponse = await response.json();
|
674
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
641
675
|
if (response.ok) {
|
642
676
|
return jsonResponse;
|
643
677
|
}
|
@@ -910,6 +944,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
910
944
|
...variables,
|
911
945
|
signal
|
912
946
|
});
|
947
|
+
const chatSessionMessage = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
913
948
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
914
949
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
915
950
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -985,6 +1020,7 @@ const operationsByTag$2 = {
|
|
985
1020
|
sqlQuery,
|
986
1021
|
vectorSearchTable,
|
987
1022
|
askTable,
|
1023
|
+
chatSessionMessage,
|
988
1024
|
summarizeTable,
|
989
1025
|
aggregateTable
|
990
1026
|
}
|
@@ -2109,6 +2145,21 @@ class SearchAndFilterApi {
|
|
2109
2145
|
...this.extraProps
|
2110
2146
|
});
|
2111
2147
|
}
|
2148
|
+
chatSessionMessage({
|
2149
|
+
workspace,
|
2150
|
+
region,
|
2151
|
+
database,
|
2152
|
+
branch,
|
2153
|
+
table,
|
2154
|
+
sessionId,
|
2155
|
+
message
|
2156
|
+
}) {
|
2157
|
+
return operationsByTag.searchAndFilter.chatSessionMessage({
|
2158
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2159
|
+
body: { message },
|
2160
|
+
...this.extraProps
|
2161
|
+
});
|
2162
|
+
}
|
2112
2163
|
summarizeTable({
|
2113
2164
|
workspace,
|
2114
2165
|
region,
|
@@ -2495,12 +2546,38 @@ class XataPlugin {
|
|
2495
2546
|
}
|
2496
2547
|
|
2497
2548
|
function cleanFilter(filter) {
|
2498
|
-
if (!filter)
|
2549
|
+
if (!isDefined(filter))
|
2499
2550
|
return void 0;
|
2500
|
-
|
2501
|
-
|
2551
|
+
if (!isObject(filter))
|
2552
|
+
return filter;
|
2553
|
+
const values = Object.fromEntries(
|
2554
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2555
|
+
if (!isDefined(value))
|
2556
|
+
return acc;
|
2557
|
+
if (Array.isArray(value)) {
|
2558
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2559
|
+
if (clean.length === 0)
|
2560
|
+
return acc;
|
2561
|
+
return [...acc, [key, clean]];
|
2562
|
+
}
|
2563
|
+
if (isObject(value)) {
|
2564
|
+
const clean = cleanFilter(value);
|
2565
|
+
if (!isDefined(clean))
|
2566
|
+
return acc;
|
2567
|
+
return [...acc, [key, clean]];
|
2568
|
+
}
|
2569
|
+
return [...acc, [key, value]];
|
2570
|
+
}, [])
|
2571
|
+
);
|
2572
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2502
2573
|
}
|
2503
2574
|
|
2575
|
+
var __defProp$5 = Object.defineProperty;
|
2576
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2577
|
+
var __publicField$5 = (obj, key, value) => {
|
2578
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2579
|
+
return value;
|
2580
|
+
};
|
2504
2581
|
var __accessCheck$6 = (obj, member, msg) => {
|
2505
2582
|
if (!member.has(obj))
|
2506
2583
|
throw TypeError("Cannot " + msg);
|
@@ -2523,6 +2600,14 @@ var _query, _page;
|
|
2523
2600
|
class Page {
|
2524
2601
|
constructor(query, meta, records = []) {
|
2525
2602
|
__privateAdd$6(this, _query, void 0);
|
2603
|
+
/**
|
2604
|
+
* Page metadata, required to retrieve additional records.
|
2605
|
+
*/
|
2606
|
+
__publicField$5(this, "meta");
|
2607
|
+
/**
|
2608
|
+
* The set of results for this page.
|
2609
|
+
*/
|
2610
|
+
__publicField$5(this, "records");
|
2526
2611
|
__privateSet$6(this, _query, query);
|
2527
2612
|
this.meta = meta;
|
2528
2613
|
this.records = new RecordArray(this, records);
|
@@ -2579,7 +2664,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2579
2664
|
function isCursorPaginationOptions(options) {
|
2580
2665
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2581
2666
|
}
|
2582
|
-
const _RecordArray = class extends Array {
|
2667
|
+
const _RecordArray = class _RecordArray extends Array {
|
2583
2668
|
constructor(...args) {
|
2584
2669
|
super(..._RecordArray.parseConstructorParams(...args));
|
2585
2670
|
__privateAdd$6(this, _page, void 0);
|
@@ -2650,9 +2735,15 @@ const _RecordArray = class extends Array {
|
|
2650
2735
|
return __privateGet$6(this, _page).meta.page.more;
|
2651
2736
|
}
|
2652
2737
|
};
|
2653
|
-
let RecordArray = _RecordArray;
|
2654
2738
|
_page = new WeakMap();
|
2739
|
+
let RecordArray = _RecordArray;
|
2655
2740
|
|
2741
|
+
var __defProp$4 = Object.defineProperty;
|
2742
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2743
|
+
var __publicField$4 = (obj, key, value) => {
|
2744
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2745
|
+
return value;
|
2746
|
+
};
|
2656
2747
|
var __accessCheck$5 = (obj, member, msg) => {
|
2657
2748
|
if (!member.has(obj))
|
2658
2749
|
throw TypeError("Cannot " + msg);
|
@@ -2676,15 +2767,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2676
2767
|
return method;
|
2677
2768
|
};
|
2678
2769
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2679
|
-
const _Query = class {
|
2770
|
+
const _Query = class _Query {
|
2680
2771
|
constructor(repository, table, data, rawParent) {
|
2681
2772
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2682
2773
|
__privateAdd$5(this, _table$1, void 0);
|
2683
2774
|
__privateAdd$5(this, _repository, void 0);
|
2684
2775
|
__privateAdd$5(this, _data, { filter: {} });
|
2685
2776
|
// Implements pagination
|
2686
|
-
this
|
2687
|
-
this
|
2777
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
2778
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2688
2779
|
__privateSet$5(this, _table$1, table);
|
2689
2780
|
if (repository) {
|
2690
2781
|
__privateSet$5(this, _repository, repository);
|
@@ -2904,7 +2995,6 @@ const _Query = class {
|
|
2904
2995
|
return this.meta.page.more;
|
2905
2996
|
}
|
2906
2997
|
};
|
2907
|
-
let Query = _Query;
|
2908
2998
|
_table$1 = new WeakMap();
|
2909
2999
|
_repository = new WeakMap();
|
2910
3000
|
_data = new WeakMap();
|
@@ -2919,6 +3009,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2919
3009
|
}
|
2920
3010
|
return value;
|
2921
3011
|
};
|
3012
|
+
let Query = _Query;
|
2922
3013
|
function cleanParent(data, parent) {
|
2923
3014
|
if (isCursorPaginationOptions(data.pagination)) {
|
2924
3015
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2926,6 +3017,21 @@ function cleanParent(data, parent) {
|
|
2926
3017
|
return parent;
|
2927
3018
|
}
|
2928
3019
|
|
3020
|
+
const RecordColumnTypes = [
|
3021
|
+
"bool",
|
3022
|
+
"int",
|
3023
|
+
"float",
|
3024
|
+
"string",
|
3025
|
+
"text",
|
3026
|
+
"email",
|
3027
|
+
"multiple",
|
3028
|
+
"link",
|
3029
|
+
"object",
|
3030
|
+
"datetime",
|
3031
|
+
"vector",
|
3032
|
+
"file[]",
|
3033
|
+
"file"
|
3034
|
+
];
|
2929
3035
|
function isIdentifiable(x) {
|
2930
3036
|
return isObject(x) && isString(x?.id);
|
2931
3037
|
}
|
@@ -3183,12 +3289,22 @@ class RestRepository extends Query {
|
|
3183
3289
|
return result;
|
3184
3290
|
}
|
3185
3291
|
if (isString(a) && isObject(b)) {
|
3292
|
+
if (a === "")
|
3293
|
+
throw new Error("The id can't be empty");
|
3186
3294
|
const columns = isStringArray(c) ? c : void 0;
|
3187
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3295
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3188
3296
|
}
|
3189
3297
|
if (isObject(a) && isString(a.id)) {
|
3298
|
+
if (a.id === "")
|
3299
|
+
throw new Error("The id can't be empty");
|
3190
3300
|
const columns = isStringArray(c) ? c : void 0;
|
3191
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3301
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3302
|
+
}
|
3303
|
+
if (!isDefined(a) && isObject(b)) {
|
3304
|
+
return await this.create(b, c);
|
3305
|
+
}
|
3306
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3307
|
+
return await this.create(a, b);
|
3192
3308
|
}
|
3193
3309
|
throw new Error("Invalid arguments for createOrUpdate method");
|
3194
3310
|
});
|
@@ -3205,12 +3321,22 @@ class RestRepository extends Query {
|
|
3205
3321
|
return result;
|
3206
3322
|
}
|
3207
3323
|
if (isString(a) && isObject(b)) {
|
3324
|
+
if (a === "")
|
3325
|
+
throw new Error("The id can't be empty");
|
3208
3326
|
const columns = isStringArray(c) ? c : void 0;
|
3209
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3327
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3210
3328
|
}
|
3211
3329
|
if (isObject(a) && isString(a.id)) {
|
3330
|
+
if (a.id === "")
|
3331
|
+
throw new Error("The id can't be empty");
|
3212
3332
|
const columns = isStringArray(c) ? c : void 0;
|
3213
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3333
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3334
|
+
}
|
3335
|
+
if (!isDefined(a) && isObject(b)) {
|
3336
|
+
return await this.create(b, c);
|
3337
|
+
}
|
3338
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3339
|
+
return await this.create(a, b);
|
3214
3340
|
}
|
3215
3341
|
throw new Error("Invalid arguments for createOrReplace method");
|
3216
3342
|
});
|
@@ -3413,7 +3539,7 @@ _schemaTables$2 = new WeakMap();
|
|
3413
3539
|
_trace = new WeakMap();
|
3414
3540
|
_insertRecordWithoutId = new WeakSet();
|
3415
3541
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
3416
|
-
const record =
|
3542
|
+
const record = removeLinksFromObject(object);
|
3417
3543
|
const response = await insertRecord({
|
3418
3544
|
pathParams: {
|
3419
3545
|
workspace: "{workspaceId}",
|
@@ -3430,7 +3556,9 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
3430
3556
|
};
|
3431
3557
|
_insertRecordWithId = new WeakSet();
|
3432
3558
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
3433
|
-
|
3559
|
+
if (!recordId)
|
3560
|
+
return null;
|
3561
|
+
const record = removeLinksFromObject(object);
|
3434
3562
|
const response = await insertRecordWithID({
|
3435
3563
|
pathParams: {
|
3436
3564
|
workspace: "{workspaceId}",
|
@@ -3450,7 +3578,7 @@ _insertRecords = new WeakSet();
|
|
3450
3578
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3451
3579
|
const chunkedOperations = chunk(
|
3452
3580
|
objects.map((object) => ({
|
3453
|
-
insert: { table: __privateGet$4(this, _table), record:
|
3581
|
+
insert: { table: __privateGet$4(this, _table), record: removeLinksFromObject(object), createOnly, ifVersion }
|
3454
3582
|
})),
|
3455
3583
|
BULK_OPERATION_MAX_SIZE
|
3456
3584
|
);
|
@@ -3477,7 +3605,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3477
3605
|
};
|
3478
3606
|
_updateRecordWithID = new WeakSet();
|
3479
3607
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3480
|
-
|
3608
|
+
if (!recordId)
|
3609
|
+
return null;
|
3610
|
+
const { id: _id, ...record } = removeLinksFromObject(object);
|
3481
3611
|
try {
|
3482
3612
|
const response = await updateRecordWithID({
|
3483
3613
|
pathParams: {
|
@@ -3504,7 +3634,7 @@ _updateRecords = new WeakSet();
|
|
3504
3634
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3505
3635
|
const chunkedOperations = chunk(
|
3506
3636
|
objects.map(({ id, ...object }) => ({
|
3507
|
-
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields:
|
3637
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: removeLinksFromObject(object) }
|
3508
3638
|
})),
|
3509
3639
|
BULK_OPERATION_MAX_SIZE
|
3510
3640
|
);
|
@@ -3531,6 +3661,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3531
3661
|
};
|
3532
3662
|
_upsertRecordWithID = new WeakSet();
|
3533
3663
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3664
|
+
if (!recordId)
|
3665
|
+
return null;
|
3534
3666
|
const response = await upsertRecordWithID({
|
3535
3667
|
pathParams: {
|
3536
3668
|
workspace: "{workspaceId}",
|
@@ -3548,6 +3680,8 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3548
3680
|
};
|
3549
3681
|
_deleteRecord = new WeakSet();
|
3550
3682
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
3683
|
+
if (!recordId)
|
3684
|
+
return null;
|
3551
3685
|
try {
|
3552
3686
|
const response = await deleteRecord({
|
3553
3687
|
pathParams: {
|
@@ -3572,7 +3706,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
3572
3706
|
_deleteRecords = new WeakSet();
|
3573
3707
|
deleteRecords_fn = async function(recordIds) {
|
3574
3708
|
const chunkedOperations = chunk(
|
3575
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3709
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3576
3710
|
BULK_OPERATION_MAX_SIZE
|
3577
3711
|
);
|
3578
3712
|
for (const operations of chunkedOperations) {
|
@@ -3615,7 +3749,7 @@ getSchemaTables_fn$1 = async function() {
|
|
3615
3749
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
3616
3750
|
return schema.tables;
|
3617
3751
|
};
|
3618
|
-
const
|
3752
|
+
const removeLinksFromObject = (object) => {
|
3619
3753
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
3620
3754
|
if (key === "xata")
|
3621
3755
|
return acc;
|
@@ -3673,7 +3807,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3673
3807
|
}
|
3674
3808
|
}
|
3675
3809
|
const record = { ...data };
|
3676
|
-
const serializable = { xata, ...
|
3810
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
3677
3811
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3678
3812
|
record.read = function(columns2) {
|
3679
3813
|
return db[table].read(record["id"], columns2);
|
@@ -3691,17 +3825,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3691
3825
|
record.delete = function() {
|
3692
3826
|
return db[table].delete(record["id"]);
|
3693
3827
|
};
|
3694
|
-
record.xata = metadata;
|
3828
|
+
record.xata = Object.freeze(metadata);
|
3695
3829
|
record.getMetadata = function() {
|
3696
|
-
return
|
3830
|
+
return record.xata;
|
3697
3831
|
};
|
3698
3832
|
record.toSerializable = function() {
|
3699
3833
|
return JSON.parse(JSON.stringify(serializable));
|
3700
3834
|
};
|
3701
3835
|
record.toString = function() {
|
3702
|
-
return JSON.stringify(
|
3836
|
+
return JSON.stringify(serializable);
|
3703
3837
|
};
|
3704
|
-
for (const prop of ["read", "update", "replace", "delete", "
|
3838
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3705
3839
|
Object.defineProperty(record, prop, { enumerable: false });
|
3706
3840
|
}
|
3707
3841
|
Object.freeze(record);
|
@@ -3717,11 +3851,7 @@ function extractId(value) {
|
|
3717
3851
|
function isValidColumn(columns, column) {
|
3718
3852
|
if (columns.includes("*"))
|
3719
3853
|
return true;
|
3720
|
-
|
3721
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3722
|
-
return linkColumns.length > 0;
|
3723
|
-
}
|
3724
|
-
return columns.includes(column.name);
|
3854
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
3725
3855
|
}
|
3726
3856
|
function parseIfVersion(...args) {
|
3727
3857
|
for (const arg of args) {
|
@@ -3732,6 +3862,12 @@ function parseIfVersion(...args) {
|
|
3732
3862
|
return void 0;
|
3733
3863
|
}
|
3734
3864
|
|
3865
|
+
var __defProp$3 = Object.defineProperty;
|
3866
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3867
|
+
var __publicField$3 = (obj, key, value) => {
|
3868
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3869
|
+
return value;
|
3870
|
+
};
|
3735
3871
|
var __accessCheck$3 = (obj, member, msg) => {
|
3736
3872
|
if (!member.has(obj))
|
3737
3873
|
throw TypeError("Cannot " + msg);
|
@@ -3754,6 +3890,8 @@ var _map;
|
|
3754
3890
|
class SimpleCache {
|
3755
3891
|
constructor(options = {}) {
|
3756
3892
|
__privateAdd$3(this, _map, void 0);
|
3893
|
+
__publicField$3(this, "capacity");
|
3894
|
+
__publicField$3(this, "defaultQueryTTL");
|
3757
3895
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
3758
3896
|
this.capacity = options.max ?? 500;
|
3759
3897
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3951,6 +4089,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3951
4089
|
}
|
3952
4090
|
}
|
3953
4091
|
|
4092
|
+
var __defProp$2 = Object.defineProperty;
|
4093
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4094
|
+
var __publicField$2 = (obj, key, value) => {
|
4095
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4096
|
+
return value;
|
4097
|
+
};
|
3954
4098
|
var __accessCheck = (obj, member, msg) => {
|
3955
4099
|
if (!member.has(obj))
|
3956
4100
|
throw TypeError("Cannot " + msg);
|
@@ -3980,6 +4124,9 @@ const buildClient = (plugins) => {
|
|
3980
4124
|
__privateAdd(this, _parseOptions);
|
3981
4125
|
__privateAdd(this, _getFetchProps);
|
3982
4126
|
__privateAdd(this, _options, void 0);
|
4127
|
+
__publicField$2(this, "db");
|
4128
|
+
__publicField$2(this, "search");
|
4129
|
+
__publicField$2(this, "transactions");
|
3983
4130
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3984
4131
|
__privateSet(this, _options, safeOptions);
|
3985
4132
|
const pluginOptions = {
|
@@ -4089,11 +4236,17 @@ const buildClient = (plugins) => {
|
|
4089
4236
|
class BaseClient extends buildClient() {
|
4090
4237
|
}
|
4091
4238
|
|
4239
|
+
var __defProp$1 = Object.defineProperty;
|
4240
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4241
|
+
var __publicField$1 = (obj, key, value) => {
|
4242
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4243
|
+
return value;
|
4244
|
+
};
|
4092
4245
|
const META = "__";
|
4093
4246
|
const VALUE = "___";
|
4094
4247
|
class Serializer {
|
4095
4248
|
constructor() {
|
4096
|
-
this
|
4249
|
+
__publicField$1(this, "classes", {});
|
4097
4250
|
}
|
4098
4251
|
add(clazz) {
|
4099
4252
|
this.classes[clazz.name] = clazz;
|
@@ -4171,12 +4324,19 @@ function buildWorkerRunner(config) {
|
|
4171
4324
|
};
|
4172
4325
|
}
|
4173
4326
|
|
4327
|
+
var __defProp = Object.defineProperty;
|
4328
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4329
|
+
var __publicField = (obj, key, value) => {
|
4330
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4331
|
+
return value;
|
4332
|
+
};
|
4174
4333
|
class XataError extends Error {
|
4175
4334
|
constructor(message, status) {
|
4176
4335
|
super(message);
|
4336
|
+
__publicField(this, "status");
|
4177
4337
|
this.status = status;
|
4178
4338
|
}
|
4179
4339
|
}
|
4180
4340
|
|
4181
|
-
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 };
|
4341
|
+
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, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, aggregateTable, applyBranchSchemaEdit, askTable, branchTransaction, buildClient, buildPreviewBranchName, buildProviderString, buildWorkerRunner, bulkInsertTableRecords, cancelWorkspaceMemberInvite, chatSessionMessage, 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 };
|
4182
4342
|
//# sourceMappingURL=index.mjs.map
|