@xata.io/client 0.0.0-alpha.vfb4a018 → 0.0.0-alpha.vfd6aaf3
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/.eslintrc.cjs +1 -2
- package/CHANGELOG.md +120 -0
- package/README.md +271 -1
- package/Usage.md +395 -0
- package/dist/index.cjs +417 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +388 -133
- package/dist/index.mjs +415 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
- package/tsconfig.json +1 -0
package/dist/index.mjs
CHANGED
@@ -7,14 +7,18 @@ function compact(arr) {
|
|
7
7
|
function isObject(value) {
|
8
8
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
9
9
|
}
|
10
|
+
function isDefined(value) {
|
11
|
+
return value !== null && value !== void 0;
|
12
|
+
}
|
10
13
|
function isString(value) {
|
11
|
-
return value
|
14
|
+
return isDefined(value) && typeof value === "string";
|
12
15
|
}
|
13
16
|
function toBase64(value) {
|
14
17
|
try {
|
15
18
|
return btoa(value);
|
16
19
|
} catch (err) {
|
17
|
-
|
20
|
+
const buf = Buffer;
|
21
|
+
return buf.from(value).toString("base64");
|
18
22
|
}
|
19
23
|
}
|
20
24
|
|
@@ -70,16 +74,28 @@ function getFetchImplementation(userFetch) {
|
|
70
74
|
return fetchImpl;
|
71
75
|
}
|
72
76
|
|
73
|
-
|
74
|
-
|
77
|
+
const VERSION = "0.0.0-alpha.vfd6aaf3";
|
78
|
+
|
79
|
+
class ErrorWithCause extends Error {
|
80
|
+
constructor(message, options) {
|
81
|
+
super(message, options);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
class FetcherError extends ErrorWithCause {
|
85
|
+
constructor(status, data, requestId) {
|
75
86
|
super(getMessage(data));
|
76
87
|
this.status = status;
|
77
88
|
this.errors = isBulkError(data) ? data.errors : void 0;
|
89
|
+
this.requestId = requestId;
|
78
90
|
if (data instanceof Error) {
|
79
91
|
this.stack = data.stack;
|
80
92
|
this.cause = data.cause;
|
81
93
|
}
|
82
94
|
}
|
95
|
+
toString() {
|
96
|
+
const error = super.toString();
|
97
|
+
return `[${this.status}] (${this.requestId ?? "Unknown"}): ${error}`;
|
98
|
+
}
|
83
99
|
}
|
84
100
|
function isBulkError(error) {
|
85
101
|
return isObject(error) && Array.isArray(error.errors);
|
@@ -102,7 +118,12 @@ function getMessage(data) {
|
|
102
118
|
}
|
103
119
|
|
104
120
|
const resolveUrl = (url, queryParams = {}, pathParams = {}) => {
|
105
|
-
const
|
121
|
+
const cleanQueryParams = Object.entries(queryParams).reduce((acc, [key, value]) => {
|
122
|
+
if (value === void 0 || value === null)
|
123
|
+
return acc;
|
124
|
+
return { ...acc, [key]: value };
|
125
|
+
}, {});
|
126
|
+
const query = new URLSearchParams(cleanQueryParams).toString();
|
106
127
|
const queryString = query.length > 0 ? `?${query}` : "";
|
107
128
|
return url.replace(/\{\w*\}/g, (key) => pathParams[key.slice(1, -1)]) + queryString;
|
108
129
|
};
|
@@ -142,6 +163,7 @@ async function fetch$1({
|
|
142
163
|
body: body ? JSON.stringify(body) : void 0,
|
143
164
|
headers: {
|
144
165
|
"Content-Type": "application/json",
|
166
|
+
"User-Agent": `Xata client-ts/${VERSION}`,
|
145
167
|
...headers,
|
146
168
|
...hostHeader(fullUrl),
|
147
169
|
Authorization: `Bearer ${apiKey}`
|
@@ -150,14 +172,15 @@ async function fetch$1({
|
|
150
172
|
if (response.status === 204) {
|
151
173
|
return {};
|
152
174
|
}
|
175
|
+
const requestId = response.headers?.get("x-request-id") ?? void 0;
|
153
176
|
try {
|
154
177
|
const jsonResponse = await response.json();
|
155
178
|
if (response.ok) {
|
156
179
|
return jsonResponse;
|
157
180
|
}
|
158
|
-
throw new FetcherError(response.status, jsonResponse);
|
181
|
+
throw new FetcherError(response.status, jsonResponse, requestId);
|
159
182
|
} catch (error) {
|
160
|
-
throw new FetcherError(response.status, error);
|
183
|
+
throw new FetcherError(response.status, error, requestId);
|
161
184
|
}
|
162
185
|
}
|
163
186
|
|
@@ -366,6 +389,11 @@ const queryTable = (variables) => fetch$1({
|
|
366
389
|
method: "post",
|
367
390
|
...variables
|
368
391
|
});
|
392
|
+
const searchTable = (variables) => fetch$1({
|
393
|
+
url: "/db/{dbBranchName}/tables/{tableName}/search",
|
394
|
+
method: "post",
|
395
|
+
...variables
|
396
|
+
});
|
369
397
|
const searchBranch = (variables) => fetch$1({
|
370
398
|
url: "/db/{dbBranchName}/search",
|
371
399
|
method: "post",
|
@@ -429,6 +457,7 @@ const operationsByTag = {
|
|
429
457
|
getRecord,
|
430
458
|
bulkInsertTableRecords,
|
431
459
|
queryTable,
|
460
|
+
searchTable,
|
432
461
|
searchBranch
|
433
462
|
}
|
434
463
|
};
|
@@ -462,7 +491,7 @@ var __accessCheck$7 = (obj, member, msg) => {
|
|
462
491
|
if (!member.has(obj))
|
463
492
|
throw TypeError("Cannot " + msg);
|
464
493
|
};
|
465
|
-
var __privateGet$
|
494
|
+
var __privateGet$7 = (obj, member, getter) => {
|
466
495
|
__accessCheck$7(obj, member, "read from private field");
|
467
496
|
return getter ? getter.call(obj) : member.get(obj);
|
468
497
|
};
|
@@ -471,7 +500,7 @@ var __privateAdd$7 = (obj, member, value) => {
|
|
471
500
|
throw TypeError("Cannot add the same private member more than once");
|
472
501
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
473
502
|
};
|
474
|
-
var __privateSet$
|
503
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
475
504
|
__accessCheck$7(obj, member, "write to private field");
|
476
505
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
477
506
|
return value;
|
@@ -486,7 +515,7 @@ class XataApiClient {
|
|
486
515
|
if (!apiKey) {
|
487
516
|
throw new Error("Could not resolve a valid apiKey");
|
488
517
|
}
|
489
|
-
__privateSet$
|
518
|
+
__privateSet$6(this, _extraProps, {
|
490
519
|
apiUrl: getHostUrl(provider, "main"),
|
491
520
|
workspacesApiUrl: getHostUrl(provider, "workspaces"),
|
492
521
|
fetchImpl: getFetchImplementation(options.fetch),
|
@@ -494,34 +523,34 @@ class XataApiClient {
|
|
494
523
|
});
|
495
524
|
}
|
496
525
|
get user() {
|
497
|
-
if (!__privateGet$
|
498
|
-
__privateGet$
|
499
|
-
return __privateGet$
|
526
|
+
if (!__privateGet$7(this, _namespaces).user)
|
527
|
+
__privateGet$7(this, _namespaces).user = new UserApi(__privateGet$7(this, _extraProps));
|
528
|
+
return __privateGet$7(this, _namespaces).user;
|
500
529
|
}
|
501
530
|
get workspaces() {
|
502
|
-
if (!__privateGet$
|
503
|
-
__privateGet$
|
504
|
-
return __privateGet$
|
531
|
+
if (!__privateGet$7(this, _namespaces).workspaces)
|
532
|
+
__privateGet$7(this, _namespaces).workspaces = new WorkspaceApi(__privateGet$7(this, _extraProps));
|
533
|
+
return __privateGet$7(this, _namespaces).workspaces;
|
505
534
|
}
|
506
535
|
get databases() {
|
507
|
-
if (!__privateGet$
|
508
|
-
__privateGet$
|
509
|
-
return __privateGet$
|
536
|
+
if (!__privateGet$7(this, _namespaces).databases)
|
537
|
+
__privateGet$7(this, _namespaces).databases = new DatabaseApi(__privateGet$7(this, _extraProps));
|
538
|
+
return __privateGet$7(this, _namespaces).databases;
|
510
539
|
}
|
511
540
|
get branches() {
|
512
|
-
if (!__privateGet$
|
513
|
-
__privateGet$
|
514
|
-
return __privateGet$
|
541
|
+
if (!__privateGet$7(this, _namespaces).branches)
|
542
|
+
__privateGet$7(this, _namespaces).branches = new BranchApi(__privateGet$7(this, _extraProps));
|
543
|
+
return __privateGet$7(this, _namespaces).branches;
|
515
544
|
}
|
516
545
|
get tables() {
|
517
|
-
if (!__privateGet$
|
518
|
-
__privateGet$
|
519
|
-
return __privateGet$
|
546
|
+
if (!__privateGet$7(this, _namespaces).tables)
|
547
|
+
__privateGet$7(this, _namespaces).tables = new TableApi(__privateGet$7(this, _extraProps));
|
548
|
+
return __privateGet$7(this, _namespaces).tables;
|
520
549
|
}
|
521
550
|
get records() {
|
522
|
-
if (!__privateGet$
|
523
|
-
__privateGet$
|
524
|
-
return __privateGet$
|
551
|
+
if (!__privateGet$7(this, _namespaces).records)
|
552
|
+
__privateGet$7(this, _namespaces).records = new RecordsApi(__privateGet$7(this, _extraProps));
|
553
|
+
return __privateGet$7(this, _namespaces).records;
|
525
554
|
}
|
526
555
|
}
|
527
556
|
_extraProps = new WeakMap();
|
@@ -675,10 +704,10 @@ class DatabaseApi {
|
|
675
704
|
...this.extraProps
|
676
705
|
});
|
677
706
|
}
|
678
|
-
resolveBranch(workspace, dbName, gitBranch) {
|
707
|
+
resolveBranch(workspace, dbName, gitBranch, fallbackBranch) {
|
679
708
|
return operationsByTag.database.resolveBranch({
|
680
709
|
pathParams: { workspace, dbName },
|
681
|
-
queryParams: { gitBranch },
|
710
|
+
queryParams: { gitBranch, fallbackBranch },
|
682
711
|
...this.extraProps
|
683
712
|
});
|
684
713
|
}
|
@@ -699,10 +728,10 @@ class BranchApi {
|
|
699
728
|
...this.extraProps
|
700
729
|
});
|
701
730
|
}
|
702
|
-
createBranch(workspace, database, branch, from
|
731
|
+
createBranch(workspace, database, branch, from, options = {}) {
|
703
732
|
return operationsByTag.branch.createBranch({
|
704
733
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
705
|
-
queryParams: { from },
|
734
|
+
queryParams: isString(from) ? { from } : void 0,
|
706
735
|
body: options,
|
707
736
|
...this.extraProps
|
708
737
|
});
|
@@ -884,6 +913,13 @@ class RecordsApi {
|
|
884
913
|
...this.extraProps
|
885
914
|
});
|
886
915
|
}
|
916
|
+
searchTable(workspace, database, branch, tableName, query) {
|
917
|
+
return operationsByTag.records.searchTable({
|
918
|
+
pathParams: { workspace, dbBranchName: `${database}:${branch}`, tableName },
|
919
|
+
body: query,
|
920
|
+
...this.extraProps
|
921
|
+
});
|
922
|
+
}
|
887
923
|
searchBranch(workspace, database, branch, query) {
|
888
924
|
return operationsByTag.records.searchBranch({
|
889
925
|
pathParams: { workspace, dbBranchName: `${database}:${branch}` },
|
@@ -907,7 +943,7 @@ var __accessCheck$6 = (obj, member, msg) => {
|
|
907
943
|
if (!member.has(obj))
|
908
944
|
throw TypeError("Cannot " + msg);
|
909
945
|
};
|
910
|
-
var __privateGet$
|
946
|
+
var __privateGet$6 = (obj, member, getter) => {
|
911
947
|
__accessCheck$6(obj, member, "read from private field");
|
912
948
|
return getter ? getter.call(obj) : member.get(obj);
|
913
949
|
};
|
@@ -916,30 +952,30 @@ var __privateAdd$6 = (obj, member, value) => {
|
|
916
952
|
throw TypeError("Cannot add the same private member more than once");
|
917
953
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
918
954
|
};
|
919
|
-
var __privateSet$
|
955
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
920
956
|
__accessCheck$6(obj, member, "write to private field");
|
921
957
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
922
958
|
return value;
|
923
959
|
};
|
924
|
-
var _query;
|
960
|
+
var _query, _page;
|
925
961
|
class Page {
|
926
962
|
constructor(query, meta, records = []) {
|
927
963
|
__privateAdd$6(this, _query, void 0);
|
928
|
-
__privateSet$
|
964
|
+
__privateSet$5(this, _query, query);
|
929
965
|
this.meta = meta;
|
930
|
-
this.records = records;
|
966
|
+
this.records = new RecordArray(this, records);
|
931
967
|
}
|
932
968
|
async nextPage(size, offset) {
|
933
|
-
return __privateGet$
|
969
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, after: this.meta.page.cursor } });
|
934
970
|
}
|
935
971
|
async previousPage(size, offset) {
|
936
|
-
return __privateGet$
|
972
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, before: this.meta.page.cursor } });
|
937
973
|
}
|
938
974
|
async firstPage(size, offset) {
|
939
|
-
return __privateGet$
|
975
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, first: this.meta.page.cursor } });
|
940
976
|
}
|
941
977
|
async lastPage(size, offset) {
|
942
|
-
return __privateGet$
|
978
|
+
return __privateGet$6(this, _query).getPaginated({ pagination: { size, offset, last: this.meta.page.cursor } });
|
943
979
|
}
|
944
980
|
hasNextPage() {
|
945
981
|
return this.meta.page.more;
|
@@ -947,15 +983,56 @@ class Page {
|
|
947
983
|
}
|
948
984
|
_query = new WeakMap();
|
949
985
|
const PAGINATION_MAX_SIZE = 200;
|
950
|
-
const PAGINATION_DEFAULT_SIZE =
|
986
|
+
const PAGINATION_DEFAULT_SIZE = 20;
|
951
987
|
const PAGINATION_MAX_OFFSET = 800;
|
952
988
|
const PAGINATION_DEFAULT_OFFSET = 0;
|
989
|
+
function isCursorPaginationOptions(options) {
|
990
|
+
return isDefined(options) && (isDefined(options.first) || isDefined(options.last) || isDefined(options.after) || isDefined(options.before));
|
991
|
+
}
|
992
|
+
const _RecordArray = class extends Array {
|
993
|
+
constructor(page, overrideRecords) {
|
994
|
+
super(..._RecordArray.parseConstructorParams(page, overrideRecords));
|
995
|
+
__privateAdd$6(this, _page, void 0);
|
996
|
+
__privateSet$5(this, _page, page);
|
997
|
+
}
|
998
|
+
static parseConstructorParams(...args) {
|
999
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
1000
|
+
return new Array(args[0]);
|
1001
|
+
}
|
1002
|
+
if (args.length <= 2 && isObject(args[0]?.meta) && Array.isArray(args[1] ?? [])) {
|
1003
|
+
const result = args[1] ?? args[0].records ?? [];
|
1004
|
+
return new Array(...result);
|
1005
|
+
}
|
1006
|
+
return new Array(...args);
|
1007
|
+
}
|
1008
|
+
async nextPage(size, offset) {
|
1009
|
+
const newPage = await __privateGet$6(this, _page).nextPage(size, offset);
|
1010
|
+
return new _RecordArray(newPage);
|
1011
|
+
}
|
1012
|
+
async previousPage(size, offset) {
|
1013
|
+
const newPage = await __privateGet$6(this, _page).previousPage(size, offset);
|
1014
|
+
return new _RecordArray(newPage);
|
1015
|
+
}
|
1016
|
+
async firstPage(size, offset) {
|
1017
|
+
const newPage = await __privateGet$6(this, _page).firstPage(size, offset);
|
1018
|
+
return new _RecordArray(newPage);
|
1019
|
+
}
|
1020
|
+
async lastPage(size, offset) {
|
1021
|
+
const newPage = await __privateGet$6(this, _page).lastPage(size, offset);
|
1022
|
+
return new _RecordArray(newPage);
|
1023
|
+
}
|
1024
|
+
hasNextPage() {
|
1025
|
+
return __privateGet$6(this, _page).meta.page.more;
|
1026
|
+
}
|
1027
|
+
};
|
1028
|
+
let RecordArray = _RecordArray;
|
1029
|
+
_page = new WeakMap();
|
953
1030
|
|
954
1031
|
var __accessCheck$5 = (obj, member, msg) => {
|
955
1032
|
if (!member.has(obj))
|
956
1033
|
throw TypeError("Cannot " + msg);
|
957
1034
|
};
|
958
|
-
var __privateGet$
|
1035
|
+
var __privateGet$5 = (obj, member, getter) => {
|
959
1036
|
__accessCheck$5(obj, member, "read from private field");
|
960
1037
|
return getter ? getter.call(obj) : member.get(obj);
|
961
1038
|
};
|
@@ -964,34 +1041,35 @@ var __privateAdd$5 = (obj, member, value) => {
|
|
964
1041
|
throw TypeError("Cannot add the same private member more than once");
|
965
1042
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
966
1043
|
};
|
967
|
-
var __privateSet$
|
1044
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
968
1045
|
__accessCheck$5(obj, member, "write to private field");
|
969
1046
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
970
1047
|
return value;
|
971
1048
|
};
|
972
1049
|
var _table$1, _repository, _data;
|
973
1050
|
const _Query = class {
|
974
|
-
constructor(repository, table, data,
|
1051
|
+
constructor(repository, table, data, rawParent) {
|
975
1052
|
__privateAdd$5(this, _table$1, void 0);
|
976
1053
|
__privateAdd$5(this, _repository, void 0);
|
977
1054
|
__privateAdd$5(this, _data, { filter: {} });
|
978
1055
|
this.meta = { page: { cursor: "start", more: true } };
|
979
|
-
this.records = [];
|
980
|
-
__privateSet$
|
1056
|
+
this.records = new RecordArray(this, []);
|
1057
|
+
__privateSet$4(this, _table$1, table);
|
981
1058
|
if (repository) {
|
982
|
-
__privateSet$
|
1059
|
+
__privateSet$4(this, _repository, repository);
|
983
1060
|
} else {
|
984
|
-
__privateSet$
|
1061
|
+
__privateSet$4(this, _repository, this);
|
985
1062
|
}
|
986
|
-
|
987
|
-
__privateGet$
|
988
|
-
__privateGet$
|
989
|
-
__privateGet$
|
990
|
-
__privateGet$
|
991
|
-
__privateGet$
|
992
|
-
__privateGet$
|
993
|
-
__privateGet$
|
994
|
-
__privateGet$
|
1063
|
+
const parent = cleanParent(data, rawParent);
|
1064
|
+
__privateGet$5(this, _data).filter = data.filter ?? parent?.filter ?? {};
|
1065
|
+
__privateGet$5(this, _data).filter.$any = data.filter?.$any ?? parent?.filter?.$any;
|
1066
|
+
__privateGet$5(this, _data).filter.$all = data.filter?.$all ?? parent?.filter?.$all;
|
1067
|
+
__privateGet$5(this, _data).filter.$not = data.filter?.$not ?? parent?.filter?.$not;
|
1068
|
+
__privateGet$5(this, _data).filter.$none = data.filter?.$none ?? parent?.filter?.$none;
|
1069
|
+
__privateGet$5(this, _data).sort = data.sort ?? parent?.sort;
|
1070
|
+
__privateGet$5(this, _data).columns = data.columns ?? parent?.columns ?? ["*"];
|
1071
|
+
__privateGet$5(this, _data).pagination = data.pagination ?? parent?.pagination;
|
1072
|
+
__privateGet$5(this, _data).cache = data.cache ?? parent?.cache;
|
995
1073
|
this.any = this.any.bind(this);
|
996
1074
|
this.all = this.all.bind(this);
|
997
1075
|
this.not = this.not.bind(this);
|
@@ -1002,50 +1080,50 @@ const _Query = class {
|
|
1002
1080
|
Object.defineProperty(this, "repository", { enumerable: false });
|
1003
1081
|
}
|
1004
1082
|
getQueryOptions() {
|
1005
|
-
return __privateGet$
|
1083
|
+
return __privateGet$5(this, _data);
|
1006
1084
|
}
|
1007
1085
|
key() {
|
1008
|
-
const { columns = [], filter = {}, sort = [],
|
1009
|
-
const key = JSON.stringify({ columns, filter, sort,
|
1086
|
+
const { columns = [], filter = {}, sort = [], pagination = {} } = __privateGet$5(this, _data);
|
1087
|
+
const key = JSON.stringify({ columns, filter, sort, pagination });
|
1010
1088
|
return toBase64(key);
|
1011
1089
|
}
|
1012
1090
|
any(...queries) {
|
1013
1091
|
const $any = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1014
|
-
return new _Query(__privateGet$
|
1092
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $any } }, __privateGet$5(this, _data));
|
1015
1093
|
}
|
1016
1094
|
all(...queries) {
|
1017
1095
|
const $all = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1018
|
-
return new _Query(__privateGet$
|
1096
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1019
1097
|
}
|
1020
1098
|
not(...queries) {
|
1021
1099
|
const $not = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1022
|
-
return new _Query(__privateGet$
|
1100
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $not } }, __privateGet$5(this, _data));
|
1023
1101
|
}
|
1024
1102
|
none(...queries) {
|
1025
1103
|
const $none = queries.map((query) => query.getQueryOptions().filter ?? {});
|
1026
|
-
return new _Query(__privateGet$
|
1104
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $none } }, __privateGet$5(this, _data));
|
1027
1105
|
}
|
1028
1106
|
filter(a, b) {
|
1029
1107
|
if (arguments.length === 1) {
|
1030
1108
|
const constraints = Object.entries(a).map(([column, constraint]) => ({ [column]: constraint }));
|
1031
|
-
const $all = compact([__privateGet$
|
1032
|
-
return new _Query(__privateGet$
|
1109
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat(constraints));
|
1110
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1033
1111
|
} else {
|
1034
|
-
const $all = compact([__privateGet$
|
1035
|
-
return new _Query(__privateGet$
|
1112
|
+
const $all = compact([__privateGet$5(this, _data).filter?.$all].flat().concat([{ [a]: b }]));
|
1113
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { filter: { $all } }, __privateGet$5(this, _data));
|
1036
1114
|
}
|
1037
1115
|
}
|
1038
1116
|
sort(column, direction) {
|
1039
|
-
const originalSort = [__privateGet$
|
1117
|
+
const originalSort = [__privateGet$5(this, _data).sort ?? []].flat();
|
1040
1118
|
const sort = [...originalSort, { column, direction }];
|
1041
|
-
return new _Query(__privateGet$
|
1119
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { sort }, __privateGet$5(this, _data));
|
1042
1120
|
}
|
1043
1121
|
select(columns) {
|
1044
|
-
return new _Query(__privateGet$
|
1122
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { columns }, __privateGet$5(this, _data));
|
1045
1123
|
}
|
1046
1124
|
getPaginated(options = {}) {
|
1047
|
-
const query = new _Query(__privateGet$
|
1048
|
-
return __privateGet$
|
1125
|
+
const query = new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), options, __privateGet$5(this, _data));
|
1126
|
+
return __privateGet$5(this, _repository).query(query);
|
1049
1127
|
}
|
1050
1128
|
async *[Symbol.asyncIterator]() {
|
1051
1129
|
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
@@ -1054,18 +1132,21 @@ const _Query = class {
|
|
1054
1132
|
}
|
1055
1133
|
async *getIterator(options = {}) {
|
1056
1134
|
const { batchSize = 1 } = options;
|
1057
|
-
let
|
1058
|
-
let
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1135
|
+
let page = await this.getPaginated({ ...options, pagination: { size: batchSize, offset: 0 } });
|
1136
|
+
let more = page.hasNextPage();
|
1137
|
+
yield page.records;
|
1138
|
+
while (more) {
|
1139
|
+
page = await page.nextPage();
|
1140
|
+
more = page.hasNextPage();
|
1141
|
+
yield page.records;
|
1064
1142
|
}
|
1065
1143
|
}
|
1066
1144
|
async getMany(options = {}) {
|
1067
|
-
const
|
1068
|
-
|
1145
|
+
const page = await this.getPaginated(options);
|
1146
|
+
if (page.hasNextPage() && options.pagination?.size === void 0) {
|
1147
|
+
console.trace("Calling getMany does not return all results. Paginate to get all results or call getAll.");
|
1148
|
+
}
|
1149
|
+
return page.records;
|
1069
1150
|
}
|
1070
1151
|
async getAll(options = {}) {
|
1071
1152
|
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
@@ -1076,11 +1157,11 @@ const _Query = class {
|
|
1076
1157
|
return results;
|
1077
1158
|
}
|
1078
1159
|
async getFirst(options = {}) {
|
1079
|
-
const records = await this.getMany({ ...options,
|
1080
|
-
return records[0]
|
1160
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1161
|
+
return records[0] ?? null;
|
1081
1162
|
}
|
1082
1163
|
cache(ttl) {
|
1083
|
-
return new _Query(__privateGet$
|
1164
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1084
1165
|
}
|
1085
1166
|
nextPage(size, offset) {
|
1086
1167
|
return this.firstPage(size, offset);
|
@@ -1089,10 +1170,10 @@ const _Query = class {
|
|
1089
1170
|
return this.firstPage(size, offset);
|
1090
1171
|
}
|
1091
1172
|
firstPage(size, offset) {
|
1092
|
-
return this.getPaginated({
|
1173
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1093
1174
|
}
|
1094
1175
|
lastPage(size, offset) {
|
1095
|
-
return this.getPaginated({
|
1176
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1096
1177
|
}
|
1097
1178
|
hasNextPage() {
|
1098
1179
|
return this.meta.page.more;
|
@@ -1102,12 +1183,20 @@ let Query = _Query;
|
|
1102
1183
|
_table$1 = new WeakMap();
|
1103
1184
|
_repository = new WeakMap();
|
1104
1185
|
_data = new WeakMap();
|
1186
|
+
function cleanParent(data, parent) {
|
1187
|
+
if (isCursorPaginationOptions(data.pagination)) {
|
1188
|
+
return { ...parent, sorting: void 0, filter: void 0 };
|
1189
|
+
}
|
1190
|
+
return parent;
|
1191
|
+
}
|
1105
1192
|
|
1106
1193
|
function isIdentifiable(x) {
|
1107
1194
|
return isObject(x) && isString(x?.id);
|
1108
1195
|
}
|
1109
1196
|
function isXataRecord(x) {
|
1110
|
-
|
1197
|
+
const record = x;
|
1198
|
+
const metadata = record?.getMetadata();
|
1199
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1111
1200
|
}
|
1112
1201
|
|
1113
1202
|
function isSortFilterString(value) {
|
@@ -1137,7 +1226,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
1137
1226
|
if (!member.has(obj))
|
1138
1227
|
throw TypeError("Cannot " + msg);
|
1139
1228
|
};
|
1140
|
-
var __privateGet$
|
1229
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1141
1230
|
__accessCheck$4(obj, member, "read from private field");
|
1142
1231
|
return getter ? getter.call(obj) : member.get(obj);
|
1143
1232
|
};
|
@@ -1146,7 +1235,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1146
1235
|
throw TypeError("Cannot add the same private member more than once");
|
1147
1236
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1148
1237
|
};
|
1149
|
-
var __privateSet$
|
1238
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1150
1239
|
__accessCheck$4(obj, member, "write to private field");
|
1151
1240
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1152
1241
|
return value;
|
@@ -1155,7 +1244,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1155
1244
|
__accessCheck$4(obj, member, "access private method");
|
1156
1245
|
return method;
|
1157
1246
|
};
|
1158
|
-
var _table,
|
1247
|
+
var _table, _getFetchProps, _cache, _schema$1, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _invalidateCache, invalidateCache_fn, _setCacheRecord, setCacheRecord_fn, _getCacheRecord, getCacheRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchema$1, getSchema_fn$1;
|
1159
1248
|
class Repository extends Query {
|
1160
1249
|
}
|
1161
1250
|
class RestRepository extends Query {
|
@@ -1172,21 +1261,43 @@ class RestRepository extends Query {
|
|
1172
1261
|
__privateAdd$4(this, _getCacheRecord);
|
1173
1262
|
__privateAdd$4(this, _setCacheQuery);
|
1174
1263
|
__privateAdd$4(this, _getCacheQuery);
|
1264
|
+
__privateAdd$4(this, _getSchema$1);
|
1175
1265
|
__privateAdd$4(this, _table, void 0);
|
1176
|
-
__privateAdd$4(this, _links, void 0);
|
1177
1266
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1178
1267
|
__privateAdd$4(this, _cache, void 0);
|
1179
|
-
|
1180
|
-
__privateSet$
|
1181
|
-
__privateSet$
|
1268
|
+
__privateAdd$4(this, _schema$1, void 0);
|
1269
|
+
__privateSet$3(this, _table, options.table);
|
1270
|
+
__privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1182
1271
|
this.db = options.db;
|
1183
|
-
__privateSet$
|
1272
|
+
__privateSet$3(this, _cache, options.pluginOptions.cache);
|
1184
1273
|
}
|
1185
1274
|
async create(a, b) {
|
1186
1275
|
if (Array.isArray(a)) {
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1276
|
+
if (a.length === 0)
|
1277
|
+
return [];
|
1278
|
+
const [itemsWithoutIds, itemsWithIds, order] = a.reduce(([accWithoutIds, accWithIds, accOrder], item) => {
|
1279
|
+
const condition = isString(item.id);
|
1280
|
+
accOrder.push(condition);
|
1281
|
+
if (condition) {
|
1282
|
+
accWithIds.push(item);
|
1283
|
+
} else {
|
1284
|
+
accWithoutIds.push(item);
|
1285
|
+
}
|
1286
|
+
return [accWithoutIds, accWithIds, accOrder];
|
1287
|
+
}, [[], [], []]);
|
1288
|
+
const recordsWithoutId = await __privateMethod$2(this, _bulkInsertTableRecords, bulkInsertTableRecords_fn).call(this, itemsWithoutIds);
|
1289
|
+
await Promise.all(recordsWithoutId.map((record) => __privateMethod$2(this, _setCacheRecord, setCacheRecord_fn).call(this, record)));
|
1290
|
+
if (itemsWithIds.length > 100) {
|
1291
|
+
console.warn("Bulk create operation with id is not optimized in the Xata API yet, this request might be slow");
|
1292
|
+
}
|
1293
|
+
const recordsWithId = await Promise.all(itemsWithIds.map((object) => this.create(object)));
|
1294
|
+
return order.map((condition) => {
|
1295
|
+
if (condition) {
|
1296
|
+
return recordsWithId.shift();
|
1297
|
+
} else {
|
1298
|
+
return recordsWithoutId.shift();
|
1299
|
+
}
|
1300
|
+
}).filter((record) => !!record);
|
1190
1301
|
}
|
1191
1302
|
if (isString(a) && isObject(b)) {
|
1192
1303
|
if (a === "")
|
@@ -1209,26 +1320,38 @@ class RestRepository extends Query {
|
|
1209
1320
|
}
|
1210
1321
|
throw new Error("Invalid arguments for create method");
|
1211
1322
|
}
|
1212
|
-
async read(
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1323
|
+
async read(a) {
|
1324
|
+
if (Array.isArray(a)) {
|
1325
|
+
if (a.length === 0)
|
1326
|
+
return [];
|
1327
|
+
const ids = a.map((item) => isString(item) ? item : item.id).filter((id2) => isString(id2));
|
1328
|
+
return this.getAll({ filter: { id: { $any: ids } } });
|
1329
|
+
}
|
1330
|
+
const id = isString(a) ? a : a.id;
|
1331
|
+
if (isString(id)) {
|
1332
|
+
const cacheRecord = await __privateMethod$2(this, _getCacheRecord, getCacheRecord_fn).call(this, id);
|
1333
|
+
if (cacheRecord)
|
1334
|
+
return cacheRecord;
|
1335
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1336
|
+
try {
|
1337
|
+
const response = await getRecord({
|
1338
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId: id },
|
1339
|
+
...fetchProps
|
1340
|
+
});
|
1341
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1342
|
+
return initObject(this.db, schema, __privateGet$4(this, _table), response);
|
1343
|
+
} catch (e) {
|
1344
|
+
if (isObject(e) && e.status === 404) {
|
1345
|
+
return null;
|
1346
|
+
}
|
1347
|
+
throw e;
|
1226
1348
|
}
|
1227
|
-
throw e;
|
1228
1349
|
}
|
1229
1350
|
}
|
1230
1351
|
async update(a, b) {
|
1231
1352
|
if (Array.isArray(a)) {
|
1353
|
+
if (a.length === 0)
|
1354
|
+
return [];
|
1232
1355
|
if (a.length > 100) {
|
1233
1356
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1234
1357
|
}
|
@@ -1250,6 +1373,8 @@ class RestRepository extends Query {
|
|
1250
1373
|
}
|
1251
1374
|
async createOrUpdate(a, b) {
|
1252
1375
|
if (Array.isArray(a)) {
|
1376
|
+
if (a.length === 0)
|
1377
|
+
return [];
|
1253
1378
|
if (a.length > 100) {
|
1254
1379
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1255
1380
|
}
|
@@ -1271,6 +1396,8 @@ class RestRepository extends Query {
|
|
1271
1396
|
}
|
1272
1397
|
async delete(a) {
|
1273
1398
|
if (Array.isArray(a)) {
|
1399
|
+
if (a.length === 0)
|
1400
|
+
return;
|
1274
1401
|
if (a.length > 100) {
|
1275
1402
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1276
1403
|
}
|
@@ -1290,13 +1417,19 @@ class RestRepository extends Query {
|
|
1290
1417
|
throw new Error("Invalid arguments for delete method");
|
1291
1418
|
}
|
1292
1419
|
async search(query, options = {}) {
|
1293
|
-
const fetchProps = await __privateGet$
|
1294
|
-
const { records } = await
|
1295
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1296
|
-
body: {
|
1420
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1421
|
+
const { records } = await searchTable({
|
1422
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1423
|
+
body: {
|
1424
|
+
query,
|
1425
|
+
fuzziness: options.fuzziness,
|
1426
|
+
highlight: options.highlight,
|
1427
|
+
filter: options.filter
|
1428
|
+
},
|
1297
1429
|
...fetchProps
|
1298
1430
|
});
|
1299
|
-
|
1431
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1432
|
+
return records.map((item) => initObject(this.db, schema, __privateGet$4(this, _table), item));
|
1300
1433
|
}
|
1301
1434
|
async query(query) {
|
1302
1435
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
@@ -1305,34 +1438,35 @@ class RestRepository extends Query {
|
|
1305
1438
|
const data = query.getQueryOptions();
|
1306
1439
|
const body = {
|
1307
1440
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1308
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1309
|
-
page: data.
|
1441
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1442
|
+
page: data.pagination,
|
1310
1443
|
columns: data.columns
|
1311
1444
|
};
|
1312
|
-
const fetchProps = await __privateGet$
|
1445
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1313
1446
|
const { meta, records: objects } = await queryTable({
|
1314
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1447
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1315
1448
|
body,
|
1316
1449
|
...fetchProps
|
1317
1450
|
});
|
1318
|
-
const
|
1451
|
+
const schema = await __privateMethod$2(this, _getSchema$1, getSchema_fn$1).call(this);
|
1452
|
+
const records = objects.map((record) => initObject(this.db, schema, __privateGet$4(this, _table), record));
|
1319
1453
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1320
1454
|
return new Page(query, meta, records);
|
1321
1455
|
}
|
1322
1456
|
}
|
1323
1457
|
_table = new WeakMap();
|
1324
|
-
_links = new WeakMap();
|
1325
1458
|
_getFetchProps = new WeakMap();
|
1326
1459
|
_cache = new WeakMap();
|
1460
|
+
_schema$1 = new WeakMap();
|
1327
1461
|
_insertRecordWithoutId = new WeakSet();
|
1328
1462
|
insertRecordWithoutId_fn = async function(object) {
|
1329
|
-
const fetchProps = await __privateGet$
|
1463
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1330
1464
|
const record = transformObjectLinks(object);
|
1331
1465
|
const response = await insertRecord({
|
1332
1466
|
pathParams: {
|
1333
1467
|
workspace: "{workspaceId}",
|
1334
1468
|
dbBranchName: "{dbBranch}",
|
1335
|
-
tableName: __privateGet$
|
1469
|
+
tableName: __privateGet$4(this, _table)
|
1336
1470
|
},
|
1337
1471
|
body: record,
|
1338
1472
|
...fetchProps
|
@@ -1345,13 +1479,13 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1345
1479
|
};
|
1346
1480
|
_insertRecordWithId = new WeakSet();
|
1347
1481
|
insertRecordWithId_fn = async function(recordId, object) {
|
1348
|
-
const fetchProps = await __privateGet$
|
1482
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1349
1483
|
const record = transformObjectLinks(object);
|
1350
1484
|
const response = await insertRecordWithID({
|
1351
1485
|
pathParams: {
|
1352
1486
|
workspace: "{workspaceId}",
|
1353
1487
|
dbBranchName: "{dbBranch}",
|
1354
|
-
tableName: __privateGet$
|
1488
|
+
tableName: __privateGet$4(this, _table),
|
1355
1489
|
recordId
|
1356
1490
|
},
|
1357
1491
|
body: record,
|
@@ -1366,14 +1500,14 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1366
1500
|
};
|
1367
1501
|
_bulkInsertTableRecords = new WeakSet();
|
1368
1502
|
bulkInsertTableRecords_fn = async function(objects) {
|
1369
|
-
const fetchProps = await __privateGet$
|
1503
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1370
1504
|
const records = objects.map((object) => transformObjectLinks(object));
|
1371
1505
|
const response = await bulkInsertTableRecords({
|
1372
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1506
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1373
1507
|
body: { records },
|
1374
1508
|
...fetchProps
|
1375
1509
|
});
|
1376
|
-
const finalObjects = await this.
|
1510
|
+
const finalObjects = await this.read(response.recordIDs);
|
1377
1511
|
if (finalObjects.length !== objects.length) {
|
1378
1512
|
throw new Error("The server failed to save some records");
|
1379
1513
|
}
|
@@ -1381,10 +1515,10 @@ bulkInsertTableRecords_fn = async function(objects) {
|
|
1381
1515
|
};
|
1382
1516
|
_updateRecordWithID = new WeakSet();
|
1383
1517
|
updateRecordWithID_fn = async function(recordId, object) {
|
1384
|
-
const fetchProps = await __privateGet$
|
1518
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1385
1519
|
const record = transformObjectLinks(object);
|
1386
1520
|
const response = await updateRecordWithID({
|
1387
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1521
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1388
1522
|
body: record,
|
1389
1523
|
...fetchProps
|
1390
1524
|
});
|
@@ -1395,9 +1529,9 @@ updateRecordWithID_fn = async function(recordId, object) {
|
|
1395
1529
|
};
|
1396
1530
|
_upsertRecordWithID = new WeakSet();
|
1397
1531
|
upsertRecordWithID_fn = async function(recordId, object) {
|
1398
|
-
const fetchProps = await __privateGet$
|
1532
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1399
1533
|
const response = await upsertRecordWithID({
|
1400
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1534
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1401
1535
|
body: object,
|
1402
1536
|
...fetchProps
|
1403
1537
|
});
|
@@ -1408,51 +1542,63 @@ upsertRecordWithID_fn = async function(recordId, object) {
|
|
1408
1542
|
};
|
1409
1543
|
_deleteRecord = new WeakSet();
|
1410
1544
|
deleteRecord_fn = async function(recordId) {
|
1411
|
-
const fetchProps = await __privateGet$
|
1545
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1412
1546
|
await deleteRecord({
|
1413
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1547
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1414
1548
|
...fetchProps
|
1415
1549
|
});
|
1416
1550
|
};
|
1417
1551
|
_invalidateCache = new WeakSet();
|
1418
1552
|
invalidateCache_fn = async function(recordId) {
|
1419
|
-
await __privateGet$
|
1420
|
-
const cacheItems = await __privateGet$
|
1553
|
+
await __privateGet$4(this, _cache).delete(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1554
|
+
const cacheItems = await __privateGet$4(this, _cache).getAll();
|
1421
1555
|
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1422
1556
|
for (const [key, value] of queries) {
|
1423
1557
|
const ids = getIds(value);
|
1424
1558
|
if (ids.includes(recordId))
|
1425
|
-
await __privateGet$
|
1559
|
+
await __privateGet$4(this, _cache).delete(key);
|
1426
1560
|
}
|
1427
1561
|
};
|
1428
1562
|
_setCacheRecord = new WeakSet();
|
1429
1563
|
setCacheRecord_fn = async function(record) {
|
1430
|
-
if (!__privateGet$
|
1564
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1431
1565
|
return;
|
1432
|
-
await __privateGet$
|
1566
|
+
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1433
1567
|
};
|
1434
1568
|
_getCacheRecord = new WeakSet();
|
1435
1569
|
getCacheRecord_fn = async function(recordId) {
|
1436
|
-
if (!__privateGet$
|
1570
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1437
1571
|
return null;
|
1438
|
-
return __privateGet$
|
1572
|
+
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1439
1573
|
};
|
1440
1574
|
_setCacheQuery = new WeakSet();
|
1441
1575
|
setCacheQuery_fn = async function(query, meta, records) {
|
1442
|
-
await __privateGet$
|
1576
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1443
1577
|
};
|
1444
1578
|
_getCacheQuery = new WeakSet();
|
1445
1579
|
getCacheQuery_fn = async function(query) {
|
1446
|
-
const key = `query_${__privateGet$
|
1447
|
-
const result = await __privateGet$
|
1580
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1581
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1448
1582
|
if (!result)
|
1449
1583
|
return null;
|
1450
|
-
const { cache: ttl = __privateGet$
|
1451
|
-
if (
|
1452
|
-
return
|
1584
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1585
|
+
if (ttl < 0)
|
1586
|
+
return null;
|
1453
1587
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1454
1588
|
return hasExpired ? null : result;
|
1455
1589
|
};
|
1590
|
+
_getSchema$1 = new WeakSet();
|
1591
|
+
getSchema_fn$1 = async function() {
|
1592
|
+
if (__privateGet$4(this, _schema$1))
|
1593
|
+
return __privateGet$4(this, _schema$1);
|
1594
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1595
|
+
const { schema } = await getBranchDetails({
|
1596
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1597
|
+
...fetchProps
|
1598
|
+
});
|
1599
|
+
__privateSet$3(this, _schema$1, schema);
|
1600
|
+
return schema;
|
1601
|
+
};
|
1456
1602
|
const transformObjectLinks = (object) => {
|
1457
1603
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1458
1604
|
if (key === "xata")
|
@@ -1460,15 +1606,34 @@ const transformObjectLinks = (object) => {
|
|
1460
1606
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1461
1607
|
}, {});
|
1462
1608
|
};
|
1463
|
-
const initObject = (db,
|
1609
|
+
const initObject = (db, schema, table, object) => {
|
1464
1610
|
const result = {};
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1611
|
+
const { xata, ...rest } = object ?? {};
|
1612
|
+
Object.assign(result, rest);
|
1613
|
+
const { columns } = schema.tables.find(({ name }) => name === table) ?? {};
|
1614
|
+
if (!columns)
|
1615
|
+
console.error(`Table ${table} not found in schema`);
|
1616
|
+
for (const column of columns ?? []) {
|
1617
|
+
const value = result[column.name];
|
1618
|
+
switch (column.type) {
|
1619
|
+
case "datetime": {
|
1620
|
+
const date = value !== void 0 ? new Date(value) : void 0;
|
1621
|
+
if (date && isNaN(date.getTime())) {
|
1622
|
+
console.error(`Failed to parse date ${value} for field ${column.name}`);
|
1623
|
+
} else if (date) {
|
1624
|
+
result[column.name] = date;
|
1625
|
+
}
|
1626
|
+
break;
|
1627
|
+
}
|
1628
|
+
case "link": {
|
1629
|
+
const linkTable = column.link?.table;
|
1630
|
+
if (!linkTable) {
|
1631
|
+
console.error(`Failed to parse link for field ${column.name}`);
|
1632
|
+
} else if (isObject(value)) {
|
1633
|
+
result[column.name] = initObject(db, schema, linkTable, value);
|
1634
|
+
}
|
1635
|
+
break;
|
1636
|
+
}
|
1472
1637
|
}
|
1473
1638
|
}
|
1474
1639
|
result.read = function() {
|
@@ -1480,7 +1645,10 @@ const initObject = (db, links, table, object) => {
|
|
1480
1645
|
result.delete = function() {
|
1481
1646
|
return db[table].delete(result["id"]);
|
1482
1647
|
};
|
1483
|
-
|
1648
|
+
result.getMetadata = function() {
|
1649
|
+
return xata;
|
1650
|
+
};
|
1651
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1484
1652
|
Object.defineProperty(result, prop, { enumerable: false });
|
1485
1653
|
}
|
1486
1654
|
Object.freeze(result);
|
@@ -1500,7 +1668,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
1500
1668
|
if (!member.has(obj))
|
1501
1669
|
throw TypeError("Cannot " + msg);
|
1502
1670
|
};
|
1503
|
-
var __privateGet$
|
1671
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1504
1672
|
__accessCheck$3(obj, member, "read from private field");
|
1505
1673
|
return getter ? getter.call(obj) : member.get(obj);
|
1506
1674
|
};
|
@@ -1509,7 +1677,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1509
1677
|
throw TypeError("Cannot add the same private member more than once");
|
1510
1678
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1511
1679
|
};
|
1512
|
-
var __privateSet$
|
1680
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1513
1681
|
__accessCheck$3(obj, member, "write to private field");
|
1514
1682
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1515
1683
|
return value;
|
@@ -1518,30 +1686,30 @@ var _map;
|
|
1518
1686
|
class SimpleCache {
|
1519
1687
|
constructor(options = {}) {
|
1520
1688
|
__privateAdd$3(this, _map, void 0);
|
1521
|
-
__privateSet$
|
1689
|
+
__privateSet$2(this, _map, /* @__PURE__ */ new Map());
|
1522
1690
|
this.capacity = options.max ?? 500;
|
1523
1691
|
this.cacheRecords = options.cacheRecords ?? true;
|
1524
1692
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1525
1693
|
}
|
1526
1694
|
async getAll() {
|
1527
|
-
return Object.fromEntries(__privateGet$
|
1695
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1528
1696
|
}
|
1529
1697
|
async get(key) {
|
1530
|
-
return __privateGet$
|
1698
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1531
1699
|
}
|
1532
1700
|
async set(key, value) {
|
1533
1701
|
await this.delete(key);
|
1534
|
-
__privateGet$
|
1535
|
-
if (__privateGet$
|
1536
|
-
const leastRecentlyUsed = __privateGet$
|
1702
|
+
__privateGet$3(this, _map).set(key, value);
|
1703
|
+
if (__privateGet$3(this, _map).size > this.capacity) {
|
1704
|
+
const leastRecentlyUsed = __privateGet$3(this, _map).keys().next().value;
|
1537
1705
|
await this.delete(leastRecentlyUsed);
|
1538
1706
|
}
|
1539
1707
|
}
|
1540
1708
|
async delete(key) {
|
1541
|
-
__privateGet$
|
1709
|
+
__privateGet$3(this, _map).delete(key);
|
1542
1710
|
}
|
1543
1711
|
async clear() {
|
1544
|
-
return __privateGet$
|
1712
|
+
return __privateGet$3(this, _map).clear();
|
1545
1713
|
}
|
1546
1714
|
}
|
1547
1715
|
_map = new WeakMap();
|
@@ -1569,7 +1737,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1569
1737
|
if (!member.has(obj))
|
1570
1738
|
throw TypeError("Cannot " + msg);
|
1571
1739
|
};
|
1572
|
-
var __privateGet$
|
1740
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1573
1741
|
__accessCheck$2(obj, member, "read from private field");
|
1574
1742
|
return getter ? getter.call(obj) : member.get(obj);
|
1575
1743
|
};
|
@@ -1580,26 +1748,24 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1580
1748
|
};
|
1581
1749
|
var _tables;
|
1582
1750
|
class SchemaPlugin extends XataPlugin {
|
1583
|
-
constructor(
|
1751
|
+
constructor(tableNames) {
|
1584
1752
|
super();
|
1585
|
-
this.links = links;
|
1586
1753
|
this.tableNames = tableNames;
|
1587
1754
|
__privateAdd$2(this, _tables, {});
|
1588
1755
|
}
|
1589
1756
|
build(pluginOptions) {
|
1590
|
-
const links = this.links;
|
1591
1757
|
const db = new Proxy({}, {
|
1592
1758
|
get: (_target, table) => {
|
1593
1759
|
if (!isString(table))
|
1594
1760
|
throw new Error("Invalid table name");
|
1595
|
-
if (
|
1596
|
-
__privateGet$
|
1761
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1762
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1597
1763
|
}
|
1598
|
-
return __privateGet$
|
1764
|
+
return __privateGet$2(this, _tables)[table];
|
1599
1765
|
}
|
1600
1766
|
});
|
1601
1767
|
for (const table of this.tableNames ?? []) {
|
1602
|
-
db[table] = new RestRepository({ db, pluginOptions, table
|
1768
|
+
db[table] = new RestRepository({ db, pluginOptions, table });
|
1603
1769
|
}
|
1604
1770
|
return db;
|
1605
1771
|
}
|
@@ -1610,55 +1776,80 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
1610
1776
|
if (!member.has(obj))
|
1611
1777
|
throw TypeError("Cannot " + msg);
|
1612
1778
|
};
|
1779
|
+
var __privateGet$1 = (obj, member, getter) => {
|
1780
|
+
__accessCheck$1(obj, member, "read from private field");
|
1781
|
+
return getter ? getter.call(obj) : member.get(obj);
|
1782
|
+
};
|
1613
1783
|
var __privateAdd$1 = (obj, member, value) => {
|
1614
1784
|
if (member.has(obj))
|
1615
1785
|
throw TypeError("Cannot add the same private member more than once");
|
1616
1786
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1617
1787
|
};
|
1788
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
1789
|
+
__accessCheck$1(obj, member, "write to private field");
|
1790
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
1791
|
+
return value;
|
1792
|
+
};
|
1618
1793
|
var __privateMethod$1 = (obj, member, method) => {
|
1619
1794
|
__accessCheck$1(obj, member, "access private method");
|
1620
1795
|
return method;
|
1621
1796
|
};
|
1622
|
-
var _search, search_fn;
|
1797
|
+
var _schema, _search, search_fn, _getSchema, getSchema_fn;
|
1623
1798
|
class SearchPlugin extends XataPlugin {
|
1624
|
-
constructor(db
|
1799
|
+
constructor(db) {
|
1625
1800
|
super();
|
1626
1801
|
this.db = db;
|
1627
|
-
this.links = links;
|
1628
1802
|
__privateAdd$1(this, _search);
|
1803
|
+
__privateAdd$1(this, _getSchema);
|
1804
|
+
__privateAdd$1(this, _schema, void 0);
|
1629
1805
|
}
|
1630
1806
|
build({ getFetchProps }) {
|
1631
1807
|
return {
|
1632
1808
|
all: async (query, options = {}) => {
|
1633
1809
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1810
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1634
1811
|
return records.map((record) => {
|
1635
1812
|
const { table = "orphan" } = record.xata;
|
1636
|
-
return { table, record: initObject(this.db,
|
1813
|
+
return { table, record: initObject(this.db, schema, table, record) };
|
1637
1814
|
});
|
1638
1815
|
},
|
1639
1816
|
byTable: async (query, options = {}) => {
|
1640
1817
|
const records = await __privateMethod$1(this, _search, search_fn).call(this, query, options, getFetchProps);
|
1818
|
+
const schema = await __privateMethod$1(this, _getSchema, getSchema_fn).call(this, getFetchProps);
|
1641
1819
|
return records.reduce((acc, record) => {
|
1642
1820
|
const { table = "orphan" } = record.xata;
|
1643
1821
|
const items = acc[table] ?? [];
|
1644
|
-
const item = initObject(this.db,
|
1822
|
+
const item = initObject(this.db, schema, table, record);
|
1645
1823
|
return { ...acc, [table]: [...items, item] };
|
1646
1824
|
}, {});
|
1647
1825
|
}
|
1648
1826
|
};
|
1649
1827
|
}
|
1650
1828
|
}
|
1829
|
+
_schema = new WeakMap();
|
1651
1830
|
_search = new WeakSet();
|
1652
1831
|
search_fn = async function(query, options, getFetchProps) {
|
1653
1832
|
const fetchProps = await getFetchProps();
|
1654
|
-
const { tables, fuzziness } = options ?? {};
|
1833
|
+
const { tables, fuzziness, highlight } = options ?? {};
|
1655
1834
|
const { records } = await searchBranch({
|
1656
1835
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1657
|
-
body: { tables, query, fuzziness },
|
1836
|
+
body: { tables, query, fuzziness, highlight },
|
1658
1837
|
...fetchProps
|
1659
1838
|
});
|
1660
1839
|
return records;
|
1661
1840
|
};
|
1841
|
+
_getSchema = new WeakSet();
|
1842
|
+
getSchema_fn = async function(getFetchProps) {
|
1843
|
+
if (__privateGet$1(this, _schema))
|
1844
|
+
return __privateGet$1(this, _schema);
|
1845
|
+
const fetchProps = await getFetchProps();
|
1846
|
+
const { schema } = await getBranchDetails({
|
1847
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1848
|
+
...fetchProps
|
1849
|
+
});
|
1850
|
+
__privateSet$1(this, _schema, schema);
|
1851
|
+
return schema;
|
1852
|
+
};
|
1662
1853
|
|
1663
1854
|
const isBranchStrategyBuilder = (strategy) => {
|
1664
1855
|
return typeof strategy === "function";
|
@@ -1670,30 +1861,39 @@ const envBranchNames = [
|
|
1670
1861
|
"CF_PAGES_BRANCH",
|
1671
1862
|
"BRANCH"
|
1672
1863
|
];
|
1673
|
-
const defaultBranch = "main";
|
1674
1864
|
async function getCurrentBranchName(options) {
|
1675
|
-
const env =
|
1676
|
-
if (env)
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
return defaultBranch;
|
1865
|
+
const env = getBranchByEnvVariable();
|
1866
|
+
if (env) {
|
1867
|
+
const details = await getDatabaseBranch(env, options);
|
1868
|
+
if (details)
|
1869
|
+
return env;
|
1870
|
+
console.warn(`Branch ${env} not found in Xata. Ignoring...`);
|
1871
|
+
}
|
1872
|
+
const gitBranch = await getGitBranch();
|
1873
|
+
return resolveXataBranch(gitBranch, options);
|
1685
1874
|
}
|
1686
1875
|
async function getCurrentBranchDetails(options) {
|
1687
|
-
const
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1876
|
+
const branch = await getCurrentBranchName(options);
|
1877
|
+
return getDatabaseBranch(branch, options);
|
1878
|
+
}
|
1879
|
+
async function resolveXataBranch(gitBranch, options) {
|
1880
|
+
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1881
|
+
const apiKey = options?.apiKey || getAPIKey();
|
1882
|
+
if (!databaseURL)
|
1883
|
+
throw new Error("A databaseURL was not defined. Either set the XATA_DATABASE_URL env variable or pass the argument explicitely");
|
1884
|
+
if (!apiKey)
|
1885
|
+
throw new Error("An API key was not defined. Either set the XATA_API_KEY env variable or pass the argument explicitely");
|
1886
|
+
const [protocol, , host, , dbName] = databaseURL.split("/");
|
1887
|
+
const [workspace] = host.split(".");
|
1888
|
+
const { branch } = await resolveBranch({
|
1889
|
+
apiKey,
|
1890
|
+
apiUrl: databaseURL,
|
1891
|
+
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1892
|
+
workspacesApiUrl: `${protocol}//${host}`,
|
1893
|
+
pathParams: { dbName, workspace },
|
1894
|
+
queryParams: { gitBranch, fallbackBranch: getEnvVariable("XATA_FALLBACK_BRANCH") }
|
1895
|
+
});
|
1896
|
+
return branch;
|
1697
1897
|
}
|
1698
1898
|
async function getDatabaseBranch(branch, options) {
|
1699
1899
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
@@ -1711,10 +1911,7 @@ async function getDatabaseBranch(branch, options) {
|
|
1711
1911
|
apiUrl: databaseURL,
|
1712
1912
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1713
1913
|
workspacesApiUrl: `${protocol}//${host}`,
|
1714
|
-
pathParams: {
|
1715
|
-
dbBranchName,
|
1716
|
-
workspace
|
1717
|
-
}
|
1914
|
+
pathParams: { dbBranchName, workspace }
|
1718
1915
|
});
|
1719
1916
|
} catch (err) {
|
1720
1917
|
if (isObject(err) && err.status === 404)
|
@@ -1767,7 +1964,7 @@ var __privateMethod = (obj, member, method) => {
|
|
1767
1964
|
const buildClient = (plugins) => {
|
1768
1965
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1769
1966
|
return _a = class {
|
1770
|
-
constructor(options = {},
|
1967
|
+
constructor(options = {}, tables) {
|
1771
1968
|
__privateAdd(this, _parseOptions);
|
1772
1969
|
__privateAdd(this, _getFetchProps);
|
1773
1970
|
__privateAdd(this, _evaluateBranch);
|
@@ -1777,12 +1974,12 @@ const buildClient = (plugins) => {
|
|
1777
1974
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1778
1975
|
cache: safeOptions.cache
|
1779
1976
|
};
|
1780
|
-
const db = new SchemaPlugin(
|
1781
|
-
const search = new SearchPlugin(db
|
1977
|
+
const db = new SchemaPlugin(tables).build(pluginOptions);
|
1978
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
1782
1979
|
this.db = db;
|
1783
1980
|
this.search = search;
|
1784
1981
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1785
|
-
if (
|
1982
|
+
if (namespace === void 0)
|
1786
1983
|
continue;
|
1787
1984
|
const result = namespace.build(pluginOptions);
|
1788
1985
|
if (result instanceof Promise) {
|
@@ -1799,7 +1996,7 @@ const buildClient = (plugins) => {
|
|
1799
1996
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1800
1997
|
const apiKey = options?.apiKey || getAPIKey();
|
1801
1998
|
const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
|
1802
|
-
const branch = async () => options?.branch ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1999
|
+
const branch = async () => options?.branch !== void 0 ? await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, options.branch) : await getCurrentBranchName({ apiKey, databaseURL, fetchImpl: options?.fetch });
|
1803
2000
|
if (!databaseURL || !apiKey) {
|
1804
2001
|
throw new Error("Options databaseURL and apiKey are required");
|
1805
2002
|
}
|
@@ -1826,7 +2023,7 @@ const buildClient = (plugins) => {
|
|
1826
2023
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1827
2024
|
if (__privateGet(this, _branch))
|
1828
2025
|
return __privateGet(this, _branch);
|
1829
|
-
if (
|
2026
|
+
if (param === void 0)
|
1830
2027
|
return void 0;
|
1831
2028
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1832
2029
|
const evaluateBranch = async (strategy) => {
|
@@ -1851,5 +2048,5 @@ class XataError extends Error {
|
|
1851
2048
|
}
|
1852
2049
|
}
|
1853
2050
|
|
1854
|
-
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
2051
|
+
export { BaseClient, operationsByTag as Operations, PAGINATION_DEFAULT_OFFSET, PAGINATION_DEFAULT_SIZE, PAGINATION_MAX_OFFSET, PAGINATION_MAX_SIZE, Page, Query, RecordArray, Repository, RestRepository, SchemaPlugin, SearchPlugin, SimpleCache, XataApiClient, XataApiPlugin, XataError, XataPlugin, acceptWorkspaceMemberInvite, addGitBranchesEntry, addTableColumn, buildClient, bulkInsertTableRecords, cancelWorkspaceMemberInvite, contains, createBranch, createDatabase, createTable, createUserAPIKey, createWorkspace, deleteBranch, deleteColumn, deleteDatabase, deleteRecord, deleteTable, deleteUser, deleteUserAPIKey, deleteWorkspace, endsWith, executeBranchMigrationPlan, exists, ge, getAPIKey, getBranchDetails, getBranchList, getBranchMetadata, getBranchMigrationHistory, getBranchMigrationPlan, getBranchStats, getColumn, getCurrentBranchDetails, getCurrentBranchName, getDatabaseList, getDatabaseURL, getGitBranchesMapping, getRecord, getTableColumns, getTableSchema, getUser, getUserAPIKeys, getWorkspace, getWorkspaceMembersList, getWorkspacesList, gt, gte, includes, includesAll, includesAny, includesNone, insertRecord, insertRecordWithID, inviteWorkspaceMember, is, isCursorPaginationOptions, isIdentifiable, isNot, isXataRecord, le, lt, lte, notExists, operationsByTag, pattern, queryTable, removeGitBranchesEntry, removeWorkspaceMember, resendWorkspaceMemberInvite, resolveBranch, searchBranch, searchTable, setTableSchema, startsWith, updateBranchMetadata, updateColumn, updateRecordWithID, updateTable, updateUser, updateWorkspace, updateWorkspaceMemberRole, upsertRecordWithID };
|
1855
2052
|
//# sourceMappingURL=index.mjs.map
|