@xata.io/client 0.0.0-alpha.vfd071d9 → 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 +112 -0
- package/README.md +271 -1
- package/Usage.md +395 -0
- package/dist/index.cjs +423 -221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +397 -134
- package/dist/index.mjs +421 -222
- 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,83 +1080,88 @@ 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
|
-
for await (const [record] of this.getIterator(1)) {
|
1129
|
+
for await (const [record] of this.getIterator({ batchSize: 1 })) {
|
1052
1130
|
yield record;
|
1053
1131
|
}
|
1054
1132
|
}
|
1055
|
-
async *getIterator(
|
1056
|
-
|
1057
|
-
let
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1133
|
+
async *getIterator(options = {}) {
|
1134
|
+
const { batchSize = 1 } = options;
|
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;
|
1063
1142
|
}
|
1064
1143
|
}
|
1065
1144
|
async getMany(options = {}) {
|
1066
|
-
const
|
1067
|
-
|
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;
|
1068
1150
|
}
|
1069
|
-
async getAll(
|
1151
|
+
async getAll(options = {}) {
|
1152
|
+
const { batchSize = PAGINATION_MAX_SIZE, ...rest } = options;
|
1070
1153
|
const results = [];
|
1071
|
-
for await (const page of this.getIterator(
|
1154
|
+
for await (const page of this.getIterator({ ...rest, batchSize })) {
|
1072
1155
|
results.push(...page);
|
1073
1156
|
}
|
1074
1157
|
return results;
|
1075
1158
|
}
|
1076
1159
|
async getFirst(options = {}) {
|
1077
|
-
const records = await this.getMany({ ...options,
|
1078
|
-
return records[0]
|
1160
|
+
const records = await this.getMany({ ...options, pagination: { size: 1 } });
|
1161
|
+
return records[0] ?? null;
|
1079
1162
|
}
|
1080
1163
|
cache(ttl) {
|
1081
|
-
return new _Query(__privateGet$
|
1164
|
+
return new _Query(__privateGet$5(this, _repository), __privateGet$5(this, _table$1), { cache: ttl }, __privateGet$5(this, _data));
|
1082
1165
|
}
|
1083
1166
|
nextPage(size, offset) {
|
1084
1167
|
return this.firstPage(size, offset);
|
@@ -1087,10 +1170,10 @@ const _Query = class {
|
|
1087
1170
|
return this.firstPage(size, offset);
|
1088
1171
|
}
|
1089
1172
|
firstPage(size, offset) {
|
1090
|
-
return this.getPaginated({
|
1173
|
+
return this.getPaginated({ pagination: { size, offset } });
|
1091
1174
|
}
|
1092
1175
|
lastPage(size, offset) {
|
1093
|
-
return this.getPaginated({
|
1176
|
+
return this.getPaginated({ pagination: { size, offset, before: "end" } });
|
1094
1177
|
}
|
1095
1178
|
hasNextPage() {
|
1096
1179
|
return this.meta.page.more;
|
@@ -1100,12 +1183,20 @@ let Query = _Query;
|
|
1100
1183
|
_table$1 = new WeakMap();
|
1101
1184
|
_repository = new WeakMap();
|
1102
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
|
+
}
|
1103
1192
|
|
1104
1193
|
function isIdentifiable(x) {
|
1105
1194
|
return isObject(x) && isString(x?.id);
|
1106
1195
|
}
|
1107
1196
|
function isXataRecord(x) {
|
1108
|
-
|
1197
|
+
const record = x;
|
1198
|
+
const metadata = record?.getMetadata();
|
1199
|
+
return isIdentifiable(x) && isObject(metadata) && typeof metadata.version === "number";
|
1109
1200
|
}
|
1110
1201
|
|
1111
1202
|
function isSortFilterString(value) {
|
@@ -1135,7 +1226,7 @@ var __accessCheck$4 = (obj, member, msg) => {
|
|
1135
1226
|
if (!member.has(obj))
|
1136
1227
|
throw TypeError("Cannot " + msg);
|
1137
1228
|
};
|
1138
|
-
var __privateGet$
|
1229
|
+
var __privateGet$4 = (obj, member, getter) => {
|
1139
1230
|
__accessCheck$4(obj, member, "read from private field");
|
1140
1231
|
return getter ? getter.call(obj) : member.get(obj);
|
1141
1232
|
};
|
@@ -1144,7 +1235,7 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
1144
1235
|
throw TypeError("Cannot add the same private member more than once");
|
1145
1236
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1146
1237
|
};
|
1147
|
-
var __privateSet$
|
1238
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
1148
1239
|
__accessCheck$4(obj, member, "write to private field");
|
1149
1240
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1150
1241
|
return value;
|
@@ -1153,7 +1244,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
1153
1244
|
__accessCheck$4(obj, member, "access private method");
|
1154
1245
|
return method;
|
1155
1246
|
};
|
1156
|
-
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;
|
1157
1248
|
class Repository extends Query {
|
1158
1249
|
}
|
1159
1250
|
class RestRepository extends Query {
|
@@ -1170,21 +1261,43 @@ class RestRepository extends Query {
|
|
1170
1261
|
__privateAdd$4(this, _getCacheRecord);
|
1171
1262
|
__privateAdd$4(this, _setCacheQuery);
|
1172
1263
|
__privateAdd$4(this, _getCacheQuery);
|
1264
|
+
__privateAdd$4(this, _getSchema$1);
|
1173
1265
|
__privateAdd$4(this, _table, void 0);
|
1174
|
-
__privateAdd$4(this, _links, void 0);
|
1175
1266
|
__privateAdd$4(this, _getFetchProps, void 0);
|
1176
1267
|
__privateAdd$4(this, _cache, void 0);
|
1177
|
-
|
1178
|
-
__privateSet$
|
1179
|
-
__privateSet$
|
1268
|
+
__privateAdd$4(this, _schema$1, void 0);
|
1269
|
+
__privateSet$3(this, _table, options.table);
|
1270
|
+
__privateSet$3(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
1180
1271
|
this.db = options.db;
|
1181
|
-
__privateSet$
|
1272
|
+
__privateSet$3(this, _cache, options.pluginOptions.cache);
|
1182
1273
|
}
|
1183
1274
|
async create(a, b) {
|
1184
1275
|
if (Array.isArray(a)) {
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
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);
|
1188
1301
|
}
|
1189
1302
|
if (isString(a) && isObject(b)) {
|
1190
1303
|
if (a === "")
|
@@ -1207,26 +1320,38 @@ class RestRepository extends Query {
|
|
1207
1320
|
}
|
1208
1321
|
throw new Error("Invalid arguments for create method");
|
1209
1322
|
}
|
1210
|
-
async read(
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
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;
|
1224
1348
|
}
|
1225
|
-
throw e;
|
1226
1349
|
}
|
1227
1350
|
}
|
1228
1351
|
async update(a, b) {
|
1229
1352
|
if (Array.isArray(a)) {
|
1353
|
+
if (a.length === 0)
|
1354
|
+
return [];
|
1230
1355
|
if (a.length > 100) {
|
1231
1356
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1232
1357
|
}
|
@@ -1248,6 +1373,8 @@ class RestRepository extends Query {
|
|
1248
1373
|
}
|
1249
1374
|
async createOrUpdate(a, b) {
|
1250
1375
|
if (Array.isArray(a)) {
|
1376
|
+
if (a.length === 0)
|
1377
|
+
return [];
|
1251
1378
|
if (a.length > 100) {
|
1252
1379
|
console.warn("Bulk update operation is not optimized in the Xata API yet, this request might be slow");
|
1253
1380
|
}
|
@@ -1269,6 +1396,8 @@ class RestRepository extends Query {
|
|
1269
1396
|
}
|
1270
1397
|
async delete(a) {
|
1271
1398
|
if (Array.isArray(a)) {
|
1399
|
+
if (a.length === 0)
|
1400
|
+
return;
|
1272
1401
|
if (a.length > 100) {
|
1273
1402
|
console.warn("Bulk delete operation is not optimized in the Xata API yet, this request might be slow");
|
1274
1403
|
}
|
@@ -1288,13 +1417,19 @@ class RestRepository extends Query {
|
|
1288
1417
|
throw new Error("Invalid arguments for delete method");
|
1289
1418
|
}
|
1290
1419
|
async search(query, options = {}) {
|
1291
|
-
const fetchProps = await __privateGet$
|
1292
|
-
const { records } = await
|
1293
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1294
|
-
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
|
+
},
|
1295
1429
|
...fetchProps
|
1296
1430
|
});
|
1297
|
-
|
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));
|
1298
1433
|
}
|
1299
1434
|
async query(query) {
|
1300
1435
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
@@ -1303,34 +1438,35 @@ class RestRepository extends Query {
|
|
1303
1438
|
const data = query.getQueryOptions();
|
1304
1439
|
const body = {
|
1305
1440
|
filter: Object.values(data.filter ?? {}).some(Boolean) ? data.filter : void 0,
|
1306
|
-
sort: data.sort ? buildSortFilter(data.sort) : void 0,
|
1307
|
-
page: data.
|
1441
|
+
sort: data.sort !== void 0 ? buildSortFilter(data.sort) : void 0,
|
1442
|
+
page: data.pagination,
|
1308
1443
|
columns: data.columns
|
1309
1444
|
};
|
1310
|
-
const fetchProps = await __privateGet$
|
1445
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1311
1446
|
const { meta, records: objects } = await queryTable({
|
1312
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1447
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1313
1448
|
body,
|
1314
1449
|
...fetchProps
|
1315
1450
|
});
|
1316
|
-
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));
|
1317
1453
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
1318
1454
|
return new Page(query, meta, records);
|
1319
1455
|
}
|
1320
1456
|
}
|
1321
1457
|
_table = new WeakMap();
|
1322
|
-
_links = new WeakMap();
|
1323
1458
|
_getFetchProps = new WeakMap();
|
1324
1459
|
_cache = new WeakMap();
|
1460
|
+
_schema$1 = new WeakMap();
|
1325
1461
|
_insertRecordWithoutId = new WeakSet();
|
1326
1462
|
insertRecordWithoutId_fn = async function(object) {
|
1327
|
-
const fetchProps = await __privateGet$
|
1463
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1328
1464
|
const record = transformObjectLinks(object);
|
1329
1465
|
const response = await insertRecord({
|
1330
1466
|
pathParams: {
|
1331
1467
|
workspace: "{workspaceId}",
|
1332
1468
|
dbBranchName: "{dbBranch}",
|
1333
|
-
tableName: __privateGet$
|
1469
|
+
tableName: __privateGet$4(this, _table)
|
1334
1470
|
},
|
1335
1471
|
body: record,
|
1336
1472
|
...fetchProps
|
@@ -1343,13 +1479,13 @@ insertRecordWithoutId_fn = async function(object) {
|
|
1343
1479
|
};
|
1344
1480
|
_insertRecordWithId = new WeakSet();
|
1345
1481
|
insertRecordWithId_fn = async function(recordId, object) {
|
1346
|
-
const fetchProps = await __privateGet$
|
1482
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1347
1483
|
const record = transformObjectLinks(object);
|
1348
1484
|
const response = await insertRecordWithID({
|
1349
1485
|
pathParams: {
|
1350
1486
|
workspace: "{workspaceId}",
|
1351
1487
|
dbBranchName: "{dbBranch}",
|
1352
|
-
tableName: __privateGet$
|
1488
|
+
tableName: __privateGet$4(this, _table),
|
1353
1489
|
recordId
|
1354
1490
|
},
|
1355
1491
|
body: record,
|
@@ -1364,14 +1500,14 @@ insertRecordWithId_fn = async function(recordId, object) {
|
|
1364
1500
|
};
|
1365
1501
|
_bulkInsertTableRecords = new WeakSet();
|
1366
1502
|
bulkInsertTableRecords_fn = async function(objects) {
|
1367
|
-
const fetchProps = await __privateGet$
|
1503
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1368
1504
|
const records = objects.map((object) => transformObjectLinks(object));
|
1369
1505
|
const response = await bulkInsertTableRecords({
|
1370
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1506
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table) },
|
1371
1507
|
body: { records },
|
1372
1508
|
...fetchProps
|
1373
1509
|
});
|
1374
|
-
const finalObjects = await this.
|
1510
|
+
const finalObjects = await this.read(response.recordIDs);
|
1375
1511
|
if (finalObjects.length !== objects.length) {
|
1376
1512
|
throw new Error("The server failed to save some records");
|
1377
1513
|
}
|
@@ -1379,10 +1515,10 @@ bulkInsertTableRecords_fn = async function(objects) {
|
|
1379
1515
|
};
|
1380
1516
|
_updateRecordWithID = new WeakSet();
|
1381
1517
|
updateRecordWithID_fn = async function(recordId, object) {
|
1382
|
-
const fetchProps = await __privateGet$
|
1518
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1383
1519
|
const record = transformObjectLinks(object);
|
1384
1520
|
const response = await updateRecordWithID({
|
1385
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1521
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1386
1522
|
body: record,
|
1387
1523
|
...fetchProps
|
1388
1524
|
});
|
@@ -1393,9 +1529,9 @@ updateRecordWithID_fn = async function(recordId, object) {
|
|
1393
1529
|
};
|
1394
1530
|
_upsertRecordWithID = new WeakSet();
|
1395
1531
|
upsertRecordWithID_fn = async function(recordId, object) {
|
1396
|
-
const fetchProps = await __privateGet$
|
1532
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1397
1533
|
const response = await upsertRecordWithID({
|
1398
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1534
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1399
1535
|
body: object,
|
1400
1536
|
...fetchProps
|
1401
1537
|
});
|
@@ -1406,51 +1542,63 @@ upsertRecordWithID_fn = async function(recordId, object) {
|
|
1406
1542
|
};
|
1407
1543
|
_deleteRecord = new WeakSet();
|
1408
1544
|
deleteRecord_fn = async function(recordId) {
|
1409
|
-
const fetchProps = await __privateGet$
|
1545
|
+
const fetchProps = await __privateGet$4(this, _getFetchProps).call(this);
|
1410
1546
|
await deleteRecord({
|
1411
|
-
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$
|
1547
|
+
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}", tableName: __privateGet$4(this, _table), recordId },
|
1412
1548
|
...fetchProps
|
1413
1549
|
});
|
1414
1550
|
};
|
1415
1551
|
_invalidateCache = new WeakSet();
|
1416
1552
|
invalidateCache_fn = async function(recordId) {
|
1417
|
-
await __privateGet$
|
1418
|
-
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();
|
1419
1555
|
const queries = Object.entries(cacheItems).filter(([key]) => key.startsWith("query_"));
|
1420
1556
|
for (const [key, value] of queries) {
|
1421
1557
|
const ids = getIds(value);
|
1422
1558
|
if (ids.includes(recordId))
|
1423
|
-
await __privateGet$
|
1559
|
+
await __privateGet$4(this, _cache).delete(key);
|
1424
1560
|
}
|
1425
1561
|
};
|
1426
1562
|
_setCacheRecord = new WeakSet();
|
1427
1563
|
setCacheRecord_fn = async function(record) {
|
1428
|
-
if (!__privateGet$
|
1564
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1429
1565
|
return;
|
1430
|
-
await __privateGet$
|
1566
|
+
await __privateGet$4(this, _cache).set(`rec_${__privateGet$4(this, _table)}:${record.id}`, record);
|
1431
1567
|
};
|
1432
1568
|
_getCacheRecord = new WeakSet();
|
1433
1569
|
getCacheRecord_fn = async function(recordId) {
|
1434
|
-
if (!__privateGet$
|
1570
|
+
if (!__privateGet$4(this, _cache).cacheRecords)
|
1435
1571
|
return null;
|
1436
|
-
return __privateGet$
|
1572
|
+
return __privateGet$4(this, _cache).get(`rec_${__privateGet$4(this, _table)}:${recordId}`);
|
1437
1573
|
};
|
1438
1574
|
_setCacheQuery = new WeakSet();
|
1439
1575
|
setCacheQuery_fn = async function(query, meta, records) {
|
1440
|
-
await __privateGet$
|
1576
|
+
await __privateGet$4(this, _cache).set(`query_${__privateGet$4(this, _table)}:${query.key()}`, { date: new Date(), meta, records });
|
1441
1577
|
};
|
1442
1578
|
_getCacheQuery = new WeakSet();
|
1443
1579
|
getCacheQuery_fn = async function(query) {
|
1444
|
-
const key = `query_${__privateGet$
|
1445
|
-
const result = await __privateGet$
|
1580
|
+
const key = `query_${__privateGet$4(this, _table)}:${query.key()}`;
|
1581
|
+
const result = await __privateGet$4(this, _cache).get(key);
|
1446
1582
|
if (!result)
|
1447
1583
|
return null;
|
1448
|
-
const { cache: ttl = __privateGet$
|
1449
|
-
if (
|
1450
|
-
return
|
1584
|
+
const { cache: ttl = __privateGet$4(this, _cache).defaultQueryTTL } = query.getQueryOptions();
|
1585
|
+
if (ttl < 0)
|
1586
|
+
return null;
|
1451
1587
|
const hasExpired = result.date.getTime() + ttl < Date.now();
|
1452
1588
|
return hasExpired ? null : result;
|
1453
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
|
+
};
|
1454
1602
|
const transformObjectLinks = (object) => {
|
1455
1603
|
return Object.entries(object).reduce((acc, [key, value]) => {
|
1456
1604
|
if (key === "xata")
|
@@ -1458,15 +1606,34 @@ const transformObjectLinks = (object) => {
|
|
1458
1606
|
return { ...acc, [key]: isIdentifiable(value) ? value.id : value };
|
1459
1607
|
}, {});
|
1460
1608
|
};
|
1461
|
-
const initObject = (db,
|
1609
|
+
const initObject = (db, schema, table, object) => {
|
1462
1610
|
const result = {};
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
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
|
+
}
|
1470
1637
|
}
|
1471
1638
|
}
|
1472
1639
|
result.read = function() {
|
@@ -1478,7 +1645,10 @@ const initObject = (db, links, table, object) => {
|
|
1478
1645
|
result.delete = function() {
|
1479
1646
|
return db[table].delete(result["id"]);
|
1480
1647
|
};
|
1481
|
-
|
1648
|
+
result.getMetadata = function() {
|
1649
|
+
return xata;
|
1650
|
+
};
|
1651
|
+
for (const prop of ["read", "update", "delete", "getMetadata"]) {
|
1482
1652
|
Object.defineProperty(result, prop, { enumerable: false });
|
1483
1653
|
}
|
1484
1654
|
Object.freeze(result);
|
@@ -1498,7 +1668,7 @@ var __accessCheck$3 = (obj, member, msg) => {
|
|
1498
1668
|
if (!member.has(obj))
|
1499
1669
|
throw TypeError("Cannot " + msg);
|
1500
1670
|
};
|
1501
|
-
var __privateGet$
|
1671
|
+
var __privateGet$3 = (obj, member, getter) => {
|
1502
1672
|
__accessCheck$3(obj, member, "read from private field");
|
1503
1673
|
return getter ? getter.call(obj) : member.get(obj);
|
1504
1674
|
};
|
@@ -1507,7 +1677,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
1507
1677
|
throw TypeError("Cannot add the same private member more than once");
|
1508
1678
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1509
1679
|
};
|
1510
|
-
var __privateSet$
|
1680
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
1511
1681
|
__accessCheck$3(obj, member, "write to private field");
|
1512
1682
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
1513
1683
|
return value;
|
@@ -1516,30 +1686,30 @@ var _map;
|
|
1516
1686
|
class SimpleCache {
|
1517
1687
|
constructor(options = {}) {
|
1518
1688
|
__privateAdd$3(this, _map, void 0);
|
1519
|
-
__privateSet$
|
1689
|
+
__privateSet$2(this, _map, /* @__PURE__ */ new Map());
|
1520
1690
|
this.capacity = options.max ?? 500;
|
1521
1691
|
this.cacheRecords = options.cacheRecords ?? true;
|
1522
1692
|
this.defaultQueryTTL = options.defaultQueryTTL ?? 60 * 1e3;
|
1523
1693
|
}
|
1524
1694
|
async getAll() {
|
1525
|
-
return Object.fromEntries(__privateGet$
|
1695
|
+
return Object.fromEntries(__privateGet$3(this, _map));
|
1526
1696
|
}
|
1527
1697
|
async get(key) {
|
1528
|
-
return __privateGet$
|
1698
|
+
return __privateGet$3(this, _map).get(key) ?? null;
|
1529
1699
|
}
|
1530
1700
|
async set(key, value) {
|
1531
1701
|
await this.delete(key);
|
1532
|
-
__privateGet$
|
1533
|
-
if (__privateGet$
|
1534
|
-
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;
|
1535
1705
|
await this.delete(leastRecentlyUsed);
|
1536
1706
|
}
|
1537
1707
|
}
|
1538
1708
|
async delete(key) {
|
1539
|
-
__privateGet$
|
1709
|
+
__privateGet$3(this, _map).delete(key);
|
1540
1710
|
}
|
1541
1711
|
async clear() {
|
1542
|
-
return __privateGet$
|
1712
|
+
return __privateGet$3(this, _map).clear();
|
1543
1713
|
}
|
1544
1714
|
}
|
1545
1715
|
_map = new WeakMap();
|
@@ -1567,7 +1737,7 @@ var __accessCheck$2 = (obj, member, msg) => {
|
|
1567
1737
|
if (!member.has(obj))
|
1568
1738
|
throw TypeError("Cannot " + msg);
|
1569
1739
|
};
|
1570
|
-
var __privateGet$
|
1740
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1571
1741
|
__accessCheck$2(obj, member, "read from private field");
|
1572
1742
|
return getter ? getter.call(obj) : member.get(obj);
|
1573
1743
|
};
|
@@ -1578,26 +1748,24 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
1578
1748
|
};
|
1579
1749
|
var _tables;
|
1580
1750
|
class SchemaPlugin extends XataPlugin {
|
1581
|
-
constructor(
|
1751
|
+
constructor(tableNames) {
|
1582
1752
|
super();
|
1583
|
-
this.links = links;
|
1584
1753
|
this.tableNames = tableNames;
|
1585
1754
|
__privateAdd$2(this, _tables, {});
|
1586
1755
|
}
|
1587
1756
|
build(pluginOptions) {
|
1588
|
-
const links = this.links;
|
1589
1757
|
const db = new Proxy({}, {
|
1590
1758
|
get: (_target, table) => {
|
1591
1759
|
if (!isString(table))
|
1592
1760
|
throw new Error("Invalid table name");
|
1593
|
-
if (
|
1594
|
-
__privateGet$
|
1761
|
+
if (__privateGet$2(this, _tables)[table] === void 0) {
|
1762
|
+
__privateGet$2(this, _tables)[table] = new RestRepository({ db, pluginOptions, table });
|
1595
1763
|
}
|
1596
|
-
return __privateGet$
|
1764
|
+
return __privateGet$2(this, _tables)[table];
|
1597
1765
|
}
|
1598
1766
|
});
|
1599
1767
|
for (const table of this.tableNames ?? []) {
|
1600
|
-
db[table] = new RestRepository({ db, pluginOptions, table
|
1768
|
+
db[table] = new RestRepository({ db, pluginOptions, table });
|
1601
1769
|
}
|
1602
1770
|
return db;
|
1603
1771
|
}
|
@@ -1608,55 +1776,80 @@ var __accessCheck$1 = (obj, member, msg) => {
|
|
1608
1776
|
if (!member.has(obj))
|
1609
1777
|
throw TypeError("Cannot " + msg);
|
1610
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
|
+
};
|
1611
1783
|
var __privateAdd$1 = (obj, member, value) => {
|
1612
1784
|
if (member.has(obj))
|
1613
1785
|
throw TypeError("Cannot add the same private member more than once");
|
1614
1786
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
1615
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
|
+
};
|
1616
1793
|
var __privateMethod$1 = (obj, member, method) => {
|
1617
1794
|
__accessCheck$1(obj, member, "access private method");
|
1618
1795
|
return method;
|
1619
1796
|
};
|
1620
|
-
var _search, search_fn;
|
1797
|
+
var _schema, _search, search_fn, _getSchema, getSchema_fn;
|
1621
1798
|
class SearchPlugin extends XataPlugin {
|
1622
|
-
constructor(db
|
1799
|
+
constructor(db) {
|
1623
1800
|
super();
|
1624
1801
|
this.db = db;
|
1625
|
-
this.links = links;
|
1626
1802
|
__privateAdd$1(this, _search);
|
1803
|
+
__privateAdd$1(this, _getSchema);
|
1804
|
+
__privateAdd$1(this, _schema, void 0);
|
1627
1805
|
}
|
1628
1806
|
build({ getFetchProps }) {
|
1629
1807
|
return {
|
1630
1808
|
all: async (query, options = {}) => {
|
1631
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);
|
1632
1811
|
return records.map((record) => {
|
1633
1812
|
const { table = "orphan" } = record.xata;
|
1634
|
-
return { table, record: initObject(this.db,
|
1813
|
+
return { table, record: initObject(this.db, schema, table, record) };
|
1635
1814
|
});
|
1636
1815
|
},
|
1637
1816
|
byTable: async (query, options = {}) => {
|
1638
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);
|
1639
1819
|
return records.reduce((acc, record) => {
|
1640
1820
|
const { table = "orphan" } = record.xata;
|
1641
1821
|
const items = acc[table] ?? [];
|
1642
|
-
const item = initObject(this.db,
|
1822
|
+
const item = initObject(this.db, schema, table, record);
|
1643
1823
|
return { ...acc, [table]: [...items, item] };
|
1644
1824
|
}, {});
|
1645
1825
|
}
|
1646
1826
|
};
|
1647
1827
|
}
|
1648
1828
|
}
|
1829
|
+
_schema = new WeakMap();
|
1649
1830
|
_search = new WeakSet();
|
1650
1831
|
search_fn = async function(query, options, getFetchProps) {
|
1651
1832
|
const fetchProps = await getFetchProps();
|
1652
|
-
const { tables, fuzziness } = options ?? {};
|
1833
|
+
const { tables, fuzziness, highlight } = options ?? {};
|
1653
1834
|
const { records } = await searchBranch({
|
1654
1835
|
pathParams: { workspace: "{workspaceId}", dbBranchName: "{dbBranch}" },
|
1655
|
-
body: { tables, query, fuzziness },
|
1836
|
+
body: { tables, query, fuzziness, highlight },
|
1656
1837
|
...fetchProps
|
1657
1838
|
});
|
1658
1839
|
return records;
|
1659
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
|
+
};
|
1660
1853
|
|
1661
1854
|
const isBranchStrategyBuilder = (strategy) => {
|
1662
1855
|
return typeof strategy === "function";
|
@@ -1668,30 +1861,39 @@ const envBranchNames = [
|
|
1668
1861
|
"CF_PAGES_BRANCH",
|
1669
1862
|
"BRANCH"
|
1670
1863
|
];
|
1671
|
-
const defaultBranch = "main";
|
1672
1864
|
async function getCurrentBranchName(options) {
|
1673
|
-
const env =
|
1674
|
-
if (env)
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
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);
|
1683
1874
|
}
|
1684
1875
|
async function getCurrentBranchDetails(options) {
|
1685
|
-
const
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
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;
|
1695
1897
|
}
|
1696
1898
|
async function getDatabaseBranch(branch, options) {
|
1697
1899
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
@@ -1709,10 +1911,7 @@ async function getDatabaseBranch(branch, options) {
|
|
1709
1911
|
apiUrl: databaseURL,
|
1710
1912
|
fetchImpl: getFetchImplementation(options?.fetchImpl),
|
1711
1913
|
workspacesApiUrl: `${protocol}//${host}`,
|
1712
|
-
pathParams: {
|
1713
|
-
dbBranchName,
|
1714
|
-
workspace
|
1715
|
-
}
|
1914
|
+
pathParams: { dbBranchName, workspace }
|
1716
1915
|
});
|
1717
1916
|
} catch (err) {
|
1718
1917
|
if (isObject(err) && err.status === 404)
|
@@ -1765,7 +1964,7 @@ var __privateMethod = (obj, member, method) => {
|
|
1765
1964
|
const buildClient = (plugins) => {
|
1766
1965
|
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
1767
1966
|
return _a = class {
|
1768
|
-
constructor(options = {},
|
1967
|
+
constructor(options = {}, tables) {
|
1769
1968
|
__privateAdd(this, _parseOptions);
|
1770
1969
|
__privateAdd(this, _getFetchProps);
|
1771
1970
|
__privateAdd(this, _evaluateBranch);
|
@@ -1775,12 +1974,12 @@ const buildClient = (plugins) => {
|
|
1775
1974
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
1776
1975
|
cache: safeOptions.cache
|
1777
1976
|
};
|
1778
|
-
const db = new SchemaPlugin(
|
1779
|
-
const search = new SearchPlugin(db
|
1977
|
+
const db = new SchemaPlugin(tables).build(pluginOptions);
|
1978
|
+
const search = new SearchPlugin(db).build(pluginOptions);
|
1780
1979
|
this.db = db;
|
1781
1980
|
this.search = search;
|
1782
1981
|
for (const [key, namespace] of Object.entries(plugins ?? {})) {
|
1783
|
-
if (
|
1982
|
+
if (namespace === void 0)
|
1784
1983
|
continue;
|
1785
1984
|
const result = namespace.build(pluginOptions);
|
1786
1985
|
if (result instanceof Promise) {
|
@@ -1797,7 +1996,7 @@ const buildClient = (plugins) => {
|
|
1797
1996
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
1798
1997
|
const apiKey = options?.apiKey || getAPIKey();
|
1799
1998
|
const cache = options?.cache ?? new SimpleCache({ cacheRecords: false, defaultQueryTTL: 0 });
|
1800
|
-
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 });
|
1801
2000
|
if (!databaseURL || !apiKey) {
|
1802
2001
|
throw new Error("Options databaseURL and apiKey are required");
|
1803
2002
|
}
|
@@ -1824,7 +2023,7 @@ const buildClient = (plugins) => {
|
|
1824
2023
|
}, _evaluateBranch = new WeakSet(), evaluateBranch_fn = async function(param) {
|
1825
2024
|
if (__privateGet(this, _branch))
|
1826
2025
|
return __privateGet(this, _branch);
|
1827
|
-
if (
|
2026
|
+
if (param === void 0)
|
1828
2027
|
return void 0;
|
1829
2028
|
const strategies = Array.isArray(param) ? [...param] : [param];
|
1830
2029
|
const evaluateBranch = async (strategy) => {
|
@@ -1849,5 +2048,5 @@ class XataError extends Error {
|
|
1849
2048
|
}
|
1850
2049
|
}
|
1851
2050
|
|
1852
|
-
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 };
|
1853
2052
|
//# sourceMappingURL=index.mjs.map
|