@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/.turbo/turbo-build.log
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
|
2
|
-
> @xata.io/client@0.24.
|
2
|
+
> @xata.io/client@0.24.3 build /home/runner/work/client-ts/client-ts/packages/client
|
3
3
|
> rimraf dist && rollup -c
|
4
4
|
|
5
5
|
[36m
|
6
6
|
[1msrc/index.ts[22m → [1mdist/index.cjs[22m...[39m
|
7
|
-
[32mcreated [1mdist/index.cjs[22m in [1m1.
|
7
|
+
[32mcreated [1mdist/index.cjs[22m in [1m1.1s[22m[39m
|
8
8
|
[36m
|
9
9
|
[1msrc/index.ts[22m → [1mdist/index.mjs[22m...[39m
|
10
|
-
[32mcreated [1mdist/index.mjs[22m in [
|
10
|
+
[32mcreated [1mdist/index.mjs[22m in [1m695ms[22m[39m
|
11
11
|
[36m
|
12
12
|
[1msrc/index.ts[22m → [1mdist/index.d.ts[22m...[39m
|
13
|
-
[
|
13
|
+
[1m[33m(!) Circular dependencies[39m[22m
|
14
|
+
src/api/index.ts -> src/plugins.ts -> src/api/index.ts
|
15
|
+
src/api/index.ts -> src/api/client.ts -> src/api/components.ts -> src/api/controlPlaneComponents.ts -> src/api/controlPlaneFetcher.ts -> src/api/errors.ts -> src/api/index.ts
|
16
|
+
src/schema/record.ts -> src/schema/selection.ts -> src/schema/record.ts
|
17
|
+
...and 6 more
|
18
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m6.1s[22m[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,11 +1,33 @@
|
|
1
1
|
# @xata.io/client
|
2
2
|
|
3
|
-
## 0.0.0-alpha.
|
3
|
+
## 0.0.0-alpha.vfaba5d6
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
7
|
- Force canary build
|
8
8
|
|
9
|
+
- [#1067](https://github.com/xataio/client-ts/pull/1067) [`c1f2d264`](https://github.com/xataio/client-ts/commit/c1f2d2649e077cdffae97c90b9d2b1c75d6858fb) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix error 400 with partial filters
|
10
|
+
|
11
|
+
## 0.24.3
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- [#1033](https://github.com/xataio/client-ts/pull/1033) [`f01d1580`](https://github.com/xataio/client-ts/commit/f01d1580fc450cbf06eb8af85d68cf052fbe83a1) Thanks [@xata-bot](https://github.com/xata-bot)! - [OpenAPI] Spec updates for column selection
|
16
|
+
|
17
|
+
- [#1044](https://github.com/xataio/client-ts/pull/1044) [`52290feb`](https://github.com/xataio/client-ts/commit/52290feb5bba57384cdc14e7722fb5d9883dc581) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow undefined with createOrUpdate/createOrReplace
|
18
|
+
|
19
|
+
## 0.24.2
|
20
|
+
|
21
|
+
### Patch Changes
|
22
|
+
|
23
|
+
- [#1038](https://github.com/xataio/client-ts/pull/1038) [`51561b52`](https://github.com/xataio/client-ts/commit/51561b52b56ad5ed9101d8faf12929891419cb2c) Thanks [@SferaDev](https://github.com/SferaDev)! - Show internal columns in filters
|
24
|
+
|
25
|
+
## 0.24.1
|
26
|
+
|
27
|
+
### Patch Changes
|
28
|
+
|
29
|
+
- [#1030](https://github.com/xataio/client-ts/pull/1030) [`eaa774f5`](https://github.com/xataio/client-ts/commit/eaa774f542185ef92448155bcdff331686c4da9f) Thanks [@SferaDev](https://github.com/SferaDev)! - Make `xata` property enumerable
|
30
|
+
|
9
31
|
## 0.24.0
|
10
32
|
|
11
33
|
### Minor Changes
|
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;
|
@@ -212,6 +215,12 @@ function getPreviewBranch() {
|
|
212
215
|
}
|
213
216
|
}
|
214
217
|
|
218
|
+
var __defProp$7 = Object.defineProperty;
|
219
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
220
|
+
var __publicField$7 = (obj, key, value) => {
|
221
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
222
|
+
return value;
|
223
|
+
};
|
215
224
|
var __accessCheck$8 = (obj, member, msg) => {
|
216
225
|
if (!member.has(obj))
|
217
226
|
throw TypeError("Cannot " + msg);
|
@@ -251,6 +260,8 @@ class ApiRequestPool {
|
|
251
260
|
__privateAdd$8(this, _fetch, void 0);
|
252
261
|
__privateAdd$8(this, _queue, void 0);
|
253
262
|
__privateAdd$8(this, _concurrency, void 0);
|
263
|
+
__publicField$7(this, "running");
|
264
|
+
__publicField$7(this, "started");
|
254
265
|
__privateSet$8(this, _queue, []);
|
255
266
|
__privateSet$8(this, _concurrency, concurrency);
|
256
267
|
this.running = 0;
|
@@ -492,16 +503,26 @@ function defaultOnOpen(response) {
|
|
492
503
|
}
|
493
504
|
}
|
494
505
|
|
495
|
-
const VERSION = "0.24.
|
506
|
+
const VERSION = "0.24.3";
|
496
507
|
|
508
|
+
var __defProp$6 = Object.defineProperty;
|
509
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
510
|
+
var __publicField$6 = (obj, key, value) => {
|
511
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
512
|
+
return value;
|
513
|
+
};
|
497
514
|
class ErrorWithCause extends Error {
|
498
515
|
constructor(message, options) {
|
499
516
|
super(message, options);
|
517
|
+
__publicField$6(this, "cause");
|
500
518
|
}
|
501
519
|
}
|
502
520
|
class FetcherError extends ErrorWithCause {
|
503
521
|
constructor(status, data, requestId) {
|
504
522
|
super(getMessage(data));
|
523
|
+
__publicField$6(this, "status");
|
524
|
+
__publicField$6(this, "requestId");
|
525
|
+
__publicField$6(this, "errors");
|
505
526
|
this.status = status;
|
506
527
|
this.errors = isBulkError(data) ? data.errors : [{ message: getMessage(data), status }];
|
507
528
|
this.requestId = requestId;
|
@@ -568,6 +589,15 @@ function hostHeader(url) {
|
|
568
589
|
const { groups } = pattern.exec(url) ?? {};
|
569
590
|
return groups?.host ? { Host: groups.host } : {};
|
570
591
|
}
|
592
|
+
function parseBody(body, headers) {
|
593
|
+
if (!isDefined(body))
|
594
|
+
return void 0;
|
595
|
+
const { "Content-Type": contentType } = headers ?? {};
|
596
|
+
if (String(contentType).toLowerCase() === "application/json") {
|
597
|
+
return JSON.stringify(body);
|
598
|
+
}
|
599
|
+
return body;
|
600
|
+
}
|
571
601
|
const defaultClientID = generateUUID();
|
572
602
|
async function fetch$1({
|
573
603
|
url: path,
|
@@ -587,7 +617,8 @@ async function fetch$1({
|
|
587
617
|
sessionID,
|
588
618
|
clientName,
|
589
619
|
xataAgentExtra,
|
590
|
-
fetchOptions = {}
|
620
|
+
fetchOptions = {},
|
621
|
+
rawResponse = false
|
591
622
|
}) {
|
592
623
|
pool.setFetch(fetch2);
|
593
624
|
return await trace(
|
@@ -606,7 +637,7 @@ async function fetch$1({
|
|
606
637
|
isDefined(clientName) ? ["service", clientName] : void 0,
|
607
638
|
...Object.entries(xataAgentExtra ?? {})
|
608
639
|
]).map(([key, value]) => `${key}=${value}`).join("; ");
|
609
|
-
const headers = {
|
640
|
+
const headers = compactObject({
|
610
641
|
"Accept-Encoding": "identity",
|
611
642
|
"Content-Type": "application/json",
|
612
643
|
"X-Xata-Client-ID": clientID ?? defaultClientID,
|
@@ -615,11 +646,11 @@ async function fetch$1({
|
|
615
646
|
...customHeaders,
|
616
647
|
...hostHeader(fullUrl),
|
617
648
|
Authorization: `Bearer ${apiKey}`
|
618
|
-
};
|
649
|
+
});
|
619
650
|
const response = await pool.request(url, {
|
620
651
|
...fetchOptions,
|
621
652
|
method: method.toUpperCase(),
|
622
|
-
body: body
|
653
|
+
body: parseBody(body, headers),
|
623
654
|
headers,
|
624
655
|
signal
|
625
656
|
});
|
@@ -632,6 +663,9 @@ async function fetch$1({
|
|
632
663
|
[TraceAttributes.HTTP_HOST]: host,
|
633
664
|
[TraceAttributes.HTTP_SCHEME]: protocol?.replace(":", "")
|
634
665
|
});
|
666
|
+
const message = response.headers?.get("x-xata-message");
|
667
|
+
if (message)
|
668
|
+
console.warn(message);
|
635
669
|
if (response.status === 204) {
|
636
670
|
return {};
|
637
671
|
}
|
@@ -639,7 +673,7 @@ async function fetch$1({
|
|
639
673
|
throw new FetcherError(response.status, "Rate limit exceeded", requestId);
|
640
674
|
}
|
641
675
|
try {
|
642
|
-
const jsonResponse = await response.json();
|
676
|
+
const jsonResponse = rawResponse ? await response.blob() : await response.json();
|
643
677
|
if (response.ok) {
|
644
678
|
return jsonResponse;
|
645
679
|
}
|
@@ -912,6 +946,7 @@ const askTable = (variables, signal) => dataPlaneFetch({
|
|
912
946
|
...variables,
|
913
947
|
signal
|
914
948
|
});
|
949
|
+
const chatSessionMessage = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/ask/{sessionId}", method: "post", ...variables, signal });
|
915
950
|
const summarizeTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/summarize", method: "post", ...variables, signal });
|
916
951
|
const aggregateTable = (variables, signal) => dataPlaneFetch({ url: "/db/{dbBranchName}/tables/{tableName}/aggregate", method: "post", ...variables, signal });
|
917
952
|
const fileAccess = (variables, signal) => dataPlaneFetch({
|
@@ -987,6 +1022,7 @@ const operationsByTag$2 = {
|
|
987
1022
|
sqlQuery,
|
988
1023
|
vectorSearchTable,
|
989
1024
|
askTable,
|
1025
|
+
chatSessionMessage,
|
990
1026
|
summarizeTable,
|
991
1027
|
aggregateTable
|
992
1028
|
}
|
@@ -2111,6 +2147,21 @@ class SearchAndFilterApi {
|
|
2111
2147
|
...this.extraProps
|
2112
2148
|
});
|
2113
2149
|
}
|
2150
|
+
chatSessionMessage({
|
2151
|
+
workspace,
|
2152
|
+
region,
|
2153
|
+
database,
|
2154
|
+
branch,
|
2155
|
+
table,
|
2156
|
+
sessionId,
|
2157
|
+
message
|
2158
|
+
}) {
|
2159
|
+
return operationsByTag.searchAndFilter.chatSessionMessage({
|
2160
|
+
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, tableName: table, sessionId },
|
2161
|
+
body: { message },
|
2162
|
+
...this.extraProps
|
2163
|
+
});
|
2164
|
+
}
|
2114
2165
|
summarizeTable({
|
2115
2166
|
workspace,
|
2116
2167
|
region,
|
@@ -2497,12 +2548,38 @@ class XataPlugin {
|
|
2497
2548
|
}
|
2498
2549
|
|
2499
2550
|
function cleanFilter(filter) {
|
2500
|
-
if (!filter)
|
2551
|
+
if (!isDefined(filter))
|
2501
2552
|
return void 0;
|
2502
|
-
|
2503
|
-
|
2553
|
+
if (!isObject(filter))
|
2554
|
+
return filter;
|
2555
|
+
const values = Object.fromEntries(
|
2556
|
+
Object.entries(filter).reduce((acc, [key, value]) => {
|
2557
|
+
if (!isDefined(value))
|
2558
|
+
return acc;
|
2559
|
+
if (Array.isArray(value)) {
|
2560
|
+
const clean = value.map((item) => cleanFilter(item)).filter((item) => isDefined(item));
|
2561
|
+
if (clean.length === 0)
|
2562
|
+
return acc;
|
2563
|
+
return [...acc, [key, clean]];
|
2564
|
+
}
|
2565
|
+
if (isObject(value)) {
|
2566
|
+
const clean = cleanFilter(value);
|
2567
|
+
if (!isDefined(clean))
|
2568
|
+
return acc;
|
2569
|
+
return [...acc, [key, clean]];
|
2570
|
+
}
|
2571
|
+
return [...acc, [key, value]];
|
2572
|
+
}, [])
|
2573
|
+
);
|
2574
|
+
return Object.keys(values).length > 0 ? values : void 0;
|
2504
2575
|
}
|
2505
2576
|
|
2577
|
+
var __defProp$5 = Object.defineProperty;
|
2578
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2579
|
+
var __publicField$5 = (obj, key, value) => {
|
2580
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2581
|
+
return value;
|
2582
|
+
};
|
2506
2583
|
var __accessCheck$6 = (obj, member, msg) => {
|
2507
2584
|
if (!member.has(obj))
|
2508
2585
|
throw TypeError("Cannot " + msg);
|
@@ -2525,6 +2602,14 @@ var _query, _page;
|
|
2525
2602
|
class Page {
|
2526
2603
|
constructor(query, meta, records = []) {
|
2527
2604
|
__privateAdd$6(this, _query, void 0);
|
2605
|
+
/**
|
2606
|
+
* Page metadata, required to retrieve additional records.
|
2607
|
+
*/
|
2608
|
+
__publicField$5(this, "meta");
|
2609
|
+
/**
|
2610
|
+
* The set of results for this page.
|
2611
|
+
*/
|
2612
|
+
__publicField$5(this, "records");
|
2528
2613
|
__privateSet$6(this, _query, query);
|
2529
2614
|
this.meta = meta;
|
2530
2615
|
this.records = new RecordArray(this, records);
|
@@ -2581,7 +2666,7 @@ const PAGINATION_DEFAULT_OFFSET = 0;
|
|
2581
2666
|
function isCursorPaginationOptions(options) {
|
2582
2667
|
return isDefined(options) && (isDefined(options.start) || isDefined(options.end) || isDefined(options.after) || isDefined(options.before));
|
2583
2668
|
}
|
2584
|
-
const _RecordArray = class extends Array {
|
2669
|
+
const _RecordArray = class _RecordArray extends Array {
|
2585
2670
|
constructor(...args) {
|
2586
2671
|
super(..._RecordArray.parseConstructorParams(...args));
|
2587
2672
|
__privateAdd$6(this, _page, void 0);
|
@@ -2652,9 +2737,15 @@ const _RecordArray = class extends Array {
|
|
2652
2737
|
return __privateGet$6(this, _page).meta.page.more;
|
2653
2738
|
}
|
2654
2739
|
};
|
2655
|
-
let RecordArray = _RecordArray;
|
2656
2740
|
_page = new WeakMap();
|
2741
|
+
let RecordArray = _RecordArray;
|
2657
2742
|
|
2743
|
+
var __defProp$4 = Object.defineProperty;
|
2744
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2745
|
+
var __publicField$4 = (obj, key, value) => {
|
2746
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2747
|
+
return value;
|
2748
|
+
};
|
2658
2749
|
var __accessCheck$5 = (obj, member, msg) => {
|
2659
2750
|
if (!member.has(obj))
|
2660
2751
|
throw TypeError("Cannot " + msg);
|
@@ -2678,15 +2769,15 @@ var __privateMethod$3 = (obj, member, method) => {
|
|
2678
2769
|
return method;
|
2679
2770
|
};
|
2680
2771
|
var _table$1, _repository, _data, _cleanFilterConstraint, cleanFilterConstraint_fn;
|
2681
|
-
const _Query = class {
|
2772
|
+
const _Query = class _Query {
|
2682
2773
|
constructor(repository, table, data, rawParent) {
|
2683
2774
|
__privateAdd$5(this, _cleanFilterConstraint);
|
2684
2775
|
__privateAdd$5(this, _table$1, void 0);
|
2685
2776
|
__privateAdd$5(this, _repository, void 0);
|
2686
2777
|
__privateAdd$5(this, _data, { filter: {} });
|
2687
2778
|
// Implements pagination
|
2688
|
-
this
|
2689
|
-
this
|
2779
|
+
__publicField$4(this, "meta", { page: { cursor: "start", more: true, size: PAGINATION_DEFAULT_SIZE } });
|
2780
|
+
__publicField$4(this, "records", new RecordArray(this, []));
|
2690
2781
|
__privateSet$5(this, _table$1, table);
|
2691
2782
|
if (repository) {
|
2692
2783
|
__privateSet$5(this, _repository, repository);
|
@@ -2906,7 +2997,6 @@ const _Query = class {
|
|
2906
2997
|
return this.meta.page.more;
|
2907
2998
|
}
|
2908
2999
|
};
|
2909
|
-
let Query = _Query;
|
2910
3000
|
_table$1 = new WeakMap();
|
2911
3001
|
_repository = new WeakMap();
|
2912
3002
|
_data = new WeakMap();
|
@@ -2921,6 +3011,7 @@ cleanFilterConstraint_fn = function(column, value) {
|
|
2921
3011
|
}
|
2922
3012
|
return value;
|
2923
3013
|
};
|
3014
|
+
let Query = _Query;
|
2924
3015
|
function cleanParent(data, parent) {
|
2925
3016
|
if (isCursorPaginationOptions(data.pagination)) {
|
2926
3017
|
return { ...parent, sort: void 0, filter: void 0 };
|
@@ -2928,6 +3019,21 @@ function cleanParent(data, parent) {
|
|
2928
3019
|
return parent;
|
2929
3020
|
}
|
2930
3021
|
|
3022
|
+
const RecordColumnTypes = [
|
3023
|
+
"bool",
|
3024
|
+
"int",
|
3025
|
+
"float",
|
3026
|
+
"string",
|
3027
|
+
"text",
|
3028
|
+
"email",
|
3029
|
+
"multiple",
|
3030
|
+
"link",
|
3031
|
+
"object",
|
3032
|
+
"datetime",
|
3033
|
+
"vector",
|
3034
|
+
"file[]",
|
3035
|
+
"file"
|
3036
|
+
];
|
2931
3037
|
function isIdentifiable(x) {
|
2932
3038
|
return isObject(x) && isString(x?.id);
|
2933
3039
|
}
|
@@ -3185,12 +3291,22 @@ class RestRepository extends Query {
|
|
3185
3291
|
return result;
|
3186
3292
|
}
|
3187
3293
|
if (isString(a) && isObject(b)) {
|
3294
|
+
if (a === "")
|
3295
|
+
throw new Error("The id can't be empty");
|
3188
3296
|
const columns = isStringArray(c) ? c : void 0;
|
3189
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3297
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a, b, columns, { ifVersion });
|
3190
3298
|
}
|
3191
3299
|
if (isObject(a) && isString(a.id)) {
|
3300
|
+
if (a.id === "")
|
3301
|
+
throw new Error("The id can't be empty");
|
3192
3302
|
const columns = isStringArray(c) ? c : void 0;
|
3193
|
-
return __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3303
|
+
return await __privateMethod$2(this, _upsertRecordWithID, upsertRecordWithID_fn).call(this, a.id, { ...a, id: void 0 }, columns, { ifVersion });
|
3304
|
+
}
|
3305
|
+
if (!isDefined(a) && isObject(b)) {
|
3306
|
+
return await this.create(b, c);
|
3307
|
+
}
|
3308
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3309
|
+
return await this.create(a, b);
|
3194
3310
|
}
|
3195
3311
|
throw new Error("Invalid arguments for createOrUpdate method");
|
3196
3312
|
});
|
@@ -3207,12 +3323,22 @@ class RestRepository extends Query {
|
|
3207
3323
|
return result;
|
3208
3324
|
}
|
3209
3325
|
if (isString(a) && isObject(b)) {
|
3326
|
+
if (a === "")
|
3327
|
+
throw new Error("The id can't be empty");
|
3210
3328
|
const columns = isStringArray(c) ? c : void 0;
|
3211
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3329
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a, b, columns, { createOnly: false, ifVersion });
|
3212
3330
|
}
|
3213
3331
|
if (isObject(a) && isString(a.id)) {
|
3332
|
+
if (a.id === "")
|
3333
|
+
throw new Error("The id can't be empty");
|
3214
3334
|
const columns = isStringArray(c) ? c : void 0;
|
3215
|
-
return __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3335
|
+
return await __privateMethod$2(this, _insertRecordWithId, insertRecordWithId_fn).call(this, a.id, { ...a, id: void 0 }, columns, { createOnly: false, ifVersion });
|
3336
|
+
}
|
3337
|
+
if (!isDefined(a) && isObject(b)) {
|
3338
|
+
return await this.create(b, c);
|
3339
|
+
}
|
3340
|
+
if (isObject(a) && !isDefined(a.id)) {
|
3341
|
+
return await this.create(a, b);
|
3216
3342
|
}
|
3217
3343
|
throw new Error("Invalid arguments for createOrReplace method");
|
3218
3344
|
});
|
@@ -3415,7 +3541,7 @@ _schemaTables$2 = new WeakMap();
|
|
3415
3541
|
_trace = new WeakMap();
|
3416
3542
|
_insertRecordWithoutId = new WeakSet();
|
3417
3543
|
insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
3418
|
-
const record =
|
3544
|
+
const record = removeLinksFromObject(object);
|
3419
3545
|
const response = await insertRecord({
|
3420
3546
|
pathParams: {
|
3421
3547
|
workspace: "{workspaceId}",
|
@@ -3432,7 +3558,9 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
3432
3558
|
};
|
3433
3559
|
_insertRecordWithId = new WeakSet();
|
3434
3560
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"], { createOnly, ifVersion }) {
|
3435
|
-
|
3561
|
+
if (!recordId)
|
3562
|
+
return null;
|
3563
|
+
const record = removeLinksFromObject(object);
|
3436
3564
|
const response = await insertRecordWithID({
|
3437
3565
|
pathParams: {
|
3438
3566
|
workspace: "{workspaceId}",
|
@@ -3452,7 +3580,7 @@ _insertRecords = new WeakSet();
|
|
3452
3580
|
insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
3453
3581
|
const chunkedOperations = chunk(
|
3454
3582
|
objects.map((object) => ({
|
3455
|
-
insert: { table: __privateGet$4(this, _table), record:
|
3583
|
+
insert: { table: __privateGet$4(this, _table), record: removeLinksFromObject(object), createOnly, ifVersion }
|
3456
3584
|
})),
|
3457
3585
|
BULK_OPERATION_MAX_SIZE
|
3458
3586
|
);
|
@@ -3479,7 +3607,9 @@ insertRecords_fn = async function(objects, { createOnly, ifVersion }) {
|
|
3479
3607
|
};
|
3480
3608
|
_updateRecordWithID = new WeakSet();
|
3481
3609
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3482
|
-
|
3610
|
+
if (!recordId)
|
3611
|
+
return null;
|
3612
|
+
const { id: _id, ...record } = removeLinksFromObject(object);
|
3483
3613
|
try {
|
3484
3614
|
const response = await updateRecordWithID({
|
3485
3615
|
pathParams: {
|
@@ -3506,7 +3636,7 @@ _updateRecords = new WeakSet();
|
|
3506
3636
|
updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
3507
3637
|
const chunkedOperations = chunk(
|
3508
3638
|
objects.map(({ id, ...object }) => ({
|
3509
|
-
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields:
|
3639
|
+
update: { table: __privateGet$4(this, _table), id, ifVersion, upsert, fields: removeLinksFromObject(object) }
|
3510
3640
|
})),
|
3511
3641
|
BULK_OPERATION_MAX_SIZE
|
3512
3642
|
);
|
@@ -3533,6 +3663,8 @@ updateRecords_fn = async function(objects, { ifVersion, upsert }) {
|
|
3533
3663
|
};
|
3534
3664
|
_upsertRecordWithID = new WeakSet();
|
3535
3665
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVersion }) {
|
3666
|
+
if (!recordId)
|
3667
|
+
return null;
|
3536
3668
|
const response = await upsertRecordWithID({
|
3537
3669
|
pathParams: {
|
3538
3670
|
workspace: "{workspaceId}",
|
@@ -3550,6 +3682,8 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"], { ifVe
|
|
3550
3682
|
};
|
3551
3683
|
_deleteRecord = new WeakSet();
|
3552
3684
|
deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
3685
|
+
if (!recordId)
|
3686
|
+
return null;
|
3553
3687
|
try {
|
3554
3688
|
const response = await deleteRecord({
|
3555
3689
|
pathParams: {
|
@@ -3574,7 +3708,7 @@ deleteRecord_fn = async function(recordId, columns = ["*"]) {
|
|
3574
3708
|
_deleteRecords = new WeakSet();
|
3575
3709
|
deleteRecords_fn = async function(recordIds) {
|
3576
3710
|
const chunkedOperations = chunk(
|
3577
|
-
recordIds.map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3711
|
+
compact(recordIds).map((id) => ({ delete: { table: __privateGet$4(this, _table), id } })),
|
3578
3712
|
BULK_OPERATION_MAX_SIZE
|
3579
3713
|
);
|
3580
3714
|
for (const operations of chunkedOperations) {
|
@@ -3617,7 +3751,7 @@ getSchemaTables_fn$1 = async function() {
|
|
3617
3751
|
__privateSet$4(this, _schemaTables$2, schema.tables);
|
3618
3752
|
return schema.tables;
|
3619
3753
|
};
|
3620
|
-
const
|
3754
|
+
const removeLinksFromObject = (object) => {
|
3621
3755
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
3622
3756
|
if (key === "xata")
|
3623
3757
|
return acc;
|
@@ -3675,7 +3809,7 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3675
3809
|
}
|
3676
3810
|
}
|
3677
3811
|
const record = { ...data };
|
3678
|
-
const serializable = { xata, ...
|
3812
|
+
const serializable = { xata, ...removeLinksFromObject(data) };
|
3679
3813
|
const metadata = xata !== void 0 ? { ...xata, createdAt: new Date(xata.createdAt), updatedAt: new Date(xata.updatedAt) } : void 0;
|
3680
3814
|
record.read = function(columns2) {
|
3681
3815
|
return db[table].read(record["id"], columns2);
|
@@ -3693,17 +3827,17 @@ const initObject = (db, schemaTables, table, object, selectedColumns) => {
|
|
3693
3827
|
record.delete = function() {
|
3694
3828
|
return db[table].delete(record["id"]);
|
3695
3829
|
};
|
3696
|
-
record.xata = metadata;
|
3830
|
+
record.xata = Object.freeze(metadata);
|
3697
3831
|
record.getMetadata = function() {
|
3698
|
-
return
|
3832
|
+
return record.xata;
|
3699
3833
|
};
|
3700
3834
|
record.toSerializable = function() {
|
3701
3835
|
return JSON.parse(JSON.stringify(serializable));
|
3702
3836
|
};
|
3703
3837
|
record.toString = function() {
|
3704
|
-
return JSON.stringify(
|
3838
|
+
return JSON.stringify(serializable);
|
3705
3839
|
};
|
3706
|
-
for (const prop of ["read", "update", "replace", "delete", "
|
3840
|
+
for (const prop of ["read", "update", "replace", "delete", "getMetadata", "toSerializable", "toString"]) {
|
3707
3841
|
Object.defineProperty(record, prop, { enumerable: false });
|
3708
3842
|
}
|
3709
3843
|
Object.freeze(record);
|
@@ -3719,11 +3853,7 @@ function extractId(value) {
|
|
3719
3853
|
function isValidColumn(columns, column) {
|
3720
3854
|
if (columns.includes("*"))
|
3721
3855
|
return true;
|
3722
|
-
|
3723
|
-
const linkColumns = columns.filter((item) => item.startsWith(column.name));
|
3724
|
-
return linkColumns.length > 0;
|
3725
|
-
}
|
3726
|
-
return columns.includes(column.name);
|
3856
|
+
return columns.filter((item) => item.startsWith(column.name)).length > 0;
|
3727
3857
|
}
|
3728
3858
|
function parseIfVersion(...args) {
|
3729
3859
|
for (const arg of args) {
|
@@ -3734,6 +3864,12 @@ function parseIfVersion(...args) {
|
|
3734
3864
|
return void 0;
|
3735
3865
|
}
|
3736
3866
|
|
3867
|
+
var __defProp$3 = Object.defineProperty;
|
3868
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3869
|
+
var __publicField$3 = (obj, key, value) => {
|
3870
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3871
|
+
return value;
|
3872
|
+
};
|
3737
3873
|
var __accessCheck$3 = (obj, member, msg) => {
|
3738
3874
|
if (!member.has(obj))
|
3739
3875
|
throw TypeError("Cannot " + msg);
|
@@ -3756,6 +3892,8 @@ var _map;
|
|
3756
3892
|
class SimpleCache {
|
3757
3893
|
constructor(options = {}) {
|
3758
3894
|
__privateAdd$3(this, _map, void 0);
|
3895
|
+
__publicField$3(this, "capacity");
|
3896
|
+
__publicField$3(this, "defaultQueryTTL");
|
3759
3897
|
__privateSet$3(this, _map, /* @__PURE__ */ new Map());
|
3760
3898
|
this.capacity = options.max ?? 500;
|
3761
3899
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
@@ -3953,6 +4091,12 @@ class TransactionPlugin extends XataPlugin {
|
|
3953
4091
|
}
|
3954
4092
|
}
|
3955
4093
|
|
4094
|
+
var __defProp$2 = Object.defineProperty;
|
4095
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4096
|
+
var __publicField$2 = (obj, key, value) => {
|
4097
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4098
|
+
return value;
|
4099
|
+
};
|
3956
4100
|
var __accessCheck = (obj, member, msg) => {
|
3957
4101
|
if (!member.has(obj))
|
3958
4102
|
throw TypeError("Cannot " + msg);
|
@@ -3982,6 +4126,9 @@ const buildClient = (plugins) => {
|
|
3982
4126
|
__privateAdd(this, _parseOptions);
|
3983
4127
|
__privateAdd(this, _getFetchProps);
|
3984
4128
|
__privateAdd(this, _options, void 0);
|
4129
|
+
__publicField$2(this, "db");
|
4130
|
+
__publicField$2(this, "search");
|
4131
|
+
__publicField$2(this, "transactions");
|
3985
4132
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
3986
4133
|
__privateSet(this, _options, safeOptions);
|
3987
4134
|
const pluginOptions = {
|
@@ -4091,11 +4238,17 @@ const buildClient = (plugins) => {
|
|
4091
4238
|
class BaseClient extends buildClient() {
|
4092
4239
|
}
|
4093
4240
|
|
4241
|
+
var __defProp$1 = Object.defineProperty;
|
4242
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4243
|
+
var __publicField$1 = (obj, key, value) => {
|
4244
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4245
|
+
return value;
|
4246
|
+
};
|
4094
4247
|
const META = "__";
|
4095
4248
|
const VALUE = "___";
|
4096
4249
|
class Serializer {
|
4097
4250
|
constructor() {
|
4098
|
-
this
|
4251
|
+
__publicField$1(this, "classes", {});
|
4099
4252
|
}
|
4100
4253
|
add(clazz) {
|
4101
4254
|
this.classes[clazz.name] = clazz;
|
@@ -4173,9 +4326,16 @@ function buildWorkerRunner(config) {
|
|
4173
4326
|
};
|
4174
4327
|
}
|
4175
4328
|
|
4329
|
+
var __defProp = Object.defineProperty;
|
4330
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4331
|
+
var __publicField = (obj, key, value) => {
|
4332
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4333
|
+
return value;
|
4334
|
+
};
|
4176
4335
|
class XataError extends Error {
|
4177
4336
|
constructor(message, status) {
|
4178
4337
|
super(message);
|
4338
|
+
__publicField(this, "status");
|
4179
4339
|
this.status = status;
|
4180
4340
|
}
|
4181
4341
|
}
|
@@ -4190,6 +4350,7 @@ exports.PAGINATION_MAX_SIZE = PAGINATION_MAX_SIZE;
|
|
4190
4350
|
exports.Page = Page;
|
4191
4351
|
exports.Query = Query;
|
4192
4352
|
exports.RecordArray = RecordArray;
|
4353
|
+
exports.RecordColumnTypes = RecordColumnTypes;
|
4193
4354
|
exports.Repository = Repository;
|
4194
4355
|
exports.RestRepository = RestRepository;
|
4195
4356
|
exports.SchemaPlugin = SchemaPlugin;
|
@@ -4213,6 +4374,7 @@ exports.buildProviderString = buildProviderString;
|
|
4213
4374
|
exports.buildWorkerRunner = buildWorkerRunner;
|
4214
4375
|
exports.bulkInsertTableRecords = bulkInsertTableRecords;
|
4215
4376
|
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
4377
|
+
exports.chatSessionMessage = chatSessionMessage;
|
4216
4378
|
exports.compareBranchSchemas = compareBranchSchemas;
|
4217
4379
|
exports.compareBranchWithUserSchema = compareBranchWithUserSchema;
|
4218
4380
|
exports.compareMigrationRequest = compareMigrationRequest;
|